-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSokoboo.txt
16037 lines (16037 loc) · 797 KB
/
Sokoboo.txt
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 ./sokoboo.asm LEVEL 1 PASS 4
1 8000 ???? ; Sokoboo - a Sokoban implementation
2 8000 ???? ; using a generic tile-based display engine for the Atari 2600
3 8000 ???? ; Sokoban (倉庫番)™ is © Falcon Co., Ltd.
4 8000 ???? ;
5 8000 ???? ; Code related to this Sokoban™ implementation was developed by Andrew Davie.
6 8000 ???? ;
7 8000 ???? ; Code related to the generic tile-based display engine was developed by
8 8000 ???? ; Andrew Davie and Thomas Jentzsch during 2003-2011 and is
9 8000 ???? ; Copyright(C)2003-2019 Thomas Jentzsch and Andrew Davie - contacts details:
10 8000 ???? ; Andrew Davie (andrew@taswegian.com), Thomas Jentzsch (tjentzsch@yahoo.de).
11 8000 ???? ;
12 8000 ???? ; Code related to music and sound effects uses the TIATracker music player
13 8000 ???? ; Copyright 2016 Andre "Kylearan" Wichmann - see source code in the "sound"
14 8000 ???? ; directory for Apache licensing details.
15 8000 ???? ;
16 8000 ???? ; Some level data incorporated in this program were created by Lee J Haywood.
17 8000 ???? ; See the copyright notices in the License directory for a list of level
18 8000 ???? ; contributors.
19 8000 ???? ;
20 8000 ???? ; Except where otherwise indicated, this software is released under the
21 8000 ???? ; following licensing arrangement...
22 8000 ???? ;
23 8000 ???? ; This program is free software: you can redistribute it and/or modify
24 8000 ???? ; it under the terms of the GNU General Public License as published by
25 8000 ???? ; the Free Software Foundation, either version 3 of the License, or
26 8000 ???? ; (at your option) any later version.
27 8000 ???? ; see https://www.gnu.org/licenses/gpl-3.0.en.html
28 8000 ????
29 8000 ???? ; This program is distributed in the hope that it will be useful,
30 8000 ???? ; but WITHOUT ANY WARRANTY; without even the implied warranty of
31 8000 ???? ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 8000 ???? ; GNU General Public License for more details.
33 8000 ????
34 8000 ????
35 8000 ????
36 8000 ???? 00 40 TIA_BASE_ADDRESS = $40
37 8000 ????
38 8000 ???? processor 6502
------- FILE vcs.h LEVEL 2 PASS 4
0 8000 ???? include "vcs.h"
1 8000 ???? ; VCS.H
2 8000 ???? ; Version 1.05, 13/November/2003
3 8000 ????
4 8000 ???? 00 69 VERSION_VCS = 105
5 8000 ????
6 8000 ???? ; This file defines hardware registers and memory mapping for the
7 8000 ???? ; Atari 2600. It is distributed as a companion machine-specific support package
8 8000 ???? ; for the DASM compiler. Updates to this file, DASM, and associated tools are
9 8000 ???? ; available at at http://www.atari2600.org/dasm
10 8000 ???? ;
11 8000 ???? ; Many thanks to the original author(s) of this file, and to everyone who has
12 8000 ???? ; contributed to understanding the Atari 2600. If you take issue with the
13 8000 ???? ; contents, or naming of registers, please write to me (atari2600@taswegian.com)
14 8000 ???? ; with your views. Please contribute, if you think you can improve this
15 8000 ???? ; file!
16 8000 ???? ;
17 8000 ???? ; Latest Revisions...
18 8000 ???? ; 1.05 13/NOV/2003 - Correction to 1.04 - now functions as requested by MR.
19 8000 ???? ; - Added VERSION_VCS equate (which will reflect 100x version #)
20 8000 ???? ; This will allow conditional code to verify VCS.H being
21 8000 ???? ; used for code assembly.
22 8000 ???? ; 1.04 12/NOV/2003 Added TIA_BASE_WRITE_ADDRESS and TIA_BASE_READ_ADDRESS for
23 8000 ???? ; convenient disassembly/reassembly compatibility for hardware
24 8000 ???? ; mirrored reading/writing differences. This is more a
25 8000 ???? ; readability issue, and binary compatibility with disassembled
26 8000 ???? ; and reassembled sources. Per Manuel Rotschkar's suggestion.
27 8000 ???? ; 1.03 12/MAY/2003 Added SEG segment at end of file to fix old-code compatibility
28 8000 ???? ; which was broken by the use of segments in this file, as
29 8000 ???? ; reported by Manuel Polik on [stella] 11/MAY/2003
30 8000 ???? ; 1.02 22/MAR/2003 Added TIMINT($285)
31 8000 ???? ; 1.01 Constant offset added to allow use for 3F-style bankswitching
32 8000 ???? ; - define TIA_BASE_ADDRESS as $40 for Tigervision carts, otherwise
33 8000 ???? ; it is safe to leave it undefined, and the base address will
34 8000 ???? ; be set to 0. Thanks to Eckhard Stolberg for the suggestion.
35 8000 ???? ; Note, may use -DLABEL=EXPRESSION to define TIA_BASE_ADDRESS
36 8000 ???? ; - register definitions are now generated through assignment
37 8000 ???? ; in uninitialised segments. This allows a changeable base
38 8000 ???? ; address architecture.
39 8000 ???? ; 1.0 22/MAR/2003 Initial release
40 8000 ????
41 8000 ????
42 8000 ???? ;-------------------------------------------------------------------------------
43 8000 ????
44 8000 ???? ; TIA_BASE_ADDRESS
45 8000 ???? ; The TIA_BASE_ADDRESS defines the base address of access to TIA registers.
46 8000 ???? ; Normally 0, the base address should (externally, before including this file)
47 8000 ???? ; be set to $40 when creating 3F-bankswitched (and other?) cartridges.
48 8000 ???? ; The reason is that this bankswitching scheme treats any access to locations
49 8000 ???? ; < $40 as a bankswitch.
50 8000 ????
51 8000 ???? - IFNCONST TIA_BASE_ADDRESS
52 8000 ???? -TIA_BASE_ADDRESS = 0
53 8000 ???? ENDIF
54 8000 ????
55 8000 ???? ; Note: The address may be defined on the command-line using the -D switch, eg:
56 8000 ???? ; dasm.exe code.asm -DTIA_BASE_ADDRESS=$40 -f3 -v5 -ocode.bin
57 8000 ???? ; *OR* by declaring the label before including this file, eg:
58 8000 ???? ; TIA_BASE_ADDRESS = $40
59 8000 ???? ; include "vcs.h"
60 8000 ????
61 8000 ???? ; Alternate read/write address capability - allows for some disassembly compatibility
62 8000 ???? ; usage ; to allow reassembly to binary perfect copies). This is essentially catering
63 8000 ???? ; for the mirrored ROM hardware registers.
64 8000 ????
65 8000 ???? ; Usage: As per above, define the TIA_BASE_READ_ADDRESS and/or TIA_BASE_WRITE_ADDRESS
66 8000 ???? ; using the -D command-line switch, as required. If the addresses are not defined,
67 8000 ???? ; they defaut to the TIA_BASE_ADDRESS.
68 8000 ????
69 8000 ???? - IFNCONST TIA_BASE_READ_ADDRESS
70 8000 ???? -TIA_BASE_READ_ADDRESS = TIA_BASE_ADDRESS
71 8000 ???? ENDIF
72 8000 ????
73 8000 ???? - IFNCONST TIA_BASE_WRITE_ADDRESS
74 8000 ???? -TIA_BASE_WRITE_ADDRESS = TIA_BASE_ADDRESS
75 8000 ???? ENDIF
76 8000 ????
77 8000 ???? ;-------------------------------------------------------------------------------
78 8000 ????
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 ./sokoboo.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 ???? ; (atari2600@taswegian.com) 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 ./sokoboo.asm
41 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 (andrew@taswegian.com), Thomas Jentzsch (tjentzsch@yahoo.de).
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 xsegtime
89 0000 ???? {1} SET {2}-1
90 0000 ???? TEST_{1} = 1
91 0000 ???? ENDM
92 0000 ????
93 0000 ???? MAC segtime_c
94 0000 ???? {1} SET ({2}+32)/64 + 1
95 0000 ???? TEST_{1} = 0
96 0000 ???? ENDM
97 0000 ????
98 0000 ???? ;@TJ -- SIMPLY PUT AN X IN FRONT OF THE LINE(S) YOU WANT TO TEST
99 0000 ???? ; eg: XSEGTIME SEGTIME_BOX1,5
100 0000 ???? ; No other action required. All code enables/disables automatically.
101 0000 ????
102 0000 ???? ; 2012/02/11 -- experimental reduction in times (but not stress tested)
103 0000 ???? ; due to separation of timeslice overhead to separate check
104 0000 ????
0 0000 ???? SEGTIME_C SEGTIME_SCD_DIRECT, 355 ; @ 4/8/2019
1 0000 ???? SEGTIME_SCD_DIRECT SET (355+32)/64 + 1
2 0000 ???? 00 00 TEST_SEGTIME_SCD_DIRECT = 0
0 0000 ???? SEGTIME_C SEGTIME_SCD_QUICK, 386 ; @ 4/8/2019
1 0000 ???? SEGTIME_SCD_QUICK SET (386+32)/64 + 1
2 0000 ???? 00 00 TEST_SEGTIME_SCD_QUICK = 0
0 0000 ???? SEGTIME_C SEGTIME_SCD_SLOW, 651 ; @ 4/8/2019
1 0000 ???? SEGTIME_SCD_SLOW SET (651+32)/64 + 1
2 0000 ???? 00 00 TEST_SEGTIME_SCD_SLOW = 0
0 0000 ???? SEGTIME_C SEGTIME_SCD_PF0, 88 ; @ 4/8/2019 ??
1 0000 ???? SEGTIME_SCD_PF0 SET (88+32)/64 + 1
2 0000 ???? 00 00 TEST_SEGTIME_SCD_PF0 = 0
109 0000 ????
0 0000 ???? SEGTIME SEGTIME_SCD_MIN,SEGTIME_SCD_PF0+1 ; * MINIMUM TIME OF THE ABOVE + 1
1 0000 ???? SEGTIME_SCD_MIN SET SEGTIME_SCD_PF0+1
2 0000 ???? 00 00 TEST_SEGTIME_SCD_MIN = 0
111 0000 ????
112 0000 ???? - IF MULTI_BANK_BOARD = YES
113 0000 ???? - SEGTIME SEGTIME_BDF,42 +4 ; * 5/8/11 stress tested DHS->DS
114 0000 ???? ELSE
0 0000 ???? SEGTIME SEGTIME_BDF,38 ; glitches on 37 - 10/8/2019
1 0000 ???? SEGTIME_BDF SET 38
2 0000 ???? 00 00 TEST_SEGTIME_BDF = 0
116 0000 ???? ENDIF
117 0000 ????
0 0000 ???? SEGTIME SEGTIME_BDS, 2 ; *AD 11/8/11
1 0000 ???? SEGTIME_BDS SET 2
2 0000 ???? 00 00 TEST_SEGTIME_BDS = 0
0 0000 ???? SEGTIME_C SEGTIME_DSL, 125 ; * 9/8/11 unrolled once
1 0000 ???? SEGTIME_DSL SET (125+32)/64 + 1
2 0000 ???? 00 00 TEST_SEGTIME_DSL = 0
120 0000 ????
121 0000 ????
122 0000 ???? ;following will lock-up system if used as 'XSEGTIME'.
0 0000 ???? SEGTIME_C MINIMUM_SEGTIME, 87 ; processing slice minimum requirement
1 0000 ???? MINIMUM_SEGTIME SET (87+32)/64 + 1
2 0000 ???? 00 00 TEST_MINIMUM_SEGTIME = 0
0 0000 ???? SEGTIME SEGTIME_MINIMUM_TIMESLICE,MINIMUM_SEGTIME+1 ; MINIMUM of the TIMESLICE segments listed above
1 0000 ???? SEGTIME_MINIMUM_TIMESLICE SET MINIMUM_SEGTIME+1
2 0000 ???? 00 00 TEST_SEGTIME_MINIMUM_TIMESLICE = 0
125 0000 ????
126 0000 ???? ; Note: we add 1 to the minimum because there's a bit of overhead at the start of the timeslice code which vectors
127 0000 ???? ; to the appropriate timeslice. That timeslice then checks the segtime again -- and in the case of the minimum we
128 0000 ???? ; will already have used 55 cycles of the available timeslice to get to the segtime check. Given that there are only
129 0000 ???? ; 9 spare cycles in the 'unit' left, it's probably more efficient to abort earlier and save those 55 cycles for other
130 0000 ???? ; uses ...
131 0000 ????
132 0000 ????
133 0000 ???? ; The following timings have been physicaly timed via code/debugger... the comment shows the worst observed time.
134 0000 ???? ; Generally the allocated segtime should be a bit bigger than the worst observed, to cater for the minor code
135 0000 ???? ; outside the creature itself which might otherwise cause screen time over-run.
136 0000 ????
137 0000 ???? ; The following are NOT object-related and timing is a bit of manual guesswork/calculation
138 0000 ???? ; Comment may indicate at what value a glitch was DEFINITELY seen. These timings may not be optimal.
139 0000 ????
0 0000 ???? SEGTIME SEGTIME_MAN,10 ;24 ;<< using this as XSEGTIME stops player working ...?!
1 0000 ???? SEGTIME_MAN SET 10
2 0000 ???? 00 00 TEST_SEGTIME_MAN = 0
0 0000 ???? SEGTIME SEGTIME_CIRCLE, 10 ; drawing circle creature
1 0000 ???? SEGTIME_CIRCLE SET 10
2 0000 ???? 00 00 TEST_SEGTIME_CIRCLE = 0
0 0000 ???? SEGTIME SEGTIME_CIRCLE_HELPER, 10 ; drawing circle creature's helper
1 0000 ???? SEGTIME_CIRCLE_HELPER SET 10
2 0000 ???? 00 00 TEST_SEGTIME_CIRCLE_HELPER = 0
143 0000 ????
144 0000 ???? ; TJ: I should only prevent processes with an extra check (e.g. get TARGET)
145 0000 ????
146 0000 ???? ; push BOX is slowest (besides get TARGET which has an extra timer check)
147 0000 ???? ; if we add another check for it, SEGTIME_MAN reduces by ~5
148 0000 ????
0 0000 ???? SEGTIME_C SEGTIME_SWITCHOBJECTS,74 ; 16/8/11 by calculation. 72 cycles --> ceil(72/64)+1 --> 3 Object stack switchover
1 0000 ???? SEGTIME_SWITCHOBJECTS SET (74+32)/64 + 1
2 0000 ???? 00 00 TEST_SEGTIME_SWITCHOBJECTS = 0
------- FILE ./sokoboo.asm
43 0000 ????
44 0000 ???? ;FIXED_BANK = 3 * 2048 ;--> 8K ROM tested OK
45 0000 ???? ;FIXED_BANK = 7 * 2048 ;--> 16K ROM tested OK
46 0000 ???? 78 00 FIXED_BANK = 15 * 2048 ; ->> 32K
47 0000 ???? ;FIXED_BANK = 239 * 2048 ;--> 480K ROM tested OK (KK/CC2 compatibility)
48 0000 ???? ;FIXED_BANK = 127 * 2048 ;--> 256K ROM tested OK
49 0000 ???? ;FIXED_BANK = 255 * 2048 ;--> 512K ROM tested OK (CC2 can't handle this)
50 0000 ????
51 0000 ???? 00 01 YES = 1
52 0000 ???? 00 00 NO = 0
53 0000 ????
54 0000 ???? 00 00 DEBUG = NO
55 0000 ????
56 0000 ???? 00 00 TJ_MODE = NO ; some changes which TJ prefers
57 0000 ???? 00 01 AD_MODE = YES ; some changes which AD prefers
58 0000 ????
59 0000 ???? - IF TJ_MODE && AD_MODE
60 0000 ???? - ECHO "ERROR: Both TJ_MODE and AD_MODE set. Can't do both TJ and AD at the same time!"
61 0000 ???? - ERR
62 0000 ???? ENDIF
63 0000 ????
64 0000 ????
65 0000 ???? ; Note: you may also need to change the emulator "-format" switch in the Makefile.
66 0000 ????
67 0000 ????
68 0000 ???? ;===================================
69 0000 ???? 00 00 FINAL_VERSION = NO ; this OVERRIDES any selections below and sets everything correct for a final release
70 0000 ???? ;===================================
71 0000 ????
72 0000 ???? ;-------------------------------------------------------------------------------
73 0000 ???? ; The following should be YES for the final or DEMO version
74 0000 ???? EMBED_COPYRIGHT SET YES ; place embedded copyright notice in binary (hex string)
75 0000 ????
76 0000 ???? ;-------------------------------------------------------------------------------
77 0000 ???? ; The following are optional YES/NO depending on phase of the moon
78 0000 ???? L276 SET YES ; use 276 line display for NTSC
79 0000 ???? ;-------------------------------------------------------------------------------
80 0000 ????
81 0000 ???? 00 01 NUMPLAYERS = 1 ; 1-indexed
82 0000 ???? 00 05 NUM_LEVELS = 5
83 0000 ???? NUM_LIVES SET 3 ; use -1 for unlimited lives
84 0000 ????
85 0000 ???? ;-------------------------------------------------------------------------------
86 0000 ???? ; DO NOT MODIFY THE BELOW SETTINGS -- USE THE ONES ABOVE!
87 0000 ???? ; Here we make sure everyting is OK based on the single switch -- less chance for accidents
88 0000 ???? - IF FINAL_VERSION = YES
89 0000 ???? -L276 SET YES ; use 276 line display for NTSC
90 0000 ???? -
91 0000 ???? -NUM_LIVES SET 3 ; use -1 for unlimited lives
92 0000 ???? ENDIF
93 0000 ????
94 0000 ???? ;-------------------------------------------------------------------------------
95 0000 ????
96 0000 ???? 00 01 COMPILE_ILLEGALOPCODES = 1
97 0000 ???? 00 0c RESERVED_FOR_STACK = 12 ; bytes guaranteed not overwritten by variable use
98 0000 ????
99 0000 ????
100 0000 ???? 00 01 PUSH_LIMIT = 1 ; slowdown when pushing on a BOX
101 0000 ????
102 0000 ???? ; time bonus countdown constants:
103 0000 ???? 00 ff EXTRA_LIFE_TIMER = 255 ; Cosmic Ark star effect on extra life. Should be 5 seconds like in original
104 0000 ???? 00 3c SCORING_TIMER = 60 ; ~1.0 second
105 0000 ???? 00 96 SCORING_TIMER_FIRST = 150 ; begin level timer is long to show level/lives clearly
106 0000 ????
107 0000 ???? 00 07 DIRECTION_BITS = %111 ; for ManLastDirection
108 0000 ????
109 0000 ???? 00 03 FACE_LEFT = 3
110 0000 ????
111 0000 ???? 00 a0 MAX_THROTTLE = 160 ; must be small enough to allow ~2 * max add value overflow (<256 - 2*max throttle value!)
112 0000 ????
113 0000 ???? ;scoring flags contants:
114 0000 ???? 00 03 DISPLAY_FLAGS = %11
115 0000 ???? 00 00 DISPLAY_TIME = %00
116 0000 ???? 00 01 DISPLAY_SCORE = %01
117 0000 ???? 00 02 DISPLAY_LIVES = %10
118 0000 ???? 00 03 DISPLAY_HIGH = %11
119 0000 ????
120 0000 ???? ;------------------------------------------------------------------------------
121 0000 ????
122 0000 ???? 00 01 MIRRORED_BOX = YES
123 0000 ???? 00 01 MIRRORED_STEEL = YES
124 0000 ???? 00 01 MIRRORED_WALL = YES
125 0000 ????
126 0000 ???? 00 00 TROPHY = NO
127 0000 ???? 00 00 DIGITS = NO
128 0000 ???? 00 01 WAIT_FOR_INITIAL_DRAW = YES ; blank until all initial tiles drawn
129 0000 ????
130 0000 ???? ;------------------------------------------------------------------------------
131 0000 ????
132 0000 ???? 00 0a SCREEN_WIDTH = 10 ; board characters per line (DIFFICULT TO CHANGE)
133 0000 ????
134 0000 ???? 00 08 SCREEN_LINES = 8 ; number of scanlines in screen buffer
135 0000 ???? 00 18 LINES_PER_CHAR = 24 ; MULTIPLE OF 3 SO RGB INTERFACES CHARS OK
136 0000 ????
137 0000 ???? 00 50 SCREEN_ARRAY_SIZE = SCREEN_WIDTH * SCREEN_LINES
138 0000 ????
139 0000 ????
140 0000 ???? 00 3f SET_BANK = $3F ; write address to switch ROM banks
141 0000 ???? 00 3e SET_BANK_RAM = $3E ; write address to switch RAM banks
142 0000 ????
143 0000 ????
144 0000 ???? ; color constants:
145 0000 ???? 00 0e WHITE = $0e ; bright white, for NTSC and PAL
146 0000 ????
147 0000 ???? 00 10 YELLOW_NTSC = $10
148 0000 ???? 00 20 YELLOW_PAL = $20
149 0000 ????
150 0000 ????
151 0000 ???? 10 00 RAM_3E = $1000
152 0000 ???? 04 00 RAM_SIZE = $400
153 0000 ???? 04 00 RAM_WRITE = $400 ; add this to RAM address when doing writes
154 0000 ????
155 0000 ????
156 0000 ???? 00 b4 RND_EOR_VAL = $b4
157 0000 ????
158 0000 ????
159 0000 ???? ; Platform constants:
160 0000 ???? 00 02 PAL = %10
161 0000 ???? 00 02 PAL_50 = PAL|0
162 0000 ???? 00 03 PAL_60 = PAL|1
163 0000 ????
164 0000 ????
165 0000 ???? IF L276
166 0000 ???? 00 32 VBLANK_TIM_NTSC = 50 ; NTSC 276 (Desert Falcon does 280, so this should be pretty safe)
167 0000 ???? - ELSE
168 0000 ???? -VBLANK_TIM_NTSC = 50 ; NTSC 262
169 0000 ???? ENDIF
170 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)
171 0000 ????
172 0000 ???? IF L276
173 0000 ???? 00 22 OVERSCAN_TIM_NTSC = 34 ;24 ;51 ; NTSC 276 (Desert Falcon does 280, so this should be pretty safe)
174 0000 ???? - ELSE
175 0000 ???? -OVERSCAN_TIM_NTSC = 8 ;51 ; NTSC 262
176 0000 ???? ENDIF
177 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)
178 0000 ????
179 0000 ???? IF L276
180 0000 ???? 01 14 SCANLINES_NTSC = 276 ; NTSC 276 (Desert Falcon does 280, so this should be pretty safe)
181 0000 ???? - ELSE
182 0000 ???? -SCANLINES_NTSC = 262 ; NTSC 262
183 0000 ???? ENDIF
184 0000 ???? 01 38 SCANLINES_PAL = 312
185 0000 ????
186 0000 ????
187 0000 ???? ;------------------------------------------------------------------------------
188 0000 ???? ; MACRO definitions
189 0000 ????
190 0000 ???? 08 00 ROM_BANK_SIZE = $800
191 0000 ????
192 0000 ???? MAC newbank
193 0000 ???? SEG {1}
194 0000 ???? ORG ORIGIN
195 0000 ???? RORG $F000
196 0000 ???? BANK_START SET *
197 0000 ???? {1} SET ORIGIN / 2048
198 0000 ???? ORIGIN SET ORIGIN + 2048
199 0000 ???? _CURRENT_BANK SET {1}
200 0000 ???? ENDM ; bank name
201 0000 ????
202 0000 ???? MAC define_1k_segment
203 0000 ???? ALIGN $400
204 0000 ???? SEGMENT_{1} SET *
205 0000 ???? BANK_{1} SET _CURRENT_BANK
206 0000 ???? ENDM ; {seg name}
207 0000 ????
208 0000 ???? MAC check_bank_size
209 0000 ???? .TEMP = * - BANK_START
210 0000 ???? ECHO {1}, "(2K) SIZE = ", .TEMP, ", FREE=", ROM_BANK_SIZE - .TEMP
211 0000 ???? if ( .TEMP ) > ROM_BANK_SIZE
212 0000 ???? ECHO "BANK OVERFLOW @ ", * - ORIGIN
213 0000 ???? ERR
214 0000 ???? endif
215 0000 ???? ENDM ; name
216 0000 ????
217 0000 ????
218 0000 ???? MAC check_half_bank_size
219 0000 ???? ; This macro is for checking the first 1K of ROM bank data that is to be copied to RAM.
220 0000 ???? ; Note that these ROM banks can contain 2K, so this macro will generally go 'halfway'
221 0000 ???? .TEMP = * - BANK_START
222 0000 ???? ECHO {1}, "(1K) SIZE = ", .TEMP, ", FREE=", ROM_BANK_SIZE/2 - .TEMP
223 0000 ???? if ( .TEMP ) > ROM_BANK_SIZE/2
224 0000 ???? ECHO "HALF-BANK OVERFLOW @ ", * - ORIGIN
225 0000 ???? ERR
226 0000 ???? endif
227 0000 ???? ENDM ; name
228 0000 ????
229 0000 ????
230 0000 ???? MAC overlay
231 0000 ???? SEG.U OVERLAY_{1}
232 0000 ???? org Overlay
233 0000 ???? ENDM ; {name}
234 0000 ????
235 0000 ???? ;--------------------------------------------------------------------------
236 0000 ????
237 0000 ???? MAC validate_overlay
238 0000 ???? LIST OFF
239 0000 ???? if * - Overlay > OVERLAY_SIZE
240 0000 ???? ERR
241 0000 ???? endif
242 0000 ???? LIST ON
243 0000 ???? ENDM
244 0000 ????
245 0000 ???? ;--------------------------------------------------------------------------
246 0000 ???? ; Macro inserts a page break if the object would overlap a page
247 0000 ????
248 0000 ???? MAC optional_pagebreak
249 0000 ???? LIST OFF
250 0000 ???? IF (>( * + {2} -1 )) > ( >* )
251 0000 ???? EARLY_LOCATION SET *
252 0000 ???? ALIGN 256
253 0000 ???? ECHO "PAGE BREAK INSERTED FOR ", {1}
254 0000 ???? ECHO "REQUESTED SIZE = ", {2}
255 0000 ???? ECHO "WASTED SPACE = ", *-EARLY_LOCATION
256 0000 ???? ECHO "PAGEBREAK LOCATION = ", *
257 0000 ???? ENDIF
258 0000 ???? LIST ON
259 0000 ???? ENDM ; { string, size }
260 0000 ????
261 0000 ????
262 0000 ???? MAC check_page_crossing
263 0000 ???? LIST OFF
264 0000 ???? if ( >BLOCK_END != >BLOCK_START )
265 0000 ???? ECHO "PAGE CROSSING @ ", BLOCK_START
266 0000 ???? endif
267 0000 ???? LIST ON
268 0000 ???? ENDM
269 0000 ????
270 0000 ???? MAC checkpage
271 0000 ???? LIST OFF
272 0000 ???? IF >. != >{1}
273 0000 ???? ECHO ""
274 0000 ???? ECHO "ERROR: different pages! (", {1}, ",", ., ")"
275 0000 ???? ECHO ""
276 0000 ???? ERR
277 0000 ???? ENDIF
278 0000 ???? LIST ON
279 0000 ???? ENDM
280 0000 ????
281 0000 ???? MAC checkpagex
282 0000 ???? LIST OFF
283 0000 ???? IF >. != >{1}
284 0000 ???? ECHO ""
285 0000 ???? ECHO "ERROR: different pages! (", {1}, ",", ., ") @ {0}"
286 0000 ???? ECHO {2}
287 0000 ???? ECHO ""
288 0000 ???? ERR
289 0000 ???? ENDIF
290 0000 ???? LIST ON
291 0000 ???? ENDM
292 0000 ????
293 0000 ????
294 0000 ???? MAC checkpage_bne
295 0000 ???? LIST OFF
296 0000 ???? IF 0 ;>(. + 2) != >{1}
297 0000 ???? ECHO ""
298 0000 ???? ECHO "ERROR: different pages! (", {1}, ",", ., ")"
299 0000 ???? ECHO ""
300 0000 ???? ERR
301 0000 ???? ENDIF
302 0000 ???? LIST ON
303 0000 ???? bne {1}
304 0000 ???? ENDM
305 0000 ????
306 0000 ???? MAC checkpage_bpl
307 0000 ???? LIST OFF
308 0000 ???? IF (>(.+2 )) != >{1}
309 0000 ???? ECHO ""
310 0000 ???? ECHO "ERROR: different pages! (", {1}, ",", ., ")"
311 0000 ???? ECHO ""
312 0000 ???? ERR
313 0000 ???? ENDIF
314 0000 ???? LIST ON
315 0000 ???? bpl {1}
316 0000 ???? ENDM
317 0000 ????
318 0000 ???? MAC align_free
319 0000 ???? FREE SET FREE - .
320 0000 ???? align {1}
321 0000 ???? FREE SET FREE + .
322 0000 ???? echo "@", ., ":", FREE
323 0000 ???? ENDM
324 0000 ????
325 0000 ???? MAC stress_time
326 0000 ???? IF TEST_{1} = 1
327 0000 ????
328 0000 ????
329 0000 ???? ;LIST OFF
330 0000 ???? ; has to be put *directly* after cmp #SEGTIME_... , bcc abort
331 0000 ???? ;LIST ON
332 0000 ???? echo "***** WARNING! STRESS_TIME enabled @", ., "! *****"
333 0000 ???? bne . - 7 ; branches to lda INTIM
334 0000 ???? ENDIF
335 0000 ???? ENDM
336 0000 ????
337 0000 ???? IDENTITY SET 0
338 0000 ???? MAC ident
339 0000 ???? if DEBUG=YES
340 0000 ???? lda #IDENTITY
341 0000 ???? sta debug_ident
342 0000 ???? lda {1}
343 0000 ???? sta debug_object
344 0000 ???? endif
345 0000 ???? IDENTITY SET IDENTITY + 1
346 0000 ???? ENDM ; {object}
347 0000 ????
348 0000 ???? ;--------------------------------------------------------------------------
349 0000 ????
350 0000 ???? MAC vector
351 0000 ???? .word {1}
352 0000 ???? ENDM ; just a word pointer to code
353 0000 ????
354 0000 ????
355 0000 ???? MAC define_subroutine
356 0000 ???? BANK_{1} = _CURRENT_BANK ; bank in which this subroutine resides
357 0000 ???? SUBROUTINE ; keep everything local
358 0000 ???? {1} ; entry point
359 0000 ???? ENDM ; name of subroutine
360 0000 ????
361 0000 ????
362 0000 ????
363 0000 ???? ;--------------------------------------------------------------------------
364 0000 ????
365 0000 ???? MAC newrambank
366 0000 ???? SEG.U {1}
367 0000 ???? ORG ORIGIN
368 0000 ???? RORG RAM_3E
369 0000 ???? BANK_START SET *
370 0000 ???? {1} SET ORIGIN / RAM_SIZE
371 0000 ???? ORIGIN SET ORIGIN + RAM_SIZE
372 0000 ???? ENDM ; bank name
373 0000 ????
374 0000 ???? MAC validate_ram_size
375 0000 ???? if * - RAM_3E > RAM_SIZE
376 0000 ???? ERR
377 0000 ???? endif
378 0000 ???? ENDM
379 0000 ????
380 0000 ???? MAC next_random
381 0000 ???? ; update random value:
382 0000 ???? lda rnd ; 3
383 0000 ???? lsr ; 2
384 0000 ???? IFCONST rndHi
385 0000 ???? ror rndHi ; 5 16 bit LFSR
386 0000 ???? ENDIF
387 0000 ???? bcc .skipEOR ; 2/3
388 0000 ???? eor #RND_EOR_VAL ; 2
389 0000 ???? .skipEOR
390 0000 ???? sta rnd ; 3 = 14/19
391 0000 ???? ENDM
392 0000 ????
393 0000 ???? MAC resync
394 0000 ???? ; resync screen, X and Y == 0 afterwards
395 0000 ???? lda #%10 ; make sure VBLANK is ON
396 0000 ???? sta VBLANK
397 0000 ????
398 0000 ???? ldx #8 ; 5 or more RESYNC_FRAMES
399 0000 ???? .loopResync
400 0000 ???? VERTICAL_SYNC
401 0000 ????
402 0000 ???? ldy #SCANLINES_NTSC/2 - 2
403 0000 ???? lda Platform
404 0000 ???? eor #PAL_50 ; PAL-50?
405 0000 ???? bne .ntsc
406 0000 ???? ldy #SCANLINES_PAL/2 - 2
407 0000 ???? .ntsc
408 0000 ???? .loopWait
409 0000 ???? sta WSYNC
410 0000 ???? sta WSYNC
411 0000 ???? dey
412 0000 ???? bne .loopWait
413 0000 ???? dex
414 0000 ???? bne .loopResync
415 0000 ???? ENDM
416 0000 ????
417 0000 ???? MAC set_platform
418 0000 ???? ; 00 = NTSC
419 0000 ???? ; 01 = NTSC
420 0000 ???? ; 10 = PAL-50
421 0000 ???? ; 11 = PAL-60
422 0000 ???? lda SWCHB
423 0000 ???? rol
424 0000 ???? rol
425 0000 ???? rol
426 0000 ???? and #%11
427 0000 ???? eor #PAL
428 0000 ???? sta Platform ; P1 difficulty --> TV system (0=NTSC, 1=PAL)
429 0000 ???? ENDM
430 0000 ????
431 0000 ???? ; IF TJ_MODE
432 0000 ???? ; MAC GET_RAM_BYTE_FROM_RAM ; = 29
433 0000 ???? ; ldy #{1} ; 2 read bank
434 0000 ???? ; ldx #{2} ; 2 return bank
435 0000 ???? ; jsr GetRAMByteFromRAM ;25
436 0000 ???? ; ENDM
437 0000 ???? ;
438 0000 ???? ; MAC PUT_RAM_BYTE_FROM_RAM ; = 30
439 0000 ???? ; ldy #{1} ; 2 write bank
440 0000 ???? ; ldx #{2} ; 2 return bank
441 0000 ???? ; jsr PutRAMByteFromRAM ;26
442 0000 ???? ; ENDM
443 0000 ???? ;
444 0000 ???? ; MAC GET_RAM_BYTE_FROM_RAM_ADR ; = 39
445 0000 ???? ; ldx #<{1} ; 2
446 0000 ???? ; stx addressR ; 3
447 0000 ???? ; ldx #>{1} ; 2
448 0000 ???? ; stx addressR+1 ; 3
449 0000 ???? ; GET_RAM_BYTE_FROM_RAM {2}, {3} ;29
450 0000 ???? ; ENDM
451 0000 ???? ;
452 0000 ???? ; MAC PUT_RAM_BYTE_FROM_RAM_ADR ; = 40
453 0000 ???? ; ldx #<{1} ; 2
454 0000 ???? ; stx addressW ; 3