aboutsummaryrefslogtreecommitdiff
path: root/taipan.c
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2016-01-06 01:55:41 -0500
committerB. Watson <yalhcru@gmail.com>2016-01-06 01:55:41 -0500
commitad615f1eb4febb59f5148ba356d9ad91dc72db09 (patch)
tree1ac19501a81295c9e7df255ef6196c63545cf7fa /taipan.c
parent78955cb3856cfc0115c7e2f2813132cc46c4fd23 (diff)
downloadtaipan-ad615f1eb4febb59f5148ba356d9ad91dc72db09.tar.gz
compressed title image, loads faster
Diffstat (limited to 'taipan.c')
-rw-r--r--taipan.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/taipan.c b/taipan.c
index 4792896..af755e4 100644
--- a/taipan.c
+++ b/taipan.c
@@ -43,11 +43,12 @@ extern unsigned char agetc(void);
/* wrapper for agetc(): lowercases letters */
extern unsigned char lcgetc(void);
-/* wrapper for agetc(): returns only numbers, enter, backspace */
+/* wrapper for agetc(): returns only numbers, a, enter, backspace */
extern unsigned char numgetc(void);
/* wrapper for agetc(): returns only y or n.
- dflt is 'y' 'n' to set the default answer, or 0 for no default. */
+ dflt is 'y' or 'n' to set the default answer if the user presses Enter,
+ or 0 for no default (waits until user presses either y or n) */
extern unsigned char __fastcall__ yngetc(char dflt);
/* sleep for j jiffies (no PAL adjustment at the moment) */
@@ -130,7 +131,7 @@ void cblank(unsigned char count) {
gotoxy(oldx, oldy);
}
-/* conio doesn't back up the cursor if you cputc(BS), it
+/* conio doesn't back up the cursor if you cputc(BKSP), it
prints the graphics character instead. Could use putchar(),
but using stdio links a bunch of extra support code. So: */
/* TODO: rewrite in asm */
@@ -139,6 +140,9 @@ void backspace() {
cblank(1);
}
+/* get an inventory item, return its index into items[].
+ 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;
for(;;) {
@@ -201,7 +205,7 @@ char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
char *st[] = { "Critical", " Poor", " Fair",
" Good", " Prime", "Perfect" };
-unsigned long cash = 0,
+unsigned long cash = 0,
bank = 0,
debt = 0,
booty = 0,
@@ -894,6 +898,9 @@ int sea_battle(int id, int num_ships) {
timed_getch(TMOUT_3S);
flushinp();
+ /* screen flash doesn't change the hue bit of
+ COLOR2 register, since we now support changing
+ it on the title screen. */
for(i = 0; i < 3; i++) {
unsigned char color = PEEK(710) & 0xf0;
POKE(710, color | 0x0c);
@@ -953,9 +960,11 @@ int sea_battle(int id, int num_ships) {
// 0 or 1: the intended result would just be 0 or 1 anyway.
newdamage = ((ed * i * id)/2) + (i / 2);
+ if(newdamage <= 0) newdamage = 1; // how the hell could this happen?
if(newdamage > 1)
newdamage = randi() % newdamage;
damage += newdamage;
+ if(damage > capacity) damage = capacity; /* just in case */
#ifdef DAMAGE_TEST
gotoxy(0, 23);
@@ -971,7 +980,6 @@ int sea_battle(int id, int num_ships) {
cgetc();
#endif
- if(damage > capacity) damage = capacity; /* just in case */
if((id == GENERIC) && (randi()%20 == 0)) {
return 2;
}
@@ -2743,7 +2751,9 @@ int main(void) {
{
// float fine = ((cash / 1.8) * ((float) randi() / RAND_MAX)) + 1;
// the 1.8 is now a 2
- unsigned long fine = randclamp(cash >> 1) + 1;
+ unsigned long fine = 0;
+ if(cash > 0)
+ fine = randclamp(cash >> 1) + 1;
hold += hold_[0];
hold_[0] = 0;