Decompile w58 (Alucart Shield) Shield Spell (#1439)

This modifies a variable at 0x80097420, I noticed that was in the
g_UnkGraphicsStruct, so I went through all the uses of that variable and
made them all use the struct.
This commit is contained in:
bismurphy 2024-07-26 14:13:51 -04:00 committed by GitHub
parent 4b425c4cd0
commit 12f8f7149d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 194 additions and 6 deletions

View File

@ -208,6 +208,7 @@ typedef enum { MONO_SOUND, STEREO_SOUND } soundMode;
#define SFX_DOOR_UNKNOWN 0x64F
#endif
#define SFX_UNK_641 0x641
#define NA_SE_EN_COG_CLICK 0x642
#define NA_SE_EN_ROCK_BREAK 0x644
#define SOUND_BAT_SCREECH 0x64E

View File

@ -3,6 +3,7 @@
#define WEAPON
#include <game.h>
#include <sfx.h>
typedef struct {
/* 0x00 */ void (*EntityWeaponAttack)(Entity* self);

View File

@ -1205,7 +1205,7 @@ void func_80115394(DamageParam* damage, s16 arg_PlayerStep, s16 arg2) {
nullifyVelY = false;
PLAYER.drawFlags = DRAW_COLORS;
plDraw = &g_PlayerDraw[0];
if ((D_80097420 == 0xFFF) && (PLAYER.step_s)) {
if ((g_unkGraphicsStruct.unk20 == 0xFFF) && (PLAYER.step_s)) {
SetPlayerStep(Player_Unk17);
PLAYER.velocityY = 0;
PLAYER.velocityX = 0;

View File

@ -1521,7 +1521,7 @@ void EntityLevelUpAnimation(Entity* self) {
break;
case 1:
if (++D_80138090 == 2) {
D_80097420 = 3;
g_unkGraphicsStruct.unk20 = 3;
}
self->ext.factory.unk80 -= 8;
self->ext.factory.unk82 -= 8;
@ -1565,7 +1565,7 @@ void EntityLevelUpAnimation(Entity* self) {
self->ext.factory.unk7E = 0;
}
if (self->ext.factory.unk80 > 0x200) {
D_80097420 = 0;
g_unkGraphicsStruct.unk20 = 0;
DestroyEntity(self);
return;
}

View File

@ -284,7 +284,6 @@ extern u8 aPbav_0[0x2000]; // TODO: extract file
extern u8 aPbav_1[0x2000]; // TODO: extract file
extern u8 aPbav_2[0x2000]; // TODO: extract file
extern s32 D_80097420;
extern u16 g_ButtonMask[];
extern u8 g_StageSelectOrder[];
extern u16 D_800A04CC[];

View File

@ -163,7 +163,6 @@ u32 D_801362B4;
u32 g_DebugCurPal;
s32 D_801362D4;
s32 D_8013640C;
s32 D_80097420;
s32 D_800974A4;
OT_TYPE* g_CurrentOT;
s32 D_801362B8;

View File

@ -3,6 +3,8 @@
#include "weapon_private.h"
#include "shared.h"
extern SpriteParts D_19A000_8017A040[];
INCLUDE_ASM("weapon/nonmatchings/w_058", EntityWeaponAttack);
s32 func_ptr_80170004(Entity* self) {}
@ -17,7 +19,193 @@ s32 func_ptr_80170014(Entity* self) {}
s32 GetWeaponId(void) { return 52; }
INCLUDE_ASM("weapon/nonmatchings/w_058", EntityWeaponShieldSpell);
void EntityWeaponShieldSpell(Entity* self) {
Primitive* prim;
s16 primRight;
s16 primLeft;
s16 selfX;
s16 selfY;
bool showQuestionMark;
// This block sets variables that are unused
s16 temp_s1;
s16 temp_s5;
temp_s1 = 0x1C;
if (PLAYER.facingLeft) {
temp_s1 = -temp_s1;
}
temp_s5 = 0x30;
showQuestionMark = false;
switch (self->step) {
case 0:
self->primIndex = g_api.AllocPrimitives(PRIM_GT4, 2);
if (self->primIndex == -1) {
DestroyEntity(self);
return;
}
SetSpriteBank1(D_19A000_8017A040);
if (g_HandId != 0) {
self->animSet = ANIMSET_OVL(0x12);
self->palette = 0x128;
self->ext.shield.unk86 = 0x129;
self->unk5A = 0x66;
self->ext.shield.unk7C = 0;
self->ext.shield.unk7D = 0x80;
} else {
self->animSet = ANIMSET_OVL(0x10);
self->palette = 0x110;
self->ext.shield.unk86 = 0x111;
self->unk5A = 0x64;
self->ext.shield.unk7C = 0x80;
self->ext.shield.unk7D = 0;
}
self->posY.i.hi -= 8;
self->flags = FLAG_UNK_04000000 | FLAG_HAS_PRIMS | FLAG_UNK_10000;
self->zPriority = PLAYER.zPriority - 2;
self->facingLeft = PLAYER.facingLeft;
self->animCurFrame = 0x3E;
self->drawFlags = FLAG_DRAW_ROTX | FLAG_DRAW_ROTY;
self->rotX = self->rotY = 0;
// The primitive for the main shield appearing up behind Alucard
prim = &g_PrimBuf[self->primIndex];
prim->clut = 0x19F;
prim->tpage = 0x19;
prim->u0 = prim->u2 = 0x80;
prim->u1 = prim->u3 = 0x80 + 0x4F;
prim->v0 = prim->v1 =
self->ext.shield.unk7C + 0; // PSP needs +0 which is interesting
prim->v2 = prim->v3 = self->ext.shield.unk7C + 0x4F;
self->ext.shield.unk82 = 0;
prim->r0 = prim->g0 = prim->b0 = prim->r1 = prim->g1 = prim->b1 =
prim->r2 = prim->g2 = prim->b2 = prim->r3 = prim->g3 = prim->b3 =
0x80;
prim->priority = self->zPriority - 4;
prim->drawMode =
DRAW_UNK_40 | DRAW_TPAGE2 | DRAW_TPAGE | DRAW_COLORS | DRAW_TRANSP;
prim = prim->next;
// The primitive for the little question mark above Alucard
prim->clut = 0x190;
prim->tpage = 0x1E;
prim->u0 = prim->u2 = 0x78;
prim->u1 = prim->u3 = 0x78 + 7;
prim->v0 = prim->v1 = 8;
prim->v2 = prim->v3 = 8 + 7;
prim->priority = self->zPriority + 4;
prim->drawMode = DRAW_HIDE;
SetSpeedX(FIX(-2));
self->velocityY = 0;
DestroyEntityWeapon(1);
g_api.PlaySfx(SFX_UNK_641);
g_unkGraphicsStruct.unk20 = 1;
self->step++;
break;
case 1:
DecelerateX(0x1000);
self->velocityY -= FIX(0.15625);
self->posX.val += self->velocityX;
self->posY.val += self->velocityY;
self->rotX += 12;
self->rotY = self->rotX;
self->ext.shield.unk82 = self->rotX * 0x28 / 256;
if (self->rotX >= 0x100) {
self->ext.shield.unk82 = 0x28;
self->rotY = self->rotX = 0x100;
self->ext.shield.unk80 = 0x40;
self->step++;
}
break;
case 2:
if (--self->ext.shield.unk80 == 0) {
self->ext.shield.unk80 = 0x10;
g_api.PlaySfx(SFX_UNK_668);
self->step++;
}
break;
case 3:
prim = &g_PrimBuf[self->primIndex];
if (!(self->ext.shield.unk80 & 1)) {
prim->priority = 0x1FC;
} else {
prim->priority = self->zPriority - 2;
}
self->rotX -= 0x10;
if (self->rotX <= 0) {
self->rotX = 0;
}
self->rotY = self->rotX;
if (--self->ext.shield.unk80 == 0) {
self->animCurFrame = 0;
self->ext.shield.unk80 = 0x20;
self->step++;
}
break;
case 4:
self->ext.shield.unk82 += 8;
self->rotX += 0x10;
if (self->rotX >= 0x100) {
self->rotX = 0x100;
}
self->ext.shield.childPalette = self->rotX * 36 / 256;
self->ext.shield.unk8A = self->rotX * 28 / 256;
prim = &g_PrimBuf[self->primIndex];
if (prim->b3 > 8) {
prim->b3 -= 4;
}
prim->r0 = prim->g0 = prim->b0 = prim->r1 = prim->g1 = prim->b1 =
prim->r2 = prim->g2 = prim->b2 = prim->r3 = prim->g3 = prim->b3;
self->ext.shield.unk86 += 4;
self->ext.shield.unk92 += self->ext.shield.unk86;
if (--self->ext.shield.unk80 == 0) {
self->ext.shield.unk80 = 0x28;
self->step++;
}
break;
case 5:
showQuestionMark = true;
if (--self->ext.shield.unk80 == 0) {
self->step++;
}
break;
case 6:
g_unkGraphicsStruct.unk20 = 0;
DestroyEntity(self);
return;
}
selfX = self->posX.i.hi;
selfY = self->posY.i.hi;
prim = &g_PrimBuf[self->primIndex];
if (prim->b3 > 8) {
if (g_Timer & 1) {
prim->drawMode |= DRAW_HIDE;
} else {
prim->drawMode &= ~DRAW_HIDE;
}
}
prim->x0 = prim->x2 = selfX - self->ext.shield.unk82;
prim->x1 = prim->x3 = (selfX + self->ext.shield.unk82) - 1;
prim->y0 = prim->y1 = selfY - self->ext.shield.unk82;
prim->y2 = prim->y3 = (selfY + self->ext.shield.unk82) - 1;
prim = prim->next;
if (PLAYER.facingLeft) {
prim->x0 = prim->x2 = PLAYER.posX.i.hi + 2;
prim->x1 = prim->x3 = prim->x0 + 7;
} else {
prim->x0 = prim->x2 = PLAYER.posX.i.hi - 6;
prim->x1 = prim->x3 = prim->x0 + 7;
}
prim->y0 = prim->y1 = PLAYER.posY.i.hi - 0x22;
prim->y2 = prim->y3 = prim->y0 + 7;
if (showQuestionMark) {
prim->drawMode = DRAW_DEFAULT;
} else {
prim->drawMode = DRAW_HIDE;
}
}
void func_ptr_80170024(Entity* self) {}