-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpokeyexp.s
1804 lines (1398 loc) · 41.1 KB
/
pokeyexp.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
; ---------------------------------------------------------------------------
;
; POKEY EXPLORER
;
; by Ivo van Poorten (C)2020
;
; License: Zero clause BSD
;
; Permission to use, copy, modify, and/or distribute this software for any
; purpose with or without fee is hereby granted.
;
; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
; REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
; AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
; INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
; LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
; OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
; PERFORMANCE OF THIS SOFTWARE.
; ---------------------------------------------------------------------------
; Timing has to be different on PAL and NTSC
PAL = 0
NTSC = 1
; Note that the _exact_ hardware framerate is not 50Hz (PAL) or 60Hz (NTSC),
; but 49.8607Hz (PAL) and 59.9277Hz (NTSC).
; Emulator settings might vary between exact 50Hz/60Hz, hardware framerate
; or broadcast framerate.
; When post-processing audio recordings, keep this in mind and adjust for it.
.if SYSTEM == PAL
FRAMES_PER_SECOND = 50
.else
FRAMES_PER_SECOND = 60
.fi
WAIT_TIME_100ms = FRAMES_PER_SECOND/10
WAIT_TIME_200ms = FRAMES_PER_SECOND/5
WAIT_TIME_500ms = FRAMES_PER_SECOND/2
WAIT_TIME_800ms = (WAIT_TIME_1s)-(WAIT_TIME_200ms)
WAIT_TIME_1s = FRAMES_PER_SECOND
WAIT_TIME_2s = FRAMES_PER_SECOND*2
WAIT_TIME_4s = FRAMES_PER_SECOND*4
; ---------------------------------------------------------------------------
icl 'cio.s'
; ---------------------------------------------------------------------------
RTCLOK = $0012
SDLSTL = $0230
SSKCTL = $0232
SHFLOK = $02be
NOCLIK = $02db
CHBAS = $02f4
CH = $02fc
CONSOL = $d01f
AUDF1 = $d200
AUDC1 = $d201
AUDF2 = $d202
AUDC2 = $d203
AUDF3 = $d204
AUDC3 = $d205
AUDF4 = $d206
AUDC4 = $d207
AUDCTL = $d208
STIMER = $d209
RANDOM = $d20a
SKCTL = $d20f
WSYNC = $d40a
; ---------------------------------------------------------------------------
zp = $fe
; ---------------------------------------------------------------------------
org $2000
; ---------------------------------------------------------------------------
; SHADOW POKEY
shadow_pokey
shadow_audf1 dta $00 ; $d200
shadow_audc1 dta $a0 ; $d201
shadow_audf2 dta $00 ; $d202
shadow_audc2 dta $a0 ; $d203
shadow_audf3 dta $00 ; $d204
shadow_audc3 dta $a0 ; $d205
shadow_audf4 dta $00 ; $d206
shadow_audc4 dta $a0 ; $d207
shadow_audctl dta $00 ; $d208
shadow_skctl dta $83 ; $d20f
; SHADOW POKEY default values
shadow_pokey_default_values
dta $00, $a0, $00, $a0, $00, $a0, $00, $a0, $00, $83
shadow_pokey_length = * - shadow_pokey_default_values
shadow_pokey_storage
dta $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
; Sweep Variables
sweep_variables
var_sweep_resolution dta $00
var_sweep_channel
var_sweep_channels dta $00
var_sweep_start_value dta $00, $00
var_sweep_end_value dta $ff, $ff
var_sweep_interval dta $01, $00
var_sweep_play_time dta $01
var_sweep_gap_time dta $01
var_sweep_poly_reset dta $00
; Sweep UI Variables
var_sweep_ui_updown
dta $00
; Sweep UI Variables default values
var_sweep_ui_default_values
dta $00
; Sweep Temporary Values
var_sweep_poly_reset_copy
dta $00
var_sweep_value
dta $00, $00, $00 ; 24-bit LE for easily detecting 16-bit overflow
; Tuning Variables
var_tuning_enabled
dta $00
var_tuning_volume
dta $07
var_tuning_note
dta $09 ; A
var_tuning_octave
dta $04
var_tuning_key_was_pressed
dta $01 ; display first run
; ---------------------------------------------------------------------------
; MAIN
main .proc
jsr detect_2nd_pokey
beq no_2nd_pokey
mwa #tuning_enabled_line tuning_line_one
mwa #tuning_volume_line tuning_line_two
mwa #tuning_note_line tuning_line_three
jsr clear_second_pokey
jsr display_tuning_variables
no_2nd_pokey
mva #>font CHBAS
mwa #display_list SDLSTL
mva #$ff NOCLIK
.if BATCH == 0
jmp main_interactive
.else
jmp main_batch
.fi
.endp
; ---------------------------------------------------------------------------
; MAIN BATCH
main_batch .proc
mwa #sweep_batch_table zp ; init (zp)
loop_batch
ldy #9
loop_set_sweep_pokey
mva (zp),y shadow_pokey,y
dey
bpl loop_set_sweep_pokey
jsr display_shadow_pokey
ldy #20
ldx #10
loop_set_sweep_variables
mva (zp),y sweep_variables,x
dey
dex
bpl loop_set_sweep_variables
jsr display_sweep_variables
jsr handle_start_key ; execute sweep
adw zp #21
lda zp
cmp #<sweep_batch_table_end
bne loop_batch
lda zp+1
cmp #>sweep_batch_table_end
bne loop_batch
endless
jmp endless
.endp
; ---------------------------------------------------------------------------
; MAIN INTERACTIVE
main_interactive .proc
open 1, 4, 0, "K"
loop
lda stereo_pokey
beq skip_display_tuning_variables
lda var_tuning_key_was_pressed ; always enabled on first run
beq skip_display_tuning_variables
jsr play_tuning_note ; play when settings are changed
jsr display_tuning_variables
skip_display_tuning_variables
jsr display_sweep_variables
jsr display_shadow_pokey
jsr play_shadow_pokey
mwa #sweep_line sweep_line_dl_location
mva #$00 SHFLOK ; set lower case, always lower case
mva #$ff CH
no_key_yet
lda CONSOL
cmp #6
bne no_start_key
jsr handle_start_key
jmp loop
no_start_key
lda CH
cmp #$ff
beq no_key_yet
bget 1, 1, keybuf
jsr handle_keypress
jmp loop
.endp
; ---------------------------------------------------------------------------
; MAIN data
keybuf
dta 0
stereo_pokey
dta 0
sweep_batch_table
.if BATCH == 1
icl 'sweeps.s'
.fi
sweep_batch_table_end
; ---------------------------------------------------------------------------
; Detect 2nd Pokey. Result in A and also store to stereo_pokey
detect_2nd_pokey .proc
wait_for_vertical_blank
; Clear SKCTL. This stops all poly counters
mva #0 SSKCTL
mva #0 SKCTL
mva #0 SKCTL+$10 ; make sure a potential 2nd pokey is cleared
wait_for_vertical_blank
; Restart SKCTL. This starts all the poly counters
mva #3 SSKCTL
mva #3 SKCTL
wait_for_vertical_blank
; Except when there's a seconds pokey!! Its counters are not restarted.
; Its RANDOM should not change.
lda RANDOM+$10
cmp RANDOM+$10
beq detected_stereo ; so equal means there's a 2nd pokey
detected_mono
mva #0 stereo_pokey
rts
detected_stereo
mva #1 stereo_pokey
rts
.endp
; ---------------------------------------------------------------------------
; CLEAR second Pokey
clear_second_pokey .proc
ldx #$0f
lda #0
clear_loop
sta $d210,x
dex
bpl clear_loop
rts
.endp
; ---------------------------------------------------------------------------
; PLAY tuning note on second Pokey
play_tuning_note .proc
lda var_tuning_enabled
bne play_the_note
play_silence
mva #0 AUDF1+$10
mva #0 AUDC1+$10
mva #0 AUDF2+$10
mva #0 AUDC2+$10
mva #0 AUDCTL+$10
mva #0 SKCTL+$10
rts
play_the_note
mva #$50 AUDCTL+$10 ; join 1+2, ch1 clock 1.79MHz
mva #$83 SKCTL+$10 ; start poly counters
ldx var_tuning_octave ; 0-9
lda mul_by_12_tab,x ; A = octave*12
clc
adc var_tuning_note
asl ; mul by 2
tax
mva tuning_table,x AUDF1+$10
mva tuning_table+1,x AUDF2+$10
mva #$a0 AUDC1+$10
lda var_tuning_volume
and #$0f ; UI treats it as an 8-bit value
clc
adc #$a0
sta AUDC2+$10
rts
.endp
mul_by_12_tab
dta 0, 12, 24, 36, 48, 60, 72, 84, 96, 108
; ---------------------------------------------------------------------------
; SWEEP and BUZZER timing macros
; clobbers A
wait_for_vertical_blank .macro
lda RTCLOK+2
wait
cmp RTCLOK+2
beq wait
.endm
; clobbers X and A
wait_number_of_frames .macro expression
ldx :expression
beq done
wait
wait_for_vertical_blank
dex
bne wait
done
.endm
; ---------------------------------------------------------------------------
; GTIA BUZZERS
gtia_buzzer_countdown .proc
ldy #WAIT_TIME_200ms
buzz
mva #0 CONSOL
wait_number_of_frames #1
dey
bne buzz
wait_number_of_frames #WAIT_TIME_800ms
rts
.endp
gtia_buzzer_error .proc
ldy #WAIT_TIME_1s
buzz
mva #0 CONSOL
wait_number_of_frames #2 ; 2 seconds to read the error message
dey
bne buzz
rts
.endp
; ---------------------------------------------------------------------------
; SWEEP helper code
do_poly_reset_if_necessary .proc
lda var_sweep_poly_reset_copy
beq sweep_poly_reset_none
cmp #2
beq sweep_poly_reset_each
; fall through, must be 1 (once), decrement so next loop it will be none
dec var_sweep_poly_reset_copy
; fall though again and do one Polycounter Reset
sweep_poly_reset_each
mva #$ff STIMER ; OK for now. Later more stable reset for Timbres
sweep_poly_reset_none
rts
.endp
wait_sweep_play_time .proc
lda var_sweep_play_time
beq do_sweep_play_time_0
cmp #1
beq do_sweep_play_time_1
cmp #2
beq do_sweep_play_time_2
bne do_sweep_play_time_3
do_sweep_play_time_0
wait_number_of_frames #WAIT_TIME_100ms
jmp play_time_done
do_sweep_play_time_1
wait_number_of_frames #WAIT_TIME_1s
jmp play_time_done
do_sweep_play_time_2
wait_number_of_frames #WAIT_TIME_2s
jmp play_time_done
do_sweep_play_time_3
wait_number_of_frames #WAIT_TIME_4s
jmp play_time_done
play_time_done
rts
.endp
wait_sweep_gap_time .proc
lda var_sweep_gap_time
beq do_sweep_gap_time_0
cmp #1
beq do_sweep_gap_time_1
cmp #2
beq do_sweep_gap_time_2
bne do_sweep_gap_time_3
do_sweep_gap_time_0
jmp gap_time_done ; 0s
; Mute here, because we don't want to mute for 0s, so don't factorize this!
do_sweep_gap_time_1
jsr mute_real_pokey
wait_number_of_frames #WAIT_TIME_100ms
jmp gap_time_done
do_sweep_gap_time_2
jsr mute_real_pokey
wait_number_of_frames #WAIT_TIME_500ms
jmp gap_time_done
do_sweep_gap_time_3
jsr mute_real_pokey
wait_number_of_frames #WAIT_TIME_1s
jmp gap_time_done
gap_time_done
rts
.endp
; ---------------------------------------------------------------------------
; SWEEP code
handle_start_key .proc
.if BATCH == 0
wait_for_release
lda CONSOL
cmp #7
bne wait_for_release
.fi
jsr mute_real_pokey
mwa #empty_line sweep_line_dl_location
wait_number_of_frames #WAIT_TIME_1s
lda var_sweep_resolution
jne do_16bit_check
; ----- 8-BIT SWEEP -----
do_8bit_check
; check start <= end
lda var_sweep_start_value
cmp var_sweep_end_value
bcc do_8bit_sweep
beq do_8bit_sweep
mwa #sweep_error sweep_line_dl_location
jsr gtia_buzzer_error
rts
do_8bit_sweep
; save pre-sweep settings
memcpyshort shadow_pokey shadow_pokey_storage shadow_pokey_length
mva var_sweep_poly_reset var_sweep_poly_reset_copy
mwa #sweep_countdown sweep_line_dl_location
jsr gtia_buzzer_countdown
jsr gtia_buzzer_countdown
jsr gtia_buzzer_countdown
jsr gtia_buzzer_countdown
; DO 8-BIT SWEEP
mwa #sweep_busy sweep_line_dl_location
; initialize start sweep value
mva var_sweep_start_value var_sweep_value
mva #0 var_sweep_value+1
loop_8bit_sweep
.if BATCH == 0
lda CONSOL
cmp #6
jeq done_8bit_sweep ; hold START to end sweep prematurely
.fi
; set sweep value to shadow_pokey channel
lda var_sweep_channel ; 0,1,2,3
asl ; 0,2,4,6
tax
lda var_sweep_value
sta shadow_pokey,x
jsr display_shadow_pokey
jsr play_shadow_pokey
jsr do_poly_reset_if_necessary
jsr wait_sweep_play_time
jsr wait_sweep_gap_time ; if non-zero, pokey will be muted
; increase var_sweep_value by interval
lda var_sweep_value
clc
adc var_sweep_interval
sta var_sweep_value
lda var_sweep_value+1
adc #0
sta var_sweep_value+1
; check overflow or greater than end_value, in that order
lda var_sweep_value+1 ; superfluous load
bne done_8bit_sweep
lda var_sweep_value
cmp var_sweep_end_value
jcc loop_8bit_sweep ; less than end_value
jeq loop_8bit_sweep ; equal, but play end_value, too
done_8bit_sweep
jmp done_whatever_sweep
; ----- 16-BIT SWEEP -----
do_16bit_check
; check start <= end
lda var_sweep_start_value+1
cmp var_sweep_end_value+1
bcc do_16bit_sweep ; start is less than end
bne msb_is_not_equal_so_error_out ; not equal, so definitely higher
msb_is_equal_so_check_lsb
lda var_sweep_start_value
cmp var_sweep_end_value
bcc do_16bit_sweep ; less than
beq do_16bit_sweep ; equal
; fall through
msb_is_not_equal_so_error_out
mwa #sweep_error sweep_line_dl_location
jsr gtia_buzzer_error
rts
do_16bit_sweep
; save pre-sweep settings
memcpyshort shadow_pokey shadow_pokey_storage shadow_pokey_length
mva var_sweep_poly_reset var_sweep_poly_reset_copy
mwa #sweep_countdown sweep_line_dl_location
jsr gtia_buzzer_countdown
jsr gtia_buzzer_countdown
jsr gtia_buzzer_countdown
jsr gtia_buzzer_countdown
; DO 16-BIT SWEEP
mwa #sweep_busy sweep_line_dl_location
mwa var_sweep_start_value var_sweep_value
mva #0 var_sweep_value+2
loop_16bit_sweep
.if BATCH == 0
lda CONSOL
cmp #6
jeq done_16bit_sweep ; hold START to end sweep prematurely
.fi
; X and Y become AUDF offsets for specific channel combinations
lda var_sweep_channel ; four options
beq do_sweep_channels_0
cmp #1
beq do_sweep_channels_1
cmp #2
beq do_sweep_channels_2
do_sweep_channels_3 ; 2+4
ldx #2
ldy #6
bne channels_selection_done
do_sweep_channels_0 ; 1+2
ldx #0
ldy #2
bne channels_selection_done
do_sweep_channels_1 ; 3+4
ldx #4
ldy #6
bne channels_selection_done
do_sweep_channels_2 ; 1+3
ldx #0
ldy #4
channels_selection_done
lda var_sweep_resolution
cmp #2 ; reverse 16-bit!
bne no_reverse_16_bit
txa ; swap X and Y
pha
tya
tax
pla
tay
no_reverse_16_bit
mva var_sweep_value shadow_pokey,x
mva var_sweep_value+1 shadow_pokey,y
jsr display_shadow_pokey
jsr play_shadow_pokey
jsr do_poly_reset_if_necessary
jsr wait_sweep_play_time
jsr wait_sweep_gap_time ; if non-zero, pokey will be muted
; - do sweep increment
lda var_sweep_value
clc
adc var_sweep_interval
sta var_sweep_value
lda var_sweep_value+1
adc var_sweep_interval+1
sta var_sweep_value+1
lda var_sweep_value+2
adc #0
sta var_sweep_value+2
; - check overflow
lda var_sweep_value+2 ; superfluous load
bne done_16bit_sweep
; 16-bit unsigned compare between var_sweep_value and var_sweep_end_value
lda var_sweep_value+1
cmp var_sweep_end_value+1
bcc loop_16bit_sweep ; value is less than end
bne done_16bit_sweep ; not equal, so definitely higher
lda var_sweep_value
cmp var_sweep_end_value
jcc loop_16bit_sweep ; less than
jeq loop_16bit_sweep ; equal, but play end_value, too
; fall through
done_16bit_sweep
done_whatever_sweep
mwa #sweep_done sweep_line_dl_location
jsr mute_real_pokey
; restore pre-sweep settings
memcpyshort shadow_pokey_storage shadow_pokey shadow_pokey_length
mva var_sweep_poly_reset_copy var_sweep_poly_reset
jsr gtia_buzzer_countdown
jsr gtia_buzzer_countdown
jsr gtia_buzzer_countdown
jsr gtia_buzzer_countdown
rts
.endp
; ---------------------------------------------------------------------------
mute_real_pokey .proc
ldx #8
loop
mva shadow_pokey_default_values,x AUDF1,x
dex
bpl loop
; leave SKCTL alone
rts
.endp
; ---------------------------------------------------------------------------
; PRINT MACROS
print_byte_to_hex .macro register, location
lda :register
tay
:+4 lsr
tax
mva hextab,x :location
tya
and #$0f
tax
mva hextab,x :location+1
.mend
memcpyshort .macro src, dst, len
ldx #0
copyloop
mva :src,x :dst,x
inx
cpx #:len
bne copyloop
.mend
print_shadow_bit .macro register, mask, offstring, onstring, location, length
lda :register
and #:mask
bne bit_on
memcpyshort :offstring :location :length
jmp bit_done
bit_on
memcpyshort :onstring :location :length
bit_done
.mend
; ---------------------------------------------------------------------------
; DISPLAY SHADOW POKEY
display_shadow_pokey
print_byte_to_hex shadow_audf1 loc_audf1
print_byte_to_hex shadow_audc1 loc_audc1
print_byte_to_hex shadow_audf2 loc_audf2
print_byte_to_hex shadow_audc2 loc_audc2
print_byte_to_hex shadow_audf3 loc_audf3
print_byte_to_hex shadow_audc3 loc_audc3
print_byte_to_hex shadow_audf4 loc_audf4
print_byte_to_hex shadow_audc4 loc_audc4
print_byte_to_hex shadow_audctl loc_audctl
print_byte_to_hex shadow_skctl loc_skctl
print_shadow_bit shadow_audctl, $80, poly17_string, \
poly9_string, \
loc_poly_string, \
poly_strlen
print_shadow_bit shadow_audctl, $40, channel_clock_base_string, \
channel_clock_179_string, \
loc_channel1_clock_string, \
channel_clock_strlen
print_shadow_bit shadow_audctl, $20, channel_clock_base_string, \
channel_clock_179_string, \
loc_channel3_clock_string, \
channel_clock_strlen
; join channels
lda shadow_audctl
and #$10
bne do_join12_on
memcpyshort join_off_string, loc_join12_string, join_strlen
jmp handle_join34
do_join12_on
memcpyshort join_on_string, loc_join12_string, join_strlen
handle_join34
lda shadow_audctl
and #$08
bne do_join34_on
memcpyshort join_off_string, loc_join34_string, join_strlen
jmp cont_display_shadow_pokey
do_join34_on
memcpyshort join_on_string, loc_join34_string, join_strlen
cont_display_shadow_pokey
print_shadow_bit shadow_audctl, $04, filter_off_string, \
filter_on_string, \
loc_filter13_string, \
filter_strlen
print_shadow_bit shadow_audctl, $02, filter_off_string, \
filter_on_string, \
loc_filter24_string, \
filter_strlen
print_shadow_bit shadow_audctl, $01, base_clock64_string, \
base_clock15_string, \
loc_base_clock_string, \
base_clock_strlen
print_shadow_bit shadow_skctl, $08, two_tone_off_string, \
two_tone_on_string, \
loc_two_tone_string, \
two_tone_strlen
rts
; ---------------------------------------------------------------------------
hextab
dta d'0123456789ABCDEF'
; ---------------------------------------------------------------------------
; SWEEP DISPLAY MACROS
case_sweep .macro val, dst, string, len
cmp #:val
bne nope
memcpyshort :string :dst :len
nope
.mend
; ---------------------------------------------------------------------------
; DISPLAY SWEEP VARIABLES
display_sweep_variables .proc
lda var_sweep_resolution
case_sweep 0, loc_sweep_resolution_string, \
sweep_resolution_8bit_string, \
sweep_resolution_strlen
case_sweep 1, loc_sweep_resolution_string, \
sweep_resolution_16bit_string, \
sweep_resolution_strlen
case_sweep 2, loc_sweep_resolution_string, \
sweep_resolution_reverse16bit_string, \
sweep_resolution_strlen
lda var_sweep_resolution
beq do_8bit_channels
do_16bit_channels
lda var_sweep_channels
case_sweep 0, loc_sweep_channels_string, \
sweep_16bit_channels_0_string, \
sweep_channels_strlen
case_sweep 1, loc_sweep_channels_string, \
sweep_16bit_channels_1_string, \
sweep_channels_strlen
case_sweep 2, loc_sweep_channels_string, \
sweep_16bit_channels_2_string, \
sweep_channels_strlen
case_sweep 3, loc_sweep_channels_string, \
sweep_16bit_channels_3_string, \
sweep_channels_strlen
jmp channels_done
do_8bit_channels
lda var_sweep_channels
case_sweep 0, loc_sweep_channels_string, \
sweep_8bit_channels_0_string, \
sweep_channels_strlen
case_sweep 1, loc_sweep_channels_string, \
sweep_8bit_channels_1_string, \
sweep_channels_strlen
case_sweep 2, loc_sweep_channels_string, \
sweep_8bit_channels_2_string, \
sweep_channels_strlen
case_sweep 3, loc_sweep_channels_string, \
sweep_8bit_channels_3_string, \
sweep_channels_strlen
channels_done
lda var_sweep_resolution
beq do_8bit_start_value
do_16bit_start_value
print_byte_to_hex var_sweep_start_value, loc_sweep_start_value_string+2
print_byte_to_hex var_sweep_start_value+1, loc_sweep_start_value_string
jmp start_value_done
do_8bit_start_value
print_byte_to_hex var_sweep_start_value, loc_sweep_start_value_string
memcpyshort two_spaces, loc_sweep_start_value_string+2, 2
start_value_done
lda var_sweep_resolution
beq do_8bit_end_value
do_16bit_end_value
print_byte_to_hex var_sweep_end_value, loc_sweep_end_value_string+2
print_byte_to_hex var_sweep_end_value+1, loc_sweep_end_value_string