aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2021-04-20 13:46:30 -0400
committerB. Watson <yalhcru@gmail.com>2021-04-20 13:46:30 -0400
commit1faab1ce210840391abe150c71cd44c228585af8 (patch)
tree3306e314468f91c6d20469ccdd7d807206fed948
parenteedb858a9f384ccccd5b1c0860f55d2ef788966d (diff)
downloadtaipan-1faab1ce210840391abe150c71cd44c228585af8.tar.gz
Save 8 bytes
-rw-r--r--console.s56
-rw-r--r--taipan.c32
2 files changed, 65 insertions, 23 deletions
diff --git a/console.s b/console.s
index 99b264e..554b03d 100644
--- a/console.s
+++ b/console.s
@@ -12,6 +12,7 @@
.export _cputc0, _set_orders, _pluralize, _print_combat_msg
.export _rvs_on, _rvs_off
.export _prepare_report, _clear_msg_window
+ .export _print_status_desc, _print_month
.importzp tmp3 ; ditto
.import _revflag ; conio/revers.s
@@ -21,6 +22,8 @@
.import _cprintulong, _cputc, _cprint_taipan, _timed_getch, _orders
.import _turbo
.import _print_msg, _cspaces
+ .import _st, _month, _cputs
+ .import _cprintuint
.ifdef CART_TARGET
.segment "HIGHCODE"
@@ -281,6 +284,43 @@ _pluralize:
bne _cputc_s
rts
+; extern void __fastcall__ _print_status_desc(char status);
+; replaces this C code:
+; cputs(st[status / 20]);
+; status ranges 0 to 100 (it's the seaworthiness percentage),
+; the st[] array has elements 0 to 5. 5 is "Perfect" and only
+; used when status == 100.
+_print_status_desc:
+ lsr
+ lsr ; now 0-25
+ ldx #$ff
+ sec
+@div5loop:
+ inx
+ sbc #5
+ bcs @div5loop
+ txa
+ asl
+ tay
+ lda _st,y
+ ldx _st+1,y
+ jmp _cputs
+
+; extern void __fastcall__ print_month(void);
+; _month is a global, ranges 1 to 12.
+
+_print_month:
+ lda _month
+ asl
+ asl ; carry will be left clear
+ adc #<(months-4)
+ pha
+ lda #>(months-4)
+ adc #0
+ tax
+ pla
+ jmp _cputs
+
; extern void set_orders(void);
_set_orders:
lda _turbo ; in turbo fight mode?
@@ -314,3 +354,19 @@ _set_orders:
.rodata
orders_tbl: .byte "frt"
+
+; inverse "Jan\0Feb\0Mar\0Apr\0May\0Jun\0Jul\0Aug\0Sep\0Oct\0Nov\0Dec\0"
+months:
+ .byte $ca, $e1, $ee, $00
+ .byte $c6, $e5, $e2, $00
+ .byte $cd, $e1, $f2, $00
+ .byte $c1, $f0, $f2, $00
+ .byte $cd, $e1, $f9, $00
+ .byte $ca, $f5, $ee, $00
+ .byte $ca, $f5, $ec, $00
+ .byte $c1, $f5, $e7, $00
+ .byte $d3, $e5, $f0, $00
+ .byte $cf, $e3, $f4, $00
+ .byte $ce, $ef, $f6, $00
+ .byte $c4, $e5, $e3, $00
+
diff --git a/taipan.c b/taipan.c
index 193822b..e795493 100644
--- a/taipan.c
+++ b/taipan.c
@@ -372,7 +372,7 @@ char *num_buf = (char *) 0x600;
// char *item[] = { "Opium", "Silk", "Arms", "General Cargo" };
const char * const item[] = { M_opium, M_silk, M_arms, M_gen_cargo };
-extern void __fastcall__ print_item(char item);
+extern void __fastcall__ print_item(char item); // textdecomp.s
/*
const char *location[] = { "At sea", "Hong Kong", "Shanghai", "Nagasaki",
@@ -383,21 +383,9 @@ const char * const location[] = { M_at_sea, M_hong_kong, M_shanghai,
M_nagasaki, M_saigon, M_manila,
M_singapore, M_batavia };
-extern void __fastcall__ print_location(char loc);
-
-// inverse "Jan\0Feb\0Mar\0Apr\0May\0Jun\0Jul\0Aug\0Sep\0Oct\0Nov\0Dec\0";
-const char * const 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";
+extern void __fastcall__ print_location(char loc); // textdecomp.s
+
+extern void __fastcall__ print_month(void); // console.s
const char * const st[] = {
"\xc3\xf2\xe9\xf4\xe9\xe3\xe1\xec", // inverse "Critical"
@@ -408,10 +396,7 @@ const char * const st[] = {
"Perfect"
};
-/*
-char *st[] = { "Critical", " Poor", " Fair",
- " Good", " Prime", "Perfect" };
- */
+extern void __fastcall__ print_status_desc(char s); // console.s
#ifdef BIGNUM
bignum(bank) = BIG_0;
@@ -1099,7 +1084,7 @@ char sea_battle(char id, int num_ships) {
// cputs("Current seaworthiness: ");
print_msg(M_cur_seaworth);
- cputs(st[status / 20]);
+ print_status_desc(status);
cputs(" (");
cprintuchar(status);
cputs("%)");
@@ -1730,7 +1715,8 @@ void port_stats(void) {
}
gotoxy(32, 3);
- cputs(months + 4 * (month - 1));
+ // cputs(months + 4 * (month - 1));
+ print_month();
cspace();
cprintuint(year);
@@ -1748,7 +1734,7 @@ void port_stats(void) {
gotoxy(29, 12);
clrtoeol();
- cputs(st[status / 20]);
+ print_status_desc(status);
cputc(':');
cprintuint(status);