-
Notifications
You must be signed in to change notification settings - Fork 0
/
my_sound_01.bas.asm
1962 lines (1750 loc) · 35.6 KB
/
my_sound_01.bas.asm
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
; Provided under the CC0 license. See the included LICENSE.txt for details.
processor 6502
include "vcs.h"
include "macro.h"
include "2600basic.h"
include "2600basic_variable_redefs.h"
ifconst bankswitch
if bankswitch == 8
ORG $1000
RORG $D000
endif
if bankswitch == 16
ORG $1000
RORG $9000
endif
if bankswitch == 32
ORG $1000
RORG $1000
endif
if bankswitch == 64
ORG $1000
RORG $1000
endif
else
ORG $F000
endif
ifconst bankswitch_hotspot
if bankswitch_hotspot = $083F ; 0840 bankswitching hotspot
.byte 0 ; stop unexpected bankswitches
endif
endif
; Provided under the CC0 license. See the included LICENSE.txt for details.
start
sei
cld
ldy #0
lda $D0
cmp #$2C ;check RAM location #1
bne MachineIs2600
lda $D1
cmp #$A9 ;check RAM location #2
bne MachineIs2600
dey
MachineIs2600
ldx #0
txa
clearmem
inx
txs
pha
bne clearmem
sty temp1
ifnconst multisprite
ifconst pfrowheight
lda #pfrowheight
else
ifconst pfres
lda #(96/pfres)
else
lda #8
endif
endif
sta playfieldpos
endif
ldx #5
initscore
lda #<scoretable
sta scorepointers,x
dex
bpl initscore
lda #1
sta CTRLPF
ora INTIM
sta rand
ifconst multisprite
jsr multisprite_setup
endif
ifnconst bankswitch
jmp game
else
lda #>(game-1)
pha
lda #<(game-1)
pha
pha
pha
ldx #1
jmp BS_jsr
endif
; Provided under the CC0 license. See the included LICENSE.txt for details.
; This is a 2-line kernel!
ifnconst vertical_reflect
kernel
endif
sta WSYNC
lda #255
sta TIM64T
lda #1
sta VDELBL
sta VDELP0
ldx ballheight
inx
inx
stx temp4
lda player1y
sta temp3
ifconst shakescreen
jsr doshakescreen
else
ldx missile0height
inx
endif
inx
stx stack1
lda bally
sta stack2
lda player0y
ldx #0
sta WSYNC
stx GRP0
stx GRP1
stx PF1L
stx PF2
stx CXCLR
ifconst readpaddle
stx paddle
else
sleep 3
endif
sta temp2,x
;store these so they can be retrieved later
ifnconst pfres
ldx #128-44+(4-pfwidth)*12
else
ldx #132-pfres*pfwidth
endif
dec player0y
lda missile0y
sta temp5
lda missile1y
sta temp6
lda playfieldpos
sta temp1
ifconst pfrowheight
lda #pfrowheight+2
else
ifnconst pfres
lda #10
else
lda #(96/pfres)+2 ; try to come close to the real size
endif
endif
clc
sbc playfieldpos
sta playfieldpos
jmp .startkernel
.skipDrawP0
lda #0
tay
jmp .continueP0
.skipDrawP1
lda #0
tay
jmp .continueP1
.kerloop ; enter at cycle 59??
continuekernel
sleep 2
continuekernel2
lda ballheight
ifconst pfres
ldy playfield+pfres*pfwidth-132,x
sty PF1L ;3
ldy playfield+pfres*pfwidth-131-pfadjust,x
sty PF2L ;3
ldy playfield+pfres*pfwidth-129,x
sty PF1R ; 3 too early?
ldy playfield+pfres*pfwidth-130-pfadjust,x
sty PF2R ;3
else
ldy playfield-48+pfwidth*12+44-128,x
sty PF1L ;3
ldy playfield-48+pfwidth*12+45-128-pfadjust,x ;4
sty PF2L ;3
ldy playfield-48+pfwidth*12+47-128,x ;4
sty PF1R ; 3 too early?
ldy playfield-48+pfwidth*12+46-128-pfadjust,x;4
sty PF2R ;3
endif
; should be playfield+$38 for width=2
dcp bally
rol
rol
; rol
; rol
goback
sta ENABL
.startkernel
lda player1height ;3
dcp player1y ;5
bcc .skipDrawP1 ;2
ldy player1y ;3
lda (player1pointer),y ;5; player0pointer must be selected carefully by the compiler
; so it doesn't cross a page boundary!
.continueP1
sta GRP1 ;3
ifnconst player1colors
lda missile1height ;3
dcp missile1y ;5
rol;2
rol;2
sta ENAM1 ;3
else
lda (player1color),y
sta COLUP1
ifnconst playercolors
sleep 7
else
lda.w player0colorstore
sta COLUP0
endif
endif
ifconst pfres
lda playfield+pfres*pfwidth-132,x
sta PF1L ;3
lda playfield+pfres*pfwidth-131-pfadjust,x
sta PF2L ;3
lda playfield+pfres*pfwidth-129,x
sta PF1R ; 3 too early?
lda playfield+pfres*pfwidth-130-pfadjust,x
sta PF2R ;3
else
lda playfield-48+pfwidth*12+44-128,x ;4
sta PF1L ;3
lda playfield-48+pfwidth*12+45-128-pfadjust,x ;4
sta PF2L ;3
lda playfield-48+pfwidth*12+47-128,x ;4
sta PF1R ; 3 too early?
lda playfield-48+pfwidth*12+46-128-pfadjust,x;4
sta PF2R ;3
endif
; sleep 3
lda player0height
dcp player0y
bcc .skipDrawP0
ldy player0y
lda (player0pointer),y
.continueP0
sta GRP0
ifnconst no_blank_lines
ifnconst playercolors
lda missile0height ;3
dcp missile0y ;5
sbc stack1
sta ENAM0 ;3
else
lda (player0color),y
sta player0colorstore
sleep 6
endif
dec temp1
bne continuekernel
else
dec temp1
beq altkernel2
ifconst readpaddle
ldy currentpaddle
lda INPT0,y
bpl noreadpaddle
inc paddle
jmp continuekernel2
noreadpaddle
sleep 2
jmp continuekernel
else
ifnconst playercolors
ifconst PFcolors
txa
tay
lda (pfcolortable),y
ifnconst backgroundchange
sta COLUPF
else
sta COLUBK
endif
jmp continuekernel
else
ifconst kernelmacrodef
kernelmacro
else
sleep 12
endif
endif
else
lda (player0color),y
sta player0colorstore
sleep 4
endif
jmp continuekernel
endif
altkernel2
txa
ifnconst vertical_reflect
sbx #256-pfwidth
else
sbx #256-pfwidth/2
endif
bmi lastkernelline
ifconst pfrowheight
lda #pfrowheight
else
ifnconst pfres
lda #8
else
lda #(96/pfres) ; try to come close to the real size
endif
endif
sta temp1
jmp continuekernel
endif
altkernel
ifconst PFmaskvalue
lda #PFmaskvalue
else
lda #0
endif
sta PF1L
sta PF2
;sleep 3
;28 cycles to fix things
;minus 11=17
; lax temp4
; clc
txa
ifnconst vertical_reflect
sbx #256-pfwidth
else
sbx #256-pfwidth/2
endif
bmi lastkernelline
ifconst PFcolorandheight
ifconst pfres
ldy playfieldcolorandheight-131+pfres*pfwidth,x
else
ldy playfieldcolorandheight-87,x
endif
ifnconst backgroundchange
sty COLUPF
else
sty COLUBK
endif
ifconst pfres
lda playfieldcolorandheight-132+pfres*pfwidth,x
else
lda playfieldcolorandheight-88,x
endif
sta.w temp1
endif
ifconst PFheights
lsr
lsr
tay
lda (pfheighttable),y
sta.w temp1
endif
ifconst PFcolors
tay
lda (pfcolortable),y
ifnconst backgroundchange
sta COLUPF
else
sta COLUBK
endif
ifconst pfrowheight
lda #pfrowheight
else
ifnconst pfres
lda #8
else
lda #(96/pfres) ; try to come close to the real size
endif
endif
sta temp1
endif
ifnconst PFcolorandheight
ifnconst PFcolors
ifnconst PFheights
ifnconst no_blank_lines
; read paddle 0
; lo-res paddle read
; bit INPT0
; bmi paddleskipread
; inc paddle0
;donepaddleskip
sleep 10
ifconst pfrowheight
lda #pfrowheight
else
ifnconst pfres
lda #8
else
lda #(96/pfres) ; try to come close to the real size
endif
endif
sta temp1
endif
endif
endif
endif
lda ballheight
dcp bally
sbc temp4
jmp goback
ifnconst no_blank_lines
lastkernelline
ifnconst PFcolors
sleep 10
else
ldy #124
lda (pfcolortable),y
sta COLUPF
endif
ifconst PFheights
ldx #1
;sleep 4
sleep 3 ; this was over 1 cycle
else
ldx playfieldpos
;sleep 3
sleep 2 ; this was over 1 cycle
endif
jmp enterlastkernel
else
lastkernelline
ifconst PFheights
ldx #1
;sleep 5
sleep 4 ; this was over 1 cycle
else
ldx playfieldpos
;sleep 4
sleep 3 ; this was over 1 cycle
endif
cpx #0
bne .enterfromNBL
jmp no_blank_lines_bailout
endif
if ((<*)>$d5)
align 256
endif
; this is a kludge to prevent page wrapping - fix!!!
.skipDrawlastP1
lda #0
tay ; added so we don't cross a page
jmp .continuelastP1
.endkerloop ; enter at cycle 59??
nop
.enterfromNBL
ifconst pfres
ldy.w playfield+pfres*pfwidth-4
sty PF1L ;3
ldy.w playfield+pfres*pfwidth-3-pfadjust
sty PF2L ;3
ldy.w playfield+pfres*pfwidth-1
sty PF1R ; possibly too early?
ldy.w playfield+pfres*pfwidth-2-pfadjust
sty PF2R ;3
else
ldy.w playfield-48+pfwidth*12+44
sty PF1L ;3
ldy.w playfield-48+pfwidth*12+45-pfadjust
sty PF2L ;3
ldy.w playfield-48+pfwidth*12+47
sty PF1R ; possibly too early?
ldy.w playfield-48+pfwidth*12+46-pfadjust
sty PF2R ;3
endif
enterlastkernel
lda ballheight
; tya
dcp bally
; sleep 4
; sbc stack3
rol
rol
sta ENABL
lda player1height ;3
dcp player1y ;5
bcc .skipDrawlastP1
ldy player1y ;3
lda (player1pointer),y ;5; player0pointer must be selected carefully by the compiler
; so it doesn't cross a page boundary!
.continuelastP1
sta GRP1 ;3
ifnconst player1colors
lda missile1height ;3
dcp missile1y ;5
else
lda (player1color),y
sta COLUP1
endif
dex
;dec temp4 ; might try putting this above PF writes
beq endkernel
ifconst pfres
ldy.w playfield+pfres*pfwidth-4
sty PF1L ;3
ldy.w playfield+pfres*pfwidth-3-pfadjust
sty PF2L ;3
ldy.w playfield+pfres*pfwidth-1
sty PF1R ; possibly too early?
ldy.w playfield+pfres*pfwidth-2-pfadjust
sty PF2R ;3
else
ldy.w playfield-48+pfwidth*12+44
sty PF1L ;3
ldy.w playfield-48+pfwidth*12+45-pfadjust
sty PF2L ;3
ldy.w playfield-48+pfwidth*12+47
sty PF1R ; possibly too early?
ldy.w playfield-48+pfwidth*12+46-pfadjust
sty PF2R ;3
endif
ifnconst player1colors
rol;2
rol;2
sta ENAM1 ;3
else
ifnconst playercolors
sleep 7
else
lda.w player0colorstore
sta COLUP0
endif
endif
lda.w player0height
dcp player0y
bcc .skipDrawlastP0
ldy player0y
lda (player0pointer),y
.continuelastP0
sta GRP0
ifnconst no_blank_lines
lda missile0height ;3
dcp missile0y ;5
sbc stack1
sta ENAM0 ;3
jmp .endkerloop
else
ifconst readpaddle
ldy currentpaddle
lda INPT0,y
bpl noreadpaddle2
inc paddle
jmp .endkerloop
noreadpaddle2
sleep 4
jmp .endkerloop
else ; no_blank_lines and no paddle reading
pla
pha ; 14 cycles in 4 bytes
pla
pha
; sleep 14
jmp .endkerloop
endif
endif
; ifconst donepaddleskip
;paddleskipread
; this is kind of lame, since it requires 4 cycles from a page boundary crossing
; plus we get a lo-res paddle read
; bmi donepaddleskip
; endif
.skipDrawlastP0
lda #0
tay
jmp .continuelastP0
ifconst no_blank_lines
no_blank_lines_bailout
ldx #0
endif
endkernel
; 6 digit score routine
stx PF1
stx PF2
stx PF0
clc
ifconst pfrowheight
lda #pfrowheight+2
else
ifnconst pfres
lda #10
else
lda #(96/pfres)+2 ; try to come close to the real size
endif
endif
sbc playfieldpos
sta playfieldpos
txa
ifconst shakescreen
bit shakescreen
bmi noshakescreen2
ldx #$3D
noshakescreen2
endif
sta WSYNC,x
; STA WSYNC ;first one, need one more
sta REFP0
sta REFP1
STA GRP0
STA GRP1
; STA PF1
; STA PF2
sta HMCLR
sta ENAM0
sta ENAM1
sta ENABL
lda temp2 ;restore variables that were obliterated by kernel
sta player0y
lda temp3
sta player1y
ifnconst player1colors
lda temp6
sta missile1y
endif
ifnconst playercolors
ifnconst readpaddle
lda temp5
sta missile0y
endif
endif
lda stack2
sta bally
; strangely, this isn't required any more. might have
; resulted from the no_blank_lines score bounce fix
;ifconst no_blank_lines
;sta WSYNC
;endif
lda INTIM
clc
ifnconst vblank_time
adc #43+12+87
else
adc #vblank_time+12+87
endif
; sta WSYNC
sta TIM64T
ifconst minikernel
jsr minikernel
endif
; now reassign temp vars for score pointers
; score pointers contain:
; score1-5: lo1,lo2,lo3,lo4,lo5,lo6
; swap lo2->temp1
; swap lo4->temp3
; swap lo6->temp5
ifnconst noscore
lda scorepointers+1
; ldy temp1
sta temp1
; sty scorepointers+1
lda scorepointers+3
; ldy temp3
sta temp3
; sty scorepointers+3
sta HMCLR
tsx
stx stack1
ldx #$E0
stx HMP0
LDA scorecolor
STA COLUP0
STA COLUP1
ifconst scorefade
STA stack2
endif
ifconst pfscore
lda pfscorecolor
sta COLUPF
endif
sta WSYNC
ldx #0
STx GRP0
STx GRP1 ; seems to be needed because of vdel
lda scorepointers+5
; ldy temp5
sta temp5,x
; sty scorepointers+5
lda #>scoretable
sta scorepointers+1
sta scorepointers+3
sta scorepointers+5
sta temp2
sta temp4
sta temp6
LDY #7
STY VDELP0
STA RESP0
STA RESP1
LDA #$03
STA NUSIZ0
STA NUSIZ1
STA VDELP1
LDA #$F0
STA HMP1
lda (scorepointers),y
sta GRP0
STA HMOVE ; cycle 73 ?
jmp beginscore
if ((<*)>$d4)
align 256 ; kludge that potentially wastes space! should be fixed!
endif
loop2
lda (scorepointers),y ;+5 68 204
sta GRP0 ;+3 71 213 D1 -- -- --
ifconst pfscore
lda.w pfscore1
sta PF1
else
ifconst scorefade
sleep 2
dec stack2 ; decrement the temporary scorecolor
else
sleep 7
endif
endif
; cycle 0
beginscore
lda (scorepointers+$8),y ;+5 5 15
sta GRP1 ;+3 8 24 D1 D1 D2 --
lda (scorepointers+$6),y ;+5 13 39
sta GRP0 ;+3 16 48 D3 D1 D2 D2
lax (scorepointers+$2),y ;+5 29 87
txs
lax (scorepointers+$4),y ;+5 36 108
ifconst scorefade
lda stack2
else
sleep 3
endif
ifconst pfscore
lda pfscore2
sta PF1
else
ifconst scorefade
sta COLUP0
sta COLUP1
else
sleep 6
endif
endif
lda (scorepointers+$A),y ;+5 21 63
stx GRP1 ;+3 44 132 D3 D3 D4 D2!
tsx
stx GRP0 ;+3 47 141 D5 D3! D4 D4
sta GRP1 ;+3 50 150 D5 D5 D6 D4!
sty GRP0 ;+3 53 159 D4* D5! D6 D6
dey
bpl loop2 ;+2 60 180
ldx stack1
txs
; lda scorepointers+1
ldy temp1
; sta temp1
sty scorepointers+1
LDA #0
sta PF1
STA GRP0
STA GRP1
STA VDELP0
STA VDELP1;do we need these
STA NUSIZ0
STA NUSIZ1
; lda scorepointers+3
ldy temp3
; sta temp3
sty scorepointers+3
; lda scorepointers+5
ldy temp5
; sta temp5
sty scorepointers+5
endif ;noscore
LDA #%11000010
sta WSYNC
STA VBLANK
RETURN
ifconst shakescreen
doshakescreen
bit shakescreen
bmi noshakescreen
sta WSYNC
noshakescreen
ldx missile0height
inx
rts
endif
; Provided under the CC0 license. See the included LICENSE.txt for details.
; playfield drawing routines
; you get a 32x12 bitmapped display in a single color :)
; 0-31 and 0-11
pfclear ; clears playfield - or fill with pattern
ifconst pfres
ldx #pfres*pfwidth-1
else
ldx #47-(4-pfwidth)*12 ; will this work?
endif
pfclear_loop
ifnconst superchip
sta playfield,x
else
sta playfield-128,x
endif
dex
bpl pfclear_loop
RETURN
setuppointers
stx temp2 ; store on.off.flip value
tax ; put x-value in x
lsr
lsr
lsr ; divide x pos by 8
sta temp1
tya
asl
if pfwidth=4
asl ; multiply y pos by 4
endif ; else multiply by 2
clc
adc temp1 ; add them together to get actual memory location offset
tay ; put the value in y
lda temp2 ; restore on.off.flip value
rts
pfread
;x=xvalue, y=yvalue
jsr setuppointers
lda setbyte,x
and playfield,y
eor setbyte,x
; beq readzero
; lda #1
; readzero
RETURN
pfpixel
;x=xvalue, y=yvalue, a=0,1,2
jsr setuppointers
ifconst bankswitch
lda temp2 ; load on.off.flip value (0,1, or 2)
beq pixelon_r ; if "on" go to on
lsr
bcs pixeloff_r ; value is 1 if true
lda playfield,y ; if here, it's "flip"
eor setbyte,x
ifconst superchip
sta playfield-128,y
else
sta playfield,y
endif
RETURN
pixelon_r
lda playfield,y
ora setbyte,x
ifconst superchip
sta playfield-128,y
else
sta playfield,y
endif
RETURN
pixeloff_r
lda setbyte,x
eor #$ff
and playfield,y
ifconst superchip
sta playfield-128,y
else
sta playfield,y
endif
RETURN
else
jmp plotpoint
endif
pfhline
;x=xvalue, y=yvalue, a=0,1,2, temp3=endx
jsr setuppointers
jmp noinc
keepgoing
inx
txa
and #7
bne noinc
iny
noinc