diff --git a/asm/entrypoint.s b/asm/entrypoint.s index 0e10d93f..ebe6ff30 100644 --- a/asm/entrypoint.s +++ b/asm/entrypoint.s @@ -10,13 +10,11 @@ .section .text -# .word __BSS_SECTION_SIZE # Should equal 0x41490 - glabel entrypoint /* 001000 80000400 3C08800F */ lui $t0, %hi(gBssSectionStart) # $t0, 0x800f -/* 001004 80000404 3C090004 */ lui $t1, (0x41490 >> 16) # lui $t1, 4 +/* 001004 80000404 3C090004 */ lui $t1, %hi(__BSS_SECTION_SIZE) # lui $t1, 4 /* 001008 80000408 2508BF60 */ addiu $t0, %lo(gBssSectionStart) # addiu $t0, $t0, -0x40a0 -/* 00100C 8000040C 35291490 */ ori $t1, (0x41490 & 0xFFFF) # ori $t1, $t1, 0x1490 +/* 00100C 8000040C 35291490 */ ori $t1, %lo(__BSS_SECTION_SIZE) # ori $t1, $t1, 0x1490 .L80000410: /* 001010 80000410 2129FFF8 */ addi $t1, $t1, -8 /* 001014 80000414 AD000000 */ sw $zero, ($t0) diff --git a/include/unknown_003260.h b/include/unknown_003260.h index c322fff9..4a8e10d3 100644 --- a/include/unknown_003260.h +++ b/include/unknown_003260.h @@ -2,7 +2,9 @@ #define _UNKNOWN_003260_H_ #include "types.h" +#include "macros.h" #include "audio_internal.h" +#include "libultra_internal.h" typedef struct unk800DC6BC_40 { ALLink node; @@ -24,6 +26,40 @@ typedef struct unk800DC6BC { ALMicroTime curTime; } unk800DC6BC; //ALSndPlayer +typedef union { + ALEvent msg; + + struct{ + s16 type; + void* state; + u32 unk04; + }snd_event; + +}ALSndpEvent; + +typedef struct unk80119240 +{ + ALLink node; + u32 unk08; + u32 unk0C; + void* unk10; +} unk80119240; + +/* Unknown Size */ +/*typedef struct unk800DC6B0 { + ALLink node; + ALLink_s * unk08; +} unk800DC6B0; +*/ + +typedef struct audioMgrConfig_s{ + u32 unk00; + u32 unk04; + u32 maxChannels; + ALHeap *hp; + u16 unk10; +} audioMgrConfig; + extern s32 D_800DC680; extern s32 D_800DC684; extern s32 D_800DC688; diff --git a/lib/asm/exception/__osException.s b/lib/asm/exception/__osException.s index a6c15414..205dc3aa 100644 --- a/lib/asm/exception/__osException.s +++ b/lib/asm/exception/__osException.s @@ -11,15 +11,15 @@ glabel D_800E9670 .word 0x10101010 glabel D_800E9690 -.word 0x800D3168 -.word 0x800D3130 -.word 0x800D3110 -.word 0x800D2F74 -.word 0x800D2F20 -.word 0x800D30B4 -.word 0x800D2EE8 -.word 0x800D2EF4 -.word 0x800D2F00 +.word .L800D3168 +.word .L800D3130 +.word .L800D3110 +.word .L800D2F74 +.word .L800D2F20 +.word .L800D30B4 +.word .L800D2EE8 +.word .L800D2EF4 +.word .L800D2F00 .section .text @@ -167,12 +167,15 @@ glabel __osException /* 0D3ADC 800D2EDC 8C2A9690 */ lw $t2, %lo(D_800E9690)($at) /* 0D3AE0 800D2EE0 01400008 */ jr $t2 /* 0D3AE4 800D2EE4 00000000 */ nop +.L800D2EE8: /* 0D3AE8 800D2EE8 2401DFFF */ li $at, -8193 /* 0D3AEC 800D2EEC 1000FFF0 */ b .L800D2EB0 /* 0D3AF0 800D2EF0 02018024 */ and $s0, $s0, $at +.L800D2EF4: /* 0D3AF4 800D2EF4 2401BFFF */ li $at, -16385 /* 0D3AF8 800D2EF8 1000FFED */ b .L800D2EB0 /* 0D3AFC 800D2EFC 02018024 */ and $s0, $s0, $at +.L800D2F00: /* 0D3B00 800D2F00 40095800 */ mfc0 $t1, $11 /* 0D3B04 800D2F04 40895800 */ mtc0 $t1, $11 /* 0D3B08 800D2F08 0C034C79 */ jal send_mesg @@ -181,6 +184,7 @@ glabel __osException /* 0D3B14 800D2F14 34217FFF */ ori $at, (0xFFFF7FFF & 0xFFFF) # ori $at, $at, 0x7fff /* 0D3B18 800D2F18 1000FFE5 */ b .L800D2EB0 /* 0D3B1C 800D2F1C 02018024 */ and $s0, $s0, $at +.L800D2F20: /* 0D3B20 800D2F20 2401F7FF */ li $at, -2049 /* 0D3B24 800D2F24 02018024 */ and $s0, $s0, $at /* 0D3B28 800D2F28 240A0004 */ li $t2, 4 @@ -203,6 +207,7 @@ glabel __osException /* 0D3B68 800D2F68 00000000 */ nop /* 0D3B6C 800D2F6C 1000FFD0 */ b .L800D2EB0 /* 0D3B70 800D2F70 00000000 */ nop +.L800D2F74: /* 0D3B74 800D2F74 3C08800E */ lui $t0, %hi(D_800E38AC) # $t0, 0x800e /* 0D3B78 800D2F78 250838AC */ addiu $t0, %lo(D_800E38AC) # addiu $t0, $t0, 0x38ac /* 0D3B7C 800D2F7C 8D080000 */ lw $t0, ($t0) @@ -290,6 +295,7 @@ glabel __osException /* 0D3CA8 800D30A8 2401FBFF */ li $at, -1025 /* 0D3CAC 800D30AC 1000FF80 */ b .L800D2EB0 /* 0D3CB0 800D30B0 02018024 */ and $s0, $s0, $at +.L800D30B4: /* 0D3CB4 800D30B4 8F5B0118 */ lw $k1, 0x118($k0) /* 0D3CB8 800D30B8 2401EFFF */ li $at, -4097 /* 0D3CBC 800D30BC 3C09800E */ lui $t1, %hi(D_800E38A8) # $t1, 0x800e @@ -314,6 +320,7 @@ glabel __osException /* 0D3D04 800D3104 0361D824 */ and $k1, $k1, $at /* 0D3D08 800D3108 10000017 */ b .L800D3168 /* 0D3D0C 800D310C AD5B0118 */ sw $k1, 0x118($t2) +.L800D3110: /* 0D3D10 800D3110 2401FDFF */ li $at, -513 /* 0D3D14 800D3114 01014024 */ and $t0, $t0, $at /* 0D3D18 800D3118 40886800 */ mtc0 $t0, $13 @@ -322,6 +329,7 @@ glabel __osException /* 0D3D24 800D3124 2401FDFF */ li $at, -513 /* 0D3D28 800D3128 1000FF61 */ b .L800D2EB0 /* 0D3D2C 800D312C 02018024 */ and $s0, $s0, $at +.L800D3130: /* 0D3D30 800D3130 2401FEFF */ li $at, -257 /* 0D3D34 800D3134 01014024 */ and $t0, $t0, $at /* 0D3D38 800D3138 40886800 */ mtc0 $t0, $13 diff --git a/lib/src/osTimer.c b/lib/src/osTimer.c index cdc87fee..14615318 100644 --- a/lib/src/osTimer.c +++ b/lib/src/osTimer.c @@ -4,7 +4,8 @@ #include "macros.h" #include "libultra_internal.h" -OSTimer *D_800E4910 = (OSTimer *)0x8012D200; +extern OSTimer D_8012D200; +OSTimer *D_800E4910 = &D_8012D200; extern OSTime __osCurrentTime; extern u32 __osBaseCounter; diff --git a/lib/src/unknown_0CE200.c b/lib/src/unknown_0CE200.c index 757a3e77..3a244b91 100644 --- a/lib/src/unknown_0CE200.c +++ b/lib/src/unknown_0CE200.c @@ -3,6 +3,7 @@ #include "types.h" #include "macros.h" +#include "libultra_internal.h" s32 D_800E38D0 = 0; @@ -22,7 +23,8 @@ s32 viCounterMsg[6]; s32 D_8012D190[4]; s32 D_8012D1A0[16]; s32 D_8012D1E0[2]; -s32 piAccessQueue[14]; +s32 piAccessQueue[6]; +OSTimer D_8012D200; s32 __osCurrentTime; s32 D_8012D224; s32 __osBaseCounter; diff --git a/src/unknown_001050.c b/src/unknown_001050.c index c7296133..b4cdd6bd 100644 --- a/src/unknown_001050.c +++ b/src/unknown_001050.c @@ -135,6 +135,8 @@ void audio_init(u32 arg0){ u32 seq_max_len; u32 tmp2; audioMgrConfig audConfig; + + //*((s32*)0x803FFFFC) = 0xDEADBEEF; seq_max_len = 0; alHeapInit(&gALHeap, gBssSectionStart, 0x00029D88); diff --git a/src/unknown_003260.c b/src/unknown_003260.c index 1e6a5353..c4613031 100644 --- a/src/unknown_003260.c +++ b/src/unknown_003260.c @@ -3,11 +3,6 @@ #include "unknown_003260.h" -#include "types.h" -#include "macros.h" -#include "audio_internal.h" -#include "libultra_internal.h" - #define AL_SNDP_PLAY_EVT (1 << 0) #define AL_SNDP_STOP_EVT (1 << 1) #define AL_SNDP_PAN_EVT (1 << 2) @@ -21,39 +16,38 @@ extern void func_80002A98(void*); extern u32 D_80003008; -typedef union { - ALEvent msg; +/************ .bss ************/ - struct{ - s16 type; - void* state; - u32 unk04; - }snd_event; +// All of these are defined in unknown_003260_bss.c +// This was needed, since there is a bss reordering issue with D_80119BD0 and gAlSndPlayer -}ALSndpEvent; +extern s32 D_80115F90; +extern ALHeap* D_80115F94; +extern s32 D_80115F98[2]; +extern s32 D_80115FA0[3]; +extern OSThread audioThread; +extern OSMesgQueue OSMesgQueue_80116160; +extern OSMesg D_80116178[8]; +extern OSMesgQueue D_80116198; +extern OSMesg D_801161B0[8]; +extern ALGlobals ALGlobals_801161D0; +extern s32 D_80116220[3076]; +extern s32 D_80119230[3]; +extern unk80119240 D_80119240[50]; +extern s32 D_80119628; +extern s32 D_8011962C; +extern s32 D_80119630; +extern s32 D_80119634; +extern s32 D_80119638[2]; +extern s32 D_80119640[300]; +extern OSMesgQueue D_80119AF0; +extern OSMesg D_80119B08[50]; +extern unk800DC6BC D_80119BD0; +extern u16 *D_80119C28; -typedef struct unk80119240 -{ - ALLink node; - u32 unk08; - u32 unk0C; - void* unk10; -} unk80119240; +extern f32 D_80126170; -/* Unknown Size */ -/*typedef struct unk800DC6B0 { - ALLink node; - ALLink_s * unk08; -} unk800DC6B0; -*/ - -typedef struct audioMgrConfig_s{ - u32 unk00; - u32 unk04; - u32 maxChannels; - ALHeap* hp; - u16 unk10; -} audioMgrConfig; +/******************************/ /************ .data ************/ @@ -72,8 +66,8 @@ s32 D_800DC6AC = 0; // Currently unknown, might be a different type. s32 D_800DC6B0 = 0; // Currently unknown, might be a different type. s32 D_800DC6B4 = 0; // Currently unknown, might be a different type. -unk800DC6BC_40* D_800DC6B8 = NULL; -unk800DC6BC* gAlSndPlayer = (unk800DC6BC*)0x80119BD0; // What variable is 0x80119BD0? +unk800DC6BC_40 *D_800DC6B8 = NULL; +unk800DC6BC *gAlSndPlayer = &D_80119BD0; s32 sfxVolumeSlider = 0x100; s32 D_800DC6C4 = 0; // Currently unknown, might be a different type. @@ -97,35 +91,6 @@ const char D_800E4B80[] = "WARNING: Attempt to stop NULL sound aborted\n"; /*********************************/ -/************ .bss ************/ - -s32 D_80115F90; -ALHeap* D_80115F94; -s32 D_80115F98[2]; -s32 D_80115FA0[3]; -OSThread audioThread; -OSMesgQueue OSMesgQueue_80116160; -OSMesg D_80116178[8]; -OSMesgQueue D_80116198; -OSMesg D_801161B0[8]; -ALGlobals ALGlobals_801161D0; -s32 D_80116220[3076]; -s32 D_80119230[3]; -unk80119240 D_80119240[50]; -s32 D_80119628; -s32 D_8011962C; -s32 D_80119630; -s32 D_80119634; -s32 D_80119638[2]; -s32 D_80119640[300]; -OSMesgQueue D_80119AF0; -OSMesg D_80119B08[72]; -u16* D_80119C28; - -extern f32 D_80126170; - -/******************************/ - void *alHeapDBAlloc(u8 *, s32, ALHeap *, s32, s32); #if 1 @@ -196,7 +161,7 @@ void sfxSetVolumeSlider(u32 arg0) { if (arg0 > 256) { arg0 = 256; } - + sfxVolumeSlider = arg0; } diff --git a/src/unknown_003260_bss.c b/src/unknown_003260_bss.c new file mode 100644 index 00000000..ccf2a007 --- /dev/null +++ b/src/unknown_003260_bss.c @@ -0,0 +1,30 @@ +/* The comment below is needed for this file to be picked up by generate_ld */ +/* RAM_POS: 0x80002660 */ + +#include "unknown_003260.h" + +// This file is needed, since there is a bss reordering issue with D_80119BD0 and gAlSndPlayer + +s32 D_80115F90; +ALHeap* D_80115F94; +s32 D_80115F98[2]; +s32 D_80115FA0[3]; +OSThread audioThread; +OSMesgQueue OSMesgQueue_80116160; +OSMesg D_80116178[8]; +OSMesgQueue D_80116198; +OSMesg D_801161B0[8]; +ALGlobals ALGlobals_801161D0; +s32 D_80116220[3076]; +s32 D_80119230[3]; +unk80119240 D_80119240[50]; +s32 D_80119628; +s32 D_8011962C; +s32 D_80119630; +s32 D_80119634; +s32 D_80119638[2]; +s32 D_80119640[300]; +OSMesgQueue D_80119AF0; +OSMesg D_80119B08[50]; +unk800DC6BC D_80119BD0; +u16 *D_80119C28; diff --git a/tools/python/generate_ld.py b/tools/python/generate_ld.py index 568a1df7..220f4d04 100644 --- a/tools/python/generate_ld.py +++ b/tools/python/generate_ld.py @@ -134,7 +134,7 @@ class GenerateLD: self.gen_newline() def gen_bss_section(self): - self.gen_line('__BSS_SECTION_SIZE = SIZEOF(.bss.noload);') + self.gen_line('__BSS_SECTION_SIZE = SIZEOF(.bss.noload) - 0x10;') self.gen_newline() self.gen_line('.bss.noload . (NOLOAD): SUBALIGN(4)') self.gen_open_block()