diff options
author | B. Watson <yalhcru@gmail.com> | 2021-04-19 15:26:48 -0400 |
---|---|---|
committer | B. Watson <yalhcru@gmail.com> | 2021-04-19 15:26:48 -0400 |
commit | 47f494288d0ab525ddc93efefaf08dfb084dd10c (patch) | |
tree | 5cb9e7fc31a7aa60b7a0ca5678dfdc521ce8af57 | |
parent | bd3b540db943c2ffdd246d88af212cfe41511d0f (diff) | |
download | taipan-47f494288d0ab525ddc93efefaf08dfb084dd10c.tar.gz |
Allow pressing Enter to abort buy/sell (costs 15 bytes)
-rw-r--r-- | taipan.c | 13 | ||||
-rw-r--r-- | timed_getch.s | 68 |
2 files changed, 54 insertions, 27 deletions
@@ -251,10 +251,9 @@ void backspace() { } */ -/* get an inventory item, return its index into items[]. - if allow_all is true, allows '*', which is used for - 'throw cargo' in sea_battle. */ -extern unsigned char get_item(unsigned char allow_all); + +extern unsigned char get_item_port(void); +extern unsigned char get_item_battle(void); /* rewritten in asm, in timed_getch.s, here's the original: @@ -1319,7 +1318,7 @@ char sea_battle(char id, int num_ships) { print_msg(M_what_shall_i_throw); cprint_taipan_prompt(); - choice = get_item(1); + choice = get_item_battle(); if(choice < 4) { gotox0y(6); @@ -3082,7 +3081,7 @@ char what_do_you_wish_me_to(char *buy_or_sell) { print_msg(M_me_to); cputs(buy_or_sell); cprint_taipan_prompt(); - return get_item(0); + return get_item_port(); } #ifdef CART_TARGET # pragma code-name (pop) @@ -3093,6 +3092,7 @@ void buy(void) { unsigned long afford, amount; choice = what_do_you_wish_me_to("buy"); + if(choice == 5) return; for (;;) { gotoxy(31, 21); @@ -3152,6 +3152,7 @@ void sell(void) { unsigned long amount; choice = what_do_you_wish_me_to("sell"); + if(choice == 5) return; for (;;) { gotox0y22(); 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 |