aboutsummaryrefslogtreecommitdiff
path: root/taipan.c
diff options
context:
space:
mode:
Diffstat (limited to 'taipan.c')
-rw-r--r--taipan.c144
1 files changed, 98 insertions, 46 deletions
diff --git a/taipan.c b/taipan.c
index 40cfb5d..334543e 100644
--- a/taipan.c
+++ b/taipan.c
@@ -8,7 +8,10 @@
/* define this for testing sea_battle(). it causes a pirate
attack every time you leave port. Don't leave defined for
a release!! */
-#define COMBAT_TEST
+// #define COMBAT_TEST
+
+/* define this to show internals of damage calculation */
+#define DAMAGE_TEST
/**** atari-specific stuff */
@@ -58,6 +61,7 @@ unsigned long randl() {
}
*/
+extern const char *port_stat_screen;
/**** End of atari-specific stuff */
@@ -179,6 +183,8 @@ int hold = 0,
wu_warn = 0,
wu_bailout = 0;
+int newdamage;
+
/* print an int or long as a string, conio-style */
void cprintulong(unsigned long ul) {
cputs(ultoa(ul, fancy_num, 10));
@@ -312,7 +318,7 @@ void new_gun(void)
fancy_numbers(amount, fancy_num);
compradores_report();
- cputs("Do you wish to buy a ship's gun\r\n for ");
+ cputs("Do you wish to buy a ship's gun\r\nfor ");
cputs(fancy_num);
cputs(", Taipan? ");
@@ -963,7 +969,24 @@ int sea_battle(int id, int num_ships) {
// damage = damage + randclamp((ed * i * id)/2) + (i / 2);
// damage = damage + randclamp((ed * i * id)/2) + (i / 2); // b0rked
- damage = damage + (randi() % ((ed * i * id)/2)) + (i / 2);
+ newdamage = (randi() % ((ed * i * id)/2)) + (i / 2);
+ // damage = damage + (randi() % ((ed * i * id)/2)) + (i / 2);
+ damage += newdamage;
+
+#ifdef DAMAGE_TEST
+ gotoxy(0, 23);
+ cprintulong(ed);
+ cputc(' ');
+ cprintulong(i);
+ cputc(' ');
+ cprintulong(id);
+ cputc(' ');
+ cprintulong(damage);
+ cputc(' ');
+ cprintulong(newdamage);
+ cgetc();
+#endif
+
if(damage > capacity) damage = capacity; /* just in case */
if((id == GENERIC) && (randi()%20 == 0)) {
return 2;
@@ -1127,13 +1150,13 @@ void port_stats(void)
int i, in_use,
status = 100 - ((damage * 100) / capacity);
- clrscr();
- gotox(12 - strlen(firm) / 2); /* TODO: store in global */
- cputs("Firm: ");
- cputs(firm);
- cputs(", Hong Kong");
+ /* all the static text that used to be in port_stats() has
+ been moved to mkportstats.c, which creates a .xex file which
+ will get prepended to taipan.xex and loaded into a chunk of memory
+ cc65 won't use. When it's time to print it, it'll get memcpy()ed
+ into *SAVMSC. */
- show_damage();
+#if 0
chlinexy(1, 1, 26);
chlinexy(1, 7, 26);
chlinexy(1, 13, 26);
@@ -1154,34 +1177,57 @@ void port_stats(void)
cputsxy(1, 2, "Hong Kong Warehouse");
cputsxy(4, 3, "Opium In use");
cputsxy(4, 4, "Silk ");
- in_use = hkw_[0] + hkw_[1] + hkw_[2] + hkw_[3];
- // printw("%d", in_use);
- cprintulong(in_use);
cputsxy(4, 5, "Arms Vacant");
cputsxy(4, 6, "General ");
- // printw("%d", (10000 - in_use));
+ cputsxy(1, 8, "Hold ");
+ cputsxy(16, 8, "Guns ");
+
+ cputsxy(4, 9, "Opium ");
+ cputsxy(4, 10, "Silk ");
+ cputsxy(4, 11, "Arms ");
+ cputsxy(4, 12, "General ");
+ cputsxy(32, 2, "Date");
+ cputsxy(29, 3, "15 ");
+
+ cputsxy(30, 5, "Location");
+ cputsxy(32, 8, "Debt");
+ cputsxy(29, 11, "Ship Status");
+ cputsxy(0, 14, "Cash: ");
+ cputsxy(20, 14, "Bank: ");
+#else
+
+ void *p = PEEK(88) + 256 * PEEK(89);
+ memcpy(p, &port_stat_screen, 640);
+#endif
+
+ /* dynamic stuff: */
+ gotoxy(12 - strlen(firm) / 2, 0); /* TODO: store in global */
+ cputs("Firm: ");
+ cputs(firm);
+ cputs(", Hong Kong");
+ show_damage();
+
+ gotoxy(21, 4);
+ in_use = hkw_[0] + hkw_[1] + hkw_[2] + hkw_[3];
+ cprintulong(in_use);
+
+ gotoxy(21, 6);
cprintulong(10000 - in_use);
gotoxy(12, 3);
- // printw("%d", hkw_[0]);
cprintulong(hkw_[0]);
gotoxy(12, 4);
- // printw("%d", hkw_[1]);
cprintulong(hkw_[1]);
gotoxy(12, 5);
- // printw("%d", hkw_[2]);
cprintulong(hkw_[2]);
gotoxy(12, 6);
- // printw("%d", hkw_[3]);
cprintulong(hkw_[3]);
- cputsxy(1, 8, "Hold ");
- if (hold >= 0)
- {
- // printw("%d", hold);
+ gotoxy(7, 8);
+ if (hold >= 0) {
cprintulong(hold);
} else {
revers(1);
@@ -1189,48 +1235,38 @@ void port_stats(void)
revers(0);
}
- cputsxy(16, 8, "Guns ");
- // printw("%d", guns);
+ gotoxy(22, 8);
cprintulong(guns);
- cputsxy(4, 9, "Opium ");
- // printw("%d", hold_[0]);
+ gotoxy(12, 9);
cprintulong(hold_[0]);
- cputsxy(4, 10, "Silk ");
- // printw("%d", hold_[1]);
+ gotoxy(12, 10);
cprintulong(hold_[1]);
- cputsxy(4, 11, "Arms ");
- // printw("%d", hold_[2]);
+ gotoxy(12, 11);
cprintulong(hold_[2]);
- cputsxy(4, 12, "General ");
- // printw("%d", hold_[3]);
+ gotoxy(12, 12);
cprintulong(hold_[3]);
- cputsxy(32, 2, "Date");
- cputsxy(29, 3, "15 ");
+ gotoxy(32, 3);
revers(1);
cputs(months[month - 1]);
revers(0);
cputc(' ');
- // printw(" %d", year);
cprintulong(year);
- cputsxy(30, 5, "Location");
revers(1);
cputsxy(30, 6, location[port]);
revers(0);
- cputsxy(32, 8, "Debt");
revers(1);
gotoxy(33, 9);
fancy_numbers(debt, fancy_num);
cputs(fancy_num);
revers(0);
- cputsxy(29, 11, "Ship Status");
gotoxy(29, 12);
i = status / 20;
if (i < 2) {
@@ -1241,10 +1277,10 @@ void port_stats(void)
cprintulong(status);
revers(0);
- cputsxy(0, 14, "Cash: ");
+ gotoxy(6, 14);
fancy_numbers(cash, fancy_num);
cputs(fancy_num);
- cputsxy(20, 14, "Bank: ");
+ gotoxy(26, 14);
fancy_numbers(bank, fancy_num);
cputs(fancy_num);
}
@@ -1263,6 +1299,19 @@ void splash_intro(void)
{
int i;
+ cursor(0);
+ gotoxy(0,23);
+#ifdef VERSION
+ cputs(VERSION);
+#else
+ cputs("(no version info)");
+#endif
+
+ /* if we print anything in this function, the character at (2,0)
+ gets inversed because the OS placed a cursor there. Fix it: */
+ gotoxy(2,0);
+ cputc(0xa0);
+
for(i=0; i<3; i++) draw_lorcha(i);
for(i=5; i<8; i++) draw_lorcha(i);
@@ -1274,12 +1323,13 @@ void splash_intro(void)
void mchenry(void)
{
- int choice = 0;
+ static int choice;
+ choice = 0;
compradores_report();
cputs("Taipan, Mc Henry from the Hong Kong\r\n");
- cputs("Shipyards has arrived!! He says, \"I see\r\n");
- cputs("ye've a wee bit of damage to yer ship.\r\n");
+ cputs("Shipyards has arrived!! He says, 'I see\r\n");
+ cputs("ye've a wee bit of damage to yer ship.'\r\n");
cputs("Will ye be wanting repairs? ");
while ((choice != 'Y') && (choice != 'y') &&
@@ -1292,8 +1342,10 @@ void mchenry(void)
{
// int percent = ((float) damage / capacity) * 100,
// this is likely wrong:
- int percent = ((damage * 100) / (capacity * 100)) * 100,
- time = ((year - 1860) * 12) + month;
+ static int percent, time;
+ static long br, repair_price, amount;
+ percent = ((damage * 100) / (capacity * 100)) * 100;
+ time = ((year - 1860) * 12) + month;
/*
long br = ((((60 * (time + 3) / 4) * (float) randi() / RAND_MAX) +
@@ -1302,7 +1354,6 @@ void mchenry(void)
amount;
*/
- long br, repair_price, amount;
br = ((randclamp(60 * (time + 3) / 4) + 25 * (time + 3) / 4) * capacity / 50);
repair_price = (br * damage) + 1;
@@ -1666,7 +1717,8 @@ void quit(void)
return;
} else {
- int num_ships = randi()%((capacity / 5) + guns) + 5;
+ static int num_ships;
+ num_ships = randi()%((capacity / 5) + guns) + 5;
cprintulong(num_ships);
cputs("ships of Li Yuen's pirate\r\n");