]> git.sur5r.net Git - cc65/blob - libsrc/c64/soft80mono_conio.s
AtariOS: Fix for FPIDX enum
[cc65] / libsrc / c64 / soft80mono_conio.s
1 ;
2 ; Groepaz/Hitmen, 19.10.2015
3 ;
4 ; Low level init code for the monochrome soft80 screen output/console input
5 ;
6
7         .constructor    soft80mono_init, 8
8         .destructor     soft80mono_shutdown
9
10         .import         soft80mono_kclrscr, soft80_charset
11         .export         soft80mono_internal_bgcolor, soft80mono_internal_cellcolor
12         .export         soft80mono_internal_cursorxlsb
13         .export         soft80mono_internal_nibble
14
15         .importzp       ptr1, ptr2, ptr3
16
17         .include        "c64.inc"
18         .include        "soft80.inc"
19
20 soft80mono_init:
21         lda     soft80mono_first_init
22         bne     @skp
23         jsr     firstinit
24 @skp:
25         ; the "color voodoo" in other parts of the code relies on the vram and
26         ; colorram being set up as expected, which is why we cant use the
27         ; _bgcolor and _textcolor functions here.
28
29         lda     CHARCOLOR                       ; use current textcolor
30         and     #$0f                            ; make sure the upper nibble is 0s
31         sta     CHARCOLOR
32
33         lda     VIC_BG_COLOR0                   ; use current bgcolor
34         and     #$0f
35         sta     soft80mono_internal_bgcolor
36         asl     a
37         asl     a
38         asl     a
39         asl     a
40         ora     CHARCOLOR
41         sta     soft80mono_internal_cellcolor
42
43         lda     #$3b
44         sta     VIC_CTRL1
45         lda     #$00
46         sta     CIA2_PRA
47         lda     #$68
48         sta     VIC_VIDEO_ADR
49         lda     #$c8
50         sta     VIC_CTRL2
51
52         jmp     soft80mono_kclrscr
53
54 soft80mono_shutdown:
55         lda     #$1b
56         sta     VIC_CTRL1
57         lda     #$03
58         sta     CIA2_PRA
59         lda     #$15
60         sta     VIC_VIDEO_ADR
61         rts
62
63         .segment "ONCE"
64 firstinit:
65         ; copy charset to RAM under I/O
66         sei
67         lda     $01
68         pha
69         lda     #$34
70         sta     $01
71
72         inc     soft80mono_first_init
73
74         lda     #>soft80_charset
75         sta     ptr1+1
76         lda     #<soft80_charset
77         sta     ptr1
78         lda     #>soft80_lo_charset
79         sta     ptr2+1
80         lda     #<soft80_lo_charset
81         sta     ptr2
82         lda     #>soft80_hi_charset
83         sta     ptr3+1
84         lda     #<soft80_hi_charset
85         sta     ptr3
86
87         ldx     #4
88 @l2:
89         ldy     #0
90 @l1:
91         lda     (ptr1),y
92         sta     (ptr2),y
93         asl     a
94         asl     a
95         asl     a
96         asl     a
97         sta     (ptr3),y
98         iny
99         bne     @l1
100         inc     ptr1+1
101         inc     ptr2+1
102         inc     ptr3+1
103         dex
104         bne     @l2
105
106         ; copy the kplot tables to ram under I/O
107         ;ldx     #0              ; is 0
108 @l3:
109         lda     soft80_tables_data_start,x
110         sta     soft80_bitmapxlo,x
111         lda     soft80_tables_data_start + (soft80_tables_data_end - soft80_tables_data_start - $100) ,x
112         sta     soft80_bitmapxlo + (soft80_tables_data_end - soft80_tables_data_start - $100),x
113         inx
114         bne     @l3
115
116         pla
117         sta     $01
118         cli
119         rts
120
121 ; the following tables take up 267 bytes, used by kplot
122 soft80_tables_data_start:
123
124 soft80_bitmapxlo_data:
125         .repeat 80,col
126         .byte <((col/2)*8)
127         .endrepeat
128 soft80_bitmapxhi_data:
129         .repeat 80,col
130         .byte >((col/2)*8)
131         .endrepeat
132 soft80_vramlo_data:
133         .repeat 25,row
134         .byte <(soft80_vram+(row*40))
135         .endrepeat
136         .byte 0,0,0,0,0,0,0     ; padding to next page
137 soft80_vramhi_data:
138         .repeat 25,row
139         .byte >(soft80_vram+(row*40))
140         .endrepeat
141 soft80_bitmapylo_data:
142         .repeat 25,row
143         .byte <(soft80_bitmap+(row*40*8))
144         .endrepeat
145 soft80_bitmapyhi_data:
146         .repeat 25,row
147         .byte >(soft80_bitmap+(row*40*8))
148         .endrepeat
149
150 soft80_tables_data_end:
151
152 ;-------------------------------------------------------------------------------
153         .segment "INIT"
154 soft80mono_internal_cellcolor:
155         .res 1
156 soft80mono_internal_bgcolor:
157         .res 1
158 soft80mono_internal_cursorxlsb:
159         .res 1
160
161         .data
162 soft80mono_first_init:
163         .byte 0         ; flag to check first init, this really must be in .data
164
165         .rodata
166 soft80mono_internal_nibble:
167         .byte $f0, $0f
168