]> git.sur5r.net Git - cc65/blob - libsrc/gamate/cputc.s
conio and most other stuff working now
[cc65] / libsrc / gamate / 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         .import         fontdata
12         .import         _plotlo
13
14         .importzp       tmp3,tmp4
15         .importzp       ptr3
16
17         .include        "gamate.inc"
18         .include        "extzp.inc"
19
20 _cputcxy:
21         pha                     ; Save C
22         jsr     popa            ; Get Y
23         jsr     _gotoxy         ; Set cursor, drop x
24         pla                     ; Restore C
25
26 ; Plot a character - also used as internal function
27
28 _cputc: cmp     #$0d            ; CR?
29         bne     L1
30         lda     #0
31         sta     CURS_X
32         beq     plot            ; Recalculate pointers
33
34 L1:     cmp     #$0a            ; LF?
35         beq     newline         ; Recalculate pointers
36
37 ; Printable char of some sort
38
39 cputdirect:
40         jsr     putchar         ; Write the character to the screen
41
42 ; Advance cursor position
43
44 advance:
45         ldy     CURS_X
46         iny
47         cpy     xsize
48         bne     L3
49         jsr     newline         ; new line
50         ldy     #0              ; + cr
51 L3:     sty     CURS_X
52         jmp     plot
53
54 newline:
55         inc     CURS_Y
56
57 ; Set cursor position, calculate RAM pointers
58
59 plot:   ldy     CURS_X
60         ldx     CURS_Y
61         clc
62         jmp     PLOT            ; Set the new cursor
63
64 ; Write one character to the screen without doing anything else, return X
65 ; position in Y
66
67 putchar:
68
69 ; FIXME
70 ;        ora     RVS             ; Set revers bit
71
72 ;        sty     temp_y
73 ;        stx     temp_x
74 ;        sta     temp_a
75
76 ;        lda     temp_a
77
78         sta     ptr3
79
80         txa
81         pha
82
83         lda     #0
84         sta     ptr3+1
85         ; * 8
86         asl     ptr3
87         rol     ptr3+1
88         asl     ptr3
89         rol     ptr3+1
90         asl     ptr3
91         rol     ptr3+1
92
93         lda     ptr3
94         clc
95         adc     #<(fontdata-$f8)
96         sta     ptr3
97         lda     ptr3+1
98         adc     #>(fontdata-$f8)
99         sta     ptr3+1
100
101         lda     CHARCOLOR
102         and     #1
103         beq     @skip_plane1
104
105         lda     #LCD_XPOS_PLANE1
106         clc
107         adc     CURS_X
108         sta     LCD_X
109
110         ldy     #$f8
111 @copylp1:
112         lda     (ptr3),y
113         eor     RVS
114         sta     LCD_DATA
115         iny
116         bne     @copylp1
117
118 @skip_plane1:
119
120         lda     CHARCOLOR
121         and     #2
122         beq     @skip_plane2
123
124         lda     #LCD_XPOS_PLANE2
125         clc
126         adc     CURS_X
127         sta     LCD_X
128
129         ldx     CURS_Y
130         lda     _plotlo,x
131         sta     LCD_Y
132
133         ldy     #$f8
134 @copylp2:
135         lda     (ptr3),y
136         eor     RVS
137         sta     LCD_DATA
138         iny
139         bne     @copylp2
140
141 @skip_plane2:
142
143
144         pla
145         tax
146         ldy     CURS_X
147         rts
148
149 ;-------------------------------------------------------------------------------
150 ; force the init constructor to be imported
151
152         .import initconio
153 conio_init      = initconio