]> git.sur5r.net Git - cc65/blob - libsrc/c64/soft80_conio.s
some code shuffling to get rid of long branches
[cc65] / libsrc / c64 / soft80_conio.s
1 ;
2 ; Groepaz/Hitmen, 11.10.2015
3 ;
4 ; Low level init code for soft80 screen output/console input
5 ;
6
7         .constructor    soft80_init
8         .destructor     soft80_shutdown
9
10         .import         soft80_kclrscr, soft80_charset
11         .export         soft80_internal_textcolor, soft80_internal_bgcolor
12         .export         soft80_internal_cursorxlsb
13
14         .importzp       ptr1, ptr2, ptr3
15
16         .include        "c64.inc"
17         .include        "soft80.inc"
18
19 soft80_init:
20         lda     #$3b
21         sta     VIC_CTRL1
22         lda     #$00
23         sta     CIA2_PRA
24         lda     #$68
25         sta     VIC_VIDEO_ADR
26         lda     #$c8
27         sta     VIC_CTRL2
28
29         ; copy charset to RAM under I/O
30         ; FIXME: move charset and this constructor into init segment
31         sei
32         lda     $01
33         pha
34         lda     #$34
35         sta     $01
36
37         lda     #>soft80_charset
38         sta     ptr1+1
39         lda     #<soft80_charset
40         sta     ptr1
41         lda     #>soft80_lo_charset
42         sta     ptr2+1
43         lda     #<soft80_lo_charset
44         sta     ptr2
45         lda     #>soft80_hi_charset
46         sta     ptr3+1
47         lda     #<soft80_hi_charset
48         sta     ptr3
49
50         ldx     #4
51 @l2:
52         ldy     #0
53 @l1:
54         lda     (ptr1),y
55         sta     (ptr2),y
56         asl     a
57         asl     a
58         asl     a
59         asl     a
60         sta     (ptr3),y
61         iny
62         bne     @l1
63         inc     ptr1+1
64         inc     ptr2+1
65         inc     ptr3+1
66         dex
67         bne     @l2
68
69         pla
70         sta     $01
71         cli
72
73         ; the "color voodoo" in other parts of the code relies on the vram and
74         ; colorram being set up as expected, which is why we cant use the
75         ; _bgcolor and _textcolor functions here.
76
77         lda     646                             ; use current textcolor
78         and     #$0f
79         sta     soft80_internal_textcolor
80
81         lda     VIC_BG_COLOR0                   ; use current bgcolor
82         and     #$0f
83         sta     soft80_internal_bgcolor
84         asl     a
85         asl     a
86         asl     a
87         asl     a
88         ora     soft80_internal_textcolor
89         sta     CHARCOLOR
90
91         jmp     soft80_kclrscr
92
93 soft80_shutdown:
94         lda     #$1b
95         sta     VIC_CTRL1
96         lda     #$03
97         sta     CIA2_PRA
98         lda     #$15
99         sta     VIC_VIDEO_ADR
100         rts
101
102 ;-------------------------------------------------------------------------------
103 ; FIXME: when the code is fixed to use the "init" segment, these variables must
104 ;        be moved into a section other than .bss so they survive after the init
105 ;        code has been run.
106
107         .bss
108 soft80_internal_textcolor:
109         .res 1
110 soft80_internal_bgcolor:
111         .res 1
112 soft80_internal_cursorxlsb:
113         .res 1
114