From 0697de373a5d070333806e28cf9d1d75708036e5 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Wed, 25 Apr 2018 20:00:49 -0400 Subject: [PATCH] add a cursor. --- ansi.asm | 150 ++++++++++++++++++++++++++++++++----------------------- vt100.c | 8 +++ 2 files changed, 96 insertions(+), 62 deletions(-) diff --git a/ansi.asm b/ansi.asm index 714a8d1..1d9777a 100644 --- a/ansi.asm +++ b/ansi.asm @@ -40,9 +40,14 @@ rows anop ; columns are simply x * 2 ; - - end + +cursor_data privdata + +cursor_offset dc i2'0' +cursor_bits dc i2'0' + end + ; ;ReverseScrollRegion(line1, line2) ; @@ -477,66 +482,6 @@ exit anop END -; -; void DrawCursor(int Xpos, int Ypos, int state); -; -; -DrawCursor START - - -state equ 13 -Ypos equ 11 -Xpos equ 9 -_rtlb equ 5 -tmp equ 3 -_d equ 1 - - phb - pha ;tmp - phd - tsc - tcd - - - lda $e12000,x - - - - pld - pla ;tmp - pla - sta 5,s - pla - sta 5,s - pla - plb - rtl - - END - - ; ; clear the screen to black (or whatnot) @@ -695,6 +640,87 @@ exit anop rtl end + +HideCursor start + using cursor_data + + ldx cursor_offset + beq exit + + lda cursor_bits + sta >$e10000,x + stz cursor_offset + +exit rtl + + end + +ShowCursor start + using cursor_data + using tables + + +yy equ 9 +xx equ 7 +_rtlb equ 3 +_d equ 1 + + + phb + + phd + tsc + tcd + + + ldx cursor_offset + beq off + +* hide old cursor. + lda cursor_bits + sta >$e10000,x + stz cursor_offset + +off anop + + lda $e10000,x + sta cursor_bits + lda #-1 + sta >$e10000,x + +exit anop + + + lda _rtlb+2 + sta yy + lda _rtlb + sta xx + + pld + pla + pla + plb + rtl + + end + ;Cursor START ;StartCursor ENTRY diff --git a/vt100.c b/vt100.c index 704b2f9..a42f408 100644 --- a/vt100.c +++ b/vt100.c @@ -28,6 +28,9 @@ extern void ClearLine2(unsigned line, unsigned start, unsigned end); extern void SetCursor(unsigned x, unsigned y); +extern void HideCursor(void); +extern void ShowCursor(unsigned x, unsigned y); + extern pascal void SysBeep2(Word) inline(0x3803,dispatcher); @@ -90,6 +93,8 @@ void vt100_init(void) parm_count = 0; private = 0; state = 0; + + HideCursor(); } #if 0 @@ -476,6 +481,7 @@ static void do_control(char c) { void vt100_process(const unsigned char *buffer, unsigned buffer_size) { unsigned i; + HideCursor(); for (i = 0; i < buffer_size; ++i) { unsigned char c = buffer[i] & 0x7f; if (c == 0 || c == 0x7f) continue; @@ -612,6 +618,8 @@ void vt100_process(const unsigned char *buffer, unsigned buffer_size) { } } + + ShowCursor(__x, __y); }