ref: 93a129eb6dc261faccaf2b2d58daf3db204ab3ba
parent: 8a6a1a7d77fdcd1f8468f0c411795a8f039d4bd8
author: PikalaxALT <PikalaxALT@gmail.com>
date: Thu Nov 19 13:07:20 EST 2015
main.asm is now under 30k lines
--- /dev/null
+++ b/engine/crystal_intro.asm
@@ -1,0 +1,2531 @@
+Functione455c: ; e455c
+ hlcoord 1, 1
+ ld de, SCREEN_WIDTH
+ ld c, $10
+.asm_e4564
+ ld [hl], $7f
+ add hl, de
+ dec c
+ jr nz, .asm_e4564
+ hlcoord 1, 2
+ ld bc, $28
+ ld a, [wJumptableIndex]
+ call AddNTimes
+ ld [hl], $ed
+ ret
+; e4579
+
+
+Functione4579: ; e4579
+ ld de, MUSIC_NONE
+ call PlayMusic
+ call ClearBGPalettes
+ call ClearTileMap
+ ld a, VBGMap0 / $100
+ ld [hBGMapAddress + 1], a
+ xor a
+ ld [hBGMapAddress], a
+ ld [hJoyDown], a
+ ld [hSCX], a
+ ld [hSCY], a
+ ld a, $90
+ ld [hWY], a
+ call WaitBGMap
+ ld b, SCGB_19
+ call GetSGBLayout
+ call SetPalettes
+ ld c, 10
+ call DelayFrames
+ callab Copyright
+ call WaitBGMap
+ ld c, 100
+ call DelayFrames
+ call ClearTileMap
+ callba GBCOnlyScreen
+ call Functione45e8
+.joy_loop
+ call JoyTextDelay
+ ld a, [hJoyLast]
+ and BUTTONS
+ jr nz, .pressed_button
+ ld a, [wJumptableIndex]
+ bit 7, a
+ jr nz, .finish
+ call PlaceGameFreakPresents
+ callba Function8cf69
+ call DelayFrame
+ jr .joy_loop
+
+.pressed_button
+ call Functione465e
+ scf
+ ret
+
+.finish
+ call Functione465e
+ and a
+ ret
+; e45e8
+
+Functione45e8: ; e45e8
+ ld de, GameFreakLogo
+ ld hl, VTiles2
+ lb bc, BANK(GameFreakLogo), $1c
+ call Get1bpp
+
+ ld a, [rSVBK]
+ push af
+ ld a, $6
+ ld [rSVBK], a
+
+ ld hl, IntroLogoGFX
+ ld de, w6_d000
+ ld a, BANK(IntroLogoGFX)
+ call FarDecompress
+
+ ld hl, VTiles0
+ ld de, w6_d000
+ lb bc, 1, 8 tiles
+ call Request2bpp
+
+ ld hl, VTiles1
+ ld de, w6_d000 + $80 tiles
+ lb bc, 1, 8 tiles
+ call Request2bpp
+
+ pop af
+ ld [rSVBK], a
+
+ callba Function8cf53
+ depixel 10, 11, 4, 0
+ ld a, SPRITE_ANIM_INDEX_03
+ call _InitSpriteAnimStruct
+ ld hl, $7
+ add hl, bc
+ ld [hl], $a0
+ ld hl, $c
+ add hl, bc
+ ld [hl], $60
+ ld hl, $d
+ add hl, bc
+ ld [hl], $30
+ xor a
+ ld [wJumptableIndex], a
+ ld [wcf64], a
+ ld [wcf65], a
+ ld [hSCX], a
+ ld [hSCY], a
+ ld a, $1
+ ld [hBGMapMode], a
+ ld a, $90
+ ld [hWY], a
+ ld de, $e4e4
+ call DmgToCgbObjPals
+ ret
+; e465e
+
+Functione465e: ; e465e
+ callba Function8cf53
+ call ClearTileMap
+ call ClearSprites
+ ld c, 16
+ call DelayFrames
+ ret
+; e4670
+
+PlaceGameFreakPresents: ; e4670
+ ld a, [wJumptableIndex]
+ ld e, a
+ ld d, 0
+ ld hl, .jumptable
+rept 2
+ add hl, de
+endr
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp [hl]
+; e467f
+
+.jumptable: ; e467f
+ dw PlaceGameFreakPresents_0
+ dw PlaceGameFreakPresents_1
+ dw PlaceGameFreakPresents_2
+ dw PlaceGameFreakPresents_3
+; e4687
+
+PlaceGameFreakPresents_AdvanceIndex: ; e4687
+ ld hl, wJumptableIndex
+ inc [hl]
+ ret
+; e468c
+
+PlaceGameFreakPresents_0: ; e468c
+ ret
+; e468d
+
+PlaceGameFreakPresents_1: ; e468d
+ ld hl, wcf65
+ ld a, [hl]
+ cp $20
+ jr nc, .PlaceGameFreak
+ inc [hl]
+ ret
+
+.PlaceGameFreak
+ ld [hl], 0
+ ld hl, .GAME_FREAK
+ decoord 5, 10
+ ld bc, .end - .GAME_FREAK
+ call CopyBytes
+ call PlaceGameFreakPresents_AdvanceIndex
+ ld de, SFX_GAME_FREAK_PRESENTS
+ call PlaySFX
+ ret
+; e46af
+
+.GAME_FREAK
+ ; G A M E _ F R E A K
+ db 0, 1, 2, 3, 13, 4, 5, 3, 1, 6
+.end
+ db "@"
+; e46ba
+
+PlaceGameFreakPresents_2: ; e46ba
+ ld hl, wcf65
+ ld a, [hl]
+ cp $40
+ jr nc, .place_presents
+ inc [hl]
+ ret
+
+.place_presents
+ ld [hl], 0
+ ld hl, .presents
+ decoord 7,11
+ ld bc, .end - .presents
+ call CopyBytes
+ call PlaceGameFreakPresents_AdvanceIndex
+ ret
+; e46d6
+
+.presents
+ db 7, 8, 9, 10, 11, 12
+.end
+ db "@"
+; e46dd
+
+PlaceGameFreakPresents_3: ; e46dd
+ ld hl, wcf65
+ ld a, [hl]
+ cp $80
+ jr nc, .finish
+ inc [hl]
+ ret
+
+.finish
+ ld hl, wJumptableIndex
+ set 7, [hl]
+ ret
+; e46ed
+
+
+
+GameFreakLogoJumper: ; e46ed (39:46ed)
+ ld hl, $b
+ add hl, bc
+ ld e, [hl]
+ ld d, 0
+ ld hl, GameFreakLogoScenes
+rept 2
+ add hl, de
+endr
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp [hl]
+
+GameFreakLogoScenes: ; e46fd (39:46fd)
+ dw GameFreakLogoScene1
+ dw GameFreakLogoScene2
+ dw GameFreakLogoScene3
+ dw GameFreakLogoScene4
+ dw GameFreakLogoScene5
+
+
+GameFreakLogoScene1: ; e4707 (39:4707)
+ ld hl, $b
+ add hl, bc
+ inc [hl]
+ ret
+
+GameFreakLogoScene2: ; e470d (39:470d)
+ ld hl, $c
+ add hl, bc
+ ld a, [hl]
+ and a
+ jr z, .asm_e4747
+ ld d, a
+ ld hl, $d
+ add hl, bc
+ ld a, [hl]
+ and $3f
+ cp $20
+ jr nc, .asm_e4723
+ add $20
+.asm_e4723
+ ld e, a
+ callba Functionce765
+ ld hl, $7
+ add hl, bc
+ ld [hl], e
+ ld hl, $d
+ add hl, bc
+ ld a, [hl]
+ dec [hl]
+ and $1f
+ ret nz
+ ld hl, $c
+ add hl, bc
+ ld a, [hl]
+ sub $30
+ ld [hl], a
+ ld de, SFX_DITTO_BOUNCE
+ call PlaySFX
+ ret
+.asm_e4747
+ ld hl, $b
+ add hl, bc
+ inc [hl]
+ ld hl, $d
+ add hl, bc
+ ld [hl], $0
+ ld de, SFX_DITTO_POP_UP
+ call PlaySFX
+ ret
+
+GameFreakLogoScene3: ; e4759 (39:4759)
+ ld hl, $d
+ add hl, bc
+ ld a, [hl]
+ cp $20
+ jr nc, .asm_e4764
+ inc [hl]
+ ret
+.asm_e4764
+ ld hl, $b
+ add hl, bc
+ inc [hl]
+ ld hl, $d
+ add hl, bc
+ ld [hl], $0
+ ld de, SFX_DITTO_TRANSFORM
+ call PlaySFX
+ ret
+
+GameFreakLogoScene4: ; e4776 (39:4776)
+ ld hl, $d
+ add hl, bc
+ ld a, [hl]
+ cp $40
+ jr z, .asm_e47a3
+ inc [hl]
+ srl a
+ srl a
+ ld e, a
+ ld d, $0
+ ld hl, GameFreakLogoPalettes
+rept 2
+ add hl, de
+endr
+ ld a, [rSVBK]
+ push af
+ ld a, $5
+ ld [rSVBK], a
+ ld a, [hli]
+ ld [OBPals + 12], a
+ ld a, [hli]
+ ld [OBPals + 13], a
+ pop af
+ ld [rSVBK], a
+ ld a, $1
+ ld [hCGBPalUpdate], a
+ ret
+.asm_e47a3
+ ld hl, $b
+ add hl, bc
+ inc [hl]
+ call PlaceGameFreakPresents_AdvanceIndex
+
+GameFreakLogoScene5: ; e47ab (39:47ab)
+ ret
+; e47ac (39:47ac)
+
+GameFreakLogoPalettes: ; e47ac
+; Ditto's color as it turns into the Game Freak logo.
+; Fade from pink to orange.
+; One color per step.
+ RGB 23, 12, 28
+ RGB 23, 12, 27
+ RGB 23, 13, 26
+ RGB 23, 13, 24
+ RGB 24, 14, 22
+ RGB 24, 14, 20
+ RGB 24, 15, 18
+ RGB 24, 15, 16
+ RGB 25, 16, 14
+ RGB 25, 16, 12
+ RGB 25, 17, 10
+ RGB 25, 17, 08
+ RGB 26, 18, 06
+ RGB 26, 18, 04
+ RGB 26, 19, 02
+ RGB 26, 19, 00
+;' e47cc
+
+GameFreakLogo: ; e47cc
+INCBIN "gfx/splash/logo.1bpp"
+; e48ac
+
+CrystalIntro: ; e48ac
+ ld a, [rSVBK]
+ push af
+ ld a, 5
+ ld [rSVBK], a
+ ld a, [hInMenu]
+ push af
+ ld a, [hVBlank]
+ push af
+ call Functione4901
+.loop: ; e48bc
+ call JoyTextDelay
+ ld a, [hJoyLast]
+ and BUTTONS
+ jr nz, .ShutOffMusic
+ ld a, [wJumptableIndex]
+ bit 7, a
+ jr nz, .done
+ call IntroSceneJumper
+ callba Function8cf69
+ call DelayFrame
+ jp .loop
+
+.ShutOffMusic
+ ld de, MUSIC_NONE
+ call PlayMusic
+
+.done
+ call ClearBGPalettes
+ call ClearSprites
+ call ClearTileMap
+ xor a
+ ld [hSCX], a
+ ld [hSCY], a
+ ld a, $7
+ ld [hWX], a
+ ld a, $90
+ ld [hWY], a
+ pop af
+ ld [hVBlank], a
+ pop af
+ ld [hInMenu], a
+ pop af
+ ld [rSVBK], a
+ ret
+; e4901
+
+Functione4901: ; e4901
+ xor a
+ ld [hVBlank], a
+ ld a, $1
+ ld [hInMenu], a
+ xor a
+ ld [hMapAnims], a
+ ld [wJumptableIndex], a
+ ret
+; e490f
+
+IntroSceneJumper: ; e490f
+ ld a, [wJumptableIndex]
+ ld e, a
+ ld d, 0
+ ld hl, IntroScenes
+rept 2
+ add hl, de
+endr
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp [hl]
+; e491e
+
+
+IntroScenes: ; e491e (39:491e)
+ dw IntroScene1
+ dw IntroScene2
+ dw IntroScene3
+ dw IntroScene4
+ dw IntroScene5
+ dw IntroScene6
+ dw IntroScene7
+ dw IntroScene8
+ dw IntroScene9
+ dw IntroScene10
+ dw IntroScene11
+ dw IntroScene12
+ dw IntroScene13
+ dw IntroScene14
+ dw IntroScene15
+ dw IntroScene16
+ dw IntroScene17
+ dw IntroScene18
+ dw IntroScene19
+ dw IntroScene20
+ dw IntroScene21
+ dw IntroScene22
+ dw IntroScene23
+ dw IntroScene24
+ dw IntroScene25
+ dw IntroScene26
+ dw IntroScene27
+ dw IntroScene28
+
+
+NextIntroScene: ; e4956 (39:4956)
+ ld hl, wJumptableIndex
+ inc [hl]
+ ret
+
+IntroScene1: ; e495b (39:495b)
+; Setup the next scene.
+ call Functione54a3
+ call ClearSprites
+ call ClearTileMap
+ xor a
+ ld [hBGMapMode], a
+ ld a, $1
+ ld [rVBK], a
+ ld hl, IntroTilemap001
+ ld de, VBGMap0 tile $00
+ call Functione54fa
+ ld a, $0
+ ld [rVBK], a
+ ld hl, IntroUnownsGFX
+ ld de, VTiles2 tile $00
+ call Functione54c2
+ ld hl, IntroPulseGFX
+ ld de, VTiles0 tile $00
+ call Functione54c2
+ ld hl, IntroTilemap002
+ ld de, VBGMap0 tile $00
+ call Functione54fa
+ ld a, [rSVBK]
+ push af
+ ld a, $5
+ ld [rSVBK], a
+ ld hl, Palette_365ad
+ ld de, wMapPals
+ ld bc, $80
+ call CopyBytes
+ ld hl, Palette_365ad
+ ld de, BGPals
+ ld bc, $80
+ call CopyBytes
+ pop af
+ ld [rSVBK], a
+ xor a
+ ld [hSCX], a
+ ld [hSCY], a
+ ld a, $7
+ ld [hWX], a
+ ld a, $90
+ ld [hWY], a
+ callba Function8cf53
+ call Functione549e
+ xor a
+ ld [wIntroSceneFrameCounter], a
+ ld [wcf65], a
+ call NextIntroScene
+ ret
+
+IntroScene2: ; e49d6 (39:49d6)
+; First Unown (A) fades in, pulses, then fades out.
+ ld hl, wIntroSceneFrameCounter
+ ld a, [hl]
+ inc [hl]
+ cp $80
+ jr nc, .endscene
+ cp $60
+ jr nz, .DontPlaySound
+ push af
+ ld de, $5858
+ call Functione51dc
+ ld de, SFX_INTRO_UNOWN_1
+ call PlaySFX
+ pop af
+.DontPlaySound
+ ld [wcf65], a
+ xor a
+ call Functione5223
+ ret
+.endscene
+ call NextIntroScene
+ ret
+
+IntroScene3: ; e49fd (39:49fd)
+; More setup. Transition to the outdoor scene.
+ call Functione54a3
+ call ClearSprites
+ call ClearTileMap
+ xor a
+ ld [hBGMapMode], a
+ ld a, $1
+ ld [rVBK], a
+ ld hl, IntroTilemap003
+ ld de, VBGMap0 tile $00
+ call Functione54fa
+ ld a, $0
+ ld [rVBK], a
+ ld hl, IntroBackgroundGFX
+ ld de, VTiles2 tile $00
+ call Functione54c2
+ ld hl, IntroTilemap004
+ ld de, VBGMap0 tile $00
+ call Functione54fa
+ ld a, [rSVBK]
+ push af
+ ld a, $5
+ ld [rSVBK], a
+ ld hl, Palette_e5edd
+ ld de, wMapPals
+ ld bc, $80
+ call CopyBytes
+ ld hl, Palette_e5edd
+ ld de, BGPals
+ ld bc, $80
+ call CopyBytes
+ pop af
+ ld [rSVBK], a
+ xor a
+ ld [hSCX], a
+ ld [hSCY], a
+ ld a, $7
+ ld [hWX], a
+ ld a, $90
+ ld [hWY], a
+ call Functione5516
+ call Functione549e
+ xor a
+ ld [wIntroSceneFrameCounter], a
+ call NextIntroScene
+ ret
+
+IntroScene4: ; e4a69 (39:4a69)
+; Scroll the outdoor panorama for a bit.
+ call Functione552f
+ ld hl, wIntroSceneFrameCounter
+ ld a, [hl]
+ cp $80
+ jr z, .endscene
+ inc [hl]
+ ret
+.endscene
+ call NextIntroScene
+ ret
+
+IntroScene5: ; e4a7a (39:4a7a)
+; Go back to the Unown.
+ call Functione54a3
+ call ClearSprites
+ call ClearTileMap
+ xor a
+ ld [hBGMapMode], a
+ ld [hLCDStatCustom], a
+ ld a, $1
+ ld [rVBK], a
+ ld hl, IntroTilemap005
+ ld de, VBGMap0 tile $00
+ call Functione54fa
+ ld a, $0
+ ld [rVBK], a
+ ld hl, IntroUnownsGFX
+ ld de, VTiles2 tile $00
+ call Functione54c2
+ ld hl, IntroPulseGFX
+ ld de, VTiles0 tile $00
+ call Functione54c2
+ ld hl, IntroTilemap006
+ ld de, VBGMap0 tile $00
+ call Functione54fa
+ ld a, [rSVBK]
+ push af
+ ld a, $5
+ ld [rSVBK], a
+ ld hl, Palette_365ad
+ ld de, wMapPals
+ ld bc, $80
+ call CopyBytes
+ ld hl, Palette_365ad
+ ld de, BGPals
+ ld bc, $80
+ call CopyBytes
+ pop af
+ ld [rSVBK], a
+ xor a
+ ld [hSCX], a
+ ld [hSCY], a
+ ld a, $7
+ ld [hWX], a
+ ld a, $90
+ ld [hWY], a
+ callba Function8cf53
+ call Functione549e
+ xor a
+ ld [wcf64], a
+ ld [wcf65], a
+ call NextIntroScene
+ ret
+
+IntroScene6: ; e4af7 (39:4af7)
+; Two more Unown (I, H) fade in.
+ ld hl, wcf64
+ ld a, [hl]
+ inc [hl]
+ cp $80
+ jr nc, .endscene
+ cp $60
+ jr z, .SecondUnown
+ cp $40
+ jr nc, .StopUnown
+ cp $20
+ jr z, .FirstUnown
+ jr .NoUnown
+.FirstUnown
+ push af
+ ld de, $3878
+ call Functione51dc
+ ld de, SFX_INTRO_UNOWN_2
+ call PlaySFX
+ pop af
+.NoUnown
+ ld [wcf65], a
+ xor a
+ call Functione5223
+ ret
+.SecondUnown
+ push af
+ ld de, $7030
+ call Functione51dc
+ ld de, SFX_INTRO_UNOWN_1
+ call PlaySFX
+ pop af
+.StopUnown
+ ld [wcf65], a
+ ld a, $1
+ call Functione5223
+ ret
+.endscene
+ call NextIntroScene
+ ret
+
+IntroScene7: ; e4b3f (39:4b3f)
+; Back to the outdoor scene.
+ call Functione54a3
+ call ClearSprites
+ call ClearTileMap
+ xor a
+ ld [hBGMapMode], a
+ ld a, $1
+ ld [rVBK], a
+ ld hl, IntroTilemap003
+ ld de, VBGMap0 tile $00
+ call Functione54fa
+ ld hl, IntroPichuWooperGFX
+ ld de, VTiles0 tile $00
+ call Functione54c2
+ ld a, $0
+ ld [rVBK], a
+ ld hl, IntroSuicuneRunGFX
+ ld de, VTiles0 tile $00
+ call Functione54de
+ ld hl, IntroBackgroundGFX
+ ld de, VTiles2 tile $00
+ call Functione54c2
+ ld hl, IntroTilemap004
+ ld de, VBGMap0 tile $00
+ call Functione54fa
+ ld a, [rSVBK]
+ push af
+ ld a, $5
+ ld [rSVBK], a
+ ld hl, Palette_e5edd
+ ld de, wMapPals
+ ld bc, $80
+ call CopyBytes
+ ld hl, Palette_e5edd
+ ld de, BGPals
+ ld bc, $80
+ call CopyBytes
+ pop af
+ ld [rSVBK], a
+ xor a
+ ld [hSCX], a
+ ld [hSCY], a
+ ld a, $7
+ ld [hWX], a
+ ld a, $90
+ ld [hWY], a
+ call Functione5516
+ callba Function8cf53
+ depixel 13, 27, 4, 0
+ ld a, SPRITE_ANIM_INDEX_26
+ call _InitSpriteAnimStruct
+ ld a, $f0
+ ld [wc3c0], a
+ call Functione549e
+ xor a
+ ld [wIntroSceneFrameCounter], a
+ ld [wcf65], a
+ call NextIntroScene
+ ret
+
+IntroScene8: ; e4bd3 (39:4bd3)
+; Scroll the scene, then show Suicune running across the screen.
+ ld hl, wIntroSceneFrameCounter
+ ld a, [hl]
+ inc [hl]
+ cp $40
+ jr z, .asm_e4be2
+ jr nc, .asm_e4be8
+ call Functione552f
+ ret
+.asm_e4be2
+ ld de, SFX_INTRO_SUICUNE_3
+ call PlaySFX
+.asm_e4be8
+ ld a, [wc3c0]
+ and a
+ jr z, .asm_e4bf4
+ sub $8
+ ld [wc3c0], a
+ ret
+.asm_e4bf4
+ ld de, SFX_INTRO_SUICUNE_2
+ call PlaySFX
+ callba Function8d03d
+ call NextIntroScene
+ ret
+
+IntroScene9: ; e4c04 (39:4c04)
+; Set up the next scene (same bg).
+ xor a
+ ld [hLCDStatCustom], a
+ call ClearSprites
+ hlcoord 0, 0, AttrMap
+ ld bc, $f0
+ ld a, $1
+ call ByteFill
+ ld bc, $3c
+ ld a, $2
+ call ByteFill
+ ld bc, $3c
+ ld a, $3
+ call ByteFill
+ ld a, $2
+ ld [hBGMapMode], a
+ call DelayFrame
+ call DelayFrame
+ call DelayFrame
+ ld a, $c
+ ld [hBGMapAddress], a
+ call DelayFrame
+ call DelayFrame
+ call DelayFrame
+ xor a
+ ld [hBGMapMode], a
+ ld [hBGMapAddress], a
+ ld [wc3c0], a
+ xor a
+ ld [wcf64], a
+ call NextIntroScene
+ ret
+
+IntroScene10: ; e4c4f (39:4c4f)
+; Wooper and Pichu enter.
+ call Functione546d
+ ld hl, wcf64
+ ld a, [hl]
+ inc [hl]
+ cp $c0
+ jr z, .done
+ cp $20
+ jr z, .wooper
+ cp $40
+ jr z, .pichu
+ ret
+
+.pichu
+ depixel 21, 16, 1, 0
+ ld a, SPRITE_ANIM_INDEX_27
+ call _InitSpriteAnimStruct
+ ld de, SFX_INTRO_PICHU
+ call PlaySFX
+ ret
+
+.wooper
+ depixel 22, 6
+ ld a, SPRITE_ANIM_INDEX_28
+ call _InitSpriteAnimStruct
+ ld de, SFX_INTRO_PICHU
+ call PlaySFX
+ ret
+.done
+ call NextIntroScene
+ ret
+
+IntroScene11: ; e4c86 (39:4c86)
+; Back to Unown again.
+ call Functione54a3
+ call ClearSprites
+ call ClearTileMap
+ xor a
+ ld [hBGMapMode], a
+ ld [hLCDStatCustom], a
+ ld a, $1
+ ld [rVBK], a
+ ld hl, IntroTilemap007
+ ld de, VBGMap0 tile $00
+ call Functione54fa
+ ld a, $0
+ ld [rVBK], a
+ ld hl, IntroUnownsGFX
+ ld de, VTiles2 tile $00
+ call Functione54c2
+ ld hl, IntroTilemap008
+ ld de, VBGMap0 tile $00
+ call Functione54fa
+ ld a, [rSVBK]
+ push af
+ ld a, $5
+ ld [rSVBK], a
+ ld hl, Palette_365ad
+ ld de, wMapPals
+ ld bc, $80
+ call CopyBytes
+ ld hl, Palette_365ad
+ ld de, BGPals
+ ld bc, $80
+ call CopyBytes
+ pop af
+ ld [rSVBK], a
+ xor a
+ ld [hSCX], a
+ ld [hSCY], a
+ ld a, $7
+ ld [hWX], a
+ ld a, $90
+ ld [hWY], a
+ callba Function8cf53
+ call Functione549e
+ xor a
+ ld [wIntroSceneFrameCounter], a
+ ld [wcf65], a
+ call NextIntroScene
+ ret
+
+IntroScene12: ; e4cfa (39:4cfa)
+; Even more Unown.
+ call Functione4d36
+ ld hl, wIntroSceneFrameCounter
+ ld a, [hl]
+ inc [hl]
+ cp $c0
+ jr nc, .asm_e4d32
+ cp $80
+ jr nc, .asm_e4d1d
+ ld c, a
+ and $1f
+ sla a
+ ld [wcf65], a
+ ld a, c
+ and $e0
+ srl a
+ swap a
+ call Functione5223
+ ret
+.asm_e4d1d
+ ld c, a
+ and $f
+ sla a
+ sla a
+ ld [wcf65], a
+ ld a, c
+ and $70
+ or $40
+ swap a
+ call Functione5223
+ ret
+.asm_e4d32
+ call NextIntroScene
+ ret
+
+Functione4d36: ; e4d36 (39:4d36)
+ ld a, [wIntroSceneFrameCounter]
+ ld c, a
+ ld hl, .UnownSounds
+.loop
+ ld a, [hli]
+ cp -1
+ ret z
+ cp c
+ jr z, .playsound
+rept 2
+ inc hl
+endr
+ jr .loop
+.playsound
+ ld a, [hli]
+ ld d, [hl]
+ ld e, a
+ push de
+ call SFXChannelsOff
+ pop de
+ call PlaySFX
+ ret
+; e4d54 (39:4d54)
+
+.UnownSounds: ; e4d54
+ dbw $00, SFX_INTRO_UNOWN_3
+ dbw $20, SFX_INTRO_UNOWN_2
+ dbw $40, SFX_INTRO_UNOWN_1
+ dbw $60, SFX_INTRO_UNOWN_2
+ dbw $80, SFX_INTRO_UNOWN_3
+ dbw $90, SFX_INTRO_UNOWN_2
+ dbw $a0, SFX_INTRO_UNOWN_1
+ dbw $b0, SFX_INTRO_UNOWN_2
+ db $ff
+; e4d6d
+
+IntroScene13: ; e4d6d (39:4d6d)
+; Switch scenes again.
+ call Functione54a3
+ call ClearSprites
+ call ClearTileMap
+ xor a
+ ld [hBGMapMode], a
+ ld a, $1
+ ld [rVBK], a
+ ld hl, IntroTilemap003
+ ld de, VBGMap0 tile $00
+ call Functione54fa
+ ld a, $0
+ ld [rVBK], a
+ ld hl, IntroSuicuneRunGFX
+ ld de, VTiles0 tile $00
+ call Functione54de
+ ld hl, IntroBackgroundGFX
+ ld de, VTiles2 tile $00
+ call Functione54c2
+ ld hl, IntroTilemap004
+ ld de, VBGMap0 tile $00
+ call Functione54fa
+ ld a, [rSVBK]
+ push af
+ ld a, $5
+ ld [rSVBK], a
+ ld hl, Palette_e5edd
+ ld de, wMapPals
+ ld bc, $80
+ call CopyBytes
+ ld hl, Palette_e5edd
+ ld de, BGPals
+ ld bc, $80
+ call CopyBytes
+ pop af
+ ld [rSVBK], a
+ xor a
+ ld [hSCX], a
+ ld [hSCY], a
+ ld a, $7
+ ld [hWX], a
+ ld a, $90
+ ld [hWY], a
+ callba Function8cf53
+ depixel 13, 11, 4, 0
+ ld a, SPRITE_ANIM_INDEX_26
+ call _InitSpriteAnimStruct
+ ld de, MUSIC_CRYSTAL_OPENING
+ call PlayMusic
+ xor a
+ ld [wc3c0], a
+ call Functione549e
+ xor a
+ ld [wcf64], a
+ ld [wcf65], a
+ call NextIntroScene
+ ret
+
+IntroScene14: ; e4dfa (39:4dfa)
+; Suicune runs then jumps.
+ ld a, [hSCX]
+ sub 10
+ ld [hSCX], a
+ ld hl, wcf64
+ ld a, [hl]
+ inc [hl]
+ cp $80
+ jr z, .done
+ cp $60
+ jr z, .jump
+ jr nc, .asm_e4e1a
+ cp $40
+ jr nc, .asm_e4e33
+ ret
+
+.jump
+ ld de, SFX_INTRO_SUICUNE_4
+ call PlaySFX
+
+.asm_e4e1a
+ ld a, $1
+ ld [wcf65], a
+ ld a, [wc3c0]
+ cp $88
+ jr c, .asm_e4e2c
+ sub $8
+ ld [wc3c0], a
+ ret
+
+.asm_e4e2c
+ callba Function8d03d
+ ret
+
+.asm_e4e33
+ ld a, [wc3c0]
+ sub $2
+ ld [wc3c0], a
+ ret
+
+.done
+ call NextIntroScene
+ ret
+
+IntroScene15: ; e4e40 (39:4e40)
+; Transition to a new scene.
+ call Functione54a3
+ call ClearSprites
+ call ClearTileMap
+ xor a
+ ld [hBGMapMode], a
+ ld a, $1
+ ld [rVBK], a
+ ld hl, IntroTilemap009
+ ld de, VBGMap0 tile $00
+ call Functione54fa
+ ld a, $0
+ ld [rVBK], a
+ ld hl, IntroSuicuneJumpGFX
+ ld de, VTiles2 tile $00
+ call Functione54c2
+ ld hl, IntroUnownBackGFX
+ ld de, VTiles0 tile $00
+ call Functione54c2
+ ld de, GFX_e7a5d
+ ld hl, VTiles1 tile $00
+ lb bc, BANK(GFX_e7a5d), 1
+ call Request2bpp
+ ld hl, IntroTilemap010
+ ld de, VBGMap0 tile $00
+ call Functione54fa
+ call Functione541b
+ ld a, [rSVBK]
+ push af
+ ld a, $5
+ ld [rSVBK], a
+ ld hl, Palette_e77dd
+ ld de, wMapPals
+ ld bc, $80
+ call CopyBytes
+ ld hl, Palette_e77dd
+ ld de, BGPals
+ ld bc, $80
+ call CopyBytes
+ pop af
+ ld [rSVBK], a
+ xor a
+ ld [hSCX], a
+ ld a, $90
+ ld [hSCY], a
+ ld a, $7
+ ld [hWX], a
+ ld a, $90
+ ld [hWY], a
+ callba Function8cf53
+ call Functione549e
+ depixel 8, 5
+ ld a, SPRITE_ANIM_INDEX_2A
+ call _InitSpriteAnimStruct
+ depixel 12, 0
+ ld a, SPRITE_ANIM_INDEX_2B
+ call _InitSpriteAnimStruct
+ xor a
+ ld [wcf64], a
+ ld [wcf65], a
+ call NextIntroScene
+ ret
+
+IntroScene16: ; e4edc (39:4edc)
+; Suicune shows its face. An Unown appears in front.
+ ld hl, wcf64
+ ld a, [hl]
+ inc [hl]
+ cp $80
+ jr nc, .done
+ call Functione5441
+ ld a, [hSCY]
+ and a
+ ret z
+ add 8
+ ld [hSCY], a
+ ret
+.done
+ call NextIntroScene
+ ret
+
+IntroScene17: ; e4ef5 (39:4ef5)
+; ...
+ call Functione54a3
+ call ClearSprites
+ call ClearTileMap
+ xor a
+ ld [hBGMapMode], a
+ ld a, $1
+ ld [rVBK], a
+ ld hl, IntroTilemap011
+ ld de, VBGMap0 tile $00
+ call Functione54fa
+ ld a, $0
+ ld [rVBK], a
+ ld hl, IntroSuicuneCloseGFX
+ ld de, VTiles1 tile $00
+ call Functione54de
+ ld hl, IntroTilemap012
+ ld de, VBGMap0 tile $00
+ call Functione54fa
+ ld a, [rSVBK]
+ push af
+ ld a, $5
+ ld [rSVBK], a
+ ld hl, Palette_e6d6d
+ ld de, wMapPals
+ ld bc, $80
+ call CopyBytes
+ ld hl, Palette_e6d6d
+ ld de, BGPals
+ ld bc, $80
+ call CopyBytes
+ pop af
+ ld [rSVBK], a
+ xor a
+ ld [hSCX], a
+ ld [hSCY], a
+ ld a, $7
+ ld [hWX], a
+ ld a, $90
+ ld [hWY], a
+ callba Function8cf53
+ call Functione549e
+ xor a
+ ld [wcf64], a
+ ld [wcf65], a
+ call NextIntroScene
+ ret
+
+IntroScene18: ; e4f67 (39:4f67)
+; Suicune close up.
+ ld hl, wcf64
+ ld a, [hl]
+ inc [hl]
+ cp $60
+ jr nc, .done
+ ld a, [hSCX]
+ cp $60
+ ret z
+ add 8
+ ld [hSCX], a
+ ret
+.done
+ call NextIntroScene
+ ret
+
+IntroScene19: ; e4f7e (39:4f7e)
+; More setup.
+ call Functione54a3
+ call ClearSprites
+ call ClearTileMap
+ xor a
+ ld [hBGMapMode], a
+ ld a, $1
+ ld [rVBK], a
+ ld hl, IntroTilemap013
+ ld de, VBGMap0 tile $00
+ call Functione54fa
+ ld a, $0
+ ld [rVBK], a
+ ld hl, IntroSuicuneBackGFX
+ ld de, VTiles2 tile $00
+ call Functione54c2
+ ld hl, IntroUnownsGFX
+ ld de, VTiles1 tile $00
+ call Functione54c2
+ ld de, GFX_e7a5d
+ ld hl, VTiles1 tile $7f
+ lb bc, BANK(GFX_e7a5d), 1
+ call Request2bpp
+ ld hl, IntroTilemap014
+ ld de, VBGMap0 tile $00
+ call Functione54fa
+ call Functione541b
+ ld a, [rSVBK]
+ push af
+ ld a, $5
+ ld [rSVBK], a
+ ld hl, Palette_e77dd
+ ld de, wMapPals
+ ld bc, $80
+ call CopyBytes
+ ld hl, Palette_e77dd
+ ld de, BGPals
+ ld bc, $80
+ call CopyBytes
+ pop af
+ ld [rSVBK], a
+ xor a
+ ld [hSCX], a
+ ld a, $d8
+ ld [hSCY], a
+ ld a, $7
+ ld [hWX], a
+ ld a, $90
+ ld [hWY], a
+ callba Function8cf53
+ ld hl, wc300
+ xor a
+ ld [hli], a
+ ld [hl], $7f
+ call Functione549e
+ depixel 12, 0
+ ld a, SPRITE_ANIM_INDEX_2B
+ call _InitSpriteAnimStruct
+ xor a
+ ld [wcf64], a
+ ld [wcf65], a
+ call NextIntroScene
+ ret
+
+IntroScene20: ; e5019 (39:5019)
+; Suicune running away. A bunch of Unown appear.
+ ld hl, wcf64
+ ld a, [hl]
+ inc [hl]
+ cp $98
+ jr nc, .asm_e5059
+ cp $58
+ ret nc
+ cp $40
+ jr nc, .asm_e5032
+ cp $28
+ ret nc
+ ld a, [hSCY]
+ inc a
+ ld [hSCY], a
+ ret
+
+.asm_e5032
+ sub $18
+ ld c, a
+ and $3
+ cp $3
+ ret nz
+ ld a, c
+ and $1c
+ srl a
+ srl a
+ ld [wcf65], a
+ xor a
+ call Functione5348
+ ret
+; e5049 (39:5049)
+
+ ld a, c
+ and $1c
+ srl a
+ srl a
+ ld [wcf65], a
+ ld a, 1
+ call Functione5348
+ ret
+
+.asm_e5059
+ call NextIntroScene
+ ret
+
+IntroScene21: ; e505d (39:505d)
+; Suicune gets more distant and turns black.
+ call Functione5451
+ ld c, 3
+ call DelayFrames
+ xor a
+ ld [hBGMapMode], a
+ ld [wcf64], a
+ ld [wcf65], a
+ call NextIntroScene
+ ret
+
+IntroScene22: ; e5072 (39:5072)
+ ld hl, wcf64
+ ld a, [hl]
+ inc [hl]
+ cp $8
+ jr nc, .done
+ ret
+.done
+ callba Function8d03d
+ call NextIntroScene
+ ret
+
+IntroScene23: ; e5086 (39:5086)
+ xor a
+ ld [wcf64], a
+ call NextIntroScene
+ ret
+
+IntroScene24: ; e508e (39:508e)
+; Fade to white.
+ ld hl, wcf64
+ ld a, [hl]
+ inc [hl]
+ cp $20
+ jr nc, .done
+
+ ld c, a
+ and $3
+ ret nz
+ ld a, c
+ and $1c
+ sla a
+ call Functione5172
+ ret
+
+.done
+ ld a, $40
+ ld [wcf64], a
+ call NextIntroScene
+ ret
+
+IntroScene25: ; e50ad (39:50ad)
+; Wait around a bit.
+ ld a, [wcf64]
+ dec a
+ jr z, .done
+ ld [wcf64], a
+ ret
+.done
+ call NextIntroScene
+ ret
+
+IntroScene26: ; e50bb (39:50bb)
+; Load the final scene.
+ call ClearBGPalettes
+ call ClearSprites
+ call ClearTileMap
+ xor a
+ ld [hBGMapMode], a
+ ld a, $1
+ ld [rVBK], a
+ ld hl, IntroTilemap015
+ ld de, VBGMap0 tile $00
+ call Functione54fa
+ ld a, $0
+ ld [rVBK], a
+ ld hl, IntroCrystalUnownsGFX
+ ld de, VTiles2 tile $00
+ call Functione54c2
+ ld hl, IntroTilemap017
+ ld de, VBGMap0 tile $00
+ call Functione54fa
+ ld a, [rSVBK]
+ push af
+ ld a, $5
+ ld [rSVBK], a
+ ld hl, Palette_e679d
+ ld de, wMapPals
+ ld bc, $80
+ call CopyBytes
+ ld hl, Palette_e679d
+ ld de, BGPals
+ ld bc, $80
+ call CopyBytes
+ pop af
+ ld [rSVBK], a
+ xor a
+ ld [hSCX], a
+ ld [hSCY], a
+ ld a, $7
+ ld [hWX], a
+ ld a, $90
+ ld [hWY], a
+ callba Function8cf53
+ call Functione549e
+ xor a
+ ld [wcf64], a
+ ld [wcf65], a
+ call NextIntroScene
+ ret
+
+IntroScene27: ; e512d (39:512d)
+; Spell out C R Y S T A L with Unown.
+ ld hl, wcf65
+ inc [hl]
+ ld hl, wcf64
+ ld a, [hl]
+ inc [hl]
+ cp $80
+ jr nc, .done
+
+ ld c, a
+ and $f
+ ld [wcf65], a
+ ld a, c
+ and $70
+ swap a
+ call Functione539d
+ ret
+
+.done
+ call NextIntroScene
+ ld a, $80
+ ld [wcf64], a
+ ret
+
+IntroScene28: ; e5152 (39:5152)
+; Cut out when the music ends, and lead into the title screen.
+ ld hl, wcf64
+ ld a, [hl]
+ and a
+ jr z, .done
+ dec [hl]
+ cp $18
+ jr z, .clear
+ cp $8
+ ret nz
+
+ ld de, SFX_UNKNOWN_CB
+ call PlaySFX
+ ret
+
+.clear
+ call ClearBGPalettes
+ ret
+
+.done
+ ld hl, wJumptableIndex
+ set 7, [hl]
+ ret
+
+
+Functione5172: ; e5172 (39:5172)
+ ld hl, Unknown_e519c
+ add l
+ ld l, a
+ ld a, $0
+ adc h
+ ld h, a
+ ld a, [rSVBK]
+ push af
+ ld a, $5
+ ld [rSVBK], a
+ ld de, BGPals
+ ld b, $8
+.asm_e5187
+ push hl
+ ld c, $8
+.asm_e518a
+ ld a, [hli]
+ ld [de], a
+ inc de
+ dec c
+ jr nz, .asm_e518a
+ pop hl
+ dec b
+ jr nz, .asm_e5187
+ pop af
+ ld [rSVBK], a
+ ld a, $1
+ ld [hCGBPalUpdate], a
+ ret
+; e519c (39:519c)
+
+Unknown_e519c: ; e519c
+; Fade to white.
+ RGB 24, 12, 09
+ RGB 31, 31, 31
+ RGB 12, 00, 31
+ RGB 00, 00, 00
+
+ RGB 31, 19, 05
+ RGB 31, 31, 31
+ RGB 15, 05, 31
+ RGB 07, 07, 07
+
+ RGB 31, 21, 09
+ RGB 31, 31, 31
+ RGB 18, 09, 31
+ RGB 11, 11, 11
+
+ RGB 31, 23, 13
+ RGB 31, 31, 31
+ RGB 21, 13, 31
+ RGB 15, 15, 15
+
+ RGB 31, 25, 17
+ RGB 31, 31, 31
+ RGB 25, 17, 31
+ RGB 19, 19, 19
+
+ RGB 31, 27, 21
+ RGB 31, 31, 31
+ RGB 27, 21, 31
+ RGB 23, 23, 23
+
+ RGB 31, 29, 25
+ RGB 31, 31, 31
+ RGB 29, 26, 31
+ RGB 27, 27, 27
+
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+; e51dc
+
+Functione51dc: ; e51dc (39:51dc)
+ push de
+ ld a, SPRITE_ANIM_INDEX_29
+ call _InitSpriteAnimStruct
+ ld hl, $c
+ add hl, bc
+ ld [hl], $8
+ ld a, $3c
+ call Function3b3c
+ pop de
+
+ push de
+ ld a, SPRITE_ANIM_INDEX_29
+ call _InitSpriteAnimStruct
+ ld hl, $c
+ add hl, bc
+ ld [hl], $18
+ ld a, $3b
+ call Function3b3c
+ pop de
+
+ push de
+ ld a, SPRITE_ANIM_INDEX_29
+ call _InitSpriteAnimStruct
+ ld hl, $c
+ add hl, bc
+ ld [hl], $28
+ ld a, $39
+ call Function3b3c
+ pop de
+
+ ld a, SPRITE_ANIM_INDEX_29
+ call _InitSpriteAnimStruct
+ ld hl, $c
+ add hl, bc
+ ld [hl], $38
+ ld a, $3a
+ call Function3b3c
+ ret
+
+Functione5223: ; e5223 (39:5223)
+rept 3
+ add a
+endr
+ ld e, a
+ ld d, $0
+ ld hl, BGPals
+ add hl, de
+rept 2
+ inc hl
+endr
+ ld a, [wcf65]
+ and $3f
+ cp $1f
+ jr z, .asm_e523e
+ jr c, .asm_e523e
+ ld c, a
+ ld a, $3f
+ sub c
+.asm_e523e
+ ld c, a
+ ld b, $0
+ ld a, [rSVBK]
+ push af
+ ld a, $5
+ ld [rSVBK], a
+ push hl
+ push bc
+ ld hl, BGPals
+ ld bc, $40
+ xor a
+ call ByteFill
+ pop bc
+ pop hl
+ push hl
+ ld hl, Unknown_e5288
+rept 2
+ add hl, bc
+endr
+ ld a, [hli]
+ ld d, [hl]
+ ld e, a
+ pop hl
+ ld a, e
+ ld [hli], a
+ ld a, d
+ ld [hli], a
+ push hl
+ ld hl, Unknown_e52c8
+rept 2
+ add hl, bc
+endr
+ ld a, [hli]
+ ld d, [hl]
+ ld e, a
+ pop hl
+ ld a, e
+ ld [hli], a
+ ld a, d
+ ld [hli], a
+ push hl
+ ld hl, Unknown_e5308
+rept 2
+ add hl, bc
+endr
+ ld a, [hli]
+ ld d, [hl]
+ ld e, a
+ pop hl
+ ld a, e
+ ld [hli], a
+ ld a, d
+ ld [hli], a
+ pop af
+ ld [rSVBK], a
+ ld a, $1
+ ld [hCGBPalUpdate], a
+ ret
+; e5288 (39:5288)
+
+Unknown_e5288: ; e5288
+; Fade between black and white.
+hue = 0
+rept 32
+ RGB hue, hue, hue
+hue = hue + 1
+endr
+; e52c8
+
+Unknown_e52c8: ; e52c8
+; Fade between black and light blue.
+hue = 0
+rept 32
+ RGB 0, hue / 2, hue
+hue = hue + 1
+endr
+; e5308
+
+Unknown_e5308: ; e5308
+; Fade between black and blue.
+hue = 0
+rept 32
+ RGB 0, 0, hue
+hue = hue + 1
+endr
+; e5348
+
+Functione5348: ; e5348 (39:5348)
+ and a
+ jr nz, .asm_e5350
+ ld hl, Palette_e538d
+ jr .asm_e5353
+.asm_e5350
+ ld hl, Palette_e5395
+.asm_e5353
+ ld a, [wcf65]
+ and $7
+rept 3
+ add a
+endr
+ ld c, a
+ ld a, [rSVBK]
+ push af
+ ld a, $5
+ ld [rSVBK], a
+ push bc
+ ld de, BGPals
+ ld a, c
+ add e
+ ld e, a
+ ld a, $0
+ adc d
+ ld d, a
+ ld bc, $8
+ call CopyBytes
+ pop bc
+ ld de, wMapPals
+ ld a, c
+ add e
+ ld e, a
+ ld a, $0
+ adc d
+ ld d, a
+ ld bc, $8
+ call CopyBytes
+ pop af
+ ld [rSVBK], a
+ ld a, $1
+ ld [hCGBPalUpdate], a
+ ret
+; e538d (39:538d)
+
+Palette_e538d: ; e538d
+ RGB 24, 12, 09
+ RGB 31, 31, 31
+ RGB 12, 00, 31
+ RGB 00, 00, 00
+; e5395
+
+Palette_e5395: ; e5395
+ RGB 24, 12, 09
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+; e539d
+
+Functione539d: ; e539d (39:539d)
+rept 3
+ add a
+endr
+ ld e, a
+ ld d, $0
+ ld hl, BGPals
+ add hl, de
+rept 4
+ inc hl
+endr
+ ld a, [wcf65]
+ add a
+ ld c, a
+ ld b, $0
+ ld a, [rSVBK]
+ push af
+ ld a, $5
+ ld [rSVBK], a
+ push hl
+ ld hl, Palette_e53db
+ add hl, bc
+ ld a, [hli]
+ ld d, [hl]
+ ld e, a
+ pop hl
+ ld a, e
+ ld [hli], a
+ ld a, d
+ ld [hli], a
+ push hl
+ ld hl, Palette_e53fb
+ add hl, bc
+ ld a, [hli]
+ ld d, [hl]
+ ld e, a
+ pop hl
+ ld a, e
+ ld [hli], a
+ ld a, d
+ ld [hli], a
+ pop af
+ ld [rSVBK], a
+ ld a, $1
+ ld [hCGBPalUpdate], a
+ ret
+; e53db (39:53db)
+
+Palette_e53db: ; e53db
+hue = 31
+rept 8
+ RGB hue, hue, hue
+hue = hue + -1
+ RGB hue, hue, hue
+hue = hue + -2
+endr
+; e53fb
+
+Palette_e53fb: ; e53fb
+hue = 31
+rept 16
+ RGB hue, hue, hue
+hue = hue + -1
+endr
+; e541b
+
+Functione541b: ; e541b (39:541b)
+ ld a, [rSVBK]
+ push af
+ ld a, $6
+ ld [rSVBK], a
+ ld hl, w6_d000
+ decoord 0, 0
+ ld b, SCREEN_HEIGHT
+.asm_e542a
+ ld c, SCREEN_WIDTH
+.asm_e542c
+ ld a, [hli]
+ ld [de], a
+ inc de
+ dec c
+ jr nz, .asm_e542c
+ ld a, $c
+ add l
+ ld l, a
+ ld a, $0
+ adc h
+ ld h, a
+ dec b
+ jr nz, .asm_e542a
+ pop af
+ ld [rSVBK], a
+ ret
+
+Functione5441: ; e5441 (39:5441)
+ ld a, [wcf64]
+ and $3
+ jr z, Functione5451
+ cp $3
+ jr z, .asm_e544d
+ ret
+.asm_e544d
+ xor a
+ ld [hBGMapMode], a
+ ret
+
+Functione5451: ; e5451 (39:5451)
+ hlcoord 0, 0
+ ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
+.asm_e5457
+ ld a, [hl]
+ and a
+ jr z, .asm_e5462
+ cp $80
+ jr nc, .asm_e5462
+ xor $8
+ ld [hl], a
+.asm_e5462
+ inc hl
+ dec bc
+ ld a, c
+ or b
+ jr nz, .asm_e5457
+ ld a, $1
+ ld [hBGMapMode], a
+ ret
+
+Functione546d: ; e546d (39:546d)
+ ld a, [wcf64]
+ cp $24
+ ret nc
+ and $c
+ srl a
+ ld e, a
+ ld d, $0
+ ld hl, Unknown_e5496
+ add hl, de
+ ld a, [hli]
+ ld [Requested2bppSource], a
+ ld a, [hli]
+ ld [Requested2bppSource + 1], a
+ ld a, (VTiles2 tile $09) % $100
+ ld [Requested2bppDest], a
+ ld a, (VTiles2 tile $09) / $100
+ ld [Requested2bppDest + 1], a
+ ld a, $4
+ ld [Requested2bpp], a
+ ret
+; e5496 (39:5496)
+
+Unknown_e5496: ; e5496
+ dw GFX_e799d
+ dw GFX_e79dd
+ dw GFX_e7a1d
+ dw GFX_e79dd
+; e549e
+
+Functione549e: ; e549e (39:549e)
+ ld a, $1
+ ld [hCGBPalUpdate], a
+ ret
+
+Functione54a3: ; e54a3 (39:54a3)
+ ld a, [rSVBK]
+ push af
+ ld a, $5
+ ld [rSVBK], a
+ ld hl, BGPals
+ ld bc, $80
+ xor a
+ call ByteFill
+ pop af
+ ld [rSVBK], a
+ ld a, $1
+ ld [hCGBPalUpdate], a
+ call DelayFrame
+ call DelayFrame
+ ret
+
+Functione54c2: ; e54c2 (39:54c2)
+ ld a, [rSVBK]
+ push af
+ ld a, $6
+ ld [rSVBK], a
+ push de
+ ld de, w6_d000
+ call Decompress
+ pop hl
+ ld de, w6_d000
+ ld bc, $180
+ call Request2bpp
+ pop af
+ ld [rSVBK], a
+ ret
+
+Functione54de: ; e54de (39:54de)
+ ld a, [rSVBK]
+ push af
+ ld a, $6
+ ld [rSVBK], a
+ push de
+ ld de, w6_d000
+ call Decompress
+ pop hl
+ ld de, w6_d000
+ ld bc, $1ff
+ call Request2bpp
+ pop af
+ ld [rSVBK], a
+ ret
+
+Functione54fa: ; e54fa (39:54fa)
+ ld a, [rSVBK]
+ push af
+ ld a, $6
+ ld [rSVBK], a
+ push de
+ ld de, w6_d000
+ call Decompress
+ pop hl
+ ld de, w6_d000
+ ld bc, $140
+ call Request2bpp
+ pop af
+ ld [rSVBK], a
+ ret
+
+Functione5516: ; e5516 (39:5516)
+ ld a, [rSVBK]
+ push af
+ ld a, $5
+ ld [rSVBK], a
+ ld hl, LYOverrides
+ ld bc, $90
+ xor a
+ call ByteFill
+ pop af
+ ld [rSVBK], a
+ ld a, $43
+ ld [hLCDStatCustom], a
+ ret
+
+Functione552f: ; e552f (39:552f)
+ ld a, [rSVBK]
+ push af
+ ld a, $5
+ ld [rSVBK], a
+ ld a, [wcf64]
+ and $1
+ jr z, .asm_e5548
+ ld hl, LYOverrides
+ ld a, [hl]
+ inc a
+ ld bc, $5f
+ call ByteFill
+.asm_e5548
+ ld hl, LYOverrides + $5f
+ ld a, [hl]
+rept 2
+ inc a
+endr
+ ld bc, $31
+ call ByteFill
+ ld a, [LYOverrides + 0]
+ ld [hSCX], a
+ pop af
+ ld [rSVBK], a
+ ret
+
+IntroSuicuneRunGFX: ; e555d
+INCBIN "gfx/intro/suicune_run.2bpp.lz"
+; e592d
+
+IntroPichuWooperGFX: ; e592d
+INCBIN "gfx/intro/pichu_wooper.2bpp.lz"
+; e5c7d
+
+IntroBackgroundGFX: ; e5c7d
+INCBIN "gfx/intro/background.2bpp.lz"
+; e5e6d
+
+IntroTilemap004: ; e5e6d
+INCBIN "gfx/intro/004.tilemap.lz"
+; e5ecd
+
+IntroTilemap003: ; e5ecd
+INCBIN "gfx/intro/003.tilemap.lz"
+; e5edd
+
+Palette_e5edd: ; e5edd
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 0, 4, 5
+ RGB 1, 8, 5
+ RGB 4, 12, 9
+ RGB 24, 12, 9
+ RGB 0, 4, 5
+ RGB 9, 6, 8
+ RGB 8, 16, 5
+ RGB 5, 10, 4
+ RGB 31, 31, 31
+ RGB 9, 6, 8
+ RGB 18, 9, 9
+ RGB 13, 8, 9
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 2, 5, 22
+ RGB 1, 5, 12
+ RGB 31, 31, 31
+ RGB 31, 10, 25
+ RGB 31, 21, 0
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 21, 31
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+
+IntroUnownsGFX: ; e5f5d
+INCBIN "gfx/intro/unowns.2bpp.lz"
+; e634d
+
+IntroPulseGFX: ; e634d
+INCBIN "gfx/intro/pulse.2bpp.lz"
+; e63dd
+
+IntroTilemap002: ; e63dd
+INCBIN "gfx/intro/002.tilemap.lz"
+; e641d
+
+IntroTilemap001: ; e641d
+INCBIN "gfx/intro/001.tilemap.lz"
+; e642d
+
+IntroTilemap006: ; e642d
+INCBIN "gfx/intro/006.tilemap.lz"
+; e647d
+
+IntroTilemap005: ; e647d
+INCBIN "gfx/intro/005.tilemap.lz"
+; e649d
+
+IntroTilemap008: ; e649d
+INCBIN "gfx/intro/008.tilemap.lz"
+; e655d
+
+IntroTilemap007: ; e655d
+INCBIN "gfx/intro/007.tilemap.lz"
+; e65ad
+
+Palette_365ad: ; e65ad
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 10, 0, 10
+ RGB 19, 0, 19
+ RGB 31, 0, 31
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+
+IntroCrystalUnownsGFX: ; e662d
+INCBIN "gfx/intro/crystal_unowns.2bpp.lz"
+; e672d
+
+IntroTilemap017: ; e672d
+INCBIN "gfx/intro/017.tilemap.lz"
+; e676d
+
+IntroTilemap015: ; e676d
+INCBIN "gfx/intro/015.tilemap.lz"
+; e679d
+
+Palette_e679d: ; e679d
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+
+IntroSuicuneCloseGFX: ; e681d
+INCBIN "gfx/intro/suicune_close.2bpp.lz"
+; e6c3d
+
+IntroTilemap012: ; e6c3d
+INCBIN "gfx/intro/012.tilemap.lz"
+; e6d0d
+
+IntroTilemap011: ; e6d0d
+INCBIN "gfx/intro/011.tilemap.lz"
+; e6d6d
+
+Palette_e6d6d: ; e6d6d
+ RGB 24, 12, 9
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 24, 12, 9
+ RGB 31, 31, 31
+ RGB 8, 9, 31
+ RGB 0, 0, 0
+ RGB 24, 12, 9
+ RGB 12, 20, 31
+ RGB 19, 8, 31
+ RGB 0, 0, 0
+ RGB 12, 20, 31
+ RGB 8, 9, 31
+ RGB 19, 8, 31
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 12, 20, 31
+ RGB 8, 9, 31
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+
+IntroSuicuneJumpGFX: ; e6ded
+INCBIN "gfx/intro/suicune_jump.2bpp.lz"
+; e72ad
+
+IntroSuicuneBackGFX: ; e72ad
+INCBIN "gfx/intro/suicune_back.2bpp.lz"
+; e764d
+
+IntroTilemap010: ; e764d
+INCBIN "gfx/intro/010.tilemap.lz"
+; e76ad
+
+IntroTilemap009: ; e76ad
+INCBIN "gfx/intro/009.tilemap.lz"
+; e76bd
+
+IntroTilemap014: ; e76bd
+INCBIN "gfx/intro/014.tilemap.lz"
+; e778d
+
+IntroTilemap013: ; e778d
+INCBIN "gfx/intro/013.tilemap.lz"
+; e77dd
+
+Palette_e77dd: ; e77dd
+ RGB 24, 12, 9
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 24, 12, 9
+ RGB 31, 31, 31
+ RGB 8, 9, 31
+ RGB 0, 0, 0
+ RGB 24, 12, 9
+ RGB 24, 12, 9
+ RGB 24, 12, 9
+ RGB 24, 12, 9
+ RGB 24, 12, 9
+ RGB 24, 12, 9
+ RGB 24, 12, 9
+ RGB 24, 12, 9
+ RGB 24, 12, 9
+ RGB 24, 12, 9
+ RGB 24, 12, 9
+ RGB 24, 12, 9
+ RGB 24, 12, 9
+ RGB 24, 12, 9
+ RGB 24, 12, 9
+ RGB 24, 12, 9
+ RGB 24, 12, 9
+ RGB 24, 12, 9
+ RGB 24, 12, 9
+ RGB 24, 12, 9
+ RGB 24, 12, 9
+ RGB 24, 12, 9
+ RGB 24, 12, 9
+ RGB 24, 12, 9
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 12, 0, 31
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 21, 9, 0
+ RGB 21, 9, 0
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 20, 20, 20
+ RGB 11, 11, 11
+ RGB 0, 0, 0
+
+IntroUnownBackGFX: ; e785d
+INCBIN "gfx/intro/unown_back.2bpp.lz"
+; e799d
+
+GFX_e799d: ; e799d
+INCBIN "gfx/unknown/0e799d.2bpp"
+GFX_e79dd: ; e79dd
+INCBIN "gfx/unknown/0e79dd.2bpp"
+GFX_e7a1d: ; e7a1d
+INCBIN "gfx/unknown/0e7a1d.2bpp"
+
+GFX_e7a5d: ; e7a5d
+INCBIN "gfx/unknown/0e7a5d.2bpp"
+
+
--- /dev/null
+++ b/engine/debug.asm
@@ -1,0 +1,1517 @@
+ColorTest: ; 818ac
+; A debug menu to test monster and trainer palettes at runtime.
+
+ ld a, [hCGB]
+ and a
+ jr nz, .asm_818b5
+ ld a, [hSGB]
+ and a
+ ret z
+
+.asm_818b5
+ ld a, [hInMenu]
+ push af
+ ld a, $1
+ ld [hInMenu], a
+ call DisableLCD
+ call Function81948
+ call Function8197c
+ call Function819a7
+ call Function818f4
+ call EnableLCD
+ ld de, MUSIC_NONE
+ call PlayMusic
+ xor a
+ ld [wJumptableIndex], a
+ ld [wcf66], a
+ ld [wd003], a
+.asm_818de
+ ld a, [wJumptableIndex]
+ bit 7, a
+ jr nz, .asm_818f0
+ call Function81a74
+ call Function81f5e
+ call DelayFrame
+ jr .asm_818de
+
+.asm_818f0
+ pop af
+ ld [hInMenu], a
+ ret
+; 818f4
+
+Function818f4: ; 818f4
+ ld a, [wd002]
+ and a
+ jr nz, Function81911
+ ld hl, PokemonPalettes
+
+Function818fd: ; 818fd
+ ld de, OverworldMap
+ ld c, NUM_POKEMON + 1
+.asm_81902
+ push bc
+ push hl
+ call Function81928
+ pop hl
+ ld bc, 8
+ add hl, bc
+ pop bc
+ dec c
+ jr nz, .asm_81902
+ ret
+
+Function81911: ; 81911
+ ld hl, TrainerPalettes
+ ld de, OverworldMap
+ ld c, NUM_TRAINER_CLASSES
+.asm_81919
+ push bc
+ push hl
+ call Function81928
+ pop hl
+ ld bc, 4
+ add hl, bc
+ pop bc
+ dec c
+ jr nz, .asm_81919
+ ret
+; 81928
+
+Function81928: ; 81928
+ ld a, BANK(PokemonPalettes) ; BANK(TrainerPalettes)
+ call GetFarByte
+ ld [de], a
+ inc de
+ inc hl
+ ld a, BANK(PokemonPalettes) ; BANK(TrainerPalettes)
+ call GetFarByte
+ ld [de], a
+ inc de
+ inc hl
+ ld a, BANK(PokemonPalettes) ; BANK(TrainerPalettes)
+ call GetFarByte
+ ld [de], a
+ inc de
+ inc hl
+ ld a, BANK(PokemonPalettes) ; BANK(TrainerPalettes)
+ call GetFarByte
+ ld [de], a
+ inc de
+ ret
+; 81948
+
+Function81948: ; 81948
+ ld a, $1
+ ld [rVBK], a
+ ld hl, VTiles0
+ ld bc, sScratch - VTiles0
+ xor a
+ call ByteFill
+ ld a, $0
+ ld [rVBK], a
+ ld hl, VTiles0
+ ld bc, sScratch - VTiles0
+ xor a
+ call ByteFill
+ hlcoord 0, 0, AttrMap
+ ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
+ xor a
+ call ByteFill
+ hlcoord 0, 0
+ ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
+ xor a
+ call ByteFill
+ call ClearSprites
+ ret
+; 8197c
+
+Function8197c: ; 8197c
+ ld hl, DebugColorTestGFX + $10
+ ld de, VTiles2 tile $6a
+ ld bc, $160
+ call CopyBytes
+ ld hl, DebugColorTestGFX
+ ld de, VTiles0
+ ld bc, $10
+ call CopyBytes
+ call LoadStandardFont
+ ld hl, VTiles1
+ lb bc, 8, 0
+.asm_8199d
+ ld a, [hl]
+ xor $ff
+ ld [hli], a
+ dec bc
+ ld a, c
+ or b
+ jr nz, .asm_8199d
+ ret
+; 819a7
+
+Function819a7: ; 819a7
+ ld a, [hCGB]
+ and a
+ ret z
+ ld a, [rSVBK]
+ push af
+ ld a, $5
+ ld [rSVBK], a
+ ld hl, Palette_819f4
+ ld de, BGPals
+ ld bc, $80
+ call CopyBytes
+ ld a, $80
+ ld [rBGPI], a
+ ld hl, Palette_819f4
+ ld c, $40
+ xor a
+.asm_819c8
+ ld [rBGPD], a
+ dec c
+ jr nz, .asm_819c8
+ ld a, $80
+ ld [rOBPI], a
+ ld hl, Palette_81a34
+ ld c, $40
+.asm_819d6
+ ld a, [hli]
+ ld [rOBPD], a
+ dec c
+ jr nz, .asm_819d6
+ ld a, $94
+ ld [wc608], a
+ ld a, $52
+ ld [wc608 + 1], a
+ ld a, $4a
+ ld [wc608 + 2], a
+ ld a, $29
+ ld [wc608 + 3], a
+ pop af
+ ld [rSVBK], a
+ ret
+; 819f4
+
+Palette_819f4: ; 819f4
+ ; white
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 00, 00, 00
+
+ ; red
+ RGB 31, 00, 00
+ RGB 31, 00, 00
+ RGB 31, 00, 00
+ RGB 00, 00, 00
+
+ ; green
+ RGB 00, 31, 00
+ RGB 00, 31, 00
+ RGB 00, 31, 00
+ RGB 00, 00, 00
+
+ ; blue
+ RGB 00, 00, 31
+ RGB 00, 00, 31
+ RGB 00, 00, 31
+ RGB 00, 00, 00
+
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 00, 00, 00
+
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 00, 00, 00
+
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 00, 00, 00
+
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 00, 00, 00
+
+Palette_81a34: ; 81a34
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 00, 00, 00
+
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 00, 00, 00
+
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 00, 00, 00
+
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 00, 00, 00
+
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+ RGB 00, 00, 00
+
+ ; red
+ RGB 31, 31, 31
+ RGB 31, 00, 00
+ RGB 31, 00, 00
+ RGB 00, 00, 00
+
+ ; green
+ RGB 31, 31, 31
+ RGB 00, 31, 00
+ RGB 00, 31, 00
+ RGB 00, 00, 00
+
+ ; blue
+ RGB 31, 31, 31
+ RGB 00, 00, 31
+ RGB 00, 00, 31
+ RGB 00, 00, 00
+; 81a74
+
+Function81a74: ; 81a74
+ call JoyTextDelay
+ ld a, [wJumptableIndex]
+ cp $4
+ jr nc, .asm_81a8b
+ ld hl, hJoyLast
+ ld a, [hl]
+ and SELECT
+ jr nz, .asm_81a9a
+ ld a, [hl]
+ and START
+ jr nz, .asm_81aab
+
+.asm_81a8b
+ ld a, [wJumptableIndex]
+ ld e, a
+ ld d, 0
+ ld hl, Jumptable_81acf
+rept 2
+ add hl, de
+endr
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp [hl]
+
+.asm_81a9a
+ call Function81eca
+ call Function81ac3
+ ld e, a
+ ld a, [wcf66]
+ inc a
+ cp e
+ jr c, .asm_81aba
+ xor a
+ jr .asm_81aba
+
+.asm_81aab
+ call Function81eca
+ ld a, [wcf66]
+ dec a
+ cp $ff
+ jr nz, .asm_81aba
+ call Function81ac3
+ dec a
+
+.asm_81aba
+ ld [wcf66], a
+ ld a, $0
+ ld [wJumptableIndex], a
+ ret
+; 81ac3
+
+Function81ac3: ; 81ac3
+; Looping back around the pic set.
+ ld a, [wd002]
+ and a
+ jr nz, .asm_81acc
+ ld a, NUM_POKEMON ; CELEBI
+ ret
+
+.asm_81acc
+ ld a, NUM_TRAINER_CLASSES - 1 ; MYSTICALMAN
+ ret
+; 81acf
+
+Jumptable_81acf: ; 81acf
+ dw Function81adb
+ dw Function81c18
+ dw Function81c33
+ dw Function81cc2
+ dw Function81d8e
+ dw Function81daf
+; 81adb
+
+Function81adb: ; 81adb
+ xor a
+ ld [hBGMapMode], a
+ hlcoord 0, 0
+ ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
+ ld a, $6f
+ call ByteFill
+ hlcoord 1, 3
+ lb bc, 7, 18
+ ld a, $6c
+ call Bank20_FillBoxWithByte
+ hlcoord 11, 0
+ lb bc, 2, 3
+ ld a, $6d
+ call Bank20_FillBoxWithByte
+ hlcoord 16, 0
+ lb bc, 2, 3
+ ld a, $6e
+ call Bank20_FillBoxWithByte
+ call Function81bc0
+ call Function81bf4
+ ld a, [wcf66]
+ inc a
+ ld [CurPartySpecies], a
+ ld [wd265], a
+ hlcoord 0, 1
+ ld de, wd265
+ lb bc, PRINTNUM_LEADINGZEROS | 1, 3
+ call PrintNum
+ ld a, [wd002]
+ and a
+ jr nz, .asm_81b7a
+ ld a, $1
+ ld [UnownLetter], a
+ call GetPokemonName
+ hlcoord 4, 1
+ call PlaceString
+ xor a
+ ld [wc2c6], a
+ hlcoord 12, 3
+ call _PrepMonFrontpic
+ ld de, VTiles2 tile $31
+ predef GetBackpic
+ ld a, $31
+ ld [hFillBox], a
+ hlcoord 2, 4
+ lb bc, 6, 6
+ predef FillBox
+ ld a, [wd003]
+ and a
+ jr z, .asm_81b66
+ ld de, String_81baf
+ jr .asm_81b69
+
+.asm_81b66
+ ld de, String_81bb4
+
+.asm_81b69
+ hlcoord 7, 17
+ call PlaceString
+ hlcoord 0, 17
+ ld de, String_81bb9
+ call PlaceString
+ jr .asm_81ba9
+
+.asm_81b7a
+ ld a, [wd265]
+ ld [TrainerClass], a
+ callab Function3957b
+ ld de, StringBuffer1
+ hlcoord 4, 1
+ call PlaceString
+ ld de, VTiles2
+ callab GetTrainerPic
+ xor a
+ ld [TempEnemyMonSpecies], a
+ ld [hFillBox], a
+ hlcoord 2, 3
+ lb bc, 7, 7
+ predef FillBox
+
+.asm_81ba9
+ ld a, $1
+ ld [wJumptableIndex], a
+ ret
+; 81baf
+
+String_81baf: db "レア", $6f, $6f, "@" ; rare (shiny)
+String_81bb4: db "ノーマル@" ; normal
+String_81bb9: db $7a, "きりかえ▶@" ; (A) switches
+; 81bc0
+
+Function81bc0: ; 81bc0
+ decoord 0, 11, AttrMap
+ hlcoord 2, 11
+ ld a, $1
+ call Function81bde
+ decoord 0, 13, AttrMap
+ hlcoord 2, 13
+ ld a, $2
+ call Function81bde
+ decoord 0, 15, AttrMap
+ hlcoord 2, 15
+ ld a, $3
+
+Function81bde: ; 81bde
+ push af
+ ld a, $6a
+ ld [hli], a
+ ld bc, $f
+ ld a, $6b
+ call ByteFill
+ ld l, e
+ ld h, d
+ pop af
+ ld bc, $28
+ call ByteFill
+ ret
+; 81bf4
+
+Function81bf4: ; 81bf4
+ ld a, [wcf66]
+ inc a
+ ld l, a
+ ld h, $0
+rept 2
+ add hl, hl
+endr
+ ld de, OverworldMap
+ add hl, de
+ ld de, wc608
+ ld bc, 4
+ call CopyBytes
+ xor a
+ ld [wcf64], a
+ ld [wcf65], a
+ ld de, wc608
+ call Function81ea5
+ ret
+; 81c18
+
+Function81c18: ; 81c18
+ ld a, [hCGB]
+ and a
+ jr z, .asm_81c2a
+ ld a, $2
+ ld [hBGMapMode], a
+ call DelayFrame
+ call DelayFrame
+ call DelayFrame
+
+.asm_81c2a
+ call WaitBGMap
+ ld a, $2
+ ld [wJumptableIndex], a
+ ret
+; 81c33
+
+Function81c33: ; 81c33
+ ld a, [hCGB]
+ and a
+ jr z, .asm_81c69
+ ld a, [rSVBK]
+ push af
+ ld a, $5
+ ld [rSVBK], a
+ ld hl, BGPals
+ ld de, wc608
+ ld c, $1
+ call Function81ee3
+ hlcoord 10, 2
+ ld de, wc608
+ call Function81ca7
+ hlcoord 15, 2
+ ld de, wc608 + 2
+ call Function81ca7
+ ld a, $1
+ ld [hCGBPalUpdate], a
+ ld a, $3
+ ld [wJumptableIndex], a
+ pop af
+ ld [rSVBK], a
+ ret
+
+.asm_81c69
+ ld hl, wcda9
+ ld a, $1
+ ld [hli], a
+ ld a, $ff
+ ld [hli], a
+ ld a, $7f
+ ld [hli], a
+ ld a, [wc608]
+ ld [hli], a
+ ld a, [wc608 + 1]
+ ld [hli], a
+ ld a, [wc608 + 2]
+ ld [hli], a
+ ld a, [wc608 + 3]
+ ld [hli], a
+ xor a
+rept 2
+ ld [hli], a
+endr
+ ld [hl], a
+ ld hl, wcda9
+ call Function81f0c
+ hlcoord 10, 2
+ ld de, wc608
+ call Function81ca7
+ hlcoord 15, 2
+ ld de, wc608 + 2
+ call Function81ca7
+ ld a, $3
+ ld [wJumptableIndex], a
+ ret
+; 81ca7
+
+Function81ca7: ; 81ca7
+rept 3
+ inc hl
+endr
+ ld a, [de]
+ call Function81cbc
+ ld a, [de]
+ swap a
+ call Function81cbc
+ inc de
+ ld a, [de]
+ call Function81cbc
+ ld a, [de]
+ swap a
+
+Function81cbc: ; 81cbc
+ and $f
+ add $70
+ ld [hld], a
+ ret
+; 81cc2
+
+Function81cc2: ; 81cc2
+ ld a, [hJoyLast]
+ and B_BUTTON
+ jr nz, .asm_81cdf
+ ld a, [hJoyLast]
+ and A_BUTTON
+ jr nz, .asm_81ce5
+ ld a, [wcf64]
+ and $3
+ ld e, a
+ ld d, 0
+ ld hl, Jumptable_81d02
+rept 2
+ add hl, de
+endr
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp [hl]
+
+.asm_81cdf
+ ld a, $4
+ ld [wJumptableIndex], a
+ ret
+
+.asm_81ce5
+ ld a, [wd002]
+ and a
+ ret nz
+ ld a, [wd003]
+ xor $4
+ ld [wd003], a
+ ld c, a
+ ld b, 0
+ ld hl, PokemonPalettes
+ add hl, bc
+ call Function818fd
+ ld a, $0
+ ld [wJumptableIndex], a
+ ret
+; 81d02
+
+Jumptable_81d02: ; 81d02
+ dw Function81d0a
+ dw Function81d34
+ dw Function81d46
+ dw Function81d58
+; 81d0a
+
+Function81d0a: ; 81d0a
+ ld hl, hJoyLast
+ ld a, [hl]
+ and D_DOWN
+ jr nz, Function81d89
+ ld a, [hl]
+ and D_LEFT
+ jr nz, .asm_81d1d
+ ld a, [hl]
+ and D_RIGHT
+ jr nz, .asm_81d28
+ ret
+
+.asm_81d1d
+ xor a
+ ld [wcf65], a
+ ld de, wc608
+ call Function81ea5
+ ret
+
+.asm_81d28
+ ld a, $1
+ ld [wcf65], a
+ ld de, wc608 + 2
+ call Function81ea5
+ ret
+
+Function81d34: ; 81d34
+ ld hl, hJoyLast
+ ld a, [hl]
+ and D_DOWN
+ jr nz, Function81d89
+ ld a, [hl]
+ and D_UP
+ jr nz, Function81d84
+ ld hl, wc608 + 10
+ jr Function81d63
+
+Function81d46: ; 81d46
+ ld hl, hJoyLast
+ ld a, [hl]
+ and D_DOWN
+ jr nz, Function81d89
+ ld a, [hl]
+ and D_UP
+ jr nz, Function81d84
+ ld hl, wc608 + 11
+ jr Function81d63
+
+Function81d58: ; 81d58
+ ld hl, hJoyLast
+ ld a, [hl]
+ and D_UP
+ jr nz, Function81d84
+ ld hl, wc608 + 12
+
+Function81d63: ; 81d63
+ ld a, [hJoyLast]
+ and D_RIGHT
+ jr nz, Function81d70
+ ld a, [hJoyLast]
+ and D_LEFT
+ jr nz, Function81d77
+ ret
+
+Function81d70: ; 81d70
+ ld a, [hl]
+ cp $1f
+ ret nc
+ inc [hl]
+ jr Function81d7b
+
+Function81d77: ; 81d77
+ ld a, [hl]
+ and a
+ ret z
+ dec [hl]
+
+Function81d7b: ; 81d7b
+ call Function81e67
+ ld a, $2
+ ld [wJumptableIndex], a
+ ret
+
+Function81d84: ; 81d84
+ ld hl, wcf64
+ dec [hl]
+ ret
+
+Function81d89: ; 81d89
+ ld hl, wcf64
+ inc [hl]
+ ret
+; 81d8e
+
+Function81d8e: ; 81d8e
+ hlcoord 0, 10
+ ld bc, $a0
+ ld a, $6f
+ call ByteFill
+ hlcoord 2, 12
+ ld de, String_81fcd
+ call PlaceString
+ xor a
+ ld [wd004], a
+ call Function81df4
+ ld a, $5
+ ld [wJumptableIndex], a
+ ret
+; 81daf
+
+Function81daf: ; 81daf
+ ld hl, hJoyPressed
+ ld a, [hl]
+ and B_BUTTON
+ jr nz, .asm_81dbb
+ call Function81dc7
+ ret
+
+.asm_81dbb
+ ld a, $0
+ ld [wJumptableIndex], a
+ ret
+; 81dc1
+
+Function81dc1: ; 81dc1
+ ld hl, wJumptableIndex
+ set 7, [hl]
+ ret
+; 81dc7
+
+Function81dc7: ; 81dc7
+ ld hl, hJoyLast
+ ld a, [hl]
+ and D_UP
+ jr nz, .asm_81dd5
+ ld a, [hl]
+ and D_DOWN
+ jr nz, .asm_81de2
+ ret
+
+.asm_81dd5
+ ld a, [wd004]
+ cp $3b
+ jr z, .asm_81ddf
+ inc a
+ jr .asm_81ded
+
+.asm_81ddf
+ xor a
+ jr .asm_81ded
+
+.asm_81de2
+ ld a, [wd004]
+ and a
+ jr z, .asm_81deb
+ dec a
+ jr .asm_81ded
+
+.asm_81deb
+ ld a, $3b
+
+.asm_81ded
+ ld [wd004], a
+ call Function81df4
+ ret
+; 81df4
+
+Function81df4: ; 81df4
+ hlcoord 10, 11
+ call Function81e5e
+ hlcoord 10, 12
+ call Function81e5e
+ hlcoord 10, 13
+ call Function81e5e
+ hlcoord 10, 14
+ call Function81e5e
+ ld a, [wd004]
+ inc a
+ ld [wd265], a
+ predef GetTMHMMove
+ ld a, [wd265]
+ ld [wd262], a
+ call GetMoveName
+ hlcoord 10, 12
+ call PlaceString
+ ld a, [wd004]
+ call Function81e55
+ ld [CurItem], a
+ predef CanLearnTMHMMove
+ ld a, c
+ and a
+ ld de, String_81e46
+ jr nz, .asm_81e3f
+ ld de, String_81e4d
+
+.asm_81e3f
+ hlcoord 10, 14
+ call PlaceString
+ ret
+; 81e46
+
+String_81e46: db "おぼえられる@" ; can be taught
+String_81e4d: db "おぼえられない@" ; cannot be taught
+; 81e55
+
+Function81e55: ; 81e55
+ cp $32
+ jr c, .asm_81e5b
+rept 2
+ inc a
+endr
+
+.asm_81e5b
+ add $bf
+ ret
+; 81e5e
+
+Function81e5e: ; 81e5e
+ ld bc, $a
+ ld a, $6f
+ call ByteFill
+ ret
+; 81e67
+
+Function81e67: ; 81e67
+ ld a, [wc608 + 10]
+ and $1f
+ ld e, a
+ ld a, [wc608 + 11]
+ and $7
+ sla a
+ swap a
+ or e
+ ld e, a
+ ld a, [wc608 + 11]
+ and $18
+ sla a
+ swap a
+ ld d, a
+ ld a, [wc608 + 12]
+ and $1f
+ sla a
+ sla a
+ or d
+ ld d, a
+ ld a, [wcf65]
+ and a
+ jr z, .asm_81e9c
+ ld a, e
+ ld [wc608 + 2], a
+ ld a, d
+ ld [wc608 + 3], a
+ ret
+
+.asm_81e9c
+ ld a, e
+ ld [wc608], a
+ ld a, d
+ ld [wc608 + 1], a
+ ret
+; 81ea5
+
+Function81ea5: ; 81ea5
+ ld a, [de]
+ and $1f
+ ld [wc608 + 10], a
+ ld a, [de]
+ and $e0
+ swap a
+ srl a
+ ld b, a
+ inc de
+ ld a, [de]
+ and $3
+ swap a
+ srl a
+ or b
+ ld [wc608 + 11], a
+ ld a, [de]
+ and $7c
+ srl a
+ srl a
+ ld [wc608 + 12], a
+ ret
+; 81eca
+
+Function81eca: ; 81eca
+ ld a, [wcf66]
+ inc a
+ ld l, a
+ ld h, $0
+rept 2
+ add hl, hl
+endr
+ ld de, OverworldMap
+ add hl, de
+ ld e, l
+ ld d, h
+ ld hl, wc608
+ ld bc, 4
+ call CopyBytes
+ ret
+; 81ee3
+
+Function81ee3: ; 81ee3
+.asm_81ee3
+ ld a, $ff
+ ld [hli], a
+ ld a, $7f
+ 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
+ ld a, [de]
+ inc de
+ ld [hli], a
+ xor a
+rept 2
+ ld [hli], a
+endr
+ dec c
+ jr nz, .asm_81ee3
+ ret
+; 81efc
+
+Bank20_FillBoxWithByte: ; 81efc
+; For some reason, we have another copy of FillBoxWithByte here
+.row
+ push bc
+ push hl
+.col
+ ld [hli], a
+ dec c
+ jr nz, .col
+ pop hl
+ ld bc, SCREEN_WIDTH
+ add hl, bc
+ pop bc
+ dec b
+ jr nz, .row
+ ret
+; 81f0c
+
+Function81f0c: ; 81f0c
+ ld a, [wcfbe]
+ push af
+ set 7, a
+ ld [wcfbe], a
+ call Function81f1d
+ pop af
+ ld [wcfbe], a
+ ret
+; 81f1d
+
+Function81f1d: ; 81f1d
+ ld a, [hl]
+ and $7
+ ret z
+ ld b, a
+.asm_81f22
+ push bc
+ xor a
+ ld [rJOYP], a
+ ld a, $30
+ ld [rJOYP], a
+ ld b, $10
+.asm_81f2c
+ ld e, $8
+ ld a, [hli]
+ ld d, a
+.asm_81f30
+ bit 0, d
+ ld a, $10
+ jr nz, .asm_81f38
+ ld a, $20
+
+.asm_81f38
+ ld [rJOYP], a
+ ld a, $30
+ ld [rJOYP], a
+ rr d
+ dec e
+ jr nz, .asm_81f30
+ dec b
+ jr nz, .asm_81f2c
+ ld a, $20
+ ld [rJOYP], a
+ ld a, $30
+ ld [rJOYP], a
+ ld de, 7000
+.asm_81f51
+ nop
+ nop
+ nop
+ dec de
+ ld a, d
+ or e
+ jr nz, .asm_81f51
+ pop bc
+ dec b
+ jr nz, .asm_81f22
+ ret
+; 81f5e
+
+Function81f5e: ; 81f5e
+ ld a, $6f
+ hlcoord 10, 0
+ ld [hl], a
+ hlcoord 15, 0
+ ld [hl], a
+ hlcoord 1, 11
+ ld [hl], a
+ hlcoord 1, 13
+ ld [hl], a
+ hlcoord 1, 15
+ ld [hl], a
+ ld a, [wJumptableIndex]
+ cp $3
+ jr nz, .asm_81fc9
+ ld a, [wcf64]
+ and a
+ jr z, .asm_81f8d
+ dec a
+ hlcoord 1, 11
+ ld bc, 2 * SCREEN_WIDTH
+ call AddNTimes
+ ld [hl], $ed
+
+.asm_81f8d
+ ld a, [wcf65]
+ and a
+ jr z, .asm_81f98
+ hlcoord 15, 0
+ jr .asm_81f9b
+
+.asm_81f98
+ hlcoord 10, 0
+
+.asm_81f9b
+ ld [hl], $ed
+ ld b, $70
+ ld c, $5
+ ld hl, Sprites
+ ld de, wc608 + 10
+ call .asm_81fb7
+ ld de, wc608 + 11
+ call .asm_81fb7
+ ld de, wc608 + 12
+ call .asm_81fb7
+ ret
+
+.asm_81fb7
+ ld a, b
+ ld [hli], a
+ ld a, [de]
+rept 2
+ add a
+endr
+ add $18
+ ld [hli], a
+ xor a
+ ld [hli], a
+ ld a, c
+ ld [hli], a
+ ld a, $10
+ add b
+ ld b, a
+ inc c
+ ret
+
+.asm_81fc9
+ call ClearSprites
+ ret
+; 81fcd
+
+String_81fcd: ; 81fcd
+ db "おわりますか?" ; Are you finished?
+ next "はい", $f2, $f2, $f2, $7a ; YES (A)
+ next "いいえ", $f2, $f2, $7b ; NO (B)
+ db "@"
+; 81fe3
+
+DebugColorTestGFX:
+INCBIN "gfx/debug/color_test.2bpp"
+
+
+TilesetColorTest:
+ ret
+ xor a
+ ld [wJumptableIndex], a
+ ld [wcf64], a
+ ld [wcf65], a
+ ld [wcf66], a
+ ld [hMapAnims], a
+ call ClearSprites
+ call OverworldTextModeSwitch
+ call Function3200
+ xor a
+ ld [hBGMapMode], a
+ ld de, DebugColorTestGFX + $10
+ ld hl, VTiles2 tile $6a
+ lb bc, BANK(DebugColorTestGFX), $16
+ call Request2bpp
+ ld de, DebugColorTestGFX
+ ld hl, VTiles1
+ lb bc, BANK(DebugColorTestGFX), 1
+ call Request2bpp
+ ld a, VBGMap1 / $100
+ ld [hBGMapAddress + 1], a
+ hlcoord 0, 0
+ ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
+ ld a, $6f
+ call ByteFill
+ hlcoord 0, 0, AttrMap
+ ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
+ ld a, $7
+ call ByteFill
+ ld de, $15
+ ld a, $6c
+ call Function821d2
+ ld de, $1a
+ ld a, $6d
+ call Function821d2
+ ld de, $1f
+ ld a, $6e
+ call Function821d2
+ ld de, $24
+ ld a, $6f
+ call Function821d2
+ call Function821f4
+ call Function8220f
+ call Function3200
+ ld [wJumptableIndex], a
+ ld a, $40
+ ld [hWY], a
+ ret
+; 821d2
+
+Function821d2: ; 821d2
+ hlcoord 0, 0
+ call Function821de
+
+Function821d8: ; 821d8
+ ld a, [wcf64]
+ hlcoord 0, 0, AttrMap
+
+Function821de: ; 821de
+ add hl, de
+rept 4
+ ld [hli], a
+endr
+ ld bc, $10
+ add hl, bc
+rept 4
+ ld [hli], a
+endr
+ ld bc, $10
+ add hl, bc
+rept 4
+ ld [hli], a
+endr
+ ret
+; 821f4
+
+Function821f4: ; 821f4
+ hlcoord 2, 4
+ call Function82203
+ hlcoord 2, 6
+ call Function82203
+ hlcoord 2, 8
+
+Function82203: ; 82203
+ ld a, $6a
+ ld [hli], a
+ ld bc, $10 - 1
+ ld a, $6b
+ call ByteFill
+ ret
+; 8220f
+
+Function8220f: ; 8220f
+ ld a, [rSVBK]
+ push af
+ ld a, $5
+ ld [rSVBK], a
+ ld a, [wcf64]
+ ld l, a
+ ld h, $0
+rept 3
+ add hl, hl
+endr
+ ld de, wMapPals
+ add hl, de
+ ld de, wc608
+ ld bc, 8
+ call CopyBytes
+ ld de, wc608
+ call Function81ea5
+ pop af
+ ld [rSVBK], a
+ ret
+; 82236
+
+
+Function82236: ; 82236
+ ld hl, hJoyLast
+ ld a, [hl]
+ and SELECT
+ jr nz, .loop7
+ ld a, [hl]
+ and B_BUTTON
+ jr nz, .asm_82299
+ call Function822f0
+ ret
+
+.loop7
+ ld hl, wcf64
+ ld a, [hl]
+ inc a
+ and $7
+ cp $7
+ jr nz, .asm_82253
+ xor a
+
+.asm_82253
+ ld [hl], a
+ ld de, $15
+ call Function821d8
+ ld de, $1a
+ call Function821d8
+ ld de, $1f
+ call Function821d8
+ ld de, $24
+ call Function821d8
+ ld a, [rSVBK]
+ push af
+ ld a, $5
+ ld [rSVBK], a
+ ld hl, BGPals
+ ld a, [wcf64]
+ ld bc, 8
+ call AddNTimes
+ ld de, wc608
+ ld bc, 8
+ call CopyBytes
+ pop af
+ ld [rSVBK], a
+ ld a, $2
+ ld [hBGMapMode], a
+ ld c, 3
+ call DelayFrames
+ ld a, $1
+ ld [hBGMapMode], a
+ ret
+
+.asm_82299
+ call ClearSprites
+ ld a, [hWY]
+ xor $d0
+ ld [hWY], a
+ ret
+; 822a3
+
+Function822a3: ; 822a3
+ ld a, [rSVBK]
+ push af
+ ld a, $5
+ ld [rSVBK], a
+ ld hl, BGPals
+ ld a, [wcf64]
+ ld bc, 8
+ call AddNTimes
+ ld e, l
+ ld d, h
+ ld hl, wc608
+ ld bc, 8
+ call CopyBytes
+ hlcoord 1, 0
+ ld de, wc608
+ call Function81ca7
+ hlcoord 6, 0
+ ld de, wc608 + 2
+ call Function81ca7
+ hlcoord 11, 0
+ ld de, wc608 + 4
+ call Function81ca7
+ hlcoord 16, 0
+ ld de, wc608 + 6
+ call Function81ca7
+ pop af
+ ld [rSVBK], a
+ ld a, $1
+ ld [hCGBPalUpdate], a
+ call DelayFrame
+ ret
+; 822f0
+
+Function822f0: ; 822f0
+ ld a, [wcf65]
+ and 3
+ ld e, a
+ ld d, 0
+ ld hl, .jumptable
+rept 2
+ add hl, de
+endr
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp [hl]
+; 82301
+
+.jumptable: ; 82301
+ dw Function82309
+ dw Function82339
+ dw Function8234b
+ dw Function8235d
+; 82309
+
+Function82309: ; 82309
+ ld hl, hJoyLast
+ ld a, [hl]
+ and D_DOWN
+ jr nz, Function8238c
+ ld a, [hl]
+ and D_LEFT
+ jr nz, .asm_8231c
+ ld a, [hl]
+ and D_RIGHT
+ jr nz, .asm_82322
+ ret
+
+.asm_8231c
+ ld a, [wcf66]
+ dec a
+ jr .asm_82326
+
+.asm_82322
+ ld a, [wcf66]
+ inc a
+
+.asm_82326
+ and $3
+ ld [wcf66], a
+ ld e, a
+ ld d, $0
+ ld hl, wc608
+rept 2
+ add hl, de
+endr
+ ld e, l
+ ld d, h
+ call Function81ea5
+ ret
+
+Function82339: ; 82338
+ ld hl, hJoyLast
+ ld a, [hl]
+ and D_DOWN
+ jr nz, Function8238c
+ ld a, [hl]
+ and D_UP
+ jr nz, Function82387
+ ld hl, wc608 + 10
+ jr Function82368
+
+Function8234b: ; 8234b
+ ld hl, hJoyLast
+ ld a, [hl]
+ and D_DOWN
+ jr nz, Function8238c
+ ld a, [hl]
+ and D_UP
+ jr nz, Function82387
+ ld hl, wc608 + 11
+ jr Function82368
+
+Function8235d: ; 8235d
+ ld hl, hJoyLast
+ ld a, [hl]
+ and D_UP
+ jr nz, Function82387
+ ld hl, wc608 + 12
+
+Function82368: ; 82368
+ ld a, [hJoyLast]
+ and D_RIGHT
+ jr nz, .asm_82375
+ ld a, [hJoyLast]
+ and D_LEFT
+ jr nz, .asm_8237c
+ ret
+
+.asm_82375
+ ld a, [hl]
+ cp $1f
+ ret nc
+ inc [hl]
+ jr .asm_82380
+
+.asm_8237c
+ ld a, [hl]
+ and a
+ ret z
+ dec [hl]
+
+.asm_82380
+ call Function82391
+ call Function822a3
+ ret
+
+Function82387: ; 82387
+ ld hl, wcf65
+ dec [hl]
+ ret
+
+Function8238c: ; 8238c
+ ld hl, wcf65
+ inc [hl]
+ ret
+; 82391
+
+Function82391: ; 82391
+ ld a, [wc608 + 10]
+ and $1f
+ ld e, a
+ ld a, [wc608 + 11]
+ and $7
+ sla a
+ swap a
+ or e
+ ld e, a
+ ld a, [wc608 + 11]
+ and $18
+ sla a
+ swap a
+ ld d, a
+ ld a, [wc608 + 12]
+ and $1f
+ sla a
+ sla a
+ or d
+ ld d, a
+ ld a, [wcf66]
+ ld c, a
+ ld b, $0
+ ld hl, wc608
+rept 2
+ add hl, bc
+endr
+ ld a, e
+ ld [hli], a
+ ld [hl], d
+ ret
+; 823c6
+
+Function823c6: ; 823c6
+ ret
+
+Function823c7: ; 823c7
+ ret
+; 823c8
--- a/engine/engine_flags.asm
+++ b/engine/engine_flags.asm
@@ -1,3 +1,90 @@
+EngineFlagAction:: ; 80430
+; Do action b on engine flag de
+;
+; b = 0: reset flag
+; = 1: set flag
+; > 1: check flag, result in c
+;
+; Setting/resetting does not return a result.
+
+
+; 16-bit flag ids are considered invalid, but it's nice
+; to know that the infrastructure is there.
+
+ ld a, d
+ cp 0
+ jr z, .ceiling
+ jr c, .read ; cp 0 can't set carry!
+ jr .invalid
+
+; There are only $a2 engine flags, so
+; anything beyond that is invalid too.
+
+.ceiling
+ ld a, e
+ cp NUM_ENGINE_FLAGS
+ jr c, .read
+
+; Invalid flags are treated as flag 00.
+
+.invalid
+ xor a
+ ld e, a
+ ld d, a
+
+; Get this flag's location.
+
+.read
+ ld hl, EngineFlags
+; location
+rept 2
+ add hl, de
+endr
+; bit
+ add hl, de
+
+; location
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ inc hl
+; bit
+ ld c, [hl]
+
+; What are we doing with this flag?
+
+ ld a, b
+ cp 1
+ jr c, .reset ; b = 0
+ jr z, .set ; b = 1
+
+; Return the given flag in c.
+.check
+ ld a, [de]
+ and c
+ ld c, a
+ ret
+
+; Set the given flag.
+.set
+ ld a, [de]
+ or c
+ ld [de], a
+ ret
+
+; Reset the given flag.
+.reset
+ ld a, c
+ cpl ; AND all bits except the one in question
+ ld c, a
+ ld a, [de]
+ and c
+ ld [de], a
+ ret
+; 80462
+
+
+EngineFlags: ; 80462
; All locations are in WRAM bank 1.
engine_flag: MACRO
dwb \1, 1 << \2
--- /dev/null
+++ b/engine/npctrade.asm
@@ -1,0 +1,620 @@
+
+; Trade struct
+TRADE_DIALOG EQU 0
+TRADE_GIVEMON EQU 1
+TRADE_GETMON EQU 2
+TRADE_NICK EQU 3
+TRADE_DVS EQU 14
+TRADE_ITEM EQU 16
+TRADE_OT_ID EQU 17
+TRADE_OT_NAME EQU 19
+TRADE_GENDER EQU 30
+TRADE_PADDING EQU 31
+
+; Trade dialogs
+TRADE_INTRO EQU 0
+TRADE_CANCEL EQU 1
+TRADE_WRONG EQU 2
+TRADE_COMPLETE EQU 3
+TRADE_AFTER EQU 4
+
+NPCTrade:: ; fcba8
+ ld a, e
+ ld [wJumptableIndex], a
+ call Functionfcc59
+ ld b, CHECK_FLAG
+ call TradeFlagAction
+ ld a, TRADE_AFTER
+ jr nz, .done
+
+ ld a, TRADE_INTRO
+ call PrintTradeText
+
+ call YesNoBox
+ ld a, TRADE_CANCEL
+ jr c, .done
+
+; Select givemon from party
+ ld b, 6
+ callba Function5001d
+ ld a, TRADE_CANCEL
+ jr c, .done
+
+ ld e, TRADE_GIVEMON
+ call GetTradeAttribute
+ ld a, [CurPartySpecies]
+ cp [hl]
+ ld a, TRADE_WRONG
+ jr nz, .done
+
+ call CheckTradeGender
+ ld a, TRADE_WRONG
+ jr c, .done
+
+ ld b, SET_FLAG
+ call TradeFlagAction
+
+ ld hl, ConnectLinkCableText
+ call PrintText
+
+ call Functionfcc63
+ call Functionfcc07
+ call GetTradeMonNames
+
+ ld hl, TradedForText
+ call PrintText
+
+ call RestartMapMusic
+
+ ld a, TRADE_COMPLETE
+
+.done
+ call PrintTradeText
+ ret
+; fcc07
+
+Functionfcc07: ; fcc07
+ call DisableSpriteUpdates
+ ld a, [wJumptableIndex]
+ push af
+ ld a, [wcf64]
+ push af
+ predef Function28f24
+ pop af
+ ld [wcf64], a
+ pop af
+ ld [wJumptableIndex], a
+ call Function2b74
+ ret
+; fcc23
+
+CheckTradeGender: ; fcc23
+ xor a
+ ld [MonType], a
+
+ ld e, TRADE_GENDER
+ call GetTradeAttribute
+ ld a, [hl]
+ and a
+ jr z, .asm_fcc46
+ cp 1
+ jr z, .asm_fcc3e
+
+ callba GetGender
+ jr nz, .asm_fcc48
+ jr .asm_fcc46
+
+.asm_fcc3e
+ callba GetGender
+ jr z, .asm_fcc48
+
+.asm_fcc46
+ and a
+ ret
+
+.asm_fcc48
+ scf
+ ret
+; fcc4a
+
+TradeFlagAction: ; fcc4a
+ ld hl, wd960
+ ld a, [wJumptableIndex]
+ ld c, a
+ predef FlagPredef
+ ld a, c
+ and a
+ ret
+; fcc59
+
+Functionfcc59: ; fcc59
+ ld e, TRADE_DIALOG
+ call GetTradeAttribute
+ ld a, [hl]
+ ld [wcf64], a
+ ret
+; fcc63
+
+Functionfcc63: ; fcc63
+ ld e, TRADE_GIVEMON
+ call GetTradeAttribute
+ ld a, [hl]
+ ld [wc6d0], a
+
+ ld e, TRADE_GETMON
+ call GetTradeAttribute
+ ld a, [hl]
+ ld [wc702], a
+
+ ld a, [wc6d0]
+ ld de, wc6d1
+ call Functionfcde8
+ call Functionfcdf4
+
+ ld a, [wc702]
+ ld de, wc703
+ call Functionfcde8
+ call Functionfcdf4
+
+ ld hl, PartyMonOT
+ ld bc, NAME_LENGTH
+ call Functionfcdd7
+ ld de, wc6f2
+ call Functionfcdf4
+
+ ld hl, PlayerName
+ ld de, wc6e7
+ call Functionfcdf4
+
+ ld hl, PartyMon1ID
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call Functionfcdd7
+ ld de, wc6ff
+ call Functionfce0f
+
+ ld hl, PartyMon1DVs
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call Functionfcdd7
+ ld de, wc6fd
+ call Functionfce0f
+
+ ld hl, PartyMon1Species
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call Functionfcdd7
+ ld b, h
+ ld c, l
+ callba GetCaughtGender
+ ld a, c
+ ld [wc701], a
+
+ ld e, TRADE_DIALOG
+ call GetTradeAttribute
+ ld a, [hl]
+ cp TRADE_COMPLETE
+ ld a, 1
+ jr c, .asm_fcce6
+ ld a, 2
+.asm_fcce6
+ ld [wEnemyCharging], a
+
+ ld hl, PartyMon1Level
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call Functionfcdd7
+ ld a, [hl]
+ ld [CurPartyLevel], a
+ ld a, [wc702]
+ ld [CurPartySpecies], a
+ xor a
+ ld [MonType], a
+ ld [wPokemonWithdrawDepositParameter], a
+ callab Functione039
+ predef TryAddMonToParty
+
+ ld e, TRADE_DIALOG
+ call GetTradeAttribute
+ ld a, [hl]
+ cp TRADE_COMPLETE
+ ld b, 0
+ jr c, .asm_fcd1c
+ ld b, 1
+.asm_fcd1c
+ callba SetGiftPartyMonCaughtData
+
+ ld e, TRADE_NICK
+ call GetTradeAttribute
+ ld de, wc70e
+ call Functionfcdf4
+
+ ld hl, PartyMonNicknames
+ ld bc, PKMN_NAME_LENGTH
+ call Functionfcdde
+ ld hl, wc70e
+ call Functionfcdf4
+
+ ld e, TRADE_OT_NAME
+ call GetTradeAttribute
+ push hl
+ ld de, wc724
+ call Functionfcdf4
+ pop hl
+ ld de, wc719
+ call Functionfcdf4
+
+ ld hl, PartyMonOT
+ ld bc, NAME_LENGTH
+ call Functionfcdde
+ ld hl, wc724
+ call Functionfcdf4
+
+ ld e, TRADE_DVS
+ call GetTradeAttribute
+ ld de, wEnemyTrappingMove
+ call Functionfce0f
+
+ ld hl, PartyMon1DVs
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call Functionfcdde
+ ld hl, wEnemyTrappingMove
+ call Functionfce0f
+
+ ld e, TRADE_OT_ID
+ call GetTradeAttribute
+ ld de, wPlayerCharging
+ call Functionfce15
+
+ ld hl, PartyMon1ID
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call Functionfcdde
+ ld hl, wEnemyWrapCount
+ call Functionfce0f
+
+ ld e, TRADE_ITEM
+ call GetTradeAttribute
+ push hl
+ ld hl, PartyMon1Item
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call Functionfcdde
+ pop hl
+ ld a, [hl]
+ ld [de], a
+
+ push af
+ push bc
+ push de
+ push hl
+ ld a, [CurPartyMon]
+ push af
+ ld a, [PartyCount]
+ dec a
+ ld [CurPartyMon], a
+ callba Functione134
+ pop af
+ ld [CurPartyMon], a
+ pop hl
+ pop de
+ pop bc
+ pop af
+ ret
+; fcdc2
+
+
+GetTradeAttribute: ; 0xfcdc2
+ ld d, 0
+ push de
+ ld a, [wJumptableIndex]
+ and $f
+ swap a
+ ld e, a
+ ld d, 0
+ ld hl, NPCTrades
+rept 2
+ add hl, de
+endr
+ pop de
+ add hl, de
+ ret
+; 0xfcdd7
+
+Functionfcdd7: ; fcdd7
+ ld a, [CurPartyMon]
+ call AddNTimes
+ ret
+; fcdde
+
+Functionfcdde: ; fcdde
+ ld a, [PartyCount]
+ dec a
+ call AddNTimes
+ ld e, l
+ ld d, h
+ ret
+; fcde8
+
+Functionfcde8: ; fcde8
+ push de
+ ld [wd265], a
+ call GetBasePokemonName
+ ld hl, StringBuffer1
+ pop de
+ ret
+; fcdf4
+
+Functionfcdf4: ; fcdf4
+ ld bc, NAME_LENGTH
+ call CopyBytes
+ ret
+; fcdfb
+
+Functionfcdfb: ; fcdfb
+ ld bc, 4
+ call CopyBytes
+ ld a, $50
+ ld [de], a
+ ret
+; fce05
+
+Functionfce05: ; fce05
+ ld bc, 3
+ call CopyBytes
+ ld a, $50
+ ld [de], a
+ ret
+; fce0f
+
+Functionfce0f: ; fce0f
+ ld a, [hli]
+ ld [de], a
+ inc de
+ ld a, [hl]
+ ld [de], a
+ ret
+; fce15
+
+Functionfce15: ; fce15
+ ld a, [hli]
+ ld [de], a
+ dec de
+ ld a, [hl]
+ ld [de], a
+ ret
+; fce1b
+
+GetTradeMonNames: ; fce1b
+ ld e, TRADE_GETMON
+ call GetTradeAttribute
+ ld a, [hl]
+ call Functionfcde8
+
+ ld de, StringBuffer2
+ call Functionfcdf4
+
+ ld e, TRADE_GIVEMON
+ call GetTradeAttribute
+ ld a, [hl]
+ call Functionfcde8
+
+ ld de, wd050
+ call Functionfcdf4
+
+ ld hl, StringBuffer1
+.loop
+ ld a, [hli]
+ cp "@"
+ jr nz, .loop
+
+ dec hl
+ push hl
+ ld e, TRADE_GENDER
+ call GetTradeAttribute
+ ld a, [hl]
+ pop hl
+ and a
+ ret z
+
+ cp 1
+ ld a, "♂"
+ jr z, .done
+ ld a, "♀"
+.done
+ ld [hli], a
+ ld [hl], "@"
+ ret
+; fce58
+
+
+NPCTrades: ; fce58
+ db 0, ABRA, MACHOP, "MUSCLE@@@@@", $37, $66, GOLD_BERRY, $54, $92, "MIKE@@@@@@@", 0, 0
+ db 0, BELLSPROUT, ONIX, "ROCKY@@@@@@", $96, $66, BITTER_BERRY, $1e, $bf, "KYLE@@@@@@@", 0, 0
+ db 1, KRABBY, VOLTORB, "VOLTY@@@@@@", $98, $88, PRZCUREBERRY, $05, $72, "TIM@@@@@@@@", 0, 0
+ db 3, DRAGONAIR, DODRIO, "DORIS@@@@@@", $77, $66, SMOKE_BALL, $1b, $01, "EMY@@@@@@@@", 2, 0
+ db 2, HAUNTER, XATU, "PAUL@@@@@@@", $96, $86, MYSTERYBERRY, $00, $3d, "CHRIS@@@@@@", 0, 0
+ db 3, CHANSEY, AERODACTYL, "AEROY@@@@@@", $96, $66, GOLD_BERRY, $7b, $67, "KIM@@@@@@@@", 0, 0
+ db 0, DUGTRIO, MAGNETON, "MAGGIE@@@@@", $96, $66, METAL_COAT, $a2, $c3, "FOREST@@@@@", 0, 0
+; fcf38
+
+
+PrintTradeText: ; fcf38
+ push af
+ call GetTradeMonNames
+ pop af
+ ld bc, 2 * 4
+ ld hl, TradeTexts
+ call AddNTimes
+ ld a, [wcf64]
+ ld c, a
+rept 2
+ add hl, bc
+endr
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ call PrintText
+ ret
+; fcf53
+
+TradeTexts: ; fcf53
+; intro
+ dw TradeIntroText1
+ dw TradeIntroText2
+ dw TradeIntroText3
+ dw TradeIntroText4
+
+; cancel
+ dw TradeCancelText1
+ dw TradeCancelText2
+ dw TradeCancelText3
+ dw TradeCancelText4
+
+; wrong mon
+ dw TradeWrongText1
+ dw TradeWrongText2
+ dw TradeWrongText3
+ dw TradeWrongText4
+
+; completed
+ dw TradeCompleteText1
+ dw TradeCompleteText2
+ dw TradeCompleteText3
+ dw TradeCompleteText4
+
+; after
+ dw TradeAfterText1
+ dw TradeAfterText2
+ dw TradeAfterText3
+ dw TradeAfterText4
+; fcf7b
+
+
+ConnectLinkCableText: ; 0xfcf7b
+ ; OK, connect the Game Link Cable.
+ text_jump UnknownText_0x1bd407
+ db "@"
+; 0xfcf80
+
+
+TradedForText: ; 0xfcf80
+ ; traded givemon for getmon
+ text_jump UnknownText_0x1bd429
+ start_asm
+
+ ld de, MUSIC_NONE
+ call PlayMusic
+ call DelayFrame
+ ld hl, .done
+ ret
+
+.done
+ ; sound0x0A
+ ; interpret_data
+ text_jump UnknownText_0x1bd445
+ db "@"
+; 0xfcf97
+
+
+TradeIntroText1: ; 0xfcf97
+ ; I collect #MON. Do you have @ ? Want to trade it for my @ ?
+ text_jump UnknownText_0x1bd449
+ db "@"
+; 0xfcf9c
+
+TradeCancelText1: ; 0xfcf9c
+ ; You don't want to trade? Aww…
+ text_jump UnknownText_0x1bd48c
+ db "@"
+; 0xfcfa1
+
+TradeWrongText1: ; 0xfcfa1
+ ; Huh? That's not @ . What a letdown…
+ text_jump UnknownText_0x1bd4aa
+ db "@"
+; 0xfcfa6
+
+TradeCompleteText1: ; 0xfcfa6
+ ; Yay! I got myself @ ! Thanks!
+ text_jump UnknownText_0x1bd4d2
+ db "@"
+; 0xfcfab
+
+TradeAfterText1: ; 0xfcfab
+ ; Hi, how's my old @ doing?
+ text_jump UnknownText_0x1bd4f4
+ db "@"
+; 0xfcfb0
+
+
+TradeIntroText2:
+TradeIntroText3: ; 0xfcfb0
+ ; Hi, I'm looking for this #MON. If you have @ , would you trade it for my @ ?
+ text_jump UnknownText_0x1bd512
+ db "@"
+; 0xfcfb5
+
+TradeCancelText2:
+TradeCancelText3: ; 0xfcfb5
+ ; You don't have one either? Gee, that's really disappointing…
+ text_jump UnknownText_0x1bd565
+ db "@"
+; 0xfcfba
+
+TradeWrongText2:
+TradeWrongText3: ; 0xfcfba
+ ; You don't have @ ? That's too bad, then.
+ text_jump UnknownText_0x1bd5a1
+ db "@"
+; 0xfcfbf
+
+TradeCompleteText2: ; 0xfcfbf
+ ; Great! Thank you! I finally got @ .
+ text_jump UnknownText_0x1bd5cc
+ db "@"
+; 0xfcfc4
+
+TradeAfterText2: ; 0xfcfc4
+ ; Hi! The @ you traded me is doing great!
+ text_jump UnknownText_0x1bd5f4
+ db "@"
+; 0xfcfc9
+
+
+TradeIntroText4: ; 0xfcfc9
+ ; 's cute, but I don't have it. Do you have @ ? Want to trade it for my @ ?
+ text_jump UnknownText_0x1bd621
+ db "@"
+; 0xfcfce
+
+TradeCancelText4: ; 0xfcfce
+ ; You don't want to trade? Oh, darn…
+ text_jump UnknownText_0x1bd673
+ db "@"
+; 0xfcfd3
+
+TradeWrongText4: ; 0xfcfd3
+ ; That's not @ . Please trade with me if you get one.
+ text_jump UnknownText_0x1bd696
+ db "@"
+; 0xfcfd8
+
+TradeCompleteText4: ; 0xfcfd8
+ ; Wow! Thank you! I always wanted @ !
+ text_jump UnknownText_0x1bd6cd
+ db "@"
+; 0xfcfdd
+
+TradeAfterText4: ; 0xfcfdd
+ ; How is that @ I traded you doing? Your @ 's so cute!
+ text_jump UnknownText_0x1bd6f5
+ db "@"
+; 0xfcfe2
+
+
+TradeCompleteText3: ; 0xfcfe2
+ ; Uh? What happened?
+ text_jump UnknownText_0x1bd731
+ db "@"
+; 0xfcfe7
+
+TradeAfterText3: ; 0xfcfe7
+ ; Trading is so odd… I still have a lot to learn about it.
+ text_jump UnknownText_0x1bd745
+ db "@"
+; 0xfcfec
--- a/engine/party_menu.asm
+++ b/engine/party_menu.asm
@@ -41,7 +41,7 @@
LoadPartyMenuGFX: ; 5004f
call LoadFontsBattleExtra
callab Function8ad1 ; engine/color.asm
- callab InefficientlyClear121BytesAtwc300
+ callab ClearSpriteAnims
ret
; 5005f
--- /dev/null
+++ b/engine/printer.asm
@@ -1,0 +1,1493 @@
+Function84000: ; 84000
+ ld hl, OverworldMap
+ lb bc, 4, 12
+ xor a
+ call Function842ab
+ xor a
+ ld [rSB], a
+ ld [rSC], a
+ ld [wc2d5], a
+ ld hl, wc2d4
+ set 0, [hl]
+ ld a, [GBPrinter]
+ ld [wcbfb], a
+ xor a
+ ld [wJumptableIndex], a
+ ret
+; 84022
+
+Function84022: ; 84022
+ ld a, [wJumptableIndex]
+ ld e, a
+ ld d, 0
+ ld hl, Jumptable_84031
+rept 2
+ add hl, de
+endr
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp [hl]
+; 84031
+
+
+Jumptable_84031: ; 84031 (21:4031)
+ dw Function84077
+ dw Function84143
+ dw Function84120
+ dw Function84099
+ dw Function84180
+ dw Function8412e
+ dw Function840c5
+ dw Function84180
+ dw Function84120
+ dw Function840de
+ dw Function84180
+ dw Function84120
+ dw Function841a1
+ dw Function84063
+ dw Function8406d
+ dw Function84120
+ dw Function84103
+ dw Function84071
+ dw Function841b0
+ dw Function841b3
+
+
+Function84059: ; 84059 (21:4059)
+ ld hl, wJumptableIndex
+ inc [hl]
+ ret
+
+Function8405e: ; 8405e (21:405e)
+ ld hl, wJumptableIndex
+ dec [hl]
+ ret
+
+Function84063: ; 84063 (21:4063)
+ xor a
+ ld [wca89], a
+ ld hl, wJumptableIndex
+ set 7, [hl]
+ ret
+
+Function8406d: ; 8406d (21:406d)
+ call Function84059
+ ret
+
+Function84071: ; 84071 (21:4071)
+ ld a, $1
+ ld [wJumptableIndex], a
+ ret
+
+Function84077: ; 84077 (21:4077)
+ call Function841fb
+ ld hl, Unknown_842b7
+ call Function841e2
+ xor a
+ ld [wca8e], a
+ ld [wca8f], a
+ ld a, [wcf65]
+ ld [wca81], a
+ call Function84059
+ call Function841c3
+ ld a, $1
+ ld [wcbf8], a
+ ret
+
+Function84099: ; 84099 (21:4099)
+ call Function841fb
+ ld hl, wca81
+ ld a, [hl]
+ and a
+ jr z, Function840c5
+ ld hl, Unknown_842c3
+ call Function841e2
+ call Function84260
+ ld a, $80
+ ld [wca8e], a
+ ld a, $2
+ ld [wca8f], a
+ call Function84219
+ call Function84059
+ call Function841c3
+ ld a, $2
+ ld [wcbf8], a
+ ret
+
+Function840c5: ; 840c5 (21:40c5)
+ ld a, $6
+ ld [wJumptableIndex], a
+ ld hl, Unknown_842c9
+ call Function841e2
+ xor a
+ ld [wca8e], a
+ ld [wca8f], a
+ call Function84059
+ call Function841c3
+ ret
+
+Function840de: ; 840de (21:40de)
+ call Function841fb
+ ld hl, Unknown_842bd
+ call Function841e2
+ call Function84249
+ ld a, $4
+ ld [wca8e], a
+ ld a, $0
+ ld [wca8f], a
+ call Function84219
+ call Function84059
+ call Function841c3
+ ld a, $3
+ ld [wcbf8], a
+ ret
+
+Function84103: ; 84103 (21:4103)
+ call Function841fb
+ ld hl, Unknown_842b7
+ call Function841e2
+ xor a
+ ld [wca8e], a
+ ld [wca8f], a
+ ld a, [wcf65]
+ ld [wca81], a
+ call Function84059
+ call Function841c3
+ ret
+
+Function84120: ; 84120 (21:4120)
+ ld hl, wca8b
+ inc [hl]
+ ld a, [hl]
+ cp $6
+ ret c
+ xor a
+ ld [hl], a
+ call Function84059
+ ret
+
+Function8412e: ; 8412e (21:412e)
+ ld hl, wca8b
+ inc [hl]
+ ld a, [hl]
+ cp $6
+ ret c
+ xor a
+ ld [hl], a
+ ld hl, wca81
+ dec [hl]
+ call Function8405e
+ call Function8405e
+ ret
+
+Function84143: ; 84143 (21:4143)
+ ld a, [wc2d5]
+ and a
+ ret nz
+ ld a, [wca88]
+ cp $ff
+ jr nz, .printer_connected
+ ld a, [wca89]
+ cp $ff
+ jr z, .printer_error
+
+.printer_connected
+ ld a, [wca88]
+ cp $81
+ jr nz, .printer_error
+ ld a, [wca89]
+ cp $0
+ jr nz, .printer_error
+ ld hl, wc2d4
+ set 1, [hl]
+ ld a, $5
+ ld [wca8a], a
+ call Function84059
+ ret
+
+.printer_error
+ ld a, $ff
+ ld [wca88], a
+ ld [wca89], a
+ ld a, $e
+ ld [wJumptableIndex], a
+ ret
+
+Function84180: ; 84180 (21:4180)
+ ld a, [wc2d5]
+ and a
+ ret nz
+ ld a, [wca89]
+ and $f0
+ jr nz, .asm_8419b
+ ld a, [wca89]
+ and $1
+ jr nz, .asm_84197
+ call Function84059
+ ret
+.asm_84197
+ call Function8405e
+ ret
+.asm_8419b
+ ld a, $12
+ ld [wJumptableIndex], a
+ ret
+
+Function841a1: ; 841a1 (21:41a1)
+ ld a, [wc2d5]
+ and a
+ ret nz
+ ld a, [wca89]
+ and $f3
+ ret nz
+ call Function84059
+ ret
+
+Function841b0: ; 841b0 (21:41b0)
+ call Function84059
+
+Function841b3: ; 841b3 (21:41b3)
+ ld a, [wc2d5]
+ and a
+ ret nz
+ ld a, [wca89]
+ and $f0
+ ret nz
+ xor a
+ ld [wJumptableIndex], a
+ ret
+
+Function841c3: ; 841c3 (21:41c3)
+ ld a, [wc2d5]
+ and a
+ jr nz, Function841c3
+ xor a
+ ld [wca8c], a
+ ld [wca8d], a
+ ld a, $1
+ ld [wc2d5], a
+ ld a, $88
+ ld [rSB], a
+ ld a, $1
+ ld [rSC], a
+ ld a, $81
+ ld [rSC], a
+ ret
+
+Function841e2: ; 841e2 (21:41e2)
+ ld a, [hli]
+ ld [wca82], a
+ ld a, [hli]
+ ld [wca83], a
+ ld a, [hli]
+ ld [wca84], a
+ ld a, [hli]
+ ld [wca85], a
+ ld a, [hli]
+ ld [wca86], a
+ ld a, [hl]
+ ld [wca87], a
+ ret
+
+Function841fb: ; 841fb (21:41fb)
+ xor a
+ ld hl, wca82
+rept 3
+ ld [hli], a
+endr
+ ld [hl], a
+ ld hl, wca86
+ ld [hli], a
+ ld [hl], a
+ xor a
+ ld [wca8e], a
+ ld [wca8f], a
+ ld hl, OverworldMap
+ ld bc, $280
+ call Function842ab
+ ret
+
+Function84219: ; 84219 (21:4219)
+ ld hl, 0
+ ld bc, $4
+ ld de, wca82
+ call Function8423c
+ ld a, [wca8e]
+ ld c, a
+ ld a, [wca8f]
+ ld b, a
+ ld de, OverworldMap
+ call Function8423c
+ ld a, l
+ ld [wca86], a
+ ld a, h
+ ld [wca87], a
+ ret
+
+Function8423c: ; 8423c (21:423c)
+ ld a, [de]
+ inc de
+ add l
+ jr nc, .asm_84242
+ inc h
+.asm_84242
+ ld l, a
+ dec bc
+ ld a, c
+ or b
+ jr nz, Function8423c
+ ret
+
+Function84249: ; 84249 (21:4249)
+ ld a, $1
+ ld [OverworldMap], a
+ ld a, [wcbfa]
+ ld [wc801], a
+ ld a, $e4
+ ld [wc802], a
+ ld a, [wcbfb]
+ ld [wc803], a
+ ret
+
+Function84260: ; 84260 (21:4260)
+ ld a, [wca81]
+ xor $ff
+ ld d, a
+ ld a, [wcf65]
+ inc a
+ add d
+ ld hl, wca90
+ ld de, $28
+.asm_84271
+ and a
+ jr z, .asm_84278
+ add hl, de
+ dec a
+ jr .asm_84271
+.asm_84278
+ ld e, l
+ ld d, h
+ ld hl, OverworldMap
+ ld c, $28
+.asm_8427f
+ ld a, [de]
+ inc de
+ push bc
+ push de
+ push hl
+ swap a
+ ld d, a
+ and $f0
+ ld e, a
+ ld a, d
+ and $f
+ ld d, a
+ and $8
+ ld a, d
+ jr nz, .asm_84297
+ or $90
+ jr .asm_84299
+.asm_84297
+ or $80
+.asm_84299
+ ld d, a
+ lb bc, $21, 1
+ call Request2bpp
+ pop hl
+ ld de, $10
+ add hl, de
+ pop de
+ pop bc
+ dec c
+ jr nz, .asm_8427f
+ ret
+
+Function842ab: ; 842ab
+ push de
+ ld e, a
+.asm_842ad
+ ld [hl], e
+ inc hl
+ dec bc
+ ld a, c
+ or b
+ jr nz, .asm_842ad
+ ld a, e
+ pop de
+ ret
+; 842b7
+
+Unknown_842b7: db 1, 0, $00, 0, 1, 0
+Unknown_842bd: db 2, 0, $04, 0, 0, 0
+Unknown_842c3: db 4, 0, $80, 2, 0, 0
+Unknown_842c9: db 4, 0, $00, 0, 4, 0
+Unknown_842cf: db 8, 0, $00, 0, 8, 0 ; unused
+Unknown_842d5: db 15, 0, $00, 0, 15, 0 ; unused
+; 842db
+
+
+Function842db:: ; 842db
+ ld a, [wc2d5]
+ add a
+ ld e, a
+ ld d, 0
+ ld hl, Jumptable_842ea
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp [hl]
+; 842ea
+
+
+Jumptable_842ea: ; 842ea (21:42ea)
+ dw Function8432f
+ dw Function84330
+ dw Function84339
+ dw Function84343
+ dw Function8434d
+ dw Function84357
+ dw Function84361
+ dw Function8438b
+ dw Function84395
+ dw Function8439f
+ dw Function843a8
+ dw Function843b6
+ dw Function84330
+ dw Function843c0
+ dw Function843c9
+ dw Function843c9
+ dw Function843c9
+ dw Function843c0
+ dw Function843c9
+ dw Function8439f
+ dw Function843a8
+ dw Function843e6
+ dw Function84330
+ dw Function843d2
+ dw Function843c9
+ dw Function843c9
+ dw Function843c9
+ dw Function843d2
+ dw Function843c9
+ dw Function8439f
+ dw Function843a8
+ dw Function843b6
+
+
+Function8432a: ; 8432a (21:432a)
+ ld hl, wc2d5
+ inc [hl]
+ ret
+
+Function8432f: ; 8432f (21:432f)
+ ret
+
+Function84330: ; 84330 (21:4330)
+ ld a, $33
+ call Function843db
+ call Function8432a
+ ret
+
+Function84339: ; 84339 (21:4339)
+ ld a, [wca82]
+ call Function843db
+ call Function8432a
+ ret
+
+Function84343: ; 84343 (21:4343)
+ ld a, [wca83]
+ call Function843db
+ call Function8432a
+ ret
+
+Function8434d: ; 8434d (21:434d)
+ ld a, [wca84]
+ call Function843db
+ call Function8432a
+ ret
+
+Function84357: ; 84357 (21:4357)
+ ld a, [wca85]
+ call Function843db
+ call Function8432a
+ ret
+
+Function84361: ; 84361 (21:4361)
+ ld hl, wca8e
+ ld a, [hli]
+ ld d, [hl]
+ ld e, a
+ or d
+ jr z, .asm_84388
+ dec de
+ ld [hl], d
+ dec hl
+ ld [hl], e
+ ld a, [wca8c]
+ ld e, a
+ ld a, [wca8d]
+ ld d, a
+ ld hl, OverworldMap
+ add hl, de
+ inc de
+ ld a, e
+ ld [wca8c], a
+ ld a, d
+ ld [wca8d], a
+ ld a, [hl]
+ call Function843db
+ ret
+.asm_84388
+ call Function8432a
+
+Function8438b: ; 8438b (21:438b)
+ ld a, [wca86]
+ call Function843db
+ call Function8432a
+ ret
+
+Function84395: ; 84395 (21:4395)
+ ld a, [wca87]
+ call Function843db
+ call Function8432a
+ ret
+
+Function8439f: ; 8439f (21:439f)
+ ld a, $0
+ call Function843db
+ call Function8432a
+ ret
+
+Function843a8: ; 843a8 (21:43a8)
+ ld a, [rSB]
+ ld [wca88], a
+ ld a, $0
+ call Function843db
+ call Function8432a
+ ret
+
+Function843b6: ; 843b6 (21:43b6)
+ ld a, [rSB]
+ ld [wca89], a
+ xor a
+ ld [wc2d5], a
+ ret
+
+Function843c0: ; 843c0 (21:43c0)
+ ld a, $f
+ call Function843db
+ call Function8432a
+ ret
+
+Function843c9: ; 843c9 (21:43c9)
+ ld a, $0
+ call Function843db
+ call Function8432a
+ ret
+
+Function843d2: ; 843d2 (21:43d2)
+ ld a, $8
+ call Function843db
+ call Function8432a
+ ret
+
+Function843db: ; 843db (21:43db)
+ ld [rSB], a
+ ld a, $1
+ ld [rSC], a
+ ld a, $81
+ ld [rSC], a
+ ret
+
+Function843e6: ; 843e6 (21:43e6)
+ ld a, [rSB]
+ ld [wca89], a
+ xor a
+ ld [wc2d5], a
+ ret
+
+Function843f0: ; 843f0
+.asm_843f0
+ call JoyTextDelay
+ call Function846f6
+ jr c, .asm_8440f
+ ld a, [wJumptableIndex]
+ bit 7, a
+ jr nz, .asm_8440d
+ call Function84022
+ call Function84757
+ call Function84785
+ call DelayFrame
+ jr .asm_843f0
+
+.asm_8440d
+ and a
+ ret
+
+.asm_8440f
+ scf
+ ret
+; 84411
+
+Function84411: ; 84411
+ xor a
+ ld [wc2d4], a
+ ld [wc2d5], a
+ ret
+; 84419
+
+Function84419: ; 84419
+ push af
+ call Function84000
+ pop af
+ ld [wcbfa], a
+ call Function84728
+ ret
+; 84425
+
+Function84425: ; 84425
+ call ReturnToMapFromSubmenu
+ call Function84753
+ ret
+; 8442c
+
+Function8442c: ; 8442c
+ ld a, [wcf65]
+ push af
+ ld hl, VTiles1
+ ld de, FontInversed
+ lb bc, BANK(FontInversed), $80
+ call Request1bpp
+ xor a
+ ld [$ffac], a
+ call Function8474c
+ ld a, [rIE]
+ push af
+ xor a
+ ld [rIF], a
+ ld a, $9
+ ld [rIE], a
+ call Function84000
+ ld a, $10
+ ld [wcbfa], a
+ callba Function1dc1b0
+ call ClearTileMap
+ ld a, $e4
+ call DmgToCgbBGPals
+ call DelayFrame
+ ld hl, hVBlank
+ ld a, [hl]
+ push af
+ ld [hl], $4
+ ld a, $8
+ ld [wcf65], a
+ call Function84742
+ call Function843f0
+ jr c, .asm_8449d
+ call Function84411
+ ld c, 12
+ call DelayFrames
+ xor a
+ ld [hBGMapMode], a
+ call Function84000
+ ld a, $3
+ ld [wcbfa], a
+ callba Function1dc213
+ call Function84742
+ ld a, $4
+ ld [wcf65], a
+ call Function843f0
+
+.asm_8449d
+ pop af
+ ld [hVBlank], a
+ call Function84411
+ xor a
+ ld [rIF], a
+ pop af
+ ld [rIE], a
+ call Function84425
+ ld c, $8
+.asm_844ae
+ call LowVolume
+ call DelayFrame
+ dec c
+ jr nz, .asm_844ae
+ pop af
+ ld [wcf65], a
+ ret
+; 844bc
+
+Function844bc: ; 844bc (21:44bc)
+ ld a, [wcf65]
+ push af
+ ld a, $9
+ ld [wcf65], a
+ ld a, e
+ ld [wd004], a
+ ld a, d
+ ld [StartFlypoint], a
+ ld a, b
+ ld [EndFlypoint], a
+ ld a, c
+ ld [MovementBuffer], a
+ xor a
+ ld [$ffac], a
+ ld [wd003], a
+ call Function8474c
+ ld a, [rIE]
+ push af
+ xor a
+ ld [rIF], a
+ ld a, $9
+ ld [rIE], a
+ ld hl, hVBlank
+ ld a, [hl]
+ push af
+ ld [hl], $4
+ xor a
+ ld [hBGMapMode], a
+ call Function84817
+ ld a, $10
+ call Function84419
+ call Function84559
+ jr c, .asm_84545
+ call Function84411
+ ld c, 12
+ call DelayFrames
+ xor a
+ ld [hBGMapMode], a
+ call Function8486f
+ ld a, $0
+ call Function84419
+ call Function84559
+ jr c, .asm_84545
+ call Function84411
+ ld c, 12
+ call DelayFrames
+ xor a
+ ld [hBGMapMode], a
+ call Function84893
+ ld a, $0
+ call Function84419
+ call Function84559
+ jr c, .asm_84545
+ call Function84411
+ ld c, 12
+ call DelayFrames
+ xor a
+ ld [hBGMapMode], a
+ call Function848b7
+ ld a, $3
+ call Function84419
+ call Function84559
+.asm_84545
+ pop af
+ ld [hVBlank], a
+ call Function84411
+ xor a
+ ld [rIF], a
+ pop af
+ ld [rIE], a
+ call Function84425
+ pop af
+ ld [wcf65], a
+ ret
+
+Function84559: ; 84559 (21:4559)
+ call Function84742
+ call Function843f0
+ ret
+
+Function84560: ; 84560
+ ld a, [wcf65]
+ push af
+ xor a
+ ld [$ffac], a
+ call Function8474c
+ ld a, [rIE]
+ push af
+ xor a
+ ld [rIF], a
+ ld a, $9
+ ld [rIE], a
+ ld hl, hVBlank
+ ld a, [hl]
+ push af
+ ld [hl], $4
+ xor a
+ ld [hBGMapMode], a
+ call LoadTileMapToTempTileMap
+ callba Function16dac
+ ld a, $0
+ call Function84419
+ call Call_LoadTempTileMapToTileMap
+ call Function84742
+ ld a, $9
+ ld [wcf65], a
+.asm_84597
+ call JoyTextDelay
+ call Function846f6
+ jr c, .asm_845c0
+ ld a, [wJumptableIndex]
+ bit 7, a
+ jr nz, .asm_845c0
+ call Function84022
+ ld a, [wJumptableIndex]
+ cp $2
+ jr nc, .asm_845b5
+ ld a, $3
+ ld [wca81], a
+
+.asm_845b5
+ call Function84757
+ call Function84785
+ call DelayFrame
+ jr .asm_84597
+
+.asm_845c0
+ pop af
+ ld [hVBlank], a
+ call Function84411
+ call Call_LoadTempTileMapToTileMap
+ xor a
+ ld [rIF], a
+ pop af
+ ld [rIE], a
+ pop af
+ ld [wcf65], a
+ ret
+; 845d4
+
+Function845d4: ; 845d4
+ call Function845db
+ call Function84425
+ ret
+; 845db
+
+Function845db: ; 845db
+ ld a, [wcf65]
+ push af
+ xor a
+ ld [$ffac], a
+ call Function8474c
+ ld a, [rIE]
+ push af
+ xor a
+ ld [rIF], a
+ ld a, $9
+ ld [rIE], a
+ xor a
+ ld [hBGMapMode], a
+ ld a, $13
+ call Function84419
+ ld hl, hVBlank
+ ld a, [hl]
+ push af
+ ld [hl], $4
+ ld a, $9
+ ld [wcf65], a
+ call Function843f0
+ pop af
+ ld [hVBlank], a
+ call Function84411
+ call Function84735
+ xor a
+ ld [rIF], a
+ pop af
+ ld [rIE], a
+ pop af
+ ld [wcf65], a
+ ret
+; 8461a
+
+Function8461a: ; 8461a
+ ld a, [wcf65]
+ push af
+ xor a
+ ld [$ffac], a
+ call Function8474c
+ ld a, [rIE]
+ push af
+ xor a
+ ld [rIF], a
+ ld a, $9
+ ld [rIE], a
+ xor a
+ ld [hBGMapMode], a
+ callba Function1dc381
+ ld a, $10
+ call Function84419
+ ld hl, hVBlank
+ ld a, [hl]
+ push af
+ ld [hl], $4
+ ld a, $8
+ ld [wcf65], a
+ call Function84742
+ call Function843f0
+ jr c, .asm_84671
+ call Function84411
+ ld c, 12
+ call DelayFrames
+ xor a
+ ld [hBGMapMode], a
+ callba Function1dc47b
+ ld a, $3
+ call Function84419
+ ld a, $9
+ ld [wcf65], a
+ call Function84742
+ call Function843f0
+
+.asm_84671
+ pop af
+ ld [hVBlank], a
+ call Function84411
+ call Function84735
+ xor a
+ ld [rIF], a
+ pop af
+ ld [rIE], a
+ call Function84425
+ pop af
+ ld [wcf65], a
+ ret
+; 84688
+
+_PrintDiploma: ; 84688
+ ld a, [wcf65]
+ push af
+ callba Function1dd709
+ xor a
+ ld [$ffac], a
+ call Function8474c
+ ld a, [rIE]
+ push af
+ xor a
+ ld [rIF], a
+ ld a, $9
+ ld [rIE], a
+ ld hl, hVBlank
+ ld a, [hl]
+ push af
+ ld [hl], $4
+ ld a, $10
+ call Function84419
+ call Function84742
+ ld a, $9
+ ld [wcf65], a
+ call Function843f0
+ jr c, .asm_846e2
+ call Function84411
+ ld c, 12
+ call DelayFrames
+ call LoadTileMapToTempTileMap
+ xor a
+ ld [hBGMapMode], a
+ callba Function1dd7ae
+ ld a, $3
+ call Function84419
+ call Call_LoadTempTileMapToTileMap
+ call Function84742
+ ld a, $9
+ ld [wcf65], a
+ call Function843f0
+
+.asm_846e2
+ pop af
+ ld [hVBlank], a
+ call Function84411
+ xor a
+ ld [rIF], a
+ pop af
+ ld [rIE], a
+ call Function84425
+ pop af
+ ld [wcf65], a
+ ret
+; 846f6
+
+Function846f6: ; 846f6
+ ld a, [hJoyDown]
+ and B_BUTTON
+ jr nz, .asm_846fe
+ and a
+ ret
+
+.asm_846fe
+ ld a, [wca80]
+ cp $c
+ jr nz, .asm_84722
+.asm_84705
+ ld a, [wc2d5]
+ and a
+ jr nz, .asm_84705
+ ld a, $16
+ ld [wc2d5], a
+ ld a, $88
+ ld [rSB], a
+ ld a, $1
+ ld [rSC], a
+ ld a, $81
+ ld [rSC], a
+.asm_8471c
+ ld a, [wc2d5]
+ and a
+ jr nz, .asm_8471c
+
+.asm_84722
+ ld a, $1
+ ld [$ffac], a
+ scf
+ ret
+; 84728
+
+Function84728: ; 84728
+ hlcoord 0, 0
+ ld de, wca90
+ ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
+ call CopyBytes
+ ret
+; 84735
+
+Function84735: ; 84735
+ ld hl, wca90
+ decoord 0, 0
+ ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
+ call CopyBytes
+ ret
+; 84742
+
+Function84742: ; 84742
+ xor a
+ ld [hJoyReleased], a
+ ld [hJoyPressed], a
+ ld [hJoyDown], a
+ ld [hJoyLast], a
+ ret
+; 8474c
+
+Function8474c: ; 8474c
+ ld de, MUSIC_PRINTER
+ call PlayMusic2
+ ret
+; 84753
+
+Function84753: ; 84753
+ call RestartMapMusic
+ ret
+; 84757
+
+Function84757: ; 84757
+ ld a, [wca88]
+ cp -1
+ jr nz, .printer_connected
+ ld a, [wca89]
+ cp -1
+ jr z, .error_2
+
+.printer_connected
+ ld a, [wca89]
+ and %11100000
+ ret z ; no error
+
+ bit 7, a
+ jr nz, .error_1
+ bit 6, a
+ jr nz, .error_4
+ ld a, 6 ; error 3
+ jr .load_text_index
+
+.error_4
+ ld a, 7 ; error 4
+ jr .load_text_index
+
+.error_1
+ ld a, 4 ; error 1
+ jr .load_text_index
+
+.error_2
+ ld a, 5 ; error 2
+
+.load_text_index
+ ld [wcbf8], a
+ ret
+; 84785
+
+Function84785: ; 84785
+ ld a, [wcbf8]
+ and a
+ ret z
+ push af
+ xor a
+ ld [hBGMapMode], a
+ hlcoord 0, 5
+ lb bc, 10, 18
+ call TextBox
+ pop af
+ ld e, a
+ ld d, 0
+ ld hl, PrinterStatusStringPointers
+rept 2
+ add hl, de
+endr
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ hlcoord 1, 7
+ ld a, BANK(GBPrinterStrings)
+ call FarString
+ hlcoord 2, 15
+ ld de, String_PressBToCancel
+ call PlaceString
+ ld a, $1
+ ld [hBGMapMode], a
+ xor a
+ ld [wcbf8], a
+ ret
+; 847bd
+
+Function847bd: ; 847bd
+ ld a, [wcbf8]
+ and a
+ ret z
+ push af
+ xor a
+ ld [hBGMapMode], a
+ hlcoord 2, 4
+ lb bc, 13, 16
+ call ClearBox
+ pop af
+ ld e, a
+ ld d, 0
+ ld hl, PrinterStatusStringPointers
+rept 2
+ add hl, de
+endr
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ hlcoord 4, 7
+ ld a, BANK(GBPrinterStrings)
+ call FarString
+ hlcoord 4, 15
+ ld de, String_PressBToCancel
+ call PlaceString
+ ld a, $1
+ ld [hBGMapMode], a
+ xor a
+ ld [wcbf8], a
+ ret
+; 847f5
+
+String_PressBToCancel:
+ db "Press B to Cancel@"
+; 84807
+
+PrinterStatusStringPointers: ; 84807
+ dw String_1dc275 ; @
+ dw String_1dc276 ; CHECKING LINK
+ dw String_1dc289 ; TRANSMITTING
+ dw String_1dc29c ; PRINTING
+ dw String_1dc2ad ; error 1
+ dw String_1dc2e2 ; error 2
+ dw String_1dc317 ; error 3
+ dw String_1dc34c ; error 4
+; 84817
+
+Function84817: ; 84817 (21:4817)
+ xor a
+ ld [wd002], a
+ hlcoord 0, 0
+ ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
+ ld a, " "
+ call ByteFill
+ call Function84a0e
+ hlcoord 0, 0
+ ld bc, 9 * SCREEN_WIDTH
+ ld a, " "
+ call ByteFill
+ call Function849e9
+ call Function849d7
+ hlcoord 4, 3
+ ld de, String_84865
+ call PlaceString
+ ld a, [wd007]
+ ld bc, BOX_NAME_LENGTH
+ ld hl, wBoxNames
+ call AddNTimes
+ ld d, h
+ ld e, l
+ hlcoord 6, 5
+ call PlaceString
+ ld a, $1
+ call Function849c6
+ hlcoord 2, 9
+ ld c, $3
+ call Function848e7
+ ret
+; 84865 (21:4865)
+
+String_84865:
+ db "#MON LIST@"
+; 8486f
+
+Function8486f: ; 8486f (21:486f)
+ hlcoord 0, 0
+ ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
+ ld a, " "
+ call ByteFill
+ call Function84a0e
+ call Function849e9
+ ld a, [wd003]
+ and a
+ ret nz
+ ld a, $4
+ call Function849c6
+ hlcoord 2, 0
+ ld c, $6
+ call Function848e7
+ ret
+
+Function84893: ; 84893 (21:4893)
+ hlcoord 0, 0
+ ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
+ ld a, " "
+ call ByteFill
+ call Function84a0e
+ call Function849e9
+ ld a, [wd003]
+ and a
+ ret nz
+ ld a, $a
+ call Function849c6
+ hlcoord 2, 0
+ ld c, $6
+ call Function848e7
+ ret
+
+Function848b7: ; 848b7 (21:48b7)
+ hlcoord 0, 0
+ ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
+ ld a, " "
+ call ByteFill
+ call Function84a0e
+ hlcoord 1, 15
+ lb bc, 2, 18
+ call ClearBox
+ call Function849e9
+ call Function849fc
+ ld a, [wd003]
+ and a
+ ret nz
+ ld a, $10
+ call Function849c6
+ hlcoord 2, 0
+ ld c, $5
+ call Function848e7
+ ret
+
+Function848e7: ; 848e7 (21:48e7)
+ ld a, [EndFlypoint]
+ call GetSRAMBank
+
+Function848ed: ; 848ed (21:48ed)
+ ld a, c
+ and a
+ jp z, Function84986
+ dec c
+ ld a, [de]
+ cp $ff
+ jp z, Function84981
+ ld [wd265], a
+ ld [CurPartySpecies], a
+ push bc
+ push hl
+ push de
+ push hl
+ ld bc, $10
+ ld a, " "
+ call ByteFill
+ pop hl
+ push hl
+ call GetBasePokemonName
+ pop hl
+ push hl
+ call PlaceString
+ ld a, [CurPartySpecies]
+ cp $fd
+ pop hl
+ jr z, .ok2
+ ld bc, $b
+ add hl, bc
+ call Function8498a
+ ld bc, $9
+ add hl, bc
+ ld a, $f3
+ ld [hli], a
+ push hl
+ ld bc, $e
+ ld a, " "
+ call ByteFill
+ pop hl
+ push hl
+ ld a, [wd004]
+ ld l, a
+ ld a, [StartFlypoint]
+ ld h, a
+ ld bc, $372
+ add hl, bc
+ ld bc, $b
+ ld a, [wd002]
+ call AddNTimes
+ ld e, l
+ ld d, h
+ pop hl
+ push hl
+ call PlaceString
+ pop hl
+ ld bc, $b
+ add hl, bc
+ push hl
+ ld a, [wd004]
+ ld l, a
+ ld a, [StartFlypoint]
+ ld h, a
+ ld bc, $35
+ add hl, bc
+ ld bc, $20
+ ld a, [wd002]
+ call AddNTimes
+ ld a, [hl]
+ pop hl
+ call Function383d
+.ok2
+ ld hl, wd002
+ inc [hl]
+ pop de
+ pop hl
+ ld bc, $3c
+ add hl, bc
+ pop bc
+ inc de
+ jp Function848ed
+
+Function84981: ; 84981 (21:4981)
+ ld a, $1
+ ld [wd003], a
+
+Function84986: ; 84986 (21:4986)
+ call CloseSRAM
+ ret
+
+Function8498a: ; 8498a (21:498a)
+ push hl
+ ld a, [wd004]
+ ld l, a
+ ld a, [StartFlypoint]
+ ld h, a
+ ld bc, $2b
+ add hl, bc
+ ld bc, $20
+ ld a, [wd002]
+ call AddNTimes
+ ld de, TempMonDVs
+ ld a, [hli]
+ ld [de], a
+ inc de
+ ld a, [hli]
+ ld [de], a
+ ld a, [wd002]
+ ld [CurPartyMon], a
+ ld a, $3
+ ld [MonType], a
+ callba GetGender
+ ld a, $7f
+ jr c, .asm_849c3
+ ld a, $ef
+ jr nz, .asm_849c3
+ ld a, $f5
+.asm_849c3
+ pop hl
+ ld [hli], a
+ ret
+
+Function849c6: ; 849c6 (21:49c6)
+ push hl
+ ld e, a
+ ld d, $0
+ ld a, [wd004]
+ ld l, a
+ ld a, [StartFlypoint]
+ ld h, a
+ add hl, de
+ ld e, l
+ ld d, h
+ pop hl
+ ret
+
+Function849d7: ; 849d7 (21:49d7)
+ hlcoord 0, 0
+ ld a, "┌"
+ ld [hli], a
+ ld a, "─"
+ ld c, SCREEN_WIDTH - 2
+.asm_849e1
+ ld [hli], a
+ dec c
+ jr nz, .asm_849e1
+ ld a, "┐"
+ ld [hl], a
+ ret
+
+Function849e9: ; 849e9 (21:49e9)
+ hlcoord 0, 0
+ ld de, SCREEN_WIDTH - 1
+ ld c, SCREEN_HEIGHT
+.asm_849f1
+ ld a, "│"
+ ld [hl], a
+ add hl, de
+ ld a, "│"
+ ld [hli], a
+ dec c
+ jr nz, .asm_849f1
+ ret
+
+Function849fc: ; 849fc (21:49fc)
+ hlcoord 0, 17
+ ld a, "└"
+ ld [hli], a
+ ld a, "─"
+ ld c, SCREEN_WIDTH - 2
+.asm_84a06
+ ld [hli], a
+ dec c
+ jr nz, .asm_84a06
+ ld a, "┘"
+ ld [hl], a
+ ret
+
+Function84a0e: ; 84a0e (21:4a0e)
+ hlcoord 2, 0
+ ld c, $6
+.asm_84a13
+ push bc
+ push hl
+ ld de, String84a25
+ call PlaceString
+ pop hl
+ ld bc, $3c
+ add hl, bc
+ pop bc
+ dec c
+ jr nz, .asm_84a13
+ ret
+; 84a25 (21:4a25)
+
+String84a25: ; 84a25
+ db " ------@"
+; 84a2e
--- a/engine/scripting.asm
+++ b/engine/scripting.asm
@@ -2985,8 +2985,8 @@
xor a
ld [hBGMapMode], a
call OverworldTextModeSwitch
- call Function2914
- callba Function104061
+ call GetMovementPermissions
+ callba ReloadMapPart
call UpdateSprites
ret
; 97af6
--- a/engine/sprites.asm
+++ b/engine/sprites.asm
@@ -174,7 +174,7 @@
; Look up the third field from the table in the wc300 array (10x2).
; Take the value and load it in
ld a, [de]
- call LookUpInwDict_c300
+ call LookUpInwSpriteAnimDict
ld [hli], a
pop de
; Set hl to field 4. Kinda pointless, because we're presumably already here.
@@ -374,11 +374,11 @@
ret
; 8d109
-LookUpInwDict_c300: ; 8d109
-; a = wDict_c300[a] if a in wDict_c300 else 0
+LookUpInwSpriteAnimDict: ; 8d109
+; a = wSpriteAnimDict[a] if a in wSpriteAnimDict else 0
push hl
push bc
- ld hl, wDict_c300
+ ld hl, wSpriteAnimDict
ld b, a
ld c, 10
.loop
@@ -2885,3 +2885,540 @@
Unknown_8e75d: ; 8e75d
sine_wave $100
+
+
+Function8e79d: ; 8e79d
+ ld a, [hSGB]
+ ld de, GFX_8e7f4
+ and a
+ jr z, .asm_8e7a8
+ ld de, GFX_8e804
+
+.asm_8e7a8
+ ld hl, VTiles0
+ lb bc, BANK(GFX_8e7f4), 1
+ call Request2bpp
+ ld c, $8
+ ld d, $0
+.asm_8e7b5
+ push bc
+ call Function8e7c6
+ call DelayFrame
+ pop bc
+rept 2
+ inc d
+endr
+ dec c
+ jr nz, .asm_8e7b5
+ call ClearSprites
+ ret
+; 8e7c6
+
+Function8e7c6: ; 8e7c6
+ ld hl, Sprites
+ ld c, $8
+.asm_8e7cb
+ ld a, c
+ and a
+ ret z
+ dec c
+ ld a, c
+ sla a
+ sla a
+ sla a
+ push af
+ push de
+ push hl
+ call Function8e72c
+ pop hl
+ pop de
+ add $68
+ ld [hli], a
+ pop af
+ push de
+ push hl
+ call Function8e72a
+ pop hl
+ pop de
+ add $54
+ ld [hli], a
+ ld a, $0
+ ld [hli], a
+ ld a, $6
+ ld [hli], a
+ jr .asm_8e7cb
+; 8e7f4
+
+GFX_8e7f4: ; 8e7f4
+INCBIN "gfx/unknown/08e7f4.2bpp"
+GFX_8e804: ; 8e804
+INCBIN "gfx/unknown/08e804.2bpp"
+
+ClearSpriteAnims: ; 8e814
+ push hl
+ push de
+ push bc
+ push af
+ ld hl, wSpriteAnimDict
+ ld bc, wSpriteAnimsEnd - wSpriteAnimDict
+.loop
+ ld [hl], $0
+ inc hl
+ dec bc
+ ld a, c
+ or b
+ jr nz, .loop
+ pop af
+ pop bc
+ pop de
+ pop hl
+ ret
+; 8e82b
+
+Function8e82b: ; 8e82b
+ ld a, e
+ call ReadMonMenuIcon
+ ld l, a
+ ld h, 0
+ add hl, hl
+ ld de, IconPointers
+ add hl, de
+ ld a, [hli]
+ ld e, a
+ ld d, [hl]
+ ld b, BANK(Icons)
+ ld c, 8
+ ret
+; 8e83f
+
+Function8e83f: ; 8e83f
+ push hl
+ push de
+ push bc
+ call Function8e849
+ pop bc
+ pop de
+ pop hl
+ ret
+; 8e849
+
+Function8e849: ; 8e849
+ ld d, 0
+ ld hl, Jumptable_8e854
+rept 2
+ add hl, de
+endr
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp [hl]
+; 8e854
+
+
+Jumptable_8e854: ; 8e854 (23:6854)
+ dw Function8e8d5
+ dw Function8e961
+ dw Function8e97d
+ dw Function8e99a
+ dw Function8e898
+ dw Function8e8b1
+ dw Function8e862
+
+
+Function8e862: ; 8e862 (23:6862)
+ call Function8e908
+ call Function8e86c
+ call Function8e936
+ ret
+
+Function8e86c: ; 8e86c (23:686c)
+ push bc
+ ld a, [hObjectStructIndexBuffer]
+ ld hl, PartyMon1Item
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call AddNTimes
+ pop bc
+ ld a, [hl]
+ and a
+ jr z, .asm_8e890
+ push hl
+ push bc
+ ld d, a
+ callab ItemIsMail
+ pop bc
+ pop hl
+ jr c, .asm_8e88e
+ ld a, $6
+ jr .asm_8e892
+.asm_8e88e
+ ld a, $5
+.asm_8e890
+ ld a, $4
+.asm_8e892
+ ld hl, $1
+ add hl, bc
+ ld [hl], a
+ ret
+
+Function8e898: ; 8e898 (23:6898)
+ call Function8e8d5
+ ld hl, $2
+ add hl, bc
+ ld a, $0
+ ld [hl], a
+ ld hl, $4
+ add hl, bc
+ ld a, $48
+ ld [hl], a
+ ld hl, $5
+ add hl, bc
+ ld a, $48
+ ld [hl], a
+ ret
+
+Function8e8b1: ; 8e8b1 (23:68b1)
+ call Function8e908
+ call Function8e936
+ ld hl, $2
+ add hl, bc
+ ld a, $0
+ ld [hl], a
+ ld hl, $4
+ add hl, bc
+ ld a, $18
+ ld [hl], a
+ ld hl, $5
+ add hl, bc
+ ld a, $60
+ ld [hl], a
+ ld a, c
+ ld [wc608], a
+ ld a, b
+ ld [wc608 + 1], a
+ ret
+
+Function8e8d5: ; 8e8d5 (23:68d5)
+ call Function8e908
+ call Function8e8df
+ call Function8e936
+ ret
+
+Function8e8df: ; 8e8df (23:68df)
+ push bc
+ ld a, [hObjectStructIndexBuffer]
+ ld hl, PartyMon1Item
+ ld bc, $30
+ call AddNTimes
+ pop bc
+ ld a, [hl]
+ and a
+ ret z
+ push hl
+ push bc
+ ld d, a
+ callab ItemIsMail
+ pop bc
+ pop hl
+ jr c, .asm_8e900
+ ld a, $3
+ jr .asm_8e902
+.asm_8e900
+ ld a, $2
+.asm_8e902
+ ld hl, $1
+ add hl, bc
+ ld [hl], a
+ ret
+
+Function8e908: ; 8e908 (23:6908)
+ ld a, [wc3b7]
+ push af
+ ld a, [hObjectStructIndexBuffer]
+ ld hl, PartySpecies
+ ld e, a
+ ld d, $0
+ add hl, de
+ ld a, [hl]
+ call ReadMonMenuIcon
+ ld [CurIcon], a
+ call Function8e9db
+ ld a, [hObjectStructIndexBuffer]
+; y coord
+rept 4
+ add a
+endr
+ add $1c
+ ld d, a
+; x coord
+ ld e, $10
+; type is partymon icon
+ ld a, SPRITE_ANIM_INDEX_00
+ call InitSpriteAnimStruct
+ pop af
+ ld hl, $3
+ add hl, bc
+ ld [hl], a
+ ret
+
+Function8e936: ; 8e936 (23:6936)
+ push bc
+ ld a, [hObjectStructIndexBuffer]
+ ld b, a
+ call Function8e94c
+ ld a, b
+ pop bc
+ ld hl, $9
+ add hl, bc
+ ld [hl], a
+ rlca
+ rlca
+ ld hl, $d
+ add hl, bc
+ ld [hl], a
+ ret
+
+Function8e94c: ; 8e94c (23:694c)
+ callba PlacePartymonHPBar
+ call GetHPPal
+ ld e, d
+ ld d, 0
+ ld hl, Unknown_8e95e
+ add hl, de
+ ld b, [hl]
+ ret
+; 8e95e (23:695e)
+
+Unknown_8e95e: ; 8e95e
+ db $00, $40, $80
+; 8e961
+
+Function8e961: ; 8e961 (23:6961)
+ ld a, [wd265]
+ call ReadMonMenuIcon
+ ld [CurIcon], a
+ xor a
+ call GetIconGFX
+ lb de, $24, $20
+ ld a, SPRITE_ANIM_INDEX_00
+ call InitSpriteAnimStruct
+ ld hl, $2
+ add hl, bc
+ ld [hl], $0
+ ret
+
+Function8e97d: ; 8e97d (23:697d)
+ ld a, [wd265]
+ call ReadMonMenuIcon
+ ld [CurIcon], a
+ xor a
+ call GetIconGFX
+ ld d, $1a
+ ld e, $24
+ ld a, SPRITE_ANIM_INDEX_00
+ call InitSpriteAnimStruct
+ ld hl, $2
+ add hl, bc
+ ld [hl], $0
+ ret
+
+Function8e99a: ; 8e99a (23:699a)
+ ld a, [wd265]
+ call ReadMonMenuIcon
+ ld [CurIcon], a
+ ld a, $62
+ ld [wc3b7], a
+ call Function8e9db
+ ret
+
+GetSpeciesIcon: ; 8e9ac
+; Load species icon into VRAM at tile a
+ push de
+ ld a, [wd265]
+ call ReadMonMenuIcon
+ ld [CurIcon], a
+ pop de
+ ld a, e
+ call GetIconGFX
+ ret
+; 8e9bc
+
+
+Function8e9bc: ; 8e9bc (23:69bc)
+ push de
+ ld a, [wd265]
+ call ReadMonMenuIcon
+ ld [CurIcon], a
+ pop de
+ ld a, e
+ call GetIcon_a
+ ret
+; 8e9cc (23:69cc)
+
+Function8e9cc: ; 8e9cc
+ push de
+ ld a, [wd265]
+ call ReadMonMenuIcon
+ ld [CurIcon], a
+ pop de
+ call GetIcon_de
+ ret
+; 8e9db
+
+Function8e9db: ; 8e9db (23:69db)
+ ld a, [wc3b7]
+
+GetIconGFX: ; 8e9de
+ call GetIcon_a
+ ld de, $80 ; 8 tiles
+ add hl, de
+ ld de, HeldItemIcons
+ lb bc, BANK(HeldItemIcons), 2
+ call GetGFXUnlessMobile
+ ld a, [wc3b7]
+ add 10
+ ld [wc3b7], a
+ ret
+
+HeldItemIcons:
+INCBIN "gfx/icon/mail.2bpp"
+INCBIN "gfx/icon/item.2bpp"
+; 8ea17
+
+GetIcon_de: ; 8ea17
+; Load icon graphics into VRAM starting from tile de.
+ ld l, e
+ ld h, d
+ jr GetIcon
+
+GetIcon_a: ; 8ea1b
+; Load icon graphics into VRAM starting from tile a.
+ ld l, a
+ ld h, 0
+
+GetIcon: ; 8ea1e
+; Load icon graphics into VRAM starting from tile hl.
+
+; One tile is 16 bytes long.
+rept 4
+ add hl, hl
+endr
+
+ ld de, VTiles0
+ add hl, de
+ push hl
+
+; The icons are contiguous, in order and of the same
+; size, so the pointer table is somewhat redundant.
+ ld a, [CurIcon]
+ push hl
+ ld l, a
+ ld h, 0
+ add hl, hl
+ ld de, IconPointers
+ add hl, de
+ ld a, [hli]
+ ld e, a
+ ld d, [hl]
+ pop hl
+
+ lb bc, BANK(Icons), 8
+ call GetGFXUnlessMobile
+
+ pop hl
+ ret
+; 8ea3f
+
+GetGFXUnlessMobile: ; 8ea3f
+ ld a, [wLinkMode]
+ cp LINK_MOBILE
+ jp nz, Request2bpp
+ jp Get2bpp_2
+; 8ea4a
+
+Function8ea4a: ; 8ea4a
+ ld hl, wSpriteAnimationStructs
+ ld e, $6
+ ld a, [MenuSelection2]
+ ld d, a
+.loop
+ ld a, [hl]
+ and a
+ jr z, .next
+ cp d
+ jr z, .loadwithtwo
+ ld a, $0
+ jr .ok
+
+.loadwithtwo
+ ld a, $2
+
+.ok
+ push hl
+ ld c, l
+ ld b, h
+ ld hl, $2
+ add hl, bc
+ ld [hl], a
+ pop hl
+
+.next
+ ld bc, $10
+ add hl, bc
+ dec e
+ jr nz, .loop
+ ret
+; 8ea71
+
+Function8ea71: ; 8ea71
+ ld hl, wSpriteAnimationStructs
+ ld e, $6
+.loop
+ ld a, [hl]
+ and a
+ jr z, .zero
+ push hl
+ ld c, l
+ ld b, h
+ ld hl, $2
+ add hl, bc
+ ld [hl], $1
+ pop hl
+.zero
+ ld bc, $10
+ add hl, bc
+ dec e
+ jr nz, .loop
+ ret
+; 8ea8c (23:6a8c)
+
+Function8ea8c: ; 8ea8c
+ ld hl, wSpriteAnimationStructs
+ ld e, $6
+ ld a, [wd0e3]
+ ld d, a
+.asm_8ea95
+ ld a, [hl]
+ and a
+ jr z, .asm_8eaab
+ cp d
+ jr z, .asm_8eaa0
+ ld a, $3
+ jr .asm_8eaa2
+.asm_8eaa0
+ ld a, $2
+.asm_8eaa2
+ push hl
+ ld c, l
+ ld b, h
+ ld hl, $2
+ add hl, bc
+ ld [hl], a
+ pop hl
+.asm_8eaab
+ ld bc, $10
+ add hl, bc
+ dec e
+ jr nz, .asm_8ea95
+ ret
+
+INCLUDE "menu/mon_icons.asm"
--- a/engine/startmenu.asm
+++ b/engine/startmenu.asm
@@ -1761,7 +1761,7 @@
xor a
ld [hBGMapMode], a
callba Functionfb571
- callba InefficientlyClear121BytesAtwc300
+ callba ClearSpriteAnims
ld a, [CurPartyMon]
ld e, a
ld d, $0
--- /dev/null
+++ b/engine/time_capsule/conversion.asm
@@ -1,0 +1,684 @@
+; These functions seem to be related to backwards compatibility
+
+Functionfb57e: ; fb57e
+ ld a, [wd003]
+ ld hl, OTPartyMon1Species
+ call GetPartyLocation
+ push hl
+ ld a, [wd003]
+ inc a
+ ld c, a
+ ld b, 0
+ ld hl, OTPartyCount
+ add hl, bc
+ ld a, [hl]
+ pop hl
+ cp EGG
+ jr z, .asm_fb59c
+ cp [hl]
+ jr nz, .asm_fb5db
+
+.asm_fb59c
+ ld b, h
+ ld c, l
+ ld hl, MON_LEVEL
+ add hl, bc
+ ld a, [hl]
+ cp 101
+ jr nc, .asm_fb5db
+ ld a, [wLinkMode]
+ cp LINK_TIMECAPSULE
+ jr nz, .asm_fb5d9
+ ld hl, OTPartySpecies
+ ld a, [wd003]
+ ld c, a
+ ld b, 0
+ add hl, bc
+ ld a, [hl]
+
+ ; Magnemite and Magneton's types changed
+ ; from Electric to Electric/Steel.
+ cp MAGNEMITE
+ jr z, .asm_fb5d9
+ cp MAGNETON
+ jr z, .asm_fb5d9
+
+ ld [CurSpecies], a
+ call GetBaseData
+ ld hl, wcbea
+rept 2
+ add hl, bc
+endr
+ ld a, [BaseType1]
+ cp [hl]
+ jr nz, .asm_fb5db
+ inc hl
+ ld a, [BaseType2]
+ cp [hl]
+ jr nz, .asm_fb5db
+
+.asm_fb5d9
+ and a
+ ret
+
+.asm_fb5db
+ scf
+ ret
+; fb5dd
+
+Functionfb5dd: ; fb5dd
+ ld a, [wd002]
+ ld d, a
+ ld a, [PartyCount]
+ ld b, a
+ ld c, $0
+.asm_fb5e7
+ ld a, c
+ cp d
+ jr z, .asm_fb5f8
+ push bc
+ ld a, c
+ ld hl, PartyMon1HP
+ call GetPartyLocation
+ pop bc
+ ld a, [hli]
+ or [hl]
+ jr nz, .asm_fb60b
+
+.asm_fb5f8
+ inc c
+ dec b
+ jr nz, .asm_fb5e7
+ ld a, [wd003]
+ ld hl, OTPartyMon1HP
+ call GetPartyLocation
+ ld a, [hli]
+ or [hl]
+ jr nz, .asm_fb60b
+ scf
+ ret
+
+.asm_fb60b
+ and a
+ ret
+; fb60d
+
+Functionfb60d: ; fb60d
+ hlcoord 4, 0
+ ld de, PlayerName
+ call PlaceString
+ ld a, $14
+ ld [bc], a
+ hlcoord 4, 8
+ ld de, wd26b
+ call PlaceString
+ ld a, $14
+ ld [bc], a
+ hlcoord 7, 1
+ ld de, PartySpecies
+ call Functionfb634
+ hlcoord 7, 9
+ ld de, OTPartySpecies
+
+Functionfb634: ; fb634
+ ld c, $0
+.asm_fb636
+ ld a, [de]
+ cp $ff
+ ret z
+ ld [wd265], a
+ push bc
+ push hl
+ push de
+ push hl
+ ld a, c
+ ld [hProduct], a
+ call GetPokemonName
+ pop hl
+ call PlaceString
+ pop de
+ inc de
+ pop hl
+ ld bc, SCREEN_WIDTH
+ add hl, bc
+ pop bc
+ inc c
+ jr .asm_fb636
+; fb656
+
+KantoMonSpecials: ; fb656
+; The original special base stat for
+; each Kanto monster from Red/Blue.
+ db 65 ; BULBASAUR
+ db 80 ; IVYSAUR
+ db 100 ; VENUSAUR
+ db 50 ; CHARMANDER
+ db 65 ; CHARMELEON
+ db 85 ; CHARIZARD
+ db 50 ; SQUIRTLE
+ db 65 ; WARTORTLE
+ db 85 ; BLASTOISE
+ db 20 ; CATERPIE
+ db 25 ; METAPOD
+ db 80 ; BUTTERFREE
+ db 20 ; WEEDLE
+ db 25 ; KAKUNA
+ db 45 ; BEEDRILL
+ db 35 ; PIDGEY
+ db 50 ; PIDGEOTTO
+ db 70 ; PIDGEOT
+ db 25 ; RATTATA
+ db 50 ; RATICATE
+ db 31 ; SPEAROW
+ db 61 ; FEAROW
+ db 40 ; EKANS
+ db 65 ; ARBOK
+ db 50 ; PIKACHU
+ db 90 ; RAICHU
+ db 30 ; SANDSHREW
+ db 55 ; SANDSLASH
+ db 40 ; NIDORAN_F
+ db 55 ; NIDORINA
+ db 75 ; NIDOQUEEN
+ db 40 ; NIDORAN_M
+ db 55 ; NIDORINO
+ db 75 ; NIDOKING
+ db 60 ; CLEFAIRY
+ db 85 ; CLEFABLE
+ db 65 ; VULPIX
+ db 100 ; NINETALES
+ db 25 ; JIGGLYPUFF
+ db 50 ; WIGGLYTUFF
+ db 40 ; ZUBAT
+ db 75 ; GOLBAT
+ db 75 ; ODDISH
+ db 85 ; GLOOM
+ db 100 ; VILEPLUME
+ db 55 ; PARAS
+ db 80 ; PARASECT
+ db 40 ; VENONAT
+ db 90 ; VENOMOTH
+ db 45 ; DIGLETT
+ db 70 ; DUGTRIO
+ db 40 ; MEOWTH
+ db 65 ; PERSIAN
+ db 50 ; PSYDUCK
+ db 80 ; GOLDUCK
+ db 35 ; MANKEY
+ db 60 ; PRIMEAPE
+ db 50 ; GROWLITHE
+ db 80 ; ARCANINE
+ db 40 ; POLIWAG
+ db 50 ; POLIWHIRL
+ db 70 ; POLIWRATH
+ db 105 ; ABRA
+ db 120 ; KADABRA
+ db 135 ; ALAKAZAM
+ db 35 ; MACHOP
+ db 50 ; MACHOKE
+ db 65 ; MACHAMP
+ db 70 ; BELLSPROUT
+ db 85 ; WEEPINBELL
+ db 100 ; VICTREEBEL
+ db 100 ; TENTACOOL
+ db 120 ; TENTACRUEL
+ db 30 ; GEODUDE
+ db 45 ; GRAVELER
+ db 55 ; GOLEM
+ db 65 ; PONYTA
+ db 80 ; RAPIDASH
+ db 40 ; SLOWPOKE
+ db 80 ; SLOWBRO
+ db 95 ; MAGNEMITE
+ db 120 ; MAGNETON
+ db 58 ; FARFETCH_D
+ db 35 ; DODUO
+ db 60 ; DODRIO
+ db 70 ; SEEL
+ db 95 ; DEWGONG
+ db 40 ; GRIMER
+ db 65 ; MUK
+ db 45 ; SHELLDER
+ db 85 ; CLOYSTER
+ db 100 ; GASTLY
+ db 115 ; HAUNTER
+ db 130 ; GENGAR
+ db 30 ; ONIX
+ db 90 ; DROWZEE
+ db 115 ; HYPNO
+ db 25 ; KRABBY
+ db 50 ; KINGLER
+ db 55 ; VOLTORB
+ db 80 ; ELECTRODE
+ db 60 ; EXEGGCUTE
+ db 125 ; EXEGGUTOR
+ db 40 ; CUBONE
+ db 50 ; MAROWAK
+ db 35 ; HITMONLEE
+ db 35 ; HITMONCHAN
+ db 60 ; LICKITUNG
+ db 60 ; KOFFING
+ db 85 ; WEEZING
+ db 30 ; RHYHORN
+ db 45 ; RHYDON
+ db 105 ; CHANSEY
+ db 100 ; TANGELA
+ db 40 ; KANGASKHAN
+ db 70 ; HORSEA
+ db 95 ; SEADRA
+ db 50 ; GOLDEEN
+ db 80 ; SEAKING
+ db 70 ; STARYU
+ db 100 ; STARMIE
+ db 100 ; MR__MIME
+ db 55 ; SCYTHER
+ db 95 ; JYNX
+ db 85 ; ELECTABUZZ
+ db 85 ; MAGMAR
+ db 55 ; PINSIR
+ db 70 ; TAUROS
+ db 20 ; MAGIKARP
+ db 100 ; GYARADOS
+ db 95 ; LAPRAS
+ db 48 ; DITTO
+ db 65 ; EEVEE
+ db 110 ; VAPOREON
+ db 110 ; JOLTEON
+ db 110 ; FLAREON
+ db 75 ; PORYGON
+ db 90 ; OMANYTE
+ db 115 ; OMASTAR
+ db 45 ; KABUTO
+ db 70 ; KABUTOPS
+ db 60 ; AERODACTYL
+ db 65 ; SNORLAX
+ db 125 ; ARTICUNO
+ db 125 ; ZAPDOS
+ db 125 ; MOLTRES
+ db 50 ; DRATINI
+ db 70 ; DRAGONAIR
+ db 100 ; DRAGONITE
+ db 154 ; MEWTWO
+ db 100 ; MEW
+; fb6ed
+
+
+INCLUDE "event/name_rater.asm"
+
+
+PlaySlowCry: ; fb841
+ ld a, [ScriptVar]
+ call LoadCryHeader
+ jr c, .done
+
+ ld hl, CryPitch
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld bc, -$140
+ add hl, bc
+ ld a, l
+ ld [CryPitch], a
+ ld a, h
+ ld [CryPitch + 1], a
+ ld hl, CryLength
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld bc, $60
+ add hl, bc
+ ld a, l
+ ld [CryLength], a
+ ld a, h
+ ld [CryLength + 1], a
+ callba _PlayCryHeader
+ call WaitSFX
+
+.done
+ ret
+; fb877
+
+NewPokedexEntry: ; fb877
+ ld a, [hMapAnims]
+ push af
+ xor a
+ ld [hMapAnims], a
+ call LowVolume
+ call ClearBGPalettes
+ call ClearTileMap
+ call UpdateSprites
+ call ClearSprites
+ ld a, [wPokedexStatus]
+ push af
+ ld a, [hSCX]
+ add $5
+ ld [hSCX], a
+ xor a
+ ld [wPokedexStatus], a
+ callba Function41a7f
+ call WaitPressAorB_BlinkCursor
+ ld a, $1
+ ld [wPokedexStatus], a
+ callba Function4424d
+ call WaitPressAorB_BlinkCursor
+ pop af
+ ld [wPokedexStatus], a
+ call MaxVolume
+ call FadeToWhite
+ ld a, [hSCX]
+ add $fb
+ ld [hSCX], a
+ call Functionfb8c8
+ pop af
+ ld [hMapAnims], a
+ ret
+; fb8c8
+
+Functionfb8c8: ; fb8c8
+ call ClearTileMap
+ call LoadFontsExtra
+ call LoadStandardFont
+ callba Function40ab2
+ call Function3200
+ callba GetEnemyMonDVs
+ ld a, [hli]
+ ld [TempMonDVs], a
+ ld a, [hl]
+ ld [TempMonDVs + 1], a
+ ld b, SCGB_1C
+ call GetSGBLayout
+ call SetPalettes
+ ret
+; fb8f1
+
+ConvertMon_2to1: ; fb8f1
+; Takes the Gen-2 Pokemon number stored in wd265, finds it in the Pokered_MonIndices table, and returns its index in wd265.
+ push bc
+ push hl
+ ld a, [wd265]
+ ld b, a
+ ld c, 0
+ ld hl, Pokered_MonIndices
+.loop
+ inc c
+ ld a, [hli]
+ cp b
+ jr nz, .loop
+ ld a, c
+ ld [wd265], a
+ pop hl
+ pop bc
+ ret
+; fb908
+
+ConvertMon_1to2: ; fb908
+; Takes the Gen-1 Pokemon number stored in wd265 and returns the corresponding value from Pokered_MonIndices in wd265.
+ push bc
+ push hl
+ ld a, [wd265]
+ dec a
+ ld hl, Pokered_MonIndices
+ ld b, 0
+ ld c, a
+ add hl, bc
+ ld a, [hl]
+ ld [wd265], a
+ pop hl
+ pop bc
+ ret
+; fb91c
+
+Pokered_MonIndices: ; fb91c
+ db RHYDON
+ db KANGASKHAN
+ db NIDORAN_M
+ db CLEFAIRY
+ db SPEAROW
+ db VOLTORB
+ db NIDOKING
+ db SLOWBRO
+ db IVYSAUR
+ db EXEGGUTOR
+ db LICKITUNG
+ db EXEGGCUTE
+ db GRIMER
+ db GENGAR
+ db NIDORAN_F
+ db NIDOQUEEN
+ db CUBONE
+ db RHYHORN
+ db LAPRAS
+ db ARCANINE
+ db MEW
+ db GYARADOS
+ db SHELLDER
+ db TENTACOOL
+ db GASTLY
+ db SCYTHER
+ db STARYU
+ db BLASTOISE
+ db PINSIR
+ db TANGELA
+ db SCIZOR
+ db SHUCKLE
+ db GROWLITHE
+ db ONIX
+ db FEAROW
+ db PIDGEY
+ db SLOWPOKE
+ db KADABRA
+ db GRAVELER
+ db CHANSEY
+ db MACHOKE
+ db MR__MIME
+ db HITMONLEE
+ db HITMONCHAN
+ db ARBOK
+ db PARASECT
+ db PSYDUCK
+ db DROWZEE
+ db GOLEM
+ db HERACROSS
+ db MAGMAR
+ db HO_OH
+ db ELECTABUZZ
+ db MAGNETON
+ db KOFFING
+ db SNEASEL
+ db MANKEY
+ db SEEL
+ db DIGLETT
+ db TAUROS
+ db TEDDIURSA
+ db URSARING
+ db SLUGMA
+ db FARFETCH_D
+ db VENONAT
+ db DRAGONITE
+ db MAGCARGO
+ db SWINUB
+ db PILOSWINE
+ db DODUO
+ db POLIWAG
+ db JYNX
+ db MOLTRES
+ db ARTICUNO
+ db ZAPDOS
+ db DITTO
+ db MEOWTH
+ db KRABBY
+ db CORSOLA
+ db REMORAID
+ db OCTILLERY
+ db VULPIX
+ db NINETALES
+ db PIKACHU
+ db RAICHU
+ db DELIBIRD
+ db MANTINE
+ db DRATINI
+ db DRAGONAIR
+ db KABUTO
+ db KABUTOPS
+ db HORSEA
+ db SEADRA
+ db SKARMORY
+ db HOUNDOUR
+ db SANDSHREW
+ db SANDSLASH
+ db OMANYTE
+ db OMASTAR
+ db JIGGLYPUFF
+ db WIGGLYTUFF
+ db EEVEE
+ db FLAREON
+ db JOLTEON
+ db VAPOREON
+ db MACHOP
+ db ZUBAT
+ db EKANS
+ db PARAS
+ db POLIWHIRL
+ db POLIWRATH
+ db WEEDLE
+ db KAKUNA
+ db BEEDRILL
+ db HOUNDOOM
+ db DODRIO
+ db PRIMEAPE
+ db DUGTRIO
+ db VENOMOTH
+ db DEWGONG
+ db KINGDRA
+ db PHANPY
+ db CATERPIE
+ db METAPOD
+ db BUTTERFREE
+ db MACHAMP
+ db DONPHAN
+ db GOLDUCK
+ db HYPNO
+ db GOLBAT
+ db MEWTWO
+ db SNORLAX
+ db MAGIKARP
+ db PORYGON2
+ db STANTLER
+ db MUK
+ db SMEARGLE
+ db KINGLER
+ db CLOYSTER
+ db TYROGUE
+ db ELECTRODE
+ db CLEFABLE
+ db WEEZING
+ db PERSIAN
+ db MAROWAK
+ db HITMONTOP
+ db HAUNTER
+ db ABRA
+ db ALAKAZAM
+ db PIDGEOTTO
+ db PIDGEOT
+ db STARMIE
+ db BULBASAUR
+ db VENUSAUR
+ db TENTACRUEL
+ db SMOOCHUM
+ db GOLDEEN
+ db SEAKING
+ db ELEKID
+ db MAGBY
+ db MILTANK
+ db BLISSEY
+ db PONYTA
+ db RAPIDASH
+ db RATTATA
+ db RATICATE
+ db NIDORINO
+ db NIDORINA
+ db GEODUDE
+ db PORYGON
+ db AERODACTYL
+ db RAIKOU
+ db MAGNEMITE
+ db ENTEI
+ db SUICUNE
+ db CHARMANDER
+ db SQUIRTLE
+ db CHARMELEON
+ db WARTORTLE
+ db CHARIZARD
+ db LARVITAR
+ db PUPITAR
+ db TYRANITAR
+ db LUGIA
+ db ODDISH
+ db GLOOM
+ db VILEPLUME
+ db BELLSPROUT
+ db WEEPINBELL
+ db VICTREEBEL
+ db CHIKORITA
+ db BAYLEEF
+ db MEGANIUM
+ db CYNDAQUIL
+ db QUILAVA
+ db TYPHLOSION
+ db TOTODILE
+ db CROCONAW
+ db FERALIGATR
+ db SENTRET
+ db FURRET
+ db HOOTHOOT
+ db NOCTOWL
+ db LEDYBA
+ db LEDIAN
+ db SPINARAK
+ db ARIADOS
+ db CROBAT
+ db CHINCHOU
+ db LANTURN
+ db PICHU
+ db CLEFFA
+ db IGGLYBUFF
+ db TOGEPI
+ db TOGETIC
+ db NATU
+ db XATU
+ db MAREEP
+ db FLAAFFY
+ db AMPHAROS
+ db BELLOSSOM
+ db MARILL
+ db AZUMARILL
+ db SUDOWOODO
+ db POLITOED
+ db HOPPIP
+ db SKIPLOOM
+ db JUMPLUFF
+ db AIPOM
+ db SUNKERN
+ db SUNFLORA
+ db YANMA
+ db WOOPER
+ db QUAGSIRE
+ db ESPEON
+ db UMBREON
+ db MURKROW
+ db SLOWKING
+ db MISDREAVUS
+ db UNOWN
+ db WOBBUFFET
+ db GIRAFARIG
+ db PINECO
+ db FORRETRESS
+ db DUNSPARCE
+ db GLIGAR
+ db STEELIX
+ db SNUBBULL
+ db GRANBULL
+ db QWILFISH
+ db WOBBUFFET
+ db WOBBUFFET
+; fba18
--- /dev/null
+++ b/engine/variables.asm
@@ -1,0 +1,150 @@
+_GetVarAction:: ; 80648 (20:4648)
+ ld a, c
+ cp NUM_VARS
+ jr c, .valid
+ xor a
+.valid
+ ld c, a
+ ld b, 0
+ ld hl, .VarActionTable
+rept 3
+ add hl, bc
+endr
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ inc hl
+ ld b, [hl]
+ ld a, b
+ and RETVAR_EXECUTE
+ jr nz, .call
+ ld a, b
+ and RETVAR_ADDR_DE
+ ret nz
+ ld a, [de]
+ jr .loadstringbuffer2
+
+.call
+ call _de_
+ ret
+
+.loadstringbuffer2: ; 8066c (20:466c)
+ ld de, StringBuffer2
+ ld [de], a
+ ret
+; 80671 (20:4671)
+
+.VarActionTable: ; 80671
+; $00: copy [de] to StringBuffer2
+; $40: return address in de
+; $80: call function
+ dwb StringBuffer2, RETVAR_STRBUF2
+ dwb PartyCount, RETVAR_STRBUF2
+ dwb .BattleResult, RETVAR_EXECUTE
+ dwb BattleType, RETVAR_ADDR_DE
+ dwb TimeOfDay, RETVAR_STRBUF2
+ dwb .CountCaughtMons, RETVAR_EXECUTE
+ dwb .CountSeenMons, RETVAR_EXECUTE
+ dwb .CountBadges, RETVAR_EXECUTE
+ dwb PlayerState, RETVAR_ADDR_DE
+ dwb .PlayerFacing, RETVAR_EXECUTE
+ dwb hHours, RETVAR_STRBUF2
+ dwb .DayOfWeek, RETVAR_EXECUTE
+ dwb MapGroup, RETVAR_STRBUF2
+ dwb MapNumber, RETVAR_STRBUF2
+ dwb .UnownCaught, RETVAR_EXECUTE
+ dwb wPermission, RETVAR_STRBUF2
+ dwb .BoxFreeSpace, RETVAR_EXECUTE
+ dwb wBugContestMinsRemaining, RETVAR_STRBUF2
+ dwb XCoord, RETVAR_STRBUF2
+ dwb YCoord, RETVAR_STRBUF2
+ dwb wSpecialPhoneCallID, RETVAR_STRBUF2
+ dwb wcf64, RETVAR_STRBUF2
+ dwb wKurtApricornQuantity, RETVAR_STRBUF2
+ dwb wCurrentCaller, RETVAR_ADDR_DE
+ dwb wBlueCardBalance, RETVAR_ADDR_DE
+ dwb wBuenasPassword, RETVAR_ADDR_DE
+ dwb wdc58, RETVAR_STRBUF2
+ dwb NULL, RETVAR_STRBUF2
+; 806c5
+
+.CountCaughtMons: ; 806c5
+; Caught mons.
+ ld hl, PokedexCaught
+ ld b, EndPokedexCaught - PokedexCaught
+ call CountSetBits
+ ld a, [wd265]
+ jp .loadstringbuffer2
+; 806d3
+
+.CountSeenMons: ; 806d3
+; Seen mons.
+ ld hl, PokedexSeen
+ ld b, EndPokedexSeen - PokedexSeen
+ call CountSetBits
+ ld a, [wd265]
+ jp .loadstringbuffer2
+; 806e1
+
+.CountBadges: ; 806e1
+; Number of owned badges.
+ ld hl, Badges
+ ld b, 2
+ call CountSetBits
+ ld a, [wd265]
+ jp .loadstringbuffer2
+; 806ef
+
+.PlayerFacing: ; 806ef
+; The direction the player is facing.
+ ld a, [PlayerDirection]
+ and $c
+ rrca
+ rrca
+ jp .loadstringbuffer2
+; 806f9
+
+.DayOfWeek: ; 806f9
+; The day of the week.
+ call GetWeekday
+ jp .loadstringbuffer2
+; 806ff
+
+.UnownCaught: ; 806ff
+; Number of unique Unown caught.
+ call .count
+ ld a, b
+ jp .loadstringbuffer2
+
+.count
+ ld hl, UnownDex
+ ld b, 0
+.loop
+ ld a, [hli]
+ and a
+ ret z
+ inc b
+ ld a, b
+ cp 26
+ jr c, .loop
+ ret
+; 80715
+
+.BoxFreeSpace: ; 80715
+; Remaining slots in the current box.
+ ld a, BANK(sBoxCount)
+ call GetSRAMBank
+ ld hl, sBoxCount
+ ld a, MONS_PER_BOX
+ sub [hl]
+ ld b, a
+ call CloseSRAM
+ ld a, b
+ jp .loadstringbuffer2
+; 80728
+
+.BattleResult: ; 80728
+ ld a, [wBattleResult]
+ and $3f
+ jp .loadstringbuffer2
+; 80730
--- /dev/null
+++ b/event/halloffame.asm
@@ -1,0 +1,628 @@
+HallOfFame:: ; 0x8640e
+ call Function8648e
+ ld a, [StatusFlags]
+ push af
+ ld a, 1
+ ld [wc2cd], a
+ call DisableSpriteUpdates
+ ld a, SPAWN_LANCE
+ ld [wSpawnAfterChampion], a
+
+ ; Enable the Pokégear map to cycle through all of Kanto
+ ld hl, StatusFlags
+ set 6, [hl] ; hall of fame
+
+ callba Function14da0
+
+ ld hl, wHallOfFameCount
+ ld a, [hl]
+ cp 200
+ jr nc, .ok
+ inc [hl]
+.ok
+ callba SaveGameData
+ call GetHallOfFameParty
+ callba AddHallOfFameEntry
+
+ xor a
+ ld [wc2cd], a
+ call Function864c3
+ pop af
+ ld b, a
+ callba Function109847
+ ret
+; 0x86455
+
+RedCredits:: ; 86455
+ ld a, MUSIC_NONE % $100
+ ld [MusicFadeIDLo], a
+ ld a, MUSIC_NONE / $100
+ ld [MusicFadeIDHi], a
+ ld a, $a
+ ld [MusicFade], a
+ callba FadeOutPalettes
+ xor a
+ ld [VramState], a
+ ld [hMapAnims], a
+ callba Function4e8c2
+ ld c, 8
+ call DelayFrames
+ call DisableSpriteUpdates
+ ld a, SPAWN_RED
+ ld [wSpawnAfterChampion], a
+ ld a, [StatusFlags]
+ ld b, a
+ callba Function109847
+ ret
+; 8648e
+
+Function8648e: ; 8648e
+ ld a, MUSIC_NONE % $100
+ ld [MusicFadeIDLo], a
+ ld a, MUSIC_NONE / $100
+ ld [MusicFadeIDHi], a
+ ld a, 10
+ ld [MusicFade], a
+ callba FadeOutPalettes
+ xor a
+ ld [VramState], a
+ ld [hMapAnims], a
+ callba Function4e881
+ ld c, 100
+ jp DelayFrames
+; 864b4
+
+Function864b4: ; 864b4
+ push de
+ ld de, MUSIC_NONE
+ call PlayMusic
+ call DelayFrame
+ pop de
+ call PlayMusic
+ ret
+; 864c3
+
+Function864c3: ; 864c3
+ xor a
+ ld [wJumptableIndex], a
+ call Function8671c
+ jr c, .done
+ ld de, SCREEN_WIDTH
+ call Function864b4
+ xor a
+ ld [wcf64], a
+.loop
+ ld a, [wcf64]
+ cp 6
+ jr nc, .done
+ ld hl, wc608 + 1
+ ld bc, $10
+ call AddNTimes
+ ld a, [hl]
+ cp -1
+ jr z, .done
+ push hl
+ call Function865b5
+ pop hl
+ call Function8650c
+ jr c, .done
+ ld hl, wcf64
+ inc [hl]
+ jr .loop
+
+.done
+ call Function86810
+ ld a, $4
+ ld [MusicFade], a
+ call FadeToWhite
+ ld c, 8
+ call DelayFrames
+ ret
+; 8650c
+
+Function8650c: ; 8650c
+ call Function86748
+ ld de, String_8652c
+ hlcoord 1, 2
+ call PlaceString
+ call WaitBGMap
+ decoord 6, 5
+ ld c, $6
+ predef Functiond066e
+ ld c, 60
+ call DelayFrames
+ and a
+ ret
+; 8652c
+
+String_8652c:
+ db "New Hall of Famer!@"
+; 8653f
+
+
+GetHallOfFameParty: ; 8653f
+ ld hl, OverworldMap
+ ld bc, HOF_LENGTH
+ xor a
+ call ByteFill
+ ld a, [wHallOfFameCount]
+ ld de, OverworldMap
+ ld [de], a
+ inc de
+ ld hl, PartySpecies
+ ld c, 0
+.next
+ ld a, [hli]
+ cp -1
+ jr z, .done
+ cp EGG
+ jr nz, .mon
+ inc c
+ jr .next
+
+.mon
+ push hl
+ push de
+ push bc
+
+ ld a, c
+ ld hl, PartyMons
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call AddNTimes
+ ld c, l
+ ld b, h
+
+ ld hl, MON_SPECIES
+ add hl, bc
+ ld a, [hl]
+ ld [de], a
+ inc de
+
+ ld hl, MON_ID
+ add hl, bc
+ ld a, [hli]
+ ld [de], a
+ inc de
+ ld a, [hl]
+ ld [de], a
+ inc de
+
+ ld hl, MON_DVS
+ add hl, bc
+ ld a, [hli]
+ ld [de], a
+ inc de
+ ld a, [hl]
+ ld [de], a
+ inc de
+
+ ld hl, MON_LEVEL
+ add hl, bc
+ ld a, [hl]
+ ld [de], a
+ inc de
+
+ pop bc
+ push bc
+ ld a, c
+ ld hl, PartyMonNicknames
+ ld bc, PKMN_NAME_LENGTH
+ call AddNTimes
+ ld bc, PKMN_NAME_LENGTH - 1
+ call CopyBytes
+
+ pop bc
+ inc c
+ pop de
+ ld hl, HOF_MON_LENGTH
+ add hl, de
+ ld e, l
+ ld d, h
+ pop hl
+ jr .next
+
+.done
+ ld a, $ff
+ ld [de], a
+ ret
+; 865b5
+
+Function865b5: ; 865b5
+ push hl
+ call ClearBGPalettes
+ callba Function4e906
+ pop hl
+ ld a, [hli]
+ ld [TempMonSpecies], a
+ ld [CurPartySpecies], a
+rept 2
+ inc hl
+endr
+ ld a, [hli]
+ ld [TempMonDVs], a
+ ld a, [hli]
+ ld [TempMonDVs + 1], a
+ ld hl, TempMonDVs
+ predef GetUnownLetter
+ hlcoord 0, 0
+ ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
+ ld a, " "
+ call ByteFill
+ ld de, VTiles2 tile $31
+ predef GetBackpic
+ ld a, $31
+ ld [hFillBox], a
+ hlcoord 6, 6
+ lb bc, 6, 6
+ predef FillBox
+ ld a, $d0
+ ld [hSCY], a
+ ld a, $90
+ ld [hSCX], a
+ call WaitBGMap
+ xor a
+ ld [hBGMapMode], a
+ ld b, SCGB_1A
+ call GetSGBLayout
+ call SetPalettes
+ call Function86635
+ xor a
+ ld [wc2c6], a
+ hlcoord 0, 0
+ ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
+ ld a, " "
+ call ByteFill
+ hlcoord 6, 5
+ call _PrepMonFrontpic
+ call WaitBGMap
+ xor a
+ ld [hBGMapMode], a
+ ld [hSCY], a
+ call Function86643
+ ret
+; 86635
+
+Function86635: ; 86635
+.loop
+ ld a, [hSCX]
+ cp $70
+ ret z
+ add $4
+ ld [hSCX], a
+ call DelayFrame
+ jr .loop
+; 86643
+
+Function86643: ; 86643
+.loop
+ ld a, [hSCX]
+ and a
+ ret z
+rept 2
+ dec a
+endr
+ ld [hSCX], a
+ call DelayFrame
+ jr .loop
+; 86650
+
+_HallOfFamePC: ; 86650
+ call LoadFontsBattleExtra
+ xor a
+ ld [wJumptableIndex], a
+.loop
+ call Function8671c
+ ret c
+ call Function86665
+ ret c
+ ld hl, wJumptableIndex
+ inc [hl]
+ jr .loop
+; 86665
+
+Function86665: ; 86665
+ xor a
+ ld [wcf64], a
+.next
+ call Function86692
+ jr c, .start_button
+.loop
+ call JoyTextDelay
+ ld hl, hJoyLast
+ ld a, [hl]
+ and B_BUTTON
+ jr nz, .b_button
+ ld a, [hl]
+ and A_BUTTON
+ jr nz, .a_button
+ ld a, [hl]
+ and START
+ jr nz, .start_button
+ call DelayFrame
+ jr .loop
+
+.a_button
+ ld hl, wcf64
+ inc [hl]
+ jr .next
+
+.b_button
+ scf
+ ret
+
+.start_button
+ and a
+ ret
+; 86692
+
+Function86692: ; 86692
+; Print the number of times the player has entered the Hall of Fame.
+; If that number is above 200, print "HOF Master!" instead.
+ ld a, [wcf64]
+ cp $6
+ jr nc, .fail
+ ld hl, wc608 + 1
+ ld bc, $10
+ call AddNTimes
+ ld a, [hl]
+ cp $ff
+ jr nz, .okay
+
+.fail
+ scf
+ ret
+
+.okay
+ push hl
+ call ClearBGPalettes
+ pop hl
+ call Function86748
+ ld a, [wc608]
+ cp 200 + 1
+ jr c, .print_num_hof
+ ld de, String_866fc
+ hlcoord 1, 2
+ call PlaceString
+ hlcoord 13, 2
+ jr .finish
+
+.print_num_hof
+ ld de, String_8670c
+ hlcoord 1, 2
+ call PlaceString
+ hlcoord 2, 2
+ ld de, wc608
+ lb bc, 1, 3
+ call PrintNum
+ hlcoord 11, 2
+
+.finish
+ ld de, String_866fb
+ call PlaceString
+ call WaitBGMap
+ ld b, SCGB_1A
+ call GetSGBLayout
+ call SetPalettes
+ decoord 6, 5
+ ld c, $6
+ predef Functiond066e
+ and a
+ ret
+; 866fb
+
+String_866fb:
+ db "@"
+; 866fc
+
+String_866fc:
+ db " HOF Master!@"
+; 8670c
+
+String_8670c:
+ db " -Time Famer@"
+; 8671c
+
+
+Function8671c: ; 8671c
+ ld a, [wJumptableIndex]
+ cp NUM_HOF_TEAMS
+ jr nc, .full
+ ld hl, sHallOfFame
+ ld bc, HOF_LENGTH
+ call AddNTimes
+ ld a, BANK(sHallOfFame)
+ call GetSRAMBank
+ ld a, [hl]
+ and a
+ jr z, .fail
+ ld de, wc608
+ ld bc, HOF_LENGTH
+ call CopyBytes
+ call CloseSRAM
+ and a
+ ret
+
+.fail
+ call CloseSRAM
+
+.full
+ scf
+ ret
+; 86748
+
+Function86748: ; 86748
+ xor a
+ ld [hBGMapMode], a
+ ld a, [hli]
+ ld [TempMonSpecies], a
+ ld a, [hli]
+ ld [TempMonID], a
+ ld a, [hli]
+ ld [TempMonID + 1], a
+ ld a, [hli]
+ ld [TempMonDVs], a
+ ld a, [hli]
+ ld [TempMonDVs + 1], a
+ ld a, [hli]
+ ld [TempMonLevel], a
+ ld de, StringBuffer2
+ ld bc, 10
+ call CopyBytes
+ ld a, "@"
+ ld [StringBuffer2 + 10], a
+ hlcoord 0, 0
+ ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
+ ld a, " "
+ call ByteFill
+ hlcoord 0, 0
+ lb bc, 3, SCREEN_WIDTH - 2
+ call TextBox
+ hlcoord 0, 12
+ lb bc, 4, SCREEN_WIDTH - 2
+ call TextBox
+ ld a, [TempMonSpecies]
+ ld [CurPartySpecies], a
+ ld [wd265], a
+ ld hl, TempMonDVs
+ predef GetUnownLetter
+ xor a
+ ld [wc2c6], a
+ hlcoord 6, 5
+ call _PrepMonFrontpic
+ ld a, [CurPartySpecies]
+ cp EGG
+ jr z, .print_id_no
+ hlcoord 1, 13
+ ld a, "№"
+ ld [hli], a
+ ld [hl], "·"
+ hlcoord 3, 13
+ ld de, wd265
+ lb bc, PRINTNUM_LEADINGZEROS | 1, 3
+ call PrintNum
+ call GetBasePokemonName
+ hlcoord 7, 13
+ call PlaceString
+ ld a, BREEDMON
+ ld [MonType], a
+ callba GetGender
+ ld a, " "
+ jr c, .got_gender
+ ld a, "♂"
+ jr nz, .got_gender
+ ld a, "♀"
+
+.got_gender
+ hlcoord 18, 13
+ ld [hli], a
+ hlcoord 8, 14
+ ld a, "/"
+ ld [hli], a
+ ld de, StringBuffer2
+ call PlaceString
+ hlcoord 1, 16
+ call PrintLevel
+
+.print_id_no
+ hlcoord 7, 16
+ ld a, "<ID>"
+ ld [hli], a
+ ld a, "№"
+ ld [hli], a
+ ld [hl], "/"
+ hlcoord 10, 16
+ ld de, TempMonID
+ lb bc, PRINTNUM_LEADINGZEROS | 2, 5
+ call PrintNum
+ ret
+; 86810
+
+Function86810: ; 86810
+ call ClearBGPalettes
+ ld hl, VTiles2 tile $63
+ ld de, FontExtra + $d0
+ lb bc, BANK(FontExtra), 1
+ call Request2bpp
+ hlcoord 0, 0
+ ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
+ ld a, " "
+ call ByteFill
+ callba GetPlayerBackpic
+ ld a, $31
+ ld [hFillBox], a
+ hlcoord 6, 6
+ lb bc, 6, 6
+ predef FillBox
+ ld a, $d0
+ ld [hSCY], a
+ ld a, $90
+ ld [hSCX], a
+ call WaitBGMap
+ xor a
+ ld [hBGMapMode], a
+ ld [CurPartySpecies], a
+ ld b, SCGB_1A
+ call GetSGBLayout
+ call SetPalettes
+ call Function86635
+ xor a
+ ld [wc2c6], a
+ hlcoord 0, 0
+ ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
+ ld a, " "
+ call ByteFill
+ callba Function88840
+ xor a
+ ld [hFillBox], a
+ hlcoord 12, 5
+ lb bc, 7, 7
+ predef FillBox
+ ld a, $c0
+ ld [hSCX], a
+ call WaitBGMap
+ xor a
+ ld [hBGMapMode], a
+ ld [hSCY], a
+ call Function86643
+ xor a
+ ld [hBGMapMode], a
+ hlcoord 0, 2
+ lb bc, 8, 9
+ call TextBox
+ hlcoord 0, 12
+ lb bc, 4, 18
+ call TextBox
+ hlcoord 2, 4
+ ld de, PlayerName
+ call PlaceString
+ hlcoord 1, 6
+ ld a, "<ID>"
+ ld [hli], a
+ ld a, "№"
+ ld [hli], a
+ ld [hl], "/"
+ hlcoord 4, 6
+ ld de, PlayerID
+ lb bc, PRINTNUM_LEADINGZEROS | 2, 5
+ call PrintNum
+ hlcoord 1, 8
+ ld de, .PlayTime
+ call PlaceString
+ hlcoord 3, 9
+ ld de, GameTimeHours
+ lb bc, 2, 3
+ call PrintNum
+ ld [hl], 99
+ inc hl
+ ld de, GameTimeMinutes
+ lb bc, PRINTNUM_LEADINGZEROS | 1, 2
+ call PrintNum
+ call WaitBGMap
+ callba Function26601
+ ret
+; 868ed
+
+.PlayTime
+ db "PLAY TIME@"
+; 868f7
+
--- /dev/null
+++ b/event/mom_phone.asm
@@ -1,0 +1,285 @@
+MomTriesToBuySomething:: ; fcfec
+ ld a, [wMapReentryScriptQueueFlag]
+ and a
+ ret nz
+ call GetMapHeaderPhoneServiceNybble
+ and a
+ ret nz
+ xor a
+ ld [wdc18], a
+ call CheckBalance_MomItem2
+ ret nc
+ call Functionfd0c3
+ ret nc
+ ld b, BANK(UnknownScript_0xfd00f)
+ ld de, UnknownScript_0xfd00f
+ callba LoadScriptBDE
+ scf
+ ret
+; fd00f
+
+UnknownScript_0xfd00f: ; 0xfd00f
+ callasm Functionfd017
+ farjump Script_ReceivePhoneCall
+; 0xfd017
+
+Functionfd017: ; fd017
+ call MomBuysItem_DeductFunds
+ call Functionfd0eb
+ ld a, [wdc18]
+ and a
+ jr nz, .ok
+ ld hl, wdc17
+ inc [hl]
+.ok
+ ld a, 1
+ ld [wCurrentCaller], a
+ ld bc, wd03f
+ ld hl, 0
+ add hl, bc
+ ld [hl], 0
+ inc hl
+ ld [hl], 1
+ ld hl, 9
+ add hl, bc
+ ld a, $3f
+ ld [hli], a
+ ld a, e
+ ld [hli], a
+ ld a, d
+ ld [hl], a
+ ret
+; fd044
+
+CheckBalance_MomItem2: ; fd044
+ ld a, [wdc17]
+ cp 10
+ jr nc, .nope
+ call GetItemFromMom
+ ld a, [hli]
+ ld [hMoneyTemp], a
+ ld a, [hli]
+ ld [hMoneyTemp + 1], a
+ ld a, [hli]
+ ld [hMoneyTemp + 2], a
+ ld de, wMomsMoney
+ ld bc, hMoneyTemp
+ callba CompareMoney
+ jr nc, .have_enough_money
+
+.nope
+ jr .check_have_2300
+
+.have_enough_money
+ scf
+ ret
+
+.check_have_2300
+ ld hl, hMoneyTemp
+ ld [hl], (2300 / $10000) ; $00
+ inc hl
+ ld [hl], ((2300 % $10000) / $100) ; $08
+ inc hl
+ ld [hl], (2300 % $100) ; $fc
+.loop
+ ld de, wdc19
+ ld bc, wMomsMoney
+ callba CompareMoney
+ jr z, .exact
+ jr nc, .less_than
+ call Functionfd099
+ jr .loop
+
+.less_than
+ xor a
+ ret
+
+.exact
+ call Functionfd099
+ ld a, 5
+ call RandomRange
+ inc a
+ ld [wdc18], a
+ scf
+ ret
+; fd099
+
+Functionfd099: ; fd099
+ ld de, wdc19
+ ld bc, hMoneyTemp
+ callba AddMoney
+ ret
+; fd0a6
+
+
+MomBuysItem_DeductFunds: ; fd0a6 (3f:50a6)
+ call GetItemFromMom
+ ld de, 3
+ add hl, de
+ ld a, [hli]
+ ld [hMoneyTemp], a
+ ld a, [hli]
+ ld [hMoneyTemp + 1], a
+ ld a, [hli]
+ ld [hMoneyTemp + 2], a
+ ld de, wMomsMoney
+ ld bc, hMoneyTemp
+ callba TakeMoney
+ ret
+
+
+Functionfd0c3: ; fd0c3
+ call GetItemFromMom
+ ld de, 6
+ add hl, de
+ ld a, [hli]
+ cp 1
+ jr z, .not_doll
+ ld a, [hl]
+ ld c, a
+ ld b, 1
+ callba DecorationFlagAction_c
+ scf
+ ret
+
+.not_doll
+ ld a, [hl]
+ ld [CurItem], a
+ ld a, $1
+ ld [wItemQuantityChangeBuffer], a
+ ld hl, PCItems
+ call ReceiveItem
+ ret
+; fd0eb
+
+
+Functionfd0eb: ; fd0eb (3f:50eb)
+ call GetItemFromMom
+ ld de, 6 ; field
+ add hl, de
+ ld a, [hli]
+ ld de, Script_MomBoughtItem
+ cp 1
+ ret z
+ ld de, Script_MomBoughtDoll
+ ret
+; fd0fd (3f:50fd)
+
+Script_MomBoughtItem: ; 0xfd0fd
+ writetext _MomText_HiHowAreYou
+ writetext _MomText_FoundAnItem
+ writetext _MomText_BoughtWithYourMoney
+ writetext _MomText_ItsInPC
+ end
+; 0xfd10a
+
+Script_MomBoughtDoll: ; 0xfd10a
+ writetext _MomText_HiHowAreYou
+ writetext _MomText_FoundADoll
+ writetext _MomText_BoughtWithYourMoney
+ writetext _MomText_ItsInRoom
+ end
+; 0xfd117
+
+
+GetItemFromMom: ; fd117
+ ld a, [wdc18]
+ and a
+ jr z, .zero
+ dec a
+ ld de, MomItems_1
+ jr .incave
+
+.zero
+ ld a, [wdc17]
+ cp 10 ; length of MomItems_2
+ jr c, .ok
+ xor a
+
+.ok
+ ld de, MomItems_2
+
+.incave
+ ld l, a
+ ld h, 0
+rept 3 ; multiply hl by 8
+ add hl, hl
+endr
+ add hl, de
+ ret
+; fd136
+
+momitem: macro
+; money to trigger, cost, kind, item
+ dt \1
+ dt \2
+ db \3, \4
+ENDM
+
+
+MomItems_1: ; fd136
+ momitem 0, 600, MOM_ITEM, SUPER_POTION
+ momitem 0, 90, MOM_ITEM, ANTIDOTE
+ momitem 0, 180, MOM_ITEM, POKE_BALL
+ momitem 0, 450, MOM_ITEM, ESCAPE_ROPE
+ momitem 0, 500, MOM_ITEM, GREAT_BALL
+; fd15e
+
+MomItems_2: ; fd15e
+ momitem 900, 600, MOM_ITEM, SUPER_POTION
+ momitem 4000, 270, MOM_ITEM, REPEL
+ momitem 7000, 600, MOM_ITEM, SUPER_POTION
+ momitem 10000, 1800, MOM_DOLL, DECO_CHARMANDER_DOLL
+ momitem 15000, 3000, MOM_ITEM, MOON_STONE
+ momitem 19000, 600, MOM_ITEM, SUPER_POTION
+ momitem 30000, 4800, MOM_DOLL, DECO_CLEFAIRY_DOLL
+ momitem 40000, 900, MOM_ITEM, HYPER_POTION
+ momitem 50000, 8000, MOM_DOLL, DECO_PIKACHU_DOLL
+ momitem 100000, 22800, MOM_DOLL, DECO_BIG_SNORLAX_DOLL
+; fd1ae
+
+ db 0, 0, 0 ; XXX
+
+_MomText_HiHowAreYou: ; 0xfd1b1
+ ; Hi, ! How are you?
+ text_jump UnknownText_0x1bc615
+ db "@"
+; 0xfd1b6
+
+_MomText_FoundAnItem: ; 0xfd1b6
+ ; I found a useful item shopping, so
+ text_jump UnknownText_0x1bc62a
+ db "@"
+; 0xfd1bb
+
+_MomText_BoughtWithYourMoney: ; 0xfd1bb
+ ; I bought it with your money. Sorry!
+ text_jump UnknownText_0x1bc64e
+ db "@"
+; 0xfd1c0
+
+_MomText_ItsInPC: ; 0xfd1c0
+ ; It's in your PC. You'll like it!
+ text_jump UnknownText_0x1bc673
+ db "@"
+; 0xfd1c5
+
+_MomText_FoundADoll: ; 0xfd1c5
+ ; While shopping today, I saw this adorable doll, so
+ text_jump UnknownText_0x1bc693
+ db "@"
+; 0xfd1ca
+
+_MomText_ItsInRoom: ; 0xfd1ca
+ ; It's in your room. You'll love it!
+ text_jump UnknownText_0x1bc6c7
+ db "@"
+; 0xfd1cf
+
+ db 0 ; XXX
+
+Functionfd1d0: ; fd1d0
+ ret
+; fd1d1
+
+ ret ; XXX
--- /dev/null
+++ b/gfx/font.asm
@@ -1,0 +1,236 @@
+FontExtra:
+INCBIN "gfx/misc/font_extra.2bpp"
+
+Font:
+INCBIN "gfx/misc/font.1bpp"
+
+FontBattleExtra:
+INCBIN "gfx/misc/font_battle_extra.2bpp"
+
+Frames: ; f8800
+INCBIN "gfx/frames/1.1bpp"
+INCBIN "gfx/frames/2.1bpp"
+INCBIN "gfx/frames/3.1bpp"
+INCBIN "gfx/frames/4.1bpp"
+INCBIN "gfx/frames/5.1bpp"
+INCBIN "gfx/frames/6.1bpp"
+INCBIN "gfx/frames/7.1bpp"
+INCBIN "gfx/frames/8.1bpp"
+INCBIN "gfx/frames/9.1bpp"
+; f89b0
+
+; TODO: Various misc graphics here.
+
+GFX_f89b0: ; f89b0
+INCBIN "gfx/unknown/0f89b0.2bpp"
+; f8a90
+
+ShinyIcon: ; f8a90
+INCBIN "gfx/stats/shiny.2bpp"
+
+GFX_f8aa0: ; f8aa0
+INCBIN "gfx/unknown/0f8aa0.2bpp"
+; f8ac0
+
+EnemyHPBarBorderGFX: ; f8ac0
+INCBIN "gfx/battle/enemy_hp_bar_border.1bpp"
+; f8ae0
+
+HPExpBarBorderGFX: ; f8ae0
+INCBIN "gfx/battle/hp_exp_bar_border.1bpp"
+; f8b10
+
+ExpBarGFX: ; f8b10
+INCBIN "gfx/battle/expbar.2bpp"
+; f8ba0
+
+TownMapGFX: ; f8ba0
+INCBIN "gfx/misc/town_map.2bpp.lz"
+; f8ea4
+
+GFX_f8ea4: ; unused
+INCBIN "gfx/unknown/0f8ea4.2bpp"
+; f8f24
+
+OverworldPhoneIconGFX: ; f8f24
+INCBIN "gfx/mobile/overworld_phone_icon.2bpp"
+; f8f34
+
+GFX_f8f34: ; unused
+INCBIN "gfx/unknown/0f8f34.2bpp"
+; f9204
+
+TextBoxSpaceGFX: ; f9204
+INCBIN "gfx/frames/space.2bpp"
+; f9214
+
+MobilePhoneTilesGFX: ; f9214
+INCBIN "gfx/mobile/phone_tiles.2bpp"
+; f9344
+
+MapEntryFrameGFX: ; f9344
+INCBIN "gfx/frames/map_entry_sign.2bpp"
+; f9424
+
+GFX_f9424: ; f9424
+INCBIN "gfx/unknown/0f9424.2bpp"
+; f9434
+
+Footprints: ; f9434
+INCBIN "gfx/misc/footprints.1bpp"
+; fb434
+
+; This and the following two functions are unreferenced.
+Unknown_fb434:
+ db 0
+
+Functionfb435: ; 4b435
+ ld a, [Unknown_fb434]
+ and a
+ jp nz, Get1bpp_2
+ jp Get1bpp
+; fb43f
+
+Functionfb43f: ; fb43f
+ ld a, [Unknown_fb434]
+ and a
+ jp nz, Get2bpp_2
+ jp Get2bpp
+; End unreferenced block
+; fb449
+
+_LoadStandardFont:: ; fb449
+ ld de, Font
+ ld hl, VTiles1
+ lb bc, BANK(Font), $80
+ ld a, [rLCDC]
+ bit 7, a
+ jp z, Copy1bpp
+
+ ld de, Font
+ ld hl, VTiles1
+ lb bc, BANK(Font), $20
+ call Get1bpp_2
+ ld de, Font + $20 * LEN_1BPP_TILE
+ ld hl, VTiles1 tile $20
+ lb bc, BANK(Font), $20
+ call Get1bpp_2
+ ld de, Font + $40 * LEN_1BPP_TILE
+ ld hl, VTiles1 tile $40
+ lb bc, BANK(Font), $20
+ call Get1bpp_2
+ ld de, Font + $60 * LEN_1BPP_TILE
+ ld hl, VTiles1 tile $60
+ lb bc, BANK(Font), $20
+ call Get1bpp_2
+ ret
+; fb48a
+
+_LoadFontsExtra1:: ; fb48a
+ ld de, MobilePhoneTilesGFX
+ ld hl, VTiles2 tile $60
+ lb bc, BANK(MobilePhoneTilesGFX), 1
+ call Get1bpp_2
+ ld de, OverworldPhoneIconGFX
+ ld hl, VTiles2 tile $62
+ lb bc, BANK(OverworldPhoneIconGFX), 1
+ call Get2bpp_2
+ ld de, FontExtra + 3 * LEN_2BPP_TILE
+ ld hl, VTiles2 tile $63
+ lb bc, BANK(FontExtra), $16
+ call Get2bpp_2
+ jr LoadFrame
+; fb4b0
+
+_LoadFontsExtra2:: ; fb4b0
+ ld de, GFX_f9424
+ ld hl, VTiles2 tile $61
+ ld b, BANK(GFX_f9424)
+ ld c, 1
+ call Get2bpp_2
+ ret
+; fb4be
+
+_LoadFontsBattleExtra:: ; fb4be
+ ld de, FontBattleExtra
+ ld hl, VTiles2 tile $60
+ lb bc, BANK(FontBattleExtra), $19
+ call Get2bpp_2
+ jr LoadFrame
+; fb4cc
+
+LoadFrame: ; fb4cc
+ ld a, [TextBoxFrame]
+ and 7
+ ld bc, TILES_PER_FRAME * LEN_1BPP_TILE
+ ld hl, Frames
+ call AddNTimes
+ ld d, h
+ ld e, l
+ ld hl, VTiles2 tile $79
+ lb bc, BANK(Frames), TILES_PER_FRAME
+ call Get1bpp_2
+ ld hl, VTiles2 tile $7f
+ ld de, TextBoxSpaceGFX
+ lb bc, BANK(TextBoxSpaceGFX), 1
+ call Get1bpp_2
+ ret
+; fb4f2
+
+LoadBattleFontsHPBar: ; fb4f2
+ ld de, FontBattleExtra
+ ld hl, VTiles2 tile $60
+ lb bc, BANK(FontBattleExtra), $c
+ call Get2bpp_2
+ ld hl, VTiles2 tile $70
+ ld de, FontBattleExtra + $10 * LEN_2BPP_TILE
+ lb bc, BANK(FontBattleExtra), 3
+ call Get2bpp_2
+ call LoadFrame
+
+LoadHPBar: ; fb50d
+ ld de, EnemyHPBarBorderGFX
+ ld hl, VTiles2 tile $6c
+ lb bc, BANK(EnemyHPBarBorderGFX), 4
+ call Get1bpp_2
+ ld de, HPExpBarBorderGFX
+ ld hl, VTiles2 tile $73
+ lb bc, BANK(HPExpBarBorderGFX), 6
+ call Get1bpp_2
+ ld de, ExpBarGFX
+ ld hl, VTiles2 tile $55
+ lb bc, BANK(ExpBarGFX), 9
+ call Get2bpp_2
+ ld de, MobilePhoneTilesGFX + 9 * LEN_2BPP_TILE
+ ld hl, VTiles2 tile $5e
+ lb bc, BANK(MobilePhoneTilesGFX), 2
+ call Get2bpp_2
+ ret
+; fb53e
+
+Functionfb53e: ; fb53e
+ call _LoadFontsBattleExtra
+ ld de, EnemyHPBarBorderGFX
+ ld hl, VTiles2 tile $6c
+ lb bc, BANK(EnemyHPBarBorderGFX), 4
+ call Get1bpp_2
+ ld de, HPExpBarBorderGFX
+ ld hl, VTiles2 tile $78
+ lb bc, BANK(HPExpBarBorderGFX), 1
+ call Get1bpp_2
+ ld de, HPExpBarBorderGFX + 3 * LEN_1BPP_TILE
+ ld hl, VTiles2 tile $76
+ lb bc, BANK(HPExpBarBorderGFX), 2
+ call Get1bpp_2
+ ld de, ExpBarGFX
+ ld hl, VTiles2 tile $55
+ lb bc, BANK(ExpBarGFX), 8
+ call Get2bpp_2
+
+Functionfb571: ; fb571
+ ld de, GFX_f89b0
+ ld hl, VTiles2 tile $31
+ lb bc, BANK(GFX_f89b0), $11
+ call Get2bpp_2
+ ret
+; fb57e
--- /dev/null
+++ b/gfx/mail.asm
@@ -1,0 +1,1088 @@
+ReadPartyMonMail: ; b9229
+ ld a, [CurPartyMon]
+ ld hl, sPartyMail
+ ld bc, MAIL_STRUCT_LENGTH
+ call AddNTimes
+ ld d, h
+ ld e, l
+ReadAnyMail: ; b9237
+ push de
+ call ClearBGPalettes
+ call ClearSprites
+ call ClearTileMap
+ call DisableLCD
+ call LoadFontsExtra
+ pop de
+ push de
+ ld a, BANK(sPartyMail)
+ call GetSRAMBank
+ callba Function1de5c8
+ call CloseSRAM
+ ld a, c
+ ld de, GFX_1de5e6
+ or a
+ jr z, .asm_b9268
+ ld de, GFX_1de9e6
+ sub $3
+ jr c, .asm_b9268
+ ld de, GFX_1dede6
+
+.asm_b9268
+ ld hl, VTiles1
+ lb bc, BANK(GFX_1de5e6), $80
+ call Get1bpp
+ pop de
+ call Functionb92b8
+ call EnableLCD
+ call WaitBGMap
+ ld a, [wd1ec]
+ ld e, a
+ callba Function8cb4
+ call SetPalettes
+ xor a
+ ld [hJoyPressed], a
+ call Functionb929a
+ call ClearBGPalettes
+ call DisableLCD
+ call LoadStandardFont
+ jp EnableLCD
+; b929a
+
+Functionb929a: ; b929a
+.asm_b929a
+ call GetJoypad
+ ld a, [hJoyPressed]
+ and A_BUTTON | B_BUTTON | START
+ jr z, .asm_b929a
+ and START
+ jr nz, .asm_b92a8
+ ret
+
+.asm_b92a8
+ ld a, [wJumptableIndex]
+ push af
+ callab Function845d4
+ pop af
+ ld [wJumptableIndex], a
+ jr .asm_b929a
+; b92b8
+
+Functionb92b8: ; b92b8
+ ld h, d
+ ld l, e
+ push hl
+ ld a, $0
+ call GetSRAMBank
+ ld de, $2b
+ add hl, de
+ ld a, [hli]
+ ld [Buffer1], a
+ ld a, [hli]
+ ld [Buffer2], a
+ ld a, [hli]
+ ld [CurPartySpecies], a
+ ld b, [hl]
+ call CloseSRAM
+ ld hl, MailGFXPointers
+ ld c, 0
+.asm_b92d9
+ ld a, [hli]
+ cp b
+ jr z, .asm_b92ea
+ cp $ff
+ jr z, .asm_b92e6
+ inc c
+rept 2
+ inc hl
+endr
+ jr .asm_b92d9
+
+.asm_b92e6
+ ld hl, MailGFXPointers
+ inc hl
+
+.asm_b92ea
+ ld a, c
+ ld [wd1ec], a
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld de, .done
+ pop bc
+ push de
+ jp [hl]
+.done
+ ret
+; b92f8
+
+MailGFXPointers: ; b92f8
+ dbw FLOWER_MAIL, LoadFlowerMailGFX
+ dbw SURF_MAIL, LoadSurfMailGFX
+ dbw LITEBLUEMAIL, LoadLiteBlueMailGFX
+ dbw PORTRAITMAIL, LoadPortraitMailGFX
+ dbw LOVELY_MAIL, LoadLovelyMailGFX
+ dbw EON_MAIL, LoadEonMailGFX
+ dbw MORPH_MAIL, LoadMorphMailGFX
+ dbw BLUESKY_MAIL, LoadBlueSkyMailGFX
+ dbw MUSIC_MAIL, LoadMusicMailGFX
+ dbw MIRAGE_MAIL, LoadMirageMailGFX
+ db $ff
+; b9317
+
+LoadSurfMailGFX: ; b9317
+ push bc
+ ld hl, VTiles2 tile $31
+ ld de, Unknown_b9d46
+ ld c, $40
+ call Functionb9915
+ ld de, MailLaprasGFX
+ ld c, $30
+ call Functionb991e
+ ld de, Unknown_b994e
+ ld c, $8
+ call Functionb9915
+ jr Functionb9351
+
+LoadLiteBlueMailGFX: ; b9335
+ push bc
+ ld hl, VTiles2 tile $31
+ ld de, Unknown_b9dc6
+ ld c, $40
+ call Functionb9915
+ ld de, MailDratiniGFX
+ ld c, $30
+ call Functionb991e
+ ld de, Unknown_b995e
+ ld c, $8
+ call Functionb9915
+
+Functionb9351: ; b9351
+ ld de, Unknown_b9976
+ ld c, $10
+ call Functionb9915
+ ld c, $10
+ call Functionb990c
+ ld de, Unknown_b9c3e
+ ld c, $40
+ call Functionb990c
+ ld c, $40
+ call Functionb9915
+ call Functionb9858
+ hlcoord 2, 15
+ ld a, $3f
+ call Functionb98d4
+ ld a, $39
+ hlcoord 15, 14
+ call Functionb98fc
+ ld a, $44
+ hlcoord 2, 2
+ call Functionb98ee
+ hlcoord 15, 11
+ call Functionb98ee
+ ld a, $4c
+ hlcoord 3, 12
+ call Functionb98ee
+ hlcoord 15, 2
+ call Functionb98ee
+ ld a, $50
+ hlcoord 6, 3
+ call Functionb98ee
+ ld a, $40
+ hlcoord 13, 2
+ ld [hli], a
+ hlcoord 6, 14
+ ld [hl], a
+ ld a, $41
+ hlcoord 4, 5
+ ld [hli], a
+ hlcoord 17, 5
+ ld [hli], a
+ hlcoord 13, 12
+ ld [hl], a
+ ld a, $42
+ hlcoord 9, 2
+ ld [hli], a
+ hlcoord 14, 5
+ ld [hli], a
+ hlcoord 3, 10
+ ld [hl], a
+ ld a, $43
+ hlcoord 6, 11
+ ld [hli], a
+ pop hl
+ jp Functionb9803
+; b93d2
+
+LoadEonMailGFX: ; b93d2
+ push bc
+ ld hl, VTiles2 tile $31
+ ld de, Unknown_b997e
+ ld c, $8
+ call Functionb9915
+ ld de, Unknown_b998e
+ ld c, $8
+ call Functionb990c
+ ld de, Unknown_b998e
+ ld c, $8
+ call Functionb990c
+ ld de, Unknown_b997e
+ ld c, $8
+ call Functionb9915
+ ld de, Unknown_b9d76
+ ld c, $8
+ call Functionb9915
+ ld de, MailPikaGFX
+ ld c, $30
+ call Functionb991e
+ ld hl, VTiles2 tile $3d
+ ld de, Unknown_b9c9e
+ ld c, $20
+ call Functionb990c
+ ld de, Unknown_b998e
+ ld c, $8
+ call Functionb9915
+ ld a, $31
+ hlcoord 0, 0
+ call Functionb98a8
+ hlcoord 1, 17
+ call Functionb98a8
+ ld a, $33
+ hlcoord 0, 1
+ call Functionb98ba
+ hlcoord 19, 0
+ call Functionb98ba
+ hlcoord 2, 15
+ ld a, $35
+ call Functionb98d4
+ inc a
+ hlcoord 15, 14
+ call Functionb98fc
+ call Functionb9491
+ pop hl
+ jp Functionb9803
+; b944b
+
+LoadLovelyMailGFX: ; b944b
+ push bc
+ ld hl, VTiles2 tile $31
+ ld de, Unknown_b9e26
+ ld c, $28
+ call Functionb9915
+ ld de, MailPoliwagGFX
+ ld c, $30
+ call Functionb991e
+ ld de, Unknown_b9966
+ ld c, $8
+ call Functionb9915
+ ld de, Unknown_b9c5e
+ ld c, $20
+ call Functionb9915
+ ld de, Unknown_b996e
+ ld c, $8
+ call Functionb990c
+ call Functionb987b
+ hlcoord 2, 15
+ ld a, $3c
+ call Functionb98d4
+ ld a, $36
+ hlcoord 15, 14
+ call Functionb98fc
+ call Functionb9491
+ pop hl
+ jp Functionb9803
+; b9491
+
+Functionb9491: ; b9491
+ ld a, $3d
+ hlcoord 2, 2
+ call Functionb98ee
+ hlcoord 16, 2
+ call Functionb98ee
+ hlcoord 9, 4
+ call Functionb98ee
+ hlcoord 2, 11
+ call Functionb98ee
+ hlcoord 6, 12
+ call Functionb98ee
+ hlcoord 12, 11
+ call Functionb98ee
+ ld a, $41
+ hlcoord 5, 4
+ ld [hl], a
+ hlcoord 6, 2
+ ld [hl], a
+ hlcoord 12, 4
+ ld [hl], a
+ hlcoord 14, 2
+ ld [hl], a
+ hlcoord 3, 13
+ ld [hl], a
+ hlcoord 9, 11
+ ld [hl], a
+ hlcoord 16, 12
+ ld [hl], a
+ ret
+; b94d6
+
+LoadMorphMailGFX: ; b94d6
+ push bc
+ ld hl, VTiles2 tile $31
+ ld bc, $28
+ call Functionb97f8
+ ld de, Unknown_b9c96
+ ld c, 8
+ call Functionb9915
+ ld de, Unknown_b9c7e
+ ld c, 8
+ call Functionb9915
+ ld de, Unknown_b993e
+ ld c, 8
+ call Functionb9915
+ ld de, Unknown_b997e
+ ld c, 8
+ call Functionb990c
+ ld de, Unknown_b9926
+ ld c, 8
+ call Functionb9915
+ ld de, MailDittoGFX
+ ld c, $30
+ call Functionb991e
+ call Functionb987b
+ ld a, $31
+ hlcoord 1, 1
+ call Functionb98ee
+ hlcoord 17, 15
+ call Functionb98ee
+ hlcoord 1, 3
+ ld [hl], a
+ hlcoord 3, 1
+ ld [hl], a
+ hlcoord 16, 16
+ ld [hl], a
+ hlcoord 18, 14
+ ld [hl], a
+ ld a, $36
+ hlcoord 1, 4
+ ld [hl], a
+ hlcoord 2, 3
+ ld [hl], a
+ hlcoord 3, 2
+ ld [hl], a
+ hlcoord 4, 1
+ ld [hl], a
+ inc a
+ hlcoord 15, 16
+ ld [hl], a
+ hlcoord 16, 15
+ ld [hl], a
+ hlcoord 17, 14
+ ld [hl], a
+ hlcoord 18, 13
+ ld [hl], a
+ inc a
+ hlcoord 2, 15
+ ld b, $e
+ call Functionb98de
+ inc a
+ hlcoord 2, 11
+ call Functionb98d4
+ hlcoord 2, 5
+ call Functionb98d4
+ inc a
+ hlcoord 6, 1
+ call Functionb98d0
+ hlcoord 1, 16
+ call Functionb98d0
+ inc a
+ hlcoord 3, 13
+ call Functionb98fc
+ pop hl
+ jp Functionb9803
+; b9582
+
+LoadBlueSkyMailGFX: ; b9582
+ push bc
+ ld hl, VTiles2 tile $31
+ ld de, Unknown_b997e
+ ld c, $8
+ call Functionb9915
+ ld a, $ff
+ ld bc, $10
+ call ByteFill
+ ld de, Unknown_b992e
+ ld c, $8
+ call Functionb991e
+ ld de, MailDragoniteGFX
+ ld c, $b8
+ call Functionb991e
+ ld de, MailCloudGFX
+ ld c, $30
+ call Functionb990c
+ ld de, Unknown_b9db6
+ ld c, $8
+ call Functionb990c
+ ld de, MailCloudGFX
+ ld c, $8
+ call Functionb990c
+ ld de, Unknown_b9d26
+ ld c, $10
+ call Functionb990c
+ ld de, Unknown_b9d3e
+ ld c, $8
+ call Functionb990c
+ ld a, $31
+ hlcoord 0, 0
+ call Functionb98dc
+ hlcoord 0, 1
+ call Functionb98e3
+ hlcoord 19, 1
+ call Functionb98e3
+ inc a
+ hlcoord 0, 17
+ call Functionb98dc
+ inc a
+ hlcoord 0, 16
+ call Functionb98dc
+ inc a
+ hlcoord 2, 2
+ call Functionb9636
+ hlcoord 3, 3
+ call Functionb9636
+ hlcoord 4, 4
+ call Functionb9636
+ dec hl
+ ld [hl], $7f
+ dec a
+ hlcoord 15, 14
+ call Functionb98ee
+ add $4
+ hlcoord 15, 16
+ ld [hli], a
+ inc a
+ ld [hl], a
+ inc a
+ push af
+ hlcoord 12, 1
+ call Functionb98fc
+ pop af
+ hlcoord 15, 4
+ call Functionb98fc
+ inc a
+ hlcoord 2, 11
+ call Functionb98d4
+ inc a
+ hlcoord 10, 3
+ call Functionb98ee
+ pop hl
+ jp Functionb9803
+; b9636
+
+Functionb9636: ; b9636
+ ld b, $6
+.asm_b9638
+ ld [hli], a
+ inc a
+ dec b
+ jr nz, .asm_b9638
+ ret
+; b963e
+
+LoadFlowerMailGFX: ; b963e
+ push bc
+ ld hl, VTiles2 tile $31
+ ld de, Unknown_b9d86
+ ld c, $40
+ call Functionb990c
+ ld de, MailOddishGFX
+ ld c, $20
+ call Functionb991e
+ ld de, Unknown_b9db6
+ ld c, $8
+ call Functionb9915
+ ld de, Unknown_b9cbe
+ ld c, $20
+ call Functionb990c
+ ld c, $20
+ call Functionb9915
+ call Functionb9858
+ hlcoord 2, 15
+ ld a, $3d
+ call Functionb98d4
+ ld a, $39
+ hlcoord 16, 13
+ call Functionb98ee
+ hlcoord 2, 13
+ call Functionb98ee
+ ld a, $3e
+ hlcoord 2, 2
+ call Functionb98ee
+ hlcoord 5, 3
+ call Functionb98ee
+ hlcoord 10, 2
+ call Functionb98ee
+ hlcoord 16, 3
+ call Functionb98ee
+ hlcoord 5, 11
+ call Functionb98ee
+ hlcoord 16, 10
+ call Functionb98ee
+ ld a, $42
+ hlcoord 3, 4
+ call Functionb98ee
+ hlcoord 12, 3
+ call Functionb98ee
+ hlcoord 14, 2
+ call Functionb98ee
+ hlcoord 2, 10
+ call Functionb98ee
+ hlcoord 14, 11
+ call Functionb98ee
+ pop hl
+ jp Functionb9803
+; b96ca
+
+LoadPortraitMailGFX: ; b96ca
+ push bc
+ ld hl, VTiles2 tile $31
+ ld de, Unknown_b9e4e
+ ld c, $28
+ call Functionb9915
+ ld de, Unknown_b995e
+ ld c, $8
+ call Functionb9915
+ ld hl, VTiles2 tile $3d
+ ld de, Unknown_b9bfe
+ ld c, $20
+ call Functionb990c
+ ld de, Unknown_b9936
+ ld c, $8
+ call Functionb9915
+ call Functionb987b
+ hlcoord 8, 15
+ ld a, $36
+ ld b, $a
+ call Functionb98de
+ call Functionb9491
+ ld a, $1
+ ld [UnownLetter], a
+ hlcoord 1, 10
+ call PrepMonFrontpic
+ pop hl
+ jp Functionb9803
+; b9710
+
+LoadMusicMailGFX: ; b9710
+ push bc
+ ld hl, VTiles2 tile $31
+ ld de, Unknown_b9e06
+ ld c, $20
+ call Functionb9915
+ ld de, Unknown_b993e
+ ld c, $10
+ call Functionb9915
+ ld de, Unknown_b9996
+ ld c, $30
+ call Functionb991e
+ xor a
+ ld bc, $10
+ call ByteFill
+ ld de, Unknown_b9cfe
+ ld c, $18
+ call Functionb990c
+ ld de, Unknown_b9946
+ ld c, $8
+ call Functionb990c
+ ld a, $31
+ hlcoord 0, 0
+ call Functionb98a8
+ hlcoord 1, 17
+ call Functionb98a8
+ ld a, $33
+ hlcoord 0, 1
+ call Functionb98ba
+ hlcoord 19, 0
+ call Functionb98ba
+ ld a, $35
+ hlcoord 2, 15
+ call Functionb989e
+ ld a, $37
+ hlcoord 15, 14
+ call Functionb98fc
+ call Functionb9491
+ pop hl
+ jp Functionb9803
+; b9776
+
+LoadMirageMailGFX: ; b9776
+ push bc
+ ld hl, VTiles2 tile $31
+ ld bc, $28
+ call Functionb97f8
+ ld de, Unknown_b992e
+ ld c, $8
+ call Functionb9915
+ ld de, MailMewGFX
+ ld c, $90
+ call Functionb9915
+ ld de, Unknown_b9dce
+ ld c, $8
+ call Functionb990c
+ ld de, Unknown_b9df6
+ ld c, $8
+ call Functionb990c
+ call Functionb987b
+ ld a, $36
+ hlcoord 1, 16
+ call Functionb98d8
+ inc a
+ hlcoord 15, 14
+ call Functionb98fc
+ inc a
+ hlcoord 15, 16
+ ld [hli], a
+ inc a
+ ld [hl], a
+ ld a, $3f
+ hlcoord 1, 1
+ call Functionb98a8
+ ld a, $41
+ hlcoord 0, 2
+ call Functionb98b5
+ ld a, $43
+ hlcoord 19, 2
+ call Functionb98b5
+ ld a, $45
+ hlcoord 0, 1
+ ld [hl], a
+ inc a
+ hlcoord 19, 1
+ ld [hl], a
+ inc a
+ hlcoord 0, 16
+ ld [hl], a
+ inc a
+ hlcoord 19, 16
+ ld [hl], a
+ inc a
+ hlcoord 2, 5
+ call Functionb98d4
+ inc a
+ hlcoord 2, 11
+ call Functionb98d4
+ pop hl
+ jp Functionb9803
+; b97f8
+
+Functionb97f8: ; b97f8
+.asm_b97f8
+ xor a
+ ld [hli], a
+ ld a, $ff
+ ld [hli], a
+ dec bc
+ ld a, b
+ or c
+ jr nz, .asm_b97f8
+ ret
+; b9803
+
+Functionb9803: ; b9803
+ ld bc, $2f
+ ld de, wd002
+ ld a, $0
+ call GetSRAMBank
+ call CopyBytes
+ call CloseSRAM
+ ld hl, wd023
+ ld de, wd050
+ ld bc, $a
+ call CopyBytes
+ ld a, $50
+ ld [wd023], a
+ ld [wd05a], a
+ ld de, wd002
+ hlcoord 2, 7
+ call PlaceString
+ ld de, wd050
+ ld a, [de]
+ and a
+ ret z
+ ld a, [wd1ec]
+ hlcoord 8, 14
+ cp $3
+ jr z, .asm_b984b
+ hlcoord 6, 14
+ cp $6
+ jr z, .asm_b984b
+ hlcoord 5, 14
+
+.asm_b984b
+ jp PlaceString
+; b984e
+
+Functionb984e: ; b984e
+.asm_b984e
+ ld a, [hl]
+ xor $ff
+ ld [hli], a
+ dec bc
+ ld a, b
+ or c
+ jr nz, .asm_b984e
+ ret
+; b9858
+
+Functionb9858: ; b9858
+ hlcoord 0, 0
+ ld a, $31
+ ld [hli], a
+ inc a
+ call Functionb98d8
+ inc a
+ ld [hli], a
+ inc a
+ call Functionb98e3
+ ld a, $36
+ ld [hli], a
+ inc a
+ call Functionb98d8
+ hlcoord 19, 1
+ ld a, $35
+ call Functionb98e3
+ ld a, $38
+ ld [hl], a
+ ret
+; b987b
+
+Functionb987b: ; b987b
+ hlcoord 0, 0
+ ld a, $31
+ ld [hli], a
+ inc a
+ call Functionb98d8
+ ld [hl], $31
+ inc hl
+ inc a
+ call Functionb98e3
+ ld [hl], $31
+ inc hl
+ inc a
+ call Functionb98d8
+ hlcoord 19, 1
+ ld a, $35
+ call Functionb98e3
+ ld [hl], $31
+ ret
+; b989e
+
+Functionb989e: ; b989e
+ push af
+ ld b, $7
+ jr Functionb98ab
+
+Functionb98a3: ; b98a3
+ push af
+ ld b, $8
+ jr Functionb98ab
+
+Functionb98a8: ; b98a8
+ push af
+ ld b, $9
+
+Functionb98ab: ; b98ab
+ ld [hli], a
+ inc a
+ ld [hli], a
+ dec a
+ dec b
+ jr nz, Functionb98ab
+ ld [hl], a
+ pop af
+ ret
+; b98b5
+
+Functionb98b5: ; b98b5
+ push af
+ ld b, $7
+ jr Functionb98bd
+
+Functionb98ba: ; b98ba
+ push af
+ ld b, $8
+
+Functionb98bd: ; b98bd
+ ld [hl], a
+ ld de, SCREEN_WIDTH
+ add hl, de
+ inc a
+ ld [hl], a
+ add hl, de
+ dec a
+ dec b
+ jr nz, Functionb98bd
+ ld [hl], a
+ pop af
+ ret
+; b98cc
+
+Functionb98cc: ; b98cc
+ ld b, $7
+ jr Functionb98de
+
+Functionb98d0: ; b98d0
+ ld b, $d
+ jr Functionb98de
+
+Functionb98d4: ; b98d4
+ ld b, $10
+ jr Functionb98de
+
+Functionb98d8: ; b98d8
+ ld b, $12
+ jr Functionb98de
+
+Functionb98dc: ; b98dc
+ ld b, $14
+
+Functionb98de: ; b98de
+ ld [hli], a
+ dec b
+ jr nz, Functionb98de
+ ret
+; b98e3
+
+Functionb98e3: ; b98e3
+ ld b, $10
+ ld de, SCREEN_WIDTH
+.asm_b98e8
+ ld [hl], a
+ add hl, de
+ dec b
+ jr nz, .asm_b98e8
+ ret
+; b98ee
+
+Functionb98ee: ; b98ee
+ push af
+ ld [hli], a
+ inc a
+ ld [hl], a
+ ld bc, $13
+ add hl, bc
+ inc a
+ ld [hli], a
+ inc a
+ ld [hl], a
+ pop af
+ ret
+; b98fc
+
+Functionb98fc: ; b98fc
+ ld [hli], a
+ inc a
+ ld [hli], a
+ inc a
+ ld [hl], a
+ ld bc, SCREEN_HEIGHT
+ add hl, bc
+ inc a
+ ld [hli], a
+ inc a
+ ld [hli], a
+ inc a
+ ld [hl], a
+ ret
+; b990c
+
+Functionb990c: ; b990c
+.asm_b990c
+ ld a, [de]
+ inc de
+ ld [hli], a
+ xor a
+ ld [hli], a
+ dec c
+ jr nz, .asm_b990c
+ ret
+; b9915
+
+Functionb9915: ; b9915
+.asm_b9915
+ xor a
+ ld [hli], a
+ ld a, [de]
+ inc de
+ ld [hli], a
+ dec c
+ jr nz, .asm_b9915
+ ret
+; b991e
+
+Functionb991e: ; b991e
+.asm_b991e
+ ld a, [de]
+ inc de
+rept 2
+ ld [hli], a
+endr
+ dec c
+ jr nz, .asm_b991e
+ ret
+; b9926
+
+Unknown_b9926: ; b9926
+INCBIN "gfx/unknown/0b9926.1bpp"
+
+Unknown_b992e: ; b992e
+INCBIN "gfx/unknown/0b992e.1bpp"
+
+Unknown_b9936: ; b9936
+INCBIN "gfx/unknown/0b9936.1bpp"
+
+Unknown_b993e: ; b993e
+INCBIN "gfx/unknown/0b993e.1bpp"
+
+Unknown_b9946: ; b9946
+INCBIN "gfx/unknown/0b9946.1bpp"
+
+Unknown_b994e: ; b994e
+INCBIN "gfx/unknown/0b994e.1bpp"
+
+Unknown_b995e: ; b995e
+INCBIN "gfx/unknown/0b995e.1bpp"
+
+Unknown_b9966: ; b9966
+INCBIN "gfx/unknown/0b9966.1bpp"
+
+Unknown_b996e: ; b996e
+INCBIN "gfx/unknown/0b996e.1bpp"
+
+Unknown_b9976: ; b9976
+INCBIN "gfx/unknown/0b9976.1bpp"
+
+Unknown_b997e: ; b997e
+INCBIN "gfx/unknown/0b997e.1bpp"
+
+Unknown_b998e: ; b998e
+INCBIN "gfx/unknown/0b998e.1bpp"
+
+Unknown_b9996: ; b9996
+INCBIN "gfx/unknown/0b9996.1bpp"
+
+MailDratiniGFX: ; b99c6
+INCBIN "gfx/unknown/0b99c6.1bpp"
+
+MailPoliwagGFX: ; b99f6
+INCBIN "gfx/unknown/0b99f6.1bpp"
+
+MailLaprasGFX: ; b9a26
+INCBIN "gfx/unknown/0b9a26.1bpp"
+
+MailPikaGFX: ; b9a56
+INCBIN "gfx/unknown/0b9a56.1bpp"
+
+MailDittoGFX: ; b9a86
+INCBIN "gfx/unknown/0b9a86.1bpp"
+
+MailMewGFX: ; b9ab6
+INCBIN "gfx/unknown/0b9ab6.1bpp"
+
+MailDragoniteGFX: ; b9b46
+INCBIN "gfx/unknown/0b9b46.1bpp"
+
+MailSentretGFX: ; b9bce
+INCBIN "gfx/unknown/0b9bce.1bpp"
+
+Unknown_b9bee: ; b9bee
+INCBIN "gfx/unknown/0b9bee.1bpp"
+
+Unknown_b9bfe: ; b9bfe
+INCBIN "gfx/unknown/0b9bfe.1bpp"
+
+MailOddishGFX: ; b9c1e
+INCBIN "gfx/unknown/0b9c1e.1bpp"
+
+Unknown_b9c3e: ; b9c3e
+INCBIN "gfx/unknown/0b9c3e.1bpp"
+
+Unknown_b9c5e: ; b9c5e
+INCBIN "gfx/unknown/0b9c5e.1bpp"
+
+Unknown_b9c7e: ; b9c7e
+INCBIN "gfx/unknown/0b9c7e.1bpp"
+
+Unknown_b9c96: ; b9c96
+INCBIN "gfx/unknown/0b9c96.1bpp"
+
+Unknown_b9c9e: ; b9c9e
+INCBIN "gfx/unknown/0b9c9e.1bpp"
+
+Unknown_b9cbe: ; b9cbe
+INCBIN "gfx/unknown/0b9cbe.1bpp"
+
+Unknown_b9cde: ; b9cde
+INCBIN "gfx/unknown/0b9cde.1bpp"
+
+Unknown_b9cfe: ; b9cfe
+INCBIN "gfx/unknown/0b9cfe.1bpp"
+
+MailCloudGFX: ; b9d16
+INCBIN "gfx/unknown/0b9d16.1bpp"
+
+Unknown_b9d26: ; b9d26
+INCBIN "gfx/unknown/0b9d26.1bpp"
+
+Unknown_b9d3e: ; b9d3e
+INCBIN "gfx/unknown/0b9d3e.1bpp"
+
+Unknown_b9d46: ; b9d46
+INCBIN "gfx/unknown/0b9d46.1bpp"
+
+Unknown_b9d76: ; b9d76
+INCBIN "gfx/unknown/0b9d76.1bpp"
+
+Unknown_b9d86: ; b9d86
+INCBIN "gfx/unknown/0b9d86.1bpp"
+
+Unknown_b9db6: ; b9db6
+INCBIN "gfx/unknown/0b9db6.1bpp"
+
+Unknown_b9dc6: ; b9dc6
+INCBIN "gfx/unknown/0b9dc6.1bpp"
+
+Unknown_b9dce: ; b9dce
+INCBIN "gfx/unknown/0b9dce.1bpp"
+
+Unknown_b9df6: ; b9df6
+INCBIN "gfx/unknown/0b9df6.1bpp"
+
+Unknown_b9e06: ; b9e06
+INCBIN "gfx/unknown/0b9e06.1bpp"
+
+Unknown_b9e26: ; b9e26
+INCBIN "gfx/unknown/0b9e26.1bpp"
+
+Unknown_b9e4e: ; b9e4e
+INCBIN "gfx/unknown/0b9e4e.1bpp"
+
+
+ItemIsMail: ; b9e76
+ ld a, d
+ ld hl, .items
+ ld de, 1
+ jp IsInArray
+; b9e80
+
+.items
+ db FLOWER_MAIL
+ db SURF_MAIL
+ db LITEBLUEMAIL
+ db PORTRAITMAIL
+ db LOVELY_MAIL
+ db EON_MAIL
+ db MORPH_MAIL
+ db BLUESKY_MAIL
+ db MUSIC_MAIL
+ db MIRAGE_MAIL
+ db $ff
+; b9e8b
--- a/home/map.asm
+++ b/home/map.asm
@@ -1588,7 +1588,7 @@
ret
; 2914
-Function2914:: ; 2914
+GetMovementPermissions:: ; 2914
xor a
ld [TilePermissions], a
call GetLeftRightCollision
--- a/main.asm
+++ b/main.asm
@@ -4839,7 +4839,7 @@
ld e, a
callba OWCutAnimation
call BufferScreen
- call Function2914
+ call GetMovementPermissions
call UpdateSprites
call DelayFrame
call LoadStandardFont
@@ -5952,7 +5952,7 @@
ld e, a
callba PlayWhirlpoolSound
call BufferScreen
- call Function2914
+ call GetMovementPermissions
ret
; ce3e
@@ -7350,7 +7350,7 @@
ret
Jumptable_d4f2: ; d4f2 (3:54f2)
- dw Function2914
+ dw GetMovementPermissions
dw BufferScreen
dw .mobile
dw .fail2
@@ -18307,7 +18307,7 @@
push hl
cp -1
jr z, .done
- ld hl, wc314
+ ld hl, wSpriteAnimationStructs
inc a
ld d, a
.inner_loop
@@ -24674,3902 +24674,24 @@
-EngineFlagAction:: ; 80430
-; Do action b on engine flag de
-;
-; b = 0: reset flag
-; = 1: set flag
-; > 1: check flag, result in c
-;
-; Setting/resetting does not return a result.
-
-
-; 16-bit flag ids are considered invalid, but it's nice
-; to know that the infrastructure is there.
-
- ld a, d
- cp 0
- jr z, .ceiling
- jr c, .read ; cp 0 can't set carry!
- jr .invalid
-
-; There are only $a2 engine flags, so
-; anything beyond that is invalid too.
-
-.ceiling
- ld a, e
- cp NUM_ENGINE_FLAGS
- jr c, .read
-
-; Invalid flags are treated as flag 00.
-
-.invalid
- xor a
- ld e, a
- ld d, a
-
-; Get this flag's location.
-
-.read
- ld hl, EngineFlags
-; location
-rept 2
- add hl, de
-endr
-; bit
- add hl, de
-
-; location
- ld e, [hl]
- inc hl
- ld d, [hl]
- inc hl
-; bit
- ld c, [hl]
-
-; What are we doing with this flag?
-
- ld a, b
- cp 1
- jr c, .reset ; b = 0
- jr z, .set ; b = 1
-
-; Return the given flag in c.
-.check
- ld a, [de]
- and c
- ld c, a
- ret
-
-; Set the given flag.
-.set
- ld a, [de]
- or c
- ld [de], a
- ret
-
-; Reset the given flag.
-.reset
- ld a, c
- cpl ; AND all bits except the one in question
- ld c, a
- ld a, [de]
- and c
- ld [de], a
- ret
-; 80462
-
-
-EngineFlags: ; 80462
INCLUDE "engine/engine_flags.asm"
; 80648
+INCLUDE "engine/variables.asm"
-
-_GetVarAction:: ; 80648 (20:4648)
- ld a, c
- cp NUM_VARS
- jr c, .valid
- xor a
-.valid
- ld c, a
- ld b, 0
- ld hl, .VarActionTable
-rept 3
- add hl, bc
-endr
- ld e, [hl]
- inc hl
- ld d, [hl]
- inc hl
- ld b, [hl]
- ld a, b
- and RETVAR_EXECUTE
- jr nz, .call
- ld a, b
- and RETVAR_ADDR_DE
- ret nz
- ld a, [de]
- jr .loadstringbuffer2
-
-.call
- call _de_
- ret
-
-.loadstringbuffer2: ; 8066c (20:466c)
- ld de, StringBuffer2
- ld [de], a
- ret
-; 80671 (20:4671)
-
-.VarActionTable: ; 80671
-; $00: copy [de] to StringBuffer2
-; $40: return address in de
-; $80: call function
- dwb StringBuffer2, RETVAR_STRBUF2
- dwb PartyCount, RETVAR_STRBUF2
- dwb .BattleResult, RETVAR_EXECUTE
- dwb BattleType, RETVAR_ADDR_DE
- dwb TimeOfDay, RETVAR_STRBUF2
- dwb .CountCaughtMons, RETVAR_EXECUTE
- dwb .CountSeenMons, RETVAR_EXECUTE
- dwb .CountBadges, RETVAR_EXECUTE
- dwb PlayerState, RETVAR_ADDR_DE
- dwb .PlayerFacing, RETVAR_EXECUTE
- dwb hHours, RETVAR_STRBUF2
- dwb .DayOfWeek, RETVAR_EXECUTE
- dwb MapGroup, RETVAR_STRBUF2
- dwb MapNumber, RETVAR_STRBUF2
- dwb .UnownCaught, RETVAR_EXECUTE
- dwb wPermission, RETVAR_STRBUF2
- dwb .BoxFreeSpace, RETVAR_EXECUTE
- dwb wBugContestMinsRemaining, RETVAR_STRBUF2
- dwb XCoord, RETVAR_STRBUF2
- dwb YCoord, RETVAR_STRBUF2
- dwb wSpecialPhoneCallID, RETVAR_STRBUF2
- dwb wcf64, RETVAR_STRBUF2
- dwb wKurtApricornQuantity, RETVAR_STRBUF2
- dwb wCurrentCaller, RETVAR_ADDR_DE
- dwb wBlueCardBalance, RETVAR_ADDR_DE
- dwb wBuenasPassword, RETVAR_ADDR_DE
- dwb wdc58, RETVAR_STRBUF2
- dwb NULL, RETVAR_STRBUF2
-; 806c5
-
-.CountCaughtMons: ; 806c5
-; Caught mons.
- ld hl, PokedexCaught
- ld b, EndPokedexCaught - PokedexCaught
- call CountSetBits
- ld a, [wd265]
- jp .loadstringbuffer2
-; 806d3
-
-.CountSeenMons: ; 806d3
-; Seen mons.
- ld hl, PokedexSeen
- ld b, EndPokedexSeen - PokedexSeen
- call CountSetBits
- ld a, [wd265]
- jp .loadstringbuffer2
-; 806e1
-
-.CountBadges: ; 806e1
-; Number of owned badges.
- ld hl, Badges
- ld b, 2
- call CountSetBits
- ld a, [wd265]
- jp .loadstringbuffer2
-; 806ef
-
-.PlayerFacing: ; 806ef
-; The direction the player is facing.
- ld a, [PlayerDirection]
- and $c
- rrca
- rrca
- jp .loadstringbuffer2
-; 806f9
-
-.DayOfWeek: ; 806f9
-; The day of the week.
- call GetWeekday
- jp .loadstringbuffer2
-; 806ff
-
-.UnownCaught: ; 806ff
-; Number of unique Unown caught.
- call .count
- ld a, b
- jp .loadstringbuffer2
-
-.count
- ld hl, UnownDex
- ld b, 0
-.loop
- ld a, [hli]
- and a
- ret z
- inc b
- ld a, b
- cp 26
- jr c, .loop
- ret
-; 80715
-
-.BoxFreeSpace: ; 80715
-; Remaining slots in the current box.
- ld a, BANK(sBoxCount)
- call GetSRAMBank
- ld hl, sBoxCount
- ld a, MONS_PER_BOX
- sub [hl]
- ld b, a
- call CloseSRAM
- ld a, b
- jp .loadstringbuffer2
-; 80728
-
-.BattleResult: ; 80728
- ld a, [wBattleResult]
- and $3f
- jp .loadstringbuffer2
-; 80730
-
-
BattleText::
INCLUDE "text/battle.asm"
+INCLUDE "engine/debug.asm"
-ColorTest: ; 818ac
-; A debug menu to test monster and trainer palettes at runtime.
-
- ld a, [hCGB]
- and a
- jr nz, .asm_818b5
- ld a, [hSGB]
- and a
- ret z
-
-.asm_818b5
- ld a, [hInMenu]
- push af
- ld a, $1
- ld [hInMenu], a
- call DisableLCD
- call Function81948
- call Function8197c
- call Function819a7
- call Function818f4
- call EnableLCD
- ld de, MUSIC_NONE
- call PlayMusic
- xor a
- ld [wJumptableIndex], a
- ld [wcf66], a
- ld [wd003], a
-.asm_818de
- ld a, [wJumptableIndex]
- bit 7, a
- jr nz, .asm_818f0
- call Function81a74
- call Function81f5e
- call DelayFrame
- jr .asm_818de
-
-.asm_818f0
- pop af
- ld [hInMenu], a
- ret
-; 818f4
-
-Function818f4: ; 818f4
- ld a, [wd002]
- and a
- jr nz, Function81911
- ld hl, PokemonPalettes
-
-Function818fd: ; 818fd
- ld de, OverworldMap
- ld c, NUM_POKEMON + 1
-.asm_81902
- push bc
- push hl
- call Function81928
- pop hl
- ld bc, 8
- add hl, bc
- pop bc
- dec c
- jr nz, .asm_81902
- ret
-
-Function81911: ; 81911
- ld hl, TrainerPalettes
- ld de, OverworldMap
- ld c, NUM_TRAINER_CLASSES
-.asm_81919
- push bc
- push hl
- call Function81928
- pop hl
- ld bc, 4
- add hl, bc
- pop bc
- dec c
- jr nz, .asm_81919
- ret
-; 81928
-
-Function81928: ; 81928
- ld a, BANK(PokemonPalettes) ; BANK(TrainerPalettes)
- call GetFarByte
- ld [de], a
- inc de
- inc hl
- ld a, BANK(PokemonPalettes) ; BANK(TrainerPalettes)
- call GetFarByte
- ld [de], a
- inc de
- inc hl
- ld a, BANK(PokemonPalettes) ; BANK(TrainerPalettes)
- call GetFarByte
- ld [de], a
- inc de
- inc hl
- ld a, BANK(PokemonPalettes) ; BANK(TrainerPalettes)
- call GetFarByte
- ld [de], a
- inc de
- ret
-; 81948
-
-Function81948: ; 81948
- ld a, $1
- ld [rVBK], a
- ld hl, VTiles0
- ld bc, sScratch - VTiles0
- xor a
- call ByteFill
- ld a, $0
- ld [rVBK], a
- ld hl, VTiles0
- ld bc, sScratch - VTiles0
- xor a
- call ByteFill
- hlcoord 0, 0, AttrMap
- ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
- xor a
- call ByteFill
- hlcoord 0, 0
- ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
- xor a
- call ByteFill
- call ClearSprites
- ret
-; 8197c
-
-Function8197c: ; 8197c
- ld hl, DebugColorTestGFX + $10
- ld de, VTiles2 tile $6a
- ld bc, $160
- call CopyBytes
- ld hl, DebugColorTestGFX
- ld de, VTiles0
- ld bc, $10
- call CopyBytes
- call LoadStandardFont
- ld hl, VTiles1
- lb bc, 8, 0
-.asm_8199d
- ld a, [hl]
- xor $ff
- ld [hli], a
- dec bc
- ld a, c
- or b
- jr nz, .asm_8199d
- ret
-; 819a7
-
-Function819a7: ; 819a7
- ld a, [hCGB]
- and a
- ret z
- ld a, [rSVBK]
- push af
- ld a, $5
- ld [rSVBK], a
- ld hl, Palette_819f4
- ld de, BGPals
- ld bc, $80
- call CopyBytes
- ld a, $80
- ld [rBGPI], a
- ld hl, Palette_819f4
- ld c, $40
- xor a
-.asm_819c8
- ld [rBGPD], a
- dec c
- jr nz, .asm_819c8
- ld a, $80
- ld [rOBPI], a
- ld hl, Palette_81a34
- ld c, $40
-.asm_819d6
- ld a, [hli]
- ld [rOBPD], a
- dec c
- jr nz, .asm_819d6
- ld a, $94
- ld [wc608], a
- ld a, $52
- ld [wc608 + 1], a
- ld a, $4a
- ld [wc608 + 2], a
- ld a, $29
- ld [wc608 + 3], a
- pop af
- ld [rSVBK], a
- ret
-; 819f4
-
-Palette_819f4: ; 819f4
- ; white
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 00, 00, 00
-
- ; red
- RGB 31, 00, 00
- RGB 31, 00, 00
- RGB 31, 00, 00
- RGB 00, 00, 00
-
- ; green
- RGB 00, 31, 00
- RGB 00, 31, 00
- RGB 00, 31, 00
- RGB 00, 00, 00
-
- ; blue
- RGB 00, 00, 31
- RGB 00, 00, 31
- RGB 00, 00, 31
- RGB 00, 00, 00
-
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 00, 00, 00
-
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 00, 00, 00
-
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 00, 00, 00
-
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 00, 00, 00
-
-Palette_81a34: ; 81a34
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 00, 00, 00
-
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 00, 00, 00
-
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 00, 00, 00
-
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 00, 00, 00
-
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 00, 00, 00
-
- ; red
- RGB 31, 31, 31
- RGB 31, 00, 00
- RGB 31, 00, 00
- RGB 00, 00, 00
-
- ; green
- RGB 31, 31, 31
- RGB 00, 31, 00
- RGB 00, 31, 00
- RGB 00, 00, 00
-
- ; blue
- RGB 31, 31, 31
- RGB 00, 00, 31
- RGB 00, 00, 31
- RGB 00, 00, 00
-; 81a74
-
-Function81a74: ; 81a74
- call JoyTextDelay
- ld a, [wJumptableIndex]
- cp $4
- jr nc, .asm_81a8b
- ld hl, hJoyLast
- ld a, [hl]
- and SELECT
- jr nz, .asm_81a9a
- ld a, [hl]
- and START
- jr nz, .asm_81aab
-
-.asm_81a8b
- ld a, [wJumptableIndex]
- ld e, a
- ld d, 0
- ld hl, Jumptable_81acf
-rept 2
- add hl, de
-endr
- ld a, [hli]
- ld h, [hl]
- ld l, a
- jp [hl]
-
-.asm_81a9a
- call Function81eca
- call Function81ac3
- ld e, a
- ld a, [wcf66]
- inc a
- cp e
- jr c, .asm_81aba
- xor a
- jr .asm_81aba
-
-.asm_81aab
- call Function81eca
- ld a, [wcf66]
- dec a
- cp $ff
- jr nz, .asm_81aba
- call Function81ac3
- dec a
-
-.asm_81aba
- ld [wcf66], a
- ld a, $0
- ld [wJumptableIndex], a
- ret
-; 81ac3
-
-Function81ac3: ; 81ac3
-; Looping back around the pic set.
- ld a, [wd002]
- and a
- jr nz, .asm_81acc
- ld a, NUM_POKEMON ; CELEBI
- ret
-
-.asm_81acc
- ld a, NUM_TRAINER_CLASSES - 1 ; MYSTICALMAN
- ret
-; 81acf
-
-Jumptable_81acf: ; 81acf
- dw Function81adb
- dw Function81c18
- dw Function81c33
- dw Function81cc2
- dw Function81d8e
- dw Function81daf
-; 81adb
-
-Function81adb: ; 81adb
- xor a
- ld [hBGMapMode], a
- hlcoord 0, 0
- ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
- ld a, $6f
- call ByteFill
- hlcoord 1, 3
- lb bc, 7, 18
- ld a, $6c
- call Bank20_FillBoxWithByte
- hlcoord 11, 0
- lb bc, 2, 3
- ld a, $6d
- call Bank20_FillBoxWithByte
- hlcoord 16, 0
- lb bc, 2, 3
- ld a, $6e
- call Bank20_FillBoxWithByte
- call Function81bc0
- call Function81bf4
- ld a, [wcf66]
- inc a
- ld [CurPartySpecies], a
- ld [wd265], a
- hlcoord 0, 1
- ld de, wd265
- lb bc, PRINTNUM_LEADINGZEROS | 1, 3
- call PrintNum
- ld a, [wd002]
- and a
- jr nz, .asm_81b7a
- ld a, $1
- ld [UnownLetter], a
- call GetPokemonName
- hlcoord 4, 1
- call PlaceString
- xor a
- ld [wc2c6], a
- hlcoord 12, 3
- call _PrepMonFrontpic
- ld de, VTiles2 tile $31
- predef GetBackpic
- ld a, $31
- ld [hFillBox], a
- hlcoord 2, 4
- lb bc, 6, 6
- predef FillBox
- ld a, [wd003]
- and a
- jr z, .asm_81b66
- ld de, String_81baf
- jr .asm_81b69
-
-.asm_81b66
- ld de, String_81bb4
-
-.asm_81b69
- hlcoord 7, 17
- call PlaceString
- hlcoord 0, 17
- ld de, String_81bb9
- call PlaceString
- jr .asm_81ba9
-
-.asm_81b7a
- ld a, [wd265]
- ld [TrainerClass], a
- callab Function3957b
- ld de, StringBuffer1
- hlcoord 4, 1
- call PlaceString
- ld de, VTiles2
- callab GetTrainerPic
- xor a
- ld [TempEnemyMonSpecies], a
- ld [hFillBox], a
- hlcoord 2, 3
- lb bc, 7, 7
- predef FillBox
-
-.asm_81ba9
- ld a, $1
- ld [wJumptableIndex], a
- ret
-; 81baf
-
-String_81baf: db "レア", $6f, $6f, "@" ; rare (shiny)
-String_81bb4: db "ノーマル@" ; normal
-String_81bb9: db $7a, "きりかえ▶@" ; (A) switches
-; 81bc0
-
-Function81bc0: ; 81bc0
- decoord 0, 11, AttrMap
- hlcoord 2, 11
- ld a, $1
- call Function81bde
- decoord 0, 13, AttrMap
- hlcoord 2, 13
- ld a, $2
- call Function81bde
- decoord 0, 15, AttrMap
- hlcoord 2, 15
- ld a, $3
-
-Function81bde: ; 81bde
- push af
- ld a, $6a
- ld [hli], a
- ld bc, $f
- ld a, $6b
- call ByteFill
- ld l, e
- ld h, d
- pop af
- ld bc, $28
- call ByteFill
- ret
-; 81bf4
-
-Function81bf4: ; 81bf4
- ld a, [wcf66]
- inc a
- ld l, a
- ld h, $0
-rept 2
- add hl, hl
-endr
- ld de, OverworldMap
- add hl, de
- ld de, wc608
- ld bc, 4
- call CopyBytes
- xor a
- ld [wcf64], a
- ld [wcf65], a
- ld de, wc608
- call Function81ea5
- ret
-; 81c18
-
-Function81c18: ; 81c18
- ld a, [hCGB]
- and a
- jr z, .asm_81c2a
- ld a, $2
- ld [hBGMapMode], a
- call DelayFrame
- call DelayFrame
- call DelayFrame
-
-.asm_81c2a
- call WaitBGMap
- ld a, $2
- ld [wJumptableIndex], a
- ret
-; 81c33
-
-Function81c33: ; 81c33
- ld a, [hCGB]
- and a
- jr z, .asm_81c69
- ld a, [rSVBK]
- push af
- ld a, $5
- ld [rSVBK], a
- ld hl, BGPals
- ld de, wc608
- ld c, $1
- call Function81ee3
- hlcoord 10, 2
- ld de, wc608
- call Function81ca7
- hlcoord 15, 2
- ld de, wc608 + 2
- call Function81ca7
- ld a, $1
- ld [hCGBPalUpdate], a
- ld a, $3
- ld [wJumptableIndex], a
- pop af
- ld [rSVBK], a
- ret
-
-.asm_81c69
- ld hl, wcda9
- ld a, $1
- ld [hli], a
- ld a, $ff
- ld [hli], a
- ld a, $7f
- ld [hli], a
- ld a, [wc608]
- ld [hli], a
- ld a, [wc608 + 1]
- ld [hli], a
- ld a, [wc608 + 2]
- ld [hli], a
- ld a, [wc608 + 3]
- ld [hli], a
- xor a
-rept 2
- ld [hli], a
-endr
- ld [hl], a
- ld hl, wcda9
- call Function81f0c
- hlcoord 10, 2
- ld de, wc608
- call Function81ca7
- hlcoord 15, 2
- ld de, wc608 + 2
- call Function81ca7
- ld a, $3
- ld [wJumptableIndex], a
- ret
-; 81ca7
-
-Function81ca7: ; 81ca7
-rept 3
- inc hl
-endr
- ld a, [de]
- call Function81cbc
- ld a, [de]
- swap a
- call Function81cbc
- inc de
- ld a, [de]
- call Function81cbc
- ld a, [de]
- swap a
-
-Function81cbc: ; 81cbc
- and $f
- add $70
- ld [hld], a
- ret
-; 81cc2
-
-Function81cc2: ; 81cc2
- ld a, [hJoyLast]
- and B_BUTTON
- jr nz, .asm_81cdf
- ld a, [hJoyLast]
- and A_BUTTON
- jr nz, .asm_81ce5
- ld a, [wcf64]
- and $3
- ld e, a
- ld d, 0
- ld hl, Jumptable_81d02
-rept 2
- add hl, de
-endr
- ld a, [hli]
- ld h, [hl]
- ld l, a
- jp [hl]
-
-.asm_81cdf
- ld a, $4
- ld [wJumptableIndex], a
- ret
-
-.asm_81ce5
- ld a, [wd002]
- and a
- ret nz
- ld a, [wd003]
- xor $4
- ld [wd003], a
- ld c, a
- ld b, 0
- ld hl, PokemonPalettes
- add hl, bc
- call Function818fd
- ld a, $0
- ld [wJumptableIndex], a
- ret
-; 81d02
-
-Jumptable_81d02: ; 81d02
- dw Function81d0a
- dw Function81d34
- dw Function81d46
- dw Function81d58
-; 81d0a
-
-Function81d0a: ; 81d0a
- ld hl, hJoyLast
- ld a, [hl]
- and D_DOWN
- jr nz, Function81d89
- ld a, [hl]
- and D_LEFT
- jr nz, .asm_81d1d
- ld a, [hl]
- and D_RIGHT
- jr nz, .asm_81d28
- ret
-
-.asm_81d1d
- xor a
- ld [wcf65], a
- ld de, wc608
- call Function81ea5
- ret
-
-.asm_81d28
- ld a, $1
- ld [wcf65], a
- ld de, wc608 + 2
- call Function81ea5
- ret
-
-Function81d34: ; 81d34
- ld hl, hJoyLast
- ld a, [hl]
- and D_DOWN
- jr nz, Function81d89
- ld a, [hl]
- and D_UP
- jr nz, Function81d84
- ld hl, wc608 + 10
- jr Function81d63
-
-Function81d46: ; 81d46
- ld hl, hJoyLast
- ld a, [hl]
- and D_DOWN
- jr nz, Function81d89
- ld a, [hl]
- and D_UP
- jr nz, Function81d84
- ld hl, wc608 + 11
- jr Function81d63
-
-Function81d58: ; 81d58
- ld hl, hJoyLast
- ld a, [hl]
- and D_UP
- jr nz, Function81d84
- ld hl, wc608 + 12
-
-Function81d63: ; 81d63
- ld a, [hJoyLast]
- and D_RIGHT
- jr nz, Function81d70
- ld a, [hJoyLast]
- and D_LEFT
- jr nz, Function81d77
- ret
-
-Function81d70: ; 81d70
- ld a, [hl]
- cp $1f
- ret nc
- inc [hl]
- jr Function81d7b
-
-Function81d77: ; 81d77
- ld a, [hl]
- and a
- ret z
- dec [hl]
-
-Function81d7b: ; 81d7b
- call Function81e67
- ld a, $2
- ld [wJumptableIndex], a
- ret
-
-Function81d84: ; 81d84
- ld hl, wcf64
- dec [hl]
- ret
-
-Function81d89: ; 81d89
- ld hl, wcf64
- inc [hl]
- ret
-; 81d8e
-
-Function81d8e: ; 81d8e
- hlcoord 0, 10
- ld bc, $a0
- ld a, $6f
- call ByteFill
- hlcoord 2, 12
- ld de, String_81fcd
- call PlaceString
- xor a
- ld [wd004], a
- call Function81df4
- ld a, $5
- ld [wJumptableIndex], a
- ret
-; 81daf
-
-Function81daf: ; 81daf
- ld hl, hJoyPressed
- ld a, [hl]
- and B_BUTTON
- jr nz, .asm_81dbb
- call Function81dc7
- ret
-
-.asm_81dbb
- ld a, $0
- ld [wJumptableIndex], a
- ret
-; 81dc1
-
-Function81dc1: ; 81dc1
- ld hl, wJumptableIndex
- set 7, [hl]
- ret
-; 81dc7
-
-Function81dc7: ; 81dc7
- ld hl, hJoyLast
- ld a, [hl]
- and D_UP
- jr nz, .asm_81dd5
- ld a, [hl]
- and D_DOWN
- jr nz, .asm_81de2
- ret
-
-.asm_81dd5
- ld a, [wd004]
- cp $3b
- jr z, .asm_81ddf
- inc a
- jr .asm_81ded
-
-.asm_81ddf
- xor a
- jr .asm_81ded
-
-.asm_81de2
- ld a, [wd004]
- and a
- jr z, .asm_81deb
- dec a
- jr .asm_81ded
-
-.asm_81deb
- ld a, $3b
-
-.asm_81ded
- ld [wd004], a
- call Function81df4
- ret
-; 81df4
-
-Function81df4: ; 81df4
- hlcoord 10, 11
- call Function81e5e
- hlcoord 10, 12
- call Function81e5e
- hlcoord 10, 13
- call Function81e5e
- hlcoord 10, 14
- call Function81e5e
- ld a, [wd004]
- inc a
- ld [wd265], a
- predef GetTMHMMove
- ld a, [wd265]
- ld [wd262], a
- call GetMoveName
- hlcoord 10, 12
- call PlaceString
- ld a, [wd004]
- call Function81e55
- ld [CurItem], a
- predef CanLearnTMHMMove
- ld a, c
- and a
- ld de, String_81e46
- jr nz, .asm_81e3f
- ld de, String_81e4d
-
-.asm_81e3f
- hlcoord 10, 14
- call PlaceString
- ret
-; 81e46
-
-String_81e46: db "おぼえられる@" ; can be taught
-String_81e4d: db "おぼえられない@" ; cannot be taught
-; 81e55
-
-Function81e55: ; 81e55
- cp $32
- jr c, .asm_81e5b
-rept 2
- inc a
-endr
-
-.asm_81e5b
- add $bf
- ret
-; 81e5e
-
-Function81e5e: ; 81e5e
- ld bc, $a
- ld a, $6f
- call ByteFill
- ret
-; 81e67
-
-Function81e67: ; 81e67
- ld a, [wc608 + 10]
- and $1f
- ld e, a
- ld a, [wc608 + 11]
- and $7
- sla a
- swap a
- or e
- ld e, a
- ld a, [wc608 + 11]
- and $18
- sla a
- swap a
- ld d, a
- ld a, [wc608 + 12]
- and $1f
- sla a
- sla a
- or d
- ld d, a
- ld a, [wcf65]
- and a
- jr z, .asm_81e9c
- ld a, e
- ld [wc608 + 2], a
- ld a, d
- ld [wc608 + 3], a
- ret
-
-.asm_81e9c
- ld a, e
- ld [wc608], a
- ld a, d
- ld [wc608 + 1], a
- ret
-; 81ea5
-
-Function81ea5: ; 81ea5
- ld a, [de]
- and $1f
- ld [wc608 + 10], a
- ld a, [de]
- and $e0
- swap a
- srl a
- ld b, a
- inc de
- ld a, [de]
- and $3
- swap a
- srl a
- or b
- ld [wc608 + 11], a
- ld a, [de]
- and $7c
- srl a
- srl a
- ld [wc608 + 12], a
- ret
-; 81eca
-
-Function81eca: ; 81eca
- ld a, [wcf66]
- inc a
- ld l, a
- ld h, $0
-rept 2
- add hl, hl
-endr
- ld de, OverworldMap
- add hl, de
- ld e, l
- ld d, h
- ld hl, wc608
- ld bc, 4
- call CopyBytes
- ret
-; 81ee3
-
-Function81ee3: ; 81ee3
-.asm_81ee3
- ld a, $ff
- ld [hli], a
- ld a, $7f
- 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
- ld a, [de]
- inc de
- ld [hli], a
- xor a
-rept 2
- ld [hli], a
-endr
- dec c
- jr nz, .asm_81ee3
- ret
-; 81efc
-
-Bank20_FillBoxWithByte: ; 81efc
-; For some reason, we have another copy of FillBoxWithByte here
-.row
- push bc
- push hl
-.col
- ld [hli], a
- dec c
- jr nz, .col
- pop hl
- ld bc, SCREEN_WIDTH
- add hl, bc
- pop bc
- dec b
- jr nz, .row
- ret
-; 81f0c
-
-Function81f0c: ; 81f0c
- ld a, [wcfbe]
- push af
- set 7, a
- ld [wcfbe], a
- call Function81f1d
- pop af
- ld [wcfbe], a
- ret
-; 81f1d
-
-Function81f1d: ; 81f1d
- ld a, [hl]
- and $7
- ret z
- ld b, a
-.asm_81f22
- push bc
- xor a
- ld [rJOYP], a
- ld a, $30
- ld [rJOYP], a
- ld b, $10
-.asm_81f2c
- ld e, $8
- ld a, [hli]
- ld d, a
-.asm_81f30
- bit 0, d
- ld a, $10
- jr nz, .asm_81f38
- ld a, $20
-
-.asm_81f38
- ld [rJOYP], a
- ld a, $30
- ld [rJOYP], a
- rr d
- dec e
- jr nz, .asm_81f30
- dec b
- jr nz, .asm_81f2c
- ld a, $20
- ld [rJOYP], a
- ld a, $30
- ld [rJOYP], a
- ld de, 7000
-.asm_81f51
- nop
- nop
- nop
- dec de
- ld a, d
- or e
- jr nz, .asm_81f51
- pop bc
- dec b
- jr nz, .asm_81f22
- ret
-; 81f5e
-
-Function81f5e: ; 81f5e
- ld a, $6f
- hlcoord 10, 0
- ld [hl], a
- hlcoord 15, 0
- ld [hl], a
- hlcoord 1, 11
- ld [hl], a
- hlcoord 1, 13
- ld [hl], a
- hlcoord 1, 15
- ld [hl], a
- ld a, [wJumptableIndex]
- cp $3
- jr nz, .asm_81fc9
- ld a, [wcf64]
- and a
- jr z, .asm_81f8d
- dec a
- hlcoord 1, 11
- ld bc, 2 * SCREEN_WIDTH
- call AddNTimes
- ld [hl], $ed
-
-.asm_81f8d
- ld a, [wcf65]
- and a
- jr z, .asm_81f98
- hlcoord 15, 0
- jr .asm_81f9b
-
-.asm_81f98
- hlcoord 10, 0
-
-.asm_81f9b
- ld [hl], $ed
- ld b, $70
- ld c, $5
- ld hl, Sprites
- ld de, wc608 + 10
- call .asm_81fb7
- ld de, wc608 + 11
- call .asm_81fb7
- ld de, wc608 + 12
- call .asm_81fb7
- ret
-
-.asm_81fb7
- ld a, b
- ld [hli], a
- ld a, [de]
-rept 2
- add a
-endr
- add $18
- ld [hli], a
- xor a
- ld [hli], a
- ld a, c
- ld [hli], a
- ld a, $10
- add b
- ld b, a
- inc c
- ret
-
-.asm_81fc9
- call ClearSprites
- ret
-; 81fcd
-
-String_81fcd: ; 81fcd
- db "おわりますか?" ; Are you finished?
- next "はい", $f2, $f2, $f2, $7a ; YES (A)
- next "いいえ", $f2, $f2, $7b ; NO (B)
- db "@"
-; 81fe3
-
-DebugColorTestGFX:
-INCBIN "gfx/debug/color_test.2bpp"
-
-
-TilesetColorTest:
- ret
- xor a
- ld [wJumptableIndex], a
- ld [wcf64], a
- ld [wcf65], a
- ld [wcf66], a
- ld [hMapAnims], a
- call ClearSprites
- call OverworldTextModeSwitch
- call Function3200
- xor a
- ld [hBGMapMode], a
- ld de, DebugColorTestGFX + $10
- ld hl, VTiles2 tile $6a
- lb bc, BANK(DebugColorTestGFX), $16
- call Request2bpp
- ld de, DebugColorTestGFX
- ld hl, VTiles1
- lb bc, BANK(DebugColorTestGFX), 1
- call Request2bpp
- ld a, VBGMap1 / $100
- ld [hBGMapAddress + 1], a
- hlcoord 0, 0
- ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
- ld a, $6f
- call ByteFill
- hlcoord 0, 0, AttrMap
- ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
- ld a, $7
- call ByteFill
- ld de, $15
- ld a, $6c
- call Function821d2
- ld de, $1a
- ld a, $6d
- call Function821d2
- ld de, $1f
- ld a, $6e
- call Function821d2
- ld de, $24
- ld a, $6f
- call Function821d2
- call Function821f4
- call Function8220f
- call Function3200
- ld [wJumptableIndex], a
- ld a, $40
- ld [hWY], a
- ret
-; 821d2
-
-Function821d2: ; 821d2
- hlcoord 0, 0
- call Function821de
-
-Function821d8: ; 821d8
- ld a, [wcf64]
- hlcoord 0, 0, AttrMap
-
-Function821de: ; 821de
- add hl, de
-rept 4
- ld [hli], a
-endr
- ld bc, $10
- add hl, bc
-rept 4
- ld [hli], a
-endr
- ld bc, $10
- add hl, bc
-rept 4
- ld [hli], a
-endr
- ret
-; 821f4
-
-Function821f4: ; 821f4
- hlcoord 2, 4
- call Function82203
- hlcoord 2, 6
- call Function82203
- hlcoord 2, 8
-
-Function82203: ; 82203
- ld a, $6a
- ld [hli], a
- ld bc, $10 - 1
- ld a, $6b
- call ByteFill
- ret
-; 8220f
-
-Function8220f: ; 8220f
- ld a, [rSVBK]
- push af
- ld a, $5
- ld [rSVBK], a
- ld a, [wcf64]
- ld l, a
- ld h, $0
-rept 3
- add hl, hl
-endr
- ld de, wMapPals
- add hl, de
- ld de, wc608
- ld bc, 8
- call CopyBytes
- ld de, wc608
- call Function81ea5
- pop af
- ld [rSVBK], a
- ret
-; 82236
-
-
-Function82236: ; 82236
- ld hl, hJoyLast
- ld a, [hl]
- and SELECT
- jr nz, .loop7
- ld a, [hl]
- and B_BUTTON
- jr nz, .asm_82299
- call Function822f0
- ret
-
-.loop7
- ld hl, wcf64
- ld a, [hl]
- inc a
- and $7
- cp $7
- jr nz, .asm_82253
- xor a
-
-.asm_82253
- ld [hl], a
- ld de, $15
- call Function821d8
- ld de, $1a
- call Function821d8
- ld de, $1f
- call Function821d8
- ld de, $24
- call Function821d8
- ld a, [rSVBK]
- push af
- ld a, $5
- ld [rSVBK], a
- ld hl, BGPals
- ld a, [wcf64]
- ld bc, 8
- call AddNTimes
- ld de, wc608
- ld bc, 8
- call CopyBytes
- pop af
- ld [rSVBK], a
- ld a, $2
- ld [hBGMapMode], a
- ld c, 3
- call DelayFrames
- ld a, $1
- ld [hBGMapMode], a
- ret
-
-.asm_82299
- call ClearSprites
- ld a, [hWY]
- xor $d0
- ld [hWY], a
- ret
-; 822a3
-
-Function822a3: ; 822a3
- ld a, [rSVBK]
- push af
- ld a, $5
- ld [rSVBK], a
- ld hl, BGPals
- ld a, [wcf64]
- ld bc, 8
- call AddNTimes
- ld e, l
- ld d, h
- ld hl, wc608
- ld bc, 8
- call CopyBytes
- hlcoord 1, 0
- ld de, wc608
- call Function81ca7
- hlcoord 6, 0
- ld de, wc608 + 2
- call Function81ca7
- hlcoord 11, 0
- ld de, wc608 + 4
- call Function81ca7
- hlcoord 16, 0
- ld de, wc608 + 6
- call Function81ca7
- pop af
- ld [rSVBK], a
- ld a, $1
- ld [hCGBPalUpdate], a
- call DelayFrame
- ret
-; 822f0
-
-Function822f0: ; 822f0
- ld a, [wcf65]
- and 3
- ld e, a
- ld d, 0
- ld hl, .jumptable
-rept 2
- add hl, de
-endr
- ld a, [hli]
- ld h, [hl]
- ld l, a
- jp [hl]
-; 82301
-
-.jumptable: ; 82301
- dw Function82309
- dw Function82339
- dw Function8234b
- dw Function8235d
-; 82309
-
-Function82309: ; 82309
- ld hl, hJoyLast
- ld a, [hl]
- and D_DOWN
- jr nz, Function8238c
- ld a, [hl]
- and D_LEFT
- jr nz, .asm_8231c
- ld a, [hl]
- and D_RIGHT
- jr nz, .asm_82322
- ret
-
-.asm_8231c
- ld a, [wcf66]
- dec a
- jr .asm_82326
-
-.asm_82322
- ld a, [wcf66]
- inc a
-
-.asm_82326
- and $3
- ld [wcf66], a
- ld e, a
- ld d, $0
- ld hl, wc608
-rept 2
- add hl, de
-endr
- ld e, l
- ld d, h
- call Function81ea5
- ret
-
-Function82339: ; 82338
- ld hl, hJoyLast
- ld a, [hl]
- and D_DOWN
- jr nz, Function8238c
- ld a, [hl]
- and D_UP
- jr nz, Function82387
- ld hl, wc608 + 10
- jr Function82368
-
-Function8234b: ; 8234b
- ld hl, hJoyLast
- ld a, [hl]
- and D_DOWN
- jr nz, Function8238c
- ld a, [hl]
- and D_UP
- jr nz, Function82387
- ld hl, wc608 + 11
- jr Function82368
-
-Function8235d: ; 8235d
- ld hl, hJoyLast
- ld a, [hl]
- and D_UP
- jr nz, Function82387
- ld hl, wc608 + 12
-
-Function82368: ; 82368
- ld a, [hJoyLast]
- and D_RIGHT
- jr nz, .asm_82375
- ld a, [hJoyLast]
- and D_LEFT
- jr nz, .asm_8237c
- ret
-
-.asm_82375
- ld a, [hl]
- cp $1f
- ret nc
- inc [hl]
- jr .asm_82380
-
-.asm_8237c
- ld a, [hl]
- and a
- ret z
- dec [hl]
-
-.asm_82380
- call Function82391
- call Function822a3
- ret
-
-Function82387: ; 82387
- ld hl, wcf65
- dec [hl]
- ret
-
-Function8238c: ; 8238c
- ld hl, wcf65
- inc [hl]
- ret
-; 82391
-
-Function82391: ; 82391
- ld a, [wc608 + 10]
- and $1f
- ld e, a
- ld a, [wc608 + 11]
- and $7
- sla a
- swap a
- or e
- ld e, a
- ld a, [wc608 + 11]
- and $18
- sla a
- swap a
- ld d, a
- ld a, [wc608 + 12]
- and $1f
- sla a
- sla a
- or d
- ld d, a
- ld a, [wcf66]
- ld c, a
- ld b, $0
- ld hl, wc608
-rept 2
- add hl, bc
-endr
- ld a, e
- ld [hli], a
- ld [hl], d
- ret
-; 823c6
-
-Function823c6: ; 823c6
- ret
-
-Function823c7: ; 823c7
- ret
-; 823c8
-
-
SECTION "bank21", ROMX, BANK[$21]
-Function84000: ; 84000
- ld hl, OverworldMap
- lb bc, 4, 12
- xor a
- call Function842ab
- xor a
- ld [rSB], a
- ld [rSC], a
- ld [wc2d5], a
- ld hl, wc2d4
- set 0, [hl]
- ld a, [GBPrinter]
- ld [wcbfb], a
- xor a
- ld [wJumptableIndex], a
- ret
-; 84022
+INCLUDE "engine/printer.asm"
-Function84022: ; 84022
- ld a, [wJumptableIndex]
- ld e, a
- ld d, 0
- ld hl, Jumptable_84031
-rept 2
- add hl, de
-endr
- ld a, [hli]
- ld h, [hl]
- ld l, a
- jp [hl]
-; 84031
-
-
-Jumptable_84031: ; 84031 (21:4031)
- dw Function84077
- dw Function84143
- dw Function84120
- dw Function84099
- dw Function84180
- dw Function8412e
- dw Function840c5
- dw Function84180
- dw Function84120
- dw Function840de
- dw Function84180
- dw Function84120
- dw Function841a1
- dw Function84063
- dw Function8406d
- dw Function84120
- dw Function84103
- dw Function84071
- dw Function841b0
- dw Function841b3
-
-
-Function84059: ; 84059 (21:4059)
- ld hl, wJumptableIndex
- inc [hl]
- ret
-
-Function8405e: ; 8405e (21:405e)
- ld hl, wJumptableIndex
- dec [hl]
- ret
-
-Function84063: ; 84063 (21:4063)
- xor a
- ld [wca89], a
- ld hl, wJumptableIndex
- set 7, [hl]
- ret
-
-Function8406d: ; 8406d (21:406d)
- call Function84059
- ret
-
-Function84071: ; 84071 (21:4071)
- ld a, $1
- ld [wJumptableIndex], a
- ret
-
-Function84077: ; 84077 (21:4077)
- call Function841fb
- ld hl, Unknown_842b7
- call Function841e2
- xor a
- ld [wca8e], a
- ld [wca8f], a
- ld a, [wcf65]
- ld [wca81], a
- call Function84059
- call Function841c3
- ld a, $1
- ld [wcbf8], a
- ret
-
-Function84099: ; 84099 (21:4099)
- call Function841fb
- ld hl, wca81
- ld a, [hl]
- and a
- jr z, Function840c5
- ld hl, Unknown_842c3
- call Function841e2
- call Function84260
- ld a, $80
- ld [wca8e], a
- ld a, $2
- ld [wca8f], a
- call Function84219
- call Function84059
- call Function841c3
- ld a, $2
- ld [wcbf8], a
- ret
-
-Function840c5: ; 840c5 (21:40c5)
- ld a, $6
- ld [wJumptableIndex], a
- ld hl, Unknown_842c9
- call Function841e2
- xor a
- ld [wca8e], a
- ld [wca8f], a
- call Function84059
- call Function841c3
- ret
-
-Function840de: ; 840de (21:40de)
- call Function841fb
- ld hl, Unknown_842bd
- call Function841e2
- call Function84249
- ld a, $4
- ld [wca8e], a
- ld a, $0
- ld [wca8f], a
- call Function84219
- call Function84059
- call Function841c3
- ld a, $3
- ld [wcbf8], a
- ret
-
-Function84103: ; 84103 (21:4103)
- call Function841fb
- ld hl, Unknown_842b7
- call Function841e2
- xor a
- ld [wca8e], a
- ld [wca8f], a
- ld a, [wcf65]
- ld [wca81], a
- call Function84059
- call Function841c3
- ret
-
-Function84120: ; 84120 (21:4120)
- ld hl, wca8b
- inc [hl]
- ld a, [hl]
- cp $6
- ret c
- xor a
- ld [hl], a
- call Function84059
- ret
-
-Function8412e: ; 8412e (21:412e)
- ld hl, wca8b
- inc [hl]
- ld a, [hl]
- cp $6
- ret c
- xor a
- ld [hl], a
- ld hl, wca81
- dec [hl]
- call Function8405e
- call Function8405e
- ret
-
-Function84143: ; 84143 (21:4143)
- ld a, [wc2d5]
- and a
- ret nz
- ld a, [wca88]
- cp $ff
- jr nz, .printer_connected
- ld a, [wca89]
- cp $ff
- jr z, .printer_error
-
-.printer_connected
- ld a, [wca88]
- cp $81
- jr nz, .printer_error
- ld a, [wca89]
- cp $0
- jr nz, .printer_error
- ld hl, wc2d4
- set 1, [hl]
- ld a, $5
- ld [wca8a], a
- call Function84059
- ret
-
-.printer_error
- ld a, $ff
- ld [wca88], a
- ld [wca89], a
- ld a, $e
- ld [wJumptableIndex], a
- ret
-
-Function84180: ; 84180 (21:4180)
- ld a, [wc2d5]
- and a
- ret nz
- ld a, [wca89]
- and $f0
- jr nz, .asm_8419b
- ld a, [wca89]
- and $1
- jr nz, .asm_84197
- call Function84059
- ret
-.asm_84197
- call Function8405e
- ret
-.asm_8419b
- ld a, $12
- ld [wJumptableIndex], a
- ret
-
-Function841a1: ; 841a1 (21:41a1)
- ld a, [wc2d5]
- and a
- ret nz
- ld a, [wca89]
- and $f3
- ret nz
- call Function84059
- ret
-
-Function841b0: ; 841b0 (21:41b0)
- call Function84059
-
-Function841b3: ; 841b3 (21:41b3)
- ld a, [wc2d5]
- and a
- ret nz
- ld a, [wca89]
- and $f0
- ret nz
- xor a
- ld [wJumptableIndex], a
- ret
-
-Function841c3: ; 841c3 (21:41c3)
- ld a, [wc2d5]
- and a
- jr nz, Function841c3
- xor a
- ld [wca8c], a
- ld [wca8d], a
- ld a, $1
- ld [wc2d5], a
- ld a, $88
- ld [rSB], a
- ld a, $1
- ld [rSC], a
- ld a, $81
- ld [rSC], a
- ret
-
-Function841e2: ; 841e2 (21:41e2)
- ld a, [hli]
- ld [wca82], a
- ld a, [hli]
- ld [wca83], a
- ld a, [hli]
- ld [wca84], a
- ld a, [hli]
- ld [wca85], a
- ld a, [hli]
- ld [wca86], a
- ld a, [hl]
- ld [wca87], a
- ret
-
-Function841fb: ; 841fb (21:41fb)
- xor a
- ld hl, wca82
-rept 3
- ld [hli], a
-endr
- ld [hl], a
- ld hl, wca86
- ld [hli], a
- ld [hl], a
- xor a
- ld [wca8e], a
- ld [wca8f], a
- ld hl, OverworldMap
- ld bc, $280
- call Function842ab
- ret
-
-Function84219: ; 84219 (21:4219)
- ld hl, 0
- ld bc, $4
- ld de, wca82
- call Function8423c
- ld a, [wca8e]
- ld c, a
- ld a, [wca8f]
- ld b, a
- ld de, OverworldMap
- call Function8423c
- ld a, l
- ld [wca86], a
- ld a, h
- ld [wca87], a
- ret
-
-Function8423c: ; 8423c (21:423c)
- ld a, [de]
- inc de
- add l
- jr nc, .asm_84242
- inc h
-.asm_84242
- ld l, a
- dec bc
- ld a, c
- or b
- jr nz, Function8423c
- ret
-
-Function84249: ; 84249 (21:4249)
- ld a, $1
- ld [OverworldMap], a
- ld a, [wcbfa]
- ld [wc801], a
- ld a, $e4
- ld [wc802], a
- ld a, [wcbfb]
- ld [wc803], a
- ret
-
-Function84260: ; 84260 (21:4260)
- ld a, [wca81]
- xor $ff
- ld d, a
- ld a, [wcf65]
- inc a
- add d
- ld hl, wca90
- ld de, $28
-.asm_84271
- and a
- jr z, .asm_84278
- add hl, de
- dec a
- jr .asm_84271
-.asm_84278
- ld e, l
- ld d, h
- ld hl, OverworldMap
- ld c, $28
-.asm_8427f
- ld a, [de]
- inc de
- push bc
- push de
- push hl
- swap a
- ld d, a
- and $f0
- ld e, a
- ld a, d
- and $f
- ld d, a
- and $8
- ld a, d
- jr nz, .asm_84297
- or $90
- jr .asm_84299
-.asm_84297
- or $80
-.asm_84299
- ld d, a
- lb bc, $21, 1
- call Request2bpp
- pop hl
- ld de, $10
- add hl, de
- pop de
- pop bc
- dec c
- jr nz, .asm_8427f
- ret
-
-Function842ab: ; 842ab
- push de
- ld e, a
-.asm_842ad
- ld [hl], e
- inc hl
- dec bc
- ld a, c
- or b
- jr nz, .asm_842ad
- ld a, e
- pop de
- ret
-; 842b7
-
-Unknown_842b7: db 1, 0, $00, 0, 1, 0
-Unknown_842bd: db 2, 0, $04, 0, 0, 0
-Unknown_842c3: db 4, 0, $80, 2, 0, 0
-Unknown_842c9: db 4, 0, $00, 0, 4, 0
-Unknown_842cf: db 8, 0, $00, 0, 8, 0 ; unused
-Unknown_842d5: db 15, 0, $00, 0, 15, 0 ; unused
-; 842db
-
-
-Function842db:: ; 842db
- ld a, [wc2d5]
- add a
- ld e, a
- ld d, 0
- ld hl, Jumptable_842ea
- add hl, de
- ld a, [hli]
- ld h, [hl]
- ld l, a
- jp [hl]
-; 842ea
-
-
-Jumptable_842ea: ; 842ea (21:42ea)
- dw Function8432f
- dw Function84330
- dw Function84339
- dw Function84343
- dw Function8434d
- dw Function84357
- dw Function84361
- dw Function8438b
- dw Function84395
- dw Function8439f
- dw Function843a8
- dw Function843b6
- dw Function84330
- dw Function843c0
- dw Function843c9
- dw Function843c9
- dw Function843c9
- dw Function843c0
- dw Function843c9
- dw Function8439f
- dw Function843a8
- dw Function843e6
- dw Function84330
- dw Function843d2
- dw Function843c9
- dw Function843c9
- dw Function843c9
- dw Function843d2
- dw Function843c9
- dw Function8439f
- dw Function843a8
- dw Function843b6
-
-
-Function8432a: ; 8432a (21:432a)
- ld hl, wc2d5
- inc [hl]
- ret
-
-Function8432f: ; 8432f (21:432f)
- ret
-
-Function84330: ; 84330 (21:4330)
- ld a, $33
- call Function843db
- call Function8432a
- ret
-
-Function84339: ; 84339 (21:4339)
- ld a, [wca82]
- call Function843db
- call Function8432a
- ret
-
-Function84343: ; 84343 (21:4343)
- ld a, [wca83]
- call Function843db
- call Function8432a
- ret
-
-Function8434d: ; 8434d (21:434d)
- ld a, [wca84]
- call Function843db
- call Function8432a
- ret
-
-Function84357: ; 84357 (21:4357)
- ld a, [wca85]
- call Function843db
- call Function8432a
- ret
-
-Function84361: ; 84361 (21:4361)
- ld hl, wca8e
- ld a, [hli]
- ld d, [hl]
- ld e, a
- or d
- jr z, .asm_84388
- dec de
- ld [hl], d
- dec hl
- ld [hl], e
- ld a, [wca8c]
- ld e, a
- ld a, [wca8d]
- ld d, a
- ld hl, OverworldMap
- add hl, de
- inc de
- ld a, e
- ld [wca8c], a
- ld a, d
- ld [wca8d], a
- ld a, [hl]
- call Function843db
- ret
-.asm_84388
- call Function8432a
-
-Function8438b: ; 8438b (21:438b)
- ld a, [wca86]
- call Function843db
- call Function8432a
- ret
-
-Function84395: ; 84395 (21:4395)
- ld a, [wca87]
- call Function843db
- call Function8432a
- ret
-
-Function8439f: ; 8439f (21:439f)
- ld a, $0
- call Function843db
- call Function8432a
- ret
-
-Function843a8: ; 843a8 (21:43a8)
- ld a, [rSB]
- ld [wca88], a
- ld a, $0
- call Function843db
- call Function8432a
- ret
-
-Function843b6: ; 843b6 (21:43b6)
- ld a, [rSB]
- ld [wca89], a
- xor a
- ld [wc2d5], a
- ret
-
-Function843c0: ; 843c0 (21:43c0)
- ld a, $f
- call Function843db
- call Function8432a
- ret
-
-Function843c9: ; 843c9 (21:43c9)
- ld a, $0
- call Function843db
- call Function8432a
- ret
-
-Function843d2: ; 843d2 (21:43d2)
- ld a, $8
- call Function843db
- call Function8432a
- ret
-
-Function843db: ; 843db (21:43db)
- ld [rSB], a
- ld a, $1
- ld [rSC], a
- ld a, $81
- ld [rSC], a
- ret
-
-Function843e6: ; 843e6 (21:43e6)
- ld a, [rSB]
- ld [wca89], a
- xor a
- ld [wc2d5], a
- ret
-
-Function843f0: ; 843f0
-.asm_843f0
- call JoyTextDelay
- call Function846f6
- jr c, .asm_8440f
- ld a, [wJumptableIndex]
- bit 7, a
- jr nz, .asm_8440d
- call Function84022
- call Function84757
- call Function84785
- call DelayFrame
- jr .asm_843f0
-
-.asm_8440d
- and a
- ret
-
-.asm_8440f
- scf
- ret
-; 84411
-
-Function84411: ; 84411
- xor a
- ld [wc2d4], a
- ld [wc2d5], a
- ret
-; 84419
-
-Function84419: ; 84419
- push af
- call Function84000
- pop af
- ld [wcbfa], a
- call Function84728
- ret
-; 84425
-
-Function84425: ; 84425
- call ReturnToMapFromSubmenu
- call Function84753
- ret
-; 8442c
-
-Function8442c: ; 8442c
- ld a, [wcf65]
- push af
- ld hl, VTiles1
- ld de, FontInversed
- lb bc, BANK(FontInversed), $80
- call Request1bpp
- xor a
- ld [$ffac], a
- call Function8474c
- ld a, [rIE]
- push af
- xor a
- ld [rIF], a
- ld a, $9
- ld [rIE], a
- call Function84000
- ld a, $10
- ld [wcbfa], a
- callba Function1dc1b0
- call ClearTileMap
- ld a, $e4
- call DmgToCgbBGPals
- call DelayFrame
- ld hl, hVBlank
- ld a, [hl]
- push af
- ld [hl], $4
- ld a, $8
- ld [wcf65], a
- call Function84742
- call Function843f0
- jr c, .asm_8449d
- call Function84411
- ld c, 12
- call DelayFrames
- xor a
- ld [hBGMapMode], a
- call Function84000
- ld a, $3
- ld [wcbfa], a
- callba Function1dc213
- call Function84742
- ld a, $4
- ld [wcf65], a
- call Function843f0
-
-.asm_8449d
- pop af
- ld [hVBlank], a
- call Function84411
- xor a
- ld [rIF], a
- pop af
- ld [rIE], a
- call Function84425
- ld c, $8
-.asm_844ae
- call LowVolume
- call DelayFrame
- dec c
- jr nz, .asm_844ae
- pop af
- ld [wcf65], a
- ret
-; 844bc
-
-Function844bc: ; 844bc (21:44bc)
- ld a, [wcf65]
- push af
- ld a, $9
- ld [wcf65], a
- ld a, e
- ld [wd004], a
- ld a, d
- ld [StartFlypoint], a
- ld a, b
- ld [EndFlypoint], a
- ld a, c
- ld [MovementBuffer], a
- xor a
- ld [$ffac], a
- ld [wd003], a
- call Function8474c
- ld a, [rIE]
- push af
- xor a
- ld [rIF], a
- ld a, $9
- ld [rIE], a
- ld hl, hVBlank
- ld a, [hl]
- push af
- ld [hl], $4
- xor a
- ld [hBGMapMode], a
- call Function84817
- ld a, $10
- call Function84419
- call Function84559
- jr c, .asm_84545
- call Function84411
- ld c, 12
- call DelayFrames
- xor a
- ld [hBGMapMode], a
- call Function8486f
- ld a, $0
- call Function84419
- call Function84559
- jr c, .asm_84545
- call Function84411
- ld c, 12
- call DelayFrames
- xor a
- ld [hBGMapMode], a
- call Function84893
- ld a, $0
- call Function84419
- call Function84559
- jr c, .asm_84545
- call Function84411
- ld c, 12
- call DelayFrames
- xor a
- ld [hBGMapMode], a
- call Function848b7
- ld a, $3
- call Function84419
- call Function84559
-.asm_84545
- pop af
- ld [hVBlank], a
- call Function84411
- xor a
- ld [rIF], a
- pop af
- ld [rIE], a
- call Function84425
- pop af
- ld [wcf65], a
- ret
-
-Function84559: ; 84559 (21:4559)
- call Function84742
- call Function843f0
- ret
-
-Function84560: ; 84560
- ld a, [wcf65]
- push af
- xor a
- ld [$ffac], a
- call Function8474c
- ld a, [rIE]
- push af
- xor a
- ld [rIF], a
- ld a, $9
- ld [rIE], a
- ld hl, hVBlank
- ld a, [hl]
- push af
- ld [hl], $4
- xor a
- ld [hBGMapMode], a
- call LoadTileMapToTempTileMap
- callba Function16dac
- ld a, $0
- call Function84419
- call Call_LoadTempTileMapToTileMap
- call Function84742
- ld a, $9
- ld [wcf65], a
-.asm_84597
- call JoyTextDelay
- call Function846f6
- jr c, .asm_845c0
- ld a, [wJumptableIndex]
- bit 7, a
- jr nz, .asm_845c0
- call Function84022
- ld a, [wJumptableIndex]
- cp $2
- jr nc, .asm_845b5
- ld a, $3
- ld [wca81], a
-
-.asm_845b5
- call Function84757
- call Function84785
- call DelayFrame
- jr .asm_84597
-
-.asm_845c0
- pop af
- ld [hVBlank], a
- call Function84411
- call Call_LoadTempTileMapToTileMap
- xor a
- ld [rIF], a
- pop af
- ld [rIE], a
- pop af
- ld [wcf65], a
- ret
-; 845d4
-
-Function845d4: ; 845d4
- call Function845db
- call Function84425
- ret
-; 845db
-
-Function845db: ; 845db
- ld a, [wcf65]
- push af
- xor a
- ld [$ffac], a
- call Function8474c
- ld a, [rIE]
- push af
- xor a
- ld [rIF], a
- ld a, $9
- ld [rIE], a
- xor a
- ld [hBGMapMode], a
- ld a, $13
- call Function84419
- ld hl, hVBlank
- ld a, [hl]
- push af
- ld [hl], $4
- ld a, $9
- ld [wcf65], a
- call Function843f0
- pop af
- ld [hVBlank], a
- call Function84411
- call Function84735
- xor a
- ld [rIF], a
- pop af
- ld [rIE], a
- pop af
- ld [wcf65], a
- ret
-; 8461a
-
-Function8461a: ; 8461a
- ld a, [wcf65]
- push af
- xor a
- ld [$ffac], a
- call Function8474c
- ld a, [rIE]
- push af
- xor a
- ld [rIF], a
- ld a, $9
- ld [rIE], a
- xor a
- ld [hBGMapMode], a
- callba Function1dc381
- ld a, $10
- call Function84419
- ld hl, hVBlank
- ld a, [hl]
- push af
- ld [hl], $4
- ld a, $8
- ld [wcf65], a
- call Function84742
- call Function843f0
- jr c, .asm_84671
- call Function84411
- ld c, 12
- call DelayFrames
- xor a
- ld [hBGMapMode], a
- callba Function1dc47b
- ld a, $3
- call Function84419
- ld a, $9
- ld [wcf65], a
- call Function84742
- call Function843f0
-
-.asm_84671
- pop af
- ld [hVBlank], a
- call Function84411
- call Function84735
- xor a
- ld [rIF], a
- pop af
- ld [rIE], a
- call Function84425
- pop af
- ld [wcf65], a
- ret
-; 84688
-
-_PrintDiploma: ; 84688
- ld a, [wcf65]
- push af
- callba Function1dd709
- xor a
- ld [$ffac], a
- call Function8474c
- ld a, [rIE]
- push af
- xor a
- ld [rIF], a
- ld a, $9
- ld [rIE], a
- ld hl, hVBlank
- ld a, [hl]
- push af
- ld [hl], $4
- ld a, $10
- call Function84419
- call Function84742
- ld a, $9
- ld [wcf65], a
- call Function843f0
- jr c, .asm_846e2
- call Function84411
- ld c, 12
- call DelayFrames
- call LoadTileMapToTempTileMap
- xor a
- ld [hBGMapMode], a
- callba Function1dd7ae
- ld a, $3
- call Function84419
- call Call_LoadTempTileMapToTileMap
- call Function84742
- ld a, $9
- ld [wcf65], a
- call Function843f0
-
-.asm_846e2
- pop af
- ld [hVBlank], a
- call Function84411
- xor a
- ld [rIF], a
- pop af
- ld [rIE], a
- call Function84425
- pop af
- ld [wcf65], a
- ret
-; 846f6
-
-Function846f6: ; 846f6
- ld a, [hJoyDown]
- and B_BUTTON
- jr nz, .asm_846fe
- and a
- ret
-
-.asm_846fe
- ld a, [wca80]
- cp $c
- jr nz, .asm_84722
-.asm_84705
- ld a, [wc2d5]
- and a
- jr nz, .asm_84705
- ld a, $16
- ld [wc2d5], a
- ld a, $88
- ld [rSB], a
- ld a, $1
- ld [rSC], a
- ld a, $81
- ld [rSC], a
-.asm_8471c
- ld a, [wc2d5]
- and a
- jr nz, .asm_8471c
-
-.asm_84722
- ld a, $1
- ld [$ffac], a
- scf
- ret
-; 84728
-
-Function84728: ; 84728
- hlcoord 0, 0
- ld de, wca90
- ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
- call CopyBytes
- ret
-; 84735
-
-Function84735: ; 84735
- ld hl, wca90
- decoord 0, 0
- ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
- call CopyBytes
- ret
-; 84742
-
-Function84742: ; 84742
- xor a
- ld [hJoyReleased], a
- ld [hJoyPressed], a
- ld [hJoyDown], a
- ld [hJoyLast], a
- ret
-; 8474c
-
-Function8474c: ; 8474c
- ld de, MUSIC_PRINTER
- call PlayMusic2
- ret
-; 84753
-
-Function84753: ; 84753
- call RestartMapMusic
- ret
-; 84757
-
-Function84757: ; 84757
- ld a, [wca88]
- cp -1
- jr nz, .printer_connected
- ld a, [wca89]
- cp -1
- jr z, .error_2
-
-.printer_connected
- ld a, [wca89]
- and %11100000
- ret z ; no error
-
- bit 7, a
- jr nz, .error_1
- bit 6, a
- jr nz, .error_4
- ld a, 6 ; error 3
- jr .load_text_index
-
-.error_4
- ld a, 7 ; error 4
- jr .load_text_index
-
-.error_1
- ld a, 4 ; error 1
- jr .load_text_index
-
-.error_2
- ld a, 5 ; error 2
-
-.load_text_index
- ld [wcbf8], a
- ret
-; 84785
-
-Function84785: ; 84785
- ld a, [wcbf8]
- and a
- ret z
- push af
- xor a
- ld [hBGMapMode], a
- hlcoord 0, 5
- lb bc, 10, 18
- call TextBox
- pop af
- ld e, a
- ld d, 0
- ld hl, PrinterStatusStringPointers
-rept 2
- add hl, de
-endr
- ld e, [hl]
- inc hl
- ld d, [hl]
- hlcoord 1, 7
- ld a, BANK(GBPrinterStrings)
- call FarString
- hlcoord 2, 15
- ld de, String_PressBToCancel
- call PlaceString
- ld a, $1
- ld [hBGMapMode], a
- xor a
- ld [wcbf8], a
- ret
-; 847bd
-
-Function847bd: ; 847bd
- ld a, [wcbf8]
- and a
- ret z
- push af
- xor a
- ld [hBGMapMode], a
- hlcoord 2, 4
- lb bc, 13, 16
- call ClearBox
- pop af
- ld e, a
- ld d, 0
- ld hl, PrinterStatusStringPointers
-rept 2
- add hl, de
-endr
- ld e, [hl]
- inc hl
- ld d, [hl]
- hlcoord 4, 7
- ld a, BANK(GBPrinterStrings)
- call FarString
- hlcoord 4, 15
- ld de, String_PressBToCancel
- call PlaceString
- ld a, $1
- ld [hBGMapMode], a
- xor a
- ld [wcbf8], a
- ret
-; 847f5
-
-String_PressBToCancel:
- db "Press B to Cancel@"
-; 84807
-
-PrinterStatusStringPointers: ; 84807
- dw String_1dc275 ; @
- dw String_1dc276 ; CHECKING LINK
- dw String_1dc289 ; TRANSMITTING
- dw String_1dc29c ; PRINTING
- dw String_1dc2ad ; error 1
- dw String_1dc2e2 ; error 2
- dw String_1dc317 ; error 3
- dw String_1dc34c ; error 4
-; 84817
-
-Function84817: ; 84817 (21:4817)
- xor a
- ld [wd002], a
- hlcoord 0, 0
- ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
- ld a, " "
- call ByteFill
- call Function84a0e
- hlcoord 0, 0
- ld bc, 9 * SCREEN_WIDTH
- ld a, " "
- call ByteFill
- call Function849e9
- call Function849d7
- hlcoord 4, 3
- ld de, String_84865
- call PlaceString
- ld a, [wd007]
- ld bc, BOX_NAME_LENGTH
- ld hl, wBoxNames
- call AddNTimes
- ld d, h
- ld e, l
- hlcoord 6, 5
- call PlaceString
- ld a, $1
- call Function849c6
- hlcoord 2, 9
- ld c, $3
- call Function848e7
- ret
-; 84865 (21:4865)
-
-String_84865:
- db "#MON LIST@"
-; 8486f
-
-Function8486f: ; 8486f (21:486f)
- hlcoord 0, 0
- ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
- ld a, " "
- call ByteFill
- call Function84a0e
- call Function849e9
- ld a, [wd003]
- and a
- ret nz
- ld a, $4
- call Function849c6
- hlcoord 2, 0
- ld c, $6
- call Function848e7
- ret
-
-Function84893: ; 84893 (21:4893)
- hlcoord 0, 0
- ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
- ld a, " "
- call ByteFill
- call Function84a0e
- call Function849e9
- ld a, [wd003]
- and a
- ret nz
- ld a, $a
- call Function849c6
- hlcoord 2, 0
- ld c, $6
- call Function848e7
- ret
-
-Function848b7: ; 848b7 (21:48b7)
- hlcoord 0, 0
- ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
- ld a, " "
- call ByteFill
- call Function84a0e
- hlcoord 1, 15
- lb bc, 2, 18
- call ClearBox
- call Function849e9
- call Function849fc
- ld a, [wd003]
- and a
- ret nz
- ld a, $10
- call Function849c6
- hlcoord 2, 0
- ld c, $5
- call Function848e7
- ret
-
-Function848e7: ; 848e7 (21:48e7)
- ld a, [EndFlypoint]
- call GetSRAMBank
-
-Function848ed: ; 848ed (21:48ed)
- ld a, c
- and a
- jp z, Function84986
- dec c
- ld a, [de]
- cp $ff
- jp z, Function84981
- ld [wd265], a
- ld [CurPartySpecies], a
- push bc
- push hl
- push de
- push hl
- ld bc, $10
- ld a, " "
- call ByteFill
- pop hl
- push hl
- call GetBasePokemonName
- pop hl
- push hl
- call PlaceString
- ld a, [CurPartySpecies]
- cp $fd
- pop hl
- jr z, .ok2
- ld bc, $b
- add hl, bc
- call Function8498a
- ld bc, $9
- add hl, bc
- ld a, $f3
- ld [hli], a
- push hl
- ld bc, $e
- ld a, " "
- call ByteFill
- pop hl
- push hl
- ld a, [wd004]
- ld l, a
- ld a, [StartFlypoint]
- ld h, a
- ld bc, $372
- add hl, bc
- ld bc, $b
- ld a, [wd002]
- call AddNTimes
- ld e, l
- ld d, h
- pop hl
- push hl
- call PlaceString
- pop hl
- ld bc, $b
- add hl, bc
- push hl
- ld a, [wd004]
- ld l, a
- ld a, [StartFlypoint]
- ld h, a
- ld bc, $35
- add hl, bc
- ld bc, $20
- ld a, [wd002]
- call AddNTimes
- ld a, [hl]
- pop hl
- call Function383d
-.ok2
- ld hl, wd002
- inc [hl]
- pop de
- pop hl
- ld bc, $3c
- add hl, bc
- pop bc
- inc de
- jp Function848ed
-
-Function84981: ; 84981 (21:4981)
- ld a, $1
- ld [wd003], a
-
-Function84986: ; 84986 (21:4986)
- call CloseSRAM
- ret
-
-Function8498a: ; 8498a (21:498a)
- push hl
- ld a, [wd004]
- ld l, a
- ld a, [StartFlypoint]
- ld h, a
- ld bc, $2b
- add hl, bc
- ld bc, $20
- ld a, [wd002]
- call AddNTimes
- ld de, TempMonDVs
- ld a, [hli]
- ld [de], a
- inc de
- ld a, [hli]
- ld [de], a
- ld a, [wd002]
- ld [CurPartyMon], a
- ld a, $3
- ld [MonType], a
- callba GetGender
- ld a, $7f
- jr c, .asm_849c3
- ld a, $ef
- jr nz, .asm_849c3
- ld a, $f5
-.asm_849c3
- pop hl
- ld [hli], a
- ret
-
-Function849c6: ; 849c6 (21:49c6)
- push hl
- ld e, a
- ld d, $0
- ld a, [wd004]
- ld l, a
- ld a, [StartFlypoint]
- ld h, a
- add hl, de
- ld e, l
- ld d, h
- pop hl
- ret
-
-Function849d7: ; 849d7 (21:49d7)
- hlcoord 0, 0
- ld a, $79
- ld [hli], a
- ld a, $7a
- ld c, $12
-.asm_849e1
- ld [hli], a
- dec c
- jr nz, .asm_849e1
- ld a, $7b
- ld [hl], a
- ret
-
-Function849e9: ; 849e9 (21:49e9)
- hlcoord 0, 0
- ld de, $13
- ld c, $12
-.asm_849f1
- ld a, $7c
- ld [hl], a
- add hl, de
- ld a, $7c
- ld [hli], a
- dec c
- jr nz, .asm_849f1
- ret
-
-Function849fc: ; 849fc (21:49fc)
- hlcoord 0, 17
- ld a, $7d
- ld [hli], a
- ld a, $7a
- ld c, $12
-.asm_84a06
- ld [hli], a
- dec c
- jr nz, .asm_84a06
- ld a, $7e
- ld [hl], a
- ret
-
-Function84a0e: ; 84a0e (21:4a0e)
- hlcoord 2, 0
- ld c, $6
-.asm_84a13
- push bc
- push hl
- ld de, String84a25
- call PlaceString
- pop hl
- ld bc, $3c
- add hl, bc
- pop bc
- dec c
- jr nz, .asm_84a13
- ret
-; 84a25 (21:4a25)
-
-String84a25: ; 84a25
- db " ------@"
-; 84a2e
-
-
INCLUDE "battle/anim_gfx.asm"
+INCLUDE "event/halloffame.asm"
-HallOfFame:: ; 0x8640e
- call Function8648e
- ld a, [StatusFlags]
- push af
- ld a, 1
- ld [wc2cd], a
- call DisableSpriteUpdates
- ld a, SPAWN_LANCE
- ld [wSpawnAfterChampion], a
-
- ; Enable the Pokégear map to cycle through all of Kanto
- ld hl, StatusFlags
- set 6, [hl] ; hall of fame
-
- callba Function14da0
-
- ld hl, wHallOfFameCount
- ld a, [hl]
- cp 200
- jr nc, .ok
- inc [hl]
-.ok
- callba SaveGameData
- call GetHallOfFameParty
- callba AddHallOfFameEntry
-
- xor a
- ld [wc2cd], a
- call Function864c3
- pop af
- ld b, a
- callba Function109847
- ret
-; 0x86455
-
-RedCredits:: ; 86455
- ld a, MUSIC_NONE % $100
- ld [MusicFadeIDLo], a
- ld a, MUSIC_NONE / $100
- ld [MusicFadeIDHi], a
- ld a, $a
- ld [MusicFade], a
- callba FadeOutPalettes
- xor a
- ld [VramState], a
- ld [hMapAnims], a
- callba Function4e8c2
- ld c, 8
- call DelayFrames
- call DisableSpriteUpdates
- ld a, SPAWN_RED
- ld [wSpawnAfterChampion], a
- ld a, [StatusFlags]
- ld b, a
- callba Function109847
- ret
-; 8648e
-
-Function8648e: ; 8648e
- ld a, MUSIC_NONE % $100
- ld [MusicFadeIDLo], a
- ld a, MUSIC_NONE / $100
- ld [MusicFadeIDHi], a
- ld a, 10
- ld [MusicFade], a
- callba FadeOutPalettes
- xor a
- ld [VramState], a
- ld [hMapAnims], a
- callba Function4e881
- ld c, 100
- jp DelayFrames
-; 864b4
-
-Function864b4: ; 864b4
- push de
- ld de, MUSIC_NONE
- call PlayMusic
- call DelayFrame
- pop de
- call PlayMusic
- ret
-; 864c3
-
-Function864c3: ; 864c3
- xor a
- ld [wJumptableIndex], a
- call Function8671c
- jr c, .done
- ld de, SCREEN_WIDTH
- call Function864b4
- xor a
- ld [wcf64], a
-.loop
- ld a, [wcf64]
- cp 6
- jr nc, .done
- ld hl, wc608 + 1
- ld bc, $10
- call AddNTimes
- ld a, [hl]
- cp -1
- jr z, .done
- push hl
- call Function865b5
- pop hl
- call Function8650c
- jr c, .done
- ld hl, wcf64
- inc [hl]
- jr .loop
-
-.done
- call Function86810
- ld a, $4
- ld [MusicFade], a
- call FadeToWhite
- ld c, 8
- call DelayFrames
- ret
-; 8650c
-
-Function8650c: ; 8650c
- call Function86748
- ld de, String_8652c
- hlcoord 1, 2
- call PlaceString
- call WaitBGMap
- decoord 6, 5
- ld c, $6
- predef Functiond066e
- ld c, 60
- call DelayFrames
- and a
- ret
-; 8652c
-
-String_8652c:
- db "New Hall of Famer!@"
-; 8653f
-
-
-GetHallOfFameParty: ; 8653f
- ld hl, OverworldMap
- ld bc, HOF_LENGTH
- xor a
- call ByteFill
- ld a, [wHallOfFameCount]
- ld de, OverworldMap
- ld [de], a
- inc de
- ld hl, PartySpecies
- ld c, 0
-.next
- ld a, [hli]
- cp -1
- jr z, .done
- cp EGG
- jr nz, .mon
- inc c
- jr .next
-
-.mon
- push hl
- push de
- push bc
-
- ld a, c
- ld hl, PartyMons
- ld bc, PARTYMON_STRUCT_LENGTH
- call AddNTimes
- ld c, l
- ld b, h
-
- ld hl, MON_SPECIES
- add hl, bc
- ld a, [hl]
- ld [de], a
- inc de
-
- ld hl, MON_ID
- add hl, bc
- ld a, [hli]
- ld [de], a
- inc de
- ld a, [hl]
- ld [de], a
- inc de
-
- ld hl, MON_DVS
- add hl, bc
- ld a, [hli]
- ld [de], a
- inc de
- ld a, [hl]
- ld [de], a
- inc de
-
- ld hl, MON_LEVEL
- add hl, bc
- ld a, [hl]
- ld [de], a
- inc de
-
- pop bc
- push bc
- ld a, c
- ld hl, PartyMonNicknames
- ld bc, PKMN_NAME_LENGTH
- call AddNTimes
- ld bc, PKMN_NAME_LENGTH - 1
- call CopyBytes
-
- pop bc
- inc c
- pop de
- ld hl, HOF_MON_LENGTH
- add hl, de
- ld e, l
- ld d, h
- pop hl
- jr .next
-
-.done
- ld a, $ff
- ld [de], a
- ret
-; 865b5
-
-Function865b5: ; 865b5
- push hl
- call ClearBGPalettes
- callba Function4e906
- pop hl
- ld a, [hli]
- ld [TempMonSpecies], a
- ld [CurPartySpecies], a
-rept 2
- inc hl
-endr
- ld a, [hli]
- ld [TempMonDVs], a
- ld a, [hli]
- ld [TempMonDVs + 1], a
- ld hl, TempMonDVs
- predef GetUnownLetter
- hlcoord 0, 0
- ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
- ld a, " "
- call ByteFill
- ld de, VTiles2 tile $31
- predef GetBackpic
- ld a, $31
- ld [hFillBox], a
- hlcoord 6, 6
- lb bc, 6, 6
- predef FillBox
- ld a, $d0
- ld [hSCY], a
- ld a, $90
- ld [hSCX], a
- call WaitBGMap
- xor a
- ld [hBGMapMode], a
- ld b, SCGB_1A
- call GetSGBLayout
- call SetPalettes
- call Function86635
- xor a
- ld [wc2c6], a
- hlcoord 0, 0
- ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
- ld a, " "
- call ByteFill
- hlcoord 6, 5
- call _PrepMonFrontpic
- call WaitBGMap
- xor a
- ld [hBGMapMode], a
- ld [hSCY], a
- call Function86643
- ret
-; 86635
-
-Function86635: ; 86635
-.loop
- ld a, [hSCX]
- cp $70
- ret z
- add $4
- ld [hSCX], a
- call DelayFrame
- jr .loop
-; 86643
-
-Function86643: ; 86643
-.loop
- ld a, [hSCX]
- and a
- ret z
-rept 2
- dec a
-endr
- ld [hSCX], a
- call DelayFrame
- jr .loop
-; 86650
-
-_HallOfFamePC: ; 86650
- call LoadFontsBattleExtra
- xor a
- ld [wJumptableIndex], a
-.loop
- call Function8671c
- ret c
- call Function86665
- ret c
- ld hl, wJumptableIndex
- inc [hl]
- jr .loop
-; 86665
-
-Function86665: ; 86665
- xor a
- ld [wcf64], a
-.next
- call Function86692
- jr c, .start_button
-.loop
- call JoyTextDelay
- ld hl, hJoyLast
- ld a, [hl]
- and B_BUTTON
- jr nz, .b_button
- ld a, [hl]
- and A_BUTTON
- jr nz, .a_button
- ld a, [hl]
- and START
- jr nz, .start_button
- call DelayFrame
- jr .loop
-
-.a_button
- ld hl, wcf64
- inc [hl]
- jr .next
-
-.b_button
- scf
- ret
-
-.start_button
- and a
- ret
-; 86692
-
-Function86692: ; 86692
-; Print the number of times the player has entered the Hall of Fame.
-; If that number is above 200, print "HOF Master!" instead.
- ld a, [wcf64]
- cp $6
- jr nc, .fail
- ld hl, wc608 + 1
- ld bc, $10
- call AddNTimes
- ld a, [hl]
- cp $ff
- jr nz, .okay
-
-.fail
- scf
- ret
-
-.okay
- push hl
- call ClearBGPalettes
- pop hl
- call Function86748
- ld a, [wc608]
- cp 200 + 1
- jr c, .print_num_hof
- ld de, String_866fc
- hlcoord 1, 2
- call PlaceString
- hlcoord 13, 2
- jr .finish
-
-.print_num_hof
- ld de, String_8670c
- hlcoord 1, 2
- call PlaceString
- hlcoord 2, 2
- ld de, wc608
- lb bc, 1, 3
- call PrintNum
- hlcoord 11, 2
-
-.finish
- ld de, String_866fb
- call PlaceString
- call WaitBGMap
- ld b, SCGB_1A
- call GetSGBLayout
- call SetPalettes
- decoord 6, 5
- ld c, $6
- predef Functiond066e
- and a
- ret
-; 866fb
-
-String_866fb:
- db "@"
-; 866fc
-
-String_866fc:
- db " HOF Master!@"
-; 8670c
-
-String_8670c:
- db " -Time Famer@"
-; 8671c
-
-
-Function8671c: ; 8671c
- ld a, [wJumptableIndex]
- cp NUM_HOF_TEAMS
- jr nc, .full
- ld hl, sHallOfFame
- ld bc, HOF_LENGTH
- call AddNTimes
- ld a, BANK(sHallOfFame)
- call GetSRAMBank
- ld a, [hl]
- and a
- jr z, .fail
- ld de, wc608
- ld bc, HOF_LENGTH
- call CopyBytes
- call CloseSRAM
- and a
- ret
-
-.fail
- call CloseSRAM
-
-.full
- scf
- ret
-; 86748
-
-Function86748: ; 86748
- xor a
- ld [hBGMapMode], a
- ld a, [hli]
- ld [TempMonSpecies], a
- ld a, [hli]
- ld [TempMonID], a
- ld a, [hli]
- ld [TempMonID + 1], a
- ld a, [hli]
- ld [TempMonDVs], a
- ld a, [hli]
- ld [TempMonDVs + 1], a
- ld a, [hli]
- ld [TempMonLevel], a
- ld de, StringBuffer2
- ld bc, 10
- call CopyBytes
- ld a, "@"
- ld [StringBuffer2 + 10], a
- hlcoord 0, 0
- ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
- ld a, " "
- call ByteFill
- hlcoord 0, 0
- lb bc, 3, SCREEN_WIDTH - 2
- call TextBox
- hlcoord 0, 12
- lb bc, 4, SCREEN_WIDTH - 2
- call TextBox
- ld a, [TempMonSpecies]
- ld [CurPartySpecies], a
- ld [wd265], a
- ld hl, TempMonDVs
- predef GetUnownLetter
- xor a
- ld [wc2c6], a
- hlcoord 6, 5
- call _PrepMonFrontpic
- ld a, [CurPartySpecies]
- cp EGG
- jr z, .print_id_no
- hlcoord 1, 13
- ld a, $74
- ld [hli], a
- ld [hl], $f2
- hlcoord 3, 13
- ld de, wd265
- lb bc, PRINTNUM_LEADINGZEROS | 1, 3
- call PrintNum
- call GetBasePokemonName
- hlcoord 7, 13
- call PlaceString
- ld a, $3
- ld [MonType], a
- callba GetGender
- ld a, " "
- jr c, .got_gender
- ld a, "♂"
- jr nz, .got_gender
- ld a, "♀"
-
-.got_gender
- hlcoord 18, 13
- ld [hli], a
- hlcoord 8, 14
- ld a, "/"
- ld [hli], a
- ld de, StringBuffer2
- call PlaceString
- hlcoord 1, 16
- call PrintLevel
-
-.print_id_no
- hlcoord 7, 16
- ld a, "<ID>"
- ld [hli], a
- ld a, "№"
- ld [hli], a
- ld [hl], "/"
- hlcoord 10, 16
- ld de, TempMonID
- lb bc, PRINTNUM_LEADINGZEROS | 2, 5
- call PrintNum
- ret
-; 86810
-
-Function86810: ; 86810
- call ClearBGPalettes
- ld hl, VTiles2 tile $63
- ld de, FontExtra + $d0
- lb bc, BANK(FontExtra), 1
- call Request2bpp
- hlcoord 0, 0
- ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
- ld a, " "
- call ByteFill
- callba GetPlayerBackpic
- ld a, $31
- ld [hFillBox], a
- hlcoord 6, 6
- lb bc, 6, 6
- predef FillBox
- ld a, $d0
- ld [hSCY], a
- ld a, $90
- ld [hSCX], a
- call WaitBGMap
- xor a
- ld [hBGMapMode], a
- ld [CurPartySpecies], a
- ld b, SCGB_1A
- call GetSGBLayout
- call SetPalettes
- call Function86635
- xor a
- ld [wc2c6], a
- hlcoord 0, 0
- ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
- ld a, " "
- call ByteFill
- callba Function88840
- xor a
- ld [hFillBox], a
- hlcoord 12, 5
- lb bc, 7, 7
- predef FillBox
- ld a, $c0
- ld [hSCX], a
- call WaitBGMap
- xor a
- ld [hBGMapMode], a
- ld [hSCY], a
- call Function86643
- xor a
- ld [hBGMapMode], a
- hlcoord 0, 2
- lb bc, 8, 9
- call TextBox
- hlcoord 0, 12
- lb bc, 4, 18
- call TextBox
- hlcoord 2, 4
- ld de, PlayerName
- call PlaceString
- hlcoord 1, 6
- ld a, $73
- ld [hli], a
- ld a, $74
- ld [hli], a
- ld [hl], $f3
- hlcoord 4, 6
- ld de, PlayerID
- lb bc, PRINTNUM_LEADINGZEROS | 2, 5
- call PrintNum
- hlcoord 1, 8
- ld de, .PlayTime
- call PlaceString
- hlcoord 3, 9
- ld de, GameTimeHours
- lb bc, 2, 3
- call PrintNum
- ld [hl], $63
- inc hl
- ld de, GameTimeMinutes
- lb bc, PRINTNUM_LEADINGZEROS | 1, 2
- call PrintNum
- call WaitBGMap
- callba Function26601
- ret
-; 868ed
-
-.PlayTime
- db "PLAY TIME@"
-; 868f7
-
-
SECTION "bank22", ROMX, BANK[$22]
INCLUDE "event/kurt.asm"
@@ -29053,544 +25175,7 @@
INCLUDE "engine/sprites.asm"
-Function8e79d: ; 8e79d
- ld a, [hSGB]
- ld de, GFX_8e7f4
- and a
- jr z, .asm_8e7a8
- ld de, GFX_8e804
-.asm_8e7a8
- ld hl, VTiles0
- lb bc, BANK(GFX_8e7f4), 1
- call Request2bpp
- ld c, $8
- ld d, $0
-.asm_8e7b5
- push bc
- call Function8e7c6
- call DelayFrame
- pop bc
-rept 2
- inc d
-endr
- dec c
- jr nz, .asm_8e7b5
- call ClearSprites
- ret
-; 8e7c6
-
-Function8e7c6: ; 8e7c6
- ld hl, Sprites
- ld c, $8
-.asm_8e7cb
- ld a, c
- and a
- ret z
- dec c
- ld a, c
- sla a
- sla a
- sla a
- push af
- push de
- push hl
- call Function8e72c
- pop hl
- pop de
- add $68
- ld [hli], a
- pop af
- push de
- push hl
- call Function8e72a
- pop hl
- pop de
- add $54
- ld [hli], a
- ld a, $0
- ld [hli], a
- ld a, $6
- ld [hli], a
- jr .asm_8e7cb
-; 8e7f4
-
-GFX_8e7f4: ; 8e7f4
-INCBIN "gfx/unknown/08e7f4.2bpp"
-GFX_8e804: ; 8e804
-INCBIN "gfx/unknown/08e804.2bpp"
-
-InefficientlyClear121BytesAtwc300: ; 8e814
- push hl
- push de
- push bc
- push af
- ld hl, wc300
- ld bc, wc3c1 - wc300
-.loop
- ld [hl], $0
- inc hl
- dec bc
- ld a, c
- or b
- jr nz, .loop
- pop af
- pop bc
- pop de
- pop hl
- ret
-; 8e82b
-
-Function8e82b: ; 8e82b
- ld a, e
- call ReadMonMenuIcon
- ld l, a
- ld h, 0
- add hl, hl
- ld de, IconPointers
- add hl, de
- ld a, [hli]
- ld e, a
- ld d, [hl]
- ld b, BANK(Icons)
- ld c, 8
- ret
-; 8e83f
-
-Function8e83f: ; 8e83f
- push hl
- push de
- push bc
- call Function8e849
- pop bc
- pop de
- pop hl
- ret
-; 8e849
-
-Function8e849: ; 8e849
- ld d, 0
- ld hl, Jumptable_8e854
-rept 2
- add hl, de
-endr
- ld a, [hli]
- ld h, [hl]
- ld l, a
- jp [hl]
-; 8e854
-
-
-Jumptable_8e854: ; 8e854 (23:6854)
- dw Function8e8d5
- dw Function8e961
- dw Function8e97d
- dw Function8e99a
- dw Function8e898
- dw Function8e8b1
- dw Function8e862
-
-
-Function8e862: ; 8e862 (23:6862)
- call Function8e908
- call Function8e86c
- call Function8e936
- ret
-
-Function8e86c: ; 8e86c (23:686c)
- push bc
- ld a, [hObjectStructIndexBuffer]
- ld hl, PartyMon1Item
- ld bc, PARTYMON_STRUCT_LENGTH
- call AddNTimes
- pop bc
- ld a, [hl]
- and a
- jr z, .asm_8e890
- push hl
- push bc
- ld d, a
- callab ItemIsMail
- pop bc
- pop hl
- jr c, .asm_8e88e
- ld a, $6
- jr .asm_8e892
-.asm_8e88e
- ld a, $5
-.asm_8e890
- ld a, $4
-.asm_8e892
- ld hl, $1
- add hl, bc
- ld [hl], a
- ret
-
-Function8e898: ; 8e898 (23:6898)
- call Function8e8d5
- ld hl, $2
- add hl, bc
- ld a, $0
- ld [hl], a
- ld hl, $4
- add hl, bc
- ld a, $48
- ld [hl], a
- ld hl, $5
- add hl, bc
- ld a, $48
- ld [hl], a
- ret
-
-Function8e8b1: ; 8e8b1 (23:68b1)
- call Function8e908
- call Function8e936
- ld hl, $2
- add hl, bc
- ld a, $0
- ld [hl], a
- ld hl, $4
- add hl, bc
- ld a, $18
- ld [hl], a
- ld hl, $5
- add hl, bc
- ld a, $60
- ld [hl], a
- ld a, c
- ld [wc608], a
- ld a, b
- ld [wc608 + 1], a
- ret
-
-Function8e8d5: ; 8e8d5 (23:68d5)
- call Function8e908
- call Function8e8df
- call Function8e936
- ret
-
-Function8e8df: ; 8e8df (23:68df)
- push bc
- ld a, [hObjectStructIndexBuffer]
- ld hl, PartyMon1Item
- ld bc, $30
- call AddNTimes
- pop bc
- ld a, [hl]
- and a
- ret z
- push hl
- push bc
- ld d, a
- callab ItemIsMail
- pop bc
- pop hl
- jr c, .asm_8e900
- ld a, $3
- jr .asm_8e902
-.asm_8e900
- ld a, $2
-.asm_8e902
- ld hl, $1
- add hl, bc
- ld [hl], a
- ret
-
-Function8e908: ; 8e908 (23:6908)
- ld a, [wc3b7]
- push af
- ld a, [hObjectStructIndexBuffer]
- ld hl, PartySpecies
- ld e, a
- ld d, $0
- add hl, de
- ld a, [hl]
- call ReadMonMenuIcon
- ld [CurIcon], a
- call Function8e9db
- ld a, [hObjectStructIndexBuffer]
-; y coord
-rept 4
- add a
-endr
- add $1c
- ld d, a
-; x coord
- ld e, $10
-; type is partymon icon
- ld a, SPRITE_ANIM_INDEX_00
- call InitSpriteAnimStruct
- pop af
- ld hl, $3
- add hl, bc
- ld [hl], a
- ret
-
-Function8e936: ; 8e936 (23:6936)
- push bc
- ld a, [hObjectStructIndexBuffer]
- ld b, a
- call Function8e94c
- ld a, b
- pop bc
- ld hl, $9
- add hl, bc
- ld [hl], a
- rlca
- rlca
- ld hl, $d
- add hl, bc
- ld [hl], a
- ret
-
-Function8e94c: ; 8e94c (23:694c)
- callba PlacePartymonHPBar
- call GetHPPal
- ld e, d
- ld d, 0
- ld hl, Unknown_8e95e
- add hl, de
- ld b, [hl]
- ret
-; 8e95e (23:695e)
-
-Unknown_8e95e: ; 8e95e
- db $00, $40, $80
-; 8e961
-
-Function8e961: ; 8e961 (23:6961)
- ld a, [wd265]
- call ReadMonMenuIcon
- ld [CurIcon], a
- xor a
- call GetIconGFX
- lb de, $24, $20
- ld a, SPRITE_ANIM_INDEX_00
- call InitSpriteAnimStruct
- ld hl, $2
- add hl, bc
- ld [hl], $0
- ret
-
-Function8e97d: ; 8e97d (23:697d)
- ld a, [wd265]
- call ReadMonMenuIcon
- ld [CurIcon], a
- xor a
- call GetIconGFX
- ld d, $1a
- ld e, $24
- ld a, SPRITE_ANIM_INDEX_00
- call InitSpriteAnimStruct
- ld hl, $2
- add hl, bc
- ld [hl], $0
- ret
-
-Function8e99a: ; 8e99a (23:699a)
- ld a, [wd265]
- call ReadMonMenuIcon
- ld [CurIcon], a
- ld a, $62
- ld [wc3b7], a
- call Function8e9db
- ret
-
-GetSpeciesIcon: ; 8e9ac
-; Load species icon into VRAM at tile a
- push de
- ld a, [wd265]
- call ReadMonMenuIcon
- ld [CurIcon], a
- pop de
- ld a, e
- call GetIconGFX
- ret
-; 8e9bc
-
-
-Function8e9bc: ; 8e9bc (23:69bc)
- push de
- ld a, [wd265]
- call ReadMonMenuIcon
- ld [CurIcon], a
- pop de
- ld a, e
- call GetIcon_a
- ret
-; 8e9cc (23:69cc)
-
-Function8e9cc: ; 8e9cc
- push de
- ld a, [wd265]
- call ReadMonMenuIcon
- ld [CurIcon], a
- pop de
- call GetIcon_de
- ret
-; 8e9db
-
-Function8e9db: ; 8e9db (23:69db)
- ld a, [wc3b7]
-
-GetIconGFX: ; 8e9de
- call GetIcon_a
- ld de, $80 ; 8 tiles
- add hl, de
- ld de, HeldItemIcons
- lb bc, BANK(HeldItemIcons), 2
- call GetGFXUnlessMobile
- ld a, [wc3b7]
- add 10
- ld [wc3b7], a
- ret
-
-HeldItemIcons:
-INCBIN "gfx/icon/mail.2bpp"
-INCBIN "gfx/icon/item.2bpp"
-; 8ea17
-
-GetIcon_de: ; 8ea17
-; Load icon graphics into VRAM starting from tile de.
- ld l, e
- ld h, d
- jr GetIcon
-
-GetIcon_a: ; 8ea1b
-; Load icon graphics into VRAM starting from tile a.
- ld l, a
- ld h, 0
-
-GetIcon: ; 8ea1e
-; Load icon graphics into VRAM starting from tile hl.
-
-; One tile is 16 bytes long.
-rept 4
- add hl, hl
-endr
-
- ld de, VTiles0
- add hl, de
- push hl
-
-; The icons are contiguous, in order and of the same
-; size, so the pointer table is somewhat redundant.
- ld a, [CurIcon]
- push hl
- ld l, a
- ld h, 0
- add hl, hl
- ld de, IconPointers
- add hl, de
- ld a, [hli]
- ld e, a
- ld d, [hl]
- pop hl
-
- lb bc, BANK(Icons), 8
- call GetGFXUnlessMobile
-
- pop hl
- ret
-; 8ea3f
-
-GetGFXUnlessMobile: ; 8ea3f
- ld a, [wLinkMode]
- cp LINK_MOBILE
- jp nz, Request2bpp
- jp Get2bpp_2
-; 8ea4a
-
-Function8ea4a: ; 8ea4a
- ld hl, wc314
- ld e, $6
- ld a, [MenuSelection2]
- ld d, a
-.loop
- ld a, [hl]
- and a
- jr z, .next
- cp d
- jr z, .loadwithtwo
- ld a, $0
- jr .ok
-
-.loadwithtwo
- ld a, $2
-
-.ok
- push hl
- ld c, l
- ld b, h
- ld hl, $2
- add hl, bc
- ld [hl], a
- pop hl
-
-.next
- ld bc, $10
- add hl, bc
- dec e
- jr nz, .loop
- ret
-; 8ea71
-
-Function8ea71: ; 8ea71
- ld hl, wc314
- ld e, $6
-.loop
- ld a, [hl]
- and a
- jr z, .zero
- push hl
- ld c, l
- ld b, h
- ld hl, $2
- add hl, bc
- ld [hl], $1
- pop hl
-.zero
- ld bc, $10
- add hl, bc
- dec e
- jr nz, .loop
- ret
-; 8ea8c (23:6a8c)
-
-Function8ea8c: ; 8ea8c
- ld hl, wc314
- ld e, $6
- ld a, [wd0e3]
- ld d, a
-.asm_8ea95
- ld a, [hl]
- and a
- jr z, .asm_8eaab
- cp d
- jr z, .asm_8eaa0
- ld a, $3
- jr .asm_8eaa2
-.asm_8eaa0
- ld a, $2
-.asm_8eaa2
- push hl
- ld c, l
- ld b, h
- ld hl, $2
- add hl, bc
- ld [hl], a
- pop hl
-.asm_8eaab
- ld bc, $10
- add hl, bc
- dec e
- jr nz, .asm_8ea95
- ret
-
-
-INCLUDE "menu/mon_icons.asm"
-
-
SECTION "bank24", ROMX, BANK[$24]
INCLUDE "engine/phone.asm"
@@ -29638,1096 +25223,8 @@
INCLUDE "engine/radio.asm"
-ReadPartyMonMail: ; b9229
- ld a, [CurPartyMon]
- ld hl, sPartyMail
- ld bc, MAIL_STRUCT_LENGTH
- call AddNTimes
- ld d, h
- ld e, l
-ReadAnyMail: ; b9237
- push de
- call ClearBGPalettes
- call ClearSprites
- call ClearTileMap
- call DisableLCD
- call LoadFontsExtra
- pop de
- push de
- ld a, BANK(sPartyMail)
- call GetSRAMBank
- callba Function1de5c8
- call CloseSRAM
- ld a, c
- ld de, GFX_1de5e6
- or a
- jr z, .asm_b9268
- ld de, GFX_1de9e6
- sub $3
- jr c, .asm_b9268
- ld de, GFX_1dede6
+INCLUDE "gfx/mail.asm"
-.asm_b9268
- ld hl, VTiles1
- lb bc, BANK(GFX_1de5e6), $80
- call Get1bpp
- pop de
- call Functionb92b8
- call EnableLCD
- call WaitBGMap
- ld a, [wd1ec]
- ld e, a
- callba Function8cb4
- call SetPalettes
- xor a
- ld [hJoyPressed], a
- call Functionb929a
- call ClearBGPalettes
- call DisableLCD
- call LoadStandardFont
- jp EnableLCD
-; b929a
-
-Functionb929a: ; b929a
-.asm_b929a
- call GetJoypad
- ld a, [hJoyPressed]
- and A_BUTTON | B_BUTTON | START
- jr z, .asm_b929a
- and START
- jr nz, .asm_b92a8
- ret
-
-.asm_b92a8
- ld a, [wJumptableIndex]
- push af
- callab Function845d4
- pop af
- ld [wJumptableIndex], a
- jr .asm_b929a
-; b92b8
-
-Functionb92b8: ; b92b8
- ld h, d
- ld l, e
- push hl
- ld a, $0
- call GetSRAMBank
- ld de, $2b
- add hl, de
- ld a, [hli]
- ld [Buffer1], a
- ld a, [hli]
- ld [Buffer2], a
- ld a, [hli]
- ld [CurPartySpecies], a
- ld b, [hl]
- call CloseSRAM
- ld hl, Unknown_b92f8
- ld c, 0
-.asm_b92d9
- ld a, [hli]
- cp b
- jr z, .asm_b92ea
- cp $ff
- jr z, .asm_b92e6
- inc c
-rept 2
- inc hl
-endr
- jr .asm_b92d9
-
-.asm_b92e6
- ld hl, Unknown_b92f8
- inc hl
-
-.asm_b92ea
- ld a, c
- ld [wd1ec], a
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld de, .done
- pop bc
- push de
- jp [hl]
-.done
- ret
-; b92f8
-
-Unknown_b92f8: ; b92f8
- dbw FLOWER_MAIL, Functionb963e
- dbw SURF_MAIL, Functionb9317
- dbw LITEBLUEMAIL, Functionb9335
- dbw PORTRAITMAIL, Functionb96ca
- dbw LOVELY_MAIL, Functionb944b
- dbw EON_MAIL, Functionb93d2
- dbw MORPH_MAIL, Functionb94d6
- dbw BLUESKY_MAIL, Functionb9582
- dbw MUSIC_MAIL, Functionb9710
- dbw MIRAGE_MAIL, Functionb9776
- db $ff
-; b9317
-
-Functionb9317: ; b9317
- push bc
- ld hl, VTiles2 tile $31
- ld de, Unknown_b9d46
- ld c, $40
- call Functionb9915
- ld de, MailLaprasGFX
- ld c, $30
- call Functionb991e
- ld de, Unknown_b994e
- ld c, $8
- call Functionb9915
- jr Functionb9351
-
-Functionb9335: ; b9335
- push bc
- ld hl, VTiles2 tile $31
- ld de, Unknown_b9dc6
- ld c, $40
- call Functionb9915
- ld de, MailDratiniGFX
- ld c, $30
- call Functionb991e
- ld de, Unknown_b995e
- ld c, $8
- call Functionb9915
-
-Functionb9351: ; b9351
- ld de, Unknown_b9976
- ld c, $10
- call Functionb9915
- ld c, $10
- call Functionb990c
- ld de, Unknown_b9c3e
- ld c, $40
- call Functionb990c
- ld c, $40
- call Functionb9915
- call Functionb9858
- hlcoord 2, 15
- ld a, $3f
- call Functionb98d4
- ld a, $39
- hlcoord 15, 14
- call Functionb98fc
- ld a, $44
- hlcoord 2, 2
- call Functionb98ee
- hlcoord 15, 11
- call Functionb98ee
- ld a, $4c
- hlcoord 3, 12
- call Functionb98ee
- hlcoord 15, 2
- call Functionb98ee
- ld a, $50
- hlcoord 6, 3
- call Functionb98ee
- ld a, $40
- hlcoord 13, 2
- ld [hli], a
- hlcoord 6, 14
- ld [hl], a
- ld a, $41
- hlcoord 4, 5
- ld [hli], a
- hlcoord 17, 5
- ld [hli], a
- hlcoord 13, 12
- ld [hl], a
- ld a, $42
- hlcoord 9, 2
- ld [hli], a
- hlcoord 14, 5
- ld [hli], a
- hlcoord 3, 10
- ld [hl], a
- ld a, $43
- hlcoord 6, 11
- ld [hli], a
- pop hl
- jp Functionb9803
-; b93d2
-
-Functionb93d2: ; b93d2
- push bc
- ld hl, VTiles2 tile $31
- ld de, Unknown_b997e
- ld c, $8
- call Functionb9915
- ld de, Unknown_b998e
- ld c, $8
- call Functionb990c
- ld de, Unknown_b998e
- ld c, $8
- call Functionb990c
- ld de, Unknown_b997e
- ld c, $8
- call Functionb9915
- ld de, Unknown_b9d76
- ld c, $8
- call Functionb9915
- ld de, MailPikaGFX
- ld c, $30
- call Functionb991e
- ld hl, VTiles2 tile $3d
- ld de, Unknown_b9c9e
- ld c, $20
- call Functionb990c
- ld de, Unknown_b998e
- ld c, $8
- call Functionb9915
- ld a, $31
- hlcoord 0, 0
- call Functionb98a8
- hlcoord 1, 17
- call Functionb98a8
- ld a, $33
- hlcoord 0, 1
- call Functionb98ba
- hlcoord 19, 0
- call Functionb98ba
- hlcoord 2, 15
- ld a, $35
- call Functionb98d4
- inc a
- hlcoord 15, 14
- call Functionb98fc
- call Functionb9491
- pop hl
- jp Functionb9803
-; b944b
-
-Functionb944b: ; b944b
- push bc
- ld hl, VTiles2 tile $31
- ld de, Unknown_b9e26
- ld c, $28
- call Functionb9915
- ld de, MailPoliwagGFX
- ld c, $30
- call Functionb991e
- ld de, Unknown_b9966
- ld c, $8
- call Functionb9915
- ld de, Unknown_b9c5e
- ld c, $20
- call Functionb9915
- ld de, Unknown_b996e
- ld c, $8
- call Functionb990c
- call Functionb987b
- hlcoord 2, 15
- ld a, $3c
- call Functionb98d4
- ld a, $36
- hlcoord 15, 14
- call Functionb98fc
- call Functionb9491
- pop hl
- jp Functionb9803
-; b9491
-
-Functionb9491: ; b9491
- ld a, $3d
- hlcoord 2, 2
- call Functionb98ee
- hlcoord 16, 2
- call Functionb98ee
- hlcoord 9, 4
- call Functionb98ee
- hlcoord 2, 11
- call Functionb98ee
- hlcoord 6, 12
- call Functionb98ee
- hlcoord 12, 11
- call Functionb98ee
- ld a, $41
- hlcoord 5, 4
- ld [hl], a
- hlcoord 6, 2
- ld [hl], a
- hlcoord 12, 4
- ld [hl], a
- hlcoord 14, 2
- ld [hl], a
- hlcoord 3, 13
- ld [hl], a
- hlcoord 9, 11
- ld [hl], a
- hlcoord 16, 12
- ld [hl], a
- ret
-; b94d6
-
-Functionb94d6: ; b94d6
- push bc
- ld hl, VTiles2 tile $31
- ld bc, $28
- call Functionb97f8
- ld de, Unknown_b9c96
- ld c, 8
- call Functionb9915
- ld de, Unknown_b9c7e
- ld c, 8
- call Functionb9915
- ld de, Unknown_b993e
- ld c, 8
- call Functionb9915
- ld de, Unknown_b997e
- ld c, 8
- call Functionb990c
- ld de, Unknown_b9926
- ld c, 8
- call Functionb9915
- ld de, MailDittoGFX
- ld c, $30
- call Functionb991e
- call Functionb987b
- ld a, $31
- hlcoord 1, 1
- call Functionb98ee
- hlcoord 17, 15
- call Functionb98ee
- hlcoord 1, 3
- ld [hl], a
- hlcoord 3, 1
- ld [hl], a
- hlcoord 16, 16
- ld [hl], a
- hlcoord 18, 14
- ld [hl], a
- ld a, $36
- hlcoord 1, 4
- ld [hl], a
- hlcoord 2, 3
- ld [hl], a
- hlcoord 3, 2
- ld [hl], a
- hlcoord 4, 1
- ld [hl], a
- inc a
- hlcoord 15, 16
- ld [hl], a
- hlcoord 16, 15
- ld [hl], a
- hlcoord 17, 14
- ld [hl], a
- hlcoord 18, 13
- ld [hl], a
- inc a
- hlcoord 2, 15
- ld b, $e
- call Functionb98de
- inc a
- hlcoord 2, 11
- call Functionb98d4
- hlcoord 2, 5
- call Functionb98d4
- inc a
- hlcoord 6, 1
- call Functionb98d0
- hlcoord 1, 16
- call Functionb98d0
- inc a
- hlcoord 3, 13
- call Functionb98fc
- pop hl
- jp Functionb9803
-; b9582
-
-Functionb9582: ; b9582
- push bc
- ld hl, VTiles2 tile $31
- ld de, Unknown_b997e
- ld c, $8
- call Functionb9915
- ld a, $ff
- ld bc, $10
- call ByteFill
- ld de, Unknown_b992e
- ld c, $8
- call Functionb991e
- ld de, MailDragoniteGFX
- ld c, $b8
- call Functionb991e
- ld de, MailCloudGFX
- ld c, $30
- call Functionb990c
- ld de, Unknown_b9db6
- ld c, $8
- call Functionb990c
- ld de, MailCloudGFX
- ld c, $8
- call Functionb990c
- ld de, Unknown_b9d26
- ld c, $10
- call Functionb990c
- ld de, Unknown_b9d3e
- ld c, $8
- call Functionb990c
- ld a, $31
- hlcoord 0, 0
- call Functionb98dc
- hlcoord 0, 1
- call Functionb98e3
- hlcoord 19, 1
- call Functionb98e3
- inc a
- hlcoord 0, 17
- call Functionb98dc
- inc a
- hlcoord 0, 16
- call Functionb98dc
- inc a
- hlcoord 2, 2
- call Functionb9636
- hlcoord 3, 3
- call Functionb9636
- hlcoord 4, 4
- call Functionb9636
- dec hl
- ld [hl], $7f
- dec a
- hlcoord 15, 14
- call Functionb98ee
- add $4
- hlcoord 15, 16
- ld [hli], a
- inc a
- ld [hl], a
- inc a
- push af
- hlcoord 12, 1
- call Functionb98fc
- pop af
- hlcoord 15, 4
- call Functionb98fc
- inc a
- hlcoord 2, 11
- call Functionb98d4
- inc a
- hlcoord 10, 3
- call Functionb98ee
- pop hl
- jp Functionb9803
-; b9636
-
-Functionb9636: ; b9636
- ld b, $6
-.asm_b9638
- ld [hli], a
- inc a
- dec b
- jr nz, .asm_b9638
- ret
-; b963e
-
-Functionb963e: ; b963e
- push bc
- ld hl, VTiles2 tile $31
- ld de, Unknown_b9d86
- ld c, $40
- call Functionb990c
- ld de, MailOddishGFX
- ld c, $20
- call Functionb991e
- ld de, Unknown_b9db6
- ld c, $8
- call Functionb9915
- ld de, Unknown_b9cbe
- ld c, $20
- call Functionb990c
- ld c, $20
- call Functionb9915
- call Functionb9858
- hlcoord 2, 15
- ld a, $3d
- call Functionb98d4
- ld a, $39
- hlcoord 16, 13
- call Functionb98ee
- hlcoord 2, 13
- call Functionb98ee
- ld a, $3e
- hlcoord 2, 2
- call Functionb98ee
- hlcoord 5, 3
- call Functionb98ee
- hlcoord 10, 2
- call Functionb98ee
- hlcoord 16, 3
- call Functionb98ee
- hlcoord 5, 11
- call Functionb98ee
- hlcoord 16, 10
- call Functionb98ee
- ld a, $42
- hlcoord 3, 4
- call Functionb98ee
- hlcoord 12, 3
- call Functionb98ee
- hlcoord 14, 2
- call Functionb98ee
- hlcoord 2, 10
- call Functionb98ee
- hlcoord 14, 11
- call Functionb98ee
- pop hl
- jp Functionb9803
-; b96ca
-
-Functionb96ca: ; b96ca
- push bc
- ld hl, VTiles2 tile $31
- ld de, Unknown_b9e4e
- ld c, $28
- call Functionb9915
- ld de, Unknown_b995e
- ld c, $8
- call Functionb9915
- ld hl, VTiles2 tile $3d
- ld de, Unknown_b9bfe
- ld c, $20
- call Functionb990c
- ld de, Unknown_b9936
- ld c, $8
- call Functionb9915
- call Functionb987b
- hlcoord 8, 15
- ld a, $36
- ld b, $a
- call Functionb98de
- call Functionb9491
- ld a, $1
- ld [UnownLetter], a
- hlcoord 1, 10
- call PrepMonFrontpic
- pop hl
- jp Functionb9803
-; b9710
-
-Functionb9710: ; b9710
- push bc
- ld hl, VTiles2 tile $31
- ld de, Unknown_b9e06
- ld c, $20
- call Functionb9915
- ld de, Unknown_b993e
- ld c, $10
- call Functionb9915
- ld de, Unknown_b9996
- ld c, $30
- call Functionb991e
- xor a
- ld bc, $10
- call ByteFill
- ld de, Unknown_b9cfe
- ld c, $18
- call Functionb990c
- ld de, Unknown_b9946
- ld c, $8
- call Functionb990c
- ld a, $31
- hlcoord 0, 0
- call Functionb98a8
- hlcoord 1, 17
- call Functionb98a8
- ld a, $33
- hlcoord 0, 1
- call Functionb98ba
- hlcoord 19, 0
- call Functionb98ba
- ld a, $35
- hlcoord 2, 15
- call Functionb989e
- ld a, $37
- hlcoord 15, 14
- call Functionb98fc
- call Functionb9491
- pop hl
- jp Functionb9803
-; b9776
-
-Functionb9776: ; b9776
- push bc
- ld hl, VTiles2 tile $31
- ld bc, $28
- call Functionb97f8
- ld de, Unknown_b992e
- ld c, $8
- call Functionb9915
- ld de, MailMewGFX
- ld c, $90
- call Functionb9915
- ld de, Unknown_b9dce
- ld c, $8
- call Functionb990c
- ld de, Unknown_b9df6
- ld c, $8
- call Functionb990c
- call Functionb987b
- ld a, $36
- hlcoord 1, 16
- call Functionb98d8
- inc a
- hlcoord 15, 14
- call Functionb98fc
- inc a
- hlcoord 15, 16
- ld [hli], a
- inc a
- ld [hl], a
- ld a, $3f
- hlcoord 1, 1
- call Functionb98a8
- ld a, $41
- hlcoord 0, 2
- call Functionb98b5
- ld a, $43
- hlcoord 19, 2
- call Functionb98b5
- ld a, $45
- hlcoord 0, 1
- ld [hl], a
- inc a
- hlcoord 19, 1
- ld [hl], a
- inc a
- hlcoord 0, 16
- ld [hl], a
- inc a
- hlcoord 19, 16
- ld [hl], a
- inc a
- hlcoord 2, 5
- call Functionb98d4
- inc a
- hlcoord 2, 11
- call Functionb98d4
- pop hl
- jp Functionb9803
-; b97f8
-
-Functionb97f8: ; b97f8
-.asm_b97f8
- xor a
- ld [hli], a
- ld a, $ff
- ld [hli], a
- dec bc
- ld a, b
- or c
- jr nz, .asm_b97f8
- ret
-; b9803
-
-Functionb9803: ; b9803
- ld bc, $2f
- ld de, wd002
- ld a, $0
- call GetSRAMBank
- call CopyBytes
- call CloseSRAM
- ld hl, wd023
- ld de, wd050
- ld bc, $a
- call CopyBytes
- ld a, $50
- ld [wd023], a
- ld [wd05a], a
- ld de, wd002
- hlcoord 2, 7
- call PlaceString
- ld de, wd050
- ld a, [de]
- and a
- ret z
- ld a, [wd1ec]
- hlcoord 8, 14
- cp $3
- jr z, .asm_b984b
- hlcoord 6, 14
- cp $6
- jr z, .asm_b984b
- hlcoord 5, 14
-
-.asm_b984b
- jp PlaceString
-; b984e
-
-Functionb984e: ; b984e
-.asm_b984e
- ld a, [hl]
- xor $ff
- ld [hli], a
- dec bc
- ld a, b
- or c
- jr nz, .asm_b984e
- ret
-; b9858
-
-Functionb9858: ; b9858
- hlcoord 0, 0
- ld a, $31
- ld [hli], a
- inc a
- call Functionb98d8
- inc a
- ld [hli], a
- inc a
- call Functionb98e3
- ld a, $36
- ld [hli], a
- inc a
- call Functionb98d8
- hlcoord 19, 1
- ld a, $35
- call Functionb98e3
- ld a, $38
- ld [hl], a
- ret
-; b987b
-
-Functionb987b: ; b987b
- hlcoord 0, 0
- ld a, $31
- ld [hli], a
- inc a
- call Functionb98d8
- ld [hl], $31
- inc hl
- inc a
- call Functionb98e3
- ld [hl], $31
- inc hl
- inc a
- call Functionb98d8
- hlcoord 19, 1
- ld a, $35
- call Functionb98e3
- ld [hl], $31
- ret
-; b989e
-
-Functionb989e: ; b989e
- push af
- ld b, $7
- jr Functionb98ab
-
-Functionb98a3: ; b98a3
- push af
- ld b, $8
- jr Functionb98ab
-
-Functionb98a8: ; b98a8
- push af
- ld b, $9
-
-Functionb98ab: ; b98ab
- ld [hli], a
- inc a
- ld [hli], a
- dec a
- dec b
- jr nz, Functionb98ab
- ld [hl], a
- pop af
- ret
-; b98b5
-
-Functionb98b5: ; b98b5
- push af
- ld b, $7
- jr Functionb98bd
-
-Functionb98ba: ; b98ba
- push af
- ld b, $8
-
-Functionb98bd: ; b98bd
- ld [hl], a
- ld de, SCREEN_WIDTH
- add hl, de
- inc a
- ld [hl], a
- add hl, de
- dec a
- dec b
- jr nz, Functionb98bd
- ld [hl], a
- pop af
- ret
-; b98cc
-
-Functionb98cc: ; b98cc
- ld b, $7
- jr Functionb98de
-
-Functionb98d0: ; b98d0
- ld b, $d
- jr Functionb98de
-
-Functionb98d4: ; b98d4
- ld b, $10
- jr Functionb98de
-
-Functionb98d8: ; b98d8
- ld b, $12
- jr Functionb98de
-
-Functionb98dc: ; b98dc
- ld b, $14
-
-Functionb98de: ; b98de
- ld [hli], a
- dec b
- jr nz, Functionb98de
- ret
-; b98e3
-
-Functionb98e3: ; b98e3
- ld b, $10
- ld de, SCREEN_WIDTH
-.asm_b98e8
- ld [hl], a
- add hl, de
- dec b
- jr nz, .asm_b98e8
- ret
-; b98ee
-
-Functionb98ee: ; b98ee
- push af
- ld [hli], a
- inc a
- ld [hl], a
- ld bc, $13
- add hl, bc
- inc a
- ld [hli], a
- inc a
- ld [hl], a
- pop af
- ret
-; b98fc
-
-Functionb98fc: ; b98fc
- ld [hli], a
- inc a
- ld [hli], a
- inc a
- ld [hl], a
- ld bc, SCREEN_HEIGHT
- add hl, bc
- inc a
- ld [hli], a
- inc a
- ld [hli], a
- inc a
- ld [hl], a
- ret
-; b990c
-
-Functionb990c: ; b990c
-.asm_b990c
- ld a, [de]
- inc de
- ld [hli], a
- xor a
- ld [hli], a
- dec c
- jr nz, .asm_b990c
- ret
-; b9915
-
-Functionb9915: ; b9915
-.asm_b9915
- xor a
- ld [hli], a
- ld a, [de]
- inc de
- ld [hli], a
- dec c
- jr nz, .asm_b9915
- ret
-; b991e
-
-Functionb991e: ; b991e
-.asm_b991e
- ld a, [de]
- inc de
-rept 2
- ld [hli], a
-endr
- dec c
- jr nz, .asm_b991e
- ret
-; b9926
-
-Unknown_b9926: ; b9926
-INCBIN "gfx/unknown/0b9926.1bpp"
-
-Unknown_b992e: ; b992e
-INCBIN "gfx/unknown/0b992e.1bpp"
-
-Unknown_b9936: ; b9936
-INCBIN "gfx/unknown/0b9936.1bpp"
-
-Unknown_b993e: ; b993e
-INCBIN "gfx/unknown/0b993e.1bpp"
-
-Unknown_b9946: ; b9946
-INCBIN "gfx/unknown/0b9946.1bpp"
-
-Unknown_b994e: ; b994e
-INCBIN "gfx/unknown/0b994e.1bpp"
-
-Unknown_b995e: ; b995e
-INCBIN "gfx/unknown/0b995e.1bpp"
-
-Unknown_b9966: ; b9966
-INCBIN "gfx/unknown/0b9966.1bpp"
-
-Unknown_b996e: ; b996e
-INCBIN "gfx/unknown/0b996e.1bpp"
-
-Unknown_b9976: ; b9976
-INCBIN "gfx/unknown/0b9976.1bpp"
-
-Unknown_b997e: ; b997e
-INCBIN "gfx/unknown/0b997e.1bpp"
-
-Unknown_b998e: ; b998e
-INCBIN "gfx/unknown/0b998e.1bpp"
-
-Unknown_b9996: ; b9996
-INCBIN "gfx/unknown/0b9996.1bpp"
-
-MailDratiniGFX: ; b99c6
-INCBIN "gfx/unknown/0b99c6.1bpp"
-
-MailPoliwagGFX: ; b99f6
-INCBIN "gfx/unknown/0b99f6.1bpp"
-
-MailLaprasGFX: ; b9a26
-INCBIN "gfx/unknown/0b9a26.1bpp"
-
-MailPikaGFX: ; b9a56
-INCBIN "gfx/unknown/0b9a56.1bpp"
-
-MailDittoGFX: ; b9a86
-INCBIN "gfx/unknown/0b9a86.1bpp"
-
-MailMewGFX: ; b9ab6
-INCBIN "gfx/unknown/0b9ab6.1bpp"
-
-MailDragoniteGFX: ; b9b46
-INCBIN "gfx/unknown/0b9b46.1bpp"
-
-MailSentretGFX: ; b9bce
-INCBIN "gfx/unknown/0b9bce.1bpp"
-
-Unknown_b9bee: ; b9bee
-INCBIN "gfx/unknown/0b9bee.1bpp"
-
-Unknown_b9bfe: ; b9bfe
-INCBIN "gfx/unknown/0b9bfe.1bpp"
-
-MailOddishGFX: ; b9c1e
-INCBIN "gfx/unknown/0b9c1e.1bpp"
-
-Unknown_b9c3e: ; b9c3e
-INCBIN "gfx/unknown/0b9c3e.1bpp"
-
-Unknown_b9c5e: ; b9c5e
-INCBIN "gfx/unknown/0b9c5e.1bpp"
-
-Unknown_b9c7e: ; b9c7e
-INCBIN "gfx/unknown/0b9c7e.1bpp"
-
-Unknown_b9c96: ; b9c96
-INCBIN "gfx/unknown/0b9c96.1bpp"
-
-Unknown_b9c9e: ; b9c9e
-INCBIN "gfx/unknown/0b9c9e.1bpp"
-
-Unknown_b9cbe: ; b9cbe
-INCBIN "gfx/unknown/0b9cbe.1bpp"
-
-Unknown_b9cde: ; b9cde
-INCBIN "gfx/unknown/0b9cde.1bpp"
-
-Unknown_b9cfe: ; b9cfe
-INCBIN "gfx/unknown/0b9cfe.1bpp"
-
-MailCloudGFX: ; b9d16
-INCBIN "gfx/unknown/0b9d16.1bpp"
-
-Unknown_b9d26: ; b9d26
-INCBIN "gfx/unknown/0b9d26.1bpp"
-
-Unknown_b9d3e: ; b9d3e
-INCBIN "gfx/unknown/0b9d3e.1bpp"
-
-Unknown_b9d46: ; b9d46
-INCBIN "gfx/unknown/0b9d46.1bpp"
-
-Unknown_b9d76: ; b9d76
-INCBIN "gfx/unknown/0b9d76.1bpp"
-
-Unknown_b9d86: ; b9d86
-INCBIN "gfx/unknown/0b9d86.1bpp"
-
-Unknown_b9db6: ; b9db6
-INCBIN "gfx/unknown/0b9db6.1bpp"
-
-Unknown_b9dc6: ; b9dc6
-INCBIN "gfx/unknown/0b9dc6.1bpp"
-
-Unknown_b9dce: ; b9dce
-INCBIN "gfx/unknown/0b9dce.1bpp"
-
-Unknown_b9df6: ; b9df6
-INCBIN "gfx/unknown/0b9df6.1bpp"
-
-Unknown_b9e06: ; b9e06
-INCBIN "gfx/unknown/0b9e06.1bpp"
-
-Unknown_b9e26: ; b9e26
-INCBIN "gfx/unknown/0b9e26.1bpp"
-
-Unknown_b9e4e: ; b9e4e
-INCBIN "gfx/unknown/0b9e4e.1bpp"
-
-
-ItemIsMail: ; b9e76
- ld a, d
- ld hl, .items
- ld de, 1
- jp IsInArray
-; b9e80
-
-.items
- db FLOWER_MAIL
- db SURF_MAIL
- db LITEBLUEMAIL
- db PORTRAITMAIL
- db LOVELY_MAIL
- db EON_MAIL
- db MORPH_MAIL
- db BLUESKY_MAIL
- db MUSIC_MAIL
- db MIRAGE_MAIL
- db $ff
-; b9e8b
-
-
SECTION "bank2F", ROMX, BANK[$2F]
INCLUDE "engine/std_scripts.asm"
@@ -31159,3464 +25656,13 @@
; e41d0
INCLUDE "engine/options_menu.asm"
+INCLUDE "engine/crystal_intro.asm"
-Functione455c: ; e455c
- hlcoord 1, 1
- ld de, SCREEN_WIDTH
- ld c, $10
-.asm_e4564
- ld [hl], $7f
- add hl, de
- dec c
- jr nz, .asm_e4564
- hlcoord 1, 2
- ld bc, $28
- ld a, [wJumptableIndex]
- call AddNTimes
- ld [hl], $ed
- ret
-; e4579
-
-
-Functione4579: ; e4579
- ld de, MUSIC_NONE
- call PlayMusic
- call ClearBGPalettes
- call ClearTileMap
- ld a, VBGMap0 / $100
- ld [hBGMapAddress + 1], a
- xor a
- ld [hBGMapAddress], a
- ld [hJoyDown], a
- ld [hSCX], a
- ld [hSCY], a
- ld a, $90
- ld [hWY], a
- call WaitBGMap
- ld b, SCGB_19
- call GetSGBLayout
- call SetPalettes
- ld c, 10
- call DelayFrames
- callab Copyright
- call WaitBGMap
- ld c, 100
- call DelayFrames
- call ClearTileMap
- callba GBCOnlyScreen
- call Functione45e8
-.joy_loop
- call JoyTextDelay
- ld a, [hJoyLast]
- and BUTTONS
- jr nz, .pressed_button
- ld a, [wJumptableIndex]
- bit 7, a
- jr nz, .finish
- call PlaceGameFreakPresents
- callba Function8cf69
- call DelayFrame
- jr .joy_loop
-
-.pressed_button
- call Functione465e
- scf
- ret
-
-.finish
- call Functione465e
- and a
- ret
-; e45e8
-
-Functione45e8: ; e45e8
- ld de, GameFreakLogo
- ld hl, VTiles2
- lb bc, BANK(GameFreakLogo), $1c
- call Get1bpp
-
- ld a, [rSVBK]
- push af
- ld a, $6
- ld [rSVBK], a
-
- ld hl, IntroLogoGFX
- ld de, w6_d000
- ld a, BANK(IntroLogoGFX)
- call FarDecompress
-
- ld hl, VTiles0
- ld de, w6_d000
- lb bc, 1, 8 tiles
- call Request2bpp
-
- ld hl, VTiles1
- ld de, w6_d000 + $80 tiles
- lb bc, 1, 8 tiles
- call Request2bpp
-
- pop af
- ld [rSVBK], a
-
- callba Function8cf53
- depixel 10, 11, 4, 0
- ld a, SPRITE_ANIM_INDEX_03
- call _InitSpriteAnimStruct
- ld hl, $7
- add hl, bc
- ld [hl], $a0
- ld hl, $c
- add hl, bc
- ld [hl], $60
- ld hl, $d
- add hl, bc
- ld [hl], $30
- xor a
- ld [wJumptableIndex], a
- ld [wcf64], a
- ld [wcf65], a
- ld [hSCX], a
- ld [hSCY], a
- ld a, $1
- ld [hBGMapMode], a
- ld a, $90
- ld [hWY], a
- ld de, $e4e4
- call DmgToCgbObjPals
- ret
-; e465e
-
-Functione465e: ; e465e
- callba Function8cf53
- call ClearTileMap
- call ClearSprites
- ld c, 16
- call DelayFrames
- ret
-; e4670
-
-PlaceGameFreakPresents: ; e4670
- ld a, [wJumptableIndex]
- ld e, a
- ld d, 0
- ld hl, .jumptable
-rept 2
- add hl, de
-endr
- ld a, [hli]
- ld h, [hl]
- ld l, a
- jp [hl]
-; e467f
-
-.jumptable: ; e467f
- dw PlaceGameFreakPresents_0
- dw PlaceGameFreakPresents_1
- dw PlaceGameFreakPresents_2
- dw PlaceGameFreakPresents_3
-; e4687
-
-PlaceGameFreakPresents_AdvanceIndex: ; e4687
- ld hl, wJumptableIndex
- inc [hl]
- ret
-; e468c
-
-PlaceGameFreakPresents_0: ; e468c
- ret
-; e468d
-
-PlaceGameFreakPresents_1: ; e468d
- ld hl, wcf65
- ld a, [hl]
- cp $20
- jr nc, .PlaceGameFreak
- inc [hl]
- ret
-
-.PlaceGameFreak
- ld [hl], 0
- ld hl, .GAME_FREAK
- decoord 5, 10
- ld bc, .end - .GAME_FREAK
- call CopyBytes
- call PlaceGameFreakPresents_AdvanceIndex
- ld de, SFX_GAME_FREAK_PRESENTS
- call PlaySFX
- ret
-; e46af
-
-.GAME_FREAK
- ; G A M E _ F R E A K
- db 0, 1, 2, 3, 13, 4, 5, 3, 1, 6
-.end
- db "@"
-; e46ba
-
-PlaceGameFreakPresents_2: ; e46ba
- ld hl, wcf65
- ld a, [hl]
- cp $40
- jr nc, .place_presents
- inc [hl]
- ret
-
-.place_presents
- ld [hl], 0
- ld hl, .presents
- decoord 7,11
- ld bc, .end - .presents
- call CopyBytes
- call PlaceGameFreakPresents_AdvanceIndex
- ret
-; e46d6
-
-.presents
- db 7, 8, 9, 10, 11, 12
-.end
- db "@"
-; e46dd
-
-PlaceGameFreakPresents_3: ; e46dd
- ld hl, wcf65
- ld a, [hl]
- cp $80
- jr nc, .finish
- inc [hl]
- ret
-
-.finish
- ld hl, wJumptableIndex
- set 7, [hl]
- ret
-; e46ed
-
-
-
-GameFreakLogoJumper: ; e46ed (39:46ed)
- ld hl, $b
- add hl, bc
- ld e, [hl]
- ld d, 0
- ld hl, GameFreakLogoScenes
-rept 2
- add hl, de
-endr
- ld a, [hli]
- ld h, [hl]
- ld l, a
- jp [hl]
-
-GameFreakLogoScenes: ; e46fd (39:46fd)
- dw GameFreakLogoScene1
- dw GameFreakLogoScene2
- dw GameFreakLogoScene3
- dw GameFreakLogoScene4
- dw GameFreakLogoScene5
-
-
-GameFreakLogoScene1: ; e4707 (39:4707)
- ld hl, $b
- add hl, bc
- inc [hl]
- ret
-
-GameFreakLogoScene2: ; e470d (39:470d)
- ld hl, $c
- add hl, bc
- ld a, [hl]
- and a
- jr z, .asm_e4747
- ld d, a
- ld hl, $d
- add hl, bc
- ld a, [hl]
- and $3f
- cp $20
- jr nc, .asm_e4723
- add $20
-.asm_e4723
- ld e, a
- callba Functionce765
- ld hl, $7
- add hl, bc
- ld [hl], e
- ld hl, $d
- add hl, bc
- ld a, [hl]
- dec [hl]
- and $1f
- ret nz
- ld hl, $c
- add hl, bc
- ld a, [hl]
- sub $30
- ld [hl], a
- ld de, SFX_DITTO_BOUNCE
- call PlaySFX
- ret
-.asm_e4747
- ld hl, $b
- add hl, bc
- inc [hl]
- ld hl, $d
- add hl, bc
- ld [hl], $0
- ld de, SFX_DITTO_POP_UP
- call PlaySFX
- ret
-
-GameFreakLogoScene3: ; e4759 (39:4759)
- ld hl, $d
- add hl, bc
- ld a, [hl]
- cp $20
- jr nc, .asm_e4764
- inc [hl]
- ret
-.asm_e4764
- ld hl, $b
- add hl, bc
- inc [hl]
- ld hl, $d
- add hl, bc
- ld [hl], $0
- ld de, SFX_DITTO_TRANSFORM
- call PlaySFX
- ret
-
-GameFreakLogoScene4: ; e4776 (39:4776)
- ld hl, $d
- add hl, bc
- ld a, [hl]
- cp $40
- jr z, .asm_e47a3
- inc [hl]
- srl a
- srl a
- ld e, a
- ld d, $0
- ld hl, GameFreakLogoPalettes
-rept 2
- add hl, de
-endr
- ld a, [rSVBK]
- push af
- ld a, $5
- ld [rSVBK], a
- ld a, [hli]
- ld [OBPals + 12], a
- ld a, [hli]
- ld [OBPals + 13], a
- pop af
- ld [rSVBK], a
- ld a, $1
- ld [hCGBPalUpdate], a
- ret
-.asm_e47a3
- ld hl, $b
- add hl, bc
- inc [hl]
- call PlaceGameFreakPresents_AdvanceIndex
-
-GameFreakLogoScene5: ; e47ab (39:47ab)
- ret
-; e47ac (39:47ac)
-
-GameFreakLogoPalettes: ; e47ac
-; Ditto's color as it turns into the Game Freak logo.
-; Fade from pink to orange.
-; One color per step.
- RGB 23, 12, 28
- RGB 23, 12, 27
- RGB 23, 13, 26
- RGB 23, 13, 24
- RGB 24, 14, 22
- RGB 24, 14, 20
- RGB 24, 15, 18
- RGB 24, 15, 16
- RGB 25, 16, 14
- RGB 25, 16, 12
- RGB 25, 17, 10
- RGB 25, 17, 08
- RGB 26, 18, 06
- RGB 26, 18, 04
- RGB 26, 19, 02
- RGB 26, 19, 00
-;' e47cc
-
-GameFreakLogo: ; e47cc
-INCBIN "gfx/splash/logo.1bpp"
-; e48ac
-
-CrystalIntro: ; e48ac
- ld a, [rSVBK]
- push af
- ld a, 5
- ld [rSVBK], a
- ld a, [hInMenu]
- push af
- ld a, [hVBlank]
- push af
- call Functione4901
-.loop: ; e48bc
- call JoyTextDelay
- ld a, [hJoyLast]
- and BUTTONS
- jr nz, .ShutOffMusic
- ld a, [wJumptableIndex]
- bit 7, a
- jr nz, .done
- call IntroSceneJumper
- callba Function8cf69
- call DelayFrame
- jp .loop
-
-.ShutOffMusic
- ld de, MUSIC_NONE
- call PlayMusic
-
-.done
- call ClearBGPalettes
- call ClearSprites
- call ClearTileMap
- xor a
- ld [hSCX], a
- ld [hSCY], a
- ld a, $7
- ld [hWX], a
- ld a, $90
- ld [hWY], a
- pop af
- ld [hVBlank], a
- pop af
- ld [hInMenu], a
- pop af
- ld [rSVBK], a
- ret
-; e4901
-
-Functione4901: ; e4901
- xor a
- ld [hVBlank], a
- ld a, $1
- ld [hInMenu], a
- xor a
- ld [hMapAnims], a
- ld [wJumptableIndex], a
- ret
-; e490f
-
-IntroSceneJumper: ; e490f
- ld a, [wJumptableIndex]
- ld e, a
- ld d, 0
- ld hl, IntroScenes
-rept 2
- add hl, de
-endr
- ld a, [hli]
- ld h, [hl]
- ld l, a
- jp [hl]
-; e491e
-
-
-IntroScenes: ; e491e (39:491e)
- dw IntroScene1
- dw IntroScene2
- dw IntroScene3
- dw IntroScene4
- dw IntroScene5
- dw IntroScene6
- dw IntroScene7
- dw IntroScene8
- dw IntroScene9
- dw IntroScene10
- dw IntroScene11
- dw IntroScene12
- dw IntroScene13
- dw IntroScene14
- dw IntroScene15
- dw IntroScene16
- dw IntroScene17
- dw IntroScene18
- dw IntroScene19
- dw IntroScene20
- dw IntroScene21
- dw IntroScene22
- dw IntroScene23
- dw IntroScene24
- dw IntroScene25
- dw IntroScene26
- dw IntroScene27
- dw IntroScene28
-
-
-NextIntroScene: ; e4956 (39:4956)
- ld hl, wJumptableIndex
- inc [hl]
- ret
-
-IntroScene1: ; e495b (39:495b)
-; Setup the next scene.
- call Functione54a3
- call ClearSprites
- call ClearTileMap
- xor a
- ld [hBGMapMode], a
- ld a, $1
- ld [rVBK], a
- ld hl, IntroTilemap001
- ld de, VBGMap0 tile $00
- call Functione54fa
- ld a, $0
- ld [rVBK], a
- ld hl, IntroUnownsGFX
- ld de, VTiles2 tile $00
- call Functione54c2
- ld hl, IntroPulseGFX
- ld de, VTiles0 tile $00
- call Functione54c2
- ld hl, IntroTilemap002
- ld de, VBGMap0 tile $00
- call Functione54fa
- ld a, [rSVBK]
- push af
- ld a, $5
- ld [rSVBK], a
- ld hl, Palette_365ad
- ld de, wMapPals
- ld bc, $80
- call CopyBytes
- ld hl, Palette_365ad
- ld de, BGPals
- ld bc, $80
- call CopyBytes
- pop af
- ld [rSVBK], a
- xor a
- ld [hSCX], a
- ld [hSCY], a
- ld a, $7
- ld [hWX], a
- ld a, $90
- ld [hWY], a
- callba Function8cf53
- call Functione549e
- xor a
- ld [wIntroSceneFrameCounter], a
- ld [wcf65], a
- call NextIntroScene
- ret
-
-IntroScene2: ; e49d6 (39:49d6)
-; First Unown (A) fades in, pulses, then fades out.
- ld hl, wIntroSceneFrameCounter
- ld a, [hl]
- inc [hl]
- cp $80
- jr nc, .endscene
- cp $60
- jr nz, .DontPlaySound
- push af
- ld de, $5858
- call Functione51dc
- ld de, SFX_INTRO_UNOWN_1
- call PlaySFX
- pop af
-.DontPlaySound
- ld [wcf65], a
- xor a
- call Functione5223
- ret
-.endscene
- call NextIntroScene
- ret
-
-IntroScene3: ; e49fd (39:49fd)
-; More setup. Transition to the outdoor scene.
- call Functione54a3
- call ClearSprites
- call ClearTileMap
- xor a
- ld [hBGMapMode], a
- ld a, $1
- ld [rVBK], a
- ld hl, IntroTilemap003
- ld de, VBGMap0 tile $00
- call Functione54fa
- ld a, $0
- ld [rVBK], a
- ld hl, IntroBackgroundGFX
- ld de, VTiles2 tile $00
- call Functione54c2
- ld hl, IntroTilemap004
- ld de, VBGMap0 tile $00
- call Functione54fa
- ld a, [rSVBK]
- push af
- ld a, $5
- ld [rSVBK], a
- ld hl, Palette_e5edd
- ld de, wMapPals
- ld bc, $80
- call CopyBytes
- ld hl, Palette_e5edd
- ld de, BGPals
- ld bc, $80
- call CopyBytes
- pop af
- ld [rSVBK], a
- xor a
- ld [hSCX], a
- ld [hSCY], a
- ld a, $7
- ld [hWX], a
- ld a, $90
- ld [hWY], a
- call Functione5516
- call Functione549e
- xor a
- ld [wIntroSceneFrameCounter], a
- call NextIntroScene
- ret
-
-IntroScene4: ; e4a69 (39:4a69)
-; Scroll the outdoor panorama for a bit.
- call Functione552f
- ld hl, wIntroSceneFrameCounter
- ld a, [hl]
- cp $80
- jr z, .endscene
- inc [hl]
- ret
-.endscene
- call NextIntroScene
- ret
-
-IntroScene5: ; e4a7a (39:4a7a)
-; Go back to the Unown.
- call Functione54a3
- call ClearSprites
- call ClearTileMap
- xor a
- ld [hBGMapMode], a
- ld [hLCDStatCustom], a
- ld a, $1
- ld [rVBK], a
- ld hl, IntroTilemap005
- ld de, VBGMap0 tile $00
- call Functione54fa
- ld a, $0
- ld [rVBK], a
- ld hl, IntroUnownsGFX
- ld de, VTiles2 tile $00
- call Functione54c2
- ld hl, IntroPulseGFX
- ld de, VTiles0 tile $00
- call Functione54c2
- ld hl, IntroTilemap006
- ld de, VBGMap0 tile $00
- call Functione54fa
- ld a, [rSVBK]
- push af
- ld a, $5
- ld [rSVBK], a
- ld hl, Palette_365ad
- ld de, wMapPals
- ld bc, $80
- call CopyBytes
- ld hl, Palette_365ad
- ld de, BGPals
- ld bc, $80
- call CopyBytes
- pop af
- ld [rSVBK], a
- xor a
- ld [hSCX], a
- ld [hSCY], a
- ld a, $7
- ld [hWX], a
- ld a, $90
- ld [hWY], a
- callba Function8cf53
- call Functione549e
- xor a
- ld [wcf64], a
- ld [wcf65], a
- call NextIntroScene
- ret
-
-IntroScene6: ; e4af7 (39:4af7)
-; Two more Unown (I, H) fade in.
- ld hl, wcf64
- ld a, [hl]
- inc [hl]
- cp $80
- jr nc, .endscene
- cp $60
- jr z, .SecondUnown
- cp $40
- jr nc, .StopUnown
- cp $20
- jr z, .FirstUnown
- jr .NoUnown
-.FirstUnown
- push af
- ld de, $3878
- call Functione51dc
- ld de, SFX_INTRO_UNOWN_2
- call PlaySFX
- pop af
-.NoUnown
- ld [wcf65], a
- xor a
- call Functione5223
- ret
-.SecondUnown
- push af
- ld de, $7030
- call Functione51dc
- ld de, SFX_INTRO_UNOWN_1
- call PlaySFX
- pop af
-.StopUnown
- ld [wcf65], a
- ld a, $1
- call Functione5223
- ret
-.endscene
- call NextIntroScene
- ret
-
-IntroScene7: ; e4b3f (39:4b3f)
-; Back to the outdoor scene.
- call Functione54a3
- call ClearSprites
- call ClearTileMap
- xor a
- ld [hBGMapMode], a
- ld a, $1
- ld [rVBK], a
- ld hl, IntroTilemap003
- ld de, VBGMap0 tile $00
- call Functione54fa
- ld hl, IntroPichuWooperGFX
- ld de, VTiles0 tile $00
- call Functione54c2
- ld a, $0
- ld [rVBK], a
- ld hl, IntroSuicuneRunGFX
- ld de, VTiles0 tile $00
- call Functione54de
- ld hl, IntroBackgroundGFX
- ld de, VTiles2 tile $00
- call Functione54c2
- ld hl, IntroTilemap004
- ld de, VBGMap0 tile $00
- call Functione54fa
- ld a, [rSVBK]
- push af
- ld a, $5
- ld [rSVBK], a
- ld hl, Palette_e5edd
- ld de, wMapPals
- ld bc, $80
- call CopyBytes
- ld hl, Palette_e5edd
- ld de, BGPals
- ld bc, $80
- call CopyBytes
- pop af
- ld [rSVBK], a
- xor a
- ld [hSCX], a
- ld [hSCY], a
- ld a, $7
- ld [hWX], a
- ld a, $90
- ld [hWY], a
- call Functione5516
- callba Function8cf53
- depixel 13, 27, 4, 0
- ld a, SPRITE_ANIM_INDEX_26
- call _InitSpriteAnimStruct
- ld a, $f0
- ld [wc3c0], a
- call Functione549e
- xor a
- ld [wIntroSceneFrameCounter], a
- ld [wcf65], a
- call NextIntroScene
- ret
-
-IntroScene8: ; e4bd3 (39:4bd3)
-; Scroll the scene, then show Suicune running across the screen.
- ld hl, wIntroSceneFrameCounter
- ld a, [hl]
- inc [hl]
- cp $40
- jr z, .asm_e4be2
- jr nc, .asm_e4be8
- call Functione552f
- ret
-.asm_e4be2
- ld de, SFX_INTRO_SUICUNE_3
- call PlaySFX
-.asm_e4be8
- ld a, [wc3c0]
- and a
- jr z, .asm_e4bf4
- sub $8
- ld [wc3c0], a
- ret
-.asm_e4bf4
- ld de, SFX_INTRO_SUICUNE_2
- call PlaySFX
- callba Function8d03d
- call NextIntroScene
- ret
-
-IntroScene9: ; e4c04 (39:4c04)
-; Set up the next scene (same bg).
- xor a
- ld [hLCDStatCustom], a
- call ClearSprites
- hlcoord 0, 0, AttrMap
- ld bc, $f0
- ld a, $1
- call ByteFill
- ld bc, $3c
- ld a, $2
- call ByteFill
- ld bc, $3c
- ld a, $3
- call ByteFill
- ld a, $2
- ld [hBGMapMode], a
- call DelayFrame
- call DelayFrame
- call DelayFrame
- ld a, $c
- ld [hBGMapAddress], a
- call DelayFrame
- call DelayFrame
- call DelayFrame
- xor a
- ld [hBGMapMode], a
- ld [hBGMapAddress], a
- ld [wc3c0], a
- xor a
- ld [wcf64], a
- call NextIntroScene
- ret
-
-IntroScene10: ; e4c4f (39:4c4f)
-; Wooper and Pichu enter.
- call Functione546d
- ld hl, wcf64
- ld a, [hl]
- inc [hl]
- cp $c0
- jr z, .done
- cp $20
- jr z, .wooper
- cp $40
- jr z, .pichu
- ret
-
-.pichu
- depixel 21, 16, 1, 0
- ld a, SPRITE_ANIM_INDEX_27
- call _InitSpriteAnimStruct
- ld de, SFX_INTRO_PICHU
- call PlaySFX
- ret
-
-.wooper
- depixel 22, 6
- ld a, SPRITE_ANIM_INDEX_28
- call _InitSpriteAnimStruct
- ld de, SFX_INTRO_PICHU
- call PlaySFX
- ret
-.done
- call NextIntroScene
- ret
-
-IntroScene11: ; e4c86 (39:4c86)
-; Back to Unown again.
- call Functione54a3
- call ClearSprites
- call ClearTileMap
- xor a
- ld [hBGMapMode], a
- ld [hLCDStatCustom], a
- ld a, $1
- ld [rVBK], a
- ld hl, IntroTilemap007
- ld de, VBGMap0 tile $00
- call Functione54fa
- ld a, $0
- ld [rVBK], a
- ld hl, IntroUnownsGFX
- ld de, VTiles2 tile $00
- call Functione54c2
- ld hl, IntroTilemap008
- ld de, VBGMap0 tile $00
- call Functione54fa
- ld a, [rSVBK]
- push af
- ld a, $5
- ld [rSVBK], a
- ld hl, Palette_365ad
- ld de, wMapPals
- ld bc, $80
- call CopyBytes
- ld hl, Palette_365ad
- ld de, BGPals
- ld bc, $80
- call CopyBytes
- pop af
- ld [rSVBK], a
- xor a
- ld [hSCX], a
- ld [hSCY], a
- ld a, $7
- ld [hWX], a
- ld a, $90
- ld [hWY], a
- callba Function8cf53
- call Functione549e
- xor a
- ld [wIntroSceneFrameCounter], a
- ld [wcf65], a
- call NextIntroScene
- ret
-
-IntroScene12: ; e4cfa (39:4cfa)
-; Even more Unown.
- call Functione4d36
- ld hl, wIntroSceneFrameCounter
- ld a, [hl]
- inc [hl]
- cp $c0
- jr nc, .asm_e4d32
- cp $80
- jr nc, .asm_e4d1d
- ld c, a
- and $1f
- sla a
- ld [wcf65], a
- ld a, c
- and $e0
- srl a
- swap a
- call Functione5223
- ret
-.asm_e4d1d
- ld c, a
- and $f
- sla a
- sla a
- ld [wcf65], a
- ld a, c
- and $70
- or $40
- swap a
- call Functione5223
- ret
-.asm_e4d32
- call NextIntroScene
- ret
-
-Functione4d36: ; e4d36 (39:4d36)
- ld a, [wIntroSceneFrameCounter]
- ld c, a
- ld hl, .UnownSounds
-.loop
- ld a, [hli]
- cp -1
- ret z
- cp c
- jr z, .playsound
-rept 2
- inc hl
-endr
- jr .loop
-.playsound
- ld a, [hli]
- ld d, [hl]
- ld e, a
- push de
- call SFXChannelsOff
- pop de
- call PlaySFX
- ret
-; e4d54 (39:4d54)
-
-.UnownSounds: ; e4d54
- dbw $00, SFX_INTRO_UNOWN_3
- dbw $20, SFX_INTRO_UNOWN_2
- dbw $40, SFX_INTRO_UNOWN_1
- dbw $60, SFX_INTRO_UNOWN_2
- dbw $80, SFX_INTRO_UNOWN_3
- dbw $90, SFX_INTRO_UNOWN_2
- dbw $a0, SFX_INTRO_UNOWN_1
- dbw $b0, SFX_INTRO_UNOWN_2
- db $ff
-; e4d6d
-
-IntroScene13: ; e4d6d (39:4d6d)
-; Switch scenes again.
- call Functione54a3
- call ClearSprites
- call ClearTileMap
- xor a
- ld [hBGMapMode], a
- ld a, $1
- ld [rVBK], a
- ld hl, IntroTilemap003
- ld de, VBGMap0 tile $00
- call Functione54fa
- ld a, $0
- ld [rVBK], a
- ld hl, IntroSuicuneRunGFX
- ld de, VTiles0 tile $00
- call Functione54de
- ld hl, IntroBackgroundGFX
- ld de, VTiles2 tile $00
- call Functione54c2
- ld hl, IntroTilemap004
- ld de, VBGMap0 tile $00
- call Functione54fa
- ld a, [rSVBK]
- push af
- ld a, $5
- ld [rSVBK], a
- ld hl, Palette_e5edd
- ld de, wMapPals
- ld bc, $80
- call CopyBytes
- ld hl, Palette_e5edd
- ld de, BGPals
- ld bc, $80
- call CopyBytes
- pop af
- ld [rSVBK], a
- xor a
- ld [hSCX], a
- ld [hSCY], a
- ld a, $7
- ld [hWX], a
- ld a, $90
- ld [hWY], a
- callba Function8cf53
- depixel 13, 11, 4, 0
- ld a, SPRITE_ANIM_INDEX_26
- call _InitSpriteAnimStruct
- ld de, MUSIC_CRYSTAL_OPENING
- call PlayMusic
- xor a
- ld [wc3c0], a
- call Functione549e
- xor a
- ld [wcf64], a
- ld [wcf65], a
- call NextIntroScene
- ret
-
-IntroScene14: ; e4dfa (39:4dfa)
-; Suicune runs then jumps.
- ld a, [hSCX]
- sub 10
- ld [hSCX], a
- ld hl, wcf64
- ld a, [hl]
- inc [hl]
- cp $80
- jr z, .done
- cp $60
- jr z, .jump
- jr nc, .asm_e4e1a
- cp $40
- jr nc, .asm_e4e33
- ret
-
-.jump
- ld de, SFX_INTRO_SUICUNE_4
- call PlaySFX
-
-.asm_e4e1a
- ld a, $1
- ld [wcf65], a
- ld a, [wc3c0]
- cp $88
- jr c, .asm_e4e2c
- sub $8
- ld [wc3c0], a
- ret
-
-.asm_e4e2c
- callba Function8d03d
- ret
-
-.asm_e4e33
- ld a, [wc3c0]
- sub $2
- ld [wc3c0], a
- ret
-
-.done
- call NextIntroScene
- ret
-
-IntroScene15: ; e4e40 (39:4e40)
-; Transition to a new scene.
- call Functione54a3
- call ClearSprites
- call ClearTileMap
- xor a
- ld [hBGMapMode], a
- ld a, $1
- ld [rVBK], a
- ld hl, IntroTilemap009
- ld de, VBGMap0 tile $00
- call Functione54fa
- ld a, $0
- ld [rVBK], a
- ld hl, IntroSuicuneJumpGFX
- ld de, VTiles2 tile $00
- call Functione54c2
- ld hl, IntroUnownBackGFX
- ld de, VTiles0 tile $00
- call Functione54c2
- ld de, GFX_e7a5d
- ld hl, VTiles1 tile $00
- lb bc, BANK(GFX_e7a5d), 1
- call Request2bpp
- ld hl, IntroTilemap010
- ld de, VBGMap0 tile $00
- call Functione54fa
- call Functione541b
- ld a, [rSVBK]
- push af
- ld a, $5
- ld [rSVBK], a
- ld hl, Palette_e77dd
- ld de, wMapPals
- ld bc, $80
- call CopyBytes
- ld hl, Palette_e77dd
- ld de, BGPals
- ld bc, $80
- call CopyBytes
- pop af
- ld [rSVBK], a
- xor a
- ld [hSCX], a
- ld a, $90
- ld [hSCY], a
- ld a, $7
- ld [hWX], a
- ld a, $90
- ld [hWY], a
- callba Function8cf53
- call Functione549e
- depixel 8, 5
- ld a, SPRITE_ANIM_INDEX_2A
- call _InitSpriteAnimStruct
- depixel 12, 0
- ld a, SPRITE_ANIM_INDEX_2B
- call _InitSpriteAnimStruct
- xor a
- ld [wcf64], a
- ld [wcf65], a
- call NextIntroScene
- ret
-
-IntroScene16: ; e4edc (39:4edc)
-; Suicune shows its face. An Unown appears in front.
- ld hl, wcf64
- ld a, [hl]
- inc [hl]
- cp $80
- jr nc, .done
- call Functione5441
- ld a, [hSCY]
- and a
- ret z
- add 8
- ld [hSCY], a
- ret
-.done
- call NextIntroScene
- ret
-
-IntroScene17: ; e4ef5 (39:4ef5)
-; ...
- call Functione54a3
- call ClearSprites
- call ClearTileMap
- xor a
- ld [hBGMapMode], a
- ld a, $1
- ld [rVBK], a
- ld hl, IntroTilemap011
- ld de, VBGMap0 tile $00
- call Functione54fa
- ld a, $0
- ld [rVBK], a
- ld hl, IntroSuicuneCloseGFX
- ld de, VTiles1 tile $00
- call Functione54de
- ld hl, IntroTilemap012
- ld de, VBGMap0 tile $00
- call Functione54fa
- ld a, [rSVBK]
- push af
- ld a, $5
- ld [rSVBK], a
- ld hl, Palette_e6d6d
- ld de, wMapPals
- ld bc, $80
- call CopyBytes
- ld hl, Palette_e6d6d
- ld de, BGPals
- ld bc, $80
- call CopyBytes
- pop af
- ld [rSVBK], a
- xor a
- ld [hSCX], a
- ld [hSCY], a
- ld a, $7
- ld [hWX], a
- ld a, $90
- ld [hWY], a
- callba Function8cf53
- call Functione549e
- xor a
- ld [wcf64], a
- ld [wcf65], a
- call NextIntroScene
- ret
-
-IntroScene18: ; e4f67 (39:4f67)
-; Suicune close up.
- ld hl, wcf64
- ld a, [hl]
- inc [hl]
- cp $60
- jr nc, .done
- ld a, [hSCX]
- cp $60
- ret z
- add 8
- ld [hSCX], a
- ret
-.done
- call NextIntroScene
- ret
-
-IntroScene19: ; e4f7e (39:4f7e)
-; More setup.
- call Functione54a3
- call ClearSprites
- call ClearTileMap
- xor a
- ld [hBGMapMode], a
- ld a, $1
- ld [rVBK], a
- ld hl, IntroTilemap013
- ld de, VBGMap0 tile $00
- call Functione54fa
- ld a, $0
- ld [rVBK], a
- ld hl, IntroSuicuneBackGFX
- ld de, VTiles2 tile $00
- call Functione54c2
- ld hl, IntroUnownsGFX
- ld de, VTiles1 tile $00
- call Functione54c2
- ld de, GFX_e7a5d
- ld hl, VTiles1 tile $7f
- lb bc, BANK(GFX_e7a5d), 1
- call Request2bpp
- ld hl, IntroTilemap014
- ld de, VBGMap0 tile $00
- call Functione54fa
- call Functione541b
- ld a, [rSVBK]
- push af
- ld a, $5
- ld [rSVBK], a
- ld hl, Palette_e77dd
- ld de, wMapPals
- ld bc, $80
- call CopyBytes
- ld hl, Palette_e77dd
- ld de, BGPals
- ld bc, $80
- call CopyBytes
- pop af
- ld [rSVBK], a
- xor a
- ld [hSCX], a
- ld a, $d8
- ld [hSCY], a
- ld a, $7
- ld [hWX], a
- ld a, $90
- ld [hWY], a
- callba Function8cf53
- ld hl, wc300
- xor a
- ld [hli], a
- ld [hl], $7f
- call Functione549e
- depixel 12, 0
- ld a, SPRITE_ANIM_INDEX_2B
- call _InitSpriteAnimStruct
- xor a
- ld [wcf64], a
- ld [wcf65], a
- call NextIntroScene
- ret
-
-IntroScene20: ; e5019 (39:5019)
-; Suicune running away. A bunch of Unown appear.
- ld hl, wcf64
- ld a, [hl]
- inc [hl]
- cp $98
- jr nc, .asm_e5059
- cp $58
- ret nc
- cp $40
- jr nc, .asm_e5032
- cp $28
- ret nc
- ld a, [hSCY]
- inc a
- ld [hSCY], a
- ret
-
-.asm_e5032
- sub $18
- ld c, a
- and $3
- cp $3
- ret nz
- ld a, c
- and $1c
- srl a
- srl a
- ld [wcf65], a
- xor a
- call Functione5348
- ret
-; e5049 (39:5049)
-
- ld a, c
- and $1c
- srl a
- srl a
- ld [wcf65], a
- ld a, 1
- call Functione5348
- ret
-
-.asm_e5059
- call NextIntroScene
- ret
-
-IntroScene21: ; e505d (39:505d)
-; Suicune gets more distant and turns black.
- call Functione5451
- ld c, 3
- call DelayFrames
- xor a
- ld [hBGMapMode], a
- ld [wcf64], a
- ld [wcf65], a
- call NextIntroScene
- ret
-
-IntroScene22: ; e5072 (39:5072)
- ld hl, wcf64
- ld a, [hl]
- inc [hl]
- cp $8
- jr nc, .done
- ret
-.done
- callba Function8d03d
- call NextIntroScene
- ret
-
-IntroScene23: ; e5086 (39:5086)
- xor a
- ld [wcf64], a
- call NextIntroScene
- ret
-
-IntroScene24: ; e508e (39:508e)
-; Fade to white.
- ld hl, wcf64
- ld a, [hl]
- inc [hl]
- cp $20
- jr nc, .done
-
- ld c, a
- and $3
- ret nz
- ld a, c
- and $1c
- sla a
- call Functione5172
- ret
-
-.done
- ld a, $40
- ld [wcf64], a
- call NextIntroScene
- ret
-
-IntroScene25: ; e50ad (39:50ad)
-; Wait around a bit.
- ld a, [wcf64]
- dec a
- jr z, .done
- ld [wcf64], a
- ret
-.done
- call NextIntroScene
- ret
-
-IntroScene26: ; e50bb (39:50bb)
-; Load the final scene.
- call ClearBGPalettes
- call ClearSprites
- call ClearTileMap
- xor a
- ld [hBGMapMode], a
- ld a, $1
- ld [rVBK], a
- ld hl, IntroTilemap015
- ld de, VBGMap0 tile $00
- call Functione54fa
- ld a, $0
- ld [rVBK], a
- ld hl, IntroCrystalUnownsGFX
- ld de, VTiles2 tile $00
- call Functione54c2
- ld hl, IntroTilemap017
- ld de, VBGMap0 tile $00
- call Functione54fa
- ld a, [rSVBK]
- push af
- ld a, $5
- ld [rSVBK], a
- ld hl, Palette_e679d
- ld de, wMapPals
- ld bc, $80
- call CopyBytes
- ld hl, Palette_e679d
- ld de, BGPals
- ld bc, $80
- call CopyBytes
- pop af
- ld [rSVBK], a
- xor a
- ld [hSCX], a
- ld [hSCY], a
- ld a, $7
- ld [hWX], a
- ld a, $90
- ld [hWY], a
- callba Function8cf53
- call Functione549e
- xor a
- ld [wcf64], a
- ld [wcf65], a
- call NextIntroScene
- ret
-
-IntroScene27: ; e512d (39:512d)
-; Spell out C R Y S T A L with Unown.
- ld hl, wcf65
- inc [hl]
- ld hl, wcf64
- ld a, [hl]
- inc [hl]
- cp $80
- jr nc, .done
-
- ld c, a
- and $f
- ld [wcf65], a
- ld a, c
- and $70
- swap a
- call Functione539d
- ret
-
-.done
- call NextIntroScene
- ld a, $80
- ld [wcf64], a
- ret
-
-IntroScene28: ; e5152 (39:5152)
-; Cut out when the music ends, and lead into the title screen.
- ld hl, wcf64
- ld a, [hl]
- and a
- jr z, .done
- dec [hl]
- cp $18
- jr z, .clear
- cp $8
- ret nz
-
- ld de, SFX_UNKNOWN_CB
- call PlaySFX
- ret
-
-.clear
- call ClearBGPalettes
- ret
-
-.done
- ld hl, wJumptableIndex
- set 7, [hl]
- ret
-
-
-Functione5172: ; e5172 (39:5172)
- ld hl, Unknown_e519c
- add l
- ld l, a
- ld a, $0
- adc h
- ld h, a
- ld a, [rSVBK]
- push af
- ld a, $5
- ld [rSVBK], a
- ld de, BGPals
- ld b, $8
-.asm_e5187
- push hl
- ld c, $8
-.asm_e518a
- ld a, [hli]
- ld [de], a
- inc de
- dec c
- jr nz, .asm_e518a
- pop hl
- dec b
- jr nz, .asm_e5187
- pop af
- ld [rSVBK], a
- ld a, $1
- ld [hCGBPalUpdate], a
- ret
-; e519c (39:519c)
-
-Unknown_e519c: ; e519c
-; Fade to white.
- RGB 24, 12, 09
- RGB 31, 31, 31
- RGB 12, 00, 31
- RGB 00, 00, 00
-
- RGB 31, 19, 05
- RGB 31, 31, 31
- RGB 15, 05, 31
- RGB 07, 07, 07
-
- RGB 31, 21, 09
- RGB 31, 31, 31
- RGB 18, 09, 31
- RGB 11, 11, 11
-
- RGB 31, 23, 13
- RGB 31, 31, 31
- RGB 21, 13, 31
- RGB 15, 15, 15
-
- RGB 31, 25, 17
- RGB 31, 31, 31
- RGB 25, 17, 31
- RGB 19, 19, 19
-
- RGB 31, 27, 21
- RGB 31, 31, 31
- RGB 27, 21, 31
- RGB 23, 23, 23
-
- RGB 31, 29, 25
- RGB 31, 31, 31
- RGB 29, 26, 31
- RGB 27, 27, 27
-
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
-; e51dc
-
-Functione51dc: ; e51dc (39:51dc)
- push de
- ld a, SPRITE_ANIM_INDEX_29
- call _InitSpriteAnimStruct
- ld hl, $c
- add hl, bc
- ld [hl], $8
- ld a, $3c
- call Function3b3c
- pop de
-
- push de
- ld a, SPRITE_ANIM_INDEX_29
- call _InitSpriteAnimStruct
- ld hl, $c
- add hl, bc
- ld [hl], $18
- ld a, $3b
- call Function3b3c
- pop de
-
- push de
- ld a, SPRITE_ANIM_INDEX_29
- call _InitSpriteAnimStruct
- ld hl, $c
- add hl, bc
- ld [hl], $28
- ld a, $39
- call Function3b3c
- pop de
-
- ld a, SPRITE_ANIM_INDEX_29
- call _InitSpriteAnimStruct
- ld hl, $c
- add hl, bc
- ld [hl], $38
- ld a, $3a
- call Function3b3c
- ret
-
-Functione5223: ; e5223 (39:5223)
-rept 3
- add a
-endr
- ld e, a
- ld d, $0
- ld hl, BGPals
- add hl, de
-rept 2
- inc hl
-endr
- ld a, [wcf65]
- and $3f
- cp $1f
- jr z, .asm_e523e
- jr c, .asm_e523e
- ld c, a
- ld a, $3f
- sub c
-.asm_e523e
- ld c, a
- ld b, $0
- ld a, [rSVBK]
- push af
- ld a, $5
- ld [rSVBK], a
- push hl
- push bc
- ld hl, BGPals
- ld bc, $40
- xor a
- call ByteFill
- pop bc
- pop hl
- push hl
- ld hl, Unknown_e5288
-rept 2
- add hl, bc
-endr
- ld a, [hli]
- ld d, [hl]
- ld e, a
- pop hl
- ld a, e
- ld [hli], a
- ld a, d
- ld [hli], a
- push hl
- ld hl, Unknown_e52c8
-rept 2
- add hl, bc
-endr
- ld a, [hli]
- ld d, [hl]
- ld e, a
- pop hl
- ld a, e
- ld [hli], a
- ld a, d
- ld [hli], a
- push hl
- ld hl, Unknown_e5308
-rept 2
- add hl, bc
-endr
- ld a, [hli]
- ld d, [hl]
- ld e, a
- pop hl
- ld a, e
- ld [hli], a
- ld a, d
- ld [hli], a
- pop af
- ld [rSVBK], a
- ld a, $1
- ld [hCGBPalUpdate], a
- ret
-; e5288 (39:5288)
-
-Unknown_e5288: ; e5288
-; Fade between black and white.
-hue = 0
-rept 32
- RGB hue, hue, hue
-hue = hue + 1
-endr
-; e52c8
-
-Unknown_e52c8: ; e52c8
-; Fade between black and light blue.
-hue = 0
-rept 32
- RGB 0, hue / 2, hue
-hue = hue + 1
-endr
-; e5308
-
-Unknown_e5308: ; e5308
-; Fade between black and blue.
-hue = 0
-rept 32
- RGB 0, 0, hue
-hue = hue + 1
-endr
-; e5348
-
-Functione5348: ; e5348 (39:5348)
- and a
- jr nz, .asm_e5350
- ld hl, Palette_e538d
- jr .asm_e5353
-.asm_e5350
- ld hl, Palette_e5395
-.asm_e5353
- ld a, [wcf65]
- and $7
-rept 3
- add a
-endr
- ld c, a
- ld a, [rSVBK]
- push af
- ld a, $5
- ld [rSVBK], a
- push bc
- ld de, BGPals
- ld a, c
- add e
- ld e, a
- ld a, $0
- adc d
- ld d, a
- ld bc, $8
- call CopyBytes
- pop bc
- ld de, wMapPals
- ld a, c
- add e
- ld e, a
- ld a, $0
- adc d
- ld d, a
- ld bc, $8
- call CopyBytes
- pop af
- ld [rSVBK], a
- ld a, $1
- ld [hCGBPalUpdate], a
- ret
-; e538d (39:538d)
-
-Palette_e538d: ; e538d
- RGB 24, 12, 09
- RGB 31, 31, 31
- RGB 12, 00, 31
- RGB 00, 00, 00
-; e5395
-
-Palette_e5395: ; e5395
- RGB 24, 12, 09
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
-; e539d
-
-Functione539d: ; e539d (39:539d)
-rept 3
- add a
-endr
- ld e, a
- ld d, $0
- ld hl, BGPals
- add hl, de
-rept 4
- inc hl
-endr
- ld a, [wcf65]
- add a
- ld c, a
- ld b, $0
- ld a, [rSVBK]
- push af
- ld a, $5
- ld [rSVBK], a
- push hl
- ld hl, Palette_e53db
- add hl, bc
- ld a, [hli]
- ld d, [hl]
- ld e, a
- pop hl
- ld a, e
- ld [hli], a
- ld a, d
- ld [hli], a
- push hl
- ld hl, Palette_e53fb
- add hl, bc
- ld a, [hli]
- ld d, [hl]
- ld e, a
- pop hl
- ld a, e
- ld [hli], a
- ld a, d
- ld [hli], a
- pop af
- ld [rSVBK], a
- ld a, $1
- ld [hCGBPalUpdate], a
- ret
-; e53db (39:53db)
-
-Palette_e53db: ; e53db
-hue = 31
-rept 8
- RGB hue, hue, hue
-hue = hue + -1
- RGB hue, hue, hue
-hue = hue + -2
-endr
-; e53fb
-
-Palette_e53fb: ; e53fb
-hue = 31
-rept 16
- RGB hue, hue, hue
-hue = hue + -1
-endr
-; e541b
-
-Functione541b: ; e541b (39:541b)
- ld a, [rSVBK]
- push af
- ld a, $6
- ld [rSVBK], a
- ld hl, w6_d000
- decoord 0, 0
- ld b, SCREEN_HEIGHT
-.asm_e542a
- ld c, SCREEN_WIDTH
-.asm_e542c
- ld a, [hli]
- ld [de], a
- inc de
- dec c
- jr nz, .asm_e542c
- ld a, $c
- add l
- ld l, a
- ld a, $0
- adc h
- ld h, a
- dec b
- jr nz, .asm_e542a
- pop af
- ld [rSVBK], a
- ret
-
-Functione5441: ; e5441 (39:5441)
- ld a, [wcf64]
- and $3
- jr z, Functione5451
- cp $3
- jr z, .asm_e544d
- ret
-.asm_e544d
- xor a
- ld [hBGMapMode], a
- ret
-
-Functione5451: ; e5451 (39:5451)
- hlcoord 0, 0
- ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
-.asm_e5457
- ld a, [hl]
- and a
- jr z, .asm_e5462
- cp $80
- jr nc, .asm_e5462
- xor $8
- ld [hl], a
-.asm_e5462
- inc hl
- dec bc
- ld a, c
- or b
- jr nz, .asm_e5457
- ld a, $1
- ld [hBGMapMode], a
- ret
-
-Functione546d: ; e546d (39:546d)
- ld a, [wcf64]
- cp $24
- ret nc
- and $c
- srl a
- ld e, a
- ld d, $0
- ld hl, Unknown_e5496
- add hl, de
- ld a, [hli]
- ld [Requested2bppSource], a
- ld a, [hli]
- ld [Requested2bppSource + 1], a
- ld a, (VTiles2 tile $09) % $100
- ld [Requested2bppDest], a
- ld a, (VTiles2 tile $09) / $100
- ld [Requested2bppDest + 1], a
- ld a, $4
- ld [Requested2bpp], a
- ret
-; e5496 (39:5496)
-
-Unknown_e5496: ; e5496
- dw GFX_e799d
- dw GFX_e79dd
- dw GFX_e7a1d
- dw GFX_e79dd
-; e549e
-
-Functione549e: ; e549e (39:549e)
- ld a, $1
- ld [hCGBPalUpdate], a
- ret
-
-Functione54a3: ; e54a3 (39:54a3)
- ld a, [rSVBK]
- push af
- ld a, $5
- ld [rSVBK], a
- ld hl, BGPals
- ld bc, $80
- xor a
- call ByteFill
- pop af
- ld [rSVBK], a
- ld a, $1
- ld [hCGBPalUpdate], a
- call DelayFrame
- call DelayFrame
- ret
-
-Functione54c2: ; e54c2 (39:54c2)
- ld a, [rSVBK]
- push af
- ld a, $6
- ld [rSVBK], a
- push de
- ld de, w6_d000
- call Decompress
- pop hl
- ld de, w6_d000
- ld bc, $180
- call Request2bpp
- pop af
- ld [rSVBK], a
- ret
-
-Functione54de: ; e54de (39:54de)
- ld a, [rSVBK]
- push af
- ld a, $6
- ld [rSVBK], a
- push de
- ld de, w6_d000
- call Decompress
- pop hl
- ld de, w6_d000
- ld bc, $1ff
- call Request2bpp
- pop af
- ld [rSVBK], a
- ret
-
-Functione54fa: ; e54fa (39:54fa)
- ld a, [rSVBK]
- push af
- ld a, $6
- ld [rSVBK], a
- push de
- ld de, w6_d000
- call Decompress
- pop hl
- ld de, w6_d000
- ld bc, $140
- call Request2bpp
- pop af
- ld [rSVBK], a
- ret
-
-Functione5516: ; e5516 (39:5516)
- ld a, [rSVBK]
- push af
- ld a, $5
- ld [rSVBK], a
- ld hl, LYOverrides
- ld bc, $90
- xor a
- call ByteFill
- pop af
- ld [rSVBK], a
- ld a, $43
- ld [hLCDStatCustom], a
- ret
-
-Functione552f: ; e552f (39:552f)
- ld a, [rSVBK]
- push af
- ld a, $5
- ld [rSVBK], a
- ld a, [wcf64]
- and $1
- jr z, .asm_e5548
- ld hl, LYOverrides
- ld a, [hl]
- inc a
- ld bc, $5f
- call ByteFill
-.asm_e5548
- ld hl, LYOverrides + $5f
- ld a, [hl]
-rept 2
- inc a
-endr
- ld bc, $31
- call ByteFill
- ld a, [LYOverrides + 0]
- ld [hSCX], a
- pop af
- ld [rSVBK], a
- ret
-
-IntroSuicuneRunGFX: ; e555d
-INCBIN "gfx/intro/suicune_run.2bpp.lz"
-; e592d
-
-IntroPichuWooperGFX: ; e592d
-INCBIN "gfx/intro/pichu_wooper.2bpp.lz"
-; e5c7d
-
-IntroBackgroundGFX: ; e5c7d
-INCBIN "gfx/intro/background.2bpp.lz"
-; e5e6d
-
-IntroTilemap004: ; e5e6d
-INCBIN "gfx/intro/004.tilemap.lz"
-; e5ecd
-
-IntroTilemap003: ; e5ecd
-INCBIN "gfx/intro/003.tilemap.lz"
-; e5edd
-
-Palette_e5edd: ; e5edd
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 0, 4, 5
- RGB 1, 8, 5
- RGB 4, 12, 9
- RGB 24, 12, 9
- RGB 0, 4, 5
- RGB 9, 6, 8
- RGB 8, 16, 5
- RGB 5, 10, 4
- RGB 31, 31, 31
- RGB 9, 6, 8
- RGB 18, 9, 9
- RGB 13, 8, 9
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 2, 5, 22
- RGB 1, 5, 12
- RGB 31, 31, 31
- RGB 31, 10, 25
- RGB 31, 21, 0
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 21, 31
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
-
-IntroUnownsGFX: ; e5f5d
-INCBIN "gfx/intro/unowns.2bpp.lz"
-; e634d
-
-IntroPulseGFX: ; e634d
-INCBIN "gfx/intro/pulse.2bpp.lz"
-; e63dd
-
-IntroTilemap002: ; e63dd
-INCBIN "gfx/intro/002.tilemap.lz"
-; e641d
-
-IntroTilemap001: ; e641d
-INCBIN "gfx/intro/001.tilemap.lz"
-; e642d
-
-IntroTilemap006: ; e642d
-INCBIN "gfx/intro/006.tilemap.lz"
-; e647d
-
-IntroTilemap005: ; e647d
-INCBIN "gfx/intro/005.tilemap.lz"
-; e649d
-
-IntroTilemap008: ; e649d
-INCBIN "gfx/intro/008.tilemap.lz"
-; e655d
-
-IntroTilemap007: ; e655d
-INCBIN "gfx/intro/007.tilemap.lz"
-; e65ad
-
-Palette_365ad: ; e65ad
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 10, 0, 10
- RGB 19, 0, 19
- RGB 31, 0, 31
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
-
-IntroCrystalUnownsGFX: ; e662d
-INCBIN "gfx/intro/crystal_unowns.2bpp.lz"
-; e672d
-
-IntroTilemap017: ; e672d
-INCBIN "gfx/intro/017.tilemap.lz"
-; e676d
-
-IntroTilemap015: ; e676d
-INCBIN "gfx/intro/015.tilemap.lz"
-; e679d
-
-Palette_e679d: ; e679d
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
-
-IntroSuicuneCloseGFX: ; e681d
-INCBIN "gfx/intro/suicune_close.2bpp.lz"
-; e6c3d
-
-IntroTilemap012: ; e6c3d
-INCBIN "gfx/intro/012.tilemap.lz"
-; e6d0d
-
-IntroTilemap011: ; e6d0d
-INCBIN "gfx/intro/011.tilemap.lz"
-; e6d6d
-
-Palette_e6d6d: ; e6d6d
- RGB 24, 12, 9
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 24, 12, 9
- RGB 31, 31, 31
- RGB 8, 9, 31
- RGB 0, 0, 0
- RGB 24, 12, 9
- RGB 12, 20, 31
- RGB 19, 8, 31
- RGB 0, 0, 0
- RGB 12, 20, 31
- RGB 8, 9, 31
- RGB 19, 8, 31
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 12, 20, 31
- RGB 8, 9, 31
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
-
-IntroSuicuneJumpGFX: ; e6ded
-INCBIN "gfx/intro/suicune_jump.2bpp.lz"
-; e72ad
-
-IntroSuicuneBackGFX: ; e72ad
-INCBIN "gfx/intro/suicune_back.2bpp.lz"
-; e764d
-
-IntroTilemap010: ; e764d
-INCBIN "gfx/intro/010.tilemap.lz"
-; e76ad
-
-IntroTilemap009: ; e76ad
-INCBIN "gfx/intro/009.tilemap.lz"
-; e76bd
-
-IntroTilemap014: ; e76bd
-INCBIN "gfx/intro/014.tilemap.lz"
-; e778d
-
-IntroTilemap013: ; e778d
-INCBIN "gfx/intro/013.tilemap.lz"
-; e77dd
-
-Palette_e77dd: ; e77dd
- RGB 24, 12, 9
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 24, 12, 9
- RGB 31, 31, 31
- RGB 8, 9, 31
- RGB 0, 0, 0
- RGB 24, 12, 9
- RGB 24, 12, 9
- RGB 24, 12, 9
- RGB 24, 12, 9
- RGB 24, 12, 9
- RGB 24, 12, 9
- RGB 24, 12, 9
- RGB 24, 12, 9
- RGB 24, 12, 9
- RGB 24, 12, 9
- RGB 24, 12, 9
- RGB 24, 12, 9
- RGB 24, 12, 9
- RGB 24, 12, 9
- RGB 24, 12, 9
- RGB 24, 12, 9
- RGB 24, 12, 9
- RGB 24, 12, 9
- RGB 24, 12, 9
- RGB 24, 12, 9
- RGB 24, 12, 9
- RGB 24, 12, 9
- RGB 24, 12, 9
- RGB 24, 12, 9
- RGB 31, 31, 31
- RGB 31, 31, 31
- RGB 12, 0, 31
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 21, 9, 0
- RGB 21, 9, 0
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 20, 20, 20
- RGB 11, 11, 11
- RGB 0, 0, 0
-
-IntroUnownBackGFX: ; e785d
-INCBIN "gfx/intro/unown_back.2bpp.lz"
-; e799d
-
-GFX_e799d: ; e799d
-INCBIN "gfx/unknown/0e799d.2bpp"
-GFX_e79dd: ; e79dd
-INCBIN "gfx/unknown/0e79dd.2bpp"
-GFX_e7a1d: ; e7a1d
-INCBIN "gfx/unknown/0e7a1d.2bpp"
-
-GFX_e7a5d: ; e7a5d
-INCBIN "gfx/unknown/0e7a5d.2bpp"
-
-
-
SECTION "bank3E", ROMX, BANK[$3E]
-FontExtra:
-INCBIN "gfx/misc/font_extra.2bpp"
+INCLUDE "gfx/font.asm"
+INCLUDE "engine/time_capsule/conversion.asm"
-Font:
-INCBIN "gfx/misc/font.1bpp"
-
-FontBattleExtra:
-INCBIN "gfx/misc/font_battle_extra.2bpp"
-
-Frames: ; f8800
-INCBIN "gfx/frames/1.1bpp"
-INCBIN "gfx/frames/2.1bpp"
-INCBIN "gfx/frames/3.1bpp"
-INCBIN "gfx/frames/4.1bpp"
-INCBIN "gfx/frames/5.1bpp"
-INCBIN "gfx/frames/6.1bpp"
-INCBIN "gfx/frames/7.1bpp"
-INCBIN "gfx/frames/8.1bpp"
-INCBIN "gfx/frames/9.1bpp"
-; f89b0
-
-; TODO: Various misc graphics here.
-
-GFX_f89b0: ; f89b0
-INCBIN "gfx/unknown/0f89b0.2bpp"
-; f8a90
-
-ShinyIcon: ; f8a90
-INCBIN "gfx/stats/shiny.2bpp"
-
-GFX_f8aa0: ; f8aa0
-INCBIN "gfx/unknown/0f8aa0.2bpp"
-; f8ac0
-
-EnemyHPBarBorderGFX: ; f8ac0
-INCBIN "gfx/battle/enemy_hp_bar_border.1bpp"
-; f8ae0
-
-HPExpBarBorderGFX: ; f8ae0
-INCBIN "gfx/battle/hp_exp_bar_border.1bpp"
-; f8b10
-
-ExpBarGFX: ; f8b10
-INCBIN "gfx/battle/expbar.2bpp"
-; f8ba0
-
-TownMapGFX: ; f8ba0
-INCBIN "gfx/misc/town_map.2bpp.lz"
-; f8ea4
-
-GFX_f8ea4: ; unused
-INCBIN "gfx/unknown/0f8ea4.2bpp"
-; f8f24
-
-OverworldPhoneIconGFX: ; f8f24
-INCBIN "gfx/mobile/overworld_phone_icon.2bpp"
-; f8f34
-
-GFX_f8f34: ; unused
-INCBIN "gfx/unknown/0f8f34.2bpp"
-; f9204
-
-TextBoxSpaceGFX: ; f9204
-INCBIN "gfx/frames/space.2bpp"
-; f9214
-
-MobilePhoneTilesGFX: ; f9214
-INCBIN "gfx/mobile/phone_tiles.2bpp"
-; f9344
-
-MapEntryFrameGFX: ; f9344
-INCBIN "gfx/frames/map_entry_sign.2bpp"
-; f9424
-
-GFX_f9424: ; f9424
-INCBIN "gfx/unknown/0f9424.2bpp"
-; f9434
-
-Footprints: ; f9434
-INCBIN "gfx/misc/footprints.1bpp"
-; fb434
-
-; This and the following two functions are unreferenced.
-Unknown_fb434:
- db 0
-
-Functionfb435: ; 4b435
- ld a, [Unknown_fb434]
- and a
- jp nz, Get1bpp_2
- jp Get1bpp
-; fb43f
-
-Functionfb43f: ; fb43f
- ld a, [Unknown_fb434]
- and a
- jp nz, Get2bpp_2
- jp Get2bpp
-; End unreferenced block
-; fb449
-
-_LoadStandardFont:: ; fb449
- ld de, Font
- ld hl, VTiles1
- lb bc, BANK(Font), $80
- ld a, [rLCDC]
- bit 7, a
- jp z, Copy1bpp
-
- ld de, Font
- ld hl, VTiles1
- lb bc, BANK(Font), $20
- call Get1bpp_2
- ld de, Font + $20 * LEN_1BPP_TILE
- ld hl, VTiles1 tile $20
- lb bc, BANK(Font), $20
- call Get1bpp_2
- ld de, Font + $40 * LEN_1BPP_TILE
- ld hl, VTiles1 tile $40
- lb bc, BANK(Font), $20
- call Get1bpp_2
- ld de, Font + $60 * LEN_1BPP_TILE
- ld hl, VTiles1 tile $60
- lb bc, BANK(Font), $20
- call Get1bpp_2
- ret
-; fb48a
-
-_LoadFontsExtra1:: ; fb48a
- ld de, MobilePhoneTilesGFX
- ld hl, VTiles2 tile $60
- lb bc, BANK(MobilePhoneTilesGFX), 1
- call Get1bpp_2
- ld de, OverworldPhoneIconGFX
- ld hl, VTiles2 tile $62
- lb bc, BANK(OverworldPhoneIconGFX), 1
- call Get2bpp_2
- ld de, FontExtra + 3 * LEN_2BPP_TILE
- ld hl, VTiles2 tile $63
- lb bc, BANK(FontExtra), $16
- call Get2bpp_2
- jr LoadFrame
-; fb4b0
-
-_LoadFontsExtra2:: ; fb4b0
- ld de, GFX_f9424
- ld hl, VTiles2 tile $61
- ld b, BANK(GFX_f9424)
- ld c, 1
- call Get2bpp_2
- ret
-; fb4be
-
-_LoadFontsBattleExtra:: ; fb4be
- ld de, FontBattleExtra
- ld hl, VTiles2 tile $60
- lb bc, BANK(FontBattleExtra), $19
- call Get2bpp_2
- jr LoadFrame
-; fb4cc
-
-LoadFrame: ; fb4cc
- ld a, [TextBoxFrame]
- and 7
- ld bc, TILES_PER_FRAME * LEN_1BPP_TILE
- ld hl, Frames
- call AddNTimes
- ld d, h
- ld e, l
- ld hl, VTiles2 tile $79
- lb bc, BANK(Frames), TILES_PER_FRAME
- call Get1bpp_2
- ld hl, VTiles2 tile $7f
- ld de, TextBoxSpaceGFX
- lb bc, BANK(TextBoxSpaceGFX), 1
- call Get1bpp_2
- ret
-; fb4f2
-
-LoadBattleFontsHPBar: ; fb4f2
- ld de, FontBattleExtra
- ld hl, VTiles2 tile $60
- lb bc, BANK(FontBattleExtra), $c
- call Get2bpp_2
- ld hl, VTiles2 tile $70
- ld de, FontBattleExtra + $10 * LEN_2BPP_TILE
- lb bc, BANK(FontBattleExtra), 3
- call Get2bpp_2
- call LoadFrame
-
-LoadHPBar: ; fb50d
- ld de, EnemyHPBarBorderGFX
- ld hl, VTiles2 tile $6c
- lb bc, BANK(EnemyHPBarBorderGFX), 4
- call Get1bpp_2
- ld de, HPExpBarBorderGFX
- ld hl, VTiles2 tile $73
- lb bc, BANK(HPExpBarBorderGFX), 6
- call Get1bpp_2
- ld de, ExpBarGFX
- ld hl, VTiles2 tile $55
- lb bc, BANK(ExpBarGFX), 9
- call Get2bpp_2
- ld de, MobilePhoneTilesGFX + 9 * LEN_2BPP_TILE
- ld hl, VTiles2 tile $5e
- lb bc, BANK(MobilePhoneTilesGFX), 2
- call Get2bpp_2
- ret
-; fb53e
-
-Functionfb53e: ; fb53e
- call _LoadFontsBattleExtra
- ld de, EnemyHPBarBorderGFX
- ld hl, VTiles2 tile $6c
- lb bc, BANK(EnemyHPBarBorderGFX), 4
- call Get1bpp_2
- ld de, HPExpBarBorderGFX
- ld hl, VTiles2 tile $78
- lb bc, BANK(HPExpBarBorderGFX), 1
- call Get1bpp_2
- ld de, HPExpBarBorderGFX + 3 * LEN_1BPP_TILE
- ld hl, VTiles2 tile $76
- lb bc, BANK(HPExpBarBorderGFX), 2
- call Get1bpp_2
- ld de, ExpBarGFX
- ld hl, VTiles2 tile $55
- lb bc, BANK(ExpBarGFX), 8
- call Get2bpp_2
-
-Functionfb571: ; fb571
- ld de, GFX_f89b0
- ld hl, VTiles2 tile $31
- lb bc, BANK(GFX_f89b0), $11
- call Get2bpp_2
- ret
-; fb57e
-
-; These functions seem to be related to backwards compatibility
-
-Functionfb57e: ; fb57e
- ld a, [wd003]
- ld hl, OTPartyMon1Species
- call GetPartyLocation
- push hl
- ld a, [wd003]
- inc a
- ld c, a
- ld b, 0
- ld hl, OTPartyCount
- add hl, bc
- ld a, [hl]
- pop hl
- cp EGG
- jr z, .asm_fb59c
- cp [hl]
- jr nz, .asm_fb5db
-
-.asm_fb59c
- ld b, h
- ld c, l
- ld hl, MON_LEVEL
- add hl, bc
- ld a, [hl]
- cp 101
- jr nc, .asm_fb5db
- ld a, [wLinkMode]
- cp LINK_TIMECAPSULE
- jr nz, .asm_fb5d9
- ld hl, OTPartySpecies
- ld a, [wd003]
- ld c, a
- ld b, 0
- add hl, bc
- ld a, [hl]
-
- ; Magnemite and Magneton's types changed
- ; from Electric to Electric/Steel.
- cp MAGNEMITE
- jr z, .asm_fb5d9
- cp MAGNETON
- jr z, .asm_fb5d9
-
- ld [CurSpecies], a
- call GetBaseData
- ld hl, wcbea
-rept 2
- add hl, bc
-endr
- ld a, [BaseType1]
- cp [hl]
- jr nz, .asm_fb5db
- inc hl
- ld a, [BaseType2]
- cp [hl]
- jr nz, .asm_fb5db
-
-.asm_fb5d9
- and a
- ret
-
-.asm_fb5db
- scf
- ret
-; fb5dd
-
-Functionfb5dd: ; fb5dd
- ld a, [wd002]
- ld d, a
- ld a, [PartyCount]
- ld b, a
- ld c, $0
-.asm_fb5e7
- ld a, c
- cp d
- jr z, .asm_fb5f8
- push bc
- ld a, c
- ld hl, PartyMon1HP
- call GetPartyLocation
- pop bc
- ld a, [hli]
- or [hl]
- jr nz, .asm_fb60b
-
-.asm_fb5f8
- inc c
- dec b
- jr nz, .asm_fb5e7
- ld a, [wd003]
- ld hl, OTPartyMon1HP
- call GetPartyLocation
- ld a, [hli]
- or [hl]
- jr nz, .asm_fb60b
- scf
- ret
-
-.asm_fb60b
- and a
- ret
-; fb60d
-
-Functionfb60d: ; fb60d
- hlcoord 4, 0
- ld de, PlayerName
- call PlaceString
- ld a, $14
- ld [bc], a
- hlcoord 4, 8
- ld de, wd26b
- call PlaceString
- ld a, $14
- ld [bc], a
- hlcoord 7, 1
- ld de, PartySpecies
- call Functionfb634
- hlcoord 7, 9
- ld de, OTPartySpecies
-
-Functionfb634: ; fb634
- ld c, $0
-.asm_fb636
- ld a, [de]
- cp $ff
- ret z
- ld [wd265], a
- push bc
- push hl
- push de
- push hl
- ld a, c
- ld [hProduct], a
- call GetPokemonName
- pop hl
- call PlaceString
- pop de
- inc de
- pop hl
- ld bc, SCREEN_WIDTH
- add hl, bc
- pop bc
- inc c
- jr .asm_fb636
-; fb656
-
-KantoMonSpecials: ; fb656
-; The original special base stat for
-; each Kanto monster from Red/Blue.
- db 65 ; BULBASAUR
- db 80 ; IVYSAUR
- db 100 ; VENUSAUR
- db 50 ; CHARMANDER
- db 65 ; CHARMELEON
- db 85 ; CHARIZARD
- db 50 ; SQUIRTLE
- db 65 ; WARTORTLE
- db 85 ; BLASTOISE
- db 20 ; CATERPIE
- db 25 ; METAPOD
- db 80 ; BUTTERFREE
- db 20 ; WEEDLE
- db 25 ; KAKUNA
- db 45 ; BEEDRILL
- db 35 ; PIDGEY
- db 50 ; PIDGEOTTO
- db 70 ; PIDGEOT
- db 25 ; RATTATA
- db 50 ; RATICATE
- db 31 ; SPEAROW
- db 61 ; FEAROW
- db 40 ; EKANS
- db 65 ; ARBOK
- db 50 ; PIKACHU
- db 90 ; RAICHU
- db 30 ; SANDSHREW
- db 55 ; SANDSLASH
- db 40 ; NIDORAN_F
- db 55 ; NIDORINA
- db 75 ; NIDOQUEEN
- db 40 ; NIDORAN_M
- db 55 ; NIDORINO
- db 75 ; NIDOKING
- db 60 ; CLEFAIRY
- db 85 ; CLEFABLE
- db 65 ; VULPIX
- db 100 ; NINETALES
- db 25 ; JIGGLYPUFF
- db 50 ; WIGGLYTUFF
- db 40 ; ZUBAT
- db 75 ; GOLBAT
- db 75 ; ODDISH
- db 85 ; GLOOM
- db 100 ; VILEPLUME
- db 55 ; PARAS
- db 80 ; PARASECT
- db 40 ; VENONAT
- db 90 ; VENOMOTH
- db 45 ; DIGLETT
- db 70 ; DUGTRIO
- db 40 ; MEOWTH
- db 65 ; PERSIAN
- db 50 ; PSYDUCK
- db 80 ; GOLDUCK
- db 35 ; MANKEY
- db 60 ; PRIMEAPE
- db 50 ; GROWLITHE
- db 80 ; ARCANINE
- db 40 ; POLIWAG
- db 50 ; POLIWHIRL
- db 70 ; POLIWRATH
- db 105 ; ABRA
- db 120 ; KADABRA
- db 135 ; ALAKAZAM
- db 35 ; MACHOP
- db 50 ; MACHOKE
- db 65 ; MACHAMP
- db 70 ; BELLSPROUT
- db 85 ; WEEPINBELL
- db 100 ; VICTREEBEL
- db 100 ; TENTACOOL
- db 120 ; TENTACRUEL
- db 30 ; GEODUDE
- db 45 ; GRAVELER
- db 55 ; GOLEM
- db 65 ; PONYTA
- db 80 ; RAPIDASH
- db 40 ; SLOWPOKE
- db 80 ; SLOWBRO
- db 95 ; MAGNEMITE
- db 120 ; MAGNETON
- db 58 ; FARFETCH_D
- db 35 ; DODUO
- db 60 ; DODRIO
- db 70 ; SEEL
- db 95 ; DEWGONG
- db 40 ; GRIMER
- db 65 ; MUK
- db 45 ; SHELLDER
- db 85 ; CLOYSTER
- db 100 ; GASTLY
- db 115 ; HAUNTER
- db 130 ; GENGAR
- db 30 ; ONIX
- db 90 ; DROWZEE
- db 115 ; HYPNO
- db 25 ; KRABBY
- db 50 ; KINGLER
- db 55 ; VOLTORB
- db 80 ; ELECTRODE
- db 60 ; EXEGGCUTE
- db 125 ; EXEGGUTOR
- db 40 ; CUBONE
- db 50 ; MAROWAK
- db 35 ; HITMONLEE
- db 35 ; HITMONCHAN
- db 60 ; LICKITUNG
- db 60 ; KOFFING
- db 85 ; WEEZING
- db 30 ; RHYHORN
- db 45 ; RHYDON
- db 105 ; CHANSEY
- db 100 ; TANGELA
- db 40 ; KANGASKHAN
- db 70 ; HORSEA
- db 95 ; SEADRA
- db 50 ; GOLDEEN
- db 80 ; SEAKING
- db 70 ; STARYU
- db 100 ; STARMIE
- db 100 ; MR__MIME
- db 55 ; SCYTHER
- db 95 ; JYNX
- db 85 ; ELECTABUZZ
- db 85 ; MAGMAR
- db 55 ; PINSIR
- db 70 ; TAUROS
- db 20 ; MAGIKARP
- db 100 ; GYARADOS
- db 95 ; LAPRAS
- db 48 ; DITTO
- db 65 ; EEVEE
- db 110 ; VAPOREON
- db 110 ; JOLTEON
- db 110 ; FLAREON
- db 75 ; PORYGON
- db 90 ; OMANYTE
- db 115 ; OMASTAR
- db 45 ; KABUTO
- db 70 ; KABUTOPS
- db 60 ; AERODACTYL
- db 65 ; SNORLAX
- db 125 ; ARTICUNO
- db 125 ; ZAPDOS
- db 125 ; MOLTRES
- db 50 ; DRATINI
- db 70 ; DRAGONAIR
- db 100 ; DRAGONITE
- db 154 ; MEWTWO
- db 100 ; MEW
-; fb6ed
-
-
-INCLUDE "event/name_rater.asm"
-
-
-PlaySlowCry: ; fb841
- ld a, [ScriptVar]
- call LoadCryHeader
- jr c, .done
-
- ld hl, CryPitch
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld bc, -$140
- add hl, bc
- ld a, l
- ld [CryPitch], a
- ld a, h
- ld [CryPitch + 1], a
- ld hl, CryLength
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld bc, $60
- add hl, bc
- ld a, l
- ld [CryLength], a
- ld a, h
- ld [CryLength + 1], a
- callba _PlayCryHeader
- call WaitSFX
-
-.done
- ret
-; fb877
-
-NewPokedexEntry: ; fb877
- ld a, [hMapAnims]
- push af
- xor a
- ld [hMapAnims], a
- call LowVolume
- call ClearBGPalettes
- call ClearTileMap
- call UpdateSprites
- call ClearSprites
- ld a, [wPokedexStatus]
- push af
- ld a, [hSCX]
- add $5
- ld [hSCX], a
- xor a
- ld [wPokedexStatus], a
- callba Function41a7f
- call WaitPressAorB_BlinkCursor
- ld a, $1
- ld [wPokedexStatus], a
- callba Function4424d
- call WaitPressAorB_BlinkCursor
- pop af
- ld [wPokedexStatus], a
- call MaxVolume
- call FadeToWhite
- ld a, [hSCX]
- add $fb
- ld [hSCX], a
- call Functionfb8c8
- pop af
- ld [hMapAnims], a
- ret
-; fb8c8
-
-Functionfb8c8: ; fb8c8
- call ClearTileMap
- call LoadFontsExtra
- call LoadStandardFont
- callba Function40ab2
- call Function3200
- callba GetEnemyMonDVs
- ld a, [hli]
- ld [TempMonDVs], a
- ld a, [hl]
- ld [TempMonDVs + 1], a
- ld b, SCGB_1C
- call GetSGBLayout
- call SetPalettes
- ret
-; fb8f1
-
-ConvertMon_2to1: ; fb8f1
-; Takes the Gen-2 Pokemon number stored in wd265, finds it in the Pokered_MonIndices table, and returns its index in wd265.
- push bc
- push hl
- ld a, [wd265]
- ld b, a
- ld c, 0
- ld hl, Pokered_MonIndices
-.loop
- inc c
- ld a, [hli]
- cp b
- jr nz, .loop
- ld a, c
- ld [wd265], a
- pop hl
- pop bc
- ret
-; fb908
-
-ConvertMon_1to2: ; fb908
-; Takes the Gen-1 Pokemon number stored in wd265 and returns the corresponding value from Pokered_MonIndices in wd265.
- push bc
- push hl
- ld a, [wd265]
- dec a
- ld hl, Pokered_MonIndices
- ld b, 0
- ld c, a
- add hl, bc
- ld a, [hl]
- ld [wd265], a
- pop hl
- pop bc
- ret
-; fb91c
-
-Pokered_MonIndices: ; fb91c
- db RHYDON
- db KANGASKHAN
- db NIDORAN_M
- db CLEFAIRY
- db SPEAROW
- db VOLTORB
- db NIDOKING
- db SLOWBRO
- db IVYSAUR
- db EXEGGUTOR
- db LICKITUNG
- db EXEGGCUTE
- db GRIMER
- db GENGAR
- db NIDORAN_F
- db NIDOQUEEN
- db CUBONE
- db RHYHORN
- db LAPRAS
- db ARCANINE
- db MEW
- db GYARADOS
- db SHELLDER
- db TENTACOOL
- db GASTLY
- db SCYTHER
- db STARYU
- db BLASTOISE
- db PINSIR
- db TANGELA
- db SCIZOR
- db SHUCKLE
- db GROWLITHE
- db ONIX
- db FEAROW
- db PIDGEY
- db SLOWPOKE
- db KADABRA
- db GRAVELER
- db CHANSEY
- db MACHOKE
- db MR__MIME
- db HITMONLEE
- db HITMONCHAN
- db ARBOK
- db PARASECT
- db PSYDUCK
- db DROWZEE
- db GOLEM
- db HERACROSS
- db MAGMAR
- db HO_OH
- db ELECTABUZZ
- db MAGNETON
- db KOFFING
- db SNEASEL
- db MANKEY
- db SEEL
- db DIGLETT
- db TAUROS
- db TEDDIURSA
- db URSARING
- db SLUGMA
- db FARFETCH_D
- db VENONAT
- db DRAGONITE
- db MAGCARGO
- db SWINUB
- db PILOSWINE
- db DODUO
- db POLIWAG
- db JYNX
- db MOLTRES
- db ARTICUNO
- db ZAPDOS
- db DITTO
- db MEOWTH
- db KRABBY
- db CORSOLA
- db REMORAID
- db OCTILLERY
- db VULPIX
- db NINETALES
- db PIKACHU
- db RAICHU
- db DELIBIRD
- db MANTINE
- db DRATINI
- db DRAGONAIR
- db KABUTO
- db KABUTOPS
- db HORSEA
- db SEADRA
- db SKARMORY
- db HOUNDOUR
- db SANDSHREW
- db SANDSLASH
- db OMANYTE
- db OMASTAR
- db JIGGLYPUFF
- db WIGGLYTUFF
- db EEVEE
- db FLAREON
- db JOLTEON
- db VAPOREON
- db MACHOP
- db ZUBAT
- db EKANS
- db PARAS
- db POLIWHIRL
- db POLIWRATH
- db WEEDLE
- db KAKUNA
- db BEEDRILL
- db HOUNDOOM
- db DODRIO
- db PRIMEAPE
- db DUGTRIO
- db VENOMOTH
- db DEWGONG
- db KINGDRA
- db PHANPY
- db CATERPIE
- db METAPOD
- db BUTTERFREE
- db MACHAMP
- db DONPHAN
- db GOLDUCK
- db HYPNO
- db GOLBAT
- db MEWTWO
- db SNORLAX
- db MAGIKARP
- db PORYGON2
- db STANTLER
- db MUK
- db SMEARGLE
- db KINGLER
- db CLOYSTER
- db TYROGUE
- db ELECTRODE
- db CLEFABLE
- db WEEZING
- db PERSIAN
- db MAROWAK
- db HITMONTOP
- db HAUNTER
- db ABRA
- db ALAKAZAM
- db PIDGEOTTO
- db PIDGEOT
- db STARMIE
- db BULBASAUR
- db VENUSAUR
- db TENTACRUEL
- db SMOOCHUM
- db GOLDEEN
- db SEAKING
- db ELEKID
- db MAGBY
- db MILTANK
- db BLISSEY
- db PONYTA
- db RAPIDASH
- db RATTATA
- db RATICATE
- db NIDORINO
- db NIDORINA
- db GEODUDE
- db PORYGON
- db AERODACTYL
- db RAIKOU
- db MAGNEMITE
- db ENTEI
- db SUICUNE
- db CHARMANDER
- db SQUIRTLE
- db CHARMELEON
- db WARTORTLE
- db CHARIZARD
- db LARVITAR
- db PUPITAR
- db TYRANITAR
- db LUGIA
- db ODDISH
- db GLOOM
- db VILEPLUME
- db BELLSPROUT
- db WEEPINBELL
- db VICTREEBEL
- db CHIKORITA
- db BAYLEEF
- db MEGANIUM
- db CYNDAQUIL
- db QUILAVA
- db TYPHLOSION
- db TOTODILE
- db CROCONAW
- db FERALIGATR
- db SENTRET
- db FURRET
- db HOOTHOOT
- db NOCTOWL
- db LEDYBA
- db LEDIAN
- db SPINARAK
- db ARIADOS
- db CROBAT
- db CHINCHOU
- db LANTURN
- db PICHU
- db CLEFFA
- db IGGLYBUFF
- db TOGEPI
- db TOGETIC
- db NATU
- db XATU
- db MAREEP
- db FLAAFFY
- db AMPHAROS
- db BELLOSSOM
- db MARILL
- db AZUMARILL
- db SUDOWOODO
- db POLITOED
- db HOPPIP
- db SKIPLOOM
- db JUMPLUFF
- db AIPOM
- db SUNKERN
- db SUNFLORA
- db YANMA
- db WOOPER
- db QUAGSIRE
- db ESPEON
- db UMBREON
- db MURKROW
- db SLOWKING
- db MISDREAVUS
- db UNOWN
- db WOBBUFFET
- db GIRAFARIG
- db PINECO
- db FORRETRESS
- db DUNSPARCE
- db GLIGAR
- db STEELIX
- db SNUBBULL
- db GRANBULL
- db QWILFISH
- db WOBBUFFET
- db WOBBUFFET
-; fba18
-
-
UpdateUnownDex: ; fba18
ld a, [UnownLetter]
ld c, a
@@ -34747,915 +25793,10 @@
INCLUDE "tilesets/animations.asm"
+INCLUDE "engine/npctrade.asm"
-; Trade struct
-TRADE_DIALOG EQU 0
-TRADE_GIVEMON EQU 1
-TRADE_GETMON EQU 2
-TRADE_NICK EQU 3
-TRADE_DVS EQU 14
-TRADE_ITEM EQU 16
-TRADE_OT_ID EQU 17
-TRADE_OT_NAME EQU 19
-TRADE_GENDER EQU 30
-TRADE_PADDING EQU 31
+INCLUDE "event/mom_phone.asm"
-; Trade dialogs
-TRADE_INTRO EQU 0
-TRADE_CANCEL EQU 1
-TRADE_WRONG EQU 2
-TRADE_COMPLETE EQU 3
-TRADE_AFTER EQU 4
-
-NPCTrade:: ; fcba8
- ld a, e
- ld [wJumptableIndex], a
- call Functionfcc59
- ld b, CHECK_FLAG
- call TradeFlagAction
- ld a, TRADE_AFTER
- jr nz, .done
-
- ld a, TRADE_INTRO
- call PrintTradeText
-
- call YesNoBox
- ld a, TRADE_CANCEL
- jr c, .done
-
-; Select givemon from party
- ld b, 6
- callba Function5001d
- ld a, TRADE_CANCEL
- jr c, .done
-
- ld e, TRADE_GIVEMON
- call GetTradeAttribute
- ld a, [CurPartySpecies]
- cp [hl]
- ld a, TRADE_WRONG
- jr nz, .done
-
- call CheckTradeGender
- ld a, TRADE_WRONG
- jr c, .done
-
- ld b, SET_FLAG
- call TradeFlagAction
-
- ld hl, ConnectLinkCableText
- call PrintText
-
- call Functionfcc63
- call Functionfcc07
- call GetTradeMonNames
-
- ld hl, TradedForText
- call PrintText
-
- call RestartMapMusic
-
- ld a, TRADE_COMPLETE
-
-.done
- call PrintTradeText
- ret
-; fcc07
-
-Functionfcc07: ; fcc07
- call DisableSpriteUpdates
- ld a, [wJumptableIndex]
- push af
- ld a, [wcf64]
- push af
- predef Function28f24
- pop af
- ld [wcf64], a
- pop af
- ld [wJumptableIndex], a
- call Function2b74
- ret
-; fcc23
-
-CheckTradeGender: ; fcc23
- xor a
- ld [MonType], a
-
- ld e, TRADE_GENDER
- call GetTradeAttribute
- ld a, [hl]
- and a
- jr z, .asm_fcc46
- cp 1
- jr z, .asm_fcc3e
-
- callba GetGender
- jr nz, .asm_fcc48
- jr .asm_fcc46
-
-.asm_fcc3e
- callba GetGender
- jr z, .asm_fcc48
-
-.asm_fcc46
- and a
- ret
-
-.asm_fcc48
- scf
- ret
-; fcc4a
-
-TradeFlagAction: ; fcc4a
- ld hl, wd960
- ld a, [wJumptableIndex]
- ld c, a
- predef FlagPredef
- ld a, c
- and a
- ret
-; fcc59
-
-Functionfcc59: ; fcc59
- ld e, TRADE_DIALOG
- call GetTradeAttribute
- ld a, [hl]
- ld [wcf64], a
- ret
-; fcc63
-
-Functionfcc63: ; fcc63
- ld e, TRADE_GIVEMON
- call GetTradeAttribute
- ld a, [hl]
- ld [wc6d0], a
-
- ld e, TRADE_GETMON
- call GetTradeAttribute
- ld a, [hl]
- ld [wc702], a
-
- ld a, [wc6d0]
- ld de, wc6d1
- call Functionfcde8
- call Functionfcdf4
-
- ld a, [wc702]
- ld de, wc703
- call Functionfcde8
- call Functionfcdf4
-
- ld hl, PartyMonOT
- ld bc, NAME_LENGTH
- call Functionfcdd7
- ld de, wc6f2
- call Functionfcdf4
-
- ld hl, PlayerName
- ld de, wc6e7
- call Functionfcdf4
-
- ld hl, PartyMon1ID
- ld bc, PARTYMON_STRUCT_LENGTH
- call Functionfcdd7
- ld de, wc6ff
- call Functionfce0f
-
- ld hl, PartyMon1DVs
- ld bc, PARTYMON_STRUCT_LENGTH
- call Functionfcdd7
- ld de, wc6fd
- call Functionfce0f
-
- ld hl, PartyMon1Species
- ld bc, PARTYMON_STRUCT_LENGTH
- call Functionfcdd7
- ld b, h
- ld c, l
- callba GetCaughtGender
- ld a, c
- ld [wc701], a
-
- ld e, TRADE_DIALOG
- call GetTradeAttribute
- ld a, [hl]
- cp TRADE_COMPLETE
- ld a, 1
- jr c, .asm_fcce6
- ld a, 2
-.asm_fcce6
- ld [wEnemyCharging], a
-
- ld hl, PartyMon1Level
- ld bc, PARTYMON_STRUCT_LENGTH
- call Functionfcdd7
- ld a, [hl]
- ld [CurPartyLevel], a
- ld a, [wc702]
- ld [CurPartySpecies], a
- xor a
- ld [MonType], a
- ld [wPokemonWithdrawDepositParameter], a
- callab Functione039
- predef TryAddMonToParty
-
- ld e, TRADE_DIALOG
- call GetTradeAttribute
- ld a, [hl]
- cp TRADE_COMPLETE
- ld b, 0
- jr c, .asm_fcd1c
- ld b, 1
-.asm_fcd1c
- callba SetGiftPartyMonCaughtData
-
- ld e, TRADE_NICK
- call GetTradeAttribute
- ld de, wc70e
- call Functionfcdf4
-
- ld hl, PartyMonNicknames
- ld bc, PKMN_NAME_LENGTH
- call Functionfcdde
- ld hl, wc70e
- call Functionfcdf4
-
- ld e, TRADE_OT_NAME
- call GetTradeAttribute
- push hl
- ld de, wc724
- call Functionfcdf4
- pop hl
- ld de, wc719
- call Functionfcdf4
-
- ld hl, PartyMonOT
- ld bc, NAME_LENGTH
- call Functionfcdde
- ld hl, wc724
- call Functionfcdf4
-
- ld e, TRADE_DVS
- call GetTradeAttribute
- ld de, wEnemyTrappingMove
- call Functionfce0f
-
- ld hl, PartyMon1DVs
- ld bc, PARTYMON_STRUCT_LENGTH
- call Functionfcdde
- ld hl, wEnemyTrappingMove
- call Functionfce0f
-
- ld e, TRADE_OT_ID
- call GetTradeAttribute
- ld de, wPlayerCharging
- call Functionfce15
-
- ld hl, PartyMon1ID
- ld bc, PARTYMON_STRUCT_LENGTH
- call Functionfcdde
- ld hl, wEnemyWrapCount
- call Functionfce0f
-
- ld e, TRADE_ITEM
- call GetTradeAttribute
- push hl
- ld hl, PartyMon1Item
- ld bc, PARTYMON_STRUCT_LENGTH
- call Functionfcdde
- pop hl
- ld a, [hl]
- ld [de], a
-
- push af
- push bc
- push de
- push hl
- ld a, [CurPartyMon]
- push af
- ld a, [PartyCount]
- dec a
- ld [CurPartyMon], a
- callba Functione134
- pop af
- ld [CurPartyMon], a
- pop hl
- pop de
- pop bc
- pop af
- ret
-; fcdc2
-
-
-GetTradeAttribute: ; 0xfcdc2
- ld d, 0
- push de
- ld a, [wJumptableIndex]
- and $f
- swap a
- ld e, a
- ld d, 0
- ld hl, NPCTrades
-rept 2
- add hl, de
-endr
- pop de
- add hl, de
- ret
-; 0xfcdd7
-
-Functionfcdd7: ; fcdd7
- ld a, [CurPartyMon]
- call AddNTimes
- ret
-; fcdde
-
-Functionfcdde: ; fcdde
- ld a, [PartyCount]
- dec a
- call AddNTimes
- ld e, l
- ld d, h
- ret
-; fcde8
-
-Functionfcde8: ; fcde8
- push de
- ld [wd265], a
- call GetBasePokemonName
- ld hl, StringBuffer1
- pop de
- ret
-; fcdf4
-
-Functionfcdf4: ; fcdf4
- ld bc, NAME_LENGTH
- call CopyBytes
- ret
-; fcdfb
-
-Functionfcdfb: ; fcdfb
- ld bc, 4
- call CopyBytes
- ld a, $50
- ld [de], a
- ret
-; fce05
-
-Functionfce05: ; fce05
- ld bc, 3
- call CopyBytes
- ld a, $50
- ld [de], a
- ret
-; fce0f
-
-Functionfce0f: ; fce0f
- ld a, [hli]
- ld [de], a
- inc de
- ld a, [hl]
- ld [de], a
- ret
-; fce15
-
-Functionfce15: ; fce15
- ld a, [hli]
- ld [de], a
- dec de
- ld a, [hl]
- ld [de], a
- ret
-; fce1b
-
-GetTradeMonNames: ; fce1b
- ld e, TRADE_GETMON
- call GetTradeAttribute
- ld a, [hl]
- call Functionfcde8
-
- ld de, StringBuffer2
- call Functionfcdf4
-
- ld e, TRADE_GIVEMON
- call GetTradeAttribute
- ld a, [hl]
- call Functionfcde8
-
- ld de, wd050
- call Functionfcdf4
-
- ld hl, StringBuffer1
-.loop
- ld a, [hli]
- cp "@"
- jr nz, .loop
-
- dec hl
- push hl
- ld e, TRADE_GENDER
- call GetTradeAttribute
- ld a, [hl]
- pop hl
- and a
- ret z
-
- cp 1
- ld a, "♂"
- jr z, .done
- ld a, "♀"
-.done
- ld [hli], a
- ld [hl], "@"
- ret
-; fce58
-
-
-NPCTrades: ; fce58
- db 0, ABRA, MACHOP, "MUSCLE@@@@@", $37, $66, GOLD_BERRY, $54, $92, "MIKE@@@@@@@", 0, 0
- db 0, BELLSPROUT, ONIX, "ROCKY@@@@@@", $96, $66, BITTER_BERRY, $1e, $bf, "KYLE@@@@@@@", 0, 0
- db 1, KRABBY, VOLTORB, "VOLTY@@@@@@", $98, $88, PRZCUREBERRY, $05, $72, "TIM@@@@@@@@", 0, 0
- db 3, DRAGONAIR, DODRIO, "DORIS@@@@@@", $77, $66, SMOKE_BALL, $1b, $01, "EMY@@@@@@@@", 2, 0
- db 2, HAUNTER, XATU, "PAUL@@@@@@@", $96, $86, MYSTERYBERRY, $00, $3d, "CHRIS@@@@@@", 0, 0
- db 3, CHANSEY, AERODACTYL, "AEROY@@@@@@", $96, $66, GOLD_BERRY, $7b, $67, "KIM@@@@@@@@", 0, 0
- db 0, DUGTRIO, MAGNETON, "MAGGIE@@@@@", $96, $66, METAL_COAT, $a2, $c3, "FOREST@@@@@", 0, 0
-; fcf38
-
-
-PrintTradeText: ; fcf38
- push af
- call GetTradeMonNames
- pop af
- ld bc, 2 * 4
- ld hl, TradeTexts
- call AddNTimes
- ld a, [wcf64]
- ld c, a
-rept 2
- add hl, bc
-endr
- ld a, [hli]
- ld h, [hl]
- ld l, a
- call PrintText
- ret
-; fcf53
-
-TradeTexts: ; fcf53
-; intro
- dw TradeIntroText1
- dw TradeIntroText2
- dw TradeIntroText3
- dw TradeIntroText4
-
-; cancel
- dw TradeCancelText1
- dw TradeCancelText2
- dw TradeCancelText3
- dw TradeCancelText4
-
-; wrong mon
- dw TradeWrongText1
- dw TradeWrongText2
- dw TradeWrongText3
- dw TradeWrongText4
-
-; completed
- dw TradeCompleteText1
- dw TradeCompleteText2
- dw TradeCompleteText3
- dw TradeCompleteText4
-
-; after
- dw TradeAfterText1
- dw TradeAfterText2
- dw TradeAfterText3
- dw TradeAfterText4
-; fcf7b
-
-
-ConnectLinkCableText: ; 0xfcf7b
- ; OK, connect the Game Link Cable.
- text_jump UnknownText_0x1bd407
- db "@"
-; 0xfcf80
-
-
-TradedForText: ; 0xfcf80
- ; traded givemon for getmon
- text_jump UnknownText_0x1bd429
- start_asm
-
- ld de, MUSIC_NONE
- call PlayMusic
- call DelayFrame
- ld hl, .done
- ret
-
-.done
- ; sound0x0A
- ; interpret_data
- text_jump UnknownText_0x1bd445
- db "@"
-; 0xfcf97
-
-
-TradeIntroText1: ; 0xfcf97
- ; I collect #MON. Do you have @ ? Want to trade it for my @ ?
- text_jump UnknownText_0x1bd449
- db "@"
-; 0xfcf9c
-
-TradeCancelText1: ; 0xfcf9c
- ; You don't want to trade? Aww…
- text_jump UnknownText_0x1bd48c
- db "@"
-; 0xfcfa1
-
-TradeWrongText1: ; 0xfcfa1
- ; Huh? That's not @ . What a letdown…
- text_jump UnknownText_0x1bd4aa
- db "@"
-; 0xfcfa6
-
-TradeCompleteText1: ; 0xfcfa6
- ; Yay! I got myself @ ! Thanks!
- text_jump UnknownText_0x1bd4d2
- db "@"
-; 0xfcfab
-
-TradeAfterText1: ; 0xfcfab
- ; Hi, how's my old @ doing?
- text_jump UnknownText_0x1bd4f4
- db "@"
-; 0xfcfb0
-
-
-TradeIntroText2:
-TradeIntroText3: ; 0xfcfb0
- ; Hi, I'm looking for this #MON. If you have @ , would you trade it for my @ ?
- text_jump UnknownText_0x1bd512
- db "@"
-; 0xfcfb5
-
-TradeCancelText2:
-TradeCancelText3: ; 0xfcfb5
- ; You don't have one either? Gee, that's really disappointing…
- text_jump UnknownText_0x1bd565
- db "@"
-; 0xfcfba
-
-TradeWrongText2:
-TradeWrongText3: ; 0xfcfba
- ; You don't have @ ? That's too bad, then.
- text_jump UnknownText_0x1bd5a1
- db "@"
-; 0xfcfbf
-
-TradeCompleteText2: ; 0xfcfbf
- ; Great! Thank you! I finally got @ .
- text_jump UnknownText_0x1bd5cc
- db "@"
-; 0xfcfc4
-
-TradeAfterText2: ; 0xfcfc4
- ; Hi! The @ you traded me is doing great!
- text_jump UnknownText_0x1bd5f4
- db "@"
-; 0xfcfc9
-
-
-TradeIntroText4: ; 0xfcfc9
- ; 's cute, but I don't have it. Do you have @ ? Want to trade it for my @ ?
- text_jump UnknownText_0x1bd621
- db "@"
-; 0xfcfce
-
-TradeCancelText4: ; 0xfcfce
- ; You don't want to trade? Oh, darn…
- text_jump UnknownText_0x1bd673
- db "@"
-; 0xfcfd3
-
-TradeWrongText4: ; 0xfcfd3
- ; That's not @ . Please trade with me if you get one.
- text_jump UnknownText_0x1bd696
- db "@"
-; 0xfcfd8
-
-TradeCompleteText4: ; 0xfcfd8
- ; Wow! Thank you! I always wanted @ !
- text_jump UnknownText_0x1bd6cd
- db "@"
-; 0xfcfdd
-
-TradeAfterText4: ; 0xfcfdd
- ; How is that @ I traded you doing? Your @ 's so cute!
- text_jump UnknownText_0x1bd6f5
- db "@"
-; 0xfcfe2
-
-
-TradeCompleteText3: ; 0xfcfe2
- ; Uh? What happened?
- text_jump UnknownText_0x1bd731
- db "@"
-; 0xfcfe7
-
-TradeAfterText3: ; 0xfcfe7
- ; Trading is so odd… I still have a lot to learn about it.
- text_jump UnknownText_0x1bd745
- db "@"
-; 0xfcfec
-
-
-MomTriesToBuySomething:: ; fcfec
- ld a, [wMapReentryScriptQueueFlag]
- and a
- ret nz
- call GetMapHeaderPhoneServiceNybble
- and a
- ret nz
- xor a
- ld [wdc18], a
- call CheckBalance_MomItem2
- ret nc
- call Functionfd0c3
- ret nc
- ld b, BANK(UnknownScript_0xfd00f)
- ld de, UnknownScript_0xfd00f
- callba LoadScriptBDE
- scf
- ret
-; fd00f
-
-UnknownScript_0xfd00f: ; 0xfd00f
- callasm Functionfd017
- farjump Script_ReceivePhoneCall
-; 0xfd017
-
-Functionfd017: ; fd017
- call MomBuysItem_DeductFunds
- call Functionfd0eb
- ld a, [wdc18]
- and a
- jr nz, .ok
- ld hl, wdc17
- inc [hl]
-.ok
- ld a, 1
- ld [wCurrentCaller], a
- ld bc, wd03f
- ld hl, 0
- add hl, bc
- ld [hl], 0
- inc hl
- ld [hl], 1
- ld hl, 9
- add hl, bc
- ld a, $3f
- ld [hli], a
- ld a, e
- ld [hli], a
- ld a, d
- ld [hl], a
- ret
-; fd044
-
-CheckBalance_MomItem2: ; fd044
- ld a, [wdc17]
- cp 10
- jr nc, .nope
- call GetItemFromMom
- ld a, [hli]
- ld [hMoneyTemp], a
- ld a, [hli]
- ld [hMoneyTemp + 1], a
- ld a, [hli]
- ld [hMoneyTemp + 2], a
- ld de, wMomsMoney
- ld bc, hMoneyTemp
- callba CompareMoney
- jr nc, .have_enough_money
-
-.nope
- jr .check_have_2300
-
-.have_enough_money
- scf
- ret
-
-.check_have_2300
- ld hl, hMoneyTemp
- ld [hl], (2300 / $10000) ; $00
- inc hl
- ld [hl], ((2300 % $10000) / $100) ; $08
- inc hl
- ld [hl], (2300 % $100) ; $fc
-.loop
- ld de, wdc19
- ld bc, wMomsMoney
- callba CompareMoney
- jr z, .exact
- jr nc, .less_than
- call Functionfd099
- jr .loop
-
-.less_than
- xor a
- ret
-
-.exact
- call Functionfd099
- ld a, 5
- call RandomRange
- inc a
- ld [wdc18], a
- scf
- ret
-; fd099
-
-Functionfd099: ; fd099
- ld de, wdc19
- ld bc, hMoneyTemp
- callba AddMoney
- ret
-; fd0a6
-
-
-MomBuysItem_DeductFunds: ; fd0a6 (3f:50a6)
- call GetItemFromMom
- ld de, 3
- add hl, de
- ld a, [hli]
- ld [hMoneyTemp], a
- ld a, [hli]
- ld [hMoneyTemp + 1], a
- ld a, [hli]
- ld [hMoneyTemp + 2], a
- ld de, wMomsMoney
- ld bc, hMoneyTemp
- callba TakeMoney
- ret
-
-
-Functionfd0c3: ; fd0c3
- call GetItemFromMom
- ld de, 6
- add hl, de
- ld a, [hli]
- cp 1
- jr z, .not_doll
- ld a, [hl]
- ld c, a
- ld b, 1
- callba DecorationFlagAction_c
- scf
- ret
-
-.not_doll
- ld a, [hl]
- ld [CurItem], a
- ld a, $1
- ld [wItemQuantityChangeBuffer], a
- ld hl, PCItems
- call ReceiveItem
- ret
-; fd0eb
-
-
-Functionfd0eb: ; fd0eb (3f:50eb)
- call GetItemFromMom
- ld de, 6 ; field
- add hl, de
- ld a, [hli]
- ld de, Script_MomBoughtItem
- cp 1
- ret z
- ld de, Script_MomBoughtDoll
- ret
-; fd0fd (3f:50fd)
-
-Script_MomBoughtItem: ; 0xfd0fd
- writetext _MomText_HiHowAreYou
- writetext _MomText_FoundAnItem
- writetext _MomText_BoughtWithYourMoney
- writetext _MomText_ItsInPC
- end
-; 0xfd10a
-
-Script_MomBoughtDoll: ; 0xfd10a
- writetext _MomText_HiHowAreYou
- writetext _MomText_FoundADoll
- writetext _MomText_BoughtWithYourMoney
- writetext _MomText_ItsInRoom
- end
-; 0xfd117
-
-
-GetItemFromMom: ; fd117
- ld a, [wdc18]
- and a
- jr z, .zero
- dec a
- ld de, MomItems_1
- jr .incave
-
-.zero
- ld a, [wdc17]
- cp 10 ; length of MomItems_2
- jr c, .ok
- xor a
-
-.ok
- ld de, MomItems_2
-
-.incave
- ld l, a
- ld h, 0
-rept 3 ; multiply hl by 8
- add hl, hl
-endr
- add hl, de
- ret
-; fd136
-
-momitem: macro
-; money to trigger, cost, kind, item
- dt \1
- dt \2
- db \3, \4
-ENDM
-
-
-MomItems_1: ; fd136
- momitem 0, 600, MOM_ITEM, SUPER_POTION
- momitem 0, 90, MOM_ITEM, ANTIDOTE
- momitem 0, 180, MOM_ITEM, POKE_BALL
- momitem 0, 450, MOM_ITEM, ESCAPE_ROPE
- momitem 0, 500, MOM_ITEM, GREAT_BALL
-; fd15e
-
-MomItems_2: ; fd15e
- momitem 900, 600, MOM_ITEM, SUPER_POTION
- momitem 4000, 270, MOM_ITEM, REPEL
- momitem 7000, 600, MOM_ITEM, SUPER_POTION
- momitem 10000, 1800, MOM_DOLL, DECO_CHARMANDER_DOLL
- momitem 15000, 3000, MOM_ITEM, MOON_STONE
- momitem 19000, 600, MOM_ITEM, SUPER_POTION
- momitem 30000, 4800, MOM_DOLL, DECO_CLEFAIRY_DOLL
- momitem 40000, 900, MOM_ITEM, HYPER_POTION
- momitem 50000, 8000, MOM_DOLL, DECO_PIKACHU_DOLL
- momitem 100000, 22800, MOM_DOLL, DECO_BIG_SNORLAX_DOLL
-; fd1ae
-
- db 0, 0, 0 ; XXX
-
-_MomText_HiHowAreYou: ; 0xfd1b1
- ; Hi, ! How are you?
- text_jump UnknownText_0x1bc615
- db "@"
-; 0xfd1b6
-
-_MomText_FoundAnItem: ; 0xfd1b6
- ; I found a useful item shopping, so
- text_jump UnknownText_0x1bc62a
- db "@"
-; 0xfd1bb
-
-_MomText_BoughtWithYourMoney: ; 0xfd1bb
- ; I bought it with your money. Sorry!
- text_jump UnknownText_0x1bc64e
- db "@"
-; 0xfd1c0
-
-_MomText_ItsInPC: ; 0xfd1c0
- ; It's in your PC. You'll like it!
- text_jump UnknownText_0x1bc673
- db "@"
-; 0xfd1c5
-
-_MomText_FoundADoll: ; 0xfd1c5
- ; While shopping today, I saw this adorable doll, so
- text_jump UnknownText_0x1bc693
- db "@"
-; 0xfd1ca
-
-_MomText_ItsInRoom: ; 0xfd1ca
- ; It's in your room. You'll love it!
- text_jump UnknownText_0x1bc6c7
- db "@"
-; 0xfd1cf
-
- db 0 ; XXX
-
-Functionfd1d0: ; fd1d0
- ret
-; fd1d1
-
- ret ; XXX
-
-
INCLUDE "misc/mobile_40.asm"
@@ -35716,7 +25857,7 @@
ret
; 104061
-Function104061:: ; 104061
+ReloadMapPart:: ; 104061
ld hl, Function104067
jp Function104177
; 104067
@@ -35746,7 +25887,7 @@
ret
Function104099: ; 104099
- ld hl, Function104061
+ ld hl, ReloadMapPart ; useless
ld hl, Function1040a2
jp Function104177
; 1040a2
@@ -36585,7 +26726,7 @@
RefreshMapSprites: ; 1047f0
call ClearSprites
callba ReturnFromMapSetupScript
- call Function2914
+ call GetMovementPermissions
callba Function579d
callba CheckReplaceKrisSprite
ld hl, wPlayerSpriteSetupFlags
--- a/misc/battle_tower_47.asm
+++ b/misc/battle_tower_47.asm
@@ -385,7 +385,7 @@
ld de, VTiles0
call Decompress
call EnableLCD
- callba Function104061
+ callba ReloadMapPart
callba Function8cf53
callba LoadPokemonData
callba Function40c30
@@ -443,7 +443,7 @@
jr nz, .asm_11c2a2
call Function11c2ac
callba Function8cf69
- callba Function104061
+ callba ReloadMapPart
jr .asm_11c283
.asm_11c2a2
@@ -782,7 +782,7 @@
hlcoord 0, 14, AttrMap
ld bc, $28
call ByteFill
- callba Function104061
+ callba ReloadMapPart
ret
; 11c4db (47:44db)
@@ -978,7 +978,7 @@
hlcoord 0, 6, AttrMap
ld bc, $c8
call ByteFill
- callba Function104061
+ callba ReloadMapPart
ret
; 11c62a (47:462a)
@@ -1585,7 +1585,7 @@
hlcoord 0, 6, AttrMap
ld bc, $c8
call ByteFill
- callba Function104061
+ callba ReloadMapPart
ret
Function11c9bd: ; 11c9bd (47:49bd)
@@ -1672,7 +1672,7 @@
add hl, de
dec c
jr nz, .asm_11ca22
- callba Function104061
+ callba ReloadMapPart
ret
; 11ca38 (47:4a38)
@@ -2089,7 +2089,7 @@
hlcoord 0, 12, AttrMap
ld bc, $50
call ByteFill
- callba Function104061
+ callba ReloadMapPart
ret
; 11cdc7 (47:4dc7)
--- a/misc/crystal_misc.asm
+++ b/misc/crystal_misc.asm
@@ -173,7 +173,7 @@
ret
.asm_17a79f
- callba Function104061
+ callba ReloadMapPart
ret
; 17a7a6 (5e:67a6)
--- a/misc/mobile_22.asm
+++ b/misc/mobile_22.asm
@@ -93,7 +93,7 @@
Function891ab: ; 891ab
call Function89240
- callba Function104061
+ callba ReloadMapPart
call Function8923c
ret
; 891b8
--- a/misc/mobile_40.asm
+++ b/misc/mobile_40.asm
@@ -1495,7 +1495,7 @@
call PrintNum
ld de, SFX_TWO_PC_BEEPS
call PlaySFX
- callba Function104061
+ callba ReloadMapPart
ld c, $3c
call DelayFrames
ret
@@ -1506,7 +1506,7 @@
call PlaceString
ld de, SFX_4_NOTE_DITTY
call PlaySFX
- callba Function104061
+ callba ReloadMapPart
ld c, 120
call DelayFrames
ret
@@ -1536,7 +1536,7 @@
decoord 0, 0
call Function1009a5
call Function1009ae
- callba Function104061
+ callba ReloadMapPart
ld hl, w3_dd68
decoord 0, 0, AttrMap
call Function1009a5
--- a/misc/mobile_45.asm
+++ b/misc/mobile_45.asm
@@ -5750,7 +5750,7 @@
pop af
ld [rSVBK], a
- callba Function104061
+ callba ReloadMapPart
ld a, $8
ld [MusicFade], a
ld de, MUSIC_MOBILE_ADAPTER
@@ -5931,7 +5931,7 @@
call UpdateSprites
pop af
ld [rSVBK], a
- callba Function104061
+ callba ReloadMapPart
ld a, $8
ld [MusicFade], a
ld a, [wc2c0]
@@ -5975,7 +5975,7 @@
callba Function14157
pop af
ld [rSVBK], a
- callba Function104061
+ callba ReloadMapPart
ld a, [wLinkMode]
cp $4
jr z, .asm_11642a
@@ -6006,7 +6006,7 @@
callba Function17d405
ld a, $90
ld [hWY], a
- callba Function104061
+ callba ReloadMapPart
ld a, $8
ld [MusicFade], a
ld a, [wc2c0]
@@ -7711,7 +7711,7 @@
call ClearBGPalettes
call ClearSprites
callba Function171c87
- callba Function104061
+ callba ReloadMapPart
callba Function8cf53
ret
@@ -7722,7 +7722,7 @@
jr nz, .asm_117709
call Function117719
callba Function8cf69
- callba Function104061
+ callba ReloadMapPart
jr Function1176ee
.asm_117709
callba Function8cf53
@@ -7978,7 +7978,7 @@
call LoadMenuDataHeader
call MenuBox
call MenuBoxCoord2Tile
- callba Function104061
+ callba ReloadMapPart
hlcoord 16, 8
ld de, String_1179c5
call PlaceString
@@ -8077,7 +8077,7 @@
call LoadMenuDataHeader
call MenuBox
call MenuBoxCoord2Tile
- callba Function104061
+ callba ReloadMapPart
hlcoord 1, 14
ld de, String_1179e1
call PlaceString
@@ -8184,7 +8184,7 @@
call ClearSprites
callba Function172e78
callba Function172eb9
- callba Function104061
+ callba ReloadMapPart
ret
; 0x117acd
@@ -8299,12 +8299,12 @@
jr nz, .asm_117ba4 ; 0x117b93 $f
call ExitMenu
call ExitMenu
- callba Function104061
+ callba ReloadMapPart
jp Function117cdd
.asm_117ba4
call ExitMenu
call ExitMenu
- callba Function104061
+ callba ReloadMapPart
ld a, $80
ld [wJumptableIndex], a
ret
@@ -8387,7 +8387,7 @@
call LoadMenuDataHeader
call MenuBox
call MenuBoxCoord2Tile
- callba Function104061
+ callba ReloadMapPart
ld hl, MobileStadiumSuccessText
call PrintText
ld a, [rSVBK]
--- a/misc/mobile_46.asm
+++ b/misc/mobile_46.asm
@@ -4463,7 +4463,7 @@
and a
jr z, .asm_119fd4
call ExitMenu
- callba Function104061
+ callba ReloadMapPart
callba Function115dc3
ld a, [wcd33]
ld [wcf66], a
@@ -4480,7 +4480,7 @@
ld [wc30d], a
ld a, $1
ld [wc314], a
- callba Function104061
+ callba ReloadMapPart
and a
ret
@@ -4487,7 +4487,7 @@
.asm_119fef
call ExitMenu
call ExitMenu
- callba Function104061
+ callba ReloadMapPart
ld a, [wcd45]
ld [wcf66], a
callba Function115dc3
@@ -4562,7 +4562,7 @@
callba Function106462
callba Function106464
call ExitMenu
- callba Function104061
+ callba ReloadMapPart
callba Function115d99
ld c, $0
callba Function115e18
@@ -4585,7 +4585,7 @@
callba Function106462
callba Function106464
call ExitMenu
- callba Function104061
+ callba ReloadMapPart
callba Function115d99
ld c, $0
callba Function115e18
@@ -4677,7 +4677,7 @@
and a
jr nz, .asm_11a1b6
call ExitMenu
- callba Function104061
+ callba ReloadMapPart
call Function11a63c
hlcoord 4, 2
ld de, String_11a6d2
@@ -4687,7 +4687,7 @@
.asm_11a1b6
call ExitMenu
- callba Function104061
+ callba ReloadMapPart
ld a, [wcd45]
ld [wcf66], a
ld [wcd80], a
@@ -4818,7 +4818,7 @@
and a
jr nz, .asm_11a2c4
call ExitMenu
- callba Function104061
+ callba ReloadMapPart
ld a, [wcd46]
cp $0
jr z, .asm_11a2b4
@@ -4840,7 +4840,7 @@
.asm_11a2c4
call ExitMenu
- callba Function104061
+ callba ReloadMapPart
and a
ret
; 11a2cf
@@ -4919,7 +4919,7 @@
.asm_11a346
call ExitMenu
- callba Function104061
+ callba ReloadMapPart
callba Function115dc3
and a
ret
@@ -4963,7 +4963,7 @@
and a
jr nz, .asm_11a3b1
call ExitMenu
- callba Function104061
+ callba ReloadMapPart
call Function11a63c
hlcoord 4, 2
ld de, String_11a6d2
@@ -4973,7 +4973,7 @@
.asm_11a3b1
call ExitMenu
- callba Function104061
+ callba ReloadMapPart
ld a, [wcd45]
ld [wcf66], a
ld [wcd80], a
@@ -5038,7 +5038,7 @@
and a
jr nz, .asm_11a43f
call ExitMenu
- callba Function104061
+ callba ReloadMapPart
call Function11a63c
hlcoord 4, 2
ld de, String_11a6d2
@@ -5048,7 +5048,7 @@
.asm_11a43f
call ExitMenu
- callba Function104061
+ callba ReloadMapPart
ld a, $1c
ld [wcf66], a
ld [wcd80], a
@@ -5109,7 +5109,7 @@
and a
jr nz, .asm_11a4c7
call ExitMenu
- callba Function104061
+ callba ReloadMapPart
call Function11a63c
hlcoord 4, 2
ld de, String_11a6d2
@@ -5121,7 +5121,7 @@
.asm_11a4c7
call ExitMenu
- callba Function104061
+ callba ReloadMapPart
ld a, [wcd46]
ld [wcf66], a
ld [wcd80], a
@@ -5156,7 +5156,7 @@
and a
jr nz, .asm_11a522
call ExitMenu
- callba Function104061
+ callba ReloadMapPart
call Function11a63c
hlcoord 4, 2
ld de, String_11a6d2
@@ -5166,7 +5166,7 @@
.asm_11a522
call ExitMenu
- callba Function104061
+ callba ReloadMapPart
ld a, [wcd45]
ld [wcf66], a
ld [wcd80], a
@@ -5195,7 +5195,7 @@
call Function11a9f0
jr nz, .asm_11a562
call ExitMenu
- callba Function104061
+ callba ReloadMapPart
.asm_11a562
scf
@@ -5271,7 +5271,7 @@
ld b, $4
ld c, $12
call Function3eea
- callba Function104061
+ callba ReloadMapPart
call UpdateSprites
ld c, $0
callba Function115e18
@@ -5306,7 +5306,7 @@
hlcoord 15, 7
ld a, $ed
ld [hl], a
- callba Function104061
+ callba ReloadMapPart
ret
; 11a63c
@@ -5840,7 +5840,7 @@
Function11ac3e: ; 11ac3e
call SpeechTextBox
call FadeToMenu
- callab InefficientlyClear121BytesAtwc300
+ callab ClearSpriteAnims
call Function11ac51
call ReturnToCallingMenu
ret
@@ -5881,7 +5881,7 @@
ld a, $78
ld [wc3b5], a
callba Function8cf7a
- callba Function104061
+ callba ReloadMapPart
jr .asm_11ac82
.asm_11aca8
@@ -6025,7 +6025,7 @@
hlcoord 10, 10, AttrMap
ld bc, $0808
call Function11afd6
- callba Function104061
+ callba ReloadMapPart
call Function11ad8a
ld a, $1
ld [MenuSelection2], a
@@ -6104,7 +6104,7 @@
.asm_11ae2e
call ExitMenu
- callba Function104061
+ callba ReloadMapPart
ret
; 11ae38
@@ -6142,7 +6142,7 @@
hlcoord 9, 12, AttrMap
lb bc, 6, 11
call Function11afd6
- callba Function104061
+ callba ReloadMapPart
call Function11ad8a
ld a, $1
ld [MenuSelection2], a
@@ -6210,7 +6210,7 @@
.asm_11aef7
call ExitMenu
call ExitMenu
- callba Function104061
+ callba ReloadMapPart
ret
; 11af04
@@ -6233,7 +6233,7 @@
hlcoord 9, 12, AttrMap
lb bc, 6, 11
call Function11afd6
- callba Function104061
+ callba ReloadMapPart
call Function11ad8a
ld a, $2
ld [MenuSelection2], a
@@ -6301,7 +6301,7 @@
.asm_11afaa
call ExitMenu
call ExitMenu
- callba Function104061
+ callba ReloadMapPart
ret
; 11afb7
--- a/misc/mobile_5c.asm
+++ b/misc/mobile_5c.asm
@@ -391,7 +391,7 @@
bit 7, a
jr nz, .asm_17050f
call Function170510
- callba Function104061
+ callba ReloadMapPart
jr .asm_1704fa
.asm_17050f
@@ -1692,7 +1692,7 @@
call ClearBGPalettes
call ClearSprites
callba Function171d2b
- callba Function104061
+ callba ReloadMapPart
callba Function8cf53
ret
@@ -1703,7 +1703,7 @@
jr nz, .asm_171a2c
call Function171a36
callba Function8cf69
- callba Function104061
+ callba ReloadMapPart
jr Function171a11
.asm_171a2c
callba Function8cf53
@@ -1960,7 +1960,7 @@
call LoadMenuDataHeader
call MenuBox
call MenuBoxCoord2Tile
- callba Function104061
+ callba ReloadMapPart
hlcoord 1, 14
ld de, String_171c73
call PlaceString
--- a/misc/mobile_5f.asm
+++ b/misc/mobile_5f.asm
@@ -81,7 +81,7 @@
ld [rVBK], a
call EnableLCD
- callba Function104061
+ callba ReloadMapPart
ret
; 17c083
@@ -629,7 +629,7 @@
call ClearBGPalettes
call ClearSprites
call ClearScreen
- callba Function104061
+ callba ReloadMapPart
call DisableLCD
ld hl, VTiles1 tile $6e
ld de, $c608
@@ -675,7 +675,7 @@
call ClearBGPalettes
call ClearSprites
call ClearScreen
- callba Function104061
+ callba ReloadMapPart
Function17d405:
call DisableLCD
@@ -721,7 +721,7 @@
bit 7, a
jr nz, .asm_17d46f
call Function17d474
- callba Function104061
+ callba ReloadMapPart
jr .asm_17d45a
.asm_17d46f
@@ -935,7 +935,7 @@
call Function17e451
call Function17e55b
call Function17e5af
- callba Function104061
+ callba ReloadMapPart
jp Function17e438
; 17d5be
--- a/wram.asm
+++ b/wram.asm
@@ -372,8 +372,8 @@
SECTION "c300", WRAM0 [$c300]
; wc300 - wc313 is a 10x2 dictionary.
-wDict_c300:: ds 10 * 2
- ds wDict_c300 - @
+wSpriteAnimDict:: ds 10 * 2
+ ds wSpriteAnimDict - @
wc300:: ds 1
wc301:: ds 1
wc302:: ds 1
@@ -456,7 +456,7 @@
wc3be:: ds 1
wc3bf:: ds 1
wc3c0:: ds 1
-; wc300_data_end
+wSpriteAnimsEnd::
wc3c1:: ds 11
wc3cc:: ds 1