-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsraiders.asm
2348 lines (2308 loc) · 87.1 KB
/
sraiders.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;*******************************************************************************
;* *
;* S T A R R A I D E R S *
;* *
;* for the Atari 8-bit Home Computer System *
;* *
;* Reverse engineered and documented assembly language source code *
;* *
;* by *
;* *
;* Lorenz Wiest *
;* *
;* (lo.wiest(at)web.de) *
;* *
;* First Release *
;* 22-SEP-2015 *
;* *
;* Last Update *
;* 10-dec-2016 *
;* *
;* STAR RAIDERS was created by Douglas Neubauer *
;* STAR RAIDERS was published by Atari Inc. *
;* *
;*******************************************************************************
.cpu "65c02"
.include "equates/system_f256jr.equ"
.include "equates/zeropage.equ"
.include "equates/game.equ"
.include "macros/frs_jr_graphic.mac"
.include "macros/frs_jr_mouse.mac"
.include "macros/frs_jr_random.mac"
.include "macros/frs_jr_text.mac"
;--------------------------------------
;--------------------------------------
* = $8000
;--------------------------------------
; Boot from RAM data block
.byte $F2,$56 ; signature
.byte $02 ; block count
.byte $04 ; start at block1
.addr BOOT ; execute address
.word $0000 ; version
.word $0000 ; kernel
; binary name
.text 'Star Raiders',$00
;--------------------------------------
BOOT cld ; clear decimal
ldx #$FF ; initialize the stack
txs
jmp INIT
;--------------------------------------
.include "platform_f256jr.asm"
;--------------------------------------
.align $100
;--------------------------------------
GameFont .include "DATA/FONT.inc"
GameFont_end
Palette .include "DATA/PALETTE.inc"
Palette_end
;--------------------------------------
INIT .proc
jsr InitSystemVectors
; jsr InitMMU
jsr RandomSeedQuick
.frsGraphics mcTextOn|mcOverlayOn|mcGraphicsOn|mcSpriteOn,mcVideoMode240|mcTextDoubleX|mcTextDoubleY
.frsMouse_off
.frsBorder_off
stz BITMAP0_CTRL ; disable all bitmaps
stz BITMAP1_CTRL
stz BITMAP2_CTRL
stz LAYER_ORDER_CTRL_0
stz LAYER_ORDER_CTRL_1
jsr InitGfxPalette
jsr InitTextPalette
jsr SetFont
jsr ClearScreen
jsr ClearGamePanel
; jsr InitSID ; initialize SID sound
; jsr InitPSG ; initialize PSG sound
; initialize sprites
jsr InitSprites
jmp InitGame.COLD
.endproc
;--------------------------------------
;--------------------------------------
* = $A000
;--------------------------------------
.include "DATA/PART1.inc"
.include "DATA/VIEWS.inc"
;--------------------------------------
.include "src/gameinit.asm"
.include "src/gameloop.asm"
.include "src/irqhandler.asm"
.include "src/drawline.asm"
.include "src/attackcomputer.asm"
.include "src/hyperwarp.asm"
.include "src/projection.asm"
.include "src/maneuver.asm"
.include "src/explode.asm"
.include "src/docking.asm"
.include "src/playfield.asm"
.include "src/trigger.asm"
.include "src/noise.asm"
.include "src/combat.asm"
.include "src/keyboard.asm"
.include "src/gameover.asm"
.include "src/selectwarp.asm"
.include "src/titleline.asm"
.include "src/sound.asm"
.include "src/initialize.asm"
.include "src/galacticchart.asm"
.include "src/gameloopflush.asm"
.include "src/calc.asm"
.include "src/surrounded.asm"
.include "src/panel.asm"
;--------------------------------------
.include "DATA/PART2.inc"
; I wrote this document out of my own curiosity. When STAR RAIDERS was released
; in 1979 it became the killer app for the Atari 8-bit Home Computer System.
; Since then I have always been wondering what made it tick and how its (at that
; time) spectacular 3D graphics worked, especially the rotating star field.
; Impressed by "The Atari BASIC Source Book" I decided to reverse engineer the
; STAR RAIDERS 8KB ROM cartridge to recreate a fully documented assembly
; language source code file. I had no access to the original source code, so the
; only way to succeed was a combination of educated guesses, trial-and-error,
; and patience. Eventually, I made it.
;
; Essential in preparing this document were three programs I wrote:
;
; (1) A 6502-cross-assembler based on the syntax of the MAC/65 assembler for the
; Atari 8-bit Home Computer System to create the binary file that I verified
; against the binary of the original ROM cartridge.
;
; (2) A text formatter to layout the source code file with its copious comment
; sections. This was a big time saver, because as the documentation grew the
; source code had to be reformatted over and over again.
;
; (3) A symbol checker to verify that the ubiquitous symbol-value pairs in the
; documentation match the corresponding symbol values produced by the
; assembler.
;
; This assembly language source code file is compatible with the MAC/65
; assembler for the Atari 8-bit Home Computer System. I was able to assemble it
; on an emulated Atari running MAC/65, producing the identical binary of the ROM
; cartridge.
;
; Your feedback is welcome! Send feedback to lo.wiest(at)web.de.
;
; Enjoy! -- Lorenz
;*******************************************************************************
;* *
;* N O T A T I O N *
;* *
;*******************************************************************************
; BITS and BYTES
;
; o A "byte" consists of 8 bits. They are numbered B7..0. Bit B0 is the least
; significant bit.
;
; o A "word" consists of 16 bits. They are numbered B15..B0. Bit B0 is the
; least significant bit. A word is stored in low-order then high-order byte
; order.
;
; o The high-order byte ("high byte") of a word consists of bits B15..8 of the
; word.
;
; o The low-order byte ("low byte") of a word consists of bits B7..0 of the
; word.
;
; NUMBERS
;
; o The dollar sign ($) prefixes hexadecimal numbers.
; Example: $101 is the decimal number 257.
;
; o The percent sign (%) prefixes binary numbers.
; Example: %101 is the decimal number 5.
;
; o The asterisk (*) is a wildcard character for a single hexadecimal or
; binary digit.
; Example: $0*00 is a placeholder for the numbers $0000, $0100, ..., $0F00.
;
; o The lowercase R (r) is a wildcard character for a single random
; hexadecimal or binary digit. The random digit r is chosen by a random
; number generator.
; Example: %00r0 is a placeholder for the numbers %0000 or %0010.
;
; OPERATORS
;
; o The exclamation mark (!) is the binary OR operator.
; Example: $01!$02 is $03.
;
; o The less-than sign (<) indicates bits B7..0 of a word.
; Example: <$1234 is $34.
;
; o The greater-than sign (>) indicates bits B15..8 of a word.
; Example: >$1234 is $12.
;
; o A pair of brackets ([]) groups mathematical expressions.
; Example: [3-1]*4 is 8.
;
; ASSEMBLY LANGUAGE
;
; o The uppercase A (A) indicates the accumulator register of the 6502 CPU.
;
; o The uppercase X (X) indicates the X register of the 6502 CPU.
;
; o The uppercase Y (Y) indicates the Y register of the 6502 CPU.
;
; o The prefix uppercase L and dot (L_) indicates a local variable, a memory
; location used temporarily in a subroutine.
;
; PSEUDO-FUNCTIONS
;
; o The function ABS(<num>) returns the absolute value of <num>.
; Example: ABS(3) returns 3.
; Example: ABS(-3) returns 3.
;
; o The function RND(<num1>..<num2>) returns a random integer in
; <num1>..<num2>.
; Example: RND(3..5) returns a random number out of 3, 4, or 5.
;
; o The function MAX(<num1>,<num2>) returns the larger number of <num1> and
; <num2>.
; Example: MAX(2,4) returns 4.
;
; VECTORS
;
; o The lowercase X (x) indicates the x-axis of the 3D coordinate system.
;
; o The lowercase Y (y) indicates the y-axis of the 3D coordinate system.
;
; o The lowercase Z (z) indicates the z-axis of the 3D coordinate system.
;
; o Components of a position vector (called "coordinates") have the arbitrary
; unit <KM> ("kilometers").
;
; o Components of a velocity vector have the arbitrary unit <KM/H>
; ("kilometers per hour").
;
; o A positive component of a position vector (coordinate) in hexadecimal
; notation is written in the form +$<hexNum> <KM>. <hexNum> is an unsigned
; integer value.
; Example: The starbase is +$1000 (or 4096) <KM> ahead of our starship.
;
; o A negative component of a position vector (coordinate) in hexadecimal
; notation is written in the form -($<hexNum>) <KM>. <hexNum> is an unsigned
; integer value. To calculate the actual bit pattern of this coordinate
; value compute the two's-complement of <hexNum>. See also "ON POSITION
; VECTORS".
; Example: The starbase is -($1000) (or -4096) <KM> behind our starship.
;
; o An absolute component of a position vector (coordinate) in hexadecimal
; notation is written in the form $<hexNum> <KM>. <hexNum> is an unsigned
; integer value.
; Example: The Zylon fighter fires when it is closer than $1000 (or 4096)
; <KM>.
;
; DISPLAY LIST
;
; o The following notation is used for Display List instructions:
;
; BLK<n> = Display <n> blank video lines (<n> in 1..8)
; GR1 = Display one GRAPHICS 1 row of 20 text characters
; GR2 = Display one GRAPHICS 2 row of 20 text characters
; GR7 = Display one GRAPHICS 7 row of 160 pixels
; DLI = Trigger a Display List Interrupt
; ... @ <addr> = Point to screen memory at address <addr>
; jmp @ <addr> = Jump to next Display List instruction at address <addr>
; WAITJMP @ <addr> = Wait for vertical blank phase, then jump to next
; Display List instruction at address <addr>
;
; MISCELLANEOUS
;
; o Probabilities are written in the form <percentage>% (<number of values out
; of the possible values>:<number of possible values>).
; Example: The probability to throw the number 3 with a die is 16% (1:6).
;
; o A "game loop iteration" (or "game loop") is a single execution of the game
; loop, the main program of the game.
;
; o A "TICK" is the time span it takes to update the TV screen (1/60 s on an
; NTSC TV system, 1/50 s on a PAL TV system).
;
; o A pair of braces ({}) encloses color names.
; Example: {BLACK}
;
; o A pair of parentheses enclosing a question mark ((?)) indicates code that
; is not well understood.
;
; o A pair of parentheses enclosing an exclamation mark ((!)) indicates a
; potential bug.
;*******************************************************************************
;* *
;* O V E R V I E W *
;* *
;*******************************************************************************
; ON POSITION VECTORS
;
; The game uses a 3D coordinate system with the position of our starship at the
; center of the coordinate system and the following coordinate axes:
;
; o The x-axis points to the right.
; o The y-axis points up.
; o The z-axis points in flight direction.
;
; By the way, this is called a "left-handed" coordinate system.
;
; The locations of all space objects (Zylon ships, meteors, photon torpedoes,
; starbase, transfer vessel, Hyperwarp Target Marker, stars, and explosion
; fragments) are described by a "position vector".
;
; A "position vector" is composed of an x, y, and z component. The values of the
; position vector components are called the x, y, and z "coordinates". They have
; the arbitrary unit <KM>.
;
; Each coordinate is a signed 17-bit integer number, which fits into 3 bytes:
;
; Sign Mantissa
; B16 B15...B8 B7....B0
; | | | | |
; 0000000* ******** ********
;
; o B16 contains the sign bit. Used values are:
; 1 -> Positive sign
; 0 -> Negative sign
; o B15..0 contain the coordinate value (or "mantissa") as a two's-complement
; integer number.
;
; The range of a position vector component is -65536..+65535 <KM>.
;
; Examples:
;
; 00000001 11111111 11111111 = +65535 <KM>
; 00000001 00010000 00000000 = +4096 <KM>
; 00000001 00001111 11111111 = +4095 <KM>
; 00000001 00000001 00000000 = +256 <KM>
; 00000001 00000000 11111111 = +255 <KM>
; 00000001 00000000 00010000 = +16 <KM>
; 00000001 00000000 00001111 = +15 <KM>
; 00000001 00000000 00000001 = +1 <KM>
; 00000001 00000000 00000000 = +0 <KM>
;
; 00000000 11111111 11111111 = -1 <KM>
; 00000000 11111111 11111110 = -2 <KM>
; 00000000 11111111 11110001 = -15 <KM>
; 00000000 11111111 11110000 = -16 <KM>
; 00000000 11111111 00000001 = -255 <KM>
; 00000000 11111111 00000000 = -256 <KM>
; 00000000 11110000 00000001 = -4095 <KM>
; 00000000 11110000 00000000 = -4096 <KM>
; 00000000 00000000 00000000 = -65536 <KM>
;
; The position vector for each space object is stored in 9 tables:
;
; o XPOSSIGN ($09DE..$0A0E), XPOSHI ($0A71..$0AA1), and XPOSLO ($0B04..$0B34)
; o YPOSSIGN ($0A0F..$0A3F), YPOSHI ($0AA2..$0AD2), and YPOSLO ($0B35..$0B65)
; o ZPOSSIGN ($09AD..$09DD), ZPOSHI ($0A40..$0A70), and ZPOSLO ($0AD3..$0B03)
;
; There are up to 49 space objects used in the game simultaneously, thus each
; table is 49 bytes long.
;
; o Position vectors 0..4 belong to space objects represented by PLAYERs
; (Zylon ships, meteors, photon torpedoes, starbase, transfer vessel, and
; Hyperwarp Target Marker).
; o Position vectors 5..48 belong to space objects represented by PLAYFIELD
; pixels. Position vectors 5..16 (stars, explosion fragments) are used for
; stars, position vectors 17..48 are used for explosion fragments and star
; trails.
;
; INFO: The x and y coordinates of space objects are converted and displayed by
; the THETA and PHI readouts of the Control Panel Display in "gradons". The
; z-coordinate is converted and displayed by the RANGE readout in "centrons".
; The conversion takes place in subroutine SHOWDIGITS ($B8CD) where the high
; byte of a coordinate (with values $00..$FF) is transformed with lookup table
; MAPTOBCD99 ($0EE9) into a BCD value of 00..99 in "gradons" or "centrons".
;
;
; ON VELOCITY VECTORS
;
; The velocities of all space objects are described by a "velocity vector". The
; velocity vector is relative to our starship.
;
; A "velocity vector" is composed of an x, y, and z component. The values of the
; velocity vector components are called the x, y, and z "velocities". They have
; the arbitrary unit <KM/H>.
;
; Each velocity vector component is an 8-bit integer number, which fits into 1
; byte:
;
; B7 Sign
; |
; |B6...B0 Mantissa
; || |
; ********
;
; o B7 contains the sign bit. Used values are:
; 0 -> Positive sign, movement along the positive coordinate axis
; (x-velocity: right, y-velocity: up, z-velocity: in flight direction)
; 1 -> Negative sign, movement along the negative coordinate axis
; (x-velocity: left, y-velocity: down, z-velocity: in reverse flight
; direction)
; o B6..B0 contain the velocity value (or "mantissa"). It is an unsigned
; number.
;
; The range of a velocity vector component is -127..+127 <KM/H>.
;
; Examples:
;
; 01111111 = +127 <KM/H>
; 00010000 = +16 <KM/H>
; 00001111 = +15 <KM/H>
; 00000001 = +1 <KM/H>
; 00000000 = +0 <KM/H>
;
; 10000000 = -0 <KM/H>
; 10000001 = -1 <KM/H>
; 10001111 = +15 <KM/H>
; 10010000 = +16 <KM/H>
; 11111111 = -127 <KM/H>
;
; The velocity vector for each space object stored in 3 tables:
;
; o XVEL ($0B97..$0BC7)
; o YVEL ($0BC8..$0BF8)
; o ZVEL ($0B66..$0B96)
;
; There are up to 49 space objects used in the game simultaneously, thus each
; table is 49 bytes long.
;
; o Velocity vectors 0..4 belong to space objects represented by PLAYERs
; (Zylon ships, meteors, photon torpedoes, starbase, transfer vessel, and
; Hyperwarp Target Marker).
; o Velocity vectors 5..48 belong to space objects represented by PLAYFIELD
; pixels. Velocity vectors 5..16 are used for stars, velocity vectors 17..48
; are used for explosion fragments and star trails.
;
; INFO: The velocity of our starship is converted and displayed by the VELOCITY
; readout of the Control Panel Display in "metrons per second" units. The
; conversion takes place in subroutine SHOWDIGITS ($B8CD) where our starship's
; velocity VELOCITYL ($70) (with values $00..$FF) is transformed with lookup
; table MAPTOBCD99 ($0EE9) into a BCD value of 00..99 in "metrons per second".
;*******************************************************************************
;* *
;* M E M O R Y M A P *
;* *
;*******************************************************************************
;
; The following variables are not changed by a SYSTEM RESET:
;
; $62 MISSIONLEVEL
;
; Mission level. Used values are:
; $00 -> NOVICE mission
; $01 -> PILOT mission
; $02 -> WARRIOR mission
; $03 -> COMMANDER mission
;
; $63 FKEYCODE
;
; Function key code. Used values are:
; $00 -> No function key pressed
; $01 -> START function key pressed
; $02 -> SELECT function key pressed
;
; $64 ISDEMOMODE
;
; Indicates whether the game is in game or in demo mode. Used values
; are:
; $00 -> Game mode
; $FF -> Demo mode
;
; $65 NEWTITLEPHR
;
; New title phrase offset for the text in the title line. The new title
; phrase is not immediately displayed in the title line but only after
; the display time of the currently displayed title phrase has expired.
; Thus, setting a value to NEWTITLEPHR ($65) "enqueues" the display of
; new title phrase. Used values are:
; $00..$7B -> Title phrase offset into PHRASETAB ($BBAA)
; $FF -> Hide title line
;
; See also TITLEPHR ($D1).
;
; $66 IDLECNTHI
;
; Idle counter (high byte). Forms a 16-bit counter together with
; IDLECNTLO ($77), which is incremented during the execution of the
; Vertical Blank Interrupt handler VBIHNDLR ($A6D1). IDLECNTHI ($66) is
; reset to 0 when the joystick trigger or a keyboard key has been
; pressed, or to 1..3 when a function key has been pressed. When
; IDLECNTHI ($66) reaches a value of 128 (after about 10 min idle time)
; the game enters demo mode.
;
; The following variables are set to 0 after a SYSTEM RESET:
;
; $67 ISVBISYNC
;
; Indicates whether the Vertical Blank Interrupt handler VBIHNDLR
; ($A6D1) is executed. Used to synchronize the execution of a new game
; loop iteration in GAMELOOP ($A1F3) with the vertical blank phase.
; Used values are:
; $00 -> Halt execution at start of game loop and wait for VBI
; $FF -> Continue execution of game loop
;
; $68..$69 MEMPTR
;
; A 16-bit memory pointer.
;
; Also used as a local variable.
;
; $6A..$6B DIVIDEND
;
; A 16-bit dividend value passed in GAMELOOP ($A1F3) to subroutine
; PROJECTION ($AA21) to calculate a division.
;
; Also used as a local variable.
;
; $6C Used as a local variable.
;
; $6D JOYSTICKDELTA
;
; Used to pass joystick directions from GAMELOOP ($A1F3) to subroutine
; ROTATE ($B69B). Used values are:
; $01 -> Joystick pressed right or up
; $00 -> Joystick centered
; $FF -> Joystick pressed left or down
;
; Also used as a local variable.
;
; $6E Used as a local variable.
;
; $70 VELOCITYLO
;
; Our starship's current velocity (low byte) in <KM/H>. Forms a 16-bit
; value together with VELOCITYHI ($C1). In subroutine UPDPANEL ($B804),
; VELOCITYLO ($70) is mapped to a BCD-value in 00..99 and displayed by
; the VELOCITY readout of the Control Panel Display. See also
; NEWVELOCITY ($71).
;
; $71 NEWVELOCITY
;
; Our starship's new velocity (low byte) in <KM/H>. It is set by
; pressing one of the speed keys '0'..'9'. A pressed speed key is
; mapped to the new velocity value with VELOCITYTAB ($BAB4).
;
; $72 COUNT8
;
; Wrap-around counter. Counts from 0..7, then starts over at 0. It is
; incremented every game loop iteration. It is used to change the
; brightness of stars and explosion fragments more randomly in GAMELOOP
; ($A1F3) and to slow down the movement of the hyperwarp markers of the
; Galactic Chart in subroutine SELECTWARP ($B162).
;
; $73 EXPLLIFE
;
; Explosion lifetime. It is decremented every game loop iteration. Used
; values are:
; $00 -> Explosion is over
; < $18 -> Number of explosion fragment space objects is decremented
; < $70 -> HITBADNESS ($8A) is reset
; $80 -> Initial value at start of explosion
;
; $74 CLOCKTIM
;
; Star date clock delay timer. Counts down from 40 to 0. It is
; decremented every game loop iteration. When the timer falls below 0
; the last digit of the star date of the Galactic Chart Panel Display
; is increased and the timer is reset to a value of 40.
;
; $75 DOCKSTATE
;
; State of docking operation. Used values are:
; $00 -> NOT DOCKED
; $01 -> TRANSFER COMPLETE
; $81 -> RETURN TRANSFER VESSEL
; $FF -> ORBIT ESTABLISHED
;
; $76 COUNT256
;
; Wrap-around counter. Counts from 0..255, then starts over at 0. It is
; incremented every game loop iteration. It is used to make the
; starbase pulsate in brightness in GAMELOOP ($A1F3) and to decide on
; the creation of a meteor in subroutine MANEUVER ($AA79).
;
; $77 IDLECNTLO
;
; Idle counter (low byte). Forms a 16-bit counter together with
; IDLECNTHI ($66), which is incremented during the execution of the
; Vertical Blank Interrupt handler VBIHNDLR ($A6D1).
;
; NOTE: This variable is never properly initialized except at initial
; cartridge startup (cold start).
;
; $78 ZYLONUNITTIM
;
; Zylon unit movement timer. This delay timer triggers movement of
; Zylon units on the Galactic Chart. At the start of the game, the
; timer is initialized to a value of 100. It is decremented every 40
; game loop iterations. When the timer falls below 0 the Zylon units
; move on the Galactic Chart and the timer value is reset to 49. If a
; starbase is surrounded the timer is reset to 99 to buy you some extra
; time to destroy one of the surrounding Zylon units.
;
; $79 MAXSPCOBJIND
;
; Maximum index of used space objects in the current game loop
; iteration. Frequently used values are:
; $10 -> During regular cruise (5 PLAYER space objects + 12 PLAYFIELD
; space objects (stars), counted $00..$10)
; $30 -> During explosion or hyperwarp (5 PLAYER space objects + 12
; PLAYFIELD space objects (stars) + 32 PLAYFIELD space objects
; (explosion fragments or stars of star trails), counted
; $00..$30)
;
; $7A OLDMAXSPCOBJIND
;
; Maximum index of used space objects in the previous game loop
; iteration. Frequently used values are:
; $10 -> During regular cruise (5 PLAYER space objects + 12 PLAYFIELD
; space objects (stars), counted $00..$10)
; $30 -> During explosion or hyperwarp (5 PLAYER space objects + 12
; PLAYFIELD space objects (stars) + 32 PLAYFIELD space objects
; (explosion fragments or stars of star trails), counted
; $00..$30)
;
; $7B ISSTARBASESECT
;
; Indicates whether a starbase is in this sector. Used values are:
; $00 -> Sector contains no starbase
; $FF -> Sector contains starbase
;
; $7C ISTRACKCOMPON
;
; Indicates whether the Tracking Computer is on or off. Used values
; are:
; $00 -> Tracking Computer is off
; $FF -> Tracking Computer is on
;
; $7D DRAINSHIELDS
;
; Energy drain rate of the Shields per game loop iteration in energy
; subunits. See also subroutine UPDPANEL ($B804). Used values are:
; $00 -> Shields are off
; $08 -> Shields are on
;
; $7E DRAINATTCOMP
;
; Energy drain rate of the Attack Computer per game loop iteration in
; energy subunits. See also subroutine UPDPANEL ($B804). Used values
; are:
; $00 -> Attack Computer off
; $02 -> Attack Computer on
;
; $7F ENERGYCNT
;
; Running counter of consumed energy subunits (256 energy subunits = 1
; energy unit displayed by the 4-digit ENERGY readout of the Control
; Panel Display). Forms an invisible fractional or "decimals" part of
; the 4-digit ENERGY readout of the Control Panel Display. See also
; subroutine UPDPANEL ($B804).
;
; $80 DRAINENGINES
;
; Energy drain rate of our starship's Engines per game loop iteration
; in energy subunits (256 energy subunits = 1 energy unit displayed by
; the 4-digit ENERGY readout of the Control Panel Display). Values are
; picked from table DRAINRATETAB ($BAD3). See also subroutine UPDPANEL
; ($B804).
;
; $81 SHIELDSCOLOR
;
; Shields color. Used values are:
; $00 -> {BLACK} (Shields are off)
; $A0 -> {DARK GREEN} (Shields are on)
;
; $82 PL3HIT
;
; Collision register of PLAYER3 (usually our starship's photon torpedo
; 0) with other PLAYERs. Used values are:
; $00 -> No collision
; > $00 -> PLAYER3 has collided with another PLAYER space object. See
; subroutine Collision ($AF3D) for details which PLAYER has
; been hit by PLAYER3.
;
; $83 PL4HIT
;
; Collision register of PLAYER4 (usually our starship's photon torpedo
; 1) with other PLAYERs. Used values are:
; $00 -> No collision
; > $00 -> PLAYER4 has collided with another PLAYER space object. See
; subroutine Collision ($AF3D) for details which PLAYER has
; been hit by PLAYER4.
;
; $84 OLDTRIG0
;
; Joystick trigger state. Used values are:
; $00 -> Joystick trigger was pressed
; $01 -> Joystick trigger was not pressed
; $AA -> Joystick trigger was "virtually" pressed (will launch
; another of our starship's photon torpedoes, see subroutine
; TRIGGER ($AE29).
;
; $86 ISTRACKING
;
; Indicates whether one of our starship's photon torpedoes is currently
; tracking (homing in on) the target space object. Used values are:
; $00 -> No target space object tracked. Our starship's photon
; torpedoes will fly just straight ahead.
; > $00 -> Tracking a target space object. Our starship's photon
; torpedoes will home in on the tracked space object.
;
; $87 BARRELNR
;
; Barrel from which our starship's next photon torpedo will be
; launched. Used values are:
; $00 -> Left barrel
; $01 -> Right barrel
;
; $88 LOCKONLIFE
;
; Lifetime of target lock-on. A target remains in lock-on while
; LOCKONLIFE ($88) counts down from 12 to 0. It is decremented every
; game loop iteration.
;
; $89 PLTRACKED
;
; Index of currently tracked PLAYER. It is copied in subroutine TRIGGER
; ($AE29) from TRACKDIGIT ($095C). Used values are:
; $00 -> Track Zylon ship 0
; $01 -> Track Zylon ship 1
; $02 -> Track starbase during docking operations
; $03 -> Track Hyperwarp Target Marker during hyperwarp
;
; $8A HITBADNESS
;
; Severity of a Zylon photon torpedo hit. Used values are:
; $00 -> NO HIT
; $7F -> SHIELDS HIT
; $FF -> STARSHIP DESTROYED
;
; $8B REDALERTLIFE
;
; Lifetime of red alert. It decreases from 255 to 0. It is decremented
; every game loop iteration.
;
; $8C WARPDEPRROW
;
; Departure hyperwarp marker row number on the Galactic Chart. It is
; given in Player/Missile pixels relative to the top Galactic Chart
; border. It is initialized to a value of $47 (vertical center of
; Galactic Chart). Divide this value by 16 to get the departure sector
; row number. Used values are: $00..$7F.
;
; $8D WARPDEPRCOLUMN
;
; Departure hyperwarp marker column number on the Galactic Chart. It is
; given in Player/Missile pixels relative to the left Galactic Chart
; border and initialized to a value of $43 (horizontal center of
; Galactic Chart). Divide this value by 8 to get the departure sector
; column number. Used values are: $00..$7F.
;
; $8E WARPARRVROW
;
; Arrival hyperwarp marker row number on the Galactic Chart in
; Player/Missile pixels relative to top Galactic Chart border. It is
; initialized to a value of $47 (vertical center of Galactic Chart).
; Divide this value by 16 to get the arrival sector row number. Used
; values are: $00..$7F.
;
; $8F WARPARRVCOLUMN
;
; Arrival hyperwarp marker column number on the Galactic Chart in
; Player/Missile pixels relative to left Galactic Chart border. It is
; initialized to a value of $43 (horizontal center of Galactic Chart).
; Divide this value by 8 to get the arrival sector column number. Used
; values are: $00..$7F.
;
; $90 CURRSECTOR
;
; Galactic Chart sector of the current location of our starship. At the
; start of the game it is initialized to a value of $48. Used values
; are: $00..$7F with, for example,
; $00 -> NORTHWEST corner sector
; $0F -> NORTHEAST corner sector
; $70 -> SOUTHWEST corner sector
; $7F -> SOUTHWEST corner sector
;
; See also ARRVSECTOR ($92).
;
; $91 WARPENERGY
;
; Energy required to hyperwarp between the departure and arrival
; hyperwarp marker locations on the Galactic Chart divided by 10.
; Values are picked from table WARPENERGYTAB ($BADD). Multiply this
; value by 10 to get the actual value in energy units displayed by the
; Galactic Chart Panel Display.
;
; $92 ARRVSECTOR
;
; Galactic Chart arrival sector of our starship after hyperwarp. Used
; values are: $00..$7F with, for example,
; $00 -> NORTHWEST corner sector
; $0F -> NORTHEAST corner sector
; $70 -> SOUTHWEST corner sector
; $7F -> SOUTHWEST corner sector
;
; See also CURRSECTOR ($90).
;
; $93 HUNTSECTOR
;
; Galactic Chart sector of the starbase toward which the Zylon units
; are currently moving. Used values are: $00..$7F with, for example,
; $00 -> NORTHWEST corner sector
; $0F -> NORTHEAST corner sector
; $70 -> SOUTHWEST corner sector
; $7F -> SOUTHWEST corner sector
;
; $94 HUNTSECTCOLUMN
;
; Galactic Chart sector column number of the starbase toward which the
; Zylon units are currently moving. Used values are: 0..15.
;
; $95 HUNTSECTROW
;
; Galactic Chart sector row number of the starbase toward which the
; Zylon units are currently moving. Used values are: 0..7.
;
; $96..$9E NEWZYLONDIST
;
; Table of distances between a Zylon unit and the hunted starbase when
; the Zylon unit is tentatively moved in one of the 9 possible
; directions NORTH, NORTHWEST, WEST, SOUTHWEST, SOUTH, SOUTHEAST, EAST,
; NORTHEAST, CENTER. Used to decide into which sector the Zylon unit
; should move.
;
; $9E OLDZYLONDIST
;
; Current distance between the Zylon unit and the hunted starbase.
;
; $9F HUNTTIM
;
; Delay timer for Zylon units to decide on which starbase to hunt. It
; counts down from 7. It is decremented every game loop iteration. When
; the timer falls below 0 the Zylon units re-decide toward which
; starbase to move.
;
; $A0 BLIPCOLUMN
;
; Top-left screen pixel column number of blip shape displayed in the
; Attack Computer Display. Used in subroutine UPDATTCOMP ($A7BF). Used
; values are: 120..142.
;
; $A1 BLIPROW
;
; Top-left screen pixel row number of blip shape displayed in the
; Attack Computer Display. Used in subroutine UPDATTCOMP ($A7BF). Used
; values are: 71..81.
;
; $A2 BLIPCYCLECNT
;
; Blip cycle counter. It controls drawing the blip shape in the Attack
; Computer Display. Its value is incremented every game loop iteration.
; Used in subroutine UPDATTCOMP ($A7BF). Used values are:
; $00..$04 -> Draw 0..4th row of blip shape
; $05..$09 -> Do not draw blip shape (delay)
; $0A -> Recalculate blip shape position, erase Attack Computer
; Display
;
; $A3 ISINLOCKON
;
; Indicates whether the tracked space object is currently in full
; lock-on (horizontally and vertically centered as well as in range) in
; the Attack Computer Display. If so, all lock-on markers show up on
; the Attack Computer Display and our starship's launched photon
; torpedoes will home in on the tracked space object. Used values are:
; $00 -> Not in lock-on
; $A0 -> In lock-on
;
; $A4 DIRLEN
;
; Used to pass the direction and length of a single line to be drawn in
; the PLAYFIELD. Used in subroutines DrawLines ($A76F), DrawLine
; ($A782), and UPDATTCOMP ($A7BF). Used values are:
; Bit B7 = 0 -> Draw right
; Bit B7 = 1 -> Draw down
; Bits B6..0 -> Length of line in pixels.
;
; See also PENROW ($A5) and PENCOLUMN ($A6).
;
; $A5 PENROW
;
; Used to pass the start screen pixel row number of the line to be
; drawn in the PLAYFIELD. Used in subroutines DrawLines ($A76F),
; DrawLine ($A782), and UPDATTCOMP ($A7BF).
;
; $A6 PENCOLUMN
;
; Used to pass the start screen pixel column number of the line to be
; drawn in the PLAYFIELD. Used in subroutines DrawLines ($A76F),
; DrawLine ($A782), and UPDATTCOMP ($A7BF).
;
; $A7 CTRLDZYLON
;
; Index of Zylon ship currently controlled by the game. Used in
; subroutine MANEUVER ($AA79). The value is toggled every other game
; loop iteration. Used values are:
; $00 -> Control Zylon ship 0.
; $01 -> Control Zylon ship 1.
;
; $A8 ZYLONFLPAT0
;
; Flight pattern of Zylon ship 0. Used in subroutine MANEUVER ($AA79).
; Used values are:
; $00 -> Attack flight pattern "0"
; $01 -> Flight pattern "1"
; $04 -> Flight pattern "4"
;
; $A9 ZYLONFLPAT1
;
; Flight pattern of Zylon ship 1. Compare ZYLONFLPAT0 ($A8).
;
; $AA MILESTTIM0
;
; Delay timer of the milestone velocity indices of Zylon ship 0. Used
; in subroutine MANEUVER ($AA79).
;
; When Zylon ship 0 is active, this value is decremented every game
; loop iteration. If it falls below 0 then the milestone velocity
; indices of Zylon ship 0 are recalculated. When Zylon ship 0 is
; controlled by the computer for the first time, the timer is set to an
; initial value of 1, later to an initial value of 120.
;
; $AB MILESTTIM1
;
; Delay timer of the milestone velocity index vector of Zylon ship 1.
; Compare MILESTTIM0 ($AA).
;
; $AC MILESTVELINDZ0
;
; Milestone z-velocity index of Zylon ship 0. Used in subroutine
; MANEUVER ($AA79). The current z-velocity index of Zylon ship 0
; ZYLONVELINDZ0 ($B2) is compared with this index and gradually
; adjusted to it. Used values are: 0..15.
;
; $AD MILESTVELINDZ1
;
; Milestone z-velocity index of Zylon ship 1. Compare MILESTVELINDZ0
; ($AC).
;
; $AE MILESTVELINDX0
;
; Milestone x-velocity index of Zylon ship 0. Used in subroutine
; MANEUVER ($AA79). The current x-velocity index of Zylon ship 0
; ZYLONVELINDX0 ($B4) is compared with this index and gradually
; adjusted to it. Used values are: 0..15.
;
; $AF MILESTVELINDX1
;
; Milestone x-velocity index of Zylon ship 1. Compare MILESTVELINDX0
; ($AE).