Skip to content

Commit

Permalink
PSP ST0 DrawCutsceneActorName
Browse files Browse the repository at this point in the history
  • Loading branch information
Xeeynamo committed Jan 11, 2025
1 parent ead48b4 commit 29dc1f5
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 18 deletions.
4 changes: 4 additions & 0 deletions config/symbols.pspeu.stst0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ func_801B0280 = 0x09237B18;
SetTitleDisplayBuffer = 0x09237BC0;
func_801B0414 = 0x09237CB8;
PrologueScroll = 0x09237D10;
DrawCutsceneActorName = 0x09238BF8;
ST0_EntityCutscene = 0x092396A0;
EntitySecretButton = 0x0923B5D8;
EntitySecretStairsCeiling = 0x0923B950;
Expand Down Expand Up @@ -142,6 +143,7 @@ explode_lifetime = 0x09279610;
g_eDamageDisplayClut = 0x09279978;
eRoomForegroundInit = 0x092799B0;
D_80180908 = 0x09279DA0;
g_Dialogue = 0x0927BA58;
D_801BEE0C = 0x0927BAB0;
D_801BEE08 = 0x0927BAB8;
D_801BEE04 = 0x0927BAC0;
Expand All @@ -153,3 +155,5 @@ g_LayoutObjPosHorizontal = 0x0927BAE8;
g_LayoutObjVertical = 0x0927BAF0;
g_LayoutObjHorizontal = 0x0927BAF8;
g_ItemIconSlots = 0x0927BB00;
GetLang = 0x092377C8;
GetLangAt = 0x09237700;
4 changes: 4 additions & 0 deletions include/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -2079,4 +2079,8 @@ extern s32 D_800987C8;
extern s32 g_DebugPlayer;
extern s32 D_80098894;

// exclusive PSP content
u8* GetLangAt(s32 idx, u8* en, u8* fr, u8* sp, u8* ge, u8* it);
u8* GetLang(u8* en, u8* fr, u8* sp, u8* ge, u8* it);

#endif
26 changes: 13 additions & 13 deletions src/st/st0/title_card.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

#if defined(VERSION_PSP)
extern s32 D_80180908;
extern int D_pspeu_09253FB0;
extern int D_pspeu_09253FF0;
extern int D_pspeu_09254300;
extern int D_pspeu_092545D8;
extern int D_pspeu_092548E8;
extern int D_pspeu_09254BD8;
extern int D_pspeu_09254E98;
extern int D_pspeu_09254EA4;
extern u8 D_pspeu_09253FB0[];
extern u8 D_pspeu_09253FF0[];
extern u8 D_pspeu_09254300[];
extern u8 D_pspeu_092545D8[];
extern u8 D_pspeu_092548E8[];
extern u8 D_pspeu_09254BD8[];
extern u16 D_pspeu_09254E98[];
extern u8* D_pspeu_09254EA4;
#else
static s32 D_80180908 = 0;
#endif
Expand Down Expand Up @@ -217,11 +217,11 @@ void EntityStageTitleCard(Entity* self) {
}
InitializeEntity(g_EInit3DObject);
#if defined(VERSION_PSP)
D_pspeu_09254EA4 = func_pspeu_092377C8(
&D_pspeu_09253FF0, &D_pspeu_09254BD8, &D_pspeu_092545D8,
&D_pspeu_092548E8, &D_pspeu_09254300);
func_91040A0(&D_pspeu_09254E98);
func_892667C(0x8210, &D_pspeu_09253FB0);
D_pspeu_09254EA4 =
GetLang(D_pspeu_09253FF0, D_pspeu_09254BD8, D_pspeu_092545D8,
D_pspeu_092548E8, D_pspeu_09254300);
func_91040A0(D_pspeu_09254E98);
func_892667C(0x8210, D_pspeu_09253FB0);
#endif
primIndex = g_api.AllocPrimitives(PRIM_GT4, 8);
if (primIndex == -1) {
Expand Down
35 changes: 32 additions & 3 deletions src/st/st0_psp/80.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
#include "common.h"
#include <game.h>

INCLUDE_ASM("st/st0_psp/psp/st0_psp/80", func_pspeu_09237700);
extern s32 D_8B42058;
u8* GetLangAt(s32 idx, u8* en, u8* fr, u8* sp, u8* ge, u8* it) {
switch (D_8B42058) {
default:
case 1:
return en + idx;
case 2:
return fr + idx;
case 3:
return sp + idx;
case 4:
return ge + idx;
case 5:
return it + idx;
}
}

INCLUDE_ASM("st/st0_psp/psp/st0_psp/80", func_pspeu_092377C8);
u8* GetLang(u8* en, u8* fr, u8* sp, u8* ge, u8* it) {
switch (D_8B42058) {
default:
case 1:
return en;
case 2:
return fr;
case 3:
return sp;
case 4:
return ge;
case 5:
return it;
}
}
89 changes: 87 additions & 2 deletions src/st/st0_psp/cutscene.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,92 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
#include "common.h"
#include "../st0/st0.h"
#include <cutscene.h>

INCLUDE_ASM("st/st0_psp/psp/st0_psp/cutscene", func_pspeu_09238BF8);
extern Dialogue g_Dialogue;
extern u8 D_pspeu_09253C08[];
extern u8 D_pspeu_09253DE0[];
extern u8 D_pspeu_09253CA0[];
extern u8 D_pspeu_09253E78[];
extern u8 D_pspeu_09253D48[];
extern u8 D_pspeu_09253B80[];
extern u8 D_pspeu_09253D58[];
extern u8 D_pspeu_09253C18[];
extern u8 D_pspeu_09253DF0[];
extern u8 D_pspeu_09253CB0[];

void DrawCutsceneActorName(u16 actorIndex, Entity* self, u16* actorNames,
u8* arg3, s32* arg4, s32 nActors) {
Primitive* prim;
u16 ch;
u16 i;
s16 x;
u8* actorNameLength;
u16 actorNameStartIndex;
u16* actorName;
s32 primIndex;
u8* len;

// Create a certain amount of sprites based on the actor name's letter count
actorNameLength =
(u8*)GetLang(D_pspeu_09253C08, D_pspeu_09253DE0, D_pspeu_09253CA0,
D_pspeu_09253E78, D_pspeu_09253D48);
ch = actorNameLength[arg3[actorIndex]];
primIndex = g_api.AllocPrimitives(PRIM_SPRT, ch);
if (primIndex == -1) {
DestroyEntity(self);
return;
}

// Pre-calculate primitives that renders the actor's name
x = 0x38;
#if defined(VERSION_PSP)
g_Dialogue.primIndex[0] = primIndex;
#else
g_Dialogue.primIndex[1] = primIndex;
#endif
prim = &g_PrimBuf[primIndex];
len = actorNameLength;
actorNameStartIndex = 0;
for (i = 0; i < arg3[actorIndex]; i++) {
actorNameStartIndex += actorNameLength[i];
}
actorNames =
(u16*)GetLang(D_pspeu_09253B80, D_pspeu_09253D58, D_pspeu_09253C18,
D_pspeu_09253DF0, D_pspeu_09253CB0);
actorName = (u16*)(actorNames + actorNameStartIndex);
while (prim) {
prim->type = PRIM_SPRT;
prim->tpage = 0x1E;
prim->clut = 0x196;
ch = *actorName++;
prim->u0 = (s8)((ch & 0x0F) * FONT_W);
prim->v0 = (s8)((ch & 0xF0) >> 1);
prim->u1 = prim->v1 = FONT_W;
prim->priority = 0x1FF;
prim->drawMode = DRAW_HIDE;
prim->x0 = x;
prim->y0 = g_Dialogue.startY + 6;
if (ch & 0xF000) {
prim = prim->next;
prim->type = PRIM_SPRT;
prim->tpage = 0x1E;
prim->clut = 0x196;
if (ch & 0x4000) {
prim->u0 = 0x78;
} else {
prim->u0 = 0x70;
}
prim->v0 = 0x48;
prim->u1 = prim->v1 = FONT_W;
prim->priority = 0x1FF;
prim->drawMode = DRAW_HIDE;
prim->x0 = x;
prim->y0 = g_Dialogue.startY - 2;
}
x += FONT_GAP;
prim = prim->next;
}
}

INCLUDE_ASM("st/st0_psp/psp/st0_psp/cutscene", func_pspeu_09238F10);

Expand Down

0 comments on commit 29dc1f5

Please sign in to comment.