Debian Codegraph @

src/asm/6502/stream.s

raw
1 ; Furnace Command Stream player for 6502 architecture
2 ; written by tildearrow
3
4 ; usage:
5 ; define the following constants:
6 ; - FCS_MAX_CHAN: the number of channels in your stream
7 ; - fcsAddrBase: player state address base
8 ; - fcsZeroPage: player state address base for zero-page-mandatory variables
9 ; - fcsGlobalStack: player stack (best placed in a page)
10 ; - fcsPtr: pointer to command stream
11 ; - fcsVolMax: pointer to max channel volume array
12 ; - fcsCmdTableLow: low address of command table
13 ; - fcsCmdTableHigh: high address of command table
14 ; - see stream_example.i for an example
15 ; call fcsInit - this sets A to 0 on success or 1 on failure
16 ; call fcsTick on every frame/tick/whatever
17 ; - call your dispatch implementation's tick function afterwards
18
19 ; notes:
20 ; - short pointers only
21 ; - little-endian only!
22
23 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
24
25 ; calculated from player constants
26 fcsDelays=fcsPtr+8
27 fcsSpeedDial=fcsPtr+24
28 fcsStackSize=fcsPtr+40+(FCS_MAX_CHAN*2)
29
30 ; variables
31 ; these may be read by your command handling routines
32 fcsArg0=fcsAddrBase ; int
33 fcsArg1=fcsAddrBase+4 ; int
34 ; something else
35 fcsTicks=fcsAddrBase+8 ; short
36 ; temporary variables
37 fcsSendVolume=fcsAddrBase+10 ; char
38 fcsSendPitch=fcsAddrBase+11 ; char
39 fcsArpSpeed=fcsAddrBase+12 ; char
40 fcsCmd=fcsAddrBase+16 ; char[8]
41 fcsTempPtr=fcsZeroPage ; short
42 ; channel state
43 chanPC=fcsZeroPage+2 ; short
44 chanTicks=fcsAddrBase+24 ; short
45 chanStackPtr=fcsAddrBase+24+(FCS_MAX_CHAN*2) ; char
46 chanNote=fcsAddrBase+24+(FCS_MAX_CHAN*2)+1 ; char
47 chanVibratoPos=fcsAddrBase+24+(FCS_MAX_CHAN*4) ; char
48 chanVibrato=fcsAddrBase+24+(FCS_MAX_CHAN*4)+1 ; char
49 chanPitch=fcsAddrBase+24+(FCS_MAX_CHAN*6) ; char
50 chanArp=fcsAddrBase+24+(FCS_MAX_CHAN*6)+1 ; char
51 chanPortaSpeed=fcsAddrBase+24+(FCS_MAX_CHAN*8) ; char
52 chanPortaTarget=fcsAddrBase+24+(FCS_MAX_CHAN*8)+1 ; char
53 chanVol=fcsAddrBase+24+(FCS_MAX_CHAN*10) ; short
54 chanVolSpeed=fcsAddrBase+24+(FCS_MAX_CHAN*12) ; short
55 chanPan=fcsAddrBase+24+(FCS_MAX_CHAN*14) ; short
56 chanArpStage=fcsAddrBase+24+(FCS_MAX_CHAN*16) ; char
57 chanArpTicks=fcsAddrBase+24+(FCS_MAX_CHAN*16)+1 ; char
58 chanVibratoDebug=fcsAddrBase+24+(FCS_MAX_CHAN*18) ; char
59
60 ; may be used for driver detection
61 fcsDriverInfo:
62 .db "Furnace"
63 .db 0
64
65 ; x: channel*2
66 ; a is set to next byte
67 .MACRO fcsReadNext
68 ; a=chanPC[x]
69 lda (chanPC,x)
70 ; increase PC
71 inc chanPC,x
72 bne +
73 inc chanPC+1,x
74 +
75 .ENDM
76
77 ; same as fcsReadNext, but don't change PC
78 .MACRO fcsPeekNext
79 ; a=chanPC[x]
80 lda (chanPC,x)
81 .ENDM
82
83 ; note on null
84 fcsNoteOnNull:
85 lda #0
86 sta chanVibratoPos,x
87 ldy #$00
88 jsr fcsDispatchCmd
89 rts
90
91 ; note off, note off env, env release
92 fcsNoArgDispatchB4:
93 tya
94 sec
95 sbc #$b4
96 tay
97 jsr fcsDispatchCmd
98 rts
99
100 fcsOneByteDispatchB4:
101 tya
102 pha
103 fcsReadNext
104 sta fcsArg0
105 pla
106 sec
107 sbc #$b4
108 tay
109 jsr fcsDispatchCmd
110 rts
111
112 ; dispatch subroutines for full commands
113 fcsNoArgDispatch:
114 jsr fcsDispatchCmd
115 rts
116
117 fcsOneByteDispatch:
118 tya
119 pha
120 fcsReadNext
121 sta fcsArg0
122 pla
123 tay
124 jsr fcsDispatchCmd
125 rts
126
127 fcsTwoByteDispatch:
128 tya
129 pha
130 fcsReadNext
131 sta fcsArg0
132 fcsReadNext
133 sta fcsArg1
134 pla
135 tay
136 jsr fcsDispatchCmd
137 rts
138
139 fcsOneShortDispatch:
140 tya
141 pha
142 fcsReadNext
143 sta fcsArg0
144 fcsReadNext
145 sta fcsArg0+1
146 pla
147 tay
148 jsr fcsDispatchCmd
149 rts
150
151 fcsTwoShortDispatch:
152 tya
153 pha
154 fcsReadNext
155 sta fcsArg0
156 fcsReadNext
157 sta fcsArg0+1
158 fcsReadNext
159 sta fcsArg1
160 fcsReadNext
161 sta fcsArg1+1
162 pla
163 tay
164 jsr fcsDispatchCmd
165 rts
166
167 fcsPrePorta:
168 fcsReadNext
169 pha
170 and #$80
171 sta fcsArg0
172 pla
173 and #$40
174 sta fcsArg1
175 ldy #$0c
176 jsr fcsDispatchCmd
177 rts
178
179 fcsArpTime:
180 fcsReadNext
181 sta fcsArpSpeed
182 rts
183
184 fcsVibrato:
185 fcsReadNext
186 sta chanVibrato,x
187 lda #1
188 sta fcsSendPitch
189 rts
190
191 ; TODO
192 fcsVibRange:
193 fcsVibShape:
194 fcsReadNext
195 rts
196
197 fcsPitch:
198 fcsReadNext
199 sta chanPitch,x
200 lda #1
201 sta fcsSendPitch
202 rts
203
204 fcsArpeggio:
205 fcsReadNext
206 sta chanArp,x
207 rts
208
209 fcsVolume:
210 fcsReadNext
211 sta chanVol+1,x
212 lda #0
213 sta chanVol,x
214 lda #1
215 sta fcsSendVolume
216 rts
217
218 fcsVolSlide:
219 fcsReadNext
220 sta chanVolSpeed,x
221 fcsReadNext
222 sta chanVolSpeed+1,x
223 rts
224
225 fcsPorta:
226 fcsReadNext
227 sta chanPortaTarget,x
228 fcsReadNext
229 sta chanPortaSpeed,x
230 rts
231
232 fcsLegato:
233 fcsReadNext
234 sta chanNote,x
235 sta fcsArg0
236 ldy #11
237 jsr fcsDispatchCmd
238 rts
239
240 fcsVolSlideTarget:
241 fcsReadNext
242 sta chanVolSpeed,x
243 fcsReadNext
244 sta chanVolSpeed+1,x
245 ; TODO: we don't support this yet...
246 fcsReadNext
247 fcsReadNext
248 rts
249
250 fcsNoOpOneByte:
251 fcsReadNext
252 rts
253
254 fcsPan:
255 fcsReadNext
256 sta chanPan.w,x
257 sta fcsArg0
258 fcsReadNext
259 sta chanPan.w+1,x
260 sta fcsArg1
261 ldy #10
262 jsr fcsDispatchCmd
263 rts
264
265 fcsOptPlaceholder:
266 fcsReadNext
267 fcsReadNext
268 fcsReadNext
269 rts
270
271 fcsCallI:
272 ; get address and relocate it
273 fcsReadNext
274 clc
275 adc #<fcsPtr
276 pha
277 fcsReadNext
278 adc #>fcsPtr
279 pha
280 ; ignore next two bytes
281 jsr fcsIgnoreNext
282 jsr fcsIgnoreNext
283 ; fcsPushCall BEGIN
284 ldy chanStackPtr,x
285 lda chanPC,x
286 sta fcsGlobalStack,y
287 iny
288 lda chanPC+1,x
289 sta fcsGlobalStack,y
290 iny
291 sty chanStackPtr,x
292 ; fcsPushCall END
293 pla
294 sta chanPC+1,x
295 pla
296 sta chanPC,x
297 rts
298
299 fcsOffWait:
300 ldy #0
301 sty chanTicks+1,x
302 iny
303 sty chanTicks,x
304 jsr fcsDispatchCmd
305 rts
306
307 fcsFullCmd:
308 ; read command
309 fcsReadNext
310 tay
311 lda fcsFullCmdTable-28,y
312 tay
313 lda fcsCmdReadTableLow,y
314 sta fcsTempPtr
315 lda fcsCmdReadTableHigh,y
316 sta fcsTempPtr+1
317 jmp (fcsTempPtr)
318
319 fcsSpeedDialCmd:
320 lda fcsSpeedDial-224,y
321 pha
322 tay
323 lda fcsFullCmdTable-28,y
324 tay
325 lda fcsCmdReadTableLow,y
326 sta fcsTempPtr
327 lda fcsCmdReadTableHigh,y
328 sta fcsTempPtr+1
329 pla
330 tay
331 jmp (fcsTempPtr)
332
333 fcsCall:
334 ; get address and relocate it
335 fcsReadNext
336 clc
337 adc #<fcsPtr
338 pha
339 fcsReadNext
340 adc #>fcsPtr
341 pha
342 ; fcsPushCall BEGIN
343 ; push channel PC to stack
344 ldy chanStackPtr,x
345 lda chanPC,x
346 sta fcsGlobalStack,y
347 iny
348 lda chanPC+1,x
349 sta fcsGlobalStack,y
350 iny
351 sty chanStackPtr,x
352 ; fcsPushCall END
353 pla
354 sta chanPC+1,x
355 pla
356 sta chanPC,x
357 rts
358
359 ; retrieve channel PC from stack
360 fcsRet:
361 ldy chanStackPtr,x
362 dey
363 lda fcsGlobalStack,y
364 sta chanPC+1,x
365 dey
366 lda fcsGlobalStack,y
367 sta chanPC,x
368 sty chanStackPtr,x
369 rts
370
371 fcsJump:
372 ; get address and relocate it
373 fcsReadNext
374 clc
375 adc #<fcsPtr
376 pha
377 fcsPeekNext
378 adc #>fcsPtr
379 sta chanPC+1,x
380 pla
381 sta chanPC,x
382 rts
383
384 ; TODO
385 fcsTickRate:
386 rts
387
388 fcsWaitS:
389 sec
390 fcsReadNext
391 and #$ff
392 sta chanTicks,x
393 bne +
394 clc
395 + fcsReadNext
396 adc #$ff
397 sta chanTicks+1,x
398 rts
399
400 fcsWaitC:
401 fcsReadNext
402 sta chanTicks,x
403 lda #0
404 sta chanTicks+1,x
405 rts
406
407 fcsWait1:
408 ldy #1
409 sty chanTicks,x
410 dey
411 sty chanTicks+1,x
412 rts
413
414 fcsStop:
415 lda #0
416 sta chanPC,x
417 sta chanPC+1,x
418 rts
419
420 fcsNoOp:
421 rts
422
423 ; x: channel*2
424 ; y: command
425 fcsDispatchCmd:
426 ; read command call table
427 lda fcsCmdTableLow,y
428 sta fcsTempPtr
429 lda fcsCmdTableHigh,y
430 sta fcsTempPtr+1
431 ; check for zero
432 lda fcsTempPtr
433 ora fcsTempPtr
434 beq + ; get out
435 ; handle command in dispatch code
436 jmp (fcsTempPtr)
437 ; only if pointer is zero
438 + rts
439
440 ; x: channel*2
441 fcsIgnoreNext:
442 ; increase PC
443 inc chanPC,x
444 bne +
445 inc chanPC+1,x
446 + rts
447
448 ; x: channel*2 (for speed... char variables are interleaved)
449 ; read commands
450 fcsChannelCmd:
451 ; read next byte
452 fcsReadNext
453 and #$ff ; touch flags
454
455 ; process and read arguments
456 ; if (a<0xb3)
457 bpl fcsNote ; handle $00-$7f
458 cmp #$b4
459 bpl fcsCheckOther
460
461 ; this is a note
462 fcsNote:
463 sta fcsArg0
464 sta chanNote,x
465 lda #0
466 tay
467 sta chanVibratoPos,x
468 ; call DIV_CMD_NOTE_ON
469 jsr fcsDispatchCmd
470 rts
471
472 ; check other instructions
473 fcsCheckOther:
474 ; check for preset delays
475 cmp #$f0
476 bmi fcsOther
477
478 ; handler for preset delays
479 fcsPresetDelay:
480 ; load preset delay and store it
481 tay
482 lda fcsPtr+8-240,y
483 sta chanTicks,x
484 lda #0
485 sta chanTicks+1,x
486 rts
487
488 ; other instructions
489 fcsOther:
490 ; call respective handler
491 tay
492 lda fcsInsTableLow-180,y
493 sta fcsTempPtr
494 lda fcsInsTableHigh-180,y
495 sta fcsTempPtr+1
496 jmp (fcsTempPtr)
497
498 ; this is called when vibrato depth is zero
499 fcsChanPitchShortcut:
500 ; extend pitch sign
501 lda chanPitch,x
502 sta fcsArg0
503 bmi +
504
505 ; positive
506 lda #0
507 sta fcsArg0+1
508 ; dispatch command
509 ldy #9
510 jsr fcsDispatchCmd
511 ; end
512 jmp fcsChanDoPorta
513
514 ; negative
515 + lda #$ff
516 sta fcsArg0+1
517 ; dispatch command
518 ldy #9
519 jsr fcsDispatchCmd
520 ; end
521 jmp fcsChanDoPorta
522
523 ; x: channel*2
524 ; stuff that goes after command reading
525 fcsChannelPost:
526 ;;; DO VOLUME
527 fcsChanDoVolume:
528 ; if (sendVolume || chanVolSpeed[x]!=0)
529 lda fcsSendVolume
530 bne +
531 lda chanVolSpeed,x
532 ora chanVolSpeed+1,x
533 beq fcsChanDoPitch
534 ; increase volume
535 + lda chanVol,x
536 clc
537 adc chanVolSpeed,x
538 sta chanVol,x
539 lda chanVol+1,x
540 adc chanVolSpeed+1,x
541 sta chanVol+1,x
542 ; TODO: handle vol slide with target
543 ; get sign of volume speed
544 lda chanVolSpeed+1,x
545 bpl fcsChanPlus
546 fcsChanMinus:
547 ; if (chanVol[x]<0)
548 bcs fcsChanSubmitVol
549 ; chanVol[x]=0
550 lda #0
551 sta chanVol,x
552 sta chanVol+1,x
553 beq fcsChanSubmitVol ; shortcut
554 fcsChanPlus:
555 ; if (chanVol[x]>=fcsVolMax[x] || CARRY)
556 bcs + ; overflow check
557 lda chanVol+1,x ; comparison check
558 cmp fcsVolMax.w,x
559 bmi fcsChanSubmitVol
560 ; chanVol[x]=fcsVolMax[x]
561 + lda fcsVolMax.w,x
562 sta chanVol+1,x
563 lda #0
564 sta chanVol,x
565 fcsChanSubmitVol:
566 lda chanVol+1,x
567 sta fcsArg0
568 ldy #$05 ; volume
569 jsr fcsDispatchCmd
570
571 ;;; DO PITCH
572 fcsChanDoPitch:
573 ; check for vibrato depth
574 lda chanVibrato,x
575 and #$0f ; depth only
576 bne +
577 jmp fcsChanDoPitch1
578
579 ; update vibrato
580 ; 1. store vibrato pitch table offset
581 + lda chanVibrato,x
582 rol
583 rol
584 rol
585 rol
586 and #$f0
587 sta fcsTempPtr
588 ; 2. update vibrato position
589 lda chanVibrato,x
590 lsr
591 lsr
592 lsr
593 lsr
594 clc
595 adc chanVibratoPos,x
596 and #$3f
597 sta chanVibratoPos,x
598 ; 3. calculate vibrato pitch
599 ; - we use 15 quarter sine tables, one for each vibrato depth
600 ; - 32-63 are negatives of 0-31
601 ; - a&31: zero is zero. otherwise a-1 in the table unless a&16
602 ; - if a&16 then invert a
603 tay
604 ; check for zero in a&31
605 and #$1f
606 bne +
607 ; it is. load zero
608 lda #0
609 jmp fcsPostVibratoCalc1
610 ; it is not. check a&16
611 + and #$10
612 bne +
613 ; 0-15
614 dey
615 tya
616 and #$0f
617 jmp fcsPostVibratoCalc
618 ; 16-31
619 + tya
620 and #$0f
621 eor #$0f ; 0-15 -> 15-0
622
623 fcsPostVibratoCalc:
624 ; check for 32-63
625 pha
626 tya
627 and #$20
628 bne +
629 ; 0-31
630 pla
631 clc
632 adc fcsTempPtr
633 tay
634 lda fcsVibTable-16,y
635 jmp fcsPostVibratoCalc1
636 ; 32-63 (negate)
637 + pla
638 clc
639 adc fcsTempPtr
640 tay
641 lda fcsVibTable-16,y
642 eor #$ff
643 clc
644 adc #1
645
646 ; at this point, a contains the vibrato pitch
647 fcsPostVibratoCalc1:
648 sta fcsArg0
649 sta chanVibratoDebug,x
650 ; extend sign
651 bmi +
652 lda #0
653 sta fcsArg0+1
654 beq ++
655 + lda #$ff
656 sta fcsArg0+1
657 ; extend pitch sign
658 ++ lda chanPitch,x
659 sta fcsTempPtr
660 bmi +
661 lda #0
662 sta fcsTempPtr+1
663 beq ++
664 + lda #$ff
665 sta fcsTempPtr+1
666 ; add pitch
667 ++ lda fcsArg0
668 clc
669 adc fcsTempPtr
670 sta fcsArg0
671 lda fcsArg0+1
672 adc fcsTempPtr+1
673 sta fcsArg0+1
674 ; dispatch command
675 ldy #9
676 jsr fcsDispatchCmd
677 jmp fcsChanDoPorta
678
679 ; check whether we should send pitch
680 ; (vibrato depth is zero)
681 fcsChanDoPitch1:
682 lda fcsSendPitch
683 beq fcsChanDoPorta
684 jmp fcsChanPitchShortcut
685
686 ;;; DO PORTAMENTO
687 fcsChanDoPorta:
688 ; if (chanPortaSpeed[x])
689 lda chanPortaSpeed,x
690 beq fcsChanDoArp
691 ; do portamento
692 sta fcsArg0
693 lda #0
694 sta fcsArg0+1
695 lda chanPortaTarget,x
696 sta fcsArg1
697 ldy #8 ; NOTE_PORTA
698 jsr fcsDispatchCmd
699 ; get out (we can't do porta and arp simultaneously)
700 rts
701
702 ;;; DO ARPEGGIO
703 fcsChanDoArp:
704 ; if (chanArp[x] && !chanPortaSpeed[x])
705 lda chanArp,x
706 beq fcsChanEnd
707 ; if (chanArpTicks[x]==0)
708 lda chanArpTicks,x
709 bne ++
710 ; switch (chanArpStage[x])
711 lda chanArpStage,x
712 cmp #1 ; mi is 0, eq is 1 and pl is 2
713 beq fcsChanArp1
714 bpl fcsChanArp2
715 ; bmi fcsChanArp0
716 fcsChanArp0:
717 lda chanNote,x
718 jmp fcsChanArpPost
719 fcsChanArp1:
720 lda chanArp,x
721 lsr
722 lsr
723 lsr
724 lsr
725 clc
726 adc chanNote,x
727 jmp fcsChanArpPost
728 fcsChanArp2:
729 lda chanArp,x
730 and #$0f
731 clc
732 adc chanNote,x
733 jmp fcsChanArpPost
734
735 fcsChanArpPost:
736 sta fcsArg0
737 ldy #11 ; legato
738 jsr fcsDispatchCmd
739
740 ; post-operations
741 lda chanArpStage,x
742 clc
743 adc #1
744 cmp #3
745 ; if (chanArpStage[x]>=3) chanArpStage[x]=0
746 bmi +
747 lda #0
748 + sta chanArpStage,x
749
750 ; chanArpTicks[x]=fcsArpSpeed
751 lda fcsArpSpeed
752 sta chanArpTicks,x
753
754 ; chanArpTicks[x]--
755 ++ dec chanArpTicks,x
756
757 ;;; END
758 fcsChanEnd:
759 rts
760
761 ; x: channel*2
762 fcsDoChannel:
763 ; initialize
764 lda #0
765 sta fcsSendVolume
766 sta fcsSendPitch
767
768 ; begin processing
769 ; chanTicks--
770 + lda chanTicks,x
771 sec
772 sbc #1
773 sta chanTicks,x
774 bne + ; skip if our counter isn't zero
775
776 ; ticks lower is zero; check upper byte
777 ldy chanTicks+1,x
778 beq fcsDoChannelLoop ; go to read commands if it's zero as well
779 ; decrease ticks upper
780 dey
781 sty chanTicks+1,x
782 ; process channel stuff
783 jsr fcsChannelPost
784 rts
785
786 ; ticks is zero... read commands until chanTicks is set
787 fcsDoChannelLoop:
788 lda chanTicks,x
789 ora chanTicks+1,x
790 bne + ; get out if chanTicks is no longer zero
791 jsr fcsChannelCmd ; read next command
792 jmp fcsDoChannelLoop
793
794 + jsr fcsChannelPost
795 ; end
796 rts
797
798 fcsTick:
799 ; update channel state
800 ; for (x=0; x<FCS_MAX_CHAN; x++)
801 ldx #0
802 - jsr fcsDoChannel
803 inx
804 inx
805 cpx #FCS_MAX_CHAN*2
806 bne -
807
808 ; increase tick counter
809 inc fcsTicks
810 bne +
811 inc fcsTicks+1
812
813 ; end
814 + rts
815
816 fcsInit:
817 ; set all tick counters to 1
818 lda #1
819 ldy #0
820 ldx #(FCS_MAX_CHAN*2)
821 - dex
822 sty chanTicks,x
823 dex
824 sta chanTicks,x
825 bne -
826
827 ; set channel program counters
828 ldx #(FCS_MAX_CHAN*2)
829 - dex
830 lda fcsPtr+40.w,x
831 sta chanPC,x
832 cpx #0
833 bne -
834
835 ; relocate program counters
836 ldx #0
837 - clc
838 lda chanPC,x
839 adc #<fcsPtr
840 sta chanPC,x
841 inx
842 lda chanPC,x
843 adc #>fcsPtr
844 sta chanPC,x
845 inx
846 cpx #(FCS_MAX_CHAN*2)
847 bne -
848
849 ; initialize channel stacks
850 lda #0
851 ldx #0
852 ldy #0
853 - sta chanStackPtr,x
854 clc
855 adc fcsStackSize.w,y
856 clc
857 adc fcsStackSize.w,y
858 inx
859 inx
860 iny
861 cpx #(FCS_MAX_CHAN*2)
862 bne -
863
864 ; set volumes
865 ldx #0
866 - lda fcsVolMax.w,x
867 sta chanVol+1,x
868 inx
869 inx
870 cpx #(FCS_MAX_CHAN*2)
871 bne -
872
873 ; set arp speed
874 lda #1
875 sta fcsArpSpeed
876
877 ; success
878 lda #0
879 rts
880
881 ; floor(127*sin((x/64)*(2*pi))*depth/15)
882 fcsVibTable:
883 .db 0, 1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 7, 8, 8, 8, 8
884 .db 1, 3, 4, 6, 7, 9, 10, 11, 13, 14, 14, 15, 16, 16, 16, 16
885 .db 2, 4, 7, 9, 11, 14, 16, 17, 19, 21, 22, 23, 24, 24, 25, 25
886 .db 3, 6, 9, 12, 15, 18, 21, 23, 26, 28, 29, 31, 32, 33, 33, 33
887 .db 4, 8, 12, 16, 19, 23, 26, 29, 32, 35, 37, 39, 40, 41, 42, 42
888 .db 4, 9, 14, 19, 23, 28, 32, 35, 39, 42, 44, 46, 48, 49, 50, 50
889 .db 5, 11, 16, 22, 27, 32, 37, 41, 45, 49, 52, 54, 56, 57, 58, 59
890 .db 6, 12, 19, 25, 31, 37, 42, 47, 52, 56, 59, 62, 64, 66, 67, 67
891 .db 7, 14, 21, 28, 35, 42, 48, 53, 58, 63, 67, 70, 72, 74, 75, 76
892 .db 8, 16, 24, 32, 39, 46, 53, 59, 65, 70, 74, 78, 80, 82, 84, 84
893 .db 8, 17, 26, 35, 43, 51, 58, 65, 71, 77, 82, 85, 88, 90, 92, 93
894 .db 9, 19, 28, 38, 47, 56, 64, 71, 78, 84, 89, 93, 96, 99, 100, 101
895 .db 10, 20, 31, 41, 51, 60, 69, 77, 84, 91, 97, 101, 104, 107, 109, 110
896 .db 11, 22, 33, 44, 55, 65, 74, 83, 91, 98, 104, 109, 112, 115, 117, 118
897 .db 12, 24, 36, 48, 59, 70, 80, 89, 98, 105, 112, 117, 121, 124, 126, 127
898
899 ; COMMAND TABLE
900 ; $b4 fcsNoArgDispatch,
901 ; $b5 fcsNoArgDispatch,
902 ; $b6 fcsNoArgDispatch,
903 ; $b7 fcsNoArgDispatch,
904 ; $b8 fcsOneByteDispatch,
905 ; $b9 fcsNoOp,
906 ; $ba fcsNoOp,
907 ; $bb fcsNoOp,
908 ; $bc fcsNoOp,
909 ; $bd fcsNoOp,
910 ; $be fcsNoOp,
911 ; $bf fcsNoOp,
912 ; $c0 fcsPrePorta,
913 ; $c1 fcsArpTime,
914 ; $c2 fcsVibrato,
915 ; $c3 fcsVibRange,
916 ; $c4 fcsVibShape,
917 ; $c5 fcsPitch,
918 ; $c6 fcsArpeggio,
919 ; $c7 fcsVolume,
920 ; $c8 fcsVolSlide,
921 ; $c9 fcsPorta,
922 ; $ca fcsLegato,
923 ; $cb fcsVolSlideTarget,
924 ; $cc fcsNoOpOneByte,
925 ; $cd fcsNoOpOneByte,
926 ; $ce fcsNoOpOneByte,
927 ; $cf fcsPan,
928 ; $d0 fcsOptPlaceholder,
929 ; $d1 fcsNoOp,
930 ; $d2 fcsNoOp,
931 ; $d3 fcsNoOp,
932 ; $d4 fcsNoOp,
933 ; $d5 fcsCallI,
934 ; $d6 fcsOffWait,
935 ; $d7 fcsFullCmd,
936 ; $d8 fcsCall,
937 ; $d9 fcsRet,
938 ; $da fcsJump,
939 ; $db fcsTickRate,
940 ; $dc fcsWaitS,
941 ; $dd fcsWaitC,
942 ; $de fcsWait1,
943 ; $df fcsStop,
944 fcsInsTableHigh:
945 .db >fcsNoArgDispatchB4, >fcsNoArgDispatchB4, >fcsNoArgDispatchB4, >fcsNoArgDispatchB4, >fcsOneByteDispatchB4, >fcsNoOp, >fcsNoOp, >fcsNoOp, >fcsNoOp, >fcsNoOp, >fcsNoOp, >fcsNoOp
946 .db >fcsPrePorta, >fcsArpTime, >fcsVibrato, >fcsVibRange, >fcsVibShape, >fcsPitch, >fcsArpeggio, >fcsVolume, >fcsVolSlide, >fcsPorta, >fcsLegato, >fcsVolSlideTarget, >fcsNoOpOneByte, >fcsNoOpOneByte, >fcsNoOpOneByte, >fcsPan
947 .db >fcsOptPlaceholder, >fcsNoOp, >fcsNoOp, >fcsNoOp, >fcsNoOp, >fcsCallI, >fcsOffWait, >fcsFullCmd, >fcsCall, >fcsRet, >fcsJump, >fcsTickRate, >fcsWaitS, >fcsWaitC, >fcsWait1, >fcsStop
948 .db >fcsSpeedDialCmd, >fcsSpeedDialCmd, >fcsSpeedDialCmd, >fcsSpeedDialCmd, >fcsSpeedDialCmd, >fcsSpeedDialCmd, >fcsSpeedDialCmd, >fcsSpeedDialCmd, >fcsSpeedDialCmd, >fcsSpeedDialCmd, >fcsSpeedDialCmd, >fcsSpeedDialCmd, >fcsSpeedDialCmd, >fcsSpeedDialCmd, >fcsSpeedDialCmd, >fcsSpeedDialCmd
949
950 fcsInsTableLow:
951 .db <fcsNoArgDispatchB4, <fcsNoArgDispatchB4, <fcsNoArgDispatchB4, <fcsNoArgDispatchB4, <fcsOneByteDispatchB4, <fcsNoOp, <fcsNoOp, <fcsNoOp, <fcsNoOp, <fcsNoOp, <fcsNoOp, <fcsNoOp
952 .db <fcsPrePorta, <fcsArpTime, <fcsVibrato, <fcsVibRange, <fcsVibShape, <fcsPitch, <fcsArpeggio, <fcsVolume, <fcsVolSlide, <fcsPorta, <fcsLegato, <fcsVolSlideTarget, <fcsNoOpOneByte, <fcsNoOpOneByte, <fcsNoOpOneByte, <fcsPan
953 .db <fcsOptPlaceholder, <fcsNoOp, <fcsNoOp, <fcsNoOp, <fcsNoOp, <fcsCallI, <fcsOffWait, <fcsFullCmd, <fcsCall, <fcsRet, <fcsJump, <fcsTickRate, <fcsWaitS, <fcsWaitC, <fcsWait1, <fcsStop
954 .db <fcsSpeedDialCmd, <fcsSpeedDialCmd, <fcsSpeedDialCmd, <fcsSpeedDialCmd, <fcsSpeedDialCmd, <fcsSpeedDialCmd, <fcsSpeedDialCmd, <fcsSpeedDialCmd, <fcsSpeedDialCmd, <fcsSpeedDialCmd, <fcsSpeedDialCmd, <fcsSpeedDialCmd, <fcsSpeedDialCmd, <fcsSpeedDialCmd, <fcsSpeedDialCmd, <fcsSpeedDialCmd
955
956 fcsCmdReadTableHigh:
957 .db >fcsNoArgDispatch
958 .db >fcsOneByteDispatch
959 .db >fcsTwoByteDispatch
960 .db >fcsOneShortDispatch
961 .db >fcsTwoShortDispatch
962
963 fcsCmdReadTableLow:
964 .db <fcsNoArgDispatch
965 .db <fcsOneByteDispatch
966 .db <fcsTwoByteDispatch
967 .db <fcsOneShortDispatch
968 .db <fcsTwoShortDispatch
969
970 fcsFullCmdTable:
971 ; starting from $1c
972 .db 1
973 .db 1
974 .db 1
975 .db 4
976 .db 1
977 ; FM commands
978 .db 1
979 .db 1
980 .db 1
981 .db 2
982 .db 2
983 .db 2
984 .db 2
985 .db 2
986 .db 2
987 .db 2
988 .db 2
989 .db 2
990 .db 2
991 .db 2
992 .db 2
993 .db 2
994 .db 2
995 .db 2
996 .db 2
997 .db 2
998 .db 1
999 .db 2
1000 .db 2
1001 .db 3
1002 .db 1
1003 .db 1
1004 .db 1
1005 .db 1
1006 .db 1
1007 ; PSG commands
1008 .db 1
1009 .db 1
1010 .db 1
1011 ; Game Boy commands
1012 .db 1
1013 .db 1
1014 ; PC Engine commands
1015 .db 1
1016 .db 1
1017 ; NES
1018 .db 1
1019 .db 1
1020 ; C64
1021 .db 1
1022 .db 1
1023 .db 1
1024 .db 1
1025 .db 1
1026 .db 1
1027 .db 1
1028 .db 1
1029 .db 3
1030 .db 3
1031 ; AY commands
1032 .db 1
1033 .db 1
1034 .db 1
1035 .db 1
1036 .db 1
1037 .db 1
1038 .db 1
1039 .db 2
1040 .db 2
1041 ; FDS
1042 .db 1
1043 .db 1
1044 .db 1
1045 .db 1
1046 .db 1
1047 ; SAA1099
1048 .db 1
1049 ; Amiga
1050 .db 1
1051 .db 1
1052 .db 1
1053 ; Lynx
1054 .db 3
1055 ; QSound
1056 .db 1
1057 .db 3
1058 .db 1
1059 .db 1
1060 ; X1-010
1061 .db 1
1062 .db 1
1063 .db 1
1064 .db 1
1065 .db 1
1066 .db 1
1067 .db 1
1068 ; WonderSwan
1069 .db 1
1070 .db 1
1071 ; Namco 163
1072 .db 1
1073 .db 1
1074 .db 1
1075 .db 1
1076 .db 1
1077 .db 1
1078 .db 1
1079 .db 1
1080 .db 1
1081 .db 1
1082 .db 1
1083 .db 1
1084 ; Sound Unit
1085 .db 2
1086 .db 2
1087 .db 2
1088 .db 2
1089 .db 1
1090 .db 1
1091 ; ADPCM-A
1092 .db 1
1093 ; SNES
1094 .db 1
1095 .db 1
1096 .db 1
1097 .db 1
1098 .db 1
1099 .db 1
1100 .db 1
1101 .db 1
1102 .db 1
1103 .db 1
1104 .db 2
1105 ; NES
1106 .db 1
1107 .db 1
1108 .db 1
1109 ; macro control
1110 .db 1
1111 .db 1
1112 ; surround
1113 .db 2
1114 ; FM
1115 .db 1
1116 .db 1
1117 ; ES5506
1118 .db 1
1119 .db 4
1120 .db 4
1121 .db 2
1122 .db 2
1123 .db 3
1124 .db 1
1125 .db 1
1126 .db 2
1127 .db 2
1128 .db 1
1129 ; unused gap
1130 .db 1
1131 ; SNES
1132 .db 1
1133 .db 1
1134 ; NES linear counter
1135 .db 1
1136 ; ext cmd
1137 .db 1
1138 ; C64
1139 .db 1
1140 .db 1
1141 ; ESFM
1142 .db 2
1143 .db 2
1144 .db 2
1145 .db 2
1146 ; restart macro
1147 .db 1
1148 ; PowerNoise
1149 .db 2
1150 .db 2
1151 ; Dave
1152 .db 1
1153 .db 1
1154 .db 1
1155 .db 1
1156 .db 1
1157 ; MinMod
1158 .db 1
1159 ; Bifurcator
1160 .db 2
1161 .db 2
1162 ; FDS AutoMod
1163 .db 1
1164 ; OpMask
1165 .db 1
1166 ; MultiPCM
1167 .db 1
1168 .db 1
1169 .db 1
1170 .db 1
1171 .db 1
1172 .db 1
1173 .db 1
1174 .db 1
1175 .db 1
1176 .db 1
1177 .db 1
1178 .db 1
1179 .db 1
1180 .db 1
1181 .db 1
1182 ; SID3
1183 .db 1
1184 .db 1
1185 .db 1
1186 .db 1
1187 .db 1
1188 .db 2
1189 .db 1
1190 .db 2
1191 .db 2
1192 .db 1
1193 .db 1
1194 .db 1
1195 .db 1
1196 ; slide
1197 .db 2
1198 .db 2
1199 ; SID3 continued
1200 .db 1
1201 .db 1
1202 .db 1
1203 .db 1
1204 .db 1
1205 ; WonderSwan speaker vol
1206 .db 1