Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull DRA DrawHudSubweapon into PSP #2023

Merged
merged 3 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile.psp.mk
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ $(BUILD_DIR)/%.s.o: %.s
OPT_HIGH = -O4,p #need this because otherwise the comma breaks the if-statement
OPT_OVL = $(if $(findstring dra, $@), $(OPT_HIGH), -Op)
# Allow override. Any file in this list will get Op.
OPT_LO_OVERRIDES = 67F0.c.o 22A40.c.o 23FE0.c.o 32DA0.c.o 3AE30.c.o 60D80.c.o 60F10.c.o
OPT_LO_OVERRIDES = 67F0.c.o 86A0.c.o 22A40.c.o 23FE0.c.o 32DA0.c.o 3AE30.c.o 60D80.c.o 60F10.c.o
OPTIMIZATION = $(if $(filter $(notdir $@),$(OPT_LO_OVERRIDES)), -Op, $(OPT_OVL))

$(BUILD_DIR)/%.c.o: %.c $(MWCCPSP) $(MWCCGAP_APP)
Expand Down
2 changes: 2 additions & 0 deletions config/splat.pspeu.dra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ segments:
- [0x67E90, c, dra_psp/67E90]
- [0x680C0, c, dra_psp/680C0]
- [0x68D80, data]
- [0x6A8B8, .data, dra_psp/86A0] # Subwpn clut/u/v
- [0x6A8F8, data]
- [0x6DDE8, .data, dra_psp/186E8] # "\no\n"
- [0x6DDF0, .data, dra_psp/186E8] # func_psp_090F5188 strings
- [0x6DE50, data]
Expand Down
5 changes: 5 additions & 0 deletions config/symbols.pspeu.dra.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ func_801026BC = 0x090E28D0;
func_801027A4 = 0x090E29A8;
func_801027C4 = 0x090E29B0;
func_80102CD8 = 0x090E2EC8;
DrawRichterHudSubweapon = 0x090E5020;
DrawHudSubweapon = 0x090E62B8;
SetNextRoomToLoad = 0x090E73D0;
func_800F0CD8 = 0x090E74E8;
func_800F24F4 = 0x090E8B30;
Expand Down Expand Up @@ -149,6 +151,7 @@ ExecCdSoundCommands = 0x09143ED8;
CheckCollision = 0x09144C90;
g_ApiInit = 0x0914A628;
g_LevelHPIncrease = 0x09160B90;
D_800C52F8 = 0x09170960;
D_800AFDA4 = 0x0917C638;
g_DraEntityTbl = 0x09183838;
g_SubwpnDefs = 0x09190EC8;
Expand All @@ -157,6 +160,8 @@ D_8013799C = 0x091CDC70;
D_801379A0 = 0x091CDC74;
D_801379A4 = 0x091CDC78;
D_801379A8 = 0x091CDC7C;
g_PlayerHud = 0x091CDC90;
g_HealingMailTimer = 0x091CDCBC;
D_8013B5E8 = 0x091CDCC0;
D_80137598 = 0x091CDD38;
g_DebugWaitInfoTimer = 0x091CE268;
Expand Down
2 changes: 2 additions & 0 deletions config/symbols.pspeu.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ DrawSync = 0x0891B448;
VSync = 0x0891B5BC;
LoadImage = 0x0891BFE4;
ClearImage = 0x0891CA60;
LoadTPage = 0x0891CF3C;
ClearOTag = 0x0891D0E0;
PutDrawEnv = 0x0891D484;
PutDispEnv = 0x0891D68C;
Expand Down Expand Up @@ -70,5 +71,6 @@ g_Clut = 0x091F5DF8;
g_Clut_2800 = 0x091F85F8;
g_Clut_2860 = 0x091F8658;
g_GameTimer = 0x091FC460;
g_Timer = 0x091FC468;
g_CurrentBuffer = 0x091FC4E0;
g_CastleFlags = 0x09234730;
123 changes: 73 additions & 50 deletions src/dra/5F60C.c
Original file line number Diff line number Diff line change
Expand Up @@ -1027,9 +1027,9 @@ void DrawHudSubweapon() {
s32 statXPos;
s32 hpdiff;
s32 mpFillSteps;
s32 leading_zeros;
s32 digitSpacing;
u16 clut;
u32 clut;
u32 leading_zeros;

if (g_StageId == STAGE_ST0 || g_PlayableCharacter != PLAYER_ALUCARD) {
DrawRichterHudSubweapon();
Expand All @@ -1041,13 +1041,13 @@ void DrawHudSubweapon() {
prim->drawMode = DRAW_ABSPOS | DRAW_TPAGE2 | DRAW_TPAGE | DRAW_TRANSP;
prim = prim->next;
prim->p2--;
if (prim->p2 == 0) {
if (!prim->p2) {
prim->p1 += 1;
if (prim->p1 == 0xF) {
prim->p1 = 0;
prim->p2 = rand() + 8;
prim->p2 = (rand() & 0xFF) + 8;
prim->p3--;
if (prim->p3 != 0) {
if (prim->p3) {
prim->p1 = 1;
prim->p2 = 1;
} else {
Expand All @@ -1066,7 +1066,7 @@ void DrawHudSubweapon() {
prim->v3 = g_HudSubwpnSpriteV[prim->p1 - 1] + 16;
}
}
if (prim->p1 != 0) {
if (prim->p1) {
prim->drawMode = DRAW_ABSPOS;
} else {
prim->drawMode = DRAW_HIDE;
Expand Down Expand Up @@ -1106,9 +1106,8 @@ void DrawHudSubweapon() {
}

if ((CheckEquipmentItemCount(ITEM_HEALING_MAIL, EQUIP_ARMOR)) &&
((g_Player.status &
(PLAYER_STATUS_TRANSFORM | PLAYER_STATUS_UNK4000000)) ==
PLAYER_STATUS_UNK4000000)) {
(g_Player.status & PLAYER_STATUS_UNK4000000) &&
!(g_Player.status & PLAYER_STATUS_TRANSFORM)) {
g_HealingMailTimer[0]++;
if (g_HealingMailTimer[0] >= 128) {
g_Player.unk56 = 2;
Expand All @@ -1127,12 +1126,16 @@ void DrawHudSubweapon() {
mpFillSteps = (g_Status.mp * 50) / g_Status.mpMax;
LoadTPage(D_800C52F8[10] + 4, 0, 0, 0x3DC, 0x100, 8, mpFillSteps);
// Use one clut if MP is full, otherwise a different one
prim->clut = mpFillSteps == 50 ? 0x162 : 0x174;
if (mpFillSteps == 50) {
prim->clut = 0x162;
} else {
prim->clut = 0x174;
}

if (D_8013B5E8 == 0) {
hpdiff = g_Status.hp - g_PlayerHud.displayHP;
if (hpdiff > 0) {
if (hpdiff >= 11) {
if (hpdiff > 10) {
g_PlayerHud.displayHP += (hpdiff) / 10;
} else {
g_PlayerHud.displayHP++;
Expand All @@ -1156,29 +1159,31 @@ void DrawHudSubweapon() {
func_800EA5E4(1); // Normal health display
}

if (g_PlayerHud.displayHP >= 1000) {
if (g_PlayerHud.displayHP > 999) {
leading_zeros = 0;
digitSpacing = 6;
statXPos = 3;
} else if (g_PlayerHud.displayHP >= 100) {
} else if (g_PlayerHud.displayHP > 99) {
leading_zeros = 1;
digitSpacing = 6;
statXPos = 0;
statXPos = 6 - digitSpacing;
} else {
digitSpacing = 7;
statXPos = -6;
if (g_PlayerHud.displayHP >= 10) {
statXPos = 8 - digitSpacing * 2;
if (g_PlayerHud.displayHP > 9) {
leading_zeros = 2;
} else {
leading_zeros = 3;
}
}
// Thousands digit of HP
prim = prim->next;
prim->u2 = prim->u0 = ((g_PlayerHud.displayHP / 1000) * 8) + 0x20;
prim->u3 = prim->u1 = prim->u0 + 8;
prim->u0 = ((g_PlayerHud.displayHP / 1000) * 8) + 0x20;
prim->u2 = prim->u0;
prim->u1 = prim->u0 + 8;
prim->u3 = prim->u1;
prim->x0 = prim->x2 = statXPos;
prim->x1 = prim->x3 = statXPos + 8;
prim->x1 = prim->x3 = prim->x0 + 8;
prim->drawMode = DRAW_ABSPOS;

if (leading_zeros != 0) {
Expand All @@ -1187,63 +1192,74 @@ void DrawHudSubweapon() {
}
// Hundreds digit of HP
prim = prim->next;
prim->u2 = prim->u0 = (((g_PlayerHud.displayHP / 100) % 10) * 8) + 0x20;
prim->u3 = prim->u1 = prim->u0 + 8;
prim->u0 = (((g_PlayerHud.displayHP / 100) % 10) * 8) + 0x20;
prim->u2 = prim->u0;
prim->u1 = prim->u0 + 8;
prim->u3 = prim->u1;
prim->x0 = prim->x2 = statXPos + digitSpacing;
prim->x1 = prim->x3 = statXPos + digitSpacing + 8;
prim->x1 = prim->x3 = prim->x0 + 8;
prim->drawMode = DRAW_ABSPOS;
if (leading_zeros != 0) {
leading_zeros--;
prim->drawMode = DRAW_HIDE;
}
// Tens digit of HP
prim = prim->next;
prim->u2 = prim->u0 = (((g_PlayerHud.displayHP / 10) % 10) * 8) + 0x20;
prim->u3 = prim->u1 = prim->u0 + 8;
prim->u0 = (((g_PlayerHud.displayHP / 10) % 10) * 8) + 0x20;
prim->u2 = prim->u0;
prim->u1 = prim->u0 + 8;
prim->u3 = prim->u1;
prim->x0 = prim->x2 = statXPos + (digitSpacing * 2);
prim->x1 = prim->x3 = statXPos + (digitSpacing * 2) + 8;
prim->x1 = prim->x3 = prim->x0 + 8;
prim->drawMode = DRAW_ABSPOS;

if (leading_zeros != 0) {
leading_zeros--;
prim->drawMode = DRAW_HIDE;
}
// Ones digit of HP
prim = prim->next;
prim->u2 = prim->u0 = ((g_PlayerHud.displayHP % 10) * 8) + 0x20;
prim->u3 = prim->u1 = prim->u0 + 8;
prim->u0 = ((g_PlayerHud.displayHP % 10) * 8) + 0x20;
prim->u2 = prim->u0;
prim->u1 = prim->u0 + 8;
prim->u3 = prim->u1;
prim->x0 = prim->x2 = statXPos + (digitSpacing * 3);
prim->x1 = prim->x3 = statXPos + (digitSpacing * 3) + 8;
prim->x1 = prim->x3 = prim->x0 + 8;

if (g_Status.hearts >= 1000) {
if (g_Status.hearts > 999) {
leading_zeros = 0;
statXPos = 0x3B;
} else if (g_Status.hearts >= 100) {
} else if (g_Status.hearts > 99) {
leading_zeros = 1;
statXPos = 0x37;
} else {
statXPos = 0x33;
if (g_Status.hearts >= 10) {
if (g_Status.hearts > 9) {
leading_zeros = 2;
} else {
leading_zeros = 3;
}
}

// Seems like this should be a simple || but that doesn't work here.
if (func_800FE3C4(&subwpn, 0, false) == 0) {
clut = 0x196;
} else if (g_Timer & 2) {
clut = 0x196;
if (func_800FE3C4(&subwpn, 0, false)) {
// Enable flickering with g_Timer
if (g_Timer & 2) {
clut = 0x196;
} else {
clut = 0x193;
}
} else {
clut = 0x193;
clut = 0x196;
}

// Thousands digit of hearts
prim = prim->next;
prim->u2 = prim->u0 = ((g_Status.hearts / 1000) * 8) + 0x20;
prim->u3 = prim->u1 = prim->u0 + 8;
prim->u0 = ((g_Status.hearts / 1000) * 8) + 0x20;
prim->u2 = prim->u0;
prim->u1 = prim->u0 + 8;
prim->u3 = prim->u1;
prim->x0 = prim->x2 = statXPos;
prim->x1 = prim->x3 = statXPos + 8;
prim->x1 = prim->x3 = prim->x0 + 8;
prim->drawMode = DRAW_ABSPOS;
prim->clut = clut;
if (leading_zeros != 0) {
Expand All @@ -1252,10 +1268,12 @@ void DrawHudSubweapon() {
}
// Hundreds digit of hearts
prim = prim->next;
prim->u2 = prim->u0 = (((g_Status.hearts / 100) % 10) * 8) + 0x20;
prim->u3 = prim->u1 = prim->u0 + 8;
prim->u0 = (((g_Status.hearts / 100) % 10) * 8) + 0x20;
prim->u2 = prim->u0;
prim->u1 = prim->u0 + 8;
prim->u3 = prim->u1;
prim->x0 = prim->x2 = statXPos + 4;
prim->x1 = prim->x3 = statXPos + 0xC;
prim->x1 = prim->x3 = prim->x0 + 8;
prim->drawMode = DRAW_ABSPOS;
prim->clut = clut;
if (leading_zeros != 0) {
Expand All @@ -1264,20 +1282,25 @@ void DrawHudSubweapon() {
}
// Tens digit of hearts
prim = prim->next;
prim->u2 = prim->u0 = (((g_Status.hearts / 10) % 10) * 8) + 0x20;
prim->u3 = prim->u1 = prim->u0 + 8;
prim->u0 = (((g_Status.hearts / 10) % 10) * 8) + 0x20;
prim->u2 = prim->u0;
prim->u1 = prim->u0 + 8;
prim->u3 = prim->u1;
prim->x0 = prim->x2 = statXPos + 8;
prim->x1 = prim->x3 = statXPos + 0x10;
prim->x1 = prim->x3 = prim->x0 + 8;
prim->drawMode = DRAW_ABSPOS;
prim->clut = clut;
if (leading_zeros != 0) {
leading_zeros--;
prim->drawMode = DRAW_HIDE;
}
// Ones digit of hearts
prim = prim->next;
prim->u2 = prim->u0 = ((g_Status.hearts % 10) * 8) + 0x20;
prim->u3 = prim->u1 = prim->u0 + 8;
prim->x0 = prim->x2 = statXPos + 0xC;
prim->x1 = prim->x3 = statXPos + 0x14;
prim->u0 = ((g_Status.hearts % 10) * 8) + 0x20;
prim->u2 = prim->u0;
prim->u1 = prim->u0 + 8;
prim->u3 = prim->u1;
prim->x0 = prim->x2 = statXPos + 12;
prim->x1 = prim->x3 = prim->x0 + 8;
prim->clut = clut;
}
Loading
Loading