From 3151bcfe0e8ac23a930326999498f7c6f75bf659 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Thu, 15 Apr 2021 13:48:58 -0400 Subject: Save 31 bytes --- console.s | 12 +++++++++++- taipan.c | 49 +++++++++++++++++++------------------------------ 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/console.s b/console.s index 3cee1b5..87514a7 100644 --- a/console.s +++ b/console.s @@ -2,7 +2,7 @@ .include "atari.inc" .include "conio/mul40.s" - .export _clrtobot, _clrtoeol, _clr_screen, _clrtoline, _cspaces, _cblank, _cblankto, _backspace, _cprint_pipe, _cprint_bang, _cspace, _cputc_s, _comma_space, _cprint_colon_space, _cprint_question_space, _cprint_period, _cprint_taipan_prompt, _plus_or_space, _gotox0y22, _gotox0y3, _gotox0y, _gotox0y3_clrtoeol,_cputc0, _set_orders, _pluralize + .export _clrtobot, _clrtoeol, _clr_screen, _clrtoline, _cspaces, _cblank, _cblankto, _backspace, _cprint_pipe, _cprint_bang, _cspace, _cputc_s, _comma_space, _cprint_colon_space, _cprint_question_space, _cprint_period, _cprint_taipan_prompt, _plus_or_space, _gotox0y22, _gotox0y3, _gotox0y, _gotox0y3_clrtoeol,_cputc0, _set_orders, _pluralize, _print_combat_msg .export _rvs_on, _rvs_off .importzp tmp3 ; ditto @@ -12,6 +12,7 @@ .importzp sreg .import _cprintulong, _cputc, _cprint_taipan, _timed_getch, _orders .import _turbo + .import _print_msg .ifdef CART_TARGET .segment "HIGHCODE" @@ -254,6 +255,15 @@ _gotox0y3_clrtoeol: jsr _gotox0y3 jmp _clrtoeol +; extern void print_combat_msg(const char *); +_print_combat_msg: + pha + jsr _gotox0y3 + pla + jsr _print_msg + jmp _clrtoeol + + ; extern void __fastcall__ pluralize(int num); _pluralize: cmp #1 diff --git a/taipan.c b/taipan.c index 28628be..41145a8 100644 --- a/taipan.c +++ b/taipan.c @@ -140,6 +140,9 @@ extern void __fastcall__ gotox0y3(void); /* same as gotoxy(0,3) */ extern void __fastcall__ gotox0y22(void); /* same as gotoxy(0,22) */ extern void __fastcall__ gotox0y3_clrtoeol(void); /* same as gotoxy(0,3); clrtoeol(); */ +/* same as gotoxy(0,3); clrtoeol(); print_msg(x); */ +extern void __fastcall__ print_combat_msg(const char *); + /* each prints one specific character */ extern void crlf(void); extern void cspace(void); @@ -1150,15 +1153,13 @@ char sea_battle(char id, int num_ships) { ok = 3; ik = 1; - gotox0y3_clrtoeol(); // cputs("Aye, we'll fight 'em"); - print_msg(M_aye_fight); + print_combat_msg(M_aye_fight); cprint_taipan_period(); set_orders(); - gotox0y3_clrtoeol(); // cputs("We're firing on 'em"); - print_msg(M_were_firing); + print_combat_msg(M_were_firing); cprint_taipan_bang(); set_orders(); @@ -1220,10 +1221,9 @@ char sea_battle(char id, int num_ships) { tjsleep(10); } } - gotox0y3_clrtoeol(); if(sk > 0) { // cputs("Sunk "); - print_msg(M_sunk); + print_combat_msg(M_sunk); cprintuint(sk); // cputs(" of the buggers"); print_msg(M_of_the_buggers); @@ -1231,7 +1231,7 @@ char sea_battle(char id, int num_ships) { if(!turbo) bad_joss_sound(); } else { // cputs("Hit 'em, but didn't sink 'em"); - print_msg(M_didnt_sink); + print_combat_msg(M_didnt_sink); cprint_taipan_bang(); } set_orders(); @@ -1271,9 +1271,8 @@ char sea_battle(char id, int num_ships) { set_orders(); } } else if ((orders == 1) && (guns == 0)) { - gotox0y3_clrtoeol(); // cputs("We have no guns"); - print_msg(M_we_have_no_guns); + print_combat_msg(M_we_have_no_guns); cprint_taipan_bangbang(); turbo = 0; set_orders(); @@ -1283,9 +1282,8 @@ char sea_battle(char id, int num_ships) { total = 0; turbo = 0; - gotox0y3(); // cputs("You have the following on board"); - print_msg(M_you_have_on_board); + print_combat_msg(M_you_have_on_board); cprint_colon_space(); gotoxy(4, 4); // cputs(item[0]); @@ -1343,9 +1341,8 @@ char sea_battle(char id, int num_ships) { cblank(120); if(total > 0) { - gotox0y3_clrtoeol(); // cputs("Let's hope we lose 'em"); - print_msg(M_hope_we_lose_em); + print_combat_msg(M_hope_we_lose_em); cprint_taipan_bang(); bad_joss_sound(); if (choice < 4) { @@ -1363,9 +1360,8 @@ char sea_battle(char id, int num_ships) { set_orders(); } else { - gotox0y3_clrtoeol(); // cputs("There's nothing there"); - print_msg(M_nothing_there); + print_combat_msg(M_nothing_there); cprint_taipan_bang(); good_joss_sound(); @@ -1375,18 +1371,16 @@ char sea_battle(char id, int num_ships) { if((orders == 2) || (orders == 3)) { if(orders == 2) { - gotox0y3_clrtoeol(); // cputs("Aye, we'll run"); - print_msg(M_aye_run); + print_combat_msg(M_aye_run); cprint_taipan_period(); set_orders(); } ok += ik++; - gotox0y3_clrtoeol(); if(randi()%ok > randi()%num_ships) { // cputs("We got away from 'em"); - print_msg(M_we_got_away); + print_combat_msg(M_we_got_away); cprint_taipan_bang(); good_joss_sound(); /* don't use set_orders() here! it allows changing from Run @@ -1396,7 +1390,7 @@ char sea_battle(char id, int num_ships) { num_ships = 0; } else { // cputs("Couldn't lose 'em."); - print_msg(M_couldnt_lose_em); + print_combat_msg(M_couldnt_lose_em); set_orders(); if((num_ships > 2) && (one_chance_in(5))) { @@ -1405,9 +1399,8 @@ char sea_battle(char id, int num_ships) { num_ships -= lost; fight_stats(num_ships, orders); - gotox0y3_clrtoeol(); // cputs("But we escaped from "); - print_msg(M_but_we_escaped); + print_combat_msg(M_but_we_escaped); cprintuint(lost); // cputs(" of 'em!"); print_msg(M_of_em); @@ -1433,9 +1426,8 @@ char sea_battle(char id, int num_ships) { } if(num_ships > 0) { - gotox0y3_clrtoeol(); // cputs("They're firing on us"); - print_msg(M_theyre_firing); + print_combat_msg(M_theyre_firing); cprint_taipan_bang(); set_orders(); @@ -1444,9 +1436,8 @@ char sea_battle(char id, int num_ships) { fight_stats(num_ships, orders); plus_or_space(num_ships > num_on_screen); - gotox0y3_clrtoeol(); // cputs("We've been hit"); - print_msg(M_weve_been_hit); + print_combat_msg(M_weve_been_hit); cprint_taipan_bangbang(); under_attack_sound(); @@ -1465,9 +1456,8 @@ char sea_battle(char id, int num_ships) { guns--; hold += 10; fight_stats(num_ships, orders); - gotox0y3_clrtoeol(); // cputs("The buggers hit a gun"); - print_msg(M_buggers_hit_gun); + print_combat_msg(M_buggers_hit_gun); cprint_taipan_bangbang(); if(!turbo) under_attack_sound(); fight_stats(num_ships, orders); @@ -1529,9 +1519,8 @@ char sea_battle(char id, int num_ships) { if(orders == 1) { fight_stats(num_ships, orders); - gotox0y3_clrtoeol(); // cputs("We got 'em all"); - print_msg(M_we_got_em_all); + print_combat_msg(M_we_got_em_all); cprint_taipan_bang(); bad_joss_timed_getch(); -- cgit v1.2.3