Some more

This commit is contained in:
Ethan Roseman 2020-10-03 16:04:49 -04:00
parent 926df66474
commit 5794cdf6fc
12 changed files with 128 additions and 137 deletions

View File

@ -1,9 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel func_800E26B0
/* 7BB60 800E26B0 3C028011 */ lui $v0, %hi(gPlayerStatus)
/* 7BB64 800E26B4 2442EFC8 */ addiu $v0, $v0, %lo(gPlayerStatus)
/* 7BB68 800E26B8 C440002C */ lwc1 $f0, 0x2c($v0)
/* 7BB6C 800E26BC 03E00008 */ jr $ra
/* 7BB70 800E26C0 E4400050 */ swc1 $f0, 0x50($v0)

View File

@ -1,20 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel func_800E34D8
/* 7C988 800E34D8 27BDFFE0 */ addiu $sp, $sp, -0x20
/* 7C98C 800E34DC AFBF0010 */ sw $ra, 0x10($sp)
/* 7C990 800E34E0 0C038D12 */ jal integrate_gravity
/* 7C994 800E34E4 F7B40018 */ sdc1 $f20, 0x18($sp)
/* 7C998 800E34E8 0C038082 */ jal func_800E0208
/* 7C99C 800E34EC 46000506 */ mov.s $f20, $f0
/* 7C9A0 800E34F0 10400004 */ beqz $v0, .L800E3504
/* 7C9A4 800E34F4 4600A006 */ mov.s $f0, $f20
/* 7C9A8 800E34F8 4480A000 */ mtc1 $zero, $f20
/* 7C9AC 800E34FC 00000000 */ nop
/* 7C9B0 800E3500 4600A006 */ mov.s $f0, $f20
.L800E3504:
/* 7C9B4 800E3504 8FBF0010 */ lw $ra, 0x10($sp)
/* 7C9B8 800E3508 D7B40018 */ ldc1 $f20, 0x18($sp)
/* 7C9BC 800E350C 03E00008 */ jr $ra
/* 7C9C0 800E3510 27BD0020 */ addiu $sp, $sp, 0x20

View File

@ -1,8 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel get_current_partner_id
/* 7E538 800E5088 3C028011 */ lui $v0, 0x8011
/* 7E53C 800E508C 8042F2A2 */ lb $v0, -0xd5e($v0)
/* 7E540 800E5090 03E00008 */ jr $ra
/* 7E544 800E5094 00000000 */ nop

View File

@ -1,20 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel save_ground_pos
/* 7E990 800E54E0 3C038011 */ lui $v1, %hi(gPlayerStatus)
/* 7E994 800E54E4 2463EFC8 */ addiu $v1, $v1, %lo(gPlayerStatus)
/* 7E998 800E54E8 C4600028 */ lwc1 $f0, 0x28($v1)
/* 7E99C 800E54EC C4620030 */ lwc1 $f2, 0x30($v1)
/* 7E9A0 800E54F0 4600010D */ trunc.w.s $f4, $f0
/* 7E9A4 800E54F4 44022000 */ mfc1 $v0, $f4
/* 7E9A8 800E54F8 C460002C */ lwc1 $f0, 0x2c($v1)
/* 7E9AC 800E54FC A4620016 */ sh $v0, 0x16($v1)
/* 7E9B0 800E5500 4600010D */ trunc.w.s $f4, $f0
/* 7E9B4 800E5504 44022000 */ mfc1 $v0, $f4
/* 7E9B8 800E5508 00000000 */ nop
/* 7E9BC 800E550C A4620018 */ sh $v0, 0x18($v1)
/* 7E9C0 800E5510 4600110D */ trunc.w.s $f4, $f2
/* 7E9C4 800E5514 44022000 */ mfc1 $v0, $f4
/* 7E9C8 800E5518 03E00008 */ jr $ra
/* 7E9CC 800E551C A462001A */ sh $v0, 0x1a($v1)

View File

@ -1,25 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel start_bounce_b
/* 7F53C 800E608C 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 7F540 800E6090 AFBF0010 */ sw $ra, 0x10($sp)
/* 7F544 800E6094 0C039769 */ jal set_action_state
/* 7F548 800E6098 24040004 */ addiu $a0, $zero, 4
/* 7F54C 800E609C 3C048011 */ lui $a0, %hi(gPlayerStatus)
/* 7F550 800E60A0 2484EFC8 */ addiu $a0, $a0, %lo(gPlayerStatus)
/* 7F554 800E60A4 3C014100 */ lui $at, 0x4100
/* 7F558 800E60A8 44810000 */ mtc1 $at, $f0
/* 7F55C 800E60AC 3C01BF80 */ lui $at, 0xbf80
/* 7F560 800E60B0 44811000 */ mtc1 $at, $f2
/* 7F564 800E60B4 8C820000 */ lw $v0, ($a0)
/* 7F568 800E60B8 3C030080 */ lui $v1, 0x80
/* 7F56C 800E60BC AC800078 */ sw $zero, 0x78($a0)
/* 7F570 800E60C0 AC80007C */ sw $zero, 0x7c($a0)
/* 7F574 800E60C4 00431025 */ or $v0, $v0, $v1
/* 7F578 800E60C8 E4800070 */ swc1 $f0, 0x70($a0)
/* 7F57C 800E60CC E4820074 */ swc1 $f2, 0x74($a0)
/* 7F580 800E60D0 AC820000 */ sw $v0, ($a0)
/* 7F584 800E60D4 8FBF0010 */ lw $ra, 0x10($sp)
/* 7F588 800E60D8 03E00008 */ jr $ra
/* 7F58C 800E60DC 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -1368,7 +1368,7 @@ typedef struct PlayerStatus {
/* 0x012 */ s16 moveFrames;
/* 0x014 */ s8 enableCollisionOverlapsCheck;
/* 0x015 */ s8 statusMenuCounterinputEnabledCounter; /* whether the C-up menu can appear */
/* 0x016 */ s16 lastGoodPosition[3];
/* 0x016 */ Vec3s lastGoodPosition;
/* 0x01C */ struct Vec3f extraVelocity;
/* 0x028 */ struct Vec3f position;
/* 0x034 */ char unk_34[16];

View File

@ -11,6 +11,7 @@ typedef UNK_TYPE EncounterTriggerFlags;
#define EncounterTriggerFlags_HAMMER 0x00000004
#define EncounterTriggerFlags_PARTNER 0x00000006
typedef s8 PartnerId;
#define PartnerId_NONE 0x00
#define PartnerId_GOOMBARIO 0x01
#define PartnerId_KOOPER 0x02

View File

@ -19,6 +19,8 @@ Shadow* get_shadow_by_index(s32 index);
void render_player_model();
f32 integrate_gravity(void);
void parent_collider_to_model(s32 colliderID, s16 modelIndex);
void clone_model(u16 srcModelID, u16 newModelID);
Model* get_model_from_list_index(s32 listIndex);

View File

@ -12,6 +12,7 @@ extern ActionState gPlayerActionState;
extern PlayerAnim gPlayerAnimation;
extern PlayerStatus gPlayerStatus;
extern PlayerStatus* gPlayerStatusPtr;
extern CollisionStatus gCollisionStatus;
extern GameStatus* gGameStatusPtr[1];
extern s32 gRandSeed;
extern StaticItem gItemTable[364];
@ -110,7 +111,7 @@ extern UNK_TYPE D_80147574;
extern UNK_TYPE D_80109270;
extern UNK_TYPE D_80108558;
extern UNK_TYPE D_8010F250; // play_sound state struct?
extern s8 D_8010EBB0;
extern s8 D_8010EBB0[];
extern SaveData gCurrentSaveFile;

View File

@ -100,7 +100,7 @@ INCLUDE_ASM(s32, "code_20ec0_len_5040", func_8004824C);
INCLUDE_ASM(s32, "code_20ec0_len_5040", spawn_drops);
//INCLUDE_ASM(s32, "code_20ec0_len_5040", get_coin_drop_amount);
#ifdef NON_MATCHING
s32 get_coin_drop_amount(Enemy* enemy) {
EncounterStatus* currentEncounter;
s32 amt;
@ -156,6 +156,9 @@ s32 get_coin_drop_amount(Enemy* enemy) {
return amt;
}
#else
INCLUDE_ASM(s32, "code_20ec0_len_5040", get_coin_drop_amount);
#endif
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80048E34);

View File

@ -1,21 +1,25 @@
#include "common.h"
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E26B0);
void func_800E26B0(void) {
PlayerStatus* playerStatus = &gPlayerStatus;
playerStatus->jumpApexHeight = playerStatus->position.y;
}
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E26C4);
void set_action_state(s32 actionState);
void move_player(s16 duration, f32 heading, f32 speed) {
PlayerStatus* player_status = &gPlayerStatus;
PlayerStatus* playerStatus = &gPlayerStatus;
player_status->flags = player_status->flags | 0x4000;
player_status->heading = heading;
player_status->moveFrames = duration;
player_status->currentSpeed = speed;
playerStatus->flags |= 0x4000;
playerStatus->heading = heading;
playerStatus->moveFrames = duration;
playerStatus->currentSpeed = speed;
if (!(player_status->animFlags & 0x00400000)) {
set_action_state(speed > player_status->walkSpeed ? ActionState_RUN : ActionState_WALK);
if (!(playerStatus->animFlags & 0x00400000)) {
set_action_state(speed > playerStatus->walkSpeed ? ActionState_RUN : ActionState_WALK);
}
}
@ -37,9 +41,16 @@ INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E315C);
INCLUDE_ASM(s32, "code_7bb60_len_41b0", phys_player_land);
INCLUDE_ASM(s32, "code_7bb60_len_41b0", integrate_gravity);
INCLUDE_ASM(f32, "code_7bb60_len_41b0", integrate_gravity);
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E34D8);
f32 func_800E34D8(void) {
f32 ret = integrate_gravity();
if (func_800E0208() != 0) {
ret = 0.0f;
}
return ret;
}
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E3514);
@ -67,7 +78,9 @@ INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E4F10);
INCLUDE_ASM(s32, "code_7bb60_len_41b0", check_input_midair_jump);
INCLUDE_ASM(s32, "code_7bb60_len_41b0", get_current_partner_id);
PartnerId get_current_partner_id(void) {
return gPlayerData.currentPartner;
}
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E5098);
@ -81,7 +94,13 @@ INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E5348);
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E546C);
INCLUDE_ASM(s32, "code_7bb60_len_41b0", save_ground_pos);
void save_ground_pos(void) {
PlayerStatus* playerStatus = &gPlayerStatus;
playerStatus->lastGoodPosition.x = playerStatus->position.x;
playerStatus->lastGoodPosition.y = playerStatus->position.y;
playerStatus->lastGoodPosition.z = playerStatus->position.z;
}
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E5520);
@ -98,21 +117,21 @@ INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E5A2C);
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E5C78);
void set_action_state(s32 actionState) {
PlayerStatus* player_status = &gPlayerStatus;
PlayerData* player_data = &gPlayerData;
UNK_TYPE* unknown_struct = &D_8010F250;
PlayerStatus* playerStatus = &gPlayerStatus;
PlayerData* playerData = &gPlayerData;
UNK_TYPE* unknownStruct = &D_8010F250;
if (player_status->flags & 0x200) {
player_status->flags &= ~0x200;
if (playerStatus->flags & 0x200) {
playerStatus->flags &= ~0x200;
enable_player_input();
}
if (player_status->animFlags & 0x4000) {
if (playerStatus->animFlags & 0x4000) {
if (actionState < ActionState_CONVERSATION) {
if (actionState >= 0) {
player_status->prevActionState = player_status->actionState;
player_status->actionState = actionState;
player_status->flags |= 0x80000000;
playerStatus->prevActionState = playerStatus->actionState;
playerStatus->actionState = actionState;
playerStatus->flags |= 0x80000000;
}
}
return;
@ -121,71 +140,117 @@ void set_action_state(s32 actionState) {
if (actionState == ActionState_HIT_HAZARD || actionState == ActionState_HIT_LAVA) {
u8 partner;
if (player_status->unk_BF == 3) {
if (playerStatus->unk_BF == 3) {
actionState = ActionState_HIT_HAZARD;
}
// Whilst Lakilester, Bow, or Parakarry's ability is active, hazards have no effect.
partner = player_data->currentPartner;
if ((partner - 7) < 2u || (s8)partner == PartnerId_PARAKARRY) {
if (D_8010EBB0) {
player_status->animFlags |= 0x4;
player_status->flags |= 0x800;
partner = playerData->currentPartner;
if (((u8)(partner - 7) < 2) || (playerData->currentPartner == PartnerId_PARAKARRY)) {
if (D_8010EBB0[0]) {
playerStatus->animFlags |= 0x4;
playerStatus->flags |= 0x800;
return;
}
}
}
if (actionState == ActionState_SLIDING) {
player_status->flags |= 0x10;
player_status->moveFrames = 0;
player_status->flags &= ~0x4000;
playerStatus->flags |= 0x10;
playerStatus->moveFrames = 0;
playerStatus->flags &= ~0x4000;
}
player_status->prevActionState = player_status->actionState;
playerStatus->prevActionState = playerStatus->actionState;
if (actionState == ActionState_USE_TWEESTER) {
player_status->prevActionState = ActionState_IDLE;
playerStatus->prevActionState = ActionState_IDLE;
}
if (actionState == ActionState_ENEMY_FIRST_STRIKE) {
player_status->animFlags |= 4;
playerStatus->animFlags |= 4;
}
player_status->actionState = actionState;
player_status->flags |= 0x80000000;
playerStatus->actionState = actionState;
playerStatus->flags |= 0x80000000;
if (player_status->actionState == ActionState_SPIN) {
if (playerStatus->actionState == ActionState_SPIN) {
return;
}
player_status->flags &= 0xFFFDFFFF;
player_status->animFlags &= 0xFFFEFFFF;
playerStatus->flags &= ~0x20000;
playerStatus->animFlags &= ~0x10000;
if (unknown_struct[0xC]) {
stop_sound(unknown_struct[0xC]);
if (unknownStruct[0xC]) {
stop_sound(unknownStruct[0xC]);
}
if (player_status->unk_D8) {
player_status->unk_D8[3][9] = 0xA;
player_status->unk_D8 = NULL;
if (playerStatus->unk_D8) {
playerStatus->unk_D8[3][9] = 0xA;
playerStatus->unk_D8 = NULL;
}
}
INCLUDE_ASM(s32, "code_7bb60_len_41b0", update_locomotion_state);
/*void update_locomotion_state(void) {
PlayerStatus* playerStatus = &gPlayerStatus;
ActionState actionState = ActionState_WALK;
INCLUDE_ASM(s32, "code_7bb60_len_41b0", start_falling);
if (!is_ability_active(Ability_SLOW_GO)) {
actionState = ActionState_WALK;
if (SQ(playerStatus->stickAxis[0]) + SQ(playerStatus->stickAxis[1]) >= 0xBD2) {
actionState = ActionState_RUN;
}
}
set_action_state(actionState);
}*/
INCLUDE_ASM(s32, "code_7bb60_len_41b0", start_bounce_a);
// todo these floats don't work
#ifdef NON_MATCHING
void start_falling(void) {
PlayerStatus* playerStatus = &gPlayerStatus;
INCLUDE_ASM(s32, "code_7bb60_len_41b0", start_bounce_b);
set_action_state(ActionState_FALLING);
playerStatus->gravityIntegrator[1] = 0.1143f;
playerStatus->gravityIntegrator[2] = -0.2871f;
playerStatus->gravityIntegrator[3] = -0.1823f;
playerStatus->gravityIntegrator[4] = 0.01152f;
}
#else
INCLUDE_ASM(void, "code_7bb60_len_41b0", start_falling);
#endif
#ifdef NON_MATCHING
void start_bounce_a(void) {
PlayerStatus* playerStatus = &gPlayerStatus;
set_action_state(ActionState_BOUNCE);
playerStatus->gravityIntegrator[0] = 10.0f;
playerStatus->gravityIntegrator[1] = -2.0f;
playerStatus->gravityIntegrator[2] = 0.5f; // todo is 0.8f but this doesn't work atm
playerStatus->gravityIntegrator[3] = -0.75f;
}
#else
INCLUDE_ASM(void, "code_7bb60_len_41b0", start_bounce_a);
#endif
void start_bounce_b(void) {
PlayerStatus* playerStatus = &gPlayerStatus;
set_action_state(ActionState_BOUNCE);
playerStatus->gravityIntegrator[0] = 8.0f;
playerStatus->gravityIntegrator[1] = -1.0f;
playerStatus->gravityIntegrator[2] = 0;
playerStatus->gravityIntegrator[3] = 0;
playerStatus->flags |= 0x800000;
}
s32 check_input_hammer(void) {
PlayerStatus* player_status = &gPlayerStatus;
PlayerData* player_data = &gPlayerData;
PlayerStatus* playerStatus = &gPlayerStatus;
PlayerData* playerData = &gPlayerData;
if (player_status->pressedButtons & Buttons_B) {
if (!(player_status->flags & 4)) {
if (D_8010EBB0 != 1 || player_data->currentPartner != PartnerId_WATT) {
if (player_data->hammerLevel != -1) {
if (playerStatus->pressedButtons & Buttons_B) {
if (!(playerStatus->flags & 4)) {
if (D_8010EBB0[0] != 1 || playerData->currentPartner != PartnerId_WATT) {
if (playerData->hammerLevel != -1) {
set_action_state(ActionState_HAMMER);
return TRUE;
}

View File

@ -101,6 +101,7 @@ gCurrentTriggerListPtr = 0x80159390;
D_801595A0 = 0x801595A0;
D_80159AE2 = 0x80159AE2;
D_80159AE4 = 0x80159AE4;
gCollisionStatus = 0x8015A55A0;
D_8015C7C0 = 0x8015C7C0;
gWorldModelList = 0x80151770;