2 ; Ullrich von Bassewitz, 16.09.2001
15 ; ------------------------------------------------------------------------
19 lda keyidx ; Characters waiting?
22 ; Switch on the cursor if needed
37 ; Read the character from the keyboard buffer
39 L3: ldx #$00 ; Get index
40 ldy keybuf ; Get first character in the buffer
42 L4: lda keybuf+1,x ; Move up the remaining chars
51 tya ; First char from buffer
56 ; ------------------------------------------------------------------------
63 bne @L9 ; Go set it on
64 lda CURS_FLAG ; Is the cursor currently off?
67 sta CURS_FLAG ; Mark it as off
68 lda CURS_STATE ; Cursor currently displayed?
69 sty CURS_STATE ; Cursor will be cleared later
72 ; Switch to the system bank, load Y with the cursor X coordinate
75 sta IndReg ; Access system bank
78 ; Reset the current cursor
81 sta (CRAM_PTR),y ; Store cursor color
83 sta IndReg ; Switch to our segment
85 eor #$80 ; Toggle reverse flag
92 @L9: sty CURS_FLAG ; Cursor on (Y = 0)
98 ; ------------------------------------------------------------------------
99 ; Blink the cursor in the interrupt. A blinking cursor is only available if
100 ; we use the cgetc() function, so we will export this IRQ handler only in
101 ; case the module is included into a program.
106 lda CURS_FLAG ; Is the cursor on?
107 bne curend ; Jump if not
111 ; Re-initialize the blink counter
113 lda #20 ; Initial value
116 ; Load Y with the cursor X coordinate
120 ; Check if the cursor state was on or off before
122 lda CURS_COLOR ; Load color behind cursor
123 lsr CURS_STATE ; Cursor currently displayed?
124 bcs curset ; Jump if yes
126 ; Cursor was off before, switch it on
128 inc CURS_STATE ; Mark as displayed
129 lda (CRAM_PTR),y ; Get color behind cursor...
130 sta CURS_COLOR ; ...and remember it
131 lda CHARCOLOR ; Use character color
133 ; Set the cursor with color in A
135 curset: sta (CRAM_PTR),y ; Store cursor color
137 sta IndReg ; Switch to our segment
139 eor #$80 ; Toggle reverse flag
142 ; Switch back to the system bank