-
Notifications
You must be signed in to change notification settings - Fork 0
/
tempest.a65
21518 lines (18370 loc) · 431 KB
/
tempest.a65
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
.feature leading_dot_in_identifiers
.localchar '?'
.linecont +
;
; Most of this is derived from:
;
; http://www.ionpool.net/arcade/tempest_code_project/136002.txt
; and
; http://216.46.5.1:18804/
;
;
; From ionpool:
;
; ; Tempest Source Code
; ; -------------------
; ; The actual code is Copyright 1981 by Atari.
; ; Documentation is Copyright 1999 by Arcade Gameshop Corporation.
; ; All rights reserved. Additional rights granted through OpenContent
; ; License. See http://arcade.gameshop.com/opl.html
; ;
; ; No warranty or fitness for particular purpose expressed or implied.
; ;
; ; Updated 09/17/2004 by Josh McCormick
; ;
; ; Contributors:
; ; -------------
; ; Josh McCormick - Project lead and main documentarian.
; ; (http://www.galstar.com/~jmccorm)
; ; Clay Cowgill - EAROM programming example, Vector ROM image list,
; ; MAME programming tips (http://www.multigame.com)
; ; Ken Lui - Documentation of data segments on V1 roms.
; ; Provided a much better assembler/disassembler package.
; ; (http://www.ecst.csuchico.edu/~tempest)
;
; From rodents.montreal.qc.ca
;
; ; There is doubtless much that is wrong or missing here. If you can help
; ; supply any missing bits, or correct anything wrong, please feel free to
; ; write me: mouse@rodents.montreal.qc.ca.
;
; 11Dec11 cac
; In selftest, an "M" appears
; From "Tempest Detailed theory of operation.html",
;
; The [...] 4 socketed 40-pin chips on the math box (at locations E2, F/H2,
; J2 and K/L2 on Tempest) are called "transistor array"s by the manual and
; the chips themselves carry only the Atari part number 137004-001 on them
; in an attempt to hide their true identity (to keep people from making
; illegal copies of the game?) They are really 2901 bit-slice ALUs, which
; were very popular and are fairly commonly available. They were made by
; AMD and a number of other vendors. In a technical sense the part really
; is a transistor array, but calling it that serves no purpose other than
; obfuscation. These go bad every now and then and will generate an "M" on
; the self-test screen. NOTE: the "M" is a generic "M"ath box failure
; indicator and does not necessarily indicate that an ALU is bad; lots of
; failures cause the "M" indicator to appear but one of the most frequent
; causes is bad ALUs (Note: The most frequent cause I've seen is the
; interboard cable failing. Check that first, as it's a lot easier to
; fix -- Nick).
;
; During self test screen 1, the code does a 24 bit divide on 16 bit
; numbers [0/0, 1/1, 2/2, ... ffff/ffff], compares the sign of the
; result to the factors. This works up til $8000, at which point
; a M error is diagnosed. I do not know if this is expected behavior,
; or a bug in the math box code.
;
; The test code changed in version 2, and no longer displays this
; behavior, so I assume that this was a bug in the test code.
;
;
; Copy detection.
; The vector generation character font defined here draws identical
; images for "0" (zero) and "O" (oh). Some of the strings use
; the syntactically incorrect character (spelling "foo" as eff zero
; zero). I would guess that this is deliberate, allowing the
; detection of copied code.
;
; From MAME tempest.c
;
; HEX R/W D7 D6 D5 D4 D3 D2 D2 D0 function
; 0000-07FF R/W D D D D D D D D program ram (2K)
; 0800-080F W D D D D Colour ram
;
; 0C00 R D Right coin sw
; 0C00 R D Center coin sw
; 0C00 R D Left coin sw
; 0C00 R D Slam sw
; 0C00 R D Self test sw
; 0C00 R D Diagnostic step sw
; 0C00 R D Halt
; 0C00 R D 3kHz ??
; 0D00 R D D D D D D D D option switches
; 0E00 R D D D D D D D D option switches
;
; 2000-2FFF R/W D D D D D D D D Vector Ram (4K)
; 3000-3FFF R D D D D D D D D Vector Rom (4K)
;
; 4000 W D Right coin counter
; 4000 W D left coin counter
; 4000 W D Video invert - x
; 4000 W D Video invert - y
; 4800 W Vector generator GO
;
; 5000 W WD clear
; 5800 W Vect gen reset
;
; 6000-603F W D D D D D D D D EAROM write
; 6040 W D D D D D D D D EAROM control
; 6040 R D Mathbox status
; 6050 R D D D D D D D D EAROM read
;
; 6060 R D D D D D D D D Mathbox read
; 6070 R D D D D D D D D Mathbox read
; 6080-609F W D D D D D D D D Mathbox start
;
; 60C0-60CF R/W D D D D D D D D Custom audio chip 1
; 60D0-60DF R/W D D D D D D D D Custom audio chip 2
;
; 60E0 R D one player start LED
; 60E0 R D two player start LED
; 60E0 R D FLIP
;
; 9000-DFFF R D D D D D D D D Program ROM (20K)
;
; notes: program ram decode may be incorrect, but it appears like
; this on the schematics, and the troubleshooting guide.
;
; ZAP1, FIRE1, FIRE2, ZAP2 go to pokey2, bits 3 and 4
; (depending on state of FLIP)
; player1 start, player2 start are pokey2, bits 5 and 6
;
; encoder wheel goes to pokey1 bits 0-3
; pokey1, bit4 is cocktail detect
;
; TEMPEST SWITCH SETTINGS (Atari, 1980)
; -------------------------------------
;
;
; GAME OPTIONS:
; (8-position switch at L12 on Analog Vector-Generator PCB)
;
; 1 2 3 4 5 6 7 8 Meaning
; -------------------------------------------------------------------------
; Off Off 2 lives per game
; On On 3 lives per game
; On Off 4 lives per game
; Off On 5 lives per game
; On On Off Bonus life every 10000 pts
; On On On Bonus life every 20000 pts
; On Off On Bonus life every 30000 pts
; On Off Off Bonus life every 40000 pts
; Off On On Bonus life every 50000 pts
; Off On Off Bonus life every 60000 pts
; Off Off On Bonus life every 70000 pts
; Off Off Off No bonus lives
; On On English
; On Off French
; Off On German
; Off Off Spanish
; On 1-credit minimum
; Off 2-credit minimum
;
; GAME OPTIONS:
; (4-position switch at D/E2 on Math Box PCB)
;
; 1 2 3 4 Meaning
; -------------------------------------------------------------------------
; Off Minimum rating range: 1, 3, 5, 7, 9
; On Minimum rating range tied to high score
; Off Off Medium difficulty (see notes)
; Off On Easy difficulty (see notes)
; On Off Hard difficulty (see notes)
; On On Medium difficulty (see notes)
;
; PRICING OPTIONS:
; (8-position switch at N13 on Analog Vector-Generator PCB)
;
; 1 2 3 4 5 6 7 8 Meaning
; -------------------------------------------------------------------------
; On On On No bonus coins
; On On Off For every 2 coins, game adds 1 more coin
; On Off On For every 4 coins, game adds 1 more coin
; On Off Off For every 4 coins, game adds 2 more coins
; Off On On For every 5 coins, game adds 1 more coin
; Off On Off For every 3 coins, game adds 1 more coin
; On Off Off On Demonstration Mode (see notes)
; Off Off Off On Demonstration-Freeze Mode (see notes)
; On Left coin mech * 1
; Off Left coin mech * 2
; On On Right coin mech * 1
; On Off Right coin mech * 4
; Off On Right coin mech * 5
; Off Off Right coin mech * 6
; Off On Free Play
; Off Off 1 coin 2 plays
; On On 1 coin 1 play
; On Off 2 coins 1 play
;
;
; GAME SETTING NOTES:
; -------------------
;
; Demonstration Mode:
; - Plays a normal game of Tempest, but pressing SUPERZAP sends you
; directly to the next level.
;
; Demonstration-Freeze Mode:
; - Just like Demonstration Mode, but with frozen screen action.
;
; Both Demonstration Modes:
; - Pressing RESET in either mode will cause the game to lock up.
; To recover, set switch 1 to On.
; - You can start at any level from 1..81, so it's an easy way of
; seeing what the game can throw at you
; - The score is zeroed at the end of the game, so you also don't
; have to worry about artificially high scores disrupting your
; scoring records as stored in the game's EAROM.
;
; Easy Difficulty:
; - Enemies move more slowly
; - One less enemy shot on the screen at any given time
;
; Hard Difficulty:
; - Enemies move more quickly
; - 1-4 more enemy shots on the screen at any given time
; - One more enemy may be on the screen at any given time
;
; High Scores:
; - Changing toggles 1-5 at L12 (more/fewer lives, bonus ship levels)
; will erase the high score table.
; - You should also wait 8-10 seconds after a game has been played
; before entering self-test mode or powering down; otherwise, you
; might erase or corrupt the high score table.
;
;
; From 136002.txt
; Tempest Source Code
; -------------------
; The actual code is Copyright 1981 by Atari.
; Documentation is Copyright 1999 by Arcade Gameshop Corporation.
; All rights reserved. Additional rights granted through OpenContent
; License. See http://arcade.gameshop.com/opl.html
;
; No warranty or fitness for particular purpose expressed or implied.
;
; Updated 09/17/2004 by Josh McCormick
;
; Contributors:
; -------------
; Josh McCormick - Project lead and main documentarian.
; (http://www.galstar.com/~jmccorm)
; Clay Cowgill - EAROM programming example, Vector ROM image list,
; MAME programming tips (http://www.multigame.com)
; Ken Lui - Documentation of data segments on V1 roms.
; Provided a much better assembler/disassembler package.
; (http://www.ecst.csuchico.edu/~tempest)
;
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Coding conventions
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Identifiers starting with "_" are offets, indicies or enumerations
; Label notation
;
; vg_sub_..... Vector generator subroutine
; vg_sub_char_X VG sub to draw character "X"
; vg_sub_image_X VG sub to draw image "X"
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Constants
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
n_segments_per_tunnel = 16
n_pending_enemies = 64
n_enemies_on_screen = 7
n_player_bullets = 8
n_enemy_bullets = 4
n_levels = 99
curlevel_red = 17
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Pokey
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
_pokey_nchans = 8
;;;
;;; Pokey 1 register addresses
;;;
pokey1 = $60c0
; Audio ports - WO
pokey1_audf1 = $60c0
pokey1_audc1 = $60c1
pokey1_audf2 = $60c2
pokey1_audc2 = $60c3
pokey1_audf3 = $60c4
pokey1_audc3 = $60c5
pokey1_audctl = $60c8 ; W/O
; Control - WO
pokey1_rescan = $60cb
pokey1_skctls = $60cf
; Data for skctls
; $01 15KHz clock base
; $02 High pass filter into channel 2, clocked by channel 4
; $04 High pass filter into channel 1, clocked by channel 3
pokey_skctls_setup = $07
; Inputs - RO
; The encoder wheel output is a pair of sine waves (square waves will work
; too) 90 degrees out of phase. The direction of the phase shift indicates
; which direction the control is being turned. If the knob seems to be
; operating backwards, swap the two outputs. The 4 inputs (potentially from
; two knobs) are squared off by E6. D6 then selects which pair to use. C6 is
; used to convert the two out of phase square waves into a simple clock and
; direction signal (note that in doing so it introduces an error. The first
; "click" in the opposite direction from the last movement may register as a
; click in the wrong direction. Fortunately, the knob is very sensitive and
; the software reduces the sensitivity so that this error is lost as noise).
; This is fed into an up/down nibble counter, which forms 4 inputs to POKEY
; #1. FIRE and ZAP go to POKEY #2 (again, after being chosen with D6). The
; 1- and 2-player start buttons, DIP switches at D/E2, and the cocktail
; signal all go to the POKEYs, thusly:
;
pokey1_spinner_cabtyp = $60c8 ; R/O
; BITS 0-3: Encoder Wheel $0f
; BIT 4 : Cocktail detection $10
; BIT 5 : Switch #1 at D/E2 $20
; BITS 6-7: Unused.
;
; BIT 5/Switch#1 is Marked "unused" in the service manual, and although the
; get_diff_bits routine collects this bit and saves it in diff_bits, it
; does not appear to be tested in the code.
_pokey1_encoder_mask = $0f
_pokey1_cocktail_mask = $10
_pokey1_unused_mask = $20
pokey1_rand = $60ca
; Fout = 15.6999 KHz / (audf + 7)
;;;
;;; Pokey 2 register addresses
;;;
pokey2 = $60d0
; Audio ports - WO
pokey2_audf1 = $60d0
pokey2_audc1 = $60d1
pokey2_audctl = $60d8 ; W/O
; Control - WO
pokey2_rescan = $60db
pokey2_skctls = $60df
; Inputs - RO
pokey2_zap_fire_starts = $60d8 ; R/O
; Switch D/E2, switch #2 -> pokey 2 bit 2
; #3 -> pokey 2 bit 1
; #4 -> pokey 2 bit 0
; $03 = Difficulty
; $00 = Medium
; $01 = Easy
; $02 = Hard
; $03 = Medium
; $04 = Rating
; $00 = 1, 3, 5, 7, 9
; $04 = tied to high score
;
; $08 = zap button
; $10 = fire button
; $20 = 1p start button
; $40 = 2p start button
; $80 = unknown (nothing?)
_pokey2_sw_diff_mask = $03
_pokey2_sw_diff_val_easy = $01
_pokey2_sw_diff_val_medium1 = $00
_pokey2_sw_diff_val_medium2 = $03
_pokey2_sw_diff_val_hard = $02
_pokey2_btn_rating_mask = $04
_pokey2_btn_zap_mask = $08
_pokey2_btn_fire_mask = $10
_pokey2_btn_start1p_mask = $20
_pokey2_btn_start2p_mask = $40
pokey2_rand = $60da
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Other h/w registers
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Register @ 4000
;;;
vid_coins = $4000
; 01 Right coin counter
; 02 center coin counter
; 04 left coind counter
; 08 invert X
; 10 invert Y
_vid_coins_invert_x_mask = $08
_vid_coins_invert_y_mask = $10
;;;
;;; Register @ 60e0
;;;
; The FLIP signal obtained from the coin counter register is used to feed D6,
; which is used as a player 1/player 2 control arbitrator. If the cocktail
; signal is grounded (POKEY 1, P4), then the program will assert the X and Y
; invert signals and FLIP whenever it's player #2's turn in a 2 player game.
;
leds_flip = $60e0
; Read Write
; bit $01 One player start / 1 player start LED
; bit $02 two player start / 2 player start LED
; bit $04 use 2 player controls on cocktail games
; / flip player start
; bit $08 SAEN 2, 3 (a debugging signal on the small connector on the aux board)
; Write bits
_leds_flip_1p_led_val = $01
_leds_flip_2p_lev_val = $02
_leds_flip_alt_cntrls = $04
_leds_flip_alt_mask = $04
_legs_flip_debug = $08
;;;
;;; Switch register @ 0c00
;;;
cabsw = $0c00
; $01 = right coin switch
; $02 = middle coin switch
; $04 = left coin switch (not used in arcade Tempest, I think)
; $08 = slam switch
; $10 = service switch
; $20 = diagnostic step switch
; $40 = halt bit from vector processor
; $80 = 3KHz square wave
_cabsw_r_coin_sw_mask = $01
_cabsw_m_coin_sw_mask = $02
_cabsw_l_coin_sw_mask = $04
_cabsw_slam_sw_mask = $08
_cabsw_service_sw_mask = $10
_cabsw_diag_sw_mask = $20
_cabsw_vg_halt_mask = $40
_cabsw_3khz_mask = $80
;;;
;;; Switch register @ 0d00
;;;
optsw1 = $0d00 ; DIP switch N13
; $03 = coinage
; $00 = 1 coin 1 credit
; $01 = 2 coins 1 credit
; $02 = free play
; $03 = 1 coin 2 credits
; $0c = right coin multiplier
; $00 = x1
; $04 = x4
; $08 = x5
; $0c = x6
; $10 = middle ("left") coin multiplier
; $00 = x1
; $10 = x2
; $e0 = bonus coins
; $00 = none
; $20 = 1 each 2
; $40 = 1 each 4
; $60 = 2 each 4
; $80 = 1 each 5
; $a0 = 1 each 3
; $c0 = demo mode
; $e0 = demo mode freeze
_optsw1_coinage_mask = $03
_optsw1_r_coin_mult_mask = $0c
_optsw1_l_coin_mult_mask = $10
_optsw1_bonus_coins_mask = $e0
_optsw1_coinage_val_freeplay = $02
_optsw1_bonus_coins_val_1each5 = $80
; This is used in main loop for some odd test
_optsw1_special_mask = $80
;;;
;;; Switch register @ 0e00
;;;
optsw2 = $0e00 ; DIP Switch L12
; $01 = minimum
; $00 = 1 credit minimum
; $01 = 2 credit minimum
; $06 = language
; $00 = English
; $02 = French
; $04 = German
; $06 = Spanish
; $38 = points needed per bonus life
; $00 = 20000
; $08 = 10000
; $10 = 30000
; $18 = 40000
; $20 = 50000
; $28 = 60000
; $30 = 70000
; $38 = none
; $c0 = initial lives
; $00 = 3
; $40 = 4
; $80 = 5
; $c0 = 2
_optsw2_min_mask = $01
_optsw2_lang_mask = $06
_optsw2_pts_needed_mask = $38
_optsw2_init_lives_mask = $c0
;;;
;;; Watchdog
;;;
; The watchdog is comprised of counter D4, which is fed from the 3 kHz
; source. D4 divides the signal by 256, which means that a properly running
; program must access location 5000 at least once every 80 msec or so in
; order to avoid being reset.
watchdog = $5000
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Math board
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mb_status_rd = $6040
mb_rd_l = $6060 ; mathbox read
mb_rd_h = $6070 ; mathbox read
mb_w_00 = $6080 ; 6080-609f mathbox
mb_set_00_l = mb_w_00 + $00
mb_set_00_h = mb_w_00 + $01
mb_set_01_l = mb_w_00 + $02
mb_set_01_h = mb_w_00 + $03
mb_set_02_l = mb_w_00 + $04
mb_set_02_h = mb_w_00 + $05
mb_set_03_l = mb_w_00 + $06
mb_set_03_h = mb_w_00 + $07
mb_set_04_l = mb_w_00 + $08
mb_set_04_h = mb_w_00 + $09
mb_set_05_l = mb_w_00 + $0a
mb_cmd_0b = mb_w_00 + $0b
mb_set_06_l = mb_w_00 + $0c
mb_set_10_l = mb_w_00 + $0d
mb_set_10_h = mb_w_00 + $0e
mb_set_11_l = mb_w_00 + $0f
mb_set_11_h = mb_w_00 + $10
mb_cmd_11 = mb_w_00 + $11
mb_cmd_12 = mb_w_00 + $12
mb_cmd_13 = mb_w_00 + $13
mb_cmd_14 = mb_w_00 + $14
mb_set_07_l = mb_w_00 + $15
mb_set_07_h = mb_w_00 + $16
mb_get_07 = mb_w_00 + $17
mb_get_09 = mb_w_00 + $18
mb_get_08 = mb_w_00 + $19
mb_set_08_l = mb_w_00 + $1a
mb_set_08_h = mb_w_00 + $1b
mb_cmd_1c = mb_w_00 + $1c
mb_cmd_1d = mb_w_00 + $1d
mb_cmd_1e = mb_w_00 + $1e
mb_cmd_selftest = mb_w_00 + $1f
; mb divide command usage
;
mb_set_divisor_l = mb_set_07_l
mb_set_divisor_h = mb_set_07_h
mb_set_divide_width = mb_set_06_l
mb_set_dividend_l = mb_set_10_l
mb_set_dividend_m = mb_set_10_h
mb_set_dividend_h = mb_set_11_l
mb_cmd_divide = mb_cmd_14
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; EAROM
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; EEPROM
;
; The EEPROM is a 64x8 one. It requires a -25 volt erase power supply,
; which is supplied by K3 and its associated cirtuitry.
; Any write to the EEPROM Write area (6000-603F) latches the address pins for
; the EEPROM. So a do-nothing write must take place before you can read a
; location within the EEPROM.
;
; Reading the EEPROM read register gates the EEPROM data pins onto the bus.
; It will also gate the write register if it is not disabled with the correct
; settings of the control register.
;
; The bottom 4 bits of the control register location are latched by J3. The
; outputs of J3 go to the control pins of the EEPROM.
;
; Unfortunately, I can find no data on the EEPROM chip they used, so I can't
; divine how the control signals are used.
;
; cac - It is a ER2055 "512 bit Electrically Alterable Read Only Memory
; From the schematic, the wiring to earom_ctrl is:
;
; Bit 0: CLK
; 1: C2
; 2: !C1
; 3: CS1
;
earom_write = $6000 ; EEPROM write
earom_ctrl = $6040 ; EEPROM control WO
_earom_ctrl_cs1 = $08
_earom_ctrl_not_c1 = $04
_earom_ctrl_c2 = $02
_earom_ctrl_clk = $01
_earom_ctrl_rd = _earom_ctrl_cs1 ; CS1 | C1
_earom_ctrl_rdclk = _earom_ctrl_cs1 | \
_earom_ctrl_clk ; CS1 | C1 | CLK
_earom_ctrl_er = _earom_ctrl_cs1 | \
_earom_ctrl_not_c1 | \
_earom_ctrl_c2 ; CS1 | C2
_earom_ctrl_wr = _earom_ctrl_cs1 | \
_earom_ctrl_not_c1 ; CS1
earom_rd = $6050 ; EEPROM read
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Common macros
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Building jump tables
;;;
.macro .jump addr
.word addr - 1
.endmac
; ".jump nowhere" generates ".word 0"
nowhere = 1
;;;
;;; Loading a 16 bit address
;;;
; ldax_me - lda highbyte, ldx lowbyte
.macro ldax_me addr
lda addr + 1
ldx addr
.endmac
; ldax_im - lda #highbyte, ldx #lowbyte
.macro ldax_im addr
lda #>(addr)
ldx #<(addr)
.endmac
; ldax_my - lda highbyte, ldx lowbyte from zeropage, y
.macro ldax_my addr
lda addr + 1, y
ldx addr, y
.endmac
;;;
;;; tail - mark tail recursion, a subroutine returns a jumping into a
;;; different subroutine
.macro tail addr
jmp addr
.endmac
;;;
;;; .fall - mark a fall through
;;;
.macro .fall addr
.ifdef pass1_done
.if addr <> *
.error ".fall fail"
.endif
.endif
.endmac
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Code layout and analysis
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; There is doubtless much that is wrong or missing here. If you can help
; supply any missing bits, or correct anything wrong, please feel free to
; write me: mouse@rodents.montreal.qc.ca.
;
; General game state. Whether we're running in selftest is not recorded
; here, so each value here has two interpretations, depending on whether
; we're in selftest.
;
; In selftest:
; $02 = first selftest screen (config bits, spinner line)
; $04 = second selftest screen (diagonal grid, line of characters)
; $06 = third selftest screen (crosshair, shrinking rectangle)
; $08 = fourth selftest screen (coloured lines)
; $0a = fifth selftest screen, grid with colour depending on spinner
; $0c = sixth selftest screen, blank rectangle
;
; Not in selftest (see table at Lc7da):
; $00 = entered briefly at game startup
; $02 = entered briefly at the beginning of first level of a game
; $04 = playing (including attract mode) "PRESS START" blinking
; $06 = entered briefly on player death (game-ending or not)
; $08 = set briefly at the beginning of each level?
; $0a = high-score, logo screen, AVOID SPIKES (etc?)
; AVOID SPIKES: $1e->$04, $0a->game_state, $20->$02, $80->$0123
; $0c = unused? (jump table holds $0000)
; $0e = entered briefly when zooming off the end of a level
; $10 = countdown; next state in next_game_state
; $12 = entering initials
; $14 = logo zoom
; $16 = starting level selection screen
; $18 = zooming new level in
; $1a = unknown
; $1c = unknown
; $1e = unknown
; $20 = descending down tube at level end
; $22 = non-selftest service mode display
; $24 = high-score explosion
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Page zero
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.org 0
page0 = *
;
; game_state
;
game_state: .res 1
; game_state values for self test mode
test_state_diag_grid = 4
;
; observed behavior:
; state 04 mode 0 pregame, simulated battle, "press start" blinking
; 20
; 0a
; 20
; 0e
; 18
; 08
; 14
; 0a
; 0a high scores
; 1a
; 0a
; 12
; 14 logo zoom
; 00
; 02
; 00 pregame
; 1e
; 0a
; 04
; Normal usage
;
; game mode
;
game_mode: .res 1
; Memory test routines overload addrs 0 and 1
memory_test_ptr = game_state
memory_test_ptr_l = memory_test_ptr
memory_test_ptr_h = memory_test_ptr + 1
; game_state_10 switches to this game state when waiting for input with
; a countdown is done
next_game_state: .res 1
timectr: .res 1
; In BCD seconds? Sometimes
; game_state_pregame uses decimal math to decrement
; game_state_countdown uses binary math
countdown_timer: .res 1
; $80 bit: set when player controlling, clear in attract mode
; $40 bit: set when player playing, clear when dead (entering score)
play_state: .res 1
credits: .res 1
; Increments every second; No, every interrupt... Approx 246 Hz?
timer_seconds: .res 1
cabsw_shadow: .res 1
; Shadow of optsw1. Note value is XORed with $02 before storing.
coinage_shadow: .res 1
optsw2_shadow: .res 1 ; soft shadow of optsw2
.res 1
; Set to 240 when the slam switch is detected, decremented in check_coin_sw
; which is called 246 times a second, so this should be ~1 second.
slam_timer: .res 1
;RAM 000D = ??? for coin cointer "A" and cancelled out by tilt.
;RAM 000E = ??? for coin cointer "B" and cancelled out by tilt.
;RAM 000F = ??? for coin cointer "C" and cancelled out by tilt.
L0d: .res 3
;RAM 0010 = ??? for coin cointer "A".
;RAM 0011 = ??? for coin cointer "B".
;RAM 0012 = ??? for coin cointer "C".
L10: .res 3
;RAM 0013 = Countdown timer to hold closed hardware coin cointer "A".
;RAM 0014 = Countdown timer to hold closed hardware coin cointer "B".
;RAM 0015 = Countdown timer to hold closed hardware coin cointer "C".
L13: .res 3
coin_string: .res 1
uncredited: .res 1 ; coins accepted but not yet converted to credits
L18: .res 1 ; used in calculating bonus games for multiple games?
; col_ram ram shadow
col_ram_shadow: .res 16
col_ram_shadow_plyr_shot_clr = col_ram_shadow + 8
;RAM 0029 = Scratchpad area
;RAM 002A = Scratchpad area
;RAM 002B = Scratchpad area
;RAM 002C = Scratchpad area
;RAM 002D = Scratchpad area
;RAM 002E = Scratchpad area
;RAM 0037 = Scratchpad area
L29: .res 1 ; 29
L29_l = L29
L29_m = L29 + 1
L2a: .res 1 ; 2a
; Scratchpad -- one use...
; Level being played (curlevel + 1; if curlevel is last level, L2b contains
; a random level 64-95)
L2b: .res 1 ; 2b
; Scatchpad -- 2c/2d are used as a word
L2c: .res 1 ; 2c
ptr2 = L2c
ptr2_l = ptr2
ptr2_h = ptr2 + 1
L2d: .res 1 ; 2d
L2e: .res 1 ; 2e
L2f: .res 1 ; 2f
L30: .res 1 ; 30
L31: .res 1 ; 31
L32: .res 1 ; 32
abs_delta_x = L32
L33: .res 1 ; 33
y_neg = L33
L34: .res 1 ; 34
x_neg = L34
L35: .res 1 ; 35
L36: .res 1 ; 36
L37: .res 1 ; 37
loopidx = L37
L38: .res 1 ; 38
L39: .res 1 ; 39
L3a: .res 1 ; 3a
ptr1: .res 2
ptr1_l = ptr1
ptr1_h = ptr1 + 1
curplayer: .res 1 ; 3d
; 0 if 1p game, 1 if 2p
twoplayer: .res 1 ; 3e
L3f: .res 1 ; 3f