-
Notifications
You must be signed in to change notification settings - Fork 1
/
PCB_ROM_20211012.s
7519 lines (6707 loc) · 204 KB
/
PCB_ROM_20211012.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
;General Information
; Project for 6502+LCD+PS2+VGA for Ben Eater circuit design
; This assembly code developed by rehsd with foundational elements from Ben Eater (others if noted in code)
; Last updated September 2021
; Assembly code compiled with vasm and uploaded to ROM on 6502 build
; Example build command line:
; vasm6502_oldstyle.exe -Fbin -dotdir -wdc02 source.s -o rom.bin
; vasm6502_oldstyle.exe -Fbin -dotdir -wdc02 g8.s -o g8.bin
; *** Hardware config ***
; W65C02 (Ben), 5.0 MHz
; VGA circuit (Ben), 10.0 MHz
; PS2 keyboard circuit (Ben)
; Joystick circuit (not on PCB)
; VIA1 PortA - PS2 keyboard input
; VIA1 PortB - 20x04 LCD in 4-bit (nibble) mode
; VIA2 PortA - SPI extra control / clock
; VIA2 PortB - Joystick input
; VIA3 PortA - SPI data
; VIA3 PortB - SPI control / clock (using external shift registers)
; VIA4 PortA - AY38910 audio data
; VIA4 PortB - AY38910 audio control
; VIA5 PortA - USB mouse (through Arduino Mega)
; VIA5 PortB - USB mouse (through Arduino Mega)
; W65C51N ACIA at $4100 (data direct from 6502 data bus)
; *** SPI devices ***
; BME280 Temp/Humidity/Pressure
; 8-char 7-segment LED Display
; VGA info
; Use X to track the video page
; Use Y to track the column in the page
; Use A to track pixel color
; 'VGA' Resolution: 100 columns x 64 rows (was 75 rows with just VGA circuit, with no 6502 integration)
; All calls to the Delay routine are tested with a 6502 clock of ~5.0 MHz. Other clock speeds may require adjusting the duration of the delays.
;6502 microprocessor reference: https://www.westerndesigncenter.com/wdc/documentation/w65c02s.pdf
;6502 dev reference: http://www.obelisk.me.uk/6502/reference.html
;6522 VIA reference: https://www.westerndesigncenter.com/wdc/documentation/w65c22.pdf
;2-line LCD display reference: ;see page 42 of https://eater.net/datasheets/HD44780.pdf
;VGA color info
; 00000000 0 #$00 black
; 00000001 1 #$01 red
; 00000010 2 #$02 dark red
; 00000011 3 #$03 bright red
; 00000100 4 #$04 green
; 00001000 8 #$08 dark green
; 00001100 12 #$0c bright green
; 00010000 16 #$10 blue
; 00100000 32 #$20 dark blue
; 00110000 48 #$30 bright blue
; 00111111 63 #$3F white
; Combine bits for other colors
; Font: 5x7 fixed https://fontstruct.com/fontstructions/show/847768/5x7_dot_matrix
; Font pixel data is stored in ROM - see charmaps at end of file
; Could add additional fonts, up to 8x8 pixels given the initial structure of this code
; Video locations start at 20 00. Increment by 00 80 to move down a line.
; Example VGA rows: 1 - 20 00
; 2 - 20 80
; 3 - 21 00
; 4 - 21 80
; 5 - 22 00
; Possible ranges: 20 00 to 3F FF
; See https://github.com/rehsd/VGA-6502/blob/main/Notes
; TO DO
; -Improve code commenting :)
; -ClearChar subroutine
; -Take advantage of 65C02 new instructions (e.g., bra, bbs, phx phy plx ply)
; -General code optimization - removal of unecessary calls, better ways of solving problems, ...
; -safety code in case text/cursor/drawing is taken outside of screen (video address range) - keyboard, mouse, other
; -Clean up variable memory locations
; -Clean up capitalization of procedures to be consistent - same with variables, etc.
; -Clean up indentation
;Variable declarations / memory-related
vidpage = $0000 ; 2 bytes
kb_wptr = $0005
kb_rptr = $0006
kb_flags = $0007
kb_flags2 = $0008
char_vp = $0010
char_vp_p1 = $0012
char_color = $0014
char_y_offset = $0016
char_current_val = $0018
message_to_process = $0019
delayDurationHighByte = $001A ;Count from this number (high byte) to FF - higher number results in shorter delay
SPI_LED_MSB = $001B
SPI_LED_LSB = $001C
SPI_LED_VAL1 = $001D
SPI_LED_VAL2 = $001E
SPI_ARD_Next_Command = $0020
SPI_ARD_Send_Next_Byte = $0021
TUNE_PTR_LO = $0039
TUNE_PTR_HI = $003A
;other addresses used throughout code
; $40, $41 Delay subroutine
; $44 Horizontal pixel writing location
; $46
; $48 Charpixel row stop
; $49 Store A while in print_stats
; $4A Store vidpage while in print_stats
; $4B Store vidpage+1 while in print_stats
; $4C Store color while in print_stats
; $50 charmap current char byte
; $52 charix row loop counter
; $54 print string current char to process
; $60 Temporarily track incoming cursor x position during procedure call (high)
; $61 Temporarily track incoming cursor x position during procedure call (low)
; $62 Temporarily track incoming cursor y position during procedure call
; $63 FillRegion loop tracking columns
; $64 FillRegion loop tracking rows
; $65 print_hex_lcd, print_dec_lcd
; $66 print_dec_lcd
; $67 print_dec_lcd
; $68 print_dec_lcd
; $69 temp storage in joystick interrupt handlers
; $6A temp storage in mouse handlers
; $6B print_dec_spi_led
; $6C print_dec_spi_led
; $6D print_dec_spi_led
; $6E print_dec_spi_led
fill_region_start_x = $A0 ;Horizontal pixel position, 0 to 99
fill_region_start_y = $A1 ;Vertical pixel position, 0 to 59
fill_region_end_x = $A2 ;Horizontal pixel position, 0 to 99
fill_region_end_y = $A3 ;Vertical pixel position, 0 to 59
fill_region_color = $A4 ;Color for fill, 0 to 63
jump_to_line_y = $A5 ;Line to jump to, 0 to 63
pixel_prev_x = $A6 ;Previous pixel x position 0 to 99
pixel_prev_y = $A7 ;Previous pixel y position 0 to 63
pixel_prev_color = $A8 ;Previous pixel COLOR 0 to 63
currently_drawing = $A9 ;0x01 if yes
fill_region_clk_start_x = $AA ;when drawing rectangles by using keyboard, joystick, mouse... capture the start of bounds
fill_region_clk_start_y = $AB
mouseFillRegionStarted = $AC ;used to track if mouse right-button has been used to mark the start of a region to fill
audio_data_to_write = $AD ;used to track when audio config data has been received from Arduino and should be processed in loop:
kb_buffer = $0200 ; 256-byte kb buffer 0200-02ff
;TO DO map out all memory spaces to ensure no potential overlaps -- where are the gaps?
TonePeriodCourseLA = $0300
TonePeriodCourseLB = $0301
TonePeriodCourseLC = $0302
TonePeriodCourseLD = $0303
TonePeriodCourseLE = $0304
TonePeriodCourseLF = $0305
TonePeriodFineLA = $0306
TonePeriodFineLB = $0307
TonePeriodFineLC = $0308
TonePeriodFineLD = $0309
TonePeriodFineLE = $030A
TonePeriodFineLF = $030B
VolumeLA = $030C
VolumeLB = $030D
VolumeLC = $030E
VolumeLD = $030F
VolumeLE = $0310
VolumeLF = $0311
TonePeriodCourseRA = $0312
TonePeriodCourseRB = $0313
TonePeriodCourseRC = $0314
TonePeriodCourseRD = $0315
TonePeriodCourseRE = $0316
TonePeriodCourseRF = $0317
TonePeriodFineRA = $0318
TonePeriodFineRB = $0319
TonePeriodFineRC = $031A
TonePeriodFineRD = $031B
TonePeriodFineRE = $031C
TonePeriodFineRF = $031D
VolumeRA = $031E
VolumeRB = $031F
VolumeRC = $0320
VolumeRD = $0321
VolumeRE = $0322
VolumeRF = $0323
NoisePeriodL1 = $0324
EnvelopePeriodCourseL1 = $0325
EnvelopePeriodFineL1 = $0326
EnvelopeShapeCycleL1 = $0327
EnableLeft1 = $0328
EnableRight1 = $0329
EnableLeft2 = $032A
EnableRight2 = $032B
NoisePeriodR1 = $032C
EnvelopePeriodCourseR1 = $032D
EnvelopePeriodFineR1 = $032E
EnvelopeShapeCycleR1 = $032F
NoisePeriodL2 = $0330
EnvelopePeriodCourseL2 = $0331
EnvelopePeriodFineL2 = $0332
EnvelopeShapeCycleL2 = $0333
NoisePeriodR2 = $0334
EnvelopePeriodCourseR2 = $0335
EnvelopePeriodFineR2 = $0336
EnvelopeShapeCycleR2 = $0337
;VIAs
;VIA1 Address Line A13 110000000000000
PORT1B = $6000
PORT1A = $6001
DDR1B = $6002
DDR1A = $6003
PCR1 = $600C
IFR1 = $600D
IER1 = $600E
;VIA2 Address Line A12 101000000000000
PORT2B = $5000
PORT2A = $5001
DDR2B = $5002
DDR2A = $5003
PCR2 = $500C
IFR2 = $500D
IER2 = $500E
;VIA3 Address Line A11 100100000000000
PORT3B = $4800
PORT3A = $4801
DDR3B = $4802
DDR3A = $4803
PCR3 = $480C
IFR3 = $480D
IER3 = $480E
;VIA 4 Address Line A10 100010000000000
PORT4B = $4400
PORT4A = $4401
DDR4B = $4402
DDR4A = $4403
PCR4 = $440C
IFR4 = $440D
IER4 = $440E
;VIA 5 Address Line A09 100001000000000
PORT5B = $4200
PORT5A = $4201
DDR5B = $4202
DDR5A = $4203
T1C_L5 = $4204
T1C_H5 = $4205
T1L_L5 = $4206
T1L_H5 = $4207
T2C_L5 = $4208
T2C_H5 = $4209
SR5 = $420A
ACR5 = $420B
PCR5 = $420C
IFR5 = $420D
IER5 = $420E
;ACIA
;Address Line A08 100000100000000
ACIA_DATA = $4100 ;A0 and A1 off
ACIA_STATUS = $4101 ;tied to A0
ACIA_COMMAND = $4102 ;tied to A1
ACIA_CONTROL = $4103 ;A0 & A1 on
;for kb_flags
RELEASE = %00000001
SHIFT = %00000010
ARROW_LEFT = %00000100
ARROW_RIGHT = %00001000
ARROW_UP = %00010000
ARROW_DOWN = %00100000
NKP5 = %01000000
NKP_PLUS = %10000000
;for kb_flags2
NKP_INSERT = %00000001
NKP_DELETE = %00000010
NKP_MINUS = %00000100
NKP_ASTERISK = %00001000
PRINTSCREEN = %00010000
;room for four more
E = %01000000
RW = %00100000
RS = %00010000
PIXEL_COL1 = %10000000
PIXEL_COL2 = %01000000
PIXEL_COL3 = %00100000
PIXEL_COL4 = %00010000
PIXEL_COL5 = %00001000
ASCII_CHARMAP = %11100000
JOYSTICK_DOWN = %00000001
JOYSTICK_UP = %00000010
JOYSTICK_PRESS = %00000100
JOYSTICK_RIGHT = %00001000
JOYSTICK_LEFT = %00010000
;VIA5 PORTB
MOUSE_LEFT = %00000001 ;PB0
MOUSE_UP = %00000010 ;PB1
MOUSE_RIGHT = %00000100 ;PB2
MOUSE_DOWN = %00001000 ;PB3
MOUSE_CLICK_LEFT = %00010000 ;PB4
MOUSE_CLICK_RIGHT = %00100000 ;PB5
MOUSE_CLICK_MIDDLE = %01000000 ;PB6
; ;PB7 unused
;VIA5 PORTA
MOUSE_LEFT_UP = %00000001 ;PA0
MOUSE_RIGHT_UP = %00000010 ;PA1
MOUSE_RIGHT_DOWN = %00000100 ;PA2
MOUSE_LEFT_DOWN = %00001000 ;PA3
;VIA2 ;PORTA
SPI_SCK = %00000001 ;Used for separate SCK on devices without OE, such as SPI 8 char 7-segment LED display with MAX7219
;VIA3 ;PORTB
OE = %00000001
SCK = %00000010
RCK_OUT = %00000100
SLOAD = %00001000
RCK_IN = %00010000
SPI_DEV0 = %00000000 ;Leave unused for now -- to toggle away from other SPI_DEVs
SPI_DEV1 = %00100000 ;8 digit 7-segment LED
SPI_DEV2_ARD = %01000000 ;Arduino Nano
SPI_DEV3 = %01100000
SPI_DEV4 = %10000000
SPI_DEV5 = %10100000
SPI_DEV6 = %11000000 ;previously Waveshare BME280 temperature sensor
SPI_DEV7 = %11100000 ;74HC595 serial to parallel shift register OE (SPI to VIA)
TIMER5_1_INTERVAL = 65535 ;Interrupt every xx ms with 5 MHz 6502
;AY38910
AY1_A9_B = %00000001
AY1_BC1 = %00000010
AY1_BDIR = %00000100
AY2_A9_B = %00010000
AY2_BC1 = %00100000
AY2_BDIR = %01000000
;Arduino SPI Communication
SPI_ARD_CMD_RESET = 00
SPI_ARD_CMD_GETSTATUS = 01
SPI_ARD_CMD_GETTWOBYTES = 02
SPI_ARD_CMD_PRINTSCREEN = 03
SPI_ARD_CMD_GETSOUNDINFO = 04
;.org $8000 ;comment here for outlining in Visual Studio editor
.org $8000
reset:
sei
cld
ldx #$ff ;initialize stack
txs
;Reset variables
lda #$00
sta mouseFillRegionStarted
; ******* LCD *******
;see page 42 of https://eater.net/datasheets/HD44780.pdf
;when running 6502 at ~5.0 MHz (versus 1.0 MHz), sometimes init needs additional call or delay
jsr lcd_init
lda #%00101000 ; Set 4-bit mode; 2-line display; 5x8 font ;See page 24 of HD44780.pdf
jsr lcd_instruction
;call again for higher clock speed setup
lda #%00101000 ; Set 4-bit mode; 2-line display; 5x8 font ;See page 24 of HD44780.pdf
jsr lcd_instruction
lda #%00001110 ; Display on; cursor on; blink off
jsr lcd_instruction
lda #%00000110 ; Increment and shift cursor; don't shift display
jsr lcd_instruction
lda #%00000001 ; Clear display
jsr lcd_instruction
lda #%00001110 ; Display on; cursor on; blink off
jsr lcd_instruction
; ******* INTERRUPTS *******
lda #$01 ;positive edge (in code from Ben)
sta PCR1 ;Set CA1 to positive edge
lda #$00 ;edge negative
sta PCR2
sta PCR3
sta PCR4
sta PCR5
lda #%10000010 ;Enables interrupt CA1 (PS2 keyboard), disables everything else. Set/Clear Timer1 Timer2 CB1 CB2 ShiftRegister CA1 CA2
sta IER1
lda #%10010000 ;Enable CB1 (joystick), disable others. Set/Clear Timer1 Timer2 CB1 CB2 ShiftRegister CA1 CA2
sta IER2
lda #%10001000 ;Used to enable CB1 (counter for temperature sensor refresh) // CA1 (ACIA) //CB2 SPI Nano , and disables everything else. Set/Clear Timer1 Timer2 CB1 CB2 ShiftRegister CA1 CA2
sta IER3
lda #%01111111 ;Disable all interrupt for this VIA -- SPI master, so interrupts are not being used
sta IER4
lda #%10010000 ;Enable CB1 (USB mouse), disable others. Set/Clear Timer1 Timer2 CB1 CB2 ShiftRegister CA1 CA2
sta IER5
;set VIA ports input/output
lda #%11111111 ; Set all pins on port B to output
sta DDR1B
lda #%00000000 ; Set all pins on port A to input
sta DDR1A
lda #$00 ; Set all pins to input
;lda #$ff ;set as output
sta DDR2B
sta DDR2A
sta DDR3B
sta DDR3A
sta DDR4B
sta DDR4A
sta DDR5B
sta DDR5A
; ******* KEYBOARD ******* init keyboard handling memory
lda #$00
sta kb_flags
sta kb_flags2
sta kb_wptr
sta kb_rptr
; ******* VGA *******
jsr InitVideoMemory
jsr FillBlack
;*** Display string to VGA ***
;where to place chars and char color - change these locations before calling PrintChar/PrintString
;lda #$28
;sta char_vp_p1
;lda #$80
;sta char_vp
;lda #$3F ;white
;sta char_color
;lda #$5
;sta char_y_offset
;Display pre-defined message #1
;lda #$01
;sta message_to_process
;jsr PrintString
;Set message_to_process to 0 when transitioning to dynamic strings/chars (vs. pre-defined, stored messages)
lda #$00 ;done processing pre-defined strings
sta message_to_process
;jsr LoadScreen ;Windows logo screen
jsr InitVideoMemory
jsr FillBlack
jsr StartScreen
CantGetEnough:
;jsr PlayWindowsStartSound
;jmp CantGetEnough
lda #$00
sta audio_data_to_write
jsr LoadDynamicSound
;starting center pixel for drawing
lda #50
sta fill_region_start_x
lda #31
sta fill_region_start_y
lda #%00111100 ;blue green
sta fill_region_color
lda #$00
sta pixel_prev_color
lda #$00
sta currently_drawing
jsr DrawPixel
;jsr SetupTemperatureTimer ;Call to start a timer interrupt -- Not used, but leaving here as a reminder for future use
;jsr spi_led_init ;Initializes SPI 7-segment display
;jsr StartSerial ;Initializes serial on ACIA
;lda #$3E ;>
;jsr print_char_lcd
;jsr SPI_Ard_GetStatus
;jsr SPI_Ard_PrintScreen ;this will take some time...
;lda #$3C ;<
;jsr print_char_lcd
;lda #%10101000 ; put cursor at position 40 (next line)
;jsr lcd_instruction
;lda #$3E ;>
;jsr print_char_lcd
;jsr SPI_Ard_GetTwoBytes
;lda #$3C ;<
;jsr print_char_lcd
lda #%00000001 ; Clear display
jsr lcd_instruction
lda #$A0 ;start counting up at this value; higher # = shorter delay
sta delayDurationHighByte
cli ;enable interrupts
lda #%00000001 ; Clear display
jsr lcd_instruction
jsr PrintStringLCD ;Finished message
jmp loop
;timer interrupt vars
ticks: .byte 0
max_ticks: .byte 0
Sound:
PlayWindowsStartSound:
lda #$60
sta delayDurationHighByte
;init VIA
lda #$FF
sta DDR4A
sta DDR4B
;init AY38910 #1
lda #(AY2_A9_B) ;AY1_A9_B not set, therefore AY active. AY2_A9_B set, therefore AY2 disabled
sta PORT4B
;*************** sound to AY1_2 (SND_RESET) ***************
lda #<SND_RESET
sta TUNE_PTR_LO
lda #>SND_RESET
sta TUNE_PTR_HI
jsr AY1_PlayTune
jsr AY2_PlayTune
;*************** sound to AY1_2 (SND_TONE_E6_FLAT_A) ***************
lda #<SND_TONE_E6_FLAT_A
sta TUNE_PTR_LO
lda #>SND_TONE_E6_FLAT_A
sta TUNE_PTR_HI
jsr AY1_PlayTune
jsr AY2_PlayTune
;*************** sound to AY1_2 (SND_TONE_F1_C) ***************
lda #<SND_TONE_F1_C
sta TUNE_PTR_LO
lda #>SND_TONE_F1_C
sta TUNE_PTR_HI
jsr AY1_PlayTune
jsr AY2_PlayTune
;*************** delay 3 ticks ***************
jsr Delay
jsr Delay
jsr Delay
;*************** sound to AY1_2 (SND_OFF_A) ***************
lda #<SND_OFF_A
sta TUNE_PTR_LO
lda #>SND_OFF_A
sta TUNE_PTR_HI
jsr AY1_PlayTune
jsr AY2_PlayTune
;*************** sound to AY1_2 (SND_TONE_E5_FLAT_A) ***************
lda #<SND_TONE_E5_FLAT_A
sta TUNE_PTR_LO
lda #>SND_TONE_E5_FLAT_A
sta TUNE_PTR_HI
jsr AY1_PlayTune
jsr AY2_PlayTune
;*************** delay 2 ticks ***************
jsr Delay
jsr Delay
;*************** sound to AY1_2 (SND_TONE_B6_FLAT_A) ***************
lda #<SND_TONE_B6_FLAT_A
sta TUNE_PTR_LO
lda #>SND_TONE_B6_FLAT_A
sta TUNE_PTR_HI
jsr AY1_PlayTune
jsr AY2_PlayTune
;*************** delay 3 ticks ***************
jsr Delay
jsr Delay
jsr Delay
;*************** sound to AY1_2 (SND_OFF_ALL) ***************
lda #<SND_OFF_ALL
sta TUNE_PTR_LO
lda #>SND_OFF_ALL
sta TUNE_PTR_HI
jsr AY1_PlayTune
jsr AY2_PlayTune
;*************** sound to AY1_2 (SND_TONE_A6_FLAT_A) ***************
lda #<SND_TONE_A6_FLAT_A
sta TUNE_PTR_LO
lda #>SND_TONE_A6_FLAT_A
sta TUNE_PTR_HI
jsr AY1_PlayTune
jsr AY2_PlayTune
;*************** sound to AY1_2 (SND_OFF_C) ***************
lda #<SND_OFF_C
sta TUNE_PTR_LO
lda #>SND_OFF_C
sta TUNE_PTR_HI
jsr AY1_PlayTune
jsr AY2_PlayTune
;*************** sound to AY1_2 (SND_TONE_A2_FLAT_C) ***************
lda #<SND_TONE_A2_FLAT_C
sta TUNE_PTR_LO
lda #>SND_TONE_A2_FLAT_C
sta TUNE_PTR_HI
jsr AY1_PlayTune
jsr AY2_PlayTune
;*************** delay 5 ticks ***************
jsr Delay
jsr Delay
jsr Delay
jsr Delay
jsr Delay
;*************** sound to AY1_2 (SND_OFF_A) ***************
lda #<SND_OFF_A
sta TUNE_PTR_LO
lda #>SND_OFF_A
sta TUNE_PTR_HI
jsr AY1_PlayTune
jsr AY2_PlayTune
;*************** sound to AY1_2 (SND_TONE_E6_FLAT_A) ***************
lda #<SND_TONE_E6_FLAT_A
sta TUNE_PTR_LO
lda #>SND_TONE_E6_FLAT_A
sta TUNE_PTR_HI
jsr AY1_PlayTune
jsr AY2_PlayTune
;*************** delay 3 ticks ***************
jsr Delay
jsr Delay
jsr Delay
;*************** sound to AY1_2 (SND_OFF_ALL) ***************
lda #<SND_OFF_ALL
sta TUNE_PTR_LO
lda #>SND_OFF_ALL
sta TUNE_PTR_HI
jsr AY1_PlayTune
jsr AY2_PlayTune
;*************** sound to AY1_2 (SND_TONE_B6_FLAT_A) ***************
lda #<SND_TONE_B6_FLAT_A
sta TUNE_PTR_LO
lda #>SND_TONE_B6_FLAT_A
sta TUNE_PTR_HI
jsr AY1_PlayTune
jsr AY2_PlayTune
;*************** sound to AY1_2 (SND_TONE_E3_FLAT_B) ***************
lda #<SND_TONE_E3_FLAT_B
sta TUNE_PTR_LO
lda #>SND_TONE_E3_FLAT_B
sta TUNE_PTR_HI
jsr AY2_PlayTune
jsr AY1_PlayTune
;*************** sound to AY1_2 (SND_TONE_B3_FLAT_C) ***************
lda #<SND_TONE_B3_FLAT_C
sta TUNE_PTR_LO
lda #>SND_TONE_B3_FLAT_C
sta TUNE_PTR_HI
jsr AY1_PlayTune
jsr AY2_PlayTune
;*************** delay 8 ticks ***************
jsr Delay
jsr Delay
jsr Delay
jsr Delay
jsr Delay
jsr Delay
jsr Delay
jsr Delay
;*************** sound to AY1_2 (off) ***************
lda #<SND_OFF_ALL
sta TUNE_PTR_LO
lda #>SND_OFF_ALL
sta TUNE_PTR_HI
jsr AY1_PlayTune
jsr AY2_PlayTune
rts
;temporary testing ****************************************
;*************** delay 8 ticks ***************
jsr Delay
jsr Delay
jsr Delay
jsr Delay
jsr Delay
jsr Delay
jsr Delay
jsr Delay
PlayWindowsStartSound_LeftOnly:
lda #$60
sta delayDurationHighByte
;init VIA
lda #$FF
sta DDR4A
sta DDR4B
;init AY38910 #1
lda #(AY2_A9_B) ;AY1_A9_B not set, therefore AY active. AY2_A9_B set, therefore AY2 disabled
sta PORT4B
;*************** sound to AY1_2 (SND_RESET) ***************
lda #<SND_RESET
sta TUNE_PTR_LO
lda #>SND_RESET
sta TUNE_PTR_HI
jsr AY1_PlayTune
;jsr AY2_PlayTune
;*************** sound to AY1_2 (SND_TONE_E6_FLAT_A) ***************
lda #<SND_TONE_E6_FLAT_A
sta TUNE_PTR_LO
lda #>SND_TONE_E6_FLAT_A
sta TUNE_PTR_HI
jsr AY1_PlayTune
;jsr AY2_PlayTune
;*************** sound to AY1_2 (SND_TONE_F1_C) ***************
lda #<SND_TONE_F1_C
sta TUNE_PTR_LO
lda #>SND_TONE_F1_C
sta TUNE_PTR_HI
jsr AY1_PlayTune
;jsr AY2_PlayTune
;*************** delay 3 ticks ***************
jsr Delay
jsr Delay
jsr Delay
;*************** sound to AY1_2 (SND_OFF_A) ***************
lda #<SND_OFF_A
sta TUNE_PTR_LO
lda #>SND_OFF_A
sta TUNE_PTR_HI
jsr AY1_PlayTune
;jsr AY2_PlayTune
;*************** sound to AY1_2 (SND_TONE_E5_FLAT_A) ***************
lda #<SND_TONE_E5_FLAT_A
sta TUNE_PTR_LO
lda #>SND_TONE_E5_FLAT_A
sta TUNE_PTR_HI
jsr AY1_PlayTune
;jsr AY2_PlayTune
;*************** delay 2 ticks ***************
jsr Delay
jsr Delay
;*************** sound to AY1_2 (SND_TONE_B6_FLAT_A) ***************
lda #<SND_TONE_B6_FLAT_A
sta TUNE_PTR_LO
lda #>SND_TONE_B6_FLAT_A
sta TUNE_PTR_HI
jsr AY1_PlayTune
;jsr AY2_PlayTune
;*************** delay 3 ticks ***************
jsr Delay
jsr Delay
jsr Delay
;*************** sound to AY1_2 (SND_OFF_ALL) ***************
lda #<SND_OFF_ALL
sta TUNE_PTR_LO
lda #>SND_OFF_ALL
sta TUNE_PTR_HI
jsr AY1_PlayTune
;jsr AY2_PlayTune
;*************** sound to AY1_2 (SND_TONE_A6_FLAT_A) ***************
lda #<SND_TONE_A6_FLAT_A
sta TUNE_PTR_LO
lda #>SND_TONE_A6_FLAT_A
sta TUNE_PTR_HI
jsr AY1_PlayTune
;jsr AY2_PlayTune
;*************** sound to AY1_2 (SND_OFF_C) ***************
lda #<SND_OFF_C
sta TUNE_PTR_LO
lda #>SND_OFF_C
sta TUNE_PTR_HI
jsr AY1_PlayTune
;jsr AY2_PlayTune
;*************** sound to AY1_2 (SND_TONE_A2_FLAT_C) ***************
lda #<SND_TONE_A2_FLAT_C
sta TUNE_PTR_LO
lda #>SND_TONE_A2_FLAT_C
sta TUNE_PTR_HI
jsr AY1_PlayTune
;jsr AY2_PlayTune
;*************** delay 5 ticks ***************
jsr Delay
jsr Delay
jsr Delay
jsr Delay
jsr Delay
;*************** sound to AY1_2 (SND_OFF_A) ***************
lda #<SND_OFF_A
sta TUNE_PTR_LO
lda #>SND_OFF_A
sta TUNE_PTR_HI
jsr AY1_PlayTune
;jsr AY2_PlayTune
;*************** sound to AY1_2 (SND_TONE_E6_FLAT_A) ***************
lda #<SND_TONE_E6_FLAT_A
sta TUNE_PTR_LO
lda #>SND_TONE_E6_FLAT_A
sta TUNE_PTR_HI
jsr AY1_PlayTune
;jsr AY2_PlayTune
;*************** delay 3 ticks ***************
jsr Delay
jsr Delay
jsr Delay
;*************** sound to AY1_2 (SND_OFF_ALL) ***************
lda #<SND_OFF_ALL
sta TUNE_PTR_LO
lda #>SND_OFF_ALL
sta TUNE_PTR_HI
jsr AY1_PlayTune
;jsr AY2_PlayTune
;*************** sound to AY1_2 (SND_TONE_B6_FLAT_A) ***************
lda #<SND_TONE_B6_FLAT_A
sta TUNE_PTR_LO
lda #>SND_TONE_B6_FLAT_A
sta TUNE_PTR_HI
jsr AY1_PlayTune
;jsr AY2_PlayTune
;*************** sound to AY1_2 (SND_TONE_E3_FLAT_B) ***************
lda #<SND_TONE_E3_FLAT_B
sta TUNE_PTR_LO
lda #>SND_TONE_E3_FLAT_B
sta TUNE_PTR_HI
jsr AY2_PlayTune
;jsr AY1_PlayTune
;*************** sound to AY1_2 (SND_TONE_B3_FLAT_C) ***************
lda #<SND_TONE_B3_FLAT_C
sta TUNE_PTR_LO
lda #>SND_TONE_B3_FLAT_C
sta TUNE_PTR_HI
jsr AY1_PlayTune
;jsr AY2_PlayTune
;*************** delay 8 ticks ***************
jsr Delay
jsr Delay
jsr Delay
jsr Delay
jsr Delay
jsr Delay
jsr Delay
jsr Delay
;*************** sound to AY1 (off) ***************
lda #<SND_OFF_ALL
sta TUNE_PTR_LO
lda #>SND_OFF_ALL
sta TUNE_PTR_HI
jsr AY1_PlayTune
jsr AY2_PlayTune
;*************** delay 8 ticks ***************
jsr Delay
jsr Delay
jsr Delay
jsr Delay
jsr Delay
jsr Delay
jsr Delay
jsr Delay
PlayWindowsStartSound_RighttOnly:
lda #$60
sta delayDurationHighByte
;init VIA
lda #$FF
sta DDR4A
sta DDR4B
;init AY38910 #1
lda #(AY2_A9_B) ;AY1_A9_B not set, therefore AY active. AY2_A9_B set, therefore AY2 disabled
sta PORT4B
;*************** sound to AY1_2 (SND_RESET) ***************
lda #<SND_RESET
sta TUNE_PTR_LO
lda #>SND_RESET
sta TUNE_PTR_HI
;jsr AY1_PlayTune
jsr AY2_PlayTune
;*************** sound to AY1_2 (SND_TONE_E6_FLAT_A) ***************
lda #<SND_TONE_E6_FLAT_A
sta TUNE_PTR_LO
lda #>SND_TONE_E6_FLAT_A
sta TUNE_PTR_HI
;jsr AY1_PlayTune
jsr AY2_PlayTune
;*************** sound to AY1_2 (SND_TONE_F1_C) ***************
lda #<SND_TONE_F1_C
sta TUNE_PTR_LO
lda #>SND_TONE_F1_C
sta TUNE_PTR_HI
;jsr AY1_PlayTune
jsr AY2_PlayTune
;*************** delay 3 ticks ***************
jsr Delay
jsr Delay
jsr Delay
;*************** sound to AY1_2 (SND_OFF_A) ***************
lda #<SND_OFF_A
sta TUNE_PTR_LO
lda #>SND_OFF_A
sta TUNE_PTR_HI
;jsr AY1_PlayTune
jsr AY2_PlayTune
;*************** sound to AY1_2 (SND_TONE_E5_FLAT_A) ***************
lda #<SND_TONE_E5_FLAT_A
sta TUNE_PTR_LO
lda #>SND_TONE_E5_FLAT_A
sta TUNE_PTR_HI
;jsr AY1_PlayTune
jsr AY2_PlayTune
;*************** delay 2 ticks ***************
jsr Delay
jsr Delay
;*************** sound to AY1_2 (SND_TONE_B6_FLAT_A) ***************
lda #<SND_TONE_B6_FLAT_A
sta TUNE_PTR_LO
lda #>SND_TONE_B6_FLAT_A
sta TUNE_PTR_HI
;jsr AY1_PlayTune
jsr AY2_PlayTune
;*************** delay 3 ticks ***************
jsr Delay
jsr Delay
jsr Delay
;*************** sound to AY1_2 (SND_OFF_ALL) ***************
lda #<SND_OFF_ALL
sta TUNE_PTR_LO
lda #>SND_OFF_ALL
sta TUNE_PTR_HI
;jsr AY1_PlayTune
jsr AY2_PlayTune
;*************** sound to AY1_2 (SND_TONE_A6_FLAT_A) ***************
lda #<SND_TONE_A6_FLAT_A
sta TUNE_PTR_LO
lda #>SND_TONE_A6_FLAT_A
sta TUNE_PTR_HI
;jsr AY1_PlayTune
jsr AY2_PlayTune
;*************** sound to AY1_2 (SND_OFF_C) ***************
lda #<SND_OFF_C
sta TUNE_PTR_LO
lda #>SND_OFF_C
sta TUNE_PTR_HI
;jsr AY1_PlayTune
jsr AY2_PlayTune
;*************** sound to AY1_2 (SND_TONE_A2_FLAT_C) ***************
lda #<SND_TONE_A2_FLAT_C
sta TUNE_PTR_LO
lda #>SND_TONE_A2_FLAT_C
sta TUNE_PTR_HI
;jsr AY1_PlayTune
jsr AY2_PlayTune
;*************** delay 5 ticks ***************
jsr Delay
jsr Delay
jsr Delay
jsr Delay
jsr Delay
;*************** sound to AY1_2 (SND_OFF_A) ***************
lda #<SND_OFF_A
sta TUNE_PTR_LO
lda #>SND_OFF_A
sta TUNE_PTR_HI
;jsr AY1_PlayTune
jsr AY2_PlayTune