merge master

This commit is contained in:
dark-samus 2020-08-11 20:58:54 -04:00
commit e60a7bb5e0
8 changed files with 241 additions and 83 deletions

1
.gitignore vendored
View File

@ -3,6 +3,7 @@ n64split
*.bin
*.FS
*.bgm
papermario/ctx.c
papermario/Map_Assets.FS
papermario/bgm
papermario/bin

View File

@ -1,74 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
.include "include/macro.inc"
glabel coin_counter_draw_content
/* 082788 800E92D8 3C038011 */ lui $v1, 0x8011
/* 08278C 800E92DC 8463F29C */ lh $v1, -0xd64($v1)
/* 082790 800E92E0 27BDFFC8 */ addiu $sp, $sp, -0x38
/* 082794 800E92E4 AFB3002C */ sw $s3, 0x2c($sp)
/* 082798 800E92E8 00A0982D */ daddu $s3, $a1, $zero
/* 08279C 800E92EC AFB20028 */ sw $s2, 0x28($sp)
/* 0827A0 800E92F0 3C128011 */ lui $s2, 0x8011
/* 0827A4 800E92F4 2652EF58 */ addiu $s2, $s2, -0x10a8
/* 0827A8 800E92F8 AFBF0034 */ sw $ra, 0x34($sp)
/* 0827AC 800E92FC AFB40030 */ sw $s4, 0x30($sp)
/* 0827B0 800E9300 AFB10024 */ sw $s1, 0x24($sp)
/* 0827B4 800E9304 AFB00020 */ sw $s0, 0x20($sp)
/* 0827B8 800E9308 86420040 */ lh $v0, 0x40($s2)
/* 0827BC 800E930C 10620011 */ beq $v1, $v0, .L800E9354
/* 0827C0 800E9310 00C0A02D */ daddu $s4, $a2, $zero
/* 0827C4 800E9314 3C028007 */ lui $v0, 0x8007
/* 0827C8 800E9318 8C42419C */ lw $v0, 0x419c($v0)
/* 0827CC 800E931C 94430134 */ lhu $v1, 0x134($v0)
/* 0827D0 800E9320 3C02AAAA */ lui $v0, 0xaaaa
/* 0827D4 800E9324 3442AAAB */ ori $v0, $v0, 0xaaab
/* 0827D8 800E9328 00620019 */ multu $v1, $v0
/* 0827DC 800E932C 00004010 */ mfhi $t0
/* 0827E0 800E9330 00082042 */ srl $a0, $t0, 1
/* 0827E4 800E9334 00041040 */ sll $v0, $a0, 1
/* 0827E8 800E9338 00441021 */ addu $v0, $v0, $a0
/* 0827EC 800E933C 00621823 */ subu $v1, $v1, $v0
/* 0827F0 800E9340 3063FFFF */ andi $v1, $v1, 0xffff
/* 0827F4 800E9344 14600004 */ bnez $v1, .L800E9358
/* 0827F8 800E9348 2665001B */ addiu $a1, $s3, 0x1b
/* 0827FC 800E934C 0C05272D */ jal play_sound
/* 082800 800E9350 24040211 */ addiu $a0, $zero, 0x211
.L800E9354:
/* 082804 800E9354 2665001B */ addiu $a1, $s3, 0x1b
.L800E9358:
/* 082808 800E9358 2690000B */ addiu $s0, $s4, 0xb
/* 08280C 800E935C 8E51005C */ lw $s1, 0x5c($s2)
/* 082810 800E9360 0200302D */ daddu $a2, $s0, $zero
/* 082814 800E9364 0C051261 */ jal set_icon_render_pos
/* 082818 800E9368 0220202D */ daddu $a0, $s1, $zero
/* 08281C 800E936C 0C0511EA */ jal draw_icon_0
/* 082820 800E9370 0220202D */ daddu $a0, $s1, $zero
/* 082824 800E9374 2665000F */ addiu $a1, $s3, 0xf
/* 082828 800E9378 8E510060 */ lw $s1, 0x60($s2)
/* 08282C 800E937C 0200302D */ daddu $a2, $s0, $zero
/* 082830 800E9380 0C051261 */ jal set_icon_render_pos
/* 082834 800E9384 0220202D */ daddu $a0, $s1, $zero
/* 082838 800E9388 0C0511EA */ jal draw_icon_0
/* 08283C 800E938C 0220202D */ daddu $a0, $s1, $zero
/* 082840 800E9390 2665003A */ addiu $a1, $s3, 0x3a
/* 082844 800E9394 26860004 */ addiu $a2, $s4, 4
/* 082848 800E9398 2402000A */ addiu $v0, $zero, 0xa
/* 08284C 800E939C AFA20010 */ sw $v0, 0x10($sp)
/* 082850 800E93A0 240200FF */ addiu $v0, $zero, 0xff
/* 082854 800E93A4 AFA20014 */ sw $v0, 0x14($sp)
/* 082858 800E93A8 24020003 */ addiu $v0, $zero, 3
/* 08285C 800E93AC 86440040 */ lh $a0, 0x40($s2)
/* 082860 800E93B0 24070001 */ addiu $a3, $zero, 1
/* 082864 800E93B4 0C049DA7 */ jal draw_number
/* 082868 800E93B8 AFA20018 */ sw $v0, 0x18($sp)
/* 08286C 800E93BC 8FBF0034 */ lw $ra, 0x34($sp)
/* 082870 800E93C0 8FB40030 */ lw $s4, 0x30($sp)
/* 082874 800E93C4 8FB3002C */ lw $s3, 0x2c($sp)
/* 082878 800E93C8 8FB20028 */ lw $s2, 0x28($sp)
/* 08287C 800E93CC 8FB10024 */ lw $s1, 0x24($sp)
/* 082880 800E93D0 8FB00020 */ lw $s0, 0x20($sp)
/* 082884 800E93D4 03E00008 */ jr $ra
/* 082888 800E93D8 27BD0038 */ addiu $sp, $sp, 0x38

View File

@ -27,13 +27,20 @@ typedef struct {
/* 0x081 */ s8 unk_81;
/* 0x082 */ s8 unk_82;
/* 0x083 */ s8 unk_83;
/* 0x084 */ char unk_84[0x8];
/* 0x084 */ char unk_84[2];
/* 0x086 */ s16 unk_86;
/* 0x088 */ s16 unk_88;
/* 0x08A */ s16 unk_8A;
/* 0x08C */ s16 mapID;
/* 0x08E */ char unk_8E[0x1A];
/* 0x0A8 */ s8 unk_A8;
/* 0x0A9 */ char unk_A9;
/* 0x0AA */ s8 unk_AA;
/* 0x0AB */ char unk_AB[0x91];
/* 0x0AB */ char unk_AB[1];
/* 0x0AC */ s8 unk_AC;
/* 0x0AD */ char unk_AD[0x87];
/* 0x134 */ u16 unk_134;
/* 0x136 */ char unk_136[0x6];
/* 0x13C */ s16 unk_13C;
/* 0x13E */ char unk_13E[0xA];
/* 0x148 */ s16 unk_148;
@ -134,6 +141,105 @@ typedef struct {
/* 0x33E */ char unk_33E[0x2];
} player_data; // size = 0x340
typedef enum eActionState {
actionBounce=4,
actionConversation=12,
actionEnemyFirstStrike=27,
actionFalling=8,
actionGroundPound=14,
actionHammer=18,
actionIdle=0,
actionJump=3,
actionLand=10,
actionLaunch=6,
actionRide=33,
actionRun=2,
actionSpin=26,
actionSpinJump=13,
actionSpinningFlower=29,
actionStepDown=9,
actionStepUp=34,
actionUltraJump=15,
actionUltraPound=16,
actionUseSpring=38,
actionWalk=1
} eActionState;
typedef enum eFallState {
Falling=1,
Rising=0
} eFallState;
typedef struct {
/* 0x000 */ s32 flags;
/* 0x004 */ u32 animFlags;
/* 0x008 */ s16 framesOnGround; /* Number of frames since last jump landed */
/* 0x00A */ char unk_0A[2];
/* 0x00C */ s8 peachDisguise;
/* 0x00D */ char unk_0D[3];
/* 0x010 */ s16 unk_10;
/* 0x012 */ s16 moveFrames;
/* 0x014 */ s8 enableCollisionOverlapsCheck;
/* 0x015 */ s8 statusMenuCounter; /* whether the C-up menu can appear */
/* 0x016 */ s16 lastGoodPosition[3]; // TODO: Vec3s?
/* 0x01C */ f32 extraVelocity[3]; // TODO: Vec3f?
/* 0x028 */ f32 position[3]; //TODO: Vec3f?
/* 0x034 */ f32 unk_34;
/* 0x038 */ f32 unk_38;
/* 0x03C */ char unk_3C[8];
/* 0x044 */ f32 decorationPos[2];
/* 0x04C */ char unk_4C[4];
/* 0x050 */ f32 jumpApexHeight;
/* 0x054 */ s32 currentSpeed;
/* 0x058 */ f32 walkSpeed;
/* 0x05C */ f32 runSpeed;
/* 0x060 */ char unk_60[4];
/* 0x064 */ s32 unk_64;
/* 0x068 */ f32 normalPitch;
/* 0x06C */ f32 unk_6C;
/* 0x070 */ f32 gravityIntegrator[4];
/* 0x080 */ f32 targetYaw;
/* 0x084 */ f32 currentYaw;
/* 0x088 */ s32 unk_88;
/* 0x08C */ char unk_8C[4];
/* 0x090 */ s32 unk_90;
/* 0x094 */ s32 unk_94;
/* 0x098 */ s32 unk_98;
/* 0x09C */ s32 unk_9C;
/* 0x0A0 */ f32 heading;
/* 0x0A4 */ char unk_A4[4];
/* 0x0A8 */ f32 spriteFacingAngle; /* angle of sprite, relative to camera, from 0 to 180 */
/* 0x0AC */ char unk_AC[4];
/* 0x0B0 */ s16 colliderHeight;
/* 0x0B2 */ s16 colliderDiameter;
/* 0x0B4 */ eActionState actionState;
/* 0x0B5 */ eActionState prevActionState;
/* 0x0B6 */ eFallState fallState;
/* 0x0B7 */ char unk_B7;
/* 0x0B8 */ s32 anim;
/* 0x0BC */ char unk_BC[2];
/* 0x0BE */ s8 renderMode;
/* 0x0BF */ s8 unk_BF;
/* 0x0C0 */ u32* decorationList;
/* 0x0C4 */ char unk_C4;
/* 0x0C5 */ s8 unk_C5;
/* 0x0C6 */ char unk_C6[6];
/* 0x0CC */ s32 shadowID;
/* 0x0D0 */ char unk_D0[8];
/* 0x0D8 */ s32 unk_D8;
/* 0x0DC */ s32 currentButtons;
/* 0x0E0 */ s32 pressedButtons;
/* 0x0E4 */ s32 heldButtons;
/* 0x0E8 */ f32 stickAxis[2];
/* 0x0F0 */ s32 currentButtonsBuffer[10];
/* 0x118 */ s32 pressedButtonsBuffer[10];
/* 0x140 */ s32 heldButtonsBuffer[10];
/* 0x168 */ f32 stickXBuffer[10];
/* 0x190 */ f32 stickYBuffer[10];
/* 0x1B8 */ s32 inputBufPos;
/* 0x1BC */ char unk_1BC[0xCC];
} player_status; // size = 0x288
typedef struct {
/* 0x00 */ s32 hpIconIndexes[2]; /* hpIconIndex, heartIconIndex */
/* 0x08 */ s32 fpIconIndexes[2]; /* fpIconIndex, flowerIconIndex */

View File

@ -7,6 +7,7 @@
extern ui_status gUIStatus;
extern player_data gPlayerData;
extern player_status gPlayerStatus;
extern game_status* gGameStatusPtr[1];
extern item_table_entry gItemTable[364];
extern s16* D_80151328;
@ -17,5 +18,8 @@ extern UNK_TYPE D_800E92D8;
extern UNK_TYPE D_80147474;
extern UNK_TYPE D_80109270;
extern UNK_TYPE D_80108558;
extern u16 D_800A0940;
extern u16 D_800A0942;
extern s16 D_800A0944;
#endif

View File

@ -1,6 +1,10 @@
#include "common.h"
INCLUDE_ASM(code_111f0_len_860, func_80035DF0);
void func_80035DF0(s16 arg0) {
s16* tempPtr = &D_800A0942;
*tempPtr = arg0;
}
INCLUDE_ASM(code_111f0_len_860, func_80035E00);
@ -10,17 +14,55 @@ INCLUDE_ASM(code_111f0_len_860, func_80035E54);
INCLUDE_ASM(code_111f0_len_860, func_80035EEC);
INCLUDE_ASM(code_111f0_len_860, func_800360FC);
void func_800360FC(void) {
game_status* gameStatus = *gGameStatusPtr;
INCLUDE_ASM(code_111f0_len_860, func_80036130);
if (gameStatus->unk_AC == 2) {
func_800E973C();
}
}
void func_80036130(void) {
game_status* gameStatus = *gGameStatusPtr;
D_800A0940 = 0x00;
D_800A0942 = 0x14;
D_800A0944 = 0x00;
if (gameStatus->unk_88 != gameStatus->unk_86) {
gameStatus->unk_8A = 0x01;
gameStatus->unk_88 = gameStatus->unk_86;
}
else {
gameStatus->unk_8A = 0;
}
}
INCLUDE_ASM(code_111f0_len_860, func_8003617C);
INCLUDE_ASM(code_111f0_len_860, func_800363FC);
s32 func_800363FC(void) {
s32 phi_return;
INCLUDE_ASM(code_111f0_len_860, func_80036430);
if ((D_800A0944 == 4) || (phi_return = 4, (D_800A0944 == 0))) {
phi_return = func_800E973C();
}
return phi_return;
}
s32 func_80036430(void) {
player_status* pPlayerStatus = &gPlayerStatus;
D_800A0940 = 0xFF;
D_800A0942 = 0x14;
D_800A0944 = 0x01;
pPlayerStatus->flags |= 0x1000;
return pPlayerStatus->flags;
}
INCLUDE_ASM(code_111f0_len_860, func_8003646C);
INCLUDE_ASM(code_111f0_len_860, func_80036640);
void func_80036640(void) {
}

View File

@ -280,7 +280,24 @@ INCLUDE_ASM(code_80850_len_3060, status_menu_draw_stat);
INCLUDE_ASM(code_80850_len_3060, update_status_menu);
INCLUDE_ASM(code_80850_len_3060, coin_counter_draw_content);
void coin_counter_draw_content(UNK_TYPE arg0, s32 posX, s32 posY) {
ui_status *uiStatus = &gUIStatus;
s32 iconIndex;
if ((gPlayerData.coins != uiStatus->displayCoins) && (((*gGameStatusPtr)->unk_134 % 3) == 0)) {
play_sound(0x211);
}
iconIndex = uiStatus->iconIndex10;
set_icon_render_pos(iconIndex, posX + 27, posY + 11);
draw_icon_0(iconIndex);
iconIndex = uiStatus->iconIndex11;
set_icon_render_pos(iconIndex, posX + 15, posY + 11);
draw_icon_0(iconIndex);
draw_number(uiStatus->displayCoins, posX + 58, posY + 4, 1, 10, 255, 3);
}
INCLUDE_ASM(code_80850_len_3060, update_coin_counter);

58
papermario/tools/m2ctx.py Executable file
View File

@ -0,0 +1,58 @@
#!/usr/bin/python3
import os
import sys
import subprocess
from pathlib import Path
script_dir = os.path.dirname(os.path.realpath(__file__))
root_dir = script_dir + "/../"
src_dir = root_dir + "src/"
def get_c_dir(dirname):
for root, dirs, files in os.walk(src_dir):
for directory in dirs:
if directory == dirname:
return os.path.join(root, directory)
def get_c_file(directory):
for root, dirs, files in os.walk(directory):
for file in files:
if file.endswith(".c") and "data" not in file:
return file
def import_c_file(in_file):
in_file = os.path.relpath(in_file, root_dir)
cpp_command = ["cpp", "-P", "-Iinclude", "-undef", "-D__sgi", "-D_LANGUAGE_C",
"-DNON_MATCHING", "-D_Static_assert(x, y)=", "-D__attribute__(x)=", in_file]
try:
return subprocess.check_output(cpp_command, cwd=root_dir, encoding="utf-8")
except subprocess.CalledProcessError:
print(
"Failed to preprocess input file, when running command:\n"
+ cpp_command,
file=sys.stderr,
)
sys.exit(1)
def main():
if len(sys.argv) > 1:
arg = sys.argv[1]
if arg == "-h" or arg == "--help":
sys.exit("Usage: ./m2ctx.py path/to/file.c\n" \
"or ./m2ctx.py (from an actor or gamestate's asm dir)\n" \
"Output will be saved in oot/ctx.c")
c_file_path = Path.cwd() / sys.argv[1]
else:
sys.exit("Please specify a .c file path as an argument to this script")
output = import_c_file(c_file_path)
with open(os.path.join(root_dir, "ctx.c"), "w", encoding="UTF-8") as f:
f.write(output)
if __name__ == "__main__":
main()

View File

@ -1,12 +1,16 @@
gGameStatusPtr = 0x8007419C;
gUIStatus = 0x8010EF58;
gPlayerData = 0x8010F290;
gPlayerStatus = 0x8010EFC8;
gItemTable = 0x800878E0;
D_800E92D8 = 0x800E92D8;
D_80147474 = 0x80147474;
D_80109270 = 0x80109270;
D_80108558 = 0x80108558;
D_800A0940 = 0x800A0940;
D_800A0942 = 0x800A0942;
D_800A0944 = 0x800A0944;
D_8010CD10 = 0x8010CD10;
D_8010CD12 = 0x8010CD12;