diff options
Diffstat (limited to 'taipan.c')
-rw-r--r-- | taipan.c | 80 |
1 files changed, 36 insertions, 44 deletions
@@ -2,6 +2,7 @@ #include <time.h> #include <stdlib.h> // #include <stdio.h> // finally got rid of it! +#include <ctype.h> #include <string.h> #include <peekpoke.h> @@ -55,53 +56,38 @@ extern void __fastcall__ jsleep(unsigned int j); extern unsigned int __fastcall__ randi(void); extern unsigned long __fastcall__ randl(void); -char port_stat_dirty = 1; +/* defined in portstat.s, this is the contents of PORTSTAT.DAT. + used to quickly redraw the port stats screen. + If ever PORTSTAT.DAT needs to be regenerated, use mkportstats.c */ extern const char *port_stat_screen; -/**** End of atari-specific stuff */ +/* boolean, whether or not port_stats() needs to redraw the + static parts of the port stats screen (by copying + port_stat_screen into screen RAM) */ +char port_stat_dirty = 1; -unsigned long randclamp(unsigned long clamp) { - return randl() % clamp; -} +/* asm curses/conio funcs from clrtobot.s. Old C versions moved to + oldcurses.c for reference. */ +extern void clrtobot(); +extern void clrtoeol(); -/* TODO: rewrite in asm */ -void clrtobot() { - unsigned char rows, cols, y, oldx, oldy; - oldx = wherex(); - oldy = wherey(); - screensize(&cols, &rows); - cclear(cols - wherex()); /* leaves cursor at start of next line */ - for(y = wherey(); y < rows; y++) - cclearxy(0, y, cols); - gotoxy(oldx, oldy); -} -/* TODO: rewrite in asm */ -void clrtoeol() { - unsigned char cols, rows, oldx, oldy; - oldx = wherex(); - oldy = wherey(); - screensize(&cols, &rows); - cclear(cols - wherex()); - gotoxy(oldx, oldy); -} +/**** End of atari-specific stuff */ -/* TODO: rewrite in asm */ -int lc(int a) { - if(a >= 'A' && a <= 'Z') a ^= 0x20; - return a; +unsigned long randclamp(unsigned long clamp) { + return randl() % clamp; } -/* TODO: rewrite in asm */ /* wrapper for cgetc() that returns letters as lowercase only (and everything else normally). Avoids a bunch of reduntant if(foo == 'A' || foo == 'a') tests. */ -int lcgetch() { - return lc(cgetc()); +int lcgetc() { + return tolower(cgetc()); } /* print 'count' spaces, but leave the cursor where it was. doesn't work if the cursor wraps to the next line! + TODO: rewrite in asm. */ void cblank(unsigned char count) { char oldx = wherex(); @@ -121,7 +107,7 @@ void backspace() { #define GENERIC 1 #define LI_YUEN 2 -void splash_intro(void); +// void splash_intro(void); int get_one(void); unsigned long get_num(int maxlen); void name_firm(void); @@ -312,8 +298,7 @@ void new_gun(void) time = ((year - 1860) * 12) + month; amount = randi()%(1000 * (time + 5) / 6) + 500; - if ((cash < amount) || (hold < 10)) - { + if((cash < amount) || (hold < 10)) { return; } @@ -523,7 +508,7 @@ int sea_battle(int id, int num_ships) { (input != 'r') && (input != 't')) { - input = lcgetch(); + input = lcgetc(); } gotoxy(0, 3); clrtoeol(); @@ -716,7 +701,7 @@ int sea_battle(int id, int num_ships) { (choice != 'g') && (choice != '*')) { - choice = lc(get_one()); + choice = tolower(get_one()); } if(choice == 'o') { @@ -962,7 +947,7 @@ int get_one(void) // is printed... can't use cputc() here as it escapes the // character (prints graphics char instead of actually backspacing) - /* new: */ + /* these 2 lines make the cursor visible */ cursor(1); cblank(1); @@ -971,7 +956,6 @@ int get_one(void) if (((input == BKSP) || (input == 127)) && (character == 0)) { } else if ((input == BKSP) || (input == 127)) { - // putchar(BKSP); backspace(); character--; } else if (character >= 1) { @@ -1008,7 +992,6 @@ unsigned long get_num(int maxlen) if (((input == BKSP) || (input == 127)) && (character == 0)) { } else if ((input == BKSP) || (input == 127)) { - // putchar(BKSP); backspace(); number[character] = '\0'; character--; @@ -1235,13 +1218,13 @@ void port_stats(void) revers(0); gotoxy(29, 12); + clrtoeol(); i = status / 20; if (i < 2) { revers(1); } cputs(st[i]); cputc(':'); - cblank(3); cprintulong(status); revers(0); @@ -1265,6 +1248,7 @@ void port_stats(void) that I can draw a nice ATASCII trading ship. But for now I'll just draw 6 of the lorchas. */ +#if 0 void splash_intro(void) { int i; @@ -1290,6 +1274,7 @@ void splash_intro(void) flushinp(); return; } +#endif void mchenry(void) { @@ -2205,7 +2190,14 @@ void name_firm(void) int input, character = 0; + cursor(0); clrscr(); + gotoxy(0,23); +#ifdef VERSION + cputs(VERSION); +#else + cputs("(no version info)"); +#endif chlinexy(1, 7, 38); chlinexy(1, 16, 38); @@ -2271,7 +2263,7 @@ void buy(void) cputs("What do you wish me to buy, Taipan? "); /* TODO: buy() sell() and throwing cargo, common code in get_item() */ - choice = lc(get_one()); + choice = tolower(get_one()); if(choice == 'o') { choice = 0; break; @@ -2364,7 +2356,7 @@ void sell(void) { cputs("What do you wish me to sell, Taipan? "); /* TODO: buy() sell() and throwing cargo, common code in get_item() */ - choice = lc(get_one()); + choice = tolower(get_one()); if(choice == 'o') { choice = 0; break; @@ -2491,7 +2483,7 @@ int main(void) { atari_text_setup(); initrand(); - splash_intro(); + // splash_intro(); name_firm(); cash_or_guns(); set_prices(); |