From 47f494288d0ab525ddc93efefaf08dfb084dd10c Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Mon, 19 Apr 2021 15:26:48 -0400 Subject: Allow pressing Enter to abort buy/sell (costs 15 bytes) --- timed_getch.s | 68 +++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 21 deletions(-) (limited to 'timed_getch.s') diff --git a/timed_getch.s b/timed_getch.s index 5c5ff7c..6ea1bff 100644 --- a/timed_getch.s +++ b/timed_getch.s @@ -1,6 +1,6 @@ .export _timed_getch, _set_jiffy_timer, _agetc, _numgetc - .export _yngetc, _lcgetc, _jsleep, _get_item, _tjsleep + .export _yngetc, _lcgetc, _jsleep, _get_item_port, _get_item_battle, _tjsleep .import _cgetc, _cblank, putchar, _rand, _turbo .include "atari.inc" @@ -175,28 +175,54 @@ _yngetc: beq _yngetc ; no default, get another keypress rts ; else return the default -; extern unsigned char get_item(unsigned char allow_all); -_get_item: - sta FR0 ; stash arg +; extern unsigned char get_item_port(void) +; return 0-3 for opium, silk, arms, general. +; return 5 for Enter key (nothing chosen) +_get_item_port: + lda #4 + .byte $2c + +; extern unsigned char get_item_battle(void) +; return 0-4 for opium, silk, arms, general, all. +_get_item_battle: + lda #5 + sta FR0 +@get_loop: + jsr get_item + cmp FR0 + beq @get_loop + rts + + +get_item: @getkey: jsr _lcgetc ; switch(lcgetc()) { - ldx #0 - cmp #'o' - beq @gi_done ; case 'o': return 0; - inx - cmp #'s' - beq @gi_done ; case 's': return 1; - inx - cmp #'a' - beq @gi_done ; case 'a': return 2; - inx - cmp #'g' - beq @gi_done ; case 'g': return 3; - ldy FR0 - beq @getkey ; if allow_all is false, get another key - inx - cmp #'*' ; case '*': return 4; - bne @getkey ; if none of the above, get another key + sta FR0+1 + +;;; ldx #0 +;;; cmp #'o' +;;; beq @gi_done ; case 'o': return 0; +;;; inx +;;; cmp #'s' +;;; beq @gi_done ; case 's': return 1; +;;; inx +;;; cmp #'a' +;;; beq @gi_done ; case 'a': return 2; +;;; inx +;;; cmp #'g' +;;; beq @gi_done ; case 'g': return 3; + + ldx #5 +@giloop: + lda items_tbl,x + cmp FR0+1 + beq @gi_done + dex + bpl @giloop + bmi @getkey @gi_done: txa rts + +.rodata + items_tbl: .byte "osag*",$9b -- cgit v1.2.3