diff --git a/include/n64dd.h b/include/n64dd.h index d2bf02c1c6..8c756ce692 100644 --- a/include/n64dd.h +++ b/include/n64dd.h @@ -3,16 +3,48 @@ #include "z64scene.h" +struct RegEditor; +struct SaveContext; + +// TODO Use the specific pointer types instead of void* +typedef struct n64ddStruct_800FF4B0_pointers { + void* unk_00; + void* unk_04; + struct RegEditor* unk_08; + void* unk_0C[31]; + struct SaveContext* unk_88; + void* unk_8C[9]; +} n64ddStruct_800FF4B0_pointers; // size = 0xB0 + +struct n64ddStruct_80121AF0; struct PlayState; typedef struct n64ddStruct_80121AF0 { - char unk_00[0x3C]; + void (*unk_00)(n64ddStruct_800FF4B0_pointers*, struct n64ddStruct_80121AF0*); + void (*unk_04)(void); + char unk_08[0x34]; void (*unk_3C)(void); void (*unk_40)(void); char unk_44[0x28]; void (*unk_6C)(struct PlayState*, SceneDrawConfigFunc*); } n64ddStruct_80121AF0; // size = ? +void func_800ADA80(void); +void func_800ADAF8(void); +n64ddStruct_80121AF0* func_800ADB30(n64ddStruct_80121AF0* arg0); +void func_800ADB8C(void); +n64ddStruct_800FF4B0_pointers* func_800ADBD0(void); +void func_800ADC00(void); +void func_800ADC08(s32 arg0, s32 arg1, s32 arg2); + +extern n64ddStruct_800FF4B0_pointers D_800FF4B0; extern n64ddStruct_80121AF0* B_80121AF0; +extern u8 B_80121AE0; +extern s8 B_80121AE1; +extern u8 B_80121AE2; + +extern char D_801DA410; // type ? +extern char D_801E8090; // type ? + #endif diff --git a/spec b/spec index b91d55a22a..fd724b9c61 100644 --- a/spec +++ b/spec @@ -656,6 +656,15 @@ beginseg include "$(BUILD_DIR)/data/rsp.rodata.o" endseg +#if PLATFORM_N64 +beginseg + // TODO + name "n64dd" + address 0x801C7740 + include "$(BUILD_DIR)/baserom/n64dd.o" +endseg +#endif + beginseg name "buffers" flags NOLOAD diff --git a/src/code/code_n64dd_800AD410.c b/src/code/code_n64dd_800AD410.c index 8b13789179..330b99bb59 100644 --- a/src/code/code_n64dd_800AD410.c +++ b/src/code/code_n64dd_800AD410.c @@ -1 +1,32 @@ +#include "ultra64.h" +#include "z64dma.h" +#include "segment_symbols.h" +#include "n64dd.h" +DECLARE_SEGMENT(n64dd) +DECLARE_ROM_SEGMENT(n64dd) +DECLARE_BSS_SEGMENT(n64dd) + +s8 func_801C7740_unknown(void); + +u8 B_80121AE0; +s8 B_80121AE1; +u8 B_80121AE2; + +void func_800ADA80(void) { + if (!B_80121AE0) { + DmaMgr_RequestSync(_n64ddSegmentStart, (uintptr_t)_n64ddSegmentRomStart, + _n64ddSegmentRomEnd - _n64ddSegmentRomStart); + // TODO use _n64ddSegmentBssStart, _n64ddSegmentBssEnd + bzero(&D_801DA410, &D_801E8090 - &D_801DA410); + B_80121AE0 = true; + B_80121AE1 = func_801C7740_unknown(); + if (B_80121AE1) {} + } +} + +void func_800ADAF8(void) { + if (B_80121AE0 && (B_80121AE2 == 0)) { + B_80121AE0 = false; + } +} diff --git a/src/code/code_n64dd_800AD4C0.c b/src/code/code_n64dd_800AD4C0.c index f75d79f5ef..858348d2bf 100644 --- a/src/code/code_n64dd_800AD4C0.c +++ b/src/code/code_n64dd_800AD4C0.c @@ -1,3 +1,90 @@ +#include "global.h" #include "n64dd.h" +// TODO functions of unknown prototype +extern char func_801C8510_unknown[]; +extern char func_800AE170_unknown[]; +extern char func_800ADCD8_unknown[]; +extern char osGetIntMask[]; +extern char osSetTime[]; + +n64ddStruct_800FF4B0_pointers D_800FF4B0 = { + func_801C8510_unknown, + NULL, + NULL, + Fault_RemoveClient, + Fault_AddClient, + func_800AE170_unknown, + func_800ADCD8_unknown, + Fault_AddHungupAndCrashImpl, + Fault_AddHungupAndCrash, + func_800ADC08, + _Printf, + osCreateThread, + osDestroyThread, + osYieldThread, + osStartThread, + osStopThread, + osGetThreadId, + osSetThreadPri, + osGetThreadPri, + osCreateMesgQueue, + osSendMesg, + osJamMesg, + osRecvMesg, + osSetEventMesg, + osGetIntMask, + osSetIntMask, + osInvalDCache, + osInvalICache, + osWritebackDCache, + osWritebackDCacheAll, + osGetTime, + osSetTime, + osSetTimer, + osStopTimer, + &gSaveContext, + DmaMgr_RequestAsync, + DmaMgr_RequestSync, + DmaMgr_DmaFromDriveRom, + Cutscene_HandleEntranceTriggers, + gSegments, + Flags_GetEventChkInf, + Flags_SetEventChkInf, + NULL, // TODO possibly file padding + NULL, +}; + n64ddStruct_80121AF0* B_80121AF0; + +n64ddStruct_80121AF0* func_800ADB30(n64ddStruct_80121AF0* arg0) { + n64ddStruct_800FF4B0_pointers* temp_a0 = func_800ADBD0(); + + if (arg0 != NULL && arg0->unk_00 != NULL) { + arg0->unk_00(temp_a0, arg0); + } + B_80121AF0 = arg0; + return B_80121AF0; +} + +void func_800ADB8C(void) { + if (B_80121AF0 != NULL) { + if (B_80121AF0->unk_04 != NULL) { + B_80121AF0->unk_04(); + } + } + B_80121AF0 = NULL; +} + +n64ddStruct_800FF4B0_pointers* func_800ADBD0(void) { + D_800FF4B0.unk_04 = 0; + D_800FF4B0.unk_08 = gRegEditor; + D_800FF4B0.unk_88 = &gSaveContext; + return &D_800FF4B0; +} + +void func_800ADC00(void) { +} + +void func_800ADC08(s32 arg0, s32 arg1, s32 arg2) { +} diff --git a/tools/disasm/ntsc-1.2/functions.txt b/tools/disasm/ntsc-1.2/functions.txt index 2a9b367e7e..75ffeb36b0 100644 --- a/tools/disasm/ntsc-1.2/functions.txt +++ b/tools/disasm/ntsc-1.2/functions.txt @@ -2304,13 +2304,13 @@ IrqMgr_HandlePreNMI500 = 0x800AD808; // type:func IrqMgr_HandleRetrace = 0x800AD82C; // type:func IrqMgr_ThreadEntry = 0x800AD8E4; // type:func IrqMgr_Init = 0x800AD9B8; // type:func -func_800ADA80_unknown = 0x800ADA80; // type:func -func_800ADAF8_unknown = 0x800ADAF8; // type:func -func_800ADB30_unknown = 0x800ADB30; // type:func -func_800ADB8C_unknown = 0x800ADB8C; // type:func -func_800ADBD0_unknown = 0x800ADBD0; // type:func -func_800ADC00_unknown = 0x800ADC00; // type:func -func_800ADC08_unknown = 0x800ADC08; // type:func +func_800ADA80 = 0x800ADA80; // type:func +func_800ADAF8 = 0x800ADAF8; // type:func +func_800ADB30 = 0x800ADB30; // type:func +func_800ADB8C = 0x800ADB8C; // type:func +func_800ADBD0 = 0x800ADBD0; // type:func +func_800ADC00 = 0x800ADC00; // type:func +func_800ADC08 = 0x800ADC08; // type:func Fault_SleepImpl = 0x800ADC20; // type:func func_800ADC5C_unknown = 0x800ADC5C; // type:func func_800ADCD8_unknown = 0x800ADCD8; // type:func @@ -3097,6 +3097,8 @@ Message_Init = 0x800E2660; // type:func Regs_InitDataImpl = 0x800E2704; // type:func Regs_InitData = 0x800E35D0; // type:func njpgdspMainTextStart = 0x800E7200; // type:func +func_801C7740_unknown = 0x801C7740; // type:func +func_801C8510_unknown = 0x801C8510; // type:func n64dd_SetDiskVersion = 0x801C8808; // type:func ConsoleLogo_Calc = 0x80800000; // type:func ConsoleLogo_SetupView = 0x8080009C; // type:func diff --git a/tools/disasm/ntsc-1.2/variables.txt b/tools/disasm/ntsc-1.2/variables.txt index 29faa9c929..b949848748 100644 --- a/tools/disasm/ntsc-1.2/variables.txt +++ b/tools/disasm/ntsc-1.2/variables.txt @@ -12,3 +12,13 @@ gSaveContext = 0x8011AC80; // size:0x1428 type:SaveContext gRegEditor = 0x8011C0B0; // size:0x4 type:RegEditor* gSegments = 0x80121508; // size:0x40 _string_n64dd_c = 0x801D9680; // size:0x1 type:char +B_80121AF0 = 0x80121AF0; // size:0x4 type:n64ddStruct_80121AF0* +B_80121AE0 = 0x80121AE0; // size:0x1 type:u8 +B_80121AE1 = 0x80121AE1; // size:0x1 type:s8 +B_80121AE2 = 0x80121AE2; // size:0x1 type:u8 +_n64ddSegmentStart = 0x801C7740; +_n64ddSegmentRomStart = 0x00B8ADA0; +_n64ddSegmentRomEnd = 0x00B9DA70; +D_801DA410 = 0x801DA410; +D_801E8090 = 0x801E8090; +D_800FF4B0 = 0x800FF4B0; // size:0xB0 type:n64ddStruct_800FF4B0_pointers diff --git a/undefined_syms.txt b/undefined_syms.txt index c6d194e0cb..10eb929100 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -16,4 +16,14 @@ D_06000000 = 0x06000000; func_80001720 = 0x80001720; osInitialize = 0x80003230; +// code_n64dd_800AD410.c +func_800ADCD8_unknown = 0x800ADCD8; +func_800AE170_unknown = 0x800AE170; +osGetIntMask = 0x800CFBB0; +osSetTime = 0x800D3660; +func_801C7740_unknown = 0x801C7740; +func_801C8510_unknown = 0x801C8510; +D_801DA410 = 0x801DA410; +D_801E8090 = 0x801E8090; + #endif