From 296a58304861d08eaa9fed0cba75b76fd3ed5dc8 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Wed, 16 Dec 2020 09:54:12 -0500 Subject: [PATCH] duke: working on key actions --- duke/Makefile | 2 +- duke/actions.s | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ duke/duke.s | 1 + duke/keyboard.s | 20 ++++-------------- duke/zp.inc | 4 ++-- 5 files changed, 62 insertions(+), 19 deletions(-) create mode 100644 duke/actions.s diff --git a/duke/Makefile b/duke/Makefile index 671e94ca..a072de2b 100644 --- a/duke/Makefile +++ b/duke/Makefile @@ -43,7 +43,7 @@ DUKE: duke.o duke.o: duke.s zp.inc hardware.inc duke.s \ print_help.s gr_fast_clear.s quit_yn.s text_drawbox.s level_end.s \ - enemies.s \ + enemies.s actions.s \ graphics/duke_graphics.inc \ maps/level1_map.lzsa \ status_bar.s draw_duke.s move_duke.s gr_putsprite_crop.s \ diff --git a/duke/actions.s b/duke/actions.s new file mode 100644 index 00000000..999835d7 --- /dev/null +++ b/duke/actions.s @@ -0,0 +1,54 @@ + + ; someone pressed UP + +up_action: + + ; check if it's a key slot +check_red_keyhole: + + ; check that we have the key + lda INVENTORY + and #INV_RED_KEY + beq done_up_action + + ; open the red wall + ; there has to be a more efficient way of doing this + + ; reset smc + lda #>BIG_TILEMAP + sta rwr_smc1+2 + sta rwr_smc2+2 + +remove_red_wall_outer: + ldx #0 +remove_red_wall_loop: +rwr_smc1: + lda BIG_TILEMAP,X + cmp #49 ; red key tile + bne not_red_tile + lda #2 ; lblue bg tile +rwr_smc2: + sta BIG_TILEMAP,X +not_red_tile: + inx + bne remove_red_wall_loop + + inc rwr_smc1+2 + inc rwr_smc2+2 + + lda rwr_smc1+2 + cmp #(>BIG_TILEMAP)+40 + bne remove_red_wall_outer + + ; refresh local tilemap + + jsr copy_tilemap_subset + + + ; check if it's the exit +check_if_exit: + + +done_up_action: + + rts diff --git a/duke/duke.s b/duke/duke.s index 81c858c5..a3c2a331 100644 --- a/duke/duke.s +++ b/duke/duke.s @@ -220,6 +220,7 @@ done_with_duke: .include "handle_laser.s" .include "draw_tilemap.s" .include "enemies.s" + .include "actions.s" .include "sound_effects.s" diff --git a/duke/keyboard.s b/duke/keyboard.s index 90c07065..4d56beeb 100644 --- a/duke/keyboard.s +++ b/duke/keyboard.s @@ -156,14 +156,9 @@ check_up: cmp #$0B ; up key bne check_down up_pressed: - lda CURSOR_Y ; if 49