aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile6
-rw-r--r--procsizes.pl24
-rw-r--r--taipan.c199
-rw-r--r--timed_getch.s27
5 files changed, 137 insertions, 120 deletions
diff --git a/.gitignore b/.gitignore
index 45483cf..dbf7582 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+procsizes
msg.inc
messages.c
msg.out
diff --git a/Makefile b/Makefile
index 758f06b..0e5b021 100644
--- a/Makefile
+++ b/Makefile
@@ -253,7 +253,7 @@ taimain.xex: $(TAIMAIN_C_SRC) $(TAIMAIN_ASM_SRC) $(TAIMAIN_HDRS) $(BIGNUM_SRC) $
# taipan.c. This rule not used as part of the main build, it's only for
# debugging.
taipan.lst: taipan.c
- $(CC) -m taipan.map $(CFLAGS) -c -o /dev/null -l taipan.lst -T taipan.c
+ $(CC) -m taipan.map $(CFLAGS) $(BIGNUM_CFLAGS) -c -o /dev/null -l taipan.lst -T taipan.c
# Another such rule for sounds.c:
sounds.lst: sounds.c sounds.h
@@ -400,6 +400,10 @@ push:
size: clean all
$(PERL) size.pl $(TAIMAIN_ADDR) $(STACK_SIZE)
+procsizes: clean all taipan.lst
+ $(PERL) procsizes.pl > procsizes
+ cat procsizes
+
# Cruft. Was used for testing the enemy ship animation.
lorchatest: lorchatest.c draw_lorcha.s taifont.xex
$(CC) -t atari -O -T -o lorchatest1.xex lorchatest.c draw_lorcha.s
diff --git a/procsizes.pl b/procsizes.pl
new file mode 100644
index 0000000..287cf46
--- /dev/null
+++ b/procsizes.pl
@@ -0,0 +1,24 @@
+#!/usr/bin/perl -w
+
+open IN, "<taipan.lst" or die $!;
+
+while(<IN>) {
+ (/^([0-9A-F]{6})/) && (eval "\$addr = 0x$1");
+ if(/\.proc\s+_(\w+)/) {
+ $proc = $1;
+ $start{$proc} = $addr;
+ } elsif(/\.endproc/) {
+ $end{$proc} = $addr - 1;
+ $proc = "";
+ }
+}
+
+for(sort keys %start) {
+ $len{$_} = $end{$_} - $start{$_} + 1;
+}
+
+for(sort { $len{$a} <=> $len{$b} } keys %len) {
+ printf "% 32s % d\n", $_, $len{$_};
+ $total += $len{$_};
+}
+printf "% 32s % d\n", "Total:", $total;
diff --git a/taipan.c b/taipan.c
index 1f58cd8..1b30c6b 100644
--- a/taipan.c
+++ b/taipan.c
@@ -221,6 +221,10 @@ void backspace() {
/* get an inventory item, return its index into items[].
if allow_all is true, allows '*', which is used for
'throw cargo' in sea_battle. */
+extern unsigned char get_item(unsigned char allow_all);
+
+/*
+ rewritten in asm, in timed_getch.s, here's the original:
unsigned char get_item(unsigned char allow_all) {
for(;;) {
switch(lcgetc()) {
@@ -233,6 +237,26 @@ unsigned char get_item(unsigned char allow_all) {
}
}
}
+*/
+
+/* sound-and-getch functions cost 6 bytes each, but save 3 bytes
+ every time they replace 2 function calls. Total saving works
+ out to 56 bytes, so worth doing.
+ */
+void good_joss_timed_getch() {
+ good_joss_sound();
+ timed_getch();
+}
+
+void bad_joss_timed_getch() {
+ bad_joss_sound();
+ timed_getch();
+}
+
+void under_attack_timed_getch() {
+ under_attack_sound();
+ timed_getch();
+}
#ifdef CART_TARGET
# pragma code-name (pop)
@@ -692,8 +716,7 @@ void overload(void) {
// cputs("Your ship is overloaded");
print_msg(M_overloaded);
cprint_taipan_bangbang();
- good_joss_sound();
- timed_getch();
+ good_joss_timed_getch();
return;
}
@@ -1472,8 +1495,7 @@ char sea_battle(char id, int num_ships) {
// cputs("We got 'em all");
print_msg(M_we_got_em_all);
cprint_taipan_bang();
- bad_joss_sound();
- timed_getch();
+ bad_joss_timed_getch();
return 1;
} else {
@@ -2138,8 +2160,7 @@ void you_have_only(void) {
#endif
-void transfer(void)
-{
+void transfer(void) {
int i, in_use;
unsigned long amount = 0;
@@ -2150,18 +2171,13 @@ void transfer(void)
print_msg(M_you_have_no_cargo);
cprint_taipan_period();
crlf();
- good_joss_sound();
-
- timed_getch();
+ good_joss_timed_getch();
return;
}
- for (i = 0; i < 4; i++)
- {
- if (hold_[i] > 0)
- {
- for (;;)
- {
+ for(i = 0; i < 4; i++) {
+ if(hold_[i] > 0) {
+ for (;;) {
compradores_report();
how_much();
// cputs(item[i]);
@@ -2171,35 +2187,30 @@ void transfer(void)
cprint_taipan_prompt();
amount = get_num();
- if (amount == UINT32_MAX)
- {
+ if(amount == UINT32_MAX)
amount = hold_[i];
- }
- if (amount <= hold_[i])
- {
+
+ if(amount <= hold_[i]) {
// in_use = hkw_[0] + hkw_[1] + hkw_[2] + hkw_[3];
in_use = warehouse_in_use();
- if ((in_use + amount) <= 10000)
- {
+ if((in_use + amount) <= 10000) {
hold_[i] -= amount;
hkw_[i] += amount;
hold += amount;
break;
- } else if (in_use == 10000) {
+ } else if(in_use == 10000) {
gotoxy(0, 21);
// cputs("Your warehouse is full");
print_msg(M_whouse_full);
cprint_taipan_bang();
- good_joss_sound();
+ good_joss_timed_getch();
} else {
gotoxy(0, 21);
// cputs("Your warehouse will only hold an\nadditional ");
print_msg(M_whouse_only_hold);
cprintuint(10000 - in_use);
cprint_taipan_bang();
- good_joss_sound();
-
- timed_getch();
+ good_joss_timed_getch();
}
} else {
clear_msg_window();
@@ -2209,18 +2220,14 @@ void transfer(void)
cprintulong(hold_[i]);
// cputs(", Taipan.\n");
cprint_taipan_period();
- good_joss_sound();
-
- timed_getch();
+ good_joss_timed_getch();
}
}
port_stats();
}
- if (hkw_[i] > 0)
- {
- for (;;)
- {
+ if(hkw_[i] > 0) {
+ for(;;) {
compradores_report();
how_much();
// cputs(item[i]);
@@ -2230,12 +2237,10 @@ void transfer(void)
cprint_taipan_prompt();
amount = get_num();
- if (amount == UINT32_MAX)
- {
+ if(amount == UINT32_MAX)
amount = hkw_[i];
- }
- if (amount <= hkw_[i])
- {
+
+ if(amount <= hkw_[i]) {
hold_[i] += amount;
hkw_[i] -= amount;
hold -= amount;
@@ -2249,8 +2254,7 @@ void transfer(void)
cprint_taipan_period();
// cputs("\n");
crlf();
-
- timed_getch();
+ good_joss_timed_getch();
}
}
port_stats();
@@ -2290,21 +2294,18 @@ void quit(void)
"7) Batavia ? ");
*/
- for (;;)
- {
+ for (;;) {
gotoxy(12, 21);
clrtobot();
choice = numgetc() - '0';
- if (choice == port)
- {
+ if(choice == port) {
// cputs("\n\nYou're already here");
print_msg(M_already_here);
cprint_taipan_period();
- good_joss_sound();
- timed_getch();
- } else if ((choice >= 1) && (choice <= 7)) {
+ good_joss_timed_getch();
+ } else if((choice >= 1) && (choice <= 7)) {
port = choice;
break;
}
@@ -2333,16 +2334,13 @@ void quit(void)
print_msg(M_approaching);
cprint_taipan_bang();
crlf();
- under_attack_sound();
-
- timed_getch();
+ under_attack_timed_getch();
result = sea_battle(GENERIC, num_ships);
gotoxy(0,23); /* to avoid disappearing U in "In use" */
}
- if (result == 2)
- {
+ if(result == 2) {
port_stats();
at_sea();
@@ -2354,8 +2352,7 @@ void quit(void)
timed_getch();
}
- if (((result == 0) && (randi()%(4 + (8 * li))) == 0) || (result == 2))
- {
+ if(((result == 0) && (randi()%(4 + (8 * li))) == 0) || (result == 2)) {
clear_msg_window();
// cprint_li_yuen();
// cputs("'s pirates");
@@ -2363,17 +2360,12 @@ void quit(void)
cprint_taipan_bangbang();
crlf();
crlf();
- bad_joss_sound();
+ bad_joss_timed_getch();
- timed_getch();
-
- if (li > 0)
- {
+ if(li > 0) {
// cputs("Good joss!! They let us be!!\n");
print_msg(M_they_let_us_be);
- bad_joss_sound();
-
- timed_getch();
+ bad_joss_timed_getch();
// return; // original code, results in prices not changing.
result = 0;
@@ -2386,8 +2378,7 @@ void quit(void)
// cputs(" ships of Li Yuen's pirate\nfleet");
print_msg(M_ships_of_fleet);
cprint_taipan_bangbang();
- under_attack_sound();
- timed_getch();
+ under_attack_timed_getch();
/* WTF, the original code reads:
sea_battle(LI_YUEN, num_ships);
@@ -2399,39 +2390,34 @@ void quit(void)
}
}
- if (result > 0)
- {
+ if(result > 0) {
port_stats();
at_sea();
captains_report();
- if (result == 1)
- {
+ if(result == 1) {
// cputs("We captured some booty.\n"
// "It's worth ");
print_msg(M_captured_some_booty);
cprintfancy(booty);
cprint_bang();
cash += booty;
- good_joss_sound();
+ good_joss_timed_getch();
} else if (result == 3) {
// cputs("We made it!");
print_msg(M_we_made_it);
- good_joss_sound();
+ good_joss_timed_getch();
} else {
// cputs("The buggers got us");
print_msg(M_buggers_got_us);
cprint_taipan_bangbang();
// cputs("!\nIt's all over, now!!!");
print_msg(M_all_over_now);
-
- timed_getch();
+ under_attack_timed_getch();
final_stats();
return;
}
-
- timed_getch();
}
if(one_chance_in(10)) {
@@ -2441,8 +2427,7 @@ void quit(void)
cprint_taipan_bangbang();
crlf();
crlf();
- bad_joss_sound();
- timed_getch();
+ bad_joss_timed_getch();
if(one_chance_in(30)) {
// cputs(" I think we're going down!!\n\n");
@@ -2468,8 +2453,7 @@ void quit(void)
print_msg(M_were_going_down);
cprint_taipan_bangbang();
crlf();
- under_attack_sound();
- timed_getch();
+ under_attack_timed_getch();
final_stats();
}
@@ -2477,8 +2461,7 @@ void quit(void)
// cputs(" We made it!!\n\n");
print_msg(M_storm_we_made_it);
- bad_joss_sound();
- timed_getch();
+ bad_joss_timed_getch();
if(one_chance_in(3)) {
int orig = port;
@@ -2662,9 +2645,7 @@ void you_only_have(unsigned char in_bank) {
// cputs(in_bank ? "the bank" : "cash");
print_msg(in_bank ? M_the_bank : M_cash);
cputs(".\n");
- good_joss_sound();
-
- timed_getch();
+ good_joss_timed_getch();
}
#else
void you_only_have(unsigned char in_bank) {
@@ -2678,15 +2659,12 @@ void you_only_have(unsigned char in_bank) {
cputs("\nin ");
cputs(in_bank ? "the bank" : "cash");
cputs(".\n");
- good_joss_sound();
-
- timed_getch();
+ good_joss_timed_getch();
}
#endif
-void elder_brother_wu(void)
-{
- int choice = 0;
+void elder_brother_wu(void) {
+ int choice = 0;
unsigned long wu = 0;
@@ -2740,9 +2718,7 @@ void elder_brother_wu(void)
compradores_report();
// cputs("Very well, Taipan, the game is over!\n");
print_msg(M_game_is_over);
- under_attack_sound();
-
- timed_getch();
+ under_attack_timed_getch();
final_stats();
} else {
@@ -2753,9 +2729,7 @@ void elder_brother_wu(void)
compradores_report();
// cputs("Very well, Taipan. Good joss!!\n");
print_msg(M_very_well_good_joss);
- bad_joss_sound();
-
- timed_getch();
+ bad_joss_timed_getch();
return;
}
@@ -2819,8 +2793,7 @@ void elder_brother_wu(void)
// cputs("\n\nHe won't loan you so much");
print_msg(M_wont_loan);
cprint_taipan_bang();
- good_joss_sound();
- timed_getch();
+ good_joss_timed_getch();
}
}
port_stats();
@@ -2833,14 +2806,14 @@ void elder_brother_wu(void)
}
if((debt > 20000) && (cash > 0) && (one_chance_in(5))) {
- int num = randi()%3 + 1;
+ unsigned char num = randi()%3 + 1;
cash = 0;
port_stats();
compradores_report();
cprint_bad_joss();
- cprintuint(num);
+ cprintuchar(num);
/*
cputs(" of your bodyguards have been killed\n"
"by cutthroats and you have been robbed\n"
@@ -2849,9 +2822,7 @@ void elder_brother_wu(void)
print_msg(M_bodyguards_killed);
cprint_taipan_bangbang();
crlf();
- under_attack_sound();
-
- timed_getch();
+ under_attack_timed_getch();
}
return;
@@ -2886,9 +2857,7 @@ void good_prices(void) {
cprintulong(price[i]);
// cputs("!!\n");
print_msg(M_bang_bang_nl);
- good_joss_sound();
-
- timed_getch();
+ good_joss_timed_getch();
}
int port_choices(void) {
@@ -3228,8 +3197,7 @@ void too_much_cash(void) {
cprint_taipan_bang();
// cputs("\nYour ship would sink under the weight\nof your riches.\n");
print_msg(M_ship_would_sink);
- bad_joss_sound();
- timed_getch();
+ bad_joss_timed_getch();
}
#ifdef CART_TARGET
# pragma code-name (pop)
@@ -3407,8 +3375,7 @@ int main(void) {
cprint_taipan_comma();
// cputs("you have been assassinated!");
print_msg(M_assassinated_1);
- under_attack_sound();
- timed_getch();
+ under_attack_timed_getch();
compradores_report();
// cputs("As the masked figure plunges the blade\n"
// "into your heart, he says:\n");
@@ -3545,8 +3512,7 @@ int main(void) {
"to see you in Hong Kong, posthaste!\n");
*/
print_msg(M_has_sent_lieutenant);
- bad_joss_sound();
- timed_getch();
+ bad_joss_timed_getch();
}
if(one_chance_in(9))
@@ -3569,14 +3535,11 @@ int main(void) {
print_msg(M_in_cash);
cprint_taipan_bangbang();
crlf();
- under_attack_sound();
-
- timed_getch();
+ under_attack_timed_getch();
}
- for (;;)
- {
- while (choice != 'q') {
+ for(;;) {
+ while(choice != 'q') {
switch (choice = port_choices()) {
case 'b':
buy();
diff --git a/timed_getch.s b/timed_getch.s
index 40a2722..eaf7ab3 100644
--- a/timed_getch.s
+++ b/timed_getch.s
@@ -1,6 +1,6 @@
.export _timed_getch, _set_jiffy_timer, _agetc, _numgetc
- .export _yngetc, _lcgetc, _jsleep
+ .export _yngetc, _lcgetc, _jsleep, _get_item
.import _cgetc, _cblank, putchar, _rand
.include "atari.inc"
@@ -166,3 +166,28 @@ _yngetc:
beq _yngetc ; no default, get another keypress
rts ; else return the default
+; extern unsigned char get_item(unsigned char allow_all);
+_get_item:
+ sta FR0 ; stash arg
+@getkey:
+ jsr _lcgetc ; switch(lcgetc()) {
+ ldx #0
+ cmp #'o'
+ beq @gi_done ; case 'o': return 0;
+ inx
+ cmp #'s'
+ beq @gi_done ; case 's': return 1;
+ inx
+ cmp #'a'
+ beq @gi_done ; case 'a': return 2;
+ inx
+ cmp #'g'
+ beq @gi_done ; case 'g': return 3;
+ ldy FR0
+ beq @getkey ; if allow_all is false, get another key
+ inx
+ cmp #'*' ; case '*': return 4;
+ bne @getkey ; if none of the above, get another key
+@gi_done:
+ txa
+ rts