-
Notifications
You must be signed in to change notification settings - Fork 0
/
ingame.asm
2949 lines (2518 loc) · 52.8 KB
/
ingame.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
; XXXXXXXXXXXXXZZZZZZZZZZ============-----------...............
; XXX ...
; XXX Initialize Game ...
; XXX ...
; XXXXXXXXXXXXXXXXXXXXZZZZZZZZZZZZZ================------------
DEFSECT "START_MAIN", CODE
SECT "START_MAIN"
; mis stuff
GLOBAL _InGameStart
EXTERN _GameEndSequence
EXTERN _LevelList
GLOBAL _GameSettings
GLOBAL _GameContrast
GLOBAL _InGameStart
GLOBAL GameFlags
GLOBAL _MainLoopRender
; sound driver
EXTERN _ADPM_RUN
EXTERN _ADPM_SETUP
EXTERN _ADPM_SFXbank
EXTERN _ADPM_SFXdir
EXTERN _ADPMrunSFX
EXTERN _ADPM_SFXoverlay
; music and sound
EXTERN _SongList
EXTERN _SFXdata
; graphics
EXTERN StripeDta
EXTERN SprDta_Dawn_Sh1
EXTERN SprDta_Dawn_Sh2
EXTERN SprDta_Expl_Sh1
EXTERN SprDta_Expl_Sh2
EXTERN BannerData
EXTERN PauseBannerIdle
EXTERN PauseBannerMenu
EXTERN GFX_NumbersBlack
EXTERN GFX_NumbersWhite
EXTERN PauseSoundSettingsText
EXTERN PauseRumbleSettingOFF
EXTERN PauseRumbleSettingON
_MainLoopRender:
rete
_InGameStart:
; interrupts
ld a, #0
ld [br:020h], #11111111b ; priority
ld [br:021h], #11111111b
ld [br:022h], #11111111b
ld [br:023h], #00001000b ; enable
ld [br:024h], a
ld [br:025h], a
ld [br:026h], a
ld [br:027h], #11111111b ; flags
ld [br:028h], #11111111b
ld [br:029h], #11111111b
ld [br:02Ah], #11111111b
; timers
ld [br:80h], a
ld hl, #0D854h ;#0D4D4h
ld [2032h], hl
ld [br:18h], #10001000b
; ld [br:19h], #00110000b
ld [br:30h], #10000110b
ld [br:0FEh], #10101111b
ld [br:0FEh], #10100111b
ld [br:01Ch], #10001000b ; timer 3
ld [br:01Dh], #00000000b
ld [br:048h], #10000110b
ld [br:019h], #00100000b ; oscillator
ld [br:070h], #0 ; sound
ld [br:071h], #00000011b
carl InitObjBuffer
ld a, #80h ; center player pos
ld [PlayerPos], a
ld a, #10h
ld [ObjSpawnWait], a
ld a, #@dpag(_SFXdata) ; bank
ld [_ADPM_SFXbank], a
ld hl, #_SFXdata
ld [_ADPM_SFXdir], hl
ld a, #00000111b; TEST INSTRUCTION REMOVE LATER
ld [_GameSettings], a
ld a, #31
ld [_GameContrast], a
ld a, #0FFh
ld [CurrentSong], a
ld a, #0
ld [CurrentLevel], a
carl InitLevel
ld a, #00000100b ; dummy on, sprite off, frame even
ld [GameFlags], a
; show first banner
ld a, [CurrentLevel]
ld [BannerCurrNumber], a
carl BannerDispStart
MainLoopStart_NoBanner:
ld hl, #GameFlags
and [hl], #11110011b ; turn off ObjGen dummy mode and clear ObjEv flag
or [hl], #00000001b ; turn on sprite
ld a, #@HIGH(SprDta_Dawn_Sh1) ; setup dawn's ingame sprites
ld [SpritePage], a
carl DrawProgressCounter
; XXXXXXXXXXXXXZZZZZZZZZZ============-----------...............
; XXX ...
; XXX In-Game Loop ...
; XXX ...
; XXXXXXXXXXXXXXXXXXXXZZZZZZZZZZZZZ================------------
MainLoop:
; get inputs
ld l, [br:52h]
ld a, l
ld b, [LastInput]
and a, #10000000b
and b, #10000000b
cp a, b
ld a, l
jrs z, SleepStillPressed
ld [LastInput], a
bit a, #10000000b
jrs nz, NoSleep
ld [br:71h], #0 ; turn off audio output
int [42h]
ld [br:0FEh], #10100111b ; invert LCD back
NoSleep:
SleepStillPressed:
ld a, l
ld b, [LastInput]
and a, #00000100b
and b, #00000100b
cp a, b
ld a, l
jrs z, CstillPressed
ld [LastInput], a
bit a, #00000100b
jrs nz, CstillPressed
jrl PauseGame
CstillPressed:
ld hl, #PlayerPos
ld b, [hl]
ld [LastPos], b
; ld b, #0
bit a, #00100000b ; left
jrs nz, NoLeft
add [hl], #6
; clobber
cp [hl], #0E0h
jrs c, NoLeft
ld [hl], #0E0h
NoLeft:
bit a, #01000000b ; right
jrs nz, NoRight
sub [hl], #6
; clobber
cp [hl], #020h
jrs nc, NoRight
ld [hl], #020h
NoRight:
ld a, [LastPos]
cp a, [hl]
jrs z, DawnSprIdle
jrs nc, DawnSprLeft
jrs c, DawnSprRight
DawnSprLeft:
ld b, #64
jrs SpriteSet
DawnSprRight:
ld b, #32
jrs SpriteSet
DawnSprIdle:
ld b, #0
SpriteSet:
ld [SpriteIndex], b
; XXXXXXXXXXXXXZZZZZZZZZZ============-----------...............
; XXX ...
; XXX Player Collision ...
; XXX ...
; XXXXXXXXXXXXXXXXXXXXZZZZZZZZZZZZZ================------------
; dawn's hitbox is represented by two points relative from the center player pos
; -24 --- Player pos --- +24
; if either of these points are inside the hit region of the wall then dawn is dead
; the hit region depends on the wall type
; but if for some case the wall happens to be in between the hit points, an additional check between the hit points is made
; if there is a wall point inside then dawn is dead
; the check works by taking a point and range comparing it against the wall points
; if both wall points are to the left or to the right relative to the player point, the point is outside range
; if the wall points are different, the player point is inside range
; this is done twice because dawn has two points
; outside range (dead if apr wall)
; Dawn A: <<
; Dawn B: <<
; Dawn A: >>
; Dawn B: >>
; inside range (dead if strip wall)
; Dawn A: ><
; Dawn B: ><
; in boundary (dead regardless of wall type)
; Dawn A ><
; Dawn B >>
; Dawn A <<
; Dawn B ><
; Dawn A << ; inside a very thin strip wall
; Dawn B >>
; note on subtraction carry relationship:
; --- cp a, b ---
; if A >= B, carry is clear
; if A < B, carry is set
ld ix, #ObjState7 ; check if the wall is in the hit position
ld a, #0F0h
cp a, [ix]
jrl nz, Collision_Done
inc ix ; check if wall type is not empty
ld a, #0
cp a, [ix]
jrl z, Collision_Done
inc ix
ld a, [PlayerPos]
cpl a
ld hl, #0
sub a, #18
cp a, [ix] ; left point
jrs c, Collision_PointAtLeft1
ld l, #1
Collision_PointAtLeft1:
inc ix
cp a, [ix] ; right point
jrs c, Collision_PointAtLeft2
ld h, #1
Collision_PointAtLeft2:
push hl
ld hl, #0
dec ix
add a, #18+18
cp a, [ix] ; left point
jrs c, Collision_PointAtLeft3
ld l, #1
Collision_PointAtLeft3:
inc ix
cp a, [ix] ; right point
jrs c, Collision_PointAtLeft4
ld h, #1
Collision_PointAtLeft4:
; compare points
pop ba
cp a, b
jrs nz, Collision_InsideRange1
or a, a
jrs z, Collision_OutsideRange1 ; left
ld a, #2 ; right
jrs Collision_OutsideRange1
Collision_InsideRange1:
ld a, #1
Collision_OutsideRange1:
ex ba, hl
cp a, b
jrs nz, Collision_InsideRange2
or a, a
jrs z, Collision_OutsideRange2 ; left
ld a, #2 ; right
jrs Collision_OutsideRange2
Collision_InsideRange2:
ld a, #1
Collision_OutsideRange2:
ld b, l
cp a, b
ld b, [ObjState7+1] ; get wall type
jrl nz, DawnIsFuckingDead ; if they differ then it's insta kill
cp a, #1
jrs z, Collision_InsideWallRange
; or else outside
cp b, #2 ; check for type = aperture
jrl z, DawnIsFuckingDead
jrs Collision_Done
Collision_InsideWallRange:
cp b, #1 ; check for type = strip
jrl z, DawnIsFuckingDead
Collision_Done:
carl _CalcObj
carl _RenderGameState
carl _DisplayBuffer
carl _SoundRun
; LEVEL LOOP CONTROL
ld hl, #GameFlags
bit [hl], #00001000b ; check step flag
jrl z, LvlCon_ContinueMain
and [hl], #11110111b ; set flag back off
; increment level count
ld hl, #LevelTime
inc [hl]
ld sc, #00010000b
ld ba, [LevelTimeBCDlow]
add a, #1
ld [LevelTimeBCDlow], a
ld a, b
adc a, #0
ld [LevelTimeBCDhigh], a
ld sc, #00000000b
carl DrawProgressCounter
; check if level count hit disable limit
ld a, [LevelTime]
cp a, #120-70
jrs nz, LvlCon_NoDisable
ld hl, #GameFlags
or [hl], #00000100b ; enable dummy mode
LvlCon_NoDisable:
; check if it hit end level limit
cp a, #136-70
jrl z, LvlCon_AutoCenter
LvlCon_ContinueMain:
; this works, cool! but i might have a better idea
; - make the CalcObj call to return a flag only when a wall steps
; - increment level time externally and work with it that way
halt
jrl MainLoop
DrawProgressCounter:
; refresh progress counter
; setup area
ld ix, #GFX_NumbersBlack
ld [br:0FEh], #10110111b ; select last row
ld [br:0FEh], #00010100b ; 5th column area
ld [br:0FEh], #12 ; offset inside column area
; start refreshing area
ld [br:0FFh], #0
; print level number
ld a, [CurrentLevel]
inc a
carl PrintNum
; print the short dash in the middle
ld [br:0FFh], #00010000b
ld [br:0FFh], #00010000b
ld [br:0FFh], #00000000b
ld a, [LevelTime]
sub a, #8
ld hl, [LevelTimeBCDlow]
jrs nc, LvlCon_NumDone
ld hl, #0AAAh
; jrs LvlCon_NumDone
;LvlCon_KeepNum:
; swap a
; add a, #60h
; jrs nc, LvlCon_BCDnoOver1
; inc a
; jrs LvlCon_BCDOverFlw1
;LvlCon_BCDnoOver1:
; sub a, #60h
;LvlCon_BCDOverFlw1:
;
; swap a
; add a, #60h
; jrs nc, LvlCon_BCDnoOver2
; inc h
; jrs LvlCon_BCDOverFlw2
;LvlCon_BCDnoOver2:
; sub a, #60h
;LvlCon_BCDOverFlw2:
; ld l, a
LvlCon_NumDone:
; print high number
ld a, h
carl PrintNum
; print middle number
ld a, l
swap a
and a, #00001111b
carl PrintNum
; print low number
ld a, l
and a, #00001111b
carl PrintNum
ret
; XXXXXXXXXXXXXZZZZZZZZZZ============-----------...............
; XXX ...
; XXX Player Death Animation Loop ...
; XXX ...
; XXXXXXXXXXXXXXXXXXXXZZZZZZZZZZZZZ================------------
DawnIsFuckingDead:
ld a, [_GameSettings]
bit a, #00000100b ; check for rumble ON/OFF setting
jrs z, Dead_NoRumble
ld [br:061h], #01111100b ; rumble ON, IR OFF, EEPROM I2C do nothing
Dead_NoRumble:
ld a, #0 ; sound effect
ld [_ADPM_SFXoverlay], a
ld a, #70 ; frame counter
ld [DeadFrameCount], a
ld a, #0
ld [ExplosionAnimCount], a
ld [SpriteIndex], a
ld a, #@HIGH(SprDta_Expl_Sh1)
ld [SpritePage], a
Dead_WaitLoop:
; explosion animation
ld a, [ExplosionAnimCount]
cp a, #16
jrs z, Dead_SkipExplosion
inc a
ld b, a
ld [ExplosionAnimCount], a
swap a
and a, #11100000b
ld [SpriteIndex], a
cp b, #16
jrs nz, Dead_SkipExplosion
ld hl, #GameFlags
and [hl], #11111110b ; player off
ld [br:061h], #01101100b ; rumble OFF, IR OFF, EEPROM I2C do nothing
Dead_SkipExplosion:
; close out animation
ld a, [DeadFrameCount]
cp a, #25
jrs nc, Dead_SkipCloseAnim
; slp
add a, a
ld l, a
ld b, #0
ld ix, #StripBuffer
add ix, ba
add ix, #47
xor a, a
ld [ix], ba
ld ix, #StripBuffer+48
ld b, #0
ld a, l
sub ix, ba
; sub ix, #2
xor a, a
ld [ix], ba
Dead_SkipCloseAnim:
carl _DisplayBuffer
carl _SoundRun
halt
ld hl, #DeadFrameCount
dec [hl]
jrs nz, Dead_WaitLoop
ld a, #80h
ld [PlayerPos], a
ld [LastPos], a
ld hl, #GameFlags
or [hl], #00000001b ; player on
carl InitObjBuffer
carl InitLevel
jrl MainLoopStart_NoBanner
; XXXXXXXXXXXXXZZZZZZZZZZ============-----------...............
; XXX ...
; XXX Level Complete Loop ...
; XXX ...
; XXXXXXXXXXXXXXXXXXXXZZZZZZZZZZZZZ================------------
LvlCon_AutoCenter:
halt
LvlCon_CenterLoop:
; check direction relative to center (80h)
; add or sub from last position and check if it crosses or equals center
; if it doesn't change or equal, write result to position, else write 80h and end this function
ld a, [PlayerPos]
cp a, #80h
jrs z, LvlCon_CenterDone
jrs c, LvlCon_CenterFromRight
; else from left
ld b, #64
ld [SpriteIndex], b
sub a, #6
cp a, #80h
jrs z, LvlCon_CenterDone
jrs c, LvlCon_CenterDone
jrs LvlCon_ContinueLoop
LvlCon_CenterFromRight:
ld b, #32
ld [SpriteIndex], b
add a, #6
cp a, #80h
jrs z, LvlCon_CenterDone
jrs nc, LvlCon_CenterDone
LvlCon_ContinueLoop:
ld [PlayerPos], a
carl _CalcObj
carl _RenderGameState
carl _DisplayBuffer
carl _SoundRun
halt
jrl LvlCon_CenterLoop
LvlCon_CenterDone:
ld a, #80h
ld [PlayerPos], a
ld [LastPos], a
ld a, #0
ld [SpriteIndex], a
ld b, #10
LvlCon_WaitFrames:
push b
carl _CalcObj
carl _RenderGameState
carl _DisplayBuffer
carl _SoundRun
halt
pop b
djr nz, LvlCon_WaitFrames
; increment level
ld hl, #CurrentLevel
inc [hl]
cp [hl], #3 ; level 4
ld a, #6
ld [BannerCurrNumber], a
carl z, BannerDispStart ; display "BOMB DOWN"
ld a, [CurrentLevel]
cp a, #6 ; level after 6 (don't exist)
jrs z, GameEndFade
; or else go to next level
carl InitLevel
ld a, [CurrentLevel]
ld [BannerCurrNumber], a
carl BannerDispStart
;LvlCon_WaitObjAlign:
; carl _CalcObj
; carl _RenderGameState
; carl _DisplayBuffer
; carl _SoundRun
; halt
; ld a, [ObjState0]
; cp a, #87h
; jrs nz, LvlCon_WaitObjAlign
jrl MainLoopStart_NoBanner
GameEndFade:
ld a, #7
ld [BannerCurrNumber], a
carl BannerDispStart
; wait 128 frames to empty out the ObjBuffer
ld a, #80h
ld [WaitFramesCount], a
ld a, #10
ld [ObjState0], a
ld hl, #GameFlags
and [hl], #11111110b
or [hl], #00010000b
LvlCon_EndWaitLoop:
; decrement spawn count
ld hl, #ObjSpawnWait
dec [hl]
jrl nz, EndingObjGen_StepFrame
ld [hl], #16
; set flag for the main loop's level state track function
; ld hl, #GameFlags
; or [hl], #00001000b ; step flag on
ld hl, #EndingFadeCount
inc [hl]
; begin spawn obj process
ld ix, #ObjState6
ld b, #7
EndingObjGen_MoveBuffer:
ld hl, [ix]
ld [ix+4], l
ld [ix+5], h
add ix, #2
ld hl, [ix]
ld [ix+4], l
ld [ix+5], h
sub ix, #6
djr nz, EndingObjGen_MoveBuffer
ld hl, #ObjState0
sub [hl], #10h
jrs EndingObjGen_SpawnBlank
EndingObjGen_StepFrame:
ld hl, #ObjState0
ld b, #8h
EndingObjGen_CalcLoop:
inc [hl]
add hl, #4
djr nz, EndingObjGen_CalcLoop
jrs EndingObjGen_Done
EndingObjGen_SpawnBlank:
ld hl, #0
ld [ObjState0+1], l
ld [ObjState0+2], hl
EndingObjGen_Done:
; now overwrite some entries to disappear with them
ld b, [EndingFadeCount]
cp b, #0
jrs z, EndingFadeLoopDone
ld hl, #ObjState0
ld a, #10h ; any value below 80h will not render
EndingFadeLoop:
ld [hl], a
add hl, #4
djr nz, EndingFadeLoop
EndingFadeLoopDone:
carl _RenderGameState
carl _DisplayBuffer
carl _SoundRun
halt
ld hl, #WaitFramesCount
dec [hl]
jrl nz, LvlCon_EndWaitLoop
jrl _GameEndSequence
; slp
; XXXXXXXXXXXXXZZZZZZZZZZ============-----------...............
; XXX ...
; XXX Display Level/Event Banner loop ...
; XXX ...
; XXXXXXXXXXXXXXXXXXXXZZZZZZZZZZZZZ================------------
; hide dawn's sprite
; scroll from the left to right (easier to do so) untill it hits 96 scroll pos
; decrement the frame counter
; scroll the banner back into the left untill it hits 0 scroll pos
; show dawn's sprite again
; pass execution to in-game loop
BannerDispStart:
xor a, a
ld [BannerScrollPos], a
ld a, #80
ld [BannerFrameCount], a
Banner_Loop:
ld hl, #BannerFrameCount
cp [hl], #0
jrs z, Banner_scrollout
; scroll banner in
ld hl, #BannerScrollPos
cp [hl], #95
jrs nc, Banner_Wait
add [hl], #2
jrs Banner_ContinueLoop
Banner_Wait:
ld hl, #BannerFrameCount
cp [hl], #0
jrs z, Banner_scrollout
dec [hl]
jrs Banner_ContinueLoop
Banner_scrollout:
ld hl, #BannerScrollPos
sub [hl], #2
jrl z, Banner_BannerDone
jrl c, Banner_BannerDone
Banner_ContinueLoop:
carl _CalcObj
carl _RenderGameState
; carl _DisplayBuffer
; display buffer, but custom made for event banners
ld iy, #StripeDta
ld hl, #GameFlags
xor [hl], #00000010b
bit [hl], #00000010b
jrs z, BannerRender_FrameIsEven
add iy, #200h
BannerRender_FrameIsEven:
ld [br:0FEh], #10110000b
carl PageCopy
add iy, #32
ld [br:0FEh], #10110001b
carl PageCopy
add iy, #32
ld [br:0FEh], #10110010b
carl PageCopy
add iy, #32
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; copy banner into video memory
; note: the banner scroll value won't go beyond 96
ld ix, #BannerData
ld a, [BannerCurrNumber] ; index to the banner going to be displayed
ld l, #192
mlt
add ix, hl
ld b, [BannerScrollPos]
ld a, #96
sub a, b ; invert scroll pos to get the end of the banner's first page
; to get to the second page it's as easy as just adding 96 to this
ld l, a
ld h, b
; display first half page
ld [br:0FEh], #10110011b
carl Banner_CopyPage
add iy, #32
ld ix, #BannerData+96
ld a, [BannerCurrNumber] ; index to the banner going to be displayed
ld l, #192
mlt
add ix, hl
ld b, [BannerScrollPos]
ld a, #96
sub a, b ; invert scroll pos to get the end of the banner's second page
ld l, a
ld h, b
; display second half page
; ld [br:0FEh], #0
; ld [br:0FEh], #00010000b
ld [br:0FEh], #10110100b
carl Banner_CopyPage
add iy, #32
; jrs Banner_FinishCopies
ld [br:0FEh], #10110101b
carl PageCopy
add iy, #32
ld [br:0FEh], #10110110b
carl PageCopy
add iy, #32
ld [br:0FEh], #10110111b
carl PageCopy
carl _SoundRun
; push ip
; carl _ADPM_RUN
; pop ip
; push ip
; carl _ADPMrunSFX
; pop ip
halt
jrl Banner_Loop
Banner_BannerDone:
ret
; ld a, #96
; sub a, b
; ld l, a
; ld h, b
; add ix, #96
;Banner_CopyPage2:
; ld a, [ix+l]
; inc l
; ld [br:0FFh], a
; dec h
; db 0E7h, 0F9h ; jr nz, .CopyPage2
; add iy, #64 ; just for test purposes
; jrs Banner_FinishCopies
Banner_CopyPage:
ld [br:0FEh], #0
ld [br:0FEh], #00010000b
ld a, [ix+l]
inc l
ld [br:0FFh], a
dec h
db 0E7h, 0F9h ; jr nz, .CopyPage
; render remaining area as strip buffer like normal
ld a, [BannerScrollPos]
ld l, #9
mlt
ld ix, #PageCopy_LoopBase
add hl, ix
bit a, #1
jrs z, Banner_ScrollIsEven
add hl, #3
Banner_ScrollIsEven:
ld ix, #StripBuffer+1
ld b, #0
add ix, ba
; ld a, #0
; push a
; ld ba, #thisAddr
; push ba
jp hl
;thisAddr:
;Banner_FinishCopies:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; XXXXXXXXXXXXXZZZZZZZZZZ============-----------...............
; XXX ...
; XXX Audio Management ...
; XXX ...
; XXXXXXXXXXXXXXXXXXXXZZZZZZZZZZZZZ================------------
_SoundRun:
ld a, [_GameSettings]
bit a, #00000001b
jrs nz, SoundRun_KeepSFX
ld a, #0FFh ; or else disable SFX
ld [_ADPM_SFXoverlay], a
SoundRun_KeepSFX:
push ip
ld a, [_GameSettings]
bit a, #00000010b
carl nz, _ADPM_RUN
pop ip
push ip
ld a, [_GameSettings]
bit a, #00000001b
carl nz, _ADPMrunSFX
pop ip
ld a, [_GameSettings]
and a, #00000011b
cp a, #00000001b ; if only SFX is enabled, it's required that the sound is terminated when the sound effect ends
jrs nz, SoundRun_SoundDone
ld a, [_ADPM_SFXoverlay]
inc a ; check if 0
jrs nz, SoundRun_SoundDone
ld [br:71h], a
SoundRun_SoundDone:
ret
; XXXXXXXXXXXXXZZZZZZZZZZ============-----------...............
; XXX ...
; XXX Pause State ...
; XXX ...