From 9330c2c720aae34c2dea5bc9c5b670468e0c77dd Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Tue, 9 Jul 2019 11:23:48 -0400 Subject: [PATCH] ootw: c2: split out elevator code --- ootw/Makefile | 2 +- ootw/hello.bas | 10 +-- ootw/ootw_c2.s | 51 ++++++++++- ootw/ootw_c2_cage.s | 11 +-- ootw/ootw_c2_elevator.s | 194 ++++++++++++++++++++++++++++++++++++++++ ootw/ootw_c2_jail.s | 3 - 6 files changed, 251 insertions(+), 20 deletions(-) create mode 100644 ootw/ootw_c2_elevator.s diff --git a/ootw/Makefile b/ootw/Makefile index a7dff924..064ad9ca 100644 --- a/ootw/Makefile +++ b/ootw/Makefile @@ -56,7 +56,7 @@ ootw_c2.o: ootw_c2.s \ gr_putsprite.s gr_putsprite_flipped.s gr_putsprite_crop.s \ keyboard.s gr_run_sequence.s physicist.s \ ootw_graphics/sprites/sprites_physicist.inc \ - ootw_c2_cage.s ootw_c2_jail.s ootw_c2_intro.s \ + ootw_c2_cage.s ootw_c2_jail.s ootw_c2_elevator.s ootw_c2_intro.s \ ootw_graphics/cage/ootw_c2_cage.inc \ ootw_graphics/l2intro/ootw_l2intro.inc ca65 -o ootw_c2.o ootw_c2.s -l ootw_c2.lst diff --git a/ootw/hello.bas b/ootw/hello.bas index 0f311d62..8cb01784 100644 --- a/ootw/hello.bas +++ b/ootw/hello.bas @@ -14,13 +14,13 @@ 92 PRINT 95 HTAB 12:PRINT "APPLE ][ FOREVER" 100 PRINT:PRINT "WHAT DO YOU WANT TO DO?" - 110 PRINT "1). START WITH INTRO MOVIE" - 120 PRINT "2). START AT CHECKPOINT 1 (IH8S)" - 130 PRINT "3). START AT CHECKPOINT 2 (RAGE)" + 110 PRINT "0). START WITH INTRO MOVIE" + 120 PRINT "1). START AT CHECKPOINT 1 (IH8S)" + 130 PRINT "2). START AT CHECKPOINT 2 (RAGE)" 140 INPUT A - 150 IF A < 1 OR A > 3 THEN 5 + 150 IF A < 0 OR A > 2 THEN 5 155 IF A=1 OR A=2 THEN GOSUB 300 - 160 POKE 5,(A-1) + 160 POKE 5,A 200 PRINT CHR$ (4)"BRUN LOADER" 300 HOME 305 HTAB 8:PRINT "LOADING (BE PATIENT...)" diff --git a/ootw/ootw_c2.s b/ootw/ootw_c2.s index db366940..b085fdaa 100644 --- a/ootw/ootw_c2.s +++ b/ootw/ootw_c2.s @@ -27,7 +27,7 @@ ootw_c2: ; Run the intro ;======================= - jsr ootw_c2_intro +; jsr ootw_c2_intro ;======================= ; Enter the game @@ -35,6 +35,54 @@ ootw_c2: jsr ootw_cage + ;======================= + ; Start Levels + ;======================= + + lda #1 + sta DIRECTION + lda #22 + sta PHYSICIST_Y + lda #24 + sta PHYSICIST_X + lda #0 + sta PHYSICIST_STATE + sta WHICH_JAIL + + ;========================= + ; c2_new_room + ;========================= + ; enter new room on level2 + +c2_new_room: + + lda WHICH_JAIL + cmp #4 + bcs elevator_room ; bge +jail_room: + jsr ootw_jail + jmp c2_check_done + +elevator_room: + cmp #8 + bcs multilevel_room ; bge + jsr ootw_elevator + jmp c2_check_done + +multilevel_room: + ; FIXME + + + +c2_check_done: + ; only exit if done level + ; FIXME: or quit pressed? + + lda WHICH_JAIL + cmp #11 + bne c2_new_room + + ;=========================== ; quit_level ;=========================== @@ -70,6 +118,7 @@ end_message: .include "ootw_c2_cage.s" .include "ootw_c2_jail.s" +.include "ootw_c2_elevator.s" .include "ootw_c2_intro.s" .include "physicist.s" .include "text_print.s" diff --git a/ootw/ootw_c2_cage.s b/ootw/ootw_c2_cage.s index 13ea592d..9b5c24fe 100644 --- a/ootw/ootw_c2_cage.s +++ b/ootw/ootw_c2_cage.s @@ -66,17 +66,8 @@ cage_loop: bit KEYRESET ; clear keyboard - lda #1 - sta DIRECTION - lda #22 - sta PHYSICIST_Y - lda #24 - sta PHYSICIST_X - lda #0 - sta PHYSICIST_STATE - sta WHICH_JAIL - jmp ootw_jail + rts cage_no_keypress: diff --git a/ootw/ootw_c2_elevator.s b/ootw/ootw_c2_elevator.s new file mode 100644 index 00000000..97ac6c34 --- /dev/null +++ b/ootw/ootw_c2_elevator.s @@ -0,0 +1,194 @@ +; Ootw Checkpoint2 -- Using the elevator + +ootw_elevator: + ;=========================== + ; Enable graphics + + bit LORES + bit SET_GR + bit FULLGR + + ;=========================== + ; Setup pages (is this necessary?) + + lda #0 + sta DRAW_PAGE + lda #1 + sta DISP_PAGE + + ;============================= + ; load background image + + jsr jail_load_background + + + ;============================== + ; setup per-room variables + + lda WHICH_JAIL + bne elevator1 + +elevator0: + lda #(20+128) + sta LEFT_LIMIT + lda #(39+128) + sta RIGHT_LIMIT + + ; set right exit + lda #1 + sta jer_smc+1 + lda #ootw_jail + sta jer_smc+6 + + ; set left exit + lda #0 + sta jel_smc+1 + lda #ootw_jail + sta jel_smc+6 + + + jmp jail_setup_done + +elevator1: + lda #(-4+128) + sta LEFT_LIMIT + lda #(39+128) + sta RIGHT_LIMIT + +elevator_setup_done: + + + ;================================= + ; copy to screen + + jsr gr_copy_to_current + jsr page_flip + + ;================================= + ; setup vars + + lda #0 + sta GAIT + sta GAME_OVER + + ;============================ + ; Elevator Loop + ;============================ +elevator_loop: + + ;================================ + ; copy background to current page + + jsr gr_copy_to_current + + ;=============================== + ; check keyboard + + jsr handle_keypress + + ;=============================== + ; move physicist + + jsr move_physicist + + ;=============== + ; check room limits + + jsr check_screen_limit + + + ;=============== + ; draw physicist + + jsr draw_physicist + + + ;================ + ; draw foreground + + ;=============== + ; page flip + + jsr page_flip + + ;================ + ; inc frame count + + inc FRAMEL + bne elevator_frame_no_oflo + inc FRAMEH + +elevator_frame_no_oflo: + + ; check if done this level + + lda GAME_OVER + beq still_in_elevator + + cmp #$ff ; if $ff, we died + beq done_elevator + + ;=============================== + ; check if exited room to right + cmp #1 + beq elevator_exit_left + + ; exit to right +elevator_exit_right: + lda #0 + sta PHYSICIST_X +eer_smc: + lda #$0 + sta WHICH_CAVE + jmp ootw_elevator + +elevator_exit_left: + lda #37 + sta PHYSICIST_X +eel_smc: + lda #0 + sta WHICH_CAVE + jmp ootw_elevator + + + ; loop forever +still_in_elevator: + jmp elevator_loop + +done_elevator: + rts + + + + + ;=============================== + ; load proper background to $c00 + ;=============================== + +elevator_load_background: + + lda WHICH_JAIL + bne elevator_bg1 + +elevator_bg0: + ; load background + lda #>(cage_fell_rle) + sta GBASH + lda #<(cage_fell_rle) + sta GBASL + jmp elevator_bg_done + +elevator_bg1: + ; load background + lda #>(jail2_rle) + sta GBASH + lda #<(jail2_rle) + sta GBASL +elevator_bg_done: + lda #$c ; load to page $c00 + jmp load_rle_gr ; tail call + diff --git a/ootw/ootw_c2_jail.s b/ootw/ootw_c2_jail.s index 28330516..3fd3bf26 100644 --- a/ootw/ootw_c2_jail.s +++ b/ootw/ootw_c2_jail.s @@ -16,8 +16,6 @@ ootw_jail: lda #1 sta DISP_PAGE - - ;============================= ; load background image @@ -87,7 +85,6 @@ jail_loop: jsr gr_copy_to_current - ;======================= ; draw miners mining