-
Notifications
You must be signed in to change notification settings - Fork 0
/
scenarii.asm
1557 lines (1277 loc) · 23.6 KB
/
scenarii.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
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
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
; Scenarii
; FKey Demo 2010
;**********************
; Scenario - idle
;**********************
.idle
ret
;********************
; Scenario - Test END
;********************
forceNextScenario
; reset all remainings framecount in scenarii table
ld hl,(frameCount+1)
ld de,(testEnd+1)
add hl,de
ex de,hl ; de contains what should be added to remaining scenarii framecounts
ld ix,(nextScenario+1)
ld bc,4 ; const
.loopForceScenario
ld l,(ix)
ld h,(ix+1)
ld a,l
or h ; reset carry flag
jp z,forceNextScenario2 ; if zero then we reached end of scenarii
sbc hl,de
ld (ix),l
ld (ix+1),h
add ix,bc
jp loopForceScenario
.testEnd
ld hl,-SCENARIO_STEP01 ; first scenario should be hard coded
add hl,de
ret nc ; not finished
.forceNextScenario2
push af
; if the scenario is finished we should
; - set next call
; - prepare the next test
.nextScenario
ld hl,scenarii+4
ld de,testEnd+1
ldi:ldi
ld de,currentScenario+1
ldi:ldi
ld (nextScenario+1),hl
pop af
ret
;**********************
; Scenario - delayStart
;**********************
;.delayStart
; ; end test
; jp testEnd
;**********************
; Scenario - openScreen
;**********************
; in de=
; corrupt a,b,hl
.openScreen
call testEnd
ret c
.sinOpen
ld a,(sin_intro+128)
ld b,a
ld hl,sinOpen+1
inc (hl)
ld hl,delayIntro1-1
ld (hl),a
ret
;*************************
; Scenario - setMode2Trick
;*************************
; in de=frameCount
; corrupt a,b,hl
.setMode2Trick
halt
; reset DMA
ld hl,aylMultimode
ld (DMA2ADD+1),hl ; set DMA2 to produce interrupts
ld hl,DMACTL+1
set 2,(hl) ; enable DMA2
; swap interrupt vector
ld hl,screen_on
ld (intJMP+1),hl
jp testEnd
; toggle witch's eyes
.toggleWitchEyes
ld hl,blinkEyes
ld a,&C9 ; toggle between ret/nop
xor (hl)
ld (hl),a
jp testEnd
;**********************
; Scenario - run3DBalls
;**********************
.run3DBalls
; end test
; end test
call testEnd
jp c,endFirstBalls
.run3DBalls2
; ***********************************************
; The following code compute the new 2D positions
; ***********************************************
call change_object
; copy original pos
ld hl,morphobj
ld bc,(nbBallsMul3)
ld de,ballpos3D
ldir
.rotat_inc1
ld a,0
inc a
ld (rotat_inc1+1),a
ld (angleX+1),a
.rotat_inc2
ld hl,0
ld bc,&C3
add hl,bc
ld (rotat_inc2+1),hl
ld a,h
ld (angleY+1),a
.rotat_inc3
ld hl,0
ld bc,&131
add hl,bc
ld (rotat_inc3+1),hl
ld a,h
ld (angleZ+1),a
;.rotation_inc
;ld a,0
;inc a
;ld (rotation_inc+1),a
; rotation
ld h,sin/256
;ld l,a
; get all angles
;ld d,32 ; angle suivant X
;ld b,(hl) ; angle suivant Y
;ld c,(hl) ; angle suivant Z
.angleX
ld l,0
ld d,(hl) ; angle suivant X
.angleY
ld l,0
ld b,(hl) ; angle suivant Y
.angleZ
ld l,0
ld c,(hl) ; angle suivant Z
call rotation
.speed_FX
call speed_effect
.symetrie
call symetrie_centrale
; project 3D to 2D position
;call projection
; sort balls using Z
call sortZ
; Translate object on screen & Save Positions
call moveSave2D
.enableSecondObject
ret
;*****************
;* SECOND OBJECT *
;*****************
; direct memory update (4 balls)
; second object
ld hl,NB_BALLS_SECOND
ld (nbBalls),hl
ld hl,NB_BALLS_SECOND*3
ld (nbBallsMul3),hl
ld hl,NBCRD*NB_BALLS_SECOND + ballpos3D_second - 1
ld (crdEndNbBalls),hl
ld a,ballpos3D_second/256
ld (saveBall2D+1),a
ld hl,ballpos2Dend_second
ld (saveBall2D_SP+1),hl
ld hl,0 : org $-2 : ld a,64+128
ld (movY3D),hl
; invert X
ld hl,0 : org $-2 : neg
ld (invertX),hl
call change_object2
; copy original pos
ld hl,morphObj2
ld bc,(nbBallsMul3)
ld de,ballpos3D_second
ldir
.rotation_inc2
ld a,0
inc a
ld (rotation_inc2+1),a
; rotation
ld h,sin/256
ld l,a
; get all angles
ld d,(hl) ; angle suivant X
ld b,32 ; angle suivant Y
ld c,(hl) ; angle suivant Z
call rotation
; speed effect
;call speed_effect
; Symetrie centrale
ld hl,(crdEndNbBalls)
ld de,NBCRD*NB_BALLS_TOTAL + ballpos3D_second - 1
ld a,(nbBalls)
add -NB_BALLS_TOTAL
neg
ld b,a
.symetrie2
; X
ld a,(hl)
dec hl
neg
ld (de),a
dec de
; Y
ld a,(hl)
dec hl
neg
ld (de),a
dec de
; Z
ld a,(hl)
dec hl
neg
ld (de),a
dec de
djnz symetrie2
; Translate object on screen & Save Positions
call moveSave2D
; direct memory update (8 balls)
; first object
ld hl,NB_BALLS
ld (nbBalls),hl
ld hl,NB_BALLS*3
ld (nbBallsMul3),hl
ld hl,NBCRD*NB_BALLS + ballpos3D - 1
;ld hl,NBCRD*NB_BALLS_SECOND + ballpos3D - 1
ld (crdEndNbBalls),hl
ld a,ballpos3D/256
ld (saveBall2D+1),a
ld hl,ballpos2Dend
ld (saveBall2D_SP+1),hl
ld hl,0 : org $-2 : ld a,60
ld (movY3D),hl
; invert X
ld hl,0
ld (invertX),hl
;*********************
;* END SECOND OBJECT *
;*********************
ret
.endFirstBalls
; we reach the end of this scenario
; - remove call
; - exit
;ld a,&C9 ; disable 3D display
;ld (display3D),a
;ld (display3D_second),a
; set null object
ld hl,0 : org $-2 : ld a,OBJECTS_NUMBER
ld (forceObject),hl
ld (forceObject2),hl
; reset timing (morphing next frame)
ld hl,-1
ld (object_timing),hl
ld (object_timing2),hl
; enable morphing
xor a
ld (morphing),a
ld (morphing2),a
; save last X position
ld a,&21 ; ld hl,xx
ld (movX3D),a
ld hl,(XTRANS+1)
ld (movX3D+1),hl ; ld hl,(movX3D+1)
ret
;**********************
; Scenario - end3DBalls
;**********************
.collapse3DBalls
; end test
call testEnd
jp c,endcollapse3DBalls
; move to &300 (hidden)
ld hl,(movX3D+1)
ld bc,11
add hl,bc
ld a,&3
cp h
jp nz,nofixTo300
ld hl,&300
.nofixTo300
ld (movX3D+1),hl
jp run3DBalls2
.endcollapse3DBalls
; we reach the end of this scenario
; - remove call
; - exit
ld a,&C9 ; disable 3D display
ld (display3D),a
ld (display3D_second),a
ret
;**********************
; Scenario - multiSprite
;**********************
dw setMultiSprite1
dw setMultiSprite2
dw setMultiSprite3
; in de=frameCount
; corrupt a,b,hl
.initMulti
; end test
call testEnd
jr c,endSetMulti
.nextMulti
ld hl,initMulti-6
ld e,(hl)
inc hl
ld d,(hl)
inc hl
ld (nextMulti+1),hl
ex hl,de
halt
jp (hl)
ret
.endSetMulti
; reset initVector
ld hl,initMulti-6
ld (nextMulti+1),hl
call bg_compute
jp setMultiSprite4
;ret
;**********************
; Scenario - drawMulti
;**********************
; in de=frameCount
; corrupt hl,a
.drawMulti
; end test
call testEnd
jr c,endDrawMulti
.dMOffset
ld hl,&6004
; Connect Asic
ld bc,&7FB8 ; [3]
out (c),c ; [4]
ld (hl),ZOOM_MULTI
; Deconnect Asic
ld bc,&7FA0
out (c),c
ld a,8
add l
ld (dMOffset+1),a ; save next Offset
; compute X position
call bg_compute
ret
.endDrawMulti
; reset zoom init offset
ld a,&04
ld (dMOffset+1),a
; compute X position
call bg_compute
ret
;**********************
; Scenario - vanishMulti
;**********************
; in de=frameCount
; corrupt hl,a
.vanishMulti
; end test
call testEnd
jr c,endFirstMulti;endVanishMulti
.dMOffsetVanish
ld hl,&6004
; Connect Asic
ld bc,&7FB8 ; [3]
out (c),c ; [4]
ld (hl),0
; Deconnect Asic
ld bc,&7FA0
out (c),c
ld a,8
add l
ld (dMOffsetVanish+1),a ; save next Offset
; compute X position
call bg_compute
ret
;.endVanishMulti
; ; reset zoom init offset
; ld a,&04
; ld (dMOffsetVanish+1),a
;
; ; compute X position
; call bg_compute
;
; ret
;***********************
; Scenario - runMulti
;***********************
.runMulti
; end test
call testEnd
jp c,bg_compute
;jr c,endFirstMulti
; compute X position
call bg_compute
ret
.endFirstMulti
; reset zoom init offset
ld a,&04
ld (dMOffsetVanish+1),a
; disable RASTER interrupts
ld hl,intVoid
ld (intvect+4),hl
ld (intvect+6),hl
; Connect Asic
ld bc,&7FB8 ; [3]
out (c),c ; [4]
; set PRI to END of screen
ld hl,&6800
ld (hl),&FF
; deco asic
call deco_asic
; change second multi text sprite
; and prepare 3rd one
.nextMultiSprite
ld hl,txtSprite2_end-1-4
ld (txtSpriteOffset+1),hl
ld hl,txtSprite3_end-1-4
ld (nextMultiSprite+1),hl
ret
;*******************
; Scenario - set3DA
;*******************
; in de=frameCount
; corrupt a,b,hl
dw set3DSpriteA1
dw set3DSpriteA2
dw set3DSpriteA3
.set3DA
; end test
call testEnd
jr c,endSet3DA
.nextSet3DA
ld hl,set3DA-6
ld e,(hl)
inc hl
ld d,(hl)
inc hl
ld (nextSet3DA+1),hl
ex hl,de
halt
jp (hl)
ret
.endSet3DA
; we reach the end of this scenario
; - enable display3D
; - Reset scenario length
; reset initVector
ld hl,set3DA-6
ld (nextSet3DA+1),hl
; enable display3D 1
xor a
ld (display3D),a
; enable speed effect
ld (speed_effect),a
; enable Z sorting (transparent)
ld (sortZ),a
; Fix Y coords to 60 (top)
ld hl,0 : org $-2 : ld a,b : nop
ld (movY3D),hl
; disable second object rotation
ld a,0 : org $-1 : ret
ld (enableSecondObject),a
; disable second display3D
ld (display3D_second),a
; enable morphing between objects
ld hl,0
ld (forceObject),hl
; reset timing (morphing next frame)
ld hl,-1
ld (object_timing),hl
; enable morphing
xor a
ld (morphing),a
; reset X scroll
ld a,0 : org $-1 : ex hl,de ;HL<-X
ld (movX3D),a
ld hl,0 ; nop;nop
ld (movX3D+1),hl
; enable change in symetrie and speedFX
xor a
ld(enableSym3DFx),a
ret
;*******************
; Scenario - set3DB
;*******************
; in de=frameCount
; corrupt a,b,hl
dw set3DSpriteB1
dw set3DSpriteB2
dw set3DSpriteB3
.set3DB
; end test
call testEnd
jr c,endSet3DB
.nextSet3DB
ld hl,set3DB-6
ld e,(hl)
inc hl
ld d,(hl)
inc hl
ld (nextSet3DB+1),hl
ex hl,de
halt
jp (hl)
ret
.endSet3DB
; we reach the end of this scenario
; - enable display3D
; - Reset scenario length
; reset initVector
ld hl,set3DB-6
ld (nextSet3DB+1),hl
; enable display3D
xor a
ld (display3D),a
ld (display3D_second),a
; disable speed effect
ld a,0 : org $-1: ret
ld (speed_effect),a
; Fix Y coords to 60 (top)
ld hl,0 : org $-2 : ld a,60
ld (movY3D),hl
; disable Z sorting (transparent)
ld hl,sortZ
ld (hl),0 : org $-1 : ret
; enable second object rotation
xor a
ld (enableSecondObject),a
; enable morphing between objects
ld hl,0
ld (forceObject),hl
ld (forceObject2),hl
; reset timing (morphing next frame)
ld hl,-1
ld (object_timing),hl
ld (object_timing2),hl
; enable morphing
xor a
ld (morphing),a
ld (morphing2),a
; reset X scroll
ld a,0 : org $-1 : ex hl,de ;HL<-X
ld (movX3D),a
ld hl,0 ; nop;nop
ld (movX3D+1),hl
; force symetrie centrale for object 1
; and disable change in symetrie and speedFX
ld hl,symetrie_centrale
ld (symetrie+1),hl
ld a,0:org $-1:ret
ld(enableSym3DFx),a
ret
;*******************
; Scenario - set3DC
;*******************
; in de=frameCount
; corrupt a,b,hl
dw set3DSpriteC1
dw set3DSpriteC2
dw set3DSpriteC3
dw set3DSpriteC4
.set3DC
; end test
call testEnd
jr c,endSet3DC
.nextSet3DC
ld hl,set3DC-8
ld e,(hl)
inc hl
ld d,(hl)
inc hl
ld (nextSet3DC+1),hl
ex hl,de
; call (hl) with asic locked
call HL_WithAsicLocked
ret
.endSet3DC
; Replace sphere2D by sphere3D
ld hl,sphere3D
ld (0*5+obj_seq),hl
; set symetrie centrale
ld hl,symetrie_centrale
ld (0*5+obj_seq+2),hl
; reset speed FX
xor a
ld (0*5+obj_seq+4),a
jp endSet3DA
;***********************
; Scenario - initrotoZoom
;***********************
.initrotoZoom
; end test
halt
call setRotoZoom
ld a,&C9 ; disable 3D display
ld (display3D),a
jp testEnd
;***********************
; Scenario - rotoZoom
;***********************
.rotoZoom
; end test
call testEnd
jr c,endrotoZoom
jp displayRotoZoom
.endrotoZoom
; wait to be in the bottom part of the screen (mode 2)
halt:halt:halt
; Connect Asic
ld bc,&7FB8
out (c),c
; hide sprites (brutally)
call hideAllSprites
; reset DMA
ld hl,aylMultiModeIntro
ld (DMA2ADD+1),hl ; set DMA2 to produce interrupts
ld hl,DMACTL+1
set 2,(hl) ; enable DMA2
; Deconnect Asic
ld bc,&7FA0
out (c),c
; swap interrupt vector
ld hl,screen_intro
ld (intJMP+1),hl
ret
;***********************
; Scenario - initBMP
;***********************
dw setBumpMap0
dw setBumpMap1
dw setBumpMap2
.initBMP
push de
.nextInitBMP
ld hl,initBMP-6
ld e,(hl)
inc hl
ld d,(hl)
inc hl
ld (nextInitBMP+1),hl
ex hl,de
; call (hl) with asic locked
call HL_WithAsicLocked
pop de
jp testEnd
;***********************
; Scenario - MuteSound
;***********************
.runMuteSound
; end test
call testEnd
jr c,endRunMuteSound
; carry not set ...
ld a,256
dec a
ld ($-2),a
rra
rra
rra
rra
and &F
; to mute music we need to :
; 1 - mute psg volumes (reg 8,9,A)
; 2 - mute sid voices playing
ld hl,reg8
cp (hl)
jp P,$+3+1
ld (hl),a
ld hl,reg9
cp (hl)
jp P,$+3+1
ld (hl),a
ld hl,regA
cp (hl)
jp P,$+3+1
ld (hl),a
ld (shallWeMuteSid+2),a ; set sid mute value
xor a
ld (shallWeMuteSid),a ; enable sid mute
ret
.endRunMuteSound
; *****
; reset
; *****
; stop music decoding
ld a,0:org $-1:ret
ld (player+3),a
; disable all DMAs' but the one for the screen Mode 0/2 Trick
; in the sound player code
ld a,%100
ld (DMACTL+1),a
di
; Connect Asic
ld bc,&7FB8 ; [3]
out (c),c ; [4]
; disable DMA
ld hl,DMACONTROL ; [3]
ld a,%11111100 ; [2]
and (hl) ; [2]
ld (hl),a ; [2]
call waitOneHBL
call waitOneHBL
call waitOneHBL
; reset PSG using AYL on DMA0
ld hl,resetPSGAYL
ld (DMACHANNEL0),hl
; Set DMA0 (reset PSG values)
ld hl,DMACONTROL
set 0,(hl)
; Deconnect Asic
ld bc,&7FA0 ; [3]
out (c),c ; [4]
ei
ret
;.playOnlyDMA2
; ; Connect Asic
; ld bc,&7FB8 ; [3]
; out (c),c ; [4]
;
; ld hl,aylMultiMode ; [3]
; ld (DMACHANNEL2),hl ; [5]
;
; ld hl,DMACONTROL ; [3]
; set 2,(hl)
;
; ; Deconnect Asic
; ld bc,&7FA0 ; [3]
; out (c),c ; [4]
;
; ret
; Used to synchro with HBL
; Legal offsets 0 = [64] to 56 = [8]
.waitOneHBL
ds 64-5-3,0
ret ; [3]
.resetPSGAYL
align 2
dw &0000
dw &0100
dw &0200
dw &0300
dw &0400
dw &0500
dw &0600
dw &073F
dw &0800
dw &0900
dw &0A00
dw &0B00
dw &0C00
dw &0D00
dw &4020
;***********************
; Scenario - runBMPScrollDownEnabled
;***********************
.runBMPScrollDownEnabled
ld a,0 : org $ - 1 : inc a
ld (BMP_SCROLL_DOWN),a
jp runBMP
;***********************
; Scenario - runBMPScrollLeftEnabled
;***********************
.runBMPScrollLeftEnabled
ld hl,0
ld (setBMPPosition00),hl
jp runBMP
;***********************
; Scenario - runBMPOndulXEnabled
;***********************
.runBMPOndulXEnabled
ld a,0 : org $ - 1 : add 127 : org $ - 1
ld (enableOndulX),a
jp runBMP
;***********************
; Scenario - runBMP
;***********************
.lastRunBMP
ld a,0 : org $ - 1 : ret nc
ld (endRunBMP),a ; enable endRunBMP
ld hl,runBMP
ld (currentScenario+1),hl
.runBMP
push de
ld ixl,BMP_YPOS_BASE
ld ixh,2*&20 + BMP_YPOS_BASE
ld iyl,2*&20 + BMP_YPOS_BASE - 1
;jp displayBumpMap
call displayBumpMap
; lock asic
; ld hl,deco_asic ; [3]
; ld (hl),&C9 ; [3]
; connect asic
; ld bc,&7FB8 ; [3]
; out (c),c ; [4]
; Debug Using Sprite 0 ;)
; ld hl,40
; ld (&6000),hl
; ld (&6002),hl
; ld a,%1111
; ld (&6004),a
; sprite 1
; ld a,(intDLRastersCall2+1) ; N,J
; ld de,&4000
; call print8bits
; sprite 6
; ld a,(6*8 + &6002) ; N,J
; ld de,&4008
; call print8bits