Skip to content

Commit

Permalink
Dedupe lib e_mist_door, e_life_up, e_flea_man (#2199)
Browse files Browse the repository at this point in the history
Rematched for `e_life_up` PSP

`e_flea_man` was basically good to go on PSP

`e_mist_door` I imported the PSP data and BSS as well, and cleaned up
naming on PSX side
  • Loading branch information
JoshSchreuder authored Feb 11, 2025
1 parent 7781b56 commit 4f0d175
Show file tree
Hide file tree
Showing 19 changed files with 344 additions and 308 deletions.
4 changes: 2 additions & 2 deletions Makefile.psp.mk
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ $(BUILD_DIR)/dra.elf: $(BUILD_DIR)/dra.ld $(addprefix $(BUILD_DIR)/src/dra/,$(ad
$(BUILD_DIR)/tt_%.elf: $(BUILD_DIR)/tt_%.ld $$(call list_o_files_psp,servant/tt_$$*) $(BUILD_DIR)/assets/servant/tt_%/mwo_header.bin.o
$(call link_with_deadstrip,tt_$*,$@)

ST_LIB_MERGE = collision e_chair st_update create_entity e_red_door e_room_fg st_common prim_helpers e_bloody_zombie e_misc en_thornweed_corpseweed e_skeleton
ST_LIB_MERGE = collision e_chair st_update create_entity e_red_door e_room_fg st_common prim_helpers e_bloody_zombie e_misc en_thornweed_corpseweed e_skeleton e_life_up e_flea_man e_mist_door
$(BUILD_DIR)/stlib.elf: $(BUILD_DIR)/stlib.ld $(addprefix $(BUILD_DIR)/src/st/lib/,$(addsuffix .c.o,$(ST_LIB_MERGE))) $$(call list_o_files_psp,st/lib_psp) $(BUILD_DIR)/assets/st/lib/mwo_header.bin.o
$(call link_with_deadstrip,stlib,$@)
ST_NO4_MERGE =
ST_NO4_MERGE =
$(BUILD_DIR)/stno4.elf: $(BUILD_DIR)/stno4.ld $(addprefix $(BUILD_DIR)/src/st/no4/,$(addsuffix .c.o,$(ST_NO4_MERGE))) $$(call list_o_files_psp,st/no4_psp) $(BUILD_DIR)/assets/st/no4/mwo_header.bin.o
$(call link_with_deadstrip,stno4,$@)
ST_ST0_MERGE = prologue_scroll title_card popup e_room_fg st_common collision e_lock_camera st_update e_red_door create_entity st_debug 2A218 e_particles e_collect prim_helpers e_bg_vortex e_misc 2805C 2A8DC
Expand Down
20 changes: 13 additions & 7 deletions config/splat.pspeu.stlib.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ segments:
- [0x80, c, lib/create_entity]
- [0x1028, c, lib/e_bloody_zombie]
- [0x1848, c, lib_psp/e_spellbook_magic_tome]
- [0x3DC0, c, lib_psp/e_life_up]
- [0x3DC0, c, lib/e_life_up]
- [0x4A40, c, lib_psp/e_stage_name]
- [0x5940, c, lib_psp/e_dhuron]
- [0x6648, c, lib_psp/6648]
Expand All @@ -59,10 +59,10 @@ segments:
- [0xFB10, c, lib_psp/e_misc_2]
- [0x10458, c, lib/e_misc]
- [0x11A88, c, lib/collision]
- [0x13C60, c, lib_psp/e_mist_door]
- [0x13C60, c, lib/e_mist_door]
- [0x13EE8, c, lib_psp/e_mudman]
- [0x15190, c, lib_psp/popup]
- [0x15788, c, lib_psp/e_flea_man]
- [0x15788, c, lib/e_flea_man]
- [0x15E00, c, lib/e_room_fg]
- [0x15F18, c, lib_psp/e_flea_armor]
- [0x169E8, c, lib/e_skeleton]
Expand All @@ -79,13 +79,17 @@ segments:
- [0x36780, data]
- [0x36800, .data, lib/e_bloody_zombie]
- [0x36840, data]
- [0x36AA0, .data, lib/e_life_up]
- [0x36AF0, data]
- [0x37918, .data, lib/e_red_door]
- [0x37930, .data, lib/st_update]
- [0x37960, data]
- [0x37B70, .data, lib_psp/e_collect]
- [0x380B8, .data, lib/e_misc]
- [0x38138, .data, lib/collision]
- [0x38510, data]
- [0x38510, .data, lib/e_mist_door]
- [0x38698, data]
- [0x38728, .data, lib/e_flea_man]
- [0x38790, .data, lib/e_room_fg]
- [0x38830, data]
- [0x388A0, .data, lib/e_skeleton]
Expand All @@ -95,20 +99,22 @@ segments:
- [0x60AB8, .data, lib/e_chair]
- [0x60AE8, data]
- [0x6D800, .rodata, lib_psp/e_spellbook_magic_tome]
- [0x6D858, .rodata, lib_psp/e_life_up]
- [0x6D858, .rodata, lib/e_life_up]
- [0x6D878, .rodata, lib_psp/e_dhuron]
- [0x6D8A0, .rodata, lib/e_red_door]
- [0x6D8B8, .rodata, lib_psp/8658]
- [0x6D8E0, .rodata, lib_psp/e_collect]
- [0x6D940, .rodata, lib_psp/e_mist_door]
- [0x6D940, .rodata, lib/e_mist_door]
- [0x6D940, .rodata, lib_psp/e_mudman]
- [0x6D988, .rodata, lib/en_thornweed_corpseweed]
- [0x6D9C8, .rodata, lib_psp/1B7F0]
- [0x6D9E8, .rodata, lib_psp/unk_1D9E8]
- [0x6DB78, .rodata, lib_psp/e_shop]
- [0x6DBB8, .rodata, lib_psp/2BC10]
- [0x6DD80, .bss, lib/create_entity]
- [0x6DDA0, bss, 6DDA0]
- [0x6DDA0, .bss, lib/e_life_up]
- [0x6DDA8, .bss, lib_psp/e_collect]
- [0x6DDE8, bss, 6DDE8]
- [0x6DE08, .bss, lib/e_mist_door]
- [0x6DE20, bss]
- [0x6EC00]
7 changes: 6 additions & 1 deletion config/splat.us.stlib.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ segments:
- [0x2B80, .data, en_thornweed_corpseweed]
- [0x2C38, data] # unused data?
- [0x2C48, .data, e_skeleton]
- [0x2D38, data]
- [0x2D38, .data, e_mist_door]
- [0x2D78, data]
- [0x2DE4, .data, e_flea_man]
- [0x2E3C, data]
- [0x319C, .data, e_life_up]
- [0x31F0, data]
- [0x2B938, .rodata, first_c_file]
- [0x2B960, .rodata, unk_2FA80]
- [0x2CE78, .rodata, e_shop]
Expand Down
1 change: 1 addition & 0 deletions config/splat.us.stno0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ segments:
- [0x2478, .data, e_axe_knight]
- [0x25CC, .data, e_ouija_table]
- [0x2618, .data, e_flea_man]
- [0x2670, data] # unused data?
- [0x2680, .data, e_skeleton]
- [0x2770, .data, e_magically_sealed_door]
- [0x27E0, data]
Expand Down
1 change: 1 addition & 0 deletions config/symbols.pspeu.stlib.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ g_EInitCorpseweedProjectile = 0x09276158;
g_EInitSkeleton = 0x09276228;
g_EInitSkeletonPieces = 0x09276238;
g_EInitSkeletonBone = 0x09276248;
g_EInitFleaMan = 0x09276278;
g_Rooms = 0x092762A8;
LIB_PrizeDrops = 0x09298168;
D_us_801811FC = 0x092A4520;
Expand Down
2 changes: 2 additions & 0 deletions config/symbols.pspeu.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ main_ = 0x08926994;
ScaleMatrix = 0x892752C;
CompMatrix = 0x8927678;
NormalClip = 0x089278D4;
RotTransPers = 0x89279C4;
RotTransPers4 = 0x8927AF8;
SquareRoot0 = 0x08927CC4;
SquareRoot12 = 0x08927CCC;
ratan2 = 0x08927CFC;
Expand Down
1 change: 1 addition & 0 deletions config/symbols.us.stlib.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ g_EInitCorpseweedProjectile = 0x801808F0;
g_EInitSkeleton = 0x80180998;
g_EInitSkeletonPieces = 0x801809A4;
g_EInitSkeletonBone = 0x801809B0;
g_EInitFleaMan = 0x801809D4;
LIB_RedDoorTiles = 0x80180AC8;
actor_names = 0x80181A60;
LIB_PrizeDrops = 0x80181A90;
Expand Down
184 changes: 184 additions & 0 deletions src/st/e_flea_man.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
static s32 fidgetVelocityX[] = {FIX(-2), FIX(-0.875), FIX(1.5), 0, FIX(-2.5)};
static s32 fidgetVelocityY[] = {
FIX(-0.5), FIX(-6), FIX(-3), FIX(-3.5), FIX(-4)};
static u8 anim_stand[] = {0x04, 0x10, 0x04, 0x11, 0x04, 0x12, 0x04, 0x13, 0x00};
static s16 sensors_ground[][2] = {{0, 10}, {0, 4}, {6, -4}, {-12, 0}};
static s16 sensors_move_y[][2] = {{0, -8}, {4, 0}, {-8, 0}};
static s16 sensors_move_x[][2] = {{-9, 6}, {0, -12}};

extern s32 D_us_80181ACC;

// Checks for collisions while the entity is moving downward, updating position
// if collision occurs. This is similar to other function CheckFieldCollision
static void CheckFieldCollisionY(s16 hitSensors[], s16 sensorCount) {
Collider collider;
s32 velocityY;
s16 currentPosX;
s16 currentPosY;
s16 i;

velocityY = g_CurrentEntity->velocityY;
if (velocityY >= 0) {
return;
}

currentPosX = g_CurrentEntity->posX.i.hi;
currentPosY = g_CurrentEntity->posY.i.hi;

for (i = 0; i < sensorCount; i++) {
currentPosX += *hitSensors++;
currentPosY += *hitSensors++;

g_api.CheckCollision(currentPosX, currentPosY, &collider, 0);

if (collider.effects & EFFECT_SOLID) {
g_CurrentEntity->posY.i.hi += collider.unk20;
break;
}
}
}

static void UpdateFacingDirection(void) {
g_CurrentEntity->facingLeft = (GetSideToPlayer() & 1) ^ 1;
}

void EntityFleaMan(Entity* self) {
u32 distanceX;
u8 rand;
u8 index;

#ifdef STAGE_IS_LIB
if (D_us_80181ACC & 1) {
self->flags |= FLAG_DEAD;
}
#endif

if (self->flags & FLAG_DEAD) {
PlaySfxPositional(SFX_SMALL_FLAME_IGNITE);
EntityExplosionSpawn(1, 0);
return;
}

if (self->ext.fleaMan.unk7C) {
self->ext.fleaMan.unk7C--;
self->hitboxState = 0;
} else {
self->hitboxState = 19;
}

switch (self->step) {
case 0:
InitializeEntity(g_EInitFleaMan);
self->animCurFrame = 16;
if (self->params & 1) {
self->facingLeft = 1;
self->velocityX = 0x140;
self->velocityY = 0xA0;
self->step = 2;
} else {
self->step = 1;
}

#ifndef VERSION_PSP
if (self->ext.fleaMan.unk7C) {
self->step = 3;
}
#endif
break;

case 1:
AnimateEntity(anim_stand, self);
UpdateFacingDirection();
if (GetDistanceToPlayerX() < 0x60 && GetDistanceToPlayerY() < 0x40) {
self->step = 3;
}
break;

case 2:
self->zPriority = 0;
MoveEntity();
break;

case 3:
UpdateFacingDirection();
if (self->hitParams && self->hitParams < 4) {
index = 2;
} else {
rand = Random() & 7;
distanceX = GetDistanceToPlayerX();

if (distanceX < 0x50) {
switch (rand) {
case 0:
case 1:
index = 3;
break;
case 2:
index = 2;
break;
case 3:
index = 1;
break;
default:
index = 0;
break;
}
} else if (distanceX <= 0x7F) {
switch (rand) {
case 0:
index = 3;
break;
case 1:
index = 2;
break;
case 2:
index = 0;
break;
default:
if (self->facingLeft ^ PLAYER.facingLeft) {
index = 0;
} else {
index = 1;
}
break;
}
} else {
index = 4;
}
}

distanceX = fidgetVelocityX[index];
if (self->facingLeft) {
self->velocityX = -distanceX;
} else {
self->velocityX = distanceX;
}

self->velocityY = fidgetVelocityY[index];
if (index == 1) {
PlaySfxPositional(SFX_BLIPS_C);
} else if (index == 0 || index == 2) {
PlaySfxPositional(SFX_BLIPS_D);
}

self->step++;
break;

case 4:
if (self->velocityY > FIX(-0.25) && self->velocityY < FIX(0.25)) {
index = 19;
} else if (self->velocityY < 0) {
index = 20;
} else {
index = 18;
}
self->animCurFrame = index;
if (UnkCollisionFunc3(sensors_ground) & 1) {
self->step = 3;
}
CheckFieldCollisionY(*sensors_move_y, 3);
CheckFieldCollision(sensors_move_x, 2);
break;
}
}
Loading

0 comments on commit 4f0d175

Please sign in to comment.