2014-04-25 01:02:44 +00:00
|
|
|
;
|
|
|
|
; adapted from Atari version
|
|
|
|
; Christian Groessler, 2014
|
|
|
|
;
|
|
|
|
; void cputcxy (unsigned char x, unsigned char y, char c);
|
|
|
|
; void cputc (char c);
|
|
|
|
;
|
|
|
|
|
|
|
|
.include "atari5200.inc"
|
|
|
|
|
|
|
|
.export _cputcxy, _cputc
|
|
|
|
.export plot, cputdirect, putchar
|
2019-03-29 21:36:01 +00:00
|
|
|
.import gotoxy, _mul20
|
2019-04-02 19:11:11 +00:00
|
|
|
.import conio_color
|
|
|
|
.importzp screen_width, screen_height
|
2014-04-25 01:02:44 +00:00
|
|
|
.importzp ptr4
|
|
|
|
|
2019-04-10 20:15:27 +00:00
|
|
|
.import initconio
|
|
|
|
.constructor initconio_constructor
|
|
|
|
initconio_constructor = initconio
|
2014-04-25 01:02:44 +00:00
|
|
|
|
|
|
|
_cputcxy:
|
|
|
|
pha ; Save C
|
2016-06-05 12:58:38 +00:00
|
|
|
jsr gotoxy ; Set cursor, drop x and y
|
2014-04-25 01:02:44 +00:00
|
|
|
pla ; Restore C
|
|
|
|
|
|
|
|
_cputc:
|
|
|
|
cmp #$0D ; CR
|
|
|
|
bne L4
|
|
|
|
lda #0
|
|
|
|
sta COLCRS_5200
|
|
|
|
beq plot ; return
|
|
|
|
|
|
|
|
L4: cmp #$0A ; LF
|
|
|
|
beq newline
|
|
|
|
cmp #ATEOL ; Atari-EOL?
|
|
|
|
beq newline
|
|
|
|
|
|
|
|
tay
|
|
|
|
rol a
|
|
|
|
rol a
|
|
|
|
rol a
|
|
|
|
rol a
|
|
|
|
and #3
|
|
|
|
tax
|
|
|
|
tya
|
2019-04-02 19:11:11 +00:00
|
|
|
and #$9F
|
2014-04-25 01:02:44 +00:00
|
|
|
ora ataint,x
|
|
|
|
|
|
|
|
cputdirect: ; accepts screen code
|
|
|
|
jsr putchar
|
|
|
|
|
|
|
|
; advance cursor
|
|
|
|
inc COLCRS_5200
|
|
|
|
lda COLCRS_5200
|
2019-04-02 19:11:11 +00:00
|
|
|
cmp #screen_width
|
2014-04-25 01:02:44 +00:00
|
|
|
bcc plot
|
|
|
|
lda #0
|
|
|
|
sta COLCRS_5200
|
|
|
|
|
|
|
|
.export newline
|
|
|
|
newline:
|
|
|
|
inc ROWCRS_5200
|
|
|
|
lda ROWCRS_5200
|
2019-04-02 19:11:11 +00:00
|
|
|
cmp #screen_height
|
2014-04-25 01:02:44 +00:00
|
|
|
bne plot
|
|
|
|
lda #0
|
|
|
|
sta ROWCRS_5200
|
2019-04-02 19:11:11 +00:00
|
|
|
plot: ldy COLCRS_5200
|
2014-04-25 01:02:44 +00:00
|
|
|
ldx ROWCRS_5200
|
|
|
|
rts
|
|
|
|
|
|
|
|
putchar:
|
|
|
|
pha ; save char
|
|
|
|
|
|
|
|
lda ROWCRS_5200
|
2019-03-29 21:36:01 +00:00
|
|
|
jsr _mul20 ; destroys tmp4, carry is cleared
|
2014-04-25 01:02:44 +00:00
|
|
|
adc SAVMSC ; add start of screen memory
|
|
|
|
sta ptr4
|
|
|
|
txa
|
|
|
|
adc SAVMSC+1
|
|
|
|
sta ptr4+1
|
|
|
|
pla ; get char again
|
|
|
|
|
2019-04-04 23:26:34 +00:00
|
|
|
and #$3F ; clear palette index bits
|
|
|
|
ora conio_color ; use currently selected palette
|
2019-04-02 19:11:11 +00:00
|
|
|
|
2014-04-25 01:02:44 +00:00
|
|
|
ldy COLCRS_5200
|
|
|
|
sta (ptr4),y
|
2019-04-02 19:11:11 +00:00
|
|
|
rts
|
2014-04-25 01:02:44 +00:00
|
|
|
|
|
|
|
.rodata
|
|
|
|
ataint: .byte 64,0,32,96
|