Commit 806bea4

Nick committed on
WIP on adding effects/instruments
commit 806bea4bb2cc549418039d0979bd2ee56abc8866 parent bb19bd3
5 changed files +100−34
Added4ify.py +19−0
@@ -0,0 +1,19 @@
1 file = 'test_wave'
2
3 orig = open(f'{file}.raw', 'rb').read()
4 newf = open(f'{file}2.raw', 'wb')
5 destf = open(f'{file}3.raw', 'wb')
6
7 ls1 = []
8 for byte in orig:
9 new = int((byte/255)*15)
10 ls1.append(new)
11 newf.write(bytes([new]))
12
13 for pair in zip(ls1[::2], ls1[1::2]):
14 h, l = pair
15 new = (h << 4) | l
16 destf.write(bytes([new]))
17
18 newf.close()
19 destf.close()
ModifiedUnitMain.lfm +2−2
@@ -1,7 +1,7 @@
1 object frmGameboy: TfrmGameboy 1 object frmGameboy: TfrmGameboy
2 Left = 3304 2 Left = 3306
3 Height = 354 3 Height = 354
4 Top = 337 4 Top = 338
5 Width = 318 5 Width = 318
6 Caption = 'Gameboy' 6 Caption = 'Gameboy'
7 ClientHeight = 324 7 ClientHeight = 324
Modifiedconstants.inc +2−1
@@ -72,4 +72,5 @@ G8 EQU 67
72 G#8 EQU 68 72 G#8 EQU 68
73 A8 EQU 69 73 A8 EQU 69
74 A#8 EQU 70 74 A#8 EQU 70
75 B8 EQU 71 75 B8 EQU 71
76 LAST_NOTE EQU 72
Modifieddriver.z80 +68−30
@@ -104,8 +104,8 @@ SECTION "Song Data", ROM0
104 order_cnt: db 8 104 order_cnt: db 8
105 order1: dw unreal, lunawaves, lunawaves, unreal 105 order1: dw unreal, lunawaves, lunawaves, unreal
106 order2: dw lunawaves, unreal, unreal, lunawaves 106 order2: dw lunawaves, unreal, unreal, lunawaves
107 order3: dw lunawaves 107 order3: dw unreal, lunawaves, lunawaves, unreal
108 order4: dw 108 order4: dw unreal, lunawaves, lunawaves, unreal
109 109
110 lunawaves: 110 lunawaves:
111 include "lunawaves.inc" 111 include "lunawaves.inc"
@@ -158,6 +158,23 @@ _init:
158 ld bc, `00000001 158 ld bc, `00000001
159 call _paint_tile 159 call _paint_tile
160 160
161 ;; Load some wave data into _AUD3WAVERAM
162 ld hl, $150 ;; note_table
163 _addr = _AUD3WAVERAM
164 REPT 16
165 ld a, [hl+]
166 ldh [_addr], a
167 _addr = _addr + 1
168 ENDR
169
170 ;; Enable chanel 3
171 ; ld a, $80
172 ; ldh [rAUD3ENA], a
173 ; ld a, $ff
174 ; ldh [rAUD3LEN], a
175 ; ld a, $20
176 ; ldh [rAUD3LEVEL], a
177
161 ; Enable sound globally 178 ; Enable sound globally
162 ld a, $80 179 ld a, $80
163 ldh [rAUDENA], a 180 ldh [rAUDENA], a
@@ -208,7 +225,6 @@ _lookup_note:
208 ;; Pattern pointer in DE 225 ;; Pattern pointer in DE
209 226
210 ;; Stores note value in H and L 227 ;; Stores note value in H and L
211
212 ld a, [row] 228 ld a, [row]
213 229
214 ld h, 0 230 ld h, 0
@@ -216,6 +232,15 @@ _lookup_note:
216 add hl, de 232 add hl, de
217 ld a, [hl] 233 ld a, [hl]
218 234
235 cp LAST_NOTE
236 jp c, .note_exists
237
238 ;; Pop the return pointer off the stack and get the one the caller pushed
239 pop hl
240 ld hl, 0
241 ret
242
243 .note_exists:
219 add a, a ;; double it to get index into hi/lo table 244 add a, a ;; double it to get index into hi/lo table
220 245
221 LD H, 0 246 LD H, 0
@@ -236,7 +261,7 @@ _playnote1:
236 261
237 ld a, %11111111 ; $10 262 ld a, %11111111 ; $10
238 ldh [rAUD1LEN], a 263 ldh [rAUD1LEN], a
239 ld a, %11110000 264 ld a, %00110000
240 ldh [rAUD1ENV], a 265 ldh [rAUD1ENV], a
241 266
242 ld a, l 267 ld a, l
@@ -269,17 +294,11 @@ _playnote3:
269 ;; Note value in H and L 294 ;; Note value in H and L
270 295
271 ;; Play a note on channel 3 (waveform) 296 ;; Play a note on channel 3 (waveform)
272 297 ld a, l
273 ; ld a, %10111111 ; $10 298 ldh [rAUD3LOW], a
274 ; ldh [rAUD1LEN], a 299 ld a, h
275 ; ld a, %11110000 300 or %10000000
276 ; ldh [rAUD1ENV], a 301 ldh [rAUD3HIGH], a
277
278 ; ld a, l
279 ; ldh [rAUD1LOW], a
280 ; ld a, h
281 ; or %10000000
282 ; ldh [rAUD1HIGH], a
283 ret 302 ret
284 303
285 _playnote4: 304 _playnote4:
@@ -288,16 +307,15 @@ _playnote4:
288 307
289 ;; Play a "note" on channel 4 (noise) 308 ;; Play a "note" on channel 4 (noise)
290 309
291 ; ld a, %10111111 ; $10 310 ld a, 1
292 ; ldh [rAUD1LEN], a 311 ld [rAUD4LEN], a
293 ; ld a, %11110000 312 ld a, %11110111
294 ; ldh [rAUD1ENV], a 313 ldh [rAUD4ENV], a
314 ld a, l; %01000100
315 ldh [rAUD4POLY], a
316 ld a, %10000000
317 ldh [rAUD4GO], a
295 318
296 ; ld a, l
297 ; ldh [rAUD1LOW], a
298 ; ld a, h
299 ; or %10000000
300 ; ldh [rAUD1HIGH], a
301 ret 319 ret
302 320
303 loadShort: MACRO 321 loadShort: MACRO
@@ -316,27 +334,42 @@ _dosound:
316 ;; We're on tick zero, so lookup and play the notes, 334 ;; We're on tick zero, so lookup and play the notes,
317 ;; then continue as usual 335 ;; then continue as usual
318 336
337 ;; For each call of _lookup_note we push an address to jump to,
338 ;; and the procedure will discard its normal return value if it needs to
339 ;; skip a note and use the new value instead.
340
341 ld hl, _after_note1
342 push hl
319 loadShort pattern1, d, e 343 loadShort pattern1, d, e
320 call _lookup_note 344 call _lookup_note
321 call _playnote1 345 call _playnote1
322 346
323 loadShort pattern2, d, e 347 _after_note1:
324 call _lookup_note 348 ; ld hl, _after_note2
325 call _playnote2 349 ; push hl
350 ; loadShort pattern2, d, e
351 ; call _lookup_note
352 ; call _playnote2
326 353
354 _after_note2:
355 ; ld hl, _after_note3
356 ; push hl
327 ; loadShort pattern3, d, e 357 ; loadShort pattern3, d, e
328 ; call _lookup_note 358 ; call _lookup_note
329 ; call _playnote 359 ; call _playnote3
330 360
361 _after_note3:
362 ; ld hl, _process_tick
363 ; push hl
331 ; loadShort pattern4, d, e 364 ; loadShort pattern4, d, e
332 ; call _lookup_note 365 ; call _lookup_note
333 ; call _playnote 366 ; call _playnote4
334 367
335 _process_tick: 368 _process_tick:
336 ld a, c 369 ld a, c
337 inc a 370 inc a
338 371
339 cp TICKS ;;TODO: Change to a parameter somewhere 372 cp TICKS
340 jp z, _newrow 373 jp z, _newrow
341 374
342 ld [tick], a 375 ld [tick], a
@@ -352,6 +385,7 @@ _newrow:
352 inc a 385 inc a
353 cp PATTERN_LENGTH 386 cp PATTERN_LENGTH
354 jr nz, noreset 387 jr nz, noreset
388
355 ;; Increment order and change loaded patterns 389 ;; Increment order and change loaded patterns
356 ld a, [order_cnt] 390 ld a, [order_cnt]
357 ld b, a 391 ld b, a
@@ -381,6 +415,10 @@ _halt:
381 nop 415 nop
382 jr _halt 416 jr _halt
383 417
418 SECTION "Wave stuff", ROM0
419 test_wave:
420 incbin "test_wave3.raw"
421
384 SECTION "Note Table", ROM0 422 SECTION "Note Table", ROM0
385 note_table: 423 note_table:
386 include "music.inc" 424 include "music.inc"
Modifiedunreal.inc +9−1
@@ -1,4 +1,12 @@
1 ;; unreal superhero 1 note: MACRO ;; (note, instr, effect)
2 db \1
3 db ((\2 << 4) | (\3 >> 8))
4 db LOW(\3)
5 ENDM
6
7 ; ;; unreal superhero
8 note F4, 01, $A01
9
2 db F4 10 db F4
3 db G#4 11 db G#4
4 db C5 12 db C5