diff --git a/games/peasant/hgr_input.s b/games/peasant/hgr_input.s index ca65a154..68b6c6d7 100644 --- a/games/peasant/hgr_input.s +++ b/games/peasant/hgr_input.s @@ -6,6 +6,7 @@ ; TODO: when backspacing, erase old char not XOR hgr_input: + bit KEYRESET ldx #0 ldy #184 @@ -23,20 +24,26 @@ hgr_input_loop: and #$7f ; trim off top? - cmp #13 + cmp #13 ; if return, then done beq done_hgr_input - cmp #$7f + cmp #$7f ; check if backspace beq hgr_input_backspace cmp #8 beq hgr_input_backspace - ldy #184 + ldx INPUT_X + sta input_buffer-1,X ; store to buffer + + ldy #184 ; print char ldx INPUT_X jsr hgr_put_char + ldx INPUT_X + cpx #38 + bcs input_too_big ; FIXME this is a hack inc INPUT_X - +input_too_big: jmp hgr_input_loop hgr_input_backspace: @@ -44,12 +51,25 @@ hgr_input_backspace: cpx #1 ; don't backspace too far beq hgr_input_loop - lda #' ' - ldy #184 - jsr hgr_put_char - dec INPUT_X + ldx INPUT_X + + lda input_buffer-1,X ; load old char + ldy #184 + jsr hgr_put_char ; xor it on top + jmp hgr_input_loop done_hgr_input: + + ldx INPUT_X ; NUL terminate + lda #0 + sta input_buffer-1,X + rts + +input_buffer: + .byte 0,0,0,0,0,0,0,0,0,0 + .byte 0,0,0,0,0,0,0,0,0,0 + .byte 0,0,0,0,0,0,0,0,0,0 + .byte 0,0,0,0,0,0,0,0,0,0 diff --git a/games/peasant/peasant.s b/games/peasant/peasant.s index bf95373c..b7b3c215 100644 --- a/games/peasant/peasant.s +++ b/games/peasant/peasant.s @@ -10,8 +10,12 @@ .include "qload.inc" +ENDING_COPY = 1 + peasant_quest: + lda #0 + sta GAME_OVER jsr hgr_make_tables @@ -70,32 +74,7 @@ peasant_quest: ; draw rectangle on bottom -; draw rectangle - - lda #$00 ; color is black1 - sta VGI_RCOLOR - - lda #0 - sta VGI_RX1 - lda #183 - sta VGI_RY1 - lda #140 - sta VGI_RXRUN - lda #9 - sta VGI_RYRUN - - jsr vgi_simple_rectangle - - lda #140 - sta VGI_RX1 - lda #183 - sta VGI_RY1 - lda #140 - sta VGI_RXRUN - lda #9 - sta VGI_RYRUN - - jsr vgi_simple_rectangle + jsr clear_bottom jsr hgr_save @@ -172,10 +151,24 @@ peasant_the_same: jsr check_keyboard + lda GAME_OVER + bne game_over + jmp game_loop + ;************************ + ; copy protection check + ;************************ +game_over: +exit_copy_check: + lda #LOAD_COPY_CHECK + sta WHICH_LOAD + + rts + + check_keyboard: @@ -207,7 +200,7 @@ check_up: cmp #'W' bne check_down - lda #$1 + lda #$FF sta PEASANT_YADD jmp done_check_keyboard @@ -215,7 +208,7 @@ check_down: cmp #'S' bne check_enter - lda #$FF + lda #$1 sta PEASANT_YADD jmp done_check_keyboard @@ -225,7 +218,12 @@ check_enter: cmp #' ' bne done_check_keyboard enter_pressed: + jsr clear_bottom + jsr hgr_input + jsr parse_input + + jsr clear_bottom done_check_keyboard: @@ -235,14 +233,6 @@ done_check_keyboard: - ; read input - - jsr hgr_input - - rts - - - peasant_text: .byte 25,2,"Peasant's Quest",0 @@ -250,16 +240,53 @@ score_text: .byte 0,2,"Score: 0 of 150",0 - ;************************ - ; copy protection check - ;************************ -exit_copy_check: - lda #LOAD_COPY_CHECK - sta WHICH_LOAD + + +parse_input: + jsr hgr_save + + lda input_buffer ; get first char FIXME + and #$DF ; make uppercase 0110 0001 -> 0100 0001 + +parse_copy: + cmp #'C' + bne parse_version + + ; want copy + lda #ENDING_COPY + sta GAME_OVER + jmp done_parse_message + + +parse_version: + cmp #'V' + bne parse_help + + lda #version_message + jmp finish_parse_message + +parse_help: + lda #help_message + +finish_parse_message: + sta OUTH + jsr hgr_text_box + + jsr wait_until_keypress + +done_parse_message: + jsr hgr_restore rts + + + .include "decompress_fast_v2.s" .include "wait_keypress.s" @@ -284,3 +311,40 @@ help_message: .byte 0,43,24, 0,253,82 .byte 8,41,"I don't understand. Type",13 .byte "HELP for assistances.",0 + +version_message: +.byte 0,43,24, 0,253,82 +.byte 8,41,"APPLE ][ PEASANT'S QUEST",13 +.byte "version 0.2",0 + + + +clear_bottom: + ; draw rectangle + + lda #$00 ; color is black1 + sta VGI_RCOLOR + + lda #0 + sta VGI_RX1 + lda #183 + sta VGI_RY1 + lda #140 + sta VGI_RXRUN + lda #9 + sta VGI_RYRUN + + jsr vgi_simple_rectangle + + lda #140 + sta VGI_RX1 + lda #183 + sta VGI_RY1 + lda #140 + sta VGI_RXRUN + lda #9 + sta VGI_RYRUN + + jsr vgi_simple_rectangle + + rts diff --git a/games/peasant/zp.inc b/games/peasant/zp.inc index 87ee824d..9b308c46 100644 --- a/games/peasant/zp.inc +++ b/games/peasant/zp.inc @@ -28,7 +28,7 @@ ALTH = $68 SAVED_X = $69 PEASANT_XADD = $6A PEASANT_YADD = $6B - +GAME_OVER = $6C ; pt3 player registers AY_REGISTERS = $70