Skip to content

Commit

Permalink
- Updated sounds effects
Browse files Browse the repository at this point in the history
- Added text when finishing a duel
- Added new record text when beating the score
  • Loading branch information
ajgalan committed Sep 18, 2021
1 parent aa7d820 commit 6266c42
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 16 deletions.
34 changes: 27 additions & 7 deletions src/duel_banked.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,31 +239,51 @@ void print_duel_text() {
}

void print_duel_score() {
for (UINT8 y = 7; y != 12; y++) {
for (UINT8 y = 6; y != 13; y++) {
for (UINT8 x = 0; x != 32; x++) {
set_bkg_tile_xy(x, y, 0x00);
}
}
UINT8 i = 0;
while(you_text[i] != '\0') {
if (you_text[i] > 64 && you_text[i] < 91) {
set_bkg_tile_xy(6+i, 8, you_text[i] + 111);
set_bkg_tile_xy(6+i, 7, you_text[i] + 111);
} else if (you_text[i] == '-') {
set_bkg_tile_xy(6+i, 8, 204);
set_bkg_tile_xy(6+i, 7, 204);
}
i++;
}
set_bkg_tile_xy(6+i, 8, 245 + roundsWon);
set_bkg_tile_xy(6+i, 7, 245 + roundsWon);

i = 0;
while(enemy_text[i] != '\0') {
if (enemy_text[i] > 64 && enemy_text[i] < 91) {
set_bkg_tile_xy(4+i, 10, enemy_text[i] + 111);
set_bkg_tile_xy(4+i, 9, enemy_text[i] + 111);
} else if (enemy_text[i] == '-') {
set_bkg_tile_xy(4+i, 10, 204);
set_bkg_tile_xy(4+i, 9, 204);
}
i++;
}
set_bkg_tile_xy(4+i, 10, 245 + roundsLost);
set_bkg_tile_xy(4+i, 9, 245 + roundsLost);
i = 0;
if (roundsWon == 3) {
while(you_win_text[i] != '\0') {
if (you_win_text[i] > 64 && you_win_text[i] < 91) {
set_bkg_tile_xy(6+i, 11, you_win_text[i] + 111);
} else if (you_win_text[i] == '!') {
set_bkg_tile_xy(6+i, 11, 205);
}
i++;
}
} else if (roundsLost == 3) {
while(you_lose_text[i] != '\0') {
if (you_lose_text[i] > 64 && you_lose_text[i] < 91) {
set_bkg_tile_xy(5+i, 11, you_lose_text[i] + 111);
} else if (you_lose_text[i] == '!') {
set_bkg_tile_xy(5+i, 11, 205);
}
i++;
}
}
}

26 changes: 19 additions & 7 deletions src/levels.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ BOOLEAN isSurvivalMode;
BOOLEAN loadPrelevelScreen;
BOOLEAN showingHowToPlay;
BOOLEAN showingPressAnyKey;
BOOLEAN newRecord;


const level levels[] = {
Expand Down Expand Up @@ -106,8 +107,7 @@ void load_level() {
default:
break;
}
} else {
update_score();
} else {
load_credits();
}
}
Expand Down Expand Up @@ -173,7 +173,10 @@ void game_over_loop() {
if (textScreenTimer != 0 && decimalTimer == 0) {
textScreenTimer--;
if (textScreenTimer == 1) {
print_text_win(1, 15, press_any_button_text);
print_text_win(1, 16, press_any_button_text);
if (newRecord == TRUE) {
print_text_win(4, 13, new_record_text);
}
}
} else if (joypad() && textScreenTimer == 0) {
reset_values();
Expand Down Expand Up @@ -217,7 +220,7 @@ void load_game_over() {
set_win_tile_xy(14 - x, 12, 245 + digit);
}
}
update_score();
newRecord = update_score();
enable_interrupts();
move_win(7,0);
SHOW_WIN;
Expand All @@ -233,7 +236,10 @@ void game_mode_level_complete_loop() {
if (textScreenTimer != 0 && decimalTimer == 0) {
textScreenTimer--;
if (textScreenTimer == 1) {
print_text_win(1, 15, press_any_button_text);
print_text_win(1, 16, press_any_button_text);
if (newRecord == TRUE) {
print_text_win(4, 14, new_record_text);
}
} else if (textScreenTimer == 50) {
print_text_win(1, 4, bonus_text);
print_current_score(13);
Expand Down Expand Up @@ -261,7 +267,12 @@ void game_mode_level_complete_loop() {
print_number_win(8, 11, difficultyBonus);
currentScore += difficultyBonus;
print_current_score(13);
play_reload_sound();
play_reload_sound();
if (currentLevel == 14) {
newRecord = update_score();
} else {
newRecord = FALSE;
}
}
} else if (joypad() && textScreenTimer == 0) {
gameMode = previousGameMode;
Expand All @@ -288,6 +299,7 @@ void load_level_complete() {
performant_delay(4);
}
if (isPracticeMode == FALSE) {

UINT8 bank =_current_bank;
SWITCH_ROM_MBC1(2);
gb_decompress_bkg_data(205, borderTiles);
Expand Down Expand Up @@ -537,7 +549,7 @@ void game_mode_credits_loop() {
} else if (credits_text[creditsTextIndex] == '!') {
set_bkg_tile_xy(creditsTextCursor, creditsLine, 0xF3);
} else if (credits_text[creditsTextIndex] == '\0') {
print_text_bkg(1, 15, press_any_button_text);
print_text_bkg(1, 16, press_any_button_text);
showingPressAnyKey = TRUE;
}
creditsTextCursor++;
Expand Down
1 change: 1 addition & 0 deletions src/levels.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ extern BOOLEAN isSurvivalMode;
extern BOOLEAN loadPrelevelScreen;
extern BOOLEAN showingHowToPlay;
extern BOOLEAN showingPressAnyKey;
extern BOOLEAN newRecord;

extern const level levels[];
extern const duelLevel duelLevels[];
Expand Down
6 changes: 5 additions & 1 deletion src/shooting_banked.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,11 @@ void shoot() {
break;
}
}
play_shoot_sound();
if (ammo == 0) {
play_last_bullet_shoot_sound();
} else {
play_shoot_sound();
}
canShoot = FALSE;
} else if (canShoot == TRUE && ammo == 0) {
play_empty_sound();
Expand Down
13 changes: 13 additions & 0 deletions src/sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,19 @@ void play_shoot_sound() {
channel1Timer = 10;
}

void play_last_bullet_shoot_sound() {
UINT8 bank = _current_bank;
SWITCH_ROM_MBC1(3);
hUGE_mute_channel(HT_CH1, HT_CH_MUTE);
SWITCH_ROM_MBC1(bank);
NR10_REG = 0x5E;
NR11_REG = 0xC2;
NR12_REG = 0xB3;
NR13_REG = 0x66;
NR14_REG = 0x85;
channel1Timer = 10;
}

void play_almost_exploding_sound() {
UINT8 bank = _current_bank;
SWITCH_ROM_MBC1(3);
Expand Down
1 change: 1 addition & 0 deletions src/sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ void set_riding_song();
void set_win_song();
void set_lose_song();
void play_shoot_sound();
void play_last_bullet_shoot_sound();
void play_explosion_sound();
void play_empty_sound();
void play_reload_sound();
Expand Down
5 changes: 4 additions & 1 deletion src/text.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ const unsigned char round_text[] = "ROUND \0";
const unsigned char rounds_text[] = "ROUNDS\0";
const unsigned char enemy_text[] = "ENEMY - \0";
const unsigned char you_text[] = "YOU - \0";
const unsigned char you_win_text[] = "YOU WIN!\0";
const unsigned char you_lose_text[] = "YOU LOSE!\0";

const unsigned char lives_text[] = "LIVES\0";
const unsigned char start_text[] = "START\0";
Expand Down Expand Up @@ -122,4 +124,5 @@ const unsigned char * credits_texts[] = {
credits_text_9,
credits_text_10,
};
const unsigned char credits_text[] = " EL DUELOROSO\nA GAME BY ADRIAN JG\n\nTHANKS TO\nGBDK-2020 DEVS\nHUGETRACKER DEVS\nHUGEBUILD DEVS\nGAMINGMONSTERS\n\nSPECIAL THANKS TO\nALEX @\n\nAND THANK YOU\nFOR PLAYING!\n\0";
const unsigned char credits_text[] = " EL DUELOROSO\nA GAME BY ADRIAN JG\n\nTHANKS TO\nGBDK-2020 DEVS\nHUGETRACKER DEVS\nHUGEBUILD DEVS\nGAMINGMONSTERS\n\nSPECIAL THANKS TO\nALEX @\n\nAND THANK YOU\nFOR PLAYING!\n\0";
const unsigned char new_record_text[] = "NEW RECORD!\n";
3 changes: 3 additions & 0 deletions src/text.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ extern const unsigned char round_text[];
extern const unsigned char rounds_text[];
extern const unsigned char enemy_text[];
extern const unsigned char you_text[];
extern const unsigned char you_win_text[];
extern const unsigned char you_lose_text[];

extern const unsigned char lives_text[];
extern const unsigned char start_text[];
Expand Down Expand Up @@ -72,5 +74,6 @@ extern const unsigned char credits_text_9[];
extern const unsigned char credits_text_10[];
extern const unsigned char * credits_texts[];
extern const unsigned char credits_text[];
extern const unsigned char new_record_text[];

#endif
2 changes: 2 additions & 0 deletions src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ void print_text_win(UINT8 x, UINT8 y, unsigned char text[]) {
set_win_tile_xy(i+x, y, text[i] + 149);
} else if (text[i] == ':') {
set_win_tile_xy(i+x, y, 0xF2);
} else if (text[i] == '!') {
set_win_tile_xy(i+x, y, 0xF3);
}
i++;
}
Expand Down

0 comments on commit 6266c42

Please sign in to comment.