mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-24 14:49:53 -06:00
imma be real, i have no idea what is going on here
This commit is contained in:
38
src/ARM.cpp
38
src/ARM.cpp
@ -177,6 +177,8 @@ void ARM::Reset()
|
|||||||
|
|
||||||
ExceptionBase = Num ? 0x00000000 : 0xFFFF0000;
|
ExceptionBase = Num ? 0x00000000 : 0xFFFF0000;
|
||||||
|
|
||||||
|
BuggyJump = 0;
|
||||||
|
|
||||||
CodeMem.Mem = NULL;
|
CodeMem.Mem = NULL;
|
||||||
|
|
||||||
#ifdef JIT_ENABLED
|
#ifdef JIT_ENABLED
|
||||||
@ -284,6 +286,32 @@ void ARM::SetupCodeMem(u32 addr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ARMv5::BuggedJumpTo32(const u32 addr)
|
||||||
|
{
|
||||||
|
if (BuggyJump == 1)
|
||||||
|
{
|
||||||
|
BuggyJump = 2;
|
||||||
|
JumpTo(addr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
JumpTo(addr & ~0x1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ARMv5::BuggedJumpTo(const u32 addr)
|
||||||
|
{
|
||||||
|
if ((BuggyJump == 0) && (addr & 0x3))
|
||||||
|
{
|
||||||
|
BuggyJump = 1;
|
||||||
|
PrefetchAbort(); // checkme
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
JumpTo(addr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ARMv5::JumpTo(u32 addr, bool restorecpsr)
|
void ARMv5::JumpTo(u32 addr, bool restorecpsr)
|
||||||
{
|
{
|
||||||
if (restorecpsr)
|
if (restorecpsr)
|
||||||
@ -352,6 +380,16 @@ void ARMv5::JumpTo(u32 addr, bool restorecpsr)
|
|||||||
NDS.MonitorARM9Jump(addr);
|
NDS.MonitorARM9Jump(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ARMv4::BuggedJumpTo32(const u32 addr)
|
||||||
|
{
|
||||||
|
JumpTo(addr); // todo
|
||||||
|
}
|
||||||
|
|
||||||
|
void ARMv4::BuggedJumpTo(const u32 addr)
|
||||||
|
{
|
||||||
|
JumpTo(addr); // todo
|
||||||
|
}
|
||||||
|
|
||||||
void ARMv4::JumpTo(u32 addr, bool restorecpsr)
|
void ARMv4::JumpTo(u32 addr, bool restorecpsr)
|
||||||
{
|
{
|
||||||
if (restorecpsr)
|
if (restorecpsr)
|
||||||
|
13
src/ARM.h
13
src/ARM.h
@ -64,7 +64,9 @@ public:
|
|||||||
virtual void DoSavestate(Savestate* file);
|
virtual void DoSavestate(Savestate* file);
|
||||||
|
|
||||||
virtual void FillPipeline() = 0;
|
virtual void FillPipeline() = 0;
|
||||||
|
|
||||||
|
virtual void BuggedJumpTo32(const u32 addr) = 0;
|
||||||
|
virtual void BuggedJumpTo(const u32 addr) = 0;
|
||||||
virtual void JumpTo(u32 addr, bool restorecpsr = false) = 0;
|
virtual void JumpTo(u32 addr, bool restorecpsr = false) = 0;
|
||||||
void RestoreCPSR();
|
void RestoreCPSR();
|
||||||
|
|
||||||
@ -173,6 +175,7 @@ public:
|
|||||||
u32 R_UND[3];
|
u32 R_UND[3];
|
||||||
u32 CurInstr;
|
u32 CurInstr;
|
||||||
u32 NextInstr[2];
|
u32 NextInstr[2];
|
||||||
|
u32 BuggyJump;
|
||||||
|
|
||||||
u32 ExceptionBase;
|
u32 ExceptionBase;
|
||||||
|
|
||||||
@ -235,7 +238,9 @@ public:
|
|||||||
void UpdateRegionTimings(u32 addrstart, u32 addrend);
|
void UpdateRegionTimings(u32 addrstart, u32 addrend);
|
||||||
|
|
||||||
void FillPipeline() override;
|
void FillPipeline() override;
|
||||||
|
|
||||||
|
void BuggedJumpTo32(const u32 addr) override;
|
||||||
|
void BuggedJumpTo(const u32 addr) override;
|
||||||
void JumpTo(u32 addr, bool restorecpsr = false) override;
|
void JumpTo(u32 addr, bool restorecpsr = false) override;
|
||||||
|
|
||||||
void PrefetchAbort();
|
void PrefetchAbort();
|
||||||
@ -380,7 +385,9 @@ public:
|
|||||||
ARMv4(melonDS::NDS& nds, std::optional<GDBArgs> gdb, bool jit);
|
ARMv4(melonDS::NDS& nds, std::optional<GDBArgs> gdb, bool jit);
|
||||||
|
|
||||||
void FillPipeline() override;
|
void FillPipeline() override;
|
||||||
|
|
||||||
|
void BuggedJumpTo32(const u32 addr) override;
|
||||||
|
void BuggedJumpTo(const u32 addr) override;
|
||||||
void JumpTo(u32 addr, bool restorecpsr = false) override;
|
void JumpTo(u32 addr, bool restorecpsr = false) override;
|
||||||
|
|
||||||
void Execute() override;
|
void Execute() override;
|
||||||
|
@ -141,8 +141,8 @@ namespace melonDS::ARMInterpreter
|
|||||||
cpu->AddCycles_CDI(); \
|
cpu->AddCycles_CDI(); \
|
||||||
if (dataabort) return; \
|
if (dataabort) return; \
|
||||||
if (cpu->CurInstr & (1<<21)) cpu->R[(cpu->CurInstr>>16) & 0xF] = offset; \
|
if (cpu->CurInstr & (1<<21)) cpu->R[(cpu->CurInstr>>16) & 0xF] = offset; \
|
||||||
if (((cpu->CurInstr>>12) & 0xF) == 15) cpu->JumpTo(val); \
|
if (((cpu->CurInstr>>12) & 0xF) == 15) cpu->BuggedJumpTo(val); \
|
||||||
else cpu->R[(cpu->CurInstr>>12) & 0xF] = val; \
|
else cpu->R[(cpu->CurInstr>>12) & 0xF] = val;
|
||||||
|
|
||||||
// TODO: user mode (note: ldrbt w/ rd = 15 may be an undef instr)
|
// TODO: user mode (note: ldrbt w/ rd = 15 may be an undef instr)
|
||||||
#define A_LDRB_POST \
|
#define A_LDRB_POST \
|
||||||
@ -151,8 +151,8 @@ namespace melonDS::ARMInterpreter
|
|||||||
cpu->AddCycles_CDI(); \
|
cpu->AddCycles_CDI(); \
|
||||||
if (dataabort) return; \
|
if (dataabort) return; \
|
||||||
cpu->R[(cpu->CurInstr>>16) & 0xF] += offset; \
|
cpu->R[(cpu->CurInstr>>16) & 0xF] += offset; \
|
||||||
if (((cpu->CurInstr>>12) & 0xF) == 15) cpu->JumpTo(val); \
|
if (((cpu->CurInstr>>12) & 0xF) == 15) cpu->BuggedJumpTo(val); \
|
||||||
else cpu->R[(cpu->CurInstr>>12) & 0xF] = val; \
|
else cpu->R[(cpu->CurInstr>>12) & 0xF] = val;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -262,7 +262,7 @@ A_IMPLEMENT_WB_LDRSTR(LDRB)
|
|||||||
if (r&1) { A_UNK(cpu); return; } /* checkme */ \
|
if (r&1) { A_UNK(cpu); return; } /* checkme */ \
|
||||||
if (!cpu->DataRead32 (offset , &cpu->R[r ])) {cpu->AddCycles_CDI(); return;} \
|
if (!cpu->DataRead32 (offset , &cpu->R[r ])) {cpu->AddCycles_CDI(); return;} \
|
||||||
u32 val; if (!cpu->DataRead32S(offset+4, &val)) {cpu->AddCycles_CDI(); return;} \
|
u32 val; if (!cpu->DataRead32S(offset+4, &val)) {cpu->AddCycles_CDI(); return;} \
|
||||||
if (r == 14) A_UNK(cpu); /* checkme */ \
|
if (r == 14) cpu->BuggedJumpTo32(val); \
|
||||||
else cpu->R[r+1] = val; \
|
else cpu->R[r+1] = val; \
|
||||||
cpu->AddCycles_CDI(); \
|
cpu->AddCycles_CDI(); \
|
||||||
if (cpu->CurInstr & (1<<21)) cpu->R[(cpu->CurInstr>>16) & 0xF] = offset;
|
if (cpu->CurInstr & (1<<21)) cpu->R[(cpu->CurInstr>>16) & 0xF] = offset;
|
||||||
@ -274,7 +274,7 @@ A_IMPLEMENT_WB_LDRSTR(LDRB)
|
|||||||
if (r&1) { A_UNK(cpu); return; } /* checkme */ \
|
if (r&1) { A_UNK(cpu); return; } /* checkme */ \
|
||||||
if (!cpu->DataRead32 (addr , &cpu->R[r ])) {cpu->AddCycles_CDI(); return;} \
|
if (!cpu->DataRead32 (addr , &cpu->R[r ])) {cpu->AddCycles_CDI(); return;} \
|
||||||
u32 val; if (!cpu->DataRead32S(addr+4, &val)) {cpu->AddCycles_CDI(); return;} \
|
u32 val; if (!cpu->DataRead32S(addr+4, &val)) {cpu->AddCycles_CDI(); return;} \
|
||||||
if (r == 14) A_UNK(cpu); /* checkme */ \
|
if (r == 14) cpu->BuggedJumpTo32(val); \
|
||||||
else cpu->R[r+1] = val; \
|
else cpu->R[r+1] = val; \
|
||||||
cpu->AddCycles_CDI(); \
|
cpu->AddCycles_CDI(); \
|
||||||
cpu->R[(cpu->CurInstr>>16) & 0xF] += offset;
|
cpu->R[(cpu->CurInstr>>16) & 0xF] += offset;
|
||||||
@ -308,7 +308,7 @@ A_IMPLEMENT_WB_LDRSTR(LDRB)
|
|||||||
u32 val; bool dataabort = !cpu->DataRead16(offset, &val); \
|
u32 val; bool dataabort = !cpu->DataRead16(offset, &val); \
|
||||||
cpu->AddCycles_CDI(); \
|
cpu->AddCycles_CDI(); \
|
||||||
if (dataabort) return; \
|
if (dataabort) return; \
|
||||||
if (((cpu->CurInstr>>12) & 0xF) == 15) cpu->JumpTo(val); \
|
if (((cpu->CurInstr>>12) & 0xF) == 15) cpu->BuggedJumpTo(val); \
|
||||||
else cpu->R[(cpu->CurInstr>>12) & 0xF] = val; \
|
else cpu->R[(cpu->CurInstr>>12) & 0xF] = val; \
|
||||||
if (cpu->CurInstr & (1<<21)) cpu->R[(cpu->CurInstr>>16) & 0xF] = offset;
|
if (cpu->CurInstr & (1<<21)) cpu->R[(cpu->CurInstr>>16) & 0xF] = offset;
|
||||||
|
|
||||||
@ -317,7 +317,7 @@ A_IMPLEMENT_WB_LDRSTR(LDRB)
|
|||||||
u32 val; bool dataabort = !cpu->DataRead16(addr, &val); \
|
u32 val; bool dataabort = !cpu->DataRead16(addr, &val); \
|
||||||
cpu->AddCycles_CDI(); \
|
cpu->AddCycles_CDI(); \
|
||||||
if (dataabort) return; \
|
if (dataabort) return; \
|
||||||
if (((cpu->CurInstr>>12) & 0xF) == 15) cpu->JumpTo(val); \
|
if (((cpu->CurInstr>>12) & 0xF) == 15) cpu->BuggedJumpTo(val); \
|
||||||
else cpu->R[(cpu->CurInstr>>12) & 0xF] = val; \
|
else cpu->R[(cpu->CurInstr>>12) & 0xF] = val; \
|
||||||
cpu->R[(cpu->CurInstr>>16) & 0xF] += offset;
|
cpu->R[(cpu->CurInstr>>16) & 0xF] += offset;
|
||||||
|
|
||||||
@ -327,7 +327,7 @@ A_IMPLEMENT_WB_LDRSTR(LDRB)
|
|||||||
cpu->AddCycles_CDI(); \
|
cpu->AddCycles_CDI(); \
|
||||||
if (dataabort) return; \
|
if (dataabort) return; \
|
||||||
val = (s32)(s8)val; \
|
val = (s32)(s8)val; \
|
||||||
if (((cpu->CurInstr>>12) & 0xF) == 15) A_UNK(cpu); \
|
if (((cpu->CurInstr>>12) & 0xF) == 15) cpu->BuggedJumpTo(val); \
|
||||||
else cpu->R[(cpu->CurInstr>>12) & 0xF] = val; \
|
else cpu->R[(cpu->CurInstr>>12) & 0xF] = val; \
|
||||||
if (cpu->CurInstr & (1<<21)) cpu->R[(cpu->CurInstr>>16) & 0xF] = offset;
|
if (cpu->CurInstr & (1<<21)) cpu->R[(cpu->CurInstr>>16) & 0xF] = offset;
|
||||||
|
|
||||||
@ -337,7 +337,7 @@ A_IMPLEMENT_WB_LDRSTR(LDRB)
|
|||||||
cpu->AddCycles_CDI(); \
|
cpu->AddCycles_CDI(); \
|
||||||
if (dataabort) return; \
|
if (dataabort) return; \
|
||||||
val = (s32)(s8)val; \
|
val = (s32)(s8)val; \
|
||||||
if (((cpu->CurInstr>>12) & 0xF) == 15) A_UNK(cpu); \
|
if (((cpu->CurInstr>>12) & 0xF) == 15) cpu->BuggedJumpTo(val); \
|
||||||
else cpu->R[(cpu->CurInstr>>12) & 0xF] = val; \
|
else cpu->R[(cpu->CurInstr>>12) & 0xF] = val; \
|
||||||
cpu->R[(cpu->CurInstr>>16) & 0xF] += offset;
|
cpu->R[(cpu->CurInstr>>16) & 0xF] += offset;
|
||||||
|
|
||||||
@ -347,7 +347,7 @@ A_IMPLEMENT_WB_LDRSTR(LDRB)
|
|||||||
cpu->AddCycles_CDI(); \
|
cpu->AddCycles_CDI(); \
|
||||||
if (dataabort) return; \
|
if (dataabort) return; \
|
||||||
val = (s32)(s16)val; \
|
val = (s32)(s16)val; \
|
||||||
if (((cpu->CurInstr>>12) & 0xF) == 15) A_UNK(cpu); /* checkme */ \
|
if (((cpu->CurInstr>>12) & 0xF) == 15) cpu->BuggedJumpTo(val); \
|
||||||
else cpu->R[(cpu->CurInstr>>12) & 0xF] = val; \
|
else cpu->R[(cpu->CurInstr>>12) & 0xF] = val; \
|
||||||
if (cpu->CurInstr & (1<<21)) cpu->R[(cpu->CurInstr>>16) & 0xF] = offset;
|
if (cpu->CurInstr & (1<<21)) cpu->R[(cpu->CurInstr>>16) & 0xF] = offset;
|
||||||
|
|
||||||
@ -357,7 +357,7 @@ A_IMPLEMENT_WB_LDRSTR(LDRB)
|
|||||||
cpu->AddCycles_CDI(); \
|
cpu->AddCycles_CDI(); \
|
||||||
if (dataabort) return; \
|
if (dataabort) return; \
|
||||||
val = (s32)(s16)val; \
|
val = (s32)(s16)val; \
|
||||||
if (((cpu->CurInstr>>12) & 0xF) == 15) A_UNK(cpu); /* checkme */ \
|
if (((cpu->CurInstr>>12) & 0xF) == 15) cpu->BuggedJumpTo(val); \
|
||||||
else cpu->R[(cpu->CurInstr>>12) & 0xF] = val; \
|
else cpu->R[(cpu->CurInstr>>12) & 0xF] = val; \
|
||||||
cpu->R[(cpu->CurInstr>>16) & 0xF] += offset;
|
cpu->R[(cpu->CurInstr>>16) & 0xF] += offset;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user