aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--messages.pl18
-rw-r--r--taipan.c83
-rw-r--r--textcomp.c25
3 files changed, 98 insertions, 28 deletions
diff --git a/messages.pl b/messages.pl
index 0fd871f..2d39b6d 100644
--- a/messages.pl
+++ b/messages.pl
@@ -48,6 +48,19 @@ print "// ratio: " . sprintf("%.1f", $total_out * 100 / $total_in) .
=cut
__END__
+opium "Opium"
+silk "Silk"
+arms "Arms"
+gen_cargo "General Cargo"
+ellipsis "..."
+at_sea "At sea"
+hong_kong "Hong Kong"
+shanghai "Shanghai"
+nagasaki "Nagasaki"
+saigon "Saigon"
+manila "Manila"
+singapore "Singapore"
+batavia "Batavia"
how_much_spc "How much "
will_you "will you "
bad_joss "Bad Joss!!\r\n"
@@ -147,6 +160,9 @@ given_the_diff "has given Li Yuen the\r\ndifference between what he wanted and\r
very_well "Very well. "
will_not_pay "will not pay\r\nLi Yuen the difference. I would be very\r\nwary of pirates if I were you."
you_only_have "you only have "
+nl_in_spc "\nin "
+the_bank "the bank"
+cash "cash"
do_you_have_biz_with_wu "Do you have business with Elder Brother\r\nWu, the moneylender? "
aware_of_your_plight "Elder Brother is aware of your plight,\r\nTaipan. He is willing to loan you an\r\nadditional "
if_you_will_pay_back " if you will pay back\r\n"
@@ -158,9 +174,11 @@ to_borrow "to \r\nborrow? "
wont_loan "\r\n\nHe won't loan you so much"
bodyguards_killed " of your bodyguards have been killed\r\nby cutthroats and you have been robbed\r\nof all of your cash"
the_price_of "!! The price of "
+nl_has_spc "\n has "
risen "risen"
dropped "dropped"
spc_to_spc " to "
+bang_bang_nl "!!\n"
prices_here_are "present prices per unit here are"
general_shortname "General"
shall_i_buy_sell "Shall I Buy, Sell, "
diff --git a/taipan.c b/taipan.c
index 03ba095..1600fb3 100644
--- a/taipan.c
+++ b/taipan.c
@@ -304,13 +304,20 @@ char *firm = (char *) 0x680;
char *num_buf = (char *) 0x600;
#endif
-char *item[] = { "Opium", "Silk", "Arms", "General Cargo" };
+// char *item[] = { "Opium", "Silk", "Arms", "General Cargo" };
+const char * const item[] = { M_opium, M_silk, M_arms, M_gen_cargo };
-char *location[] = { "At sea", "Hong Kong", "Shanghai", "Nagasaki",
+/*
+const char *location[] = { "At sea", "Hong Kong", "Shanghai", "Nagasaki",
"Saigon", "Manila", "Singapore", "Batavia" };
+ */
+
+const char * const location[] = { M_at_sea, M_hong_kong, M_shanghai,
+ M_nagasaki, M_saigon, M_manila,
+ M_singapore, M_batavia };
// inverse "Jan\0Feb\0Mar\0Apr\0May\0Jun\0Jul\0Aug\0Sep\0Oct\0Nov\0Dec\0";
-char *months = "\xca\xe1\xee\0"
+const char * const months = "\xca\xe1\xee\0"
"\xc6\xe5\xe2\0"
"\xcd\xe1\xf2\0"
"\xc1\xf0\xf2\0"
@@ -323,7 +330,7 @@ char *months = "\xca\xe1\xee\0"
"\xce\xef\xf6\0"
"\xc4\xe5\xe3\0";
-char *st[] = {
+const char * const st[] = {
"\xc3\xf2\xe9\xf4\xe9\xe3\xe1\xec", // inverse "Critical"
"\xa0\xa0\xd0\xef\xef\xf2", // inverse " Poor"
" Fair",
@@ -353,7 +360,7 @@ unsigned long cash = 0,
unsigned long price[4];
-int base_price[4][8] = { {1000, 11, 16, 15, 14, 12, 10, 13},
+const int base_price[4][8] = { {1000, 11, 16, 15, 14, 12, 10, 13},
{100, 11, 14, 15, 16, 10, 13, 12},
{10, 12, 16, 10, 11, 13, 14, 15},
{1, 10, 11, 12, 13, 14, 15, 16} };
@@ -602,7 +609,8 @@ void at_sea(void) {
gotoxy(30, 6);
cspace();
rvs_on();
- cputs(location[0]);
+ // cputs(location[0]);
+ print_msg(location[0]);
rvs_off();
cspaces(3);
@@ -1139,19 +1147,23 @@ char sea_battle(char id, int num_ships) {
print_msg(M_you_have_on_board);
cprint_taipan_colon();
gotoxy(4, 4);
- cputs(item[0]);
+ // cputs(item[0]);
+ print_msg(item[0]);
cputs(": ");
cprintulong(hold_[0]);
gotoxy(24, 4);
- cputs(item[1]);
+ // cputs(item[1]);
+ print_msg(item[1]);
cputs(": ");
cprintulong(hold_[1]);
gotoxy(5, 5);
- cputs(item[2]);
+ // cputs(item[2]);
+ print_msg(item[2]);
cputs(": ");
cprintulong(hold_[2]);
gotoxy(21, 5);
- cputs(item[3]);
+ // cputs(item[3]);
+ print_msg(item[3]);
cputs(": ");
cprintulong(hold_[3]);
@@ -1575,7 +1587,8 @@ void port_stats(void)
cprint_firm_colon();
cputs(firm);
comma_space();
- cputs(location[1]);
+ // cputs(location[1]);
+ print_msg(location[1]);
gotoxy(21, 4);
in_use = warehouse_in_use();
@@ -1657,7 +1670,8 @@ void port_stats(void)
cblank(10);
rvs_on();
if(port == 4 || port == 5) cspace();
- cputs(location[port]);
+ // cputs(location[port]);
+ print_msg(location[port]);
rvs_off();
gotoxy(28, 9);
@@ -2071,7 +2085,8 @@ void transfer(void)
{
compradores_report();
how_much();
- cputs(item[i]);
+ // cputs(item[i]);
+ print_msg(item[i]);
// cputs(" shall I move\r\nto the warehouse");
print_msg(M_move_to_whouse);
cprint_taipan_prompt();
@@ -2129,7 +2144,8 @@ void transfer(void)
{
compradores_report();
how_much();
- cputs(item[i]);
+ // cputs(item[i]);
+ print_msg(item[i]);
// cputs(" shall I move\r\naboard ship");
print_msg(M_move_aboard);
cprint_taipan_prompt();
@@ -2183,7 +2199,8 @@ void quit(void)
if(choice == 7) crlf();
cputc(choice + '0');
cputs(") ");
- cputs(location[choice]);
+ // cputs(location[choice]);
+ print_msg(location[choice]);
if(choice != 7) comma_space();
}
cprint_question_space();
@@ -2393,7 +2410,8 @@ void quit(void)
clear_msg_window();
// cputs("We've been blown off course\r\nto ");
print_msg(M_blown_off_course);
- cputs(location[port]);
+ // cputs(location[port]);
+ print_msg(location[port]);
timed_getch();
}
}
@@ -2457,8 +2475,10 @@ void quit(void)
clear_msg_window();
// cputs("Arriving at ");
print_msg(M_arriving_at);
- cputs(location[port]);
- cputs("...");
+ // cputs(location[port]);
+ print_msg(location[port]);
+ // cputs("...");
+ print_msg(M_ellipsis);
timed_getch();
return;
@@ -2559,8 +2579,10 @@ void you_only_have(unsigned char in_bank) {
cprintfancy_big(bank);
else
cprintfancy(cash);
- cputs("\r\nin ");
- cputs(in_bank ? "the bank" : "cash");
+ // cputs("\r\nin ");
+ print_msg(M_nl_in_spc);
+ // cputs(in_bank ? "the bank" : "cash");
+ print_msg(in_bank ? M_the_bank : M_cash);
cputs(".\r\n");
good_joss_sound();
@@ -2764,8 +2786,10 @@ void good_prices(void) {
cprint_taipan();
// cputs("!! The price of ");
print_msg(M_the_price_of);
- cputs(item[i]);
- cputs("\r\n has ");
+ // cputs(item[i]);
+ print_msg(item[i]);
+ // cputs("\r\n has ");
+ print_msg(M_nl_has_spc);
if(randi()&1) {
price[i] *= (randi()%5 + 5);
@@ -2782,7 +2806,8 @@ void good_prices(void) {
print_msg(M_spc_to_spc);
cprintulong(price[i]);
- cputs("!!\r\n");
+ // cputs("!!\r\n");
+ print_msg(M_bang_bang_nl);
good_joss_sound();
timed_getch();
@@ -2803,9 +2828,11 @@ int port_choices(void) {
for(choice = 0; choice < 4; ++choice) {
gotox(3 + ((choice & 1) * 16));
if(choice == 3)
- cputs("General");
+ // cputs("General");
+ print_msg(M_general_shortname);
else
- cputs(item[choice]);
+ // cputs(item[choice]);
+ print_msg(item[choice]);
cputc(':');
gotox(11 + ((choice & 1) * 18));
cprintulong(price[choice]);
@@ -3020,7 +3047,8 @@ void buy(void) {
rvs_off();
gotoxy(0, 22);
how_much();
- cputs(item[choice]);
+ // cputs(item[choice]);
+ print_msg(item[choice]);
// cputs(" shall");
print_msg(M_spc_shall);
gotoxy(31, 22);
@@ -3072,7 +3100,8 @@ void sell(void) {
clrtobot();
how_much();
- cputs(item[choice]);
+ // cputs(item[choice]);
+ print_msg(item[choice]);
// cputs(" shall\r\nI sell, ");
print_msg(M_shall_i_sell);
cprint_taipan_colon();
diff --git a/textcomp.c b/textcomp.c
index 1ff769f..bb0b4c0 100644
--- a/textcomp.c
+++ b/textcomp.c
@@ -4,7 +4,28 @@
Example: "Taipan" (7 bytes, including null terminator) encodes as
0xb8 0x12 0x50 0x04 0xe0 0x00 (6 bytes).
- Longer strings approach 75% compression ratio.
+ Longer strings approach 75% compression ratio. Sadly, the result
+ has to be padded to an 8-bit byte boundary, or else we'd get 75%
+ for every string.
+
+ Input length | Encoded length | Ratio
+ (incl. null) | |
+ 2 | 2 | 100%, don't bother
+ 3 | 3 | 100%, don't bother
+ 4 | 3 | 75%
+ 5 | 4 | 80%
+ 6 | 5 | 83%
+ 7 | 6 | 86%
+ 8 | 6 | 75%
+ 9 | 7 | 78%
+ 10 | 8 | 80%
+ 11 | 9 | 82%
+ 12 | 9 | 75%
+ 13 | 10 | 77%
+ 14 | 11 | 79%
+ 15 | 12 | 80%
+ 16 | 12 | 75%
+ ...etc etc
No encoded string can be over 256 bytes long, as the decompressor
can't currently handle it.
@@ -38,6 +59,8 @@
print an encoded message. The decoding step slows down printing a bit,
but it's not really noticeable. cputc() is used for printing, so it
respects the reverse video setting (set by rvs_on() and rvs_off()).
+ The task of replacing cputs("some string") with print_msg(M_some_string)
+ is done manually.
When a newline is printed, the decoder always prints a carriage
return first. Any \r sequences listed in messages.pl are discarded