@@ -124,59 +124,63 @@ SECTION "Song Data", ROM0 |
| 124 |
order_cnt: db 2 |
124 |
order_cnt: db 2 |
| 125 |
order1: dw unreal ;; unreal ;; unreal;, lunawaves, lunawaves, unreal |
125 |
order1: dw unreal ;; unreal ;; unreal;, lunawaves, lunawaves, unreal |
| 126 |
order2: dw unreal_arps ;; empty, unreal, unreal, lunawaves |
126 |
order2: dw unreal_arps ;; empty, unreal, unreal, lunawaves |
| 127 |
order3: dw empty, lunawaves, lunawaves, unreal |
127 |
order3: dw empty |
| 128 |
order4: dw empty, lunawaves, lunawaves, unreal |
128 |
order4: dw empty |
| 129 |
|
129 |
|
| 130 |
lunawaves: |
130 |
; lunawaves: |
| 131 |
include "lunawaves.inc" |
131 |
; include "lunawaves.inc" |
| 132 |
unreal: |
132 |
unreal: |
| 133 |
include "unreal.inc" |
133 |
include "unreal.inc" |
| 134 |
unreal_arps: |
134 |
unreal_arps: |
| 135 |
include "unreal_arps.inc" |
135 |
include "unreal_arps.inc" |
|
|
136 |
tfau_arps: |
|
|
137 |
include "tfau_arps.inc" |
|
|
138 |
tfau_bass: |
|
|
139 |
include "tfau_bass.inc" |
| 136 |
empty: |
140 |
empty: |
| 137 |
rept 64 |
141 |
rept 64 |
| 138 |
db 90, 0, 0 |
142 |
db 90, 0, 0 |
| 139 |
endr |
143 |
endr |
| 140 |
drums: |
144 |
; drums: |
| 141 |
rept 16 |
145 |
; rept 16 |
| 142 |
db 44, 0, 0 |
146 |
; db 44, 0, 0 |
| 143 |
db 90, 0, 0 |
147 |
; db 90, 0, 0 |
| 144 |
db 90, 0, 0 |
148 |
; db 90, 0, 0 |
| 145 |
db 90, 0, 0 |
149 |
; db 90, 0, 0 |
| 146 |
endr |
150 |
; endr |
| 147 |
slideup: |
151 |
; slideup: |
| 148 |
dn C4, 00, $000 |
152 |
; dn C4, 00, $000 |
| 149 |
rept 63 |
153 |
; rept 63 |
| 150 |
dn 90, 00, $101 |
154 |
; dn 90, 00, $101 |
| 151 |
endr |
155 |
; endr |
| 152 |
arps: |
156 |
; arps: |
| 153 |
rept 64 |
157 |
; rept 64 |
| 154 |
dn C5, 00, $047 |
158 |
; dn C5, 00, $047 |
| 155 |
endr |
159 |
; endr |
| 156 |
vib: |
160 |
vib: |
| 157 |
dn C5, 00, $000 |
161 |
dn C5, 00, $000 |
| 158 |
rept 63 |
162 |
rept 63 |
| 159 |
dn 90, 00, $443 |
163 |
dn 90, 00, $443 |
| 160 |
endr |
164 |
endr |
| 161 |
updown: |
165 |
; updown: |
| 162 |
dn C4, 00, $105 |
166 |
; dn C4, 00, $105 |
| 163 |
rept 31 |
167 |
; rept 31 |
| 164 |
dn 90, 00, $105 |
168 |
; dn 90, 00, $105 |
| 165 |
endr |
169 |
; endr |
| 166 |
rept 32 |
170 |
; rept 32 |
| 167 |
dn 90, 00, $205 |
171 |
; dn 90, 00, $205 |
| 168 |
endr |
172 |
; endr |
| 169 |
volset: |
173 |
; volset: |
| 170 |
dn C5, 00, $000 |
174 |
; dn C5, 00, $000 |
| 171 |
rept 32 |
175 |
; rept 32 |
| 172 |
dn 90, 00, $C90 |
176 |
; dn 90, 00, $C90 |
| 173 |
dn 90, 00, $CF0 |
177 |
; dn 90, 00, $CF0 |
| 174 |
endr |
178 |
; endr |
| 175 |
notecut: |
179 |
; notecut: |
| 176 |
rept 32 |
180 |
; rept 32 |
| 177 |
dn C5, 00, $E04 |
181 |
; dn C5, 00, $E04 |
| 178 |
dn 90, 00, $000 |
182 |
; dn 90, 00, $000 |
| 179 |
endr |
183 |
; endr |
| 180 |
|
184 |
|
| 181 |
SECTION "Playback variables", WRAM0 |
185 |
SECTION "Playback variables", WRAM0 |
| 182 |
pattern1: dw |
186 |
pattern1: dw |
@@ -349,6 +353,9 @@ _lookup_note: |
| 349 |
;; Pattern pointer in DE |
353 |
;; Pattern pointer in DE |
| 350 |
|
354 |
|
| 351 |
;; Stores note period value in HL |
355 |
;; Stores note period value in HL |
|
|
356 |
;; Stores instrument/effect code in B |
|
|
357 |
;; Stores effect params in C |
|
|
358 |
|
| 352 |
ld a, [row] |
359 |
ld a, [row] |
| 353 |
ld h, a |
360 |
ld h, a |
| 354 |
;; Multiply by 3 for the note value |
361 |
;; Multiply by 3 for the note value |
@@ -388,12 +395,6 @@ _convert_note: |
| 388 |
ccf ;; uh....? |
395 |
ccf ;; uh....? |
| 389 |
ret |
396 |
ret |
| 390 |
|
397 |
|
| 391 |
strip_instrument: MACRO |
|
|
| 392 |
ld a, b |
|
|
| 393 |
and %00001111 |
|
|
| 394 |
cp $3 |
|
|
| 395 |
ENDM |
|
|
| 396 |
|
|
|
| 397 |
_update_channel: |
398 |
_update_channel: |
| 398 |
;; Call with: |
399 |
;; Call with: |
| 399 |
;; Channel in B |
400 |
;; Channel in B |
@@ -430,14 +431,28 @@ _update_channel4: |
| 430 |
|
431 |
|
| 431 |
ret |
432 |
ret |
| 432 |
|
433 |
|
|
|
434 |
strip_instrument: MACRO |
|
|
435 |
ld a, b |
|
|
436 |
and %00001111 |
|
|
437 |
ENDM |
|
|
438 |
|
|
|
439 |
;;;;;;; |
|
|
440 |
;; Note playing routines. Need to either consolidate these or find some |
|
|
441 |
;; better way of doing effects that happen on the first tick. |
|
|
442 |
;;;;;;; |
|
|
443 |
|
| 433 |
_playnote1: |
444 |
_playnote1: |
| 434 |
;; Call with: |
445 |
;; Call with: |
| 435 |
;; Note value in H and L |
446 |
;; Note value in H and L |
| 436 |
;; instrument + effect code in B |
447 |
;; Instrument + effect code in B |
|
|
448 |
;; Effect params in C |
|
|
449 |
|
|
|
450 |
;; Free: A, D, E |
| 437 |
|
451 |
|
| 438 |
;; Play a note on channel 1 (square wave) |
452 |
;; Play a note on channel 1 (square wave) |
| 439 |
strip_instrument |
453 |
strip_instrument |
| 440 |
|
454 |
|
|
|
455 |
cp $3 |
| 441 |
jr nz, .no_toneporta |
456 |
jr nz, .no_toneporta |
| 442 |
ld a, h |
457 |
ld a, h |
| 443 |
ld [toneporta_target1+1], a |
458 |
ld [toneporta_target1+1], a |
@@ -446,10 +461,17 @@ _playnote1: |
| 446 |
ret |
461 |
ret |
| 447 |
|
462 |
|
| 448 |
.no_toneporta: |
463 |
.no_toneporta: |
| 449 |
ld a, %10111111 |
464 |
cp $C |
|
|
465 |
jr nz, .no_volume |
|
|
466 |
ld e, c |
|
|
467 |
jr .set_regs |
|
|
468 |
.no_volume: |
|
|
469 |
ld e, %11110000 ; TODO: Get from instrument |
|
|
470 |
.set_regs: |
|
|
471 |
ld a, %01111111 |
| 450 |
ld [rAUD1LEN], a |
472 |
ld [rAUD1LEN], a |
| 451 |
|
473 |
|
| 452 |
ld a, %11110000 |
474 |
ld a, e |
| 453 |
ld [rAUD1ENV], a |
475 |
ld [rAUD1ENV], a |
| 454 |
|
476 |
|
| 455 |
ld a, l |
477 |
ld a, l |
@@ -471,6 +493,7 @@ _playnote2: |
| 471 |
;; Play a note on channel 2 (square wave) |
493 |
;; Play a note on channel 2 (square wave) |
| 472 |
strip_instrument |
494 |
strip_instrument |
| 473 |
|
495 |
|
|
|
496 |
cp $3 |
| 474 |
jr nz, .no_toneporta |
497 |
jr nz, .no_toneporta |
| 475 |
ld a, h |
498 |
ld a, h |
| 476 |
ld [toneporta_target2+1], a |
499 |
ld [toneporta_target2+1], a |
@@ -479,14 +502,23 @@ _playnote2: |
| 479 |
ret |
502 |
ret |
| 480 |
|
503 |
|
| 481 |
.no_toneporta: |
504 |
.no_toneporta: |
| 482 |
ld a, %00111111 ; $10 |
505 |
cp $C |
|
|
506 |
jr nz, .no_volume |
|
|
507 |
ld e, c |
|
|
508 |
jr .set_regs |
|
|
509 |
.no_volume: |
|
|
510 |
ld e, %11110000 ; TODO: Get from instrument |
|
|
511 |
.set_regs: |
|
|
512 |
ld a, %01111111 ; $10 |
| 483 |
ld [rAUD2LEN], a |
513 |
ld [rAUD2LEN], a |
| 484 |
ld a, %11110000 |
514 |
|
|
|
515 |
ld a, e |
| 485 |
ld [rAUD2ENV], a |
516 |
ld [rAUD2ENV], a |
| 486 |
|
517 |
|
| 487 |
ld a, l |
518 |
ld a, l |
| 488 |
ld [channel_period2], a |
519 |
ld [channel_period2], a |
| 489 |
ld [rAUD2LOW], a |
520 |
ld [rAUD2LOW], a |
|
|
521 |
|
| 490 |
ld a, h |
522 |
ld a, h |
| 491 |
ld [channel_period2+1], a |
523 |
ld [channel_period2+1], a |
| 492 |
or %10000000 |
524 |
or %10000000 |
@@ -501,6 +533,7 @@ _playnote3: |
| 501 |
;; Play a note on channel 3 (waveform) |
533 |
;; Play a note on channel 3 (waveform) |
| 502 |
strip_instrument |
534 |
strip_instrument |
| 503 |
|
535 |
|
|
|
536 |
cp $3 |
| 504 |
jr nz, .no_toneporta |
537 |
jr nz, .no_toneporta |
| 505 |
ld a, h |
538 |
ld a, h |
| 506 |
ld [toneporta_target2+1], a |
539 |
ld [toneporta_target2+1], a |
@@ -589,7 +622,11 @@ _doeffect: |
| 589 |
jp fx_no_op ;fx_set_duty ;9xy |
622 |
jp fx_no_op ;fx_set_duty ;9xy |
| 590 |
jp fx_no_op ;fx_vol_slide ;Axy |
623 |
jp fx_no_op ;fx_vol_slide ;Axy |
| 591 |
jp fx_no_op ;fx_pos_jump ;Bxy |
624 |
jp fx_no_op ;fx_pos_jump ;Bxy |
| 592 |
jp fx_set_volume ;Cxy |
625 |
jp fx_set_volume |
|
|
626 |
; ret ;Cxy Volume always runs on first tick |
|
|
627 |
; nop |
|
|
628 |
; nop |
|
|
629 |
jp fx_no_op |
| 593 |
jp fx_no_op ;fx_pattern_break ;Dxy |
630 |
jp fx_no_op ;fx_pattern_break ;Dxy |
| 594 |
jp fx_note_cut ;Exy |
631 |
jp fx_note_cut ;Exy |
| 595 |
jp fx_no_op ;fx_set_speed ;Fxy |
632 |
jp fx_no_op ;fx_set_speed ;Fxy |
@@ -685,15 +722,19 @@ fx_vibrato: |
| 685 |
swap a |
722 |
swap a |
| 686 |
ld d, a |
723 |
ld d, a |
| 687 |
|
724 |
|
| 688 |
ld a, [tick] |
725 |
ld a, [tick] ; Probably should change to some constantly ticking thing |
| 689 |
and d |
726 |
and d |
| 690 |
ld a, [hl] |
727 |
ld a, [hl-] |
| 691 |
jr z, .go_up |
728 |
jr z, .go_up |
| 692 |
.restore: |
729 |
.restore: |
| 693 |
call _convert_note ;; just grab the current period instead?? |
730 |
dec hl |
|
|
731 |
dec hl |
|
|
732 |
ld a, [hl-] |
|
|
733 |
ld l, [hl] |
|
|
734 |
ld h, a |
| 694 |
jr .finish_vibrato |
735 |
jr .finish_vibrato |
| 695 |
.go_up: |
736 |
.go_up: |
| 696 |
call _convert_note |
737 |
call _convert_note ; TODO: Find a way to grab it directly rather than recompute |
| 697 |
ld a, c |
738 |
ld a, c |
| 698 |
and %00001111 |
739 |
and %00001111 |
| 699 |
add_a_to_hl |
740 |
add_a_to_hl |
@@ -944,10 +985,6 @@ _dosound: |
| 944 |
;; We're on tick zero, so lookup and play the notes, |
985 |
;; We're on tick zero, so lookup and play the notes, |
| 945 |
;; then return |
986 |
;; then return |
| 946 |
|
987 |
|
| 947 |
;; For each call of _lookup_note we push an address to jump to, |
|
|
| 948 |
;; and the procedure will discard its normal return value if it needs to |
|
|
| 949 |
;; skip a note and use the new value instead. |
|
|
| 950 |
|
|
|
| 951 |
loadShort pattern1, d, e |
988 |
loadShort pattern1, d, e |
| 952 |
call _lookup_note |
989 |
call _lookup_note |
| 953 |
jr nc, .after_note1 |
990 |
jr nc, .after_note1 |
@@ -981,35 +1018,35 @@ _dosound: |
| 981 |
|
1018 |
|
| 982 |
ld a, c |
1019 |
ld a, c |
| 983 |
cp 0 |
1020 |
cp 0 |
| 984 |
jp z, after_effect1 |
1021 |
jr z, .after_effect1 |
| 985 |
|
1022 |
|
| 986 |
ld e, 0 |
1023 |
ld e, 0 |
| 987 |
call _doeffect |
1024 |
call _doeffect |
| 988 |
|
1025 |
|
| 989 |
after_effect1: |
1026 |
.after_effect1: |
| 990 |
loadShort pattern2, d, e |
1027 |
loadShort pattern2, d, e |
| 991 |
call _lookup_note |
1028 |
call _lookup_note |
| 992 |
|
1029 |
|
| 993 |
ld a, c |
1030 |
ld a, c |
| 994 |
cp 0 |
1031 |
cp 0 |
| 995 |
jp z, after_effect2 |
1032 |
jr z, .after_effect2 |
| 996 |
|
1033 |
|
| 997 |
ld e, 1 |
1034 |
ld e, 1 |
| 998 |
call _doeffect |
1035 |
call _doeffect |
| 999 |
|
1036 |
|
| 1000 |
after_effect2: |
1037 |
.after_effect2: |
| 1001 |
; loadShort pattern3, d, e |
1038 |
; loadShort pattern3, d, e |
| 1002 |
; call _lookup_note |
1039 |
; call _lookup_note |
| 1003 |
; ld e, 2 |
1040 |
; ld e, 2 |
| 1004 |
; call _doeffect |
1041 |
; call _doeffect |
| 1005 |
|
1042 |
|
| 1006 |
after_effect3: |
1043 |
.after_effect3: |
| 1007 |
; loadShort pattern4, d, e |
1044 |
; loadShort pattern4, d, e |
| 1008 |
; call _lookup_note |
1045 |
; call _lookup_note |
| 1009 |
; ld e, 3 |
1046 |
; ld e, 3 |
| 1010 |
; call _doeffect |
1047 |
; call _doeffect |
| 1011 |
|
1048 |
|
| 1012 |
after_effect4: |
1049 |
.after_effect4: |
| 1013 |
|
1050 |
|
| 1014 |
process_tick: |
1051 |
process_tick: |
| 1015 |
ld a, [tick] |
1052 |
ld a, [tick] |