]> git.sur5r.net Git - cc65/blob - libsrc/pce/cputc.s
Add sample linker configurations for Atari binary output in C.
[cc65] / libsrc / pce / cputc.s
1 ;
2 ; void cputcxy (unsigned char x, unsigned char y, char c);
3 ; void cputc (char c);
4 ;
5
6         .export         _cputcxy, _cputc, cputdirect, putchar
7         .export         newline, plot
8         .forceimport    initconio       ; force conio initiation
9
10         .import         gotoxy
11         .import         PLOT
12         .import         xsize
13         .importzp       tmp3, tmp4
14
15         .include        "pce.inc"
16         .include        "extzp.inc"
17
18 _cputcxy:
19         pha                     ; Save C
20         jsr     gotoxy          ; Set cursor, drop x and y
21         pla                     ; Restore C
22
23 ; Plot a character - also used as internal function
24
25 _cputc: cmp     #$0D            ; CR?
26         bne     L1
27         stz     CURS_X
28         bra     plot            ; Recalculate pointer
29
30 L1:     cmp     #$0A            ; LF?
31         beq     newline         ; Recalculate pointer
32
33 ; Printable char of some sort
34
35 cputdirect:
36         jsr     putchar         ; Write the character to the screen
37
38 ; Move the cursor (rightwards) to the next position.
39
40 advance:
41         ldy     CURS_X
42         iny
43         cpy     xsize
44         bne     L3
45         inc     CURS_Y          ; new line
46         cly                     ; + CR
47 L3:     sty     CURS_X
48
49 ; Set cursor position; calculate VRAM pointer.
50
51 plot:   ldy     CURS_X
52         ldx     CURS_Y
53         clc
54         jmp     PLOT            ; Set the new cursor
55
56 newline:
57         inc     CURS_Y
58         bra     plot
59
60 ; Write one character to the screen without doing anything else.
61
62 putchar:
63         ora     RVS             ; Set reverse bit
64
65         st0     #VDC_MAWR       ; Memory-Address Write
66         ldy     SCREEN_PTR
67         ldx     SCREEN_PTR+1
68         sty     VDC_DATA_LO
69         stx     VDC_DATA_HI
70
71         st0     #VDC_VWR
72         sta     VDC_DATA_LO     ; character
73
74         lda     CHARCOLOR       ; pallette number
75         asl     a
76         asl     a
77         asl     a
78         asl     a
79         ora     #>$0200         ; high nybble of char. index
80         sta     VDC_DATA_HI
81
82         rts