]> git.sur5r.net Git - cc65/blob - libsrc/c1p/cputc.s
Remove unnecessary commented code.
[cc65] / libsrc / c1p / cputc.s
1 ;
2 ; cputc/cputcxy for Challenger 1P
3 ; Based on PET/CBM implementation
4 ;
5 ; void cputcxy (unsigned char x, unsigned char y, char c);
6 ; void cputc (char c);
7 ;
8         .export         _cputcxy, _cputc, cputdirect, putchar
9         .export         newline, plot
10         .import         popa, _gotoxy
11
12         .include        "c1p.inc"
13         .include        "extzp.inc"
14
15 _cputcxy:
16         pha                     ; Save C
17         jsr     popa            ; Get Y
18         jsr     _gotoxy         ; Set cursor, drop x
19         pla                     ; Restore C
20
21 ; Plot a character - also used as internal function
22
23 _cputc: cmp     #$0A            ; CR?
24         bne     L1
25         lda     #0
26         sta     CURS_X
27         beq     plot            ; Recalculate pointers
28
29 L1:     cmp     #$0D            ; LF?
30         beq     newline         ; Recalculate pointers
31
32 cputdirect:
33         jsr     putchar         ; Write the character to the screen
34
35 ; Advance cursor position
36
37 advance:
38         cpy     SCR_LINELEN     ; xsize-1
39         bne     L3
40         jsr     newline         ; new line
41         ldy     #$FF            ; + cr
42 L3:     iny
43         sty     CURS_X
44         rts
45
46 newline:
47         lda     SCR_LINELEN     ; xsize-1
48         sec                     ; Account for -1 above
49         adc     SCREEN_PTR
50         sta     SCREEN_PTR
51         bcc     L4
52         inc     SCREEN_PTR+1
53 L4:     inc     CURS_Y
54         rts
55
56 plot:   ldy     CURS_Y
57         lda     ScrLo,y
58         sta     SCREEN_PTR
59         lda     ScrHi,y
60         sta     SCREEN_PTR+1
61         rts
62
63 ; Write one character to the screen without doing anything else, return X
64 ; position in Y
65
66 putchar:
67         ldy     CURS_X
68         sta     (SCREEN_PTR),y  ; Set char
69         rts
70
71 ; Screen address tables - offset to real screen
72
73 .rodata
74
75 ScrLo:  .byte   $83, $A3, $C3, $E3, $03, $23, $43, $63
76         .byte   $83, $A3, $C3, $E3, $03, $23, $43, $63
77         .byte   $83, $A3, $C3, $E3, $03, $23, $43, $63
78         .byte   $83
79
80 ScrHi:  .byte   $D0, $D0, $D0, $D0, $D1, $D1, $D1, $D1
81         .byte   $D1, $D1, $D1, $D1, $D2, $D2, $D2, $D2
82         .byte   $D2, $D2, $D2, $D2, $D3, $D3, $D3, $D3
83         .byte   $D3