Browse Source

add explosion sfxs

Thomas B 1 month ago
parent
commit
70224e8f78
8 changed files with 28 additions and 16 deletions
  1. BIN
      data/sfx_expl_orb.wav
  2. BIN
      data/sfx_expl_ship.wav
  3. 5
    4
      src/game.c
  4. 3
    0
      src/obj.c
  5. 18
    0
      src/sample.c
  6. 2
    0
      src/sample.h
  7. 0
    10
      src/sound.c
  8. 0
    2
      src/sound.h

BIN
data/sfx_expl_orb.wav View File


BIN
data/sfx_expl_ship.wav View File


+ 5
- 4
src/game.c View File

@@ -122,12 +122,13 @@ static void status(uint8_t health, uint8_t power, uint8_t *hiwater) NONBANKED {
122 122
 
123 123
 static void show_explosion(uint16_t power) NONBANKED {
124 124
     snd_music_off();
125
+    sample_play_explosion_ship();
125 126
 
126
-    snd_explode();
127
-
128
-    for (uint8_t n = 0; n < (4 * 4); n++) {
127
+    for (uint8_t n = 0; n < (4 * 4 * 4); n++) {
129 128
         uint8_t hiwater = SPR_NUM_START;
130
-        spr_draw(SPR_EXPL, FLIP_NONE, 0, 0, n >> 2, &hiwater);
129
+        if (n < (4 * 4)) {
130
+            spr_draw(SPR_EXPL, FLIP_NONE, 0, 0, n >> 2, &hiwater);
131
+        }
131 132
         status(0, power >> POWER_SHIFT, &hiwater);
132 133
         hide_sprites_range(hiwater, MAX_HARDWARE_SPRITES);
133 134
         vsync();

+ 3
- 0
src/obj.c View File

@@ -24,6 +24,7 @@
24 24
 
25 25
 #include "sprites.h"
26 26
 #include "game.h"
27
+#include "sample.h"
27 28
 #include "obj.h"
28 29
 
29 30
 /*
@@ -333,6 +334,8 @@ int16_t obj_do(int16_t *spd_off_x, int16_t *spd_off_y, int32_t *score, uint8_t *
333 334
 
334 335
                     if ((abs(objs[i].off_x - objs[j].off_x) <= SHOT_RANGE)
335 336
                             && (abs(objs[i].off_y - objs[j].off_y) <= SHOT_RANGE)) {
337
+                        sample_play_explosion_orbs();
338
+
336 339
                         objs[i].active = 0;
337 340
                         objs[j].active = 0;
338 341
 

+ 18
- 0
src/sample.c View File

@@ -24,6 +24,8 @@
24 24
  */
25 25
 
26 26
 #include "sfx_shoot.h"
27
+#include "sfx_expl_orb.h"
28
+#include "sfx_expl_ship.h"
27 29
 #include "sample.h"
28 30
 
29 31
 static volatile uint8_t play_bank = 1;
@@ -38,6 +40,22 @@ void sample_play_shoot(void) NONBANKED {
38 40
     }
39 41
 }
40 42
 
43
+void sample_play_explosion_orbs(void) NONBANKED {
44
+    CRITICAL {
45
+        play_bank = BANK(sfx_expl_orb);
46
+        play_sample = sfx_expl_orb;
47
+        play_length = sfx_expl_orb_SIZE >> 4;
48
+    }
49
+}
50
+
51
+void sample_play_explosion_ship(void) NONBANKED {
52
+    CRITICAL {
53
+        play_bank = BANK(sfx_expl_ship);
54
+        play_sample = sfx_expl_ship;
55
+        play_length = sfx_expl_ship_SIZE >> 4;
56
+    }
57
+}
58
+
41 59
 void sample_isr(void) NONBANKED NAKED {
42 60
     __asm
43 61
     ld hl, #_play_length    ; something left to play?

+ 2
- 0
src/sample.h View File

@@ -21,6 +21,8 @@
21 21
 #define __SAMPLE_H__
22 22
 
23 23
 void sample_play_shoot(void);
24
+void sample_play_explosion_orbs(void);
25
+void sample_play_explosion_ship(void);
24 26
 void sample_isr(void);
25 27
 
26 28
 #endif // __SAMPLE_H__

+ 0
- 10
src/sound.c View File

@@ -173,13 +173,3 @@ void snd_play(void) NONBANKED {
173 173
         }
174 174
     END_ROM_BANK();
175 175
 }
176
-
177
-void snd_explode(void) BANKED {
178
-    // TODO use something more elaborate than noise
179
-    //return;
180
-
181
-    NR41_REG = 0x00; // length timer, higher value is shorter time (up to 0x3F)
182
-    NR42_REG = 0xF1; // initially full volume, then fade sound out
183
-    NR43_REG = 0x46; // frequency distribution
184
-    NR44_REG = 0xC0; // trigger and enable length
185
-}

+ 0
- 2
src/sound.h View File

@@ -73,8 +73,6 @@ void snd_game_music(void) BANKED;
73 73
 void snd_gameover_music(void) BANKED;
74 74
 void snd_play(void);
75 75
 
76
-void snd_explode(void) BANKED;
77
-
78 76
 BANKREF_EXTERN(sound)
79 77
 
80 78
 #endif // __SOUND_H__

Loading…
Cancel
Save