]> git.sur5r.net Git - cc65/blob - libsrc/cbm610/cputc.s
Added strftime
[cc65] / libsrc / cbm610 / 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         .exportzp       CURS_X, CURS_Y
11         .import         _gotoxy
12         .import         popa
13         .import         xsize, revers
14
15         .include        "cbm610.inc"
16         .include        "../cbm/cbm.inc"
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     #$0A            ; CR?
27         bne     L1
28         lda     #0
29         sta     CURS_X
30         beq     plot            ; Recalculate pointers
31
32 L1:     cmp     #$0D            ; LF?
33         beq     newline         ; Recalculate pointers
34
35 ; Printable char of some sort
36
37         cmp     #' '
38         bcc     cputdirect      ; Other control char
39         tay
40         bmi     L10
41         cmp     #$60
42         bcc     L2
43         and     #$DF
44         bne     cputdirect      ; Branch always
45 L2:     and     #$3F
46
47 cputdirect:
48         jsr     putchar         ; Write the character to the screen
49
50 ; Advance cursor position
51
52 advance:
53         iny
54         cpy     xsize
55         bne     L3
56         jsr     newline         ; new line
57         ldy     #0              ; + cr
58 L3:     sty     CURS_X
59         rts
60
61 newline:
62         clc
63         lda     xsize
64         adc     CharPtr
65         sta     CharPtr
66         bcc     L4
67         inc     CharPtr+1
68 L4:     inc     CURS_Y
69         rts
70
71 ; Handle character if high bit set
72
73 L10:    and     #$7F
74         cmp     #$7E            ; PI?
75         bne     L11
76         lda     #$5E            ; Load screen code for PI
77         bne     cputdirect
78 L11:    ora     #$40
79         bne     cputdirect      ; Branch always
80
81 ; Set cursor position, calculate RAM pointers
82
83 plot:   ldy     CURS_X
84         ldx     CURS_Y
85         clc
86         jmp     PLOT
87
88 ; Write one character to the screen without doing anything else, return X
89 ; position in Y
90
91 putchar:
92         ldx     IndReg
93         ldy     #$0F
94         sty     IndReg
95         ora     revers          ; Set revers bit
96         ldy     CURS_X
97         sta     (CharPtr),y     ; Set char
98         stx     IndReg
99         rts
100
101