duke: working on key actions

This commit is contained in:
Vince Weaver 2020-12-16 09:54:12 -05:00
parent e91572962f
commit 296a583048
5 changed files with 62 additions and 19 deletions

View File

@ -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 \

54
duke/actions.s Normal file
View File

@ -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

View File

@ -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"

View File

@ -156,14 +156,9 @@ check_up:
cmp #$0B ; up key
bne check_down
up_pressed:
lda CURSOR_Y ; if 49<y<$F0 don't decrement
cmp #49
bcc do_dec_cursor_y
cmp #$F0
bcc done_up_pressed
do_dec_cursor_y:
dec CURSOR_Y
dec CURSOR_Y
jsr up_action
done_up_pressed:
jmp done_keypress
@ -173,14 +168,7 @@ check_down:
cmp #$0A
bne check_space
down_pressed:
lda CURSOR_Y ; if 48<y<$EE don't decrement
cmp #48
bcc do_inc_cursor_y
cmp #$EE
bcc done_down_pressed
do_inc_cursor_y:
inc CURSOR_Y
inc CURSOR_Y
done_down_pressed:
jmp done_keypress

View File

@ -32,8 +32,8 @@ XMAX = $50
FRAMEL = $60
FRAMEH = $61
CURSOR_X = $62
CURSOR_Y = $63
;CURSOR_X = $62
;CURSOR_Y = $63
XPOS = $64
YPOS = $65
LOCATION_STRUCT_L = $66