From 43da6edbfa483d8fa9755538242ce6402d585d4e Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Sun, 20 Jan 2019 01:05:52 -0500 Subject: [PATCH] ootw: spin off earthquake code --- ootw/Makefile | 2 +- ootw/earthquake.s | 62 ++++++++++++++++++++++++++++++++++++++++++++++ ootw/ootw.s | 1 + ootw/ootw_cavern.s | 60 ++------------------------------------------ 4 files changed, 66 insertions(+), 59 deletions(-) create mode 100644 ootw/earthquake.s diff --git a/ootw/Makefile b/ootw/Makefile index 88d8ffb5..026a99e0 100644 --- a/ootw/Makefile +++ b/ootw/Makefile @@ -18,7 +18,7 @@ OOTW: ootw.o ootw.o: ootw.s \ gr_copy.s gr_fast_clear.s gr_pageflip.s gr_unrle.s gr_putsprite.s \ keyboard.s sluggy.s \ - ootw_rope.s \ + ootw_rope.s earthquake.s \ ootw_pool.s ootw_cavern.s physicist.s random16.s slug_cutscene.s \ ootw_pool.inc \ ootw_cavern.inc ootw_cavern2.inc ootw_cavern3.inc \ diff --git a/ootw/earthquake.s b/ootw/earthquake.s new file mode 100644 index 00000000..936bce1e --- /dev/null +++ b/ootw/earthquake.s @@ -0,0 +1,62 @@ + ;========================== + ; check for earthquake + +earthquake_handler: + lda FRAMEH + and #3 + bne earth_mover + lda FRAMEL + cmp #$ff + bne earth_mover +earthquake_init: + lda #200 + sta EQUAKE_PROGRESS + + lda #0 + sta BOULDER_Y + jsr random16 + lda SEEDL + and #$1f + clc + adc #4 + sta BOULDER_X + + +earth_mover: + lda EQUAKE_PROGRESS + beq earth_still + + and #$8 + bne earth_calm + + lda #2 + bne earth_decrement + +earth_calm: + lda #0 +earth_decrement: + sta EARTH_OFFSET + dec EQUAKE_PROGRESS + jmp earth_done + + +earth_still: + lda #0 + sta EARTH_OFFSET + +earth_done: + + ;================================ + ; copy background to current page + + lda EARTH_OFFSET + bne shake_shake +no_shake: + jsr gr_copy_to_current + jmp done_shake +shake_shake: + jsr gr_copy_to_current_1000 +done_shake: + + rts + diff --git a/ootw/ootw.s b/ootw/ootw.s index a7e904a4..361e8127 100644 --- a/ootw/ootw.s +++ b/ootw/ootw.s @@ -121,6 +121,7 @@ end_message: .include "ootw_cavern.s" .include "physicist.s" .include "sluggy.s" +.include "earthquake.s" .include "text_print.s" .include "gr_pageflip.s" .include "gr_unrle.s" diff --git a/ootw/ootw_cavern.s b/ootw/ootw_cavern.s index 95995ec1..1c6c29d5 100644 --- a/ootw/ootw_cavern.s +++ b/ootw/ootw_cavern.s @@ -78,65 +78,9 @@ cave_bg_done: cavern_loop: ;========================== - ; check for earthquake - -earthquake_handler: - lda FRAMEH - and #3 - bne earth_mover - lda FRAMEL - cmp #$ff - bne earth_mover -earthquake_init: - lda #200 - sta EQUAKE_PROGRESS - - lda #0 - sta BOULDER_Y - jsr random16 - lda SEEDL - and #$1f - clc - adc #4 - sta BOULDER_X - - -earth_mover: - lda EQUAKE_PROGRESS - beq earth_still - - and #$8 - bne earth_calm - - lda #2 - bne earth_decrement - -earth_calm: - lda #0 -earth_decrement: - sta EARTH_OFFSET - dec EQUAKE_PROGRESS - jmp earth_done - - -earth_still: - lda #0 - sta EARTH_OFFSET - -earth_done: - - ;================================ - ; copy background to current page - - lda EARTH_OFFSET - bne shake_shake -no_shake: - jsr gr_copy_to_current - jmp done_shake -shake_shake: - jsr gr_copy_to_current_1000 -done_shake: + ; handle earthquake + jsr earthquake_handler ;=============== ; handle slug death