-
Notifications
You must be signed in to change notification settings - Fork 0
/
bank20.asm
executable file
·1533 lines (1390 loc) · 27.7 KB
/
bank20.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
SECTION "bank20", ROMX, BANK[$14]
; $14:$0000 = 0x50000
; 2=opens shutters. 4=defeats all enemies. 6=a treasure chest appears at position 28. 8=a key falls at position 32. A=a staircase will appear at position 18. C=the miniboss flag is set, shutter opens, warp to start of dungeon is opened.
; Events
const_def
const EVENT_0
const EVENT_1
const EVENT_2
const EVENT_3
const EVENT_4
const EVENT_5
const EVENT_6
const EVENT_7
const EVENT_8
const EVENT_9
const EVENT_A
const EVENT_B
const EVENT_C
const EVENT_D
const EVENT_E
const EVENT_F
; 1=must defeat all enemies. 2=push a block. 3=push a trigger. 4=? 5=light all torches. 6=level 2 nightmare key puzzle, that is you need to destroy a Pols Voice first, then a keese, then a staflos. 7=push two blocks together, can be in any form as long as they are both movable blocks. 8=kill special enemies, which are defined as enemies that can't normally be destroyed like traps and sparks. 9=level 4 tile puzzle must be completed. A=defeat boss 4 or 7 to open shutter door. B=one way shutter, or throw somthing at it to open. C=throw the horse heads at a wall to stand them up. D=smash a chest to open, allways get a nightmare key, allways opens at a specific spot. E="Fill in the holes with the rock that rolls". F=fire an arrow at a statue, might be sprite related.
; EventTriggers
const_def
const EVENT_TRIGGER_0
const EVENT_TRIGGER_1
const EVENT_TRIGGER_2
EventData: ; 0x50000
db $00
db $00
db EVENT_2 << 4 | EVENT_TRIGGER_1
db EVENT_A << 4 | EVENT_TRIGGER_1
db $22, $00, $21, $00, $00, $00, $61, $00, $00, $61, $00, $00
db $00, $C1, $21, $63, $61, $21, $81, $00, $00, $00, $00, $00, $00, $00, $00, $00
; 0x50020
INCBIN "baserom.gbc", 16384*20+$20, $220-$20
RoomOrderData: ; 0x50220
INCBIN "baserom.gbc", 16384*20+$220, $4e0-$220
Unknown_504e0:
INCBIN "baserom.gbc", 16384*20+$4e0, $520-$4e0
Unknown_50520:
INCBIN "baserom.gbc", 16384*20+$520, $660-$520
ChestData: ; 0x50660
INCBIN "baserom.gbc", 16384*20+$660, $881-$660
Unknown_50881: ; 0x50881
dw Unknown_508a1
dw Unknown_508ae
dw Unknown_508bb
dw Unknown_508c8
dw Unknown_508d5
dw Unknown_508e2
dw Unknown_508ef
dw Unknown_508fc
dw Unknown_50909
dw Unknown_50916
dw Unknown_50916
dw Unknown_50916
dw Unknown_50916
dw Unknown_50916
dw Unknown_50916
dw Unknown_50916
; 0x508a1
Unknown_508a1:
db $c5, $21, $11, $d7, $01, $17, $49, $11, $38, $49, $c3, $42, $35
Unknown_508ae:
db $c5, $21, $11, $d7, $01, $58, $49, $11, $71, $49, $c3, $42, $35
Unknown_508bb:
db $c5, $21, $11, $d7, $01, $89, $49, $11, $a4, $49, $c3, $42, $35
Unknown_508c8:
db $c5, $21, $11, $d7, $01, $be, $49, $11, $d7, $49, $c3, $42, $35
Unknown_508d5:
db $c5, $21, $11, $d7, $01, $ef, $49, $11, $0a, $4a, $c3, $42, $35
Unknown_508e2:
db $c5, $21, $11, $d7, $01, $24, $4a, $11, $36, $4a, $c3, $42, $35
Unknown_508ef:
db $c5, $21, $11, $d7, $01, $47, $4a, $11, $59, $4a, $c3, $42, $35
Unknown_508fc:
db $c5, $21, $11, $d7, $01, $6a, $4a, $11, $7c, $4a, $c3, $42, $35
Unknown_50909:
db $c5, $21, $11, $d7, $01, $8d, $4a, $11, $9f, $4a, $c3, $42, $35
Unknown_50916:
db $c9
ScreenTemplateData: ; 0x50917
INCBIN "baserom.gbc", 16384*20+$917, $aad-$917
Unknown_50aad:
db $23, $23, $23, $18, $20, $28, $30, $38, $40, $48, $50, $58, $60, $68, $70
Function50abc:
ld a, [$d462]
and a
jr z, .asm_50acc
dec a
ld [$d462], a
jr nz, .asm_50acc
ld a, $1b
ld [$fff3], a
.asm_50acc
ld a, [$c502]
and a
jr z, .asm_50ad6
dec a
ld [$c502], a
.asm_50ad6
ld a, [$c5af]
and a
jr z, .asm_50ae7
dec a
ld [$c5af], a
jr nz, .asm_50ae7
ld a, [$ffbf]
ld [$d368], a
.asm_50ae7
ld a, [$dba5]
and a
jr nz, .asm_50b0c
ld a, [$fff6]
ld [$db54], a
ld a, [$fff6]
cp $f0
jr c, .asm_50b0c
cp $f6
jr nc, .asm_50b0c
ld a, [$c114]
inc a
cp $a0
jr nz, .asm_50b09
ld a, $f
ld [$fff4], a
xor a
.asm_50b09
ld [$c114], a
.asm_50b0c
ld a, [$db5b]
ld e, a
ld d, b
ld hl, Unknown_50aad
add hl, de
ld a, [$db5a]
cp [hl]
ld a, $0
jr nz, .asm_50b1e
inc a
.asm_50b1e
ld [$c5a9], a
ld a, [$c5ac]
inc a
cp $1a
jr nz, .asm_50b2a
xor a
.asm_50b2a
ld [$c5ac], a
ld a, [$ffe7]
and $3f
jr nz, .asm_50b3e
ld a, [$db47]
cp $ff
jr z, .asm_50b3e
inc a
ld [$db47], a
.asm_50b3e
ld a, [$d464]
and a
ret z
ld a, [$fffe]
and a
jr z, .asm_50b4d
call $4bef
jr .asm_50b5a
.asm_50b4d
ld a, $e4
ld [$db97], a
ld [$db99], a
ld a, $1c
ld [$db98], a
.asm_50b5a
ld hl, $d464
dec [hl]
ret z
ld a, [hl]
ld hl, $c155
ld [hl], b
cp $20
jr c, .asm_50b8e
rla
nop
nop
nop
and $4
sub $2
ld [$c155], a
ld a, [$fffe]
and a
jr z, .asm_50b7d
call $4ba7
jr .asm_50b8a
.asm_50b7d
ld a, $cc
ld [$db97], a
ld [$db99], a
ld a, $c
ld [$db98], a
.asm_50b8a
ld a, $2
ld [$ffa1], a
.asm_50b8e
ret
; 0x50b8f
INCBIN "baserom.gbc", 16384*20+$b8f, $c40-$b8f
Unknown_50c40:
db $00, $00, $00, $01, $01, $00, $00, $00, $00, $00, $00
Function50c4b:
ld a, [$db96]
cp $7
ret nz
ld a, [$c16b]
cp $4
ret nz
ld a, [$c3cb]
and a
jr z, .asm_50cb1
xor a
ld [$ffd7], a
ld d, a
ld a, [$c11c]
ld e, a
ld hl, Unknown_50c40
add hl, de
ld a, [hl]
and a
jr nz, .asm_50cb1
ld a, [$db9a]
cp $0
jr z, .asm_50c82
ld hl, $c17f
ld a, [$c19f]
or [hl]
jr nz, .asm_50c82
ld a, [$c3cd]
ld [$ffd7], a
.asm_50c82
ld a, [$c3cc]
ld e, a
ld a, [$ffe7]
and $3
add e
ld e, a
ld hl, $4c20
add hl, de
ld a, [hl]
ld [$db97], a
ld [$c5ad], a
ld a, [$fffe]
and a
jr nz, .asm_50cb2
ld a, [$ffe7]
and $1
jr nz, .asm_50cb1
ld a, [$ffd7]
ld hl, $c3cc
sub [hl]
jr z, .asm_50cb1
and $80
jr nz, .asm_50cb0
inc [hl]
inc [hl]
.asm_50cb0
dec [hl]
.asm_50cb1
ret
.asm_50cb2
ld hl, $c17f
ld a, [$c19f]
or [hl]
ret nz
ld a, [$ffd7]
ld hl, $c3cc
sub [hl]
jr nz, .asm_50cc7
ld a, [$ddd6]
and a
ret z
.asm_50cc7
ld a, [$c11c]
cp $0
ret nz
ld a, [$c125]
cp $4
jr nz, .asm_50cdf
ld a, [$c3cd]
ld [$c3cc], a
xor a
ld [$c125], a
ret
.asm_50cdf
ld a, [$ddd7]
dec a
ld [$ddd7], a
jr z, .asm_50ceb
cp $1
ret nz
.asm_50ceb
ld a, [$ddd6]
and $80
jr nz, .asm_50d0b
ld a, [$ddd7]
and a
jr z, .asm_50d22
ld a, [hl]
and $6
jr z, .asm_50d01
dec [hl]
dec [hl]
jr .asm_50d22
.asm_50d01
ld a, [$c3cc]
sub $4
ld [$c3cc], a
jr .asm_50d22
.asm_50d0b
ld a, [$ddd7]
and a
jr z, .asm_50d22
ld a, [hl]
and $4
jr nz, .asm_50d1a
inc [hl]
inc [hl]
jr .asm_50d22
.asm_50d1a
ld a, [$c3cc]
add $4
ld [$c3cc], a
.asm_50d22
ld a, [$c3cd]
cp [hl]
jr nz, .asm_50d32
ld a, [$ddd7]
and a
jr nz, .asm_50d32
xor a
ld [$ddd6], a
.asm_50d32
ld a, [$ddd7]
and a
jr z, .asm_50d4a
ld hl, $de01
ld a, $21
ld [hli], a
ld a, $53
ld [hli], a
ld a, $55
ld [hli], a
ld a, $14
ld [hl], a
call Functionbd3
.asm_50d4a
ld a, [$ddd7]
xor $1
swap a
ld [$ddd3], a
ld a, $10
ld [$ddd4], a
ld a, $81
ld [$ddd1], a
ld a, [$ddd7]
and a
ret nz
ld a, [$fff7]
cp $7
jr nz, .asm_50d6d
ld a, $a
jr .asm_50d6f
.asm_50d6d
ld a, $b
.asm_50d6f
ld [$ddd7], a
ret
; 0x50d73
Function50d73:
xor a
ld [$ffbe], a
ld [$fff5], a
ld a, [$db95]
cp $7
jr z, .asm_50ded
cp $1
jr z, .asm_50d97
cp $b
jr nz, .asm_50ded
ld a, [$c16b]
cp $4
jr z, .asm_50d97
ld hl, $c3a0
add hl, bc
ld a, [hl]
cp $83
jr nz, .asm_50ded
.asm_50d97
ld a, [$c124]
ld hl, $c14f
or [hl]
ld hl, $c19f
or [hl]
ld hl, $c166
or [hl]
jr nz, .asm_50ded
ld hl, $c2e0
add hl, bc
ld a, [hl]
and a
jr z, .asm_50db1
dec [hl]
.asm_50db1
ld hl, $c2f0
add hl, bc
ld a, [hl]
and a
jr z, .asm_50dba
dec [hl]
.asm_50dba
ld hl, $c300
add hl, bc
ld a, [hl]
and a
jr z, .asm_50dc3
dec [hl]
.asm_50dc3
ld hl, $c480
add hl, bc
ld a, [hl]
and a
jr z, .asm_50dcc
dec [hl]
.asm_50dcc
ld a, [$ffe7]
and $3
jr nz, .asm_50ddb
ld hl, $c450
add hl, bc
ld a, [hl]
and a
jr z, .asm_50ddb
dec [hl]
.asm_50ddb
ld hl, $c420
add hl, bc
ld a, [hl]
and a
jr z, .asm_50de4
dec [hl]
.asm_50de4
sla a
sla a
and $10
ld [$ffed], a
ret
.asm_50ded
xor a
ld [$ffed], a
ret
; 0x50df1
Unknown_50df1:
INCBIN "baserom.gbc", 16384*20+$df1, $e41-$df1
Unknown_50e41:
db $3b, $3a, $39, $3b, $3f, $3b, $39, $3b, $3b, $00, $00, $00, $00, $00, $00, $00
Function50e51:
ld a, $1
ld [$d474], a
ld a, $3
ld [$c11c], a
ld a, [$dba5]
and a
jr z, .asm_50e88
ld a, [$fff7]
cp $ff
jr nz, .asm_50e6b
and $f
jr .asm_50e6f
.asm_50e6b
cp $a
jr nc, .asm_50e88
.asm_50e6f
ld e, a
sla a
sla a
add e
ld e, a
ld d, $0
ld hl, Unknown_50df1
add hl, de
ld e, $5
ld bc, $d401
.asm_50e81
ld a, [hli]
ld [bc], a
inc bc
dec e
jr nz, .asm_50e81
ret
.asm_50e88
xor a
ld [$d401], a
ld [$d402], a
ld a, $45
ld [$d403], a
ld a, $38
ld [$d404], a
ld [$ff98], a
ld a, $60
ld [$d405], a
ld [$ff99], a
ld a, $53
ld [$d416], a
ret
; 0x50ea8
INCBIN "baserom.gbc", 16384*20+$ea8, $ee8-$ea8
Unknown_50ee8:
INCBIN "baserom.gbc", 16384*20+$ee8, $1038-$ee8
Function51038:
srl a
srl a
ld [$ffd7], a
ld a, [$c180]
nop
and $e0
ld e, a
ld a, [$c17f]
cp $3
jr nz, .asm_51050
ld a, e
xor $e0
ld e, a
.asm_51050
ld a, e
ld [$ffd8], a
ld hl, $c17c
xor a
ld [hli], a
ld [hli], a
ld [hli], a
ld a, $58
ld [$ffd9], a
ld a, [$fffe]
and a
jr z, .asm_51067
ld a, $88
ld [$ffd9], a
.asm_51067
ld a, [$ff41]
and $3
jr nz, .asm_51067
ld d, $0
.asm_5106f
ld a, [$c17e]
inc a
ld [$c17e], a
and $1
jr nz, .asm_5106f
ld a, [$c17c]
add $1
ld [$c17c], a
ld a, [$c17d]
adc $0
ld [$c17d], a
ld a, [$ffd9]
ld hl, $c17c
cp [hl]
ret z
ld c, $0
ld a, [$c17f]
cp $1
jr z, .asm_5109b
inc c
.asm_5109b
ld a, [$ffd7]
add [hl]
and $1f
ld hl, $ffd8
or [hl]
ld e, a
ld hl, Unknown_50ee8
add hl, de
ld a, [$c180]
and c
ld a, [hl]
jr z, .asm_510b2
cpl
inc a
.asm_510b2
push af
ld hl, $ff96
add [hl]
ld [$ff43], a
pop af
ld hl, $ff97
add [hl]
ld [$ff42], a
jp .asm_51067
; 0x510c3
INCBIN "baserom.gbc", 16384*20+$10c3, $1310-$10c3
Unknown_51310:
db $30, $d0, $00, $00, $18, $e8, $00, $00, $30, $d0, $00, $00, $18, $e8, $00, $00
Unknown_51320:
db $00, $00, $d0, $30, $00, $00, $e8, $18, $f4, $f4, $d0, $00, $f8, $f8, $e8, $00
Unknown_51330:
db $04, $04, $04, $04, $10, $10, $10, $10, $00, $00, $00, $00, $00, $00, $00, $00
Unknown_51340:
db $02, $06, $00, $04
Function51344:
ld a, [$c124]
and a
jr nz, .asm_51351
ld a, [$c11c]
cp $6
jr nz, .asm_5135d
.asm_51351
ld a, [$ffeb]
cp $a8
jr z, .asm_5135d
call .asm_513a0
jp Function3d76
.asm_5135d
ld a, [$c5ae]
and a
jr z, .asm_51368
dec a
ld [$c5ae], a
ret
.asm_51368
ld a, [$c15c]
cp $1
jp nz, .asm_51440
ld d, $3
ld a, [$ffeb]
cp $2
jr nz, .asm_5137a
ld d, $2
.asm_5137a
ld e, $10
ld a, [$db00]
cp d
jr nz, .asm_51386
sla e
jr .asm_5138e
.asm_51386
ld a, [$db01]
cp d
jr z, .asm_5138e
ld e, $30
.asm_5138e
ld a, [$ffcc]
and e
jp z, .asm_51440
ld a, [$ff9e]
ld hl, $c5d0
add hl, bc
ld [hl], a
ld hl, $fff2
ld [hl], $8
.asm_513a0
ld hl, $c280
add hl, bc
ld [hl], $5
ld a, [$ffeb]
cp $2
jr nz, .asm_513b3
call Functionc01
ld [hl], $a0
jr .asm_51406
.asm_513b3
ld hl, $c280
add hl, bc
cp $d6
jr z, .asm_513ea
cp $d5
jr z, .asm_513ea
cp $6c
jr z, .asm_513ea
cp $9d
jr z, .asm_513ea
cp $a8
jr z, .asm_513ea
cp $98
jr nz, .asm_513f3
push hl
ld a, [$ff9e]
ld e, a
ld d, b
ld hl, Unknown_51340
add hl, de
ld a, [hl]
ld hl, $c380
add hl, bc
ld [hl], a
call Functionc01
call Function2804
and $1f
add $30
ld [hl], a
pop hl
.asm_513ea
ld [hl], $5
call Function3b09
ld [hl], $2
jr .asm_51406
.asm_513f3
cp $92
jr nz, .asm_51400
ld [hl], $5
call Function3b09
ld [hl], $3
jr .asm_51406
.asm_51400
cp $5
jr z, .asm_51406
ld [hl], $8
.asm_51406
ld e, b
ld a, [$fff9]
and a
jr z, .asm_5140e
ld e, $8
.asm_5140e
ld a, [$ffeb]
cp $2
jr nz, .asm_51418
ld a, e
add $4
ld e, a
.asm_51418
ld a, [$ff9e]
add e
ld e, a
ld d, b
ld hl, Unknown_51310
add hl, de
ld a, [hl]
ld hl, $c240
add hl, bc
ld [hl], a
ld hl, Unknown_51320
add hl, de
ld a, [hl]
ld hl, $c250
add hl, bc
ld [hl], a
ld hl, Unknown_51330
add hl, de
ld a, [hl]
ld hl, $c320
add hl, bc
ld [hl], a
ld a, $c
ld [$c19b], a
.asm_51440
ret
; 0x51441
Function51441:
xor a
ld [$c19f], a
ret
; 0x51446
Function51446:
ld a, [$c3c9]
and a
jr nz, .asm_51457
ld a, [$c11c]
cp $3
jr z, Function51441
cp $4
jr z, Function51441
.asm_51457
ld a, [$db95]
cp $1
jr z, .asm_5147c
ld a, [$c3cb]
and a
jr nz, .asm_5147c
ld a, [$ff9d]
cp $6c
jr z, .asm_5147c
ld a, $4
ld [$c16b], a
ld a, $e4
ld [$db97], a
ld [$db99], a
ld a, $1c
ld [$db98], a
.asm_5147c
ld a, [$d601]
and a
ret nz
ld hl, $c19f
inc [hl]
ld a, [$fffe]
and a
ret z
ld a, [$db95]
cp $b
ret nz
ld a, [$c3cc]
cp $8
ret c
ld hl, $de01
ld a, $21
ld [hli], a
ld a, $53
ld [hli], a
ld a, $b6
ld [hli], a
ld a, $14
ld [$de04], a
jp Functionbd3
; 0x514a9
Function514a9:
ld hl, $c17b
ld a, [$c124]
or [hl]
jr nz, .asm_514e4
ld a, [$ff98]
sub $11
cp $7e
jr c, .asm_514ce
ld a, [$ff98]
cp $50
jr nc, .asm_514c7
ld a, [$ff98]
inc a
ld [$ff98], a
jr .asm_514db
.asm_514c7
ld a, [$ff98]
dec a
ld [$ff98], a
jr .asm_514db
.asm_514ce
ld a, [$ff99]
sub $16
cp $5e
jr c, .asm_514e4
ld a, [$ff99]
dec a
ld [$ff99], a
.asm_514db
ld a, $1
ld [$ffa1], a
ld a, $2
ld [$c111], a
.asm_514e4
ret
; 0x514e5
Unknown_514e5:
db $00, $02, $00, $fe, $00, $00, $00, $00
Unknown_514ed:
db $00, $00, $00, $00, $00, $02, $00, $fe
Function514f5:
ld a, [$c178]
and a
jr z, .asm_514ff
dec a
ld [$c178], a
.asm_514ff
ld a, [$c157]
and a
jr z, .asm_51522
dec a
ld [$c157], a
and $3
ld hl, $c158
add [hl]
ld e, a
ld d, $0
ld hl, Unknown_514e5
add hl, de
ld a, [hl]
ld [$c155], a
ld hl, Unknown_514ed
add hl, de
ld a, [hl]
ld [$c156], a
.asm_51522
ret
; 0x51523
Function51523:
ld hl, $d711
add hl, de
ld a, [$ffaf]
cp $8e
jr nz, .asm_5157a
ld [hl], $aa
call Function287e
ld a, [$fffe]
and a