]> git.sur5r.net Git - cc65/blob - libsrc/atari/cputc.s
652c6589dd88c145b654629383ba09c2bb855e3c
[cc65] / libsrc / atari / cputc.s
1 ;
2 ; Mark Keates, Christian Groessler
3 ;
4 ; void cputcxy (unsigned char x, unsigned char y, char c);
5 ; void cputc (char c);
6 ;
7
8         .export         _cputcxy, _cputc
9         .export         plot, cputdirect, putchar
10         .import         popa, _gotoxy, mul40
11         .importzp       tmp4,ptr4
12         .import         _revflag
13
14         .include        "atari.inc"
15
16 _cputcxy:
17         pha                     ; Save C
18         jsr     popa            ; Get Y
19         jsr     _gotoxy         ; Set cursor, drop x
20         pla                     ; Restore C
21
22 _cputc:
23         cmp     #$0D            ; CR
24         bne     L4
25         lda     #0
26         sta     COLCRS
27         beq     plot            ; return
28         
29 L4:     cmp     #$0A            ; LF
30         beq     newline
31         cmp     #ATEOL          ; Atari-EOL?
32         beq     newline
33
34         tay
35         rol     a
36         rol     a
37         rol     a
38         rol     a
39         and     #3
40         tax
41         tya
42         and     #$9f
43         ora     ataint,x
44
45 cputdirect:                     ; accepts screen code
46         jsr     putchar
47         
48 ; advance cursor
49         inc     COLCRS
50         lda     COLCRS
51         cmp     #40
52         bcc     plot
53         lda     #0
54         sta     COLCRS
55
56         .export newline
57 newline:
58         inc     ROWCRS
59         lda     ROWCRS
60         cmp     #24
61         bne     plot
62         lda     #0
63         sta     ROWCRS
64 plot:   ldy     COLCRS
65         ldx     ROWCRS
66         rts
67
68 putchar:
69         pha                     ; save char
70         lda     ROWCRS
71         jsr     mul40
72 L3:     clc
73         adc     SAVMSC          ; add start of screen memory
74         sta     ptr4
75         lda     tmp4
76         adc     SAVMSC+1
77         sta     ptr4+1
78         pla                     ; get char again
79         ora     _revflag
80         ldy     COLCRS
81         sta     (ptr4),y
82         rts
83
84         .rodata
85 ataint: .byte   64,0,32,96
86