-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmsxsindm.asc
384 lines (333 loc) · 6.24 KB
/
msxsindm.asc
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
include "bios.asc"
WRVDP MACRO @WAARDE,@POORT
; {{{
LD A,@WAARDE
OUT (#99),A
LD A,128+@POORT
OUT (#99),A
ENDM
; }}}
chkvdp2 macro
; {{{
LOCAL chkvdp2@sym
chkvdp2@sym
in a,(#99)
rrca
jp c,chkvdp2@sym
endm
; }}}
DEBUG equ 0
;This code is used in conjunction with the openMSX debugdevice to help debug/time my code
debugdeviceascii macro @TEXTVAL
; {{{
if DEBUG
LOCAL _debugdevicetmp
LOCAL _debugdevicetmp2
jr _debugdevicetmp2
_debugdevicetmp
db @TEXTVAL
_debugdevicetmp2
ld a,0x58
out (0x2e),a
ld a,'-'
out (0x2f),a
ld a,0x63
out (0x2e),a
ld hl,_debugdevicetmp
ld c,0x2f
ld b,_debugdevicetmp2-_debugdevicetmp
otir
ld a,0x03
out (0x2e),a
ld a,'-'
out (0x2f),a
endif
endm
; }}}
START EQU #4000
BUFROWS EQU 8
BUFCOLS EQU 8
; created by pasmo and the --bin switch, the org command should be the first one seen by pasmo
org START
db 'AB' ; expansion ROM header
DW initcode ; start of the init code, 0 if no initcode
DW 0 ; pointer to CALL statement handler, 0 if no such handler
DW 0 ; pointer to expansion device handler, 0 if no such handler
DW 0 ; pointer to the start of a tokenized basicprogram, 0 if no basicprogram
DW 0,0,0 ; room reserved for future extensions
initcode:
init:
; first clear all variables to zero
;especially needed for the routeinstack!!
ld de,#c001
ld hl,#c000
xor a
ld (hl),a
ld bc,32*24
ldir
inc a
ld a,240
ld de,#c001+10*32
ld hl,#c000+10*32
ld (hl),a
ld bc,32*14
ldir
; xor a
; ld b,a
; ld hl,#c000+32
;init1: ld (hl),a
; inc a
; inc hl
; djnz init1
ld a,1
call CHGMOD ; screen 1
xor a
ld (CLIKSW),a ; disable keyboard click
; now make the sprites zoomed
ld a,(RG1SAV)
or 2 ; 2=16x16,1=magnified
ld (RG1SAV),a
ld b,a
ld c,1
call WRTVDP
; call DISSCR ; disable screen
ld hl,charsetdb
ld de,0
ld bc,188*8
call LDIRVM ; copy patern generator
ld a,0
ld hl,240*8
ld bc,6*8
call FILVRM ; clear chars 240 and above
ld hl,dotcharstable
ld de,245*8
ld bc,11*8
call LDIRVM ; copy patern generator
ld hl,#c000
ld de,#1800
ld bc,32*24
call LDIRVM ; copy patern layout
ld hl,spritetable
ld de,#3800
ld bc,32*24 ; 24 16x16 sprites
call LDIRVM ; copy patern layout
ld a,#47
ld hl,#2000
ld bc,32
call FILVRM ; color patern
ld a,#e4
ld hl,#2000+30
ld bc,2
call FILVRM ; color patern
ld de,#400 ;400
ld (sinwparams),de
ld de,#370
ld (sinwparams+2),de
ld a,1
ld (spriteinfo+5),a ; sprite color
xor a
ld (spriteinfo+4),a ; sprite shape
ld hl,scrollertable
ld (scrollertablewavepos),hl
ld hl,scrollertable+256*8 ; 8 lines high of 256 chars length
ld (scrollertableletterpos),hl
ld hl,128
ld (scrollertableletterwait),hl
dowave:
;ld bc,#f807
;call WRTVDP
ld b,33
exx
ld de,(sinwparams)
exx
ld de,(sinwparams+2)
ld hl,sinewave
ld ix,screenwave
calcwave:
ld a,e
add a,d
ld e,a
ld l,a
ld a,(hl)
srl a
ld (ix+0),a
exx
ld a,e
add a,d
ld e,a
exx
ld l,a
ld a,(hl)
srl a
add a,(ix+0)
ld (ix+0),a
inc ix
djnz calcwave
ld de,(sinwparams)
ld a,e
add a,d
ld e,a
ld (sinwparams),de
ld de,(sinwparams+2)
ld a,e
add a,d
ld e,a
ld (sinwparams+2),de
ld b,32
ld ix,screenwave
ld iy,#c000 ;start of buffer
drawwave:
push bc
ld a,(ix+0); a is height in subpixel resolution
push iy
pop de ;start of buffer
ld h,0
and #f0 ; divide by 16, multiply by 32
ld l,a
add hl,hl
add hl,de ; add buffer origin
ld a,(ix+0); a is height in subpixel resolution
ld d,a
add a,a
add a,a
add a,a
add a,a
ld e,a ; e is now 4 highest bits as height
ld a,-8
add a,d
ld d,a
ld a,(ix+1); a is height in subpixel resolution
sub d
and 15
or e
ld de,charbasedtable
ld e,a
; now draw the 3 chars in a column in our buffer
ld bc,32
ld a,(de)
inc d ; next LUT for char2
ld (hl),a ; store in buffer
add hl,bc ; descend one row in buffer
ld a,(de)
inc d ; next LUT for char3
ld (hl),a ; store in buffer
add hl,bc ; descend one row in buffer
ld a,(de)
ld (hl),a ; store in buffer
pop bc
inc ix
inc iy
djnz drawwave
; now place das boot
ld hl,(spriteinfo)
ld a,h
add a,l
ld h,a
cp 30
jp nc,placeship1
ld l,1
jr placeship5
placeship1
cp 220
jp c,placeship5
ld l,255
placeship5
ld (spriteinfo),hl
add a,-16
ld (spriteinfo+3),a ; x position
add a,16
ld h,0
srl a
srl a
srl a
ld l,a
ld de,screenwave
add hl,de
ld a,(hl)
ld e,a ; store current wave height
srl a ; since subpixel height!
sub 5; 14 ; shift ship higher
ld (spriteinfo+2),a ; y position
; now next height to determine slope of ship
inc hl
ld a,-8
add a,e
ld e,a
ld a,(hl)
sub e
; now we have the slope
add a,a
add a,a
ld (spriteinfo+4),a ; shape
; now do the scroller thingy
ld de,#c000+32*15
ld hl,(scrollertablewavepos)
exx
ld hl,(scrollertableletterpos)
ld b,8
nextletterlinescroll
exx
ld b,32
letterlinescroll
exx
ld a,(hl)
inc l
exx
and (hl)
inc l
ld (de),a
inc de
djnz letterlinescroll
inc h
exx
inc h
djnz nextletterlinescroll
; next x position
ld hl,scrollertablewavepos
dec (hl)
ld hl,(scrollertableletterwait)
ld a,h
add a,l
ld h,a
ld (scrollertableletterwait),hl
jr nc,aaaa
ld hl,scrollertableletterpos
inc (hl)
aaaa:
;ld bc,#f707
;call WRTVDP
ei
halt
ld hl,#c000
ld de,#1800
ld bc,32*24
call LDIRVM ; copy patern layout
ld hl,spriteinfo+2
ld de,#1b00
ld bc,4
call LDIRVM ; copy sprite info
jp dowave
di
halt
;call ENASCR
ds 256*(1+($/256))-$
scrollertable:
INCLUDE "scrollertable.asc"
INCLUDE "scrollertext.asc"
charbasedtable:
INCLUDE "msxsindemo-dbtables.asc"
spritetable:
INCLUDE "bootsprites.asc"
dotcharstable:
INCLUDE "dotting.asc"
einde equ $
ds #8000-einde
nametabel: equ #c000
screenwave: equ nametabel+24*32
sinwparams: equ screenwave+34
spriteinfo: equ sinwparams+6 ; direction,location, 4 bytes for info
scrollertablewavepos: equ spriteinfo+6
scrollertableletterpos: equ scrollertablewavepos+2
scrollertableletterwait: equ scrollertableletterpos+2
endvarspace: equ scrollertableletterwait+2
; vim:foldmethod=marker:ft=z8a:ts=16