2 ; Ullrich von Bassewitz, 16.09.2001
14 ; ------------------------------------------------------------------------
18 lda KeyIndex ; Characters waiting?
21 ; Switch on the cursor if needed
36 ; Read the character from the keyboard buffer
38 L3: ldx #$00 ; Get index
39 ldy KeyBuf ; Get first character in the buffer
41 L4: lda KeyBuf+1,x ; Move up the remaining chars
50 tya ; First char from buffer
55 ; ------------------------------------------------------------------------
62 bne @L9 ; Go set it on
63 lda CURS_FLAG ; Is the cursor currently off?
66 sta CURS_FLAG ; Mark it as off
67 lda CURS_STATE ; Cursor currently displayed?
68 sty CURS_STATE ; Cursor will be cleared later
71 ; Switch to the system bank, load Y with the cursor X coordinate
74 sta IndReg ; Access system bank
77 ; Reset the current cursor
80 sta (CRAM_PTR),y ; Store cursor color
82 sta IndReg ; Switch to our segment
84 eor #$80 ; Toggle reverse flag
91 @L9: sty CURS_FLAG ; Cursor on (Y = 0)
97 ; ------------------------------------------------------------------------
98 ; Blink the cursor in the interrupt. A blinking cursor is only available if
99 ; we use the cgetc() function, so we will export this IRQ handler only in
100 ; case the module is included into a program.
105 lda CURS_FLAG ; Is the cursor on?
106 bne curend ; Jump if not
110 ; Re-initialize the blink counter
112 lda #20 ; Initial value
115 ; Load Y with the cursor X coordinate
119 ; Check if the cursor state was on or off before
121 lda CURS_COLOR ; Load color behind cursor
122 lsr CURS_STATE ; Cursor currently displayed?
123 bcs curset ; Jump if yes
125 ; Cursor was off before, switch it on
127 inc CURS_STATE ; Mark as displayed
128 lda (CRAM_PTR),y ; Get color behind cursor...
129 sta CURS_COLOR ; ...and remember it
130 lda CHARCOLOR ; Use character color
132 ; Set the cursor with color in A
134 curset: sta (CRAM_PTR),y ; Store cursor color
136 sta IndReg ; Switch to our segment
138 eor #$80 ; Toggle reverse flag
141 ; Switch back to the system bank