Skip to content

Commit

Permalink
maple: clear mapleDmaOut on reset. Other reset issues
Browse files Browse the repository at this point in the history
mapleDmaOut wasn't reset, causing crashes or freezes in subsequent runs
Issue #1253

reset YUV state, pvr tile clip, MMU sq_remap, sh4 sq_buffer and more
  • Loading branch information
flyinghead committed Oct 20, 2023
1 parent eaf2c00 commit b7d923e
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions core/hw/maple/maple_if.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ void maple_Reset(bool hard)
SB_MSHTCL = 0;
SB_MDAPRO = 0x00007F00;
SB_MMSEL = 1;
mapleDmaOut.clear();
}

void maple_Term()
Expand Down
4 changes: 4 additions & 0 deletions core/hw/pvr/pvr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ void reset(bool hard)
tactx_Term();
elan::reset(hard);
if (hard)
{
ta_parse_reset();
YUV_reset();
taRenderPass = 0;
}
}

void init()
Expand Down
12 changes: 12 additions & 0 deletions core/hw/pvr/pvr_mem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,18 @@ void YUV_deserialize(Deserializer& deser)
YUV_index = 0;
}

void YUV_reset()
{
memset(YUV_tempdata, 0, sizeof(YUV_tempdata));
YUV_dest = 0;
YUV_blockcount = 0;
YUV_x_curr = 0;
YUV_y_curr = 0;
YUV_x_size = 0;
YUV_y_size = 0;
YUV_index = 0;
}

//vram 32-64b

//read
Expand Down
1 change: 1 addition & 0 deletions core/hw/pvr/pvr_mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ void DYNACALL TAWriteSQ(u32 address, const SQBuffer *sqb);
void YUV_init();
void YUV_serialize(Serializer& ser);
void YUV_deserialize(Deserializer& deser);
void YUV_reset();

// 32-bit vram path handlers
template<typename T> T DYNACALL pvr_read32p(u32 addr);
Expand Down
3 changes: 3 additions & 0 deletions core/hw/pvr/spg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ void spg_Reset(bool hard)
cpu_time_idx = 0;
cpu_cycles.fill(0);
real_times.fill(0.0);
maple_int_pending = false;
lightgun_line = 0xffff;
lightgun_hpos = 0;
}

void scheduleRenderDone(TA_context *cntx)
Expand Down
1 change: 1 addition & 0 deletions core/hw/pvr/ta_vtx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class BaseTAParser

static void reset()
{
tileclip_val = 0;
memset(FaceBaseColor, 0xff, sizeof(FaceBaseColor));
memset(FaceOffsColor, 0xff, sizeof(FaceOffsColor));
memset(FaceBaseColor1, 0xff, sizeof(FaceBaseColor1));
Expand Down
1 change: 1 addition & 0 deletions core/hw/sh4/modules/mmu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ void MMU_reset()
memset(ITLB, 0, sizeof(ITLB));
mmu_set_state();
mmu_flush_table();
memset(sq_remap, 0, sizeof(sq_remap));
}

void MMU_term()
Expand Down
1 change: 0 additions & 1 deletion core/hw/sh4/modules/mmu.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ struct TLB_Entry

extern TLB_Entry UTLB[64];
extern TLB_Entry ITLB[4];
extern u32 sq_remap[64];
extern bool mmuOn;

constexpr u32 fast_reg_lut[8] =
Expand Down
1 change: 1 addition & 0 deletions core/hw/sh4/sh4_mmr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@ void sh4_mmr_reset(bool hard)
ubc.reset();

MMU_reset();
memset(p_sh4rcb->sq_buffer, 0, sizeof(p_sh4rcb->sq_buffer));
}

void sh4_mmr_term()
Expand Down

0 comments on commit b7d923e

Please sign in to comment.