From 3abf7993ce2d2deb1c0596f3404b2bfa27324564 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Wed, 17 Feb 2016 23:47:59 -0500 Subject: make the cursor behave *much* better, via custom conio function --- conio/cputc.s | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 conio/cputc.s (limited to 'conio/cputc.s') 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 -- cgit v1.2.3