2003-04-13 22:12:09 +00:00
|
|
|
;
|
2013-07-26 07:33:54 +00:00
|
|
|
; 2003-04-13, Ullrich von Bassewitz
|
|
|
|
; 2013-07-16, Greg King
|
2003-04-13 22:12:09 +00:00
|
|
|
;
|
|
|
|
; void cputcxy (unsigned char x, unsigned char y, char c);
|
|
|
|
; void cputc (char c);
|
|
|
|
;
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.export _cputcxy, _cputc
|
2020-11-15 16:44:12 +00:00
|
|
|
.export setscrptr, cputdirect, putchar
|
2018-01-23 12:02:47 +00:00
|
|
|
.constructor initcputc
|
2003-04-13 22:12:09 +00:00
|
|
|
.import rvs
|
2013-05-09 11:56:54 +00:00
|
|
|
.import popax
|
2003-04-13 22:12:09 +00:00
|
|
|
.importzp ptr2
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.include "atmos.inc"
|
2003-04-13 22:12:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
_cputcxy:
|
2013-05-09 11:56:54 +00:00
|
|
|
pha ; Save C
|
|
|
|
jsr popax ; Get X and Y
|
2003-04-13 22:12:09 +00:00
|
|
|
sta CURS_Y ; Store Y
|
|
|
|
stx CURS_X ; Store X
|
2013-05-09 11:56:54 +00:00
|
|
|
pla ; Restore C
|
2003-04-13 22:12:09 +00:00
|
|
|
|
|
|
|
; Plot a character - also used as internal function
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
_cputc: cmp #$0D ; CR?
|
|
|
|
bne L1
|
|
|
|
lda #0
|
|
|
|
sta CURS_X ; Carriage return
|
2003-04-13 22:12:09 +00:00
|
|
|
rts
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
L1: cmp #$0A ; LF?
|
2020-11-15 16:44:12 +00:00
|
|
|
bne cputdirect
|
2013-05-09 11:56:54 +00:00
|
|
|
inc CURS_Y ; Newline
|
|
|
|
rts
|
2003-04-13 22:12:09 +00:00
|
|
|
|
|
|
|
; Output the character, then advance the cursor position
|
|
|
|
|
2020-11-15 16:44:12 +00:00
|
|
|
cputdirect:
|
2003-04-13 22:12:09 +00:00
|
|
|
jsr putchar
|
|
|
|
|
|
|
|
advance:
|
2013-05-09 11:56:54 +00:00
|
|
|
iny
|
2013-07-26 07:33:54 +00:00
|
|
|
cpy #SCREEN_XSIZE
|
2013-05-09 11:56:54 +00:00
|
|
|
bne L3
|
|
|
|
inc CURS_Y ; new line
|
|
|
|
ldy #0 ; + cr
|
|
|
|
L3: sty CURS_X
|
|
|
|
rts
|
2003-04-13 22:12:09 +00:00
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
; Set ptr2 to the screen, load the X offset into Y
|
|
|
|
|
|
|
|
.code
|
|
|
|
.proc setscrptr
|
|
|
|
|
|
|
|
ldy CURS_Y ; Get line number into Y
|
|
|
|
lda ScrTabLo,y ; Get low byte of line address
|
|
|
|
sta ptr2
|
|
|
|
lda ScrTabHi,y ; Get high byte of line address
|
|
|
|
sta ptr2+1
|
2013-05-09 11:56:54 +00:00
|
|
|
ldy CURS_X ; Get X offset
|
2003-04-13 22:12:09 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
.endproc
|
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
; Write one character to the screen without doing anything else, return X
|
|
|
|
; position in Y
|
|
|
|
|
|
|
|
.code
|
|
|
|
.proc putchar
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
ora rvs ; Set revers bit
|
2003-04-13 22:12:09 +00:00
|
|
|
pha ; And save
|
|
|
|
jsr setscrptr ; Set ptr2 to the screen
|
|
|
|
pla ; Restore the character
|
2013-05-09 11:56:54 +00:00
|
|
|
sta (ptr2),y ; Set char
|
|
|
|
rts
|
2003-04-13 22:12:09 +00:00
|
|
|
|
|
|
|
.endproc
|
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
; Screen address table
|
|
|
|
|
|
|
|
.rodata
|
|
|
|
ScrTabLo:
|
2013-07-26 07:33:54 +00:00
|
|
|
.repeat SCREEN_YSIZE, Line
|
|
|
|
.byte <(SCREEN + Line * SCREEN_XSIZE)
|
2003-04-13 22:12:09 +00:00
|
|
|
.endrep
|
|
|
|
|
|
|
|
ScrTabHi:
|
2013-07-26 07:33:54 +00:00
|
|
|
.repeat SCREEN_YSIZE, Line
|
|
|
|
.byte >(SCREEN + Line * SCREEN_XSIZE)
|
2003-04-13 22:12:09 +00:00
|
|
|
.endrep
|
|
|
|
|
2018-01-23 12:02:47 +00:00
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
; Switch the cursor off. Code goes into the ONCE segment,
|
|
|
|
; which will be reused after it is run.
|
|
|
|
|
|
|
|
.segment "ONCE"
|
|
|
|
|
|
|
|
initcputc:
|
|
|
|
lsr STATUS
|
|
|
|
asl STATUS ; Clear bit zero
|
|
|
|
rts
|