From 4ff916de3f977e1bb3c85717ba219c40a34af70f Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sat, 6 Feb 2016 05:10:45 -0500 Subject: trim another few bytes --- taipan.c | 103 ++++++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 59 insertions(+), 44 deletions(-) diff --git a/taipan.c b/taipan.c index fc346ff..6d8d12f 100644 --- a/taipan.c +++ b/taipan.c @@ -259,11 +259,19 @@ char *item[] = { "Opium", "Silk", "Arms", "General Cargo" }; char *location[] = { "At sea", "Hong Kong", "Shanghai", "Nagasaki", "Saigon", "Manila", "Singapore", "Batavia" }; -/* -char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; - */ -char *months = "Jan\0Feb\0Mar\0Apr\0May\0Jun\0Jul\0Aug\0Sep\0Oct\0Nov\0Dec\0"; +// inverse "Jan\0Feb\0Mar\0Apr\0May\0Jun\0Jul\0Aug\0Sep\0Oct\0Nov\0Dec\0"; +char *months = "\xca\xe1\xee\0" + "\xc6\xe5\xe2\0" + "\xcd\xe1\xf2\0" + "\xc1\xf0\xf2\0" + "\xcd\xe1\xf9\0" + "\xca\xf5\xee\0" + "\xca\xf5\xec\0" + "\xc1\xf5\xe7\0" + "\xd3\xe5\xf0\0" + "\xcf\xe3\xf4\0" + "\xce\xef\xf6\0" + "\xc4\xe5\xe3\0"; char *st[] = { "\xc3\xf2\xe9\xf4\xe9\xe3\xe1\xec", // inverse "Critical" @@ -344,6 +352,11 @@ unsigned char port = 1, // displaying ship status. long damage = 0, capacity = 60, newdamage; +/* a bunch of text strings that occur multiple times in the + prompts. Each of these actually does save a few bytes, but + there are diminishing returns. Anything that only occurs twice + might or might not be worth turning into a function. */ + void how_much(void) { cputs("How much "); } @@ -374,15 +387,23 @@ void cprint_taipan_comma(void) { comma_space(); } +void cprint_bang(void) { + cputc('!'); +} + +void cprint_pipe(void) { + cputc('|'); +} + void cprint_taipan_bang(void) { comma_space(); cprint_taipan(); - cputc('!'); + cprint_bang(); } void cprint_taipan_bangbang(void) { cprint_taipan_bang(); - cputc('!'); + cprint_bang(); } void cprint_taipan_period(void) { @@ -397,6 +418,10 @@ void cprint_taipan_prompt(void) { cputs("? "); } +void do_you_wish(void) { + cputs("do you wish "); +} + #ifdef BIGNUM bignum(big1T) = BIG_1T; bignum(big1B) = BIG_1B; @@ -429,9 +454,8 @@ void cprintfancy_big(bignump b) { } if(big_cmp(tmp, big1T) >= 0) { - revers(1); - cputs("1 Trillion+!"); - revers(0); + // inverse "1 Trillion+!": + cputs("\xb1\xa0\xd4\xf2\xe9\xec\xec\xe9\xef\xee\xab\xa1"); return; } @@ -540,14 +564,11 @@ void new_ship(void) { compradores_report(); cputs("Do you wish to trade in your "); if(damage > 0) { - revers(1); - cputs("damaged"); - revers(0); + cputs("\xe4\xe1\xed\xe1\xe7\xe5\xe4"); // inverse "damaged" } else { cputs("fine"); } - cputs("\r\nship for one with 50 more capacity by\r\n"); - cputs("paying an additional "); + cputs("\r\nship for one with 50 more capacity by\r\npaying an additional "); cprintfancy(amount); cprint_taipan_prompt(); @@ -1491,9 +1512,7 @@ void port_stats(void) cblank(8); cprintulong(hold); } else { - revers(1); - cputs("Overload"); - revers(0); + cputs("\xcf\xf6\xe5\xf2\xec\xef\xe1\xe4"); // inverse "Overload" } gotoxy(22, 8); @@ -1525,9 +1544,9 @@ void port_stats(void) */ gotoxy(32, 3); - revers(1); + // revers(1); cputs(months + 4 * (month - 1)); - revers(0); + // revers(0); cspace(); cprintulong(year); @@ -1790,7 +1809,8 @@ void final_stats(void) cputc(5); // upper right corner // cputs("\r\n"); crlf(); - cputc('|'); + cprint_pipe(); + // cputc('|'); if (score > 49999L) { @@ -1800,7 +1820,8 @@ void final_stats(void) revers(0); cspaces(9); cputs("50,000 and over |\r\n"); - cputc('|'); + cprint_pipe(); + // cputc('|'); if ((score < 50000L) && (score > 7999L)) { @@ -1809,7 +1830,8 @@ void final_stats(void) cputs("Master Taipan"); revers(0); cputs(" 8,000 to 49,999|\r\n"); - cputc('|'); + cprint_pipe(); + // cputc('|'); if ((score < 8000L) && (score > 999L)) { @@ -1820,7 +1842,8 @@ void final_stats(void) revers(0); cspaces(10); cputs("1,000 to 7,999|\r\n"); - cputc('|'); + cprint_pipe(); + // cputc('|'); if ((score < 1000) && (score > 499)) { @@ -1830,7 +1853,8 @@ void final_stats(void) revers(0); cspaces(8); cputs("500 to 999|\r\n"); - cputc('|'); + cprint_pipe(); + // cputc('|'); if (score < 500) { @@ -2031,7 +2055,8 @@ void quit(void) compradores_report(); cprint_taipan_comma(); - cputs("do you wish me to go to:\r\n"); + do_you_wish(); + cputs("me to go to:\r\n"); for(choice = 1; choice < 8; ++choice) { if(choice == 7) crlf(); @@ -2165,7 +2190,7 @@ void quit(void) "It's worth "); // cputs(fancy_num); cprintfancy(booty); - cputc('!'); + cprint_bang(); cash += booty; good_joss_sound(); } else if (result == 3) { @@ -2332,20 +2357,6 @@ void li_yuen_extortion(void) { // amount = ((cash / i) * ((float) randi() / RAND_MAX)) + j; amount = randclamp((cash >> (i - 1))) + j; - /* - clear_msg_window(); - cputs("DEBUG li_yuen_extortion()\r\n"); - cputs("amount time i j\r\n"); - cprintulong(amount); - cspace(); - cprintulong(time); - cspace(); - cprintulong(i); - cspace(); - cprintulong(j); - agetc(); - */ - if(!amount) return; /* asking for 0 is dumb */ compradores_report(); @@ -2510,7 +2521,8 @@ void elder_brother_wu(void) { compradores_report(); how_much(); - cputs("do you wish to repay\r\nhim? "); + do_you_wish(); + cputs("to repay\r\nhim? "); wu = get_num(); if(wu == UINT32_MAX) @@ -2542,7 +2554,8 @@ void elder_brother_wu(void) { compradores_report(); how_much(); - cputs("do you wish to\r\nborrow? "); + do_you_wish(); + cputs("to \r\nborrow? "); wu = get_num(); @@ -2766,7 +2779,9 @@ void name_firm(void) { char what_do_you_wish_me_to(char buy_or_sell) { gotoxy(0, 22); clrtobot(); - cputs("What do you wish me to "); + cputs("What "); + do_you_wish(); + cputs("me to "); cputs(buy_or_sell ? "buy" : "sell"); cprint_taipan_prompt(); return get_item(0); -- cgit v1.2.3