TT_000 PSP match more functions (#1150)

Highlights:
* `abs` is a real function the compiler can optimise and inline (thanks
@Mc-muffin for the discovery)
* `-Op` is required to avoid using `div` when dividing integer numbers
* A file split in TT_000 is required to match on PSP
* `UpdateAnim` had the wrong signature
* Splatting the PSP build has been an excellent idea
This commit is contained in:
Luciano Ciccariello 2024-05-19 19:23:30 +01:00 committed by GitHub
parent 898e90f963
commit eae3cfbe94
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 245 additions and 220 deletions

View File

@ -18,7 +18,7 @@ CCPSP := MWCIncludes=bin/ $(WIBO) $(MWCCPSP)
PSP_EU_TARGETS := tt_000
SPLAT_PIP := splat split
MWCCPSP_FLAGS := -gccinc -Iinclude -D_internal_version_$(VERSION) -O0 -c -lang c -sdatathreshold 0
MWCCPSP_FLAGS := -gccinc -Iinclude -D_internal_version_$(VERSION) -Op -c -lang c -sdatathreshold 0
define list_src_files_psp
$(foreach dir,$(ASM_DIR)/$(1),$(wildcard $(dir)/**.s))

View File

@ -39,5 +39,6 @@ segments:
- [0x10AC, .rodata, 10E8] # func_80172120
- [0x10C4, .rodata, 10E8] # func_80174038
- [0x10E8, c, 10E8]
- [0x45C4, c, 45E4]
- [0x48B8, .bss, 10E8]
- [19852]

View File

@ -42,6 +42,7 @@ segments:
subalign: 8
subsegments:
- [0x80, c, 10E8]
- [0x48C8, c, 45E4]
- [0x4C80, data]
- [0x5E00, data] # rodata, not data
- {type: bss, vram: 0x092ed480}

View File

@ -39,5 +39,6 @@ segments:
- [0x10AC, .rodata, 10E8] # func_80172120
- [0x10C4, .rodata, 10E8] # func_80174038
- [0x10E8, c]
- [0x45E4, c]
- [0x48D8, .bss, 10E8]
- [0xA000]

View File

@ -45,6 +45,19 @@ g_Events = 0x092ECA28;
g_EventQueue = 0x092ed358;
g_ServantDesc = 0x092ED360;
D_801748D8 = 0x092ED480;
D_80174B30 = 0x092ED6E8;
D_80174B34 = 0x092ED6F0;
D_80174B38 = 0x092ED6F8;
D_80174B3C = 0x092ED700;
D_80174B40 = 0x092ED708;
D_80174B44 = 0x092ED710;
D_80174B48 = 0x092ED718;
D_80174B4C = 0x092ED720;
D_80174B8C = 0x092ED760;
D_80174BCC = 0x092ED7A0;
D_80174BEC = 0x092ED7C0;
D_80174C0C = 0x092ED7E0;
D_80174C2C = 0x092ED800;
g_CurrentServant = 0x092ed808;
g_CurrentRoomX = 0x092ed810;
g_CurrentRoomY = 0x092ed818;

View File

@ -12,6 +12,7 @@ g_Player = 0x91CF030;
g_Player_pl_vram_flag = 0x91CF380;
g_Player_unk50 = 0x91CF3D0;
g_Player_unk52 = 0x91CF3D2;
g_Status = 0x091CF400;
g_api_FreePrimitives = 0x091cf778;
g_api_AllocPrimitives = 0x091cf77c;
g_api_PlaySfx = 0x091cf7a0;
@ -35,3 +36,4 @@ PLAYER_step_s = 0x91E16AE;
g_Clut = 0x091F5DF8;
g_Clut_2800 = 0x091F85F8;
g_Clut_2860 = 0x091F8658;
g_CastleFlags = 0x09234730;

View File

@ -1,4 +1,5 @@
g_StageId = 0x091CE5B8;
g_Servant = 0x091CF028;
g_Player = 0x091CF030;
g_api = 0x091CF738;
g_PrimBuf = 0x091CFAF8;

View File

@ -1281,7 +1281,8 @@ typedef struct {
/* 8003C7B8 */ s16 (*AllocPrimitives)(PrimitiveType type, s32 count);
/* 8003C7BC */ void (*CheckCollision)(s32 x, s32 y, Collider* res, s32 unk);
/* 8003C7C0 */ void (*func_80102CD8)(s32 arg0);
/* 8003C7C4 */ void (*UpdateAnim)(FrameProperty* frameProps, s32* arg1);
/* 8003C7C4 */ void (*UpdateAnim)(
FrameProperty* frameProps, AnimationFrame** anims);
/* 8003C7C8 */ void (*SetSpeedX)(s32 value);
/* 8003C7CC */ Entity* (*GetFreeEntity)(s16 start, s16 end);
/* 8003C7D0 */ void (*GetEquipProperties)(

View File

@ -29,15 +29,15 @@ typedef struct {
typedef struct ServantEvent {
/* 0x00 */ struct ServantEvent* next; // next event in the queue
/* 0x04 */ u32 timer; // internal timer from 'delay' to the activation 0
/* 0x08 */ u32 servantId; // the familiar ID that can trigger the event
/* 0x08 */ s32 servantId; // the familiar ID that can trigger the event
/* 0x0C */ s32 roomX; // only activate in the specified room coords...
/* 0x10 */ u32 roomY; // ... where on X negative is the inverted castle
/* 0x14 */ u32 cameraX; // only activate on the camera coordinate...
/* 0x18 */ u32 cameraY; // ...within the room
/* 0x10 */ s32 roomY; // ... where on X negative is the inverted castle
/* 0x14 */ s32 cameraX; // only activate on the camera coordinate...
/* 0x18 */ s32 cameraY; // ...within the room
/* 0x1C */ s32 condition; // condition for the event
/* 0x20 */ u32 delay; // after how many frames the event is triggered
/* 0x24 */ u32 entityId; // ID of the entity to spawn
/* 0x28 */ u32 params; // parameters of the entity to spawn
/* 0x24 */ s32 entityId; // ID of the entity to spawn
/* 0x28 */ s32 params; // parameters of the entity to spawn
/* 0x2C */ u32 unk2C;
} ServantEvent;

View File

@ -229,8 +229,7 @@ void func_8010DBFC(s8* frameProps, s32* frames) {
// FrameProperty* but anything besides this where we assign this big
// expression fails.
// Please check function u32 UpdateAnim(s8* frameProps, s32* frames)
// down below
// Please check function UpdateAnim down below
frameProps = &frameProps[animFrame->unk2 >> 9 << 2];
g_CurrentEntity->hitboxOffX = *frameProps++;
g_CurrentEntity->hitboxOffY = *frameProps++;
@ -240,7 +239,7 @@ void func_8010DBFC(s8* frameProps, s32* frames) {
g_CurrentEntity->animCurFrame = animFrame->unk2 & 0x1FF;
}
u32 UpdateAnim(s8* frameProps, s32* frames) {
u32 UpdateAnim(s8* frameProps, AnimationFrame** anims) {
AnimationFrame* animFrame;
s32 ret;
@ -264,7 +263,7 @@ u32 UpdateAnim(s8* frameProps, s32* frames) {
g_CurrentEntity->animFrameDuration = -1;
ret = -1;
} else if (animFrame->duration == 0xFFFE) {
g_CurrentEntity->unk4C = frames[animFrame->unk2];
g_CurrentEntity->unk4C = anims[animFrame->unk2];
g_CurrentEntity->animFrameIdx = 0;
ret = -2;
g_CurrentEntity->animFrameDuration =

View File

@ -125,7 +125,7 @@ void func_8011A4D0(void) {
DestroyEntity(entity);
} else {
if (entity->flags & 0x100000) {
UpdateAnim(NULL, (s32*)D_800ACFB4);
UpdateAnim(NULL, D_800ACFB4);
}
}
}

View File

@ -391,7 +391,7 @@ extern unkstruct_800ACF7C D_800ACF7C[];
extern s16 D_800ACF84[8]; // collection of sounds
extern s16 D_800ACF94[];
extern u8 D_800AD094[0x30];
extern u8 D_800ACFB4[][4];
extern u8 D_800ACFB4[][4]; // TODO AnimationFrames*[]
extern unkstr_800cfe48* D_800CFE48[];
extern PfnEntityUpdate D_800AD0C4[];
extern FactoryBlueprint g_FactoryBlueprints[];
@ -883,7 +883,7 @@ void func_801073C0(void);
void func_801092E8(s32);
void SetPrimRect(Primitive* poly, s32 x, s32 y, s32 width, s32 height);
void SetPlayerStep(PlayerSteps step);
u32 UpdateAnim(s8* frameProps, s32*);
u32 UpdateAnim(s8* frameProps, AnimationFrame** anims);
void func_8010DFF0(s32, s32);
void func_8010E0A8(void);
void func_8010E0B8(void);

View File

@ -12,7 +12,7 @@ void FreePrimitives(s32 primitiveIndex);
s32 AllocPrimitives(u8 primType, s32 count);
void CheckCollision(s32 x, s32 y, Collider* res, s32 unk);
void func_80102CD8(s32 start);
u32 UpdateAnim(s8* frameProps, s32* frames);
u32 UpdateAnim(s8* frameProps, AnimationFrame** anims);
void SetSpeedX(s32 speed);
Entity* GetFreeEntity(s16 start, s16 end);
void GetEquipProperties(s32 handId, Equipment* res, s32 equipId);

View File

@ -641,7 +641,7 @@ block_48:
if ((g_Player.D_80072F00[13] | g_Player.D_80072F00[14]) != 0) {
g_Player.unk0C |= 0x100;
}
g_api.UpdateAnim(&D_80155964, &D_8015538C);
g_api.UpdateAnim(D_80155964, D_8015538C);
PLAYER.hitboxState = 1;
PLAYER.unk44 = 0;
PLAYER.hitPoints = 0;

View File

@ -1421,7 +1421,7 @@ void func_801603C4(void) {
(u16)(entity->posY.i.hi + 16) > 272)) {
DestroyEntity(entity);
} else if (entity->flags & 0x100000) {
g_api.UpdateAnim(0, (s32*)D_80154674);
g_api.UpdateAnim(0, D_80154674);
}
}
}

View File

@ -128,7 +128,7 @@ extern u16 D_80154644[4];
extern u16 D_8015464C[8];
extern u16 D_8015465C[4];
extern u16 D_80154664[8];
extern u8 D_80154674[][4];
extern u8 D_80154674[][4]; // TODO AnimationFrames*[]
extern SubweaponDef D_80154688[];
extern u8 D_801548F4[6][8];
extern AnimationFrame* D_80154924;
@ -155,7 +155,7 @@ extern s32 D_80154EC4[];
extern unkStr80154E5C D_80154E5C[];
extern s16 D_8015519C[][6];
extern s16 D_80155364[];
extern s32 D_8015538C;
extern AnimationFrame* D_8015538C[];
extern AnimationFrame* D_80155394;
extern AnimationFrame* D_8015539C;
extern AnimationFrame* D_801553BC;
@ -201,7 +201,7 @@ extern AnimationFrame D_801558E4[];
extern AnimationFrame* D_801558DC;
extern AnimationFrame* D_8015591C;
extern AnimationFrame* D_80155950;
extern FrameProperty D_80155964;
extern FrameProperty D_80155964[];
extern Point16 D_801559AC[];
extern Point16 D_801559C8[];
extern Point16 D_801559E4[];

View File

@ -67,12 +67,45 @@ ServantDesc g_ServantDesc = {
#endif
#ifdef VERSION_PSP
extern s32 D_80174D3C;
extern FamiliarStats D_80174C30;
extern s32 D_801748D8[0x80];
extern Collider D_80174AD8;
extern s16 D_80174AFC;
extern s16 D_80174B00;
extern s16 D_80174B04;
extern s16 D_80174B08;
extern s16 D_80174B0C;
extern s16 D_80174B10;
extern s16 D_80174B14;
extern s16 D_80174B18;
extern s32 D_80174B1C;
extern s32 D_80174B20;
extern s32 D_80174B24;
extern s32 D_80174B28;
extern s32 D_80174B2C;
extern s32 D_80174B2C;
extern s32 D_80174B30;
extern s32 D_80174B34;
extern s16 D_80174B38;
extern s16 D_80174B3C;
extern s16 D_80174B40;
extern s16 D_80174B44;
extern Primitive* D_80174B48;
extern s32 D_80174B4C[16];
extern Point16 D_80174B8C[16];
extern s16 D_80174BCC[16];
extern s16 D_80174BEC[16];
extern s16 D_80174C0C[16];
extern s32 D_80174C2C;
extern FamiliarStats D_80174C30;
extern Point16 D_80174C3C[4][16];
extern s32 D_801748D8[0x80];
extern s32 D_80174D3C;
extern s32 D_80174D40;
void DestroyEntity(Entity* entity);
void ProcessEvent(Entity* self, bool resetEvent);
void CreateEventEntity(Entity* entityParent, s32 entityId, s32 params);
#endif
void func_801710E8(Entity* entity, AnimationFrame* anim) {
@ -83,9 +116,6 @@ void func_801710E8(Entity* entity, AnimationFrame* anim) {
}
}
#ifdef VERSION_PSP
INCLUDE_ASM("servant/tt_000/nonmatchings/10E8", func_8017110C);
#else
Entity* func_8017110C(Entity* self) {
const int EntitySearchCount = 128;
s32 foundIndex;
@ -93,8 +123,6 @@ Entity* func_8017110C(Entity* self) {
u32 found;
Entity* e;
s32 distance;
s32 entityX;
s32 selfX;
found = 0;
e = &g_Entities[STAGE_ENTITY_START];
@ -109,7 +137,6 @@ Entity* func_8017110C(Entity* self) {
if (e->flags & FLAG_UNK_00200000) {
continue;
}
entityX = e->posX.i.hi;
if (e->posX.i.hi < -0x10) {
continue;
}
@ -125,23 +152,14 @@ Entity* func_8017110C(Entity* self) {
if (e->hitboxState & 8 && !D_80170658[D_80174C30.level / 10][4]) {
continue;
}
selfX = self->posX.i.hi;
distance = self->posX.i.hi - entityX;
if (distance < 0) {
distance = -distance;
if (abs(self->posX.i.hi - e->posX.i.hi) < 64 &&
abs(self->posY.i.hi - e->posY.i.hi) < 64) {
continue;
}
if (distance < 64) {
distance = self->posY.i.hi - e->posY.i.hi;
if (distance < 0) {
distance = -distance;
}
if (distance < 64) {
continue;
}
if (!self->facingLeft && self->posX.i.hi < e->posX.i.hi) {
continue;
}
if ((self->facingLeft ? entityX < selfX : selfX < entityX) != 0) {
if (self->facingLeft && self->posX.i.hi > e->posX.i.hi) {
continue;
}
if (e->hitPoints >= 0x7000) {
@ -173,7 +191,6 @@ Entity* func_8017110C(Entity* self) {
return NULL;
}
#endif
s32 func_801713C8(Entity* entity) {
if (entity->hitboxState == 0)
@ -654,7 +671,7 @@ void func_80172120(Entity* self) {
<< 0xC) >>
0xC;
if (D_80174B2C < 0x18) {
if (self->ext.bat.unk8E != 0) {
if (self->ext.bat.unk8E) {
self->ext.bat.unk8E = 0;
func_801710E8(self, D_8017054C);
}
@ -663,7 +680,7 @@ void func_80172120(Entity* self) {
self->ext.bat.unk8C) {
self->ext.bat.unk8C = 0;
self->ext.bat.target = func_8017110C(self);
if (self->ext.bat.target != 0) {
if (self->ext.bat.target) {
self->step++;
}
}
@ -780,7 +797,7 @@ void func_80172C30(Entity* self) {
switch (self->step) {
case 0:
func_801719E0(self);
if (self->ext.bat.unk82 == 0) {
if (!self->ext.bat.unk82) {
func_8017160C(D_80170658[D_80174C30.level / 10][2], 0xD2);
}
break;
@ -798,28 +815,30 @@ void func_80172C30(Entity* self) {
self->posX.val += self->velocityX;
self->posY.val += self->velocityY;
if ((self->velocityX == 0) && (self->velocityY == 0)) {
if (self->ext.bat.unk8E != 0) {
if (self->ext.bat.unk8E) {
func_801710E8(self, D_8017054C);
self->ext.bat.unk8E = 0;
self->ext.bat.unk8E = false;
}
} else {
if (self->velocityY > FIX(1)) {
func_801710E8(self, &D_801705EC);
func_801710E8(self, D_801705EC);
} else {
func_801710E8(self, &D_801704A8);
func_801710E8(self, D_801704A8);
}
self->ext.bat.unk8E = 1;
self->ext.bat.unk8E = true;
}
self->facingLeft = PLAYER.facingLeft == 0;
if (self->ext.bat.unkA8 == 0) {
self->facingLeft = PLAYER.facingLeft ? false : true;
if (!self->ext.bat.unkA8) {
if (g_Player.unk0C & 0x800) {
// This causes the bat familiar to shoot a fireball when the
// player does so in bat form.
g_api.CreateEntFactoryFromEntity(self, FACTORY(0x100, 81), 0);
self->ext.bat.unkA8 = 1;
}
} else if (!(g_Player.unk0C & 0x800)) {
self->ext.bat.unkA8 = 0;
} else if (self->ext.bat.unkA8) {
if (!(g_Player.unk0C & 0x800)) {
self->ext.bat.unkA8 = 0;
}
}
D_80174B38 = self->ext.bat.follow->posX.i.hi - self->posX.i.hi;
D_80174B3C = self->ext.bat.follow->posY.i.hi - self->posY.i.hi;
@ -827,7 +846,7 @@ void func_80172C30(Entity* self) {
SquareRoot12(((D_80174B38 * D_80174B38) + (D_80174B3C * D_80174B3C))
<< 0xC) >>
0xC;
if ((func_801746A0(0) != 0) || (D_80174B34 >= 0x19)) {
if (func_801746A0(0) || D_80174B34 >= 0x19) {
for (D_80174B30 = 0; D_80174B30 < 0xF; D_80174B30++) {
D_80174C3C[self->ext.bat.unk82][D_80174B30].x =
D_80174C3C[self->ext.bat.unk82][D_80174B30 + 1].x;
@ -845,14 +864,15 @@ void func_80172C30(Entity* self) {
}
break;
case 2:
if (++self->ext.bat.unk8C == 1) {
if (self->ext.bat.unk82 == 0) {
self->ext.bat.unk8C++;
if (self->ext.bat.unk8C == 1) {
if (!self->ext.bat.unk82) {
g_api.PlaySfx(SFX_BAT_SCREECH);
}
func_8017170C(self, 2);
} else if (self->ext.bat.unk8C >= 0x1F) {
func_8017170C(self, 0);
if (self->ext.bat.unk82 == 0) {
if (!self->ext.bat.unk82) {
self->entityId = 0xD1;
self->step = 0;
break;
@ -861,7 +881,7 @@ void func_80172C30(Entity* self) {
D_80174C3C[self->ext.bat.unk82][0].x =
PLAYER.facingLeft ? -0x80 : 0x180;
D_80174C3C[self->ext.bat.unk82][0].y = rand() % 256;
func_801710E8(self, &D_801704A8);
func_801710E8(self, D_801704A8);
}
break;
case 3:
@ -897,9 +917,6 @@ void func_801733C4(void) {}
void func_801733CC(void) {}
#ifdef VERSION_PSP
INCLUDE_ASM("servant/tt_000/nonmatchings/10E8", func_801733D4);
#else
void func_801733D4(Entity* self) {
const s32 nPrim = 16;
const s32 XS = 11; // X start, left
@ -944,8 +961,7 @@ void func_801733D4(Entity* self) {
D_80174BEC[D_80174C2C] = 256;
D_80174C0C[D_80174C2C] = 192;
D_80174B4C[D_80174C2C] = 1;
D_80174C2C++;
D_80174C2C = D_80174C2C >= nPrim ? 0 : D_80174C2C;
D_80174C2C = ++D_80174C2C >= nPrim ? 0 : D_80174C2C;
D_80174B48 = &g_PrimBuf[self->primIndex];
for (i = 0; i < nPrim; i++) {
if (D_80174B4C[i]) {
@ -1031,7 +1047,6 @@ void func_801733D4(Entity* self) {
break;
}
}
#endif
void func_80173C0C(void) {}
@ -1146,12 +1161,7 @@ s16 func_80173F30(Entity* entity, s16 x, s16 y) {
}
s16 func_80173F74(s16 x1, s16 x2, s16 minDistance) {
#ifdef VERSION_PSP
s16 diff = abs(x2 - x1);
#else
s32 diffTmp = x2 - x1;
s16 diff = abs(diffTmp);
#endif
if (minDistance > diff) {
minDistance = diff;
}
@ -1252,9 +1262,6 @@ void func_80174038(Entity* entity) {
}
#endif
#ifdef VERSION_PSP
INCLUDE_ASM("servant/tt_000/nonmatchings/10E8", ProcessEvent);
#else
extern ServantEvent g_Events[];
extern ServantEvent* g_EventQueue;
extern u32 g_CurrentServant;
@ -1263,10 +1270,10 @@ extern s32 g_CurrentRoomY;
// Trigger an event under certain specific set of conditions
void ProcessEvent(Entity* self, bool resetEvent) {
ServantEvent* evt;
ServantEvent* queue;
s32 cameraY;
s32 cameraX;
s32 temp_v0;
s32 cameraY;
s32 i;
if (resetEvent) {
@ -1281,12 +1288,12 @@ void ProcessEvent(Entity* self, bool resetEvent) {
// Ensures the following block is only evaluated once per room
if (g_CurrentServant != g_Servant || g_CurrentRoomX != g_Tilemap.left ||
g_CurrentRoomY != g_Tilemap.top) {
queue = g_EventQueue;
g_CurrentServant = g_Servant;
g_CurrentRoomX = g_Tilemap.left;
g_CurrentRoomY = g_Tilemap.top;
queue = g_EventQueue;
for (i = 1; g_Events[i].roomX != -1; i++) {
ServantEvent* evt = &g_Events[i];
evt = &g_Events[i];
// Filter by familiar
if (evt->servantId != -1 && evt->servantId != g_CurrentServant) {
continue;
@ -1301,7 +1308,7 @@ void ProcessEvent(Entity* self, bool resetEvent) {
}
if (!(g_StageId & STAGE_INVERTEDCASTLE_FLAG)) {
block_13:
#elif defined(VERSION_HD)
#elif defined(VERSION_HD) || defined(VERSION_PSP)
if (evt->roomX >= 0 ||
(g_StageId >= STAGE_RNO0 && g_StageId < STAGE_RNZ1_DEMO)) {
#endif
@ -1312,53 +1319,50 @@ void ProcessEvent(Entity* self, bool resetEvent) {
if (evt->cameraX == cameraX && evt->cameraY == cameraY &&
(evt->condition == -1 ||
(evt->condition >= 0 ||
g_CastleFlags[evt->condition & 0xFFFF] == 0) &&
(!(evt->condition & 0x80000000) ||
!g_CastleFlags[evt->condition & 0xFFFF]) &&
(!(evt->condition & CHECK_RELIC_FLAG) ||
!(g_Status.relics[evt->condition & 0xFFFF] &
RELIC_FLAG_FOUND)))) {
evt->timer = 0;
if (evt->delay == 0) {
CreateEventEntity(self, evt->entityId, evt->params);
if (!evt->unk2C) {
goto block_26;
if (evt->unk2C) {
continue;
}
} else {
goto block_27;
}
} else {
block_26:
if (evt->delay > 0) {
block_27:
evt->timer = evt->delay - 1;
}
queue->next = evt;
queue = evt;
}
if (evt->delay > 0) {
evt->timer = evt->delay - 1;
}
queue->next = evt;
queue = evt;
}
}
queue->next = NULL;
} else {
queue = g_EventQueue;
while (queue->next != NULL) {
ServantEvent* evt = queue->next;
if (evt->cameraX == cameraX && evt->cameraY == cameraY &&
(evt->condition == -1 ||
(evt->condition >= 0 ||
g_CastleFlags[evt->condition & 0xFFFF] == 0) &&
(!(evt->condition & CHECK_RELIC_FLAG) ||
!(g_Status.relics[evt->condition & 0xFFFF] & 1)))) {
evt = queue->next;
if (evt->timer > 0) {
evt->timer--;
if (!evt->delay) {
}
if (queue->next->cameraX == cameraX &&
queue->next->cameraY == cameraY &&
(queue->next->condition == -1 ||
(!(queue->next->condition & 0x80000000) ||
!g_CastleFlags[queue->next->condition & 0xFFFF]) &&
(!(queue->next->condition & CHECK_RELIC_FLAG) ||
!(g_Status.relics[queue->next->condition & 0xFFFF] &
1)))) {
if (queue->next->timer > 0) {
queue->next->timer--;
} else {
CreateEventEntity(self, evt->entityId, evt->params);
evt = queue->next;
if (evt->unk2C) {
queue->next = evt->next;
CreateEventEntity(
self, queue->next->entityId, queue->next->params);
if (queue->next->unk2C) {
queue->next = queue->next->next;
continue;
} else {
evt->timer = evt->delay;
queue->next->timer = queue->next->delay;
}
}
}
@ -1366,113 +1370,3 @@ void ProcessEvent(Entity* self, bool resetEvent) {
}
}
}
#endif
void CreateEventEntity(Entity* entityParent, s32 entityId, s32 params) {
Entity* entity;
s32 i;
for (i = 0; i < 3; i++) {
entity = &g_Entities[5 + i];
if (!entity->entityId) {
break;
}
}
if (!entity->entityId) {
DestroyEntity(entity);
entity->entityId = entityId;
entity->zPriority = entityParent->zPriority;
entity->facingLeft = entityParent->facingLeft;
entity->flags = FLAG_UNK_04000000;
entity->posX.val = entityParent->posX.val;
entity->posY.val = entityParent->posY.val;
entity->ext.generic.unk8C.entityPtr = entityParent;
entity->params = params;
}
}
s32 func_801746A0(s32 arg0) {
if (PLAYER.velocityY < 0 && !(g_Player.pl_vram_flag & 1)) {
return 1;
}
if (PLAYER.velocityY > 0 && !(g_Player.pl_vram_flag & 2)) {
return 1;
}
if (PLAYER.velocityX < 0 && !(g_Player.pl_vram_flag & 8))
return 1;
if (PLAYER.velocityX > 0 && !(g_Player.pl_vram_flag & 4))
return 1;
if (arg0 == 0)
return 0;
if (g_Player.unk50 != PLAYER.step || PLAYER.step != 0)
return 1;
if (g_Player.unk52 != PLAYER.step_s)
return 1;
if (PLAYER.step_s != 0 && PLAYER.step_s != 4)
return 1;
return 0;
}
#ifndef VERSION_PSP
s32 func_801747B8(void) {
Entity* entity;
s32 i;
entity = &g_Entities[STAGE_ENTITY_START];
for (i = 0; i < 0x80; i++, entity++) {
if (entity->entityId == 0)
continue;
if (entity->hitboxState == 0)
continue;
if (entity->flags & FLAG_UNK_00200000)
continue;
if (entity->posX.i.hi < -16)
continue;
if (entity->posX.i.hi > 272)
continue;
if (entity->posY.i.hi > 240)
continue;
if (entity->posY.i.hi < 0)
continue;
if (entity->hitPoints < 0x7000)
return 1;
}
return 0;
}
#endif
s32 func_80174864(void) {
if (g_StageId >= STAGE_RNO0 && g_StageId < STAGE_RNZ1_DEMO) {
if (D_8003C708.flags == 0x22) {
return 1;
}
if (D_8003C708.flags == 0x20) {
return 0;
}
return 2;
} else {
if (D_8003C708.flags == 0x22) {
return 0;
}
if (D_8003C708.flags == 0x20) {
return 1;
}
return 2;
}
}
#ifdef VERSION_PSP
void func_092EC220(void) {
memcpy((u8*)&D_8D1DC40, (u8*)&g_ServantDesc, sizeof(ServantDesc));
}
#endif

112
src/servant/tt_000/45E4.c Normal file
View File

@ -0,0 +1,112 @@
#include <servant.h>
#include <sfx.h>
#include <psxsdk/libc.h>
void CreateEventEntity(Entity* entityParent, s32 entityId, s32 params) {
Entity* entity;
s32 i;
for (i = 0; i < 3; i++) {
entity = &g_Entities[5 + i];
if (!entity->entityId) {
break;
}
}
if (!entity->entityId) {
DestroyEntity(entity);
entity->entityId = entityId;
entity->zPriority = entityParent->zPriority;
entity->facingLeft = entityParent->facingLeft;
entity->flags = FLAG_UNK_04000000;
entity->posX.val = entityParent->posX.val;
entity->posY.val = entityParent->posY.val;
entity->ext.generic.unk8C.entityPtr = entityParent;
entity->params = params;
}
}
s32 func_801746A0(s32 arg0) {
if (PLAYER.velocityY < 0 && !(g_Player.pl_vram_flag & 1)) {
return 1;
}
if (PLAYER.velocityY > 0 && !(g_Player.pl_vram_flag & 2)) {
return 1;
}
if (PLAYER.velocityX < 0 && !(g_Player.pl_vram_flag & 8))
return 1;
if (PLAYER.velocityX > 0 && !(g_Player.pl_vram_flag & 4))
return 1;
if (arg0 == 0)
return 0;
if (g_Player.unk50 != PLAYER.step || PLAYER.step != 0)
return 1;
if (g_Player.unk52 != PLAYER.step_s)
return 1;
if (PLAYER.step_s != 0 && PLAYER.step_s != 4)
return 1;
return 0;
}
#ifndef VERSION_PSP
s32 func_801747B8(void) {
Entity* entity;
s32 i;
entity = &g_Entities[STAGE_ENTITY_START];
for (i = 0; i < 0x80; i++, entity++) {
if (entity->entityId == 0)
continue;
if (entity->hitboxState == 0)
continue;
if (entity->flags & FLAG_UNK_00200000)
continue;
if (entity->posX.i.hi < -16)
continue;
if (entity->posX.i.hi > 272)
continue;
if (entity->posY.i.hi > 240)
continue;
if (entity->posY.i.hi < 0)
continue;
if (entity->hitPoints < 0x7000)
return 1;
}
return 0;
}
#endif
s32 func_80174864(void) {
if (g_StageId >= STAGE_RNO0 && g_StageId < STAGE_RNZ1_DEMO) {
if (D_8003C708.flags == 0x22) {
return 1;
}
if (D_8003C708.flags == 0x20) {
return 0;
}
return 2;
} else {
if (D_8003C708.flags == 0x22) {
return 0;
}
if (D_8003C708.flags == 0x20) {
return 1;
}
return 2;
}
}
#ifdef VERSION_PSP
void func_092EC220(void) {
memcpy((u8*)&D_8D1DC40, (u8*)&g_ServantDesc, sizeof(ServantDesc));
}
#endif