aboutsummaryrefslogtreecommitdiff
path: root/taipan.c
diff options
context:
space:
mode:
Diffstat (limited to 'taipan.c')
-rw-r--r--taipan.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/taipan.c b/taipan.c
index 65a017a..e987170 100644
--- a/taipan.c
+++ b/taipan.c
@@ -75,6 +75,9 @@ extern unsigned char __fastcall__ yngetc(char dflt);
/* sleep for j jiffies (no PAL adjustment at the moment) */
extern void __fastcall__ jsleep(unsigned int j);
+/* sleep for j jiffies unless turbo is true */
+extern void __fastcall__ tjsleep(unsigned int j);
+
/* flash screen when we're hit in combat */
extern void explosion(void);
@@ -1012,10 +1015,13 @@ void set_orders(void) {
/* sea_battle only ever returns 1 to 4. making the
return type a char saved 61 bytes! */
+int ships_on_screen[10];
+extern char have_ships_on_screen(void);
+extern void clear_ships_on_screen(void);
+
char sea_battle(char id, int num_ships) {
/* These locals seem to eat too much stack and
cause weird behaviour, so they're static now. */
- static int ships_on_screen[10];
static int time,
s0,
ok,
@@ -1025,15 +1031,16 @@ char sea_battle(char id, int num_ships) {
char choice, flashctr, num_on_screen, status;
unsigned long amount, total;
- turbo = 0;
port_stat_dirty = 1;
+ ik = 1;
+ ok = 0;
+ turbo = 0;
orders = 0;
num_on_screen = 0;
+
time = get_time();
s0 = num_ships;
- ok = 0;
- ik = 1;
booty = (time / 4 * 1000 * num_ships) + randi()%1000 + 250;
if(would_overflow(cash, booty)) {
@@ -1088,7 +1095,7 @@ char sea_battle(char id, int num_ships) {
for(i = 0; i <= 9; i++) {
if (num_ships > num_on_screen) {
if (ships_on_screen[i] == 0) {
- if(!turbo) jsleep(5);
+ tjsleep(5);
ships_on_screen[i] = (randi() % ec) + 20;
draw_lorcha(i);
num_on_screen++;
@@ -1146,12 +1153,7 @@ char sea_battle(char id, int num_ships) {
set_orders();
for(i = 1; i <= guns; i++) {
- if ((ships_on_screen[0] == 0) && (ships_on_screen[1] == 0) &&
- (ships_on_screen[2] == 0) && (ships_on_screen[3] == 0) &&
- (ships_on_screen[4] == 0) && (ships_on_screen[5] == 0) &&
- (ships_on_screen[6] == 0) && (ships_on_screen[7] == 0) &&
- (ships_on_screen[8] == 0) && (ships_on_screen[9] == 0))
- {
+ if(!have_ships_on_screen()) {
static int j;
for (j = 0; j <= 9; j++) {
@@ -1176,9 +1178,9 @@ char sea_battle(char id, int num_ships) {
/* flash_lorcha must be called an even number of times
to leave the lorcha in an unflashed state after. */
- if(!turbo) for(flashctr = 0; flashctr < 6; flashctr++) {
+ for(flashctr = 0; flashctr < 6; flashctr++) {
flash_lorcha(targeted);
- jsleep(2);
+ tjsleep(2);
}
damage_lorcha(targeted);
@@ -1205,7 +1207,7 @@ char sea_battle(char id, int num_ships) {
if(num_ships == 0) {
i += guns;
} else {
- if(!turbo) jsleep(10);
+ tjsleep(10);
}
}
gotox0y(3);
@@ -1248,7 +1250,7 @@ char sea_battle(char id, int num_ships) {
num_on_screen--;
clear_lorcha(i);
- if(!turbo) jsleep(5);
+ tjsleep(5);
}
}
if(num_ships == num_on_screen) {
@@ -1419,7 +1421,7 @@ char sea_battle(char id, int num_ships) {
num_on_screen--;
clear_lorcha(i);
- jsleep(5);
+ tjsleep(5);
}
}
plus_or_space(num_ships > num_on_screen);