-
Notifications
You must be signed in to change notification settings - Fork 2
/
InitVram.s
779 lines (660 loc) · 27.4 KB
/
InitVram.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
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
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
InitVram:
; ; disable keyboard click
; xor a
; ld (BIOS_CLIKSW), a ; Key Press Click Switch 0:Off 1:On (1B/RW)
; define screen colors
ld a, 1 ; Foreground color
ld (BIOS_FORCLR), a
ld a, 1 ; Background color
ld (BIOS_BAKCLR), a
ld a, 1 ; Border color
ld (BIOS_BDRCLR), a
call BIOS_CHGCLR ; Change Screen Color
call Screen11
call BIOS_DISSCR
call ClearVram_MSX2
call SetSprites16x16
call Set192Lines
call SetColor0ToTransparent
call EnableSprites
; ---- set SPRATR to 0x1fa00 (SPRCOL is automatically set 512 bytes before SPRATR, so 0x1f800)
; bits: 16 14 7
; | | |
; 0x1fa00 = 1 1111 1010 0000 0000
; low bits (aaaaa111: bits 14 to 10)
ld b, 1111 0111 b ; data ; In sprite mode 2 the least significant three bits in register 5 should be 1 otherwise mirroring will occur. ; https://www.msx.org/forum/msx-talk/development/strange-behaviour-bug-on-spratr-base-addr-register-on-v993858
ld c, 5 ; register #
call BIOS_WRTVDP
; high bits (000000aa: bits 16 to 15)
ld b, 0000 0011 b ; data
ld c, 11 ; register #
call BIOS_WRTVDP
; ---- set SPRPAT to 0x1f000
; bits: 16 11
; | |
; 0x1f000 = 1 1111 0000 0000 0000
; high bits (00aaaaaa: bits 16 to 11)
ld b, 0011 1110 b ; data
ld c, 6 ; register #
call BIOS_WRTVDP
; -------------------------- VRAM mapping (screen 11)
; first page (0x00000 to 0x0ffff):
NAMTBL: equ 0x0000
; second page (0x10000 to 0x1ffff):
SPRPAT: equ 0xf000 ; 0x1f000 - 0x1f7ff ; 64 * 32 = 2048 bytes ; actually 0x1f000, but 17 bits address are not accepted
SPRCOL: equ 0xf800 ; 0x1f800 - 0x1f9ff ; 32 * 16 = 512 bytes
SPRATR: equ 0xfa00 ; 0x1fa00 - 0x1fa7f ; 4 * 32 = 128 bytes
; 0x1fa80 - 0x1ffff = 1408 bytes free (5.5 last lines)
; --------------------------
ld hl, PaletteData_0
call LoadPalette
ret
LoadSpritesForGameplay:
; set MegaROM page for Sprite Patterns data
ld a, SPRITE_PATTERNS_DATA_MEGAROM_PAGE
; ld (Seg_P8000_SW), a
call Set_and_Save_MegaROM_Page
; --------- Load sprite patterns
ld hl, SPRPAT
; Spr 0 and 1 patterns
push hl
ld a, 0000 0001 b
;ld hl, SPRPAT
call SetVdp_Write
ld b, SpritePattern_PlayerPlane_0_and_1.size
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld hl, SpritePattern_PlayerPlane_0_and_1
otir
pop hl
ld bc, SpritePattern_PlayerPlane_0_and_1.size
add hl, bc
; ld de, SpritePattern_PlayerPlane_0_and_1
; ld b, SpritePattern_PlayerPlane_0_and_1.size
; call LoadPatterns
; Spr 2 and 3 patterns
push hl
ld a, 0000 0001 b
;ld hl, SPRPAT + 64
call SetVdp_Write
ld b, SpritePattern_PlayerPlane_2_and_3.size
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld hl, SpritePattern_PlayerPlane_2_and_3
otir
pop hl
ld bc, SpritePattern_PlayerPlane_2_and_3.size
add hl, bc
; ld de, SpritePattern_PlayerPlane_2_and_3
; ld b, SpritePattern_PlayerPlane_2_and_3.size
; call LoadPatterns
; Spr 4 patterns
push hl
; ld a, 0000 0001 b
; ;ld hl, SPRPAT + 128
; call SetVdp_Write
; ld b, SpritePattern_PlayerShot_Thin.size
; ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
; ld hl, SpritePattern_PlayerShot_Thin
; otir
ld hl, SpritePattern_PlayerShot_Thin
ld de, SpriteColors_PlayerShot_Thin
call Load_PlayerShot_Pattern_And_Colors
pop hl
ld bc, SpritePattern_PlayerShot_Thin.size
add hl, bc
; Spr 5 and 6 patterns
push hl
ld a, 0000 0001 b
;ld hl, SPRPAT + 128 + SpritePattern_PlayerShot.size
call SetVdp_Write
ld b, SpritePattern_EnemyPlane_Frame_0_Patterns_0_and_1.size
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld hl, SpritePattern_EnemyPlane_Frame_0_Patterns_0_and_1
otir
pop hl
ld bc, SpritePattern_EnemyPlane_Frame_0_Patterns_0_and_1.size
add hl, bc
; Spr 7, 8 and 9 patterns
push hl
ld a, 0000 0001 b
;ld hl, SPRPAT + 128 + SpritePattern_PlayerShot.size + SpritePattern_EnemyPlane_Frame_0_Patterns_0_and_1.size
call SetVdp_Write
ld b, SpritePattern_Explosion_Frames_0_to_2.size
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld hl, SpritePattern_Explosion_Frames_0_to_2
otir
pop hl
ld bc, SpritePattern_Explosion_Frames_0_to_2.size
add hl, bc
; Spr 10 and 11 patterns
push hl
ld a, 0000 0001 b
;ld hl, SPRPAT + 128 + SpritePattern_PlayerShot.size + SpritePattern_EnemyPlane_Frame_0_Patterns_0_and_1.size + SpritePattern_Explosion_Frames_0_to_2.size
call SetVdp_Write
ld b, SpritePattern_EnemyShot_0_and_1.size
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld hl, SpritePattern_EnemyShot_0_and_1
otir
pop hl
ld bc, SpritePattern_EnemyShot_0_and_1.size
add hl, bc
; Spr 12 and 13 patterns
push hl
ld a, 0000 0001 b
;ld hl, SPRPAT + 128 + SpritePattern_PlayerShot.size + SpritePattern_EnemyPlane_Frame_0_Patterns_0_and_1.size + SpritePattern_Explosion_Frames_0_to_2.size + SpritePattern_EnemyShot_0_and_1.size
call SetVdp_Write
ld b, SpritePattern_EnemyPlane_Frame_1_Patterns_0_and_1.size
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld hl, SpritePattern_EnemyPlane_Frame_1_Patterns_0_and_1
otir
pop hl
ld bc, SpritePattern_EnemyPlane_Frame_1_Patterns_0_and_1.size
add hl, bc
; Spr 14 and 15 patterns
push hl
ld a, 0000 0001 b
call SetVdp_Write
ld b, SpritePattern_EnemyPlane_Frame_2_Patterns_0_and_1.size
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld hl, SpritePattern_EnemyPlane_Frame_2_Patterns_0_and_1
otir
pop hl
ld bc, SpritePattern_EnemyPlane_Frame_2_Patterns_0_and_1.size
add hl, bc
; Spr 16 and 17 patterns
push hl
ld a, 0000 0001 b
call SetVdp_Write
ld b, SpritePattern_EnemyPlane_Frame_3_Patterns_0_and_1.size
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld hl, SpritePattern_EnemyPlane_Frame_3_Patterns_0_and_1
otir
pop hl
ld bc, SpritePattern_EnemyPlane_Frame_3_Patterns_0_and_1.size
add hl, bc
; Spr 18 and 19 patterns
push hl
ld a, 0000 0001 b
call SetVdp_Write
ld b, SpritePattern_EnemyPlane_Frame_4_Patterns_0_and_1.size
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld hl, SpritePattern_EnemyPlane_Frame_4_Patterns_0_and_1
otir
pop hl
ld bc, SpritePattern_EnemyPlane_Frame_4_Patterns_0_and_1.size
add hl, bc
; Spr 20 and 21 patterns
push hl
ld a, 0000 0001 b
call SetVdp_Write
ld b, SpritePattern_EnemyPlane_Frame_5_Patterns_0_and_1.size
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld hl, SpritePattern_EnemyPlane_Frame_5_Patterns_0_and_1
otir
pop hl
ld bc, SpritePattern_EnemyPlane_Frame_5_Patterns_0_and_1.size
add hl, bc
; Spr 22 and 23 patterns
push hl
ld a, 0000 0001 b
call SetVdp_Write
ld b, SpritePattern_PlayerPlane_Left_Frame_0_Top.size
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld hl, SpritePattern_PlayerPlane_Left_Frame_0_Top
otir
pop hl
ld bc, SpritePattern_PlayerPlane_Left_Frame_0_Top.size
add hl, bc
; Spr 24 and 25 patterns
push hl
ld a, 0000 0001 b
call SetVdp_Write
ld b, SpritePattern_PlayerPlane_Left_Frame_0_Bottom.size
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld hl, SpritePattern_PlayerPlane_Left_Frame_0_Bottom
otir
pop hl
ld bc, SpritePattern_PlayerPlane_Left_Frame_0_Bottom.size
add hl, bc
; Spr 26 and 27 patterns
push hl
ld a, 0000 0001 b
call SetVdp_Write
ld b, SpritePattern_PlayerPlane_Left_Frame_1_Top.size
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld hl, SpritePattern_PlayerPlane_Left_Frame_1_Top
otir
pop hl
ld bc, SpritePattern_PlayerPlane_Left_Frame_1_Top.size
add hl, bc
; Spr 28 and 29 patterns
push hl
ld a, 0000 0001 b
call SetVdp_Write
ld b, SpritePattern_PlayerPlane_Left_Frame_1_Bottom.size
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld hl, SpritePattern_PlayerPlane_Left_Frame_1_Bottom
otir
pop hl
ld bc, SpritePattern_PlayerPlane_Left_Frame_1_Bottom.size
add hl, bc
; Spr 30 and 31 patterns
push hl
ld a, 0000 0001 b
call SetVdp_Write
ld b, SpritePattern_PlayerPlane_Right_Frame_0_Top.size
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld hl, SpritePattern_PlayerPlane_Right_Frame_0_Top
otir
pop hl
ld bc, SpritePattern_PlayerPlane_Right_Frame_0_Top.size
add hl, bc
; Spr 32 and 33 patterns
push hl
ld a, 0000 0001 b
call SetVdp_Write
ld b, SpritePattern_PlayerPlane_Right_Frame_0_Bottom.size
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld hl, SpritePattern_PlayerPlane_Right_Frame_0_Bottom
otir
pop hl
ld bc, SpritePattern_PlayerPlane_Right_Frame_0_Bottom.size
add hl, bc
; Spr 34 and 35 patterns
push hl
ld a, 0000 0001 b
call SetVdp_Write
ld b, SpritePattern_PlayerPlane_Right_Frame_1_Top.size
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld hl, SpritePattern_PlayerPlane_Right_Frame_1_Top
otir
pop hl
ld bc, SpritePattern_PlayerPlane_Right_Frame_1_Top.size
add hl, bc
; Spr 36 and 37 patterns
push hl
ld a, 0000 0001 b
call SetVdp_Write
ld b, SpritePattern_PlayerPlane_Right_Frame_1_Bottom.size
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld hl, SpritePattern_PlayerPlane_Right_Frame_1_Bottom
otir
pop hl
ld bc, SpritePattern_PlayerPlane_Right_Frame_1_Bottom.size
add hl, bc
; Spr 38 and 39 patterns
push hl
ld a, 0000 0001 b
call SetVdp_Write
ld b, 64 ; loading just the 2 first sprites (1st frame of animation) ; SpritePattern_Item_P_Frames_0_to_7.size
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld hl, SpritePattern_Item_P_Frames_0_to_7
otir
pop hl
ld bc, 64
add hl, bc
; Spr 40 pattern
push hl
ld a, 0000 0001 b
call SetVdp_Write
ld b, SpritePattern_GroundTarget_0.size
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld hl, SpritePattern_GroundTarget_0
otir
pop hl
ld bc, SpritePattern_GroundTarget_0.size
add hl, bc
; --- Enemy plane turning
; Spr 41 and 42 patterns
push hl
ld a, 0000 0001 b
call SetVdp_Write
ld b, SpritePattern_EnemyPlaneTurning_Frame_0_Patterns_0_and_1.size
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld hl, SpritePattern_EnemyPlaneTurning_Frame_0_Patterns_0_and_1
otir
pop hl
ld bc, SpritePattern_EnemyPlaneTurning_Frame_0_Patterns_0_and_1.size
add hl, bc
; Spr 43 and 44 patterns
push hl
ld a, 0000 0001 b
call SetVdp_Write
ld b, SpritePattern_EnemyPlaneTurning_Frame_1_Patterns_0_and_1.size
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld hl, SpritePattern_EnemyPlaneTurning_Frame_1_Patterns_0_and_1
otir
pop hl
ld bc, SpritePattern_EnemyPlaneTurning_Frame_1_Patterns_0_and_1.size
add hl, bc
; Spr 45 and 46 patterns
push hl
ld a, 0000 0001 b
call SetVdp_Write
ld b, SpritePattern_EnemyPlaneTurning_Frame_2_Patterns_0_and_1.size
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld hl, SpritePattern_EnemyPlaneTurning_Frame_2_Patterns_0_and_1
otir
pop hl
ld bc, SpritePattern_EnemyPlaneTurning_Frame_2_Patterns_0_and_1.size
add hl, bc
; Spr 47 and 48 patterns
push hl
ld a, 0000 0001 b
call SetVdp_Write
ld b, SpritePattern_EnemyPlaneTurning_Frame_3_Patterns_0_and_1.size
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld hl, SpritePattern_EnemyPlaneTurning_Frame_3_Patterns_0_and_1
otir
pop hl
ld bc, SpritePattern_EnemyPlaneTurning_Frame_3_Patterns_0_and_1.size
add hl, bc
; Spr 49 and 50 patterns
push hl
ld a, 0000 0001 b
call SetVdp_Write
ld b, SpritePattern_EnemyPlaneTurning_Frame_4_Patterns_0_and_1.size
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld hl, SpritePattern_EnemyPlaneTurning_Frame_4_Patterns_0_and_1
otir
pop hl
ld bc, SpritePattern_EnemyPlaneTurning_Frame_4_Patterns_0_and_1.size
add hl, bc
; Spr 51 and 52 patterns
push hl
ld a, 0000 0001 b
call SetVdp_Write
ld b, SpritePattern_EnemyPlaneTurning_Frame_5_Patterns_0_and_1.size
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld hl, SpritePattern_EnemyPlaneTurning_Frame_5_Patterns_0_and_1
otir
pop hl
ld bc, SpritePattern_EnemyPlaneTurning_Frame_5_Patterns_0_and_1.size
add hl, bc
; Spr 53 and 54 patterns
push hl
ld a, 0000 0001 b
call SetVdp_Write
ld b, SpritePattern_EnemyPlaneTurning_Frame_6_Patterns_0_and_1.size
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld hl, SpritePattern_EnemyPlaneTurning_Frame_6_Patterns_0_and_1
otir
pop hl
ld bc, SpritePattern_EnemyPlaneTurning_Frame_6_Patterns_0_and_1.size
add hl, bc
; Spr 55 and 56 patterns
push hl
ld a, 0000 0001 b
call SetVdp_Write
ld b, SpritePattern_EnemyPlaneTurning_Frame_7_Patterns_0_and_1.size
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld hl, SpritePattern_EnemyPlaneTurning_Frame_7_Patterns_0_and_1
otir
pop hl
ld bc, SpritePattern_EnemyPlaneTurning_Frame_7_Patterns_0_and_1.size
add hl, bc
; --- END OF Enemy plane turning
; Spr 57 pattern
push hl
ld a, 0000 0001 b
call SetVdp_Write
ld b, SpritePattern_1000_points.size
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld hl, SpritePattern_1000_points
otir
pop hl
ld bc, SpritePattern_1000_points.size
add hl, bc
; Spr 58 and 59 patterns
push hl
ld a, 0000 0001 b
call SetVdp_Write
ld b, 64 ; loading just the 2 first sprites (1st frame of animation) ; SpritePattern_Item_P_Frames_0_to_7.size
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld hl, SpritePattern_Item_Bomb_Frames_0_to_7
otir
pop hl
ld bc, 64
add hl, bc
; --------- Load sprite colors
; Spr 0 and 1 colors
ld a, 0000 0001 b
ld hl, SPRCOL
call SetVdp_Write
ld b, SpriteColors_PlayerPlane_0_and_1.size
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld hl, SpriteColors_PlayerPlane_0_and_1
otir
; Spr 2 and 3 colors
ld a, 0000 0001 b
ld hl, SPRCOL + 32
call SetVdp_Write
ld b, SpriteColors_PlayerPlane_2_and_3.size
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld hl, SpriteColors_PlayerPlane_2_and_3
otir
; ; Spr 4 colors
; ld a, 0000 0001 b
; ld hl, SPRCOL + 64 + (SpriteColors_PlayerShot_Thin.size * 0)
; call SetVdp_Write
; ld b, SpriteColors_PlayerShot_Thin.size
; ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
; ld hl, SpriteColors_PlayerShot_Thin
; otir
; ; Spr 5 colors
; ld a, 0000 0001 b
; ld hl, SPRCOL + 64 + (SpriteColors_PlayerShot_Thin.size * 1)
; call SetVdp_Write
; ld b, SpriteColors_PlayerShot_Thin.size
; ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
; ld hl, SpriteColors_PlayerShot_Thin
; otir
; ; Spr 6 colors
; ld a, 0000 0001 b
; ld hl, SPRCOL + 64 + (SpriteColors_PlayerShot_Thin.size * 2)
; call SetVdp_Write
; ld b, SpriteColors_PlayerShot_Thin.size
; ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
; ld hl, SpriteColors_PlayerShot_Thin
; otir
; ; Spr 7 colors
; ld a, 0000 0001 b
; ld hl, SPRCOL + 64 + (SpriteColors_PlayerShot_Thin.size * 3)
; call SetVdp_Write
; ld b, SpriteColors_PlayerShot_Thin.size
; ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
; ld hl, SpriteColors_PlayerShot_Thin
; otir
; ; Spr 8 colors
; ld a, 0000 0001 b
; ld hl, SPRCOL + 64 + (SpriteColors_PlayerShot_Thin.size * 4)
; call SetVdp_Write
; ld b, SpriteColors_PlayerShot_Thin.size
; ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
; ld hl, SpriteColors_PlayerShot_Thin
; otir
; ; Spr 9 colors
; ld a, 0000 0001 b
; ld hl, SPRCOL + 64 + (SpriteColors_PlayerShot_Thin.size * 5)
; call SetVdp_Write
; ld b, SpriteColors_PlayerShot_Thin.size
; ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
; ld hl, SpriteColors_PlayerShot_Thin
; otir
; --------------- this will be loaded on EnemyInit
ENEMY_0_SPRCOL_ADDR: equ SPRCOL + 64 + (16 * 6) + (SpriteColors_EnemyPlane_Frame_0_Patterns_0_and_1.size * 0)
ENEMY_1_SPRCOL_ADDR: equ SPRCOL + 64 + (16 * 6) + (SpriteColors_EnemyPlane_Frame_0_Patterns_0_and_1.size * 1)
ENEMY_2_SPRCOL_ADDR: equ SPRCOL + 64 + (16 * 6) + (SpriteColors_EnemyPlane_Frame_0_Patterns_0_and_1.size * 2)
ENEMY_3_SPRCOL_ADDR: equ SPRCOL + 64 + (16 * 6) + (SpriteColors_EnemyPlane_Frame_0_Patterns_0_and_1.size * 3)
ENEMY_4_SPRCOL_ADDR: equ SPRCOL + 64 + (16 * 6) + (SpriteColors_EnemyPlane_Frame_0_Patterns_0_and_1.size * 4)
ENEMY_5_SPRCOL_ADDR: equ SPRCOL + 64 + (16 * 6) + (SpriteColors_EnemyPlane_Frame_0_Patterns_0_and_1.size * 5)
ENEMY_6_SPRCOL_ADDR: equ SPRCOL + 64 + (16 * 6) + (SpriteColors_EnemyPlane_Frame_0_Patterns_0_and_1.size * 6)
BIG_ENEMY_0_SPRCOL_ADDR: equ ENEMY_0_SPRCOL_ADDR
BIG_ENEMY_1_SPRCOL_ADDR: equ BIG_ENEMY_0_SPRCOL_ADDR + (16 * 7) ; seven sprites for each Big enemy
ENEMY_SHOT_0_SPRCOL_ADDR: equ ENEMY_6_SPRCOL_ADDR + SpriteColors_EnemyPlane_Frame_0_Patterns_0_and_1.size
ENEMY_SHOT_1_SPRCOL_ADDR: equ ENEMY_SHOT_0_SPRCOL_ADDR + 16
ENEMY_SHOT_2_SPRCOL_ADDR: equ ENEMY_SHOT_1_SPRCOL_ADDR + 16
ENEMY_SHOT_3_SPRCOL_ADDR: equ ENEMY_SHOT_2_SPRCOL_ADDR + 16
ENEMY_SHOT_4_SPRCOL_ADDR: equ ENEMY_SHOT_3_SPRCOL_ADDR + 16
ENEMY_SHOT_5_SPRCOL_ADDR: equ ENEMY_SHOT_4_SPRCOL_ADDR + 16
ENEMY_SHOT_6_SPRCOL_ADDR: equ ENEMY_SHOT_5_SPRCOL_ADDR + 16
GROUND_TARGET_SPRCOL_ADDR: equ SPRCOL + (16 * 31)
; ; Spr 7 and 8 colors
; ld a, 0000 0001 b
; ld hl, SPRCOL + 64 + 32 + 16 + (SpriteColors_EnemyPlane_0_and_1.size * 0)
; call SetVdp_Write
; ld b, SpriteColors_EnemyPlane_0_and_1.size
; ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
; ld hl, SpriteColors_EnemyPlane_0_and_1
; otir
; ; Spr 9 and 10 colors
; ld a, 0000 0001 b
; ld hl, SPRCOL + 64 + 32 + 16 + (SpriteColors_EnemyPlane_0_and_1.size * 1)
; call SetVdp_Write
; ld b, SpriteColors_EnemyPlane_0_and_1.size
; ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
; ld hl, SpriteColors_EnemyPlane_0_and_1
; otir
; ; Spr 11 and 12 colors
; ld a, 0000 0001 b
; ld hl, SPRCOL + 64 + 32 + 16 + (SpriteColors_EnemyPlane_0_and_1.size * 2)
; call SetVdp_Write
; ld b, SpriteColors_EnemyPlane_0_and_1.size
; ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
; ld hl, SpriteColors_EnemyPlane_0_and_1
; otir
; ; Spr 13 and 14 colors
; ld a, 0000 0001 b
; ld hl, SPRCOL + 64 + 32 + 16 + (SpriteColors_EnemyPlane_0_and_1.size * 3)
; call SetVdp_Write
; ld b, SpriteColors_EnemyPlane_0_and_1.size
; ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
; ld hl, SpriteColors_EnemyPlane_0_and_1
; otir
; ; Spr 15 and 16 colors
; ld a, 0000 0001 b
; ld hl, SPRCOL + 64 + 32 + 16 + (SpriteColors_EnemyPlane_0_and_1.size * 4)
; call SetVdp_Write
; ld b, SpriteColors_EnemyPlane_0_and_1.size
; ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
; ld hl, SpriteColors_EnemyPlane_0_and_1
; otir
; ; Spr 17 and 18 colors
; ld a, 0000 0001 b
; ld hl, SPRCOL + 64 + 32 + 16 + (SpriteColors_EnemyPlane_0_and_1.size * 5)
; call SetVdp_Write
; ld b, SpriteColors_EnemyPlane_0_and_1.size
; ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
; ld hl, SpriteColors_EnemyPlane_0_and_1
; otir
; ; Atributes of all sprites
; ld a, 0000 0001 b
; ld hl, SPRATR
; call SetVdp_Write
; ld b, InitialSpriteAttributes.size
; ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
; ld hl, InitialSpriteAttributes
; otir
; -----------
; Load test bg image
; ld hl, ImageData_1 ; RAM address (source)
; ld a, 0 ; VRAM address (destiny, bit 16)
; ld de, NAMTBL + (1 * (256 * 64)) ; VRAM address (destiny, bits 15-0)
; ld c, 0 + (ImageData_1.size / 256) ; Block length * 256
; call LDIRVM_MSX2
;call BIOS_ENASCR
; --------------------------
; load $ char bitmaps on second page, to be used by HMMM command
; set MegaROM page for Ground Targe Destroyed data
ld a, GROUND_TARGET_DESTROYED_DATA_MEGAROM_PAGE
; ld (Seg_P8000_SW), a
call Set_and_Save_MegaROM_Page
ld de, GroundTargetDestroyed_Dollar_0 ; ROM source addr
ld hl, GROUND_TARGET_DESTROYED_DOLLAR_0_VRAM_ADDR ; VRAM destiny addr (lower 16 bits)
call Load_6x8_BitmapFromRAMToVRAM
ld de, GroundTargetDestroyed_Dollar_1 ; ROM source addr
ld hl, GROUND_TARGET_DESTROYED_DOLLAR_1_VRAM_ADDR ; VRAM destiny addr (lower 16 bits)
call Load_6x8_BitmapFromRAMToVRAM
ld de, GroundTargetDestroyed_Dollar_2 ; ROM source addr
ld hl, GROUND_TARGET_DESTROYED_DOLLAR_2_VRAM_ADDR ; VRAM destiny addr (lower 16 bits)
call Load_6x8_BitmapFromRAMToVRAM
ld de, GroundTargetDestroyed_Dollar_3 ; ROM source addr
ld hl, GROUND_TARGET_DESTROYED_DOLLAR_3_VRAM_ADDR ; VRAM destiny addr (lower 16 bits)
call Load_6x8_BitmapFromRAMToVRAM
ret
GROUND_TARGET_DESTROYED_DOLLAR_0_VRAM_ADDR: equ 0x0000 + (6 * 0)
GROUND_TARGET_DESTROYED_DOLLAR_1_VRAM_ADDR: equ 0x0000 + (6 * 1)
GROUND_TARGET_DESTROYED_DOLLAR_2_VRAM_ADDR: equ 0x0000 + (6 * 2)
GROUND_TARGET_DESTROYED_DOLLAR_3_VRAM_ADDR: equ 0x0000 + (6 * 3)
; Inputs:
; HL: VRAM destiny addr (lower 16 bits)
; DE: ROM source addr
Load_6x8_BitmapFromRAMToVRAM:
ld b, 8 ; number of lines
.loop:
push bc
ld a, 0000 0001 b ; set vram write base address (high bit)
push hl
call SetVDP_Write
ld c, PORT_0
ex de, hl
outi outi outi outi outi outi ; number of cols
ex de, hl
pop hl
ld bc, 256 ; next screen line
add hl, bc
pop bc
djnz .loop
ret
;TEST_1: db 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08
; ; Inputs:
; ; DE: source addr in RAM
; ; HL: destiny addr in VRAM (17 bits, highest bit fixed to 1)
; ; B: size in bytes
; ; Output:
; ; HL updated to next VRAM sprite pattern place
; LoadPatterns:
; ;ex de, hl
; push hl
; ld a, 0000 0001 b
; ;ld hl, SPRPAT
; call SetVdp_Write
; ;ld b, SpritePattern_PlayerPlane_0_and_1.size
; ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
; ;ld hl, SpritePattern_PlayerPlane_0_and_1
; ;ex de, hl
; ld h, d
; ld l, e
; otir
; pop hl
; ;ld bc, SpritePattern_PlayerPlane_0_and_1.size
; ld c, b
; ld b, 0
; add hl, bc
; ;ex de, hl
; ret
HideAllSprites:
; ---------- hide all sprites
ld a, 0000 0001 b
ld hl, SPRATR
call SetVdp_Write
ld c, PORT_0 ; you can also write ld bc,#nn9B, which is faster
ld b, 32 ; 32 sprites on SPRATR
.loop_HideAllSprites:
ld a, 216
nop
nop
out (c), a ; set Y to 216 hides all sprites from here onwards
ld a, 255
nop
nop
out (c), a ; X
ld a, EMPTY_SPR_PAT_NUMBER
nop
nop
out (c), a ; pattern
xor a
nop
nop
out (c), a ; not used
djnz .loop_HideAllSprites
ret