]> git.sur5r.net Git - cc65/blob - libsrc/pce/conio.s
Fixed bugs; and, improved the efficiency of some pce library functions.
[cc65] / libsrc / pce / conio.s
1         .constructor    initconio, 24
2
3         .import         vdc_init
4         .import         psg_init
5         .import         colors
6         .importzp       ptr1, tmp1
7
8         .include        "pce.inc"
9         .include        "extzp.inc"
10
11         .segment        "ONCE"
12 initconio:
13         jsr     vdc_init
14         jsr     psg_init
15         jsr     load_font
16
17 set_palette:
18         stz     VCE_ADDR_LO
19         stz     VCE_ADDR_HI
20
21         clx
22 @lp:    ldy     #16             ; size of a palette
23
24 @lp1:   lda     colors,x
25         sta     VCE_DATA_LO
26         lda     colors+1,x
27         sta     VCE_DATA_HI
28         dey
29         bne     @lp1
30
31         inx
32         inx
33         cpx     #16 * 2         ; 16 palettes
34         bne     @lp
35
36         sty     BGCOLOR         ; white on black
37         iny
38         sty     CHARCOLOR
39
40         VREG    VDC_CR, $0088   ; enable background and vertical-blank interrupt
41         rts
42
43 ; Load the conio font into the VDC.
44 load_font:
45         VREG    VDC_MAWR, $2000
46         st0     #VDC_VWR
47
48         stz     tmp1            ; #%00000000
49         bsr     copy            ; make normal characters
50
51         dec     tmp1            ; #%11111111
52 ;       bsr     copy            ; make reversed characters
53 ;       rts                     ; (fall through)
54
55 ; Point to the font data.
56 copy:   lda     #<font
57         ldx     #>font
58         sta     ptr1
59         stx     ptr1+1
60
61         ldy     #$80            ; 128 chars
62 charloop:
63         ldx     #$08            ; 8 bytes/char
64 lineloop:
65         lda     (ptr1)
66         eor     tmp1
67         sta     VDC_DATA_LO     ; bitplane 0
68         st2     #>$0000         ; bitplane 1
69
70         inc     ptr1            ; increment font pointer
71         bne     @noC
72         inc     ptr1+1
73 @noC:   dex
74         bne     lineloop        ; next bitplane-0 byte
75
76         ldx     #$08            ; fill bitplanes 2 and 3 with 0
77 fillloop:
78         st1     #<$0000
79         st2     #>$0000
80         dex
81         bne     fillloop        ; next byte
82
83         dey
84         bne     charloop        ; next character
85
86         rts
87
88 .rodata
89 font:   .include        "vga.inc"