diff --git a/asm/graph.s b/asm/graph.s index 95e67955a5..4ca4e63c46 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 af861774b2..0000000000 --- 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 beeb6015b1..0000000000 --- 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 658558825d..0000000000 --- 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 8e679d77ac..84bfe49f78 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_jpeg/func_8006E418.s b/asm/non_matchings/code/z_jpeg/func_8006E418.s index ca42877a75..09a98ffa82 100644 --- a/asm/non_matchings/code/z_jpeg/func_8006E418.s +++ b/asm/non_matchings/code/z_jpeg/func_8006E418.s @@ -96,7 +96,7 @@ glabel func_8006E418 /* AE5620 8006E480 27A502B8 */ addiu $a1, $sp, 0x2b8 /* AE5624 8006E484 0C001874 */ jal osCreateMesgQueue /* AE5628 8006E488 24060001 */ li $a2, 1 -/* AE562C 8006E48C 0C01EFC4 */ jal func_8007BF10 +/* AE562C 8006E48C 0C01EFC4 */ jal MsgEvent_SendNullTask /* AE5630 8006E490 00000000 */ nop /* AE5634 8006E494 0C001A78 */ jal osGetTime /* AE5638 8006E498 00000000 */ nop diff --git a/asm/non_matchings/code/z_play/func_800BEDD8.s b/asm/non_matchings/code/z_play/func_800BEDD8.s index 040866161b..1be2fffa21 100644 --- a/asm/non_matchings/code/z_play/func_800BEDD8.s +++ b/asm/non_matchings/code/z_play/func_800BEDD8.s @@ -370,7 +370,7 @@ glabel func_800BEDD8 /* B364E4 800BF344 84430190 */ lh $v1, 0x190($v0) /* B364E8 800BF348 5461000E */ bnel $v1, $at, .L800BF384 /* B364EC 800BF34C 28610004 */ slti $at, $v1, 4 -/* B364F0 800BF350 0C01EFC4 */ jal func_8007BF10 +/* B364F0 800BF350 0C01EFC4 */ jal MsgEvent_SendNullTask /* B364F4 800BF354 00000000 */ nop /* B364F8 800BF358 0C030DDC */ jal func_800C3770 /* B364FC 800BF35C 8FA4003C */ lw $a0, 0x3c($sp) diff --git a/asm/non_matchings/code/z_room/func_80096B6C.s b/asm/non_matchings/code/z_room/func_80096B6C.s index dd8e978216..d4ecbeac47 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 ab46640fb5..ebf2d7cdde 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 20ab1ea6b7..0000000000 --- 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 95f685e1b2..909c3e3815 100644 --- a/include/functions.h +++ b/include/functions.h @@ -922,10 +922,10 @@ u8 ZeldaArena_IsInitalized(); void MapMark_Init(GlobalContext* globalCtx); void MapMark_ClearPointers(GlobalContext* globalCtx); void MapMark_DrawConditionally(GlobalContext* globalCtx); -// ? func_8007BE60(?); -// ? func_8007BED4(?); -// ? func_8007BF08(?); -// ? func_8007BF10(?); +void PreNmiBuff_Init(PreNmiBuff* this); +void PreNmiBuff_SetReset(PreNmiBuff* this); +u32 PreNmiBuff_IsResetting(PreNmiBuff* this); +void MsgEvent_SendNullTask(); f32 func_8007BF90(Vec3f*, Vec3f*); // ? func_8007C028(?); // ? func_8007C058(?); @@ -1633,10 +1633,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 423724d968..ff396be94b 100644 --- a/include/sched.h +++ b/include/sched.h @@ -3,6 +3,16 @@ #include +#define OS_SC_NEEDS_RDP 0x0001 +#define OS_SC_NEEDS_RSP 0x0002 +#define OS_SC_DRAM_DLIST 0x0004 +#define OS_SC_PARALLEL_TASK 0x0010 +#define OS_SC_LAST_TASK 0x0020 +#define OS_SC_SWAPBUFFER 0x0040 + +#define OS_SC_RCP_MASK 0x0003 +#define OS_SC_TYPE_MASK 0x0007 + typedef struct OSScTask { /* 0x00 */ struct OSScTask* next; @@ -10,8 +20,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 +49,6 @@ typedef struct /* 0x0220 */ char unk_254[0x04]; } SchedContext; // size = 0x258 +extern SchedContext gSchedContext; + #endif diff --git a/include/ultra64/mbi.h b/include/ultra64/mbi.h index 17213ea2bd..00b113595f 100644 --- a/include/ultra64/mbi.h +++ b/include/ultra64/mbi.h @@ -76,9 +76,11 @@ * **************************************************************************/ -#define M_GFXTASK 1 -#define M_AUDTASK 2 -#define M_VIDTASK 3 +#define M_NULTASK 0 +#define M_GFXTASK 1 +#define M_AUDTASK 2 +#define M_VIDTASK 3 +#define M_NJPEGTASK 4 #define M_HVQTASK 6 #define M_HVQMTASK 7 diff --git a/include/variables.h b/include/variables.h index 868080bb85..b12c078d56 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 964402a1e5..7381d9bf78 100644 --- a/include/z64.h +++ b/include/z64.h @@ -1403,4 +1403,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 739987d4f6..11c4fd944d 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,8 +339,8 @@ 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/code_8007BF10.o" + include "build/src/code/z_prenmi_buff.o" + include "build/src/code/z_msgevent.o" include "build/src/code/code_8007BF90.o" include "build/src/code/z_onepointdemo.o" include "build/data/z_onepointdemo.data.o" diff --git a/src/code/code_8006C360.c b/src/code/code_8006C360.c index 3180bab891..fa48f62edd 100644 --- a/src/code/code_8006C360.c +++ b/src/code/code_8006C360.c @@ -1,5 +1,72 @@ #include #include -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8006C360/func_8006C360.s") +u16 D_8011F3F0[60][9] = +{ + { 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][mask]; +} diff --git a/src/code/code_8007BE60.c b/src/code/code_8007BE60.c deleted file mode 100644 index 59ef949c56..0000000000 --- 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 deleted file mode 100644 index 46771a3038..0000000000 --- a/src/code/code_8007BF10.c +++ /dev/null @@ -1,5 +0,0 @@ -#include -#include - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8007BF10/func_8007BF10.s") - diff --git a/src/code/main.c b/src/code/main.c index f69f62317d..987654a416 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/sys_ucode.c b/src/code/sys_ucode.c index f92a0d61e2..0bd1690905 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_msgevent.c b/src/code/z_msgevent.c new file mode 100644 index 0000000000..3282d0342f --- /dev/null +++ b/src/code/z_msgevent.c @@ -0,0 +1,23 @@ +#include +#include +#include + +void MsgEvent_SendNullTask() +{ + u32 pad[4]; + OSScTask task; + OSMesgQueue queue; + OSMesg msg; + u32 pad2[1]; + + task.next = NULL; + task.flags = OS_SC_RCP_MASK; + task.msgQ = &queue; + task.msg = NULL; + task.framebuffer = NULL; + task.list.t.type = M_NULTASK; + 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/z_prenmi_buff.c b/src/code/z_prenmi_buff.c new file mode 100644 index 0000000000..5616e3b798 --- /dev/null +++ b/src/code/z_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/z_room.c b/src/code/z_room.c index bbcb3d6f49..79c0d2bf6e 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); } }