-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchess.lst
16757 lines (16757 loc) · 841 KB
/
chess.lst
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
------- FILE ./chess.asm LEVEL 1 PASS 4
1 7c00 ???? ; Chess
2 7c00 ???? ; Atari 2600 Chess display system
3 7c00 ???? ; Copyright (c) 2019-2020 Andrew Davie
4 7c00 ???? ; [email protected]
5 7c00 ????
6 7c00 ????
7 7c00 ???? 00 40 TIA_BASE_ADDRESS = $40
8 7c00 ????
9 7c00 ???? processor 6502
------- FILE vcs.h LEVEL 2 PASS 4
0 7c00 ???? include "vcs.h"
1 7c00 ???? ; VCS.H
2 7c00 ???? ; Version 1.05, 13/November/2003
3 7c00 ????
4 7c00 ???? 00 69 VERSION_VCS = 105
5 7c00 ????
6 7c00 ???? ; This file defines hardware registers and memory mapping for the
7 7c00 ???? ; Atari 2600. It is distributed as a companion machine-specific support package
8 7c00 ???? ; for the DASM compiler. Updates to this file, DASM, and associated tools are
9 7c00 ???? ; available at at http://www.atari2600.org/dasm
10 7c00 ???? ;
11 7c00 ???? ; Many thanks to the original author(s) of this file, and to everyone who has
12 7c00 ???? ; contributed to understanding the Atari 2600. If you take issue with the
13 7c00 ???? ; contents, or naming of registers, please write to me ([email protected])
14 7c00 ???? ; with your views. Please contribute, if you think you can improve this
15 7c00 ???? ; file!
16 7c00 ???? ;
17 7c00 ???? ; Latest Revisions...
18 7c00 ???? ; 1.05 13/NOV/2003 - Correction to 1.04 - now functions as requested by MR.
19 7c00 ???? ; - Added VERSION_VCS equate (which will reflect 100x version #)
20 7c00 ???? ; This will allow conditional code to verify VCS.H being
21 7c00 ???? ; used for code assembly.
22 7c00 ???? ; 1.04 12/NOV/2003 Added TIA_BASE_WRITE_ADDRESS and TIA_BASE_READ_ADDRESS for
23 7c00 ???? ; convenient disassembly/reassembly compatibility for hardware
24 7c00 ???? ; mirrored reading/writing differences. This is more a
25 7c00 ???? ; readability issue, and binary compatibility with disassembled
26 7c00 ???? ; and reassembled sources. Per Manuel Rotschkar's suggestion.
27 7c00 ???? ; 1.03 12/MAY/2003 Added SEG segment at end of file to fix old-code compatibility
28 7c00 ???? ; which was broken by the use of segments in this file, as
29 7c00 ???? ; reported by Manuel Polik on [stella] 11/MAY/2003
30 7c00 ???? ; 1.02 22/MAR/2003 Added TIMINT($285)
31 7c00 ???? ; 1.01 Constant offset added to allow use for 3F-style bankswitching
32 7c00 ???? ; - define TIA_BASE_ADDRESS as $40 for Tigervision carts, otherwise
33 7c00 ???? ; it is safe to leave it undefined, and the base address will
34 7c00 ???? ; be set to 0. Thanks to Eckhard Stolberg for the suggestion.
35 7c00 ???? ; Note, may use -DLABEL=EXPRESSION to define TIA_BASE_ADDRESS
36 7c00 ???? ; - register definitions are now generated through assignment
37 7c00 ???? ; in uninitialised segments. This allows a changeable base
38 7c00 ???? ; address architecture.
39 7c00 ???? ; 1.0 22/MAR/2003 Initial release
40 7c00 ????
41 7c00 ????
42 7c00 ???? ;-------------------------------------------------------------------------------
43 7c00 ????
44 7c00 ???? ; TIA_BASE_ADDRESS
45 7c00 ???? ; The TIA_BASE_ADDRESS defines the base address of access to TIA registers.
46 7c00 ???? ; Normally 0, the base address should (externally, before including this file)
47 7c00 ???? ; be set to $40 when creating 3F-bankswitched (and other?) cartridges.
48 7c00 ???? ; The reason is that this bankswitching scheme treats any access to locations
49 7c00 ???? ; < $40 as a bankswitch.
50 7c00 ????
51 7c00 ???? - IFNCONST TIA_BASE_ADDRESS
52 7c00 ???? -TIA_BASE_ADDRESS = 0
53 7c00 ???? ENDIF
54 7c00 ????
55 7c00 ???? ; Note: The address may be defined on the command-line using the -D switch, eg:
56 7c00 ???? ; dasm.exe code.asm -DTIA_BASE_ADDRESS=$40 -f3 -v5 -ocode.bin
57 7c00 ???? ; *OR* by declaring the label before including this file, eg:
58 7c00 ???? ; TIA_BASE_ADDRESS = $40
59 7c00 ???? ; include "vcs.h"
60 7c00 ????
61 7c00 ???? ; Alternate read/write address capability - allows for some disassembly compatibility
62 7c00 ???? ; usage ; to allow reassembly to binary perfect copies). This is essentially catering
63 7c00 ???? ; for the mirrored ROM hardware registers.
64 7c00 ????
65 7c00 ???? ; Usage: As per above, define the TIA_BASE_READ_ADDRESS and/or TIA_BASE_WRITE_ADDRESS
66 7c00 ???? ; using the -D command-line switch, as required. If the addresses are not defined,
67 7c00 ???? ; they defaut to the TIA_BASE_ADDRESS.
68 7c00 ????
69 7c00 ???? - IFNCONST TIA_BASE_READ_ADDRESS
70 7c00 ???? -TIA_BASE_READ_ADDRESS = TIA_BASE_ADDRESS
71 7c00 ???? ENDIF
72 7c00 ????
73 7c00 ???? - IFNCONST TIA_BASE_WRITE_ADDRESS
74 7c00 ???? -TIA_BASE_WRITE_ADDRESS = TIA_BASE_ADDRESS
75 7c00 ???? ENDIF
76 7c00 ????
77 7c00 ???? ;-------------------------------------------------------------------------------
78 7c00 ????
79 U006d ???? SEG.U TIA_REGISTERS_WRITE
80 U0040 ORG TIA_BASE_WRITE_ADDRESS
81 U0040
82 U0040 ; DO NOT CHANGE THE RELATIVE ORDERING OF REGISTERS!
83 U0040
84 U0040 00 VSYNC ds 1 ; $00 0000 00x0 Vertical Sync Set-Clear
85 U0041 00 VBLANK ds 1 ; $01 xx00 00x0 Vertical Blank Set-Clear
86 U0042 00 WSYNC ds 1 ; $02 ---- ---- Wait for Horizontal Blank
87 U0043 00 RSYNC ds 1 ; $03 ---- ---- Reset Horizontal Sync Counter
88 U0044 00 NUSIZ0 ds 1 ; $04 00xx 0xxx Number-Size player/missle 0
89 U0045 00 NUSIZ1 ds 1 ; $05 00xx 0xxx Number-Size player/missle 1
90 U0046 00 COLUP0 ds 1 ; $06 xxxx xxx0 Color-Luminance Player 0
91 U0047 00 COLUP1 ds 1 ; $07 xxxx xxx0 Color-Luminance Player 1
92 U0048 00 COLUPF ds 1 ; $08 xxxx xxx0 Color-Luminance Playfield
93 U0049 00 COLUBK ds 1 ; $09 xxxx xxx0 Color-Luminance Background
94 U004a 00 CTRLPF ds 1 ; $0A 00xx 0xxx Control Playfield, Ball, Collisions
95 U004b 00 REFP0 ds 1 ; $0B 0000 x000 Reflection Player 0
96 U004c 00 REFP1 ds 1 ; $0C 0000 x000 Reflection Player 1
97 U004d 00 PF0 ds 1 ; $0D xxxx 0000 Playfield Register Byte 0
98 U004e 00 PF1 ds 1 ; $0E xxxx xxxx Playfield Register Byte 1
99 U004f 00 PF2 ds 1 ; $0F xxxx xxxx Playfield Register Byte 2
100 U0050 00 RESP0 ds 1 ; $10 ---- ---- Reset Player 0
101 U0051 00 RESP1 ds 1 ; $11 ---- ---- Reset Player 1
102 U0052 00 RESM0 ds 1 ; $12 ---- ---- Reset Missle 0
103 U0053 00 RESM1 ds 1 ; $13 ---- ---- Reset Missle 1
104 U0054 00 RESBL ds 1 ; $14 ---- ---- Reset Ball
105 U0055 00 AUDC0 ds 1 ; $15 0000 xxxx Audio Control 0
106 U0056 00 AUDC1 ds 1 ; $16 0000 xxxx Audio Control 1
107 U0057 00 AUDF0 ds 1 ; $17 000x xxxx Audio Frequency 0
108 U0058 00 AUDF1 ds 1 ; $18 000x xxxx Audio Frequency 1
109 U0059 00 AUDV0 ds 1 ; $19 0000 xxxx Audio Volume 0
110 U005a 00 AUDV1 ds 1 ; $1A 0000 xxxx Audio Volume 1
111 U005b 00 GRP0 ds 1 ; $1B xxxx xxxx Graphics Register Player 0
112 U005c 00 GRP1 ds 1 ; $1C xxxx xxxx Graphics Register Player 1
113 U005d 00 ENAM0 ds 1 ; $1D 0000 00x0 Graphics Enable Missle 0
114 U005e 00 ENAM1 ds 1 ; $1E 0000 00x0 Graphics Enable Missle 1
115 U005f 00 ENABL ds 1 ; $1F 0000 00x0 Graphics Enable Ball
116 U0060 00 HMP0 ds 1 ; $20 xxxx 0000 Horizontal Motion Player 0
117 U0061 00 HMP1 ds 1 ; $21 xxxx 0000 Horizontal Motion Player 1
118 U0062 00 HMM0 ds 1 ; $22 xxxx 0000 Horizontal Motion Missle 0
119 U0063 00 HMM1 ds 1 ; $23 xxxx 0000 Horizontal Motion Missle 1
120 U0064 00 HMBL ds 1 ; $24 xxxx 0000 Horizontal Motion Ball
121 U0065 00 VDELP0 ds 1 ; $25 0000 000x Vertical Delay Player 0
122 U0066 00 VDELP1 ds 1 ; $26 0000 000x Vertical Delay Player 1
123 U0067 00 VDELBL ds 1 ; $27 0000 000x Vertical Delay Ball
124 U0068 00 RESMP0 ds 1 ; $28 0000 00x0 Reset Missle 0 to Player 0
125 U0069 00 RESMP1 ds 1 ; $29 0000 00x0 Reset Missle 1 to Player 1
126 U006a 00 HMOVE ds 1 ; $2A ---- ---- Apply Horizontal Motion
127 U006b 00 HMCLR ds 1 ; $2B ---- ---- Clear Horizontal Move Registers
128 U006c 00 CXCLR ds 1 ; $2C ---- ---- Clear Collision Latches
129 U006d
130 U006d ;-------------------------------------------------------------------------------
131 U006d
132 U004e ???? SEG.U TIA_REGISTERS_READ
133 U0040 ORG TIA_BASE_READ_ADDRESS
134 U0040
135 U0040 ; bit 7 bit 6
136 U0040 00 CXM0P ds 1 ; $00 xx00 0000 Read Collision M0-P1 M0-P0
137 U0041 00 CXM1P ds 1 ; $01 xx00 0000 M1-P0 M1-P1
138 U0042 00 CXP0FB ds 1 ; $02 xx00 0000 P0-PF P0-BL
139 U0043 00 CXP1FB ds 1 ; $03 xx00 0000 P1-PF P1-BL
140 U0044 00 CXM0FB ds 1 ; $04 xx00 0000 M0-PF M0-BL
141 U0045 00 CXM1FB ds 1 ; $05 xx00 0000 M1-PF M1-BL
142 U0046 00 CXBLPF ds 1 ; $06 x000 0000 BL-PF -----
143 U0047 00 CXPPMM ds 1 ; $07 xx00 0000 P0-P1 M0-M1
144 U0048 00 INPT0 ds 1 ; $08 x000 0000 Read Pot Port 0
145 U0049 00 INPT1 ds 1 ; $09 x000 0000 Read Pot Port 1
146 U004a 00 INPT2 ds 1 ; $0A x000 0000 Read Pot Port 2
147 U004b 00 INPT3 ds 1 ; $0B x000 0000 Read Pot Port 3
148 U004c 00 INPT4 ds 1 ; $0C x000 0000 Read Input (Trigger) 0
149 U004d 00 INPT5 ds 1 ; $0D x000 0000 Read Input (Trigger) 1
150 U004e
151 U004e ;-------------------------------------------------------------------------------
152 U004e
153 U0298 ???? SEG.U RIOT
154 U0280 ORG $280
155 U0280
156 U0280 ; RIOT MEMORY MAP
157 U0280
158 U0280 00 SWCHA ds 1 ; $280 Port A data register for joysticks:
159 U0281 ; Bits 4-7 for player 1. Bits 0-3 for player 2.
160 U0281
161 U0281 00 SWACNT ds 1 ; $281 Port A data direction register (DDR)
162 U0282 00 SWCHB ds 1 ; $282 Port B data (console switches)
163 U0283 00 SWBCNT ds 1 ; $283 Port B DDR
164 U0284 00 INTIM ds 1 ; $284 Timer output
165 U0285
166 U0285 00 TIMINT ds 1 ; $285
167 U0286
168 U0286 ; Unused/undefined registers ($285-$294)
169 U0286
170 U0286 00 ds 1 ; $286
171 U0287 00 ds 1 ; $287
172 U0288 00 ds 1 ; $288
173 U0289 00 ds 1 ; $289
174 U028a 00 ds 1 ; $28A
175 U028b 00 ds 1 ; $28B
176 U028c 00 ds 1 ; $28C
177 U028d 00 ds 1 ; $28D
178 U028e 00 ds 1 ; $28E
179 U028f 00 ds 1 ; $28F
180 U0290 00 ds 1 ; $290
181 U0291 00 ds 1 ; $291
182 U0292 00 ds 1 ; $292
183 U0293 00 ds 1 ; $293
184 U0294
185 U0294 00 TIM1T ds 1 ; $294 set 1 clock interval
186 U0295 00 TIM8T ds 1 ; $295 set 8 clock interval
187 U0296 00 TIM64T ds 1 ; $296 set 64 clock interval
188 U0297 00 T1024T ds 1 ; $297 set 1024 clock interval
189 U0298
190 U0298 ;-------------------------------------------------------------------------------
191 U0298 ; The following required for back-compatibility with code which does not use
192 U0298 ; segments.
193 U0298
194 0000 ???? SEG
195 0000 ????
196 0000 ???? ; EOF
------- FILE ./chess.asm
------- FILE macro.h LEVEL 2 PASS 4
0 0000 ???? include "macro.h"
1 0000 ????
2 0000 ???? ; MACRO.H
3 0000 ???? ; Version 1.06, 3/SEPTEMBER/2004
4 0000 ????
5 0000 ???? 00 6a VERSION_MACRO = 106
6 0000 ????
7 0000 ???? ;
8 0000 ???? ; THIS FILE IS EXPLICITLY SUPPORTED AS A DASM-PREFERRED COMPANION FILE
9 0000 ???? ; PLEASE DO *NOT* REDISTRIBUTE MODIFIED VERSIONS OF THIS FILE!
10 0000 ???? ;
11 0000 ???? ; This file defines DASM macros useful for development for the Atari 2600.
12 0000 ???? ; It is distributed as a companion machine-specific support package
13 0000 ???? ; for the DASM compiler. Updates to this file, DASM, and associated tools are
14 0000 ???? ; available at at http://www.atari2600.org/dasm
15 0000 ???? ;
16 0000 ???? ; Many thanks to the people who have contributed. If you take issue with the
17 0000 ???? ; contents, or would like to add something, please write to me
18 0000 ???? ; ([email protected]) with your contribution.
19 0000 ???? ;
20 0000 ???? ; Latest Revisions...
21 0000 ???? ;
22 0000 ???? ; 1.06 03/SEP/2004 - nice revision of VERTICAL_BLANK (Edwin Blink)
23 0000 ???? ; 1.05 14/NOV/2003 - Added VERSION_MACRO equate (which will reflect 100x version #)
24 0000 ???? ; This will allow conditional code to verify MACRO.H being
25 0000 ???? ; used for code assembly.
26 0000 ???? ; 1.04 13/NOV/2003 - SET_POINTER macro added (16-bit address load)
27 0000 ???? ;
28 0000 ???? ; 1.03 23/JUN/2003 - CLEAN_START macro added - clears TIA, RAM, registers
29 0000 ???? ;
30 0000 ???? ; 1.02 14/JUN/2003 - VERTICAL_SYNC macro added
31 0000 ???? ; (standardised macro for vertical synch code)
32 0000 ???? ; 1.01 22/MAR/2003 - SLEEP macro added.
33 0000 ???? ; - NO_ILLEGAL_OPCODES switch implemented
34 0000 ???? ; 1.0 22/MAR/2003 Initial release
35 0000 ????
36 0000 ???? ; Note: These macros use illegal opcodes. To disable illegal opcode usage,
37 0000 ???? ; define the symbol NO_ILLEGAL_OPCODES (-DNO_ILLEGAL_OPCODES=1 on command-line).
38 0000 ???? ; If you do not allow illegal opcode usage, you must include this file
39 0000 ???? ; *after* including VCS.H (as the non-illegal opcodes access hardware
40 0000 ???? ; registers and require them to be defined first).
41 0000 ????
42 0000 ???? ; Available macros...
43 0000 ???? ; SLEEP n - sleep for n cycles
44 0000 ???? ; VERTICAL_SYNC - correct 3 scanline vertical synch code
45 0000 ???? ; CLEAN_START - set machine to known state on startup
46 0000 ???? ; SET_POINTER - load a 16-bit absolute to a 16-bit variable
47 0000 ????
48 0000 ???? ;-------------------------------------------------------------------------------
49 0000 ???? ; SLEEP duration
50 0000 ???? ; Original author: Thomas Jentzsch
51 0000 ???? ; Inserts code which takes the specified number of cycles to execute. This is
52 0000 ???? ; useful for code where precise timing is required.
53 0000 ???? ; ILLEGAL-OPCODE VERSION DOES NOT AFFECT FLAGS OR REGISTERS.
54 0000 ???? ; LEGAL OPCODE VERSION MAY AFFECT FLAGS
55 0000 ???? ; Uses illegal opcode (DASM 2.20.01 onwards).
56 0000 ????
57 0000 ???? MAC sleep
58 0000 ???? .CYCLES SET {1}
59 0000 ????
60 0000 ???? IF .CYCLES < 2
61 0000 ???? ECHO "MACRO ERROR: 'SLEEP': Duration must be > 1"
62 0000 ???? ERR
63 0000 ???? ENDIF
64 0000 ????
65 0000 ???? IF .CYCLES & 1
66 0000 ???? IFNCONST NO_ILLEGAL_OPCODES
67 0000 ???? nop 0
68 0000 ???? ELSE
69 0000 ???? bit VSYNC
70 0000 ???? ENDIF
71 0000 ???? .CYCLES SET .CYCLES - 3
72 0000 ???? ENDIF
73 0000 ????
74 0000 ???? REPEAT .CYCLES / 2
75 0000 ???? nop
76 0000 ???? REPEND
77 0000 ???? ENDM ;usage: SLEEP n (n>1)
78 0000 ????
79 0000 ???? ;-------------------------------------------------------------------------------
80 0000 ???? ; VERTICAL_SYNC
81 0000 ???? ; revised version by Edwin Blink -- saves bytes!
82 0000 ???? ; Inserts the code required for a proper 3 scanline vertical sync sequence
83 0000 ???? ; Note: Alters the accumulator
84 0000 ????
85 0000 ???? ; OUT: A = 0
86 0000 ????
87 0000 ???? MAC vertical_sync
88 0000 ???? lda #%1110 ; each '1' bits generate a VSYNC ON line (bits 1..3)
89 0000 ???? .VSLP1 sta WSYNC ; 1st '0' bit resets Vsync, 2nd '0' bit exit loop
90 0000 ???? sta VSYNC
91 0000 ???? lsr
92 0000 ???? bne .VSLP1 ; branch until VYSNC has been reset
93 0000 ???? ENDM
94 0000 ????
95 0000 ???? ;-------------------------------------------------------------------------------
96 0000 ???? ; CLEAN_START
97 0000 ???? ; Original author: Andrew Davie
98 0000 ???? ; Standardised start-up code, clears stack, all TIA registers and RAM to 0
99 0000 ???? ; Sets stack pointer to $FF, and all registers to 0
100 0000 ???? ; Sets decimal mode off, sets interrupt flag (kind of un-necessary)
101 0000 ???? ; Use as very first section of code on boot (ie: at reset)
102 0000 ???? ; Code written to minimise total ROM usage - uses weird 6502 knowledge :)
103 0000 ????
104 0000 ???? MAC clean_start
105 0000 ???? sei
106 0000 ???? cld
107 0000 ????
108 0000 ???? ldx #0
109 0000 ???? txa
110 0000 ???? tay
111 0000 ???? .CLEAR_STACK dex
112 0000 ???? txs
113 0000 ???? pha
114 0000 ???? bne .CLEAR_STACK ; SP=$FF, X = A = Y = 0
115 0000 ????
116 0000 ???? ENDM
117 0000 ????
118 0000 ???? ;-------------------------------------------------------
119 0000 ???? ; SET_POINTER
120 0000 ???? ; Original author: Manuel Rotschkar
121 0000 ???? ;
122 0000 ???? ; Sets a 2 byte RAM pointer to an absolute address.
123 0000 ???? ;
124 0000 ???? ; Usage: SET_POINTER pointer, address
125 0000 ???? ; Example: SET_POINTER SpritePTR, SpriteData
126 0000 ???? ;
127 0000 ???? ; Note: Alters the accumulator, NZ flags
128 0000 ???? ; IN 1: 2 byte RAM location reserved for pointer
129 0000 ???? ; IN 2: absolute address
130 0000 ????
131 0000 ???? MAC set_pointer
132 0000 ???? .POINTER SET {1}
133 0000 ???? .ADDRESS SET {2}
134 0000 ????
135 0000 ???? LDA #<.ADDRESS ; Get Lowbyte of Address
136 0000 ???? STA .POINTER ; Store in pointer
137 0000 ???? LDA #>.ADDRESS ; Get Hibyte of Address
138 0000 ???? STA .POINTER+1 ; Store in pointer+1
139 0000 ????
140 0000 ???? ENDM
141 0000 ????
142 0000 ???? ;-------------------------------------------------------
143 0000 ???? ; BOUNDARY byte#
144 0000 ???? ; Original author: Denis Debro (borrowed from Bob Smith / Thomas)
145 0000 ???? ;
146 0000 ???? ; Push data to a certain position inside a page and keep count of how
147 0000 ???? ; many free bytes the programmer will have.
148 0000 ???? ;
149 0000 ???? ; eg: BOUNDARY 5 ; position at byte #5 in page
150 0000 ????
151 0000 ???? __DASM__TOTAL_FREE_MEMORY SET 0
152 0000 ???? .FREE_BYTES SET 0
153 0000 ???? MAC boundary
154 0000 ???? REPEAT 256
155 0000 ???? IF <. % {1} = 0
156 0000 ???? MEXIT
157 0000 ???? ELSE
158 0000 ???? .FREE_BYTES SET .FREE_BYTES + 1
159 0000 ???? .byte $00
160 0000 ???? ENDIF
161 0000 ???? REPEND
162 0000 ???? __DASM__TOTAL_FREE_MEMORY SET __DASM__TOTAL_FREE_MEMORY + .FREE_BYTES
163 0000 ???? ENDM
164 0000 ????
165 0000 ????
166 0000 ???? ; EOF
------- FILE ./chess.asm
------- FILE piece_defines.h LEVEL 2 PASS 4
0 0000 ???? include "piece_defines.h"
1 0000 ???? ; Copyright (C)2020 Andrew Davie
2 0000 ????
3 0000 ???? 00 80 BLACK = 128
4 0000 ???? 00 00 WHITE = 0
5 0000 ????
6 0000 ???? 00 80 FLAG_COLOUR = 128 ; mask
7 0000 ???? 00 40 FLAG_MOVED = 64 ; mark ALL pieces when moved. Used for castling
8 0000 ???? ; but maybe useful for evaluation of development
9 0000 ???? 00 20 FLAG_ENPASSANT = 32
10 0000 ???? 00 10 FLAG_CASTLE = 16
11 0000 ????
12 0000 ???? ;---------------------------------------------------------------------------------------------------
13 0000 ???? ; DEFINE THE PIECES
14 0000 ???? ; ID lives in bits 0-2
15 0000 ????
16 0000 ???? 00 00 BLANK = 0
17 0000 ???? 00 00 ███ = BLANK
18 0000 ????
19 0000 ???? 00 01 WPAWN = 1
20 0000 ???? 00 01 WP = WPAWN
21 0000 ???? 00 02 BPAWN = 2
22 0000 ???? 00 02 BP = BPAWN
23 0000 ???? 00 03 KNIGHT = 3
24 0000 ???? 00 03 N = KNIGHT
25 0000 ???? 00 04 BISHOP = 4
26 0000 ???? 00 04 B = BISHOP
27 0000 ???? 00 05 ROOK = 5
28 0000 ???? 00 05 R = ROOK
29 0000 ???? 00 06 QUEEN = 6
30 0000 ???? 00 06 Q = QUEEN
31 0000 ???? 00 07 KING = 7
32 0000 ???? 00 07 K = KING
33 0000 ????
34 0000 ???? 00 0f PIECE_MASK = 15 ; trim off the flags leaving just piece ID
35 0000 ????
36 0000 ???? ;---------------------------------------------------------------------------------------------------
37 0000 ????
38 0000 ???? ; Movements
39 0000 ????
40 0000 ???? 00 0a _UP = 10 ; up
41 0000 ???? ff ff ff ff _LEFT = -1 ; left
42 0000 ???? ff ff ff f6 _DOWN = -10 ; down
43 0000 ???? 00 01 _RIGHT = 1 ; right
44 0000 ????
45 0000 ???? ; EOF
------- FILE ./chess.asm
13 0000 ????
14 0000 ???? 00 00 VERBOSE = 0 ; set to 1 for compile messages
15 0000 ????
16 0000 ???? ORIGIN SET 0
17 0000 ???? ORIGIN_RAM SET 0
18 0000 ????
------- FILE segtime.asm LEVEL 2 PASS 4
0 0000 ???? include "segtime.asm"
1 0000 ???? ; Sokoboo - a Sokoban implementation
2 0000 ???? ; using a generic tile-based display engine for the Atari 2600
3 0000 ???? ; Sokoban (倉庫番)™ is © Falcon Co., Ltd.
4 0000 ???? ;
5 0000 ???? ; Code related to this Sokoban™ implementation was developed by Andrew Davie.
6 0000 ???? ;
7 0000 ???? ; Code related to the generic tile-based display engine was developed by
8 0000 ???? ; Andrew Davie and Thomas Jentzsch during 2003-2011 and is
9 0000 ???? ; Copyright(C)2003-2019 Thomas Jentzsch and Andrew Davie - contacts details:
10 0000 ???? ; Andrew Davie ([email protected]), Thomas Jentzsch ([email protected]).
11 0000 ???? ;
12 0000 ???? ; Code related to music and sound effects uses the TIATracker music player
13 0000 ???? ; Copyright 2016 Andre "Kylearan" Wichmann - see source code in the "sound"
14 0000 ???? ; directory for Apache licensing details.
15 0000 ???? ;
16 0000 ???? ; Some level data incorporated in this program were created by Lee J Haywood.
17 0000 ???? ; See the copyright notices in the License directory for a list of level
18 0000 ???? ; contributors.
19 0000 ???? ;
20 0000 ???? ; Except where otherwise indicated, this software is released under the
21 0000 ???? ; following licensing arrangement...
22 0000 ???? ;
23 0000 ???? ; This program is free software: you can redistribute it and/or modify
24 0000 ???? ; it under the terms of the GNU General Public License as published by
25 0000 ???? ; the Free Software Foundation, either version 3 of the License, or
26 0000 ???? ; (at your option) any later version.
27 0000 ???? ; see https://www.gnu.org/licenses/gpl-3.0.en.html
28 0000 ????
29 0000 ???? ; This program is distributed in the hope that it will be useful,
30 0000 ???? ; but WITHOUT ANY WARRANTY; without even the implied warranty of
31 0000 ???? ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 0000 ???? ; GNU General Public License for more details.
33 0000 ????
34 0000 ???? ; segtime optimization (averages):
35 0000 ???? ; lost time = segtime/2 * 64
36 0000 ???? ; num-segments = (vblank + overscan time) (NTSC 276=62+51=113) / 2 / segtime
37 0000 ???? ; overhead: num-segments * 8 (assuming minimal INTIM check only)
38 0000 ???? ;
39 0000 ???? ; segtime = 2:
40 0000 ???? ; lost time = 64
41 0000 ???? ; num-segments = 28
42 0000 ???? ; overhead = 224!
43 0000 ???? ; segtime = 3:
44 0000 ???? ; lost time = 96
45 0000 ???? ; num-segments = 18
46 0000 ???? ; overhead = 144!
47 0000 ???? ; segtime = 4: <--!!!
48 0000 ???? ; lost time = 128!
49 0000 ???? ; num-segments = 28
50 0000 ???? ; overhead = 112
51 0000 ???? ; segtime = 5:
52 0000 ???? ; lost time = 160!
53 0000 ???? ; num-segments = 11
54 0000 ???? ; overhead = 88
55 0000 ???? ; segtime = 6:
56 0000 ???? ; lost time = 192!
57 0000 ???? ; num-segments = 9
58 0000 ???? ; overhead = 72
59 0000 ???? ; segtime = 7:
60 0000 ???? ; lost time = 224!
61 0000 ???? ; num-segments = 8
62 0000 ???? ; overhead = 64
63 0000 ???? ; segtime = 10:
64 0000 ???? ; lost time = 320!
65 0000 ???? ; num-segments = 5
66 0000 ???? ; overhead = 40
67 0000 ???? ; segtime = 20:
68 0000 ???? ; lost time = 640!
69 0000 ???? ; num-segments = 2
70 0000 ???? ; overhead = 16
71 0000 ???? ; segtime = 40:
72 0000 ???? ; lost time = 1280!
73 0000 ???? ; num-segments = 1
74 0000 ???? ; overhead = 8
75 0000 ????
76 0000 ???? ; optimal INTIM segtime is 4 + 1 = 5,
77 0000 ???? ; below wasted time increases rapidly, above only moderately
78 0000 ???? ; if the overhead becomes larger, optimal segtimes will increase too
79 0000 ???? ; also the lost time will become smaller, if smaller segments can be used instead,
80 0000 ???? ; so larger segtimes are not that bad then
81 0000 ????
82 0000 ????
83 0000 ???? MAC segtime
84 0000 ???? {1} SET {2}
85 0000 ???? TEST_{1} = 0
86 0000 ???? ENDM
87 0000 ????
88 0000 ???? MAC segtime_c
89 0000 ???? {1} SET ({2}+32)/64 + 2
90 0000 ???? TEST_{1} = 0
91 0000 ???? ENDM
92 0000 ????
93 0000 ???? ; Pathways
94 0000 ???? ; StealPart3, not enough time for SCD_SLOW --> 79✅
95 0000 ???? ; if QuickDraw does immediate exit, 58✅
96 0000 ????
97 0000 ???? ;---------------------------------------------------------------------------------------------------
98 0000 ????
0 0000 ???? SEGTIME_C SEGTIME_MINIMUM_TIMESLICE, 54 ;✅ abort time maximum requirement for timeslice
1 0000 ???? SEGTIME_MINIMUM_TIMESLICE SET (54+32)/64 + 2
2 0000 ???? 00 00 TEST_SEGTIME_MINIMUM_TIMESLICE = 0
100 0000 ????
101 0000 ???? ; Note: we add 1 to the minimum because there's a bit of overhead at the start of the timeslice code which vectors
102 0000 ???? ; to the appropriate timeslice. That timeslice then checks the segtime again -- and in the case of the minimum we
103 0000 ???? ; will already have used 55 cycles of the available timeslice to get to the segtime check. Given that there are only
104 0000 ???? ; 9 spare cycles in the 'unit' left, it's probably more efficient to abort earlier and save those 55 cycles for other
105 0000 ???? ; uses ...
106 0000 ????
107 0000 ????
108 0000 ???? ; The following timings have been physicaly timed via code/debugger... the comment shows the worst observed time.
109 0000 ???? ; Generally the allocated segtime should be a bit bigger than the worst observed, to cater for the minor code
110 0000 ???? ; outside the creature itself which might otherwise cause screen time over-run.
111 0000 ????
112 0000 ???? ; The following are NOT object-related and timing is a bit of manual guesswork/calculation
113 0000 ???? ; Comment may indicate at what value a glitch was DEFINITELY seen. These timings may not be optimal.
114 0000 ????
0 0000 ???? SEGTIME SEGTIME_MAN,22 ;18 ;12 ;NFI
1 0000 ???? SEGTIME_MAN SET 22
2 0000 ???? 00 00 TEST_SEGTIME_MAN = 0
------- FILE ./chess.asm
20 0000 ????
21 0000 ????
22 0000 ???? 00 00 _FIRST_BANK = 0 ; 3E+ 1st bank holds reset vectors
23 0000 ????
24 0000 ???? ;FIXED_BANK = 3 * 2048 ;--> 8K ROM tested OK
25 0000 ???? ;FIXED_BANK = 7 * 2048 ;--> 16K ROM tested OK
26 0000 ???? ;FIXED_BANK = 15 * 2048 ; ->> 32K
27 0000 ???? ;FIXED_BANK = 31 * 2048 ; ->> 64K
28 0000 ???? ;FIXED_BANK = 239 * 2048 ;--> 480K ROM tested OK (KK/CC2 compatibility)
29 0000 ???? ;FIXED_BANK = 127 * 2048 ;--> 256K ROM tested OK
30 0000 ???? ;FIXED_BANK = 255 * 2048 ;--> 512K ROM tested OK (CC2 can't handle this)
31 0000 ????
32 0000 ???? 00 01 YES = 1
33 0000 ???? 00 00 NO = 0
34 0000 ????
35 0000 ???? 70 00 INFINITY = $7000 ;32767
36 0000 ????
37 0000 ????
38 0000 ???? ; assemble diagnostics. Remove for release.
39 0000 ????
40 0000 ???? 00 00 TEST_POSITION = 0 ; 0=normal, 1 = setup test position
41 0000 ???? 00 00 DIAGNOSTICS = 0
42 0000 ???? 00 01 QUIESCENCE = 1
43 0000 ???? 00 00 ASSERTS = 0
44 0000 ???? 00 00 PVSP = 0 ; player versus player =1
45 0000 ???? 00 01 ENPASSANT_ENABLED = 1
46 0000 ???? 00 01 CASTLING_ENABLED = 1
47 0000 ????
48 0000 ???? 00 03 SEARCH_DEPTH = 3
49 0000 ???? 00 04 QUIESCE_EXTRA_DEPTH = 4
50 0000 ????
51 0000 ????
52 0000 ???? 00 07 PLY_BANKS = SEARCH_DEPTH + QUIESCE_EXTRA_DEPTH
53 0000 ???? 00 07 MAX_PLY_DEPTH_BANK = PLY_BANKS ;TODO -- RAMBANK_PLY + PLY_BANKS
54 0000 ????
55 0000 ???? ;IF RAMBANK_PLY + MAX_PLY_DEPTH_BANK > 31
56 0000 ???? ; ERR "Not enough RAM for PLY banks"
57 0000 ???? ;ENDIF
58 0000 ????
59 0000 ????
60 0000 ????
61 0000 ????
62 0000 ???? 00 80 SWAP_SIDE = 128 ;TODO + (RAMBANK_PLY ^ (RAMBANK_PLY+1))
63 0000 ????
64 0000 ????
65 0000 ????
66 0000 ???? ; DELAYS
67 0000 ????
68 0000 ???? 00 0a READY_TO_MOVE_FLASH = 10
69 0000 ????
70 0000 ???? ;===================================
71 0000 ???? 00 00 FINAL_VERSION = NO ; this OVERRIDES any selections below and sets everything correct for a final release
72 0000 ???? ;===================================
73 0000 ????
74 0000 ???? ;-------------------------------------------------------------------------------
75 0000 ???? ; The following are optional YES/NO depending on phase of the moon
76 0000 ???? L276 SET YES ; use 276 line display for NTSC
77 0000 ???? ;-------------------------------------------------------------------------------
78 0000 ???? ; DO NOT MODIFY THE BELOW SETTINGS -- USE THE ONES ABOVE!
79 0000 ???? ; Here we make sure everyting is OK based on the single switch -- less chance for accidents
80 0000 ???? - IF FINAL_VERSION = YES
81 0000 ???? -L276 SET YES ; use 276 line display for NTSC
82 0000 ???? ENDIF
83 0000 ????
84 0000 ???? ;-------------------------------------------------------------------------------
85 0000 ????
86 0000 ???? 00 01 COMPILE_ILLEGALOPCODES = 1
87 0000 ????
88 0000 ???? 00 07 DIRECTION_BITS = %111 ; for ManLastDirection
89 0000 ????
90 0000 ???? ;------------------------------------------------------------------------------
91 0000 ????
92 0000 ???? 00 01 PLUSCART = YES
93 0000 ????
94 0000 ???? ;------------------------------------------------------------------------------
95 0000 ????
96 0000 ????
97 0000 ???? 00 08 CHESSBOARD_ROWS = 8 ; number of ROWS of chessboard
98 0000 ???? 00 18 LINES_PER_CHAR = 24 ; MULTIPLE OF 3 SO RGB INTERFACES CHARS OK
99 0000 ???? 00 48 PIECE_SHAPE_SIZE = 72 ; 3 PF bytes x 24 scanlines
100 0000 ????
101 0000 ???? 00 3f SET_BANK = $3F ; write address to switch ROM banks
102 0000 ???? 00 3e SET_BANK_RAM = $3E ; write address to switch RAM banks
103 0000 ????
104 0000 ????
105 0000 ???? 02 00 RAM_SIZE = $200
106 0000 ???? 02 00 RAM_WRITE = $200 ; add this to RAM address when doing writes
107 0000 ???? 02 00 RAM = RAM_WRITE
108 0000 ????
109 0000 ????
110 0000 ????
111 0000 ???? ; Platform constants:
112 0000 ???? 00 02 PAL = %10
113 0000 ???? 00 02 PAL_50 = PAL|0
114 0000 ???? 00 03 PAL_60 = PAL|1
115 0000 ????
116 0000 ????
117 0000 ???? IF L276
118 0000 ???? 00 30 VBLANK_TIM_NTSC = 48 ; NTSC 276 (Desert Falcon does 280, so this should be pretty safe)
119 0000 ???? - ELSE
120 0000 ???? -VBLANK_TIM_NTSC = 50 ; NTSC 262
121 0000 ???? ENDIF
122 0000 ???? 00 55 VBLANK_TIM_PAL = 85 ;85 ; PAL 312 (we could increase this too, if we want to, but I suppose the used vertical screen size would become very small then)
123 0000 ????
124 0000 ???? IF L276
125 0000 ???? 00 23 OVERSCAN_TIM_NTSC = 35 ;24 ;51 ; NTSC 276 (Desert Falcon does 280, so this should be pretty safe)
126 0000 ???? - ELSE
127 0000 ???? -OVERSCAN_TIM_NTSC = 8 ;51 ; NTSC 262
128 0000 ???? ENDIF
129 0000 ???? 00 29 OVERSCAN_TIM_PAL = 41 ; PAL 312 (we could increase this too, if we want to, but I suppose the used vertical screen size would become very small then)
130 0000 ????
131 0000 ???? IF L276
132 0000 ???? 01 14 SCANLINES_NTSC = 276 ; NTSC 276 (Desert Falcon does 280, so this should be pretty safe)
133 0000 ???? - ELSE
134 0000 ???? -SCANLINES_NTSC = 262 ; NTSC 262
135 0000 ???? ENDIF
136 0000 ???? 01 38 SCANLINES_PAL = 312
137 0000 ????
138 0000 ????
139 0000 ???? 00 2e TIME_PART_2 = 46
140 0000 ???? 00 2e TIME_PART_1 = 46
141 0000 ????
142 0000 ????
143 0000 ???? 00 00 SLOT0 = 0
144 0000 ???? 00 40 SLOT1 = 64
145 0000 ???? 00 80 SLOT2 = 128
146 0000 ???? 00 c0 SLOT3 = 192
147 0000 ????
148 0000 ???? ;------------------------------------------------------------------------------
149 0000 ???? ; MACRO definitions
150 0000 ????
151 0000 ????
152 0000 ???? 04 00 _ROM_BANK_SIZE = $400
153 0000 ???? 02 00 _RAM_BANK_SIZE = $200
154 0000 ????
155 0000 ???? MAC newbank
156 0000 ???? SEG {1}
157 0000 ???? ORG _ORIGIN
158 0000 ???? RORG _BANK_ADDRESS_ORIGIN
159 0000 ???? _BANK_START SET *
160 0000 ???? {1}_START SET *
161 0000 ???? _CURRENT_BANK SET _ORIGIN/1024
162 0000 ???? {1} SET _BANK_SLOT + _CURRENT_BANK
163 0000 ???? _ORIGIN SET _ORIGIN + 1024
164 0000 ???? ENDM ; bank name
165 0000 ????
166 0000 ???? ; MAC DEFINE_1K_SEGMENT ; {seg name}
167 0000 ???? ; ALIGN $400
168 0000 ???? ;SEGMENT_{1} SET *
169 0000 ???? ;BANK_{1} SET _CURRENT_BANK
170 0000 ???? ; ENDM
171 0000 ????
172 0000 ???? MAC check_bank_size
173 0000 ???? .TEMP = * - _BANK_START
174 0000 ???? ECHO {1}, "(1K) SIZE = ", .TEMP, ", FREE=", _ROM_BANK_SIZE - .TEMP
175 0000 ???? IF ( .TEMP ) > _ROM_BANK_SIZE
176 0000 ???? ECHO "BANK OVERFLOW @ ", {1}, " size=", * - ORIGIN
177 0000 ???? ERR
178 0000 ???? ENDIF
179 0000 ???? ENDM ; name
180 0000 ????
181 0000 ???? MAC check_ram_bank_size
182 0000 ???? .TEMP = * - _BANK_START
183 0000 ???? ECHO {1}, "(512 byte) SIZE = ", .TEMP, ", FREE=", _RAM_BANK_SIZE - .TEMP
184 0000 ???? IF ( .TEMP ) > _RAM_BANK_SIZE
185 0000 ???? ECHO "BANK OVERFLOW @ ", {1}, " size=", * - ORIGIN
186 0000 ???? ERR
187 0000 ???? ENDIF
188 0000 ???? ENDM ; name
189 0000 ????
190 0000 ???? ;---------------------------------------------------------------------------------------------------
191 0000 ????
192 0000 ???? ; Macro inserts a page break if the object would overlap a page
193 0000 ????
194 0000 ???? MAC optional_pagebreak
195 0000 ???? LIST OFF
196 0000 ???? IF (>( * + {2} -1 )) > ( >* )
197 0000 ???? EARLY_LOCATION SET *
198 0000 ???? ALIGN 256
199 0000 ???? IF VERBOSE=1
200 0000 ???? ECHO "PAGE BREAK INSERTED FOR", {1}
201 0000 ???? ECHO "REQUESTED SIZE =", {2}
202 0000 ???? ECHO "WASTED SPACE =", *-EARLY_LOCATION
203 0000 ???? ECHO "PAGEBREAK LOCATION =", *
204 0000 ???? ENDIF
205 0000 ???? ENDIF
206 0000 ???? LIST ON
207 0000 ???? ENDM ; { string, size }
208 0000 ????
209 0000 ????
210 0000 ???? MAC check_page_crossing
211 0000 ???? LIST OFF
212 0000 ???? IF ( >BLOCK_END != >BLOCK_START )
213 0000 ???? ECHO "PAGE CROSSING @ ", BLOCK_START
214 0000 ???? ENDIF
215 0000 ???? LIST ON
216 0000 ???? ENDM
217 0000 ????
218 0000 ???? MAC checkpage
219 0000 ???? LIST OFF
220 0000 ???? IF >. != >{1}
221 0000 ???? ECHO ""
222 0000 ???? ECHO "ERROR: different pages! (", {1}, ",", ., ")"
223 0000 ???? ECHO ""
224 0000 ???? ERR
225 0000 ???? ENDIF
226 0000 ???? LIST ON
227 0000 ???? ENDM
228 0000 ????
229 0000 ???? MAC checkpagex
230 0000 ???? LIST OFF
231 0000 ???? IF >. != >{1}
232 0000 ???? ECHO ""
233 0000 ???? ECHO "ERROR: different pages! (", {1}, ",", ., ") @ {0}"
234 0000 ???? ECHO {2}
235 0000 ???? ECHO ""
236 0000 ???? ERR
237 0000 ???? ENDIF
238 0000 ???? LIST ON
239 0000 ???? ENDM
240 0000 ????
241 0000 ???? ;---------------------------------------------------------------------------------------------------
242 0000 ????
243 0000 ???? ; Defines a variable of the given size, making sure it doesn't cross a page
244 0000 ???? MAC variable
245 0000 ???? OPTIONAL_PAGEBREAK "Variable", {2}
246 0000 ???? {1} ds {2}
247 0000 ???? ENDM ; {name, size}
248 0000 ????
249 0000 ????
250 0000 ???? ;---------------------------------------------------------------------------------------------------
251 0000 ????
252 0000 ???? MAC def
253 0000 ???? SLOT_{1} SET _BANK_SLOT
254 0000 ???? BANK_{1} SET SLOT_{1} + _CURRENT_BANK ; bank in which this subroutine resides
255 0000 ???? {1} ; entry point
256 0000 ???? TEMPORARY_VAR SET Overlay
257 0000 ???? TEMPORARY_OFFSET SET 0
258 0000 ???? VAR_BOUNDARY_{1} SET TEMPORARY_OFFSET
259 0000 ???? FUNCTION_NAME SET {1}
260 0000 ???? ENDM ; name of subroutine
261 0000 ????
262 0000 ????
263 0000 ???? ;---------------------------------------------------------------------------------------------------
264 0000 ????
265 0000 ???? MAC allocate
266 0000 ???? OPTIONAL_PAGEBREAK "Table", {2}
267 0000 ???? DEF {1}
268 0000 ???? ENDM
269 0000 ????
270 0000 ???? ;---------------------------------------------------------------------------------------------------
271 0000 ????
272 0000 ???? MAC slot
273 0000 ???? IF ({1} < 0) || ({1} > 3)
274 0000 ???? ECHO "Illegal bank address/segment location", {1}
275 0000 ???? ERR
276 0000 ???? ENDIF
277 0000 ???? _BANK_ADDRESS_ORIGIN SET $F000 + ({1} * _ROM_BANK_SIZE)
278 0000 ???? _BANK_SLOT SET {1} * 64 ; D7/D6 selector
279 0000 ???? ENDM ; {1}
280 0000 ????
281 0000 ????
282 0000 ???? ;---------------------------------------------------------------------------------------------------
283 0000 ????
284 0000 ???? MAC negeval
285 0000 ????
286 0000 ???? sec
287 0000 ???? lda #0
288 0000 ???? sbc Evaluation
289 0000 ???? sta Evaluation
290 0000 ???? lda #0
291 0000 ???? sbc Evaluation+1
292 0000 ???? sta Evaluation+1
293 0000 ???? ENDM
294 0000 ????
295 0000 ????
296 0000 ???? MAC swap
297 0000 ???? lda sideToMove
298 0000 ???? eor #SWAP_SIDE
299 0000 ???? sta sideToMove
300 0000 ???? ENDM
301 0000 ????
302 0000 ????
303 0000 ???? ;---------------------------------------------------------------------------------------------------
304 0000 ????
305 0000 ???? TEMPORARY_OFFSET SET 0
306 0000 ????
307 0000 ????
308 0000 ???? MAC vend
309 0000 ???? IFNCONST {1}
310 0000 ???? ECHO "Incorrect VEND label", {1}
311 0000 ???? ERR
312 0000 ???? ENDIF
313 0000 ???? VAREND_{1} = TEMPORARY_VAR
314 0000 ???? ENDM ; {1}
315 0000 ????
316 0000 ????
317 0000 ???? MAC refer
318 0000 ???? IF VAREND_{1} > TEMPORARY_VAR
319 0000 ???? TEMPORARY_VAR SET VAREND_{1}
320 0000 ???? ENDIF
321 0000 ???? ENDM ; {1}
322 0000 ????
323 0000 ????
324 0000 ????
325 0000 ???? ; Define a temporary variable for use in a subroutine
326 0000 ???? ; Will allocate appropriate bytes, and also check for overflow of the available overlay buffer
327 0000 ????
328 0000 ???? MAC var
329 0000 ???? {1} = TEMPORARY_VAR
330 0000 ???? TEMPORARY_VAR SET TEMPORARY_VAR + TEMPORARY_OFFSET + {2}
331 0000 ????
332 0000 ???? OVERLAY_DELTA SET TEMPORARY_VAR - Overlay
333 0000 ???? IF OVERLAY_DELTA > MAXIMUM_REQUIRED_OVERLAY_SIZE
334 0000 ???? MAXIMUM_REQUIRED_OVERLAY_SIZE SET OVERLAY_DELTA
335 0000 ???? ENDIF
336 0000 ???? IF OVERLAY_DELTA > OVERLAY_SIZE
337 0000 ???? ECHO "Temporary Variable", {1}, "overflow!"
338 0000 ???? ERR
339 0000 ???? ENDIF
340 0000 ???? LIST ON
341 0000 ???? ENDM ; { name, size }
342 0000 ????
343 0000 ????
344 0000 ???? ;---------------------------------------------------------------------------------------------------
345 0000 ????
346 0000 ???? MAC tag
347 0000 ???? ; {0}
348 0000 ???? ENDM ; {ident/tag}
349 0000 ????
350 0000 ???? ;---------------------------------------------------------------------------------------------------
351 0000 ????
352 0000 ???? MAC sta@ram
353 0000 ???? sta [RAM]+{0}
354 0000 ???? ENDM ;{}
355 0000 ????
356 0000 ???? MAC stx@ram
357 0000 ???? stx [RAM]+{0}
358 0000 ???? ENDM
359 0000 ????
360 0000 ???? MAC sty@ram
361 0000 ???? sty [RAM]+{0}
362 0000 ???? ENDM
363 0000 ????
364 0000 ???? MAC sta@ply
365 0000 ???? sta [RAM]+{0}
366 0000 ???? ENDM ;{}
367 0000 ????
368 0000 ???? MAC stx@ply
369 0000 ???? stx [RAM]+{0}
370 0000 ???? ENDM
371 0000 ????
372 0000 ???? MAC sty@ply
373 0000 ???? sty [RAM]+{0}
374 0000 ???? ENDM
375 0000 ????
376 0000 ????
377 0000 ???? MAC lda@ram
378 0000 ???? lda {0}
379 0000 ???? ENDM ;{}
380 0000 ????
381 0000 ???? MAC ldx@ram
382 0000 ???? ldx {0}
383 0000 ???? ENDM ;{}
384 0000 ????
385 0000 ???? MAC ldy@ram
386 0000 ???? ldy {0}
387 0000 ???? ENDM ;{}
388 0000 ????
389 0000 ????
390 0000 ???? MAC lda@ply
391 0000 ???? lda {0}
392 0000 ???? ENDM ;{}
393 0000 ????
394 0000 ???? MAC ldx@ply
395 0000 ???? ldx {0}
396 0000 ???? ENDM ;{}
397 0000 ????
398 0000 ???? MAC ldy@ply
399 0000 ???? ldy {0}
400 0000 ???? ENDM ;{}
401 0000 ????
402 0000 ????
403 0000 ???? MAC adc@ply
404 0000 ???? adc {0}
405 0000 ???? ENDM ;{}
406 0000 ????
407 0000 ???? MAC sbc@ply
408 0000 ???? sbc {0}
409 0000 ???? ENDM ;{}
410 0000 ????
411 0000 ???? MAC cmp@ply
412 0000 ???? cmp {0}
413 0000 ???? ENDM ;{}
414 0000 ????
415 0000 ???? ;---------------------------------------------------------------------------------------------------
416 0000 ????
417 0000 ???? MAC newrambank
418 0000 ???? ; {1} bank name
419 0000 ???? ; {2} RAM bank number
420 0000 ????
421 0000 ???? SEG.U {1}
422 0000 ???? ORG ORIGIN_RAM
423 0000 ???? RORG _BANK_ADDRESS_ORIGIN
424 0000 ???? _BANK_START SET *
425 0000 ???? RAMBANK_{1} SET _BANK_SLOT + (ORIGIN_RAM / RAM_SIZE)
426 0000 ???? _CURRENT_RAMBANK SET RAMBANK_{1}
427 0000 ???? ORIGIN_RAM SET ORIGIN_RAM + RAM_SIZE
428 0000 ???? ENDM ; bank name
429 0000 ????
430 0000 ???? ;---------------------------------------------------------------------------------------------------
431 0000 ????
432 0000 ???? MAC resync
433 0000 ???? ; resync screen, X and Y == 0 afterwards
434 0000 ???? lda #%10 ; make sure VBLANK is ON
435 0000 ???? sta VBLANK
436 0000 ????
437 0000 ???? ldx #8 ; 5 or more RESYNC_FRAMES
438 0000 ???? .loopResync
439 0000 ???? VERTICAL_SYNC
440 0000 ????
441 0000 ???? ldy #SCANLINES_NTSC/2 - 2
442 0000 ???? lda Platform
443 0000 ???? eor #PAL_50 ; PAL-50?
444 0000 ???? bne .ntsc
445 0000 ???? ldy #SCANLINES_PAL/2 - 2
446 0000 ???? .ntsc
447 0000 ???? .loopWait
448 0000 ???? sta WSYNC
449 0000 ???? sta WSYNC
450 0000 ???? dey
451 0000 ???? bne .loopWait
452 0000 ???? dex
453 0000 ???? bne .loopResync
454 0000 ???? ENDM
455 0000 ????
456 0000 ???? MAC set_platform
457 0000 ???? ; 00 = NTSC
458 0000 ???? ; 01 = NTSC
459 0000 ???? ; 10 = PAL-50
460 0000 ???? ; 11 = PAL-60
461 0000 ???? lda SWCHB
462 0000 ???? rol
463 0000 ???? rol
464 0000 ???? rol
465 0000 ???? and #%11