-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloader.asm
More file actions
127 lines (97 loc) · 1.48 KB
/
loader.asm
File metadata and controls
127 lines (97 loc) · 1.48 KB
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
;
; loader.asm
;
; Your ass is grass (tm)
;
; We'll use entry point 0x0563 for LD_BYTES so we don't get redirected
; through SA/LD-RET on completion.
define LD_BYTES 0x0556
org 25000
di
xor a
ld hl, 0x5800
push hl
pop de
inc de
ld bc, 0x2ff
ld (hl), a
ldir
; Load title screen
ld ix, 0x8000
ld de, 0x1b00
ld a, 0xff
scf
call LD_BYTES
; Copy it to screen RAM
ld hl, 0x8000
ld de, 0x4000
ld bc, 0x1b00
ldir
; Load main game
ld a, 0
call pagein
ld ix, 0x8000
ld de, 0x8000
ld a, 0xff
scf
call LD_BYTES
call detect_128k
ld a, (v_128k)
cp 0
jr z, start_game
; 128K detected - load music blocks
ld a, 1
call pagein
ld ix, 0xc000
ld de, 0x4000
ld a, 0xff
scf
call LD_BYTES
ld a, 3
call pagein
ld ix, 0xc000
ld de, 0x4000
ld a, 0xff
scf
call LD_BYTES
ld a, 0
call pagein
; Start game!
start_game
xor a
out (0xfe), a
jp 0x8000
detect_128k
xor a
ld bc, 0x7ffd
out (c), a
ld a, 0x55
ld (0xffff), a
ld a, 7
out (c), a
ld a, (0xffff)
cp 0x55
jr z, detect_128k_done
ld a, 1
ld (v_128k), a
detect_128k_done
ret
; We always want ROM 0 to be in place.
; So, we'll first write to 1FFD just in
; case we're on a +2A or +3, then do the
; proper write to 7FFD.
pagein
push af
ld bc, 0x1ffd
ld a, 0x04 ; ROM 3 - 48K BASIC
out (c), a
pop af
and 0x07
ld b, a
ld a, 0x10
or b
ld bc, 0x7ffd
out (c), a
ret
v_128k
defb 0 ; 128K Detection flag