Decompile DRA DrawRelicsMenu (#596)

This has some annoying version differences but I made it work. Tried to
document variables and spots in code that I could identify, such as
taking the liberty of naming g_RelicMenuFadeTimer.

This one was really tricky, there are a ton of variables being assigned
all over and different registers doing different things, it's cool to
have this working, and especially working across two different game
versions.

I think the ifdef was done as well as I can, nice to only need to have a
single statement (by including the INDEXER). Let me know if there is a
better way!

Cheers!
This commit is contained in:
bismurphy 2023-09-15 22:20:28 -04:00 committed by GitHub
parent 6cf0290319
commit 08fa9fbe5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 90 additions and 1 deletions

View File

@ -907,6 +907,7 @@ D_8013783C = 0x80137414;
D_80137840 = 0x80137418;
D_80137844 = 0x8013741C;
D_80137848 = 0x80137420;
g_RelicMenuFadeTimer = 0x80137424;
g_TimeAttackEntryTimes = 0x80137428;
c_strTimeAttackEntry = 0x80137494;
g_NewAttackRightHand = 0x80137500;

View File

@ -1077,6 +1077,7 @@ g_IsCloakColorUnlocked = 0x80137604;
g_IsSelectingEquipment = 0x8013760C;
g_EquipmentCursor = 0x80137610;
g_MenuData = 0x8013761C;
g_RelicMenuFadeTimer = 0x80137850;
g_TimeAttackEntryTimes = 0x80137854;
c_strTimeAttackEntry = 0x801378C0;
g_NewAttackRightHand = 0x8013792C;

View File

@ -588,7 +588,93 @@ void func_800F5E68(MenuContext* context, s32 cursorIdx, s32 x, s32 y, s32 w,
DrawMenuRect(context, x, y + (cursorIdx * (h + yGap)), w, h, r, 0, 0);
}
INCLUDE_ASM("dra/nonmatchings/5298C", DrawRelicsMenu);
void DrawRelicsMenu(MenuContext* ctx) {
s32 ctx_h;
s32 switchFadeLevel;
s32 spriteY;
s32 spriteX;
s32 var_a0;
s32 i;
s32 offsetY;
s32 baseY;
s32 var_s3;
s32 u_OnOff;
u8* relic;
ctx_h = ctx->h;
relic = &g_Status.relics[RELIC_SOUL_OF_BAT];
#if defined(VERSION_US)
for (i = 0, var_s3 = 0; i < 30; i++, var_s3++, relic++) {
// This if-statement only exists in US. This is to skip over
// rendering the JP-exclusive familiars (sprite and nosedevil)
if (i == 23) {
i = 25;
relic += 2;
}
// Declare this as the var to use for the two comparisons later
#define INDEXER var_s3
#else
for (i = 0; i < 30; i++, relic++) {
#define INDEXER i
#endif
offsetY = (INDEXER / 2) * 0x13;
baseY = ctx_h + 0x22;
spriteY = offsetY + baseY;
spriteX = (i & 1) * 0xB0;
if (*relic & RELIC_FLAG_FOUND) {
if (spriteY < 0) {
continue;
}
if (spriteY >= 193) {
continue;
}
if (!(i & 2)) {
if (i < 0) {
var_a0 = i + 3;
} else {
var_a0 = i;
}
DrawMenuSprite(
ctx, spriteX + 0x38, spriteY, 0x78, 0x10, (i & 1) * 0x78,
func_800F548C((var_a0 >> 2) - 0x80), 0x1A1, 6, 1, 0, 0);
} else {
if (i < 0) {
var_a0 = i + 3;
} else {
var_a0 = i;
}
DrawMenuSprite(
ctx, spriteX + 0x38, spriteY, 0x78, 0x10, (i & 1) * 0x78,
func_800F548C((var_a0 >> 2) + 3), 0x1A1, 7, 1, 0, 0);
}
}
switchFadeLevel = 0;
// Determine the U value for the texture to use for the switch
u_OnOff = -(!(*relic & RELIC_FLAG_ACTIVE)) & 0x30;
if (INDEXER == g_MenuNavigation.cursorRelic) {
// This routine handles the fade in/fade out of the ON/OFF switch
// when hovering
if (++g_RelicMenuFadeTimer >= 0x48) {
g_RelicMenuFadeTimer = 0;
}
if (g_RelicMenuFadeTimer < 0x24) {
// Fade up
switchFadeLevel = g_RelicMenuFadeTimer / 6;
} else {
// Fade down
switchFadeLevel = 6 - ((g_RelicMenuFadeTimer - 0x24) / 6);
}
}
DrawMenuSprite(ctx, spriteX | 8, spriteY, 0x2F, 0xF, u_OnOff, 0x70,
switchFadeLevel + 0x1C8, 0x1F,
INDEXER == g_MenuNavigation.cursorRelic, 0x40, 0);
}
spriteY = ctx_h + ((g_MenuNavigation.cursorRelic / 2) * 0x13);
DrawMenuRect(ctx, ((g_MenuNavigation.cursorRelic & 1) * 0xB0) | 8,
spriteY + 0x21, 0xA8, 0x12, 0x60, 0, 0);
#undef INDEXER
}
void DrawMenuAlucardPortrait(MenuContext* ctx) {
DrawMenuSprite(ctx, 0x10, 0x24, 0x40, 0x40, 0, 0x80, 0x150, 0x9C, 1, 0, 0);

View File

@ -504,6 +504,7 @@ extern s32 D_80137840;
extern s32 D_80137844[];
extern s32 D_80137848[];
extern s32 D_8013784C;
extern s16 g_RelicMenuFadeTimer;
extern s32 g_TimeAttackEntryTimes[];
extern s32 c_strTimeAttackEntry[];
extern s32 c_strTimeAttackGoals[];