duke: add help screen

This commit is contained in:
Vince Weaver 2020-12-11 00:44:55 -05:00
parent 19e128a4a6
commit fd99d63dbf
7 changed files with 73 additions and 6 deletions

View File

@ -26,6 +26,7 @@ DUKE: duke.o
ld65 -o DUKE duke.o -C ../linker_scripts/apple2_2000.inc
duke.o: duke.s zp.inc hardware.inc duke.s \
print_help.s \
graphics/duke_graphics.inc \
maps/level1_map.lzsa \
status_bar.s draw_duke.s gr_putsprite_crop.s \

View File

@ -6,6 +6,8 @@ move_duke:
jsr check_falling
jsr handle_jumping
lda DUKE_WALKING
beq done_move_duke
@ -63,11 +65,30 @@ duke_collide:
rts
;=========================
; check_jumping
;=========================
handle_jumping:
lda DUKE_JUMPING
beq done_handle_jumping
dec DUKE_Y
dec DUKE_Y
dec DUKE_JUMPING
done_handle_jumping:
rts
;=========================
; check_falling
;=========================
check_falling:
lda DUKE_JUMPING
bne done_check_falling
; check below feet
; block index below feet is (y+10)*16/4 + (x/2) + 1
@ -100,7 +121,7 @@ check_falling:
jsr copy_tilemap_subset
done_check_below:
done_check_falling:
rts

View File

@ -159,6 +159,7 @@ done_with_duke:
.include "status_bar.s"
.include "keyboard.s"
.include "joystick.s"
.include "print_help.s"
.include "draw_duke.s"
.include "handle_laser.s"

View File

@ -78,13 +78,20 @@ keypress:
check_sound:
cmp #$14 ; control-T
bne check_joystick
bne check_help
lda SOUND_STATUS
eor #SOUND_DISABLED
sta SOUND_STATUS
jmp done_keypress
check_help:
cmp #'H' ; H (^H is same as left)
bne check_joystick
jsr print_help
jmp done_keypress
; can't be ^J as that's the same as down
check_joystick:
cmp #'J' ; J
@ -163,7 +170,7 @@ check_down:
cmp #'S'
beq down_pressed
cmp #$0A
bne check_return
bne check_space
down_pressed:
lda CURSOR_Y ; if 48<y<$EE don't decrement
cmp #48
@ -182,6 +189,11 @@ check_space:
space_pressed:
; jump
lda DUKE_JUMPING
bne done_keypress ; don't jump if already jumping
lda #5
sta DUKE_JUMPING
jmp done_keypress

32
duke/print_help.s Normal file
View File

@ -0,0 +1,32 @@
; For Help press ^H
print_help:
bit KEYRESET ; clear keyboard
bit SET_TEXT
jsr HOME
lda #<help_text
sta OUTL
lda #>help_text
sta OUTH
jsr move_and_print_list
jsr page_flip
wait_for_keypress:
lda KEYPRESS
bpl wait_for_keypress
bit KEYRESET
bit SET_GR
rts
help_text:
.byte 0, 5,"CONTROLS:",0
.byte 3, 6, "A OR <- : MOVE LEFT",0
.byte 3, 7, "D OR -> : MOVE RIGHT",0
.byte 3, 8, "SPACEBAR : JUMP",0
.byte 3,11, "RETURN : SHOOT LASER",0
.byte 3,12, "ESC : QUITS",0
.byte 255

View File

@ -22,7 +22,7 @@ draw_status_bar:
help_string:
.byte 3,20," PRESS ^H FOR HELP ",0
.byte 3,20," PRESS 'H' FOR HELP ",0
score_string:
; 012456789012345678901234567890123456789

View File

@ -90,7 +90,7 @@ done_print_string:
rts
.if 0
;================================
; move and print a list of lines
;================================
@ -103,7 +103,7 @@ move_and_print_list:
rts
.if 0
;================================
; move and print a list of lines
;================================