1
0
mirror of https://github.com/cc65/cc65.git synced 2024-11-02 18:06:48 +00:00
cc65/libsrc/creativision/cputc.s

126 lines
2.7 KiB
ArmAsm
Raw Normal View History

2013-12-05 11:40:44 +00:00
;
; Written by Groepaz/Hitmen <groepaz@gmx.net>
; Cleanup by Ullrich von Bassewitz <uz@cc65.org>
;
; void cputcxy (unsigned char x, unsigned char y, char c);
; void cputc (char c);
;
.export _cputcxy, _cputc, cputdirect, putchar
.export newline
.constructor initconio
.import popa, _gotoxy
.import setcursor
.importzp tmp3,tmp4
.include "creativision.inc"
.include "boxchars.inc"
;-----------------------------------------------------------------------------
.code
_cputcxy:
pha ; Save C
jsr popa ; Get Y
jsr _gotoxy ; Set cursor, drop x
pla ; Restore C
; Plot a character - also used as internal function
2017-02-01 18:46:04 +00:00
_cputc: cmp #$0D ; CR?
2013-12-05 11:40:44 +00:00
bne L1
lda #0
sta CURSOR_X
beq plot ; Recalculate pointers
2017-02-01 18:46:04 +00:00
L1: cmp #$0A ; LF?
2013-12-05 11:40:44 +00:00
beq newline ; Recalculate pointers
; Printable char of some sort
cputdirect:
jsr putchar ; Write the character to the screen
; Advance cursor position
advance:
ldy CURSOR_X
iny
cpy #SCREEN_COLS
bne L3
2017-02-14 22:52:44 +00:00
inc CURSOR_Y ; new line
2013-12-05 11:40:44 +00:00
ldy #0 ; + cr
L3: sty CURSOR_X
jmp plot
newline:
inc CURSOR_Y
; Set cursor position, calculate RAM pointers
plot: ldy CURSOR_X
ldx CURSOR_Y
jmp setcursor ; Set the new cursor
; Write one character to the screen without doing anything else, return X
; position in Y
putchar:
cmp #$5B
bcc IS_UPPER
clc
sbc #$1F
IS_UPPER:
cmp #$20
bcc BAD_CHAR
pha
lda SCREEN_PTR
sei
2017-02-01 18:46:04 +00:00
sta VDP_CONTROL_W
2013-12-05 11:40:44 +00:00
lda SCREEN_PTR+1
2017-02-01 18:46:04 +00:00
ora #$40
sta VDP_CONTROL_W
2013-12-05 11:40:44 +00:00
pla
clc
2017-02-01 18:46:04 +00:00
adc #160
sta VDP_DATA_W
2013-12-05 11:40:44 +00:00
cli
BAD_CHAR:
jmp plot
2017-02-01 18:46:04 +00:00
2013-12-05 11:40:44 +00:00
;-----------------------------------------------------------------------------
; Initialize the conio subsystem. "INIT" segment is nothing special on the
; Creativision, it is part of the "ROM" memory.
2013-12-05 11:40:44 +00:00
.segment "INIT"
initconio:
2017-02-01 18:46:04 +00:00
lda #$0
sta SCREEN_PTR
lda #$10
sta SCREEN_PTR+1
; Copy box characters to slot
sei
lda #08
sta VDP_CONTROL_W
lda #$46
sta VDP_CONTROL_W
ldx #0
LL: lda boxchars,x
sta VDP_DATA_W
inx
cpx #48
bne LL
cli
jmp plot