Skip to content

Commit c87b08f

Browse files
committed
Implemented save on achievements and fixed some bugs
1 parent 6b3a42b commit c87b08f

25 files changed

Lines changed: 312 additions & 60 deletions

src/audio/external.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2304,7 +2304,11 @@ void play_music(u8 player, u16 seqArgs, u16 fadeTimer) {
23042304
if (i == 0) {
23052305
seq_player_play_sequence(SEQ_PLAYER_LEVEL, seqId, fadeTimer);
23062306
} else if (!gSequencePlayers[SEQ_PLAYER_LEVEL].enabled) {
2307-
stop_background_music(sBackgroundMusicQueue[0].seqId);
2307+
s16 seqId = sBackgroundMusicQueue[0].seqId;
2308+
stop_background_music(seqId);
2309+
if (seqId == SEQ_LEVEL_BOSS_KOOPA || seqId == SEQ_LEVEL_BOSS_KOOPA_FINAL) {
2310+
CALL_EVENT(BossBattleEnded);
2311+
}
23082312
}
23092313
return;
23102314
}

src/audio/synthesis.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,10 @@ u64 *synthesis_process_notes(s16 *aiBuf, s32 bufLen, u64 *cmd) {
799799
#endif
800800

801801
while (nAdpcmSamplesProcessed != samplesLenAdjusted) {
802+
803+
if (note->synthesisBuffers == NULL) {
804+
continue;
805+
}
802806
s32 samplesRemaining; // v1
803807
s32 s0;
804808

src/engine/level_script.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "math_util.h"
2424
#include "surface_collision.h"
2525
#include "surface_load.h"
26+
#include "seq_ids.h"
2627
#include "port/hooks/Events.h"
2728

2829
#define CMD_GET(type, offset) (*(type *) (CMD_PROCESS_OFFSET(offset) + (u8 *) sCurrentCmd))
@@ -708,7 +709,11 @@ static void level_cmd_set_music(void) {
708709
}
709710

710711
static void level_cmd_set_menu_music(void) {
711-
set_background_music(0, CMD_GET(s16, 2), 0);
712+
s16 seqId = CMD_GET(s16, 2);
713+
if(seqId == SEQ_LEVEL_BOSS_KOOPA || seqId == SEQ_LEVEL_BOSS_KOOPA_FINAL) {
714+
CALL_EVENT(BossBattleStarted, seqId == SEQ_LEVEL_BOSS_KOOPA ? BOSS_BATTLE_KOOPA : BOSS_BATTLE_KOOPA_FINAL);
715+
}
716+
set_background_music(0, seqId, 0);
712717
sCurrentCmd = CMD_NEXT;
713718
}
714719

src/game/behaviors/eyerok.inc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ static void eyerok_boss_act_die(void) {
128128
} else if (o->oTimer > 120) {
129129
stop_background_music(SEQUENCE_ARGS(4, SEQ_EVENT_BOSS));
130130
obj_mark_for_deletion(o);
131+
CALL_EVENT(BossBattleEnded);
131132
}
132133
}
133134

src/game/behaviors/king_bobomb.inc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ void king_bobomb_act_2(void) {
9191
if (mario_is_far_below_object(1200.0f)) {
9292
o->oAction = 0;
9393
stop_background_music(SEQUENCE_ARGS(4, SEQ_EVENT_BOSS));
94+
CALL_EVENT(BossBattleEnded);
9495
}
9596
}
9697

@@ -157,6 +158,7 @@ void king_bobomb_act_1(void) {
157158
if (mario_is_far_below_object(1200.0f)) {
158159
o->oAction = 0;
159160
stop_background_music(SEQUENCE_ARGS(4, SEQ_EVENT_BOSS));
161+
CALL_EVENT(BossBattleEnded);
160162
}
161163
}
162164

@@ -227,6 +229,7 @@ void king_bobomb_act_7(void) {
227229
void king_bobomb_act_8(void) {
228230
if (o->oTimer == 60) {
229231
stop_background_music(SEQUENCE_ARGS(4, SEQ_EVENT_BOSS));
232+
CALL_EVENT(BossBattleEnded);
230233
}
231234
}
232235

@@ -313,6 +316,7 @@ void king_bobomb_act_5(void) { // bobomb returns home
313316
if (mario_is_far_below_object(1200.0f)) {
314317
o->oAction = 0;
315318
stop_background_music(SEQUENCE_ARGS(4, SEQ_EVENT_BOSS));
319+
CALL_EVENT(BossBattleEnded);
316320
}
317321

318322
if (cur_obj_can_mario_activate_textbox_2(500.0f, 100.0f)) {

src/game/behaviors/whomp.inc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ void king_whomp_chase(void) {
114114
if (mario_is_far_below_object(1000.0f)) {
115115
o->oAction = 0;
116116
stop_background_music(SEQUENCE_ARGS(4, SEQ_EVENT_BOSS));
117+
CALL_EVENT(BossBattleEnded);
117118
}
118119
}
119120

@@ -264,6 +265,7 @@ void whomp_die(void) {
264265
void king_whomp_stop_music(void) {
265266
if (o->oTimer == 60) {
266267
stop_background_music(SEQUENCE_ARGS(4, SEQ_EVENT_BOSS));
268+
CALL_EVENT(BossBattleEnded);
267269
}
268270
}
269271

src/game/behaviors/wiggler.inc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ static void wiggler_act_fall_through_floor(void) {
370370
if (o->oTimer == 60) {
371371
stop_background_music(SEQUENCE_ARGS(4, SEQ_EVENT_BOSS));
372372
o->oWigglerFallThroughFloorsHeight = 1700.0f;
373+
CALL_EVENT(BossBattleEnded);
373374
} else if (o->oTimer > 60) {
374375
if (o->oPosY < o->oWigglerFallThroughFloorsHeight) {
375376
o->oAction = WIGGLER_ACT_WALK;

src/game/ingame_menu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,6 +1362,7 @@ void handle_special_dialog_text(s16 dialogID) { // dialog ID tables, in order
13621362
if (dialogBossStart[i] == dialogID) {
13631363
seq_player_unlower_volume(SEQ_PLAYER_LEVEL, 60);
13641364
play_music(SEQ_PLAYER_LEVEL, SEQUENCE_ARGS(4, SEQ_EVENT_BOSS), 0);
1365+
CALL_EVENT(BossBattleStarted, BOSS_BATTLE_GENERIC);
13651366
return;
13661367
}
13671368
}

src/game/level_update.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,15 +728,19 @@ s16 level_trigger_warp(struct MarioState *m, s32 warpOp) {
728728
play_transition(WARP_TRANSITION_FADE_INTO_MARIO, 0x20, 0x00, 0x00, 0x00);
729729
break;
730730

731-
case WARP_OP_DEATH:
731+
case WARP_OP_DEATH: {
732732
if (m->numLives == 0) {
733733
sDelayedWarpOp = WARP_OP_GAME_OVER;
734734
}
735+
if(is_sequence_playing(SEQ_EVENT_BOSS) || is_sequence_playing(SEQ_LEVEL_BOSS_KOOPA) || is_sequence_playing(SEQ_LEVEL_BOSS_KOOPA_FINAL)) {
736+
CALL_EVENT(BossBattleEnded);
737+
}
735738
sDelayedWarpTimer = 48;
736739
sSourceWarpNodeId = WARP_NODE_DEATH;
737740
play_transition(WARP_TRANSITION_FADE_INTO_BOWSER, 0x30, 0x00, 0x00, 0x00);
738741
play_sound(SOUND_MENU_BOWSER_LAUGH, gGlobalSoundSource);
739742
break;
743+
}
740744

741745
case WARP_OP_WARP_FLOOR:
742746
sSourceWarpNodeId = WARP_NODE_WARP_FLOOR;

src/game/mario_actions_airborne.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "mario_step.h"
1414
#include "save_file.h"
1515
#include "rumble_init.h"
16+
#include "seq_ids.h"
1617

1718
void play_flip_sounds(struct MarioState *m, s16 frame1, s16 frame2, s16 frame3) {
1819
s32 animFrame = m->marioObj->header.gfx.animInfo.animFrame;

0 commit comments

Comments
 (0)