aboutsummaryrefslogtreecommitdiff
path: root/clrtobot.s
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2016-01-01 07:35:12 -0500
committerB. Watson <yalhcru@gmail.com>2016-01-01 07:35:12 -0500
commiteb26be6238c9d9254dbd7b01844e9f0b2a674a93 (patch)
tree138de65cc9c36c791a3aa476dcb1ee44608361b4 /clrtobot.s
parent745aa81b83b9cea5468210bf65601fd3a1090787 (diff)
downloadtaipan-eb26be6238c9d9254dbd7b01844e9f0b2a674a93.tar.gz
graphical title, Makefile clean/documentation
Diffstat (limited to 'clrtobot.s')
-rw-r--r--clrtobot.s66
1 files changed, 66 insertions, 0 deletions
diff --git a/clrtobot.s b/clrtobot.s
new file mode 100644
index 0000000..72f97e5
--- /dev/null
+++ b/clrtobot.s
@@ -0,0 +1,66 @@
+
+
+ .include "atari.inc"
+ .export _clrtobot, _clrtoeol, _clrtoline
+
+ .import mul40 ; from cc65's runtime
+ .importzp tmp3 ; ditto
+ .import bump_destptr ; these two are
+ .importzp destptr ; from draw_lorcha.s
+
+; void clrtobot(void);
+; void clrtoeol(void);
+; void clrtoline(unsigned char line);
+
+; this stuff doesn't disturb conio's (and the OS's) idea of the
+; current cursor position. It's *way* faster than writing them in
+; C in terms of cclear() (which uses one cputc() call per blank).
+
+_clrtobot: ; same as clrtoline(24);
+ lda #24
+ bne _clrtoline
+
+_clrtoeol:
+ lda ROWCRS
+ ; fall through to _clrtoline
+
+_clrtoline:
+ sta tmp3 ; stash our arg
+ lda #0
+ sta OLDCHR ; stop conio from redrawing stuff after we clear it
+
+ ; setup destptr to start of current line, NOT
+ ; current cursor position.
+ lda ROWCRS
+ jsr mul40 ; AX = A*40 (addr of start-of-row)
+ clc
+ adc SAVMSC ; add to screen pointer
+ sta destptr
+ txa
+ adc SAVMSC+1
+ sta destptr+1
+
+ ; X = current row, Y = current column. Stop clearing a line when Y == 40,
+ ; we're done when X == 24. Apologies, the names X and Y are backwards
+ ; compared to proper Cartesian coordinates.
+ ldx ROWCRS
+ ldy COLCRS
+ lda #0
+
+clrloop:
+ sta (destptr),y ; blank a character (A == 0, screen code for a space)
+ iny
+ cpy #40
+ bne clrloop
+ ldy #0
+ inx
+ cpx tmp3
+ bcs done
+
+ jsr bump_destptr
+ lda #0
+ tay
+ beq clrloop
+
+done:
+ rts