peasant: add hgr input support

This commit is contained in:
Vince Weaver 2021-08-11 23:53:49 -04:00
parent c0ae45645e
commit 4246c3d5cc
5 changed files with 84 additions and 3 deletions

View File

@ -67,7 +67,7 @@ PEASANT: peasant.o
ld65 -o PEASANT peasant.o -C $(LINKER_SCRIPTS)/apple2_6000.inc
peasant.o: peasant.s graphics/graphics.inc \
draw_box.s hgr_rectangle.s hgr_font.s \
draw_box.s hgr_rectangle.s hgr_font.s hgr_input.s \
title.s directions.s \
cottage.s lake_w.s lake_e.s river.s knight.s \
ending.s
@ -79,6 +79,7 @@ ENDING: ending.o
ld65 -o ENDING ending.o -C $(LINKER_SCRIPTS)/apple2_6000.inc
ending.o: ending.s graphics_end/end_graphics.inc \
hgr_input.s \
draw_box.s hgr_rectangle.s hgr_font.s \
ending.s
ca65 -o ending.o ending.s -l ending.lst

View File

@ -28,7 +28,20 @@ trogdor_question:
jsr decompress_lzsa2_fast
jsr wait_until_keypress
lda #<copy_protection_text
sta OUTL
lda #>copy_protection_text
sta OUTH
jsr hgr_put_string
jsr hgr_put_string
jsr hgr_put_string
jsr hgr_input
;=============================
; game over man
;=============================
game_over:
@ -64,6 +77,7 @@ forever:
.include "hgr_font.s"
.include "draw_box.s"
.include "hgr_rectangle.s"
.include "hgr_input.s"
.include "graphics_end/end_graphics.inc"
@ -72,3 +86,11 @@ peasant_text:
score_text:
.byte 0,2,"Score: 0 of 150",0
; 0123456789012345678901234567890123456789
copy_protection_text:
.byte 0,160,"Before proceeding, don thy red glasses",0
.byte 0,168,"spin the wheel on p27 and answer this:",0
.byte 0,176,"+ Who is Trogdor's cousin's brother?",0

View File

@ -42,7 +42,7 @@ outl_no_oflo:
rts
;==================
; in X
; X in X
; Y in Y
; Char in A
hgr_put_char:

55
games/peasant/hgr_input.s Normal file
View File

@ -0,0 +1,55 @@
;====================
; hgr input
;====================
; TODO: save to string
; TODO: arbitrary Y location
; TODO: when backspacing, erase old char not XOR
hgr_input:
ldx #0
ldy #184
lda #'>'
jsr hgr_put_char
ldx #1
stx INPUT_X
hgr_input_loop:
lda KEYPRESS
bpl hgr_input_loop
bit KEYRESET
and #$7f ; trim off top?
cmp #13
beq done_hgr_input
cmp #$7f
beq hgr_input_backspace
cmp #8
beq hgr_input_backspace
ldy #184
ldx INPUT_X
jsr hgr_put_char
inc INPUT_X
jmp hgr_input_loop
hgr_input_backspace:
ldx INPUT_X
cpx #1 ; don't backspace too far
beq hgr_input_loop
lda #' '
ldy #184
jsr hgr_put_char
dec INPUT_X
jmp hgr_input_loop
done_hgr_input:
rts

View File

@ -17,9 +17,12 @@ CURSOR_Y = $63
WHICH_LOAD=$80
INPUT_X = $D0
WHICH_SLOT = $DA
CURRENT_DISK = $DC
HGR_COLOR = $E4
HGR_PAGE = $E6
P0 = $F1