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