aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2016-02-19 06:43:11 -0500
committerB. Watson <yalhcru@gmail.com>2016-02-19 06:43:11 -0500
commit08fd9af5a9247f5c47b926259ed45cf6a437e67d (patch)
tree5b1b9baf7da562d74493121caa71bc64619b3ea4
parent53c1088fff0e8c8730622449dc863bbab938801c (diff)
downloadtaipan-08fd9af5a9247f5c47b926259ed45cf6a437e67d.tar.gz
save a byte in timed_getch, add conio doc
-rw-r--r--conio/README15
-rw-r--r--timed_getch.s23
2 files changed, 27 insertions, 11 deletions
diff --git a/conio/README b/conio/README
index d2ba1c7..bfe8187 100644
--- a/conio/README
+++ b/conio/README
@@ -1 +1,16 @@
This is a modified conio. It doesn't draw a cursor at all.
+
+More particularly, the standard cc65 conio always draws a cursor, whether
+the cursor is enabled or not. When it's disabled, the cursor is drawn
+as a space character.
+
+Benefits of doing this:
+
+- Faster and smoother screen updates
+- Slightly smaller code (20-30 bytes)
+- No more "cursor ghosts" at timed prompts
+- No need for a hide_cursor() function
+
+Disadvantage: Have to draw the cursor myself when needed. It turns out
+that only agetc() needs to do this, so not a big deal. Also had to
+add an agetc_no_cursor() for timed_getch() to use.
diff --git a/timed_getch.s b/timed_getch.s
index c996438..40a2722 100644
--- a/timed_getch.s
+++ b/timed_getch.s
@@ -38,11 +38,16 @@ _timed_getch:
lda #$2c ; $012c jiffies = 5 sec (NTSC) or 6 sec (PAL)
ldx #$01
jsr _set_jiffy_timer
+
@wait4key:
lda CDTMV3 ; has timer counted down to 0?
ora CDTMV3+1
- beq @done ; yes, return(0)
- lda CH ; no, check for a keypress
+ bne @timer_running
+ tax ; timer expired, return(0), A is already 0 here
+ rts
+
+@timer_running:
+ lda CH ; no, check for a keypress
; ...but don't let the capslock or inverse keys count
; as a keypress, here.
@@ -54,13 +59,7 @@ _timed_getch:
cmp #$27 ; inverse (atari) key
beq @wait4key
- jmp _agetc_no_cursor ; user hit a key, read it.
-
-@done:
- ;lda #$00 ; return(0), A is already 0 here
- tax
- rts
-
+ ; user hit a key, handle it. but don't print a cursor.
_agetc_no_cursor:
jsr _cgetc
jmp finish_agetc
@@ -71,12 +70,14 @@ _agetc_no_cursor:
; (such as clear, delete, escape) are replaced with a space.
; extern unsigned char agetc(void);
_agetc:
- lda #$80 ; inverse space
+ ; show the user a cursor
+ lda #$80 ; inverse space (putchar uses screen codes)
jsr putchar
jsr _cgetc ; get ATASCII code of keypress
-
pha
+
+ ; get rid of the cursor
lda #$00 ; space
jsr putchar
pla