From 41bbac55209e4cf6481937a2ffdfc39997b5572a Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Thu, 20 May 2021 15:45:09 -0400 Subject: Save 120 bytes in final_stats(), now 8967 --- taipan.c | 115 ++++++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 65 insertions(+), 50 deletions(-) (limited to 'taipan.c') diff --git a/taipan.c b/taipan.c index a6f6e5f..2c9dbb8 100644 --- a/taipan.c +++ b/taipan.c @@ -49,6 +49,9 @@ /* define this to test lorcha drawing/damage */ // #define LORCHA_TEST +/* define this to test final_stats() */ +// #define FINAL_STATS_TEST + /**** atari-specific stuff */ /* values returned by cgetc() for backspace/enter/delete keys */ @@ -1961,6 +1964,30 @@ void retire(void) { // This didn't work out (revisit someday?) // extern void __fastcall__ print_score_msg(long *scoreptr); +long score_lim[] = { + 50000L, + 8000L, + 1000L, + 500L, + ((long) 0x80000000) +}; + +const char const *score_msg[] = { + M_ma_tsu, + M_master_taipan, + M_taipan, + M_compradore, + M_galley_hand +}; + +const char const *score_desc[] = { + "50,000 and over |\n|", + " 8,000 to 49,999|\n|", + " 1,000 to 7,999|\n|", + " 500 to 999|\n|", + " less than 500|\n" +}; + void final_stats(void) { int years = year - 1860; @@ -2066,56 +2093,19 @@ void final_stats(void) { crlf(); cprint_pipe(); - if (score > 49999L) - { - rvs_on(); - } - // cputs("Ma Tsu"); - print_msg(M_ma_tsu); - rvs_off(); - cspaces(9); - cputs("50,000 and over |\n|"); - - if ((score < 50000L) && (score > 7999L)) - { - rvs_on(); - } - // cputs("Master Taipan"); - print_msg(M_master_taipan); - rvs_off(); - cputs(" 8,000 to 49,999|\n|"); - // cprint_pipe(); - - if ((score < 8000L) && (score > 999L)) - { - rvs_on(); - } - cprint_taipan(); - rvs_off(); - cspaces(10); - cputs("1,000 to 7,999|\n|"); - // cprint_pipe(); - - if ((score < 1000) && (score > 499)) - { - rvs_on(); - } - // cputs("Compradore"); - print_msg(M_compradore); - rvs_off(); - cspaces(8); - cputs("500 to 999|\n|"); - // cprint_pipe(); - - if (score < 500) - { - rvs_on(); - } - // cputs("Galley Hand"); - print_msg(M_galley_hand); - rvs_off(); - cspaces(7); - cputs("less than 500|\n"); + { + char i, unrated = 1; + for(i = 0; i < 5; i++) { + if(unrated && score >= score_lim[i]) { + unrated = 0; + rvs_on(); + } + print_msg(score_msg[i]); + rvs_off(); + gotox(16); + cputs(score_desc[i]); + } + } cputc(26); // lower left corner chline(31); @@ -2125,6 +2115,12 @@ void final_stats(void) { // cputs("Play again? "); print_msg(M_play_again); +#ifdef FINAL_STATS_TEST + agetc(); + clrscr(); + return; +#endif + if(yngetc('y') == 'y') { init_game(); return; @@ -3341,6 +3337,21 @@ hangx: goto hangx; } #endif +#ifdef FINAL_STATS_TEST +void final_stats_test(void) { + cputs("cash? "); + cash = get_num(); + crlf(); + cputs("debt? "); + debt = get_num(); + crlf(); + cputs("year? "); + year = get_num(); + month = 1; + final_stats(); +} +#endif + /* N.B. cc65 is perfectly OK with main(void), and it avoids warnings about argv/argc unused. */ int main(void) { @@ -3356,6 +3367,10 @@ int main(void) { POKE(731, 1); // disable keyclick on XL/XE (does nothing on 400/800) POKE(559, 34); // turn on the screen (normal playfield) +#ifdef FINAL_STATS_TEST + while(1) final_stats_test(); +#endif + #ifdef LORCHA_TEST while(1) { gotox0y(0); -- cgit v1.2.3