@@ -36,7 +36,7 @@ STACK_SIZE EQU 20 |
| 36 |
;; Stack starts at $FFFE |
36 |
;; Stack starts at $FFFE |
| 37 |
|
37 |
|
| 38 |
PATTERN_LENGTH EQU 64 |
38 |
PATTERN_LENGTH EQU 64 |
| 39 |
TICKS EQU 4 |
39 |
; TICKS EQU 4 |
| 40 |
|
40 |
|
| 41 |
; $0000 - $003F: RST handlers. |
41 |
; $0000 - $003F: RST handlers. |
| 42 |
|
42 |
|
@@ -121,14 +121,14 @@ DB "NF" |
| 121 |
|
121 |
|
| 122 |
SECTION "Song Data", ROM0 |
122 |
SECTION "Song Data", ROM0 |
| 123 |
;; order_cnt is the number of orders times 2 |
123 |
;; order_cnt is the number of orders times 2 |
| 124 |
order_cnt: db 2 |
124 |
order_cnt: db 6 |
| 125 |
order1: dw tfau_bass ;; unreal ;; unreal;, lunawaves, lunawaves, unreal |
125 |
order1: dw tfau_bass, unreal, unreal ;; unreal ;; unreal;, lunawaves, lunawaves, unreal |
| 126 |
order2: dw tfau_arps ;; empty, unreal, unreal, lunawaves |
126 |
order2: dw tfau_arps, unreal_arps, unreal_arps ;; empty, unreal, unreal, lunawaves |
| 127 |
order3: dw empty |
127 |
order3: dw empty |
| 128 |
order4: dw empty |
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: |
@@ -188,6 +188,7 @@ pattern2: dw |
| 188 |
pattern3: dw |
188 |
pattern3: dw |
| 189 |
pattern4: dw |
189 |
pattern4: dw |
| 190 |
|
190 |
|
|
|
191 |
ticks_per_row: db |
| 191 |
current_order: dw |
192 |
current_order: dw |
| 192 |
|
193 |
|
| 193 |
;; TODO: Find some way to get rid of this thing. |
194 |
;; TODO: Find some way to get rid of this thing. |
@@ -304,6 +305,10 @@ _addr = _addr + 1 |
| 304 |
ld a, %11110000 |
305 |
ld a, %11110000 |
| 305 |
ld [envelope2], a |
306 |
ld [envelope2], a |
| 306 |
|
307 |
|
|
|
308 |
;; Load starting speed (7 ticks per row) |
|
|
309 |
ld a, 4 |
|
|
310 |
ld [ticks_per_row], a |
|
|
311 |
|
| 307 |
; Enable sound globally |
312 |
; Enable sound globally |
| 308 |
ld a, $80 |
313 |
ld a, $80 |
| 309 |
ldh [rAUDENA], a |
314 |
ldh [rAUDENA], a |
@@ -571,11 +576,11 @@ _doeffect: |
| 571 |
jp fx_no_op ;fx_set_pan ;8xy |
576 |
jp fx_no_op ;fx_set_pan ;8xy |
| 572 |
jp fx_no_op ;fx_set_duty ;9xy |
577 |
jp fx_no_op ;fx_set_duty ;9xy |
| 573 |
jp fx_no_op ;fx_vol_slide ;Axy |
578 |
jp fx_no_op ;fx_vol_slide ;Axy |
| 574 |
jp fx_no_op ;fx_pos_jump ;Bxy |
579 |
jp fx_pos_jump ;Bxy |
| 575 |
jp fx_set_volume ;Cxy |
580 |
jp fx_set_volume ;Cxy |
| 576 |
jp fx_no_op ;fx_pattern_break ;Dxy |
581 |
jp fx_pattern_break ;Dxy |
| 577 |
jp fx_note_cut ;Exy |
582 |
jp fx_note_cut ;Exy |
| 578 |
jp fx_no_op ;fx_set_speed ;Fxy |
583 |
jp fx_set_speed ;Fxy |
| 579 |
|
584 |
|
| 580 |
setup_channel_pointer: |
585 |
setup_channel_pointer: |
| 581 |
;; Call with: |
586 |
;; Call with: |
@@ -599,6 +604,55 @@ ENDM |
| 599 |
fx_no_op: |
604 |
fx_no_op: |
| 600 |
ret |
605 |
ret |
| 601 |
|
606 |
|
|
|
607 |
fx_set_speed: |
|
|
608 |
ret nz |
|
|
609 |
|
|
|
610 |
;; B: channel |
|
|
611 |
;; C: effect parameters |
|
|
612 |
|
|
|
613 |
;; free registers: A, D, E, H, L |
|
|
614 |
ld a, c |
|
|
615 |
ld [ticks_per_row], a |
|
|
616 |
ret |
|
|
617 |
|
|
|
618 |
fx_pos_jump: |
|
|
619 |
;; B: channel |
|
|
620 |
;; C: effect parameters |
|
|
621 |
|
|
|
622 |
;; free registers: A, D, E, H, L |
|
|
623 |
|
|
|
624 |
pop hl ;; remove return address |
|
|
625 |
pop hl ;; remove the AF pushed |
|
|
626 |
|
|
|
627 |
;; when we return from here, it will be as if we returned from the main |
|
|
628 |
;; _dosound function |
|
|
629 |
|
|
|
630 |
ld a, c |
|
|
631 |
add a ;; double it, as orders are words |
|
|
632 |
|
|
|
633 |
jp _update_current_order |
|
|
634 |
|
|
|
635 |
fx_pattern_break: |
|
|
636 |
;; B: channel |
|
|
637 |
;; C: effect parameters |
|
|
638 |
|
|
|
639 |
;; free registers: A, D, E, H, L |
|
|
640 |
|
|
|
641 |
pop hl ;; remove return address |
|
|
642 |
pop hl ;; remove the AF pushed |
|
|
643 |
|
|
|
644 |
;; when we return from here, it will be as if we returned from the main |
|
|
645 |
;; _dosound function |
|
|
646 |
|
|
|
647 |
ld b, c |
|
|
648 |
|
|
|
649 |
call _neworder |
|
|
650 |
|
|
|
651 |
ld a, b |
|
|
652 |
ld [row], a |
|
|
653 |
|
|
|
654 |
reti |
|
|
655 |
|
| 602 |
;; TODO: Fix this |
656 |
;; TODO: Fix this |
| 603 |
fx_note_cut: |
657 |
fx_note_cut: |
| 604 |
;; B: channel |
658 |
;; B: channel |
@@ -1050,10 +1104,13 @@ _dosound: |
| 1050 |
.after_effect4: |
1104 |
.after_effect4: |
| 1051 |
|
1105 |
|
| 1052 |
process_tick: |
1106 |
process_tick: |
|
|
1107 |
ld a, [ticks_per_row] |
|
|
1108 |
ld b, a |
|
|
1109 |
|
| 1053 |
ld a, [tick] |
1110 |
ld a, [tick] |
| 1054 |
inc a |
1111 |
inc a |
| 1055 |
|
1112 |
|
| 1056 |
cp TICKS |
1113 |
cp b |
| 1057 |
jp z, _newrow |
1114 |
jp z, _newrow |
| 1058 |
|
1115 |
|
| 1059 |
ld [tick], a |
1116 |
ld [tick], a |
@@ -1068,29 +1125,26 @@ _newrow: |
| 1068 |
ld a, [row] |
1125 |
ld a, [row] |
| 1069 |
inc a |
1126 |
inc a |
| 1070 |
cp PATTERN_LENGTH |
1127 |
cp PATTERN_LENGTH |
| 1071 |
jr nz, .noreset |
1128 |
jr nz, _noreset |
| 1072 |
|
1129 |
_neworder: |
| 1073 |
;; Increment order and change loaded patterns |
1130 |
;; Increment order and change loaded patterns |
| 1074 |
ld a, [order_cnt] |
1131 |
ld a, [order_cnt] |
| 1075 |
ld b, a |
1132 |
ld c, a |
| 1076 |
ld a, [current_order] |
1133 |
ld a, [current_order] |
| 1077 |
add a, 2 |
1134 |
add a, 2 |
| 1078 |
cp b |
1135 |
cp c |
| 1079 |
jr nz, .update_current_order |
1136 |
jr nz, _update_current_order |
| 1080 |
xor a ; ld a, 0 |
1137 |
xor a ; ld a, 0 |
| 1081 |
.update_current_order: |
1138 |
_update_current_order: |
| 1082 |
ld [current_order], a |
1139 |
ld [current_order], a |
| 1083 |
ld c, a |
1140 |
ld c, a |
| 1084 |
|
1141 |
|
| 1085 |
call _refresh_patterns |
1142 |
call _refresh_patterns |
| 1086 |
|
1143 |
|
| 1087 |
xor a ; ld a, 0 |
1144 |
xor a ; ld a, 0 |
| 1088 |
ld [row], a |
|
|
| 1089 |
reti |
|
|
| 1090 |
|
1145 |
|
| 1091 |
.noreset: |
1146 |
_noreset: |
| 1092 |
ld [row], a |
1147 |
ld [row], a |
| 1093 |
|
|
|
| 1094 |
reti |
1148 |
reti |
| 1095 |
|
1149 |
|
| 1096 |
_halt: |
1150 |
_halt: |