-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path5.s
2278 lines (1963 loc) · 30.5 KB
/
5.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
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 "text.charmap"
bankswitch: MACRO
rst $20
ENDM
freespace: MACRO
incbin "base5.gb",\1,(\1 / $4000 + 1) * $4000 - \1
ENDM
bankword: MACRO
dw \1
db BANK(\1)
ENDM
; $DF3D is the number of P chips
SECTION "func0",ROM0[0]
Func0:
di
ld sp,$FFFE
jp $150
SECTION "func8",ROM0[8]
Func8:
ld a,l
ld [$CF78],a
ld a,h
jp $876
SECTION "func10",ROM0[$10]
Func10:
ld [$CF7A],a
ld a,l
jp Function334
SECTION "func18",ROM0[$18]
Func18:
ld a,[$DF03]
cp $2B
ret
SECTION "func20",ROM0[$20]
Bankswitch: ; $20
ld [$DF00],a
ld [$2100],a
ret
Function27: ; $27
ld bc,$2AE1
push hl
jp $4A0
SECTION "vblank",ROM0[$40]
jp $50E
SECTION "lcdc",ROM0[$48]
jp $73D
db $01,$1F,$FF
SECTION "timer",ROM0[$50]
reti
SECTION "serial",ROM0[$58]
reti
SECTION "joypad",ROM0[$60]
reti
db $01,$02,$04,$08,$10,$20,$40,$80
db 0,0,0,0,0,0
db $11,$FF,$80,$00
db $7E,$FF,$C9,$C9,$C9,$C9,$C9,$C9
SECTION "unknownhome",ROM0[$D0]
INCBIN "base5.gb",$D0,$30
SECTION "header",ROM0[$100]
nop
jp Function150
SECTION "start",ROM0[$150]
Function150:
jp Function4FA
Function153:
jp $20B2
Function156:
jp $3D65
Function159:
jp $3D71
Function15C:
jp $2C05
Function15F:
jp $2C0D
Function162:
jp $0406
Function165:
jp $0D96
Function168:
jp $1A96
Function16B:
jp $19D7
Function16E:
jp $1CFF
Function171:
jp $1D0A
Function174:
jp Function1A5E
Copy8: ; $177
jp Function19FC
Copy4: ; $17A
jp Function1A08
Copy2: ; $17D
jp Function1A0E
Function180:
jp Function1A22
Function183:
jp $1C39
Function186:
jp $1BAD
Function189:
jp $1C15
Function18C:
jp $11AB
Function18F:
jp $243D
Function192:
jp $2458
Function195:
jp $2405
Function198:
jp $2D2D
Function19B:
jp $2D2A
Function19E:
jp $317F
Function1A1:
jp $3192
Function1A4:
jp $30C1
Function1A7:
jp $30F7
Function1AA:
jp $2DE8
Function1AD:
jp $2B45
Function1B0:
jp $2B51
Function1B3:
jp $2B60
Function1B6:
jp $2A5F
Function1B9:
jp $3170
Function1BC:
jp $0EDA
Function1BF:
jp $3B4C
Function1C2:
jp $1E37
Function1C5:
jp $19AE
Function1C8:
jp $186B
Function1CB:
jp Function35E
Function1CE:
jp $1E48
Function1D1:
jp $3289
Function1D4:
jp $1E5F
Function1D7:
jp $2A45
Function1DA:
jp $2A57
Function1DD:
jp $2A7A
Function1E0:
jp $2A88
Function1E3:
jp $2A98
Function1E6:
jp $2B6E
Function1E9:
jp $2B72
Function1EC:
jp $1D18
Function1EF:
jp $2B78
Function1F2:
jp $2B89
Function1F5:
jp $048C
Function1F8:
jp $2B9C
Function1FB:
jp $2BA4
Function1FE:
jp $2B39
Function201:
jp $2B20
Function204:
jp $2B2A
Function207:
jp $202A
Function20A:
jp $202A
Function20D:
jp $1FE8
Function210:
jp $31F8
Function213:
jp $1D26
Function216:
jp $0FD5
Function219:
jp $2400
Function21C:
jp $2BF8
Function21F:
jp $10E0
Function222:
jp $0884
Function225:
jp $0851
Function228:
jp $0AFC
Function22B:
jp $1F51
Function22E:
jp $0429
Function231:
jp $0421
Function234:
jp $03F6
Function237:
jp $03FA
Function23A:
jp $1973
Function23D:
jp $04E9
Function240:
jp $10C6
Function243:
jp $3A30
Function246:
jp $3A0D
Function249:
jp $3ABC
Function24C:
jp $1D61
Function24F:
jp $2C74
Function252:
jp $2C97
Function255:
jp $1E0D
Function258:
jp $1E23
Function25B:
jp $04B4
Function25E:
jp $2D0E
Function261:
jp $1E3D
Function264:
jp $100F
Function267:
jp $1079
Function26A:
jp $108B
Function26D:
jp $2A0E
Function270:
jp $18F8
Function273:
jp $1096
Function276:
jp $129B
Function279:
jp $1326
Function27C:
jp $043A
Function27F:
jp $0F32
Function282:
jp $2DB4
Function285:
jp Function1A69
Function288:
jp $192B
Function28B:
jp $195D
Function28E:
jp $190f
Function291:
jp $0480
Function294:
jp $0EC4
Function297:
jp $0BC5
Function29A:
jp $0BCC
Function29D:
jp $244E
Function2A0:
jp Function504
Function2A3:
jp $03E3
Function2A6:
jp $03DA
Function2A9:
jp $03EE
Function2AC:
jp $23DD
Function2AF:
jp $05BC
Function2B2:
jp $05DF
Function2B5:
jp $04E6
Function2B8:
jp $191D
Function2BB:
jp $0927
Function2BE:
jp $31FB
Function2C1:
jp $04C5
Function2C4:
jp $042D
Function2C7:
jp $04C1
Function2CA:
jp $0466
Function2CD:
jp Function326
Function2D0:
jp $04BC
Function2D3:
jp $04DC
Function2D6:
jp $0490
Function2D9:
jp $03F2
Function2DC:
jp $03FE
Function2DF:
jp $03D4
Function2E2:
jp $047C
Function2E5:
jp $0462
Function2E8:
jp $0322
Function2EB:
jp $0AC4
Function2EE:
jp $0EDF
Function2F1:
jp $049C
Function2F4:
jp Func0
Function2F7:
jp Function306
Function2FA:
jp $030A
Function2FD:
jp $030E
Function300:
jp $0316
Function303:
jp $0312
Function306:
INCBIN "base5.gb",$306,$326-$306
Function326: ; $326
ld a,[$DF00]
push af
ld a,b
bankswitch
call Function332
pop af
bankswitch
ret
Function332:
push de
ret
Function334: ; $334
ld [$cf78],a
ld a,h
ld [$cf79],a
pop hl
ld a,$c3
ld [$c0e0],a
ldi a,[hl]
ld [$c0e1],a
ldi a,[hl]
ld [$c0e2],a
ld a,[$df00]
push af
ld a,[hl]
bankswitch
ld hl,$cf78
ldi a,[hl]
ld h,[hl]
ld l,a
ld a,[$cf7a]
call $c0e0
pop af
bankswitch
ret
Function35E: ; $35E
cp $24
ret nC
ld [$ff8a], a
ld a, [$df00]
push af
push hl
push de
ld a, [$ff8a]
ld e, a
ld d, $00
ld hl, Pointers38B
add hl, de
add hl, de
add hl, de
ldi a, [hl]
ld [$c0d1], a
ldi a, [hl]
ld [$c0d2], a
ld a, $c3 ; jp
ld [$c0d0], a
ld a, [hl]
pop de
pop hl
bankswitch
call $c0d0
pop af
bankswitch
ret
Pointers38B:
dw Function3D3
db 1
bankword Function4F9D
bankword Function4E2B
bankword Function3400C
bankword Function4E21
bankword Function44F4
bankword Function70C2
bankword Function44AB
bankword Function68010
bankword Function4002B
bankword Function34048
bankword Function1000F
bankword Function40028
bankword Function10006
dw Function2268
db 1
bankword Function5FDF
bankword Function70010
bankword Function64013
dw Function3D3
db 1
bankword Function4F8E
bankword FunctionC003
bankword Function24003
bankword Function78020
bankword Function14006
Function3D3:
ret
INCBIN "base5.gb",$3D4,$4FA-$3D4
Function4FA: ; $4FA
di
ld sp,$FFFE
ld a,1
bankswitch
jp $4000
Function504: ; $504
di
ld sp,$FFFE
ld a,1
bankswitch
jp $4030
INCBIN "base5.gb",$50E,$BE9-$50E
InitializeLives: ; $BE9
ld a,3
ld [$DF34],a
call $B5D
xor a
ld [$DE9B],a
ld [$DED4],a
jp $454D
INCBIN "base5.gb",$BFB,$19FC-$BFB
Function19FC: ; $19FC
ld a,[de]
inc de
ld [hli],a
ld a,[de]
inc de
ld [hli],a
ld a,[de]
inc de
ld [hli],a
ld a,[de]
inc de
ld [hli],a
Function1A08: ; $1A08
ld a,[de]
inc de
ld [hli],a
ld a,[de]
inc de
ld [hli],a
Function1A0E: ; $1A0E
ld a,[de]
inc de
ld [hli],a
ld a,[de]
inc de
ld [hli],a
ret
Function1A15: ; $1A15
ld a,[hli]
ld [de],a
inc de
ld a,[hli]
ld [de],a
inc de
ld a,[hli]
ld [de],a
inc de
ld a,[hli]
ld [de],a
inc de
ret
Function1A22: ; $1A22
push af
.loop
ld a,[hli]
ld [de],a
inc de
dec bc
ld a,b
or c
jr nz,.loop
pop af
ret
Function1A2D: ; $1A2D
ld a,[hli]
ld [de],a
inc de
ld a,[hli]
ld [de],a
inc de
ld a,[hli]
ld [de],a
inc de
ld a,[hli]
ld [de],a
inc de
ld a,[hli]
ld [de],a
inc de
ld a,[hli]
ld [de],a
inc de
ld a,[hli]
ld [de],a
inc de
ld a,[hli]
ld [de],a
inc de
ld a,[hli]
ld [de],a
inc de
ld a,[hli]
ld [de],a
inc de
ld a,[hli]
ld [de],a
inc de
ld a,[hli]
ld [de],a
inc de
ld a,[hli]
ld [de],a
inc de
ld a,[hli]
ld [de],a
inc de
ld a,[hli]
ld [de],a
inc de
ld a,[hli]
ld [de],a
inc de
ret
Function1A5E: ; $1A5E
ld [hl],a
ld e,l
ld d,h
inc de
dec bc
ld a,b
or c
ret z
jp Function1A22
Function1A69: ; $1A69
ld hl,0
ld a,$10
.loop
add hl,hl
rl c
rl b
jr nc,.next
add hl,de
jr nc,.next
inc bc
.next
dec a
jr nz,.loop
ret
INCBIN "base5.gb",$1A7D,$2268-$1A7D
Function2268:
INCBIN "base5.gb",$2268,$3ec9-$2268
Function3EC9:
INCBIN "base5.gb",$3ec9,$3ee1-$3ec9
freespace $3ee1
SECTION "bank1",ROMX,BANK[$1]
INCBIN "base5.gb",$4000,$44AB-$4000
Function44AB:
INCBIN "base5.gb",$44ab,$44f4-$44ab
Function44F4:
INCBIN "base5.gb",$44f4,$4AE1-$44f4
Function4AE1:
ld hl,$DF34
inc [hl]
ld a,[hl]
cp 11
jr c,.nextlife
ld [hl],10 ; maximum of 9 extra lives
ret
.nextlife
rst 8
ld [de],a
ret
.bighealth
ld d,10
jr .healaddress
.littlehealth
ld d,2
.healaddress
ld hl,$DE9E
jr .heal
.bigweap
ld d,10
jr .weapaddress
.littleweap
ld d,2
.weapaddress
ld a,[$DE9B] ; current weapon
or a
jr z,.nomoreheal ; can't heal the buster
add $9E ; $DE9E & $FF???
ld l,a
ld h,$DE ; $DE9E >> 8???
ld a,[hl]
cp $98
jr nc,.nomoreheal
.heal
ld a,d
ld [$D4BB],a
ld a,l
ld [$D4B9],a
ld a,h
ld [$D4BA],a
ld hl,$DEAF
set 1,[hl]
xor a
ld [$D4B8],a
jr .next
ld hl,$D4B8
inc [hl]
ld a,[hl]
cp 4
ret c
xor a
ld [hl],a
.next
ld hl,$D4BB
ld a,[hl]
or a
jr z,.next2
dec [hl]
ld hl,$D4B9
ld a,[hli]
ld h,[hl]
ld l,a
ld a,[hl]
cp $98
jr nc,.next2
rst 8
rla
ld a,8
add [hl]
ld [hl],a
cp $98
ret c
ld [hl],$98
ret
.next2
ld hl,$DEAF
res 1,[hl]
ret
.nomoreheal
ld a,[$DF3C]
or a
ret z
push bc
push de
ld a,0
ld [$FF8A],a
ld a,0
ld [$FF8B],a
ld c,$99
ld b,$C
ld hl,$DE9F
ld a,[$DE9C]
ld e,a
ld a,[$DE9D]
ld d,a
.next5
srl d
rr e
.next3
srl d
rr e
jr nc,.next4
ld a,[hl]
cp c
jr nc,.next4
ld c,a
ld a,l
ld [$FF8A],a
ld a,h
ld [$FF8B],a
.next4
inc hl
dec b
jr nz,.next3
.next7
pop de
pop bc
ld hl,$FF8A
ld a,[hli]
ld h,[hl]
ld l,a
ld a,h
or l
ret z
jp $4B11
ld hl,$D40A
ld a,[hl]
or a
ret z
ld [hl],0
ld b,a
ld l,0
.next6
ld a,[hli]
ld c,l
push bc
add $a
ld l,a
ld a,[hl]
ld [hl],$40
call $30F7
ld h,$D4
pop bc
ld l,c
dec b
jr nz,.next6
ret
INCBIN "base5.gb",$4BBB,$4e21-$4BBB
Function4E21:
ld a, $FF
ld hl, $4e40
ld b, 0
jp Function4FEF
Function4E2B:
INCBIN "base5.gb",$4e2b,$4f8e-$4e2b
Function4F8E:
INCBIN "base5.gb",$4f8e,$4f9d-$4f8e
Function4F9D:
INCBIN "base5.gb",$4f9d,$4fef-$4f9d
Function4FEF:
INCBIN "base5.gb",$4fef,$5fdf-$4fef
Function5FDF:
INCBIN "base5.gb",$5fdf,$70c2-$5fdf
Function70C2:
INCBIN "base5.gb",$70c2,$7d08-$70c2
freespace $7D08
SECTION "bank2",ROMX,BANK[$2]
INCBIN "base5.gb",$8000,$4000
SECTION "bank3",ROMX,BANK[$3]
FunctionC000:
jp FunctionF9FC
FunctionC003:
jp FunctionFAA3
FunctionC006:
jp FunctionC778
FunctionC009:
jp FunctionE8AC
FunctionC00C:
jp FunctionD1A1
FunctionC00F:
jp FunctionDB36
FunctionC012:
jp FunctionF12E
FunctionC015:
jp FunctionF9C9
FunctionC018:
jp FunctionF9C9
FunctionC01B:
INCBIN "base5.gb",$C01B,$C778-$C01B
FunctionC778:
INCBIN "base5.gb",$C778,$D1A1-$C778
FunctionD1A1:
INCBIN "base5.gb",$D1A1,$DB36-$D1A1
FunctionDB36:
INCBIN "base5.gb",$DB36,$E8AC-$DB36
FunctionE8AC:
INCBIN "base5.gb",$E8AC,$F12E-$E8AC
FunctionF12E:
INCBIN "base5.gb",$F12E,$F9C9-$F12E
FunctionF9C9:
INCBIN "base5.gb",$F9C9,$F9FC-$F9C9
FunctionF9FC:
INCBIN "base5.gb",$f9fc,$fa99-$f9fc
DataFA99:
dw $4EA3
dw $59B3
dw $62CE
dw $6F7A
dw $7743
FunctionFAA3:
ld a, b
dec a
ld de, DataFA99
jp Function171
freespace $FAAB
SECTION "bank4",ROMX,BANK[$4]
Function10000:
jp $405D
Function10003:
jp $53d7
Function10006:
jp $6b9e
Function10009:
jp $50ef
Function1000C:
jp $51db
Function1000F:
jp $4069
Function10012:
jp $63d6
Function10015:
jp $63d0
Function10018:
jp $7437
Function1001B:
jp $743b
Function1001E:
jp $743f
Function10021:
jp $7443
Function10024:
jp $5090
INCBIN "base5.gb",$10027,$14000-$10027
SECTION "bank5",ROMX,BANK[$5]
INCBIN "base5.gb",$14000,$6
Function14006:
INCBIN "base5.gb",$14006,$18000-$14006
SECTION "bank6",ROMX,BANK[$6]
INCBIN "base5.gb",$18000,$4000
SECTION "bank7",ROMX,BANK[$7]
INCBIN "base5.gb",$1C000,$4000
SECTION "bank8",ROMX,BANK[$8]
INCBIN "base5.gb",$20000,$4000
SECTION "bank9",ROMX,BANK[$9]
Function24000:
jp $7c9a
Function24003:
jp $7ee4
Function24006:
jp $42c3
Function24009:
jp $464e
Function2400c:
jp $4ca0
Function2400f:
jp $5574
Function24012:
jp $5d28
Function24015:
jp $6650
Function24018:
jp $7802
Function2401B:
INCBIN "base5.gb",$2401b,$28000-$2401b
SECTION "bankA",ROMX,BANK[$A]
INCBIN "base5.gb",$28000,$4000
SECTION "bankB",ROMX,BANK[$B]
Function2C000:
jp $4b3c
Function2C003:
jp $4DCA
Function2C006:
jp $5EB2
Function2C009: