From: Oliver Schmidt
diff --git a/doc/apple2enh.sgml b/doc/apple2enh.sgml
index 7c17c24f2..b5231b4cd 100644
--- a/doc/apple2enh.sgml
+++ b/doc/apple2enh.sgml
@@ -450,10 +450,6 @@ BASIC.SYSTEM) there are some limitations for DOS 3.3:
The enhanced Apple //e has no color text mode. Therefore the functions
textcolor(), bgcolor() and bordercolor() have no effect.
-
diff --git a/libsrc/apple2/cgetc.s b/libsrc/apple2/cgetc.s
index 511e434df..b1bda8b91 100644
--- a/libsrc/apple2/cgetc.s
+++ b/libsrc/apple2/cgetc.s
@@ -6,20 +6,44 @@
; If open_apple key is pressed then the high-bit of the key is set.
;
- .export _cgetc
+ .export _cgetc
+ .import cursor, putchardirect
- .include "apple2.inc"
+ .include "apple2.inc"
_cgetc:
- lda KBD
- bpl _cgetc ; If < 128, no key pressed
+ ; Cursor on ?
+ lda cursor
+ beq :+
- ; At this time, the high bit of the key pressed is set
- bit KBDSTRB ; Clear keyboard strobe
+ ; Show caret.
+ .ifdef __APPLE2ENH__
+ lda #$7F | $80 ; Checkerboard, screen code
+ .else
+ lda #' ' | $40 ; Blank, flashing
+ .endif
+ jsr putchardirect ; Returns old character in X
+
+ ; Wait for keyboard strobe.
+: lda KBD
+ bpl :- ; If < 128, no key pressed
+
+ ; Cursor on ?
+ ldy cursor
+ beq :+
+
+ ; Restore old character.
+ pha
+ txa
+ jsr putchardirect
+ pla
+
+ ; At this time, the high bit of the key pressed is set.
+: bit KBDSTRB ; Clear keyboard strobe
.ifdef __APPLE2ENH__
bit BUTN0 ; Check if OpenApple is down
bmi done
.endif
and #$7F ; If not down, then clear high bit
-done: ldx #$00
+done: ldx #>$0000
rts
diff --git a/libsrc/apple2/chline.s b/libsrc/apple2/chline.s
index 6cf77de1b..ca1ee707c 100644
--- a/libsrc/apple2/chline.s
+++ b/libsrc/apple2/chline.s
@@ -26,11 +26,12 @@ _chline:
ldx #'-' | $80 ; Horizontal line, screen code
chlinedirect:
+ stx tmp1
cmp #$00 ; Is the length zero?
beq done ; Jump if done
- sta tmp1
-: txa ; Screen code
+ sta tmp2
+: lda tmp1 ; Screen code
jsr cputdirect ; Direct output
- dec tmp1
+ dec tmp2
bne :-
done: rts
diff --git a/libsrc/apple2/cputc.s b/libsrc/apple2/cputc.s
index 6607c6178..6f610fe92 100644
--- a/libsrc/apple2/cputc.s
+++ b/libsrc/apple2/cputc.s
@@ -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
+ .endif
+put: lda (BASL),Y ; Get current character
+ tax ; Return old character for _cgetc
+ pla
sta (BASL),Y
- bit LOWSCR ; Assume SET80COL
- rts
+ .ifdef __APPLE2ENH__
+ bit LOWSCR ; Doesn't hurt in 40 column mode
.endif
-col40: sta (BASL),Y
rts
diff --git a/libsrc/apple2/cvline.s b/libsrc/apple2/cvline.s
index a26cc7063..c8ae1e269 100644
--- a/libsrc/apple2/cvline.s
+++ b/libsrc/apple2/cvline.s
@@ -23,12 +23,13 @@ _cvline:
.endif
cvlinedirect:
+ stx tmp1
cmp #$00 ; Is the length zero?
beq done ; Jump if done
- sta tmp1
-: txa ; Screen code
+ sta tmp2
+: lda tmp1 ; Screen code
jsr putchar ; Write, no cursor advance
jsr newline ; Advance cursor to next line
- dec tmp1
+ dec tmp2
bne :-
done: rts
diff --git a/libsrc/apple2/textframe.s b/libsrc/apple2/textframe.s
index d5e9b80d7..55ac235b8 100644
--- a/libsrc/apple2/textframe.s
+++ b/libsrc/apple2/textframe.s
@@ -16,10 +16,10 @@
.include "zeropage.inc"
.include "apple2.inc"
-WIDTH = tmp2
-HEIGHT = tmp3
-XORIGIN = tmp4
-YORIGIN = ptr1
+WIDTH = ptr1
+HEIGHT = ptr1+1
+XORIGIN = ptr2
+YORIGIN = ptr2+1
_textframexy:
sec