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
 
122
 
123
 static void show_explosion(uint16_t power) NONBANKED {
123
 static void show_explosion(uint16_t power) NONBANKED {
124
     snd_music_off();
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
         uint8_t hiwater = SPR_NUM_START;
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
         status(0, power >> POWER_SHIFT, &hiwater);
132
         status(0, power >> POWER_SHIFT, &hiwater);
132
         hide_sprites_range(hiwater, MAX_HARDWARE_SPRITES);
133
         hide_sprites_range(hiwater, MAX_HARDWARE_SPRITES);
133
         vsync();
134
         vsync();

+ 3
- 0
src/obj.c View File

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

+ 18
- 0
src/sample.c View File

24
  */
24
  */
25
 
25
 
26
 #include "sfx_shoot.h"
26
 #include "sfx_shoot.h"
27
+#include "sfx_expl_orb.h"
28
+#include "sfx_expl_ship.h"
27
 #include "sample.h"
29
 #include "sample.h"
28
 
30
 
29
 static volatile uint8_t play_bank = 1;
31
 static volatile uint8_t play_bank = 1;
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
 void sample_isr(void) NONBANKED NAKED {
59
 void sample_isr(void) NONBANKED NAKED {
42
     __asm
60
     __asm
43
     ld hl, #_play_length    ; something left to play?
61
     ld hl, #_play_length    ; something left to play?

+ 2
- 0
src/sample.h View File

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

+ 0
- 10
src/sound.c View File

173
         }
173
         }
174
     END_ROM_BANK();
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
 void snd_gameover_music(void) BANKED;
73
 void snd_gameover_music(void) BANKED;
74
 void snd_play(void);
74
 void snd_play(void);
75
 
75
 
76
-void snd_explode(void) BANKED;
77
-
78
 BANKREF_EXTERN(sound)
76
 BANKREF_EXTERN(sound)
79
 
77
 
80
 #endif // __SOUND_H__
78
 #endif // __SOUND_H__

Loading…
Cancel
Save