Added CONIO cursor support.
For quite some time I deliberately didn't add cursor support to the Apple II CONIO imöplementation. I consider it inappropriate to increase the size of cgetc() unduly for a rather seldom used feature. There's no hardware cursor on the Apple II so displaying a cursor during keyboard input means reading the character stored at the cursor location, writing the cursor character, reading the keyboard and finally writing back the character read initially. The naive approach is to reuse the part of cputc() that determines the memory location of the character at the cursor position in order to read the character stored there. However that means to add at least one additional JSR / RTS pair to cputc() adding 4 bytes and 12 cycles :-( Apart from that this approach means still a "too" large cgetc(). The approach implemented instead is to include all functionality required by cgetc() into cputc() - which is to read the current character before writing a new one. This may seem surprising at first glance but an LDA(),Y / TAX sequence adds only 3 bytes and 7 cycles so it cheaper than the JSR / RTS pair and allows to brings down the code increase in cgetc() down to a reasonable value. However so far the internal cputc() code in question saved the X register. Now it uses the X register to return the old character present before writing the new character for cgetc(). This requires some rather small adjustments in other functions using that internal cputc() code.
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
.constructor initconio
|
||||
.endif
|
||||
.export _cputcxy, _cputc
|
||||
.export cputdirect, newline, putchar
|
||||
.export cputdirect, newline, putchar, putchardirect
|
||||
.import gotoxy, VTABZ
|
||||
|
||||
.include "apple2.inc"
|
||||
@@ -62,32 +62,36 @@ newline:
|
||||
lda WNDTOP ; Goto top of screen
|
||||
sta CV
|
||||
: jmp VTABZ
|
||||
|
||||
|
||||
putchar:
|
||||
.ifdef __APPLE2ENH__
|
||||
ldy INVFLG
|
||||
cpy #$FF ; Normal character display mode?
|
||||
beq put
|
||||
beq putchardirect
|
||||
cmp #$E0 ; Lowercase?
|
||||
bcc mask
|
||||
and #$7F ; Inverse lowercase
|
||||
bra put
|
||||
bra putchardirect
|
||||
.endif
|
||||
mask: and INVFLG ; Apply normal, inverse, flash
|
||||
put: ldy CH
|
||||
|
||||
putchardirect:
|
||||
pha
|
||||
ldy CH
|
||||
.ifdef __APPLE2ENH__
|
||||
bit RD80VID ; In 80 column mode?
|
||||
bpl col40 ; No, in 40 cols
|
||||
pha
|
||||
bpl put ; No, just go ahead
|
||||
tya
|
||||
lsr ; Div by 2
|
||||
tay
|
||||
pla
|
||||
bcs col40 ; Odd cols go in 40 col memory
|
||||
bcs put ; Odd cols go in main memory
|
||||
bit HISCR ; Assume SET80COL
|
||||
sta (BASL),Y
|
||||
bit LOWSCR ; Assume SET80COL
|
||||
rts
|
||||
.endif
|
||||
col40: sta (BASL),Y
|
||||
put: lda (BASL),Y ; Get current character
|
||||
tax ; Return old character for _cgetc
|
||||
pla
|
||||
sta (BASL),Y
|
||||
.ifdef __APPLE2ENH__
|
||||
bit LOWSCR ; Doesn't hurt in 40 column mode
|
||||
.endif
|
||||
rts
|
||||
|
||||
Reference in New Issue
Block a user