-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.txt
1603 lines (1603 loc) · 73.6 KB
/
game.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 game.asm LEVEL 1 PASS 2
1 1d08 ???? ;-----------------------------------------
2 1d08 ???? ; Work in progress demo for Star Fox 1980
3 1d08 ???? ;-----------------------------------------
4 1d08 ???? ;-----------------------------Macros-------------------------------
5 1d08 ???? 00 57 PLAYER_HEALTH equ $57
6 1d08 ???? 00 58 PLAYER_POS equ $58
7 1d08 ???? 00 59 BOSS_POS equ $59
8 1d08 ???? 00 5a BOSS_HEALTH equ $5a
9 1d08 ???? 00 5b SCORE equ $5b
10 1d08 ???? 00 5c HISCORE equ $5c
11 1d08 ???? 00 5d MINIONS equ $5d
12 1d08 ???? 00 5e MINION_IND equ $5e
13 1d08 ???? 00 5f LEVEL equ $5f
14 1d08 ???? 00 60 RANDNUM equ $60
15 1d08 ???? 00 61 SEED equ $61 ; 61 to 62 is 16 bit SEED
16 1d08 ???? 00 62 TMP equ $62
17 1d08 ???? 00 63 TMP2 equ $63
18 1d08 ????
19 1d08 ???? ff d2 CHROUT equ $ffd2
20 1d08 ???? fd 22 RESET equ $fd22
21 1d08 ???? ff e4 GETIN equ $ffe4
22 1d08 ???? 90 0a SOUND1 equ $900a
23 1d08 ???? 90 0b SOUND2 equ $900b
24 1d08 ???? 90 0c SOUND3 equ $900c
25 1d08 ???? 90 0d NOISE equ $900d
26 1d08 ???? 90 0e VOLUME equ $900e
27 1d08 ???? 90 0f SCRCOLOR equ $900f
28 1d08 ???? 02 86 TXTCOLOR equ $0286
29 1d08 ???? e5 5f CLRSCRN equ $e55f
30 1d08 ????
31 1d08 ???? f7 67 SETTIM equ $f767
32 1d08 ???? ;----------------------------End Macros----------------------------
33 1d08 ????
34 1d08 ????
35 1d08 ???? ;----------------------------Basic Stub----------------------------
36 1d08 ???? Processor 6502
37 1001 org $1001 ; Unexpanded VIC
38 1001
39 1001 ; BASIC stub (unexpanded vic)
40 1001 0b 10 dc.w $100b ; Pointer to next BASIC line
41 1003 bd 07 dc.w 1981 ; BASIC Line#
42 1005 9e dc.b $9e ; BASIC SYS token
43 1006 34 31 30 39 dc.b $34,$31,$30,$39 ; 4109 (ML start)
44 100a 00 dc.b 0 ; End of BASIC line
45 100b 00 00 dc.w 0 ; End of BASIC program
46 100d ;-----------------------------End Stub----------------------------
47 100d
------- FILE title.asm LEVEL 2 PASS 2
0 100d include "title.asm"
1 100d ;---------------------------Main Title Screen------------------------------
2 100d title
3 100d 20 5f e5 jsr $e55f ; clear the screen
4 1010
5 1010 a9 40 lda #$40 ; load new text colour
6 1012 8d 86 02 sta TXTCOLOR ; change text colour
7 1015
8 1015 a9 19 lda #$19 ; load new background colour
9 1017 8d 0f 90 sta SCRCOLOR ; change background and border colours
10 101a
11 101a ; loop that iterates through title characters
12 101a a0 00 ldy #00 ; initialize counter at 0
13 101c
14 101c titleloop
15 101c b9 5b 16 lda titlescreen,y
16 101f 20 d2 ff jsr CHROUT
17 1022 c8 iny
18 1023 c0 65 cpy #101 ; 101 characters in the title screen
19 1025 d0 f5 bne titleloop
20 1027
21 1027 20 d3 12 jsr victoryTheme
22 102a
23 102a titlewait
24 102a 20 e4 ff jsr GETIN ; pressing any input ends title screen
25 102d f0 fb beq titlewait
26 102f 4c 11 13 jmp draw_init
------- FILE game.asm
------- FILE player.asm LEVEL 2 PASS 2
0 1032 include "player.asm"
1 1032 ;---------------------------------------------------
2 1032 ; Handles player movement, collision, life, and attacking
3 1032 ;---------------------------------------------------
4 1032
5 1032 spawn_player
6 1032 a0 03 ldy #$03
7 1034 84 57 sty PLAYER_HEALTH
8 1036 a9 c2 lda #$c2
9 1038 85 58 sta PLAYER_POS
10 103a
11 103a 60 rts
12 103b
13 103b draw_player
14 103b a6 58 ldx PLAYER_POS ; Get player position
15 103d a9 03 lda #$03 ; Load starfighter character
16 103f 9d 00 1f sta $1f00 ,x ; Draw to screen
17 1042 a9 06 lda #$06 ; Color blue
18 1044 9d 00 97 sta $9700 ,x
19 1047 60 rts
20 1048
21 1048 player_collision
22 1048 a6 58 ldx PLAYER_POS
23 104a bd 00 1f lda $1f00 ,x
24 104d c9 0f cmp #$0f
25 104f d0 03 bne player_collision_end
26 1051
27 1051 20 f5 13 jsr decr_player_health
28 1054
29 1054 player_collision_end
30 1054 60 rts
------- FILE game.asm
------- FILE boss.asm LEVEL 2 PASS 2
0 1055 include "boss.asm"
1 1055 ;-----------------------------------------
2 1055 ; Handles boss spawning and movement
3 1055 ;-----------------------------------------
4 1055
5 1055 spawn_boss
6 1055 a2 08 ldx #$08 ; Initialize boss health
7 1057 86 5a stx BOSS_HEALTH
8 1059 a2 1f ldx #$1f ; Boss position
9 105b 86 59 stx BOSS_POS ;
10 105d
11 105d 60 rts
12 105e
13 105e draw_boss
14 105e
15 105e a6 59 ldx BOSS_POS
16 1060 a9 07 lda #$07 ; Boss top left character
17 1062 9d 00 1e sta $1e00 ,x ; Store it at the right locatin
18 1065 a9 02 lda #$02 ; Colour
19 1067 9d 00 96 sta $9600 ,x
20 106a
21 106a e8 inx
22 106b a9 08 lda #$08 ; Boss top mid-left character
23 106d 9d 00 1e sta $1e00 ,x ; Store it at the right locatin
24 1070 a9 02 lda #$02 ; Colour
25 1072 9d 00 96 sta $9600 ,x
26 1075
27 1075 e8 inx
28 1076 a9 09 lda #$09 ; Boss top mid-right character
29 1078 9d 00 1e sta $1e00 ,x ; Store it at the right locatin
30 107b a9 02 lda #$02 ; Colour
31 107d 9d 00 96 sta $9600 ,x
32 1080
33 1080 e8 inx
34 1081 a9 0a lda #$0a ; Boss top right character
35 1083 9d 00 1e sta $1e00 ,x ; Store it at the right locatin
36 1086 a9 02 lda #$02 ; Colour
37 1088 9d 00 96 sta $9600 ,x
38 108b
39 108b a5 59 lda BOSS_POS ; Get boss position
40 108d 18 clc
41 108e 69 16 adc #$16 ; Get the bottom row
42 1090 aa tax ; Transfer it to x register
43 1091 a9 0b lda #$0b ; Boss bottom left character
44 1093 9d 00 1e sta $1e00 ,x ; Store it at the right locatin
45 1096 a9 02 lda #$02 ; Colour
46 1098 9d 00 96 sta $9600 ,x
47 109b
48 109b e8 inx
49 109c a9 0c lda #$0c ; Boss bottom mid-left character
50 109e 9d 00 1e sta $1e00 ,x ; Store it at the right locatin
51 10a1 a9 02 lda #$02 ; Colour
52 10a3 9d 00 96 sta $9600 ,x
53 10a6
54 10a6 e8 inx
55 10a7 a9 0d lda #$0d ; Boss bottom mid-right character
56 10a9 9d 00 1e sta $1e00 ,x ; Store it at the right locatin
57 10ac a9 02 lda #$02 ; Colour
58 10ae 9d 00 96 sta $9600 ,x
59 10b1
60 10b1 e8 inx
61 10b2 a9 0e lda #$0e ; Boss bottom right character
62 10b4 9d 00 1e sta $1e00 ,x ; Store it at the right locatin
63 10b7 a9 02 lda #$02 ; Colour
64 10b9 9d 00 96 sta $9600 ,x
65 10bc
66 10bc 60 rts
67 10bd
68 10bd boss_move_left
69 10bd a6 59 ldx BOSS_POS ; Get current boss location
70 10bf e0 16 cpx #$16 ; is it touching the left boundary
71 10c1 f0 04 beq boss_move_right ; if so move right instead
72 10c3 ca dex ; if not move left
73 10c4 86 59 stx BOSS_POS ; and update new location
74 10c6 60 rts
75 10c7
76 10c7 boss_move_right
77 10c7 a6 59 ldx BOSS_POS ; Get current boss location
78 10c9 e0 28 cpx #$28 ; is it touching right boundary
79 10cb f0 f0 beq boss_move_left ; if so move left instead
80 10cd e8 inx ; if not move right
81 10ce 86 59 stx BOSS_POS ; and update new location
82 10d0 60 rts
83 10d1
84 10d1 boss_ai
85 10d1 a5 59 lda BOSS_POS ; Get the boss position
86 10d3 69 a2 adc #$a2 ; Add an offset
87 10d5 c5 58 cmp PLAYER_POS ; Compare it with player position
88 10d7 f0 04 beq boss_ai_shoot ; If the boss is where the player boss ai determine when to shoot
89 10d9 90 ec bcc boss_move_right ; If player is to the right of boss move right
90 10db b0 e0 bcs boss_move_left ; If player to the left of boss move left
91 10dd
92 10dd boss_ai_shoot
93 10dd a5 59 lda BOSS_POS ; Get the boss location
94 10df 8d 78 17 sta laser_pos ; Shoot the left laser at this location
95 10e2 20 73 14 jsr writeEnemyShot
96 10e5 aa tax
97 10e6 e8 inx
98 10e7 e8 inx
99 10e8 8a txa ; Get the right laser location
100 10e9 8d 78 17 sta laser_pos
101 10ec 20 73 14 jsr writeEnemyShot
102 10ef 60 rts
103 10f0
104 10f0
105 10f0 boss_collision
106 10f0 a6 59 ldx BOSS_POS
107 10f2 bd 00 1e lda $1e00 ,x
108 10f5 c9 10 cmp #$10
109 10f7 d0 03 bne boss_collision_end
110 10f9
111 10f9 20 fd 10 jsr decr_boss_health
112 10fc
113 10fc boss_collision_end
114 10fc 60 rts
115 10fd
116 10fd decr_boss_health
117 10fd
118 10fd a6 59 ldx BOSS_POS
119 10ff a9 17 lda #$17 ; Boss top left character
120 1101 9d 00 1e sta $1e00 ,x ; Store it at the right locatin
121 1104 a9 07 lda #$07 ; Colour
122 1106 9d 00 96 sta $9600 ,x
123 1109
124 1109 a6 5a ldx BOSS_HEALTH
125 110b ca dex ; Decrease health
126 110c 86 5a stx BOSS_HEALTH ; Store it
127 110e e0 00 cpx #$00
128 1110 f0 01 beq boss_death
129 1112 60 rts
130 1113
131 1113 boss_death
132 1113 20 d3 12 jsr victoryTheme
133 1116
134 1116 a6 59 ldx BOSS_POS
135 1118 a9 17 lda #$17 ; Boss top left character
136 111a 9d 00 1e sta $1e00 ,x ; Store it at the right locatin
137 111d a9 07 lda #$07 ; Colour
138 111f 9d 00 96 sta $9600 ,x
139 1122
140 1122 e8 inx
141 1123 a9 18 lda #$18 ; Boss top mid-left character
142 1125 9d 00 1e sta $1e00 ,x ; Store it at the right locatin
143 1128 a9 07 lda #$07 ; Colour
144 112a 9d 00 96 sta $9600 ,x
145 112d
146 112d e8 inx
147 112e a9 19 lda #$19 ; Boss top mid-right character
148 1130 9d 00 1e sta $1e00 ,x ; Store it at the right locatin
149 1133 a9 07 lda #$07 ; Colour
150 1135 9d 00 96 sta $9600 ,x
151 1138
152 1138 e8 inx
153 1139 a9 1a lda #$1a ; Boss top right character
154 113b 9d 00 1e sta $1e00 ,x ; Store it at the right locatin
155 113e a9 07 lda #$07 ; Colour
156 1140 9d 00 96 sta $9600 ,x
157 1143
158 1143 a5 59 lda BOSS_POS ; Get boss position
159 1145 18 clc
160 1146 69 16 adc #$16 ; Get the bottom row
161 1148 aa tax ; Transfer it to x register
162 1149 a9 1b lda #$1b ; Boss bottom left character
163 114b 9d 00 1e sta $1e00 ,x ; Store it at the right locatin
164 114e a9 07 lda #$07 ; Colour
165 1150 9d 00 96 sta $9600 ,x
166 1153
167 1153 e8 inx
168 1154 a9 1c lda #$1c ; Boss bottom mid-left character
169 1156 9d 00 1e sta $1e00 ,x ; Store it at the right locatin
170 1159 a9 17 lda #$17 ; Colour
171 115b 9d 00 96 sta $9600 ,x
172 115e
173 115e e8 inx
174 115f a9 1d lda #$1d ; Boss bottom mid-right character
175 1161 9d 00 1e sta $1e00 ,x ; Store it at the right locatin
176 1164 a9 07 lda #$07 ; Colour
177 1166 9d 00 96 sta $9600 ,x
178 1169
179 1169 e8 inx
180 116a a9 1e lda #$1e ; Boss bottom right character
181 116c 9d 00 1e sta $1e00 ,x ; Store it at the right locatin
182 116f a9 07 lda #$07 ; Colour
183 1171 9d 00 96 sta $9600 ,x
184 1174
185 1174 20 49 16 jsr victory_screen
------- FILE game.asm
------- FILE minions.asm LEVEL 2 PASS 2
0 1177 include "minions.asm"
1 1177 ;-----------------------------------------
2 1177 ; Handles minions spawning and movement
3 1177 ;-----------------------------------------
4 1177
5 1177 spawn_minions
6 1177 20 be 12 jsr randgen ; Generate random number
7 117a 46 60 lsr RANDNUM ; shift bit 0
8 117c 90 02 bcc spawn_laser_minion ; If even number generate enemy type 1
9 117e b0 0f bcs spawn_rocket_minion ; If odd number generate enemy type 2
10 1180
11 1180 spawn_laser_minion
12 1180 a6 5e ldx MINION_IND ; Get the current index
13 1182 a9 01 lda #$01 ; 01 represents laser
14 1184 9d 5a 17 sta minion_status ,x ; Save the status
15 1187 e8 inx ; Increment the index
16 1188 86 5e stx MINION_IND ; Save the new index
17 118a e0 0a cpx #$0a ; If not at the end of the index
18 118c d0 e9 bne spawn_minions ; Keep spawning more minions
19 118e 60 rts
20 118f
21 118f spawn_rocket_minion
22 118f a6 5e ldx MINION_IND ; Get the current index
23 1191 a9 02 lda #$02 ; 02 represents rocket
24 1193 9d 5a 17 sta minion_status ,x ; Save the status
25 1196 e8 inx ; Increment the index
26 1197 86 5e stx MINION_IND ; Save the new index
27 1199 e0 0a cpx #$0a ; If not at the end of the index
28 119b d0 da bne spawn_minions
29 119d 60 rts
30 119e
31 119e draw_minions
32 119e a6 5e ldx MINION_IND ; Get the current minion index
33 11a0 bc 5a 17 ldy minion_status ,x ; Get the minion status
34 11a3 c0 01 cpy #$01 ; Is it laser minion?
35 11a5 f0 06 beq draw_laser_minion ; If so draw it
36 11a7 c0 02 cpy #$02 ; Is it rocket minion?
37 11a9 f0 14 beq draw_rocket_minion ; Draw it
38 11ab d0 21 bne end_draw_minion ; Otherwise dont draw a thing
39 11ad draw_laser_minion
40 11ad a6 5e ldx MINION_IND ; Get the current minion index
41 11af bc 69 17 ldy minion_pos ,x ; Get the position of the minion
42 11b2 a9 11 lda #$11 ; Laser minion char
43 11b4 99 00 1e sta $1e00 ,y ; At the location
44 11b7 a9 02 lda #$02
45 11b9 99 00 96 sta $9600 ,y ; Color location
46 11bc 4c ce 11 jmp end_draw_minion ; Done drawing
47 11bf
48 11bf draw_rocket_minion
49 11bf a6 5e ldx MINION_IND ; Get the current minion index
50 11c1 bc 69 17 ldy minion_pos ,x ; Get the position of the minion
51 11c4 a9 12 lda #$12 ; Rocket minion char
52 11c6 99 00 1e sta $1e00 ,y ; At the location
53 11c9 a9 05 lda #$05
54 11cb 99 00 96 sta $9600 ,y ; Color location
55 11ce
56 11ce end_draw_minion
57 11ce e8 inx ; Next minion
58 11cf 86 5e stx MINION_IND ; store the new minion
59 11d1 e0 0a cpx #$0a ; Are we done drawing minions?
60 11d3 d0 c9 bne draw_minions ; If not keep drawing
61 11d5
62 11d5 60 rts
63 11d6
64 11d6 minion_ai
65 11d6
66 11d6
67 11d6 a6 5e ldx MINION_IND
68 11d8 bd 69 17 lda minion_pos ,x
69 11db 8d 78 17 sta laser_pos
70 11de 20 73 14 jsr writeEnemyShot
71 11e1
72 11e1 20 be 12 jsr randgen ; Generate random number
73 11e4 46 60 lsr RANDNUM ; shift bit 0
74 11e6 90 43 bcc minion_move_right ; If even
75 11e8 b0 01 bcs minion_move_left ; If odd
76 11ea
77 11ea 60 rts
78 11eb
79 11eb minion_move_left
80 11eb a6 5e ldx MINION_IND
81 11ed bd 69 17 lda minion_pos ,x
82 11f0 c9 6e cmp #$6e
83 11f2 f0 74 beq minion_move_end
84 11f4 c9 84 cmp #$84
85 11f6 f0 70 beq minion_move_end
86 11f8 c9 9a cmp #$9a
87 11fa f0 6c beq minion_move_end
88 11fc c9 b0 cmp #$b0
89 11fe f0 68 beq minion_move_end
90 1200 c9 c6 cmp #$c6
91 1202 f0 64 beq minion_move_end
92 1204 c9 dc cmp #$dc
93 1206 f0 60 beq minion_move_end
94 1208
95 1208 a6 5e ldx MINION_IND
96 120a bc 69 17 ldy minion_pos ,x
97 120d 88 dey
98 120e b9 00 1e lda $1e00 ,y
99 1211 c9 11 cmp #$11
100 1213 f0 53 beq minion_move_end
101 1215 c9 12 cmp #$12
102 1217 f0 4f beq minion_move_end
103 1219 88 dey
104 121a b9 00 1e lda $1e00 ,y
105 121d c9 11 cmp #$11
106 121f f0 47 beq minion_move_end
107 1221 c9 12 cmp #$12
108 1223 f0 43 beq minion_move_end
109 1225
110 1225 de 69 17 dec minion_pos ,x
111 1228 4c 68 12 jmp minion_move_end
112 122b
113 122b minion_move_right
114 122b a6 5e ldx MINION_IND
115 122d bd 69 17 lda minion_pos ,x
116 1230 c9 83 cmp #$83
117 1232 f0 34 beq minion_move_end
118 1234 c9 99 cmp #$99
119 1236 f0 30 beq minion_move_end
120 1238 c9 af cmp #$af
121 123a f0 2c beq minion_move_end
122 123c c9 c5 cmp #$c5
123 123e f0 28 beq minion_move_end
124 1240 c9 db cmp #$db
125 1242 f0 24 beq minion_move_end
126 1244 c9 f1 cmp #$f1
127 1246 f0 20 beq minion_move_end
128 1248
129 1248 ; Compare tiles near minion
130 1248 a6 5e ldx MINION_IND
131 124a bc 69 17 ldy minion_pos ,x
132 124d c8 iny
133 124e b9 00 1e lda $1e00 ,y
134 1251 c9 11 cmp #$11
135 1253 f0 13 beq minion_move_end
136 1255 c9 12 cmp #$12
137 1257 f0 0f beq minion_move_end
138 1259 c8 iny
139 125a b9 00 1e lda $1e00 ,y
140 125d c9 11 cmp #$11
141 125f f0 07 beq minion_move_end
142 1261 c9 12 cmp #$12
143 1263 f0 03 beq minion_move_end
144 1265
145 1265 fe 69 17 inc minion_pos ,x
146 1268
147 1268 minion_move_end
148 1268
149 1268 e8 inx
150 1269 86 5e stx MINION_IND
151 126b
152 126b e4 5d cpx MINIONS
153 126d f0 03 beq minion_ai_end
154 126f 20 d6 11 jsr minion_ai
155 1272
156 1272 minion_ai_end
157 1272 60 rts
158 1273
159 1273 minion_collision
160 1273 a6 5e ldx MINION_IND
161 1275 bd 5a 17 lda minion_status ,x
162 1278 c9 00 cmp #$00 ; Check if the minion is already dead
163 127a f0 11 beq minion_collision_next
164 127c
165 127c a6 5e ldx MINION_IND
166 127e bc 69 17 ldy minion_pos ,x
167 1281
168 1281 b9 00 1e lda $1e00 ,y
169 1284 c9 10 cmp #$10
170 1286 d0 05 bne minion_collision_next
171 1288 a5 5e lda MINION_IND
172 128a 20 97 12 jsr kill_minion
173 128d
174 128d minion_collision_next
175 128d e8 inx ; Increment minion index
176 128e 86 5e stx MINION_IND ; Save it
177 1290
178 1290 e4 5d cpx MINIONS ; At the end of minions?
179 1292 f0 02 beq minion_collision_end
180 1294 d0 dd bne minion_collision
181 1296
182 1296 minion_collision_end
183 1296 60 rts
184 1297
185 1297 kill_minion
186 1297 aa tax
187 1298 bc 69 17 ldy minion_pos ,x ; Get the position
188 129b a9 13 lda #$13 ; Death animation
189 129d 99 00 1e sta $1e00 ,y
190 12a0 a9 02 lda #$02
191 12a2 99 00 96 sta $9600 ,y ; Color location
192 12a5
193 12a5 a6 5e ldx MINION_IND
194 12a7 a9 00 lda #$00 ; death status
195 12a9 9d 5a 17 sta minion_status ,x ; Update minion status
196 12ac
197 12ac 60 rts
198 12ad
------- FILE game.asm
------- FILE utilities.asm LEVEL 2 PASS 2
0 12ad include "utilities.asm"
1 12ad ;-------------------------------------------------------
2 12ad ; Math utility subroutines and Random number generation
3 12ad ;
4 12ad ;-------------------------------------------------------
5 12ad seedgen
6 12ad a5 8b lda $8b ; Get rnd seed 1 from kernel
7 12af 4d 14 91 eor $9114 ; Exclusive or it with timer 1 low byte
8 12b2 85 61 sta SEED+0 ; store it in the 1st byte of SEED
9 12b4 a9 8c lda #$8c ; Get rnd seed 2 from kernel
10 12b6 49 8d eor #$8d ; Exclusive or it with rnd seed 3 from kernel
11 12b8 4d 18 91 eor $9118 ; Exclusive or it with timer 2 low byte
12 12bb 85 62 sta SEED+1 ; Store it in 2nd byte of SEED
13 12bd 60 rts
14 12be ;-------------------------------------------------------
15 12be ; Linear Feedback shift register
16 12be ; Generate pseudo random number from seed and store it
17 12be ; Returns 0 to ff number in RANDNUM
18 12be ;-------------------------------------------------------
19 12be randgen
20 12be a2 08 ldx #8 ; Loop counter
21 12c0 a5 61 lda SEED+0 ; Load the 1st byte of the seed
22 12c2 rand1
23 12c2 0a asl ; Arithmetic shift left
24 12c3 26 62 rol SEED+1 ; Rotate left 2nd byte of SEED
25 12c5 90 02 bcc rand2 ; If the bit is cleared (no bit is shifted out) go to rand2
26 12c7 49 2d eor #$2d ; If a bit is shfited out exlusive or feedback
27 12c9 rand2
28 12c9 ca dex ; Decrement loop counter
29 12ca d0 f6 bne rand1 ; Loop if not at 0
30 12cc 85 61 sta SEED+0 ;
31 12ce c9 00 cmp #0 ;
32 12d0 85 60 sta RANDNUM ; Store the resulting random number
33 12d2 60 rts
34 12d3
35 12d3
36 12d3 victoryTheme
37 12d3
38 12d3 ;music goes here
39 12d3
40 12d3 a9 0f lda #$0f ; 15 is the max volume the speakers can be set at. The 1-15 values can be found at p(95,96) of the vic 20 manual
41 12d5 8d 0e 90 sta $900e
42 12d8
43 12d8 playMusicstart
44 12d8
45 12d8
46 12d8 a0 0d ldy #$0d ;start of loop counter, music has 12(or 13 notes, dunno ask jack) notes notes in it (c in hex)
47 12da
48 12da loopMusicStart
49 12da
50 12da a9 1e lda #$1e
51 12dc 98 tya ; transferring y to a in prep to preserve it
52 12dd 48 pha
53 12de 48 pha ; the first thing in the stack is the duration of the music
54 12df
55 12df
56 12df anotherStartLoop
57 12df b9 3a 17 lda victory_notes,y
58 12e2 48 pha ; the music note to play
59 12e3 b9 48 17 lda tune_registers,y ; the register in now in A
60 12e6 aa tax ; the music register is now in x
61 12e7 68 pla ; the music note to play is now in a
62 12e8 9d 00 90 sta $9000,x ; the music note that needs to be played is now active in the indicated register
63 12eb
64 12eb
65 12eb delanStart
66 12eb 20 cb 13 jsr delay
67 12ee 68 pla ; pull the loop count to make a second from the stack
68 12ef aa tax ; loop count now in x
69 12f0 d0 06 bne enddStart
70 12f2 ca dex ; x is decremented down
71 12f3 8a txa ; transfer x to a in preparation to do a push to preserve the decrement value in the stack
72 12f4 48 pha ; push the decrement value into the stack
73 12f5 4c eb 12 jmp delanStart
74 12f8
75 12f8 enddStart
76 12f8 68 pla
77 12f9 a8 tay ; y now contains the index counter thing again
78 12fa
79 12fa a9 00 lda #$00
80 12fc 8d 0a 90 sta SOUND1
81 12ff 8d 0b 90 sta SOUND2
82 1302 8d 0c 90 sta SOUND3
83 1305 88 dey
84 1306 c0 01 cpy #$01
85 1308 f0 03 beq endd2Start
86 130a
87 130a 4c da 12 jmp loopMusicStart
88 130d
89 130d endd2Start
90 130d ;jmp playMusicGainzOver
91 130d 60 rts
92 130e
93 130e
------- FILE game.asm
53 130e
54 130e 4c 0d 10 jmp title
55 1311
56 1311 ;---------------------------Initialization-----------------------------------
57 1311 draw_init
58 1311
59 1311 a9 08 lda #$08 ; load new black background colour
60 1313 8d 0f 90 sta SCRCOLOR ; change background and border colours
61 1316
62 1316 a9 ff lda #$ff ; loading the value into $9005 makes the VIC not look into the rom location for characters, instead the vic looks at memory starting at $1c00
63 1318 8d 05 90 sta $9005 ; the above can be found on pages 85 and 86 of the VIC 20 manual
64 131b
65 131b 20 5f e5 jsr CLRSCRN ; clear screen
66 131e
67 131e ; Draw hearts
68 131e ;lda #$02 ; Heart character
69 131e ;sta $1fe4
70 131e ;sta $97e4
71 131e ;sta $1fe5
72 131e ;sta $97e5
73 131e ;sta $1fe6
74 131e ;sta $97e6
75 131e
76 131e
77 131e init
78 131e ;------------------------------Game state/variable initialization-----------------------------
79 131e a9 c2 lda #$c2
80 1320 85 58 sta PLAYER_POS ; We are treating this location as ram, it contains the offset to add to the screen
81 1322 a0 03 ldy #$03
82 1324 84 57 sty PLAYER_HEALTH
83 1326
84 1326 20 ad 12 jsr seedgen
85 1329 20 55 10 jsr spawn_boss
86 132c 20 77 11 jsr spawn_minions
87 132f
88 132f a2 00 ldx #$00
89 1331 86 5b stx SCORE
90 1333 86 5c stx HISCORE
91 1335 86 5f stx LEVEL
92 1337 86 5e stx MINION_IND
93 1339 a2 0a ldx #$0a
94 133b 86 5d stx MINIONS
95 133d
96 133d ;----------------------------------music loop----------------------------------
97 133d
98 133d a9 0f lda #$0f ; 15 is the max volume the speakers can be set at. The 1-15 values can be found at p(95,96) of the vic 20 manual
99 133f 8d 0e 90 sta $900e ; 900e controls volume, is where the volume values are written to. this address can be found at p(95,96) of the vic 20 manual
100 1342
101 1342 playMusic
102 1342
103 1342 a0 23 ldy #$23 ;start of loop counter, music has 35 notes in it (23 in hex)
104 1344
105 1344 loopMusic
106 1344
107 1344 a9 02 lda #$02 ; Duration of each note
108 1346 98 tya ; transferring y to a in prep to preserve it
109 1347 48 pha
110 1348 48 pha ; the first thing in the stack is the duration of the music
111 1349
112 1349 anotherLoop
113 1349 b9 e4 16 lda main_notes,y
114 134c 48 pha ; the music note to play
115 134d b9 08 17 lda main_music_registers,y ; the register in now in A
116 1350 aa tax ; the music register is now in x
117 1351 68 pla ; the music note to play is now in a
118 1352 9d 00 90 sta $9000,x ; the music note that needs to be played is now active in the indicated register
119 1355 delan
120 1355 20 7d 13 jsr gameloop
121 1358 20 cb 13 jsr delay
122 135b 68 pla ; pull the loop count to make a second from the stack
123 135c aa tax ; loop count now in x
124 135d d0 06 bne endd
125 135f ca dex ; x is decremented down
126 1360 8a txa ; transfer x to a in preparation to do a push to preserve the decrement value in the stack
127 1361 48 pha ; push the decrement value into the stack
128 1362 4c 55 13 jmp delan
129 1365
130 1365 endd
131 1365 68 pla
132 1366 a8 tay ; y now contains the index counter thing again
133 1367
134 1367 a9 00 lda #$00
135 1369 8d 0a 90 sta SOUND1
136 136c 8d 0b 90 sta SOUND2
137 136f 8d 0c 90 sta SOUND3
138 1372 88 dey
139 1373 c0 01 cpy #$01
140 1375 f0 03 beq endd2
141 1377
142 1377 4c 44 13 jmp loopMusic
143 137a
144 137a endd2
145 137a 4c 42 13 jmp playMusic
146 137d
147 137d ;-------------------------------Main game loop-------------------------------
148 137d
149 137d gameloop
150 137d
151 137d 20 5f e5 jsr CLRSCRN
152 1380 20 2c 16 jsr DrawHearts
153 1383
154 1383 a5 c5 lda $00c5 ; get current pressed key
155 1385 c9 20 cmp #32
156 1387 d0 03 bne no_shoot
157 1389 20 4b 15 jsr writePlayerShot
158 138c
159 138c no_shoot
160 138c 8d 5a 16 sta key_pressed
161 138f
162 138f 20 70 15 jsr drawPlayerShot
163 1392 20 99 14 jsr drawEnemyShot
164 1395
165 1395 20 48 10 jsr player_collision
166 1398 20 73 12 jsr minion_collision
167 139b 20 f0 10 jsr boss_collision
168 139e
169 139e a6 5a ldx BOSS_HEALTH
170 13a0 e0 00 cpx #$00 ; Is the boss dead?
171 13a2 f0 06 beq no_boss ; If so dont draw it
172 13a4 20 5e 10 jsr draw_boss
173 13a7 20 d1 10 jsr boss_ai
174 13aa no_boss
175 13aa a2 00 ldx #$00 ; Reset minion index counter
176 13ac 86 5e stx MINION_IND
177 13ae 20 9e 11 jsr draw_minions ; Draw minions
178 13b1 20 58 14 jsr moveplayer
179 13b4 a2 00 ldx #$00 ; Reset minion index counter
180 13b6 86 5e stx MINION_IND
181 13b8 20 d6 11 jsr minion_ai
182 13bb a2 00 ldx #$00
183 13bd 86 5e stx MINION_IND
184 13bf 20 cb 13 jsr delay
185 13c2 20 d9 13 jsr collisioncheck
186 13c5
187 13c5 a9 40 lda #64 ; reset the key pressed
188 13c7 8d 5a 16 sta key_pressed
189 13ca
190 13ca 60 rts
191 13cb
192 13cb
193 13cb delay ; (p 171 a0-a02 jiffy clock) p204 - 205 settim
194 13cb a9 fc LDA #$fc ; 4F1A01, the max value the clock can be at, goes back to 0 after
195 13cd a2 19 LDX #$19
196 13cf a0 4f LDY #$4f
197 13d1 20 67 f7 JSR $f767
198 13d4 dosum
199 13d4 a5 a0 LDA $A0
200 13d6 d0 fc BNE dosum
201 13d8 60 rts
202 13d9
203 13d9
204 13d9 collisioncheck
205 13d9
206 13d9 a6 58 ldx PLAYER_POS
207 13db e0 b8 cpx #$b8
208 13dd f0 09 beq predec_player_health
209 13df
210 13df a6 58 ldx PLAYER_POS
211 13e1 e0 cd cpx #$cd
212 13e3 f0 08 beq predec_player_health2
213 13e5
214 13e5 4c 01 14 jmp next3
215 13e8
216 13e8
217 13e8 predec_player_health
218 13e8 a9 12 lda #18 ; reset the key pressed
219 13ea 4c ef 13 jmp next2
220 13ed
221 13ed predec_player_health2
222 13ed a9 11 lda #17 ; reset the key pressed
223 13ef next2
224 13ef 8d 5a 16 sta key_pressed
225 13f2 20 58 14 jsr moveplayer
226 13f5
227 13f5
228 13f5 decr_player_health
229 13f5
230 13f5 20 02 14 jsr update_player_health
231 13f8 a4 57 ldy PLAYER_HEALTH
232 13fa c0 00 cpy #$00
233 13fc d0 03 bne next3
234 13fe 20 0d 14 jsr gameover
235 1401
236 1401 next3
237 1401 60 rts
238 1402
239 1402
240 1402 update_player_health
241 1402 a6 57 ldx PLAYER_HEALTH
242 1404 ca dex
243 1405 a9 00 lda #$00 ; blank
244 1407 9d e4 1f sta $1fe4 ,x
245 140a 86 57 stx PLAYER_HEALTH
246 140c 60 rts
247 140d
248 140d
249 140d gameover
250 140d ;--------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------
251 140d
252 140d ;music goes here
253 140d
254 140d a9 0f lda #$0f ; 15 is the max volume the speakers can be set at. The 1-15 values can be found at p(95,96) of the vic 20 manual
255 140f 8d 0e 90 sta $900e
256 1412
257 1412 playMusicGainzOver
258 1412
259 1412 a0 0d ldy #$0d ;start of loop counter, music has 12(or 13 notes, dunno ask jack) notes notes in it (c in hex)
260 1414
261 1414
262 1414 loopMusicGainzOver
263 1414
264 1414 a9 04 lda #$04
265 1416 98 tya ; transferring y to a in prep to preserve it
266 1417 48 pha
267 1418 48 pha ; the first thing in the stack is the duration of the music
268 1419
269 1419 anotherGainzLoop
270 1419 b9 2c 17 lda gameover_notes,y
271 141c 48 pha ; the music note to play
272 141d b9 48 17 lda tune_registers,y ; the register in now in A
273 1420 aa tax ; the music register is now in x
274 1421 68 pla ; the music note to play is now in a
275 1422 9d 00 90 sta $9000,x ; the music note that needs to be played is now active in the indicated register
276 1425
277 1425
278 1425 delanGainz
279 1425 20 cb 13 jsr delay
280 1428 68 pla ; pull the loop count to make a second from the stack
281 1429 aa tax ; loop count now in x
282 142a d0 06 bne enddGainz
283 142c ca dex ; x is decremented down
284 142d 8a txa ; transfer x to a in preparation to do a push to preserve the decrement value in the stack
285 142e 48 pha ; push the decrement value into the stack
286 142f 4c 25 14 jmp delanGainz
287 1432
288 1432 enddGainz
289 1432 68 pla
290 1433 a8 tay ; y now contains the index counter thing again
291 1434
292 1434 a9 00 lda #$00
293 1436 8d 0a 90 sta SOUND1
294 1439 8d 0b 90 sta SOUND2
295 143c 8d 0c 90 sta SOUND3
296 143f 88 dey
297 1440 c0 01 cpy #$01
298 1442 f0 03 beq endd2Gainz
299 1444
300 1444 4c 14 14 jmp loopMusicGainzOver
301 1447
302 1447 endd2Gainz
303 1447 ;jmp playMusicGainzOver
304 1447
305 1447
306 1447 ;-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
307 1447 gameover2
308 1447
309 1447 20 5f e5 jsr CLRSCRN ; clear screen
310 144a
311 144a a9 19 lda #$19 ; load new background colour
312 144c 8d 0f 90 sta SCRCOLOR ; change background and border colours
313 144f
314 144f a9 08 lda #$8 ; load new background colour
315 1451 8d 0f 90 sta SCRCOLOR ; change background and border colours
316 1454
317 1454 4c 47 14 jmp gameover2
318 1457
319 1457 60 rts
320 1458
321 1458
322 1458 moveplayer
323 1458
324 1458 a6 58 ldx PLAYER_POS
325 145a ad 5a 16 lda key_pressed
326 145d
327 145d c9 12 cmp #18
328 145f f0 07 beq increment
329 1461
330 1461 c9 11 cmp #17
331 1463 f0 07 beq decrement
332 1465
333 1465 4c 6d 14 jmp next
334 1468
335 1468 increment
336 1468 e8 inx ; increment x by 1 to represent location as current location has moved 1
337 1469 4c 6d 14 jmp next
338 146c decrement
339 146c ca dex
340 146d next
341 146d 86 58 stx PLAYER_POS
342 146f 20 3b 10 jsr draw_player
343 1472
344 1472 end
345 1472 60 rts
346 1473
347 1473 writeEnemyShot
348 1473 ; find the first available space that is #$00
349 1473 ;write #$1e to first value, then the players x position but shifted down 1 on the grid
350 1473 ; calls another subroutine to draw the shot
351 1473 a0 10 ldy #$10 ; this is 2x the number of shots we are allowing to be on screen, the max num is currently 4
352 1475
353 1475 wesLoop
354 1475 b9 d3 16 LDA enemyShots,y ;the "first" thing holds 1e, 1f or 00. if it is 00 we want to write to it
355 1478 c9 00 cmp #$00
356 147a f0 07 beq exitwesLoop
357 147c 88 dey ; dec y so it points to the "suffix" of 1e or 1f
358 147d 88 dey ; dec again so it is pointing to the next prefix of 1e or 1f
359 147e d0 f5 bne wesLoop
360 1480 4c 98 14 jmp endwesLoop ;if the loop finishes without triggering exit, then no #$00 was found
361 1483
362 1483
363 1483 exitwesLoop ;the y register now contains the offset we need to write to for either 1f or 1e
364 1483 a9 1e LDA #$1e
365 1485 99 d3 16 STA enemyShots,y
366 1488 88 dey ;decrement to prepare for storing the suffix to the appropriate area in data
367 1489 98 TYA ; prep y to be pushed to stack for storage
368 148a 48 PHA ; the y index is now in the stack
369 148b
370 148b ad 78 17 lda laser_pos
371 148e
372 148e ;LDA BOSS_POS ;temp placeholder value, replace with boss position
373 148e ; minion_pos with location
374 148e 18 clc
375 148f 69 16 adc #$16
376 1491
377 1491
378 1491 aa TAX ; X is temporarily holding the player pos value
379 1492 68 PLA ; pull the y value into a
380 1493 a8 TAY ;transfer value back to y
381 1494 8a TXA ;transfer the player pos back into A
382 1495 99 d3 16 sta enemyShots ,y ; now the suffix should be properly stored
383 1498
384 1498 endwesLoop
385 1498 60 rts
386 1499
387 1499
388 1499 drawEnemyShot
389 1499 ;pull the first thing from the list that is not 00, draw laser to the specified location, then iterate through the location and repeat
390 1499 ;also need a backstop subroutine to stop the fire from going past the screen in both directions, will likely need 2
391 1499 ;the shot is "incremented up" in this. if it were to hit a backstop then it is reset to 00
392 1499
393 1499 a0 10 ldy #$10 ; this is 2x the number of shots we are allowing to be on screen, the max num is currently 4
394 149b
395 149b desLoop
396 149b b9 d3 16 LDA enemyShots,y ;the "first" thing holds 1e, 1f or 00. if it is 00 we want to write to it
397 149e c9 00 cmp #$00
398 14a0 f0 3b beq enddesLoop
399 14a2
400 14a2 c9 1e cmp #$1e
401 14a4 d0 1b bne nextdes
402 14a6 ;draw the laser then shift it up one
403 14a6 88 dey ; the gets the address ready for the suffix value for the laser
404 14a7 b9 d3 16 LDA enemyShots,y
405 14aa aa TAX ;transfer a to x to get ready for another aaaa ,x to write the laser to memory
406 14ab a9 0f lda #$0f ;load the character of the laser
407 14ad 9d 00 1e sta #$1e00 ,x ; the laser is now stored here, 1f00 + 30,000 = 9430
408 14b0
409 14b0 ;cpy #$02
410 14b0 ;bne skip
411 14b0 ;jsr spinloop
412 14b0
413 14b0
414 14b0 98 TYA
415 14b1 48 PHA
416 14b2 20 0c 15 jsr shiftupfordes ;x will contain the value that was shifted
417 14b5 68 pla
418 14b6 a8 tay ;need to retrieve the y value corresponding to the list
419 14b7
420 14b7 ;cpx #$f2
421 14b7 ;bne skip
422 14b7 ;jsr spinloop
423 14b7
424 14b7 20 16 15 jsr shiftupfordes2
425 14ba
426 14ba
427 14ba
428 14ba
429 14ba ; lda #$05 ;load the character of the laser;debug
430 14ba ;sta #$1f00 ,x ; the laser is now stored here, 1f00 + 30,000 = 9430 ;debug
431 14ba
432 14ba
433 14ba ;cpx #$08
434 14ba ;bne skip
435 14ba ;jsr spinloop
436 14ba
437 14ba
438 14ba
439 14ba 8a TXA ; the offset of x calculated is now in a for a aaaa,y address
440 14bb 99 d3 16 STA enemyShots ,y
441 14be
442 14be 4c d9 14 jmp enddesLoop2
443 14c1 skip
444 14c1 nextdes
445 14c1
446 14c1 88 dey ; the gets the address ready for the suffix value for the laser
447 14c2 b9 d3 16 LDA enemyShots ,y
448 14c5 aa TAX ;transfer a to x to get ready for another aaaa ,x to write the laser to memory
449 14c6 a9 0f lda #$0f ;load the character of the laser
450 14c8
451 14c8 9d 00 1f sta #$1f00 ,x ; the laser is now stored here, 1f00 + 30,000 = 9430
452 14cb ;lda #$04 ;color code
453 14cb ;sta 9430 ,x ; x currently contains the offset we want to shift up
454 14cb
455 14cb ;cpx #$08
456 14cb ;bne skip
457 14cb ;jsr spinloop