diff options
author | StapleButter <thetotalworm@gmail.com> | 2018-11-04 23:21:58 +0100 |
---|---|---|
committer | StapleButter <thetotalworm@gmail.com> | 2018-11-04 23:21:58 +0100 |
commit | b4165cc0a907906440608b2023babed7a7e1f14e (patch) | |
tree | bde137e476efe23767424a9eefc7c1a0853e6d90 /src/ARM.cpp | |
parent | fb284f33ad6573be7a43bddb040c2573c67dba17 (diff) |
3D: keep the rasterizer from accidentally going out of bounds when given very flat X-major edge slopes.
this, by a fucking shitshow of butterfly effect, ends up fixing #234. technically, the rasterizer was going out of bounds, which, under certain circumstances, caused interpolation to shit itself and generate Z values that were out of range (but still ended up in the zbuffer). sometimes those values ended up negative, which caused these glitches when polygons had to be drawn over those.
about fucking time.
Diffstat (limited to 'src/ARM.cpp')
-rw-r--r-- | src/ARM.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/ARM.cpp b/src/ARM.cpp index 2368a1b..d71d0e1 100644 --- a/src/ARM.cpp +++ b/src/ARM.cpp @@ -157,6 +157,8 @@ void ARM::Reset() ExceptionBase = Num ? 0x00000000 : 0xFFFF0000; + CodeMem.Mem = NULL; + // zorp JumpTo(ExceptionBase); } @@ -180,6 +182,24 @@ void ARM::DoSavestate(Savestate* file) file->VarArray(NextInstr, 2*sizeof(u32)); file->Var32(&ExceptionBase); + + if (!file->Saving) + SetupCodeMem(R[15]); // should fix it +} + +void ARM::SetupCodeMem(u32 addr) +{ + if (!Num) + { + if (CP15::GetCodeMemRegion(addr, &CodeMem)) + return; + + NDS::ARM9GetMemRegion(addr, false, &CodeMem); + } + else + { + NDS::ARM7GetMemRegion(addr, false, &CodeMem); + } } void ARM::JumpTo(u32 addr, bool restorecpsr) @@ -196,20 +216,31 @@ void ARM::JumpTo(u32 addr, bool restorecpsr) //if (addr == 0x0201764C) printf("capture test %d: R1=%08X\n", R[6], R[1]); //if (addr == 0x020175D8) printf("capture test %d: res=%08X\n", R[6], R[0]); + u32 oldregion = R[15] >> 23; + u32 newregion = addr >> 23; +//if(!Num)printf("ARM%c branch from %08X to %08X. %03X->%03X\n", Num?'7':'9', R[15], addr, oldregion, newregion); if (addr & 0x1) { addr &= ~0x1; R[15] = addr+2; + + if (newregion != oldregion) SetupCodeMem(addr); + NextInstr[0] = CodeRead16(addr); NextInstr[1] = CodeRead16(addr+2); + CPSR |= 0x20; } else { addr &= ~0x3; R[15] = addr+4; + + if (newregion != oldregion) SetupCodeMem(addr); + NextInstr[0] = CodeRead32(addr); NextInstr[1] = CodeRead32(addr+4); + CPSR &= ~0x20; } } |