forked from EtchedPixels/FUZIX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrt0.s
159 lines (149 loc) · 3.75 KB
/
crt0.s
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
; Ordering of segments for the linker.
; WRS: Note we list all our segments here, even though
; we don't use them all, because their ordering is set
; when they are first seen.
.area _CODE
.area _CODE2
.area _VIDEO
.area _CONST
.area _INITIALIZED
.area _DATA
.area _BSEG
.area _BSS
.area _HEAP
; note that areas below here may be overwritten by the heap at runtime, so
; put initialisation stuff in here
.area _FONT
.area _GSINIT
.area _GSFINAL
.area _INITIALIZER
.area _COMMONMEM
.area _DISCARD
; imported symbols
.globl _fuzix_main
.globl init_early
.globl init_hardware
.globl s__DATA
.globl l__DATA
.globl s__DISCARD
.globl l__DISCARD
.globl s__COMMONMEM
.globl l__COMMONMEM
.globl kstack_top
.globl start
; startup code
.area _CODE
;
; We have 0x88 bytes before the standard UZI start point, everyone
; breathe in
;
; Once the first loader block is called we are called via RST 0 each
; block end and we do the gui progress bar bits that wouldn't fit in
; the boot block
;
; On entry h is set to 0 and the top of screen is banked at 0x8000
;
track .equ 0xF1F4
progress: ; top bar
; bank then down 14 character lines
; and
ld de, #(0x8000+0x2760+312)
ld a, #font0
rst 0x18 ; choline
; progress bar
ld de, #(0x8000+0x2760+312+720)
rst 0x18 ; choline
ld de, #(0x8000+0x2760+312+720+8)
ld a, (track)
inc a
ld b, a
ld a, #fontX
rst 0x28 ; nchout
; bottom bar
ld de, #(0x8000+0x2760+312+2*720)
choline: rst 0x20 ; chout at 0x18
add a,#8
ld b, #10
rst 0x28 ; nchout
jr tail
chout: ld l, a ; chout at 0x20
ld bc, #8
ldir
ret
nop ; and nchout at 0x28
nchout: push bc
rst 0x20
pop bc
djnz nchout
tail2: add a, #8
ret
tail: rst 0x20
jr tail2
font0: .db 0x00, 0x00, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f
font1: .db 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
font2: .db 0x00, 0x00, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8
font3: .db 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f
font4: .db 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00
font5: .db 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8
fontX: .db 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00
font6: .db 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x00, 0x00
font7: .db 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00
font8: .db 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0x00, 0x00
.dw 0, 0
; Pad to 0x88 bytes
.db 0
;
; Once the loader completes it jumps here
;
; On entry - stack is somewhere high, video is in bank 4 to middle of
; bank 5 and the OS is loaded into banks 0-2
;
start:
ld sp, #kstack_top
;
; Move the common into place (our build tool
; moved INITIALIZED ready and then packed common after
; it)
;
ld hl, #s__DATA
ld de, #s__COMMONMEM
ld bc, #l__COMMONMEM
ldir
;
; Straight after that is the font. We need the font
; somewhere accessible when the display is mapped sp
; put it after the display. hl points at the font data
; need to copy it from common
;
call fontcopy
;
; This is followed by the DISCARD area
;
ld de, #s__DISCARD
ld bc, #l__DISCARD
ldir
;
; Zero the data area
;
ld hl, #s__DATA
ld de, #s__DATA + 1
ld bc, #l__DATA - 1
ld (hl), #0
ldir
call init_early
call init_hardware
call _fuzix_main
di
stop: halt
jr stop
;
; Keep this linked low as we will unmap a chunk of kernel to font copy
;
fontcopy: ld a, #0x85
out (0xf1), a ; font is linked high so clear of 16-32K
ld de, #23552 ; after roller ram
ld bc, #2048 ; 256x8 font
ldir
ld a, #0x81 ; put the kernel back
out (0xf1), a
ret ; and return into it