]> git.sur5r.net Git - cc65/blob - libsrc/atmos/cputc.s
Removed (pretty inconsistently used) tab chars from source code base.
[cc65] / libsrc / atmos / cputc.s
1 ;
2 ; Ullrich von Bassewitz, 2003-04-13
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         setscrptr, putchar
10         .import         rvs
11         .import         popax
12         .importzp       ptr2
13
14         .include        "atmos.inc"
15
16
17 _cputcxy:
18         pha                     ; Save C
19         jsr     popax           ; Get X and Y
20         sta     CURS_Y          ; Store Y
21         stx     CURS_X          ; Store 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          ; Carriage return
30         rts
31
32 L1:     cmp     #$0A            ; LF?
33         bne     output
34         inc     CURS_Y          ; Newline
35         rts
36
37 ; Output the character, then advance the cursor position
38
39 output:
40         jsr     putchar
41
42 advance:
43         iny
44         cpy     #40
45         bne     L3
46         inc     CURS_Y          ; new line
47         ldy     #0              ; + cr
48 L3:     sty     CURS_X
49         rts
50
51 ; ------------------------------------------------------------------------
52 ; Set ptr2 to the screen, load the X offset into Y
53
54 .code
55 .proc   setscrptr
56
57         ldy     CURS_Y          ; Get line number into Y
58         lda     ScrTabLo,y      ; Get low byte of line address
59         sta     ptr2
60         lda     ScrTabHi,y      ; Get high byte of line address
61         sta     ptr2+1
62         ldy     CURS_X          ; Get X offset
63         rts
64
65 .endproc
66
67 ; ------------------------------------------------------------------------
68 ; Write one character to the screen without doing anything else, return X
69 ; position in Y
70
71 .code
72 .proc   putchar
73
74         ora     rvs             ; Set revers bit
75         pha                     ; And save
76         jsr     setscrptr       ; Set ptr2 to the screen
77         pla                     ; Restore the character
78         sta     (ptr2),y        ; Set char
79         rts
80
81 .endproc
82
83 ; ------------------------------------------------------------------------
84 ; Screen address table
85
86 .rodata
87 ScrTabLo:
88         .repeat 28, Line
89                 .byte   <(SCREEN + Line * 40)
90         .endrep
91
92 ScrTabHi:
93         .repeat 28, Line
94                 .byte   >(SCREEN + Line * 40)
95         .endrep
96