;
.ifdef __APPLE2ENH__
- .constructor initconio, 17
+ .constructor initconio
.endif
.export _cputcxy, _cputc
- .export cputdirect, newline, putchar
- .import popa, _gotoxy, VTABZ
+ .export cputdirect, newline, putchar, putchardirect
+ .import gotoxy, VTABZ
.include "apple2.inc"
- .segment "INIT"
+ .segment "ONCE"
.ifdef __APPLE2ENH__
initconio:
sta SETALTCHAR ; Switch in alternate charset
- bit LORES ; Limit SET80COL-HISCR to text
+ bit LORES ; Limit SET80COL-HISCR to text
rts
.endif
_cputcxy:
pha ; Save C
- jsr popa ; Get Y
- jsr _gotoxy
- pla ; Restore C
+ jsr gotoxy ; Call this one, will pop params
+ pla ; Restore C and run into _cputc
_cputc:
cmp #$0D ; Test for \r = carrage return
beq left
cmp #$0A ; Test for \n = line feed
beq newline
- ora #$80 ; Turn on high bit
+ eor #$80 ; Invert high bit
.ifndef __APPLE2ENH__
cmp #$E0 ; Test for lowercase
bcc cputdirect
lda CH
cmp WNDWDTH
bcc :+
+ jsr newline
left: lda #$00 ; Goto left edge of screen
sta CH
: rts
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