aboutsummaryrefslogtreecommitdiff
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
parentb2f7604ac51db075201ea0aa40d002d3d5e7e071 (diff)
downloadtaipan-3abf7993ce2d2deb1c0596f3404b2bfa27324564.tar.gz
make the cursor behave *much* better, via custom conio function
-rw-r--r--Makefile11
-rw-r--r--conio/Makefile12
-rw-r--r--conio/README1
-rw-r--r--conio/cgetc.s31
-rw-r--r--conio/chline.s32
-rw-r--r--conio/clrscr.s35
-rw-r--r--conio/cputc.s95
-rw-r--r--conio/cputs.s36
-rw-r--r--conio/cvline.s38
-rw-r--r--conio/gotox.s14
-rw-r--r--conio/gotoxy.s18
-rw-r--r--conio/gotoy.s12
-rw-r--r--conio/revers.s28
-rw-r--r--conio/wherex.s13
-rw-r--r--conio/wherey.s13
-rw-r--r--console.s16
-rw-r--r--taipan.c50
-rw-r--r--timed_getch.s33
18 files changed, 449 insertions, 39 deletions
diff --git a/Makefile b/Makefile
index 6707ee1..f1dae80 100644
--- a/Makefile
+++ b/Makefile
@@ -100,6 +100,7 @@ XEX=taipan.xex
TAIMAIN_HDRS=sounds.h
TAIMAIN_C_SRC=taipan.c strtonum.c
TAIMAIN_ASM_SRC=rand.s draw_lorcha.s timed_getch.s portstat.s console.s ultostr.s soundasm.s explosion.s
+TAIMAIN_LIBS=conio/conio.lib
# Comment these lines out to build without big number support.
# This will stop being possible at some point.
@@ -182,6 +183,8 @@ mydos: all
rm -f TAIPAN
atari800 -nopatch mydos.atr
+conio/conio.lib:
+ $(MAKE) -C conio
# The game binary is a multi-part binary load file. This rule
# depends on all the pieces, and just concatenates them. We used
@@ -238,8 +241,8 @@ help.dat: help.txt text2screen.pl
# The main executable. All the C and asm code goes here, except the init
# segment in newtitle.s.
-taimain.xex: $(TAIMAIN_C_SRC) $(TAIMAIN_ASM_SRC) $(TAIMAIN_HDRS) $(BIGNUM_SRC) $(BIGNUM_HDRS)
- cl65 -m taipan.map $(CFLAGS) $(BIGNUM_CFLAGS) -o taimain.xex $(TAIMAIN_C_SRC) $(TAIMAIN_ASM_SRC) $(BIGNUM_SRC)
+taimain.xex: $(TAIMAIN_C_SRC) $(TAIMAIN_ASM_SRC) $(TAIMAIN_HDRS) $(BIGNUM_SRC) $(BIGNUM_HDRS) $(TAIMAIN_LIBS)
+ cl65 -m taipan.map $(CFLAGS) $(BIGNUM_CFLAGS) -o taimain.xex $(TAIMAIN_C_SRC) $(TAIMAIN_ASM_SRC) $(BIGNUM_SRC) $(TAIMAIN_LIBS)
#cl65 --mapfile taipan.map $(CFLAGS) -o taimain.xex taipan.c sounds.c rand.s draw_lorcha.s timed_getch.s jsleep.s portstat.s console.s
@@ -312,7 +315,7 @@ mkcart: mkcart.c
# rm -f taimain.xex
romable_taimain.raw: $(TAIMAIN_C_SRC) $(TAIMAIN_ASM_SRC) $(TAIMAIN_HDRS) $(BIGNUM_SRC) $(BIGNUM_HDRS)
- cl65 --config cartbank3.cfg -m taipan.map -t atari -T -I. -L. -DFONT_ADDR=0x9c00 --start-addr 0x3ff -Wl -D__STACKSIZE__=0x200 -O -Wl -D__SYSTEM_CHECK__=1 -Wl -D__AUTOSTART__=1 -Wl -D__EXEHDR__=1 -DCART_TARGET=1 --asm-define CART_TARGET=1 -DBIGNUM=BIGFLOAT -o romable_taimain.raw.in $(TAIMAIN_C_SRC) $(TAIMAIN_ASM_SRC) $(BIGNUM_SRC)
+ cl65 --config cartbank3.cfg -m taipan.map -t atari -T -I. -L. -DFONT_ADDR=0x9c00 --start-addr 0x3ff -Wl -D__STACKSIZE__=0x200 -O -Wl -D__SYSTEM_CHECK__=1 -Wl -D__AUTOSTART__=1 -Wl -D__EXEHDR__=1 -DCART_TARGET=1 --asm-define CART_TARGET=1 -DBIGNUM=BIGFLOAT -o romable_taimain.raw.in $(TAIMAIN_C_SRC) $(TAIMAIN_ASM_SRC) $(BIGNUM_SRC) $(TAIMAIN_LIBS)
tail -c+2 romable_taimain.raw.in > romable_taimain.raw
rm -f romable_taimain.raw.in
@@ -381,7 +384,7 @@ testcart: cart
# Obligatory clean and distclean rules.
clean:
- rm -f *.o *.lst convfont mkcart gzip2deflate *.xex AUTORUN.SYS taipan.atr dos2.atr mydos.atr fenders.atr ver.dat help.dat tags cartmsg.dat splitrom.raw.* taipan.rom taipan.cart bank[0-9] fill256 blankbank romable_taimain.raw splitrom.raw.* comptitle.s comptitle.dat
+ rm -f *.o *.lst convfont mkcart gzip2deflate *.xex AUTORUN.SYS taipan.atr dos2.atr mydos.atr fenders.atr ver.dat help.dat tags cartmsg.dat splitrom.raw.* taipan.rom taipan.cart bank[0-9] fill256 blankbank romable_taimain.raw splitrom.raw.* comptitle.s comptitle.dat conio/*.o conio/*.lib
distclean: clean
rm -f *~ core .*.swp 1.* 2.* 1 2 3 map map.* *.map a b c foo bar baz
diff --git a/conio/Makefile b/conio/Makefile
new file mode 100644
index 0000000..4679d31
--- /dev/null
+++ b/conio/Makefile
@@ -0,0 +1,12 @@
+all: conio.lib
+
+OBJS=cgetc.o chline.o clrscr.o cputc.o cputs.o cvline.o gotox.o gotoxy.o gotoy.o revers.o wherex.o wherey.o
+
+conio.lib: $(OBJS)
+ ar65 a conio.lib *.o
+
+%.o: %.s
+ cl65 -O -t atari -c $<
+
+clean:
+ rm -f *.o
diff --git a/conio/README b/conio/README
new file mode 100644
index 0000000..d2ba1c7
--- /dev/null
+++ b/conio/README
@@ -0,0 +1 @@
+This is a modified conio. It doesn't draw a cursor at all.
diff --git a/conio/cgetc.s b/conio/cgetc.s
new file mode 100644
index 0000000..d1ae705
--- /dev/null
+++ b/conio/cgetc.s
@@ -0,0 +1,31 @@
+;
+; Christian Groessler, November-2002
+;
+; get a char from the keyboard
+; char cgetc(void)
+;
+
+ .include "atari.inc"
+ .export _cgetc
+ .import KEYBDV_handler
+ .import cursor,mul40
+
+_cgetc:
+ lda #12
+ sta ICAX1Z ; fix problems with direct call to KEYBDV
+.ifdef __ATARIXL__
+ jsr KEYBDV_handler
+.else
+ jsr @1
+.endif
+ ldx #0
+ rts
+
+.ifndef __ATARIXL__
+@1: lda KEYBDV+5
+ pha
+ lda KEYBDV+4
+ pha
+ rts
+.endif
+
diff --git a/conio/chline.s b/conio/chline.s
new file mode 100644
index 0000000..2ad7fed
--- /dev/null
+++ b/conio/chline.s
@@ -0,0 +1,32 @@
+;
+; Ullrich von Bassewitz, 08.08.1998
+;
+; void chlinexy (unsigned char x, unsigned char y, unsigned char length);
+; void chline (unsigned char length);
+;
+
+ .export _chlinexy, _chline
+ .import popa, _gotoxy, cputdirect
+ .importzp tmp1
+
+.ifdef __ATARI5200__
+CHRCODE = 14
+.else
+CHRCODE = $12+64
+.endif
+
+_chlinexy:
+ pha ; Save the length
+ jsr popa ; Get y
+ jsr _gotoxy ; Call this one, will pop params
+ pla ; Restore the length
+
+_chline:
+ cmp #0 ; Is the length zero?
+ beq L9 ; Jump if done
+ sta tmp1
+L1: lda #CHRCODE ; Horizontal line, screen code
+ jsr cputdirect ; Direct output
+ dec tmp1
+ bne L1
+L9: rts
diff --git a/conio/clrscr.s b/conio/clrscr.s
new file mode 100644
index 0000000..5881aea
--- /dev/null
+++ b/conio/clrscr.s
@@ -0,0 +1,35 @@
+;
+; Christian Groessler, Apr-2000
+;
+; void clrscr (void);
+;
+
+ .export _clrscr
+ .include "atari.inc"
+ .importzp ptr1
+
+SCRSIZE = 960 ; 40x24: size of default atari screen
+
+_clrscr:lda SAVMSC ; screen memory
+ sta ptr1
+ lda SAVMSC+1
+ clc
+ adc #>(SCRSIZE-1)
+ sta ptr1+1
+ lda #0 ; screen code of space char
+ sta OLDCHR
+ ldy #<(SCRSIZE-1)
+ ldx #>(SCRSIZE-1)
+_clr1: sta (ptr1),y
+ dey
+ bne _clr1
+ sta (ptr1),y
+ dex
+ bmi done
+ dec ptr1+1
+ dey
+ jmp _clr1
+
+done: sta COLCRS
+ sta ROWCRS
+ rts
diff --git a/conio/cputc.s b/conio/cputc.s
new file mode 100644
index 0000000..5955b42
--- /dev/null
+++ b/conio/cputc.s
@@ -0,0 +1,95 @@
+;
+; Mark Keates, Christian Groessler
+;
+; void cputcxy (unsigned char x, unsigned char y, char c);
+; void cputc (char c);
+;
+
+ .export _cputcxy, _cputc
+ .export plot, cputdirect, putchar
+ .import popa, _gotoxy, mul40
+ .importzp tmp4,ptr4
+ .import _revflag
+
+ .include "atari.inc"
+
+_cputcxy:
+ pha ; Save C
+ jsr popa ; Get Y
+ jsr _gotoxy ; Set cursor, drop x
+ pla ; Restore C
+
+_cputc:
+ cmp #$0D ; CR
+ bne L4
+ lda #0
+ sta COLCRS
+ beq plot ; return
+
+L4: cmp #$0A ; LF
+ beq newline
+ cmp #ATEOL ; Atari-EOL?
+ beq newline
+
+ tay
+ rol a
+ rol a
+ rol a
+ rol a
+ and #3
+ tax
+ tya
+ and #$9f
+ ora ataint,x
+
+cputdirect: ; accepts screen code
+ jsr putchar
+
+; advance cursor
+ inc COLCRS
+ lda COLCRS
+ cmp #40
+ bcc plot
+ lda #0
+ sta COLCRS
+
+ .export newline
+newline:
+ inc ROWCRS
+ lda ROWCRS
+ cmp #24
+ bne plot
+ lda #0
+ sta ROWCRS
+plot:
+ ldy COLCRS
+ ldx ROWCRS
+ rts
+
+; update screen
+; if called directly, putchar prints the screen code in A
+; without updating the cursor position.
+putchar:
+ pha ; save char
+
+ ldy #0
+
+ lda ROWCRS
+ jsr mul40 ; destroys tmp4
+ clc
+ adc SAVMSC ; add start of screen memory
+ sta ptr4
+ txa
+ adc SAVMSC+1
+ sta ptr4+1
+ pla ; get char again
+
+ ora _revflag
+ sta OLDCHR
+
+ ldy COLCRS
+ sta (ptr4),y
+ rts
+
+ .rodata
+ataint: .byte 64,0,32,96
diff --git a/conio/cputs.s b/conio/cputs.s
new file mode 100644
index 0000000..13cf847
--- /dev/null
+++ b/conio/cputs.s
@@ -0,0 +1,36 @@
+;
+; Ullrich von Bassewitz, 06.08.1998
+;
+; void cputsxy (unsigned char x, unsigned char y, char* s);
+; void cputs (char* s);
+;
+
+ .export _cputsxy, _cputs
+ .import popa, _gotoxy, _cputc
+ .importzp ptr1, tmp1
+
+_cputsxy:
+ sta ptr1 ; Save s for later
+ stx ptr1+1
+ jsr popa ; Get Y
+ jsr _gotoxy ; Set cursor, pop x
+ jmp L0 ; Same as cputs...
+
+_cputs: sta ptr1 ; Save s
+ stx ptr1+1
+L0: ldy #0
+L1: lda (ptr1),y
+ beq L9 ; Jump if done
+ iny
+ sty tmp1 ; Save offset
+ jsr _cputc ; Output char, advance cursor
+ ldy tmp1 ; Get offset
+ bne L1 ; Next char
+ inc ptr1+1 ; Bump high byte
+ bne L1
+
+; Done
+
+L9: rts
+
+
diff --git a/conio/cvline.s b/conio/cvline.s
new file mode 100644
index 0000000..7ff56c3
--- /dev/null
+++ b/conio/cvline.s
@@ -0,0 +1,38 @@
+;
+; Ullrich von Bassewitz, 08.08.1998
+;
+; void cvlinexy (unsigned char x, unsigned char y, unsigned char length);
+; void cvline (unsigned char length);
+;
+ .include "atari.inc"
+
+ .export _cvlinexy, _cvline
+ .import popa, _gotoxy, putchar
+ .importzp tmp1
+
+.ifdef __ATARI5200__
+CHRCODE = 1 ; exclamation mark
+.else
+CHRCODE = $7C ; Vertical bar
+.endif
+
+_cvlinexy:
+ pha ; Save the length
+ jsr popa ; Get y
+ jsr _gotoxy ; Call this one, will pop params
+ pla ; Restore the length and run into _cvline
+
+_cvline:
+ cmp #0 ; Is the length zero?
+ beq L9 ; Jump if done
+ sta tmp1
+L1: lda COLCRS
+ pha
+ lda #CHRCODE ; Vertical bar
+ jsr putchar ; Write, no cursor advance
+ pla
+ sta COLCRS
+ inc ROWCRS
+ dec tmp1
+ bne L1
+L9: rts
diff --git a/conio/gotox.s b/conio/gotox.s
new file mode 100644
index 0000000..f7c78b4
--- /dev/null
+++ b/conio/gotox.s
@@ -0,0 +1,14 @@
+;
+; Christian Groessler, 19-Feb-2000
+;
+; void gotox (unsigned char x);
+;
+
+ .include "atari.inc"
+ .export _gotox
+
+_gotox:
+ sta COLCRS ; Set X
+ lda #0
+ sta COLCRS+1
+ rts
diff --git a/conio/gotoxy.s b/conio/gotoxy.s
new file mode 100644
index 0000000..ca91b07
--- /dev/null
+++ b/conio/gotoxy.s
@@ -0,0 +1,18 @@
+;
+; Ullrich von Bassewitz, 06.08.1998
+;
+; void gotoxy (unsigned char x, unsigned char y);
+;
+
+ .include "atari.inc"
+
+ .export _gotoxy
+ .import popa
+
+_gotoxy: ; Set the cursor position
+ sta ROWCRS ; Set Y
+ jsr popa ; Get X
+ sta COLCRS ; Set X
+ lda #0
+ sta COLCRS+1 ;
+ rts
diff --git a/conio/gotoy.s b/conio/gotoy.s
new file mode 100644
index 0000000..1e2479a
--- /dev/null
+++ b/conio/gotoy.s
@@ -0,0 +1,12 @@
+;
+; Christian Groessler, 19-Feb-2000
+;
+; void gotoy (unsigned char y);
+;
+
+ .include "atari.inc"
+ .export _gotoy
+
+_gotoy:
+ sta ROWCRS ; Set Y
+ rts
diff --git a/conio/revers.s b/conio/revers.s
new file mode 100644
index 0000000..7195039
--- /dev/null
+++ b/conio/revers.s
@@ -0,0 +1,28 @@
+;
+; Ullrich von Bassewitz, 07.08.1998
+;
+; unsigned char revers (unsigned char onoff);
+;
+ .include "atari.inc"
+
+ .export _revers
+ .export _revflag
+
+_revers:
+ ldx #$00 ; Assume revers off
+ tay ; Test onoff
+ beq L1 ; Jump if off
+ ldx #$80 ; Load on value
+L1: ldy #$00 ; Assume old value is zero
+ lda _revflag ; Load old value
+ stx _revflag ; Set new value
+ beq L2 ; Jump if old value zero
+ iny ; Make old value = 1
+L2: ldx #$00 ; Load high byte of result
+ tya ; Load low byte, set CC
+ rts
+
+ .bss
+
+_revflag:
+ .res 1
diff --git a/conio/wherex.s b/conio/wherex.s
new file mode 100644
index 0000000..1b72199
--- /dev/null
+++ b/conio/wherex.s
@@ -0,0 +1,13 @@
+;
+; Carsten Strotmann, 30.12.2002
+;
+; unsigned char wherex (void);
+;
+
+ .export _wherex
+ .include "atari.inc"
+
+_wherex:
+ lda COLCRS
+ ldx #0
+ rts
diff --git a/conio/wherey.s b/conio/wherey.s
new file mode 100644
index 0000000..f391eec
--- /dev/null
+++ b/conio/wherey.s
@@ -0,0 +1,13 @@
+;
+; Carsten Strotmann, 30.12.2002
+;
+; unsigned char wherey (void);
+;
+
+ .export _wherey
+ .include "atari.inc"
+
+_wherey:
+ lda ROWCRS
+ ldx #0
+ rts
diff --git a/console.s b/console.s
index 7be2fb3..2ad5e58 100644
--- a/console.s
+++ b/console.s
@@ -1,7 +1,7 @@
.include "atari.inc"
- .export _clrtobot, _clrtoeol, _clrtoline, _cspaces
+ .export _clrtobot, _clrtoeol, _clrtoline, _cspaces, _cblank
.import mul40 ; from cc65's runtime
.importzp tmp3 ; ditto
@@ -80,3 +80,17 @@ _cspaces:
dec tmp3
bne @lp
rts
+
+_cblank:
+ tax
+ lda COLCRS
+ pha
+ lda ROWCRS
+ pha
+ txa
+ jsr _cspaces
+ pla
+ sta ROWCRS
+ pla
+ sta COLCRS
+ rts
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();
diff --git a/timed_getch.s b/timed_getch.s
index 510c885..c996438 100644
--- a/timed_getch.s
+++ b/timed_getch.s
@@ -1,7 +1,7 @@
.export _timed_getch, _set_jiffy_timer, _agetc, _numgetc
.export _yngetc, _lcgetc, _jsleep
- .import _cgetc, _cblank, _cursor, _rand
+ .import _cgetc, _cblank, putchar, _rand
.include "atari.inc"
@@ -54,30 +54,37 @@ _timed_getch:
cmp #$27 ; inverse (atari) key
beq @wait4key
- jmp _agetc ; user hit a key, read it.
+ jmp _agetc_no_cursor ; user hit a key, read it.
@done:
;lda #$00 ; return(0), A is already 0 here
tax
rts
+_agetc_no_cursor:
+ jsr _cgetc
+ jmp finish_agetc
+
; _agetc removes the inverse-video bit, and if
; a control key is pressed, it turns it into the non-control version
; (e.g. ^A = lowercase a). Keys that can't be mapped to regular ASCII
; (such as clear, delete, escape) are replaced with a space.
; extern unsigned char agetc(void);
_agetc:
- lda #1 ; show cursor
- jsr _cursor
- sta FR1+2 ; save old cursor status
- lda #1
- jsr _cblank
+ lda #$80 ; inverse space
+ jsr putchar
jsr _cgetc ; get ATASCII code of keypress
+ pha
+ lda #$00 ; space
+ jsr putchar
+ pla
+
+finish_agetc:
+ pha
; twitch the random bottle based on the low bit of
; the character entered.
- pha
and #$01
beq @nr
jsr _rand
@@ -107,11 +114,11 @@ notcontrol:
bcc ok ; (remember, $7e, backspace, was handled above)
lda #$20
ok:
- pha
- ldx #0
- lda FR1+2
- jsr _cursor
- pla
+; pha
+; ldx #0
+; lda FR1+2
+; jsr _cursor
+; pla
ldx #0
rts