;
.export _cputcxy, _cputc, cputdirect, putchar
- .export newline, plot
- .constructor initcputc
- .destructor donecputc
+ .export newline, plot
.import popa, _gotoxy
.import PLOT
.include "c128.inc"
-cputdirect = PRINT
newline = NEWLINE
;--------------------------------------------------------------------------
; Printable char of some sort
L2: cmp #' '
- bcc L4 ; Other control char
+ bcc cputdirect ; Other control char
tay
bmi L5
cmp #$60
bcc L3
and #$DF
- bne L4 ; Branch always
+ bne cputdirect ; Branch always
L3: and #$3F
-L4: jmp PRINT ; Output character
+
+; Output one character to the screen. We will disable scrolling while doing so
+
+cputdirect:
+ ldx SCROLL
+ stx ScrollSave ; Save scroll flag
+ ldx #$C0
+ stx SCROLL ; Disable scrolling
+ jsr PRINT ; Call kernal entry point
+ ldx ScrollSave
+ stx SCROLL ; Restore old scroll flag
+ rts
; Handle character if high bit set
cmp #$7E ; PI?
bne L6
lda #$5E ; Load screen code for PI
- bne L4
+ bne cputdirect
L6: ora #$40
- bne L4 ; Branch always
+ bne cputdirect ; Branch always
; Carriage return
putchar = $CC2F
;--------------------------------------------------------------------------
-; Module constructor/destructor. Don't move the constructor into the INIT
-; segment, because it shares most of the code with the destructor.
-
-initcputc:
- lda #$C0
- .byte $2C
-donecputc:
- lda #$00
- sta SCROLL
- rts
+; Data
+.bss
+
+ScrollSave: .res 1 ; Save location for scroll byte
+
jsr SWAPPER ; Toggle the mode
lda #14
jsr BSOUT ; Switch to lower case chars
- lda #$C0
- sta SCROLL ; Disable scrolling
+
pla ; Get old mode into A
; Done, old mode is in A