aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2016-01-23 16:50:57 -0500
committerB. Watson <yalhcru@gmail.com>2016-01-23 16:50:57 -0500
commit9203bbfed671b809d8c4c8e2d2dabe058b8bc249 (patch)
treeccf9ac05571323caccc27345d883ee84c1dba424
parent06536b454feb4a1db2548fd36c660ee1721a4a4d (diff)
downloadtaipan-9203bbfed671b809d8c4c8e2d2dabe058b8bc249.tar.gz
get_num() now handles values up to UINT32_MAX-1
-rw-r--r--taipan.c58
1 files changed, 26 insertions, 32 deletions
diff --git a/taipan.c b/taipan.c
index 9327a89..246c60e 100644
--- a/taipan.c
+++ b/taipan.c
@@ -13,8 +13,8 @@
#include "bignum.h"
#endif
-/* define this to use cc65's rand() instead of POKEY's RANDOM
- register. Disabled for now, maybe forever (pending testing) */
+/* define this to use POKEY's RANDOM register instead of cc65's
+ rand(). Disabled for now, maybe forever (pending testing) */
// #define POKEY_RANDOM
/**** These defines should be disabled for normal gameplay.
@@ -214,7 +214,7 @@ char wu_assassin = 0;
// void splash_intro(void);
#define get_one() agetc();
-long get_num(void);
+unsigned long get_num(void);
void name_firm(void);
void cash_or_guns(void);
void set_prices(void);
@@ -726,7 +726,7 @@ int sea_battle(int id, int num_ships) {
input,
status;
char choice, flashctr;
- long amount, total;
+ unsigned long amount, total;
port_stat_dirty = 1;
@@ -1026,7 +1026,7 @@ int sea_battle(int id, int num_ships) {
cputs("How much, Taipan? ");
amount = get_num();
- if((hold_[choice] > 0) && ((amount == -1) || (amount > hold_[choice])))
+ if((hold_[choice] > 0) && ((amount == UINT32_MAX) || (amount > hold_[choice])))
{
amount = hold_[choice];
}
@@ -1266,7 +1266,7 @@ int sea_battle(int id, int num_ships) {
}
/* TODO: rewrite in asm. Maybe. */
-long get_num(void) {
+unsigned long get_num(void) {
unsigned char count = 0;
char input;
@@ -1281,7 +1281,7 @@ long get_num(void) {
num_buf[count] = '\0';
count--;
} else if(input == 'a') {
- if(!count) return -1;
+ if(!count) return UINT32_MAX;
} else if(input == 'k' || input == 'm') {
char i;
for(i = 0; i < (input == 'k' ? 3 : 6); i++) {
@@ -1302,7 +1302,7 @@ long get_num(void) {
}
cursor(0);
num_buf[count] = '\0';
- return strtol(num_buf, (char **)NULL, 10);
+ return strtoul(num_buf, (char **)NULL, 10);
}
/* TODO: rewrite in asm */
@@ -1569,7 +1569,7 @@ void mchenry(void)
if(choice == 'y') {
static int percent, time;
- static long br, repair_price, amount;
+ static unsigned long br, repair_price, amount;
// int percent = ((float) damage / capacity) * 100,
percent = (damage * 100L / capacity);
// time = ((year - 1860) * 12) + month;
@@ -1598,7 +1598,7 @@ void mchenry(void)
for (;;) {
gotoxy(24, 21);
amount = get_num();
- if(amount == -1) {
+ if(amount == UINT32_MAX) {
if(cash > repair_price)
amount = repair_price;
else
@@ -1854,7 +1854,7 @@ void transfer(void)
a few bytes of code... but it makes the code a little
bigger instead! */
int i, in_use;
- long amount = 0;
+ unsigned long amount = 0;
if ((hkw_[0] == 0) && (hold_[0] == 0) &&
(hkw_[1] == 0) && (hold_[1] == 0) &&
(hkw_[2] == 0) && (hold_[2] == 0) &&
@@ -1881,7 +1881,7 @@ void transfer(void)
cputs(" shall I move\r\nto the warehouse, Taipan? ");
amount = get_num();
- if (amount == -1)
+ if (amount == UINT32_MAX)
{
amount = hold_[i];
}
@@ -1932,7 +1932,7 @@ void transfer(void)
cputs(" shall I move\r\naboard ship, Taipan? ");
amount = get_num();
- if (amount == -1)
+ if (amount == UINT32_MAX)
{
amount = hkw_[i];
}
@@ -2354,7 +2354,7 @@ void elder_brother_wu(void)
{
int choice = 0;
- long wu = 0;
+ unsigned long wu = 0;
compradores_report();
cputs("Do you have business with Elder Brother\r\n");
@@ -2431,7 +2431,7 @@ void elder_brother_wu(void)
cputs("him? ");
wu = get_num();
- if (wu == -1)
+ if (wu == UINT32_MAX)
{
wu = cash;
}
@@ -2464,7 +2464,7 @@ void elder_brother_wu(void)
cputs("borrow? ");
wu = get_num();
- if(wu == -1)
+ if(wu == UINT32_MAX)
{
wu = (cash * 2);
}
@@ -2684,13 +2684,8 @@ void name_firm(void) {
}
void buy(void) {
- /* see comment in fancy_numbers for why this is static */
- // static char space[5];
-
- int choice = 0;
-
- long afford,
- amount;
+ int choice = 0;
+ unsigned long afford, amount;
gotoxy(0, 22);
clrtobot();
@@ -2754,7 +2749,7 @@ void buy(void) {
cputs("I buy, Taipan: ");
amount = get_num();
- if(amount == -1) {
+ if(amount == UINT32_MAX) {
amount = afford;
}
if(amount <= afford) {
@@ -2770,9 +2765,8 @@ void buy(void) {
}
void sell(void) {
- int choice = 0;
-
- long amount;
+ int choice = 0;
+ unsigned long amount;
gotoxy(0, 22);
clrtobot();
@@ -2816,7 +2810,7 @@ void sell(void) {
amount = get_num();
- if (amount == -1)
+ if (amount == UINT32_MAX)
{
amount = hold_[choice];
}
@@ -2854,7 +2848,7 @@ void too_much_cash(void) {
void visit_bank(void)
{
- long amount = 0;
+ unsigned long amount = 0;
#ifdef BIGNUM
bignum(bigamt);
bignum(biglimit);
@@ -2867,7 +2861,7 @@ void visit_bank(void)
cputs("How much will you deposit? ");
amount = get_num();
- if (amount == -1)
+ if (amount == UINT32_MAX)
{
amount = cash;
}
@@ -2894,7 +2888,7 @@ void visit_bank(void)
amount = get_num();
#ifdef BIGNUM
- if(amount == -1) {
+ if(amount == UINT32_MAX) {
// memcpy(bigamt, bank, 6);
big_copy(bigamt, bank);
} else {
@@ -2930,7 +2924,7 @@ void visit_bank(void)
break;
}
#else
- if (amount == -1)
+ if (amount == UINT32_MAX)
{
amount = bank;
}