aboutsummaryrefslogtreecommitdiff
path: root/taipan.c
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2016-02-17 23:47:59 -0500
committerB. Watson <yalhcru@gmail.com>2016-02-17 23:47:59 -0500
commit3abf7993ce2d2deb1c0596f3404b2bfa27324564 (patch)
tree67b4cb01fb3b303a14edf41f6ffa56243d33af3a /taipan.c
parentb2f7604ac51db075201ea0aa40d002d3d5e7e071 (diff)
downloadtaipan-3abf7993ce2d2deb1c0596f3404b2bfa27324564.tar.gz
make the cursor behave *much* better, via custom conio function
Diffstat (limited to 'taipan.c')
-rw-r--r--taipan.c50
1 files changed, 29 insertions, 21 deletions
diff --git a/taipan.c b/taipan.c
index 2bbe84a..042733e 100644
--- a/taipan.c
+++ b/taipan.c
@@ -1,9 +1,14 @@
-// TODO: replace conio with coffio
+/* Taipan! for Atari 8-bit. Ported from the Linux/curses version,
+ which was based on the original Applesoft BASIC version. */
-#include <conio.h>
-#include <stdlib.h> /* rand() srand() exit() */
-#include <stdint.h> /* UINT32_MAX */
-#include <peekpoke.h> /* PEEK() PEEKW() POKE() POKEW() */
+#include <conio.h> /* cputc() wherex() wherey() gotoxy()
+ gotox() cputs() revers() clrscr()
+ chline() chlinexy() cvlinexy() */
+/* we're actually using a locally modified conio, see conio/README */
+
+#include <stdlib.h> /* rand() srand() exit() */
+#include <stdint.h> /* UINT32_MAX */
+#include <peekpoke.h> /* PEEK() PEEKW() POKE() POKEW() */
#include "sounds.h"
@@ -73,6 +78,8 @@ extern void __fastcall__ jsleep(unsigned int j);
/* flash screen when we're hit in combat */
extern void explosion(void);
+extern void __fastcall__ cblank(unsigned char count);
+
/* Atari-specific random number functions from rand.s.
Non-Atari platforms can probably just:
#define initrand() _randomize()
@@ -166,12 +173,14 @@ void cputc_s(void) {
/* print 'count' spaces, but leave the cursor where it was.
TODO: rewrite in asm. */
+/*
void cblank(unsigned char count) {
char oldx = wherex();
char oldy = wherey();
cspaces(count);
gotoxy(oldx, oldy);
}
+*/
/* conio doesn't back up the cursor if you cputc(BKSP), it
prints the graphics character instead. Could use putchar(),
@@ -751,17 +760,19 @@ void justify_int(unsigned int num) {
cprintulong(num);
}
+/*
void hide_cursor() {
gotoxy(0,23);
cspace();
}
+*/
void update_guns() {
revers(1);
gotoxy(31, 1);
justify_int(guns);
revers(0);
- hide_cursor();
+ // hide_cursor();
}
void fight_stats(int ships, int orders) {
@@ -794,7 +805,7 @@ void fight_stats(int ships, int orders) {
cputs("Throw Cargo");
*/
- hide_cursor();
+ // hide_cursor();
}
/* print an inverse video plus if there are offscreen ships,
@@ -802,7 +813,7 @@ void fight_stats(int ships, int orders) {
void plus_or_space(unsigned char b) {
gotoxy(39, 15);
cputc(b ? 0xab : ' ');
- hide_cursor();
+ // hide_cursor();
}
char set_orders(char orders) {
@@ -1228,7 +1239,7 @@ int sea_battle(int id, int num_ships) {
cprint_taipan_bang();
timed_getch();
- hide_cursor();
+ // hide_cursor();
explosion();
fight_stats(num_ships, orders);
@@ -1386,11 +1397,9 @@ void cash_or_guns(void)
cprint_Do_you_want();
cputs("to start . . .\r\n\n");
cputs(" 1) With cash (and a debt)\r\n\n");
- // cputs(" -- or --\r\n\n");
cspaces(16);
cputs("-- or --\r\n\n");
cputs(" 2) With five guns and no cash\r\n");
- // cputs(" (But no debt!)\r\n");
cspaces(16);
cputs("(But no debt!)\r\n");
@@ -1630,7 +1639,7 @@ void port_stats(void)
}
void mchenry(void) {
- static char choice;
+ // static char choice;
compradores_report();
cprint_taipan_comma();
@@ -1639,9 +1648,9 @@ void mchenry(void) {
"ye've a wee bit of damage to yer ship.'\r\n"
"Will ye be wanting repairs? ");
- choice = yngetc('y');
+ // choice = yngetc('y');
- if(choice == 'y') {
+ if(yngetc('y') == 'y') {
static int percent, time;
static unsigned long br, repair_price, amount;
// int percent = ((float) damage / capacity) * 100,
@@ -2384,7 +2393,6 @@ void quit(void)
void li_yuen_extortion(void) {
// int time = ((year - 1860) * 12) + month;
int time = get_time();
- unsigned char choice;
/*
float i = 1.8,
@@ -2409,9 +2417,8 @@ void li_yuen_extortion(void) {
cputs(" asks ");
cprintfancy(amount);
cputs(" in donation\r\nto the temple of Tin Hau, the Sea\r\nGoddess. Will you pay? ");
- choice = yngetc(0);
- if(choice == 'y') {
+ if(yngetc(0) == 'y') {
if(amount <= cash) {
cash -= amount;
li = 1;
@@ -2427,12 +2434,12 @@ void li_yuen_extortion(void) {
cprint_Do_you_want();
cprint_elder_brother_wu();
cputs("to make up\r\nthe difference for you? ");
- choice = yngetc(0);;
- clear_msg_window();
+ // clear_msg_window();
// gotoxy(0, 18);
// clrtobot();
- if(choice == 'y') {
+ if(yngetc(0) == 'y') {
+ clear_msg_window();
amount -= cash;
debt += amount;
cash = 0;
@@ -2444,6 +2451,7 @@ void li_yuen_extortion(void) {
"your cash on hand and added the same\r\n"
"amount to your debt.\r\n");
} else {
+ clear_msg_window();
cash = 0;
cputs("Very well. ");
cprint_elder_brother_wu();
@@ -3087,7 +3095,7 @@ int main(void) {
#endif
atari_text_setup();
- cursor(0);
+ // cursor(0);
#ifdef BIGNUM_TEST
bignum_test();