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
|
EndOfBallBonus: ; 0xf533
call FillBottomMessageBufferWithBlackTile
call LoadEAcuteCharacterGfx
call Func_f57f
ld a, $60
ld [hWY], a
dec a
ld [hLYC], a
ld a, $fd
ld [hLCDCMask], a
call ShowBallBonusSummary
ld a, $90
ld [hWY], a
ld a, $83
ld [hLYC], a
ld [hLastLYC], a
ld a, $ff
ld [hLCDCMask], a
call FillBottomMessageBufferWithBlackTile
ret
LoadEAcuteCharacterGfx: ; 0xf55c
ld a, [hGameBoyColorFlag]
and a
jr nz, .gameboyColor
ld a, BANK(E_Acute_CharacterGfx)
ld hl, E_Acute_CharacterGfx
ld de, vTilesSH tile $03
ld bc, $0010
call LoadVRAMData
ret
.gameboyColor
ld a, BANK(E_Acute_CharacterGfx_GameboyColor)
ld hl, E_Acute_CharacterGfx_GameboyColor
ld de, vTilesSH tile $03
ld bc, $0010
call LoadVRAMData
ret
Func_f57f: ; 0xf57f
xor a
ld [wDrawBottomMessageBox], a
ld hl, wBottomMessageText
ld a, $81
ld b, $40
.clearLoop
ld [hli], a
ld [hli], a
ld [hli], a
ld [hli], a
dec b
jr nz, .clearLoop
ld a, $0
ld hl, wBottomMessageText
ld de, vBGWin
ld bc, $00c0
call LoadVRAMData
ret
ShowBallBonusSummary: ; 0xf5a0
ld de, wBottomMessageText + $40
ld hl, BonusPointsText
call PlaceTextAlphanumericOnly
ld de, wBottomMessageText + $80
ld hl, SubtotalPointsText
call PlaceTextAlphanumericOnly
ld hl, wEndOfBallBonusSubTotal
call ClearBCD6Buffer
ld hl, wEndOfBallBonusTotalScore
call ClearBCD6Buffer
ld a, $1
ld [wd4ab], a
call HandleNumPokemonCaughtBallBonus
call HandleNumPokemonEvolvedBallBonus
call HandleBallBonusForCurrentField
call Func_f676
ld a, $1
ld [wd4ab], a
call Func_f70d
ld a, [wGameOver]
and a
ret z
ld a, Bank(Music_GameOver)
call SetSongBank
ld de, MUSIC_GAME_OVER
call PlaySong
ld hl, wBottomMessageText
ld bc, $0040
call Func_f81b
ld de, wBottomMessageText + $20
ld hl, GameOverText
call PlaceTextAlphanumericOnly
ld bc, $0040
ld de, $0000
call Func_f80d
.waitForAPress
rst AdvanceFrame
ld a, [hNewlyPressedButtons]
bit BIT_A_BUTTON, a
jr z, .waitForAPress
ret
HandleBallBonusForCurrentField: ; 0xf60a
ld a, [wCurrentStage]
rst JumpTable ; calls JumpToFuncInTable
CallTable_f60d: ; 0xf60d
dw HandleBallBonusRedField ; STAGE_RED_FIELD_TOP
dw HandleBallBonusRedField ; STAGE_RED_FIELD_BOTTOM
dw DoNothing_f9f2
dw DoNothing_f9f2
dw HandleBallBonusBlueField ; STAGE_BLUE_FIELD_TOP
dw HandleBallBonusBlueField ; STAGE_BLUE_FIELD_BOTTOM
dw DoNothing_faf6 ; STAGE_GENGAR_BONUS
dw DoNothing_faf6 ; STAGE_GENGAR_BONUS
dw DoNothing_faf7 ; STAGE_MEWTWO_BONUS
dw DoNothing_faf7 ; STAGE_MEWTWO_BONUS
dw DoNothing_faf8 ; STAGE_MEOWTH_BONUS
dw DoNothing_faf8 ; STAGE_MEOWTH_BONUS
HandleNumPokemonCaughtBallBonus: ; 0xf626
ld de, wBottomMessageText + $01
ld hl, NumPokemonCaughtText
call PlaceTextAlphanumericOnly
ld hl, wBottomMessageText + $01
ld a, [wNumPokemonCaughtInBallBonus]
call Func_f78e
ld bc, $0040
ld de, $0000
call Func_f80d
ld hl, wNumPokemonCaughtInBallBonus
ld de, PointsPerPokemonCaught
call Func_f853
call Func_f824
ret
HandleNumPokemonEvolvedBallBonus: ; 0xf64e
ld de, wBottomMessageText
ld hl, NumPokemonEvolvedText
call PlaceTextAlphanumericOnly
ld hl, wBottomMessageText
ld a, [wNumPokemonEvolvedInBallBonus]
call Func_f78e
ld bc, $0040
ld de, $0000
call Func_f80d
ld hl, wNumPokemonEvolvedInBallBonus
ld de, PointsPerPokemonEvolved
call Func_f853
call Func_f824
ret
Func_f676: ; 0xf676
ld b, $4
.asm_f678
push bc
ld hl, wBottomMessageText + $20
ld de, wBottomMessageText
ld bc, $00e0
call LocalCopyData
ld bc, $00c0
ld de, $0000
call Func_f80d
ld a, [wd4ab]
and a
jr z, .asm_f69f
rst AdvanceFrame
ld a, [hNewlyPressedButtons]
bit BIT_A_BUTTON, a
jr z, .asm_f69f
xor a
ld [wd4ab], a
.asm_f69f
pop bc
dec b
jr nz, .asm_f678
ld de, wBottomMessageText + $40
ld hl, MultiplierPointsText
call PlaceTextAlphanumericOnly
ld de, wBottomMessageText + $80
ld hl, TotalPointsText
call PlaceTextAlphanumericOnly
ld hl, wBottomMessageText + $50
ld a, [wCurBonusMultiplier]
call Func_f78e
ld bc, $0040
ld de, $0040
call Func_f80d
.asm_f6c7
push de
push hl
ld hl, wEndOfBallBonusTotalScore + $5
ld de, wBottomMessageText + $86
call Func_f8bd
ld bc, $0040
ld de, $0080
call Func_f80d
lb de, $00, $3e
call PlaySoundEffect
ld a, [wd4ab]
and a
jr z, .asm_f6f2
rst AdvanceFrame
ld a, [hNewlyPressedButtons]
bit BIT_A_BUTTON, a
jr z, .asm_f6f2
xor a
ld [wd4ab], a
.asm_f6f2
pop hl
pop de
ld a, [wCurBonusMultiplier]
and a
jr z, .asm_f709
dec a
ld [wCurBonusMultiplier], a
ld hl, wEndOfBallBonusTotalScore
ld de, wEndOfBallBonusSubTotal
call AddBigBCD6
jr .asm_f6c7
.asm_f709
call Func_f83a
ret
Func_f70d: ; 0xf70d
ld b, $4
.asm_f70f
push bc
ld hl, wBottomMessageText + $20
ld de, wBottomMessageText
ld bc, $00e0
call LocalCopyData
ld bc, $00c0
ld de, $0000
call Func_f80d
ld a, [wd4ab]
and a
jr z, .asm_f736
rst AdvanceFrame
ld a, [hNewlyPressedButtons]
bit BIT_A_BUTTON, a
jr z, .asm_f736
xor a
ld [wd4ab], a
.asm_f736
pop bc
dec b
jr nz, .asm_f70f
ld de, wBottomMessageText + $60
ld hl, ScoreText
call PlaceTextAlphanumericOnly
ld hl, wScore + $5
ld de, wBottomMessageText + $66
call Func_f8bd
ld bc, $0040
ld de, $0060
call Func_f80d
lb de, $00, $3e
call PlaySoundEffect
ld a, [wd4ab]
and a
jr z, .asm_f76c
rst AdvanceFrame
ld a, [hNewlyPressedButtons]
bit BIT_A_BUTTON, a
jr z, .asm_f76c
xor a
ld [wd4ab], a
.asm_f76c
ld hl, wScore
ld de, wEndOfBallBonusTotalScore
call AddBigBCD6
ld hl, wScore + $5
ld de, wBottomMessageText + $66
call Func_f8bd
ld bc, $0040
ld de, $0060
call Func_f80d
call Func_f83a
call Func_f83a
ret
Func_f78e: ; 0xf78e
push hl
call ConvertHexByteToDecWord
pop hl
ld c, $1
ld a, d
call .asm_f7a4
inc hl
ld a, e
swap a
call .asm_f7a4
inc hl
ld c, $0
ld a, e
; fall through
.asm_f7a4
and $f
jr nz, .asm_f7ab
ld a, c
and a
ret nz
.asm_f7ab
add $86
ld [hl], a
ld c, $0
ret
PlaceTextAlphanumericOnly: ; 0xf7b1 seems to filter out punctuation and other misc characters
ld a, [wd805] ;id unusedTextFlag is set, take olther path
and a
jr nz, .UnusedBranch
.loop
ld a, [hli]
and a
ret z ;if end of text, ret
cp "0"
jr c, .NotADigit ;if a digit, add $56 and skip letter check
cp "9" + 1
jr nc, .NotADigit
add $56
jr .IsValidChar
.NotADigit
cp "A"
jr c, .NotALetter ;if a letter, add $56 and skip letter check
cp "Z" + 1
jr nc, .NotALetter
add $bf
jr .IsValidChar
.NotALetter
cp "e" ;check if acute e
jr nz, .NotAcuteE
ld a, $83
jr .IsValidChar
.NotAcuteE
ld a, $81 ;if none of the above groups, replace with a space
.IsValidChar
ld [de], a ;load result into de
inc de
jr .loop
.UnusedBranch
ld a, [hli]
and a
ret z
cp "0"
jr c, .asm_f7ef
cp "9" + 1
jr nc, .asm_f7ef
add $56
jr .asm_f809
.asm_f7ef
cp $a0
jr c, .asm_f7fb
cp $e0
jr nc, .asm_f7fb
sub $80
jr .asm_f809
.asm_f7fb
cp $e0
jr c, .asm_f807
cp $f4
jr nc, .asm_f807
sub $50
jr .asm_f809
.asm_f807
ld a, $81
.asm_f809
ld [de], a
inc de
jr .UnusedBranch
Func_f80d: ; 0xf80d
hlCoord 0, 0, vBGWin
add hl, de
push hl
ld hl, wBottomMessageText
add hl, de
pop de
call LoadVRAMData
ret
Func_f81b: ; 0xf81b
ld a, $81
ld [hli], a
dec bc
ld a, b
or c
jr nz, Func_f81b
ret
Func_f824: ; 0xf824
call Func_f83a
ld hl, wBottomMessageText
ld bc, $0040
call Func_f81b
ld hl, wBottomMessageText + $48
ld bc, $0038
call Func_f81b
ret
Func_f83a: ; 0xf83a
ld a, [wd4ab]
and a
ret z
ld b, $46
.asm_f841
push bc
rst AdvanceFrame
pop bc
ld a, [hNewlyPressedButtons]
bit BIT_A_BUTTON, a
jr nz, .asm_f84e
dec b
jr nz, .asm_f841
ret
.asm_f84e
xor a
ld [wd4ab], a
ret
Func_f853: ; 0xf853
push hl
ld hl, wEndOfBallBonusCategoryScore
call ClearBCD6Buffer
pop hl
.asm_f85b
push de
push hl
ld hl, wEndOfBallBonusCategoryScore + $5
ld de, wBottomMessageText + $46
call Func_f8bd
ld bc, $0040
ld de, $0040
call Func_f80d
lb de, $00, $3e
call PlaySoundEffect
ld a, [wd4ab]
and a
jr z, .asm_f886
rst AdvanceFrame
ld a, [hNewlyPressedButtons]
bit BIT_A_BUTTON, a
jr z, .asm_f886
xor a
ld [wd4ab], a
.asm_f886
pop hl
pop de
ld a, [hl]
and a
jr z, .asm_f899
dec [hl]
push de
push hl
ld hl, wEndOfBallBonusCategoryScore
call AddBigBCD6
pop hl
pop de
jr .asm_f85b
.asm_f899
ld hl, wEndOfBallBonusSubTotal
ld de, wEndOfBallBonusCategoryScore
call AddBigBCD6
ld hl, wEndOfBallBonusSubTotal + $5
ld de, wBottomMessageText + $86
call Func_f8bd
ld bc, $0040
ld de, $0080
call Func_f80d
ret
ClearBCD6Buffer: ; 0xf8b5
xor a
ld b, $6
.loop
ld [hli], a
dec b
jr nz, .loop
ret
Func_f8bd: ; 0xf8bd
ld bc, $0c01
.asm_f8c0
ld a, [hl]
swap a
call Func_f8d5
inc de
dec b
ld a, [hld]
call Func_f8d5
inc de
dec b
jr nz, .asm_f8c0
ld a, $86
ld [de], a
inc de
ret
Func_f8d5: ; 0xf8d5
and $f
jr nz, .asm_f8e0
ld a, b
dec a
jr z, .asm_f8e0
ld a, c
and a
ret nz
.asm_f8e0
add $86
ld [de], a
ld c, $0
ld a, b
cp $c
jr z, .asm_f8f5
cp $9
jr z, .asm_f8f5
cp $6
jr z, .asm_f8f5
cp $3
ret nz
.asm_f8f5
push de
ld a, e
add $20
ld e, a
jr nc, .asm_f8fd
inc d
.asm_f8fd
ld a, $82
ld [de], a
pop de
ret
AddBigBCD6: ; 0xf902
x = 0
rept 6
ld a, [de]
if x == 0
add [hl]
else
adc [hl]
endc
x = x + 1
daa
ld [hli], a
inc de
endr
ret
PointsPerPokemonCaught: ; 0xf921
bigBCD6 50000
PointsPerPokemonEvolved: ; 0xf927
bigBCD6 75000
PointsPerBellsproutEntry: ; 0xf92d
PointsPerCloysterEntry:
PointsPerSlowpokeEntry:
bigBCD6 7500
PointsPerPoliwagTriple: ; 0xf933
PointsPerPsyduckTriple:
PointsPerDugtrioTriple:
bigBCD6 5000
PointsPerCAVECompletion: ; 0xf939
bigBCD6 2500
PointsPerSpinnerTurn: ; 0xf93f
bigBCD6 1000
HandleBallBonusRedField: ; 0xf945
call HandleBellsproutEntriesBallBonus
call HandleDugtrioTriplesBallBonus
call HandleCAVECompletionsBallBonus_RedField
call HandleSpinnerTurnsBallBonus_RedField
ret
HandleBellsproutEntriesBallBonus: ; 0xf952
ld de, wBottomMessageText + $03
ld hl, BellsproutCounterText
call PlaceTextAlphanumericOnly
ld hl, wBottomMessageText + $03
ld a, [wNumBellsproutEntries]
call Func_f78e
ld bc, $0040
ld de, $0000
call Func_f80d
ld hl, wNumBellsproutEntries
ld de, PointsPerBellsproutEntry
call Func_f853
call Func_f824
ret
HandleDugtrioTriplesBallBonus: ; 0xf97a
ld de, wBottomMessageText + $04
ld hl, DugtrioCounterText
call PlaceTextAlphanumericOnly
ld hl, wBottomMessageText + $04
ld a, [wNumDugtrioTriples]
call Func_f78e
ld bc, $0040
ld de, $0000
call Func_f80d
ld hl, wNumDugtrioTriples
ld de, PointsPerDugtrioTriple
call Func_f853
call Func_f824
ret
HandleCAVECompletionsBallBonus_RedField: ; 0xf9a2
ld de, wBottomMessageText + $03
ld hl, CaveShotCounterText
call PlaceTextAlphanumericOnly
ld hl, wBottomMessageText + $03
ld a, [wNumCAVECompletions]
call Func_f78e
ld bc, $0040
ld de, $0000
call Func_f80d
ld hl, wNumCAVECompletions
ld de, PointsPerCAVECompletion
call Func_f853
call Func_f824
ret
HandleSpinnerTurnsBallBonus_RedField: ; 0xf9ca
ld de, wBottomMessageText + $01
ld hl, SpinnerTurnsCounterText
call PlaceTextAlphanumericOnly
ld hl, wBottomMessageText + $01
ld a, [wNumSpinnerTurns]
call Func_f78e
ld bc, $0040
ld de, $0000
call Func_f80d
ld hl, wNumSpinnerTurns
ld de, PointsPerSpinnerTurn
call Func_f853
call Func_f824
ret
DoNothing_f9f2: ; 0xf9f2
ret
HandleBallBonusBlueField: ; 0xf9f3
call HandleCloysterEntriesBallBonus
call HandleSlowpokeEntriesBallBonus
call HandlePoliwagTriplesBallBonus
call HandlePsyduckTriplesBallBonus
call HandleCAVECompletionsBallBonus_BlueField
call HandleSpinnerTurnsBallBonus_BlueField
ret
HandleCloysterEntriesBallBonus: ; 0xfa06
ld de, wBottomMessageText + $04
ld hl, CloysterCounterText
call PlaceTextAlphanumericOnly
ld hl, wBottomMessageText + $04
ld a, [wNumCloysterEntries]
call Func_f78e
ld bc, $0040
ld de, $0000
call Func_f80d
ld hl, wNumCloysterEntries
ld de, PointsPerCloysterEntry
call Func_f853
call Func_f824
ret
HandleSlowpokeEntriesBallBonus: ; 0xfa2e
ld de, wBottomMessageText + $04
ld hl, SlowpokeCounterText
call PlaceTextAlphanumericOnly
ld hl, wBottomMessageText + $04
ld a, [wNumSlowpokeEntries]
call Func_f78e
ld bc, $0040
ld de, $0000
call Func_f80d
ld hl, wNumSlowpokeEntries
ld de, PointsPerSlowpokeEntry
call Func_f853
call Func_f824
ret
HandlePoliwagTriplesBallBonus: ; 0xfa56
ld de, wBottomMessageText + $04
ld hl, PoliwagCounterText
call PlaceTextAlphanumericOnly
ld hl, wBottomMessageText + $04
ld a, [wNumPoliwagTriples]
call Func_f78e
ld bc, $0040
ld de, $0000
call Func_f80d
ld hl, wNumPoliwagTriples
ld de, PointsPerPoliwagTriple
call Func_f853
call Func_f824
ret
HandlePsyduckTriplesBallBonus: ; 0xfa7e
ld de, wBottomMessageText + $04
ld hl, PsyduckCounterText
call PlaceTextAlphanumericOnly
ld hl, wBottomMessageText + $04
ld a, [wNumPsyduckTriples]
call Func_f78e
ld bc, $0040
ld de, $0000
call Func_f80d
ld hl, wNumPsyduckTriples
ld de, PointsPerPsyduckTriple
call Func_f853
call Func_f824
ret
HandleCAVECompletionsBallBonus_BlueField: ; 0xfaa6
ld de, wBottomMessageText + $03
ld hl, CaveShotCounterText
call PlaceTextAlphanumericOnly
ld hl, wBottomMessageText + $03
ld a, [wNumCAVECompletions]
call Func_f78e
ld bc, $0040
ld de, $0000
call Func_f80d
ld hl, wNumCAVECompletions
ld de, PointsPerCAVECompletion
call Func_f853
call Func_f824
ret
HandleSpinnerTurnsBallBonus_BlueField: ; 0xface :)
ld de, wBottomMessageText + $01
ld hl, SpinnerTurnsCounterText
call PlaceTextAlphanumericOnly
ld hl, wBottomMessageText + $01
ld a, [wNumSpinnerTurns]
call Func_f78e
ld bc, $0040
ld de, $0000
call Func_f80d
ld hl, wNumSpinnerTurns
ld de, PointsPerSpinnerTurn
call Func_f853
call Func_f824
ret
DoNothing_faf6: ; 0xfaf6
ret
DoNothing_faf7: ; 0xfaf7
ret
DoNothing_faf8: ; 0xfaf8
ret
; XXX
ret
; XXX
ret
|