Decompiled the rest of bank 23

This commit is contained in:
DrippingYellow 2025-10-22 21:41:35 -05:00
parent 9743fff41b
commit c13ff726a7
13 changed files with 504 additions and 64 deletions

View File

@ -91,8 +91,8 @@ GiveItemPredef::
add_predef LoadSGBLayout
add_predef Pokedex_GetArea
add_predef DoBattleTransition
add_predef Function8c9c6
add_predef Function8c940 ; 50
add_predef LeaveMapAnim_Old
add_predef EnterMapAnim_Old ; 50
add_predef PlayBattleAnim
add_predef Functioncc000
add_predef Functioncc000_2

View File

@ -735,7 +735,7 @@ LoadTrainerHudOAM:
LoadBallIconGFX:
ld de, PokeBallsGFX
ld hl, vChars0 + 49 tiles
ld hl, vChars0 tile $31
lb bc, 14, 4
jp Request2bpp
@ -1452,7 +1452,6 @@ AI_Smart_Substitute:
call AICheckEnemyHalfHP
jr nc, .discourage
; BUG: Should be "ret nz" in order to discourage if the enemy already has substitute.
ld a, [wEnemySubStatus4]
bit SUBSTATUS_SUBSTITUTE, a
ret z

View File

@ -61,7 +61,7 @@ RestoreOverworldMapTiles::
call CloseSRAM
call UpdateSprites
call WaitBGMap
ld a, 144
ld a, SCREEN_HEIGHT_PX
ldh [hWY], a
call DelayFrame
@ -71,3 +71,487 @@ RestoreOverworldMapTiles::
ld b, SGB_MAP_PALS
call GetSGBLayout
ret
SECTION "engine/dumps/bank23.asm@EnterMapAnim_Old", ROMX
; A bunch of old animation functions from Generation I.
; Basically non-functional because RAM has moved around so much since then.
; Certain lines of code were removed here, presumably so that it would actually compile.
; TODO: Make this less messy by including old variables in wram.asm.
; Shouldn't be too much of a priority since it's... you know, not used. Or functional.
EnterMapAnim_Old::
call InitFacingDirectionList_Old
ld a, $ec
ld [wReservedObjectFlags], a ; wSpritePlayerStateData1YPixels in pokered
call WaitBGMap
push hl
call GBFadeInFromWhite
pop hl
call PlayerSpinWhileMovingDown_Old
call FishingAnim_Old ; was IsPlayerStandingOnWarpPadOrHole
ld a, b
and a
jr nz, .done
; if the player is not standing on a warp pad or hole
ld hl, wBattleMenuRows ; originally wPlayerSpinInPlaceAnimFrameDelay
xor a
ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelay
inc a
ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelayDelta
ld a, $8
ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelayEndValue
ld [hl], $ff ; wPlayerSpinInPlaceAnimSoundID
ld hl, $cc45 ; originally wFacingDirectionList
call PlayerSpinInPlace_Old
.done
jp RestoreFacingDirectionAndYScreenPos_Old
; Unreferenced
.dungeonWarpAnimation
ld c, 50
call DelayFrames
call PlayerSpinWhileMovingDown_Old
jr .done
; Also unreferenced
.flyAnimation
pop hl
ld de, PidgeySpriteGFX
ld hl, vNPCSprites
lb bc, BANK(PidgeySpriteGFX), $c
call Request2bpp
call LoadBirdSpriteGraphics_Old
ld hl, wBattleMenuRows ; Originally wFlyAnimUsingCoordList
xor a ; is using coord list
ld [hli], a ; wFlyAnimUsingCoordList
ld a, 12
ld [hli], a ; wFlyAnimCounter
ld [hl], $8 ; wFlyAnimBirdSpriteImageIndex (facing right)
ld de, FlyAnimationEnterScreenCoords_Old
call DoFlyAnimation_Old
call RedrawPlayerSprite
jr .done
FlyAnimationEnterScreenCoords_Old:
; y, x pairs
; This was the sequence of screen coordinates used by the overworld
; Fly animation when the player is entering a map.
db $05, $98
db $0F, $90
db $18, $88
db $20, $80
db $27, $78
db $2D, $70
db $32, $68
db $36, $60
db $39, $58
db $3B, $50
db $3C, $48
db $3C, $40
PlayerSpinWhileMovingDown_Old:
ld hl, wBattleMenuRows ; originally wPlayerSpinWhileMovingUpOrDownAnimDeltaY
ld a, $10
ld [hli], a ; wPlayerSpinWhileMovingUpOrDownAnimDeltaY
ld a, $3c
ld [hli], a ; wPlayerSpinWhileMovingUpOrDownAnimMaxY
call GetPlayerTeleportAnimFrameDelay_Old
ld [hl], a ; wPlayerSpinWhileMovingUpOrDownAnimFrameDelay
jp PlayerSpinWhileMovingUpOrDown_Old
LeaveMapAnim_Old:
call InitFacingDirectionList_Old
call FishingAnim_Old ; originally IsPlayerStandingOnWarpPadOrHole
ld a, b
and a
jr z, .playerNotStandingOnWarpPadOrHole
dec a
jp nz, LeaveMapThroughHoleAnim_Old
.spinWhileMovingUp
ld hl, wBattleMenuRows ; originally wPlayerSpinWhileMovingUpOrDownAnimDeltaY
ld a, -$10
ld [hli], a ; wPlayerSpinWhileMovingUpOrDownAnimDeltaY
ld a, $ec
ld [hli], a ; wPlayerSpinWhileMovingUpOrDownAnimMaxY
call GetPlayerTeleportAnimFrameDelay_Old
ld [hl], a ; wPlayerSpinWhileMovingUpOrDownAnimFrameDelay
call PlayerSpinWhileMovingUpOrDown_Old
call FishingAnim_Old ; originally IsPlayerStandingOnWarpPadOrHole
ld a, b
dec a
jr z, .playerStandingOnWarpPad
; if not standing on a warp pad, there is an extra delay
ld c, 10
call DelayFrames
.playerStandingOnWarpPad
call GBFadeOutToWhite
jp RestoreFacingDirectionAndYScreenPos_Old
.playerNotStandingOnWarpPadOrHole
ld hl, wBattleMenuRows ; originally wPlayerSpinInPlaceAnimFrameDelay
ld a, 16
ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelay
ld a, -1
ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelayDelta
xor a
ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelayEndValue
ld [hl], SFX_TELEPORT_EXIT_2 ; wPlayerSpinInPlaceAnimSoundID
ld hl, $cc45 ; originally wFacingDirectionList
call PlayerSpinInPlace_Old
jr .spinWhileMovingUp
; Also unreferenced
.flyAnimation
call LoadBirdSpriteGraphics_Old
ld hl, wBattleMenuRows ; originally wFlyAnimUsingCoordList
ld a, $ff ; is not using coord list (flap in place)
ld [hli], a ; wFlyAnimUsingCoordList
ld a, 8
ld [hli], a ; wFlyAnimCounter
ld [hl], $c ; wFlyAnimBirdSpriteImageIndex
call DoFlyAnimation_Old
ld hl, wBattleMenuRows ; wFlyAnimUsingCoordList
xor a ; is using coord list
ld [hli], a ; wFlyAnimUsingCoordList
ld a, $c
ld [hli], a ; wFlyAnimCounter
ld [hl], $c ; wFlyAnimBirdSpriteImageIndex (facing right)
ld de, FlyAnimationScreenCoords1_Old
call DoFlyAnimation_Old
ld c, 40
call DelayFrames
ld hl, wBattleMenuColumns ; originally wFlyAnimCounter
ld a, 11
ld [hli], a ; wFlyAnimCounter
ld [hl], $8 ; wFlyAnimBirdSpriteImageIndex (facing left)
ld de, FlyAnimationScreenCoords2_Old
call DoFlyAnimation_Old
call GBFadeOutToWhite
jp RestoreFacingDirectionAndYScreenPos_Old
FlyAnimationScreenCoords1_Old:
; y, x pairs
; This is the sequence of screen coordinates used by the first part
; of the Fly overworld animation.
db $3C, $48
db $3C, $50
db $3B, $58
db $3A, $60
db $39, $68
db $37, $70
db $37, $78
db $33, $80
db $30, $88
db $2D, $90
db $2A, $98
db $27, $A0
FlyAnimationScreenCoords2_Old:
; y, x pairs
; This is the sequence of screen coordinates used by the second part
; of the Fly overworld animation.
db $1A, $90
db $19, $80
db $17, $70
db $15, $60
db $12, $50
db $0F, $40
db $0C, $30
db $09, $20
db $05, $10
db $00, $00
db $F0, $00
LeaveMapThroughHoleAnim_Old:
ld a, [wShadowOAMSprite00TileID]
ld [wShadowOAMSprite02TileID], a
ld a, [wShadowOAMSprite01TileID]
ld [wShadowOAMSprite03TileID], a
ld a, $a0
ld [wShadowOAMSprite00YCoord], a
ld [wShadowOAMSprite01YCoord], a
ld c, 2
call DelayFrames
; hide upper half of player's sprite
ld a, $a0
ld [wShadowOAMSprite02YCoord], a
ld [wShadowOAMSprite03YCoord], a
call GBFadeOutToWhite
jp RestoreFacingDirectionAndYScreenPos_Old
DoFlyAnimation_Old:
ld a, [wTrainerHUDTiles] ; originally wFlyAnimBirdSpriteImageIndex
xor $1 ; make the bird flap its wings
ld [wTrainerHUDTiles], a
ld [wReservedObjectSpriteTile], a ; originally wSpritePlayerStateData1ImageIndex
ld c, 3
call DelayFrames
ld a, [wBattleMenuRows] ; wFlyAnimUsingCoordList
cp $ff
jr z, .skipCopyingCoords ; if the bird is flapping its wings in place
ld hl, wReservedObjectFlags ; originally wSpritePlayerStateData1YPixels
ld a, [de]
inc de
ld [hli], a ; y
inc hl
ld a, [de]
inc de
ld [hl], a ; x
.skipCopyingCoords
ld a, [wBattleMenuColumns] ; wFlyAnimCounter
dec a
ld [wBattleMenuColumns], a
jr nz, DoFlyAnimation_Old
ret
LoadBirdSpriteGraphics_Old:
ld de, PidgeySpriteGFX
ld hl, vNPCSprites
lb bc, BANK(PidgeySpriteGFX), 12
call Request2bpp
ld de, PidgeySpriteGFX tile 12
ld hl, vNPCSprites2
lb bc, BANK(PidgeySpriteGFX), 12
jp Request2bpp
InitFacingDirectionList_Old:
ld a, [wReservedObjectSpriteTile] ; originally wSpritePlayerStateData1ImageIndex
ld [$cc4d], a ; originally wSavedPlayerFacingDirection
ld a, [wReservedObjectFlags] ; originally wSpritePlayerStateData1YPixels
ld [$cc4c], a ; originally wSavedPlayerScreenY
ld hl, .PlayerSpinningFacingOrder
ld de, $cc45 ; originally wFacingDirectionList
ld bc, 4
call CopyBytes
ld a, [wReservedObjectSpriteTile]
ld hl, $cc45
; find the place in the list that matches the current facing direction
.loop
cp [hl]
inc hl
jr nz, .loop
dec hl
ret
.PlayerSpinningFacingOrder:
; The order of the direction the player's sprite is facing when teleporting
; away. Creates a spinning effect.
db OW_DOWN, OW_LEFT, OW_UP, OW_RIGHT
SpinPlayerSprite_Old:
; copy the current value from the list into the sprite data and rotate the list
ld a, [hl]
ld [wReservedObjectSpriteTile], a ; originally wSpritePlayerStateData1ImageIndex
push hl
ld hl, $cc45 ; wFacingDirectionList
ld de, $cc44 ; wFacingDirectionList - 1
ld bc, 4
call CopyBytes
ld a, [$cc44]
ld [$cc48], a ; wFacingDirectionList + 3
pop hl
ret
PlayerSpinInPlace_Old:
call SpinPlayerSprite_Old
ld a, [wBattleMenuRows] ; originally wPlayerSpinInPlaceAnimFrameDelay
ld c, a
and $3
jr nz, .skipPlayingSound
.skipPlayingSound
ld a, [wBattleMenuColumns] ; wPlayerSpinInPlaceAnimFrameDelayDelta
add c
ld [wBattleMenuRows], a ; wPlayerSpinInPlaceAnimFrameDelay
ld c, a
ld a, [wTrainerHUDTiles] ; wPlayerSpinInPlaceAnimFrameDelayEndValue
cp c
ret z
call DelayFrames
jr PlayerSpinInPlace_Old
PlayerSpinWhileMovingUpOrDown_Old:
call SpinPlayerSprite_Old
ld a, [wBattleMenuRows] ; wPlayerSpinWhileMovingUpOrDownAnimDeltaY
ld c, a
ld a, [wReservedObjectFlags] ; wSpritePlayerStateData1YPixels
add c
ld [wReservedObjectFlags], a ; wSpritePlayerStateData1YPixels
ld c, a
ld a, [wBattleMenuColumns] ; wPlayerSpinWhileMovingUpOrDownAnimMaxY
cp c
ret z
ld a, [wTrainerHUDTiles] ; wPlayerSpinWhileMovingUpOrDownAnimFrameDelay
ld c, a
call DelayFrames
jr PlayerSpinWhileMovingUpOrDown_Old
RestoreFacingDirectionAndYScreenPos_Old:
ld a, [$cc4c] ; wSavedPlayerScreenY
ld [wReservedObjectFlags], a ; wSpritePlayerStateData1YPixels
ld a, [$cc4d] ; wSavedPlayerFacingDirection
ld [wReservedObjectSpriteTile], a ; wSpritePlayerStateData1ImageIndex
ret
; if SGB, 2 frames, else 3 frames
GetPlayerTeleportAnimFrameDelay_Old:
ld a, [wSGB]
xor $1
inc a
inc a
ret
FishingAnim_Old:
ld c, 10
call DelayFrames
ld hl, wMovementFlags_Old
set 6, [hl] ; BIT_LEDGE_OR_FISHING
ld de, GoldSpriteGFX
ld hl, vNPCSprites tile $00
lb bc, BANK(GoldSpriteGFX), 12
call Request2bpp
ld a, 4
ld hl, RedFishingTiles
call $4c4d ; LoadAnimSpriteGfx_Old
ld a, [wReservedObjectSpriteTile] ; originally wSpritePlayerStateData1ImageIndex
ld c, a
ld b, $0
ld hl, FishingRodOAM
add hl, bc
ld de, wShadowOAMSprite39
ld bc, $4
call CopyBytes
ld c, 100
call DelayFrames
ld a, [wRodResponse_Old]
and a
ld hl, NoNibbleText
jr z, .done
cp 2
ld hl, NothingHereText
jr z, .done
; there was a bite
; shake the player's sprite vertically
ld b, 10
.loop
ld hl, wReservedObjectFlags ; wSpritePlayerStateData1YPixels
call .ShakePlayerSprite
ld hl, wShadowOAMSprite39
call .ShakePlayerSprite
ld c, 3
call DelayFrames
dec b
jr nz, .loop
; If the player is facing up, hide the fishing rod so it doesn't overlap with
; the exclamation bubble that will be shown next.
ld a, [wReservedObjectSpriteTile] ; wSpritePlayerStateData1ImageIndex
cp OW_UP
jr nz, .skipHidingFishingRod
ld a, $a0
ld [wShadowOAMSprite39YCoord], a
.skipHidingFishingRod
ld hl, $cc4c ; wEmotionBubbleSpriteIndex
xor a
ld [hli], a ; player's sprite
ld [hl], a ; EXCLAMATION_BUBBLE
; There's no predef for displaying emotion bubbles in this build, so this amounts to nothing
; If the player is facing up, unhide the fishing rod.
ld a, [wReservedObjectSpriteTile] ; wSpritePlayerStateData1ImageIndex
cp OW_UP
jr nz, .skipUnhidingFishingRod
ld a, $44
ld [wShadowOAMSprite39YCoord], a
.skipUnhidingFishingRod
ld hl, ItsABiteText
.done
call PrintText
ld hl, wMovementFlags_Old
res 6, [hl] ; BIT_LEDGE_OR_FISHING
call RedrawPlayerSprite
call LoadFont
ret
.ShakePlayerSprite
ld a, [hl]
xor $1
ld [hl], a
ret
NoNibbleText:
text "つれないなー<⋯⋯>"
prompt
NothingHereText:
text "なにも いない みたい<⋯⋯>"
prompt
ItsABiteText:
text "おっ!"
line "ひいてる ひいてる!"
prompt
FishingRodOAM:
; specifies how the fishing rod should be drawn on the screen
dbsprite 9, 11, 4, 3, $fd, 0 ; down
dbsprite 9, 8, 4, 4, $fd, 0 ; up
dbsprite 8, 10, 0, 0, $fe, 0 ; left
dbsprite 11, 10, 0, 0, $fe, X_FLIP ; right
MACRO fishing_gfx
dw \1
db \2
db $32 ; should've been BANK(\1)
dw vNPCSprites tile \3
ENDM
RedFishingTiles:
fishing_gfx RedFishingTilesFront, 2, $02
fishing_gfx RedFishingTilesBack, 2, $06
fishing_gfx RedFishingTilesSide, 2, $0a
fishing_gfx RedFishingRodTiles, 3, $fd
LoadAnimSpriteGfx_Old:
; Load animated sprite tile patterns into VRAM during V-blank. hl is the address
; of an array of structures that contain arguments for CopyVideoData and a is
; the number of structures in the array.
ld bc, $0
.loop
push af
push bc
push hl
add hl, bc
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
ld a, [hli]
ld c, a
ld a, [hli]
ld b, a
ld a, [hli]
ld h, [hl]
ld l, a
call Request2bpp
pop hl
pop bc
ld a, $6
add c
ld c, a
pop af
dec a
jr nz, .loop
ret
RedFishingTilesFront: INCBIN "gfx/overworld/red_fish_front.2bpp"
RedFishingTilesBack: INCBIN "gfx/overworld/red_fish_back.2bpp"
RedFishingTilesSide: INCBIN "gfx/overworld/red_fish_side.2bpp"
RedFishingRodTiles: INCBIN "gfx/overworld/fishing_rod.2bpp"

View File

@ -398,7 +398,7 @@ PikachuMiniGame_RunFrame:
ldh [hSCX], a
ldh [hSCY], a
ld a, 144
ld a, SCREEN_HEIGHT_PX
ldh [hWY], a
scf
ret

View File

@ -395,8 +395,9 @@ MACRO map_buffer_pointers
ENDM
; TODO: Rename to something more fitting, and actually label the flag ram addresses.
UnknownMapBufferPointers:
map_buffer_pointers PLAYER_HOUSE_2F, wPlayerHouse2FCurScript, PlayerHouse2FScriptPointers, $d39a
map_buffer_pointers PLAYER_HOUSE_2F, wPlayerHouse2FCurScript, PlayerHouse2FScriptPointers, wd39a
;db $01, $09, $9A, $D2, $95, $41, $9A, $D3
db $01, $08, $9B, $D2, $A6, $40, $9B, $D3 ; PLAYER_HOUSE_1F
db $01, $04, $9C, $D2, $7E, $76, $9C, $D3 ; SILENT_HILL

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 B

View File

@ -67,7 +67,7 @@ SetUpMapBuffer::
ld de, wMapScriptNumberLocation
call GetMapScriptNumber ; Read map script from pointed location
call CopyWord ; Copy map script pointer
ld de, wUnknownMapPointer
ld de, wMapScriptPointerLocation
call CopyWord
.done
@ -955,7 +955,7 @@ InitObjectMasks::
ld a, $ff
call ByteFill
ld hl, wUnknownMapPointer
ld hl, wMapScriptPointerLocation
ld e, [hl]
inc hl
ld d, [hl]

View File

@ -389,6 +389,8 @@ ROMX $23
"engine/dumps/bank23.asm@RestoreOverworldMapTiles"
org $44be
"engine/battle/battle_transitions.asm"
org $4940
"engine/dumps/bank23.asm@EnterMapAnim_Old"
org $4cfd
"engine/dumps/bank23.asm@ClearSpriteAnims"
org $60cc

View File

@ -297,7 +297,7 @@ SECTION "Map Buffer", WRAM0
wMapBuffer::
wMapScriptNumber:: db
wMapScriptNumberLocation:: dw
wUnknownMapPointer:: dw ; TODO
wMapScriptPointerLocation:: dw ; TODO
; setting bit 7 seems to disable overworld updates and player control?
wc5ed:: db
ds 18
@ -1624,6 +1624,8 @@ wJoypadFlags:: db
; ||\------ don't wait for keypress to close text box
; |\------- joypad sync mtx
; \-------- joypad disabled
ds 1
wMovementFlags_Old:: db
SECTION "wDigWarpNumber", WRAM0[$D4B2]

View File

@ -1,29 +1,4 @@
;05:43E0 SaveMenu
;05:44E9 VerifyChecksum
;05:451B PrintSaveScreenText
;05:457A SaveOptionsAndGameData
;05:45B8 SavePokemonData
;05:45DE Dummy_SaveBox
;05:4624 TryLoadSaveFile
;05:46DC TryLoadPokemonData
; Structure:
; byte Map group ($ff = end)
; byte Map ID
; ptr Copied to c5e9, also byte pointed to written at wMapScriptNumber
; ptr Copied to c5eb
; word Unknown (2 bytes)
;05:470E UnknownMapBufferPointers
;05:4777 Function14777
;05:4C94 Data14c94
;05:4CAC _Unreferenced_PokemonNewsScript
;05:4DAC _PokemonBooksScript
;05:4DC4 _PlayerHouse1FFridgeScript
;05:4DDD _SilentHillHouseStoveScript
;05:4E00 _SilentHillHouseSinkScript
;05:4E5F _SilentHillHouseTVScript
;05:4E27 _PokecenterSignScript
;05:4E4A _RivalHouseWindowScript
; Link cable-related functions.
; all these probably print text
0A:4000 Function28000
0A:4C98 LinkTextboxAtHL
@ -33,36 +8,11 @@
0A:5A1F Function29a1f ; prints text
0A:5ABF Function29abf ; prints text
;0E:4B78 GetTrainerAttributesName
;0E:4BA0 GetTrainerAttributesName.got_name
;0E:4BA9 GetTrainerAttributes
;0E:4BD0 TrainerClassAttributes
;0E:4000 TrainerAI
;0E:4220 AI_Switch
;0E:4340 BattleStart_TrainerHuds
;0E:434E EnemySwitch_TrainerHud
;0E:43CD DrawPlayerHUDBorder
;0E:43FD DrawEnemyHUDBorder
;0E:4415 PlaceHUDBorderTiles
;0E:4431 LinkBattle_TrainerHuds
;0E:4594 AIScoringPointers
;0e:49b4 AICompareSpeed
;0e:49c7 AICheckPlayerHalfHP
;0e:49da AICheckEnemyHalfHP
;0e:49ed AICheckEnemyQuarterHP
;0e:4a1f UsefulMoves
;0e:4b5f AIGetEnemyMove
;0E:44D4 Function384d4
;0E:4F45 ReadTrainerParty
;0E:50E9 Battle_GetTrainerName
23:4940 Function8c940
23:49C6 Function8c9c6
23:4b6d FishingAnim_Old
;23:4940 EnterMapAnim_Old
;23:49C6 Function8c9c6
;23:4b6d FishingAnim_Old
38:48A2 PokerMinigame
38:5AE3 FifteenPuzzleMinigame
38:4E5F Cursor_AnimateCursor
38:4EA8 Cursor_InterpretJoypad
@ -70,6 +20,8 @@
; Poker Cursor AnimSeq Function
38:5054 Functione1054
38:5AE3 FifteenPuzzleMinigame
;3F:40E9 InGameDebugMenu
;3F:4E3E Functionfce3e
3F:5B66 Functionfdb66