diff --git a/Makefile b/Makefile index 3bdab7052f..3dc7c960ed 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ BUILD_DIR = build SRC_DIRS := src src/os src/os/nusys ASM_DIRS := asm asm/os -INCLUDE_DIRS := include include/PR +INCLUDE_DIRS := include include/PR src DATA_DIRS := bin # Source code files diff --git a/asm/nonmatchings/code_1370_len_7d0/boot_main.s b/asm/nonmatchings/code_1370_len_7d0/boot_main.s index 781ff51d1d..8eefbc48ee 100644 --- a/asm/nonmatchings/code_1370_len_7d0/boot_main.s +++ b/asm/nonmatchings/code_1370_len_7d0/boot_main.s @@ -11,52 +11,52 @@ glabel boot_main /* 1388 80025F88 3C048009 */ lui $a0, 0x8009 /* 138C 80025F8C 24845820 */ addiu $a0, $a0, 0x5820 /* 1390 80025F90 080097EB */ j .L80025FAC -/* 1394 80025F94 00000000 */ nop +/* 1394 80025F94 00000000 */ nop .L80025F98: /* 1398 80025F98 24020002 */ addiu $v0, $zero, 2 /* 139C 80025F9C 14620009 */ bne $v1, $v0, .L80025FC4 -/* 13A0 80025FA0 00000000 */ nop +/* 13A0 80025FA0 00000000 */ nop /* 13A4 80025FA4 3C048009 */ lui $a0, 0x8009 /* 13A8 80025FA8 24845870 */ addiu $a0, $a0, 0x5870 .L80025FAC: /* 13AC 80025FAC 0C019B84 */ jal osViSetMode -/* 13B0 80025FB0 00000000 */ nop +/* 13B0 80025FB0 00000000 */ nop /* 13B4 80025FB4 0C019B98 */ jal osViSetSpecialFeatures /* 13B8 80025FB8 2404005A */ addiu $a0, $zero, 0x5a /* 13BC 80025FBC 080097F3 */ j .L80025FCC -/* 13C0 80025FC0 00000000 */ nop +/* 13C0 80025FC0 00000000 */ nop .L80025FC4: /* 13C4 80025FC4 080097F1 */ j .L80025FC4 -/* 13C8 80025FC8 00000000 */ nop +/* 13C8 80025FC8 00000000 */ nop .L80025FCC: /* 13CC 80025FCC 0C017D00 */ jal nuGfxDisplayOff -/* 13D0 80025FD0 00000000 */ nop +/* 13D0 80025FD0 00000000 */ nop /* 13D4 80025FD4 0C00B22C */ jal crash_create_monitor -/* 13D8 80025FD8 00000000 */ nop +/* 13D8 80025FD8 00000000 */ nop /* 13DC 80025FDC 0C009718 */ jal func_80025C60 -/* 13E0 80025FE0 00000000 */ nop +/* 13E0 80025FE0 00000000 */ nop /* 13E4 80025FE4 0C017D58 */ jal nuGfxInit -/* 13E8 80025FE8 00000000 */ nop +/* 13E8 80025FE8 00000000 */ nop /* 13EC 80025FEC 0C017D84 */ jal nuContInit -/* 13F0 80025FF0 00000000 */ nop +/* 13F0 80025FF0 00000000 */ nop /* 13F4 80025FF4 3C038007 */ lui $v1, %hi(gGameStatusPtr) /* 13F8 80025FF8 8C63419C */ lw $v1, %lo(gGameStatusPtr)($v1) /* 13FC 80025FFC 0C00B458 */ jal func_8002D160 /* 1400 80026000 A0620073 */ sb $v0, 0x73($v1) /* 1404 80026004 0C0AC800 */ jal func_802B2000 -/* 1408 80026008 00000000 */ nop +/* 1408 80026008 00000000 */ nop /* 140C 8002600C 0C0AC80F */ jal func_802B203C -/* 1410 80026010 00000000 */ nop +/* 1410 80026010 00000000 */ nop /* 1414 80026014 3C048002 */ lui $a0, 0x8002 /* 1418 80026018 2484605C */ addiu $a0, $a0, 0x605c /* 141C 8002601C 0C017C94 */ jal nuGfxFuncSet -/* 1420 80026020 00000000 */ nop +/* 1420 80026020 00000000 */ nop /* 1424 80026024 3C048002 */ lui $a0, 0x8002 /* 1428 80026028 2484670C */ addiu $a0, $a0, 0x670c /* 142C 8002602C 0C017CA4 */ jal nuGfxPreNMIFuncSet -/* 1430 80026030 00000000 */ nop +/* 1430 80026030 00000000 */ nop /* 1434 80026034 0C019680 */ jal osGetCount -/* 1438 80026038 00000000 */ nop +/* 1438 80026038 00000000 */ nop /* 143C 8002603C 3C048007 */ lui $a0, %hi(gRandSeed) /* 1440 80026040 24844410 */ addiu $a0, $a0, %lo(gRandSeed) /* 1444 80026044 8C830000 */ lw $v1, ($a0) @@ -65,73 +65,4 @@ glabel boot_main /* 1450 80026050 AC830000 */ sw $v1, ($a0) .L80026054: /* 1454 80026054 08009815 */ j .L80026054 -/* 1458 80026058 00000000 */ nop -/* 145C 8002605C 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 1460 80026060 AFB10014 */ sw $s1, 0x14($sp) -/* 1464 80026064 3C118007 */ lui $s1, 0x8007 -/* 1468 80026068 26313E00 */ addiu $s1, $s1, 0x3e00 -/* 146C 8002606C AFBF0018 */ sw $ra, 0x18($sp) -/* 1470 80026070 AFB00010 */ sw $s0, 0x10($sp) -/* 1474 80026074 8E230000 */ lw $v1, ($s1) -/* 1478 80026078 10600022 */ beqz $v1, .L80026104 -/* 147C 8002607C 0080802D */ daddu $s0, $a0, $zero -/* 1480 80026080 24020001 */ addiu $v0, $zero, 1 -/* 1484 80026084 14620016 */ bne $v1, $v0, .L800260E0 -/* 1488 80026088 00000000 */ nop -/* 148C 8002608C 0C017CB4 */ jal nuGfxTaskAllEndWait -/* 1490 80026090 00000000 */ nop -/* 1494 80026094 16000012 */ bnez $s0, .L800260E0 -/* 1498 80026098 00000000 */ nop -/* 149C 8002609C 0C019A6C */ jal osViGetCurrentFramebuffer -/* 14A0 800260A0 00000000 */ nop -/* 14A4 800260A4 3C10800A */ lui $s0, 0x800a -/* 14A8 800260A8 2610A680 */ addiu $s0, $s0, -0x5980 -/* 14AC 800260AC 0200202D */ daddu $a0, $s0, $zero -/* 14B0 800260B0 AE020008 */ sw $v0, 8($s0) -/* 14B4 800260B4 AE020004 */ sw $v0, 4($s0) -/* 14B8 800260B8 AE020000 */ sw $v0, ($s0) -/* 14BC 800260BC 3C018007 */ lui $at, 0x8007 -/* 14C0 800260C0 AC223E04 */ sw $v0, 0x3e04($at) -/* 14C4 800260C4 0C017CBC */ jal nuGfxSetCfb -/* 14C8 800260C8 24050003 */ addiu $a1, $zero, 3 -/* 14CC 800260CC 8E040000 */ lw $a0, ($s0) -/* 14D0 800260D0 0C019C08 */ jal osViSwapBuffer -/* 14D4 800260D4 00000000 */ nop -/* 14D8 800260D8 24020002 */ addiu $v0, $zero, 2 -/* 14DC 800260DC AE220000 */ sw $v0, ($s1) -.L800260E0: -/* 14E0 800260E0 3C038007 */ lui $v1, 0x8007 -/* 14E4 800260E4 8C633E00 */ lw $v1, 0x3e00($v1) -/* 14E8 800260E8 24020002 */ addiu $v0, $zero, 2 -/* 14EC 800260EC 14620018 */ bne $v1, $v0, .L80026150 -/* 14F0 800260F0 00000000 */ nop -/* 14F4 800260F4 0C009859 */ jal func_80026164 -/* 14F8 800260F8 00000000 */ nop -/* 14FC 800260FC 08009854 */ j .L80026150 -/* 1500 80026100 00000000 */ nop -.L80026104: -/* 1504 80026104 3C038007 */ lui $v1, 0x8007 -/* 1508 80026108 24633E0A */ addiu $v1, $v1, 0x3e0a -/* 150C 8002610C 94620000 */ lhu $v0, ($v1) -/* 1510 80026110 38420001 */ xori $v0, $v0, 1 -/* 1514 80026114 1440000E */ bnez $v0, .L80026150 -/* 1518 80026118 A4620000 */ sh $v0, ($v1) -/* 151C 8002611C 0C0099D0 */ jal step_game_loop -/* 1520 80026120 00000000 */ nop -/* 1524 80026124 3C038007 */ lui $v1, 0x8007 -/* 1528 80026128 24633E08 */ addiu $v1, $v1, 0x3e08 -/* 152C 8002612C 24020001 */ addiu $v0, $zero, 1 -/* 1530 80026130 A4620000 */ sh $v0, ($v1) -/* 1534 80026134 2A020003 */ slti $v0, $s0, 3 -/* 1538 80026138 10400005 */ beqz $v0, .L80026150 -/* 153C 8002613C 00000000 */ nop -/* 1540 80026140 0C009A7B */ jal func_800269EC -/* 1544 80026144 A4600000 */ sh $zero, ($v1) -/* 1548 80026148 0C009AC2 */ jal gfx_draw_frame -/* 154C 8002614C 00000000 */ nop -.L80026150: -/* 1550 80026150 8FBF0018 */ lw $ra, 0x18($sp) -/* 1554 80026154 8FB10014 */ lw $s1, 0x14($sp) -/* 1558 80026158 8FB00010 */ lw $s0, 0x10($sp) -/* 155C 8002615C 03E00008 */ jr $ra -/* 1560 80026160 27BD0020 */ addiu $sp, $sp, 0x20 +/* 1458 80026058 00000000 */ nop diff --git a/asm/nonmatchings/code_1370_len_7d0/gfxRetrace_Callback.s b/asm/nonmatchings/code_1370_len_7d0/gfxRetrace_Callback.s new file mode 100644 index 0000000000..0c89158b8f --- /dev/null +++ b/asm/nonmatchings/code_1370_len_7d0/gfxRetrace_Callback.s @@ -0,0 +1,73 @@ +.set noat # allow manual use of $at +.set noreorder # don't insert nops after branches + +glabel gfxRetrace_Callback +/* 145C 8002605C 27BDFFE0 */ addiu $sp, $sp, -0x20 +/* 1460 80026060 AFB10014 */ sw $s1, 0x14($sp) +/* 1464 80026064 3C118007 */ lui $s1, 0x8007 +/* 1468 80026068 26313E00 */ addiu $s1, $s1, 0x3e00 +/* 146C 8002606C AFBF0018 */ sw $ra, 0x18($sp) +/* 1470 80026070 AFB00010 */ sw $s0, 0x10($sp) +/* 1474 80026074 8E230000 */ lw $v1, ($s1) +/* 1478 80026078 10600022 */ beqz $v1, .L80026104 +/* 147C 8002607C 0080802D */ daddu $s0, $a0, $zero +/* 1480 80026080 24020001 */ addiu $v0, $zero, 1 +/* 1484 80026084 14620016 */ bne $v1, $v0, .L800260E0 +/* 1488 80026088 00000000 */ nop +/* 148C 8002608C 0C017CB4 */ jal nuGfxTaskAllEndWait +/* 1490 80026090 00000000 */ nop +/* 1494 80026094 16000012 */ bnez $s0, .L800260E0 +/* 1498 80026098 00000000 */ nop +/* 149C 8002609C 0C019A6C */ jal osViGetCurrentFramebuffer +/* 14A0 800260A0 00000000 */ nop +/* 14A4 800260A4 3C10800A */ lui $s0, 0x800a +/* 14A8 800260A8 2610A680 */ addiu $s0, $s0, -0x5980 +/* 14AC 800260AC 0200202D */ daddu $a0, $s0, $zero +/* 14B0 800260B0 AE020008 */ sw $v0, 8($s0) +/* 14B4 800260B4 AE020004 */ sw $v0, 4($s0) +/* 14B8 800260B8 AE020000 */ sw $v0, ($s0) +/* 14BC 800260BC 3C018007 */ lui $at, 0x8007 +/* 14C0 800260C0 AC223E04 */ sw $v0, 0x3e04($at) +/* 14C4 800260C4 0C017CBC */ jal nuGfxSetCfb +/* 14C8 800260C8 24050003 */ addiu $a1, $zero, 3 +/* 14CC 800260CC 8E040000 */ lw $a0, ($s0) +/* 14D0 800260D0 0C019C08 */ jal osViSwapBuffer +/* 14D4 800260D4 00000000 */ nop +/* 14D8 800260D8 24020002 */ addiu $v0, $zero, 2 +/* 14DC 800260DC AE220000 */ sw $v0, ($s1) +.L800260E0: +/* 14E0 800260E0 3C038007 */ lui $v1, 0x8007 +/* 14E4 800260E4 8C633E00 */ lw $v1, 0x3e00($v1) +/* 14E8 800260E8 24020002 */ addiu $v0, $zero, 2 +/* 14EC 800260EC 14620018 */ bne $v1, $v0, .L80026150 +/* 14F0 800260F0 00000000 */ nop +/* 14F4 800260F4 0C009859 */ jal func_80026164 +/* 14F8 800260F8 00000000 */ nop +/* 14FC 800260FC 08009854 */ j .L80026150 +/* 1500 80026100 00000000 */ nop +.L80026104: +/* 1504 80026104 3C038007 */ lui $v1, 0x8007 +/* 1508 80026108 24633E0A */ addiu $v1, $v1, 0x3e0a +/* 150C 8002610C 94620000 */ lhu $v0, ($v1) +/* 1510 80026110 38420001 */ xori $v0, $v0, 1 +/* 1514 80026114 1440000E */ bnez $v0, .L80026150 +/* 1518 80026118 A4620000 */ sh $v0, ($v1) +/* 151C 8002611C 0C0099D0 */ jal step_game_loop +/* 1520 80026120 00000000 */ nop +/* 1524 80026124 3C038007 */ lui $v1, 0x8007 +/* 1528 80026128 24633E08 */ addiu $v1, $v1, 0x3e08 +/* 152C 8002612C 24020001 */ addiu $v0, $zero, 1 +/* 1530 80026130 A4620000 */ sh $v0, ($v1) +/* 1534 80026134 2A020003 */ slti $v0, $s0, 3 +/* 1538 80026138 10400005 */ beqz $v0, .L80026150 +/* 153C 8002613C 00000000 */ nop +/* 1540 80026140 0C009A7B */ jal func_800269EC +/* 1544 80026144 A4600000 */ sh $zero, ($v1) +/* 1548 80026148 0C009AC2 */ jal gfx_draw_frame +/* 154C 8002614C 00000000 */ nop +.L80026150: +/* 1550 80026150 8FBF0018 */ lw $ra, 0x18($sp) +/* 1554 80026154 8FB10014 */ lw $s1, 0x14($sp) +/* 1558 80026158 8FB00010 */ lw $s0, 0x10($sp) +/* 155C 8002615C 03E00008 */ jr $ra +/* 1560 80026160 27BD0020 */ addiu $sp, $sp, 0x20 diff --git a/asm/nonmatchings/code_6e40_len_500/render_curtains.s b/asm/nonmatchings/code_6e40_len_500/render_curtains.s index 93169e3a54..dcd30f0a70 100644 --- a/asm/nonmatchings/code_6e40_len_500/render_curtains.s +++ b/asm/nonmatchings/code_6e40_len_500/render_curtains.s @@ -6,8 +6,8 @@ glabel render_curtains /* 6E84 8002BA84 C420BA94 */ lwc1 $f0, -0x456c($at) /* 6E88 8002BA88 27BDFF78 */ addiu $sp, $sp, -0x88 /* 6E8C 8002BA8C AFB20068 */ sw $s2, 0x68($sp) -/* 6E90 8002BA90 3C12800A */ lui $s2, %hi(D_8009BA90) -/* 6E94 8002BA94 2652BA90 */ addiu $s2, $s2, %lo(D_8009BA90) +/* 6E90 8002BA90 3C12800A */ lui $s2, %hi(gCurtainScale) +/* 6E94 8002BA94 2652BA90 */ addiu $s2, $s2, %lo(gCurtainScale) /* 6E98 8002BA98 AFBF0078 */ sw $ra, 0x78($sp) /* 6E9C 8002BA9C AFB50074 */ sw $s5, 0x74($sp) /* 6EA0 8002BAA0 AFB40070 */ sw $s4, 0x70($sp) @@ -17,35 +17,35 @@ glabel render_curtains /* 6EB0 8002BAB0 F7B40080 */ sdc1 $f20, 0x80($sp) /* 6EB4 8002BAB4 C6440000 */ lwc1 $f4, ($s2) /* 6EB8 8002BAB8 46040032 */ c.eq.s $f0, $f4 -/* 6EBC 8002BABC 00000000 */ nop +/* 6EBC 8002BABC 00000000 */ nop /* 6EC0 8002BAC0 4501000B */ bc1t .L8002BAF0 -/* 6EC4 8002BAC4 00000000 */ nop +/* 6EC4 8002BAC4 00000000 */ nop /* 6EC8 8002BAC8 46040001 */ sub.s $f0, $f0, $f4 /* 6ECC 8002BACC 3C018009 */ lui $at, 0x8009 /* 6ED0 8002BAD0 D4227E00 */ ldc1 $f2, 0x7e00($at) /* 6ED4 8002BAD4 46000021 */ cvt.d.s $f0, $f0 /* 6ED8 8002BAD8 46220002 */ mul.d $f0, $f0, $f2 -/* 6EDC 8002BADC 00000000 */ nop +/* 6EDC 8002BADC 00000000 */ nop /* 6EE0 8002BAE0 460020A1 */ cvt.d.s $f2, $f4 /* 6EE4 8002BAE4 46201080 */ add.d $f2, $f2, $f0 /* 6EE8 8002BAE8 462010A0 */ cvt.s.d $f2, $f2 /* 6EEC 8002BAEC E6420000 */ swc1 $f2, ($s2) .L8002BAF0: -/* 6EF0 8002BAF0 3C13800A */ lui $s3, %hi(D_8009BA98) -/* 6EF4 8002BAF4 2673BA98 */ addiu $s3, $s3, %lo(D_8009BA98) +/* 6EF0 8002BAF0 3C13800A */ lui $s3, %hi(gCurtainFade) +/* 6EF4 8002BAF4 2673BA98 */ addiu $s3, $s3, %lo(gCurtainFade) /* 6EF8 8002BAF8 3C01800A */ lui $at, 0x800a /* 6EFC 8002BAFC C420BA9C */ lwc1 $f0, -0x4564($at) /* 6F00 8002BB00 C6640000 */ lwc1 $f4, ($s3) /* 6F04 8002BB04 46040032 */ c.eq.s $f0, $f4 -/* 6F08 8002BB08 00000000 */ nop +/* 6F08 8002BB08 00000000 */ nop /* 6F0C 8002BB0C 4501000B */ bc1t .L8002BB3C -/* 6F10 8002BB10 00000000 */ nop +/* 6F10 8002BB10 00000000 */ nop /* 6F14 8002BB14 46040001 */ sub.s $f0, $f0, $f4 /* 6F18 8002BB18 3C018009 */ lui $at, 0x8009 /* 6F1C 8002BB1C D4227E08 */ ldc1 $f2, 0x7e08($at) /* 6F20 8002BB20 46000021 */ cvt.d.s $f0, $f0 /* 6F24 8002BB24 46220002 */ mul.d $f0, $f0, $f2 -/* 6F28 8002BB28 00000000 */ nop +/* 6F28 8002BB28 00000000 */ nop /* 6F2C 8002BB2C 460020A1 */ cvt.d.s $f2, $f4 /* 6F30 8002BB30 46201080 */ add.d $f2, $f2, $f0 /* 6F34 8002BB34 462010A0 */ cvt.s.d $f2, $f2 @@ -56,7 +56,7 @@ glabel render_curtains /* 6F44 8002BB44 D4227E10 */ ldc1 $f2, 0x7e10($at) /* 6F48 8002BB48 46000021 */ cvt.d.s $f0, $f0 /* 6F4C 8002BB4C 4622003C */ c.lt.d $f0, $f2 -/* 6F50 8002BB50 00000000 */ nop +/* 6F50 8002BB50 00000000 */ nop /* 6F54 8002BB54 45000087 */ bc1f .L8002BD74 /* 6F58 8002BB58 3C03FF10 */ lui $v1, 0xff10 /* 6F5C 8002BB5C 3463013F */ ori $v1, $v1, 0x13f @@ -121,7 +121,7 @@ glabel render_curtains /* 7048 8002BC48 AC640000 */ sw $a0, ($v1) /* 704C 8002BC4C 46200120 */ cvt.s.d $f4, $f0 /* 7050 8002BC50 4614203C */ c.lt.s $f4, $f20 -/* 7054 8002BC54 00000000 */ nop +/* 7054 8002BC54 00000000 */ nop /* 7058 8002BC58 45000002 */ bc1f .L8002BC64 /* 705C 8002BC5C AC700004 */ sw $s0, 4($v1) /* 7060 8002BC60 4600A106 */ mov.s $f4, $f20 @@ -132,7 +132,7 @@ glabel render_curtains /* 7070 8002BC70 44050000 */ mfc1 $a1, $f0 /* 7074 8002BC74 46002021 */ cvt.d.s $f0, $f4 /* 7078 8002BC78 46220002 */ mul.d $f0, $f0, $f2 -/* 707C 8002BC7C 00000000 */ nop +/* 707C 8002BC7C 00000000 */ nop /* 7080 8002BC80 27A40020 */ addiu $a0, $sp, 0x20 /* 7084 8002BC84 3C01C3A0 */ lui $at, 0xc3a0 /* 7088 8002BC88 44811000 */ mtc1 $at, $f2 @@ -175,7 +175,7 @@ glabel render_curtains /* 711C 8002BD1C AE220000 */ sw $v0, ($s1) /* 7120 8002BD20 24020040 */ addiu $v0, $zero, 0x40 /* 7124 8002BD24 46001082 */ mul.s $f2, $f2, $f0 -/* 7128 8002BD28 00000000 */ nop +/* 7128 8002BD28 00000000 */ nop /* 712C 8002BD2C ACA20014 */ sw $v0, 0x14($a1) /* 7130 8002BD30 24A20020 */ addiu $v0, $a1, 0x20 /* 7134 8002BD34 ACA40010 */ sw $a0, 0x10($a1) @@ -185,7 +185,7 @@ glabel render_curtains /* 7144 8002BD44 ACA0001C */ sw $zero, 0x1c($a1) /* 7148 8002BD48 4600018D */ trunc.w.s $f6, $f0 /* 714C 8002BD4C 44023000 */ mfc1 $v0, $f6 -/* 7150 8002BD50 00000000 */ nop +/* 7150 8002BD50 00000000 */ nop /* 7154 8002BD54 304200FF */ andi $v0, $v0, 0xff /* 7158 8002BD58 00021E00 */ sll $v1, $v0, 0x18 /* 715C 8002BD5C 00022400 */ sll $a0, $v0, 0x10 @@ -195,12 +195,12 @@ glabel render_curtains /* 716C 8002BD6C 346300FF */ ori $v1, $v1, 0xff /* 7170 8002BD70 ACA30004 */ sw $v1, 4($a1) .L8002BD74: -/* 7174 8002BD74 3C02800A */ lui $v0, %hi(D_8009BAA0) -/* 7178 8002BD78 8C42BAA0 */ lw $v0, %lo(D_8009BAA0)($v0) +/* 7174 8002BD74 3C02800A */ lui $v0, %hi(gCurtainDrawCallback) +/* 7178 8002BD78 8C42BAA0 */ lw $v0, %lo(gCurtainDrawCallback)($v0) /* 717C 8002BD7C 10400003 */ beqz $v0, .L8002BD8C -/* 7180 8002BD80 00000000 */ nop +/* 7180 8002BD80 00000000 */ nop /* 7184 8002BD84 0040F809 */ jalr $v0 -/* 7188 8002BD88 00000000 */ nop +/* 7188 8002BD88 00000000 */ nop .L8002BD8C: /* 718C 8002BD8C 3C108007 */ lui $s0, %hi(gGameStatusPtr) /* 7190 8002BD90 2610419C */ addiu $s0, $s0, %lo(gGameStatusPtr) @@ -208,25 +208,25 @@ glabel render_curtains /* 7198 8002BD98 90420073 */ lbu $v0, 0x73($v0) /* 719C 8002BD9C 30420001 */ andi $v0, $v0, 1 /* 71A0 8002BDA0 14400044 */ bnez $v0, .L8002BEB4 -/* 71A4 8002BDA4 00000000 */ nop +/* 71A4 8002BDA4 00000000 */ nop /* 71A8 8002BDA8 0C00CD4A */ jal get_game_mode -/* 71AC 8002BDAC 00000000 */ nop +/* 71AC 8002BDAC 00000000 */ nop /* 71B0 8002BDB0 00021400 */ sll $v0, $v0, 0x10 /* 71B4 8002BDB4 00021403 */ sra $v0, $v0, 0x10 /* 71B8 8002BDB8 24030010 */ addiu $v1, $zero, 0x10 /* 71BC 8002BDBC 1043000C */ beq $v0, $v1, .L8002BDF0 -/* 71C0 8002BDC0 00000000 */ nop +/* 71C0 8002BDC0 00000000 */ nop /* 71C4 8002BDC4 0C00CD4A */ jal get_game_mode -/* 71C8 8002BDC8 00000000 */ nop +/* 71C8 8002BDC8 00000000 */ nop /* 71CC 8002BDCC 00021400 */ sll $v0, $v0, 0x10 /* 71D0 8002BDD0 00021403 */ sra $v0, $v0, 0x10 /* 71D4 8002BDD4 24030002 */ addiu $v1, $zero, 2 /* 71D8 8002BDD8 10430005 */ beq $v0, $v1, .L8002BDF0 -/* 71DC 8002BDDC 00000000 */ nop +/* 71DC 8002BDDC 00000000 */ nop /* 71E0 8002BDE0 8E020000 */ lw $v0, ($s0) /* 71E4 8002BDE4 80420071 */ lb $v0, 0x71($v0) /* 71E8 8002BDE8 10400032 */ beqz $v0, .L8002BEB4 -/* 71EC 8002BDEC 00000000 */ nop +/* 71EC 8002BDEC 00000000 */ nop .L8002BDF0: /* 71F0 8002BDF0 3C028007 */ lui $v0, %hi(gGameStatusPtr) /* 71F4 8002BDF4 8C42419C */ lw $v0, %lo(gGameStatusPtr)($v0) diff --git a/include/variables.h b/include/variables.h index 5290e33a19..523037696c 100644 --- a/include/variables.h +++ b/include/variables.h @@ -89,10 +89,21 @@ extern Trigger* gTriggerList1[64]; extern Trigger* gTriggerList2[64]; extern Trigger** gCurrentTriggerListPtr[64]; +// Map transition data. Should probably be a struct extern u16 gMapTransitionAlpha; -extern u16 D_800A0942; +extern s16 D_800A0942; extern s16 D_800A0944; - +extern s16 D_800A0954; +extern s16 D_800A0956; +extern s16 D_800A0958; +extern s16 D_800A095A; +extern u8 D_800A095B; +extern s16 D_800A095C; +extern u8 D_800A095D; +extern s16 D_800A095E; +extern u8 D_800A095F; +extern s32 D_800A0960; +extern s32 D_800A0964; extern s32 gGameState; extern s32 D_8009A650[1]; @@ -101,13 +112,6 @@ extern u16 D_8009A6A2; extern u16 D_8009A6A4; extern u16 D_8009A6A6; -// curtains -extern f32 D_8009BA90; -extern f32 D_8009BA94; // curtain scale goal -extern f32 D_8009BA98; -extern f32 D_8009BA9C; // curtain fade goal -extern s32 D_8009BAA0; // curtain draw callback - extern s16 gCurrentDoorSoundsSet; extern s32 D_800D9620; @@ -138,6 +142,9 @@ extern u32 gBattleMapFlags[MAX_MAPFLAGS]; extern s32 D_8009A5D8; +extern u8 D_800779B0; +extern u8 D_800A0963; + extern s32 mapScriptLibStart; extern s32 mapScriptLibEnd; extern s32 mapScriptLibVram; diff --git a/src/code_11a50_len_7a0.c b/src/code_11a50_len_7a0.c index b14218f0db..85ae72db81 100644 --- a/src/code_11a50_len_7a0.c +++ b/src/code_11a50_len_7a0.c @@ -1,6 +1,91 @@ -#include "common.h" +#include "code_11a50_len_7a0.h" +#ifdef NON_MATCHING +void begin_state_intro(void) { + s8 unk_A8; + + GAME_STATUS->loadMenuState = 0; + + set_curtain_scale_goal(1.0f); + set_curtain_fade_goal(0.3f); + + unk_A8 = GAME_STATUS->unk_A8; + switch (unk_A8) { + case 0: + intro_logos_set_fade_alpha(0); + + D_800A0954 = 0xFF; + D_800A0956 = 0x10; + D_800A0958 = 4; + D_800A0960 = 0; + D_800A095A = 0xD0; + D_800A095C = 0xD0; + D_800A095E = 0xD0; + D_800A0964 = 0; + + do { + GameStatus* gameStatus = GAME_STATUS; + + // hos_05 (Star Sanctuary) + gameStatus->areaID = 5; + gameStatus->mapID = 5; + gameStatus->entryID = 3; + } while (0); + + break; + case 1: + intro_logos_set_fade_alpha(0); + + D_800A0954 = 0; + D_800A0956 = 0xC; + D_800A0958 = 4; + D_800A0960 = unk_A8; + D_800A095A = 0; + D_800A095C = 0; + D_800A095E = 0; + D_800A0964 = 0; + + // FIXME: regalloc issues + do { + GameStatus* gameStatus = GAME_STATUS; + + // hos_04 (Outside the Sanctuary) + gameStatus->areaID = 5; + gameStatus->mapID = 4; + gameStatus->entryID = 4; + } while (0); + + break; + default: + intro_logos_set_fade_alpha(0); + intro_logos_set_fade_color(0xD0); + + { + GameStatus* gameStatus = GAME_STATUS; + u8* mystery = &D_800779B0; + + gameStatus->unk_A8 = -1; + + D_800A0956 = 6; + D_800A0958 = 6; + + ++*mystery; + if (*mystery >= 4) { + *mystery = 0; + } + + D_800A0964 = 3; + } + } + + func_80137DA4(D_800A0963, (f32)D_800A0954); + func_80137E10(1, D_800A095B, D_800A095D, D_800A095F); + + intro_logos_update_fade(); +} +#else INCLUDE_ASM(s32, "code_11a50_len_7a0", begin_state_intro); +#endif INCLUDE_ASM(s32, "code_11a50_len_7a0", step_intro); diff --git a/src/code_11a50_len_7a0.h b/src/code_11a50_len_7a0.h new file mode 100644 index 0000000000..77ffa27ad4 --- /dev/null +++ b/src/code_11a50_len_7a0.h @@ -0,0 +1,8 @@ +#ifndef _CODE_11A50_LEN_7A0_H_ +#define _CODE_11A50_LEN_7A0_H_ + +#include "common.h" +#include "code_ebd0_len_6a0.h" +#include "code_6e40_len_500.h" + +#endif diff --git a/src/code_1370_len_7d0.c b/src/code_1370_len_7d0.c index 42f1924ee7..25b09e2082 100644 --- a/src/code_1370_len_7d0.c +++ b/src/code_1370_len_7d0.c @@ -1,7 +1,48 @@ #include "common.h" +#include "nu/nusys.h" -INCLUDE_ASM(s32, "code_1370_len_7d0", boot_main); +void gfxRetrace_Callback(void); +void gfxPreNMI_Callback(void); + +#ifdef NON_MATCHING +// Control flow issue w/ PANIC +void boot_main(void) { + OSViMode* viMode; + if (osTvType == OS_TV_NTSC) { + viMode = &osViModeTable[56]; + } else if (osTvType == OS_TV_MPAL) { + viMode = &osViModeTable[57]; + } else { + PANIC(); + } + osViSetMode(viMode); + + osViSetSpecialFeatures(OS_VI_GAMMA_OFF | OS_VI_GAMMA_DITHER_OFF | OS_VI_DIVOT_ON | OS_VI_DITHER_FILTER_ON); + nuGfxDisplayOff(); + crash_create_monitor(); + func_80025C60(); + nuGfxInit(); + GAME_STATUS->contBitPattern = nuContInit(); + func_8002D160(); + func_802B2000(); + func_802B203C(); + nuGfxFuncSet(gfxRetrace_Callback); + nuGfxPreNMIFuncSet(gfxPreNMI_Callback); + { + // Required to match + s32* randSeed = &gRandSeed; + (*randSeed) += osGetCount(); + } + nuGfxDisplayOn(); + + while (TRUE) {} +} +#else +INCLUDE_ASM(void, "code_1370_len_7d0", boot_main, void); +#endif + +INCLUDE_ASM(void, "code_1370_len_7d0", gfxRetrace_Callback, void); INCLUDE_ASM(s32, "code_1370_len_7d0", func_80026164); -INCLUDE_ASM(s32, "code_1370_len_7d0", gfxPreNMI_Callback); +INCLUDE_ASM(void, "code_1370_len_7d0", gfxPreNMI_Callback, void); diff --git a/src/code_6e40_len_500.c b/src/code_6e40_len_500.c index 5aa122e62e..a6c1296f82 100644 --- a/src/code_6e40_len_500.c +++ b/src/code_6e40_len_500.c @@ -1,11 +1,11 @@ -#include "common.h" +#include "code_6e40_len_500.h" void initialize_curtains(void) { - D_8009BAA0 = 0; - D_8009BA90 = 2.0f; - D_8009BA94 = 2.0f; - D_8009BA98 = 0; - D_8009BA9C = 0; + gCurtainDrawCallback = NULL; + gCurtainScale = 2.0f; + gCurtainScaleGoal = 2.0f; + gCurtainFade = 0.0f; + gCurtainFadeGoal = 0.0f; } void update_curtains(void) { @@ -13,24 +13,24 @@ void update_curtains(void) { INCLUDE_ASM(s32, "code_6e40_len_500", render_curtains); -void set_curtain_scale_goal(f32 arg0) { - D_8009BA94 = arg0; +void set_curtain_scale_goal(f32 scale) { + gCurtainScaleGoal = scale; } -void set_curtain_scale(f32 arg0) { - D_8009BA94 = arg0; - D_8009BA90 = arg0; +void set_curtain_scale(f32 scale) { + gCurtainScaleGoal = scale; + gCurtainScale = scale; } -void set_curtain_draw_callback(s32 arg0) { - D_8009BAA0 = arg0; +void set_curtain_draw_callback(UNK_FUN_PTR(callback)) { + gCurtainDrawCallback = callback; } -void set_curtain_fade_goal(f32 arg0) { - D_8009BA9C = arg0; +void set_curtain_fade_goal(f32 fade) { + gCurtainFadeGoal = fade; } -void set_curtain_fade(f32 arg0) { - D_8009BA9C = arg0; - D_8009BA98 = arg0; +void set_curtain_fade(f32 fade) { + gCurtainFadeGoal = fade; + gCurtainFade = fade; } diff --git a/src/code_6e40_len_500.h b/src/code_6e40_len_500.h new file mode 100644 index 0000000000..e3c3281073 --- /dev/null +++ b/src/code_6e40_len_500.h @@ -0,0 +1,21 @@ +#ifndef _CODE_6E40_LEN_500_H_ +#define _CODE_6E40_LEN_500_H_ + +#include "common.h" + +extern f32 gCurtainScale; +extern f32 gCurtainScaleGoal; +extern f32 gCurtainFade; +extern f32 gCurtainFadeGoal; +extern UNK_FUN_PTR(gCurtainDrawCallback); + +void initialize_curtains(void); +void update_curtains(void); +// render_curtains +void set_curtain_scale_goal(f32 scale); +void set_curtain_scale(f32 scale); +void set_curtain_draw_callback(UNK_FUN_PTR(callback)); +void set_curtain_fade_goal(f32 fade); +void set_curtain_fade(f32 fade); + +#endif diff --git a/src/code_ebd0_len_6a0.c b/src/code_ebd0_len_6a0.c index 0d491e9182..e1f40e50e7 100644 --- a/src/code_ebd0_len_6a0.c +++ b/src/code_ebd0_len_6a0.c @@ -1,24 +1,24 @@ -#include "common.h" +#include "code_ebd0_len_6a0.h" -void intro_logos_set_fade_alpha(s16 new_alpha) { +void intro_logos_set_fade_alpha(s16 alpha) { GameStatus* gameStatus = GAME_STATUS; - gameStatus->bootAlpha = new_alpha; + gameStatus->bootAlpha = alpha; } -void intro_logos_set_fade_color(s16 arg0) { +void intro_logos_set_fade_color(s16 color) { GameStatus* gameStatus = GAME_STATUS; - gameStatus->bootRed = arg0; - gameStatus->bootGreen = arg0; - gameStatus->bootBlue = arg0; + gameStatus->bootRed = color; + gameStatus->bootGreen = color; + gameStatus->bootBlue = color; } -s16 intro_logos_fade_in(subtract_val) { +s16 intro_logos_fade_in(s16 subtractAlpha) { GameStatus* gameStatus = GAME_STATUS; if (gameStatus->bootAlpha != 0) { - gameStatus->bootAlpha -= subtract_val; + gameStatus->bootAlpha -= subtractAlpha; if (gameStatus->bootAlpha << 16 < 0) { gameStatus->bootAlpha = 0; } @@ -28,11 +28,11 @@ s16 intro_logos_fade_in(subtract_val) { return 0; } -s16 intro_logos_fade_out(add_val) { +s16 intro_logos_fade_out(s16 addAlpha) { GameStatus* gameStatus = GAME_STATUS; if (gameStatus->bootAlpha != 0xFF) { - gameStatus->bootAlpha += add_val; + gameStatus->bootAlpha += addAlpha; if ((gameStatus->bootAlpha > 0xFF)) { gameStatus->bootAlpha = 0xFF; } diff --git a/src/code_ebd0_len_6a0.h b/src/code_ebd0_len_6a0.h new file mode 100644 index 0000000000..cde379c7fc --- /dev/null +++ b/src/code_ebd0_len_6a0.h @@ -0,0 +1,12 @@ +#ifndef _CODE_EBD0_LEN_6A0_H_ +#define _CODE_EBD0_LEN_6A0_H_ + +#include "common.h" + +void intro_logos_set_fade_alpha(s16 alpha); +void intro_logos_set_fade_color(s16 color); +s16 intro_logos_fade_in(s16 subtractAlpha); +s16 intro_logos_fade_out(s16 addAlpha); +void intro_logos_update_fade(void); + +#endif diff --git a/undefined_syms.txt b/undefined_syms.txt index 26d4c827af..b52d37138f 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -29,13 +29,27 @@ gWorldMapFlags = 0x802DBC70; gBattleMapFlags = 0x802DBD34; gMapTransitionAlpha = 0x800A0940; +D_800A0940 = 0x800A0940; +D_800A0942 = 0x800A0942; +D_800A0944 = 0x800A0944; +D_800A0954 = 0x800A0954; +D_800A0956 = 0x800A0956; +D_800A0958 = 0x800A0958; +D_800A095A = 0x800A095A; +D_800A095B = 0x800A095B; +D_800A095C = 0x800A095C; +D_800A095D = 0x800A095D; +D_800A095E = 0x800A095E; +D_800A095F = 0x800A095D; +D_800A0960 = 0x800A0960; +D_800A0963 = 0x800A0963; +D_800A0964 = 0x800A0964; + D_800E92D8 = 0x800E92D8; D_80147474 = 0x80147474; D_80109270 = 0x80109270; D_80108558 = 0x80108558; -D_800A0940 = 0x800A0940; -D_800A0942 = 0x800A0942; -D_800A0944 = 0x800A0944; +D_800779B0 = 0x800779B0; D_8010CD10 = 0x8010CD10; D_8010CD12 = 0x8010CD12; @@ -95,11 +109,11 @@ D_8009A6A2 = 0x8009A6A2; D_8009A6A4 = 0x8009A6A4; D_8009A6A6 = 0x8009A6A6; -D_8009BA90 = 0x8009BA90; -D_8009BA94 = 0x8009BA94; -D_8009BA98 = 0x8009BA98; -D_8009BA9C = 0x8009BA9C; -D_8009BAA0 = 0x8009BAA0; +gCurtainScale = 0x8009BA90; +gCurtainScaleGoal = 0x8009BA94; +gCurtainFade = 0x8009BA98; +gCurtainFadeGoal = 0x8009BA9C; +gCurtainDrawCallback = 0x8009BAA0; D_800A0900 = 0x800A0900; nuScStack = 0x800A65D0;