Browse Source

fix music note duration reading from proper bank, start working on game music

Thomas B 3 weeks ago
parent
commit
c198beb8e0
4 changed files with 45 additions and 11 deletions
  1. 10
    1
      src/sound.c
  2. 29
    4
      src/sound_game.c
  3. 3
    3
      src/sound_menu.c
  4. 3
    3
      src/sound_over.c

+ 10
- 1
src/sound.c View File

@@ -24,6 +24,7 @@
24 24
  * See <http://www.gnu.org/licenses/>.
25 25
  */
26 26
 
27
+#include "asm/types.h"
27 28
 #include "banks.h"
28 29
 #include "config.h"
29 30
 #include "timer.h"
@@ -134,6 +135,14 @@ void snd_note_off(void) BANKED {
134 135
     play_note2(SILENCE);
135 136
 }
136 137
 
138
+static uint16_t snd_duration(enum SOUNDS snd) NONBANKED {
139
+    uint16_t r;
140
+    START_ROM_BANK(snds[snd].bank) {
141
+        r = snds[snd].snd->duration;
142
+    } END_ROM_BANK
143
+    return r;
144
+}
145
+
137 146
 void snd_music(enum SOUNDS snd) BANKED {
138 147
     if (snd >= SND_COUNT) {
139 148
         return;
@@ -142,7 +151,7 @@ void snd_music(enum SOUNDS snd) BANKED {
142 151
     CRITICAL {
143 152
         music = snds[snd].snd;
144 153
         bank = snds[snd].bank;
145
-        duration = 0x3F - MIN((snds[snd].snd->duration >> 2) + 1, 0x3F);
154
+        duration = 0x3F - MIN((snd_duration(snd) >> 2) + 1, 0x3F);
146 155
         off = 0;
147 156
         last_t = timer_get();
148 157
     }

+ 29
- 4
src/sound_game.c View File

@@ -28,14 +28,39 @@
28 28
 
29 29
 BANKREF(sound_game)
30 30
 
31
-const enum notes game_music[] = {
32
-    SILENCE, SILENCE, END
31
+#define NOTE_LOOP \
32
+    F1,  F1,  F1,  G1, Gd2, Gd1, Cd1,  D1, \
33
+    D2,  D2,  D2, Fd1, Fd1,  D2,  D2,  D2
34
+
35
+
36
+static const enum notes game_music[] = {
37
+    NOTE_LOOP, NOTE_LOOP, NOTE_LOOP, NOTE_LOOP,
38
+    NOTE_LOOP, NOTE_LOOP, NOTE_LOOP, NOTE_LOOP,
39
+
40
+    SILENCE, SILENCE, SILENCE, SILENCE,
41
+    SILENCE, SILENCE, SILENCE, SILENCE,
42
+    SILENCE, SILENCE, SILENCE, SILENCE,
43
+    SILENCE, SILENCE, SILENCE, SILENCE,
44
+    END
45
+};
46
+
47
+#define DRUM_LOOP \
48
+dSn, dSI, dSn, dSI, dKi, dSI, dSI, dSI, \
49
+dSn, dSI, dSn, dSI, dKi, dSI, dSI, dSI  \
50
+
51
+static const enum drums game_drums[] = {
52
+    DRUM_LOOP, DRUM_LOOP, DRUM_LOOP, DRUM_LOOP,
53
+    DRUM_LOOP, DRUM_LOOP, DRUM_LOOP, DRUM_LOOP,
54
+
55
+    dSI, dSI, dSI, dSI, dSI, dSI, dSI, dSI,
56
+    dSI, dSI, dSI, dSI, dSI, dSI, dSI, dSI,
57
+    dEND
33 58
 };
34 59
 
35 60
 const struct music music_game = {
36 61
     .notes = game_music,
37 62
     .notes2 = NULL,
38
-    .drums = NULL,
39
-    .duration = 200,
63
+    .drums = game_drums,
64
+    .duration = 160,
40 65
     .repeat = 0,
41 66
 };

+ 3
- 3
src/sound_menu.c View File

@@ -28,7 +28,7 @@
28 28
 
29 29
 BANKREF(sound_menu)
30 30
 
31
-const enum notes menu_music[] = {
31
+static const enum notes menu_music[] = {
32 32
     // intro
33 33
 
34 34
      G2,  G2,  D2,  D2,  F1,  F1,  G1,  G1, // 1
@@ -112,7 +112,7 @@ const enum notes menu_music[] = {
112 112
     END
113 113
 };
114 114
 
115
-const enum notes menu_music2[] = {
115
+static const enum notes menu_music2[] = {
116 116
     // intro
117 117
 
118 118
     SIL, SIL, SIL, SIL, SIL, SIL, SIL, SIL,
@@ -200,7 +200,7 @@ const enum notes menu_music2[] = {
200 200
     dSI, dSI, dSn, dSI, dKi, dSI, dSI, dSI, \
201 201
     dSn, dSI, dSI, dSI, dKi, dSI, dSI, dSI  \
202 202
 
203
-const enum drums menu_drums[] = {
203
+static const enum drums menu_drums[] = {
204 204
     // intro
205 205
 
206 206
     DRUM_LOOP,

+ 3
- 3
src/sound_over.c View File

@@ -29,7 +29,7 @@
29 29
 
30 30
 BANKREF(sound_over)
31 31
 
32
-const enum notes over_notes[] = {
32
+static const enum notes over_notes[] = {
33 33
     // fanfare
34 34
     /*
35 35
      C3,  C3,  C3,  C3, Ab2, Ab2, Bb2, Bb2,
@@ -121,7 +121,7 @@ const enum notes over_notes[] = {
121 121
      E2, SIL,  E2, SIL,  E2, SIL,  E2, SIL, \
122 122
      E2, SIL,  E2, SIL,  E2, SIL,  E2, SIL
123 123
 
124
-const enum notes over_notes2[] = {
124
+static const enum notes over_notes2[] = {
125 125
     ADD_LOOP, ADD_LOOP_2,
126 126
     ADD_LOOP, ADD_LOOP_3,
127 127
     ADD_LOOP, ADD_LOOP_2,
@@ -165,7 +165,7 @@ const enum notes over_notes2[] = {
165 165
     dKi, dSI, dSI, dSI, dSI, dSI, dKi, dSI, \
166 166
     dSn, dSI, dSI, dSI, dKi, dSI, dSI, dSI  \
167 167
 
168
-const enum drums over_drums[] = {
168
+static const enum drums over_drums[] = {
169 169
     DRUM_LOOP,
170 170
     DRUM_LOOP,
171 171
     DRUM_LOOP,

Loading…
Cancel
Save