Skip to content

Commit

Permalink
Merge branch 'master' into sfx
Browse files Browse the repository at this point in the history
  • Loading branch information
synamaxmusic authored Sep 18, 2024
2 parents 646ac35 + 77f0f5e commit 13c95bb
Show file tree
Hide file tree
Showing 38 changed files with 388 additions and 145 deletions.
2 changes: 2 additions & 0 deletions config/splat.us.bomar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ segments:
- [0x9710, .data, sprites]
- [0xA9D4, data]
- [0xA9EC, .rodata, AFC4]
- [0xAA70, .rodata, CA94]
- [0xAAB0, .rodata, e_red_door]
- [0xAAC8, .rodata, e_collect]
- [0xAB50, .rodata, e_misc]
Expand All @@ -73,6 +74,7 @@ segments:
- [0xAC0C, c, st_debug]
- [0xAE90, c, e_breakable]
- [0xAFC4, c]
- [0xCA94, c]
- [0xCF70, c, st_update]
- [0xD3A4, c, collision]
- [0xEB60, c, create_entity]
Expand Down
42 changes: 42 additions & 0 deletions include/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -1807,6 +1807,48 @@ extern s32 g_IsTimeAttackUnlocked;
// prevents the player to enter in the warp room. When g_CastleFlags[0x32] the
// column will disappear.
extern u8 g_CastleFlags[0x300]; // starts at 0x8003BDEC
typedef enum {
CLOCK_ROOM_DOORS, // opened by gold and silver ring; drops down to CEN
CASTLE_FLAG_2 = 2,
CASTLE_FLAG_19 = 19, // Randomized by g_RandomizeCastleFlag13; unused
// Start NO3/NP3 flags
CASTLE_FLAG_48 = 48,
CASTLE_FLAG_49,
CASTLE_FLAG_50,
JEWEL_SWORD_ROOM,
CASTLE_FLAG_52,
CASTLE_FLAG_53,
CASTLE_FLAG_54, // Unused
CASTLE_FLAG_55,
DEATH_STAIRWAY_BROKEN, // Piece of stairs right before Death room
SG_RETR_ENTR, // Slogra/Gaibon retreated from Entrance encounter
CASTLE_FLAG_58,
CASTLE_FLAG_98 = 98, // Set in DRA, unused
CASTLE_FLAG_99, // Set in DRA, unused
// Start NZ0 flags
CASTLE_FLAG_129 = 129,
CASTLE_FLAG_130,
CASTLE_FLAG_131,
SG_KILL_ALCH, // Slogra & Gaibon were killed in Alchemy Lab
CASTLE_FLAG_133,
CASTLE_FLAG_149 = 149,
CASTLE_FLAG_150,
CASTLE_FLAG_155 = 155,
CASTLE_FLAG_185 = 185,
// WRP
CASTLE_FLAG_208 = 208,
// RWRP
CASTLE_FLAG_209,
// Cutscenes the player has finished seeing
SUCC_CS_DONE = 212, // Succubus cutscene (as Lisa)
HG_CS_DONE = 216, // Holy Glasses cutscene (in CEN)
HEART_FLAGS_START = 256,
MAD_COLLISION_FLAGS_START = 288,
MAD_RAREDROP_FLAGS_START = 320,
COLLISION_FLAGS_START = 400,
COLLECT_FLAGS_START = 432,
} CastleFlagOffsets;

extern s32 D_8003C0EC[4];
extern s32 D_8003C0F8;
extern s32 D_8003C100;
Expand Down
9 changes: 4 additions & 5 deletions src/boss/mar/17FEC.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,33 +499,32 @@ extern s16 D_us_80181298[];
// Stone doors on the floor leading to CEN Entity ID 0x1B
void EntityStoneDoor(Entity* self) {
u16 params = self->params;
const int centerCubeDoor = 0;

switch (self->step) {
case 0:
InitializeEntity(g_eInitGeneric2);
self->animSet = ANIMSET_OVL(1);
self->animCurFrame = params + 27;
self->zPriority = 0x40;
if (g_CastleFlags[centerCubeDoor] == 0) {
if (g_CastleFlags[CLOCK_ROOM_DOORS] == 0) {
self->posX.i.hi += D_us_80181294[params];
UpdateStoneDoorTiles(true);
} else {
self->posX.i.hi += D_us_80181298[params];
UpdateStoneDoorTiles(false);
}
self->posY.i.hi += 88;
self->ext.stoneDoor.flag = g_CastleFlags[centerCubeDoor];
self->ext.stoneDoor.flag = g_CastleFlags[CLOCK_ROOM_DOORS];
break;

case 1:
if (self->ext.stoneDoor.flag == NULL) {
if (g_CastleFlags[centerCubeDoor]) {
if (g_CastleFlags[CLOCK_ROOM_DOORS]) {
self->ext.stoneDoor.unk80 = 0;
self->step++;
}
}
self->ext.stoneDoor.flag = g_CastleFlags[centerCubeDoor];
self->ext.stoneDoor.flag = g_CastleFlags[CLOCK_ROOM_DOORS];
break;

case 2:
Expand Down
2 changes: 0 additions & 2 deletions src/boss/mar/AFC4.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,3 @@ INCLUDE_ASM("boss/mar/nonmatchings/AFC4", func_us_8018B74C);
INCLUDE_ASM("boss/mar/nonmatchings/AFC4", EntityMariaCutscene);

INCLUDE_ASM("boss/mar/nonmatchings/AFC4", func_us_8018C90C);

INCLUDE_ASM("boss/mar/nonmatchings/AFC4", func_us_8018CA94);
190 changes: 190 additions & 0 deletions src/boss/mar/CA94.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
#include <stage.h>

extern u16 D_80180A60[];
extern u8 D_us_80180690[];
extern u8 D_us_801806A4[];
extern u8 D_us_801806B8[];
extern u8 D_us_801806CC[];
extern u8 D_us_801806E4[];
extern u8 D_us_801806EC[];
extern u8 D_us_80180700[];
extern u8 D_us_80180718[];
extern u8 D_us_80180724[];
extern u8 D_us_80180738[];
extern u32 g_CutsceneFlags;
extern s32 D_us_8019AE70;

void func_us_8018CA94(Entity* self) {
Entity* player;
Tilemap* tilemap;
s32 pan;

// n.b.! unused, required for PSP
tilemap = &g_Tilemap;
player = &PLAYER;

if (D_us_8019AE70 && self->step < 12) {
SetStep(12);
}

switch (self->step) {
case 0:
InitializeEntity(D_80180A60);
self->animSet = ANIMSET_OVL(2);
self->animCurFrame = 1;
self->unk5A = 0x48;
self->palette = PAL_DRA(0x210);
break;

case 1:
if (g_CutsceneFlags & 0x4) {
self->animCurFrame = 2;
self->step++;
}
break;

case 2:
if (g_CutsceneFlags & 0x8) {
SetStep(3);
}
break;

case 3:
AnimateEntity(D_us_80180690, self);
if (g_CutsceneFlags & 0x10) {
SetStep(4);
}
break;

case 4:
AnimateEntity(D_us_801806A4, self);
if (g_CutsceneFlags & 0x20) {
SetStep(5);
}
break;

case 5:
AnimateEntity(D_us_801806B8, self);
if (g_CutsceneFlags & 0x40) {
SetStep(6);
}
break;

case 6:
self->animCurFrame = 19;
if (g_CutsceneFlags & 0x80) {
self->step++;
}
break;

case 7:
self->animCurFrame = 0x12;
if (g_CutsceneFlags & 0x100) {
self->step++;
}
break;

case 8:
AnimateEntity(D_us_801806CC, self);
if (g_CutsceneFlags & 0x200) {
SetStep(9);
}
break;

case 9:
AnimateEntity(D_us_801806E4, self);
if (g_CutsceneFlags & 0x400) {
SetStep(10);
}
break;

case 10:
AnimateEntity(D_us_801806EC, self);
if (g_CutsceneFlags & 0x800) {
SetStep(11);
}
break;

case 11:
AnimateEntity(D_us_80180700, self);
if (g_CutsceneFlags & 0x1000) {
SetStep(12);
}
break;

case 12:
if (!AnimateEntity(D_us_80180718, self)) {
SetStep(13);
self->velocityX = FIX(1.5);
}
break;

case 13:
pan = AnimateEntity(D_us_80180724, self);
if (pan & 0x80 &&
(self->animFrameIdx == 3 || self->animFrameIdx == 7)) {

pan = (self->posX.i.hi - 120) / 16;

if (pan < -8) {
pan = -8;
}
if (pan > 8) {
pan = 8;
}

g_api.PlaySfxVolPan(SFX_STOMP_SOFT_B, 80, pan);
}

MoveEntity();

if (self->posX.i.hi > 184) {
SetStep(14);
self->velocityY = FIX(-4.0);
}

break;

case 14:
AnimateEntity(D_us_80180738, self);
self->velocityY += FIX(0.1875);
MoveEntity();

if (self->velocityY > 0 && self->posY.i.hi > 0x83) {
self->velocityY = 0;
SetStep(15);
}

break;

case 15:
pan = AnimateEntity(D_us_80180724, self);
if (pan & 0x80 &&
(self->animFrameIdx == 3 || self->animFrameIdx == 7)) {

pan = (self->posX.i.hi - 120) / 16;

if (pan < -8) {
pan = -8;
}
if (pan > 8) {
pan = 8;
}

g_api.PlaySfxVolPan(SFX_STOMP_SOFT_B, 80, pan);
}

MoveEntity();

if (self->posX.i.hi > 256) {
g_CutsceneFlags |= 0x2000;
}

if (self->posX.i.hi > 272) {
DestroyEntity(self);
}

break;
}
}
2 changes: 1 addition & 1 deletion src/dra/loading.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ void HandleNowLoading(void) {
}
if (g_StageId == STAGE_NO3 && g_PlayableCharacter != PLAYER_ALUCARD) {
D_8006C374 = 0x11;
g_CastleFlags[0x34] = 1;
g_CastleFlags[CASTLE_FLAG_52] = 1;
}
D_800978C4 = 1;
SetGameState(Game_Play);
Expand Down
21 changes: 11 additions & 10 deletions src/dra/play.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ void HandlePlay(void) {
for (i = 0; i < LEN(g_CastleFlags); i++) {
g_CastleFlags[i] = 0;
}
g_CastleFlags[0xB9] = 1;
g_CastleFlags[0x9B] = 1;
g_CastleFlags[CASTLE_FLAG_185] = 1;
g_CastleFlags[CASTLE_FLAG_155] = 1;
if (g_PlayableCharacter != 0) {
g_CastleFlags[0x35] = 1;
g_CastleFlags[0x62] = 1;
g_CastleFlags[0x63] = 1;
g_CastleFlags[0x85] = 1;
g_CastleFlags[0x95] = 1;
g_CastleFlags[0x96] = 1;
g_CastleFlags[CASTLE_FLAG_53] = 1;
g_CastleFlags[CASTLE_FLAG_98] = 1;
g_CastleFlags[CASTLE_FLAG_99] = 1;
g_CastleFlags[CASTLE_FLAG_133] = 1;
g_CastleFlags[CASTLE_FLAG_149] = 1;
g_CastleFlags[CASTLE_FLAG_150] = 1;
}

for (i = 0, ptr = &g_MenuNavigation; i < sizeof(MenuNavigation);
Expand Down Expand Up @@ -179,8 +179,9 @@ void HandlePlay(void) {
DestroyAllPrimitives();
func_800EDAE4();
func_801024DC();
if (g_CastleFlags[0x13] & 0x80) {
g_CastleFlags[0x13] = g_RandomizeCastleFlag13[rand() & 0xF] + 0x80;
if (g_CastleFlags[CASTLE_FLAG_19] & 0x80) {
g_CastleFlags[CASTLE_FLAG_19] =
g_RandomizeCastleFlag13[rand() & 0xF] + 0x80;
}
g_GameStep++;
break;
Expand Down
6 changes: 3 additions & 3 deletions src/st/cen/F890.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void EntityPlatform(Entity* self) {
self->animCurFrame = 9;
self->zPriority = 0x80;

if (g_CastleFlags[216] != 0) {
if (g_CastleFlags[HG_CS_DONE] != 0) {
self->step = 9;
}

Expand Down Expand Up @@ -276,7 +276,7 @@ void EntityRoomDarkness(Entity* self) {
switch (self->step) {
case 0:
/* Has player seen Maria Holy Glasses Cutscene? */
if (g_CastleFlags[216] != 0) {
if (g_CastleFlags[HG_CS_DONE] != 0) {
DestroyEntity(self);
return;
}
Expand Down Expand Up @@ -348,7 +348,7 @@ void EntityRoomDarkness(Entity* self) {
void EntityMaria(Entity* self) {
if (self->step == 0) {
/* Has player seen Maria Holy Glasses Cutscene? */
if (g_CastleFlags[216] != 0) {
if (g_CastleFlags[HG_CS_DONE] != 0) {
DestroyEntity(self);
return;
}
Expand Down
5 changes: 3 additions & 2 deletions src/st/cen/entity_heart_drop.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ void EntityHeartDrop(Entity* self) {

if (!self->step) {
index = self->ext.heartDrop.unkB4 = self->params + 0xC0;
value = g_CastleFlags[(index >> 3) + 0x100] >> (index & 7);
value = g_CastleFlags[(index >> 3) + HEART_FLAGS_START] >> (index & 7);
if (value & 1) {
DestroyEntity(self);
return;
Expand All @@ -29,7 +29,8 @@ void EntityHeartDrop(Entity* self) {
index = self->ext.heartDrop.unkB4;
if (self->step < 5) {
if (self->hitFlags) {
g_CastleFlags[(index >> 3) + 0x100] |= 1 << (index & 7);
g_CastleFlags[(index >> 3) + HEART_FLAGS_START] |=
1 << (index & 7);
self->step = 5;
}
}
Expand Down
Loading

0 comments on commit 13c95bb

Please sign in to comment.