File: conio.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 (89 lines) | stat: -rw-r--r-- 2,102 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
        .constructor    initconio, 24

        .import         vdc_init
        .import         psg_init
        .import         colors
        .importzp       ptr1, tmp1

        .include        "pce.inc"
        .include        "extzp.inc"

        .segment        "ONCE"
initconio:
        jsr     vdc_init
        jsr     psg_init
        jsr     load_font

set_palette:
        stz     VCE_ADDR_LO
        stz     VCE_ADDR_HI

        clx
@lp:    ldy     #16             ; size of a palette

@lp1:   lda     colors,x
        sta     VCE_DATA_LO
        lda     colors+1,x
        sta     VCE_DATA_HI
        dey
        bne     @lp1

        inx
        inx
        cpx     #16 * 2         ; 16 palettes
        bne     @lp

        sty     BGCOLOR         ; white on black
        iny
        sty     CHARCOLOR

        VREG    VDC_CR, $0088   ; enable background and vertical-blank interrupt
        rts

; Load the conio font into the VDC.
load_font:
        VREG    VDC_MAWR, $2000
        st0     #VDC_VWR

        stz     tmp1            ; #%00000000
        bsr     copy            ; make normal characters

        dec     tmp1            ; #%11111111
;       bsr     copy            ; make reversed characters
;       rts                     ; (fall through)

; Point to the font data.
copy:   lda     #<font
        ldx     #>font
        sta     ptr1
        stx     ptr1+1

        ldy     #$80            ; 128 chars
charloop:
        ldx     #$08            ; 8 bytes/char
lineloop:
        lda     (ptr1)
        eor     tmp1
        sta     VDC_DATA_LO     ; bitplane 0
        st2     #>$0000         ; bitplane 1

        inc     ptr1            ; increment font pointer
        bne     @noC
        inc     ptr1+1
@noC:   dex
        bne     lineloop        ; next bitplane-0 byte

        ldx     #$08            ; fill bitplanes 2 and 3 with 0
fillloop:
        st1     #<$0000
        st2     #>$0000
        dex
        bne     fillloop        ; next byte

        dey
        bne     charloop        ; next character

        rts

.rodata
font:   .include        "vga.inc"