From 8779aaa75875d17dded8605a4e1731de475f0760 Mon Sep 17 00:00:00 2001 From: Random <28494085+Random0666@users.noreply.github.com> Date: Fri, 20 Mar 2020 12:43:51 +0100 Subject: [PATCH] Decompiled various small files - Decompiled `code_8006C360.c` - Decompiled `prenmi_buf.c` (previously `code_8007BE60.c`) - Decompiled `code_8007BF10.c` - Documented `sys_ucode.c` --- asm/graph.s | 10 +-- .../code/code_8006C360/func_8006C360.s | 17 ---- .../code/code_8007BE60/func_8007BE60.s | 33 -------- .../code/code_8007BF10/func_8007BF10.s | 30 -------- asm/non_matchings/code/z_jpeg/func_8006DE30.s | 4 +- asm/non_matchings/code/z_room/func_80096B6C.s | 4 +- .../actors/ovl_kaleido_scope/func_8081D398.s | 4 +- data/code_8006C360.data.s | 11 --- include/functions.h | 14 ++-- include/sched.h | 6 +- include/variables.h | 2 +- include/z64.h | 8 ++ spec | 3 +- src/code/code_8006C360.c | 77 ++++++++++++++++++- src/code/code_8007BE60.c | 50 ------------ src/code/code_8007BF10.c | 20 ++++- src/code/main.c | 8 +- src/code/prenmi_buff.c | 35 +++++++++ src/code/sys_ucode.c | 8 +- src/code/z_room.c | 8 +- 20 files changed, 174 insertions(+), 178 deletions(-) delete mode 100644 asm/non_matchings/code/code_8006C360/func_8006C360.s delete mode 100644 asm/non_matchings/code/code_8007BE60/func_8007BE60.s delete mode 100644 asm/non_matchings/code/code_8007BF10/func_8007BF10.s delete mode 100644 data/code_8006C360.data.s delete mode 100644 src/code/code_8007BE60.c create mode 100644 src/code/prenmi_buff.c diff --git a/asm/graph.s b/asm/graph.s index 95e67955a..4ca4e63c4 100644 --- a/asm/graph.s +++ b/asm/graph.s @@ -539,13 +539,13 @@ glabel func_800C5DC0 /* B3D1A8 800C6008 24090001 */ li $t1, 1 /* B3D1AC 800C600C 240C0004 */ li $t4, 4 /* B3D1B0 800C6010 AE090000 */ sw $t1, ($s0) -/* B3D1B4 800C6014 0C034B7C */ jal func_800D2DF0 +/* B3D1B4 800C6014 0C034B7C */ jal SysUcode_GetUCodeBoot /* B3D1B8 800C6018 AE0C0004 */ sw $t4, 4($s0) -/* B3D1BC 800C601C 0C034B7F */ jal func_800D2DFC +/* B3D1BC 800C601C 0C034B7F */ jal SysUcode_GetUcodeBootSize /* B3D1C0 800C6020 AE020008 */ sw $v0, 8($s0) -/* B3D1C4 800C6024 0C034B85 */ jal func_800D2E14 +/* B3D1C4 800C6024 0C034B85 */ jal SysUcode_GetUcode /* B3D1C8 800C6028 AE02000C */ sw $v0, 0xc($s0) -/* B3D1CC 800C602C 0C034B88 */ jal func_800D2E20 +/* B3D1CC 800C602C 0C034B88 */ jal SysUcode_GetUcodeData /* B3D1D0 800C6030 AE020010 */ sw $v0, 0x10($s0) /* B3D1D4 800C6034 3C0F801B */ lui $t7, %hi(gGfxSPTaskStack) # $t7, 0x801b /* B3D1D8 800C6038 3C19801A */ lui $t9, %hi(gGfxSPTaskOutputBuffer) # $t9, 0x801a @@ -1056,7 +1056,7 @@ glabel func_800C61D8 .L800C67DC: /* B3D97C 800C67DC 10800014 */ beqz $a0, .L800C6830 /* B3D980 800C67E0 3C048016 */ lui $a0, %hi(gAppNmiBufferPtr) # $a0, 0x8016 -/* B3D984 800C67E4 0C01EFC2 */ jal func_8007BF08 +/* B3D984 800C67E4 0C01EFC2 */ jal PreNmiBuff_IsResetting /* B3D988 800C67E8 8C846660 */ lw $a0, %lo(gAppNmiBufferPtr)($a0) /* B3D98C 800C67EC 10400010 */ beqz $v0, .L800C6830 /* B3D990 800C67F0 8FAE00CC */ lw $t6, 0xcc($sp) diff --git a/asm/non_matchings/code/code_8006C360/func_8006C360.s b/asm/non_matchings/code/code_8006C360/func_8006C360.s deleted file mode 100644 index af861774b..000000000 --- a/asm/non_matchings/code/code_8006C360/func_8006C360.s +++ /dev/null @@ -1,17 +0,0 @@ -glabel func_8006C360 -/* AE3500 8006C360 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* AE3504 8006C364 AFBF0014 */ sw $ra, 0x14($sp) -/* AE3508 8006C368 0C023C20 */ jal func_8008F080 -/* AE350C 8006C36C AFA5001C */ sw $a1, 0x1c($sp) -/* AE3510 8006C370 8FAE001C */ lw $t6, 0x1c($sp) -/* AE3514 8006C374 0002C040 */ sll $t8, $v0, 1 -/* AE3518 8006C378 8FBF0014 */ lw $ra, 0x14($sp) -/* AE351C 8006C37C 000E78C0 */ sll $t7, $t6, 3 -/* AE3520 8006C380 01EE7821 */ addu $t7, $t7, $t6 -/* AE3524 8006C384 000F7840 */ sll $t7, $t7, 1 -/* AE3528 8006C388 01F8C821 */ addu $t9, $t7, $t8 -/* AE352C 8006C38C 3C028012 */ lui $v0, %hi(D_8011F3F0) -/* AE3530 8006C390 00591021 */ addu $v0, $v0, $t9 -/* AE3534 8006C394 9442F3F0 */ lhu $v0, %lo(D_8011F3F0)($v0) -/* AE3538 8006C398 03E00008 */ jr $ra -/* AE353C 8006C39C 27BD0018 */ addiu $sp, $sp, 0x18 \ No newline at end of file diff --git a/asm/non_matchings/code/code_8007BE60/func_8007BE60.s b/asm/non_matchings/code/code_8007BE60/func_8007BE60.s deleted file mode 100644 index beeb6015b..000000000 --- a/asm/non_matchings/code/code_8007BE60/func_8007BE60.s +++ /dev/null @@ -1,33 +0,0 @@ -glabel func_8007BE60 -/* AF3000 8007BE60 AC800000 */ sw $zero, ($a0) -/* AF3004 8007BE64 3C0E8000 */ lui $t6, %hi(osResetType) # $t6, 0x8000 -/* AF3008 8007BE68 8DCE030C */ lw $t6, %lo(osResetType)($t6) -/* AF300C 8007BE6C 24180000 */ li $t8, 0 -/* AF3010 8007BE70 24190000 */ li $t9, 0 -/* AF3014 8007BE74 55C00006 */ bnezl $t6, .L8007BE90 -/* AF3018 8007BE78 8C8F0004 */ lw $t7, 4($a0) -/* AF301C 8007BE7C AC800004 */ sw $zero, 4($a0) -/* AF3020 8007BE80 AC980008 */ sw $t8, 8($a0) -/* AF3024 8007BE84 1000000E */ b .L8007BEC0 -/* AF3028 8007BE88 AC99000C */ sw $t9, 0xc($a0) -/* AF302C 8007BE8C 8C8F0004 */ lw $t7, 4($a0) -.L8007BE90: -/* AF3030 8007BE90 8C8B000C */ lw $t3, 0xc($a0) -/* AF3034 8007BE94 8C8D0014 */ lw $t5, 0x14($a0) -/* AF3038 8007BE98 8C8A0008 */ lw $t2, 8($a0) -/* AF303C 8007BE9C 25E80001 */ addiu $t0, $t7, 1 -/* AF3040 8007BEA0 8C8C0010 */ lw $t4, 0x10($a0) -/* AF3044 8007BEA4 016D7821 */ addu $t7, $t3, $t5 -/* AF3048 8007BEA8 01ED082B */ sltu $at, $t7, $t5 -/* AF304C 8007BEAC 002A7021 */ addu $t6, $at, $t2 -/* AF3050 8007BEB0 01CC7021 */ addu $t6, $t6, $t4 -/* AF3054 8007BEB4 AC880004 */ sw $t0, 4($a0) -/* AF3058 8007BEB8 AC8E0008 */ sw $t6, 8($a0) -/* AF305C 8007BEBC AC8F000C */ sw $t7, 0xc($a0) -.L8007BEC0: -/* AF3060 8007BEC0 24180000 */ li $t8, 0 -/* AF3064 8007BEC4 24190000 */ li $t9, 0 -/* AF3068 8007BEC8 AC990014 */ sw $t9, 0x14($a0) -/* AF306C 8007BECC 03E00008 */ jr $ra -/* AF3070 8007BED0 AC980010 */ sw $t8, 0x10($a0) - diff --git a/asm/non_matchings/code/code_8007BF10/func_8007BF10.s b/asm/non_matchings/code/code_8007BF10/func_8007BF10.s deleted file mode 100644 index 658558825..000000000 --- a/asm/non_matchings/code/code_8007BF10/func_8007BF10.s +++ /dev/null @@ -1,30 +0,0 @@ -glabel func_8007BF10 -/* AF30B0 8007BF10 27BDFF60 */ addiu $sp, $sp, -0xa0 -/* AF30B4 8007BF14 AFBF0014 */ sw $ra, 0x14($sp) -/* AF30B8 8007BF18 27A40020 */ addiu $a0, $sp, 0x20 -/* AF30BC 8007BF1C 240E0003 */ li $t6, 3 -/* AF30C0 8007BF20 AFA00038 */ sw $zero, 0x38($sp) -/* AF30C4 8007BF24 AFAE0040 */ sw $t6, 0x40($sp) -/* AF30C8 8007BF28 AFA40088 */ sw $a0, 0x88($sp) -/* AF30CC 8007BF2C AFA0008C */ sw $zero, 0x8c($sp) -/* AF30D0 8007BF30 AFA00044 */ sw $zero, 0x44($sp) -/* AF30D4 8007BF34 AFA00048 */ sw $zero, 0x48($sp) -/* AF30D8 8007BF38 27A5001C */ addiu $a1, $sp, 0x1c -/* AF30DC 8007BF3C 0C001874 */ jal osCreateMesgQueue -/* AF30E0 8007BF40 24060001 */ li $a2, 1 -/* AF30E4 8007BF44 3C048016 */ lui $a0, %hi(gSchedContext+0x38) # $a0, 0x8016 -/* AF30E8 8007BF48 248466A0 */ addiu $a0, %lo(gSchedContext+0x38) # addiu $a0, $a0, 0x66a0 -/* AF30EC 8007BF4C 27A50038 */ addiu $a1, $sp, 0x38 -/* AF30F0 8007BF50 0C000C18 */ jal osSendMesg -/* AF30F4 8007BF54 24060001 */ li $a2, 1 -/* AF30F8 8007BF58 3C048016 */ lui $a0, %hi(gSchedContext) # $a0, 0x8016 -/* AF30FC 8007BF5C 0C03257E */ jal func_800C95F8 -/* AF3100 8007BF60 24846668 */ addiu $a0, %lo(gSchedContext) # addiu $a0, $a0, 0x6668 -/* AF3104 8007BF64 27A40020 */ addiu $a0, $sp, 0x20 -/* AF3108 8007BF68 00002825 */ move $a1, $zero -/* AF310C 8007BF6C 0C000CA0 */ jal osRecvMesg -/* AF3110 8007BF70 24060001 */ li $a2, 1 -/* AF3114 8007BF74 8FBF0014 */ lw $ra, 0x14($sp) -/* AF3118 8007BF78 27BD00A0 */ addiu $sp, $sp, 0xa0 -/* AF311C 8007BF7C 03E00008 */ jr $ra -/* AF3120 8007BF80 00000000 */ nop diff --git a/asm/non_matchings/code/z_jpeg/func_8006DE30.s b/asm/non_matchings/code/z_jpeg/func_8006DE30.s index 8e679d77a..84bfe49f7 100644 --- a/asm/non_matchings/code/z_jpeg/func_8006DE30.s +++ b/asm/non_matchings/code/z_jpeg/func_8006DE30.s @@ -25,10 +25,10 @@ glabel func_8006DE30 /* AE502C 8006DE8C 3C018012 */ lui $at, %hi(D_8011FA64) # $at, 0x8012 /* AE5030 8006DE90 AC20FA64 */ sw $zero, %lo(D_8011FA64)($at) /* AE5034 8006DE94 AFA40028 */ sw $a0, 0x28($sp) -/* AE5038 8006DE98 0C034B7C */ jal func_800D2DF0 +/* AE5038 8006DE98 0C034B7C */ jal SysUcode_GetUCodeBoot /* AE503C 8006DE9C AFA30024 */ sw $v1, 0x24($sp) /* AE5040 8006DEA0 3C018012 */ lui $at, %hi(D_8011FA68) # $at, 0x8012 -/* AE5044 8006DEA4 0C034B7F */ jal func_800D2DFC +/* AE5044 8006DEA4 0C034B7F */ jal SysUcode_GetUcodeBootSize /* AE5048 8006DEA8 AC22FA68 */ sw $v0, %lo(D_8011FA68)($at) /* AE504C 8006DEAC 8FA30024 */ lw $v1, 0x24($sp) /* AE5050 8006DEB0 8FA70028 */ lw $a3, 0x28($sp) diff --git a/asm/non_matchings/code/z_room/func_80096B6C.s b/asm/non_matchings/code/z_room/func_80096B6C.s index dd8e97821..d4ecbeac4 100644 --- a/asm/non_matchings/code/z_room/func_80096B6C.s +++ b/asm/non_matchings/code/z_room/func_80096B6C.s @@ -224,7 +224,7 @@ glabel func_80096B6C /* B0E010 80096E70 AE0A02C0 */ sw $t2, 0x2c0($s0) /* B0E014 80096E74 AF2B0000 */ sw $t3, ($t9) /* B0E018 80096E78 AFB90058 */ sw $t9, 0x58($sp) -/* B0E01C 80096E7C 0C034B88 */ jal func_800D2E20 +/* B0E01C 80096E7C 0C034B88 */ jal SysUcode_GetUcodeData /* B0E020 80096E80 AFA80048 */ sw $t0, 0x48($sp) /* B0E024 80096E84 8FA40058 */ lw $a0, 0x58($sp) /* B0E028 80096E88 3C0DDD00 */ lui $t5, (0xDD0007FF >> 16) # lui $t5, 0xdd00 @@ -234,7 +234,7 @@ glabel func_80096B6C /* B0E038 80096E98 246C0008 */ addiu $t4, $v1, 8 /* B0E03C 80096E9C AE0C02C0 */ sw $t4, 0x2c0($s0) /* B0E040 80096EA0 AC6D0000 */ sw $t5, ($v1) -/* B0E044 80096EA4 0C034B85 */ jal func_800D2E14 +/* B0E044 80096EA4 0C034B85 */ jal SysUcode_GetUcode /* B0E048 80096EA8 AFA30058 */ sw $v1, 0x58($sp) /* B0E04C 80096EAC 8FA40058 */ lw $a0, 0x58($sp) /* B0E050 80096EB0 8FA80048 */ lw $t0, 0x48($sp) diff --git a/asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_8081D398.s b/asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_8081D398.s index ab46640fb..ebf2d7cdd 100644 --- a/asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_8081D398.s +++ b/asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_8081D398.s @@ -620,13 +620,13 @@ glabel func_8081D398 /* 0A4BC 8081DCDC 8FB101CC */ lw $s1, 0x01CC($sp) /* 0A4C0 8081DCE0 26390008 */ addiu $t9, $s1, 0x0008 ## $t9 = 0C000008 /* 0A4C4 8081DCE4 AFB901CC */ sw $t9, 0x01CC($sp) -/* 0A4C8 8081DCE8 0C034B88 */ jal func_800D2E20 +/* 0A4C8 8081DCE8 0C034B88 */ jal SysUcode_GetUcodeData /* 0A4CC 8081DCEC AE320000 */ sw $s2, 0x0000($s1) ## 0C000000 /* 0A4D0 8081DCF0 AE220004 */ sw $v0, 0x0004($s1) ## 0C000004 /* 0A4D4 8081DCF4 8FB101CC */ lw $s1, 0x01CC($sp) /* 0A4D8 8081DCF8 262E0008 */ addiu $t6, $s1, 0x0008 ## $t6 = 0C000008 /* 0A4DC 8081DCFC AFAE01CC */ sw $t6, 0x01CC($sp) -/* 0A4E0 8081DD00 0C034B85 */ jal func_800D2E14 +/* 0A4E0 8081DD00 0C034B85 */ jal SysUcode_GetUcode /* 0A4E4 8081DD04 AE330000 */ sw $s3, 0x0000($s1) ## 0C000000 /* 0A4E8 8081DD08 AE220004 */ sw $v0, 0x0004($s1) ## 0C000004 /* 0A4EC 8081DD0C 8FB801CC */ lw $t8, 0x01CC($sp) diff --git a/data/code_8006C360.data.s b/data/code_8006C360.data.s deleted file mode 100644 index 20ab1ea6b..000000000 --- a/data/code_8006C360.data.s +++ /dev/null @@ -1,11 +0,0 @@ -.include "macro.inc" - -# assembler directives -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches -.set gp=64 # allow use of 64-bit general purposee registers - -.section .data - -glabel D_8011F3F0 - .incbin "baserom.z64", 0xB96590, 0x440 diff --git a/include/functions.h b/include/functions.h index 9a9e55a96..08b0a5b1a 100644 --- a/include/functions.h +++ b/include/functions.h @@ -921,9 +921,9 @@ u8 ZeldaArena_IsInitalized(); void MapMark_Init(GlobalContext* globalCtx); void MapMark_ClearPointers(GlobalContext* globalCtx); void MapMark_DrawConditionally(GlobalContext* globalCtx); -// ? func_8007BE60(?); -// ? func_8007BED4(?); -// ? func_8007BF08(?); +void PreNmiBuff_Init(PreNmiBuff* this); +void PreNmiBuff_SetReset(PreNmiBuff* this); +u32 PreNmiBuff_IsResetting(PreNmiBuff* this); // ? func_8007BF10(?); f32 func_8007BF90(Vec3f*, Vec3f*); // ? func_8007C028(?); @@ -1631,10 +1631,10 @@ void func_800D2264(MtxF* mf, Vec3s* vec, s32 flag); void func_800D23FC(f32 f, Vec3f* vec, u8 mode); MtxF* Matrix_CheckFloats(MtxF* mf, char* file, s32 line); void func_800D2CEC(Mtx* mtx, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6); -// ? func_800D2DF0(?); -// ? func_800D2DFC(?); -// ? func_800D2E14(?); -// ? func_800D2E20(?); +// ? SysUcode_GetUCodeBoot(?); +// ? SysUcode_GetUcodeBootSize(?); +// ? SysUcode_GetUcode(?); +// ? SysUcode_GetUcodeData(?); // ? func_800D2E30(?); // ? func_800D3140(?); // ? func_800D3140(?); diff --git a/include/sched.h b/include/sched.h index 423724d96..ece6bfdde 100644 --- a/include/sched.h +++ b/include/sched.h @@ -10,8 +10,8 @@ typedef struct OSScTask /* 0x08 */ u32 flags; /* 0x0C */ void* framebuffer; /* 0x10 */ OSTask list; - /* 0x58 */ OSMesgQueue* msgQ; - /* 0x5C */ OSMesg msg; + /* 0x50 */ OSMesgQueue* msgQ; + /* 0x54 */ OSMesg msg; } OSScTask; typedef struct @@ -39,4 +39,6 @@ typedef struct /* 0x0220 */ char unk_254[0x04]; } SchedContext; // size = 0x258 +extern SchedContext gSchedContext; + #endif diff --git a/include/variables.h b/include/variables.h index 868080bb8..b12c078d5 100644 --- a/include/variables.h +++ b/include/variables.h @@ -3573,7 +3573,7 @@ extern Color_RGBA8 D_801614B0; //extern ? D_801665E0; //extern ? D_801665F0; //extern ? D_80166648; -extern u8* gAppNmiBufferPtr; +extern PreNmiBuff* gAppNmiBufferPtr; //extern ? gSchedContext; //extern u8 gPadMgr[]; extern u8 D_80166B68; diff --git a/include/z64.h b/include/z64.h index 0e9d44487..025431cb4 100644 --- a/include/z64.h +++ b/include/z64.h @@ -1390,4 +1390,12 @@ typedef struct ListAlloc /* 0x04 */ struct ListAlloc* next; } ListAlloc; //size = 0x8 +typedef struct +{ + /* 0x00 */ u32 resetting; + /* 0x04 */ u32 resetCount; + /* 0x08 */ OSTime duration; + /* 0x10 */ OSTime resetTime; +} PreNmiBuff; //size = 0x18 (actually osAppNmiBuffer is 0x40 bytes large but the rest is unused) + #endif diff --git a/spec b/spec index d3f55e986..5b8caf7eb 100644 --- a/spec +++ b/spec @@ -316,7 +316,6 @@ beginseg include "build/src/code/z_elf_message.o" include "build/data/z_elf_message.data.o" include "build/src/code/code_8006C360.o" - include "build/data/code_8006C360.data.o" include "build/src/code/code_8006C3A0.o" include "build/src/code/code_8006C510.o" include "build/src/code/z_fcurve_data_skelanime.o" @@ -340,7 +339,7 @@ beginseg include "build/src/code/z_malloc.o" include "build/src/code/z_map_mark.o" include "build/src/code/z_moji.o" - include "build/src/code/code_8007BE60.o" + include "build/src/code/prenmi_buff.o" include "build/src/code/code_8007BF10.o" include "build/src/code/code_8007BF90.o" include "build/src/code/z_onepointdemo.o" diff --git a/src/code/code_8006C360.c b/src/code/code_8006C360.c index 3180bab89..3551ed172 100644 --- a/src/code/code_8006C360.c +++ b/src/code/code_8006C360.c @@ -1,5 +1,80 @@ #include #include -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8006C360/func_8006C360.s") +//#pragma GLOBAL_ASM("asm/non_matchings/code/code_8006C360/func_8006C360.s") + +typedef struct +{ + u16 data[9]; +} struct_8011F3F0; // size = 0x12 + +struct_8011F3F0 D_8011F3F0[60] = +{ + { { 0x0000, 0x7124, 0x7127, 0x7126, 0x7125, 0x7127, 0x7124, 0x7125, 0x7127 } }, + { { 0x0000, 0x7128, 0x7129, 0x7128, 0x7128, 0x7128, 0x7128, 0x712A, 0x712B } }, + { { 0x0000, 0x7128, 0x712B, 0x7128, 0x7128, 0x7129, 0x7128, 0x712B, 0x7128 } }, + { { 0x0000, 0x7128, 0x7129, 0x7128, 0x7128, 0x7128, 0x7128, 0x712A, 0x712B } }, + { { 0x0000, 0x7128, 0x7129, 0x712B, 0x7128, 0x7128, 0x7128, 0x7129, 0x7128 } }, + { { 0x0000, 0x712D, 0x712D, 0x712D, 0x712D, 0x712D, 0x712D, 0x712D, 0x712F } }, + { { 0x0000, 0x712C, 0x712C, 0x712C, 0x712E, 0x712C, 0x712C, 0x712F, 0x712F } }, + { { 0x0000, 0x712C, 0x712C, 0x712C, 0x712F, 0x712C, 0x712C, 0x712F, 0x712F } }, + { { 0x0000, 0x7130, 0x7132, 0x7133, 0x7130, 0x7130, 0x7131, 0x7132, 0x7131 } }, + { { 0x0000, 0x7134, 0x7137, 0x7135, 0x7134, 0x7136, 0x7135, 0x7134, 0x7135 } }, + { { 0x0000, 0x7138, 0x713A, 0x7138, 0x7139, 0x713A, 0x7138, 0x7139, 0x713B } }, + { { 0x0000, 0x7144, 0x7146, 0x7144, 0x7146, 0x7147, 0x7145, 0x7145, 0x7147 } }, + { { 0x0000, 0x7148, 0x7149, 0x7149, 0x714A, 0x714A, 0x714B, 0x7149, 0x714B } }, + { { 0x0000, 0x714C, 0x714D, 0x714C, 0x714C, 0x714E, 0x714C, 0x714E, 0x714F } }, + { { 0x0000, 0x7150, 0x7153, 0x7152, 0x7150, 0x7151, 0x7153, 0x7153, 0x7151 } }, + { { 0x0000, 0x7155, 0x7156, 0x7157, 0x7154, 0x7156, 0x7156, 0x7156, 0x7156 } }, + { { 0x0000, 0x715A, 0x7159, 0x715B, 0x715A, 0x715A, 0x7158, 0x7158, 0x715B } }, + { { 0x0000, 0x715E, 0x715D, 0x715D, 0x715F, 0x715E, 0x715C, 0x715C, 0x715D } }, + { { 0x0000, 0x7163, 0x7162, 0x7160, 0x7163, 0x7160, 0x7161, 0x7161, 0x7160 } }, + { { 0x0000, 0x7164, 0x7166, 0x7164, 0x7167, 0x7164, 0x7164, 0x7164, 0x7167 } }, + { { 0x0000, 0x716B, 0x7169, 0x7168, 0x716B, 0x716A, 0x716B, 0x716B, 0x716A } }, + { { 0x0000, 0x716C, 0x716D, 0x716F, 0x716C, 0x716E, 0x716E, 0x716E, 0x716F } }, + { { 0x0000, 0x7171, 0x7173, 0x7170, 0x7172, 0x0000, 0x0000, 0x0000, 0x0000 } }, + { { 0x0000, 0x7176, 0x7177, 0x7174, 0x7174, 0x7175, 0x7174, 0x7174, 0x7177 } }, + { { 0x0000, 0x7178, 0x7179, 0x7179, 0x717B, 0x717A, 0x717B, 0x717A, 0x717B } }, + { { 0x0000, 0x717D, 0x717C, 0x717C, 0x717D, 0x717F, 0x717C, 0x717E, 0x717D } }, + { { 0x0000, 0x7183, 0x7181, 0x7180, 0x7183, 0x7182, 0x7183, 0x7181, 0x7183 } }, + { { 0x0000, 0x7184, 0x7186, 0x7185, 0x7186, 0x7184, 0x7187, 0x7186, 0x7184 } }, + { { 0x0000, 0x71A4, 0x71A6, 0x71A5, 0x0000, 0x71A6, 0x71A6, 0x71A6, 0x71A7 } }, + { { 0x0000, 0x7188, 0x7188, 0x7189, 0x7188, 0x7189, 0x718B, 0x718A, 0x7189 } }, + { { 0x0000, 0x718C, 0x718C, 0x718D, 0x718C, 0x718E, 0x718F, 0x718D, 0x718C } }, + { { 0x0000, 0x7190, 0x7190, 0x7191, 0x7192, 0x7191, 0x7193, 0x7190, 0x7191 } }, + { { 0x0000, 0x7196, 0x7194, 0x7195, 0x7196, 0x7197, 0x7194, 0x7196, 0x7195 } }, + { { 0x0000, 0x7199, 0x719A, 0x7198, 0x7198, 0x719A, 0x719A, 0x719B, 0x7198 } }, + { { 0x0000, 0x719D, 0x719C, 0x719E, 0x719D, 0x719D, 0x719C, 0x719F, 0x719E } }, + { { 0x0000, 0x71A1, 0x71A0, 0x71A1, 0x71A2, 0x71A1, 0x71A2, 0x71A3, 0x71A2 } }, + { { 0x0000, 0x711C, 0x711E, 0x711C, 0x711F, 0x711E, 0x711C, 0x711D, 0x711F } }, + { { 0x0000, 0x7104, 0x7105, 0x7107, 0x7107, 0x7105, 0x7106, 0x7107, 0x7107 } }, + { { 0x0000, 0x7107, 0x7105, 0x7107, 0x7107, 0x7106, 0x7107, 0x7107, 0x7105 } }, + { { 0x0000, 0x7113, 0x7117, 0x7113, 0x7110, 0x7112, 0x7112, 0x7116, 0x7112 } }, + { { 0x0000, 0x7113, 0x7113, 0x7113, 0x7113, 0x7113, 0x7113, 0x7111, 0x7113 } }, + { { 0x0000, 0x7113, 0x7117, 0x7113, 0x7110, 0x7112, 0x7112, 0x7116, 0x7112 } }, + { { 0x0000, 0x7117, 0x7117, 0x7117, 0x7117, 0x7117, 0x7117, 0x7117, 0x7113 } }, + { { 0x0000, 0x7101, 0x7100, 0x7102, 0x7103, 0x7101, 0x7100, 0x7102, 0x7103 } }, + { { 0x0000, 0x7100, 0x7102, 0x7100, 0x7100, 0x7100, 0x7100, 0x7100, 0x7102 } }, + { { 0x0000, 0x710A, 0x7109, 0x7109, 0x710A, 0x710B, 0x7108, 0x7109, 0x710B } }, + { { 0x0000, 0x7117, 0x7112, 0x7113, 0x7110, 0x710C, 0x7117, 0x710E, 0x7112 } }, + { { 0x0000, 0x710D, 0x710F, 0x710C, 0x7112, 0x710D, 0x710C, 0x710C, 0x710F } }, + { { 0x0000, 0x710A, 0x7109, 0x711A, 0x710A, 0x7109, 0x7108, 0x710B, 0x7109 } }, + { { 0x0000, 0x710C, 0x710F, 0x7113, 0x7110, 0x710D, 0x7112, 0x7116, 0x710D } }, + { { 0x0000, 0x7115, 0x7114, 0x7114, 0x7115, 0x7114, 0x7114, 0x7116, 0x7117 } }, + { { 0x0000, 0x7113, 0x710F, 0x7113, 0x7110, 0x710C, 0x711A, 0x710D, 0x7112 } }, + { { 0x0000, 0x7101, 0x7102, 0x7103, 0x7101, 0x7100, 0x7100, 0x7102, 0x7100 } }, + { { 0x0000, 0x7112, 0x710E, 0x7112, 0x710E, 0x710D, 0x7112, 0x710E, 0x710F } }, + { { 0x0000, 0x7142, 0x7141, 0x7142, 0x7143, 0x7140, 0x7140, 0x7141, 0x7143 } }, + { { 0x0000, 0x713C, 0x713D, 0x713D, 0x713E, 0x713E, 0x713F, 0x713D, 0x713F } }, + { { 0x0000, 0x7101, 0x7102, 0x7103, 0x7101, 0x7100, 0x7100, 0x7102, 0x7100 } }, + { { 0x0000, 0x7113, 0x7117, 0x7113, 0x7110, 0x7112, 0x7112, 0x7116, 0x7112 } }, + { { 0x0000, 0x7104, 0x7105, 0x7107, 0x7105, 0x7105, 0x7105, 0x7107, 0x7107 } }, + { { 0x0000, 0x7104, 0x7105, 0x7107, 0x7105, 0x710C, 0x7105, 0x7107, 0x7107 } }, +}; + +u16 func_8006C360(GlobalContext* globalCtx, u32 idx) +{ + u8 mask = func_8008F080(globalCtx); + return D_8011F3F0[idx].data[mask]; +} diff --git a/src/code/code_8007BE60.c b/src/code/code_8007BE60.c deleted file mode 100644 index 59ef949c5..000000000 --- a/src/code/code_8007BE60.c +++ /dev/null @@ -1,50 +0,0 @@ -#include -#include - -extern u32 osResetType; - -/* -void func_8007BE60(u32* a0) -{ - u32 var1; - - //*a0 = 0; - - if (osResetType == 0) - { - a0[1] = 0; - a0[2] = 0; - a0[3] = 0; - } - else - { - var1 = a0[3] + a0[5]; - a0[1]++; - a0[2] = (var1 < a0[5]) + a0[2] + a0[4]; - a0[3] = var1; - } - - a0[5] = 0; - a0[4] = 0; -} -*/ - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8007BE60/func_8007BE60.s") - -typedef struct -{ - /* 0x00 */ u32 unk_00; - /* 0x04 */ char unk_04[0x0C]; - /* 0x10 */ OSTime unk_10; -} struct_8007BED4; - -void func_8007BED4(struct_8007BED4* arg0) -{ - arg0->unk_00 = 1; - arg0->unk_10 = osGetTime(); -} - -u32 func_8007BF08(struct_8007BED4* arg0) -{ - return arg0->unk_00; -} diff --git a/src/code/code_8007BF10.c b/src/code/code_8007BF10.c index 46771a303..f318d23bf 100644 --- a/src/code/code_8007BF10.c +++ b/src/code/code_8007BF10.c @@ -1,5 +1,23 @@ #include #include +#include -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8007BF10/func_8007BF10.s") +void func_8007BF10() +{ + u32 pad[4]; + OSScTask task; + OSMesgQueue queue; + OSMesg msg; + u32 pad2[1]; + task.next = NULL; + task.flags = 3; + task.msgQ = &queue; + task.msg = NULL; + task.framebuffer = NULL; + task.list.t.type = 0; + osCreateMesgQueue(task.msgQ, &msg, 1); + osSendMesg(&gSchedContext.cmdQ, &task, OS_MESG_BLOCK); + func_800C95F8(&gSchedContext); // osScKickEntryMsg + osRecvMesg(&queue, NULL, OS_MESG_BLOCK); +} diff --git a/src/code/main.c b/src/code/main.c index f69f62317..987654a41 100644 --- a/src/code/main.c +++ b/src/code/main.c @@ -7,7 +7,7 @@ u32 gScreenWidth = SCREEN_WIDTH; u32 gScreenHeight = SCREEN_HEIGHT; u32 gSystemHeapSize = 0; -u8* gAppNmiBufferPtr; +PreNmiBuff* gAppNmiBufferPtr; SchedContext gSchedContext; PadMgr gPadMgr; IrqMgr gIrqMgr; @@ -50,8 +50,8 @@ void Main(void* arg0) osSyncPrintf("mainproc 実行開始\n"); //Start running gScreenWidth = SCREEN_WIDTH; gScreenHeight = SCREEN_HEIGHT; - gAppNmiBufferPtr = osAppNmiBuffer; - func_8007BE60(gAppNmiBufferPtr); + gAppNmiBufferPtr = (PreNmiBuff*)osAppNmiBuffer; + PreNmiBuff_Init(gAppNmiBufferPtr); Fault_Start(); SysCfb_Init(0); sysHeap = (u32)gSystemHeap; @@ -112,7 +112,7 @@ void Main(void* arg0) if (*msg == OS_SC_PRE_NMI_MSG) { osSyncPrintf("main.c: リセットされたみたいだよ\n"); //Looks like it's been reset - func_8007BED4(gAppNmiBufferPtr); + PreNmiBuff_SetReset(gAppNmiBufferPtr); } } diff --git a/src/code/prenmi_buff.c b/src/code/prenmi_buff.c new file mode 100644 index 000000000..5616e3b79 --- /dev/null +++ b/src/code/prenmi_buff.c @@ -0,0 +1,35 @@ +#include +#include + +#define COLD_RESET 0 +#define NMI 1 + + +void PreNmiBuff_Init(PreNmiBuff* this) +{ + this->resetting = false; + if (osResetType == COLD_RESET) + { + this->resetCount = 0; + this->duration = 0; + } + else + { + this->resetCount++; + this->duration += this->resetTime; + } + + this->resetTime = 0; +} + + +void PreNmiBuff_SetReset(PreNmiBuff* this) +{ + this->resetting = true; + this->resetTime = osGetTime(); +} + +u32 PreNmiBuff_IsResetting(PreNmiBuff* this) +{ + return this->resetting; +} diff --git a/src/code/sys_ucode.c b/src/code/sys_ucode.c index f92a0d61e..0bd169090 100644 --- a/src/code/sys_ucode.c +++ b/src/code/sys_ucode.c @@ -1,21 +1,21 @@ #include -u32 func_800D2DF0() +u32 SysUcode_GetUCodeBoot() { return &D_80009320; } -u32 func_800D2DFC() +u32 SysUcode_GetUcodeBootSize() { return (u32)&D_800093F0 - (u32)&D_80009320; } -u32 func_800D2E14() +u32 SysUcode_GetUcode() { return D_8012DBA0; } -u32 func_800D2E20() +u32 SysUcode_GetUcodeData() { return D_8012DBA4; } diff --git a/src/code/z_room.c b/src/code/z_room.c index bbcb3d6f4..79c0d2bf6 100644 --- a/src/code/z_room.c +++ b/src/code/z_room.c @@ -426,8 +426,8 @@ void func_80096680(GlobalContext* globalCtx, Room* room, u32 flags) gfxCtx->polyOpa.p = spA8; } - // gSPLoadUcode(gfxCtx->polyOpa.p++, func_800D2E14(), func_800D2E20())? - gSPLoadUcodeEx(gfxCtx->polyOpa.p++, func_800D2E14(), func_800D2E20(), 0x800); + // gSPLoadUcode(gfxCtx->polyOpa.p++, SysUcode_GetUcode(), SysUcode_GetUcodeData())? + gSPLoadUcodeEx(gfxCtx->polyOpa.p++, SysUcode_GetUcode(), SysUcode_GetUcodeData(), 0x800); } } @@ -542,8 +542,8 @@ void func_80096B6C(GlobalContext* globalCtx, Room* room, u32 flags) gfxCtx->polyOpa.p = spA8; } - // gSPLoadUcode(gfxCtx->polyOpa.p++, func_800D2E14(), func_800D2E20())? - gSPLoadUcodeEx(gfxCtx->polyOpa.p++, func_800D2E14(), func_800D2E20(), 0x800); + // gSPLoadUcode(gfxCtx->polyOpa.p++, SysUcode_GetUcode(), SysUcode_GetUcodeData())? + gSPLoadUcodeEx(gfxCtx->polyOpa.p++, SysUcode_GetUcode(), SysUcode_GetUcodeData(), 0x800); } }