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