Add blinking cursor on input
git-svn-id: svn://svn.cc65.org/cc65/trunk@944 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -21,6 +21,7 @@ OBJS = _scrsize.o \
|
|||||||
cputc.o \
|
cputc.o \
|
||||||
crt0.o \
|
crt0.o \
|
||||||
kbhit.o \
|
kbhit.o \
|
||||||
|
kblncur.o \
|
||||||
kirq.o \
|
kirq.o \
|
||||||
kplot.o \
|
kplot.o \
|
||||||
kscnkey.o \
|
kscnkey.o \
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
;
|
;
|
||||||
; Ullrich von Bassewitz, 06.08.1998
|
; Ullrich von Bassewitz, 16.09.2001
|
||||||
;
|
;
|
||||||
; char cgetc (void);
|
; char cgetc (void);
|
||||||
;
|
;
|
||||||
|
|
||||||
.export _cgetc
|
.export _cgetc
|
||||||
.import plot, write_crtc
|
|
||||||
.import cursor
|
.import cursor
|
||||||
|
|
||||||
.include "zeropage.inc"
|
.include "zeropage.inc"
|
||||||
@@ -16,23 +15,81 @@
|
|||||||
|
|
||||||
.proc _cgetc
|
.proc _cgetc
|
||||||
|
|
||||||
L1: lda KeyIndex
|
lda KeyIndex ; Characters waiting?
|
||||||
beq L1
|
bne L3 ; Jump if so
|
||||||
|
|
||||||
L2: ldx #$00 ; Get index
|
; Switch on the cursor if needed
|
||||||
ldy KeyBuf ; Get first character in the buffer
|
|
||||||
sei
|
lda CURS_FLAG
|
||||||
L3: lda KeyBuf+1,x ; Move up the remaining chars
|
pha
|
||||||
sta KeyBuf,x
|
lda cursor
|
||||||
|
jsr setcursor
|
||||||
|
L1: lda KeyIndex
|
||||||
|
beq L1
|
||||||
|
ldx #0
|
||||||
|
pla
|
||||||
|
bne L2
|
||||||
inx
|
inx
|
||||||
cpx KeyIndex
|
L2: txa
|
||||||
bne L3
|
jsr setcursor
|
||||||
dec KeyIndex
|
|
||||||
|
; Read the character from the keyboard buffer
|
||||||
|
|
||||||
|
L3: ldx #$00 ; Get index
|
||||||
|
ldy KeyBuf ; Get first character in the buffer
|
||||||
|
sei
|
||||||
|
L4: lda KeyBuf+1,x ; Move up the remaining chars
|
||||||
|
sta KeyBuf,x
|
||||||
|
inx
|
||||||
|
cpx KeyIndex
|
||||||
|
bne L4
|
||||||
|
dec KeyIndex
|
||||||
cli
|
cli
|
||||||
|
|
||||||
ldx #$00 ; High byte
|
ldx #$00 ; High byte
|
||||||
tya ; First char from buffer
|
tya ; First char from buffer
|
||||||
rts
|
rts
|
||||||
|
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
|
; ------------------------------------------------------------------------
|
||||||
|
;
|
||||||
|
|
||||||
|
.proc setcursor
|
||||||
|
|
||||||
|
ldy #$00 ;
|
||||||
|
tax ; On or off?
|
||||||
|
bne @L9 ; Go set it on
|
||||||
|
lda CURS_FLAG ; Is the cursor currently off?
|
||||||
|
bne @L8 ; Jump if yes
|
||||||
|
lda #1
|
||||||
|
sta CURS_FLAG ; Mark it as off
|
||||||
|
lda CURS_STATE ; Cursor currently displayed?
|
||||||
|
sty CURS_STATE ; Cursor will be cleared later
|
||||||
|
beq @L8 ; Jump if no
|
||||||
|
|
||||||
|
; Switch to the system bank, load Y with the cursor X coordinate
|
||||||
|
|
||||||
|
lda #$0F
|
||||||
|
sta IndReg ; Access system bank
|
||||||
|
ldy CURS_X
|
||||||
|
|
||||||
|
; Reset the current cursor
|
||||||
|
|
||||||
|
lda CURS_COLOR
|
||||||
|
sta (CRAM_PTR),y ; Store cursor color
|
||||||
|
lda ExecReg
|
||||||
|
sta IndReg ; Switch to our segment
|
||||||
|
lda (SCREEN_PTR),y
|
||||||
|
eor #$80 ; Toggle reverse flag
|
||||||
|
sta (SCREEN_PTR),y
|
||||||
|
|
||||||
|
; Done
|
||||||
|
|
||||||
|
@L8: rts
|
||||||
|
|
||||||
|
@L9: sty CURS_FLAG ; Cursor on (Y = 0)
|
||||||
|
rts
|
||||||
|
|
||||||
|
.endproc
|
||||||
|
|
||||||
|
|||||||
56
libsrc/cbm510/kblncur.s
Normal file
56
libsrc/cbm510/kblncur.s
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
;
|
||||||
|
; Ullrich von Bassewitz, 16.09.2001
|
||||||
|
;
|
||||||
|
|
||||||
|
.export k_blncur
|
||||||
|
|
||||||
|
.include "zeropage.inc"
|
||||||
|
|
||||||
|
|
||||||
|
; ------------------------------------------------------------------------
|
||||||
|
; Blink the cursor in the interrupt
|
||||||
|
|
||||||
|
.proc k_blncur
|
||||||
|
|
||||||
|
lda CURS_FLAG ; Is the cursor on?
|
||||||
|
bne curend ; Jump if not
|
||||||
|
dec CURS_BLINK
|
||||||
|
bne curend
|
||||||
|
|
||||||
|
; Re-initialize the blink counter
|
||||||
|
|
||||||
|
lda #20 ; Initial value
|
||||||
|
sta CURS_BLINK
|
||||||
|
|
||||||
|
; Switch to the system bank, load Y with the cursor X coordinate
|
||||||
|
|
||||||
|
lda #$0F
|
||||||
|
sta IndReg ; Access system bank
|
||||||
|
ldy CURS_X
|
||||||
|
|
||||||
|
; Check if the cursor state was on or off before
|
||||||
|
|
||||||
|
lda CURS_COLOR ; Load color behind cursor
|
||||||
|
lsr CURS_STATE ; Cursor currently displayed?
|
||||||
|
bcs curset ; Jump if yes
|
||||||
|
|
||||||
|
; Cursor was off before, switch it on
|
||||||
|
|
||||||
|
inc CURS_STATE ; Mark as displayed
|
||||||
|
lda (CRAM_PTR),y ; Get color behind cursor...
|
||||||
|
sta CURS_COLOR ; ...and remember it
|
||||||
|
lda CHARCOLOR ; Use character color
|
||||||
|
|
||||||
|
; Set the cursor with color in A
|
||||||
|
|
||||||
|
curset: sta (CRAM_PTR),y ; Store cursor color
|
||||||
|
lda ExecReg
|
||||||
|
sta IndReg ; Switch to our segment
|
||||||
|
lda (SCREEN_PTR),y
|
||||||
|
eor #$80 ; Toggle reverse flag
|
||||||
|
sta (SCREEN_PTR),y
|
||||||
|
curend: rts
|
||||||
|
|
||||||
|
.endproc
|
||||||
|
|
||||||
|
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
;
|
;
|
||||||
|
|
||||||
.export irq, nmi, k_irq, k_nmi
|
.export irq, nmi, k_irq, k_nmi
|
||||||
.import k_scnkey, k_udtim, k_rs232
|
.import k_blncur, k_scnkey, k_udtim, k_rs232
|
||||||
.importzp tpi1
|
.importzp tpi1
|
||||||
|
|
||||||
.include "zeropage.inc"
|
.include "zeropage.inc"
|
||||||
@@ -72,6 +72,7 @@ k_irq:
|
|||||||
|
|
||||||
cmp #%00000001 ; ticker irq?
|
cmp #%00000001 ; ticker irq?
|
||||||
bne irq1
|
bne irq1
|
||||||
|
jsr k_blncur ; Blink the cursor
|
||||||
jsr k_scnkey ; Poll the keyboard
|
jsr k_scnkey ; Poll the keyboard
|
||||||
jsr k_udtim ; Bump the time
|
jsr k_udtim ; Bump the time
|
||||||
|
|
||||||
|
|||||||
@@ -93,13 +93,13 @@ ScreenRight = $DF
|
|||||||
ModKey = $E0
|
ModKey = $E0
|
||||||
NorKey = $E1
|
NorKey = $E1
|
||||||
BitTable = $E2
|
BitTable = $E2
|
||||||
BlinkOn = $E6
|
CURS_FLAG = $E6 ; 1 = no cursor
|
||||||
BlinkCounter = $E7
|
CURS_BLINK = $E7 ; cursor blink counter
|
||||||
CRAM_PTR = $E8
|
CRAM_PTR = $E8
|
||||||
TempColor = $EA
|
TempColor = $EA
|
||||||
BlinkSwitch = $EB
|
CURS_STATE = $EB ; Cursor blink state
|
||||||
CHARCOLOR = $EC
|
CHARCOLOR = $EC
|
||||||
CursBackColor = $ED ; Color behind cursor
|
CURS_COLOR = $ED ; Color behind cursor
|
||||||
OutCharTmp = $EE
|
OutCharTmp = $EE
|
||||||
ScreenSeq = $EF ; Segment of video RAM
|
ScreenSeq = $EF ; Segment of video RAM
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user