]> git.sur5r.net Git - cc65/blob - libsrc/pce/cputc.s
Fixed and improved some pce comments.
[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 pointer
29
30 L1:     cmp     #$0A            ; LF?
31         beq     newline         ; Recalculate pointer
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 VRAM pointer.
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.
61
62 putchar:
63         ora     RVS             ; Set revers bit
64
65         tax
66
67         st0     #VDC_MAWR       ; Memory Address Write
68
69         lda     SCREEN_PTR
70         sta     VDC_DATA_LO
71
72         lda     SCREEN_PTR+1
73         sta     VDC_DATA_HI
74
75         st0     #VDC_VWR        ; VWR
76
77         txa
78         sta     VDC_DATA_LO     ; character
79
80         lda     CHARCOLOR       ; pallette number
81         asl     a
82         asl     a
83         asl     a
84         asl     a
85
86         ora     #$02
87         sta     VDC_DATA_HI
88
89         rts
90
91 ;-------------------------------------------------------------------------------
92 ; force the init constructor to be imported
93
94         .import initconio
95 conio_init      = initconio