-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.asm
executable file
·30938 lines (29660 loc) · 537 KB
/
main.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
INCLUDE "hardware.inc"
INCLUDE "vram.asm"
INCLUDE "macros.asm"
INCLUDE "charmap.asm"
INCLUDE "constants.asm"
SECTION "ROM Bank $00", ROM0[$00]
LoadLevelGBCpalettesHome:
ld de, MBC5RomBank
ld a, Bank(LoadLevelGBCpalettes)
ld [de], a
ld a, [hli]
ld [wHUDTileAttribute], a
ld a, [hli]
ld c, a
ld a, [hli]
ld b, a
ld a, [hGameBoyColorDetection]
cp GBC_MODE
ret nz
push hl
ld a, Bank(LoadLevelGBCpalettes)
ld [de], a
jp LoadLevelGBCpalettes
; Adds a BCD value to the player's score.
; Input: c = value to add
AddScore:
ld a, [hScore]
add c
daa
ld [hScore], a
ld a, [hScore + 1]
adc b
daa
ld [hScore + 1], a
ret
; Waits for VBlank period or immediately returns if LCD is disabled.
WaitUntilSafeToAccessVRAM:
ld a, [rLCDC]
add a
ret nc ; return if LCD is disabled
call WaitVBlank
sub a
ld [rLCDC], a
ret
WaitHBlankStart:
; Waits for the next HBlank period to begin.
ld a, [rSTAT]
and STATF_LCD
jr z, WaitHBlankStart ; If we're already in the middle of HBlank, wait until it's over.
; fallthrough
SECTION "rst 38", ROM0 [$38]
WaitNextHBlank_:
ld a, [rSTAT]
and STATF_LCD
jr nz, WaitNextHBlank_
ret
WaitNextHBlank:
rst $38
; Hardware interrupts
SECTION "vblank", ROM0 [$40]
reti
HovershipSmokeBallSprite1:
dw Load1SubSprite
sub_sprite $7A, $25, 8, 0
SECTION "hblank", ROM0 [$48]
reti
; data related to boss stages? See screendata entries
db $02, $C0, $FF, $A0, $FF, $FF, $FF
SECTION "timer", ROM0 [$50]
reti
HovershipSmokeBallSprite0:
dw Load1SubSprite
sub_sprite $7A, $05, 8, 0
SECTION "serial", ROM0 [$58]
reti
; data related to boss stages? See screendata entries
db $02, $20, $00, $40, $00, $FF, $FF
SECTION "joypad", ROM0 [$60]
reti
SECTION "Home", ROM0 [$61]
; data related to boss stages? See screendata entries
db $03, $C0, $FF, $B0, $FF, $A0, $FF
; Waits until the VBlank period is entered.
WaitVBlank:
ld a, [rLY]
cp SCRN_Y + 1
jr c, WaitVBlank
ret
UpdateFrameCounter:
ld a, [hPaused]
and a
ret nz
ld hl, hFrameCounter
inc [hl]
ret
ResetFrameCounter:
sub a
ld [hFrameCounter], a
ret
LoadCGBPalettesHome:
ld a, Bank(LoadCGBPalettes)
ld [MBC5RomBank], a
jp LoadCGBPalettes
; The Warner Bros. Background banner graphics are only stored in ROM
; with the top-left quadrant. Since the other three quadrants are symmetric,
; this code unpacks the tiledata as such.
LoadWarnerBrosBannerQuadrants:
push hl
ld bc, $8830
ld de, $8940
.asm_8b
ld l, $09
.asm_8d
ld a, [bc]
inc bc
add a
rr h
add a
rr h
add a
rr h
add a
rr h
add a
rr h
add a
rr h
add a
rr h
add a
rr h
ld a, h
ld [de], a
inc de
ld a, c
and $0f
jr nz, .asm_8d
ld a, e
sub $20
ld e, a
ld a, d
sbc 0
ld d, a
dec l
jr nz, .asm_8d
ld a, c
add $90
ld c, a
ld a, b
adc $00
ld b, a
ld a, e
add $b0
ld e, a
ld a, d
adc $01
ld d, a
ld a, b
cp $90
jr nz, .asm_8b
ld bc, $8830
ld de, $96de
ld h, $07
.asm_d7
ld l, $12
.asm_d9
ld a, [bc]
inc bc
ld [de], a
inc de
ld a, [bc]
inc bc
ld [de], a
dec de
dec de
dec de
ld a, c
and $0f
jr nz, .asm_d9
ld a, e
add $20
ld e, a
ld a, d
adc $00
ld d, a
dec l
jr nz, .asm_d9
ld a, e
sub $40
ld e, a
ld a, d
sbc $02
ld d, a
dec h
jr nz, .asm_d7
pop hl
ret
SECTION "Entry", ROM0 [$100]
Func_100:
nop
jp Start
SECTION "Header", ROM0 [$104]
; The header is generated by rgbfix.
; The space here is allocated to prevent code from being overwritten.
ds $150 - $104
SECTION "Main", ROM0
Start:
ld [hGameBoyColorDetection], a
Start_:
di
ld sp, wStack
ld a, Bank(ResetInitialData)
ld [MBC5RomBank], a
call ResetInitialData
call ResetPlayerData
call Func_3e31
call SetInitialScreen
jp InitNextScreen
RunEpilogueSceneScreen:
ld bc, $da00
ld de, $da80
.asm_170
ld a, [bc]
ld [$ff8a], a
ld a, [de]
ld [bc], a
inc c
ld a, [$ff8a]
ld [de], a
inc e
jr nz, .asm_170
call InitScreenMusic
call WriteDMACodeToHRAM
call Func_3dce
call InitKeysState
call ResetFrameCounter
ld hl, Data_1aa1a
call LoadCGBPalettesHome
ld hl, vBGMap
ld bc, $400
ld a, [hGameBoyColorDetection]
cp GBC_MODE
jr nz, .asm_1b1
ld d, $da
.asm_19f
sub a
ld [rVBK], a
ld e, [hl]
ld a, 1
ld [rVBK], a
ld a, [de]
ld [hli], a
dec bc
ld a, c
or b
jr nz, .asm_19f
sub a
ld [rVBK], a
.asm_1b1
ld a, Bank(Func_17b59)
ld [MBC5RomBank], a
jp Func_17b59
Func_1b9:
ld a, $c7
ld [rLCDC], a
.asm_1bd
ld a, [$defd]
ld c, a
ld b, $00
ld hl, rBGPSettings
add hl, bc
ld a, [hl]
and $0c
srl a
srl a
ld b, a
swap a
or b
ld b, a
ld a, [hl]
and $c0
or b
ld [rBGP], a
sub a
ld [rSCY], a
ld hl, BugsEpilogueSpritesData
ld c, $38
ld b, $8e
call Func_cdf
ld hl, LolaEpilogueSpritesData
ld c, $18
ld b, $8e
call Func_cdf
ld hl, BugsEpilogueSpritesData
call Func_cae
.asm_1f6
ld a, [rLY]
cp 55
jr nz, .asm_1f6
call WaitHBlankStart
ld a, [$defd]
ld c, a
ld b, $00
ld hl, rBGPSettings
add hl, bc
ld a, [hli]
ld [rBGP], a
ld a, $70
ld [rSCY], a
ld hl, LolaEpilogueSpritesData
call Func_cae
call ClearOAMBufferHome
call TickMusicEngineHome
call ReadJoyPadHome
call WaitVBlank
ld a, Bank(Func_f585)
ld [MBC5RomBank], a
call Func_f585
call TryInitNextScreenHome
call UpdateFrameCounter
jp .asm_1bd
Func_233:
ld a, [hGameBoyColorDetection]
cp GBC_MODE
ret nz
ld hl, vBGMap
ld b, $da
.asm_23d
sub a
ld [rVBK], a
ld c, [hl]
ld a, 1
ld [rVBK], a
ld a, [bc]
ld [hli], a
ld a, h
cp $9c
jr nz, .asm_23d
sub a
ld [rVBK], a
ret
RunLevelBonusScreen:
ld a, [hEXTRALetters]
cp 5 ; check if player obtained all 5 EXTRA letters
jp nz, InitNextScreen
push hl
ld a, [hGameBoyColorDetection]
cp GBC_MODE
ld hl, ScreenData_LevelBonus
jr nz, .asm_264
ld hl, ScreenDataGBC_LevelBonus
.asm_264
call LoadData
call InitScreenMusic
ld a, Bank(Func_17ba8)
ld [MBC5RomBank], a
call Func_17ba8
ld hl, Data_1b75e
call LoadData
ld a, Bank(Func_17be2)
ld [MBC5RomBank], a
call Func_17be2
pop hl
ld a, $06
ld [MBC5RomBank], a
ld bc, $ddd9
ld a, [hli]
ld [bc], a
inc c
ld a, [hli]
ld [bc], a
inc c
ld a, [hli]
ld [bc], a
inc c
ld a, [hli]
ld [bc], a
inc c
ld hl, $ddde
sub a
ld [hli], a
ld [hli], a
ld a, Bank(Func_7b8a)
ld [MBC5RomBank], a
call Func_7b8a
call WriteDMACodeToHRAM
call Func_3dce
call InitKeysState
call ResetFrameCounter
ld a, Bank(Func_17bf9)
ld [MBC5RomBank], a
call Func_17bf9
ld hl, BonusScreenGBCPalettes
call LoadCGBPalettesHome
ld c, 0
call LoadHUDTileAttributes
call Func_fb4
call Func_233
ld a, LCDCF_ON | LCDCF_WIN9C00 | LCDCF_WINON | LCDCF_BG8800 | LCDCF_BG9800 | LCDCF_OBJ16 | LCDCF_OBJON | LCDCF_BGON
ld [rLCDC], a
.asm_2cc
call ReadJoyPadHome
call TryTogglePause
ld a, [hGameBoyColorDetection]
cp GBC_MODE
jr nz, .asm_31c
.asm_2d8
ld a, [rLY]
cp 51
jr nz, .asm_2d8
ld a, $80
ld [rBCPS], a
ld hl, Data_361
call WaitHBlankStart
ld a, [hli]
ld [rBCPD], a
ld a, [hli]
ld [rBCPD], a
ld a, [hli]
ld [rBCPD], a
ld a, [hli]
ld [rBCPD], a
ld a, [hli]
ld [rBCPD], a
ld a, [hli]
ld [rBCPD], a
.asm_2fa
ld a, [rLY]
cp 69
jr nz, .asm_2fa
ld a, $80
ld [rBCPS], a
ld hl, Data_367
call WaitHBlankStart
ld a, [hli]
ld [rBCPD], a
ld a, [hli]
ld [rBCPD], a
ld a, [hli]
ld [rBCPD], a
ld a, [hli]
ld [rBCPD], a
ld a, [hli]
ld [rBCPD], a
ld a, [hli]
ld [rBCPD], a
.asm_31c
call TickMusicEngineHome
ld a, [hGameBoyColorDetection]
cp GBC_MODE
jr nz, .asm_347
.asm_325
ld a, [rLY]
cp 119
jr nz, .asm_325
ld a, $80
ld [rBCPS], a
ld hl, Data_36d
call WaitHBlankStart
ld a, [hli]
ld [rBCPD], a
ld a, [hli]
ld [rBCPD], a
ld a, [hli]
ld [rBCPD], a
ld a, [hli]
ld [rBCPD], a
ld a, [hli]
ld [rBCPD], a
ld a, [hli]
ld [rBCPD], a
.asm_347
call WaitVBlank
call Func_373
call ClearOAMBufferHome
call TryInitNextScreenHome
ld a, Bank(Func_795e)
ld [MBC5RomBank], a
call Func_795e
call UpdateFrameCounter
jp .asm_2cc
Data_361:
RGB(31, 25, 11)
RGB(20, 12, 5)
RGB(11, 5, 0)
Data_367:
RGB(31, 30, 5)
RGB(19, 18, 3)
RGB(10, 7, 0)
Data_36d:
RGB(31, 20, 16)
RGB(22, 8, 6)
RGB(13, 3, 1)
Func_373:
ld a, Bank(Func_17c3a)
ld [MBC5RomBank], a
call Func_17c3a
ld a, $04
ld [MBC5RomBank], a
call Func_3153
call Func_3153
ret
RunLevelSummaryScreen:
call LoadWarnerBrosBannerQuadrants
call InitScreenMusic
call WriteDMACodeToHRAM
call Func_3dce
call InitKeysState
call ResetFrameCounter
ld hl, $c528
ld a, [hli]
ld h, [hl]
ld l, a
call DrawLocalizedText
ld hl, LevelSummaryScreenGBCPalettes
call LoadCGBPalettesHome
ld a, Bank(Func_17c82)
ld [MBC5RomBank], a
call Func_17c82
ld a, LCDCF_ON | LCDCF_WIN9C00 | LCDCF_WINOFF | LCDCF_BG8800 | LCDCF_BG9800 | LCDCF_OBJ16 | LCDCF_OBJON | LCDCF_BGON
ld [rLCDC], a
.asm_3b4
call TickMusicEngineHome
call WaitVBlank
call Func_433
ld a, $05
ld [MBC5RomBank], a
ld hl, $731c
ld bc, $0
call LoadOAMSprites
call ClearOAMBufferHome
call TryInitNextScreenHome
call ReadJoyPadHome
call UpdateFrameCounter
ld a, Bank(Func_17ca6)
ld [MBC5RomBank], a
call Func_17ca6
ld a, [hEXTRALetters]
cp 5
jr nz, .asm_3f4
ld a, [hFrameCounter]
bit 4, a
jr nz, .asm_3f4
ld bc, $8044
ld hl, $7b43
call LoadOAMSprites
.asm_3f4
ld hl, $de80
ld a, [hl]
and a
jr z, .asm_3ff
dec [hl]
jp .asm_3b4
.asm_3ff
ld a, [hNumCarrots]
and a
jr z, .asm_420
ld a, [hFrameCounter]
and 7
jp nz, .asm_3b4
ld a, [hNumCarrots]
sub 1
daa
ld [hNumCarrots], a
ld bc, $2
call AddScore
ld a, $0f
call PlaySoundEffectHome
jp .asm_3b4
.asm_420
ld a, [wNewKeys]
and PADF_START | PADF_A
jp z, .asm_3b4
ld a, $08
call PlaySoundEffectHome
call Func_3ddc
jp .asm_3b4
Func_433:
ld a, [hFrameCounter]
and $3
ret nz
ld a, $05
ld [MBC5RomBank], a
ld hl, $dda2
ld bc, $80e0
ld de, $4280
ld a, $12
call Func_2f9e
ret
RunPasswordScreen:
push hl
ld hl, ScreenData_Password
call LoadData
call InitScreenMusic
pop hl
call LoadWarnerBrosBannerQuadrants
ld a, $06
ld [MBC5RomBank], a
ld bc, $ddc9
ld a, [wDifficultySetting]
and a
jr z, .asm_46b
inc hl
inc hl
inc hl
.asm_46b
ld a, [hli]
ld [bc], a
inc c
ld a, [hli]
ld [bc], a
inc c
ld a, [hl]
ld [bc], a
call WriteDMACodeToHRAM
call Func_3dce
call InitKeysState
call ResetFrameCounter
ld hl, $c526
ld a, [hli]
ld h, [hl]
ld l, a
call DrawLocalizedText
sub a
ld [rSCY], a
ld [rSCX], a
ld hl, Data_1a9e6
call LoadCGBPalettesHome
call Func_d67
ld a, LCDCF_ON | LCDCF_WIN9C00 | LCDCF_WINOFF | LCDCF_BG8800 | LCDCF_BG9800 | LCDCF_OBJ16 | LCDCF_OBJON | LCDCF_BGON
ld [rLCDC], a
.asm_49a
call TickMusicEngineHome
call WaitVBlank
ld a, $05
ld [MBC5RomBank], a
ld hl, $731c
ld bc, $0
call LoadOAMSprites
call ClearOAMBufferHome
call TryInitNextScreenHome
call ReadJoyPadHome
call UpdateFrameCounter
ld a, $05
ld [MBC5RomBank], a
ld hl, $ddc9
ld de, $6e86
ld b, $03
.asm_4c7
push bc
ld a, [de]
inc de
ld b, a
ld a, [de]
inc de
ld c, a
push de
ld a, [hli]
push hl
add a
ld l, a
ld h, $00
ld de, $6df1
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
call LoadOAMSprites
pop hl
pop de
pop bc
dec b
jr nz, .asm_4c7
ld a, [wNewKeys]
and PADF_START | PADF_A
jp z, .asm_49a
ld a, $08
call PlaySoundEffectHome
call Func_3ddc
jp .asm_49a
RunInfogramesCopyrightScreen:
call Func_fb4
call Func_3dce
call ResetFrameCounter
sub a
ld [rSCY], a
ld [rSCX], a
ld hl, InfogramesCopyrightScreenGBCPalettes
call LoadCGBPalettesHome
ld hl, vBGMap
ld bc, $400
call Func_10e9
ld a, LCDCF_ON | LCDCF_WIN9C00 | LCDCF_WINOFF | LCDCF_BG8800 | LCDCF_BG9800 | LCDCF_OBJ16 | LCDCF_OBJOFF | LCDCF_BGON
ld [rLCDC], a
.delayFrame
call WaitVBlank
call TryInitNextScreenHome
call UpdateFrameCounter
sub a
.delayNextVBlank
dec a
jr nz, .delayNextVBlank
ld a, [hFrameCounter]
and a
jr nz, .delayFrame
call Func_3ddc
jr .delayFrame
RunWarnerBrosCopyrightScreen:
call LoadWarnerBrosBannerQuadrants
call InitScreenMusic
call Func_3bb4
call WriteDMACodeToHRAM
call Func_3dce
sub a
ld [rSCY], a
ld [rSCX], a
ld hl, WarnerBrosCopyrightScreenGBCPalettes
call LoadCGBPalettesHome
ld a, LCDCF_ON | LCDCF_WIN9C00 | LCDCF_WINOFF | LCDCF_BG8800 | LCDCF_BG9800 | LCDCF_OBJ16 | LCDCF_OBJON | LCDCF_BGON
ld [rLCDC], a
.asm_54e
call TickMusicEngineHome
call Func_3a82
call WaitVBlank
ld a, [$deee]
cp $c5
jr nc, .asm_56c
ld a, $05
ld [MBC5RomBank], a
ld hl, $7861
ld bc, $5c39
call LoadOAMSprites
.asm_56c
call ClearOAMBufferHome
call TryInitNextScreenHome
ld a, %10010000
ld [rOBP0], a
ld a, [$def2]
and a
jr nz, .asm_54e
ld hl, $def6
dec [hl]
jr nz, .asm_54e
call Func_3ddc
jr .asm_54e
RunGameOverScreen:
call LoadWarnerBrosBannerQuadrants
call InitScreenMusic
call Func_3bb4
call WriteDMACodeToHRAM
call Func_3dce
sub a
ld [rSCY], a
ld [rSCX], a
ld hl, Data_1ab36
call LoadCGBPalettesHome
ld a, LCDCF_ON | LCDCF_WIN9C00 | LCDCF_WINOFF | LCDCF_BG8800 | LCDCF_BG9800 | LCDCF_OBJ16 | LCDCF_OBJON | LCDCF_BGON
ld [rLCDC], a
.asm_5a5
call TickMusicEngineHome
call Func_3a82
call WaitVBlank
call ClearOAMBufferHome
call TryInitNextScreenHome
ld a, [$def2]
and a
jr nz, .asm_5a5
ld hl, $def6
dec [hl]
jr nz, .asm_5a5
ld a, $03
ld [wCurScreen], a
call Func_3ddc
jr .asm_5a5
RunLanguageSelectScreen:
call LoadWarnerBrosBannerQuadrants
call InitScreenMusic
call WriteDMACodeToHRAM
call Func_3dce
call InitKeysState
ld hl, $c502
ld a, [hli]
ld h, [hl]
ld l, a
call DrawLocalizedWord
sub a
ld [rSCY], a
ld [rSCX], a
ld hl, WarnerBrosCopyrightScreenGBCPalettes
call LoadCGBPalettesHome
call Func_d67
ld a, LCDCF_ON | LCDCF_WIN9C00 | LCDCF_WINOFF | LCDCF_BG8800 | LCDCF_BG9800 | LCDCF_OBJ16 | LCDCF_OBJON | LCDCF_BGON
ld [rLCDC], a
.asm_5f4:
call TickMusicEngineHome
call WaitVBlank
ld a, $05
ld [MBC5RomBank], a
ld hl, $731c
ld bc, $0
call LoadOAMSprites
call ClearOAMBufferHome
call TryInitNextScreenHome
call ReadJoyPadHome
ld a, [wLanguageSetting]
swap a
add 55
ld b, a
ld c, $14
ld hl, $6db3
ld a, $05
ld [MBC5RomBank], a
call LoadOAMSprites
ld a, [$defc]
and a
jp nz, .asm_5f4
ld hl, wLanguageSetting
ld a, [wNewKeys]
bit PADB_SELECT, a
jr nz, .moveCursorDown
add a ; check if down pressed (PADF_DOWN)
jr nc, .checkUpPressed
.moveCursorDown
inc [hl]
jr .resolveCursor
.checkUpPressed
add a
jr nc, .ok
dec [hl]
.resolveCursor
ld b, 3 ; num languages
ld a, [hl]
cp $ff
jr nz, .checkMax
dec b
ld [hl], b
jr .redraw
.checkMax
cp b
jr c, .redraw
ld [hl], $00
.redraw
ld a, $07
call PlaySoundEffectHome
.ok
ld a, [wNewKeys]
and PADF_START | PADF_A
jp z, .asm_5f4
ld a, $08
call PlaySoundEffectHome
call Func_3ddc
jp .asm_5f4
RunOptionsScreen:
call LoadWarnerBrosBannerQuadrants
call InitScreenMusic
call WriteDMACodeToHRAM
call Func_3dce
call InitKeysState
call ResetFrameCounter
ld hl, $c504
ld a, [hli]
ld h, [hl]
ld l, a
call DrawLocalizedText
ld hl, $dee6
sub a
ld [hli], a
ld [hl], a
sub a
ld [rSCY], a
ld [rSCX], a
ld hl, Data_1a9e6
call LoadCGBPalettesHome
call Func_d67
ld a, LCDCF_ON | LCDCF_WIN9C00 | LCDCF_WINOFF | LCDCF_BG8800 | LCDCF_BG9800 | LCDCF_OBJ16 | LCDCF_OBJON | LCDCF_BGON
ld [rLCDC], a
.asm_69c
call TickMusicEngineHome
call WaitVBlank
ld a, $05
ld [MBC5RomBank], a
ld hl, $731c
ld bc, $0
call LoadOAMSprites
call ClearOAMBufferHome
call TryInitNextScreenHome
call ReadJoyPadHome
call UpdateFrameCounter
ld a, Bank(Func_17cfd)
ld [MBC5RomBank], a
call Func_17cfd
ld a, [$defc]
and a
jp nz, .asm_69c
ld hl, wPasswordEntryCursor
ld a, [hl]
and a
jp z, .asm_76d
add $e7
ld c, a
ld a, $de
adc $00
ld b, a
ld a, [wNewKeys]
bit PADB_A, a
jr nz, .asm_6e5
add a
jr nc, .asm_6ea
.asm_6e5
ld a, [bc]
inc a
ld [bc], a
jr .asm_6fc
.asm_6ea
add a
jr nc, .asm_6f2
ld a, [bc]
dec a
ld [bc], a
jr .asm_6fc
.asm_6f2
add a
jr nc, .asm_6f8
dec [hl]
jr .asm_6fc
.asm_6f8
add a
jr nc, .asm_6fc
inc [hl]
.asm_6fc
ld a, [hl]
and a
jr nz, .asm_704
ld [hl], $03
jr .asm_70a
.asm_704
cp $04
jr nz, .asm_70a
ld [hl], $01
.asm_70a
ld a, [bc]
cp $05
jr nz, .asm_713
sub a
ld [bc], a
jr .asm_71a
.asm_713
cp $ff
jr nz, .asm_71a
ld a, $04
ld [bc], a
.asm_71a