This commit is contained in:
Ethan Roseman 2020-08-08 04:14:42 -04:00
parent f8343fa522
commit 356458683c
7 changed files with 161 additions and 116 deletions

View File

@ -1,16 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
.include "include/macro.inc"
glabel increment_max_SP
/* 083664 800EA1B4 3C038011 */ lui $v1, 0x8011
/* 083668 800EA1B8 2463F290 */ addiu $v1, $v1, -0xd70
/* 08366C 800EA1BC 9062028E */ lbu $v0, 0x28e($v1)
/* 083670 800EA1C0 24420001 */ addiu $v0, $v0, 1
/* 083674 800EA1C4 A062028E */ sb $v0, 0x28e($v1)
/* 083678 800EA1C8 00021600 */ sll $v0, $v0, 0x18
/* 08367C 800EA1CC 00021403 */ sra $v0, $v0, 0x10
/* 083680 800EA1D0 03E00008 */ jr $ra
/* 083684 800EA1D4 A4620290 */ sh $v0, 0x290($v1)

View File

@ -1,38 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
.include "include/macro.inc"
glabel recover_fp
/* 083714 800EA264 3C058011 */ lui $a1, 0x8011
/* 083718 800EA268 24A5F290 */ addiu $a1, $a1, -0xd70
/* 08371C 800EA26C 80A30005 */ lb $v1, 5($a1)
/* 083720 800EA270 2402FFFE */ addiu $v0, $zero, -2
/* 083724 800EA274 14820008 */ bne $a0, $v0, .L800EA298
/* 083728 800EA278 00000000 */ nop
/* 08372C 800EA27C 90A30006 */ lbu $v1, 6($a1)
/* 083730 800EA280 24630001 */ addiu $v1, $v1, 1
/* 083734 800EA284 00031600 */ sll $v0, $v1, 0x18
/* 083738 800EA288 00021603 */ sra $v0, $v0, 0x18
/* 08373C 800EA28C A0A30006 */ sb $v1, 6($a1)
/* 083740 800EA290 03E00008 */ jr $ra
/* 083744 800EA294 A0A30005 */ sb $v1, 5($a1)
.L800EA298:
/* 083748 800EA298 5C800001 */ bgtzl $a0, .L800EA2A0
/* 08374C 800EA29C 00641821 */ addu $v1, $v1, $a0
.L800EA2A0:
/* 083750 800EA2A0 2402FFFF */ addiu $v0, $zero, -1
/* 083754 800EA2A4 10820005 */ beq $a0, $v0, .L800EA2BC
/* 083758 800EA2A8 00000000 */ nop
/* 08375C 800EA2AC 80A20006 */ lb $v0, 6($a1)
/* 083760 800EA2B0 0043102A */ slt $v0, $v0, $v1
/* 083764 800EA2B4 50400003 */ beql $v0, $zero, .L800EA2C4
/* 083768 800EA2B8 A0A30005 */ sb $v1, 5($a1)
.L800EA2BC:
/* 08376C 800EA2BC 80A30006 */ lb $v1, 6($a1)
/* 083770 800EA2C0 A0A30005 */ sb $v1, 5($a1)
.L800EA2C4:
/* 083774 800EA2C4 03E00008 */ jr $ra
/* 083778 800EA2C8 0060102D */ daddu $v0, $v1, $zero

View File

@ -1,38 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
.include "include/macro.inc"
glabel recover_hp
/* 08377C 800EA2CC 3C058011 */ lui $a1, 0x8011
/* 083780 800EA2D0 24A5F290 */ addiu $a1, $a1, -0xd70
/* 083784 800EA2D4 80A30002 */ lb $v1, 2($a1)
/* 083788 800EA2D8 2402FFFE */ addiu $v0, $zero, -2
/* 08378C 800EA2DC 14820008 */ bne $a0, $v0, .L800EA300
/* 083790 800EA2E0 00000000 */ nop
/* 083794 800EA2E4 90A30003 */ lbu $v1, 3($a1)
/* 083798 800EA2E8 24630001 */ addiu $v1, $v1, 1
/* 08379C 800EA2EC 00031600 */ sll $v0, $v1, 0x18
/* 0837A0 800EA2F0 00021603 */ sra $v0, $v0, 0x18
/* 0837A4 800EA2F4 A0A30003 */ sb $v1, 3($a1)
/* 0837A8 800EA2F8 03E00008 */ jr $ra
/* 0837AC 800EA2FC A0A30002 */ sb $v1, 2($a1)
.L800EA300:
/* 0837B0 800EA300 5C800001 */ bgtzl $a0, .L800EA308
/* 0837B4 800EA304 00641821 */ addu $v1, $v1, $a0
.L800EA308:
/* 0837B8 800EA308 2402FFFF */ addiu $v0, $zero, -1
/* 0837BC 800EA30C 10820005 */ beq $a0, $v0, .L800EA324
/* 0837C0 800EA310 00000000 */ nop
/* 0837C4 800EA314 80A20003 */ lb $v0, 3($a1)
/* 0837C8 800EA318 0043102A */ slt $v0, $v0, $v1
/* 0837CC 800EA31C 50400003 */ beql $v0, $zero, .L800EA32C
/* 0837D0 800EA320 A0A30002 */ sb $v1, 2($a1)
.L800EA324:
/* 0837D4 800EA324 80A30003 */ lb $v1, 3($a1)
/* 0837D8 800EA328 A0A30002 */ sb $v1, 2($a1)
.L800EA32C:
/* 0837DC 800EA32C 03E00008 */ jr $ra
/* 0837E0 800EA330 0060102D */ daddu $v0, $v1, $zero

View File

@ -1,14 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
.include "include/macro.inc"
glabel set_max_SP
/* 083688 800EA1D8 3C028011 */ lui $v0, 0x8011
/* 08368C 800EA1DC 2442F290 */ addiu $v0, $v0, -0xd70
/* 083690 800EA1E0 A044028E */ sb $a0, 0x28e($v0)
/* 083694 800EA1E4 00042600 */ sll $a0, $a0, 0x18
/* 083698 800EA1E8 00042403 */ sra $a0, $a0, 0x10
/* 08369C 800EA1EC 03E00008 */ jr $ra
/* 0836A0 800EA1F0 A4440290 */ sh $a0, 0x290($v0)

View File

@ -319,7 +319,6 @@ def search_map_file(fn_name):
last_line = ""
for line in lines:
if line.startswith(" .text"):
print(line)
cur_objfile = line.split()[3]
if "load address" in line:
tokens = last_line.split() + line.split()

View File

@ -39,6 +39,14 @@ typedef struct {
/* 0x168 */ s32 unk_168;
} game_status;
typedef struct {
/* 0x0 */ s8 enabled;
/* 0x1 */ s8 level;
/* 0x2 */ s16 unk_2;
/* 0x4 */ s16 unk_4;
/* 0x6 */ s16 unk_6;
} partner_data; // size = 0x8
typedef struct {
/* 0x000 */ s8 bootsLevel;
/* 0x001 */ s8 hammerLevel;
@ -51,14 +59,63 @@ typedef struct {
/* 0x008 */ s8 maxBP;
/* 0x009 */ s8 level;
/* 0x00A */ s8 hasActionCommands;
/* 0x00B */ char unk_0B[0x1];
/* 0x00B */ char unk_0B;
/* 0x00C */ s16 coins;
/* 0x00E */ s8 fortressKeyCount;
/* 0x00F */ s8 starPieces;
/* 0x00F */ u8 starPieces;
/* 0x010 */ s8 starPoints;
/* 0x011 */ char unk_11[0x1];
/* 0x011 */ char unk_11;
/* 0x012 */ s8 currentPartner;
} player_data;
/* 0x013 */ char unk_13;
/* 0x014 */ partner_data partners[12];
/* 0x074 */ s16 keyItems[32];
/* 0x0B4 */ s16 badges[128];
/* 0x1B4 */ s16 invItems[10];
/* 0x1C8 */ s16 storedItems[32];
/* 0x208 */ s16 equippedBadges[64];
/* 0x288 */ s8 unk_288;
/* 0x289 */ s8 merleeSpellType;
/* 0x28A */ s8 merleeCastsLeft;
/* 0x28B */ char unk_28B;
/* 0x28C */ s16 merleeTurnCount;
/* 0x28E */ s8 maxStarPower;
/* 0x28F */ char unk_28F;
/* 0x290 */ s16 specialBarsFilled;
/* 0x292 */ s8 unk_292;
/* 0x293 */ char unk_293;
/* 0x294 */ s16 otherHitsTaken;
/* 0x296 */ s16 unk_296;
/* 0x298 */ s16 hitsTaken;
/* 0x29A */ s16 hitsBlocked;
/* 0x29C */ s16 playerFirstStrikes;
/* 0x29E */ s16 enemyFirstStrikes;
/* 0x2A0 */ s16 powerBounces;
/* 0x2A2 */ s16 battlesCount;
/* 0x2A4 */ s16 unk_2A4;
/* 0x2A6 */ s16 unk_2A6;
/* 0x2A8 */ s16 unk_2A8;
/* 0x2AA */ s16 unk_2AA;
/* 0x2AC */ s32 unk_2AC;
/* 0x2B0 */ s32 unk_2B0;
/* 0x2B4 */ s32 totalCoinsEarned;
/* 0x2B8 */ s16 idleFrameCounter; /* frames with no inputs, overflows ever ~36 minutes of idling */
/* 0x2BA */ char unk_2BA[0x2];
/* 0x2BC */ s32 frameCounter; /* increases by 2 per frame */
/* 0x2C0 */ s16 quizzesAnswered;
/* 0x2C2 */ s16 quizzesCorrect;
/* 0x2C4 */ s32 unk_2C4;
/* 0x2C8 */ s32 unk_2C8[12];
/* 0x2F8 */ char unk_2F8[0x30];
/* 0x328 */ s32 unk_328;
/* 0x32C */ s16 starPiecesCollected;
/* 0x32E */ s16 jumpGamePlays;
/* 0x330 */ s32 jumpGameTotal;
/* 0x334 */ s16 jumpGameRecord;
/* 0x336 */ s16 smashGamePlays;
/* 0x338 */ s32 smashGameTotal;
/* 0x33C */ s16 smashGameRecord;
/* 0x33E */ char unk_33E[0x2];
} player_data; // size = 0x340
typedef struct {
/* 0x00 */ char unk_00[0xC];

View File

@ -120,19 +120,114 @@ INCLUDE_ASM(code_80850_len_3060, add_star_points);
INCLUDE_ASM(code_80850_len_3060, add_star_pieces);
INCLUDE_ASM(code_80850_len_3060, increment_max_SP);
/*u8 add_star_pieces(s32 amt) {
player_data* playerData = &gPlayerData;
s32 newStarPieces = playerData->starPieces + amt;
INCLUDE_ASM(code_80850_len_3060, set_max_SP);
if (newStarPieces > 222) {
newStarPieces = 222;
}
if (newStarPieces < 0) {
newStarPieces = 0;
}
playerData->starPieces = newStarPieces;
if (amt > 0) {
playerData->starPiecesCollected += amt;
}
return playerData->starPieces;
}*/
void increment_max_SP() {
player_data* playerData = &gPlayerData;
playerData->maxStarPower++;
playerData->specialBarsFilled = playerData->maxStarPower * 256;
}
void set_max_SP(s8 newMaxSP) {
player_data* playerData = &gPlayerData;
playerData->maxStarPower = newMaxSP;
playerData->specialBarsFilled = newMaxSP * 256;
}
INCLUDE_ASM(code_80850_len_3060, add_SP);
INCLUDE_ASM(code_80850_len_3060, recover_fp);
/*u16 add_SP(s32 arg0) {
player_data* playerData = &gPlayerData;
s16 temp_v0_2;
s8 temp_v1;
u16 temp_v0;
s32 phi_v1;
INCLUDE_ASM(code_80850_len_3060, recover_hp);
(void *)0x8010EF58->unk57 = (u8)1;
(void *)0x8010EF58->unk58 = (u8)0x3C;
phi_v1 = playerData->specialBarsFilled;
if (playerData->specialBarsFilled < 0) {
phi_v1 = playerData->specialBarsFilled + 31;
}
(void *)0x8010EF58->unk59 = (s8) (phi_v1 >> 5);
playerData->specialBarsFilled += arg0;
temp_v1 = playerData->maxStarPower;
playerData->specialBarsFilled = temp_v1;
if (temp_v1 >= arg0) {
}
temp_v0 = playerData->specialBarsFilled;
(void *)0x8010EF58->unk48 = temp_v0;
return temp_v0;
}*/
s32 recover_fp(s32 amt) {
player_data* playerData = &gPlayerData;
s32 newFP = playerData->curFP;
s32 ret;
if (amt == -2) {
playerData->curMaxFP += 1;
playerData->curFP = playerData->curMaxFP;
return playerData->curMaxFP;
}
if (amt > 0) {
newFP += amt;
}
if ((amt == -1) || (ret = newFP, (playerData->curMaxFP < newFP))) {
ret = playerData->curMaxFP;
}
playerData->curFP = ret;
return ret;
}
s32 recover_hp(s32 amt) {
player_data* playerData = &gPlayerData;
s32 newHP = playerData->curHP;
s32 ret;
if (amt == -2) {
playerData->curMaxHP += 1;
playerData->curHP = playerData->curMaxHP;
return playerData->curMaxHP;
}
if (amt > 0) {
newHP += amt;
}
if ((amt == -1) || (ret = newHP, (playerData->curMaxHP < newHP))) {
ret = playerData->curMaxHP;
}
playerData->curHP = ret;
return ret;
}
void subtract_hp(s32 amt) {
player_data* playerData = &gPlayerData;
s32 newHP = gPlayerData.curHP;
s32 newHP = playerData->curHP;
if (amt > 0) {
newHP -= amt;