1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2026-04-19 09:23:06 +00:00

Use VBLank to calibrate cursor flashing

This commit is contained in:
David Schmenk
2025-03-02 09:56:35 -08:00
parent 82411e5e49
commit 83315b492d
4 changed files with 154 additions and 27 deletions
+1
View File
@@ -1,3 +1,4 @@
import vblank
predef waitVBL#1
predef statusVBL#1
end
+77 -1
View File
@@ -231,6 +231,68 @@ EXA2PC INX
BIT LCRDEN+LCBNK2
RTS
end
asm a2putuprchars(cnt, chrs)
TXTATTR = $32
LDA ESTKL+1,X ; CNT
BEQ EXA2PC
BIT ROMEN
LDA ESTKH,X
BEQ ++
STA SRCH ; SRC = CHRPTR
LDA ESTKL,X
STA SRCL
LDY #$00
- STY ESTKH+1,X
TYA
CMP ESTKL+1,X
BEQ EXA2UPC
LDA TXTATTR
PHA
LDA (SRC),Y
ORA #$80
CMP #'a'+$80
BCC +
CMP #'z'+$81
BCS +
SBC #$1F
PHA
LDA #$3F ; OUTPUT LC AS INV
STA TXTATTR
PLA
+ JSR COUT
PLA
STA TXTATTR
LDY ESTKH+1,X
INY
BNE -
++ LDA TXTATTR
PHA
LDA ESTKL,X ; CHR
ORA #$80
CMP #'a'+$80
BCC +
CMP #'z'+$81
BCS +
SBC #$1F
PHA
LDA #$3F
STA TXTATTR
PLA
+
- PHA
JSR COUT
PLA
DEC ESTKL+1,X
BNE -
PLA
STA TXTATTR
EXA2UPC INX
LDA #$00
STA ESTKL,X
STA ESTKH,X
BIT LCRDEN+LCBNK2
RTS
end
asm vidcpy(dstrow, srcrow)#0
WNDLFT = $20
WNDWID = $21
@@ -558,6 +620,15 @@ def a2ctrl(code, param)#1
fin
handled = TRUE
break
is ctrlcase
if not (flags & txt80)
flags = flags ^ uppercase
if flags & uppercase
conio:putchars = flags & uppercase ?? @a2putuprchars :: @a2putchars
fin
fin
handled = TRUE
break
wend
return handled
end
@@ -649,6 +720,7 @@ def a2textmode(columns)
conio:clear = @a2clear80v
conio:gotoxy = @a2gotoxy80v
conio:textctrl = @a2ctrl80v
conio:putchars = @a2putchars
fin
flags = flags | txt80
else
@@ -660,6 +732,9 @@ def a2textmode(columns)
*CSW = cswsave
*KSW = kswsave
a2viewport(0, 0, 40, 24)
if flags & uppercase
conio:putchars = @a2putuprchars
fin
fin
fin
conio:clear = @a2clear
@@ -894,7 +969,8 @@ when MACHID & MACHID_MODEL
conio:getkey = @a2cgetkey
break
is MACHID_II
//flags = flags | uppercase
flags = flags | uppercase
conio:putchars = @a2putuprchars
break
is MACHID_I
conio:keypressed = @a1keypressed
+44
View File
@@ -43,13 +43,57 @@ asm _vblnop#1
end
asm _vblend#1
end
export asm statusVBL#1
!SOURCE "vmsrc/plvmzp.inc"
PHP ; //c version first because its largest
SEI
STA $C07F ; Enable IOU access and reset VBL int on //c
LDA $C041 ; Save VBL int state MSB = BVL int enebaled
STA $C05B ; Enable VBL int
LDY #$00
BIT $C019
BPL + ; Check for VBL
DEY
STA $C070 ; Reset VBL int on //c
+ ASL
BCS +
STA $C05A ; Disable VBL int on //c
+ STA $C07E ; Disable IOU access on //c
PLP
TYA
DEX
STA ESTKL,X
STA ESTKH,X
RTS
end
asm _stat2e#1
LDA #$00 ; //e version
BIT $C019 ; Check for VBL
BPL +
LDA #$FF
+ DEX
STA ESTKL,X
STA ESTKH,X
RTS
end
asm _statnop#1
LDA #$00 ; NOP version
DEX ; return FALSE
STA ESTKL,X
STA ESTKH,X
RTS
end
asm _statend#1
end
//
// Check for machine specific VLB handling
//
if MACHID & MACHID_MODEL == MACHID_IIE
memcpy(@waitVBL, @_vbl2e, @_vblnop-@_vbl2e)
memcpy(@statusVBL, @_stat2e, @_statnop-@_stat2e)
elsif MACHID & MACHID_MODEL <> MACHID_IIC
memcpy(@waitVBL, @_vblnop, @_vblend-@_vblnop)
memcpy(@statusVBL, @_statnop, @_statend-@_statnop)
fin
//
// Keep module in memory
+32 -26
View File
@@ -8,6 +8,7 @@ include "inc/cmdsys.plh"
include "inc/args.plh"
include "inc/fileio.plh"
include "inc/conio.plh"
include "inc/vblank.plh"
sysflags restxt1|resxtxt1|nojitc // Keep JITC from compiling and pausing while editing
const CSW = $0036
//
@@ -20,11 +21,9 @@ const MAXLNLEN = 127
const pgjmp = 16
const changed = 1
const insmode = 2
const gutter = 4
const uppercase = 8
const selection = 16
const showcurs = 32
const shiftlock = 128
const gutter = 4 // This has to be 4 to match on-screen width
const selection = 8
const exit = 16
//
// Text screen row address array
//
@@ -39,15 +38,14 @@ word viewtop
byte nullstr = ""
byte[80] findstr = ""
byte[64] filename = "UNTITLED"
byte exit = FALSE
byte flags = 0
byte flashcurs = 0
word numlines = 0
word numcliplines = 0
word arg
word strpool, strplmapsize, strpoolmap
word txtlinbuf, cliplinbuf
word cursx, cursy, cursrow, curscol, selrow
word cursflash = 300 // default cursor flash delay
//
// Predeclared functions
//
@@ -562,18 +560,20 @@ def drawscrn#0
drawrows(0, scrnheight - 1)
end
def curshpos(hpos)#1
byte needredraw
byte needredraw, scrnleft, scrnright
needredraw = TRUE
if hpos < 0; hpos = 0; fin
if hpos > MAXLNLEN; hpos = MAXLNLEN; fin
scrnleft = flags & gutter
scrnright = scrnleft + viewwidth
curscol = hpos
cursx = curscol - viewleft + (flags & gutter)
if cursx > viewwidth
cursx = viewwidth
if cursx > scrnright
cursx = scrnright
viewleft = curscol - viewwidth
elsif cursx < flags & gutter
cursx = flags & gutter
elsif cursx < scrnleft
cursx = scrnleft
viewleft = curscol
else
needredraw = FALSE
@@ -1073,15 +1073,16 @@ end
def waitkey#0
word delay
for delay = 0 to 300
if conio:keypressed(); return; fin
next
delay = cursflash
while not conio:keypressed() and delay
delay--
loop
end
def keyin
byte key, underchr, curschr
underchr = curscol >= ^(txtlinbuf=>[cursrow]) ?? ' ' :: txtlinbuf=>[cursrow]->[curscol + 1]
curschr = flags & insmode ?? '+' :: ' '
curschr = flags & insmode ?? '+' :: '_'
repeat
conio:gotoxy(cursx, cursy)
conio:textctrl(ctrlattr, INVERSE)
@@ -1322,13 +1323,13 @@ def editmode#0
conio:textctrl(ctrlecho, ON)
conio:textctrl(ctrlcursor, ON)
cmdmode
if not exit
if not (flags & exit)
conio:textctrl(ctrlecho, OFF)
conio:textctrl(ctrlcursor, OFF)
drawscrn
fin
wend
until exit
until flags & exit
end
//
// Command mode
@@ -1417,7 +1418,7 @@ def cmdmode#0
conio:clear(cls)
puts("PLASMA Editor, Version 2.20\n")
while not exit
while not (flags & exit)
puts(@filename)
cmdptr = gets($BA)
when toupper(parsecmd(cmdptr))
@@ -1435,11 +1436,7 @@ def cmdmode#0
viewwidth = scrnwidth - (flags & gutter) - 1
break
is 'C' // Lower case chip (Apple ][/][+ only)
if flags & uppercase
//txtlower Add textctrl to force lower case output
else
//txtupper Add textctrl to force upper case output
fin
conio:textctrl(ctrlcase, 0)
break
wend
fin
@@ -1486,8 +1483,8 @@ def cmdmode#0
printtxt(slot)
break
is 'Q' // Quit
exit = chkchng
if not exit
flags = flags | (chkchng ?? exit :: 0)
if not (flags & exit)
return
fin
break
@@ -1545,6 +1542,15 @@ if ^arg
cursrow = strtonum(arg)
fin
fin
while statusVBL and cursflash
cursflash--
loop
cursflash = 0
while not statusVBL
cursflash++
loop
if cursflash == 0; cursflash = 30; fin
cursflash = cursflash * 20 // Make it flash a little slower
flags = flags | insmode | gutter
scrnwidth = conio:textmode(scrnwidth)
inittxtbuf