From bb46eade577a7e3bd3a8d2cc91c50c17b52e677d Mon Sep 17 00:00:00 2001 From: cadmic Date: Sat, 5 Oct 2024 14:08:15 -0700 Subject: [PATCH] Fix CPU offset comments (#59) --- include/emulator/cpu.h | 48 ++++++++++++++++------------------------- src/emulator/cpu.c | 49 +++++++++++++++++------------------------- 2 files changed, 39 insertions(+), 58 deletions(-) diff --git a/include/emulator/cpu.h b/include/emulator/cpu.h index 53c53e1..d83d367 100644 --- a/include/emulator/cpu.h +++ b/include/emulator/cpu.h @@ -284,23 +284,23 @@ struct Cpu { /* 0x00038 */ u32 nTickLast; /* 0x0003C */ u32 nRetrace; /* 0x00040 */ u32 nRetraceUsed; - /* 0x00044 */ CpuGpr aGPR[32]; - /* 0x00144 */ CpuFpr aFPR[32]; - /* 0x00244 */ u64 aTLB[48][5]; - /* 0x009C4 */ s32 anFCR[32]; - /* 0x00A44 */ s64 anCP0[32]; - /* 0x00B44 */ CpuExecuteFunc pfStep; - /* 0x00B48 */ CpuExecuteFunc pfJump; - /* 0x00B4C */ CpuExecuteFunc pfCall; - /* 0x00B50 */ CpuExecuteFunc pfIdle; - /* 0x00B54 */ CpuExecuteFunc pfRam; - /* 0x00B58 */ CpuExecuteFunc pfRamF; - /* 0x00B64 */ CpuDevice* apDevice[256]; - /* 0x00F64 */ u8 aiDevice[1 << DEVICE_ADDRESS_INDEX_BITS]; - /* 0x10F64 */ void* gHeap1; - /* 0x10F68 */ void* gHeap2; - /* 0x10F6C */ u32 aHeap1Flag[192]; - /* 0x1126C */ u32 aHeap2Flag[13]; + /* 0x00048 */ CpuGpr aGPR[32]; + /* 0x00148 */ CpuFpr aFPR[32]; + /* 0x00248 */ u64 aTLB[48][5]; + /* 0x009C8 */ s32 anFCR[32]; + /* 0x00A48 */ s64 anCP0[32]; + /* 0x00B48 */ CpuExecuteFunc pfStep; + /* 0x00B4C */ CpuExecuteFunc pfJump; + /* 0x00B50 */ CpuExecuteFunc pfCall; + /* 0x00B54 */ CpuExecuteFunc pfIdle; + /* 0x00B58 */ CpuExecuteFunc pfRam; + /* 0x00B5C */ CpuExecuteFunc pfRamF; + /* 0x00B60 */ CpuDevice* apDevice[256]; + /* 0x00F60 */ u8 aiDevice[1 << DEVICE_ADDRESS_INDEX_BITS]; + /* 0x10F60 */ void* gHeap1; + /* 0x10F64 */ void* gHeap2; + /* 0x10F68 */ u32 aHeap1Flag[192]; + /* 0x11268 */ u32 aHeap2Flag[13]; /* 0x1129C */ void* gHeapTree; /* 0x112A0 */ u32 aHeapTreeFlag[125]; /* 0x11494 */ CpuTreeRoot* gTree; @@ -310,20 +310,10 @@ struct Cpu { /* 0x1221C */ u32 nFlagRAM; /* 0x12220 */ u32 nFlagCODE; /* 0x12224 */ u32 nCompileFlag; - /* 0x12228 */ s32 unk_12228; - - //! TODO: fix match issue with OSAlarm - // /* 0x12230 */ OSAlarm alarmRetrace; - /* 0x12230 */ s32 alarmRetrace[12]; - - /* 0x1225C */ s32 unk_1225C; - /* 0x12260 */ s32 unk_12260; - /* 0x12264 */ s32 unk_12264; - /* 0x12268 */ s32 unk_12268; - /* 0x1226C */ s32 unk_1226C; + /* 0x12228 */ s32 unk_12228[18]; /* 0x12270 */ CpuOptimize nOptimize; /* 0x12298 */ s64 nTimeRetrace; - u8 pad[0x30]; + /* 0x122A0 */ u8 pad[0x30]; }; // size = 0x122D0 #define CPU_DEVICE(apDevice, aiDevice, nAddress) (apDevice[aiDevice[(u32)(nAddress) >> DEVICE_ADDRESS_OFFSET_BITS]]) diff --git a/src/emulator/cpu.c b/src/emulator/cpu.c index ca02757..4692d96 100644 --- a/src/emulator/cpu.c +++ b/src/emulator/cpu.c @@ -5837,35 +5837,26 @@ bool cpuReset(Cpu* pCPU) { } pCPU->nCompileFlag = 1; - pCPU->unk_12228 = 0; - - //! TODO: make this struct match - // pCPU->alarmRetrace.handler = NULL; - // pCPU->alarmRetrace.tag = 0; - // pCPU->alarmRetrace.end = 0; - // pCPU->alarmRetrace.prev = NULL; - // pCPU->alarmRetrace.next = NULL; - // pCPU->alarmRetrace.period = 0; - // pCPU->alarmRetrace.start = 0; - // pCPU->alarmRetrace.userData = NULL; - pCPU->alarmRetrace[0] = 0; - pCPU->alarmRetrace[1] = 0; - pCPU->alarmRetrace[2] = 0; - pCPU->alarmRetrace[3] = 0; - pCPU->alarmRetrace[4] = 0; - pCPU->alarmRetrace[5] = 0; - pCPU->alarmRetrace[6] = 0; - pCPU->alarmRetrace[7] = 0; - pCPU->alarmRetrace[8] = 0; - pCPU->alarmRetrace[9] = 0; - pCPU->alarmRetrace[10] = 0; - pCPU->alarmRetrace[11] = 0; - - pCPU->unk_1225C = 0; - pCPU->unk_12260 = 0; - pCPU->unk_12264 = 0; - pCPU->unk_12268 = 0; - pCPU->unk_1226C = 0; + + pCPU->unk_12228[0] = 0; + pCPU->unk_12228[1] = 0; + pCPU->unk_12228[2] = 0; + pCPU->unk_12228[3] = 0; + pCPU->unk_12228[4] = 0; + pCPU->unk_12228[5] = 0; + pCPU->unk_12228[6] = 0; + pCPU->unk_12228[7] = 0; + pCPU->unk_12228[8] = 0; + pCPU->unk_12228[9] = 0; + pCPU->unk_12228[10] = 0; + pCPU->unk_12228[11] = 0; + pCPU->unk_12228[12] = 0; + pCPU->unk_12228[13] = 0; + pCPU->unk_12228[14] = 0; + pCPU->unk_12228[15] = 0; + pCPU->unk_12228[16] = 0; + pCPU->unk_12228[17] = 0; + return true; }