/
loader.dasm
69 lines (50 loc) · 1.15 KB
/
loader.dasm
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
; Loads a program from Y to Z at address 0
; I must be 0
:loader
:loader_loop0
sti [I], [Y]
add Y, 1
ifn Y, Z
set PC, 0xE000 ;Let's go back to the loop (can't use loader_loop0 because the address changes while copying lodaer)
; We don't have to clear the RAM, since BOLD is one sector long, so it's already overwritten by now.
; We don't reset A since it holds the current drive
set B, 0
set C, 0
set X, 0
set Y, 0
set Z, 0
set I, 0
set J, 0
set EX, 0
set PC, 0
:loader_end
; =================
; Load from floppy
; =================
:loadFloppy
set I, [selected]
ife [drives_compatible + I], 0
set PC, mainLoop
; -----------------
; Reading into mem
; -----------------
set I, [selected]
set A, 2
set X, 0 ; Sector to read
set Y, 0xA000
hwi [drives + I]
ifn B, 1
set PC, mainLoop
jsr loadFloppy_waitFinish
; -------------
; Booting...
; -------------
; We can load the program into the memory
set I, 0
set Y, 0xA000
set Z, 1 ;Number of sectors the program takes
mul Z, 0x200
add Z, 0xA000
jsr clear
set A, [selected] ; So the program knows from which drive to boot
set PC, 0xE000 ;We can now load the program !