git @ Cat's Eye Technologies Bubble-Escape / 7b634d6
Update bubble escape 2k.p65 to Bubble Escape 2K (mini game compo). Cat's Eye Technologies 13 years ago
1 changed file(s) with 351 addition(s) and 585 deletion(s). Raw diff Collapse all Expand all
11 ; ;
22 ; Cat's Eye Technologies' ;
33 ; Bubble Escape 2009 ;
4 ; !!! 2K VERSION !!! ;
5 ; Submitted to the Mini Game Compo 2009 ;
46 ; ;
57 ;---------------------------------------------------------------------;
68 ; Copyright (c)2009 Cat's Eye Technologies. All rights reserved. ;
138140 .alias destptr $fd
139141 .alias sprite_len $0200
140142
141 ;----------------------------------;
142 ; Symbolic constants for debugging ;
143 ;----------------------------------;
144
145 ;
146 ; Set these to colors other than game_border_color if you want a
147 ; visual indication of how long the raster interrupt takes to execute.
148 ;
149
150 ;.alias display_critical_border_color color_red
151 .alias display_critical_border_color game_border_color
152 ;.alias irq_progress_border_color color_yellow
153 .alias irq_progress_border_color game_border_color
154
155143
156144 ;===================================================================
157145 ; ... Header ...
158146 ;===================================================================
159147
160 .org 0 ; no real address, we're just faking up a header
161 .word $0801 ; we start here.
162 .org $0801 ; 2049
163
164
165 ;===================================================================
166 ; ... BASIC loader stub ...
167 ;===================================================================
168
169 .byte $10, $08 ; base address
170 .byte $c9, $07 ; line number: 1993
171 .byte $9e ; SYS
172 .byte $32, $30, $36, $31 ; '2061'
173 .byte $00, $00, $00 ; end of program
174
175 ; here is 2061 ($080d)
176
148 .org 0
149 .word $c000
150 .org $c000
177151
178152 ;===================================================================
179153 ; ... Global Initialization ...
184158 ;
185159
186160 init:
187 lda #$80
188 sta mode ; disable SHIFT+C= changing charset
189 lda vic_vmcsb
190 and #%11111000
191 ora #$05
192 sta vic_vmcsb ; set character map base to uppercase set
193
194 lda #game_bg_color
161 lda #0
195162 sta vic_bg_0_color
196 lda #game_border_color
197163 sta vic_border_color
164 sta irq_active
165 sta waiting_collision_clear
166 tay
198167
199168 lda #$8f ; volume = 15, bit 7 = voice 3 silenced
200169 sta sid_volume
209178 lda #3
210179 sta vic_sprite_0_color
211180
212 copy_sprites:
213
214 lda #<sprite_source
215 sta srcptr
216 lda #>sprite_source
217 sta srcptr+1
218
219 lda #<sprite_dest
220 sta destptr
221 lda #>sprite_dest
222 sta destptr+1
223
224 ldx #>sprite_len
225
226 outer_loop:
227 ldy #0
228
229 inner_loop:
230 lda (srcptr), y
231 sta (destptr), y
181 copy_sprites_loop:
182 lda sprite_source, y
183 sta sprite_dest, y
184 lda sprite_source+256, y
185 sta sprite_dest+256, y
232186 iny
233 bne inner_loop
234
235 inc srcptr+1 ; bump up high bytes
236 inc destptr+1
237 dex
238 bne outer_loop
187 bne copy_sprites_loop
188
189 lda #$ff
190 ldy #63
191 wall_loop:
192 sta wall_sprite_dest-1, y
193 dey
194 bne wall_loop
195
196 lda #$cc
197 ldy #63
198 teleporter_loop:
199 sta teleporter_sprite_dest-1, y
200 dey
201 bne teleporter_loop
239202
240203 ;
241204 ; Set up the IRQ handler routine.
242205 ;
243
244 lda #$00
245 sta irq_active
246 sta waiting_collision_clear
247206
248207 patch_cinv:
249208 sei ; disable interrupts
273232
274233
275234 ;===================================================================
276 ; ... Title Screen ...
277 ;===================================================================
278
279 title_screen:
280
281 lda #<title_text
282 sta srcptr
283 lda #>title_text
284 sta srcptr+1
285 jsr show_message_screen
286
287
288 ;===================================================================
289235 ; ... Game State Initialization ...
290236 ;===================================================================
291237
296242 new_game:
297243
298244 lda #$00
299 sta player_died
300245 sta player_won
301
302 ;
303 ; For debugging, uncomment some of these lines
304 ;
305
306 .alias start_room 0
307 ;.alias start_room 18 ; near NE teleporter
308 ;.alias start_room 198 ; near exit
309 .alias initial_keys 0
310 ;.alias initial_keys 5
311
312 lda #initial_keys
246 sta room_num
313247 sta num_keys
314 ldy #start_room
315 sty room_num
316 lda map, y
317 ora #c_start
318 sta map, y
319
320 ldy #0
321 lda #0
248
249 ;XXXXXXXXXXXXXXXXXX
250 ; lda #198
251 ; sta room_num
252 ; tay
253 ; lda #5
254 ; sta num_keys
255 ; lda map, y
256 ; and #%11110000
257 ; ora #c_start
258 ; sta map, y
259 ; lda #0
260 ;XXXXXXXXXXXXXXXXXX
261
262 tay
322263 reset_actors_loop:
323264 sta actor_table_base, y
324265 iny
330271 ; Position bubble in center of room.
331272 ;
332273
333 ldy #0
274 tay
334275 jsr center_actor_number_y
335276
336277 lda #<bubble_logic_routine
341282 lda #$09
342283 sta num_lives
343284
285 lda #45
286 sta sentry_initial
287
344288 set_up_map:
345289 ldy #200
346290 set_up_map_loop:
347291 dey
348292
349 lda map, y
350
351 and #$0f
352 cmp #c_start
293 jsr check_map_for_existing
353294 beq next_map_loop
354 cmp #c_telep
355 beq next_map_loop
356 cmp #c_exit
357 beq next_map_loop
358295
359296 jsr gen_random_4
360 clc
361 adc #c_walls
297 ora #c_walls
362298 sta baddie
363299
364300 lda map, y
375311 place_keys_loop:
376312 jsr gen_random_room
377313 tay
378 lda map, y
379
380 and #$0f
381 cmp #c_start
382 beq place_keys_loop
383 cmp #c_telep
384 beq place_keys_loop
385 cmp #c_exit
386 beq place_keys_loop
387 cmp #c_key
314
315 jsr check_map_for_existing
388316 beq place_keys_loop
389317
390318 lda map, y
434362 lda #bubble_page ; to reset to bubble after it was possibly showing "pop" sprite
435363 sta sprite_0_ptr
436364
437 lda #$01
438 sta vic_sprite_enable
439
440365 jsr clear_monsters
441366 jsr set_up_monsters
442367 jsr update_sprites
476401 bne death_sequence
477402
478403 lda player_won
479 bne game_won
480404
481 jmp play_game
482
405 beq play_game
483406
484407 ;===================================================================
485408 ; ... Outside Game Play Sequences ...
486409 ;===================================================================
487410
411 ;----------;
412 ; Game Won ;
413 ;----------;
414
415 game_won:
416 lda #color_yellow
417 sta vic_bg_0_color
418 lda #color_lt_red
419 sta vic_bg_0_color
420 jmp game_won
421
488422 ;---------------;
489423 ; Bubble Popped ;
490424 ;---------------;
491425
492426 death_sequence:
493 lda #0
494 sta player_died
495
496 lda #state_alive
497 sta player_state
498
499427 ldy num_lives
500428 dey
429 sty num_lives
501430 bne reset_bubble
502431
503 jmp game_over
432 jsr draw_corners
433 sty vic_sprite_enable
434
435 wait_joystick_button:
436 lda joy2
437 and #$10
438 bne wait_joystick_button
439
440 jmp new_game ; game over
504441
505442 reset_bubble:
506 sty num_lives
507443
508444 ldy #0 ; affect actor #0, the bubble
509445
511447 ; If the room is walls or empty, place bubble in very center.
512448 ; Else place bubble offset a bit.
513449 ;
450 jsr be_still_actor_number_y
451 jsr center_actor_number_y
514452
515453 lda current_room
516454 and #$0f
520458 cmp #c_start
521459 beq very_center
522460
523 jsr offset_actor_number_y
524
525 jmp be_still_my_bubble
461 jsr offset_ur_actor_number_y
526462
527463 very_center:
528 jsr center_actor_number_y
529
530 be_still_my_bubble:
531 jsr be_still_actor_number_y
532
533464 jmp initialize_room
534
535 ;-----------;
536 ; Game Over ;
537 ;-----------;
538
539 game_over:
540 lda #<game_over_text
541 sta srcptr
542 lda #>game_over_text
543 sta srcptr+1
544 jsr show_message_screen
545
546 jmp title_screen
547
548 ;----------;
549 ; Game Won ;
550 ;----------;
551
552 game_won:
553 lda #<game_won_text
554 sta srcptr
555 lda #>game_won_text
556 sta srcptr+1
557 jsr show_message_screen
558
559 jmp title_screen
560
561465
562466 ;===================================================================
563467 ; ... Gameplay Subroutines ...
569473
570474 draw_room_contents:
571475 lda current_room
476 tax
572477 and #wall_n
573478 beq not_north
574479 jsr draw_north
575480 not_north:
576 lda current_room
481 txa
577482 and #wall_w
578483 beq not_west
579484 jsr draw_west
580485 not_west:
581 lda current_room
486 txa
582487 and #wall_e
583488 beq not_east
584489 jsr draw_east
585490 not_east:
586 lda current_room
491 txa
587492 and #wall_s
588493 beq not_south
589494 jsr draw_south
619524 draw_north_loop:
620525 lda #north_wall_char
621526 sta screen-1, y
622 lda #north_wall_color
623 sta colormap-1, y
624527 dey
625528 bne draw_north_loop
626529 rts
630533 draw_south_loop:
631534 lda #south_wall_char
632535 sta screen+959, y
633 lda #south_wall_color
634 sta colormap+959, y
635536 dey
636537 bne draw_south_loop
637538 rts
645546 sta screen+320, y
646547 sta screen+560, y
647548 sta screen+800, y
648 lda #west_wall_color
649 sta colormap, y
650 sta colormap+240, y
651 sta colormap+320, y
652 sta colormap+560, y
653 sta colormap+800, y
549
654550 tya
655551 sec
656552 sbc #40
668564 sta screen+359, y
669565 sta screen+599, y
670566 sta screen+839, y
671 lda #east_wall_color
672 sta colormap+39, y
673 sta colormap+279, y
674 sta colormap+359, y
675 sta colormap+599, y
676 sta colormap+839, y
677567
678568 tya
679569 sec
720610 ldy #1
721611 jsr center_actor_number_y
722612
723 lda vic_sprite_enable
724 ora #%00000010
613 lda #%00000011
725614 sta vic_sprite_enable
726615
727616 rts
762651
763652 ldy #2
764653
765 lda #>wall_1_x_pos
766 sta actor_0_xpos_high, y
767 lda #<wall_1_x_pos
768 sta actor_0_xpos_low, y
769
770 lda #>wall_1_y_pos
771 sta actor_0_ypos_high, y
772 lda #<wall_1_y_pos
773 sta actor_0_ypos_low, y
654 jsr offset_ul_actor_number_y
774655
775656 lda #8
776657 sta actor_0_xvel, y
777658
778659 iny
779660
780 lda #>wall_2_x_pos
781 sta actor_0_xpos_high, y
782 lda #<wall_2_x_pos
783 sta actor_0_xpos_low, y
784
785 lda #>wall_2_y_pos
786 sta actor_0_ypos_high, y
787 lda #<wall_2_y_pos
788 sta actor_0_ypos_low, y
661 jsr offset_lr_actor_number_y
789662
790663 lda #248 ; -8
791664 sta actor_0_xvel, y
792665
793 lda vic_sprite_enable
794 ora #%00001100
666 lda #%00001101
795667 sta vic_sprite_enable
796668
797669 rts
812684 lda #>sentry_logic_routine
813685 sta actor_0_logic_high, y
814686
815 lda #45
687 lda sentry_initial
816688 sta sentry_timer
817689
818 jmp setup_single_beast_tail
690 ldy #2
691 jsr center_actor_number_y
692
693 enable_single_beast_tail:
694 lda #%00000101
695 sta vic_sprite_enable
696
697 rts
819698
820699 is_it_dragon:
821700 cmp #c_dragon
845724
846725 jmp enable_single_beast_tail
847726
848 setup_single_beast_tail:
849 ldy #2
850 jsr center_actor_number_y
851
852 enable_single_beast_tail:
853 lda vic_sprite_enable
854 ora #%00000100
855 sta vic_sprite_enable
856
857 rts
858
859727 is_it_three:
860728 cmp #c_three
861729 bne its_not_anything
872740
873741 ldy #2
874742
875 lda #>fireball_1_x_pos
876 sta actor_0_xpos_high, y
877 lda #<fireball_1_x_pos
878 sta actor_0_xpos_low, y
879
880 lda #>fireball_1_y_pos
881 sta actor_0_ypos_high, y
882 lda #<fireball_1_y_pos
883 sta actor_0_ypos_low, y
884
743 jsr offset_ul_actor_number_y
885744 iny
886
887 lda #>fireball_2_x_pos
888 sta actor_0_xpos_high, y
889 lda #<fireball_2_x_pos
890 sta actor_0_xpos_low, y
891
892 lda #>fireball_2_y_pos
893 sta actor_0_ypos_high, y
894 lda #<fireball_2_y_pos
895 sta actor_0_ypos_low, y
896
745 jsr center_actor_number_y
897746 iny
898
899 lda #>fireball_3_x_pos
900 sta actor_0_xpos_high, y
901 lda #<fireball_3_x_pos
902 sta actor_0_xpos_low, y
903
904 lda #>fireball_3_y_pos
905 sta actor_0_ypos_high, y
906 lda #<fireball_3_y_pos
907 sta actor_0_ypos_low, y
908
909 lda vic_sprite_enable
910 ora #%00011100
747 jsr offset_lr_actor_number_y
748
749 lda #%00011101
911750 sta vic_sprite_enable
751 rts
912752
913753 its_not_anything:
754 lda #%00000001
755 sta vic_sprite_enable
914756 rts
915757
916758
927769 lda vic_intr ; see if this IRQ was caused by the VIC chip
928770 sta vic_intr
929771 and #$01
930 cmp #$01
931 beq we_handle_it
932 jmp (savecinv)
772 beq not_handled_by_us
933773
934774 ;
935775 ; Check to see if our IRQ handler is told to run or not.
936776 ;
937777 we_handle_it:
938778 lda irq_active
939 bne check_waiting_collision_clear
940 jmp (savecinv)
779 beq not_handled_by_us
941780
942781 ;
943782 ; Check to see if the VIC's collision register is clear
944783 ; or not, if requested. If not clear, wait until the next
945 ; raster interrupt before doing anything. XXX this logic
946 ; seems a little borked, since we don't move any sprites
947 ; between the two interrupts, so how's it going to change?
784 ; raster interrupt before doing anything.
948785 ;
949786 check_waiting_collision_clear:
950787 lda waiting_collision_clear
952789
953790 lda vic_sprite_collision
954791 ora vic_bg_collision
955 bne not_clear_yet
956
957 lda #0
792 bne not_handled_by_us
793
794 ;lda #0
958795 sta waiting_collision_clear
959796 jmp start_display_critical_region
960797
961 not_clear_yet:
798 not_handled_by_us:
962799 jmp (savecinv)
963800
964801 ;--------------------------------------------------------------------------;
968805 ;--------------------------------------------------------------------------;
969806
970807 start_display_critical_region:
971 lda #display_critical_border_color
972 sta vic_border_color
973
974808 jsr update_sprites
975809
976810 ;--------------------------------------------------------------------------;
978812 ; the raster scan line is drawing the video display. ;
979813 ; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ;
980814 ;--------------------------------------------------------------------------;
981
982 lda #irq_progress_border_color
983 sta vic_border_color
984815
985816 ;--------------------------------------------------------;
986817 ; Check for collisions that moving the sprites produced. ;
1067898 and #wall_mask
1068899 sta map, y
1069900
901 ldy sentry_initial
902 dey
903 dey
904 dey
905 sty sentry_initial
906
1070907 make_ding_sound:
1071908 lda #100
1072909 sta sid_1_high_freq
1092929 cmp #c_telep
1093930 bne try_collide_exit
1094931
932 ldx #180
933
1095934 lda room_num
1096935 cmp #180
1097 bne try_ne
1098
1099 lda #19
936 bne teleport_out
937
938 ldx #19
1100939
1101940 teleport_out:
1102 sta room_num
941 stx room_num
1103942
1104943 lda #1
1105944 sta room_changed
1106 lda #0
1107 sta irq_active
1108945
1109946 ldy #0
1110 jsr offset_actor_number_y
947 jsr offset_ur_actor_number_y
1111948 jsr be_still_actor_number_y
1112949
1113 jmp clean_exeunt
1114
1115 try_ne:
1116 lda #180
1117 jmp teleport_out
950 jmp disable_irq_exeunt
1118951
1119952 try_collide_exit:
1120953 cmp #c_exit
1121954 bne done_with_collision_checks
1122955
1123 lda vic_sprite_enable
1124 ora #%00000010
956 lda #%00000011
1125957 sta vic_sprite_enable
1126958
1127959 lda num_keys
1128960 cmp #5
1129961 bne done_with_collision_checks
1130962
1131 lda #0
1132 sta irq_active
1133963 lda #1
1134964 sta player_won
1135965
1136 jmp clean_exeunt
966 jmp disable_irq_exeunt
1137967
1138968 done_with_collision_checks:
1139969
1154984 sta indirect_jump_vector
1155985 tya
1156986 pha
1157 jmp (indirect_jump_vector)
1158
1159 logic_routine_return_address:
987 jsr indirect_jsr_trick
1160988 pla
1161989 tay
1162990
11741002 cmp #max_vel
11751003 bcc xvel_within_limit ; branch if accumulator is less
11761004 cmp #min_vel
1177 bcs xvel_within_limit ; branch if accumulator is greater or equal
1178 jmp update_xpos
1005 bcc update_xpos ; bcs xvel_within_limit ; branch if accumulator is greater or equal
1006 ;jmp update_xpos
11791007
11801008 xvel_within_limit:
11811009 sta actor_0_xvel, y
12051033 cmp #max_vel
12061034 bcc yvel_within_limit ; branch if accumulator is less
12071035 cmp #min_vel
1208 bcs yvel_within_limit ; branch if accumulator is greater or equal
1209 jmp update_ypos
1036 bcc update_ypos ; bcs yvel_within_limit ; branch if accumulator is greater or equal
1037 ;jmp update_ypos
12101038
12111039 yvel_within_limit:
12121040 sta actor_0_yvel, y
12471075 go_west:
12481076 lda #>east_boundary
12491077 sta actor_0_xpos_high, y
1250 lda #<east_boundary
1251 sec
1252 sbc #1 ; to make sure it is not over
1078 lda #<east_boundary-1
12531079 sta actor_0_xpos_low, y
12541080
12551081 lda #$ff ; -1
12671093 go_east:
12681094 lda #>west_boundary
12691095 sta actor_0_xpos_high, y
1270 lda #<west_boundary
1271 clc
1272 adc #1 ; to make sure it is not over
1096 lda #<west_boundary+1
12731097 sta actor_0_xpos_low, y
12741098
12751099 lda #$01 ; +1
12871111 go_north:
12881112 lda #>south_boundary
12891113 sta actor_0_ypos_high, y
1290 lda #<south_boundary
1291 sec
1292 sbc #1 ; to make sure it is not over
1114 lda #<south_boundary-1
12931115 sta actor_0_ypos_low, y
12941116
12951117 lda #0
13091131 go_south:
13101132 lda #>north_boundary
13111133 sta actor_0_ypos_high, y
1312 lda #<north_boundary
1313 clc
1314 adc #1 ; to make sure it is not over
1134 lda #<north_boundary+1
13151135 sta actor_0_ypos_low, y
13161136
13171137 lda #map_width
13361156
13371157 lda #1
13381158 sta room_changed
1339 lda #0
1340 sta irq_active
1341 jmp no_more_boundaries
1159
1160 jmp disable_irq_exeunt
1161
1162 ;lda #0
1163 ;sta irq_active
1164 ;jmp no_more_boundaries
13421165
13431166
13441167 exeunt:
13451168 lda player_died
13461169 beq clean_exeunt
13471170
1171 disable_irq_exeunt:
13481172 lda #0
13491173 sta irq_active
13501174
13511175 clean_exeunt:
1352 lda #game_border_color
1353 sta vic_border_color
1354
13551176 pla
13561177 tay
13571178 pla
13611182 rti
13621183
13631184
1185 indirect_jsr_trick:
1186 jmp (indirect_jump_vector)
1187
1188
13641189 ;===================================================================
13651190 ; ... Logic Routines ...
13661191 ;===================================================================
13751200 ; 1. Must not be placed in zero page, as a high byte of 0 is used to
13761201 ; indicate 'no logic routine'.
13771202 ;
1378 ; 2. Must execute jmp logic_routine_return_address at the end.
1203 ; 2. Must execute rts at the end.
13791204 ;
13801205
13811206 ; **********
14211246 lda #$01
14221247 sta actor_0_xacc, y
14231248 not_right:
1424 txa
1425 and #$10
1426 bne not_fire
1427 ; ...
1428 not_fire:
1429 jmp logic_routine_return_address
1249 rts
14301250
14311251 popped_state_handling:
1432 lda player_timer
1433 sec
1434 sbc #1
1435 sta player_timer
1436 cmp #0
1437 beq we_have_died
1438
1439 jmp logic_routine_return_address
1440
1441 we_have_died:
1442
1443 lda #$01
1444 sta player_died
1445
1446 jmp logic_routine_return_address
1252 ldx player_timer
1253 dex
1254 stx player_timer
1255 bne we_have_not_died
1256
1257 inx
1258 stx player_died
1259
1260 we_have_not_died:
1261 rts
14471262
14481263
14491264 ; **********
14541269 ;
14551270 sentry_logic_routine:
14561271 ldx sentry_timer
1457 cpx #0
14581272 beq sentry_is_active
14591273 dex
14601274 stx sentry_timer
1461 jmp logic_routine_return_address
1275 rts
14621276
14631277 sentry_is_active:
14641278 lda #$00
15101324 sentry_done:
15111325 sta actor_0_yacc, y
15121326
1513 jmp logic_routine_return_address
1327 rts
15141328
15151329
15161330 ;===================================================================
15171331 ; ... General Subroutines ...
15181332 ;===================================================================
15191333
1334 check_map_for_existing:
1335 lda map, y
1336 and #$0f
1337 cmp #c_start
1338 beq map_has_existing
1339 cmp #c_telep
1340 beq map_has_existing
1341 cmp #c_exit
1342 beq map_has_existing
1343 cmp #c_key
1344 map_has_existing:
1345 rts
1346
15201347 clear_screen:
15211348 ldy #0
15221349
15231350 clear_screen_loop:
1524 lda #0
1351 lda #north_wall_color
15251352 sta colormap, y
15261353 sta colormap+250, y
15271354 sta colormap+500, y
15371364 cpy #250
15381365 bne clear_screen_loop
15391366
1540 rts
1541
1542 wait_joystick_button:
1543 lda joy2
1544 and #$10
1545 bne wait_joystick_button
1546 wait_joystick_release:
1547 lda joy2
1548 and #$10
1549 beq wait_joystick_release
15501367 rts
15511368
15521369 gen_random_room:
16001417 rts
16011418
16021419 ; not in the center, but offset a bit so as not to collide immediately with thing in center
1603 offset_actor_number_y:
1420 offset_ur_actor_number_y:
16041421 lda #>initial_x_bubble
16051422 sta actor_0_xpos_high, y
16061423 lda #<initial_x_bubble
16091426 lda #>initial_y_bubble
16101427 sta actor_0_ypos_high, y
16111428 lda #<initial_y_bubble
1429 sta actor_0_ypos_low, y
1430
1431 rts
1432
1433 offset_ul_actor_number_y:
1434 lda #>fireball_1_x_pos
1435 sta actor_0_xpos_high, y
1436 lda #<fireball_1_x_pos
1437 sta actor_0_xpos_low, y
1438
1439 lda #>fireball_1_y_pos
1440 sta actor_0_ypos_high, y
1441 lda #<fireball_1_y_pos
1442 sta actor_0_ypos_low, y
1443
1444 rts
1445
1446 offset_lr_actor_number_y:
1447 lda #>fireball_3_x_pos
1448 sta actor_0_xpos_high, y
1449 lda #<fireball_3_x_pos
1450 sta actor_0_xpos_low, y
1451
1452 lda #>fireball_3_y_pos
1453 sta actor_0_ypos_high, y
1454 lda #<fireball_3_y_pos
16121455 sta actor_0_ypos_low, y
16131456
16141457 rts
16381481 sta msb_counter
16391482
16401483 update_sprite_loop:
1641 ; XXX check if actor/sprite #y is active.
1642 ; if not, we may skip all this.
1643 ; However, it is not necessary until we start to stuff
1644 ; so much into this IRQ handler that performance is threatened.
16451484
16461485 set_sprite_x:
16471486 lda actor_0_xpos_low, y
16781517 inx
16791518 inx
16801519 cpy #8
1681 beq done_moving_sprites
1682 jmp update_sprite_loop
1520 bne update_sprite_loop
16831521
16841522 done_moving_sprites:
16851523 rts
16891527 ; ... Game-state Routines ...
16901528 ;===================================================================
16911529
1692 show_message_screen:
1693
1694 lda #0
1695 sta vic_sprite_enable
1696
1697 jsr clear_screen
1698
1699 ldy #0
1700
1701 print_loop: ; print out message and wait for fire button
1702 lda (srcptr), y
1703 beq end_of_message
1704 sta screen, y
1705 lda #1
1706 sta colormap, y
1707 iny
1708 jmp print_loop
1709
1710 end_of_message:
1711 jsr wait_joystick_button
1712 rts
1713
17141530
17151531 ;*****************;
17161532 ; CONSTANT DATA ;
17171533 ;*****************;
1718
1719 title_text: .byte 2, 21, 2, 2, 12, 5, 32, 5, 19, 3, 1, 16, 5, 0 ; "BUBBLE ESCAPE"
1720 game_over_text: .byte 7, 1, 13, 5, 32, 15, 22, 5, 18, 0 ; "GAME OVER"
1721 game_won_text: .byte 25, 15, 21, 32, 5, 19, 3, 1, 16, 5, 4, 0 ; "YOU ESCAPED"
17221534
17231535
17241536 ;====================================================================
17671579
17681580 sprite_source:
17691581
1770 .alias sprite_dest $2000
1771 .alias sprite_0_page $80 ; 192
1582 .alias sprite_dest $2000 ; 8192 = 128 * 64
1583 .alias sprite_0_page $80 ; 128
17721584
17731585 ; Bubble
17741586 .alias bubble_page sprite_0_page
18241636
18251637 .byte 0
18261638
1639 ; POP
1640 .alias pop_page sprite_0_page+2
1641
1642 .byte $00,$08,$00
1643 .byte $20,$08,$02
1644 .byte $10,$08,$04
1645 .byte $08,$08,$08
1646 .byte $04,$08,$10
1647 .byte $02,$08,$20
1648 .byte $00,$00,$00
1649 .byte $03,$19,$80
1650 .byte $02,$a5,$40
1651 .byte $fb,$25,$9f
1652 .byte $02,$25,$00
1653 .byte $02,$19,$00
1654 .byte $00,$00,$40
1655 .byte $02,$10,$20
1656 .byte $04,$10,$10
1657 .byte $08,$10,$08
1658 .byte $10,$10,$04
1659 .byte $20,$10,$02
1660 .byte $40,$10,$00
1661 .byte $00,$10,$00
1662 .byte $00,$10,$00
1663
1664 .byte 0
1665
1666 ; Guard
1667 .alias guard_page sprite_0_page+3
1668
1669 .byte $00,$00,$00
1670 .byte $00,$00,$00
1671 .byte $00,$00,$00
1672 .byte $00,$3f,$00
1673 .byte $00,$4c,$80
1674 .byte $00,$9e,$40
1675 .byte $01,$3b,$20
1676 .byte $01,$3b,$20
1677 .byte $00,$9e,$40
1678 .byte $00,$4c,$80
1679 .byte $00,$3f,$00
1680 .byte $00,$0c,$10
1681 .byte $00,$1e,$10
1682 .byte $07,$ff,$f8
1683 .byte $07,$ff,$f8
1684 .byte $03,$0c,$30
1685 .byte $01,$ff,$e0
1686 .byte $00,$ff,$c0
1687 .byte $00,$7f,$80
1688 .byte $00,$00,$00
1689 .byte $00,$00,$00
1690
1691 .byte 0
1692
1693 ; Key
1694 .alias key_page sprite_0_page+4
1695
1696 .byte $00,$00,$00
1697 .byte $00,$00,$00
1698 .byte $00,$00,$00
1699 .byte $00,$7e,$00
1700 .byte $00,$e7,$00
1701 .byte $01,$e7,$80
1702 .byte $01,$ff,$80
1703 .byte $01,$ff,$80
1704 .byte $00,$ff,$00
1705 .byte $00,$7e,$00
1706 .byte $00,$18,$00
1707 .byte $00,$18,$00
1708 .byte $00,$78,$00
1709 .byte $00,$78,$00
1710 .byte $00,$18,$00
1711 .byte $00,$78,$00
1712 .byte $00,$78,$00
1713 .byte $00,$00,$00
1714 .byte $00,$00,$00
1715 .byte $00,$00,$00
1716 .byte $00,$00,$00
1717
1718 .byte 0
1719
18271720 ; Fireball
1828 .alias fireball_page sprite_0_page+2
1721 .alias fireball_page sprite_0_page+5
18291722
18301723 .byte $00,$00,$00
18311724 .byte $00,$00,$00
18521745 .byte 0
18531746
18541747 ; Wall
1855 .alias wall_page sprite_0_page+3
1856
1857 .byte $ff,$ff,$ff
1858 .byte $ff,$ff,$ff
1859 .byte $ff,$ff,$ff
1860 .byte $ff,$ff,$ff
1861 .byte $ff,$ff,$ff
1862 .byte $ff,$ff,$ff
1863 .byte $ff,$ff,$ff
1864 .byte $ff,$ff,$ff
1865 .byte $ff,$ff,$ff
1866 .byte $ff,$ff,$ff
1867 .byte $ff,$ff,$ff
1868 .byte $ff,$ff,$ff
1869 .byte $ff,$ff,$ff
1870 .byte $ff,$ff,$ff
1871 .byte $ff,$ff,$ff
1872 .byte $ff,$ff,$ff
1873 .byte $ff,$ff,$ff
1874 .byte $ff,$ff,$ff
1875 .byte $ff,$ff,$ff
1876 .byte $ff,$ff,$ff
1877 .byte $ff,$ff,$ff
1878
1879 .byte 0
1748 .alias wall_page sprite_0_page+6
1749 .alias wall_sprite_dest 8576 ; (128 + 6) * 64
18801750
18811751 ; Teleporter
1882 .alias teleporter_page sprite_0_page+4
1883
1884 .byte $cc,$cc,$cc
1885 .byte $cc,$cc,$cc
1886 .byte $cc,$cc,$cc
1887 .byte $cc,$cc,$cc
1888 .byte $cc,$cc,$cc
1889 .byte $cc,$cc,$cc
1890 .byte $cc,$cc,$cc
1891 .byte $cc,$cc,$cc
1892 .byte $cc,$cc,$cc
1893 .byte $cc,$cc,$cc
1894 .byte $cc,$cc,$cc
1895 .byte $cc,$cc,$cc
1896 .byte $cc,$cc,$cc
1897 .byte $cc,$cc,$cc
1898 .byte $cc,$cc,$cc
1899 .byte $cc,$cc,$cc
1900 .byte $cc,$cc,$cc
1901 .byte $cc,$cc,$cc
1902 .byte $cc,$cc,$cc
1903 .byte $cc,$cc,$cc
1904 .byte $cc,$cc,$cc
1905
1906 .byte 0
1907
1908 ; Key
1909 .alias key_page sprite_0_page+5
1910
1911 .byte $00,$00,$00
1912 .byte $00,$00,$00
1913 .byte $00,$00,$00
1914 .byte $00,$7e,$00
1915 .byte $00,$e7,$00
1916 .byte $01,$e7,$80
1917 .byte $01,$ff,$80
1918 .byte $01,$ff,$80
1919 .byte $00,$ff,$00
1920 .byte $00,$7e,$00
1921 .byte $00,$18,$00
1922 .byte $00,$18,$00
1923 .byte $00,$78,$00
1924 .byte $00,$78,$00
1925 .byte $00,$18,$00
1926 .byte $00,$78,$00
1927 .byte $00,$78,$00
1928 .byte $00,$00,$00
1929 .byte $00,$00,$00
1930 .byte $00,$00,$00
1931 .byte $00,$00,$00
1932
1933 .byte 0
1934
1935 ; POP
1936 .alias pop_page sprite_0_page+6
1937
1938 .byte $00,$08,$00
1939 .byte $20,$08,$02
1940 .byte $10,$08,$04
1941 .byte $08,$08,$08
1942 .byte $04,$08,$10
1943 .byte $02,$08,$20
1944 .byte $00,$00,$00
1945 .byte $03,$19,$80
1946 .byte $02,$a5,$40
1947 .byte $fb,$25,$9f
1948 .byte $02,$25,$00
1949 .byte $02,$19,$00
1950 .byte $00,$00,$40
1951 .byte $02,$10,$20
1952 .byte $04,$10,$10
1953 .byte $08,$10,$08
1954 .byte $10,$10,$04
1955 .byte $20,$10,$02
1956 .byte $40,$10,$00
1957 .byte $00,$10,$00
1958 .byte $00,$10,$00
1959
1960 .byte 0
1961
1962 ; Guard
1963 .alias guard_page sprite_0_page+7
1964
1965 .byte $00,$00,$00
1966 .byte $00,$00,$00
1967 .byte $00,$00,$00
1968 .byte $00,$3f,$00
1969 .byte $00,$4c,$80
1970 .byte $00,$9e,$40
1971 .byte $01,$3b,$20
1972 .byte $01,$3b,$20
1973 .byte $00,$9e,$40
1974 .byte $00,$4c,$80
1975 .byte $00,$3f,$00
1976 .byte $00,$0c,$10
1977 .byte $00,$1e,$10
1978 .byte $07,$ff,$f8
1979 .byte $07,$ff,$f8
1980 .byte $03,$0c,$30
1981 .byte $01,$ff,$e0
1982 .byte $00,$ff,$c0
1983 .byte $00,$7f,$80
1984 .byte $00,$00,$00
1985 .byte $00,$00,$00
1986
1987 .byte 0
1988
1989
1990 ;====================================================================
1991 ;**** ***** ***** ***** ***** VARIABLES ***** ***** ***** ***** *****
1992 ;====================================================================
1993
1994 ;
1995 ; Game State
1996 ;
1997
1998 .space room_num 1 ; index into map array of room currently occupied by the bubble
1999 .space current_room 1 ; cache of map cell representing current room (i.e. "lda map, y" where y = room_num)
2000 .space num_lives 1
2001 .space num_keys 1
2002
2003 .space player_state 1
2004
2005 .alias state_alive 0
2006 .alias state_popped 1
2007
2008 .space player_timer 1
2009 .space sentry_timer 1
2010
2011 ;
2012 ; Arithmetic
2013 ;
2014
2015 .space temp_low 1
2016 .space temp_high 1
2017 .space sign_extend 1
2018
2019 ;
2020 ; Interrupt Handling
2021 ;
2022
2023 .space savecinv 2
2024 .space irq_active 1
2025 .space waiting_collision_clear 1
2026
2027 ;
2028 ; Flags
2029 ;
2030
2031 .space room_changed 1
2032 .space player_died 1
2033 .space player_won 1
2034
2035 ;
2036 ; Temporary Storage in IRQ handler
2037 ;
2038
2039 .space msb_counter 1 ; for calculating sprite's x msb
2040 .space indirect_jump_vector 2
2041
2042 ;
2043 ; Temporary Storage for Setting up Room etc.
2044 ;
2045
2046 .space baddie 1
2047 .space room_delta 1
1752 .alias teleporter_page sprite_0_page+7
1753 .alias teleporter_sprite_dest 8640 ; (128 + 7) * 64
20481754
20491755
20501756 ;=====================================================================
21611867
21621868 .space actor_0_logic_low 8
21631869 .space actor_0_logic_high 8
1870
1871 ;====================================================================
1872 ;**** ***** ***** ***** ***** VARIABLES ***** ***** ***** ***** *****
1873 ;====================================================================
1874
1875 ;
1876 ; Game State
1877 ;
1878
1879 .space room_num 1 ; index into map array of room currently occupied by the bubble
1880 .space current_room 1 ; cache of map cell representing current room (i.e. "lda map, y" where y = room_num)
1881 .space num_lives 1
1882 .space num_keys 1
1883
1884 .space player_state 1
1885
1886 .alias state_alive 0
1887 .alias state_popped 1
1888
1889 .space player_timer 1
1890 .space sentry_timer 1
1891 .space sentry_initial 1
1892
1893 ;
1894 ; Arithmetic
1895 ;
1896
1897 .space temp_low 1
1898 .space temp_high 1
1899 .space sign_extend 1
1900
1901 ;
1902 ; Interrupt Handling
1903 ;
1904
1905 .space savecinv 2
1906 .space irq_active 1
1907 .space waiting_collision_clear 1
1908
1909 ;
1910 ; Flags
1911 ;
1912
1913 .space room_changed 1
1914 .space player_died 1
1915 .space player_won 1
1916
1917 ;
1918 ; Temporary Storage in IRQ handler
1919 ;
1920
1921 .space msb_counter 1 ; for calculating sprite's x msb
1922 .space indirect_jump_vector 2
1923
1924 ;
1925 ; Temporary Storage for Setting up Room etc.
1926 ;
1927
1928 .space baddie 1
1929 .space room_delta 1