From a4aa2f69497d453f7ea314a6baa43fbefa22df71 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Thu, 18 Feb 2016 07:00:17 -0500 Subject: shrink code, 5829 bytes free --- taipan.c | 45 ++++++++++++++++++--------------------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/taipan.c b/taipan.c index 1853834..9c2386d 100644 --- a/taipan.c +++ b/taipan.c @@ -1349,26 +1349,19 @@ unsigned long get_num(void) { unsigned char count = 0; char input; - // cursor(1); - // cblank(1); - while((input = numgetc()) != '\n') { - if(count >= 10) continue; if(input == BKSP) { if(!count) continue; backspace(); - num_buf[count] = '\0'; count--; } else if(input == 'a') { if(!count) { - // cursor(0); return UINT32_MAX; } } else if(input == 'k' || input == 'm') { char i; for(i = 0; i < (input == 'k' ? 3 : 6); i++) { - cputc('0'); - num_buf[count++] = '0'; + cputc(num_buf[count++] = '0'); if(count >= 10) break; } } else if(input == DEL) { @@ -1376,22 +1369,19 @@ unsigned long get_num(void) { backspace(); count--; } - POKEW(1024, count); } else { - cputc(input); - num_buf[count++] = input; + if(count >= 10) continue; + cputc(num_buf[count++] = input); } } - // cursor(0); + num_buf[count] = '\0'; - // return strtoul(num_buf, (char **)NULL, 10); return strtonum(num_buf); } /* TODO: rewrite in asm */ -void cash_or_guns(void) -{ - int choice = 0; +void cash_or_guns(void) { + char choice; clrscr(); cprint_Do_you_want(); @@ -1401,20 +1391,17 @@ void cash_or_guns(void) cputs("-- or --\r\n\n"); cputs(" 2) With five guns and no cash\r\n"); cspaces(16); - cputs("(But no debt!)\r\n"); + cputs("(But no debt!)"); + gotoxy(10, 10); + cputc('?'); - while ((choice != '1') && (choice != '2')) - { - gotoxy(10, 10); - cputc('?'); + do { choice = agetc(); - } + } while ((choice != '1') && (choice != '2')); - cputc(choice); capacity = 60; damage = 0; - if (choice == '1') - { + if(choice == '1') { cash = 400; debt = 5000; hold = 60; @@ -1453,8 +1440,6 @@ void cash_or_guns(void) damage = capacity - 1; #endif } - - return; } void set_prices(void) { @@ -1953,6 +1938,11 @@ void final_stats(void) return; } + /* player said No, don't play again... + for the xex build, exit(0) gets us back to DOS. + for the cartridge, it returns us to the title screen. */ + +#ifndef CART_TARGET /* exit(0) works by itself in DOS 2.0S or 2.5, or any DUP.SYS style DOS that reopens the E: device when entering the menu. However, command-line DOSes (XL and Sparta) don't do this, @@ -1966,6 +1956,7 @@ void final_stats(void) color1save and color2save in newtitle.s. */ POKE(709, PEEK(0x3c2)); POKE(710, PEEK(0x3c3)); +#endif exit(0); } -- cgit v1.2.3