From ed816c640f4aeb49d1f44563a543b4a029496c04 Mon Sep 17 00:00:00 2001 From: JoshDuMan Date: Fri, 18 Sep 2020 16:48:52 -0400 Subject: [PATCH 1/7] hi --- .../os/code_3a650_len_40/nuGfxFuncSet.s | 24 - .../os/code_3a690_len_40/nuGfxPreNMIFuncSet.s | 24 - .../code_3a6d0_len_20/nuGfxTaskAllEndWait.s | 17 - .../os/code_3a800_len_30/nuGfxDisplayOff.s | 20 - .../os/code_3a830_len_20/nuGfxDisplayOn.s | 16 - .../os/code_3a850_le_a40/contPakFileDelete.s | 22 - .../os/code_3a850_le_a40/contPakFileNum.s | 17 - .../os/code_3a850_le_a40/contPakFileOpen.s | 52 - .../code_3a850_le_a40/contPakFileReadWrite.s | 22 - .../os/code_3a850_le_a40/contPakFileState.s | 17 - .../os/code_3a850_le_a40/contPakFree.s | 16 - .../os/code_3a850_le_a40/contPakOpen.s | 27 - .../os/code_3a850_le_a40/contPakRepairId.s | 15 - .../os/code_3a850_le_a40/nuContDataGet.s | 30 - .../os/code_3a850_le_a40/nuContInit.s | 22 - .../os/code_3a850_le_a40/nuContPakMgrInit.s | 15 - .../os/code_3a850_le_a40/nuContPakMgrRemove.s | 15 - .../os/code_3a850_le_a40/nuGfxInit.s | 50 - .../os/code_3a850_le_a40/nuPiInit.s | 22 - .../os/code_3a850_le_a40/nuPiReadRom.s | 61 - .../nuGfxSetCfb.s | 0 include/nu/nusys.h | 1052 +++++++++++++++++ include/variables.h | 3 + papermario.ld | 18 +- src/os/code_3a650_len_40.c | 3 - src/os/code_3a690_len_40.c | 3 - src/os/code_3a6d0_len_20.c | 3 - src/os/code_3a6f0_len_110.c | 3 - src/os/code_3a800_len_30.c | 3 - src/os/code_3a830_len_20.c | 3 - src/os/code_3a850_le_a40.c | 30 - src/os/nuContDataGet.c | 8 + src/os/nuContInit.c | 12 + src/os/nuContPakMgr.c | 81 ++ src/os/nuGfxDisplayOff.c | 7 + src/os/nuGfxDisplayOn.c | 6 + src/os/nuGfxFuncSet.c | 11 + src/os/nuGfxInit.c | 28 + src/os/nuGfxPreNMIFuncSet.c | 10 + src/os/nuGfxSetCfb.c | 3 + src/os/nuGfxTaskAllEndWait.c | 7 + src/os/nuPiInit.c | 10 + src/os/nuPiReadRom.c | 35 + undefined_syms.txt | 21 + 44 files changed, 1306 insertions(+), 558 deletions(-) delete mode 100644 asm/nonmatchings/os/code_3a650_len_40/nuGfxFuncSet.s delete mode 100644 asm/nonmatchings/os/code_3a690_len_40/nuGfxPreNMIFuncSet.s delete mode 100644 asm/nonmatchings/os/code_3a6d0_len_20/nuGfxTaskAllEndWait.s delete mode 100644 asm/nonmatchings/os/code_3a800_len_30/nuGfxDisplayOff.s delete mode 100644 asm/nonmatchings/os/code_3a830_len_20/nuGfxDisplayOn.s delete mode 100644 asm/nonmatchings/os/code_3a850_le_a40/contPakFileDelete.s delete mode 100644 asm/nonmatchings/os/code_3a850_le_a40/contPakFileNum.s delete mode 100644 asm/nonmatchings/os/code_3a850_le_a40/contPakFileOpen.s delete mode 100644 asm/nonmatchings/os/code_3a850_le_a40/contPakFileReadWrite.s delete mode 100644 asm/nonmatchings/os/code_3a850_le_a40/contPakFileState.s delete mode 100644 asm/nonmatchings/os/code_3a850_le_a40/contPakFree.s delete mode 100644 asm/nonmatchings/os/code_3a850_le_a40/contPakOpen.s delete mode 100644 asm/nonmatchings/os/code_3a850_le_a40/contPakRepairId.s delete mode 100644 asm/nonmatchings/os/code_3a850_le_a40/nuContDataGet.s delete mode 100644 asm/nonmatchings/os/code_3a850_le_a40/nuContInit.s delete mode 100644 asm/nonmatchings/os/code_3a850_le_a40/nuContPakMgrInit.s delete mode 100644 asm/nonmatchings/os/code_3a850_le_a40/nuContPakMgrRemove.s delete mode 100644 asm/nonmatchings/os/code_3a850_le_a40/nuGfxInit.s delete mode 100644 asm/nonmatchings/os/code_3a850_le_a40/nuPiInit.s delete mode 100644 asm/nonmatchings/os/code_3a850_le_a40/nuPiReadRom.s rename asm/nonmatchings/os/{code_3a6f0_len_110 => nuGfxSetCfb}/nuGfxSetCfb.s (100%) create mode 100644 include/nu/nusys.h delete mode 100644 src/os/code_3a650_len_40.c delete mode 100644 src/os/code_3a690_len_40.c delete mode 100644 src/os/code_3a6d0_len_20.c delete mode 100644 src/os/code_3a6f0_len_110.c delete mode 100644 src/os/code_3a800_len_30.c delete mode 100644 src/os/code_3a830_len_20.c create mode 100644 src/os/nuContDataGet.c create mode 100644 src/os/nuContInit.c create mode 100644 src/os/nuContPakMgr.c create mode 100644 src/os/nuGfxDisplayOff.c create mode 100644 src/os/nuGfxDisplayOn.c create mode 100644 src/os/nuGfxFuncSet.c create mode 100644 src/os/nuGfxInit.c create mode 100644 src/os/nuGfxPreNMIFuncSet.c create mode 100644 src/os/nuGfxSetCfb.c create mode 100644 src/os/nuGfxTaskAllEndWait.c create mode 100644 src/os/nuPiInit.c create mode 100644 src/os/nuPiReadRom.c diff --git a/asm/nonmatchings/os/code_3a650_len_40/nuGfxFuncSet.s b/asm/nonmatchings/os/code_3a650_len_40/nuGfxFuncSet.s deleted file mode 100644 index 573db2af81..0000000000 --- a/asm/nonmatchings/os/code_3a650_len_40/nuGfxFuncSet.s +++ /dev/null @@ -1,24 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel nuGfxFuncSet -/* 03A650 8005F250 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 03A654 8005F254 AFB00010 */ sw $s0, 0x10($sp) -/* 03A658 8005F258 AFBF0014 */ sw $ra, 0x14($sp) -/* 03A65C 8005F25C 0C017CB4 */ jal nuGfxTaskAllEndWait -/* 03A660 8005F260 0080802D */ daddu $s0, $a0, $zero -/* 03A664 8005F264 0C018250 */ jal osSetIntMask -/* 03A668 8005F268 24040001 */ addiu $a0, $zero, 1 -/* 03A66C 8005F26C 3C018009 */ lui $at, 0x8009 -/* 03A670 8005F270 AC303D10 */ sw $s0, 0x3d10($at) -/* 03A674 8005F274 0C018250 */ jal osSetIntMask -/* 03A678 8005F278 0040202D */ daddu $a0, $v0, $zero -/* 03A67C 8005F27C 8FBF0014 */ lw $ra, 0x14($sp) -/* 03A680 8005F280 8FB00010 */ lw $s0, 0x10($sp) -/* 03A684 8005F284 03E00008 */ jr $ra -/* 03A688 8005F288 27BD0018 */ addiu $sp, $sp, 0x18 - -/* 03A68C 8005F28C 00000000 */ nop - - diff --git a/asm/nonmatchings/os/code_3a690_len_40/nuGfxPreNMIFuncSet.s b/asm/nonmatchings/os/code_3a690_len_40/nuGfxPreNMIFuncSet.s deleted file mode 100644 index 0c72eb4723..0000000000 --- a/asm/nonmatchings/os/code_3a690_len_40/nuGfxPreNMIFuncSet.s +++ /dev/null @@ -1,24 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel nuGfxPreNMIFuncSet -/* 03A690 8005F290 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 03A694 8005F294 AFB00010 */ sw $s0, 0x10($sp) -/* 03A698 8005F298 0080802D */ daddu $s0, $a0, $zero -/* 03A69C 8005F29C AFBF0014 */ sw $ra, 0x14($sp) -/* 03A6A0 8005F2A0 0C018250 */ jal osSetIntMask -/* 03A6A4 8005F2A4 24040001 */ addiu $a0, $zero, 1 -/* 03A6A8 8005F2A8 3C018009 */ lui $at, 0x8009 -/* 03A6AC 8005F2AC AC303D14 */ sw $s0, 0x3d14($at) -/* 03A6B0 8005F2B0 0C018250 */ jal osSetIntMask -/* 03A6B4 8005F2B4 0040202D */ daddu $a0, $v0, $zero -/* 03A6B8 8005F2B8 8FBF0014 */ lw $ra, 0x14($sp) -/* 03A6BC 8005F2BC 8FB00010 */ lw $s0, 0x10($sp) -/* 03A6C0 8005F2C0 03E00008 */ jr $ra -/* 03A6C4 8005F2C4 27BD0018 */ addiu $sp, $sp, 0x18 - -/* 03A6C8 8005F2C8 00000000 */ nop -/* 03A6CC 8005F2CC 00000000 */ nop - - diff --git a/asm/nonmatchings/os/code_3a6d0_len_20/nuGfxTaskAllEndWait.s b/asm/nonmatchings/os/code_3a6d0_len_20/nuGfxTaskAllEndWait.s deleted file mode 100644 index a07e2e4ffc..0000000000 --- a/asm/nonmatchings/os/code_3a6d0_len_20/nuGfxTaskAllEndWait.s +++ /dev/null @@ -1,17 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel nuGfxTaskAllEndWait -.L8005F2D0: -/* 03A6D0 8005F2D0 3C02800A */ lui $v0, 0x800a -/* 03A6D4 8005F2D4 8C42A618 */ lw $v0, -0x59e8($v0) -/* 03A6D8 8005F2D8 1440FFFD */ bnez $v0, .L8005F2D0 -/* 03A6DC 8005F2DC 00000000 */ nop -/* 03A6E0 8005F2E0 03E00008 */ jr $ra -/* 03A6E4 8005F2E4 00000000 */ nop - -/* 03A6E8 8005F2E8 00000000 */ nop -/* 03A6EC 8005F2EC 00000000 */ nop - - diff --git a/asm/nonmatchings/os/code_3a800_len_30/nuGfxDisplayOff.s b/asm/nonmatchings/os/code_3a800_len_30/nuGfxDisplayOff.s deleted file mode 100644 index 84fef71f3e..0000000000 --- a/asm/nonmatchings/os/code_3a800_len_30/nuGfxDisplayOff.s +++ /dev/null @@ -1,20 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel nuGfxDisplayOff -/* 03A800 8005F400 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 03A804 8005F404 AFBF0010 */ sw $ra, 0x10($sp) -/* 03A808 8005F408 3C01800A */ lui $at, 0x800a -/* 03A80C 8005F40C AC20A5F8 */ sw $zero, -0x5a08($at) -/* 03A810 8005F410 0C019CE0 */ jal osViBlack -/* 03A814 8005F414 24040001 */ addiu $a0, $zero, 1 -/* 03A818 8005F418 8FBF0010 */ lw $ra, 0x10($sp) -/* 03A81C 8005F41C 03E00008 */ jr $ra -/* 03A820 8005F420 27BD0018 */ addiu $sp, $sp, 0x18 - -/* 03A824 8005F424 00000000 */ nop -/* 03A828 8005F428 00000000 */ nop -/* 03A82C 8005F42C 00000000 */ nop - - diff --git a/asm/nonmatchings/os/code_3a830_len_20/nuGfxDisplayOn.s b/asm/nonmatchings/os/code_3a830_len_20/nuGfxDisplayOn.s deleted file mode 100644 index 22be1ccc70..0000000000 --- a/asm/nonmatchings/os/code_3a830_len_20/nuGfxDisplayOn.s +++ /dev/null @@ -1,16 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel nuGfxDisplayOn -/* 03A830 8005F430 24020080 */ addiu $v0, $zero, 0x80 -/* 03A834 8005F434 3C01800A */ lui $at, 0x800a -/* 03A838 8005F438 AC22A5F8 */ sw $v0, -0x5a08($at) -/* 03A83C 8005F43C 03E00008 */ jr $ra -/* 03A840 8005F440 00000000 */ nop - -/* 03A844 8005F444 00000000 */ nop -/* 03A848 8005F448 00000000 */ nop -/* 03A84C 8005F44C 00000000 */ nop - - diff --git a/asm/nonmatchings/os/code_3a850_le_a40/contPakFileDelete.s b/asm/nonmatchings/os/code_3a850_le_a40/contPakFileDelete.s deleted file mode 100644 index 3be86b3dfa..0000000000 --- a/asm/nonmatchings/os/code_3a850_le_a40/contPakFileDelete.s +++ /dev/null @@ -1,22 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel contPakFileDelete -/* 03AC64 8005F864 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 03AC68 8005F868 AFBF0018 */ sw $ra, 0x18($sp) -/* 03AC6C 8005F86C 8C82000C */ lw $v0, 0xc($a0) -/* 03AC70 8005F870 3C058009 */ lui $a1, 0x8009 -/* 03AC74 8005F874 94A53CA0 */ lhu $a1, 0x3ca0($a1) -/* 03AC78 8005F878 3C068009 */ lui $a2, 0x8009 -/* 03AC7C 8005F87C 8CC63CA4 */ lw $a2, 0x3ca4($a2) -/* 03AC80 8005F880 8C430008 */ lw $v1, 8($v0) -/* 03AC84 8005F884 8C440000 */ lw $a0, ($v0) -/* 03AC88 8005F888 AFA30010 */ sw $v1, 0x10($sp) -/* 03AC8C 8005F88C 8C840000 */ lw $a0, ($a0) -/* 03AC90 8005F890 0C01A170 */ jal osPfsDeleteFile -/* 03AC94 8005F894 8C470004 */ lw $a3, 4($v0) -/* 03AC98 8005F898 8FBF0018 */ lw $ra, 0x18($sp) -/* 03AC9C 8005F89C 03E00008 */ jr $ra -/* 03ACA0 8005F8A0 27BD0020 */ addiu $sp, $sp, 0x20 - diff --git a/asm/nonmatchings/os/code_3a850_le_a40/contPakFileNum.s b/asm/nonmatchings/os/code_3a850_le_a40/contPakFileNum.s deleted file mode 100644 index 473940630d..0000000000 --- a/asm/nonmatchings/os/code_3a850_le_a40/contPakFileNum.s +++ /dev/null @@ -1,17 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel contPakFileNum -/* 03ACD0 8005F8D0 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 03ACD4 8005F8D4 AFBF0010 */ sw $ra, 0x10($sp) -/* 03ACD8 8005F8D8 8C82000C */ lw $v0, 0xc($a0) -/* 03ACDC 8005F8DC 8C430000 */ lw $v1, ($v0) -/* 03ACE0 8005F8E0 8C450004 */ lw $a1, 4($v0) -/* 03ACE4 8005F8E4 8C460008 */ lw $a2, 8($v0) -/* 03ACE8 8005F8E8 0C01A424 */ jal osPfsNumFiles -/* 03ACEC 8005F8EC 8C640000 */ lw $a0, ($v1) -/* 03ACF0 8005F8F0 8FBF0010 */ lw $ra, 0x10($sp) -/* 03ACF4 8005F8F4 03E00008 */ jr $ra -/* 03ACF8 8005F8F8 27BD0018 */ addiu $sp, $sp, 0x18 - diff --git a/asm/nonmatchings/os/code_3a850_le_a40/contPakFileOpen.s b/asm/nonmatchings/os/code_3a850_le_a40/contPakFileOpen.s deleted file mode 100644 index 9634c6add3..0000000000 --- a/asm/nonmatchings/os/code_3a850_le_a40/contPakFileOpen.s +++ /dev/null @@ -1,52 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel contPakFileOpen -/* 03ABB0 8005F7B0 27BDFFD0 */ addiu $sp, $sp, -0x30 -/* 03ABB4 8005F7B4 AFBF002C */ sw $ra, 0x2c($sp) -/* 03ABB8 8005F7B8 AFB20028 */ sw $s2, 0x28($sp) -/* 03ABBC 8005F7BC AFB10024 */ sw $s1, 0x24($sp) -/* 03ABC0 8005F7C0 AFB00020 */ sw $s0, 0x20($sp) -/* 03ABC4 8005F7C4 8C90000C */ lw $s0, 0xc($a0) -/* 03ABC8 8005F7C8 3C058009 */ lui $a1, 0x8009 -/* 03ABCC 8005F7CC 94A53CA0 */ lhu $a1, 0x3ca0($a1) -/* 03ABD0 8005F7D0 3C068009 */ lui $a2, 0x8009 -/* 03ABD4 8005F7D4 8CC63CA4 */ lw $a2, 0x3ca4($a2) -/* 03ABD8 8005F7D8 8E110000 */ lw $s1, ($s0) -/* 03ABDC 8005F7DC 8E020008 */ lw $v0, 8($s0) -/* 03ABE0 8005F7E0 26320004 */ addiu $s2, $s1, 4 -/* 03ABE4 8005F7E4 AFA20010 */ sw $v0, 0x10($sp) -/* 03ABE8 8005F7E8 AFB20014 */ sw $s2, 0x14($sp) -/* 03ABEC 8005F7EC 8E240000 */ lw $a0, ($s1) -/* 03ABF0 8005F7F0 0C01A370 */ jal osPfsFindFile -/* 03ABF4 8005F7F4 8E070004 */ lw $a3, 4($s0) -/* 03ABF8 8005F7F8 0040202D */ daddu $a0, $v0, $zero -/* 03ABFC 8005F7FC 24020005 */ addiu $v0, $zero, 5 -/* 03AC00 8005F800 14820011 */ bne $a0, $v0, .L8005F848 -/* 03AC04 8005F804 24020001 */ addiu $v0, $zero, 1 -/* 03AC08 8005F808 8E030010 */ lw $v1, 0x10($s0) -/* 03AC0C 8005F80C 1462000E */ bne $v1, $v0, .L8005F848 -/* 03AC10 8005F810 00000000 */ nop -/* 03AC14 8005F814 8E020008 */ lw $v0, 8($s0) -/* 03AC18 8005F818 3C058009 */ lui $a1, 0x8009 -/* 03AC1C 8005F81C 94A53CA0 */ lhu $a1, 0x3ca0($a1) -/* 03AC20 8005F820 3C068009 */ lui $a2, 0x8009 -/* 03AC24 8005F824 8CC63CA4 */ lw $a2, 0x3ca4($a2) -/* 03AC28 8005F828 AFA20010 */ sw $v0, 0x10($sp) -/* 03AC2C 8005F82C 8E02000C */ lw $v0, 0xc($s0) -/* 03AC30 8005F830 AFB20018 */ sw $s2, 0x18($sp) -/* 03AC34 8005F834 AFA20014 */ sw $v0, 0x14($sp) -/* 03AC38 8005F838 8E240000 */ lw $a0, ($s1) -/* 03AC3C 8005F83C 0C01A064 */ jal osPfsAllocateFile -/* 03AC40 8005F840 8E070004 */ lw $a3, 4($s0) -/* 03AC44 8005F844 0040202D */ daddu $a0, $v0, $zero -.L8005F848: -/* 03AC48 8005F848 8FBF002C */ lw $ra, 0x2c($sp) -/* 03AC4C 8005F84C 8FB20028 */ lw $s2, 0x28($sp) -/* 03AC50 8005F850 8FB10024 */ lw $s1, 0x24($sp) -/* 03AC54 8005F854 8FB00020 */ lw $s0, 0x20($sp) -/* 03AC58 8005F858 0080102D */ daddu $v0, $a0, $zero -/* 03AC5C 8005F85C 03E00008 */ jr $ra -/* 03AC60 8005F860 27BD0030 */ addiu $sp, $sp, 0x30 - diff --git a/asm/nonmatchings/os/code_3a850_le_a40/contPakFileReadWrite.s b/asm/nonmatchings/os/code_3a850_le_a40/contPakFileReadWrite.s deleted file mode 100644 index 31164be2a2..0000000000 --- a/asm/nonmatchings/os/code_3a850_le_a40/contPakFileReadWrite.s +++ /dev/null @@ -1,22 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel contPakFileReadWrite -/* 03AB70 8005F770 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 03AB74 8005F774 AFBF0018 */ sw $ra, 0x18($sp) -/* 03AB78 8005F778 8C83000C */ lw $v1, 0xc($a0) -/* 03AB7C 8005F77C 8C620008 */ lw $v0, 8($v1) -/* 03AB80 8005F780 8C650000 */ lw $a1, ($v1) -/* 03AB84 8005F784 9066000C */ lbu $a2, 0xc($v1) -/* 03AB88 8005F788 AFA20010 */ sw $v0, 0x10($sp) -/* 03AB8C 8005F78C 8C620010 */ lw $v0, 0x10($v1) -/* 03AB90 8005F790 AFA20014 */ sw $v0, 0x14($sp) -/* 03AB94 8005F794 8CA40000 */ lw $a0, ($a1) -/* 03AB98 8005F798 8CA50004 */ lw $a1, 4($a1) -/* 03AB9C 8005F79C 0C01A1F8 */ jal osPfsReadWriteFile -/* 03ABA0 8005F7A0 8C670004 */ lw $a3, 4($v1) -/* 03ABA4 8005F7A4 8FBF0018 */ lw $ra, 0x18($sp) -/* 03ABA8 8005F7A8 03E00008 */ jr $ra -/* 03ABAC 8005F7AC 27BD0020 */ addiu $sp, $sp, 0x20 - diff --git a/asm/nonmatchings/os/code_3a850_le_a40/contPakFileState.s b/asm/nonmatchings/os/code_3a850_le_a40/contPakFileState.s deleted file mode 100644 index 5d9d5aa571..0000000000 --- a/asm/nonmatchings/os/code_3a850_le_a40/contPakFileState.s +++ /dev/null @@ -1,17 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel contPakFileState -/* 03ACA4 8005F8A4 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 03ACA8 8005F8A8 AFBF0010 */ sw $ra, 0x10($sp) -/* 03ACAC 8005F8AC 8C83000C */ lw $v1, 0xc($a0) -/* 03ACB0 8005F8B0 8C620000 */ lw $v0, ($v1) -/* 03ACB4 8005F8B4 8C660004 */ lw $a2, 4($v1) -/* 03ACB8 8005F8B8 8C440000 */ lw $a0, ($v0) -/* 03ACBC 8005F8BC 0C01A308 */ jal osPfsFileState -/* 03ACC0 8005F8C0 8C450004 */ lw $a1, 4($v0) -/* 03ACC4 8005F8C4 8FBF0010 */ lw $ra, 0x10($sp) -/* 03ACC8 8005F8C8 03E00008 */ jr $ra -/* 03ACCC 8005F8CC 27BD0018 */ addiu $sp, $sp, 0x18 - diff --git a/asm/nonmatchings/os/code_3a850_le_a40/contPakFree.s b/asm/nonmatchings/os/code_3a850_le_a40/contPakFree.s deleted file mode 100644 index d285cfc4f6..0000000000 --- a/asm/nonmatchings/os/code_3a850_le_a40/contPakFree.s +++ /dev/null @@ -1,16 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel contPakFree -/* 03AB48 8005F748 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 03AB4C 8005F74C AFBF0010 */ sw $ra, 0x10($sp) -/* 03AB50 8005F750 8C85000C */ lw $a1, 0xc($a0) -/* 03AB54 8005F754 8CA20000 */ lw $v0, ($a1) -/* 03AB58 8005F758 8C440000 */ lw $a0, ($v0) -/* 03AB5C 8005F75C 0C01A3E0 */ jal osPfsFreeBlocks -/* 03AB60 8005F760 24A50004 */ addiu $a1, $a1, 4 -/* 03AB64 8005F764 8FBF0010 */ lw $ra, 0x10($sp) -/* 03AB68 8005F768 03E00008 */ jr $ra -/* 03AB6C 8005F76C 27BD0018 */ addiu $sp, $sp, 0x18 - diff --git a/asm/nonmatchings/os/code_3a850_le_a40/contPakOpen.s b/asm/nonmatchings/os/code_3a850_le_a40/contPakOpen.s deleted file mode 100644 index b8aca7037f..0000000000 --- a/asm/nonmatchings/os/code_3a850_le_a40/contPakOpen.s +++ /dev/null @@ -1,27 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel contPakOpen -/* 03AAF8 8005F6F8 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 03AAFC 8005F6FC AFBF0014 */ sw $ra, 0x14($sp) -/* 03AB00 8005F700 AFB00010 */ sw $s0, 0x10($sp) -/* 03AB04 8005F704 8C90000C */ lw $s0, 0xc($a0) -/* 03AB08 8005F708 8E050000 */ lw $a1, ($s0) -/* 03AB0C 8005F70C AE00000C */ sw $zero, 0xc($s0) -/* 03AB10 8005F710 8CA60008 */ lw $a2, 8($a1) -/* 03AB14 8005F714 3C04800E */ lui $a0, 0x800e -/* 03AB18 8005F718 2484AC78 */ addiu $a0, $a0, -0x5388 -/* 03AB1C 8005F71C 0C01A464 */ jal osPfsInitPak -/* 03AB20 8005F720 00000000 */ nop -/* 03AB24 8005F724 0040182D */ daddu $v1, $v0, $zero -/* 03AB28 8005F728 14600002 */ bnez $v1, .L8005F734 -/* 03AB2C 8005F72C 24020001 */ addiu $v0, $zero, 1 -/* 03AB30 8005F730 AE02000C */ sw $v0, 0xc($s0) -.L8005F734: -/* 03AB34 8005F734 8FBF0014 */ lw $ra, 0x14($sp) -/* 03AB38 8005F738 8FB00010 */ lw $s0, 0x10($sp) -/* 03AB3C 8005F73C 0060102D */ daddu $v0, $v1, $zero -/* 03AB40 8005F740 03E00008 */ jr $ra -/* 03AB44 8005F744 27BD0018 */ addiu $sp, $sp, 0x18 - diff --git a/asm/nonmatchings/os/code_3a850_le_a40/contPakRepairId.s b/asm/nonmatchings/os/code_3a850_le_a40/contPakRepairId.s deleted file mode 100644 index 9ea1b6f79d..0000000000 --- a/asm/nonmatchings/os/code_3a850_le_a40/contPakRepairId.s +++ /dev/null @@ -1,15 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel contPakRepairId -/* 03ACFC 8005F8FC 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 03AD00 8005F900 AFBF0010 */ sw $ra, 0x10($sp) -/* 03AD04 8005F904 8C82000C */ lw $v0, 0xc($a0) -/* 03AD08 8005F908 0C01A518 */ jal osPfsRepairId -/* 03AD0C 8005F90C 8C440000 */ lw $a0, ($v0) -/* 03AD10 8005F910 8FBF0010 */ lw $ra, 0x10($sp) -/* 03AD14 8005F914 03E00008 */ jr $ra -/* 03AD18 8005F918 27BD0018 */ addiu $sp, $sp, 0x18 - -/* 03AD1C 8005F91C 00000000 */ nop diff --git a/asm/nonmatchings/os/code_3a850_le_a40/nuContDataGet.s b/asm/nonmatchings/os/code_3a850_le_a40/nuContDataGet.s deleted file mode 100644 index 0a77402c06..0000000000 --- a/asm/nonmatchings/os/code_3a850_le_a40/nuContDataGet.s +++ /dev/null @@ -1,30 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel nuContDataGet -/* 03AA50 8005F650 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 03AA54 8005F654 AFB10014 */ sw $s1, 0x14($sp) -/* 03AA58 8005F658 0080882D */ daddu $s1, $a0, $zero -/* 03AA5C 8005F65C AFB00010 */ sw $s0, 0x10($sp) -/* 03AA60 8005F660 AFBF0018 */ sw $ra, 0x18($sp) -/* 03AA64 8005F664 0C018183 */ jal nuContDataClose -/* 03AA68 8005F668 00A0802D */ daddu $s0, $a1, $zero -/* 03AA6C 8005F66C 00102040 */ sll $a0, $s0, 1 -/* 03AA70 8005F670 00902021 */ addu $a0, $a0, $s0 -/* 03AA74 8005F674 00042040 */ sll $a0, $a0, 1 -/* 03AA78 8005F678 3C02800B */ lui $v0, 0x800b -/* 03AA7C 8005F67C 24421D68 */ addiu $v0, $v0, 0x1d68 -/* 03AA80 8005F680 00822021 */ addu $a0, $a0, $v0 -/* 03AA84 8005F684 0220282D */ daddu $a1, $s1, $zero -/* 03AA88 8005F688 0C019194 */ jal bcopy -/* 03AA8C 8005F68C 24060006 */ addiu $a2, $zero, 6 -/* 03AA90 8005F690 0C01818D */ jal nuContDataOpen -/* 03AA94 8005F694 00000000 */ nop -/* 03AA98 8005F698 8FBF0018 */ lw $ra, 0x18($sp) -/* 03AA9C 8005F69C 8FB10014 */ lw $s1, 0x14($sp) -/* 03AAA0 8005F6A0 8FB00010 */ lw $s0, 0x10($sp) -/* 03AAA4 8005F6A4 03E00008 */ jr $ra -/* 03AAA8 8005F6A8 27BD0020 */ addiu $sp, $sp, 0x20 - -/* 03AAAC 8005F6AC 00000000 */ nop diff --git a/asm/nonmatchings/os/code_3a850_le_a40/nuContInit.s b/asm/nonmatchings/os/code_3a850_le_a40/nuContInit.s deleted file mode 100644 index 8d33ba1f01..0000000000 --- a/asm/nonmatchings/os/code_3a850_le_a40/nuContInit.s +++ /dev/null @@ -1,22 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel nuContInit -/* 03AA10 8005F610 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 03AA14 8005F614 AFBF0014 */ sw $ra, 0x14($sp) -/* 03AA18 8005F618 0C00B38C */ jal nuSiMgrInit -/* 03AA1C 8005F61C AFB00010 */ sw $s0, 0x10($sp) -/* 03AA20 8005F620 0C018144 */ jal nuContMgrInit -/* 03AA24 8005F624 0040802D */ daddu $s0, $v0, $zero -/* 03AA28 8005F628 0C017DAC */ jal nuContPakMgrInit -/* 03AA2C 8005F62C 00000000 */ nop -/* 03AA30 8005F630 0C017F23 */ jal nuContRmbMgrInit -/* 03AA34 8005F634 00000000 */ nop -/* 03AA38 8005F638 320200FF */ andi $v0, $s0, 0xff -/* 03AA3C 8005F63C 8FBF0014 */ lw $ra, 0x14($sp) -/* 03AA40 8005F640 8FB00010 */ lw $s0, 0x10($sp) -/* 03AA44 8005F644 03E00008 */ jr $ra -/* 03AA48 8005F648 27BD0018 */ addiu $sp, $sp, 0x18 - -/* 03AA4C 8005F64C 00000000 */ nop diff --git a/asm/nonmatchings/os/code_3a850_le_a40/nuContPakMgrInit.s b/asm/nonmatchings/os/code_3a850_le_a40/nuContPakMgrInit.s deleted file mode 100644 index 4a32d4c414..0000000000 --- a/asm/nonmatchings/os/code_3a850_le_a40/nuContPakMgrInit.s +++ /dev/null @@ -1,15 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel nuContPakMgrInit -/* 03AAB0 8005F6B0 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 03AAB4 8005F6B4 3C048009 */ lui $a0, 0x8009 -/* 03AAB8 8005F6B8 24843CD0 */ addiu $a0, $a0, 0x3cd0 -/* 03AABC 8005F6BC AFBF0010 */ sw $ra, 0x10($sp) -/* 03AAC0 8005F6C0 0C0180FC */ jal nuSiCallBackAdd -/* 03AAC4 8005F6C4 00000000 */ nop -/* 03AAC8 8005F6C8 8FBF0010 */ lw $ra, 0x10($sp) -/* 03AACC 8005F6CC 03E00008 */ jr $ra -/* 03AAD0 8005F6D0 27BD0018 */ addiu $sp, $sp, 0x18 - diff --git a/asm/nonmatchings/os/code_3a850_le_a40/nuContPakMgrRemove.s b/asm/nonmatchings/os/code_3a850_le_a40/nuContPakMgrRemove.s deleted file mode 100644 index 3d9c5dc23b..0000000000 --- a/asm/nonmatchings/os/code_3a850_le_a40/nuContPakMgrRemove.s +++ /dev/null @@ -1,15 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel nuContPakMgrRemove -/* 03AAD4 8005F6D4 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 03AAD8 8005F6D8 3C048009 */ lui $a0, 0x8009 -/* 03AADC 8005F6DC 24843CD0 */ addiu $a0, $a0, 0x3cd0 -/* 03AAE0 8005F6E0 AFBF0010 */ sw $ra, 0x10($sp) -/* 03AAE4 8005F6E4 0C018124 */ jal nuSiCallBackRemove -/* 03AAE8 8005F6E8 00000000 */ nop -/* 03AAEC 8005F6EC 8FBF0010 */ lw $ra, 0x10($sp) -/* 03AAF0 8005F6F0 03E00008 */ jr $ra -/* 03AAF4 8005F6F4 27BD0018 */ addiu $sp, $sp, 0x18 - diff --git a/asm/nonmatchings/os/code_3a850_le_a40/nuGfxInit.s b/asm/nonmatchings/os/code_3a850_le_a40/nuGfxInit.s deleted file mode 100644 index 0aa914db1e..0000000000 --- a/asm/nonmatchings/os/code_3a850_le_a40/nuGfxInit.s +++ /dev/null @@ -1,50 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel nuGfxInit -/* 03A960 8005F560 27BDF7E8 */ addiu $sp, $sp, -0x818 -/* 03A964 8005F564 AFBF0810 */ sw $ra, 0x810($sp) -/* 03A968 8005F568 0C01807C */ jal nuGfxThreadStart -/* 03A96C 8005F56C 00000000 */ nop -/* 03A970 8005F570 3C048009 */ lui $a0, 0x8009 -/* 03A974 8005F574 24843BA8 */ addiu $a0, $a0, 0x3ba8 -/* 03A978 8005F578 0C017CBC */ jal nuGfxSetCfb -/* 03A97C 8005F57C 24050003 */ addiu $a1, $zero, 3 -/* 03A980 8005F580 3C028000 */ lui $v0, 0x8000 -/* 03A984 8005F584 34420400 */ ori $v0, $v0, 0x400 -/* 03A988 8005F588 3C048006 */ lui $a0, 0x8006 -/* 03A98C 8005F58C 24840350 */ addiu $a0, $a0, 0x350 -/* 03A990 8005F590 3C01800A */ lui $at, 0x800a -/* 03A994 8005F594 AC22A5DC */ sw $v0, -0x5a24($at) -/* 03A998 8005F598 0C0180C4 */ jal nuGfxSwapCfbFuncSet -/* 03A99C 8005F59C 00000000 */ nop -/* 03A9A0 8005F5A0 3C028009 */ lui $v0, 0x8009 -/* 03A9A4 8005F5A4 24423BA0 */ addiu $v0, $v0, 0x3ba0 -/* 03A9A8 8005F5A8 3C01800A */ lui $at, 0x800a -/* 03A9AC 8005F5AC AC22A610 */ sw $v0, -0x59f0($at) -/* 03A9B0 8005F5B0 0C00B2CE */ jal nuGfxTaskMgrInit -/* 03A9B4 8005F5B4 00000000 */ nop -/* 03A9B8 8005F5B8 27A40010 */ addiu $a0, $sp, 0x10 -/* 03A9BC 8005F5BC 27A50028 */ addiu $a1, $sp, 0x28 -/* 03A9C0 8005F5C0 00A42823 */ subu $a1, $a1, $a0 -/* 03A9C4 8005F5C4 3C02DE00 */ lui $v0, 0xde00 -/* 03A9C8 8005F5C8 AFA20010 */ sw $v0, 0x10($sp) -/* 03A9CC 8005F5CC 3C020009 */ lui $v0, 9 -/* 03A9D0 8005F5D0 24423BB8 */ addiu $v0, $v0, 0x3bb8 -/* 03A9D4 8005F5D4 AC820004 */ sw $v0, 4($a0) -/* 03A9D8 8005F5D8 3C02E900 */ lui $v0, 0xe900 -/* 03A9DC 8005F5DC AFA20018 */ sw $v0, 0x18($sp) -/* 03A9E0 8005F5E0 3C02DF00 */ lui $v0, 0xdf00 -/* 03A9E4 8005F5E4 0000302D */ daddu $a2, $zero, $zero -/* 03A9E8 8005F5E8 00C0382D */ daddu $a3, $a2, $zero -/* 03A9EC 8005F5EC AFA0001C */ sw $zero, 0x1c($sp) -/* 03A9F0 8005F5F0 AFA20020 */ sw $v0, 0x20($sp) -/* 03A9F4 8005F5F4 0C00B331 */ jal nuGfxTaskStart -/* 03A9F8 8005F5F8 AFA00024 */ sw $zero, 0x24($sp) -/* 03A9FC 8005F5FC 0C017CB4 */ jal nuGfxTaskAllEndWait -/* 03AA00 8005F600 00000000 */ nop -/* 03AA04 8005F604 8FBF0810 */ lw $ra, 0x810($sp) -/* 03AA08 8005F608 03E00008 */ jr $ra -/* 03AA0C 8005F60C 27BD0818 */ addiu $sp, $sp, 0x818 - diff --git a/asm/nonmatchings/os/code_3a850_le_a40/nuPiInit.s b/asm/nonmatchings/os/code_3a850_le_a40/nuPiInit.s deleted file mode 100644 index 936252342a..0000000000 --- a/asm/nonmatchings/os/code_3a850_le_a40/nuPiInit.s +++ /dev/null @@ -1,22 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel nuPiInit -/* 03A850 8005F450 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 03A854 8005F454 24040096 */ addiu $a0, $zero, 0x96 -/* 03A858 8005F458 3C05800B */ lui $a1, 0x800b -/* 03A85C 8005F45C 24A5C5D0 */ addiu $a1, $a1, -0x3a30 -/* 03A860 8005F460 3C06800B */ lui $a2, 0x800b -/* 03A864 8005F464 24C6C5E8 */ addiu $a2, $a2, -0x3a18 -/* 03A868 8005F468 AFBF0010 */ sw $ra, 0x10($sp) -/* 03A86C 8005F46C 0C018278 */ jal osCreatePiManager -/* 03A870 8005F470 24070032 */ addiu $a3, $zero, 0x32 -/* 03A874 8005F474 0C0183C4 */ jal osCartRomInit -/* 03A878 8005F478 00000000 */ nop -/* 03A87C 8005F47C 8FBF0010 */ lw $ra, 0x10($sp) -/* 03A880 8005F480 3C01800A */ lui $at, 0x800a -/* 03A884 8005F484 AC22A638 */ sw $v0, -0x59c8($at) -/* 03A888 8005F488 03E00008 */ jr $ra -/* 03A88C 8005F48C 27BD0018 */ addiu $sp, $sp, 0x18 - diff --git a/asm/nonmatchings/os/code_3a850_le_a40/nuPiReadRom.s b/asm/nonmatchings/os/code_3a850_le_a40/nuPiReadRom.s deleted file mode 100644 index c76516624f..0000000000 --- a/asm/nonmatchings/os/code_3a850_le_a40/nuPiReadRom.s +++ /dev/null @@ -1,61 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel nuPiReadRom -/* 03A890 8005F490 27BDFFA0 */ addiu $sp, $sp, -0x60 -/* 03A894 8005F494 AFB30054 */ sw $s3, 0x54($sp) -/* 03A898 8005F498 0080982D */ daddu $s3, $a0, $zero -/* 03A89C 8005F49C AFB20050 */ sw $s2, 0x50($sp) -/* 03A8A0 8005F4A0 00A0902D */ daddu $s2, $a1, $zero -/* 03A8A4 8005F4A4 AFB1004C */ sw $s1, 0x4c($sp) -/* 03A8A8 8005F4A8 00C0882D */ daddu $s1, $a2, $zero -/* 03A8AC 8005F4AC AFB00048 */ sw $s0, 0x48($sp) -/* 03A8B0 8005F4B0 27B00028 */ addiu $s0, $sp, 0x28 -/* 03A8B4 8005F4B4 0200202D */ daddu $a0, $s0, $zero -/* 03A8B8 8005F4B8 27A50040 */ addiu $a1, $sp, 0x40 -/* 03A8BC 8005F4BC AFBF0058 */ sw $ra, 0x58($sp) -/* 03A8C0 8005F4C0 0C019560 */ jal osCreateMesgQueue -/* 03A8C4 8005F4C4 24060001 */ addiu $a2, $zero, 1 -/* 03A8C8 8005F4C8 0240202D */ daddu $a0, $s2, $zero -/* 03A8CC 8005F4CC 0220282D */ daddu $a1, $s1, $zero -/* 03A8D0 8005F4D0 A3A00012 */ sb $zero, 0x12($sp) -/* 03A8D4 8005F4D4 0C0185C8 */ jal osInvalDCache -/* 03A8D8 8005F4D8 AFB00014 */ sw $s0, 0x14($sp) -/* 03A8DC 8005F4DC 0240202D */ daddu $a0, $s2, $zero -/* 03A8E0 8005F4E0 0C0185F4 */ jal osInvalICache -/* 03A8E4 8005F4E4 0220282D */ daddu $a1, $s1, $zero -/* 03A8E8 8005F4E8 12200015 */ beqz $s1, .L8005F540 -/* 03A8EC 8005F4EC 00000000 */ nop -.L8005F4F0: -/* 03A8F0 8005F4F0 2E224001 */ sltiu $v0, $s1, 0x4001 -/* 03A8F4 8005F4F4 14400002 */ bnez $v0, .L8005F500 -/* 03A8F8 8005F4F8 0220802D */ daddu $s0, $s1, $zero -/* 03A8FC 8005F4FC 24104000 */ addiu $s0, $zero, 0x4000 -.L8005F500: -/* 03A900 8005F500 27A50010 */ addiu $a1, $sp, 0x10 -/* 03A904 8005F504 3C04800A */ lui $a0, 0x800a -/* 03A908 8005F508 8C84A638 */ lw $a0, -0x59c8($a0) -/* 03A90C 8005F50C 0000302D */ daddu $a2, $zero, $zero -/* 03A910 8005F510 AFB20018 */ sw $s2, 0x18($sp) -/* 03A914 8005F514 AFB3001C */ sw $s3, 0x1c($sp) -/* 03A918 8005F518 0C018388 */ jal osEPiStartDma -/* 03A91C 8005F51C AFB00020 */ sw $s0, 0x20($sp) -/* 03A920 8005F520 27A40028 */ addiu $a0, $sp, 0x28 -/* 03A924 8005F524 27A50040 */ addiu $a1, $sp, 0x40 -/* 03A928 8005F528 0C0195BC */ jal osRecvMesg -/* 03A92C 8005F52C 24060001 */ addiu $a2, $zero, 1 -/* 03A930 8005F530 02709821 */ addu $s3, $s3, $s0 -/* 03A934 8005F534 02308823 */ subu $s1, $s1, $s0 -/* 03A938 8005F538 1620FFED */ bnez $s1, .L8005F4F0 -/* 03A93C 8005F53C 02509021 */ addu $s2, $s2, $s0 -.L8005F540: -/* 03A940 8005F540 8FBF0058 */ lw $ra, 0x58($sp) -/* 03A944 8005F544 8FB30054 */ lw $s3, 0x54($sp) -/* 03A948 8005F548 8FB20050 */ lw $s2, 0x50($sp) -/* 03A94C 8005F54C 8FB1004C */ lw $s1, 0x4c($sp) -/* 03A950 8005F550 8FB00048 */ lw $s0, 0x48($sp) -/* 03A954 8005F554 03E00008 */ jr $ra -/* 03A958 8005F558 27BD0060 */ addiu $sp, $sp, 0x60 - -/* 03A95C 8005F55C 00000000 */ nop diff --git a/asm/nonmatchings/os/code_3a6f0_len_110/nuGfxSetCfb.s b/asm/nonmatchings/os/nuGfxSetCfb/nuGfxSetCfb.s similarity index 100% rename from asm/nonmatchings/os/code_3a6f0_len_110/nuGfxSetCfb.s rename to asm/nonmatchings/os/nuGfxSetCfb/nuGfxSetCfb.s diff --git a/include/nu/nusys.h b/include/nu/nusys.h new file mode 100644 index 0000000000..b5cd46a06f --- /dev/null +++ b/include/nu/nusys.h @@ -0,0 +1,1052 @@ +/*======================================================================*/ +/* NuSYS */ +/* nusys.h */ +/* */ +/* Copyright (C) 1997, NINTENDO Co,Ltd. */ +/* */ +/*----------------------------------------------------------------------*/ +/* Ver 1.0 97/10/09 Created by Kensaku Ohki(SLANP) */ +/* Ver 1.2 98/07/12 Modified by Kensaku Ohki(SLANP) */ +/* Ver 2.0 90/01/23 Modified by Kensaku Ohki(SLANP) */ +/*----------------------------------------------------------------------*/ +/* $Id: nusys.h,v 1.21 1999/01/26 02:33:26 ohki Exp $ */ +/*======================================================================*/ +#ifndef _NUSYS_H_ +#define _NUSYS_H_ + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +#ifndef F3DEX_GBI +#define F3DEX_GBI +#endif /* F3DEX_GBI */ + +#include +#include +#endif + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* DEFINE */ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +#define NU_VERSION "1.0" + +/*--------------------------------------*/ +/* NuSystem spec define */ +/*--------------------------------------*/ +#define NU_SPEC_BOOT_STACK_SIZE 0x2000 +#define NU_SPEC_BOOT_ADDR 0x80025c00 +#define NU_SPEC_BOOT_STACK nuMainStack + NU_SPEC_BOOT_STACK_SIZE + +/*--------------------------------------*/ +/* Thread ID for DEBUG (a precaution) */ +/*--------------------------------------*/ +#define NU_IDLE_THREAD_ID 1 +#define NU_RMON_THERAD_ID 2 /* no use */ +#define NU_MAIN_THREAD_ID 3 + + +/*--------------------------------------*/ +/* NuSYS Thread Priority */ +/*--------------------------------------*/ +#define NU_IDLE_THREAD_PRI OS_PRIORITY_IDLE /* Idle thread */ +#define NU_RMON_THREAD_PRI OS_PRIORITY_RMON /* no use */ +#define NU_MAIN_THREAD_PRI 10 /* main thread */ + +/*--------------------------------------*/ +/* NUSYS STACK SIZE */ +/*--------------------------------------*/ +#define NU_IDLE_STACK_SIZE 0x2000 /* Idle thread */ +#define NU_MAIN_STACK_SIZE NU_SPEC_BOOT_STACK_SIZE /* Main thread */ + + + + +/*----------------------------------------------------------------------*/ +/* SCHEDULER DEFINE */ +/*----------------------------------------------------------------------*/ +#define NU_SC_STACK_SIZE 0x2000 /* Thread stack size */ +#define NU_SC_NOSWAPBUFFER 0x0000 /* No swap */ +#define NU_SC_SWAPBUFFER 0x0001 /* Swap frame buffer */ +#define NU_SC_NORDP 0x0002 /* Do not wait for RDP finish */ +#define NU_SC_UCODE_XBUS 0x0004 /* XBUS Ucode */ +#define NU_SC_TASK_YIELDED (OS_TASK_YIELEDE<<16) +#define NU_SC_TASK_DP_WAIT (OS_TASK_DP_WAIT<<16) /* RDP WAIT */ +#define NU_SC_TASK_LODABLE (OS_TASK_LOADBLE<<16) /* LOADABLE */ +#define NU_SC_TASK_SP_ONLY (OS_TASK_SP_ONLY<<16) /* SP ONLY */ + + +#define NU_SC_RETRACE_MSG 0x0001 /* Retrace message */ +#define NU_SC_PRENMI_MSG 0x0002 /* NMI message */ +#define NU_SC_SWAPBUFFER_MSG 0x0004 /* Swap frame buffer message*/ +#define NU_SC_GTASKEND_MSG 0x0008 /* Task finished message */ +#define NU_SC_MAX_MESGS 8 /* Message buffer size */ + +#define NU_SC_HANDLER_PRI 120 /* EVENT HANDLER THREAD PRORITY */ +#define NU_SC_AUDIO_PRI 110 /* AUDIO DISPATCHER THREAD PRORITY */ +#define NU_SC_GRAPHICS_PRI 100 /* GFX DISPATCHER THREAD PRORITY */ +#define NU_SC_PRENMI_YET 0 /* PRE NMI has not occurred. */ +#define NU_SC_PRENMI_GET 1 /* PRE NMI received flag */ +#define NU_SC_BEFORE_RESET 2 /* Pre-RESET flag for frame before reset */ +#define NU_SC_BEFORE_RESET_FRAME 2 /* Number of frames before reset where BEFORE_RESET flag is set. */ +/*----------------------------------------------------------------------*/ +/* GRAFIC THREAD DEFINE */ +/*----------------------------------------------------------------------*/ +#define NU_GFX_THREAD_ID 4 +#define NU_GFX_TASKMGR_THREAD_ID 5 +#define NU_GFX_STACK_SIZE 0x2000 /* Thread stack size */ +#define NU_GFX_MESGS 8 /* GFX message queue*/ +#define NU_GFX_TASKMGR_STACK_SIZE 0x2000 /* Stack size */ +#define NU_GFX_TASKMGR_MESGS 8 /*Task Manager queue*/ +#define NU_GFX_THREAD_PRI 50 /* GFX thread priority */ +#define NU_GFX_TASKMGR_THREAD_PRI 60 /* Task Manager priority */ + +/*----------------------------------------------------------------------*/ +/* GRAFIC MANEGER DEFINE */ +/*----------------------------------------------------------------------*/ +#ifdef F3DEX_GBI_2 +#define NU_GFX_UCODE_F3DEX2 0 /* F3DEX microcode */ +#define NU_GFX_UCODE_F3DEX2_NON 1 /* F3DEX.NoN microcode */ +#define NU_GFX_UCODE_F3DEX2_REJ 2 /* F3DEX.NoN microcode */ +#define NU_GFX_UCODE_F3DLX2_REJ 3 /* F3DEX.ReJ microcode */ +#define NU_GFX_UCODE_L3DEX2 4 /* L3DEX microcode */ +#define NU_GFX_UCODE_S2DEX2 5 /* S2DEX microcode */ + +#define NU_GFX_UCODE_F3DEX 0 /* For compatibility */ +#define NU_GFX_UCODE_F3DEX_NON 1 /* For compatibility */ +#define NU_GFX_UCODE_F3DLX 0 /* For compatibility */ +#define NU_GFX_UCODE_F3DLX_NON 1 /* For compatibility */ +#define NU_GFX_UCODE_F3DLX_REJ 4 /* For compatibility */ +#define NU_GFX_UCODE_F3DLP_REJ 3 /* For compatibility */ +#define NU_GFX_UCODE_L3DEX 4 /* For compatibility */ +#define NU_GFX_UCODE_S2DEX 5 /* For compatibility */ +#define NU_GFX_UCODE_S2DEX_D 5 /* For compatibility */ + +#else +#define NU_GFX_UCODE_F3DEX 0 /* F3DEX microcode */ +#define NU_GFX_UCODE_F3DEX_NON 1 /* F3DEX.NoN microcode */ +#define NU_GFX_UCODE_F3DLX 2 /* F3DLX microcode */ +#define NU_GFX_UCODE_F3DLX_NON 3 /* F3DLX.NoN microcode */ +#define NU_GFX_UCODE_F3DLX_REJ 4 /* F3DEX.ReJ microcode */ +#define NU_GFX_UCODE_F3DLP_REJ 5 /* F3DLP.Rej microcode */ +#define NU_GFX_UCODE_L3DEX 6 /* L3DEX microcode */ +#define NU_GFX_UCODE_S2DEX 7 /* S2DEX microcode */ +#define NU_GFX_UCODE_S2DEX_D 8 /* S2DEX microcode */ +#endif /* F3DEX_GBI_2 */ + + +/*--------------------------------------*/ +/* The number of graphics task structures */ +/* should be set to a value at least as large as the Scheduler*/ +/* message buffer size. */ +/* Otherwise, a task structure in use may */ +/* be used. */ +/*--------------------------------------*/ +#define NU_GFX_TASK_NUM 10 /* Number of graphics task structures */ +#define NU_GFX_RDP_OUTPUTBUFF_SIZE 0x20000 /* fifo buffer size */ + +/*--------------------------------------*/ +/* Default frame buffer */ +/* The default frame buffer */ +/* is the 320x240 16-bit triple */ +/* xxbuffer in the high-order */ +/* area of RDRAM.xx */ +/*--------------------------------------*/ +#define NU_GFX_FRAMEBUFFER_NUM 3 +#define NU_GFX_FRAMEBUFFER_ADDR (0x80400000-320*240*2*3) +#define NU_GFX_FRAMEBUFFER0_ADDR (NU_GFX_FRAMEBUFFER_ADDR) +#define NU_GFX_FRAMEBUFFER1_ADDR (NU_GFX_FRAMEBUFFER0_ADDR+320*240*2) +#define NU_GFX_FRAMEBUFFER2_ADDR (NU_GFX_FRAMEBUFFER1_ADDR+320*240*2) + +#define NU_GFX_INIT_SCREEN_WD 320 +#define NU_GFX_INIT_SCREEN_HT 240 + +/*--------------------------------------*/ +/* Default Z -buffer is located in */ +/* xxlow-order memory.xx */ +/*--------------------------------------*/ +#define NU_GFX_ZBUFFER_ADDR 0x80000400 + +#define NU_GFX_DISPLAY_OFF 0 /* No display */ +#define NU_GFX_DISPLAY_ON 1 /* Display */ +#define NU_GFX_DISPLAY_ON_TRIGGER 0x80 /* Trigger */ + + +/*----------------------------------------------------------------------*/ +/* SI MANAGER DEFINE */ +/*----------------------------------------------------------------------*/ +#define NU_SI_STACK_SIZE NU_CONT_STACK_SIZE +#define NU_SI_THREAD_ID NU_CONT_THREAD_ID +#define NU_SI_THREAD_PRI NU_CONT_THREAD_PRI +#define NU_SI_MESG_MAX NU_CONT_MESG_MAX +#define NU_SI_CALLBACK_END 1 +#define NU_SI_CALLBACK_CONTINUE 0 +#define NU_SI_SC_MAJOR_NO 0x0000 +#define NU_SI_MSG_MAJOR_NO_MASK 0xff00 +#define NU_SI_MSG_MINOR_NO_MASK 0x00ff + +#define NU_SI_MAJOR_NO_CONT 0x0100 +#define NU_SI_MAJOR_NO_PAK 0x0200 +#define NU_SI_MAJOR_NO_RMB 0x0300 +#define NU_SI_MAJOR_NO_EEPROM 0x0400 +#define NU_SI_MAJOR_NO_GBPAK 0x0500 +#define NU_SI_MAJOR_NO_VRS 0x0600 +#define NU_SI_STOP_MGR_MSG 0x7F00 + +/*----------------------------------------------------------------------*/ +/* CONTROLLER MANEGER DEFINE */ +/*----------------------------------------------------------------------*/ +#define NU_CONT_MAXCONTROLLERS MAXCONTROLLERS +#define NU_CONT_STACK_SIZE 0x2000 +#define NU_CONT_MESG_MAX 8 +#define NU_CONT_THREAD_ID 5 +#define NU_CONT_THREAD_PRI 115 +#define NU_CONT_DATA_UNLOCK 0 +#define NU_CONT_DATA_LOCK 1 + + +/*----------------------------------------------------------------------*/ +/* Define messages sent to the Controller Manager */ +/*----------------------------------------------------------------------*/ +#define NU_CONT_MSG_BASE NU_SI_MAJOR_NO_CONT +#define NU_CONT_RETRACE_MSG (NU_CONT_MSG_BASE+0) +#define NU_CONT_READ_MSG (NU_CONT_MSG_BASE+1) +#define NU_CONT_READ_NW_MSG (NU_CONT_MSG_BASE+2) +#define NU_CONT_QUERY_MSG (NU_CONT_MSG_BASE+3) + + +#define NU_CONT_PAK_MSG_BASE NU_SI_MAJOR_NO_PAK +#define NU_CONT_PAK_RETRACE_MSG (NU_CONT_PAK_MSG_BASE+0) +#define NU_CONT_PAK_OPEN_MSG (NU_CONT_PAK_MSG_BASE+1) +#define NU_CONT_PAK_FREE_MSG (NU_CONT_PAK_MSG_BASE+2) +#define NU_CONT_PAK_FOPEN_MSG (NU_CONT_PAK_MSG_BASE+3) +#define NU_CONT_PAK_READWRITE_MSG (NU_CONT_PAK_MSG_BASE+4) +#define NU_CONT_PAK_FILEDELETE_MSG (NU_CONT_PAK_MSG_BASE+5) +#define NU_CONT_PAK_FILESTATE_MSG (NU_CONT_PAK_MSG_BASE+6) +#define NU_CONT_PAK_FILENUM_MSG (NU_CONT_PAK_MSG_BASE+7) +#define NU_CONT_PAK_REPAIRID_MSG (NU_CONT_PAK_MSG_BASE+8) + +#define NU_CONT_PAK_MODE_NOCREATE 0 +#define NU_CONT_PAK_MODE_CREATE 1 +#define NU_CONT_PAK_TYPE_NONE 0 +#define NU_CONT_PAK_TYPE_PAK 1 /* Controller Pak */ +#define NU_CONT_PAK_TYPE_RUMBLE 2 /* Rumble Pak */ +#define NU_CONT_PAK_TYPE_GBPAK 3 /* 64GB Pak */ +#define NU_CONT_PAK_READ PFS_READ +#define NU_CONT_PAK_WRITE PFS_WRITE + +/*----------------------------------------------------------------------*/ +/* Rumble Pak control */ +/*----------------------------------------------------------------------*/ +#define NU_CONT_RMB_STATE_STOP 0x00 +#define NU_CONT_RMB_STATE_STOPPING 0x01 +#define NU_CONT_RMB_STATE_STOPPED 0x02 +#define NU_CONT_RMB_STATE_RUN 0x03 +#define NU_CONT_RMB_STATE_FORCESTOP 0x04 +#define NU_CONT_RMB_MODE_DISABLE 0x00 +#define NU_CONT_RMB_MODE_ENABLE 0x01 +#define NU_CONT_RMB_MODE_AUTORUN 0x02 +#define NU_CONT_RMB_MODE_PAUSE 0x80 +#define NU_CONT_RMB_AUTO_SEARCH 0x00 +#define NU_CONT_RMB_AUTO_FIND 0x01 +#define NU_CONT_RMB_AUTO_SEARCHTIME (60*5) +#define NU_CONT_RMB_MSG_BASE NU_SI_MAJOR_NO_RMB +#define NU_CONT_RMB_RETRACE_MSG (NU_CONT_RMB_MSG_BASE+0) +#define NU_CONT_RMB_CHECK_MSG (NU_CONT_RMB_MSG_BASE+1) +#define NU_CONT_RMB_START_MSG (NU_CONT_RMB_MSG_BASE+2) +#define NU_CONT_RMB_STOP_MSG (NU_CONT_RMB_MSG_BASE+3) +#define NU_CONT_RMB_FORCESTOP_MSG (NU_CONT_RMB_MSG_BASE+4) +#define NU_CONT_RMB_FORCESTOPEND_MSG (NU_CONT_RMB_MSG_BASE+5) + +/*----------------------------------------------------------------------*/ +/* EEPROM */ +/*----------------------------------------------------------------------*/ +#define NU_EEPROM_MSG_BASE NU_SI_MAJOR_NO_EEPROM +#define NU_EEPROM_RETRACE_MSG (NU_EEPROM_MSG_BASE+0) +#define NU_EEPROM_CHECK_MSG (NU_EEPROM_MSG_BASE+1) +#define NU_EEPROM_READ_MSG (NU_EEPROM_MSG_BASE+2) +#define NU_EEPROM_WRITE_MSG (NU_EEPROM_MSG_BASE+3) + + +/*----------------------------------------------------------------------*/ +/* 64GB Pack Manager */ +/*----------------------------------------------------------------------*/ +#define NU_CONT_GBPAK_MSG_BASE NU_SI_MAJOR_NO_GBPAK +#define NU_CONT_GBPAK_RETRACE_MSG (NU_CONT_GBPAK_MSG_BASE+0) +#define NU_CONT_GBPAK_OPEN_MSG (NU_CONT_GBPAK_MSG_BASE+1) +#define NU_CONT_GBPAK_STATUS_MSG (NU_CONT_GBPAK_MSG_BASE+2) +#define NU_CONT_GBPAK_POWER_MSG (NU_CONT_GBPAK_MSG_BASE+3) +#define NU_CONT_GBPAK_READID_MSG (NU_CONT_GBPAK_MSG_BASE+4) +#define NU_CONT_GBPAK_READWRITE_MSG (NU_CONT_GBPAK_MSG_BASE+5) +#define NU_CONT_GBPAK_CHECKCONNECTOR_MSG (NU_CONT_GBPAK_MSG_BASE+6) + +#define NU_CONT_GBPAK_POWER_OFF OS_GBPAK_POWER_OFF +#define NU_CONT_GBPAK_POWER_ON OS_GBPAK_POWER_ON +#define NU_CONT_GBPAK_MBC_RAM_ENABLE_CODE 0x0a +#define NU_CONT_GBPAK_MBC_RAM_DISABLE_CODE 0x00 +#define NU_CONT_GBPAK_MBC_RAM_REG0_ADDR 0x0000 + +#define NU_CONT_GBPAK_MBC_REG0_ADDR 0x0000 /* Register 0 */ +#define NU_CONT_GBPAK_MBC_REG1_ADDR 0x2100 /* Register 1 */ +#define NU_CONT_GBPAK_MBC_REG2_ADDR 0x4000 /* Register 2 */ +#define NU_CONT_GBPAK_MBC_REG3_ADDR 0x6000 /* Register 3 */ + +/*----------------------------------------------------------------------*/ +/* Voice Recognition System Manager */ +/*----------------------------------------------------------------------*/ +#define NU_VRS_MSG_BASE NU_SI_MAJOR_NO_VRS +#define NU_VRS_RETRACE_MSG (NU_VRS_MSG_BASE+0) +#define NU_VRS_OPEN_MSG (NU_VRS_MSG_BASE+1) +#define NU_VRS_CLEAR_DICTIONARY_MSG (NU_VRS_MSG_BASE+2) +#define NU_VRS_SET_WORD_MSG (NU_VRS_MSG_BASE+3) +#define NU_VRS_MASK_DICTIONARY_MSG (NU_VRS_MSG_BASE+4) +#define NU_VRS_START_READ_DATA_MSG (NU_VRS_MSG_BASE+5) +#define NU_VRS_GET_READ_DATA_MSG (NU_VRS_MSG_BASE+6) +#define NU_VRS_STOP_READ_DATA_MSG (NU_VRS_MSG_BASE+7) +#define NU_VRS_CONTROL_GAIN_MSG (NU_VRS_MSG_BASE+8) + +/*----------------------------------------------------------------------*/ +/* PI DEFINE */ +/*----------------------------------------------------------------------*/ +#define NU_PI_MESG_NUM 50 /* PI message buffer size */ +#define NU_PI_CART_BLOCK_READ_SIZE 0x4000 /* cart read block size */ + +/*----------------------------------------------------------------------*/ +/* DEBUG */ +/*----------------------------------------------------------------------*/ +#define NU_DEB_PERF_GFXTASK_CNT 8 /* Graphics task count */ +#define NU_DEB_PERF_AUTASK_CNT 4 /* Audio task count */ +#define NU_DEB_DP_CLOCK_CTR 0 /* RDP internal counter */ +#define NU_DEB_DP_CMD_CTR 1 /* CMD counter */ +#define NU_DEB_DP_PIPE_CTR 2 /* PIPE counter */ +#define NU_DEB_DP_TMEM_CTR 3 /* TMEM counter */ +#define NU_DEB_BAR_FRAME1 0 /* For the performance bar */ +#define NU_DEB_BAR_FRAME2 1 /* Maximum number displayed */ +#define NU_DEB_BAR_FRAME3 2 +#define NU_DEB_BAR_FRAME4 3 +#define NU_DEB_BAR_FRAME5 4 +#define NU_DEB_BAR_FRAME6 5 +#define NU_DEB_BAR_FRAME7 6 +#define NU_DEB_CON_ROW_MAX 40 /* Number of rows in console */ +#define NU_DEB_CON_COLUMN_MAX 30 /* Number of columns in console */ +#define NU_DEB_CON_TEXT_SIZE (NU_DEB_CON_ROW_MAX*NU_DEB_CON_COLUMN_MAX) +#define NU_DEB_CON_WIDTH 320 +#define NU_DEB_CON_WINDOW_NUM 4 +#define NU_DEB_CON_WINDOW0 0 +#define NU_DEB_CON_WINDOW1 1 +#define NU_DEB_CON_WINDOW2 2 +#define NU_DEB_CON_WINDOW3 3 +#define NU_DEB_CON_TEXT_BLACK 0 /* Black */ +#define NU_DEB_CON_TEXT_BLUE 1 /* Blue */ +#define NU_DEB_CON_TEXT_GREEN 2 /* Green */ +#define NU_DEB_CON_TEXT_CYAN 3 /* Cyan */ +#define NU_DEB_CON_TEXT_RED 4 /* Red */ +#define NU_DEB_CON_TEXT_MAGENTA 5 /* Magenta */ +#define NU_DEB_CON_TEXT_YELLOW 6 /* yellow */ +#define NU_DEB_CON_TEXT_WHITE 7 /* White */ +#define NU_DEB_CON_TEXT_LIGHTBLACK 8 /* Gray */ +#define NU_DEB_CON_TEXT_LIGHTBLUE 9 /* Bright Blue */ +#define NU_DEB_CON_TEXT_LIGTHBLUE 9 /* Bright Blue (misspelled) */ +#define NU_DEB_CON_TEXT_LIGHTGREEN 10 /* Bright Green */ +#define NU_DEB_CON_TEXT_LIGHTCYAN 11 /* Bright Cyan */ +#define NU_DEB_CON_TEXT_LIGHTRED 12 /* Bright Red */ +#define NU_DEB_CON_TEXT_LIGHTMAGENTA 13 /* Bright Magenta */ +#define NU_DEB_CON_TEXT_LIGHTYELLOW 14 /* Bright yellow */ +#define NU_DEB_CON_TEXT_LIGHTWHITE 15 /* White */ +#define NU_DEB_CON_ATTR_NORMAL 0x0 /* No attribute*/ +#define NU_DEB_CON_ATTR_BLINK 0x1 /* Blinking */ +#define NU_DEB_CON_ATTR_REVERSE 0x2 /* Highlight */ +#define NU_DEB_CON_SCROLL_ON 1 +#define NU_DEB_CON_SCROLL_OFF 0 +#define NU_DEB_CON_WINDOW_OFF 0 +#define NU_DEB_CON_WINDOW_ON 1 + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* structer define */ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/*--------------------------------------*/ +/* Scheduler sturcter */ +/*--------------------------------------*/ +typedef short NUScMsg; /* Scheduler message type */ + +typedef struct st_SCClient { /* Client list structure */ + struct st_SCClient* next; /* Pointer to next client */ + OSMesgQueue* msgQ; /* Message sent to client */ + NUScMsg msgType; /* Type of message */ + /* NU_SC_RETRACE_MSG or*/ + /* NU_SC_PRENMI_MSG */ +} NUScClient; + +typedef struct st_SCTask { /* Task structure */ + struct st_SCTask *next; + u32 state; + u32 flags; + void *framebuffer; /* For graphics tasks */ + OSTask list; + OSMesgQueue *msgQ; + OSMesg msg; +} NUScTask; + +typedef struct st_Sched { /* Define the Scheduler structure. */ + + /* message */ + NUScMsg retraceMsg; + NUScMsg prenmiMsg; + + /* Define the Task request queue. */ + OSMesgQueue audioRequestMQ; + OSMesg audioRequestBuf[NU_SC_MAX_MESGS]; + OSMesgQueue graphicsRequestMQ; + OSMesg graphicsRequestBuf[NU_SC_MAX_MESGS]; + + /* Define the message queue. */ + OSMesgQueue retraceMQ; + OSMesg retraceMsgBuf[NU_SC_MAX_MESGS]; + OSMesgQueue rspMQ; + OSMesg rspMsgBuf[NU_SC_MAX_MESGS]; + OSMesgQueue rdpMQ; + OSMesg rdpMsgBuf[NU_SC_MAX_MESGS]; + + /* Implement wait for next retrace. */ + OSMesgQueue waitMQ; + OSMesg waitMsgBuf[NU_SC_MAX_MESGS]; + + /* Define threads.*/ + OSThread schedulerThread; /* Main thread */ + OSThread audioThread; /* Audio */ + OSThread graphicsThread; /* Graphics */ + + /* client list */ + NUScClient *clientList; + + /* The graphics task being executed. */ + NUScTask *curGraphicsTask; + NUScTask *curAudioTask; + NUScTask *graphicsTaskSuspended; + + u32 retraceCount; + u8 frameRate; + u8 frameBufferNum; /* Number of frame buffers */ + + +} NUSched; + + +/*--------------------------------------*/ +/* ucode structure */ +/*--------------------------------------*/ +typedef struct st_Ucode { + u64* ucode; + u64* ucode_data; +} NUUcode; + +/*--------------------------------------*/ +/* CALL BACK Function typedef */ +/*--------------------------------------*/ +typedef void (*NUIdleFunc)(void); /* Pointer to the idle callback function */ +typedef void (*NUScPreNMIFunc)(void); /* Pointer to PRENMI callback function */ +typedef void (*NUGfxFunc)(u32); /* Pointer to the GFX retrace callback function */ +typedef void (*NUGfxPreNMIFunc)(void); /* Pointer to the GFX PRENMI callback function */ + +typedef void (*NUGfxSwapCfbFunc)(void*);/* Pointer to the SWAPBUF callback function */ +typedef void (*NUGfxTaskEndFunc)(void*);/* Pointer to the TASKEND callback function */ +typedef void (*NUContReadFunc)(u32); /* Pointer to the Controller end-read */ + /* callback function */ +typedef void (*NUContPakFunc)(void*); /* Controller Pak control function callback */ +typedef void (*NUContRmbFunc)(void*); /* Rumble Pak control function callback */ +typedef s32 (*NUCallBackFunc)(void*); /* Callback function */ + + +/*--------------------------------------*/ +/* SI Common message */ +/*--------------------------------------*/ +typedef struct st_SiCommonMesg { + NUScMsg mesg; + OSMesgQueue* rtnMesgQ; + s32 error; + void* dataPtr; +} NUSiCommonMesg; + +/*--------------------------------------*/ +/* controller typedef */ +/*--------------------------------------*/ +typedef struct st_ContRead { + NUScMsg mesg; /* Type of message */ + OSMesgQueue* rtnMesgQ; + OSContPad* pad; +} NUContReadMesg; + +typedef struct st_ContData { + u16 button; /* A,B,C,Z,L,R,START,PAD ,button */ + s8 stick_x; /* Range acutally used: -61 <= stick X <= 61 */ + s8 stick_y; /* Range actually used: -63 <= stick Y <= 63 */ + u8 errno; /* Error */ + u16 trigger; /* Button trigger data */ +} NUContData; + +typedef struct st_ContQuery { + NUScMsg mesg; + OSMesgQueue* rtnMesgQ; +} NUContQueryMesg; + + +typedef struct st_ContPakFile { + OSPfs *pfs; + s32 file_no; + s32 error; + u32 type; +} NUContPakFile; + + +typedef struct st_ContPakFreeMesg { + NUContPakFile* file; + s32 size; +} NUContPakFreeMesg; + +typedef struct st_ContPakFileOpenMesg { + NUContPakFile* file; + u8* noteName; + u8* extName; + s32 size; + s32 mode; +} NUContPakFileOpenMesg; + +typedef struct st_ContPakFileRWMesg { + NUContPakFile* file; + s32 offset; + s32 size; + u8 mode; + u8* buf; +} NUContPakFileRWMesg; + +typedef struct st_ContPakFileStateMesg { + NUContPakFile* file; + OSPfsState* state; +} NUContPakFileStateMesg; + +typedef struct st_ContPakFileNumMesg { + NUContPakFile* file; + s32* max_files; + s32* used_files; +} NUContPakFileNumMesg; + +typedef struct st_ContPakIsPlugMesg { + NUScMsg mesg; + OSMesgQueue* rtnMesgQ; + s32 error; + u8 bitPattern; +} NUContPakIsPlugMesg; + +typedef struct st_ContRmbCtl { + u16 freq; /* Vibration frequency */ + u16 frame; + u16 counter; + u8 state; + u8 mode; + u8 autorun; + u8 type; +} NUContRmbCtl; + +typedef struct st_ContRmbMesg { + u8 contNo; + s32 error; + void* data; +} NUContRmbMesg; + +typedef struct st_CallBackList { + struct st_CallBackList* next; + s32 (**func)(NUSiCommonMesg*); + u16 majorNo; + u8 funcNum; +} NUCallBackList; + +typedef struct st_EepromMesg { + void* dataPtr; + s32 error; + u8 address; + u16 dataLen; +} NUEepromMesg; + +typedef struct st_ContGBPakMesg { + NUContPakFile* handle; + s32 data[4]; +} NUContGBPakMesg; + +typedef OSVoiceHandle NUVrsHandle; + +typedef OSVoiceData NUVrsData; + +typedef struct stVrsMesg { + NUVrsHandle* vrsHandle; + s32 data[2]; +} NUVrsMesg; + +/*--------------------------------------*/ +/* Debug */ +/*--------------------------------------*/ +typedef struct st_GfxTaskTime { + s64 rspStart; /* RSPTask start time */ + s64 rspEnd; /* RSPTask end time */ + s64 rdpEnd; /* RDP end time */ + u32 dpCnt[4]; /* RDP internal counter */ +} NUDebTaskTime; + +typedef struct st_DebTaskPerf { + s64 retraceTime; /* retrace event time*/ + u8 gfxTaskCnt; /* Number of graphics tasks */ + u8 auTaskCnt; /* Number of audio tasks */ + u8 gfxTaskStart; + NUDebTaskTime gfxTaskTime[NU_DEB_PERF_GFXTASK_CNT]; + NUDebTaskTime auTaskTime[NU_DEB_PERF_AUTASK_CNT]; +} NUDebTaskPerf; + +/* Console window structure */ +typedef struct st_DebConWindow { + u8 windowFlag; /* On/off flag for console window display */ + u16 scroll; /* Scroll value */ + u8 scrollFlag; /* Scrolling enabled/disabled */ + u8 textColor; /* Character color */ + u8 attribute; /* Attribute */ + u16 posX; /* Column position for write */ + u16 posY; /* Line position for write */ + u16 index; /* Position for character buffer write */ + u16 winX; /* x-coordinate of console window display */ + u16 winY; /* y-coordinate of console window display */ + u16 winW; /* Number of columns in console display */ + u16 winH; /* Number of rows in console display */ + u16 text[NU_DEB_CON_TEXT_SIZE]; /* Character buffer*/ +} NUDebConWindow; + +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* extern variables */ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ + +extern u8 nuRDPOutputBuf[NU_GFX_RDP_OUTPUTBUFF_SIZE]; +extern u8 nuDramStack[SP_DRAM_STACK_SIZE8]; +extern u8 nuYieldBuf[OS_YIELD_DATA_SIZE]; +extern NUSched nusched; /* Scheduler structure */ +extern OSMesgQueue nuGfxMesgQ; /* Graphics thread queue */ +extern u32 nuScRetraceCounter; /* Retrace counter */ +extern u8 nuScPreNMIFlag; +/*--------------------------------------*/ +/* graphics variables */ +/*--------------------------------------*/ +extern NUUcode* nuGfxUcode; /* Pointer to GFX microcode structure */ +extern u16** nuGfxCfb; /* Pointer to array of pointers to frame buffers */ +extern u16* nuGfxCfb_ptr; /* Pointer to to frame buffer */ +extern u32 nuGfxCfbNum; /* Number of frame buffers */ +extern u16* nuGfxZBuffer; /* Pointer to the Z buffer */ +extern volatile u32 nuGfxTaskSpool; /* Number of tasks in queue */ +extern u32 nuGfxDisplay; /* Display on/off flag */ +extern u32 nuGfxCfbCounter; /* For frame buffer swapping */ + +/*--------------------------------------*/ +/* controller Manager variables */ +/*--------------------------------------*/ +extern OSContStatus nuContStatus[NU_CONT_MAXCONTROLLERS]; +extern OSContPad nuContData[NU_CONT_MAXCONTROLLERS]; +extern u32 nuContNum; /* Number of controllers connected */ +extern u32 nuContDataLockKey; /* Lock Controller data. */ +extern OSMesgQueue nuContWaitMesgQ; /* Wait for Controller read */ +extern OSPfs nuContPfs[4]; +extern NUCallBackList nuContCallBack; +extern u16 nuContPakCompanyCode; /* Company code */ +extern u32 nuContPakGameCode; /* Game code */ +extern NUCallBackList nuContPakCallBack; + +/*--------------------------------------*/ +/* RUMBUL Manager variables */ +/*--------------------------------------*/ +extern NUContRmbCtl nuContRmbCtl[4]; +extern u32 nuContRmbSearchTime; +extern NUCallBackList nuContRmbCallBack; + + +/*--------------------------------------*/ +/* EEPROM Manager variables */ +/*--------------------------------------*/ +extern NUCallBackList nuEepromCallBack; + +/*--------------------------------------*/ +/* 64GBPack Manager variables */ +/*--------------------------------------*/ +extern NUCallBackList nuContGBPakCallBack; + +/*--------------------------------------*/ +/* VRS Manager variables */ +/*--------------------------------------*/ +extern NUCallBackList nuVrsCallBack; + +/*--------------------------------------*/ +/* si variables */ +/*--------------------------------------*/ +extern OSMesgQueue nuSiMesgQ; /* SI event message queue */ +extern OSMesgQueue nuSiMgrMesgQ; /* SI Manager queue */ +extern NUCallBackList* nuSiCallBackList;/* Callback function list */ + +/*--------------------------------------*/ +/* pi variables */ +/*--------------------------------------*/ +extern OSPiHandle* nuPiCartHandle; +extern OSPiHandle* nuPiSramHandle; + +/*--------------------------------------*/ +/* CALL BACK Function pointer */ +/*--------------------------------------*/ +extern NUIdleFunc nuIdleFunc; /* callback func pointer */ +extern NUScPreNMIFunc nuScPreNMIFunc; /* PRE NMI callback pointer */ +extern NUGfxSwapCfbFunc nuGfxSwapCfbFunc; /* swapbuf callback pointer */ +extern NUGfxFunc nuGfxFunc; /* callback pointer */ +extern NUGfxPreNMIFunc nuGfxPreNMIFunc; /* Callback pointer */ +extern NUGfxTaskEndFunc nuGfxTaskEndFunc; /* task end callback ptr */ +extern NUContReadFunc nuContReadFunc; /* When controller read ends */ + /* Callback function */ +/*--------------------------------------*/ +/* Debug */ +/*--------------------------------------*/ +extern NUDebTaskPerf* nuDebTaskPerfPtr; +extern NUDebConWindow nuDebConWin[]; + +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* Global Function */ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/*--------------------------------------*/ +/* Boot function */ +/*--------------------------------------*/ +extern void nuIdleFuncSet(void (*func)(void)); +extern void nuPreNMIFuncSet(NUScPreNMIFunc func); +/*--------------------------------------*/ +/* Scheduler function */ +/*--------------------------------------*/ +extern void nuScCreateScheduler(u8 videoMode, u8 numFields); +extern void nuScAddClient(NUScClient *c, OSMesgQueue *mq, NUScMsg msgType); +extern void nuScRemoveClient(NUScClient *client); +extern void nuScResetClientMesgType(NUScClient* client, NUScMsg msgType); +/* extern void nuPreNMIFuncSet(NUScPreNMIFunc func); redundant extern warning */ +extern OSMesgQueue* nuScGetGfxMQ(void); +extern OSMesgQueue* nuScGetAudioMQ(void); +extern void nuScSetFrameBufferNum(u8 frameBufferNum); +extern s32 nuScGetFrameRate(void); + +/*--------------------------------------*/ +/* graphic(GFX) Manager function */ +/*--------------------------------------*/ +extern void nuGfxInit(void); +extern void nuGfxInitEX2(void); +extern void nuGfxThreadStart(void); +extern void nuGfxTaskMgrInit(void); +extern void nuGfxTaskStart(Gfx *gfxList_ptr, u32 gfxListSize, u32 ucode, u32 flag); +extern void nuGfxFuncSet(NUGfxFunc func); +extern void nuGfxPreNMIFuncSet(NUGfxPreNMIFunc func); +extern void nuGfxSwapCfbFuncSet(NUGfxSwapCfbFunc func); +extern void nuGfxSetCfb(u16** framebuf, u32 framebufnum); +extern void nuGfxSwapCfb(void* framebuffer); + +extern void nuGfxTaskEndFuncSet(NUGfxTaskEndFunc func); +extern void nuGfxTaskAllEndWait(void); +extern void nuGfxRetraceWait(u32 retrace_num); +extern void nuGfxDisplayOff(void); +extern void nuGfxDisplayOn(void); + +/* #ifdef F3DEX_GBI_2 + #define nuGfxInit() nuGfxInitEX2() + #endif /* F3DEX_GBI_2 */ +/*--------------------------------------*/ +/* controller Manager function */ +/*--------------------------------------*/ +extern u8 nuContInit(void); +extern s32 nuContMgr(void* mesg); +extern u8 nuContMgrInit(void); +extern void nuContMgrRemove(void); +extern void nuContDataLock(void); +extern void nuContDataUnLock(void); +extern void nuContDataRead(OSContPad* pad); +extern void nuContDataReadWait(void); +extern void nuContDataReadStart(void); +extern void nuContDataGet(OSContPad* contdata, u32 padno); +extern void nuContDataGetAll(OSContPad* contdata); +extern void nuContDataGetEx(NUContData *contdata, u32 padno); +extern void nuContDataGetExAll(NUContData *contdata); +extern void nuContReadFuncSet(NUContReadFunc func); +extern void nuContQueryRead(void); +extern void nuContDataClose(void); +extern void nuContDataOpen(void); + +/*--------------------------------------*/ +/* controller pak function */ +/*--------------------------------------*/ +extern s32 nuContPakMgr(void* mesg_type); +extern void nuContPakMgrInit(void); +extern void nuContPakMgrRemove(void); +extern void nuContPakJisToN64(u8* src, u8* dest, u32 len); +extern void nuContPakN64ToJis(u8* src, u8* dest, u32 len); +extern s32 nuContPakOpen(NUContPakFile *file, u32 contNo); +extern s32 nuContPakGetFree(NUContPakFile *file); +extern void nuContPakCodeSet(u8* companyCode, u8* gameCode); +extern s32 nuContPakRepairId(NUContPakFile *file); +extern s32 nuContPakFileOpen(NUContPakFile *file, + u8* noteName,u8* extName, u32 mode, s32 size); +extern s32 nuContPakFileOpenJis(NUContPakFile *file, + u8* noteName,u8* extName, u32 mode, s32 size); +extern s32 nuContPakFileReadWrite(NUContPakFile *file, + s32 offset, s32 size,u8* buf, u32 mode); +extern s32 nuContPakFileDelete(NUContPakFile *file, u8* noteName, u8* extName); +extern s32 nuContPakFileDeleteJis(NUContPakFile *file, u8* noteName, u8* extName); +extern s32 nuContPakFileState(NUContPakFile *file, OSPfsState* state); +extern s32 nuContPakFileNum(NUContPakFile *file, + s32 *max_files, s32 *used_files); +extern s32 nuContPakFileFread(NUContPakFile *file, s32 offset, s32 size, u8* buf); + +/*--------------------------------------*/ +/* rumbler pak functions */ +/*--------------------------------------*/ +extern void nuContRmbMgrInit(void); +extern s32 nuContRmbMgr(void* mesg); +extern void nuContRmbMgrRemove(void); +extern void nuContRmbStart(u32 contNo, u16 freq, u16 frame); +extern void nuContRmbStop(u32 contNo); +extern s32 nuContRmbCheck(u32 contNo); +extern void nuContRmbModeSet(u32 contNo, u8 mode); +extern void nuContRmbForceStop(void); +extern void nuContRmbForceStopEnd(void); +extern void nuContRmbSearchTimeSet(u32 frame); + +/*--------------------------------------*/ +/* 64GB Pack functions */ +/*--------------------------------------*/ +extern s32 nuContGBPakMgr(void* mesg); +extern void nuContGBPakMgrInit(void); +extern void nuContGBPakMgrRemove(void); +extern s32 nuContGBPakOpen(NUContPakFile* handle, s32 contNo); +extern s32 nuContGBPakGetStatus(NUContPakFile* handle, u8* status); +extern s32 nuContGBPakReadID(NUContPakFile* handle, OSGbpakId* id, u8* status); +extern s32 nuContGBPakReadWrite(NUContPakFile* handle, u16 flag , u16 address, u8* buffer, u16 size); +extern s32 nuContGBPakPower(NUContPakFile* handle, s32 flag); +extern s32 nuContGBPakCheckConnector(NUContPakFile* handle, u8* status); +extern s32 nuContGBPakFread(NUContPakFile* handle, u16 address, u8* buffer, u16 size); + +extern s32 nuContGBPakFwrite(NUContPakFile* handle, u16 address, u8* buffer, u16 size); +extern s32 nuContGBPakRegWrite(NUContPakFile* handle, u16 addr, u8 data); + +/*--------------------------------------*/ +/* eeprom functions */ +/*--------------------------------------*/ +extern void nuEepromMgrInit(void); +extern s32 nuEepromMgr(void* mesg); +extern s32 nuEepromCheck(void); +extern void nuEepromMgrRemove(void); +extern s32 nuEepromRead(u8 address, u8* buffer,u16 len); +extern s32 nuEepromWrite(u8 address, u8* buffer,u16 len); + + +/*--------------------------------------*/ +/* pi functions */ +/*--------------------------------------*/ +extern void nuPiInit(void); +extern void nuPiReadRom(u32 rom_addr, void* buf_ptr, u32 size); +extern void nuPiInitSram(void); +extern void nuPiInitDDrom(void); +extern void nuPiReadWriteSram(u32 addr, void* buf_ptr, u32 size, s32 flag); + +/*--------------------------------------*/ +/* si functions */ +/*--------------------------------------*/ +extern u8 nuSiMgrInit(void); +extern void nuSiCallBackAdd(NUCallBackList* list); +extern void nuSiCallBackRemove(NUCallBackList* list); +extern s32 nuSiSendMesg(NUScMsg mesg, void* dataPtr); +extern void nuSiSendMesgNW(NUScMsg mesg, void* dataPtr); +extern void nuSiMgrStop(void); +extern void nuSiMgrRestart(void); +/*--------------------------------------*/ +/* si functions */ +/*--------------------------------------*/ +extern s32 nuVrsMgr(void *mesg); +extern void nuVrsMgrInit(void); +extern s32 nuVrsOpen(NUVrsHandle* handle, s32 contNo); +extern s32 nuVrsClearDictionary(NUVrsHandle* handle, u8 words); +extern s32 nuVrsSetWord(NUVrsHandle* handle, u8* word); +extern s32 nuVrsStartReadData(NUVrsHandle* handle); +extern s32 nuVrsGetReadData(NUVrsHandle* handle, NUVrsData* data); +extern s32 nuVrsStopReadData(NUVrsHandle* handle); +extern s32 nuVrsControlGain(NUVrsHandle* handle, s32 analog, s32 digital); +extern s32 nuVrsMaskDictionary(NUVrsHandle* handle, u8* maskpattern, s32 size); + +/*--------------------------------------*/ +/* dubug functions */ +/*--------------------------------------*/ +#ifdef NDEBUG +#define nuDebTaskPerfBar0(EX0 ,EX1 ,EX2) ((void)0) +#define nuDebTaskPerfBar1(EX0 ,EX1 ,EX2) ((void)0) +#define nuDebTaskPerfBar0EX2(EX0 ,EX1 ,EX2) ((void)0) +#define nuDebTaskPerfBar1EX2(EX0 ,EX1 ,EX2) ((void)0) +#else +extern void nuDebTaskPerfBar0(u32 frameNum, u32 y, u32 flag); +extern void nuDebTaskPerfBar1(u32 frameNum, u32 y, u32 flag); +extern void nuDebTaskPerfBar0EX2(u32 frameNum, u32 y, u32 flag); +extern void nuDebTaskPerfBar1EX2(u32 frameNum, u32 y, u32 flag); +#endif /* NDEBUG */ + +extern void nuDebConDisp(u32 flag); +extern void nuDebConDispEX2(u32 flag); +extern void nuDebConCPuts(u32 wndNo, const char *s); +extern void nuDebConInc(NUDebConWindow* conWin); +extern void nuDebConRtn(NUDebConWindow* conWin); +extern void nuDebConEsc(NUDebConWindow* conWin, char esc); +extern void nuDebConWindowSet(u32 wndNo, u32 winX , u32 winY, u32 width, u32 height); +extern void nuDebConWindowSize(u32 wndNo, u32 width, u32 height); +extern void nuDebConWindowPos(u32 wndNo, u32 winX , u32 winY); +extern void nuDebConTextColor(u32 wndNo, u32 color); +extern void nuDebConTextAttr(u32 wndNo, u32 attr); +extern void nuDebConTextPos(u32 wndNo, u32 posX, u32 posY); +extern void nuDebConScroll(u32 wndNo, u32 flag); +extern void nuDebConWindowShow(u32 wndNo, u32 flag); +extern void nuDebConClear(u32 wndNo); +extern void nuDebConPutc(u32 wndNo, u32 c); +extern void nuDebTaskPerfLoad(void); +extern void nuDebConPrintf(u32 wndNo, const char* fmt, ...); + +#ifdef F3DEX_GBI_2 +#define nuDebConDisp(flag) nuDebConDispEX2(flag) +#define nuDebTaskPerfBar0(a, b, c) nuDebTaskPerfBar0EX2(a, b, c) +#define nuDebTaskPerfBar1(a, b, c) nuDebTaskPerfBar1EX2(a, b, c) +#endif /* F3DEX_GBI_2 */ + +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* MACRO */ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------*/ +/* Registers the graphics microcode */ +/* IN: Pointer to the graphics microcode NUUcode array */ +/*----------------------------------------------------------------------*/ +#define nuGfxSetUcode(ucode) \ +{ \ + nuGfxUcode = ucode; \ +} +/*----------------------------------------------------------------------*/ +/* Z buffer settings */ +/* IN: Pointer to the Z buffer */ +/*----------------------------------------------------------------------*/ +#define nuGfxSetZBuffer(ZBuf_p) \ +{ \ + nuGfxZBuffer = ZBuf_p; \ +} +/*----------------------------------------------------------------------*/ +/* Remove callback functions */ +/* IN: nothing */ +/*----------------------------------------------------------------------*/ +#define nuPreNmiFuncRemove() nuPreNmiFuncSet(NULL) +#define nuGfxFuncRemove() nuGfxFuncSet(NULL) +#define nuGfxPreNMIFuncRemove() nuGfxPreNMIFuncSet(NULL) +#define nuGfxSwapCfbFuncRemove() nuGfxSwapCfbFuncSet(NULL) +#define nuGfxTaskEndFuncRemove() nuGfxTaskEndFuncSet(NULL) +#define nuContReadFuncRemove() nuContReadFuncSet(NULL) + +/*----------------------------------------------------------------------*/ +/* nuContDataGet - Obtains Controller data */ +/* Obtains read data from the Controller Manager. */ +/* */ +/* IN: *contpad Pointer to the Controller structure */ +/* cont_no Controller number */ +/*----------------------------------------------------------------------*/ +#if 0 +#define nuContDataGet(contpad, cont_no) \ +{ \ + bcopy(&nuContData[cont_no], contpad, sizeof(OSContPad)); \ +} + +/*----------------------------------------------------------------------*/ +/* nuContDataGetAll - Obtains Controller data */ +/* Obtains read data from the Controller Manager. */ +/* Copies all 4 buffers. */ +/* IN: *contpad Pointer to the Controller structure */ +/* cont_no Controller number */ +/*----------------------------------------------------------------------*/ +#define nuContDataGetAll(contpad) \ +{ \ + bcopy(&nuContData[0], contpad, sizeof(OSContPad)*MAXCONTROLLERS);\ +} +#endif +/*----------------------------------------------------------------------*/ +/* nuContPakFileFind - Search node */ +/*----------------------------------------------------------------------*/ +#define nuContPakFileFind(file, nodeName, extName) \ + nuContPakFileOpen(file, nodeNname, extName, NU_CONT_PAK_NOCREAT, 0)\ + + +/*----------------------------------------------------------------------*/ +/* nuContPakFileFindJis - Search node */ +/*----------------------------------------------------------------------*/ +#define nuContPakFileFindJis(file, nodeName, extName) \ + nuContPakFileOpenJis(file, nodeNname, extName, NU_CONT_PAK_NOCREAT, 0)\ + +/*----------------------------------------------------------------------*/ +/* nuContPakFileRead - Read note */ +/*----------------------------------------------------------------------*/ +#define nuContPakFileRead(file, offset, size, buf) \ + nuContPakFileReadWrite(file, offset, size, buf, PFS_READ) \ + +/*----------------------------------------------------------------------*/ +/* nuContPakFileWrite - Read note */ +/*----------------------------------------------------------------------*/ +#define nuContPakFileWrite(file, offset, size, buf) \ + nuContPakFileReadWrite(file, offset, size, buf, PFS_WRITE) \ + +/*----------------------------------------------------------------------*/ +/* nuDebConPuts - String output (with newline) */ +/*----------------------------------------------------------------------*/ +#define nuDebConPuts(wndNo, s) \ +{ \ + nuDebConCPuts(wndNo, s); \ + nuDebConRtn(&nuDebConWin[wndNo]); \ +} + +/*----------------------------------------------------------------------*/ +/* nuContGBPakRead - Read from the GB cartridge */ +/*----------------------------------------------------------------------*/ +#define nuContGBPakRead(file, address, buf, size) \ + nuContGBPakReadWrite(file, OS_READ, address, buf, size) + +/*----------------------------------------------------------------------*/ +/* nuContGBPakWrite - Write to the GB cartridge */ +/*----------------------------------------------------------------------*/ +#define nuContGBPakWrite(file, address, buf, size) \ + nuContGBPakReadWrite(file, OS_WRITE, address, buf, size) + +/*----------------------------------------------------------------------*/ +/* nuPiReadSram - Read from SRAM */ +/*----------------------------------------------------------------------*/ +#define nuPiReadSram(addr, buf_ptr, size) \ + nuPiReadWriteSram(addr, buf_ptr, size, OS_READ) + +/*----------------------------------------------------------------------*/ +/* nuPiWriteSram - Write to SRAM */ +/*----------------------------------------------------------------------*/ +#define nuPiWriteSram(addr, buf_ptr, size) \ + nuPiReadWriteSram(addr, buf_ptr, size, OS_WRITE) + +/*----------------------------------------------------------------------*/ +/* Define voice recognition macros */ +/*----------------------------------------------------------------------*/ +#define nuVrsCheckWord osVoiceCheckWord +#define nuVrsCountSyllables osVoiceCountSyllables + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif +#endif /* _NUSYS_H_ */ diff --git a/include/variables.h b/include/variables.h index 97f005b778..910ba24b06 100644 --- a/include/variables.h +++ b/include/variables.h @@ -91,4 +91,7 @@ extern UNK_TYPE D_80108558; extern UNK_TYPE D_8010F250; // play_sound state struct? extern s8 D_8010EBB0; +//nusys +extern OSPiHandle* carthandle; + #endif diff --git a/papermario.ld b/papermario.ld index 8cfa118026..b2cf323d67 100644 --- a/papermario.ld +++ b/papermario.ld @@ -52,12 +52,18 @@ SECTIONS build/src/code_39210_len_aa0.o(.text); build/src/os/code_39cb0_len_100.o(.text); build/src/os/code_39db0_len_8a0.o(.text); - build/src/os/code_3a650_len_40.o(.text); - build/src/os/code_3a690_len_40.o(.text); - build/src/os/code_3a6d0_len_20.o(.text); - build/src/os/code_3a6f0_len_110.o(.text); - build/src/os/code_3a800_len_30.o(.text); - build/src/os/code_3a830_len_20.o(.text); + build/src/os/nuGfxFuncSet.o(.text); + build/src/os/nuGfxPreNMIFuncSet.o(.text); + build/src/os/nuGfxTaskAllEndWait.o(.text); + build/src/os/nuGfxSetCfb.o(.text); + build/src/os/nuGfxDisplayOff.o(.text); + build/src/os/nuGfxDisplayOn.o(.text); + build/src/os/nuPiInit.o(.text); + build/src/os/nuPiReadRom.o(.text); + build/src/os/nuGfxInit.o(.text); + build/src/os/nuContInit.o(.text); + build/src/os/nuContDataGet.o(.text); + build/src/os/nuContPakMgr.o(.text); build/src/os/code_3a850_le_a40.o(.text); build/src/os/code_3b290_len_100.o(.text); build/src/os/code_3b390_len_110.o(.text); diff --git a/src/os/code_3a650_len_40.c b/src/os/code_3a650_len_40.c deleted file mode 100644 index 2486ea1587..0000000000 --- a/src/os/code_3a650_len_40.c +++ /dev/null @@ -1,3 +0,0 @@ -#include "common.h" - -INCLUDE_API_ASM("os/code_3a650_len_40", nuGfxFuncSet); diff --git a/src/os/code_3a690_len_40.c b/src/os/code_3a690_len_40.c deleted file mode 100644 index 0e1bc88c23..0000000000 --- a/src/os/code_3a690_len_40.c +++ /dev/null @@ -1,3 +0,0 @@ -#include "common.h" - -INCLUDE_API_ASM("os/code_3a690_len_40", nuGfxPreNMIFuncSet); diff --git a/src/os/code_3a6d0_len_20.c b/src/os/code_3a6d0_len_20.c deleted file mode 100644 index 2e14a9b684..0000000000 --- a/src/os/code_3a6d0_len_20.c +++ /dev/null @@ -1,3 +0,0 @@ -#include "common.h" - -INCLUDE_API_ASM("os/code_3a6d0_len_20", nuGfxTaskAllEndWait); diff --git a/src/os/code_3a6f0_len_110.c b/src/os/code_3a6f0_len_110.c deleted file mode 100644 index 3a9d726716..0000000000 --- a/src/os/code_3a6f0_len_110.c +++ /dev/null @@ -1,3 +0,0 @@ -#include "common.h" - -INCLUDE_API_ASM("os/code_3a6f0_len_110", nuGfxSetCfb); diff --git a/src/os/code_3a800_len_30.c b/src/os/code_3a800_len_30.c deleted file mode 100644 index ff23e22bd8..0000000000 --- a/src/os/code_3a800_len_30.c +++ /dev/null @@ -1,3 +0,0 @@ -#include "common.h" - -INCLUDE_API_ASM("os/code_3a800_len_30", nuGfxDisplayOff); diff --git a/src/os/code_3a830_len_20.c b/src/os/code_3a830_len_20.c deleted file mode 100644 index 05a0ba4e21..0000000000 --- a/src/os/code_3a830_len_20.c +++ /dev/null @@ -1,3 +0,0 @@ -#include "common.h" - -INCLUDE_API_ASM("os/code_3a830_len_20", nuGfxDisplayOn); diff --git a/src/os/code_3a850_le_a40.c b/src/os/code_3a850_le_a40.c index 2714a98eab..5c4b377c68 100644 --- a/src/os/code_3a850_le_a40.c +++ b/src/os/code_3a850_le_a40.c @@ -1,35 +1,5 @@ #include "common.h" -INCLUDE_API_ASM("os/code_3a850_le_a40", nuPiInit); - -INCLUDE_API_ASM("os/code_3a850_le_a40", nuPiReadRom); - -INCLUDE_API_ASM("os/code_3a850_le_a40", nuGfxInit); - -INCLUDE_API_ASM("os/code_3a850_le_a40", nuContInit); - -INCLUDE_API_ASM("os/code_3a850_le_a40", nuContDataGet); - -INCLUDE_API_ASM("os/code_3a850_le_a40", nuContPakMgrInit); - -INCLUDE_API_ASM("os/code_3a850_le_a40", nuContPakMgrRemove); - -INCLUDE_API_ASM("os/code_3a850_le_a40", contPakOpen); - -INCLUDE_API_ASM("os/code_3a850_le_a40", contPakFree); - -INCLUDE_API_ASM("os/code_3a850_le_a40", contPakFileReadWrite); - -INCLUDE_API_ASM("os/code_3a850_le_a40", contPakFileOpen); - -INCLUDE_API_ASM("os/code_3a850_le_a40", contPakFileDelete); - -INCLUDE_API_ASM("os/code_3a850_le_a40", contPakFileState); - -INCLUDE_API_ASM("os/code_3a850_le_a40", contPakFileNum); - -INCLUDE_API_ASM("os/code_3a850_le_a40", contPakRepairId); - #undef osMotorStop s32 INCLUDE_ASM("os/code_3a850_le_a40", osMotorStop, OSPfs* unk); diff --git a/src/os/nuContDataGet.c b/src/os/nuContDataGet.c new file mode 100644 index 0000000000..ec4d30ebc4 --- /dev/null +++ b/src/os/nuContDataGet.c @@ -0,0 +1,8 @@ +#include "common.h" +#include "nu/nusys.h" + +void nuContDataGet(OSContPad* contdata, u32 padno) { + nuContDataClose(); + bcopy(&nuContData[padno], contdata, sizeof(OSContPad)); + nuContDataOpen(); +} diff --git a/src/os/nuContInit.c b/src/os/nuContInit.c new file mode 100644 index 0000000000..72cd3e3213 --- /dev/null +++ b/src/os/nuContInit.c @@ -0,0 +1,12 @@ +#include "common.h" +#include "nu/nusys.h" + +u8 nuContInit(void) { + u8 contBits; + + contBits = nuSiMgrInit(); + nuContMgrInit(); + nuContPakMgrInit(); + nuContRmbMgrInit(); + return contBits; +} diff --git a/src/os/nuContPakMgr.c b/src/os/nuContPakMgr.c new file mode 100644 index 0000000000..cabbe77bfe --- /dev/null +++ b/src/os/nuContPakMgr.c @@ -0,0 +1,81 @@ +#include "common.h" +#include "nu/nusys.h" + +void nuContPakMgrInit(void) { + nuSiCallBackAdd(&nuContCallBack); +} + +void nuContPakMgrRemove(void) { + nuSiCallBackRemove(&nuContCallBack); +} + +// TODO: Determine what this is. +extern OSMesgQueue D_800DAC78; + +static s32 contPakOpen(NUSiCommonMesg* mesg) { + s32 err; + NUContPakFile* file = (NUContPakFile*) mesg->dataPtr; + + file->type = NU_CONT_PAK_TYPE_NONE; + err = osPfsInitPak(&D_800DAC78, file->pfs, file->pfs->channel); + + if (err == 0) { + file->type = NU_CONT_PAK_TYPE_PAK; + } + + return err; +} + +static s32 contPakFree(NUSiCommonMesg* mesg) { + NUContPakFreeMesg* freeMesg = (NUContPakFreeMesg*) mesg->dataPtr; + + return osPfsFreeBlocks(freeMesg->file->pfs, &freeMesg->size); +} + +static s32 contPakFileReadWrite(NUSiCommonMesg* mesg) { + NUContPakFileRWMesg* rwMesg = (NUContPakFileRWMesg*) mesg->dataPtr; + + return osPfsReadWriteFile(rwMesg->file->pfs, rwMesg->file->file_no, rwMesg->mode, rwMesg->offset, rwMesg->size, + rwMesg->buf); +} + +static s32 contPakFileOpen(NUSiCommonMesg* mesg) { + NUContPakFileOpenMesg* openMesg = mesg->dataPtr; + NUContPakFile* file = openMesg->file; + s32 err; + + err = osPfsFindFile(file->pfs, nuContPakCompanyCode, nuContPakGameCode, openMesg->noteName, openMesg->extName, + &file->file_no); + if (err == PFS_ERR_INVALID) { + if (openMesg->mode == NU_CONT_PAK_MODE_CREATE) { + err = osPfsAllocateFile(file->pfs, nuContPakCompanyCode, nuContPakGameCode, openMesg->noteName, openMesg->extName, + openMesg->size, &file->file_no); + } + } + return err; +} + +static s32 contPakFileDelete(NUSiCommonMesg* mesg) { + NUContPakFileOpenMesg* openMesg = (NUContPakFileOpenMesg*) mesg->dataPtr; + + return osPfsDeleteFile(openMesg->file->pfs, nuContPakCompanyCode, nuContPakGameCode, openMesg->noteName, + openMesg->extName); +} + +static s32 contPakFileState(NUSiCommonMesg* mesg) { + NUContPakFileStateMesg* state = (NUContPakFileStateMesg*) mesg->dataPtr; + + return osPfsFileState(state->file->pfs, state->file->file_no, state->state); +} + +static s32 contPakFileNum(NUSiCommonMesg* mesg) { + NUContPakFileNumMesg* fileNum = (NUContPakFileNumMesg*) mesg->dataPtr; + + return osPfsNumFiles(fileNum->file->pfs, fileNum->max_files, fileNum->used_files); +} + +static s32 contPakRepairId(NUSiCommonMesg* mesg) { + NUContPakFile* file = (NUContPakFile*) mesg->dataPtr; + + return osPfsRepairId(file->pfs); +} diff --git a/src/os/nuGfxDisplayOff.c b/src/os/nuGfxDisplayOff.c new file mode 100644 index 0000000000..8d3bb32ef6 --- /dev/null +++ b/src/os/nuGfxDisplayOff.c @@ -0,0 +1,7 @@ +#include "common.h" +#include "nu/nusys.h" + +void nuGfxDisplayOff(void) { + nuGfxDisplay = NU_GFX_DISPLAY_OFF; + osViBlack(TRUE); +} diff --git a/src/os/nuGfxDisplayOn.c b/src/os/nuGfxDisplayOn.c new file mode 100644 index 0000000000..4c53ade8cc --- /dev/null +++ b/src/os/nuGfxDisplayOn.c @@ -0,0 +1,6 @@ +#include "common.h" +#include "nu/nusys.h" + +void nuGfxDisplayOn(void) { + nuGfxDisplay = NU_GFX_DISPLAY_ON_TRIGGER; +} diff --git a/src/os/nuGfxFuncSet.c b/src/os/nuGfxFuncSet.c new file mode 100644 index 0000000000..e833fb522d --- /dev/null +++ b/src/os/nuGfxFuncSet.c @@ -0,0 +1,11 @@ +#include "common.h" +#include "nu/nusys.h" + +void nuGfxFuncSet(NUGfxFunc func) { + OSIntMask intMask; + + nuGfxTaskAllEndWait(); + intMask = osSetIntMask(OS_IM_NONE); + nuGfxFunc = func; + osSetIntMask(intMask); +} diff --git a/src/os/nuGfxInit.c b/src/os/nuGfxInit.c new file mode 100644 index 0000000000..69d3a84f85 --- /dev/null +++ b/src/os/nuGfxInit.c @@ -0,0 +1,28 @@ +#include "common.h" +#include "nu/nusys.h" + +extern u16* FrameBuf[3]; +extern UNK_PTR D_8009A610; +extern UNK_PTR D_80093BA0; +extern Gfx rdpstateinit_dl[]; + +void nuGfxInit(void) { + Gfx gfx[0x100]; + Gfx* ptr; + + nuGfxThreadStart(); + nuGfxSetCfb(FrameBuf, NU_GFX_FRAMEBUFFER_NUM); + nuGfxSetZBuffer((u16*) NU_GFX_ZBUFFER_ADDR); + nuGfxSwapCfbFuncSet(nuGfxSwapCfb); + D_8009A610 = &D_80093BA0; + nuGfxTaskMgrInit(); + + ptr = gfx; + // TODO: Verify that this macro call works in PM64. + gSPDisplayList(ptr++, OS_K0_TO_PHYSICAL(&rdpstateinit_dl)); + gDPFullSync(ptr++); + gSPEndDisplayList(ptr++); + + nuGfxTaskStart(&gfx, (s32)(ptr - gfx) * sizeof(Gfx), NU_GFX_UCODE_F3DEX, NU_SC_NOSWAPBUFFER); + nuGfxTaskAllEndWait(); +} diff --git a/src/os/nuGfxPreNMIFuncSet.c b/src/os/nuGfxPreNMIFuncSet.c new file mode 100644 index 0000000000..a896d631cf --- /dev/null +++ b/src/os/nuGfxPreNMIFuncSet.c @@ -0,0 +1,10 @@ +#include "common.h" +#include "nu/nusys.h" + +void nuGfxPreNMIFuncSet(NUGfxPreNMIFunc func) { + OSIntMask intMask; + + intMask = osSetIntMask(OS_IM_NONE); + nuGfxPreNMIFunc = func; + osSetIntMask(intMask); +} diff --git a/src/os/nuGfxSetCfb.c b/src/os/nuGfxSetCfb.c new file mode 100644 index 0000000000..69b284b871 --- /dev/null +++ b/src/os/nuGfxSetCfb.c @@ -0,0 +1,3 @@ +#include "common.h" + +INCLUDE_API_ASM("os/nuGfxSetCfb", nuGfxSetCfb); diff --git a/src/os/nuGfxTaskAllEndWait.c b/src/os/nuGfxTaskAllEndWait.c new file mode 100644 index 0000000000..bd516c7c52 --- /dev/null +++ b/src/os/nuGfxTaskAllEndWait.c @@ -0,0 +1,7 @@ +#include "common.h" +#include "nu/nusys.h" + +void nuGfxTaskAllEndWait(void) { + while (nuGfxTaskSpool) { + } +} diff --git a/src/os/nuPiInit.c b/src/os/nuPiInit.c new file mode 100644 index 0000000000..bf4011e9d5 --- /dev/null +++ b/src/os/nuPiInit.c @@ -0,0 +1,10 @@ +#include "common.h" +#include "nu/nusys.h" + +extern OSMesgQueue D_800AC5D0; +extern OSMesg D_800AC5E8[NU_PI_MESG_NUM]; + +void nuPiInit(void) { + osCreatePiManager(OS_PRIORITY_PIMGR, &D_800AC5D0, D_800AC5E8, NU_PI_MESG_NUM); + carthandle = osCartRomInit(); +} diff --git a/src/os/nuPiReadRom.c b/src/os/nuPiReadRom.c new file mode 100644 index 0000000000..321a3ea339 --- /dev/null +++ b/src/os/nuPiReadRom.c @@ -0,0 +1,35 @@ +#include "common.h" +#include "nu/nusys.h" + +void nuPiReadRom(u32 rom_addr, void* buf_ptr, u32 size) { + OSIoMesg ioMesg; + OSMesg mesg; + OSMesgQueue queue; + u32 mesgSize; + + osCreateMesgQueue(&queue, &mesg, 1); + + ioMesg.hdr.pri = OS_MESG_PRI_NORMAL; + ioMesg.hdr.retQueue = &queue; + osInvalDCache(buf_ptr, size); + osInvalICache(buf_ptr, size); + + while (size != 0) { + mesgSize = size; + + if (size > 0x4000) { + mesgSize = 0x4000; + } + + ioMesg.dramAddr = buf_ptr; + ioMesg.devAddr = rom_addr; + ioMesg.size = mesgSize; + + osEPiStartDma(carthandle, &ioMesg, OS_READ); + osRecvMesg(&queue, &mesg, OS_MESG_BLOCK); + + rom_addr += mesgSize; + buf_ptr += mesgSize; + size -= mesgSize; + } +} diff --git a/undefined_syms.txt b/undefined_syms.txt index e1383ceb04..7bf3187fc7 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -39,14 +39,35 @@ D_00102610_end = 0x0010CC10; D_0010CC10 = 0x0010CC10; D_0010CC10_end = 0x0010F1B0; D_80074021 = 0x80074021; + +D_80093BA0 = 0x80093BA0; +FrameBuf = 0x80093BA8; +rdpstateinit_dl = 0x80093BB8; +nuContPakCompanyCode = 0x80093CA0; +nuContPakGameCode = 0x80093CA4; +nuContCallBack = 0x80093CD0; +nuGfxFunc = 0x80093D10; +nuGfxPreNMIFunc = 0x80093D14; + D_800959D4 = 0x800959D4; D_8009A5D8 = 0x8009A5D8; +nuGfxZBuffer = 0x8009A5DC; +nuGfxDisplay = 0x8009A5F8; gGameState = 0x8009A600; +D_8009A610 = 0x8009A610; + +nuGfxTaskSpool = 0x8009A618; +carthandle = 0x8009A638; + D_8009A650 = 0x8009A650; D_800A0900 = 0x800A0900; +D_800AC5D0 = 0x800AC5D0; +D_800AC5E8 = 0x800AC5E8; gCurrentEncounter = 0x800B0F10; +nuContData = 0x800B1D68; gCameras = 0x800B1D80; gCurrentCameraID = 0x80077410; +D_800DAC78 = 0x800DAC78; D_800DC500 = 0x800DC500; D_8010F6D0 = 0x8010F6D0; gBackgroundImage = 0x80200000; From 5572f155bc39ca155d3250c18f40062a6ad36082 Mon Sep 17 00:00:00 2001 From: JoshDuMan Date: Fri, 18 Sep 2020 17:37:08 -0400 Subject: [PATCH 2/7] Fix build --- tools/splat.yaml | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tools/splat.yaml b/tools/splat.yaml index 958b6a4476..4dca7ac17f 100644 --- a/tools/splat.yaml +++ b/tools/splat.yaml @@ -59,13 +59,19 @@ segments: - [0x39210, "c", "code_39210_len_aa0"] - [0x39cb0, "c", "os/code_39cb0_len_100"] - [0x39db0, "c", "os/code_39db0_len_8a0"] - - [0x3a650, "c", "os/code_3a650_len_40"] - - [0x3a690, "c", "os/code_3a690_len_40"] - - [0x3a6d0, "c", "os/code_3a6d0_len_20"] - - [0x3a6f0, "c", "os/code_3a6f0_len_110"] - - [0x3a800, "c", "os/code_3a800_len_30"] - - [0x3a830, "c", "os/code_3a830_len_20"] - - [0x3a850, "c", "os/code_3a850_le_a40"] + - [0x3a650, "c", "os/nuGfxFuncSet"] + - [0x3a690, "c", "os/nuGfxPreNMIFuncSet"] + - [0x3a6d0, "c", "os/nuGfxTaskAllEndWait"] + - [0x3a6f0, "c", "os/nuGfxSetCfb"] + - [0x3a800, "c", "os/nuGfxDisplayOff"] + - [0x3a830, "c", "os/nuGfxDisplayOn"] + - [0x3a850, "c", "os/nuPiInit"] + - [0x3a890, "c", "os/nuPiReadRom"] + - [0x3a960, "c", "os/nuGfxInit"] + - [0x3aa10, "c", "os/nuContInit"] + - [0x3aa50, "c", "os/nuContDataGet"] + - [0x3aab0, "c", "os/nuContPakMgr"] + - [0x3ad20, "c", "os/code_3a850_le_a40"] - [0x3b290, "c", "os/code_3b290_len_100"] - [0x3b390, "c", "os/code_3b390_len_110"] - [0x3b4a0, "c", "os/code_3b4a0_len_270"] From 7e632e3ceb1fbc548d80dd92ccd772aa20368fba Mon Sep 17 00:00:00 2001 From: JoshDuMan Date: Mon, 21 Sep 2020 00:37:52 -0400 Subject: [PATCH 3/7] Decompile nuContRmbMgr --- Makefile | 2 +- .../os/code_3a850_le_a40/contRmbCheckMesg.s | 24 --- .../os/code_3a850_le_a40/contRmbControl.s | 116 ------------- .../os/code_3a850_le_a40/contRmbStartMesg.s | 91 ---------- .../os/code_3a850_le_a40/nuContRmbMgrRemove.s | 15 -- .../os/code_3a850_le_a40/osMotorStop.s | 150 ---------------- .../{osMotorAccess.s => __osMotorAccess.s} | 2 +- .../nuContRmbMgrInit.s | 0 papermario.ld | 26 +-- src/os/code_3a850_le_a40.c | 14 -- src/os/code_43200_len_7c0.c | 2 +- src/os/{ => nusys}/nuContDataGet.c | 0 src/os/{ => nusys}/nuContInit.c | 0 src/os/{ => nusys}/nuContPakMgr.c | 5 +- src/os/nusys/nuContRmbMgr.c | 162 ++++++++++++++++++ src/os/{ => nusys}/nuGfxDisplayOff.c | 0 src/os/{ => nusys}/nuGfxDisplayOn.c | 0 src/os/{ => nusys}/nuGfxFuncSet.c | 0 src/os/{ => nusys}/nuGfxInit.c | 2 +- src/os/{ => nusys}/nuGfxPreNMIFuncSet.c | 0 src/os/{ => nusys}/nuGfxSetCfb.c | 0 src/os/{ => nusys}/nuGfxTaskAllEndWait.c | 0 src/os/{ => nusys}/nuPiInit.c | 0 src/os/{ => nusys}/nuPiReadRom.c | 0 tools/splat.yaml | 26 +-- undefined_syms.txt | 10 +- 26 files changed, 201 insertions(+), 446 deletions(-) delete mode 100644 asm/nonmatchings/os/code_3a850_le_a40/contRmbCheckMesg.s delete mode 100644 asm/nonmatchings/os/code_3a850_le_a40/contRmbControl.s delete mode 100644 asm/nonmatchings/os/code_3a850_le_a40/contRmbStartMesg.s delete mode 100644 asm/nonmatchings/os/code_3a850_le_a40/nuContRmbMgrRemove.s delete mode 100644 asm/nonmatchings/os/code_3a850_le_a40/osMotorStop.s rename asm/nonmatchings/os/code_43200_len_7c0/{osMotorAccess.s => __osMotorAccess.s} (99%) rename asm/nonmatchings/os/{code_3a850_le_a40 => nuContRmbMgr}/nuContRmbMgrInit.s (100%) delete mode 100644 src/os/code_3a850_le_a40.c rename src/os/{ => nusys}/nuContDataGet.c (100%) rename src/os/{ => nusys}/nuContInit.c (100%) rename src/os/{ => nusys}/nuContPakMgr.c (94%) create mode 100644 src/os/nusys/nuContRmbMgr.c rename src/os/{ => nusys}/nuGfxDisplayOff.c (100%) rename src/os/{ => nusys}/nuGfxDisplayOn.c (100%) rename src/os/{ => nusys}/nuGfxFuncSet.c (100%) rename src/os/{ => nusys}/nuGfxInit.c (86%) rename src/os/{ => nusys}/nuGfxPreNMIFuncSet.c (100%) rename src/os/{ => nusys}/nuGfxSetCfb.c (100%) rename src/os/{ => nusys}/nuGfxTaskAllEndWait.c (100%) rename src/os/{ => nusys}/nuPiInit.c (100%) rename src/os/{ => nusys}/nuPiReadRom.c (100%) diff --git a/Makefile b/Makefile index 20f062eb23..7bcce6210c 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ SHELL=/bin/bash -o pipefail # BUILD_DIR is location where all build artifacts are placed BUILD_DIR = build -SRC_DIRS := src src/os +SRC_DIRS := src src/os src/os/nusys ASM_DIRS := asm asm/os INCLUDE_DIRS := include include/PR DATA_DIRS := bin diff --git a/asm/nonmatchings/os/code_3a850_le_a40/contRmbCheckMesg.s b/asm/nonmatchings/os/code_3a850_le_a40/contRmbCheckMesg.s deleted file mode 100644 index bed361ae45..0000000000 --- a/asm/nonmatchings/os/code_3a850_le_a40/contRmbCheckMesg.s +++ /dev/null @@ -1,24 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel contRmbCheckMesg -/* 03B110 8005FD10 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 03B114 8005FD14 AFBF0010 */ sw $ra, 0x10($sp) -/* 03B118 8005FD18 8C82000C */ lw $v0, 0xc($a0) -/* 03B11C 8005FD1C 3C04800E */ lui $a0, 0x800e -/* 03B120 8005FD20 2484AC78 */ addiu $a0, $a0, -0x5388 -/* 03B124 8005FD24 90460000 */ lbu $a2, ($v0) -/* 03B128 8005FD28 3C02800E */ lui $v0, 0x800e -/* 03B12C 8005FD2C 2442AAD8 */ addiu $v0, $v0, -0x5528 -/* 03B130 8005FD30 00062840 */ sll $a1, $a2, 1 -/* 03B134 8005FD34 00A62821 */ addu $a1, $a1, $a2 -/* 03B138 8005FD38 00052880 */ sll $a1, $a1, 2 -/* 03B13C 8005FD3C 00A62821 */ addu $a1, $a1, $a2 -/* 03B140 8005FD40 000528C0 */ sll $a1, $a1, 3 -/* 03B144 8005FD44 0C019FD1 */ jal osMotorInit -/* 03B148 8005FD48 00A22821 */ addu $a1, $a1, $v0 -/* 03B14C 8005FD4C 8FBF0010 */ lw $ra, 0x10($sp) -/* 03B150 8005FD50 03E00008 */ jr $ra -/* 03B154 8005FD54 27BD0018 */ addiu $sp, $sp, 0x18 - diff --git a/asm/nonmatchings/os/code_3a850_le_a40/contRmbControl.s b/asm/nonmatchings/os/code_3a850_le_a40/contRmbControl.s deleted file mode 100644 index ebcf23ae6d..0000000000 --- a/asm/nonmatchings/os/code_3a850_le_a40/contRmbControl.s +++ /dev/null @@ -1,116 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel contRmbControl -/* 03AF10 8005FB10 27BDFFD0 */ addiu $sp, $sp, -0x30 -/* 03AF14 8005FB14 AFB10014 */ sw $s1, 0x14($sp) -/* 03AF18 8005FB18 0000882D */ daddu $s1, $zero, $zero -/* 03AF1C 8005FB1C AFB40020 */ sw $s4, 0x20($sp) -/* 03AF20 8005FB20 24140002 */ addiu $s4, $zero, 2 -/* 03AF24 8005FB24 AFB50024 */ sw $s5, 0x24($sp) -/* 03AF28 8005FB28 24150001 */ addiu $s5, $zero, 1 -/* 03AF2C 8005FB2C AFB3001C */ sw $s3, 0x1c($sp) -/* 03AF30 8005FB30 0220982D */ daddu $s3, $s1, $zero -/* 03AF34 8005FB34 AFB20018 */ sw $s2, 0x18($sp) -/* 03AF38 8005FB38 0220902D */ daddu $s2, $s1, $zero -/* 03AF3C 8005FB3C AFBF0028 */ sw $ra, 0x28($sp) -/* 03AF40 8005FB40 AFB00010 */ sw $s0, 0x10($sp) -.L8005FB44: -/* 03AF44 8005FB44 3C02800B */ lui $v0, 0x800b -/* 03AF48 8005FB48 24421D40 */ addiu $v0, $v0, 0x1d40 -/* 03AF4C 8005FB4C 02428021 */ addu $s0, $s2, $v0 -/* 03AF50 8005FB50 92030007 */ lbu $v1, 7($s0) -/* 03AF54 8005FB54 10740015 */ beq $v1, $s4, .L8005FBAC -/* 03AF58 8005FB58 28620003 */ slti $v0, $v1, 3 -/* 03AF5C 8005FB5C 50400007 */ beql $v0, $zero, .L8005FB7C -/* 03AF60 8005FB60 28620083 */ slti $v0, $v1, 0x83 -/* 03AF64 8005FB64 5060003B */ beql $v1, $zero, .L8005FC54 -/* 03AF68 8005FB68 26730068 */ addiu $s3, $s3, 0x68 -/* 03AF6C 8005FB6C 10750009 */ beq $v1, $s5, .L8005FB94 -/* 03AF70 8005FB70 0200202D */ daddu $a0, $s0, $zero -/* 03AF74 8005FB74 08017F15 */ j .L8005FC54 -/* 03AF78 8005FB78 26730068 */ addiu $s3, $s3, 0x68 - -.L8005FB7C: -/* 03AF7C 8005FB7C 10400034 */ beqz $v0, .L8005FC50 -/* 03AF80 8005FB80 28620081 */ slti $v0, $v1, 0x81 -/* 03AF84 8005FB84 54400033 */ bnel $v0, $zero, .L8005FC54 -/* 03AF88 8005FB88 26730068 */ addiu $s3, $s3, 0x68 -/* 03AF8C 8005FB8C 08017F0E */ j .L8005FC38 -/* 03AF90 8005FB90 00000000 */ nop - -.L8005FB94: -/* 03AF94 8005FB94 0C017E48 */ jal osMotorStop -/* 03AF98 8005FB98 0220282D */ daddu $a1, $s1, $zero -/* 03AF9C 8005FB9C 5440002C */ bnel $v0, $zero, .L8005FC50 -/* 03AFA0 8005FBA0 A2000007 */ sb $zero, 7($s0) -/* 03AFA4 8005FBA4 08017F15 */ j .L8005FC54 -/* 03AFA8 8005FBA8 26730068 */ addiu $s3, $s3, 0x68 - -.L8005FBAC: -/* 03AFAC 8005FBAC 92020008 */ lbu $v0, 8($s0) -/* 03AFB0 8005FBB0 14400019 */ bnez $v0, .L8005FC18 -/* 03AFB4 8005FBB4 0200202D */ daddu $a0, $s0, $zero -/* 03AFB8 8005FBB8 96030004 */ lhu $v1, 4($s0) -/* 03AFBC 8005FBBC 3C028009 */ lui $v0, 0x8009 -/* 03AFC0 8005FBC0 8C423CE0 */ lw $v0, 0x3ce0($v0) -/* 03AFC4 8005FBC4 14400002 */ bnez $v0, .L8005FBD0 -/* 03AFC8 8005FBC8 0062001B */ divu $zero, $v1, $v0 -/* 03AFCC 8005FBCC 0007000D */ break 7 -.L8005FBD0: -/* 03AFD0 8005FBD0 00001010 */ mfhi $v0 -/* 03AFD4 8005FBD4 1440000C */ bnez $v0, .L8005FC08 -/* 03AFD8 8005FBD8 00000000 */ nop -/* 03AFDC 8005FBDC 3C04800E */ lui $a0, 0x800e -/* 03AFE0 8005FBE0 2484AC78 */ addiu $a0, $a0, -0x5388 -/* 03AFE4 8005FBE4 3C05800E */ lui $a1, 0x800e -/* 03AFE8 8005FBE8 24A5AAD8 */ addiu $a1, $a1, -0x5528 -/* 03AFEC 8005FBEC 02652821 */ addu $a1, $s3, $a1 -/* 03AFF0 8005FBF0 0C019FD1 */ jal osMotorInit -/* 03AFF4 8005FBF4 0220302D */ daddu $a2, $s1, $zero -/* 03AFF8 8005FBF8 14400003 */ bnez $v0, .L8005FC08 -/* 03AFFC 8005FBFC 00000000 */ nop -/* 03B000 8005FC00 A2150008 */ sb $s5, 8($s0) -/* 03B004 8005FC04 A2140009 */ sb $s4, 9($s0) -.L8005FC08: -/* 03B008 8005FC08 96020004 */ lhu $v0, 4($s0) -/* 03B00C 8005FC0C 24420001 */ addiu $v0, $v0, 1 -/* 03B010 8005FC10 08017F14 */ j .L8005FC50 -/* 03B014 8005FC14 A6020004 */ sh $v0, 4($s0) - -.L8005FC18: -/* 03B018 8005FC18 0C017E48 */ jal osMotorStop -/* 03B01C 8005FC1C 0220282D */ daddu $a1, $s1, $zero -/* 03B020 8005FC20 5040000C */ beql $v0, $zero, .L8005FC54 -/* 03B024 8005FC24 26730068 */ addiu $s3, $s3, 0x68 -/* 03B028 8005FC28 A6110004 */ sh $s1, 4($s0) -/* 03B02C 8005FC2C A2000008 */ sb $zero, 8($s0) -/* 03B030 8005FC30 08017F14 */ j .L8005FC50 -/* 03B034 8005FC34 A2000009 */ sb $zero, 9($s0) - -.L8005FC38: -/* 03B038 8005FC38 92020009 */ lbu $v0, 9($s0) -/* 03B03C 8005FC3C 54540005 */ bnel $v0, $s4, .L8005FC54 -/* 03B040 8005FC40 26730068 */ addiu $s3, $s3, 0x68 -/* 03B044 8005FC44 0200202D */ daddu $a0, $s0, $zero -/* 03B048 8005FC48 0C017E48 */ jal osMotorStop -/* 03B04C 8005FC4C 0220282D */ daddu $a1, $s1, $zero -.L8005FC50: -/* 03B050 8005FC50 26730068 */ addiu $s3, $s3, 0x68 -.L8005FC54: -/* 03B054 8005FC54 26310001 */ addiu $s1, $s1, 1 -/* 03B058 8005FC58 2E220004 */ sltiu $v0, $s1, 4 -/* 03B05C 8005FC5C 1440FFB9 */ bnez $v0, .L8005FB44 -/* 03B060 8005FC60 2652000A */ addiu $s2, $s2, 0xa -/* 03B064 8005FC64 8FBF0028 */ lw $ra, 0x28($sp) -/* 03B068 8005FC68 8FB50024 */ lw $s5, 0x24($sp) -/* 03B06C 8005FC6C 8FB40020 */ lw $s4, 0x20($sp) -/* 03B070 8005FC70 8FB3001C */ lw $s3, 0x1c($sp) -/* 03B074 8005FC74 8FB20018 */ lw $s2, 0x18($sp) -/* 03B078 8005FC78 8FB10014 */ lw $s1, 0x14($sp) -/* 03B07C 8005FC7C 8FB00010 */ lw $s0, 0x10($sp) -/* 03B080 8005FC80 0000102D */ daddu $v0, $zero, $zero -/* 03B084 8005FC84 03E00008 */ jr $ra -/* 03B088 8005FC88 27BD0030 */ addiu $sp, $sp, 0x30 - diff --git a/asm/nonmatchings/os/code_3a850_le_a40/contRmbStartMesg.s b/asm/nonmatchings/os/code_3a850_le_a40/contRmbStartMesg.s deleted file mode 100644 index 2e8180ebd9..0000000000 --- a/asm/nonmatchings/os/code_3a850_le_a40/contRmbStartMesg.s +++ /dev/null @@ -1,91 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel contRmbStartMesg -/* 03B158 8005FD58 8C84000C */ lw $a0, 0xc($a0) -/* 03B15C 8005FD5C 90830000 */ lbu $v1, ($a0) -/* 03B160 8005FD60 8C850008 */ lw $a1, 8($a0) -/* 03B164 8005FD64 00031080 */ sll $v0, $v1, 2 -/* 03B168 8005FD68 00431021 */ addu $v0, $v0, $v1 -/* 03B16C 8005FD6C 90A30006 */ lbu $v1, 6($a1) -/* 03B170 8005FD70 00021040 */ sll $v0, $v0, 1 -/* 03B174 8005FD74 3C01800B */ lui $at, 0x800b -/* 03B178 8005FD78 00220821 */ addu $at, $at, $v0 -/* 03B17C 8005FD7C A0231D46 */ sb $v1, 0x1d46($at) -/* 03B180 8005FD80 90830000 */ lbu $v1, ($a0) -/* 03B184 8005FD84 00031080 */ sll $v0, $v1, 2 -/* 03B188 8005FD88 00431021 */ addu $v0, $v0, $v1 -/* 03B18C 8005FD8C 94A30002 */ lhu $v1, 2($a1) -/* 03B190 8005FD90 00021040 */ sll $v0, $v0, 1 -/* 03B194 8005FD94 3C01800B */ lui $at, 0x800b -/* 03B198 8005FD98 00220821 */ addu $at, $at, $v0 -/* 03B19C 8005FD9C A4231D42 */ sh $v1, 0x1d42($at) -/* 03B1A0 8005FDA0 90830000 */ lbu $v1, ($a0) -/* 03B1A4 8005FDA4 00031080 */ sll $v0, $v1, 2 -/* 03B1A8 8005FDA8 00431021 */ addu $v0, $v0, $v1 -/* 03B1AC 8005FDAC 94A30000 */ lhu $v1, ($a1) -/* 03B1B0 8005FDB0 00021040 */ sll $v0, $v0, 1 -/* 03B1B4 8005FDB4 3C01800B */ lui $at, 0x800b -/* 03B1B8 8005FDB8 00220821 */ addu $at, $at, $v0 -/* 03B1BC 8005FDBC A4231D40 */ sh $v1, 0x1d40($at) -/* 03B1C0 8005FDC0 90830000 */ lbu $v1, ($a0) -/* 03B1C4 8005FDC4 00031080 */ sll $v0, $v1, 2 -/* 03B1C8 8005FDC8 00431021 */ addu $v0, $v0, $v1 -/* 03B1CC 8005FDCC 00021040 */ sll $v0, $v0, 1 -/* 03B1D0 8005FDD0 3C01800B */ lui $at, 0x800b -/* 03B1D4 8005FDD4 00220821 */ addu $at, $at, $v0 -/* 03B1D8 8005FDD8 A4201D44 */ sh $zero, 0x1d44($at) -/* 03B1DC 8005FDDC 03E00008 */ jr $ra -/* 03B1E0 8005FDE0 0000102D */ daddu $v0, $zero, $zero - -/* 03B1E4 8005FDE4 8C82000C */ lw $v0, 0xc($a0) -/* 03B1E8 8005FDE8 90430000 */ lbu $v1, ($v0) -/* 03B1EC 8005FDEC 00031080 */ sll $v0, $v1, 2 -/* 03B1F0 8005FDF0 00431021 */ addu $v0, $v0, $v1 -/* 03B1F4 8005FDF4 00021040 */ sll $v0, $v0, 1 -/* 03B1F8 8005FDF8 3C01800B */ lui $at, 0x800b -/* 03B1FC 8005FDFC 00220821 */ addu $at, $at, $v0 -/* 03B200 8005FE00 A4201D42 */ sh $zero, 0x1d42($at) -/* 03B204 8005FE04 03E00008 */ jr $ra -/* 03B208 8005FE08 0000102D */ daddu $v0, $zero, $zero - -/* 03B20C 8005FE0C 0000282D */ daddu $a1, $zero, $zero -/* 03B210 8005FE10 24060004 */ addiu $a2, $zero, 4 -/* 03B214 8005FE14 3C03800B */ lui $v1, 0x800b -/* 03B218 8005FE18 24631D47 */ addiu $v1, $v1, 0x1d47 -/* 03B21C 8005FE1C 00A0202D */ daddu $a0, $a1, $zero -.L8005FE20: -/* 03B220 8005FE20 3C01800B */ lui $at, 0x800b -/* 03B224 8005FE24 00240821 */ addu $at, $at, $a0 -/* 03B228 8005FE28 A0261D46 */ sb $a2, 0x1d46($at) -/* 03B22C 8005FE2C 2484000A */ addiu $a0, $a0, 0xa -/* 03B230 8005FE30 90620000 */ lbu $v0, ($v1) -/* 03B234 8005FE34 24A50001 */ addiu $a1, $a1, 1 -/* 03B238 8005FE38 34420080 */ ori $v0, $v0, 0x80 -/* 03B23C 8005FE3C A0620000 */ sb $v0, ($v1) -/* 03B240 8005FE40 2CA20004 */ sltiu $v0, $a1, 4 -/* 03B244 8005FE44 1440FFF6 */ bnez $v0, .L8005FE20 -/* 03B248 8005FE48 2463000A */ addiu $v1, $v1, 0xa -/* 03B24C 8005FE4C 03E00008 */ jr $ra -/* 03B250 8005FE50 0000102D */ daddu $v0, $zero, $zero - -/* 03B254 8005FE54 0000202D */ daddu $a0, $zero, $zero -/* 03B258 8005FE58 3C03800B */ lui $v1, 0x800b -/* 03B25C 8005FE5C 24631D47 */ addiu $v1, $v1, 0x1d47 -.L8005FE60: -/* 03B260 8005FE60 90620000 */ lbu $v0, ($v1) -/* 03B264 8005FE64 24840001 */ addiu $a0, $a0, 1 -/* 03B268 8005FE68 3042007F */ andi $v0, $v0, 0x7f -/* 03B26C 8005FE6C A0620000 */ sb $v0, ($v1) -/* 03B270 8005FE70 2C820004 */ sltiu $v0, $a0, 4 -/* 03B274 8005FE74 1440FFFA */ bnez $v0, .L8005FE60 -/* 03B278 8005FE78 2463000A */ addiu $v1, $v1, 0xa -/* 03B27C 8005FE7C 03E00008 */ jr $ra -/* 03B280 8005FE80 0000102D */ daddu $v0, $zero, $zero - -/* 03B284 8005FE84 00000000 */ nop -/* 03B288 8005FE88 00000000 */ nop -/* 03B28C 8005FE8C 00000000 */ nop - - diff --git a/asm/nonmatchings/os/code_3a850_le_a40/nuContRmbMgrRemove.s b/asm/nonmatchings/os/code_3a850_le_a40/nuContRmbMgrRemove.s deleted file mode 100644 index c2c4fe84d9..0000000000 --- a/asm/nonmatchings/os/code_3a850_le_a40/nuContRmbMgrRemove.s +++ /dev/null @@ -1,15 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel nuContRmbMgrRemove -/* 03B0EC 8005FCEC 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 03B0F0 8005FCF0 3C048009 */ lui $a0, 0x8009 -/* 03B0F4 8005FCF4 24843D00 */ addiu $a0, $a0, 0x3d00 -/* 03B0F8 8005FCF8 AFBF0010 */ sw $ra, 0x10($sp) -/* 03B0FC 8005FCFC 0C018124 */ jal nuSiCallBackRemove -/* 03B100 8005FD00 00000000 */ nop -/* 03B104 8005FD04 8FBF0010 */ lw $ra, 0x10($sp) -/* 03B108 8005FD08 03E00008 */ jr $ra -/* 03B10C 8005FD0C 27BD0018 */ addiu $sp, $sp, 0x18 - diff --git a/asm/nonmatchings/os/code_3a850_le_a40/osMotorStop.s b/asm/nonmatchings/os/code_3a850_le_a40/osMotorStop.s deleted file mode 100644 index 6297547d84..0000000000 --- a/asm/nonmatchings/os/code_3a850_le_a40/osMotorStop.s +++ /dev/null @@ -1,150 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel osMotorStop -/* 03AD20 8005F920 27BDFFD8 */ addiu $sp, $sp, -0x28 -/* 03AD24 8005F924 AFB20018 */ sw $s2, 0x18($sp) -/* 03AD28 8005F928 0080902D */ daddu $s2, $a0, $zero -/* 03AD2C 8005F92C 00A0302D */ daddu $a2, $a1, $zero -/* 03AD30 8005F930 AFB00010 */ sw $s0, 0x10($sp) -/* 03AD34 8005F934 AFBF0020 */ sw $ra, 0x20($sp) -/* 03AD38 8005F938 AFB3001C */ sw $s3, 0x1c($sp) -/* 03AD3C 8005F93C AFB10014 */ sw $s1, 0x14($sp) -/* 03AD40 8005F940 92430006 */ lbu $v1, 6($s2) -/* 03AD44 8005F944 24130002 */ addiu $s3, $zero, 2 -/* 03AD48 8005F948 10730069 */ beq $v1, $s3, .L8005FAF0 -/* 03AD4C 8005F94C 0000802D */ daddu $s0, $zero, $zero -/* 03AD50 8005F950 28620003 */ slti $v0, $v1, 3 -/* 03AD54 8005F954 10400005 */ beqz $v0, .L8005F96C -/* 03AD58 8005F958 24020001 */ addiu $v0, $zero, 1 -/* 03AD5C 8005F95C 1062000A */ beq $v1, $v0, .L8005F988 -/* 03AD60 8005F960 0200102D */ daddu $v0, $s0, $zero -/* 03AD64 8005F964 08017EBD */ j .L8005FAF4 -/* 03AD68 8005F968 00000000 */ nop - -.L8005F96C: -/* 03AD6C 8005F96C 24020003 */ addiu $v0, $zero, 3 -/* 03AD70 8005F970 10620018 */ beq $v1, $v0, .L8005F9D4 -/* 03AD74 8005F974 24020004 */ addiu $v0, $zero, 4 -/* 03AD78 8005F978 10620048 */ beq $v1, $v0, .L8005FA9C -/* 03AD7C 8005F97C 0200102D */ daddu $v0, $s0, $zero -/* 03AD80 8005F980 08017EBD */ j .L8005FAF4 -/* 03AD84 8005F984 00000000 */ nop - -.L8005F988: -/* 03AD88 8005F988 96420004 */ lhu $v0, 4($s2) -/* 03AD8C 8005F98C 1040000C */ beqz $v0, .L8005F9C0 -/* 03AD90 8005F990 00062040 */ sll $a0, $a2, 1 -/* 03AD94 8005F994 00862021 */ addu $a0, $a0, $a2 -/* 03AD98 8005F998 00042080 */ sll $a0, $a0, 2 -/* 03AD9C 8005F99C 00862021 */ addu $a0, $a0, $a2 -/* 03ADA0 8005F9A0 000420C0 */ sll $a0, $a0, 3 -/* 03ADA4 8005F9A4 3C02800E */ lui $v0, 0x800e -/* 03ADA8 8005F9A8 2442AAD8 */ addiu $v0, $v0, -0x5528 -/* 03ADAC 8005F9AC 00822021 */ addu $a0, $a0, $v0 -/* 03ADB0 8005F9B0 0C019F80 */ jal osMotorAccess -/* 03ADB4 8005F9B4 0000282D */ daddu $a1, $zero, $zero -/* 03ADB8 8005F9B8 08017E71 */ j .L8005F9C4 -/* 03ADBC 8005F9BC 0040802D */ daddu $s0, $v0, $zero - -.L8005F9C0: -/* 03ADC0 8005F9C0 A2530006 */ sb $s3, 6($s2) -.L8005F9C4: -/* 03ADC4 8005F9C4 96420004 */ lhu $v0, 4($s2) -/* 03ADC8 8005F9C8 2442FFFF */ addiu $v0, $v0, -1 -/* 03ADCC 8005F9CC 08017EBC */ j .L8005FAF0 -/* 03ADD0 8005F9D0 A6420004 */ sh $v0, 4($s2) - -.L8005F9D4: -/* 03ADD4 8005F9D4 96420002 */ lhu $v0, 2($s2) -/* 03ADD8 8005F9D8 1040001F */ beqz $v0, .L8005FA58 -/* 03ADDC 8005F9DC 00062040 */ sll $a0, $a2, 1 -/* 03ADE0 8005F9E0 96420004 */ lhu $v0, 4($s2) -/* 03ADE4 8005F9E4 96430000 */ lhu $v1, ($s2) -/* 03ADE8 8005F9E8 00431021 */ addu $v0, $v0, $v1 -/* 03ADEC 8005F9EC 304300FF */ andi $v1, $v0, 0xff -/* 03ADF0 8005F9F0 3042FFFF */ andi $v0, $v0, 0xffff -/* 03ADF4 8005F9F4 00021202 */ srl $v0, $v0, 8 -/* 03ADF8 8005F9F8 1040000B */ beqz $v0, .L8005FA28 -/* 03ADFC 8005F9FC A6430004 */ sh $v1, 4($s2) -/* 03AE00 8005FA00 00062040 */ sll $a0, $a2, 1 -/* 03AE04 8005FA04 00862021 */ addu $a0, $a0, $a2 -/* 03AE08 8005FA08 00042080 */ sll $a0, $a0, 2 -/* 03AE0C 8005FA0C 00862021 */ addu $a0, $a0, $a2 -/* 03AE10 8005FA10 000420C0 */ sll $a0, $a0, 3 -/* 03AE14 8005FA14 3C02800E */ lui $v0, 0x800e -/* 03AE18 8005FA18 2442AAD8 */ addiu $v0, $v0, -0x5528 -/* 03AE1C 8005FA1C 00822021 */ addu $a0, $a0, $v0 -/* 03AE20 8005FA20 08017E92 */ j .L8005FA48 -/* 03AE24 8005FA24 24050001 */ addiu $a1, $zero, 1 - -.L8005FA28: -/* 03AE28 8005FA28 00862021 */ addu $a0, $a0, $a2 -/* 03AE2C 8005FA2C 00042080 */ sll $a0, $a0, 2 -/* 03AE30 8005FA30 00862021 */ addu $a0, $a0, $a2 -/* 03AE34 8005FA34 000420C0 */ sll $a0, $a0, 3 -/* 03AE38 8005FA38 3C02800E */ lui $v0, 0x800e -/* 03AE3C 8005FA3C 2442AAD8 */ addiu $v0, $v0, -0x5528 -/* 03AE40 8005FA40 00822021 */ addu $a0, $a0, $v0 -/* 03AE44 8005FA44 0000282D */ daddu $a1, $zero, $zero -.L8005FA48: -/* 03AE48 8005FA48 0C019F80 */ jal osMotorAccess -/* 03AE4C 8005FA4C 00000000 */ nop -/* 03AE50 8005FA50 08017EA3 */ j .L8005FA8C -/* 03AE54 8005FA54 0040802D */ daddu $s0, $v0, $zero - -.L8005FA58: -/* 03AE58 8005FA58 00862021 */ addu $a0, $a0, $a2 -/* 03AE5C 8005FA5C 00042080 */ sll $a0, $a0, 2 -/* 03AE60 8005FA60 00862021 */ addu $a0, $a0, $a2 -/* 03AE64 8005FA64 000420C0 */ sll $a0, $a0, 3 -/* 03AE68 8005FA68 3C02800E */ lui $v0, 0x800e -/* 03AE6C 8005FA6C 2442AAD8 */ addiu $v0, $v0, -0x5528 -/* 03AE70 8005FA70 00822021 */ addu $a0, $a0, $v0 -/* 03AE74 8005FA74 0C019F80 */ jal osMotorAccess -/* 03AE78 8005FA78 0000282D */ daddu $a1, $zero, $zero -/* 03AE7C 8005FA7C 0040802D */ daddu $s0, $v0, $zero -/* 03AE80 8005FA80 24020001 */ addiu $v0, $zero, 1 -/* 03AE84 8005FA84 A2420006 */ sb $v0, 6($s2) -/* 03AE88 8005FA88 A6530004 */ sh $s3, 4($s2) -.L8005FA8C: -/* 03AE8C 8005FA8C 96420002 */ lhu $v0, 2($s2) -/* 03AE90 8005FA90 2442FFFF */ addiu $v0, $v0, -1 -/* 03AE94 8005FA94 08017EBC */ j .L8005FAF0 -/* 03AE98 8005FA98 A6420002 */ sh $v0, 2($s2) - -.L8005FA9C: -/* 03AE9C 8005FA9C 3C04800E */ lui $a0, 0x800e -/* 03AEA0 8005FAA0 2484AC78 */ addiu $a0, $a0, -0x5388 -/* 03AEA4 8005FAA4 00061040 */ sll $v0, $a2, 1 -/* 03AEA8 8005FAA8 00461021 */ addu $v0, $v0, $a2 -/* 03AEAC 8005FAAC 00021080 */ sll $v0, $v0, 2 -/* 03AEB0 8005FAB0 00461021 */ addu $v0, $v0, $a2 -/* 03AEB4 8005FAB4 000210C0 */ sll $v0, $v0, 3 -/* 03AEB8 8005FAB8 3C03800E */ lui $v1, 0x800e -/* 03AEBC 8005FABC 2463AAD8 */ addiu $v1, $v1, -0x5528 -/* 03AEC0 8005FAC0 00438821 */ addu $s1, $v0, $v1 -/* 03AEC4 8005FAC4 0C019FD1 */ jal osMotorInit -/* 03AEC8 8005FAC8 0220282D */ daddu $a1, $s1, $zero -/* 03AECC 8005FACC 0040802D */ daddu $s0, $v0, $zero -/* 03AED0 8005FAD0 16000005 */ bnez $s0, .L8005FAE8 -/* 03AED4 8005FAD4 24020001 */ addiu $v0, $zero, 1 -/* 03AED8 8005FAD8 0220202D */ daddu $a0, $s1, $zero -/* 03AEDC 8005FADC 0C019F80 */ jal osMotorAccess -/* 03AEE0 8005FAE0 0000282D */ daddu $a1, $zero, $zero -/* 03AEE4 8005FAE4 24020001 */ addiu $v0, $zero, 1 -.L8005FAE8: -/* 03AEE8 8005FAE8 A2420006 */ sb $v0, 6($s2) -/* 03AEEC 8005FAEC A6530004 */ sh $s3, 4($s2) -.L8005FAF0: -/* 03AEF0 8005FAF0 0200102D */ daddu $v0, $s0, $zero -.L8005FAF4: -/* 03AEF4 8005FAF4 8FBF0020 */ lw $ra, 0x20($sp) -/* 03AEF8 8005FAF8 8FB3001C */ lw $s3, 0x1c($sp) -/* 03AEFC 8005FAFC 8FB20018 */ lw $s2, 0x18($sp) -/* 03AF00 8005FB00 8FB10014 */ lw $s1, 0x14($sp) -/* 03AF04 8005FB04 8FB00010 */ lw $s0, 0x10($sp) -/* 03AF08 8005FB08 03E00008 */ jr $ra -/* 03AF0C 8005FB0C 27BD0028 */ addiu $sp, $sp, 0x28 - diff --git a/asm/nonmatchings/os/code_43200_len_7c0/osMotorAccess.s b/asm/nonmatchings/os/code_43200_len_7c0/__osMotorAccess.s similarity index 99% rename from asm/nonmatchings/os/code_43200_len_7c0/osMotorAccess.s rename to asm/nonmatchings/os/code_43200_len_7c0/__osMotorAccess.s index 2b4f1d8d31..f162844797 100644 --- a/asm/nonmatchings/os/code_43200_len_7c0/osMotorAccess.s +++ b/asm/nonmatchings/os/code_43200_len_7c0/__osMotorAccess.s @@ -2,7 +2,7 @@ .set noreorder # don't insert nops after branches -glabel osMotorAccess +glabel __osMotorAccess /* 043200 80067E00 27BDFFD8 */ addiu $sp, $sp, -0x28 /* 043204 80067E04 AFB10014 */ sw $s1, 0x14($sp) /* 043208 80067E08 00808821 */ addu $s1, $a0, $zero diff --git a/asm/nonmatchings/os/code_3a850_le_a40/nuContRmbMgrInit.s b/asm/nonmatchings/os/nuContRmbMgr/nuContRmbMgrInit.s similarity index 100% rename from asm/nonmatchings/os/code_3a850_le_a40/nuContRmbMgrInit.s rename to asm/nonmatchings/os/nuContRmbMgr/nuContRmbMgrInit.s diff --git a/papermario.ld b/papermario.ld index b2cf323d67..98ab8d8e1c 100644 --- a/papermario.ld +++ b/papermario.ld @@ -52,19 +52,19 @@ SECTIONS build/src/code_39210_len_aa0.o(.text); build/src/os/code_39cb0_len_100.o(.text); build/src/os/code_39db0_len_8a0.o(.text); - build/src/os/nuGfxFuncSet.o(.text); - build/src/os/nuGfxPreNMIFuncSet.o(.text); - build/src/os/nuGfxTaskAllEndWait.o(.text); - build/src/os/nuGfxSetCfb.o(.text); - build/src/os/nuGfxDisplayOff.o(.text); - build/src/os/nuGfxDisplayOn.o(.text); - build/src/os/nuPiInit.o(.text); - build/src/os/nuPiReadRom.o(.text); - build/src/os/nuGfxInit.o(.text); - build/src/os/nuContInit.o(.text); - build/src/os/nuContDataGet.o(.text); - build/src/os/nuContPakMgr.o(.text); - build/src/os/code_3a850_le_a40.o(.text); + build/src/os/nusys/nuGfxFuncSet.o(.text); + build/src/os/nusys/nuGfxPreNMIFuncSet.o(.text); + build/src/os/nusys/nuGfxTaskAllEndWait.o(.text); + build/src/os/nusys/nuGfxSetCfb.o(.text); + build/src/os/nusys/nuGfxDisplayOff.o(.text); + build/src/os/nusys/nuGfxDisplayOn.o(.text); + build/src/os/nusys/nuPiInit.o(.text); + build/src/os/nusys/nuPiReadRom.o(.text); + build/src/os/nusys/nuGfxInit.o(.text); + build/src/os/nusys/nuContInit.o(.text); + build/src/os/nusys/nuContDataGet.o(.text); + build/src/os/nusys/nuContPakMgr.o(.text); + build/src/os/nusys/nuContRmbMgr.o(.text); build/src/os/code_3b290_len_100.o(.text); build/src/os/code_3b390_len_110.o(.text); build/src/os/code_3b4a0_len_270.o(.text); diff --git a/src/os/code_3a850_le_a40.c b/src/os/code_3a850_le_a40.c deleted file mode 100644 index 5c4b377c68..0000000000 --- a/src/os/code_3a850_le_a40.c +++ /dev/null @@ -1,14 +0,0 @@ -#include "common.h" - -#undef osMotorStop -s32 INCLUDE_ASM("os/code_3a850_le_a40", osMotorStop, OSPfs* unk); - -INCLUDE_API_ASM("os/code_3a850_le_a40", contRmbControl); - -INCLUDE_API_ASM("os/code_3a850_le_a40", nuContRmbMgrInit); - -INCLUDE_API_ASM("os/code_3a850_le_a40", nuContRmbMgrRemove); - -INCLUDE_API_ASM("os/code_3a850_le_a40", contRmbCheckMesg); - -INCLUDE_API_ASM("os/code_3a850_le_a40", contRmbStartMesg); diff --git a/src/os/code_43200_len_7c0.c b/src/os/code_43200_len_7c0.c index 2737584967..1d1b1747f2 100644 --- a/src/os/code_43200_len_7c0.c +++ b/src/os/code_43200_len_7c0.c @@ -1,6 +1,6 @@ #include "common.h" -INCLUDE_API_ASM("os/code_43200_len_7c0", osMotorAccess); +s32 INCLUDE_ASM("os/code_43200_len_7c0", __osMotorAccess, OSPfs* pfs, s32 unk); s32 INCLUDE_ASM("os/code_43200_len_7c0", osMotorInit, OSMesgQueue* queue, OSPfs* pfs, int unk); diff --git a/src/os/nuContDataGet.c b/src/os/nusys/nuContDataGet.c similarity index 100% rename from src/os/nuContDataGet.c rename to src/os/nusys/nuContDataGet.c diff --git a/src/os/nuContInit.c b/src/os/nusys/nuContInit.c similarity index 100% rename from src/os/nuContInit.c rename to src/os/nusys/nuContInit.c diff --git a/src/os/nuContPakMgr.c b/src/os/nusys/nuContPakMgr.c similarity index 94% rename from src/os/nuContPakMgr.c rename to src/os/nusys/nuContPakMgr.c index cabbe77bfe..0c909cd211 100644 --- a/src/os/nuContPakMgr.c +++ b/src/os/nusys/nuContPakMgr.c @@ -9,15 +9,12 @@ void nuContPakMgrRemove(void) { nuSiCallBackRemove(&nuContCallBack); } -// TODO: Determine what this is. -extern OSMesgQueue D_800DAC78; - static s32 contPakOpen(NUSiCommonMesg* mesg) { s32 err; NUContPakFile* file = (NUContPakFile*) mesg->dataPtr; file->type = NU_CONT_PAK_TYPE_NONE; - err = osPfsInitPak(&D_800DAC78, file->pfs, file->pfs->channel); + err = osPfsInitPak(&nuSiMesgQ, file->pfs, file->pfs->channel); if (err == 0) { file->type = NU_CONT_PAK_TYPE_PAK; diff --git a/src/os/nusys/nuContRmbMgr.c b/src/os/nusys/nuContRmbMgr.c new file mode 100644 index 0000000000..202f0e30ed --- /dev/null +++ b/src/os/nusys/nuContRmbMgr.c @@ -0,0 +1,162 @@ +#include "common.h" +#include "nu/nusys.h" + +static s32 contRmbControl(NUContRmbCtl* rmbCtl, u32 contNo) { + s32 ret = 0; + u32 cnt; + + switch (rmbCtl->state) { + case NU_CONT_RMB_STATE_STOPPED: + break; + + case NU_CONT_RMB_STATE_STOPPING: + if (rmbCtl->counter != 0) { + ret = osMotorStop(&nuContPfs[contNo]); + } else { + rmbCtl->state = NU_CONT_RMB_STATE_STOPPED; + } + rmbCtl->counter--; + break; + + case NU_CONT_RMB_STATE_RUN: + if (rmbCtl->frame > 0) { + rmbCtl->counter += rmbCtl->freq; + cnt = rmbCtl->counter >> 8; + rmbCtl->counter &= 0xFF; + if (cnt > 0) { + ret = osMotorStart(&nuContPfs[contNo]); + } else { + ret = osMotorStop(&nuContPfs[contNo]); + } + } else { + ret = osMotorStop(&nuContPfs[contNo]); + rmbCtl->state = NU_CONT_RMB_STATE_STOPPING; + rmbCtl->counter = 2; + } + rmbCtl->frame--; + break; + + case NU_CONT_RMB_STATE_FORCESTOP: + ret = osMotorInit(&nuSiMesgQ, &nuContPfs[contNo], contNo); + if (ret == 0) { + osMotorStop(&nuContPfs[contNo]); + } + rmbCtl->state = NU_CONT_RMB_STATE_STOPPING; + rmbCtl->counter = 2; + } + + return ret; +} + +static s32 contRmbRetrace(NUSiCommonMesg* mesg) { + u32 i; + NUContRmbCtl* cont; + + for (i = 0; i < NU_CONT_MAXCONTROLLERS; i++) { + cont = &nuContRmbCtl[i]; + switch (cont->mode) { + case NU_CONT_RMB_MODE_DISABLE: + break; + + case NU_CONT_RMB_MODE_ENABLE: + if (contRmbControl(cont, i)) { + cont->mode = NU_CONT_RMB_MODE_DISABLE; + } + break; + + case NU_CONT_RMB_MODE_AUTORUN: + if (cont->autorun == NU_CONT_RMB_AUTO_SEARCH) { + if ((cont->counter % nuContRmbSearchTime) == 0) { + if (osMotorInit(&nuSiMesgQ, &nuContPfs[i], i) == 0) { + cont->autorun = NU_CONT_RMB_AUTO_FIND; + cont->type = NU_CONT_PAK_TYPE_RUMBLE; + } + } + cont->counter++; + } else { + if (contRmbControl(cont, i)) { + cont->counter = i; + cont->autorun = NU_CONT_RMB_AUTO_SEARCH; + cont->type = NU_CONT_PAK_TYPE_NONE; + } + } + break; + + case (NU_CONT_RMB_MODE_ENABLE | NU_CONT_RMB_MODE_PAUSE): + case (NU_CONT_RMB_MODE_AUTORUN | NU_CONT_RMB_MODE_PAUSE): + if (cont->type == NU_CONT_PAK_TYPE_RUMBLE) { + contRmbControl(cont, i); + } + } + } + + return 0; +} + + +#ifdef NON_MATCHING +// Will match when data is decompiled. +void nuContRmbMgrInit(void) { + u32 i; + + for (i = 0; i < NU_CONT_MAXCONTROLLERS; i++) { + nuContRmbCtl[i].state = NU_CONT_RMB_STATE_STOPPED; + nuContRmbCtl[i].mode = NU_CONT_RMB_MODE_DISABLE; + nuContRmbCtl[i].counter = i; + } + + nuSiCallBackAdd(&nuContRmbCallBack); +} +#else +void INCLUDE_ASM("os/nuContRmbMgr", nuContRmbMgrInit); +#endif + +void nuContRmbMgrRemove(void) { + nuSiCallBackRemove(&nuContRmbCallBack); +} + +static s32 contRmbCheckMesg(NUSiCommonMesg* mesg) { + NUContRmbMesg* rmbMesg = (NUContRmbMesg*) mesg->dataPtr; + + return osMotorInit(&nuSiMesgQ, &nuContPfs[rmbMesg->contNo], rmbMesg->contNo); +} + +static s32 contRmbStartMesg(NUSiCommonMesg* mesg) { + NUContRmbMesg* rmbMesg = (NUContRmbMesg*) mesg->dataPtr; + NUContRmbCtl* rmbCtl = (NUContRmbCtl*) rmbMesg->data; + + nuContRmbCtl[rmbMesg->contNo].state = rmbCtl->state; + nuContRmbCtl[rmbMesg->contNo].frame = rmbCtl->frame; + nuContRmbCtl[rmbMesg->contNo].freq = rmbCtl->freq; + nuContRmbCtl[rmbMesg->contNo].counter = 0; + return 0; +} + +static s32 contRmbStopMesg(NUSiCommonMesg* mesg) { + NUContRmbMesg* rmbMesg = (NUContRmbMesg*) mesg->dataPtr; + + nuContRmbCtl[rmbMesg->contNo].frame = 0; + + return 0; +} + +static s32 contRmbForceStopMesg(NUSiCommonMesg* mesg) { + u32 i; + + for (i = 0; i < NU_CONT_MAXCONTROLLERS; i++) { + nuContRmbCtl[i].state = NU_CONT_RMB_STATE_FORCESTOP; + nuContRmbCtl[i].mode |= NU_CONT_RMB_MODE_PAUSE; + } + + return 0; +} + +static s32 contRmbForceStopEndMesg(NUSiCommonMesg* mesg) { + u32 i; + + for (i = 0; i < NU_CONT_MAXCONTROLLERS; i++) { + nuContRmbCtl[i].mode &= ~NU_CONT_RMB_MODE_PAUSE; + } + + return 0; +} diff --git a/src/os/nuGfxDisplayOff.c b/src/os/nusys/nuGfxDisplayOff.c similarity index 100% rename from src/os/nuGfxDisplayOff.c rename to src/os/nusys/nuGfxDisplayOff.c diff --git a/src/os/nuGfxDisplayOn.c b/src/os/nusys/nuGfxDisplayOn.c similarity index 100% rename from src/os/nuGfxDisplayOn.c rename to src/os/nusys/nuGfxDisplayOn.c diff --git a/src/os/nuGfxFuncSet.c b/src/os/nusys/nuGfxFuncSet.c similarity index 100% rename from src/os/nuGfxFuncSet.c rename to src/os/nusys/nuGfxFuncSet.c diff --git a/src/os/nuGfxInit.c b/src/os/nusys/nuGfxInit.c similarity index 86% rename from src/os/nuGfxInit.c rename to src/os/nusys/nuGfxInit.c index 69d3a84f85..c9ce45a724 100644 --- a/src/os/nuGfxInit.c +++ b/src/os/nusys/nuGfxInit.c @@ -23,6 +23,6 @@ void nuGfxInit(void) { gDPFullSync(ptr++); gSPEndDisplayList(ptr++); - nuGfxTaskStart(&gfx, (s32)(ptr - gfx) * sizeof(Gfx), NU_GFX_UCODE_F3DEX, NU_SC_NOSWAPBUFFER); + nuGfxTaskStart(gfx, (s32)(ptr - gfx) * sizeof(Gfx), NU_GFX_UCODE_F3DEX, NU_SC_NOSWAPBUFFER); nuGfxTaskAllEndWait(); } diff --git a/src/os/nuGfxPreNMIFuncSet.c b/src/os/nusys/nuGfxPreNMIFuncSet.c similarity index 100% rename from src/os/nuGfxPreNMIFuncSet.c rename to src/os/nusys/nuGfxPreNMIFuncSet.c diff --git a/src/os/nuGfxSetCfb.c b/src/os/nusys/nuGfxSetCfb.c similarity index 100% rename from src/os/nuGfxSetCfb.c rename to src/os/nusys/nuGfxSetCfb.c diff --git a/src/os/nuGfxTaskAllEndWait.c b/src/os/nusys/nuGfxTaskAllEndWait.c similarity index 100% rename from src/os/nuGfxTaskAllEndWait.c rename to src/os/nusys/nuGfxTaskAllEndWait.c diff --git a/src/os/nuPiInit.c b/src/os/nusys/nuPiInit.c similarity index 100% rename from src/os/nuPiInit.c rename to src/os/nusys/nuPiInit.c diff --git a/src/os/nuPiReadRom.c b/src/os/nusys/nuPiReadRom.c similarity index 100% rename from src/os/nuPiReadRom.c rename to src/os/nusys/nuPiReadRom.c diff --git a/tools/splat.yaml b/tools/splat.yaml index 4dca7ac17f..673954f90c 100644 --- a/tools/splat.yaml +++ b/tools/splat.yaml @@ -59,19 +59,19 @@ segments: - [0x39210, "c", "code_39210_len_aa0"] - [0x39cb0, "c", "os/code_39cb0_len_100"] - [0x39db0, "c", "os/code_39db0_len_8a0"] - - [0x3a650, "c", "os/nuGfxFuncSet"] - - [0x3a690, "c", "os/nuGfxPreNMIFuncSet"] - - [0x3a6d0, "c", "os/nuGfxTaskAllEndWait"] - - [0x3a6f0, "c", "os/nuGfxSetCfb"] - - [0x3a800, "c", "os/nuGfxDisplayOff"] - - [0x3a830, "c", "os/nuGfxDisplayOn"] - - [0x3a850, "c", "os/nuPiInit"] - - [0x3a890, "c", "os/nuPiReadRom"] - - [0x3a960, "c", "os/nuGfxInit"] - - [0x3aa10, "c", "os/nuContInit"] - - [0x3aa50, "c", "os/nuContDataGet"] - - [0x3aab0, "c", "os/nuContPakMgr"] - - [0x3ad20, "c", "os/code_3a850_le_a40"] + - [0x3a650, "c", "os/nusys/nuGfxFuncSet"] + - [0x3a690, "c", "os/nusys/nuGfxPreNMIFuncSet"] + - [0x3a6d0, "c", "os/nusys/nuGfxTaskAllEndWait"] + - [0x3a6f0, "c", "os/nusys/nuGfxSetCfb"] + - [0x3a800, "c", "os/nusys/nuGfxDisplayOff"] + - [0x3a830, "c", "os/nusys/nuGfxDisplayOn"] + - [0x3a850, "c", "os/nusys/nuPiInit"] + - [0x3a890, "c", "os/nusys/nuPiReadRom"] + - [0x3a960, "c", "os/nusys/nuGfxInit"] + - [0x3aa10, "c", "os/nusys/nuContInit"] + - [0x3aa50, "c", "os/nusys/nuContDataGet"] + - [0x3aab0, "c", "os/nusys/nuContPakMgr"] + - [0x3af10, "c", "os/nusys/nuContRmbMgr"] - [0x3b290, "c", "os/code_3b290_len_100"] - [0x3b390, "c", "os/code_3b390_len_110"] - [0x3b4a0, "c", "os/code_3b4a0_len_270"] diff --git a/undefined_syms.txt b/undefined_syms.txt index 7bf3187fc7..bc52034f61 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -40,12 +40,15 @@ D_0010CC10 = 0x0010CC10; D_0010CC10_end = 0x0010F1B0; D_80074021 = 0x80074021; +gCurrentCameraID = 0x80077410; D_80093BA0 = 0x80093BA0; FrameBuf = 0x80093BA8; rdpstateinit_dl = 0x80093BB8; nuContPakCompanyCode = 0x80093CA0; nuContPakGameCode = 0x80093CA4; nuContCallBack = 0x80093CD0; +nuContRmbSearchTime = 0x80093CE0; +nuContRmbCallBack = 0x80093D00; nuGfxFunc = 0x80093D10; nuGfxPreNMIFunc = 0x80093D14; @@ -63,13 +66,16 @@ D_8009A650 = 0x8009A650; D_800A0900 = 0x800A0900; D_800AC5D0 = 0x800AC5D0; D_800AC5E8 = 0x800AC5E8; + gCurrentEncounter = 0x800B0F10; +nuContRmbCtl = 0x800B1d40; nuContData = 0x800B1D68; gCameras = 0x800B1D80; -gCurrentCameraID = 0x80077410; -D_800DAC78 = 0x800DAC78; +nuContPfs = 0x800DAAD8; +nuSiMesgQ = 0x800DAC78; D_800DC500 = 0x800DC500; D_8010F6D0 = 0x8010F6D0; + gBackgroundImage = 0x80200000; D_802C3000 = 0x802C3000; D_802DBD40 = 0x802DBD40; From 55dfeef1c82dba108920a1daa66b2717bd92d99f Mon Sep 17 00:00:00 2001 From: JoshDuMan Date: Sun, 27 Sep 2020 22:42:51 -0400 Subject: [PATCH 4/7] Work on nuSched --- .../code_39db0_len_8a0/nuScEventBroadcast.s | 33 ------- .../os/code_39db0_len_8a0/nuScRemoveClient.s | 43 --------- .../nuScResetClientMesgType.s | 22 ----- .../os/code_3b290_len_100/nuContRmbCheck.s | 51 ----------- .../os/code_3b290_len_100/nuContRmbStart.s | 31 ------- papermario.ld | 5 +- src/os/code_39db0_len_8a0.c | 27 ------ src/os/code_3b290_len_100.c | 5 -- src/os/nusys/nuContRmbCheck.c | 21 +++++ src/os/nusys/nuContRmbMgr.c | 2 +- src/os/nusys/nuContRmbStart.c | 16 ++++ src/os/nusys/nuSched.c | 90 +++++++++++++++++++ tools/splat.yaml | 5 +- undefined_syms.txt | 1 + 14 files changed, 135 insertions(+), 217 deletions(-) delete mode 100644 asm/nonmatchings/os/code_39db0_len_8a0/nuScEventBroadcast.s delete mode 100644 asm/nonmatchings/os/code_39db0_len_8a0/nuScRemoveClient.s delete mode 100644 asm/nonmatchings/os/code_39db0_len_8a0/nuScResetClientMesgType.s delete mode 100644 asm/nonmatchings/os/code_3b290_len_100/nuContRmbCheck.s delete mode 100644 asm/nonmatchings/os/code_3b290_len_100/nuContRmbStart.s delete mode 100644 src/os/code_39db0_len_8a0.c delete mode 100644 src/os/code_3b290_len_100.c create mode 100644 src/os/nusys/nuContRmbCheck.c create mode 100644 src/os/nusys/nuContRmbStart.c create mode 100644 src/os/nusys/nuSched.c diff --git a/asm/nonmatchings/os/code_39db0_len_8a0/nuScEventBroadcast.s b/asm/nonmatchings/os/code_39db0_len_8a0/nuScEventBroadcast.s deleted file mode 100644 index 2fbab9d20b..0000000000 --- a/asm/nonmatchings/os/code_39db0_len_8a0/nuScEventBroadcast.s +++ /dev/null @@ -1,33 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel nuScEventBroadcast -/* 03A4C0 8005F0C0 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 03A4C4 8005F0C4 AFB00010 */ sw $s0, 0x10($sp) -/* 03A4C8 8005F0C8 3C10800E */ lui $s0, 0x800e -/* 03A4CC 8005F0CC 8E10AAA8 */ lw $s0, -0x5558($s0) -/* 03A4D0 8005F0D0 AFB10014 */ sw $s1, 0x14($sp) -/* 03A4D4 8005F0D4 0080882D */ daddu $s1, $a0, $zero -/* 03A4D8 8005F0D8 1200000C */ beqz $s0, .L8005F10C -/* 03A4DC 8005F0DC AFBF0018 */ sw $ra, 0x18($sp) -.L8005F0E0: -/* 03A4E0 8005F0E0 96020008 */ lhu $v0, 8($s0) -/* 03A4E4 8005F0E4 96230000 */ lhu $v1, ($s1) -/* 03A4E8 8005F0E8 00431024 */ and $v0, $v0, $v1 -/* 03A4EC 8005F0EC 10400004 */ beqz $v0, .L8005F100 -/* 03A4F0 8005F0F0 0220282D */ daddu $a1, $s1, $zero -/* 03A4F4 8005F0F4 8E040004 */ lw $a0, 4($s0) -/* 03A4F8 8005F0F8 0C019608 */ jal osSendMesg -/* 03A4FC 8005F0FC 0000302D */ daddu $a2, $zero, $zero -.L8005F100: -/* 03A500 8005F100 8E100000 */ lw $s0, ($s0) -/* 03A504 8005F104 1600FFF6 */ bnez $s0, .L8005F0E0 -/* 03A508 8005F108 00000000 */ nop -.L8005F10C: -/* 03A50C 8005F10C 8FBF0018 */ lw $ra, 0x18($sp) -/* 03A510 8005F110 8FB10014 */ lw $s1, 0x14($sp) -/* 03A514 8005F114 8FB00010 */ lw $s0, 0x10($sp) -/* 03A518 8005F118 03E00008 */ jr $ra -/* 03A51C 8005F11C 27BD0020 */ addiu $sp, $sp, 0x20 - diff --git a/asm/nonmatchings/os/code_39db0_len_8a0/nuScRemoveClient.s b/asm/nonmatchings/os/code_39db0_len_8a0/nuScRemoveClient.s deleted file mode 100644 index b472ae74c1..0000000000 --- a/asm/nonmatchings/os/code_39db0_len_8a0/nuScRemoveClient.s +++ /dev/null @@ -1,43 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel nuScRemoveClient -/* 03A2BC 8005EEBC 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 03A2C0 8005EEC0 AFB00010 */ sw $s0, 0x10($sp) -/* 03A2C4 8005EEC4 0080802D */ daddu $s0, $a0, $zero -/* 03A2C8 8005EEC8 AFBF0014 */ sw $ra, 0x14($sp) -/* 03A2CC 8005EECC 0C018250 */ jal osSetIntMask -/* 03A2D0 8005EED0 24040001 */ addiu $a0, $zero, 1 -/* 03A2D4 8005EED4 3C06800E */ lui $a2, 0x800e -/* 03A2D8 8005EED8 24C6AAA8 */ addiu $a2, $a2, -0x5558 -/* 03A2DC 8005EEDC 0000282D */ daddu $a1, $zero, $zero -/* 03A2E0 8005EEE0 8CC30000 */ lw $v1, ($a2) -/* 03A2E4 8005EEE4 1060000E */ beqz $v1, .L8005EF20 -/* 03A2E8 8005EEE8 0040202D */ daddu $a0, $v0, $zero -.L8005EEEC: -/* 03A2EC 8005EEEC 54700009 */ bnel $v1, $s0, .L8005EF14 -/* 03A2F0 8005EEF0 0060282D */ daddu $a1, $v1, $zero -/* 03A2F4 8005EEF4 10A00004 */ beqz $a1, .L8005EF08 -/* 03A2F8 8005EEF8 00000000 */ nop -/* 03A2FC 8005EEFC 8C620000 */ lw $v0, ($v1) -/* 03A300 8005EF00 08017BC8 */ j .L8005EF20 -/* 03A304 8005EF04 ACA20000 */ sw $v0, ($a1) - -.L8005EF08: -/* 03A308 8005EF08 8C620000 */ lw $v0, ($v1) -/* 03A30C 8005EF0C 08017BC8 */ j .L8005EF20 -/* 03A310 8005EF10 ACC20000 */ sw $v0, ($a2) - -.L8005EF14: -/* 03A314 8005EF14 8C630000 */ lw $v1, ($v1) -/* 03A318 8005EF18 1460FFF4 */ bnez $v1, .L8005EEEC -/* 03A31C 8005EF1C 00000000 */ nop -.L8005EF20: -/* 03A320 8005EF20 0C018250 */ jal osSetIntMask -/* 03A324 8005EF24 00000000 */ nop -/* 03A328 8005EF28 8FBF0014 */ lw $ra, 0x14($sp) -/* 03A32C 8005EF2C 8FB00010 */ lw $s0, 0x10($sp) -/* 03A330 8005EF30 03E00008 */ jr $ra -/* 03A334 8005EF34 27BD0018 */ addiu $sp, $sp, 0x18 - diff --git a/asm/nonmatchings/os/code_39db0_len_8a0/nuScResetClientMesgType.s b/asm/nonmatchings/os/code_39db0_len_8a0/nuScResetClientMesgType.s deleted file mode 100644 index f52727e702..0000000000 --- a/asm/nonmatchings/os/code_39db0_len_8a0/nuScResetClientMesgType.s +++ /dev/null @@ -1,22 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel nuScResetClientMesgType -/* 03A338 8005EF38 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 03A33C 8005EF3C AFB10014 */ sw $s1, 0x14($sp) -/* 03A340 8005EF40 0080882D */ daddu $s1, $a0, $zero -/* 03A344 8005EF44 AFB00010 */ sw $s0, 0x10($sp) -/* 03A348 8005EF48 00A0802D */ daddu $s0, $a1, $zero -/* 03A34C 8005EF4C AFBF0018 */ sw $ra, 0x18($sp) -/* 03A350 8005EF50 0C018250 */ jal osSetIntMask -/* 03A354 8005EF54 24040001 */ addiu $a0, $zero, 1 -/* 03A358 8005EF58 0040202D */ daddu $a0, $v0, $zero -/* 03A35C 8005EF5C 0C018250 */ jal osSetIntMask -/* 03A360 8005EF60 A6300008 */ sh $s0, 8($s1) -/* 03A364 8005EF64 8FBF0018 */ lw $ra, 0x18($sp) -/* 03A368 8005EF68 8FB10014 */ lw $s1, 0x14($sp) -/* 03A36C 8005EF6C 8FB00010 */ lw $s0, 0x10($sp) -/* 03A370 8005EF70 03E00008 */ jr $ra -/* 03A374 8005EF74 27BD0020 */ addiu $sp, $sp, 0x20 - diff --git a/asm/nonmatchings/os/code_3b290_len_100/nuContRmbCheck.s b/asm/nonmatchings/os/code_3b290_len_100/nuContRmbCheck.s deleted file mode 100644 index 85af1ed20e..0000000000 --- a/asm/nonmatchings/os/code_3b290_len_100/nuContRmbCheck.s +++ /dev/null @@ -1,51 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel nuContRmbCheck -/* 03B2F0 8005FEF0 27BDFFD0 */ addiu $sp, $sp, -0x30 -/* 03B2F4 8005FEF4 AFB00020 */ sw $s0, 0x20($sp) -/* 03B2F8 8005FEF8 0080802D */ daddu $s0, $a0, $zero -/* 03B2FC 8005FEFC 24040301 */ addiu $a0, $zero, 0x301 -/* 03B300 8005FF00 27A50010 */ addiu $a1, $sp, 0x10 -/* 03B304 8005FF04 AFBF0028 */ sw $ra, 0x28($sp) -/* 03B308 8005FF08 AFB10024 */ sw $s1, 0x24($sp) -/* 03B30C 8005FF0C 0C00B3CA */ jal nuSiSendMesg -/* 03B310 8005FF10 A3B00010 */ sb $s0, 0x10($sp) -/* 03B314 8005FF14 24040001 */ addiu $a0, $zero, 1 -/* 03B318 8005FF18 0C018250 */ jal osSetIntMask -/* 03B31C 8005FF1C 0040882D */ daddu $s1, $v0, $zero -/* 03B320 8005FF20 1620000A */ bnez $s1, .L8005FF4C -/* 03B324 8005FF24 0040202D */ daddu $a0, $v0, $zero -/* 03B328 8005FF28 00101080 */ sll $v0, $s0, 2 -/* 03B32C 8005FF2C 00501021 */ addu $v0, $v0, $s0 -/* 03B330 8005FF30 00021040 */ sll $v0, $v0, 1 -/* 03B334 8005FF34 24030002 */ addiu $v1, $zero, 2 -/* 03B338 8005FF38 3C01800B */ lui $at, 0x800b -/* 03B33C 8005FF3C 00220821 */ addu $at, $at, $v0 -/* 03B340 8005FF40 A0231D49 */ sb $v1, 0x1d49($at) -/* 03B344 8005FF44 08017FD9 */ j .L8005FF64 -/* 03B348 8005FF48 00000000 */ nop - -.L8005FF4C: -/* 03B34C 8005FF4C 00101080 */ sll $v0, $s0, 2 -/* 03B350 8005FF50 00501021 */ addu $v0, $v0, $s0 -/* 03B354 8005FF54 00021040 */ sll $v0, $v0, 1 -/* 03B358 8005FF58 3C01800B */ lui $at, 0x800b -/* 03B35C 8005FF5C 00220821 */ addu $at, $at, $v0 -/* 03B360 8005FF60 A0201D49 */ sb $zero, 0x1d49($at) -.L8005FF64: -/* 03B364 8005FF64 0C018250 */ jal osSetIntMask -/* 03B368 8005FF68 00000000 */ nop -/* 03B36C 8005FF6C 0220102D */ daddu $v0, $s1, $zero -/* 03B370 8005FF70 8FBF0028 */ lw $ra, 0x28($sp) -/* 03B374 8005FF74 8FB10024 */ lw $s1, 0x24($sp) -/* 03B378 8005FF78 8FB00020 */ lw $s0, 0x20($sp) -/* 03B37C 8005FF7C 03E00008 */ jr $ra -/* 03B380 8005FF80 27BD0030 */ addiu $sp, $sp, 0x30 - -/* 03B384 8005FF84 00000000 */ nop -/* 03B388 8005FF88 00000000 */ nop -/* 03B38C 8005FF8C 00000000 */ nop - - diff --git a/asm/nonmatchings/os/code_3b290_len_100/nuContRmbStart.s b/asm/nonmatchings/os/code_3b290_len_100/nuContRmbStart.s deleted file mode 100644 index 5615495ec7..0000000000 --- a/asm/nonmatchings/os/code_3b290_len_100/nuContRmbStart.s +++ /dev/null @@ -1,31 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel nuContRmbStart -/* 03B290 8005FE90 00041080 */ sll $v0, $a0, 2 -/* 03B294 8005FE94 00441021 */ addu $v0, $v0, $a0 -/* 03B298 8005FE98 00021040 */ sll $v0, $v0, 1 -/* 03B29C 8005FE9C 3C01800B */ lui $at, 0x800b -/* 03B2A0 8005FEA0 00220821 */ addu $at, $at, $v0 -/* 03B2A4 8005FEA4 90221D47 */ lbu $v0, 0x1d47($at) -/* 03B2A8 8005FEA8 27BDFFC8 */ addiu $sp, $sp, -0x38 -/* 03B2AC 8005FEAC 30420080 */ andi $v0, $v0, 0x80 -/* 03B2B0 8005FEB0 1440000B */ bnez $v0, .L8005FEE0 -/* 03B2B4 8005FEB4 AFBF0030 */ sw $ra, 0x30($sp) -/* 03B2B8 8005FEB8 24020003 */ addiu $v0, $zero, 3 -/* 03B2BC 8005FEBC A3A20016 */ sb $v0, 0x16($sp) -/* 03B2C0 8005FEC0 27A20010 */ addiu $v0, $sp, 0x10 -/* 03B2C4 8005FEC4 A3A40020 */ sb $a0, 0x20($sp) -/* 03B2C8 8005FEC8 24040302 */ addiu $a0, $zero, 0x302 -/* 03B2CC 8005FECC A7A50010 */ sh $a1, 0x10($sp) -/* 03B2D0 8005FED0 27A50020 */ addiu $a1, $sp, 0x20 -/* 03B2D4 8005FED4 A7A60012 */ sh $a2, 0x12($sp) -/* 03B2D8 8005FED8 0C00B3CA */ jal nuSiSendMesg -/* 03B2DC 8005FEDC AFA20028 */ sw $v0, 0x28($sp) -.L8005FEE0: -/* 03B2E0 8005FEE0 8FBF0030 */ lw $ra, 0x30($sp) -/* 03B2E4 8005FEE4 03E00008 */ jr $ra -/* 03B2E8 8005FEE8 27BD0038 */ addiu $sp, $sp, 0x38 - -/* 03B2EC 8005FEEC 00000000 */ nop diff --git a/papermario.ld b/papermario.ld index 98ab8d8e1c..9b36df1655 100644 --- a/papermario.ld +++ b/papermario.ld @@ -51,7 +51,7 @@ SECTIONS build/src/code_362a0_len_2f70.o(.text); build/src/code_39210_len_aa0.o(.text); build/src/os/code_39cb0_len_100.o(.text); - build/src/os/code_39db0_len_8a0.o(.text); + build/src/os/nusys/nuSched.o(.text); build/src/os/nusys/nuGfxFuncSet.o(.text); build/src/os/nusys/nuGfxPreNMIFuncSet.o(.text); build/src/os/nusys/nuGfxTaskAllEndWait.o(.text); @@ -65,7 +65,8 @@ SECTIONS build/src/os/nusys/nuContDataGet.o(.text); build/src/os/nusys/nuContPakMgr.o(.text); build/src/os/nusys/nuContRmbMgr.o(.text); - build/src/os/code_3b290_len_100.o(.text); + build/src/os/nusys/nuContRmbStart.o(.text); + build/src/os/nusys/nuContRmbCheck.o(.text); build/src/os/code_3b390_len_110.o(.text); build/src/os/code_3b4a0_len_270.o(.text); build/src/os/code_3b710_len_40.o(.text); diff --git a/src/os/code_39db0_len_8a0.c b/src/os/code_39db0_len_8a0.c deleted file mode 100644 index 164a12c699..0000000000 --- a/src/os/code_39db0_len_8a0.c +++ /dev/null @@ -1,27 +0,0 @@ -#include "common.h" - -INCLUDE_API_ASM("os/code_39db0_len_8a0", nuScCreateScheduler); - -INCLUDE_API_ASM("os/code_39db0_len_8a0", nuScExecuteAudio); - -INCLUDE_API_ASM("os/code_39db0_len_8a0", nuScExecuteGraphics); - -INCLUDE_API_ASM("os/code_39db0_len_8a0", nuScAddClient); - -INCLUDE_API_ASM("os/code_39db0_len_8a0", nuScRemoveClient); - -INCLUDE_API_ASM("os/code_39db0_len_8a0", nuScResetClientMesgType); - -INCLUDE_API_ASM("os/code_39db0_len_8a0", nuScGetGfxMQ); - -INCLUDE_API_ASM("os/code_39db0_len_8a0", nuScGetAudioMQ); - -INCLUDE_API_ASM("os/code_39db0_len_8a0", nuScSetFrameBufferNum); - -INCLUDE_API_ASM("os/code_39db0_len_8a0", nuScGetFrameRate); - -INCLUDE_API_ASM("os/code_39db0_len_8a0", nuScEventHandler); - -INCLUDE_API_ASM("os/code_39db0_len_8a0", nuScEventBroadcast); - -INCLUDE_API_ASM("os/code_39db0_len_8a0", nuScWaitTaskReady); diff --git a/src/os/code_3b290_len_100.c b/src/os/code_3b290_len_100.c deleted file mode 100644 index 91b051486d..0000000000 --- a/src/os/code_3b290_len_100.c +++ /dev/null @@ -1,5 +0,0 @@ -#include "common.h" - -INCLUDE_API_ASM("os/code_3b290_len_100", nuContRmbStart); - -INCLUDE_API_ASM("os/code_3b290_len_100", nuContRmbCheck); diff --git a/src/os/nusys/nuContRmbCheck.c b/src/os/nusys/nuContRmbCheck.c new file mode 100644 index 0000000000..afbf6c05e2 --- /dev/null +++ b/src/os/nusys/nuContRmbCheck.c @@ -0,0 +1,21 @@ +#include "common.h" +#include "nu/nusys.h" + +s32 nuContRmbCheck(u32 contNo) { + NUContRmbMesg mesg; + s32 err; + OSIntMask mask; + + mesg.contNo = contNo; + err = nuSiSendMesg(NU_CONT_RMB_CHECK_MSG, &mesg); + mask = osSetIntMask(1); + + if (err == 0) { + nuContRmbCtl[contNo].type = NU_CONT_PAK_TYPE_RUMBLE; + } else { + nuContRmbCtl[contNo].type = NU_CONT_PAK_TYPE_NONE; + } + osSetIntMask(mask); + + return err; +} diff --git a/src/os/nusys/nuContRmbMgr.c b/src/os/nusys/nuContRmbMgr.c index 202f0e30ed..79b2033201 100644 --- a/src/os/nusys/nuContRmbMgr.c +++ b/src/os/nusys/nuContRmbMgr.c @@ -151,7 +151,7 @@ static s32 contRmbForceStopMesg(NUSiCommonMesg* mesg) { return 0; } -static s32 contRmbForceStopEndMesg(NUSiCommonMesg* mesg) { +s32 contRmbForceStopEndMesg(NUSiCommonMesg* mesg) { u32 i; for (i = 0; i < NU_CONT_MAXCONTROLLERS; i++) { diff --git a/src/os/nusys/nuContRmbStart.c b/src/os/nusys/nuContRmbStart.c new file mode 100644 index 0000000000..9826c374a4 --- /dev/null +++ b/src/os/nusys/nuContRmbStart.c @@ -0,0 +1,16 @@ +#include "common.h" +#include "nu/nusys.h" + +void nuContRmbStart(u32 contNo, u16 freq, u16 frame) { + NUContRmbCtl ctl; + NUContRmbMesg mesg; + + if (!(nuContRmbCtl[contNo].mode & NU_CONT_RMB_MODE_PAUSE)) { + ctl.state = NU_CONT_RMB_STATE_RUN; + ctl.freq = freq; + ctl.frame = frame; + mesg.data = &ctl; + mesg.contNo = contNo; + nuSiSendMesg(NU_CONT_RMB_START_MSG, &mesg); + } +} diff --git a/src/os/nusys/nuSched.c b/src/os/nusys/nuSched.c new file mode 100644 index 0000000000..db20b49d01 --- /dev/null +++ b/src/os/nusys/nuSched.c @@ -0,0 +1,90 @@ +#include "common.h" +#include "nu/nusys.h" + +void INCLUDE_ASM("os/code_39db0_len_8a0", nuScCreateScheduler, u8 videoMode, u8 numFields); + +INCLUDE_ASM("os/code_39db0_len_8a0", nuScExecuteAudio); + +INCLUDE_ASM("os/code_39db0_len_8a0", nuScExecuteGraphics); + +void INCLUDE_ASM("os/code_39db0_len_8a0", nuScAddClient, NUScClient *c, OSMesgQueue *mq, NUScMsg msgType); + +void nuScRemoveClient(NUScClient *client) { + s32 mask = osSetIntMask(OS_IM_NONE); + NUScClient *clientList = nusched.clientList; + NUScClient *prev = NULL; + + while (clientList != NULL) { + if (clientList == client) { + if (prev != NULL) { + prev->next = clientList->next; + } else { + nusched.clientList = clientList->next; + } + break; + } + prev = clientList; + clientList = clientList->next; + } + + osSetIntMask(mask); +} + +void nuScResetClientMesgType(NUScClient* client, NUScMsg msgType) { + s32 mask; + + mask = osSetIntMask(OS_IM_NONE); + client->msgType = msgType; + osSetIntMask(mask); +} + +#ifdef NON_MATCHING +// This should match when data is decompiled. +OSMesgQueue* nuScGetGfxMQ(void) { + return &nusched.graphicsRequestMQ; +} +#else +OSMesgQueue* INCLUDE_ASM("os/code_39db0_len_8a0", nuScGetGfxMQ, void); +#endif + +#ifdef NON_MATCHING +// This should match when data is decompiled. +OSMesgQueue* nuScGetAudioMQ(void) { + return &nusched.audioRequestMQ; +} +#else +OSMesgQueue* INCLUDE_ASM("os/code_39db0_len_8a0", nuScGetAudioMQ, void); +#endif + +#ifdef NON_MATCHING +// This should match when data is decompiled. +void nuScSetFrameBufferNum(u8 frameBufferNum) { + nusched.frameBufferNum = frameBufferNum; +} +#else +void INCLUDE_ASM("os/code_39db0_len_8a0", nuScSetFrameBufferNum, u8 frameBufferNum); +#endif + +#ifdef NON_MATCHING +// This should match when data is decompiled. +s32 nuScGetFrameRate(void) { + return nusched.frameRate; +} +#else +s32 INCLUDE_ASM("os/code_39db0_len_8a0", nuScGetFrameRate, void); +#endif + +INCLUDE_ASM("os/code_39db0_len_8a0", nuScEventHandler); + +static void nuScEventBroadcast(NUScMsg *msg) { + NUScClient *clientList = nusched.clientList; + + while (clientList != NULL) { + if (clientList->msgType & *msg) { + osSendMesg(clientList->msgQ, msg, OS_MESG_NOBLOCK); + } + clientList = clientList->next; + } +} + +INCLUDE_ASM("os/code_39db0_len_8a0", nuScWaitTaskReady); diff --git a/tools/splat.yaml b/tools/splat.yaml index 673954f90c..643992e497 100644 --- a/tools/splat.yaml +++ b/tools/splat.yaml @@ -58,7 +58,7 @@ segments: - [0x362a0, "c", "code_362a0_len_2f70"] - [0x39210, "c", "code_39210_len_aa0"] - [0x39cb0, "c", "os/code_39cb0_len_100"] - - [0x39db0, "c", "os/code_39db0_len_8a0"] + - [0x39db0, "c", "os/nusys/nuSched"] - [0x3a650, "c", "os/nusys/nuGfxFuncSet"] - [0x3a690, "c", "os/nusys/nuGfxPreNMIFuncSet"] - [0x3a6d0, "c", "os/nusys/nuGfxTaskAllEndWait"] @@ -72,7 +72,8 @@ segments: - [0x3aa50, "c", "os/nusys/nuContDataGet"] - [0x3aab0, "c", "os/nusys/nuContPakMgr"] - [0x3af10, "c", "os/nusys/nuContRmbMgr"] - - [0x3b290, "c", "os/code_3b290_len_100"] + - [0x3b290, "c", "os/nusys/nuContRmbStart"] + - [0x3b2f0, "c", "os/nusys/nuContRmbCheck"] - [0x3b390, "c", "os/code_3b390_len_110"] - [0x3b4a0, "c", "os/code_3b4a0_len_270"] - [0x3b710, "c", "os/code_3b710_len_40"] diff --git a/undefined_syms.txt b/undefined_syms.txt index bc52034f61..3ee58feb06 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -71,6 +71,7 @@ gCurrentEncounter = 0x800B0F10; nuContRmbCtl = 0x800B1d40; nuContData = 0x800B1D68; gCameras = 0x800B1D80; +nusched = 0x800DA440; nuContPfs = 0x800DAAD8; nuSiMesgQ = 0x800DAC78; D_800DC500 = 0x800DC500; From 4c4ce1a4e018098f4fc07fde92ca9f399225b57f Mon Sep 17 00:00:00 2001 From: JoshDuMan Date: Mon, 28 Sep 2020 00:38:21 -0400 Subject: [PATCH 5/7] Work on merge --- src/os/code_39db0_len_8a0.c | 25 ------------------- src/os/code_3a650_len_40.c | 3 --- src/os/code_3a690_len_40.c | 3 --- src/os/code_3a6d0_len_20.c | 3 --- src/os/code_3a6f0_len_110.c | 3 --- src/os/code_3a800_len_30.c | 3 --- src/os/code_3a830_len_20.c | 3 --- src/os/code_3a850_le_a40.c | 50 ------------------------------------- src/os/code_3b290_len_100.c | 5 ---- src/os/nusys/nuContRmbMgr.c | 2 +- src/os/nusys/nuGfxSetCfb.c | 2 +- src/os/nusys/nuSched.c | 4 +-- tools/n64splat | 1 - tools/star-rod | 1 - 14 files changed, 4 insertions(+), 104 deletions(-) delete mode 100644 src/os/code_39db0_len_8a0.c delete mode 100644 src/os/code_3a650_len_40.c delete mode 100644 src/os/code_3a690_len_40.c delete mode 100644 src/os/code_3a6d0_len_20.c delete mode 100644 src/os/code_3a6f0_len_110.c delete mode 100644 src/os/code_3a800_len_30.c delete mode 100644 src/os/code_3a830_len_20.c delete mode 100644 src/os/code_3a850_le_a40.c delete mode 100644 src/os/code_3b290_len_100.c delete mode 160000 tools/n64splat delete mode 160000 tools/star-rod diff --git a/src/os/code_39db0_len_8a0.c b/src/os/code_39db0_len_8a0.c deleted file mode 100644 index 74d513375e..0000000000 --- a/src/os/code_39db0_len_8a0.c +++ /dev/null @@ -1,25 +0,0 @@ -#include "common.h" - -INCLUDE_ASM(s32, "os/code_39db0_len_8a0", nuScCreateScheduler); - -INCLUDE_ASM(s32, "os/code_39db0_len_8a0", nuScExecuteAudio); - -INCLUDE_ASM(s32, "os/code_39db0_len_8a0", nuScAddClient); - -INCLUDE_ASM(s32, "os/code_39db0_len_8a0", nuScRemoveClient); - -INCLUDE_ASM(s32, "os/code_39db0_len_8a0", nuScResetClientMesgType); - -INCLUDE_ASM(s32, "os/code_39db0_len_8a0", nuScGetGfxMQ); - -INCLUDE_ASM(s32, "os/code_39db0_len_8a0", nuScGetAudioMQ); - -INCLUDE_ASM(s32, "os/code_39db0_len_8a0", nuScSetFrameBufferNum); - -INCLUDE_ASM(s32, "os/code_39db0_len_8a0", nuScGetFrameRate); - -INCLUDE_ASM(s32, "os/code_39db0_len_8a0", nuScEventHandler); - -INCLUDE_ASM(s32, "os/code_39db0_len_8a0", nuScEventBroadcast); - -INCLUDE_ASM(s32, "os/code_39db0_len_8a0", nuScWaitTaskReady); diff --git a/src/os/code_3a650_len_40.c b/src/os/code_3a650_len_40.c deleted file mode 100644 index b7f8f3b5c4..0000000000 --- a/src/os/code_3a650_len_40.c +++ /dev/null @@ -1,3 +0,0 @@ -#include "common.h" - -INCLUDE_ASM(s32, "os/code_3a650_len_40", nuGfxFuncSet); diff --git a/src/os/code_3a690_len_40.c b/src/os/code_3a690_len_40.c deleted file mode 100644 index 9bff4185bb..0000000000 --- a/src/os/code_3a690_len_40.c +++ /dev/null @@ -1,3 +0,0 @@ -#include "common.h" - -INCLUDE_ASM(s32, "os/code_3a690_len_40", nuGfxPreNMIFuncSet); diff --git a/src/os/code_3a6d0_len_20.c b/src/os/code_3a6d0_len_20.c deleted file mode 100644 index 8cf605b336..0000000000 --- a/src/os/code_3a6d0_len_20.c +++ /dev/null @@ -1,3 +0,0 @@ -#include "common.h" - -INCLUDE_ASM(s32, "os/code_3a6d0_len_20", nuGfxTaskAllEndWait); diff --git a/src/os/code_3a6f0_len_110.c b/src/os/code_3a6f0_len_110.c deleted file mode 100644 index 09c7bb7b09..0000000000 --- a/src/os/code_3a6f0_len_110.c +++ /dev/null @@ -1,3 +0,0 @@ -#include "common.h" - -INCLUDE_ASM(s32, "os/code_3a6f0_len_110", nuGfxSetCfb); diff --git a/src/os/code_3a800_len_30.c b/src/os/code_3a800_len_30.c deleted file mode 100644 index b396df9c1b..0000000000 --- a/src/os/code_3a800_len_30.c +++ /dev/null @@ -1,3 +0,0 @@ -#include "common.h" - -INCLUDE_ASM(s32, "os/code_3a800_len_30", nuGfxDisplayOff); diff --git a/src/os/code_3a830_len_20.c b/src/os/code_3a830_len_20.c deleted file mode 100644 index 865786c617..0000000000 --- a/src/os/code_3a830_len_20.c +++ /dev/null @@ -1,3 +0,0 @@ -#include "common.h" - -INCLUDE_ASM(s32, "os/code_3a830_len_20", nuGfxDisplayOn); diff --git a/src/os/code_3a850_le_a40.c b/src/os/code_3a850_le_a40.c deleted file mode 100644 index e623dc422c..0000000000 --- a/src/os/code_3a850_le_a40.c +++ /dev/null @@ -1,50 +0,0 @@ -#include "common.h" - -INCLUDE_ASM(s32, "os/code_3a850_le_a40", nuPiInit); - -INCLUDE_ASM(s32, "os/code_3a850_le_a40", nuPiReadRom); - -INCLUDE_ASM(s32, "os/code_3a850_le_a40", nuGfxInit); - -INCLUDE_ASM(s32, "os/code_3a850_le_a40", nuContInit); - -INCLUDE_ASM(s32, "os/code_3a850_le_a40", nuContDataGet); - -INCLUDE_ASM(s32, "os/code_3a850_le_a40", nuContPakMgrInit); - -INCLUDE_ASM(s32, "os/code_3a850_le_a40", nuContPakMgrRemove); - -INCLUDE_ASM(s32, "os/code_3a850_le_a40", contPakOpen); - -INCLUDE_ASM(s32, "os/code_3a850_le_a40", contPakFree); - -INCLUDE_ASM(s32, "os/code_3a850_le_a40", contPakFileReadWrite); - -INCLUDE_ASM(s32, "os/code_3a850_le_a40", contPakFileOpen); - -INCLUDE_ASM(s32, "os/code_3a850_le_a40", contPakFileDelete); - -INCLUDE_ASM(s32, "os/code_3a850_le_a40", contPakFileState); - -INCLUDE_ASM(s32, "os/code_3a850_le_a40", contPakFileNum); - -INCLUDE_ASM(s32, "os/code_3a850_le_a40", contPakRepairId); - -#undef osMotorStop -INCLUDE_ASM(s32, "os/code_3a850_le_a40", osMotorStop, OSPfs* unk); - -INCLUDE_ASM(s32, "os/code_3a850_le_a40", contRmbControl); - -INCLUDE_ASM(s32, "os/code_3a850_le_a40", nuContRmbMgrInit); - -INCLUDE_ASM(s32, "os/code_3a850_le_a40", nuContRmbMgrRemove); - -INCLUDE_ASM(s32, "os/code_3a850_le_a40", contRmbCheckMesg); - -INCLUDE_ASM(s32, "os/code_3a850_le_a40", contRmbStartMesg); - -INCLUDE_ASM(s32, "os/code_3a850_le_a40", func_8005FDE4); - -INCLUDE_ASM(s32, "os/code_3a850_le_a40", func_8005FE0C); - -INCLUDE_ASM(s32, "os/code_3a850_le_a40", func_8005FE54); diff --git a/src/os/code_3b290_len_100.c b/src/os/code_3b290_len_100.c deleted file mode 100644 index 355f256e80..0000000000 --- a/src/os/code_3b290_len_100.c +++ /dev/null @@ -1,5 +0,0 @@ -#include "common.h" - -INCLUDE_ASM(s32, "os/code_3b290_len_100", nuContRmbStart); - -INCLUDE_ASM(s32, "os/code_3b290_len_100", nuContRmbCheck); diff --git a/src/os/nusys/nuContRmbMgr.c b/src/os/nusys/nuContRmbMgr.c index 79b2033201..76fc26520e 100644 --- a/src/os/nusys/nuContRmbMgr.c +++ b/src/os/nusys/nuContRmbMgr.c @@ -108,7 +108,7 @@ void nuContRmbMgrInit(void) { nuSiCallBackAdd(&nuContRmbCallBack); } #else -void INCLUDE_ASM("os/nuContRmbMgr", nuContRmbMgrInit); +INCLUDE_ASM(void, "os/nuContRmbMgr", nuContRmbMgrInit); #endif void nuContRmbMgrRemove(void) { diff --git a/src/os/nusys/nuGfxSetCfb.c b/src/os/nusys/nuGfxSetCfb.c index 69b284b871..7822178a42 100644 --- a/src/os/nusys/nuGfxSetCfb.c +++ b/src/os/nusys/nuGfxSetCfb.c @@ -1,3 +1,3 @@ #include "common.h" -INCLUDE_API_ASM("os/nuGfxSetCfb", nuGfxSetCfb); +INCLUDE_ASM(void, "os/nuGfxSetCfb", nuGfxSetCfb); diff --git a/src/os/nusys/nuSched.c b/src/os/nusys/nuSched.c index d4fbae7f4e..1e28c2e601 100644 --- a/src/os/nusys/nuSched.c +++ b/src/os/nusys/nuSched.c @@ -5,7 +5,7 @@ INCLUDE_ASM(void, "os/code_39db0_len_8a0", nuScCreateScheduler, u8 videoMode, u8 INCLUDE_ASM(void, "os/code_39db0_len_8a0", nuScExecuteAudio); -INCLUDE_ASM(void, "os/code_39db0_len_8a0", nuScExecuteGraphics); +// INCLUDE_ASM(void, "os/code_39db0_len_8a0", nuScExecuteGraphics); INCLUDE_ASM(void, "os/code_39db0_len_8a0", nuScAddClient, NUScClient *c, OSMesgQueue *mq, NUScMsg msgType); @@ -71,7 +71,7 @@ s32 nuScGetFrameRate(void) { return nusched.frameRate; } #else -(s32, "os/code_39db0_len_8a0", nuScGetFrameRate, void); +INCLUDE_ASM(s32, "os/code_39db0_len_8a0", nuScGetFrameRate, void); #endif INCLUDE_ASM(void, "os/code_39db0_len_8a0", nuScEventHandler); diff --git a/tools/n64splat b/tools/n64splat deleted file mode 160000 index e9d9a22063..0000000000 --- a/tools/n64splat +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e9d9a22063fb19d270829950f4b79a5670bd4bd4 diff --git a/tools/star-rod b/tools/star-rod deleted file mode 160000 index 3a32d3d6dd..0000000000 --- a/tools/star-rod +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3a32d3d6dda7374e4f32ae86530444e45956d803 From 4116524462ab33ce9d683f8c2b9c031cdac863dc Mon Sep 17 00:00:00 2001 From: JoshDuMan Date: Mon, 28 Sep 2020 01:05:09 -0400 Subject: [PATCH 6/7] Fix build wholly --- papermario.ld | 2 +- tools/n64splat | 1 + tools/star-rod | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) create mode 160000 tools/n64splat create mode 160000 tools/star-rod diff --git a/papermario.ld b/papermario.ld index b845fe68b7..7aa6268127 100644 --- a/papermario.ld +++ b/papermario.ld @@ -2,7 +2,7 @@ SECTIONS { /* 0x0 0-40 (len 40) */ .text_0 0x0 : AT(0x0) { - build/header/header.o(.text_0); + build/asm/header.o(.text_0); } /* 0xA4000040 40-1000 (len FC0) */ diff --git a/tools/n64splat b/tools/n64splat new file mode 160000 index 0000000000..1e6f29d78e --- /dev/null +++ b/tools/n64splat @@ -0,0 +1 @@ +Subproject commit 1e6f29d78e80cd8e43b2b9e82895103baf83a04c diff --git a/tools/star-rod b/tools/star-rod new file mode 160000 index 0000000000..9df51d2962 --- /dev/null +++ b/tools/star-rod @@ -0,0 +1 @@ +Subproject commit 9df51d29626ffae94ff7ed03c252c24e71430105 From 230597b4eea827e1564b06786abb052127290078 Mon Sep 17 00:00:00 2001 From: JoshDuMan Date: Wed, 14 Oct 2020 13:36:34 -0400 Subject: [PATCH 7/7] Fix PR requests --- .../os/code_39db0_len_8a0/nuScAddClient.s | 40 ----- .../code_39db0_len_8a0/nuScCreateScheduler.s | 146 ------------------ .../os/code_39db0_len_8a0/nuScExecuteAudio.s | 74 --------- .../code_39db0_len_8a0/nuScExecuteGraphics.s | 79 ++++++++++ src/os/nusys/nuContInit.c | 3 +- src/os/nusys/nuGfxPreNMIFuncSet.c | 3 +- src/os/nusys/nuSched.c | 88 ++++++++++- undefined_syms.txt | 7 + 8 files changed, 168 insertions(+), 272 deletions(-) delete mode 100644 asm/nonmatchings/os/code_39db0_len_8a0/nuScAddClient.s delete mode 100644 asm/nonmatchings/os/code_39db0_len_8a0/nuScCreateScheduler.s create mode 100644 asm/nonmatchings/os/code_39db0_len_8a0/nuScExecuteGraphics.s diff --git a/asm/nonmatchings/os/code_39db0_len_8a0/nuScAddClient.s b/asm/nonmatchings/os/code_39db0_len_8a0/nuScAddClient.s deleted file mode 100644 index e0c6e67985..0000000000 --- a/asm/nonmatchings/os/code_39db0_len_8a0/nuScAddClient.s +++ /dev/null @@ -1,40 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel nuScAddClient -/* 3A230 8005EE30 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 3A234 8005EE34 AFB00010 */ sw $s0, 0x10($sp) -/* 3A238 8005EE38 0080802D */ daddu $s0, $a0, $zero -/* 3A23C 8005EE3C AFB20018 */ sw $s2, 0x18($sp) -/* 3A240 8005EE40 00A0902D */ daddu $s2, $a1, $zero -/* 3A244 8005EE44 AFB10014 */ sw $s1, 0x14($sp) -/* 3A248 8005EE48 00C0882D */ daddu $s1, $a2, $zero -/* 3A24C 8005EE4C AFBF001C */ sw $ra, 0x1c($sp) -/* 3A250 8005EE50 0C018250 */ jal osSetIntMask -/* 3A254 8005EE54 24040001 */ addiu $a0, $zero, 1 -/* 3A258 8005EE58 3C05800E */ lui $a1, 0x800e -/* 3A25C 8005EE5C 24A5AAA8 */ addiu $a1, $a1, -0x5558 -/* 3A260 8005EE60 AE120004 */ sw $s2, 4($s0) -/* 3A264 8005EE64 8CA30000 */ lw $v1, ($a1) -/* 3A268 8005EE68 A6110008 */ sh $s1, 8($s0) -/* 3A26C 8005EE6C 32310002 */ andi $s1, $s1, 2 -/* 3A270 8005EE70 AE030000 */ sw $v1, ($s0) -/* 3A274 8005EE74 ACB00000 */ sw $s0, ($a1) -/* 3A278 8005EE78 12200008 */ beqz $s1, .L8005EE9C -/* 3A27C 8005EE7C 0040802D */ daddu $s0, $v0, $zero -/* 3A280 8005EE80 3C02800A */ lui $v0, 0x800a -/* 3A284 8005EE84 9042A5B0 */ lbu $v0, -0x5a50($v0) -/* 3A288 8005EE88 10400004 */ beqz $v0, .L8005EE9C -/* 3A28C 8005EE8C 0240202D */ daddu $a0, $s2, $zero -/* 3A290 8005EE90 24A5F99A */ addiu $a1, $a1, -0x666 -/* 3A294 8005EE94 0C019608 */ jal osSendMesg -/* 3A298 8005EE98 0000302D */ daddu $a2, $zero, $zero -.L8005EE9C: -/* 3A29C 8005EE9C 0C018250 */ jal osSetIntMask -/* 3A2A0 8005EEA0 0200202D */ daddu $a0, $s0, $zero -/* 3A2A4 8005EEA4 8FBF001C */ lw $ra, 0x1c($sp) -/* 3A2A8 8005EEA8 8FB20018 */ lw $s2, 0x18($sp) -/* 3A2AC 8005EEAC 8FB10014 */ lw $s1, 0x14($sp) -/* 3A2B0 8005EEB0 8FB00010 */ lw $s0, 0x10($sp) -/* 3A2B4 8005EEB4 03E00008 */ jr $ra -/* 3A2B8 8005EEB8 27BD0020 */ addiu $sp, $sp, 0x20 diff --git a/asm/nonmatchings/os/code_39db0_len_8a0/nuScCreateScheduler.s b/asm/nonmatchings/os/code_39db0_len_8a0/nuScCreateScheduler.s deleted file mode 100644 index 2ef55cbe20..0000000000 --- a/asm/nonmatchings/os/code_39db0_len_8a0/nuScCreateScheduler.s +++ /dev/null @@ -1,146 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel nuScCreateScheduler -/* 39DB0 8005E9B0 27BDFFD0 */ addiu $sp, $sp, -0x30 -/* 39DB4 8005E9B4 AFB40028 */ sw $s4, 0x28($sp) -/* 39DB8 8005E9B8 0080A02D */ daddu $s4, $a0, $zero -/* 39DBC 8005E9BC AFB30024 */ sw $s3, 0x24($sp) -/* 39DC0 8005E9C0 00A0982D */ daddu $s3, $a1, $zero -/* 39DC4 8005E9C4 3C04800E */ lui $a0, 0x800e -/* 39DC8 8005E9C8 2484AAAC */ addiu $a0, $a0, -0x5554 -/* 39DCC 8005E9CC 24020001 */ addiu $v0, $zero, 1 -/* 39DD0 8005E9D0 24030002 */ addiu $v1, $zero, 2 -/* 39DD4 8005E9D4 AFBF002C */ sw $ra, 0x2c($sp) -/* 39DD8 8005E9D8 AFB20020 */ sw $s2, 0x20($sp) -/* 39DDC 8005E9DC AFB1001C */ sw $s1, 0x1c($sp) -/* 39DE0 8005E9E0 AFB00018 */ sw $s0, 0x18($sp) -/* 39DE4 8005E9E4 A482F994 */ sh $v0, -0x66c($a0) -/* 39DE8 8005E9E8 326200FF */ andi $v0, $s3, 0xff -/* 39DEC 8005E9EC AC82000C */ sw $v0, 0xc($a0) -/* 39DF0 8005E9F0 A0830011 */ sb $v1, 0x11($a0) -/* 39DF4 8005E9F4 3C028000 */ lui $v0, 0x8000 -/* 39DF8 8005E9F8 8C420300 */ lw $v0, 0x300($v0) -/* 39DFC 8005E9FC A483F996 */ sh $v1, -0x66a($a0) -/* 39E00 8005EA00 2483F994 */ addiu $v1, $a0, -0x66c -/* 39E04 8005EA04 AC800000 */ sw $zero, ($a0) -/* 39E08 8005EA08 AC800004 */ sw $zero, 4($a0) -/* 39E0C 8005EA0C AC800008 */ sw $zero, 8($a0) -/* 39E10 8005EA10 14400004 */ bnez $v0, .L8005EA24 -/* 39E14 8005EA14 AC80FFFC */ sw $zero, -4($a0) -/* 39E18 8005EA18 24020032 */ addiu $v0, $zero, 0x32 -/* 39E1C 8005EA1C 08017A8B */ j .L8005EA2C -/* 39E20 8005EA20 A062067C */ sb $v0, 0x67c($v1) -.L8005EA24: -/* 39E24 8005EA24 2402003C */ addiu $v0, $zero, 0x3c -/* 39E28 8005EA28 A0820010 */ sb $v0, 0x10($a0) -.L8005EA2C: -/* 39E2C 8005EA2C 3C10800E */ lui $s0, 0x800e -/* 39E30 8005EA30 2610A4B4 */ addiu $s0, $s0, -0x5b4c -/* 39E34 8005EA34 0200202D */ daddu $a0, $s0, $zero -/* 39E38 8005EA38 26050018 */ addiu $a1, $s0, 0x18 -/* 39E3C 8005EA3C 3C01800A */ lui $at, 0x800a -/* 39E40 8005EA40 A020A5B0 */ sb $zero, -0x5a50($at) -/* 39E44 8005EA44 0C019560 */ jal osCreateMesgQueue -/* 39E48 8005EA48 24060008 */ addiu $a2, $zero, 8 -/* 39E4C 8005EA4C 26120038 */ addiu $s2, $s0, 0x38 -/* 39E50 8005EA50 0240202D */ daddu $a0, $s2, $zero -/* 39E54 8005EA54 26050050 */ addiu $a1, $s0, 0x50 -/* 39E58 8005EA58 0C019560 */ jal osCreateMesgQueue -/* 39E5C 8005EA5C 24060008 */ addiu $a2, $zero, 8 -/* 39E60 8005EA60 26110070 */ addiu $s1, $s0, 0x70 -/* 39E64 8005EA64 0220202D */ daddu $a0, $s1, $zero -/* 39E68 8005EA68 26050088 */ addiu $a1, $s0, 0x88 -/* 39E6C 8005EA6C 0C019560 */ jal osCreateMesgQueue -/* 39E70 8005EA70 24060008 */ addiu $a2, $zero, 8 -/* 39E74 8005EA74 2604FFC8 */ addiu $a0, $s0, -0x38 -/* 39E78 8005EA78 2605FFE0 */ addiu $a1, $s0, -0x20 -/* 39E7C 8005EA7C 0C019560 */ jal osCreateMesgQueue -/* 39E80 8005EA80 24060008 */ addiu $a2, $zero, 8 -/* 39E84 8005EA84 2604FF90 */ addiu $a0, $s0, -0x70 -/* 39E88 8005EA88 2605FFA8 */ addiu $a1, $s0, -0x58 -/* 39E8C 8005EA8C 0C019560 */ jal osCreateMesgQueue -/* 39E90 8005EA90 24060008 */ addiu $a2, $zero, 8 -/* 39E94 8005EA94 260400A8 */ addiu $a0, $s0, 0xa8 -/* 39E98 8005EA98 260500C0 */ addiu $a1, $s0, 0xc0 -/* 39E9C 8005EA9C 0C019560 */ jal osCreateMesgQueue -/* 39EA0 8005EAA0 24060008 */ addiu $a2, $zero, 8 -/* 39EA4 8005EAA4 0C019A9C */ jal osCreateViManager -/* 39EA8 8005EAA8 240400FE */ addiu $a0, $zero, 0xfe -/* 39EAC 8005EAAC 328200FF */ andi $v0, $s4, 0xff -/* 39EB0 8005EAB0 00022080 */ sll $a0, $v0, 2 -/* 39EB4 8005EAB4 00822021 */ addu $a0, $a0, $v0 -/* 39EB8 8005EAB8 00042100 */ sll $a0, $a0, 4 -/* 39EBC 8005EABC 3C028009 */ lui $v0, 0x8009 -/* 39EC0 8005EAC0 244246A0 */ addiu $v0, $v0, 0x46a0 -/* 39EC4 8005EAC4 0C019B84 */ jal osViSetMode -/* 39EC8 8005EAC8 00822021 */ addu $a0, $a0, $v0 -/* 39ECC 8005EACC 0C019CE0 */ jal osViBlack -/* 39ED0 8005EAD0 24040001 */ addiu $a0, $zero, 1 -/* 39ED4 8005EAD4 0200202D */ daddu $a0, $s0, $zero -/* 39ED8 8005EAD8 2405029A */ addiu $a1, $zero, 0x29a -/* 39EDC 8005EADC 0C019B6C */ jal osViSetEvent -/* 39EE0 8005EAE0 326600FF */ andi $a2, $s3, 0xff -/* 39EE4 8005EAE4 24040004 */ addiu $a0, $zero, 4 -/* 39EE8 8005EAE8 0240282D */ daddu $a1, $s2, $zero -/* 39EEC 8005EAEC 0C019654 */ jal osSetEventMesg -/* 39EF0 8005EAF0 2406029B */ addiu $a2, $zero, 0x29b -/* 39EF4 8005EAF4 24040009 */ addiu $a0, $zero, 9 -/* 39EF8 8005EAF8 0220282D */ daddu $a1, $s1, $zero -/* 39EFC 8005EAFC 0C019654 */ jal osSetEventMesg -/* 39F00 8005EB00 2406029C */ addiu $a2, $zero, 0x29c -/* 39F04 8005EB04 2404000E */ addiu $a0, $zero, 0xe -/* 39F08 8005EB08 0200282D */ daddu $a1, $s0, $zero -/* 39F0C 8005EB0C 0C019654 */ jal osSetEventMesg -/* 39F10 8005EB10 2406029D */ addiu $a2, $zero, 0x29d -/* 39F14 8005EB14 261200E4 */ addiu $s2, $s0, 0xe4 -/* 39F18 8005EB18 0240202D */ daddu $a0, $s2, $zero -/* 39F1C 8005EB1C 24050013 */ addiu $a1, $zero, 0x13 -/* 39F20 8005EB20 3C068006 */ lui $a2, 0x8006 -/* 39F24 8005EB24 24C6EFA8 */ addiu $a2, $a2, -0x1058 -/* 39F28 8005EB28 2611FF8C */ addiu $s1, $s0, -0x74 -/* 39F2C 8005EB2C 0220382D */ daddu $a3, $s1, $zero -/* 39F30 8005EB30 3C02800B */ lui $v0, 0x800b -/* 39F34 8005EB34 244285D0 */ addiu $v0, $v0, -0x7a30 -/* 39F38 8005EB38 AFA20010 */ sw $v0, 0x10($sp) -/* 39F3C 8005EB3C 24020078 */ addiu $v0, $zero, 0x78 -/* 39F40 8005EB40 0C019798 */ jal osCreateThread -/* 39F44 8005EB44 AFA20014 */ sw $v0, 0x14($sp) -/* 39F48 8005EB48 0C019808 */ jal osStartThread -/* 39F4C 8005EB4C 0240202D */ daddu $a0, $s2, $zero -/* 39F50 8005EB50 26120294 */ addiu $s2, $s0, 0x294 -/* 39F54 8005EB54 0240202D */ daddu $a0, $s2, $zero -/* 39F58 8005EB58 24050012 */ addiu $a1, $zero, 0x12 -/* 39F5C 8005EB5C 3C068006 */ lui $a2, 0x8006 -/* 39F60 8005EB60 24C6EBE0 */ addiu $a2, $a2, -0x1420 -/* 39F64 8005EB64 0220382D */ daddu $a3, $s1, $zero -/* 39F68 8005EB68 3C02800B */ lui $v0, 0x800b -/* 39F6C 8005EB6C 2442A5D0 */ addiu $v0, $v0, -0x5a30 -/* 39F70 8005EB70 AFA20010 */ sw $v0, 0x10($sp) -/* 39F74 8005EB74 2402006E */ addiu $v0, $zero, 0x6e -/* 39F78 8005EB78 0C019798 */ jal osCreateThread -/* 39F7C 8005EB7C AFA20014 */ sw $v0, 0x14($sp) -/* 39F80 8005EB80 0C019808 */ jal osStartThread -/* 39F84 8005EB84 0240202D */ daddu $a0, $s2, $zero -/* 39F88 8005EB88 26100444 */ addiu $s0, $s0, 0x444 -/* 39F8C 8005EB8C 0200202D */ daddu $a0, $s0, $zero -/* 39F90 8005EB90 24050011 */ addiu $a1, $zero, 0x11 -/* 39F94 8005EB94 3C068006 */ lui $a2, 0x8006 -/* 39F98 8005EB98 24C6ED14 */ addiu $a2, $a2, -0x12ec -/* 39F9C 8005EB9C 0220382D */ daddu $a3, $s1, $zero -/* 39FA0 8005EBA0 3C02800B */ lui $v0, 0x800b -/* 39FA4 8005EBA4 2442C5D0 */ addiu $v0, $v0, -0x3a30 -/* 39FA8 8005EBA8 AFA20010 */ sw $v0, 0x10($sp) -/* 39FAC 8005EBAC 24020064 */ addiu $v0, $zero, 0x64 -/* 39FB0 8005EBB0 0C019798 */ jal osCreateThread -/* 39FB4 8005EBB4 AFA20014 */ sw $v0, 0x14($sp) -/* 39FB8 8005EBB8 0C019808 */ jal osStartThread -/* 39FBC 8005EBBC 0200202D */ daddu $a0, $s0, $zero -/* 39FC0 8005EBC0 8FBF002C */ lw $ra, 0x2c($sp) -/* 39FC4 8005EBC4 8FB40028 */ lw $s4, 0x28($sp) -/* 39FC8 8005EBC8 8FB30024 */ lw $s3, 0x24($sp) -/* 39FCC 8005EBCC 8FB20020 */ lw $s2, 0x20($sp) -/* 39FD0 8005EBD0 8FB1001C */ lw $s1, 0x1c($sp) -/* 39FD4 8005EBD4 8FB00018 */ lw $s0, 0x18($sp) -/* 39FD8 8005EBD8 03E00008 */ jr $ra -/* 39FDC 8005EBDC 27BD0030 */ addiu $sp, $sp, 0x30 diff --git a/asm/nonmatchings/os/code_39db0_len_8a0/nuScExecuteAudio.s b/asm/nonmatchings/os/code_39db0_len_8a0/nuScExecuteAudio.s index b535f0a735..62f7e9fa26 100644 --- a/asm/nonmatchings/os/code_39db0_len_8a0/nuScExecuteAudio.s +++ b/asm/nonmatchings/os/code_39db0_len_8a0/nuScExecuteAudio.s @@ -84,77 +84,3 @@ glabel nuScExecuteAudio /* 3A108 8005ED08 24060001 */ addiu $a2, $zero, 1 /* 3A10C 8005ED0C 08017B06 */ j .L8005EC18 /* 3A110 8005ED10 0280202D */ daddu $a0, $s4, $zero -/* 3A114 8005ED14 27BDFFD8 */ addiu $sp, $sp, -0x28 -/* 3A118 8005ED18 AFB00018 */ sw $s0, 0x18($sp) -/* 3A11C 8005ED1C 3C10800E */ lui $s0, 0x800e -/* 3A120 8005ED20 2610A47C */ addiu $s0, $s0, -0x5b84 -/* 3A124 8005ED24 AFB1001C */ sw $s1, 0x1c($sp) -/* 3A128 8005ED28 27B10014 */ addiu $s1, $sp, 0x14 -/* 3A12C 8005ED2C AFBF0020 */ sw $ra, 0x20($sp) -/* 3A130 8005ED30 0200202D */ daddu $a0, $s0, $zero -.L8005ED34: -/* 3A134 8005ED34 27A50010 */ addiu $a1, $sp, 0x10 -/* 3A138 8005ED38 0C0195BC */ jal osRecvMesg -/* 3A13C 8005ED3C 24060001 */ addiu $a2, $zero, 1 -/* 3A140 8005ED40 3C02800A */ lui $v0, 0x800a -/* 3A144 8005ED44 9042A5B0 */ lbu $v0, -0x5a50($v0) -/* 3A148 8005ED48 30420002 */ andi $v0, $v0, 2 -/* 3A14C 8005ED4C 14400032 */ bnez $v0, .L8005EE18 -/* 3A150 8005ED50 00000000 */ nop -/* 3A154 8005ED54 0C017C48 */ jal nuScWaitTaskReady -/* 3A158 8005ED58 8FA40010 */ lw $a0, 0x10($sp) -/* 3A15C 8005ED5C 0C018250 */ jal osSetIntMask -/* 3A160 8005ED60 24040001 */ addiu $a0, $zero, 1 -/* 3A164 8005ED64 8E030634 */ lw $v1, 0x634($s0) -/* 3A168 8005ED68 1060000C */ beqz $v1, .L8005ED9C -/* 3A16C 8005ED6C 0040202D */ daddu $a0, $v0, $zero -/* 3A170 8005ED70 8FA20010 */ lw $v0, 0x10($sp) -/* 3A174 8005ED74 0C018250 */ jal osSetIntMask -/* 3A178 8005ED78 AE020638 */ sw $v0, 0x638($s0) -/* 3A17C 8005ED7C 260400E0 */ addiu $a0, $s0, 0xe0 -/* 3A180 8005ED80 27A50014 */ addiu $a1, $sp, 0x14 -/* 3A184 8005ED84 0C0195BC */ jal osRecvMesg -/* 3A188 8005ED88 24060001 */ addiu $a2, $zero, 1 -/* 3A18C 8005ED8C 0C018250 */ jal osSetIntMask -/* 3A190 8005ED90 24040001 */ addiu $a0, $zero, 1 -/* 3A194 8005ED94 0040202D */ daddu $a0, $v0, $zero -/* 3A198 8005ED98 AE000638 */ sw $zero, 0x638($s0) -.L8005ED9C: -/* 3A19C 8005ED9C 0C018250 */ jal osSetIntMask -/* 3A1A0 8005EDA0 00000000 */ nop -/* 3A1A4 8005EDA4 0C018250 */ jal osSetIntMask -/* 3A1A8 8005EDA8 24040001 */ addiu $a0, $zero, 1 -/* 3A1AC 8005EDAC 8FA30010 */ lw $v1, 0x10($sp) -/* 3A1B0 8005EDB0 0040202D */ daddu $a0, $v0, $zero -/* 3A1B4 8005EDB4 0C018250 */ jal osSetIntMask -/* 3A1B8 8005EDB8 AE030630 */ sw $v1, 0x630($s0) -/* 3A1BC 8005EDBC 8FA40010 */ lw $a0, 0x10($sp) -/* 3A1C0 8005EDC0 0C019684 */ jal osSpTaskLoad -/* 3A1C4 8005EDC4 24840010 */ addiu $a0, $a0, 0x10 -/* 3A1C8 8005EDC8 8FA40010 */ lw $a0, 0x10($sp) -/* 3A1CC 8005EDCC 0C019707 */ jal osSpTaskStartGo -/* 3A1D0 8005EDD0 24840010 */ addiu $a0, $a0, 0x10 -/* 3A1D4 8005EDD4 26040070 */ addiu $a0, $s0, 0x70 -/* 3A1D8 8005EDD8 0220282D */ daddu $a1, $s1, $zero -/* 3A1DC 8005EDDC 0C0195BC */ jal osRecvMesg -/* 3A1E0 8005EDE0 24060001 */ addiu $a2, $zero, 1 -/* 3A1E4 8005EDE4 0C018250 */ jal osSetIntMask -/* 3A1E8 8005EDE8 24040001 */ addiu $a0, $zero, 1 -/* 3A1EC 8005EDEC 0040202D */ daddu $a0, $v0, $zero -/* 3A1F0 8005EDF0 0C018250 */ jal osSetIntMask -/* 3A1F4 8005EDF4 AE000630 */ sw $zero, 0x630($s0) -/* 3A1F8 8005EDF8 8FA20010 */ lw $v0, 0x10($sp) -/* 3A1FC 8005EDFC 8C420008 */ lw $v0, 8($v0) -/* 3A200 8005EE00 30420002 */ andi $v0, $v0, 2 -/* 3A204 8005EE04 14400004 */ bnez $v0, .L8005EE18 -/* 3A208 8005EE08 260400A8 */ addiu $a0, $s0, 0xa8 -/* 3A20C 8005EE0C 0220282D */ daddu $a1, $s1, $zero -/* 3A210 8005EE10 0C0195BC */ jal osRecvMesg -/* 3A214 8005EE14 24060001 */ addiu $a2, $zero, 1 -.L8005EE18: -/* 3A218 8005EE18 8FA50010 */ lw $a1, 0x10($sp) -/* 3A21C 8005EE1C 8CA40050 */ lw $a0, 0x50($a1) -/* 3A220 8005EE20 0C019608 */ jal osSendMesg -/* 3A224 8005EE24 24060001 */ addiu $a2, $zero, 1 -/* 3A228 8005EE28 08017B4D */ j .L8005ED34 -/* 3A22C 8005EE2C 0200202D */ daddu $a0, $s0, $zero diff --git a/asm/nonmatchings/os/code_39db0_len_8a0/nuScExecuteGraphics.s b/asm/nonmatchings/os/code_39db0_len_8a0/nuScExecuteGraphics.s new file mode 100644 index 0000000000..0858f9d641 --- /dev/null +++ b/asm/nonmatchings/os/code_39db0_len_8a0/nuScExecuteGraphics.s @@ -0,0 +1,79 @@ +.set noat # allow manual use of $at +.set noreorder # don't insert nops after branches + +glabel nuScExecuteGraphics + +/* 3A114 8005ED14 27BDFFD8 */ addiu $sp, $sp, -0x28 +/* 3A118 8005ED18 AFB00018 */ sw $s0, 0x18($sp) +/* 3A11C 8005ED1C 3C10800E */ lui $s0, 0x800e +/* 3A120 8005ED20 2610A47C */ addiu $s0, $s0, -0x5b84 +/* 3A124 8005ED24 AFB1001C */ sw $s1, 0x1c($sp) +/* 3A128 8005ED28 27B10014 */ addiu $s1, $sp, 0x14 +/* 3A12C 8005ED2C AFBF0020 */ sw $ra, 0x20($sp) +/* 3A130 8005ED30 0200202D */ daddu $a0, $s0, $zero +.L8005ED34: +/* 3A134 8005ED34 27A50010 */ addiu $a1, $sp, 0x10 +/* 3A138 8005ED38 0C0195BC */ jal osRecvMesg +/* 3A13C 8005ED3C 24060001 */ addiu $a2, $zero, 1 +/* 3A140 8005ED40 3C02800A */ lui $v0, 0x800a +/* 3A144 8005ED44 9042A5B0 */ lbu $v0, -0x5a50($v0) +/* 3A148 8005ED48 30420002 */ andi $v0, $v0, 2 +/* 3A14C 8005ED4C 14400032 */ bnez $v0, .L8005EE18 +/* 3A150 8005ED50 00000000 */ nop +/* 3A154 8005ED54 0C017C48 */ jal nuScWaitTaskReady +/* 3A158 8005ED58 8FA40010 */ lw $a0, 0x10($sp) +/* 3A15C 8005ED5C 0C018250 */ jal osSetIntMask +/* 3A160 8005ED60 24040001 */ addiu $a0, $zero, 1 +/* 3A164 8005ED64 8E030634 */ lw $v1, 0x634($s0) +/* 3A168 8005ED68 1060000C */ beqz $v1, .L8005ED9C +/* 3A16C 8005ED6C 0040202D */ daddu $a0, $v0, $zero +/* 3A170 8005ED70 8FA20010 */ lw $v0, 0x10($sp) +/* 3A174 8005ED74 0C018250 */ jal osSetIntMask +/* 3A178 8005ED78 AE020638 */ sw $v0, 0x638($s0) +/* 3A17C 8005ED7C 260400E0 */ addiu $a0, $s0, 0xe0 +/* 3A180 8005ED80 27A50014 */ addiu $a1, $sp, 0x14 +/* 3A184 8005ED84 0C0195BC */ jal osRecvMesg +/* 3A188 8005ED88 24060001 */ addiu $a2, $zero, 1 +/* 3A18C 8005ED8C 0C018250 */ jal osSetIntMask +/* 3A190 8005ED90 24040001 */ addiu $a0, $zero, 1 +/* 3A194 8005ED94 0040202D */ daddu $a0, $v0, $zero +/* 3A198 8005ED98 AE000638 */ sw $zero, 0x638($s0) +.L8005ED9C: +/* 3A19C 8005ED9C 0C018250 */ jal osSetIntMask +/* 3A1A0 8005EDA0 00000000 */ nop +/* 3A1A4 8005EDA4 0C018250 */ jal osSetIntMask +/* 3A1A8 8005EDA8 24040001 */ addiu $a0, $zero, 1 +/* 3A1AC 8005EDAC 8FA30010 */ lw $v1, 0x10($sp) +/* 3A1B0 8005EDB0 0040202D */ daddu $a0, $v0, $zero +/* 3A1B4 8005EDB4 0C018250 */ jal osSetIntMask +/* 3A1B8 8005EDB8 AE030630 */ sw $v1, 0x630($s0) +/* 3A1BC 8005EDBC 8FA40010 */ lw $a0, 0x10($sp) +/* 3A1C0 8005EDC0 0C019684 */ jal osSpTaskLoad +/* 3A1C4 8005EDC4 24840010 */ addiu $a0, $a0, 0x10 +/* 3A1C8 8005EDC8 8FA40010 */ lw $a0, 0x10($sp) +/* 3A1CC 8005EDCC 0C019707 */ jal osSpTaskStartGo +/* 3A1D0 8005EDD0 24840010 */ addiu $a0, $a0, 0x10 +/* 3A1D4 8005EDD4 26040070 */ addiu $a0, $s0, 0x70 +/* 3A1D8 8005EDD8 0220282D */ daddu $a1, $s1, $zero +/* 3A1DC 8005EDDC 0C0195BC */ jal osRecvMesg +/* 3A1E0 8005EDE0 24060001 */ addiu $a2, $zero, 1 +/* 3A1E4 8005EDE4 0C018250 */ jal osSetIntMask +/* 3A1E8 8005EDE8 24040001 */ addiu $a0, $zero, 1 +/* 3A1EC 8005EDEC 0040202D */ daddu $a0, $v0, $zero +/* 3A1F0 8005EDF0 0C018250 */ jal osSetIntMask +/* 3A1F4 8005EDF4 AE000630 */ sw $zero, 0x630($s0) +/* 3A1F8 8005EDF8 8FA20010 */ lw $v0, 0x10($sp) +/* 3A1FC 8005EDFC 8C420008 */ lw $v0, 8($v0) +/* 3A200 8005EE00 30420002 */ andi $v0, $v0, 2 +/* 3A204 8005EE04 14400004 */ bnez $v0, .L8005EE18 +/* 3A208 8005EE08 260400A8 */ addiu $a0, $s0, 0xa8 +/* 3A20C 8005EE0C 0220282D */ daddu $a1, $s1, $zero +/* 3A210 8005EE10 0C0195BC */ jal osRecvMesg +/* 3A214 8005EE14 24060001 */ addiu $a2, $zero, 1 +.L8005EE18: +/* 3A218 8005EE18 8FA50010 */ lw $a1, 0x10($sp) +/* 3A21C 8005EE1C 8CA40050 */ lw $a0, 0x50($a1) +/* 3A220 8005EE20 0C019608 */ jal osSendMesg +/* 3A224 8005EE24 24060001 */ addiu $a2, $zero, 1 +/* 3A228 8005EE28 08017B4D */ j .L8005ED34 +/* 3A22C 8005EE2C 0200202D */ daddu $a0, $s0, $zero diff --git a/src/os/nusys/nuContInit.c b/src/os/nusys/nuContInit.c index 72cd3e3213..50026a7b4a 100644 --- a/src/os/nusys/nuContInit.c +++ b/src/os/nusys/nuContInit.c @@ -2,9 +2,8 @@ #include "nu/nusys.h" u8 nuContInit(void) { - u8 contBits; + u8 contBits = nuSiMgrInit(); - contBits = nuSiMgrInit(); nuContMgrInit(); nuContPakMgrInit(); nuContRmbMgrInit(); diff --git a/src/os/nusys/nuGfxPreNMIFuncSet.c b/src/os/nusys/nuGfxPreNMIFuncSet.c index a896d631cf..9d88253261 100644 --- a/src/os/nusys/nuGfxPreNMIFuncSet.c +++ b/src/os/nusys/nuGfxPreNMIFuncSet.c @@ -2,9 +2,8 @@ #include "nu/nusys.h" void nuGfxPreNMIFuncSet(NUGfxPreNMIFunc func) { - OSIntMask intMask; + OSIntMask intMask = osSetIntMask(OS_IM_NONE); - intMask = osSetIntMask(OS_IM_NONE); nuGfxPreNMIFunc = func; osSetIntMask(intMask); } diff --git a/src/os/nusys/nuSched.c b/src/os/nusys/nuSched.c index 1e28c2e601..f19d3e4056 100644 --- a/src/os/nusys/nuSched.c +++ b/src/os/nusys/nuSched.c @@ -1,18 +1,90 @@ #include "common.h" #include "nu/nusys.h" -INCLUDE_ASM(void, "os/code_39db0_len_8a0", nuScCreateScheduler, u8 videoMode, u8 numFields); +void nuScEventHandler(void); +void nuScExecuteAudio(void); +void nuScExecuteGraphics(void); + +extern u8 D_8009A5B0; + +extern u64 nuScStack[NU_SC_STACK_SIZE / sizeof(u64)]; +extern u64 nuScAudioStack[NU_SC_STACK_SIZE / sizeof(u64)]; +extern u64 nuScGraphicsStack[NU_SC_STACK_SIZE / sizeof(u64)]; + +void nuScCreateScheduler(u8 videoMode, u8 numFields) { + nusched.curGraphicsTask = NULL; + nusched.curAudioTask = NULL; + nusched.graphicsTaskSuspended = NULL; + nusched.clientList = NULL; + + nusched.retraceMsg = NU_SC_RETRACE_MSG; + nusched.prenmiMsg = NU_SC_PRENMI_MSG; + nusched.retraceCount = numFields; + nusched.frameBufferNum = 2; + + if (osTvType == OS_TV_PAL) { + nusched.frameRate = 50; + } else { + nusched.frameRate = 60; + } + + D_8009A5B0 = 0; + + osCreateMesgQueue(&nusched.retraceMQ, nusched.retraceMsgBuf, NU_SC_MAX_MESGS); + osCreateMesgQueue(&nusched.rspMQ, nusched.rspMsgBuf, NU_SC_MAX_MESGS); + osCreateMesgQueue(&nusched.rdpMQ, nusched.rdpMsgBuf, NU_SC_MAX_MESGS); + osCreateMesgQueue(&nusched.graphicsRequestMQ, nusched.graphicsRequestBuf, NU_SC_MAX_MESGS); + osCreateMesgQueue(&nusched.audioRequestMQ, nusched.audioRequestBuf, NU_SC_MAX_MESGS); + osCreateMesgQueue(&nusched.waitMQ, nusched.waitMsgBuf, NU_SC_MAX_MESGS); + + osCreateViManager(0xFE); + osViSetMode(&osViModeTable[videoMode]); + osViBlack(TRUE); + osViSetEvent(&nusched.retraceMQ, (OSMesg) 0x29A, numFields); + + osSetEventMesg(OS_EVENT_SP, &nusched.rspMQ, (OSMesg) 0x29B); + osSetEventMesg(OS_EVENT_DP, &nusched.rdpMQ, (OSMesg) 0x29C); + osSetEventMesg(OS_EVENT_PRENMI, &nusched.retraceMQ, (OSMesg) 0x29D); + + osCreateThread(&nusched.schedulerThread, 19, (void(*)) nuScEventHandler, &nusched, + nuScStack + NU_SC_STACK_SIZE / sizeof(u64), NU_SC_HANDLER_PRI); + osStartThread(&nusched.schedulerThread); + + osCreateThread(&nusched.audioThread, 18, (void(*)) nuScExecuteAudio, &nusched, + nuScAudioStack + NU_SC_STACK_SIZE / sizeof(u64), NU_SC_AUDIO_PRI); + osStartThread(&nusched.audioThread); + + osCreateThread(&nusched.graphicsThread, 17, (void(*)) nuScExecuteGraphics, &nusched, + nuScGraphicsStack + NU_SC_STACK_SIZE / sizeof(u64), NU_SC_GRAPHICS_PRI); + osStartThread(&nusched.graphicsThread); +} INCLUDE_ASM(void, "os/code_39db0_len_8a0", nuScExecuteAudio); -// INCLUDE_ASM(void, "os/code_39db0_len_8a0", nuScExecuteGraphics); +INCLUDE_ASM(void, "os/code_39db0_len_8a0", nuScExecuteGraphics); -INCLUDE_ASM(void, "os/code_39db0_len_8a0", nuScAddClient, NUScClient *c, OSMesgQueue *mq, NUScMsg msgType); +void nuScAddClient(NUScClient* c, OSMesgQueue* mq, NUScMsg msgType) { + s32 mask; -void nuScRemoveClient(NUScClient *client) { + mask = osSetIntMask(OS_IM_NONE); + + c->msgQ = mq; + c->next = nusched.clientList; + c->msgType = msgType; + + nusched.clientList = c; + + if ((msgType & NU_SC_PRENMI_MSG) && D_8009A5B0) { + osSendMesg(mq, &nusched.prenmiMsg, OS_MESG_NOBLOCK); + } + + osSetIntMask(mask); +} + +void nuScRemoveClient(NUScClient* client) { s32 mask = osSetIntMask(OS_IM_NONE); - NUScClient *clientList = nusched.clientList; - NUScClient *prev = NULL; + NUScClient* clientList = nusched.clientList; + NUScClient* prev = NULL; while (clientList != NULL) { if (clientList == client) { @@ -76,8 +148,8 @@ INCLUDE_ASM(s32, "os/code_39db0_len_8a0", nuScGetFrameRate, void); INCLUDE_ASM(void, "os/code_39db0_len_8a0", nuScEventHandler); -static void nuScEventBroadcast(NUScMsg *msg) { - NUScClient *clientList = nusched.clientList; +static void nuScEventBroadcast(NUScMsg* msg) { + NUScClient* clientList = nusched.clientList; while (clientList != NULL) { if (clientList->msgType & *msg) { diff --git a/undefined_syms.txt b/undefined_syms.txt index e91d0efdba..57f046e266 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1,3 +1,5 @@ +osTvType = 0x80000300; + gGameStatusPtr = 0x8007419C; gRandSeed = 0x80074410; gUIStatus = 0x8010EF58; @@ -59,7 +61,9 @@ nuContRmbCallBack = 0x80093D00; nuGfxFunc = 0x80093D10; nuGfxPreNMIFunc = 0x80093D14; +osViModeTable = 0x800946A0; D_800959D4 = 0x800959D4; +D_8009A5B0 = 0x8009A5B0; D_8009A5D8 = 0x8009A5D8; nuGfxZBuffer = 0x8009A5DC; nuGfxDisplay = 0x8009A5F8; @@ -78,6 +82,9 @@ D_8009BA9C = 0x8009BA9C; D_8009BAA0 = 0x8009BAA0; D_800A0900 = 0x800A0900; +nuScStack = 0x800A65D0; +nuScAudioStack = 0x800A85D0; +nuScGraphicsStack = 0x800AA5D0; D_800AC5D0 = 0x800AC5D0; D_800AC5E8 = 0x800AC5E8;