aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile7
-rw-r--r--taipan.c66
2 files changed, 60 insertions, 13 deletions
diff --git a/Makefile b/Makefile
index 4daa2ea..9a68be0 100644
--- a/Makefile
+++ b/Makefile
@@ -7,10 +7,10 @@ SYS=atari
#COPT=-O -l -T
COPT=-O -T
-# for older cc65:
+# for older cc65, we need a custom linker file.
#CFLAGS=-t $(SYS) -C custom.cfg -I. -L. $(COPT)
-# for recent git cc65.
+# for recent git cc65, we can reserve memory on the command line.
# -D__RESERVED_MEMORY__=1056 because cc65's default end of memory
# is $BC20, and we want it to end just below our font, which starts
# at $B800.
@@ -88,3 +88,6 @@ lorchatest: lorchatest.c draw_lorcha.s taifont.xex
cl65 -t atari -O -T -o lorchatest1.xex lorchatest.c draw_lorcha.s
cat taifont.xex lorchatest1.xex > lorchatest.xex
atari800 -nobasic lorchatest.xex
+
+PORTSTAT.DAT: mkportstats.xex
+ atari800 -nobasic mkportstats.xex
diff --git a/taipan.c b/taipan.c
index 334543e..ac43bb8 100644
--- a/taipan.c
+++ b/taipan.c
@@ -61,6 +61,7 @@ unsigned long randl() {
}
*/
+char port_stat_dirty = 1;
extern const char *port_stat_screen;
/**** End of atari-specific stuff */
@@ -190,6 +191,15 @@ void cprintulong(unsigned long ul) {
cputs(ultoa(ul, fancy_num, 10));
}
+/* print 'count' spaces, but leave the cursor where it was.
+ doesn't work if the cursor wraps to the next line!
+ */
+void cblank(unsigned char count) {
+ char oldx = wherex();
+ while(count--) cputc(' ');
+ gotox(oldx);
+}
+
#ifdef COMBAT_TEST
void show_damage(void) {
cputc(' ');
@@ -213,6 +223,7 @@ void at_sea() {
revers(0);
cputc(' ');
cputc(' ');
+ cputc(' ');
}
/* this bit of code was duplicated a *bunch* of times,
@@ -510,6 +521,8 @@ int sea_battle(int id, int num_ships) {
input,
status;
+ port_stat_dirty = 1;
+
orders = 0;
num_on_screen = 0;
time = ((year - 1860) * 12) + month;
@@ -966,11 +979,17 @@ int sea_battle(int id, int num_ships) {
// damage = damage + ((ed * i * id) * ((float) randi() / RAND_MAX)) + (i / 2);
// remember, ed is now scaled by 2 (used to be 0.5, now 1)
- // damage = damage + randclamp((ed * i * id)/2) + (i / 2);
- // damage = damage + randclamp((ed * i * id)/2) + (i / 2); // b0rked
- newdamage = (randi() % ((ed * i * id)/2)) + (i / 2);
+ // broken because sometimes works out to 0 or 1. If it's 0,
+ // randi()%0 is just randi() (ouch)... on a modern platform,
+ // this would trigger a floating point exception or similar.
+ // cc65 runtime can't detect it...
+ // If ((ed * i * id)/2)) works out to 1, anything%1 is 0.
// damage = damage + (randi() % ((ed * i * id)/2)) + (i / 2);
+
+ newdamage = ((ed * i * id)/2) + (i / 2);
+ if(newdamage > 1)
+ newdamage = randi() % newdamage;
damage += newdamage;
#ifdef DAMAGE_TEST
@@ -1196,11 +1215,15 @@ void port_stats(void)
cputsxy(20, 14, "Bank: ");
#else
- void *p = PEEK(88) + 256 * PEEK(89);
- memcpy(p, &port_stat_screen, 640);
+ if(port_stat_dirty) {
+ void *p = PEEK(88) + 256 * PEEK(89);
+ memcpy(p, &port_stat_screen, 640);
+ port_stat_dirty = 0;
+ }
#endif
/* dynamic stuff: */
+ cursor(0);
gotoxy(12 - strlen(firm) / 2, 0); /* TODO: store in global */
cputs("Firm: ");
cputs(firm);
@@ -1209,25 +1232,32 @@ void port_stats(void)
gotoxy(21, 4);
in_use = hkw_[0] + hkw_[1] + hkw_[2] + hkw_[3];
+ cblank(5);
cprintulong(in_use);
gotoxy(21, 6);
+ cblank(5);
cprintulong(10000 - in_use);
gotoxy(12, 3);
+ cblank(5);
cprintulong(hkw_[0]);
gotoxy(12, 4);
+ cblank(5);
cprintulong(hkw_[1]);
gotoxy(12, 5);
+ cblank(5);
cprintulong(hkw_[2]);
gotoxy(12, 6);
+ cblank(5);
cprintulong(hkw_[3]);
gotoxy(7, 8);
if (hold >= 0) {
+ cblank(8);
cprintulong(hold);
} else {
revers(1);
@@ -1236,18 +1266,23 @@ void port_stats(void)
}
gotoxy(22, 8);
+ cblank(5);
cprintulong(guns);
gotoxy(12, 9);
+ cblank(9);
cprintulong(hold_[0]);
gotoxy(12, 10);
+ cblank(9);
cprintulong(hold_[1]);
gotoxy(12, 11);
+ cblank(9);
cprintulong(hold_[2]);
gotoxy(12, 12);
+ cblank(9);
cprintulong(hold_[3]);
gotoxy(32, 3);
@@ -1257,13 +1292,18 @@ void port_stats(void)
cputc(' ');
cprintulong(year);
+ gotoxy(30, 6);
+ cblank(10);
revers(1);
cputsxy(30, 6, location[port]);
revers(0);
- revers(1);
- gotoxy(33, 9);
+ // gotoxy(33, 9);
+ gotoy(9);
fancy_numbers(debt, fancy_num);
+ gotox(33 - strlen(fancy_num) / 2);
+ clrtoeol();
+ revers(1);
cputs(fancy_num);
revers(0);
@@ -1274,13 +1314,16 @@ void port_stats(void)
}
cputs(st[i]);
cputc(':');
+ cblank(3);
cprintulong(status);
revers(0);
gotoxy(6, 14);
+ cblank(14);
fancy_numbers(cash, fancy_num);
cputs(fancy_num);
gotoxy(26, 14);
+ cblank(13);
fancy_numbers(bank, fancy_num);
cputs(fancy_num);
}
@@ -1340,11 +1383,10 @@ void mchenry(void)
if ((choice == 'Y') || (choice == 'y'))
{
- // int percent = ((float) damage / capacity) * 100,
- // this is likely wrong:
static int percent, time;
static long br, repair_price, amount;
- percent = ((damage * 100) / (capacity * 100)) * 100;
+ // int percent = ((float) damage / capacity) * 100,
+ percent = (damage * 100 / capacity);
time = ((year - 1860) * 12) + month;
/*
@@ -1410,6 +1452,8 @@ void final_stats(void)
time = ((year - 1860) * 12) + month,
choice = 0;
+ port_stat_dirty = 1;
+
clrscr();
cputs("Your final status:\r\n\r\n");
cash = cash + bank - debt;
@@ -1609,7 +1653,7 @@ void transfer(void)
compradores_report();
cputs("How much ");
cputs(item[i]);
- cputs("shall I move\r\naboard ship, Taipan? ");
+ cputs(" shall I move\r\naboard ship, Taipan? ");
amount = get_num(9);
if (amount == -1)