File: cputc.s

package info (click to toggle)
cc65 2.19-2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 20,268 kB
  • sloc: ansic: 117,151; asm: 66,339; pascal: 4,248; makefile: 1,009; perl: 607
file content (93 lines) | stat: -rw-r--r-- 2,247 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
;
; adapted from Atari version
; Christian Groessler, 2014
;
; void cputcxy (unsigned char x, unsigned char y, char c);
; void cputc (char c);
;

        .include        "atari5200.inc"

        .export         _cputcxy, _cputc
        .export         plot, cputdirect, putchar
        .import         gotoxy, _mul20
        .import         conio_color
        .importzp       screen_width, screen_height
        .importzp       ptr4

        .import         screen_setup
        .constructor    initconio
initconio               =       screen_setup

_cputcxy:
        pha                     ; Save C
        jsr      gotoxy         ; Set cursor, drop x and y
        pla                     ; Restore C

_cputc:
        cmp     #$0D            ; CR
        bne     L4
        lda     #0
        sta     COLCRS_5200
        beq     plot            ; return

L4:     cmp     #$0A            ; LF
        beq     newline
        cmp     #ATEOL          ; Atari-EOL?
        beq     newline

        tay
        rol     a
        rol     a
        rol     a
        rol     a
        and     #3
        tax
        tya
        and     #$9F
        ora     ataint,x

cputdirect:                     ; accepts screen code
        jsr     putchar

; advance cursor
        inc     COLCRS_5200
        lda     COLCRS_5200
        cmp     #screen_width
        bcc     plot
        lda     #0
        sta     COLCRS_5200

        .export newline
newline:
        inc     ROWCRS_5200
        lda     ROWCRS_5200
        cmp     #screen_height
        bne     plot
        lda     #0
        sta     ROWCRS_5200
plot:   ldy     COLCRS_5200
        ldx     ROWCRS_5200
        rts

putchar:
        pha                     ; save char

        lda     ROWCRS_5200
        jsr     _mul20          ; destroys tmp4, carry is cleared
        adc     SAVMSC          ; add start of screen memory
        sta     ptr4
        txa
        adc     SAVMSC+1
        sta     ptr4+1
        pla                     ; get char again

        and     #$3F            ; clear palette index bits
        ora     conio_color     ; use currently selected palette

        ldy     COLCRS_5200
        sta     (ptr4),y
        rts

        .rodata
ataint: .byte   64,0,32,96