Commit 0bc0456

Nick committed on
Arpeggios!
commit 0bc0456ebbc1727759bb99c1aab24838046c277f parent 76552b6
1 changed files +104−19
Modifieddriver.z80 +104−19
@@ -123,7 +123,7 @@ 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 2
125 order1: dw empty ;; unreal ;; unreal;, lunawaves, lunawaves, unreal 125 order1: dw empty ;; unreal ;; unreal;, lunawaves, lunawaves, unreal
126 order2: dw slideup ;; empty, unreal, unreal, lunawaves 126 order2: dw arps ;; empty, unreal, unreal, lunawaves
127 order3: dw empty, lunawaves, lunawaves, unreal 127 order3: dw empty, lunawaves, lunawaves, unreal
128 order4: dw empty, lunawaves, lunawaves, unreal 128 order4: dw empty, lunawaves, lunawaves, unreal
129 129
@@ -147,6 +147,18 @@ slideup:
147 rept 63 147 rept 63
148 dn 90, 00, $101 148 dn 90, 00, $101
149 endr 149 endr
150 arps:
151 rept 64
152 dn C5, 00, $047
153 endr
154 updown:
155 dn C4, 00, $105
156 rept 31
157 dn 90, 00, $105
158 endr
159 rept 32
160 dn 90, 00, $205
161 endr
150 162
151 SECTION "Playback variables", WRAM0 163 SECTION "Playback variables", WRAM0
152 pattern1: dw 164 pattern1: dw
@@ -157,9 +169,9 @@ pattern4: dw
157 current_order: dw 169 current_order: dw
158 170
159 ;; Size of a channel in bytes 171 ;; Size of a channel in bytes
160 CHANNEL_SIZE EQU 4 172 CHANNEL_SIZE EQU 8
161 ;; Amount to be shifted in order to skip a channel. 173 ;; Amount to be shifted in order to skip a channel.
162 CHANNEL_SIZE_EXPONENT EQU 2 174 CHANNEL_SIZE_EXPONENT EQU 3
163 175
164 channels: 176 channels:
165 177
@@ -169,6 +181,8 @@ channels:
169 channel1: 181 channel1:
170 channel_period1: dw 182 channel_period1: dw
171 toneporta_target1: dw 183 toneporta_target1: dw
184 channel_note1: db
185 ds 3 ;; Just padding at the moment but may contain more stuff later
172 186
173 ;;;;;;;;;;; 187 ;;;;;;;;;;;
174 ;;Channel 2 188 ;;Channel 2
@@ -176,6 +190,8 @@ toneporta_target1: dw
176 channel2: 190 channel2:
177 channel_period2: dw 191 channel_period2: dw
178 toneporta_target2: dw 192 toneporta_target2: dw
193 channel_note2: db
194 ds 3
179 195
180 ;;;;;;;;;;; 196 ;;;;;;;;;;;
181 ;;Channel 3 197 ;;Channel 3
@@ -183,6 +199,8 @@ toneporta_target2: dw
183 channel3: 199 channel3:
184 channel_period3: dw 200 channel_period3: dw
185 toneporta_target3: dw 201 toneporta_target3: dw
202 channel_note3: db
203 ds 3
186 204
187 ;;;;;;;;;;; 205 ;;;;;;;;;;;
188 ;;Channel 4 206 ;;Channel 4
@@ -190,6 +208,8 @@ toneporta_target3: dw
190 channel4: 208 channel4:
191 channel_period4: dw 209 channel_period4: dw
192 toneporta_target4: dw 210 toneporta_target4: dw
211 channel_note4: db
212 ds 3
193 213
194 row: ds 1 214 row: ds 1
195 tick: ds 1 215 tick: ds 1
@@ -302,7 +322,7 @@ _lookup_note:
302 ;; Call with: 322 ;; Call with:
303 ;; Pattern pointer in DE 323 ;; Pattern pointer in DE
304 324
305 ;; Stores note value in H and L 325 ;; Stores note period value in HL
306 ld a, [row] 326 ld a, [row]
307 ld h, a 327 ld h, a
308 ;; Multiply by 3 for the note value 328 ;; Multiply by 3 for the note value
@@ -320,12 +340,18 @@ _lookup_note:
320 ld b, a 340 ld b, a
321 341
322 ld a, [hl] 342 ld a, [hl]
343 ld [channel_note2], a
323 344
345 _try_convert_note:
324 cp LAST_NOTE 346 cp LAST_NOTE
325 jp c, .note_exists 347 jp c, _convert_note
326 ret 348 ret
327 349
328 .note_exists: 350 _convert_note:
351 ;; Call with:
352 ;; Note number in A
353 ;; Stores note period value in HL
354
329 add a, a ;; double it to get index into hi/lo table 355 add a, a ;; double it to get index into hi/lo table
330 356
331 LD H, 0 357 LD H, 0
@@ -410,7 +436,7 @@ _playnote1:
410 436
411 ld a, h 437 ld a, h
412 ld [channel_period1+1], a 438 ld [channel_period1+1], a
413 or %10000000 439 or %00000000
414 ld [rAUD1HIGH], a 440 ld [rAUD1HIGH], a
415 441
416 ret 442 ret
@@ -441,7 +467,7 @@ _playnote2:
441 ld [rAUD2LOW], a 467 ld [rAUD2LOW], a
442 ld a, h 468 ld a, h
443 ld [channel_period2+1], a 469 ld [channel_period2+1], a
444 or %10000000 470 or %00000000
445 ld [rAUD2HIGH], a 471 ld [rAUD2HIGH], a
446 ret 472 ret
447 473
@@ -488,12 +514,6 @@ _playnote4:
488 514
489 ret 515 ret
490 516
491 ; cphl: MACRO
492 ; or a
493 ; sbc hl, \1
494 ; add hl, \1
495 ; ENDM
496
497 loadShort: MACRO 517 loadShort: MACRO
498 ld a, [\1] 518 ld a, [\1]
499 ld \3, a 519 ld \3, a
@@ -533,7 +553,7 @@ _doeffect:
533 553
534 .jump: 554 .jump:
535 ;; Jump table for effect 555 ;; Jump table for effect
536 jp fx_no_op ;fx_arpeggio ;0xy 556 jp fx_arpeggio ;0xy
537 jp fx_porta_up ;1xy 557 jp fx_porta_up ;1xy
538 jp fx_porta_down ;2xy 558 jp fx_porta_down ;2xy
539 jp fx_toneporta ;3xy 559 jp fx_toneporta ;3xy
@@ -553,12 +573,14 @@ _doeffect:
553 setup_channel_pointer: 573 setup_channel_pointer:
554 ;; Call with: 574 ;; Call with:
555 ;; Channel value in B 575 ;; Channel value in B
576 ;; Offset in D
556 ;; Returns value in HL 577 ;; Returns value in HL
557 578
558 ld a, b 579 ld a, b
559 REPT CHANNEL_SIZE_EXPONENT 580 REPT CHANNEL_SIZE_EXPONENT
560 sla a 581 sla a
561 ENDR 582 ENDR
583 add d
562 ld hl, channels 584 ld hl, channels
563 add_a_to_hl 585 add_a_to_hl
564 ret 586 ret
@@ -566,6 +588,58 @@ setup_channel_pointer:
566 fx_no_op: 588 fx_no_op:
567 ret 589 ret
568 590
591 fx_arpeggio:
592 ld b, e ;; so we have access to DE
593 ;; B: channel
594 ;; C: effect parameters
595
596 ;; free registers: A, D, E, H, L
597
598 ld d, 4
599 call setup_channel_pointer
600
601 ld a, [tick]
602 dec a
603 ;; Multiply by 3 to get offset into table
604 ld e, a
605 add e
606 add e
607
608 ld d, [hl]
609
610 ld hl, .arp_options
611 add_a_to_hl
612 jp hl
613
614 .arp_options:
615 jp .set_arp1
616 jp .set_arp2
617 jp .reset_arp
618 jp .set_arp1
619 jp .set_arp2
620 jp .set_arp1
621 jp .set_arp2
622 jp .reset_arp
623 jp .set_arp1
624 jp .set_arp2
625 .reset_arp:
626 ld a, d
627 jp .finish_skip_add
628 .set_arp2:
629 ld a, c
630 swap a
631 jp .finish_arp
632 .set_arp1:
633 ld a, c
634 .finish_arp:
635 and %00001111
636 add d
637 .finish_skip_add:
638 call _convert_note
639 ld d, h
640 ld e, l
641 jp _update_channel
642
569 fx_porta_up: 643 fx_porta_up:
570 ld b, e ;; so we have access to DE 644 ld b, e ;; so we have access to DE
571 ;; B: channel 645 ;; B: channel
@@ -573,6 +647,7 @@ fx_porta_up:
573 647
574 ;; free registers: A, D, E, H, L 648 ;; free registers: A, D, E, H, L
575 649
650 ld d, 0
576 call setup_channel_pointer 651 call setup_channel_pointer
577 652
578 ld a, [hl+] 653 ld a, [hl+]
@@ -597,6 +672,7 @@ fx_porta_down:
597 672
598 ;; free registers: A, D, E, H, L 673 ;; free registers: A, D, E, H, L
599 674
675 ld d, 0
600 call setup_channel_pointer 676 call setup_channel_pointer
601 677
602 ld a, [hl+] 678 ld a, [hl+]
@@ -624,6 +700,7 @@ fx_toneporta:
624 ;; better than using the stack hack which forces all effects to screw with 700 ;; better than using the stack hack which forces all effects to screw with
625 ;; pushing and popping. Most effects won't need to do this. 701 ;; pushing and popping. Most effects won't need to do this.
626 702
703 ld d, 0
627 call setup_channel_pointer 704 call setup_channel_pointer
628 push hl 705 push hl
629 706
@@ -739,12 +816,22 @@ _dosound:
739 816
740 loadShort pattern1, d, e 817 loadShort pattern1, d, e
741 call _lookup_note 818 call _lookup_note
819
820 ld a, c
821 cp 0
822 jp z, after_effect1
823
742 ld e, 0 824 ld e, 0
743 call _doeffect 825 call _doeffect
744 826
745 after_effect1: 827 after_effect1:
746 loadShort pattern2, d, e 828 loadShort pattern2, d, e
747 call _lookup_note 829 call _lookup_note
830
831 ld a, c
832 cp 0
833 jp z, after_effect2
834
748 ld e, 1 835 ld e, 1
749 call _doeffect 836 call _doeffect
750 837
@@ -781,7 +868,7 @@ _newrow:
781 ld a, [row] 868 ld a, [row]
782 inc a 869 inc a
783 cp PATTERN_LENGTH 870 cp PATTERN_LENGTH
784 jr nz, .noreset 871 jp nz, .noreset
785 872
786 ;; Increment order and change loaded patterns 873 ;; Increment order and change loaded patterns
787 ld a, [order_cnt] 874 ld a, [order_cnt]
@@ -810,11 +897,9 @@ _halt:
810 ; Do nothing, forever 897 ; Do nothing, forever
811 halt 898 halt
812 nop 899 nop
813 jr _halt 900 jp _halt
814 901
815 SECTION "Wave stuff", ROM0 902 SECTION "Wave stuff", ROM0
816 test_wave:
817 incbin "test_wave3.raw"
818 903
819 SECTION "Note Table", ROM0 904 SECTION "Note Table", ROM0
820 note_table: 905 note_table: