aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.txt39
-rw-r--r--taipan.c65
2 files changed, 82 insertions, 22 deletions
diff --git a/README.txt b/README.txt
index e361781..8bf0349 100644
--- a/README.txt
+++ b/README.txt
@@ -121,10 +121,11 @@ arcade game).
Bugs! At least these:
-- When exiting to DOS and reloading, the title screen graphics are
- messed up. The playtester who reported this was running on real
- hardware (not an emulator). I can't see how this is happening, but I
- expect it's related to this:
+- Semi-fixed: When exiting to DOS and reloading, the title screen
+ graphics are messed up. The playtester who reported this was running
+ on real hardware (not an emulator). Getting the BSS below $9000 seems
+ to have fixed it. I can't see how this is happening, but I expect it's
+ related to this:
- The BSS can overlap the start of the title screen (it's very close
anyway). Consequences: There is a momentary graphics glitch when the
@@ -178,7 +179,9 @@ Bugs! At least these:
- After a fight, "Arriving at Manila" or such would sometimes appears on the
fight screen without clearing it first (if you ran away, you can still
see ships). I *think* this is fixed, but I don't understand what caused
- it so I'm leaving it in this list in case I'm wrong.
+ it so I'm leaving it in this list in case I'm wrong.... and I'm wrong,
+ because it just happened to me again. sea_battle() is returning something
+ unexpected, but how?
Differences between the Apple II original and Linux port:
@@ -252,6 +255,22 @@ Other things that need doing to the code:
- Decide what to do about integer overflow. Possibilities:
+ - This one seems like the best solution to me. The rest of the
+ stuff listed here is left for reference (for now). Here we go: Keep
+ using unsigned long for cash and debt, and use a ROM float for the
+ bank only. If you try to make a sale, borrow from wu, or withdraw an
+ amount that would overflow 32-bit cash, "Taipan, you cannot carry so
+ much cash! Your ship would sink under the weight of your riches!". If
+ pirate booty would overflow, don't award it. If debt interest would
+ result in overflow, the player gets assassinated instead. Advantages
+ of this: less code has to be changed, and the FP stuff is limited
+ so we don't need a good API for it, just a few functions that can
+ call the ROM directly, as needed: bank_deposit(), bank_withdraw(),
+ bank_interest(), bank_compare(). These will need a common ul_to_fp().
+ Also need a would_overflow(unsigned long value, unsigned long amount)
+ to return true if adding value + amount would overflow... actually it
+ can return MAX_LONG - value (still true, but also useful as a value).
+
- Use a "bigint" library (e.g. 64-bit ints). Would still be
possible to overflow, but it would take a really determined
player. Disadvantage: slow. Maxes out at:
@@ -279,6 +298,16 @@ Other things that need doing to the code:
million", this would be faster/easier than a regular bigint.
Maxes out at 429,496,729,600,000 (429 trillion).
+ - Another hybrid idea, might be faster: one long ranging up to
+ 999,999,999, or 1 billion - 1, and an unsigned int for the top
+ bits. Existing cprintfancy() can handle the bottom part, if the
+ top is 0. If not, we only ever need the top digit of the bottom
+ (e.g. the .2 in "1.2 billion"), and then only if the top int is
+ less than 10. Maxes out at 65.535 trillion, meaning we'll need
+ to be able to print "Trillion", perhaps with no space. This is
+ approximately equivalent to a 46-bit int, but uses 48 bits of
+ storage.
+
- Leave it as-is. Obviously the easiest option, but not very satisfying.
Maxes out at a measly 4.2 billion.
diff --git a/taipan.c b/taipan.c
index a30eb93..1ba5751 100644
--- a/taipan.c
+++ b/taipan.c
@@ -165,15 +165,23 @@ void backspace() {
if allow_all is true, allows '*', which is used for
'throw cargo' in sea_battle. */
unsigned char get_item(unsigned char allow_all) {
- unsigned char i;
+ // unsigned char i;
+
for(;;) {
+ /* using a switch makes the code 12 bytes smaller here
i = lcgetc();
- switch(i) {
+ if(i == 'o') return 0;
+ if(i == 's') return 1;
+ if(i == 'a') return 2;
+ if(i == 'g') return 3;
+ if(allow_all && i == '*') return 4;
+ */
+ switch(lcgetc()) {
case 'o': return 0;
case 's': return 1;
case 'a': return 2;
case 'g': return 3;
- case '*': if(allow_all) return 4; /* else fall thru */
+ case '*': if(allow_all) return 4; // else fall thru
default: break;
}
}
@@ -292,9 +300,15 @@ void at_sea() {
revers(1);
cputs(location[0]);
revers(0);
+
+ /* this is 24 bytes smaller: */
+ cputs(" ");
+
+ /* than this:
cputc(' ');
cputc(' ');
cputc(' ');
+ */
}
/* this bit of code was duplicated a *bunch* of times,
@@ -465,9 +479,12 @@ void cprintfancy_ctr(unsigned long num, unsigned char center) {
mil = 0;
if(center) {
+ cputs(" ");
+ /*
cputc(' ');
cputc(' ');
cputc(' ');
+ */
tmp = 0;
for(tmp = 100L; tmp < 1000000L; tmp *= 100L)
if(num < tmp) cputc(' ');
@@ -521,17 +538,22 @@ void fancy_numbers(unsigned long num, char *fancy) {
}
*/
+void justify_int(unsigned int num) {
+ if(num < 1000) cputc(' ');
+ if(num < 100) cputc(' ');
+ if(num < 10) cputc(' ');
+ cprintulong(num);
+}
+
void hide_cursor() {
- gotoxy(0,23); cputc(' ');
+ gotoxy(0,23);
+ cputc(' ');
}
void update_guns() {
revers(1);
gotoxy(31, 1);
- if(guns < 1000) cputc(' ');
- if(guns < 100) cputc(' ');
- if(guns < 10) cputc(' ');
- cprintulong(guns);
+ justify_int(guns);
revers(0);
hide_cursor();
}
@@ -540,11 +562,7 @@ void fight_stats(int ships, int orders) {
cursor(0);
gotoxy(0, 0);
- if(ships < 1000) cputc(' ');
- if(ships < 100) cputc(' ');
- if(ships < 10) cputc(' ');
- cprintulong(ships);
-
+ justify_int(ships);
cputs(" ship");
if(ships != 1) cputc('s');
cputs(" attacking, Taipan! \r\n");
@@ -651,6 +669,16 @@ int sea_battle(int id, int num_ships) {
cputs("\r\n");
input = timed_getch(TMOUT_3S);
+ /* using a switch() instead of a chain of if/else
+ actually increases code size by 16 bytes!
+ switch(orders) {
+ case 'f': orders == 1;
+ case 'r': orders == 2;
+ case 't': orders == 3;
+ default: break;
+ }
+ */
+
if(input == 'f') {
orders = 1;
} else if(input == 'r') {
@@ -734,8 +762,7 @@ int sea_battle(int id, int num_ships) {
plus_or_space(num_ships > num_on_screen);
gotoxy(0, 16);
- cputc('\r');
- cputc('\n');
+ cputs("\r\n");
targeted = randi()%10;
while(ships_on_screen[targeted] == 0) {
@@ -1116,7 +1143,7 @@ int sea_battle(int id, int num_ships) {
long get_num(void) {
static char number[20];
unsigned char count = 0;
- int input;
+ char input;
cursor(1);
cblank(1);
@@ -1609,7 +1636,11 @@ void final_stats(void)
// __asm__("jmp $e477");
/* exit(0) works in DOS 2.0s and 2.5, known to fail in Sparta */
- exit(0);
+ // exit(0);
+
+ /* let's try doing it this way. I suspect it will have the same
+ results as exit(0)... */
+ __asm__("jmp (10)"); // aka DOSVEC
}
void transfer(void)