diff options
Diffstat (limited to 'taipan.c')
-rw-r--r-- | taipan.c | 122 |
1 files changed, 68 insertions, 54 deletions
@@ -117,6 +117,10 @@ extern void clrtoeol(void); /* print 'count' spaces: */ extern void __fastcall__ cspaces(unsigned char count); +/* same as gotoxy(0, y). replacing all the gotoxy(0, foo) with + this saves 208 bytes! */ +extern void __fastcall__ gotox0y(char y); + /* each prints one specific character */ extern void crlf(void); extern void cspace(void); @@ -124,6 +128,7 @@ extern void cputc_s(void); extern void cprint_bang(void); extern void cprint_pipe(void); extern void cprint_period(void); +extern void cputc0(void); /* each print 2 characters */ extern void comma_space(void); @@ -647,7 +652,7 @@ void cprintfancy_big(bignump b) { if(rightdigits) { // cputc('.'); cprint_period(); - if(leading0) cputc('0'); + if(leading0) cputc0(); // cprintulong((unsigned long)rightdigits); cprintuchar(rightdigits); } @@ -678,20 +683,20 @@ void cprintulong(unsigned long ul) { void at_sea(void) { gotoxy(30, 6); - cspace(); + // cspace(); rvs_on(); // cputs(location[0]); print_msg(M_at_sea); rvs_off(); - cspaces(3); + cspaces(2); } /* this bit of code was duplicated a *bunch* of times, making it a function makes the binary 2K smaller. */ void prepare_report(void) { - gotoxy(0, 16); + gotox0y(16); clrtobot(); } @@ -708,7 +713,7 @@ void captains_report(void) { } void clear_msg_window(void) { - gotoxy(0, 18); + gotox0y(18); clrtobot(); } @@ -724,11 +729,11 @@ void overload(void) { unsigned int gunamt(void) { return randi()%(1000 * (get_time() + 5) / 6); } + #ifdef CART_TARGET # pragma code-name (pop) #endif - void new_ship(void) { unsigned long amount; @@ -890,7 +895,7 @@ void cprintfancy(unsigned long num) { if(tmp) { // cputc('.'); cprint_period(); - if(tmp < 10L) cputc('0'); + if(tmp < 10L) cputc0(); cprintulong(tmp); } } else { @@ -919,6 +924,7 @@ void justify_int(unsigned int num) { if(num < 10) cspace(); cprintuint(num); } + void update_guns() { rvs_on(); gotoxy(31, 1); @@ -928,7 +934,7 @@ void update_guns() { } void fight_stats(int ships, int orders) { - gotoxy(0, 0); + gotox0y(0); justify_int(ships); // cputs(" ship"); @@ -959,13 +965,18 @@ void fight_stats(int ships, int orders) { /* print an inverse video plus if there are offscreen ships, or clear it to a space if not. */ +extern void plus_or_space(unsigned char b); +/* void plus_or_space(unsigned char b) { gotoxy(39, 15); cputc(b ? 0xab : ' '); // hide_cursor(); } +*/ char orders = 0; +extern void set_orders(void); +/* void set_orders(void) { switch(timed_getch()) { case 'f': orders = 1; break; @@ -974,6 +985,7 @@ void set_orders(void) { default: break; } } +*/ #ifdef CART_TARGET # pragma code-name (pop) @@ -1042,7 +1054,7 @@ char sea_battle(char id, int num_ships) { */ // flushinp(); - gotoxy(0, 3); + gotox0y(3); clrtoeol(); // cputs("Current seaworthiness: "); @@ -1051,7 +1063,7 @@ char sea_battle(char id, int num_ships) { cputs(" ("); cprintuchar(status); cputs("%)"); - gotoxy(0, 4); + gotox0y(4); for(i = 0; i <= 9; i++) { if (num_ships > num_on_screen) { @@ -1066,7 +1078,7 @@ char sea_battle(char id, int num_ships) { plus_or_space(num_ships > num_on_screen); - gotoxy(0, 16); + gotox0y(16); // cputs("\n"); crlf(); @@ -1075,7 +1087,7 @@ char sea_battle(char id, int num_ships) { if(orders == 0) { set_orders(); if(!orders) { - gotoxy(0, 3); + gotox0y(3); clrtoeol(); cprint_taipan_comma(); // cputs("what shall we do??\n(Fight, Run, Throw cargo)"); @@ -1084,9 +1096,9 @@ char sea_battle(char id, int num_ships) { while(!orders) set_orders(); - gotoxy(0, 3); + gotox0y(3); clrtoeol(); - gotoxy(0, 4); + gotox0y(4); clrtoeol(); } } @@ -1098,14 +1110,14 @@ char sea_battle(char id, int num_ships) { ok = 3; ik = 1; - gotoxy(0, 3); + gotox0y(3); clrtoeol(); // cputs("Aye, we'll fight 'em"); print_msg(M_aye_fight); cprint_taipan_period(); set_orders(); - gotoxy(0, 3); + gotox0y(3); clrtoeol(); // cputs("We're firing on 'em"); print_msg(M_were_firing); @@ -1134,7 +1146,7 @@ char sea_battle(char id, int num_ships) { plus_or_space(num_ships > num_on_screen); - gotoxy(0, 16); + gotox0y(16); crlf(); do { @@ -1172,7 +1184,7 @@ char sea_battle(char id, int num_ships) { jsleep(10); } } - gotoxy(0, 3); + gotox0y(3); clrtoeol(); if(sk > 0) { // cputs("Sunk "); @@ -1197,7 +1209,7 @@ char sea_battle(char id, int num_ships) { num_ships -= ran; fight_stats(num_ships, orders); - gotoxy(0, 3); + gotox0y(3); clrtoeol(); cprintuint(ran); // cputs(" ran away"); @@ -1220,12 +1232,12 @@ char sea_battle(char id, int num_ships) { } } - gotoxy(0, 16); + gotox0y(16); set_orders(); } } else if ((orders == 1) && (guns == 0)) { - gotoxy(0, 3); + gotox0y(3); clrtoeol(); // cputs("We have no guns"); print_msg(M_we_have_no_guns); @@ -1236,7 +1248,7 @@ char sea_battle(char id, int num_ships) { amount = 0; total = 0; - gotoxy(0, 3); + gotox0y(3); // cputs("You have the following on board"); print_msg(M_you_have_on_board); cprint_taipan_colon(); @@ -1265,7 +1277,7 @@ char sea_battle(char id, int num_ships) { cprint_colon_space(); cprintulong(hold_[3]); - gotoxy(0, 6); + gotox0y(6); clrtoeol(); // cputs("What shall I throw overboard"); print_msg(M_what_shall_i_throw); @@ -1274,7 +1286,7 @@ char sea_battle(char id, int num_ships) { choice = get_item(1); if(choice < 4) { - gotoxy(0, 6); + gotox0y(6); clrtoeol(); // cputs("How much"); print_msg(M_how_much); @@ -1290,15 +1302,15 @@ char sea_battle(char id, int num_ships) { total = hold_[0] + hold_[1] + hold_[2] + hold_[3]; } - gotoxy(0, 4); + gotox0y(4); clrtoeol(); - gotoxy(0, 5); + gotox0y(5); clrtoeol(); - gotoxy(0, 6); + gotox0y(6); clrtoeol(); if(total > 0) { - gotoxy(0, 3); + gotox0y(3); clrtoeol(); // cputs("Let's hope we lose 'em"); print_msg(M_hope_we_lose_em); @@ -1319,7 +1331,7 @@ char sea_battle(char id, int num_ships) { set_orders(); } else { - gotoxy(0, 3); + gotox0y(3); clrtoeol(); // cputs("There's nothing there"); print_msg(M_nothing_there); @@ -1332,7 +1344,7 @@ char sea_battle(char id, int num_ships) { if((orders == 2) || (orders == 3)) { if(orders == 2) { - gotoxy(0, 3); + gotox0y(3); clrtoeol(); // cputs("Aye, we'll run"); print_msg(M_aye_run); @@ -1342,7 +1354,7 @@ char sea_battle(char id, int num_ships) { ok += ik++; if(randi()%ok > randi()%num_ships) { - gotoxy(0, 3); + gotox0y(3); clrtoeol(); // cputs("We got away from 'em"); print_msg(M_we_got_away); @@ -1351,7 +1363,7 @@ char sea_battle(char id, int num_ships) { set_orders(); num_ships = 0; } else { - gotoxy(0, 3); + gotox0y(3); clrtoeol(); // cputs("Couldn't lose 'em."); print_msg(M_couldnt_lose_em); @@ -1363,7 +1375,7 @@ char sea_battle(char id, int num_ships) { num_ships -= lost; fight_stats(num_ships, orders); - gotoxy(0, 3); + gotox0y(3); clrtoeol(); // cputs("But we escaped from "); print_msg(M_but_we_escaped); @@ -1384,7 +1396,7 @@ char sea_battle(char id, int num_ships) { plus_or_space(num_ships > num_on_screen); } - gotoxy(0, 16); + gotox0y(16); set_orders(); } @@ -1392,7 +1404,7 @@ char sea_battle(char id, int num_ships) { } if(num_ships > 0) { - gotoxy(0, 3); + gotox0y(3); clrtoeol(); // cputs("They're firing on us"); print_msg(M_theyre_firing); @@ -1404,7 +1416,7 @@ char sea_battle(char id, int num_ships) { fight_stats(num_ships, orders); plus_or_space(num_ships > num_on_screen); - gotoxy(0, 3); + gotox0y(3); clrtoeol(); // cputs("We've been hit"); print_msg(M_weve_been_hit); @@ -1426,7 +1438,7 @@ char sea_battle(char id, int num_ships) { guns--; hold += 10; fight_stats(num_ships, orders); - gotoxy(0, 3); + gotox0y(3); clrtoeol(); // cputs("The buggers hit a gun"); print_msg(M_buggers_hit_gun); @@ -1469,7 +1481,7 @@ char sea_battle(char id, int num_ships) { if(damage == capacity) return 4; #ifdef DAMAGE_TEST - gotoxy(0, 23); + gotox0y(23); clrtoeol(); cprintulong(ed); cspace(); @@ -1491,7 +1503,7 @@ char sea_battle(char id, int num_ships) { if(orders == 1) { fight_stats(num_ships, orders); - gotoxy(0, 3); + gotox0y(3); clrtoeol(); // cputs("We got 'em all"); print_msg(M_we_got_em_all); @@ -2085,7 +2097,7 @@ void final_stats(void) chline(31); cputc(3); // lower right corner - gotoxy(0, 22); + gotox0y(22); // cputs("Play again? "); print_msg(M_play_again); choice = yngetc(0); @@ -2166,7 +2178,7 @@ void transfer(void) { unsigned long amount = 0; if(have_no_cargo()) { - gotoxy(0, 22); + gotox0y(22); clrtobot(); // cputs("You have no cargo"); print_msg(M_you_have_no_cargo); @@ -2200,13 +2212,13 @@ void transfer(void) { hold += amount; break; } else if(in_use == 10000) { - gotoxy(0, 21); + gotox0y(21); // cputs("Your warehouse is full"); print_msg(M_whouse_full); cprint_taipan_bang(); good_joss_timed_getch(); } else { - gotoxy(0, 21); + gotox0y(21); // cputs("Your warehouse will only hold an\nadditional "); print_msg(M_whouse_only_hold); cprintuint(10000 - in_use); @@ -2215,7 +2227,7 @@ void transfer(void) { } } else { clear_msg_window(); - // gotoxy(0, 18); + // gotox0y(18); // clrtobot(); you_have_only(); cprintulong(hold_[i]); @@ -2248,7 +2260,7 @@ void transfer(void) { break; } else { clear_msg_window(); - // gotoxy(0, 18); + // gotox0y(18); // clrtobot(); you_have_only(); cprintuint(hkw_[i]); @@ -2338,7 +2350,7 @@ void quit(void) under_attack_timed_getch(); result = sea_battle(GENERIC, num_ships); - gotoxy(0,23); /* to avoid disappearing U in "In use" */ + // gotoxy(0,23); /* to avoid disappearing U in "In use" */ } if(result == 2) { @@ -2651,7 +2663,7 @@ void you_only_have(unsigned char in_bank) { #else void you_only_have(unsigned char in_bank) { clear_msg_window(); - // gotoxy(0, 18); + // gotox0y(18); // clrtobot(); cprint_taipan_comma(); @@ -2903,7 +2915,7 @@ int port_choices(void) { cprintulong(price[3]); */ - gotoxy(0, 22); + gotox0y(22); clrtobot(); #ifdef BIGNUM @@ -3072,11 +3084,13 @@ void name_firm(void) { # pragma code-name (push, "HIGHCODE") #endif char what_do_you_wish_me_to(char buy_or_sell) { - gotoxy(0, 22); + gotox0y(22); clrtobot(); - cputs("What "); + // cputs("What "); + print_msg(M_what); do_you_wish(); - cputs("me to "); + // cputs("me to "); + print_msg(M_me_to); cputs(buy_or_sell ? "buy" : "sell"); cprint_taipan_prompt(); return get_item(0); @@ -3100,7 +3114,7 @@ void buy(void) { // cputs(" You can "); print_msg(M_spc_you_can_spc); rvs_off(); - gotoxy(0, 22); + gotox0y(22); how_much(); // cputs(item[choice]); print_msg(item[choice]); @@ -3123,7 +3137,7 @@ void buy(void) { cprintulong(afford); rvs_off(); - gotoxy(0, 23); + gotox0y(23); // cputs("I buy, "); print_msg(M_i_buy); cprint_taipan_colon(); @@ -3151,7 +3165,7 @@ void sell(void) { choice = what_do_you_wish_me_to(0); for (;;) { - gotoxy(0, 22); + gotox0y(22); clrtobot(); how_much(); |