From f98a36a5914ccdc4f077a4b24110463d16c7a44f Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Fri, 9 Aug 2019 13:58:58 -0400 Subject: [PATCH] ootw: c4: falling into pit more or less works --- ootw/gr_twoscreen_scroll.s | 8 +- ootw/keyboard.s | 2 + ootw/ootw_c4_city.s | 113 ++++++++++++++++------- ootw/ootw_graphics/sprites/physicist.inc | 15 +++ ootw/physicist.s | 41 +++++++- ootw/zp.inc | 1 + 6 files changed, 144 insertions(+), 36 deletions(-) diff --git a/ootw/gr_twoscreen_scroll.s b/ootw/gr_twoscreen_scroll.s index 2103efa1..bf90920f 100644 --- a/ootw/gr_twoscreen_scroll.s +++ b/ootw/gr_twoscreen_scroll.s @@ -13,6 +13,8 @@ gr_twoscreen_scroll: sta TEMPY ; dest ldy BG_SCROLL + cpy #48 + beq gr_twoscreen_bottom ; no top to draw gr_twoscreen_top: @@ -71,9 +73,11 @@ gr_twoscreen_smc_dst: lda BG_SCROLL beq done_twoscreen_bottom ; if 0, no bottom +gr_twoscreen_bottom: + ldy #0 -gr_twoscreen_bottom: +gr_twoscreen_bottom_loop: ; calculate source @@ -121,6 +125,6 @@ gr_twoscreen_bottom_smc_dst: cpy BG_SCROLL - bne gr_twoscreen_bottom + bne gr_twoscreen_bottom_loop done_twoscreen_bottom: rts ; 6 diff --git a/ootw/keyboard.s b/ootw/keyboard.s index ba0ada15..babd31d4 100644 --- a/ootw/keyboard.s +++ b/ootw/keyboard.s @@ -29,6 +29,8 @@ handle_keypress: beq no_keypress cmp #P_FALLING_SIDEWAYS beq no_keypress + cmp #P_IMPALED + beq no_keypress lda KEYPRESS ; 4 bmi keypress ; 3 diff --git a/ootw/ootw_c4_city.s b/ootw/ootw_c4_city.s index c0d46f3c..1d46f41a 100644 --- a/ootw/ootw_c4_city.s +++ b/ootw/ootw_c4_city.s @@ -17,6 +17,9 @@ ootw_city_init: lda #30 sta PHYSICIST_Y + lda #$2c + sta falling_stop_smc + rts @@ -125,6 +128,10 @@ room3: cmp #3 bne room4 + ; set falling floor + lda #48 + sta fall_down_destination_smc+1 + lda #(-4+128) sta LEFT_LIMIT lda #(39+128) @@ -157,9 +164,6 @@ room3: lda #$BC ; load to page $BC00 jsr load_rle_gr - - - ; load background lda #>(causeway2_rle) sta GBASH @@ -227,9 +231,10 @@ ootw_room_already_set: ;============================ city_loop: - ;================================ - ; copy background to current page - ;================================ + + ;====================================== + ; draw split screen if falling into pit + ;====================================== lda WHICH_ROOM cmp #3 @@ -241,32 +246,74 @@ city_loop: cmp #P_FALLING_DOWN bne nothing_fancy -scroll_bg: - lda FRAMEL - and #$3 - bne no_scroll_progress + ;====================== + ; falling - inc BG_SCROLL - inc BG_SCROLL +scroll_bg: + lda PHYSICIST_Y + cmp #32 + bcc scroll_check ; blt + + lda #9 + sta PHYSICIST_X + + lda #38 + sta PHYSICIST_Y + + lda #0 + sta GAIT + + lda #P_IMPALED + sta PHYSICIST_STATE + +scroll_check: + lda BG_SCROLL ; if done scrolling, re-enable falling + cmp #48 + bne scroll_bg_check22 + lda #$2c + sta falling_stop_smc + jmp not_far_enough + +scroll_bg_check22: + + lda PHYSICIST_Y ; once Y=22, stop falling (scroll bg) + cmp #22 + bcc not_far_enough + + lda #$4c + sta falling_stop_smc + +not_far_enough: + + lda FRAMEL ; slow down a bit + and #$1 + bne no_scroll_progress ldy BG_SCROLL cpy #48 -forever: - beq forever + beq no_scroll_progress + + inc BG_SCROLL + inc BG_SCROLL + +; ldy BG_SCROLL +; cpy #44 +; bne no_scroll_progress + +; lda #P_IMPALED +; sta PHYSICIST_STATE no_scroll_progress: - lda #$94 - ldy #0 -clear1: - sta $c00,Y - sta $d00,Y - sta $e00,Y - sta $f00,Y - iny - bne clear1 - -; ldy BG_SCROLL +; lda #$94 +; ldy #0 +;clear1: +; sta $c00,Y +; sta $d00,Y +; sta $e00,Y +; sta $f00,Y +; iny +; bne clear1 jsr gr_twoscreen_scroll @@ -275,6 +322,11 @@ clear1: nothing_fancy: done_city_bg: + + ;================================ + ; copy background to current page + ;================================ + jsr gr_copy_to_current @@ -358,6 +410,10 @@ c4_no_bg_action: cmp #3 bne regular_room + lda PHYSICIST_Y + cmp #18 + bne regular_room + lda PHYSICIST_X cmp #8 bcc regular_room ; blt @@ -626,10 +682,3 @@ recharge_bg4: -; 9x40 -physicist_spike_sprite: - .byte 3,4 - .byte $AA,$11,$AA - .byte $0A,$90,$0A - .byte $BB,$A9,$BB - .byte $BB,$AA,$BB diff --git a/ootw/ootw_graphics/sprites/physicist.inc b/ootw/ootw_graphics/sprites/physicist.inc index 0e27a49e..26ab530e 100644 --- a/ootw/ootw_graphics/sprites/physicist.inc +++ b/ootw/ootw_graphics/sprites/physicist.inc @@ -570,3 +570,18 @@ jump8: .byte $aa,$44,$c4,$ca,$aa .byte $fa,$f4,$5a,$5c,$aa + +;==================== +;==================== +; On Spike +;==================== +;==================== + +; 9x40 +physicist_spike_sprite: + .byte 3,4 + .byte $AA,$11,$AA + .byte $0A,$90,$0A + .byte $BB,$A9,$BB + .byte $BB,$AA,$BB + diff --git a/ootw/physicist.s b/ootw/physicist.s index 9e016110..9e694a02 100644 --- a/ootw/physicist.s +++ b/ootw/physicist.s @@ -74,6 +74,7 @@ pstate_table_lo: .byte physicist_standing @@ -89,6 +90,7 @@ pstate_table_hi: .byte >physicist_standing ; 0A elevator down .byte >physicist_shooting ; 0B .byte >physicist_falling_down ; 0C + .byte >physicist_impaled ; 0D ; Urgh, make sure this doesn't end up at $FF or you hit the ; NMOS 6502 bug @@ -367,12 +369,14 @@ still_falling: physicist_falling_down: +falling_stop_smc: ; $2C to fall, $4C for not + bit still_falling_down lda FRAMEL - and #$3 + and #$1 bne no_fall_down_progress - inc PHYSICIST_Y ; must me mul of 2 + inc PHYSICIST_Y ; must be mul of 2 inc PHYSICIST_Y no_fall_down_progress: @@ -399,6 +403,39 @@ still_falling_down: +;================================== +; IMPALED +;================================== + +physicist_impaled: + + lda GAIT + cmp #$f0 + bne impale_not_done + +impale_really_dead: + lda #$ff + sta GAME_OVER + jmp finally_draw_him + +impale_not_done: + + cmp #2 ; slide down one more + bne impale_enough + inc PHYSICIST_Y + inc PHYSICIST_Y + +impale_enough: + inc GAIT + + lda #physicist_spike_sprite + sta INH + + jmp finally_draw_him + ;============================= ; Actually Draw Him ;============================= diff --git a/ootw/zp.inc b/ootw/zp.inc index 1f40899c..2e40e2f6 100644 --- a/ootw/zp.inc +++ b/ootw/zp.inc @@ -182,6 +182,7 @@ PHYSICIST_STATE = $EA P_ELEVATING_DOWN = $0A P_SHOOTING = $0B P_FALLING_DOWN = $0C + P_IMPALED = $0D BUBBLES_Y = $EB ; C1 underwater BEFORE_SWING = $EB ; C1