-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathC.A.V.E. Apocalypse.bas
1797 lines (1532 loc) · 47.1 KB
/
C.A.V.E. Apocalypse.bas
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
inline PlusROM_functions.asm
set kernel_options pfcolors player1colors
set romsize 16kSC
set smartbranching on
;#region "Defines and Constants"
const pfres=4
const pfscore=1
const scorebkcolor=$08
const textbkcolor=$08
rem gravity is acceleration (https://atariage.com/forums/topic/226881-gravity/?do=findComment&comment=3017307)
rem by AA user bogax (https://atariage.com/forums/profile/22687-bogax/)
rem the smallest fraction is 1/256 rounded up here to 0.004
rem assuming gravity is applied each drawscreen this should
rem work out to ~7 pixels in 1 second, 28 pixels in 2 seconds
rem 63 pixels in 3 seconds
def gravity_player1=0.004
def gravity_ball=0.008
def gravity_missile0=0.024
const player_min_x = 10
const player_max_x = 134
const player_min_y = 2
const player_max_y = 76
const _M_Edge_Top = 2
const _M_Edge_Bottom = 88
const _M_Edge_Left = 14
const _M_Edge_Right = 148
const response_size_minus_1 = 30 ; = (w127 - w_room_definition_start - 1)
const response_menu_size = 6
const game_state_run = 0
const game_state_game_over = 1
const game_state_level_finished = 2
const game_state_heli_explosion = 3
def bonus_level_timer=100
def bonus_level_lives=200
def bonus_hit_wall=10
def bonus_hit_active_wall=30
def bonus_hit_air_missile=40
def bonus_hit_tank=60
def bonus_man_rescue=150
;#endregion
;#region "NTSC Constants and Colors"
; requests
const req_load = 0
const req_level_up = 1
const req_game_over = 2
const req_move_left = 3
const req_move_up = 4
const req_move_right = 5
const req_move_down = 6
const req_level_reset = 7
const req_safe_point = 8
const req_load_menu = 9
; colors
const _00 = $00
const _02 = $02
const _04 = $04
const _06 = $06
const _08 = $08
const _0A = $0A
const _0C = $0C
const _0E = $0E
const _10 = $10
const _12 = $12
const _14 = $14
const _16 = $16
const _18 = $18
const _1A = $1A
const _1C = $1C
const _1E = $1E
const _20 = $20
const _22 = $22
const _24 = $24
const _26 = $26
const _28 = $28
const _2A = $2A
const _2C = $2C
const _2E = $2E
const _30 = $30
const _32 = $32
const _34 = $34
const _36 = $36
const _38 = $38
const _3A = $3A
const _3C = $3C
const _3E = $3E
const _40 = $40
const _42 = $42
const _44 = $44
const _46 = $46
const _48 = $48
const _4A = $4A
const _4C = $4C
const _4E = $4E
const _50 = $50
const _52 = $52
const _54 = $54
const _56 = $56
const _58 = $58
const _5A = $5A
const _5C = $5C
const _5E = $5E
const _60 = $60
const _62 = $62
const _64 = $64
const _66 = $66
const _68 = $68
const _6A = $6A
const _6C = $6C
const _6E = $6E
const _70 = $70
const _72 = $72
const _74 = $74
const _76 = $76
const _78 = $78
const _7A = $7A
const _7C = $7C
const _7E = $7E
const _80 = $80
const _82 = $82
const _84 = $84
const _86 = $86
const _88 = $88
const _8A = $8A
const _8C = $8C
const _8E = $8E
const _90 = $90
const _92 = $92
const _94 = $94
const _96 = $96
const _98 = $98
const _9A = $9A
const _9C = $9C
const _9E = $9E
const _A0 = $A0
const _A2 = $A2
const _A4 = $A4
const _A6 = $A6
const _A8 = $A8
const _AA = $AA
const _AC = $AC
const _AE = $AE
const _B0 = $B0
const _B2 = $B2
const _B4 = $B4
const _B6 = $B6
const _B8 = $B8
const _BA = $BA
const _BC = $BC
const _BE = $BE
const _C0 = $C0
const _C2 = $C2
const _C4 = $C4
const _C6 = $C6
const _C8 = $C8
const _CA = $CA
const _CC = $CC
const _CE = $CE
const _D0 = $D0
const _D2 = $D2
const _D4 = $D4
const _D6 = $D6
const _D8 = $D8
const _DA = $DA
const _DC = $DC
const _DE = $DE
const _E0 = $E0
const _E2 = $E2
const _E4 = $E4
const _E6 = $E6
const _E8 = $E8
const _EA = $EA
const _EC = $EC
const _EE = $EE
const _F0 = $F0
const _F2 = $F2
const _F4 = $F4
const _F6 = $F6
const _F8 = $F8
const _FA = $FA
const _FC = $FC
const _FE = $FE
;#endregion
/*
;#region "PAL Constants and Colors"
; requests
const req_load = 128 ; PAL x+128
const req_level_up = 129
const req_game_over = 130
const req_move_left = 131
const req_move_up = 132
const req_move_right = 133
const req_move_down = 134
const req_level_reset = 135
const req_safe_point = 136
const req_load_menu = 137
; colors
const _00 = $00
const _02 = $02
const _04 = $04
const _06 = $06
const _08 = $08
const _0A = $0A
const _0C = $0C
const _0E = $0E
const _10 = $20
const _12 = $22
const _14 = $24
const _16 = $26
const _18 = $28
const _1A = $2A
const _1C = $2C
const _1E = $2E
const _20 = $40
const _22 = $42
const _24 = $44
const _26 = $46
const _28 = $48
const _2A = $4A
const _2C = $4C
const _2E = $4E
const _30 = $40
const _32 = $42
const _34 = $44
const _36 = $46
const _38 = $48
const _3A = $4A
const _3C = $4C
const _3E = $4E
const _40 = $60
const _42 = $62
const _44 = $64
const _46 = $66
const _48 = $68
const _4A = $6A
const _4C = $6C
const _4E = $6E
const _50 = $80
const _52 = $82
const _54 = $84
const _56 = $86
const _58 = $88
const _5A = $8A
const _5C = $8C
const _5E = $8E
const _60 = $A0
const _62 = $A2
const _64 = $A4
const _66 = $A6
const _68 = $A8
const _6A = $AA
const _6C = $AC
const _6E = $AE
const _70 = $C0
const _72 = $C2
const _74 = $C4
const _76 = $C6
const _78 = $C8
const _7A = $CA
const _7C = $CC
const _7E = $CE
const _80 = $D0
const _82 = $D2
const _84 = $D4
const _86 = $D6
const _88 = $D8
const _8A = $DA
const _8C = $DC
const _8E = $DE
const _90 = $B0
const _92 = $B2
const _94 = $B4
const _96 = $B6
const _98 = $B8
const _9A = $BA
const _9C = $BC
const _9E = $BE
const _A0 = $90
const _A2 = $92
const _A4 = $94
const _A6 = $96
const _A8 = $98
const _AA = $9A
const _AC = $9C
const _AE = $9E
const _B0 = $70
const _B2 = $72
const _B4 = $74
const _B6 = $76
const _B8 = $78
const _BA = $7A
const _BC = $7C
const _BE = $7E
const _C0 = $50
const _C2 = $52
const _C4 = $54
const _C6 = $56
const _C8 = $58
const _CA = $5A
const _CC = $5C
const _CE = $5E
const _D0 = $30
const _D2 = $32
const _D4 = $34
const _D6 = $36
const _D8 = $38
const _DA = $3A
const _DC = $3C
const _DE = $3E
const _E0 = $20
const _E2 = $22
const _E4 = $24
const _E6 = $26
const _E8 = $28
const _EA = $2A
const _EC = $2C
const _EE = $2E
const _F0 = $20
const _F2 = $22
const _F4 = $24
const _F6 = $26
const _F8 = $28
const _FA = $2A
const _FC = $2C
const _FE = $2E
;#endregion
*/
;#region "Zeropage Variables"
dim _sc1 = score
dim _sc2 = score+1
dim _sc3 = score+2
dim delay_counter = a
dim frame_counter = b
dim _BitOp_Ball_Shot_Dir = c
dim _Bit0_Ball_Shot_Dir_Left1 = c
dim _Bit1_Ball_Shot_Dir_Left2 = c
dim _Bit2_Ball_Shot_Dir_Right1 = c
dim _Bit3_Ball_Shot_Dir_Right2 = c
dim _BitOp_M0_Dir = d
dim _Bit0_M0_Dir_Up = d
dim _Bit1_M0_Dir_Down = d
dim _Bit2_M0_Dir_Left = d
dim _Bit3_M0_Dir_Right = d
dim _BitOp_P1_Dir = e
dim _Bit0_P1_Dir_Up = e
dim _Bit1_P1_Dir_Down = e
dim _Bit2_P1_Dir_Left = e
dim _Bit3_P1_Dir_Right = e
; Channel 0 sound variables.
dim _Ch0_Sound = f
dim _Ch0_Duration = g
dim _Ch0_Counter = h
; extra wall
dim extra_wall_move_x = i
dim roommate_move_x = j
dim roommate_type = k
dim _BitOp_Flip_positions = l
dim _Bit0_New_Room_P1_Flip = l
dim _Bit1_Safe_Point_P1_Flip = l
dim Safe_Point_P1_x = m
dim Safe_Point_P1_y = n
dim _Ch1_Duration = o
rem 16 bit velocity
dim Bally_velocity = p.q
rem 16 bit ball y position
dim Bally_position = ball_shoot_y.r
rem 16 bit velocity
dim M0y_velocity = s.t
rem 16 bit missile0 y position
dim M0y_position = missile0y.u
rem 16 bit velocity
dim P1y_velocity = v.w
rem 16 bit player1 y position
dim P1y_position = player1y.x
rem Various game states
dim _Bit_Game_State = y
dim _Bit0_Rotor_Sound_On = y
dim _Bit2_roommate_Dir = y ; direction of enemy (P0) or soldiers (P0), (0=right, 1=left)
dim _Bit3_Safe_Point_reached = y
dim _Bit4_Wall_Dir = y ; direction of moveable wall (Ball), (0=right, 1=left)
dim _Bit5_Request_Pending = y
dim _Bit6_Flip_P1 = y
dim _Bit7_FireB_Restrainer = y
dim rand16 = z ; z don't gets zeroed !
; SC RAM so var0-var47 are free for general use
dim new_room_player1y = var0
dim new_room_player1x = var1
dim gamenumber = var2
dim max_pub_level_bcd1 = var3
dim max_pub_level_bcd2 = var4
dim max_pub_level_bcd3 = var5
dim max_priv_level_bcd1 = var6
dim max_priv_level_bcd2 = var7
dim max_priv_level_bcd3 = var8
dim has_private_levels = var9
dim ball_shoot_x = var10
dim ball_shoot_y = var11
dim men_to_rescue = var12 ; men_to_rescue_index = TextIndex
dim TextIndex = var12
dim bonus_bcd_counter = var13
dim enemy_game_state = var14
dim next_shoot_rand = var16
dim Game_Status = var47
; Move text of Text Minikernel to SC RAM, so message could be loaded from backend
; or message can be modified by code (e.g. counter how many men left to rescue)
; dim w_textArea_1 = w000
; dim r_textArea_1 = r000
; dim text_strings = r000
;#endregion
;#region "SuperChip RAM Variables"
; used for room definitions before playfield area (w112/r112)
dim w_room_definition_start = w093
dim r_level_bonus_bcd_points = r093
dim w_level_bonus_bcd_points = w093
dim r_men_to_rescue_in_this_level= r094
dim w_men_to_rescue_in_this_level= w094
dim r_BitOp_room_type = r095
dim w_BitOp_room_type = w095
dim r_room_color_top = r096
dim w_room_color_top = w096
dim r_room_color_middle = r097
dim w_room_color_middle = w097
dim r_room_color_waste1 = r098
dim w_room_color_waste1 = w098
dim r_room_color_waste2 = r099
dim w_room_color_waste2 = w099
dim r_room_color_waste3 = r100
dim w_room_color_waste4 = w100
dim r_room_color_bottom = r101
dim w_room_color_bottom = w101
dim r_roommate_type_and_range = r102 ; $03 is P0 type (00=enemy, 01=air missile, 10=Fuel station, 11=soldier)
dim w_roommate_type_and_range = w102 ; $FC and $03 is moving range to the right
dim r_roommate_startpos_x = r103
dim w_roommate_startpos_x = w103
dim r_roommate_startpos_y = r104
dim w_roommate_startpos_y = w104
dim r_extra_wall_type_and_range = r105 ; type ($03) and wall range or blink frequenz (laser!)
dim w_extra_wall_type_and_range = w105
dim r_extra_wall_width = r106 ; wall width (D4 and D5) for CTRLPF
dim w_extra_wall_width = w106
dim r_extra_wall_height = r107 ; wall height default (23)
dim w_extra_wall_height = w107
dim r_extra_wall_startpos_1_x = r108
dim w_extra_wall_startpos_1_x = w108
dim r_extra_wall_startpos_1_y = r109 ; default 47
dim w_extra_wall_startpos_1_y = w109
dim r_extra_wall_startpos_2_x = r110
dim w_extra_wall_startpos_2_x = w110
dim r_extra_wall_startpos_2_y = r111 ; default 200
dim w_extra_wall_startpos_2_y = w111
dim r_Bit0_room_type_top = r_BitOp_room_type
dim w_Bit0_room_type_top = w_BitOp_room_type
;#endregion
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;#region "Bank 1"
_Start
asm
lda #0
ldx #74
.clear_ram
dex
sta var0,x
bne .clear_ram
end
WriteSendBuffer = req_load_menu : _Bit5_Request_Pending{5} = 1 : COLUP0 = _1C : scorecolor = _0E
score = 1
gamenumber = 1 : missile0height = 1 : _Ch1_Duration = 1
_Bit7_FireB_Restrainer{7} = 1
new_room_player1y = player_min_y : Safe_Point_P1_y = player_min_y
new_room_player1x = 30 : player1x = 30 : Safe_Point_P1_x = 30
AUDF1 = 31
AUDV0 = 0 : AUDV1 = 0 : AUDC1 = 0 : frame_counter = 0 : player0x = 0 : bally = 0 : player1y = 0
missile0x = 200 : missile0y = 200 : w_extra_wall_startpos_1_x = 200 : w_roommate_startpos_y = 200 : player0y = 200
; set default text for Text Minikernel in SC RAM
; w000 = #_sp : w001 = #__2 : w002 = #_sp : w003 = #__M : w004 = #__E : w005 = #__N
; w006 = #_sp : w007 = #__L : w008 = #__E : w009 = #__F : w010 = #__T : w011 = #_sp
pfclear
gosub _Set_Player_1_Colors
goto _titlescreen_menu bank2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;#region "Main Loop"
__Main_Loop
if switchreset then goto _Reset_To_Start
COLUPF = r_room_color_top
NUSIZ1 = $05
NUSIZ0 = $10
COLUBK = _00
TextColor = $0E
if Game_Status <> 3 then _player_alive
temp4 = frame_counter / 8
on temp4 goto _explosion_4_p1 _explosion_4_p1 _explosion_3_p1 _explosion_2_p1 _explosion_2_p1 _explosion_1_p1 _explosion_1_p1 _explosion_0_p1
_player_alive
if !frame_counter{2} then _player_second_frame
player1:
%00011011
%00001110
%00011111
%10111101
%11111001
%10011110
%00001000
%01111100
end
goto _roommate_def_start
_player_second_frame
player1:
%00011011
%00001110
%00011111
%10111101
%11111001
%10011110
%00001000
%00011111
end
goto _roommate_def_start
_explosion_0_p1
player1:
%00000000
%01001010
%00111100
%00111100
%00111100
%00111100
%01010010
%00000000
end
goto _End_Explosion_Definition
_explosion_1_p1
player1:
%01111110
%11011111
%11111111
%11111110
%11111111
%11111101
%11111111
%01111010
end
goto _End_Explosion_Definition
_explosion_2_p1
player1:
%00000000
%00011000
%00111100
%00111100
%00101100
%00111100
%00011000
%00000000
end
goto _End_Explosion_Definition
_explosion_3_p1
player1:
%00000000
%00000000
%00000000
%00010100
%00000000
%00101010
%00000100
%00010000
%00000000
end
goto _End_Explosion_Definition
_explosion_4_p1
player1:
%00000000
%00000000
%00000000
%00001000
%00100100
%01000000
%10001001
%01000000
%01000010
%00101100
end
_End_Explosion_Definition
if frame_counter then _roommate_def_start
Game_Status = game_state_run
gosub _Set_Player_1_Colors
goto _Decrease_live_counter
_roommate_def_start
on roommate_type goto _roommate_Enemy_def _roommate_Air_Missile_def _roommate_Fuel_def _roommate_Soldier_def
_roommate_Enemy_def
if !enemy_game_state then _enemy_alive
temp4 = frame_counter / 8
; 5 Enemy explosion animation frames
; ToDo: If the helicopter also explodes during the enemy explosion, the frame_counter is set to 63!
; Workaround: Have 8 frames here too !
on temp4 goto _enemy_expl_0 _enemy_expl_1 _enemy_expl_2 _enemy_expl_3 _enemy_expl_4 _enemy_expl_4 _enemy_expl_4 _enemy_expl_4
_enemy_alive
if !frame_counter{2} then _enemy_second_frame
player0:
%01010101
%10101010
%11111111
%00111100
%00011000
%00001000
%00000100
end
goto _roommate_End_def
_enemy_second_frame
player0:
%10101010
%01010101
%11111111
%00111100
%00011000
%00001000
%00000100
end
goto _roommate_End_def
_enemy_expl_0
player0:
%00000000
%00000000
%00000000
%00000000
%00000000
%00001000
%00000010
%00100100
%10010000
%01000001
%00101000
end
COLUP0 = _04
goto _roommate_explosion_End_def
_enemy_expl_1
player0:
%00000000
%00000000
%00000000
%00010100
%01000000
%00000000
%00100100
%00010000
end
COLUP0 = _42
goto _roommate_explosion_End_def
_enemy_expl_2
player0:
%00000000
%00000000
%00111100
%01110110
%01111110
%01011110
%00101100
end
COLUP0 = _46
goto _roommate_explosion_End_def
_enemy_expl_3
player0:
%01111101
%01111110
%11111111
%11111111
%11111111
%01101111
%00111110
%01011001
%10001000
end
COLUP0 = _4A
goto _roommate_explosion_End_def
_enemy_expl_4
player0:
%10101010
%01010101
%11111111
%00000000
%01000000
%01100000
%01110000
%01111000
%01000000
end
COLUP0 = _4E
_roommate_explosion_End_def
; Clear enemy or air missile from screen and reset player color if animation is over.
if !frame_counter then enemy_game_state = 0: COLUP0 = _1C : player0y = 200
goto _roommate_End_def
_roommate_Air_Missile_def
if !enemy_game_state then _Air_Missile_alive
temp4 = frame_counter / 8
; 5 Enemy explosion animation frames
; ToDo: If the helicopter also explodes during the enemy explosion, the frame_counter is set to 63!
; Workaround: Have 8 frames here too !
on temp4 goto _enemy_air_expl_0 _enemy_air_expl_1 _enemy_air_expl_2 _enemy_air_expl_2 _enemy_air_expl_3 _enemy_air_expl_3 _enemy_air_expl_3 _enemy_air_expl_3
_Air_Missile_alive
player0:
%10100000
%01000000
%11100000
%10100000
%01000000
%00000000
%00000000
%00000101
%00000010
%00000111
%00000101
%00000010
end
goto _roommate_End_def
_enemy_air_expl_0
player0:
%00010000
%00000100
%00000001
%00000000
%00000000
%00000010
%00000000
%00000000
%01000000
%00000000
%10000001
%00101000
end
COLUP0 = _04
goto _roommate_explosion_End_def
_enemy_air_expl_1
player0:
%00101000
%00000000
%00000001
%00000000
%00100000
%10000000
%00100000
%00000000
%00000000
end
COLUP0 = _44
goto _roommate_explosion_End_def
_enemy_air_expl_2
player0:
%01111110
%11111111
%11011111
%11111111
%11111111
%11111111
%11111111
%11111111
%11111111
%11111101
%11111011
%01111110
end
COLUP0 = _4A
goto _roommate_explosion_End_def
_enemy_air_expl_3
player0:
%01001000
%01010000
%11100000
%11111000
%11100000
%01010000
%01001000
%00000111
%00011111
%00000111
%00001010
%00010010
end
COLUP0 = _4E
goto _roommate_explosion_End_def
_roommate_Fuel_def
player0:
%00111100
%00100000
%00100000
%00100000
%00100000
%00000000
%00111100
%00100000
%00111000
%00100000
%00111100
%00000000
%00011000
%00100100
%00100100
%00100100
%00100100
%00000000
%00100000
%00100000
%00111000
%00100000
%10111101
%10000001
%11111111
end
goto _roommate_End_def
_roommate_Soldier_def
if frame_counter{2} then player0:
%10100110
%01000010
%01100011
%01000010
end
if !frame_counter{2} then player0:
%11000101
%01000010
%01100011
%01000010
end
_roommate_End_def
; compute movement of enemies, soldiers or wall (laser)
if !frame_counter{4} then _Skip_Wall_Movement
if r_extra_wall_type_and_range{1} || r_extra_wall_type_and_range < 2 then _Finish_Interior_Movement
if _Bit4_Wall_Dir{4} then extra_wall_move_x = extra_wall_move_x - 1 else extra_wall_move_x = extra_wall_move_x + 1
if extra_wall_move_x = r_extra_wall_type_and_range then _Bit4_Wall_Dir{4} = 1
if !extra_wall_move_x then _Bit4_Wall_Dir{4} = 0
goto _Finish_Interior_Movement
_Skip_Wall_Movement
if r_roommate_type_and_range < 4 || enemy_game_state then _Finish_Interior_Movement
if _Bit2_roommate_Dir{2} then roommate_move_x = roommate_move_x - 1 else roommate_move_x = roommate_move_x + 1
if roommate_move_x = r_roommate_type_and_range then _Bit2_roommate_Dir{2} = 1
if !roommate_move_x then _Bit2_roommate_Dir{2} = 0
_Finish_Interior_Movement
frame_counter = frame_counter - 1
; Check for extra wall and enemy shot (ball)
if r_extra_wall_startpos_1_x = 200 then _Skip_extra_Wall
if _BitOp_Ball_Shot_Dir && frame_counter{0} then _Skip_extra_Wall
if !r_extra_wall_width && frame_counter{1} then _Set_Second_Wall_pos
if r_extra_wall_type_and_range{1} && frame_counter < r_extra_wall_type_and_range then _Set_Second_Wall_pos
if r_extra_wall_startpos_2_x <> 200 && !r_extra_wall_type_and_range{1} && frame_counter{1} then _Set_Second_Wall_pos
bally = r_extra_wall_startpos_1_y : ballx = r_extra_wall_startpos_1_x + extra_wall_move_x
goto _Skip_Second_Wall_pos
_Set_Second_Wall_pos
bally = r_extra_wall_startpos_2_y : ballx = r_extra_wall_startpos_2_x + extra_wall_move_x
_Skip_Second_Wall_pos
ballheight = r_extra_wall_height
CTRLPF = r_extra_wall_width | 1 ; Set Ball wide ($00=1, $10=2, $20=4, $30=8).
goto _Skip_ball_shot
_Skip_extra_Wall
if !_BitOp_Ball_Shot_Dir then _Skip_ball_shot
ballx = ball_shoot_x
bally = ball_shoot_y
ballheight = 1
CTRLPF = %00010001 ; Set Ball 2 pixels wide.
_Skip_ball_shot
; Check for enemy
if r_roommate_startpos_y = 200 then _Skip_enemy
player0x = r_roommate_startpos_x + roommate_move_x
player0y = r_roommate_startpos_y
_Skip_enemy
; Check buffer and request status
if delay_counter then delay_counter = delay_counter - 1 : temp4 = SWCHA : goto _skip_game_action
if _Bit5_Request_Pending{5} && ReceiveBufferSize > response_size_minus_1 then goto _Change_Room
if _Bit5_Request_Pending{5} then temp4 = SWCHA : goto _skip_game_action ; game over screen or wait for new room
; 0=run, 1=game_over , 2=level finished, 3=heli_explosion
on Game_Status goto _game_action _game_over_action _Level_Finished_loop _skip_game_action
_game_action
if frame_counter then _Skip_dec_bonus_and_fuel
if bonus_bcd_counter then dec bonus_bcd_counter = bonus_bcd_counter - 1
if !bonus_bcd_counter{0} then pfscore2 = pfscore2 / 2
_Skip_dec_bonus_and_fuel
if !pfscore2 && !_Ch0_Sound then _Ch0_Sound = 4 : _Ch0_Duration = 1 : _Ch0_Counter = 0
; Skips this section if Enemy shoot is moving.
if player0y = 200 || enemy_game_state then goto __Skip_Enemy_Fire
if _BitOp_Ball_Shot_Dir || roommate_type then goto __Skip_Enemy_Fire
temp4 = frame_counter & 127
if temp4 <> next_shoot_rand then goto __Skip_Enemy_Fire
; Turn on ball shoot movement.
next_shoot_rand = ( rand16 & 127)
_BitOp_Ball_Shot_Dir = 0 : Bally_velocity = 0.0 : q = 0
ball_shoot_x = player0x + 4 : ball_shoot_y = player0y - 5
; sound for enemy shot !
if _Ch0_Sound <> 3 then _Ch0_Sound = 2 : _Ch0_Duration = 1 : _Ch0_Counter = 0
if player1x > player0x then _Bit2_Ball_Shot_Dir_Right1{2} = 1 else _Bit0_Ball_Shot_Dir_Left1{0} = 1
if !_Bit2_Ball_Shot_Dir_Right1{2} then __Skip_Additional_Right
temp4 = player1x - player0x
if temp4 > 25 then _Bit3_Ball_Shot_Dir_Right2{3} = 1
__Skip_Additional_Right
if !_Bit0_Ball_Shot_Dir_Left1{0} then __Skip_Enemy_Fire
temp4 = player0x - player1x
if temp4 > 25 then _Bit1_Ball_Shot_Dir_Left2{1} = 1
__Skip_Enemy_Fire
; Missile0 movement check.
; Skips this section if ball-missile isn't moving.
if !_BitOp_Ball_Shot_Dir then goto __Skip_Enemy_Missile
; Moves missile0 in the appropriate direction.
if ball_shoot_y > player1y then ball_shoot_y = ball_shoot_y - 1
if _Bit0_Ball_Shot_Dir_Left1{0} && frame_counter{0} then ball_shoot_x = ball_shoot_x - 1 : if _Bit1_Ball_Shot_Dir_Left2{1} then ball_shoot_x = ball_shoot_x - 1
if _Bit2_Ball_Shot_Dir_Right1{2} && frame_counter{0} then ball_shoot_x = ball_shoot_x + 1 : if _Bit3_Ball_Shot_Dir_Right2{3} then ball_shoot_x = ball_shoot_x + 1
rem apply gravity
Bally_velocity = Bally_velocity + gravity_ball
Bally_position = Bally_position + Bally_velocity
; Clears missile0 if it hits the edge of the screen.