;
.export _cputcxy, _cputc, cputdirect, putchar
- .export advance, newline, plot
+ .export newline, plot
.import popa, _gotoxy
- .import xsize, revers
.include "pet.inc"
- .include "../cbm/cbm.inc"
_cputcxy:
pha ; Save C
; Plot a character - also used as internal function
-_cputc: cmp #$0D ; CR?
+_cputc: cmp #$0A ; CR?
bne L1
lda #0
sta CURS_X
beq plot ; Recalculate pointers
-L1: cmp #$0A ; LF?
- bne L2
- ldy CURS_Y
- iny
- bne newline ; Recalculate pointers
+L1: cmp #$0D ; LF?
+ beq newline ; Recalculate pointers
; Printable char of some sort
-L2: cmp #' '
+ cmp #' '
bcc cputdirect ; Other control char
tay
bmi L10
cmp #$60
- bcc L3
+ bcc L2
and #$DF
bne cputdirect ; Branch always
-L3: and #$3F
+L2: and #$3F
cputdirect:
- jsr putchar ; Write the character to the screen
+ jsr putchar ; Write the character to the screen
; Advance cursor position
advance:
- iny
- cpy xsize
- bne L9
- ldy #0 ; new line
+ cpy SCR_LINELEN ; xsize-1
+ bne L3
+ jsr newline ; new line
+ ldy #$FF ; + cr
+L3: iny
+ sty CURS_X
+ rts
+
newline:
- clc
- lda xsize
+ lda SCR_LINELEN ; xsize-1
+ sec ; Account for -1 above
adc SCREEN_PTR
sta SCREEN_PTR
bcc L4
inc SCREEN_PTR+1
L4: inc CURS_Y
-L9: sty CURS_X
rts
; Handle character if high bit set
lda ScrLo,y
sta SCREEN_PTR
lda ScrHi,y
- ldy xsize
- cpy #40
- beq @L1
+ ldy SCR_LINELEN
+ cpy #40+1
+ bcc @L1
asl SCREEN_PTR ; 80 column mode
rol a
@L1: ora #$80 ; Screen at $8000
; position in Y
putchar:
- ora revers ; Set revers bit
+ ora RVS ; Set revers bit
ldy CURS_X
sta (SCREEN_PTR),y ; Set char
rts