]> git.sur5r.net Git - cc65/blob - libsrc/atari/cputc.s
Added SER_ prefix. Whitespace cleanup
[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         gotoxy, mul40
11         .importzp       tmp4,ptr4
12         .import         _revflag,setcursor
13
14         .include        "atari.inc"
15
16 _cputcxy:
17         pha                     ; Save C
18         jsr     gotoxy          ; Set cursor, drop x and y
19         pla                     ; Restore C
20
21 _cputc:
22         cmp     #$0D            ; CR
23         bne     L4
24         lda     #0
25         sta     COLCRS
26         beq     plot            ; return
27
28 L4:     cmp     #$0A            ; LF
29         beq     newline
30         cmp     #ATEOL          ; Atari-EOL?
31         beq     newline
32
33         tay
34         rol     a
35         rol     a
36         rol     a
37         rol     a
38         and     #3
39         tax
40         tya
41         and     #$9f
42         ora     ataint,x
43
44 cputdirect:                     ; accepts screen code
45         jsr     putchar
46
47 ; advance cursor
48         inc     COLCRS
49         lda     COLCRS
50         cmp     #40
51         bcc     plot
52         lda     #0
53         sta     COLCRS
54
55         .export newline
56 newline:
57         inc     ROWCRS
58         lda     ROWCRS
59         cmp     #24
60         bne     plot
61         lda     #0
62         sta     ROWCRS
63 plot:   jsr     setcursor
64         ldy     COLCRS
65         ldx     ROWCRS
66         rts
67
68 ; turn off cursor, update screen, turn on cursor
69 putchar:
70         pha                     ; save char
71
72         ldy     #0
73         lda     OLDCHR
74         sta     (OLDADR),y
75
76         lda     ROWCRS
77         jsr     mul40           ; destroys tmp4
78         clc
79         adc     SAVMSC          ; add start of screen memory
80         sta     ptr4
81         txa
82         adc     SAVMSC+1
83         sta     ptr4+1
84         pla                     ; get char again
85
86         ora     _revflag
87         sta     OLDCHR
88
89         ldy     COLCRS
90         sta     (ptr4),y
91         jmp     setcursor
92
93         .rodata
94 ataint: .byte   64,0,32,96