From 78bfce70539862629c7a3262b26c815cbc62de99 Mon Sep 17 00:00:00 2001 From: Ethan Roseman Date: Fri, 17 Jul 2020 20:47:33 -0400 Subject: [PATCH] headers, some decomp --- .gitignore | 1 + papermario/Makefile | 3 +- .../code_fe0b0_len_5a0/DemoJoystickRadial.s | 51 +++++ .../asm/code_fe0b0_len_5a0/DemoJoystickXY.s | 39 ++++ .../SetSpriteShading.s} | 179 +----------------- papermario/include/common.h | 9 + papermario/include/common_structs.h | 20 ++ papermario/include/functions.h | 12 ++ papermario/include/variables.h | 10 + papermario/papermario.ld | 2 +- papermario/src/code_fe0b0_len_5a0.c | 75 ++++++++ papermario/undefined_syms.txt | 3 + 12 files changed, 224 insertions(+), 180 deletions(-) create mode 100644 papermario/asm/code_fe0b0_len_5a0/DemoJoystickRadial.s create mode 100644 papermario/asm/code_fe0b0_len_5a0/DemoJoystickXY.s rename papermario/asm/{code_fe0b0_len_5a0.s => code_fe0b0_len_5a0/SetSpriteShading.s} (57%) create mode 100644 papermario/include/common.h create mode 100644 papermario/include/common_structs.h create mode 100644 papermario/include/functions.h create mode 100644 papermario/include/variables.h create mode 100644 papermario/src/code_fe0b0_len_5a0.c diff --git a/.gitignore b/.gitignore index ec2ddf58aa..1db10a2ab0 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ papermario/bgm papermario/bin papermario/build/ papermario/yay0 +papermario/expected .vscode/ .idea/ .DS_Store diff --git a/papermario/Makefile b/papermario/Makefile index 674d9aea4f..07b1fc6f60 100644 --- a/papermario/Makefile +++ b/papermario/Makefile @@ -47,6 +47,7 @@ LD = $(CROSS_IRIX)ld OBJDUMP = $(CROSS)objdump OBJCOPY = $(CROSS)objcopy +CPPFLAGS = -Iinclude -D _LANGUAGE_C ASFLAGS = -EB -march=vr4300 -mtune=vr4300 CFLAGS = -O2 -quiet -G 0 LDFLAGS = -T undefined_syms.txt -T $(LD_SCRIPT) -Map $(BUILD_DIR)/papermario.map --no-check-sections @@ -78,7 +79,7 @@ $(BUILD_DIR)/%.o: %.s $(AS) $(ASFLAGS) -o $@ $< $(BUILD_DIR)/%.o: %.c - cpp $< | $(CC) $(CFLAGS) -o - | $(OLD_AS) - -o $@ + cpp $(CPPFLAGS) $< | $(CC) $(CFLAGS) -o - | $(OLD_AS) - -o $@ $(BUILD_DIR)/%.o: %.bin $(LD) -r -b binary -o $@ $< diff --git a/papermario/asm/code_fe0b0_len_5a0/DemoJoystickRadial.s b/papermario/asm/code_fe0b0_len_5a0/DemoJoystickRadial.s new file mode 100644 index 0000000000..a5be36174b --- /dev/null +++ b/papermario/asm/code_fe0b0_len_5a0/DemoJoystickRadial.s @@ -0,0 +1,51 @@ +.set noat # allow manual use of $at +.set noreorder # don't insert nops after branches + +.include "globals.inc" + +DemoJoystickRadial: +/* 0FE514 802D9B64 27BDFFD0 */ addiu $sp, $sp, -0x30 +/* 0FE518 802D9B68 AFB10014 */ sw $s1, 0x14($sp) +/* 0FE51C 802D9B6C 0080882D */ daddu $s1, $a0, $zero +/* 0FE520 802D9B70 AFBF0018 */ sw $ra, 0x18($sp) +/* 0FE524 802D9B74 AFB00010 */ sw $s0, 0x10($sp) +/* 0FE528 802D9B78 F7B60028 */ sdc1 $f22, 0x28($sp) +/* 0FE52C 802D9B7C F7B40020 */ sdc1 $f20, 0x20($sp) +/* 0FE530 802D9B80 8E30000C */ lw $s0, 0xc($s1) +/* 0FE534 802D9B84 8E050000 */ lw $a1, ($s0) +/* 0FE538 802D9B88 0C0B210B */ jal get_float_variable +/* 0FE53C 802D9B8C 26100004 */ addiu $s0, $s0, 4 +/* 0FE540 802D9B90 0220202D */ daddu $a0, $s1, $zero +/* 0FE544 802D9B94 8E050000 */ lw $a1, ($s0) +/* 0FE548 802D9B98 0C0B210B */ jal get_float_variable +/* 0FE54C 802D9B9C 46000586 */ mov.s $f22, $f0 +/* 0FE550 802D9BA0 46000506 */ mov.s $f20, $f0 +/* 0FE554 802D9BA4 0C00A8BB */ jal sin_deg +/* 0FE558 802D9BA8 4600A306 */ mov.s $f12, $f20 +/* 0FE55C 802D9BAC 4600B002 */ mul.s $f0, $f22, $f0 +/* 0FE560 802D9BB0 00000000 */ nop +/* 0FE564 802D9BB4 4600A306 */ mov.s $f12, $f20 +/* 0FE568 802D9BB8 3C108007 */ lui $s0, 0x8007 +/* 0FE56C 802D9BBC 2610419C */ addiu $s0, $s0, 0x419c +/* 0FE570 802D9BC0 8E030000 */ lw $v1, ($s0) +/* 0FE574 802D9BC4 4600008D */ trunc.w.s $f2, $f0 +/* 0FE578 802D9BC8 44021000 */ mfc1 $v0, $f2 +/* 0FE57C 802D9BCC 0C00A8D4 */ jal cos_deg +/* 0FE580 802D9BD0 A062006A */ sb $v0, 0x6a($v1) +/* 0FE584 802D9BD4 4600B582 */ mul.s $f22, $f22, $f0 +/* 0FE588 802D9BD8 00000000 */ nop +/* 0FE58C 802D9BDC 8E030000 */ lw $v1, ($s0) +/* 0FE590 802D9BE0 4600B08D */ trunc.w.s $f2, $f22 +/* 0FE594 802D9BE4 44021000 */ mfc1 $v0, $f2 +/* 0FE598 802D9BE8 00000000 */ nop +/* 0FE59C 802D9BEC A062006B */ sb $v0, 0x6b($v1) +/* 0FE5A0 802D9BF0 8FBF0018 */ lw $ra, 0x18($sp) +/* 0FE5A4 802D9BF4 8FB10014 */ lw $s1, 0x14($sp) +/* 0FE5A8 802D9BF8 8FB00010 */ lw $s0, 0x10($sp) +/* 0FE5AC 802D9BFC D7B60028 */ ldc1 $f22, 0x28($sp) +/* 0FE5B0 802D9C00 D7B40020 */ ldc1 $f20, 0x20($sp) +/* 0FE5B4 802D9C04 24020002 */ addiu $v0, $zero, 2 +/* 0FE5B8 802D9C08 03E00008 */ jr $ra +/* 0FE5BC 802D9C0C 27BD0030 */ addiu $sp, $sp, 0x30 + +.set reorder \ No newline at end of file diff --git a/papermario/asm/code_fe0b0_len_5a0/DemoJoystickXY.s b/papermario/asm/code_fe0b0_len_5a0/DemoJoystickXY.s new file mode 100644 index 0000000000..62afcc2f51 --- /dev/null +++ b/papermario/asm/code_fe0b0_len_5a0/DemoJoystickXY.s @@ -0,0 +1,39 @@ +.set noat # allow manual use of $at +.set noreorder # don't insert nops after branches + +.include "globals.inc" + +DemoJoystickXY: +/* 0FE5C0 802D9C10 27BDFFD8 */ addiu $sp, $sp, -0x28 +/* 0FE5C4 802D9C14 AFB10014 */ sw $s1, 0x14($sp) +/* 0FE5C8 802D9C18 0080882D */ daddu $s1, $a0, $zero +/* 0FE5CC 802D9C1C AFBF0018 */ sw $ra, 0x18($sp) +/* 0FE5D0 802D9C20 AFB00010 */ sw $s0, 0x10($sp) +/* 0FE5D4 802D9C24 F7B40020 */ sdc1 $f20, 0x20($sp) +/* 0FE5D8 802D9C28 8E30000C */ lw $s0, 0xc($s1) +/* 0FE5DC 802D9C2C 8E050000 */ lw $a1, ($s0) +/* 0FE5E0 802D9C30 0C0B210B */ jal get_float_variable +/* 0FE5E4 802D9C34 26100004 */ addiu $s0, $s0, 4 +/* 0FE5E8 802D9C38 0220202D */ daddu $a0, $s1, $zero +/* 0FE5EC 802D9C3C 8E050000 */ lw $a1, ($s0) +/* 0FE5F0 802D9C40 0C0B210B */ jal get_float_variable +/* 0FE5F4 802D9C44 46000506 */ mov.s $f20, $f0 +/* 0FE5F8 802D9C48 3C048007 */ lui $a0, 0x8007 +/* 0FE5FC 802D9C4C 2484419C */ addiu $a0, $a0, 0x419c +/* 0FE600 802D9C50 8C830000 */ lw $v1, ($a0) +/* 0FE604 802D9C54 4600A08D */ trunc.w.s $f2, $f20 +/* 0FE608 802D9C58 44021000 */ mfc1 $v0, $f2 +/* 0FE60C 802D9C5C 00000000 */ nop +/* 0FE610 802D9C60 A062006A */ sb $v0, 0x6a($v1) +/* 0FE614 802D9C64 8C830000 */ lw $v1, ($a0) +/* 0FE618 802D9C68 4600008D */ trunc.w.s $f2, $f0 +/* 0FE61C 802D9C6C 44021000 */ mfc1 $v0, $f2 +/* 0FE620 802D9C70 00000000 */ nop +/* 0FE624 802D9C74 A062006B */ sb $v0, 0x6b($v1) +/* 0FE628 802D9C78 8FBF0018 */ lw $ra, 0x18($sp) +/* 0FE62C 802D9C7C 8FB10014 */ lw $s1, 0x14($sp) +/* 0FE630 802D9C80 8FB00010 */ lw $s0, 0x10($sp) +/* 0FE634 802D9C84 D7B40020 */ ldc1 $f20, 0x20($sp) +/* 0FE638 802D9C88 24020002 */ addiu $v0, $zero, 2 +/* 0FE63C 802D9C8C 03E00008 */ jr $ra +/* 0FE640 802D9C90 27BD0028 */ addiu $sp, $sp, 0x28 diff --git a/papermario/asm/code_fe0b0_len_5a0.s b/papermario/asm/code_fe0b0_len_5a0/SetSpriteShading.s similarity index 57% rename from papermario/asm/code_fe0b0_len_5a0.s rename to papermario/asm/code_fe0b0_len_5a0/SetSpriteShading.s index 253d3c42c4..14843617fa 100644 --- a/papermario/asm/code_fe0b0_len_5a0.s +++ b/papermario/asm/code_fe0b0_len_5a0/SetSpriteShading.s @@ -1,16 +1,8 @@ -# %s disassembly and split file -# generated by n64split v%s - N64 ROM splitter - -# assembler directives .set noat # allow manual use of $at .set noreorder # don't insert nops after branches -.set gp=64 # allow use of 64-bit general purpose registers .include "globals.inc" - -.section .text802D9700, "ax" - SetSpriteShading: /* 0FE0B0 802D9700 27BDFF98 */ addiu $sp, $sp, -0x68 /* 0FE0B4 802D9704 AFBF0064 */ sw $ra, 0x64($sp) @@ -223,173 +215,4 @@ SetSpriteShading: /* 0FE3E4 802D9A34 03E00008 */ jr $ra /* 0FE3E8 802D9A38 27BD0068 */ addiu $sp, $sp, 0x68 -EnableSpriteShading: -/* 0FE3EC 802D9A3C 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 0FE3F0 802D9A40 AFBF0010 */ sw $ra, 0x10($sp) -/* 0FE3F4 802D9A44 8C82000C */ lw $v0, 0xc($a0) -/* 0FE3F8 802D9A48 0C0B1EAF */ jal get_variable -/* 0FE3FC 802D9A4C 8C450000 */ lw $a1, ($v0) -/* 0FE400 802D9A50 10400006 */ beqz $v0, .L802D9A6C -/* 0FE404 802D9A54 00000000 */ nop -/* 0FE408 802D9A58 3C038015 */ lui $v1, 0x8015 -/* 0FE40C 802D9A5C 8C631328 */ lw $v1, 0x1328($v1) -/* 0FE410 802D9A60 94620000 */ lhu $v0, ($v1) -/* 0FE414 802D9A64 080B669F */ j .L802D9A7C -/* 0FE418 802D9A68 34420001 */ ori $v0, $v0, 1 - -.L802D9A6C: -/* 0FE41C 802D9A6C 3C038015 */ lui $v1, 0x8015 -/* 0FE420 802D9A70 8C631328 */ lw $v1, 0x1328($v1) -/* 0FE424 802D9A74 94620000 */ lhu $v0, ($v1) -/* 0FE428 802D9A78 3042FFFE */ andi $v0, $v0, 0xfffe -.L802D9A7C: -/* 0FE42C 802D9A7C A4620000 */ sh $v0, ($v1) -/* 0FE430 802D9A80 8FBF0010 */ lw $ra, 0x10($sp) -/* 0FE434 802D9A84 24020002 */ addiu $v0, $zero, 2 -/* 0FE438 802D9A88 03E00008 */ jr $ra -/* 0FE43C 802D9A8C 27BD0018 */ addiu $sp, $sp, 0x18 - -GetDemoState: -/* 0FE440 802D9A90 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 0FE444 802D9A94 AFBF0010 */ sw $ra, 0x10($sp) -/* 0FE448 802D9A98 8C82000C */ lw $v0, 0xc($a0) -/* 0FE44C 802D9A9C 3C038007 */ lui $v1, 0x8007 -/* 0FE450 802D9AA0 8C63419C */ lw $v1, 0x419c($v1) -/* 0FE454 802D9AA4 8C450000 */ lw $a1, ($v0) -/* 0FE458 802D9AA8 0C0B2026 */ jal set_variable -/* 0FE45C 802D9AAC 80660071 */ lb $a2, 0x71($v1) -/* 0FE460 802D9AB0 8FBF0010 */ lw $ra, 0x10($sp) -/* 0FE464 802D9AB4 24020002 */ addiu $v0, $zero, 2 -/* 0FE468 802D9AB8 03E00008 */ jr $ra -/* 0FE46C 802D9ABC 27BD0018 */ addiu $sp, $sp, 0x18 - -/* 0FE470 802D9AC0 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 0FE474 802D9AC4 AFBF0010 */ sw $ra, 0x10($sp) -/* 0FE478 802D9AC8 8C82000C */ lw $v0, 0xc($a0) -DemoPressButton: -/* 0FE47C 802D9ACC 0C0B1EAF */ jal get_variable -/* 0FE480 802D9AD0 8C450000 */ lw $a1, ($v0) -/* 0FE484 802D9AD4 3C048007 */ lui $a0, 0x8007 -/* 0FE488 802D9AD8 8C84419C */ lw $a0, 0x419c($a0) -/* 0FE48C 802D9ADC 94830068 */ lhu $v1, 0x68($a0) -/* 0FE490 802D9AE0 00621825 */ or $v1, $v1, $v0 -/* 0FE494 802D9AE4 A4830068 */ sh $v1, 0x68($a0) -/* 0FE498 802D9AE8 8FBF0010 */ lw $ra, 0x10($sp) -/* 0FE49C 802D9AEC 24020002 */ addiu $v0, $zero, 2 -/* 0FE4A0 802D9AF0 03E00008 */ jr $ra -/* 0FE4A4 802D9AF4 27BD0018 */ addiu $sp, $sp, 0x18 - -DemoReleaseButton: -/* 0FE4A8 802D9AF8 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 0FE4AC 802D9AFC AFBF0010 */ sw $ra, 0x10($sp) -/* 0FE4B0 802D9B00 8C82000C */ lw $v0, 0xc($a0) -/* 0FE4B4 802D9B04 0C0B1EAF */ jal get_variable -/* 0FE4B8 802D9B08 8C450000 */ lw $a1, ($v0) -/* 0FE4BC 802D9B0C 3C058007 */ lui $a1, 0x8007 -/* 0FE4C0 802D9B10 8CA5419C */ lw $a1, 0x419c($a1) -/* 0FE4C4 802D9B14 94A30068 */ lhu $v1, 0x68($a1) -/* 0FE4C8 802D9B18 00022027 */ nor $a0, $zero, $v0 -/* 0FE4CC 802D9B1C 00641824 */ and $v1, $v1, $a0 -/* 0FE4D0 802D9B20 A4A30068 */ sh $v1, 0x68($a1) -/* 0FE4D4 802D9B24 8FBF0010 */ lw $ra, 0x10($sp) -/* 0FE4D8 802D9B28 24020002 */ addiu $v0, $zero, 2 -/* 0FE4DC 802D9B2C 03E00008 */ jr $ra -/* 0FE4E0 802D9B30 27BD0018 */ addiu $sp, $sp, 0x18 - -DemoSetButtons: -/* 0FE4E4 802D9B34 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 0FE4E8 802D9B38 AFBF0010 */ sw $ra, 0x10($sp) -/* 0FE4EC 802D9B3C 8C82000C */ lw $v0, 0xc($a0) -/* 0FE4F0 802D9B40 0C0B1EAF */ jal get_variable -/* 0FE4F4 802D9B44 8C450000 */ lw $a1, ($v0) -/* 0FE4F8 802D9B48 3C038007 */ lui $v1, 0x8007 -/* 0FE4FC 802D9B4C 8C63419C */ lw $v1, 0x419c($v1) -/* 0FE500 802D9B50 A4620068 */ sh $v0, 0x68($v1) -/* 0FE504 802D9B54 8FBF0010 */ lw $ra, 0x10($sp) -/* 0FE508 802D9B58 24020002 */ addiu $v0, $zero, 2 -/* 0FE50C 802D9B5C 03E00008 */ jr $ra -/* 0FE510 802D9B60 27BD0018 */ addiu $sp, $sp, 0x18 - -DemoJoystickRadial: -/* 0FE514 802D9B64 27BDFFD0 */ addiu $sp, $sp, -0x30 -/* 0FE518 802D9B68 AFB10014 */ sw $s1, 0x14($sp) -/* 0FE51C 802D9B6C 0080882D */ daddu $s1, $a0, $zero -/* 0FE520 802D9B70 AFBF0018 */ sw $ra, 0x18($sp) -/* 0FE524 802D9B74 AFB00010 */ sw $s0, 0x10($sp) -/* 0FE528 802D9B78 F7B60028 */ sdc1 $f22, 0x28($sp) -/* 0FE52C 802D9B7C F7B40020 */ sdc1 $f20, 0x20($sp) -/* 0FE530 802D9B80 8E30000C */ lw $s0, 0xc($s1) -/* 0FE534 802D9B84 8E050000 */ lw $a1, ($s0) -/* 0FE538 802D9B88 0C0B210B */ jal get_float_variable -/* 0FE53C 802D9B8C 26100004 */ addiu $s0, $s0, 4 -/* 0FE540 802D9B90 0220202D */ daddu $a0, $s1, $zero -/* 0FE544 802D9B94 8E050000 */ lw $a1, ($s0) -/* 0FE548 802D9B98 0C0B210B */ jal get_float_variable -/* 0FE54C 802D9B9C 46000586 */ mov.s $f22, $f0 -/* 0FE550 802D9BA0 46000506 */ mov.s $f20, $f0 -/* 0FE554 802D9BA4 0C00A8BB */ jal sin_deg -/* 0FE558 802D9BA8 4600A306 */ mov.s $f12, $f20 -/* 0FE55C 802D9BAC 4600B002 */ mul.s $f0, $f22, $f0 -/* 0FE560 802D9BB0 00000000 */ nop -/* 0FE564 802D9BB4 4600A306 */ mov.s $f12, $f20 -/* 0FE568 802D9BB8 3C108007 */ lui $s0, 0x8007 -/* 0FE56C 802D9BBC 2610419C */ addiu $s0, $s0, 0x419c -/* 0FE570 802D9BC0 8E030000 */ lw $v1, ($s0) -/* 0FE574 802D9BC4 4600008D */ trunc.w.s $f2, $f0 -/* 0FE578 802D9BC8 44021000 */ mfc1 $v0, $f2 -/* 0FE57C 802D9BCC 0C00A8D4 */ jal cos_deg -/* 0FE580 802D9BD0 A062006A */ sb $v0, 0x6a($v1) -/* 0FE584 802D9BD4 4600B582 */ mul.s $f22, $f22, $f0 -/* 0FE588 802D9BD8 00000000 */ nop -/* 0FE58C 802D9BDC 8E030000 */ lw $v1, ($s0) -/* 0FE590 802D9BE0 4600B08D */ trunc.w.s $f2, $f22 -/* 0FE594 802D9BE4 44021000 */ mfc1 $v0, $f2 -/* 0FE598 802D9BE8 00000000 */ nop -/* 0FE59C 802D9BEC A062006B */ sb $v0, 0x6b($v1) -/* 0FE5A0 802D9BF0 8FBF0018 */ lw $ra, 0x18($sp) -/* 0FE5A4 802D9BF4 8FB10014 */ lw $s1, 0x14($sp) -/* 0FE5A8 802D9BF8 8FB00010 */ lw $s0, 0x10($sp) -/* 0FE5AC 802D9BFC D7B60028 */ ldc1 $f22, 0x28($sp) -/* 0FE5B0 802D9C00 D7B40020 */ ldc1 $f20, 0x20($sp) -/* 0FE5B4 802D9C04 24020002 */ addiu $v0, $zero, 2 -/* 0FE5B8 802D9C08 03E00008 */ jr $ra -/* 0FE5BC 802D9C0C 27BD0030 */ addiu $sp, $sp, 0x30 - -DemoJoystickXY: -/* 0FE5C0 802D9C10 27BDFFD8 */ addiu $sp, $sp, -0x28 -/* 0FE5C4 802D9C14 AFB10014 */ sw $s1, 0x14($sp) -/* 0FE5C8 802D9C18 0080882D */ daddu $s1, $a0, $zero -/* 0FE5CC 802D9C1C AFBF0018 */ sw $ra, 0x18($sp) -/* 0FE5D0 802D9C20 AFB00010 */ sw $s0, 0x10($sp) -/* 0FE5D4 802D9C24 F7B40020 */ sdc1 $f20, 0x20($sp) -/* 0FE5D8 802D9C28 8E30000C */ lw $s0, 0xc($s1) -/* 0FE5DC 802D9C2C 8E050000 */ lw $a1, ($s0) -/* 0FE5E0 802D9C30 0C0B210B */ jal get_float_variable -/* 0FE5E4 802D9C34 26100004 */ addiu $s0, $s0, 4 -/* 0FE5E8 802D9C38 0220202D */ daddu $a0, $s1, $zero -/* 0FE5EC 802D9C3C 8E050000 */ lw $a1, ($s0) -/* 0FE5F0 802D9C40 0C0B210B */ jal get_float_variable -/* 0FE5F4 802D9C44 46000506 */ mov.s $f20, $f0 -/* 0FE5F8 802D9C48 3C048007 */ lui $a0, 0x8007 -/* 0FE5FC 802D9C4C 2484419C */ addiu $a0, $a0, 0x419c -/* 0FE600 802D9C50 8C830000 */ lw $v1, ($a0) -/* 0FE604 802D9C54 4600A08D */ trunc.w.s $f2, $f20 -/* 0FE608 802D9C58 44021000 */ mfc1 $v0, $f2 -/* 0FE60C 802D9C5C 00000000 */ nop -/* 0FE610 802D9C60 A062006A */ sb $v0, 0x6a($v1) -/* 0FE614 802D9C64 8C830000 */ lw $v1, ($a0) -/* 0FE618 802D9C68 4600008D */ trunc.w.s $f2, $f0 -/* 0FE61C 802D9C6C 44021000 */ mfc1 $v0, $f2 -/* 0FE620 802D9C70 00000000 */ nop -/* 0FE624 802D9C74 A062006B */ sb $v0, 0x6b($v1) -/* 0FE628 802D9C78 8FBF0018 */ lw $ra, 0x18($sp) -/* 0FE62C 802D9C7C 8FB10014 */ lw $s1, 0x14($sp) -/* 0FE630 802D9C80 8FB00010 */ lw $s0, 0x10($sp) -/* 0FE634 802D9C84 D7B40020 */ ldc1 $f20, 0x20($sp) -/* 0FE638 802D9C88 24020002 */ addiu $v0, $zero, 2 -/* 0FE63C 802D9C8C 03E00008 */ jr $ra -/* 0FE640 802D9C90 27BD0028 */ addiu $sp, $sp, 0x28 - -/* 0FE644 802D9C94 00000000 */ nop -/* 0FE648 802D9C98 00000000 */ nop -/* 0FE64C 802D9C9C 00000000 */ nop +.set reorder diff --git a/papermario/include/common.h b/papermario/include/common.h new file mode 100644 index 0000000000..e79998eade --- /dev/null +++ b/papermario/include/common.h @@ -0,0 +1,9 @@ +#ifndef _COMMON_H_ +#define _COMMON_H_ + +#include "ultra64.h" +#include "common_structs.h" +#include "functions.h" +#include "variables.h" + +#endif diff --git a/papermario/include/common_structs.h b/papermario/include/common_structs.h new file mode 100644 index 0000000000..8b50f45e2f --- /dev/null +++ b/papermario/include/common_structs.h @@ -0,0 +1,20 @@ +#ifndef _COMMON_STRUCTS_H_ +#define _COMMON_STRUCTS_H_ + +#include "ultra64.h" + +typedef struct { + /* 0x00 */ char unk_00[0x68]; + /* 0x68 */ u16 demoButtonInput; + /* 0x6A */ u8 demoStickX; + /* 0x6B */ u8 demoStickY; + /* 0x6C */ char unk_6C[0x5]; + /* 0x71 */ s8 demoState; +} game_status; + +typedef struct { + /* 0x0C */ char unk_00[0xC]; + /* 0x0C */ s32* ptrReadPos; +} ScriptContext; + +#endif diff --git a/papermario/include/functions.h b/papermario/include/functions.h new file mode 100644 index 0000000000..09ff7f88ae --- /dev/null +++ b/papermario/include/functions.h @@ -0,0 +1,12 @@ +#ifndef _FUNCTIONS_H_ +#define _FUNCTIONS_H_ + +#include "ultra64.h" +#include "common_structs.h" + +s32 get_variable(ScriptContext* script, s32 pos); +f32 get_float_variable(ScriptContext* script, s32 pos); +f32 sin_deg(f32 x); +f32 cos_deg(f32 x); + +#endif diff --git a/papermario/include/variables.h b/papermario/include/variables.h new file mode 100644 index 0000000000..7fed04a287 --- /dev/null +++ b/papermario/include/variables.h @@ -0,0 +1,10 @@ +#ifndef _VARIABLES_H_ +#define _VARIABLES_H_ + +#include "ultra64.h" +#include "common_structs.h" + +extern game_status* gGameStatus; +extern s16* D_80151328; + +#endif diff --git a/papermario/papermario.ld b/papermario/papermario.ld index 045b57a005..9206e1cd18 100644 --- a/papermario/papermario.ld +++ b/papermario/papermario.ld @@ -939,7 +939,7 @@ SECTIONS /* 0x802D9700 0FE0B0-0FE650 [5A0] */ .text802D9700 0x802D9700 : AT(0x0FE0B0) { - build/asm/code_fe0b0_len_5a0.o(.text802D9700); + build/src/code_fe0b0_len_5a0.o(.text); } /* 0x00000000 0FE650-0FEE30 [7E0] */ diff --git a/papermario/src/code_fe0b0_len_5a0.c b/papermario/src/code_fe0b0_len_5a0.c new file mode 100644 index 0000000000..669e2e1039 --- /dev/null +++ b/papermario/src/code_fe0b0_len_5a0.c @@ -0,0 +1,75 @@ +#include "common.h" + +void __attribute__((naked)) SetSpriteShading(void) { + __asm__( +".include \"asm/code_fe0b0_len_5a0/SetSpriteShading.s\"\n" + ); +} + +s32 EnableSpriteShading(ScriptContext* script) { + if (get_variable(script, *script->ptrReadPos) != 0) { + *D_80151328 |= 1; + } else { + *D_80151328 &= ~1; + } + return 2; +} + +s32 getDemoState(ScriptContext* script) { + set_variable(script, *script->ptrReadPos, gGameStatus->demoState); + return 2; +} + +s32 DemoPressButton(ScriptContext* script) { + gGameStatus->demoButtonInput |= get_variable(script, *script->ptrReadPos); + return 2; +} + +s32 DemoReleaseButton(ScriptContext* script) { + gGameStatus->demoButtonInput &= ~get_variable(script, *script->ptrReadPos); + return 2; +} + +s32 DemoSetButtons(ScriptContext* script) { + gGameStatus->demoButtonInput = get_variable(script, *script->ptrReadPos); + return 2; +} + +void __attribute__((naked)) DemoJoystickRadial(void) { + __asm__( + ".include \"asm/code_fe0b0_len_5a0/DemoJoystickRadial.s\"\n" + ); +} +/*s32 DemoJoysticRadial(ScriptContext* script) { + float a; + float b; + s32* nextPos = script->ptrReadPos + 1; + + a = get_float_variable(script, *script->ptrReadPos); + b = get_float_variable(script, nextPos); + + gGameStatus->demoStickX = a * sin_deg(b); + gGameStatus->demoStickY = a * cos_deg(b); + + return 2; +}*/ + +void __attribute__((naked)) DemoJoystickXY(void) { + __asm__( + ".include \"asm/code_fe0b0_len_5a0/DemoJoystickXY.s\"\n" + ); +} +/*s32 DemoJoystickXY(ScriptContext* script) { + float a; + float b; + s32* thisPos = script->ptrReadPos; + s32* nextPos = script->ptrReadPos + 1; + + a = get_float_variable(script, *thisPos); + b = get_float_variable(script, *nextPos); + + gGameStatus->demoStickX = a; + gGameStatus->demoStickY = b; + + return 2; +}*/ diff --git a/papermario/undefined_syms.txt b/papermario/undefined_syms.txt index b9c7744111..847b691269 100644 --- a/papermario/undefined_syms.txt +++ b/papermario/undefined_syms.txt @@ -1,4 +1,7 @@ +gGameStatus = 0x8007419C; + D_8014F140 = 0x8014F140; +D_80151328 = 0x80151328; D_8015C7C0 = 0x8015C7C0; func_80244BC8 = 0x80244BC8; /* ?? */