Skip to content

Commit 942df45

Browse files
authored
Match n64dd text in code (zeldaret#2058)
* match n64dd text * format * fixups * add n64dd segment using baserom * cleanup syms 1 * cleanup symbols 2 * cleanup D_800FF4B0 * fix declaration usage and linking for D_800FF4B0
1 parent ac2224f commit 942df45

File tree

7 files changed

+189
-8
lines changed

7 files changed

+189
-8
lines changed

include/n64dd.h

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,48 @@
33

44
#include "z64scene.h"
55

6+
struct RegEditor;
7+
struct SaveContext;
8+
9+
// TODO Use the specific pointer types instead of void*
10+
typedef struct n64ddStruct_800FF4B0_pointers {
11+
void* unk_00;
12+
void* unk_04;
13+
struct RegEditor* unk_08;
14+
void* unk_0C[31];
15+
struct SaveContext* unk_88;
16+
void* unk_8C[9];
17+
} n64ddStruct_800FF4B0_pointers; // size = 0xB0
18+
19+
struct n64ddStruct_80121AF0;
620
struct PlayState;
721

822
typedef struct n64ddStruct_80121AF0 {
9-
char unk_00[0x3C];
23+
void (*unk_00)(n64ddStruct_800FF4B0_pointers*, struct n64ddStruct_80121AF0*);
24+
void (*unk_04)(void);
25+
char unk_08[0x34];
1026
void (*unk_3C)(void);
1127
void (*unk_40)(void);
1228
char unk_44[0x28];
1329
void (*unk_6C)(struct PlayState*, SceneDrawConfigFunc*);
1430
} n64ddStruct_80121AF0; // size = ?
1531

32+
void func_800ADA80(void);
33+
void func_800ADAF8(void);
34+
n64ddStruct_80121AF0* func_800ADB30(n64ddStruct_80121AF0* arg0);
35+
void func_800ADB8C(void);
36+
n64ddStruct_800FF4B0_pointers* func_800ADBD0(void);
37+
void func_800ADC00(void);
38+
void func_800ADC08(s32 arg0, s32 arg1, s32 arg2);
39+
40+
extern n64ddStruct_800FF4B0_pointers D_800FF4B0;
1641
extern n64ddStruct_80121AF0* B_80121AF0;
1742

43+
extern u8 B_80121AE0;
44+
extern s8 B_80121AE1;
45+
extern u8 B_80121AE2;
46+
47+
extern char D_801DA410; // type ?
48+
extern char D_801E8090; // type ?
49+
1850
#endif

spec

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,15 @@ beginseg
656656
include "$(BUILD_DIR)/data/rsp.rodata.o"
657657
endseg
658658

659+
#if PLATFORM_N64
660+
beginseg
661+
// TODO
662+
name "n64dd"
663+
address 0x801C7740
664+
include "$(BUILD_DIR)/baserom/n64dd.o"
665+
endseg
666+
#endif
667+
659668
beginseg
660669
name "buffers"
661670
flags NOLOAD

src/code/code_n64dd_800AD410.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,32 @@
1+
#include "ultra64.h"
2+
#include "z64dma.h"
3+
#include "segment_symbols.h"
4+
#include "n64dd.h"
15

6+
DECLARE_SEGMENT(n64dd)
7+
DECLARE_ROM_SEGMENT(n64dd)
8+
DECLARE_BSS_SEGMENT(n64dd)
9+
10+
s8 func_801C7740_unknown(void);
11+
12+
u8 B_80121AE0;
13+
s8 B_80121AE1;
14+
u8 B_80121AE2;
15+
16+
void func_800ADA80(void) {
17+
if (!B_80121AE0) {
18+
DmaMgr_RequestSync(_n64ddSegmentStart, (uintptr_t)_n64ddSegmentRomStart,
19+
_n64ddSegmentRomEnd - _n64ddSegmentRomStart);
20+
// TODO use _n64ddSegmentBssStart, _n64ddSegmentBssEnd
21+
bzero(&D_801DA410, &D_801E8090 - &D_801DA410);
22+
B_80121AE0 = true;
23+
B_80121AE1 = func_801C7740_unknown();
24+
if (B_80121AE1) {}
25+
}
26+
}
27+
28+
void func_800ADAF8(void) {
29+
if (B_80121AE0 && (B_80121AE2 == 0)) {
30+
B_80121AE0 = false;
31+
}
32+
}

src/code/code_n64dd_800AD4C0.c

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,90 @@
1+
#include "global.h"
12
#include "n64dd.h"
23

4+
// TODO functions of unknown prototype
5+
extern char func_801C8510_unknown[];
6+
extern char func_800AE170_unknown[];
7+
extern char func_800ADCD8_unknown[];
8+
extern char osGetIntMask[];
9+
extern char osSetTime[];
10+
11+
n64ddStruct_800FF4B0_pointers D_800FF4B0 = {
12+
func_801C8510_unknown,
13+
NULL,
14+
NULL,
15+
Fault_RemoveClient,
16+
Fault_AddClient,
17+
func_800AE170_unknown,
18+
func_800ADCD8_unknown,
19+
Fault_AddHungupAndCrashImpl,
20+
Fault_AddHungupAndCrash,
21+
func_800ADC08,
22+
_Printf,
23+
osCreateThread,
24+
osDestroyThread,
25+
osYieldThread,
26+
osStartThread,
27+
osStopThread,
28+
osGetThreadId,
29+
osSetThreadPri,
30+
osGetThreadPri,
31+
osCreateMesgQueue,
32+
osSendMesg,
33+
osJamMesg,
34+
osRecvMesg,
35+
osSetEventMesg,
36+
osGetIntMask,
37+
osSetIntMask,
38+
osInvalDCache,
39+
osInvalICache,
40+
osWritebackDCache,
41+
osWritebackDCacheAll,
42+
osGetTime,
43+
osSetTime,
44+
osSetTimer,
45+
osStopTimer,
46+
&gSaveContext,
47+
DmaMgr_RequestAsync,
48+
DmaMgr_RequestSync,
49+
DmaMgr_DmaFromDriveRom,
50+
Cutscene_HandleEntranceTriggers,
51+
gSegments,
52+
Flags_GetEventChkInf,
53+
Flags_SetEventChkInf,
54+
NULL, // TODO possibly file padding
55+
NULL,
56+
};
57+
358
n64ddStruct_80121AF0* B_80121AF0;
59+
60+
n64ddStruct_80121AF0* func_800ADB30(n64ddStruct_80121AF0* arg0) {
61+
n64ddStruct_800FF4B0_pointers* temp_a0 = func_800ADBD0();
62+
63+
if (arg0 != NULL && arg0->unk_00 != NULL) {
64+
arg0->unk_00(temp_a0, arg0);
65+
}
66+
B_80121AF0 = arg0;
67+
return B_80121AF0;
68+
}
69+
70+
void func_800ADB8C(void) {
71+
if (B_80121AF0 != NULL) {
72+
if (B_80121AF0->unk_04 != NULL) {
73+
B_80121AF0->unk_04();
74+
}
75+
}
76+
B_80121AF0 = NULL;
77+
}
78+
79+
n64ddStruct_800FF4B0_pointers* func_800ADBD0(void) {
80+
D_800FF4B0.unk_04 = 0;
81+
D_800FF4B0.unk_08 = gRegEditor;
82+
D_800FF4B0.unk_88 = &gSaveContext;
83+
return &D_800FF4B0;
84+
}
85+
86+
void func_800ADC00(void) {
87+
}
88+
89+
void func_800ADC08(s32 arg0, s32 arg1, s32 arg2) {
90+
}

tools/disasm/ntsc-1.2/functions.txt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2304,13 +2304,13 @@ IrqMgr_HandlePreNMI500 = 0x800AD808; // type:func
23042304
IrqMgr_HandleRetrace = 0x800AD82C; // type:func
23052305
IrqMgr_ThreadEntry = 0x800AD8E4; // type:func
23062306
IrqMgr_Init = 0x800AD9B8; // type:func
2307-
func_800ADA80_unknown = 0x800ADA80; // type:func
2308-
func_800ADAF8_unknown = 0x800ADAF8; // type:func
2309-
func_800ADB30_unknown = 0x800ADB30; // type:func
2310-
func_800ADB8C_unknown = 0x800ADB8C; // type:func
2311-
func_800ADBD0_unknown = 0x800ADBD0; // type:func
2312-
func_800ADC00_unknown = 0x800ADC00; // type:func
2313-
func_800ADC08_unknown = 0x800ADC08; // type:func
2307+
func_800ADA80 = 0x800ADA80; // type:func
2308+
func_800ADAF8 = 0x800ADAF8; // type:func
2309+
func_800ADB30 = 0x800ADB30; // type:func
2310+
func_800ADB8C = 0x800ADB8C; // type:func
2311+
func_800ADBD0 = 0x800ADBD0; // type:func
2312+
func_800ADC00 = 0x800ADC00; // type:func
2313+
func_800ADC08 = 0x800ADC08; // type:func
23142314
Fault_SleepImpl = 0x800ADC20; // type:func
23152315
func_800ADC5C_unknown = 0x800ADC5C; // type:func
23162316
func_800ADCD8_unknown = 0x800ADCD8; // type:func
@@ -3097,6 +3097,8 @@ Message_Init = 0x800E2660; // type:func
30973097
Regs_InitDataImpl = 0x800E2704; // type:func
30983098
Regs_InitData = 0x800E35D0; // type:func
30993099
njpgdspMainTextStart = 0x800E7200; // type:func
3100+
func_801C7740_unknown = 0x801C7740; // type:func
3101+
func_801C8510_unknown = 0x801C8510; // type:func
31003102
n64dd_SetDiskVersion = 0x801C8808; // type:func
31013103
ConsoleLogo_Calc = 0x80800000; // type:func
31023104
ConsoleLogo_SetupView = 0x8080009C; // type:func

tools/disasm/ntsc-1.2/variables.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,13 @@ gSaveContext = 0x8011AC80; // size:0x1428 type:SaveContext
1212
gRegEditor = 0x8011C0B0; // size:0x4 type:RegEditor*
1313
gSegments = 0x80121508; // size:0x40
1414
_string_n64dd_c = 0x801D9680; // size:0x1 type:char
15+
B_80121AF0 = 0x80121AF0; // size:0x4 type:n64ddStruct_80121AF0*
16+
B_80121AE0 = 0x80121AE0; // size:0x1 type:u8
17+
B_80121AE1 = 0x80121AE1; // size:0x1 type:s8
18+
B_80121AE2 = 0x80121AE2; // size:0x1 type:u8
19+
_n64ddSegmentStart = 0x801C7740;
20+
_n64ddSegmentRomStart = 0x00B8ADA0;
21+
_n64ddSegmentRomEnd = 0x00B9DA70;
22+
D_801DA410 = 0x801DA410;
23+
D_801E8090 = 0x801E8090;
24+
D_800FF4B0 = 0x800FF4B0; // size:0xB0 type:n64ddStruct_800FF4B0_pointers

undefined_syms.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,14 @@ D_06000000 = 0x06000000;
1616
func_80001720 = 0x80001720;
1717
osInitialize = 0x80003230;
1818

19+
// code_n64dd_800AD410.c
20+
func_800ADCD8_unknown = 0x800ADCD8;
21+
func_800AE170_unknown = 0x800AE170;
22+
osGetIntMask = 0x800CFBB0;
23+
osSetTime = 0x800D3660;
24+
func_801C7740_unknown = 0x801C7740;
25+
func_801C8510_unknown = 0x801C8510;
26+
D_801DA410 = 0x801DA410;
27+
D_801E8090 = 0x801E8090;
28+
1929
#endif

0 commit comments

Comments
 (0)