aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--README.txt6
-rw-r--r--bignum.h3
-rw-r--r--size.pl8
-rw-r--r--taipan.c184
5 files changed, 119 insertions, 83 deletions
diff --git a/Makefile b/Makefile
index dd73d76..52561b7 100644
--- a/Makefile
+++ b/Makefile
@@ -117,6 +117,7 @@ taipan.atr: all
# depends on all the pieces, and just concatenates them.
$(XEX): taimain.xex taifont.xex newtitle.xex comptitle.xex
cat comptitle.xex newtitle.xex taifont.xex taimain.xex > $(XEX)
+ perl size.pl $(STACK_SIZE)
# Bitmap data for the title screen, 256x184 = 47104 pixels, 8 bits
# per pixel, or 5888 bytes. Displayed in ANTIC mode F (aka GR.8),
diff --git a/README.txt b/README.txt
index b1aef5d..dd4eb32 100644
--- a/README.txt
+++ b/README.txt
@@ -121,6 +121,12 @@ arcade game).
Bugs! At least these:
+- When Cash is e.g. 2.09 Million, the leading 0 after the decimal
+ point isn't printed (so you get 2.9 Million)
+
+- bignum bank doesn't print enough decimal places (1.1 Million
+ instead of 1.12 Million, etc)
+
- Exiting the game (Play again? N) needs to at minimum restore the
original text/background colors.
diff --git a/bignum.h b/bignum.h
index 67ae902..8794166 100644
--- a/bignum.h
+++ b/bignum.h
@@ -34,10 +34,11 @@
/* bignum 100, used for score calculations in final_stats() */
#define BIG_100 { 0x41, 0x01, 0x00, 0x00, 0x00, 0x00 }
-/* one million, one hundred million, and one billion */
+/* one million, one hundred million, one billion, one trillion */
#define BIG_1M { 0x43, 0x01, 0x00, 0x00, 0x00, 0x00 }
#define BIG_100M { 0x44, 0x01, 0x00, 0x00, 0x00, 0x00 }
#define BIG_1B { 0x44, 0x10, 0x00, 0x00, 0x00, 0x00 }
+#define BIG_1T { 0x46, 0x01, 0x00, 0x00, 0x00, 0x00 }
/* max value for a ulong */
#define BIG_MAX_ULONG { 0x44, 0x42, 0x94, 0x96, 0x72, 0x95 }
diff --git a/size.pl b/size.pl
index 1d012bc..0ec2c4a 100644
--- a/size.pl
+++ b/size.pl
@@ -13,7 +13,7 @@ close MAP;
$free = (0xbc20 - $stack_size) - $bss_end + 1;
-printf " code ends at \$%04x\n", ($bss_start - 1);
-printf " BSS ends at \$%04x\n", $bss_end;
-printf "stack starts at \$%04x\n", 0xbc20 - $stack_size;
-printf "free code space \$%04x (%d, %.1fK)\n", $free, $free, $free / 1024;
+printf "===> code ends at \$%04x\n", ($bss_start - 1);
+printf "===> BSS ends at \$%04x\n", $bss_end;
+printf "===> stack starts at \$%04x\n", 0xbc20 - $stack_size;
+printf "===> free code space \$%04x (%d, %.1fK)\n", $free, $free, $free / 1024;
diff --git a/taipan.c b/taipan.c
index 33c7852..4a0ebbd 100644
--- a/taipan.c
+++ b/taipan.c
@@ -239,6 +239,7 @@ void cprintfancy_ctr(unsigned long num, unsigned char center);
#define cprintfancy(num) cprintfancy_ctr(num, 0)
void too_much_cash(void);
char would_overflow(unsigned long a, unsigned long b);
+int get_time(void);
unsigned char firmpos;
@@ -365,6 +366,9 @@ void cprintfancy_big(bignump b) {
}
#endif
+int get_time(void) {
+ return ((year - 1860) * 12) + month;
+}
/* print an int or long as a string, conio-style */
void cprintulong(unsigned long ul) {
@@ -391,21 +395,25 @@ void at_sea() {
/* this bit of code was duplicated a *bunch* of times,
making it a function makes the binary 2K smaller. */
-void prepare_report() {
+void prepare_report(void) {
gotoxy(0, 16);
clrtobot();
}
-void compradores_report() {
+void compradores_report(void) {
prepare_report();
cputs("Comprador's Report\r\n\n");
}
-void captains_report() {
+void captains_report(void) {
prepare_report();
cputs(" Captain's Report\r\n\n");
}
+void clear_msg_window(void) {
+ gotoxy(0, 18);
+ clrtobot();
+}
void overload(void) {
compradores_report();
@@ -418,10 +426,10 @@ void overload(void) {
void new_ship(void) {
int choice = 0,
time;
-
unsigned long amount;
- time = ((year - 1860) * 12) + month;
+ // time = ((year - 1860) * 12) + month;
+ time = get_time();
amount = randi()%(1000 * (time + 5) / 6) * (capacity / 50) + 1000;
if(cash < amount) {
@@ -468,7 +476,8 @@ void new_gun(void)
unsigned long amount;
- time = ((year - 1860) * 12) + month;
+ // time = ((year - 1860) * 12) + month;
+ time = get_time();
amount = randi()%(1000 * (time + 5) / 6) + 500;
if((cash < amount) || (hold < 10)) {
@@ -681,7 +690,8 @@ int sea_battle(int id, int num_ships) {
orders = 0;
num_on_screen = 0;
- time = ((year - 1860) * 12) + month;
+ // time = ((year - 1860) * 12) + month;
+ time = get_time();
s0 = num_ships;
ok = 0;
ik = 1;
@@ -1513,7 +1523,8 @@ void mchenry(void)
static long br, repair_price, amount;
// int percent = ((float) damage / capacity) * 100,
percent = (damage * 100L / capacity);
- time = ((year - 1860) * 12) + month;
+ // time = ((year - 1860) * 12) + month;
+ time = get_time();
/*
long br = ((((60 * (time + 3) / 4) * (float) randi() / RAND_MAX) +
@@ -1525,8 +1536,9 @@ void mchenry(void)
br = ((randclamp(60 * (time + 3) / 4) + 25 * (time + 3) / 4) * capacity / 50);
repair_price = (br * damage) + 1;
- gotoxy(0, 18);
- clrtobot();
+ clear_msg_window();
+ // gotoxy(0, 18);
+ // clrtobot();
cputs("Och, 'tis a pity to be ");
cprintulong(percent);
cputs("% damaged.\r\nWe can fix yer whole ship for ");
@@ -1557,16 +1569,41 @@ void mchenry(void)
return;
}
-void retire(void)
-{
+void retire_blanks(void) {
+ cputs(" \r\n");
+}
+
+#ifdef BIGNUM
+void aire(void) {
+ bignum(networth);
+ bignum(big1T) = BIG_1T;
+
+ ulong_to_big(cash, networth);
+ big_add(networth, networth, bank);
+
+ if(big_cmp(networth, big1B) < 0) {
+ cputs(" M I L L I O N A I R E ! \r\n");
+ } else if(big_cmp(networth, big1T) < 0) {
+ cputs(" B I L L I O N A I R E ! \r\n");
+ } else {
+ cputs(" T R I L L I O N A I R E ! \r\n");
+ }
+}
+#endif
+
+void retire(void) {
cursor(0);
compradores_report();
revers(1);
- cputs(" \r\n");
- cputs(" Y o u ' r e a \r\n");
- cputs(" \r\n");
- cputs(" M I L L I O N A I R E ! \r\n");
- cputs(" \r\n");
+ retire_blanks();
+ cputs(" Y o u ' r e a \r\n");
+ retire_blanks();
+#ifdef BIGNUM
+ aire();
+#else
+ cputs(" M I L L I O N A I R E ! \r\n");
+#endif
+ retire_blanks();
revers(0);
timed_getch(TMOUT_5S);
@@ -1576,7 +1613,8 @@ void retire(void)
void final_stats(void)
{
int years = year - 1860,
- time = ((year - 1860) * 12) + month,
+ // time = ((year - 1860) * 12) + month,
+ time = get_time(),
choice = 0;
#ifdef BIGNUM
@@ -1808,8 +1846,9 @@ void transfer(void)
timed_getch(TMOUT_5S);
}
} else {
- gotoxy(0, 18);
- clrtobot();
+ clear_msg_window();
+ // gotoxy(0, 18);
+ // clrtobot();
cputs("You have only ");
cprintulong(hold_[i]);
cputs(", Taipan.\r\n");
@@ -1842,8 +1881,9 @@ void transfer(void)
hold -= amount;
break;
} else {
- gotoxy(0, 18);
- clrtobot();
+ clear_msg_window();
+ // gotoxy(0, 18);
+ // clrtobot();
cputs("You have only ");
cprintulong(hkw_[i]);
cputs(", Taipan.\r\n");
@@ -1928,8 +1968,9 @@ void quit(void)
if (((result == 0) && (randi()%(4 + (8 * li))) == 0) || (result == 2))
{
- gotoxy(0, 18);
- clrtobot();
+ clear_msg_window();
+ // gotoxy(0, 18);
+ // clrtobot();
cputs("Li Yuen's pirates, Taipan!!\r\n\n");
bad_joss_sound();
@@ -1997,8 +2038,9 @@ void quit(void)
if (randi()%10 == 0)
{
- gotoxy(0, 18);
- clrtobot();
+ clear_msg_window();
+ // gotoxy(0, 18);
+ // clrtobot();
cputs("Storm, Taipan!!\r\n\n");
bad_joss_sound();
timed_getch(TMOUT_3S);
@@ -2044,8 +2086,9 @@ void quit(void)
port = randi()%7 + 1;
}
- gotoxy(0, 18);
- clrtobot();
+ clear_msg_window();
+ // gotoxy(0, 18);
+ // clrtobot();
cputs("We've been blown off course\r\nto ");
cputs(location[port]);
timed_getch(TMOUT_3S);
@@ -2104,8 +2147,9 @@ void quit(void)
set_prices();
- gotoxy(0, 18);
- clrtobot();
+ clear_msg_window();
+ // gotoxy(0, 18);
+ // clrtobot();
cputs("Arriving at ");
cputs(location[port]);
cputs("...");
@@ -2114,10 +2158,10 @@ void quit(void)
return;
}
-void li_yuen_extortion(void)
-{
- int time = ((year - 1860) * 12) + month,
- choice = 0;
+void li_yuen_extortion(void) {
+ // int time = ((year - 1860) * 12) + month;
+ int time = get_time();
+ unsigned char choice;
/*
float i = 1.8,
@@ -2127,89 +2171,70 @@ void li_yuen_extortion(void)
unsigned long amount = 0;
unsigned int i = 2, j = 0;
- if (time > 12)
- {
- j = randi()%(1000 * time) + (1000 * time);
+ if(time > 12) {
+ j = randi() % (1000 * time) + (1000 * time);
i = 1;
}
// amount = ((cash / i) * ((float) randi() / RAND_MAX)) + j;
amount = randclamp((cash >> (i - 1))) + j;
-
- // fancy_numbers(amount, fancy_num);
+ if(!amount) return; /* asking for 0 is dumb */
compradores_report();
cputs("Li Yuen asks ");
- // cputs(fancy_num);
cprintfancy(amount);
cputs(" in donation\r\nto the temple of Tin Hau, the Sea\r\n");
+ cputs("Goddess. Will you pay? ");
+ choice = yngetc(0);
- while ((choice != 'Y') && (choice != 'y') &&
- (choice != 'N') && (choice != 'n'))
- {
- gotoxy(0, 20);
- cputs("Goddess. Will you pay? ");
- choice = get_one();
- }
-
- if ((choice == 'Y') || (choice == 'y'))
- {
- if (amount <= cash)
- {
+ if(choice == 'y') {
+ if(amount <= cash) {
cash -= amount;
li = 1;
} else {
- gotoxy(0, 18);
- clrtobot();
+ clear_msg_window();
+ // gotoxy(0, 18);
+ // clrtobot();
cputs("Taipan, you do not have enough cash!!\r\n\r\n");
timed_getch(TMOUT_3S);
cputs("Do you want Elder Brother Wu to make up\r\n");
cputs("the difference for you? ");
- choice = 0;
- while ((choice != 'Y') && (choice != 'y') &&
- (choice != 'N') && (choice != 'n'))
- {
- choice = get_one();
- }
+ choice = yngetc(0);;
- if ((choice == 'Y') || (choice == 'y'))
- {
+ clear_msg_window();
+ // gotoxy(0, 18);
+ // clrtobot();
+ if(choice == 'y') {
amount -= cash;
debt += amount;
cash = 0;
li = 1;
- gotoxy(0, 18);
- clrtobot();
cputs("Elder Brother has given Li Yuen the\r\n");
cputs("difference between what he wanted and\r\n");
cputs("your cash on hand and added the same\r\n");
cputs("amount to your debt.\r\n");
-
- timed_getch(TMOUT_5S);
} else {
cash = 0;
cputs("Very well. Elder Brother Wu will not pay\r\n");
cputs("Li Yuen the difference. I would be very\r\n");
cputs("wary of pirates if I were you, Taipan.\r\n");
-
- timed_getch(TMOUT_5S);
}
+ timed_getch(TMOUT_5S);
}
}
port_stats();
-
- return;
}
#ifdef BIGNUM
void you_only_have(unsigned char in_bank) {
- gotoxy(0, 18);
- clrtobot();
+ clear_msg_window();
+ // gotoxy(0, 18);
+ // clrtobot();
cputs("Taipan, you only have ");
if(in_bank)
@@ -2225,8 +2250,9 @@ void you_only_have(unsigned char in_bank) {
}
#else
void you_only_have(unsigned char in_bank) {
- gotoxy(0, 18);
- clrtobot();
+ clear_msg_window();
+ // gotoxy(0, 18);
+ // clrtobot();
cputs("Taipan, you only have ");
cprintfancy(in_bank ? bank : cash);
@@ -2921,8 +2947,9 @@ int main(void) {
timed_getch(TMOUT_3S);
- gotoxy(0, 18);
- clrtobot();
+ clear_msg_window();
+ // gotoxy(0, 18);
+ // clrtobot();
cputs("Elder Brother Wu reminds you of the\r\n");
cputs("Confucian ideal of personal worthiness,\r\n");
cputs("and how this applies to paying one's\r\n");
@@ -2930,8 +2957,9 @@ int main(void) {
timed_getch(TMOUT_3S);
- gotoxy(0, 18);
- clrtobot();
+ clear_msg_window();
+ // gotoxy(0, 18);
+ // clrtobot();
cputs("He is reminded of a fabled barbarian\r\n");
cputs("who came to a bad end, after not caring\r\n");
cputs("for his obligations.\r\n\r\n");