]> git.sur5r.net Git - cc65/blob - libsrc/pce/conio.s
more cleanup and fixing
[cc65] / libsrc / pce / conio.s
1                 .include "pce.inc"
2
3                 .import vce_init
4                 .import psg_init
5                 .import vdc_init
6
7                 .export initconio
8
9                 .constructor initconio, 24
10
11                 .macpack longbranch
12 initconio:
13 ;;              jsr     vdc_init
14                 jsr     vce_init
15                 jsr     psg_init
16                 jsr     conio_init
17                 jsr     set_palette
18
19                 st0     #VDC_RCR
20                 st1     #<$0088
21                 st2     #>$0088
22                 rts
23
24                 .import colors
25 set_palette:
26                 stz     VCE_ADDR_LO
27                 stz     VCE_ADDR_HI
28
29                 ldx #0
30 @lp:
31                 .repeat 16
32                 lda colors,x
33                 sta     VCE_DATA_LO
34                 lda colors+1,x
35                 sta     VCE_DATA_HI
36                 .endrepeat
37
38                 inx
39                 inx
40                 cpx #16*2
41                 jne @lp
42
43                 stz     VCE_ADDR_LO
44                 stz     VCE_ADDR_HI
45                 stz     VCE_DATA_LO
46                 stz     VCE_DATA_HI
47
48                 rts
49
50 ;----------------------------------------------------------------------------
51 ;
52 ;----------------------------------------------------------------------------
53
54                 .importzp ptr1
55 conio_init:
56                 ; Load font
57                 st0     #VDC_MAWR
58                 st1     #<$2000
59                 st2     #>$2000
60
61                 ; ptr to font data
62                 lda     #<font
63                 sta             ptr1
64                 lda     #>font
65                 sta             ptr1+1
66
67                 st0     #VDC_VWR            ; VWR
68                 ldy     #$80            ; 128 chars
69 charloop:       ldx     #$08            ; 8 bytes/char
70 lineloop:
71                 lda (ptr1)
72                 staio   VDC_DATA_LO       ; bitplane 0
73                 stzio   VDC_DATA_HI       ; bitplane 1
74
75                 clc                     ; increment font pointer
76                 lda     ptr1
77                 adc     #$01
78                 sta     ptr1
79                 lda     ptr1+1
80                 adc     #$00
81                 sta     ptr1+1
82                 dex
83                 bne     lineloop        ; next bitplane 0 byte
84                 ldx     #$08            ; fill bitplane 2/3 with 0
85 fillloop:       st1     #$00
86                 st2     #$00
87                 dex
88                 bne     fillloop        ; next byte
89                 dey
90                 bne     charloop        ; next character
91
92                 ldx #0
93                 stx     BGCOLOR
94                 inx
95                 stx     CHARCOLOR
96
97
98                 rts
99
100                 .rodata
101 font:
102                 .include "vga.inc"