]> git.sur5r.net Git - cc65/blob - libsrc/pce/cputc.s
added missing chline, cvline
[cc65] / libsrc / pce / cputc.s
1 ;
2 ; void cputcxy (unsigned char x, unsigned char y, char c);
3 ; void cputc (char c);
4 ;
5
6                 .export _cputcxy, _cputc, cputdirect, putchar
7                 .export newline, plot
8                 .import popa, _gotoxy
9                 .import PLOT
10                 .import xsize
11
12                 .importzp tmp3,tmp4
13
14                 .include        "pce.inc"
15 _cputcxy:
16                 pha                     ; Save C
17                 jsr        popa         ; Get Y
18                 jsr        _gotoxy      ; Set cursor, drop x
19                 pla                     ; Restore C
20
21 ; Plot a character - also used as internal function
22
23 _cputc:         cmp     #$0d            ; CR?
24                 bne     L1
25                 lda     #0
26                 sta     CURS_X
27                 beq     plot            ; Recalculate pointers
28
29 L1:             cmp     #$0a            ; LF?
30                 beq     newline         ; Recalculate pointers
31
32 ; Printable char of some sort
33
34 cputdirect:
35                 jsr     putchar         ; Write the character to the screen
36
37 ; Advance cursor position
38
39 advance:
40                 ldy     CURS_X
41                 iny
42                 cpy     xsize
43                 bne     L3
44                 jsr     newline         ; new line
45                 ldy     #0              ; + cr
46 L3:             sty     CURS_X
47                 jmp     plot
48
49 newline:
50                 inc     CURS_Y
51
52 ; Set cursor position, calculate RAM pointers
53
54 plot:           ldy     CURS_X
55                 ldx     CURS_Y
56                 clc
57                 jmp     PLOT            ; Set the new cursor
58
59
60
61 ; Write one character to the screen without doing anything else, return X
62 ; position in Y
63
64 putchar:
65
66                 ora     RVS             ; Set revers bit
67
68                 tax
69
70                 st0     #VDC_MAWR       ; Memory Adress Write
71
72                 lda     SCREEN_PTR
73                 sta     a:VDC_DATA_LO
74
75                 lda     SCREEN_PTR+1
76                 sta     a:VDC_DATA_HI
77
78                 st0     #VDC_VWR        ; VWR
79
80                 txa
81                 sta     a:VDC_DATA_LO   ; character
82
83                 lda     CHARCOLOR
84
85                 asl     a
86                 asl     a
87                 asl     a
88                 asl     a
89
90                 ora     #$02
91                 sta     a:VDC_DATA_HI
92
93                 rts
94
95 ;-------------------------------------------------------------------------------
96 ; force the init constructor to be imported
97
98                 .import initconio
99 conio_init = initconio