From 669ea9edb15eac1e022154ced728b41446b12fa4 Mon Sep 17 00:00:00 2001 From: MegaMech Date: Tue, 23 Apr 2024 10:32:34 -0600 Subject: [PATCH 1/9] Update code_800AF9B0.c (#626) --- src/code_800AF9B0.c | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/src/code_800AF9B0.c b/src/code_800AF9B0.c index 9f76a1ae2..d2d10ad70 100644 --- a/src/code_800AF9B0.c +++ b/src/code_800AF9B0.c @@ -128,12 +128,11 @@ GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800AFC54.s") void func_800AFE00(Vtx *arg0, s16 (*arg1)[3], s32 arg2, s32 arg3); #ifdef NON_MATCHING // guessing on the Vtx kind again -void func_800AFE00(Vtx *arg0, s16 (*arg1)[3], s32 arg2, s32 arg3) { +void func_800AFE00(Vtx *arg0, Vec3s *arg1, s32 arg2, s32 arg3) { s32 idx1; // v0 s32 idx2; // v0 - s32 i; + s32 i, j; s16 sp14[6]; - Vtx *sec, *third, *fourth; if (arg2 == 0) { idx1 = 0; @@ -147,34 +146,18 @@ void func_800AFE00(Vtx *arg0, s16 (*arg1)[3], s32 arg2, s32 arg3) { idx2 = arg2 + 1; } - for (i = 0; i != -7; i++) { + for (i = 0; i != 3; i++) { sp14[i + 0] = (arg1[arg2][i] + arg1[idx1][i]) / 2; sp14[i + 3] = (arg1[arg2][i] + arg1[idx2][i - 1]) / 2; - // L800AFEB4 } - - sec = arg0 + 1; - third = arg0 + 2; - fourth = arg0 + 3; - - for(i = 0; i != 480; i += 3 * sizeof(Vtx)) { - (arg0 + i)->v.cn[0] = sp14[0]; - (arg0 + i)->v.cn[1] = sp14[1]; - (arg0 + i)->v.cn[2] = sp14[2]; - (sec + i)->v.cn[0] = sp14[3]; - (sec + i)->v.cn[1] = sp14[4]; - (sec + i)->v.cn[2] = sp14[5]; - (third + i)->v.cn[0] = sp14[0]; - (third + i)->v.cn[1] = sp14[1]; - (third + i)->v.cn[2] = sp14[2]; - (fourth + i)->v.cn[0] = sp14[3]; - (fourth + i)->v.cn[1] = sp14[4]; - (fourth + i)->v.cn[2] = sp14[5]; - - // i += 3 * sizeof(Vtx); - i++; - i--; + for (i = 0; i < 30; i += 4) { + for (j = 0; j < 4; j++) { + s16 *v = &sp14[(j&1)*3]; + (arg0[i+j]).v.cn[0] = v[0]; + (arg0[i+j]).v.cn[1] = v[1]; + (arg0[i+j]).v.cn[2] = v[2]; + } } } #else From 911c4ee956d8c05d20bd811db640f86c051e2421 Mon Sep 17 00:00:00 2001 From: MegaMech Date: Tue, 23 Apr 2024 11:36:24 -0600 Subject: [PATCH 2/9] Match funcs (#627) * Match funcs --- .../code_80091750/func_80097AE4.s | 227 --------- .../code_80091750/func_80097E58.s | 467 ------------------ src/code_80091750.c | 96 ++-- src/code_80091750.h | 2 +- 4 files changed, 45 insertions(+), 747 deletions(-) delete mode 100644 asm/non_matchings/code_80091750/func_80097AE4.s delete mode 100644 asm/non_matchings/code_80091750/func_80097E58.s diff --git a/asm/non_matchings/code_80091750/func_80097AE4.s b/asm/non_matchings/code_80091750/func_80097AE4.s deleted file mode 100644 index 7aaf5afd2..000000000 --- a/asm/non_matchings/code_80091750/func_80097AE4.s +++ /dev/null @@ -1,227 +0,0 @@ -glabel func_80097AE4 -/* 0986E4 80097AE4 27BDFFC0 */ addiu $sp, $sp, -0x40 -/* 0986E8 80097AE8 AFB30014 */ sw $s3, 0x14($sp) -/* 0986EC 80097AEC 8FB30054 */ lw $s3, 0x54($sp) -/* 0986F0 80097AF0 AFB20010 */ sw $s2, 0x10($sp) -/* 0986F4 80097AF4 AFB00008 */ sw $s0, 8($sp) -/* 0986F8 80097AF8 AFA50044 */ sw $a1, 0x44($sp) -/* 0986FC 80097AFC 00057600 */ sll $t6, $a1, 0x18 -/* 098700 80097B00 2A610020 */ slti $at, $s3, 0x20 -/* 098704 80097B04 000E2E03 */ sra $a1, $t6, 0x18 -/* 098708 80097B08 00C08025 */ move $s0, $a2 -/* 09870C 80097B0C 00E09025 */ move $s2, $a3 -/* 098710 80097B10 AFBF002C */ sw $ra, 0x2c($sp) -/* 098714 80097B14 AFBE0028 */ sw $fp, 0x28($sp) -/* 098718 80097B18 AFB70024 */ sw $s7, 0x24($sp) -/* 09871C 80097B1C AFB60020 */ sw $s6, 0x20($sp) -/* 098720 80097B20 AFB5001C */ sw $s5, 0x1c($sp) -/* 098724 80097B24 AFB40018 */ sw $s4, 0x18($sp) -/* 098728 80097B28 14200003 */ bnez $at, .L80097B38 -/* 09872C 80097B2C AFB1000C */ sw $s1, 0xc($sp) -/* 098730 80097B30 100000BD */ b .L80097E28 -/* 098734 80097B34 00801025 */ move $v0, $a0 -.L80097B38: -/* 098738 80097B38 30A20007 */ andi $v0, $a1, 7 -/* 09873C 80097B3C 0002C540 */ sll $t8, $v0, 0x15 -/* 098740 80097B40 3C01FD00 */ lui $at, 0xfd00 -/* 098744 80097B44 0301A025 */ or $s4, $t8, $at -/* 098748 80097B48 3C010010 */ lui $at, 0x10 -/* 09874C 80097B4C 0281C825 */ or $t9, $s4, $at -/* 098750 80097B50 3C01F500 */ lui $at, 0xf500 -/* 098754 80097B54 03016825 */ or $t5, $t8, $at -/* 098758 80097B58 3C010010 */ lui $at, 0x10 -/* 09875C 80097B5C 3734003F */ ori $s4, $t9, 0x3f -/* 098760 80097B60 24190020 */ li $t9, 32 -/* 098764 80097B64 01A17825 */ or $t7, $t5, $at -/* 098768 80097B68 03001025 */ move $v0, $t8 -/* 09876C 80097B6C 35F81200 */ ori $t8, $t7, 0x1200 -/* 098770 80097B70 03337023 */ subu $t6, $t9, $s3 -/* 098774 80097B74 340F8000 */ li $t7, 32768 -/* 098778 80097B78 01EE001A */ div $zero, $t7, $t6 -/* 09877C 80097B7C 0000A812 */ mflo $s5 -/* 098780 80097B80 03006825 */ move $t5, $t8 -/* 098784 80097B84 32B8FFFF */ andi $t8, $s5, 0xffff -/* 098788 80097B88 0018CC00 */ sll $t9, $t8, 0x10 -/* 09878C 80097B8C 3C170701 */ lui $s7, (0x07014050 >> 16) # lui $s7, 0x701 -/* 098790 80097B90 AFB00034 */ sw $s0, 0x34($sp) -/* 098794 80097B94 36F74050 */ ori $s7, (0x07014050 & 0xFFFF) # ori $s7, $s7, 0x4050 -/* 098798 80097B98 00003025 */ move $a2, $zero -/* 09879C 80097B9C 15C00002 */ bnez $t6, .L80097BA8 -/* 0987A0 80097BA0 00000000 */ nop -/* 0987A4 80097BA4 0007000D */ break 7 -.L80097BA8: -/* 0987A8 80097BA8 2401FFFF */ li $at, -1 -/* 0987AC 80097BAC 15C10004 */ bne $t6, $at, .L80097BC0 -/* 0987B0 80097BB0 3C018000 */ lui $at, 0x8000 -/* 0987B4 80097BB4 15E10002 */ bne $t7, $at, .L80097BC0 -/* 0987B8 80097BB8 00000000 */ nop -/* 0987BC 80097BBC 0006000D */ break 6 -.L80097BC0: -/* 0987C0 80097BC0 372F0400 */ ori $t7, $t9, 0x400 -/* 0987C4 80097BC4 01E0A825 */ move $s5, $t7 -/* 0987C8 80097BC8 3C1FE700 */ lui $ra, 0xe700 -/* 0987CC 80097BCC 3C1EE600 */ lui $fp, 0xe600 -/* 0987D0 80097BD0 8FB60050 */ lw $s6, 0x50($sp) -.L80097BD4: -/* 0987D4 80097BD4 00801025 */ move $v0, $a0 -/* 0987D8 80097BD8 24840008 */ addiu $a0, $a0, 8 -/* 0987DC 80097BDC 00801825 */ move $v1, $a0 -/* 0987E0 80097BE0 AC540000 */ sw $s4, ($v0) -/* 0987E4 80097BE4 AC560004 */ sw $s6, 4($v0) -/* 0987E8 80097BE8 24840008 */ addiu $a0, $a0, 8 -/* 0987EC 80097BEC 00802825 */ move $a1, $a0 -/* 0987F0 80097BF0 00063880 */ sll $a3, $a2, 2 -/* 0987F4 80097BF4 30EE0FFF */ andi $t6, $a3, 0xfff -/* 0987F8 80097BF8 24840008 */ addiu $a0, $a0, 8 -/* 0987FC 80097BFC AC770004 */ sw $s7, 4($v1) -/* 098800 80097C00 AC6D0000 */ sw $t5, ($v1) -/* 098804 80097C04 3C01F400 */ lui $at, 0xf400 -/* 098808 80097C08 24D10020 */ addiu $s1, $a2, 0x20 -/* 09880C 80097C0C 00114080 */ sll $t0, $s1, 2 -/* 098810 80097C10 01C1C025 */ or $t8, $t6, $at -/* 098814 80097C14 00804825 */ move $t1, $a0 -/* 098818 80097C18 3C010708 */ lui $at, 0x708 -/* 09881C 80097C1C 31190FFF */ andi $t9, $t0, 0xfff -/* 098820 80097C20 ACA00004 */ sw $zero, 4($a1) -/* 098824 80097C24 ACBE0000 */ sw $fp, ($a1) -/* 098828 80097C28 03217825 */ or $t7, $t9, $at -/* 09882C 80097C2C 24840008 */ addiu $a0, $a0, 8 -/* 098830 80097C30 00801025 */ move $v0, $a0 -/* 098834 80097C34 AD2F0004 */ sw $t7, 4($t1) -/* 098838 80097C38 AD380000 */ sw $t8, ($t1) -/* 09883C 80097C3C 24840008 */ addiu $a0, $a0, 8 -/* 098840 80097C40 01C03825 */ move $a3, $t6 -/* 098844 80097C44 3C0E0001 */ lui $t6, (0x00014050 >> 16) # lui $t6, 1 -/* 098848 80097C48 00801825 */ move $v1, $a0 -/* 09884C 80097C4C 35CE4050 */ ori $t6, (0x00014050 & 0xFFFF) # ori $t6, $t6, 0x4050 -/* 098850 80097C50 AC400004 */ sw $zero, 4($v0) -/* 098854 80097C54 AC5F0000 */ sw $ra, ($v0) -/* 098858 80097C58 3C01F200 */ lui $at, 0xf200 -/* 09885C 80097C5C 00E1C025 */ or $t8, $a3, $at -/* 098860 80097C60 AC6E0004 */ sw $t6, 4($v1) -/* 098864 80097C64 3C010008 */ lui $at, 8 -/* 098868 80097C68 AC6D0000 */ sw $t5, ($v1) -/* 09886C 80097C6C 24840008 */ addiu $a0, $a0, 8 -/* 098870 80097C70 03204025 */ move $t0, $t9 -/* 098874 80097C74 0321C825 */ or $t9, $t9, $at -/* 098878 80097C78 00802825 */ move $a1, $a0 -/* 09887C 80097C7C 26030020 */ addiu $v1, $s0, 0x20 -/* 098880 80097C80 26490020 */ addiu $t1, $s2, 0x20 -/* 098884 80097C84 ACB80000 */ sw $t8, ($a1) -/* 098888 80097C88 00095080 */ sll $t2, $t1, 2 -/* 09888C 80097C8C 00037080 */ sll $t6, $v1, 2 -/* 098890 80097C90 ACB90004 */ sw $t9, 4($a1) -/* 098894 80097C94 31D80FFF */ andi $t8, $t6, 0xfff -/* 098898 80097C98 314F0FFF */ andi $t7, $t2, 0xfff -/* 09889C 80097C9C 01E05025 */ move $t2, $t7 -/* 0988A0 80097CA0 0018CB00 */ sll $t9, $t8, 0xc -/* 0988A4 80097CA4 3C01E400 */ lui $at, 0xe400 -/* 0988A8 80097CA8 03217825 */ or $t7, $t9, $at -/* 0988AC 80097CAC 24840008 */ addiu $a0, $a0, 8 -/* 0988B0 80097CB0 01EA7025 */ or $t6, $t7, $t2 -/* 0988B4 80097CB4 00801025 */ move $v0, $a0 -/* 0988B8 80097CB8 0213C821 */ addu $t9, $s0, $s3 -/* 0988BC 80097CBC 00125880 */ sll $t3, $s2, 2 -/* 0988C0 80097CC0 31780FFF */ andi $t8, $t3, 0xfff -/* 0988C4 80097CC4 00197880 */ sll $t7, $t9, 2 -/* 0988C8 80097CC8 AC4E0000 */ sw $t6, ($v0) -/* 0988CC 80097CCC 31EE0FFF */ andi $t6, $t7, 0xfff -/* 0988D0 80097CD0 03005825 */ move $t3, $t8 -/* 0988D4 80097CD4 000EC300 */ sll $t8, $t6, 0xc -/* 0988D8 80097CD8 030BC825 */ or $t9, $t8, $t3 -/* 0988DC 80097CDC 24840008 */ addiu $a0, $a0, 8 -/* 0988E0 80097CE0 00802825 */ move $a1, $a0 -/* 0988E4 80097CE4 AC590004 */ sw $t9, 4($v0) -/* 0988E8 80097CE8 24840008 */ addiu $a0, $a0, 8 -/* 0988EC 80097CEC 00803025 */ move $a2, $a0 -/* 0988F0 80097CF0 3C0FB300 */ lui $t7, 0xb300 -/* 0988F4 80097CF4 ACAF0000 */ sw $t7, ($a1) -/* 0988F8 80097CF8 24840008 */ addiu $a0, $a0, 8 -/* 0988FC 80097CFC ACA00004 */ sw $zero, 4($a1) -/* 098900 80097D00 3C0EB200 */ lui $t6, 0xb200 -/* 098904 80097D04 00806025 */ move $t4, $a0 -/* 098908 80097D08 ACCE0000 */ sw $t6, ($a2) -/* 09890C 80097D0C ACD50004 */ sw $s5, 4($a2) -/* 098910 80097D10 24840008 */ addiu $a0, $a0, 8 -/* 098914 80097D14 00801025 */ move $v0, $a0 -/* 098918 80097D18 AD960004 */ sw $s6, 4($t4) -/* 09891C 80097D1C AD940000 */ sw $s4, ($t4) -/* 098920 80097D20 00608025 */ move $s0, $v1 -/* 098924 80097D24 24840008 */ addiu $a0, $a0, 8 -/* 098928 80097D28 00801825 */ move $v1, $a0 -/* 09892C 80097D2C AC570004 */ sw $s7, 4($v0) -/* 098930 80097D30 AC4D0000 */ sw $t5, ($v0) -/* 098934 80097D34 24840008 */ addiu $a0, $a0, 8 -/* 098938 80097D38 3C01F408 */ lui $at, 0xf408 -/* 09893C 80097D3C 00E1C025 */ or $t8, $a3, $at -/* 098940 80097D40 00803025 */ move $a2, $a0 -/* 098944 80097D44 3C010710 */ lui $at, 0x710 -/* 098948 80097D48 AC600004 */ sw $zero, 4($v1) -/* 09894C 80097D4C AC7E0000 */ sw $fp, ($v1) -/* 098950 80097D50 0101C825 */ or $t9, $t0, $at -/* 098954 80097D54 24840008 */ addiu $a0, $a0, 8 -/* 098958 80097D58 00801025 */ move $v0, $a0 -/* 09895C 80097D5C ACD90004 */ sw $t9, 4($a2) -/* 098960 80097D60 ACD80000 */ sw $t8, ($a2) -/* 098964 80097D64 24840008 */ addiu $a0, $a0, 8 -/* 098968 80097D68 00801825 */ move $v1, $a0 -/* 09896C 80097D6C 3C0F0001 */ lui $t7, (0x00014050 >> 16) # lui $t7, 1 -/* 098970 80097D70 35EF4050 */ ori $t7, (0x00014050 & 0xFFFF) # ori $t7, $t7, 0x4050 -/* 098974 80097D74 AC400004 */ sw $zero, 4($v0) -/* 098978 80097D78 AC5F0000 */ sw $ra, ($v0) -/* 09897C 80097D7C 3C01F208 */ lui $at, 0xf208 -/* 098980 80097D80 00E17025 */ or $t6, $a3, $at -/* 098984 80097D84 AC6F0004 */ sw $t7, 4($v1) -/* 098988 80097D88 24840008 */ addiu $a0, $a0, 8 -/* 09898C 80097D8C 00802825 */ move $a1, $a0 -/* 098990 80097D90 3C010010 */ lui $at, 0x10 -/* 098994 80097D94 AC6D0000 */ sw $t5, ($v1) -/* 098998 80097D98 0213C823 */ subu $t9, $s0, $s3 -/* 09899C 80097D9C ACAE0000 */ sw $t6, ($a1) -/* 0989A0 80097DA0 0101C025 */ or $t8, $t0, $at -/* 0989A4 80097DA4 272F0020 */ addiu $t7, $t9, 0x20 -/* 0989A8 80097DA8 ACB80004 */ sw $t8, 4($a1) -/* 0989AC 80097DAC 000F7080 */ sll $t6, $t7, 2 -/* 0989B0 80097DB0 31D80FFF */ andi $t8, $t6, 0xfff -/* 0989B4 80097DB4 0018CB00 */ sll $t9, $t8, 0xc -/* 0989B8 80097DB8 3C01E400 */ lui $at, 0xe400 -/* 0989BC 80097DBC 24840008 */ addiu $a0, $a0, 8 -/* 0989C0 80097DC0 03217825 */ or $t7, $t9, $at -/* 0989C4 80097DC4 01EA7025 */ or $t6, $t7, $t2 -/* 0989C8 80097DC8 00801025 */ move $v0, $a0 -/* 0989CC 80097DCC 0010C080 */ sll $t8, $s0, 2 -/* 0989D0 80097DD0 33190FFF */ andi $t9, $t8, 0xfff -/* 0989D4 80097DD4 00197B00 */ sll $t7, $t9, 0xc -/* 0989D8 80097DD8 AC4E0000 */ sw $t6, ($v0) -/* 0989DC 80097DDC 24840008 */ addiu $a0, $a0, 8 -/* 0989E0 80097DE0 00801825 */ move $v1, $a0 -/* 0989E4 80097DE4 01EB7025 */ or $t6, $t7, $t3 -/* 0989E8 80097DE8 AC4E0004 */ sw $t6, 4($v0) -/* 0989EC 80097DEC 24840008 */ addiu $a0, $a0, 8 -/* 0989F0 80097DF0 3C18B300 */ lui $t8, 0xb300 -/* 0989F4 80097DF4 AC780000 */ sw $t8, ($v1) -/* 0989F8 80097DF8 00802825 */ move $a1, $a0 -/* 0989FC 80097DFC AC600004 */ sw $zero, 4($v1) -/* 098A00 80097E00 3C19B200 */ lui $t9, 0xb200 -/* 098A04 80097E04 24010040 */ li $at, 64 -/* 098A08 80097E08 ACB90000 */ sw $t9, ($a1) -/* 098A0C 80097E0C ACB50004 */ sw $s5, 4($a1) -/* 098A10 80097E10 02203025 */ move $a2, $s1 -/* 098A14 80097E14 24840008 */ addiu $a0, $a0, 8 -/* 098A18 80097E18 8FB00034 */ lw $s0, 0x34($sp) -/* 098A1C 80097E1C 1621FF6D */ bne $s1, $at, .L80097BD4 -/* 098A20 80097E20 01209025 */ move $s2, $t1 -/* 098A24 80097E24 00801025 */ move $v0, $a0 -.L80097E28: -/* 098A28 80097E28 8FBF002C */ lw $ra, 0x2c($sp) -/* 098A2C 80097E2C 8FB00008 */ lw $s0, 8($sp) -/* 098A30 80097E30 8FB1000C */ lw $s1, 0xc($sp) -/* 098A34 80097E34 8FB20010 */ lw $s2, 0x10($sp) -/* 098A38 80097E38 8FB30014 */ lw $s3, 0x14($sp) -/* 098A3C 80097E3C 8FB40018 */ lw $s4, 0x18($sp) -/* 098A40 80097E40 8FB5001C */ lw $s5, 0x1c($sp) -/* 098A44 80097E44 8FB60020 */ lw $s6, 0x20($sp) -/* 098A48 80097E48 8FB70024 */ lw $s7, 0x24($sp) -/* 098A4C 80097E4C 8FBE0028 */ lw $fp, 0x28($sp) -/* 098A50 80097E50 03E00008 */ jr $ra -/* 098A54 80097E54 27BD0040 */ addiu $sp, $sp, 0x40 diff --git a/asm/non_matchings/code_80091750/func_80097E58.s b/asm/non_matchings/code_80091750/func_80097E58.s deleted file mode 100644 index 3cac9a60d..000000000 --- a/asm/non_matchings/code_80091750/func_80097E58.s +++ /dev/null @@ -1,467 +0,0 @@ -glabel func_80097E58 -/* 098A58 80097E58 27BDFF08 */ addiu $sp, $sp, -0xf8 -/* 098A5C 80097E5C 8FAE0124 */ lw $t6, 0x124($sp) -/* 098A60 80097E60 AFBF002C */ sw $ra, 0x2c($sp) -/* 098A64 80097E64 AFBE0028 */ sw $fp, 0x28($sp) -/* 098A68 80097E68 29C10020 */ slti $at, $t6, 0x20 -/* 098A6C 80097E6C AFB70024 */ sw $s7, 0x24($sp) -/* 098A70 80097E70 AFB60020 */ sw $s6, 0x20($sp) -/* 098A74 80097E74 AFB5001C */ sw $s5, 0x1c($sp) -/* 098A78 80097E78 AFB40018 */ sw $s4, 0x18($sp) -/* 098A7C 80097E7C AFB30014 */ sw $s3, 0x14($sp) -/* 098A80 80097E80 AFB20010 */ sw $s2, 0x10($sp) -/* 098A84 80097E84 AFB1000C */ sw $s1, 0xc($sp) -/* 098A88 80097E88 AFB00008 */ sw $s0, 8($sp) -/* 098A8C 80097E8C AFA500FC */ sw $a1, 0xfc($sp) -/* 098A90 80097E90 14200003 */ bnez $at, .L80097EA0 -/* 098A94 80097E94 AFA60100 */ sw $a2, 0x100($sp) -/* 098A98 80097E98 100001A3 */ b .L80098528 -/* 098A9C 80097E9C 00801025 */ move $v0, $a0 -.L80097EA0: -/* 098AA0 80097EA0 8FA3011C */ lw $v1, 0x11c($sp) -/* 098AA4 80097EA4 8FA5010C */ lw $a1, 0x10c($sp) -/* 098AA8 80097EA8 8FB40110 */ lw $s4, 0x110($sp) -/* 098AAC 80097EAC 00034042 */ srl $t0, $v1, 1 -/* 098AB0 80097EB0 00687823 */ subu $t7, $v1, $t0 -/* 098AB4 80097EB4 00E5082B */ sltu $at, $a3, $a1 -/* 098AB8 80097EB8 AFAF0080 */ sw $t7, 0x80($sp) -/* 098ABC 80097EBC AFAF00DC */ sw $t7, 0xdc($sp) -/* 098AC0 80097EC0 00E06025 */ move $t4, $a3 -/* 098AC4 80097EC4 10200197 */ beqz $at, .L80098524 -/* 098AC8 80097EC8 AFB400EC */ sw $s4, 0xec($sp) -.L80097ECC: -/* 098ACC 80097ECC 8FA5010C */ lw $a1, 0x10c($sp) -/* 098AD0 80097ED0 25990020 */ addiu $t9, $t4, 0x20 -/* 098AD4 80097ED4 8FAF0124 */ lw $t7, 0x124($sp) -/* 098AD8 80097ED8 00B9082B */ sltu $at, $a1, $t9 -/* 098ADC 80097EDC 1020007C */ beqz $at, .L800980D0 -/* 098AE0 80097EE0 240E0020 */ li $t6, 32 -/* 098AE4 80097EE4 00AC1023 */ subu $v0, $a1, $t4 -/* 098AE8 80097EE8 1040018E */ beqz $v0, .L80098524 -/* 098AEC 80097EEC 00409025 */ move $s2, $v0 -/* 098AF0 80097EF0 83A900FF */ lb $t1, 0xff($sp) -/* 098AF4 80097EF4 8FAE0124 */ lw $t6, 0x124($sp) -/* 098AF8 80097EF8 240F0020 */ li $t7, 32 -/* 098AFC 80097EFC 31380007 */ andi $t8, $t1, 7 -/* 098B00 80097F00 0018CD40 */ sll $t9, $t8, 0x15 -/* 098B04 80097F04 3C01FD00 */ lui $at, 0xfd00 -/* 098B08 80097F08 01EE1823 */ subu $v1, $t7, $t6 -/* 098B0C 80097F0C 03217825 */ or $t7, $t9, $at -/* 098B10 80097F10 03204825 */ move $t1, $t9 -/* 098B14 80097F14 8FB9011C */ lw $t9, 0x11c($sp) -/* 098B18 80097F18 3C010010 */ lui $at, 0x10 -/* 098B1C 80097F1C 01E1C025 */ or $t8, $t7, $at -/* 098B20 80097F20 AFAE0030 */ sw $t6, 0x30($sp) -/* 098B24 80097F24 272FFFFF */ addiu $t7, $t9, -1 -/* 098B28 80097F28 31EE0FFF */ andi $t6, $t7, 0xfff -/* 098B2C 80097F2C 030E9825 */ or $s3, $t8, $t6 -/* 098B30 80097F30 8FB800DC */ lw $t8, 0xdc($sp) -/* 098B34 80097F34 8FAD0080 */ lw $t5, 0x80($sp) -/* 098B38 80097F38 3C01F500 */ lui $at, 0xf500 -/* 098B3C 80097F3C 03030019 */ multu $t8, $v1 -/* 098B40 80097F40 01212825 */ or $a1, $t1, $at -/* 098B44 80097F44 3C010010 */ lui $at, 0x10 -/* 098B48 80097F48 01C07825 */ move $t7, $t6 -/* 098B4C 80097F4C 00A17025 */ or $t6, $a1, $at -/* 098B50 80097F50 01C02825 */ move $a1, $t6 -/* 098B54 80097F54 000DC140 */ sll $t8, $t5, 5 -/* 098B58 80097F58 00081080 */ sll $v0, $t0, 2 -/* 098B5C 80097F5C 00195880 */ sll $t3, $t9, 2 -/* 098B60 80097F60 03203825 */ move $a3, $t9 -/* 098B64 80097F64 0000A812 */ mflo $s5 -/* 098B68 80097F68 01003025 */ move $a2, $t0 -/* 098B6C 80097F6C 06A10003 */ bgez $s5, .L80097F7C -/* 098B70 80097F70 00157943 */ sra $t7, $s5, 5 -/* 098B74 80097F74 26A1001F */ addiu $at, $s5, 0x1f -/* 098B78 80097F78 00017943 */ sra $t7, $at, 5 -.L80097F7C: -/* 098B7C 80097F7C 01A30019 */ multu $t5, $v1 -/* 098B80 80097F80 01E0A825 */ move $s5, $t7 -/* 098B84 80097F84 01007825 */ move $t7, $t0 -/* 098B88 80097F88 000F7540 */ sll $t6, $t7, 0x15 -/* 098B8C 80097F8C AFAE0060 */ sw $t6, 0x60($sp) -/* 098B90 80097F90 00187A80 */ sll $t7, $t8, 0xa -/* 098B94 80097F94 00007012 */ mflo $t6 -/* 098B98 80097F98 00000000 */ nop -/* 098B9C 80097F9C 00000000 */ nop -/* 098BA0 80097FA0 01EE001A */ div $zero, $t7, $t6 -/* 098BA4 80097FA4 15C00002 */ bnez $t6, .L80097FB0 -/* 098BA8 80097FA8 00000000 */ nop -/* 098BAC 80097FAC 0007000D */ break 7 -.L80097FB0: -/* 098BB0 80097FB0 2401FFFF */ li $at, -1 -/* 098BB4 80097FB4 15C10004 */ bne $t6, $at, .L80097FC8 -/* 098BB8 80097FB8 3C018000 */ lui $at, 0x8000 -/* 098BBC 80097FBC 15E10002 */ bne $t7, $at, .L80097FC8 -/* 098BC0 80097FC0 00000000 */ nop -/* 098BC4 80097FC4 0006000D */ break 6 -.L80097FC8: -/* 098BC8 80097FC8 00007812 */ mflo $t7 -/* 098BCC 80097FCC 000F7400 */ sll $t6, $t7, 0x10 -/* 098BD0 80097FD0 35D80400 */ ori $t8, $t6, 0x400 -/* 098BD4 80097FD4 304F0FFF */ andi $t7, $v0, 0xfff -/* 098BD8 80097FD8 000F7300 */ sll $t6, $t7, 0xc -/* 098BDC 80097FDC AFB8005C */ sw $t8, 0x5c($sp) -/* 098BE0 80097FE0 31780FFF */ andi $t8, $t3, 0xfff -/* 098BE4 80097FE4 3C01F200 */ lui $at, 0xf200 -/* 098BE8 80097FE8 01C1B025 */ or $s6, $t6, $at -/* 098BEC 80097FEC 00187B00 */ sll $t7, $t8, 0xc -/* 098BF0 80097FF0 01C01025 */ move $v0, $t6 -/* 098BF4 80097FF4 03287023 */ subu $t6, $t9, $t0 -/* 098BF8 80097FF8 000EC840 */ sll $t9, $t6, 1 -/* 098BFC 80097FFC 3C010700 */ lui $at, 0x700 -/* 098C00 80098000 01030019 */ multu $t0, $v1 -/* 098C04 80098004 01E1B825 */ or $s7, $t7, $at -/* 098C08 80098008 27380009 */ addiu $t8, $t9, 9 -/* 098C0C 8009800C 01E05825 */ move $t3, $t7 -/* 098C10 80098010 001878C2 */ srl $t7, $t8, 3 -/* 098C14 80098014 31EE01FF */ andi $t6, $t7, 0x1ff -/* 098C18 80098018 000ECA40 */ sll $t9, $t6, 9 -/* 098C1C 8009801C 00E8C023 */ subu $t8, $a3, $t0 -/* 098C20 80098020 00187840 */ sll $t7, $t8, 1 -/* 098C24 80098024 25EE0009 */ addiu $t6, $t7, 9 -/* 098C28 80098028 00B9F025 */ or $fp, $a1, $t9 -/* 098C2C 8009802C 000EC8C2 */ srl $t9, $t6, 3 -/* 098C30 80098030 333801FF */ andi $t8, $t9, 0x1ff -/* 098C34 80098034 00187A40 */ sll $t7, $t8, 9 -/* 098C38 80098038 00AFF825 */ or $ra, $a1, $t7 -/* 098C3C 8009803C 00007812 */ mflo $t7 -/* 098C40 80098040 0008C940 */ sll $t9, $t0, 5 -/* 098C44 80098044 0019C280 */ sll $t8, $t9, 0xa -/* 098C48 80098048 030F001A */ div $zero, $t8, $t7 -/* 098C4C 8009804C 3C01F400 */ lui $at, 0xf400 -/* 098C50 80098050 00417025 */ or $t6, $v0, $at -/* 098C54 80098054 AFAE0040 */ sw $t6, 0x40($sp) -/* 098C58 80098058 8FAE0030 */ lw $t6, 0x30($sp) -/* 098C5C 8009805C 0000C812 */ mflo $t9 -/* 098C60 80098060 15E00002 */ bnez $t7, .L8009806C -/* 098C64 80098064 00000000 */ nop -/* 098C68 80098068 0007000D */ break 7 -.L8009806C: -/* 098C6C 8009806C 2401FFFF */ li $at, -1 -/* 098C70 80098070 15E10004 */ bne $t7, $at, .L80098084 -/* 098C74 80098074 3C018000 */ lui $at, 0x8000 -/* 098C78 80098078 17010002 */ bne $t8, $at, .L80098084 -/* 098C7C 8009807C 00000000 */ nop -/* 098C80 80098080 0006000D */ break 6 -.L80098084: -/* 098C84 80098084 010E0019 */ multu $t0, $t6 -/* 098C88 80098088 0019C400 */ sll $t8, $t9, 0x10 -/* 098C8C 8009808C 370F0400 */ ori $t7, $t8, 0x400 -/* 098C90 80098090 AFAF003C */ sw $t7, 0x3c($sp) -/* 098C94 80098094 0006C040 */ sll $t8, $a2, 1 -/* 098C98 80098098 270F0009 */ addiu $t7, $t8, 9 -/* 098C9C 8009809C 000F70C2 */ srl $t6, $t7, 3 -/* 098CA0 800980A0 00008812 */ mflo $s1 -/* 098CA4 800980A4 06210003 */ bgez $s1, .L800980B4 -/* 098CA8 800980A8 0011C943 */ sra $t9, $s1, 5 -/* 098CAC 800980AC 2621001F */ addiu $at, $s1, 0x1f -/* 098CB0 800980B0 0001C943 */ sra $t9, $at, 5 -.L800980B4: -/* 098CB4 800980B4 03208825 */ move $s1, $t9 -/* 098CB8 800980B8 31D901FF */ andi $t9, $t6, 0x1ff -/* 098CBC 800980BC 0019C240 */ sll $t8, $t9, 9 -/* 098CC0 800980C0 3C010700 */ lui $at, 0x700 -/* 098CC4 800980C4 00418025 */ or $s0, $v0, $at -/* 098CC8 800980C8 10000077 */ b .L800982A8 -/* 098CCC 800980CC 00B85025 */ or $t2, $a1, $t8 -.L800980D0: -/* 098CD0 800980D0 83A900FF */ lb $t1, 0xff($sp) -/* 098CD4 800980D4 01CF1823 */ subu $v1, $t6, $t7 -/* 098CD8 800980D8 3C01FD00 */ lui $at, 0xfd00 -/* 098CDC 800980DC 31390007 */ andi $t9, $t1, 7 -/* 098CE0 800980E0 0019C540 */ sll $t8, $t9, 0x15 -/* 098CE4 800980E4 03004825 */ move $t1, $t8 -/* 098CE8 800980E8 03017025 */ or $t6, $t8, $at -/* 098CEC 800980EC 8FB8011C */ lw $t8, 0x11c($sp) -/* 098CF0 800980F0 3C010010 */ lui $at, 0x10 -/* 098CF4 800980F4 01C1C825 */ or $t9, $t6, $at -/* 098CF8 800980F8 AFAF0030 */ sw $t7, 0x30($sp) -/* 098CFC 800980FC 270EFFFF */ addiu $t6, $t8, -1 -/* 098D00 80098100 31CF0FFF */ andi $t7, $t6, 0xfff -/* 098D04 80098104 032F9825 */ or $s3, $t9, $t7 -/* 098D08 80098108 8FB900DC */ lw $t9, 0xdc($sp) -/* 098D0C 8009810C 8FAD0080 */ lw $t5, 0x80($sp) -/* 098D10 80098110 3C01F500 */ lui $at, 0xf500 -/* 098D14 80098114 03230019 */ multu $t9, $v1 -/* 098D18 80098118 01212825 */ or $a1, $t1, $at -/* 098D1C 8009811C 3C010010 */ lui $at, 0x10 -/* 098D20 80098120 01E07025 */ move $t6, $t7 -/* 098D24 80098124 00A17825 */ or $t7, $a1, $at -/* 098D28 80098128 01E02825 */ move $a1, $t7 -/* 098D2C 8009812C 000DC940 */ sll $t9, $t5, 5 -/* 098D30 80098130 00081080 */ sll $v0, $t0, 2 -/* 098D34 80098134 00185880 */ sll $t3, $t8, 2 -/* 098D38 80098138 03003825 */ move $a3, $t8 -/* 098D3C 8009813C 0000A812 */ mflo $s5 -/* 098D40 80098140 01003025 */ move $a2, $t0 -/* 098D44 80098144 24120020 */ li $s2, 32 -/* 098D48 80098148 01A30019 */ multu $t5, $v1 -/* 098D4C 8009814C 06A10003 */ bgez $s5, .L8009815C -/* 098D50 80098150 00157143 */ sra $t6, $s5, 5 -/* 098D54 80098154 26A1001F */ addiu $at, $s5, 0x1f -/* 098D58 80098158 00017143 */ sra $t6, $at, 5 -.L8009815C: -/* 098D5C 8009815C 01C0A825 */ move $s5, $t6 -/* 098D60 80098160 01007025 */ move $t6, $t0 -/* 098D64 80098164 000E7D40 */ sll $t7, $t6, 0x15 -/* 098D68 80098168 AFAF0060 */ sw $t7, 0x60($sp) -/* 098D6C 8009816C 00197280 */ sll $t6, $t9, 0xa -/* 098D70 80098170 00007812 */ mflo $t7 -/* 098D74 80098174 00000000 */ nop -/* 098D78 80098178 00000000 */ nop -/* 098D7C 8009817C 01CF001A */ div $zero, $t6, $t7 -/* 098D80 80098180 15E00002 */ bnez $t7, .L8009818C -/* 098D84 80098184 00000000 */ nop -/* 098D88 80098188 0007000D */ break 7 -.L8009818C: -/* 098D8C 8009818C 2401FFFF */ li $at, -1 -/* 098D90 80098190 15E10004 */ bne $t7, $at, .L800981A4 -/* 098D94 80098194 3C018000 */ lui $at, 0x8000 -/* 098D98 80098198 15C10002 */ bne $t6, $at, .L800981A4 -/* 098D9C 8009819C 00000000 */ nop -/* 098DA0 800981A0 0006000D */ break 6 -.L800981A4: -/* 098DA4 800981A4 00007012 */ mflo $t6 -/* 098DA8 800981A8 000E7C00 */ sll $t7, $t6, 0x10 -/* 098DAC 800981AC 35F90400 */ ori $t9, $t7, 0x400 -/* 098DB0 800981B0 304E0FFF */ andi $t6, $v0, 0xfff -/* 098DB4 800981B4 000E7B00 */ sll $t7, $t6, 0xc -/* 098DB8 800981B8 AFB9005C */ sw $t9, 0x5c($sp) -/* 098DBC 800981BC 31790FFF */ andi $t9, $t3, 0xfff -/* 098DC0 800981C0 3C01F200 */ lui $at, 0xf200 -/* 098DC4 800981C4 01E1B025 */ or $s6, $t7, $at -/* 098DC8 800981C8 00197300 */ sll $t6, $t9, 0xc -/* 098DCC 800981CC 01E01025 */ move $v0, $t7 -/* 098DD0 800981D0 03087823 */ subu $t7, $t8, $t0 -/* 098DD4 800981D4 000FC040 */ sll $t8, $t7, 1 -/* 098DD8 800981D8 3C010700 */ lui $at, 0x700 -/* 098DDC 800981DC 01030019 */ multu $t0, $v1 -/* 098DE0 800981E0 01C1B825 */ or $s7, $t6, $at -/* 098DE4 800981E4 27190009 */ addiu $t9, $t8, 9 -/* 098DE8 800981E8 01C05825 */ move $t3, $t6 -/* 098DEC 800981EC 001970C2 */ srl $t6, $t9, 3 -/* 098DF0 800981F0 31CF01FF */ andi $t7, $t6, 0x1ff -/* 098DF4 800981F4 000FC240 */ sll $t8, $t7, 9 -/* 098DF8 800981F8 00E8C823 */ subu $t9, $a3, $t0 -/* 098DFC 800981FC 00197040 */ sll $t6, $t9, 1 -/* 098E00 80098200 25CF0009 */ addiu $t7, $t6, 9 -/* 098E04 80098204 00B8F025 */ or $fp, $a1, $t8 -/* 098E08 80098208 000FC0C2 */ srl $t8, $t7, 3 -/* 098E0C 8009820C 331901FF */ andi $t9, $t8, 0x1ff -/* 098E10 80098210 00197240 */ sll $t6, $t9, 9 -/* 098E14 80098214 00AEF825 */ or $ra, $a1, $t6 -/* 098E18 80098218 00007012 */ mflo $t6 -/* 098E1C 8009821C 0008C140 */ sll $t8, $t0, 5 -/* 098E20 80098220 0018CA80 */ sll $t9, $t8, 0xa -/* 098E24 80098224 032E001A */ div $zero, $t9, $t6 -/* 098E28 80098228 3C01F400 */ lui $at, 0xf400 -/* 098E2C 8009822C 00417825 */ or $t7, $v0, $at -/* 098E30 80098230 AFAF0040 */ sw $t7, 0x40($sp) -/* 098E34 80098234 8FAF0030 */ lw $t7, 0x30($sp) -/* 098E38 80098238 0000C012 */ mflo $t8 -/* 098E3C 8009823C 15C00002 */ bnez $t6, .L80098248 -/* 098E40 80098240 00000000 */ nop -/* 098E44 80098244 0007000D */ break 7 -.L80098248: -/* 098E48 80098248 2401FFFF */ li $at, -1 -/* 098E4C 8009824C 15C10004 */ bne $t6, $at, .L80098260 -/* 098E50 80098250 3C018000 */ lui $at, 0x8000 -/* 098E54 80098254 17210002 */ bne $t9, $at, .L80098260 -/* 098E58 80098258 00000000 */ nop -/* 098E5C 8009825C 0006000D */ break 6 -.L80098260: -/* 098E60 80098260 010F0019 */ multu $t0, $t7 -/* 098E64 80098264 0018CC00 */ sll $t9, $t8, 0x10 -/* 098E68 80098268 372E0400 */ ori $t6, $t9, 0x400 -/* 098E6C 8009826C AFAE003C */ sw $t6, 0x3c($sp) -/* 098E70 80098270 0006C840 */ sll $t9, $a2, 1 -/* 098E74 80098274 272E0009 */ addiu $t6, $t9, 9 -/* 098E78 80098278 000E78C2 */ srl $t7, $t6, 3 -/* 098E7C 8009827C 00008812 */ mflo $s1 -/* 098E80 80098280 06210003 */ bgez $s1, .L80098290 -/* 098E84 80098284 0011C143 */ sra $t8, $s1, 5 -/* 098E88 80098288 2621001F */ addiu $at, $s1, 0x1f -/* 098E8C 8009828C 0001C143 */ sra $t8, $at, 5 -.L80098290: -/* 098E90 80098290 03008825 */ move $s1, $t8 -/* 098E94 80098294 31F801FF */ andi $t8, $t7, 0x1ff -/* 098E98 80098298 0018CA40 */ sll $t9, $t8, 9 -/* 098E9C 8009829C 3C010700 */ lui $at, 0x700 -/* 098EA0 800982A0 00418025 */ or $s0, $v0, $at -/* 098EA4 800982A4 00B95025 */ or $t2, $a1, $t9 -.L800982A8: -/* 098EA8 800982A8 00801825 */ move $v1, $a0 -/* 098EAC 800982AC AC730000 */ sw $s3, ($v1) -/* 098EB0 800982B0 8FAE0118 */ lw $t6, 0x118($sp) -/* 098EB4 800982B4 24840008 */ addiu $a0, $a0, 8 -/* 098EB8 800982B8 00802825 */ move $a1, $a0 -/* 098EBC 800982BC 3C0F0701 */ lui $t7, (0x07014050 >> 16) # lui $t7, 0x701 -/* 098EC0 800982C0 AC6E0004 */ sw $t6, 4($v1) -/* 098EC4 800982C4 35EF4050 */ ori $t7, (0x07014050 & 0xFFFF) # ori $t7, $t7, 0x4050 -/* 098EC8 800982C8 ACAF0004 */ sw $t7, 4($a1) -/* 098ECC 800982CC 24840008 */ addiu $a0, $a0, 8 -/* 098ED0 800982D0 00804825 */ move $t1, $a0 -/* 098ED4 800982D4 ACAA0000 */ sw $t2, ($a1) -/* 098ED8 800982D8 000C3080 */ sll $a2, $t4, 2 -/* 098EDC 800982DC 30D90FFF */ andi $t9, $a2, 0xfff -/* 098EE0 800982E0 24840008 */ addiu $a0, $a0, 8 -/* 098EE4 800982E4 3C01F400 */ lui $at, 0xf400 -/* 098EE8 800982E8 01923821 */ addu $a3, $t4, $s2 -/* 098EEC 800982EC 00077880 */ sll $t7, $a3, 2 -/* 098EF0 800982F0 03217025 */ or $t6, $t9, $at -/* 098EF4 800982F4 00801825 */ move $v1, $a0 -/* 098EF8 800982F8 3C18E600 */ lui $t8, 0xe600 -/* 098EFC 800982FC AD380000 */ sw $t8, ($t1) -/* 098F00 80098300 31E70FFF */ andi $a3, $t7, 0xfff -/* 098F04 80098304 03203025 */ move $a2, $t9 -/* 098F08 80098308 AD200004 */ sw $zero, 4($t1) -/* 098F0C 8009830C AC6E0000 */ sw $t6, ($v1) -/* 098F10 80098310 0207C825 */ or $t9, $s0, $a3 -/* 098F14 80098314 24840008 */ addiu $a0, $a0, 8 -/* 098F18 80098318 00802825 */ move $a1, $a0 -/* 098F1C 8009831C AC790004 */ sw $t9, 4($v1) -/* 098F20 80098320 24840008 */ addiu $a0, $a0, 8 -/* 098F24 80098324 00806825 */ move $t5, $a0 -/* 098F28 80098328 3C0EE700 */ lui $t6, 0xe700 -/* 098F2C 8009832C ACAE0000 */ sw $t6, ($a1) -/* 098F30 80098330 ACA00004 */ sw $zero, 4($a1) -/* 098F34 80098334 3C0F0001 */ lui $t7, (0x00014050 >> 16) # lui $t7, 1 -/* 098F38 80098338 35EF4050 */ ori $t7, (0x00014050 & 0xFFFF) # ori $t7, $t7, 0x4050 -/* 098F3C 8009833C 24840008 */ addiu $a0, $a0, 8 -/* 098F40 80098340 00801825 */ move $v1, $a0 -/* 098F44 80098344 ADAF0004 */ sw $t7, 4($t5) -/* 098F48 80098348 ADAA0000 */ sw $t2, ($t5) -/* 098F4C 8009834C 3C01F200 */ lui $at, 0xf200 -/* 098F50 80098350 00C1C025 */ or $t8, $a2, $at -/* 098F54 80098354 0047C825 */ or $t9, $v0, $a3 -/* 098F58 80098358 AC790004 */ sw $t9, 4($v1) -/* 098F5C 8009835C AC780000 */ sw $t8, ($v1) -/* 098F60 80098360 8FAE0114 */ lw $t6, 0x114($sp) -/* 098F64 80098364 02888021 */ addu $s0, $s4, $t0 -/* 098F68 80098368 0010C880 */ sll $t9, $s0, 2 -/* 098F6C 8009836C 01D24821 */ addu $t1, $t6, $s2 -/* 098F70 80098370 00097880 */ sll $t7, $t1, 2 -/* 098F74 80098374 31E90FFF */ andi $t1, $t7, 0xfff -/* 098F78 80098378 332E0FFF */ andi $t6, $t9, 0xfff -/* 098F7C 8009837C 000E7B00 */ sll $t7, $t6, 0xc -/* 098F80 80098380 3C01E400 */ lui $at, 0xe400 -/* 098F84 80098384 24840008 */ addiu $a0, $a0, 8 -/* 098F88 80098388 01E1C025 */ or $t8, $t7, $at -/* 098F8C 8009838C 0309C825 */ or $t9, $t8, $t1 -/* 098F90 80098390 00802825 */ move $a1, $a0 -/* 098F94 80098394 ACB90000 */ sw $t9, ($a1) -/* 098F98 80098398 8FAA0114 */ lw $t2, 0x114($sp) -/* 098F9C 8009839C 0234C021 */ addu $t8, $s1, $s4 -/* 098FA0 800983A0 0018C880 */ sll $t9, $t8, 2 -/* 098FA4 800983A4 000A7080 */ sll $t6, $t2, 2 -/* 098FA8 800983A8 31CA0FFF */ andi $t2, $t6, 0xfff -/* 098FAC 800983AC 332E0FFF */ andi $t6, $t9, 0xfff -/* 098FB0 800983B0 000E7B00 */ sll $t7, $t6, 0xc -/* 098FB4 800983B4 01EAC025 */ or $t8, $t7, $t2 -/* 098FB8 800983B8 ACB80004 */ sw $t8, 4($a1) -/* 098FBC 800983BC 24840008 */ addiu $a0, $a0, 8 -/* 098FC0 800983C0 00801025 */ move $v0, $a0 -/* 098FC4 800983C4 000C7140 */ sll $t6, $t4, 5 -/* 098FC8 800983C8 31C5FFFF */ andi $a1, $t6, 0xffff -/* 098FCC 800983CC 24840008 */ addiu $a0, $a0, 8 -/* 098FD0 800983D0 3C19B300 */ lui $t9, 0xb300 -/* 098FD4 800983D4 AC590000 */ sw $t9, ($v0) -/* 098FD8 800983D8 00801825 */ move $v1, $a0 -/* 098FDC 800983DC AC450004 */ sw $a1, 4($v0) -/* 098FE0 800983E0 3C18B200 */ lui $t8, 0xb200 -/* 098FE4 800983E4 AC780000 */ sw $t8, ($v1) -/* 098FE8 800983E8 8FB9003C */ lw $t9, 0x3c($sp) -/* 098FEC 800983EC 24840008 */ addiu $a0, $a0, 8 -/* 098FF0 800983F0 00806825 */ move $t5, $a0 -/* 098FF4 800983F4 AC790004 */ sw $t9, 4($v1) -/* 098FF8 800983F8 ADB30000 */ sw $s3, ($t5) -/* 098FFC 800983FC 8FAE0118 */ lw $t6, 0x118($sp) -/* 099000 80098400 24840008 */ addiu $a0, $a0, 8 -/* 099004 80098404 00801025 */ move $v0, $a0 -/* 099008 80098408 3C0F0701 */ lui $t7, (0x07014050 >> 16) # lui $t7, 0x701 -/* 09900C 8009840C ADAE0004 */ sw $t6, 4($t5) -/* 099010 80098410 35EF4050 */ ori $t7, (0x07014050 & 0xFFFF) # ori $t7, $t7, 0x4050 -/* 099014 80098414 24840008 */ addiu $a0, $a0, 8 -/* 099018 80098418 00801825 */ move $v1, $a0 -/* 09901C 8009841C AC4F0004 */ sw $t7, 4($v0) -/* 099020 80098420 AC5F0000 */ sw $ra, ($v0) -/* 099024 80098424 3C18E600 */ lui $t8, 0xe600 -/* 099028 80098428 AC780000 */ sw $t8, ($v1) -/* 09902C 8009842C AC600004 */ sw $zero, 4($v1) -/* 099030 80098430 8FB90040 */ lw $t9, 0x40($sp) -/* 099034 80098434 0200A025 */ move $s4, $s0 -/* 099038 80098438 24840008 */ addiu $a0, $a0, 8 -/* 09903C 8009843C 00808025 */ move $s0, $a0 -/* 099040 80098440 24840008 */ addiu $a0, $a0, 8 -/* 099044 80098444 02E77825 */ or $t7, $s7, $a3 -/* 099048 80098448 03267025 */ or $t6, $t9, $a2 -/* 09904C 8009844C AE0E0000 */ sw $t6, ($s0) -/* 099050 80098450 AE0F0004 */ sw $t7, 4($s0) -/* 099054 80098454 00801025 */ move $v0, $a0 -/* 099058 80098458 24840008 */ addiu $a0, $a0, 8 -/* 09905C 8009845C 3C18E700 */ lui $t8, 0xe700 -/* 099060 80098460 AC580000 */ sw $t8, ($v0) -/* 099064 80098464 00801825 */ move $v1, $a0 -/* 099068 80098468 3C190001 */ lui $t9, (0x00014050 >> 16) # lui $t9, 1 -/* 09906C 8009846C 37394050 */ ori $t9, (0x00014050 & 0xFFFF) # ori $t9, $t9, 0x4050 -/* 099070 80098470 AC400004 */ sw $zero, 4($v0) -/* 099074 80098474 AC790004 */ sw $t9, 4($v1) -/* 099078 80098478 24840008 */ addiu $a0, $a0, 8 -/* 09907C 8009847C 00806825 */ move $t5, $a0 -/* 099080 80098480 AC7E0000 */ sw $fp, ($v1) -/* 099084 80098484 02C67025 */ or $t6, $s6, $a2 -/* 099088 80098488 02B4C021 */ addu $t8, $s5, $s4 -/* 09908C 8009848C ADAE0000 */ sw $t6, ($t5) -/* 099090 80098490 01677825 */ or $t7, $t3, $a3 -/* 099094 80098494 0018C880 */ sll $t9, $t8, 2 -/* 099098 80098498 ADAF0004 */ sw $t7, 4($t5) -/* 09909C 8009849C 332E0FFF */ andi $t6, $t9, 0xfff -/* 0990A0 800984A0 000E7B00 */ sll $t7, $t6, 0xc -/* 0990A4 800984A4 01E1C025 */ or $t8, $t7, $at -/* 0990A8 800984A8 24840008 */ addiu $a0, $a0, 8 -/* 0990AC 800984AC 0309C825 */ or $t9, $t8, $t1 -/* 0990B0 800984B0 00147080 */ sll $t6, $s4, 2 -/* 0990B4 800984B4 31CF0FFF */ andi $t7, $t6, 0xfff -/* 0990B8 800984B8 00801025 */ move $v0, $a0 -/* 0990BC 800984BC AC590000 */ sw $t9, ($v0) -/* 0990C0 800984C0 000FC300 */ sll $t8, $t7, 0xc -/* 0990C4 800984C4 030AC825 */ or $t9, $t8, $t2 -/* 0990C8 800984C8 AC590004 */ sw $t9, 4($v0) -/* 0990CC 800984CC 24840008 */ addiu $a0, $a0, 8 -/* 0990D0 800984D0 00801025 */ move $v0, $a0 -/* 0990D4 800984D4 3C0EB300 */ lui $t6, 0xb300 -/* 0990D8 800984D8 AC4E0000 */ sw $t6, ($v0) -/* 0990DC 800984DC 8FAF0060 */ lw $t7, 0x60($sp) -/* 0990E0 800984E0 24840008 */ addiu $a0, $a0, 8 -/* 0990E4 800984E4 00801825 */ move $v1, $a0 -/* 0990E8 800984E8 01E5C025 */ or $t8, $t7, $a1 -/* 0990EC 800984EC AC580004 */ sw $t8, 4($v0) -/* 0990F0 800984F0 3C19B200 */ lui $t9, 0xb200 -/* 0990F4 800984F4 AC790000 */ sw $t9, ($v1) -/* 0990F8 800984F8 8FAE005C */ lw $t6, 0x5c($sp) -/* 0990FC 800984FC 258C0020 */ addiu $t4, $t4, 0x20 -/* 099100 80098500 24840008 */ addiu $a0, $a0, 8 -/* 099104 80098504 AC6E0004 */ sw $t6, 4($v1) -/* 099108 80098508 8FB9010C */ lw $t9, 0x10c($sp) -/* 09910C 8009850C 8FAF0114 */ lw $t7, 0x114($sp) -/* 099110 80098510 8FB400EC */ lw $s4, 0xec($sp) -/* 099114 80098514 0199082B */ sltu $at, $t4, $t9 -/* 099118 80098518 25F80020 */ addiu $t8, $t7, 0x20 -/* 09911C 8009851C 1420FE6B */ bnez $at, .L80097ECC -/* 099120 80098520 AFB80114 */ sw $t8, 0x114($sp) -.L80098524: -/* 099124 80098524 00801025 */ move $v0, $a0 -.L80098528: -/* 099128 80098528 8FBF002C */ lw $ra, 0x2c($sp) -/* 09912C 8009852C 8FB00008 */ lw $s0, 8($sp) -/* 099130 80098530 8FB1000C */ lw $s1, 0xc($sp) -/* 099134 80098534 8FB20010 */ lw $s2, 0x10($sp) -/* 099138 80098538 8FB30014 */ lw $s3, 0x14($sp) -/* 09913C 8009853C 8FB40018 */ lw $s4, 0x18($sp) -/* 099140 80098540 8FB5001C */ lw $s5, 0x1c($sp) -/* 099144 80098544 8FB60020 */ lw $s6, 0x20($sp) -/* 099148 80098548 8FB70024 */ lw $s7, 0x24($sp) -/* 09914C 8009854C 8FBE0028 */ lw $fp, 0x28($sp) -/* 099150 80098550 03E00008 */ jr $ra -/* 099154 80098554 27BD00F8 */ addiu $sp, $sp, 0xf8 diff --git a/src/code_80091750.c b/src/code_80091750.c index 165948d97..223856122 100644 --- a/src/code_80091750.c +++ b/src/code_80091750.c @@ -3292,80 +3292,72 @@ Gfx *func_80097A14(Gfx *displayListHead, s8 arg1, s32 arg2, s32 arg3, s32 arg4, return displayListHead; } -#ifdef NON_MATCHING -// https://decomp.me/scratch/EAuX4 -// I'm fairly certain I've got the GBI macros correct, don't know what the source of the diff is -// While there may be register allocation issues, I suspect the instruction ordering issues are the actual problems -Gfx *func_80097AE4(Gfx *displayListHead, s8 fmt, s32 arg2, s32 arg3, u8 *arg4, s32 arg5) { - s32 var_a2; - UNUSED s32 stackPadding0; +Gfx *func_80097AE4(Gfx *displayListHead, s8 fmt, s32 arg2, s32 arg3, u8 *arg4, s32 width) { + s32 i; + s32 temp; s32 arg2Copy; s32 dsdx; - if (arg5 >= 0x20) return displayListHead; + if (width >= 32) { return displayListHead; } arg2Copy = arg2; - dsdx = 0x8000 / (0x20 - arg5); - for (var_a2 = 0; var_a2 < 0x40; var_a2 += 0x20) { - gDPLoadTextureTile(displayListHead++, arg4, fmt, G_IM_SIZ_16b, 64, 0, 0, var_a2, 32, var_a2 + 0x20, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 5, 5, G_TX_NOLOD, G_TX_NOLOD); - gSPTextureRectangle(displayListHead++, (arg2 + arg5) << 2, arg3 << 2, (arg2 + 0x20) << 2, (arg3 + 0x20) << 2, 0, 0, 0, dsdx, 1024); - arg2 += 0x20; - gDPLoadTextureTile(displayListHead++, arg4, fmt, G_IM_SIZ_16b, 64, 0, 32, var_a2, 64, var_a2 + 0x20, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 5, 5, G_TX_NOLOD, G_TX_NOLOD); - gSPTextureRectangle(displayListHead++, arg2 << 2, arg3 << 2, ((arg2 - arg5) + 0x20) << 2, (arg3 + 0x20) << 2, 0, 0, 0, dsdx, 1024); + + for (i = 0; i < 64; i += 32) { + temp = 0; + dsdx = 0x8000 / (32 - width); + gDPLoadTextureTile(displayListHead++, arg4, fmt, G_IM_SIZ_16b, 64, 64, temp, i, temp + 32, i + 32, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 5, 5, G_TX_NOLOD, G_TX_NOLOD); + gSPTextureRectangle(displayListHead++, (arg2 + width) << 2, arg3 << 2, (arg2 + 32) << 2, (arg3 + 32) << 2, 0, 0, 0, dsdx, 1024); + + arg2 += 32; + + gDPLoadTextureTile(displayListHead++, arg4, fmt, G_IM_SIZ_16b, 64, 64, temp + 32, i, temp + 64, i + 32, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 5, 5, G_TX_NOLOD, G_TX_NOLOD); + gSPTextureRectangle(displayListHead++, arg2 << 2, arg3 << 2, ((arg2 - width) + 32) << 2, (arg3 + 32) << 2, 0, 0, 0, dsdx, 1024); + arg2 = arg2Copy; - arg3 += 0x20; + arg3 += 32; } return displayListHead; } -#else -GLOBAL_ASM("asm/non_matchings/code_80091750/func_80097AE4.s") -#endif -#ifdef NON_MATCHING -// https://decomp.me/scratch/U4QaQ -// I'm fairly certain I have the GBI macros correct, so the massive diff is probably -// the result of somemath ordering issues. -Gfx *func_80097E58(Gfx *displayListHead, s8 fmt, UNUSED s32 arg2, s32 arg3, UNUSED s32 arg4, s32 arg5, s32 arg6, s32 arg7, u8 *someTexture, u32 width, UNUSED s32 argA, u32 argB) { +Gfx *func_80097E58(Gfx *displayListHead, s8 fmt, u32 arg2, u32 arg3, u32 arg4, u32 arg5, s32 arg6, s32 arg7, u8 *someTexture, u32 arg9, u32 argA, s32 width) { u32 ult; - s32 spDC; - s32 sp80; - s32 temp_v1; - s32 var_s1; - s32 var_s2; - s32 var_s5; - u32 lrs; + u32 temp; s32 arg6Copy; + s32 temp_v1; + s32 var_s2; + s32 lrs; + s32 spDC; + s32 temp2 = 32; - if ((s32)width >= 0x20) return displayListHead; - - lrs = width >> 1; - spDC = sp80 = width - lrs; + if (width >= 32) { return displayListHead; } + arg6Copy = arg6; - for (ult = arg3; ult < (u32) arg5; ult += 0x20) { - if ((u32) arg5 < (ult + 0x20)) { // Less than 0x20 left to reach target - var_s2 = arg5 - ult; // Leftover amount to reach target - if (var_s2 == 0) break; // Actually at target + + lrs = arg9 / 2; + spDC = arg9 - lrs; + for (ult = arg3; ult < arg5; ult += 32) { + temp = 0; + if ((ult + temp2) > arg5) { + var_s2 = arg5 - ult; + if (!var_s2) { + break; + } } else { - var_s2 = 0x20; // Go the full 0x20 on this step + var_s2 = temp2; } - temp_v1 = 0x20 - argB; - var_s1 = (lrs * argB) / 32; - var_s5 = (spDC * temp_v1) / 32; - - gDPLoadTextureTile(displayListHead++, someTexture, fmt, G_IM_SIZ_16b, width, 0, 0, ult, lrs, ult + var_s2, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 5, 5, G_TX_NOLOD, G_TX_NOLOD); - gSPTextureRectangle(displayListHead++, (arg6 + var_s1) << 2, arg7 << 2, (arg6 + lrs) << 2, (arg7 + var_s2) << 2, 0, 0, ult << 5, (s32)((lrs << 5) << 0xA) / (s32)(lrs * temp_v1), 1024); + temp_v1 = ((32 * lrs) << 10) / (lrs * (32 - width)); + gDPLoadTextureTile(displayListHead++, someTexture, fmt, G_IM_SIZ_16b, arg9, argA, temp, ult, temp + lrs, ult + var_s2, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 5, 5, G_TX_NOLOD, G_TX_NOLOD); + gSPTextureRectangle(displayListHead++, (arg6 + lrs * width / 32) << 2, arg7 << 2, (arg6 + lrs) << 2, (arg7 + var_s2) << 2, 0, 0, (ult << 5) & 0xFFFF, temp_v1, 1024); arg6 += lrs; - gDPLoadTextureTile(displayListHead++, someTexture, fmt, G_IM_SIZ_16b, width, 0, lrs, ult, width, ult + var_s2, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 5, 5, G_TX_NOLOD, G_TX_NOLOD); - gSPTextureRectangle(displayListHead++, arg6 << 2, arg7 << 2, (arg6 + var_s5) << 2, (arg7 + var_s2) << 2, 0, lrs << 5, ult << 5, ((sp80 << 5) << 0xA) / (sp80 * temp_v1), 1024); + temp_v1 = ((32 * spDC) << 10) / (spDC * (32 - width)); + gDPLoadTextureTile(displayListHead++, someTexture, fmt, G_IM_SIZ_16b, arg9, argA, temp + lrs, ult, temp + arg9, ult + var_s2, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 5, 5, G_TX_NOLOD, G_TX_NOLOD); + gSPTextureRectangle(displayListHead++, arg6 << 2, arg7 << 2, (arg6 + spDC * (32 - width) / 32) << 2, (arg7 + var_s2) << 2, 0, (lrs << 5) & 0xFFFF, (ult << 5) & 0xFFFF, temp_v1, 1024); arg6 = arg6Copy; - arg7 += 0x20; + arg7 += temp2; } return displayListHead; } -#else -GLOBAL_ASM("asm/non_matchings/code_80091750/func_80097E58.s") -#endif Gfx *func_80098558(Gfx *displayListHead, u32 arg1, u32 arg2, u32 arg3, u32 arg4, u32 arg5, u32 arg6, UNUSED s32 arg7, s32 arg8) { u32 var_a3; diff --git a/src/code_80091750.h b/src/code_80091750.h index a0eed9a7c..ea1a83ebd 100644 --- a/src/code_80091750.h +++ b/src/code_80091750.h @@ -162,7 +162,7 @@ Gfx *func_80096CD8(Gfx*, s32, s32, u32, u32); Gfx *func_80097274(Gfx *displayListHead, s8 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8, s32 arg9, u16 *argA, u32 argB, u32 argC, s32 argD); Gfx *func_80097A14(Gfx*, s8, s32, s32, s32, s32, s32, s32, u8*, u32, u32); Gfx *func_80097AE4(Gfx*, s8, s32, s32, u8*, s32); -Gfx *func_80097E58(Gfx*, s8, s32, s32, s32, s32, s32, s32, u8*, u32, s32, u32); +Gfx *func_80097E58(Gfx *displayListHead, s8 fmt, u32 arg2, u32 arg3, u32 arg4, u32 arg5, s32 arg6, s32 arg7, u8 *someTexture, u32 arg9, u32 argA, s32 width); Gfx *func_80098558(Gfx*, u32, u32, u32, u32, u32, u32, s32, s32); Gfx *func_800987D0(Gfx*, u32, u32, u32, u32, s32, s32, u8*, u32, s32); Gfx *draw_box_fill(Gfx*, s32, s32, s32, s32, s32, s32, s32, s32); From a33325212fc6e58c7e645272eedc35688718f3da Mon Sep 17 00:00:00 2001 From: MegaMech Date: Tue, 23 Apr 2024 13:23:25 -0600 Subject: [PATCH 3/9] Fix bugs in non_matching (#628) * Update menus.c * Update code_80057C60.c --- src/code_80057C60.c | 15 ++++++++------- src/menus.c | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/code_80057C60.c b/src/code_80057C60.c index ce3586ea3..39ab768a7 100644 --- a/src/code_80057C60.c +++ b/src/code_80057C60.c @@ -4907,8 +4907,7 @@ void func_80065AB0(Player *player, UNUSED s8 arg1, s16 arg2, s8 arg3) { s16 envRed; s16 envGreen; s16 envBlue; - s32 envColors[] = { MAKE_RGB(0xFF, 0xFF, 0xFF), MAKE_RGB(0xFF, 0xFF, 0x00), MAKE_RGB(0xFF, 0x96, 0x00) }; - + s32 sp8C[] = {0x00ffffff, 0x00ffff00, 0x00ff9600}; if (player->unk_258[10 + arg2].unk_01C == 1) { if (player->unk_204 >= 0x32) { var_s0 = 1; @@ -4919,9 +4918,9 @@ void func_80065AB0(Player *player, UNUSED s8 arg1, s16 arg2, s8 arg3) { primGreen = player->unk_258[10 + arg2].unk_03A; primBlue = player->unk_258[10 + arg2].unk_03C; primAlpha = player->unk_258[10 + arg2].unk_03E; - envRed = (envColors[player->unk_258[10 + arg2].unk_040] >> 0x10) & 0xFF; - envGreen = (envColors[player->unk_258[10 + arg2].unk_040] >> 0x08) & 0xFF; - envBlue = (envColors[player->unk_258[10 + arg2].unk_040] >> 0x00) & 0xFF; + envRed = (sp8C[player->unk_258[10 + arg2].unk_040] >> 0x10) & 0xFF; + envGreen = (sp8C[player->unk_258[10 + arg2].unk_040] >> 0x08) & 0xFF; + envBlue = (sp8C[player->unk_258[10 + arg2].unk_040] >> 0x00) & 0xFF; spB4[0] = player->unk_258[10 + arg2].unk_000[0]; spB4[1] = player->unk_258[10 + arg2].unk_000[1]; spB4[2] = player->unk_258[10 + arg2].unk_000[2]; @@ -4931,13 +4930,15 @@ void func_80065AB0(Player *player, UNUSED s8 arg1, s16 arg2, s8 arg3) { func_800652D4(spB4, spAC, player->unk_258[10 + arg2].unk_00C * player->size); if (var_s0 == 0) { gSPDisplayList(gDisplayListHead++, D_0D008DB8); - gDPLoadTextureBlock(gDisplayListHead++, D_800E4770[var_s0], G_IM_FMT_I, G_IM_SIZ_8b, 16, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock(gDisplayListHead++, D_800E4770[var_s0][0], G_IM_FMT_I, G_IM_SIZ_8b, 16, 16, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); func_8004B72C(primRed, primGreen, primBlue, envRed, envGreen, envBlue, primAlpha); gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_XLU_SURF, G_RM_ZB_XLU_SURF2); gSPDisplayList(gDisplayListHead++, D_0D008DF8); } else { gSPDisplayList(gDisplayListHead++, D_0D008DB8); - gDPLoadTextureBlock(gDisplayListHead++, D_800E4770[var_s0], G_IM_FMT_I, G_IM_SIZ_8b, 32, 32, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock(gDisplayListHead++, D_800E4770[var_s0][0], G_IM_FMT_I, G_IM_SIZ_8b, 32, 32, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); func_8004B72C(primRed, primGreen, primBlue, envRed, envGreen, envBlue, primAlpha); gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_XLU_SURF, G_RM_ZB_XLU_SURF2); gSPDisplayList(gDisplayListHead++, D_0D008E48); diff --git a/src/menus.c b/src/menus.c index f5d371820..734fb327a 100644 --- a/src/menus.c +++ b/src/menus.c @@ -1411,7 +1411,7 @@ void main_menu_act(struct Controller *controller, u16 arg1) { } // L800B3110 if (sp24) { - D_800E86B0[gPlayerCount - 1][gPlayerCount] += 1; + D_800E86B0[gPlayerCount - 1][D_800E86AC[gPlayerCount - 1]]++; func_800B44AC(); play_sound2(SOUND_MENU_CURSOR_MOVE); } From 21de29c7e6f6caa24f1046d69a43c64a8f53f3df Mon Sep 17 00:00:00 2001 From: MegaMech Date: Tue, 23 Apr 2024 13:41:43 -0600 Subject: [PATCH 4/9] Update menus.c (#629) --- src/menus.c | 168 ++++++++++++++++++++++++++++------------------------ 1 file changed, 91 insertions(+), 77 deletions(-) diff --git a/src/menus.c b/src/menus.c index 734fb327a..f8f07bd89 100644 --- a/src/menus.c +++ b/src/menus.c @@ -1510,163 +1510,177 @@ bool is_character_spot_free(s32 gridId) { // grid positions are from right to left, then top to bottom // nonmatching: the gCharacterGridSelections pointer is not promoted to $s0 void player_select_menu_act(struct Controller *controller, u16 arg1) { - u16 btnAndStick; // sp36 + s8 *bar; s8 selected; s8 i; + s8 saved_selection; + u16 btnAndStick; btnAndStick = (controller->buttonPressed) | (controller->stickPressed); - if (!gEnableDebugMode && btnAndStick & START_BUTTON) { - btnAndStick |= A_BUTTON; + if (!gEnableDebugMode && btnAndStick & CONT_START) { + btnAndStick |= CONT_A; } if (!func_800B4520()) { switch (D_8018EDEE) { - case 1: + case 1: { - if (gCharacterGridSelections[arg1] == 0) { - if (btnAndStick & B_BUTTON) { + saved_selection = gCharacterGridSelections[arg1]; + if (saved_selection == 0) { + if (btnAndStick & CONT_B) { func_8009E208(); - play_sound2(SOUND_MENU_GO_BACK); + play_sound2(0x49008002); } return; } // L800B3630 - if (btnAndStick & B_BUTTON) { + if (btnAndStick & CONT_B) { if (D_8018EDE8[arg1]) { D_8018EDE8[arg1] = FALSE; - play_sound2(SOUND_MENU_GO_BACK); + play_sound2(0x49008002); } else { func_8009E208(); - play_sound2(SOUND_MENU_GO_BACK); + play_sound2(0x49008002); } } // L800B3684 - if ((btnAndStick & A_BUTTON) && !D_8018EDE8[arg1]) { + if ((btnAndStick & CONT_A) && (D_8018EDE8[arg1] == 0)) { D_8018EDE8[arg1] = TRUE; - func_800C90F4( - arg1, - (((uintptr_t)D_800F2BAC[gCharacterGridSelections[arg1] - 1]) << 4) + 0x2900800EU - ); + i = D_800F2BAC[gCharacterGridSelections[arg1] - 1]; + func_800C90F4(arg1, 0x2900800e + (i << 4)); } // L800B36F4 selected = FALSE; - for (i = 0; i < ARRAY_COUNT(gCharacterGridSelections); i++) { - if (gCharacterGridSelections[i] && D_8018EDE8[i]) { + for (i = 0; i < 4; i++) { // for (i = 0; i < ARRAY_COUNT(gCharacterGridSelections); i++) { + if ((gCharacterGridSelections[i] != 0) && (D_8018EDE8[i] == 0)) { //(gCharacterGridSelections[i] && D_8018EDE8[i]) { selected = TRUE; break; } } // L800B3738 + if (!selected) { D_8018EDEE = 2; func_800B44AC(); gMenuTimingCounter = 0; } + // L800B3768 - if (D_8018EDE8[arg1]) { - if ((btnAndStick & R_JPAD) && (btnAndStick & D_JPAD)) { - if (gCharacterGridSelections[arg1] == 1 || gCharacterGridSelections[arg1] == 2 || gCharacterGridSelections[arg1] == 3) { + if (D_8018EDE8[arg1] == 0) { + if ((btnAndStick & CONT_RIGHT) && (btnAndStick & CONT_DOWN)) { + if (saved_selection == 1 || saved_selection == 2 || saved_selection == 3) { // L800B37B0 - if (is_character_spot_free(gCharacterGridSelections[arg1] + 5)) { - gCharacterGridSelections[arg1] += 5; - play_sound2(SOUND_MENU_CURSOR_MOVE); + saved_selection += 5; + if (is_character_spot_free(saved_selection)) { + gCharacterGridSelections[arg1] = saved_selection; + play_sound2(0x49008000); } } return; } // L800B37E4 - if ((btnAndStick & L_JPAD) && (btnAndStick & D_JPAD)) { - if (gCharacterGridSelections[arg1] == 2 || gCharacterGridSelections[arg1] == 3 || gCharacterGridSelections[arg1] == 4) { - if (is_character_spot_free(gCharacterGridSelections[arg1] + 3)) { - gCharacterGridSelections[arg1] += 3; - play_sound2(SOUND_MENU_CURSOR_MOVE); + if ((btnAndStick & CONT_LEFT) && (btnAndStick & CONT_DOWN)) { + if (saved_selection == 2 || saved_selection == 3 || saved_selection == 4) { + saved_selection += 3; + if (is_character_spot_free(saved_selection)) { + gCharacterGridSelections[arg1] = saved_selection; + play_sound2(0x49008000); } } return; } // L800B3844 - if ((btnAndStick & R_JPAD) && (btnAndStick & U_JPAD)) { - if (gCharacterGridSelections[arg1] == 5 || gCharacterGridSelections[arg1] == 6 || gCharacterGridSelections[arg1] == 7) { - if (is_character_spot_free(gCharacterGridSelections[arg1] - 3)) { - gCharacterGridSelections[arg1] -= 3; - play_sound2(SOUND_MENU_CURSOR_MOVE); + if ((btnAndStick & CONT_RIGHT) && (btnAndStick & CONT_UP)) { + if (saved_selection == 5 || saved_selection == 6 || saved_selection == 7) { + saved_selection -= 3; + if (is_character_spot_free(saved_selection)) { + gCharacterGridSelections[arg1] = saved_selection; + play_sound2(0x49008000); } } return; } // L800B38A0 - if ((btnAndStick & L_JPAD) && (btnAndStick & U_JPAD)) { - if (gCharacterGridSelections[arg1] == 6 || gCharacterGridSelections[arg1] == 7 || gCharacterGridSelections[arg1] == 8) { - if (is_character_spot_free(gCharacterGridSelections[arg1] - 5)) { - gCharacterGridSelections[arg1] -= 5; - play_sound2(SOUND_MENU_CURSOR_MOVE); + if ((btnAndStick & CONT_LEFT) && (btnAndStick & CONT_UP)) { + if (saved_selection == 6 || saved_selection == 7 || saved_selection == 8) { + saved_selection -= 5; + if (is_character_spot_free(saved_selection)) { + gCharacterGridSelections[arg1] = saved_selection; + play_sound2(0x49008000); } } return; } // L800B38FC - if (btnAndStick & R_JPAD) { - if (gCharacterGridSelections[arg1] != 4 && gCharacterGridSelections[arg1] != 8) { - do { - // L800B391C - if (is_character_spot_free(gCharacterGridSelections[arg1] + 1)) { - gCharacterGridSelections[arg1] += 1; - play_sound2(SOUND_MENU_CURSOR_MOVE); - break; - } - gCharacterGridSelections[arg1] += 1; - - } while (gCharacterGridSelections[arg1] != 5 && gCharacterGridSelections[arg1] != 9 && gCharacterGridSelections[arg1] <= 10); - } + if (btnAndStick & CONT_RIGHT) { + if (saved_selection == 4 || saved_selection == 8) return; + saved_selection += 1; + do { + // L800B391C + if (is_character_spot_free(saved_selection)) { + gCharacterGridSelections[arg1] = saved_selection; + play_sound2(0x49008000); // play_sound2(0x49008000); + break; + } + saved_selection += 1; + if ((saved_selection == 5) || (saved_selection == 9)) return; + } while (saved_selection < 10); return; } // L800B3978 - if (btnAndStick & L_JPAD) { - if (gCharacterGridSelections[arg1] != 1 && gCharacterGridSelections[arg1] != 5) { - do { - if (is_character_spot_free(gCharacterGridSelections[arg1] - 1)) { - gCharacterGridSelections[arg1] -= 1; - play_sound2(SOUND_MENU_CURSOR_MOVE); - break; - } - gCharacterGridSelections[arg1] -= 1; - } while (gCharacterGridSelections[arg1] != 0 && gCharacterGridSelections[arg1] != 4 && gCharacterGridSelections[arg1] >= 0); - } + if (btnAndStick & CONT_LEFT) { + if (saved_selection == 1 || saved_selection == 5) return; + saved_selection -= 1; + do { + if (is_character_spot_free(saved_selection)) { + gCharacterGridSelections[arg1] = saved_selection; + play_sound2(0x49008000); + break; + } + saved_selection -= 1; + if ((saved_selection == 0) || (saved_selection == 4)) return; + } while (saved_selection >= 0); return; } // L800B39F4 - if ((btnAndStick & U_JPAD) && (gCharacterGridSelections[arg1] >= 5)) { - gCharacterGridSelections[arg1] -= 4; + if ((btnAndStick & CONT_UP) && (saved_selection >= 5)) { + saved_selection = saved_selection - 4; } - if ((btnAndStick & D_JPAD) && (gCharacterGridSelections[arg1] < 5)) { - gCharacterGridSelections[arg1] += 4; + if ((btnAndStick & CONT_DOWN) && (saved_selection < 5)) { + saved_selection = saved_selection + 4; } // L800B3A30 - if (is_character_spot_free(gCharacterGridSelections[arg1])) { - play_sound2(SOUND_MENU_CURSOR_MOVE); + if (is_character_spot_free(saved_selection)) { + gCharacterGridSelections[arg1] = saved_selection; + play_sound2(0x49008000); } } break; } case 2: case 3: - { - if (!arg1 && (++gMenuTimingCounter == 60 || gMenuSelection % 300 == 0)) { - // L800B3A94 - play_sound2(SOUND_MENU_OK); + if (arg1 == 0) { + gMenuTimingCounter++; + if ((gMenuTimingCounter == 60) || ((gMenuTimingCounter % 300) == 0)) { + // L800B3A94 + play_sound2(0x4900900F); + } } // L800B3AA4 - if (btnAndStick & B_BUTTON) { + if (btnAndStick & CONT_B) { D_8018EDEE = 1; D_8018EDE8[arg1] = FALSE; - play_sound2(SOUND_MENU_GO_BACK); - } else if (btnAndStick & A_BUTTON) { + play_sound2(0x49008002); + break; + } + if (btnAndStick & CONT_A) { func_8009E1C0(); - play_sound2(SOUND_MENU_OK_CLICKED); + play_sound2(0x49008016); func_8000F124(); } break; - } + default: + break; } // L800B3B24 if (gCharacterGridSelections[arg1] != 0) { From 49625d397795441b8d81b9bf2f5e517094c273f2 Mon Sep 17 00:00:00 2001 From: MegaMech Date: Tue, 23 Apr 2024 14:06:18 -0600 Subject: [PATCH 5/9] Update code_80005FD0.c (#630) --- src/code_80005FD0.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/code_80005FD0.c b/src/code_80005FD0.c index 3084c84e3..7fe95d63f 100644 --- a/src/code_80005FD0.c +++ b/src/code_80005FD0.c @@ -5912,14 +5912,14 @@ void func_80017054(Camera *camera, UNUSED Player *player, UNUSED s32 index, s32 // https://decomp.me/scratch/Ck7hV // Really crazy diff, permuter only able to find fakematches for improvements (and they're big improvements) // There's something really, really wrong with the empty `if` statement -void func_80017054(Camera *camera, UNUSED Player *player, UNUSED s32 index, s32 cameraId) { - UNUSED s32 stackPadding0; - UNUSED s32 stackPadding1; +void func_80017054(Camera *camera, Player *player, s32 index, s32 cameraId) { + s32 stackPadding0; + s32 stackPadding1; f32 spAC; f32 spA8; f32 spA4; - UNUSED s32 stackPadding2; - UNUSED s32 stackPadding3; + s32 stackPadding2; + s32 stackPadding3; f32 sp98; f32 sp94; f32 sp90; @@ -5929,19 +5929,18 @@ void func_80017054(Camera *camera, UNUSED Player *player, UNUSED s32 index, s32 f32 stackPadding4; f32 stackPadding5; f32 stackPadding6; - UNUSED s32 stackPadding7; - UNUSED s32 stackPadding8; + s32 stackPadding7; + s32 stackPadding8; s16 sp6E; s16 sp6C; - UNUSED s32 stackPadding9; - UNUSED s32 stackPaddingA; - UNUSED s32 stackPaddingB; + s32 stackPadding9; + s32 stackPaddingA; + s32 stackPaddingB; s32 pathIndex; - UNUSED s32 stackPaddingC; + s32 stackPaddingC; s32 sp58; s16 sp56; s32 playerId; - f32 temp_f0; playerId = camera->playerId; pathIndex = D_80163DD8[cameraId]; @@ -5979,24 +5978,23 @@ void func_80017054(Camera *camera, UNUSED Player *player, UNUSED s32 index, s32 stackPadding4 = sp98 - D_801645F8[cameraId]; stackPadding5 = sp90 - D_80164618[cameraId]; stackPadding6 = sp94 - D_80164638[cameraId]; - temp_f0 = sqrtf(((sp98 * sp98) + (sp94 * sp94)) + (sp90 * sp90)); - if (temp_f0 != 0.0) { - sp98 = D_801645F8[cameraId] + ((D_80164648[cameraId] * stackPadding4) / temp_f0); - sp94 = D_80164618[cameraId] + ((D_80164648[cameraId] * stackPadding5) / temp_f0); - sp90 = D_80164638[cameraId] + ((D_80164648[cameraId] * stackPadding6) / temp_f0); + spAC = sqrtf(((sp98 * sp98) + (sp94 * sp94)) + (sp90 * sp90)); + if (spAC != 0.0) { + sp98 = D_801645F8[cameraId] + ((D_80164648[cameraId] * stackPadding4) / spAC); + sp94 = D_80164618[cameraId] + ((D_80164648[cameraId] * stackPadding5) / spAC); + sp90 = D_80164638[cameraId] + ((D_80164648[cameraId] * stackPadding6) / spAC); } else { sp98 = D_801645F8[cameraId]; sp94 = D_80164618[cameraId]; sp90 = D_80164638[cameraId]; } - // This empty if statement is a huge source of problems. I have no idea what's going on if ((!(sp98 < (-10000.0))) && (sp98 > 10000.0)) { if (sp98 && sp98) {} } camera->pos[0] = sp98; - if (1) {} if (1) {} if (1) {} if (1) {} camera->pos[1] = sp94 + 10.0; camera->pos[2] = sp90; + if (1) { } if (1) { } if (1) { } if (1) { } if (1) { } D_801645F8[cameraId] = sp98; D_80164638[cameraId] = sp90; D_80164618[cameraId] = sp94; From d04a5dcddacd4a0ec516df242ddc89fe1ff1e714 Mon Sep 17 00:00:00 2001 From: inspectredc <78732756+inspectredc@users.noreply.github.com> Date: Wed, 24 Apr 2024 00:43:51 +0100 Subject: [PATCH 6/9] Match func_800AFE00 (#631) * Match func_800AFE00 --- .../code_800AF9B0/func_800AFE00.s | 95 ------------------- src/code_800AF9B0.c | 48 ++++------ 2 files changed, 17 insertions(+), 126 deletions(-) delete mode 100644 asm/non_matchings/code_800AF9B0/func_800AFE00.s diff --git a/asm/non_matchings/code_800AF9B0/func_800AFE00.s b/asm/non_matchings/code_800AF9B0/func_800AFE00.s deleted file mode 100644 index e06b16471..000000000 --- a/asm/non_matchings/code_800AF9B0/func_800AFE00.s +++ /dev/null @@ -1,95 +0,0 @@ -glabel func_800AFE00 -/* 0B0A00 800AFE00 27BDFFD0 */ addiu $sp, $sp, -0x30 -/* 0B0A04 800AFE04 AFA40030 */ sw $a0, 0x30($sp) -/* 0B0A08 800AFE08 14C00003 */ bnez $a2, .L800AFE18 -/* 0B0A0C 800AFE0C AFA50034 */ sw $a1, 0x34($sp) -/* 0B0A10 800AFE10 10000002 */ b .L800AFE1C -/* 0B0A14 800AFE14 00001025 */ move $v0, $zero -.L800AFE18: -/* 0B0A18 800AFE18 24C2FFFF */ addiu $v0, $a2, -1 -.L800AFE1C: -/* 0B0A1C 800AFE1C 14C70003 */ bne $a2, $a3, .L800AFE2C -/* 0B0A20 800AFE20 27A50014 */ addiu $a1, $sp, 0x14 -/* 0B0A24 800AFE24 10000002 */ b .L800AFE30 -/* 0B0A28 800AFE28 00E01825 */ move $v1, $a3 -.L800AFE2C: -/* 0B0A2C 800AFE2C 24C30001 */ addiu $v1, $a2, 1 -.L800AFE30: -/* 0B0A30 800AFE30 8FAE0034 */ lw $t6, 0x34($sp) -/* 0B0A34 800AFE34 00067880 */ sll $t7, $a2, 2 -/* 0B0A38 800AFE38 0002C080 */ sll $t8, $v0, 2 -/* 0B0A3C 800AFE3C 0003C880 */ sll $t9, $v1, 2 -/* 0B0A40 800AFE40 0323C823 */ subu $t9, $t9, $v1 -/* 0B0A44 800AFE44 0302C023 */ subu $t8, $t8, $v0 -/* 0B0A48 800AFE48 01E67823 */ subu $t7, $t7, $a2 -/* 0B0A4C 800AFE4C 000F7840 */ sll $t7, $t7, 1 -/* 0B0A50 800AFE50 0018C040 */ sll $t8, $t8, 1 -/* 0B0A54 800AFE54 0019C840 */ sll $t9, $t9, 1 -/* 0B0A58 800AFE58 27A2001A */ addiu $v0, $sp, 0x1a -/* 0B0A5C 800AFE5C 01D94821 */ addu $t1, $t6, $t9 -/* 0B0A60 800AFE60 01D84021 */ addu $t0, $t6, $t8 -/* 0B0A64 800AFE64 01CF3821 */ addu $a3, $t6, $t7 -.L800AFE68: -/* 0B0A68 800AFE68 84ED0000 */ lh $t5, ($a3) -/* 0B0A6C 800AFE6C 850F0000 */ lh $t7, ($t0) -/* 0B0A70 800AFE70 24A50002 */ addiu $a1, $a1, 2 -/* 0B0A74 800AFE74 24E70002 */ addiu $a3, $a3, 2 -/* 0B0A78 800AFE78 01AFC021 */ addu $t8, $t5, $t7 -/* 0B0A7C 800AFE7C 07010003 */ bgez $t8, .L800AFE8C -/* 0B0A80 800AFE80 00187043 */ sra $t6, $t8, 1 -/* 0B0A84 800AFE84 27010001 */ addiu $at, $t8, 1 -/* 0B0A88 800AFE88 00017043 */ sra $t6, $at, 1 -.L800AFE8C: -/* 0B0A8C 800AFE8C A4AEFFFE */ sh $t6, -2($a1) -/* 0B0A90 800AFE90 852D0000 */ lh $t5, ($t1) -/* 0B0A94 800AFE94 84F9FFFE */ lh $t9, -2($a3) -/* 0B0A98 800AFE98 25080002 */ addiu $t0, $t0, 2 -/* 0B0A9C 800AFE9C 25290002 */ addiu $t1, $t1, 2 -/* 0B0AA0 800AFEA0 032D7821 */ addu $t7, $t9, $t5 -/* 0B0AA4 800AFEA4 05E10003 */ bgez $t7, .L800AFEB4 -/* 0B0AA8 800AFEA8 000FC043 */ sra $t8, $t7, 1 -/* 0B0AAC 800AFEAC 25E10001 */ addiu $at, $t7, 1 -/* 0B0AB0 800AFEB0 0001C043 */ sra $t8, $at, 1 -.L800AFEB4: -/* 0B0AB4 800AFEB4 14A2FFEC */ bne $a1, $v0, .L800AFE68 -/* 0B0AB8 800AFEB8 A4B80004 */ sh $t8, 4($a1) -/* 0B0ABC 800AFEBC 8FA40030 */ lw $a0, 0x30($sp) -/* 0B0AC0 800AFEC0 00001825 */ move $v1, $zero -/* 0B0AC4 800AFEC4 240C01E0 */ li $t4, 480 -/* 0B0AC8 800AFEC8 24860010 */ addiu $a2, $a0, 0x10 -/* 0B0ACC 800AFECC 24880020 */ addiu $t0, $a0, 0x20 -/* 0B0AD0 800AFED0 248A0030 */ addiu $t2, $a0, 0x30 -.L800AFED4: -/* 0B0AD4 800AFED4 87B90014 */ lh $t9, 0x14($sp) -/* 0B0AD8 800AFED8 00031100 */ sll $v0, $v1, 4 -/* 0B0ADC 800AFEDC 00822821 */ addu $a1, $a0, $v0 -/* 0B0AE0 800AFEE0 A0B9000C */ sb $t9, 0xc($a1) -/* 0B0AE4 800AFEE4 87AD0016 */ lh $t5, 0x16($sp) -/* 0B0AE8 800AFEE8 00C23821 */ addu $a3, $a2, $v0 -/* 0B0AEC 800AFEEC 01024821 */ addu $t1, $t0, $v0 -/* 0B0AF0 800AFEF0 A0AD000D */ sb $t5, 0xd($a1) -/* 0B0AF4 800AFEF4 87AF0018 */ lh $t7, 0x18($sp) -/* 0B0AF8 800AFEF8 01425821 */ addu $t3, $t2, $v0 -/* 0B0AFC 800AFEFC 24630030 */ addiu $v1, $v1, 0x30 -/* 0B0B00 800AFF00 A0AF000E */ sb $t7, 0xe($a1) -/* 0B0B04 800AFF04 87B8001A */ lh $t8, 0x1a($sp) -/* 0B0B08 800AFF08 A0F8000C */ sb $t8, 0xc($a3) -/* 0B0B0C 800AFF0C 87AE001C */ lh $t6, 0x1c($sp) -/* 0B0B10 800AFF10 A0EE000D */ sb $t6, 0xd($a3) -/* 0B0B14 800AFF14 87B9001E */ lh $t9, 0x1e($sp) -/* 0B0B18 800AFF18 A0F9000E */ sb $t9, 0xe($a3) -/* 0B0B1C 800AFF1C 87AD0014 */ lh $t5, 0x14($sp) -/* 0B0B20 800AFF20 A12D000C */ sb $t5, 0xc($t1) -/* 0B0B24 800AFF24 87AF0016 */ lh $t7, 0x16($sp) -/* 0B0B28 800AFF28 A12F000D */ sb $t7, 0xd($t1) -/* 0B0B2C 800AFF2C 87B80018 */ lh $t8, 0x18($sp) -/* 0B0B30 800AFF30 A138000E */ sb $t8, 0xe($t1) -/* 0B0B34 800AFF34 87AE001A */ lh $t6, 0x1a($sp) -/* 0B0B38 800AFF38 A16E000C */ sb $t6, 0xc($t3) -/* 0B0B3C 800AFF3C 87B9001C */ lh $t9, 0x1c($sp) -/* 0B0B40 800AFF40 A179000D */ sb $t9, 0xd($t3) -/* 0B0B44 800AFF44 87AD001E */ lh $t5, 0x1e($sp) -/* 0B0B48 800AFF48 146CFFE2 */ bne $v1, $t4, .L800AFED4 -/* 0B0B4C 800AFF4C A16D000E */ sb $t5, 0xe($t3) -/* 0B0B50 800AFF50 03E00008 */ jr $ra -/* 0B0B54 800AFF54 27BD0030 */ addiu $sp, $sp, 0x30 diff --git a/src/code_800AF9B0.c b/src/code_800AF9B0.c index d2d10ad70..07c2222ff 100644 --- a/src/code_800AF9B0.c +++ b/src/code_800AF9B0.c @@ -125,44 +125,30 @@ void func_800AFC54(Vtx *arg0, s32 arg1, s32 arg2, s32 arg3, s16 arg4[3]) { GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800AFC54.s") #endif -void func_800AFE00(Vtx *arg0, s16 (*arg1)[3], s32 arg2, s32 arg3); -#ifdef NON_MATCHING -// guessing on the Vtx kind again void func_800AFE00(Vtx *arg0, Vec3s *arg1, s32 arg2, s32 arg3) { - s32 idx1; // v0 - s32 idx2; // v0 - s32 i, j; - s16 sp14[6]; + s32 idx1; + s32 idx2; + s32 i; + Vtx *vtx; + s16 sp14[2][3]; - if (arg2 == 0) { - idx1 = 0; - } else { - idx1 = arg2 - 1; + idx1 = (arg2 == 0) ? 0 : arg2 - 1; + idx2 = (arg2 == arg3) ? arg3 : arg2 + 1; + + for (i = 0; i < 3; i++) { + sp14[0][i] = (arg1[idx1][i] + arg1[arg2][i]) / 2; + sp14[1][i] = (arg1[idx2][i] + arg1[arg2][i]) / 2; } - if (arg2 == arg3) { - idx2 = arg3; - } else { - idx2 = arg2 + 1; - } - - for (i = 0; i != 3; i++) { - sp14[i + 0] = (arg1[arg2][i] + arg1[idx1][i]) / 2; - sp14[i + 3] = (arg1[arg2][i] + arg1[idx2][i - 1]) / 2; - } - - for (i = 0; i < 30; i += 4) { - for (j = 0; j < 4; j++) { - s16 *v = &sp14[(j&1)*3]; - (arg0[i+j]).v.cn[0] = v[0]; - (arg0[i+j]).v.cn[1] = v[1]; - (arg0[i+j]).v.cn[2] = v[2]; + for (idx2 = 0; idx2 < 0x1E0; idx2 += 0x30) { + for (i = 0; i < 4; i++) { + vtx = &arg0[i]; + vtx[idx2 / 1].v.cn[0] = sp14[i % 2][0]; + vtx[idx2 / 1].v.cn[1] = sp14[i % 2][1]; + vtx[idx2 / 1].v.cn[2] = sp14[i % 2][2]; } } } -#else -GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800AFE00.s") -#endif void func_800AFF58(Vtx *arg0) { UNUSED u32 pad88[26]; From a66a6fd0091161bd4864f25ce4794397058eefcb Mon Sep 17 00:00:00 2001 From: MegaMech Date: Wed, 1 May 2024 11:35:05 -0600 Subject: [PATCH 7/9] Add an attempt for synthesis_process_notes (#632) * Update synthesis.c with attempt --- src/audio/synthesis.c | 625 ++++++++++++++++++++++-------------------- src/audio/synthesis.h | 2 +- 2 files changed, 330 insertions(+), 297 deletions(-) diff --git a/src/audio/synthesis.c b/src/audio/synthesis.c index 56f3e2a6d..b688bb061 100644 --- a/src/audio/synthesis.c +++ b/src/audio/synthesis.c @@ -324,86 +324,62 @@ Acmd *synthesis_do_one_audio_update(s16 *aiBuf, s32 bufLen, Acmd *acmd, s32 upda return acmd; } -#ifdef MIPS_TO_C +#ifdef NON_MATCHING //generated by m2c commit beb457dabfc7a01ec6540a5404a6a05097a13602 on Nov-01-2023 -Acmd *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s16 *aiBuf, s32 bufLen, Acmd *acmd, s32 updateIndex) { - void *sp130; - void *sp12C; - s32 *sp128; - s32 sp11C; - s32 sp118; - s32 sp114; /* compiler-managed */ - u16 sp112; - s32 spFC; - s32 spEC; - u32 spE4; - s32 spDC; - s32 spD8; - s32 spB0; - s32 spAC; - s32 spA0; /* compiler-managed */ - u16 sp9E; - struct Note *sp8C; - u32 sp50; - Acmd *temp_a0_2; - Acmd *temp_s2; - Acmd *temp_s2_2; - Acmd *temp_s2_3; - Acmd *temp_v0_2; - Acmd *temp_v0_3; - Acmd *temp_v0_4; - Acmd *temp_v0_5; - Acmd *temp_v0_6; - Acmd *temp_v0_8; - Acmd *var_s2; - Acmd *var_s2_2; - s16 var_t1; - s32 *temp_a2_2; - s32 temp_a0; - s32 temp_a1_2; - s32 temp_a2; - s32 temp_a2_3; - s32 temp_a2_4; - s32 temp_t6; - s32 temp_t8; - s32 temp_t9_2; - s32 temp_v0_7; - s32 temp_v1; - s32 var_a0; - s32 var_a2; - s32 var_a3; - s32 var_fp; - s32 var_s0_2; - s32 var_s1; - s32 var_s3; - s32 var_s4; - s32 var_s5; - s32 var_s6; - s32 var_t0; - s32 var_t2; - s32 var_t3; - s32 var_t4; - s32 var_v1; - u16 temp_t7; - u16 temp_v0; - u32 temp_a1_3; - u32 temp_s0; - u32 temp_t7_3; - u32 var_s0; - u32 var_t5; - u32 var_t6; - u32 var_v1_2; - u32 var_v1_3; - void *temp_a1; - void *temp_t7_2; - void *temp_t9; - void *var_a0_2; +u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s16 *aiBuf, s32 inBuf, u64 *cmd, s32 updateIndex) { + s32 pad[4]; + struct AudioBankSample *audioBookSample; + s16 *curLoadedBook; + struct AdpcmLoop *loopInfo; + s32 noteFinished; + s32 restart; + s32 flags; + u16 resamplingRateFixedPoint; + s32 nSamplesToLoad; - sp128 = NULL; - sp8C = &gNotes[noteIndex]; - var_v1 = 0; - if (((u32) (noteSubEu->unk0 * 2) >> 0x1F) == 1) { - var_v1 = 1; + s32 spFC; + s32 pad2[2]; + + s32 loopInfo_2; + u8 *sampleAddr; + s32 a1; + + + s32 samplesLenAdjusted; + s32 nAdpcmSamplesProcessed; + s32 endPos; + s32 nSamplesToProcess; + + s32 pad3; + + //u32 spE4; + s32 s3; + s32 leftRight; + s32 s4; + u32 samplesLenFixedPoint; + s32 var_s6; + s32 nSamplesInThisIteration; + u32 var_t2; + u8 *var_a0_2; + + //s32 spD8; + s32 s5Aligned; + s32 temp_t6; + s32 nParts; + s32 curPart; + s32 aligned; + s32 pad4; + s32 resampledTempLen; /* compiler-managed */ + u16 noteSamplesDmemAddrBeforeResampling; + s32 pad6[1]; + struct Note *note; + u16 addr; + + curLoadedBook = NULL; + note = &gNotes[noteIndex]; + flags = 0; + if (noteSubEu->needsInit == TRUE) { + flags = A_INIT; synthesisState->restart = 0; synthesisState->samplePosInt = 0; synthesisState->samplePosFrac = 0; @@ -411,259 +387,316 @@ Acmd *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct synthesisState->curVolRight = 0; synthesisState->prevHeadsetPanRight = 0; synthesisState->prevHeadsetPanLeft = 0; + //synthesisState->reverbVol = noteSubEu->reverbVol; + ////synthesisState->unk5 = 0; + //note->noteSubEu.finished = 0; } - temp_t7 = noteSubEu->resamplingRateFixedPoint; - sp112 = temp_t7; - spB0 = ((u16) noteSubEu->unk0 & 1) + 1; - temp_v0 = (temp_t7 * bufLen * 2) + synthesisState->samplePosFrac; - synthesisState->samplePosFrac = temp_v0; - temp_s0 = temp_v0 >> 0x10; - var_a0 = noteSubEu->unk0; - if (var_a0 & 0x20000) { - temp_v0_2 = load_wave_samples(acmd, noteSubEu, synthesisState, (s32) temp_s0); - temp_a2 = synthesisState->samplePosInt; - sp9E = (temp_a2 * 2) + 0x1A0; - synthesisState->samplePosInt = temp_a2 + temp_s0; - var_a0 = noteSubEu->unk0; - acmd = temp_v0_2; + resamplingRateFixedPoint = noteSubEu->resamplingRateFixedPoint; + + nParts = noteSubEu->hasTwoAdpcmParts + 1; + samplesLenFixedPoint = (resamplingRateFixedPoint * inBuf * 2) + synthesisState->samplePosFrac; + nSamplesToLoad = (samplesLenFixedPoint >> 0x10); + synthesisState->samplePosFrac = samplesLenFixedPoint & 0xFFFF; // m2c didn't have & 0xFFFF + +//var_a0 = noteSubEu->unk0; + if (noteSubEu->isSyntheticWave) { + cmd = load_wave_samples(cmd, noteSubEu, synthesisState, nSamplesToLoad); + + noteSamplesDmemAddrBeforeResampling = (synthesisState->samplePosInt * 2) + 0x1A0; // DMEM_ADDR_UNCOMPRESSED_NOTE + synthesisState->samplePosInt += nSamplesToLoad; } else { - temp_t7_2 = *noteSubEu->sound.samples; - sp130 = temp_t7_2; - temp_t9 = temp_t7_2->unk8; - sp12C = temp_t9; - spDC = temp_t9->unk4; - spA0 = 0; - spAC = 0; - spEC = temp_t7_2->unk4; - if (spB0 > 0) { - sp50 = temp_v0 >> 0x10; - sp114 = var_v1; - var_s2_2 = acmd; -loop_6: - temp_a1 = sp130->unkC; - var_fp = 0; - var_s4 = 0; - temp_a2_2 = temp_a1 + 8; - if (spB0 == 1) { - var_t5 = sp50; + audioBookSample = noteSubEu->sound.audioBankSound->sample; + //sp130 = audioBookSample; + loopInfo = audioBookSample->loop; + //sp12C = loopInfo; + endPos = loopInfo->end; + sampleAddr = audioBookSample->sampleAddr; // book? + resampledTempLen = 0; + //if (nParts > 0) { + // nSamplesToLoad = samplesLenFixedPoint >> 0x10; + // sp114 = flags; + // var_s2_2 = cmd; +//loop_6: + for (curPart = 0; curPart < nParts; curPart++) { + nAdpcmSamplesProcessed = 0; + s4 = 0; + + + //temp_a1 = audioBookSample->unkC; + //temp_a2_2 = temp_a1 + 8; + + if (nParts == 1) { + samplesLenAdjusted = nSamplesToLoad; + } else if (nSamplesToLoad & 1) { + samplesLenAdjusted = (nSamplesToLoad & ~1) + (curPart * 2); } else { - var_t5 = sp50; - if (sp50 & 1) { - var_t5 = (sp50 & ~1) + (spAC * 2); + samplesLenAdjusted = nSamplesToLoad; + } + // sm64 also has if (audioBookSample->codec == CODEC_A) { + if (curLoadedBook != (*audioBookSample->book).book) { + u32 nEntries; + //temp_v0_3 = var_s2_2; + // var_s2_2 += 8; + //temp_v0_3->unk0 = ((temp_a1->unk0 * 16 * temp_a1->unk4) & 0xFFFFFF) | 0x0B000000; + //temp_v0_3->unk4 = (s32) ((((u32) (noteSubEu->unk0 << 0xB) >> 0x1D) * 2) + temp_a2_2 + 0x80000000); + //var_a0 = noteSubEu->unk0; + curLoadedBook = audioBookSample->book->book; // or just one book? + nEntries = 16 * audioBookSample->book->order * audioBookSample->book->npredictors; + aLoadADPCM(cmd++, nEntries, VIRTUAL_TO_PHYSICAL2(noteSubEu->bookOffset+curLoadedBook)); + // noteSubEu here unsure but seems better? + } + if (noteSubEu->bookOffset != 0) { + curLoadedBook = &gUnknownData_800F6290; // type? + } + while (nAdpcmSamplesProcessed != samplesLenAdjusted) { +//loop_15: + s32 samplesRemaining; + s32 s1; + + noteFinished = FALSE; + restart = FALSE; + //temp_a2_3 = synthesisState->samplePosInt; + s3 = synthesisState->samplePosInt & 0xF; + samplesRemaining = endPos - synthesisState->samplePosInt; + nSamplesToProcess = samplesLenAdjusted - nAdpcmSamplesProcessed; + if ((s3 == 0) && (synthesisState->restart == FALSE)) { + s3 = 16; } - } - if (sp128 != temp_a2_2) { - temp_v0_3 = var_s2_2; - var_s2_2 += 8; - temp_v0_3->words.w0 = ((temp_a1->unk0 * 0x10 * temp_a1->unk4) & 0xFFFFFF) | 0x0B000000; - temp_v0_3->words.w1 = (((u32) (noteSubEu->unk0 << 0xB) >> 0x1D) * 2) + temp_a2_2 + 0x80000000; - var_a0 = noteSubEu->unk0; - sp128 = temp_a2_2; - } - if (((u32) (var_a0 << 0xB) >> 0x1D) != 0) { - sp128 = gUnknownData_800F6290; - } - if (var_t5 != 0) { -loop_15: - temp_a2_3 = synthesisState->samplePosInt; - temp_a0 = var_t5 - var_fp; - var_s3 = temp_a2_3 & 0xF; - var_t3 = 0; - var_t4 = 0; - temp_v1 = spDC - temp_a2_3; - if ((var_s3 == 0) && (synthesisState->restart == 0)) { - var_s3 = 0x10; - } - temp_a1_2 = 0x10 - var_s3; - var_s5 = temp_a1_2; - if (temp_a0 < temp_v1) { - temp_t9_2 = (s32) ((temp_a0 - temp_a1_2) + 0xF) / 16; - var_s1 = temp_t9_2 * 0x10; - var_t0 = temp_t9_2; - var_s6 = (temp_a1_2 + var_s1) - temp_a0; + + a1 = 16 - s3; + //var_s5 = a1; + if (nSamplesToProcess < samplesRemaining) { + loopInfo_2 = ((nSamplesToProcess - a1) + 0xF) / 16; + s1 = loopInfo_2 * 16; + //var_t0 = loopInfo_2; + var_s6 = (a1 + s1) - nSamplesToProcess; } else { - var_s1 = temp_v1 - temp_a1_2; + s1 = samplesRemaining - a1; var_s6 = 0; - if (var_s1 <= 0) { - var_s1 = 0; - var_s5 = temp_v1; + if (s1 <= 0) { + s1 = 0; + a1 = samplesRemaining; } - var_t0 = (s32) (var_s1 + 0xF) / 16; - if (sp12C->unk8 != 0) { - var_t4 = 1; + loopInfo_2 = (s1 + 0xF) / 16; + if (loopInfo->count != 0) { + restart = 1; } else { - var_t3 = 1; + noteFinished = 1; } } - var_t2 = 0; - if (var_t0 != 0) { - temp_t6 = (s32) ((temp_a2_3 - var_s3) + 0x10) / 16; - if (sp130->unk1 == 0x81) { - var_s0 = ((var_t0 * 9) + 0x1F) & ~0xF; - var_a0_2 = (temp_t6 * 9) + spEC; + //var_t2 = 0; // unsure + if (loopInfo_2 != 0) { + temp_t6 = ((synthesisState->samplePosInt - s3) + 16) / 16; // diff from sm64 sh + if (audioBookSample->loaded == 0x81) { // sm64 has audioBookSample->medium + //var_s0 = ((loopInfo_2 * 9) + 0x1F) & ~0xF; + var_a0_2 = (temp_t6 * 9) + sampleAddr; } else { - spD8 = temp_a0; - sp11C = var_t3; - sp118 = var_t4; - spE4 = var_t5; - temp_a1_3 = ((var_t0 * 9) + 0x1F) & ~0xF; - var_s0 = temp_a1_3; - var_a0_2 = dma_sample_data((temp_t6 * 9) + spEC, temp_a1_3, sp114, &synthesisState->sampleDmaIndex); + //spD8 = nSamplesToProcess; + //sp11C = noteFinished; + //sp118 = restart; + //spE4 = samplesLenAdjusted; + //temp_a1_3 += ((loopInfo_2 * 9) + 0x1F) & ~0xF; + //var_s0 = temp_a1_3; + var_a0_2 = dma_sample_data((uintptr_t) (temp_t6 * 9) + sampleAddr, ALIGN(((loopInfo_2 * 9) + 16), 4), flags, &synthesisState->sampleDmaIndex); + // unsure flags? } - var_t1 = 0x540 - var_s0; - var_t2 = (s32) var_a0_2 & 0xF; - var_s2_2->words.w1 = (var_a0_2 - var_t2) + 0x80000000; - var_s2_2->words.w0 = ((((s32) var_s0 >> 4) & 0xFF) << 0x10) | 0x14000000 | (var_t1 & 0xFFFF); - var_s2_2 += 8; + //var_t1 = 0x540 - var_s0; + var_t2 = ((uintptr_t)var_a0_2 & 0xF); + + //var_s2_2->unk4 = (s32) ((var_a0_2 - var_t2) + 0x80000000); + + aligned = ALIGN(((loopInfo_2 * 9) + 16), 4); + addr = (0x540 - aligned) & 0xFFFF; // DMEM_ADDR_COMPRESSED_ADPCM_DATA + //var_s2_2->unk0 = (((var_s0 >> 4) & 0xFF) << 16) | 0x14000000 | ((0x540 - var_s0) & 0xFFFF); + // var_s2_2 += 8; + //aLoadBuffer(cmd++, ALIGN(((loopInfo_2 * 9) + 16), 4), addr, VIRTUAL_TO_PHYSICAL2(var_a0_2 - var_t2)); + aLoadBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(var_a0_2 - var_t2), addr, aligned); } else { - var_s1 = 0; - var_t1 = 0x540 - (((var_t0 * 9) + 0x1F) & 0xFFF0); + s1 = 0; // ? + var_t2 = 0; + //addr = 0x540 - (((loopInfo_2 * 9) + 16)); } - temp_v0_4 = var_s2_2; - if (synthesisState->restart != 0) { - temp_v0_4->words.w0 = 0x0F000000; - var_s2_2 += 8; - temp_v0_4->words.w1 = sp130->unk8 + 0x80000010; - sp114 = 2; - synthesisState->restart = 0; + //temp_v0_4 = var_s2_2; + if (synthesisState->restart != FALSE) { + aSetLoop(cmd++, VIRTUAL_TO_PHYSICAL2(audioBookSample->loop->state)); + //temp_v0_4->unk0 = 0x0F000000; + //var_s2_2 += 8; + //temp_v0_4->unk4 = (s32) (audioBookSample->unk8 + 0x80000010); + flags = A_LOOP; + synthesisState->restart = FALSE; } - if (var_fp == 0) { - var_a2 = var_s1 * 2; - var_s2_2->words.w1 = (var_a2 & 0xFFFF) | 0x01A00000; - var_s2_2->words.w0 = ((var_t1 + var_t2) & 0xFFFF) | 0x08000000; - temp_s2 = var_s2_2 + 8; - temp_s2->words.w0 = ((sp114 & 0xFF) << 0x10) | 0x01000000; - temp_s2->words.w1 = (u32) (synthesisState->synthesisBuffers + 0x80000000); - var_s2_2 = temp_s2 + 8; - spFC = var_s3 * 2; - var_a3 = (var_s1 + var_s5) - var_s6; + nSamplesInThisIteration = (s1 + a1) - var_s6; + s5Aligned = ALIGN(s4 + 16, 4); + if (nAdpcmSamplesProcessed == 0) { + //var_a2 = s1 * 2; + //var_s2_2->unk4 = (s32) ((var_a2 & 0xFFFF) | 0x01A00000); + ///var_s2_2->unk0 = ((var_t1 + var_t2) & 0xFFFF) | 0x08000000; + //temp_s2 = var_s2_2 + 8; + //temp_s2->unk0 = (s32) (((sp114 & 0xFF) << 0x10) | 0x01000000); + //temp_s2->unk4 = (s32) VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->adpcmdecState); + //var_s2_2 = temp_s2 + 8; + //spFC = s3 * 2; + aligned = ALIGN(((loopInfo_2 * 9) + 16), 4); + addr = (0x540 - aligned) & 0xFFFF; + aSetBuffer(cmd++, 0, addr + var_t2, 0x1A0, s1 * 2); // unsure + // s1 or s3 here? + aADPCMdec(cmd++, flags, VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->adpcmdecState)); + spFC = s3 * 2; + //nSamplesInThisIteration = (s1 + a1) - var_s6; } else { - temp_t8 = (var_s4 + 0x1F) & ~0xF; - var_s2_2->words.w0 = ((var_t1 + var_t2) & 0xFFFF) | 0x08000000; - var_a2 = var_s1 * 2; - var_s2_2->words.w1 = ((temp_t8 + 0x1A0) << 0x10) | (var_a2 & 0xFFFF); - temp_s2_2 = var_s2_2 + 8; - temp_s2_2->words.w0 = ((sp114 & 0xFF) << 0x10) | 0x01000000; - temp_s2_2->words.w1 = (u32) (synthesisState->synthesisBuffers + 0x80000000); - temp_s2_3 = temp_s2_2 + 8; - var_a3 = (var_s1 + var_s5) - var_s6; - temp_s2_3->words.w0 = ((temp_t8 + (var_s3 * 2) + 0x1A0) & 0xFFFFFF) | 0x0A000000; - temp_s2_3->words.w1 = ((var_s4 + 0x1A0) << 0x10) | ((var_a3 * 2) & 0xFFFF); - var_s2_2 = temp_s2_3 + 8; + // temp_t8 = (s4 + 0x1F) & ~0xF; + // var_s2_2->unk0 = ((var_t1 + var_t2) & 0xFFFF) | 0x08000000; + // var_a2 = s1 * 2; + // var_s2_2->unk4 = (s32) (((temp_t8 + 0x1A0) << 0x10) | (var_a2 & 0xFFFF)); + // temp_s2_2 = var_s2_2 + 8; + // temp_s2_2->unk0 = (s32) (((sp114 & 0xFF) << 0x10) | 0x01000000); + // temp_s2_2->unk4 = (s32) VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->adpcmdecState); + // temp_s2_3 = temp_s2_2 + 8; + // temp_s2_3->unk0 = (s32) (((temp_t8 + (s3 * 2) + 0x1A0) & 0xFFFFFF) | 0x0A000000); + // temp_s2_3->unk4 = (s32) (((s4 + 0x1A0) << 0x10) | ((nSamplesInThisIteration * 2) & 0xFFFF)); + // var_s2_2 = temp_s2_3 + 8; + aligned = ALIGN(((loopInfo_2 * 9) + 16), 4); + addr = (0x540 - aligned) & 0xFFFF; + aSetBuffer(cmd++, 0, addr + var_t2, 0x1A0 + s5Aligned, s1 * 2); // unsure + + // The real macro here. Decompme requires the below to work. + //aS8Dec(cmd++, flags, VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->adpcmdecState)); + aADPCMdec(cmd++, flags, VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->adpcmdecState)); + // {\ + // Acmd *_a = (Acmd *) (cmd++);\ + // _a->words.w0 = _SHIFTL(23, 24, 8) | _SHIFTL(flags, 16, 8);\ + // _a->words.w1 = (uintptr_t) VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->adpcmdecState);\ + // }; + //nSamplesInThisIteration = (s1 + a1) - var_s6; + aDMEMMove(cmd++, 0x1A0 + s5Aligned + (s3 * 2), 0x1A0 + s4, nSamplesInThisIteration * 2); } - var_fp += var_a3; - if (sp114 != 1) { - sp114 = 0; - if ((sp114 ^ 2) != 0) { - if (var_s4 != 0) { - var_s4 += var_a3 * 2; + + nAdpcmSamplesProcessed += nSamplesInThisIteration; + switch(flags) { + case 1: + spFC = 0x20; + s4 = (s1 * 2) + 0x20; + break; + case 2: + s4 += nSamplesInThisIteration * 2; + break; + default: + if (s4 != 0) { + s4 += nSamplesInThisIteration * 2; } else { - var_s4 = (var_s3 + var_a3) * 2; + s4 = (s3 + nSamplesInThisIteration) * 2; } - } else { - var_s4 += var_a3 * 2; - } - } else { - spFC = 0x00000020; - var_s4 = var_a2 + 0x20; - sp114 = 0; + break; } - if (var_t3 != 0) { - var_s2_2->words.w0 = ((var_s4 + 0x1A0) & 0xFFFFFF) | 0x02000000; - var_s2_2->words.w1 = (var_t5 - var_fp) * 2; - var_s2_2 += 8; - noteSubEu->unk0 = (s8) ((u8) noteSubEu->unk0 | 0x20); + flags = 0; + + if (noteFinished) { + aClearBuffer(cmd++, 0x1A0 + s4, + (samplesLenAdjusted - nAdpcmSamplesProcessed) * 2); + //var_s2_2->unk0 = ((s4 + 0x1A0) & 0xFFFFFF) | 0x02000000; + //var_s2_2->unk4 = (s32) ((samplesLenAdjusted - nAdpcmSamplesProcessed) * 2); + //var_s2_2 += 8; + noteSubEu->finished = 1; // sm64 says = 1 + note->noteSubEu.finished = 1; + //note->noteSubEu.enabled = 0; + //note->noteSubEu.samplePosInt = 0; + + //note->noteSubEu.stereoHeadsetEffects = note->noteSubEu.stereoHeadsetEffects | 0x20;// |= 0x20; + //note->noteSubEu.stereoHeadsetEffects = ~(1 << 6); + /* mips to c + arg1->unk0 = (s8) ((u8) arg1->unk0 | 0x20); sp8C->unkB0 = (u8) (sp8C->unkB0 | 0x20); sp8C->unkB0 = (u8) (sp8C->unkB0 & 0xFF7F); - spE4 = var_t5; + */ + //spE4 = samplesLenAdjusted; + func_800B6FB4(updateIndex, noteIndex); } else { - if (var_t4 != 0) { - synthesisState->restart = 1; - synthesisState->samplePosInt = sp12C->unk0; + if (restart) { + synthesisState->restart = TRUE; + synthesisState->samplePosInt = loopInfo->start; } else { - synthesisState->samplePosInt += temp_a0; - } - if (var_fp != var_t5) { - goto loop_15; + synthesisState->samplePosInt += nSamplesToProcess; } + // if (nAdpcmSamplesProcessed != samplesLenAdjusted) { + // goto loop_15; + // } } } - if (spB0 != 1) { - if (spB0 != 2) { - var_a0 = noteSubEu->unk0; - var_t6 = (u32) (var_a0 * 4) >> 0x1F; - goto block_60; - } - if (spAC != 0) { - temp_v0_5 = var_s2_2; - if (spAC != 1) { - var_a0 = noteSubEu->unk0; - var_v1_2 = (u32) (var_a0 * 4) >> 0x1F; - } else { - var_s2_2 += 8; - temp_v0_5->words.w0 = ((((s32) var_t5 / 2) + 7) & 0xFFF8) | 0x11000000; - temp_v0_5->words.w1 = ((spFC + 0x1A0) << 0x10) | ((spA0 + 0x20) & 0xFFFF); - var_a0 = noteSubEu->unk0; - var_t6 = (u32) (var_a0 * 4) >> 0x1F; - goto block_60; - } - } else { - temp_v0_6 = var_s2_2; - var_s2_2 += 8; - temp_v0_6->words.w0 = ((((s32) var_t5 / 2) + 7) & 0xFFF8) | 0x11000000; - temp_v0_6->words.w1 = ((spFC + 0x1A0) << 0x10) | 0x20; - spA0 = var_t5; - sp9E = 0x0020; - var_a0 = noteSubEu->unk0; - temp_t7_3 = (u32) (var_a0 * 4) >> 0x1F; - var_v1_2 = temp_t7_3; - if (temp_t7_3 != 0) { - var_s2_2->words.w1 = var_t5 + 0x10; - var_s2_2->words.w0 = ((var_t5 + 0x20) & 0xFFFFFF) | 0x02000000; - var_a0 = noteSubEu->unk0; - var_s2_2 += 8; - var_v1_2 = (u32) (var_a0 * 4) >> 0x1F; - } - } - } else { - sp9E = spFC + 0x1A0; - var_a0 = noteSubEu->unk0; - var_t6 = (u32) (var_a0 * 4) >> 0x1F; -block_60: - var_v1_2 = var_t6; - } - if (var_v1_2 != 0) { - } else { - temp_v0_7 = spAC + 1; - spAC = temp_v0_7; - if (temp_v0_7 != spB0) { - goto loop_6; - } + switch(nParts) { + case 1: + noteSamplesDmemAddrBeforeResampling = 0x1A0 + spFC; + break; + case 2: + //temp_v0_5 = var_s2_2; + switch(curPart) { + case 0: + // temp_v0_6 = var_s2_2; + // var_s2_2 += 8; + // temp_v0_6->unk0 = ((((s32) var_t5 / 2) + 7) & 0xFFF8) | 0x11000000; + // temp_v0_6->unk4 = (s32) (((spFC + 0x1A0) << 0x10) | 0x20); + // spA0 = var_t5; + // sp9E = 0x20; + // var_a0 = arg1->unk0; + // temp_t7_3 = (u32) (var_a0 * 4) >> 0x1F; + // var_v1_2 = temp_t7_3; + // if (temp_t7_3 != 0) { + // var_s2_2->unk4 = (s32) (var_t5 + 0x10); + // var_s2_2->unk0 = ((var_t5 + 0x20) & 0xFFFFFF) | 0x02000000; + // var_a0 = arg1->unk0; + // var_s2_2 += 8; + // var_v1_2 = (u32) (var_a0 * 4) >> 0x1F; + // } + aDownsampleHalf(cmd++, ALIGN(samplesLenAdjusted / 2, 3), 0x1A0 + spFC, DMEM_ADDR_RESAMPLED); + resampledTempLen = samplesLenAdjusted; + noteSamplesDmemAddrBeforeResampling = DMEM_ADDR_RESAMPLED; + if (noteSubEu->finished != FALSE) { + aClearBuffer(cmd++, noteSamplesDmemAddrBeforeResampling + resampledTempLen, samplesLenAdjusted + 0x10); + } + break; + case 1: + //var_s2_2 += 8; + // temp_v0_5->unk0 = ((((s32) var_t5 / 2) + 7) & 0xFFF8) | 0x11000000; + // temp_v0_5->unk4 = (s32) (((spFC + 0x1A0) << 0x10) | ((spA0 + 0x20) & 0xFFFF)); + // var_a0 = arg1->unk0; + // var_t6 = (u32) (var_a0 * 4) >> 0x1F; + aDownsampleHalf(cmd++, ALIGN(samplesLenAdjusted / 2, 3), DMEM_ADDR_RESAMPLED2 + spFC, resampledTempLen + DMEM_ADDR_RESAMPLED); + break; + + } + break; + } + if (noteSubEu->finished != FALSE) { + break; } - acmd = var_s2_2; } } - var_v1_3 = 0; - if (((u32) (var_a0 * 2) >> 0x1F) == 1) { - var_v1_3 = 1; - noteSubEu->unk0 = (s8) ((u8) noteSubEu->unk0 & 0xFFBF); + flags = 0; + if (noteSubEu->needsInit == TRUE) { + flags = A_INIT; + noteSubEu->needsInit = FALSE; } - temp_a2_4 = bufLen * 2; - sp114 = var_v1_3; - temp_a0_2 = final_resample(acmd, synthesisState, temp_a2_4, sp112, (u16) (s32) sp9E, var_v1_3); - if ((noteSubEu->headsetPanRight != 0) || (synthesisState->prevHeadsetPanRight != 0)) { - var_s0_2 = 1; - } else if ((noteSubEu->headsetPanLeft != 0) || (var_s0_2 = 0, (synthesisState->prevHeadsetPanLeft != 0))) { - var_s0_2 = 2; + //temp_a2_4 = inBuf * 2; + // flags = flags; + //sp114 = flags; + //flags = flags | sp54; + cmd = final_resample(cmd, synthesisState, inBuf * 2, resamplingRateFixedPoint, noteSamplesDmemAddrBeforeResampling, flags); + + if ((noteSubEu->headsetPanRight) || (synthesisState->prevHeadsetPanRight)) { + leftRight = 1; // According to m2c this is a new var. Perhaps flags? + } else if ((noteSubEu->headsetPanLeft) || (synthesisState->prevHeadsetPanLeft)) { + leftRight = 2; + } else { + leftRight = 0; } - temp_v0_8 = func_800B86A0(temp_a0_2, noteSubEu, synthesisState, bufLen, (u16) 0, var_s0_2, sp114); - var_s2 = temp_v0_8; - if ((u8) noteSubEu->unk0 & 1) { - var_s2 = note_apply_headset_pan_effects(temp_v0_8, noteSubEu, synthesisState, temp_a2_4, (s32) sp114, var_s0_2); + cmd = func_800B86A0(cmd, noteSubEu, synthesisState, inBuf, 0, leftRight, flags); + //var_s2 = temp_v0_8; + if (noteSubEu->usesHeadsetPanEffects) { + //synthesisState->restart = 1; + cmd = note_apply_headset_pan_effects(cmd, noteSubEu, synthesisState, inBuf * 2, flags, leftRight); } - return var_s2; + return cmd; } #else GLOBAL_ASM("asm/non_matchings/audio/synthesis/synthesis_process_note.s") diff --git a/src/audio/synthesis.h b/src/audio/synthesis.h index 974fc9c32..9d8de57a9 100644 --- a/src/audio/synthesis.h +++ b/src/audio/synthesis.h @@ -103,7 +103,7 @@ Acmd *synthesis_execute(Acmd*, s32*, s16*, s32); Acmd *synthesis_resample_and_mix_reverb(Acmd*, s32, s16, s16); Acmd *synthesis_save_reverb_samples(Acmd*, s16, s16); Acmd *synthesis_do_one_audio_update(s16*, s32, Acmd*, s32); -Acmd *synthesis_process_note(s32, struct NoteSubEu*, struct NoteSynthesisState*, s16*, s32, Acmd*, s32); +u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s16 *aiBuf, s32 inBuf, u64 *cmd, s32 updateIndex); Acmd *load_wave_samples(Acmd *acmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s32 nSamplesToLoad); Acmd *final_resample(Acmd *acmd, struct NoteSynthesisState *synthesisState, s32 count, u16 pitch, u16 dmemIn, u32 flags); Acmd *func_800B86A0(Acmd *cmd, struct NoteSubEu *note, struct NoteSynthesisState *synthesisState, s32 nSamples, u16 inBuf, s32 headsetPanSettings, u32 flags); From f5d8147d4bbe44c64903c9e6627b9a5dd7d2eb26 Mon Sep 17 00:00:00 2001 From: MegaMech Date: Wed, 1 May 2024 19:19:02 -0600 Subject: [PATCH 8/9] Update Attempts and cleanup synthesis_process_notes (#633) * Update code_80005FD0.c --- .../code_80005FD0/func_800074D4.s | 498 ------------------ .../code_80005FD0/func_80007D04.s | 181 ------- src/audio/data.c | 6 +- src/audio/data.h | 2 +- src/audio/synthesis.c | 146 +---- src/audio/synthesis.h | 2 +- src/code_80005FD0.c | 161 +++--- 7 files changed, 101 insertions(+), 895 deletions(-) delete mode 100644 asm/non_matchings/code_80005FD0/func_800074D4.s delete mode 100644 asm/non_matchings/code_80005FD0/func_80007D04.s diff --git a/asm/non_matchings/code_80005FD0/func_800074D4.s b/asm/non_matchings/code_80005FD0/func_800074D4.s deleted file mode 100644 index 748d3493e..000000000 --- a/asm/non_matchings/code_80005FD0/func_800074D4.s +++ /dev/null @@ -1,498 +0,0 @@ -glabel func_800074D4 -/* 0080D4 800074D4 27BDFF70 */ addiu $sp, $sp, -0x90 -/* 0080D8 800074D8 3C048016 */ lui $a0, %hi(gCourseCompletionPercentByRank) # $a0, 0x8016 -/* 0080DC 800074DC 44800000 */ mtc1 $zero, $f0 -/* 0080E0 800074E0 AFB1000C */ sw $s1, 0xc($sp) -/* 0080E4 800074E4 AFB00008 */ sw $s0, 8($sp) -/* 0080E8 800074E8 240A0008 */ li $t2, 8 -/* 0080EC 800074EC 24842FD8 */ addiu $a0, %lo(gCourseCompletionPercentByRank) # addiu $a0, $a0, 0x2fd8 -/* 0080F0 800074F0 24070001 */ li $a3, 1 -/* 0080F4 800074F4 24020009 */ li $v0, 9 -.L800074F8: -/* 0080F8 800074F8 24E70001 */ addiu $a3, $a3, 1 -/* 0080FC 800074FC 00E2082A */ slt $at, $a3, $v0 -/* 008100 80007500 E4800000 */ swc1 $f0, ($a0) -/* 008104 80007504 1420FFFC */ bnez $at, .L800074F8 -/* 008108 80007508 24840004 */ addiu $a0, $a0, 4 -/* 00810C 8000750C 00001025 */ move $v0, $zero -/* 008110 80007510 10000025 */ b .L800075A8 -/* 008114 80007514 00004025 */ move $t0, $zero -/* 008118 80007518 000070C0 */ sll $t6, $zero, 3 -/* 00811C 8000751C 01C07023 */ subu $t6, $t6, $zero -/* 008120 80007520 000E7100 */ sll $t6, $t6, 4 -/* 008124 80007524 01C07023 */ subu $t6, $t6, $zero -/* 008128 80007528 000E7080 */ sll $t6, $t6, 2 -/* 00812C 8000752C 01C07023 */ subu $t6, $t6, $zero -/* 008130 80007530 3C0F800F */ lui $t7, %hi(gPlayers) # $t7, 0x800f -/* 008134 80007534 25EF6990 */ addiu $t7, %lo(gPlayers) # addiu $t7, $t7, 0x6990 -/* 008138 80007538 000E70C0 */ sll $t6, $t6, 3 -/* 00813C 8000753C 3C0C8016 */ lui $t4, %hi(gCourseCompletionPercentByRank) # $t4, 0x8016 -/* 008140 80007540 3C098016 */ lui $t1, %hi(gTimePlayerLastTouchedFinishLine) # $t1, 0x8016 -/* 008144 80007544 2529F898 */ addiu $t1, %lo(gTimePlayerLastTouchedFinishLine) # addiu $t1, $t1, -0x768 -/* 008148 80007548 258C2FD8 */ addiu $t4, %lo(gCourseCompletionPercentByRank) # addiu $t4, $t4, 0x2fd8 -/* 00814C 8000754C 01CF2021 */ addu $a0, $t6, $t7 -/* 008150 80007550 00002825 */ move $a1, $zero -/* 008154 80007554 24070001 */ li $a3, 1 -/* 008158 80007558 27A60068 */ addiu $a2, $sp, 0x68 -.L8000755C: -/* 00815C 8000755C 94980000 */ lhu $t8, ($a0) -/* 008160 80007560 00021880 */ sll $v1, $v0, 2 -/* 008164 80007564 00C37021 */ addu $t6, $a2, $v1 -/* 008168 80007568 33190800 */ andi $t9, $t8, 0x800 -/* 00816C 8000756C 13200009 */ beqz $t9, .L80007594 -/* 008170 80007570 24840DD8 */ addiu $a0, $a0, 0xdd8 -/* 008174 80007574 00087880 */ sll $t7, $t0, 2 -/* 008178 80007578 012FC021 */ addu $t8, $t1, $t7 -/* 00817C 8000757C ADC80000 */ sw $t0, ($t6) -/* 008180 80007580 C7040000 */ lwc1 $f4, ($t8) -/* 008184 80007584 0183C821 */ addu $t9, $t4, $v1 -/* 008188 80007588 24420001 */ addiu $v0, $v0, 1 -/* 00818C 8000758C 46002187 */ neg.s $f6, $f4 -/* 008190 80007590 E7260000 */ swc1 $f6, ($t9) -.L80007594: -/* 008194 80007594 00E04025 */ move $t0, $a3 -/* 008198 80007598 14A7FFF0 */ bne $a1, $a3, .L8000755C -/* 00819C 8000759C 24E70001 */ addiu $a3, $a3, 1 -/* 0081A0 800075A0 240B0008 */ li $t3, 8 -/* 0081A4 800075A4 110B0049 */ beq $t0, $t3, .L800076CC -.L800075A8: -/* 0081A8 800075A8 000870C0 */ sll $t6, $t0, 3 -/* 0081AC 800075AC 01C87023 */ subu $t6, $t6, $t0 -/* 0081B0 800075B0 000E7100 */ sll $t6, $t6, 4 -/* 0081B4 800075B4 01C87023 */ subu $t6, $t6, $t0 -/* 0081B8 800075B8 000E7080 */ sll $t6, $t6, 2 -/* 0081BC 800075BC 01C87023 */ subu $t6, $t6, $t0 -/* 0081C0 800075C0 3C0F800F */ lui $t7, %hi(gPlayers) # $t7, 0x800f -/* 0081C4 800075C4 25EF6990 */ addiu $t7, %lo(gPlayers) # addiu $t7, $t7, 0x6990 -/* 0081C8 800075C8 000E70C0 */ sll $t6, $t6, 3 -/* 0081CC 800075CC 3C098016 */ lui $t1, %hi(gTimePlayerLastTouchedFinishLine) # $t1, 0x8016 -/* 0081D0 800075D0 3C0C8016 */ lui $t4, %hi(gCourseCompletionPercentByRank) # $t4, 0x8016 -/* 0081D4 800075D4 258C2FD8 */ addiu $t4, %lo(gCourseCompletionPercentByRank) # addiu $t4, $t4, 0x2fd8 -/* 0081D8 800075D8 2529F898 */ addiu $t1, %lo(gTimePlayerLastTouchedFinishLine) # addiu $t1, $t1, -0x768 -/* 0081DC 800075DC 01CF2021 */ addu $a0, $t6, $t7 -/* 0081E0 800075E0 27A60068 */ addiu $a2, $sp, 0x68 -.L800075E4: -/* 0081E4 800075E4 94980000 */ lhu $t8, ($a0) -/* 0081E8 800075E8 00021880 */ sll $v1, $v0, 2 -/* 0081EC 800075EC 00C37021 */ addu $t6, $a2, $v1 -/* 0081F0 800075F0 33190800 */ andi $t9, $t8, 0x800 -/* 0081F4 800075F4 13200008 */ beqz $t9, .L80007618 -/* 0081F8 800075F8 00087880 */ sll $t7, $t0, 2 -/* 0081FC 800075FC ADC80000 */ sw $t0, ($t6) -/* 008200 80007600 012FC021 */ addu $t8, $t1, $t7 -/* 008204 80007604 C7080000 */ lwc1 $f8, ($t8) -/* 008208 80007608 0183C821 */ addu $t9, $t4, $v1 -/* 00820C 8000760C 24420001 */ addiu $v0, $v0, 1 -/* 008210 80007610 46004287 */ neg.s $f10, $f8 -/* 008214 80007614 E72A0000 */ swc1 $f10, ($t9) -.L80007618: -/* 008218 80007618 948E0DD8 */ lhu $t6, 0xdd8($a0) -/* 00821C 8000761C 00021880 */ sll $v1, $v0, 2 -/* 008220 80007620 00C3C821 */ addu $t9, $a2, $v1 -/* 008224 80007624 31CF0800 */ andi $t7, $t6, 0x800 -/* 008228 80007628 11E00009 */ beqz $t7, .L80007650 -/* 00822C 8000762C 25180001 */ addiu $t8, $t0, 1 -/* 008230 80007630 00087080 */ sll $t6, $t0, 2 -/* 008234 80007634 012E7821 */ addu $t7, $t1, $t6 -/* 008238 80007638 AF380000 */ sw $t8, ($t9) -/* 00823C 8000763C C5F00004 */ lwc1 $f16, 4($t7) -/* 008240 80007640 0183C021 */ addu $t8, $t4, $v1 -/* 008244 80007644 24420001 */ addiu $v0, $v0, 1 -/* 008248 80007648 46008487 */ neg.s $f18, $f16 -/* 00824C 8000764C E7120000 */ swc1 $f18, ($t8) -.L80007650: -/* 008250 80007650 94991BB0 */ lhu $t9, 0x1bb0($a0) -/* 008254 80007654 00021880 */ sll $v1, $v0, 2 -/* 008258 80007658 00C3C021 */ addu $t8, $a2, $v1 -/* 00825C 8000765C 332E0800 */ andi $t6, $t9, 0x800 -/* 008260 80007660 11C00009 */ beqz $t6, .L80007688 -/* 008264 80007664 250F0002 */ addiu $t7, $t0, 2 -/* 008268 80007668 0008C880 */ sll $t9, $t0, 2 -/* 00826C 8000766C 01397021 */ addu $t6, $t1, $t9 -/* 008270 80007670 AF0F0000 */ sw $t7, ($t8) -/* 008274 80007674 C5C40008 */ lwc1 $f4, 8($t6) -/* 008278 80007678 01837821 */ addu $t7, $t4, $v1 -/* 00827C 8000767C 24420001 */ addiu $v0, $v0, 1 -/* 008280 80007680 46002187 */ neg.s $f6, $f4 -/* 008284 80007684 E5E60000 */ swc1 $f6, ($t7) -.L80007688: -/* 008288 80007688 94982988 */ lhu $t8, 0x2988($a0) -/* 00828C 8000768C 00021880 */ sll $v1, $v0, 2 -/* 008290 80007690 00C37821 */ addu $t7, $a2, $v1 -/* 008294 80007694 33190800 */ andi $t9, $t8, 0x800 -/* 008298 80007698 13200009 */ beqz $t9, .L800076C0 -/* 00829C 8000769C 250E0003 */ addiu $t6, $t0, 3 -/* 0082A0 800076A0 0008C080 */ sll $t8, $t0, 2 -/* 0082A4 800076A4 0138C821 */ addu $t9, $t1, $t8 -/* 0082A8 800076A8 ADEE0000 */ sw $t6, ($t7) -/* 0082AC 800076AC C728000C */ lwc1 $f8, 0xc($t9) -/* 0082B0 800076B0 01837021 */ addu $t6, $t4, $v1 -/* 0082B4 800076B4 24420001 */ addiu $v0, $v0, 1 -/* 0082B8 800076B8 46004287 */ neg.s $f10, $f8 -/* 0082BC 800076BC E5CA0000 */ swc1 $f10, ($t6) -.L800076C0: -/* 0082C0 800076C0 25080004 */ addiu $t0, $t0, 4 -/* 0082C4 800076C4 150AFFC7 */ bne $t0, $t2, .L800075E4 -/* 0082C8 800076C8 24843760 */ addiu $a0, $a0, 0x3760 -.L800076CC: -/* 0082CC 800076CC 3C0C8016 */ lui $t4, %hi(gCourseCompletionPercentByRank) # $t4, 0x8016 -/* 0082D0 800076D0 258C2FD8 */ addiu $t4, %lo(gCourseCompletionPercentByRank) # addiu $t4, $t4, 0x2fd8 -/* 0082D4 800076D4 00004025 */ move $t0, $zero -/* 0082D8 800076D8 27A60068 */ addiu $a2, $sp, 0x68 -/* 0082DC 800076DC 240B0008 */ li $t3, 8 -/* 0082E0 800076E0 10000020 */ b .L80007764 -/* 0082E4 800076E4 00404825 */ move $t1, $v0 -/* 0082E8 800076E8 000078C0 */ sll $t7, $zero, 3 -/* 0082EC 800076EC 01E07823 */ subu $t7, $t7, $zero -/* 0082F0 800076F0 000F7900 */ sll $t7, $t7, 4 -/* 0082F4 800076F4 01E07823 */ subu $t7, $t7, $zero -/* 0082F8 800076F8 000F7880 */ sll $t7, $t7, 2 -/* 0082FC 800076FC 01E07823 */ subu $t7, $t7, $zero -/* 008300 80007700 3C18800F */ lui $t8, %hi(gPlayers) # $t8, 0x800f -/* 008304 80007704 27186990 */ addiu $t8, %lo(gPlayers) # addiu $t8, $t8, 0x6990 -/* 008308 80007708 000F78C0 */ sll $t7, $t7, 3 -/* 00830C 8000770C 3C0D8016 */ lui $t5, %hi(gCourseCompletionPercentByPlayerId) # $t5, 0x8016 -/* 008310 80007710 25AD44D0 */ addiu $t5, %lo(gCourseCompletionPercentByPlayerId) # addiu $t5, $t5, 0x44d0 -/* 008314 80007714 01F82021 */ addu $a0, $t7, $t8 -/* 008318 80007718 00002825 */ move $a1, $zero -/* 00831C 8000771C 24070001 */ li $a3, 1 -.L80007720: -/* 008320 80007720 94990000 */ lhu $t9, ($a0) -/* 008324 80007724 00021880 */ sll $v1, $v0, 2 -/* 008328 80007728 00C37821 */ addu $t7, $a2, $v1 -/* 00832C 8000772C 332E0800 */ andi $t6, $t9, 0x800 -/* 008330 80007730 15C00008 */ bnez $t6, .L80007754 -/* 008334 80007734 24840DD8 */ addiu $a0, $a0, 0xdd8 -/* 008338 80007738 0008C080 */ sll $t8, $t0, 2 -/* 00833C 8000773C 01B8C821 */ addu $t9, $t5, $t8 -/* 008340 80007740 ADE80000 */ sw $t0, ($t7) -/* 008344 80007744 C7300000 */ lwc1 $f16, ($t9) -/* 008348 80007748 01837021 */ addu $t6, $t4, $v1 -/* 00834C 8000774C 24420001 */ addiu $v0, $v0, 1 -/* 008350 80007750 E5D00000 */ swc1 $f16, ($t6) -.L80007754: -/* 008354 80007754 00E04025 */ move $t0, $a3 -/* 008358 80007758 14A7FFF1 */ bne $a1, $a3, .L80007720 -/* 00835C 8000775C 24E70001 */ addiu $a3, $a3, 1 -/* 008360 80007760 110B0042 */ beq $t0, $t3, .L8000786C -.L80007764: -/* 008364 80007764 000878C0 */ sll $t7, $t0, 3 -/* 008368 80007768 01E87823 */ subu $t7, $t7, $t0 -/* 00836C 8000776C 000F7900 */ sll $t7, $t7, 4 -/* 008370 80007770 01E87823 */ subu $t7, $t7, $t0 -/* 008374 80007774 000F7880 */ sll $t7, $t7, 2 -/* 008378 80007778 01E87823 */ subu $t7, $t7, $t0 -/* 00837C 8000777C 3C18800F */ lui $t8, %hi(gPlayers) # $t8, 0x800f -/* 008380 80007780 27186990 */ addiu $t8, %lo(gPlayers) # addiu $t8, $t8, 0x6990 -/* 008384 80007784 000F78C0 */ sll $t7, $t7, 3 -/* 008388 80007788 3C0D8016 */ lui $t5, %hi(gCourseCompletionPercentByPlayerId) # $t5, 0x8016 -/* 00838C 8000778C 25AD44D0 */ addiu $t5, %lo(gCourseCompletionPercentByPlayerId) # addiu $t5, $t5, 0x44d0 -/* 008390 80007790 01F82021 */ addu $a0, $t7, $t8 -.L80007794: -/* 008394 80007794 94990000 */ lhu $t9, ($a0) -/* 008398 80007798 00021880 */ sll $v1, $v0, 2 -/* 00839C 8000779C 00C37821 */ addu $t7, $a2, $v1 -/* 0083A0 800077A0 332E0800 */ andi $t6, $t9, 0x800 -/* 0083A4 800077A4 15C00007 */ bnez $t6, .L800077C4 -/* 0083A8 800077A8 0008C080 */ sll $t8, $t0, 2 -/* 0083AC 800077AC ADE80000 */ sw $t0, ($t7) -/* 0083B0 800077B0 01B8C821 */ addu $t9, $t5, $t8 -/* 0083B4 800077B4 C7320000 */ lwc1 $f18, ($t9) -/* 0083B8 800077B8 01837021 */ addu $t6, $t4, $v1 -/* 0083BC 800077BC 24420001 */ addiu $v0, $v0, 1 -/* 0083C0 800077C0 E5D20000 */ swc1 $f18, ($t6) -.L800077C4: -/* 0083C4 800077C4 948F0DD8 */ lhu $t7, 0xdd8($a0) -/* 0083C8 800077C8 00021880 */ sll $v1, $v0, 2 -/* 0083CC 800077CC 00C37021 */ addu $t6, $a2, $v1 -/* 0083D0 800077D0 31F80800 */ andi $t8, $t7, 0x800 -/* 0083D4 800077D4 17000008 */ bnez $t8, .L800077F8 -/* 0083D8 800077D8 25190001 */ addiu $t9, $t0, 1 -/* 0083DC 800077DC 00087880 */ sll $t7, $t0, 2 -/* 0083E0 800077E0 01AFC021 */ addu $t8, $t5, $t7 -/* 0083E4 800077E4 ADD90000 */ sw $t9, ($t6) -/* 0083E8 800077E8 C7040004 */ lwc1 $f4, 4($t8) -/* 0083EC 800077EC 0183C821 */ addu $t9, $t4, $v1 -/* 0083F0 800077F0 24420001 */ addiu $v0, $v0, 1 -/* 0083F4 800077F4 E7240000 */ swc1 $f4, ($t9) -.L800077F8: -/* 0083F8 800077F8 948E1BB0 */ lhu $t6, 0x1bb0($a0) -/* 0083FC 800077FC 00021880 */ sll $v1, $v0, 2 -/* 008400 80007800 00C3C821 */ addu $t9, $a2, $v1 -/* 008404 80007804 31CF0800 */ andi $t7, $t6, 0x800 -/* 008408 80007808 15E00008 */ bnez $t7, .L8000782C -/* 00840C 8000780C 25180002 */ addiu $t8, $t0, 2 -/* 008410 80007810 00087080 */ sll $t6, $t0, 2 -/* 008414 80007814 01AE7821 */ addu $t7, $t5, $t6 -/* 008418 80007818 AF380000 */ sw $t8, ($t9) -/* 00841C 8000781C C5E60008 */ lwc1 $f6, 8($t7) -/* 008420 80007820 0183C021 */ addu $t8, $t4, $v1 -/* 008424 80007824 24420001 */ addiu $v0, $v0, 1 -/* 008428 80007828 E7060000 */ swc1 $f6, ($t8) -.L8000782C: -/* 00842C 8000782C 94992988 */ lhu $t9, 0x2988($a0) -/* 008430 80007830 00021880 */ sll $v1, $v0, 2 -/* 008434 80007834 00C3C021 */ addu $t8, $a2, $v1 -/* 008438 80007838 332E0800 */ andi $t6, $t9, 0x800 -/* 00843C 8000783C 15C00008 */ bnez $t6, .L80007860 -/* 008440 80007840 250F0003 */ addiu $t7, $t0, 3 -/* 008444 80007844 0008C880 */ sll $t9, $t0, 2 -/* 008448 80007848 01B97021 */ addu $t6, $t5, $t9 -/* 00844C 8000784C AF0F0000 */ sw $t7, ($t8) -/* 008450 80007850 C5C8000C */ lwc1 $f8, 0xc($t6) -/* 008454 80007854 01837821 */ addu $t7, $t4, $v1 -/* 008458 80007858 24420001 */ addiu $v0, $v0, 1 -/* 00845C 8000785C E5E80000 */ swc1 $f8, ($t7) -.L80007860: -/* 008460 80007860 25080004 */ addiu $t0, $t0, 4 -/* 008464 80007864 150AFFCB */ bne $t0, $t2, .L80007794 -/* 008468 80007868 24843760 */ addiu $a0, $a0, 0x3760 -.L8000786C: -/* 00846C 8000786C 252DFFFF */ addiu $t5, $t1, -1 -/* 008470 80007870 19A00047 */ blez $t5, .L80007990 -/* 008474 80007874 00004025 */ move $t0, $zero -/* 008478 80007878 24070001 */ li $a3, 1 -.L8000787C: -/* 00847C 8000787C 00E9082A */ slt $at, $a3, $t1 -/* 008480 80007880 10200040 */ beqz $at, .L80007984 -/* 008484 80007884 00E01025 */ move $v0, $a3 -/* 008488 80007888 3C188016 */ lui $t8, %hi(gCourseCompletionPercentByRank) # $t8, 0x8016 -/* 00848C 8000788C 01276023 */ subu $t4, $t1, $a3 -/* 008490 80007890 31830001 */ andi $v1, $t4, 1 -/* 008494 80007894 27182FD8 */ addiu $t8, %lo(gCourseCompletionPercentByRank) # addiu $t8, $t8, 0x2fd8 -/* 008498 80007898 00082880 */ sll $a1, $t0, 2 -/* 00849C 8000789C 10600013 */ beqz $v1, .L800078EC -/* 0084A0 800078A0 00B82021 */ addu $a0, $a1, $t8 -/* 0084A4 800078A4 00071880 */ sll $v1, $a3, 2 -/* 0084A8 800078A8 00786021 */ addu $t4, $v1, $t8 -/* 0084AC 800078AC C5820000 */ lwc1 $f2, ($t4) -/* 0084B0 800078B0 C4800000 */ lwc1 $f0, ($a0) -/* 0084B4 800078B4 00C34021 */ addu $t0, $a2, $v1 -/* 0084B8 800078B8 00C51021 */ addu $v0, $a2, $a1 -/* 0084BC 800078BC 4602003C */ c.lt.s $f0, $f2 -/* 0084C0 800078C0 00000000 */ nop -/* 0084C4 800078C4 45020008 */ bc1fl .L800078E8 -/* 0084C8 800078C8 24E20001 */ addiu $v0, $a3, 1 -/* 0084CC 800078CC 8D190000 */ lw $t9, ($t0) -/* 0084D0 800078D0 8C500000 */ lw $s0, ($v0) -/* 0084D4 800078D4 E4820000 */ swc1 $f2, ($a0) -/* 0084D8 800078D8 AC590000 */ sw $t9, ($v0) -/* 0084DC 800078DC E5800000 */ swc1 $f0, ($t4) -/* 0084E0 800078E0 AD100000 */ sw $s0, ($t0) -/* 0084E4 800078E4 24E20001 */ addiu $v0, $a3, 1 -.L800078E8: -/* 0084E8 800078E8 10490026 */ beq $v0, $t1, .L80007984 -.L800078EC: -/* 0084EC 800078EC 3C0E8016 */ lui $t6, %hi(gCourseCompletionPercentByRank) # $t6, 0x8016 -/* 0084F0 800078F0 25CE2FD8 */ addiu $t6, %lo(gCourseCompletionPercentByRank) # addiu $t6, $t6, 0x2fd8 -/* 0084F4 800078F4 00021880 */ sll $v1, $v0, 2 -/* 0084F8 800078F8 00097880 */ sll $t7, $t1, 2 -/* 0084FC 800078FC 01EE8821 */ addu $s1, $t7, $t6 -/* 008500 80007900 006E6021 */ addu $t4, $v1, $t6 -.L80007904: -/* 008504 80007904 C4800000 */ lwc1 $f0, ($a0) -/* 008508 80007908 C5820000 */ lwc1 $f2, ($t4) -/* 00850C 8000790C 00C51021 */ addu $v0, $a2, $a1 -/* 008510 80007910 00C34021 */ addu $t0, $a2, $v1 -/* 008514 80007914 4602003C */ c.lt.s $f0, $f2 -/* 008518 80007918 00000000 */ nop -/* 00851C 8000791C 4502000A */ bc1fl .L80007948 -/* 008520 80007920 C5820004 */ lwc1 $f2, 4($t4) -/* 008524 80007924 8D180000 */ lw $t8, ($t0) -/* 008528 80007928 8C500000 */ lw $s0, ($v0) -/* 00852C 8000792C 46000306 */ mov.s $f12, $f0 -/* 008530 80007930 E4820000 */ swc1 $f2, ($a0) -/* 008534 80007934 E58C0000 */ swc1 $f12, ($t4) -/* 008538 80007938 AC580000 */ sw $t8, ($v0) -/* 00853C 8000793C C4800000 */ lwc1 $f0, ($a0) -/* 008540 80007940 AD100000 */ sw $s0, ($t0) -/* 008544 80007944 C5820004 */ lwc1 $f2, 4($t4) -.L80007948: -/* 008548 80007948 00C51021 */ addu $v0, $a2, $a1 -/* 00854C 8000794C 00C34021 */ addu $t0, $a2, $v1 -/* 008550 80007950 4602003C */ c.lt.s $f0, $f2 -/* 008554 80007954 00000000 */ nop -/* 008558 80007958 45020008 */ bc1fl .L8000797C -/* 00855C 8000795C 258C0008 */ addiu $t4, $t4, 8 -/* 008560 80007960 8D190004 */ lw $t9, 4($t0) -/* 008564 80007964 8C500000 */ lw $s0, ($v0) -/* 008568 80007968 E4820000 */ swc1 $f2, ($a0) -/* 00856C 8000796C AC590000 */ sw $t9, ($v0) -/* 008570 80007970 E5800004 */ swc1 $f0, 4($t4) -/* 008574 80007974 AD100004 */ sw $s0, 4($t0) -/* 008578 80007978 258C0008 */ addiu $t4, $t4, 8 -.L8000797C: -/* 00857C 8000797C 1591FFE1 */ bne $t4, $s1, .L80007904 -/* 008580 80007980 24630008 */ addiu $v1, $v1, 8 -.L80007984: -/* 008584 80007984 00E04025 */ move $t0, $a3 -/* 008588 80007988 14EDFFBC */ bne $a3, $t5, .L8000787C -/* 00858C 8000798C 24E70001 */ addiu $a3, $a3, 1 -.L80007990: -/* 008590 80007990 29A10006 */ slti $at, $t5, 6 -/* 008594 80007994 10200049 */ beqz $at, .L80007ABC -/* 008598 80007998 01204025 */ move $t0, $t1 -/* 00859C 8000799C 25270001 */ addiu $a3, $t1, 1 -/* 0085A0 800079A0 2549FFFF */ addiu $t1, $t2, -1 -.L800079A4: -/* 0085A4 800079A4 28E10008 */ slti $at, $a3, 8 -/* 0085A8 800079A8 10200041 */ beqz $at, .L80007AB0 -/* 0085AC 800079AC 00E01025 */ move $v0, $a3 -/* 0085B0 800079B0 240E0008 */ li $t6, 8 -/* 0085B4 800079B4 01C76023 */ subu $t4, $t6, $a3 -/* 0085B8 800079B8 3C0F8016 */ lui $t7, %hi(gCourseCompletionPercentByRank) # $t7, 0x8016 -/* 0085BC 800079BC 25EF2FD8 */ addiu $t7, %lo(gCourseCompletionPercentByRank) # addiu $t7, $t7, 0x2fd8 -/* 0085C0 800079C0 31830001 */ andi $v1, $t4, 1 -/* 0085C4 800079C4 00082880 */ sll $a1, $t0, 2 -/* 0085C8 800079C8 10600013 */ beqz $v1, .L80007A18 -/* 0085CC 800079CC 00AF2021 */ addu $a0, $a1, $t7 -/* 0085D0 800079D0 00071880 */ sll $v1, $a3, 2 -/* 0085D4 800079D4 006F6021 */ addu $t4, $v1, $t7 -/* 0085D8 800079D8 C5820000 */ lwc1 $f2, ($t4) -/* 0085DC 800079DC C4800000 */ lwc1 $f0, ($a0) -/* 0085E0 800079E0 00C34021 */ addu $t0, $a2, $v1 -/* 0085E4 800079E4 00C51021 */ addu $v0, $a2, $a1 -/* 0085E8 800079E8 4602003C */ c.lt.s $f0, $f2 -/* 0085EC 800079EC 00000000 */ nop -/* 0085F0 800079F0 45020008 */ bc1fl .L80007A14 -/* 0085F4 800079F4 24E20001 */ addiu $v0, $a3, 1 -/* 0085F8 800079F8 8D180000 */ lw $t8, ($t0) -/* 0085FC 800079FC 8C500000 */ lw $s0, ($v0) -/* 008600 80007A00 E4820000 */ swc1 $f2, ($a0) -/* 008604 80007A04 AC580000 */ sw $t8, ($v0) -/* 008608 80007A08 E5800000 */ swc1 $f0, ($t4) -/* 00860C 80007A0C AD100000 */ sw $s0, ($t0) -/* 008610 80007A10 24E20001 */ addiu $v0, $a3, 1 -.L80007A14: -/* 008614 80007A14 104B0026 */ beq $v0, $t3, .L80007AB0 -.L80007A18: -/* 008618 80007A18 3C198016 */ lui $t9, %hi(gCourseCompletionPercentByRank) # $t9, 0x8016 -/* 00861C 80007A1C 27392FD8 */ addiu $t9, %lo(gCourseCompletionPercentByRank) # addiu $t9, $t9, 0x2fd8 -/* 008620 80007A20 00021880 */ sll $v1, $v0, 2 -/* 008624 80007A24 000A7080 */ sll $t6, $t2, 2 -/* 008628 80007A28 01D96821 */ addu $t5, $t6, $t9 -/* 00862C 80007A2C 00796021 */ addu $t4, $v1, $t9 -.L80007A30: -/* 008630 80007A30 C4800000 */ lwc1 $f0, ($a0) -/* 008634 80007A34 C5820000 */ lwc1 $f2, ($t4) -/* 008638 80007A38 00C51021 */ addu $v0, $a2, $a1 -/* 00863C 80007A3C 00C34021 */ addu $t0, $a2, $v1 -/* 008640 80007A40 4602003C */ c.lt.s $f0, $f2 -/* 008644 80007A44 00000000 */ nop -/* 008648 80007A48 4502000A */ bc1fl .L80007A74 -/* 00864C 80007A4C C5820004 */ lwc1 $f2, 4($t4) -/* 008650 80007A50 8D0F0000 */ lw $t7, ($t0) -/* 008654 80007A54 8C500000 */ lw $s0, ($v0) -/* 008658 80007A58 46000306 */ mov.s $f12, $f0 -/* 00865C 80007A5C E4820000 */ swc1 $f2, ($a0) -/* 008660 80007A60 E58C0000 */ swc1 $f12, ($t4) -/* 008664 80007A64 AC4F0000 */ sw $t7, ($v0) -/* 008668 80007A68 C4800000 */ lwc1 $f0, ($a0) -/* 00866C 80007A6C AD100000 */ sw $s0, ($t0) -/* 008670 80007A70 C5820004 */ lwc1 $f2, 4($t4) -.L80007A74: -/* 008674 80007A74 00C51021 */ addu $v0, $a2, $a1 -/* 008678 80007A78 00C34021 */ addu $t0, $a2, $v1 -/* 00867C 80007A7C 4602003C */ c.lt.s $f0, $f2 -/* 008680 80007A80 00000000 */ nop -/* 008684 80007A84 45020008 */ bc1fl .L80007AA8 -/* 008688 80007A88 258C0008 */ addiu $t4, $t4, 8 -/* 00868C 80007A8C 8D180004 */ lw $t8, 4($t0) -/* 008690 80007A90 8C500000 */ lw $s0, ($v0) -/* 008694 80007A94 E4820000 */ swc1 $f2, ($a0) -/* 008698 80007A98 AC580000 */ sw $t8, ($v0) -/* 00869C 80007A9C E5800004 */ swc1 $f0, 4($t4) -/* 0086A0 80007AA0 AD100004 */ sw $s0, 4($t0) -/* 0086A4 80007AA4 258C0008 */ addiu $t4, $t4, 8 -.L80007AA8: -/* 0086A8 80007AA8 158DFFE1 */ bne $t4, $t5, .L80007A30 -/* 0086AC 80007AAC 24630008 */ addiu $v1, $v1, 8 -.L80007AB0: -/* 0086B0 80007AB0 00E04025 */ move $t0, $a3 -/* 0086B4 80007AB4 14E9FFBB */ bne $a3, $t1, .L800079A4 -/* 0086B8 80007AB8 24E70001 */ addiu $a3, $a3, 1 -.L80007ABC: -/* 0086BC 80007ABC 3C028016 */ lui $v0, %hi(D_801643E0) # $v0, 0x8016 -/* 0086C0 80007AC0 3C038016 */ lui $v1, %hi(gGPCurrentRaceRankByPlayerId) # $v1, 0x8016 -/* 0086C4 80007AC4 3C048016 */ lui $a0, %hi(gGPCurrentRaceRankByPlayerId + 0x20) # $a0, 0x8016 -/* 0086C8 80007AC8 248443D8 */ addiu $a0, %lo(gGPCurrentRaceRankByPlayerId + 0x20) # addiu $a0, $a0, 0x43d8 -/* 0086CC 80007ACC 246343B8 */ addiu $v1, %lo(gGPCurrentRaceRankByPlayerId) # addiu $v1, $v1, 0x43b8 -/* 0086D0 80007AD0 244243E0 */ addiu $v0, %lo(D_801643E0) # addiu $v0, $v0, 0x43e0 -/* 0086D4 80007AD4 24070001 */ li $a3, 1 -.L80007AD8: -/* 0086D8 80007AD8 8C6E0000 */ lw $t6, ($v1) -/* 0086DC 80007ADC 24630004 */ addiu $v1, $v1, 4 -/* 0086E0 80007AE0 0064082B */ sltu $at, $v1, $a0 -/* 0086E4 80007AE4 24E70001 */ addiu $a3, $a3, 1 -/* 0086E8 80007AE8 24420004 */ addiu $v0, $v0, 4 -/* 0086EC 80007AEC 1420FFFA */ bnez $at, .L80007AD8 -/* 0086F0 80007AF0 AC4EFFFC */ sw $t6, -4($v0) -/* 0086F4 80007AF4 10000017 */ b .L80007B54 -/* 0086F8 80007AF8 00004025 */ move $t0, $zero -/* 0086FC 80007AFC 3C0E8016 */ lui $t6, %hi(gGPCurrentRacePlayerIdByRank) # $t6, 0x8016 -/* 008700 80007B00 25CE4360 */ addiu $t6, %lo(gGPCurrentRacePlayerIdByRank) # addiu $t6, $t6, 0x4360 -/* 008704 80007B04 0000C880 */ sll $t9, $zero, 2 -/* 008708 80007B08 27AF0068 */ addiu $t7, $sp, 0x68 -/* 00870C 80007B0C 0000C040 */ sll $t8, $zero, 1 -/* 008710 80007B10 3C0C8016 */ lui $t4, %hi(gGPCurrentRaceRankByPlayerId) # $t4, 0x8016 -/* 008714 80007B14 258C43B8 */ addiu $t4, %lo(gGPCurrentRaceRankByPlayerId) # addiu $t4, $t4, 0x43b8 -/* 008718 80007B18 030E2021 */ addu $a0, $t8, $t6 -/* 00871C 80007B1C 032F1021 */ addu $v0, $t9, $t7 -/* 008720 80007B20 00002825 */ move $a1, $zero -/* 008724 80007B24 24070001 */ li $a3, 1 -.L80007B28: -/* 008728 80007B28 8C430000 */ lw $v1, ($v0) -/* 00872C 80007B2C 24420004 */ addiu $v0, $v0, 4 -/* 008730 80007B30 24840002 */ addiu $a0, $a0, 2 -/* 008734 80007B34 0003C880 */ sll $t9, $v1, 2 -/* 008738 80007B38 01997821 */ addu $t7, $t4, $t9 -/* 00873C 80007B3C ADE80000 */ sw $t0, ($t7) -/* 008740 80007B40 00E04025 */ move $t0, $a3 -/* 008744 80007B44 A483FFFE */ sh $v1, -2($a0) -/* 008748 80007B48 14A7FFF7 */ bne $a1, $a3, .L80007B28 -/* 00874C 80007B4C 24E70001 */ addiu $a3, $a3, 1 -/* 008750 80007B50 110B0025 */ beq $t0, $t3, .L80007BE8 -.L80007B54: -/* 008754 80007B54 3C0F8016 */ lui $t7, %hi(gGPCurrentRacePlayerIdByRank) # $t7, 0x8016 -/* 008758 80007B58 25EF4360 */ addiu $t7, %lo(gGPCurrentRacePlayerIdByRank) # addiu $t7, $t7, 0x4360 -/* 00875C 80007B5C 3C0C8016 */ lui $t4, %hi(gGPCurrentRaceRankByPlayerId) # $t4, 0x8016 -/* 008760 80007B60 0008C080 */ sll $t8, $t0, 2 -/* 008764 80007B64 27AE0068 */ addiu $t6, $sp, 0x68 -/* 008768 80007B68 0008C840 */ sll $t9, $t0, 1 -/* 00876C 80007B6C 032F2021 */ addu $a0, $t9, $t7 -/* 008770 80007B70 030E1021 */ addu $v0, $t8, $t6 -/* 008774 80007B74 258C43B8 */ addiu $t4, %lo(gGPCurrentRaceRankByPlayerId) # addiu $t4, $t4, 0x43b8 -/* 008778 80007B78 25070001 */ addiu $a3, $t0, 1 -.L80007B7C: -/* 00877C 80007B7C 8C430000 */ lw $v1, ($v0) -/* 008780 80007B80 24420010 */ addiu $v0, $v0, 0x10 -/* 008784 80007B84 24840008 */ addiu $a0, $a0, 8 -/* 008788 80007B88 0003C080 */ sll $t8, $v1, 2 -/* 00878C 80007B8C 01987021 */ addu $t6, $t4, $t8 -/* 008790 80007B90 ADC80000 */ sw $t0, ($t6) -/* 008794 80007B94 8C45FFF4 */ lw $a1, -0xc($v0) -/* 008798 80007B98 25180002 */ addiu $t8, $t0, 2 -/* 00879C 80007B9C A483FFF8 */ sh $v1, -8($a0) -/* 0087A0 80007BA0 0005C880 */ sll $t9, $a1, 2 -/* 0087A4 80007BA4 01997821 */ addu $t7, $t4, $t9 -/* 0087A8 80007BA8 ADE70000 */ sw $a3, ($t7) -/* 0087AC 80007BAC 8C46FFF8 */ lw $a2, -8($v0) -/* 0087B0 80007BB0 250F0003 */ addiu $t7, $t0, 3 -/* 0087B4 80007BB4 25080004 */ addiu $t0, $t0, 4 -/* 0087B8 80007BB8 00067080 */ sll $t6, $a2, 2 -/* 0087BC 80007BBC 018EC821 */ addu $t9, $t4, $t6 -/* 0087C0 80007BC0 AF380000 */ sw $t8, ($t9) -/* 0087C4 80007BC4 8C49FFFC */ lw $t1, -4($v0) -/* 0087C8 80007BC8 24E70004 */ addiu $a3, $a3, 4 -/* 0087CC 80007BCC A485FFFA */ sh $a1, -6($a0) -/* 0087D0 80007BD0 00097080 */ sll $t6, $t1, 2 -/* 0087D4 80007BD4 018EC021 */ addu $t8, $t4, $t6 -/* 0087D8 80007BD8 AF0F0000 */ sw $t7, ($t8) -/* 0087DC 80007BDC A486FFFC */ sh $a2, -4($a0) -/* 0087E0 80007BE0 150AFFE6 */ bne $t0, $t2, .L80007B7C -/* 0087E4 80007BE4 A489FFFE */ sh $t1, -2($a0) -.L80007BE8: -/* 0087E8 80007BE8 8FB00008 */ lw $s0, 8($sp) -/* 0087EC 80007BEC 8FB1000C */ lw $s1, 0xc($sp) -/* 0087F0 80007BF0 03E00008 */ jr $ra -/* 0087F4 80007BF4 27BD0090 */ addiu $sp, $sp, 0x90 diff --git a/asm/non_matchings/code_80005FD0/func_80007D04.s b/asm/non_matchings/code_80005FD0/func_80007D04.s deleted file mode 100644 index 005324184..000000000 --- a/asm/non_matchings/code_80005FD0/func_80007D04.s +++ /dev/null @@ -1,181 +0,0 @@ -glabel func_80007D04 -/* 008904 80007D04 3C0B8016 */ lui $t3, %hi(gGPCurrentRaceRankByPlayerId) # $t3, 0x8016 -/* 008908 80007D08 256B43B8 */ addiu $t3, %lo(gGPCurrentRaceRankByPlayerId) # addiu $t3, $t3, 0x43b8 -/* 00890C 80007D0C 3C038016 */ lui $v1, %hi(D_80163478) # $v1, 0x8016 -/* 008910 80007D10 00041080 */ sll $v0, $a0, 2 -/* 008914 80007D14 84633478 */ lh $v1, %lo(D_80163478)($v1) -/* 008918 80007D18 0162C821 */ addu $t9, $t3, $v0 -/* 00891C 80007D1C 8F2C0000 */ lw $t4, ($t9) -/* 008920 80007D20 3C088016 */ lui $t0, %hi(D_80164450) # $t0, 0x8016 -/* 008924 80007D24 25084450 */ addiu $t0, %lo(D_80164450) # addiu $t0, $t0, 0x4450 -/* 008928 80007D28 00037080 */ sll $t6, $v1, 2 -/* 00892C 80007D2C 27BDFFD0 */ addiu $sp, $sp, -0x30 -/* 008930 80007D30 010E7821 */ addu $t7, $t0, $t6 -/* 008934 80007D34 0102C021 */ addu $t8, $t0, $v0 -/* 008938 80007D38 29810002 */ slti $at, $t4, 2 -/* 00893C 80007D3C AFBF0014 */ sw $ra, 0x14($sp) -/* 008940 80007D40 00803825 */ move $a3, $a0 -/* 008944 80007D44 00A03025 */ move $a2, $a1 -/* 008948 80007D48 85E90002 */ lh $t1, 2($t7) -/* 00894C 80007D4C 10200019 */ beqz $at, .L80007DB4 -/* 008950 80007D50 870A0002 */ lh $t2, 2($t8) -/* 008954 80007D54 016E6821 */ addu $t5, $t3, $t6 -/* 008958 80007D58 01497023 */ subu $t6, $t2, $t1 -/* 00895C 80007D5C 000E7C00 */ sll $t7, $t6, 0x10 -/* 008960 80007D60 000FC403 */ sra $t8, $t7, 0x10 -/* 008964 80007D64 2B010191 */ slti $at, $t8, 0x191 -/* 008968 80007D68 14200020 */ bnez $at, .L80007DEC -/* 00896C 80007D6C 85A20002 */ lh $v0, 2($t5) -/* 008970 80007D70 28410006 */ slti $at, $v0, 6 -/* 008974 80007D74 1420001D */ bnez $at, .L80007DEC -/* 008978 80007D78 00A02025 */ move $a0, $a1 -/* 00897C 80007D7C 8CB900BC */ lw $t9, 0xbc($a1) -/* 008980 80007D80 3C01FFDF */ lui $at, (0xFFDFFFFF >> 16) # lui $at, 0xffdf -/* 008984 80007D84 3421FFFF */ ori $at, (0xFFDFFFFF & 0xFFFF) # ori $at, $at, 0xffff -/* 008988 80007D88 03216024 */ and $t4, $t9, $at -/* 00898C 80007D8C ACAC00BC */ sw $t4, 0xbc($a1) -/* 008990 80007D90 0C00C3F2 */ jal player_speed -/* 008994 80007D94 AFA70030 */ sw $a3, 0x30($sp) -/* 008998 80007D98 8FA70030 */ lw $a3, 0x30($sp) -/* 00899C 80007D9C 3C018016 */ lui $at, %hi(D_801634C0) # 0x8016 -/* 0089A0 80007DA0 240D0004 */ li $t5, 4 -/* 0089A4 80007DA4 00077040 */ sll $t6, $a3, 1 -/* 0089A8 80007DA8 002E0821 */ addu $at, $at, $t6 -/* 0089AC 80007DAC 10000079 */ b .L80007F94 -/* 0089B0 80007DB0 A42D34C0 */ sh $t5, %lo(D_801634C0)($at) # 0x34c0($at) -.L80007DB4: -/* 0089B4 80007DB4 8CCF00BC */ lw $t7, 0xbc($a2) -/* 0089B8 80007DB8 3C010020 */ lui $at, 0x20 -/* 0089BC 80007DBC 00C02025 */ move $a0, $a2 -/* 0089C0 80007DC0 01E1C025 */ or $t8, $t7, $at -/* 0089C4 80007DC4 ACD800BC */ sw $t8, 0xbc($a2) -/* 0089C8 80007DC8 0C00C3F2 */ jal player_speed -/* 0089CC 80007DCC AFA70030 */ sw $a3, 0x30($sp) -/* 0089D0 80007DD0 8FA70030 */ lw $a3, 0x30($sp) -/* 0089D4 80007DD4 3C018016 */ lui $at, %hi(D_801634C0) # 0x8016 -/* 0089D8 80007DD8 24050003 */ li $a1, 3 -/* 0089DC 80007DDC 0007C840 */ sll $t9, $a3, 1 -/* 0089E0 80007DE0 00390821 */ addu $at, $at, $t9 -/* 0089E4 80007DE4 1000006B */ b .L80007F94 -/* 0089E8 80007DE8 A42534C0 */ sh $a1, %lo(D_801634C0)($at) # 0x34c0($at) -.L80007DEC: -/* 0089EC 80007DEC 3C03800E */ lui $v1, %hi(gCCSelection) -/* 0089F0 80007DF0 8C63C548 */ lw $v1, %lo(gCCSelection)($v1) -/* 0089F4 80007DF4 24050003 */ li $a1, 3 -/* 0089F8 80007DF8 24010001 */ li $at, 1 -/* 0089FC 80007DFC 1060000A */ beqz $v1, .L80007E28 -/* 008A00 80007E00 3C0C8016 */ lui $t4, %hi(D_80163344) # $t4, 0x8016 -/* 008A04 80007E04 1061000E */ beq $v1, $at, .L80007E40 -/* 008A08 80007E08 3C0D8016 */ lui $t5, %hi(D_80163344) # $t5, 0x8016 -/* 008A0C 80007E0C 24010002 */ li $at, 2 -/* 008A10 80007E10 10610011 */ beq $v1, $at, .L80007E58 -/* 008A14 80007E14 3C0E8016 */ lui $t6, %hi(D_80163344) # $t6, 0x8016 -/* 008A18 80007E18 10650015 */ beq $v1, $a1, .L80007E70 -/* 008A1C 80007E1C 3C0F8016 */ lui $t7, %hi(D_80163344) # $t7, 0x8016 -/* 008A20 80007E20 10000018 */ b .L80007E84 -/* 008A24 80007E24 00001025 */ move $v0, $zero -.L80007E28: -/* 008A28 80007E28 958C3344 */ lhu $t4, %lo(D_80163344)($t4) -/* 008A2C 80007E2C 00001025 */ move $v0, $zero -/* 008A30 80007E30 54EC0015 */ bnel $a3, $t4, .L80007E88 -/* 008A34 80007E34 0149082A */ slt $at, $t2, $t1 -/* 008A38 80007E38 10000012 */ b .L80007E84 -/* 008A3C 80007E3C 24020014 */ li $v0, 20 -.L80007E40: -/* 008A40 80007E40 95AD3344 */ lhu $t5, %lo(D_80163344)($t5) -/* 008A44 80007E44 24020008 */ li $v0, 8 -/* 008A48 80007E48 54ED000F */ bnel $a3, $t5, .L80007E88 -/* 008A4C 80007E4C 0149082A */ slt $at, $t2, $t1 -/* 008A50 80007E50 1000000C */ b .L80007E84 -/* 008A54 80007E54 24020018 */ li $v0, 24 -.L80007E58: -/* 008A58 80007E58 95CE3344 */ lhu $t6, %lo(D_80163344)($t6) -/* 008A5C 80007E5C 24020012 */ li $v0, 18 -/* 008A60 80007E60 54EE0009 */ bnel $a3, $t6, .L80007E88 -/* 008A64 80007E64 0149082A */ slt $at, $t2, $t1 -/* 008A68 80007E68 10000006 */ b .L80007E84 -/* 008A6C 80007E6C 24020024 */ li $v0, 36 -.L80007E70: -/* 008A70 80007E70 95EF3344 */ lhu $t7, %lo(D_80163344)($t7) -/* 008A74 80007E74 24020008 */ li $v0, 8 -/* 008A78 80007E78 54EF0003 */ bnel $a3, $t7, .L80007E88 -/* 008A7C 80007E7C 0149082A */ slt $at, $t2, $t1 -/* 008A80 80007E80 24020018 */ li $v0, 24 -.L80007E84: -/* 008A84 80007E84 0149082A */ slt $at, $t2, $t1 -.L80007E88: -/* 008A88 80007E88 1020000F */ beqz $at, .L80007EC8 -/* 008A8C 80007E8C 01227021 */ addu $t6, $t1, $v0 -/* 008A90 80007E90 8CD800BC */ lw $t8, 0xbc($a2) -/* 008A94 80007E94 3C010020 */ lui $at, 0x20 -/* 008A98 80007E98 00C02025 */ move $a0, $a2 -/* 008A9C 80007E9C 0301C825 */ or $t9, $t8, $at -/* 008AA0 80007EA0 ACD900BC */ sw $t9, 0xbc($a2) -/* 008AA4 80007EA4 0C00C3F2 */ jal player_speed -/* 008AA8 80007EA8 AFA70030 */ sw $a3, 0x30($sp) -/* 008AAC 80007EAC 8FA70030 */ lw $a3, 0x30($sp) -/* 008AB0 80007EB0 3C018016 */ lui $at, %hi(D_801634C0) # 0x8016 -/* 008AB4 80007EB4 240C0001 */ li $t4, 1 -/* 008AB8 80007EB8 00076840 */ sll $t5, $a3, 1 -/* 008ABC 80007EBC 002D0821 */ addu $at, $at, $t5 -/* 008AC0 80007EC0 10000034 */ b .L80007F94 -/* 008AC4 80007EC4 A42C34C0 */ sh $t4, %lo(D_801634C0)($at) # 0x34c0($at) -.L80007EC8: -/* 008AC8 80007EC8 25CF0032 */ addiu $t7, $t6, 0x32 -/* 008ACC 80007ECC 014F082A */ slt $at, $t2, $t7 -/* 008AD0 80007ED0 10200010 */ beqz $at, .L80007F14 -/* 008AD4 80007ED4 00071040 */ sll $v0, $a3, 1 -/* 008AD8 80007ED8 8CD800BC */ lw $t8, 0xbc($a2) -/* 008ADC 80007EDC 3C01FFDF */ lui $at, (0xFFDFFFFF >> 16) # lui $at, 0xffdf -/* 008AE0 80007EE0 3421FFFF */ ori $at, (0xFFDFFFFF & 0xFFFF) # ori $at, $at, 0xffff -/* 008AE4 80007EE4 0301C824 */ and $t9, $t8, $at -/* 008AE8 80007EE8 ACD900BC */ sw $t9, 0xbc($a2) -/* 008AEC 80007EEC AFA70030 */ sw $a3, 0x30($sp) -/* 008AF0 80007EF0 0C00C3F2 */ jal player_speed -/* 008AF4 80007EF4 00C02025 */ move $a0, $a2 -/* 008AF8 80007EF8 8FA70030 */ lw $a3, 0x30($sp) -/* 008AFC 80007EFC 3C018016 */ lui $at, %hi(D_801634C0) # 0x8016 -/* 008B00 80007F00 24050003 */ li $a1, 3 -/* 008B04 80007F04 00076040 */ sll $t4, $a3, 1 -/* 008B08 80007F08 002C0821 */ addu $at, $at, $t4 -/* 008B0C 80007F0C 10000021 */ b .L80007F94 -/* 008B10 80007F10 A42534C0 */ sh $a1, %lo(D_801634C0)($at) # 0x34c0($at) -.L80007F14: -/* 008B14 80007F14 3C0D8016 */ lui $t5, %hi(D_801631E0) # 0x8016 -/* 008B18 80007F18 01A26821 */ addu $t5, $t5, $v0 -/* 008B1C 80007F1C 95AD31E0 */ lhu $t5, %lo(D_801631E0)($t5) # 0x31e0($t5) -/* 008B20 80007F20 3C01FFDF */ lui $at, (0xFFDFFFFF >> 16) # lui $at, 0xffdf -/* 008B24 80007F24 00C02025 */ move $a0, $a2 -/* 008B28 80007F28 15A0000E */ bnez $t5, .L80007F64 -/* 008B2C 80007F2C 3421FFFF */ ori $at, (0xFFDFFFFF & 0xFFFF) # ori $at, $at, 0xffff -/* 008B30 80007F30 8CCE00BC */ lw $t6, 0xbc($a2) -/* 008B34 80007F34 3C01FFDF */ lui $at, (0xFFDFFFFF >> 16) # lui $at, 0xffdf -/* 008B38 80007F38 3421FFFF */ ori $at, (0xFFDFFFFF & 0xFFFF) # ori $at, $at, 0xffff -/* 008B3C 80007F3C 01C17824 */ and $t7, $t6, $at -/* 008B40 80007F40 ACCF00BC */ sw $t7, 0xbc($a2) -/* 008B44 80007F44 0C00C3F2 */ jal player_speed -/* 008B48 80007F48 AFA2001C */ sw $v0, 0x1c($sp) -/* 008B4C 80007F4C 8FA2001C */ lw $v0, 0x1c($sp) -/* 008B50 80007F50 3C018016 */ lui $at, %hi(D_801634C0) # 0x8016 -/* 008B54 80007F54 24180002 */ li $t8, 2 -/* 008B58 80007F58 00220821 */ addu $at, $at, $v0 -/* 008B5C 80007F5C 1000000D */ b .L80007F94 -/* 008B60 80007F60 A43834C0 */ sh $t8, %lo(D_801634C0)($at) # 0x34c0($at) -.L80007F64: -/* 008B64 80007F64 8CD900BC */ lw $t9, 0xbc($a2) -/* 008B68 80007F68 00C02025 */ move $a0, $a2 -/* 008B6C 80007F6C 3C053F80 */ lui $a1, 0x3f80 -/* 008B70 80007F70 03216024 */ and $t4, $t9, $at -/* 008B74 80007F74 ACCC00BC */ sw $t4, 0xbc($a2) -/* 008B78 80007F78 0C00C7D2 */ jal func_80031F48 -/* 008B7C 80007F7C AFA2001C */ sw $v0, 0x1c($sp) -/* 008B80 80007F80 8FA2001C */ lw $v0, 0x1c($sp) -/* 008B84 80007F84 3C018016 */ lui $at, %hi(D_801634C0) # 0x8016 -/* 008B88 80007F88 240DFFFF */ li $t5, -1 -/* 008B8C 80007F8C 00220821 */ addu $at, $at, $v0 -/* 008B90 80007F90 A42D34C0 */ sh $t5, %lo(D_801634C0)($at) # 0x34c0($at) -.L80007F94: -/* 008B94 80007F94 8FBF0014 */ lw $ra, 0x14($sp) -/* 008B98 80007F98 27BD0030 */ addiu $sp, $sp, 0x30 -/* 008B9C 80007F9C 03E00008 */ jr $ra -/* 008BA0 80007FA0 00000000 */ nop diff --git a/src/audio/data.c b/src/audio/data.c index f1cb322ad..5efa7734a 100644 --- a/src/audio/data.c +++ b/src/audio/data.c @@ -354,9 +354,9 @@ u16 gHeadsetPanQuantization[0x10] = { 0x40, 0x40, 0x30, 0x30, 0x20, 0x20, 0x10, 0, 0, 0, }; -s32 gUnknownData_800F6290[32] = { //maybe envelope of some kind? - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 500, 0, 0, 0, 500, 0, 0, 0, 500, 0, 0, 0, 500, 0, 0, +s16 gUnknownData_800F6290[64] = { // maybe envelope of some kind? + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 500, 0, 0, 0, 0, 0, 0, 0, 500, 0, 0, 0, 0, 0, 0, 0, 500, 0, 0, 0, 0, 0, 0, 0, 500, 0, 0, 0, 0, }; // Linearly interpolated between diff --git a/src/audio/data.h b/src/audio/data.h index 801137152..563352ce0 100644 --- a/src/audio/data.h +++ b/src/audio/data.h @@ -34,7 +34,7 @@ extern u32 fill2; extern struct NoteSubEu gZeroNoteSub; extern struct NoteSubEu gDefaultNoteSub; extern u16 gHeadsetPanQuantization[0x10]; -extern s32 gUnknownData_800F6290[32]; +extern s16 gUnknownData_800F6290[]; extern f32 gHeadsetPanVolume[128]; extern f32 gStereoPanVolume[128]; extern f32 gDefaultPanVolume[128]; diff --git a/src/audio/synthesis.c b/src/audio/synthesis.c index b688bb061..c6e3e5360 100644 --- a/src/audio/synthesis.c +++ b/src/audio/synthesis.c @@ -326,8 +326,8 @@ Acmd *synthesis_do_one_audio_update(s16 *aiBuf, s32 bufLen, Acmd *acmd, s32 upda #ifdef NON_MATCHING //generated by m2c commit beb457dabfc7a01ec6540a5404a6a05097a13602 on Nov-01-2023 -u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s16 *aiBuf, s32 inBuf, u64 *cmd, s32 updateIndex) { - s32 pad[4]; +Acmd *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, UNUSED s16 *aiBuf, s32 inBuf, Acmd *cmd, s32 updateIndex) { + UNUSED s32 pad[4]; struct AudioBankSample *audioBookSample; s16 *curLoadedBook; struct AdpcmLoop *loopInfo; @@ -338,7 +338,7 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N s32 nSamplesToLoad; s32 spFC; - s32 pad2[2]; + UNUSED s32 pad2[2]; s32 loopInfo_2; u8 *sampleAddr; @@ -350,9 +350,8 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N s32 endPos; s32 nSamplesToProcess; - s32 pad3; + UNUSED s32 pad3; - //u32 spE4; s32 s3; s32 leftRight; s32 s4; @@ -362,16 +361,15 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N u32 var_t2; u8 *var_a0_2; - //s32 spD8; s32 s5Aligned; s32 temp_t6; s32 nParts; s32 curPart; s32 aligned; - s32 pad4; + UNUSED s32 pad4; s32 resampledTempLen; /* compiler-managed */ u16 noteSamplesDmemAddrBeforeResampling; - s32 pad6[1]; + UNUSED s32 pad6[1]; struct Note *note; u16 addr; @@ -387,9 +385,6 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N synthesisState->curVolRight = 0; synthesisState->prevHeadsetPanRight = 0; synthesisState->prevHeadsetPanLeft = 0; - //synthesisState->reverbVol = noteSubEu->reverbVol; - ////synthesisState->unk5 = 0; - //note->noteSubEu.finished = 0; } resamplingRateFixedPoint = noteSubEu->resamplingRateFixedPoint; @@ -398,7 +393,6 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N nSamplesToLoad = (samplesLenFixedPoint >> 0x10); synthesisState->samplePosFrac = samplesLenFixedPoint & 0xFFFF; // m2c didn't have & 0xFFFF -//var_a0 = noteSubEu->unk0; if (noteSubEu->isSyntheticWave) { cmd = load_wave_samples(cmd, noteSubEu, synthesisState, nSamplesToLoad); @@ -406,24 +400,14 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N synthesisState->samplePosInt += nSamplesToLoad; } else { audioBookSample = noteSubEu->sound.audioBankSound->sample; - //sp130 = audioBookSample; loopInfo = audioBookSample->loop; - //sp12C = loopInfo; endPos = loopInfo->end; sampleAddr = audioBookSample->sampleAddr; // book? resampledTempLen = 0; - //if (nParts > 0) { - // nSamplesToLoad = samplesLenFixedPoint >> 0x10; - // sp114 = flags; - // var_s2_2 = cmd; -//loop_6: + for (curPart = 0; curPart < nParts; curPart++) { nAdpcmSamplesProcessed = 0; s4 = 0; - - - //temp_a1 = audioBookSample->unkC; - //temp_a2_2 = temp_a1 + 8; if (nParts == 1) { samplesLenAdjusted = nSamplesToLoad; @@ -435,27 +419,22 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N // sm64 also has if (audioBookSample->codec == CODEC_A) { if (curLoadedBook != (*audioBookSample->book).book) { u32 nEntries; - //temp_v0_3 = var_s2_2; - // var_s2_2 += 8; - //temp_v0_3->unk0 = ((temp_a1->unk0 * 16 * temp_a1->unk4) & 0xFFFFFF) | 0x0B000000; - //temp_v0_3->unk4 = (s32) ((((u32) (noteSubEu->unk0 << 0xB) >> 0x1D) * 2) + temp_a2_2 + 0x80000000); - //var_a0 = noteSubEu->unk0; curLoadedBook = audioBookSample->book->book; // or just one book? nEntries = 16 * audioBookSample->book->order * audioBookSample->book->npredictors; aLoadADPCM(cmd++, nEntries, VIRTUAL_TO_PHYSICAL2(noteSubEu->bookOffset+curLoadedBook)); // noteSubEu here unsure but seems better? } if (noteSubEu->bookOffset != 0) { - curLoadedBook = &gUnknownData_800F6290; // type? + curLoadedBook = &gUnknownData_800F6290[0]; } while (nAdpcmSamplesProcessed != samplesLenAdjusted) { -//loop_15: + s32 samplesRemaining; s32 s1; noteFinished = FALSE; restart = FALSE; - //temp_a2_3 = synthesisState->samplePosInt; + s3 = synthesisState->samplePosInt & 0xF; samplesRemaining = endPos - synthesisState->samplePosInt; nSamplesToProcess = samplesLenAdjusted - nAdpcmSamplesProcessed; @@ -464,11 +443,10 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N } a1 = 16 - s3; - //var_s5 = a1; + if (nSamplesToProcess < samplesRemaining) { loopInfo_2 = ((nSamplesToProcess - a1) + 0xF) / 16; s1 = loopInfo_2 * 16; - //var_t0 = loopInfo_2; var_s6 = (a1 + s1) - nSamplesToProcess; } else { s1 = samplesRemaining - a1; @@ -488,86 +466,48 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N if (loopInfo_2 != 0) { temp_t6 = ((synthesisState->samplePosInt - s3) + 16) / 16; // diff from sm64 sh if (audioBookSample->loaded == 0x81) { // sm64 has audioBookSample->medium - //var_s0 = ((loopInfo_2 * 9) + 0x1F) & ~0xF; var_a0_2 = (temp_t6 * 9) + sampleAddr; } else { - //spD8 = nSamplesToProcess; - //sp11C = noteFinished; - //sp118 = restart; - //spE4 = samplesLenAdjusted; - //temp_a1_3 += ((loopInfo_2 * 9) + 0x1F) & ~0xF; - //var_s0 = temp_a1_3; var_a0_2 = dma_sample_data((uintptr_t) (temp_t6 * 9) + sampleAddr, ALIGN(((loopInfo_2 * 9) + 16), 4), flags, &synthesisState->sampleDmaIndex); // unsure flags? } - //var_t1 = 0x540 - var_s0; + var_t2 = ((uintptr_t)var_a0_2 & 0xF); - - //var_s2_2->unk4 = (s32) ((var_a0_2 - var_t2) + 0x80000000); aligned = ALIGN(((loopInfo_2 * 9) + 16), 4); addr = (0x540 - aligned) & 0xFFFF; // DMEM_ADDR_COMPRESSED_ADPCM_DATA - //var_s2_2->unk0 = (((var_s0 >> 4) & 0xFF) << 16) | 0x14000000 | ((0x540 - var_s0) & 0xFFFF); - // var_s2_2 += 8; - //aLoadBuffer(cmd++, ALIGN(((loopInfo_2 * 9) + 16), 4), addr, VIRTUAL_TO_PHYSICAL2(var_a0_2 - var_t2)); + aLoadBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(var_a0_2 - var_t2), addr, aligned); } else { s1 = 0; // ? var_t2 = 0; - //addr = 0x540 - (((loopInfo_2 * 9) + 16)); } - //temp_v0_4 = var_s2_2; + if (synthesisState->restart != FALSE) { aSetLoop(cmd++, VIRTUAL_TO_PHYSICAL2(audioBookSample->loop->state)); - //temp_v0_4->unk0 = 0x0F000000; - //var_s2_2 += 8; - //temp_v0_4->unk4 = (s32) (audioBookSample->unk8 + 0x80000010); + flags = A_LOOP; synthesisState->restart = FALSE; } nSamplesInThisIteration = (s1 + a1) - var_s6; s5Aligned = ALIGN(s4 + 16, 4); if (nAdpcmSamplesProcessed == 0) { - //var_a2 = s1 * 2; - //var_s2_2->unk4 = (s32) ((var_a2 & 0xFFFF) | 0x01A00000); - ///var_s2_2->unk0 = ((var_t1 + var_t2) & 0xFFFF) | 0x08000000; - //temp_s2 = var_s2_2 + 8; - //temp_s2->unk0 = (s32) (((sp114 & 0xFF) << 0x10) | 0x01000000); - //temp_s2->unk4 = (s32) VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->adpcmdecState); - //var_s2_2 = temp_s2 + 8; - //spFC = s3 * 2; + aligned = ALIGN(((loopInfo_2 * 9) + 16), 4); addr = (0x540 - aligned) & 0xFFFF; aSetBuffer(cmd++, 0, addr + var_t2, 0x1A0, s1 * 2); // unsure // s1 or s3 here? aADPCMdec(cmd++, flags, VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->adpcmdecState)); spFC = s3 * 2; - //nSamplesInThisIteration = (s1 + a1) - var_s6; + } else { - // temp_t8 = (s4 + 0x1F) & ~0xF; - // var_s2_2->unk0 = ((var_t1 + var_t2) & 0xFFFF) | 0x08000000; - // var_a2 = s1 * 2; - // var_s2_2->unk4 = (s32) (((temp_t8 + 0x1A0) << 0x10) | (var_a2 & 0xFFFF)); - // temp_s2_2 = var_s2_2 + 8; - // temp_s2_2->unk0 = (s32) (((sp114 & 0xFF) << 0x10) | 0x01000000); - // temp_s2_2->unk4 = (s32) VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->adpcmdecState); - // temp_s2_3 = temp_s2_2 + 8; - // temp_s2_3->unk0 = (s32) (((temp_t8 + (s3 * 2) + 0x1A0) & 0xFFFFFF) | 0x0A000000); - // temp_s2_3->unk4 = (s32) (((s4 + 0x1A0) << 0x10) | ((nSamplesInThisIteration * 2) & 0xFFFF)); - // var_s2_2 = temp_s2_3 + 8; + aligned = ALIGN(((loopInfo_2 * 9) + 16), 4); addr = (0x540 - aligned) & 0xFFFF; aSetBuffer(cmd++, 0, addr + var_t2, 0x1A0 + s5Aligned, s1 * 2); // unsure - - // The real macro here. Decompme requires the below to work. - //aS8Dec(cmd++, flags, VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->adpcmdecState)); + aADPCMdec(cmd++, flags, VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->adpcmdecState)); - // {\ - // Acmd *_a = (Acmd *) (cmd++);\ - // _a->words.w0 = _SHIFTL(23, 24, 8) | _SHIFTL(flags, 16, 8);\ - // _a->words.w1 = (uintptr_t) VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->adpcmdecState);\ - // }; - //nSamplesInThisIteration = (s1 + a1) - var_s6; + aDMEMMove(cmd++, 0x1A0 + s5Aligned + (s3 * 2), 0x1A0 + s4, nSamplesInThisIteration * 2); } @@ -593,22 +533,8 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N if (noteFinished) { aClearBuffer(cmd++, 0x1A0 + s4, (samplesLenAdjusted - nAdpcmSamplesProcessed) * 2); - //var_s2_2->unk0 = ((s4 + 0x1A0) & 0xFFFFFF) | 0x02000000; - //var_s2_2->unk4 = (s32) ((samplesLenAdjusted - nAdpcmSamplesProcessed) * 2); - //var_s2_2 += 8; noteSubEu->finished = 1; // sm64 says = 1 note->noteSubEu.finished = 1; - //note->noteSubEu.enabled = 0; - //note->noteSubEu.samplePosInt = 0; - - //note->noteSubEu.stereoHeadsetEffects = note->noteSubEu.stereoHeadsetEffects | 0x20;// |= 0x20; - //note->noteSubEu.stereoHeadsetEffects = ~(1 << 6); - /* mips to c - arg1->unk0 = (s8) ((u8) arg1->unk0 | 0x20); - sp8C->unkB0 = (u8) (sp8C->unkB0 | 0x20); - sp8C->unkB0 = (u8) (sp8C->unkB0 & 0xFF7F); - */ - //spE4 = samplesLenAdjusted; func_800B6FB4(updateIndex, noteIndex); } else { @@ -618,9 +544,6 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N } else { synthesisState->samplePosInt += nSamplesToProcess; } - // if (nAdpcmSamplesProcessed != samplesLenAdjusted) { - // goto loop_15; - // } } } @@ -629,25 +552,8 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N noteSamplesDmemAddrBeforeResampling = 0x1A0 + spFC; break; case 2: - //temp_v0_5 = var_s2_2; switch(curPart) { case 0: - // temp_v0_6 = var_s2_2; - // var_s2_2 += 8; - // temp_v0_6->unk0 = ((((s32) var_t5 / 2) + 7) & 0xFFF8) | 0x11000000; - // temp_v0_6->unk4 = (s32) (((spFC + 0x1A0) << 0x10) | 0x20); - // spA0 = var_t5; - // sp9E = 0x20; - // var_a0 = arg1->unk0; - // temp_t7_3 = (u32) (var_a0 * 4) >> 0x1F; - // var_v1_2 = temp_t7_3; - // if (temp_t7_3 != 0) { - // var_s2_2->unk4 = (s32) (var_t5 + 0x10); - // var_s2_2->unk0 = ((var_t5 + 0x20) & 0xFFFFFF) | 0x02000000; - // var_a0 = arg1->unk0; - // var_s2_2 += 8; - // var_v1_2 = (u32) (var_a0 * 4) >> 0x1F; - // } aDownsampleHalf(cmd++, ALIGN(samplesLenAdjusted / 2, 3), 0x1A0 + spFC, DMEM_ADDR_RESAMPLED); resampledTempLen = samplesLenAdjusted; noteSamplesDmemAddrBeforeResampling = DMEM_ADDR_RESAMPLED; @@ -656,11 +562,6 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N } break; case 1: - //var_s2_2 += 8; - // temp_v0_5->unk0 = ((((s32) var_t5 / 2) + 7) & 0xFFF8) | 0x11000000; - // temp_v0_5->unk4 = (s32) (((spFC + 0x1A0) << 0x10) | ((spA0 + 0x20) & 0xFFFF)); - // var_a0 = arg1->unk0; - // var_t6 = (u32) (var_a0 * 4) >> 0x1F; aDownsampleHalf(cmd++, ALIGN(samplesLenAdjusted / 2, 3), DMEM_ADDR_RESAMPLED2 + spFC, resampledTempLen + DMEM_ADDR_RESAMPLED); break; @@ -677,10 +578,7 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N flags = A_INIT; noteSubEu->needsInit = FALSE; } - //temp_a2_4 = inBuf * 2; - // flags = flags; - //sp114 = flags; - //flags = flags | sp54; + cmd = final_resample(cmd, synthesisState, inBuf * 2, resamplingRateFixedPoint, noteSamplesDmemAddrBeforeResampling, flags); if ((noteSubEu->headsetPanRight) || (synthesisState->prevHeadsetPanRight)) { @@ -691,7 +589,7 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N leftRight = 0; } cmd = func_800B86A0(cmd, noteSubEu, synthesisState, inBuf, 0, leftRight, flags); - //var_s2 = temp_v0_8; + if (noteSubEu->usesHeadsetPanEffects) { //synthesisState->restart = 1; cmd = note_apply_headset_pan_effects(cmd, noteSubEu, synthesisState, inBuf * 2, flags, leftRight); diff --git a/src/audio/synthesis.h b/src/audio/synthesis.h index 9d8de57a9..a1854442b 100644 --- a/src/audio/synthesis.h +++ b/src/audio/synthesis.h @@ -103,7 +103,7 @@ Acmd *synthesis_execute(Acmd*, s32*, s16*, s32); Acmd *synthesis_resample_and_mix_reverb(Acmd*, s32, s16, s16); Acmd *synthesis_save_reverb_samples(Acmd*, s16, s16); Acmd *synthesis_do_one_audio_update(s16*, s32, Acmd*, s32); -u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s16 *aiBuf, s32 inBuf, u64 *cmd, s32 updateIndex); +Acmd *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s16 *aiBuf, s32 inBuf, Acmd *cmd, s32 updateIndex); Acmd *load_wave_samples(Acmd *acmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s32 nSamplesToLoad); Acmd *final_resample(Acmd *acmd, struct NoteSynthesisState *synthesisState, s32 count, u16 pitch, u16 dmemIn, u32 flags); Acmd *func_800B86A0(Acmd *cmd, struct NoteSubEu *note, struct NoteSynthesisState *synthesisState, s32 nSamples, u16 inBuf, s32 headsetPanSettings, u32 flags); diff --git a/src/code_80005FD0.c b/src/code_80005FD0.c index 7fe95d63f..060832135 100644 --- a/src/code_80005FD0.c +++ b/src/code_80005FD0.c @@ -830,86 +830,73 @@ void func_800070F4(void) { } } -#ifdef NON_MATCHING -// https://decomp.me/scratch/AqmzN -// Decently close overall but there's a huge amount of register mismatches -// Permuter has not had much luck finding solutions. -// Replacing `temp_s0` for `var_v0` is a pretty good start, but the permuter -// is unable to find any improvements after that :( - void func_800074D4(void) { - Player *var_a0_2; f32 temp_a0; + s32 temp; s32 sp68[8]; - UNUSED s32 temp_s0; + UNUSED s32 pad; s32 temp_t1; - s32 var_a3; - s32 var_a3_2; - s32 var_v0; - s32 this_loops_upper_bound_is_brough_to_you_by_the_number_eight = NUM_PLAYERS; - - for (var_a3 = 0; var_a3 < this_loops_upper_bound_is_brough_to_you_by_the_number_eight; ) { - gCourseCompletionPercentByRank[var_a3++] = 0.0f; + s32 i; + s32 j; + s32 this_loops_upper_bound_is_brough_to_you_by_the_number = 8; + + for (i = 0; i < this_loops_upper_bound_is_brough_to_you_by_the_number;) { + gCourseCompletionPercentByRank[i++] = 0.0f; } - var_v0 = 0; - for (var_a3 = 0; var_a3 < this_loops_upper_bound_is_brough_to_you_by_the_number_eight; var_a3++) { - var_a0_2 = &gPlayers[var_a3]; - if (var_a0_2->type & 0x800) { - sp68[var_v0] = var_a3; - gCourseCompletionPercentByRank[var_v0] = -gTimePlayerLastTouchedFinishLine[var_a3]; - var_v0++; + + for (j = 0, i = 0; i < this_loops_upper_bound_is_brough_to_you_by_the_number; i++) { + if (gPlayers[i].type & 0x800) { + sp68[j] = i; + gCourseCompletionPercentByRank[j] = -gTimePlayerLastTouchedFinishLine[i]; + j++; } } - temp_t1 = var_v0; - for (var_a3 = 0; var_a3 < this_loops_upper_bound_is_brough_to_you_by_the_number_eight; var_a3++) { - var_a0_2 = &gPlayers[var_a3]; - if (!(var_a0_2->type & 0x800)) { - sp68[var_v0] = var_a3; - gCourseCompletionPercentByRank[var_v0] = gCourseCompletionPercentByPlayerId[var_a3]; - var_v0++; + temp_t1 = j; + for (i = 0; i < this_loops_upper_bound_is_brough_to_you_by_the_number; i++) { + if (!(gPlayers[i].type & 0x800)) { + sp68[j] = i; + gCourseCompletionPercentByRank[j] = gCourseCompletionPercentByPlayerId[i]; + j++; } } - - for (var_a3 = 0; var_a3 < temp_t1 - 1; var_a3++) { - for (var_a3_2 = var_a3 + 1; var_a3_2 < temp_t1; var_a3_2++) { - if (gCourseCompletionPercentByRank[var_a3] < gCourseCompletionPercentByRank[var_a3_2]) { - var_v0 = sp68[var_a3]; - sp68[var_a3] = sp68[var_a3_2]; - sp68[var_a3_2] = var_v0; - temp_a0 = gCourseCompletionPercentByRank[var_a3]; - gCourseCompletionPercentByRank[var_a3] = gCourseCompletionPercentByRank[var_a3_2]; - gCourseCompletionPercentByRank[var_a3_2] = temp_a0; + + for (i = 0; i < (temp_t1 - 1); i++) { + for (j = i + 1; j < temp_t1; j++) { + if (gCourseCompletionPercentByRank[i] < gCourseCompletionPercentByRank[j]) { + temp = sp68[i]; + sp68[i] = sp68[j]; + sp68[j] = temp; + temp_a0 = gCourseCompletionPercentByRank[i]; + gCourseCompletionPercentByRank[i] = gCourseCompletionPercentByRank[j]; + gCourseCompletionPercentByRank[j] = temp_a0; + } + } + } + + for (i = temp_t1; i < (this_loops_upper_bound_is_brough_to_you_by_the_number - 1); i++) { + for (j = i + 1; j < this_loops_upper_bound_is_brough_to_you_by_the_number; j++) { + if (gCourseCompletionPercentByRank[i] < gCourseCompletionPercentByRank[j]) { + temp = sp68[i]; + sp68[i] = sp68[j]; + sp68[j] = temp; + temp_a0 = gCourseCompletionPercentByRank[i]; + gCourseCompletionPercentByRank[i] = gCourseCompletionPercentByRank[j]; + gCourseCompletionPercentByRank[j] = temp_a0; } } } - for (var_a3 = temp_t1; var_a3 < this_loops_upper_bound_is_brough_to_you_by_the_number_eight - 1; var_a3++) { - for (var_a3_2 = var_a3 + 1; var_a3_2 < this_loops_upper_bound_is_brough_to_you_by_the_number_eight; var_a3_2++) { - if (gCourseCompletionPercentByRank[var_a3] < gCourseCompletionPercentByRank[var_a3_2]) { - var_v0 = sp68[var_a3]; - sp68[var_a3] = sp68[var_a3_2]; - sp68[var_a3_2] = var_v0; - temp_a0 = gCourseCompletionPercentByRank[var_a3]; - gCourseCompletionPercentByRank[var_a3] = gCourseCompletionPercentByRank[var_a3_2]; - gCourseCompletionPercentByRank[var_a3_2] = temp_a0; - } - } + for (i = 0; i < 8; i++) { + D_801643E0[i] = gGPCurrentRaceRankByPlayerId[i]; } - for (var_a3 = 0; var_a3 < NUM_PLAYERS; var_a3++) { - D_801643E0[var_a3] = gGPCurrentRaceRankByPlayerId[var_a3]; - } - - for (var_a3 = 0; var_a3 < this_loops_upper_bound_is_brough_to_you_by_the_number_eight; var_a3++) { - gGPCurrentRaceRankByPlayerId[sp68[var_a3]] = var_a3; - gGPCurrentRacePlayerIdByRank[var_a3] = sp68[var_a3]; + for (i = 0; i < this_loops_upper_bound_is_brough_to_you_by_the_number; i++) { + gGPCurrentRaceRankByPlayerId[sp68[i]] = i; + gGPCurrentRacePlayerIdByRank[i] = sp68[i]; } } -#else -GLOBAL_ASM("asm/non_matchings/code_80005FD0/func_800074D4.s") -#endif s32 func_80007BF8(u16 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4) { s32 var_v1; @@ -927,13 +914,11 @@ s32 func_80007BF8(u16 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4) { return var_v1; } -#ifdef NON_MATCHING // Likely func equiv -// https://decomp.me/scratch/Te4u1 - -void func_80007D04(s32 playerId, Player *player) { +void func_80007D04(s32 playerId, Player* player) { s16 temp_t1; s16 temp_t2; s32 var_v0; + temp_t1 = D_80164450[D_80163478]; temp_t2 = D_80164450[playerId]; @@ -954,33 +939,40 @@ void func_80007D04(s32 playerId, Player *player) { return; } - // Something wrong here. Maybe needs - // var_v0 = 0; + switch (gCCSelection) { // WTF, FAKE ? + case 3: + break; + } + switch (gCCSelection) { - case CC_50: + case 0: var_v0 = 0; if (playerId == D_80163344[0]) { var_v0 = 0x14; } break; + case 1: var_v0 = 8; if (playerId == D_80163344[0]) { var_v0 = 0x18; } break; + case 2: var_v0 = 0x12; if (playerId == D_80163344[0]) { var_v0 = 0x24; } break; + case 3: var_v0 = 8; if (playerId == D_80163344[0]) { var_v0 = 0x18; } break; + default: var_v0 = 0; break; @@ -990,7 +982,6 @@ void func_80007D04(s32 playerId, Player *player) { player->effects |= 0x200000; player_speed(player); D_801634C0[playerId] = 1; - } else if (temp_t2 < (temp_t1 + var_v0 + 0x32)) { player->effects &= ~0x200000; player_speed(player); @@ -1006,10 +997,6 @@ void func_80007D04(s32 playerId, Player *player) { } } -#else -GLOBAL_ASM("asm/non_matchings/code_80005FD0/func_80007D04.s") -#endif - void func_80007FA4(s32 arg0, Player *player, f32 arg2) { f32 temp_f0; f32 temp_f12; @@ -5912,32 +5899,32 @@ void func_80017054(Camera *camera, UNUSED Player *player, UNUSED s32 index, s32 // https://decomp.me/scratch/Ck7hV // Really crazy diff, permuter only able to find fakematches for improvements (and they're big improvements) // There's something really, really wrong with the empty `if` statement -void func_80017054(Camera *camera, Player *player, s32 index, s32 cameraId) { - s32 stackPadding0; - s32 stackPadding1; +void func_80017054(Camera *camera, UNUSED Player *player, UNUSED s32 index, s32 cameraId) { + UNUSED s32 stackPadding0; + UNUSED s32 stackPadding1; f32 spAC; f32 spA8; f32 spA4; - s32 stackPadding2; - s32 stackPadding3; + UNUSED s32 stackPadding2; + UNUSED s32 stackPadding3; f32 sp98; f32 sp94; f32 sp90; f32 sp8C; f32 sp88; f32 sp84; - f32 stackPadding4; - f32 stackPadding5; - f32 stackPadding6; - s32 stackPadding7; - s32 stackPadding8; + UNUSED f32 stackPadding4; + UNUSED f32 stackPadding5; + UNUSED f32 stackPadding6; + UNUSED s32 stackPadding7; + UNUSED s32 stackPadding8; s16 sp6E; s16 sp6C; - s32 stackPadding9; - s32 stackPaddingA; - s32 stackPaddingB; + UNUSED s32 stackPadding9; + UNUSED s32 stackPaddingA; + UNUSED s32 stackPaddingB; s32 pathIndex; - s32 stackPaddingC; + UNUSED s32 stackPaddingC; s32 sp58; s16 sp56; s32 playerId; From a1286750ce6945d5e9d5eb58a6b28370ddc9e354 Mon Sep 17 00:00:00 2001 From: KiritoDv Date: Wed, 1 May 2024 10:09:49 -0600 Subject: [PATCH 9/9] WIP Compilation --- .gitignore | 1 + .gitmodules | 3 + CMakeLists.txt | 520 ++ courses/all_course_data.h | 1 + courses/banshee_boardwalk/course_data.c | 4 +- courses/banshee_boardwalk/course_data.h | 4 +- .../course_displaylists.inc.c | 4 +- .../course_displaylists.inc.h | 2 +- courses/banshee_boardwalk/course_offsets.c | 6 +- courses/big_donut/course_data.c | 4 +- courses/big_donut/course_data.h | 4 +- courses/big_donut/course_displaylists.inc.c | 4 +- courses/big_donut/course_displaylists.inc.h | 2 +- courses/big_donut/course_offsets.c | 2 +- courses/block_fort/course_data.c | 4 +- courses/block_fort/course_data.h | 4 +- courses/block_fort/course_displaylists.inc.c | 4 +- courses/block_fort/course_displaylists.inc.h | 2 +- courses/block_fort/course_offsets.c | 2 +- courses/bowsers_castle/course_data.c | 4 +- courses/bowsers_castle/course_data.h | 4 +- .../bowsers_castle/course_displaylists.inc.c | 4 +- .../bowsers_castle/course_displaylists.inc.h | 2 +- courses/bowsers_castle/course_offsets.c | 2 +- courses/choco_mountain/course_data.c | 4 +- courses/choco_mountain/course_data.h | 4 +- .../choco_mountain/course_displaylists.inc.c | 4 +- .../choco_mountain/course_displaylists.inc.h | 2 +- courses/choco_mountain/course_offsets.c | 2 +- courses/courseTable.c | 3 +- courses/courseTable.h | 2 +- courses/dks_jungle_parkway/course_data.c | 4 +- courses/dks_jungle_parkway/course_data.h | 4 +- .../course_displaylists.inc.c | 4 +- .../course_displaylists.inc.h | 2 +- courses/dks_jungle_parkway/course_offsets.c | 2 +- courses/double_deck/course_data.c | 4 +- courses/double_deck/course_data.h | 4 +- courses/double_deck/course_displaylists.inc.c | 4 +- courses/double_deck/course_displaylists.inc.h | 2 +- courses/double_deck/course_offsets.c | 2 +- courses/frappe_snowland/course_data.c | 4 +- courses/frappe_snowland/course_data.h | 4 +- .../frappe_snowland/course_displaylists.inc.c | 4 +- .../frappe_snowland/course_displaylists.inc.h | 2 +- courses/frappe_snowland/course_offsets.c | 2 +- courses/kalimari_desert/course_data.c | 4 +- courses/kalimari_desert/course_data.h | 4 +- .../kalimari_desert/course_displaylists.inc.c | 4 +- .../kalimari_desert/course_displaylists.inc.h | 2 +- courses/kalimari_desert/course_offsets.c | 2 +- courses/koopa_troopa_beach/course_data.c | 4 +- courses/koopa_troopa_beach/course_data.h | 4 +- .../course_displaylists.inc.c | 4 +- .../course_displaylists.inc.h | 2 +- courses/koopa_troopa_beach/course_offsets.c | 2 +- courses/luigi_raceway/course_data.c | 4 +- courses/luigi_raceway/course_data.h | 4 +- .../luigi_raceway/course_displaylists.inc.c | 4 +- .../luigi_raceway/course_displaylists.inc.h | 2 +- courses/luigi_raceway/course_offsets.c | 2 +- courses/mario_raceway/course_data.c | 4 +- courses/mario_raceway/course_data.h | 4 +- .../mario_raceway/course_displaylists.inc.c | 4 +- .../mario_raceway/course_displaylists.inc.h | 2 +- courses/mario_raceway/course_offsets.c | 2 +- courses/moo_moo_farm/course_data.c | 4 +- courses/moo_moo_farm/course_data.h | 4 +- .../moo_moo_farm/course_displaylists.inc.c | 4 +- .../moo_moo_farm/course_displaylists.inc.h | 2 +- courses/moo_moo_farm/course_offsets.c | 2 +- courses/rainbow_road/course_data.c | 4 +- courses/rainbow_road/course_data.h | 4 +- .../rainbow_road/course_displaylists.inc.c | 4 +- .../rainbow_road/course_displaylists.inc.h | 2 +- courses/rainbow_road/course_offsets.c | 2 +- courses/royal_raceway/course_data.c | 4 +- courses/royal_raceway/course_data.h | 4 +- .../royal_raceway/course_displaylists.inc.c | 4 +- .../royal_raceway/course_displaylists.inc.h | 2 +- courses/royal_raceway/course_offsets.c | 2 +- courses/sherbet_land/course_data.c | 4 +- courses/sherbet_land/course_data.h | 4 +- .../sherbet_land/course_displaylists.inc.c | 4 +- .../sherbet_land/course_displaylists.inc.h | 2 +- courses/sherbet_land/course_offsets.c | 2 +- courses/skyscraper/course_data.c | 4 +- courses/skyscraper/course_data.h | 4 +- courses/skyscraper/course_displaylists.inc.c | 4 +- courses/skyscraper/course_displaylists.inc.h | 2 +- courses/skyscraper/course_offsets.c | 2 +- courses/staff_ghost_data.c | 3 +- courses/toads_turnpike/course_data.c | 5 +- courses/toads_turnpike/course_data.h | 4 +- .../toads_turnpike/course_displaylists.inc.c | 4 +- .../toads_turnpike/course_displaylists.inc.h | 2 +- courses/toads_turnpike/course_offsets.c | 2 +- courses/wario_stadium/course_data.c | 4 +- courses/wario_stadium/course_data.h | 4 +- .../wario_stadium/course_displaylists.inc.c | 4 +- .../wario_stadium/course_displaylists.inc.h | 2 +- courses/wario_stadium/course_offsets.c | 2 +- courses/yoshi_valley/course_data.c | 6 +- courses/yoshi_valley/course_data.h | 4 +- .../yoshi_valley/course_displaylists.inc.c | 4 +- .../yoshi_valley/course_displaylists.inc.h | 2 +- courses/yoshi_valley/course_offsets.c | 2 +- enhancements/flycam.patch | 35 +- include/PR/R4300.h | 453 -- include/PR/abi.h | 999 ---- include/PR/gbi.h | 4750 ----------------- include/PR/gs2dex.h | 392 -- include/PR/gu.h | 55 - include/PR/libaudio.h | 2 +- include/PR/libultra.h | 18 - include/PR/mbi.h | 101 - include/PR/os.h | 800 --- include/PR/os_ai.h | 92 - include/PR/os_cache.h | 96 - include/PR/os_cont.h | 207 - include/PR/os_eeprom.h | 107 - include/PR/os_exception.h | 119 - include/PR/os_internal.h | 18 - include/PR/os_libc.h | 10 - include/PR/os_message.h | 164 - include/PR/os_misc.h | 11 - include/PR/os_pi.h | 80 - include/PR/os_rdp.h | 92 - include/PR/os_thread.h | 75 - include/PR/os_time.h | 27 - include/PR/os_tlb.h | 107 - include/PR/os_vi.h | 117 - include/PR/rcp.h | 881 --- include/PR/sptask.h | 230 - include/PR/ucode.h | 27 - include/PR/ultratypes.h | 47 - include/actor_types.h | 14 +- include/common_structs.h | 4 +- include/course.h | 4 +- include/course_offsets.h | 2 +- include/debug.h | 8 +- include/kart_attributes.h | 2 +- include/libc/stddef.h | 2 +- include/libc/string.h | 2 +- include/macros.h | 4 + include/mk64.h | 7 + include/segments.h | 6 +- include/ultra64.h | 33 - libultraship | 1 + src/actors/banana/render.inc.c | 10 +- src/actors/blue_and_red_shells/render.inc.c | 18 +- src/actors/box_truck/render.inc.c | 8 +- src/actors/cow/render.inc.c | 10 +- src/actors/fake_item_box/render.inc.c | 8 +- src/actors/falling_rock/update.inc.c | 16 +- src/actors/green_shell/render.inc.c | 10 +- src/actors/kiwano_fruit/render.inc.c | 10 +- src/actors/paddle_boat/render.inc.c | 16 +- src/actors/paddle_boat/update.inc.c | 6 +- src/actors/piranha_plant/render.inc.c | 10 +- src/actors/railroad_crossing/render.inc.c | 8 +- src/actors/school_bus/render.inc.c | 8 +- src/actors/train/render.inc.c | 8 +- src/actors/trees/render.inc.c | 82 +- src/actors/wario_sign/render.inc.c | 8 +- src/audio/data.c | 2 +- src/audio/effects.c | 14 +- src/audio/external.c | 38 +- src/audio/external.h | 2 +- src/audio/heap.c | 8 +- src/audio/heap.h | 2 +- src/audio/internal.h | 6 +- src/audio/load.c | 29 +- src/audio/load.h | 5 +- src/audio/playback.c | 46 +- src/audio/playback.h | 2 +- src/audio/port_eu.c | 24 +- src/audio/seqplayer.c | 130 +- src/audio/seqplayer.h | 2 +- src/audio/synthesis.c | 24 +- src/audio/synthesis.h | 2 +- src/buffers.h | 6 +- src/buffers/buffers.c | 2 +- src/buffers/gfx_output_buffer.c | 2 +- src/buffers/gfx_output_buffer.h | 2 +- src/buffers/memory_pool.c | 2 +- src/buffers/random.h | 2 +- src/buffers/trig_tables.c | 2 +- src/buffers/trig_tables_bss.c | 2 +- src/camera.c | 2 +- src/code_800029B0.c | 2 +- src/code_800029B0.h | 2 +- src/code_80004740.c | 8 +- src/code_80005FD0.c | 130 +- src/code_8003DC40.c | 2 +- src/code_80057C60.c | 140 +- src/code_80057C60.h | 12 +- src/code_80057C60_var.c | 10 +- src/code_8006E9C0.c | 14 +- src/code_80086E70.c | 224 +- src/code_80091440.c | 6 +- src/code_80091440.h | 2 +- src/code_80091750.c | 60 +- src/code_800AF9B0.c | 6 +- src/crash_screen.c | 20 +- src/crash_screen.h | 2 +- src/data/data_segment2.c | 4 +- src/data/some_data.h | 2 +- src/data/trig_tables_bss.c | 2 +- src/data_segment2.h | 2 +- src/debug/all_variables.h | 2 +- src/debug/crash_screen_enhancement.c | 10 +- src/debug/crash_screen_enhancement.h | 2 +- src/debug/debug.c | 26 +- src/debug/debug.inc.c | 16 +- src/effects.c | 86 +- src/ending/camera_junk.c | 4 +- src/ending/ceremony_and_credits.c | 29 +- src/ending/code_80280000.c | 9 +- src/ending/code_80281780.c | 4 +- src/ending/code_80281C40.c | 3 +- src/ending/code_80281C40.h | 2 +- src/ending/credits.h | 2 +- src/ending/dl_unk_80284EE0.c | 4 +- src/ending/podium_ceremony_actors.c | 13 +- src/gbiMacro.c | 2 +- src/kart_dma.c | 2 +- src/main.c | 30 +- src/main.h | 2 + src/math_util_2.c | 18 +- src/menus.c | 56 +- src/menus.h | 1 - src/os/_Printf.c | 2 +- src/os/__osDevMgrMain.c | 4 +- src/os/__osLeoInterrupt.c | 2 +- src/os/contpfs.c | 26 +- src/os/controller.h | 2 +- src/os/guLookAtRef.c | 2 +- src/os/guMtxCatF.c | 3 +- src/os/guMtxCatL.c | 3 +- src/os/libaudio_internal.h | 2 +- src/os/libultra_internal.h | 2 +- src/os/osCartRomInit.c | 2 +- src/os/osCreatePiManager.c | 4 +- src/os/osCreateViManager.c | 6 +- src/os/osInitialize.c | 2 +- src/os/osPfsAllocateFile.c | 6 +- src/os/osPfsChecker.c | 4 +- src/os/osPfsDeleteFile.c | 6 +- src/os/osPfsIsPlug.c | 2 +- src/os/osPfsNumFiles.c | 2 +- src/os/osPfsReadWriteFile.c | 4 +- src/os/osPfsSearchFile.c | 6 +- src/os/osTimer.c | 2 +- src/os/piint.h | 8 +- src/player_controller.c | 330 +- src/port/Engine.cpp | 194 + src/port/Engine.h | 35 + src/port/GBIMiddleware.cpp | 54 + src/port/Game.cpp | 42 + src/port/Variables.cpp | 6 + .../importers/GenericArrayFactory.cpp | 104 + .../resource/importers/GenericArrayFactory.h | 11 + src/port/resource/importers/ResourceUtil.h | 15 + src/port/resource/importers/Vec3fFactory.cpp | 27 + src/port/resource/importers/Vec3fFactory.h | 11 + src/port/resource/importers/Vec3sFactory.cpp | 27 + src/port/resource/importers/Vec3sFactory.h | 11 + src/port/resource/type/Animation.cpp | 11 + src/port/resource/type/Animation.h | 38 + src/port/resource/type/ColPoly.cpp | 11 + src/port/resource/type/ColPoly.h | 33 + src/port/resource/type/EnvSettings.cpp | 11 + src/port/resource/type/EnvSettings.h | 40 + src/port/resource/type/GenericArray.cpp | 11 + src/port/resource/type/GenericArray.h | 55 + src/port/resource/type/Hitbox.cpp | 11 + src/port/resource/type/Hitbox.h | 16 + src/port/resource/type/Limb.cpp | 11 + src/port/resource/type/Limb.h | 37 + src/port/resource/type/Message.cpp | 19 + src/port/resource/type/Message.h | 32 + src/port/resource/type/ObjectInit.cpp | 11 + src/port/resource/type/ObjectInit.h | 30 + src/port/resource/type/ResourceType.h | 21 + src/port/resource/type/Script.cpp | 19 + src/port/resource/type/Script.h | 26 + src/port/resource/type/Skeleton.cpp | 11 + src/port/resource/type/Skeleton.h | 19 + src/port/resource/type/Vec3fArray.cpp | 11 + src/port/resource/type/Vec3fArray.h | 25 + src/port/resource/type/Vec3sArray.cpp | 11 + src/port/resource/type/Vec3sArray.h | 25 + src/port/ui/ImguiUI.cpp | 510 ++ src/port/ui/ImguiUI.h | 16 + src/port/ui/ResolutionEditor.cpp | 422 ++ src/port/ui/ResolutionEditor.h | 19 + src/port/ui/UIWidgets.cpp | 1033 ++++ src/port/ui/UIWidgets.h | 210 + src/profiler.c | 2 +- src/racing/actors.c | 91 +- src/racing/actors.h | 14 +- src/racing/actors_extended.c | 22 +- src/racing/collision.c | 149 +- src/racing/math_util.c | 12 +- src/racing/math_util.h | 2 +- src/racing/memory.c | 42 +- src/racing/race_logic.c | 6 +- src/racing/render_courses.c | 50 +- src/racing/skybox_and_splitscreen.c | 6 +- src/racing/skybox_and_splitscreen.h | 2 +- src/render_objects.c | 36 +- src/render_player.c | 40 +- src/save.c | 48 +- src/save.h | 2 +- src/spawn_players.c | 6 +- src/staff_ghosts.c | 8 +- src/staff_ghosts.h | 2 +- src/textures.h | 2 +- src/update_objects.c | 86 +- tools/linkonly_generator.py | 4 +- yamls/us/ceremony_data.yml | 4 +- yamls/us/ceremony_rsp_init_80284EE0.yml | 4 +- yamls/us/common_data.yml | 6 +- yamls/us/data_800E45C0.yml | 2 +- yamls/us/data_800E8700.yml | 6 +- yamls/us/data_segment2.yml | 10 +- yamls/us/startup_logo.yml | 4 +- 328 files changed, 5342 insertions(+), 11678 deletions(-) create mode 100644 CMakeLists.txt delete mode 100644 include/PR/R4300.h delete mode 100644 include/PR/abi.h delete mode 100644 include/PR/gbi.h delete mode 100644 include/PR/gs2dex.h delete mode 100644 include/PR/gu.h delete mode 100644 include/PR/libultra.h delete mode 100644 include/PR/mbi.h delete mode 100644 include/PR/os.h delete mode 100644 include/PR/os_ai.h delete mode 100644 include/PR/os_cache.h delete mode 100644 include/PR/os_cont.h delete mode 100644 include/PR/os_eeprom.h delete mode 100644 include/PR/os_exception.h delete mode 100644 include/PR/os_internal.h delete mode 100644 include/PR/os_libc.h delete mode 100644 include/PR/os_message.h delete mode 100644 include/PR/os_misc.h delete mode 100644 include/PR/os_pi.h delete mode 100644 include/PR/os_rdp.h delete mode 100644 include/PR/os_thread.h delete mode 100644 include/PR/os_time.h delete mode 100644 include/PR/os_tlb.h delete mode 100644 include/PR/os_vi.h delete mode 100644 include/PR/rcp.h delete mode 100644 include/PR/sptask.h delete mode 100644 include/PR/ucode.h delete mode 100644 include/PR/ultratypes.h delete mode 100644 include/ultra64.h create mode 160000 libultraship create mode 100644 src/port/Engine.cpp create mode 100644 src/port/Engine.h create mode 100644 src/port/GBIMiddleware.cpp create mode 100644 src/port/Game.cpp create mode 100644 src/port/Variables.cpp create mode 100644 src/port/resource/importers/GenericArrayFactory.cpp create mode 100644 src/port/resource/importers/GenericArrayFactory.h create mode 100644 src/port/resource/importers/ResourceUtil.h create mode 100644 src/port/resource/importers/Vec3fFactory.cpp create mode 100644 src/port/resource/importers/Vec3fFactory.h create mode 100644 src/port/resource/importers/Vec3sFactory.cpp create mode 100644 src/port/resource/importers/Vec3sFactory.h create mode 100644 src/port/resource/type/Animation.cpp create mode 100644 src/port/resource/type/Animation.h create mode 100644 src/port/resource/type/ColPoly.cpp create mode 100644 src/port/resource/type/ColPoly.h create mode 100644 src/port/resource/type/EnvSettings.cpp create mode 100644 src/port/resource/type/EnvSettings.h create mode 100644 src/port/resource/type/GenericArray.cpp create mode 100644 src/port/resource/type/GenericArray.h create mode 100644 src/port/resource/type/Hitbox.cpp create mode 100644 src/port/resource/type/Hitbox.h create mode 100644 src/port/resource/type/Limb.cpp create mode 100644 src/port/resource/type/Limb.h create mode 100644 src/port/resource/type/Message.cpp create mode 100644 src/port/resource/type/Message.h create mode 100644 src/port/resource/type/ObjectInit.cpp create mode 100644 src/port/resource/type/ObjectInit.h create mode 100644 src/port/resource/type/ResourceType.h create mode 100644 src/port/resource/type/Script.cpp create mode 100644 src/port/resource/type/Script.h create mode 100644 src/port/resource/type/Skeleton.cpp create mode 100644 src/port/resource/type/Skeleton.h create mode 100644 src/port/resource/type/Vec3fArray.cpp create mode 100644 src/port/resource/type/Vec3fArray.h create mode 100644 src/port/resource/type/Vec3sArray.cpp create mode 100644 src/port/resource/type/Vec3sArray.h create mode 100644 src/port/ui/ImguiUI.cpp create mode 100644 src/port/ui/ImguiUI.h create mode 100644 src/port/ui/ResolutionEditor.cpp create mode 100644 src/port/ui/ResolutionEditor.h create mode 100644 src/port/ui/UIWidgets.cpp create mode 100644 src/port/ui/UIWidgets.h diff --git a/.gitignore b/.gitignore index 94d3c4144..b5306452c 100755 --- a/.gitignore +++ b/.gitignore @@ -102,3 +102,4 @@ mingw64/ # torch torch.hash.yml +build* \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index 77ed99b48..db5197931 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,6 @@ [submodule "tools/torch"] path = tools/torch url = https://github.com/HarbourMasters/torch +[submodule "libultraship"] + path = libultraship + url = https://github.com/KiritoDv/libultraship/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..4c969792d --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,520 @@ +cmake_minimum_required(VERSION 3.16.0 FATAL_ERROR) + +# Set the project version and language +project(Spaghettify VERSION 0.1.0 LANGUAGES C CXX ASM) + +if(APPLE) + enable_language(OBJCXX) +endif() + +# Set the minimum version of CMake and the deployment target for macOS +set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version") + +# Set the C++ standard and enable the MSVC parallel build option +set(CMAKE_CXX_STANDARD 20 CACHE STRING "The C++ standard to use") +set(CMAKE_C_STANDARD 11 CACHE STRING "The C standard to use") +#add_compile_options(-fsanitize=address) +#add_link_options(-fsanitize=address) + +# Add a custom module path to locate additional CMake modules +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/") +include(FindFontconfig) + +if (WIN32) +include(cmake/automate-vcpkg.cmake) +# Forced to use MSVC +set(MSVC ON) + +if(MSVC) +set(VCPKG_TRIPLET x64-windows-static) +set(VCPKG_TARGET_TRIPLET x64-windows-static) +else() +set(VCPKG_TRIPLET x64-mingw-static) +set(VCPKG_TARGET_TRIPLET x64-mingw-static) +endif() + +vcpkg_bootstrap() +vcpkg_install_packages(fontconfig sdl2 zlib bzip2 libzip libpng getopt dirent libusb pthread glew glfw3) +endif() + +if (MSVC) +set(CPP "${CMAKE_C_COMPILER}" "/EP") +else() +set(CPP "${CMAKE_C_COMPILER}" "-E" "-P" "-Wno-trigraphs" "-x" "c") +endif() + +if(IOS) +set(PLATFORM "OS64") +include(cmake/ios.toolchain.cmake) +add_compile_definitions( + PLATFORM_IOS=1 +) +set(CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "YOUR_TEAM_ID") +set(PROJECT_ID "dev.net64.game") +endif() + +# Set game compilation version +set(VERSION us) +set(USE_NETWORKING OFF) +set(SKIP_XCODE_VERSION_CHECK ON) + +# Add compile definitions for the target +add_compile_definitions( + VERSION_US=1 + ENABLE_RUMBLE=1 + F3DEX_GBI=1 + _LANGUAGE_C + _USE_MATH_DEFINES + CIMGUI_DEFINE_ENUMS_AND_STRUCTS + NON_MATCHING=1 + NON_EQUIVALENT=1 + AVOID_UB=1 +) + +# Find necessary libraries +if (UNIX AND NOT APPLE) +find_package(OpenGL REQUIRED) +endif() + +# Include directories +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${CMAKE_CURRENT_SOURCE_DIR}/include/assets + ${CMAKE_CURRENT_SOURCE_DIR}/src + ${CMAKE_CURRENT_SOURCE_DIR}/src/racing + ${CMAKE_CURRENT_SOURCE_DIR}/src/ending +) + +# Collect source files to build the executable +file(GLOB ALL_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + "src/*.c" + "src/*.h" +) + +file(GLOB_RECURSE ALL_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + "src/actors/*.c" + "src/actors/*.h" + "src/buffers/*.c" + "src/buffers/*.h" + "src/data/*.c" + "src/data/*.h" + "src/debug/*.c" + "src/debug/*.h" + "src/ending/*.c" + "src/ending/*.h" + "src/racing/*.c" + "src/racing/*.h" + "src/audio/*.c" + "src/audio/*.h" + "src/port/*.h" + "src/port/*.c" + "src/port/*.cpp" + "assets/code" +) + +# Exclude specific files from the ALL_FILES list +list(FILTER ALL_FILES EXCLUDE REGEX ".*.inc.c") +list(FILTER ALL_FILES EXCLUDE REGEX "./src/debug/crash_screen_enhancement.c") + +if (CMAKE_SYSTEM_NAME STREQUAL "iOS") + set(IOS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/ios) + + set(STORYBOARD_FILE ${IOS_DIR}/Launch.storyboard) + set(IMAGE_FILES ${IOS_DIR}/PoweredBy.png) + set(ICON_FILES ${IOS_DIR}/Icon.png) + + list(APPEND ALL_FILES ${STORYBOARD_FILE} ${IMAGE_FILES} ${ICON_FILES}) + + add_executable(${PROJECT_NAME} ${ALL_FILES}) + set_xcode_property(${PROJECT_NAME} PRODUCT_BUNDLE_IDENTIFIER ${PROJECT_ID} All) + set_target_properties( + ${PROJECT_NAME} + PROPERTIES + MACOSX_BUNDLE TRUE + MACOSX_BUNDLE_INFO_PLIST ${IOS_DIR}/plist.in + RESOURCE "${IMAGE_FILES};${STORYBOARD_FILE};${ICON_FILES}" + ) +else() + add_executable(${PROJECT_NAME} ${ALL_FILES}) +endif() + +################################################################################ +# MSVC runtime library +################################################################################ +if (MSVC) + if (CMAKE_SYSTEM_NAME STREQUAL "Windows") + get_property(MSVC_RUNTIME_LIBRARY_DEFAULT TARGET ${PROJECT_NAME} PROPERTY MSVC_RUNTIME_LIBRARY) + if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64") + string(CONCAT "MSVC_RUNTIME_LIBRARY_STR" + $<$: + MultiThreadedDebug + > + $<$: + MultiThreaded + > + $<$,$>>:${MSVC_RUNTIME_LIBRARY_DEFAULT}> + ) + elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32") + string(CONCAT "MSVC_RUNTIME_LIBRARY_STR" + $<$: + MultiThreadedDebug + > + $<$: + MultiThreaded + > + $<$,$>>:${MSVC_RUNTIME_LIBRARY_DEFAULT}> + ) + endif() + set_target_properties(${PROJECT_NAME} PROPERTIES MSVC_RUNTIME_LIBRARY ${MSVC_RUNTIME_LIBRARY_STR}) + endif() +endif() + +#==============================================================================# +# Libultraship Integration # +#==============================================================================# + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/src + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/include + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/include/libultraship + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/log + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/debug + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/menu + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/utils + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/utils/binarytools + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/config + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/resource + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/resource/type + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/resource/factory + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/audio + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/window + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/window/gui + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/config + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/public + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/public/libultra + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/public/bridge + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/extern + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/extern/tinyxml2 + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/libultraship/Lib/ + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/libultraship/Lib/libjpeg/include/ + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/libultraship/Lib/spdlog/include/ + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/graphic/Fast3D/U64/PR + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/graphic + ${SDL2_INCLUDE_DIRS} + ${GLEW_INCLUDE_DIRS} +) + +if (CMAKE_SYSTEM_NAME STREQUAL "Windows") + if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64") + target_compile_definitions(${PROJECT_NAME} PRIVATE + "$<$:" + "_DEBUG;" + "_CRT_SECURE_NO_WARNINGS;" + "ENABLE_DX11;" + ">" + "$<$:" + "NDEBUG" + ">" + "INCLUDE_GAME_PRINTF;" + "UNICODE;" + "_UNICODE" + STORMLIB_NO_AUTO_LINK + "_CRT_SECURE_NO_WARNINGS;" + "_SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS;" + ) + elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32") + target_compile_definitions(${PROJECT_NAME} PRIVATE + "$<$:" + "NOINCLUDE_GAME_PRINTF;" + "_DEBUG;" + "_CRT_SECURE_NO_WARNINGS;" + "ENABLE_OPENGL" + ">" + "$<$:" + "NDEBUG;" + ">" + "INCLUDE_GAME_PRINTF;" + "WIN32;" + "UNICODE;" + "_UNICODE" + STORMLIB_NO_AUTO_LINK + "_SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS;" + ) + endif() +elseif (CMAKE_SYSTEM_NAME STREQUAL "CafeOS") + target_compile_definitions(${PROJECT_NAME} PRIVATE + "$<$:" + "_DEBUG" + ">" + "$<$:" + "NDEBUG" + ">" + "SPDLOG_ACTIVE_LEVEL=3;" + "SPDLOG_NO_THREAD_ID;" + "SPDLOG_NO_TLS;" + "STBI_NO_THREAD_LOCALS;" + ) +elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang|AppleClang") + target_compile_definitions(${PROJECT_NAME} PRIVATE + "$<$:" + "_DEBUG" + ">" + "$<$:" + "NDEBUG" + ">" + "$<$:ENABLE_CROWD_CONTROL>" + "SPDLOG_ACTIVE_LEVEL=0;" + "_CONSOLE;" + "_CRT_SECURE_NO_WARNINGS;" + "UNICODE;" + "_UNICODE" + ) +endif() + +add_subdirectory(libultraship ${CMAKE_CURRENT_SOURCE_DIR}/libultraship) + +add_dependencies(${PROJECT_NAME} libultraship) +target_link_libraries(${PROJECT_NAME} PRIVATE libultraship) +if (CMAKE_SYSTEM_NAME STREQUAL "Windows") + set(ADDITIONAL_LIBRARY_DEPENDENCIES + "$<$:SDL2_net::SDL2_net-static>" + ) +elseif(CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch") + set(ADDITIONAL_LIBRARY_DEPENDENCIES + -lglad + ) +elseif(CMAKE_SYSTEM_NAME STREQUAL "CafeOS") + set(ADDITIONAL_LIBRARY_DEPENDENCIES + "$<$:-Wl,--wrap=abort>" + ) + target_include_directories(${PROJECT_NAME} PRIVATE + ${DEVKITPRO}/portlibs/wiiu/include/ + ) +else() + set(ADDITIONAL_LIBRARY_DEPENDENCIES + "$<$:SDL2_net::SDL2_net>" + ) +endif() + +if(USE_NETWORKING) + if(MSVC) + vcpkg_install_packages(sdl2-net) + endif() + find_package(SDL2_net REQUIRED) + include_directories(${SDL2_NET_INCLUDE_DIRS}) + target_link_libraries(${PROJECT_NAME} PRIVATE SDL2_net::SDL2_net) + target_compile_definitions(${PROJECT_NAME} PRIVATE USE_NETWORKING) +endif() + +target_link_libraries(${PROJECT_NAME} PRIVATE "${ADDITIONAL_LIBRARY_DEPENDENCIES}") + +if(CMAKE_SYSTEM_NAME MATCHES "NintendoSwitch") + +nx_generate_nacp(Lylat.nacp + NAME "${PROJECT_NAME}" + AUTHOR "${PROJECT_TEAM}" + VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}" +) + +nx_create_nro(${PROJECT_NAME} + NACP Lylat.nacp +) + +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.nro DESTINATION . COMPONENT ${PROJECT_NAME}) +endif() + +################################################################################ +# Compile and link options +################################################################################ +if(MSVC) + if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64") + target_compile_options(${PROJECT_NAME} PRIVATE + $<$: + /w; + /Od; + /MTd + > + $<$: + /Oi; + /Gy; + /W3; + /MT + > + /permissive-; + /MP; + ${DEFAULT_CXX_DEBUG_INFORMATION_FORMAT}; + ${DEFAULT_CXX_EXCEPTION_HANDLING} + ) + target_compile_options(${PROJECT_NAME} PRIVATE $<$:/ZI;>) + elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32") + target_compile_options(${PROJECT_NAME} PRIVATE + $<$: + /MTd + > + $<$: + /O2; + /Oi; + /Gy; + /MT + > + /permissive-; + /MP; + /w; + ${DEFAULT_CXX_DEBUG_INFORMATION_FORMAT}; + ${DEFAULT_CXX_EXCEPTION_HANDLING} + ) + endif() + if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64") + target_link_options(${PROJECT_NAME} PRIVATE + $<$: + /INCREMENTAL + > + $<$: + /OPT:REF; + /OPT:ICF; + /INCREMENTAL:NO; + /FORCE:MULTIPLE + > + /MANIFEST:NO; + /DEBUG; + /SUBSYSTEM:WINDOWS + ) + elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32") + target_link_options(${PROJECT_NAME} PRIVATE + $<$: + /STACK:8777216 + > + $<$: + /OPT:REF; + /OPT:ICF; + /INCREMENTAL:NO; + /FORCE:MULTIPLE + > + /MANIFEST:NO; + /DEBUG; + /SUBSYSTEM:WINDOWS + ) + endif() + + # Remove /RTC from msvc flags + foreach (fentry + CMAKE_C_FLAGS + CMAKE_CXX_FLAGS + ) + string (REGEX REPLACE "/RTC(su|[1su])" "" ${fentry} "${${fentry}}") + endforeach(fentry) +endif() + +if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang") + if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR CMAKE_SYSTEM_NAME STREQUAL "iOS") + target_compile_options(${PROJECT_NAME} PRIVATE + -Wall -Wextra -Wno-error + -Wno-return-type + -Wno-unused-parameter + -Wno-unused-function + -Wno-unused-variable + -Wno-missing-field-initializers + -Wno-parentheses + -Wno-narrowing + -Wno-missing-braces + -Wno-int-conversion + $<$: + -Werror-implicit-function-declaration + -Wno-incompatible-pointer-types + -fpermissive + > + $<$:-fpermissive> + $<$: + -Wno-c++11-narrowing + -Wno-deprecated-enum-enum-conversion + > + -pthread + ) + + target_link_options(${PROJECT_NAME} PRIVATE + -pthread + ) + elseif (CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch") + target_compile_options(${PROJECT_NAME} PRIVATE + -Wall -Wextra -Wno-error + -Wno-return-type + -Wno-unused-parameter + -Wno-unused-function + -Wno-unused-variable + -Wno-missing-field-initializers + -Wno-parentheses + -Wno-narrowing + -Wno-missing-braces + -Wno-int-conversion + $<$: + -Werror-implicit-function-declaration + -Wno-incompatible-pointer-types + -fpermissive + > + $<$:-fpermissive> + $<$: + -Wno-c++11-narrowing + -Wno-deprecated-enum-enum-conversion + > + -pthread + ) + + target_link_options(${PROJECT_NAME} PRIVATE + -pthread + ) + elseif (CMAKE_SYSTEM_NAME STREQUAL "CafeOS") + target_compile_options(${PROJECT_NAME} PRIVATE + -O2 + + # disable some warnings to not clutter output + -Wno-multichar + -Wno-return-type + -Wno-narrowing + -Wno-switch-outside-range + $<$: + -Werror-implicit-function-declaration + -Wno-incompatible-pointer-types + -Wno-discarded-array-qualifiers + -Wno-discarded-qualifiers + -Wno-int-conversion + -Wno-builtin-declaration-mismatch + -Wno-switch-unreachable + -Wno-stringop-overflow + > + ) + else() + if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") + set(CPU_OPTION -msse2 -mfpmath=sse) + endif() + + target_compile_options(${PROJECT_NAME} PRIVATE + -Wall -Wextra -Wno-error + -Wno-unused-parameter + -Wno-unused-function + -Wno-unused-variable + -Wno-missing-field-initializers + -Wno-parentheses + -Wno-narrowing + -Wno-missing-braces + -Wno-int-conversion + $<$: + -Werror-implicit-function-declaration + -Wno-incompatible-pointer-types + -fpermissive + > + $<$:-fpermissive> + $<$:-Wno-deprecated-enum-enum-conversion> + -pthread + ${CPU_OPTION} + ) + + target_link_options(${PROJECT_NAME} PRIVATE + -pthread + -Wl,-export-dynamic + ) + endif() +endif() diff --git a/courses/all_course_data.h b/courses/all_course_data.h index bde518b5a..a3123a9a2 100644 --- a/courses/all_course_data.h +++ b/courses/all_course_data.h @@ -21,5 +21,6 @@ #include "courses/royal_raceway/course_data.h" #include "courses/sherbet_land/course_data.h" #include "courses/wario_stadium/course_data.h" +void gSPDisplayList(Gfx* pkt, Gfx* dl); #endif // ALL_COURSE_DATA_H diff --git a/courses/banshee_boardwalk/course_data.c b/courses/banshee_boardwalk/course_data.c index 69de3a934..642e905fd 100644 --- a/courses/banshee_boardwalk/course_data.c +++ b/courses/banshee_boardwalk/course_data.c @@ -1,7 +1,7 @@ //! @todo Replace addresses with variables -#include +#include #include -#include +#include #include #include #include diff --git a/courses/banshee_boardwalk/course_data.h b/courses/banshee_boardwalk/course_data.h index 40b4c42c6..a1f2e81fc 100644 --- a/courses/banshee_boardwalk/course_data.h +++ b/courses/banshee_boardwalk/course_data.h @@ -1,8 +1,8 @@ #ifndef BANSHEE_BOARDWALK_COURSE_DATA_H #define BANSHEE_BOARDWALK_COURSE_DATA_H -#include -#include +#include +#include #include #include #include diff --git a/courses/banshee_boardwalk/course_displaylists.inc.c b/courses/banshee_boardwalk/course_displaylists.inc.c index 381f746f0..f7a5e9e54 100644 --- a/courses/banshee_boardwalk/course_displaylists.inc.c +++ b/courses/banshee_boardwalk/course_displaylists.inc.c @@ -1,6 +1,6 @@ -#include +#include #include -#include +#include #include #include diff --git a/courses/banshee_boardwalk/course_displaylists.inc.h b/courses/banshee_boardwalk/course_displaylists.inc.h index cd3ee45bc..5e9788400 100644 --- a/courses/banshee_boardwalk/course_displaylists.inc.h +++ b/courses/banshee_boardwalk/course_displaylists.inc.h @@ -1,4 +1,4 @@ -#include +#include #include "macros.h" extern Gfx d_course_banshee_boardwalk_packed_dl_0[]; diff --git a/courses/banshee_boardwalk/course_offsets.c b/courses/banshee_boardwalk/course_offsets.c index 379e3f5fd..b8bde6aac 100644 --- a/courses/banshee_boardwalk/course_offsets.c +++ b/courses/banshee_boardwalk/course_offsets.c @@ -1,8 +1,8 @@ -#include -#include "PR/gbi.h" +#include +#include #include "course_offsets.h" #include "courses/banshee_boardwalk/course_data.h" -#include +#include extern u8 gTexture6447C4[]; extern u8 gTexture676FB0[]; diff --git a/courses/big_donut/course_data.c b/courses/big_donut/course_data.c index 4909ad5b8..1cdc9efd6 100644 --- a/courses/big_donut/course_data.c +++ b/courses/big_donut/course_data.c @@ -1,7 +1,7 @@ //! @todo Replace addresses with variables -#include +#include #include -#include +#include #include #include "course_displaylists.inc.h" diff --git a/courses/big_donut/course_data.h b/courses/big_donut/course_data.h index bb4cf7d1f..8d1d72fa0 100644 --- a/courses/big_donut/course_data.h +++ b/courses/big_donut/course_data.h @@ -1,8 +1,8 @@ #ifndef BIG_DONUT_COURSE_DATA_H #define BIG_DONUT_COURSE_DATA_H -#include -#include +#include +#include #include extern Gfx d_course_big_donut_dl[]; diff --git a/courses/big_donut/course_displaylists.inc.c b/courses/big_donut/course_displaylists.inc.c index e181fa080..83d4238ac 100644 --- a/courses/big_donut/course_displaylists.inc.c +++ b/courses/big_donut/course_displaylists.inc.c @@ -1,6 +1,6 @@ -#include +#include #include -#include +#include #include #include diff --git a/courses/big_donut/course_displaylists.inc.h b/courses/big_donut/course_displaylists.inc.h index 4f60fae50..8fad99ddc 100644 --- a/courses/big_donut/course_displaylists.inc.h +++ b/courses/big_donut/course_displaylists.inc.h @@ -1,4 +1,4 @@ -#include +#include #include "macros.h" extern Gfx d_course_big_donut_packed_dl_0[]; diff --git a/courses/big_donut/course_offsets.c b/courses/big_donut/course_offsets.c index af03e98cf..a432a1135 100644 --- a/courses/big_donut/course_offsets.c +++ b/courses/big_donut/course_offsets.c @@ -1,4 +1,4 @@ -#include +#include #include "course_offsets.h" extern u8 gTexture66ABA4[]; diff --git a/courses/block_fort/course_data.c b/courses/block_fort/course_data.c index de1cda9bd..2719de11f 100644 --- a/courses/block_fort/course_data.c +++ b/courses/block_fort/course_data.c @@ -1,6 +1,6 @@ -#include +#include #include -#include +#include #include #include "course_displaylists.inc.h" diff --git a/courses/block_fort/course_data.h b/courses/block_fort/course_data.h index 1cffbbdb8..aca2904f2 100644 --- a/courses/block_fort/course_data.h +++ b/courses/block_fort/course_data.h @@ -1,8 +1,8 @@ #ifndef BLOCK_FORT_COURSE_DATA_H #define BLOCK_FORT_COURSE_DATA_H -#include -#include +#include +#include #include extern Gfx d_course_block_fort_dl[]; diff --git a/courses/block_fort/course_displaylists.inc.c b/courses/block_fort/course_displaylists.inc.c index 762604b3d..943cc7682 100644 --- a/courses/block_fort/course_displaylists.inc.c +++ b/courses/block_fort/course_displaylists.inc.c @@ -1,6 +1,6 @@ -#include +#include #include -#include +#include #include #include diff --git a/courses/block_fort/course_displaylists.inc.h b/courses/block_fort/course_displaylists.inc.h index 9545e5444..299dfd774 100644 --- a/courses/block_fort/course_displaylists.inc.h +++ b/courses/block_fort/course_displaylists.inc.h @@ -1,4 +1,4 @@ -#include +#include #include "macros.h" extern Gfx d_course_block_fort_packed_dl_0[]; diff --git a/courses/block_fort/course_offsets.c b/courses/block_fort/course_offsets.c index 0e03e0bf6..7bf6ed3fb 100644 --- a/courses/block_fort/course_offsets.c +++ b/courses/block_fort/course_offsets.c @@ -1,4 +1,4 @@ -#include +#include #include "course_offsets.h" extern u8 gTexture64286C[]; diff --git a/courses/bowsers_castle/course_data.c b/courses/bowsers_castle/course_data.c index 55360bb7f..54a32f6c0 100644 --- a/courses/bowsers_castle/course_data.c +++ b/courses/bowsers_castle/course_data.c @@ -1,7 +1,7 @@ //! @todo Replace addresses with variables -#include +#include #include -#include +#include #include #include #include diff --git a/courses/bowsers_castle/course_data.h b/courses/bowsers_castle/course_data.h index aadfe865f..a505ffe57 100644 --- a/courses/bowsers_castle/course_data.h +++ b/courses/bowsers_castle/course_data.h @@ -1,8 +1,8 @@ #ifndef BOWSERS_CASTLE_COURSE_DATA_H #define BOWSERS_CASTLE_COURSE_DATA_H -#include -#include +#include +#include #include #include #include diff --git a/courses/bowsers_castle/course_displaylists.inc.c b/courses/bowsers_castle/course_displaylists.inc.c index 7162aedff..fd11e5991 100644 --- a/courses/bowsers_castle/course_displaylists.inc.c +++ b/courses/bowsers_castle/course_displaylists.inc.c @@ -1,6 +1,6 @@ -#include +#include #include -#include +#include #include #include "course_displaylists.inc.h" diff --git a/courses/bowsers_castle/course_displaylists.inc.h b/courses/bowsers_castle/course_displaylists.inc.h index ca15d5f90..2531513f0 100644 --- a/courses/bowsers_castle/course_displaylists.inc.h +++ b/courses/bowsers_castle/course_displaylists.inc.h @@ -1,4 +1,4 @@ -#include +#include #include "macros.h" extern Gfx d_course_bowsers_castle_packed_dl_0[]; diff --git a/courses/bowsers_castle/course_offsets.c b/courses/bowsers_castle/course_offsets.c index 976b884fb..4cf5d1f5a 100644 --- a/courses/bowsers_castle/course_offsets.c +++ b/courses/bowsers_castle/course_offsets.c @@ -1,4 +1,4 @@ -#include +#include #include "course_offsets.h" #include "course_data.h" diff --git a/courses/choco_mountain/course_data.c b/courses/choco_mountain/course_data.c index 72e927c6e..938240c3d 100644 --- a/courses/choco_mountain/course_data.c +++ b/courses/choco_mountain/course_data.c @@ -1,6 +1,6 @@ -#include +#include #include -#include +#include #include #include #include diff --git a/courses/choco_mountain/course_data.h b/courses/choco_mountain/course_data.h index 7584ada96..38d356707 100644 --- a/courses/choco_mountain/course_data.h +++ b/courses/choco_mountain/course_data.h @@ -1,8 +1,8 @@ #ifndef CHOCO_MOUNTAIN_COURSE_DATA_H #define CHOCO_MOUNTAIN_COURSE_DATA_H -#include -#include +#include +#include #include #include #include diff --git a/courses/choco_mountain/course_displaylists.inc.c b/courses/choco_mountain/course_displaylists.inc.c index acf65bcdb..7e5f18dc7 100644 --- a/courses/choco_mountain/course_displaylists.inc.c +++ b/courses/choco_mountain/course_displaylists.inc.c @@ -1,6 +1,6 @@ -#include +#include #include -#include +#include #include #include "course_displaylists.inc.h" diff --git a/courses/choco_mountain/course_displaylists.inc.h b/courses/choco_mountain/course_displaylists.inc.h index b68ce15a8..06f0ab4c9 100644 --- a/courses/choco_mountain/course_displaylists.inc.h +++ b/courses/choco_mountain/course_displaylists.inc.h @@ -1,4 +1,4 @@ -#include +#include #include "macros.h" extern Gfx d_course_choco_mountain_packed_dl_0[]; diff --git a/courses/choco_mountain/course_offsets.c b/courses/choco_mountain/course_offsets.c index 6ccb45107..1d7739989 100644 --- a/courses/choco_mountain/course_offsets.c +++ b/courses/choco_mountain/course_offsets.c @@ -1,4 +1,4 @@ -#include +#include #include "course_offsets.h" #include "course_data.h" diff --git a/courses/courseTable.c b/courses/courseTable.c index 00ee6ff72..750d18b7f 100644 --- a/courses/courseTable.c +++ b/courses/courseTable.c @@ -1,4 +1,4 @@ -#include +#include #include #include "courseTable.h" #include "all_course_model.h" @@ -145,4 +145,3 @@ struct CourseTable gCourseTable[] = {{ d_course_big_donut_packed, d_course_big_donut_packed_end, big_donut_textures, 0, 0x0000, }}; - diff --git a/courses/courseTable.h b/courses/courseTable.h index 2ab5f3ae1..9374f99f7 100644 --- a/courses/courseTable.h +++ b/courses/courseTable.h @@ -1,7 +1,7 @@ #ifndef COURSE_TABLE_H #define COURSE_TABLE_H -#include +#include #include // dlRomStart, vertexRomStart, & vertexStart, are u8* because mio0 compressed. diff --git a/courses/dks_jungle_parkway/course_data.c b/courses/dks_jungle_parkway/course_data.c index c1398f59e..a46d0d007 100644 --- a/courses/dks_jungle_parkway/course_data.c +++ b/courses/dks_jungle_parkway/course_data.c @@ -1,7 +1,7 @@ //! @todo Replace addresses with variables -#include +#include #include -#include +#include #include #include #include diff --git a/courses/dks_jungle_parkway/course_data.h b/courses/dks_jungle_parkway/course_data.h index 4513fcfb2..227cdbc3b 100644 --- a/courses/dks_jungle_parkway/course_data.h +++ b/courses/dks_jungle_parkway/course_data.h @@ -1,8 +1,8 @@ #ifndef DKS_JUNGLE_PARKWAY_COURSE_DATA_H #define DKS_JUNGLE_PARKWAY_COURSE_DATA_H -#include -#include +#include +#include #include #include #include diff --git a/courses/dks_jungle_parkway/course_displaylists.inc.c b/courses/dks_jungle_parkway/course_displaylists.inc.c index 2b789d787..c9f1454a4 100644 --- a/courses/dks_jungle_parkway/course_displaylists.inc.c +++ b/courses/dks_jungle_parkway/course_displaylists.inc.c @@ -1,6 +1,6 @@ -#include +#include #include -#include +#include #include #include diff --git a/courses/dks_jungle_parkway/course_displaylists.inc.h b/courses/dks_jungle_parkway/course_displaylists.inc.h index 4b71d0414..3c950e422 100644 --- a/courses/dks_jungle_parkway/course_displaylists.inc.h +++ b/courses/dks_jungle_parkway/course_displaylists.inc.h @@ -1,4 +1,4 @@ -#include +#include #include "macros.h" extern Gfx d_course_dks_jungle_parkway_packed_dl_0[]; diff --git a/courses/dks_jungle_parkway/course_offsets.c b/courses/dks_jungle_parkway/course_offsets.c index 3a87a03ff..8ef67c2b2 100644 --- a/courses/dks_jungle_parkway/course_offsets.c +++ b/courses/dks_jungle_parkway/course_offsets.c @@ -1,4 +1,4 @@ -#include +#include #include "course_offsets.h" extern u8 gTexture648508[]; diff --git a/courses/double_deck/course_data.c b/courses/double_deck/course_data.c index 6a3b3294a..305d8ed2f 100644 --- a/courses/double_deck/course_data.c +++ b/courses/double_deck/course_data.c @@ -1,6 +1,6 @@ -#include +#include #include -#include +#include #include #include "course_displaylists.inc.h" diff --git a/courses/double_deck/course_data.h b/courses/double_deck/course_data.h index 1c3367af9..2ab381275 100644 --- a/courses/double_deck/course_data.h +++ b/courses/double_deck/course_data.h @@ -1,8 +1,8 @@ #ifndef DOUBLE_DECK_COURSE_DATA_H #define DOUBLE_DECK_COURSE_DATA_H -#include -#include +#include +#include #include extern Gfx d_course_double_deck_dl[]; diff --git a/courses/double_deck/course_displaylists.inc.c b/courses/double_deck/course_displaylists.inc.c index a82236ba8..5a2d537e7 100644 --- a/courses/double_deck/course_displaylists.inc.c +++ b/courses/double_deck/course_displaylists.inc.c @@ -1,6 +1,6 @@ -#include +#include #include -#include +#include #include #include diff --git a/courses/double_deck/course_displaylists.inc.h b/courses/double_deck/course_displaylists.inc.h index 1e1ef481e..d6e7b6a68 100644 --- a/courses/double_deck/course_displaylists.inc.h +++ b/courses/double_deck/course_displaylists.inc.h @@ -1,4 +1,4 @@ -#include +#include #include "macros.h" extern Gfx d_course_double_deck_packed_dl_0[]; diff --git a/courses/double_deck/course_offsets.c b/courses/double_deck/course_offsets.c index b2b826802..a6c4c5cbd 100644 --- a/courses/double_deck/course_offsets.c +++ b/courses/double_deck/course_offsets.c @@ -1,4 +1,4 @@ -#include +#include #include "course_offsets.h" extern u8 gTextureGrayCobblestone[]; diff --git a/courses/frappe_snowland/course_data.c b/courses/frappe_snowland/course_data.c index 6e976ea92..b0a3a3a1d 100644 --- a/courses/frappe_snowland/course_data.c +++ b/courses/frappe_snowland/course_data.c @@ -1,7 +1,7 @@ //! @todo Replace addresses with variables -#include +#include #include -#include +#include #include #include #include diff --git a/courses/frappe_snowland/course_data.h b/courses/frappe_snowland/course_data.h index 0b84bc3a2..2cd4973f6 100644 --- a/courses/frappe_snowland/course_data.h +++ b/courses/frappe_snowland/course_data.h @@ -1,8 +1,8 @@ #ifndef FRAPPE_SNOWLAND_COURSE_DATA_H #define FRAPPE_SNOWLAND_COURSE_DATA_H -#include -#include +#include +#include #include #include #include diff --git a/courses/frappe_snowland/course_displaylists.inc.c b/courses/frappe_snowland/course_displaylists.inc.c index 2f8c18f2e..db2643905 100644 --- a/courses/frappe_snowland/course_displaylists.inc.c +++ b/courses/frappe_snowland/course_displaylists.inc.c @@ -1,6 +1,6 @@ -#include +#include #include -#include +#include #include #include "course_displaylists.inc.h" diff --git a/courses/frappe_snowland/course_displaylists.inc.h b/courses/frappe_snowland/course_displaylists.inc.h index 48869a152..1e43de783 100644 --- a/courses/frappe_snowland/course_displaylists.inc.h +++ b/courses/frappe_snowland/course_displaylists.inc.h @@ -1,4 +1,4 @@ -#include +#include #include "macros.h" extern Gfx d_course_frappe_snowland_packed_dl_0[]; diff --git a/courses/frappe_snowland/course_offsets.c b/courses/frappe_snowland/course_offsets.c index d95faed23..354a26698 100644 --- a/courses/frappe_snowland/course_offsets.c +++ b/courses/frappe_snowland/course_offsets.c @@ -1,4 +1,4 @@ -#include +#include #include "course_offsets.h" extern u8 gTexture6684F8[]; diff --git a/courses/kalimari_desert/course_data.c b/courses/kalimari_desert/course_data.c index ed591a654..d1612f608 100644 --- a/courses/kalimari_desert/course_data.c +++ b/courses/kalimari_desert/course_data.c @@ -1,7 +1,7 @@ //! @todo Replace addresses with variables -#include +#include #include -#include +#include #include #include #include diff --git a/courses/kalimari_desert/course_data.h b/courses/kalimari_desert/course_data.h index adf7e6936..6203fc4c6 100644 --- a/courses/kalimari_desert/course_data.h +++ b/courses/kalimari_desert/course_data.h @@ -1,8 +1,8 @@ #ifndef KALIMARI_DESERT_COURSE_DATA_H #define KALIMARI_DESERT_COURSE_DATA_H -#include -#include +#include +#include #include #include #include diff --git a/courses/kalimari_desert/course_displaylists.inc.c b/courses/kalimari_desert/course_displaylists.inc.c index c7d76edc4..0fb406d5a 100644 --- a/courses/kalimari_desert/course_displaylists.inc.c +++ b/courses/kalimari_desert/course_displaylists.inc.c @@ -1,6 +1,6 @@ -#include +#include #include -#include +#include #include #include "course_displaylists.inc.h" diff --git a/courses/kalimari_desert/course_displaylists.inc.h b/courses/kalimari_desert/course_displaylists.inc.h index 38f838f82..13980e073 100644 --- a/courses/kalimari_desert/course_displaylists.inc.h +++ b/courses/kalimari_desert/course_displaylists.inc.h @@ -1,4 +1,4 @@ -#include +#include #include "macros.h" extern Gfx d_course_kalimari_desert_packed_dl_0[]; diff --git a/courses/kalimari_desert/course_offsets.c b/courses/kalimari_desert/course_offsets.c index feff3a8a0..c3394003f 100644 --- a/courses/kalimari_desert/course_offsets.c +++ b/courses/kalimari_desert/course_offsets.c @@ -1,4 +1,4 @@ -#include +#include #include "course_offsets.h" #include "course_data.h" diff --git a/courses/koopa_troopa_beach/course_data.c b/courses/koopa_troopa_beach/course_data.c index 880364eef..34b98dc57 100644 --- a/courses/koopa_troopa_beach/course_data.c +++ b/courses/koopa_troopa_beach/course_data.c @@ -1,7 +1,7 @@ //! @todo Replace addresses with variables -#include +#include #include -#include +#include #include #include #include diff --git a/courses/koopa_troopa_beach/course_data.h b/courses/koopa_troopa_beach/course_data.h index 0ba1be885..e6e41c3e6 100644 --- a/courses/koopa_troopa_beach/course_data.h +++ b/courses/koopa_troopa_beach/course_data.h @@ -1,8 +1,8 @@ #ifndef KOOPA_TROOPA_BEACH_COURSE_DATA_H #define KOOPA_TROOPA_BEACH_COURSE_DATA_H -#include -#include +#include +#include #include #include #include diff --git a/courses/koopa_troopa_beach/course_displaylists.inc.c b/courses/koopa_troopa_beach/course_displaylists.inc.c index 27ad79b3f..498dfd2cc 100644 --- a/courses/koopa_troopa_beach/course_displaylists.inc.c +++ b/courses/koopa_troopa_beach/course_displaylists.inc.c @@ -1,6 +1,6 @@ -#include +#include #include -#include +#include #include #include "course_displaylists.inc.h" diff --git a/courses/koopa_troopa_beach/course_displaylists.inc.h b/courses/koopa_troopa_beach/course_displaylists.inc.h index 76370a713..ba9fc9d2e 100644 --- a/courses/koopa_troopa_beach/course_displaylists.inc.h +++ b/courses/koopa_troopa_beach/course_displaylists.inc.h @@ -1,4 +1,4 @@ -#include +#include #include "macros.h" extern Gfx d_course_koopa_troopa_beach_packed_dl_0[]; diff --git a/courses/koopa_troopa_beach/course_offsets.c b/courses/koopa_troopa_beach/course_offsets.c index 8d050bf13..a3dcd5089 100644 --- a/courses/koopa_troopa_beach/course_offsets.c +++ b/courses/koopa_troopa_beach/course_offsets.c @@ -1,4 +1,4 @@ -#include +#include #include "course_offsets.h" extern u8 gTexture643B3C[]; diff --git a/courses/luigi_raceway/course_data.c b/courses/luigi_raceway/course_data.c index a496c7848..55e9c7b0f 100644 --- a/courses/luigi_raceway/course_data.c +++ b/courses/luigi_raceway/course_data.c @@ -1,7 +1,7 @@ //! @todo Replace addresses with variables -#include +#include #include -#include +#include #include #include #include diff --git a/courses/luigi_raceway/course_data.h b/courses/luigi_raceway/course_data.h index 1b0694238..509783277 100644 --- a/courses/luigi_raceway/course_data.h +++ b/courses/luigi_raceway/course_data.h @@ -1,8 +1,8 @@ #ifndef LUIGI_RACEWAY_COURSE_DATA_H #define LUIGI_RACEWAY_COURSE_DATA_H -#include -#include +#include +#include #include #include #include diff --git a/courses/luigi_raceway/course_displaylists.inc.c b/courses/luigi_raceway/course_displaylists.inc.c index e61eae27f..ff9c78fc4 100644 --- a/courses/luigi_raceway/course_displaylists.inc.c +++ b/courses/luigi_raceway/course_displaylists.inc.c @@ -1,6 +1,6 @@ -#include +#include #include -#include +#include #include #include "course_displaylists.inc.h" diff --git a/courses/luigi_raceway/course_displaylists.inc.h b/courses/luigi_raceway/course_displaylists.inc.h index 1ce19662d..1c92f63bc 100644 --- a/courses/luigi_raceway/course_displaylists.inc.h +++ b/courses/luigi_raceway/course_displaylists.inc.h @@ -1,4 +1,4 @@ -#include +#include #include "macros.h" extern Gfx d_course_luigi_raceway_packed_dl_0[]; diff --git a/courses/luigi_raceway/course_offsets.c b/courses/luigi_raceway/course_offsets.c index 1cd496738..4bce40a2f 100644 --- a/courses/luigi_raceway/course_offsets.c +++ b/courses/luigi_raceway/course_offsets.c @@ -1,4 +1,4 @@ -#include +#include #include "course_offsets.h" #include "course_data.h" diff --git a/courses/mario_raceway/course_data.c b/courses/mario_raceway/course_data.c index 1e4901a6e..20de40b05 100644 --- a/courses/mario_raceway/course_data.c +++ b/courses/mario_raceway/course_data.c @@ -1,7 +1,7 @@ //! @todo Replace addresses with variables -#include +#include #include -#include +#include #include #include #include diff --git a/courses/mario_raceway/course_data.h b/courses/mario_raceway/course_data.h index bdc5a137d..d3a42aaa3 100644 --- a/courses/mario_raceway/course_data.h +++ b/courses/mario_raceway/course_data.h @@ -1,8 +1,8 @@ #ifndef MARIO_RACEWAY_COURSE_DATA_H #define MARIO_RACEWAY_COURSE_DATA_H -#include -#include +#include +#include #include #include #include diff --git a/courses/mario_raceway/course_displaylists.inc.c b/courses/mario_raceway/course_displaylists.inc.c index 750285deb..047e35f60 100644 --- a/courses/mario_raceway/course_displaylists.inc.c +++ b/courses/mario_raceway/course_displaylists.inc.c @@ -1,6 +1,6 @@ -#include +#include #include -#include +#include #include #include "course_displaylists.inc.h" diff --git a/courses/mario_raceway/course_displaylists.inc.h b/courses/mario_raceway/course_displaylists.inc.h index 3fa1b518f..6e06467ac 100644 --- a/courses/mario_raceway/course_displaylists.inc.h +++ b/courses/mario_raceway/course_displaylists.inc.h @@ -1,4 +1,4 @@ -#include +#include #include "macros.h" extern Gfx d_course_mario_raceway_packed_dl_0[]; diff --git a/courses/mario_raceway/course_offsets.c b/courses/mario_raceway/course_offsets.c index 6d299ed32..9f8bc63d4 100644 --- a/courses/mario_raceway/course_offsets.c +++ b/courses/mario_raceway/course_offsets.c @@ -1,4 +1,4 @@ -#include +#include #include "course_offsets.h" #include "course_data.h" diff --git a/courses/moo_moo_farm/course_data.c b/courses/moo_moo_farm/course_data.c index 74936e9c5..1609f819e 100644 --- a/courses/moo_moo_farm/course_data.c +++ b/courses/moo_moo_farm/course_data.c @@ -1,7 +1,7 @@ //! @todo Replace addresses with variables -#include +#include #include -#include +#include #include #include #include diff --git a/courses/moo_moo_farm/course_data.h b/courses/moo_moo_farm/course_data.h index 8ff50ec2d..dfd23d467 100644 --- a/courses/moo_moo_farm/course_data.h +++ b/courses/moo_moo_farm/course_data.h @@ -1,8 +1,8 @@ #ifndef MOO_MOO_FARM_COURSE_DATA_H #define MOO_MOO_FARM_COURSE_DATA_H -#include -#include +#include +#include #include #include #include diff --git a/courses/moo_moo_farm/course_displaylists.inc.c b/courses/moo_moo_farm/course_displaylists.inc.c index c4ae8da5d..039e9d511 100644 --- a/courses/moo_moo_farm/course_displaylists.inc.c +++ b/courses/moo_moo_farm/course_displaylists.inc.c @@ -1,6 +1,6 @@ -#include +#include #include -#include +#include #include #include "course_displaylists.inc.h" diff --git a/courses/moo_moo_farm/course_displaylists.inc.h b/courses/moo_moo_farm/course_displaylists.inc.h index c59836400..6303285a3 100644 --- a/courses/moo_moo_farm/course_displaylists.inc.h +++ b/courses/moo_moo_farm/course_displaylists.inc.h @@ -1,4 +1,4 @@ -#include +#include #include "macros.h" extern Gfx d_course_moo_moo_farm_packed_dl_0[]; diff --git a/courses/moo_moo_farm/course_offsets.c b/courses/moo_moo_farm/course_offsets.c index c3a1f8003..cab43fad2 100644 --- a/courses/moo_moo_farm/course_offsets.c +++ b/courses/moo_moo_farm/course_offsets.c @@ -1,4 +1,4 @@ -#include +#include #include "course_offsets.h" #include "course_data.h" diff --git a/courses/rainbow_road/course_data.c b/courses/rainbow_road/course_data.c index b19967c07..5e9b7c18e 100644 --- a/courses/rainbow_road/course_data.c +++ b/courses/rainbow_road/course_data.c @@ -1,7 +1,7 @@ //! @todo Replace addresses with variables -#include +#include #include -#include +#include #include #include #include diff --git a/courses/rainbow_road/course_data.h b/courses/rainbow_road/course_data.h index 4dc0a8ba5..b85f64948 100644 --- a/courses/rainbow_road/course_data.h +++ b/courses/rainbow_road/course_data.h @@ -1,8 +1,8 @@ #ifndef RAINBOW_ROAD_COURSE_DATA_H #define RAINBOW_ROAD_COURSE_DATA_H -#include -#include +#include +#include #include #include #include diff --git a/courses/rainbow_road/course_displaylists.inc.c b/courses/rainbow_road/course_displaylists.inc.c index 4ffe95176..c211825c8 100644 --- a/courses/rainbow_road/course_displaylists.inc.c +++ b/courses/rainbow_road/course_displaylists.inc.c @@ -1,6 +1,6 @@ -#include +#include #include -#include +#include #include #include diff --git a/courses/rainbow_road/course_displaylists.inc.h b/courses/rainbow_road/course_displaylists.inc.h index e6dd89628..1ba5cc699 100644 --- a/courses/rainbow_road/course_displaylists.inc.h +++ b/courses/rainbow_road/course_displaylists.inc.h @@ -1,4 +1,4 @@ -#include +#include #include "macros.h" extern Gfx d_course_rainbow_road_packed_dl_0[]; diff --git a/courses/rainbow_road/course_offsets.c b/courses/rainbow_road/course_offsets.c index 4bc5cb5d7..f94da6db5 100644 --- a/courses/rainbow_road/course_offsets.c +++ b/courses/rainbow_road/course_offsets.c @@ -1,4 +1,4 @@ -#include +#include #include "course_offsets.h" extern u8 gTextureStarOutline[]; diff --git a/courses/royal_raceway/course_data.c b/courses/royal_raceway/course_data.c index 4e7e1a7b8..05a181b41 100644 --- a/courses/royal_raceway/course_data.c +++ b/courses/royal_raceway/course_data.c @@ -1,7 +1,7 @@ //! @todo Replace addresses with variables -#include +#include #include -#include +#include #include #include #include diff --git a/courses/royal_raceway/course_data.h b/courses/royal_raceway/course_data.h index 3f7325424..2ceb1380f 100644 --- a/courses/royal_raceway/course_data.h +++ b/courses/royal_raceway/course_data.h @@ -1,8 +1,8 @@ #ifndef ROYAL_RACEWAY_COURSE_DATA_H #define ROYAL_RACEWAY_COURSE_DATA_H -#include -#include +#include +#include #include #include #include diff --git a/courses/royal_raceway/course_displaylists.inc.c b/courses/royal_raceway/course_displaylists.inc.c index a51c7ca58..539058ef8 100644 --- a/courses/royal_raceway/course_displaylists.inc.c +++ b/courses/royal_raceway/course_displaylists.inc.c @@ -1,6 +1,6 @@ -#include +#include #include -#include +#include #include #include diff --git a/courses/royal_raceway/course_displaylists.inc.h b/courses/royal_raceway/course_displaylists.inc.h index be7faeecd..9e40e2f28 100644 --- a/courses/royal_raceway/course_displaylists.inc.h +++ b/courses/royal_raceway/course_displaylists.inc.h @@ -1,4 +1,4 @@ -#include +#include #include "macros.h" extern Gfx d_course_royal_raceway_packed_dl_0[]; diff --git a/courses/royal_raceway/course_offsets.c b/courses/royal_raceway/course_offsets.c index 8b74e33be..d4c8e11bc 100644 --- a/courses/royal_raceway/course_offsets.c +++ b/courses/royal_raceway/course_offsets.c @@ -1,4 +1,4 @@ -#include +#include #include "course_offsets.h" #include "course_data.h" diff --git a/courses/sherbet_land/course_data.c b/courses/sherbet_land/course_data.c index 4eb7376ee..45e61b3ba 100644 --- a/courses/sherbet_land/course_data.c +++ b/courses/sherbet_land/course_data.c @@ -1,7 +1,7 @@ //! @todo Replace addresses with variables -#include +#include #include -#include +#include #include #include #include diff --git a/courses/sherbet_land/course_data.h b/courses/sherbet_land/course_data.h index 7479a228a..6c1c6d9dc 100644 --- a/courses/sherbet_land/course_data.h +++ b/courses/sherbet_land/course_data.h @@ -1,8 +1,8 @@ #ifndef SHERBET_LAND_COURSE_DATA_H #define SHERBET_LAND_COURSE_DATA_H -#include -#include +#include +#include #include #include #include diff --git a/courses/sherbet_land/course_displaylists.inc.c b/courses/sherbet_land/course_displaylists.inc.c index 6e7416e68..9ff78fd10 100644 --- a/courses/sherbet_land/course_displaylists.inc.c +++ b/courses/sherbet_land/course_displaylists.inc.c @@ -1,6 +1,6 @@ -#include +#include #include -#include +#include #include #include diff --git a/courses/sherbet_land/course_displaylists.inc.h b/courses/sherbet_land/course_displaylists.inc.h index c8de586c8..3c23d3f40 100644 --- a/courses/sherbet_land/course_displaylists.inc.h +++ b/courses/sherbet_land/course_displaylists.inc.h @@ -1,4 +1,4 @@ -#include +#include #include "macros.h" extern Gfx d_course_sherbet_land_packed_dl_0[]; diff --git a/courses/sherbet_land/course_offsets.c b/courses/sherbet_land/course_offsets.c index a55981bdf..28c4ccc06 100644 --- a/courses/sherbet_land/course_offsets.c +++ b/courses/sherbet_land/course_offsets.c @@ -1,4 +1,4 @@ -#include +#include #include "course_offsets.h" #include "course_data.h" diff --git a/courses/skyscraper/course_data.c b/courses/skyscraper/course_data.c index 03c5e996e..b080efdc0 100644 --- a/courses/skyscraper/course_data.c +++ b/courses/skyscraper/course_data.c @@ -1,6 +1,6 @@ -#include +#include #include -#include +#include #include #include "course_displaylists.inc.h" diff --git a/courses/skyscraper/course_data.h b/courses/skyscraper/course_data.h index 67570c375..e9f1b7a65 100644 --- a/courses/skyscraper/course_data.h +++ b/courses/skyscraper/course_data.h @@ -1,8 +1,8 @@ #ifndef SKYSCRAPER_COURSE_DATA_H #define SKYSCRAPER_COURSE_DATA_H -#include -#include +#include +#include #include extern Gfx d_course_skyscraper_dl[]; diff --git a/courses/skyscraper/course_displaylists.inc.c b/courses/skyscraper/course_displaylists.inc.c index 0294b58f2..9c0efa370 100644 --- a/courses/skyscraper/course_displaylists.inc.c +++ b/courses/skyscraper/course_displaylists.inc.c @@ -1,6 +1,6 @@ -#include +#include #include -#include +#include #include #include diff --git a/courses/skyscraper/course_displaylists.inc.h b/courses/skyscraper/course_displaylists.inc.h index 276d7fb37..921875183 100644 --- a/courses/skyscraper/course_displaylists.inc.h +++ b/courses/skyscraper/course_displaylists.inc.h @@ -1,4 +1,4 @@ -#include +#include #include "macros.h" extern Gfx d_course_skyscraper_packed_dl_0[]; diff --git a/courses/skyscraper/course_offsets.c b/courses/skyscraper/course_offsets.c index a88d8a169..201cdcf46 100644 --- a/courses/skyscraper/course_offsets.c +++ b/courses/skyscraper/course_offsets.c @@ -1,4 +1,4 @@ -#include +#include #include "course_offsets.h" extern u8 gTexture6457D8[]; diff --git a/courses/staff_ghost_data.c b/courses/staff_ghost_data.c index 87d5967d6..9483089ba 100644 --- a/courses/staff_ghost_data.c +++ b/courses/staff_ghost_data.c @@ -1,4 +1,4 @@ -#include +#include #include #include "common_structs.h" @@ -25,4 +25,3 @@ s32 D_0F4FCAD0[] = { 0xc8c80000, 0x00007b39, 0x6f6f6f6f, 0x6f6f6f6f, 0x3f7b0000, 0x0000c8c8, 0xc8c8c8c8, 0xc8000000 }; - diff --git a/courses/toads_turnpike/course_data.c b/courses/toads_turnpike/course_data.c index 709ddf1ac..e068d78b3 100644 --- a/courses/toads_turnpike/course_data.c +++ b/courses/toads_turnpike/course_data.c @@ -1,7 +1,7 @@ //! @todo Replace addresses with variables -#include +#include #include -#include +#include #include #include #include @@ -8432,4 +8432,3 @@ TrackSections d_course_toads_turnpike_addr[] = { { d_course_toads_turnpike_packed_dl_51C8, 255, 255, 0x0000 }, { 0x00000000, 0, 0, 0x0000 }, }; - diff --git a/courses/toads_turnpike/course_data.h b/courses/toads_turnpike/course_data.h index 3abb384ed..c1628ae5c 100644 --- a/courses/toads_turnpike/course_data.h +++ b/courses/toads_turnpike/course_data.h @@ -1,8 +1,8 @@ #ifndef TOADS_TURNPIKE_COURSE_DATA_H #define TOADS_TURNPIKE_COURSE_DATA_H -#include -#include +#include +#include #include #include #include diff --git a/courses/toads_turnpike/course_displaylists.inc.c b/courses/toads_turnpike/course_displaylists.inc.c index 9c6705620..541d49f8c 100644 --- a/courses/toads_turnpike/course_displaylists.inc.c +++ b/courses/toads_turnpike/course_displaylists.inc.c @@ -1,6 +1,6 @@ -#include +#include #include -#include +#include #include #include "course_displaylists.inc.h" diff --git a/courses/toads_turnpike/course_displaylists.inc.h b/courses/toads_turnpike/course_displaylists.inc.h index a92b11c0d..54b02dff9 100644 --- a/courses/toads_turnpike/course_displaylists.inc.h +++ b/courses/toads_turnpike/course_displaylists.inc.h @@ -1,4 +1,4 @@ -#include +#include #include "macros.h" extern Gfx d_course_toads_turnpike_packed_dl_0[]; diff --git a/courses/toads_turnpike/course_offsets.c b/courses/toads_turnpike/course_offsets.c index 4a2066ed4..42af983b5 100644 --- a/courses/toads_turnpike/course_offsets.c +++ b/courses/toads_turnpike/course_offsets.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include "course_offsets.h" diff --git a/courses/wario_stadium/course_data.c b/courses/wario_stadium/course_data.c index 6c75f57d5..3c87af554 100644 --- a/courses/wario_stadium/course_data.c +++ b/courses/wario_stadium/course_data.c @@ -1,7 +1,7 @@ //! @todo Replace addresses with variables -#include +#include #include -#include +#include #include #include #include diff --git a/courses/wario_stadium/course_data.h b/courses/wario_stadium/course_data.h index 1fc5d7515..2c26dd3e0 100644 --- a/courses/wario_stadium/course_data.h +++ b/courses/wario_stadium/course_data.h @@ -1,8 +1,8 @@ #ifndef WARIO_STADIUM_COURSE_DATA_H #define WARIO_STADIUM_COURSE_DATA_H -#include -#include +#include +#include #include #include #include diff --git a/courses/wario_stadium/course_displaylists.inc.c b/courses/wario_stadium/course_displaylists.inc.c index 1b0b71ab9..62e3a4c24 100644 --- a/courses/wario_stadium/course_displaylists.inc.c +++ b/courses/wario_stadium/course_displaylists.inc.c @@ -1,6 +1,6 @@ -#include +#include #include -#include +#include #include #include diff --git a/courses/wario_stadium/course_displaylists.inc.h b/courses/wario_stadium/course_displaylists.inc.h index f65532ce3..c015e6411 100644 --- a/courses/wario_stadium/course_displaylists.inc.h +++ b/courses/wario_stadium/course_displaylists.inc.h @@ -1,4 +1,4 @@ -#include +#include #include "macros.h" extern Gfx d_course_wario_stadium_packed_dl_0[]; diff --git a/courses/wario_stadium/course_offsets.c b/courses/wario_stadium/course_offsets.c index ec01ebe9f..3d55c9e24 100644 --- a/courses/wario_stadium/course_offsets.c +++ b/courses/wario_stadium/course_offsets.c @@ -1,4 +1,4 @@ -#include +#include #include "course_offsets.h" #include "course_data.h" diff --git a/courses/yoshi_valley/course_data.c b/courses/yoshi_valley/course_data.c index 2053ea389..2f9a9e339 100644 --- a/courses/yoshi_valley/course_data.c +++ b/courses/yoshi_valley/course_data.c @@ -1,7 +1,7 @@ //! @todo Replace addresses with variables -#include +#include #include -#include +#include #include #include #include @@ -10574,7 +10574,7 @@ u8 d_course_yoshi_valley_yoshi_flag[] = { // 0x141A0 Lights1 d_course_yoshi_valley_unknown_light4 = gdSPDefLights1(0x37, 0x27, 0x07, 0xDF, 0x9F, 0x1F, 0x42, 0x00, 0x9D); -Lights1 d_course_yoshi_valley_unknown_light5 = gdSPDefLights1(0x14, 0x0A, 0x00, 0x50, 0x28, 0x00, 0x42, 0x00, 0x9D); +Lights1 d_course_yoshi_valley_unknown_light5 = gdSPDefLights1(0x14, 0x0A, 0x00, 0x50, 0x28, 0x00, 0x42, 0x00, 0x9D); // 0x141D0 Vtx d_course_yoshi_valley_flag_pole_model1[] = { diff --git a/courses/yoshi_valley/course_data.h b/courses/yoshi_valley/course_data.h index 7110a18a2..299e9ca8b 100644 --- a/courses/yoshi_valley/course_data.h +++ b/courses/yoshi_valley/course_data.h @@ -1,8 +1,8 @@ #ifndef YOSHI_VALLEY_COURSE_DATA_H #define YOSHI_VALLEY_COURSE_DATA_H -#include -#include +#include +#include #include #include #include diff --git a/courses/yoshi_valley/course_displaylists.inc.c b/courses/yoshi_valley/course_displaylists.inc.c index c1efa0f59..510e8e110 100644 --- a/courses/yoshi_valley/course_displaylists.inc.c +++ b/courses/yoshi_valley/course_displaylists.inc.c @@ -1,6 +1,6 @@ -#include +#include #include -#include +#include #include #include diff --git a/courses/yoshi_valley/course_displaylists.inc.h b/courses/yoshi_valley/course_displaylists.inc.h index 5d24cffe6..5a311a179 100644 --- a/courses/yoshi_valley/course_displaylists.inc.h +++ b/courses/yoshi_valley/course_displaylists.inc.h @@ -1,4 +1,4 @@ -#include +#include #include "macros.h" extern Gfx d_course_yoshi_valley_packed_dl_0[]; diff --git a/courses/yoshi_valley/course_offsets.c b/courses/yoshi_valley/course_offsets.c index bbdea1519..0a91bf73b 100644 --- a/courses/yoshi_valley/course_offsets.c +++ b/courses/yoshi_valley/course_offsets.c @@ -1,4 +1,4 @@ -#include +#include #include "course_offsets.h" extern u8 gTexture66EBF0[]; diff --git a/enhancements/flycam.patch b/enhancements/flycam.patch index 8db6ca596..ae3b0dab7 100644 --- a/enhancements/flycam.patch +++ b/enhancements/flycam.patch @@ -45,7 +45,7 @@ index 02275b1..406739d 100644 - func_8001E45C(camera, player, index); + + flycam(camera, player, index); -+ ++ break; case 8: func_8001E0C4(camera, player, index); @@ -56,7 +56,7 @@ index 6b14e27..d10796b 100644 @@ -65,6 +65,8 @@ void func_8001F9E4(Player *player, Camera *camera, s8 arg2) { } } - + +extern u32 isFlycam; + u16 check_player_camera_collision(Player *player, Camera *camera, f32 arg2, f32 arg3) { @@ -65,11 +65,11 @@ index 6b14e27..d10796b 100644 @@ -79,6 +81,10 @@ u16 check_player_camera_collision(Player *player, Camera *camera, f32 arg2, f32 s16 var_v0; u16 ret; - + + if (isFlycam) { + return 1; + } -+ ++ ret = 0; switch (gActiveScreenMode) { /* irregular */ case SCREEN_MODE_1P: @@ -79,7 +79,7 @@ index 0000000..5569838 --- /dev/null +++ b/src/flycam.c @@ -0,0 +1,328 @@ -+#include ++#include +#include +#include ++#include @@ -105,7 +105,7 @@ index 0000000..5569838 +typedef struct { + Vec3f pos; + Vec3f lookAt; -+ Vec3s rot; ++ Vec3s rot; +} FlycamSaveState; + +FlycamSaveState fState; @@ -122,26 +122,26 @@ index 0000000..5569838 + +/** + * Controls -+ * ++ * + * Forward: A + * Backward: B -+ * ++ * + * Go faster: Z -+ * ++ * + * Up: C-up + * Down: C-down -+ * ++ * + * Targets players based on rank position -+ * ++ * + * Target player: R-trig + * Target next player: C-right + * Target previous player: C-left -+ * ++ * + * Switch camera modes: D-pad left -+ * ++ * + * Camera mode 1: Enter flycam at the player's position + * Camera mode 2: Enter flycam at previous flycam spot -+ * ++ * +*/ + +void flycam(Camera *camera, Player *player, s8 index) { @@ -151,7 +151,7 @@ index 0000000..5569838 + f32 dirY; + f32 dirZ; + f32 length; -+ ++ + if (controller->buttonPressed & L_TRIG) { + isFlycam = !isFlycam; + @@ -196,7 +196,7 @@ index 0000000..5569838 + //player->type |= PLAYER_HUMAN; + + if ((player->type & PLAYER_START_SEQUENCE)) { return; } -+ ++ + + flycam_controller_manager(camera, controller, player); + @@ -433,7 +433,7 @@ index c2a84aa..338e2bd 100644 @@ -180,6 +180,11 @@ void load_surface_map(uintptr_t addr, struct UnkStruct_800DC5EC *arg1) { arg1->pathCounter = temp_v1; temp_v1 = ((temp_v1 - 1) * 4) + var_a3; - + + if (isFlycam) { + func_8029569C(); + return; @@ -441,4 +441,3 @@ index c2a84aa..338e2bd 100644 + gSPDisplayList(gDisplayListHead++, gfx[temp_v1]); } - diff --git a/include/PR/R4300.h b/include/PR/R4300.h deleted file mode 100644 index 932694d3f..000000000 --- a/include/PR/R4300.h +++ /dev/null @@ -1,453 +0,0 @@ -/************************************************************************** - * * - * Copyright (C) 1995, Silicon Graphics, Inc. * - * * - * These coded instructions, statements, and computer programs contain * - * unpublished proprietary information of Silicon Graphics, Inc., and * - * are protected by Federal copyright law. They may not be disclosed * - * to third parties or copied or duplicated in any form, in whole or * - * in part, without the prior written consent of Silicon Graphics, Inc. * - * * - **************************************************************************/ - -/************************************************************************** - * - * $Revision: 1.13 $ - * $Date: 1997/02/11 08:15:34 $ - * $Source: /disk6/Master/cvsmdev2/PR/include/R4300.h,v $ - * - **************************************************************************/ - -#ifndef __R4300_H__ -#define __R4300_H__ - -#include - -/* - * Segment base addresses and sizes - */ -#define KUBASE 0 -#define KUSIZE 0x80000000 -#define K0BASE 0x80000000 -#define K0SIZE 0x20000000 -#define K1BASE 0xA0000000 -#define K1SIZE 0x20000000 -#define K2BASE 0xC0000000 -#define K2SIZE 0x20000000 - -/* - * Exception vectors - */ -#define SIZE_EXCVEC 0x80 /* Size of an exc. vec */ -#define UT_VEC K0BASE /* utlbmiss vector */ -#define R_VEC (K1BASE+0x1fc00000) /* reset vector */ -#define XUT_VEC (K0BASE+0x80) /* extended address tlbmiss */ -#define ECC_VEC (K0BASE+0x100) /* Ecc exception vector */ -#define E_VEC (K0BASE+0x180) /* Gen. exception vector */ - -/* - * Address conversion macros - */ -#ifdef _LANGUAGE_ASSEMBLY - -#define K0_TO_K1(x) ((x)|0xA0000000) /* kseg0 to kseg1 */ -#define K1_TO_K0(x) ((x)&0x9FFFFFFF) /* kseg1 to kseg0 */ -#define K0_TO_PHYS(x) ((x)&0x1FFFFFFF) /* kseg0 to physical */ -#define K1_TO_PHYS(x) ((x)&0x1FFFFFFF) /* kseg1 to physical */ -#define KDM_TO_PHYS(x) ((x)&0x1FFFFFFF) /* direct mapped to physical */ -#define PHYS_TO_K0(x) ((x)|0x80000000) /* physical to kseg0 */ -#define PHYS_TO_K1(x) ((x)|0xA0000000) /* physical to kseg1 */ - -#else /* _LANGUAGE_C */ - -#define K0_TO_K1(x) ((u32)(x)|0xA0000000) /* kseg0 to kseg1 */ -#define K1_TO_K0(x) ((u32)(x)&0x9FFFFFFF) /* kseg1 to kseg0 */ -#define K0_TO_PHYS(x) ((u32)(x)&0x1FFFFFFF) /* kseg0 to physical */ -#define K1_TO_PHYS(x) ((u32)(x)&0x1FFFFFFF) /* kseg1 to physical */ -#define KDM_TO_PHYS(x) ((u32)(x)&0x1FFFFFFF) /* direct mapped to physical */ -#define PHYS_TO_K0(x) ((u32)(x)|0x80000000) /* physical to kseg0 */ -#define PHYS_TO_K1(x) ((u32)(x)|0xA0000000) /* physical to kseg1 */ - -#endif /* _LANGUAGE_ASSEMBLY */ - -/* - * Address predicates - */ -#define IS_KSEG0(x) ((u32)(x) >= K0BASE && (u32)(x) < K1BASE) -#define IS_KSEG1(x) ((u32)(x) >= K1BASE && (u32)(x) < K2BASE) -#define IS_KSEGDM(x) ((u32)(x) >= K0BASE && (u32)(x) < K2BASE) -#define IS_KSEG2(x) ((u32)(x) >= K2BASE && (u32)(x) < KPTE_SHDUBASE) -#define IS_KPTESEG(x) ((u32)(x) >= KPTE_SHDUBASE) -#define IS_KUSEG(x) ((u32)(x) < K0BASE) - -/* - * TLB size constants - */ - -#define NTLBENTRIES 31 /* entry 31 is reserved by rdb */ - -#define TLBHI_VPN2MASK 0xffffe000 -#define TLBHI_VPN2SHIFT 13 -#define TLBHI_PIDMASK 0xff -#define TLBHI_PIDSHIFT 0 -#define TLBHI_NPID 255 /* 255 to fit in 8 bits */ - -#define TLBLO_PFNMASK 0x3fffffc0 -#define TLBLO_PFNSHIFT 6 -#define TLBLO_CACHMASK 0x38 /* cache coherency algorithm */ -#define TLBLO_CACHSHIFT 3 -#define TLBLO_UNCACHED 0x10 /* not cached */ -#define TLBLO_NONCOHRNT 0x18 /* Cacheable non-coherent */ -#define TLBLO_EXLWR 0x28 /* Exclusive write */ -#define TLBLO_D 0x4 /* writeable */ -#define TLBLO_V 0x2 /* valid bit */ -#define TLBLO_G 0x1 /* global access bit */ - -#define TLBINX_PROBE 0x80000000 -#define TLBINX_INXMASK 0x3f -#define TLBINX_INXSHIFT 0 - -#define TLBRAND_RANDMASK 0x3f -#define TLBRAND_RANDSHIFT 0 - -#define TLBWIRED_WIREDMASK 0x3f - -#define TLBCTXT_BASEMASK 0xff800000 -#define TLBCTXT_BASESHIFT 23 -#define TLBCTXT_BASEBITS 9 - -#define TLBCTXT_VPNMASK 0x7ffff0 -#define TLBCTXT_VPNSHIFT 4 - -#define TLBPGMASK_4K 0x0 -#define TLBPGMASK_16K 0x6000 -#define TLBPGMASK_64K 0x1e000 - -/* - * Status register - */ -#define SR_CUMASK 0xf0000000 /* coproc usable bits */ - -#define SR_CU3 0x80000000 /* Coprocessor 3 usable */ -#define SR_CU2 0x40000000 /* Coprocessor 2 usable */ -#define SR_CU1 0x20000000 /* Coprocessor 1 usable */ -#define SR_CU0 0x10000000 /* Coprocessor 0 usable */ -#define SR_RP 0x08000000 /* Reduced power (quarter speed) */ -#define SR_FR 0x04000000 /* MIPS III FP register mode */ -#define SR_RE 0x02000000 /* Reverse endian */ -#define SR_ITS 0x01000000 /* Instruction trace support */ -#define SR_BEV 0x00400000 /* Use boot exception vectors */ -#define SR_TS 0x00200000 /* TLB shutdown */ -#define SR_SR 0x00100000 /* Soft reset occured */ -#define SR_CH 0x00040000 /* Cache hit for last 'cache' op */ -#define SR_CE 0x00020000 /* Create ECC */ -#define SR_DE 0x00010000 /* ECC of parity does not cause error */ - -/* - * Interrupt enable bits - * (NOTE: bits set to 1 enable the corresponding level interrupt) - */ -#define SR_IMASK 0x0000ff00 /* Interrupt mask */ -#define SR_IMASK8 0x00000000 /* mask level 8 */ -#define SR_IMASK7 0x00008000 /* mask level 7 */ -#define SR_IMASK6 0x0000c000 /* mask level 6 */ -#define SR_IMASK5 0x0000e000 /* mask level 5 */ -#define SR_IMASK4 0x0000f000 /* mask level 4 */ -#define SR_IMASK3 0x0000f800 /* mask level 3 */ -#define SR_IMASK2 0x0000fc00 /* mask level 2 */ -#define SR_IMASK1 0x0000fe00 /* mask level 1 */ -#define SR_IMASK0 0x0000ff00 /* mask level 0 */ - -#define SR_IBIT8 0x00008000 /* bit level 8 */ -#define SR_IBIT7 0x00004000 /* bit level 7 */ -#define SR_IBIT6 0x00002000 /* bit level 6 */ -#define SR_IBIT5 0x00001000 /* bit level 5 */ -#define SR_IBIT4 0x00000800 /* bit level 4 */ -#define SR_IBIT3 0x00000400 /* bit level 3 */ -#define SR_IBIT2 0x00000200 /* bit level 2 */ -#define SR_IBIT1 0x00000100 /* bit level 1 */ - -#define SR_IMASKSHIFT 8 - -#define SR_KX 0x00000080 /* extended-addr TLB vec in kernel */ -#define SR_SX 0x00000040 /* xtended-addr TLB vec supervisor */ -#define SR_UX 0x00000020 /* xtended-addr TLB vec in user mode */ -#define SR_KSU_MASK 0x00000018 /* mode mask */ -#define SR_KSU_USR 0x00000010 /* user mode */ -#define SR_KSU_SUP 0x00000008 /* supervisor mode */ -#define SR_KSU_KER 0x00000000 /* kernel mode */ -#define SR_ERL 0x00000004 /* Error level, 1=>cache error */ -#define SR_EXL 0x00000002 /* Exception level, 1=>exception */ -#define SR_IE 0x00000001 /* interrupt enable, 1=>enable */ - -/* - * Cause Register - */ -#define CAUSE_BD 0x80000000 /* Branch delay slot */ -#define CAUSE_CEMASK 0x30000000 /* coprocessor error */ -#define CAUSE_CESHIFT 28 - -/* Interrupt pending bits */ -#define CAUSE_IP8 0x00008000 /* External level 8 pending - COMPARE */ -#define CAUSE_IP7 0x00004000 /* External level 7 pending - INT4 */ -#define CAUSE_IP6 0x00002000 /* External level 6 pending - INT3 */ -#define CAUSE_IP5 0x00001000 /* External level 5 pending - INT2 */ -#define CAUSE_IP4 0x00000800 /* External level 4 pending - INT1 */ -#define CAUSE_IP3 0x00000400 /* External level 3 pending - INT0 */ -#define CAUSE_SW2 0x00000200 /* Software level 2 pending */ -#define CAUSE_SW1 0x00000100 /* Software level 1 pending */ - -#define CAUSE_IPMASK 0x0000FF00 /* Pending interrupt mask */ -#define CAUSE_IPSHIFT 8 - -#define CAUSE_EXCMASK 0x0000007C /* Cause code bits */ - -#define CAUSE_EXCSHIFT 2 - -/* Cause register exception codes */ - -#define EXC_CODE(x) ((x)<<2) - -/* Hardware exception codes */ -#define EXC_INT EXC_CODE(0) /* interrupt */ -#define EXC_MOD EXC_CODE(1) /* TLB mod */ -#define EXC_RMISS EXC_CODE(2) /* Read TLB Miss */ -#define EXC_WMISS EXC_CODE(3) /* Write TLB Miss */ -#define EXC_RADE EXC_CODE(4) /* Read Address Error */ -#define EXC_WADE EXC_CODE(5) /* Write Address Error */ -#define EXC_IBE EXC_CODE(6) /* Instruction Bus Error */ -#define EXC_DBE EXC_CODE(7) /* Data Bus Error */ -#define EXC_SYSCALL EXC_CODE(8) /* SYSCALL */ -#define EXC_BREAK EXC_CODE(9) /* BREAKpoint */ -#define EXC_II EXC_CODE(10) /* Illegal Instruction */ -#define EXC_CPU EXC_CODE(11) /* CoProcessor Unusable */ -#define EXC_OV EXC_CODE(12) /* OVerflow */ -#define EXC_TRAP EXC_CODE(13) /* Trap exception */ -#define EXC_VCEI EXC_CODE(14) /* Virt. Coherency on Inst. fetch */ -#define EXC_FPE EXC_CODE(15) /* Floating Point Exception */ -#define EXC_WATCH EXC_CODE(23) /* Watchpoint reference */ -#define EXC_VCED EXC_CODE(31) /* Virt. Coherency on data read */ - -/* C0_PRID Defines */ -#define C0_IMPMASK 0xff00 -#define C0_IMPSHIFT 8 -#define C0_REVMASK 0xff -#define C0_MAJREVMASK 0xf0 -#define C0_MAJREVSHIFT 4 -#define C0_MINREVMASK 0xf - -/* - * Coprocessor 0 operations - */ -#define C0_READI 0x1 /* read ITLB entry addressed by C0_INDEX */ -#define C0_WRITEI 0x2 /* write ITLB entry addressed by C0_INDEX */ -#define C0_WRITER 0x6 /* write ITLB entry addressed by C0_RAND */ -#define C0_PROBE 0x8 /* probe for ITLB entry addressed by TLBHI */ -#define C0_RFE 0x10 /* restore for exception */ - -/* - * 'cache' instruction definitions - */ - -/* Target cache */ -#define CACH_PI 0x0 /* specifies primary inst. cache */ -#define CACH_PD 0x1 /* primary data cache */ -#define CACH_SI 0x2 /* secondary instruction cache */ -#define CACH_SD 0x3 /* secondary data cache */ - -/* Cache operations */ -#define C_IINV 0x0 /* index invalidate (inst, 2nd inst) */ -#define C_IWBINV 0x0 /* index writeback inval (d, sd) */ -#define C_ILT 0x4 /* index load tag (all) */ -#define C_IST 0x8 /* index store tag (all) */ -#define C_CDX 0xc /* create dirty exclusive (d, sd) */ -#define C_HINV 0x10 /* hit invalidate (all) */ -#define C_HWBINV 0x14 /* hit writeback inv. (d, sd) */ -#define C_FILL 0x14 /* fill (i) */ -#define C_HWB 0x18 /* hit writeback (i, d, sd) */ -#define C_HSV 0x1c /* hit set virt. (si, sd) */ - -/* - * Cache size definitions - */ -#define ICACHE_SIZE 0x4000 /* 16K */ -#define ICACHE_LINESIZE 32 /* 8 words */ -#define ICACHE_LINEMASK (ICACHE_LINESIZE-1) - -#define DCACHE_SIZE 0x2000 /* 8K */ -#define DCACHE_LINESIZE 16 /* 4 words */ -#define DCACHE_LINEMASK (DCACHE_LINESIZE-1) - -/* - * C0_CONFIG register definitions - */ -#define CONFIG_CM 0x80000000 /* 1 == Master-Checker enabled */ -#define CONFIG_EC 0x70000000 /* System Clock ratio */ -#define CONFIG_EC_1_1 0x6 /* System Clock ratio 1 :1 */ -#define CONFIG_EC_3_2 0x7 /* System Clock ratio 1.5 :1 */ -#define CONFIG_EC_2_1 0x0 /* System Clock ratio 2 :1 */ -#define CONFIG_EC_3_1 0x1 /* System Clock ratio 3 :1 */ -#define CONFIG_EP 0x0f000000 /* Transmit Data Pattern */ -#define CONFIG_SB 0x00c00000 /* Secondary cache block size */ - -#define CONFIG_SS 0x00200000 /* Split scache: 0 == I&D combined */ -#define CONFIG_SW 0x00100000 /* scache port: 0==128, 1==64 */ -#define CONFIG_EW 0x000c0000 /* System Port width: 0==64, 1==32 */ -#define CONFIG_SC 0x00020000 /* 0 -> 2nd cache present */ -#define CONFIG_SM 0x00010000 /* 0 -> Dirty Shared Coherency enabled*/ -#define CONFIG_BE 0x00008000 /* Endian-ness: 1 --> BE */ -#define CONFIG_EM 0x00004000 /* 1 -> ECC mode, 0 -> parity */ -#define CONFIG_EB 0x00002000 /* Block order:1->sequent,0->subblock */ - -#define CONFIG_IC 0x00000e00 /* Primary Icache size */ -#define CONFIG_DC 0x000001c0 /* Primary Dcache size */ -#define CONFIG_IB 0x00000020 /* Icache block size */ -#define CONFIG_DB 0x00000010 /* Dcache block size */ -#define CONFIG_CU 0x00000008 /* Update on Store-conditional */ -#define CONFIG_K0 0x00000007 /* K0SEG Coherency algorithm */ - -#define CONFIG_UNCACHED 0x00000002 /* K0 is uncached */ -#define CONFIG_NONCOHRNT 0x00000003 -#define CONFIG_COHRNT_EXLWR 0x00000005 -#define CONFIG_SB_SHFT 22 /* shift SB to bit position 0 */ -#define CONFIG_IC_SHFT 9 /* shift IC to bit position 0 */ -#define CONFIG_DC_SHFT 6 /* shift DC to bit position 0 */ -#define CONFIG_BE_SHFT 15 /* shift BE to bit position 0 */ - -/* - * C0_TAGLO definitions for setting/getting cache states and physaddr bits - */ -#define SADDRMASK 0xFFFFE000 /* 31..13 -> scache paddr bits 35..17 */ -#define SVINDEXMASK 0x00000380 /* 9..7: prim virt index bits 14..12 */ -#define SSTATEMASK 0x00001c00 /* bits 12..10 hold scache line state */ -#define SINVALID 0x00000000 /* invalid --> 000 == state 0 */ -#define SCLEANEXCL 0x00001000 /* clean exclusive --> 100 == state 4 */ -#define SDIRTYEXCL 0x00001400 /* dirty exclusive --> 101 == state 5 */ -#define SECC_MASK 0x0000007f /* low 7 bits are ecc for the tag */ -#define SADDR_SHIFT 4 /* shift STagLo (31..13) to 35..17 */ - -#define PADDRMASK 0xFFFFFF00 /* PTagLo31..8->prim paddr bits35..12 */ -#define PADDR_SHIFT 4 /* roll bits 35..12 down to 31..8 */ -#define PSTATEMASK 0x00C0 /* bits 7..6 hold primary line state */ -#define PINVALID 0x0000 /* invalid --> 000 == state 0 */ -#define PCLEANEXCL 0x0080 /* clean exclusive --> 10 == state 2 */ -#define PDIRTYEXCL 0x00C0 /* dirty exclusive --> 11 == state 3 */ -#define PPARITY_MASK 0x0001 /* low bit is parity bit (even). */ - -/* - * C0_CACHE_ERR definitions. - */ -#define CACHERR_ER 0x80000000 /* 0: inst ref, 1: data ref */ -#define CACHERR_EC 0x40000000 /* 0: primary, 1: secondary */ -#define CACHERR_ED 0x20000000 /* 1: data error */ -#define CACHERR_ET 0x10000000 /* 1: tag error */ -#define CACHERR_ES 0x08000000 /* 1: external ref, e.g. snoop*/ -#define CACHERR_EE 0x04000000 /* error on SysAD bus */ -#define CACHERR_EB 0x02000000 /* complicated, see spec. */ -#define CACHERR_EI 0x01000000 /* complicated, see spec. */ -#define CACHERR_SIDX_MASK 0x003ffff8 /* secondary cache index */ -#define CACHERR_PIDX_MASK 0x00000007 /* primary cache index */ -#define CACHERR_PIDX_SHIFT 12 /* bits 2..0 are paddr14..12 */ - -/* R4000 family supports hardware watchpoints: - * C0_WATCHLO: - * bits 31..3 are bits 31..3 of physaddr to watch - * bit 2: reserved; must be written as 0. - * bit 1: when set causes a watchpoint trap on load accesses to paddr. - * bit 0: when set traps on stores to paddr; - * C0_WATCHHI - * bits 31..4 are reserved and must be written as zeros. - * bits 3..0 are bits 35..32 of the physaddr to watch - */ -#define WATCHLO_WTRAP 0x00000001 -#define WATCHLO_RTRAP 0x00000002 -#define WATCHLO_ADDRMASK 0xfffffff8 -#define WATCHLO_VALIDMASK 0xfffffffb -#define WATCHHI_VALIDMASK 0x0000000f - -/* - * Coprocessor 0 registers - */ -#ifdef _LANGUAGE_ASSEMBLY -#define C0_INX $0 -#define C0_RAND $1 -#define C0_ENTRYLO0 $2 -#define C0_ENTRYLO1 $3 -#define C0_CONTEXT $4 -#define C0_PAGEMASK $5 /* page mask */ -#define C0_WIRED $6 /* # wired entries in tlb */ -#define C0_BADVADDR $8 -#define C0_COUNT $9 /* free-running counter */ -#define C0_ENTRYHI $10 -#define C0_SR $12 -#define C0_CAUSE $13 -#define C0_EPC $14 -#define C0_PRID $15 /* revision identifier */ -#define C0_COMPARE $11 /* counter comparison reg. */ -#define C0_CONFIG $16 /* hardware configuration */ -#define C0_LLADDR $17 /* load linked address */ -#define C0_WATCHLO $18 /* watchpoint */ -#define C0_WATCHHI $19 /* watchpoint */ -#define C0_ECC $26 /* S-cache ECC and primary parity */ -#define C0_CACHE_ERR $27 /* cache error status */ -#define C0_TAGLO $28 /* cache operations */ -#define C0_TAGHI $29 /* cache operations */ -#define C0_ERROR_EPC $30 /* ECC error prg. counter */ - -# else /* ! _LANGUAGE_ASSEMBLY */ - -#define C0_INX 0 -#define C0_RAND 1 -#define C0_ENTRYLO0 2 -#define C0_ENTRYLO1 3 -#define C0_CONTEXT 4 -#define C0_PAGEMASK 5 /* page mask */ -#define C0_WIRED 6 /* # wired entries in tlb */ -#define C0_BADVADDR 8 -#define C0_COUNT 9 /* free-running counter */ -#define C0_ENTRYHI 10 -#define C0_SR 12 -#define C0_CAUSE 13 -#define C0_EPC 14 -#define C0_PRID 15 /* revision identifier */ -#define C0_COMPARE 11 /* counter comparison reg. */ -#define C0_CONFIG 16 /* hardware configuration */ -#define C0_LLADDR 17 /* load linked address */ -#define C0_WATCHLO 18 /* watchpoint */ -#define C0_WATCHHI 19 /* watchpoint */ -#define C0_ECC 26 /* S-cache ECC and primary parity */ -#define C0_CACHE_ERR 27 /* cache error status */ -#define C0_TAGLO 28 /* cache operations */ -#define C0_TAGHI 29 /* cache operations */ -#define C0_ERROR_EPC 30 /* ECC error prg. counter */ - -#endif /* _LANGUAGE_ASSEMBLY */ - -/* - * floating-point status register - */ -#define FPCSR_FS 0x01000000 /* flush denorm to zero */ -#define FPCSR_C 0x00800000 /* condition bit */ -#define FPCSR_CE 0x00020000 /* cause: unimplemented operation */ -#define FPCSR_CV 0x00010000 /* cause: invalid operation */ -#define FPCSR_CZ 0x00008000 /* cause: division by zero */ -#define FPCSR_CO 0x00004000 /* cause: overflow */ -#define FPCSR_CU 0x00002000 /* cause: underflow */ -#define FPCSR_CI 0x00001000 /* cause: inexact operation */ -#define FPCSR_EV 0x00000800 /* enable: invalid operation */ -#define FPCSR_EZ 0x00000400 /* enable: division by zero */ -#define FPCSR_EO 0x00000200 /* enable: overflow */ -#define FPCSR_EU 0x00000100 /* enable: underflow */ -#define FPCSR_EI 0x00000080 /* enable: inexact operation */ -#define FPCSR_FV 0x00000040 /* flag: invalid operation */ -#define FPCSR_FZ 0x00000020 /* flag: division by zero */ -#define FPCSR_FO 0x00000010 /* flag: overflow */ -#define FPCSR_FU 0x00000008 /* flag: underflow */ -#define FPCSR_FI 0x00000004 /* flag: inexact operation */ -#define FPCSR_RM_MASK 0x00000003 /* rounding mode mask */ -#define FPCSR_RM_RN 0x00000000 /* round to nearest */ -#define FPCSR_RM_RZ 0x00000001 /* round to zero */ -#define FPCSR_RM_RP 0x00000002 /* round to positive infinity */ -#define FPCSR_RM_RM 0x00000003 /* round to negative infinity */ - -#endif /* __R4300_H */ diff --git a/include/PR/abi.h b/include/PR/abi.h deleted file mode 100644 index 551426951..000000000 --- a/include/PR/abi.h +++ /dev/null @@ -1,999 +0,0 @@ -#ifndef _ABI_H_ -#define _ABI_H_ - -/************************************************************************** - * * - * Copyright (C) 1994, Silicon Graphics, Inc. * - * * - * These coded instructions, statements, and computer programs contain * - * unpublished proprietary information of Silicon Graphics, Inc., and * - * are protected by Federal copyright law. They may not be disclosed * - * to third parties or copied or duplicated in any form, in whole or * - * in part, without the prior written consent of Silicon Graphics, Inc. * - * * - **************************************************************************/ - -/************************************************************************** - * - * $Revision: 1.32 $ - * $Date: 1997/02/11 08:16:37 $ - * $Source: /exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/abi.h,v $ - * - **************************************************************************/ - -/* - * Header file for the Audio Binary Interface. - * This is included in the Media Binary Interface file - * mbi.h. - * - * This file follows the framework used for graphics. - * - */ - -/* Audio commands: */ -#define A_SPNOOP 0 -#define A_ADPCM 1 -#define A_CLEARBUFF 2 -#define A_RESAMPLE 5 -#define A_SETBUFF 8 -#define A_DMEMMOVE 10 -#define A_LOADADPCM 11 -#define A_MIXER 12 -#define A_INTERLEAVE 13 -#define A_SETLOOP 15 - -#if !(defined(VERSION_SH) || defined(VERSION_US) || defined(VERSION_EU)) - -#define A_ENVMIXER 3 -#define A_LOADBUFF 4 -#define A_RESAMPLE 5 -#define A_SAVEBUFF 6 -#define A_SEGMENT 7 -#define A_SETVOL 9 -#define A_POLEF 14 - -#else - -#define A_ADDMIXER 4 -#define A_RESAMPLE_ZOH 6 -#define A_SEGMENT 7 -#define A_DMEMMOVE2 16 -#define A_DOWNSAMPLE_HALF 17 -#define A_ENVSETUP1 18 -#define A_ENVMIXER 19 -#define A_LOADBUFF 20 -#define A_SAVEBUFF 21 -#define A_ENVSETUP2 22 -#define A_S8DEC 23 -#define A_HILOGAIN 24 -#define A_UNK_25 25 -#define A_DUPLICATE 26 -#define A_FILTER 27 - -#endif - -#define ACMD_SIZE 32 -/* - * Audio flags - */ - -#define A_INIT 0x01 -#define A_CONTINUE 0x00 -#define A_LOOP 0x02 -#define A_OUT 0x02 -#define A_LEFT 0x02 -#define A_RIGHT 0x00 -#define A_VOL 0x04 -#define A_RATE 0x00 -#define A_AUX 0x08 -#define A_NOAUX 0x00 -#define A_MAIN 0x00 -#define A_MIX 0x10 - -/* - * BEGIN C-specific section: (typedef's) - */ -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/* - * Data Structures. - */ - -typedef struct { - unsigned int cmd:8; - unsigned int flags:8; - unsigned int gain:16; - unsigned int addr; -} Aadpcm; - -typedef struct { - unsigned int cmd:8; - unsigned int flags:8; - unsigned int gain:16; - unsigned int addr; -} Apolef; - -typedef struct { - unsigned int cmd:8; - unsigned int flags:8; - unsigned int pad1:16; - unsigned int addr; -} Aenvelope; - -typedef struct { - unsigned int cmd:8; - unsigned int pad1:8; - unsigned int dmem:16; - unsigned int pad2:16; - unsigned int count:16; -} Aclearbuff; - -typedef struct { - unsigned int cmd:8; - unsigned int pad1:8; - unsigned int pad2:16; - unsigned int inL:16; - unsigned int inR:16; -} Ainterleave; - -typedef struct { - unsigned int cmd:8; - unsigned int pad1:24; - unsigned int addr; -} Aloadbuff; - -typedef struct { - unsigned int cmd:8; - unsigned int flags:8; - unsigned int pad1:16; - unsigned int addr; -} Aenvmixer; - -typedef struct { - unsigned int cmd:8; - unsigned int flags:8; - unsigned int gain:16; - unsigned int dmemi:16; - unsigned int dmemo:16; -} Amixer; - -typedef struct { - unsigned int cmd:8; - unsigned int flags:8; - unsigned int dmem2:16; - unsigned int addr; -} Apan; - -typedef struct { - unsigned int cmd:8; - unsigned int flags:8; - unsigned int pitch:16; - unsigned int addr; -} Aresample; - -typedef struct { - unsigned int cmd:8; - unsigned int flags:8; - unsigned int pad1:16; - unsigned int addr; -} Areverb; - -typedef struct { - unsigned int cmd:8; - unsigned int pad1:24; - unsigned int addr; -} Asavebuff; - -typedef struct { - unsigned int cmd:8; - unsigned int pad1:24; - unsigned int pad2:2; - unsigned int number:4; - unsigned int base:24; -} Asegment; - -typedef struct { - unsigned int cmd:8; - unsigned int flags:8; - unsigned int dmemin:16; - unsigned int dmemout:16; - unsigned int count:16; -} Asetbuff; - -typedef struct { - unsigned int cmd:8; - unsigned int flags:8; - unsigned int vol:16; - unsigned int voltgt:16; - unsigned int volrate:16; -} Asetvol; - -typedef struct { - unsigned int cmd:8; - unsigned int pad1:8; - unsigned int dmemin:16; - unsigned int dmemout:16; - unsigned int count:16; -} Admemmove; - -typedef struct { - unsigned int cmd:8; - unsigned int pad1:8; - unsigned int count:16; - unsigned int addr; -} Aloadadpcm; - -typedef struct { - unsigned int cmd:8; - unsigned int pad1:8; - unsigned int pad2:16; - unsigned int addr; -} Asetloop; - -/* - * Generic Acmd Packet - */ - -typedef struct { - uintptr_t w0; - uintptr_t w1; -} Awords; - -typedef union { - Awords words; -#if IS_BIG_ENDIAN && !IS_64_BIT - Aadpcm adpcm; - Apolef polef; - Aclearbuff clearbuff; - Aenvelope envelope; - Ainterleave interleave; - Aloadbuff loadbuff; - Aenvmixer envmixer; - Aresample resample; - Areverb reverb; - Asavebuff savebuff; - Asegment segment; - Asetbuff setbuff; - Asetvol setvol; - Admemmove dmemmove; - Aloadadpcm loadadpcm; - Amixer mixer; - Asetloop setloop; -#endif - long long int force_union_align; /* dummy, force alignment */ -} Acmd; - -/* - * ADPCM State - */ -typedef short ADPCM_STATE[16]; - -/* - * Pole filter state - */ -typedef short POLEF_STATE[4]; - -/* - * Resampler state - */ -typedef short RESAMPLE_STATE[16]; - -/* - * Resampler constants - */ -#define UNITY_PITCH 0x8000 -#define MAX_RATIO 1.99996 /* within .03 cents of +1 octave */ - -/* - * Enveloper/Mixer state - */ -typedef short ENVMIX_STATE[40]; - -/* - * Macros to assemble the audio command list - */ - -/* - * Info about parameters: - * - * A "count" in the following macros is always measured in bytes. - * - * All volumes/gains are in Q1.15 signed fixed point numbers: - * 0x8000 is the minimum volume (-100%), negating the audio curve. - * 0x0000 is silent. - * 0x7fff is maximum volume (99.997%). - * - * All DRAM addresses refer to segmented addresses. A segment table shall - * first be set up by calling aSegment for each segment. When a DRAM - * address is later used as parameter, the 8 high bits will be an index - * to the segment table and the lower 24 bits are added to the base address - * stored in the segment table for this entry. The result is the physical address. - * With the newer rsp audio code, this segment table is not used. The address is - * used directly instead. - * - * Transfers to/from DRAM are executed using DMA and hence follow these restrictions: - * All DRAM addresses should be aligned by 8 bytes, or they will be - * rounded down to the nearest multiple of 8 bytes. - * All DRAM lengths should be aligned by 8 bytes, or they will be - * rounded up to the nearest multiple of 8 bytes. - */ - -/* - * Decompresses ADPCM data. - * Possible flags: A_INIT and A_LOOP. - * - * First set up internal data in DMEM: - * aLoadADPCM(cmd++, nEntries * 16, physicalAddressOfBook) - * aSetLoop(cmd++, physicalAddressOfLoopState) (if A_LOOP is set) - * - * Then before this command, call: - * aSetBuffer(cmd++, 0, in, out, count) - * - * Note: count will be rounded up to the nearest multiple of 32 bytes. - * - * ADPCM decompression works on a block of 16 (uncompressed) samples. - * The previous 2 samples and 9 bytes of input are decompressed to - * 16 new samples using the code book previously loaded. - * - * Before the algorithm starts, the previous 16 samples are loaded according to flag: - * A_INIT: all zeros - * A_LOOP: the address set by aSetLoop - * no flags: the DRAM address in the s parameter - * These 16 samples are immediately copied to the destination address. - * - * The result of "count" bytes will be written after these 16 initial samples. - * The last 16 samples written to the destination will also be written to - * the state address in DRAM. - */ -#define aADPCMdec(pkt, f, s) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_ADPCM, 24, 8) | _SHIFTL(f, 16, 8); \ - _a->words.w1 = (uintptr_t)(s); \ -} - -/* - * Not used in SM64. - */ -#define aPoleFilter(pkt, f, g, s) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_POLEF, 24, 8) | _SHIFTL(f, 16, 8) | \ - _SHIFTL(g, 0, 16)); \ - _a->words.w1 = (uintptr_t)(s); \ -} - -/* - * Clears DMEM data, where d is address and c is count, by writing zeros. - * - * Note: c is rounded up to the nearest multiple of 16 bytes. - */ -#define aClearBuffer(pkt, d, c) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_CLEARBUFF, 24, 8) | _SHIFTL(d, 0, 24); \ - _a->words.w1 = (uintptr_t)(c); \ -} - -/* - * Mixes an envelope with mono sound into 2 or 4 channels. - * Possible flags: A_INIT, A_AUX (indicates that 4 channels should be used). - * - * Before this command, call: - * aSetBuffer(cmd++, 0, inBuf, dryLeft, count) - * aSetBuffer(cmd++, A_AUX, dryRight, wetLeft, wetRight) - * - * The first time (A_INIT is set), volume also needs to be set: - * aSetVolume(cmd++, A_VOL | A_LEFT, initialVolumeLeft, 0, 0) - * aSetVolume(cmd++, A_VOL | A_RIGHT, initialVolumeRight, 0, 0) - * aSetVolume32(cmd++, A_RATE | A_LEFT, targetVolumeLeft, rampLeft) - * aSetVolume32(cmd++, A_RATE | A_RIGHT, targetVolumeRight, rampRight) - * aSetVolume(cmd++, A_AUX, dryVolume, 0, wetVolume) - * - * This command will now mix samples in inBuf into the destination buffers (dry and wet), - * but with the volume increased (or decreased) from initial volumes to target volumes, - * with the specified ramp rate. Once the target volume is reached, the volume stays - * at that level. Before the samples are finally mixed (added) into the destination - * buffers (dry and wet), the volume is changed according to dryVolume and wetVolume. - * - * Note: count will be rounded up to the nearest multiple of 16 bytes. - * Note: the wet channels are used for reverb. - * - */ -#define aEnvMixer(pkt, f, s) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_ENVMIXER, 24, 8) | _SHIFTL(f, 16, 8); \ - _a->words.w1 = (uintptr_t)(s); \ -} - -/* - * Interleaves two mono channels into stereo. - * - * First call: - * aSetBuffer(cmd++, 0, 0, output, count) - * - * The count refers to the size of each input. Hence 2 * count bytes will be written out. - * A left sample will be placed before the right sample. - * - * Note: count will be rounded up to the nearest multiple of 16 bytes. - */ -#define aInterleave(pkt, l, r) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_INTERLEAVE, 24, 8); \ - _a->words.w1 = _SHIFTL(l, 16, 16) | _SHIFTL(r, 0, 16); \ -} - -/* - * Loads a buffer from DRAM to DMEM. - * - * First call: - * aSetBuffer(cmd++, 0, in, 0, count) - * - * The in parameter to aSetBuffer is the destination in DMEM and the - * s parameter to this command is the source in DRAM. - */ -#define aLoadBuffer(pkt, s) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_LOADBUFF, 24, 8); \ - _a->words.w1 = (uintptr_t)(s); \ -} - -/* - * Mixes audio. - * Possible flags: no flags used, although parameter present. - * - * First call: - * aSetBuffer(cmd++, 0, 0, 0, count) - * - * Input and output addresses are taken from the i and o parameters. - * The volume with which the input is changed is taken from the g parameter. - * After the volume of the input samples have been changed, the result - * is added to the output. - * - * Note: count will be rounded up to the nearest multiple of 32 bytes. - */ -#define aMix(pkt, f, g, i, o) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_MIXER, 24, 8) | _SHIFTL(f, 16, 8) | \ - _SHIFTL(g, 0, 16)); \ - _a->words.w1 = _SHIFTL(i,16, 16) | _SHIFTL(o, 0, 16); \ -} - -// Not present in the audio microcode. -#define aPan(pkt, f, d, s) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_PAN, 24, 8) | _SHIFTL(f, 16, 8) | \ - _SHIFTL(d, 0, 16)); \ - _a->words.w1 = (uintptr_t)(s); \ -} - -/* - * Resamples audio. - * Possible flags: A_INIT, A_OUT? (not used in SM64). - * - * First call: - * aSetBuffer(cmd++, 0, in, out, count) - * - * This command resamples the audio using the given frequency ratio (pitch) - * using a filter that uses a window of 4 source samples. This can be used - * either for just resampling audio to be able to be played back at a different - * sample rate, or to change the pitch if the result is played back at - * the same sample rate as the input. - * - * The frequency ratio is given in UQ1.15 fixed point format. - * For no change in frequency, use pitch 0x8000. - * For 1 octave up or downsampling to (roughly) half number of samples, use pitch 0xffff. - * For 1 octave down or upsampling to double as many samples, use pitch 0x4000. - * - * Note: count represents the number of output sample bytes and is rounded up to - * the nearest multiple of 16 bytes. - * - * The state consists of the four following source samples when the algorithm stopped as - * well as a fractional position, and is initialized to all zeros if A_INIT is given. - * Otherwise it is loaded from DRAM at address s. - * - * The algorithm starts by writing the four source samples from the state (or zero) - * to just before the input address given. It then creates one output sample by examining - * the four next source samples and then moving the source position zero or more - * samples forward. The first output sample (when A_INIT is given) is always 0. - * - * When "count" bytes have been written, the following four source samples - * are written to the state in DRAM as well as a fractional position. - */ -#define aResample(pkt, f, p, s) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_RESAMPLE, 24, 8) | _SHIFTL(f, 16, 8) |\ - _SHIFTL(p, 0, 16)); \ - _a->words.w1 = (uintptr_t)(s); \ -} - -/* - * Stores a buffer in DMEM to DRAM. - * - * First call: - * aSetBuffer(cmd++, 0, 0, out, count) - * - * The out parameter to aSetBuffer is the source in DMEM and the - * s parameter to this command is the destination in DRAM. - */ -#define aSaveBuffer(pkt, s) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_SAVEBUFF, 24, 8); \ - _a->words.w1 = (uintptr_t)(s); \ -} - -/* - * Sets up an entry in the segment table. - * - * The s parameter is a segment index, 0 to 15. - * The b parameter is the base offset. - */ -#define aSegment(pkt, s, b) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_SEGMENT, 24, 8); \ - _a->words.w1 = _SHIFTL(s, 24, 8) | _SHIFTL(b, 0, 24); \ -} - -/* - * Sets internal DMEM buffer addresses used for later commands. - * See each command for how to use aSetBuffer. - */ -#define aSetBuffer(pkt, f, i, o, c) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_SETBUFF, 24, 8) | _SHIFTL(f, 16, 8) | \ - _SHIFTL(i, 0, 16)); \ - _a->words.w1 = _SHIFTL(o, 16, 16) | _SHIFTL(c, 0, 16); \ -} - -/* - * Sets internal volume parameters. - * See aEnvMixer for more info. - */ -#define aSetVolume(pkt, f, v, t, r) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_SETVOL, 24, 8) | _SHIFTL(f, 16, 16) | \ - _SHIFTL(v, 0, 16)); \ - _a->words.w1 = _SHIFTL(t, 16, 16) | _SHIFTL(r, 0, 16); \ -} - -/* - * Sets the address to ADPCM loop state. - * - * The a parameter is a DRAM address. - * See aADPCMdec for more info. - */ -#define aSetLoop(pkt, a) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - _a->words.w0 = _SHIFTL(A_SETLOOP, 24, 8); \ - _a->words.w1 = (uintptr_t)(a); \ -} - -/* - * Copies memory in DMEM. - * - * Copies c bytes from address i to address o. - * - * Note: count is rounded up to the nearest multiple of 16 bytes. - * - * Note: This acts as memcpy where 16 bytes are moved at a time, therefore - * if input and output overlap, output address should be less than input address. - */ -#define aDMEMMove(pkt, i, o, c) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_DMEMMOVE, 24, 8) | _SHIFTL(i, 0, 24); \ - _a->words.w1 = _SHIFTL(o, 16, 16) | _SHIFTL(c, 0, 16); \ -} - -/* - * Loads ADPCM book from DRAM into DMEM. - * - * This command loads ADPCM table entries from DRAM to DMEM. - * - * The count parameter c should be a multiple of 16 bytes. - * The d parameter is a DRAM address. - */ -#define aLoadADPCM(pkt, c, d) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_LOADADPCM, 24, 8) | _SHIFTL(c, 0, 24); \ - _a->words.w1 = (uintptr_t) (d); \ -} - -// This is a version of aSetVolume which takes a single 32-bit parameter -// instead of two 16-bit ones. According to AziAudio, it is used to set -// ramping values when neither bit 4 nor bit 8 is set in the flags parameter. -// It does not appear in the official abi.h header. -/* - * Sets internal volume parameters. - * See aEnvMixer for more info. - */ -#define aSetVolume32(pkt, f, v, tr) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_SETVOL, 24, 8) | _SHIFTL(f, 16, 16) | \ - _SHIFTL(v, 0, 16)); \ - _a->words.w1 = (uintptr_t)(tr); \ -} - -#if defined(VERSION_SH) || defined(VERSION_US) || defined (VERSION_EU) -#undef aLoadBuffer -#undef aSaveBuffer -#undef aMix -#undef aEnvMixer -// #undef aInterleave - -// New or modified operations in the new audio microcode below - -/** - * Decompresses S8 data. - * Possible flags: A_INIT and A_LOOP. - * - * First set up internal data in DMEM: - * aSetLoop(cmd++, physicalAddressOfLoopState) (if A_LOOP is set) - * - * Then before this command, call: - * aSetBuffer(cmd++, 0, in, out, count) - * - * Note: count will be rounded up to the nearest multiple of 32 bytes. - * - * S8 decompression works by expanding s8 bytes into s16 numbers, - * by performing a left shift of 8 steps. - * - * Before the algorithm starts, the previous 16 samples are loaded according to flag: - * A_INIT: all zeros - * A_LOOP: the address set by aSetLoop - * no flags: the DRAM address in the s parameter - * These 16 samples are immediately copied to the destination address. - * - * The result of "count" bytes will be written after these 16 initial samples. - * The last 16 samples written to the destination will also be written to - * the state address in DRAM. - */ -#define aS8Dec(pkt, f, s) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_S8DEC, 24, 8) | _SHIFTL(f, 16, 8); \ - _a->words.w1 = (uintptr_t)(s); \ -} - -/* - * Mix two tracks by simple clamped addition. - * - * s: DMEM source track 1 - * d: DMEM source track 2 and destination - * c: number of bytes to write - * - * Note: count is first rounded down to the nearest multiple of 16 bytes - * and then rounded up to the nearest multiple of 64 bytes. - */ -#define aAddMixer(pkt, s, d, c) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_ADDMIXER, 24, 8) | \ - _SHIFTL((c) >> 4, 16, 8) | _SHIFTL(0x7fff, 0, 16)); \ - _a->words.w1 = (_SHIFTL(s, 16, 16) | _SHIFTL(d, 0, 16)); \ -} - -/* - * Loads a buffer from DRAM to DMEM. - * - * s: DRAM source - * d: DMEM destination - * c: number of bytes to copy (rounded down to 16 byte alignment) - */ -#define aLoadBuffer(pkt, s, d, c) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_LOADBUFF, 24, 8) | \ - _SHIFTL((c) >> 4, 16, 8) | _SHIFTL(d, 0, 16); \ - _a->words.w1 = (uintptr_t)(s); \ -} - -/* - * Stores a buffer from DMEM to DRAM. - * - * s: DMEM source - * d: DRAM destination - * c: number of bytes to copy (rounded down to 16 byte alignment) - */ -#define aSaveBuffer(pkt, s, d, c) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_SAVEBUFF, 24, 8) | \ - _SHIFTL((c) >> 4, 16, 8) | _SHIFTL(s, 0, 16); \ - _a->words.w1 = (uintptr_t)(d); \ -} - -/* - * Duplicates 128 bytes of data a number of times. - * - * 128 bytes are read from source DMEM address s. - * Then c identical copies of these bytes are written to DMEM address d. - */ -#define aDuplicate(pkt, s, d, c) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_DUPLICATE, 24, 8) | \ - _SHIFTL(c, 16, 8) | _SHIFTL(s, 0, 16)); \ - _a->words.w1 = (_SHIFTL(d, 16, 16) | _SHIFTL(0x80, 0, 16)); \ -} - -/* - * Copies memory in DMEM, second version. - * - * Copies t * c bytes from address i to address o. - * - * Note: count is first rounded up to the nearest multiple of 32 bytes, - * before the multiplication by t. - * - * Note: This acts as memcpy where 32 bytes are moved at a time, therefore - * if input and output overlap, output address should be less than input address. - * - * Not used in SM64. - */ -#define aDMEMMove2(pkt, t, i, o, c) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_DMEMMOVE2, 24, 8) | \ - _SHIFTL(t, 16, 8) | _SHIFTL(i, 0, 16); \ - _a->words.w1 = _SHIFTL(o, 16, 16) | _SHIFTL(c, 0, 16); \ -} - -/* - * Fast resample. - * - * Before this command, call: - * aSetBuffer(cmd++, 0, in, out, count) - * - * This works like the other resample command but just takes the "nearest" sample, - * instead of a function of the four nearest samples. - * - * Initially the current position is calculated as (in << 16) + startFract. - * For every sample to create, the value is simply taken from the sample - * at address ((position >> 17) << 1). Then the current position is incremented - * by (pitch << 2). - * - * Note: count represents the number of output bytes to create, and is - * rounded up to the nearest multiple of 8 bytes. - */ -#define aResampleZoh(pkt, pitch, startFract) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_RESAMPLE_ZOH, 24, 8) | \ - _SHIFTL(pitch, 0, 16)); \ - _a->words.w1 = _SHIFTL(startFract, 0, 16); \ -} - -/* - * Fast downsampling by taking every other sample, discarding others. - * - * Note: nSamples refers to the number of output samples to create, and - * is first rounded up to the nearest multiple of 8. - */ -#define aDownsampleHalf(pkt, nSamples, i, o) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_DOWNSAMPLE_HALF, 24, 8) | \ - _SHIFTL(nSamples, 0, 16)); \ - _a->words.w1 = _SHIFTL(i, 16, 16) | _SHIFTL(o, 0, 16); \ -} - -/* - * Mixes audio. - * - * Input and output addresses are taken from the i and o parameters. - * The volume with which the input is changed is taken from the g parameter. - * After the volume of the input samples have been changed, the result - * is added to the output. - * - * Note: count is first rounded down to the nearest multiple of 16 bytes - * and then rounded up to the nearest multiple of 32 bytes. - */ -#define aMix(pkt, g, i, o, c) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_MIXER, 24, 8) | \ - _SHIFTL((c) >> 4, 16, 8) | _SHIFTL(g, 0, 16)); \ - _a->words.w1 = _SHIFTL(i, 16, 16) | _SHIFTL(o, 0, 16); \ -} - -/* - * See aEnvMixer for more info. - */ -#define aEnvSetup1(pkt, initialVolReverb, rampReverb, rampLeft, rampRight) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_ENVSETUP1, 24, 8) | \ - _SHIFTL(initialVolReverb, 16, 8) | \ - _SHIFTL(rampReverb, 0, 16)); \ - _a->words.w1 = _SHIFTL(rampLeft, 16, 16) | \ - _SHIFTL(rampRight, 0, 16); \ -} - -/* - * See aEnvMixer for more info. - */ -#define aEnvSetup2(pkt, initialVolLeft, initialVolRight) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_ENVSETUP2, 24, 8); \ - _a->words.w1 = _SHIFTL(initialVolLeft, 16, 16) | \ - _SHIFTL(initialVolRight, 0, 16); \ -} - -/* - * Mixes an envelope with mono sound into 4 channels. - * - * To allow for many parameters, a sequence of aEnvSetup1, aEnvSetup2, - * aEnvMixer shall always be called. - * - * The function works in blocks of 8 samples. - * However, nSamples is rounded up to the nearest multiple of 16 samples. - * - * For each sample in a block: - * 1. sampleLeft = in * volLeft * (negLeft ? -1 : 1) - * 2. sampleRight = in * volRight * (negRight ? -1 : 1) - * 3. dryLeft += sampleLeft - * 4. dryRight += sampleRight - * 5. if swapReverb: swap sampleLeft and sampleRight - * 6. wetLeft += sampleLeft * volReverb - * 7. wetRight += sampleRight * volReverb - * - * After each block, all vol variables are added by their corresponding - * ramp value. - * - * Each volume variable is treated as a UQ0.16 number. Make sure - * the ramp additions don't overflow, or wrapping will occur. - * The initialVolReverb parameter is only 8 bits, but will be left - * shifted 8 bits by the rsp. - */ -#define aEnvMixer(pkt, inBuf, nSamples, swapReverb, negLeft, negRight, \ - dryLeft, dryRight, wetLeft, wetRight) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_ENVMIXER, 24, 8) | \ - _SHIFTL((inBuf) >> 4, 16, 8) | \ - _SHIFTL(nSamples, 8, 8)) | \ - _SHIFTL(swapReverb, 2, 1) | _SHIFTL(negLeft, 1, 1) |\ - _SHIFTL(negRight, 0, 1); \ - _a->words.w1 = _SHIFTL((dryLeft) >> 4, 24, 8) | \ - _SHIFTL((dryRight) >> 4, 16, 8) | \ - _SHIFTL((wetLeft) >> 4, 8, 8) | \ - _SHIFTL((wetRight) >> 4, 0, 8); \ -} - -/* - * Interleaves two mono channels into stereo. - * - * The count refers to the size of each input. Hence 2 * count bytes - * will be written out. - * - * A left sample will be placed before the right sample. - * All addresses (output, left, right) are DMEM addresses. - * - * Note: count will be rounded up to the nearest multiple of 8 bytes. - * The previous version of this function rounded up to the nearest - * multiple of 16 bytes. - */ -/* -#define aInterleave(pkt, o, l, r, c) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_INTERLEAVE, 24, 8) | \ - _SHIFTL((c) >> 4, 16, 8) | _SHIFTL(o, 0, 16); \ - _a->words.w1 = _SHIFTL(l, 16, 16) | _SHIFTL(r, 0, 16); \ -} -*/ - -/* - * Linear filter function. - * - * Calculates out[i] = sum all elements in the vector in[i..i-7] * filter[0..7], - * where "*" represents dot multiplication. The input/output contains s16 - * samples and filter contains Q1.15 signed fixed point numbers. - * Every result sample is rounded and clamped. - * - * First initiate by calling with the flag f set to 2, countOrBuf contains - * the length in bytes that shall be processed in the next call. The addr - * parameter shall contain the DRAM address to the filter table (16 bytes). - * The count will be rounded up to the nearest multiple of 16 bytes. - * - * The aFilter function shall then be called in direct succession, with flag - * set to either 0 or 1. The countOrBuf parameter shall contain the DMEM - * address for the input/output. The addr parameter shall contain the DRAM - * address for the state, containing the last previous 8 input samples. - * The state is always written to upon exit, but is only read at entry if - * the flag is 0 (otherwise all-zero samples are used instead). - */ -#define aFilter(pkt, f, countOrBuf, addr) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_FILTER, 24, 8) | _SHIFTL((f), 16, 8) | \ - _SHIFTL((countOrBuf), 0, 16); \ - _a->words.w1 = (uintptr_t)(addr); \ -} - -/* - * Modifies the volume of samples using a simple UQ4.4 gain multiplier. - * - * Performs the following: - * - * 1. Count c is rounded up to 32 byte alignment - * 2. g is a u8 that contains a UQ4.4 number - * 3. Modify each sample s, so that s = clamp_s16(s * g >> 4) - */ -#define aHiLoGain(pkt, g, buflen, i) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_HILOGAIN, 24, 8) | \ - _SHIFTL((g), 16, 8) | _SHIFTL((buflen), 0, 16); \ - _a->words.w1 = _SHIFTL((i), 16, 16); \ -} - -/* - * Performs the following: - * - * 1. Count c is rounded up to 64 byte alignment - * 2. f is added to i - * 3. i and o are from now treated as s16 pointers - * 4. 32 s16 samples are loaded from i to tbl - * 5. for (u32 idx = 0; idx * sizeof(s16) < c; idx++) - * o[idx] = clamp_s16((s32)o[idx] * (s32)tbl[idx % 32]); - */ -#define aUnknown25(pkt, f, c, o, i) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_UNK_25, 24, 8) | \ - _SHIFTL((f), 16, 8) | _SHIFTL((c), 0, 16)); \ - _a->words.w1 = _SHIFTL((o), 16, 16) | _SHIFTL((i), 0, 16); \ -} - -#endif - -#endif /* _LANGUAGE_C */ - -#endif /* !_ABI_H_ */ diff --git a/include/PR/gbi.h b/include/PR/gbi.h deleted file mode 100644 index a1b8eb0c0..000000000 --- a/include/PR/gbi.h +++ /dev/null @@ -1,4750 +0,0 @@ -/************************************************************************** - * * - * Copyright (C) 1994, Silicon Graphics, Inc. * - * * - * These coded instructions, statements, and computer programs contain * - * unpublished proprietary information of Silicon Graphics, Inc., and * - * are protected by Federal copyright law. They may not be disclosed * - * to third parties or copied or duplicated in any form, in whole or * - * in part, without the prior written consent of Silicon Graphics, Inc. * - * * - **************************************************************************/ -/************************************************************************** - * - * $Revision: 1.141 $ - * $Date: 1999/09/03 03:43:08 $ - * $Source: /exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/gbi.h,v $ - * - **************************************************************************/ - -#ifndef _GBI_H_ -#define _GBI_H_ - -#include - -/* - * To use the F3DEX ucodes, define F3DEX_GBI before include this file. - * - * #define F3DEX_GBI - * #include - * - * or - * - * cc -c -DF3DEX_GBI -I.... foo.c - * - */ - -/************************************************************************** - * - * Graphics Binary Interface - * - **************************************************************************/ - -/* - * Graphics Commands, 'xxx' parts may be generated from ucode - * - * The command format is - * - * |00xxxxxx| = DMA 0,..,127 - * |10xxxxxx| = Immediate Mode -65,..,-128 - * |11xxxxxx| = RDP cmds -1,..,-64 - * - * Note: in order for the RSP microcode to process RDP commands opaquely, - * we need to further identify those RDP commands that need DRAM address - * "fixup". To do this, we have the dummy command G_RDP_ADDR_FIXUP, and - * all |RDP commands| less than this are commands with embedded DRAM - * addresses. Further, the format of these commands should be similar so - * only one fixup routine is needed. - * - * Further explanation: - * The names of the commands are somewhat misleading. Here is clarification: - * - * - a 'DMA' type command has a pointer to additional data and - * causes a DMA transfer to bring that into DMEM. - * - * - an 'Immediate' type command isn't really 'immediate', in the - * traditional sense. This just means that the entire command fits - * in the 64-bit word, and the ucode can execute it 'immediately' - * without additional memory transfers. - * - * - an 'RDP' command is identified as such because the RDP - * commands can be passed-thru the RSP and sent to the RDP - * directly. One further confusing thing, is that some 'DP' - * macros below actually generate immediate commands, not - * not direct DP commands. - * - * IMPLEMENTATION NOTE: - * There is another group of RDP commands that includes the triangle commands - * generated by the RSP code. These are the raw commands the rasterizer - * hardware chews on, with slope info, etc. They will follow the RDP - * ordering... - * - * IMPLEMENTATION NOTE: - * The RDP hardware has some of these bit patterns wired up. If the hardware - * changes, we must adjust this table, likewise we can't change/add things - * once the hardware is frozen. (actually, the RDP hardware only looks at - * the lower 6 bits of the command byte) - * - */ - -#ifdef F3DEX_GBI_2 -# ifndef F3DEX_GBI -# define F3DEX_GBI -# endif -#define G_NOOP 0x00 -#define G_RDPHALF_2 0xf1 -#define G_SETOTHERMODE_H 0xe3 -#define G_SETOTHERMODE_L 0xe2 -#define G_RDPHALF_1 0xe1 -#define G_SPNOOP 0xe0 -#define G_ENDDL 0xdf -#define G_DL 0xde -#define G_LOAD_UCODE 0xdd -#define G_MOVEMEM 0xdc -#define G_MOVEWORD 0xdb -#define G_MTX 0xda -#define G_GEOMETRYMODE 0xd9 -#define G_POPMTX 0xd8 -#define G_TEXTURE 0xd7 -#define G_DMA_IO 0xd6 -#define G_SPECIAL_1 0xd5 -#define G_SPECIAL_2 0xd4 -#define G_SPECIAL_3 0xd3 - -#define G_VTX 0x01 -#define G_MODIFYVTX 0x02 -#define G_CULLDL 0x03 -#define G_BRANCH_Z 0x04 -#define G_TRI1 0x05 -#define G_TRI2 0x06 -#define G_QUAD 0x07 -#define G_LINE3D 0x08 -#else /* F3DEX_GBI_2 */ - -/* DMA commands: */ -#define G_SPNOOP 0 /* handle 0 gracefully */ -#define G_MTX 1 -#define G_RESERVED0 2 /* not implemeted */ -#define G_MOVEMEM 3 /* move a block of memory (up to 4 words) to dmem */ -#define G_VTX 4 -#define G_RESERVED1 5 /* not implemeted */ -#define G_DL 6 -#define G_RESERVED2 7 /* not implemeted */ -#define G_RESERVED3 8 /* not implemeted */ -#define G_SPRITE2D_BASE 9 /* sprite command */ - -/* IMMEDIATE commands: */ -#define G_IMMFIRST -65 -#define G_TRI1 (G_IMMFIRST-0) -#define G_CULLDL (G_IMMFIRST-1) -#define G_POPMTX (G_IMMFIRST-2) -#define G_MOVEWORD (G_IMMFIRST-3) -#define G_TEXTURE (G_IMMFIRST-4) -#define G_SETOTHERMODE_H (G_IMMFIRST-5) -#define G_SETOTHERMODE_L (G_IMMFIRST-6) -#define G_ENDDL (G_IMMFIRST-7) -#define G_SETGEOMETRYMODE (G_IMMFIRST-8) -#define G_CLEARGEOMETRYMODE (G_IMMFIRST-9) -#define G_LINE3D (G_IMMFIRST-10) -#define G_RDPHALF_1 (G_IMMFIRST-11) -#define G_RDPHALF_2 (G_IMMFIRST-12) -#define G_RDPHALF_CONT (G_IMMFIRST-13) // From F3D_OLD used to render lap & timer UI. -#if (defined(F3DEX_GBI)||defined(F3DLP_GBI)) -#ifndef F3D_OLD -# define G_MODIFYVTX (G_IMMFIRST-13) // older versions of f3dex still used G_RDPHALF_CONT -#endif -# define G_TRI2 (G_IMMFIRST-14) -# define G_BRANCH_Z (G_IMMFIRST-15) -# define G_LOAD_UCODE (G_IMMFIRST-16) -# define G_QUAD (G_IMMFIRST-10) -#endif - -/* We are overloading 2 of the immediate commands - to keep the byte alignment of dmem the same */ - -#define G_SPRITE2D_SCALEFLIP (G_IMMFIRST-1) -#define G_SPRITE2D_DRAW (G_IMMFIRST-2) - -/* RDP commands: */ -#define G_NOOP 0xc0 /* 0 */ - -#endif /* F3DEX_GBI_2 */ - -/* RDP commands: */ -#define G_SETCIMG 0xff /* -1 */ -#define G_SETZIMG 0xfe /* -2 */ -#define G_SETTIMG 0xfd /* -3 */ -#define G_SETCOMBINE 0xfc /* -4 */ -#define G_SETENVCOLOR 0xfb /* -5 */ -#define G_SETPRIMCOLOR 0xfa /* -6 */ -#define G_SETBLENDCOLOR 0xf9 /* -7 */ -#define G_SETFOGCOLOR 0xf8 /* -8 */ -#define G_SETFILLCOLOR 0xf7 /* -9 */ -#define G_FILLRECT 0xf6 /* -10 */ -#define G_SETTILE 0xf5 /* -11 */ -#define G_LOADTILE 0xf4 /* -12 */ -#define G_LOADBLOCK 0xf3 /* -13 */ -#define G_SETTILESIZE 0xf2 /* -14 */ -#define G_LOADTLUT 0xf0 /* -16 */ -#define G_RDPSETOTHERMODE 0xef /* -17 */ -#define G_SETPRIMDEPTH 0xee /* -18 */ -#define G_SETSCISSOR 0xed /* -19 */ -#define G_SETCONVERT 0xec /* -20 */ -#define G_SETKEYR 0xeb /* -21 */ -#define G_SETKEYGB 0xea /* -22 */ -#define G_RDPFULLSYNC 0xe9 /* -23 */ -#define G_RDPTILESYNC 0xe8 /* -24 */ -#define G_RDPPIPESYNC 0xe7 /* -25 */ -#define G_RDPLOADSYNC 0xe6 /* -26 */ -#define G_TEXRECTFLIP 0xe5 /* -27 */ -#define G_TEXRECT 0xe4 /* -28 */ - - -/* - * The following commands are the "generated" RDP commands; the user - * never sees them, the RSP microcode generates them. - * - * The layout of the bits is magical, to save work in the ucode. - * These id's are -56, -52, -54, -50, -55, -51, -53, -49, ... - * edge, shade, texture, zbuff bits: estz - */ -#define G_TRI_FILL 0xc8 /* fill triangle: 11001000 */ -#define G_TRI_SHADE 0xcc /* shade triangle: 11001100 */ -#define G_TRI_TXTR 0xca /* texture triangle: 11001010 */ -#define G_TRI_SHADE_TXTR 0xce /* shade, texture triangle: 11001110 */ -#define G_TRI_FILL_ZBUFF 0xc9 /* fill, zbuff triangle: 11001001 */ -#define G_TRI_SHADE_ZBUFF 0xcd /* shade, zbuff triangle: 11001101 */ -#define G_TRI_TXTR_ZBUFF 0xcb /* texture, zbuff triangle: 11001011 */ -#define G_TRI_SHADE_TXTR_ZBUFF 0xcf /* shade, txtr, zbuff trngl: 11001111 */ - -/* - * A TRI_FILL triangle is just the edges. You need to set the DP - * to use primcolor, in order to see anything. (it is NOT a triangle - * that gets rendered in 'fill mode'. Triangles can't be rendered - * in 'fill mode') - * - * A TRI_SHADE is a gouraud triangle that has colors interpolated. - * Flat-shaded triangles (from the software) are still gouraud shaded, - * it's just the colors are all the same and the deltas are 0. - * - * Other triangle types, and combinations are more obvious. - */ - -/* masks to build RDP triangle commands: */ -#define G_RDP_TRI_FILL_MASK 0x08 -#define G_RDP_TRI_SHADE_MASK 0x04 -#define G_RDP_TRI_TXTR_MASK 0x02 -#define G_RDP_TRI_ZBUFF_MASK 0x01 - -/* - * HACK: - * This is a dreadful hack. For version 1.0 hardware, there are still - * some 'bowtie' hangs. This parameter can be increased to avoid - * the hangs. Every increase of 4 chops one scanline off of every - * triangle. Values of 4,8,12 should be sufficient to avoid any - * bowtie hang. - * - * Change this value, then recompile ALL of your program (including static - * display lists!) - * - * THIS WILL BE REMOVED FOR HARDWARE VERSION 2.0! - */ -#define BOWTIE_VAL 0 - - -/* gets added to RDP command, in order to test for addres fixup: */ -#define G_RDP_ADDR_FIXUP 3 /* |RDP cmds| <= this, do addr fixup */ -#ifdef _LANGUAGE_ASSEMBLY -#define G_RDP_TEXRECT_CHECK ((-1*G_TEXRECTFLIP)& 0xff) -#endif - -/* macros for command parsing: */ -#define GDMACMD(x) (x) -#define GIMMCMD(x) (G_IMMFIRST-(x)) -#define GRDPCMD(x) (0xff-(x)) - -#define G_DMACMDSIZ 128 -#define G_IMMCMDSIZ 64 -#define G_RDPCMDSIZ 64 - -/* - * Coordinate shift values, number of bits of fraction - */ -#define G_TEXTURE_IMAGE_FRAC 2 -#define G_TEXTURE_SCALE_FRAC 16 -#define G_SCALE_FRAC 8 -#define G_ROTATE_FRAC 16 - -/* - * Parameters to graphics commands - */ - -/* - * Data packing macros - */ - -/* - * Maximum z-buffer value, used to initialize the z-buffer. - * Note : this number is NOT the viewport z-scale constant. - * See the comment next to G_MAXZ for more info. - */ -#define G_MAXFBZ 0x3fff /* 3b exp, 11b mantissa */ - -#define GPACK_RGBA5551(r, g, b, a) ((((r)<<8) & 0xf800) | \ - (((g)<<3) & 0x7c0) | \ - (((b)>>2) & 0x3e) | ((a) & 0x1)) -#define GPACK_ZDZ(z, dz) ((z) << 2 | (dz)) - -/* - * G_MTX: parameter flags - */ -#ifdef F3DEX_GBI_2 -# define G_MTX_MODELVIEW 0x00 /* matrix types */ -# define G_MTX_PROJECTION 0x04 -# define G_MTX_MUL 0x00 /* concat or load */ -# define G_MTX_LOAD 0x02 -# define G_MTX_NOPUSH 0x00 /* push or not */ -# define G_MTX_PUSH 0x01 -#else /* F3DEX_GBI_2 */ -# define G_MTX_MODELVIEW 0x00 /* matrix types */ -# define G_MTX_PROJECTION 0x01 -# define G_MTX_MUL 0x00 /* concat or load */ -# define G_MTX_LOAD 0x02 -# define G_MTX_NOPUSH 0x00 /* push or not */ -# define G_MTX_PUSH 0x04 -#endif /* F3DEX_GBI_2 */ - -/* - * flags for G_SETGEOMETRYMODE - * (this rendering state is maintained in RSP) - * - * DO NOT USE THE LOW 8 BITS OF GEOMETRYMODE: - * The weird bit-ordering is for the micro-code: the lower byte - * can be OR'd in with G_TRI_SHADE (11001100) to construct - * the triangle command directly. Don't break it... - * - * DO NOT USE THE HIGH 8 BITS OF GEOMETRYMODE: - * The high byte is OR'd with 0x703 to form the clip code mask. - * If it is set to 0x04, this will cause near clipping to occur. - * If it is zero, near clipping will not occur. - * - * Further explanation: - * G_SHADE is necessary in order to see the color that you passed - * down with the vertex. If G_SHADE isn't set, you need to set the DP - * appropriately and use primcolor to see anything. - * - * G_SHADING_SMOOTH enabled means use all 3 colors of the triangle. - * If it is not set, then do 'flat shading', where only one vertex color - * is used (and all 3 vertices are set to that same color by the ucode) - * See the man page for gSP1Triangle(). - * - */ -#define G_ZBUFFER 0x00000001 -#define G_SHADE 0x00000004 /* enable Gouraud interp */ -/* rest of low byte reserved for setup ucode */ -#ifdef F3DEX_GBI_2 -# define G_TEXTURE_ENABLE 0x00000000 /* Ignored */ -# define G_SHADING_SMOOTH 0x00200000 /* flat or smooth shaded */ -# define G_CULL_FRONT 0x00000200 -# define G_CULL_BACK 0x00000400 -# define G_CULL_BOTH 0x00000600 /* To make code cleaner */ -#else -# define G_TEXTURE_ENABLE 0x00000002 /* Microcode use only */ -# define G_SHADING_SMOOTH 0x00000200 /* flat or smooth shaded */ -# define G_CULL_FRONT 0x00001000 -# define G_CULL_BACK 0x00002000 -# define G_CULL_BOTH 0x00003000 /* To make code cleaner */ -#endif -#define G_FOG 0x00010000 -#define G_LIGHTING 0x00020000 -#define G_TEXTURE_GEN 0x00040000 -#define G_TEXTURE_GEN_LINEAR 0x00080000 -#define G_LOD 0x00100000 /* NOT IMPLEMENTED */ -#if (defined(F3DEX_GBI)||defined(F3DLP_GBI)) -# define G_CLIPPING 0x00800000 -#else -# define G_CLIPPING 0x00000000 -#endif - -#ifdef _LANGUAGE_ASSEMBLY -#define G_FOG_H (G_FOG/0x10000) -#define G_LIGHTING_H (G_LIGHTING/0x10000) -#define G_TEXTURE_GEN_H (G_TEXTURE_GEN/0x10000) -#define G_TEXTURE_GEN_LINEAR_H (G_TEXTURE_GEN_LINEAR/0x10000) -#define G_LOD_H (G_LOD/0x10000) /* NOT IMPLEMENTED */ -#if (defined(F3DEX_GBI)||defined(F3DLP_GBI)) -# define G_CLIPPING_H (G_CLIPPING/0x10000) -#endif -#endif - -/* Need these defined for Sprite Microcode */ -#ifdef _LANGUAGE_ASSEMBLY -#define G_TX_LOADTILE 7 -#define G_TX_RENDERTILE 0 - -#define G_TX_NOMIRROR 0 -#define G_TX_WRAP 0 -#define G_TX_MIRROR 0x1 -#define G_TX_CLAMP 0x2 -#define G_TX_NOMASK 0 -#define G_TX_NOLOD 0 -#endif - -/* - * G_SETIMG fmt: set image formats - */ -#define G_IM_FMT_RGBA 0 -#define G_IM_FMT_YUV 1 -#define G_IM_FMT_CI 2 -#define G_IM_FMT_IA 3 -#define G_IM_FMT_I 4 - -/* - * G_SETIMG siz: set image pixel size - */ -#define G_IM_SIZ_4b 0 -#define G_IM_SIZ_8b 1 -#define G_IM_SIZ_16b 2 -#define G_IM_SIZ_32b 3 -#define G_IM_SIZ_DD 5 - -#define G_IM_SIZ_4b_BYTES 0 -#define G_IM_SIZ_4b_TILE_BYTES G_IM_SIZ_4b_BYTES -#define G_IM_SIZ_4b_LINE_BYTES G_IM_SIZ_4b_BYTES - -#define G_IM_SIZ_8b_BYTES 1 -#define G_IM_SIZ_8b_TILE_BYTES G_IM_SIZ_8b_BYTES -#define G_IM_SIZ_8b_LINE_BYTES G_IM_SIZ_8b_BYTES - -#define G_IM_SIZ_16b_BYTES 2 -#define G_IM_SIZ_16b_TILE_BYTES G_IM_SIZ_16b_BYTES -#define G_IM_SIZ_16b_LINE_BYTES G_IM_SIZ_16b_BYTES - -#define G_IM_SIZ_32b_BYTES 4 -#define G_IM_SIZ_32b_TILE_BYTES 2 -#define G_IM_SIZ_32b_LINE_BYTES 2 - -#define G_IM_SIZ_4b_LOAD_BLOCK G_IM_SIZ_16b -#define G_IM_SIZ_8b_LOAD_BLOCK G_IM_SIZ_16b -#define G_IM_SIZ_16b_LOAD_BLOCK G_IM_SIZ_16b -#define G_IM_SIZ_32b_LOAD_BLOCK G_IM_SIZ_32b - -#define G_IM_SIZ_4b_SHIFT 2 -#define G_IM_SIZ_8b_SHIFT 1 -#define G_IM_SIZ_16b_SHIFT 0 -#define G_IM_SIZ_32b_SHIFT 0 - -#define G_IM_SIZ_4b_INCR 3 -#define G_IM_SIZ_8b_INCR 1 -#define G_IM_SIZ_16b_INCR 0 -#define G_IM_SIZ_32b_INCR 0 - -/* - * G_SETCOMBINE: color combine modes - */ -/* Color combiner constants: */ -#define G_CCMUX_COMBINED 0 -#define G_CCMUX_TEXEL0 1 -#define G_CCMUX_TEXEL1 2 -#define G_CCMUX_PRIMITIVE 3 -#define G_CCMUX_SHADE 4 -#define G_CCMUX_ENVIRONMENT 5 -#define G_CCMUX_CENTER 6 -#define G_CCMUX_SCALE 6 -#define G_CCMUX_COMBINED_ALPHA 7 -#define G_CCMUX_TEXEL0_ALPHA 8 -#define G_CCMUX_TEXEL1_ALPHA 9 -#define G_CCMUX_PRIMITIVE_ALPHA 10 -#define G_CCMUX_SHADE_ALPHA 11 -#define G_CCMUX_ENV_ALPHA 12 -#define G_CCMUX_LOD_FRACTION 13 -#define G_CCMUX_PRIM_LOD_FRAC 14 -#define G_CCMUX_NOISE 7 -#define G_CCMUX_K4 7 -#define G_CCMUX_K5 15 -#define G_CCMUX_1 6 -#define G_CCMUX_0 31 - -/* Alpha combiner constants: */ -#define G_ACMUX_COMBINED 0 -#define G_ACMUX_TEXEL0 1 -#define G_ACMUX_TEXEL1 2 -#define G_ACMUX_PRIMITIVE 3 -#define G_ACMUX_SHADE 4 -#define G_ACMUX_ENVIRONMENT 5 -#define G_ACMUX_LOD_FRACTION 0 -#define G_ACMUX_PRIM_LOD_FRAC 6 -#define G_ACMUX_1 6 -#define G_ACMUX_0 7 - -/* typical CC cycle 1 modes */ -#define G_CC_PRIMITIVE 0, 0, 0, PRIMITIVE, 0, 0, 0, PRIMITIVE -#define G_CC_SHADE 0, 0, 0, SHADE, 0, 0, 0, SHADE - -#define G_CC_MODULATEI TEXEL0, 0, SHADE, 0, 0, 0, 0, SHADE -#define G_CC_MODULATEIDECALA TEXEL0, 0, SHADE, 0, 0, 0, 0, TEXEL0 -#define G_CC_MODULATEIFADE TEXEL0, 0, SHADE, 0, 0, 0, 0, ENVIRONMENT - -#define G_CC_MODULATERGB G_CC_MODULATEI -#define G_CC_MODULATERGBDECALA G_CC_MODULATEIDECALA -#define G_CC_MODULATERGBFADE G_CC_MODULATEIFADE - -#define G_CC_MODULATEIA TEXEL0, 0, SHADE, 0, TEXEL0, 0, SHADE, 0 -#define G_CC_MODULATEIFADEA TEXEL0, 0, SHADE, 0, TEXEL0, 0, ENVIRONMENT, 0 - -#define G_CC_MODULATEFADE TEXEL0, 0, SHADE, 0, ENVIRONMENT, 0, TEXEL0, 0 - -#define G_CC_MODULATERGBA G_CC_MODULATEIA -#define G_CC_MODULATERGBFADEA G_CC_MODULATEIFADEA - -#define G_CC_MODULATEI_PRIM TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE -#define G_CC_MODULATEIA_PRIM TEXEL0, 0, PRIMITIVE, 0, TEXEL0, 0, PRIMITIVE, 0 -#define G_CC_MODULATEIDECALA_PRIM TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, TEXEL0 - -#define G_CC_MODULATERGB_PRIM G_CC_MODULATEI_PRIM -#define G_CC_MODULATERGBA_PRIM G_CC_MODULATEIA_PRIM -#define G_CC_MODULATERGBDECALA_PRIM G_CC_MODULATEIDECALA_PRIM - -#define G_CC_FADE SHADE, 0, ENVIRONMENT, 0, SHADE, 0, ENVIRONMENT, 0 -#define G_CC_FADEA TEXEL0, 0, ENVIRONMENT, 0, TEXEL0, 0, ENVIRONMENT, 0 - -#define G_CC_DECALRGB 0, 0, 0, TEXEL0, 0, 0, 0, SHADE -#define G_CC_DECALRGBA 0, 0, 0, TEXEL0, 0, 0, 0, TEXEL0 -#define G_CC_DECALFADE 0, 0, 0, TEXEL0, 0, 0, 0, ENVIRONMENT - -#define G_CC_DECALFADEA 0, 0, 0, TEXEL0, TEXEL0, 0, ENVIRONMENT, 0 - -#define G_CC_BLENDI ENVIRONMENT, SHADE, TEXEL0, SHADE, 0, 0, 0, SHADE -#define G_CC_BLENDIA ENVIRONMENT, SHADE, TEXEL0, SHADE, TEXEL0, 0, SHADE, 0 -#define G_CC_BLENDIDECALA ENVIRONMENT, SHADE, TEXEL0, SHADE, 0, 0, 0, TEXEL0 - -#define G_CC_BLENDRGBA TEXEL0, SHADE, TEXEL0_ALPHA, SHADE, 0, 0, 0, SHADE -#define G_CC_BLENDRGBDECALA TEXEL0, SHADE, TEXEL0_ALPHA, SHADE, 0, 0, 0, TEXEL0 -#define G_CC_BLENDRGBFADEA TEXEL0, SHADE, TEXEL0_ALPHA, SHADE, 0, 0, 0, ENVIRONMENT - -#define G_CC_ADDRGB TEXEL0, 0, TEXEL0, SHADE, 0, 0, 0, SHADE -#define G_CC_ADDRGBDECALA TEXEL0, 0, TEXEL0, SHADE, 0, 0, 0, TEXEL0 -#define G_CC_ADDRGBFADE TEXEL0, 0, TEXEL0, SHADE, 0, 0, 0, ENVIRONMENT - -#define G_CC_REFLECTRGB ENVIRONMENT, 0, TEXEL0, SHADE, 0, 0, 0, SHADE -#define G_CC_REFLECTRGBDECALA ENVIRONMENT, 0, TEXEL0, SHADE, 0, 0, 0, TEXEL0 - -#define G_CC_HILITERGB PRIMITIVE, SHADE, TEXEL0, SHADE, 0, 0, 0, SHADE -#define G_CC_HILITERGBA PRIMITIVE, SHADE, TEXEL0, SHADE, PRIMITIVE, SHADE, TEXEL0, SHADE -#define G_CC_HILITERGBDECALA PRIMITIVE, SHADE, TEXEL0, SHADE, 0, 0, 0, TEXEL0 - -#define G_CC_SHADEDECALA 0, 0, 0, SHADE, 0, 0, 0, TEXEL0 -#define G_CC_SHADEFADEA 0, 0, 0, SHADE, 0, 0, 0, ENVIRONMENT - -#define G_CC_BLENDPE PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, SHADE, 0 -#define G_CC_BLENDPEDECALA PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, 0, 0, 0, TEXEL0 - -/* oddball modes */ -#define _G_CC_BLENDPE ENVIRONMENT, PRIMITIVE, TEXEL0, PRIMITIVE, TEXEL0, 0, SHADE, 0 -#define _G_CC_BLENDPEDECALA ENVIRONMENT, PRIMITIVE, TEXEL0, PRIMITIVE, 0, 0, 0, TEXEL0 -#define _G_CC_TWOCOLORTEX PRIMITIVE, SHADE, TEXEL0, SHADE, 0, 0, 0, SHADE -/* used for 1-cycle sparse mip-maps, primitive color has color of lowest LOD */ -#define _G_CC_SPARSEST PRIMITIVE, TEXEL0, LOD_FRACTION, TEXEL0, PRIMITIVE, TEXEL0, LOD_FRACTION, TEXEL0 -#define G_CC_TEMPLERP TEXEL1, TEXEL0, PRIM_LOD_FRAC, TEXEL0, TEXEL1, TEXEL0, PRIM_LOD_FRAC, TEXEL0 - -/* typical CC cycle 1 modes, usually followed by other cycle 2 modes */ -#define G_CC_TRILERP TEXEL1, TEXEL0, LOD_FRACTION, TEXEL0, TEXEL1, TEXEL0, LOD_FRACTION, TEXEL0 -#define G_CC_INTERFERENCE TEXEL0, 0, TEXEL1, 0, TEXEL0, 0, TEXEL1, 0 - -/* - * One-cycle color convert operation - */ -#define G_CC_1CYUV2RGB TEXEL0, K4, K5, TEXEL0, 0, 0, 0, SHADE - -/* - * NOTE: YUV2RGB expects TF step1 color conversion to occur in 2nd clock. - * Therefore, CC looks for step1 results in TEXEL1 - */ -#define G_CC_YUV2RGB TEXEL1, K4, K5, TEXEL1, 0, 0, 0, 0 - -/* typical CC cycle 2 modes */ -#define G_CC_PASS2 0, 0, 0, COMBINED, 0, 0, 0, COMBINED -#define G_CC_MODULATEI2 COMBINED, 0, SHADE, 0, 0, 0, 0, SHADE -#define G_CC_MODULATEIA2 COMBINED, 0, SHADE, 0, COMBINED, 0, SHADE, 0 -#define G_CC_MODULATERGB2 G_CC_MODULATEI2 -#define G_CC_MODULATERGBA2 G_CC_MODULATEIA2 -#define G_CC_MODULATEI_PRIM2 COMBINED, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE -#define G_CC_MODULATEIA_PRIM2 COMBINED, 0, PRIMITIVE, 0, COMBINED, 0, PRIMITIVE, 0 -#define G_CC_MODULATERGB_PRIM2 G_CC_MODULATEI_PRIM2 -#define G_CC_MODULATERGBA_PRIM2 G_CC_MODULATEIA_PRIM2 -#define G_CC_DECALRGB2 0, 0, 0, COMBINED, 0, 0, 0, SHADE -/* - * ? -#define G_CC_DECALRGBA2 COMBINED, SHADE, COMBINED_ALPHA, SHADE, 0, 0, 0, SHADE -*/ -#define G_CC_BLENDI2 ENVIRONMENT, SHADE, COMBINED, SHADE, 0, 0, 0, SHADE -#define G_CC_BLENDIA2 ENVIRONMENT, SHADE, COMBINED, SHADE, COMBINED, 0, SHADE, 0 -#define G_CC_CHROMA_KEY2 TEXEL0, CENTER, SCALE, 0, 0, 0, 0, 0 -#define G_CC_HILITERGB2 ENVIRONMENT, COMBINED, TEXEL0, COMBINED, 0, 0, 0, SHADE -#define G_CC_HILITERGBA2 ENVIRONMENT, COMBINED, TEXEL0, COMBINED, ENVIRONMENT, COMBINED, TEXEL0, COMBINED -#define G_CC_HILITERGBDECALA2 ENVIRONMENT, COMBINED, TEXEL0, COMBINED, 0, 0, 0, TEXEL0 -#define G_CC_HILITERGBPASSA2 ENVIRONMENT, COMBINED, TEXEL0, COMBINED, 0, 0, 0, COMBINED - -/* - * G_SETOTHERMODE_L sft: shift count - */ -#define G_MDSFT_ALPHACOMPARE 0 -#define G_MDSFT_ZSRCSEL 2 -#define G_MDSFT_RENDERMODE 3 -#define G_MDSFT_BLENDER 16 - -/* - * G_SETOTHERMODE_H sft: shift count - */ -#define G_MDSFT_BLENDMASK 0 /* unsupported */ -#define G_MDSFT_ALPHADITHER 4 -#define G_MDSFT_RGBDITHER 6 - -#define G_MDSFT_COMBKEY 8 -#define G_MDSFT_TEXTCONV 9 -#define G_MDSFT_TEXTFILT 12 -#define G_MDSFT_TEXTLUT 14 -#define G_MDSFT_TEXTLOD 16 -#define G_MDSFT_TEXTDETAIL 17 -#define G_MDSFT_TEXTPERSP 19 -#define G_MDSFT_CYCLETYPE 20 -#define G_MDSFT_COLORDITHER 22 /* unsupported in HW 2.0 */ -#define G_MDSFT_PIPELINE 23 - -/* G_SETOTHERMODE_H gPipelineMode */ -#define G_PM_1PRIMITIVE (1 << G_MDSFT_PIPELINE) -#define G_PM_NPRIMITIVE (0 << G_MDSFT_PIPELINE) - -/* G_SETOTHERMODE_H gSetCycleType */ -#define G_CYC_1CYCLE (0 << G_MDSFT_CYCLETYPE) -#define G_CYC_2CYCLE (1 << G_MDSFT_CYCLETYPE) -#define G_CYC_COPY (2 << G_MDSFT_CYCLETYPE) -#define G_CYC_FILL (3 << G_MDSFT_CYCLETYPE) - -/* G_SETOTHERMODE_H gSetTexturePersp */ -#define G_TP_NONE (0 << G_MDSFT_TEXTPERSP) -#define G_TP_PERSP (1 << G_MDSFT_TEXTPERSP) - -/* G_SETOTHERMODE_H gSetTextureDetail */ -#define G_TD_CLAMP (0 << G_MDSFT_TEXTDETAIL) -#define G_TD_SHARPEN (1 << G_MDSFT_TEXTDETAIL) -#define G_TD_DETAIL (2 << G_MDSFT_TEXTDETAIL) - -/* G_SETOTHERMODE_H gSetTextureLOD */ -#define G_TL_TILE (0 << G_MDSFT_TEXTLOD) -#define G_TL_LOD (1 << G_MDSFT_TEXTLOD) - -/* G_SETOTHERMODE_H gSetTextureLUT */ -#define G_TT_NONE (0 << G_MDSFT_TEXTLUT) -#define G_TT_RGBA16 (2 << G_MDSFT_TEXTLUT) -#define G_TT_IA16 (3 << G_MDSFT_TEXTLUT) - -/* G_SETOTHERMODE_H gSetTextureFilter */ -#define G_TF_POINT (0 << G_MDSFT_TEXTFILT) -#define G_TF_AVERAGE (3 << G_MDSFT_TEXTFILT) -#define G_TF_BILERP (2 << G_MDSFT_TEXTFILT) - -/* G_SETOTHERMODE_H gSetTextureConvert */ -#define G_TC_CONV (0 << G_MDSFT_TEXTCONV) -#define G_TC_FILTCONV (5 << G_MDSFT_TEXTCONV) -#define G_TC_FILT (6 << G_MDSFT_TEXTCONV) - -/* G_SETOTHERMODE_H gSetCombineKey */ -#define G_CK_NONE (0 << G_MDSFT_COMBKEY) -#define G_CK_KEY (1 << G_MDSFT_COMBKEY) - -/* G_SETOTHERMODE_H gSetColorDither */ -#define G_CD_MAGICSQ (0 << G_MDSFT_RGBDITHER) -#define G_CD_BAYER (1 << G_MDSFT_RGBDITHER) -#define G_CD_NOISE (2 << G_MDSFT_RGBDITHER) - -#ifndef _HW_VERSION_1 -#define G_CD_DISABLE (3 << G_MDSFT_RGBDITHER) -#define G_CD_ENABLE G_CD_NOISE /* HW 1.0 compatibility mode */ -#else -#define G_CD_ENABLE (1 << G_MDSFT_COLORDITHER) -#define G_CD_DISABLE (0 << G_MDSFT_COLORDITHER) -#endif - -/* G_SETOTHERMODE_H gSetAlphaDither */ -#define G_AD_PATTERN (0 << G_MDSFT_ALPHADITHER) -#define G_AD_NOTPATTERN (1 << G_MDSFT_ALPHADITHER) -#define G_AD_NOISE (2 << G_MDSFT_ALPHADITHER) -#define G_AD_DISABLE (3 << G_MDSFT_ALPHADITHER) - -/* G_SETOTHERMODE_L gSetAlphaCompare */ -#define G_AC_NONE (0 << G_MDSFT_ALPHACOMPARE) -#define G_AC_THRESHOLD (1 << G_MDSFT_ALPHACOMPARE) -#define G_AC_DITHER (3 << G_MDSFT_ALPHACOMPARE) - -/* G_SETOTHERMODE_L gSetDepthSource */ -#define G_ZS_PIXEL (0 << G_MDSFT_ZSRCSEL) -#define G_ZS_PRIM (1 << G_MDSFT_ZSRCSEL) - -/* G_SETOTHERMODE_L gSetRenderMode */ -#define AA_EN 0x8 -#define Z_CMP 0x10 -#define Z_UPD 0x20 -#define IM_RD 0x40 -#define CLR_ON_CVG 0x80 -#define CVG_DST_CLAMP 0 -#define CVG_DST_WRAP 0x100 -#define CVG_DST_FULL 0x200 -#define CVG_DST_SAVE 0x300 -#define ZMODE_OPA 0 -#define ZMODE_INTER 0x400 -#define ZMODE_XLU 0x800 -#define ZMODE_DEC 0xc00 -#define CVG_X_ALPHA 0x1000 -#define ALPHA_CVG_SEL 0x2000 -#define FORCE_BL 0x4000 -#define TEX_EDGE 0x0000 /* used to be 0x8000 */ - -#define G_BL_CLR_IN 0 -#define G_BL_CLR_MEM 1 -#define G_BL_CLR_BL 2 -#define G_BL_CLR_FOG 3 -#define G_BL_1MA 0 -#define G_BL_A_MEM 1 -#define G_BL_A_IN 0 -#define G_BL_A_FOG 1 -#define G_BL_A_SHADE 2 -#define G_BL_1 2 -#define G_BL_0 3 - -#define GBL_c1(m1a, m1b, m2a, m2b) \ - (m1a) << 30 | (m1b) << 26 | (m2a) << 22 | (m2b) << 18 -#define GBL_c2(m1a, m1b, m2a, m2b) \ - (m1a) << 28 | (m1b) << 24 | (m2a) << 20 | (m2b) << 16 - -#define RM_AA_ZB_OPA_SURF(clk) \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | \ - ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_RA_ZB_OPA_SURF(clk) \ - AA_EN | Z_CMP | Z_UPD | CVG_DST_CLAMP | \ - ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_AA_ZB_XLU_SURF(clk) \ - AA_EN | Z_CMP | IM_RD | CVG_DST_WRAP | CLR_ON_CVG | \ - FORCE_BL | ZMODE_XLU | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_ZB_OPA_DECAL(clk) \ - AA_EN | Z_CMP | IM_RD | CVG_DST_WRAP | ALPHA_CVG_SEL | \ - ZMODE_DEC | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_RA_ZB_OPA_DECAL(clk) \ - AA_EN | Z_CMP | CVG_DST_WRAP | ALPHA_CVG_SEL | \ - ZMODE_DEC | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_AA_ZB_XLU_DECAL(clk) \ - AA_EN | Z_CMP | IM_RD | CVG_DST_WRAP | CLR_ON_CVG | \ - FORCE_BL | ZMODE_DEC | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_ZB_OPA_INTER(clk) \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | \ - ALPHA_CVG_SEL | ZMODE_INTER | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_RA_ZB_OPA_INTER(clk) \ - AA_EN | Z_CMP | Z_UPD | CVG_DST_CLAMP | \ - ALPHA_CVG_SEL | ZMODE_INTER | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_AA_ZB_XLU_INTER(clk) \ - AA_EN | Z_CMP | IM_RD | CVG_DST_WRAP | CLR_ON_CVG | \ - FORCE_BL | ZMODE_INTER | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_ZB_XLU_LINE(clk) \ - AA_EN | Z_CMP | IM_RD | CVG_DST_CLAMP | CVG_X_ALPHA | \ - ALPHA_CVG_SEL | FORCE_BL | ZMODE_XLU | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_ZB_DEC_LINE(clk) \ - AA_EN | Z_CMP | IM_RD | CVG_DST_SAVE | CVG_X_ALPHA | \ - ALPHA_CVG_SEL | FORCE_BL | ZMODE_DEC | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_ZB_TEX_EDGE(clk) \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | \ - CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_OPA | TEX_EDGE | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_AA_ZB_TEX_INTER(clk) \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | \ - CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_INTER | TEX_EDGE | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_AA_ZB_SUB_SURF(clk) \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_FULL | \ - ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_AA_ZB_PCL_SURF(clk) \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | \ - ZMODE_OPA | G_AC_DITHER | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_ZB_OPA_TERR(clk) \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | \ - ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_ZB_TEX_TERR(clk) \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | \ - CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_OPA | TEX_EDGE | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_ZB_SUB_TERR(clk) \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_FULL | \ - ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - - -#define RM_AA_OPA_SURF(clk) \ - AA_EN | IM_RD | CVG_DST_CLAMP | \ - ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_RA_OPA_SURF(clk) \ - AA_EN | CVG_DST_CLAMP | \ - ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_AA_XLU_SURF(clk) \ - AA_EN | IM_RD | CVG_DST_WRAP | CLR_ON_CVG | FORCE_BL | \ - ZMODE_OPA | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_XLU_LINE(clk) \ - AA_EN | IM_RD | CVG_DST_CLAMP | CVG_X_ALPHA | \ - ALPHA_CVG_SEL | FORCE_BL | ZMODE_OPA | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_DEC_LINE(clk) \ - AA_EN | IM_RD | CVG_DST_FULL | CVG_X_ALPHA | \ - ALPHA_CVG_SEL | FORCE_BL | ZMODE_OPA | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_TEX_EDGE(clk) \ - AA_EN | IM_RD | CVG_DST_CLAMP | \ - CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_OPA | TEX_EDGE | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_AA_SUB_SURF(clk) \ - AA_EN | IM_RD | CVG_DST_FULL | \ - ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_AA_PCL_SURF(clk) \ - AA_EN | IM_RD | CVG_DST_CLAMP | \ - ZMODE_OPA | G_AC_DITHER | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_OPA_TERR(clk) \ - AA_EN | IM_RD | CVG_DST_CLAMP | \ - ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_TEX_TERR(clk) \ - AA_EN | IM_RD | CVG_DST_CLAMP | \ - CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_OPA | TEX_EDGE | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_SUB_TERR(clk) \ - AA_EN | IM_RD | CVG_DST_FULL | \ - ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - - -#define RM_ZB_OPA_SURF(clk) \ - Z_CMP | Z_UPD | CVG_DST_FULL | ALPHA_CVG_SEL | \ - ZMODE_OPA | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_ZB_XLU_SURF(clk) \ - Z_CMP | IM_RD | CVG_DST_FULL | FORCE_BL | ZMODE_XLU | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_ZB_OPA_DECAL(clk) \ - Z_CMP | CVG_DST_FULL | ALPHA_CVG_SEL | ZMODE_DEC | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_ZB_XLU_DECAL(clk) \ - Z_CMP | IM_RD | CVG_DST_FULL | FORCE_BL | ZMODE_DEC | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_ZB_CLD_SURF(clk) \ - Z_CMP | IM_RD | CVG_DST_SAVE | FORCE_BL | ZMODE_XLU | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_ZB_OVL_SURF(clk) \ - Z_CMP | IM_RD | CVG_DST_SAVE | FORCE_BL | ZMODE_DEC | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_ZB_PCL_SURF(clk) \ - Z_CMP | Z_UPD | CVG_DST_FULL | ZMODE_OPA | \ - G_AC_DITHER | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) - - -#define RM_OPA_SURF(clk) \ - CVG_DST_CLAMP | FORCE_BL | ZMODE_OPA | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) - -#define RM_XLU_SURF(clk) \ - IM_RD | CVG_DST_FULL | FORCE_BL | ZMODE_OPA | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_TEX_EDGE(clk) \ - CVG_DST_CLAMP | CVG_X_ALPHA | ALPHA_CVG_SEL | FORCE_BL |\ - ZMODE_OPA | TEX_EDGE | AA_EN | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) - -#define RM_CLD_SURF(clk) \ - IM_RD | CVG_DST_SAVE | FORCE_BL | ZMODE_OPA | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_PCL_SURF(clk) \ - CVG_DST_FULL | FORCE_BL | ZMODE_OPA | \ - G_AC_DITHER | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) - -#define RM_ADD(clk) \ - IM_RD | CVG_DST_SAVE | FORCE_BL | ZMODE_OPA | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_FOG, G_BL_CLR_MEM, G_BL_1) - -#define RM_NOOP(clk) \ - GBL_c##clk(0, 0, 0, 0) - -#define RM_VISCVG(clk) \ - IM_RD | FORCE_BL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_0, G_BL_CLR_BL, G_BL_A_MEM) - -/* for rendering to an 8-bit framebuffer */ -#define RM_OPA_CI(clk) \ - CVG_DST_CLAMP | ZMODE_OPA | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) - -/* Custom version of RM_AA_ZB_XLU_SURF with Z_UPD */ -#define RM_CUSTOM_AA_ZB_XLU_SURF(clk) \ - RM_AA_ZB_XLU_SURF(clk) | Z_UPD - - -#define G_RM_AA_ZB_OPA_SURF RM_AA_ZB_OPA_SURF(1) -#define G_RM_AA_ZB_OPA_SURF2 RM_AA_ZB_OPA_SURF(2) -#define G_RM_AA_ZB_XLU_SURF RM_AA_ZB_XLU_SURF(1) -#define G_RM_AA_ZB_XLU_SURF2 RM_AA_ZB_XLU_SURF(2) -#define G_RM_AA_ZB_OPA_DECAL RM_AA_ZB_OPA_DECAL(1) -#define G_RM_AA_ZB_OPA_DECAL2 RM_AA_ZB_OPA_DECAL(2) -#define G_RM_AA_ZB_XLU_DECAL RM_AA_ZB_XLU_DECAL(1) -#define G_RM_AA_ZB_XLU_DECAL2 RM_AA_ZB_XLU_DECAL(2) -#define G_RM_AA_ZB_OPA_INTER RM_AA_ZB_OPA_INTER(1) -#define G_RM_AA_ZB_OPA_INTER2 RM_AA_ZB_OPA_INTER(2) -#define G_RM_AA_ZB_XLU_INTER RM_AA_ZB_XLU_INTER(1) -#define G_RM_AA_ZB_XLU_INTER2 RM_AA_ZB_XLU_INTER(2) -#define G_RM_AA_ZB_XLU_LINE RM_AA_ZB_XLU_LINE(1) -#define G_RM_AA_ZB_XLU_LINE2 RM_AA_ZB_XLU_LINE(2) -#define G_RM_AA_ZB_DEC_LINE RM_AA_ZB_DEC_LINE(1) -#define G_RM_AA_ZB_DEC_LINE2 RM_AA_ZB_DEC_LINE(2) -#define G_RM_AA_ZB_TEX_EDGE RM_AA_ZB_TEX_EDGE(1) -#define G_RM_AA_ZB_TEX_EDGE2 RM_AA_ZB_TEX_EDGE(2) -#define G_RM_AA_ZB_TEX_INTER RM_AA_ZB_TEX_INTER(1) -#define G_RM_AA_ZB_TEX_INTER2 RM_AA_ZB_TEX_INTER(2) -#define G_RM_AA_ZB_SUB_SURF RM_AA_ZB_SUB_SURF(1) -#define G_RM_AA_ZB_SUB_SURF2 RM_AA_ZB_SUB_SURF(2) -#define G_RM_AA_ZB_PCL_SURF RM_AA_ZB_PCL_SURF(1) -#define G_RM_AA_ZB_PCL_SURF2 RM_AA_ZB_PCL_SURF(2) -#define G_RM_AA_ZB_OPA_TERR RM_AA_ZB_OPA_TERR(1) -#define G_RM_AA_ZB_OPA_TERR2 RM_AA_ZB_OPA_TERR(2) -#define G_RM_AA_ZB_TEX_TERR RM_AA_ZB_TEX_TERR(1) -#define G_RM_AA_ZB_TEX_TERR2 RM_AA_ZB_TEX_TERR(2) -#define G_RM_AA_ZB_SUB_TERR RM_AA_ZB_SUB_TERR(1) -#define G_RM_AA_ZB_SUB_TERR2 RM_AA_ZB_SUB_TERR(2) - -#define G_RM_RA_ZB_OPA_SURF RM_RA_ZB_OPA_SURF(1) -#define G_RM_RA_ZB_OPA_SURF2 RM_RA_ZB_OPA_SURF(2) -#define G_RM_RA_ZB_OPA_DECAL RM_RA_ZB_OPA_DECAL(1) -#define G_RM_RA_ZB_OPA_DECAL2 RM_RA_ZB_OPA_DECAL(2) -#define G_RM_RA_ZB_OPA_INTER RM_RA_ZB_OPA_INTER(1) -#define G_RM_RA_ZB_OPA_INTER2 RM_RA_ZB_OPA_INTER(2) - -#define G_RM_AA_OPA_SURF RM_AA_OPA_SURF(1) -#define G_RM_AA_OPA_SURF2 RM_AA_OPA_SURF(2) -#define G_RM_AA_XLU_SURF RM_AA_XLU_SURF(1) -#define G_RM_AA_XLU_SURF2 RM_AA_XLU_SURF(2) -#define G_RM_AA_XLU_LINE RM_AA_XLU_LINE(1) -#define G_RM_AA_XLU_LINE2 RM_AA_XLU_LINE(2) -#define G_RM_AA_DEC_LINE RM_AA_DEC_LINE(1) -#define G_RM_AA_DEC_LINE2 RM_AA_DEC_LINE(2) -#define G_RM_AA_TEX_EDGE RM_AA_TEX_EDGE(1) -#define G_RM_AA_TEX_EDGE2 RM_AA_TEX_EDGE(2) -#define G_RM_AA_SUB_SURF RM_AA_SUB_SURF(1) -#define G_RM_AA_SUB_SURF2 RM_AA_SUB_SURF(2) -#define G_RM_AA_PCL_SURF RM_AA_PCL_SURF(1) -#define G_RM_AA_PCL_SURF2 RM_AA_PCL_SURF(2) -#define G_RM_AA_OPA_TERR RM_AA_OPA_TERR(1) -#define G_RM_AA_OPA_TERR2 RM_AA_OPA_TERR(2) -#define G_RM_AA_TEX_TERR RM_AA_TEX_TERR(1) -#define G_RM_AA_TEX_TERR2 RM_AA_TEX_TERR(2) -#define G_RM_AA_SUB_TERR RM_AA_SUB_TERR(1) -#define G_RM_AA_SUB_TERR2 RM_AA_SUB_TERR(2) - -#define G_RM_RA_OPA_SURF RM_RA_OPA_SURF(1) -#define G_RM_RA_OPA_SURF2 RM_RA_OPA_SURF(2) - -#define G_RM_ZB_OPA_SURF RM_ZB_OPA_SURF(1) -#define G_RM_ZB_OPA_SURF2 RM_ZB_OPA_SURF(2) -#define G_RM_ZB_XLU_SURF RM_ZB_XLU_SURF(1) -#define G_RM_ZB_XLU_SURF2 RM_ZB_XLU_SURF(2) -#define G_RM_ZB_OPA_DECAL RM_ZB_OPA_DECAL(1) -#define G_RM_ZB_OPA_DECAL2 RM_ZB_OPA_DECAL(2) -#define G_RM_ZB_XLU_DECAL RM_ZB_XLU_DECAL(1) -#define G_RM_ZB_XLU_DECAL2 RM_ZB_XLU_DECAL(2) -#define G_RM_ZB_CLD_SURF RM_ZB_CLD_SURF(1) -#define G_RM_ZB_CLD_SURF2 RM_ZB_CLD_SURF(2) -#define G_RM_ZB_OVL_SURF RM_ZB_OVL_SURF(1) -#define G_RM_ZB_OVL_SURF2 RM_ZB_OVL_SURF(2) -#define G_RM_ZB_PCL_SURF RM_ZB_PCL_SURF(1) -#define G_RM_ZB_PCL_SURF2 RM_ZB_PCL_SURF(2) - -#define G_RM_OPA_SURF RM_OPA_SURF(1) -#define G_RM_OPA_SURF2 RM_OPA_SURF(2) -#define G_RM_XLU_SURF RM_XLU_SURF(1) -#define G_RM_XLU_SURF2 RM_XLU_SURF(2) -#define G_RM_CLD_SURF RM_CLD_SURF(1) -#define G_RM_CLD_SURF2 RM_CLD_SURF(2) -#define G_RM_TEX_EDGE RM_TEX_EDGE(1) -#define G_RM_TEX_EDGE2 RM_TEX_EDGE(2) -#define G_RM_PCL_SURF RM_PCL_SURF(1) -#define G_RM_PCL_SURF2 RM_PCL_SURF(2) -#define G_RM_ADD RM_ADD(1) -#define G_RM_ADD2 RM_ADD(2) -#define G_RM_NOOP RM_NOOP(1) -#define G_RM_NOOP2 RM_NOOP(2) -#define G_RM_VISCVG RM_VISCVG(1) -#define G_RM_VISCVG2 RM_VISCVG(2) -#define G_RM_OPA_CI RM_OPA_CI(1) -#define G_RM_OPA_CI2 RM_OPA_CI(2) - -#define G_RM_CUSTOM_AA_ZB_XLU_SURF RM_CUSTOM_AA_ZB_XLU_SURF(1) -#define G_RM_CUSTOM_AA_ZB_XLU_SURF2 RM_CUSTOM_AA_ZB_XLU_SURF(2) - - -#define G_RM_FOG_SHADE_A GBL_c1(G_BL_CLR_FOG, G_BL_A_SHADE, G_BL_CLR_IN, G_BL_1MA) -#define G_RM_FOG_PRIM_A GBL_c1(G_BL_CLR_FOG, G_BL_A_FOG, G_BL_CLR_IN, G_BL_1MA) -#define G_RM_PASS GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) - -/* - * G_SETCONVERT: K0-5 - */ -#define G_CV_K0 175 -#define G_CV_K1 -43 -#define G_CV_K2 -89 -#define G_CV_K3 222 -#define G_CV_K4 114 -#define G_CV_K5 42 - -/* - * G_SETSCISSOR: interlace mode - */ -#define G_SC_NON_INTERLACE 0 -#define G_SC_ODD_INTERLACE 3 -#define G_SC_EVEN_INTERLACE 2 - -/* flags to inhibit pushing of the display list (on branch) */ -#define G_DL_PUSH 0x00 -#define G_DL_NOPUSH 0x01 - -/* - * BEGIN C-specific section: (typedef's) - */ -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/* - * Data Structures - * - * NOTE: - * The DMA transfer hardware requires 64-bit aligned, 64-bit multiple- - * sized transfers. This important hardware optimization is unfortunately - * reflected in the programming interface, with some structures - * padded and alignment enforced. - * - * Since structures are aligned to the boundary of the "worst-case" - * element, we can't depend on the C compiler to align things - * properly. - * - * 64-bit structure alignment is enforced by wrapping structures with - * unions that contain a dummy "long long int". Why this works is - * explained in the ANSI C Spec, or on page 186 of the second edition - * of K&R, "The C Programming Language". - * - * The price we pay for this is a little awkwardness referencing the - * structures through the union. There is no memory penalty, since - * all the structures are at least 64-bits the dummy alignment field - * does not increase the size of the union. - * - * Static initialization of these union structures works because - * the ANSI C spec states that static initialization for unions - * works by using the first union element. We put the dummy alignment - * field last for this reason. - * - * (it's possible a newer 64-bit compiler from MIPS might make this - * easier with a flag, but we can't wait for it...) - * - */ - -/* - * Vertex (set up for use with colors) - */ -typedef struct { - short ob[3]; /* x, y, z */ - unsigned short flag; - short tc[2]; /* texture coord */ - unsigned char cn[4]; /* color & alpha */ -} Vtx_t; - -/* - * Vertex (set up for use with normals) - */ -typedef struct { - short ob[3]; /* x, y, z */ - unsigned short flag; - short tc[2]; /* texture coord */ - signed char n[3]; /* normal */ - unsigned char a; /* alpha */ -} Vtx_tn; - -typedef union { - Vtx_t v; /* Use this one for colors */ - Vtx_tn n; /* Use this one for normals */ - long long int force_structure_alignment; -} Vtx; - -/* - * Sprite structure - */ - -typedef struct { - void *SourceImagePointer; - void *TlutPointer; - short Stride; - short SubImageWidth; - short SubImageHeight; - char SourceImageType; - char SourceImageBitSize; - short SourceImageOffsetS; - short SourceImageOffsetT; - /* 20 bytes for above */ - - /* padding to bring structure size to 64 bit allignment */ - char dummy[4]; - -} uSprite_t; - -typedef union { - uSprite_t s; - - /* Need to make sure this is 64 bit aligned */ - long long int force_structure_allignment[3]; -} uSprite; - -/* - * Triangle face - */ -typedef struct { - unsigned char flag; - unsigned char v[3]; -} Tri; - -/* - * 4x4 matrix, fixed point s15.16 format. - * First 8 words are integer portion of the 4x4 matrix - * Last 8 words are the fraction portion of the 4x4 matrix - */ -typedef s32 Mtx_t[4][4]; - -typedef union { - Mtx_t m; - long long int force_structure_alignment; -} Mtx; - -/* - * Viewport - */ - -/* - * - * This magic value is the maximum INTEGER z-range of the hardware - * (there are also 16-bits of fraction, which are introduced during - * any transformations). This is not just a good idea, it's the law. - * Feeding the hardware eventual z-coordinates (after any transforms - * or scaling) bigger than this, will not work. - * - * This number is DIFFERENT than G_MAXFBZ, which is the maximum value - * you want to use to initialize the z-buffer. - * - * The reason these are different is mildly interesting, but too long - * to explain here. It is basically the result of optimizations in the - * hardware. A more generic API might hide this detail from the users, - * but we don't have the ucode to do that... - * - */ -#define G_MAXZ 0x03ff /* 10 bits of integer screen-Z precision */ - -/* - * The viewport structure elements have 2 bits of fraction, necessary - * to accomodate the sub-pixel positioning scaling for the hardware. - * This can also be exploited to handle odd-sized viewports. - * - * Accounting for these fractional bits, using the default projection - * and viewing matrices, the viewport structure is initialized thusly: - * - * (SCREEN_WD/2)*4, (SCREEN_HT/2)*4, G_MAXZ, 0, - * (SCREEN_WD/2)*4, (SCREEN_HT/2)*4, 0, 0, - */ -typedef struct { - short vscale[4]; /* scale, 2 bits fraction */ - short vtrans[4]; /* translate, 2 bits fraction */ - /* both the above arrays are padded to 64-bit boundary */ -} Vp_t; - -typedef union { - Vp_t vp; - long long int force_structure_alignment; -} Vp; - -/* - * MOVEMEM indices - * - * Each of these indexes an entry in a dmem table - * which points to a 1-4 word block of dmem in - * which to store a 1-4 word DMA. - * - */ -#ifdef F3DEX_GBI_2 -/* 0,4 are reserved by G_MTX */ -# define G_MV_MMTX 2 -# define G_MV_PMTX 6 -# define G_MV_VIEWPORT 8 -# define G_MV_LIGHT 10 -# define G_MV_POINT 12 -# define G_MV_MATRIX 14 /* NOTE: this is in moveword table */ -# define G_MVO_LOOKATX (0*24) -# define G_MVO_LOOKATY (1*24) -# define G_MVO_L0 (2*24) -# define G_MVO_L1 (3*24) -# define G_MVO_L2 (4*24) -# define G_MVO_L3 (5*24) -# define G_MVO_L4 (6*24) -# define G_MVO_L5 (7*24) -# define G_MVO_L6 (8*24) -# define G_MVO_L7 (9*24) -#else /* F3DEX_GBI_2 */ -# define G_MV_VIEWPORT 0x80 -# define G_MV_LOOKATY 0x82 -# define G_MV_LOOKATX 0x84 -# define G_MV_L0 0x86 -# define G_MV_L1 0x88 -# define G_MV_L2 0x8a -# define G_MV_L3 0x8c -# define G_MV_L4 0x8e -# define G_MV_L5 0x90 -# define G_MV_L6 0x92 -# define G_MV_L7 0x94 -# define G_MV_TXTATT 0x96 -# define G_MV_MATRIX_1 0x9e /* NOTE: this is in moveword table */ -# define G_MV_MATRIX_2 0x98 -# define G_MV_MATRIX_3 0x9a -# define G_MV_MATRIX_4 0x9c -#endif /* F3DEX_GBI_2 */ - -/* - * MOVEWORD indices - * - * Each of these indexes an entry in a dmem table - * which points to a word in dmem in dmem where - * an immediate word will be stored. - * - */ -#define G_MW_MATRIX 0x00 /* NOTE: also used by movemem */ -#define G_MW_NUMLIGHT 0x02 -#define G_MW_CLIP 0x04 -#define G_MW_SEGMENT 0x06 -#define G_MW_FOG 0x08 -#define G_MW_LIGHTCOL 0x0a -#ifdef F3DEX_GBI_2 -# define G_MW_FORCEMTX 0x0c -#else /* F3DEX_GBI_2 */ -# define G_MW_POINTS 0x0c -#endif /* F3DEX_GBI_2 */ -#define G_MW_PERSPNORM 0x0e - -/* - * These are offsets from the address in the dmem table - */ -#define G_MWO_NUMLIGHT 0x00 -#define G_MWO_CLIP_RNX 0x04 -#define G_MWO_CLIP_RNY 0x0c -#define G_MWO_CLIP_RPX 0x14 -#define G_MWO_CLIP_RPY 0x1c -#define G_MWO_SEGMENT_0 0x00 -#define G_MWO_SEGMENT_1 0x01 -#define G_MWO_SEGMENT_2 0x02 -#define G_MWO_SEGMENT_3 0x03 -#define G_MWO_SEGMENT_4 0x04 -#define G_MWO_SEGMENT_5 0x05 -#define G_MWO_SEGMENT_6 0x06 -#define G_MWO_SEGMENT_7 0x07 -#define G_MWO_SEGMENT_8 0x08 -#define G_MWO_SEGMENT_9 0x09 -#define G_MWO_SEGMENT_A 0x0a -#define G_MWO_SEGMENT_B 0x0b -#define G_MWO_SEGMENT_C 0x0c -#define G_MWO_SEGMENT_D 0x0d -#define G_MWO_SEGMENT_E 0x0e -#define G_MWO_SEGMENT_F 0x0f -#define G_MWO_FOG 0x00 -#define G_MWO_aLIGHT_1 0x00 -#define G_MWO_bLIGHT_1 0x04 -#ifdef F3DEX_GBI_2 -#define G_MWO_aLIGHT_2 0x18 -#define G_MWO_bLIGHT_2 0x1c -#define G_MWO_aLIGHT_3 0x30 -#define G_MWO_bLIGHT_3 0x34 -#define G_MWO_aLIGHT_4 0x48 -#define G_MWO_bLIGHT_4 0x4c -#define G_MWO_aLIGHT_5 0x60 -#define G_MWO_bLIGHT_5 0x64 -#define G_MWO_aLIGHT_6 0x78 -#define G_MWO_bLIGHT_6 0x7c -#define G_MWO_aLIGHT_7 0x90 -#define G_MWO_bLIGHT_7 0x94 -#define G_MWO_aLIGHT_8 0xa8 -#define G_MWO_bLIGHT_8 0xac -#else -#define G_MWO_aLIGHT_2 0x20 -#define G_MWO_bLIGHT_2 0x24 -#define G_MWO_aLIGHT_3 0x40 -#define G_MWO_bLIGHT_3 0x44 -#define G_MWO_aLIGHT_4 0x60 -#define G_MWO_bLIGHT_4 0x64 -#define G_MWO_aLIGHT_5 0x80 -#define G_MWO_bLIGHT_5 0x84 -#define G_MWO_aLIGHT_6 0xa0 -#define G_MWO_bLIGHT_6 0xa4 -#define G_MWO_aLIGHT_7 0xc0 -#define G_MWO_bLIGHT_7 0xc4 -#define G_MWO_aLIGHT_8 0xe0 -#define G_MWO_bLIGHT_8 0xe4 -#endif -#define G_MWO_MATRIX_XX_XY_I 0x00 -#define G_MWO_MATRIX_XZ_XW_I 0x04 -#define G_MWO_MATRIX_YX_YY_I 0x08 -#define G_MWO_MATRIX_YZ_YW_I 0x0c -#define G_MWO_MATRIX_ZX_ZY_I 0x10 -#define G_MWO_MATRIX_ZZ_ZW_I 0x14 -#define G_MWO_MATRIX_WX_WY_I 0x18 -#define G_MWO_MATRIX_WZ_WW_I 0x1c -#define G_MWO_MATRIX_XX_XY_F 0x20 -#define G_MWO_MATRIX_XZ_XW_F 0x24 -#define G_MWO_MATRIX_YX_YY_F 0x28 -#define G_MWO_MATRIX_YZ_YW_F 0x2c -#define G_MWO_MATRIX_ZX_ZY_F 0x30 -#define G_MWO_MATRIX_ZZ_ZW_F 0x34 -#define G_MWO_MATRIX_WX_WY_F 0x38 -#define G_MWO_MATRIX_WZ_WW_F 0x3c -#define G_MWO_POINT_RGBA 0x10 -#define G_MWO_POINT_ST 0x14 -#define G_MWO_POINT_XYSCREEN 0x18 -#define G_MWO_POINT_ZSCREEN 0x1c - -/* - * Light structure. - * - * Note: only directional (infinite) lights are currently supported. - * - * Note: the weird order is for the DMEM alignment benefit of - * the microcode. - * - */ - -typedef struct { - unsigned char col[3]; /* diffuse light value (rgba) */ - char pad1; - unsigned char colc[3]; /* copy of diffuse light value (rgba) */ - char pad2; - signed char dir[3]; /* direction of light (normalized) */ - char pad3; -} Light_t; - -typedef struct { - unsigned char col[3]; /* ambient light value (rgba) */ - char pad1; - unsigned char colc[3]; /* copy of ambient light value (rgba) */ - char pad2; -} Ambient_t; - -typedef struct { - int x1,y1,x2,y2; /* texture offsets for highlight 1/2 */ -} Hilite_t; - -typedef union { - Light_t l; - long long int force_structure_alignment[2]; -} Light; - -typedef union { - Ambient_t l; - long long int force_structure_alignment[1]; -} Ambient; - -typedef struct { - Ambient a; - Light l[7]; -} Lightsn; - -typedef struct { - Ambient a; - Light l[1]; -} Lights0; - -typedef struct { - Ambient a; - Light l[1]; -} Lights1; - -typedef struct { - Ambient a; - Light l[2]; -} Lights2; - -typedef struct { - Ambient a; - Light l[3]; -} Lights3; - -typedef struct { - Ambient a; - Light l[4]; -} Lights4; - -typedef struct { - Ambient a; - Light l[5]; -} Lights5; - -typedef struct { - Ambient a; - Light l[6]; -} Lights6; - -typedef struct { - Ambient a; - Light l[7]; -} Lights7; - -typedef struct { - Light l[2]; -} LookAt; - -typedef union { - Hilite_t h; - long int force_structure_alignment[4]; -} Hilite; - -#define gdSPDefLights0(ar,ag,ab) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ { 0, 0, 0},0,{ 0, 0, 0},0,{ 0, 0, 0},0}}} } -#define gdSPDefLights1(ar,ag,ab,r1,g1,b1,x1,y1,z1) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}} } -#define gdSPDefLights2(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ - {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}} } -#define gdSPDefLights3(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ - {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \ - {{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}} } -#define gdSPDefLights4(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3,r4,g4,b4,x4,y4,z4) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ - {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \ - {{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}, \ - {{ {r4,g4,b4},0,{r4,g4,b4},0,{x4,y4,z4},0}}} } -#define gdSPDefLights5(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3,r4,g4,b4,x4,y4,z4,r5,g5,b5,x5,y5,z5) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ - {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \ - {{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}, \ - {{ {r4,g4,b4},0,{r4,g4,b4},0,{x4,y4,z4},0}}, \ - {{ {r5,g5,b5},0,{r5,g5,b5},0,{x5,y5,z5},0}}} } - - -#define gdSPDefLights6(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3,r4,g4,b4,x4,y4,z4,r5,g5,b5,x5,y5,z5,r6,g6,b6,x6,y6,z6) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ - {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \ - {{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}, \ - {{ {r4,g4,b4},0,{r4,g4,b4},0,{x4,y4,z4},0}}, \ - {{ {r5,g5,b5},0,{r5,g5,b5},0,{x5,y5,z5},0}}, \ - {{ {r6,g6,b6},0,{r6,g6,b6},0,{x6,y6,z6},0}}} } - - -#define gdSPDefLights7(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3,r4,g4,b4,x4,y4,z4,r5,g5,b5,x5,y5,z5,r6,g6,b6,x6,y6,z6,r7,g7,b7,x7,y7,z7) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ - {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \ - {{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}, \ - {{ {r4,g4,b4},0,{r4,g4,b4},0,{x4,y4,z4},0}}, \ - {{ {r5,g5,b5},0,{r5,g5,b5},0,{x5,y5,z5},0}}, \ - {{ {r6,g6,b6},0,{r6,g6,b6},0,{x6,y6,z6},0}}, \ - {{ {r7,g7,b7},0,{r7,g7,b7},0,{x7,y7,z7},0}}} } - - -#define gdSPDefLookAt(rightx,righty,rightz,upx,upy,upz) \ - { {{ {{0,0,0},0,{0,0,0},0,{rightx,righty,rightz},0}}, \ - { {{0,0x80,0},0,{0,0x80,0},0,{upx,upy,upz},0}}} } - -/* Don't declare these for F3D_OLD to avoid bss reordering */ -#ifndef F3D_OLD -/* - * Graphics DMA Packet - */ -typedef struct { - int cmd:8; - unsigned int par:8; - unsigned int len:16; - uintptr_t addr; -} Gdma; - -/* - * Graphics Immediate Mode Packet types - */ -typedef struct { - int cmd:8; - int pad:24; - Tri tri; -} Gtri; - -typedef struct { - int cmd:8; - int pad1:24; - int pad2:24; - unsigned char param:8; -} Gpopmtx; - -/* - * typedef struct { - * int cmd:8; - * int pad0:24; - * int pad1:4; - * int number:4; - * int base:24; - * } Gsegment; - */ -typedef struct { - int cmd:8; - int pad0:8; - int mw_index:8; - int number:8; - int pad1:8; - int base:24; -} Gsegment; - -typedef struct { - int cmd:8; - int pad0:8; - int sft:8; - int len:8; - unsigned int data:32; -} GsetothermodeL; - -typedef struct { - int cmd:8; - int pad0:8; - int sft:8; - int len:8; - unsigned int data:32; -} GsetothermodeH; - -typedef struct { - unsigned char cmd; - unsigned char lodscale; - unsigned char tile; - unsigned char on; - unsigned short s; - unsigned short t; -} Gtexture; - -typedef struct { - int cmd:8; - int pad:24; - Tri line; -} Gline3D; - -typedef struct { - int cmd:8; - int pad1:24; - short int pad2; - short int scale; -} Gperspnorm; - - -/* - * RDP Packet types - */ -typedef struct { - int cmd:8; - unsigned int fmt:3; - unsigned int siz:2; - unsigned int pad:7; - unsigned int wd:12; /* really only 10 bits, extra */ - uintptr_t dram; /* to account for 1024 */ -} Gsetimg; - -typedef struct { - int cmd:8; - unsigned int muxs0:24; - unsigned int muxs1:32; -} Gsetcombine; - -typedef struct { - int cmd:8; - unsigned char pad; - unsigned char prim_min_level; - unsigned char prim_level; - unsigned long color; -} Gsetcolor; - -typedef struct { - int cmd:8; - int x0:10; - int x0frac:2; - int y0:10; - int y0frac:2; - unsigned int pad:8; - int x1:10; - int x1frac:2; - int y1:10; - int y1frac:2; -} Gfillrect; - -typedef struct { - int cmd:8; - unsigned int fmt:3; - unsigned int siz:2; - unsigned int pad0:1; - unsigned int line:9; - unsigned int tmem:9; - unsigned int pad1:5; - unsigned int tile:3; - unsigned int palette:4; - unsigned int ct:1; - unsigned int mt:1; - unsigned int maskt:4; - unsigned int shiftt:4; - unsigned int cs:1; - unsigned int ms:1; - unsigned int masks:4; - unsigned int shifts:4; -} Gsettile; - -typedef struct { - int cmd:8; - unsigned int sl:12; - unsigned int tl:12; - int pad:5; - unsigned int tile:3; - unsigned int sh:12; - unsigned int th:12; -} Gloadtile; - -typedef Gloadtile Gloadblock; - -typedef Gloadtile Gsettilesize; - -typedef Gloadtile Gloadtlut; - -typedef struct { - unsigned int cmd:8; /* command */ - unsigned int xl:12; /* X coordinate of upper left */ - unsigned int yl:12; /* Y coordinate of upper left */ - unsigned int pad1:5; /* Padding */ - unsigned int tile:3; /* Tile descriptor index */ - unsigned int xh:12; /* X coordinate of lower right */ - unsigned int yh:12; /* Y coordinate of lower right */ - unsigned int s:16; /* S texture coord at top left */ - unsigned int t:16; /* T texture coord at top left */ - unsigned int dsdx:16;/* Change in S per change in X */ - unsigned int dtdy:16;/* Change in T per change in Y */ -} Gtexrect; - -/* - * Textured rectangles are 128 bits not 64 bits - */ -typedef struct { - unsigned long w0; - unsigned long w1; - unsigned long w2; - unsigned long w3; -} TexRect; -#endif - -#define MakeTexRect(xh,yh,flip,tile,xl,yl,s,t,dsdx,dtdy) \ - G_TEXRECT, xh, yh, 0, flip, 0, tile, xl, yl, s, t, dsdx, dtdy - -/* - * Generic Gfx Packet - */ -typedef struct { - uintptr_t w0; - uintptr_t w1; -} Gwords; - -/* - * This union is the fundamental type of the display list. - * It is, by law, exactly 64 bits in size. - * - * (Edit: except on 64-bit, where it is exactly 128 bit. On little-endian or - * 64-bit systems, only the 'words' member may be accessed; the rest of the - * structs don't have matching layouts for now.) - */ - -typedef union { - Gwords words; -#if !defined(F3D_OLD) && IS_BIG_ENDIAN && !IS_64_BIT - Gdma dma; - Gtri tri; - Gline3D line; - Gpopmtx popmtx; - Gsegment segment; - GsetothermodeH setothermodeH; - GsetothermodeL setothermodeL; - Gtexture texture; - Gperspnorm perspnorm; - Gsetimg setimg; - Gsetcombine setcombine; - Gsetcolor setcolor; - Gfillrect fillrect; /* use for setscissor also */ - Gsettile settile; - Gloadtile loadtile; /* use for loadblock also, th is dxt */ - Gsettilesize settilesize; - Gloadtlut loadtlut; -#endif - long long int force_structure_alignment; -} Gfx; - -/* - * Macros to assemble the graphics display list - */ - -/* - * DMA macros - */ -#define gDma0p(pkt, c, s, l) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL((c), 24, 8) | _SHIFTL((l), 0, 24); \ - _g->words.w1 = (uintptr_t)(s); \ -} - -#define gsDma0p(c, s, l) \ -{{ \ - _SHIFTL((c), 24, 8) | _SHIFTL((l), 0, 24), (uintptr_t)(s) \ -}} - -#define gDma1p(pkt, c, s, l, p) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL((c), 24, 8) | _SHIFTL((p), 16, 8) | \ - _SHIFTL((l), 0, 16)); \ - _g->words.w1 = (uintptr_t)(s); \ -} - -#define gsDma1p(c, s, l, p) \ -{{ \ - (_SHIFTL((c), 24, 8) | _SHIFTL((p), 16, 8) | \ - _SHIFTL((l), 0, 16)), \ - (uintptr_t)(s) \ -}} - -#define gDma2p(pkt, c, adrs, len, idx, ofs) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = (_SHIFTL((c),24,8)|_SHIFTL(((len)-1)/8,19,5)| \ - _SHIFTL((ofs)/8,8,8)|_SHIFTL((idx),0,8)); \ - _g->words.w1 = (uintptr_t)(adrs); \ -} -#define gsDma2p(c, adrs, len, idx, ofs) \ -{{ \ - (_SHIFTL((c),24,8)|_SHIFTL(((len)-1)/8,19,5)| \ - _SHIFTL((ofs)/8,8,8)|_SHIFTL((idx),0,8)), \ - (uintptr_t)(adrs) \ -}} - -#define gSPNoOp(pkt) gDma0p(pkt, G_SPNOOP, 0, 0) -#define gsSPNoOp() gsDma0p(G_SPNOOP, 0, 0) - -#ifdef F3DEX_GBI_2 -# define gSPMatrix(pkt, m, p) \ - gDma2p((pkt),G_MTX,(m),sizeof(Mtx),(p)^G_MTX_PUSH,0) -# define gsSPMatrix(m, p) \ - gsDma2p( G_MTX,(m),sizeof(Mtx),(p)^G_MTX_PUSH,0) -#else /* F3DEX_GBI_2 */ -# define gSPMatrix(pkt, m, p) gDma1p(pkt, G_MTX, m, sizeof(Mtx), p) -# define gsSPMatrix(m, p) gsDma1p(G_MTX, m, sizeof(Mtx), p) -#endif /* F3DEX_GBI_2 */ - -#if defined(F3DEX_GBI_2) -/* - * F3DEX_GBI_2: G_VTX GBI format was changed. - * - * +--------+----+---+---+----+------+-+ - * G_VTX | cmd:8 |0000| n:8 |0000|v0+n:7|0| - * +-+---+--+----+---+---+----+------+-+ - * | |seg| address | - * +-+---+-----------------------------+ - */ -# define gSPVertex(pkt, v, n, v0) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = \ - _SHIFTL(G_VTX,24,8)|_SHIFTL((n),12,8)|_SHIFTL((v0)+(n),1,7); \ - _g->words.w1 = (uintptr_t)(v); \ -} -# define gsSPVertex(v, n, v0) \ -{{ \ - (_SHIFTL(G_VTX,24,8)|_SHIFTL((n),12,8)|_SHIFTL((v0)+(n),1,7)), \ - (uintptr_t)(v) \ -}} -#elif (defined(F3DEX_GBI)||defined(F3DLP_GBI)) -/* - * F3DEX_GBI: G_VTX GBI format was changed to support 64 vertice. - * - * +--------+--------+------+----------+ - * G_VTX | cmd:8 | v0:8 | n:6 |length:10 | - * +-+---+--+--------+------+----------+ - * | |seg| address | - * +-+---+-----------------------------+ - */ -# define gSPVertex(pkt, v, n, v0) \ - gDma1p((pkt),G_VTX,(v),((n)<<10)|(sizeof(Vtx)*(n)-1),(v0)*2) -# define gsSPVertex(v, n, v0) \ - gsDma1p(G_VTX,(v),((n)<<10)|(sizeof(Vtx)*(n)-1),(v0)*2) -#else -# define gSPVertex(pkt, v, n, v0) \ - gDma1p(pkt, G_VTX, v, sizeof(Vtx)*(n),((n)-1)<<4|(v0)) -# define gsSPVertex(v, n, v0) \ - gsDma1p(G_VTX, v, sizeof(Vtx)*(n), ((n)-1)<<4|(v0)) -#endif - - -#ifdef F3DEX_GBI_2 -# define gSPViewport(pkt, v) \ - gDma2p((pkt), G_MOVEMEM, (v), sizeof(Vp), G_MV_VIEWPORT, 0) -# define gsSPViewport(v) \ - gsDma2p( G_MOVEMEM, (v), sizeof(Vp), G_MV_VIEWPORT, 0) -#else /* F3DEX_GBI_2 */ -# define gSPViewport(pkt,v) \ - gDma1p((pkt), G_MOVEMEM, (v), sizeof(Vp), G_MV_VIEWPORT) -# define gsSPViewport(v) \ - gsDma1p( G_MOVEMEM, (v), sizeof(Vp), G_MV_VIEWPORT) -#endif /* F3DEX_GBI_2 */ - -#define gSPDisplayList(pkt,dl) gDma1p(pkt,G_DL,dl,0,G_DL_PUSH) -#define gsSPDisplayList( dl) gsDma1p( G_DL,dl,0,G_DL_PUSH) - -#define gSPBranchList(pkt,dl) gDma1p(pkt,G_DL,dl,0,G_DL_NOPUSH) -#define gsSPBranchList( dl) gsDma1p( G_DL,dl,0,G_DL_NOPUSH) - -#define gSPSprite2DBase(pkt, s) gDma1p(pkt, G_SPRITE2D_BASE, s, sizeof(uSprite), 0) -#define gsSPSprite2DBase(s) gsDma1p(G_SPRITE2D_BASE, s, sizeof(uSprite), 0) - -/* - * RSP short command (no DMA required) macros - */ -#define gImmp0(pkt, c) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL((c), 24, 8); \ -} - -#define gsImmp0(c) \ -{{ \ - _SHIFTL((c), 24, 8) \ -}} - -#define gImmp1(pkt, c, p0) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL((c), 24, 8); \ - _g->words.w1 = (uintptr_t)(p0); \ -} - -#define gsImmp1(c, p0) \ -{{ \ - _SHIFTL((c), 24, 8), (uintptr_t)(p0) \ -}} - -#define gImmp2(pkt, c, p0, p1) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL((c), 24, 8); \ - _g->words.w1 = _SHIFTL((p0), 16, 16) | _SHIFTL((p1), 8, 8); \ -} - -#define gsImmp2(c, p0, p1) \ -{{ \ - _SHIFTL((c), 24, 8), _SHIFTL((p0), 16, 16) | _SHIFTL((p1), 8, 8)\ -}} - -#define gImmp3(pkt, c, p0, p1, p2) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL((c), 24, 8); \ - _g->words.w1 = (_SHIFTL((p0), 16, 16) | _SHIFTL((p1), 8, 8) | \ - _SHIFTL((p2), 0, 8)); \ -} - -#define gsImmp3(c, p0, p1, p2) \ -{{ \ - _SHIFTL((c), 24, 8), (_SHIFTL((p0), 16, 16) | \ - _SHIFTL((p1), 8, 8) | _SHIFTL((p2), 0, 8))\ -}} - -#define gImmp21(pkt, c, p0, p1, dat) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL((c), 24, 8) | _SHIFTL((p0), 8, 16) | \ - _SHIFTL((p1), 0, 8)); \ - _g->words.w1 = (uintptr_t) (dat); \ -} - -#define gsImmp21(c, p0, p1, dat) \ -{{ \ - _SHIFTL((c), 24, 8) | _SHIFTL((p0), 8, 16) | _SHIFTL((p1), 0, 8),\ - (uintptr_t) (dat) \ -}} - -#ifdef F3DEX_GBI_2 -#define gMoveWd(pkt, index, offset, data) \ - gDma1p((pkt), G_MOVEWORD, data, offset, index) -#define gsMoveWd( index, offset, data) \ - gsDma1p( G_MOVEWORD, data, offset, index) -#else /* F3DEX_GBI_2 */ -#define gMoveWd(pkt, index, offset, data) \ - gImmp21((pkt), G_MOVEWORD, offset, index, data) -#define gsMoveWd( index, offset, data) \ - gsImmp21( G_MOVEWORD, offset, index, data) -#endif /* F3DEX_GBI_2 */ - -/* Sprite immediate macros, there is also a sprite dma macro above */ - -#define gSPSprite2DScaleFlip(pkt, sx, sy, fx, fy) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_SPRITE2D_SCALEFLIP, 24, 8) | \ - _SHIFTL((fx), 8, 8) | \ - _SHIFTL((fy), 0, 8)); \ - _g->words.w1 = (_SHIFTL((sx), 16, 16) | \ - _SHIFTL((sy), 0, 16)); \ -} - -#define gsSPSprite2DScaleFlip(sx, sy, fx, fy) \ -{{ \ - (_SHIFTL(G_SPRITE2D_SCALEFLIP, 24, 8) | \ - _SHIFTL((fx), 8, 8) | \ - _SHIFTL((fy), 0, 8)), \ - (_SHIFTL((sx), 16, 16) | \ - _SHIFTL((sy), 0, 16)) \ -}} - -#define gSPSprite2DDraw(pkt, px, py) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_SPRITE2D_DRAW, 24, 8)); \ - _g->words.w1 = (_SHIFTL((px), 16, 16) | \ - _SHIFTL((py), 0, 16)); \ -} - -#define gsSPSprite2DDraw(px, py) \ -{{ \ - (_SHIFTL(G_SPRITE2D_DRAW, 24, 8)), \ - (_SHIFTL((px), 16, 16) | \ - _SHIFTL((py), 0, 16)) \ -}} - - -/* - * Note: the SP1Triangle() and line macros multiply the vertex indices - * by 10, this is an optimization for the microcode. - */ -#if (defined(F3DLP_GBI)||defined(F3DEX_GBI)) -# define __gsSP1Triangle_w1(v0, v1, v2) \ - (_SHIFTL((v0)*2,16,8)|_SHIFTL((v1)*2,8,8)|_SHIFTL((v2)*2,0,8)) -# define __gsSP1Triangle_w1f(v0, v1, v2, flag) \ - (((flag) == 0) ? __gsSP1Triangle_w1(v0, v1, v2): \ - ((flag) == 1) ? __gsSP1Triangle_w1(v1, v2, v0): \ - __gsSP1Triangle_w1(v2, v0, v1)) -# define __gsSPLine3D_w1(v0, v1, wd) \ - (_SHIFTL((v0)*2,16,8)|_SHIFT((v1)*2,8,8)|_SHIFT((wd),0,8)) -# define __gsSPLine3D_w1f(v0, v1, wd, flag) \ - (((flag) == 0) ? __gsSPLine3D_w1(v0, v1, wd): \ - __gsSPLine3D_w1(v1, v0, wd)) - -// Only used on old F3DEX revisions, removed on latest revisions. -#define __gsSP1Quadrangle_w1(v0, v1, v2, v3) \ - (_SHIFTL((v3)*2,24,8)|_SHIFTL((v0)*2,16,8)|\ - _SHIFTL((v1)*2,8,8)|_SHIFTL((v2)*2,0,8)) - -# define __gsSP1Quadrangle_w1f(v0, v1, v2, v3, flag) \ - (((flag) == 0) ? __gsSP1Triangle_w1(v0, v1, v2): \ - ((flag) == 1) ? __gsSP1Triangle_w1(v1, v2, v3): \ - ((flag) == 2) ? __gsSP1Triangle_w1(v2, v3, v0): \ - __gsSP1Triangle_w1(v3, v0, v1)) -# define __gsSP1Quadrangle_w2f(v0, v1, v2, v3, flag) \ - (((flag) == 0) ? __gsSP1Triangle_w1(v0, v2, v3): \ - ((flag) == 1) ? __gsSP1Triangle_w1(v1, v3, v0): \ - ((flag) == 2) ? __gsSP1Triangle_w1(v2, v0, v1): \ - __gsSP1Triangle_w1(v3, v1, v2)) -#else -# define __gsSP1Triangle_w1f(v0, v1, v2, flag) \ - (_SHIFTL((flag), 24,8)|_SHIFTL((v0)*10,16,8)| \ - _SHIFTL((v1)*10, 8,8)|_SHIFTL((v2)*10, 0,8)) -# define __gsSPLine3D_w1f(v0, v1, wd, flag) \ - (_SHIFTL((flag), 24,8)|_SHIFTL((v0)*10,16,8)| \ - _SHIFTL((v1)*10, 8,8)|_SHIFTL((wd), 0,8)) -#endif - -#ifdef F3DEX_GBI_2 -/*** - *** 1 Triangle - ***/ -#define gSP1Triangle(pkt, v0, v1, v2, flag) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(G_TRI1, 24, 8)| \ - __gsSP1Triangle_w1f(v0, v1, v2, flag); \ - _g->words.w1 = 0; \ -} -#define gsSP1Triangle(v0, v1, v2, flag) \ -{{ \ - _SHIFTL(G_TRI1, 24, 8)|__gsSP1Triangle_w1f(v0, v1, v2, flag), \ - 0 \ -}} - -/*** - *** Line - ***/ -#define gSPLine3D(pkt, v0, v1, flag) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(G_LINE3D, 24, 8)| \ - __gsSPLine3D_w1f(v0, v1, 0, flag); \ - _g->words.w1 = 0; \ -} -#define gsSPLine3D(v0, v1, flag) \ -{{ \ - _SHIFTL(G_LINE3D, 24, 8)|__gsSPLine3D_w1f(v0, v1, 0, flag), \ - 0 \ -}} - -/*** - *** LineW - ***/ -/* these macros are the same as SPLine3D, except they have an - * additional parameter for width. The width is added to the "minimum" - * thickness, which is 1.5 pixels. The units for width are in - * half-pixel units, so a width of 1 translates to (.5 + 1.5) or - * a 2.0 pixels wide line. - */ -#define gSPLineW3D(pkt, v0, v1, wd, flag) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(G_LINE3D, 24, 8)| \ - __gsSPLine3D_w1f(v0, v1, wd, flag); \ - _g->words.w1 = 0; \ -} -#define gsSPLineW3D(v0, v1, wd, flag) \ -{{ \ - _SHIFTL(G_LINE3D, 24, 8)|__gsSPLine3D_w1f(v0, v1, wd, flag), \ - 0 \ -}} - -/*** - *** 1 Quadrangle - ***/ -#define gSP1Quadrangle(pkt, v0, v1, v2, v3, flag) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_QUAD, 24, 8)| \ - __gsSP1Quadrangle_w1f(v0, v1, v2, v3, flag)); \ - _g->words.w1 = __gsSP1Quadrangle_w2f(v0, v1, v2, v3, flag); \ -} - -#define gsSP1Quadrangle(v0, v1, v2, v3, flag) \ -{{ \ - (_SHIFTL(G_QUAD, 24, 8)| \ - __gsSP1Quadrangle_w1f(v0, v1, v2, v3, flag)), \ - __gsSP1Quadrangle_w2f(v0, v1, v2, v3, flag) \ -}} -#else /* F3DEX_GBI_2 */ - -/*** - *** 1 Triangle - ***/ -#define gSP1Triangle(pkt, v0, v1, v2, flag) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(G_TRI1, 24, 8); \ - _g->words.w1 = __gsSP1Triangle_w1f(v0, v1, v2, flag); \ -} -#define gsSP1Triangle(v0, v1, v2, flag) \ -{{ \ - _SHIFTL(G_TRI1, 24, 8), \ - __gsSP1Triangle_w1f(v0, v1, v2, flag) \ -}} - -/*** - *** Line - ***/ -#define gSPLine3D(pkt, v0, v1, flag) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(G_LINE3D, 24, 8); \ - _g->words.w1 = __gsSPLine3D_w1f(v0, v1, 0, flag); \ -} -#define gsSPLine3D(v0, v1, flag) \ -{{ \ - _SHIFTL(G_LINE3D, 24, 8), \ - __gsSPLine3D_w1f(v0, v1, 0, flag) \ -}} - -/*** - *** LineW - ***/ -/* these macros are the same as SPLine3D, except they have an - * additional parameter for width. The width is added to the "minimum" - * thickness, which is 1.5 pixels. The units for width are in - * half-pixel units, so a width of 1 translates to (.5 + 1.5) or - * a 2.0 pixels wide line. - */ -#define gSPLineW3D(pkt, v0, v1, wd, flag) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(G_LINE3D, 24, 8); \ - _g->words.w1 = __gsSPLine3D_w1f(v0, v1, wd, flag); \ -} -#define gsSPLineW3D(v0, v1, wd, flag) \ -{{ \ - _SHIFTL(G_LINE3D, 24, 8), \ - __gsSPLine3D_w1f(v0, v1, wd, flag) \ -}} - -// Early revision of quadrangle command uses G_QUAD instead of G_TRI2. -// It does not have a flag argument, this was added for compatibility. -// MK64: Appears to only be used in startup_logo.c -#ifdef F3D_OLD -/*** - *** 1 Quadrangle - ***/ -#define gSP1Quadrangle(v0, v1, v2, v3, flag) \ -{{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(G_QUAD, 24, 8); \ - _g->words.w1 = __gsSP1Quadrangle_w1(v0, v1, v2, v3); \ -}} - -#define gsSP1Quadrangle(v0, v1, v2, v3, flag) \ -{{ \ - _SHIFTL(G_QUAD, 24, 8), \ - __gsSP1Quadrangle_w1(v0, v1, v2, v3) \ -}} -#else -/*** - *** 1 Quadrangle - ***/ -#define gSP1Quadrangle(pkt, v0, v1, v2, v3, flag) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_TRI2, 24, 8)| \ - __gsSP1Quadrangle_w1f(v0, v1, v2, v3, flag)); \ - _g->words.w1 = __gsSP1Quadrangle_w2f(v0, v1, v2, v3, flag); \ -} - -#define gsSP1Quadrangle(v0, v1, v2, v3, flag) \ -{{ \ - (_SHIFTL(G_TRI2, 24, 8)| \ - __gsSP1Quadrangle_w1f(v0, v1, v2, v3, flag)), \ - __gsSP1Quadrangle_w2f(v0, v1, v2, v3, flag) \ -}} -#endif -#endif /* F3DEX_GBI_2 */ - -#if (defined(F3DLP_GBI)||defined(F3DEX_GBI)) -/*** - *** 2 Triangles - ***/ -#define gSP2Triangles(pkt, v00, v01, v02, flag0, v10, v11, v12, flag1) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_TRI2, 24, 8)| \ - __gsSP1Triangle_w1f(v00, v01, v02, flag0)); \ - _g->words.w1 = __gsSP1Triangle_w1f(v10, v11, v12, flag1); \ -} - -#define gsSP2Triangles(v00, v01, v02, flag0, v10, v11, v12, flag1) \ -{{ \ - (_SHIFTL(G_TRI2, 24, 8)| \ - __gsSP1Triangle_w1f(v00, v01, v02, flag0)), \ - __gsSP1Triangle_w1f(v10, v11, v12, flag1) \ -}} -#else -#define gSP2Triangles(pkt, v00, v01, v02, flag0, v10, v11, v12, flag1) \ -{ \ - gSP1Triangle(pkt, v00, v01, v02, flag0); \ - gSP1Triangle(pkt, v10, v11, v12, flag1); \ -} -#define gsSP2Triangles(v00, v01, v02, flag0, v10, v11, v12, flag1) \ - gsSP1Triangle(v00, v01, v02, flag0), \ - gsSP1Triangle(v10, v11, v12, flag1) -#endif /* F3DEX_GBI/F3DLP_GBI */ - -#ifndef F3D_OLD -#if (defined(F3DEX_GBI)||defined(F3DLP_GBI)) -#define gSPCullDisplayList(pkt,vstart,vend) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(G_CULLDL, 24, 8) | \ - _SHIFTL((vstart)*2, 0, 16); \ - _g->words.w1 = _SHIFTL((vend)*2, 0, 16); \ -} - -#define gsSPCullDisplayList(vstart,vend) \ -{{ \ - _SHIFTL(G_CULLDL, 24, 8) | _SHIFTL((vstart)*2, 0, 16), \ - _SHIFTL((vend)*2, 0, 16) \ -}} -#endif -#else /* F3D_OLD */ -#define gSPCullDisplayList(pkt,vstart,vend) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(G_CULLDL, 24, 8) | \ - ((0x0f & (vstart))*40); \ - _g->words.w1 = (unsigned int)((0x0f & ((vend)+1))*40); \ -} - -#define gsSPCullDisplayList(vstart,vend) \ -{{ \ - _SHIFTL(G_CULLDL, 24, 8) | ((0x0f & (vstart))*40), \ - ((0x0f & ((vend)+1))*40) \ -}} -#endif - -#define gSPSegment(pkt, segment, base) \ - gMoveWd(pkt, G_MW_SEGMENT, (segment)*4, base) -#define gsSPSegment(segment, base) \ - gsMoveWd( G_MW_SEGMENT, (segment)*4, base) - -/* - * Clipping Macros - */ -#define FR_NEG_FRUSTRATIO_1 0x00000001 -#define FR_POS_FRUSTRATIO_1 0x0000ffff -#define FR_NEG_FRUSTRATIO_2 0x00000002 -#define FR_POS_FRUSTRATIO_2 0x0000fffe -#define FR_NEG_FRUSTRATIO_3 0x00000003 -#define FR_POS_FRUSTRATIO_3 0x0000fffd -#define FR_NEG_FRUSTRATIO_4 0x00000004 -#define FR_POS_FRUSTRATIO_4 0x0000fffc -#define FR_NEG_FRUSTRATIO_5 0x00000005 -#define FR_POS_FRUSTRATIO_5 0x0000fffb -#define FR_NEG_FRUSTRATIO_6 0x00000006 -#define FR_POS_FRUSTRATIO_6 0x0000fffa -/* - * r should be one of: FRUSTRATIO_1, FRUSTRATIO_2, FRUSTRATIO_3, ... FRUSTRATIO_6 - */ -#define gSPClipRatio(pkt, r) \ -{ \ - gMoveWd(pkt, G_MW_CLIP, G_MWO_CLIP_RNX, FR_NEG_##r); \ - gMoveWd(pkt, G_MW_CLIP, G_MWO_CLIP_RNY, FR_NEG_##r); \ - gMoveWd(pkt, G_MW_CLIP, G_MWO_CLIP_RPX, FR_POS_##r); \ - gMoveWd(pkt, G_MW_CLIP, G_MWO_CLIP_RPY, FR_POS_##r); \ -} - -#define gsSPClipRatio(r) \ - gsMoveWd(G_MW_CLIP, G_MWO_CLIP_RNX, FR_NEG_##r), \ - gsMoveWd(G_MW_CLIP, G_MWO_CLIP_RNY, FR_NEG_##r), \ - gsMoveWd(G_MW_CLIP, G_MWO_CLIP_RPX, FR_POS_##r), \ - gsMoveWd(G_MW_CLIP, G_MWO_CLIP_RPY, FR_POS_##r) - -/* - * Insert values into Matrix - * - * where = element of matrix (byte offset) - * num = new element (32 bit value replacing 2 int or 2 frac matrix - * componants - */ -#ifdef F3DEX_GBI_2 -#define gSPInsertMatrix(pkt, where, num) \ - ERROR!! gSPInsertMatrix is no longer supported. -#define gsSPInsertMatrix(where, num) \ - ERROR!! gsSPInsertMatrix is no longer supported. -#else -#define gSPInsertMatrix(pkt, where, num) \ - gMoveWd(pkt, G_MW_MATRIX, where, num) -#define gsSPInsertMatrix(where, num) \ - gsMoveWd(G_MW_MATRIX, where, num) -#endif - -/* - * Load new matrix directly - * - * mptr = pointer to matrix - */ -#ifdef F3DEX_GBI_2 -#define gSPForceMatrix(pkt, mptr) \ -{ gDma2p((pkt),G_MOVEMEM,(mptr),sizeof(Mtx),G_MV_MATRIX,0); \ - gMoveWd((pkt), G_MW_FORCEMTX,0,0x00010000); \ -} -#define gsSPForceMatrix(mptr) \ - gsDma2p(G_MOVEMEM,(mptr),sizeof(Mtx),G_MV_MATRIX,0), \ - gsMoveWd(G_MW_FORCEMTX,0,0x00010000) - -#else /* F3DEX_GBI_2 */ -#define gSPForceMatrix(pkt, mptr) \ -{ \ - gDma1p(pkt, G_MOVEMEM, mptr, 16, G_MV_MATRIX_1); \ - gDma1p(pkt, G_MOVEMEM, (char *)(mptr)+16, 16, G_MV_MATRIX_2); \ - gDma1p(pkt, G_MOVEMEM, (char *)(mptr)+32, 16, G_MV_MATRIX_3); \ - gDma1p(pkt, G_MOVEMEM, (char *)(mptr)+48, 16, G_MV_MATRIX_4); \ -} -#define gsSPForceMatrix(mptr) \ - gsDma1p( G_MOVEMEM, mptr, 16, G_MV_MATRIX_1), \ - gsDma1p( G_MOVEMEM, (char *)(mptr)+16, 16, G_MV_MATRIX_2), \ - gsDma1p( G_MOVEMEM, (char *)(mptr)+32, 16, G_MV_MATRIX_3), \ - gsDma1p( G_MOVEMEM, (char *)(mptr)+48, 16, G_MV_MATRIX_4) -#endif /* F3DEX_GBI_2 */ - -/* - * Insert values into Points - * - * point = point number 0-15 - * where = which element of point to modify (byte offset into point) - * num = new value (32 bit) - */ -#if (defined(F3DEX_GBI)||defined(F3DLP_GBI)) -# define gSPModifyVertex(pkt, vtx, where, val) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = (_SHIFTL(G_MODIFYVTX,24,8)| \ - _SHIFTL((where),16,8)|_SHIFTL((vtx)*2,0,16)); \ - _g->words.w1 = (unsigned int)(val); \ -} -# define gsSPModifyVertex(vtx, where, val) \ -{{ \ - _SHIFTL(G_MODIFYVTX,24,8)| \ - _SHIFTL((where),16,8)|_SHIFTL((vtx)*2,0,16), \ - (unsigned int)(val) \ -}} -#else -# define gSPModifyVertex(pkt, vtx, where, val) \ - gMoveWd(pkt, G_MW_POINTS, (vtx)*40+(where), val) -# define gsSPModifyVertex(vtx, where, val) \ - gsMoveWd(G_MW_POINTS, (vtx)*40+(where), val) -#endif - -#if (defined(F3DEX_GBI)||defined(F3DLP_GBI)) -/* - * gSPBranchLessZ Branch DL if (vtx.z) less than or equal (zval). - * - * dl = DL branch to - * vtx = Vertex - * zval = Screen depth - * near = Near plane - * far = Far plane - * flag = G_BZ_PERSP or G_BZ_ORTHO - */ - -#define G_BZ_PERSP 0 -#define G_BZ_ORTHO 1 - -#define G_DEPTOZSrg(zval, near, far, flag, zmin, zmax) \ -(((unsigned int)FTOFIX32(((flag) == G_BZ_PERSP ? \ - (1.0f-(float)(near)/(float)(zval)) / \ - (1.0f-(float)(near)/(float)(far )) : \ - ((float)(zval) - (float)(near)) / \ - ((float)(far ) - (float)(near))))) * \ - (((int)((zmax) - (zmin)))&~1) + (int)FTOFIX32(zmin)) - -#define G_DEPTOZS(zval, near, far, flag) \ - G_DEPTOZSrg(zval, near, far, flag, 0, G_MAXZ) - -#define gSPBranchLessZrg(pkt, dl, vtx, zval, near, far, flag, zmin, zmax) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_RDPHALF_1,24,8); \ - _g->words.w1 = (uintptr_t)(dl); \ - _g = (Gfx *)(pkt); \ - _g->words.w0 = (_SHIFTL(G_BRANCH_Z,24,8)| \ - _SHIFTL((vtx)*5,12,12)|_SHIFTL((vtx)*2,0,12)); \ - _g->words.w1 = G_DEPTOZSrg(zval, near, far, flag, zmin, zmax); \ -} - -#define gsSPBranchLessZrg(dl, vtx, zval, near, far, flag, zmin, zmax) \ -{{ _SHIFTL(G_RDPHALF_1,24,8), \ - (uintptr_t)(dl), }}, \ -{{ _SHIFTL(G_BRANCH_Z,24,8)|_SHIFTL((vtx)*5,12,12)|_SHIFTL((vtx)*2,0,12),\ - G_DEPTOZSrg(zval, near, far, flag, zmin, zmax), }} - -#define gSPBranchLessZ(pkt, dl, vtx, zval, near, far, flag) \ - gSPBranchLessZrg(pkt, dl, vtx, zval, near, far, flag, 0, G_MAXZ) -#define gsSPBranchLessZ(dl, vtx, zval, near, far, flag) \ - gsSPBranchLessZrg(dl, vtx, zval, near, far, flag, 0, G_MAXZ) - -/* - * gSPBranchLessZraw Branch DL if (vtx.z) less than or equal (raw zval). - * - * dl = DL branch to - * vtx = Vertex - * zval = Raw value of screen depth - */ -#define gSPBranchLessZraw(pkt, dl, vtx, zval) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_RDPHALF_1,24,8); \ - _g->words.w1 = (uintptr_t)(dl); \ - _g = (Gfx *)(pkt); \ - _g->words.w0 = (_SHIFTL(G_BRANCH_Z,24,8)| \ - _SHIFTL((vtx)*5,12,12)|_SHIFTL((vtx)*2,0,12)); \ - _g->words.w1 = (unsigned int)(zval); \ -} - -#define gsSPBranchLessZraw(dl, vtx, zval) \ -{{ _SHIFTL(G_RDPHALF_1,24,8), \ - (uintptr_t)(dl), }}, \ -{{ _SHIFTL(G_BRANCH_Z,24,8)|_SHIFTL((vtx)*5,12,12)|_SHIFTL((vtx)*2,0,12),\ - (unsigned int)(zval), }} - -/* - * gSPLoadUcode RSP loads specified ucode. - * - * uc_start = ucode text section start - * uc_dstart = ucode data section start - */ -#define gSPLoadUcodeEx(pkt, uc_start, uc_dstart, uc_dsize) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_RDPHALF_1,24,8); \ - _g->words.w1 = (uintptr_t)(uc_dstart); \ - _g = (Gfx *)(pkt); \ - _g->words.w0 = (_SHIFTL(G_LOAD_UCODE,24,8)| \ - _SHIFTL((int)(uc_dsize)-1,0,16)); \ - _g->words.w1 = (uintptr_t)(uc_start); \ -} - -#define gsSPLoadUcodeEx(uc_start, uc_dstart, uc_dsize) \ -{{ _SHIFTL(G_RDPHALF_1,24,8), \ - (uintptr_t)(uc_dstart), }}, \ -{{ _SHIFTL(G_LOAD_UCODE,24,8)| \ - _SHIFTL((int)(uc_dsize)-1,0,16), \ - (uintptr_t)(uc_start), }} - -#define gSPLoadUcode(pkt, uc_start, uc_dstart) \ - gSPLoadUcodeEx((pkt), (uc_start), (uc_dstart), SP_UCODE_DATA_SIZE) -#define gsSPLoadUcode(uc_start, uc_dstart) \ - gsSPLoadUcodeEx((uc_start), (uc_dstart), SP_UCODE_DATA_SIZE) - -#define gSPLoadUcodeL(pkt, ucode) \ - gSPLoadUcode((pkt), OS_K0_TO_PHYSICAL(&##ucode##TextStart), \ - OS_K0_TO_PHYSICAL(&##ucode##DataStart)) -#define gsSPLoadUcodeL(ucode) \ - gsSPLoadUcode(OS_K0_TO_PHYSICAL(&##ucode##TextStart), \ - OS_K0_TO_PHYSICAL(&##ucode##DataStart)) -#endif - -#ifdef F3DEX_GBI_2 -/* - * gSPDma_io DMA to/from DMEM/IMEM for DEBUG. - */ -#define gSPDma_io(pkt, flag, dmem, dram, size) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_DMA_IO,24,8)|_SHIFTL((flag),23,1)| \ - _SHIFTL((dmem)/8,13,10)|_SHIFTL((size)-1,0,12); \ - _g->words.w1 = (uintptr_t)(dram); \ -} - -#define gsSPDma_io(flag, dmem, dram, size) \ -{{ \ - _SHIFTL(G_DMA_IO,24,8)|_SHIFTL((flag),23,1)| \ - _SHIFTL((dmem)/8,13,10)|_SHIFTL((size)-1,0,12), \ - (uintptr_t)(dram) \ -}} - -#define gSPDmaRead(pkt,dmem,dram,size) gSPDma_io((pkt),0,(dmem),(dram),(size)) -#define gsSPDmaRead(dmem,dram,size) gsSPDma_io(0,(dmem),(dram),(size)) -#define gSPDmaWrite(pkt,dmem,dram,size) gSPDma_io((pkt),1,(dmem),(dram),(size)) -#define gsSPDmaWrite(dmem,dram,size) gsSPDma_io(1,(dmem),(dram),(size)) -#endif - -/* - * Lighting Macros - */ -#ifdef F3DEX_GBI_2 -# define NUML(n) ((n)*24) -#else -# define NUML(n) (((n)+1)*32 + 0x80000000) -#endif -#define NUMLIGHTS_0 1 -#define NUMLIGHTS_1 1 -#define NUMLIGHTS_2 2 -#define NUMLIGHTS_3 3 -#define NUMLIGHTS_4 4 -#define NUMLIGHTS_5 5 -#define NUMLIGHTS_6 6 -#define NUMLIGHTS_7 7 -/* - * n should be one of: NUMLIGHTS_0, NUMLIGHTS_1, ..., NUMLIGHTS_7 - * NOTE: in addition to the number of directional lights specified, - * there is always 1 ambient light - */ -#define gSPNumLights(pkt, n) \ - gMoveWd(pkt, G_MW_NUMLIGHT, G_MWO_NUMLIGHT, NUML(n)) -#define gsSPNumLights(n) \ - gsMoveWd( G_MW_NUMLIGHT, G_MWO_NUMLIGHT, NUML(n)) - -#define LIGHT_1 1 -#define LIGHT_2 2 -#define LIGHT_3 3 -#define LIGHT_4 4 -#define LIGHT_5 5 -#define LIGHT_6 6 -#define LIGHT_7 7 -#define LIGHT_8 8 -/* - * l should point to a Light struct - * n should be one of: LIGHT_1, LIGHT_2, ..., LIGHT_8 - * NOTE: the highest numbered light is always the ambient light (eg if there are - * 3 directional lights defined: gsSPNumLights(NUMLIGHTS_3), then lights - * LIGHT_1 through LIGHT_3 will be the directional lights and light - * LIGHT_4 will be the ambient light. - */ -#ifdef F3DEX_GBI_2 -# define gSPLight(pkt, l, n) \ - gDma2p((pkt),G_MOVEMEM,(l),sizeof(Light),G_MV_LIGHT,(n)*24+24) -# define gsSPLight(l, n) \ - gsDma2p( G_MOVEMEM,(l),sizeof(Light),G_MV_LIGHT,(n)*24+24) -#else /* F3DEX_GBI_2 */ -# define gSPLight(pkt, l, n) \ - gDma1p(pkt, G_MOVEMEM, l, sizeof(Light),((n)-1)*2+G_MV_L0) -# define gsSPLight(l, n) \ - gsDma1p( G_MOVEMEM, l, sizeof(Light),((n)-1)*2+G_MV_L0) -#endif /* F3DEX_GBI_2 */ - -/* - * gSPLightColor changes color of light without recalculating light direction - * col is a 32 bit word with r,g,b,a (alpha is ignored) - * n should be one of LIGHT_1, LIGHT_2, ..., LIGHT_8 - */ -#define gSPLightColor(pkt, n, col) \ -{ \ - gMoveWd(pkt, G_MW_LIGHTCOL, G_MWO_a##n, col); \ - gMoveWd(pkt, G_MW_LIGHTCOL, G_MWO_b##n, col); \ -} -#define gsSPLightColor(n, col) \ - gsMoveWd(G_MW_LIGHTCOL, G_MWO_a##n, col), \ - gsMoveWd(G_MW_LIGHTCOL, G_MWO_b##n, col) - -/* These macros use a structure "name" which is init'd with the gdSPDefLights macros*/ - -#define gSPSetLights0(pkt,name) \ -{ \ - gSPNumLights(pkt,NUMLIGHTS_0); \ - gSPLight(pkt,&name.l[0],1); \ - gSPLight(pkt,&name.a,2); \ -} -#define gsSPSetLights0(name) \ - gsSPNumLights(NUMLIGHTS_0), \ - gsSPLight(&name.l[0],1), \ - gsSPLight(&name.a,2) - -#define gSPSetLights1(pkt,name) \ -{ \ - gSPNumLights(pkt,NUMLIGHTS_1); \ - gSPLight(pkt,&name.l[0],1); \ - gSPLight(pkt,&name.a,2); \ -} -#define gsSPSetLights1(name) \ - gsSPNumLights(NUMLIGHTS_1), \ - gsSPLight(&name.l[0],1), \ - gsSPLight(&name.a,2) - -#define gSPSetLights2(pkt,name) \ -{ \ - gSPNumLights(pkt,NUMLIGHTS_2); \ - gSPLight(pkt,&name.l[0],1); \ - gSPLight(pkt,&name.l[1],2); \ - gSPLight(pkt,&name.a,3); \ -} -#define gsSPSetLights2(name) \ - gsSPNumLights(NUMLIGHTS_2), \ - gsSPLight(&name.l[0],1), \ - gsSPLight(&name.l[1],2), \ - gsSPLight(&name.a,3) - -#define gSPSetLights3(pkt,name) \ -{ \ - gSPNumLights(pkt,NUMLIGHTS_3); \ - gSPLight(pkt,&name.l[0],1); \ - gSPLight(pkt,&name.l[1],2); \ - gSPLight(pkt,&name.l[2],3); \ - gSPLight(pkt,&name.a,4); \ -} -#define gsSPSetLights3(name) \ - gsSPNumLights(NUMLIGHTS_3), \ - gsSPLight(&name.l[0],1), \ - gsSPLight(&name.l[1],2), \ - gsSPLight(&name.l[2],3), \ - gsSPLight(&name.a,4) - -#define gSPSetLights4(pkt,name) \ -{ \ - gSPNumLights(pkt,NUMLIGHTS_4); \ - gSPLight(pkt,&name.l[0],1); \ - gSPLight(pkt,&name.l[1],2); \ - gSPLight(pkt,&name.l[2],3); \ - gSPLight(pkt,&name.l[3],4); \ - gSPLight(pkt,&name.a,5); \ -} -#define gsSPSetLights4(name) \ - gsSPNumLights(NUMLIGHTS_4), \ - gsSPLight(&name.l[0],1), \ - gsSPLight(&name.l[1],2), \ - gsSPLight(&name.l[2],3), \ - gsSPLight(&name.l[3],4), \ - gsSPLight(&name.a,5) - -#define gSPSetLights5(pkt,name) \ -{ \ - gSPNumLights(pkt,NUMLIGHTS_5); \ - gSPLight(pkt,&name.l[0],1); \ - gSPLight(pkt,&name.l[1],2); \ - gSPLight(pkt,&name.l[2],3); \ - gSPLight(pkt,&name.l[3],4); \ - gSPLight(pkt,&name.l[4],5); \ - gSPLight(pkt,&name.a,6); \ -} - -#define gsSPSetLights5(name) \ - gsSPNumLights(NUMLIGHTS_5), \ - gsSPLight(&name.l[0],1), \ - gsSPLight(&name.l[1],2), \ - gsSPLight(&name.l[2],3), \ - gsSPLight(&name.l[3],4), \ - gsSPLight(&name.l[4],5), \ - gsSPLight(&name.a,6) - -#define gSPSetLights6(pkt,name) \ -{ \ - gSPNumLights(pkt,NUMLIGHTS_6); \ - gSPLight(pkt,&name.l[0],1); \ - gSPLight(pkt,&name.l[1],2); \ - gSPLight(pkt,&name.l[2],3); \ - gSPLight(pkt,&name.l[3],4); \ - gSPLight(pkt,&name.l[4],5); \ - gSPLight(pkt,&name.l[5],6); \ - gSPLight(pkt,&name.a,7); \ -} - -#define gsSPSetLights6(name) \ - gsSPNumLights(NUMLIGHTS_6), \ - gsSPLight(&name.l[0],1), \ - gsSPLight(&name.l[1],2), \ - gsSPLight(&name.l[2],3), \ - gsSPLight(&name.l[3],4), \ - gsSPLight(&name.l[4],5), \ - gsSPLight(&name.l[5],6), \ - gsSPLight(&name.a,7) - -#define gSPSetLights7(pkt,name) \ -{ \ - gSPNumLights(pkt,NUMLIGHTS_7); \ - gSPLight(pkt,&name.l[0],1); \ - gSPLight(pkt,&name.l[1],2); \ - gSPLight(pkt,&name.l[2],3); \ - gSPLight(pkt,&name.l[3],4); \ - gSPLight(pkt,&name.l[4],5); \ - gSPLight(pkt,&name.l[5],6); \ - gSPLight(pkt,&name.l[6],7); \ - gSPLight(pkt,&name.a,8); \ -} - -#define gsSPSetLights7(name) \ - gsSPNumLights(NUMLIGHTS_7), \ - gsSPLight(&name.l[0],1), \ - gsSPLight(&name.l[1],2), \ - gsSPLight(&name.l[2],3), \ - gsSPLight(&name.l[3],4), \ - gsSPLight(&name.l[4],5), \ - gsSPLight(&name.l[5],6), \ - gsSPLight(&name.l[6],7), \ - gsSPLight(&name.a,8) - -/* - * Reflection/Hiliting Macros - */ -#ifdef F3DEX_GBI_2 -# define gSPLookAtX(pkt, l) \ - gDma2p((pkt),G_MOVEMEM,(l),sizeof(Light),G_MV_LIGHT,G_MVO_LOOKATX) -# define gsSPLookAtX(l) \ - gsDma2p( G_MOVEMEM,(l),sizeof(Light),G_MV_LIGHT,G_MVO_LOOKATX) -# define gSPLookAtY(pkt, l) \ - gDma2p((pkt),G_MOVEMEM,(l),sizeof(Light),G_MV_LIGHT,G_MVO_LOOKATY) -# define gsSPLookAtY(l) \ - gsDma2p( G_MOVEMEM,(l),sizeof(Light),G_MV_LIGHT,G_MVO_LOOKATY) -#else /* F3DEX_GBI_2 */ -# define gSPLookAtX(pkt, l) \ - gDma1p(pkt, G_MOVEMEM, l, sizeof(Light),G_MV_LOOKATX) -# define gsSPLookAtX(l) \ - gsDma1p( G_MOVEMEM, l, sizeof(Light),G_MV_LOOKATX) -# define gSPLookAtY(pkt, l) \ - gDma1p(pkt, G_MOVEMEM, l, sizeof(Light),G_MV_LOOKATY) -# define gsSPLookAtY(l) \ - gsDma1p( G_MOVEMEM, l, sizeof(Light),G_MV_LOOKATY) -#endif /* F3DEX_GBI_2 */ - -#define gSPLookAt(pkt, la) \ -{ \ - gSPLookAtX(pkt,la) \ - gSPLookAtY(pkt,(char *)(la)+16) \ -} -#define gsSPLookAt(la) \ - gsSPLookAtX(la), \ - gsSPLookAtY((char *)(la)+16) - -#define gDPSetHilite1Tile(pkt, tile, hilite, width, height) \ - gDPSetTileSize(pkt, tile, (hilite)->h.x1 & 0xfff, (hilite)->h.y1 & 0xfff, \ - ((((width)-1)*4)+(hilite)->h.x1) & 0xfff, ((((height)-1)*4)+(hilite)->h.y1) & 0xfff) - -#define gDPSetHilite2Tile(pkt, tile, hilite, width, height) \ - gDPSetTileSize(pkt, tile, (hilite)->h.x2 & 0xfff, (hilite)->h.y2 & 0xfff, \ - ((((width)-1)*4)+(hilite)->h.x2) & 0xfff, ((((height)-1)*4)+(hilite)->h.y2) & 0xfff) - - -/* - * FOG macros - * fm = z multiplier - * fo = z offset - * FOG FORMULA: alpha(fog) = (eyespace z) * fm + fo CLAMPED 0 to 255 - * note: (eyespace z) ranges -1 to 1 - * - * Alternate method of setting fog: - * min, max: range 0 to 1000: 0=nearplane, 1000=farplane - * min is where fog begins (usually less than max and often 0) - * max is where fog is thickest (usually 1000) - * - */ -#define gSPFogFactor(pkt, fm, fo) \ - gMoveWd(pkt, G_MW_FOG, G_MWO_FOG, \ - (_SHIFTL(fm,16,16) | _SHIFTL(fo,0,16))) - -#define gsSPFogFactor(fm, fo) \ - gsMoveWd(G_MW_FOG, G_MWO_FOG, \ - (_SHIFTL(fm,16,16) | _SHIFTL(fo,0,16))) - -#define gSPFogPosition(pkt, min, max) \ - gMoveWd(pkt, G_MW_FOG, G_MWO_FOG, \ - (_SHIFTL((128000/((max)-(min))),16,16) | \ - _SHIFTL(((500-(min))*256/((max)-(min))),0,16))) - -#define gsSPFogPosition(min, max) \ - gsMoveWd(G_MW_FOG, G_MWO_FOG, \ - (_SHIFTL((128000/((max)-(min))),16,16) | \ - _SHIFTL(((500-(min))*256/((max)-(min))),0,16))) - -#ifdef F3DEX_GBI_2 -/* - * Macros to turn texture on/off - */ -# define gSPTexture(pkt, s, t, level, tile, on) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_TEXTURE,24,8) | \ - _SHIFTL(BOWTIE_VAL,16,8) | \ - _SHIFTL((level),11,3) | _SHIFTL((tile),8,3) | \ - _SHIFTL((on),1,7)); \ - _g->words.w1 = (_SHIFTL((s),16,16) | _SHIFTL((t),0,16)); \ -} -# define gsSPTexture(s, t, level, tile, on) \ -{{ \ - (_SHIFTL(G_TEXTURE,24,8) | _SHIFTL(BOWTIE_VAL,16,8) | \ - _SHIFTL((level),11,3) | _SHIFTL((tile),8,3) | _SHIFTL((on),1,7)),\ - (_SHIFTL((s),16,16) | _SHIFTL((t),0,16)) \ -}} -/* - * Different version of SPTexture macro, has an additional parameter - * which is currently reserved in the microcode. - */ -# define gSPTextureL(pkt, s, t, level, xparam, tile, on) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_TEXTURE,24,8) | \ - _SHIFTL((xparam),16,8) | \ - _SHIFTL((level),11,3) | _SHIFTL((tile),8,3) | \ - _SHIFTL((on),1,7)); \ - _g->words.w1 = (_SHIFTL((s),16,16) | _SHIFTL((t),0,16)); \ -} -# define gsSPTextureL(s, t, level, xparam, tile, on) \ -{{ \ - (_SHIFTL(G_TEXTURE,24,8) | _SHIFTL((xparam),16,8) | \ - _SHIFTL((level),11,3) | _SHIFTL((tile),8,3) | _SHIFTL((on),1,7)),\ - (_SHIFTL((s),16,16) | _SHIFTL((t),0,16)) \ -}} -#else -/* - * Macros to turn texture on/off - */ -# define gSPTexture(pkt, s, t, level, tile, on) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_TEXTURE,24,8)|_SHIFTL(BOWTIE_VAL,16,8)|\ - _SHIFTL((level),11,3)|_SHIFTL((tile),8,3)| \ - _SHIFTL((on),0,8)); \ - _g->words.w1 = (_SHIFTL((s),16,16)|_SHIFTL((t),0,16)); \ -} -# define gsSPTexture(s, t, level, tile, on) \ -{{ \ - (_SHIFTL(G_TEXTURE,24,8)|_SHIFTL(BOWTIE_VAL,16,8)| \ - _SHIFTL((level),11,3)|_SHIFTL((tile),8,3)|_SHIFTL((on),0,8)), \ - (_SHIFTL((s),16,16)|_SHIFTL((t),0,16)) \ -}} -/* - * Different version of SPTexture macro, has an additional parameter - * which is currently reserved in the microcode. - */ -# define gSPTextureL(pkt, s, t, level, xparam, tile, on) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_TEXTURE,24,8)|_SHIFTL((xparam),16,8)| \ - _SHIFTL((level),11,3)|_SHIFTL((tile),8,3)| \ - _SHIFTL((on),0,8)); \ - _g->words.w1 = (_SHIFTL((s),16,16)|_SHIFTL((t),0,16)); \ -} -# define gsSPTextureL(s, t, level, xparam, tile, on) \ -{{ \ - (_SHIFTL(G_TEXTURE,24,8)|_SHIFTL((xparam),16,8)| \ - _SHIFTL((level),11,3)|_SHIFTL((tile),8,3)|_SHIFTL((on),0,8)), \ - (_SHIFTL((s),16,16)|_SHIFTL((t),0,16)) \ -}} -#endif - -#ifndef F3D_OLD -# define gSPPerspNormalize(pkt, s) gMoveWd(pkt, G_MW_PERSPNORM, 0, (s)) -# define gsSPPerspNormalize(s) gsMoveWd( G_MW_PERSPNORM, 0, (s)) -#else -# define gSPPerspNormalize(pkt, s) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(G_RDPHALF_1, 24, 8); \ - _g->words.w1 = (s); \ -} -# define gsSPPerspNormalize(s) \ -{{ \ - _SHIFTL(G_RDPHALF_1, 24, 8), \ - (s) \ -}} -#endif - -#ifdef F3DEX_GBI_2 -# define gSPPopMatrixN(pkt, n, num) gDma2p((pkt),G_POPMTX,(num)*64,64,2,0) -# define gsSPPopMatrixN(n, num) gsDma2p( G_POPMTX,(num)*64,64,2,0) -# define gSPPopMatrix(pkt, n) gSPPopMatrixN((pkt), (n), 1) -# define gsSPPopMatrix(n) gsSPPopMatrixN( (n), 1) -#else /* F3DEX_GBI_2 */ -# define gSPPopMatrix(pkt, n) gImmp1(pkt, G_POPMTX, n) -# define gsSPPopMatrix(n) gsImmp1( G_POPMTX, n) -#endif /* F3DEX_GBI_2 */ - -#define gSPEndDisplayList(pkt) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(G_ENDDL, 24, 8); \ - _g->words.w1 = 0; \ -} - -#define gsSPEndDisplayList() \ -{{ \ - _SHIFTL(G_ENDDL, 24, 8), 0 \ -}} - -#ifdef F3DEX_GBI_2 -/* - * One gSPGeometryMode(pkt,c,s) GBI is equal to these two GBIs. - * - * gSPClearGeometryMode(pkt,c) - * gSPSetGeometryMode(pkt,s) - * - * gSPLoadGeometryMode(pkt, word) sets GeometryMode directly. - */ -#define gSPGeometryMode(pkt, c, s) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_GEOMETRYMODE,24,8)|_SHIFTL(~(u32)(c),0,24);\ - _g->words.w1 = (u32)(s); \ -} - -#define gsSPGeometryMode(c, s) \ -{{ \ - (_SHIFTL(G_GEOMETRYMODE,24,8)|_SHIFTL(~(u32)(c),0,24)),(u32)(s) \ -}} -#define gSPSetGeometryMode(pkt, word) gSPGeometryMode((pkt),0,(word)) -#define gsSPSetGeometryMode(word) gsSPGeometryMode(0,(word)) -#define gSPClearGeometryMode(pkt, word) gSPGeometryMode((pkt),(word),0) -#define gsSPClearGeometryMode(word) gsSPGeometryMode((word),0) -#define gSPLoadGeometryMode(pkt, word) gSPGeometryMode((pkt),-1,(word)) -#define gsSPLoadGeometryMode(word) gsSPGeometryMode(-1,(word)) -#define gsSPGeometryModeSetFirst(c, s) gsSPGeometryMode(c, s) -#else /* F3DEX_GBI_2 */ -#define gSPSetGeometryMode(pkt, word) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(G_SETGEOMETRYMODE, 24, 8); \ - _g->words.w1 = (unsigned int)(word); \ -} - -#define gsSPSetGeometryMode(word) \ -{{ \ - _SHIFTL(G_SETGEOMETRYMODE, 24, 8), (unsigned int)(word) \ -}} - -#define gSPClearGeometryMode(pkt, word) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(G_CLEARGEOMETRYMODE, 24, 8); \ - _g->words.w1 = (unsigned int)(word); \ -} - -#define gsSPClearGeometryMode(word) \ -{{ \ - _SHIFTL(G_CLEARGEOMETRYMODE, 24, 8), (unsigned int)(word) \ -}} - -/* - * gsSPGeometryMode - * In Fast3DEX2 it is better to use this, as the RSP geometry mode - * is able to be set and cleared in a single command. - */ -#define gsSPGeometryMode(c, s) \ - gsSPClearGeometryMode(c), \ - gsSPSetGeometryMode(s) -#define gsSPGeometryModeSetFirst(c, s) \ - gsSPSetGeometryMode(s), \ - gsSPClearGeometryMode(c) -#endif /* F3DEX_GBI_2 */ - -#ifdef F3DEX_GBI_2 -#define gSPSetOtherMode(pkt, cmd, sft, len, data) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = (_SHIFTL(cmd,24,8)|_SHIFTL(32-(sft)-(len),8,8)| \ - _SHIFTL((len)-1,0,8)); \ - _g->words.w1 = (unsigned int)(data); \ -} - -#define gsSPSetOtherMode(cmd, sft, len, data) \ -{{ \ - _SHIFTL(cmd,24,8)|_SHIFTL(32-(sft)-(len),8,8)|_SHIFTL((len)-1,0,8), \ - (unsigned int)(data) \ -}} -#else -#define gSPSetOtherMode(pkt, cmd, sft, len, data) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(cmd, 24, 8) | _SHIFTL(sft, 8, 8) | \ - _SHIFTL(len, 0, 8)); \ - _g->words.w1 = (unsigned int)(data); \ -} - -#define gsSPSetOtherMode(cmd, sft, len, data) \ -{{ \ - _SHIFTL(cmd, 24, 8) | _SHIFTL(sft, 8, 8) | _SHIFTL(len, 0, 8), \ - (unsigned int)(data) \ -}} -#endif - -/* - * RDP setothermode register commands - register shadowed in RSP - */ -#define gDPPipelineMode(pkt, mode) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_PIPELINE, 1, mode) -#define gsDPPipelineMode(mode) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_PIPELINE, 1, mode) - -#define gDPSetCycleType(pkt, type) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_CYCLETYPE, 2, type) -#define gsDPSetCycleType(type) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_CYCLETYPE, 2, type) - -#define gDPSetTexturePersp(pkt, type) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_TEXTPERSP, 1, type) -#define gsDPSetTexturePersp(type) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_TEXTPERSP, 1, type) - -#define gDPSetTextureDetail(pkt, type) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_TEXTDETAIL, 2, type) -#define gsDPSetTextureDetail(type) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_TEXTDETAIL, 2, type) - -#define gDPSetTextureLOD(pkt, type) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_TEXTLOD, 1, type) -#define gsDPSetTextureLOD(type) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_TEXTLOD, 1, type) - -#define gDPSetTextureLUT(pkt, type) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_TEXTLUT, 2, type) -#define gsDPSetTextureLUT(type) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_TEXTLUT, 2, type) - -#define gDPSetTextureFilter(pkt, type) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_TEXTFILT, 2, type) -#define gsDPSetTextureFilter(type) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_TEXTFILT, 2, type) - -#define gDPSetTextureConvert(pkt, type) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_TEXTCONV, 3, type) -#define gsDPSetTextureConvert(type) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_TEXTCONV, 3, type) - -#define gDPSetCombineKey(pkt, type) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_COMBKEY, 1, type) -#define gsDPSetCombineKey(type) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_COMBKEY, 1, type) - -#ifndef _HW_VERSION_1 -#define gDPSetColorDither(pkt, mode) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_RGBDITHER, 2, mode) -#define gsDPSetColorDither(mode) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_RGBDITHER, 2, mode) -#else -#define gDPSetColorDither(pkt, mode) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_COLORDITHER, 1, mode) -#define gsDPSetColorDither(mode) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_COLORDITHER, 1, mode) -#endif - -#ifndef _HW_VERSION_1 -#define gDPSetAlphaDither(pkt, mode) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_ALPHADITHER, 2, mode) -#define gsDPSetAlphaDither(mode) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_ALPHADITHER, 2, mode) -#endif - -/* 'blendmask' is not supported anymore. - * The bits are reserved for future use. - * Fri May 26 13:45:55 PDT 1995 - */ -#define gDPSetBlendMask(pkt, mask) gDPNoOp(pkt) -#define gsDPSetBlendMask(mask) gsDPNoOp() - -#define gDPSetAlphaCompare(pkt, type) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_L, G_MDSFT_ALPHACOMPARE, 2, type) -#define gsDPSetAlphaCompare(type) \ - gsSPSetOtherMode(G_SETOTHERMODE_L, G_MDSFT_ALPHACOMPARE, 2, type) - -#define gDPSetDepthSource(pkt, src) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_L, G_MDSFT_ZSRCSEL, 1, src) -#define gsDPSetDepthSource(src) \ - gsSPSetOtherMode(G_SETOTHERMODE_L, G_MDSFT_ZSRCSEL, 1, src) - -#define gDPSetRenderMode(pkt, c0, c1) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_L, G_MDSFT_RENDERMODE, 29, \ - (c0) | (c1)) -#define gsDPSetRenderMode(c0, c1) \ - gsSPSetOtherMode(G_SETOTHERMODE_L, G_MDSFT_RENDERMODE, 29, \ - (c0) | (c1)) - -#define gSetImage(pkt, cmd, fmt, siz, width, i) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(cmd, 24, 8) | _SHIFTL(fmt, 21, 3) | \ - _SHIFTL(siz, 19, 2) | _SHIFTL((width)-1, 0, 12); \ - _g->words.w1 = (uintptr_t)(i); \ -} - -#define gsSetImage(cmd, fmt, siz, width, i) \ -{{ \ - _SHIFTL(cmd, 24, 8) | _SHIFTL(fmt, 21, 3) | \ - _SHIFTL(siz, 19, 2) | _SHIFTL((width)-1, 0, 12), \ - (uintptr_t)(i) \ -}} - -#define gDPSetColorImage(pkt, f, s, w, i) gSetImage(pkt, G_SETCIMG, f, s, w, i) -#define gsDPSetColorImage(f, s, w, i) gsSetImage(G_SETCIMG, f, s, w, i) - - -/* use these for new code */ -#define gDPSetDepthImage(pkt, i) gSetImage(pkt, G_SETZIMG, 0, 0, 1, i) -#define gsDPSetDepthImage(i) gsSetImage(G_SETZIMG, 0, 0, 1, i) -/* kept for compatibility */ -#define gDPSetMaskImage(pkt, i) gDPSetDepthImage(pkt, i) -#define gsDPSetMaskImage(i) gsDPSetDepthImage(i) - -#define gDPSetTextureImage(pkt, f, s, w, i) gSetImage(pkt, G_SETTIMG, f, s, w, i) -#define gsDPSetTextureImage(f, s, w, i) gsSetImage(G_SETTIMG, f, s, w, i) - -/* - * RDP macros - */ - -#define gDPSetCombine(pkt, muxs0, muxs1) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(G_SETCOMBINE, 24, 8) | _SHIFTL(muxs0, 0, 24);\ - _g->words.w1 = (unsigned int)(muxs1); \ -} - -#define gsDPSetCombine(muxs0, muxs1) \ -{{ \ - _SHIFTL(G_SETCOMBINE, 24, 8) | _SHIFTL(muxs0, 0, 24), \ - (unsigned int)(muxs1) \ -}} - -#define GCCc0w0(saRGB0, mRGB0, saA0, mA0) \ - (_SHIFTL((saRGB0), 20, 4) | _SHIFTL((mRGB0), 15, 5) | \ - _SHIFTL((saA0), 12, 3) | _SHIFTL((mA0), 9, 3)) - -#define GCCc1w0(saRGB1, mRGB1) \ - (_SHIFTL((saRGB1), 5, 4) | _SHIFTL((mRGB1), 0, 5)) - -#define GCCc0w1(sbRGB0, aRGB0, sbA0, aA0) \ - (_SHIFTL((sbRGB0), 28, 4) | _SHIFTL((aRGB0), 15, 3) | \ - _SHIFTL((sbA0), 12, 3) | _SHIFTL((aA0), 9, 3)) - -#define GCCc1w1(sbRGB1, saA1, mA1, aRGB1, sbA1, aA1) \ - (_SHIFTL((sbRGB1), 24, 4) | _SHIFTL((saA1), 21, 3) | \ - _SHIFTL((mA1), 18, 3) | _SHIFTL((aRGB1), 6, 3) | \ - _SHIFTL((sbA1), 3, 3) | _SHIFTL((aA1), 0, 3)) - -#define gDPSetCombineLERP(pkt, a0, b0, c0, d0, Aa0, Ab0, Ac0, Ad0, \ - a1, b1, c1, d1, Aa1, Ab1, Ac1, Ad1) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(G_SETCOMBINE, 24, 8) | \ - _SHIFTL(GCCc0w0(G_CCMUX_##a0, G_CCMUX_##c0, \ - G_ACMUX_##Aa0, G_ACMUX_##Ac0) | \ - GCCc1w0(G_CCMUX_##a1, G_CCMUX_##c1), \ - 0, 24); \ - _g->words.w1 = (unsigned int)(GCCc0w1(G_CCMUX_##b0, \ - G_CCMUX_##d0, \ - G_ACMUX_##Ab0, \ - G_ACMUX_##Ad0) | \ - GCCc1w1(G_CCMUX_##b1, \ - G_ACMUX_##Aa1, \ - G_ACMUX_##Ac1, \ - G_CCMUX_##d1, \ - G_ACMUX_##Ab1, \ - G_ACMUX_##Ad1)); \ -} - -#define gsDPSetCombineLERP(a0, b0, c0, d0, Aa0, Ab0, Ac0, Ad0, \ - a1, b1, c1, d1, Aa1, Ab1, Ac1, Ad1) \ -{{ \ - _SHIFTL(G_SETCOMBINE, 24, 8) | \ - _SHIFTL(GCCc0w0(G_CCMUX_##a0, G_CCMUX_##c0, \ - G_ACMUX_##Aa0, G_ACMUX_##Ac0) | \ - GCCc1w0(G_CCMUX_##a1, G_CCMUX_##c1), 0, 24), \ - (unsigned int)(GCCc0w1(G_CCMUX_##b0, G_CCMUX_##d0, \ - G_ACMUX_##Ab0, G_ACMUX_##Ad0) | \ - GCCc1w1(G_CCMUX_##b1, G_ACMUX_##Aa1, \ - G_ACMUX_##Ac1, G_CCMUX_##d1, \ - G_ACMUX_##Ab1, G_ACMUX_##Ad1)) \ -}} - -/* - * SetCombineMode macros are NOT redunant. It allow the C preprocessor - * to substitute single parameter which includes commas in the token and - * rescan for higher parameter count macro substitution. - * - * eg. gsDPSetCombineMode(G_CC_MODULATE, G_CC_MODULATE) turns into - * gsDPSetCombineLERP(TEXEL0, 0, SHADE, 0, TEXEL0, 0, SHADE, 0, - * TEXEL0, 0, SHADE, 0, TEXEL0, 0, SHADE, 0) - */ - -#define gDPSetCombineMode(pkt, a, b) gDPSetCombineLERP(pkt, a, b) -#define gsDPSetCombineMode(a, b) gsDPSetCombineLERP(a, b) - -#define gDPSetColor(pkt, c, d) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(c, 24, 8); \ - _g->words.w1 = (unsigned int)(d); \ -} - -#define gsDPSetColor(c, d) \ -{{ \ - _SHIFTL(c, 24, 8), (unsigned int)(d) \ -}} - -#define DPRGBColor(pkt, cmd, r, g, b, a) \ - gDPSetColor(pkt, cmd, \ - (_SHIFTL(r, 24, 8) | _SHIFTL(g, 16, 8) | \ - _SHIFTL(b, 8, 8) | _SHIFTL(a, 0, 8))) -#define sDPRGBColor(cmd, r, g, b, a) \ - gsDPSetColor(cmd, \ - (_SHIFTL(r, 24, 8) | _SHIFTL(g, 16, 8) | \ - _SHIFTL(b, 8, 8) | _SHIFTL(a, 0, 8))) - -#define gDPSetEnvColor(pkt, r, g, b, a) \ - DPRGBColor(pkt, G_SETENVCOLOR, r,g,b,a) -#define gsDPSetEnvColor(r, g, b, a) \ - sDPRGBColor(G_SETENVCOLOR, r,g,b,a) -#define gDPSetBlendColor(pkt, r, g, b, a) \ - DPRGBColor(pkt, G_SETBLENDCOLOR, r,g,b,a) -#define gsDPSetBlendColor(r, g, b, a) \ - sDPRGBColor(G_SETBLENDCOLOR, r,g,b,a) -#define gDPSetFogColor(pkt, r, g, b, a) \ - DPRGBColor(pkt, G_SETFOGCOLOR, r,g,b,a) -#define gsDPSetFogColor(r, g, b, a) \ - sDPRGBColor(G_SETFOGCOLOR, r,g,b,a) -#define gDPSetFillColor(pkt, d) \ - gDPSetColor(pkt, G_SETFILLCOLOR, (d)) -#define gsDPSetFillColor(d) \ - gsDPSetColor(G_SETFILLCOLOR, (d)) - -#define gDPSetPrimDepth(pkt, z, dz) \ - gDPSetColor(pkt, G_SETPRIMDEPTH, \ - _SHIFTL(z, 16, 16) | _SHIFTL(dz, 0, 16)) -#define gsDPSetPrimDepth(z, dz) \ - gsDPSetColor(G_SETPRIMDEPTH, _SHIFTL(z, 16, 16) | \ - _SHIFTL(dz, 0, 16)) - -#define gDPSetPrimColor(pkt, m, l, r, g, b, a) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_SETPRIMCOLOR, 24, 8) | \ - _SHIFTL(m, 8, 8) | _SHIFTL(l, 0, 8)); \ - _g->words.w1 = (_SHIFTL(r, 24, 8) | _SHIFTL(g, 16, 8) | \ - _SHIFTL(b, 8, 8) | _SHIFTL(a, 0, 8)); \ -} - -#define gsDPSetPrimColor(m, l, r, g, b, a) \ -{{ \ - (_SHIFTL(G_SETPRIMCOLOR, 24, 8) | _SHIFTL(m, 8, 8) | \ - _SHIFTL(l, 0, 8)), \ - (_SHIFTL(r, 24, 8) | _SHIFTL(g, 16, 8) | _SHIFTL(b, 8, 8) | \ - _SHIFTL(a, 0, 8)) \ -}} - -/* - * gDPSetOtherMode (This is for expert user.) - * - * This command makes all othermode parameters set. - * Do not use this command in the same DL with another g*SPSetOtherMode DLs. - * - * [Usage] - * gDPSetOtherMode(pkt, modeA, modeB) - * - * 'modeA' is described all parameters of GroupA GBI command. - * 'modeB' is also described all parameters of GroupB GBI command. - * - * GroupA: - * gDPPipelineMode, gDPSetCycleType, gSPSetTexturePersp, - * gDPSetTextureDetail, gDPSetTextureLOD, gDPSetTextureLUT, - * gDPSetTextureFilter, gDPSetTextureConvert, gDPSetCombineKey, - * gDPSetColorDither, gDPSetAlphaDither - * - * GroupB: - * gDPSetAlphaCompare, gDPSetDepthSource, gDPSetRenderMode - * - * Use 'OR' operation to get modeA and modeB. - * - * modeA = G_PM_* | G_CYC_* | G_TP_* | G_TD_* | G_TL_* | G_TT_* | G_TF_* - * G_TC_* | G_CK_* | G_CD_* | G_AD_*; - * - * modeB = G_AC_* | G_ZS_* | G_RM_* | G_RM_*2; - */ -#define gDPSetOtherMode(pkt, mode0, mode1) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(G_RDPSETOTHERMODE,24,8)|_SHIFTL(mode0,0,24);\ - _g->words.w1 = (unsigned int)(mode1); \ -} - -#define gsDPSetOtherMode(mode0, mode1) \ -{{ \ - _SHIFTL(G_RDPSETOTHERMODE,24,8)|_SHIFTL(mode0,0,24), \ - (unsigned int)(mode1) \ -}} - -/* - * Texturing macros - */ - -/* These are also defined defined above for Sprite Microcode */ - -#define G_TX_LOADTILE 7 -#define G_TX_RENDERTILE 0 - -#define G_TX_NOMIRROR 0 -#define G_TX_WRAP 0 -#define G_TX_MIRROR 0x1 -#define G_TX_CLAMP 0x2 -#define G_TX_NOMASK 0 -#define G_TX_NOLOD 0 - - -#ifndef MAX -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#endif - -#ifndef MIN -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#endif -/* - * Dxt is the inverse of the number of 64-bit words in a line of - * the texture being loaded using the load_block command. If - * there are any 1's to the right of the 11th fractional bit, - * dxt should be rounded up. The following macros accomplish - * this. The 4b macros are a special case since 4-bit textures - * are loaded as 8-bit textures. Dxt is fixed point 1.11. RJM - */ -#define G_TX_DXT_FRAC 11 - -/* - * For RCP 2.0, the maximum number of texels that can be loaded - * using a load_block command is 2048. In order to load the total - * 4kB of Tmem, change the texel size when loading to be G_IM_SIZ_16b, - * then change the tile to the proper texel size after the load. - * The g*DPLoadTextureBlock macros already do this, so this change - * will be transparent if you use these macros. If you use - * the g*DPLoadBlock macros directly, you will need to handle this - * tile manipulation yourself. RJM. - */ -#ifdef _HW_VERSION_1 -#define G_TX_LDBLK_MAX_TXL 4095 -#else -#define G_TX_LDBLK_MAX_TXL 2047 -#endif /* _HW_VERSION_1 */ - -#define TXL2WORDS(txls, b_txl) MAX(1, ((txls)*(b_txl)/8)) -#define CALC_DXT(width, b_txl) \ - (((1 << G_TX_DXT_FRAC) + TXL2WORDS(width, b_txl) - 1) / \ - TXL2WORDS(width, b_txl)) - -#define TXL2WORDS_4b(txls) MAX(1, ((txls)/16)) -#define CALC_DXT_4b(width) \ - (((1 << G_TX_DXT_FRAC) + TXL2WORDS_4b(width) - 1) / \ - TXL2WORDS_4b(width)) - -#define gDPLoadTileGeneric(pkt, c, tile, uls, ult, lrs, lrt) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(c, 24, 8) | _SHIFTL(uls, 12, 12) | \ - _SHIFTL(ult, 0, 12); \ - _g->words.w1 = _SHIFTL(tile, 24, 3) | _SHIFTL(lrs, 12, 12) | \ - _SHIFTL(lrt, 0, 12); \ -} - -#define gsDPLoadTileGeneric(c, tile, uls, ult, lrs, lrt) \ -{{ \ - _SHIFTL(c, 24, 8) | _SHIFTL(uls, 12, 12) | _SHIFTL(ult, 0, 12), \ - _SHIFTL(tile, 24, 3) | _SHIFTL(lrs, 12, 12) | _SHIFTL(lrt, 0, 12)\ -}} - -#define gDPSetTileSize(pkt, t, uls, ult, lrs, lrt) \ - gDPLoadTileGeneric(pkt, G_SETTILESIZE, t, uls, ult, lrs, lrt) -#define gsDPSetTileSize(t, uls, ult, lrs, lrt) \ - gsDPLoadTileGeneric(G_SETTILESIZE, t, uls, ult, lrs, lrt) -#define gDPLoadTile(pkt, t, uls, ult, lrs, lrt) \ - gDPLoadTileGeneric(pkt, G_LOADTILE, t, uls, ult, lrs, lrt) -#define gsDPLoadTile(t, uls, ult, lrs, lrt) \ - gsDPLoadTileGeneric(G_LOADTILE, t, uls, ult, lrs, lrt) - -#define gDPSetTile(pkt, fmt, siz, line, tmem, tile, palette, cmt, \ - maskt, shiftt, cms, masks, shifts) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(G_SETTILE, 24, 8) | _SHIFTL(fmt, 21, 3) |\ - _SHIFTL(siz, 19, 2) | _SHIFTL(line, 9, 9) | \ - _SHIFTL(tmem, 0, 9); \ - _g->words.w1 = _SHIFTL(tile, 24, 3) | _SHIFTL(palette, 20, 4) | \ - _SHIFTL(cmt, 18, 2) | _SHIFTL(maskt, 14, 4) | \ - _SHIFTL(shiftt, 10, 4) |_SHIFTL(cms, 8, 2) | \ - _SHIFTL(masks, 4, 4) | _SHIFTL(shifts, 0, 4); \ -} - -#define gsDPSetTile(fmt, siz, line, tmem, tile, palette, cmt, \ - maskt, shiftt, cms, masks, shifts) \ -{{ \ - (_SHIFTL(G_SETTILE, 24, 8) | _SHIFTL(fmt, 21, 3) | \ - _SHIFTL(siz, 19, 2) | _SHIFTL(line, 9, 9) | _SHIFTL(tmem, 0, 9)),\ - (_SHIFTL(tile, 24, 3) | _SHIFTL(palette, 20, 4) | \ - _SHIFTL(cmt, 18, 2) | _SHIFTL(maskt, 14, 4) | \ - _SHIFTL(shiftt, 10, 4) | _SHIFTL(cms, 8, 2) | \ - _SHIFTL(masks, 4, 4) | _SHIFTL(shifts, 0, 4)) \ -}} - -/* - * For RCP 2.0, the maximum number of texels that can be loaded - * using a load_block command is 2048. In order to load the total - * 4kB of Tmem, change the texel size when loading to be G_IM_SIZ_16b, - * then change the tile to the proper texel size after the load. - * The g*DPLoadTextureBlock macros already do this, so this change - * will be transparent if you use these macros. If you use - * the g*DPLoadBlock macros directly, you will need to handle this - * tile manipulation yourself. RJM. - */ -#define gDPLoadBlock(pkt, tile, uls, ult, lrs, dxt) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_LOADBLOCK, 24, 8) | \ - _SHIFTL(uls, 12, 12) | _SHIFTL(ult, 0, 12)); \ - _g->words.w1 = (_SHIFTL(tile, 24, 3) | \ - _SHIFTL((MIN(lrs,G_TX_LDBLK_MAX_TXL)), 12, 12) |\ - _SHIFTL(dxt, 0, 12)); \ -} - -#define gsDPLoadBlock(tile, uls, ult, lrs, dxt) \ -{{ \ - (_SHIFTL(G_LOADBLOCK, 24, 8) | _SHIFTL(uls, 12, 12) | \ - _SHIFTL(ult, 0, 12)), \ - (_SHIFTL(tile, 24, 3) | \ - _SHIFTL((MIN(lrs,G_TX_LDBLK_MAX_TXL)), 12, 12) | \ - _SHIFTL(dxt, 0, 12)) \ -}} - -#define gDPLoadTLUTCmd(pkt, tile, count) \ -{ \ - Gfx *_g = (Gfx *)pkt; \ - \ - _g->words.w0 = _SHIFTL(G_LOADTLUT, 24, 8); \ - _g->words.w1 = _SHIFTL((tile), 24, 3) | _SHIFTL((count), 14, 10);\ -} - -#define gsDPLoadTLUTCmd(tile, count) \ -{{ \ - _SHIFTL(G_LOADTLUT, 24, 8), \ - _SHIFTL((tile), 24, 3) | _SHIFTL((count), 14, 10) \ -}} - -#define gDPLoadTextureBlock(pkt, timg, fmt, siz, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ - gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \ - gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, 0, G_TX_LOADTILE, \ - 0 , cmt, maskt, shiftt, cms, masks, shifts); \ - gDPLoadSync(pkt); \ - gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ - (((width)*(height) + siz##_INCR) >> siz##_SHIFT) -1, \ - CALC_DXT(width, siz##_BYTES)); \ - gDPPipeSync(pkt); \ - gDPSetTile(pkt, fmt, siz, \ - (((width) * siz##_LINE_BYTES)+7)>>3, 0, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ -} - -#define gDPLoadTextureBlockYuv(pkt, timg, fmt, siz, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ - gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \ - gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, 0, G_TX_LOADTILE, \ - 0 , cmt, maskt, shiftt, cms, masks, shifts); \ - gDPLoadSync(pkt); \ - gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ - (((width)*(height) + siz##_INCR) >> siz##_SHIFT) -1, \ - CALC_DXT(width, siz##_BYTES)); \ - gDPPipeSync(pkt); \ - gDPSetTile(pkt, fmt, siz, \ - (((width) * 1)+7)>>3, 0, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ -} - -/* Load fix rww 27jun95 */ -/* The S at the end means odd lines are already word Swapped */ - -#define gDPLoadTextureBlockS(pkt, timg, fmt, siz, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ - gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \ - gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, 0, G_TX_LOADTILE, \ - 0 , cmt, maskt, shiftt, cms, masks, shifts); \ - gDPLoadSync(pkt); \ - gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ - (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1,0); \ - gDPPipeSync(pkt); \ - gDPSetTile(pkt, fmt, siz, \ - (((width) * siz##_LINE_BYTES)+7)>>3, 0, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ -} - -/* - * Allow tmem address and render tile to be specified. - * The S at the end means odd lines are already word Swapped - */ -#define gDPLoadMultiBlockS(pkt, timg, tmem, rtile, fmt, siz, width, \ - height, pal, cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ - gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \ - gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, \ - 0 , cmt, maskt, shiftt, cms, masks, shifts); \ - gDPLoadSync(pkt); \ - gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ - (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1,0); \ - gDPPipeSync(pkt); \ - gDPSetTile(pkt, fmt, siz, \ - (((width) * siz##_LINE_BYTES)+7)>>3, tmem, \ - rtile, pal, cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPSetTileSize(pkt, rtile, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ -} - - -#define gDPLoadTextureBlockYuvS(pkt, timg, fmt, siz, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ - gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \ - gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, 0, G_TX_LOADTILE, \ - 0 , cmt, maskt, shiftt, cms, masks, shifts); \ - gDPLoadSync(pkt); \ - gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ - (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1,0); \ - gDPPipeSync(pkt); \ - gDPSetTile(pkt, fmt, siz, \ - (((width) * 1)+7)>>3, 0, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ -} - -/* - * allows tmem address to be specified - */ -#define _gDPLoadTextureBlock(pkt, timg, tmem, fmt, siz, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ - gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \ - gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, \ - 0, cmt, maskt, shiftt, cms, masks, shifts); \ - gDPLoadSync(pkt); \ - gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ - (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1, \ - CALC_DXT(width, siz##_BYTES)); \ - gDPPipeSync(pkt); \ - gDPSetTile(pkt, fmt, siz, (((width) * siz##_LINE_BYTES)+7)>>3, \ - tmem, G_TX_RENDERTILE, pal, cmt, \ - maskt, shiftt, cms, masks, shifts); \ - gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ -} - -/* - * allows tmem address and render tile to be specified - */ -#define _gDPLoadTextureBlockTile(pkt, timg, tmem, rtile, fmt, siz, width, \ - height, pal, cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ - gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \ - gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, 0,\ - cmt, maskt, shiftt, cms, masks, shifts); \ - gDPLoadSync(pkt); \ - gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ - (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1, \ - CALC_DXT(width, siz##_BYTES)); \ - gDPPipeSync(pkt); \ - gDPSetTile(pkt, fmt, siz, (((width) * siz##_LINE_BYTES)+7)>>3, \ - tmem, rtile, pal, cmt, \ - maskt, shiftt, cms, masks, shifts); \ - gDPSetTileSize(pkt, rtile, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ -} - -/* - * allows tmem address and render tile to be specified - */ -#define gDPLoadMultiBlock(pkt, timg, tmem, rtile, fmt, siz, width, \ - height, pal, cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ - gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \ - gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, 0,\ - cmt, maskt, shiftt, cms, masks, shifts); \ - gDPLoadSync(pkt); \ - gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ - (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1, \ - CALC_DXT(width, siz##_BYTES)); \ - gDPPipeSync(pkt); \ - gDPSetTile(pkt, fmt, siz, (((width) * siz##_LINE_BYTES)+7)>>3, \ - tmem, rtile, pal, cmt, \ - maskt, shiftt, cms, masks, shifts); \ - gDPSetTileSize(pkt, rtile, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ -} - -#define gsDPLoadTextureBlock(timg, fmt, siz, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ - \ - gsDPSetTextureImage(fmt, siz##_LOAD_BLOCK, 1, timg), \ - gsDPSetTile(fmt, siz##_LOAD_BLOCK, 0, 0, \ - G_TX_LOADTILE, 0 , cmt, maskt, shiftt, cms, \ - masks, shifts), \ - gsDPLoadSync(), \ - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, \ - (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1, \ - CALC_DXT(width, siz##_BYTES)), \ - gsDPPipeSync(), \ - gsDPSetTile(fmt, siz, ((((width) * siz##_LINE_BYTES)+7)>>3), 0, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ - shifts), \ - gsDPSetTileSize(G_TX_RENDERTILE, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) - -/* Here is the static form of the pre-swapped texture block loading */ -/* See gDPLoadTextureBlockS() for reference. Basically, just don't - calculate DxT, use 0 */ - -#define gsDPLoadTextureBlockS(timg, fmt, siz, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ - \ - gsDPSetTextureImage(fmt, siz##_LOAD_BLOCK, 1, timg), \ - gsDPSetTile(fmt, siz##_LOAD_BLOCK, 0, 0, G_TX_LOADTILE, 0 , \ - cmt, maskt,shiftt, cms, masks, shifts), \ - gsDPLoadSync(), \ - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, \ - (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1, 0 ),\ - gsDPPipeSync(), \ - gsDPSetTile(fmt, siz, ((((width) * siz##_LINE_BYTES)+7)>>3), 0, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ - shifts), \ - gsDPSetTileSize(G_TX_RENDERTILE, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) - -/* - * Allow tmem address to be specified - */ -#define _gsDPLoadTextureBlock(timg, tmem, fmt, siz, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ - \ - gsDPSetTextureImage(fmt, siz##_LOAD_BLOCK, 1, timg), \ - gsDPSetTile(fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, \ - 0 , cmt, maskt, shiftt, cms, masks, shifts), \ - gsDPLoadSync(), \ - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, \ - (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1, \ - CALC_DXT(width, siz##_BYTES)), \ - gsDPPipeSync(), \ - gsDPSetTile(fmt, siz, \ - ((((width) * siz##_LINE_BYTES)+7)>>3), tmem, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ - shifts), \ - gsDPSetTileSize(G_TX_RENDERTILE, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) - - -/* - * Allow tmem address and render_tile to be specified - */ -#define _gsDPLoadTextureBlockTile(timg, tmem, rtile, fmt, siz, width, \ - height, pal, cms, cmt, masks, maskt, shifts, shiftt) \ - \ - gsDPSetTextureImage(fmt, siz##_LOAD_BLOCK, 1, timg), \ - gsDPSetTile(fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, \ - 0 , cmt, maskt, shiftt, cms, masks, shifts), \ - gsDPLoadSync(), \ - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, \ - (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1, \ - CALC_DXT(width, siz##_BYTES)), \ - gsDPPipeSync(), \ - gsDPSetTile(fmt, siz, \ - ((((width) * siz##_LINE_BYTES)+7)>>3), tmem, \ - rtile, pal, cmt, maskt, shiftt, cms, masks, \ - shifts), \ - gsDPSetTileSize(rtile, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) - - -/* - * Allow tmem address and render_tile to be specified, useful when loading - * mutilple tiles at a time. - */ -#define gsDPLoadMultiBlock(timg, tmem, rtile, fmt, siz, width, \ - height, pal, cms, cmt, masks, maskt, shifts, shiftt) \ - \ - gsDPSetTextureImage(fmt, siz##_LOAD_BLOCK, 1, timg), \ - gsDPSetTile(fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, \ - 0 , cmt, maskt, shiftt, cms, masks, shifts), \ - gsDPLoadSync(), \ - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, \ - (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1, \ - CALC_DXT(width, siz##_BYTES)), \ - gsDPPipeSync(), \ - gsDPSetTile(fmt, siz, \ - ((((width) * siz##_LINE_BYTES)+7)>>3), tmem, \ - rtile, pal, cmt, maskt, shiftt, cms, masks, \ - shifts), \ - gsDPSetTileSize(rtile, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) - -/* - * Allows tmem and render tile to be specified. Useful when loading - * several tiles at a time. - * - * Here is the static form of the pre-swapped texture block loading - * See gDPLoadTextureBlockS() for reference. Basically, just don't - * calculate DxT, use 0 - */ - -#define gsDPLoadMultiBlockS(timg, tmem, rtile, fmt, siz, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ - \ - gsDPSetTextureImage(fmt, siz##_LOAD_BLOCK, 1, timg), \ - gsDPSetTile(fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, 0 , \ - cmt, maskt,shiftt, cms, masks, shifts), \ - gsDPLoadSync(), \ - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, \ - (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1, 0 ),\ - gsDPPipeSync(), \ - gsDPSetTile(fmt, siz, ((((width) * siz##_LINE_BYTES)+7)>>3), tmem,\ - rtile, pal, cmt, maskt, shiftt, cms, masks, \ - shifts), \ - gsDPSetTileSize(rtile, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) - - -#define gDPLoadTextureBlock_4b(pkt, timg, fmt, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ - gDPSetTextureImage(pkt, fmt, G_IM_SIZ_16b, 1, timg); \ - gDPSetTile(pkt, fmt, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, \ - cmt, maskt, shiftt, cms, masks, shifts); \ - gDPLoadSync(pkt); \ - gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ - (((width)*(height)+3)>>2)-1, \ - CALC_DXT_4b(width)); \ - gDPPipeSync(pkt); \ - gDPSetTile(pkt, fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), 0, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ -} - -/* Load fix rww 27jun95 */ -/* The S at the end means odd lines are already word Swapped */ - -#define gDPLoadTextureBlock_4bS(pkt, timg, fmt, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ - gDPSetTextureImage(pkt, fmt, G_IM_SIZ_16b, 1, timg); \ - gDPSetTile(pkt, fmt, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, \ - cmt, maskt, shiftt, cms, masks, shifts); \ - gDPLoadSync(pkt); \ - gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ - (((width)*(height)+3)>>2)-1, 0 ); \ - gDPPipeSync(pkt); \ - gDPSetTile(pkt, fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), 0, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ -} - -/* - * 4-bit load block. Useful when loading multiple tiles - */ -#define gDPLoadMultiBlock_4b(pkt, timg, tmem, rtile, fmt, width, height,\ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ - gDPSetTextureImage(pkt, fmt, G_IM_SIZ_16b, 1, timg); \ - gDPSetTile(pkt, fmt, G_IM_SIZ_16b, 0, tmem, G_TX_LOADTILE, 0, \ - cmt, maskt, shiftt, cms, masks, shifts); \ - gDPLoadSync(pkt); \ - gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ - (((width)*(height)+3)>>2)-1, \ - CALC_DXT_4b(width)); \ - gDPPipeSync(pkt); \ - gDPSetTile(pkt, fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), tmem, \ - rtile, pal, cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPSetTileSize(pkt, rtile, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ -} - -/* - * 4-bit load block. Allows tmem and render tile to be specified. Useful when - * loading multiple tiles. The S means odd lines are already word swapped. - */ -#define gDPLoadMultiBlock_4bS(pkt, timg, tmem, rtile, fmt, width, height,\ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ - gDPSetTextureImage(pkt, fmt, G_IM_SIZ_16b, 1, timg); \ - gDPSetTile(pkt, fmt, G_IM_SIZ_16b, 0, tmem, G_TX_LOADTILE, 0, \ - cmt, maskt, shiftt, cms, masks, shifts); \ - gDPLoadSync(pkt); \ - gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ - (((width)*(height)+3)>>2)-1, 0 ); \ - gDPPipeSync(pkt); \ - gDPSetTile(pkt, fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), tmem, \ - rtile, pal, cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPSetTileSize(pkt, rtile, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ -} - - -#define _gDPLoadTextureBlock_4b(pkt, timg, tmem, fmt, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ - gDPSetTextureImage(pkt, fmt, G_IM_SIZ_16b, 1, timg); \ - gDPSetTile(pkt, fmt, G_IM_SIZ_16b, 0, tmem, G_TX_LOADTILE, 0, \ - cmt, maskt, shiftt, cms, masks, shifts); \ - gDPLoadSync(pkt); \ - gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ - (((width)*(height)+3)>>2)-1, \ - CALC_DXT_4b(width)); \ - gDPPipeSync(pkt); \ - gDPSetTile(pkt, fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), tmem, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ -} - -#define gsDPLoadTextureBlock_4b(timg, fmt, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ - \ - gsDPSetTextureImage(fmt, G_IM_SIZ_16b, 1, timg), \ - gsDPSetTile(fmt, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0 , cmt, \ - maskt, shiftt, cms, masks, shifts), \ - gsDPLoadSync(), \ - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, (((width)*(height)+3)>>2)-1, \ - CALC_DXT_4b(width)), \ - gsDPPipeSync(), \ - gsDPSetTile(fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), 0, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ - shifts), \ - gsDPSetTileSize(G_TX_RENDERTILE, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) - -#define gsDPLoadTextureBlock_4bS(timg, fmt, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ - \ - gsDPSetTextureImage(fmt, G_IM_SIZ_16b, 1, timg), \ - gsDPSetTile(fmt, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0 , cmt, \ - maskt, shiftt, cms, masks, shifts), \ - gsDPLoadSync(), \ - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, (((width)*(height)+3)>>2)-1,0),\ - gsDPPipeSync(), \ - gsDPSetTile(fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), 0, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ - shifts), \ - gsDPSetTileSize(G_TX_RENDERTILE, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) - -/* - * 4-bit load block. Allows tmem address and render tile to be specified. - * Useful when loading multiple tiles. - */ -#define gsDPLoadMultiBlock_4b(timg, tmem, rtile, fmt, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ - \ - gsDPSetTextureImage(fmt, G_IM_SIZ_16b, 1, timg), \ - gsDPSetTile(fmt, G_IM_SIZ_16b, 0, tmem, G_TX_LOADTILE, 0 , cmt, \ - maskt, shiftt, cms, masks, shifts), \ - gsDPLoadSync(), \ - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, (((width)*(height)+3)>>2)-1, \ - CALC_DXT_4b(width)), \ - gsDPPipeSync(), \ - gsDPSetTile(fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), tmem, \ - rtile, pal, cmt, maskt, shiftt, cms, masks, \ - shifts), \ - gsDPSetTileSize(rtile, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) - - -/* - * 4-bit load block. Allows tmem address and render tile to be specified. - * Useful when loading multiple tiles. S means odd lines are already swapped. - */ -#define gsDPLoadMultiBlock_4bS(timg, tmem, rtile, fmt, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ - \ - gsDPSetTextureImage(fmt, G_IM_SIZ_16b, 1, timg), \ - gsDPSetTile(fmt, G_IM_SIZ_16b, 0, tmem, G_TX_LOADTILE, 0 , cmt, \ - maskt, shiftt, cms, masks, shifts), \ - gsDPLoadSync(), \ - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, (((width)*(height)+3)>>2)-1,0),\ - gsDPPipeSync(), \ - gsDPSetTile(fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), tmem, \ - rtile, pal, cmt, maskt, shiftt, cms, masks, \ - shifts), \ - gsDPSetTileSize(rtile, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) - - -/* - * Allows tmem address to be specified - */ -#define _gsDPLoadTextureBlock_4b(timg, tmem, fmt, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ - \ - gsDPSetTextureImage(fmt, G_IM_SIZ_16b, 1, timg), \ - gsDPSetTile(fmt, G_IM_SIZ_16b, 0, tmem, G_TX_LOADTILE, 0 , cmt, \ - maskt, shiftt, cms, masks, shifts), \ - gsDPLoadSync(), \ - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, (((width)*(height)+3)>>2)-1, \ - CALC_DXT_4b(width)), \ - gsDPPipeSync(), \ - gsDPSetTile(fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), tmem, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ - shifts), \ - gsDPSetTileSize(G_TX_RENDERTILE, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) - -#ifndef _HW_VERSION_1 - -#define gDPLoadTextureTile(pkt, timg, fmt, siz, width, height, \ - uls, ult, lrs, lrt, pal, \ - cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ - gDPSetTextureImage(pkt, fmt, siz, width, timg); \ - gDPSetTile(pkt, fmt, siz, \ - (((((lrs)-(uls)+1) * siz##_TILE_BYTES)+7)>>3), 0, \ - G_TX_LOADTILE, 0 , cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPLoadSync(pkt); \ - gDPLoadTile( pkt, G_TX_LOADTILE, \ - (uls)<>3), 0, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPSetTileSize(pkt, G_TX_RENDERTILE, \ - (uls)<>3), tmem, \ - G_TX_LOADTILE, 0 , cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPLoadSync(pkt); \ - gDPLoadTile( pkt, G_TX_LOADTILE, \ - (uls)<>3), tmem, \ - rtile, pal, cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPSetTileSize(pkt, rtile, \ - (uls)<>3), 0, \ - G_TX_LOADTILE, 0 , cmt, maskt, shiftt, cms, masks, \ - shifts), \ - gsDPLoadSync(), \ - gsDPLoadTile( G_TX_LOADTILE, \ - (uls)<>3), 0, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks,\ - shifts), \ - gsDPSetTileSize(G_TX_RENDERTILE, \ - (uls)<>3), \ - tmem, G_TX_LOADTILE, 0 , cmt, maskt, shiftt, cms, \ - masks, shifts), \ - gsDPLoadSync(), \ - gsDPLoadTile( G_TX_LOADTILE, \ - (uls)<>3), \ - tmem, rtile, pal, cmt, maskt, shiftt, cms, masks, \ - shifts), \ - gsDPSetTileSize(rtile, \ - (uls)<>1), timg); \ - gDPSetTile(pkt, fmt, G_IM_SIZ_8b, \ - (((((lrs)-(uls)+1)>>1)+7)>>3), 0, \ - G_TX_LOADTILE, 0 , cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPLoadSync(pkt); \ - gDPLoadTile( pkt, G_TX_LOADTILE, \ - (uls)<<(G_TEXTURE_IMAGE_FRAC-1), \ - (ult)<<(G_TEXTURE_IMAGE_FRAC), \ - (lrs)<<(G_TEXTURE_IMAGE_FRAC-1), \ - (lrt)<<(G_TEXTURE_IMAGE_FRAC)); \ - gDPPipeSync(pkt); \ - gDPSetTile(pkt, fmt, G_IM_SIZ_4b, \ - (((((lrs)-(uls)+1)>>1)+7)>>3), 0, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, \ - masks, shifts); \ - gDPSetTileSize(pkt, G_TX_RENDERTILE, \ - (uls)<>1), timg); \ - gDPSetTile(pkt, fmt, G_IM_SIZ_8b, \ - (((((lrs)-(uls)+1)>>1)+7)>>3), tmem, \ - G_TX_LOADTILE, 0 , cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPLoadSync(pkt); \ - gDPLoadTile( pkt, G_TX_LOADTILE, \ - (uls)<<(G_TEXTURE_IMAGE_FRAC-1), \ - (ult)<<(G_TEXTURE_IMAGE_FRAC), \ - (lrs)<<(G_TEXTURE_IMAGE_FRAC-1), \ - (lrt)<<(G_TEXTURE_IMAGE_FRAC)); \ - gDPPipeSync(pkt); \ - gDPSetTile(pkt, fmt, G_IM_SIZ_4b, \ - (((((lrs)-(uls)+1)>>1)+7)>>3), tmem, \ - rtile, pal, cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPSetTileSize(pkt, rtile, \ - (uls)<>1), timg), \ - gsDPSetTile(fmt, G_IM_SIZ_8b, (((((lrs)-(uls)+1)>>1)+7)>>3), 0, \ - G_TX_LOADTILE, 0 , cmt, maskt, shiftt, cms, masks, \ - shifts), \ - gsDPLoadSync(), \ - gsDPLoadTile( G_TX_LOADTILE, \ - (uls)<<(G_TEXTURE_IMAGE_FRAC-1), \ - (ult)<<(G_TEXTURE_IMAGE_FRAC), \ - (lrs)<<(G_TEXTURE_IMAGE_FRAC-1), \ - (lrt)<<(G_TEXTURE_IMAGE_FRAC)), \ - gsDPPipeSync(), \ - gsDPSetTile(fmt, G_IM_SIZ_4b, (((((lrs)-(uls)+1)>>1)+7)>>3), 0, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ - shifts), \ - gsDPSetTileSize(G_TX_RENDERTILE, \ - (uls)<>1), timg), \ - gsDPSetTile(fmt, G_IM_SIZ_8b, (((((lrs)-(uls)+1)>>1)+7)>>3), \ - tmem, G_TX_LOADTILE, 0 , cmt, maskt, shiftt, cms, \ - masks, shifts), \ - gsDPLoadSync(), \ - gsDPLoadTile( G_TX_LOADTILE, \ - (uls)<<(G_TEXTURE_IMAGE_FRAC-1), \ - (ult)<<(G_TEXTURE_IMAGE_FRAC), \ - (lrs)<<(G_TEXTURE_IMAGE_FRAC-1), \ - (lrt)<<(G_TEXTURE_IMAGE_FRAC)), \ - gsDPPipeSync(), \ - gsDPSetTile(fmt, G_IM_SIZ_4b, (((((lrs)-(uls)+1)>>1)+7)>>3), \ - tmem, rtile, pal, cmt, maskt, shiftt, cms, masks, \ - shifts), \ - gsDPSetTileSize(rtile, \ - (uls)<words.w0 = _SHIFTL(G_SETSCISSOR, 24, 8) | \ - _SHIFTL((int)((float)(ulx)*4.0F), 12, 12) | \ - _SHIFTL((int)((float)(uly)*4.0F), 0, 12); \ - _g->words.w1 = _SHIFTL(mode, 24, 2) | \ - _SHIFTL((int)((float)(lrx)*4.0F), 12, 12) | \ - _SHIFTL((int)((float)(lry)*4.0F), 0, 12); \ -} - - -#define gDPSetScissorFrac(pkt, mode, ulx, uly, lrx, lry) \ -{ \ - Gfx *_g = (Gfx *)pkt; \ - \ - _g->words.w0 = _SHIFTL(G_SETSCISSOR, 24, 8) | \ - _SHIFTL((int)((ulx)), 12, 12) | \ - _SHIFTL((int)((uly)), 0, 12); \ - _g->words.w1 = _SHIFTL(mode, 24, 2) | \ - _SHIFTL((int)((lrx)), 12, 12) | \ - _SHIFTL((int)((lry)), 0, 12); \ -} - -#define gsDPSetScissor(mode, ulx, uly, lrx, lry) \ -{{ \ - _SHIFTL(G_SETSCISSOR, 24, 8) | \ - _SHIFTL((int)((float)(ulx)*4.0F), 12, 12) | \ - _SHIFTL((int)((float)(uly)*4.0F), 0, 12), \ - _SHIFTL(mode, 24, 2) | \ - _SHIFTL((int)((float)(lrx)*4.0F), 12, 12) | \ - _SHIFTL((int)((float)(lry)*4.0F), 0, 12) \ -}} - -#define gsDPSetScissorFrac(mode, ulx, uly, lrx, lry) \ -{{ \ - _SHIFTL(G_SETSCISSOR, 24, 8) | \ - _SHIFTL((int)((ulx)), 12, 12) | \ - _SHIFTL((int)((uly)), 0, 12), \ - _SHIFTL(mode, 24, 2) | \ - _SHIFTL((int)(lrx), 12, 12) | \ - _SHIFTL((int)(lry), 0, 12) \ -}} - -/* Fraction never used in fill */ -#define gDPFillRectangle(pkt, ulx, uly, lrx, lry) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_FILLRECT, 24, 8) | \ - _SHIFTL((lrx), 14, 10) | _SHIFTL((lry), 2, 10));\ - _g->words.w1 = (_SHIFTL((ulx), 14, 10) | _SHIFTL((uly), 2, 10));\ -} - -#define gsDPFillRectangle(ulx, uly, lrx, lry) \ -{{ \ - (_SHIFTL(G_FILLRECT, 24, 8) | _SHIFTL((lrx), 14, 10) | \ - _SHIFTL((lry), 2, 10)), \ - (_SHIFTL((ulx), 14, 10) | _SHIFTL((uly), 2, 10)) \ -}} - -/* like gDPFillRectangle but accepts negative arguments */ -#define gDPScisFillRectangle(pkt, ulx, uly, lrx, lry) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_FILLRECT, 24, 8) | \ - _SHIFTL(MAX((lrx),0), 14, 10) | \ - _SHIFTL(MAX((lry),0), 2, 10)); \ - _g->words.w1 = (_SHIFTL(MAX((ulx),0), 14, 10) | \ - _SHIFTL(MAX((uly),0), 2, 10)); \ -} - -#define gDPSetConvert(pkt, k0, k1, k2, k3, k4, k5) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_SETCONVERT, 24, 8) | \ - _SHIFTL(k0, 13, 9) | _SHIFTL(k1, 4, 9) | \ - _SHIFTR(k2, 5, 4)); \ - _g->words.w1 = (_SHIFTL(k2, 27, 5) | _SHIFTL(k3, 18, 9) | \ - _SHIFTL(k4, 9, 9) | _SHIFTL(k5, 0, 9)); \ -} - -#define gsDPSetConvert(k0, k1, k2, k3, k4, k5) \ -{{ \ - (_SHIFTL(G_SETCONVERT, 24, 8) | \ - _SHIFTL(k0, 13, 9) | _SHIFTL(k1, 4, 9) | _SHIFTR(k2, 5, 4)), \ - (_SHIFTL(k2, 27, 5) | _SHIFTL(k3, 18, 9) | _SHIFTL(k4, 9, 9) | \ - _SHIFTL(k5, 0, 9)) \ -}} - -#define gDPSetKeyR(pkt, cR, sR, wR) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(G_SETKEYR, 24, 8); \ - _g->words.w1 = (_SHIFTL(wR, 16, 12) | _SHIFTL(cR, 8, 8) | \ - _SHIFTL(sR, 0, 8)); \ -} - -#define gsDPSetKeyR(cR, sR, wR) \ -{{ \ - _SHIFTL(G_SETKEYR, 24, 8), \ - _SHIFTL(wR, 16, 12) | _SHIFTL(cR, 8, 8) | _SHIFTL(sR, 0, 8) \ -}} - -#define gDPSetKeyGB(pkt, cG, sG, wG, cB, sB, wB) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_SETKEYGB, 24, 8) | \ - _SHIFTL(wG, 12, 12) | _SHIFTL(wB, 0, 12)); \ - _g->words.w1 = (_SHIFTL(cG, 24, 8) | _SHIFTL(sG, 16, 8) | \ - _SHIFTL(cB, 8, 8) | _SHIFTL(sB, 0, 8)); \ -} - -#define gsDPSetKeyGB(cG, sG, wG, cB, sB, wB) \ -{{ \ - (_SHIFTL(G_SETKEYGB, 24, 8) | _SHIFTL(wG, 12, 12) | \ - _SHIFTL(wB, 0, 12)), \ - (_SHIFTL(cG, 24, 8) | _SHIFTL(sG, 16, 8) | _SHIFTL(cB, 8, 8) | \ - _SHIFTL(sB, 0, 8)) \ -}} - -#define gDPNoParam(pkt, cmd) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(cmd, 24, 8); \ - _g->words.w1 = 0; \ -} - -#define gsDPNoParam(cmd) \ -{{ \ - _SHIFTL(cmd, 24, 8), 0 \ -}} - -#define gDPParam(pkt, cmd, param) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(cmd, 24, 8); \ - _g->words.w1 = (param); \ -} - -#define gsDPParam(cmd, param) \ -{{ \ - _SHIFTL(cmd, 24, 8), (param) \ -}} - -/* Notice that textured rectangles are 128-bit commands, therefore - * gsDPTextureRectangle() should not be used in display lists - * under normal circumstances (use gsSPTextureRectangle()). - * That is also why there is no gDPTextureRectangle() macros. - */ -#define gsDPTextureRectangle(xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ -{{ \ - (_SHIFTL(G_TEXRECT, 24, 8) | _SHIFTL(xh, 12, 12) | \ - _SHIFTL(yh, 0, 12)), \ - (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12)), \ -}}, \ -{{ \ - _SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16), \ - _SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16) \ -}} - -#define gDPTextureRectangle(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy)\ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - if (pkt); \ - _g->words.w0 = (_SHIFTL(G_TEXRECT, 24, 8) | _SHIFTL(xh, 12, 12) | \ - _SHIFTL(yh, 0, 12)); \ - _g->words.w1 = (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | \ - _SHIFTL(yl, 0, 12)); \ - _g ++; \ - _g->words.w0 = (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16)); \ - _g->words.w1 = (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16)); \ -} - -#define gsDPTextureRectangleFlip(xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ -{{ \ - (_SHIFTL(G_TEXRECTFLIP, 24, 8) | _SHIFTL(xh, 12, 12) | \ - _SHIFTL(yh, 0, 12)), \ - (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12)), \ -}}, \ -{{ \ - _SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16), \ - _SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16) \ -}} - -#define gDPTextureRectangleFlip(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy)\ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - if (pkt); \ - _g->words.w0 = (_SHIFTL(G_TEXRECTFLIP, 24, 8) | _SHIFTL(xh, 12, 12) | \ - _SHIFTL(yh, 0, 12)); \ - _g->words.w1 = (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | \ - _SHIFTL(yl, 0, 12)); \ - _g ++; \ - _g->words.w0 = (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16)); \ - _g->words.w1 = (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16)); \ -} - -#ifdef F3D_OLD -# define gSPTextureRectangle(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy)\ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_TEXRECT, 24, 8) | _SHIFTL(xh, 12, 12) | \ - _SHIFTL(yh, 0, 12)); \ - _g->words.w1 = (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | \ - _SHIFTL(yl, 0, 12)); \ - gImmp1(pkt, G_RDPHALF_2, (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16))); \ - gImmp1(pkt, G_RDPHALF_CONT, (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16)));\ -} - -#define gsSPTextureRectangle(xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ - {{(_SHIFTL(G_TEXRECT, 24, 8) | _SHIFTL(xh, 12, 12) | _SHIFTL(yh, 0, 12)),\ - (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12))}}, \ - gsImmp1(G_RDPHALF_2, (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16))), \ - gsImmp1(G_RDPHALF_CONT, (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16))) - -/* like gSPTextureRectangle but accepts negative position arguments */ -# define gSPScisTextureRectangle(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_TEXRECT, 24, 8) | \ - _SHIFTL(MAX((s16)(xh),0), 12, 12) | \ - _SHIFTL(MAX((s16)(yh),0), 0, 12)); \ - _g->words.w1 = (_SHIFTL((tile), 24, 3) | \ - _SHIFTL(MAX((s16)(xl),0), 12, 12) | \ - _SHIFTL(MAX((s16)(yl),0), 0, 12)); \ - gImmp1(pkt, G_RDPHALF_2, \ - (_SHIFTL(((s) - \ - (((s16)(xl) < 0) ? \ - (((s16)(dsdx) < 0) ? \ - (MAX((((s16)(xl)*(s16)(dsdx))>>7),0)) : \ - (MIN((((s16)(xl)*(s16)(dsdx))>>7),0))) : 0)), \ - 16, 16) | \ - _SHIFTL(((t) - \ - (((yl) < 0) ? \ - (((s16)(dtdy) < 0) ? \ - (MAX((((s16)(yl)*(s16)(dtdy))>>7),0)) : \ - (MIN((((s16)(yl)*(s16)(dtdy))>>7),0))) : 0)), \ - 0, 16))); \ - gImmp1(pkt, G_RDPHALF_CONT, (_SHIFTL((dsdx), 16, 16) | \ - _SHIFTL((dtdy), 0, 16))); \ -} - -# define gsSPTextureRectangleFlip(xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ - {{(_SHIFTL(G_TEXRECTFLIP, 24, 8) | _SHIFTL(xh, 12, 12) | \ - _SHIFTL(yh, 0, 12)), \ - (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12))}}, \ - gsImmp1(G_RDPHALF_2, (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16))), \ - gsImmp1(G_RDPHALF_CONT, (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16))) - -# define gSPTextureRectangleFlip(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_TEXRECTFLIP, 24, 8) | _SHIFTL(xh, 12, 12) |\ - _SHIFTL(yh, 0, 12)); \ - _g->words.w1 = (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | \ - _SHIFTL(yl, 0, 12)); \ - gImmp1(pkt, G_RDPHALF_2, (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16))); \ - gImmp1(pkt, G_RDPHALF_CONT, (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16))); \ -} -#else -# define gSPTextureRectangle(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy)\ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_TEXRECT, 24, 8) | _SHIFTL(xh, 12, 12) | \ - _SHIFTL(yh, 0, 12)); \ - _g->words.w1 = (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | \ - _SHIFTL(yl, 0, 12)); \ - gImmp1(pkt, G_RDPHALF_1, (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16))); \ - gImmp1(pkt, G_RDPHALF_2, (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16)));\ -} - -#define gsSPTextureRectangle(xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ - {{(_SHIFTL(G_TEXRECT, 24, 8) | _SHIFTL(xh, 12, 12) | _SHIFTL(yh, 0, 12)),\ - (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12))}}, \ - gsImmp1(G_RDPHALF_1, (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16))), \ - gsImmp1(G_RDPHALF_2, (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16))) - -/* like gSPTextureRectangle but accepts negative position arguments */ -# define gSPScisTextureRectangle(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_TEXRECT, 24, 8) | \ - _SHIFTL(MAX((s16)(xh),0), 12, 12) | \ - _SHIFTL(MAX((s16)(yh),0), 0, 12)); \ - _g->words.w1 = (_SHIFTL((tile), 24, 3) | \ - _SHIFTL(MAX((s16)(xl),0), 12, 12) | \ - _SHIFTL(MAX((s16)(yl),0), 0, 12)); \ - gImmp1(pkt, G_RDPHALF_1, \ - (_SHIFTL(((s) - \ - (((s16)(xl) < 0) ? \ - (((s16)(dsdx) < 0) ? \ - (MAX((((s16)(xl)*(s16)(dsdx))>>7),0)) : \ - (MIN((((s16)(xl)*(s16)(dsdx))>>7),0))) : 0)), \ - 16, 16) | \ - _SHIFTL(((t) - \ - (((yl) < 0) ? \ - (((s16)(dtdy) < 0) ? \ - (MAX((((s16)(yl)*(s16)(dtdy))>>7),0)) : \ - (MIN((((s16)(yl)*(s16)(dtdy))>>7),0))) : 0)), \ - 0, 16))); \ - gImmp1(pkt, G_RDPHALF_2, (_SHIFTL((dsdx), 16, 16) | \ - _SHIFTL((dtdy), 0, 16))); \ -} - -# define gsSPTextureRectangleFlip(xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ - {{(_SHIFTL(G_TEXRECTFLIP, 24, 8) | _SHIFTL(xh, 12, 12) | \ - _SHIFTL(yh, 0, 12)), \ - (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12))}}, \ - gsImmp1(G_RDPHALF_1, (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16))), \ - gsImmp1(G_RDPHALF_2, (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16))) - -# define gSPTextureRectangleFlip(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_TEXRECTFLIP, 24, 8) | _SHIFTL(xh, 12, 12) |\ - _SHIFTL(yh, 0, 12)); \ - _g->words.w1 = (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | \ - _SHIFTL(yl, 0, 12)); \ - gImmp1(pkt, G_RDPHALF_1, (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16))); \ - gImmp1(pkt, G_RDPHALF_2, (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16))); \ -} -#endif - -#define gsDPWord(wordhi, wordlo) \ - gsImmp1(G_RDPHALF_1, (uintptr_t)(wordhi)), \ - gsImmp1(G_RDPHALF_2, (uintptr_t)(wordlo)) - -#define gDPWord(pkt, wordhi, wordlo) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - gImmp1(pkt, G_RDPHALF_1, (uintptr_t)(wordhi)); \ - gImmp1(pkt, G_RDPHALF_2, (uintptr_t)(wordlo)); \ -} - -#define gDPFullSync(pkt) gDPNoParam(pkt, G_RDPFULLSYNC) -#define gsDPFullSync() gsDPNoParam(G_RDPFULLSYNC) -#define gDPTileSync(pkt) gDPNoParam(pkt, G_RDPTILESYNC) -#define gsDPTileSync() gsDPNoParam(G_RDPTILESYNC) -#define gDPPipeSync(pkt) gDPNoParam(pkt, G_RDPPIPESYNC) -#define gsDPPipeSync() gsDPNoParam(G_RDPPIPESYNC) -#define gDPLoadSync(pkt) gDPNoParam(pkt, G_RDPLOADSYNC) -#define gsDPLoadSync() gsDPNoParam(G_RDPLOADSYNC) -#define gDPNoOp(pkt) gDPNoParam(pkt, G_NOOP) -#define gsDPNoOp() gsDPNoParam(G_NOOP) -#define gDPNoOpTag(pkt, tag) gDPParam(pkt, G_NOOP, tag) -#define gsDPNoOpTag(tag) gsDPParam(G_NOOP, tag) - -#endif /* _LANGUAGE_C */ - - -#endif /* _GBI_H_ */ diff --git a/include/PR/gs2dex.h b/include/PR/gs2dex.h deleted file mode 100644 index ced468555..000000000 --- a/include/PR/gs2dex.h +++ /dev/null @@ -1,392 +0,0 @@ -/*--------------------------------------------------------------------- - Copyright (C) 1997, Nintendo. - - File gs2dex.h - Coded by Yoshitaka Yasumoto. Jul 31, 1997. - Modified by - Comments Header file for S2DEX ucode. - - $Id: gs2dex.h,v 1.21 1998/05/28 00:14:49 has Exp $ - ---------------------------------------------------------------------*/ - -#ifndef _GS2DEX_H_ -#define _GS2DEX_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include - -/*===========================================================================* - * Macro - *===========================================================================*/ -#define GS_CALC_DXT(line) (((1<< G_TX_DXT_FRAC)-1)/(line)+1) -#define GS_PIX2TMEM(pix, siz) ((pix)>>(4-(siz))) -#define GS_PIX2DXT(pix, siz) GS_CALC_DXT(GS_PIX2TMEM((pix), (siz))) - -/*===========================================================================* - * Data structures for S2DEX microcode - *===========================================================================*/ - -/*---------------------------------------------------------------------------* - * Background - *---------------------------------------------------------------------------*/ -#define G_BGLT_LOADBLOCK 0x0033 -#define G_BGLT_LOADTILE 0xfff4 - -#define G_BG_FLAG_FLIPS 0x01 -#define G_BG_FLAG_FLIPT 0x10 - -/* Non scalable background plane */ -typedef struct { - u16 imageX; /* x-coordinate of upper-left position of texture (u10.5) */ - u16 imageW; /* width of the texture (u10.2) */ - s16 frameX; /* upper-left position of transferred frame (s10.2) */ - u16 frameW; /* width of transferred frame (u10.2) */ - - u16 imageY; /* y-coordinate of upper-left position of texture (u10.5) */ - u16 imageH; /* height of the texture (u10.2) */ - s16 frameY; /* upper-left position of transferred frame (s10.2) */ - u16 frameH; /* height of transferred frame (u10.2) */ - - u64 *imagePtr; /* texture source address on DRAM */ - u16 imageLoad; /* which to use, LoadBlock or LoadTile */ - u8 imageFmt; /* format of texel - G_IM_FMT_* */ - u8 imageSiz; /* size of texel - G_IM_SIZ_* */ - u16 imagePal; /* pallet number */ - u16 imageFlip; /* right & left image inversion (Inverted by G_BG_FLAG_FLIPS) */ - - /* The following is set in the initialization routine guS2DInitBg(). There is no need for the user to set it. */ - u16 tmemW; /* TMEM width and Word size of frame 1 line. - At LoadBlock, GS_PIX2TMEM(imageW/4,imageSiz) - At LoadTile GS_PIX2TMEM(frameW/4,imageSiz)+1 */ - u16 tmemH; /* height of TMEM loadable at a time (s13.2) 4 times value - When the normal texture, 512/tmemW*4 - When the CI texture, 256/tmemW*4 */ - u16 tmemLoadSH; /* SH value - At LoadBlock, tmemSize/2-1 - At LoadTile, tmemW*16-1 */ - u16 tmemLoadTH; /* TH value or Stride value - At LoadBlock, GS_CALC_DXT(tmemW) - At LoadTile, tmemH-1 */ - u16 tmemSizeW; /* skip value of imagePtr for image 1-line - At LoadBlock, tmemW*2 - At LoadTile, GS_PIX2TMEM(imageW/4,imageSiz)*2 */ - u16 tmemSize; /* skip value of imagePtr for 1-loading - = tmemSizeW*tmemH */ -} uObjBg_t; /* 40 bytes */ - -/* Scalable background plane */ -typedef struct { - u16 imageX; /* x-coordinate of upper-left position of texture (u10.5) */ - u16 imageW; /* width of texture (u10.2) */ - s16 frameX; /* upper-left position of transferred frame (s10.2) */ - u16 frameW; /* width of transferred frame (u10.2) */ - - u16 imageY; /* y-coordinate of upper-left position of texture (u10.5) */ - u16 imageH; /* height of texture (u10.2) */ - s16 frameY; /* upper-left position of transferred frame (s10.2) */ - u16 frameH; /* height of transferred frame (u10.2) */ - - u64 *imagePtr; /* texture source address on DRAM */ - u16 imageLoad; /* Which to use, LoadBlock or LoadTile? */ - u8 imageFmt; /* format of texel - G_IM_FMT_* */ - u8 imageSiz; /* size of texel - G_IM_SIZ_* */ - u16 imagePal; /* pallet number */ - u16 imageFlip; /* right & left image inversion (Inverted by G_BG_FLAG_FLIPS) */ - - u16 scaleW; /* scale value of X-direction (u5.10) */ - u16 scaleH; /* scale value of Y-direction (u5.10) */ - s32 imageYorig; /* start point of drawing on image (s20.5) */ - - u8 padding[4]; - -} uObjScaleBg_t; /* 40 bytes */ - -typedef union { - uObjBg_t b; - uObjScaleBg_t s; - long long int force_structure_alignment; -} uObjBg; - -/*---------------------------------------------------------------------------* - * 2D Objects - *---------------------------------------------------------------------------*/ -#define G_OBJ_FLAG_FLIPS 1<<0 /* inversion to S-direction */ -#define G_OBJ_FLAG_FLIPT 1<<4 /* nversion to T-direction */ - -typedef struct { - s16 objX; /* s10.2 OBJ x-coordinate of upper-left end */ - u16 scaleW; /* u5.10 Scaling of u5.10 width direction */ - u16 imageW; /* u10.5 width of u10.5 texture (length of S-direction) */ - u16 paddingX; /* Unused - Always 0 */ - s16 objY; /* s10.2 OBJ y-coordinate of s10.2 OBJ upper-left end */ - u16 scaleH; /* u5.10 Scaling of u5.10 height direction */ - u16 imageH; /* u10.5 height of u10.5 texture (length of T-direction) */ - u16 paddingY; /* Unused - Always 0 */ - u16 imageStride; /* folding width of texel (In units of 64bit word) */ - u16 imageAdrs; /* texture header position in TMEM (In units of 64bit word) */ - u8 imageFmt; /* format of texel - G_IM_FMT_* */ - u8 imageSiz; /* size of texel - G_IM_SIZ_* */ - u8 imagePal; /* pallet number (0-7) */ - u8 imageFlags; /* The display flag - G_OBJ_FLAG_FLIP* */ -} uObjSprite_t; /* 24 bytes */ - -typedef union { - uObjSprite_t s; - long long int force_structure_alignment; -} uObjSprite; - -/*---------------------------------------------------------------------------* - * 2D Matrix - *---------------------------------------------------------------------------*/ -typedef struct { - s32 A, B, C, D; /* s15.16 */ - s16 X, Y; /* s10.2 */ - u16 BaseScaleX; /* u5.10 */ - u16 BaseScaleY; /* u5.10 */ -} uObjMtx_t; /* 24 bytes */ - -typedef union { - uObjMtx_t m; - long long int force_structure_alignment; -} uObjMtx; - -typedef struct { - s16 X, Y; /* s10.2 */ - u16 BaseScaleX; /* u5.10 */ - u16 BaseScaleY; /* u5.10 */ -} uObjSubMtx_t; /* 8 bytes */ - -typedef union { - uObjSubMtx_t m; - long long int force_structure_alignment; -} uObjSubMtx; - -/*---------------------------------------------------------------------------* - * Loading into TMEM - *---------------------------------------------------------------------------*/ -#define G_OBJLT_TXTRBLOCK 0x00001033 -#define G_OBJLT_TXTRTILE 0x00fc1034 -#define G_OBJLT_TLUT 0x00000030 - -#define GS_TB_TSIZE(pix,siz) (GS_PIX2TMEM((pix),(siz))-1) -#define GS_TB_TLINE(pix,siz) (GS_CALC_DXT(GS_PIX2TMEM((pix),(siz)))) - -typedef struct { - u32 type; /* G_OBJLT_TXTRBLOCK divided into types */ - u64 *image; /* texture source address on DRAM */ - u16 tmem; /* loaded TMEM word address (8byteWORD) */ - u16 tsize; /* Texture size, Specified by macro GS_TB_TSIZE() */ - u16 tline; /* width of Texture 1-line, Specified by macro GS_TB_TLINE() */ - u16 sid; /* STATE ID Multipled by 4 (Either one of 0, 4, 8 and 12) */ - u32 flag; /* STATE flag */ - u32 mask; /* STATE mask */ -} uObjTxtrBlock_t; /* 24 bytes */ - -#define GS_TT_TWIDTH(pix,siz) ((GS_PIX2TMEM((pix), (siz))<<2)-1) -#define GS_TT_THEIGHT(pix,siz) (((pix)<<2)-1) - -typedef struct { - u32 type; /* G_OBJLT_TXTRTILE divided into types */ - u64 *image; /* texture source address on DRAM */ - u16 tmem; /* loaded TMEM word address (8byteWORD)*/ - u16 twidth; /* width of Texture (Specified by macro GS_TT_TWIDTH()) */ - u16 theight; /* height of Texture (Specified by macro GS_TT_THEIGHT()) */ - u16 sid; /* STATE ID Multipled by 4 (Either one of 0, 4, 8 and 12) */ - u32 flag; /* STATE flag */ - u32 mask; /* STATE mask */ -} uObjTxtrTile_t; /* 24 bytes */ - -#define GS_PAL_HEAD(head) ((head)+256) -#define GS_PAL_NUM(num) ((num)-1) - -typedef struct { - u32 type; /* G_OBJLT_TLUT divided into types */ - u64 *image; /* texture source address on DRAM */ - u16 phead; /* pallet number of load header (Between 256 and 511) */ - u16 pnum; /* loading pallet number -1 */ - u16 zero; /* Assign 0 all the time */ - u16 sid; /* STATE ID Multipled by 4 (Either one of 0, 4, 8 and 12)*/ - u32 flag; /* STATE flag */ - u32 mask; /* STATE mask */ -} uObjTxtrTLUT_t; /* 24 bytes */ - -typedef union { - uObjTxtrBlock_t block; - uObjTxtrTile_t tile; - uObjTxtrTLUT_t tlut; - long long int force_structure_alignment; -} uObjTxtr; - -/*---------------------------------------------------------------------------* - * Loading into TMEM & 2D Objects - *---------------------------------------------------------------------------*/ -typedef struct { - uObjTxtr txtr; - uObjSprite sprite; -} uObjTxSprite; /* 48 bytes */ - -/*===========================================================================* - * GBI Commands for S2DEX microcode - *===========================================================================*/ -/* GBI Header */ -#ifdef F3DEX_GBI_2 -#define G_OBJ_RECTANGLE_R 0xda -#define G_OBJ_MOVEMEM 0xdc -#define G_RDPHALF_0 0xe4 -#define G_OBJ_RECTANGLE 0x01 -#define G_OBJ_SPRITE 0x02 -#define G_SELECT_DL 0x04 -#define G_OBJ_LOADTXTR 0x05 -#define G_OBJ_LDTX_SPRITE 0x06 -#define G_OBJ_LDTX_RECT 0x07 -#define G_OBJ_LDTX_RECT_R 0x08 -#define G_BG_1CYC 0x09 -#define G_BG_COPY 0x0a -#define G_OBJ_RENDERMODE 0x0b -#else -#define G_BG_1CYC 0x01 -#define G_BG_COPY 0x02 -#define G_OBJ_RECTANGLE 0x03 -#define G_OBJ_SPRITE 0x04 -#define G_OBJ_MOVEMEM 0x05 -#define G_SELECT_DL 0xb0 -#define G_OBJ_RENDERMODE 0xb1 -#define G_OBJ_RECTANGLE_R 0xb2 -#define G_OBJ_LOADTXTR 0xc1 -#define G_OBJ_LDTX_SPRITE 0xc2 -#define G_OBJ_LDTX_RECT 0xc3 -#define G_OBJ_LDTX_RECT_R 0xc4 -#define G_RDPHALF_0 0xe4 -#endif - -/*---------------------------------------------------------------------------* - * Background wrapped screen - *---------------------------------------------------------------------------*/ -#define gSPBgRectangle(pkt, m, mptr) gDma0p((pkt),(m),(mptr),0) -#define gsSPBgRectangle(m, mptr) gsDma0p( (m),(mptr),0) -#define gSPBgRectCopy(pkt, mptr) gSPBgRectangle((pkt), G_BG_COPY, (mptr)) -#define gsSPBgRectCopy(mptr) gsSPBgRectangle( G_BG_COPY, (mptr)) -#define gSPBgRect1Cyc(pkt, mptr) gSPBgRectangle((pkt), G_BG_1CYC, (mptr)) -#define gsSPBgRect1Cyc(mptr) gsSPBgRectangle( G_BG_1CYC, (mptr)) - -/*---------------------------------------------------------------------------* - * 2D Objects - *---------------------------------------------------------------------------*/ -#define gSPObjSprite(pkt, mptr) gDma0p((pkt),G_OBJ_SPRITE, (mptr),0) -#define gsSPObjSprite(mptr) gsDma0p( G_OBJ_SPRITE, (mptr),0) -#define gSPObjRectangle(pkt, mptr) gDma0p((pkt),G_OBJ_RECTANGLE, (mptr),0) -#define gsSPObjRectangle(mptr) gsDma0p( G_OBJ_RECTANGLE, (mptr),0) -#define gSPObjRectangleR(pkt, mptr) gDma0p((pkt),G_OBJ_RECTANGLE_R,(mptr),0) -#define gsSPObjRectangleR(mptr) gsDma0p( G_OBJ_RECTANGLE_R,(mptr),0) - -/*---------------------------------------------------------------------------* - * 2D Matrix - *---------------------------------------------------------------------------*/ -#define gSPObjMatrix(pkt, mptr) gDma1p((pkt),G_OBJ_MOVEMEM,(mptr),0,23) -#define gsSPObjMatrix(mptr) gsDma1p( G_OBJ_MOVEMEM,(mptr),0,23) -#define gSPObjSubMatrix(pkt, mptr) gDma1p((pkt),G_OBJ_MOVEMEM,(mptr),2, 7) -#define gsSPObjSubMatrix(mptr) gsDma1p( G_OBJ_MOVEMEM,(mptr),2, 7) - -/*---------------------------------------------------------------------------* - * Loading into TMEM - *---------------------------------------------------------------------------*/ -#define gSPObjLoadTxtr(pkt, tptr) gDma0p((pkt),G_OBJ_LOADTXTR, (tptr),23) -#define gsSPObjLoadTxtr(tptr) gsDma0p( G_OBJ_LOADTXTR, (tptr),23) -#define gSPObjLoadTxSprite(pkt, tptr) gDma0p((pkt),G_OBJ_LDTX_SPRITE,(tptr),47) -#define gsSPObjLoadTxSprite(tptr) gsDma0p( G_OBJ_LDTX_SPRITE,(tptr),47) -#define gSPObjLoadTxRect(pkt, tptr) gDma0p((pkt),G_OBJ_LDTX_RECT, (tptr),47) -#define gsSPObjLoadTxRect(tptr) gsDma0p( G_OBJ_LDTX_RECT, (tptr),47) -#define gSPObjLoadTxRectR(pkt, tptr) gDma0p((pkt),G_OBJ_LDTX_RECT_R,(tptr),47) -#define gsSPObjLoadTxRectR(tptr) gsDma0p( G_OBJ_LDTX_RECT_R,(tptr),47) - -/*---------------------------------------------------------------------------* - * Select Display List - *---------------------------------------------------------------------------*/ -#define gSPSelectDL(pkt, mptr, sid, flag, mask) \ -{ gDma1p((pkt), G_RDPHALF_0, (flag), (u32)(mptr) & 0xffff, (sid)); \ - gDma1p((pkt), G_SELECT_DL, (mask), (u32)(mptr) >> 16, G_DL_PUSH); } -#define gsSPSelectDL(mptr, sid, flag, mask) \ -{ gsDma1p(G_RDPHALF_0, (flag), (u32)(mptr) & 0xffff, (sid)); \ - gsDma1p(G_SELECT_DL, (mask), (u32)(mptr) >> 16, G_DL_PUSH); } -#define gSPSelectBranchDL(pkt, mptr, sid, flag, mask) \ -{ gDma1p((pkt), G_RDPHALF_0, (flag), (u32)(mptr) & 0xffff, (sid)); \ - gDma1p((pkt), G_SELECT_DL, (mask), (u32)(mptr) >> 16, G_DL_NOPUSH); } -#define gsSPSelectBranchDL(mptr, sid, flag, mask) \ -{ gsDma1p(G_RDPHALF_0, (flag), (u32)(mptr) & 0xffff, (sid)); \ - gsDma1p(G_SELECT_DL, (mask), (u32)(mptr) >> 16, G_DL_NOPUSH); } - -/*---------------------------------------------------------------------------* - * Set general status - *---------------------------------------------------------------------------*/ -#define G_MW_GENSTAT 0x08 /* Note that it is the same value of G_MW_FOG */ - -#define gSPSetStatus(pkt, sid, val) \ - gMoveWd((pkt), G_MW_GENSTAT, (sid), (val)) -#define gsSPSetStatus(sid, val) \ - gsMoveWd( G_MW_GENSTAT, (sid), (val)) - -/*---------------------------------------------------------------------------* - * Set Object Render Mode - *---------------------------------------------------------------------------*/ -#define G_OBJRM_NOTXCLAMP 0x01 -#define G_OBJRM_XLU 0x02 /* Ignored */ -#define G_OBJRM_ANTIALIAS 0x04 /* Ignored */ -#define G_OBJRM_BILERP 0x08 -#define G_OBJRM_SHRINKSIZE_1 0x10 -#define G_OBJRM_SHRINKSIZE_2 0x20 -#define G_OBJRM_WIDEN 0x40 - -#define gSPObjRenderMode(pkt, mode) gImmp1((pkt),G_OBJ_RENDERMODE,(mode)) -#define gsSPObjRenderMode(mode) gsImmp1( G_OBJ_RENDERMODE,(mode)) - -/*===========================================================================* - * Render Mode Macro - *===========================================================================*/ -#define RM_RA_SPRITE(clk) \ - AA_EN | CVG_DST_CLAMP | \ - CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_OPA | TEX_EDGE | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define G_RM_SPRITE G_RM_OPA_SURF -#define G_RM_SPRITE2 G_RM_OPA_SURF2 -#define G_RM_RA_SPRITE RM_RA_SPRITE(1) -#define G_RM_RA_SPRITE2 RM_RA_SPRITE(2) -#define G_RM_AA_SPRITE G_RM_AA_TEX_TERR -#define G_RM_AA_SPRITE2 G_RM_AA_TEX_TERR2 -#define G_RM_XLU_SPRITE G_RM_XLU_SURF -#define G_RM_XLU_SPRITE2 G_RM_XLU_SURF2 -#define G_RM_AA_XLU_SPRITE G_RM_AA_XLU_SURF -#define G_RM_AA_XLU_SPRITE2 G_RM_AA_XLU_SURF2 - -/*===========================================================================* - * External functions - *===========================================================================*/ -extern u64 gspS2DEX_fifoTextStart[], gspS2DEX_fifoTextEnd[]; -extern u64 gspS2DEX_fifoDataStart[], gspS2DEX_fifoDataEnd[]; -extern u64 gspS2DEX_fifo_dTextStart[], gspS2DEX_fifo_dTextEnd[]; -extern u64 gspS2DEX_fifo_dDataStart[], gspS2DEX_fifo_dDataEnd[]; -extern u64 gspS2DEX2_fifoTextStart[], gspS2DEX2_fifoTextEnd[]; -extern u64 gspS2DEX2_fifoDataStart[], gspS2DEX2_fifoDataEnd[]; -extern u64 gspS2DEX2_xbusTextStart[], gspS2DEX2_xbusTextEnd[]; -extern u64 gspS2DEX2_xbusDataStart[], gspS2DEX2_xbusDataEnd[]; -extern void guS2DInitBg(uObjBg *); - -#ifdef F3DEX_GBI_2 -# define guS2DEmuBgRect1Cyc guS2D2EmuBgRect1Cyc /*Wrapper*/ -# define guS2DEmuSetScissor guS2D2EmuSetScissor /*Wrapper*/ - extern void guS2D2EmuSetScissor(u32, u32, u32, u32, u8); - extern void guS2D2EmuBgRect1Cyc(Gfx **, uObjBg *); -#else - extern void guS2DEmuSetScissor(u32, u32, u32, u32, u8); - extern void guS2DEmuBgRect1Cyc(Gfx **, uObjBg *); -#endif - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif -#endif /* _GS2DEX_H_ */ - -/*======== End of gs2dex.h ========*/ diff --git a/include/PR/gu.h b/include/PR/gu.h deleted file mode 100644 index 9b34e19f0..000000000 --- a/include/PR/gu.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef _ULTRA64_GU_H_ -#define _ULTRA64_GU_H_ - -#include -#include -#include "common_structs.h" - -#define GU_PI 3.1415926 -/* Functions */ - -void guPerspectiveF(float mf[4][4], u16 *perspNorm, float fovy, float aspect, - float near, float far, float scale); -void guPerspective(Mtx *m, u16 *perspNorm, float fovy, float aspect, float near, - float far, float scale); -void guFrustum(Mtx *m, float left, float right, float bottom, float top, - float near, float far, float scale); -void guOrtho(Mtx *m, float left, float right, float bottom, float top, - float near, float far, float scale); -void guTranslate(Mtx *m, float x, float y, float z); -void guRotate(Mtx *m, float a, float x, float y, float z); -void guScale(Mtx *m, float x, float y, float z); -void guMtxF2L(float mf[4][4], Mtx *m); -void guMtxIdent(Mtx *m); -void guMtxIdentF(float mf[4][4]); -void guMtxL2F(float mf[4][4], Mtx *m); -void guNormalize(float *, float *, float *); - - -void guLookAt(Mtx *, - f32, - f32, - f32, - f32, - f32, - f32, - f32, - f32, - f32); - -void guLookAtF(f32[4][4], - f32, - f32, - f32, - f32, - f32, - f32, - f32, - f32, - f32); - -/* Used only in Fast3DEX2 */ -void guLookAtReflect (Mtx *m, LookAt *l, float xEye, float yEye, float zEye, - float xAt, float yAt, float zAt, - float xUp, float yUp, float zUp); -#endif diff --git a/include/PR/libaudio.h b/include/PR/libaudio.h index c374a9ff3..209a43227 100644 --- a/include/PR/libaudio.h +++ b/include/PR/libaudio.h @@ -1,7 +1,7 @@ #ifndef _ULTRA64_LIBAUDIO_H_ #define _ULTRA64_LIBAUDIO_H_ -#include "abi.h" +#include typedef struct { diff --git a/include/PR/libultra.h b/include/PR/libultra.h deleted file mode 100644 index eaccc0113..000000000 --- a/include/PR/libultra.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef _LIBULTRA_H -#define _LIBULTRA_H - -#define TV_TYPE_NTSC 1 -#define TV_TYPE_PAL 0 -#define TV_TYPE_MPAL 2 - -#define RESET_TYPE_COLD_RESET 0 -#define RESET_TYPE_NMI 1 -#define RESET_TYPE_BOOT_DISK 2 - -extern u32 osTvType; -extern u32 osRomBase; -extern u32 osResetType; -extern u32 osMemSize; -extern s32 osAppNmiBuffer[16]; - -#endif /* _LIBULTRA_H */ diff --git a/include/PR/mbi.h b/include/PR/mbi.h deleted file mode 100644 index 6d54a00e2..000000000 --- a/include/PR/mbi.h +++ /dev/null @@ -1,101 +0,0 @@ -#ifndef _MBI_H_ -#define _MBI_H_ - -/************************************************************************** - * * - * Copyright (C) 1994, Silicon Graphics, Inc. * - * * - * These coded instructions, statements, and computer programs contain * - * unpublished proprietary information of Silicon Graphics, Inc., and * - * are protected by Federal copyright law. They may not be disclosed * - * to third parties or copied or duplicated in any form, in whole or * - * in part, without the prior written consent of Silicon Graphics, Inc. * - * * - **************************************************************************/ - -/************************************************************************** - * - * $Revision: 1.136 $ - * $Date: 1999/01/05 13:04:00 $ - * $Source: /hosts/gate3/exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/mbi.h,v $ - * - **************************************************************************/ - -/* - * Header file for the Media Binary Interface - * - * NOTE: This file is included by the RSP microcode, so any C-specific - * constructs must be bracketed by #ifdef _LANGUAGE_C - * - */ - - -/* - * the SHIFT macros are used to build display list commands, inserting - * bit-fields into a 32-bit word. They take a value, a shift amount, - * and a width. - * - * For the left shift, the lower bits of the value are masked, - * then shifted left. - * - * For the right shift, the value is shifted right, then the lower bits - * are masked. - * - * (NOTE: _SHIFTL(v, 0, 32) won't work, just use an assignment) - * - */ -#define _SHIFTL(v, s, w) \ - ((unsigned int) (((unsigned int)(v) & ((0x01 << (w)) - 1)) << (s))) -#define _SHIFTR(v, s, w) \ - ((unsigned int)(((unsigned int)(v) >> (s)) & ((0x01 << (w)) - 1))) - -#define _SHIFT _SHIFTL /* old, for compatibility only */ - -#define G_ON (1) -#define G_OFF (0) - -/************************************************************************** - * - * Graphics Binary Interface - * - **************************************************************************/ - -#include - -/************************************************************************** - * - * Audio Binary Interface - * - **************************************************************************/ - -#include - -/************************************************************************** - * - * Task list - * - **************************************************************************/ - -#define M_GFXTASK 1 -#define M_AUDTASK 2 -#define M_VIDTASK 3 -#define M_HVQTASK 6 -#define M_HVQMTASK 7 - -/************************************************************************** - * - * Segment macros and definitions - * - **************************************************************************/ - -#define NUM_SEGMENTS (16) -#define SEGMENT_OFFSET(a) ((unsigned int)(a) & 0x00ffffff) -#define SEGMENT_NUMBER(a) (((unsigned int)(a) << 4) >> 28) -#define SEGMENT_NUMBER2(a) ((unsigned int)(a) >> 24) -#define SEGMENT_ADDR(num, off) (((num) << 24) + (off)) - -#ifndef NULL -#define NULL 0 -#endif - -#endif /* !_MBI_H_ */ diff --git a/include/PR/os.h b/include/PR/os.h deleted file mode 100644 index e710ccaa8..000000000 --- a/include/PR/os.h +++ /dev/null @@ -1,800 +0,0 @@ - -/*==================================================================== - * os.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/************************************************************************** - * - * $Revision: 1.149 $ - * $Date: 1997/12/15 04:30:52 $ - * $Source: /disk6/Master/cvsmdev2/PR/include/os.h,v $ - * - **************************************************************************/ - - -#ifndef _OS_H_ -#define _OS_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include -#include "PR/os_message.h" - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - -/* - * Structure for device manager block - */ -typedef struct { - s32 active; /* Status flag */ - OSThread *thread; /* Calling thread */ - OSMesgQueue *cmdQueue; /* Command queue */ - OSMesgQueue *evtQueue; /* Event queue */ - OSMesgQueue *acsQueue; /* Access queue */ - /* Raw DMA routine */ - s32 (*dma)(s32, u32, void *, u32); - s32 (*edma)(OSPiHandle *, s32, u32, void *, u32); -} OSDevMgr; - -/* - * Structure for file system - */ - - - -typedef struct { - int status; - OSMesgQueue *queue; - int channel; - u8 id[32]; - u8 label[32]; - int version; - int dir_size; - int inode_table; /* block location */ - int minode_table; /* mirrioring inode_table */ - int dir_table; /* block location */ - int inode_start_page; /* page # */ - u8 banks; - u8 activebank; -} OSPfs; - - -typedef struct { - u32 file_size; /* bytes */ - u32 game_code; - u16 company_code; - char ext_name[4]; - char game_name[16]; -} OSPfsState; - -/* - * Structure for Profiler - */ -typedef struct { - u16 *histo_base; /* histogram base */ - u32 histo_size; /* histogram size */ - u32 *text_start; /* start of text segment */ - u32 *text_end; /* end of text segment */ -} OSProf; - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - -/* Thread states */ - -#define OS_STATE_STOPPED 1 -#define OS_STATE_RUNNABLE 2 -#define OS_STATE_RUNNING 4 -#define OS_STATE_WAITING 8 - -/* Events */ -#ifdef _FINALROM -#define OS_NUM_EVENTS 15 -#else -#define OS_NUM_EVENTS 23 -#endif - -#define OS_EVENT_SW1 0 /* CPU SW1 interrupt */ -#define OS_EVENT_SW2 1 /* CPU SW2 interrupt */ -#define OS_EVENT_CART 2 /* Cartridge interrupt: used by rmon */ -#define OS_EVENT_COUNTER 3 /* Counter int: used by VI/Timer Mgr */ -#define OS_EVENT_SP 4 /* SP task done interrupt */ -#define OS_EVENT_SI 5 /* SI (controller) interrupt */ -#define OS_EVENT_AI 6 /* AI interrupt */ -#define OS_EVENT_VI 7 /* VI interrupt: used by VI/Timer Mgr */ -#define OS_EVENT_PI 8 /* PI interrupt: used by PI Manager */ -#define OS_EVENT_DP 9 /* DP full sync interrupt */ -#define OS_EVENT_CPU_BREAK 10 /* CPU breakpoint: used by rmon */ -#define OS_EVENT_SP_BREAK 11 /* SP breakpoint: used by rmon */ -#define OS_EVENT_FAULT 12 /* CPU fault event: used by rmon */ -#define OS_EVENT_THREADSTATUS 13 /* CPU thread status: used by rmon */ -#define OS_EVENT_PRENMI 14 /* Pre NMI interrupt */ -#ifndef _FINALROM -#define OS_EVENT_RDB_READ_DONE 15 /* RDB read ok event: used by rmon */ -#define OS_EVENT_RDB_LOG_DONE 16 /* read of log data complete */ -#define OS_EVENT_RDB_DATA_DONE 17 /* read of hostio data complete */ -#define OS_EVENT_RDB_REQ_RAMROM 18 /* host needs ramrom access */ -#define OS_EVENT_RDB_FREE_RAMROM 19 /* host is done with ramrom access */ -#define OS_EVENT_RDB_DBG_DONE 20 -#define OS_EVENT_RDB_FLUSH_PROF 21 -#define OS_EVENT_RDB_ACK_PROF 22 -#endif - -/* Flags for debugging purpose */ - -#define OS_FLAG_CPU_BREAK 1 /* Break exception has occurred */ -#define OS_FLAG_FAULT 2 /* CPU fault has occurred */ - -/* Interrupt masks */ - -#define OS_IM_NONE 0x00000001 -#define OS_IM_SW1 0x00000501 -#define OS_IM_SW2 0x00000601 -#define OS_IM_CART 0x00000c01 -#define OS_IM_PRENMI 0x00001401 -#define OS_IM_RDBWRITE 0x00002401 -#define OS_IM_RDBREAD 0x00004401 -#define OS_IM_COUNTER 0x00008401 -#define OS_IM_CPU 0x0000ff01 -#define OS_IM_SP 0x00010401 -#define OS_IM_SI 0x00020401 -#define OS_IM_AI 0x00040401 -#define OS_IM_VI 0x00080401 -#define OS_IM_PI 0x00100401 -#define OS_IM_DP 0x00200401 -#define OS_IM_ALL 0x003fff01 -#define RCP_IMASK 0x003f0000 -#define RCP_IMASKSHIFT 16 - -/* Recommended thread priorities for the system threads */ - -#define OS_PRIORITY_MAX 255 -#define OS_PRIORITY_VIMGR 254 -#define OS_PRIORITY_RMON 250 -#define OS_PRIORITY_RMONSPIN 200 -#define OS_PRIORITY_PIMGR 150 -#define OS_PRIORITY_SIMGR 140 -#define OS_PRIORITY_APPMAX 127 -#define OS_PRIORITY_IDLE 0 /* Must be 0 */ - - -/* Flags to turn blocking on/off when sending/receiving message */ - -#define OS_MESG_NOBLOCK 0 -#define OS_MESG_BLOCK 1 - -/* Flags to indicate direction of data transfer */ - -#define OS_READ 0 /* device -> RDRAM */ -#define OS_WRITE 1 /* device <- RDRAM */ -#define OS_OTHERS 2 /* for Leo disk only */ - -/* - * I/O message types - */ -#define OS_MESG_TYPE_BASE (10) -#define OS_MESG_TYPE_LOOPBACK (OS_MESG_TYPE_BASE+0) -#define OS_MESG_TYPE_DMAREAD (OS_MESG_TYPE_BASE+1) -#define OS_MESG_TYPE_DMAWRITE (OS_MESG_TYPE_BASE+2) -#define OS_MESG_TYPE_VRETRACE (OS_MESG_TYPE_BASE+3) -#define OS_MESG_TYPE_COUNTER (OS_MESG_TYPE_BASE+4) -#define OS_MESG_TYPE_EDMAREAD (OS_MESG_TYPE_BASE+5) -#define OS_MESG_TYPE_EDMAWRITE (OS_MESG_TYPE_BASE+6) - -/* - * I/O message priority - */ -#define OS_MESG_PRI_NORMAL 0 -#define OS_MESG_PRI_HIGH 1 - -/* - * Page size argument for TLB routines - */ -#define OS_PM_4K 0x0000000 -#define OS_PM_16K 0x0006000 -#define OS_PM_64K 0x001e000 -#define OS_PM_256K 0x007e000 -#define OS_PM_1M 0x01fe000 -#define OS_PM_4M 0x07fe000 -#define OS_PM_16M 0x1ffe000 - -/* - * Stack size for I/O device managers: PIM (PI Manager), VIM (VI Manager), - * SIM (SI Manager) - * - */ -#define OS_PIM_STACKSIZE 4096 -#define OS_VIM_STACKSIZE 4096 -#define OS_SIM_STACKSIZE 4096 - -#define OS_MIN_STACKSIZE 72 - -/* - * Values for osTvType - */ -#define OS_TV_PAL 0 -#define OS_TV_NTSC 1 -#define OS_TV_MPAL 2 - -/* - * Video Interface (VI) mode type - */ -#define OS_VI_NTSC_LPN1 0 /* NTSC */ -#define OS_VI_NTSC_LPF1 1 -#define OS_VI_NTSC_LAN1 2 -#define OS_VI_NTSC_LAF1 3 -#define OS_VI_NTSC_LPN2 4 -#define OS_VI_NTSC_LPF2 5 -#define OS_VI_NTSC_LAN2 6 -#define OS_VI_NTSC_LAF2 7 -#define OS_VI_NTSC_HPN1 8 -#define OS_VI_NTSC_HPF1 9 -#define OS_VI_NTSC_HAN1 10 -#define OS_VI_NTSC_HAF1 11 -#define OS_VI_NTSC_HPN2 12 -#define OS_VI_NTSC_HPF2 13 - -#define OS_VI_PAL_LPN1 14 /* PAL */ -#define OS_VI_PAL_LPF1 15 -#define OS_VI_PAL_LAN1 16 -#define OS_VI_PAL_LAF1 17 -#define OS_VI_PAL_LPN2 18 -#define OS_VI_PAL_LPF2 19 -#define OS_VI_PAL_LAN2 20 -#define OS_VI_PAL_LAF2 21 -#define OS_VI_PAL_HPN1 22 -#define OS_VI_PAL_HPF1 23 -#define OS_VI_PAL_HAN1 24 -#define OS_VI_PAL_HAF1 25 -#define OS_VI_PAL_HPN2 26 -#define OS_VI_PAL_HPF2 27 - -#define OS_VI_MPAL_LPN1 28 /* MPAL - mainly Brazil */ -#define OS_VI_MPAL_LPF1 29 -#define OS_VI_MPAL_LAN1 30 -#define OS_VI_MPAL_LAF1 31 -#define OS_VI_MPAL_LPN2 32 -#define OS_VI_MPAL_LPF2 33 -#define OS_VI_MPAL_LAN2 34 -#define OS_VI_MPAL_LAF2 35 -#define OS_VI_MPAL_HPN1 36 -#define OS_VI_MPAL_HPF1 37 -#define OS_VI_MPAL_HAN1 38 -#define OS_VI_MPAL_HAF1 39 -#define OS_VI_MPAL_HPN2 40 -#define OS_VI_MPAL_HPF2 41 - -/* - * Video Interface (VI) special features - */ -#define OS_VI_GAMMA_ON 0x0001 -#define OS_VI_GAMMA_OFF 0x0002 -#define OS_VI_GAMMA_DITHER_ON 0x0004 -#define OS_VI_GAMMA_DITHER_OFF 0x0008 -#define OS_VI_DIVOT_ON 0x0010 -#define OS_VI_DIVOT_OFF 0x0020 -#define OS_VI_DITHER_FILTER_ON 0x0040 -#define OS_VI_DITHER_FILTER_OFF 0x0080 - -/* - * Video Interface (VI) mode attribute bit - */ -#define OS_VI_BIT_NONINTERLACE 0x0001 /* lo-res */ -#define OS_VI_BIT_INTERLACE 0x0002 /* lo-res */ -#define OS_VI_BIT_NORMALINTERLACE 0x0004 /* hi-res */ -#define OS_VI_BIT_DEFLICKINTERLACE 0x0008 /* hi-res */ -#define OS_VI_BIT_ANTIALIAS 0x0010 -#define OS_VI_BIT_POINTSAMPLE 0x0020 -#define OS_VI_BIT_16PIXEL 0x0040 -#define OS_VI_BIT_32PIXEL 0x0080 -#define OS_VI_BIT_LORES 0x0100 -#define OS_VI_BIT_HIRES 0x0200 -#define OS_VI_BIT_NTSC 0x0400 -#define OS_VI_BIT_PAL 0x0800 - -/* - * Leo Disk - */ - -/* transfer mode */ - -#define LEO_BLOCK_MODE 1 -#define LEO_TRACK_MODE 2 -#define LEO_SECTOR_MODE 3 - -/* - * Controllers number - */ - -#ifndef _HW_VERSION_1 -#define MAXCONTROLLERS 4 -#else -#define MAXCONTROLLERS 6 -#endif - -/* controller errors */ -#define CONT_NO_RESPONSE_ERROR 0x8 -#define CONT_OVERRUN_ERROR 0x4 -#ifdef _HW_VERSION_1 -#define CONT_FRAME_ERROR 0x2 -#define CONT_COLLISION_ERROR 0x1 -#endif - -/* Controller type */ - -#define CONT_ABSOLUTE 0x0001 -#define CONT_RELATIVE 0x0002 -#define CONT_JOYPORT 0x0004 -#define CONT_EEPROM 0x8000 -#define CONT_EEP16K 0x4000 -#define CONT_TYPE_MASK 0x1f07 -#define CONT_TYPE_NORMAL 0x0005 -#define CONT_TYPE_MOUSE 0x0002 - -/* Controller status */ - -#define CONT_CARD_ON 0x01 -#define CONT_CARD_PULL 0x02 -#define CONT_ADDR_CRC_ER 0x04 -#define CONT_EEPROM_BUSY 0x80 - -/* EEPROM TYPE */ - -#define EEPROM_TYPE_4K 0x01 -#define EEPROM_TYPE_16K 0x02 - -/* Buttons */ - -#define CONT_A 0x8000 -#define CONT_B 0x4000 -#define CONT_G 0x2000 -#define CONT_START 0x1000 -#define CONT_UP 0x0800 -#define CONT_DOWN 0x0400 -#define CONT_LEFT 0x0200 -#define CONT_RIGHT 0x0100 -#define CONT_L 0x0020 -#define CONT_R 0x0010 -#define CONT_E 0x0008 -#define CONT_D 0x0004 -#define CONT_C 0x0002 -#define CONT_F 0x0001 - -/* Nintendo's official button names */ - -#define A_BUTTON CONT_A -#define B_BUTTON CONT_B -#define L_TRIG CONT_L -#define R_TRIG CONT_R -#define Z_TRIG CONT_G -#define START_BUTTON CONT_START -#define U_JPAD CONT_UP -#define L_JPAD CONT_LEFT -#define R_JPAD CONT_RIGHT -#define D_JPAD CONT_DOWN -#define U_CBUTTONS CONT_E -#define L_CBUTTONS CONT_C -#define R_CBUTTONS CONT_F -#define D_CBUTTONS CONT_D - -/* File System size */ -#define OS_PFS_VERSION 0x0200 -#define OS_PFS_VERSION_HI (OS_PFS_VERSION >> 8) -#define OS_PFS_VERSION_LO (OS_PFS_VERSION & 255) - -#define PFS_FILE_NAME_LEN 16 -#define PFS_FILE_EXT_LEN 4 -#define BLOCKSIZE 32 /* bytes */ -#define PFS_ONE_PAGE 8 /* blocks */ -#define PFS_MAX_BANKS 62 - -/* File System flag */ - -#define PFS_READ 0 -#define PFS_WRITE 1 -#define PFS_CREATE 2 - -/* File System status */ -#define PFS_INITIALIZED 0x1 -#define PFS_CORRUPTED 0x2 /* File system was corrupted */ - -/* File System error number */ - -#define PFS_ERR_NOPACK 1 /* no memory card is plugged or */ -#define PFS_ERR_NEW_PACK 2 /* ram pack has been changed to a */ - /* different one */ -#define PFS_ERR_INCONSISTENT 3 /* need to run Pfschecker */ -#define PFS_ERR_CONTRFAIL CONT_OVERRUN_ERROR -#define PFS_ERR_INVALID 5 /* invalid parameter or file not exist*/ -#define PFS_ERR_BAD_DATA 6 /* the data read from pack are bad*/ -#define PFS_DATA_FULL 7 /* no free pages on ram pack */ -#define PFS_DIR_FULL 8 /* no free directories on ram pack*/ -#define PFS_ERR_EXIST 9 /* file exists */ -#define PFS_ERR_ID_FATAL 10 /* dead ram pack */ -#define PFS_ERR_DEVICE 11 /* wrong device type*/ - -/* definition for EEPROM */ - -#define EEPROM_MAXBLOCKS 64 -#define EEP16K_MAXBLOCKS 256 -#define EEPROM_BLOCK_SIZE 8 - -/* - * PI/EPI - */ -#define PI_DOMAIN1 0 -#define PI_DOMAIN2 1 - -/* - * Profiler constants - */ -#define PROF_MIN_INTERVAL 50 /* microseconds */ - -/* - * Boot addresses - */ -#define BOOT_ADDRESS_ULTRA 0x80000400 -#define BOOT_ADDRESS_COSIM 0x80002000 -#define BOOT_ADDRESS_EMU 0x20010000 -#define BOOT_ADDRESS_INDY 0x88100000 - -/* - * Size of buffer the retains contents after NMI - */ -#define OS_APP_NMI_BUFSIZE 64 - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - -/* PARTNER-N64 */ -#ifdef PTN64 -#define osReadHost osReadHost_pt -#define osWriteHost osWriteHost_pt -#endif - -/* Get count of valid messages in queue */ -#define MQ_GET_COUNT(mq) ((mq)->validCount) - -/* Figure out if message queue is empty or full */ -#define MQ_IS_EMPTY(mq) (MQ_GET_COUNT(mq) == 0) -#define MQ_IS_FULL(mq) (MQ_GET_COUNT(mq) >= (mq)->msgCount) - -/* - * CPU counter increments at 3/4 of bus clock rate: - * - * Bus Clock Proc Clock Counter (1/2 Proc Clock) - * --------- ---------- ------------------------ - * 62.5 Mhz 93.75 Mhz 46.875 Mhz - */ -extern u64 osClockRate; - -#define OS_CLOCK_RATE 62500000LL -#define OS_CPU_COUNTER (OS_CLOCK_RATE*3/4) -#define OS_NSEC_TO_CYCLES(n) (((u64)(n)*(OS_CPU_COUNTER/15625000LL))/(1000000000LL/15625000LL)) -#define OS_USEC_TO_CYCLES(n) (((u64)(n)*(OS_CPU_COUNTER/15625LL))/(1000000LL/15625LL)) -#define OS_CYCLES_TO_NSEC(c) (((u64)(c)*(1000000000LL/15625000LL))/(OS_CPU_COUNTER/15625000LL)) -#define OS_CYCLES_TO_USEC(c) (((u64)(c)*(1000000LL/15625LL))/(OS_CPU_COUNTER/15625LL)) - -/************************************************************************** - * - * Extern variables - * - */ -extern OSViMode osViModeTable[]; /* Global VI mode table */ - -extern OSViMode osViModeNtscLpn1; /* Individual VI NTSC modes */ -extern OSViMode osViModeNtscLpf1; -extern OSViMode osViModeNtscLan1; -extern OSViMode osViModeNtscLaf1; -extern OSViMode osViModeNtscLpn2; -extern OSViMode osViModeNtscLpf2; -extern OSViMode osViModeNtscLan2; -extern OSViMode osViModeNtscLaf2; -extern OSViMode osViModeNtscHpn1; -extern OSViMode osViModeNtscHpf1; -extern OSViMode osViModeNtscHan1; -extern OSViMode osViModeNtscHaf1; -extern OSViMode osViModeNtscHpn2; -extern OSViMode osViModeNtscHpf2; - -extern OSViMode osViModePalLpn1; /* Individual VI PAL modes */ -extern OSViMode osViModePalLpf1; -extern OSViMode osViModePalLan1; -extern OSViMode osViModePalLaf1; -extern OSViMode osViModePalLpn2; -extern OSViMode osViModePalLpf2; -extern OSViMode osViModePalLan2; -extern OSViMode osViModePalLaf2; -extern OSViMode osViModePalHpn1; -extern OSViMode osViModePalHpf1; -extern OSViMode osViModePalHan1; -extern OSViMode osViModePalHaf1; -extern OSViMode osViModePalHpn2; -extern OSViMode osViModePalHpf2; - -extern OSViMode osViModeMpalLpn1; /* Individual VI MPAL modes */ -extern OSViMode osViModeMpalLpf1; -extern OSViMode osViModeMpalLan1; -extern OSViMode osViModeMpalLaf1; -extern OSViMode osViModeMpalLpn2; -extern OSViMode osViModeMpalLpf2; -extern OSViMode osViModeMpalLan2; -extern OSViMode osViModeMpalLaf2; -extern OSViMode osViModeMpalHpn1; -extern OSViMode osViModeMpalHpf1; -extern OSViMode osViModeMpalHan1; -extern OSViMode osViModeMpalHaf1; -extern OSViMode osViModeMpalHpn2; -extern OSViMode osViModeMpalHpf2; - -extern s32 osRomType; /* Bulk or cartridge ROM. 0=cartridge 1=bulk */ -extern u32 osRomBase; /* Rom base address of the game image */ -extern u32 osTvType; /* 0 = PAL, 1 = NTSC, 2 = MPAL */ -extern u32 osResetType; /* 0 = cold reset, 1 = NMI */ -extern s32 osCicId; -extern s32 osVersion; -extern u32 osMemSize; /* Memory Size */ -extern s32 osAppNMIBuffer[]; - -extern OSIntMask __OSGlobalIntMask; /* global interrupt mask */ -extern OSPiHandle *__osPiTable; /* The head of OSPiHandle link list */ -extern OSPiHandle *__osDiskHandle; /* For exceptasm to get disk info*/ - - - -/************************************************************************** - * - * Function prototypes - * - */ - -/* Thread operations */ - -extern void osCreateThread(OSThread *, OSId, void (*)(void *), - void *, void *, OSPri); -extern void osDestroyThread(OSThread *); -extern void osYieldThread(void); -extern void osStartThread(OSThread *); -extern void osStopThread(OSThread *); -extern OSId osGetThreadId(OSThread *); -extern void osSetThreadPri(OSThread *, OSPri); -extern OSPri osGetThreadPri(OSThread *); - -/* Message operations */ - -extern void osCreateMesgQueue(OSMesgQueue *, OSMesg *, s32); -extern s32 osSendMesg(OSMesgQueue *, OSMesg, s32); -extern s32 osJamMesg(OSMesgQueue *, OSMesg, s32); -extern s32 osRecvMesg(OSMesgQueue *, OSMesg *, s32); - -/* Event operations */ - -extern void osSetEventMesg(OSEvent, OSMesgQueue *, OSMesg); - -/* Interrupt operations */ - -extern OSIntMask osGetIntMask(void); -extern OSIntMask osSetIntMask(OSIntMask); - -/* RDB port operations */ - -extern void osInitRdb(u8 *sendBuf, u32 sendSize); - -/* Cache operations and macros */ - -extern void osInvalDCache(void *, size_t); -extern void osInvalICache(void *, size_t); -extern void osWritebackDCache(void *, size_t); -extern void osWritebackDCacheAll(void); - -#define OS_DCACHE_ROUNDUP_ADDR(x) (void *)(((((u32)(x)+0xf)/0x10)*0x10)) -#define OS_DCACHE_ROUNDUP_SIZE(x) (u32)(((((u32)(x)+0xf)/0x10)*0x10)) - -/* TLB management routines */ - -extern void osMapTLB(s32, OSPageMask, void *, u32, u32, s32); -extern void osMapTLBRdb(void); -extern void osUnmapTLB(s32); -extern void osUnmapTLBAll(void); -extern void osSetTLBASID(s32); - -/* Address translation routines and macros */ - -extern u32 osVirtualToPhysical(void *); -extern void * osPhysicalToVirtual(u32); - -#define OS_K0_TO_PHYSICAL(x) (u32)(((char *)(x)-0x80000000)) -#define OS_K1_TO_PHYSICAL(x) (u32)(((char *)(x)-0xa0000000)) - -#define OS_PHYSICAL_TO_K0(x) (void *)(((u32)(x)+0x80000000)) -#define OS_PHYSICAL_TO_K1(x) (void *)(((u32)(x)+0xa0000000)) - -/* I/O operations */ - -/* Audio interface (Ai) */ -extern u32 osAiGetStatus(void); -extern u32 osAiGetLength(void); -extern s32 osAiSetFrequency(u32); -extern s32 osAiSetNextBuffer(void *, u32); - -/* Display processor interface (Dp) */ -extern u32 osDpGetStatus(void); -extern void osDpSetStatus(u32); -extern void osDpGetCounters(u32 *); -extern s32 osDpSetNextBuffer(void *, u64); - -/* Peripheral interface (Pi) */ -extern u32 osPiGetStatus(void); -extern s32 osPiGetDeviceType(void); -extern s32 osPiRawWriteIo(u32, u32); -extern s32 osPiRawReadIo(u32, u32 *); -extern s32 osPiRawStartDma(s32, u32, void *, u32); -extern s32 osPiWriteIo(u32, u32); -extern s32 osPiReadIo(u32, u32 *); -extern s32 osPiStartDma(OSIoMesg *, s32, s32, u32, void *, u32, - OSMesgQueue *); -extern void osCreatePiManager(OSPri, OSMesgQueue *, OSMesg *, s32); - -/* Video interface (Vi) */ -extern u32 osViGetStatus(void); -extern u32 osViGetCurrentMode(void); -extern u32 osViGetCurrentLine(void); -extern u32 osViGetCurrentField(void); -extern void *osViGetCurrentFramebuffer(void); -extern void *osViGetNextFramebuffer(void); -extern void osViSetXScale(f32); -extern void osViSetYScale(f32); -extern void osViSetSpecialFeatures(u32); -extern void osViSetMode(OSViMode *); -extern void osViSetEvent(OSMesgQueue *, OSMesg, u32); -extern void osViSwapBuffer(void *); -extern void osViBlack(u8); -extern void osViFade(u8, u16); -extern void osViRepeatLine(u8); -extern void osCreateViManager(OSPri); - -/* Timer interface */ - -extern OSTime osGetTime(void); -extern void osSetTime(OSTime); -extern u32 osSetTimer(OSTimer *, OSTime, OSTime, - OSMesgQueue *, OSMesg); -extern int osStopTimer(OSTimer *); - -/* Controller interface */ - -extern s32 osContInit(OSMesgQueue *, u8 *, OSContStatus *); -extern s32 osContReset(OSMesgQueue *, OSContStatus *); -extern s32 osContStartQuery(OSMesgQueue *); -extern s32 osContStartReadData(OSMesgQueue *); -#ifndef _HW_VERSION_1 -extern s32 osContSetCh(u8); -#endif -extern void osContGetQuery(OSContStatus *); -extern void osContGetReadData(OSContPad *); - -/* file system interface */ - -extern s32 osPfsInitPak(OSMesgQueue *, OSPfs *, int); -extern s32 osPfsRepairId(OSPfs *); -extern s32 osPfsInit(OSMesgQueue *, OSPfs *, int); -extern s32 osPfsReFormat(OSPfs *, OSMesgQueue *, int); -extern s32 osPfsChecker(OSPfs *); -extern s32 osPfsAllocateFile(OSPfs *, u16, u32, u8 *, u8 *, int, s32 *); -extern s32 osPfsFindFile(OSPfs *, u16, u32, u8 *, u8 *, s32 *); -extern s32 osPfsDeleteFile(OSPfs *, u16, u32, u8 *, u8 *); -extern s32 osPfsReadWriteFile(OSPfs *, s32, u8, int, int, u8 *); -extern s32 osPfsFileState(OSPfs *, s32, OSPfsState *); -extern s32 osPfsGetLabel(OSPfs *, u8 *, int *); -extern s32 osPfsSetLabel(OSPfs *, u8 *); -extern s32 osPfsIsPlug(OSMesgQueue *, u8 *); -extern s32 osPfsFreeBlocks(OSPfs *, s32 *); -extern s32 osPfsNumFiles(OSPfs *, s32 *, s32 *); - -/* EEPROM interface */ - -extern s32 osEepromProbe(OSMesgQueue *); -extern s32 osEepromRead(OSMesgQueue *, u8, u8 *); -extern s32 osEepromWrite(OSMesgQueue *, u8, u8 *); -extern s32 osEepromLongRead(OSMesgQueue *, u8, u8 *, s32); -extern s32 osEepromLongWrite(OSMesgQueue *, u8, u8 *, s32); - -/* MOTOR interface */ - -extern s32 osMotorInit(OSMesgQueue *, OSPfs *, int); -extern s32 osMotorStop(OSPfs *); -extern s32 osMotorStart(OSPfs *); - -/* Enhanced PI interface */ - -extern OSPiHandle *osCartRomInit(void); -extern OSPiHandle *osLeoDiskInit(void); -extern OSPiHandle *osDriveRomInit(void); - -extern s32 osEPiDeviceType(OSPiHandle *, OSPiInfo *); -extern s32 osEPiRawWriteIo(OSPiHandle *, u32 , u32); -extern s32 osEPiRawReadIo(OSPiHandle *, u32 , u32 *); -extern s32 osEPiRawStartDma(OSPiHandle *, s32 , u32 , void *, u32 ); -extern s32 osEPiWriteIo(OSPiHandle *, u32 , u32 ); -extern s32 osEPiReadIo(OSPiHandle *, u32 , u32 *); -extern s32 osEPiStartDma(OSPiHandle *, OSIoMesg *, s32); -extern s32 osEPiLinkHandle(OSPiHandle *); - -/* Profiler Interface */ - -extern void osProfileInit(OSProf *, u32 profcnt); -extern void osProfileStart(u32); -extern void osProfileFlush(void); -extern void osProfileStop(void); - -/* Game <> Host data transfer functions */ - -extern s32 osTestHost(void); -extern void osReadHost(void *, u32); -extern void osWriteHost(void *, u32); -extern void osAckRamromRead(void); -extern void osAckRamromWrite(void); - - -/* byte string operations */ - -extern void bcopy(const void *, void *, size_t); -extern int bcmp(const void *, const void *, int); -extern void bzero(void *, size_t); - -/* Miscellaneous operations */ - -extern void osInitialize(void); -extern u32 osGetCount(void); -extern void osExit(void); -extern u32 osGetMemSize(void); - -/* Printf */ - -extern int sprintf(char *s, const char *fmt, ...); -extern void osSyncPrintf(const char *fmt, ...); -extern void osAsyncPrintf(const char *fmt, ...); -extern int osSyncGetChars(char *buf); -extern int osAsyncGetChars(char *buf); - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_H */ diff --git a/include/PR/os_ai.h b/include/PR/os_ai.h deleted file mode 100644 index f89d87cfe..000000000 --- a/include/PR/os_ai.h +++ /dev/null @@ -1,92 +0,0 @@ - -/*==================================================================== - * os_ai.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os_ai.h,v $ - $Revision: 1.1 $ - $Date: 1998/10/09 08:01:04 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_AI_H_ -#define _OS_AI_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - - -/************************************************************************** - * - * Extern variables - * - */ - - -/************************************************************************** - * - * Function prototypes - * - */ - -/* Audio interface (Ai) */ -extern u32 osAiGetStatus(void); -extern u32 osAiGetLength(void); -extern s32 osAiSetFrequency(u32); -extern s32 osAiSetNextBuffer(void *, u32); - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_AI_H_ */ diff --git a/include/PR/os_cache.h b/include/PR/os_cache.h deleted file mode 100644 index 93d53c5f1..000000000 --- a/include/PR/os_cache.h +++ /dev/null @@ -1,96 +0,0 @@ - -/*==================================================================== - * os_cache.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os_cache.h,v $ - $Revision: 1.1 $ - $Date: 1998/10/09 08:01:04 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_CACHE_H_ -#define _OS_CACHE_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - -#define OS_DCACHE_ROUNDUP_ADDR(x) (void *)(((((u32)(x)+0xf)/0x10)*0x10)) -#define OS_DCACHE_ROUNDUP_SIZE(x) (u32)(((((u32)(x)+0xf)/0x10)*0x10)) - - -/************************************************************************** - * - * Extern variables - * - */ - - -/************************************************************************** - * - * Function prototypes - * - */ - -/* Cache operations and macros */ - -extern void osInvalDCache(void *, size_t); -extern void osInvalICache(void *, size_t); -extern void osWritebackDCache(void *, size_t); -extern void osWritebackDCacheAll(void); - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_CACHE_H_ */ diff --git a/include/PR/os_cont.h b/include/PR/os_cont.h deleted file mode 100644 index 2b989a5ab..000000000 --- a/include/PR/os_cont.h +++ /dev/null @@ -1,207 +0,0 @@ - -/*==================================================================== - * os_cont.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os_cont.h,v $ - $Revision: 1.1 $ - $Date: 1998/10/09 08:01:05 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_CONT_H_ -#define _OS_CONT_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include -#include "os_message.h" - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - -/* - * Structure for controllers - */ - -typedef struct { - u16 type; /* Controller Type */ - u8 status; /* Controller status */ - u8 errnum; -}OSContStatus; - -typedef struct { - u16 button; - s8 stick_x; /* -80 <= stick_x <= 80 */ - s8 stick_y; /* -80 <= stick_y <= 80 */ - u8 errno; -} OSContPad; - -typedef struct { - void *address; /* Ram pad Address: 11 bits */ - u8 databuffer[32]; /* address of the data buffer */ - u8 addressCrc; /* CRC code for address */ - u8 dataCrc; /* CRC code for data */ - u8 errno; -} OSContRamIo; - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - -/* - * Controllers number - */ - -#ifndef _HW_VERSION_1 -#define MAXCONTROLLERS 4 -#else -#define MAXCONTROLLERS 6 -#endif - -/* controller errors */ -#define CONT_NO_RESPONSE_ERROR 0x8 -#define CONT_OVERRUN_ERROR 0x4 -#ifdef _HW_VERSION_1 -#define CONT_FRAME_ERROR 0x2 -#define CONT_COLLISION_ERROR 0x1 -#endif - -/* Controller type */ - -#define CONT_ABSOLUTE 0x0001 -#define CONT_RELATIVE 0x0002 -#define CONT_JOYPORT 0x0004 -#define CONT_EEPROM 0x8000 -#define CONT_EEP16K 0x4000 -#define CONT_TYPE_MASK 0x1f07 -#define CONT_TYPE_NORMAL 0x0005 -#define CONT_TYPE_MOUSE 0x0002 -#define CONT_TYPE_VOICE 0x0100 - -/* Controller status */ - -#define CONT_CARD_ON 0x01 -#define CONT_CARD_PULL 0x02 -#define CONT_ADDR_CRC_ER 0x04 -#define CONT_EEPROM_BUSY 0x80 - -/* Buttons */ - -#define CONT_A 0x8000 -#define CONT_B 0x4000 -#define CONT_G 0x2000 -#define CONT_START 0x1000 -#define CONT_UP 0x0800 -#define CONT_DOWN 0x0400 -#define CONT_LEFT 0x0200 -#define CONT_RIGHT 0x0100 -#define CONT_L 0x0020 -#define CONT_R 0x0010 -#define CONT_E 0x0008 -#define CONT_D 0x0004 -#define CONT_C 0x0002 -#define CONT_F 0x0001 - -/* Nintendo's official button names */ - -#define A_BUTTON CONT_A -#define B_BUTTON CONT_B -#define L_TRIG CONT_L -#define R_TRIG CONT_R -#define Z_TRIG CONT_G -#define START_BUTTON CONT_START -#define U_JPAD CONT_UP -#define L_JPAD CONT_LEFT -#define R_JPAD CONT_RIGHT -#define D_JPAD CONT_DOWN -#define U_CBUTTONS CONT_E -#define L_CBUTTONS CONT_C -#define R_CBUTTONS CONT_F -#define D_CBUTTONS CONT_D - -/* Controller error number */ - -#define CONT_ERR_NO_CONTROLLER PFS_ERR_NOPACK /* 1 */ -#define CONT_ERR_CONTRFAIL CONT_OVERRUN_ERROR /* 4 */ -#define CONT_ERR_INVALID PFS_ERR_INVALID /* 5 */ -#define CONT_ERR_DEVICE PFS_ERR_DEVICE /* 11 */ -#define CONT_ERR_NOT_READY 12 -#define CONT_ERR_VOICE_MEMORY 13 -#define CONT_ERR_VOICE_WORD 14 -#define CONT_ERR_VOICE_NO_RESPONSE 15 - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - - -/************************************************************************** - * - * Extern variables - * - */ - - -/************************************************************************** - * - * Function prototypes - * - */ - -/* Controller interface */ - -extern s32 osContInit(OSMesgQueue *, u8 *, OSContStatus *); -extern s32 osContReset(OSMesgQueue *, OSContStatus *); -extern s32 osContStartQuery(OSMesgQueue *); -extern s32 osContStartReadData(OSMesgQueue *); -#ifndef _HW_VERSION_1 -extern s32 osContSetCh(u8); -#endif -extern void osContGetQuery(OSContStatus *); -extern void osContGetReadData(OSContPad *); - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_CONT_H_ */ diff --git a/include/PR/os_eeprom.h b/include/PR/os_eeprom.h deleted file mode 100644 index b3bca8144..000000000 --- a/include/PR/os_eeprom.h +++ /dev/null @@ -1,107 +0,0 @@ - -/*==================================================================== - * os_eeprom.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os_eeprom.h,v $ - $Revision: 1.1 $ - $Date: 1998/10/09 08:01:06 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_EEPROM_H_ -#define _OS_EEPROM_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include -#include "os_message.h" - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - -/* EEPROM TYPE */ - -#define EEPROM_TYPE_4K 0x01 -#define EEPROM_TYPE_16K 0x02 - -/* definition for EEPROM */ - -#define EEPROM_MAXBLOCKS 64 -#define EEP16K_MAXBLOCKS 256 -#define EEPROM_BLOCK_SIZE 8 - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - - -/************************************************************************** - * - * Extern variables - * - */ - - -/************************************************************************** - * - * Function prototypes - * - */ - -/* EEPROM interface */ - -extern s32 osEepromProbe(OSMesgQueue *); -extern s32 osEepromRead(OSMesgQueue *, u8, u8 *); -extern s32 osEepromWrite(OSMesgQueue *, u8, u8 *); -extern s32 osEepromLongRead(OSMesgQueue *, u8, u8 *, int); -extern s32 osEepromLongWrite(OSMesgQueue *, u8, u8 *, int); - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_EEPROM_H_ */ diff --git a/include/PR/os_exception.h b/include/PR/os_exception.h deleted file mode 100644 index 245e5e697..000000000 --- a/include/PR/os_exception.h +++ /dev/null @@ -1,119 +0,0 @@ - -/*==================================================================== - * os_exception.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os_exception.h,v $ - $Revision: 1.1 $ - $Date: 1998/10/09 08:01:07 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_EXCEPTION_H_ -#define _OS_EXCEPTION_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - -typedef u32 OSIntMask; -typedef u32 OSHWIntr; - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - -/* Flags for debugging purpose */ - -#define OS_FLAG_CPU_BREAK 1 /* Break exception has occurred */ -#define OS_FLAG_FAULT 2 /* CPU fault has occurred */ - -/* Interrupt masks */ - -#define OS_IM_NONE 0x00000001 -#define OS_IM_SW1 0x00000501 -#define OS_IM_SW2 0x00000601 -#define OS_IM_CART 0x00000c01 -#define OS_IM_PRENMI 0x00001401 -#define OS_IM_RDBWRITE 0x00002401 -#define OS_IM_RDBREAD 0x00004401 -#define OS_IM_COUNTER 0x00008401 -#define OS_IM_CPU 0x0000ff01 -#define OS_IM_SP 0x00010401 -#define OS_IM_SI 0x00020401 -#define OS_IM_AI 0x00040401 -#define OS_IM_VI 0x00080401 -#define OS_IM_PI 0x00100401 -#define OS_IM_DP 0x00200401 -#define OS_IM_ALL 0x003fff01 -#define RCP_IMASK 0x003f0000 -#define RCP_IMASKSHIFT 16 - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - - -/************************************************************************** - * - * Extern variables - * - */ - - -/************************************************************************** - * - * Function prototypes - * - */ - -/* Interrupt operations */ - -extern OSIntMask osGetIntMask(void); -extern OSIntMask osSetIntMask(OSIntMask); - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_EXCEPTION_H_ */ diff --git a/include/PR/os_internal.h b/include/PR/os_internal.h deleted file mode 100644 index a18e03674..000000000 --- a/include/PR/os_internal.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef _ULTRA64_OS_INTERNAL_H_ -#define _ULTRA64_OS_INTERNAL_H_ - -/* Internal functions used by the operating system */ -/* Do not include this header in application code */ - -/* Variables */ - -//extern u64 osClockRate; - -/* Functions */ - -/*u32 __osProbeTLB(void *); -u32 __osDisableInt(void); -void __osRestoreInt(u32);*/ -OSThread *__osGetCurrFaultedThread(void); - -#endif diff --git a/include/PR/os_libc.h b/include/PR/os_libc.h deleted file mode 100644 index 94111c0b6..000000000 --- a/include/PR/os_libc.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef _OS_LIBC_H_ -#define _OS_LIBC_H_ - -#include "ultratypes.h" - -// Old deprecated functions from strings.h, replaced by memcpy/memset. -extern void bcopy(const void *, void *, size_t); -extern void bzero(void *, size_t); - -#endif /* !_OS_LIBC_H_ */ diff --git a/include/PR/os_message.h b/include/PR/os_message.h deleted file mode 100644 index 71e769866..000000000 --- a/include/PR/os_message.h +++ /dev/null @@ -1,164 +0,0 @@ - -/*==================================================================== - * os_message.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os_message.h,v $ - $Revision: 1.1 $ - $Date: 1998/10/09 08:01:15 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_MESSAGE_H_ -#define _OS_MESSAGE_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include -#include - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - -typedef u32 OSEvent; - -/* - * Structure for message - */ -typedef void * OSMesg; - -/* - * Structure for message queue - */ -typedef struct OSMesgQueue_s { - OSThread *mtqueue; /* Queue to store threads blocked - on empty mailboxes (receive) */ - OSThread *fullqueue; /* Queue to store threads blocked - on full mailboxes (send) */ - s32 validCount; /* Contains number of valid message */ - s32 first; /* Points to first valid message */ - s32 msgCount; /* Contains total # of messages */ - OSMesg *msg; /* Points to message buffer array */ -} OSMesgQueue; - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - -/* Events */ -#ifdef _FINALROM -#define OS_NUM_EVENTS 15 -#else -#define OS_NUM_EVENTS 23 -#endif - -#define OS_EVENT_SW1 0 /* CPU SW1 interrupt */ -#define OS_EVENT_SW2 1 /* CPU SW2 interrupt */ -#define OS_EVENT_CART 2 /* Cartridge interrupt: used by rmon */ -#define OS_EVENT_COUNTER 3 /* Counter int: used by VI/Timer Mgr */ -#define OS_EVENT_SP 4 /* SP task done interrupt */ -#define OS_EVENT_SI 5 /* SI (controller) interrupt */ -#define OS_EVENT_AI 6 /* AI interrupt */ -#define OS_EVENT_VI 7 /* VI interrupt: used by VI/Timer Mgr */ -#define OS_EVENT_PI 8 /* PI interrupt: used by PI Manager */ -#define OS_EVENT_DP 9 /* DP full sync interrupt */ -#define OS_EVENT_CPU_BREAK 10 /* CPU breakpoint: used by rmon */ -#define OS_EVENT_SP_BREAK 11 /* SP breakpoint: used by rmon */ -#define OS_EVENT_FAULT 12 /* CPU fault event: used by rmon */ -#define OS_EVENT_THREADSTATUS 13 /* CPU thread status: used by rmon */ -#define OS_EVENT_PRENMI 14 /* Pre NMI interrupt */ -#ifndef _FINALROM -#define OS_EVENT_RDB_READ_DONE 15 /* RDB read ok event: used by rmon */ -#define OS_EVENT_RDB_LOG_DONE 16 /* read of log data complete */ -#define OS_EVENT_RDB_DATA_DONE 17 /* read of hostio data complete */ -#define OS_EVENT_RDB_REQ_RAMROM 18 /* host needs ramrom access */ -#define OS_EVENT_RDB_FREE_RAMROM 19 /* host is done with ramrom access */ -#define OS_EVENT_RDB_DBG_DONE 20 -#define OS_EVENT_RDB_FLUSH_PROF 21 -#define OS_EVENT_RDB_ACK_PROF 22 -#endif - -/* Flags to turn blocking on/off when sending/receiving message */ - -#define OS_MESG_NOBLOCK 0 -#define OS_MESG_BLOCK 1 - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - -/* Get count of valid messages in queue */ -#define MQ_GET_COUNT(mq) ((mq)->validCount) - -/* Figure out if message queue is empty or full */ -#define MQ_IS_EMPTY(mq) (MQ_GET_COUNT(mq) == 0) -#define MQ_IS_FULL(mq) (MQ_GET_COUNT(mq) >= (mq)->msgCount) - - -/************************************************************************** - * - * Extern variables - * - */ - - -/************************************************************************** - * - * Function prototypes - * - */ - -/* Message operations */ - -extern void osCreateMesgQueue(OSMesgQueue *, OSMesg *, s32); -extern s32 osSendMesg(OSMesgQueue *, OSMesg, s32); -extern s32 osJamMesg(OSMesgQueue *, OSMesg, s32); -extern s32 osRecvMesg(OSMesgQueue *, OSMesg *, s32); - -/* Event operations */ - -extern void osSetEventMesg(OSEvent, OSMesgQueue *, OSMesg); - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_MESSAGE_H_ */ diff --git a/include/PR/os_misc.h b/include/PR/os_misc.h deleted file mode 100644 index 71e111f13..000000000 --- a/include/PR/os_misc.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef _ULTRA64_OS_MISC_H_ -#define _ULTRA64_OS_MISC_H_ -#include -/* Miscellaneous OS functions */ - -void osInitialize(void); -u32 osGetCount(void); - -uintptr_t osVirtualToPhysical(void *); - -#endif diff --git a/include/PR/os_pi.h b/include/PR/os_pi.h deleted file mode 100644 index 4bdf45f53..000000000 --- a/include/PR/os_pi.h +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef _ULTRA64_PI_H_ -#define _ULTRA64_PI_H_ - -/* Ultra64 Parallel Interface */ - -/* Types */ - -typedef struct { - void *dramAddr; - void *C2Addr; - u32 sectorSize; - u32 C1ErrNum; - u32 C1ErrSector[4]; -} __OSBlockInfo; - -typedef struct { - u32 cmdType; // 0 - u16 transferMode; // 4 - u16 blockNum; // 6 - s32 sectorNum; // 8 - uintptr_t devAddr; // c - u32 errStatus; //error status added moved to blockinfo - u32 bmCtlShadow; // 10 - u32 seqCtlShadow; // 14 - __OSBlockInfo block[2]; // 18 -} __OSTranxInfo; - -typedef struct OSPiHandle_s { - struct OSPiHandle_s *next; - u8 type; - u8 latency; - u8 pageSize; - u8 relDuration; - u8 pulse; - u8 domain; - u32 baseAddress; - u32 speed; - __OSTranxInfo transferInfo; -} OSPiHandle; - -typedef struct { - u8 type; - uintptr_t address; -} OSPiInfo; - -typedef struct { - u16 type; - u8 pri; - u8 status; - OSMesgQueue *retQueue; -} OSIoMesgHdr; - -typedef struct { - /*0x00*/ OSIoMesgHdr hdr; - /*0x08*/ void *dramAddr; - /*0x0C*/ uintptr_t devAddr; - /*0x10*/ size_t size; - OSPiHandle *piHandle; // from the official definition -} OSIoMesg; - -/* Definitions */ - -#define OS_READ 0 // device -> RDRAM -#define OS_WRITE 1 // device <- RDRAM - -#define OS_MESG_PRI_NORMAL 0 -#define OS_MESG_PRI_HIGH 1 - -/* Functions */ - -s32 osPiStartDma(OSIoMesg *mb, s32 priority, s32 direction, uintptr_t devAddr, void *vAddr, - size_t nbytes, OSMesgQueue *mq); -void osCreatePiManager(OSPri pri, OSMesgQueue *cmdQ, OSMesg *cmdBuf, s32 cmdMsgCnt); -OSMesgQueue *osPiGetCmdQueue(void); -s32 osPiWriteIo(uintptr_t devAddr, u32 data); -s32 osPiReadIo(uintptr_t devAddr, u32 *data); - -s32 osPiRawStartDma(s32 dir, u32 cart_addr, void *dram_addr, size_t size); -s32 osEPiRawStartDma(OSPiHandle *piHandle, s32 dir, u32 cart_addr, void *dram_addr, size_t size); -#endif diff --git a/include/PR/os_rdp.h b/include/PR/os_rdp.h deleted file mode 100644 index 6b3d288ce..000000000 --- a/include/PR/os_rdp.h +++ /dev/null @@ -1,92 +0,0 @@ - -/*==================================================================== - * os_rdp.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os_rdp.h,v $ - $Revision: 1.1 $ - $Date: 1998/10/09 08:01:16 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_RDP_H_ -#define _OS_RDP_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - - -/************************************************************************** - * - * Extern variables - * - */ - - -/************************************************************************** - * - * Function prototypes - * - */ - -/* Display processor interface (Dp) */ -extern u32 osDpGetStatus(void); -extern void osDpSetStatus(u32); -extern void osDpGetCounters(u32 *); -extern s32 osDpSetNextBuffer(void *, u64); - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_RDP_H_ */ diff --git a/include/PR/os_thread.h b/include/PR/os_thread.h deleted file mode 100644 index 76e528b50..000000000 --- a/include/PR/os_thread.h +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef _ULTRA64_THREAD_H_ -#define _ULTRA64_THREAD_H_ -#include "ultratypes.h" -/* Recommended priorities for system threads */ -#define OS_PRIORITY_MAX 255 -#define OS_PRIORITY_VIMGR 254 -#define OS_PRIORITY_RMON 250 -#define OS_PRIORITY_RMONSPIN 200 -#define OS_PRIORITY_PIMGR 150 -#define OS_PRIORITY_SIMGR 140 -#define OS_PRIORITY_APPMAX 127 -#define OS_PRIORITY_IDLE 0 - -#define OS_STATE_STOPPED 1 -#define OS_STATE_RUNNABLE 2 -#define OS_STATE_RUNNING 4 -#define OS_STATE_WAITING 8 - -/* Types */ - -typedef s32 OSPri; -typedef s32 OSId; - -typedef union -{ - struct {f32 f_odd; f32 f_even;} f; -} __OSfp; - -typedef struct -{ - /* registers */ - /*0x20*/ u64 at, v0, v1, a0, a1, a2, a3; - /*0x58*/ u64 t0, t1, t2, t3, t4, t5, t6, t7; - /*0x98*/ u64 s0, s1, s2, s3, s4, s5, s6, s7; - /*0xD8*/ u64 t8, t9, gp, sp, s8, ra; - /*0x108*/ u64 lo, hi; - /*0x118*/ u32 sr, pc, cause, badvaddr, rcp; - /*0x12C*/ u32 fpcsr; - __OSfp fp0, fp2, fp4, fp6, fp8, fp10, fp12, fp14; - __OSfp fp16, fp18, fp20, fp22, fp24, fp26, fp28, fp30; -} __OSThreadContext; - -typedef struct -{ - u32 flag; - u32 count; - u64 time; -} __OSThreadprofile_s; - -typedef struct OSThread_s -{ - /*0x00*/ struct OSThread_s *next; - /*0x04*/ OSPri priority; - /*0x08*/ struct OSThread_s **queue; - /*0x0C*/ struct OSThread_s *tlnext; - /*0x10*/ u16 state; - /*0x12*/ u16 flags; - /*0x14*/ OSId id; - /*0x18*/ int fp; - /*0x1C*/ __OSThreadprofile_s *thprof; - /*0x20*/ __OSThreadContext context; -} OSThread; - - -/* Functions */ - -void osCreateThread(OSThread *thread, OSId id, void (*entry)(void *), - void *arg, void *sp, OSPri pri); -OSId osGetThreadId(OSThread *thread); -OSPri osGetThreadPri(OSThread *thread); -void osSetThreadPri(OSThread *thread, OSPri pri); -void osStartThread(OSThread *thread); -void osStopThread(OSThread *thread); - -#endif diff --git a/include/PR/os_time.h b/include/PR/os_time.h deleted file mode 100644 index 328e60150..000000000 --- a/include/PR/os_time.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _ULTRA64_TIME_H_ -#define _ULTRA64_TIME_H_ - -#include -#include - -/* Types */ - -typedef struct OSTimer_str -{ - struct OSTimer_str *next; - struct OSTimer_str *prev; - u64 interval; - u64 remaining; - OSMesgQueue *mq; - OSMesg *msg; -} OSTimer; - -typedef u64 OSTime; - -/* Functions */ - -OSTime osGetTime(void); -void osSetTime(OSTime time); -u32 osSetTimer(OSTimer *, OSTime, u64, OSMesgQueue *, OSMesg); - -#endif diff --git a/include/PR/os_tlb.h b/include/PR/os_tlb.h deleted file mode 100644 index 2cdd5c9c6..000000000 --- a/include/PR/os_tlb.h +++ /dev/null @@ -1,107 +0,0 @@ - -/*==================================================================== - * os_tlb.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os_tlb.h,v $ - $Revision: 1.1 $ - $Date: 1998/10/09 08:01:20 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_TLB_H_ -#define _OS_TLB_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - -typedef u32 OSPageMask; - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - -/* - * Page size argument for TLB routines - */ -#define OS_PM_4K 0x0000000 -#define OS_PM_16K 0x0006000 -#define OS_PM_64K 0x001e000 -#define OS_PM_256K 0x007e000 -#define OS_PM_1M 0x01fe000 -#define OS_PM_4M 0x07fe000 -#define OS_PM_16M 0x1ffe000 - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - - -/************************************************************************** - * - * Extern variables - * - */ - - -/************************************************************************** - * - * Function prototypes - * - */ - -/* TLB management routines */ - -extern void osMapTLB(s32, OSPageMask, void *, u32, u32, s32); -extern void osMapTLBRdb(void); -extern void osUnmapTLB(s32); -extern void osUnmapTLBAll(void); -extern void osSetTLBASID(s32); - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_TLB_H_ */ diff --git a/include/PR/os_vi.h b/include/PR/os_vi.h deleted file mode 100644 index 98fb4ed31..000000000 --- a/include/PR/os_vi.h +++ /dev/null @@ -1,117 +0,0 @@ -#ifndef _ULTRA64_VI_H_ -#define _ULTRA64_VI_H_ - -#include -#include - -/* Ultra64 Video Interface */ - - -/* Special Features */ -#define OS_VI_GAMMA_ON 0x0001 -#define OS_VI_GAMMA_OFF 0x0002 -#define OS_VI_GAMMA_DITHER_ON 0x0004 -#define OS_VI_GAMMA_DITHER_OFF 0x0008 -#define OS_VI_DIVOT_ON 0x0010 -#define OS_VI_DIVOT_OFF 0x0020 -#define OS_VI_DITHER_FILTER_ON 0x0040 -#define OS_VI_DITHER_FILTER_OFF 0x0080 - -#define OS_VI_GAMMA 0x08 -#define OS_VI_GAMMA_DITHER 0x04 -#define OS_VI_DIVOT 0x10 -#define OS_VI_DITHER_FILTER 0x10000 -#define OS_VI_UNK200 0x200 -#define OS_VI_UNK100 0x100 - - -/* Types */ - -typedef struct -{ - u32 ctrl; - u32 width; - u32 burst; - u32 vSync; - u32 hSync; - u32 leap; - u32 hStart; - u32 xScale; - u32 vCurrent; -} OSViCommonRegs; - -typedef struct -{ - u32 origin; - u32 yScale; - u32 vStart; - u32 vBurst; - u32 vIntr; -} OSViFieldRegs; - -typedef struct -{ - u8 type; - OSViCommonRegs comRegs; - OSViFieldRegs fldRegs[2]; -} OSViMode; - -typedef struct -{ - /* 0x00 */ u16 unk00; //some kind of flags. swap buffer sets to 0x10 - /* 0x02 */ u16 retraceCount; - /* 0x04 */ void* buffer; - /* 0x08 */ OSViMode *modep; - /* 0x0c */ u32 features; - /* 0x10 */ OSMesgQueue *mq; - /* 0x14 */ OSMesg *msg; - /* 0x18 */ u32 unk18; - /* 0x1c */ u32 unk1c; - /* 0x20 */ u32 unk20; - /* 0x24 */ f32 unk24; - /* 0x28 */ u16 unk28; - /* 0x2c */ u32 unk2c; -} OSViContext; - -void osCreateViManager(OSPri pri); -void osViSetMode(OSViMode *mode); -void osViSetEvent(OSMesgQueue *mq, OSMesg msg, u32 retraceCount); -void osViBlack(u8 active); -void osViSetSpecialFeatures(u32 func); -void osViSwapBuffer(void *vaddr); - - -#define OS_VI_NTSC_LPN1 0 /* NTSC */ -#define OS_VI_NTSC_LPF1 1 -#define OS_VI_NTSC_LAN1 2 -#define OS_VI_NTSC_LAF1 3 -#define OS_VI_NTSC_LPN2 4 -#define OS_VI_NTSC_LPF2 5 -#define OS_VI_NTSC_LAN2 6 -#define OS_VI_NTSC_LAF2 7 -#define OS_VI_NTSC_HPN1 8 -#define OS_VI_NTSC_HPF1 9 -#define OS_VI_NTSC_HAN1 10 -#define OS_VI_NTSC_HAF1 11 -#define OS_VI_NTSC_HPN2 12 -#define OS_VI_NTSC_HPF2 13 - -#define OS_VI_PAL_LPN1 14 /* PAL */ -#define OS_VI_PAL_LPF1 15 -#define OS_VI_PAL_LAN1 16 -#define OS_VI_PAL_LAF1 17 -#define OS_VI_PAL_LPN2 18 -#define OS_VI_PAL_LPF2 19 -#define OS_VI_PAL_LAN2 20 -#define OS_VI_PAL_LAF2 21 -#define OS_VI_PAL_HPN1 22 -#define OS_VI_PAL_HPF1 23 -#define OS_VI_PAL_HAN1 24 -#define OS_VI_PAL_HAF1 25 -#define OS_VI_PAL_HPN2 26 -#define OS_VI_PAL_HPF2 27 - -extern OSViMode osViModeTable[]; /* Global VI mode table */ - - -#endif diff --git a/include/PR/rcp.h b/include/PR/rcp.h deleted file mode 100644 index 68ce9682d..000000000 --- a/include/PR/rcp.h +++ /dev/null @@ -1,881 +0,0 @@ -#ifndef _RCP_H_ -#define _RCP_H_ - -/************************************************************************** - * * - * Copyright (C) 1995, Silicon Graphics, Inc. * - * * - * These coded instructions, statements, and computer programs contain * - * unpublished proprietary information of Silicon Graphics, Inc., and * - * are protected by Federal copyright law. They may not be disclosed * - * to third parties or copied or duplicated in any form, in whole or * - * in part, without the prior written consent of Silicon Graphics, Inc. * - * * - **************************************************************************/ - -/************************************************************************** - * - * File: rcp.h - * - * This file contains register and bit definitions for RCP memory map. - * $Revision: 1.20 $ - * $Date: 1997/07/23 08:35:21 $ - * $Source: /disk6/Master/cvsmdev2/PR/include/rcp.h,v $ - * - **************************************************************************/ - -#include -#include - -/********************************************************************** - * - * Here is a quick overview of the RCP memory map: - * - -0x0000_0000 .. 0x03ef_ffff RDRAM memory -0x03f0_0000 .. 0x03ff_ffff RDRAM registers - - RCP registers (see below) -0x0400_0000 .. 0x040f_ffff SP registers -0x0410_0000 .. 0x041f_ffff DP command registers -0x0420_0000 .. 0x042f_ffff DP span registers -0x0430_0000 .. 0x043f_ffff MI registers -0x0440_0000 .. 0x044f_ffff VI registers -0x0450_0000 .. 0x045f_ffff AI registers -0x0460_0000 .. 0x046f_ffff PI registers -0x0470_0000 .. 0x047f_ffff RI registers -0x0480_0000 .. 0x048f_ffff SI registers -0x0490_0000 .. 0x04ff_ffff unused - -0x0500_0000 .. 0x05ff_ffff cartridge domain 2 -0x0600_0000 .. 0x07ff_ffff cartridge domain 1 -0x0800_0000 .. 0x0fff_ffff cartridge domain 2 -0x1000_0000 .. 0x1fbf_ffff cartridge domain 1 - -0x1fc0_0000 .. 0x1fc0_07bf PIF Boot Rom (1984 bytes) -0x1fc0_07c0 .. 0x1fc0_07ff PIF (JoyChannel) RAM (64 bytes) -0x1fc0_0800 .. 0x1fcf_ffff Reserved -0x1fd0_0000 .. 0x7fff_ffff cartridge domain 1 -0x8000_0000 .. 0xffff_ffff external SysAD device - -The Indy development board use cartridge domain 1: -0x1000_0000 .. 0x10ff_ffff RAMROM -0x1800_0000 .. 0x1800_0003 GIO interrupt (6 bits valid in 4 bytes) -0x1800_0400 .. 0x1800_0403 GIO sync (6 bits valid in 4 bytes) -0x1800_0800 .. 0x1800_0803 CART interrupt (6 bits valid in 4 bytes) - - - -**************************************************************************/ - - -/************************************************************************* - * RDRAM Memory (Assumes that maximum size is 4 MB) - */ -#define RDRAM_0_START 0x00000000 -#define RDRAM_0_END 0x001FFFFF -#define RDRAM_1_START 0x00200000 -#define RDRAM_1_END 0x003FFFFF - -#define RDRAM_START RDRAM_0_START -#define RDRAM_END RDRAM_1_END - - -/************************************************************************* - * Address predicates - */ -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) -#define IS_RDRAM(x) ((unsigned)(x) >= RDRAM_START && \ - (unsigned)(x) < RDRAM_END) -#endif - - -/************************************************************************* - * RDRAM Registers (0x03f0_0000 .. 0x03ff_ffff) - */ -#define RDRAM_BASE_REG 0x03F00000 - -#define RDRAM_CONFIG_REG (RDRAM_BASE_REG+0x00) -#define RDRAM_DEVICE_TYPE_REG (RDRAM_BASE_REG+0x00) -#define RDRAM_DEVICE_ID_REG (RDRAM_BASE_REG+0x04) -#define RDRAM_DELAY_REG (RDRAM_BASE_REG+0x08) -#define RDRAM_MODE_REG (RDRAM_BASE_REG+0x0c) -#define RDRAM_REF_INTERVAL_REG (RDRAM_BASE_REG+0x10) -#define RDRAM_REF_ROW_REG (RDRAM_BASE_REG+0x14) -#define RDRAM_RAS_INTERVAL_REG (RDRAM_BASE_REG+0x18) -#define RDRAM_MIN_INTERVAL_REG (RDRAM_BASE_REG+0x1c) -#define RDRAM_ADDR_SELECT_REG (RDRAM_BASE_REG+0x20) -#define RDRAM_DEVICE_MANUF_REG (RDRAM_BASE_REG+0x24) - -#define RDRAM_0_DEVICE_ID 0 -#define RDRAM_1_DEVICE_ID 1 - -#define RDRAM_RESET_MODE 0 -#define RDRAM_ACTIVE_MODE 1 -#define RDRAM_STANDBY_MODE 2 - -#define RDRAM_LENGTH (2*512*2048) -#define RDRAM_0_BASE_ADDRESS (RDRAM_0_DEVICE_ID*RDRAM_LENGTH) -#define RDRAM_1_BASE_ADDRESS (RDRAM_1_DEVICE_ID*RDRAM_LENGTH) - -#define RDRAM_0_CONFIG 0x00000 -#define RDRAM_1_CONFIG 0x00400 -#define RDRAM_GLOBAL_CONFIG 0x80000 - - -/************************************************************************* - * PIF Physical memory map (total size = 2 KB) - * - * Size Description Mode - * 1FC007FF +-------+-----------------+-----+ - * | 64 B | JoyChannel RAM | R/W | - * 1FC007C0 +-------+-----------------+-----+ - * |1984 B | Boot ROM | * | * = Reserved - * 1FC00000 +-------+-----------------+-----+ - * - */ -#define PIF_ROM_START 0x1FC00000 -#define PIF_ROM_END 0x1FC007BF -#define PIF_RAM_START 0x1FC007C0 -#define PIF_RAM_END 0x1FC007FF - - -/************************************************************************* - * Controller channel - * Each game controller channel has 4 error bits that are defined in bit 6-7 of - * the Rx and Tx data size area bytes. Programmers need to clear these bits - * when setting the Tx/Rx size area values for a channel - */ -#define CHNL_ERR_NORESP 0x80 /* Bit 7 (Rx): No response error */ -#define CHNL_ERR_OVERRUN 0x40 /* Bit 6 (Rx): Overrun error */ -#define CHNL_ERR_FRAME 0x80 /* Bit 7 (Tx): Frame error */ -#define CHNL_ERR_COLLISION 0x40 /* Bit 6 (Tx): Collision error */ - -#define CHNL_ERR_MASK 0xC0 /* Bit 6-7: channel errors */ - - -/************************************************************************* - * External device info - */ -#define DEVICE_TYPE_CART 0 /* ROM cartridge */ -#define DEVICE_TYPE_BULK 1 /* ROM bulk */ -#define DEVICE_TYPE_64DD 2 /* 64 Disk Drive */ -#define DEVICE_TYPE_SRAM 3 /* SRAM */ - -/************************************************************************* - * SP Memory - */ -#define SP_DMEM_START 0x04000000 /* read/write */ -#define SP_DMEM_END 0x04000FFF -#define SP_IMEM_START 0x04001000 /* read/write */ -#define SP_IMEM_END 0x04001FFF - -/************************************************************************* - * SP CP0 Registers - */ - -#define SP_BASE_REG 0x04040000 - -/* SP memory address (R/W): [11:0] DMEM/IMEM address; [12] 0=DMEM,1=IMEM */ -#define SP_MEM_ADDR_REG (SP_BASE_REG+0x00) /* Master */ - -/* SP DRAM DMA address (R/W): [23:0] RDRAM address */ -#define SP_DRAM_ADDR_REG (SP_BASE_REG+0x04) /* Slave */ - -/* SP read DMA length (R/W): [11:0] length, [19:12] count, [31:20] skip */ -/* direction: I/DMEM <- RDRAM */ -#define SP_RD_LEN_REG (SP_BASE_REG+0x08) /* R/W: read len */ - -/* SP write DMA length (R/W): [11:0] length, [19:12] count, [31:20] skip */ -/* direction: I/DMEM -> RDRAM */ -#define SP_WR_LEN_REG (SP_BASE_REG+0x0C) /* R/W: write len */ - -/* SP status (R/W): [14:0] valid bits; see below for write/read mode */ -#define SP_STATUS_REG (SP_BASE_REG+0x10) - -/* SP DMA full (R): [0] valid bit; dma full */ -#define SP_DMA_FULL_REG (SP_BASE_REG+0x14) - -/* SP DMA busy (R): [0] valid bit; dma busy */ -#define SP_DMA_BUSY_REG (SP_BASE_REG+0x18) - -/* SP semaphore (R/W): Read: [0] semaphore flag (set on read) */ -/* Write: [] clear semaphore flag */ -#define SP_SEMAPHORE_REG (SP_BASE_REG+0x1C) - -/* SP PC (R/W): [11:0] program counter */ -#define SP_PC_REG 0x04080000 - -/* SP MEM address: bit 12 specifies if address is IMEM or DMEM */ -#define SP_DMA_DMEM 0x0000 /* Bit 12: 0=DMEM, 1=IMEM */ -#define SP_DMA_IMEM 0x1000 /* Bit 12: 0=DMEM, 1=IMEM */ - -/* - * Values to clear/set bit in status reg (SP_STATUS_REG - write) - */ -#define SP_CLR_HALT 0x00001 /* Bit 0: clear halt */ -#define SP_SET_HALT 0x00002 /* Bit 1: set halt */ -#define SP_CLR_BROKE 0x00004 /* Bit 2: clear broke */ -#define SP_CLR_INTR 0x00008 /* Bit 3: clear intr */ -#define SP_SET_INTR 0x00010 /* Bit 4: set intr */ -#define SP_CLR_SSTEP 0x00020 /* Bit 5: clear sstep */ -#define SP_SET_SSTEP 0x00040 /* Bit 6: set sstep */ -#define SP_CLR_INTR_BREAK 0x00080 /* Bit 7: clear intr on break */ -#define SP_SET_INTR_BREAK 0x00100 /* Bit 8: set intr on break */ -#define SP_CLR_SIG0 0x00200 /* Bit 9: clear signal 0 */ -#define SP_SET_SIG0 0x00400 /* Bit 10: set signal 0 */ -#define SP_CLR_SIG1 0x00800 /* Bit 11: clear signal 1 */ -#define SP_SET_SIG1 0x01000 /* Bit 12: set signal 1 */ -#define SP_CLR_SIG2 0x02000 /* Bit 13: clear signal 2 */ -#define SP_SET_SIG2 0x04000 /* Bit 14: set signal 2 */ -#define SP_CLR_SIG3 0x08000 /* Bit 15: clear signal 3 */ -#define SP_SET_SIG3 0x10000 /* Bit 16: set signal 3 */ -#define SP_CLR_SIG4 0x20000 /* Bit 17: clear signal 4 */ -#define SP_SET_SIG4 0x40000 /* Bit 18: set signal 4 */ -#define SP_CLR_SIG5 0x80000 /* Bit 19: clear signal 5 */ -#define SP_SET_SIG5 0x100000 /* Bit 20: set signal 5 */ -#define SP_CLR_SIG6 0x200000 /* Bit 21: clear signal 6 */ -#define SP_SET_SIG6 0x400000 /* Bit 22: set signal 6 */ -#define SP_CLR_SIG7 0x800000 /* Bit 23: clear signal 7 */ -#define SP_SET_SIG7 0x1000000 /* Bit 24: set signal 7 */ - -/* - * Patterns to interpret status reg (SP_STATUS_REG - read) - */ -#define SP_STATUS_HALT 0x001 /* Bit 0: halt */ -#define SP_STATUS_BROKE 0x002 /* Bit 1: broke */ -#define SP_STATUS_DMA_BUSY 0x004 /* Bit 2: dma busy */ -#define SP_STATUS_DMA_FULL 0x008 /* Bit 3: dma full */ -#define SP_STATUS_IO_FULL 0x010 /* Bit 4: io full */ -#define SP_STATUS_SSTEP 0x020 /* Bit 5: single step */ -#define SP_STATUS_INTR_BREAK 0x040 /* Bit 6: interrupt on break */ -#define SP_STATUS_SIG0 0x080 /* Bit 7: signal 0 set */ -#define SP_STATUS_SIG1 0x100 /* Bit 8: signal 1 set */ -#define SP_STATUS_SIG2 0x200 /* Bit 9: signal 2 set */ -#define SP_STATUS_SIG3 0x400 /* Bit 10: signal 3 set */ -#define SP_STATUS_SIG4 0x800 /* Bit 11: signal 4 set */ -#define SP_STATUS_SIG5 0x1000 /* Bit 12: signal 5 set */ -#define SP_STATUS_SIG6 0x2000 /* Bit 13: signal 6 set */ -#define SP_STATUS_SIG7 0x4000 /* Bit 14: signal 7 set */ - -/* - * Use of SIG bits - */ -#define SP_CLR_YIELD SP_CLR_SIG0 -#define SP_SET_YIELD SP_SET_SIG0 -#define SP_STATUS_YIELD SP_STATUS_SIG0 -#define SP_CLR_YIELDED SP_CLR_SIG1 -#define SP_SET_YIELDED SP_SET_SIG1 -#define SP_STATUS_YIELDED SP_STATUS_SIG1 -#define SP_CLR_TASKDONE SP_CLR_SIG2 -#define SP_SET_TASKDONE SP_SET_SIG2 -#define SP_STATUS_TASKDONE SP_STATUS_SIG2 -#define SP_CLR_RSPSIGNAL SP_CLR_SIG3 -#define SP_SET_RSPSIGNAL SP_SET_SIG3 -#define SP_STATUS_RSPSIGNAL SP_STATUS_SIG3 -#define SP_CLR_CPUSIGNAL SP_CLR_SIG4 -#define SP_SET_CPUSIGNAL SP_SET_SIG4 -#define SP_STATUS_CPUSIGNAL SP_STATUS_SIG4 - -/* SP IMEM BIST REG (R/W): [6:0] BIST status bits; see below for detail */ -#define SP_IBIST_REG 0x04080004 - -/* - * Patterns to interpret status reg (SP_BIST_REG - write) - */ -#define SP_IBIST_CHECK 0x01 /* Bit 0: BIST check */ -#define SP_IBIST_GO 0x02 /* Bit 1: BIST go */ -#define SP_IBIST_CLEAR 0x04 /* Bit 2: BIST clear */ - -/* - * Patterns to interpret status reg (SP_BIST_REG - read) - */ -/* First 2 bits are same as in write mode: - * Bit 0: BIST check; Bit 1: BIST go - */ -#define SP_IBIST_DONE 0x04 /* Bit 2: BIST done */ -#define SP_IBIST_FAILED 0x78 /* Bit [6:3]: BIST fail */ - - -/************************************************************************* - * DP Command Registers - */ -#define DPC_BASE_REG 0x04100000 - -/* DP CMD DMA start (R/W): [23:0] DMEM/RDRAM start address */ -#define DPC_START_REG (DPC_BASE_REG+0x00) - -/* DP CMD DMA end (R/W): [23:0] DMEM/RDRAM end address */ -#define DPC_END_REG (DPC_BASE_REG+0x04) - -/* DP CMD DMA end (R): [23:0] DMEM/RDRAM current address */ -#define DPC_CURRENT_REG (DPC_BASE_REG+0x08) - -/* DP CMD status (R/W): [9:0] valid bits - see below for definitions */ -#define DPC_STATUS_REG (DPC_BASE_REG+0x0C) - -/* DP clock counter (R): [23:0] clock counter */ -#define DPC_CLOCK_REG (DPC_BASE_REG+0x10) - -/* DP buffer busy counter (R): [23:0] clock counter */ -#define DPC_BUFBUSY_REG (DPC_BASE_REG+0x14) - -/* DP pipe busy counter (R): [23:0] clock counter */ -#define DPC_PIPEBUSY_REG (DPC_BASE_REG+0x18) - -/* DP TMEM load counter (R): [23:0] clock counter */ -#define DPC_TMEM_REG (DPC_BASE_REG+0x1C) - -/* - * Values to clear/set bit in status reg (DPC_STATUS_REG - write) - */ -#define DPC_CLR_XBUS_DMEM_DMA 0x0001 /* Bit 0: clear xbus_dmem_dma */ -#define DPC_SET_XBUS_DMEM_DMA 0x0002 /* Bit 1: set xbus_dmem_dma */ -#define DPC_CLR_FREEZE 0x0004 /* Bit 2: clear freeze */ -#define DPC_SET_FREEZE 0x0008 /* Bit 3: set freeze */ -#define DPC_CLR_FLUSH 0x0010 /* Bit 4: clear flush */ -#define DPC_SET_FLUSH 0x0020 /* Bit 5: set flush */ -#define DPC_CLR_TMEM_CTR 0x0040 /* Bit 6: clear tmem ctr */ -#define DPC_CLR_PIPE_CTR 0x0080 /* Bit 7: clear pipe ctr */ -#define DPC_CLR_CMD_CTR 0x0100 /* Bit 8: clear cmd ctr */ -#define DPC_CLR_CLOCK_CTR 0x0200 /* Bit 9: clear clock ctr */ - -/* - * Patterns to interpret status reg (DPC_STATUS_REG - read) - */ -#define DPC_STATUS_XBUS_DMEM_DMA 0x001 /* Bit 0: xbus_dmem_dma */ -#define DPC_STATUS_FREEZE 0x002 /* Bit 1: freeze */ -#define DPC_STATUS_FLUSH 0x004 /* Bit 2: flush */ -/*#define DPC_STATUS_FROZEN 0x008*/ /* Bit 3: frozen */ -#define DPC_STATUS_START_GCLK 0x008 /* Bit 3: start gclk */ -#define DPC_STATUS_TMEM_BUSY 0x010 /* Bit 4: tmem busy */ -#define DPC_STATUS_PIPE_BUSY 0x020 /* Bit 5: pipe busy */ -#define DPC_STATUS_CMD_BUSY 0x040 /* Bit 6: cmd busy */ -#define DPC_STATUS_CBUF_READY 0x080 /* Bit 7: cbuf ready */ -#define DPC_STATUS_DMA_BUSY 0x100 /* Bit 8: dma busy */ -#define DPC_STATUS_END_VALID 0x200 /* Bit 9: end valid */ -#define DPC_STATUS_START_VALID 0x400 /* Bit 10: start valid */ - - -/************************************************************************* - * DP Span Registers - */ -#define DPS_BASE_REG 0x04200000 - -/* DP tmem bist (R/W): [10:0] BIST status bits; see below for detail */ -#define DPS_TBIST_REG (DPS_BASE_REG+0x00) - -/* DP span test mode (R/W): [0] Span buffer test access enable */ -#define DPS_TEST_MODE_REG (DPS_BASE_REG+0x04) - -/* DP span buffer test address (R/W): [6:0] bits; see below for detail */ -#define DPS_BUFTEST_ADDR_REG (DPS_BASE_REG+0x08) - -/* DP span buffer test data (R/W): [31:0] span buffer data */ -#define DPS_BUFTEST_DATA_REG (DPS_BASE_REG+0x0C) - -/* - * Patterns to interpret status reg (DPS_TMEM_BIST_REG - write) - */ -#define DPS_TBIST_CHECK 0x01 /* Bit 0: BIST check */ -#define DPS_TBIST_GO 0x02 /* Bit 1: BIST go */ -#define DPS_TBIST_CLEAR 0x04 /* Bit 2: BIST clear */ - -/* - * Patterns to interpret status reg (DPS_TMEM_BIST_REG - read) - */ -/* First 2 bits are same as in write mode: - * Bit 0: BIST check; Bit 1: BIST go - */ -#define DPS_TBIST_DONE 0x004 /* Bit 2: BIST done */ -#define DPS_TBIST_FAILED 0x7F8 /* Bit [10:3]: BIST fail */ - - -/************************************************************************* - * MIPS Interface (MI) Registers - */ -#define MI_BASE_REG 0x04300000 - -/* - * MI init mode (W): [6:0] init length, [7] clear init mode, [8] set init mode - * [9/10] clear/set ebus test mode, [11] clear DP interrupt - * (R): [6:0] init length, [7] init mode, [8] ebus test mode - */ -#define MI_INIT_MODE_REG (MI_BASE_REG+0x00) -#define MI_MODE_REG MI_INIT_MODE_REG - -/* - * Values to clear/set bit in mode reg (MI_MODE_REG - write) - */ -#define MI_CLR_INIT 0x0080 /* Bit 7: clear init mode */ -#define MI_SET_INIT 0x0100 /* Bit 8: set init mode */ -#define MI_CLR_EBUS 0x0200 /* Bit 9: clear ebus test */ -#define MI_SET_EBUS 0x0400 /* Bit 10: set ebus test mode */ -#define MI_CLR_DP_INTR 0x0800 /* Bit 11: clear dp interrupt */ -#define MI_CLR_RDRAM 0x1000 /* Bit 12: clear RDRAM reg */ -#define MI_SET_RDRAM 0x2000 /* Bit 13: set RDRAM reg mode */ - -/* - * Patterns to interpret mode reg (MI_MODE_REG - read) - */ -#define MI_MODE_INIT 0x0080 /* Bit 7: init mode */ -#define MI_MODE_EBUS 0x0100 /* Bit 8: ebus test mode */ -#define MI_MODE_RDRAM 0x0200 /* Bit 9: RDRAM reg mode */ - -/* MI version (R): [7:0] io, [15:8] rac, [23:16] rdp, [31:24] rsp */ -#define MI_VERSION_REG (MI_BASE_REG+0x04) -#define MI_NOOP_REG MI_VERSION_REG - -/* MI interrupt (R): [5:0] valid bits - see below for bit patterns */ -#define MI_INTR_REG (MI_BASE_REG+0x08) - -/* - * MI interrupt mask (W): [11:0] valid bits - see below for bit patterns - * (R): [5:0] valid bits - see below for bit patterns - */ -#define MI_INTR_MASK_REG (MI_BASE_REG+0x0C) - -/* - * The following are values to check for interrupt setting (MI_INTR_REG) - */ -#define MI_INTR_SP 0x01 /* Bit 0: SP intr */ -#define MI_INTR_SI 0x02 /* Bit 1: SI intr */ -#define MI_INTR_AI 0x04 /* Bit 2: AI intr */ -#define MI_INTR_VI 0x08 /* Bit 3: VI intr */ -#define MI_INTR_PI 0x10 /* Bit 4: PI intr */ -#define MI_INTR_DP 0x20 /* Bit 5: DP intr */ - -/* - * The following are values to clear/set various interrupt bit mask - * They can be ORed together to manipulate multiple bits - * (MI_INTR_MASK_REG - write) - */ -#define MI_INTR_MASK_CLR_SP 0x0001 /* Bit 0: clear SP mask */ -#define MI_INTR_MASK_SET_SP 0x0002 /* Bit 1: set SP mask */ -#define MI_INTR_MASK_CLR_SI 0x0004 /* Bit 2: clear SI mask */ -#define MI_INTR_MASK_SET_SI 0x0008 /* Bit 3: set SI mask */ -#define MI_INTR_MASK_CLR_AI 0x0010 /* Bit 4: clear AI mask */ -#define MI_INTR_MASK_SET_AI 0x0020 /* Bit 5: set AI mask */ -#define MI_INTR_MASK_CLR_VI 0x0040 /* Bit 6: clear VI mask */ -#define MI_INTR_MASK_SET_VI 0x0080 /* Bit 7: set VI mask */ -#define MI_INTR_MASK_CLR_PI 0x0100 /* Bit 8: clear PI mask */ -#define MI_INTR_MASK_SET_PI 0x0200 /* Bit 9: set PI mask */ -#define MI_INTR_MASK_CLR_DP 0x0400 /* Bit 10: clear DP mask */ -#define MI_INTR_MASK_SET_DP 0x0800 /* Bit 11: set DP mask */ - -/* - * The following are values to check for interrupt mask setting - * (MI_INTR_MASK_REG - read) - */ -#define MI_INTR_MASK_SP 0x01 /* Bit 0: SP intr mask */ -#define MI_INTR_MASK_SI 0x02 /* Bit 1: SI intr mask */ -#define MI_INTR_MASK_AI 0x04 /* Bit 2: AI intr mask */ -#define MI_INTR_MASK_VI 0x08 /* Bit 3: VI intr mask */ -#define MI_INTR_MASK_PI 0x10 /* Bit 4: PI intr mask */ -#define MI_INTR_MASK_DP 0x20 /* Bit 5: DP intr mask */ - - -/************************************************************************* - * Video Interface (VI) Registers - */ -#define VI_BASE_REG 0x04400000 - -/* VI status/control (R/W): [15-0] valid bits: - * [1:0] = type[1:0] (pixel size) - * 0: blank (no data, no sync) - * 1: reserved - * 2: 5/5/5/3 ("16" bit) - * 3: 8/8/8/8 (32 bit) - * [2] = gamma_dither_enable (normally on, unless "special effect") - * [3] = gamma_enable (normally on, unless MPEG/JPEG) - * [4] = divot_enable (normally on if antialiased, unless decal lines) - * [5] = reserved - always off - * [6] = serrate (always on if interlaced, off if not) - * [7] = reserved - diagnostics only - * [9:8] = anti-alias (aa) mode[1:0] - * 0: aa & resamp (always fetch extra lines) - * 1: aa & resamp (fetch extra lines if needed) - * 2: resamp only (treat as all fully covered) - * 3: neither (replicate pixels, no interpolate) - * [11] = reserved - diagnostics only - * [15:12] = reserved - * - */ -#define VI_STATUS_REG (VI_BASE_REG+0x00) -#define VI_CONTROL_REG VI_STATUS_REG - -/* VI origin (R/W): [23:0] frame buffer origin in bytes */ -#define VI_ORIGIN_REG (VI_BASE_REG+0x04) -#define VI_DRAM_ADDR_REG VI_ORIGIN_REG - -/* VI width (R/W): [11:0] frame buffer line width in pixels */ -#define VI_WIDTH_REG (VI_BASE_REG+0x08) -#define VI_H_WIDTH_REG VI_WIDTH_REG - -/* VI vertical intr (R/W): [9:0] interrupt when current half-line = V_INTR */ -#define VI_INTR_REG (VI_BASE_REG+0x0C) -#define VI_V_INTR_REG VI_INTR_REG - -/* - * VI current vertical line (R/W): [9:0] current half line, sampled once per - * line (the lsb of V_CURRENT is constant within a field, and in - * interlaced modes gives the field number - which is constant for non- - * interlaced modes) - * - Any write to this register will clear interrupt line - */ -#define VI_CURRENT_REG (VI_BASE_REG+0x10) -#define VI_V_CURRENT_LINE_REG VI_CURRENT_REG - -/* - * VI video timing (R/W): [ 7: 0] horizontal sync width in pixels, - * [15: 8] color burst width in pixels, - * [19:16] vertical sync width in half lines, - * [29:20] start of color burst in pixels from h-sync - */ -#define VI_BURST_REG (VI_BASE_REG+0x14) -#define VI_TIMING_REG VI_BURST_REG - -/* VI vertical sync (R/W): [9:0] number of half-lines per field */ -#define VI_V_SYNC_REG (VI_BASE_REG+0x18) - -/* VI horizontal sync (R/W): [11: 0] total duration of a line in 1/4 pixel - * [20:16] a 5-bit leap pattern used for PAL only - * (h_sync_period) - */ -#define VI_H_SYNC_REG (VI_BASE_REG+0x1C) - -/* - * VI horizontal sync leap (R/W): [11: 0] identical to h_sync_period - * [27:16] identical to h_sync_period - */ -#define VI_LEAP_REG (VI_BASE_REG+0x20) -#define VI_H_SYNC_LEAP_REG VI_LEAP_REG - -/* - * VI horizontal video (R/W): [ 9: 0] end of active video in screen pixels - * : [25:16] start of active video in screen pixels - */ -#define VI_H_START_REG (VI_BASE_REG+0x24) -#define VI_H_VIDEO_REG VI_H_START_REG - -/* - * VI vertical video (R/W): [ 9: 0] end of active video in screen half-lines - * : [25:16] start of active video in screen half-lines - */ -#define VI_V_START_REG (VI_BASE_REG+0x28) -#define VI_V_VIDEO_REG VI_V_START_REG - -/* - * VI vertical burst (R/W): [ 9: 0] end of color burst enable in half-lines - * : [25:16] start of color burst enable in half-lines - */ -#define VI_V_BURST_REG (VI_BASE_REG+0x2C) - -/* VI x-scale (R/W): [11: 0] 1/horizontal scale up factor (2.10 format) - * [27:16] horizontal subpixel offset (2.10 format) - */ -#define VI_X_SCALE_REG (VI_BASE_REG+0x30) - -/* VI y-scale (R/W): [11: 0] 1/vertical scale up factor (2.10 format) - * [27:16] vertical subpixel offset (2.10 format) - */ -#define VI_Y_SCALE_REG (VI_BASE_REG+0x34) - -/* - * Patterns to interpret VI_CONTROL_REG - */ -#define VI_CTRL_TYPE_16 0x00002 /* Bit [1:0] pixel size: 16 bit */ -#define VI_CTRL_TYPE_32 0x00003 /* Bit [1:0] pixel size: 32 bit */ -#define VI_CTRL_GAMMA_DITHER_ON 0x00004 /* Bit 2: default = on */ -#define VI_CTRL_GAMMA_ON 0x00008 /* Bit 3: default = on */ -#define VI_CTRL_DIVOT_ON 0x00010 /* Bit 4: default = on */ -#define VI_CTRL_SERRATE_ON 0x00040 /* Bit 6: on if interlaced */ -#define VI_CTRL_ANTIALIAS_MASK 0x00300 /* Bit [9:8] anti-alias mode */ -#define VI_CTRL_DITHER_FILTER_ON 0x10000 /* Bit 16: dither-filter mode */ - -/* - * Possible video clocks (NTSC or PAL) - */ -#define VI_NTSC_CLOCK 48681812 /* Hz = 48.681812 MHz */ -#define VI_PAL_CLOCK 49656530 /* Hz = 49.656530 MHz */ -#define VI_MPAL_CLOCK 48628316 /* Hz = 48.628316 MHz */ - - -/************************************************************************* - * Audio Interface (AI) Registers - * - * The address and length registers are double buffered; that is, they - * can be written twice before becoming full. - * The address must be written before the length. - */ -#define AI_BASE_REG 0x04500000 - -/* AI DRAM address (W): [23:0] starting RDRAM address (8B-aligned) */ -#define AI_DRAM_ADDR_REG (AI_BASE_REG+0x00) /* R0: DRAM address */ - -/* AI length (R/W): [14:0] transfer length (v1.0) - Bottom 3 bits are ignored */ -/* [17:0] transfer length (v2.0) - Bottom 3 bits are ignored */ -#define AI_LEN_REG (AI_BASE_REG+0x04) /* R1: Length */ - -/* AI control (W): [0] DMA enable - if LSB == 1, DMA is enabled */ -#define AI_CONTROL_REG (AI_BASE_REG+0x08) /* R2: DMA Control */ - -/* - * AI status (R): [31]/[0] ai_full (addr & len buffer full), [30] ai_busy - * Note that a 1->0 transition in ai_full will set interrupt - * (W): clear audio interrupt - */ -#define AI_STATUS_REG (AI_BASE_REG+0x0C) /* R3: Status */ - -/* - * AI DAC sample period register (W): [13:0] dac rate - * - vid_clock/(dperiod + 1) is the DAC sample rate - * - (dperiod + 1) >= 66 * (aclockhp + 1) must be true - */ -#define AI_DACRATE_REG (AI_BASE_REG+0x10) /* R4: DAC rate 14-lsb*/ - -/* - * AI bit rate (W): [3:0] bit rate (abus clock half period register - aclockhp) - * - vid_clock/(2 * (aclockhp + 1)) is the DAC clock rate - * - The abus clock stops if aclockhp is zero - */ -#define AI_BITRATE_REG (AI_BASE_REG+0x14) /* R5: Bit rate 4-lsb */ - -/* Value for control register */ -#define AI_CONTROL_DMA_ON 0x01 /* LSB = 1: DMA enable*/ -#define AI_CONTROL_DMA_OFF 0x00 /* LSB = 1: DMA enable*/ - -/* Value for status register */ -#define AI_STATUS_FIFO_FULL 0x80000000 /* Bit 31: full */ -#define AI_STATUS_DMA_BUSY 0x40000000 /* Bit 30: busy */ - -/* DAC rate = video clock / audio frequency - * - DAC rate >= (66 * Bit rate) must be true - */ -#define AI_MAX_DAC_RATE 16384 /* 14-bit+1 */ -#define AI_MIN_DAC_RATE 132 - -/* Bit rate <= (DAC rate / 66) */ -#define AI_MAX_BIT_RATE 16 /* 4-bit+1 */ -#define AI_MIN_BIT_RATE 2 - -/* - * Maximum and minimum values for audio frequency based on video clocks - * max frequency = (video clock / min dac rate) - * min frequency = (video clock / max dac rate) - */ -#define AI_NTSC_MAX_FREQ 368000 /* 368 KHz */ -#define AI_NTSC_MIN_FREQ 3000 /* 3 KHz ~ 2971 Hz */ - -#define AI_PAL_MAX_FREQ 376000 /* 376 KHz */ -#define AI_PAL_MIN_FREQ 3050 /* 3 KHz ~ 3031 Hz */ - -#define AI_MPAL_MAX_FREQ 368000 /* 368 KHz */ -#define AI_MPAL_MIN_FREQ 3000 /* 3 KHz ~ 2968 Hz */ - - -/************************************************************************* - * Peripheral Interface (PI) Registers - */ -#define PI_BASE_REG 0x04600000 - -/* PI DRAM address (R/W): [23:0] starting RDRAM address */ -#define PI_DRAM_ADDR_REG (PI_BASE_REG+0x00) /* DRAM address */ - -/* PI pbus (cartridge) address (R/W): [31:0] starting AD16 address */ -#define PI_CART_ADDR_REG (PI_BASE_REG+0x04) - -/* PI read length (R/W): [23:0] read data length */ -#define PI_RD_LEN_REG (PI_BASE_REG+0x08) - -/* PI write length (R/W): [23:0] write data length */ -#define PI_WR_LEN_REG (PI_BASE_REG+0x0C) - -/* - * PI status (R): [0] DMA busy, [1] IO busy, [2], error - * (W): [0] reset controller (and abort current op), [1] clear intr - */ -#define PI_STATUS_REG (PI_BASE_REG+0x10) - -/* PI dom1 latency (R/W): [7:0] domain 1 device latency */ -#define PI_BSD_DOM1_LAT_REG (PI_BASE_REG+0x14) - -/* PI dom1 pulse width (R/W): [7:0] domain 1 device R/W strobe pulse width */ -#define PI_BSD_DOM1_PWD_REG (PI_BASE_REG+0x18) - -/* PI dom1 page size (R/W): [3:0] domain 1 device page size */ -#define PI_BSD_DOM1_PGS_REG (PI_BASE_REG+0x1C) /* page size */ - -/* PI dom1 release (R/W): [1:0] domain 1 device R/W release duration */ -#define PI_BSD_DOM1_RLS_REG (PI_BASE_REG+0x20) - -/* PI dom2 latency (R/W): [7:0] domain 2 device latency */ -#define PI_BSD_DOM2_LAT_REG (PI_BASE_REG+0x24) /* Domain 2 latency */ - -/* PI dom2 pulse width (R/W): [7:0] domain 2 device R/W strobe pulse width */ -#define PI_BSD_DOM2_PWD_REG (PI_BASE_REG+0x28) /* pulse width */ - -/* PI dom2 page size (R/W): [3:0] domain 2 device page size */ -#define PI_BSD_DOM2_PGS_REG (PI_BASE_REG+0x2C) /* page size */ - -/* PI dom2 release (R/W): [1:0] domain 2 device R/W release duration */ -#define PI_BSD_DOM2_RLS_REG (PI_BASE_REG+0x30) /* release duration */ - -#define PI_DOMAIN1_REG PI_BSD_DOM1_LAT_REG -#define PI_DOMAIN2_REG PI_BSD_DOM2_LAT_REG - -#define PI_DOM_LAT_OFS 0x00 -#define PI_DOM_PWD_OFS 0x04 -#define PI_DOM_PGS_OFS 0x08 -#define PI_DOM_RLS_OFS 0x0C - -/* - * PI status register has 3 bits active when read from (PI_STATUS_REG - read) - * Bit 0: DMA busy - set when DMA is in progress - * Bit 1: IO busy - set when IO is in progress - * Bit 2: Error - set when CPU issues IO request while DMA is busy - */ -#define PI_STATUS_ERROR 0x04 -#define PI_STATUS_IO_BUSY 0x02 -#define PI_STATUS_DMA_BUSY 0x01 - -/* PI status register has 2 bits active when written to: - * Bit 0: When set, reset PIC - * Bit 1: When set, clear interrupt flag - * The values of the two bits can be ORed together to both reset PIC and - * clear interrupt at the same time. - * - * Note: - * - The PIC does generate an interrupt at the end of each DMA. CPU - * needs to clear the interrupt flag explicitly (from an interrupt - * handler) by writing into the STATUS register with bit 1 set. - * - * - When a DMA completes, the interrupt flag is set. CPU can issue - * another request even while the interrupt flag is set (as long as - * PIC is idle). However, it is the CPU's responsibility for - * maintaining accurate correspondence between DMA completions and - * interrupts. - * - * - When PIC is reset, if PIC happens to be busy, an interrupt will - * be generated as PIC returns to idle. Otherwise, no interrupt will - * be generated and PIC remains idle. - */ -/* - * Values to clear interrupt/reset PIC (PI_STATUS_REG - write) - */ -#define PI_STATUS_RESET 0x01 -#define PI_SET_RESET PI_STATUS_RESET - -#define PI_STATUS_CLR_INTR 0x02 -#define PI_CLR_INTR PI_STATUS_CLR_INTR - -#define PI_DMA_BUFFER_SIZE 128 - -#define PI_DOM1_ADDR1 0x06000000 /* to 0x07FFFFFF */ -#define PI_DOM1_ADDR2 0x10000000 /* to 0x1FBFFFFF */ -#define PI_DOM1_ADDR3 0x1FD00000 /* to 0x7FFFFFFF */ -#define PI_DOM2_ADDR1 0x05000000 /* to 0x05FFFFFF */ -#define PI_DOM2_ADDR2 0x08000000 /* to 0x0FFFFFFF */ - - -/************************************************************************* - * RDRAM Interface (RI) Registers - */ -#define RI_BASE_REG 0x04700000 - -/* RI mode (R/W): [1:0] operating mode, [2] stop T active, [3] stop R active */ -#define RI_MODE_REG (RI_BASE_REG+0x00) - -/* RI config (R/W): [5:0] current control input, [6] current control enable */ -#define RI_CONFIG_REG (RI_BASE_REG+0x04) - -/* RI current load (W): [] any write updates current control register */ -#define RI_CURRENT_LOAD_REG (RI_BASE_REG+0x08) - -/* RI select (R/W): [2:0] receive select, [2:0] transmit select */ -#define RI_SELECT_REG (RI_BASE_REG+0x0C) - -/* RI refresh (R/W): [7:0] clean refresh delay, [15:8] dirty refresh delay, - * [16] refresh bank, [17] refresh enable - * [18] refresh optimize - */ -#define RI_REFRESH_REG (RI_BASE_REG+0x10) -#define RI_COUNT_REG RI_REFRESH_REG - -/* RI latency (R/W): [3:0] DMA latency/overlap */ -#define RI_LATENCY_REG (RI_BASE_REG+0x14) - -/* RI error (R): [0] nack error, [1] ack error */ -#define RI_RERROR_REG (RI_BASE_REG+0x18) - -/* RI error (W): [] any write clears all error bits */ -#define RI_WERROR_REG (RI_BASE_REG+0x1C) - - -/************************************************************************* - * Serial Interface (SI) Registers - */ -#define SI_BASE_REG 0x04800000 - -/* SI DRAM address (R/W): [23:0] starting RDRAM address */ -#define SI_DRAM_ADDR_REG (SI_BASE_REG+0x00) /* R0: DRAM address */ - -/* SI address read 64B (W): [] any write causes a 64B DMA write */ -#define SI_PIF_ADDR_RD64B_REG (SI_BASE_REG+0x04) /* R1: 64B PIF->DRAM */ - -/* Address SI_BASE_REG + (0x08, 0x0c, 0x14) are reserved */ - -/* SI address write 64B (W): [] any write causes a 64B DMA read */ -#define SI_PIF_ADDR_WR64B_REG (SI_BASE_REG+0x10) /* R4: 64B DRAM->PIF */ - -/* - * SI status (W): [] any write clears interrupt - * (R): [0] DMA busy, [1] IO read busy, [2] reserved - * [3] DMA error, [12] interrupt - */ -#define SI_STATUS_REG (SI_BASE_REG+0x18) /* R6: Status */ - -/* SI status register has the following bits active: - * 0: DMA busy - set when DMA is in progress - * 1: IO busy - set when IO access is in progress - * 3: DMA error - set when there are overlapping DMA requests - * 12: Interrupt - Interrupt set - */ -#define SI_STATUS_DMA_BUSY 0x0001 -#define SI_STATUS_RD_BUSY 0x0002 -#define SI_STATUS_DMA_ERROR 0x0008 -#define SI_STATUS_INTERRUPT 0x1000 - -/************************************************************************* - * Development Board GIO Control Registers - */ - -#define GIO_BASE_REG 0x18000000 - -/* Game to Host Interrupt */ -#define GIO_GIO_INTR_REG (GIO_BASE_REG+0x000) - -/* Game to Host SYNC */ -#define GIO_GIO_SYNC_REG (GIO_BASE_REG+0x400) - -/* Host to Game Interrupt */ -#define GIO_CART_INTR_REG (GIO_BASE_REG+0x800) - - -/************************************************************************* - * Common macros - */ -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) -#define IO_READ(addr) (*(vu32 *)PHYS_TO_K1(addr)) -#define IO_WRITE(addr,data) (*(vu32 *)PHYS_TO_K1(addr)=(u32)(data)) -#define RCP_STAT_PRINT \ - rmonPrintf("current=%x start=%x end=%x dpstat=%x spstat=%x\n", \ - IO_READ(DPC_CURRENT_REG), \ - IO_READ(DPC_START_REG), \ - IO_READ(DPC_END_REG), \ - IO_READ(DPC_STATUS_REG), \ - IO_READ(SP_STATUS_REG)) - -#endif - -#endif /* _RCP_H_ */ diff --git a/include/PR/sptask.h b/include/PR/sptask.h deleted file mode 100644 index ebb3ee9dd..000000000 --- a/include/PR/sptask.h +++ /dev/null @@ -1,230 +0,0 @@ -/************************************************************************** - * * - * Copyright (C) 1995, Silicon Graphics, Inc. * - * * - * These coded instructions, statements, and computer programs contain * - * unpublished proprietary information of Silicon Graphics, Inc., and * - * are protected by Federal copyright law. They may not be disclosed * - * to third parties or copied or duplicated in any form, in whole or * - * in part, without the prior written consent of Silicon Graphics, Inc. * - * * - **************************************************************************/ - -/************************************************************************** - * - * $Revision: 1.9 $ - * $Date: 1998/03/05 06:40:29 $ - * $Source: /exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/sptask.h,v $ - * - **************************************************************************/ - -#ifndef _SPTASK_H_ -#define _SPTASK_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - -/* - * Task List Structure. - * - * Things an app might pass to the SP via the task list. - * Not every task ucode would need/use every field, but - * - * - type (audio, gfx, video, ...) - * - flags - * - wait for DP to drain before running new task - * - SEE BIT DEFINITIONS UNDER "Task Flags field" - * - pointer to boot ucode - * - size of boot ucode - * - pointer to ucode - * - size of ucode - * - pointer to initial DMEM data - * - size of initial DMEM data - * - pointer to DRAM stack - * - size of DRAM stack (max) - * - pointer to output buffer - * - pointer to store output buffer length - * - generic data pointer (for display list, etc.) - * - generic data length (for display list, etc.) - * - pointer to buffer where to store saved DMEM (in yield case) - * - size of buffer to store saved DMEM. - * - * IMPORTANT!!! Watch alignment issues. - * - * IMPORTANT!!! Watch data cache issues. The RCP may write data into the - * dram_stack, output_buff, output_buff_size, and the yield_data_ptr areas. - * These buffers should be cache aligned and use the entire line (16 bytes) to - * avoid corruption by writebacks by the CPU (cache tearing). - * - * IMPORTANT!!! all addresses are virtual addresses. Library does - * any necessary translation. - * - */ -typedef struct -{ - /*0x00*/ u32 type; - /*0x04*/ u32 flags; - - /*0x08*/ u64 *ucode_boot; - /*0x0C*/ u32 ucode_boot_size; - - /*0x10*/ u64 *ucode; - /*0x14*/ u32 ucode_size; - - /*0x18*/ u64 *ucode_data; - /*0x1C*/ u32 ucode_data_size; - - /*0x20*/ u64 *dram_stack; - /*0x24*/ u32 dram_stack_size; - - /*0x28*/ u64 *output_buff; - /*0x2C*/ u64 *output_buff_size; - - /*0x30*/ u64 *data_ptr; - /*0x34*/ u32 data_size; - - /*0x38*/ u64 *yield_data_ptr; - /*0x3C*/ u32 yield_data_size; -} OSTask_t; // size = 0x40 - -typedef union { - OSTask_t t; - long long int force_structure_alignment; -} OSTask; - -typedef u32 OSYieldResult; -#endif /* _LANGUAGE_C */ - - -/* - * Task Flags field - */ -#define OS_TASK_YIELDED 0x0001 -#define OS_TASK_DP_WAIT 0x0002 -#define OS_TASK_LOADABLE 0x0004 -#define OS_TASK_SP_ONLY 0x0008 -#define OS_TASK_USR0 0x0010 -#define OS_TASK_USR1 0x0020 -#define OS_TASK_USR2 0x0040 -#define OS_TASK_USR3 0x0080 - -/* - * Size of Yield buffer. The taskHdrPtr->t.yield_data_ptr must point to a - * buffer of this size. (The size is in bytes). ONLY If the task will NEVER - * yield it may be a null pointer. The buffer must be aligned to a 64 bit - * boundary. The taskHdrPtr->t.yield_data_ptr must be set to point to the - * buffer BEFORE the task is started. - */ -#if (defined(F3DEX_GBI) || defined(F3DLP_GBI) || defined(F3DEX_GBI_2)) -#ifdef F3D_OLD -#define OS_YIELD_DATA_SIZE 0xD00 -#else -#define OS_YIELD_DATA_SIZE 0xC00 -#endif -#else -#define OS_YIELD_DATA_SIZE 0x900 -#endif - -//! @todo These defines shouldn't exist - PR/rcp.h has them properly defined (ultralib) -/* Flags */ -#define M_TASK_FLAG0 1 -#define M_TASK_FLAG1 2 - -/* SpStatus */ -#define SPSTATUS_CLEAR_HALT 0x00000001 -#define SPSTATUS_SET_HALT 0x00000002 -#define SPSTATUS_CLEAR_BROKE 0x00000004 -#define SPSTATUS_CLEAR_INTR 0x00000008 -#define SPSTATUS_SET_INTR 0x00000010 -#define SPSTATUS_CLEAR_SSTEP 0x00000020 -#define SPSTATUS_SET_SSTEP 0x00000040 -#define SPSTATUS_CLEAR_INTR_ON_BREAK 0x00000080 -#define SPSTATUS_SET_INTR_ON_BREAK 0x00000100 -#define SPSTATUS_CLEAR_SIGNAL0 0x00000200 -#define SPSTATUS_SET_SIGNAL0 0x00000400 -#define SPSTATUS_CLEAR_SIGNAL1 0x00000800 -#define SPSTATUS_SET_SIGNAL1 0x00001000 -#define SPSTATUS_CLEAR_SIGNAL2 0x00002000 -#define SPSTATUS_SET_SIGNAL2 0x00004000 -#define SPSTATUS_CLEAR_SIGNAL3 0x00008000 -#define SPSTATUS_SET_SIGNAL3 0x00010000 -#define SPSTATUS_CLEAR_SIGNAL4 0x00020000 -#define SPSTATUS_SET_SIGNAL4 0x00040000 -#define SPSTATUS_CLEAR_SIGNAL5 0x00080000 -#define SPSTATUS_SET_SIGNAL5 0x00100000 -#define SPSTATUS_CLEAR_SIGNAL6 0x00200000 -#define SPSTATUS_SET_SIGNAL6 0x00800000 -#define SPSTATUS_CLEAR_SIGNAL7 0x01000000 -#define SPSTATUS_SET_SIGNAL7 0x02000000 - -#define SPSTATUS_HALT 0x0001 -#define SPSTATUS_BROKE 0x0002 -#define SPSTATUS_DMA_BUSY 0x0004 -#define SPSTATUS_DMA_FULL 0x0008 -#define SPSTATUS_IO_FULL 0x0010 -#define SPSTATUS_SINGLE_STEP 0x0020 -#define SPSTATUS_INTERRUPT_ON_BREAK 0x0040 -#define SPSTATUS_SIGNAL0_SET 0x0080 -#define SPSTATUS_SIGNAL1_SET 0x0100 -#define SPSTATUS_SIGNAL2_SET 0x0200 -#define SPSTATUS_SIGNAL3_SET 0x0400 -#define SPSTATUS_SIGNAL4_SET 0x0800 -#define SPSTATUS_SIGNAL5_SET 0x1000 -#define SPSTATUS_SIGNAL6_SET 0x2000 -#define SPSTATUS_SIGNAL7_SET 0x4000 - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - -/* - * this macro simulates atomic action. - */ -#define osSpTaskStart(p) \ - osSpTaskLoad(p); \ - osSpTaskStartGo(p); - -/************************************************************************** - * - * Extern variables - * - */ - - -/************************************************************************** - * - * Function prototypes - * - */ - -/* - * break this up into two steps for debugging. - */ -extern void osSpTaskLoad(OSTask *task); -extern void osSpTaskStartGo(OSTask *task); - -extern void osSpTaskYield(void); -extern OSYieldResult osSpTaskYielded(OSTask *task); - -#endif /* _LANGUAGE_C */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_SPTASK_H */ diff --git a/include/PR/ucode.h b/include/PR/ucode.h deleted file mode 100644 index f86d3047a..000000000 --- a/include/PR/ucode.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _ULTRA64_UCODE_H_ -#define _ULTRA64_UCODE_H_ - -#define SP_DRAM_STACK_SIZE8 0x400 -#define SP_UCODE_SIZE 0x1000 -#define SP_UCODE_DATA_SIZE 0x800 - -// standard boot ucode -extern u64 rspF3DBootStart[], rspF3DBootEnd[]; - -// F3D ucode -extern u64 gspF3DEXTextStart[], gspF3DEXTextEnd[]; - -extern u64 gspF3DLXTextStart[], gspF3DLXTextEnd[]; - -// F3D ucode data -extern u64 gspF3DEXDataStart[], gspF3DEXDataEnd[]; - -extern u64 gspF3DLXDataStart[], gspF3DLXDataEnd[]; - -// aspMain (audio) ucode -extern u64 rspAspMainStart[], rspAspMainEnd[]; - -// aspMain ucode data -extern u64 rspAspMainDataStart[], rspAspMainDataEnd[]; - -#endif diff --git a/include/PR/ultratypes.h b/include/PR/ultratypes.h deleted file mode 100644 index 5a7ba5a93..000000000 --- a/include/PR/ultratypes.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef _ULTRA64_TYPES_H_ -#define _ULTRA64_TYPES_H_ - -#ifndef NULL -#define NULL (void *)0 -#endif - -#define TRUE 1 -#define FALSE 0 - -typedef signed char s8; -typedef unsigned char u8; -typedef signed short int s16; -typedef unsigned short int u16; -typedef signed int s32; -typedef unsigned int u32; -typedef signed long long int s64; -typedef unsigned long long int u64; - -typedef signed int bool; -typedef signed char bool8; -typedef unsigned char ubool8; - -typedef volatile u8 vu8; -typedef volatile u16 vu16; -typedef volatile u32 vu32; -typedef volatile u64 vu64; -typedef volatile s8 vs8; -typedef volatile s16 vs16; -typedef volatile s32 vs32; -typedef volatile s64 vs64; - -typedef float f32; -typedef double f64; - -#ifdef TARGET_N64 -typedef u32 size_t; -typedef s32 ssize_t; -typedef u32 uintptr_t; -typedef s32 intptr_t; -typedef s32 ptrdiff_t; -#else -#include -typedef ptrdiff_t ssize_t; -#endif - -#endif diff --git a/include/actor_types.h b/include/actor_types.h index 3c3d88745..c8b611b88 100644 --- a/include/actor_types.h +++ b/include/actor_types.h @@ -1,7 +1,7 @@ #ifndef ACTOR_TYPES_H #define ACTOR_TYPES_H -#include +#include #include #include @@ -13,25 +13,25 @@ * gActorList should be understood to be populated by generic Actor structs. * However, for human readability, many functions interacting with actor list elements expect one of the many * specialized types found in this file. - * + * * Note that specialized types must be the same size as a plain Actor. Don't be mislead into thinking that * because its a separate type that it can modified separately from plain Actor. If you modify/add an actor type * and its size is different from plain Actor's, you WILL run into buggy (potentially crash inducing) behaviour. - * + * * Specialized structs are customizable so long as the following member specifications are met: - * + * * In general: * 0x00 -> s16 type * 0x02 -> s16 flags * 0x30 -> Collision unk30 - * + * * If player can collide with the actor: * 0x0C -> f32 boundingBoxSize - * + * * If the actor makes sound (necessary for doppler/volume stuff): * 0x18 -> Vec3f pos * 0x24 -> Vec3f velocity - * + * * Other members are more flexible, and even the non-general specifications can be ignored IF AND ONLY IF you know * exactly what you're doing. */ diff --git a/include/common_structs.h b/include/common_structs.h index c7384e036..7726cace8 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -1,7 +1,7 @@ #ifndef _COMMON_STRUCTS_H_ #define _COMMON_STRUCTS_H_ -#include "ultra64.h" +#include typedef f32 Vec3f[3]; typedef f32 Vec4f[4]; @@ -400,7 +400,7 @@ typedef struct { } Player; // size = 0xDD8 typedef struct -{ +{ // Something related to time trial ghost data? /* 0x00 */ s32 unk_00; /* 0x04 */ u8 ghostDataSaved; diff --git a/include/course.h b/include/course.h index 3f4498766..60c70744a 100644 --- a/include/course.h +++ b/include/course.h @@ -1,8 +1,8 @@ #ifndef COURSE_H #define COURSE_H -#include -#include +#include +#include #include /** diff --git a/include/course_offsets.h b/include/course_offsets.h index 5b10a8940..61c044b5d 100644 --- a/include/course_offsets.h +++ b/include/course_offsets.h @@ -1,7 +1,7 @@ #ifndef COURSE_OFFSETS_H #define COURSE_OFFSETS_H -#include +#include typedef struct { diff --git a/include/debug.h b/include/debug.h index de202bfbb..ba30c8698 100644 --- a/include/debug.h +++ b/include/debug.h @@ -1,7 +1,7 @@ #ifndef _DEBUG_H_ #define _DEBUG_H_ -#include +#include #include /** @@ -41,7 +41,7 @@ #define OCTAL 8 #define BINARY 2 -/** +/** * This structure is the heart of the DVDL. * only the first 4 attributes should be set by the user, the other 2 are used by the program. */ @@ -57,7 +57,7 @@ typedef struct /** * This structure array is what you edit to display in the list. - * First index is the variable name, second is a pointer to the variable and + * First index is the variable name, second is a pointer to the variable and * third is the size of the variable. * * initilized in debug/debug.inc.c @@ -65,7 +65,7 @@ typedef struct extern variableWatchAttributes gMainVariableWatchList[]; /** - * This is what calls the debug watch list. Because of how mk64 was programed, + * This is what calls the debug watch list. Because of how mk64 was programed, * It's called at 4 different parts of the code. One for menus, race, * ending sequence and creditis. It does not display during loading time because * the RSP is not initialized during that portion of the code. diff --git a/include/kart_attributes.h b/include/kart_attributes.h index b89d01ce7..d94a4144e 100644 --- a/include/kart_attributes.h +++ b/include/kart_attributes.h @@ -1,7 +1,7 @@ #ifndef KART_ATTRIBUTES_H #define KART_ATTRIBUTES_H -#include +#include extern f32 D_800E2360[8]; extern f32 D_800E2380[8]; diff --git a/include/libc/stddef.h b/include/libc/stddef.h index 7e72a7bb6..467c140da 100644 --- a/include/libc/stddef.h +++ b/include/libc/stddef.h @@ -1,7 +1,7 @@ #ifndef STDDEF_H #define STDDEF_H -#include "PR/ultratypes.h" +#include #ifndef offsetof #define offsetof(st, m) ((size_t)&(((st *)0)->m)) diff --git a/include/libc/string.h b/include/libc/string.h index 183409eb5..70eb56dcb 100644 --- a/include/libc/string.h +++ b/include/libc/string.h @@ -1,7 +1,7 @@ #ifndef STRING_H #define STRING_H -#include "PR/ultratypes.h" +#include void *memcpy(void *dst, const void *src, size_t size); size_t strlen(const char *str); diff --git a/include/macros.h b/include/macros.h index 9e15613f4..241cffdb4 100644 --- a/include/macros.h +++ b/include/macros.h @@ -1,6 +1,8 @@ #ifndef _MACROS_H_ #define _MACROS_H_ +#include +#include #ifndef __sgi #define GLOBAL_ASM(...) @@ -89,4 +91,6 @@ **/ #define GET_PACKED_END(dl) (((u8 *) dl) + sizeof(dl) - sizeof(dl[0]) - 0x07000000) +void gSPDisplayList(Gfx* pkt, Gfx* dl); + #endif diff --git a/include/mk64.h b/include/mk64.h index 18604c9f0..ea1a65b63 100644 --- a/include/mk64.h +++ b/include/mk64.h @@ -116,4 +116,11 @@ enum SURFACE_TYPE { #define MACRO_COLOR_FLAG(r, g, b, flag) (r&~0x3) | (flag & 0x3), (g&~0x3) | ((flag>>2) & 0x3), b +// libultra +void gSPSegmentLoadRes(void* value, int segNum, uintptr_t target); +void gSPDisplayList(Gfx* pkt, Gfx* dl); +void gSPDisplayListOffset(Gfx* pkt, Gfx* dl, int offset); +void gSPVertex(Gfx* pkt, uintptr_t v, int n, int v0); +void gSPInvalidateTexCache(Gfx* pkt, uintptr_t texAddr); + #endif // MK64_H diff --git a/include/segments.h b/include/segments.h index 20e57cfaf..ec34b6d64 100644 --- a/include/segments.h +++ b/include/segments.h @@ -1,7 +1,7 @@ #ifndef SEGMENTS_H #define SEGMENTS_H -#include +#include #include extern u8 _memoryPoolSegmentNoloadStart[]; @@ -52,7 +52,7 @@ extern u8 _startupLogoSegmentRomEnd[]; #define SEG_ENDING (uintptr_t) &_endingSegmentStart[0] #define SEG_ENDING_ROM_START (uintptr_t) &_endingSegmentRomStart[0] - /** + /** * Ending segment original size is 0xDF00 but much of that remains unused. * This auto fits the segment to its proper size. */ @@ -87,7 +87,7 @@ extern u8 _startupLogoSegmentRomEnd[]; #define SEG_ENDING (uintptr_t) 0x80280000 #define SEG_ENDING_ROM_START (u8 *) &_endingSegmentRomStart[0] - + #define SEG_ENDING_SIZE (size_t) 0xDF00 #define SEG_ENDING_ROM_SIZE (size_t) ALIGN16( (ptrdiff_t) (&_endingSegmentRomEnd[0] - &_endingSegmentRomStart[0]) ) diff --git a/include/ultra64.h b/include/ultra64.h deleted file mode 100644 index 409a3cf76..000000000 --- a/include/ultra64.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _ULTRA64_H_ -#define _ULTRA64_H_ - -#include - -#ifndef _LANGUAGE_C -#define _LANGUAGE_C -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif diff --git a/libultraship b/libultraship new file mode 160000 index 000000000..dc2477416 --- /dev/null +++ b/libultraship @@ -0,0 +1 @@ +Subproject commit dc2477416266cfc15dc79c4d7135a70c0c4a56bd diff --git a/src/actors/banana/render.inc.c b/src/actors/banana/render.inc.c index e148cb767..ee7220421 100644 --- a/src/actors/banana/render.inc.c +++ b/src/actors/banana/render.inc.c @@ -1,13 +1,13 @@ #include #include -#include +#include /** * @brief Render the banana actor - * - * @param camera - * @param arg1 - * @param banana + * + * @param camera + * @param arg1 + * @param banana */ void render_actor_banana(Camera *camera, UNUSED Mat4 arg1, struct BananaActor *banana) { UNUSED s32 pad[2]; diff --git a/src/actors/blue_and_red_shells/render.inc.c b/src/actors/blue_and_red_shells/render.inc.c index 42bf7ca82..c0dc24c8f 100644 --- a/src/actors/blue_and_red_shells/render.inc.c +++ b/src/actors/blue_and_red_shells/render.inc.c @@ -1,12 +1,12 @@ #include -#include +#include /** * @brief Render the red shell actor - * - * @param camera - * @param matrix - * @param shell + * + * @param camera + * @param matrix + * @param shell */ void render_actor_red_shell(Camera *camera, Mat4 matrix, struct ShellActor *shell) { gDPLoadTLUT_pal256(gDisplayListHead++, &gTLUTRedShell); // set texture @@ -15,10 +15,10 @@ void render_actor_red_shell(Camera *camera, Mat4 matrix, struct ShellActor *shel /** * @brief Render the blue shell actor - * - * @param camera - * @param matrix - * @param shell + * + * @param camera + * @param matrix + * @param shell */ void render_actor_blue_shell(Camera *camera, Mat4 matrix, struct ShellActor *shell) { gDPLoadTLUT_pal256(gDisplayListHead++, common_tlut_blue_shell); // set texture diff --git a/src/actors/box_truck/render.inc.c b/src/actors/box_truck/render.inc.c index 794dd305e..f429144c1 100644 --- a/src/actors/box_truck/render.inc.c +++ b/src/actors/box_truck/render.inc.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include "courses/toads_turnpike/course_data.h" @@ -8,9 +8,9 @@ * @brief Renders the box truck actor. * Actor used in Toad's Turnpike. * His update are made in vehicle. - * - * @param arg0 - * @param arg1 + * + * @param arg0 + * @param arg1 */ void render_actor_box_truck(Camera *arg0, struct Actor *arg1) { UNUSED s32 pad[6]; diff --git a/src/actors/cow/render.inc.c b/src/actors/cow/render.inc.c index 3800fbbbc..58042e389 100644 --- a/src/actors/cow/render.inc.c +++ b/src/actors/cow/render.inc.c @@ -1,16 +1,16 @@ #include #include #include -#include +#include #include "courses/moo_moo_farm/course_data.h" /** * @brief Renders the cow actor. * Actor used in Moo Moo Farm. - * - * @param camera - * @param arg1 - * @param arg2 + * + * @param camera + * @param arg1 + * @param arg2 */ void render_actor_cow(Camera *camera, Mat4 arg1, struct Actor *arg2) { if (is_within_render_distance(camera->pos, arg2->pos, camera->rot[1], 0, gCameraZoom[camera - camera1], 4000000.0f) < 0) { return; } diff --git a/src/actors/fake_item_box/render.inc.c b/src/actors/fake_item_box/render.inc.c index 30ef468d4..e01de10a8 100644 --- a/src/actors/fake_item_box/render.inc.c +++ b/src/actors/fake_item_box/render.inc.c @@ -1,13 +1,13 @@ #include #include -#include +#include #include /** * @brief Renders the fake item box actor. - * - * @param camera - * @param fakeItemBox + * + * @param camera + * @param fakeItemBox */ void render_actor_fake_item_box(Camera *camera, struct FakeItemBox *fakeItemBox) { Vec3s someRot; diff --git a/src/actors/falling_rock/update.inc.c b/src/actors/falling_rock/update.inc.c index b10a9b26f..15f9e589d 100644 --- a/src/actors/falling_rock/update.inc.c +++ b/src/actors/falling_rock/update.inc.c @@ -4,9 +4,7 @@ #include "courses/choco_mountain/course_data.h" void func_8029CF0C(struct ActorSpawnData *spawnData, struct FallingRock *rock) { - s32 segment = SEGMENT_NUMBER2(spawnData); - s32 offset = SEGMENT_OFFSET(spawnData); - struct ActorSpawnData *temp_v0 = (struct ActorSpawnData *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + struct ActorSpawnData *temp_v0 = (struct ActorSpawnData *) spawnData; Vec3s sp24 = {60, 120, 180}; temp_v0 += rock->unk_06; rock->respawnTimer = sp24[rock->unk_06]; // * 2 @@ -20,14 +18,12 @@ void func_8029CF0C(struct ActorSpawnData *spawnData, struct FallingRock *rock) { /** * @brief Spawns falling rocks. * Used in Choco Mountain. - * - * @param spawnData + * + * @param spawnData */ void spawn_falling_rocks(struct ActorSpawnData *spawnData) { - s32 addr = SEGMENT_NUMBER2(spawnData); - s32 offset = SEGMENT_OFFSET(spawnData); // Casting this to prevent warning does not work. - struct ActorSpawnData *temp_s0 = (struct ActorSpawnData *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[addr] + offset); + struct ActorSpawnData *temp_s0 = spawnData; struct FallingRock *temp_v1; Vec3f startingPos; Vec3f startingVelocity; @@ -52,8 +48,8 @@ void spawn_falling_rocks(struct ActorSpawnData *spawnData) { /** * @brief Updates the falling rock actor. * Actor used in Choco Mountain. - * - * @param rock + * + * @param rock */ void update_actor_falling_rocks(struct FallingRock *rock) { Vec3f unkVec; diff --git a/src/actors/green_shell/render.inc.c b/src/actors/green_shell/render.inc.c index 627e62886..e5432f9bc 100644 --- a/src/actors/green_shell/render.inc.c +++ b/src/actors/green_shell/render.inc.c @@ -1,14 +1,14 @@ #include -#include +#include #include #include /** * @brief Renders the green shell actor. - * - * @param camera - * @param matrix - * @param shell + * + * @param camera + * @param matrix + * @param shell */ void render_actor_green_shell(Camera *camera, Mat4 matrix, struct ShellActor *shell) { gDPLoadTLUT_pal256(gDisplayListHead++, common_tlut_green_shell); // set texture diff --git a/src/actors/kiwano_fruit/render.inc.c b/src/actors/kiwano_fruit/render.inc.c index b6d4c16bd..eef9bd5c9 100644 --- a/src/actors/kiwano_fruit/render.inc.c +++ b/src/actors/kiwano_fruit/render.inc.c @@ -1,15 +1,15 @@ #include -#include +#include #include #include "courses/dks_jungle_parkway/course_data.h" /** * @brief Renders the kiwano fruit actor. * Actor used in DK's Jungle Parkway. - * - * @param camera - * @param arg1 - * @param actor + * + * @param camera + * @param arg1 + * @param actor */ void render_actor_kiwano_fruit(UNUSED Camera *camera, Mat4 arg1, struct Actor *actor) { uintptr_t addr; diff --git a/src/actors/paddle_boat/render.inc.c b/src/actors/paddle_boat/render.inc.c index 379b7455d..bf2c4006d 100644 --- a/src/actors/paddle_boat/render.inc.c +++ b/src/actors/paddle_boat/render.inc.c @@ -1,20 +1,20 @@ -#include +#include #include #include #include "camera.h" #include "main.h" #include "actors.h" #include "courses/all_course_data.h" -#include +#include /** * @brief Renders the paddle boat actor. * Actor used in DK's Jungle Parkway. - * - * @param arg0 - * @param boat - * @param arg2 - * @param pathCounter + * + * @param arg0 + * @param boat + * @param arg2 + * @param pathCounter */ void render_actor_paddle_boat(Camera *arg0, struct PaddleWheelBoat *boat, UNUSED Mat4 arg2, u16 pathCounter) { UNUSED s32 pad[3]; @@ -25,7 +25,7 @@ void render_actor_paddle_boat(Camera *arg0, struct PaddleWheelBoat *boat, UNUSED f32 temp; if ((pathCounter > 20) && (pathCounter < 25)) { return; } - + temp = is_within_render_distance(arg0->pos, boat->pos, arg0->rot[1], 90000.0f, gCameraZoom[arg0 - camera1], 9000000.0f); if (temp < 0.0f) { return; } diff --git a/src/actors/paddle_boat/update.inc.c b/src/actors/paddle_boat/update.inc.c index 386e634d0..fdb596388 100644 --- a/src/actors/paddle_boat/update.inc.c +++ b/src/actors/paddle_boat/update.inc.c @@ -1,12 +1,12 @@ -#include +#include #include /** * @brief Updates the paddle boat actor. * Actor used in DK's Jungle Parkway. * Rotate only the paddle wheel, for position and rotation of the boat it's in vehicle. - * - * @param boat + * + * @param boat */ void update_actor_paddle_boat(struct PaddleWheelBoat *boat) { boat->wheelRot += 0x38E; diff --git a/src/actors/piranha_plant/render.inc.c b/src/actors/piranha_plant/render.inc.c index 525c73b01..8be53d488 100644 --- a/src/actors/piranha_plant/render.inc.c +++ b/src/actors/piranha_plant/render.inc.c @@ -1,16 +1,16 @@ #include #include -#include +#include #include "courses/mario_raceway/course_data.h" #include "courses/royal_raceway/course_data.h" /** * @brief Renders the piranha plant actor. * Actor used in Mario Raceway and Royal Raceway. - * - * @param arg0 - * @param arg1 - * @param arg2 + * + * @param arg0 + * @param arg1 + * @param arg2 */ void render_actor_piranha_plant(Camera *arg0, Mat4 arg1, struct PiranhaPlant *arg2) { UNUSED s32 pad; diff --git a/src/actors/railroad_crossing/render.inc.c b/src/actors/railroad_crossing/render.inc.c index b87d6a695..e21894b0f 100644 --- a/src/actors/railroad_crossing/render.inc.c +++ b/src/actors/railroad_crossing/render.inc.c @@ -1,14 +1,14 @@ #include -#include +#include #include #include "courses/kalimari_desert/course_data.h" /** * @brief Renders the railroad crossing actor. * Actor used in Kalimari Desert. - * - * @param arg0 - * @param rr_crossing + * + * @param arg0 + * @param rr_crossing */ void render_actor_railroad_crossing(Camera *arg0, struct RailroadCrossing *rr_crossing) { UNUSED Vec3s sp80 = {0, 0, 0}; diff --git a/src/actors/school_bus/render.inc.c b/src/actors/school_bus/render.inc.c index 163e258ee..82de0926f 100644 --- a/src/actors/school_bus/render.inc.c +++ b/src/actors/school_bus/render.inc.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include @@ -7,9 +7,9 @@ * @brief Renders the school bus actor. * Actor used in Toad's Turnpike. * His update are made in vehicle. - * - * @param arg0 - * @param arg1 + * + * @param arg0 + * @param arg1 */ void render_actor_school_bus(Camera *arg0, struct Actor *arg1) { UNUSED s32 pad[6]; diff --git a/src/actors/train/render.inc.c b/src/actors/train/render.inc.c index d4fab764a..ff6596c6b 100644 --- a/src/actors/train/render.inc.c +++ b/src/actors/train/render.inc.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "courses/kalimari_desert/course_data.h" @@ -7,9 +7,9 @@ * @brief Renders the train engine actor. * Actor used in Kalimari Desert. * His update position are made in vehicle. - * - * @param camera - * @param actor + * + * @param camera + * @param actor */ void render_actor_train_engine(Camera *camera, struct TrainCar *actor) { UNUSED s32 pad[2]; diff --git a/src/actors/trees/render.inc.c b/src/actors/trees/render.inc.c index 9fe162160..5521e787e 100644 --- a/src/actors/trees/render.inc.c +++ b/src/actors/trees/render.inc.c @@ -1,15 +1,15 @@ #include -#include +#include #include #include #include "courses/all_course_data.h" /** * @brief Renders the tree actor in Mario rawceay. - * - * @param camera - * @param arg1 - * @param arg2 + * + * @param camera + * @param arg1 + * @param arg2 */ void render_actor_tree_mario_raceway(Camera *camera, Mat4 arg1, struct Actor *arg2) { f32 temp_f0; @@ -36,10 +36,10 @@ void render_actor_tree_mario_raceway(Camera *camera, Mat4 arg1, struct Actor *ar /** * @brief Renders the tree actor in Yoshi Valley. - * - * @param camera - * @param arg1 - * @param arg2 + * + * @param camera + * @param arg1 + * @param arg2 */ void render_actor_tree_yoshi_valley(Camera *camera, Mat4 arg1, struct Actor *arg2) { f32 temp_f0; @@ -66,10 +66,10 @@ void render_actor_tree_yoshi_valley(Camera *camera, Mat4 arg1, struct Actor *arg /** * @brief Renders the tree actor in Royal Raceway. - * - * @param camera - * @param arg1 - * @param arg2 + * + * @param camera + * @param arg1 + * @param arg2 */ void render_actor_tree_royal_raceway(Camera *camera, Mat4 arg1, struct Actor *arg2) { f32 temp_f0; @@ -96,10 +96,10 @@ void render_actor_tree_royal_raceway(Camera *camera, Mat4 arg1, struct Actor *ar /** * @brief Renders the tree actor in Moo Moo Farm. - * - * @param camera - * @param arg1 - * @param arg2 + * + * @param camera + * @param arg1 + * @param arg2 */ void render_actor_tree_moo_moo_farm(Camera *camera, Mat4 arg1, struct Actor *arg2) { f32 temp_f0; @@ -154,10 +154,10 @@ void func_80299864(Camera *camera, Mat4 arg1, struct Actor *arg2) { /** * @brief Renders the tree actor in Bowser's Castle. - * - * @param camera - * @param arg1 - * @param arg2 + * + * @param camera + * @param arg1 + * @param arg2 */ void render_actor_tree_bowser_castle(Camera *camera, Mat4 arg1, struct Actor *arg2) { f32 temp_f0; @@ -184,10 +184,10 @@ void render_actor_tree_bowser_castle(Camera *camera, Mat4 arg1, struct Actor *ar /** * @brief Renders the bush actor in Bowser's Castle. - * - * @param camera - * @param arg1 - * @param arg2 + * + * @param camera + * @param arg1 + * @param arg2 */ void render_actor_bush_bowser_castle(Camera *camera, Mat4 arg1, struct Actor *arg2) { f32 temp_f0; @@ -214,10 +214,10 @@ void render_actor_bush_bowser_castle(Camera *camera, Mat4 arg1, struct Actor *ar /** * @brief Renders the tree actor in Frappe Snowland. - * - * @param camera - * @param arg1 - * @param arg2 + * + * @param camera + * @param arg1 + * @param arg2 */ void render_actor_tree_frappe_snowland(Camera *camera, Mat4 arg1, struct Actor *arg2) { f32 temp_f0; @@ -243,10 +243,10 @@ void render_actor_tree_frappe_snowland(Camera *camera, Mat4 arg1, struct Actor * /** * @brief Renders the a first variant of cactus in Kalimari Desert. - * - * @param camera - * @param arg1 - * @param arg2 + * + * @param camera + * @param arg1 + * @param arg2 */ void render_actor_tree_cactus1_kalimari_desert(Camera *camera, Mat4 arg1, struct Actor *arg2) { f32 temp_f0; @@ -272,10 +272,10 @@ void render_actor_tree_cactus1_kalimari_desert(Camera *camera, Mat4 arg1, struct /** * @brief Renders the a second variant of cactus in Kalimari Desert. - * - * @param camera - * @param arg1 - * @param arg2 + * + * @param camera + * @param arg1 + * @param arg2 */ void render_actor_tree_cactus2_kalimari_desert(Camera *camera, Mat4 arg1, struct Actor *arg2) { f32 temp_f0; @@ -301,10 +301,10 @@ void render_actor_tree_cactus2_kalimari_desert(Camera *camera, Mat4 arg1, struct /** * @brief Renders the a third variant of cactus in Kalimari Desert. - * - * @param camera - * @param arg1 - * @param arg2 + * + * @param camera + * @param arg1 + * @param arg2 */ void render_actor_tree_cactus3_kalimari_desert(Camera *camera, Mat4 arg1, struct Actor *arg2) { f32 temp_f0; diff --git a/src/actors/wario_sign/render.inc.c b/src/actors/wario_sign/render.inc.c index 84216470f..1572d940b 100644 --- a/src/actors/wario_sign/render.inc.c +++ b/src/actors/wario_sign/render.inc.c @@ -1,14 +1,14 @@ #include -#include +#include #include #include "courses/wario_stadium/course_data.h" /** * @brief Renders the Wario sign actor. * Used in Wario Stadium. - * - * @param arg0 - * @param arg1 + * + * @param arg0 + * @param arg1 */ void render_actor_wario_sign(Camera *arg0, struct Actor *arg1) { Mat4 sp38; diff --git a/src/audio/data.c b/src/audio/data.c index 5efa7734a..eac2a10ff 100644 --- a/src/audio/data.c +++ b/src/audio/data.c @@ -1,4 +1,4 @@ -#include +#include #include #include "data.h" diff --git a/src/audio/effects.c b/src/audio/effects.c index d8003ef1a..2ebd60da3 100644 --- a/src/audio/effects.c +++ b/src/audio/effects.c @@ -1,4 +1,4 @@ -#include +#include #include #include "audio/seqplayer.h" @@ -30,7 +30,7 @@ void sequence_channel_process_sound(struct SequenceChannel *seqChannel, s32 reca layer->noteFreqScale = layer->freqScale * seqChannel->freqScale; layer->noteVelocity = layer->velocitySquare * seqChannel->appliedVolume; layer->notePan = (seqChannel->pan + layer->pan * (0x80 - seqChannel->panChannelWeight)) >> 7; - layer->notePropertiesNeedInit = FALSE; + layer->notePropertiesNeedInit = false; } else { if (seqChannel->changes.as_bitfields.freqScale) { layer->noteFreqScale = layer->freqScale * seqChannel->freqScale; @@ -52,7 +52,7 @@ void sequence_player_process_sound(struct SequencePlayer *seqPlayer) { if (seqPlayer->fadeRemainingFrames != 0) { seqPlayer->fadeVolume += seqPlayer->fadeVelocity; - seqPlayer->recalculateVolume = TRUE; + seqPlayer->recalculateVolume = true; if (seqPlayer->fadeVolume > US_FLOAT2(1)) { seqPlayer->fadeVolume = US_FLOAT2(1); @@ -75,13 +75,13 @@ void sequence_player_process_sound(struct SequencePlayer *seqPlayer) { // Process channels for (i = 0; i < CHANNELS_MAX; i++) { - if (IS_SEQUENCE_CHANNEL_VALID(seqPlayer->channels[i]) == TRUE - && seqPlayer->channels[i]->enabled == TRUE) { + if (IS_SEQUENCE_CHANNEL_VALID(seqPlayer->channels[i]) == true + && seqPlayer->channels[i]->enabled == true) { sequence_channel_process_sound(seqPlayer->channels[i], seqPlayer->recalculateVolume); } } - seqPlayer->recalculateVolume = FALSE; + seqPlayer->recalculateVolume = false; } f32 get_portamento_freq_scale(struct Portamento *p) { @@ -176,7 +176,7 @@ void note_vibrato_init(struct Note *note) { vib = ¬e->vibratoState; - vib->active = TRUE; + vib->active = true; vib->time = 0; vib->curve = gWaveSamples[2]; diff --git a/src/audio/external.c b/src/audio/external.c index a46e63712..ead0d88eb 100644 --- a/src/audio/external.c +++ b/src/audio/external.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -12,6 +12,7 @@ #include "code_800029B0.h" #include "code_80005FD0.h" #include "code_80091750.h" +#include s8 D_8018EF10; UnkStruct8018EF18 D_8018EF18[16]; @@ -31,7 +32,7 @@ u8 sSoundBankFreeListFront[SOUND_BANK_COUNT]; u8 sNumSoundsInBank[SOUND_BANK_COUNT]; u8 D_80192AB8[SOUND_BANK_COUNT][8][8]; u8 D_80192C38; -ubool8 sSoundBankDisabled[SOUND_BANK_COUNT]; +bool sSoundBankDisabled[SOUND_BANK_COUNT]; struct ChannelVolumeScaleFade D_80192C48[SOUND_BANK_COUNT]; struct_D_80192CA8_entry D_80192CA8[3][5]; u8 D_80192CC6[3]; @@ -244,7 +245,7 @@ void audio_reset_session_eu(OSMesg presetId) { osRecvMesg(D_800EA3B4, &mesg, 0); osSendMesg(D_800EA3B0, presetId, 0); osRecvMesg(D_800EA3B4, &mesg, 1); - if (mesg != presetId) { + if (mesg.data32 != presetId.data32) { osRecvMesg(D_800EA3B4, &mesg, 1); } } @@ -931,7 +932,8 @@ void func_800C2A2C(u32 arg0) { break; case 15: D_800EA1C0 = (arg0 & 0xFF00) >> 8; - audio_reset_session_eu((void *) test); + // UTODO: Stubbed + // audio_reset_session_eu((void *) test); D_800EA1F4[0] = test; func_800CBBE8(0x46020000U, why); func_800C5C40(); @@ -963,14 +965,14 @@ u16 func_800C3508(u8 player) { } u8 func_800C357C(s32 arg0) { - u8 var_v1; + bool var_v1; u8 i; i = D_800EA1E8; - var_v1 = TRUE; + var_v1 = true; for(i = D_800EA1E8; i < (s32) D_800EA1E4; i++) { if ((u32) arg0 == D_80192CD0[i]) { - var_v1 = FALSE; + var_v1 = false; i = D_800EA1E4; } } @@ -1237,9 +1239,9 @@ void func_800C4084(u16 bankMask) { for (bank = 0; bank < SOUND_BANK_COUNT; bank++) { if (bankMask & 1) { - sSoundBankDisabled[bank] = TRUE; + sSoundBankDisabled[bank] = true; } else { - sSoundBankDisabled[bank] = FALSE; + sSoundBankDisabled[bank] = false; } bankMask = bankMask >> 1; } @@ -1258,7 +1260,7 @@ void play_sound(u32 soundBits, Vec3f *position, u8 cameraId, f32 *arg3, f32 *arg struct Sound *temp_v0; bank = soundBits >> 0x1C; - if (sSoundBankDisabled[bank] == FALSE) { + if (sSoundBankDisabled[bank] == false) { temp_v0 = &sSoundRequests[sSoundRequestCount]; temp_v0->soundBits = soundBits; temp_v0->position = position; @@ -1276,37 +1278,37 @@ void func_800C41CC(u8 arg0, struct SoundCharacteristics *arg1) { struct Sound *sound; for (soundId = sNumProcessedSoundRequests; soundId != sSoundRequestCount; soundId++) { - found = FALSE; + found = false; sound = &sSoundRequests[soundId]; switch (arg0) { case 0: if ((sound->soundBits & 0xF0000000) == (arg1->soundBits & 0xF0000000)) { - found = TRUE; + found = true; } break; case 1: if (((sound->soundBits & 0xF0000000) == (arg1->soundBits & 0xF0000000)) && (sound->position == arg1->unk00)) { - found = TRUE; + found = true; } break; case 2: if (sound->position == arg1->unk00) { - found = TRUE; + found = true; } break; case 3: if ((sound->position == arg1->unk00) && (sound->soundBits == arg1->soundBits)) { - found = TRUE; + found = true; } break; case 4: if ((sound->cameraId == arg1->cameraId) && (sound->soundBits == arg1->soundBits)) { - found = TRUE; + found = true; } break; case 5: if (sound->soundBits == arg1->soundBits) { - found = TRUE; + found = true; } break; } @@ -1806,7 +1808,7 @@ void sound_init(void) { sSoundBankUsedListBack[var_v0] = 0; sSoundBankFreeListFront[var_v0] = 1; sNumSoundsInBank[var_v0] = 0; - sSoundBankDisabled[var_v0] = FALSE; + sSoundBankDisabled[var_v0] = false; D_80192C48[var_v0].current = 1.0f; D_80192C48[var_v0].remainingFrames = 0; } diff --git a/src/audio/external.h b/src/audio/external.h index 6425b936a..42c8ab4c5 100644 --- a/src/audio/external.h +++ b/src/audio/external.h @@ -345,7 +345,7 @@ extern u8 sSoundBankFreeListFront[SOUND_BANK_COUNT]; extern u8 sNumSoundsInBank[SOUND_BANK_COUNT]; extern u8 D_80192AB8[SOUND_BANK_COUNT][8][8]; extern u8 D_80192C38; -extern u8 sSoundBankDisabled[SOUND_BANK_COUNT]; +extern bool sSoundBankDisabled[SOUND_BANK_COUNT]; extern struct ChannelVolumeScaleFade D_80192C48[SOUND_BANK_COUNT]; extern struct_D_80192CA8_entry D_80192CA8[3][5]; extern u8 D_80192CC6[3]; diff --git a/src/audio/heap.c b/src/audio/heap.c index 59eadb63b..53a104e06 100644 --- a/src/audio/heap.c +++ b/src/audio/heap.c @@ -1,4 +1,4 @@ -#include +#include #include #include "audio/data.h" @@ -126,8 +126,8 @@ void discard_bank(s32 bankId) { if (note->priority >= NOTE_PRIORITY_MIN) { // eu_stubbed_printf_3("Kill Voice %d (ID %d) %d\n", note->waveId, bankId, note->priority); // eu_stubbed_printf_0("Warning: Running Sequence's data disappear!\n"); - note->parentLayer->enabled = FALSE; // is 0x48, should be 0x44 - note->parentLayer->finished = TRUE; + note->parentLayer->enabled = false; // is 0x48, should be 0x44 + note->parentLayer->finished = true; } note_disable(note); audio_list_remove(¬e->listItem); @@ -380,7 +380,7 @@ void *alloc_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 size, s32 arg pool = &arg0->temporary.pool; if (tp->entries[tp->nextSide].id != (s8)-1) { table[tp->entries[tp->nextSide].id] = SOUND_LOAD_STATUS_NOT_LOADED; - if (isSound == TRUE) { + if (isSound == true) { discard_bank(tp->entries[tp->nextSide].id); } } diff --git a/src/audio/heap.h b/src/audio/heap.h index 6a8999396..533d598d1 100644 --- a/src/audio/heap.h +++ b/src/audio/heap.h @@ -1,7 +1,7 @@ #ifndef AUDIO_HEAP_H #define AUDIO_HEAP_H -#include +#include #include "internal.h" diff --git a/src/audio/internal.h b/src/audio/internal.h index 85ea368c9..ea67502fd 100644 --- a/src/audio/internal.h +++ b/src/audio/internal.h @@ -1,8 +1,8 @@ #ifndef AUDIO_INTERNAL_H #define AUDIO_INTERNAL_H -#include - +#include +#include "common_structs.h" #define SEQUENCE_PLAYERS 4 #define SEQUENCE_CHANNELS 48 @@ -226,7 +226,7 @@ struct SequencePlayer { /*0x11C, 0x124*/ OSIoMesg bankDmaIoMesg; /*0x130, 0x13C*/ u8 *bankDmaCurrMemAddr; /*0x138, 0x140*/ uintptr_t bankDmaCurrDevAddr; - /*0x13C, 0x144*/ ssize_t bankDmaRemaining; + /*0x13C, 0x144*/ size_t bankDmaRemaining; }; // size = 0x140, 0x148 on EU, 0x14C on SH struct AdsrSettings { diff --git a/src/audio/load.c b/src/audio/load.c index f6c60d17a..2c9e6fdfe 100644 --- a/src/audio/load.c +++ b/src/audio/load.c @@ -1,4 +1,4 @@ -#include +#include #include #include "audio/load.h" @@ -126,8 +126,8 @@ void audio_dma_copy_async(uintptr_t devAddr, void *vAddr, size_t nbytes, OSMesgQ * Performs a partial asynchronous (normal priority) DMA copy. This is limited * to 0x1000 bytes transfer at once. */ -void audio_dma_partial_copy_async(uintptr_t *devAddr, u8 **vAddr, ssize_t *remaining, OSMesgQueue *queue, OSIoMesg *mesg) { - ssize_t transfer = (*remaining >= 0x1000 ? 0x1000 : *remaining); +void audio_dma_partial_copy_async(uintptr_t *devAddr, u8 **vAddr, size_t *remaining, OSMesgQueue *queue, OSIoMesg *mesg) { + size_t transfer = (*remaining >= 0x1000 ? 0x1000 : *remaining); *remaining -= transfer; osInvalDCache(*vAddr, transfer); osPiStartDma(mesg, OS_MESG_PRI_NORMAL, OS_READ, *devAddr, *vAddr, transfer, queue); @@ -164,13 +164,13 @@ void decrease_sample_dma_ttls() { } void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *dmaIndexRef) { - s32 hasDma = FALSE; + s32 hasDma = false; struct SharedDma *dma; uintptr_t dmaDevAddr; u32 transfer; u32 i; u32 dmaIndex; - ssize_t bufferPos; + size_t bufferPos; UNUSED u32 pad; if (arg2 != 0 || *dmaIndexRef >= sSampleDmaListSize1) { @@ -199,7 +199,7 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *dmaIndexRef) { // TTL 60 is pretty large. dmaIndex = sSampleDmaReuseQueue2[sSampleDmaReuseQueueTail2++]; dma = &sSampleDmas[dmaIndex]; - hasDma = TRUE; + hasDma = true; } } else { dma = &sSampleDmas[*dmaIndexRef]; @@ -231,7 +231,7 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *dmaIndexRef) { // be empty, since TTL 2 is so small. dmaIndex = sSampleDmaReuseQueue1[sSampleDmaReuseQueueTail1++]; dma = &sSampleDmas[dmaIndex]; - hasDma = TRUE; + hasDma = true; } transfer = dma->bufSize; @@ -539,7 +539,7 @@ struct AudioBank *bank_load_async(s32 bankId, s32 arg1, struct SequencePlayer *s seqPlayer->bankDmaRemaining = alloc; if (1) { } osCreateMesgQueue(&seqPlayer->bankDmaMesgQueue, &seqPlayer->bankDmaMesg, 1); - seqPlayer->bankDmaInProgress = TRUE; + seqPlayer->bankDmaInProgress = true; audio_dma_partial_copy_async(&seqPlayer->bankDmaCurrDevAddr, &seqPlayer->bankDmaCurrMemAddr, &seqPlayer->bankDmaRemaining, &seqPlayer->bankDmaMesgQueue, &seqPlayer->bankDmaIoMesg); if (gBankLoadStatus[bankId] != 5) { gBankLoadStatus[bankId] = 1; @@ -590,7 +590,7 @@ void *sequence_dma_async(s32 seqId, s32 arg1, struct SequencePlayer *seqPlayer) audio_dma_copy_immediate(seqData, ptr, 0x00000040U); mesgQueue = &seqPlayer->seqDmaMesgQueue; osCreateMesgQueue(mesgQueue, &seqPlayer->seqDmaMesg, 1); - seqPlayer->seqDmaInProgress = TRUE; + seqPlayer->seqDmaInProgress = true; audio_dma_copy_async((uintptr_t) (seqData + 0x40), (u8*) ptr + 0x40, seqLength - 0x40, mesgQueue, &seqPlayer->seqDmaIoMesg); if (gSeqLoadStatus[seqId] != 5) { gSeqLoadStatus[seqId] = 1; @@ -612,7 +612,7 @@ u8 get_missing_bank(u32 seqId, s32 *nonNullCount, s32 *nullCount) { for (i = gAlBankSets[offset++], ret = 0; i != 0; i--) { bankId = gAlBankSets[offset++]; - if (IS_BANK_LOAD_COMPLETE(bankId) == TRUE) { + if (IS_BANK_LOAD_COMPLETE(bankId) == true) { temp = get_bank_or_seq(1, 2, bankId); } else { temp = NULL; @@ -639,7 +639,7 @@ struct AudioBank *load_banks_immediate(s32 seqId, u8 *outDefaultBank) { for (i = gAlBankSets[offset++]; i != 0; i--) { bankId = gAlBankSets[offset++]; - if (IS_BANK_LOAD_COMPLETE(bankId) == TRUE) { + if (IS_BANK_LOAD_COMPLETE(bankId) == true) { ret = get_bank_or_seq(1, 2, bankId); } else { ret = NULL; @@ -672,7 +672,7 @@ void preload_sequence(u32 seqId, u8 preloadMask) { if (preloadMask & PRELOAD_SEQUENCE) { //! @bug should be IS_SEQ_LOAD_COMPLETE - if (IS_BANK_LOAD_COMPLETE(seqId) == TRUE) { + if (IS_BANK_LOAD_COMPLETE(seqId) == true) { sequenceData = get_bank_or_seq(0, 2, seqId); } else { sequenceData = NULL; @@ -753,7 +753,7 @@ void load_sequence_internal(u32 player, u32 seqId, s32 loadAsync) { init_sequence_player(player); seqPlayer->scriptState.depth = 0; seqPlayer->delay = 0; - seqPlayer->enabled = TRUE; + seqPlayer->enabled = true; seqPlayer->seqData = sequenceData; seqPlayer->scriptState.pc = sequenceData; } @@ -796,7 +796,8 @@ void audio_init(void) { } #endif - switch (osTvType) { /* irregular */ + // UTODO: Which is the correct one? + switch (0) { /* irregular */ case 0: D_803B7178 = 20.03042f; gRefreshRate = 0x00000032; diff --git a/src/audio/load.h b/src/audio/load.h index 4feedf970..24523bd1b 100644 --- a/src/audio/load.h +++ b/src/audio/load.h @@ -1,8 +1,9 @@ #ifndef AUDIO_LOAD_H #define AUDIO_LOAD_H -#include +#include #include "audio/internal.h" +#include "PR/libaudio.h" #define AUDIO_FRAME_DMA_QUEUE_SIZE 0x40 @@ -23,7 +24,7 @@ struct SharedDma { void audio_dma_copy_immediate(u8* devAddr, void *vAddr, size_t nbytes); void audio_dma_copy_async(uintptr_t, void*, size_t, OSMesgQueue*, OSIoMesg*); -void audio_dma_partial_copy_async(uintptr_t*, u8**, ssize_t*, OSMesgQueue*, OSIoMesg*); +void audio_dma_partial_copy_async(uintptr_t*, u8**, size_t*, OSMesgQueue*, OSIoMesg*); void decrease_sample_dma_ttls(void); void *dma_sample_data(uintptr_t, u32, s32, u8*); void func_800BB030(s32); diff --git a/src/audio/playback.c b/src/audio/playback.c index 750f40873..6162c1f70 100644 --- a/src/audio/playback.c +++ b/src/audio/playback.c @@ -1,4 +1,4 @@ -#include +#include #include #include "audio/internal.h" @@ -28,26 +28,26 @@ void note_set_vel_pan_reverb(struct Note *note, f32 velocity, u8 pan, u8 reverbV sub->headsetPanLeft = gHeadsetPanQuantization[smallPanIndex]; sub->headsetPanRight = gHeadsetPanQuantization[ARRAY_COUNT(gHeadsetPanQuantization) - 1 - smallPanIndex]; - sub->stereoStrongRight = FALSE; - sub->stereoStrongLeft = FALSE; - sub->usesHeadsetPanEffects = TRUE; + sub->stereoStrongRight = false; + sub->stereoStrongLeft = false; + sub->usesHeadsetPanEffects = true; volLeft = gHeadsetPanVolume[pan]; volRight = gHeadsetPanVolume[127 - pan]; } else if (sub->stereoHeadsetEffects && gAudioLibSoundMode == SOUND_MODE_STEREO) { - strongRight = FALSE; - strongLeft = FALSE; + strongRight = false; + strongLeft = false; sub->headsetPanRight = 0; sub->headsetPanLeft = 0; - sub->usesHeadsetPanEffects = FALSE; + sub->usesHeadsetPanEffects = false; volLeft = gStereoPanVolume[pan]; volRight = gStereoPanVolume[127 - pan]; if (pan < 0x20) { - strongLeft = TRUE; + strongLeft = true; } else if (pan > 0x60) { - strongRight = TRUE; + strongRight = true; } sub->stereoStrongRight = strongRight; @@ -76,14 +76,14 @@ void note_set_vel_pan_reverb(struct Note *note, f32 velocity, u8 pan, u8 reverbV //! @bug for the change to UQ0.7, the if statement should also have been changed accordingly if (sub->reverbVol != reverbVol) { sub->reverbVol = reverbVol; - sub->envMixerNeedsInit = TRUE; + sub->envMixerNeedsInit = true; return; } if (sub->needsInit) { - sub->envMixerNeedsInit = TRUE; + sub->envMixerNeedsInit = true; } else { - sub->envMixerNeedsInit = FALSE; + sub->envMixerNeedsInit = false; } } @@ -130,7 +130,7 @@ struct AudioBankSound *instrument_get_audio_bank_sound(struct Instrument *instru struct Instrument *get_instrument_inner(s32 bankId, s32 instId) { struct Instrument *inst; - if (IS_BANK_LOAD_COMPLETE(bankId) == FALSE) { + if (IS_BANK_LOAD_COMPLETE(bankId) == false) { stubbed_printf("Audio: voiceman: No bank error %d\n", bankId); gAudioErrorFlags = bankId + 0x10000000; return NULL; @@ -155,7 +155,7 @@ struct Instrument *get_instrument_inner(s32 bankId, s32 instId) { struct Drum *get_drum(s32 bankId, s32 drumId) { struct Drum *drum; - if (IS_BANK_LOAD_COMPLETE(bankId) == FALSE) { + if (IS_BANK_LOAD_COMPLETE(bankId) == false) { stubbed_printf("Audio: voiceman: No bank error %d\n", bankId); gAudioErrorFlags = bankId + 0x10000000; return NULL; @@ -196,16 +196,16 @@ void note_init(struct Note *note) { } void note_disable(struct Note *note) { - if (note->noteSubEu.needsInit == TRUE) { - note->noteSubEu.needsInit = FALSE; + if (note->noteSubEu.needsInit == true) { + note->noteSubEu.needsInit = false; } else { note_set_vel_pan_reverb(note, 0, 0x40, 0); } note->priority = NOTE_PRIORITY_DISABLED; note->parentLayer = NO_LAYER; note->prevParentLayer = NO_LAYER; - note->noteSubEu.enabled = FALSE; - note->noteSubEu.finished = FALSE; + note->noteSubEu.enabled = false; + note->noteSubEu.finished = false; } void process_notes(void) { @@ -625,7 +625,7 @@ void note_init_for_layer(struct Note *note, struct SequenceChannelLayer *seqLaye note->prevParentLayer = NO_LAYER; note->parentLayer = seqLayer; note->priority = seqLayer->seqChannel->notePriority; - seqLayer->notePropertiesNeedInit = TRUE; + seqLayer->notePropertiesNeedInit = true; seqLayer->status = SOUND_LOAD_STATUS_DISCARDABLE; // "loaded" seqLayer->note = note; seqLayer->seqChannel->noteUnused = note; @@ -639,9 +639,9 @@ void note_init_for_layer(struct Note *note, struct SequenceChannelLayer *seqLaye sub->sound.audioBankSound = seqLayer->sound; if (instId >= 0x80) { - sub->isSyntheticWave = TRUE; + sub->isSyntheticWave = true; } else { - sub->isSyntheticWave = FALSE; + sub->isSyntheticWave = false; } if (sub->isSyntheticWave) { @@ -693,7 +693,7 @@ struct Note *alloc_note_from_active(struct NotePool *pool, struct SequenceChanne func_800BD8F4(aNote, seqLayer); audio_list_push_back(&pool->releasing, &aNote->listItem); } - + return aNote; } @@ -781,7 +781,7 @@ void note_init_all(void) { note->adsrVolScale = 0; note->adsr.state = ADSR_STATE_DISABLED; note->adsr.action = 0; - note->vibratoState.active = FALSE; + note->vibratoState.active = false; note->portamento.cur = 0.0f; note->portamento.speed = 0.0f; // This only works if NoteSynthesisBuffers are size 0xA0. See internal.h diff --git a/src/audio/playback.h b/src/audio/playback.h index e33422fe6..2c25be714 100644 --- a/src/audio/playback.h +++ b/src/audio/playback.h @@ -1,7 +1,7 @@ #ifndef AUDIO_PLAYBACK_H #define AUDIO_PLAYBACK_H -#include +#include #include "internal.h" diff --git a/src/audio/port_eu.c b/src/audio/port_eu.c index e5b3c7e01..eeb8e983c 100644 --- a/src/audio/port_eu.c +++ b/src/audio/port_eu.c @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -168,7 +168,7 @@ void eu_process_audio_cmd(struct EuAudioCmd *cmd) { break; case 0x83: - if (gSequencePlayers[cmd->u.s.bankId].enabled != FALSE) { + if (gSequencePlayers[cmd->u.s.bankId].enabled != false) { if (cmd->u2.as_s32 == 0) { sequence_player_disable(&gSequencePlayers[cmd->u.s.bankId]); } @@ -184,15 +184,15 @@ void eu_process_audio_cmd(struct EuAudioCmd *cmd) { case 0xf1: for (i = 0; i < 4; i++) { - gSequencePlayers[i].muted = TRUE; - gSequencePlayers[i].recalculateVolume = TRUE; + gSequencePlayers[i].muted = true; + gSequencePlayers[i].recalculateVolume = true; } break; case 0xf2: for (i = 0; i < 4; i++) { - gSequencePlayers[i].muted = FALSE; - gSequencePlayers[i].recalculateVolume = TRUE; + gSequencePlayers[i].muted = false; + gSequencePlayers[i].recalculateVolume = true; } break; case 0xF3: @@ -297,7 +297,7 @@ void func_800CBCB0(u32 arg0) { switch (cmd->u.s.op) { case 0x41: seqPlayer->fadeVolumeScale = cmd->u2.as_f32; - seqPlayer->recalculateVolume = TRUE; + seqPlayer->recalculateVolume = true; break; case 0x47: @@ -313,25 +313,25 @@ void func_800CBCB0(u32 arg0) { break; } } - else if (seqPlayer->enabled != FALSE && cmd->u.s.arg2 < 0x10) { + else if (seqPlayer->enabled != false && cmd->u.s.arg2 < 0x10) { chan = seqPlayer->channels[cmd->u.s.arg2]; if (IS_SEQUENCE_CHANNEL_VALID(chan)) { switch (cmd->u.s.op) { case 1: chan->volumeScale = cmd->u2.as_f32; - chan->changes.as_bitfields.volume = TRUE; + chan->changes.as_bitfields.volume = true; break; case 2: chan->volume = cmd->u2.as_f32; - chan->changes.as_bitfields.volume = TRUE; + chan->changes.as_bitfields.volume = true; break; case 3: chan->newPan = cmd->u2.as_s8; - chan->changes.as_bitfields.pan = TRUE; + chan->changes.as_bitfields.pan = true; break; case 4: chan->freqScale = cmd->u2.as_f32; - chan->changes.as_bitfields.freqScale = TRUE; + chan->changes.as_bitfields.freqScale = true; break; case 5: chan->reverbVol = cmd->u2.as_s8; diff --git a/src/audio/seqplayer.c b/src/audio/seqplayer.c index 131c32984..6aca09dcf 100644 --- a/src/audio/seqplayer.c +++ b/src/audio/seqplayer.c @@ -1,4 +1,4 @@ -#include +#include #include #include "audio/data.h" @@ -52,14 +52,14 @@ char seqplayer_unused_string25[] = "Group:Undefined Command\n"; void sequence_channel_init(struct SequenceChannel *seqChannel) { s32 i; - seqChannel->enabled = FALSE; - seqChannel->finished = FALSE; - seqChannel->stopScript = FALSE; - seqChannel->stopSomething2 = FALSE; - seqChannel->hasInstrument = FALSE; - seqChannel->stereoHeadsetEffects = FALSE; + seqChannel->enabled = false; + seqChannel->finished = false; + seqChannel->stopScript = false; + seqChannel->stopSomething2 = false; + seqChannel->hasInstrument = false; + seqChannel->stereoHeadsetEffects = false; seqChannel->transposition = 0; - seqChannel->largeNotes = FALSE; + seqChannel->largeNotes = false; seqChannel->bookOffset = 0; seqChannel->changes.as_u8 = 0xff; seqChannel->scriptState.depth = 0; @@ -86,7 +86,7 @@ void sequence_channel_init(struct SequenceChannel *seqChannel) { for (i = 0; i < 8; i++) { seqChannel->soundScriptIO[i] = -1; } - seqChannel->unused = FALSE; + seqChannel->unused = false; init_note_lists(&seqChannel->notePool); } @@ -109,11 +109,11 @@ s32 seq_channel_set_layer(struct SequenceChannel *seqChannel, s32 layerIndex) { layer->seqChannel = seqChannel; layer->adsr = seqChannel->adsr; layer->adsr.releaseRate = 0; - layer->enabled = TRUE; - layer->stopSomething = FALSE; - layer->continuousNotes = FALSE; - layer->finished = FALSE; - layer->ignoreDrumPan = FALSE; + layer->enabled = true; + layer->stopSomething = false; + layer->continuousNotes = false; + layer->finished = false; + layer->ignoreDrumPan = false; layer->portamento.mode = 0; layer->scriptState.depth = 0; layer->status = SOUND_LOAD_STATUS_NOT_LOADED; @@ -134,8 +134,8 @@ s32 seq_channel_set_layer(struct SequenceChannel *seqChannel, s32 layerIndex) { void seq_channel_layer_disable(struct SequenceChannelLayer *layer) { if (layer != NULL) { seq_channel_layer_note_decay(layer); - layer->enabled = FALSE; - layer->finished = TRUE; + layer->enabled = false; + layer->finished = true; } } @@ -156,8 +156,8 @@ void sequence_channel_disable(struct SequenceChannel *seqChannel) { } note_pool_clear(&seqChannel->notePool); - seqChannel->enabled = FALSE; - seqChannel->finished = TRUE; + seqChannel->enabled = false; + seqChannel->finished = true; } struct SequenceChannel *allocate_sequence_channel(void) { @@ -177,12 +177,12 @@ void sequence_player_init_channels(struct SequencePlayer *seqPlayer, u16 channel for (i = 0; i < CHANNELS_MAX; i++) { if (channelBits & 1) { seqChannel = seqPlayer->channels[i]; - if (IS_SEQUENCE_CHANNEL_VALID(seqChannel) == TRUE && seqChannel->seqPlayer == seqPlayer) { + if (IS_SEQUENCE_CHANNEL_VALID(seqChannel) == true && seqChannel->seqPlayer == seqPlayer) { sequence_channel_disable(seqChannel); seqChannel->seqPlayer = NULL; } seqChannel = allocate_sequence_channel(); - if (IS_SEQUENCE_CHANNEL_VALID(seqChannel) == FALSE) { + if (IS_SEQUENCE_CHANNEL_VALID(seqChannel) == false) { //eu_stubbed_printf_0("Audio:Track:Warning: No Free Notetrack\n"); gAudioErrorFlags = i + 0x10000; seqPlayer->channels[i] = seqChannel; @@ -207,7 +207,7 @@ void sequence_player_disable_channels(struct SequencePlayer *seqPlayer, u16 chan for (i = 0; i < CHANNELS_MAX; i++) { if (channelBits & 1) { seqChannel = seqPlayer->channels[i]; - if (IS_SEQUENCE_CHANNEL_VALID(seqChannel) == TRUE) { + if (IS_SEQUENCE_CHANNEL_VALID(seqChannel) == true) { if (seqChannel->seqPlayer == seqPlayer) { sequence_channel_disable(seqChannel); seqChannel->seqPlayer = NULL; @@ -225,12 +225,12 @@ void sequence_player_disable_channels(struct SequencePlayer *seqPlayer, u16 chan void sequence_channel_enable(struct SequencePlayer *seqPlayer, u8 channelIndex, void *script) { struct SequenceChannel *seqChannel = seqPlayer->channels[channelIndex]; s32 i; - if (IS_SEQUENCE_CHANNEL_VALID(seqChannel) == FALSE) { + if (IS_SEQUENCE_CHANNEL_VALID(seqChannel) == false) { //stubbed_printf("SEQID %d,BANKID %d\n", seqPlayer->seqId, seqPlayer->defaultBank[0]); //stubbed_printf("ERR:SUBTRACK %d NOT ALLOCATED\n", channelIndex); } else { - seqChannel->enabled = TRUE; - seqChannel->finished = FALSE; + seqChannel->enabled = true; + seqChannel->finished = false; seqChannel->scriptState.depth = 0; seqChannel->scriptState.pc = script; seqChannel->delay = 0; @@ -245,8 +245,8 @@ void sequence_channel_enable(struct SequencePlayer *seqPlayer, u8 channelIndex, void sequence_player_disable(struct SequencePlayer *seqPlayer) { sequence_player_disable_channels(seqPlayer, 0xffff); note_pool_clear(&seqPlayer->notePool); - seqPlayer->finished = TRUE; - seqPlayer->enabled = FALSE; + seqPlayer->finished = true; + seqPlayer->enabled = false; if (IS_SEQ_LOAD_COMPLETE(seqPlayer->seqId) && gSeqLoadStatus[seqPlayer->seqId] != 5) { gSeqLoadStatus[seqPlayer->seqId] = SOUND_LOAD_STATUS_DISCARDABLE; @@ -347,8 +347,8 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { f32 temp_f12; f32 temp_f2; - sameSound = TRUE; - if (layer->enabled == FALSE) { + sameSound = true; + if (layer->enabled == false) { return; } @@ -356,7 +356,7 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { layer->delay--; if (!layer->stopSomething && layer->delay <= layer->duration) { seq_channel_layer_note_decay(layer); - layer->stopSomething = TRUE; + layer->stopSomething = true; } return; } @@ -379,7 +379,7 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { seqChannel = layer->seqChannel; seqPlayer = seqChannel->seqPlayer; - layer->notePropertiesNeedInit = TRUE; + layer->notePropertiesNeedInit = true; for (;;) { state = &layer->scriptState; @@ -455,9 +455,9 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { case 0xc4: // layer_somethingon case 0xc5: // layer_somethingoff if (cmd == 0xc4) { - layer->continuousNotes = TRUE; + layer->continuousNotes = true; } else { - layer->continuousNotes = FALSE; + layer->continuousNotes = false; } seq_channel_layer_note_decay(layer); break; @@ -525,7 +525,7 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { break; case 0xcc: - layer->ignoreDrumPan = TRUE; + layer->ignoreDrumPan = true; break; default: @@ -545,11 +545,11 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { if (cmd == 0xc0) { // layer_delay layer->delay = m64_read_compressed_u16(state); - layer->stopSomething = TRUE; + layer->stopSomething = true; } else { - layer->stopSomething = FALSE; + layer->stopSomething = false; - if (seqChannel->largeNotes == TRUE) { + if (seqChannel->largeNotes == true) { switch (cmd & 0xc0) { case 0x00: // layer_note0 (play percentage, velocity, duration) sp3A = m64_read_compressed_u16(state); @@ -602,7 +602,7 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { if ((seqPlayer->muted && (seqChannel->muteBehavior & MUTE_BEHAVIOR_STOP_NOTES) != 0) || seqChannel->stopSomething2 ) { - layer->stopSomething = TRUE; + layer->stopSomething = true; } else { s32 temp = layer->instOrWave; @@ -617,7 +617,7 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { drum = get_drum(seqChannel->bankId, cmd); if (drum == NULL) { - layer->stopSomething = TRUE; + layer->stopSomething = true; layer->delayUnused = layer->delay; return; } else { @@ -634,7 +634,7 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { cmd += seqPlayer->transposition + seqChannel->transposition + layer->transposition; if (cmd >= 0x80) { - layer->stopSomething = TRUE; + layer->stopSomething = true; } else { if (layer->instOrWave == 0xffu) { instrument = seqChannel->instrument; @@ -706,30 +706,30 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { } } - if (layer->stopSomething == TRUE) { + if (layer->stopSomething == true) { if (layer->note != NULL || layer->continuousNotes) { seq_channel_layer_note_decay(layer); } return; } - cmd = FALSE; + cmd = false; if (!layer->continuousNotes) { - cmd = TRUE; + cmd = true; } else if (layer->note == NULL || layer->status == SOUND_LOAD_STATUS_NOT_LOADED) { - cmd = TRUE; - } else if (sameSound == FALSE) { + cmd = true; + } else if (sameSound == false) { seq_channel_layer_note_decay(layer); - cmd = TRUE; + cmd = true; } else if (layer != layer->note->parentLayer) { - cmd = TRUE; + cmd = true; } else if (layer->sound == NULL) { init_synthetic_wave(layer->note, layer); } - if (cmd != FALSE) { + if (cmd != false) { layer->note = alloc_note(layer); } @@ -764,11 +764,11 @@ void set_instrument(struct SequenceChannel *seqChannel, u8 instId) { } else { if ((seqChannel->instOrWave = get_instrument(seqChannel, instId, &seqChannel->instrument, &seqChannel->adsr)) == 0) { - seqChannel->hasInstrument = FALSE; + seqChannel->hasInstrument = false; return; } } - seqChannel->hasInstrument = TRUE; + seqChannel->hasInstrument = true; } void sequence_channel_set_volume(struct SequenceChannel *seqChannel, u8 volume) { @@ -1215,16 +1215,16 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer) { struct M64ScriptState *state; s32 temp32; - if (seqPlayer->enabled == FALSE) { + if (seqPlayer->enabled == false) { return; } - if (seqPlayer->bankDmaInProgress == TRUE) { + if (seqPlayer->bankDmaInProgress == true) { if (osRecvMesg(&seqPlayer->bankDmaMesgQueue, NULL, 0) == -1) { return; } if (seqPlayer->bankDmaRemaining == 0) { - seqPlayer->bankDmaInProgress = FALSE; + seqPlayer->bankDmaInProgress = false; func_800BB584(seqPlayer->loadingBankId); if (gBankLoadStatus[seqPlayer->loadingBankId] != 5) { gBankLoadStatus[seqPlayer->loadingBankId] = 2; @@ -1237,11 +1237,11 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer) { return; } - if (seqPlayer->seqDmaInProgress == TRUE) { + if (seqPlayer->seqDmaInProgress == true) { if (osRecvMesg(&seqPlayer->seqDmaMesgQueue, NULL, 0) == -1) { return; } - seqPlayer->seqDmaInProgress = FALSE; + seqPlayer->seqDmaInProgress = false; if (gSeqLoadStatus[seqPlayer->seqId] != 5) { gSeqLoadStatus[seqPlayer->seqId] = 2; } @@ -1249,9 +1249,9 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer) { // If discarded, bail out. temp32 = 2; // I beg your pardon? - if (IS_SEQ_LOAD_COMPLETE(seqPlayer->seqId) == FALSE + if (IS_SEQ_LOAD_COMPLETE(seqPlayer->seqId) == false || ( - IS_BANK_LOAD_COMPLETE(seqPlayer->defaultBank[0]) == FALSE)) { + IS_BANK_LOAD_COMPLETE(seqPlayer->defaultBank[0]) == false)) { sequence_player_disable(seqPlayer); return; } @@ -1457,7 +1457,7 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer) { break; case 0xd4: // seq_mute - seqPlayer->muted = TRUE; + seqPlayer->muted = true; break; case 0xd3: // seq_setmutebhv @@ -1534,7 +1534,7 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer) { } for (i = 0; i < CHANNELS_MAX; i++) { - if (IS_SEQUENCE_CHANNEL_VALID(seqPlayer->channels[i]) == TRUE) { + if (IS_SEQUENCE_CHANNEL_VALID(seqPlayer->channels[i]) == true) { sequence_channel_process_script(seqPlayer->channels[i]); } } @@ -1543,7 +1543,7 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer) { void process_sequences(UNUSED s32 iterationsRemaining) { s32 i; for (i = 0; i < SEQUENCE_PLAYERS; i++) { - if (gSequencePlayers[i].enabled == TRUE) { + if (gSequencePlayers[i].enabled == true) { sequence_player_process_sequence(&gSequencePlayers[i]); sequence_player_process_sound(&gSequencePlayers[i]); } @@ -1577,7 +1577,7 @@ void init_sequence_players(void) { for (i = 0; i < ARRAY_COUNT(gSequenceChannels); i++) { gSequenceChannels[i].seqPlayer = NULL; - gSequenceChannels[i].enabled = FALSE; + gSequenceChannels[i].enabled = false; /** * @bug Size of wrong array. Zeroes out second half of gSequenceChannels[0], * all of gSequenceChannels[1..31], and part of gSequenceLayers[0]. @@ -1597,7 +1597,7 @@ void init_sequence_players(void) { for (i = 0; i < ARRAY_COUNT(gSequenceLayers); i++) { gSequenceLayers[i].seqChannel = NULL; - gSequenceLayers[i].enabled = FALSE; + gSequenceLayers[i].enabled = false; } for (i = 0; i < SEQUENCE_PLAYERS; i++) { @@ -1607,10 +1607,10 @@ void init_sequence_players(void) { gSequencePlayers[i].seqVariationEu[0] = -1; gSequencePlayers[i].muteBehavior = MUTE_BEHAVIOR_STOP_SCRIPT | MUTE_BEHAVIOR_STOP_NOTES | MUTE_BEHAVIOR_SOFTEN; - gSequencePlayers[i].enabled = FALSE; - gSequencePlayers[i].muted = FALSE; - gSequencePlayers[i].bankDmaInProgress = FALSE; - gSequencePlayers[i].seqDmaInProgress = FALSE; + gSequencePlayers[i].enabled = false; + gSequencePlayers[i].muted = false; + gSequencePlayers[i].bankDmaInProgress = false; + gSequencePlayers[i].seqDmaInProgress = false; init_note_lists(&gSequencePlayers[i].notePool); init_sequence_player(i); } diff --git a/src/audio/seqplayer.h b/src/audio/seqplayer.h index dc8cbe995..8c95a60d5 100644 --- a/src/audio/seqplayer.h +++ b/src/audio/seqplayer.h @@ -1,7 +1,7 @@ #ifndef AUDIO_SEQPLAYER_H #define AUDIO_SEQPLAYER_H -#include +#include #include "audio/internal.h" diff --git a/src/audio/synthesis.c b/src/audio/synthesis.c index c6e3e5360..f808e359c 100644 --- a/src/audio/synthesis.c +++ b/src/audio/synthesis.c @@ -1,4 +1,4 @@ -#include +#include #include #include "audio/synthesis.h" #include "audio/heap.h" @@ -7,7 +7,7 @@ #include "audio/seqplayer.h" #include "audio/internal.h" //#include "audio/external.h" -#include "PR/abi.h" +#include #define aSetLoadBufferPair(pkt, c, off) \ aSetBuffer(pkt, 0, c + DMEM_ADDR_WET_LEFT_CH, 0, DEFAULT_LEN_1CH - c); \ @@ -127,7 +127,7 @@ void func_800B6FB4(s32 updateIndexStart, s32 noteIndex) { for (i = updateIndexStart + 1; i < gAudioBufferParameters.updatesPerFrame; i++) { if (!gNoteSubsEu[gMaxSimultaneousNotes * i + noteIndex].needsInit) { - gNoteSubsEu[gMaxSimultaneousNotes * i + noteIndex].enabled = FALSE; + gNoteSubsEu[gMaxSimultaneousNotes * i + noteIndex].enabled = false; } else { break; } @@ -144,9 +144,9 @@ void synthesis_load_note_subs_eu(s32 updateIndex) { dest = &gNoteSubsEu[gMaxSimultaneousNotes * updateIndex + i]; if (src->enabled) { *dest = *src; - src->needsInit = FALSE; + src->needsInit = false; } else { - dest->enabled = FALSE; + dest->enabled = false; } } } @@ -161,7 +161,8 @@ Acmd *synthesis_execute(Acmd *acmd, s32 *writtenCmds, s16 *aiBuf, s32 bufLen) { process_sequences(i - 1); synthesis_load_note_subs_eu(gAudioBufferParameters.updatesPerFrame - i); } - aSegment(cmd++, 0, 0); + // UTODO: Stubbed + // aSegment(cmd++, 0, 0); aiBufPtr = (u32 *) aiBuf; for (i = gAudioBufferParameters.updatesPerFrame; i > 0; i--) { if (i == 1) { @@ -307,7 +308,7 @@ Acmd *synthesis_do_one_audio_update(s16 *aiBuf, s32 bufLen, Acmd *acmd, s32 upda } for (; i < notePos; i++) { temp = updateIndex * gMaxSimultaneousNotes; - if (IS_BANK_LOAD_COMPLETE(gNoteSubsEu[temp + noteIndices[i]].bankId) == TRUE) { + if (IS_BANK_LOAD_COMPLETE(gNoteSubsEu[temp + noteIndices[i]].bankId)) { acmd = synthesis_process_note(noteIndices[i], &gNoteSubsEu[temp + noteIndices[i]], &gNotes[noteIndices[i]].synthesisState, @@ -319,7 +320,8 @@ Acmd *synthesis_do_one_audio_update(s16 *aiBuf, s32 bufLen, Acmd *acmd, s32 upda temp = bufLen * 2; aSetBuffer(acmd++, 0, 0, DMEM_ADDR_TEMP, temp); - aInterleave(acmd++, DMEM_ADDR_LEFT_CH, DMEM_ADDR_RIGHT_CH); + // UTODO: Stubbed + // aInterleave(acmd++, DMEM_ADDR_LEFT_CH, DMEM_ADDR_RIGHT_CH); aSaveBuffer(acmd++, DMEM_ADDR_TEMP, VIRTUAL_TO_PHYSICAL2(aiBuf), temp * 2); return acmd; } @@ -603,14 +605,16 @@ GLOBAL_ASM("asm/non_matchings/audio/synthesis/synthesis_process_note.s") Acmd *load_wave_samples(Acmd *acmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s32 nSamplesToLoad) { s32 a3; s32 repeats; - aLoadBuffer(acmd++, VIRTUAL_TO_PHYSICAL2(noteSubEu->sound.samples), 0x1A0, 128); + // UTODO: Stubbed + // aLoadBuffer(acmd++, VIRTUAL_TO_PHYSICAL2(noteSubEu->sound.samples), 0x1A0, 128); synthesisState->samplePosInt &= 0x3f; a3 = 64 - synthesisState->samplePosInt; if (a3 < nSamplesToLoad) { repeats = (nSamplesToLoad - a3 + 63) / 64; if (repeats != 0) { - aDMEMMove2(acmd++, repeats, 0x1A0, 0x1A0 + 128, 128); + // UTODO: Stubbed + // aDMEMMove2(acmd++, repeats, 0x1A0, 0x1A0 + 128, 128); } } return acmd; diff --git a/src/audio/synthesis.h b/src/audio/synthesis.h index a1854442b..59f6bd43f 100644 --- a/src/audio/synthesis.h +++ b/src/audio/synthesis.h @@ -2,7 +2,7 @@ #define AUDIO_SYNTHESIS_H #include "audio/internal.h" -#include "PR/abi.h" +#include #define DEFAULT_LEN_1CH 0x180 #define DEFAULT_LEN_2CH 0x300 diff --git a/src/buffers.h b/src/buffers.h index 13584036d..66f58ad1a 100644 --- a/src/buffers.h +++ b/src/buffers.h @@ -1,7 +1,7 @@ #ifndef BUFFERS_H #define BUFFERS_H -#include +#include #include #include "common_structs.h" @@ -52,7 +52,7 @@ typedef struct { * Appears to be a combination of 2 different palettes: * kart_palette contains the palette for all non-wheel elements of the kart (including the driver). * wheel_palette contains the palette for the wheels. - * + * * kart palette sets a defined palette based on the character while * wheels palette sets a dynamic palette as you drive around with the kart. * @@ -74,7 +74,7 @@ extern struct_D_802DFB80 D_802DFB80[][2][8]; /** * It would be nice to define D_802F1F80 as "struct_D_802F1F80 D_802F1F80[2][4][8]". - * But due to register allocation issues in load_kart_palette / func_80026B4C + * But due to register allocation issues in load_kart_palette / func_80026B4C * we have to define it in a different manner to match those functions. * If AVOID_UB is defined, the struct is properly defined with their correct pointers. **/ diff --git a/src/buffers/buffers.c b/src/buffers/buffers.c index cc08aa60a..1218438a9 100644 --- a/src/buffers/buffers.c +++ b/src/buffers/buffers.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include "buffers.h" diff --git a/src/buffers/gfx_output_buffer.c b/src/buffers/gfx_output_buffer.c index 0a699180c..355ffdd55 100644 --- a/src/buffers/gfx_output_buffer.c +++ b/src/buffers/gfx_output_buffer.c @@ -1,4 +1,4 @@ -#include +#include #include #include "gfx_output_buffer.h" diff --git a/src/buffers/gfx_output_buffer.h b/src/buffers/gfx_output_buffer.h index 5336b65ad..f3637b7df 100644 --- a/src/buffers/gfx_output_buffer.h +++ b/src/buffers/gfx_output_buffer.h @@ -1,7 +1,7 @@ #ifndef GFX_OUTPUT_BUFFER_H #define GFX_OUTPUT_BUFFER_H -#include +#include // 0x1f000 bytes, aligned to a 0x1000-byte boundary through sm64.ld. (This results // in a bunch of unused space: ~0x100 in JP, ~0x300 in US.) diff --git a/src/buffers/memory_pool.c b/src/buffers/memory_pool.c index d7dee6cc9..5b401d83f 100644 --- a/src/buffers/memory_pool.c +++ b/src/buffers/memory_pool.c @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/src/buffers/random.h b/src/buffers/random.h index bb7aefa8b..d0443e200 100644 --- a/src/buffers/random.h +++ b/src/buffers/random.h @@ -1,7 +1,7 @@ #ifndef RANDOM_H #define RANDOM_H -#include +#include extern u16 gRandomSeed16; extern u8 randomSeedPadding[]; diff --git a/src/buffers/trig_tables.c b/src/buffers/trig_tables.c index 22c61be30..d95b50189 100644 --- a/src/buffers/trig_tables.c +++ b/src/buffers/trig_tables.c @@ -1,4 +1,4 @@ -#include +#include #include f32 gSineTable[] = { diff --git a/src/buffers/trig_tables_bss.c b/src/buffers/trig_tables_bss.c index aa2bc38d1..6caec65c2 100644 --- a/src/buffers/trig_tables_bss.c +++ b/src/buffers/trig_tables_bss.c @@ -1,4 +1,4 @@ -#include +#include #include /** diff --git a/src/camera.c b/src/camera.c index 0ff40d9be..e82303eb1 100644 --- a/src/camera.c +++ b/src/camera.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/src/code_800029B0.c b/src/code_800029B0.c index c55bcc712..d4c3c8747 100644 --- a/src/code_800029B0.c +++ b/src/code_800029B0.c @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/src/code_800029B0.h b/src/code_800029B0.h index 40376ff2e..ccf20c8e5 100644 --- a/src/code_800029B0.h +++ b/src/code_800029B0.h @@ -2,7 +2,7 @@ #define CODE_800029B0_H #include -#include +#include #include #include "camera.h" diff --git a/src/code_80004740.c b/src/code_80004740.c index a863eac74..094305e83 100644 --- a/src/code_80004740.c +++ b/src/code_80004740.c @@ -1,11 +1,11 @@ -#include +#include #include #include #include "math_util.h" #include "code_80004740.h" #include "memory.h" #include -#include +#include #include "code_80057C60.h" Vec3s D_80162D70; @@ -91,7 +91,7 @@ void func_80004A1C(animation_type_1 *arg0, s16 *arg1, animation_type_3_triplet a } sp8C[someIndex] = arg1[arg2[someIndex].some_offset + some_offset]; } - + mtxf_translate_rotate2(sp4C, sp94, sp8C); func_80004740(&gGfxPool->mtxHud[gMatrixHudCount], sp4C); D_80162D7A += 1; @@ -172,6 +172,6 @@ s16 func_80004DFC(animation_type_1 *arg0, animation_type_2 **arg1, s16 arg2, s16 s16 func_80004EAC(void *addr, s16 offset) { uintptr_t *item = segmented_to_virtual(addr); struct stru_80004EAC *temp = (struct stru_80004EAC *) segmented_to_virtual((void *) item[offset]); - + return temp->unk8 - 1; } diff --git a/src/code_80005FD0.c b/src/code_80005FD0.c index 060832135..731e0683e 100644 --- a/src/code_80005FD0.c +++ b/src/code_80005FD0.c @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -1191,19 +1191,19 @@ s32 func_800088D8(s32 playerId, s16 arg1, s16 arg2) { D_80163128[playerId] = -1; D_80163150[playerId] = -1; if (gModeSelection == 1) { - return TRUE; + return true; } if (arg1 < 0) { - return TRUE; + return true; } else if (arg1 >= 4) { arg1 = 3; } if (D_80163330[playerId] == 1) { - return TRUE; + return true; } player = &gPlayers[playerId]; if (player->type & 0x4000) { - return TRUE; + return true; } arg1_times_8 = arg1 * 8; temp_a3 = &D_800DCBB4[gCurrentCourseId][arg1_times_8]; @@ -1220,9 +1220,9 @@ s32 func_800088D8(s32 playerId, s16 arg1, s16 arg2) { D_80163150[playerId] = temp_a3[0]; } if (D_80163150[playerId] < temp_a2 && player->unk_094 / 18.0f * 216.0f >= 20.0f) { - return FALSE; + return false; } - return TRUE; + return true; } progress = D_80164450[playerId] - D_80164450[D_80163478]; rank = gGPCurrentRaceRankByPlayerId[2 + (D_80163478 * 4)]; @@ -1240,9 +1240,9 @@ s32 func_800088D8(s32 playerId, s16 arg1, s16 arg2) { } D_80163150[playerId] = (gCCSelection + 1) * var_a0_2; if (D_80163150[playerId] < progress && player->unk_094 / 18.0f * 216.0f >= 20.0f) { - return FALSE; + return false; } - return TRUE; + return true; } else { var_a1_4 = D_80164450[(s16) *D_80163344] - D_80164450[playerId]; if (var_a1_4 < 0) { @@ -1266,7 +1266,7 @@ s32 func_800088D8(s32 playerId, s16 arg1, s16 arg2) { } D_80164538[playerId] = var_t1; if (var_t1 < 0 || var_t1 >= 8) { - return FALSE; + return false; } if (arg1_times_8 < 24) { temp_a3 = &temp_a3[var_t1]; @@ -1277,9 +1277,9 @@ s32 func_800088D8(s32 playerId, s16 arg1, s16 arg2) { } D_80163128[playerId] = var_a1_4; if (D_80163150[playerId] < var_a1_4) { - return TRUE; + return true; } - return FALSE; + return false; } } #else @@ -2204,22 +2204,22 @@ void func_8000BBD8(u16 waypointIndex, f32 arg1, s16 pathIndex) { path1 = &D_80164560[pathIndex][waypointIndex]; path2 = &D_80164570[pathIndex][waypointIndex]; - + x1 = (f32) path1->posX; z1 = (f32) path1->posZ; - + x2 = (f32) path2->posX; z2 = (f32) path2->posZ; - + waypointIndex += 1; waypointIndex = waypointIndex % gWaypointCountByPathIndex[pathIndex]; - + path1 = &D_80164560[pathIndex][waypointIndex]; path2 = &D_80164570[pathIndex][waypointIndex]; - + x3 = (f32) path1->posX; z3 = (f32) path1->posZ; - + x4 = (f32) path2->posX; z4 = (f32) path2->posZ; @@ -3002,13 +3002,13 @@ void func_8000DF8C(s32 bombKartId) { Player *var_v0; bombKart = &gBombKarts[bombKartId]; - + sp7E = bombKart->state; if (sp7E == 0) { return; } - + if (((bombKart->unk_4A != 1) || (gCurrentCourseId == COURSE_AWARD_CEREMONY))) { var_f22 = bombKart->bombPos[0]; var_f20 = bombKart->bombPos[1]; @@ -3344,10 +3344,10 @@ void func_8000F124(void) { for (j = 0; j < 2; j++) { D_80163348[j] = 0; } - + if (gDemoMode == 1) { return; } if (gModeSelection != GRAND_PRIX) { return; } - + for (i = 0; i < 2; i++) { while(1) { @@ -3357,7 +3357,7 @@ void func_8000F124(void) { if (gPlayerCount < 1) { break; } var_a1 = 0; - + for (j = 0; j < gPlayerCount; j++) { if (gCharacterSelections[j] == D_80163348[i]) { var_a1 = 1; @@ -3392,7 +3392,7 @@ void func_8000F2DC(void) { D_80163368[1] = (s32) ptr->unk2; D_80163368[2] = (s32) ptr->unk4; D_80163368[3] = (s32) ptr->unk6; - + temp = ptr->unk8; D_80163598 = get_next_available_memory_addr(temp * 4); @@ -3467,7 +3467,7 @@ void func_8000F628(void) { for (i = 0; i < NUM_PLAYERS; i++) { Player *player = &gPlayerOne[i]; - + D_80163050[i] = 0; D_80162FF8[i] = 0; D_80163010[i] = 0; @@ -3521,7 +3521,7 @@ void func_8000F628(void) { D_80163380[i] = 6; if (gPlayers[i].type & PLAYER_HUMAN) { D_80163330[i] = 3; - + } else { D_80163330[i] = 0; } @@ -3545,7 +3545,7 @@ void func_8000F628(void) { D_80163344[i] = D_80164478[D_80163348[i]]; D_80163330[ D_80163344[i] ] = 1; D_8016334C[ D_80163344[i] ] = i; - } + } } } if ((D_8018EE08 == 1) && (gCurrentCourseId != COURSE_AWARD_CEREMONY)) { @@ -3557,12 +3557,12 @@ void func_8000F628(void) { D_80163344[0] = cameras->playerId; D_80163330[D_80163344[0]] = 1; D_8016334C[D_80163344[0]] = 0; - + for (i = 1; i < 2; i++) { D_80163344[i] = cameras[i].playerId; D_80163330[D_80163344[i]] = 1; D_8016334C[D_80163344[i]] = i; - + } } } @@ -3938,21 +3938,21 @@ s32 func_80011014(TrackWaypoint *pathDest, TrackWaypoint *path, s32 numPathPoint z3 = (f32) point3->posZ; temp = 0.05 / (sqrtf(((x2 - x1) * (x2 - x1)) + ((z2 - z1) * (z2 - z1))) + (sqrtf(((x3 - x2) * (x3 - x2)) + ((z3 - z2) * (z3 - z2))))); - + for (j = 0.0f; j <= 1.0 ; j += temp) { temp_f2_3 = (f32) ((1.0 - j) * 0.5 * (1.0 - j)); z1_3 = (f32) (((1.0 - j) * j) + 0.5); temp_f16 = (f32) (j * 0.5 * j); - + temp_f24_2 = (temp_f2_3 * x1) + (z1_3 * x2) + (temp_f16 * x3); x1_2 = (temp_f2_3 * z1) + (z1_3 * z2) + (temp_f16 * z3); - + var_f30 += sqrtf(((temp_f24_2 - temp_f20) * (temp_f24_2 - temp_f20)) + ((x1_2 - temp_f22) * (x1_2 - temp_f22))); - + temp_f20 = temp_f24_2; temp_f22 = x1_2; - + if ((var_f30 > 20.0f) || ((i == 0) && (j == 0.0))) { if (gIsMirrorMode) { //temp_f12 = -temp_f24_2; @@ -3970,7 +3970,7 @@ s32 func_80011014(TrackWaypoint *pathDest, TrackWaypoint *path, s32 numPathPoint if (var_f20_2 < -500.0) { var_f20_2 = var_f28; } else { - + switch (gCurrentCourseId) { case 13: if (var_f20_2 < (var_f28 - 15.0)) { @@ -4059,11 +4059,11 @@ s32 func_8001168C(PathNoY *pathDest, TrackWaypoint *pathSrc, s32 numWaypoints) { UNUSED s32 pad2; f32 temp_f24; - + f32 spA8; f32 temp_f26; f32 spA0; - + f32 temp_f2_3; TrackWaypoint *point1; @@ -4291,9 +4291,7 @@ void func_80011EC0(s32 arg0, Player *player, s32 arg2, UNUSED u16 arg3) { void func_800120C8(void) { s32 i; PathNoY *temp; - TrackWaypoint *waypoint = (TrackWaypoint *) VIRTUAL_TO_PHYSICAL2( - gSegmentTable[SEGMENT_NUMBER2(d_course_kalimari_desert_track_unknown_waypoints)] - + SEGMENT_OFFSET(d_course_kalimari_desert_track_unknown_waypoints)); + TrackWaypoint *waypoint = (TrackWaypoint *) d_course_kalimari_desert_track_unknown_waypoints; for (i = 0; ; i++) { if ((u16)waypoint[i].posX == 0x8000) { @@ -4307,11 +4305,9 @@ void func_800120C8(void) { } void func_80012190(void) { - TrackWaypoint *tree; + TrackWaypoint *tree = d_frappe_snowland_tree; s32 i; - tree = (TrackWaypoint *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[SEGMENT_NUMBER2(d_frappe_snowland_tree)] + (SEGMENT_OFFSET(d_frappe_snowland_tree))); - for (i = 0; ; i++) { if ((u16)tree[i].posX == 0x8000) { break; @@ -4478,29 +4474,29 @@ void func_800127E0(void) { ptr1 = &gTrainList[i].tender; ptr2 = &D_80163598[waypointOffset]; func_80012780(ptr1, ptr2, waypointOffset); - + waypointOffset += 4; ptr1 = &gTrainList[i].locomotive; ptr2 = &D_80163598[waypointOffset]; func_80012780(ptr1, ptr2, waypointOffset); - + // Only use locomotive unless overwritten below. gTrainList[i].numCars = LOCOMOTIVE_ONLY; } - + // Spawn all rolling stock in single player mode. switch (gScreenModeSelection) { case SCREEN_MODE_1P: // single player for (i = 0; i < NUM_TRAINS; i++) { gTrainList[i].tender.isActive = 1; - + // Same line required for matching... for (j = 0; j < NUM_PASSENGER_CAR_ENTRIES; j++) { gTrainList[i].passengerCars[j].isActive = 1; } - + gTrainList[i].numCars = NUM_TENDERS + NUM_PASSENGER_CAR_ENTRIES; } break; - + // Spawn locomotive, tender, and one passenger car in versus 2/3 player mode. case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL: // multiplayer fall-through case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL: @@ -4512,9 +4508,9 @@ void func_800127E0(void) { } } break; - + } - + D_80162FCC = 0; } @@ -4670,12 +4666,12 @@ void func_80013054(void) { temp_f18 = 0.72017354f; temp_f12 = 0.42299348f; - if (((temp_f12 - 0.1) < temp_f16) + if (((temp_f12 - 0.1) < temp_f16) && (temp_f16 < ((((f64) gTrainList[i].numCars) * 0.01) + (temp_f12 + 0.01)))) { isCrossingTriggeredByIndex[0] = 1; } - if (((temp_f18 - 0.1) < temp_f16) + if (((temp_f18 - 0.1) < temp_f16) && (temp_f16 < ((((f64) gTrainList[i].numCars) * 0.01) + (temp_f18 + 0.01)))) { isCrossingTriggeredByIndex[1] = 1; @@ -4697,9 +4693,9 @@ void func_800131DC(s32 playerId) { if ((!(D_801631E0[playerId] != 0)) || (func_800061DC(gPlayers[playerId].pos, 1000.0f, 0))) { - if ((isCrossingTriggeredByIndex[1] == 1) + if ((isCrossingTriggeredByIndex[1] == 1) && ((D_801637BC[1]) > 240)) { - + if ((D_80162FCE > 176) && (D_80162FCE < 182)) { D_801634D8[playerId] = 1; } @@ -4727,7 +4723,7 @@ void func_800132F4(void) { var_a1->position[2] = temp_a2->z; var_a1->waypointIndex = i * 0xB4; var_a1->actorIndex = -1; - + if (gPlayerCount >= 3) { var_a1->isActive = 0; } else { @@ -5018,7 +5014,7 @@ void func_80013F7C(s32 playerId, Player *player, VehicleStuff *vehicle, f32 arg3 f32 temp_f12; f32 temp_f14; f32 temp_f22; - + s32 i; f32 spC4; @@ -5027,7 +5023,7 @@ void func_80013F7C(s32 playerId, Player *player, VehicleStuff *vehicle, f32 arg3 if (((D_801631E0[playerId] != 1) || (( ((player->type & PLAYER_HUMAN) != 0)) && !(player->type & PLAYER_KART_AI))) && !(player->effects & 0x01000000)) { - + spC4 = player->pos[0]; spC0 = player->pos[1]; spBC = player->pos[2]; @@ -5039,7 +5035,7 @@ void func_80013F7C(s32 playerId, Player *player, VehicleStuff *vehicle, f32 arg3 if (((temp_f12) > -100.0) && ((temp_f12) < 100.0)) { if ((temp_f22 > -20.0) && (temp_f22 < 20.0)) { - + if (((temp_f14) > -100.0) && ((temp_f14) < 100.0)) { if (func_80006018(vehicle->position[0], vehicle->position[2], vehicle->velocity[0], vehicle->velocity[2], arg3, arg4, spC4, spBC) == (s32) 1) { player->soundEffects |= REVERSE_SOUND_EFFECT; @@ -5068,12 +5064,12 @@ void func_80013F7C(s32 playerId, Player *player, VehicleStuff *vehicle, f32 arg3 if (((temp_f12) > -200.0) && ((temp_f12) < 200.0) && ((temp_f22 > -20.0)) && (temp_f22 < 20.0) && ( ((temp_f14) > -200.0)) && ((temp_f14) < 200.0)) { if (!(vehicle->someFlagsTheSequel & ((1 << playerId)))) { - + s32 var_s1 = 0; - u16 path = gWaypointCountByPathIndex[0]; + u16 path = gWaypointCountByPathIndex[0]; s32 t1; s32 t2; - + switch (D_8016347A) { case 0: t1 = func_80007BF8(vehicle->waypointIndex, gNearestWaypointByPlayerId[playerId], 10, 0, path); @@ -5102,9 +5098,9 @@ void func_80013F7C(s32 playerId, Player *player, VehicleStuff *vehicle, f32 arg3 break; } if (var_s1 == 1) { - + u32 soundBits2 = SOUND_ARG_LOAD(0x19, 0x01, 0x70, 0x3B); - + switch (soundBits) { case SOUND_ARG_LOAD(0x51, 0x01, 0x80, 0x05): soundBits2 = SOUND_ARG_LOAD(0x19, 0x01, 0x70, 0x3B); @@ -6485,7 +6481,7 @@ void func_80019890(s32 playerId, s32 cameraId) { Camera *camera = camera1; camera += cameraId; camera->playerId = playerId; - + D_801646C0[cameraId] = 0; pathIndex = gPathIndexByPlayerId[playerId]; @@ -6848,7 +6844,7 @@ void func_8001A588(UNUSED u16 *localD_80152300, Camera *camera, Player *player, func_8001A518((s32) playerId, gGPCurrentRaceRankByPlayerId[playerId], 0); } if ((gModeSelection != TIME_TRIALS) && (cameraIndex == 1) && (((D_801646C8 == 260)) || (D_801646C8 == 261))) { - + var_v1 = 0; if (gPlayerCount == 2) { func_8001A518((s32) playerId, gGPCurrentRaceRankByPlayerId[playerId], 1); @@ -6971,7 +6967,7 @@ void kart_ai_decisions_branch_item(UNUSED s32 arg0, s16 *arg1, s32 arg2) { case ITEM_MUSHROOM: value = 0x1D; break; - case ITEM_DOUBLE_MUSHROOM: + case ITEM_DOUBLE_MUSHROOM: break; case ITEM_TRIPLE_MUSHROOM: break; diff --git a/src/code_8003DC40.c b/src/code_8003DC40.c index 3de5b0add..9853b8d7e 100644 --- a/src/code_8003DC40.c +++ b/src/code_8003DC40.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include "math_util.h" diff --git a/src/code_80057C60.c b/src/code_80057C60.c index 39ab768a7..910c26b61 100644 --- a/src/code_80057C60.c +++ b/src/code_80057C60.c @@ -3,9 +3,9 @@ * @warning there are too many variables here */ -#include +#include #include -#include +#include #include #include "camera.h" @@ -113,7 +113,7 @@ s32 D_80165754; ThwompSpawn *gThowmpSpawnList; Vec4s D_80165760; -UNUSED s16 D_80165768; +UNUSED s16 D_80165768; s8 D_8016576A; Vec4s D_80165770; UNUSED s32 D_80165778; @@ -151,21 +151,21 @@ s8 D_801657E2; s8 D_801657E3; s8 D_801657E4; s8 D_801657E5; -bool8 D_801657E6; +bool D_801657E6; u8 D_801657E7; -bool8 D_801657E8; +bool D_801657E8; UNUSED s32 D_801657EC; -bool8 D_801657F0; +bool D_801657F0; UNUSED s32 D_801657F4; -bool8 D_801657F8; +bool D_801657F8; s32 D_801657FC; s8 D_80165800[2]; s32 D_80165804; s8 D_80165808; s32 D_8016580C; -bool8 D_80165810; +bool D_80165810; s32 D_80165814; -bool8 D_80165818; +bool D_80165818; s32 D_8016581C; s8 D_80165820; UNUSED s32 D_80165824; @@ -971,7 +971,7 @@ void func_80058F78(void) { render_hud_timer(PLAYER_ONE); draw_simplified_lap_count(PLAYER_ONE); func_8004EB38(0); - if (D_801657E6 != FALSE) { + if (D_801657E6 != false) { func_8004ED40(0); } } @@ -1044,10 +1044,10 @@ void func_800591B4(void) { if (gIsHUDVisible != 0) { if (D_801657D8 == 0) { - if (D_801657F0 != FALSE) { + if (D_801657F0 != false) { func_800514BC(); } - if ((!gDemoMode) && (D_801657E8 != FALSE)) { + if ((!gDemoMode) && (D_801657E8 != false)) { if (D_80165800[0] != 0) { func_8004EE54(0); if (gModeSelection != BATTLE) { @@ -1224,7 +1224,7 @@ void randomize_seed_from_controller(s32 arg0) { } void func_8005994C(void) { - D_8018D214 = TRUE; + D_8018D214 = true; } void func_8005995C(void) { @@ -1233,7 +1233,7 @@ void func_8005995C(void) { for (i = 0; i < 4; i++) { if ((D_80165890 != 0) && (player->type & PLAYER_INVISIBLE_OR_BOMB)) { player->currentItemCopy = ITEM_MUSHROOM; - + playerHUD[i].unk_75 = 2; } if ((player->type & PLAYER_INVISIBLE_OR_BOMB) && (player->currentItemCopy == ITEM_NONE)) { @@ -1258,7 +1258,7 @@ void func_80059A88(s32 playerId) { void func_80059AC8(void) { s32 i; - if (gIsGamePaused == FALSE) { + if (gIsGamePaused == false) { func_8008C1D8(&D_80165678); gRaceFrameCounter++; for (i = 0; i < NUM_PLAYERS; i++) { @@ -1311,16 +1311,16 @@ void func_80059C50(void) { } void func_80059D00(void) { - + func_8005A99C(); func_8005A3C0(); func_8005A380(); if (D_801657AE == 0) { - switch (gScreenModeSelection) { + switch (gScreenModeSelection) { case SCREEN_MODE_1P: randomize_seed_from_controller(PLAYER_ONE); - if (D_8018D214 == FALSE) { + if (D_8018D214 == false) { func_80059820(PLAYER_ONE); func_8005B914(); if (!gDemoMode) { @@ -1420,7 +1420,7 @@ void func_8005A070(void) { gMatrixHudCount = 0; D_801655C0 = 0; func_80041D34(); - if (gIsGamePaused == FALSE) { + if (gIsGamePaused == false) { func_8005C728(); if (gGamestate == ENDING) { func_80086604(); @@ -1497,7 +1497,7 @@ void func_8005A380(void) { } void func_8005A3C0(void) { - bool b = FALSE; + bool b = false; if ((gGamestate != ENDING) && (gGamestate != CREDITS_SEQUENCE) && !D_8018D204) { switch (gPlayerCountSelection1) { case 1: @@ -1506,38 +1506,38 @@ void func_8005A3C0(void) { D_801657E4 = 0; } if (D_801657E4 == 2) { - D_801657E8 = FALSE; - D_801657E6 = FALSE; - D_801657F0 = TRUE; + D_801657E8 = false; + D_801657E6 = false; + D_801657F0 = true; } else if (D_801657E4 == 1) { - D_801657E8 = FALSE; - D_801657E6 = TRUE; - D_801657F0 = FALSE; + D_801657E8 = false; + D_801657E6 = true; + D_801657F0 = false; } else { - D_801657E8 = TRUE; - D_801657E6 = FALSE; - D_801657F0 = FALSE; + D_801657E8 = true; + D_801657E6 = false; + D_801657F0 = false; } - b = TRUE; + b = true; } break; case 2: if (gModeSelection != BATTLE) { if (gControllerOne->buttonPressed & R_CBUTTONS) { D_80165800[0] = (D_80165800[0] + 1) & 1; - b = TRUE; + b = true; } if (gControllerTwo->buttonPressed & R_CBUTTONS) { D_80165800[1] = (D_80165800[1] + 1) & 1; - b = TRUE; + b = true; } if (D_80165800[0] && D_80165800[1]) { - D_801657F0 = FALSE; + D_801657F0 = false; } else { - D_801657F0 = TRUE; + D_801657F0 = true; } if (gDemoMode) { - D_801657F0 = FALSE; + D_801657F0 = false; } } break; @@ -1549,7 +1549,7 @@ void func_8005A3C0(void) { D_801657F0 = (D_801657F0 + 1) & 1; } D_801657E4 = (D_801657E4 + 1) & 1; - b = TRUE; + b = true; } break; case 4: @@ -1563,7 +1563,7 @@ void func_8005A3C0(void) { if (gModeSelection != BATTLE) { D_801657F0 = (D_801657F0 + 1) & 1; } - b = TRUE; + b = true; } break; } @@ -1664,7 +1664,7 @@ void func_8005A99C(void) { func_8005AA34(); } if (gPlayerCountSelection1 == 3) { - D_801657E8 = TRUE; + D_801657E8 = true; } gIsHUDVisible = (s32) 1; D_8018D170 = (s32) 1; @@ -2862,7 +2862,7 @@ void func_8005D898(Player* player, s16 arg1, UNUSED s32 arg2, UNUSED s8 arg3, UN if (player->unk_22A == 1) { func_8005D800(&player->unk_258[10 + arg1], 0xFFFF00, 0x70); - + } if (player->unk_22A >= 2) { @@ -4197,7 +4197,7 @@ void func_80062C74(Player *player, s16 arg1, UNUSED s32 arg2, UNUSED s32 arg3) { void func_80062F98(Player* player, s16 arg1, s8 arg2, UNUSED s8 arg3) { f32 temp_f0; - + temp_f0 = player->unk_258[10 + arg1].unk_018 / 10.0f; ++player->unk_258[10 + arg1].unk_01E; player->unk_258[10 + arg1].unk_000[1] += temp_f0; @@ -4443,7 +4443,7 @@ void func_80063D58(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { } else { player->unk_258[10 + arg1].unk_000[1] += 0.4; } - + if (player->unk_258[10 + arg1].unk_03E <= 0) { player->unk_258[10 + arg1].unk_03E = 0; } @@ -4513,7 +4513,7 @@ void func_800643A8(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { player->unk_258[10 + arg1].unk_01E = 0; player->unk_258[10 + arg1].unk_012 = 0; } - + player->unk_258[10 + arg1].unk_00C += 0.2; player->unk_258[10 + arg1].unk_03E -= 8; if (player->unk_258[10 + arg1].unk_03E <= 0) { @@ -4598,11 +4598,11 @@ void func_800648E4(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { player->unk_258[30 + arg1].unk_00C -= 0.06; player->unk_258[30 + arg1].unk_000[1] += 0.1; player->unk_258[30 + arg1].unk_03E -= 12; - + if (player->unk_258[30 + arg1].unk_03E <= 0) { player->unk_258[30 + arg1].unk_03E = 0; } - + if (player->unk_258[30 + arg1].unk_01E == 10) { player->unk_258[30 + arg1].unk_01C = 0; player->unk_258[30 + arg1].unk_01E = 0; @@ -4624,7 +4624,7 @@ void func_80064988(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { void func_800649F4(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { f32 temp; temp = player->unk_258[30 + arg1].unk_018; - + player->unk_258[30 + arg1].unk_000[2] = player->unk_21C + (((-temp) * player->unk_258[30 + arg1].unk_01E) * coss(player->unk_258[30 + arg1].unk_020)); player->unk_258[30 + arg1].unk_000[0] = player->unk_218 + (((-temp) * player->unk_258[30 + arg1].unk_01E) * sins(player->unk_258[30 + arg1].unk_020)); player->unk_258[30 + arg1].unk_000[1] = player->pos[1] + player->unk_258[30 + arg1].unk_014; @@ -4636,7 +4636,7 @@ void func_800649F4(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { player->unk_258[30 + arg1].unk_01C = 0; player->unk_258[30 + arg1].unk_012 = 0; } - + if (player->unk_258[30 + arg1].unk_01E >= 9) { player->unk_258[30 + arg1].unk_03E -= 0x10; if (player->unk_258[30 + arg1].unk_03E <= 0) { @@ -4659,7 +4659,7 @@ void func_80064B30(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { player->unk_258[30 + arg1].unk_01C = 0; player->unk_258[30 + arg1].unk_012 = 0; } - + player->unk_258[30 + arg1].unk_038 += 1820; if (player->unk_258[30 + arg1].unk_01E >= 6) { player->unk_258[30 + arg1].unk_03E -= 16; @@ -4676,7 +4676,7 @@ void func_80064C74(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { } else { player->unk_258[30 + arg1].unk_020 -= 2184; } - + player->unk_258[30 + arg1].unk_000[2] = player->pos[2] + (coss(player->unk_258[30 + arg1].unk_020 - player->rotation[1] - player->unk_0C0) * 5.0f); player->unk_258[30 + arg1].unk_000[0] = player->pos[0] + (sins(player->unk_258[30 + arg1].unk_020 - player->rotation[1] - player->unk_0C0) * 5.0f); player->unk_258[30 + arg1].unk_000[1] = player->pos[1] - 1.0f; @@ -4700,14 +4700,14 @@ void func_80064DEC(Player* player, UNUSED s8 arg1, UNUSED s8 arg2, s8 arg3) { player->unk_258[20 + arg3].unk_000[1] = player->pos[1]; ++player->unk_258[20 + arg3].unk_01E; - + if (player->unk_258[20 + arg3].unk_01E == 9) { player->unk_0B6 &= ~0x0040; player->unk_258[20 + arg3].unk_01C = 0; player->unk_258[20 + arg3].unk_01E = 0; player->unk_258[20 + arg3].unk_012 = 0; } - + player->unk_258[20 + arg3].unk_00C += 0.8; if (player->unk_258[20 + arg3].unk_00C >= (f64) 2.5) { player->unk_258[20 + arg3].unk_00C = 2.5f; @@ -4735,7 +4735,7 @@ void func_80064EA4(Player* player, UNUSED s8 arg1, UNUSED s8 arg2, s8 arg3) { void func_80064F88(Player* player, UNUSED s8 arg1, UNUSED s8 arg2, s8 arg3) { ++player->unk_258[20 + arg3].unk_01E; player->unk_258[20 + arg3].unk_00C += 0.15; - + if (1.2 <= player->unk_258[20 + arg3].unk_00C) { player->unk_258[20 + arg3].unk_00C = 1.2f; } @@ -4755,7 +4755,7 @@ void func_80065030(Player* player, UNUSED s8 arg1, UNUSED s8 arg2, s8 arg3) { if (player->unk_258[20 + arg3].unk_00C >= (f64) 1.5) { player->unk_258[20 + arg3].unk_00C = 1.5f; } - + if (player->unk_258[20 + arg3].unk_01E >= 12) { player->unk_0B6 &= ~0x0100; player->unk_258[20 + arg3].unk_01C = 0; @@ -5790,7 +5790,7 @@ void render_battle_balloon(Player *player, s8 arg1, s16 arg2, s8 arg3) { gDPSetTextureLUT(gDisplayListHead++, G_TT_RGBA16); func_8004B614(primRed, primGreen, primBlue, envRed, envGreen, envBlue, 0x000000D8); - + gDPSetRenderMode(gDisplayListHead++, AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_WRAP | ZMODE_XLU | CVG_X_ALPHA | FORCE_BL | GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA), AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_WRAP | ZMODE_XLU | CVG_X_ALPHA | FORCE_BL | GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)); gDPLoadTextureBlock(gDisplayListHead++, D_8018D4BC, G_IM_FMT_CI, G_IM_SIZ_8b, 64, 32, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); gSPVertex(gDisplayListHead++, gBalloonVertexPlane1, 4, 0); @@ -6056,39 +6056,39 @@ void func_8006C9B8(Player *player, s16 arg1, s8 arg2, s8 arg3) { case 1: func_800644E8(player, arg1, arg2, arg3); break; - + case 2: func_800649F4(player, arg1, arg2, arg3); break; - + case 3: func_80064C74(player, arg1, arg2, arg3); break; - + case 4: func_800647C8(player, arg1, arg2, arg3); break; - + case 5: func_80064B30(player, arg1, arg2, arg3); break; - + case 6: func_800648E4(player, arg1, arg2, arg3); break; - + case 7: func_80064988(player, arg1, arg2, arg3); break; - + case 8: func_80064C74(player, arg1, arg2, arg3); break; - + case 9: func_80064664(player, arg1, arg2, arg3); break; - + default: break; } @@ -6175,7 +6175,7 @@ void func_8006CEC0(Player *arg0, s16 arg1, s8 arg2, s8 arg3) { } else if (((arg0->effects & 0x40000000) == 0x40000000) && (arg0->unk_0B0 < 0x32)) { func_80061094(arg0, arg1, sp20, arg2, arg3); return; - } else if ((arg0->type & 0x4000) == 0x4000) { + } else if ((arg0->type & 0x4000) == 0x4000) { if ((arg0->unk_0DE & 8) == 8) { func_80060F50(arg0, arg1, sp20, arg2, arg3); return; @@ -6450,7 +6450,7 @@ void func_8006DD3C(Player* arg0, s8 arg1, s8 arg2) { } void func_8006E058(void) { - switch (gActiveScreenMode) { + switch (gActiveScreenMode) { case SCREEN_MODE_1P: switch (gModeSelection) { case GRAND_PRIX: @@ -6470,7 +6470,7 @@ void func_8006E058(void) { if ((gPlayerTwo->type & 0x100) == 0x100) { func_8006E420(gPlayerTwo, 1, 0); } - + if ((gPlayerThree->type & 0x100) == 0x100) { func_8006E420(gPlayerThree, 2, 0); break; @@ -6481,7 +6481,7 @@ void func_8006E058(void) { case BATTLE: func_8006E420(gPlayerOne, 0, 0); func_8006E420(gPlayerTwo, 1, 0); - + if (gPlayerCountSelection1 >= 3) { func_8006E420(gPlayerThree, 2, 0); } @@ -6497,7 +6497,7 @@ void func_8006E058(void) { break; case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL: case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL: - switch (gModeSelection) { + switch (gModeSelection) { case GRAND_PRIX: func_8006E420(gPlayerOne, 0, 0); func_8006E420(gPlayerTwo, 1, 0); @@ -6509,7 +6509,7 @@ void func_8006E058(void) { func_8006E420(gPlayerEight, 7, 0); break; - case VERSUS: + case VERSUS: case BATTLE: func_8006E420(gPlayerOne, 0, 0); func_8006E420(gPlayerTwo, 1, 0); @@ -6517,7 +6517,7 @@ void func_8006E058(void) { break; case TIME_TRIALS: func_8006E420(gPlayerOne, 0, 0); - + if ((gPlayerTwo->type & 0x8000) == 0x8000) { func_8006E420(gPlayerTwo, 1, 0); break; @@ -6549,7 +6549,7 @@ void func_8006E420(Player* player, s8 arg1, s8 arg2) { if ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) { func_8006D194(player, arg1, arg2); } - + for (temp_s0 = 0; temp_s0 < 10; ++temp_s0) { func_8006CEC0(player, temp_s0, arg1, arg2); if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) || (gGamestate == ENDING)) { diff --git a/src/code_80057C60.h b/src/code_80057C60.h index f8f5eeeeb..c9150e67a 100644 --- a/src/code_80057C60.h +++ b/src/code_80057C60.h @@ -333,20 +333,20 @@ extern s8 D_801657E2; extern s8 D_801657E3; extern s8 D_801657E4; extern s8 D_801657E5; -extern bool8 D_801657E6; +extern bool D_801657E6; extern u8 D_801657E7; -extern bool8 D_801657E8; -extern bool8 D_801657F0; -extern bool8 D_801657F8; +extern bool D_801657E8; +extern bool D_801657F0; +extern bool D_801657F8; extern s32 D_801657FC; extern s8 D_80165800[2]; extern s32 D_80165804; extern s8 D_80165808; extern s32 D_8016580C; -extern bool8 D_80165810; +extern bool D_80165810; extern s32 D_80165814; -extern bool8 D_80165818; +extern bool D_80165818; extern s32 D_8016581C; extern s8 D_80165820; extern s8 D_80165828; diff --git a/src/code_80057C60_var.c b/src/code_80057C60_var.c index 04393db96..0ed5c549c 100644 --- a/src/code_80057C60_var.c +++ b/src/code_80057C60_var.c @@ -1,4 +1,4 @@ -#include +#include #include #include "code_80057C60.h" @@ -152,13 +152,13 @@ s32 D_8018D3D4; s32 D_8018D3D8; s32 D_8018D3DC; //! some alpha -s32 D_8018D3E0; +s32 D_8018D3E0; //! some red -s32 D_8018D3E4; +s32 D_8018D3E4; //! some green -s32 D_8018D3E8; +s32 D_8018D3E8; //! some blue -s32 D_8018D3EC; +s32 D_8018D3EC; s32 D_8018D3F0; s32 D_8018D3F4; s32 D_8018D3F8; diff --git a/src/code_8006E9C0.c b/src/code_8006E9C0.c index 3eb226d95..5a2263a00 100644 --- a/src/code_8006E9C0.c +++ b/src/code_8006E9C0.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -67,7 +67,7 @@ void reset_object_variable(void) { void func_8006EB10(void) { s32 i; - + for (i = 0; i < gObjectParticle1_SIZE; i++) { gObjectParticle1[i] = NULL_OBJECT_ID; } @@ -638,10 +638,10 @@ void init_clouds(CloudData *cloudList) { /** * This function is part of the spawning for the "stars" in some stages - * + * * arg2 is a pointer to some type of spawn data for the stars, although it not super clear * what types each element is. It seems like its a bunch of u16's, so maybe a Vec4su? - * + * * The stars in Wario's Stadium, Toad's Turnpike, and Rainbow Road are not part of the skybox. * They are instead objects that seemingly hover in the air around the player * They have no true x/y/z position, instead they seem to be kept in a position relative to the @@ -694,7 +694,7 @@ void func_8007055C(void) { if (gPlayerCount == 1) { var_s4 = 0x32; } else { - var_s4 = 0x19; + var_s4 = 0x19; } for (var_s0 = 0; var_s0 < var_s4; var_s0++) { find_unused_obj_index(&D_8018CC80[D_8018D1F8 + var_s0]); @@ -1278,7 +1278,7 @@ void init_hud_three_four_player(void) { playerHUD[PLAYER_TWO].lapY = 0x60; playerHUD[PLAYER_TWO].unk_6C = 0xC8; playerHUD[PLAYER_TWO].unk_6E = 0xC8; - + playerHUD[PLAYER_THREE].itemBoxX = -0x36; playerHUD[PLAYER_THREE].itemBoxY = 0x2D; playerHUD[PLAYER_THREE].slideItemBoxX = 0; @@ -1293,7 +1293,7 @@ void init_hud_three_four_player(void) { playerHUD[PLAYER_THREE].lapY = 0xD4; playerHUD[PLAYER_THREE].unk_6C = 0xDE; playerHUD[PLAYER_THREE].unk_6E = 0xC0; - + playerHUD[PLAYER_FOUR].itemBoxX = 0x175; playerHUD[PLAYER_FOUR].itemBoxY = 0x2D; playerHUD[PLAYER_FOUR].slideItemBoxX = 0; diff --git a/src/code_80086E70.c b/src/code_80086E70.c index 0489faa0a..c0cd42e9d 100644 --- a/src/code_80086E70.c +++ b/src/code_80086E70.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -45,9 +45,9 @@ void func_80086F60(s32 objectIndex) { } bool func_80086FA4(s32 objectIndex) { - bool ret = FALSE; + bool ret = false; if (gObjectList[objectIndex].unk_0AE == 0) { - ret = TRUE; + ret = true; } return ret; } @@ -66,7 +66,7 @@ s32 func_80087060(s32 objectIndex, s32 arg1) { s32 sp1C; sp1C = 0; - if (is_obj_index_flag_status_inactive(objectIndex, 8) != FALSE) { + if (is_obj_index_flag_status_inactive(objectIndex, 8) != false) { set_object_flag_status_true(objectIndex, 8); gObjectList[objectIndex].unk_0B0 = arg1; } @@ -82,7 +82,7 @@ s32 func_80087104(s32 objectIndex, u16 arg1) { s32 sp24; sp24 = 0; - if (is_obj_index_flag_status_inactive(objectIndex, 8) != FALSE) { + if (is_obj_index_flag_status_inactive(objectIndex, 8) != false) { set_object_flag_status_true(objectIndex, 8); gObjectList[objectIndex].unk_0B0 = random_int(arg1); } @@ -98,7 +98,7 @@ s32 func_800871AC(s32 objectIndex, s32 arg1) { s32 sp24; sp24 = 0; - if (is_obj_index_flag_status_inactive(objectIndex, 8) != FALSE) { + if (is_obj_index_flag_status_inactive(objectIndex, 8) != false) { set_object_flag_status_true(objectIndex, 8); gObjectList[objectIndex].unk_0B0 = (s16) arg1; } @@ -218,7 +218,7 @@ s32 func_8008789C(s32 objectIndex, s32 arg1) { s32 sp24; sp24 = 0; - if (is_obj_index_flag_status_inactive(objectIndex, 8) != FALSE) { + if (is_obj_index_flag_status_inactive(objectIndex, 8) != false) { set_object_flag_status_true(objectIndex, 8); func_8008751C(objectIndex); gObjectList[objectIndex].unk_0B0 = arg1; @@ -237,7 +237,7 @@ s32 func_80087954(s32 objectIndex, s32 arg1) { s32 sp24; sp24 = 0; - if (is_obj_index_flag_status_inactive(objectIndex, 8) != FALSE) { + if (is_obj_index_flag_status_inactive(objectIndex, 8) != false) { set_object_flag_status_true(objectIndex, 8); func_80087620(objectIndex); gObjectList[objectIndex].unk_0B0 = arg1; @@ -258,8 +258,8 @@ bool func_80087A0C(s32 objectIndex, s16 arg1, s16 arg2, s16 arg3, s16 arg4) { s16 temp_v0; bool sp2C; - sp2C = FALSE; - if (is_obj_index_flag_status_inactive(objectIndex, 8) != FALSE) { + sp2C = false; + if (is_obj_index_flag_status_inactive(objectIndex, 8) != false) { set_object_flag_status_true(objectIndex, 8); temp_v0 = arg2 - arg1; temp_a0 = arg4 - arg3; @@ -272,7 +272,7 @@ bool func_80087A0C(s32 objectIndex, s16 arg1, s16 arg2, s16 arg3, s16 arg4) { gObjectList[objectIndex].unk_0B0--; if (gObjectList[objectIndex].unk_0B0 < 0) { set_object_flag_status_false(objectIndex, 8); - sp2C = TRUE; + sp2C = true; } else { object_add_velocity_offset_xz(objectIndex); } @@ -283,7 +283,7 @@ s32 func_80087B84(s32 objectIndex, f32 arg1, f32 arg2) { s32 sp24; sp24 = 0; - if (is_obj_index_flag_status_inactive(objectIndex, 8) != FALSE) { + if (is_obj_index_flag_status_inactive(objectIndex, 8) != false) { set_object_flag_status_true(objectIndex, 8); gObjectList[objectIndex].velocity[1] = -arg1; } @@ -300,7 +300,7 @@ s32 func_80087C48(s32 objectIndex, f32 arg1, f32 arg2, s32 arg3) { s32 sp24; sp24 = 0; - if (is_obj_index_flag_status_inactive(objectIndex, 8) != FALSE) { + if (is_obj_index_flag_status_inactive(objectIndex, 8) != false) { set_object_flag_status_true(objectIndex, 8); gObjectList[objectIndex].velocity[1] = arg1; gObjectList[objectIndex].unk_0B0 = (s16) arg3; @@ -340,7 +340,7 @@ bool func_80087E08(s32 objectIndex, f32 arg1, f32 arg2, f32 arg3, s16 arg4, s32 bool sp2C; UNUSED s32 pad; - sp2C = FALSE; + sp2C = false; if (is_obj_index_flag_status_inactive(objectIndex, 8) != 0) { set_object_flag_status_true(objectIndex, 8); gObjectList[objectIndex].offset[2] = 0.0f; @@ -356,7 +356,7 @@ bool func_80087E08(s32 objectIndex, f32 arg1, f32 arg2, f32 arg3, s16 arg4, s32 if (gObjectList[objectIndex].unk_0B0 < 0) { set_object_flag_status_false(objectIndex, 8); func_80086FD4(objectIndex); - sp2C = TRUE; + sp2C = true; } else { gObjectList[objectIndex].velocity[1] -= arg2; object_add_velocity_offset_xyz(objectIndex); @@ -585,10 +585,10 @@ void func_800887C0(s32 objectIndex) { /** * @brief Returns the distance between the object and the player. - * - * @param objectIndex - * @param player - * @return UNUSED + * + * @param objectIndex + * @param player + * @return UNUSED */ UNUSED s32 get_horizontal_distance_to_player(s32 objectIndex, Player *player) { s32 x; @@ -601,10 +601,10 @@ UNUSED s32 get_horizontal_distance_to_player(s32 objectIndex, Player *player) { /** * @brief Returns the distance between the object and the player. - * - * @param objectIndex - * @param player - * @return UNUSED + * + * @param objectIndex + * @param player + * @return UNUSED */ UNUSED s32 get_distance_to_player(s32 objectIndex, Player *player) { s32 x; @@ -619,10 +619,10 @@ UNUSED s32 get_distance_to_player(s32 objectIndex, Player *player) { /** * @brief Returns the distance between the object and the camera. - * - * @param objectIndex - * @param camera - * @return UNUSED + * + * @param objectIndex + * @param camera + * @return UNUSED */ u32 get_horizontal_distance_to_camera(s32 objectIndex, Camera *camera) { s32 x; @@ -635,10 +635,10 @@ u32 get_horizontal_distance_to_camera(s32 objectIndex, Camera *camera) { /** * @brief Returns the distance between the object and the camera. - * - * @param objectIndex - * @param camera - * @return UNUSED + * + * @param objectIndex + * @param camera + * @return UNUSED */ UNUSED s32 get_distance_to_camera(s32 objectIndex, Camera *camera) { s32 x; @@ -653,36 +653,36 @@ UNUSED s32 get_distance_to_camera(s32 objectIndex, Camera *camera) { /** * @brief Returns if the object is closer than the distance to the player. - * - * @param objectIndex - * @param player + * + * @param objectIndex + * @param player * @param distance - * @return true - * @return false + * @return true + * @return false */ bool is_within_horizontal_distance_of_player(s32 objectIndex, Player *player, f32 distance) { f32 x; f32 y; bool var_v1; - var_v1 = FALSE; + var_v1 = false; x = gObjectList[objectIndex].pos[0] - player->pos[0]; y = gObjectList[objectIndex].pos[2] - player->pos[2]; if (((x * x) + (y * y)) <= (distance * distance)) { - var_v1 = TRUE; + var_v1 = true; } return var_v1; } /** * @brief Returns if the object is between the distance_min and distance_max to the player. - * - * @param objectIndex - * @param player - * @param distance_min - * @param distance_max - * @return true - * @return false + * + * @param objectIndex + * @param player + * @param distance_min + * @param distance_max + * @return true + * @return false */ bool is_in_bounds_to_player(s32 objectIndex, Player *player, f32 distance_min, f32 distance_max) { f32 x; @@ -690,24 +690,24 @@ bool is_in_bounds_to_player(s32 objectIndex, Player *player, f32 distance_min, f f32 z; bool var_v1; - var_v1 = FALSE; + var_v1 = false; x = gObjectList[objectIndex].pos[0] - player->pos[0]; z = gObjectList[objectIndex].pos[2] - player->pos[2]; distance = (x * x) + (z * z); if (((distance_min * distance_min) <= distance) && (distance <= (distance_max * distance_max))) { - var_v1 = TRUE; + var_v1 = true; } return var_v1; } /** * @brief Returns if the object is closer than the distance to the player. - * - * @param objectIndex - * @param player - * @param distance - * @return true - * @return false + * + * @param objectIndex + * @param player + * @param distance + * @return true + * @return false */ bool is_within_distance_to_player(s32 objectIndex, Player *player, f32 distance) { f32 x; @@ -715,47 +715,47 @@ bool is_within_distance_to_player(s32 objectIndex, Player *player, f32 distance) f32 y; bool var_v1; - var_v1 = FALSE; + var_v1 = false; x = gObjectList[objectIndex].pos[0] - player->pos[0]; y = gObjectList[objectIndex].pos[1] - player->pos[1]; z = gObjectList[objectIndex].pos[2] - player->pos[2]; if (((x * x) + (y * y) + (z * z)) <= (distance * distance)) { - var_v1 = TRUE; + var_v1 = true; } return var_v1; } /** * @brief Returns if the object is between the distance_min and distance_max to the camera. - * - * @param objectIndex - * @param camera - * @param distance - * @return true - * @return false + * + * @param objectIndex + * @param camera + * @param distance + * @return true + * @return false */ bool is_within_horizontal_distance_to_camera(s32 objectIndex, Camera *camera, f32 distance) { f32 x; f32 y; bool var_v1; - var_v1 = FALSE; + var_v1 = false; x = gObjectList[objectIndex].pos[0] - camera->pos[0]; y = gObjectList[objectIndex].pos[2] - camera->pos[2]; if (((x * x) + (y * y)) <= (distance * distance)) { - var_v1 = TRUE; + var_v1 = true; } return var_v1; } /** * @brief Returns if the object is between the distance_min and distance_max to the camera. - * - * @param objectIndex - * @param camera - * @param distance_min - * @param distance_max - * @return UNUSED + * + * @param objectIndex + * @param camera + * @param distance_min + * @param distance_max + * @return UNUSED */ UNUSED bool is_within_bounds_to_camera(s32 objectIndex, Camera *camera, f32 distance_min, f32 distance_max) { f32 x; @@ -763,23 +763,23 @@ UNUSED bool is_within_bounds_to_camera(s32 objectIndex, Camera *camera, f32 dist f32 z; bool var_v1; - var_v1 = FALSE; + var_v1 = false; x = gObjectList[objectIndex].pos[0] - camera->pos[0]; z = gObjectList[objectIndex].pos[2] - camera->pos[2]; distance = (x * x) + (z * z); if (((distance_min * distance_min) <= distance) && (distance <= (distance_max * distance_max))) { - var_v1 = TRUE; + var_v1 = true; } return var_v1; } /** * @brief Returns if the object is closer than the distance to the camera. - * - * @param objectIndex - * @param camera - * @param distance - * @return UNUSED + * + * @param objectIndex + * @param camera + * @param distance + * @return UNUSED */ UNUSED bool is_within_distance_to_camera(s32 objectIndex, Camera *camera, f32 distance) { f32 x; @@ -787,23 +787,23 @@ UNUSED bool is_within_distance_to_camera(s32 objectIndex, Camera *camera, f32 di f32 y; bool var_v1; - var_v1 = FALSE; + var_v1 = false; x = gObjectList[objectIndex].pos[0] - camera->pos[0]; y = gObjectList[objectIndex].pos[1] - camera->pos[1]; z = gObjectList[objectIndex].pos[2] - camera->pos[2]; if (((x * x) + (y * y) + (z * z)) <= (distance * distance)) { - var_v1 = TRUE; + var_v1 = true; } return var_v1; } /** * @brief Returns if the object collided with the player. - * - * @param objectIndex - * @param player - * @return true - * @return false + * + * @param objectIndex + * @param player + * @return true + * @return false */ bool has_collided_horizontally_with_player(s32 objectIndex, Player *player) { f32 x; @@ -811,23 +811,23 @@ bool has_collided_horizontally_with_player(s32 objectIndex, Player *player) { f32 z; bool var_v1; - var_v1 = FALSE; + var_v1 = false; x = gObjectList[objectIndex].pos[0] - player->pos[0]; z = gObjectList[objectIndex].pos[2] - player->pos[2]; distance = gObjectList[objectIndex].boundingBoxSize + player->boundingBoxSize; if (((x * x) + (z * z)) <= (distance * distance)) { - var_v1 = TRUE; + var_v1 = true; } return var_v1; } /** * @brief Returns if the object collided with the player. - * - * @param objectIndex - * @param player - * @return true - * @return false + * + * @param objectIndex + * @param player + * @return true + * @return false */ bool has_collided_with_player(s32 objectIndex, Player *player) { f32 x; @@ -836,45 +836,45 @@ bool has_collided_with_player(s32 objectIndex, Player *player) { f32 y; bool var_v1; - var_v1 = FALSE; + var_v1 = false; x = gObjectList[objectIndex].pos[0] - player->pos[0]; y = gObjectList[objectIndex].pos[1] - player->pos[1]; z = gObjectList[objectIndex].pos[2] - player->pos[2]; distance = gObjectList[objectIndex].boundingBoxSize + player->boundingBoxSize; if (((x * x) + (y * y) + (z * z)) <= (distance * distance)) { - var_v1 = TRUE; + var_v1 = true; } return var_v1; } /** * @brief Returns if the object collided with the player. - * - * @param objectIndex - * @param player - * @param distance - * @return UNUSED + * + * @param objectIndex + * @param player + * @param distance + * @return UNUSED */ UNUSED bool has_collided_with_player_1d(s32 objectIndex, Player *player, f32 distance) { f32 x; bool var_v1; - var_v1 = FALSE; + var_v1 = false; x = gObjectList[objectIndex].pos[1] - player->pos[1]; if ((x * x) <= (distance * distance)) { - var_v1 = TRUE; + var_v1 = true; } return var_v1; } /** * @brief Returns if the object collided with the player and is closer than the distance in the y axis. - * - * @param objectIndex - * @param player - * @param distance_y - * @return true - * @return false + * + * @param objectIndex + * @param player + * @param distance_y + * @return true + * @return false */ bool has_collided_with_player_and_within_height(s32 objectIndex, Player *player, f32 distance_y) { f32 x; @@ -883,7 +883,7 @@ bool has_collided_with_player_and_within_height(s32 objectIndex, Player *player, f32 y; bool var_v1; - var_v1 = FALSE; + var_v1 = false; x = gObjectList[objectIndex].pos[0] - player->pos[0]; y = gObjectList[objectIndex].pos[1] - player->pos[1]; z = gObjectList[objectIndex].pos[2] - player->pos[2]; @@ -893,7 +893,7 @@ bool has_collided_with_player_and_within_height(s32 objectIndex, Player *player, y = -y; } if ((((x * x) + (z * z)) <= (distance * distance)) && (y <= distance_y)) { - var_v1 = TRUE; + var_v1 = true; } return var_v1; } @@ -914,13 +914,13 @@ UNUSED bool func_80088F94(s32 objectIndex, Player *player, f32 arg2) { bool var_v1; distance = gObjectList[objectIndex].pos[1] - player->unk_074; - var_v1 = FALSE; + var_v1 = false; // abs(distance) if (distance < 0.0f) { distance = -distance; } if (distance <= arg2) { - var_v1 = TRUE; + var_v1 = true; } return var_v1; } @@ -1238,7 +1238,7 @@ s32 func_8008A060(s32 objectIndex, Camera *camera, u16 arg2) { var_v1 = 0; temp_t3 = (((u16)camera->rot[1] - gObjectList[objectIndex].direction_angle[1]) + (arg2 >> 1)); - + //! @warning Always true if ((temp_t3 >= 0) && (arg2 >= temp_t3)) { var_v1 = 1; @@ -1266,10 +1266,10 @@ bool is_object_visible_on_camera(s32 objectIndex, Camera *camera, u16 angle) { u16 temp_t2; s32 var_t0; - var_t0 = FALSE; + var_t0 = false; temp_t2 = (get_angle_between_xy(camera->pos[0], gObjectList[objectIndex].pos[0], camera->pos[2], gObjectList[objectIndex].pos[2]) + ((s32) angle / 2)) - camera->rot[1]; if ((temp_t2 >= 0) && (angle >= temp_t2)) { - var_t0 = TRUE; + var_t0 = true; } return var_t0; } diff --git a/src/code_80091440.c b/src/code_80091440.c index 45201bedf..b6c02d8d3 100644 --- a/src/code_80091440.c +++ b/src/code_80091440.c @@ -16,10 +16,8 @@ void func_800914A0(void) { UNUSED void func_800914E0(void) { UNUSED Vec3f sp64 = {0.0f, -20.0f, 150.0f}; UNUSED Vec3f sp58 = {0.0f, -6.0f, 4.0f}; - uintptr_t segment = SEGMENT_NUMBER2(D_8015F718[0]); - uintptr_t offset = SEGMENT_OFFSET(D_8015F718[0]); Camera *camera = &cameras[0]; - struct ActorSpawnData *sp48 = (struct ActorSpawnData *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + struct ActorSpawnData *sp48 = D_8015F718[0]; struct ActorSpawnData *tempData; s16 temp3 = (s16) D_80152308; @@ -31,7 +29,7 @@ UNUSED void func_800914E0(void) { camera->up[0] = 0; camera->up[1] = 1; camera->up[2] = 0; - + if(1) {} // waa? temp = temp2 - temp3; diff --git a/src/code_80091440.h b/src/code_80091440.h index 18aa89297..a8956a0ac 100644 --- a/src/code_80091440.h +++ b/src/code_80091440.h @@ -1,7 +1,7 @@ #ifndef CODE_80091440_H #define CODE_80091440_H -#include "ultra64.h" +#include void func_80091440(s8); void func_800914A0(void); diff --git a/src/code_80091750.c b/src/code_80091750.c index 223856122..661789ca8 100644 --- a/src/code_80091750.c +++ b/src/code_80091750.c @@ -1,9 +1,9 @@ -#include +#include #include #include #include #include -#include +#include #include #include "code_800029B0.h" #include "code_80091750.h" @@ -1498,7 +1498,7 @@ void func_80091EE4(void) { if ((D_8018EDFB != 0) && (tmp == 0)) { temp_s2 = (gCupSelection * 4) + gCupCourseSelection; func_800B6708(); - + for (temp_s0 = 0; temp_s0 < 2; ++temp_s0) { if ((D_8018EE10[temp_s0].ghostDataSaved != 0) && (temp_s2 == D_8018EE10[temp_s0].courseIndex)) { func_800B64EC(temp_s0); @@ -1612,7 +1612,7 @@ void func_80092290(s32 arg0, s32 *arg1, s32 *arg2) { if ((arg0 < 4) || (arg0 >= 6)) { return; } idx = (((arg0 * 4) + ((gGlobalTimer % 2) * 2)) - 6); - + *arg2 += 16; if (*arg2 >= 256) { *arg2 = 0; @@ -2739,7 +2739,7 @@ Gfx *draw_flash_select_case(UNUSED Gfx *displayListHead, s32 ulx, s32 uly, s32 l if (greyscale > 0xFF) { // set max greyscale to 0xFF greyscale = 0xFF; } - + #if AVOID_UB return gDisplayListHead = draw_box_fill(gDisplayListHead, ulx, uly, lrx, lry, greyscale, greyscale, greyscale, 0xFF); #else @@ -2832,7 +2832,7 @@ void func_80095AE0(Mtx2 *arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4) { arg0->u.i[1][1] = sp10.s[0]; arg0->u.i[2][2] = 1; arg0->u.i[3][0] = spC.s[0]; - arg0->u.i[3][1] = sp8.s[0]; + arg0->u.i[3][1] = sp8.s[0]; arg0->u.i[3][3] = 1; arg0->u.f[0][0] = sp14.s[1]; arg0->u.f[1][1] = sp10.s[1]; @@ -2964,7 +2964,7 @@ Gfx *func_80095E10(Gfx *displayListHead, s8 arg1, s32 arg2, s32 arg3, s32 arg4, arg8 += var_t0; } - + arg8 = sp7C; arg9 += temp_lo; } @@ -3062,7 +3062,7 @@ Gfx *func_800963F0(Gfx *displayListHead, s8 arg1, s32 arg2, s32 arg3, f32 arg4, argA += var_t0 * arg4; } - + argA = sp7C; argB += temp_lo * arg5; } @@ -3162,7 +3162,7 @@ Gfx *func_80096CD8(Gfx *displayListHead, s32 arg1, s32 arg2, u32 width, u32 arg4 G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); gSPTextureRectangle(displayListHead++, var_s1_3 * 4, var_fp * 4, (var_s1_3 + var_a1) * 4, (var_fp + var_v0) * 4, 0, (var_s1_3 * 32) & 0xFFFF, (var_fp * 32) & 0xFFFF, 1024, 1024); - + } } @@ -3256,14 +3256,14 @@ Gfx *func_80097274(Gfx *displayListHead, s8 arg1, s32 arg2, s32 arg3, s32 arg4, } else { var_s2 = var_t0; } - - gDPLoadMultiTile(displayListHead++, arg1, 0, G_TX_RENDERTILE, arg2, G_IM_SIZ_16b, - argB, argC, var_a1_2, var_s3, var_a1_2 + var_s2, var_s3 + var_s4, 0, + + gDPLoadMultiTile(displayListHead++, arg1, 0, G_TX_RENDERTILE, arg2, G_IM_SIZ_16b, + argB, argC, var_a1_2, var_s3, var_a1_2 + var_s2, var_s3 + var_s4, 0, G_TX_WRAP, G_TX_WRAP, sp68, sp64, G_TX_NOLOD, G_TX_NOLOD); - gDPLoadMultiTile(displayListHead++, D_0B002A00 + random_int(128) * 2, 256, G_TX_RENDERTILE+1, arg2, G_IM_SIZ_16b, - argB, argC, var_a1_2, var_s3, var_a1_2 + var_s2, var_s3 + var_s4, 0, + gDPLoadMultiTile(displayListHead++, D_0B002A00 + random_int(128) * 2, 256, G_TX_RENDERTILE+1, arg2, G_IM_SIZ_16b, + argB, argC, var_a1_2, var_s3, var_a1_2 + var_s2, var_s3 + var_s4, 0, G_TX_WRAP, G_TX_WRAP, sp68, sp64, G_TX_NOLOD, G_TX_NOLOD); gSPTextureRectangle(displayListHead++, arg8 * 4, arg9 * 4, (arg8 + var_s2) * 4, (arg9 + var_s4) * 4, 0, @@ -3271,7 +3271,7 @@ Gfx *func_80097274(Gfx *displayListHead, s8 arg1, s32 arg2, s32 arg3, s32 arg4, arg8 += var_t0; } - + arg8 = sp7C; arg9 += temp_lo; } @@ -3514,9 +3514,9 @@ void func_80099110(void) { /** * Differs from memory.c with `+ 0x8` instead of `| 0x8` - * - * @param addr - * @return void* + * + * @param addr + * @return void* */ void *segmented_to_virtual_dupe(const void *addr) { size_t segment = (uintptr_t) addr >> 24; @@ -3808,9 +3808,9 @@ void func_80099AEC(void) { var_s4 = 0; var_s1 = D_8018E060; temp_s2 = var_s1->texture; - + if (temp_s2 == NULL) return; - + huh = temp_s2->size; if (huh != 0) { var_s0 = huh; @@ -3907,9 +3907,9 @@ void func_80099EC4(void) { var_s4 = 0; var_s1 = D_8018E0E8; temp_s2 = var_s1->mk64Texture; - + if (temp_s2 == NULL) return; - + huh = temp_s2->size; if (huh != 0) { var_s0 = huh; @@ -4393,11 +4393,11 @@ Gfx *func_8009B9D0(Gfx *displayListHead, MkTexture *textures) { bool found; s32 index; - found = FALSE; + found = false; for (index = 0; index < D_8018E768_SIZE; index++) { if (D_8018E768[index].textures == segmented_to_virtual_dupe(textures)) { displayList = D_8018E768[index].displayList; - found = TRUE; + found = true; break; } } @@ -6435,7 +6435,7 @@ void func_800A08D8(u8 arg0, s32 column, s32 row) { s32 func_800A095C(char *someString, s32 len, s32 column, s32 row) { s32 tempColumn; s32 nonTerminatorCount; - + nonTerminatorCount = 0; tempColumn = column; for (; len != 0; len--, tempColumn += 8) { @@ -7995,7 +7995,7 @@ void func_800A5738(struct_8018D9E0_entry *arg0) { void func_800A6034(struct_8018D9E0_entry *arg0) { char *text; - if (D_801657E8 != TRUE) { + if (D_801657E8 != true) { gDPSetPrimColor(gDisplayListHead++, 0, 0, 0x00, 0x00, 0x00, arg0->unk1C); text = gCupNames[D_800DC540]; set_text_color(TEXT_BLUE_GREEN_RED_CYCLE_2); @@ -10006,7 +10006,7 @@ struct_8018D9E0_entry *func_800AAE68(void) { } // Something VERY wrong has occurred - while(TRUE); + while(true); escape: return entry; } @@ -10026,7 +10026,7 @@ struct_8018D9E0_entry *func_800AAEB4(s32 arg0) { } // Something VERY wrong has occurred - while(TRUE); + while(true); escape: return entry; } @@ -10036,7 +10036,7 @@ escape: * search for. If no entry with that "type" is found, this * function will enter a `while(1)` loop, hard-locking the * game. - * + * * In practice this never appears to happen, but that is * probably as much a matter of luck as it is good * reasoning on the original author(s) part. @@ -10050,7 +10050,7 @@ struct_8018D9E0_entry *find_8018D9E0_entry_dupe(s32 arg0) { } // Something VERY wrong has occurred - while(TRUE); + while(true); escape: return entry; } diff --git a/src/code_800AF9B0.c b/src/code_800AF9B0.c index 07c2222ff..361087020 100644 --- a/src/code_800AF9B0.c +++ b/src/code_800AF9B0.c @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -91,7 +91,7 @@ void func_800AFC54(Vtx *arg0, s32 arg1, s32 arg2, s32 arg3, s16 arg4[3]) { a1 = &arg0[arg1]; a2 = &arg0[arg2]; - a3 = &arg0[arg3]; + a3 = &arg0[arg3]; saved1 = a2->v.ob[0]; saved2 = a2->v.ob[1]; @@ -154,7 +154,7 @@ void func_800AFF58(Vtx *arg0) { UNUSED u32 pad88[26]; s32 i, j; s16 sp40[12][3]; - + for (i = 0, j = 0; i < ARRAY_COUNT(sp40); i++, j += 4) { func_800AFC54(&arg0[j], 1, 2, 0, sp40[i]); } diff --git a/src/crash_screen.c b/src/crash_screen.c index 0208862be..1afe58019 100644 --- a/src/crash_screen.c +++ b/src/crash_screen.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -99,11 +99,11 @@ GLOBAL_ASM("asm/non_matchings/crash_screen/crash_screen_draw_square.s") * Line 1: threadId - address of faulted instruction - error code * Line 2: Address in the return address register * Line 3: Machine code of faulted instruction - * + * * The R4300i manual discusses exceptions in more depth. - * - * @param framebuffer - * @param faulted thread + * + * @param framebuffer + * @param faulted thread **/ // 0xRGBA @@ -203,16 +203,16 @@ void thread9_crash_screen(UNUSED void *arg0) osSetEventMesg(10, &D_80162D40, (OSMesg) 16); sButtonSequenceIndex = 0; - while (TRUE) { + while (true) { osRecvMesg(&D_80162D40, &mesg, 1); thread = get_faulted_thread(); - + if (thread) { // Run only on the first iteration. if (sCounter == 0) { crash_screen_draw_square(pFramebuffer); #ifndef DEBUG - while(TRUE) + while(true) { read_controllers(); @@ -235,9 +235,9 @@ void thread9_crash_screen(UNUSED void *arg0) #else crash_screen_draw_info(pFramebuffer, thread); #endif - + } - if (sCounter < 5) { + if (sCounter < 5) { sCounter++; } } diff --git a/src/crash_screen.h b/src/crash_screen.h index 44ea6619d..bdcab16ea 100644 --- a/src/crash_screen.h +++ b/src/crash_screen.h @@ -1,7 +1,7 @@ #ifndef CRASH_SCREEN_H #define CRASH_SCREEN_H -#include +#include #include extern u16 *pFramebuffer; diff --git a/src/data/data_segment2.c b/src/data/data_segment2.c index 2d72f4398..54e98c666 100644 --- a/src/data/data_segment2.c +++ b/src/data/data_segment2.c @@ -1,6 +1,6 @@ #include -#include -#include +#include +#include #include "data_segment2.h" #include diff --git a/src/data/some_data.h b/src/data/some_data.h index 3d70b3158..96ab00f5e 100644 --- a/src/data/some_data.h +++ b/src/data/some_data.h @@ -1,7 +1,7 @@ #ifndef SOME_DATA_H #define SOME_DATA_H -#include "PR/gbi.h" +#include #include "spline.h" #include "data/other_textures.h" #include "objects.h" diff --git a/src/data/trig_tables_bss.c b/src/data/trig_tables_bss.c index aa2bc38d1..6caec65c2 100644 --- a/src/data/trig_tables_bss.c +++ b/src/data/trig_tables_bss.c @@ -1,4 +1,4 @@ -#include +#include #include /** diff --git a/src/data_segment2.h b/src/data_segment2.h index f69f6a4d0..4dd9913e1 100644 --- a/src/data_segment2.h +++ b/src/data_segment2.h @@ -1,7 +1,7 @@ #ifndef DATA_SEGMENT2_H #define DATA_SEGMENT2_H -#include +#include extern Vtx D_02007B38[]; diff --git a/src/debug/all_variables.h b/src/debug/all_variables.h index 561a23ea6..73b15e69d 100644 --- a/src/debug/all_variables.h +++ b/src/debug/all_variables.h @@ -63,7 +63,7 @@ #include #include #include "buffers/trig_tables.h" -#include +#include #include #include diff --git a/src/debug/crash_screen_enhancement.c b/src/debug/crash_screen_enhancement.c index 574b3f531..4c05f28ae 100644 --- a/src/debug/crash_screen_enhancement.c +++ b/src/debug/crash_screen_enhancement.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -126,9 +126,9 @@ void crash_screen_print(s32 x, s32 y, const char *fmt, ...) { void crash_screen_sleep(s32 ms) { u64 cycles = ms * 1000LL * osClockRate / 1000000ULL; - osSetTime(0); - while (osGetTime() < cycles) { - } + // osSetTime(0); + // while (osGetTime() < cycles) { + // } } void crash_screen_print_float_reg(s32 x, s32 y, s32 regNum, void *addr) { @@ -215,6 +215,6 @@ void crash_screen_draw(OSThread* thread) { crash_screen_print_float_reg(120, 210, 26, &tc->fp26.f.f_even); crash_screen_print_float_reg(210, 210, 28, &tc->fp28.f.f_even); crash_screen_print_float_reg(30, 220, 30, &tc->fp30.f.f_even); - osViBlack(FALSE); + osViBlack(false); osViSwapBuffer(pFramebuffer); } diff --git a/src/debug/crash_screen_enhancement.h b/src/debug/crash_screen_enhancement.h index 9f9a321ca..5860f9226 100644 --- a/src/debug/crash_screen_enhancement.h +++ b/src/debug/crash_screen_enhancement.h @@ -1,7 +1,7 @@ #ifndef CRASH_SCREEN_ENHANCEMENT_H #define CRASH_SCREEN_ENHANCEMENT_H -#include +#include #include void crash_screen_draw(OSThread* thread); diff --git a/src/debug/debug.c b/src/debug/debug.c index cdc333dc5..f5daa4397 100644 --- a/src/debug/debug.c +++ b/src/debug/debug.c @@ -1,4 +1,4 @@ -#include +#include #include #include "debug.inc.c" #include @@ -82,14 +82,14 @@ static u32 variable_to_u64(variableWatchAttributes *attribute) { u32 variable; switch (attribute->variableSize) { - case sizeof(u8): + case sizeof(u8): variable = *((u8*) attribute->variablePointer); break; - case sizeof(u16): + case sizeof(u16): variable = *((u16*) attribute->variablePointer); break; case sizeof(u32): - case sizeof(u64): + case sizeof(u64): variable = *((u32*) attribute->variablePointer); // no floating point rounding break; default: @@ -103,7 +103,7 @@ static void round_up_float(u32 *variable, u8 variableSize) { switch (variableSize) { case sizeof(u64): case sizeof(u32): - *variable = (u32) (*(f32*) &*variable); + *variable = (u32) (*(f32*) &*variable); break; default: sDisplayListState = BAD; @@ -131,7 +131,7 @@ static void u64_to_string(variableWatchAttributes *attribute, u32 variable, u8 b switch (variableSize) { case sizeof(u8): signedVariable = (s8) variable; - if (signedVariable < 0) { + if (signedVariable < 0) { signedVariable = -signedVariable; variable = (u8) signedVariable; *bufferedString = '-'; @@ -150,7 +150,7 @@ static void u64_to_string(variableWatchAttributes *attribute, u32 variable, u8 b case sizeof(u32): case sizeof(u64): signedVariable = (s32) variable; - if (signedVariable < 0) { + if (signedVariable < 0) { signedVariable = -signedVariable; variable = (u32) signedVariable; *bufferedString = '-'; @@ -164,11 +164,11 @@ static void u64_to_string(variableWatchAttributes *attribute, u32 variable, u8 b // convert u64 into a string but it gets put in reverse if (base != HEXIDECIMAL) { - do { + do { stringLength++; *bufferedString = variable % base + '0'; bufferedString++; - variable /= base; + variable /= base; } while (variable != 0); } else { do { @@ -186,8 +186,8 @@ static void u64_to_string(variableWatchAttributes *attribute, u32 variable, u8 b } while (variable != 0); } - bufferedString -= stringLength; - upperIndex = stringLength - 1; + bufferedString -= stringLength; + upperIndex = stringLength - 1; // flip string 4321 --> 1234 for (lowerIndex = 0; lowerIndex < stringLength >> 1; lowerIndex++) { @@ -228,7 +228,7 @@ static void u64_to_string(variableWatchAttributes *attribute, u32 variable, u8 b static u32 _strlen(const char *str) { u32 len; - + len = 0; for (; *str != '\0'; str++) { len++; @@ -245,7 +245,7 @@ static void _memcpy(char *destStr, const char *copyStr, u32 copySize) { *destStr = *copyStr; destStr++; copyStr++; - } + } } #endif diff --git a/src/debug/debug.inc.c b/src/debug/debug.inc.c index 758bf3600..82f26be03 100644 --- a/src/debug/debug.inc.c +++ b/src/debug/debug.inc.c @@ -1,4 +1,4 @@ -#include +#include #include #include "all_variables.h" @@ -6,7 +6,7 @@ extern s32 gGlobalTimer; -/** +/** * Edit this to edit what displays on the screen while the DVDL is active. * The Size of the structure array is calculated at compile time. */ @@ -14,42 +14,42 @@ variableWatchAttributes gMainVariableWatchList[] = { { "Global Timer: ", &gGlobalTimer, - sizeof(gGlobalTimer), + sizeof(gGlobalTimer), DISPLAY_DECIMAL_NUMBER | DISPLAY_SIGNED_NUMBER, 0, 0 }, { "Actors: ", &gNumActors, - sizeof(gNumActors), + sizeof(gNumActors), DISPLAY_DECIMAL_NUMBER, 0, 0 }, { "Player Type: ", &gPlayers[0].type, - sizeof(gPlayerOne->type), + sizeof(gPlayerOne->type), DISPLAY_HEXIDECIMAL_NUMBER, 0, 0 }, { "X ", &gPlayers[0].pos[0], - sizeof(gPlayerOne->pos[0]), + sizeof(gPlayerOne->pos[0]), DISPLAY_FLOAT_NUMBER, 0, 0 }, { "Y ", &gPlayers[0].pos[1], - sizeof(gPlayerOne->pos[1]), + sizeof(gPlayerOne->pos[1]), DISPLAY_FLOAT_NUMBER, 0, 0 }, { "Z ", &gPlayers[0].pos[2], - sizeof(gPlayerOne->pos[2]), + sizeof(gPlayerOne->pos[2]), DISPLAY_FLOAT_NUMBER, 0, 0 }, diff --git a/src/effects.c b/src/effects.c index 52c5127e2..d8614722d 100644 --- a/src/effects.c +++ b/src/effects.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -186,14 +186,14 @@ void clean_effect(Player *player, s8 arg1) { if ((player->effects & 0x400) == 0x400) { func_8008C6D0(player, arg1); } - + if (((player->effects & 0x80) == 0x80) || (player->effects & 0x40) == 0x40) { func_8008C8C4(player, arg1); } if ((player->effects & 0x800) == 0x800) { func_8008D0E4(player, arg1); } - if ((player->unk_044 & 0x4000) != 0) { + if ((player->unk_044 & 0x4000) != 0) { func_8008D3B0(player, arg1); } if ((player->effects & BOOST_EFFECT) == BOOST_EFFECT) { @@ -311,7 +311,7 @@ void func_8008C73C(Player *player, s8 arg1) { D_80165190[3][arg1] = 1; D_80165280[arg1] = player->currentSpeed; gTimerBoostTripleACombo[arg1] = 0; - gIsPlayerTripleAButtonCombo[arg1] = FALSE; + gIsPlayerTripleAButtonCombo[arg1] = false; gCountASwitch[arg1] = 0; gFrameSinceLastACombo[arg1] = 0; D_8018D920[arg1] = 0; @@ -340,7 +340,7 @@ void func_8008C8C4(Player* player, s8 playerId) { player->unk_046 &= 0xFFBF; - if ((gIsPlayerTripleAButtonCombo[playerId] == TRUE) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { + if ((gIsPlayerTripleAButtonCombo[playerId] == true) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { player->currentSpeed = (f32) (player->currentSpeed + 100.0f); } if ((gModeSelection == VERSUS) && ((player->type & PLAYER_KART_AI) == PLAYER_KART_AI) && (!gDemoMode) && ((player->unk_0CA & 2) == 0) && (gGPCurrentRaceRankByPlayerId[playerId] != 0)) { @@ -394,7 +394,7 @@ void func_8008C9EC(Player *player, s8 arg1) { } } } - if ((gIsPlayerTripleAButtonCombo[arg1] == TRUE) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { + if ((gIsPlayerTripleAButtonCombo[arg1] == true) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { gTimerBoostTripleACombo[arg1] = 0x00000078; if (player->currentSpeed <= 90.0f) { player->currentSpeed = 90.0f; @@ -410,7 +410,7 @@ void func_8008CDC0(Player* player, s8 arg1) { player->unk_0B8 = 3.0f; player->unk_0AC = 1; player->effects &= ~0x10; - + if (((player->unk_07C >> 0x10) >= 0x14) || ((player->unk_07C >> 0x10) < -0x13) || (((player->unk_094 / 18.0f) * 216.0f) <= 30.0f) || ((player->effects & 8) != 0) || (((player->type & PLAYER_HUMAN) == 0) && ((player->effects & 0x1000) == 0))) { func_8008C73C(player, arg1); } @@ -548,7 +548,7 @@ void apply_boost_sound_effect(Player* player, s8 arg1) { player->soundEffects &= ~BOOST_SOUND_EFFECT; player->unk_DB4.unk0 = 0; player->unk_DB4.unk8 = 8.0f; - + if (D_8015F890 != 1) { if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { func_800C9250(arg1); @@ -575,7 +575,7 @@ void apply_boost_effect(Player* player) { } else { move_f32_towards(&player->boostPower, 0.0f, 0.1f); } - + if (player->boostPower <= 1.0f) { player->effects &= ~BOOST_EFFECT; } @@ -613,7 +613,7 @@ void func_8008D570(Player *player, s8 arg1) { void func_8008D698(Player* player, s8 arg1) { s16 temp; - + if (player->unk_0B2 == 0) { player->rotation[1] = player->unk_0AE; temp = 0; @@ -758,7 +758,7 @@ void apply_hit_effect(Player* player, s8 arg1) { player->currentSpeed = 0.0f; if ((player->unk_110.unk3C[2] >= 600.0f) || ((player->effects & 0x1000) != 0)) { D_8018D990[arg1] = 3; } // placed block on same line to match - switch (D_8018D990[arg1]) { + switch (D_8018D990[arg1]) { case 0: player->unk_DB4.unk10 = 4.5f; if (player->unk_238 < 0x3D) { @@ -792,7 +792,7 @@ void apply_hit_effect(Player* player, s8 arg1) { player->unk_DB4.unk10 = 4.5f; player->pos[1] += 0.13; ++player->unk_238; - + if ((player->unk_046 & 0x80) != 0) { if (player->unk_238 >= 0x32) { D_8018D990[arg1] = 2; @@ -868,9 +868,9 @@ void apply_hit_rotating_sound_effect(Player* player, s8 arg1) { player->unk_0AE = player->rotation[1]; player->unk_0B2 = 2; player->unk_0C0 = 0; - player->unk_07C = 0; + player->unk_07C = 0; player->unk_078 = 0; - + D_80165190[0][arg1] = 1; D_80165190[1][arg1] = 1; D_80165190[2][arg1] = 1; @@ -942,18 +942,18 @@ void apply_lightning_effect(Player *player, s8 arg1) { void remove_lightning_effect(Player* player, UNUSED s8 arg1) { move_f32_towards(&player->size, 1.0f, 0.1f); move_f32_towards(&player->boundingBoxSize, gKartBoundingBoxSizeTable[player->characterId], 0.1f); - + player->effects &= ~LIGHTNING_EFFECT; player->size = 1.0f; player->boundingBoxSize = gKartBoundingBoxSizeTable[player->characterId]; player->unk_DB4.unk10 = 3.0f; player->unk_DB4.unk2 = 0; player->effects |= 0x08000000; - + if ((player->effects & 0x20000) == 0x20000) { player->rotation[1] = player->unk_0AE; } - + player->effects &= ~0x20000; } @@ -985,7 +985,7 @@ void func_8008E4A4(Player* player, s8 arg1) { player->unk_042 = 0; player->type &= ~0x80; - if ((gIsPlayerTripleAButtonCombo[arg1] == TRUE) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { + if ((gIsPlayerTripleAButtonCombo[arg1] == true) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { player->currentSpeed += 100.0f; } if (gModeSelection == BATTLE) { @@ -1008,7 +1008,7 @@ void func_8008E4A4(Player* player, s8 arg1) { if (gModeSelection == BATTLE) { func_8006B8B4(player, arg1); } - if ((gIsPlayerTripleAButtonCombo[arg1] == TRUE) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { + if ((gIsPlayerTripleAButtonCombo[arg1] == true) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { player->currentSpeed += 100.0f; } @@ -1055,7 +1055,7 @@ void apply_reverse_sound_effect(Player *player, s8 arg1) player->soundEffects &= ~(REVERSE_SOUND_EFFECT | 0x80000); player->unk_0B6 |= 0x40; gTimerBoostTripleACombo[arg1] = 0; - gIsPlayerTripleAButtonCombo[arg1] = FALSE; + gIsPlayerTripleAButtonCombo[arg1] = false; gCountASwitch[arg1] = 0; gFrameSinceLastACombo[arg1] = 0; } @@ -1096,7 +1096,7 @@ void apply_hit_by_item_effect(Player *player, s8 arg1) { D_80165190[2][arg1] = 1; player->unk_042 = 0; - if ((gIsPlayerTripleAButtonCombo[arg1] == TRUE) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { + if ((gIsPlayerTripleAButtonCombo[arg1] == true) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { player->currentSpeed += 100.0f; } @@ -1116,7 +1116,7 @@ void apply_hit_by_item_effect(Player *player, s8 arg1) { D_80165190[2][arg1] = 1; D_80165190[3][arg1] = 1; player->unk_042 = 0; - if ((gIsPlayerTripleAButtonCombo[arg1] == TRUE) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { + if ((gIsPlayerTripleAButtonCombo[arg1] == true) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { player->currentSpeed += 100.0f; } @@ -1142,20 +1142,20 @@ void apply_hit_by_item_sound_effect(Player* player, s8 arg1) { player->unk_236 = 4; player->unk_042 = 0; player->unk_0E0 = 0; - + if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { func_800C90F4(arg1, (player->characterId * 0x10) + 0x29008005); func_800C9060(arg1, SOUND_ACTION_EXPLOSION); } else { func_800098FC(arg1, player); } - + player->effects |= HIT_BY_ITEM_EFFECT; player->unk_0B6 |= 0x40; player->soundEffects &= ~0x01000002; gTimerBoostTripleACombo[arg1] = 0; - gIsPlayerTripleAButtonCombo[arg1] = FALSE; + gIsPlayerTripleAButtonCombo[arg1] = false; gCountASwitch[arg1] = 0; gFrameSinceLastACombo[arg1] = 0; } @@ -1247,7 +1247,7 @@ void apply_boost_ramp_wood_effect(Player* player) { } else { move_f32_towards(&player->boostPower, 300.0f, 0.1f); } - + if (player->boostPower <= 1.0f) { player->effects &= ~BOOST_RAMP_WOOD_EFFECT; player->boostPower = 0.0f; @@ -1268,10 +1268,10 @@ void func_8008F104(Player* player, s8 arg1) { player->unk_0B2 = 2; player->unk_0C0 = 0; player->unk_07C = 0; - player->effects |= 0x4000; + player->effects |= 0x4000; player->unk_078 = 0; D_8018D920[arg1] = -0x8000; - + if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { func_800C90F4(arg1, (player->characterId * 0x10) + 0x29008003); } @@ -1358,13 +1358,13 @@ void func_8008F494(Player* player, s8 arg1) { clean_effect(player, arg1); func_8008F86C(player, arg1); - + player->unk_0A8 = 0; player->effects |= 0x10000; player->effects &= ~0x10; player->unk_236 = 0x1E; player->unk_042 = 0; - + if (((player->type & PLAYER_HUMAN) != 0) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) == 0) && ((player->unk_0CA & 2) == 0) && @@ -1380,7 +1380,7 @@ void func_8008F5A4(Player* player, s8 arg1) { func_8006B8B4(player, arg1); player->unk_044 &= ~0x8000; } - + player->unk_206 = 0; player->slopeAccel = 0; player->effects &= ~0x10000; @@ -1453,7 +1453,7 @@ void apply_boo_effect(Player* arg0, s8 arg1) { tmp = ((s32) gCourseTimer) - D_8018D950[arg1]; if (tmp < 7) { arg0->unk_0C6 -= 2; - + if (arg0->unk_0C6 < 0x61) { arg0->unk_0C6 = 0x60; } @@ -1489,7 +1489,7 @@ void apply_boo_sound_effect(Player* player, s8 arg1) { if ((player->type & PLAYER_HUMAN) != 0) { player->unk_044 |= 0x200; - + for (temp_v1 = 0; temp_v1 < 10; ++temp_v1) { player->unk_258[temp_v1].unk_01C = 0; player->unk_258[temp_v1].unk_01E = 0; @@ -1549,7 +1549,7 @@ void func_8008FC64(Player* player, s8 arg1) { player->soundEffects &= 0xFBFFFFFF; player->soundEffects |= 0x08000000; player->type |= PLAYER_UNKNOWN_0x40; - + func_8008FDA8(player, arg1); func_800569F4(arg1); } @@ -1567,7 +1567,7 @@ void func_8008FCDC(Player* player, s8 arg1) { void func_8008FD4C(Player* player, UNUSED s8 arg1) { s16 temp_v0; - + player->soundEffects |= 0x04000000; player->unk_044 |= 0x200; @@ -1590,7 +1590,7 @@ void func_8008FDA8(Player* player, UNUSED s8 arg1) { void func_8008FDF4(Player* player, UNUSED s8 arg1) { clean_effect(player, arg1); - + player->effects &= ~0x10; player->kartHopJerk = D_800E37F0[player->characterId]; player->kartHopAcceleration = 0.0f; @@ -1649,9 +1649,9 @@ void func_8008FF08(Player *player, s8 playerId) { case COURSE_FRAPPE_SNOWLAND: waypoint = gNearestWaypointByPlayerId[playerId]; #ifdef VERSION_EU - if (((waypoint >= 0xF0) && (waypoint < 0x11E)) || + if (((waypoint >= 0xF0) && (waypoint < 0x11E)) || ((gCopyNearestWaypointByPlayerId[playerId] >= 0xF0) && (gCopyNearestWaypointByPlayerId[playerId] < 0x11E))) -#else +#else if ((waypoint >= 0xF0) && (waypoint < 0x105)) #endif { @@ -1791,7 +1791,7 @@ void func_80090778(Player* player) { clean_effect(player, playerIndex); func_8008F86C(player, playerIndex); - + player->unk_DB4.unk0 = 0; player->unk_0C2 = 0; player->unk_DB4.unk8 = 0.0f; @@ -2009,7 +2009,7 @@ void func_80090970(Player *player, s8 playerId, s8 arg2) { bool prevent_item_use(Player *player) { s32 phi_v0 = 0; if ((((((player->unk_0CA & 2) == 2) || ((player->unk_0CA & 8) == 8)) || ((player->type & PLAYER_UNKNOWN_0x40) != 0)) || ((player->type & PLAYER_CINEMATIC_MODE) != 0)) || ((player->type & PLAYER_EXISTS) == 0)) { - return TRUE; + return true; } switch (player->currentItemCopy) { @@ -2018,7 +2018,7 @@ bool prevent_item_use(Player *player) { case ITEM_TRIPLE_MUSHROOM: case ITEM_SUPER_MUSHROOM: if ((player->effects & 8) != 0) { - return TRUE; + return true; } phi_v0 = EFFECT_BLACKLIST_USE_ITEM; goto prevent_item_use_label; @@ -2029,9 +2029,9 @@ bool prevent_item_use(Player *player) { prevent_item_use_label: default: if ((player->effects & phi_v0) != 0) { - return TRUE; + return true; } - return FALSE; + return false; } } diff --git a/src/ending/camera_junk.c b/src/ending/camera_junk.c index ec709d0ff..808fd9bb0 100644 --- a/src/ending/camera_junk.c +++ b/src/ending/camera_junk.c @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -16,7 +16,7 @@ void setup_camera_podium_ceremony(void) { camera = &cameras[0]; func_80283648(camera); - + x_dist = camera->lookAt[0] - camera->pos[0]; y_dist = camera->lookAt[1] - camera->pos[1]; z_dist = camera->lookAt[2] - camera->pos[2]; diff --git a/src/ending/ceremony_and_credits.c b/src/ending/ceremony_and_credits.c index d12c5d276..a4ae32ee7 100644 --- a/src/ending/ceremony_and_credits.c +++ b/src/ending/ceremony_and_credits.c @@ -4,7 +4,7 @@ * Camera moves via splines. */ -#include +#include #include #include #include @@ -113,9 +113,9 @@ s32 f32_lerp(f32 *dest, f32 src, f32 lerp) { if (lerp > 1.0f) { lerp = 1.0f; } - + *dest = *dest + ((src - *dest) * lerp); - + if (src == *dest) { return 0; } @@ -133,7 +133,7 @@ UNUSED s32 func_80282200(Vec3s arg0, s16 arg1, s16 arg2) { temp_v0 += arg1; arg0[0] = temp_v0; } - + if (arg1 == arg0[0]) { return 0; } @@ -143,7 +143,7 @@ UNUSED s32 func_80282200(Vec3s arg0, s16 arg1, s16 arg2) { // Calculates fade in/out s32 set_transition_colour_fade_alpha_ending(f32 *arg0, f32 arg1, f32 arg2) { f32 temp_f0 = arg1 - *arg0; - + if (arg2 < 0.0f) { arg2 = -1.0f * arg2; } @@ -309,7 +309,7 @@ s32 move_point_along_spline(Vec3f p, f32 *arg1, struct struct_80283430 spline[], } func_80282700(u, p, arg1, controlPoints[0], controlPoints[1], controlPoints[2], controlPoints[3]); - + if (spline[*splineSegment + 1].unk2 != 0) { firstSpeed = 1.0f / spline[*splineSegment + 1].unk2; } @@ -356,10 +356,10 @@ void func_80282C40(struct struct_80283430 *arg0, struct struct_80282C40 *arg1, s s32 i = 0; s32 j = 0; func_80282BE4(&arg0[j], arg1[j].unk0, arg1[j].unk3, arg1[j].unk4, arg1[j].unk6, arg2); - + j++; goto dummy_label_888430; - while(TRUE) { + while(true) { do { dummy_label_888430: ; @@ -372,7 +372,7 @@ dummy_label_888430: ; func_80282BE4(&arg0[j], arg1->unk0, arg1[i].unk3, arg1[i].unk4, arg1[i].unk6, arg2); func_80282BE4(&arg0[j + 1], arg1->unk0, 0, arg1[i].unk4, arg1[i].unk6, arg2); func_80282BE4(&arg0[j + 2], arg1->unk0, 0, arg1[i].unk4, arg1[i].unk6, arg2); - func_80282BE4(&arg0[j + 3], -1, 0, arg1[i].unk4, arg1[i].unk6, arg2); + func_80282BE4(&arg0[j + 3], -1, 0, arg1[i].unk4, arg1[i].unk6, arg2); break; } } @@ -727,7 +727,7 @@ void func_80283BF0(UNUSED struct CinematicCamera *camera) { func_800C8EF8(0x1A); } -// +// void func_80283C14(UNUSED struct CinematicCamera *camera) { func_800C8EF8(0x1B); } @@ -1584,7 +1584,7 @@ void func_802847CC(struct CinematicCamera *camera) { } #endif - if (gCutsceneShotTimer == sp2C) { + if (gCutsceneShotTimer == sp2C) { if (D_80286A04[D_800DC5E4].unk0 != 2) { func_80280268(D_80286A04[D_800DC5E4 + 1].unk1); } @@ -1631,7 +1631,7 @@ void play_cutscene(struct CinematicCamera *camera) { #undef CUTSCENE if ((cutsceneDuration != 0) && ((gCutsceneShotTimer & 0xC000) == 0)) { - + if (gCutsceneShotTimer < 16383) { gCutsceneShotTimer++; } @@ -1651,12 +1651,12 @@ void play_cutscene(struct CinematicCamera *camera) { reset_spline(); } } - + } /** * Scene transition - * + * * Sliding black borders that open horizontally to display scene. * Used at the beginning of award ceremony and throughout credits. */ @@ -1681,4 +1681,3 @@ void transition_sliding_borders(void) { gDPSetCycleType(gDisplayListHead++, G_CYC_1CYCLE); set_transition_colour_fade_alpha_ending(&D_802856C0, D_802856B8, D_802856BC / D_802856B4); } - diff --git a/src/ending/code_80280000.c b/src/ending/code_80280000.c index f9f1fe824..c7351a09b 100644 --- a/src/ending/code_80280000.c +++ b/src/ending/code_80280000.c @@ -1,8 +1,7 @@ -#include +#include #include #include #include -#include #include #include @@ -50,7 +49,7 @@ void func_80280038(void) { func_802A53A4(); init_rdp(); func_80057FC4(0); - + gSPSetGeometryMode(gDisplayListHead++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_SHADING_SMOOTH); guPerspective(&gGfxPool->mtxPersp[0], &perspNorm, gCameraZoom[0], gScreenAspect, D_80150150, D_8015014C, 1.0f); gSPPerspNormalize(gDisplayListHead++, perspNorm); @@ -83,7 +82,7 @@ void func_80280268(s32 arg0) { void credits_loop(void) { Camera *camera = &cameras[0]; - + f32 temp_f12; f32 temp; f32 temp_f14; @@ -140,7 +139,7 @@ void load_credits(void) { load_course(gCurrentCourseId); D_8015F730 = gNextFreeMemoryAddress; set_segment_base_addr(0xB, (void *) decompress_segments((u8 *) CEREMONY_DATA_ROM_START, (u8 *) CEREMONY_DATA_ROM_END)); - + gCourseMinX = -0x15A1; gCourseMinY = -0x15A1; gCourseMinZ = -0x15A1; diff --git a/src/ending/code_80281780.c b/src/ending/code_80281780.c index 4b33160a1..367241e39 100644 --- a/src/ending/code_80281780.c +++ b/src/ending/code_80281780.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -21,6 +21,8 @@ #include "menus.h" #include "render_courses.h" +#define bcopy memcpy + u8 defaultCharacterIds[] = { 1, 2, 3, 4, 5, 6, 7, 0 }; diff --git a/src/ending/code_80281C40.c b/src/ending/code_80281C40.c index afc01f1de..7c6ff8f7a 100644 --- a/src/ending/code_80281C40.c +++ b/src/ending/code_80281C40.c @@ -1,5 +1,4 @@ -#include -#include +#include #include #include "code_80281C40.h" diff --git a/src/ending/code_80281C40.h b/src/ending/code_80281C40.h index 50ccc4f4e..23f356284 100644 --- a/src/ending/code_80281C40.h +++ b/src/ending/code_80281C40.h @@ -1,5 +1,5 @@ #ifndef CODE_80281C40_H -#define CODE_80281C40_h +#define CODE_80281C40_H /* Function Prototypes */ diff --git a/src/ending/credits.h b/src/ending/credits.h index 277cf0196..505bb6262 100644 --- a/src/ending/credits.h +++ b/src/ending/credits.h @@ -1,7 +1,7 @@ #ifndef CREDITS_H #define CREDITS_H -#include "PR/ultratypes.h" +#include #define SLIDE_RIGHT 0 #define SLIDE_LEFT 1 diff --git a/src/ending/dl_unk_80284EE0.c b/src/ending/dl_unk_80284EE0.c index 64282cb08..ada5ac8b0 100644 --- a/src/ending/dl_unk_80284EE0.c +++ b/src/ending/dl_unk_80284EE0.c @@ -1,5 +1,5 @@ -#include -#include +#include +#include #include "courses/royal_raceway/course_displaylists.inc.h" // Init RDP - RSP (Ceremony) diff --git a/src/ending/podium_ceremony_actors.c b/src/ending/podium_ceremony_actors.c index dc6a224d6..f6d5231c0 100644 --- a/src/ending/podium_ceremony_actors.c +++ b/src/ending/podium_ceremony_actors.c @@ -1,6 +1,5 @@ -#include +#include #include -#include #include #include #include @@ -90,7 +89,7 @@ void set_initial_position(CeremonyActor *actor) { actor->pos[0] = params->unk2[0]; actor->pos[1] = params->unk2[1]; actor->pos[2] = params->unk2[2]; - + // Place value in the high bits of s16. // Example: 85, 0b01010101 -> 0b0101010100000000 actor->unkA = params->unk8 << 8; @@ -149,7 +148,7 @@ u16 random_u16_credits(void) { temp1 = ((temp1 & 0x00FF) << 1) ^ sRandomSeed16; temp2 = (temp1 >> 1) ^ 0xFF80; - + if ((temp1 & 1) == 0) { if (temp2 == 43605) { sRandomSeed16 = 0; @@ -356,7 +355,7 @@ void spawn_firework_cone(s32 arg0, s32 arg1, s32 arg2) { cone->pos[0] = random_who_knows(0.0f) + arg0; cone->pos[1] = random_who_knows((f32) (D_802874B0[11] + 100)) + (f32) arg1; cone->pos[2] = random_who_knows((f32) (D_802874B0[12] + 700)) + (f32) arg2; - + num = 1.1f; // Wrap the counter from zero to three @@ -393,7 +392,7 @@ void spawn_timer(void) { } else if (D_802874D8.actorTimer == 2) { spawn_balloons(-0xC6C, (s32) ((f32) D_802874B0[10] + 210.0f), -0x1EF); } - + D_802874D8.actorTimer += 1; } @@ -475,7 +474,7 @@ void podium_ceremony_loop(void) { func_80281D00(); func_80281540(); #if DVDL - display_dvdl(); + display_dvdl(); #endif gDPFullSync(gDisplayListHead++); gSPEndDisplayList(gDisplayListHead++); diff --git a/src/gbiMacro.c b/src/gbiMacro.c index 18f131dce..d1f2fefe4 100644 --- a/src/gbiMacro.c +++ b/src/gbiMacro.c @@ -1,4 +1,4 @@ -#include +#include #include #include "PR/gu.h" #include "main.h" diff --git a/src/kart_dma.c b/src/kart_dma.c index faba825d3..97825a528 100644 --- a/src/kart_dma.c +++ b/src/kart_dma.c @@ -1,4 +1,4 @@ -#include +#include #include #include "main.h" #include "buffers.h" diff --git a/src/main.c b/src/main.c index 19eb4f4c5..74146d418 100644 --- a/src/main.c +++ b/src/main.c @@ -1,7 +1,7 @@ #ifndef GCC #define D_800DC510_AS_U16 #endif -#include +#include #include #include #include @@ -230,7 +230,7 @@ void thread1_idle(void *arg) { osViSetMode(&osViModeTable[OS_VI_MPAL_LAN1]); } #endif - osViBlack(TRUE); + osViBlack(true); osViSetSpecialFeatures(OS_VI_GAMMA_OFF); osCreatePiManager(OS_PRIORITY_PIMGR, &gPIMesgQueue, gPIMesgBuf, ARRAY_COUNT(gPIMesgBuf)); wasSoftReset = (s16) osResetType; @@ -241,7 +241,7 @@ void thread1_idle(void *arg) { osSetThreadPri(NULL, 0); // Halt - while (TRUE); + while (true); } void setup_mesg_queues(void) { @@ -306,9 +306,9 @@ void init_controllers(void) { osSetEventMesg(OS_EVENT_SI, &gSIEventMesgQueue, (OSMesg) 0x33333333); osContInit(&gSIEventMesgQueue, &gControllerBits, gControllerStatuses); if ((gControllerBits & 1) == 0) { - sIsController1Unplugged = TRUE; + sIsController1Unplugged = true; } else { - sIsController1Unplugged = FALSE; + sIsController1Unplugged = false; } } @@ -517,7 +517,7 @@ void setup_game_memory(void) { init_segment_racing(); gHeapEndPtr = SEG_RACING; set_segment_base_addr(0, (void *) SEG_START); - + // Memory pool size of 0xAB630 initialize_memory_pool(MEMORY_POOL_START, MEMORY_POOL_END); @@ -529,7 +529,7 @@ void setup_game_memory(void) { osRecvMesg(&gDmaMesgQueue, &gMainReceivedMesg, OS_MESG_BLOCK); set_segment_base_addr(2, (void *) load_data(SEG_DATA_START, SEG_DATA_END)); - + commonCourseDataSize = COMMON_TEXTURES_SIZE; commonCourseDataSize = ALIGN16(commonCourseDataSize); @@ -613,14 +613,14 @@ void race_logic_loop(void) { D_8015F788 = 0; render_player_one_1p_screen(); if (!gEnableDebugMode) { - D_800DC514 = FALSE; + D_800DC514 = false; } else { if (D_800DC514) { if ((gControllerOne->buttonPressed & R_TRIG) && (gControllerOne->button & A_BUTTON) && (gControllerOne->button & B_BUTTON)) { - D_800DC514 = FALSE; + D_800DC514 = false; } rotY = camera1->rot[1]; @@ -641,7 +641,7 @@ void race_logic_loop(void) { if ((gControllerOne->buttonPressed & L_TRIG) && (gControllerOne->button & A_BUTTON) && (gControllerOne->button & B_BUTTON)) { - D_800DC514 = TRUE; + D_800DC514 = true; } } } @@ -872,7 +872,7 @@ void game_state_handler(void) { (gControllerOne->button & Z_TRIG) && (gControllerOne->button & A_BUTTON)) { gGamestateNext = CREDITS_SEQUENCE; - } else if ((gControllerOne->button & L_TRIG) && + } else if ((gControllerOne->button & L_TRIG) && (gControllerOne->button & R_TRIG) && (gControllerOne->button & Z_TRIG) && (gControllerOne->button & B_BUTTON)) { @@ -1080,7 +1080,7 @@ void thread3_video(UNUSED void *arg0) { create_thread(&gGameLoopThread, 5, &thread5_game_loop, 0, gGameLoopThreadStack + ARRAY_COUNT(gGameLoopThreadStack), 10); osStartThread(&gGameLoopThread); - while (TRUE) { + while (true) { osRecvMesg(&gIntrMesgQueue, &msg, OS_MESG_BLOCK); switch ((u32) msg) { case MESG_VI_VBLANK: @@ -1147,7 +1147,7 @@ void update_gamestate(void) { gCurrentlyLoadedCourseId = COURSE_NULL; break; case RACING: - /** + /** * @bug Reloading this segment makes random_u16() deterministic for player spawn order. * In laymens terms, random_u16() outputs the same value every time. */ @@ -1189,7 +1189,7 @@ void thread5_game_loop(UNUSED void *arg) { read_controllers(); func_800C5CB8(); - while(TRUE) { + while(true) { func_800CB2C4(); // Update the gamestate if it has changed (racing, menus, credits, etc.). @@ -1215,7 +1215,7 @@ void thread4_audio(UNUSED void *arg) { osCreateMesgQueue(&sSoundMesgQueue, sSoundMesgBuf, ARRAY_COUNT(sSoundMesgBuf)); set_vblank_handler(1, &sSoundVblankHandler, &sSoundMesgQueue, (OSMesg) 512); - while (TRUE) { + while (true) { OSMesg msg; struct SPTask *spTask; diff --git a/src/main.h b/src/main.h index b1e37ea95..f760b9e44 100644 --- a/src/main.h +++ b/src/main.h @@ -1,6 +1,8 @@ #ifndef MAIN_H #define MAIN_H +#include "mk64.h" +#include "common_structs.h" // Message IDs #define MESG_SP_COMPLETE 100 diff --git a/src/math_util_2.c b/src/math_util_2.c index 2afe7f201..d5571ee4b 100644 --- a/src/math_util_2.c +++ b/src/math_util_2.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include "math_util_2.h" @@ -30,9 +30,9 @@ UNUSED void operator_xor(s32 *arg0, s32 arg1) { UNUSED bool func_80040E84(s32 *arg0, s32 arg1) { bool phi_v1; - phi_v1 = FALSE; + phi_v1 = false; if ((*arg0 & arg1) != 0) { - phi_v1 = TRUE; + phi_v1 = true; } return phi_v1; } @@ -455,10 +455,10 @@ bool is_particle_on_screen(Vec3f arg0, Camera *arg1, u16 arg2) { u16 temp_t9; s32 ret; - ret = FALSE; + ret = false; temp_t9 = (get_angle_between_xy(arg1->pos[0], arg0[0], arg1->pos[2], arg0[2]) + (arg2 / 2)) - arg1->rot[1]; if ((temp_t9 >= 0) && (arg2 >= temp_t9)) { - ret = TRUE; + ret = true; } return ret; } @@ -502,7 +502,7 @@ void mtfx_translation_x_y(Mat4 arg0, s32 x, s32 y) { * 1 0 0 x * 0 1 0 y * 0 0 1 0 - * 0 0 0 1 + * 0 0 0 1 */ } @@ -944,10 +944,10 @@ void vec3f_rotate_x_y(Vec3f dest, Vec3f pos, Vec3s rot) { /** * @brief set the matrix to a transformation matrix - * + * * @param translate or position - * @param orientation - * @param scale + * @param orientation + * @param scale */ void rsp_set_matrix_transformation(Vec3f translate, Vec3su orientation, f32 scale) { Mat4 matrix; diff --git a/src/menus.c b/src/menus.c index f8f07bd89..90d479081 100644 --- a/src/menus.c +++ b/src/menus.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -30,7 +30,7 @@ f32 D_8018EDD8; f32 D_8018EDDC; s32 D_8018EDE0; s8 gCharacterGridSelections[4]; // map from player id to current grid position -bool8 D_8018EDE8[4]; // map player id to isCharSelected on CSS +bool D_8018EDE8[4]; // map player id to isCharSelected on CSS s8 D_8018EDEC; s8 gMainMenuSelectionDepth; s8 D_8018EDEE; // grid screen state? @@ -240,7 +240,7 @@ void options_menu_act(struct Controller *controller, u16 arg1) { case 0x17: case 0x18: { - sp2C = FALSE; + sp2C = false; if ((btnAndStick & D_JPAD) && (D_8018EDEC < 0x18)) { D_8018EDEC += 1; play_sound2(SOUND_MENU_CURSOR_MOVE); @@ -248,7 +248,7 @@ void options_menu_act(struct Controller *controller, u16 arg1) { sp38->unk24 += 4.0; } sp38->unk8 = 1; - sp2C = TRUE; + sp2C = true; } if ((btnAndStick & U_JPAD) && (D_8018EDEC >= 0x16)) { D_8018EDEC -= 1; @@ -256,7 +256,7 @@ void options_menu_act(struct Controller *controller, u16 arg1) { if (sp38->unk24 < 4.2) { sp38->unk24 += 4.0; } - sp2C = TRUE; + sp2C = true; sp38->unk8 = -1; } if (sp2C && gSoundMode != sp38->cursor) { @@ -1008,7 +1008,7 @@ void splash_menu_act(struct Controller *controller, u16 arg1) { u16 i; s32 sp28; - sp28 = TRUE; + sp28 = true; btnAndStick = controller->buttonPressed | controller->stickPressed; if (func_800B4520() == 0) { @@ -1018,7 +1018,7 @@ void splash_menu_act(struct Controller *controller, u16 arg1) { switch (gDebugMenuSelection) { case DEBUG_MENU_DISABLED: { - sp28 = FALSE; + sp28 = false; if ((gMenuDelayTimer >= 0x2E) && (btnAndStick & (A_BUTTON | START_BUTTON))) { func_8009E1C0(); func_800CA330(0x19); @@ -1035,7 +1035,7 @@ void splash_menu_act(struct Controller *controller, u16 arg1) { if (gEnableDebugMode) { gEnableDebugMode = DEBUG_MODE; } else { - gEnableDebugMode = TRUE; + gEnableDebugMode = true; } } if (btnAndStick & D_JPAD) { @@ -1398,15 +1398,15 @@ void main_menu_act(struct Controller *controller, u16 arg1) { } // L800B3068 if (btnAndStick & D_JPAD) { - sp24 = FALSE; + sp24 = false; if (func_800B555C()) { if (sp28 < D_800F2B60[gPlayerCount + 4][D_800E86AC[gPlayerCount - 1] + 1]) { - sp24 = TRUE; + sp24 = true; } } else { // L800B30D4 if (sp28 < D_800F2B60[gPlayerCount][D_800E86AC[gPlayerCount - 1] + 1]) { - sp24 = TRUE; + sp24 = true; } } // L800B3110 @@ -1500,10 +1500,10 @@ bool is_character_spot_free(s32 gridId) { s32 i; for (i = 0; i < ARRAY_COUNT(gCharacterGridSelections); i++) { if (gridId == gCharacterGridSelections[i]) { - return FALSE; + return false; } } - return TRUE; + return true; } #ifdef NON_MATCHING @@ -1536,8 +1536,8 @@ void player_select_menu_act(struct Controller *controller, u16 arg1) { // L800B3630 if (btnAndStick & CONT_B) { if (D_8018EDE8[arg1]) { - D_8018EDE8[arg1] = FALSE; - play_sound2(0x49008002); + D_8018EDE8[arg1] = false; + play_sound2(SOUND_MENU_GO_BACK); } else { func_8009E208(); play_sound2(0x49008002); @@ -1545,15 +1545,15 @@ void player_select_menu_act(struct Controller *controller, u16 arg1) { } // L800B3684 if ((btnAndStick & CONT_A) && (D_8018EDE8[arg1] == 0)) { - D_8018EDE8[arg1] = TRUE; + D_8018EDE8[arg1] = true; i = D_800F2BAC[gCharacterGridSelections[arg1] - 1]; func_800C90F4(arg1, 0x2900800e + (i << 4)); } // L800B36F4 - selected = FALSE; + selected = false; for (i = 0; i < 4; i++) { // for (i = 0; i < ARRAY_COUNT(gCharacterGridSelections); i++) { if ((gCharacterGridSelections[i] != 0) && (D_8018EDE8[i] == 0)) { //(gCharacterGridSelections[i] && D_8018EDE8[i]) { - selected = TRUE; + selected = true; break; } } @@ -1667,13 +1667,13 @@ void player_select_menu_act(struct Controller *controller, u16 arg1) { } } // L800B3AA4 - if (btnAndStick & CONT_B) { + if (btnAndStick & B_BUTTON) { D_8018EDEE = 1; - D_8018EDE8[arg1] = FALSE; - play_sound2(0x49008002); + D_8018EDE8[arg1] = false; + play_sound2(SOUND_MENU_GO_BACK); break; } - if (btnAndStick & CONT_A) { + if (btnAndStick & A_BUTTON) { func_8009E1C0(); play_sound2(0x49008016); func_8000F124(); @@ -1920,7 +1920,7 @@ void func_800B3F74(s32 menuSelection) { } else { gCharacterGridSelections[i] = 0; } - D_8018EDE8[i] = FALSE; + D_8018EDE8[i] = false; gCharacterSelections[i] = i; } play_sound2(SOUND_MENU_SELECT_PLAYER); @@ -1931,7 +1931,7 @@ void func_800B3F74(s32 menuSelection) { gGamestateNext = 0; func_800C8EAC(2); for (i = 0; i < ARRAY_COUNT(D_8018EDE8); i++) { - D_8018EDE8[i] = FALSE; + D_8018EDE8[i] = false; } } break; @@ -1941,9 +1941,9 @@ void func_800B3F74(s32 menuSelection) { D_8018EDEE = 3; for (i = 0; i < ARRAY_COUNT(D_8018EDE8); i++) { if (gPlayerCount > i) { - D_8018EDE8[i] = TRUE; + D_8018EDE8[i] = true; } else { - D_8018EDE8[i] = FALSE; + D_8018EDE8[i] = false; } } break; @@ -2004,9 +2004,9 @@ void func_800B44BC(void) { bool func_800B4520(void) { if ((D_8018E7B0 == 2) || (D_8018E7B0 == 3) || (D_8018E7B0 == 4) || (D_8018E7B0 == 7)) { - return TRUE; + return true; } - return FALSE; + return false; } UNUSED void func_800B4560(s32 arg0, s32 arg1) { diff --git a/src/menus.h b/src/menus.h index 487697564..7d5101d03 100644 --- a/src/menus.h +++ b/src/menus.h @@ -1,7 +1,6 @@ #ifndef MENUS_H #define MENUS_H -#include "PR/os.h" #include "common_structs.h" #include diff --git a/src/os/_Printf.c b/src/os/_Printf.c index 0442e5fcc..cd57ceb60 100644 --- a/src/os/_Printf.c +++ b/src/os/_Printf.c @@ -47,7 +47,7 @@ s32 _Printf(char *(*prout)(char *, const char *, size_t), char *dst, const char u8 sp4c[0x20]; // probably a buffer? s32 sp48, sp44, sp40, sp3c, sp38, sp34, sp30, sp2c, sp28, sp24; sp78.size = 0; - while (TRUE) { + while (true) { fmt_ptr = (u8 *) fmt; #ifdef VERSION_SH // new version: don't point fmt_ptr beyond NUL character diff --git a/src/os/__osDevMgrMain.c b/src/os/__osDevMgrMain.c index 62f2c6ffd..10e074d29 100644 --- a/src/os/__osDevMgrMain.c +++ b/src/os/__osDevMgrMain.c @@ -22,7 +22,7 @@ void __osDevMgrMain(void *args) { mb = NULL; ret = 0; sp34 = (OSMgrArgs *) args; - while (TRUE) { + while (true) { osRecvMesg(sp34->cmdQueue, (OSMesg) &mb, OS_MESG_BLOCK); if (mb->piHandle != NULL && mb->piHandle->type == 2 && (mb->piHandle->transferInfo.cmdType == 0 @@ -41,7 +41,7 @@ void __osDevMgrMain(void *args) { osRecvMesg(sp34->accessQueue, &dummy, OS_MESG_BLOCK); __osResetGlobalIntMask(0x00100401); // remove magic constant! __osEPiRawWriteIo(mb->piHandle, 0x05000510, (sp24->bmCtlShadow | 0x80000000)); - while (TRUE) { + while (true) { osRecvMesg(sp34->eventQueue, &em, OS_MESG_BLOCK); sp30 = osSendMesg(mb->hdr.retQueue, mb, OS_MESG_NOBLOCK); if (sp2c != 1 || mb->piHandle->transferInfo.errStatus != 0) { diff --git a/src/os/__osLeoInterrupt.c b/src/os/__osLeoInterrupt.c index e77c5af6d..99b4e532a 100644 --- a/src/os/__osLeoInterrupt.c +++ b/src/os/__osLeoInterrupt.c @@ -1,4 +1,4 @@ -#include "ultra64.h" +#include #include "osint.h" #include "piint.h" #include "libultra_internal.h" diff --git a/src/os/contpfs.c b/src/os/contpfs.c index 1ff0fc7f9..b6d191e2b 100644 --- a/src/os/contpfs.c +++ b/src/os/contpfs.c @@ -57,7 +57,7 @@ s32 __osRepairPackId(OSPfs *pfs, __OSPackId *badid, __OSPackId *newid) pfs->activebank = j; ERRCK(__osPfsSelectBank(pfs)) //! @todo fix magic number - ERRCK(__osContRamRead(pfs->queue, pfs->channel, 0, (u8*)&temp)); + ERRCK(__osContRamRead(pfs->queue, pfs->channel, 0, (u8*)&temp)); temp[0] = j | 0x80; for (i = 1; i < ARRLEN(temp); i++) { @@ -65,7 +65,7 @@ s32 __osRepairPackId(OSPfs *pfs, __OSPackId *badid, __OSPackId *newid) temp[i] = ~temp[i]; } - ERRCK(__osContRamWrite(pfs->queue, pfs->channel, 0, (u8*)temp, FALSE)); //oddr 0, don't force + ERRCK(__osContRamWrite(pfs->queue, pfs->channel, 0, (u8*)temp, false)); //oddr 0, don't force ERRCK(__osContRamRead(pfs->queue, pfs->channel, 0, (u8*)&comp)); for (i = 0; i < ARRLEN(temp); i++) @@ -82,7 +82,7 @@ s32 __osRepairPackId(OSPfs *pfs, __OSPackId *badid, __OSPackId *newid) ERRCK(__osContRamRead(pfs->queue, pfs->channel, 0, (u8*)temp)); if (temp[0] != 128) //! @todo remove magic constant - break; + break; } j++; } @@ -102,7 +102,7 @@ s32 __osRepairPackId(OSPfs *pfs, __OSPackId *badid, __OSPackId *newid) index[3] = 6; for (i = 0; i < ARRLEN(index); i++) { - ERRCK(__osContRamWrite(pfs->queue, pfs->channel, index[i], (u8*)newid, TRUE)); + ERRCK(__osContRamWrite(pfs->queue, pfs->channel, index[i], (u8*)newid, true)); } ERRCK(__osContRamRead(pfs->queue, pfs->channel, 1, (u8*)temp)); for (i = 0; i < ARRLEN(temp); i++) @@ -142,7 +142,7 @@ s32 __osCheckPackId(OSPfs *pfs, __OSPackId *temp) { if (j != i) { - ERRCK(__osContRamWrite(pfs->queue, pfs->channel, index[j], (u8*)temp, TRUE)); + ERRCK(__osContRamWrite(pfs->queue, pfs->channel, index[j], (u8*)temp, true)); } } return 0; @@ -176,7 +176,7 @@ s32 __osGetId(OSPfs *pfs) } } //! @todo remove magic constant - if ((id->deviceid & 1) == 0) + if ((id->deviceid & 1) == 0) { ERRCK(__osRepairPackId(pfs, id, &newid)); id = &newid; @@ -190,7 +190,7 @@ s32 __osGetId(OSPfs *pfs) pfs->version = id->version; pfs->banks = id->banks; //! @todo loads of magic constants.. - pfs->inode_start_page = pfs->banks * 2 + 3; + pfs->inode_start_page = pfs->banks * 2 + 3; pfs->dir_size = 16; pfs->inode_table = 8; pfs->minode_table = pfs->banks * PFS_ONE_PAGE + 8; @@ -247,11 +247,11 @@ s32 __osPfsRWInode(OSPfs *pfs, __OSInode *inode, u8 flag, u8 bank) for (j = 0; j < 8; j++) { //! @todo don't like this =/ //maybe &inode->inode_table[j*PFS_ONE_PAGE].ipage or something - addr = ((u8 *)inode->inode_page + j * 32); + addr = ((u8 *)inode->inode_page + j * 32); if (flag == PFS_WRITE) { - ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->inode_table + bank * 8 + j, addr, FALSE); - ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->minode_table + bank * 8 + j, addr, FALSE); + ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->inode_table + bank * 8 + j, addr, false); + ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->minode_table + bank * 8 + j, addr, false); } else { @@ -275,7 +275,7 @@ s32 __osPfsRWInode(OSPfs *pfs, __OSInode *inode, u8 flag, u8 bank) for (j = 0; j < PFS_ONE_PAGE; j++) { addr = ((u8 *)inode->inode_page + j * 32); - ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->inode_table + bank * PFS_ONE_PAGE + j, addr, FALSE); + ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->inode_table + bank * PFS_ONE_PAGE + j, addr, false); } } else @@ -283,7 +283,7 @@ s32 __osPfsRWInode(OSPfs *pfs, __OSInode *inode, u8 flag, u8 bank) for (j = 0; j < PFS_ONE_PAGE; j++) { addr = ((u8 *)inode->inode_page + j * 32); - ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->minode_table + bank * PFS_ONE_PAGE + j, addr, FALSE); + ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->minode_table + bank * PFS_ONE_PAGE + j, addr, false); } } } @@ -300,6 +300,6 @@ s32 __osPfsSelectBank(OSPfs *pfs) { temp[i] = pfs->activebank; } - ret = __osContRamWrite(pfs->queue, pfs->channel, 1024, (u8*)temp, FALSE); + ret = __osContRamWrite(pfs->queue, pfs->channel, 1024, (u8*)temp, false); return ret; } diff --git a/src/os/controller.h b/src/os/controller.h index 541fafdc6..92af3d4bd 100644 --- a/src/os/controller.h +++ b/src/os/controller.h @@ -1,7 +1,7 @@ #ifndef _CONTROLLER_H #define _CONTROLLER_H #include "PR/os_internal.h" -#include "PR/os.h" +#include #include "PR/rcp.h" //should go somewhere else but diff --git a/src/os/guLookAtRef.c b/src/os/guLookAtRef.c index 4e65a49a3..1b5174760 100644 --- a/src/os/guLookAtRef.c +++ b/src/os/guLookAtRef.c @@ -19,7 +19,7 @@ **************************************************************************/ /* Minor modifications */ -#include +#include #define FTOFRAC8(x) ((int) MIN(((x) * (128.0)), 127.0) & 0xff) void guLookAtReflectF(float mf[4][4], LookAt *l, float xEye, float yEye, float zEye, float xAt, diff --git a/src/os/guMtxCatF.c b/src/os/guMtxCatF.c index 94e0d10f3..96c01c2b6 100755 --- a/src/os/guMtxCatF.c +++ b/src/os/guMtxCatF.c @@ -30,7 +30,7 @@ * */ -#include +#include void guMtxCatF(float mf[4][4], float nf[4][4], float res[4][4]) { @@ -60,4 +60,3 @@ void guMtxXFMF(float mf[4][4], float x, float y, float z, float *ox, float *oy, *oy = mf[0][1]*x + mf[1][1]*y + mf[2][1]*z + mf[3][1]; *oz = mf[0][2]*x + mf[1][2]*y + mf[2][2]*z + mf[3][2]; } - diff --git a/src/os/guMtxCatL.c b/src/os/guMtxCatL.c index 82fd4c597..f7b22d482 100755 --- a/src/os/guMtxCatL.c +++ b/src/os/guMtxCatL.c @@ -30,8 +30,7 @@ * */ -#include "libultra_internal.h" -#include +#include void guMtxXFMF(Mtx *, float, float, float, float *, float *, float *); void guMtxCatF(float mf[4][4], float nf[4][4], float res[4][4]); diff --git a/src/os/libaudio_internal.h b/src/os/libaudio_internal.h index ea63322c1..74868ac4e 100644 --- a/src/os/libaudio_internal.h +++ b/src/os/libaudio_internal.h @@ -1,6 +1,6 @@ #ifndef _LIBAUDIO_INTERNAL_H_ #define _LIBAUDIO_INTERNAL_H_ -#include +#include #define AL_BANK_VERSION 0x4231 /* 'B1' */ typedef u8 ALPan; diff --git a/src/os/libultra_internal.h b/src/os/libultra_internal.h index 5a6027f75..dafdbd8a9 100644 --- a/src/os/libultra_internal.h +++ b/src/os/libultra_internal.h @@ -1,6 +1,6 @@ #ifndef _LIBULTRA_INTERNAL_H_ #define _LIBULTRA_INTERNAL_H_ -#include +#include #include #include "macros.h" diff --git a/src/os/osCartRomInit.c b/src/os/osCartRomInit.c index b1b6599c7..389e69ea0 100644 --- a/src/os/osCartRomInit.c +++ b/src/os/osCartRomInit.c @@ -5,7 +5,7 @@ #include "PR/R4300.h" #include "PR/rcp.h" #include "PR/os_pi.h" -#include "PR/os.h" +#include OSPiHandle CartRomHandle; diff --git a/src/os/osCreatePiManager.c b/src/os/osCreatePiManager.c index 68c491eb6..c65201934 100644 --- a/src/os/osCreatePiManager.c +++ b/src/os/osCreatePiManager.c @@ -3,7 +3,7 @@ #define OS_PI_MGR_MESG_BUFF_SIZE 1 //! @todo In libreultra this is in an include -#ifdef VERSION_SH +#ifdef VERSION_SH extern OSPiHandle *CartRomHandle; extern OSPiHandle *LeoDiskHandle; #endif @@ -39,7 +39,7 @@ void osCreatePiManager(OSPri pri, OSMesgQueue *cmdQ, OSMesg *cmdBuf, s32 cmdMsgC osSetThreadPri(NULL, pri); } int_disabled = __osDisableInt(); - __osPiDevMgr.initialized = TRUE; + __osPiDevMgr.initialized = true; __osPiDevMgr.mgrThread = &piMgrThread; __osPiDevMgr.cmdQueue = cmdQ; __osPiDevMgr.eventQueue = &__osPiMesgQueue; diff --git a/src/os/osCreateViManager.c b/src/os/osCreateViManager.c index a90b3eab5..950f43d81 100644 --- a/src/os/osCreateViManager.c +++ b/src/os/osCreateViManager.c @@ -41,7 +41,7 @@ void osCreateViManager(OSPri pri) { osSetThreadPri(NULL, pri); } int_disabled = __osDisableInt(); - viMgrMainArgs.initialized = TRUE; + viMgrMainArgs.initialized = true; viMgrMainArgs.mgrThread = &viMgrThread; viMgrMainArgs.cmdQueue = &__osViMesgQueue; viMgrMainArgs.eventQueue = &__osViMesgQueue; @@ -67,7 +67,7 @@ void viMgrMain(void *vargs) { u32 sp28; // always 0 u32 sp24; // time related mesg = NULL; - sp28 = FALSE; + sp28 = false; context = __osViGetCurrentContext(); if ((retrace = context->retraceCount) == 0) { @@ -76,7 +76,7 @@ void viMgrMain(void *vargs) { args = (OSMgrArgs *) vargs; - while (TRUE) { + while (true) { osRecvMesg(args->eventQueue, &mesg, OS_MESG_BLOCK); switch (*(u16 *) mesg) { case 13: diff --git a/src/os/osInitialize.c b/src/os/osInitialize.c index 921c969ae..292cbbc1c 100644 --- a/src/os/osInitialize.c +++ b/src/os/osInitialize.c @@ -33,7 +33,7 @@ void osInitialize(void) { UNUSED u32 eu_sp34; UNUSED u32 eu_sp30; UNUSED u32 sp2c; - D_80194040 = TRUE; + D_80194040 = true; __osSetSR(__osGetSR() | 0x20000000); __osSetFpcCsr(0x01000800); while (__osSiRawReadIo(PIF_ADDR_START, &sp34)) { diff --git a/src/os/osPfsAllocateFile.c b/src/os/osPfsAllocateFile.c index 655c57cd0..b2614955e 100644 --- a/src/os/osPfsAllocateFile.c +++ b/src/os/osPfsAllocateFile.c @@ -29,7 +29,7 @@ s32 osPfsAllocateFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name return PFS_ERR_INVALID; file_size_in_pages = (file_size_in_bytes + 255) / (BLOCKSIZE * PFS_ONE_PAGE); - if ((pfs->status & PFS_INITIALIZED) == FALSE) + if ((pfs->status & PFS_INITIALIZED) == false) return PFS_ERR_INVALID; PFS_CHECK_ID; @@ -99,7 +99,7 @@ s32 osPfsAllocateFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name dir.game_name[j] = *game_name++; for (j = 0; j < ARRLEN(dir.ext_name); j++) dir.ext_name[j] = *ext_name++; - ERRCK(__osContRamWrite(pfs->queue, pfs->channel, *file_no + pfs->dir_table, (u8*)&dir, FALSE)); + ERRCK(__osContRamWrite(pfs->queue, pfs->channel, *file_no + pfs->dir_table, (u8*)&dir, false)); return ret; } return PFS_ERR_INVALID; @@ -171,7 +171,7 @@ static s32 __osClearPage(OSPfs *pfs, int page_no, u8 *data, u8 bank) ERRCK(__osPfsSelectBank(pfs)); for (i = 0; i < PFS_ONE_PAGE; i++) { - ret = __osContRamWrite(pfs->queue, pfs->channel, page_no * PFS_ONE_PAGE + i, data, FALSE); + ret = __osContRamWrite(pfs->queue, pfs->channel, page_no * PFS_ONE_PAGE + i, data, false); if (ret != 0) break; } diff --git a/src/os/osPfsChecker.c b/src/os/osPfsChecker.c index 18457216e..78bd44bb9 100644 --- a/src/os/osPfsChecker.c +++ b/src/os/osPfsChecker.c @@ -59,7 +59,7 @@ s32 osPfsChecker(OSPfs *pfs) tmp_dir.status = DIR_STATUS_EMPTY; tmp_dir.data_sum = 0; SET_ACTIVEBANK_TO_ZERO; - ERRCK(__osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + j, (u8*)&tmp_dir, FALSE)); + ERRCK(__osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + j, (u8*)&tmp_dir, false)); fixed++; } else @@ -73,7 +73,7 @@ s32 osPfsChecker(OSPfs *pfs) tmp_dir.data_sum = 0; SET_ACTIVEBANK_TO_ZERO; - ERRCK(__osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + j, (u8*)&tmp_dir, FALSE)); + ERRCK(__osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + j, (u8*)&tmp_dir, false)); fixed++; } } diff --git a/src/os/osPfsDeleteFile.c b/src/os/osPfsDeleteFile.c index 7ea124f8b..c7ec885b4 100644 --- a/src/os/osPfsDeleteFile.c +++ b/src/os/osPfsDeleteFile.c @@ -32,7 +32,7 @@ s32 osPfsDeleteFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, { ERRCK(__osPfsRWInode(pfs, &inode, OS_READ, bank)); //! @todo magic constant - ERRCK(__osPfsReleasePages(pfs, &inode, startpage, &sum, bank, &last_page, 1)); + ERRCK(__osPfsReleasePages(pfs, &inode, startpage, &sum, bank, &last_page, 1)); ERRCK(__osPfsRWInode(pfs, &inode, OS_WRITE, bank)); if (last_page.ipage == 1) break; @@ -56,7 +56,7 @@ s32 osPfsDeleteFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, dir.ext_name[k] = 0; } dir.status = DIR_STATUS_EMPTY; - ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + file_no, (u8*)&dir, FALSE); + ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + file_no, (u8*)&dir, false); return ret; } @@ -86,7 +86,7 @@ s32 __osPfsReleasePages(OSPfs *pfs, __OSInode *inode, u8 start_page, u16 *sum, u return PFS_ERR_INCONSISTENT; *last_page = next_page; //! @todo magic number - if (flag == 1) + if (flag == 1) inode->inode_page[start_page].ipage = 3; ERRCK(__osBlockSum(pfs, start_page, sum, bank)); diff --git a/src/os/osPfsIsPlug.c b/src/os/osPfsIsPlug.c index 11580732b..4df1bf328 100644 --- a/src/os/osPfsIsPlug.c +++ b/src/os/osPfsIsPlug.c @@ -17,7 +17,7 @@ s32 osPfsIsPlug(OSMesgQueue *queue, u8 *pattern) { bits = 0; crc_error_cnt = 3; __osSiGetAccess(); - while (TRUE) { + while (true) { __osPfsRequestData(CONT_CMD_REQUEST_STATUS); ret = __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); osRecvMesg(queue, &dummy, OS_MESG_BLOCK); diff --git a/src/os/osPfsNumFiles.c b/src/os/osPfsNumFiles.c index 09d0eba6f..1bcebaca2 100755 --- a/src/os/osPfsNumFiles.c +++ b/src/os/osPfsNumFiles.c @@ -1,5 +1,5 @@ #include "libultra_internal.h" -#include "PR/os.h" +#include #include "controller.h" s32 osPfsNumFiles(OSPfs *pfs, s32 *max_files, s32 *files_used) diff --git a/src/os/osPfsReadWriteFile.c b/src/os/osPfsReadWriteFile.c index b972147a2..a910a681d 100644 --- a/src/os/osPfsReadWriteFile.c +++ b/src/os/osPfsReadWriteFile.c @@ -82,7 +82,7 @@ s32 osPfsReadWriteFile(OSPfs *pfs, s32 file_no, u8 flag, int offset, int size_in if (flag == OS_READ) ret = __osContRamRead(pfs->queue, pfs->channel, blockno, buffer); else - ret = __osContRamWrite(pfs->queue, pfs->channel, blockno, buffer, FALSE); + ret = __osContRamWrite(pfs->queue, pfs->channel, blockno, buffer, false); if (ret != 0) return ret; buffer += BLOCKSIZE; @@ -94,7 +94,7 @@ s32 osPfsReadWriteFile(OSPfs *pfs, s32 file_no, u8 flag, int offset, int size_in dir.status |= DIR_STATUS_OCCUPIED; pfs->activebank = 0; ERRCK(__osPfsSelectBank(pfs)); - ERRCK(__osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + file_no, (u8*)&dir, FALSE)); + ERRCK(__osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + file_no, (u8*)&dir, false)); } return 0; diff --git a/src/os/osPfsSearchFile.c b/src/os/osPfsSearchFile.c index efd994698..b78171294 100755 --- a/src/os/osPfsSearchFile.c +++ b/src/os/osPfsSearchFile.c @@ -15,14 +15,14 @@ s32 osPfsFindFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, u8 ERRCK(__osContRamRead(pfs->queue, pfs->channel, pfs->dir_table + j, (u8*)&dir)); if ((dir.company_code == company_code) && dir.game_code == game_code) { - fail = FALSE; + fail = false; if (game_name != NULL) { for (i = 0; i < ARRLEN(dir.game_name); i++) { if (dir.game_name[i] != game_name[i]) { - fail = TRUE; + fail = true; break; } } @@ -34,7 +34,7 @@ s32 osPfsFindFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, u8 { if (dir.ext_name[i] != ext_name[i]) { - fail = TRUE; + fail = true; break; } } diff --git a/src/os/osTimer.c b/src/os/osTimer.c index b14139a94..21d6ee19a 100644 --- a/src/os/osTimer.c +++ b/src/os/osTimer.c @@ -26,7 +26,7 @@ void __osTimerInterrupt(void) { if (__osTimerList->next == __osTimerList) { return; } - while (TRUE) { + while (true) { sp24 = __osTimerList->next; if (sp24 == __osTimerList) { __osSetCompare(0); diff --git a/src/os/piint.h b/src/os/piint.h index 39278eed9..8b2a479a2 100644 --- a/src/os/piint.h +++ b/src/os/piint.h @@ -3,7 +3,7 @@ #include "PR/os_internal.h" #include "PR/rcp.h" #include "PR/os_pi.h" -#include "PR/os.h" +#include //https://github.com/LuigiBlood/64dd/wiki/Memory-Map @@ -84,11 +84,11 @@ #define LEO_BM_CTL_SECTOR_SHIFT 16 //! @todo name -#define LEO_CMD_TYPE_0 0 +#define LEO_CMD_TYPE_0 0 //! @todo name -#define LEO_CMD_TYPE_1 1 +#define LEO_CMD_TYPE_1 1 //! @todo name -#define LEO_CMD_TYPE_2 2 +#define LEO_CMD_TYPE_2 2 #define LEO_ERROR_GOOD 0 #define LEO_ERROR_3 3 diff --git a/src/player_controller.c b/src/player_controller.c index 08b852f68..5b8c9332f 100644 --- a/src/player_controller.c +++ b/src/player_controller.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -620,7 +620,7 @@ void func_80027EDC(Player *player, s8 playerId) { void func_80028864(Player *player, Camera *camera, s8 arg2, s8 arg3) { u16 sp1E; - + if (!(player->type & PLAYER_START_SEQUENCE)) { switch (gActiveScreenMode) { case SCREEN_MODE_1P: @@ -633,32 +633,32 @@ void func_80028864(Player *player, Camera *camera, s8 arg2, s8 arg3) { sp1E = check_player_camera_collision(player, camera2, (f32) D_8016557C, 0.0f); break; case SCREEN_MODE_3P_4P_SPLITSCREEN: - sp1E = check_player_camera_collision(player, camera1, (f32) D_8016557C, 0.0f); + sp1E = check_player_camera_collision(player, camera1, (f32) D_8016557C, 0.0f); + if (sp1E == 1) break; + sp1E = check_player_camera_collision(player, camera2, (f32) D_8016557C, 0.0f); + if (sp1E == 1) break; + sp1E = check_player_camera_collision(player, camera3, (f32) D_8016557C, 0.0f); if (sp1E == 1) break; - sp1E = check_player_camera_collision(player, camera2, (f32) D_8016557C, 0.0f); - if (sp1E == 1) break; - sp1E = check_player_camera_collision(player, camera3, (f32) D_8016557C, 0.0f); - if (sp1E == 1) break; sp1E = check_player_camera_collision(player, camera4, (f32) D_8016557C, 0.0f); - break; + break; } - if ((sp1E == 1) || - ((player->type & PLAYER_INVISIBLE_OR_BOMB) == PLAYER_INVISIBLE_OR_BOMB) || - (gModeSelection == BATTLE) || - ((player->unk_0CA & 2) != 0) || - (player->unk_0CA & 8) || + if ((sp1E == 1) || + ((player->type & PLAYER_INVISIBLE_OR_BOMB) == PLAYER_INVISIBLE_OR_BOMB) || + (gModeSelection == BATTLE) || + ((player->unk_0CA & 2) != 0) || + (player->unk_0CA & 8) || //! @todo make a proper match ((*(D_801633F8 + (arg2))) == ((s16) 1U))) { player->effects &= ~0x1000; - if (((player->effects & 0x80) == 0x80) || - ((player->effects & 0x40) == 0x40) || - ((player->effects & 0x400) == 0x400) || - ((player->effects & 0x4000) == 0x4000) || - ((player->effects & 0x80000) == 0x80000) || - ((player->effects & 0x800000) == 0x800000) || - ((player->effects & 0x01000000) == 0x01000000) || - ((player->effects & HIT_BY_ITEM_EFFECT) == HIT_BY_ITEM_EFFECT) || - ((player->effects & 0x20000) == 0x20000) || + if (((player->effects & 0x80) == 0x80) || + ((player->effects & 0x40) == 0x40) || + ((player->effects & 0x400) == 0x400) || + ((player->effects & 0x4000) == 0x4000) || + ((player->effects & 0x80000) == 0x80000) || + ((player->effects & 0x800000) == 0x800000) || + ((player->effects & 0x01000000) == 0x01000000) || + ((player->effects & HIT_BY_ITEM_EFFECT) == HIT_BY_ITEM_EFFECT) || + ((player->effects & 0x20000) == 0x20000) || (player->unk_044 & 0x800)) { func_8002E594(player, camera, arg3, arg2); } else { @@ -680,18 +680,18 @@ void func_80028864(Player *player, Camera *camera, s8 arg2, s8 arg3) { } } -void func_80028C44(Player *player, Camera *camera, s8 arg2, s8 arg3) { +void func_80028C44(Player *player, Camera *camera, s8 arg2, s8 arg3) { if ((player->type & PLAYER_START_SEQUENCE) == 0) { player->effects &= ~0x1000; - if (((player->effects & 0x80) == 0x80) || - ((player->effects & 0x40) == 0x40) || - ((player->effects & 0x400) == 0x400) || - ((player->effects & 0x4000) == 0x4000) || - ((player->effects & 0x80000) == 0x80000) || - ((player->effects & 0x800000) == 0x800000) || - ((player->effects & 0x1000000) == 0x1000000) || - ((player->effects & HIT_BY_ITEM_EFFECT) == HIT_BY_ITEM_EFFECT) || - ((player->effects & 0x20000) == 0x20000) || + if (((player->effects & 0x80) == 0x80) || + ((player->effects & 0x40) == 0x40) || + ((player->effects & 0x400) == 0x400) || + ((player->effects & 0x4000) == 0x4000) || + ((player->effects & 0x80000) == 0x80000) || + ((player->effects & 0x800000) == 0x800000) || + ((player->effects & 0x1000000) == 0x1000000) || + ((player->effects & HIT_BY_ITEM_EFFECT) == HIT_BY_ITEM_EFFECT) || + ((player->effects & 0x20000) == 0x20000) || ((player->unk_044 & 0x800) != 0)) { func_8002E594(player, camera, arg3, arg2); } else { @@ -709,16 +709,16 @@ void func_80028D3C(Player *player, Camera *camera, s8 arg2, s8 arg3) { || (player->unk_0CA & 8) != 0 || (player->effects & 0x4F010CC0) != 0) { player->effects &= ~0x1000; - - if (((player->effects & 0x80) == 0x80) || - ((player->effects & 0x40) == 0x40) || - ((player->effects & 0x400) == 0x400) || - ((player->effects & 0x4000) == 0x4000) || - ((player->effects & 0x80000) == 0x80000) || - ((player->effects & 0x800000) == 0x800000) || - ((player->effects & 0x1000000) == 0x1000000) || - ((player->effects & HIT_BY_ITEM_EFFECT) == HIT_BY_ITEM_EFFECT) || - ((player->effects & 0x20000) == 0x20000) || + + if (((player->effects & 0x80) == 0x80) || + ((player->effects & 0x40) == 0x40) || + ((player->effects & 0x400) == 0x400) || + ((player->effects & 0x4000) == 0x4000) || + ((player->effects & 0x80000) == 0x80000) || + ((player->effects & 0x800000) == 0x800000) || + ((player->effects & 0x1000000) == 0x1000000) || + ((player->effects & HIT_BY_ITEM_EFFECT) == HIT_BY_ITEM_EFFECT) || + ((player->effects & 0x20000) == 0x20000) || ((player->unk_044 & 0x800) != 0)) { func_8002E594(player, camera, arg3, arg2); } else { @@ -737,9 +737,9 @@ void func_80028E70(Player *player, Camera *camera, s8 arg2, s8 arg3) { func_80038C6C(player, camera, arg3, arg2); } else { player->effects &= ~8; - } + } break; - default: + default: func_80027DA8(player, arg2); switch (gModeSelection) { case TIME_TRIALS: @@ -752,7 +752,7 @@ void func_80028E70(Player *player, Camera *camera, s8 arg2, s8 arg3) { default: func_80028864(player, camera, arg2, arg3); break; - } + } break; } } @@ -915,7 +915,7 @@ void func_8002934C(Player *player, Camera *camera, s8 arg2, s8 playerId) { || (player->unk_044 & 0x800)) { player->unk_050[arg2] = 0; } - if (((player->effects & 8) == 8) + if (((player->effects & 8) == 8) && ((player->unk_0CA & 2) == 2)) { player->unk_050[arg2] = 0; } @@ -951,7 +951,7 @@ void func_8002934C(Player *player, Camera *camera, s8 arg2, s8 playerId) { || (player->effects & 0x800000) || (player->effects & 0x20000) || (player->unk_044 & 0x800)) { - + if ((player->animFrameSelector[arg2]) >= 0x14) { player->animFrameSelector[arg2] = 0; } @@ -971,10 +971,10 @@ void func_8002934C(Player *player, Camera *camera, s8 arg2, s8 playerId) { || (player->effects & 0x10000) || (player->effects & 0x80) || (player->effects & 0x40)) { - + player->unk_002 |= 1 << (arg2 * 4); D_80165190[arg2][playerId] = 1; - + if ((player->effects & 0x80) || (player->effects & 0x40)) { if ((player->animFrameSelector[arg2] == D_801650D0[arg2][playerId]) && (player->animGroupSelector[arg2] == D_80165110[arg2][playerId])) { @@ -1016,7 +1016,7 @@ void func_80029B4C(Player *player, UNUSED f32 arg1, f32 arg2, UNUSED f32 arg3) { else { var_f12 = 18.0f * (gCharacterSize[player->characterId] / 2); } - + calculate_orientation_matrix(sp5C, 0.0f, 1.0f, 0.0f, (player->rotation[1] + player->unk_0C0)); sp8C[0] = var_f12 - 3.6; sp8C[1] = -player->boundingBoxSize; @@ -1029,7 +1029,7 @@ void func_80029B4C(Player *player, UNUSED f32 arg1, f32 arg2, UNUSED f32 arg3) { player->boundingBoxCorners[0].cornerPos[1] = player->pos[1] + sp8C[1]; player->boundingBoxCorners[0].cornerPos[2] = player->pos[2] + sp8C[2]; process_collision(player, &player->boundingBoxCorners[0], sp80[0], sp80[1], sp80[2]); - + sp8C[0] = (-var_f12) + 3.6; sp8C[1] = -player->boundingBoxSize; sp8C[2] = var_f12 - 2.0f; @@ -1041,7 +1041,7 @@ void func_80029B4C(Player *player, UNUSED f32 arg1, f32 arg2, UNUSED f32 arg3) { player->boundingBoxCorners[1].cornerPos[1] = player->pos[1] + sp8C[1]; player->boundingBoxCorners[1].cornerPos[2] = player->pos[2] + sp8C[2]; process_collision(player, &player->boundingBoxCorners[1], sp80[0], sp80[1], sp80[2]); - + sp8C[0] = var_f12 - 2.6; sp8C[1] = -player->boundingBoxSize; sp8C[2] = (-var_f12) + 4.0f; @@ -1053,7 +1053,7 @@ void func_80029B4C(Player *player, UNUSED f32 arg1, f32 arg2, UNUSED f32 arg3) { player->boundingBoxCorners[2].cornerPos[1] = player->pos[1] + sp8C[1]; player->boundingBoxCorners[2].cornerPos[2] = player->pos[2] + sp8C[2]; process_collision(player, &player->boundingBoxCorners[2], sp80[0], sp80[1], sp80[2]); - + sp8C[0] = (-var_f12) + 2.6; sp8C[1] = -player->boundingBoxSize; sp8C[2] = (-var_f12) + 4.0f; @@ -1065,7 +1065,7 @@ void func_80029B4C(Player *player, UNUSED f32 arg1, f32 arg2, UNUSED f32 arg3) { player->boundingBoxCorners[3].cornerPos[1] = player->pos[1] + sp8C[1]; player->boundingBoxCorners[3].cornerPos[2] = player->pos[2] + sp8C[2]; process_collision(player, &player->boundingBoxCorners[3], sp80[0], sp80[1], sp80[2]); - + if (!(player->effects & 8)) { a = (player->boundingBoxCorners[2].cornerGroundY + player->boundingBoxCorners[0].cornerGroundY) / 2; move_f32_towards(&player->unk_230, a, 0.5f); @@ -1712,59 +1712,59 @@ void func_8002BB9C(Player *player, f32 *arg1, f32 *arg2, UNUSED s8 arg3, UNUSED s16 t0; UNUSED s32 pad; s16 sp30[10] = {0x0000, 0x00b6, 0x016c, 0x0222, 0x02d8, 0x038e, 0x0444, 0x04fa, 0x05b0, 0x0666}; - + if (((u16) player->unk_256) <= 0) { - return; + return; } if (((u16) player->unk_256) > 2) { return; } - + if (!(player->unk_046 & 0x20)) { - return; + return; } - + calculate_orientation_matrix(sp64, 0, 1, 0, (s16) 0); - + sp58[0] = *arg1; sp58[1] = 0; sp58[2] = *arg2; - + mtxf_translate_vec3f_mat3(sp58, sp64); - + sp4C[0] = player->copy_rotation_x; sp4C[1] = 0; sp4C[2] = player->copy_rotation_z; - + mtxf_translate_vec3f_mat3(sp4C, sp64); var_v0 = -(s16)get_angle_between_two_vectors(sp58, sp4C); t0 = player->rotation[1]; var_v0 = 0x10000 + (t0 - var_v0); var_v0 /= 182; - + if (var_v0 < 0x97 && (var_v0 > -0x97)) { return; } - + var_v0 = (player->unk_07C >> 0x10) / 6; - + if (var_v0 < 0) { var_v0 *= -1; } - + if (var_v0 >= 8) { var_v0 = 8; } - + if ((player->unk_07C >> 0x10) < 0) { player->rotation[1] -= sp30[var_v0]; } else { player->rotation[1] += sp30[var_v0]; } } - + void func_8002BD58(Player *player) { s32 sp2C[7] = { 0x002f0000, 0x00300000, 0x00310000, 0x00320000, 0x00320000, 0x00320000, 0x00320000 }; s32 spC[8] = { 0x00280000, 0x002c0000, 0x00300000, 0x00320000, 0x00320000, 0x00320000, 0x00320000, 0x00320000 }; @@ -1794,16 +1794,16 @@ void func_8002BD58(Player *player) { } } -void func_8002BF4C(Player *player, s8 arg1) { +void func_8002BF4C(Player *player, s8 arg1) { UNUSED s32 pad[3]; UNUSED s32 uselessAssignment; s32 i; s32 var_a2; Player *playerBorrow; Player *players = gPlayerOne; - + var_a2 = 0; - + if (((player->unk_094 / 18.0f) * 216.0f) < 50.0f) { player->unk_0E2 = 0; player->effects &= 0xFFDFFFFF; @@ -1817,9 +1817,9 @@ void func_8002BF4C(Player *player, s8 arg1) { } else { for (i = 0; i < NUM_PLAYERS; i++) { playerBorrow = &players[i]; - if (((player != playerBorrow) && - ((playerBorrow->type & 0x100) == 0) && - (playerBorrow->type & 0x8000)) && + if (((player != playerBorrow) && + ((playerBorrow->type & 0x100) == 0) && + (playerBorrow->type & 0x8000)) && ((var_a2 = func_8001FD78(player, playerBorrow->pos[0], playerBorrow->pos[1], playerBorrow->pos[2]), var_a2 == 1))) { player->unk_0E2 += 1; if (player->unk_0E2 >= 0x3D) { @@ -1836,7 +1836,7 @@ void func_8002BF4C(Player *player, s8 arg1) { break; } } - + if (var_a2 == 0) { player->unk_0E2 = 0; } @@ -1970,7 +1970,7 @@ void func_8002C4F8(Player *player, s8 arg1) { func_8002C17C(player, arg1); } -void func_8002C7E4(Player *player, s8 arg1, s8 arg2) { +void func_8002C7E4(Player *player, s8 arg1, s8 arg2) { if ((player->unk_046 & 1) != 1) { if ((player->effects & 0x8000) == 0x8000) { if ((player->effects & BOOST_EFFECT) != BOOST_EFFECT) { @@ -2017,15 +2017,15 @@ void func_8002C954(Player *player, s8 playerId, Vec3f arg2) { f32 zdist; temp_f0 = player->pos[1] - player->unk_074; - if (((((player->effects & 0x10000) != 0x10000) && - ((player->effects & BOOST_RAMP_ASPHALT_EFFECT) == BOOST_RAMP_ASPHALT_EFFECT)) || - ((((temp_f0 >= 20.0f) || - (temp_f0 < (-1.0f))) && - ((player->effects & 0x10000) == 0)) && - (player->effects & 8)) || - ((player->unk_110.unk34 == 0) && - ((player->effects & 0x10000) == 0))) && - (((player->unk_0CA & 2) == 0) || + if (((((player->effects & 0x10000) != 0x10000) && + ((player->effects & BOOST_RAMP_ASPHALT_EFFECT) == BOOST_RAMP_ASPHALT_EFFECT)) || + ((((temp_f0 >= 20.0f) || + (temp_f0 < (-1.0f))) && + ((player->effects & 0x10000) == 0)) && + (player->effects & 8)) || + ((player->unk_110.unk34 == 0) && + ((player->effects & 0x10000) == 0))) && + (((player->unk_0CA & 2) == 0) || (!(player->unk_0CA & 8)))) { func_8008F494(player, playerId); } @@ -2051,17 +2051,17 @@ void func_8002C954(Player *player, s8 playerId, Vec3f arg2) { var_f14 = D_80165070[playerId][1] - arg2[1]; ydist = var_f14; // okay zdist = D_80165070[playerId][2] - arg2[2]; - var_f14 = sqrtf((xdist * xdist) + (ydist * ydist) + (zdist * zdist)) / 3; + var_f14 = sqrtf((xdist * xdist) + (ydist * ydist) + (zdist * zdist)) / 3; if (var_f14 >= 1.0) { var_f14 = 1.0f; } - if ((var_f14 <= 0.6) && - (((player->unk_094 / 18.0f) * 216.0f) >= 40.0f) && + if ((var_f14 <= 0.6) && + (((player->unk_094 / 18.0f) * 216.0f) >= 40.0f) && (!(player->type & PLAYER_INVISIBLE_OR_BOMB))) { func_800CAEC4(playerId, 0.6F); } else if (!(player->type & PLAYER_INVISIBLE_OR_BOMB)) { - if ((var_f14 <= 0.6) && - (((player->unk_094 / 18.0f) * 216.0f) < 40.0f) && + if ((var_f14 <= 0.6) && + (((player->unk_094 / 18.0f) * 216.0f) < 40.0f) && (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f)) { func_800CAEC4(playerId, 0.3F); } else { @@ -2166,7 +2166,7 @@ void func_8002D028(Player *player, s8 arg1) { thing0 = 8; - + if (temp > ((s16) (thing0 * 182))) { temp = (thing0 * 182); } @@ -2324,7 +2324,7 @@ void func_8002D268(Player *player, UNUSED Camera *camera, s8 arg2, s8 playerId) posX = player->pos[0]; posY = player->pos[1]; posZ = player->pos[2]; - + player->copy_rotation_x = player->pos[0]; player->copy_rotation_z = player->pos[2]; player->copy_rotation_y = player->pos[1]; @@ -2362,10 +2362,10 @@ void func_8002D268(Player *player, UNUSED Camera *camera, s8 arg2, s8 playerId) player->unk_DB4.unkC = 3.0f; player->unk_DB4.unk18 = 0; player->unk_0B6 |= 0x100; - if ((((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) - && ((player->effects & BOOST_RAMP_ASPHALT_EFFECT) == BOOST_RAMP_ASPHALT_EFFECT)) - && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) - + if ((((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) + && ((player->effects & BOOST_RAMP_ASPHALT_EFFECT) == BOOST_RAMP_ASPHALT_EFFECT)) + && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) + func_800C9060(playerId, 0x1900A60AU); else if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { @@ -2379,7 +2379,7 @@ void func_8002D268(Player *player, UNUSED Camera *camera, s8 arg2, s8 playerId) if (((player->unk_0C2 < 0x23) && (player->unk_0C2 >= 0x1C)) && (((player->unk_094 / 18.0f) * 216.0f) >= 20.0f)) { player->unk_DB4.unkC = 2.8f; player->unk_DB4.unk18 = 0; - if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) + if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { func_800CADD0((u8) playerId, ((f32) player->unk_0C2) / 35.0f); } @@ -2449,7 +2449,7 @@ void func_8002D268(Player *player, UNUSED Camera *camera, s8 arg2, s8 playerId) player->unk_22C = player->unk_094; player->unk_094 = sqrtf(temp2); - if ((player->unk_08C <= 0.0f) + if ((player->unk_08C <= 0.0f) && (player->unk_094 <= 0.08) && (D_8018CE10[playerId].unk_04[0] == 0.0f) && (D_8018CE10[playerId].unk_04[2] == 0.0f)) { @@ -2583,7 +2583,7 @@ void func_8002E594(Player *player, UNUSED Camera *camera, s8 arg2, s8 playerId) } else { sp54[0] += ((((f64) (spEC[0] + sp80 + spD4[0]) - (sp54[0] * (0.2 * (f64) player->kartFriction))) / 6000) * 0.08); sp54[2] += ((((f64) (spEC[2] + sp78 + spD4[2]) - (sp54[2] * (0.2 * (f64) player->kartFriction))) / 6000) * 0.08); - + } sp54[1] += ((( ((spEC[1] + sp7C) + spD4[1])) - (sp54[1] * (0.12 * player->kartFriction))) / 6000) / player->unk_DAC; @@ -2595,11 +2595,11 @@ void func_8002E594(Player *player, UNUSED Camera *camera, s8 arg2, s8 playerId) posX = player->pos[0]; posY = player->pos[1]; posZ = player->pos[2]; - + player->copy_rotation_x = player->pos[0]; player->copy_rotation_y = player->pos[1]; player->copy_rotation_z = player->pos[2]; - + spD0 = posX + player->velocity[0] + D_8018CE10[playerId].unk_04[0]; spCC = posY + player->velocity[1]; spC8 = posZ + player->velocity[2] + D_8018CE10[playerId].unk_04[2]; @@ -2917,7 +2917,7 @@ void func_8002F730(Player *player, UNUSED Camera *camera, UNUSED s8 arg2, s8 arg player->velocity[0] = sp68[0]; player->velocity[1] = sp68[1]; player->velocity[2] = sp68[2]; - + D_80165070[arg3][0] = sp68[0]; D_80165070[arg3][1] = sp68[1]; D_80165070[arg3][2] = sp68[2]; @@ -2987,7 +2987,7 @@ void func_8002FE84(Player *player, f32 arg1) { player->unk_098 = ((player->currentSpeed * player->currentSpeed) / 25.0f) * 1.1; return; } - + // Huh? if (((player->effects & 0xFFFFFFFF) & 8) == 8) { player->unk_098 = ((player->currentSpeed * player->currentSpeed) / 25.0f) * 1.1; @@ -3039,14 +3039,14 @@ f32 func_80030150(Player *player, s8 arg1) { } else { var_f0 += D_800E2E90[player->characterId][player->boundingBoxCorners[3].surfaceType]; } - - if ((s32) player->boundingBoxCorners[2].surfaceType < 0xF) + + if ((s32) player->boundingBoxCorners[2].surfaceType < 0xF) var_f0 += D_800E2E90[player->characterId][player->boundingBoxCorners[2].surfaceType]; - - if ((s32) player->boundingBoxCorners[1].surfaceType < 0xF) + + if ((s32) player->boundingBoxCorners[1].surfaceType < 0xF) var_f0 += D_800E2EB0[player->characterId][player->boundingBoxCorners[1].surfaceType]; - - if ((s32) player->boundingBoxCorners[0].surfaceType < 0xF) + + if ((s32) player->boundingBoxCorners[0].surfaceType < 0xF) var_f0 += D_800E2E90[player->characterId][player->boundingBoxCorners[0].surfaceType]; } if (((player->effects & 8) != 8) && ((player->unk_0CA & 2) != 2)) { @@ -3229,15 +3229,15 @@ void detect_triple_a_combo_a_released(Player *player) { if (player == gPlayerEight) { playerIndex = 7; } - if (gIsPlayerTripleAButtonCombo[playerIndex] == FALSE) { - if (gPlayerIsThrottleActive[playerIndex] == TRUE) { + if (gIsPlayerTripleAButtonCombo[playerIndex] == false) { + if (gPlayerIsThrottleActive[playerIndex] == true) { if ((gFrameSinceLastACombo[playerIndex] < 2) || (gFrameSinceLastACombo[playerIndex] >= 9)) { gCountASwitch[playerIndex] = 0; } gFrameSinceLastACombo[playerIndex] = 0; D_80165400[playerIndex] = 0; } - gPlayerIsThrottleActive[playerIndex] = FALSE; + gPlayerIsThrottleActive[playerIndex] = false; gFrameSinceLastACombo[playerIndex]++; if (gFrameSinceLastACombo[playerIndex] >= 9) { gFrameSinceLastACombo[playerIndex] = 9; @@ -3249,7 +3249,7 @@ void detect_triple_a_combo_a_released(Player *player) { D_80165400[playerIndex] = 1; } if (gCountASwitch[playerIndex] == 5) { - gIsPlayerTripleAButtonCombo[playerIndex] = TRUE; + gIsPlayerTripleAButtonCombo[playerIndex] = true; gTimerBoostTripleACombo[playerIndex] = 120; gCountASwitch[playerIndex] = 0; gFrameSinceLastACombo[playerIndex] = 0; @@ -3257,7 +3257,7 @@ void detect_triple_a_combo_a_released(Player *player) { } else { gTimerBoostTripleACombo[playerIndex]--; if (gTimerBoostTripleACombo[playerIndex] <= 0) { - gIsPlayerTripleAButtonCombo[playerIndex] = FALSE; + gIsPlayerTripleAButtonCombo[playerIndex] = false; } } } @@ -3289,15 +3289,15 @@ void detect_triple_a_combo_a_pressed(Player *player) { if (player == gPlayerEight) { playerIndex = 7; } - if (gIsPlayerTripleAButtonCombo[playerIndex] == FALSE) { - if (gPlayerIsThrottleActive[playerIndex] == FALSE) { + if (gIsPlayerTripleAButtonCombo[playerIndex] == false) { + if (gPlayerIsThrottleActive[playerIndex] == false) { if ((gFrameSinceLastACombo[playerIndex] < 2) || (gFrameSinceLastACombo[playerIndex] >= 9)) { gCountASwitch[playerIndex] = 0; } gFrameSinceLastACombo[playerIndex] = 0; D_80165400[playerIndex] = 0; } - gPlayerIsThrottleActive[playerIndex] = TRUE; + gPlayerIsThrottleActive[playerIndex] = true; gFrameSinceLastACombo[playerIndex]++; if (gFrameSinceLastACombo[playerIndex] >= 9) { gFrameSinceLastACombo[playerIndex] = 9; @@ -3309,7 +3309,7 @@ void detect_triple_a_combo_a_pressed(Player *player) { D_80165400[playerIndex] = 1; } if (gCountASwitch[playerIndex] == 5) { - gIsPlayerTripleAButtonCombo[playerIndex] = TRUE; + gIsPlayerTripleAButtonCombo[playerIndex] = true; gTimerBoostTripleACombo[playerIndex] = 120; gCountASwitch[playerIndex] = 0; gFrameSinceLastACombo[playerIndex] = 0; @@ -3317,7 +3317,7 @@ void detect_triple_a_combo_a_pressed(Player *player) { } else { gTimerBoostTripleACombo[playerIndex]--; if (gTimerBoostTripleACombo[playerIndex] <= 0) { - gIsPlayerTripleAButtonCombo[playerIndex] = FALSE; + gIsPlayerTripleAButtonCombo[playerIndex] = false; } } } @@ -3326,7 +3326,7 @@ void player_speed(Player *player) { s32 player_index; player_index = get_player_index_for_player(player); - if (gIsPlayerTripleAButtonCombo[player_index] == FALSE) { + if (gIsPlayerTripleAButtonCombo[player_index] == false) { if ((0.0 <= player->currentSpeed) && (player->currentSpeed < (player->topSpeed * 0.1))) { player->currentSpeed += gKartAccelerationTables[player->characterId][0] + (0.05 * (player->slopeAccel / 182)); } @@ -3457,15 +3457,15 @@ void detect_triple_b_combo_b_released(Player *player) { playerIndex = 7; } - if (gIsPlayerTripleBButtonCombo[playerIndex] == FALSE) { - if (gPlayerIsBrakeActive[playerIndex] == TRUE) { + if (gIsPlayerTripleBButtonCombo[playerIndex] == false) { + if (gPlayerIsBrakeActive[playerIndex] == true) { if ((gFrameSinceLastBCombo[playerIndex] < 2) || (gFrameSinceLastBCombo[playerIndex] >= 9)) { gCountBChangement[playerIndex] = 0; } gFrameSinceLastBCombo[playerIndex] = 0; D_801654C0[playerIndex] = 0; } - gPlayerIsBrakeActive[playerIndex] = FALSE; + gPlayerIsBrakeActive[playerIndex] = false; gFrameSinceLastBCombo[playerIndex]++; if (gFrameSinceLastBCombo[playerIndex] >= 9) { gFrameSinceLastBCombo[playerIndex] = 9; @@ -3477,7 +3477,7 @@ void detect_triple_b_combo_b_released(Player *player) { D_801654C0[playerIndex] = 1; } if (gCountBChangement[playerIndex] == 5) { - gIsPlayerTripleBButtonCombo[playerIndex] = TRUE; + gIsPlayerTripleBButtonCombo[playerIndex] = true; gTimerBoostTripleBCombo[playerIndex] = 120; gCountBChangement[playerIndex] = 0; gFrameSinceLastBCombo[playerIndex] = 0; @@ -3485,7 +3485,7 @@ void detect_triple_b_combo_b_released(Player *player) { } else { gTimerBoostTripleBCombo[playerIndex]--; if (gTimerBoostTripleBCombo[playerIndex] <= 0) { - gIsPlayerTripleBButtonCombo[playerIndex] = FALSE; + gIsPlayerTripleBButtonCombo[playerIndex] = false; } } } @@ -3518,15 +3518,15 @@ void detect_triple_b_combo_b_pressed(Player *player) { playerIndex = 7; } - if (gIsPlayerTripleBButtonCombo[playerIndex] == FALSE) { - if (gPlayerIsBrakeActive[playerIndex] == FALSE) { + if (gIsPlayerTripleBButtonCombo[playerIndex] == false) { + if (gPlayerIsBrakeActive[playerIndex] == false) { if ((gFrameSinceLastBCombo[playerIndex] < 2) || (gFrameSinceLastBCombo[playerIndex] >= 9)) { gCountBChangement[playerIndex] = 0; } gFrameSinceLastBCombo[playerIndex] = 0; D_801654C0[playerIndex] = 0; } - gPlayerIsBrakeActive[playerIndex] = TRUE; + gPlayerIsBrakeActive[playerIndex] = true; gFrameSinceLastBCombo[playerIndex]++; if (gFrameSinceLastBCombo[playerIndex] >= 9) { gFrameSinceLastBCombo[playerIndex] = 9; @@ -3538,7 +3538,7 @@ void detect_triple_b_combo_b_pressed(Player *player) { D_801654C0[playerIndex] = 1; } if (gCountBChangement[playerIndex] == 5) { - gIsPlayerTripleBButtonCombo[playerIndex] = TRUE; + gIsPlayerTripleBButtonCombo[playerIndex] = true; gTimerBoostTripleBCombo[playerIndex] = 120; gCountBChangement[playerIndex] = 0; gFrameSinceLastBCombo[playerIndex] = 0; @@ -3546,7 +3546,7 @@ void detect_triple_b_combo_b_pressed(Player *player) { } else { gTimerBoostTripleBCombo[playerIndex]--; if (gTimerBoostTripleBCombo[playerIndex] <= 0) { - gIsPlayerTripleBButtonCombo[playerIndex] = FALSE; + gIsPlayerTripleBButtonCombo[playerIndex] = false; } } } @@ -3602,7 +3602,7 @@ void func_800323E4(Player *player) { player->unk_20C = 2.0f; } } - if (gIsPlayerTripleBButtonCombo[var_v1] == TRUE) { + if (gIsPlayerTripleBButtonCombo[var_v1] == true) { if (player->unk_20C >= 2.0f) { func_80031F48(player, (1.0f - var_f2) * 5.0f); } else { @@ -3807,9 +3807,9 @@ void func_80033850(Player *arg0, f32 arg1) { void func_80033884(Player *player, s32 *arg1, s32 *arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6) { s32 temp_v1; - if ((*arg1 >= arg4) || (-arg4 >= *arg1)) { + if ((*arg1 >= arg4) || (-arg4 >= *arg1)) { temp_v1 = player->unk_200; - player->unk_200 -= 0x800; + player->unk_200 -= 0x800; if (player->unk_200 >= 0xF0000000) { player->unk_200 = temp_v1; } @@ -3827,7 +3827,7 @@ void func_80033884(Player *player, s32 *arg1, s32 *arg2, s32 arg3, s32 arg4, s32 UNUSED void func_80033940(Player *player, s32 *arg1, s32 arg2, s32 arg3, f32 arg4) { u32 temp_v1; - + temp_v1 = player->unk_200; player->unk_200 -= 0x800; if (!(player->unk_200 < 0xF0000000)) { @@ -3846,7 +3846,7 @@ UNUSED void func_80033940(Player *player, s32 *arg1, s32 arg2, s32 arg3, f32 arg void func_800339C4(Player *player, s32 *arg1, s32 arg2, s32 arg3, f32 arg4) { s32 temp_v0; - + temp_v0 = player->unk_200; player->unk_200 -= 0x800; if (player->unk_200 >= 0xF0000000) { @@ -3855,18 +3855,18 @@ void func_800339C4(Player *player, s32 *arg1, s32 arg2, s32 arg3, f32 arg4) { if (arg3 >= (s32)player->unk_200) { player->unk_200 = arg3; } - + *arg1 = (arg2 < *arg1) ? *arg1 - player->unk_200 : *arg1 + player->unk_200; - + func_80033850(player, arg4); } void func_80033A40(Player *player, s32 *arg1, s32 *arg2, s32 arg3, s32 arg4, s32 arg5, f32 arg6) { s32 temp_v1; - if ((*arg1 >= arg4) || (-arg4 >= *arg1)) { + if ((*arg1 >= arg4) || (-arg4 >= *arg1)) { temp_v1 = player->unk_200; - player->unk_200 -= 0x800; + player->unk_200 -= 0x800; if (player->unk_200 >= 0xF0000000) { player->unk_200 = temp_v1; } @@ -4631,17 +4631,17 @@ void func_80037BB4(Player *player, Vec3f arg1) { } void func_80037CFC(Player *player, struct Controller *controller, s8 arg2) { - if (((player->effects & 0x80) != 0x80) && - ((player->effects & 0x40) != 0x40) && - ((player->effects & 0x400) != 0x400) && - ((player->effects & 0x4000) != 0x4000) && - ((player->effects & 0x01000000) != 0x01000000) && - ((player->effects & HIT_BY_ITEM_EFFECT) != HIT_BY_ITEM_EFFECT) && ((player->effects & 0x10000) != 0x10000) && + if (((player->effects & 0x80) != 0x80) && + ((player->effects & 0x40) != 0x40) && + ((player->effects & 0x400) != 0x400) && + ((player->effects & 0x4000) != 0x4000) && + ((player->effects & 0x01000000) != 0x01000000) && + ((player->effects & HIT_BY_ITEM_EFFECT) != HIT_BY_ITEM_EFFECT) && ((player->effects & 0x10000) != 0x10000) && ((player->effects & 0x20000) != 0x20000)) { - if (((player->effects & HIT_EFFECT) != HIT_EFFECT) && - ((player->effects & 8) != 8) && - ((player->effects & 2) != 2) && - ((player->effects & 0x10) != 0x10) && + if (((player->effects & HIT_EFFECT) != HIT_EFFECT) && + ((player->effects & 8) != 8) && + ((player->effects & 2) != 2) && + ((player->effects & 0x10) != 0x10) && (controller->buttonPressed & R_TRIG)) { kart_hop(player); if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { @@ -4665,8 +4665,8 @@ void func_80037CFC(Player *player, struct Controller *controller, s8 arg2) { } } } - if (((player->effects & 0x20) == 0x20) && - (((controller->button & B_BUTTON) == 0) || + if (((player->effects & 0x20) == 0x20) && + (((controller->button & B_BUTTON) == 0) || (!(controller->button & A_BUTTON)))) { player->effects &= ~0x20; } @@ -4695,8 +4695,8 @@ void func_80037CFC(Player *player, struct Controller *controller, s8 arg2) { } } if ((!(player->effects & BOOST_RAMP_ASPHALT_EFFECT)) && (!(player->effects & 4))) { - if (((func_800388B0(controller) < (-0x31)) && - (((player->unk_094 / 18.0f) * 216.0f) <= 5.0f)) && + if (((func_800388B0(controller) < (-0x31)) && + (((player->unk_094 / 18.0f) * 216.0f) <= 5.0f)) && (controller->button & B_BUTTON)) { player->currentSpeed = 140.0f; player->unk_044 |= 1; @@ -4718,9 +4718,9 @@ void func_80037CFC(Player *player, struct Controller *controller, s8 arg2) { func_80031F48(player, 5.0f); } } - if (((((player->effects & 0x80) == 0x80) || - ((player->effects & 0x40) == 0x40)) || - ((player->effects & 0x01000000) == 0x01000000)) || + if (((((player->effects & 0x80) == 0x80) || + ((player->effects & 0x40) == 0x40)) || + ((player->effects & 0x01000000) == 0x01000000)) || ((player->effects & HIT_BY_ITEM_EFFECT) == HIT_BY_ITEM_EFFECT)) { if (controller->button & A_BUTTON) { detect_triple_a_combo_a_pressed(player); @@ -4734,8 +4734,8 @@ void func_80037CFC(Player *player, struct Controller *controller, s8 arg2) { } void func_800381AC(Player *player, struct Controller *controller, s8 arg2) { - if (((player->type & PLAYER_EXISTS) == PLAYER_EXISTS) && - ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && + if (((player->type & PLAYER_EXISTS) == PLAYER_EXISTS) && + ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_KART_AI) != PLAYER_KART_AI)) { if ((player->type & PLAYER_START_SEQUENCE) != PLAYER_START_SEQUENCE) { if (((player->unk_0CA & 2) == 2) || ((player->unk_0CA & 8) == 8)) { @@ -4802,7 +4802,7 @@ void func_800382DC(void) { } return; } - + break; } break; @@ -4964,7 +4964,7 @@ void func_80038C6C(Player *player, UNUSED Camera *camera, s8 arg2, s8 playerId) Vec3f sp88; Vec3f sp7C; UNUSED s32 pad[10]; - + player->unk_084 = -10.0f; player->unk_088 = 28.0f; player->topSpeed = 250.0f; @@ -4985,12 +4985,12 @@ void func_80038C6C(Player *player, UNUSED Camera *camera, s8 arg2, s8 playerId) spA4 += sp108[0]; sp9C += sp108[2]; sp114[2] = player->unk_08C; - mtxf_translate_vec3f_mat3(sp114, player->orientationMatrix); - + mtxf_translate_vec3f_mat3(sp114, player->orientationMatrix); + sp88[0] = player->velocity[0]; sp88[1] = player->velocity[1]; sp88[2] = player->velocity[2]; - + sp88[0] += ((((((sp114[0] + spA4) + spF0[0])) - (sp88[0] * (0.12 * (player->kartFriction)))) / 6000.0) / 1); sp88[2] += ((((((sp114[2] + sp9C) + spF0[2])) - (sp88[2] * (0.12 * (player->kartFriction)))) / 6000.0) / 1); sp88[1] += ((((((sp114[1] + spA0) + spF0[1])) - (sp88[1] * (0.12 * (player->kartFriction)))) / 6000.0) / 1); @@ -5068,7 +5068,7 @@ void func_80038C6C(Player *player, UNUSED Camera *camera, s8 arg2, s8 playerId) D_80165070[playerId][0] = sp88[0]; D_80165070[playerId][1] = sp88[1]; D_80165070[playerId][2] = sp88[2]; - + if ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) { if (gKartTopSpeedTable[player->characterId] < player->unk_094) { divOptimize = gKartTopSpeedTable[player->characterId] / player->unk_094; diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp new file mode 100644 index 000000000..f3466be60 --- /dev/null +++ b/src/port/Engine.cpp @@ -0,0 +1,194 @@ +#include "Engine.h" +#include "ui/ImguiUI.h" +#include "ZAPDUtils/Utils/StringHelper.h" +#include "libultraship/src/Context.h" +#include "resource/type/ResourceType.h" +#include "resource/importers/GenericArrayFactory.h" +#include "resource/importers/Vec3fFactory.h" +#include "resource/importers/Vec3sFactory.h" + +#include +#include +#include + +#include + +extern "C" { +float gInterpolationStep = 0.0f; +#include +} + +GameEngine* GameEngine::Instance; + +GameEngine::GameEngine() { + std::vector OTRFiles; + if (const std::string cube_path = LUS::Context::GetPathRelativeToAppDirectory("sp.otr"); std::filesystem::exists(cube_path)) { + OTRFiles.push_back(cube_path); + } + if (const std::string sm64_otr_path = LUS::Context::GetPathRelativeToAppBundle("sm64.otr"); std::filesystem::exists(sm64_otr_path)) { + OTRFiles.push_back(sm64_otr_path); + } + if (const std::string patches_path = LUS::Context::GetPathRelativeToAppDirectory("mods"); !patches_path.empty() && std::filesystem::exists(patches_path)) { + if (std::filesystem::is_directory(patches_path)) { + for (const auto&p: std::filesystem::recursive_directory_iterator(patches_path)) { + if (StringHelper::IEquals(p.path().extension().string(), ".otr")) { + OTRFiles.push_back(p.path().generic_string()); + } + } + } + } + + this->context = LUS::Context::CreateInstance("Spaghettify", "skart64", "spaghettify.cfg.json", OTRFiles, {}, 3); + + auto loader = context->GetResourceManager()->GetResourceLoader(); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Vec3f", static_cast(SF64::ResourceType::Vec3f), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Vec3s", static_cast(SF64::ResourceType::Vec3s), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "GenericArray", static_cast(SF64::ResourceType::GenericArray), 0); +} + +void GameEngine::Create(){ + const auto instance = Instance = new GameEngine(); + GameUI::SetupGuiElements(); +#if defined(__SWITCH__) || defined(__WIIU__) + CVarRegisterInteger("gControlNav", 1); // always enable controller nav on switch/wii u +#endif +} + +void GameEngine::Destroy(){ + +} + +bool ShouldClearTextureCacheAtEndOfFrame = false; + +void GameEngine::StartFrame() const{ + using LUS::KbScancode; + const int32_t dwScancode = this->context->GetWindow()->GetLastScancode(); + this->context->GetWindow()->SetLastScancode(-1); + + switch (dwScancode) { + case KbScancode::LUS_KB_TAB: { + // Toggle HD Assets + CVarSetInteger("gAltAssets", !CVarGetInteger("gAltAssets", 0)); + ShouldClearTextureCacheAtEndOfFrame = true; + break; + } + default: break; + } + this->context->GetWindow()->StartFrame(); +} + +void GameEngine::ProcessFrame(void (*run_one_game_iter)()) const { + this->context->GetWindow()->MainLoop(run_one_game_iter); +} + +void GameEngine::RunCommands(Gfx* Commands) { + gfx_run(Commands, {}); + gfx_end_frame(); + + if (ShouldClearTextureCacheAtEndOfFrame) { + gfx_texture_cache_clear(); + ShouldClearTextureCacheAtEndOfFrame = false; + } +} + +void GameEngine::ProcessGfxCommands(Gfx* commands) { + RunCommands(commands); + Instance->context->GetWindow()->SetTargetFps(30); + Instance->context->GetWindow()->SetMaximumFrameLatency(1); +} + +extern "C" uint32_t GameEngine_GetSampleRate() { + auto player = LUS::Context::GetInstance()->GetAudio()->GetAudioPlayer(); + if (player == nullptr) { + return 0; + } + + if (!player->IsInitialized()) { + return 0; + } + + return player->GetSampleRate(); +} + +extern "C" uint32_t GameEngine_GetSamplesPerFrame(){ + return SAMPLES_PER_FRAME; +} + +// End + +extern "C" float GameEngine_GetAspectRatio() { + return gfx_current_dimensions.aspect_ratio; +} + +extern "C" uint32_t GameEngine_GetGameVersion() { + return 0x00000001; +} + +static const char* sOtrSignature = "__OTR__"; + +extern "C" uint8_t GameEngine_OTRSigCheck(const char* data) { + if(data == nullptr) { + return 0; + } + return strncmp(data, sOtrSignature, strlen(sOtrSignature)) == 0; +} + +// struct TimedEntry { +// uint64_t duration; +// TimerAction action; +// int32_t* address; +// int32_t value; +// bool active; +// }; + +// std::vector gTimerTasks; + + +// uint64_t Timer_GetCurrentMillis() { +// return SDL_GetTicks(); +// } + +// extern "C" s32 Timer_CreateTask(u64 time, TimerAction action, s32* address, s32 value) { +// const auto millis = Timer_GetCurrentMillis(); +// TimedEntry entry = { +// .duration = millis + CYCLES_TO_MSEC_PC(time), +// .action = action, +// .address = address, +// .value = value, +// .active = true, +// }; + +// gTimerTasks.push_back(entry); + +// return gTimerTasks.size() - 1; +// } + +extern "C" void Timer_Increment(int32_t* address, int32_t value) { + *address += value; +} + +extern "C" void Timer_SetValue(int32_t* address, int32_t value) { + *address = value; +} + +// void Timer_CompleteTask(TimedEntry& task) { +// if (task.action != nullptr) { +// task.action(task.address, task.value); +// } +// task.active = false; +// } + +// extern "C" void Timer_Update() { + +// if(gTimerTasks.empty()) { +// return; +// } + +// const auto millis = Timer_GetCurrentMillis(); + +// for (auto& task : gTimerTasks) { +// if (task.active && millis >= task.duration) { +// Timer_CompleteTask(task); +// } +// } +// } diff --git a/src/port/Engine.h b/src/port/Engine.h new file mode 100644 index 000000000..79c29533a --- /dev/null +++ b/src/port/Engine.h @@ -0,0 +1,35 @@ +#pragma once + +#define LOAD_ASSET(path) (path == NULL ? NULL : (GameEngine_OTRSigCheck((const char*) path) ? ResourceGetDataByName((const char*) path) : path)) +#define LOAD_ASSET_RAW(path) ResourceGetDataByName((const char*) path) + +#ifdef __cplusplus +#include +#include +#include "libultraship/src/Context.h" + +#define SAMPLES_HIGH 544 +#define SAMPLES_LOW 528 +#define AUDIO_FRAMES_PER_UPDATE 2 +#define NUM_AUDIO_CHANNELS 2 +#define SAMPLES_PER_FRAME (SAMPLES_HIGH * NUM_AUDIO_CHANNELS * 2) + +class GameEngine { + public: + static GameEngine* Instance; + + std::shared_ptr context; + + GameEngine(); + static void Create(); + void StartFrame() const; + static void RunCommands(Gfx* Commands); + void ProcessFrame(void (*run_one_game_iter)()) const; + static void Destroy(); + static void ProcessGfxCommands(Gfx* commands); +}; +#else +void GameEngine_ProcessGfxCommands(Gfx* commands); +float GameEngine_GetAspectRatio(); +uint8_t GameEngine_OTRSigCheck(char* imgData); +#endif \ No newline at end of file diff --git a/src/port/GBIMiddleware.cpp b/src/port/GBIMiddleware.cpp new file mode 100644 index 000000000..37b86004a --- /dev/null +++ b/src/port/GBIMiddleware.cpp @@ -0,0 +1,54 @@ +#include + +#include "Engine.h" +#include "DisplayList.h" +#include "Array.h" + +extern "C" int GameEngine_OTRSigCheck(const char* data); + +extern "C" void gSPDisplayList(Gfx* pkt, Gfx* dl) { + char* imgData = (char*)dl; + + if (GameEngine_OTRSigCheck(imgData) == 1) { + auto resource = LUS::Context::GetInstance()->GetResourceManager()->LoadResource(imgData); + auto res = std::static_pointer_cast(resource); + dl = &res->Instructions[0]; + dl->words.trace.file = imgData; + dl->words.trace.idx = 0; + dl->words.trace.valid = true; + } + + __gSPDisplayList(pkt, dl); +} + +extern "C" void gSPVertex(Gfx* pkt, uintptr_t v, int n, int v0) { + + if (GameEngine_OTRSigCheck((char*)v) == 1) { + v = (uintptr_t) ResourceGetDataByName((char *) v); + } + + __gSPVertex(pkt, v, n, v0); +} + +extern "C" void gSPInvalidateTexCache(Gfx* pkt, uintptr_t texAddr) { + auto data = reinterpret_cast(texAddr); + + if (texAddr != 0 && GameEngine_OTRSigCheck(data)) { + const auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadResource(data); + const auto type = static_cast(res->GetInitData()->Type); + + switch(type) { + case LUS::ResourceType::DisplayList: + texAddr = reinterpret_cast(&std::static_pointer_cast(res)->Instructions[0]); + break; + case LUS::ResourceType::Array: + texAddr = reinterpret_cast(std::static_pointer_cast(res)->Vertices.data()); + break; + default: + texAddr = reinterpret_cast(res->GetRawPointer()); + break; + } + } + + __gSPInvalidateTexCache(pkt, texAddr); +} diff --git a/src/port/Game.cpp b/src/port/Game.cpp new file mode 100644 index 000000000..9dbb0eb54 --- /dev/null +++ b/src/port/Game.cpp @@ -0,0 +1,42 @@ +#include + +#include +#include "Engine.h" + +extern "C" { + +} + +extern "C" +void Graphics_PushFrame(Gfx* data) { + GameEngine::ProcessGfxCommands(data); +} + +extern "C" void Timer_Update(); + +void push_frame() { + // GameEngine::StartAudioFrame(); + GameEngine::Instance->StartFrame(); + // Graphics_ThreadUpdate();w + // Timer_Update(); + // thread5_iteration(); + // GameEngine::EndAudioFrame(); +} + +#ifdef _WIN32 +int SDL_main(int argc, char **argv) { +#else +#if defined(__cplusplus) && defined(PLATFORM_IOS) +extern "C" +#endif +int main(int argc, char *argv[]) { +#endif + GameEngine::Create(); + // Main_SetVIMode(); + // Lib_FillScreen(1); + // Main_Initialize(); + // Main_ThreadEntry(NULL); + GameEngine::Instance->ProcessFrame(push_frame); + GameEngine::Instance->Destroy(); + return 0; +} \ No newline at end of file diff --git a/src/port/Variables.cpp b/src/port/Variables.cpp new file mode 100644 index 000000000..f7ccf0eb6 --- /dev/null +++ b/src/port/Variables.cpp @@ -0,0 +1,6 @@ +#include +#include + +extern "C" { + +} \ No newline at end of file diff --git a/src/port/resource/importers/GenericArrayFactory.cpp b/src/port/resource/importers/GenericArrayFactory.cpp new file mode 100644 index 000000000..64608f442 --- /dev/null +++ b/src/port/resource/importers/GenericArrayFactory.cpp @@ -0,0 +1,104 @@ +#include "GenericArrayFactory.h" +#include "../type/GenericArray.h" +#include "spdlog/spdlog.h" + +namespace SF64 { +std::shared_ptr ResourceFactoryBinaryGenericArrayV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { + return nullptr; + } + + auto arr = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader); + + auto type = reader->ReadUInt32(); + + SPDLOG_INFO("GenericArray Type Num: {}", type); + + auto count = reader->ReadUInt32(); + + SPDLOG_INFO("GenericArray Count: {}", count); + + for (uint32_t i = 0; i < count; i++) { + switch (static_cast(type)) { + case ArrayType::u8: { + auto x = reader->ReadUByte(); + arr->mData.push_back(x); + break; + } + case ArrayType::s8: { + auto x = reader->ReadInt8(); + arr->mData.push_back(x); + break; + } + case ArrayType::u16: { + auto x = reader->ReadUInt16(); + std::copy_n(reinterpret_cast(&x), 2, std::back_inserter(arr->mData)); + break; + } + case ArrayType::s16: { + auto x = reader->ReadInt16(); + std::copy_n(reinterpret_cast(&x), 2, std::back_inserter(arr->mData)); + break; + } + case ArrayType::u32: { + auto x = reader->ReadUInt32(); + std::copy_n(reinterpret_cast(&x), 4, std::back_inserter(arr->mData)); + break; + } + case ArrayType::s32: { + auto x = reader->ReadInt32(); + std::copy_n(reinterpret_cast(&x), 4, std::back_inserter(arr->mData)); + break; + } + case ArrayType::u64: { + auto x = reader->ReadUInt64(); + std::copy_n(reinterpret_cast(&x), 8, std::back_inserter(arr->mData)); + break; + } + case ArrayType::f32: { + auto x = reader->ReadFloat(); + std::copy_n(reinterpret_cast(&x), 4, std::back_inserter(arr->mData)); + break; + } + case ArrayType::f64: { + auto x = reader->ReadDouble(); + std::copy_n(reinterpret_cast(&x), 8, std::back_inserter(arr->mData)); + break; + } + case ArrayType::Vec2f: { + Vec2f vec(reader->ReadFloat(), reader->ReadFloat()); + std::copy_n(reinterpret_cast(&vec), sizeof(Vec2f), std::back_inserter(arr->mData)); + break; + } + case ArrayType::Vec3f: { + Vec3f vec(reader->ReadFloat(), reader->ReadFloat(), reader->ReadFloat()); + std::copy_n(reinterpret_cast(&vec), sizeof(Vec3f), std::back_inserter(arr->mData)); + break; + } + case ArrayType::Vec3s: { + Vec3s vec(reader->ReadInt16(), reader->ReadInt16(), reader->ReadInt16()); + std::copy_n(reinterpret_cast(&vec), sizeof(Vec3s), std::back_inserter(arr->mData)); + break; + } + case ArrayType::Vec3i: { + Vec3i vec(reader->ReadInt32(), reader->ReadInt32(), reader->ReadInt32()); + std::copy_n(reinterpret_cast(&vec), sizeof(Vec3i), std::back_inserter(arr->mData)); + break; + } + case ArrayType::Vec4f: { + Vec4f vec(reader->ReadFloat(), reader->ReadFloat(), reader->ReadFloat(), reader->ReadFloat()); + std::copy_n(reinterpret_cast(&vec), sizeof(Vec4f), std::back_inserter(arr->mData)); + break; + } + case ArrayType::Vec4s: { + Vec4s vec(reader->ReadInt16(), reader->ReadInt16(), reader->ReadInt16(), reader->ReadInt16()); + std::copy_n(reinterpret_cast(&vec), sizeof(Vec4s), std::back_inserter(arr->mData)); + break; + } + } + } + + return arr; +} +} // namespace LUS diff --git a/src/port/resource/importers/GenericArrayFactory.h b/src/port/resource/importers/GenericArrayFactory.h new file mode 100644 index 000000000..ce0d2262a --- /dev/null +++ b/src/port/resource/importers/GenericArrayFactory.h @@ -0,0 +1,11 @@ +#pragma once + +#include "Resource.h" +#include "ResourceFactoryBinary.h" + +namespace SF64 { +class ResourceFactoryBinaryGenericArrayV0 : public LUS::ResourceFactoryBinary { + public: + std::shared_ptr ReadResource(std::shared_ptr file) override; +}; +}; // namespace LUS diff --git a/src/port/resource/importers/ResourceUtil.h b/src/port/resource/importers/ResourceUtil.h new file mode 100644 index 000000000..4872ad649 --- /dev/null +++ b/src/port/resource/importers/ResourceUtil.h @@ -0,0 +1,15 @@ +#pragma once + +#include "resourcebridge.h" +#include "Context.h" + +namespace SF64 { +template T LoadChild(uint64_t crc) { + auto path = ResourceGetNameByCrc(crc); + if (path == nullptr) { + return nullptr; + } + auto asset = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(path); + return asset ? static_cast(asset->GetRawPointer()) : nullptr; +} +} \ No newline at end of file diff --git a/src/port/resource/importers/Vec3fFactory.cpp b/src/port/resource/importers/Vec3fFactory.cpp new file mode 100644 index 000000000..e93b4f3d5 --- /dev/null +++ b/src/port/resource/importers/Vec3fFactory.cpp @@ -0,0 +1,27 @@ +#include "Vec3fFactory.h" +#include "../type/Vec3fArray.h" +#include "spdlog/spdlog.h" + +namespace SF64 { +std::shared_ptr ResourceFactoryBinaryVec3fV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { + return nullptr; + } + + auto vec = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader); + + auto vecCount = reader->ReadUInt32(); + + SPDLOG_INFO("Vec3f Count: {}", vecCount); + + for (uint32_t i = 0; i < vecCount; i++) { + auto x = reader->ReadFloat(); + auto y = reader->ReadFloat(); + auto z = reader->ReadFloat(); + vec->mData.emplace_back(x, y, z); + } + + return vec; +} +} // namespace LUS diff --git a/src/port/resource/importers/Vec3fFactory.h b/src/port/resource/importers/Vec3fFactory.h new file mode 100644 index 000000000..ee7ac7e0c --- /dev/null +++ b/src/port/resource/importers/Vec3fFactory.h @@ -0,0 +1,11 @@ +#pragma once + +#include "Resource.h" +#include "ResourceFactoryBinary.h" + +namespace SF64 { +class ResourceFactoryBinaryVec3fV0 : public LUS::ResourceFactoryBinary { + public: + std::shared_ptr ReadResource(std::shared_ptr file) override; +}; +}; // namespace LUS diff --git a/src/port/resource/importers/Vec3sFactory.cpp b/src/port/resource/importers/Vec3sFactory.cpp new file mode 100644 index 000000000..549a1d20f --- /dev/null +++ b/src/port/resource/importers/Vec3sFactory.cpp @@ -0,0 +1,27 @@ +#include "Vec3sFactory.h" +#include "../type/Vec3sArray.h" +#include "spdlog/spdlog.h" + +namespace SF64 { +std::shared_ptr ResourceFactoryBinaryVec3sV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { + return nullptr; + } + + auto vec = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader); + + auto vecCount = reader->ReadUInt32(); + + SPDLOG_INFO("Vec3s Count: {}", vecCount); + + for (uint32_t i = 0; i < vecCount; i++) { + auto x = reader->ReadInt16(); + auto y = reader->ReadInt16(); + auto z = reader->ReadInt16(); + vec->mData.emplace_back(x, y, z); + } + + return vec; +} +} // namespace LUS diff --git a/src/port/resource/importers/Vec3sFactory.h b/src/port/resource/importers/Vec3sFactory.h new file mode 100644 index 000000000..eddcc1dc7 --- /dev/null +++ b/src/port/resource/importers/Vec3sFactory.h @@ -0,0 +1,11 @@ +#pragma once + +#include "Resource.h" +#include "ResourceFactoryBinary.h" + +namespace SF64 { +class ResourceFactoryBinaryVec3sV0 : public LUS::ResourceFactoryBinary { + public: + std::shared_ptr ReadResource(std::shared_ptr file) override; +}; +}; // namespace LUS diff --git a/src/port/resource/type/Animation.cpp b/src/port/resource/type/Animation.cpp new file mode 100644 index 000000000..7cb2c9002 --- /dev/null +++ b/src/port/resource/type/Animation.cpp @@ -0,0 +1,11 @@ +#include "Animation.h" + +namespace SF64 { +AnimationData* Animation::GetPointer() { + return &mData; +} + +size_t Animation::GetPointerSize() { + return sizeof(mData); +} +} \ No newline at end of file diff --git a/src/port/resource/type/Animation.h b/src/port/resource/type/Animation.h new file mode 100644 index 000000000..868aa5d2c --- /dev/null +++ b/src/port/resource/type/Animation.h @@ -0,0 +1,38 @@ +#pragma once + +#include +#include +#include + +namespace SF64 { +struct JointKey { + /* 0x0 */ uint16_t xLen; + /* 0x2 */ uint16_t x; + /* 0x4 */ uint16_t yLen; + /* 0x6 */ uint16_t y; + /* 0x8 */ uint16_t zLen; + /* 0xA */ uint16_t z; +}; // size = 0xC + +struct AnimationData { + /* 0x00 */ int16_t frameCount; + /* 0x02 */ int16_t limbCount; + /* 0x04 */ uint16_t* frameData; + /* 0x08 */ JointKey* jointKey; +}; // size = 0xC + +class Animation : public LUS::Resource { + public: + using Resource::Resource; + + Animation() : Resource(std::shared_ptr()) {} + + AnimationData* GetPointer(); + size_t GetPointerSize(); + + AnimationData mData; + + std::vector frameData; + std::vector jointKey; +}; +} \ No newline at end of file diff --git a/src/port/resource/type/ColPoly.cpp b/src/port/resource/type/ColPoly.cpp new file mode 100644 index 000000000..3823181b9 --- /dev/null +++ b/src/port/resource/type/ColPoly.cpp @@ -0,0 +1,11 @@ +#include "ColPoly.h" + +namespace SF64 { +ColPolyData* ColPoly::GetPointer() { + return mColPolys.data(); +} + +size_t ColPoly::GetPointerSize() { + return sizeof(mColPolys); +} +} \ No newline at end of file diff --git a/src/port/resource/type/ColPoly.h b/src/port/resource/type/ColPoly.h new file mode 100644 index 000000000..49c6c5ba6 --- /dev/null +++ b/src/port/resource/type/ColPoly.h @@ -0,0 +1,33 @@ +#pragma once + +#include +#include +#include + +namespace SF64 { + +struct Vec3s { + int16_t x, y, z; +}; + +struct ColPolyData { + /* 0x00 */ Vec3s tri; + /* 0x06 */ int16_t unk_06; + /* 0x08 */ Vec3s norm; + /* 0x0E */ int16_t unk_0E; + /* 0x10 */ int32_t dist; + ColPolyData(Vec3s tri, int16_t unk_06, Vec3s norm, int16_t unk_0E, int32_t dist) : tri(std::move(tri)), unk_06(unk_06), norm(std::move(norm)), unk_0E(unk_0E), dist(dist) {} +}; // size = 0x14 + +class ColPoly : public LUS::Resource { + public: + using Resource::Resource; + + ColPoly() : Resource(std::shared_ptr()) {} + + ColPolyData* GetPointer(); + size_t GetPointerSize(); + + std::vector mColPolys; +}; +} \ No newline at end of file diff --git a/src/port/resource/type/EnvSettings.cpp b/src/port/resource/type/EnvSettings.cpp new file mode 100644 index 000000000..54dde2734 --- /dev/null +++ b/src/port/resource/type/EnvSettings.cpp @@ -0,0 +1,11 @@ +#include "EnvSettings.h" + +namespace SF64 { +EnvSettingsData* EnvSettings::GetPointer() { + return &mSettings; +} + +size_t EnvSettings::GetPointerSize() { + return sizeof(EnvSettingsData); +} +} \ No newline at end of file diff --git a/src/port/resource/type/EnvSettings.h b/src/port/resource/type/EnvSettings.h new file mode 100644 index 000000000..eba0e47ef --- /dev/null +++ b/src/port/resource/type/EnvSettings.h @@ -0,0 +1,40 @@ +#pragma once + +#include "Limb.h" + +#include +#include + +namespace SF64 { + +struct EnvSettingsData { + /* 0x00 */ int32_t type; + /* 0x04 */ int32_t unk_04; + /* 0x08 */ uint16_t bgColor; + /* 0x0A */ uint16_t seqId; + /* 0x0C */ int32_t fogR; + /* 0x10 */ int32_t fogG; + /* 0x14 */ int32_t fogB; + /* 0x18 */ int32_t fogN; + /* 0x1C */ int32_t fogF; + /* 0x20 */ Vec3f unk_20; + /* 0x2C */ int32_t lightR; + /* 0x30 */ int32_t lightG; + /* 0x34 */ int32_t lightB; + /* 0x38 */ int32_t ambR; + /* 0x3C */ int32_t ambG; + /* 0x40 */ int32_t ambB; +}; + +class EnvSettings : public LUS::Resource { + public: + using Resource::Resource; + + EnvSettings() : Resource(std::shared_ptr()) {} + + EnvSettingsData* GetPointer(); + size_t GetPointerSize(); + + EnvSettingsData mSettings{}; +}; +} \ No newline at end of file diff --git a/src/port/resource/type/GenericArray.cpp b/src/port/resource/type/GenericArray.cpp new file mode 100644 index 000000000..74332a7e4 --- /dev/null +++ b/src/port/resource/type/GenericArray.cpp @@ -0,0 +1,11 @@ +#include "GenericArray.h" + +namespace SF64 { +uint8_t* GenericArray::GetPointer() { + return mData.data(); +} + +size_t GenericArray::GetPointerSize() { + return mData.size(); +} +} \ No newline at end of file diff --git a/src/port/resource/type/GenericArray.h b/src/port/resource/type/GenericArray.h new file mode 100644 index 000000000..576c60150 --- /dev/null +++ b/src/port/resource/type/GenericArray.h @@ -0,0 +1,55 @@ +#pragma once + +#include +#include +#include + +namespace SF64 { + +struct Vec2f { + float x, y; + Vec2f(float x, float y) : x(x), y(y) {} +}; + +struct Vec3f { + float x, y, z; + Vec3f(float x, float y, float z) : x(x), y(y), z(z) {} +}; + +struct Vec3s { + int16_t x, y, z; + Vec3s(int16_t x, int16_t y, int16_t z) : x(x), y(y), z(z) {} +}; + +struct Vec3i { + int32_t x, y, z; + Vec3i(int32_t x, int32_t y, int32_t z) : x(x), y(y), z(z) {} +}; + +struct Vec4f { + float x, y, z, w; + Vec4f(float x, float y, float z, float w) : x(x), y(y), z(z), w(w) {} +}; + +struct Vec4s { + int16_t x, y, z, w; + Vec4s(int16_t x, int16_t y, int16_t z, int16_t w) : x(x), y(y), z(z), w(w) {} +}; + +enum class ArrayType { + u8, s8, u16, s16, u32, s32, u64, f32, f64, Vec2f, Vec3f, Vec3s, Vec3i, Vec4f, Vec4s, +}; + +class GenericArray : public LUS::Resource { + public: + using Resource::Resource; + + GenericArray() : Resource(std::shared_ptr()) {} + + uint8_t* GetPointer(); + size_t GetPointerSize(); + + std::vector mData; + size_t mSize; +}; +} \ No newline at end of file diff --git a/src/port/resource/type/Hitbox.cpp b/src/port/resource/type/Hitbox.cpp new file mode 100644 index 000000000..44a31ba30 --- /dev/null +++ b/src/port/resource/type/Hitbox.cpp @@ -0,0 +1,11 @@ +#include "Hitbox.h" + +namespace SF64 { +float* Hitbox::GetPointer() { + return mHitbox.data(); +} + +size_t Hitbox::GetPointerSize() { + return sizeof(float) * mHitbox.size(); +} +} \ No newline at end of file diff --git a/src/port/resource/type/Hitbox.h b/src/port/resource/type/Hitbox.h new file mode 100644 index 000000000..832eedf15 --- /dev/null +++ b/src/port/resource/type/Hitbox.h @@ -0,0 +1,16 @@ +#pragma once + +#include +#include + +namespace SF64 { +class Hitbox : public LUS::Resource { + public: + using Resource::Resource; + + float* GetPointer() override; + size_t GetPointerSize() override; + + std::vector mHitbox; +}; +} \ No newline at end of file diff --git a/src/port/resource/type/Limb.cpp b/src/port/resource/type/Limb.cpp new file mode 100644 index 000000000..a2030c32f --- /dev/null +++ b/src/port/resource/type/Limb.cpp @@ -0,0 +1,11 @@ +#include "Limb.h" + +namespace SF64 { +LimbData* Limb::GetPointer() { + return &mData; +} + +size_t Limb::GetPointerSize() { + return sizeof(mData); +} +} \ No newline at end of file diff --git a/src/port/resource/type/Limb.h b/src/port/resource/type/Limb.h new file mode 100644 index 000000000..eb12e2e32 --- /dev/null +++ b/src/port/resource/type/Limb.h @@ -0,0 +1,37 @@ +#pragma once + +#include +#include + +namespace SF64 { + +struct Vec3f { + float x, y, z; +}; + +struct Vec3s { + int16_t x, y, z; +}; + +struct Gfx; + +struct LimbData { + /* 0x000 */ Gfx* dList; + /* 0x004 */ Vec3f trans; + /* 0x010 */ Vec3s rot; + /* 0x018 */ LimbData* sibling; + /* 0x01C */ LimbData* child; +}; // size = 0x20 + +class Limb : public LUS::Resource { + public: + using Resource::Resource; + + Limb() : Resource(std::shared_ptr()) {} + + LimbData* GetPointer(); + size_t GetPointerSize(); + + LimbData mData{}; +}; +} \ No newline at end of file diff --git a/src/port/resource/type/Message.cpp b/src/port/resource/type/Message.cpp new file mode 100644 index 000000000..a0708f608 --- /dev/null +++ b/src/port/resource/type/Message.cpp @@ -0,0 +1,19 @@ +#include "Message.h" + +namespace SF64 { +void* Message::GetPointer() { + return mMessage.data(); +} + +size_t Message::GetPointerSize() { + return mMessage.size() * sizeof(uint16_t); +} + +MsgLookup* MessageLookup::GetPointer() { + return mLookupTable.data(); +} + +size_t MessageLookup::GetPointerSize() { + return mLookupTable.size() * sizeof(MsgLookup); +} +} \ No newline at end of file diff --git a/src/port/resource/type/Message.h b/src/port/resource/type/Message.h new file mode 100644 index 000000000..ac0748627 --- /dev/null +++ b/src/port/resource/type/Message.h @@ -0,0 +1,32 @@ +#pragma once + +#include +#include +#include + +namespace SF64 { +typedef struct { + s32 msgId; + u16* msgPtr; +} MsgLookup; + +class Message : public LUS::Resource { + public: + using Resource::Resource; + + void* GetPointer() override; + size_t GetPointerSize() override; + + std::vector mMessage; +}; + +class MessageLookup : public LUS::Resource { + public: + using Resource::Resource; + + MsgLookup* GetPointer() override; + size_t GetPointerSize() override; + + std::vector mLookupTable; +}; +} \ No newline at end of file diff --git a/src/port/resource/type/ObjectInit.cpp b/src/port/resource/type/ObjectInit.cpp new file mode 100644 index 000000000..3fe6e95b7 --- /dev/null +++ b/src/port/resource/type/ObjectInit.cpp @@ -0,0 +1,11 @@ +#include "ObjectInit.h" + +namespace SF64 { +ObjectInitData* ObjectInit::GetPointer() { + return mObjects.data(); +} + +size_t ObjectInit::GetPointerSize() { + return sizeof(ObjectInitData) * mObjects.size(); +} +} \ No newline at end of file diff --git a/src/port/resource/type/ObjectInit.h b/src/port/resource/type/ObjectInit.h new file mode 100644 index 000000000..56f755665 --- /dev/null +++ b/src/port/resource/type/ObjectInit.h @@ -0,0 +1,30 @@ +#pragma once + +#include "Limb.h" + +#include +#include + +namespace SF64 { + +struct ObjectInitData { + /* 0x00 */ float zPos1; + /* 0x04 */ int16_t zPos2; + /* 0x06 */ int16_t xPos; + /* 0x08 */ int16_t yPos; + /* 0x0A */ Vec3s rot; + /* 0x10 */ int16_t id; +}; // size = 0x14 + +class ObjectInit : public LUS::Resource { + public: + using Resource::Resource; + + ObjectInit() : Resource(std::shared_ptr()) {} + + ObjectInitData* GetPointer(); + size_t GetPointerSize(); + + std::vector mObjects; +}; +} \ No newline at end of file diff --git a/src/port/resource/type/ResourceType.h b/src/port/resource/type/ResourceType.h new file mode 100644 index 000000000..c143457d2 --- /dev/null +++ b/src/port/resource/type/ResourceType.h @@ -0,0 +1,21 @@ +#pragma once + +namespace SF64 { +enum class ResourceType { + // SF64 + AnimData = 0x414E494D, // ANIM + ColPoly = 0x43504C59, // CPLY + EnvSettings = 0x454E5653, // ENVS + Limb = 0x4C494D42, // LIMB + Message = 0x4D534720, // MSG + MessageTable = 0x4D534754, // MSGT + Skeleton = 0x534B454C, // SKEL + Script = 0x53435250, // SCRP + ScriptCmd = 0x53434D44, // SCMD + Hitbox = 0x48544258, // HTBX + ObjectInit = 0x4F42494E, // OBIN + Vec3f = 0x56433346, // VC3F + Vec3s = 0x56433353, // VC3S + GenericArray = 0x47415252, // GARR +}; +} // namespace SOH diff --git a/src/port/resource/type/Script.cpp b/src/port/resource/type/Script.cpp new file mode 100644 index 000000000..71ddc7680 --- /dev/null +++ b/src/port/resource/type/Script.cpp @@ -0,0 +1,19 @@ +#include "Script.h" + +namespace SF64 { +uint16_t** Script::GetPointer() { + return mScripts.data(); +} + +size_t Script::GetPointerSize() { + return sizeof(uint16_t*) * mScripts.size(); +} + +uint16_t* ScriptCMDs::GetPointer() { + return mCommands.data(); +} + +size_t ScriptCMDs::GetPointerSize() { + return sizeof(uint16_t) * mCommands.size(); +} +} \ No newline at end of file diff --git a/src/port/resource/type/Script.h b/src/port/resource/type/Script.h new file mode 100644 index 000000000..55d0b348d --- /dev/null +++ b/src/port/resource/type/Script.h @@ -0,0 +1,26 @@ +#pragma once + +#include +#include + +namespace SF64 { +class Script : public LUS::Resource { + public: + using Resource::Resource; + + uint16_t** GetPointer() override; + size_t GetPointerSize() override; + + std::vector mScripts; +}; + +class ScriptCMDs : public LUS::Resource { + public: + using Resource::Resource; + + uint16_t* GetPointer() override; + size_t GetPointerSize() override; + + std::vector mCommands; +}; +} \ No newline at end of file diff --git a/src/port/resource/type/Skeleton.cpp b/src/port/resource/type/Skeleton.cpp new file mode 100644 index 000000000..49e9a59ad --- /dev/null +++ b/src/port/resource/type/Skeleton.cpp @@ -0,0 +1,11 @@ +#include "Skeleton.h" + +namespace SF64 { +LimbData** Skeleton::GetPointer() { + return mLimbs.data(); +} + +size_t Skeleton::GetPointerSize() { + return mLimbs.size() * sizeof(LimbData*); +} +} \ No newline at end of file diff --git a/src/port/resource/type/Skeleton.h b/src/port/resource/type/Skeleton.h new file mode 100644 index 000000000..3332abf77 --- /dev/null +++ b/src/port/resource/type/Skeleton.h @@ -0,0 +1,19 @@ +#pragma once + +#include "Limb.h" + +#include + +namespace SF64 { +class Skeleton : public LUS::Resource { + public: + using Resource::Resource; + + Skeleton() : Resource(std::shared_ptr()) {} + + LimbData** GetPointer(); + size_t GetPointerSize(); + + std::vector mLimbs; +}; +} \ No newline at end of file diff --git a/src/port/resource/type/Vec3fArray.cpp b/src/port/resource/type/Vec3fArray.cpp new file mode 100644 index 000000000..27ccd1d9e --- /dev/null +++ b/src/port/resource/type/Vec3fArray.cpp @@ -0,0 +1,11 @@ +#include "Vec3fArray.h" + +namespace SF64 { +Vec3fData* Vec3fArray::GetPointer() { + return mData.data(); +} + +size_t Vec3fArray::GetPointerSize() { + return sizeof(mData); +} +} \ No newline at end of file diff --git a/src/port/resource/type/Vec3fArray.h b/src/port/resource/type/Vec3fArray.h new file mode 100644 index 000000000..9a6cb0bdf --- /dev/null +++ b/src/port/resource/type/Vec3fArray.h @@ -0,0 +1,25 @@ +#pragma once + +#include +#include +#include + +namespace SF64 { + +struct Vec3fData { + float x, y, z; + Vec3fData(float x, float y, float z) : x(x), y(y), z(z) {} +}; + +class Vec3fArray : public LUS::Resource { + public: + using Resource::Resource; + + Vec3fArray() : Resource(std::shared_ptr()) {} + + Vec3fData* GetPointer(); + size_t GetPointerSize(); + + std::vector mData; +}; +} \ No newline at end of file diff --git a/src/port/resource/type/Vec3sArray.cpp b/src/port/resource/type/Vec3sArray.cpp new file mode 100644 index 000000000..e6c4fa2d7 --- /dev/null +++ b/src/port/resource/type/Vec3sArray.cpp @@ -0,0 +1,11 @@ +#include "Vec3sArray.h" + +namespace SF64 { +Vec3sData* Vec3sArray::GetPointer() { + return mData.data(); +} + +size_t Vec3sArray::GetPointerSize() { + return sizeof(mData); +} +} \ No newline at end of file diff --git a/src/port/resource/type/Vec3sArray.h b/src/port/resource/type/Vec3sArray.h new file mode 100644 index 000000000..5e8f466b9 --- /dev/null +++ b/src/port/resource/type/Vec3sArray.h @@ -0,0 +1,25 @@ +#pragma once + +#include +#include +#include + +namespace SF64 { + +struct Vec3sData { + int16_t x, y, z; + Vec3sData(int16_t x, int16_t y, int16_t z) : x(x), y(y), z(z) {} +}; + +class Vec3sArray : public LUS::Resource { + public: + using Resource::Resource; + + Vec3sArray() : Resource(std::shared_ptr()) {} + + Vec3sData* GetPointer(); + size_t GetPointerSize(); + + std::vector mData; +}; +} \ No newline at end of file diff --git a/src/port/ui/ImguiUI.cpp b/src/port/ui/ImguiUI.cpp new file mode 100644 index 000000000..83e91ed6b --- /dev/null +++ b/src/port/ui/ImguiUI.cpp @@ -0,0 +1,510 @@ +#include "ImguiUI.h" +#include "UIWidgets.h" +#include "ResolutionEditor.h" + +#include +#include +#define IMGUI_DEFINE_MATH_OPERATORS +#include "libultraship/src/Context.h" + +#include +#include +#include +#include "port/Engine.h" + +extern "C" { + +} + +namespace GameUI { +std::shared_ptr mGameMenuBar; +std::shared_ptr mConsoleWindow; +std::shared_ptr mStatsWindow; +std::shared_ptr mInputEditorWindow; +std::shared_ptr mGfxDebuggerWindow; +std::shared_ptr mAdvancedResolutionSettingsWindow; + +void SetupGuiElements() { + auto gui = LUS::Context::GetInstance()->GetWindow()->GetGui(); + + auto& style = ImGui::GetStyle(); + style.FramePadding = ImVec2(4.0f, 6.0f); + style.ItemSpacing = ImVec2(8.0f, 6.0f); + style.Colors[ImGuiCol_MenuBarBg] = UIWidgets::Colors::DarkGray; + + mGameMenuBar = std::make_shared("gOpenMenuBar", CVarGetInteger("gOpenMenuBar", 0)); + gui->SetMenuBar(mGameMenuBar); + mStatsWindow = gui->GetGuiWindow("Stats"); + if (mStatsWindow == nullptr) { + SPDLOG_ERROR("Could not find stats window"); + } + + mConsoleWindow = gui->GetGuiWindow("Console"); + if (mConsoleWindow == nullptr) { + SPDLOG_ERROR("Could not find console window"); + } + + mInputEditorWindow = gui->GetGuiWindow("Input Editor"); + if (mInputEditorWindow == nullptr) { + SPDLOG_ERROR("Could not find input editor window"); + return; + } + + mGfxDebuggerWindow = gui->GetGuiWindow("GfxDebuggerWindow"); + if (mGfxDebuggerWindow == nullptr) { + SPDLOG_ERROR("Could not find input GfxDebuggerWindow"); + } + + mAdvancedResolutionSettingsWindow = std::make_shared("gAdvancedResolutionEditorEnabled", "Advanced Resolution Settings"); + gui->AddGuiWindow(mAdvancedResolutionSettingsWindow); +} + +void Destroy() { + mAdvancedResolutionSettingsWindow = nullptr; + mConsoleWindow = nullptr; + mStatsWindow = nullptr; + mInputEditorWindow = nullptr; +} + +std::string GetWindowButtonText(const char* text, bool menuOpen) { + char buttonText[100] = ""; + if (menuOpen) { + strcat(buttonText, ICON_FA_CHEVRON_RIGHT " "); + } + strcat(buttonText, text); + if (!menuOpen) { strcat(buttonText, " "); } + return buttonText; +} +} + +static const char* filters[3] = { +#ifdef __WIIU__ + "", +#else + "Three-Point", +#endif + "Linear", "None" +}; + +void DrawSettingsMenu(){ + if(UIWidgets::BeginMenu("Settings")){ + // if (UIWidgets::BeginMenu("Audio")) { + // UIWidgets::CVarSliderFloat("Master Volume", "gGameMasterVolume", 0.0f, 1.0f, 1.0f, { + // .format = "%.0f%%", + // .isPercentage = true, + // }); + // if (UIWidgets::CVarSliderFloat("Main Music Volume", "gMainMusicVolume", 0.0f, 1.0f, 1.0f, { + // .format = "%.0f%%", + // .isPercentage = true, + // })) { + // audio_set_player_volume(SEQ_PLAYER_LEVEL, CVarGetFloat("gMainMusicVolume", 1.0f)); + // } + // if (UIWidgets::CVarSliderFloat("Sound Effects Volume", "gSFXMusicVolume", 0.0f, 1.0f, 1.0f, { + // .format = "%.0f%%", + // .isPercentage = true, + // })) { + // audio_set_player_volume(SEQ_PLAYER_SFX, CVarGetFloat("gSFXMusicVolume", 1.0f)); + // } + // if (UIWidgets::CVarSliderFloat("Environment Volume", "gEnvironmentVolume", 0.0f, 1.0f, 1.0f, { + // .format = "%.0f%%", + // .isPercentage = true, + // })) { + // audio_set_player_volume(SEQ_PLAYER_ENV, CVarGetFloat("gEnvironmentVolume", 1.0f)); + // } + // + // static std::unordered_map audioBackendNames = { + // { LUS::AudioBackend::WASAPI, "Windows Audio Session API" }, + // { LUS::AudioBackend::PULSE, "PulseAudio" }, + // { LUS::AudioBackend::SDL, "SDL" }, + // }; + // + // ImGui::Text("Audio API (Needs reload)"); + // auto currentAudioBackend = LUS::Context::GetInstance()->GetAudio()->GetAudioBackend(); + // + // if (LUS::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) { + // UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); + // } + // if (ImGui::BeginCombo("##AApi", audioBackendNames[currentAudioBackend])) { + // for (uint8_t i = 0; i < LUS::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size(); i++) { + // auto backend = LUS::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->data()[i]; + // if (ImGui::Selectable(audioBackendNames[backend], backend == currentAudioBackend)) { + // LUS::Context::GetInstance()->GetAudio()->SetAudioBackend(backend); + // } + // } + // ImGui::EndCombo(); + // } + // if (LUS::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) { + // UIWidgets::ReEnableComponent(""); + // } + // + // ImGui::EndMenu(); + // } + + UIWidgets::Spacer(0); + + if (UIWidgets::BeginMenu("Controller")) { + UIWidgets::WindowButton("Controller Mapping", "gInputEditorWindow", GameUI::mInputEditorWindow); + + UIWidgets::Spacer(0); + +#ifndef __SWITCH__ + UIWidgets::CVarCheckbox("Menubar Controller Navigation", "gControlNav", { + .tooltip = "Allows controller navigation of the SOH menu bar (Settings, Enhancements,...)\nCAUTION: This will disable game inputs while the menubar is visible.\n\nD-pad to move between items, A to select, and X to grab focus on the menu bar" + }); +#endif + UIWidgets::CVarCheckbox("Show Inputs", "gInputEnabled", { + .tooltip = "Shows currently pressed inputs on the bottom right of the screen" + }); + if (CVarGetInteger("gInputEnabled", 0)) { + UIWidgets::CVarSliderFloat("Input Scale", "gInputScale", 1.0f, 3.0f, 1.0f, { + .tooltip = "Sets the on screen size of the displayed inputs from the Show Inputs setting", + .format = "%.1fx", + }); + } + + ImGui::EndMenu(); + } + + ImGui::EndMenu(); + } + + ImGui::SetCursorPosY(0.0f); + if (UIWidgets::BeginMenu("Graphics")) { + UIWidgets::WindowButton("Resolution Editor", "gAdvancedResolutionEditorEnabled", GameUI::mAdvancedResolutionSettingsWindow); + + UIWidgets::Spacer(0); + + // Previously was running every frame, and nothing was setting it? Maybe a bad copy/paste? + // LUS::Context::GetInstance()->GetWindow()->SetResolutionMultiplier(CVarGetFloat("gInternalResolution", 1)); + // UIWidgets::Tooltip("Multiplies your output resolution by the value inputted, as a more intensive but effective form of anti-aliasing"); +#ifndef __WIIU__ + if (UIWidgets::CVarSliderInt("MSAA: %d", "gMSAAValue", 1, 8, 1, { + .tooltip = "Activates multi-sample anti-aliasing when above 1x up to 8x for 8 samples for every pixel" + })) { + LUS::Context::GetInstance()->GetWindow()->SetMsaaLevel(CVarGetInteger("gMSAAValue", 1)); + } +#endif + + { // FPS Slider + const int minFps = 30; + static int maxFps; + if (LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() == LUS::WindowBackend::DX11) { + maxFps = 360; + } else { + maxFps = LUS::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); + } + int currentFps = 0; + #ifdef __WIIU__ + UIWidgets::Spacer(0); + // only support divisors of 60 on the Wii U + if (currentFps > 60) { + currentFps = 60; + } else { + currentFps = 60 / (60 / currentFps); + } + + int fpsSlider = 1; + if (currentFps == 30) { + ImGui::Text("FPS: Original (30)"); + } else { + ImGui::Text("FPS: %d", currentFps); + if (currentFps == 30) { + fpsSlider = 2; + } else { // currentFps == 60 + fpsSlider = 3; + } + } + if (CVarGetInteger("gMatchRefreshRate", 0)) { + UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); + } + + if (ImGui::Button(" - ##WiiUFPS")) { + fpsSlider--; + } + ImGui::SameLine(); + ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); + + UIWidgets::Spacer(0); + + ImGui::PushItemWidth(std::min((ImGui::GetContentRegionAvail().x - 60.0f), 260.0f)); + ImGui::SliderInt("##WiiUFPSSlider", &fpsSlider, 1, 3, "", ImGuiSliderFlags_AlwaysClamp); + ImGui::PopItemWidth(); + + ImGui::SameLine(); + ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); + if (ImGui::Button(" + ##WiiUFPS")) { + fpsSlider++; + } + + if (CVarGetInteger("gMatchRefreshRate", 0)) { + UIWidgets::ReEnableComponent(""); + } + if (fpsSlider > 3) { + fpsSlider = 3; + } else if (fpsSlider < 1) { + fpsSlider = 1; + } + + if (fpsSlider == 1) { + currentFps = 20; + } else if (fpsSlider == 2) { + currentFps = 30; + } else if (fpsSlider == 3) { + currentFps = 60; + } + CVarSetInteger("gInterpolationFPS", currentFps); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + #else + bool matchingRefreshRate = + CVarGetInteger("gMatchRefreshRate", 0) && LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() != LUS::WindowBackend::DX11; + UIWidgets::CVarSliderInt((currentFps == 20) ? "FPS: Original (20)" : "FPS: %d", "gInterpolationFPS", minFps, maxFps, 1, { + .disabled = matchingRefreshRate + }); + #endif + if (LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() == LUS::WindowBackend::DX11) { + UIWidgets::Tooltip( + "Uses Matrix Interpolation to create extra frames, resulting in smoother graphics. This is purely " + "visual and does not impact game logic, execution of glitches etc.\n\n" + "A higher target FPS than your monitor's refresh rate will waste resources, and might give a worse result." + ); + } else { + UIWidgets::Tooltip( + "Uses Matrix Interpolation to create extra frames, resulting in smoother graphics. This is purely " + "visual and does not impact game logic, execution of glitches etc." + ); + } + } // END FPS Slider + + if (LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() == LUS::WindowBackend::DX11) { + UIWidgets::Spacer(0); + if (ImGui::Button("Match Refresh Rate")) { + int hz = LUS::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); + if (hz >= 30 && hz <= 360) { + CVarSetInteger("gInterpolationFPS", hz); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + } + } + } else { + UIWidgets::PaddedEnhancementCheckbox("Match Refresh Rate", "gMatchRefreshRate", true, false); + } + + UIWidgets::Tooltip("Matches interpolation value to the current game's window refresh rate"); + + if (LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() == LUS::WindowBackend::DX11) { + UIWidgets::PaddedEnhancementSliderInt(CVarGetInteger("gExtraLatencyThreshold", 80) == 0 ? "Jitter fix: Off" : "Jitter fix: >= %d FPS", + "##ExtraLatencyThreshold", "gExtraLatencyThreshold", 0, 360, "", 80, true, true, false); + UIWidgets::Tooltip("When Interpolation FPS setting is at least this threshold, add one frame of input lag (e.g. 16.6 ms for 60 FPS) in order to avoid jitter. This setting allows the CPU to work on one frame while GPU works on the previous frame.\nThis setting should be used when your computer is too slow to do CPU + GPU work in time."); + } + + UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); + + + static std::unordered_map windowBackendNames = { + { LUS::WindowBackend::DX11, "DirectX" }, + { LUS::WindowBackend::SDL_OPENGL, "OpenGL"}, + { LUS::WindowBackend::SDL_METAL, "Metal" }, + { LUS::WindowBackend::GX2, "GX2"} + }; + + ImGui::Text("Renderer API (Needs reload)"); + LUS::WindowBackend runningWindowBackend = LUS::Context::GetInstance()->GetWindow()->GetWindowBackend(); + LUS::WindowBackend configWindowBackend; + int configWindowBackendId = LUS::Context::GetInstance()->GetConfig()->GetInt("Window.Backend.Id", -1); + if (configWindowBackendId != -1 && configWindowBackendId < static_cast(LUS::WindowBackend::BACKEND_COUNT)) { + configWindowBackend = static_cast(configWindowBackendId); + } else { + configWindowBackend = runningWindowBackend; + } + + if (LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size() <= 1) { + UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); + } + if (ImGui::BeginCombo("##RApi", windowBackendNames[configWindowBackend])) { + for (size_t i = 0; i < LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size(); i++) { + auto backend = LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->data()[i]; + if (ImGui::Selectable(windowBackendNames[backend], backend == configWindowBackend)) { + LUS::Context::GetInstance()->GetConfig()->SetInt("Window.Backend.Id", static_cast(backend)); + LUS::Context::GetInstance()->GetConfig()->SetString("Window.Backend.Name", + windowBackendNames[backend]); + LUS::Context::GetInstance()->GetConfig()->Save(); + } + } + ImGui::EndCombo(); + } + if (LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size() <= 1) { + UIWidgets::ReEnableComponent(""); + } + + if (LUS::Context::GetInstance()->GetWindow()->CanDisableVerticalSync()) { + UIWidgets::PaddedEnhancementCheckbox("Enable Vsync", "gVsyncEnabled", true, false); + } + + if (LUS::Context::GetInstance()->GetWindow()->SupportsWindowedFullscreen()) { + UIWidgets::PaddedEnhancementCheckbox("Windowed fullscreen", "gSdlWindowedFullscreen", true, false); + } + + if (LUS::Context::GetInstance()->GetWindow()->GetGui()->SupportsViewports()) { + UIWidgets::PaddedEnhancementCheckbox("Allow multi-windows", "gEnableMultiViewports", true, false, false, "", UIWidgets::CheckboxGraphics::Cross, true); + UIWidgets::Tooltip("Allows windows to be able to be dragged off of the main game window. Requires a reload to take effect."); + } + + // If more filters are added to LUS, make sure to add them to the filters list here + ImGui::Text("Texture Filter (Needs reload)"); + + UIWidgets::EnhancementCombobox("gTextureFilter", filters, 0); + + UIWidgets::Spacer(0); + + LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->DrawSettings(); + + ImGui::EndMenu(); + } +} + +void DrawMenuBarIcon() { + static bool gameIconLoaded = false; + if (!gameIconLoaded) { + // LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTexture("Game_Icon", "textures/icons/gIcon.png"); + gameIconLoaded = false; + } + + if (LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Game_Icon")) { +#ifdef __SWITCH__ + ImVec2 iconSize = ImVec2(20.0f, 20.0f); + float posScale = 1.0f; +#elif defined(__WIIU__) + ImVec2 iconSize = ImVec2(16.0f * 2, 16.0f * 2); + float posScale = 2.0f; +#else + ImVec2 iconSize = ImVec2(20.0f, 20.0f); + float posScale = 1.5f; +#endif + ImGui::SetCursorPos(ImVec2(5, 2.5f) * posScale); + ImGui::Image(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Game_Icon"), iconSize); + ImGui::SameLine(); + ImGui::SetCursorPos(ImVec2(25, 0) * posScale); + } +} + +void DrawGameMenu() { + if (UIWidgets::BeginMenu("Lylat64")) { + if (UIWidgets::MenuItem("Reset", +#ifdef __APPLE__ + "Command-R" +#else + "Ctrl+R" +#endif + )) { + // gNextGameState = GSTATE_BOOT; + } +#if !defined(__SWITCH__) && !defined(__WIIU__) + + if (UIWidgets::MenuItem("Toggle Fullscreen", "F9")) { + LUS::Context::GetInstance()->GetWindow()->ToggleFullscreen(); + } + + if (UIWidgets::MenuItem("Quit")) { + LUS::Context::GetInstance()->GetWindow()->Close(); + } +#endif + ImGui::EndMenu(); + } +} + +void DrawEnhancementsMenu() { + if (UIWidgets::BeginMenu("Enhancements")) { + + if (UIWidgets::BeginMenu("Gameplay")) { + UIWidgets::CVarCheckbox("No Level of Detail (LOD)", "gDisableLOD", { + .tooltip = "Disable Level of Detail (LOD) to avoid models using lower poly versions at a distance" + }); + UIWidgets::CVarCheckbox("Select any star from menu", "gSelectAllStars", { + .tooltip = "Let's you select any star from the menu regardless of the courses completion status." + }); + UIWidgets::CVarCheckbox("Collecting Stars Will Not Exit Level", "gStarNoExit", { + .tooltip = "Stars act like the 100 coin star and will not take you out of the level" + }); + UIWidgets::CVarCheckbox("Avoid playing peach cutscene", "gDisablePeachCutscene", { + .tooltip = "Avoid playing the peach cutscene when starting a new game" + }); + ImGui::EndMenu(); + } + + ImGui::EndMenu(); + } +} + +void DrawCheatsMenu() { + if (UIWidgets::BeginMenu("Cheats")) { + UIWidgets::CVarCheckbox("Infinite Health", "gInfiniteHealth"); + UIWidgets::CVarCheckbox("Infinite Lives", "gInfiniteLives"); + + ImGui::EndMenu(); + } +} + +const char* debugInfoPages[6] = { + "Object", + "Check Surface", + "Map", + "Stage", + "Effect", + "Enemy", +}; + +void DrawDebugMenu() { + if (UIWidgets::BeginMenu("Developer")) { + UIWidgets::WindowButton("Gfx Debugger", "gGfxDebuggerEnabled", GameUI::mGfxDebuggerWindow, { + .tooltip = "Enables the Gfx Debugger window, allowing you to input commands, type help for some examples" + }); + + UIWidgets::CVarCheckbox("Debug mode", "gEnableDebugMode", { + .tooltip = "TBD" + }); + + UIWidgets::CVarCheckbox("Level Selector", "gLevelSelector", { + .tooltip = "Allows you to select any level from the main menu" + }); + + UIWidgets::CVarCheckbox("SFX Jukebox", "gSfxJukebox", { + .tooltip = "Allows you to play sound effects from the game" + }); + + UIWidgets::Spacer(0); + + UIWidgets::WindowButton("Stats", "gStatsEnabled", GameUI::mStatsWindow, { + .tooltip = "Shows the stats window, with your FPS and frametimes, and the OS you're playing on" + }); + UIWidgets::WindowButton("Console", "gConsoleEnabled", GameUI::mConsoleWindow, { + .tooltip = "Enables the console window, allowing you to input commands, type help for some examples" + }); + + ImGui::EndMenu(); + } +} + +void GameMenuBar::DrawElement() { + if(ImGui::BeginMenuBar()){ + DrawMenuBarIcon(); + + DrawGameMenu(); + + ImGui::SetCursorPosY(0.0f); + + DrawSettingsMenu(); + + ImGui::SetCursorPosY(0.0f); + + DrawEnhancementsMenu(); + + ImGui::SetCursorPosY(0.0f); + + DrawCheatsMenu(); + + ImGui::SetCursorPosY(0.0f); + + DrawDebugMenu(); + + ImGui::EndMenuBar(); + } +} \ No newline at end of file diff --git a/src/port/ui/ImguiUI.h b/src/port/ui/ImguiUI.h new file mode 100644 index 000000000..2d233f4c5 --- /dev/null +++ b/src/port/ui/ImguiUI.h @@ -0,0 +1,16 @@ +#pragma once +#include + +namespace GameUI { + void SetupGuiElements(); + void Destroy(); +} + +class GameMenuBar : public LUS::GuiMenuBar { + public: + using LUS::GuiMenuBar::GuiMenuBar; + protected: + void DrawElement() override; + void InitElement() override {}; + void UpdateElement() override {}; +}; \ No newline at end of file diff --git a/src/port/ui/ResolutionEditor.cpp b/src/port/ui/ResolutionEditor.cpp new file mode 100644 index 000000000..01995a3c9 --- /dev/null +++ b/src/port/ui/ResolutionEditor.cpp @@ -0,0 +1,422 @@ +#include "ResolutionEditor.h" +#include "UIWidgets.h" +#include "libultraship/src/Context.h" + +#include +#include +#include + +/* Console Variables are grouped under gAdvancedResolution. (e.g. "gAdvancedResolution.Enabled") + + The following CVars are used in Libultraship and can be edited here: + - Enabled - Turns Advanced Resolution Mode on. + - AspectRatioX, AspectRatioY - Aspect ratio controls. To toggle off, set either to zero. + - VerticalPixelCount, VerticalResolutionToggle - Resolution controls. + - PixelPerfectMode, IntegerScale.Factor - Pixel Perfect Mode a.k.a. integer scaling controls. + (Waiting on a second PR merge on LUS for this to fully function.): + - IntegerScale.FitAutomatically - Automatic resizing for Pixel Perfect Mode. + - IntegerScale.NeverExceedBounds - Prevents manual resizing from exceeding screen bounds. + + The following CVars are also implemented in LUS for niche use cases: + - IgnoreAspectCorrection - Stretch framebuffer to fill screen. + This is something of a power-user setting for niche setups that most people won't need or care about, + but may be useful if playing the Switch/Wii U ports on a 4:3 television. + - IntegerScale.ExceedBoundsBy - Offset the max screen bounds, usually by +1. + This isn't that useful at the moment. +*/ + +namespace AdvancedResolutionSettings { + enum setting { UPDATE_aspectRatioX, UPDATE_aspectRatioY, UPDATE_verticalPixelCount }; + + const char* aspectRatioPresetLabels[] = { + "Off", "Custom", "Original (4:3)", "Widescreen (16:9)", "Nintendo 3DS (5:3)", "16:10 (8:5)", "Ultrawide (21:9)" + }; + const float aspectRatioPresetsX[] = { 0.0f, 12.0f, 4.0f, 16.0f, 5.0f, 16.0f, 21.0f }; + const float aspectRatioPresetsY[] = { 0.0f, 9.0f, 3.0f, 9.0f, 3.0f, 10.0f, 9.0f }; + const int default_aspectRatio = 1; // Default combo list option + + const char* pixelCountPresetLabels[] = { "Custom", "Native N64 (240p)", "2x (480p)", "3x (720p)", "4x (960p)", + "5x (1200p)", "6x (1440p)", "Full HD (1080p)", "4K (2160p)" }; + const int pixelCountPresets[] = { 480, 240, 480, 720, 960, 1200, 1440, 1080, 2160, 480 }; + const int default_pixelCount = 0; // Default combo list option + + const uint32_t minVerticalPixelCount = 240; // see: LUS::AdvancedResolution() + const uint32_t maxVerticalPixelCount = 4320; + + const unsigned short default_maxIntegerScaleFactor = 6; // Default size of Integer scale factor slider. + + const float enhancementSpacerHeight = 19.0f; +// This will need to be determined more intelligently when Hi-DPI UI support is added. + + void AdvancedResolutionSettingsWindow::InitElement() { + } + + void AdvancedResolutionSettingsWindow::DrawElement() { + ImGui::SetNextWindowSize(ImVec2(497, 532), ImGuiCond_FirstUseEver); + if (ImGui::Begin("Advanced Resolution Settings", &mIsVisible)) { + // Initialise update flags. + bool update[sizeof(setting)]; + for (unsigned short i = 0; i < sizeof(setting); i++) + update[i] = false; + static short updateCountdown = 0; + short countdownStartingValue = CVarGetInteger("gInterpolationFPS", 20) / 2; // half of a second, in frames. + + // Initialise integer scale bounds. + short max_integerScaleFactor = default_maxIntegerScaleFactor; // default value, which may or may not get + // overridden depending on viewport res + + short integerScale_maximumBounds = 1; // can change when window is resized + // This is mostly just for UX purposes, as Fit Automatically logic is part of LUS. + if (((float)gfx_current_game_window_viewport.width / gfx_current_game_window_viewport.height) > + ((float)gfx_current_dimensions.width / gfx_current_dimensions.height)) { + // Scale to window height + integerScale_maximumBounds = gfx_current_game_window_viewport.height / gfx_current_dimensions.height; + } else { + // Scale to window width + integerScale_maximumBounds = gfx_current_game_window_viewport.width / gfx_current_dimensions.width; + } + // Lower-clamping maximum bounds value to 1 is no-longer necessary as that's accounted for in LUS. + // Letting it go below 1 in this Editor will even allow for checking if screen bounds are being exceeded. + if (default_maxIntegerScaleFactor < integerScale_maximumBounds) { + max_integerScaleFactor = + integerScale_maximumBounds + CVarGetInteger("gAdvancedResolution.IntegerScale.ExceedBoundsBy", 0); + } + + // Stored Values for non-UIWidgets elements + static float aspectRatioX = CVarGetFloat("gAdvancedResolution.AspectRatioX", 16.0f); + static float aspectRatioY = CVarGetFloat("gAdvancedResolution.AspectRatioY", 9.0f); + static int verticalPixelCount = CVarGetInteger("gAdvancedResolution.VerticalPixelCount", 480); + // Combo List defaults + static int item_aspectRatio = default_aspectRatio; + static int item_pixelCount = default_pixelCount; + // Additional settings + static bool showHorizontalResField = false; + static int horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; + +#ifdef __APPLE__ + ImGui::Text("Note: these settings may behave incorrectly on Apple Retina Displays."); + UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); +#endif + + // The original resolution slider (for convenience) + if (UIWidgets::EnhancementSliderFloat("Internal Resolution: %d %%", "##IMul", "gInternalResolution", 0.5f, 2.0f, + "", 1.0f, true, true, + (CVarGetInteger("gAdvancedResolution.VerticalResolutionToggle", 0) && + CVarGetInteger("gAdvancedResolution.Enabled", 0)) || + CVarGetInteger("gLowResMode", 0))) { + LUS::Context::GetInstance()->GetWindow()->SetResolutionMultiplier(CVarGetFloat("gInternalResolution", 1)); + } + UIWidgets::Tooltip("Multiplies your output resolution by the value entered, as a more intensive but effective " + "form of anti-aliasing"); // Description pulled from SohMenuBar.cpp + + // N64 Mode toggle (again for convenience) + // UIWidgets::PaddedEnhancementCheckbox("(Enhancements>Graphics) N64 Mode", "gLowResMode", false, false, false, + // "", UIWidgets::CheckboxGraphics::Cross, false); + + UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); + // Activator + UIWidgets::PaddedEnhancementCheckbox("Enable advanced settings.", "gAdvancedResolution.Enabled", false, false, + false, "", UIWidgets::CheckboxGraphics::Cross, false); + // Error/Warning display + if (!CVarGetInteger("gLowResMode", 0)) { + if (IsDroppingFrames()) { // Significant frame drop warning + ImGui::TextColored({ 0.85f, 0.85f, 0.0f, 1.0f }, + ICON_FA_EXCLAMATION_TRIANGLE " Significant frame rate (FPS) drops may be occuring."); + UIWidgets::Spacer(2); + } else { // No warnings + UIWidgets::Spacer(enhancementSpacerHeight); + } + } else { // N64 Mode warning + ImGui::TextColored({ 0.0f, 0.85f, 0.85f, 1.0f }, + ICON_FA_QUESTION_CIRCLE " \"N64 Mode\" is overriding these settings."); + ImGui::SameLine(); + if (ImGui::Button("Click to disable")) { + CVarSetInteger("gLowResMode", (int)false); + CVarSave(); + } + } + // Resolution visualiser + ImGui::Text("Viewport dimensions: %d x %d", gfx_current_game_window_viewport.width, + gfx_current_game_window_viewport.height); + ImGui::Text("Internal resolution: %d x %d", gfx_current_dimensions.width, gfx_current_dimensions.height); + + UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); + + // Aspect Ratio + ImGui::Text("Force aspect ratio:"); + ImGui::SameLine(); + ImGui::TextColored({ 0.75f, 0.75f, 0.75f, 1.0f }, "(Select \"Off\" to disable.)"); + if (ImGui::Combo(" ", &item_aspectRatio, aspectRatioPresetLabels, + IM_ARRAYSIZE(aspectRatioPresetLabels)) && + item_aspectRatio != default_aspectRatio) { // don't change anything if "Custom" is selected. + aspectRatioX = aspectRatioPresetsX[item_aspectRatio]; + aspectRatioY = aspectRatioPresetsY[item_aspectRatio]; + update[UPDATE_aspectRatioX] = true; + update[UPDATE_aspectRatioY] = true; + + if (showHorizontalResField) { + horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; + } + } + if (item_aspectRatio == default_aspectRatio && !showHorizontalResField) { + // Declaring the Y input interaction in particular as a variable beforehand + // will prevent a bug where the Y field would disappear when modifying X. + bool inputX = ImGui::InputFloat("X", &aspectRatioX, 0.1f, 1.0f, "%.3f"); + bool inputY = ImGui::InputFloat("Y", &aspectRatioY, 0.1f, 1.0f, "%.3f"); + if (inputX || inputY) { + item_aspectRatio = default_aspectRatio; + update[UPDATE_aspectRatioX] = true; + update[UPDATE_aspectRatioY] = true; + } + } else if (showHorizontalResField) { // Show calculated aspect ratio + if (item_aspectRatio) { + UIWidgets::Spacer(2); + float resolvedAspectRatio = (float)gfx_current_dimensions.height / gfx_current_dimensions.width; + ImGui::Text("Aspect ratio: %.4f", resolvedAspectRatio); + } else { + UIWidgets::Spacer(enhancementSpacerHeight); + } + } + + UIWidgets::Spacer(0); + // Vertical Resolution + UIWidgets::PaddedEnhancementCheckbox("Set fixed vertical resolution (disables Resolution slider)", + "gAdvancedResolution.VerticalResolutionToggle", true, false, false, "", + UIWidgets::CheckboxGraphics::Cross, false); + UIWidgets::Tooltip( + "Override the resolution scale slider and use the settings below, irrespective of window size."); + if (ImGui::Combo("Pixel Count Presets", &item_pixelCount, pixelCountPresetLabels, + IM_ARRAYSIZE(pixelCountPresetLabels)) && + item_pixelCount != default_pixelCount) { // don't change anything if "Custom" is selected. + verticalPixelCount = pixelCountPresets[item_pixelCount]; + update[UPDATE_verticalPixelCount] = true; + + if (showHorizontalResField) { + horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; + } + } + // Horizontal Resolution, if visibility is enabled for it. + if (showHorizontalResField) { + // Only show the field if Aspect Ratio is being enforced. + if ((aspectRatioX > 0.0f) && (aspectRatioY > 0.0f)) { + // So basically we're "faking" this one by setting aspectRatioX instead. + if (ImGui::InputInt("Horiz. Pixel Count", &horizontalPixelCount, 8, 320)) { + item_aspectRatio = default_aspectRatio; + if (horizontalPixelCount < (minVerticalPixelCount / 3.0f) * 4.0f) { + horizontalPixelCount = (minVerticalPixelCount / 3.0f) * 4.0f; + } + aspectRatioX = aspectRatioY * horizontalPixelCount / verticalPixelCount; + update[UPDATE_aspectRatioX] = true; + } + } else { // Display a notice instead. + ImGui::TextColored({ 0.0f, 0.85f, 0.85f, 1.0f }, + ICON_FA_QUESTION_CIRCLE " \"Force aspect ratio\" required."); + // ImGui::Text(" "); + ImGui::SameLine(); + if (ImGui::Button("Click to resolve")) { + item_aspectRatio = default_aspectRatio; // Set it to Custom + aspectRatioX = aspectRatioPresetsX[2]; // but use the 4:3 defaults + aspectRatioY = aspectRatioPresetsY[2]; + update[UPDATE_aspectRatioX] = true; + update[UPDATE_aspectRatioY] = true; + horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; + } + } + } + // Vertical Resolution part 2 + if (ImGui::InputInt("Vertical Pixel Count", &verticalPixelCount, 8, 240)) { + item_pixelCount = default_pixelCount; + update[UPDATE_verticalPixelCount] = true; + + // Account for the natural instinct to enter horizontal first. + // Ignore vertical resolutions that are below the lower clamp constant. + if (showHorizontalResField && !(verticalPixelCount < minVerticalPixelCount)) { + aspectRatioX = aspectRatioY * horizontalPixelCount / verticalPixelCount; + update[UPDATE_aspectRatioX] = true; + } + } + + UIWidgets::Spacer(0); + // UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); + + // Integer scaling settings group + if (ImGui::CollapsingHeader("Integer Scaling Settings")) { + // Pixel-perfect Mode + UIWidgets::PaddedEnhancementCheckbox("Pixel-perfect Mode", "gAdvancedResolution.PixelPerfectMode", true, + true, + !CVarGetInteger("gAdvancedResolution.VerticalResolutionToggle", 0), "", + UIWidgets::CheckboxGraphics::Cross, false); + UIWidgets::Tooltip("Don't scale image to fill window."); + if (!CVarGetInteger("gAdvancedResolution.VerticalResolutionToggle", 0)) { + CVarSetInteger("gAdvancedResolution.PixelPerfectMode", (int)false); + CVarSave(); + } + + // Integer Scaling + UIWidgets::EnhancementSliderInt("Integer scale factor: %d", "##ARSIntScale", + "gAdvancedResolution.IntegerScale.Factor", 1, max_integerScaleFactor, "%d", + 1, true, + !CVarGetInteger("gAdvancedResolution.PixelPerfectMode", 0) || + CVarGetInteger("gAdvancedResolution.IntegerScale.FitAutomatically", 0)); + UIWidgets::Tooltip("Integer scales the image. Only available in pixel-perfect mode."); + // Display warning if size is being clamped or if framebuffer is larger than viewport. + if (CVarGetInteger("gAdvancedResolution.PixelPerfectMode", 0) && + (CVarGetInteger("gAdvancedResolution.IntegerScale.NeverExceedBounds", 1) && + CVarGetInteger("gAdvancedResolution.IntegerScale.Factor", 1) > integerScale_maximumBounds)) { + ImGui::SameLine(); + ImGui::TextColored({ 0.85f, 0.85f, 0.0f, 1.0f }, ICON_FA_EXCLAMATION_TRIANGLE " Window exceeded."); + } + + UIWidgets::PaddedEnhancementCheckbox("Automatically scale image to fit viewport", + "gAdvancedResolution.IntegerScale.FitAutomatically", true, true, + !CVarGetInteger("gAdvancedResolution.PixelPerfectMode", 0), "", + UIWidgets::CheckboxGraphics::Cross, false); + UIWidgets::Tooltip("Automatically sets scale factor to fit window. Only available in pixel-perfect mode."); + if (CVarGetInteger("gAdvancedResolution.IntegerScale.FitAutomatically", 0)) { + // This is just here to update the value shown on the slider. + // The function in LUS to handle this setting will ignore IntegerScaleFactor while active. + CVarSetInteger("gAdvancedResolution.IntegerScale.Factor", integerScale_maximumBounds); + // CVarSave(); + } + } + + UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); + + // Collapsible panel for additional settings + if (ImGui::CollapsingHeader("Additional Settings")) { + UIWidgets::Spacer(0); +#if defined(__SWITCH__) || defined(__WIIU__) + // Disable aspect correction, stretching the framebuffer to fill the viewport. + // This option is only really needed on systems limited to 16:9 TV resolutions, such as consoles. + // The associated CVar is still functional on PC platforms if you want to use it though. + UIWidgets::PaddedEnhancementCheckbox("Disable aspect correction and stretch the output image.\n" + "(Might be useful for 4:3 televisions!)\n" + "Not available in Pixel Perfect Mode.", + "gAdvancedResolution.IgnoreAspectCorrection", false, true, + CVarGetInteger("gAdvancedResolution.PixelPerfectMode", 0), "", + UIWidgets::CheckboxGraphics::Cross, false); +#else + if (CVarGetInteger("gAdvancedResolution.IgnoreAspectCorrection", 0)) { + // This setting is intentionally not exposed on PC platforms, + // but may be accidentally activated for varying reasons. + // Having this button should hopefully prevent support headaches. + ImGui::TextColored({ 0.0f, 0.85f, 0.85f, 1.0f }, ICON_FA_QUESTION_CIRCLE + " If the image is stretched and you don't know why, click this."); + if (ImGui::Button("Click to reenable aspect correction.")) { + CVarSetInteger("gAdvancedResolution.IgnoreAspectCorrection", (int)false); + CVarSave(); + } + UIWidgets::Spacer(2); + } +#endif + + if (ImGui::Checkbox("Show a horizontal resolution field.", &showHorizontalResField)) { + if (!showHorizontalResField && (aspectRatioX > 0.0f)) { // when turning this setting off + // Refresh relevant values + aspectRatioX = aspectRatioY * horizontalPixelCount / verticalPixelCount; + horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; + } else { // when turning this setting on + item_aspectRatio = default_aspectRatio; + if (aspectRatioX > 0.0f) { + // Refresh relevant values in the opposite order + horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; + aspectRatioX = aspectRatioY * horizontalPixelCount / verticalPixelCount; + } + } + update[UPDATE_aspectRatioX] = true; + } + + UIWidgets::PaddedEnhancementCheckbox( + "Don't allow integer scaling to exceed screen bounds.\n" + "(Makes screen bounds take priority over specified factor.)", + "gAdvancedResolution.IntegerScale.NeverExceedBounds", true, false, + !CVarGetInteger("gAdvancedResolution.PixelPerfectMode", 0) || + CVarGetInteger("gAdvancedResolution.IntegerScale.FitAutomatically", 0), + "", UIWidgets::CheckboxGraphics::Cross, true); + + if (!CVarGetInteger("gAdvancedResolution.IntegerScale.NeverExceedBounds", 1) || + CVarGetInteger("gAdvancedResolution.IntegerScale.ExceedBoundsBy", 0)) { + ImGui::TextColored({ 0.0f, 0.85f, 0.85f, 1.0f }, + " " ICON_FA_QUESTION_CIRCLE + " A scroll bar may become visible if screen bounds are exceeded."); + // Another helpful button for an unused CVar. + if (CVarGetInteger("gAdvancedResolution.IntegerScale.ExceedBoundsBy", 0)) { + if (ImGui::Button("Click to reset an unused CVar that may be causing this.")) { + CVarSetInteger("gAdvancedResolution.IntegerScale.ExceedBoundsBy", 0); + CVarSave(); + } + } + } else { + UIWidgets::Spacer(enhancementSpacerHeight); + } + + // I've ended up dummying this one out because it doesn't function in a satisfactory way. + // Consider this idea on the table, but I don't deem it an important enough feature to push for. + /* + UIWidgets::PaddedEnhancementCheckbox("Allow integer scale factor to go 1x above maximum screen bounds.", + "gAdvancedResolution.IntegerScale.ExceedBoundsBy", false, false, + !CVarGetInteger("gAdvancedResolution.PixelPerfectMode", 0), "", + UIWidgets::CheckboxGraphics::Cross, false); + if (CVarGetInteger("gAdvancedResolution.IntegerScale.ExceedBoundsBy", 0)) { + ImGui::TextColored({ 0.0f, 0.85f, 0.85f, 1.0f }, + " " ICON_FA_QUESTION_CIRCLE + " A scroll bar may become visible if screen bounds are exceeded."); + }*/ + + } // end of Additional Settings + + // Clamp and update the CVars that don't use UIWidgets + if (IsBoolArrayTrue(update)) { + if (update[UPDATE_aspectRatioX]) { + if (aspectRatioX < 0.0f) { + aspectRatioX = 0.0f; + } + CVarSetFloat("gAdvancedResolution.AspectRatioX", aspectRatioX); + } + if (update[UPDATE_aspectRatioY]) { + if (aspectRatioY < 0.0f) { + aspectRatioY = 0.0f; + } + CVarSetFloat("gAdvancedResolution.AspectRatioY", aspectRatioY); + } + if (update[UPDATE_verticalPixelCount]) { + // There's a upper and lower clamp on the Libultraship side too, + // so clamping it here is purely visual, so the vertical resolution field reflects it. + if (verticalPixelCount < minVerticalPixelCount) { + verticalPixelCount = minVerticalPixelCount; + } + if (verticalPixelCount > maxVerticalPixelCount) { + verticalPixelCount = maxVerticalPixelCount; + } + CVarSetInteger("gAdvancedResolution.VerticalPixelCount", verticalPixelCount); + } + // Delay saving this set of CVars by a predetermined length of time, in frames. + updateCountdown = countdownStartingValue; + } + if (updateCountdown > 0) { + updateCountdown--; + } else { + CVarSave(); + } + } + ImGui::End(); + } + + void AdvancedResolutionSettingsWindow::UpdateElement() { + } + + bool AdvancedResolutionSettingsWindow::IsDroppingFrames() { + // a rather imprecise way of checking for frame drops. + // but it's mostly there to inform the player of large drops. + const short targetFPS = CVarGetInteger("gInterpolationFPS", 20); + const float threshold = targetFPS / 20.0f + 4.1f; + return ImGui::GetIO().Framerate < targetFPS - threshold; + } + + bool AdvancedResolutionSettingsWindow::IsBoolArrayTrue(bool* foo) { + for (unsigned short i = 0; i < sizeof(&foo); i++) + if (&foo[i]) + return true; + return false; + } +} // namespace AdvancedResolutionSettings \ No newline at end of file diff --git a/src/port/ui/ResolutionEditor.h b/src/port/ui/ResolutionEditor.h new file mode 100644 index 000000000..38af56073 --- /dev/null +++ b/src/port/ui/ResolutionEditor.h @@ -0,0 +1,19 @@ +#pragma once +#include + +namespace AdvancedResolutionSettings { + class AdvancedResolutionSettingsWindow : public LUS::GuiWindow { + private: + bool IsDroppingFrames(); + + protected: + bool IsBoolArrayTrue(bool*); + + public: + using LUS::GuiWindow::GuiWindow; + + void InitElement() override; + void DrawElement() override; + void UpdateElement() override; + }; +} // namespace AdvancedResolutionSettings \ No newline at end of file diff --git a/src/port/ui/UIWidgets.cpp b/src/port/ui/UIWidgets.cpp new file mode 100644 index 000000000..7aec506c6 --- /dev/null +++ b/src/port/ui/UIWidgets.cpp @@ -0,0 +1,1033 @@ +// +// UIWidgets.cpp +// soh +// +// Created by David Chavez on 25.08.22. +// + +#include "UIWidgets.h" + +#include "libultraship/src/Context.h" + +#include +#include +#include +#include + +namespace UIWidgets { + + // MARK: - Layout Helper + + // Automatically adds newlines to break up text longer than a specified number of characters + // Manually included newlines will still be respected and reset the line length + // If line is midword when it hits the limit, text should break at the last encountered space + char* WrappedText(const char* text, unsigned int charactersPerLine) { + std::string newText(text); + const size_t tipLength = newText.length(); + int lastSpace = -1; + int currentLineLength = 0; + for (unsigned int currentCharacter = 0; currentCharacter < tipLength; currentCharacter++) { + if (newText[currentCharacter] == '\n') { + currentLineLength = 0; + lastSpace = -1; + continue; + } else if (newText[currentCharacter] == ' ') { + lastSpace = currentCharacter; + } + + if ((currentLineLength >= charactersPerLine) && (lastSpace >= 0)) { + newText[lastSpace] = '\n'; + currentLineLength = currentCharacter - lastSpace - 1; + lastSpace = -1; + } + currentLineLength++; + } + + return strdup(newText.c_str()); + } + + char* WrappedText(const std::string& text, unsigned int charactersPerLine) { + return WrappedText(text.c_str(), charactersPerLine); + } + + void SetLastItemHoverText(const std::string& text) { + if (ImGui::IsItemHovered()) { + ImGui::BeginTooltip(); + ImGui::Text("%s", WrappedText(text, 60)); + ImGui::EndTooltip(); + } + } + + void SetLastItemHoverText(const char* text) { + if (ImGui::IsItemHovered()) { + ImGui::BeginTooltip(); + ImGui::Text("%s", WrappedText(text, 60)); + ImGui::EndTooltip(); + } + } + + // Adds a "?" next to the previous ImGui item with a custom tooltip + void InsertHelpHoverText(const std::string& text) { + ImGui::SameLine(); + ImGui::TextColored(ImVec4(0.7f, 0.7f, 0.7f, 1.0f), "?"); + if (ImGui::IsItemHovered()) { + ImGui::BeginTooltip(); + ImGui::Text("%s", WrappedText(text, 60)); + ImGui::EndTooltip(); + } + } + + void InsertHelpHoverText(const char* text) { + ImGui::SameLine(); + ImGui::TextColored(ImVec4(0.7f, 0.7f, 0.7f, 1.0f), "?"); + if (ImGui::IsItemHovered()) { + ImGui::BeginTooltip(); + ImGui::Text("%s", WrappedText(text, 60)); + ImGui::EndTooltip(); + } + } + + + // MARK: - UI Elements + + void Tooltip(const char* text) { + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("%s", WrappedText(text)); + } + } + + void Spacer(float height) { + ImGui::Dummy(ImVec2(0.0f, height)); + } + + void PaddedSeparator(bool padTop, bool padBottom, float extraVerticalTopPadding, float extraVerticalBottomPadding) { + if (padTop) { + Spacer(extraVerticalTopPadding); + } + ImGui::Separator(); + if (padBottom) { + Spacer(extraVerticalBottomPadding); + } + } + + void RenderCross(ImDrawList* draw_list, ImVec2 pos, ImU32 col, float sz) { + float thickness = ImMax(sz / 5.0f, 1.0f); + sz -= thickness * 0.5f; + pos += ImVec2(thickness * 0.25f, thickness * 0.25f); + + draw_list->PathLineTo(ImVec2(pos.x, pos.y)); + draw_list->PathLineTo(ImVec2(pos.x + sz, pos.y + sz)); + draw_list->PathStroke(col, 0, thickness); + + draw_list->PathLineTo(ImVec2(pos.x + sz, pos.y)); + draw_list->PathLineTo(ImVec2(pos.x, pos.y + sz)); + draw_list->PathStroke(col, 0, thickness); + } + + bool CustomCheckbox(const char* label, bool* v, bool disabled, CheckboxGraphics disabledGraphic) { + ImGuiWindow* window = ImGui::GetCurrentWindow(); + if (window->SkipItems) { + return false; + } + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + const ImGuiID id = window->GetID(label); + const ImVec2 label_size = ImGui::CalcTextSize(label, NULL, true); + + const float square_sz = ImGui::GetFrameHeight(); + const ImVec2 pos = window->DC.CursorPos; + const ImRect total_bb(pos, pos + ImVec2(square_sz + (label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f), label_size.y + style.FramePadding.y * 2.0f)); + ImGui::ItemSize(total_bb, style.FramePadding.y); + if (!ImGui::ItemAdd(total_bb, id)) { + IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Checkable | (*v ? ImGuiItemStatusFlags_Checked : 0)); + return false; + } + + bool hovered, held; + bool pressed = ImGui::ButtonBehavior(total_bb, id, &hovered, &held); + if (pressed) { + *v = !(*v); + ImGui::MarkItemEdited(id); + } + + const ImRect check_bb(pos, pos + ImVec2(square_sz, square_sz)); + ImGui::RenderNavHighlight(total_bb, id); + ImGui::RenderFrame(check_bb.Min, check_bb.Max, ImGui::GetColorU32((held && hovered) ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg), true, style.FrameRounding); + ImU32 check_col = ImGui::GetColorU32(ImGuiCol_CheckMark); + ImU32 cross_col = ImGui::GetColorU32(ImVec4(0.50f, 0.50f, 0.50f, 1.00f)); + bool mixed_value = (g.LastItemData.InFlags & ImGuiItemFlags_MixedValue) != 0; + if (mixed_value) { + // Undocumented tristate/mixed/indeterminate checkbox (#2644) + // This may seem awkwardly designed because the aim is to make ImGuiItemFlags_MixedValue supported by all widgets (not just checkbox) + ImVec2 pad(ImMax(1.0f, IM_FLOOR(square_sz / 3.6f)), ImMax(1.0f, IM_FLOOR(square_sz / 3.6f))); + window->DrawList->AddRectFilled(check_bb.Min + pad, check_bb.Max - pad, check_col, style.FrameRounding); + } else if ((!disabled && *v) || (disabled && disabledGraphic == CheckboxGraphics::Checkmark)) { + const float pad = ImMax(1.0f, IM_FLOOR(square_sz / 6.0f)); + ImGui::RenderCheckMark(window->DrawList, check_bb.Min + ImVec2(pad, pad), check_col, square_sz - pad * 2.0f); + } else if (disabled && disabledGraphic == CheckboxGraphics::Cross) { + const float pad = ImMax(1.0f, IM_FLOOR(square_sz / 6.0f)); + RenderCross(window->DrawList, check_bb.Min + ImVec2(pad, pad), cross_col, square_sz - pad * 2.0f); + } + + ImVec2 label_pos = ImVec2(check_bb.Max.x + style.ItemInnerSpacing.x, check_bb.Min.y + style.FramePadding.y); + if (g.LogEnabled) { + ImGui::LogRenderedText(&label_pos, mixed_value ? "[~]" : *v ? "[x]" : "[ ]"); + } + if (label_size.x > 0.0f) { + ImGui::RenderText(label_pos, label); + } + + IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Checkable | (*v ? ImGuiItemStatusFlags_Checked : 0)); + return pressed; + } + + void ReEnableComponent(const char* disabledTooltipText) { + // End of disable region of previous component + ImGui::PopStyleVar(1); + if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(disabledTooltipText, "") != 0) { + ImGui::SetTooltip("%s", disabledTooltipText); + } + ImGui::PopItemFlag(); + } + + void DisableComponent(const float alpha) { + ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); + ImGui::PushStyleVar(ImGuiStyleVar_Alpha, alpha); + } + + bool EnhancementCheckbox(const char* text, const char* cvarName, bool disabled, const char* disabledTooltipText, CheckboxGraphics disabledGraphic, bool defaultValue) { + bool changed = false; + if (disabled) { + DisableComponent(ImGui::GetStyle().Alpha * 0.5f); + } + + bool val = (bool)CVarGetInteger(cvarName, defaultValue); + if (CustomCheckbox(text, &val, disabled, disabledGraphic)) { + CVarSetInteger(cvarName, val); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + changed = true; + } + + if (disabled) { + ReEnableComponent(disabledTooltipText); + } + return changed; + } + + bool PaddedEnhancementCheckbox(const char* text, const char* cvarName, bool padTop, bool padBottom, bool disabled, const char* disabledTooltipText, CheckboxGraphics disabledGraphic, bool defaultValue) { + ImGui::BeginGroup(); + if (padTop) Spacer(0); + + bool changed = EnhancementCheckbox(text, cvarName, disabled, disabledTooltipText, disabledGraphic, defaultValue); + + if (padBottom) Spacer(0); + ImGui::EndGroup(); + return changed; + } + + bool EnhancementCombobox(const char* cvarName, std::span comboArray, uint8_t defaultIndex, bool disabled, const char* disabledTooltipText, uint8_t disabledValue) { + bool changed = false; + if (defaultIndex <= 0) { + defaultIndex = 0; + } + + if (disabled) { + DisableComponent(ImGui::GetStyle().Alpha * 0.5f); + } + + uint8_t selected = CVarGetInteger(cvarName, defaultIndex); + std::string comboName = std::string("##") + std::string(cvarName); + if (ImGui::BeginCombo(comboName.c_str(), comboArray[selected])) { + for (uint8_t i = 0; i < comboArray.size(); i++) { + if (strlen(comboArray[i]) > 1) { + if (ImGui::Selectable(comboArray[i], i == selected)) { + CVarSetInteger(cvarName, i); + selected = i; + changed = true; + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + } + } + } + ImGui::EndCombo(); + } + + if (disabled) { + ReEnableComponent(disabledTooltipText); + + if (disabledValue >= 0 && selected != disabledValue) { + CVarSetInteger(cvarName, disabledValue); + changed = true; + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + } + } + + return changed; + } + + bool LabeledRightAlignedEnhancementCombobox(const char* label, const char* cvarName, std::span comboArray, uint8_t defaultIndex, bool disabled, const char* disabledTooltipText, uint8_t disabledValue) { + ImGui::Text(label); + s32 currentValue = CVarGetInteger(cvarName, defaultIndex); + +#ifdef __WIIU__ + ImGui::SameLine(ImGui::GetContentRegionAvail().x - (ImGui::CalcTextSize(comboArray[currentValue]).x + 40.0f)); + ImGui::PushItemWidth(ImGui::CalcTextSize(comboArray[currentValue]).x + 60.0f); +#else + ImGui::SameLine(ImGui::GetContentRegionAvail().x - (ImGui::CalcTextSize(comboArray[currentValue]).x + 20.0f)); + ImGui::PushItemWidth(ImGui::CalcTextSize(comboArray[currentValue]).x + 30.0f); +#endif + + bool changed = EnhancementCombobox(cvarName, comboArray, defaultIndex, disabled, disabledTooltipText, disabledValue); + + ImGui::PopItemWidth(); + return changed; + } + + void PaddedText(const char* text, bool padTop, bool padBottom) { + if (padTop) Spacer(0); + + ImGui::Text("%s", text); + + if (padBottom) Spacer(0); + } + + bool EnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue, bool PlusMinusButton, bool disabled, const char* disabledTooltipText) { + bool changed = false; + int val = CVarGetInteger(cvarName, defaultValue); + + if (disabled) { + DisableComponent(ImGui::GetStyle().Alpha * 0.5f); + } + + ImGui::Text(text, val); + Spacer(0); + + ImGui::BeginGroup(); + if (PlusMinusButton) { + std::string MinusBTNName = " - ##" + std::string(cvarName); + if (ImGui::Button(MinusBTNName.c_str())) { + val--; + changed = true; + } + ImGui::SameLine(); + ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); + } + + ImGui::PushItemWidth(std::min((ImGui::GetContentRegionAvail().x - (PlusMinusButton ? sliderButtonWidth : 0.0f)), maxSliderWidth)); + if (ImGui::SliderInt(id, &val, min, max, format, ImGuiSliderFlags_AlwaysClamp)) + { + changed = true; + } + ImGui::PopItemWidth(); + + if (PlusMinusButton) { + std::string PlusBTNName = " + ##" + std::string(cvarName); + ImGui::SameLine(); + ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); + if (ImGui::Button(PlusBTNName.c_str())) { + val++; + changed = true; + } + } + ImGui::EndGroup(); + + if (disabled) { + ReEnableComponent(disabledTooltipText); + } + + if (val < min) { + val = min; + changed = true; + } + + if (val > max) { + val = max; + changed = true; + } + + if (changed) { + CVarSetInteger(cvarName, val); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + } + + return changed; + } + + bool EnhancementSliderFloat(const char* text, const char* id, const char* cvarName, float min, float max, const char* format, float defaultValue, bool isPercentage, bool PlusMinusButton, bool disabled, const char* disabledTooltipText) { + bool changed = false; + float val = CVarGetFloat(cvarName, defaultValue); + + if (disabled) { + DisableComponent(ImGui::GetStyle().Alpha * 0.5f); + } + + if (!isPercentage) { + ImGui::Text(text, val); + } else { + ImGui::Text(text, static_cast(100 * val)); + } + Spacer(0); + + ImGui::BeginGroup(); + if (PlusMinusButton) { + std::string MinusBTNName = " - ##" + std::string(cvarName); + if (ImGui::Button(MinusBTNName.c_str())) { + if (isPercentage) { + val -= 0.01f; + } else { + val -= 0.1f; + } + changed = true; + } + ImGui::SameLine(); + ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); + } + + ImGui::PushItemWidth(std::min((ImGui::GetContentRegionAvail().x - (PlusMinusButton ? sliderButtonWidth : 0.0f)), maxSliderWidth)); + if (ImGui::SliderFloat(id, &val, min, max, format, ImGuiSliderFlags_AlwaysClamp)) { + if (isPercentage) { + val = roundf(val * 100) / 100; + } + changed = true; + } + ImGui::PopItemWidth(); + + if (PlusMinusButton) { + std::string PlusBTNName = " + ##" + std::string(cvarName); + ImGui::SameLine(); + ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); + if (ImGui::Button(PlusBTNName.c_str())) { + if (isPercentage) { + val += 0.01f; + } else { + val += 0.1f; + } + changed = true; + } + } + ImGui::EndGroup(); + + if (disabled) { + ReEnableComponent(disabledTooltipText); + } + + if (val < min) { + val = min; + changed = true; + } + + if (val > max) { + val = max; + changed = true; + } + + if (changed) { + CVarSetFloat(cvarName, val); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + } + + return changed; + } + + bool PaddedEnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue, bool PlusMinusButton, bool padTop, bool padBottom, bool disabled, const char* disabledTooltipText) { + bool changed = false; + ImGui::BeginGroup(); + if (padTop) Spacer(0); + + changed = EnhancementSliderInt(text, id, cvarName, min, max, format, defaultValue, PlusMinusButton, disabled, disabledTooltipText); + + if (padBottom) Spacer(0); + ImGui::EndGroup(); + return changed; + } + + bool PaddedEnhancementSliderFloat(const char* text, const char* id, const char* cvarName, float min, float max, const char* format, float defaultValue, bool isPercentage, bool PlusMinusButton, bool padTop, bool padBottom, bool disabled, const char* disabledTooltipText) { + bool changed = false; + ImGui::BeginGroup(); + if (padTop) Spacer(0); + + changed = EnhancementSliderFloat(text, id, cvarName, min, max, format, defaultValue, isPercentage, PlusMinusButton, disabled, disabledTooltipText); + + if (padBottom) Spacer(0); + ImGui::EndGroup(); + return changed; + } + + bool EnhancementRadioButton(const char* text, const char* cvarName, int id) { + /*Usage : + EnhancementRadioButton("My Visible Name","gMyCVarName", MyID); + First arg is the visible name of the Radio button + Second is the cvar name where MyID will be saved. + Note: the CVar name should be the same to each Buddies. + Example : + EnhancementRadioButton("English", "gLanguages", LANGUAGE_ENG); + EnhancementRadioButton("German", "gLanguages", LANGUAGE_GER); + EnhancementRadioButton("French", "gLanguages", LANGUAGE_FRA); + */ + std::string make_invisible = "##" + std::string(text) + std::string(cvarName); + + bool ret = false; + int val = CVarGetInteger(cvarName, 0); + if (ImGui::RadioButton(make_invisible.c_str(), id == val)) { + CVarSetInteger(cvarName, id); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + ret = true; + } + ImGui::SameLine(); + ImGui::Text("%s", text); + + return ret; + } + + bool DrawResetColorButton(const char* cvarName, ImVec4* colors, ImVec4 defaultcolors, bool has_alpha) { + bool changed = false; + std::string Cvar_RBM = std::string(cvarName) + "RBM"; + std::string MakeInvisible = "Reset##" + std::string(cvarName) + "Reset"; + if (ImGui::Button(MakeInvisible.c_str())) { + colors->x = defaultcolors.x; + colors->y = defaultcolors.y; + colors->z = defaultcolors.z; + colors->w = has_alpha ? defaultcolors.w : 255.0f; + + Color_RGBA8 colorsRGBA; + colorsRGBA.r = defaultcolors.x; + colorsRGBA.g = defaultcolors.y; + colorsRGBA.b = defaultcolors.z; + colorsRGBA.a = has_alpha ? defaultcolors.w : 255.0f; + + CVarSetColor(cvarName, colorsRGBA); + CVarSetInteger(Cvar_RBM.c_str(), 0); //On click disable rainbow mode. + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + changed = true; + } + Tooltip("Revert colors to the game's original colors (GameCube version)\nOverwrites previously chosen color"); + return changed; + } + + void DrawLockColorCheckbox(const char* cvarName) { + std::string Cvar_Lock = std::string(cvarName) + "Lock"; + s32 lock = CVarGetInteger(Cvar_Lock.c_str(), 0); + std::string FullName = "Lock##" + Cvar_Lock; + EnhancementCheckbox(FullName.c_str(), Cvar_Lock.c_str()); + Tooltip("Prevents this color from being changed upon selecting \"Randomize all\""); + } + + void RainbowColor(const char* cvarName, ImVec4* colors) { + std::string Cvar_RBM = std::string(cvarName) + "RBM"; + std::string MakeInvisible = "Rainbow##" + std::string(cvarName) + "Rainbow"; + + EnhancementCheckbox(MakeInvisible.c_str(), Cvar_RBM.c_str()); + Tooltip("Cycles through colors on a timer\nOverwrites previously chosen color"); + } + + void LoadPickersColors(ImVec4& ColorArray, const char* cvarname, const ImVec4& default_colors, bool has_alpha) { + Color_RGBA8 defaultColors; + defaultColors.r = default_colors.x; + defaultColors.g = default_colors.y; + defaultColors.b = default_colors.z; + defaultColors.a = default_colors.w; + + Color_RGBA8 cvarColor = CVarGetColor(cvarname, defaultColors); + + ColorArray.x = cvarColor.r / 255.0; + ColorArray.y = cvarColor.g / 255.0; + ColorArray.z = cvarColor.b / 255.0; + ColorArray.w = cvarColor.a / 255.0; + } + + void DrawFlagArray32(const std::string& name, uint32_t& flags) { + ImGui::PushID(name.c_str()); + for (int32_t flagIndex = 0; flagIndex < 32; flagIndex++) { + if ((flagIndex % 8) != 0) { + ImGui::SameLine(); + } + ImGui::PushID(flagIndex); + uint32_t bitMask = 1 << flagIndex; + bool flag = (flags & bitMask) != 0; + if (ImGui::Checkbox("##check", &flag)) { + if (flag) { + flags |= bitMask; + } else { + flags &= ~bitMask; + } + } + ImGui::PopID(); + } + ImGui::PopID(); + } + + void DrawFlagArray16(const std::string& name, uint16_t& flags) { + ImGui::PushID(name.c_str()); + for (int16_t flagIndex = 0; flagIndex < 16; flagIndex++) { + if ((flagIndex % 8) != 0) { + ImGui::SameLine(); + } + ImGui::PushID(flagIndex); + uint16_t bitMask = 1 << flagIndex; + bool flag = (flags & bitMask) != 0; + if (ImGui::Checkbox("##check", &flag)) { + if (flag) { + flags |= bitMask; + } else { + flags &= ~bitMask; + } + } + ImGui::PopID(); + } + ImGui::PopID(); + } + + void DrawFlagArray8(const std::string& name, uint8_t& flags) { + ImGui::PushID(name.c_str()); + for (int8_t flagIndex = 0; flagIndex < 8; flagIndex++) { + if ((flagIndex % 8) != 0) { + ImGui::SameLine(); + } + ImGui::PushID(flagIndex); + uint8_t bitMask = 1 << flagIndex; + bool flag = (flags & bitMask) != 0; + if (ImGui::Checkbox("##check", &flag)) { + if (flag) { + flags |= bitMask; + } else { + flags &= ~bitMask; + } + } + ImGui::PopID(); + } + ImGui::PopID(); + } + + // V2 + + void PushStyleMenu(const ImVec4& color) { + ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(color.x, color.y, color.z, 0.5f)); + ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_PopupBg, UIWidgets::Colors::DarkGray); + ImGui::PushStyleColor(ImGuiCol_Border, UIWidgets::Colors::DarkGray); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(8.0f, 15.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_PopupBorderSize, 3.0f); + } + + void PopStyleMenu() { + ImGui::PopStyleVar(2); + ImGui::PopStyleColor(4); + } + + bool BeginMenu(const char* label, const ImVec4& color) { + bool dirty = false; + PushStyleMenu(color); + if (ImGui::BeginMenu(label)) { + dirty = true; + } + PopStyleMenu(); + return dirty; + } + + void PushStyleMenuItem(const ImVec4& color) { + ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(20.0f, 15.0f)); + } + + void PopStyleMenuItem() { + ImGui::PopStyleVar(1); + ImGui::PopStyleColor(1); + } + + bool MenuItem(const char* label, const char* shortcut, const ImVec4& color) { + bool dirty = false; + PushStyleMenuItem(color); + if (ImGui::MenuItem(label, shortcut)) { + dirty = true; + } + PopStyleMenuItem(); + return dirty; + } + + void PushStyleButton(const ImVec4& color) { + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(color.x, color.y, color.z, 0.8f)); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(color.x, color.y, color.z, 0.6f)); + ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.0f, 0.0f, 0.0f, 0.3f)); + ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10.0f, 8.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 5.0f); + } + + void PopStyleButton() { + ImGui::PopStyleVar(3); + ImGui::PopStyleColor(4); + } + + bool Button(const char* label, const ButtonOptions& options) { + ImGui::BeginDisabled(options.disabled); + PushStyleButton(options.color); + bool dirty = ImGui::Button(label, options.size); + PopStyleButton(); + ImGui::EndDisabled(); + if (options.disabled && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.disabledTooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.disabledTooltip)); + } else if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.tooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.tooltip)); + } + return dirty; + } + + bool WindowButton(const char* label, const char* cvarName, std::shared_ptr windowPtr, const ButtonOptions& options) { + ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0, 0)); + std::string buttonText = label; + bool dirty = false; + if (CVarGetInteger(cvarName, 0)) { + buttonText = ICON_FA_WINDOW_CLOSE " " + buttonText; + } else { + buttonText = ICON_FA_EXTERNAL_LINK_SQUARE " " + buttonText; + } + if (Button(buttonText.c_str(), options)) { + windowPtr->ToggleVisibility(); + dirty = true; + } + ImGui::PopStyleVar(); + return dirty; + } + + void PushStyleCheckbox(const ImVec4& color) { + ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(color.x, color.y, color.z, 0.8f)); + ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(color.x, color.y, color.z, 0.6f)); + ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.0f, 0.0f, 0.0f, 0.3f)); + ImGui::PushStyleColor(ImGuiCol_CheckMark, ImVec4(1.0f, 1.0f, 1.0f, 0.7f)); + ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10.0f, 6.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 5.0f); + } + + void PopStyleCheckbox() { + ImGui::PopStyleVar(3); + ImGui::PopStyleColor(5); + } + + bool Checkbox(const char* label, bool* value, const CheckboxOptions& options) { + ImGui::PushID(label); + bool dirty = false; + float startX = ImGui::GetCursorPosX(); + std::string invisibleLabelStr = "##" + std::string(label); + const char* invisibleLabel = invisibleLabelStr.c_str(); + ImGui::BeginDisabled(options.disabled); + PushStyleCheckbox(options.color); + if (options.alignment == ComponentAlignment::Right) { + if (options.labelPosition == LabelPosition::Near || options.labelPosition == LabelPosition::Far || options.labelPosition == LabelPosition::None) { + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::GetStyle().FramePadding.x * 2 - ImGui::GetStyle().ItemSpacing.x); + } else if (options.labelPosition == LabelPosition::Above) { + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x); + ImGui::Text(label); + ImGui::NewLine(); + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::GetStyle().FramePadding.x * 2 - ImGui::GetStyle().ItemSpacing.x); + } + } else if (options.alignment == ComponentAlignment::Left) { + if (options.labelPosition == LabelPosition::Above) { + ImGui::Text(label); + } + } + dirty = ImGui::Checkbox(invisibleLabel, value); + if (options.alignment == ComponentAlignment::Right) { + if (options.labelPosition == LabelPosition::Near) { + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x - ImGui::GetStyle().FramePadding.x * 2 - ImGui::GetStyle().ItemSpacing.x * 2); + ImGui::Text(label); + } else if (options.labelPosition == LabelPosition::Far) { + ImGui::SameLine(); + ImGui::SetCursorPosX(startX); + ImGui::Text(label); + } + } else if (options.alignment == ComponentAlignment::Left) { + if (options.labelPosition == LabelPosition::Near) { + ImGui::SameLine(); + ImGui::Text(label); + } else if (options.labelPosition == LabelPosition::Far) { + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x); + ImGui::Text(label); + } + } + PopStyleCheckbox(); + ImGui::EndDisabled(); + if (options.disabled && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.disabledTooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.disabledTooltip)); + } else if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.tooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.tooltip)); + } + ImGui::PopID(); + return dirty; + } + + bool CVarCheckbox(const char* label, const char* cvarName, const CheckboxOptions& options) { + bool dirty = false; + bool value = (bool)CVarGetInteger(cvarName, options.defaultValue); + if (Checkbox(label, &value, options)) { + CVarSetInteger(cvarName, value); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + return dirty; + } + + void PushStyleCombobox(const ImVec4& color) { + ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(color.x, color.y, color.z, 0.8f)); + ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(color.x, color.y, color.z, 0.6f)); + ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(color.x, color.y, color.z, 0.6f)); + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(color.x, color.y, color.z, 0.8f)); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(color.x, color.y, color.z, 0.5f)); + ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImVec4(color.x, color.y, color.z, 0.6f)); + ImGui::PushStyleColor(ImGuiCol_HeaderActive, ImVec4(color.x, color.y, color.z, 0.6f)); + ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f); + ImGui::PushStyleVar(ImGuiStyleVar_PopupRounding, 3.0f); + ImGui::PushStyleVar(ImGuiStyleVar_PopupBorderSize, 0.0f); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10.0f, 6.0f)); + } + + void PopStyleCombobox() { + ImGui::PopStyleVar(4); + ImGui::PopStyleColor(9); + } + + bool Combobox(const char* label, uint8_t* value, std::span comboArray, const ComboboxOptions& options) { + bool dirty = false; + float startX = ImGui::GetCursorPosX(); + std::string invisibleLabelStr = "##" + std::string(label); + const char* invisibleLabel = invisibleLabelStr.c_str(); + ImGui::PushID(label); + ImGui::BeginGroup(); + ImGui::BeginDisabled(options.disabled); + PushStyleCombobox(options.color); + if (options.alignment == ComponentAlignment::Left) { + if (options.labelPosition == LabelPosition::Above) { + ImGui::Text(label); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + } else if (options.labelPosition == LabelPosition::Near) { + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x - ImGui::GetStyle().ItemSpacing.x * 2); + } else if (options.labelPosition == LabelPosition::Far || options.labelPosition == LabelPosition::None) { + ImGui::SetNextItemWidth(ImGui::CalcTextSize(comboArray[*value]).x + ImGui::GetStyle().FramePadding.x * 4 + ImGui::GetStyle().ItemSpacing.x); + } + } else if (options.alignment == ComponentAlignment::Right) { + if (options.labelPosition == LabelPosition::Above) { + ImGui::NewLine(); + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x); + ImGui::Text(label); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + } else if (options.labelPosition == LabelPosition::Near) { + ImGui::SameLine(ImGui::CalcTextSize(label).x + ImGui::GetStyle().ItemSpacing.x * 2); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + } else if (options.labelPosition == LabelPosition::Far || options.labelPosition == LabelPosition::None) { + float width = ImGui::CalcTextSize(comboArray[*value]).x + ImGui::GetStyle().FramePadding.x * 4; + ImGui::SameLine(ImGui::GetContentRegionAvail().x - width); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + } + } + if (ImGui::BeginCombo(invisibleLabel, comboArray[*value], options.flags)) { + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(10.0f, 10.0f)); + for (uint8_t i = 0; i < comboArray.size(); i++) { + if (strlen(comboArray[i]) > 1) { + if (ImGui::Selectable(comboArray[i], i == *value)) { + *value = i; + dirty = true; + } + } + } + ImGui::PopStyleVar(); + ImGui::EndCombo(); + } + if (options.alignment == ComponentAlignment::Left) { + if (options.labelPosition == LabelPosition::Near) { + ImGui::SameLine(); + ImGui::Text(label); + } else if (options.labelPosition == LabelPosition::Far) { + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x); + ImGui::Text(label); + } + } else if (options.alignment == ComponentAlignment::Right) { + if (options.labelPosition == LabelPosition::Near || options.labelPosition == LabelPosition::Far) { + ImGui::SameLine(startX); + ImGui::Text(label); + } + } + PopStyleCombobox(); + ImGui::EndDisabled(); + ImGui::EndGroup(); + if (options.disabled && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.disabledTooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.disabledTooltip)); + } else if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.tooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.tooltip)); + } + ImGui::PopID(); + return dirty; + } + + bool CVarCombobox(const char* label, const char* cvarName, std::span comboArray, const ComboboxOptions& options) { + bool dirty = false; + uint8_t value = (uint8_t)CVarGetInteger(cvarName, options.defaultIndex); + if (Combobox(label, &value, comboArray, options)) { + CVarSetInteger(cvarName, value); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + return dirty; + } + + void PushStyleSlider(const ImVec4& color) { + ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_SliderGrab, ImVec4(1.0, 1.0, 1.0, 0.4f)); + ImGui::PushStyleColor(ImGuiCol_SliderGrabActive, ImVec4(1.0, 1.0, 1.0, 0.5f)); + ImGui::PushStyleVar(ImGuiStyleVar_GrabRounding, 3.0f); + ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10.0f, 8.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0f); + } + + void PopStyleSlider() { + ImGui::PopStyleVar(4); + ImGui::PopStyleColor(6); + } + + bool SliderInt(const char* label, int32_t* value, int32_t min, int32_t max, const IntSliderOptions& options) { + bool dirty = false; + std::string invisibleLabelStr = "##" + std::string(label); + const char* invisibleLabel = invisibleLabelStr.c_str(); + ImGui::PushID(label); + ImGui::BeginGroup(); + ImGui::BeginDisabled(options.disabled); + PushStyleSlider(options.color); + if (options.alignment == ComponentAlignment::Left) { + if (options.labelPosition == LabelPosition::Above) { + ImGui::Text(label, *value); + } + } else if (options.alignment == ComponentAlignment::Right) { + if (options.labelPosition == LabelPosition::Above) { + ImGui::NewLine(); + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x); + ImGui::Text(label, *value); + } + } + if (options.showButtons) { + if (Button("-", { .color = options.color, .size = Sizes::Inline }) && *value > min) { + *value -= options.step; + if (*value < min) *value = min; + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + ImGui::SameLine(0, 3.0f); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x - (ImGui::CalcTextSize("+").x + 20.0f + 3.0f)); + } else { + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + } + if (ImGui::SliderScalar(invisibleLabel, ImGuiDataType_S32, value, &min, &max, options.format, options.flags)) { + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + if (options.showButtons) { + ImGui::SameLine(0, 3.0f); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + if (Button("+", { .color = options.color, .size = Sizes::Inline }) && *value < max) { + *value += options.step; + if (*value > max) *value = max; + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + } + PopStyleSlider(); + ImGui::EndDisabled(); + ImGui::EndGroup(); + if (options.disabled && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.disabledTooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.disabledTooltip)); + } else if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.tooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.tooltip)); + } + ImGui::PopID(); + return dirty; + } + + bool CVarSliderInt(const char* label, const char* cvarName, int32_t min, int32_t max, const int32_t defaultValue, const IntSliderOptions& options) { + bool dirty = false; + int32_t value = CVarGetInteger(cvarName, defaultValue); + if (SliderInt(label, &value, min, max, options)) { + CVarSetInteger(cvarName, value); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + return dirty; + } + + bool SliderFloat(const char* label, float* value, float min, float max, const FloatSliderOptions& options) { + bool dirty = false; + std::string invisibleLabelStr = "##" + std::string(label); + const char* invisibleLabel = invisibleLabelStr.c_str(); + float valueToDisplay = options.isPercentage ? *value * 100.0f : *value; + float maxToDisplay = options.isPercentage ? max * 100.0f : max; + float minToDisplay = options.isPercentage ? min * 100.0f : min; + ImGui::PushID(label); + ImGui::BeginGroup(); + ImGui::BeginDisabled(options.disabled); + PushStyleSlider(options.color); + if (options.alignment == ComponentAlignment::Left) { + if (options.labelPosition == LabelPosition::Above) { + ImGui::Text(label, valueToDisplay); + } + } else if (options.alignment == ComponentAlignment::Right) { + if (options.labelPosition == LabelPosition::Above) { + ImGui::NewLine(); + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x); + ImGui::Text(label, valueToDisplay); + } + } + if (options.showButtons) { + if (Button("-", { .color = options.color, .size = Sizes::Inline }) && *value > min) { + *value -= options.step; + if (*value < min) *value = min; + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + ImGui::SameLine(0, 3.0f); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x - (ImGui::CalcTextSize("+").x + 20.0f + 3.0f)); + } else { + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + } + if (ImGui::SliderScalar(invisibleLabel, ImGuiDataType_Float, &valueToDisplay, &minToDisplay, &maxToDisplay, options.format, options.flags)) { + *value = options.isPercentage ? valueToDisplay / 100.0f : valueToDisplay; + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + if (options.showButtons) { + ImGui::SameLine(0, 3.0f); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + if (Button("+", { .color = options.color, .size = Sizes::Inline }) && *value < max) { + *value += options.step; + if (*value > max) *value = max; + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + } + PopStyleSlider(); + ImGui::EndDisabled(); + ImGui::EndGroup(); + if (options.disabled && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.disabledTooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.disabledTooltip)); + } else if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.tooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.tooltip)); + } + ImGui::PopID(); + return dirty; + } + + bool CVarSliderFloat(const char* label, const char* cvarName, float min, float max, const float defaultValue, const FloatSliderOptions& options) { + bool dirty = false; + float value = CVarGetFloat(cvarName, defaultValue); + if (SliderFloat(label, &value, min, max, options)) { + CVarSetFloat(cvarName, value); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + return dirty; + } +} diff --git a/src/port/ui/UIWidgets.h b/src/port/ui/UIWidgets.h new file mode 100644 index 000000000..63daa568f --- /dev/null +++ b/src/port/ui/UIWidgets.h @@ -0,0 +1,210 @@ +#pragma once + +#include +#include +#include +#include +#define IMGUI_DEFINE_MATH_OPERATORS +#include +#include + +namespace UIWidgets { + + struct TextFilters { + static int FilterNumbers(ImGuiInputTextCallbackData* data) { + if (data->EventChar < 256 && strchr("1234567890", (char)data->EventChar)) { + return 0; + } + return 1; + } + + static int FilterAlphaNum(ImGuiInputTextCallbackData* data) { + const char* alphanum = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWYZ0123456789"; + if (data->EventChar < 256 && strchr(alphanum, (char)data->EventChar)) { + return 0; + } + return 1; + } + + }; + + // MARK: - Enums + + enum class CheckboxGraphics { + Cross, + Checkmark, + None + }; + constexpr float maxSliderWidth = 260.0f; +#ifdef __SWITCH__ + constexpr float sliderButtonWidth = 42.0f; +#elif defined(__WIIU__) + constexpr float sliderButtonWidth = 60.0f; +#else + constexpr float sliderButtonWidth = 30.0f; +#endif + + char* WrappedText(const char* text, unsigned int charactersPerLine = 60); + char* WrappedText(const std::string& text, unsigned int charactersPerLine); + + void SetLastItemHoverText(const std::string& text); + void SetLastItemHoverText(const char* text); + + void InsertHelpHoverText(const std::string& text); + void InsertHelpHoverText(const char* text); + + void Tooltip(const char* text); + void Spacer(float height); + void PaddedSeparator(bool padTop = true, bool padBottom = true, float extraVerticalTopPadding = 0.0f, float extraVerticalBottomPadding = 0.0f); + + void RenderCross(ImDrawList* draw_list, ImVec2 pos, ImU32 col, float sz); + bool CustomCheckbox(const char* label, bool* v, bool disabled, CheckboxGraphics disabledGraphic); + + void ReEnableComponent(const char* disabledTooltipText); + void DisableComponent(const float alpha); + + bool EnhancementCheckbox(const char* text, const char* cvarName, bool disabled = false, const char* disabledTooltipText = "", CheckboxGraphics disabledGraphic = CheckboxGraphics::Cross, bool defaultValue = false); + bool PaddedEnhancementCheckbox(const char* text, const char* cvarName, bool padTop = true, bool padBottom = true, bool disabled = false, const char* disabledTooltipText = "", CheckboxGraphics disabledGraphic = CheckboxGraphics::Cross, bool defaultValue = false); + + bool EnhancementCombobox(const char* cvarName, std::span comboArray, uint8_t defaultIndex, bool disabled = false, const char* disabledTooltipText = "", uint8_t disabledValue = -1); + bool LabeledRightAlignedEnhancementCombobox(const char* label, const char* cvarName, std::span comboArray, uint8_t defaultIndex, bool disabled = false, const char* disabledTooltipText = "", uint8_t disabledValue = -1); + + void PaddedText(const char* text, bool padTop = true, bool padBottom = true); + + bool EnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue = 0, bool PlusMinusButton = true, bool disabled = false, const char* disabledTooltipText = ""); + bool PaddedEnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue = 0, bool PlusMinusButton = true, bool padTop = true, bool padBottom = true, bool disabled = false, const char* disabledTooltipText = ""); + bool EnhancementSliderFloat(const char* text, const char* id, const char* cvarName, float min, float max, const char* format, float defaultValue, bool isPercentage, bool PlusMinusButton = true, bool disabled = false, const char* disabledTooltipText = ""); + bool PaddedEnhancementSliderFloat(const char* text, const char* id, const char* cvarName, float min, float max, const char* format, float defaultValue, bool isPercentage, bool PlusMinusButton = true, bool padTop = true, bool padBottom = true, bool disabled = false, const char* disabledTooltipText = ""); + + bool EnhancementRadioButton(const char* text, const char* cvarName, int id); + + bool DrawResetColorButton(const char* cvarName, ImVec4* colors, ImVec4 defaultcolors, bool has_alpha); + bool DrawRandomizeColorButton(const char* cvarName, ImVec4* colors); + void DrawLockColorCheckbox(const char* cvarName); + void RainbowColor(const char* cvarName, ImVec4* colors); + + void LoadPickersColors(ImVec4& ColorArray, const char* cvarname, const ImVec4& default_colors, bool has_alpha); + bool EnhancementColor(const char* text, const char* cvarName, ImVec4 ColorRGBA, ImVec4 default_colors, bool allow_rainbow = true, bool has_alpha = false, bool TitleSameLine = false); + + void DrawFlagArray32(const std::string& name, uint32_t& flags); + void DrawFlagArray16(const std::string& name, uint16_t& flags); + void DrawFlagArray8(const std::string& name, uint8_t& flags); + + // V2 + namespace Colors { + const ImVec4 White = ImVec4(1.0f, 1.0f, 1.0f, 1.0f); + const ImVec4 Gray = ImVec4(0.4f, 0.4f, 0.4f, 1.0f); + const ImVec4 DarkGray = ImVec4(0.1f, 0.1f, 0.1f, 1.0f); + const ImVec4 Indigo = ImVec4(0.24f, 0.31f, 0.71f, 1.0f); + const ImVec4 Red = ImVec4(0.5f, 0.0f, 0.0f, 1.0f); + const ImVec4 DarkRed = ImVec4(0.3f, 0.0f, 0.0f, 1.0f); + const ImVec4 LightGreen = ImVec4(0.0f, 0.7f, 0.0f, 1.0f); + const ImVec4 Green = ImVec4(0.0f, 0.5f, 0.0f, 1.0f); + const ImVec4 DarkGreen = ImVec4(0.0f, 0.3f, 0.0f, 1.0f); + const ImVec4 Yellow = ImVec4(1.0f, 0.627f, 0.0f, 1.0f); + }; + + namespace Sizes { + const ImVec2 Inline = ImVec2(0.0f, 0.0f); + const ImVec2 Fill = ImVec2(-1.0f, 0.0f); + } + + enum LabelPosition { + Near, + Far, + Above, + None, + Within, + }; + + enum ComponentAlignment { + Left, + Right, + }; + + void PushStyleMenu(const ImVec4& color = Colors::Indigo); + void PopStyleMenu(); + bool BeginMenu(const char* label, const ImVec4& color = Colors::Indigo); + + void PushStyleMenuItem(const ImVec4& color = Colors::Indigo); + void PopStyleMenuItem(); + bool MenuItem(const char* label, const char* shortcut = NULL, const ImVec4& color = Colors::Indigo); + + struct ButtonOptions { + const ImVec4 color = Colors::Gray; + const ImVec2 size = Sizes::Fill; + const char* tooltip = ""; + bool disabled = false; + const char* disabledTooltip = ""; + }; + + void PushStyleButton(const ImVec4& color = Colors::Gray); + void PopStyleButton(); + bool Button(const char* label, const ButtonOptions& options = {}); + bool WindowButton(const char* label, const char* cvarName, std::shared_ptr windowPtr, const ButtonOptions& options = {}); + + struct CheckboxOptions { + const ImVec4 color = Colors::Indigo; + const char* tooltip = ""; + bool disabled = false; + const char* disabledTooltip = ""; + bool defaultValue = false; // Only applicable to CVarCheckbox + ComponentAlignment alignment = ComponentAlignment::Left; + LabelPosition labelPosition = LabelPosition::Near; + }; + + void PushStyleCheckbox(const ImVec4& color = Colors::Indigo); + void PopStyleCheckbox(); + bool Checkbox(const char* label, bool* v, const CheckboxOptions& options = {}); + bool CVarCheckbox(const char* label, const char* cvarName, const CheckboxOptions& options = {}); + + struct ComboboxOptions { + const ImVec4 color = Colors::Indigo; + const char* tooltip = ""; + bool disabled = false; + const char* disabledTooltip = ""; + uint32_t defaultIndex = 0; // Only applicable to CVarCombobox + ComponentAlignment alignment = ComponentAlignment::Left; + LabelPosition labelPosition = LabelPosition::Above; + ImGuiComboFlags flags = 0; + }; + + void PushStyleCombobox(const ImVec4& color = Colors::Indigo); + void PopStyleCombobox(); + bool Combobox(const char* label, uint8_t* value, std::span comboArray, const ComboboxOptions& options = {}); + bool CVarCombobox(const char* label, const char* cvarName, std::span comboArray, const ComboboxOptions& options = {}); + + struct IntSliderOptions { + const ImVec4 color = Colors::Gray; + const char* tooltip = ""; + bool disabled = false; + const char* disabledTooltip = ""; + bool showButtons = true; + ImGuiSliderFlags flags = 0; + const char* format = "%d"; + const uint32_t step = 1; + ComponentAlignment alignment = ComponentAlignment::Left; + LabelPosition labelPosition = LabelPosition::Above; + }; + + struct FloatSliderOptions { + const ImVec4 color = Colors::Gray; + const char* tooltip = ""; + bool disabled = false; + const char* disabledTooltip = ""; + bool showButtons = true; + ImGuiSliderFlags flags = 0; + const char* format = "%f"; + const float step = 0.01f; + bool isPercentage = false; // Multiplies visual value by 100 + ComponentAlignment alignment = ComponentAlignment::Left; + LabelPosition labelPosition = LabelPosition::Above; + }; + + void PushStyleSlider(const ImVec4& color = Colors::Indigo); + void PopStyleSlider(); + bool SliderInt(const char* label, int32_t* value, int32_t min, int32_t max, const IntSliderOptions& options = {}); + bool CVarSliderInt(const char* label, const char* cvarName, int32_t min, int32_t max, const int32_t defaultValue, const IntSliderOptions& options = {}); + bool SliderFloat(const char* label, float* value, float min, float max, const FloatSliderOptions& options = {}); + bool CVarSliderFloat(const char* label, const char* cvarName, float min, float max, const float defaultValue, const FloatSliderOptions& options = {}); +} \ No newline at end of file diff --git a/src/profiler.c b/src/profiler.c index 2bb9f5b97..1066c3964 100644 --- a/src/profiler.c +++ b/src/profiler.c @@ -1,4 +1,4 @@ -#include +#include #include #include "profiler.h" #include diff --git a/src/racing/actors.c b/src/racing/actors.c index 4f919a22e..5013b0878 100644 --- a/src/racing/actors.c +++ b/src/racing/actors.c @@ -1,12 +1,11 @@ -#include +#include #include -#include #include #include #include #include #include -#include +#include #include "code_800029B0.h" #include "main.h" @@ -396,7 +395,7 @@ void func_802977E4(Player *arg0) { // Invert green and red on green shell texture void init_red_shell_texture(void) { s16 *red_shell_texture = (s16 *) &gTLUTRedShell[0]; - s16 *green_shell_texture = (s16 *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[SEGMENT_NUMBER2(common_tlut_green_shell)] + SEGMENT_OFFSET(common_tlut_green_shell)); + s16 *green_shell_texture = (s16 *) common_tlut_green_shell; s16 color_pixel, red_color, green_color, blue_color, alpha_color; s32 i; for (i = 0; i < 256; i++) { @@ -469,10 +468,8 @@ void render_cows(Camera *camera, Mat4 arg1, UNUSED struct Actor *actor) { struct ActorSpawnData *var_s5; Vec3f sp88; u32 soundThing = SOUND_ARG_LOAD(0x19, 0x01, 0x90, 0x4D); - s32 segment = SEGMENT_NUMBER2(d_course_moo_moo_farm_cow_spawn); - s32 offset = SEGMENT_OFFSET(d_course_moo_moo_farm_cow_spawn); - var_t1 = (struct ActorSpawnData*)VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + var_t1 = d_course_moo_moo_farm_cow_spawn; D_8015F704 = 6.4e7f; gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON); gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA); @@ -537,9 +534,7 @@ void render_cows(Camera *camera, Mat4 arg1, UNUSED struct Actor *actor) { void evaluate_collision_player_palm_trees(Player *player) { Vec3f pos; - s32 segment = SEGMENT_NUMBER2(d_course_dks_jungle_parkway_tree_spawn); - s32 offset = SEGMENT_OFFSET(d_course_dks_jungle_parkway_tree_spawn); - struct UnkActorSpawnData *data = (struct UnkActorSpawnData *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + struct UnkActorSpawnData *data = d_course_dks_jungle_parkway_tree_spawn; while (data->pos[0] != END_OF_SPAWN_DATA) { pos[0] = data->pos[0] * gCourseDirection; @@ -572,9 +567,7 @@ void evaluate_collision_players_palm_trees(void) { } void func_80298D10(void) { - s32 segment = SEGMENT_NUMBER2(d_course_dks_jungle_parkway_tree_spawn); - s32 offset = SEGMENT_OFFSET(d_course_dks_jungle_parkway_tree_spawn); - struct UnkActorSpawnData *temp_v1 = (struct UnkActorSpawnData *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + struct UnkActorSpawnData *temp_v1 = d_course_dks_jungle_parkway_tree_spawn; while (temp_v1->pos[0] != END_OF_SPAWN_DATA) { temp_v1->pos[1] = temp_v1->unk8; @@ -584,9 +577,7 @@ void func_80298D10(void) { } void render_palm_trees(Camera *camera, Mat4 arg1, UNUSED struct Actor *actor) { - s32 segment = SEGMENT_NUMBER2(d_course_dks_jungle_parkway_tree_spawn); - s32 offset = SEGMENT_OFFSET(d_course_dks_jungle_parkway_tree_spawn); - struct UnkActorSpawnData *var_s1 = (struct UnkActorSpawnData *)VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + struct UnkActorSpawnData *var_s1 = d_course_dks_jungle_parkway_tree_spawn; UNUSED s32 pad; Vec3f spD4; f32 var_f22; @@ -803,9 +794,7 @@ UNUSED void func_8029AE14() { #include "actors/falling_rock/render.inc.c" void spawn_piranha_plants(struct ActorSpawnData *spawnData) { - s32 segment = SEGMENT_NUMBER2(spawnData); - s32 offset = SEGMENT_OFFSET(spawnData); - struct ActorSpawnData *temp_s0 = (struct ActorSpawnData *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + struct ActorSpawnData *temp_s0 = spawnData; struct PiranhaPlant *temp_v1; UNUSED s32 pad; Vec3f startingPos; @@ -835,9 +824,7 @@ void spawn_piranha_plants(struct ActorSpawnData *spawnData) { } void spawn_palm_trees(struct ActorSpawnData *spawnData) { - s32 segment = SEGMENT_NUMBER2(spawnData); - s32 offset = SEGMENT_OFFSET(spawnData); - struct ActorSpawnData *temp_s0 = (struct ActorSpawnData *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + struct ActorSpawnData *temp_s0 = spawnData; struct PalmTree *temp_v1; Vec3f startingPos; Vec3f startingVelocity; @@ -873,10 +860,8 @@ void spawn_foliage(struct ActorSpawnData *arg0) { s16 actorType; struct Actor *temp_s0; struct ActorSpawnData *var_s3; - s32 segment = SEGMENT_NUMBER2(arg0); - s32 offset = SEGMENT_OFFSET(arg0); - var_s3 = (struct ActorSpawnData *)VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + var_s3 = arg0; vec3f_set(velocity, 0.0f, 0.0f, 0.0f); rotation[0] = 0x4000; rotation[1] = 0; @@ -946,14 +931,12 @@ void spawn_foliage(struct ActorSpawnData *arg0) { } void spawn_all_item_boxes(struct ActorSpawnData *spawnData) { - s32 segment = SEGMENT_NUMBER2(spawnData); - s32 offset = SEGMENT_OFFSET(spawnData); s16 temp_s1; f32 temp_f0; Vec3f startingPos; Vec3f startingVelocity; Vec3s startingRot; - struct ActorSpawnData *temp_s0 = (struct ActorSpawnData *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + struct ActorSpawnData *temp_s0 = spawnData; //struct ItemBox *itemBox; if ((gModeSelection == TIME_TRIALS) || (gPlaceItemBoxes == 0)) { return; } @@ -1157,7 +1140,7 @@ void spawn_course_actors(void) { /** * @brief Loads actor textures, course specific actor textures. * Calls to init_course_vehicles and place_course_actors - * + * */ void init_actors_and_load_textures(void) { set_segment_base_addr(3, (void *) gNextFreeMemoryAddress); @@ -1448,10 +1431,8 @@ struct test { UNUSED void prototype_actor_spawn_data(Player *player, uintptr_t arg1) { Vec3f sp64; struct test *var_s0; - s32 segment = SEGMENT_NUMBER2(arg1); - s32 offset = SEGMENT_OFFSET(arg1); - var_s0 = (struct test *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + var_s0 = (struct test *) arg1; while (var_s0->thing[0] != END_OF_SPAWN_DATA) { sp64[0] = var_s0->thing[0] * gCourseDirection; sp64[1] = var_s0->thing[1]; @@ -1555,9 +1536,9 @@ bool collision_mario_sign(Player *player, struct Actor *marioRacewaySign) { func_800C9060(player - gPlayerOne, SOUND_ARG_LOAD(0x19, 0x00, 0x70, 0x1A)); } } - return TRUE; + return true; } - return FALSE; + return false; } bool collision_piranha_plant(Player *player, struct PiranhaPlant *plant) { @@ -1571,9 +1552,9 @@ bool collision_piranha_plant(Player *player, struct PiranhaPlant *plant) { func_800C9060(player - gPlayerOne, SOUND_ARG_LOAD(0x19, 0x00, 0xA0, 0x52)); } } - return TRUE; + return true; } - return FALSE; + return false; } bool collision_yoshi_egg(Player *player, struct YoshiValleyEgg *egg) { @@ -1588,34 +1569,34 @@ bool collision_yoshi_egg(Player *player, struct YoshiValleyEgg *egg) { x_dist = egg->pos[0] - player->pos[0]; if ((x_dist < minDist) && (x_dist < -maxDist)) { - return FALSE; + return false; } if (x_dist > maxDist) { - return FALSE; + return false; } z_dist = egg->pos[2] - player->pos[2]; if ((z_dist < minDist) && (z_dist < -maxDist)) { - return FALSE; + return false; } if (z_dist > maxDist) { - return FALSE; + return false; } xz_dist = sqrtf((x_dist * x_dist) + (z_dist * z_dist)); if (xz_dist > maxDist) { - return FALSE; + return false; } func_802977B0(player); y_dist = player->pos[1] - egg->pos[1]; if (y_dist < minDist) { - return FALSE; + return false; } totalBox = player->boundingBoxSize + egg->boundingBoxSize; if (totalBox < xz_dist) { - return FALSE; + return false; } if ((player->type & PLAYER_HUMAN) != 0) { @@ -1634,7 +1615,7 @@ bool collision_yoshi_egg(Player *player, struct YoshiValleyEgg *egg) { apply_hit_sound_effect(player, player - gPlayerOne); } - return TRUE; + return true; } bool collision_tree(Player *player, struct Actor *actor) { @@ -1654,33 +1635,33 @@ bool collision_tree(Player *player, struct Actor *actor) { var_f16 = actor->unk_08; x_dist = actor->pos[0] - player->pos[0]; if ((x_dist < 0.0f) && (x_dist < -var_f16)) { - return FALSE; + return false; } if (var_f16 < x_dist) { - return FALSE; + return false; } z_dist = actor->pos[2] - player->pos[2]; if ((z_dist < 0.0f) && (z_dist < -var_f16)) { - return FALSE; + return false; } if (var_f16 < z_dist) { - return FALSE; + return false; } y_dist = player->pos[1] - actor->pos[1]; if (y_dist < 0.0f) { - return FALSE; + return false; } if ((f32) actor->state < y_dist) { - return FALSE; + return false; } xz_dist = sqrtf((x_dist * x_dist) + (z_dist * z_dist)); if (var_f16 < xz_dist) { - return FALSE; + return false; } func_802977B0(player); var_f16 = player->boundingBoxSize + actor->boundingBoxSize; if (var_f16 < xz_dist) { - return FALSE; + return false; } sp48 = player->velocity[0]; sp44 = player->velocity[2]; @@ -1689,7 +1670,7 @@ bool collision_tree(Player *player, struct Actor *actor) { actor->flags |= 0x400; func_800C98B8(player->pos, player->velocity, SOUND_ARG_LOAD(0x19, 0x01, 0x80, 0x10)); func_800C90F4(player - gPlayerOne, (player->characterId * 0x10) + SOUND_ARG_LOAD(0x29, 0x00, 0x80, 0x0D)); - return TRUE; + return true; } if (!(player->type & PLAYER_INVISIBLE_OR_BOMB)) { func_800C9060(player - gPlayerOne, SOUND_ARG_LOAD(0x19, 0x00, 0x70, 0x18)); @@ -1720,7 +1701,7 @@ bool collision_tree(Player *player, struct Actor *actor) { player->pos[2] = actorPos[2] - (z_dist * var_f16 * 1.2f); player->velocity[0] = 0; player->velocity[2] = 0; - return TRUE; + return true; } temp_f12 = ((x_dist * sp48) + (z_dist * sp44)) / temp_f0_4; temp_f12 = temp_f0_4 * temp_f12 * 1.5f; @@ -1730,7 +1711,7 @@ bool collision_tree(Player *player, struct Actor *actor) { player->pos[0] += x_dist * temp_f2 * 0.5f; player->pos[2] += z_dist * temp_f2 * 0.5f; } - return TRUE; + return true; } bool query_collision_player_vs_actor_item(Player *arg0, struct Actor *arg1) { diff --git a/src/racing/actors.h b/src/racing/actors.h index 8c0b2e2b2..a9cb13830 100644 --- a/src/racing/actors.h +++ b/src/racing/actors.h @@ -83,13 +83,13 @@ void destroy_actor(struct Actor*); s16 try_remove_destructable_item(Vec3f, Vec3s, Vec3f, s16); s16 add_actor_to_empty_slot(Vec3f, Vec3s, Vec3f, s16); s16 spawn_actor_at_pos(Vec3f, s16); -s32 query_and_resolve_collision_player_actor(Player*, Vec3f, f32, f32, f32); -s32 collision_mario_sign(Player*, struct Actor*); -s32 collision_piranha_plant(Player*, struct PiranhaPlant*); -s32 collision_yoshi_egg(Player*, struct YoshiValleyEgg*); -s32 collision_tree(Player*, struct Actor*); -s32 query_collision_player_vs_actor_item(Player*, struct Actor*); -s32 query_collision_actor_vs_actor(struct Actor*, struct Actor*); +bool query_and_resolve_collision_player_actor(Player*, Vec3f, f32, f32, f32); +bool collision_mario_sign(Player*, struct Actor*); +bool collision_piranha_plant(Player*, struct PiranhaPlant*); +bool collision_yoshi_egg(Player*, struct YoshiValleyEgg*); +bool collision_tree(Player*, struct Actor*); +bool query_collision_player_vs_actor_item(Player*, struct Actor*); +bool query_collision_actor_vs_actor(struct Actor*, struct Actor*); void destroy_destructable_actor(struct Actor*); void play_sound_on_destructible_actor_collision(struct Actor*, struct Actor*); void evaluate_actor_collision_between_two_destructible_actors(struct Actor*, struct Actor*); diff --git a/src/racing/actors_extended.c b/src/racing/actors_extended.c index a28d64215..0b3df79de 100644 --- a/src/racing/actors_extended.c +++ b/src/racing/actors_extended.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -315,19 +315,19 @@ void update_actor_banana_bunch(struct BananaBunchParent *banana_bunch) { bool is_shell_exist(s16 arg0) { struct ShellActor *actor; if (arg0 < 0) { - return FALSE; + return false; } actor = (struct ShellActor*) &gActorList[arg0]; if (actor->type == ACTOR_GREEN_SHELL) { if (actor->state == TRIPLE_GREEN_SHELL) { - return TRUE; + return true; } - return FALSE; + return false; } if (actor->state == TRIPLE_RED_SHELL) { - return TRUE; + return true; } - return FALSE; + return false; } void update_actor_triple_shell(TripleShellParent *parent, s16 shellType) { @@ -606,12 +606,12 @@ s32 use_green_shell_item(Player *player) { // rotate to match player orientation mtxf_translate_vec3f_mat3(startingPos, player->orientationMatrix); - + // move to player position startingPos[0] += player->pos[0]; startingPos[1] += player->pos[1]; startingPos[2] += player->pos[2]; - + // spawn the shell actorIndex = add_actor_to_empty_slot(startingPos, startingRot, startingVelocity, ACTOR_GREEN_SHELL); if (actorIndex < 0) { @@ -848,8 +848,8 @@ s32 use_banana_item(Player *player) { /** * Strikes players with thunder - * - * @param Activating player (not to be struck) + * + * @param Activating player (not to be struck) */ void use_thunder_item(Player *player) { s32 index; @@ -932,7 +932,7 @@ void check_player_use_item(void) { for (player = &gPlayers[0], loopController = &gControllers[0], target = &gControllers[4]; loopController != target; player++, loopController++) { controller = loopController; - if (prevent_item_use(player) == FALSE) { + if (prevent_item_use(player) == false) { if((player->type & PLAYER_INVISIBLE_OR_BOMB) != 0){ if ((player - gPlayerTwo) == 0) { controller = gControllerSix; diff --git a/src/racing/collision.c b/src/racing/collision.c index f42acaf5a..1f3b94a7a 100644 --- a/src/racing/collision.c +++ b/src/racing/collision.c @@ -1,6 +1,6 @@ -#include +#include #include -#include +#include #include #include #include @@ -10,16 +10,11 @@ #include "math_util.h" #include "code_800029B0.h" -#pragma intrinsic (sqrtf) - // Used to delete the choco mountain guard rail void nullify_displaylist(uintptr_t addr) { - s32 segment = SEGMENT_NUMBER2(addr); - s32 offset = SEGMENT_OFFSET(addr); - Gfx *macro; - macro = (Gfx *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + macro = (Gfx *) addr; macro->words.w0 = (G_ENDDL << 24); macro->words.w1 = 0; } @@ -127,7 +122,7 @@ s32 func_802AAE4C(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, f32 temp_f10; f32 temp_f0_3; f32 temp_f2_2; - s32 bool = 1; + s32 flag = 1; if (surfaceMap->gravity < -0.9f) return 0; @@ -160,7 +155,7 @@ s32 func_802AAE4C(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, temp_f2_2 = (z3 - posZ) * (x1 - posX) - (x3 - posX) * (z1 - posZ); if ((temp_f0_3 * temp_f2_2) < 0.0f) { - bool = 0; + flag = 0; } } else { @@ -170,22 +165,22 @@ s32 func_802AAE4C(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, temp_f2_2 = (z3 - posZ) * (x1 - posX) - (x3 - posX) * (z1 - posZ); if ((temp_f10 * temp_f2_2) < 0.0f) { - bool = 0; + flag = 0; } } else { if ((temp_f10 * temp_f0_3) < 0.0f) { - bool = 0; + flag = 0; } else { temp_f2_2 = (z3 - posZ) * (x1 - posX) - (x3 - posX) * (z1 - posZ); if (temp_f2_2 != 0) { if ((temp_f0_3 * temp_f2_2) < 0.0f) { - bool = 0; + flag = 0; } } } } } - if (!bool) { + if (!flag) { return 0; } temp_f0_5 = ((surfaceMap->height * posX) + (surfaceMap->gravity * posY) + (surfaceMap->rotation * posZ) @@ -222,7 +217,7 @@ s32 func_802AB288(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, f32 x3; f32 y3; UNUSED f32 pad2[1]; - + UNUSED f32 pad3[5]; f32 x2; f32 y2; @@ -232,7 +227,7 @@ s32 func_802AB288(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, f32 temp_f2_2; f32 temp_f0_2; f32 temp_f2_3; - s32 bool = 1; + s32 flag = 1; if (surfaceMap->vtx31 > posX) { return 0; @@ -272,29 +267,29 @@ s32 func_802AB288(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, temp_f2_3 = (y3 - posY) * (x1 - posX) - (x3 - posX) * (y1 - posY); if ((temp_f0_2 * temp_f2_3) < 0.0f) { - bool = 0; + flag = 0; } } else { temp_f0_2 = (y2 - posY) * (x3 - posX) - (x2 - posX) * (y3 - posY); if (!temp_f0_2) { temp_f2_3 = (y3 - posY) * (x1 - posX) - (x3 - posX) * (y1 - posY); if (temp_f2_2 * temp_f2_3 < 0.0f) { - bool = 0; + flag = 0; } } else { if ((temp_f2_2 * temp_f0_2) < 0.0f) { - bool = 0; + flag = 0; } else { temp_f2_3 = ((y3 - posY) * (x1 - posX)) - ((x3 - posX) * (y1 - posY)); if (temp_f2_3 != 0) { if ((temp_f0_2 * temp_f2_3) < 0.0f) { - bool = 0; + flag = 0; } } } } } - if (!bool) { + if (!flag) { return 0; } temp_f0_4 = ((surfaceMap->height * posX) + (surfaceMap->gravity * posY) + (surfaceMap->rotation * posZ) + surfaceMap->height2) - boundingBoxSize; @@ -325,7 +320,7 @@ s32 func_802AB288(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, s32 func_802AB6C4(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, f32 posZ, u16 index) { mk64_surface_map_ram *surfaceMap = &gSurfaceMap[index]; - s32 bool = 1; + bool flag = 1; UNUSED f32 pad[7]; f32 sp20; f32 temp_f8; @@ -375,7 +370,7 @@ s32 func_802AB6C4(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, temp_f2_3 = ((sp20 - posY) * (sp24 - posZ)) - ((temp_f8 - posZ) * (temp_f4 - posY)); if ((temp_f0_2 * temp_f2_3) < 0.0f) { - bool = 0; + flag = 0; } } else { @@ -385,23 +380,23 @@ s32 func_802AB6C4(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, temp_f2_3 = ((sp20 - posY) * (sp24 - posZ)) - ((temp_f8 - posZ) * (temp_f4 - posY)); if ((temp_f2_2 * temp_f2_3) < 0.0f) { - bool = 0; + flag = 0; } } else { if ((temp_f2_2 * temp_f0_2) < 0.0f) { - bool = 0; + flag = 0; } else { temp_f2_3 = ((sp20 - posY) * (sp24 - posZ)) - ((temp_f8 - posZ) * (temp_f4 - posY)); if (temp_f2_3 != 0) { if ((temp_f0_2 * temp_f2_3) < 0.0f) { - bool = 0; + flag = 0; } } } } } - if (!bool) { + if (!flag) { return 0; } @@ -447,7 +442,7 @@ s32 func_802ABB04(f32 posX, f32 posZ, u16 index) { f32 temp_f2_2; f32 temp_f2_3; f32 temp_f0_2; - s32 bool = 1; + s32 flag = 1; x1 = surfaceMap->vtxPoly1->v.ob[0]; z1 = surfaceMap->vtxPoly1->v.ob[2]; @@ -467,29 +462,29 @@ s32 func_802ABB04(f32 posX, f32 posZ, u16 index) { temp_f2_3 = (z3 - posZ) * (x1 - posX) - (x3 - posX) * (z1 - posZ); if ((temp_f0_2 * temp_f2_3) < 0.0f) { - bool = 0; + flag = 0; } } else { temp_f0_2 = (z2 - posZ) * (x3 - posX) - (x2 - posX) * (z3 - posZ); if (!temp_f0_2) { temp_f2_3 = (z3 - posZ) * (x1 - posX) - (x3 - posX) * (z1 - posZ); if (temp_f2_2 * temp_f2_3 < 0.0f) { - bool = 0; + flag = 0; } } else { if ((temp_f2_2 * temp_f0_2) < 0.0f) { - bool = 0; + flag = 0; } else { temp_f2_3 = ((z3 - posZ) * (x1 - posX)) - ((x3 - posX) * (z1 - posZ)); if (temp_f2_3 != 0) { if ((temp_f0_2 * temp_f2_3) < 0.0f) { - bool = 0; + flag = 0; } } } } } - return bool; + return flag; } s8 get_surface_type(u16 index) { @@ -777,7 +772,7 @@ s32 is_colliding_with_drivable_surface(Collision *collision, f32 boundingBoxSize f32 area; f32 area2; f32 area3; - s32 bool = 1; + s32 flag = 1; if (tile->vtx31 > x1) { return 0; @@ -810,7 +805,7 @@ s32 is_colliding_with_drivable_surface(Collision *collision, f32 boundingBoxSize area2 = (z3 - z1) * (x4 - x1) - (x3 - x1) * (z4 - z1); area3 = (z4 - z1) * (x2 - x1) - (x4 - x1) * (z2 - z1); if (area2 * area3 < 0.0f) { - bool = 0; + flag = 0; } } else { @@ -822,22 +817,22 @@ s32 is_colliding_with_drivable_surface(Collision *collision, f32 boundingBoxSize area3 = (z4 - z1) * (x2 - x1) - (x4 - x1) * (z2 - z1); if (area * area3 < 0.0f) { - bool = 0; + flag = 0; } } else { if ((area * area2) < 0.0f) { - bool = 0; + flag = 0; } else { area3 = (z4- z1) * (x2 - x1) - (x4 - x1) * (z2 - z1); if (area3 != 0) { if (area2 * area3 < 0.0f) { - bool = 0; + flag = 0; } } } } } - if (bool == 0) { + if (flag == 0) { return 0; } @@ -884,11 +879,11 @@ s32 is_colliding_with_wall2(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, UNUSED s32 pad2[3]; f32 temp_f0_4; f32 temp_f4_2; - UNUSED s32 pad3[2]; + UNUSED s32 pad3[2]; f32 area; f32 area2; f32 area3; - s32 bool = 1; + s32 flag = 1; if (tile->vtx31 > x1) { return 0; } @@ -925,7 +920,7 @@ s32 is_colliding_with_wall2(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, if (area2 * area3 < 0.0f) { - bool = 0; + flag = 0; } } else { @@ -936,23 +931,23 @@ s32 is_colliding_with_wall2(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, if ((area * area3) < 0.0f) { - bool = 0; + flag = 0; } } else { if ((area * area2) < 0.0f) { - bool = 0; + flag = 0; } else { area3 = (y4 - y1) * (x2 - x1) - (x4 - x1) * (y2 - y1); if (area3 != 0) { if ((area2 * area3) < 0.0f) { - bool = 0; + flag = 0; } } } } } - if (bool == 0) { + if (flag == 0) { return 0; } @@ -1054,7 +1049,7 @@ s32 is_colliding_with_wall2(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, */ s32 is_colliding_with_wall1(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, f32 z1, u16 arg5, f32 arg6, f32 arg7, f32 arg8) { mk64_surface_map_ram *tile = &gSurfaceMap[arg5]; - s32 bool = 1; + s32 flag = 1; UNUSED s32 pad[7]; f32 y4; f32 z4; @@ -1065,7 +1060,7 @@ s32 is_colliding_with_wall1(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, UNUSED s32 pad3[2]; f32 temp_f0_4; f32 temp_f4_2; - UNUSED s32 pad4[2]; + UNUSED s32 pad4[2]; f32 area; f32 area2; f32 area3; @@ -1106,7 +1101,7 @@ s32 is_colliding_with_wall1(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, if (area2 * area3 < 0.0f) { - bool = 0; + flag = 0; } } else { @@ -1117,23 +1112,23 @@ s32 is_colliding_with_wall1(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, if ((area * area3) < 0.0f) { - bool = 0; + flag = 0; } } else { if ((area * area2) < 0.0f) { - bool = 0; + flag = 0; } else { area3 = (y4 - y1) * (z2 - z1) - (z4 - z1) * (y2 - y1); if (area3 != 0) { if ((area2 * area3) < 0.0f) { - bool = 0; + flag = 0; } } } } } - if (bool == 0) { + if (flag == 0) { return 0; } @@ -1246,7 +1241,7 @@ u16 func_802AD950(Collision *collision, f32 boundingBoxSize, f32 x1, f32 y1, f32 u16 flags = 0; s32 temp1; s32 temp2; - + u16 i; collision->unk30 = 0; @@ -1341,7 +1336,7 @@ u16 func_802AD950(Collision *collision, f32 boundingBoxSize, f32 x1, f32 y1, f32 } } phi_s2++; - + } return flags; } @@ -1386,7 +1381,7 @@ u16 func_802ADDC8(Collision* collision, f32 boundingBoxSize, f32 posX, f32 posY, if (var_s4 == (0x4000 | 0x2000 | 0x8000)) { return var_s4; } - + temp_f4 = (s32) gCourseMaxX - gCourseMinX; temp_f6 = (s32) gCourseMaxZ - gCourseMinZ; @@ -1396,7 +1391,7 @@ u16 func_802ADDC8(Collision* collision, f32 boundingBoxSize, f32 posX, f32 posY, temp_f10 = (posX - gCourseMinX) / temp1; temp_f16 = (posZ - gCourseMinZ) / temp2; - + if (temp_f10 < 0) { return 0; } @@ -1577,10 +1572,10 @@ void func_802AE434(Vtx *vtx1, Vtx *vtx2, Vtx *vtx3, s8 surfaceType, u16 sectionI tile->vtxPoly1 = vtx1; tile->vtxPoly2 = vtx2; tile->vtxPoly3 = vtx3; - if ((tile->vtxPoly1->v.flag == 4) && - (tile->vtxPoly2->v.flag == 4) && + if ((tile->vtxPoly1->v.flag == 4) && + (tile->vtxPoly2->v.flag == 4) && (tile->vtxPoly3->v.flag == 4)) { - + return; } @@ -1680,7 +1675,7 @@ void func_802AE434(Vtx *vtx1, Vtx *vtx2, Vtx *vtx3, s8 surfaceType, u16 sectionI if (maxZ > gCourseMaxZ) { gCourseMaxZ = maxZ; } - + tile->height = normalX; tile->gravity = normalY; tile->rotation = normalZ; @@ -1782,7 +1777,7 @@ void set_vtx_from_quadrangle(u32 line, s8 surfaceType, u16 sectionId) { vtx2 = vtxBuffer[vert2]; vtx3 = vtxBuffer[vert3]; vtx4 = vtxBuffer[vert4]; - + // Triangle 1 func_802AE434(vtx1, vtx2, vtx3, surfaceType, sectionId); // Triangle 2 @@ -1794,9 +1789,7 @@ void set_vtx_from_quadrangle(u32 line, s8 surfaceType, u16 sectionId) { */ void set_vtx_buffer(uintptr_t addr, u32 numVertices, u32 bufferIndex) { u32 i; - u32 segment = SEGMENT_NUMBER2(addr); - u32 offset = SEGMENT_OFFSET(addr); - Vtx *vtx = (Vtx *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + Vtx *vtx = (Vtx *) addr; for (i = 0; i < numVertices; i++) { vtxBuffer[bufferIndex] = vtx; vtx++; @@ -1986,7 +1979,7 @@ void set_vertex_data_with_default_section_id(Gfx *gfx, s8 surfaceType) { extern u32 D_8015F58C; /** - * Recursive search and set for vertex data + * Recursive search and set for vertex data */ void find_and_set_vertex_data(Gfx *addr, s8 surfaceType, u16 sectionId) { s32 opcode; @@ -1994,9 +1987,7 @@ void find_and_set_vertex_data(Gfx *addr, s8 surfaceType, u16 sectionId) { uintptr_t hi; s32 i; - s32 segment = SEGMENT_NUMBER2(addr); - s32 offset = SEGMENT_OFFSET(addr); - Gfx *gfx = (Gfx *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + Gfx *gfx = (Gfx *) addr; D_8015F6FA = 0; D_8015F6FC = 0; @@ -2036,15 +2027,13 @@ void find_and_set_vertex_data(Gfx *addr, s8 surfaceType, u16 sectionId) { * Search for G_SETTILESIZE and set its args. */ void find_and_set_tile_size(uintptr_t addr, s32 uls, s32 ult) { - u32 segment = SEGMENT_NUMBER2(addr); - u32 offset = SEGMENT_OFFSET(addr); - Gfx *gfx = (Gfx *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + Gfx *gfx = (Gfx *) addr; u32 opcode; uls = (uls << 12) & 0xFFF000; ult &= 0xFFF; - while(TRUE) { + while(true) { opcode = GFX_GET_OPCODE(gfx->words.w0); @@ -2060,10 +2049,8 @@ void find_and_set_tile_size(uintptr_t addr, s32 uls, s32 ult) { } void set_vertex_colours(uintptr_t addr, u32 vertexCount, UNUSED s32 vert3, s8 alpha, u8 red, u8 green, u8 blue) { - s32 segment = SEGMENT_NUMBER2(addr); - s32 offset = SEGMENT_OFFSET(addr); s32 i; - Vtx *vtx = (Vtx *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + Vtx *vtx = (Vtx *) addr; for (i = 0; (u32)i < vertexCount; i++) { if (red) { @@ -2080,14 +2067,12 @@ void set_vertex_colours(uintptr_t addr, u32 vertexCount, UNUSED s32 vert3, s8 al * Recursive search for vertices and set their colour values. */ void find_vtx_and_set_colours(uintptr_t displayList, s8 alpha, u8 red, u8 green, u8 blue) { - s32 segment = SEGMENT_NUMBER2(displayList); - s32 offset = SEGMENT_OFFSET(displayList); - Gfx *gfx = (Gfx *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + Gfx *gfx = (Gfx *) displayList; uintptr_t lo; uintptr_t hi; s32 opcode; - while(TRUE) { + while(true) { lo = gfx->words.w0; hi = gfx->words.w1; opcode = GFX_GET_OPCODE(lo); @@ -2122,7 +2107,7 @@ u16 process_collision(Player *player, KartBoundingBoxCorner *corner, f32 cornerP f32 cornerPos3; f32 boundingBoxSize; f32 temp_f0; - + s32 temp_v0_2; s32 temp_v1; @@ -2183,7 +2168,7 @@ u16 process_collision(Player *player, KartBoundingBoxCorner *corner, f32 cornerP } // If the surface flags are not set then try setting them. - + temp_v0_2 = (s32) gCourseMaxX - gCourseMinX; temp_v1 = (s32) gCourseMaxZ - gCourseMinZ; diff --git a/src/racing/math_util.c b/src/racing/math_util.c index 3305cb931..2590f0408 100644 --- a/src/racing/math_util.c +++ b/src/racing/math_util.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -127,7 +127,7 @@ void *vec3f_copy_return(Vec3f dest, Vec3f src) { dest[1] = src[1]; dest[2] = src[2]; //! @warning function returns address of local variable - return &dest; + return &dest; } void vec3s_copy(Vec3s dest, Vec3s src) { @@ -422,8 +422,6 @@ void func_802B5D30(s16 arg0, s16 arg1, s32 arg2) { } void func_802B5D64(uintptr_t addr, s16 arg1, s16 arg2, s32 arg3) { - u32 segment = SEGMENT_NUMBER2(addr); - u32 offset = SEGMENT_OFFSET(addr); UNUSED s32 pad; f32 sp48; f32 sp44; @@ -434,7 +432,7 @@ void func_802B5D64(uintptr_t addr, s16 arg1, s16 arg2, s32 arg3) { s8 sp2C[3]; Lights1 *var_s0; - var_s0 = (Lights1 *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + var_s0 = (Lights1 *) addr; sp48 = sins(arg2); sp44 = coss(arg2); sp40 = sins(arg1); @@ -1154,8 +1152,6 @@ f32 is_within_render_distance(Vec3f cameraPos, Vec3f objectPos, u16 orientationY // No idea if arg1 is actually a Mat4 or not, but since this function is unused // its impossible to know with certainty either way, very close of func_802B5D64 UNUSED void func_802B8414(uintptr_t addr, Mat4 arg1, s16 arg2, s16 arg3, s32 arg4) { - u32 segment = SEGMENT_NUMBER2(addr); - u32 offset = SEGMENT_OFFSET(addr); UNUSED s32 pad; Vec3f sp40; s8 sp3C[3]; @@ -1163,7 +1159,7 @@ UNUSED void func_802B8414(uintptr_t addr, Mat4 arg1, s16 arg2, s16 arg3, s32 arg UNUSED s32 pad2[3]; Lights1 *var_s0; - var_s0 = (Lights1 *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + var_s0 = (Lights1 *) addr; sins(arg3); coss(arg3); sins(arg2); diff --git a/src/racing/math_util.h b/src/racing/math_util.h index f3ec26b3f..6b7159556 100644 --- a/src/racing/math_util.h +++ b/src/racing/math_util.h @@ -1,7 +1,7 @@ #ifndef MATH_UTIL_H #define MATH_UTIL_H -#include +#include //#define sins(x) gSineTable[(u16) (x) >> 4] diff --git a/src/racing/memory.c b/src/racing/memory.c index d2d352d62..f453c3262 100644 --- a/src/racing/memory.c +++ b/src/racing/memory.c @@ -1,5 +1,5 @@ -#include -#include +#include +#include #include #include #include @@ -31,7 +31,7 @@ s32 memoryPadding[2]; * @brief Returns the address of the next available memory location and updates the memory pointer * to reference the next location of available memory based provided size to allocate. * @param size of memory to allocate. - * @return Address of free memory + * @return Address of free memory */ void *get_next_available_memory_addr(u32 size) { u32 *freeSpace = (u32 *)gNextFreeMemoryAddress; @@ -84,7 +84,7 @@ void move_segment_table_to_dmem(void) { /** * @brief Sets the starting location for allocating memory and calculates pool size. - * + * * Default memory size, 701.984 Kilobytes. */ void initialize_memory_pool(uintptr_t poolStart, uintptr_t poolEnd) { @@ -245,7 +245,7 @@ UNUSED void *func_802A80B0(u8 *dest, u8 *srcStart, u8 *srcEnd) { void *addr; u32 size = srcStart - dest; addr = main_pool_alloc(size, (u32) srcEnd); - + if (addr != 0) { osInvalDCache(addr, size); @@ -349,7 +349,7 @@ UNUSED s32 func_802A8348(s32 arg0, s32 arg1, s32 arg2) { UNUSED void *pad; uintptr_t oldAddr; void *newAddr; - + offset = ALIGN16(arg1 * arg2); oldAddr = gNextFreeMemoryAddress; newAddr = (void *) (oldAddr + offset); @@ -357,7 +357,7 @@ UNUSED s32 func_802A8348(s32 arg0, s32 arg1, s32 arg2) { osInvalDCache(newAddr, offset); osPiStartDma(&gDmaIoMesg, 0, 0, (uintptr_t) &_other_texturesSegmentRomStart[SEGMENT_OFFSET(arg0)], newAddr, offset, &gDmaMesgQueue); osRecvMesg(&gDmaMesgQueue, &gMainReceivedMesg, 1); - + func_80040030((u8 *) newAddr, (u8 *) oldAddr); gNextFreeMemoryAddress += offset; return oldAddr; @@ -370,7 +370,7 @@ UNUSED u8 *func_802A841C(u8* arg0, s32 arg1, s32 arg2) { temp_a0 = temp_v0 + arg2; arg1 = ALIGN16(arg1); arg2 = ALIGN16(arg2); - + osInvalDCache(temp_a0, arg1); osPiStartDma(&gDmaIoMesg, 0, 0, (uintptr_t) &_other_texturesSegmentRomStart[SEGMENT_OFFSET(arg0)],temp_a0, arg1, &gDmaMesgQueue); osRecvMesg(&gDmaMesgQueue, &gMainReceivedMesg, 1); @@ -458,10 +458,8 @@ void func_802A86A8(CourseVtx *data, u32 arg1) { void decompress_vtx(CourseVtx *arg0, u32 vertexCount) { s32 size = ALIGN16(vertexCount * 0x18); - u32 segment = SEGMENT_NUMBER2(arg0); - u32 offset = SEGMENT_OFFSET(arg0); void *freeSpace; - u8 *vtxCompressed = VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + u8 *vtxCompressed = arg0; UNUSED s32 pad; freeSpace = (void *) gNextFreeMemoryAddress; @@ -684,7 +682,7 @@ void unpack_tile_sync(Gfx *gfx, u8 *args, s8 opcode) { lo = (G_SETTILE << 24) | (fmt << 21) | (siz << 19) | (line << 9) | tmem; hi = ((cmt) << 18) | ((maskt) << 14) | ((cms) << 8) | ((masks) << 4); - + gfx[sGfxSeekPosition].words.w0 = lo; gfx[sGfxSeekPosition].words.w1 = hi; sGfxSeekPosition++; @@ -954,16 +952,14 @@ UNUSED void func_802A9AEC(void) { * The opcodes range from 0 to 87 which are used to run the relevant unpack function. * The file pointer increments when arguments are used. This way, * displaylist_unpack will always read an opcode and not an argument by accident. - * + * * @warning opcodes that do not contain a definition in the switch are ignored. If an undefined opcode * contained arguments the unpacker might try to unpack those arguments. * This issue is prevented so long as the packed file adheres to correct opcodes and unpack code * increments the file pointer the correct number of times. */ void displaylist_unpack(uintptr_t *data, uintptr_t finalDisplaylistOffset, u32 arg2) { - uintptr_t segment = SEGMENT_NUMBER2(data); - uintptr_t offset = SEGMENT_OFFSET(data); - u8 *packed_dl = VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + u8 *packed_dl = data; Gfx *gfx; u32 addr; @@ -977,14 +973,14 @@ void displaylist_unpack(uintptr_t *data, uintptr_t finalDisplaylistOffset, u32 a sGfxSeekPosition = 0; sPackedSeekPosition = 0; - while(TRUE) { + while(true) { // Seek to the next byte opcode = packed_dl[sPackedSeekPosition++]; // Break when the eof has been reached denoted by opcode 0xFF if (opcode == 0xFF) break; - + switch (opcode) { case 0x0: unpack_lights(gfx, packed_dl, opcode); @@ -1036,7 +1032,7 @@ void displaylist_unpack(uintptr_t *data, uintptr_t finalDisplaylistOffset, u32 a break; case 0x10: unpack_lights(gfx, packed_dl, opcode); - break; + break; case 0x11: unpack_lights(gfx, packed_dl, opcode); break; @@ -1263,10 +1259,8 @@ struct UnkStr_802AA7C8 { }; void decompress_textures(u32 *arg0) { - u32 segment = SEGMENT_NUMBER2(arg0); - u32 offset = SEGMENT_OFFSET(arg0); struct UnkStr_802AA7C8 *phi_s0 = - (struct UnkStr_802AA7C8 *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + (struct UnkStr_802AA7C8 *) arg0; struct UnkStr_802AA7C8 *temp_s0; u32 temp_t2; u8 *temp_a0; @@ -1275,7 +1269,7 @@ void decompress_textures(u32 *arg0) { phi_v0 = 0; temp_s0 = phi_s0; - while (TRUE) { + while (true) { temp_a0 = phi_s0->unk0; if ((temp_a0) == 0) { break; @@ -1287,7 +1281,7 @@ void decompress_textures(u32 *arg0) { gHeapEndPtr -= phi_v0; sp20 = gHeapEndPtr; - while (TRUE) { + while (true) { temp_a0 = phi_s0->unk0; if ((temp_a0) == 0) { break; diff --git a/src/racing/race_logic.c b/src/racing/race_logic.c index 1c690e512..9b3babac4 100644 --- a/src/racing/race_logic.c +++ b/src/racing/race_logic.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -836,7 +836,7 @@ void func_8028F970(void) { return; } } - + if (gEnableDebugMode) { if (gModeSelection == BATTLE) { // do stuff? @@ -1108,7 +1108,7 @@ void func_802903B0(void) { void func_802903D8(Player *playerOne, Player *playerTwo) { f32 sp70 = (playerOne->boundingBoxSize + playerTwo->boundingBoxSize) - 5.0f; f32 temp_f0; - f32 sp74; + f32 sp74; Vec3f sp60; Vec3f sp54; f32 temp_f0_2; diff --git a/src/racing/render_courses.c b/src/racing/render_courses.c index 8bb715a79..0aef69c6b 100644 --- a/src/racing/render_courses.c +++ b/src/racing/render_courses.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -44,9 +44,7 @@ s32 func_80290C20(Camera *camera) { } void parse_course_displaylists(uintptr_t addr) { - s32 segment = SEGMENT_NUMBER2(addr); - s32 offset = SEGMENT_OFFSET(addr); - TrackSections *section = (TrackSections *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + TrackSections *section = (TrackSections *) addr; while(section->addr != 0) { if (section->flags & 0x8000) { @@ -74,10 +72,8 @@ extern u32 isFlycam; void load_surface_map(uintptr_t addr, struct UnkStruct_800DC5EC *arg1) { Player *player = arg1->player; Camera *camera = arg1->camera; - u32 segment = SEGMENT_NUMBER2(addr); - u32 offset = SEGMENT_OFFSET(addr); //! @todo Should be Gfx* - s32 *gfx = (s32 *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + Gfx* gfx = (Gfx*) addr; s16 var_a3; s16 temp_v1; s16 sp1E; @@ -125,12 +121,12 @@ void load_surface_map(uintptr_t addr, struct UnkStruct_800DC5EC *arg1) { temp_v1 = arg1->pathCounter; } else if (player->unk_110.unk3C[2] > 30.0f) { temp_v1 = arg1->pathCounter; - } else { + } else { temp_v1 = temp_v0_3; } } else if (camera->unk_54.unk3C[2] > 30.0f) { temp_v1 = arg1->pathCounter; - } else { + } else { temp_v1 = sp1E; } } else { @@ -163,7 +159,7 @@ void load_surface_map(uintptr_t addr, struct UnkStruct_800DC5EC *arg1) { temp_v1 = arg1->pathCounter; } else if (player->unk_110.unk3C[2] > 30.0f) { temp_v1 = arg1->pathCounter; - } else { + } else { temp_v1 = temp_v0_3; } break; @@ -173,14 +169,14 @@ void load_surface_map(uintptr_t addr, struct UnkStruct_800DC5EC *arg1) { temp_v1 = func_802ABD40(camera->unk_54.unk3A); if (camera->unk_54.unk3C[2] > 30.0f) { temp_v1 = arg1->pathCounter; - } else if (temp_v1 == 255) { + } else if (temp_v1 == 255) { temp_v1 = arg1->pathCounter; } } arg1->pathCounter = temp_v1; temp_v1 = ((temp_v1 - 1) * 4) + var_a3; - + gSPDisplayList(gDisplayListHead++, gfx[temp_v1]); } @@ -866,7 +862,7 @@ void render_luigi_raceway(struct UnkStruct_800DC5EC *arg0) { gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); load_surface_map((uintptr_t) luigi_raceway_dls, arg0); - + gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2); // d_course_luigi_raceway_packed_dl_E0 @@ -940,48 +936,48 @@ void render_moo_moo_farm(struct UnkStruct_800DC5EC *arg0) { if ((temp_s0 < 14) && (temp_s0 > 10)) { if ((temp_s1 == 2) || (temp_s1 == 3) || (temp_s1 == 1)) - // + // gSPDisplayList(gDisplayListHead++, d_course_moo_moo_farm_dl_13FF8); - + } else if (temp_s0 < 16) { gSPDisplayList(gDisplayListHead++, d_course_moo_moo_farm_dl_13FF8); } else if (temp_s0 < 19) { - if (temp_s1 != 2) + if (temp_s1 != 2) gSPDisplayList(gDisplayListHead++, d_course_moo_moo_farm_dl_13FF8); - + } else if (temp_s0 < 20) { - if (temp_s1 == 0) + if (temp_s1 == 0) gSPDisplayList(gDisplayListHead++, d_course_moo_moo_farm_dl_13FF8); - + } gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEI, G_CC_MODULATEI); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); if ((temp_s0 >= 16) && (temp_s0 < 24)) { - if ((temp_s1 == 2) || (temp_s1 == 3)) + if ((temp_s1 == 2) || (temp_s1 == 3)) // d_course_moo_moo_farm_packed_dl_5410 gSPDisplayList(gDisplayListHead++, ((uintptr_t)0x07005410)); - + } else if (temp_s0 < 9) { - if (temp_s1 == 2) + if (temp_s1 == 2) // d_course_moo_moo_farm_packed_dl_5410 gSPDisplayList(gDisplayListHead++, ((uintptr_t)0x07005410)); - + } if (temp_s0 < 4) { if (temp_s1 != 0) gSPDisplayList(gDisplayListHead++, d_course_moo_moo_farm_dl_14060); - + } else if (temp_s0 < 8) { if (temp_s1 == 2) gSPDisplayList(gDisplayListHead++, d_course_moo_moo_farm_dl_14060); - + } else if (temp_s0 >= 22) { gSPDisplayList(gDisplayListHead++, d_course_moo_moo_farm_dl_14060); } else if (temp_s0 >= 18) { if ((temp_s1 == 0) || (temp_s1 == 3)) gSPDisplayList(gDisplayListHead++, d_course_moo_moo_farm_dl_14060); - + } gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2); @@ -1412,7 +1408,7 @@ void func_80295D88(void) { gCourseMaxX = 0; gCourseMaxY = 0; gCourseMaxZ = 0; - + D_8015F59C = 0; D_8015F5A0 = 0; func_80295D6C(); diff --git a/src/racing/skybox_and_splitscreen.c b/src/racing/skybox_and_splitscreen.c index 0245992b0..e0cd0ac7b 100644 --- a/src/racing/skybox_and_splitscreen.c +++ b/src/racing/skybox_and_splitscreen.c @@ -1,6 +1,6 @@ -#include +#include #include -#include +#include #include #include "skybox_and_splitscreen.h" @@ -471,7 +471,7 @@ void func_802A4A0C(Vtx *vtx, struct UnkStruct_800DC5EC *arg1, UNUSED s32 arg2, U vtx[2].v.ob[1] = temp_t5; vtx[4].v.ob[1] = temp_t5; vtx[7].v.ob[1] = temp_t5; - + init_rdp(); gDPSetRenderMode(gDisplayListHead++, G_RM_OPA_SURF, G_RM_OPA_SURF2); gSPClearGeometryMode(gDisplayListHead++, G_ZBUFFER | G_LIGHTING); diff --git a/src/racing/skybox_and_splitscreen.h b/src/racing/skybox_and_splitscreen.h index 820a593bc..34d7c7456 100644 --- a/src/racing/skybox_and_splitscreen.h +++ b/src/racing/skybox_and_splitscreen.h @@ -1,7 +1,7 @@ #ifndef SKYBOX_AND_SPLITSCREEN_H #define SKYBOX_AND_SPLITSCREEN_H -#include +#include #include "code_800029B0.h" #define G_CLEAR_ALL_MODES 0xFFFFFFFF diff --git a/src/render_objects.c b/src/render_objects.c index 085d6780d..b09a77190 100644 --- a/src/render_objects.c +++ b/src/render_objects.c @@ -3,9 +3,9 @@ * A more suitable name may be print.c **/ -#include +#include #include -#include +#include #include #include #include @@ -153,7 +153,7 @@ UNUSED void func_8004398C(s32 arg0, s32 arg1, u16 arg2, f32 arg3, Vtx *vtx, s32 gSPVertex(gDisplayListHead++, vtx, 4, 0); gSPDisplayList(gDisplayListHead++, common_rectangle_display); } - + s32 func_80043A54(s32 arg0) { s32 temp_a1; s32 phi_v0; @@ -252,7 +252,7 @@ void func_80044DA0(u8 *image, s32 width, s32 height) { // This macro ought to be equivalent to the block of macros below but it doesn't match // See comment above the `gDPLoadBlock` macro // gDPLoadTextureBlock_4b(gDisplayListHead++, image, G_IM_FMT_I, width, height, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - + gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_I, G_IM_SIZ_16b, 1, image); gDPSetTile(gDisplayListHead++, G_IM_FMT_I, G_IM_SIZ_16b, 0, G_TX_RENDERTILE, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOLOD); gDPLoadSync(gDisplayListHead++); @@ -268,7 +268,7 @@ void func_80044F34(u8 *image, s32 width, s32 height) { // This macro ought to be equivalent to the block of macros below but it doesn't match // See comment above the `gDPLoadBlock` macro // gDPLoadTextureBlock_4b(gDisplayListHead++, image, G_IM_FMT_I, width, height, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - + gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_I, G_IM_SIZ_16b, 1, image); gDPSetTile(gDisplayListHead++, G_IM_FMT_I, G_IM_SIZ_16b, 0, G_TX_RENDERTILE, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOLOD); gDPLoadSync(gDisplayListHead++); @@ -831,7 +831,7 @@ void func_800485C4(Vec3f arg0, Vec3su arg1, f32 arg2, s32 arg3, u8 *tlut, u8 *te set_transparency(arg3); draw_rectangle_texture_overlap(tlut, texture, arg6, arg7, arg8, arg9, argA); - + gDPSetAlphaCompare(gDisplayListHead++, G_AC_NONE); } @@ -1683,7 +1683,7 @@ void func_8004C6FC(s16 arg0, s16 arg1, u8 *texture, u32 width, u32 arg4) { athing += var_s4 * 0; var_s4 += heigth; } - + gSPDisplayList(gDisplayListHead++, D_0D007EB8); } #else @@ -2074,7 +2074,7 @@ void func_8004DF5C(s32 arg0, s32 arg1, u8 *texture, s32 width, s32 arg4, s32 hei s32 var_s0 = var_s0 = arg1 - (arg4 / 2); u8 *img = texture; s32 i; - + for (i = 0; i < arg4 / height; i++) { rsp_load_texture(img, width, height); func_8004B97C(arg0 - (width / 2), var_s0, width, height, 1); @@ -3270,7 +3270,7 @@ void render_ice_block(s32 arg0) { for (playerId = 0; playerId < gPlayerCountSelection1; playerId++) { objectIndex = gIndexLakituList[playerId]; if (objectIndex) {} - if (func_80072320(objectIndex, 4) != FALSE) { + if (func_80072320(objectIndex, 4) != false) { func_8005285C(playerId); } func_80072320(objectIndex, 0x00000010); @@ -3633,7 +3633,7 @@ void render_object_paddle_boat_smoke_particles(s32 cameraId) { UNUSED s32 pad[2]; Camera *camera; s32 i; - + camera = &camera1[cameraId]; gSPDisplayList(gDisplayListHead++, D_0D007AE0); @@ -4420,18 +4420,18 @@ UNUSED void func_800573BC(void) { } UNUSED void func_800573C4(void) { - + } UNUSED void func_800573CC(void) { - + } UNUSED void func_800573D4(void) { - + } UNUSED void func_800573DC(void) { - + } @@ -4473,7 +4473,7 @@ void debug_print_number(s32 *x, s32 *y, s32 number, u32 numDigits) debug_wrap_text(x, y); n = -number; } - + *D_801657B8 = -1; ptr = D_801657B8; if (n != 0) { @@ -4485,7 +4485,7 @@ void debug_print_number(s32 *x, s32 *y, s32 number, u32 numDigits) } else { *++ptr = 0; } - + do { func_800573E4(*x, *y, *ptr--); debug_wrap_text(x, y); @@ -4502,7 +4502,7 @@ void func_8005762C(s32 *x, s32 *y, s32 pathCount, u32 numDigits) { s8 *ptr; s32 count; s8 remainder; - + debug_wrap_text(x, y); *D_801657B8 = -1; ptr = D_801657B8; @@ -4518,7 +4518,7 @@ void func_8005762C(s32 *x, s32 *y, s32 pathCount, u32 numDigits) { } else { *++ptr = 0; } - + do { func_800573E4(*x, *y, *ptr--); debug_wrap_text(x, y); diff --git a/src/render_player.c b/src/render_player.c index aec58a16c..e4b073343 100644 --- a/src/render_player.c +++ b/src/render_player.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -106,7 +106,7 @@ u16 check_player_camera_collision(Player *player, Camera *camera, f32 arg2, f32 s16 var_v0; u16 ret; - ret = FALSE; + ret = false; switch (gActiveScreenMode) { /* irregular */ case SCREEN_MODE_1P: var_v0 = 0x293C; @@ -135,7 +135,7 @@ u16 check_player_camera_collision(Player *player, Camera *camera, f32 arg2, f32 sp5C = ((sp44 - player->pos[2]) * (sp58 - player->pos[0])) - ((sp4C - player->pos[2]) * (sp50 - player->pos[0])); if (((sp64 >= 0) && (sp60 >= 0) && (sp5C >= 0)) || (((sp64) <= 0) && (sp60 <= 0) && (sp5C <= 0))) { - ret = TRUE; + ret = true; } return ret; } @@ -152,7 +152,7 @@ u16 func_8001FD78(Player *player, f32 posX, UNUSED f32 arg2, f32 posZ) { f32 thing1; u16 ret; - ret = FALSE; + ret = false; sp58 = (70.0f * coss(((player->unk_0C0 - player->rotation[1]) - 0x71C))) + player->pos[2]; sp64 = (70.0f * sins(((player->unk_0C0 - player->rotation[1]) - 0x71C))) + player->pos[0]; @@ -165,7 +165,7 @@ u16 func_8001FD78(Player *player, f32 posX, UNUSED f32 arg2, f32 posZ) { thing0 = ((sp54 - posZ) * (sp5c - posX)) - ((sp50 - posZ) * (sp60 - posX)); thing1 = ((sp50 - posZ) * (sp64 - posX)) - ((sp58 - posZ) * (sp5c - posX)); if (((temp_f14 >= 0) && (thing0 >= 0) && (thing1 >= 0)) || ((temp_f14 <= 0) && (thing0 <= 0) && (thing1 <= 0))) { - ret = TRUE; + ret = true; } return ret; } @@ -710,7 +710,7 @@ void mtxf_scale2(Mat4 arg0, f32 scale) { * This function writes a fixed-point value to each Mtx entry. This is not how the Mtx struct works. * The first half of Mtx only holds s16 whole numbers and the second half holds the s16 decimal (fractional) parts. * See convert_to_fixed_point_matrix() for correct calculations. Note that each Mtx entry is the size of s32. - * This means each Mtx entry holds two s16 values. + * This means each Mtx entry holds two s16 values. * The first sixteen entries contain only the integer parts and the second sixteen entries hold only the decimal (fractional) parts. */ UNUSED void failed_fixed_point_matrix_conversion(Mtx *dest, Mat4 src) { @@ -793,9 +793,9 @@ bool adjust_angle(s16 *angle, s16 targetAngle, s16 step) { } } if (targetAngle == *angle) { - return FALSE; + return false; } - return TRUE; + return true; } void move_s32_towards(s32 *startingValue, s32 targetValue, f32 somePercent) { @@ -1063,12 +1063,12 @@ bool is_player_under_light_luigi_raceway(Player *player, s8 arg1) { change_player_color_effect_rgb(player, arg1, COLOR_LIGHT, 0.3f); change_player_color_effect_cmy(player, arg1, 0xE0, 0.3f); D_80164B80[arg1] = 0; - return TRUE; + return true; } - return FALSE; + return false; default: - return FALSE; + return false; } } @@ -1214,7 +1214,7 @@ void func_800235AC(Player *player, s8 arg1) { return; } } - if (is_player_under_light_luigi_raceway(player, arg1) != TRUE) { + if (is_player_under_light_luigi_raceway(player, arg1) != true) { if (((player->boundingBoxCorners[3].unk_14 & 1) == 1) || ((player->boundingBoxCorners[3].unk_14 & 2) == 2) || ((player->boundingBoxCorners[0].unk_14 & 3) == 3)) { @@ -1296,7 +1296,7 @@ void render_player_shadow(Player *player, s8 arg1, s8 arg2) { convert_to_fixed_point_matrix(&gGfxPool->mtxShadow[arg1 + (arg2 * 8)], sp118); gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxShadow[arg1 + (arg2 * 8)]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - + gSPDisplayList(gDisplayListHead++, D_0D008D58); gDPSetTextureLUT(gDisplayListHead++, G_TT_NONE); gDPLoadTextureBlock(gDisplayListHead++, D_8018D474, G_IM_FMT_I, G_IM_SIZ_8b, 64, 32, 0, G_TX_NOMIRROR @@ -1304,14 +1304,14 @@ void render_player_shadow(Player *player, s8 arg1, s8 arg2) { func_8004B414(0, 0, 0, 0xFF); gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_CLD_SURF, G_RM_ZB_CLD_SURF2); gSPVertex(gDisplayListHead++, &D_800E51D0[0], 4, 0); - + gSPDisplayList(gDisplayListHead++, common_square_plain_render); gDPLoadTextureBlock(gDisplayListHead++, (D_8018D474 + SOME_TEXTURE_POINTER_MATH), G_IM_FMT_I, G_IM_SIZ_8b, 64, 32, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); func_8004B414(0, 0, 0, 0xFF); gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_CLD_SURF, G_RM_ZB_CLD_SURF2); gSPVertex(gDisplayListHead++, &D_800E5210[0], 4, 0); - + gSPDisplayList(gDisplayListHead++, common_square_plain_render); gSPTexture(gDisplayListHead++, 1, 1, 0, G_TX_RENDERTILE, G_OFF); } @@ -1346,9 +1346,9 @@ void render_player_shadow_credits(Player *player, s8 playerId, s8 arg2) { mtxf_translate_rotate(sp118, spCC, spC4); mtxf_scale2(sp118, gCharacterSize[player->characterId] * player->size); convert_to_fixed_point_matrix(&gGfxPool->mtxShadow[playerId + (arg2 * 8)], sp118); - + gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxShadow[playerId + (arg2 * 8)]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - + gSPDisplayList(gDisplayListHead++, D_0D008D58); gDPSetTextureLUT(gDisplayListHead++, G_TT_NONE); gDPLoadTextureBlock(gDisplayListHead++, D_8018D474, G_IM_FMT_I, G_IM_SIZ_8b, 64, 32, 0, @@ -1356,14 +1356,14 @@ void render_player_shadow_credits(Player *player, s8 playerId, s8 arg2) { func_8004B414(0, 0, 0, 0x000000D0); gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_CLD_SURF, G_RM_ZB_CLD_SURF2); gSPVertex(gDisplayListHead++, &D_800E51D0[0], 4, 0); - + gSPDisplayList(gDisplayListHead++, common_square_plain_render); gDPLoadTextureBlock(gDisplayListHead++, (D_8018D474 + SOME_TEXTURE_POINTER_MATH), G_IM_FMT_I, G_IM_SIZ_8b, 64, 32, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); func_8004B414(0, 0, 0, 0x000000D0); gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_CLD_SURF, G_RM_ZB_CLD_SURF2); gSPVertex(gDisplayListHead++, &D_800E5210[0], 4, 0); - + gSPDisplayList(gDisplayListHead++, common_square_plain_render); gSPTexture(gDisplayListHead++, 1, 1, 0, G_TX_RENDERTILE, G_OFF); } @@ -1705,7 +1705,7 @@ void func_80026A48(Player *player, s8 arg1) { } temp_f0 = ((player->unk_094 * (1.0f + player->unk_104)) / 18.0f) * 216.0f; - if ((temp_f0 <= 1.0f) || (gIsPlayerTripleBButtonCombo[arg1] == TRUE)) { + if ((temp_f0 <= 1.0f) || (gIsPlayerTripleBButtonCombo[arg1] == true)) { player->unk_240 = 0; } else { player->unk_240 += D_800DDE74[(s32)(temp_f0 / 12.0f)]; diff --git a/src/save.c b/src/save.c index 664a0faf8..260b314e0 100644 --- a/src/save.c +++ b/src/save.c @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -144,7 +144,7 @@ void load_save_data(void) { for (i = 0; i < 16; i++) { func_800B4A9C(i); } - + validate_save_data(); gSoundMode = gSaveData.main.soundMode; @@ -165,7 +165,7 @@ void func_800B4A9C(s32 course) { .unknownBytes[0] = 1; } sp24 = &gSaveData.allCourseTimeTrialRecords.cupRecords[course / 4].courseRecords[course % 4]; - + func_800B4FB0(course); if(sp24) {} @@ -209,7 +209,7 @@ void validate_save_data(void) { Stuff *backup = &gSaveData.backup; if (main->checksum[1] != (compute_save_data_checksum_1()) || (main->checksum[2] != compute_save_data_checksum_2())) { reset_save_data_grand_prix_points_and_sound_mode(); - + if (validate_save_data_checksum_backup() == 0) { for (cup_index = 0; cup_index < 4; cup_index++) { main->grandPrixPoints[cup_index] = backup->grandPrixPoints[cup_index]; @@ -385,7 +385,7 @@ void func_800B536C(s32 arg0) { if (arg0 >= 0) { points = &gSaveData.main.grandPrixPoints[gCCSelection]; - + tmp = func_800B54EC(gCupSelection, *points); tmp2 = 3 - arg0; if ((arg0 < 3) && (tmp < (3-arg0))) { @@ -411,7 +411,7 @@ void func_800B5404(s32 arg0, s32 arg1) if ((arg0 < 3) && (temp < (temp_a0 = 3 - arg0))) { *points = func_800B5508(temp2, *points, temp_a0); - + write_save_data_grand_prix_points_and_sound_mode(); update_save_data_backup(); } @@ -499,7 +499,7 @@ void func_800B559C(s32 arg0) { * odd. It calculates a checksum for 51 bytes in 17 byte chunks, but that doesn't line * up with anything in the save data cleanly. At that byte count it would get the 48 bytes * for the records plus 3 of the unknown bytes. -* +* * But only unknown bytes 7 and 8 ever get set, so why the extra 3, and why in chunks of 17? **/ s32 func_800B578C(s32 arg0) { @@ -595,7 +595,7 @@ s32 check_for_controller_pak(s32 controller) { } osPfsIsPlug(&gSIEventMesgQueue, &controllerBitpattern); - + if ((controllerBitpattern & (1 << controller)) != 0) { return PAK; } @@ -618,8 +618,8 @@ s32 controller_pak_1_status(void) { gControllerPak1State = BAD; break; } - } - + } + if (!gControllerPak1State) { s32 errorCode; if (check_for_controller_pak(CONTROLLER_1) == NO_PAK) { @@ -639,7 +639,7 @@ s32 controller_pak_1_status(void) { return PFS_PAK_BAD_READ; } } - + gControllerPak1State = OK; if (osPfsFindFile(&gControllerPak1FileHandle, gCompanyCode, gGameCode, (u8 *) gGameName, (u8 *) gExtCode, &gControllerPak1FileNote) == PFS_NO_ERROR) { return PFS_NO_ERROR; @@ -663,13 +663,13 @@ s32 controller_pak_1_status(void) { } // gives status info about controller pak insterted in controller 2 -s32 controller_pak_2_status(void) { +s32 controller_pak_2_status(void) { s32 stateBorrow = sControllerPak2State; - + if (stateBorrow) { switch (osPfsFindFile(&gControllerPak2FileHandle, gCompanyCode, gGameCode, (u8 *) gGameName, (u8 *) gExtCode, &gControllerPak2FileNote)) { case PFS_NO_ERROR: - return PFS_NO_ERROR; + return PFS_NO_ERROR; case PFS_ERR_INVALID: return PFS_INVALID_DATA; default: @@ -683,7 +683,7 @@ s32 controller_pak_2_status(void) { if (check_for_controller_pak(CONTROLLER_2) == NO_PAK) { return PFS_NO_PAK_INSERTED; } - + errorCode = osPfsInit(&gSIEventMesgQueue, &gControllerPak2FileHandle, CONTROLLER_2); if (errorCode) { switch (errorCode) { @@ -699,7 +699,7 @@ s32 controller_pak_2_status(void) { } sControllerPak2State = OK; - + switch (osPfsFindFile(&gControllerPak2FileHandle, gCompanyCode, gGameCode, (u8 *) gGameName, (u8 *) gExtCode, &gControllerPak2FileNote)) { case PFS_NO_ERROR: return PFS_NO_ERROR; @@ -765,7 +765,7 @@ u8 func_800B60E8(s32 page) { s32 i; u32 checksum = 0; u8 *addr; - + for (i = 0, addr = (u8*) &((u8*)D_800DC714)[page * 256]; i < 256; i++) { checksum += (*addr++ * (page + 1) + i); } @@ -847,7 +847,7 @@ s32 func_800B63F0(s32 arg0) { func_800051C4(); D_80162DD6 = 1; func_80005AE8(gPlayerThree); - + phi_s3 = 0; if (((gCupSelection * 4) + gCupCourseSelection) != D_8018EE10[arg0].courseIndex) { phi_s3 = 2; @@ -859,14 +859,14 @@ s32 func_800B63F0(s32 arg0) { } else { temp_s0 = 0; phi_s1 = (u8*) &D_8018EE10[arg0]; - + while (temp_s0 < 0x3C) { if (phi_s1[7] != func_800B60E8(temp_s0)) { phi_s3 = 1; break; } - + ++phi_s1; ++temp_s0; } @@ -943,7 +943,7 @@ void func_800B6708(void) { s32 temp_s0; osPfsReadWriteFile(&gControllerPak1FileHandle, gControllerPak1FileNote, PFS_READ, 0, 0x100 /* 2*sizeof(struct_8018EE10_entry) ? */, (u8*) &D_8018EE10); - + for (temp_s0 = 0; temp_s0 < 2; ++temp_s0) { if (D_8018EE10[temp_s0].checksum != func_800B6828(temp_s0)) { D_8018EE10[temp_s0].ghostDataSaved = 0; @@ -954,7 +954,7 @@ void func_800B6708(void) { void func_800B6798(void) { s32 temp_s0; u8* tmp; - + tmp = (u8*) D_8018D9C0; osPfsReadWriteFile(&gControllerPak2FileHandle, gControllerPak2FileNote, PFS_READ, 0, 0x100 /* 2*sizeof(struct_8018EE10_entry) ? */, tmp); @@ -999,14 +999,14 @@ s32 func_800B69BC(s32 arg0) { s32 i; struct_8018EE10_entry *plz = &D_8018EE10[arg0]; - plz->ghostDataSaved = FALSE; + plz->ghostDataSaved = false; plz->courseIndex = 0; plz->characterId = 0; for (i = 0; i < sizeof(plz->unk_07); i++) { plz->unk_07[i] = i; } plz->checksum = func_800B6828(arg0); - + return osPfsReadWriteFile(&gControllerPak1FileHandle, gControllerPak1FileNote, PFS_WRITE, (s32) sizeof(struct_8018EE10_entry) * arg0, sizeof(struct_8018EE10_entry), (u8 *)plz); } diff --git a/src/save.h b/src/save.h index 81c93d340..aadba2660 100644 --- a/src/save.h +++ b/src/save.h @@ -1,7 +1,7 @@ #ifndef SAVE_H #define SAVE_H -#include "PR/os.h" +#include #include "common_structs.h" /* define symbols */ diff --git a/src/spawn_players.c b/src/spawn_players.c index 427975e50..0206569bf 100644 --- a/src/spawn_players.c +++ b/src/spawn_players.c @@ -269,11 +269,11 @@ void spawn_player(Player *player, s8 playerIndex, f32 startingRow, f32 startingC gFrameSinceLastACombo[idx] = 0; gCountASwitch[idx] = 0; - gIsPlayerTripleAButtonCombo[idx] = FALSE; + gIsPlayerTripleAButtonCombo[idx] = false; gTimerBoostTripleACombo[idx] = 0; gFrameSinceLastBCombo[idx] = 0; gCountBChangement[idx] = 0; - gIsPlayerTripleBButtonCombo[idx] = FALSE; + gIsPlayerTripleBButtonCombo[idx] = false; gTimerBoostTripleBCombo[playerIndex] = 0; D_8018D900[0] = 0; @@ -456,7 +456,7 @@ void func_80039AE4(void) { void func_80039DA4(void) { s32 i; - + s32 sp2C[] = { 7, 6, 5, 4, 3, 2, 1, 0, diff --git a/src/staff_ghosts.c b/src/staff_ghosts.c index 97142e717..6b75e232f 100644 --- a/src/staff_ghosts.c +++ b/src/staff_ghosts.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -412,8 +412,8 @@ void func_8000599C(void) { u32 temp_t0; u32 temp_a0_2; - if (((D_80162DB8 >= 0x1000) || - ((gPlayerOne->unk_0CA & 2) != 0)) || + if (((D_80162DB8 >= 0x1000) || + ((gPlayerOne->unk_0CA & 2) != 0)) || ((gPlayerOne->unk_0CA & 8) != 0)) { D_80162DF8 = 1; return; @@ -458,7 +458,7 @@ void func_8000599C(void) { temp_t0 += 0x10000; D_80162DBC[D_80162DB8] = temp_t0; - + } } else { D_80162DB8++; D_80162DBC[D_80162DB8] = phi_a3; diff --git a/src/staff_ghosts.h b/src/staff_ghosts.h index 5444caa8b..b02de2412 100644 --- a/src/staff_ghosts.h +++ b/src/staff_ghosts.h @@ -1,7 +1,7 @@ #ifndef STAFF_GHOSTS_H #define STAFF_GHOSTS_H -#include "PR/os.h" +#include #include "common_structs.h" void func_80005B18(void); diff --git a/src/textures.h b/src/textures.h index 079c8703e..5a631cf58 100644 --- a/src/textures.h +++ b/src/textures.h @@ -1,7 +1,7 @@ #ifndef TEXTURES_H #define TEXTURES_H -#include "PR/ultratypes.h" +#include /** * @brief struct for a texture use in menu mainly diff --git a/src/update_objects.c b/src/update_objects.c index 09996421b..281b611e7 100644 --- a/src/update_objects.c +++ b/src/update_objects.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -37,7 +37,7 @@ #include "memory.h" //! @todo unused? -f32 D_800E43B0[] = { +f32 D_800E43B0[] = { 65536.0, 0.0, 1.0, 0.0, 0.0, 65536.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, @@ -211,9 +211,9 @@ UNUSED void func_80072214(s32 objectIndex, s32 arg1) { } bool is_obj_flag_status_active(s32 objectIndex, s32 arg1) { - s32 phi_v1 = FALSE; + s32 phi_v1 = false; if ((gObjectList[objectIndex].status & arg1) != 0) { - phi_v1 = TRUE; + phi_v1 = true; } return phi_v1; } @@ -239,17 +239,17 @@ UNUSED void func_800722F8(s32 objectIndex, s32 arg1) { } bool func_80072320(s32 objectIndex, s32 arg1) { - s32 b = FALSE; + s32 b = false; if ((gObjectList[objectIndex].unk_058 & arg1) != 0) { - b = TRUE; + b = true; } return b; } bool func_80072354(s32 objectIndex, s32 arg1) { - s32 b = FALSE; + s32 b = false; if ((gObjectList[objectIndex].unk_058 & arg1) == 0) { - b = TRUE; + b = true; } return b; } @@ -363,7 +363,7 @@ s32 func_8007278C(s32 objectIndex, s32 arg1) { func_80072488(objectIndex); phi_v1 = 1; } - + return phi_v1; } @@ -382,7 +382,7 @@ UNUSED s32 func_8007281C(s32 objectIndex, s32 arg1) { func_80072488(objectIndex); phi_a2 = 1; } - + return phi_a2; } @@ -401,7 +401,7 @@ UNUSED s32 func_800728B0(s32 objectIndex, s32 arg1, s32 arg2) { func_80072488(objectIndex); phi_a3 = 1; } - + return phi_a3; } @@ -430,7 +430,7 @@ void set_type_object(s32 objectIndex, s32 arg1) { } void func_800729EC(s32 objectIndex) { - u32 temp_v1 = 1; + u32 temp_v1 = 1; s32 i; start_race(); @@ -547,7 +547,7 @@ void func_80072D3C(s32 objectIndex, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { } else { gObjectList[objectIndex].itemDisplay = arg2; } - + if (gObjectList[objectIndex].unk_0D4 < 0) { gObjectList[objectIndex].unk_0D4 = 1; if (gObjectList[objectIndex].unk_0CC > 0) { @@ -600,7 +600,7 @@ s32 func_80072E54(s32 objectIndex, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 a bool func_80072F88(s32 objectIndex, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5) { s32 sp24; - sp24 = FALSE; + sp24 = false; if (is_obj_index_flag_status_inactive(objectIndex, 0x2000) != 0) { gObjectList[objectIndex].itemDisplay = arg1; gObjectList[objectIndex].unk_050 = arg4; @@ -621,7 +621,7 @@ bool func_80072F88(s32 objectIndex, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 set_object_flag_status_false(objectIndex, 0x2000); set_object_unk_0CB(objectIndex, 0); func_80072488(objectIndex); - sp24 = TRUE; + sp24 = true; } else { gObjectList[objectIndex].itemDisplay = arg1; } @@ -634,7 +634,7 @@ bool func_80072F88(s32 objectIndex, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 bool func_800730BC(s32 objectIndex, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5) { s32 sp24; - sp24 = FALSE; + sp24 = false; if (is_obj_index_flag_status_inactive(objectIndex ,0x2000) != 0) { gObjectList[objectIndex].itemDisplay = arg1; gObjectList[objectIndex].unk_050 = arg4; @@ -665,7 +665,7 @@ bool func_800730BC(s32 objectIndex, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 set_object_flag_status_false(objectIndex, 0x2000); set_object_unk_0CB(objectIndex, 0); func_80072488(objectIndex); - sp24 = TRUE; + sp24 = true; } else { set_object_flag_status_false(objectIndex, 0x4000); set_object_flag_status_true(objectIndex, 0x80); @@ -775,7 +775,7 @@ UNUSED void func_80073570(s32 objectIndex) { D_8018D1EC = 0; } (*test)++; -} +} void func_800735BC(s32 objectIndex, Gfx *arg1, f32 arg2) { gObjectList[objectIndex].status = 0; @@ -814,7 +814,7 @@ void func_80073720(s32 objectIndex) { bool func_8007375C(s32 objectIndex, s32 arg1) { s32 sp24; - sp24 = FALSE; + sp24 = false; if (is_obj_index_flag_status_inactive(objectIndex, 0x00008000) != 0) { gObjectList[objectIndex].unk_04C = arg1; set_object_flag_status_true(objectIndex, 0x00008000); @@ -823,7 +823,7 @@ bool func_8007375C(s32 objectIndex, s32 arg1) { if (gObjectList[objectIndex].unk_04C < 0) { set_object_flag_status_false(objectIndex, 0x00008000); func_80073654(objectIndex); - sp24 = TRUE; + sp24 = true; } return sp24; } @@ -893,7 +893,7 @@ UNUSED void func_800739CC(s32 arg0, s16* arg1, s32 arg2, s32 arg3, s32 arg4, s32 bool func_80073A10(s32 objectIndex, s16* arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6) { bool phi_t0; - phi_t0 = FALSE; + phi_t0 = false; if (gObjectList[objectIndex].unk_0CF == 0) { *arg1 = arg2; gObjectList[objectIndex].unk_0AC = arg5; @@ -913,7 +913,7 @@ bool func_80073A10(s32 objectIndex, s16* arg1, s32 arg2, s32 arg3, s32 arg4, s32 *arg1 = arg3; func_80073800(objectIndex, 0); func_8007381C(objectIndex); - phi_t0 = TRUE; + phi_t0 = true; } else { *arg1 = arg2; } @@ -937,7 +937,7 @@ s32 func_80073B34(s32 arg0, s16* arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s bool func_80073B78(s32 arg0, s32 objectIndex, s16* arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7) { s32 phi_t0; - phi_t0 = FALSE; + phi_t0 = false; if (gObjectList[objectIndex].unk_0CF == 0) { gObjectList[objectIndex].unk_0AC = arg6; if (arg0 != 0) { @@ -965,7 +965,7 @@ bool func_80073B78(s32 arg0, s32 objectIndex, s16* arg2, s32 arg3, s32 arg4, s32 if (gObjectList[objectIndex].unk_0D0 == 0) { func_80073800(objectIndex, 0); func_8007381C(objectIndex); - phi_t0 = TRUE; + phi_t0 = true; } else { gObjectList[objectIndex].unk_0CF = 1; } @@ -1007,7 +1007,7 @@ bool func_80073E18(s32 objectIndex, u16* arg1, u16 arg2, s32 arg3) { bool phi_t0; s32 temp_v1; - phi_t0 = FALSE; + phi_t0 = false; if (gObjectList[objectIndex].unk_0CF == 0) { func_80073800(objectIndex, 1); gObjectList[objectIndex].unk_048 = arg3; @@ -1017,12 +1017,12 @@ bool func_80073E18(s32 objectIndex, u16* arg1, u16 arg2, s32 arg3) { if (temp_v1 <= 0) { *arg1 += gObjectList[objectIndex].unk_048; func_80073800(objectIndex, 0); - phi_t0 = TRUE; + phi_t0 = true; } else { *arg1 += arg2; gObjectList[objectIndex].unk_048 = temp_v1; } - + return phi_t0; } @@ -1030,7 +1030,7 @@ UNUSED bool func_80073ED4(s32 objectIndex, u16* arg1, u16 arg2, s32 arg3) { bool phi_t0; s32 temp_v1; - phi_t0 = FALSE; + phi_t0 = false; if (gObjectList[objectIndex].unk_0CF == 0) { func_80073800(objectIndex, 1); gObjectList[objectIndex].unk_048 = arg3; @@ -1040,7 +1040,7 @@ UNUSED bool func_80073ED4(s32 objectIndex, u16* arg1, u16 arg2, s32 arg3) { if (temp_v1 <= 0) { *arg1 += gObjectList[objectIndex].unk_048; func_80073800(objectIndex, 0); - phi_t0 = TRUE; + phi_t0 = true; } else { *arg1 -= arg2; gObjectList[objectIndex].unk_048 = temp_v1; @@ -1068,7 +1068,7 @@ UNUSED void func_80074014(void) { bool func_8007401C(s32 objectIndex, f32* arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5, s32 arg6) { bool phi_a3; - phi_a3 = FALSE; + phi_a3 = false; if (gObjectList[objectIndex].unk_0CD == 0) { *arg1 = arg2; gObjectList[objectIndex].unk_0AA = arg5; @@ -1087,14 +1087,14 @@ bool func_8007401C(s32 objectIndex, f32* arg1, f32 arg2, f32 arg3, f32 arg4, s32 *arg1 = arg3; func_80073F90(objectIndex, 0); func_80073FAC(objectIndex); - phi_a3 = TRUE; + phi_a3 = true; } else { *arg1 = arg2; } } } } - + return phi_a3; } @@ -1133,7 +1133,7 @@ s32 func_800741B4(s32 objectIndex, f32* arg1, f32 arg2, f32 arg3, f32 arg4, s32 } } } - + return 0; } @@ -1224,7 +1224,7 @@ void func_800745C8(s32 objectIndex, s32 arg1) { if ((gObjectList[objectIndex].status & 2) != 0) { phi_a1 = 1; } - + gObjectList[objectIndex].activeTexture = (u8 *) (gObjectList[objectIndex].textureWidth * gObjectList[objectIndex].textureHeight * phi_a1) + arg1; func_800744A0(objectIndex); } @@ -1248,7 +1248,7 @@ void func_8007466C(s32 objectIndex, s32 arg1) { void func_80074704(s32 objectIndex, s32 arg1) { s32 phi_a1; - + if ((gObjectList[objectIndex].status & 1) != 0) { gObjectList[objectIndex].activeTLUT = gObjectList[objectIndex].tlutList; gObjectList[objectIndex].status ^= 2; @@ -1581,7 +1581,7 @@ void func_80075714(s32 objectIndex) { case 0: break; } - + object_calculate_new_pos_offset(objectIndex); } @@ -1664,7 +1664,7 @@ s32 func_80075A6C(s32 arg0, Vec3f arg1, f32 arg2) { func_800759EC(objectIndex, arg1, arg2); } } - + return objectIndex; } @@ -3567,7 +3567,7 @@ void func_8007AA44(s32 playerId) { void func_8007ABFC(s32 playerId, bool arg1) { s32 itemWindow; - if (playerHUD[playerId].raceCompleteBool == FALSE) { + if (playerHUD[playerId].raceCompleteBool == false) { itemWindow = gItemWindowObjectByPlayerId[playerId]; if (func_80072354(itemWindow, 4) != 0) { init_object(itemWindow, 0); @@ -3648,11 +3648,11 @@ u8 gen_random_item(s16 rank, s16 isCpu) } u8 gen_random_item_human(UNUSED s16 arg0, s16 rank) { - return gen_random_item(rank, FALSE); + return gen_random_item(rank, false); } u8 kart_ai_gen_random_item(UNUSED s32 arg0, s16 rank) { - return gen_random_item(rank, TRUE); + return gen_random_item(rank, true); } s16 func_8007AFB0(s32 objectIndex, s32 arg1) { @@ -3660,7 +3660,7 @@ s16 func_8007AFB0(s32 objectIndex, s32 arg1) { s16 randomItem; randomItem = gen_random_item_human(gLapCountByPlayerId[arg1], gGPCurrentRaceRankByPlayerId[arg1]); - + if (playerHUD[arg1].itemOverride != 0) { randomItem = (s16) playerHUD[arg1].itemOverride; playerHUD[arg1].itemOverride = 0; @@ -5858,7 +5858,7 @@ void func_80080A4C(s32 objectIndex, s32 cameraPlayerId) { Player *player = &gPlayerOne[cameraPlayerId]; if (gScreenModeSelection != SCREEN_MODE_3P_4P_SPLITSCREEN) { - if ((func_80072320(objectIndex, 0x00000010) != 0) && (is_within_horizontal_distance_of_player(objectIndex, player, 500.0f) != FALSE)) { + if ((func_80072320(objectIndex, 0x00000010) != 0) && (is_within_horizontal_distance_of_player(objectIndex, player, 500.0f) != false)) { func_8001CA10(camera); func_800C98B8(gObjectList[objectIndex].pos, gObjectList[objectIndex].velocity, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x0F)); } @@ -6114,7 +6114,7 @@ void func_8008153C(s32 objectIndex) { } void func_80081790(s32 objectIndex) { - switch (gObjectList[objectIndex].state) { + switch (gObjectList[objectIndex].state) { case 0: break; /* irregular */ case 1: diff --git a/tools/linkonly_generator.py b/tools/linkonly_generator.py index 163051b17..fe2aa073b 100644 --- a/tools/linkonly_generator.py +++ b/tools/linkonly_generator.py @@ -324,7 +324,7 @@ with open(f"courses/{course_name}/course_offsets.c", "r") as offsets: h_string += "#ifndef COURSE_TEXTURES_H" h_string += "\n#define COURSE_TEXTURES_H" - h_string += "\n\n#include " + h_string += "\n\n#include " c_string += f"#include \"courses/{course_name}/course_textures.linkonly.h\"" @@ -348,7 +348,7 @@ with open(f"courses/{course_name}/course_offsets.c", "r") as offsets: else: texture_include_dir = "textures/standalone" texture_filename = f"{texture_map[texture_name][0]}.{texture_map[texture_name][1]}.inc.c" - + unique_texture_name = re.sub("gTexture", f"g{abbreviations[course_name]}Texture", texture_name) c_string += f"\n\n/* 0x050{current_offset:05X} */" diff --git a/yamls/us/ceremony_data.yml b/yamls/us/ceremony_data.yml index bc68825e6..2a5d84265 100644 --- a/yamls/us/ceremony_data.yml +++ b/yamls/us/ceremony_data.yml @@ -1,11 +1,11 @@ :config: segments: - [0x0B, 0x821D10] - header: + header: code: - '#include ' header: - - '#include ' + - '#include ' - '#include ' - '#include ' diff --git a/yamls/us/ceremony_rsp_init_80284EE0.yml b/yamls/us/ceremony_rsp_init_80284EE0.yml index c316b45ca..515d5aa51 100644 --- a/yamls/us/ceremony_rsp_init_80284EE0.yml +++ b/yamls/us/ceremony_rsp_init_80284EE0.yml @@ -4,9 +4,9 @@ offset: 0x128520 header: code: - - '#include ' + - '#include ' - '#include ' - - '#include ' + - '#include ' - '#include "courses/royal_raceway/course_displaylists.inc.h"' D_80284EE0: symbol: D_80284EE0 diff --git a/yamls/us/common_data.yml b/yamls/us/common_data.yml index 0b0c8a56a..29d573d84 100644 --- a/yamls/us/common_data.yml +++ b/yamls/us/common_data.yml @@ -7,8 +7,8 @@ - '#include ' - '#include ' header: - - '#include ' - - '#include ' + - '#include ' + - '#include ' - '#include ' tables: common_grand_prix_human_item_curve: @@ -225,7 +225,7 @@ itemBoxQuestionMarkModel: symbol: itemBoxQuestionMarkModel type: gfx offset: 0x3008 - + D_0D003090: symbol: D_0D003090 type: gfx diff --git a/yamls/us/data_800E45C0.yml b/yamls/us/data_800E45C0.yml index 09432db1f..a96827b03 100644 --- a/yamls/us/data_800E45C0.yml +++ b/yamls/us/data_800E45C0.yml @@ -6,7 +6,7 @@ code: - '#include ' header: - - '#include ' + - '#include ' - '#include ' tables: D_800E45C0: diff --git a/yamls/us/data_800E8700.yml b/yamls/us/data_800E8700.yml index dad1283c4..d26c28c28 100644 --- a/yamls/us/data_800E8700.yml +++ b/yamls/us/data_800E8700.yml @@ -2,12 +2,12 @@ vram: addr: 0x800E8700 offset: 0xE9300 - header: + header: code: - - '#include ' + - '#include ' - '#include ' header: - - '#include ' + - '#include ' tables: D_800E8900: range: [0x800E8900, 0x800E89C0] diff --git a/yamls/us/data_segment2.yml b/yamls/us/data_segment2.yml index b4f76de73..117ad7297 100644 --- a/yamls/us/data_segment2.yml +++ b/yamls/us/data_segment2.yml @@ -2,17 +2,17 @@ segments: - [0x02, 0x12AAE0] - [0x0D, 0x132B50] - header: + header: code: - '#include ' - - '#include ' + - '#include ' - '#include ' - - '#include ' - - '#include ' + - '#include ' + - '#include ' - '#include "data_segment2.h"' - '#include ' header: - - '#include ' + - '#include ' # D_02007650: # symbol: D_02007650 # type: gfx diff --git a/yamls/us/startup_logo.yml b/yamls/us/startup_logo.yml index 52483c382..f4efc94c7 100644 --- a/yamls/us/startup_logo.yml +++ b/yamls/us/startup_logo.yml @@ -1,11 +1,11 @@ :config: segments: - [0x06, 0x825800] - header: + header: code: - '#include ' header: - - '#include ' + - '#include ' - '#include ' dl1: