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 (54 lines) | stat: -rw-r--r-- 1,340 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
; 2018-04-13, Jede (jede@oric.org)
;

; void cputc (char c);
;

        .export         _cputc, CHARCOLOR, OLD_CHARCOLOR, BGCOLOR, OLD_BGCOLOR

        .include        "telestrat.inc"

.proc _cputc
    ldx     CHARCOLOR
    cpx     OLD_CHARCOLOR
    beq     do_not_change_color_foreground
    
    stx     OLD_CHARCOLOR         ; Store CHARCOLOR into OLD_CHARCOLOR

    dec     SCRX
    dec     SCRX

    pha
    txa                           ; Swap X to A because, X contains CHARCOLOR
    BRK_TELEMON  XFWR             ; Change color on the screen (foreground)
    inc     SCRX
    pla

do_not_change_color_foreground:
    ldx     BGCOLOR
    cpx     OLD_BGCOLOR
    beq     do_not_change_color

    stx     OLD_BGCOLOR

    dec     SCRX                 ; Dec SCRX in order to place attribute before the right position

    pha
    txa                          ; Swap X to A because, X contains BGCOLOR
    ORA     #%00010000           ; Add 16 because background color is an attribute between 16 and 23. 17 is red background for example
    BRK_TELEMON  XFWR            ; Change color on the screen (background)
    pla

do_not_change_color:
    BRK_TELEMON  XFWR            ; Macro send char to screen (channel 0)
    rts
.endproc
.bss
CHARCOLOR:
    .res 1
OLD_CHARCOLOR:
    .res 1    
BGCOLOR:
    .res 1    
OLD_BGCOLOR:
    .res 1