diff --git a/Makefile b/Makefile index 91f11f04b8..c5bcc159ea 100644 --- a/Makefile +++ b/Makefile @@ -171,8 +171,8 @@ asm/non_matchings/%: asm/%.asm asm/%.asm: disasm ; -disasm: tables/files.txt tables/functions.txt tables/objects.txt tables/variables.txt tables/vrom_variables.txt tables/pre_boot_variables.txt - ./tools/disasm.py -d ./asm -u . -l ./tables/files.txt -f ./tables/functions.txt -o ./tables/objects.txt -v ./tables/variables.txt -v ./tables/vrom_variables.txt -v ./tables/pre_boot_variables.txt +disasm: tables/files.txt tables/functions.txt tables/objects.txt tables/variables.txt tables/vrom_variables.txt + ./tools/disasm.py -d ./asm -l ./tables/files.txt -f ./tables/functions.txt -o ./tables/objects.txt -v ./tables/variables.txt -v ./tables/vrom_variables.txt clean: rm -f $(ROM) $(UNCOMPRESSED_ROM) -r build asm diff --git a/include/pre_boot_variables.h b/include/pre_boot_variables.h deleted file mode 100644 index bec691ad8b..0000000000 --- a/include/pre_boot_variables.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef _PRE_BOOT_VARIABLES_H_ -#define _PRE_BOOT_VARIABLES_H_ - -#include - -extern UNK_TYPE osTvType; // D_80000300 -extern UNK_TYPE osRomType; // D_80000304 -extern UNK_TYPE osRomBase; // D_80000308 -extern UNK_TYPE osResetType; // D_8000030C -extern UNK_TYPE osCicId; // D_80000310 -extern UNK_TYPE osVersion; // D_80000314 -extern UNK_TYPE osMemSize; // D_80000318 -extern UNK_TYPE D_8000031C; // D_8000031C -extern UNK_TYPE D_80000500; // D_80000500 -extern UNK_TYPE D_80025D00; // D_80025D00 - -#endif diff --git a/include/sptask.h b/include/sptask.h index f2536b43bf..f9846ee827 100644 --- a/include/sptask.h +++ b/include/sptask.h @@ -3,6 +3,8 @@ #include +#define OS_YIELD_DATA_SIZE 0xC00 + typedef struct { /* 0x0 */ u32 type; /* 0x4 */ u32 flags; diff --git a/include/unk.h b/include/unk.h index 00893ab3e5..ffc24d3608 100644 --- a/include/unk.h +++ b/include/unk.h @@ -13,5 +13,6 @@ #define UNK_FUN_ARG void(*)(void) #define UNK_FUN_PTR(name) void(*name)(void) #define UNK_ARGS void +#define UNK_SIZE 1 #endif diff --git a/include/variables.h b/include/variables.h index 4f84130847..42efca03fd 100644 --- a/include/variables.h +++ b/include/variables.h @@ -5,7 +5,19 @@ #include #include #include -#include + +// pre-boot variables +extern UNK_TYPE osTvType; +extern UNK_TYPE osRomType; +extern UNK_TYPE osRomBase; +extern UNK_TYPE osResetType; +extern UNK_TYPE osCicId; +extern UNK_TYPE osVersion; +extern UNK_TYPE osMemSize; +extern s32 osAppNmiBuffer[0x10]; +extern u16 gFramebuffer1[SCREEN_HEIGHT][SCREEN_WIDTH]; // at 0x80000500 +extern u16 gFramebufferHighRes1[SCREEN_HEIGHT_HIGH_RES][SCREEN_WIDTH_HIGH_RES]; // at 0x80000500 +extern u8 D_80025D00[]; // data extern UNK_TYPE1 D_800969C0; @@ -4514,14 +4526,15 @@ extern OSMesg D_80203290[1]; // extern UNK_TYPE1 D_80208E98; // extern UNK_TYPE1 D_80208E99; // extern UNK_TYPE1 D_80208E9C; -// extern UNK_TYPE1 D_80208EA0; -// extern UNK_TYPE1 D_80209AA0; +extern u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE]; +extern u8 gGfxSPTaskStack[0x400]; extern GfxPool gGfxPools[2]; -extern u8 gAudioHeap[1277952]; -extern u32 gSystemHeap[1046224]; -extern u8 D_80780000[17920]; -extern u8 D_80784600[352768]; -extern u16 D_807DA800[76800]; +extern u8 gAudioHeap[0x138000]; +extern u32 gSystemHeap[UNK_SIZE]; +extern u16 gFramebufferHighRes0[SCREEN_HEIGHT_HIGH_RES][SCREEN_WIDTH_HIGH_RES]; // at 0x80780000 +extern u8 D_80780000[0x4600]; +extern u8 D_80784600[0x56200]; +extern u16 gFramebuffer0[SCREEN_HEIGHT][SCREEN_WIDTH]; // at 0x807DA800 #endif diff --git a/include/z64.h b/include/z64.h index ec9d602d72..fec555b48e 100644 --- a/include/z64.h +++ b/include/z64.h @@ -27,6 +27,12 @@ #include #include +#define SCREEN_WIDTH 320 +#define SCREEN_HEIGHT 240 + +#define SCREEN_WIDTH_HIGH_RES 576 +#define SCREEN_HEIGHT_HIGH_RES 454 + typedef struct { /* 0x0 */ s16 priority; // Lower means higher priority. -1 means it ignores priority /* 0x2 */ s16 length; diff --git a/linker_scripts/code_script.txt b/linker_scripts/code_script.txt index 73192bc798..190bd61c49 100644 --- a/linker_scripts/code_script.txt +++ b/linker_scripts/code_script.txt @@ -625,6 +625,23 @@ SECTIONS . += 0x24F00; code_bss_end = .; + buffers ALIGN(0x10): + { + build/src/buffers/gfxbuffers.o(.bss) + build/src/buffers/heaps.o(.bss) + } + + /* Framebuffers */ + gFramebuffer1 = 0x80000500; + gFramebuffer0 = 0x80800000 - 320*240*2; /* SCREEN_WIDTH*SCREEN_HEIGHT*sizeof(s16) */ + gFramebufferHighRes1 = 0x80000500; + gFramebufferHighRes0 = 0x80780000; + + /* Unkown buffers */ + D_80025D00 = 0x80025D00; /* Used in z_vr_box.c */ + D_80780000 = 0x80780000; + D_80784600 = 0x80784600; + . = 0x80800000; SegmentStart = .; _ovl_titleSegmentStart = SegmentStart; diff --git a/src/boot_O2_g3/idle.c b/src/boot_O2_g3/idle.c index f3c5f711c4..fdc330543f 100644 --- a/src/boot_O2_g3/idle.c +++ b/src/boot_O2_g3/idle.c @@ -27,9 +27,9 @@ void Idle_InitFramebuffer(u32* ptr, u32 numBytes, u32 value) { #endif void Idle_InitScreen(void) { - Idle_InitFramebuffer((u32*)&D_80000500, 0x25800, 0x00010001); + Idle_InitFramebuffer((u32*)&gFramebuffer1, 0x25800, 0x00010001); ViConfig_UpdateVi(0); - osViSwapBuffer(&D_80000500); + osViSwapBuffer(&gFramebuffer1); osViBlack(0); } @@ -37,7 +37,7 @@ void Idle_InitMemory(void) { u32 pad; void* memEnd = (void*)(0x80000000 + osMemSize); - Idle_ClearMemory((void*)0x80000400, &D_80000500); + Idle_ClearMemory((void*)0x80000400, &gFramebuffer1); Idle_ClearMemory(&D_80025D00, (int*)&boot_text_start); Idle_ClearMemory(&code_bss_end, memEnd); } diff --git a/src/buffers/gfxbuffers.c b/src/buffers/gfxbuffers.c new file mode 100644 index 0000000000..cb7e36be0b --- /dev/null +++ b/src/buffers/gfxbuffers.c @@ -0,0 +1,8 @@ +#include +#include + +u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE]; + +u8 gGfxSPTaskStack[0x400]; + +GfxPool gGfxPools[2]; diff --git a/src/buffers/heaps.c b/src/buffers/heaps.c new file mode 100644 index 0000000000..d35d0056e4 --- /dev/null +++ b/src/buffers/heaps.c @@ -0,0 +1,6 @@ +#include +#include + +u8 gAudioHeap[0x138000]; + +u32 gSystemHeap[UNK_SIZE]; diff --git a/src/libultra/os/initialize.c b/src/libultra/os/initialize.c index 9e50f26fa7..dd888fd730 100644 --- a/src/libultra/os/initialize.c +++ b/src/libultra/os/initialize.c @@ -48,7 +48,7 @@ void osInitialize(void) { D_80097E50 = (D_80097E50 * 3) / 4; if (osResetType == 0) { - _blkclr((u8*)&D_8000031C, 64); + _blkclr((u8*)&osAppNmiBuffer, 64); } if (osTvType == 0) { diff --git a/tables/pre_boot_variables.txt b/tables/pre_boot_variables.txt deleted file mode 100644 index 7dedaacebc..0000000000 --- a/tables/pre_boot_variables.txt +++ /dev/null @@ -1,13 +0,0 @@ -# Follows the format of Address:(Name, Type, Array Info, Size) -{ - 0x80000300:("osTvType","UNK_TYPE","",0x4), - 0x80000304:("osRomType","UNK_TYPE","",0x4), - 0x80000308:("osRomBase","UNK_TYPE","",0x4), - 0x8000030C:("osResetType","UNK_TYPE","",0x4), - 0x80000310:("osCicId","UNK_TYPE","",0x4), - 0x80000314:("osVersion","UNK_TYPE","",0x4), - 0x80000318:("osMemSize","UNK_TYPE","",0x4), - 0x8000031C:("D_8000031C","UNK_TYPE","",0x4), # TODO size - 0x80000500:("D_80000500","UNK_TYPE","",0x1), # TODO size - 0x80025D00:("D_80025D00","UNK_TYPE","",0x1), # TODO size -} \ No newline at end of file diff --git a/tables/variables.txt b/tables/variables.txt index b4779f2a63..ee64a32818 100644 --- a/tables/variables.txt +++ b/tables/variables.txt @@ -1,5 +1,15 @@ # Follows the format of Entry Point Address:(Name, Type, Array Info, Size) { + 0x80000300:("osTvType","UNK_TYPE","",0x4), + 0x80000304:("osRomType","UNK_TYPE","",0x4), + 0x80000308:("osRomBase","UNK_TYPE","",0x4), + 0x8000030C:("osResetType","UNK_TYPE","",0x4), + 0x80000310:("osCicId","UNK_TYPE","",0x4), + 0x80000314:("osVersion","UNK_TYPE","",0x4), + 0x80000318:("osMemSize","UNK_TYPE","",0x4), + 0x8000031C:("osAppNmiBuffer","s32","[0x10]",0x40), + 0x80000500:("gFramebuffer1","u16","[SCREEN_HEIGHT][SCREEN_WIDTH]",0x25800), + 0x80025D00:("D_80025D00","u8","[]",0x1), # TODO size 0x800969C0:("D_800969C0","UNK_TYPE1","",0x1), 0x80096B20:("D_80096B20","u8","",0x1), 0x80096B24:("gViConfigUseDefault","vu8","",0x1), @@ -4626,14 +4636,14 @@ 0x80208E98:("D_80208E98","UNK_TYPE1","",0x1), 0x80208E99:("D_80208E99","UNK_TYPE1","",0x1), 0x80208E9C:("D_80208E9C","UNK_TYPE1","",0x1), - 0x80208EA0:("D_80208EA0","UNK_TYPE1","",0x1), - 0x80209AA0:("D_80209AA0","UNK_TYPE1","",0x1), + 0x80208EA0:("gGfxSPTaskYieldBuffer","u8","[OS_YIELD_DATA_SIZE]",0xC00), + 0x80209AA0:("gGfxSPTaskStack","u8","[0x400]",0x400), 0x80209EA0:("gGfxPools","GfxPool","[2]",0x40620), - 0x8024A4C0:("gAudioHeap","u8","[1277952]",0x138000), - 0x803824C0:("gSystemHeap","u32","[1046224]",0x3fdb40), - 0x80780000:("D_80780000","u8","[17920]",0x4600), - 0x80784600:("D_80784600","u8","[352768]",0x56200), - 0x807DA800:("D_807DA800","u16","[76800]",0x25800), + 0x8024A4C0:("gAudioHeap","u8","[0x138000]",0x138000), + 0x803824C0:("gSystemHeap","u32","[UNK_SIZE]",0x3fdb40), + 0x80780000:("D_80780000","u8","[0x4600]",0x4600), + 0x80784600:("D_80784600","u8","[0x56200]",0x56200), + 0x807DA800:("gFramebuffer0","u16","[SCREEN_HEIGHT][SCREEN_WIDTH]",0x25800), 0x80800860:("titleRotation","s16","",0x2), 0x80800868:("D_80800868","UNK_TYPE1","",0x1), 0x80800870:("D_80800870","UNK_TYPE1","",0x1), diff --git a/undef.txt b/undef.txt index 06ede1c635..4fff589074 100644 --- a/undef.txt +++ b/undef.txt @@ -5,9 +5,7 @@ osResetType = 0x8000030C; osCicId = 0x80000310; osVersion = 0x80000314; osMemSize = 0x80000318; -D_8000031C = 0x8000031C; -D_80000500 = 0x80000500; -D_80025D00 = 0x80025D00; +osAppNmiBuffer = 0x8000031C; sBootThreadInfo = boot_bss_start + 0x00000000; sIdleThread = boot_bss_start + 0x00000020; sIdleThreadStack = boot_bss_start + 0x000001D0; @@ -793,14 +791,6 @@ D_80208E94 = code_bss_start + 0x00024EF4; D_80208E98 = code_bss_start + 0x00024EF8; D_80208E99 = code_bss_start + 0x00024EF9; D_80208E9C = code_bss_start + 0x00024EFC; -D_80208EA0 = code_bss_start + 0x00024F00; -D_80209AA0 = code_bss_start + 0x00025B00; -gGfxPools = code_bss_start + 0x00025F00; -gAudioHeap = code_bss_start + 0x00066520; -gSystemHeap = code_bss_start + 0x0019E520; -D_80780000 = code_bss_start + 0x0059C060; -D_80784600 = code_bss_start + 0x005A0660; -D_807DA800 = code_bss_start + 0x005F6860; D_80814E80 = ovl_file_choose_bss_start + 0x00000000; D_80814E90 = ovl_file_choose_bss_start + 0x00000010; D_8082DA50 = ovl_kaleido_scope_bss_start + 0x00000000;