-
Notifications
You must be signed in to change notification settings - Fork 0
/
TOTALBMP.ASM
277 lines (219 loc) · 5.04 KB
/
TOTALBMP.ASM
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
output "TOTALBMP.ROM"
defpage 0,0x4000, 0x2000 ; page 0 main code
defpage 1,0x6000, 0x2000 ; page 1
defpage 2..31 ; swapped data
; konami scc
_kBank1: equ 05000h ;- 57FFh (5000h used)
_kBank2: equ 07000h ;- 77FFh (7000h used)
_kBank3: equ 09000h ;- 97FFh (9000h used)
_kBank4: equ 0B000h ;- B7FFh (B000h used)
MACRO VDP_SetReg register ;Set value A in the specified register
di
out (#99),a
ld a,register+128
out (#99),a
ei
ENDM
page 0
org 4000h
dw 4241h,START,0,0,0,0,0,0
; make happy the map guessers
ld (_kBank1),a
ld (_kBank2),a
ld (_kBank3),a
ld (_kBank4),a
screeninit:
ld a,8
call 005fh
di
ld a,#0A
out (#99),a
ld a,#88
out (#99),a ; no sprites
ld a,#1F
out (#99),a
ld a,#82
out (#99),a ; set page 0
ei
ld hl,0h
call 0053h
ld de,256*:_opening+8+8
2: ld a,d
ld (_kBank2),a
ld hl,0x6000
ld bc,0x98
ld a,32
1: otir
dec a
jp nz,1b
inc d
dec e
jr nz,2b
ret
;
; Wait until the VDP is done copying.
;
VDP_Ready:
ld a,2
di
out (#99),a ;select s#2
ld a,15+128
out (#99),a
in a,(#99)
rra
ld a,0 ;select s#0
out (#99),a
ld a,15+128
ei
out (#99),a
jp c,VDP_Ready
ret
START:
call screeninit
mode7YMMM:
xor a
VDP_SetReg 34 ; R34 = 0 ; source page for ground
ld a,1
VDP_SetReg 35 ; R35 = 1 ; source page for ground
xor a
VDP_SetReg 36 ; R36 = 0
xor a
VDP_SetReg 37 ; R37 = 0 ; DX = 0
ld a,1
VDP_SetReg 42 ; R42 = 1 ; NYl = 1
xor a
VDP_SetReg 43 ; R43 = 0 ; NYh = 0
xor a
VDP_SetReg 45 ; R45 = 0 ; mode
ld e,0
2: halt
ld a,106
VDP_SetReg 38 ; R38 = 106 ; DY = 106 ; first line on the screen
xor a
VDP_SetReg 39 ; R39 = 0
ld a,1
VDP_SetReg 35 ; R35 = 1 ; source page for ground
ld hl,raster_tab
ld b,106
1: call VDP_Ready
ld a,1
VDP_SetReg 42 ; R42 = 1 ; NYl = 1
ld a,(hl)
sub a,e
cp 255
jr nz,3f
inc a
3: VDP_SetReg 34 ; R34 = source
ld a,#E0
VDP_SetReg 46 ; R46 = #E0 ; execute YMMM command
inc hl
djnz 1b
inc e
jp 2b
_START:
call screeninit
ld de,0
2: halt ; allow ISR
di
ld a,d
out (#99),a
ld a,23 or 010000000b
out (#99),a ; scroll=0
ld a,#1F
out (#99),a
ld a,#82
out (#99),a ; set page 0
ei
call raster_wave
inc de
jp 2b
;S#2
;b6 VR: Vertical scanning line timing flag
; During vertical retrace and while lower and upper bordersare drawn, this flag is set to 1.
;b5 HR: Horizontal scanning line timing flag
; During horizontal retrace and while left and right borders are drawn, this flag is set to 1.
raster_wave:
di
ld a,#97
out (#99),a
ld a,#91
out (#99),a ; write R#23 using port 0x9B and R#17
ld a,106
add a,d
out (#99),a
ld a,19 or 010000000b
out (#99),a ; Set FH at line 106
ld a,#01
out (#99),a
ld a,#8f
out (#99),a ; read S#1
1: ; wait for start of the line in R#19
in a,(#99)
rrca
jp nc,1b
ld a,#3F
out (#99),a
ld a,#82
out (#99),a ; set page 1
ld a,#02
out (#99),a
ld a,#8f
out (#99),a ; read S#2
ld hl,raster_tab
ld b,103
.loop:
ld a,(hl)
sub a,e
inc hl
ex af,af'
1: in a,(#99) ; wait for HR start the line
bit 5,a
jp z,1b
ex af,af'
out (#9B),a
djnz .loop
xor a
out (#99),a
ld a,#8f
out (#99),a
ei
ret
code @ 4200h, # 256
raster_tab:
repeat 256
db (@#-256/(1+@#)) & 255
endrepeat
end_raster_tab:
page 1
_opening:
incbin "galaxy.bin",0x0000,0x2000
page 2
incbin "galaxy.bin",0x2000,0x2000
page 3
incbin "galaxy.bin",0x4000,0x2000
page 4
incbin "galaxy.bin",0x6000,0x2000
page 5
incbin "galaxy.bin",0x8000,0x2000
page 6
incbin "galaxy.bin",0xA000,0x2000
page 7
incbin "galaxy.bin",0xC000,0x2000
page 8
incbin "galaxy.bin",0xE000,0x2000
page 9
incbin "PLASMA.bin",0x0000,0x2000
page 10
incbin "PLASMA.bin",0x2000,0x2000
page 11
incbin "PLASMA.bin",0x4000,0x2000
page 12
incbin "PLASMA.bin",0x6000,0x2000
page 13
incbin "PLASMA.bin",0x8000,0x2000
page 14
incbin "PLASMA.bin",0xA000,0x2000
page 15
incbin "PLASMA.bin",0xC000,0x2000
page 16
incbin "PLASMA.bin",0xE000,0x2000