2004-03-13 21:42:44 +00:00
|
|
|
;
|
|
|
|
; Ullrich von Bassewitz, 06.08.1998
|
|
|
|
;
|
|
|
|
; void cputcxy (unsigned char x, unsigned char y, char c);
|
|
|
|
; void cputc (char c);
|
|
|
|
;
|
|
|
|
|
|
|
|
.constructor initconio
|
|
|
|
.export _cputcxy, _cputc
|
|
|
|
.export _gotoxy, cputdirect
|
|
|
|
.export newline, putchar
|
|
|
|
|
2004-06-03 15:05:41 +00:00
|
|
|
.import popa, SETWND, BASCALC
|
2004-03-13 21:42:44 +00:00
|
|
|
|
|
|
|
.include "../apple2/apple2.inc"
|
|
|
|
|
|
|
|
initconio:
|
|
|
|
lda #$FF ; Normal character display mode
|
|
|
|
sta INVFLG
|
|
|
|
sta SETALTCHAR ; Switch in alternate charset
|
2004-06-03 15:05:41 +00:00
|
|
|
lda #$00
|
|
|
|
jsr SETWND ; Reset text window to full screen
|
2004-03-13 21:42:44 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
; Plot a character - also used as internal function
|
|
|
|
|
|
|
|
_cputcxy:
|
|
|
|
pha ; Save C
|
|
|
|
jsr popa ; Get Y
|
|
|
|
jsr _gotoxy
|
|
|
|
pla ; Restore C
|
|
|
|
|
|
|
|
_cputc:
|
|
|
|
cmp #$0D ; Test for \r = carrage return
|
2005-01-06 12:26:47 +00:00
|
|
|
beq left
|
2004-03-13 21:42:44 +00:00
|
|
|
cmp #$0A ; Test for \n = line feed
|
|
|
|
beq newline
|
|
|
|
ora #$80 ; Turn on high bit
|
|
|
|
|
|
|
|
cputdirect:
|
|
|
|
jsr putchar
|
|
|
|
inc CH ; Bump to next column
|
|
|
|
lda CH
|
|
|
|
cmp WNDWDTH
|
2005-01-06 12:26:47 +00:00
|
|
|
bne done
|
|
|
|
left: stz CH ; Goto left edge of screen
|
|
|
|
done: rts
|
|
|
|
|
|
|
|
newline:
|
|
|
|
inc CV
|
|
|
|
lda CV
|
|
|
|
cmp #24
|
|
|
|
bne :+
|
|
|
|
lda #$00
|
|
|
|
sta CV
|
|
|
|
: jsr BASCALC
|
2004-03-13 21:42:44 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
putchar:
|
|
|
|
ldy INVFLG
|
|
|
|
cpy #$FF ; Normal character display mode?
|
|
|
|
beq put
|
|
|
|
cmp #$E0 ; Lowercase?
|
2005-01-06 12:26:47 +00:00
|
|
|
bcc mask
|
2004-03-13 21:42:44 +00:00
|
|
|
and #$7F ; Inverse lowercase
|
|
|
|
bra put
|
2005-01-06 12:26:47 +00:00
|
|
|
mask: and INVFLG ; Apply normal, inverse, flash
|
|
|
|
put: ldy CH
|
2004-03-13 21:42:44 +00:00
|
|
|
bit RD80VID ; In 80 column mode?
|
|
|
|
bpl col40 ; No, in 40 cols
|
|
|
|
pha
|
|
|
|
tya
|
|
|
|
lsr ; Div by 2
|
|
|
|
tay
|
|
|
|
pla
|
|
|
|
bcs col40 ; Odd cols go in 40 col memory
|
|
|
|
bit HISCR
|
|
|
|
sta (BASL),Y
|
|
|
|
bit LOWSCR
|
|
|
|
rts
|
2005-01-06 12:26:47 +00:00
|
|
|
col40: sta (BASL),Y
|
2004-03-13 21:42:44 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
_gotoxy:
|
|
|
|
sta CV ; Store Y
|
2004-06-03 15:05:41 +00:00
|
|
|
jsr BASCALC
|
2004-03-13 21:42:44 +00:00
|
|
|
jsr popa ; Get X
|
|
|
|
sta CH ; Store X
|
|
|
|
rts
|