From a6ef892a3c562641dcca20ef7fac966ecffb0c67 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Thu, 4 Feb 2016 15:03:30 -0500 Subject: crunch another 100 bytes of code --- taipan.c | 162 +++++++++++++++++++++++++++++---------------------------------- 1 file changed, 74 insertions(+), 88 deletions(-) diff --git a/taipan.c b/taipan.c index 685cf45..6ff242f 100644 --- a/taipan.c +++ b/taipan.c @@ -75,8 +75,6 @@ extern void __fastcall__ jsleep(unsigned int j); /* flash screen when we're hit in combat */ extern void explosion(void); -#define flushinp() (POKE(764,255)) - /* Atari-specific random number functions from rand.s. Non-Atari platforms can probably just: #define initrand() _randomize() @@ -152,16 +150,16 @@ unsigned char one_chance_in(unsigned char odds) { return ( (randi() % odds) == 0); } -/* print 'count' spaces */ -void cspaces(unsigned char count) { - while(count--) cputc(' '); -} - /* print 1 space */ void cspace(void) { cputc(' '); } +/* print 'count' spaces */ +void cspaces(unsigned char count) { + while(count--) cspace(); +} + /* print 'count' spaces, but leave the cursor where it was. TODO: rewrite in asm. */ void cblank(unsigned char count) { @@ -246,6 +244,7 @@ void cprint_taipan_comma(void); void cprint_taipan_bang(void); void cprint_taipan_bangbang(void); void cprint_taipan_period(void); +void cprint_taipan_prompt(void); unsigned char firmpos; @@ -329,6 +328,15 @@ unsigned char port = 1, // displaying ship status. long damage = 0, capacity = 60, newdamage; +void how_much(void) { + cputs("How much "); +} + +void how_much_will_you(void) { + how_much(); + cputs("will you "); +} + void cprint_bad_joss() { cputs("Bad Joss!!\r\n"); } @@ -367,6 +375,12 @@ void cprint_taipan_period(void) { cputc('.'); } +void cprint_taipan_prompt(void) { + comma_space(); + cprint_taipan(); + cputs("? "); +} + #ifdef BIGNUM bignum(big1T) = BIG_1T; bignum(big1B) = BIG_1B; @@ -519,7 +533,7 @@ void new_ship(void) { cputs("\r\nship for one with 50 more capacity by\r\n"); cputs("paying an additional "); cprintfancy(amount); - cputs(", Taipan? "); + cprint_taipan_prompt(); choice = yngetc(0); if(choice == 'y') { @@ -561,7 +575,7 @@ void new_gun(void) cputs("Do you wish to buy a ship's gun\r\nfor "); // cputs(fancy_num); cprintfancy(amount); - cputs(", Taipan? "); + cprint_taipan_prompt(); choice = yngetc(0); if(choice == 'y') { @@ -686,7 +700,11 @@ void fight_stats(int ships, int orders) { justify_int(ships); cputs(" ship"); if(ships != 1) cputc('s'); - cputs(" attacking, Taipan! \r\n"); + // cputs(" attacking, Taipan! \r\n"); + cputs(" attacking"); + cprint_taipan_bang(); + cspace(); + crlf(); cputs("Your orders are: "); if(orders == 1) @@ -888,7 +906,6 @@ int sea_battle(int id, int num_ships) { plus_or_space(num_ships > num_on_screen); gotoxy(0, 16); - // cputs("\r\n"); crlf(); do { @@ -1006,14 +1023,16 @@ int sea_battle(int id, int num_ships) { gotoxy(0, 6); clrtoeol(); - cputs("What shall I throw overboard, Taipan? "); + cputs("What shall I throw overboard"); + cprint_taipan_prompt(); choice = get_item(1); if(choice < 4) { gotoxy(0, 6); clrtoeol(); - cputs("How much, Taipan? "); + cputs("How much"); + cprint_taipan_prompt(); amount = get_num(); if((hold_[choice] > 0) && ((amount == UINT32_MAX) || (amount > hold_[choice]))) @@ -1074,7 +1093,6 @@ int sea_battle(int id, int num_ships) { ok += ik++; if(randi()%ok > randi()%num_ships) { - // flushinp(); gotoxy(0, 3); clrtoeol(); cputs("We got away from 'em"); @@ -1555,7 +1573,8 @@ void mchenry(void) cputs("% damaged.\r\nWe can fix yer whole ship for "); cprintulong(repair_price); cputs(",\r\nor make partial repairs if you wish.\r\n"); - cputs("How much will ye spend? "); + how_much(); + cputs("will ye spend? "); for (;;) { gotoxy(24, 21); @@ -1852,6 +1871,10 @@ char have_no_cargo(void) { return 1; } +void you_have_only(void) { + cputs("You have only "); +} + void transfer(void) { int i, in_use; @@ -1876,9 +1899,10 @@ void transfer(void) for (;;) { compradores_report(); - cputs("How much "); + how_much(); cputs(item[i]); - cputs(" shall I move\r\nto the warehouse, Taipan? "); + cputs(" shall I move\r\nto the warehouse"); + cprint_taipan_prompt(); amount = get_num(); if (amount == UINT32_MAX) @@ -1913,7 +1937,7 @@ void transfer(void) clear_msg_window(); // gotoxy(0, 18); // clrtobot(); - cputs("You have only "); + you_have_only(); cprintulong(hold_[i]); // cputs(", Taipan.\r\n"); cprint_taipan_period(); @@ -1930,9 +1954,10 @@ void transfer(void) for (;;) { compradores_report(); - cputs("How much "); + how_much(); cputs(item[i]); - cputs(" shall I move\r\naboard ship, Taipan? "); + cputs(" shall I move\r\naboard ship"); + cprint_taipan_prompt(); amount = get_num(); if (amount == UINT32_MAX) @@ -1949,7 +1974,7 @@ void transfer(void) clear_msg_window(); // gotoxy(0, 18); // clrtobot(); - cputs("You have only "); + you_have_only(); cprintulong(hkw_[i]); cprint_taipan_period(); // cputs("\r\n"); @@ -1988,10 +2013,10 @@ void quit(void) cputs(" ? "); /* - cputs("1) Hong Kong, 2) Shanghai, 3) Nagasaki,\r\n"); - cputs("4) Saigon, 5) Manila, 6) Singapore, or\r\n"); - cputs("7) Batavia ? "); - */ + cputs("1) Hong Kong, 2) Shanghai, 3) Nagasaki,\r\n" + "4) Saigon, 5) Manila, 6) Singapore, or\r\n" + "7) Batavia ? "); + */ for (;;) { @@ -2424,7 +2449,8 @@ void elder_brother_wu(void) cprintulong(i); cputs(" if you will pay back\r\n"); cprintulong(j); - cputs(". Are you willing, Taipan? "); + cputs(". Are you willing"); + cprint_taipan_prompt(); choice = agetc(); if(choice != 'y') { @@ -2453,7 +2479,8 @@ void elder_brother_wu(void) for (;;) { compradores_report(); - cputs("How much do you wish to repay\r\nhim? "); + how_much(); + cputs("do you wish to repay\r\nhim? "); wu = get_num(); if(wu == UINT32_MAX) @@ -2484,7 +2511,8 @@ void elder_brother_wu(void) for (;;) { compradores_report(); - cputs("How much do you wish to\r\nborrow? "); + how_much(); + cputs("do you wish to\r\nborrow? "); wu = get_num(); @@ -2708,42 +2736,22 @@ void name_firm(void) { return; } +void what_do_you_wish_me_to(void) { + cputs("What do you wish me to "); +} + void buy(void) { int choice = 0; unsigned long afford, amount; gotoxy(0, 22); clrtobot(); - cputs("What do you wish me to buy, Taipan? "); + what_do_you_wish_me_to(); + cputs("buy"); + cprint_taipan_prompt(); choice = get_item(0); - /* - for (;;) - { - gotoxy(0, 22); - clrtobot(); - - cputs("What do you wish me to buy, Taipan? "); - - choice = tolower(agetc()); - if(choice == 'o') { - choice = 0; - break; - } else if (choice == 's') { - choice = 1; - break; - } else if (choice == 'a') { - choice = 2; - break; - } else if (choice == 'g') { - choice = 3; - break; - } - } - */ - - for (;;) - { + for (;;) { gotoxy(31, 21); clrtobot(); @@ -2752,7 +2760,7 @@ void buy(void) { cputs(" You can "); revers(0); gotoxy(0, 22); - cputs("How much "); + how_much(); cputs(item[choice]); cputs(" shall"); gotoxy(31, 22); @@ -2796,40 +2804,16 @@ void sell(void) { gotoxy(0, 22); clrtobot(); - cputs("What do you wish me to sell, Taipan? "); + what_do_you_wish_me_to(); + cputs("sell"); + cprint_taipan_prompt(); choice = get_item(0); - /* - for (;;) - { - gotoxy(0, 22); - clrtobot(); - - cputs("What do you wish me to sell, Taipan? "); - - choice = tolower(agetc()); - if(choice == 'o') { - choice = 0; - break; - } else if(choice == 's') { - choice = 1; - break; - } else if(choice == 'a') { - choice = 2; - break; - } else if(choice == 'g') { - choice = 3; - break; - } - } - */ - - for (;;) - { + for (;;) { gotoxy(0, 22); clrtobot(); - cputs("How much "); + how_much(); cputs(item[choice]); cputs(" shall\r\nI sell, Taipan: "); @@ -2883,7 +2867,8 @@ void visit_bank(void) for (;;) { compradores_report(); - cputs("How much will you deposit? "); + how_much_will_you(); + cputs("deposit? "); amount = get_num(); if (amount == UINT32_MAX) @@ -2909,7 +2894,8 @@ void visit_bank(void) for (;;) { compradores_report(); - cputs("How much will you withdraw? "); + how_much_will_you(); + cputs("withdraw? "); amount = get_num(); #ifdef BIGNUM -- cgit v1.2.3