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