diff options
Diffstat (limited to 'engine')
31 files changed, 1813 insertions, 916 deletions
diff --git a/engine/battle_start.asm b/engine/battle_start.asm index 845af9d2a..4ef26cae3 100644 --- a/engine/battle_start.asm +++ b/engine/battle_start.asm @@ -120,7 +120,7 @@ Function8c2cf: ; 8c2cf ld a, $6 ld [rSVBK], a push hl - ld hl, w6_d000 + ld hl, wBackupTilemap ld bc, $28 * $10 .loop @@ -132,7 +132,7 @@ Function8c2cf: ; 8c2cf jr nz, .loop pop hl - ld de, w6_d000 + ld de, wBackupTilemap ld b, BANK(Function8c2cf) ; BANK(@) ld c, $28 call Request2bpp diff --git a/engine/breeding/egg.asm b/engine/breeding/egg.asm index ebf5e48d8..6d6141c4f 100755 --- a/engine/breeding/egg.asm +++ b/engine/breeding/egg.asm @@ -194,7 +194,7 @@ OverworldHatchEgg:: ; 16f5e call Function16f70 call ExitAllMenus call RestartMapMusic - jp LoadMoveSprites + jp CloseText ; 16f70 Function16f70: ; 16f70 (5:6f70) @@ -678,7 +678,7 @@ Function1727f: ; 1727f (5:727f) push hl push de push bc - callab Function8cf69 + callab PlaySpriteAnimations call DelayFrame pop bc pop de @@ -789,9 +789,9 @@ Function1736d: ; 1736d (5:736d) ret nc swap a srl a - add $4c + add 9 * 8 + 4 ld d, a - ld e, $58 + ld e, 11 * 8 ld a, SPRITE_ANIM_INDEX_19 call _InitSpriteAnimStruct ld hl, $3 @@ -807,10 +807,10 @@ INCBIN "gfx/unknown/017393.2bpp" Function173b3: ; 173b3 (5:73b3) callba Function8cf53 - ld hl, Unknown_173ef + ld hl, .SpriteData .loop ld a, [hli] - cp $ff + cp -1 jr z, .done ld e, a ld a, [hli] @@ -823,16 +823,16 @@ Function173b3: ; 173b3 (5:73b3) push bc ld a, SPRITE_ANIM_INDEX_1C call _InitSpriteAnimStruct - ld hl, $3 + ld hl, SpriteAnim1TileID - SpriteAnim1 add hl, bc ld [hl], $0 pop de ld a, e - ld hl, $1 + ld hl, SpriteAnim1Sprite01 - SpriteAnim1 add hl, bc add [hl] ld [hl], a - ld hl, $b + ld hl, SpriteAnim1Sprite0b - SpriteAnim1 add hl, bc ld [hl], d pop hl @@ -844,19 +844,19 @@ Function173b3: ; 173b3 (5:73b3) ret ; 173ef (5:73ef) -Unknown_173ef: ; 173ef +.SpriteData: ; 173ef ; Probably OAM. - db $54, $48, $00, $3c - db $5c, $48, $01, $04 - db $54, $50, $00, $30 - db $5c, $50, $01, $10 - db $54, $58, $02, $24 - db $5c, $58, $03, $1c - db $50, $4c, $00, $36 - db $60, $4c, $01, $0a - db $50, $54, $02, $2a - db $60, $54, $03, $16 - db $ff + dsprite 10, 4, 9, 0, $00, $3c + dsprite 11, 4, 9, 0, $01, $04 + dsprite 10, 4, 10, 0, $00, $30 + dsprite 11, 4, 10, 0, $01, $10 + dsprite 10, 4, 11, 0, $02, $24 + dsprite 11, 4, 11, 0, $03, $1c + dsprite 10, 0, 9, 4, $00, $36 + dsprite 12, 0, 9, 4, $01, $0a + dsprite 10, 0, 10, 4, $02, $2a + dsprite 12, 0, 10, 4, $03, $16 + db -1 ; 17418 Function17418: ; 17418 (5:7418) diff --git a/engine/credits.asm b/engine/credits.asm index 6e2bef12d..41ee36920 100644 --- a/engine/credits.asm +++ b/engine/credits.asm @@ -118,7 +118,7 @@ const_value SET -7 const CREDITS_END -Function109847:: ; 109847 +Credits:: ; 109847 bit 6, b ld a, $0 jr z, .asm_10984f diff --git a/engine/crystal_intro.asm b/engine/crystal_intro.asm index 69a068ff9..beada9f84 100755 --- a/engine/crystal_intro.asm +++ b/engine/crystal_intro.asm @@ -52,7 +52,7 @@ Functione4579: ; e4579 bit 7, a jr nz, .finish call PlaceGameFreakPresents - callba Function8cf69 + callba PlaySpriteAnimations call DelayFrame jr .joy_loop @@ -79,17 +79,17 @@ Functione45e8: ; e45e8 ld [rSVBK], a ld hl, IntroLogoGFX - ld de, w6_d000 + ld de, wBackupTilemap ld a, BANK(IntroLogoGFX) call FarDecompress ld hl, VTiles0 - ld de, w6_d000 + ld de, wBackupTilemap lb bc, 1, 8 tiles call Request2bpp ld hl, VTiles1 - ld de, w6_d000 + $80 tiles + ld de, wBackupTilemap + $80 tiles lb bc, 1, 8 tiles call Request2bpp @@ -406,7 +406,7 @@ CrystalIntro: ; e48ac bit 7, a jr nz, .done call IntroSceneJumper - callba Function8cf69 + callba PlaySpriteAnimations call DelayFrame jp .loop @@ -1886,7 +1886,7 @@ Functione541b: ; e541b (39:541b) push af ld a, $6 ld [rSVBK], a - ld hl, w6_d000 + ld hl, wBackupTilemap decoord 0, 0 ld b, SCREEN_HEIGHT .asm_e542a @@ -2000,10 +2000,10 @@ Functione54c2: ; e54c2 (39:54c2) ld a, $6 ld [rSVBK], a push de - ld de, w6_d000 + ld de, wBackupTilemap call Decompress pop hl - ld de, w6_d000 + ld de, wBackupTilemap ld bc, $180 call Request2bpp pop af @@ -2016,10 +2016,10 @@ Functione54de: ; e54de (39:54de) ld a, $6 ld [rSVBK], a push de - ld de, w6_d000 + ld de, wBackupTilemap call Decompress pop hl - ld de, w6_d000 + ld de, wBackupTilemap ld bc, $1ff call Request2bpp pop af @@ -2032,10 +2032,10 @@ Functione54fa: ; e54fa (39:54fa) ld a, $6 ld [rSVBK], a push de - ld de, w6_d000 + ld de, wBackupTilemap call Decompress pop hl - ld de, w6_d000 + ld de, wBackupTilemap ld bc, $140 call Request2bpp pop af diff --git a/engine/debug.asm b/engine/debug.asm index 0d2720990..1e00ae4f5 100755 --- a/engine/debug.asm +++ b/engine/debug.asm @@ -425,7 +425,7 @@ Function81adb: ; 81adb .asm_81b7a ld a, [wd265] ld [TrainerClass], a - callab Function3957b + callab GetTrainerAttributes ld de, StringBuffer1 hlcoord 4, 1 call PlaceString diff --git a/engine/decorations.asm b/engine/decorations.asm index 1fa5cac7e..2da9fa48a 100755 --- a/engine/decorations.asm +++ b/engine/decorations.asm @@ -1246,9 +1246,9 @@ DecorationDesc_PosterPointers: ; 26f84 DecorationDesc_TownMapPoster: ; 0x26f91 loadfont writetext .TownMapText - closetext + waitbutton special Special_TownMap - loadmovesprites + closetext end ; 0x26f9b diff --git a/engine/dummy_game.asm b/engine/dummy_game.asm index 4e8dad1a3..756486ff8 100755 --- a/engine/dummy_game.asm +++ b/engine/dummy_game.asm @@ -47,7 +47,7 @@ Functione1ebb: ; e1ebb (38:5ebb) bit 7, a jr nz, .asm_e1ed0 call Functione1ed2 - callab Function8cf69 + callab PlaySpriteAnimations call DelayFrame and a ret @@ -89,7 +89,7 @@ Functione1ef3: ; e1ef3 ; e1efb Functione1efb: ; e1efb - call Functione00ed + call ret_e00ed jr nc, .asm_e1f06 ld hl, wJumptableIndex set 7, [hl] @@ -251,7 +251,7 @@ Functione1fcc: ; e1fcc inc [hl] Functione2000: ; e2000 - call Functione00ed + call ret_e00ed jr nc, .asm_e200b ld hl, wJumptableIndex set 7, [hl] diff --git a/engine/events.asm b/engine/events.asm index 40e863cdc..d78a0a333 100644 --- a/engine/events.asm +++ b/engine/events.asm @@ -491,11 +491,11 @@ endr bit 3, [hl] jr z, .nope - ld hl, ScriptDelay + 2 + ld hl, wPriorityScriptAddr ld a, [hli] ld h, [hl] ld l, a - ld a, [ScriptDelay + 1] + ld a, [wPriorityScriptBank] call CallScript scf ret diff --git a/engine/events_2.asm b/engine/events_2.asm index c9b673e81..5be1d4226 100644 --- a/engine/events_2.asm +++ b/engine/events_2.asm @@ -142,7 +142,7 @@ RandomEncounter:: ; 97cc0 ; 97cf9 WildBattleScript: ; 97cf9 - battlecheck + setup_random_encounter startbattle returnafterbattle end diff --git a/engine/evolution_animation.asm b/engine/evolution_animation.asm index 835db8b52..5cf655980 100755 --- a/engine/evolution_animation.asm +++ b/engine/evolution_animation.asm @@ -21,7 +21,7 @@ EvolutionAnimation: ; 4e5e1 pop de pop hl - ld a, [wd1ed] + ld a, [Buffer4] and a ret z @@ -99,7 +99,7 @@ _EvolutionAnimation: ; 4e607 call .ReplaceFrontpic xor a - ld [wd1ed], a + ld [Buffer4], a ld a, [Buffer2] ld [PlayerHPPal], a @@ -136,7 +136,7 @@ _EvolutionAnimation: ; 4e607 .cancel_evo ld a, $1 - ld [wd1ed], a + ld [Buffer4], a ld a, [Buffer1] ld [PlayerHPPal], a @@ -252,7 +252,7 @@ endr ret .pressed_b - ld a, [wd1e9] + ld a, [wForceEvolution] and a jr nz, .loop3 scf @@ -270,7 +270,7 @@ Function4e794: ; 4e794 ; 4e7a6 Function4e7a6: ; 4e7a6 - ld a, [wd1ed] + ld a, [Buffer4] and a ret nz ld de, SFX_EVOLVED @@ -286,7 +286,7 @@ Function4e7a6: ; 4e7a6 jr .loop .done - ld c, $20 + ld c, 32 .loop2 call Function4e80c dec c @@ -299,7 +299,7 @@ Function4e7a6: ; 4e7a6 Function4e7cf: ; 4e7cf ld hl, wJumptableIndex ld a, [hl] - cp $20 + cp 32 ret nc ld d, a inc [hl] @@ -317,8 +317,8 @@ Function4e7cf: ; 4e7cf Function4e7e8: ; 4e7e8 push de - lb de, $48, $58 - ld a, $13 + depixel 9, 11 + ld a, SPRITE_ANIM_INDEX_13 call _InitSpriteAnimStruct ld hl, $b add hl, bc @@ -339,7 +339,7 @@ Function4e7e8: ; 4e7e8 Function4e80c: ; 4e80c push bc - callab Function8cf69 + callab PlaySpriteAnimations ; a = (([hVBlankCounter] + 4) / 2) % NUM_PALETTES ld a, [hVBlankCounter] and $e @@ -369,88 +369,3 @@ endr EvolutionGFX: INCBIN "gfx/evo/bubble_large.2bpp" INCBIN "gfx/evo/bubble.2bpp" - -Function4e881: ; 4e881 - call ClearBGPalettes - call ClearTileMap - call ClearSprites - call DisableLCD - call LoadStandardFont - call LoadFontsBattleExtra - hlbgcoord 0, 0 - ld bc, VBGMap1 - VBGMap0 - ld a, " " - call ByteFill - hlcoord 0, 0, AttrMap - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT - xor a - call ByteFill - xor a - ld [hSCY], a - ld [hSCX], a - call EnableLCD - ld hl, UnknownText_0x4e8bd - call PrintText - call Function3200 - call SetPalettes - ret -; 4e8bd - -UnknownText_0x4e8bd: ; 0x4e8bd - ; SAVING RECORD… DON'T TURN OFF! - text_jump UnknownText_0x1bd39e - db "@" -; 0x4e8c2 - - -Function4e8c2: ; 4e8c2 - call ClearBGPalettes - call ClearTileMap - call ClearSprites - call DisableLCD - call LoadStandardFont - call LoadFontsBattleExtra - hlbgcoord 0, 0 - ld bc, VBGMap1 - VBGMap0 - ld a, " " - call ByteFill - hlcoord 0, 0, AttrMap - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT - xor a - call ByteFill - ld hl, wd000 - ld c, $40 -.asm_4e8ee - ld a, -1 - ld [hli], a - ld a, " " - ld [hli], a - dec c - jr nz, .asm_4e8ee - xor a - ld [hSCY], a - ld [hSCX], a - call EnableLCD - call Function3200 - call SetPalettes - ret -; 4e906 - -Function4e906: ; 4e906 - ld a, [rSVBK] - push af - ld a, $6 - ld [rSVBK], a - ld hl, w6_d000 - ld bc, w6_d400 - w6_d000 - ld a, " " - call ByteFill - hlbgcoord 0, 0 - ld de, w6_d000 - ld b, $0 - ld c, $40 - call Request2bpp - pop af - ld [rSVBK], a - ret -; 4e929 diff --git a/engine/evolve.asm b/engine/evolve.asm index 6772db932..2ea3ee0a9 100755 --- a/engine/evolve.asm +++ b/engine/evolve.asm @@ -78,7 +78,7 @@ endr cp EVOLVE_ITEM jp z, .item - ld a, [wd1e9] + ld a, [wForceEvolution] and a jp nz, .dont_evolve_2 @@ -179,7 +179,7 @@ endr cp b jp nz, .dont_evolve_3 - ld a, [wd1e9] + ld a, [wForceEvolution] and a jp z, .dont_evolve_3 ld a, [wLinkMode] diff --git a/engine/fruit_trees.asm b/engine/fruit_trees.asm index 28e6e8cec..e6f7de9d1 100644 --- a/engine/fruit_trees.asm +++ b/engine/fruit_trees.asm @@ -9,7 +9,7 @@ FruitTreeScript:: ; 44000 callasm CheckFruitTree iffalse .fruit writetext NothingHereText - closetext + waitbutton jump .end .fruit @@ -27,10 +27,10 @@ FruitTreeScript:: ; 44000 .packisfull keeptextopen writetext FruitPackIsFullText - closetext + waitbutton .end - loadmovesprites + closetext end ; 44041 diff --git a/engine/learn.asm b/engine/learn.asm new file mode 100755 index 000000000..cafbe6f43 --- /dev/null +++ b/engine/learn.asm @@ -0,0 +1,257 @@ +LearnMove: ; 6508 + call LoadTileMapToTempTileMap + ld a, [CurPartyMon] + ld hl, PartyMonNicknames + call GetNick + ld hl, StringBuffer1 + ld de, wd050_MonNick + ld bc, PKMN_NAME_LENGTH + call CopyBytes + +.loop + ld hl, PartyMon1Moves + ld bc, PARTYMON_STRUCT_LENGTH + ld a, [CurPartyMon] + call AddNTimes + ld d, h + ld e, l + ld b, NUM_MOVES +; Get the first empty move slot. This routine also serves to +; determine whether the Pokemon learning the moves already has +; all four slots occupied, in which case one would need to be +; deleted. +.next + ld a, [hl] + and a + jr z, .learn + inc hl + dec b + jr nz, .next +; If we're here, we enter the routine for forgetting a move +; to make room for the new move we're trying to learn. + push de + call ForgetMove + pop de + jp c, .cancel + + push hl + push de + ld [wd265], a + + ld b, a + ld a, [wBattleMode] + and a + jr z, .not_disabled + ld a, [DisabledMove] + cp b + jr nz, .not_disabled + xor a + ld [DisabledMove], a + ld [PlayerDisableCount], a +.not_disabled + + call GetMoveName + ld hl, UnknownText_0x6684 ; 1, 2 and… + call PrintText + pop de + pop hl + +.learn + ld a, [wd262] + ld [hl], a + ld bc, MON_PP - MON_MOVES + add hl, bc + + push hl + push de + dec a + ld hl, Moves + MOVE_PP + ld bc, MOVE_LENGTH + call AddNTimes + ld a, BANK(Moves) + call GetFarByte + pop de + pop hl + + ld [hl], a + + ld a, [wBattleMode] + and a + jp z, .learned + + ld a, [CurPartyMon] + ld b, a + ld a, [CurBattleMon] + cp b + jp nz, .learned + + ld a, [PlayerSubStatus5] + bit SUBSTATUS_TRANSFORMED, a + jp nz, .learned + + ld h, d + ld l, e + ld de, BattleMonMoves + ld bc, NUM_MOVES + call CopyBytes + ld bc, PartyMon1PP - (PartyMon1Moves + NUM_MOVES) + add hl, bc + ld de, BattleMonPP + ld bc, NUM_MOVES + call CopyBytes + jp .learned + +.cancel + ld hl, UnknownText_0x6675 ; Stop learning <MOVE>? + call PrintText + call YesNoBox + jp c, .loop + + ld hl, UnknownText_0x667a ; <MON> did not learn <MOVE>. + call PrintText + ld b, 0 + ret + +.learned + ld hl, UnknownText_0x666b ; <MON> learned <MOVE>! + call PrintText + ld b, 1 + ret +; 65d3 + +ForgetMove: ; 65d3 + push hl + ld hl, UnknownText_0x667f + call PrintText + call YesNoBox + pop hl + ret c + ld bc, -NUM_MOVES + add hl, bc + push hl + ld de, wListMoves_MoveIndicesBuffer + ld bc, NUM_MOVES + call CopyBytes + pop hl +.loop + push hl + ld hl, UnknownText_0x6670 + call PrintText + hlcoord 5, 2 + ld b, NUM_MOVES * 2 + ld c, MOVE_NAME_LENGTH + call TextBox + hlcoord 5 + 2, 2 + 2 + ld a, SCREEN_WIDTH * 2 + ld [Buffer1], a + predef ListMoves + ; wMenuData3 + ld a, $4 + ld [wcfa1], a + ld a, $6 + ld [wcfa2], a + ld a, [wd0eb] + inc a + ld [wcfa3], a + ld a, $1 + ld [wcfa4], a + ld [MenuSelection2], a + ld [wcfaa], a + ld a, $3 + ld [wcfa8], a + ld a, $20 + ld [wcfa5], a + xor a + ld [wcfa6], a + ld a, $20 + ld [wcfa7], a + call Function1bc9 + push af + call Call_LoadTempTileMapToTileMap + pop af + pop hl + bit 1, a + jr nz, .cancel + push hl + ld a, [MenuSelection2] + dec a + ld c, a + ld b, 0 + add hl, bc + ld a, [hl] + push af + push bc + call IsHMMove + pop bc + pop de + ld a, d + jr c, .hmmove + pop hl + add hl, bc + and a + ret + +.hmmove + ld hl, UnknownText_0x669a + call PrintText + pop hl + jr .loop + +.cancel + scf + ret +; 666b + +UnknownText_0x666b: ; 666b +; <MON> learned <MOVE>! + text_jump UnknownText_0x1c5660 + db "@" +; 6670 + +UnknownText_0x6670: ; 6670 +; Which move should be forgotten? + text_jump UnknownText_0x1c5678 + db "@" +; 6675 + +UnknownText_0x6675: ; 6675 +; Stop learning <MOVE>? + text_jump UnknownText_0x1c5699 + db "@" +; 667a + +UnknownText_0x667a: ; 667a +; <MON> did not learn <MOVE>. + text_jump UnknownText_0x1c56af + db "@" +; 667f + +UnknownText_0x667f: ; 667f +; <MON> is trying to learn <MOVE>. But <MON> can't learn more than +; four moves. Delete an older move to make room for <MOVE>? + text_jump UnknownText_0x1c56c9 + db "@" +; 6684 + +UnknownText_0x6684: ; 6684 + text_jump UnknownText_0x1c5740 ; 1, 2 and… + start_asm + push de + ld de, SFX_SWITCH_POKEMON + call PlaySFX + pop de + ld hl, UnknownText_0x6695 + ret +; 6695 + +UnknownText_0x6695: ; 6695 +; Poof! <MON> forgot <MOVE>. And… + text_jump UnknownText_0x1c574e + db "@" +; 669a + +UnknownText_0x669a: ; 669a +; HM moves can't be forgotten now. + text_jump UnknownText_0x1c5772 + db "@" +; 669f diff --git a/engine/link.asm b/engine/link.asm index 8ba1702e9..619cc1375 100755 --- a/engine/link.asm +++ b/engine/link.asm @@ -1891,7 +1891,7 @@ Function28b87: ; 28b87 dec a ld [CurPartyMon], a ld a, $1 - ld [wd1e9], a + ld [wForceEvolution], a ld a, [wd003] push af ld hl, OTPartySpecies diff --git a/engine/math.asm b/engine/math.asm new file mode 100755 index 000000000..0cd6b0b47 --- /dev/null +++ b/engine/math.asm @@ -0,0 +1,196 @@ +_Multiply:: ; 66de + +; hMultiplier is one byte. + ld a, 8 + ld b, a + + xor a + ld [hProduct], a + ld [hMathBuffer + 1], a + ld [hMathBuffer + 2], a + ld [hMathBuffer + 3], a + ld [hMathBuffer + 4], a + + +.loop + ld a, [hMultiplier] + srl a + ld [hMultiplier], a + jr nc, .next + + ld a, [hMathBuffer + 4] + ld c, a + ld a, [hMultiplicand + 2] + add c + ld [hMathBuffer + 4], a + + ld a, [hMathBuffer + 3] + ld c, a + ld a, [hMultiplicand + 1] + adc c + ld [hMathBuffer + 3], a + + ld a, [hMathBuffer + 2] + ld c, a + ld a, [hMultiplicand + 0] + adc c + ld [hMathBuffer + 2], a + + ld a, [hMathBuffer + 1] + ld c, a + ld a, [hProduct] + adc c + ld [hMathBuffer + 1], a + +.next + dec b + jr z, .done + + +; hMultiplicand <<= 1 + + ld a, [hMultiplicand + 2] + add a + ld [hMultiplicand + 2], a + + ld a, [hMultiplicand + 1] + rla + ld [hMultiplicand + 1], a + + ld a, [hMultiplicand + 0] + rla + ld [hMultiplicand + 0], a + + ld a, [hProduct] + rla + ld [hProduct], a + + jr .loop + + +.done + ld a, [hMathBuffer + 4] + ld [hProduct + 3], a + + ld a, [hMathBuffer + 3] + ld [hProduct + 2], a + + ld a, [hMathBuffer + 2] + ld [hProduct + 1], a + + ld a, [hMathBuffer + 1] + ld [hProduct + 0], a + + ret +; 673e + + +_Divide:: ; 673e + xor a + ld [hMathBuffer + 0], a + ld [hMathBuffer + 1], a + ld [hMathBuffer + 2], a + ld [hMathBuffer + 3], a + ld [hMathBuffer + 4], a + + ld a, 9 + ld e, a + +.loop + ld a, [hMathBuffer + 0] + ld c, a + ld a, [hDividend + 1] + sub c + ld d, a + + ld a, [hDivisor] + ld c, a + ld a, [hDividend + 0] + sbc c + jr c, .next + + ld [hDividend + 0], a + + ld a, d + ld [hDividend + 1], a + + ld a, [hMathBuffer + 4] + inc a + ld [hMathBuffer + 4], a + + jr .loop + +.next + ld a, b + cp 1 + jr z, .done + + ld a, [hMathBuffer + 4] + add a + ld [hMathBuffer + 4], a + + ld a, [hMathBuffer + 3] + rla + ld [hMathBuffer + 3], a + + ld a, [hMathBuffer + 2] + rla + ld [hMathBuffer + 2], a + + ld a, [hMathBuffer + 1] + rla + ld [hMathBuffer + 1], a + + dec e + jr nz, .next2 + + ld e, 8 + ld a, [hMathBuffer + 0] + ld [hDivisor], a + xor a + ld [hMathBuffer + 0], a + + ld a, [hDividend + 1] + ld [hDividend + 0], a + + ld a, [hDividend + 2] + ld [hDividend + 1], a + + ld a, [hDividend + 3] + ld [hDividend + 2], a + +.next2 + ld a, e + cp 1 + jr nz, .okay + dec b + +.okay + ld a, [hDivisor] + srl a + ld [hDivisor], a + + ld a, [hMathBuffer + 0] + rr a + ld [hMathBuffer + 0], a + + jr .loop + +.done + ld a, [hDividend + 1] + ld [hDivisor], a + + ld a, [hMathBuffer + 4] + ld [hDividend + 3], a + + ld a, [hMathBuffer + 3] + ld [hDividend + 2], a + + ld a, [hMathBuffer + 2] + ld [hDividend + 1], a + + ld a, [hMathBuffer + 1] + ld [hDividend + 0], a + + ret +; 67c1 diff --git a/engine/party_menu.asm b/engine/party_menu.asm index 06b774064..1c2c70eee 100644 --- a/engine/party_menu.asm +++ b/engine/party_menu.asm @@ -670,7 +670,7 @@ InitPartyMenuGFX: ; 503e0 pop bc dec c jr nz, .loop - callab Function8cf69 + callab PlaySpriteAnimations ret ; 50405 diff --git a/engine/phone.asm b/engine/phone.asm index ab0ecb84a..672ca6042 100644 --- a/engine/phone.asm +++ b/engine/phone.asm @@ -443,9 +443,9 @@ Script_ReceivePhoneCall: ; 0x90241 refreshscreen $0 callasm RingTwice_StartCall ptcall wd048 - closetext + waitbutton callasm HangUp - loadmovesprites + closetext callasm InitCallReceiveDelay end ; 0x90255 diff --git a/engine/phone_scripts.asm b/engine/phone_scripts.asm index 5d0795766..0ce4f017b 100644 --- a/engine/phone_scripts.asm +++ b/engine/phone_scripts.asm @@ -188,7 +188,7 @@ BillPhoneScript1: ; 0xbcfc5 BillPhoneScript2: ; 0xbd007 farwritetext BillPhoneNewlyFullText - closetext + waitbutton end ; Elm diff --git a/engine/pokedex.asm b/engine/pokedex.asm index d150ee471..25111dea1 100644 --- a/engine/pokedex.asm +++ b/engine/pokedex.asm @@ -31,7 +31,7 @@ Pokedex: ; 40000 ld a, [wJumptableIndex] bit 7, a jr nz, .exit - call Function4010b + call Pokedex_Main call DelayFrame jr .main @@ -40,8 +40,8 @@ Pokedex: ; 40000 call PlaySFX call WaitSFX call ClearSprites - ld a, [wc7d4] - ld [wd959], a + ld a, [wCurrentDexMode] + ld [wLastDexMode], a pop af ld [hInMenu], a @@ -63,7 +63,7 @@ InitPokedex: ; 40063 call ClearBGPalettes call ClearSprites call ClearTileMap - call Function414b7 + call Pokedex_LoadGFX ld hl, wPokedexDataStart ld bc, wPokedexDataEnd - wPokedexDataStart @@ -76,78 +76,78 @@ InitPokedex: ; 40063 ld [wcf65], a ld [wcf66], a - call Function400a2 + call Pokedex_CheckUnlockedUnownMode - ld a, [wd959] - ld [wc7d4], a + ld a, [wLastDexMode] + ld [wCurrentDexMode], a - call Function40bdc - call Function400b4 - call Function400ed + call Pokedex_ChangeMode + call Pokedex_InitCursorPosition + call Pokedex_GetLandmark callba Function1de247 - call Function41af7 + call Pokedex_ResetBGMapMode ret ; 400a2 -Function400a2: ; 400a2 +Pokedex_CheckUnlockedUnownMode: ; 400a2 ld a, [StatusFlags] bit 1, a - jr nz, .asm_400ae + jr nz, .unlocked xor a - ld [wc7dc], a + ld [wUnlockedUnownMode], a ret -.asm_400ae - ld a, 1 - ld [wc7dc], a +.unlocked + ld a, TRUE + ld [wUnlockedUnownMode], a ret ; 400b4 -Function400b4: ; 400b4 - ld hl, wc6d0 - ld a, [wc2d6] +Pokedex_InitCursorPosition: ; 400b4 + ld hl, wPokedexDataStart + ld a, [wLastDexEntry] and a - jr z, .asm_400ec - cp $fc - jr nc, .asm_400ec + jr z, .done + cp NUM_POKEMON + 1 + jr nc, .done ld b, a - ld a, [wc7d2] + ld a, [wDexListingEnd] cp $8 - jr c, .asm_400db + jr c, .only_one_page sub $7 ld c, a -.asm_400cc +.loop1 ld a, b cp [hl] - jr z, .asm_400ec + jr z, .done inc hl - ld a, [wc7d0] + ld a, [wDexListingPage] inc a - ld [wc7d0], a + ld [wDexListingPage], a dec c - jr nz, .asm_400cc + jr nz, .loop1 -.asm_400db +.only_one_page ld c, $7 -.asm_400dd +.loop2 ld a, b cp [hl] - jr z, .asm_400ec + jr z, .done inc hl - ld a, [wc7d1] + ld a, [wDexListingCursor] inc a - ld [wc7d1], a + ld [wDexListingCursor], a dec c - jr nz, .asm_400dd + jr nz, .loop2 -.asm_400ec +.done ret ; 400ed -Function400ed: ; 400ed +Pokedex_GetLandmark: ; 400ed ld a, [MapGroup] ld b, a ld a, [MapNumber] @@ -155,7 +155,7 @@ Function400ed: ; 400ed call GetWorldMapLocation cp SPECIAL_MAP - jr nz, .asm_40107 + jr nz, .load ld a, [BackupMapGroup] ld b, a @@ -163,20 +163,20 @@ Function400ed: ; 400ed ld c, a call GetWorldMapLocation -.asm_40107 - ld [wc7e4], a +.load + ld [wDexCurrentLocation], a ret ; 4010b -Function4010b: ; 4010b +Pokedex_Main: ; 4010b ld a, [wJumptableIndex] - ld hl, Jumptable_40115 - call Function41432 + ld hl, .Jumptable + call Pokedex_LoadPointer jp [hl] ; 40115 -Jumptable_40115: ; 40115 (10:4115) +.Jumptable: ; 40115 (10:4115) dw Function4013c dw Function401ae dw Function40217 @@ -188,17 +188,17 @@ Jumptable_40115: ; 40115 (10:4115) dw Function403be dw Function4050a dw Function40562 - dw Function405bd + dw Pokedex_UnownMode ; Unown Dex dw Function405df - dw Function40136 + dw Pokedex_CloseDex ; Exit -Function40131: ; 40131 (10:4131) +Pokedex_IncrementDexPointer: ; 40131 (10:4131) ld hl, wJumptableIndex inc [hl] ret -Function40136: ; 40136 (10:4136) +Pokedex_CloseDex: ; 40136 (10:4136) ld hl, wJumptableIndex set 7, [hl] ret @@ -209,45 +209,46 @@ Function4013c: ; 4013c (10:413c) call ClearSprites xor a hlcoord 0, 0, AttrMap - ld bc, $168 + ld bc, SCREEN_HEIGHT * SCREEN_WIDTH call ByteFill - callba Function1de171 + callba DrawPokedexListWindow hlcoord 0, 17 ld de, String_START_SEARCH - call Function40acd + call Pokedex_PlaceString ld a, $7 ld [wc7d3], a call Function40b0f - call Function41aeb - call Function41af7 + call Pokedex_SetBGMapMode_3ifDMG_4ifCGB + call Pokedex_ResetBGMapMode call Function4074c ld a, $5 ld [hSCX], a - ld a, [wc7d4] - cp $1 + + ld a, [wCurrentDexMode] + cp DEXMODE_OLD ld a, $4a - jr z, .asm_4017b + jr z, .okay ld a, $47 - -.asm_4017b +.okay ld [hWX], a xor a ld [hWY], a call WaitBGMap - call Function41af7 - ld a, $ff + + call Pokedex_ResetBGMapMode + ld a, -1 ld [CurPartySpecies], a ld a, $4 call Function41423 call Function41148 - callba Function1de171 + callba DrawPokedexListWindow hlcoord 0, 17 ld de, String_START_SEARCH - call Function40acd + call Pokedex_PlaceString ld a, $7 ld [wc7d3], a call Function40b0f - call Function40131 + call Pokedex_IncrementDexPointer ret Function401ae: ; 401ae (10:41ae) @@ -270,13 +271,13 @@ Function401ae: ; 401ae (10:41ae) xor a ld [hBGMapMode], a call Function40b0f - call Function41ad7 - call Function41af7 + call Pokedex_SetBGMapMode3 + call Pokedex_ResetBGMapMode ret .a - call Function40bb1 - call Function40bd0 + call Pokedex_GetMonAtCursorPosition + call Pokedex_CheckSeen ret z ld a, $2 ld [wJumptableIndex], a @@ -318,23 +319,23 @@ Function40217: ; 40217 (10:4217) xor a ld [hBGMapMode], a call ClearSprites - call Function41478 + call Pokedex_LoadCurrentFootprint call Function407fd call Function4134f - call Function40bb1 - ld [wc2d6], a - callba Function4424d - call Function40ba0 + call Pokedex_GetMonAtCursorPosition + ld [wLastDexEntry], a + callba DisplayDexEntry + call Pokedex_DrawFootprint call WaitBGMap ld a, $a7 ld [hWX], a - call Function40bb1 + call Pokedex_GetMonAtCursorPosition ld [CurPartySpecies], a ld a, $4 call Function41423 ld a, [CurPartySpecies] call PlayCry - call Function40131 + call Pokedex_IncrementDexPointer ret Function40258: ; 40258 (10:4258) @@ -347,25 +348,25 @@ Function40258: ; 40258 (10:4258) ld a, [hl] and A_BUTTON jr nz, .a - call Function4066c + call Pokedex_NextOrPreviousDexEntry ret nc - call Function40131 + call Pokedex_IncrementDexPointer ret .a ld a, [wc7d8] ld hl, Jumptable_402f2 - call Function41432 + call Pokedex_LoadPointer jp [hl] .b ld a, [LastVolume] and a - jr z, .asm_40288 + jr z, .max_volume ld a, $77 ld [LastVolume], a -.asm_40288 +.max_volume call MaxVolume ld a, [wcf64] ld [wJumptableIndex], a @@ -376,9 +377,9 @@ Function40292: ; 40292 ld a, [wPokedexStatus] xor $1 ld [wPokedexStatus], a - call Function40bb1 - ld [wc2d6], a - callba Function4424d + call Pokedex_GetMonAtCursorPosition + ld [wLastDexEntry], a + callba DisplayDexEntry call WaitBGMap ret ; 402aa @@ -391,14 +392,14 @@ Function402aa: ; 402aa (10:42aa) ld [hBGMapMode], a call Function407fd call Function4134f - call Function41478 - call Function40bb1 - ld [wc2d6], a - callba Function4424d - call Function40ba0 + call Pokedex_LoadCurrentFootprint + call Pokedex_GetMonAtCursorPosition + ld [wLastDexEntry], a + callba DisplayDexEntry + call Pokedex_DrawFootprint call Function4143b call WaitBGMap - call Function40bb1 + call Pokedex_GetMonAtCursorPosition ld [CurPartySpecies], a ld a, $4 call Function41423 @@ -410,11 +411,12 @@ Function402aa: ; 402aa (10:42aa) ; 402e8 (10:42e8) Unknown_402e8: ; 402e8 - dw $0430 + db D_RIGHT | D_LEFT, 4 dwcoord 1, 17 dwcoord 6, 17 dwcoord 11, 17 dwcoord 15, 17 + ; 402f2 Jumptable_402f2: ; 402f2 @@ -433,8 +435,8 @@ Function402fa: ; 402fa ld [hWX], a ld a, $90 ld [hWY], a - call Function40bb1 - ld a, [wc7e4] + call Pokedex_GetMonAtCursorPosition + ld a, [wDexCurrentLocation] ld e, a predef Function91d11 call Function41401 @@ -449,7 +451,7 @@ Function402fa: ; 402fa call Function4038d call Function4143b call WaitBGMap - call Function40bb1 + call Pokedex_GetMonAtCursorPosition ld [CurPartySpecies], a ld a, $4 call Function41423 @@ -457,7 +459,7 @@ Function402fa: ; 402fa ; 40340 Function40340: ; 40340 - call Function40bb1 + call Pokedex_GetMonAtCursorPosition ld a, [wd265] call GetCryIndex ld e, c @@ -485,7 +487,7 @@ Function4034f: ; 4034f ld [wcf65], a call ClearBGPalettes call DisableLCD - call Function414fb + call Pokedex_LoadInvertedFont call Function4038d call EnableLCD call WaitBGMap @@ -497,9 +499,9 @@ Function4034f: ; 4034f Function4038d: ; 4038d call Function407fd - call Function40bb1 - callba Function4424d - call Function40ba0 + call Pokedex_GetMonAtCursorPosition + callba DisplayDexEntry + call Pokedex_DrawFootprint ret ; 4039d @@ -509,17 +511,17 @@ Function4039d: ; 4039d (10:439d) call ClearSprites call Function4087c call Function4134f - ld a, [wc7d4] + ld a, [wCurrentDexMode] ld [wc7d8], a call Function40e5b call WaitBGMap ld a, $10 call Function41423 - call Function40131 + call Pokedex_IncrementDexPointer ret Function403be: ; 403be (10:43be) - ld a, [wc7dc] + ld a, [wUnlockedUnownMode] and a jr nz, .asm_403c9 ld de, Unknown_403f3 @@ -542,7 +544,7 @@ Function403be: ; 403be (10:43be) .asm_403e0 ld a, [wc7d8] ld hl, Jumptable_40405 - call Function41432 + call Pokedex_LoadPointer jp [hl] .asm_403ea @@ -553,17 +555,17 @@ Function403be: ; 403be (10:43be) ; 403f3 (10:43f3) Unknown_403f3: ; 403f3 - dw $03c0 - dwcoord 2, 4 - dwcoord 2, 6 - dwcoord 2, 8 + db D_UP | D_DOWN, 3 + dwcoord 2, 4 + dwcoord 2, 6 + dwcoord 2, 8 ; 403fb Unknown_403fb: ; 403fb - dw $04c0 - dwcoord 2, 4 - dwcoord 2, 6 - dwcoord 2, 8 + db D_UP | D_DOWN, 4 + dwcoord 2, 4 + dwcoord 2, 6 + dwcoord 2, 8 dwcoord 2, 10 ; 40405 @@ -585,17 +587,17 @@ Function40411: ; 40411 (10:4411) Function40415: ; 40415 (10:4415) ld b, $2 Function40417: ; 40417 (10:4417) - ld a, [wc7d4] + ld a, [wCurrentDexMode] cp b jr z, .asm_40431 ld a, b - ld [wc7d4], a - call Function40bdc + ld [wCurrentDexMode], a + call Pokedex_ChangeMode call Function40f08 xor a - ld [wc7d0], a - ld [wc7d1], a - call Function400b4 + ld [wDexListingPage], a + ld [wDexListingCursor], a + call Pokedex_InitCursorPosition .asm_40431 call Function41401 @@ -621,12 +623,12 @@ Function40443: ; 40443 (10:4443) ld [wc7d6], a call Function40fa8 xor a - ld [wc7db], a - callba Function44207 + ld [wDexSearchSlowpokeFrame], a + callba DoDexSearchSlowpokeFrame call WaitBGMap ld a, $10 call Function41423 - call Function40131 + call Pokedex_IncrementDexPointer ret Function40471: ; 40471 (10:4471) @@ -646,7 +648,7 @@ Function40471: ; 40471 (10:4471) .asm_4048b ld a, [wc7d8] ld hl, Jumptable_404a8 - call Function41432 + call Pokedex_LoadPointer jp [hl] .asm_40495 @@ -657,7 +659,7 @@ Function40471: ; 40471 (10:4471) ; 4049e (10:449e) Unknown_4049e: ; 4049e - dw $04c0 + db D_UP | D_DOWN, 4 dwcoord 2, 4 dwcoord 2, 6 dwcoord 2, 13 @@ -679,11 +681,11 @@ Function404b0: ; 404b0 Function404b7: ; 404b7 call Function41086 - callba Function441cf + callba AnimateDexSearchSlowpoke ld a, [wc7d7] and a jr nz, .asm_404dc - call Function40bdc + call Pokedex_ChangeMode call Function41107 xor a ld [hBGMapMode], a @@ -694,16 +696,16 @@ Function404b7: ; 404b7 ret .asm_404dc - ld [wc7d2], a - ld a, [wc7d0] + ld [wDexListingEnd], a + ld a, [wDexListingPage] ld [wc7e0], a - ld a, [wc7d1] + ld a, [wDexListingCursor] ld [wc7e1], a - ld a, [wc2d6] + ld a, [wLastDexEntry] ld [wcf65], a xor a - ld [wc7d0], a - ld [wc7d1], a + ld [wDexListingPage], a + ld [wDexListingCursor], a call Function41401 ld a, $9 ld [wJumptableIndex], a @@ -722,17 +724,17 @@ Function4050a: ; 4050a (10:450a) ld [hBGMapMode], a xor a hlcoord 0, 0, AttrMap - ld bc, $168 + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT call ByteFill - call Function41ae1 - call Function41af7 - callba Function1de1d1 + call Pokedex_SetBGMapMode4 + call Pokedex_ResetBGMapMode + callba DrawPokedexSearchResultsWindow call Function409cf ld a, $4 ld [wc7d3], a call Function40b0f - call Function41ad7 - call Function41af7 + call Pokedex_SetBGMapMode3 + call Pokedex_ResetBGMapMode call Function40962 ld a, $5 ld [hSCX], a @@ -741,15 +743,15 @@ Function4050a: ; 4050a (10:450a) xor a ld [hWY], a call WaitBGMap - call Function41af7 - callba Function1de1d1 + call Pokedex_ResetBGMapMode + callba DrawPokedexSearchResultsWindow call Function409cf call Function41281 ld a, $ff ld [CurPartySpecies], a ld a, $4 call Function41423 - call Function40131 + call Pokedex_IncrementDexPointer ret Function40562: ; 40562 (10:4562) @@ -766,13 +768,13 @@ Function40562: ; 40562 (10:4562) xor a ld [hBGMapMode], a call Function40b0f - call Function41ad7 - call Function41af7 + call Pokedex_SetBGMapMode3 + call Pokedex_ResetBGMapMode ret .asm_40583 - call Function40bb1 - call Function40bd0 + call Pokedex_GetMonAtCursorPosition + call Pokedex_CheckSeen ret z ld a, $2 ld [wJumptableIndex], a @@ -782,14 +784,14 @@ Function40562: ; 40562 (10:4562) .asm_40595 ld a, [wc7e0] - ld [wc7d0], a + ld [wDexListingPage], a ld a, [wc7e1] - ld [wc7d1], a + ld [wDexListingCursor], a ld a, [wcf65] - ld [wc2d6], a + ld [wLastDexEntry], a call Function41401 call ClearSprites - call Function40bdc + call Pokedex_ChangeMode ld a, $5 ld [wJumptableIndex], a xor a @@ -798,45 +800,45 @@ Function40562: ; 40562 (10:4562) ld [hWX], a ret -Function405bd: ; 405bd (10:45bd) - call Function41a2c +Pokedex_UnownMode: ; 405bd (10:45bd) + call Pokedex_LoadUnownFont call Function409f1 xor a ld [wc7dd], a call Function41a58 call Function40658 - callba Functionfba2e + callba PrintUnownWord call WaitBGMap ld a, $16 call Function41423 - call Function40131 + call Pokedex_IncrementDexPointer ret Function405df: ; 405df (10:45df) ld hl, hJoyPressed ; $ffa7 ld a, [hl] and A_BUTTON | B_BUTTON - jr nz, .asm_405eb + jr nz, .a_b call Function40610 ret -.asm_405eb +.a_b call Function41401 ld a, $7 ld [wJumptableIndex], a call DelayFrame - call Function41a24 - jr nz, .asm_40603 + call Pokedex_CheckSGB + jr nz, .decompress callba Function1ddf26 - jr .asm_4060f + jr .done -.asm_40603 +.decompress ld hl, PokedexLZ ld de, VTiles2 tile $31 lb bc, BANK(PokedexLZ), $3a call DecompressRequest2bpp -.asm_4060f +.done ret Function40610: ; 40610 (10:4610) @@ -859,7 +861,7 @@ Function40610: ; 40610 (10:4610) ret nc ld a, [hl] inc [hl] - jr .asm_40635 + jr .update .left ld hl, wc7dd @@ -869,7 +871,7 @@ Function40610: ; 40610 (10:4610) ld a, [hl] dec [hl] -.asm_40635 +.update push af xor a ld [hBGMapMode], a @@ -877,7 +879,7 @@ Function40610: ; 40610 (10:4610) call Function40654 call Function41a58 call Function40658 - callba Functionfba2e + callba PrintUnownWord ld a, $1 ld [hBGMapMode], a call DelayFrame @@ -904,11 +906,11 @@ endr ld [hl], c ret -Function4066c: ; 4066c (10:466c) - ld a, [wc7d1] - ld [wc7e2], a - ld a, [wc7d0] - ld [wc7e3], a +Pokedex_NextOrPreviousDexEntry: ; 4066c (10:466c) + ld a, [wDexListingCursor] + ld [wBackupDexListingCursor], a + ld a, [wDexListingPage] + ld [wBackupDexListingPage], a ld hl, hJoyLast ld a, [hl] and D_UP @@ -922,43 +924,43 @@ Function4066c: ; 4066c (10:466c) .up ld a, [wc7d3] ld d, a - ld a, [wc7d2] + ld a, [wDexListingEnd] ld e, a call Function406ea - jr nc, .asm_406b7 - call Function40bb1 - call Function40bd0 - jr nz, .asm_406b5 + jr nc, .nope + call Pokedex_GetMonAtCursorPosition + call Pokedex_CheckSeen + jr nz, .yep jr .up .down ld a, [wc7d3] ld d, a - ld a, [wc7d2] + ld a, [wDexListingEnd] ld e, a call Function406fe - jr nc, .asm_406b7 - call Function40bb1 - call Function40bd0 - jr nz, .asm_406b5 + jr nc, .nope + call Pokedex_GetMonAtCursorPosition + call Pokedex_CheckSeen + jr nz, .yep jr .down -.asm_406b5 +.yep scf ret -.asm_406b7 - ld a, [wc7e2] - ld [wc7d1], a - ld a, [wc7e3] - ld [wc7d0], a +.nope + ld a, [wBackupDexListingCursor] + ld [wDexListingCursor], a + ld a, [wBackupDexListingPage] + ld [wDexListingPage], a and a ret Function406c5: ; 406c5 (10:46c5) ld a, [wc7d3] ld d, a - ld a, [wc7d2] + ld a, [wDexListingEnd] ld e, a ld hl, hJoyLast ld a, [hl] @@ -979,14 +981,14 @@ Function406c5: ; 406c5 (10:46c5) jr asm_4073d Function406ea: ; 406ea (10:46ea) - ld hl, wc7d1 + ld hl, wDexListingCursor ld a, [hl] and a jr z, .asm_406f4 dec [hl] jr asm_4073f .asm_406f4 - ld hl, wc7d0 + ld hl, wDexListingPage ld a, [hl] and a jr z, asm_4073d @@ -994,7 +996,7 @@ Function406ea: ; 406ea (10:46ea) jr asm_4073f Function406fe: ; 406fe (10:46fe) - ld hl, wc7d1 + ld hl, wDexListingCursor ld a, [hl] inc a cp e @@ -1004,14 +1006,14 @@ Function406fe: ; 406fe (10:46fe) inc [hl] jr asm_4073f .asm_4070c - ld hl, wc7d0 + ld hl, wDexListingPage add [hl] cp e jr nc, asm_4073d inc [hl] jr asm_4073f asm_40716: ; 40716 (10:4716) - ld hl, wc7d0 + ld hl, wDexListingPage ld a, [hl] and a jr z, asm_4073d @@ -1025,7 +1027,7 @@ asm_40716: ; 40716 (10:4716) ld [hl], a jr asm_4073f asm_40728: ; 40728 (10:4728) - ld hl, wc7d0 + ld hl, wDexListingPage ld a, d add a add [hl] @@ -1065,20 +1067,20 @@ Function40741: ; 40741 Function4074c: ; 4074c (10:474c) hlcoord 0, 17 ld de, String_START_SEARCH - call Function40acd + call Pokedex_PlaceString ld a, $32 hlcoord 0, 0 - ld bc, $168 + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT call ByteFill hlcoord 0, 0 lb bc, 7, 7 - call Function40ad5 + call Pokedex_PlaceBorder hlcoord 0, 9 ld bc, $607 - call Function40ad5 + call Pokedex_PlaceBorder hlcoord 1, 11 ld de, String_SEEN - call Function40acd + call Pokedex_PlaceString ld hl, PokedexSeen ; wdeb9 (aliases: EndPokedexSeen) ld b, EndPokedexSeen - PokedexSeen call CountSetBits @@ -1088,7 +1090,7 @@ Function4074c: ; 4074c (10:474c) call PrintNum hlcoord 1, 14 ld de, String_OWN - call Function40acd + call Pokedex_PlaceString ld hl, PokedexCaught ld b, EndPokedexCaught - PokedexCaught call CountSetBits @@ -1098,7 +1100,7 @@ Function4074c: ; 4074c (10:474c) call PrintNum hlcoord 1, 17 ld de, String_SELECT_OPTION - call Function40acd + call Pokedex_PlaceString hlcoord 8, 1 ld b, $7 ld a, $5a @@ -1115,7 +1117,7 @@ Function4074c: ; 4074c (10:474c) ld [hl], $54 hlcoord 8, 16 ld [hl], $5b - call Function40ab2 + call Pokedex_PlaceFrontpicTopLeftCorner ret ; 407e1 (10:47e1) @@ -1130,10 +1132,10 @@ String_START_SEARCH: ; 407f2 ; 407fd Function407fd: ; 407fd - call Function40aa6 + call Pokedex_FillBackgroundColor2 hlcoord 0, 0 ld bc, $0f12 - call Function40ad5 + call Pokedex_PlaceBorder hlcoord 19, 0 ld [hl], $34 hlcoord 19, 1 @@ -1151,14 +1153,14 @@ Function407fd: ; 407fd call ByteFill hlcoord 9, 7 ld de, Unknown_40852 - call Function40acd + call Pokedex_PlaceString hlcoord 9, 9 ld de, Unknown_4085c - call Function40acd + call Pokedex_PlaceString hlcoord 0, 17 ld de, Unknown_40867 - call Function40acd - call Function40ab2 + call Pokedex_PlaceString + call Pokedex_PlaceFrontpicTopLeftCorner ret ; 4084f @@ -1173,20 +1175,20 @@ Unknown_40867: ; 40867 ; 4087c Function4087c: ; 4087c (10:487c) - call Function40aa6 + call Pokedex_FillBackgroundColor2 hlcoord 0, 2 lb bc, 8, 18 - call Function40ad5 + call Pokedex_PlaceBorder hlcoord 0, 12 lb bc, 4, 18 - call Function40ad5 + call Pokedex_PlaceBorder hlcoord 0, 1 ld de, Unknown_408b2 - call Function40acd + call Pokedex_PlaceString hlcoord 3, 4 ld de, String_408bd call PlaceString - ld a, [wc7dc] + ld a, [wUnlockedUnownMode] and a ret z hlcoord 3, 10 @@ -1211,19 +1213,19 @@ String_408e5: ; 408e5 ; 408f0 Function408f0: ; 408f0 (10:48f0) - call Function40aa6 + call Pokedex_FillBackgroundColor2 hlcoord 0, 2 lb bc, 14, 18 - call Function40ad5 + call Pokedex_PlaceBorder hlcoord 0, 1 ld de, Unknown_4092a - call Function40acd + call Pokedex_PlaceString hlcoord 8, 4 ld de, Unknown_40935 - call Function40acd + call Pokedex_PlaceString hlcoord 8, 6 ld de, Unknown_40935 - call Function40acd + call Pokedex_PlaceString hlcoord 3, 4 ld de, String_40940 call PlaceString @@ -1254,13 +1256,13 @@ String_4094c: ; 4094c ; 40962 Function40962: ; 40962 (10:4962) - call Function40aa6 + call Pokedex_FillBackgroundColor2 hlcoord 0, 0 lb bc, 7, 7 - call Function40ad5 + call Pokedex_PlaceBorder hlcoord 0, 11 lb bc, 5, 18 - call Function40ad5 + call Pokedex_PlaceBorder hlcoord 1, 12 ld de, String_409ae call PlaceString @@ -1280,7 +1282,7 @@ Function40962: ; 40962 (10:4962) ld [hl], $69 hlcoord 8, 10 ld [hl], $6a - call Function40ab2 + call Pokedex_PlaceFrontpicTopLeftCorner ret ; 409ae (10:49ae) @@ -1310,28 +1312,28 @@ Function409cf: ; 409cf (10:49cf) ret Function409f1: ; 409f1 (10:49f1) - call Function40aa6 + call Pokedex_FillBackgroundColor2 hlcoord 2, 1 lb bc, 10, 13 - call Function40ad5 + call Pokedex_PlaceBorder hlcoord 2, 14 lb bc, 1, 13 - call Function40ad5 + call Pokedex_PlaceBorder hlcoord 2, 15 ld [hl], $3d hlcoord 16, 15 ld [hl], $3e hlcoord 6, 5 - call Function40ab5 + call Pokedex_PlaceFrontpicAtHL ld de, 0 ld b, 0 ld c, 26 -.asm_40a1d +.loop ld hl, UnownDex add hl, de ld a, [hl] and a - jr z, .asm_40a39 + jr z, .done push af ld hl, Unknown_40a3e rept 4 @@ -1341,19 +1343,20 @@ endr ld h, [hl] ld l, a pop af - add $3f + add $40 - 1 ; Unown A ld [hl], a inc de inc b dec c - jr nz, .asm_40a1d -.asm_40a39 + jr nz, .loop +.done ld a, b ld [wc7de], a ret ; 40a3e (10:4a3e) Unknown_40a3e: ; 40a3e +; letter, cursor dwcoord 4,11, 3,11 dwcoord 4,10, 3,10 dwcoord 4, 9, 3, 9 @@ -1382,7 +1385,7 @@ Unknown_40a3e: ; 40a3e dwcoord 14,10, 15,10 ; 40aa6 -Function40aa6: ; 40aa6 +Pokedex_FillBackgroundColor2: ; 40aa6 hlcoord 0, 0 ld a, $32 ld bc, SCREEN_WIDTH * SCREEN_HEIGHT @@ -1390,113 +1393,118 @@ Function40aa6: ; 40aa6 ret ; 40ab2 -Function40ab2: ; 40ab2 +Pokedex_PlaceFrontpicTopLeftCorner: ; 40ab2 hlcoord 1, 1 -Function40ab5: ; 40ab5 +Pokedex_PlaceFrontpicAtHL: ; 40ab5 xor a ld b, $7 -.asm_40ab8 +.row ld c, $7 push af push hl -.asm_40abc +.col ld [hli], a add $7 dec c - jr nz, .asm_40abc + jr nz, .col pop hl - ld de, $0014 + ld de, SCREEN_WIDTH add hl, de pop af inc a dec b - jr nz, .asm_40ab8 + jr nz, .row ret ; 40acd -Function40acd: ; 40acd -.asm_40acd +Pokedex_PlaceString: ; 40acd +.loop ld a, [de] - cp $ff + cp -1 ret z inc de ld [hli], a - jr .asm_40acd + jr .loop ; 40ad5 -Function40ad5: ; 40ad5 +Pokedex_PlaceBorder: ; 40ad5 push hl ld a, $33 ld [hli], a ld d, $34 - call Function40b06 + call .FillRow ld a, $35 ld [hl], a pop hl - ld de, $0014 + ld de, SCREEN_WIDTH add hl, de -.asm_40ae6 +.loop push hl ld a, $36 ld [hli], a ld d, $7f - call Function40b06 + call .FillRow ld a, $37 ld [hl], a pop hl - ld de, $0014 + ld de, SCREEN_WIDTH add hl, de dec b - jr nz, .asm_40ae6 + jr nz, .loop ld a, $38 ld [hli], a ld d, $39 - call Function40b06 + call .FillRow ld a, $3a ld [hl], a ret ; 40b06 -Function40b06: ; 40b06 +.FillRow: ; 40b06 ld e, c -.asm_40b07 +.row_loop ld a, e and a ret z ld a, d ld [hli], a dec e - jr .asm_40b07 + jr .row_loop ; 40b0f Function40b0f: ; 40b0f (10:4b0f) - ld a, [wc7d4] - cp $1 - jr z, .asm_40b1a - ld c, $b - jr .asm_40b1c -.asm_40b1a - ld c, $b -.asm_40b1c +; This check is completely useless. + ld a, [wCurrentDexMode] + cp DEXMODE_OLD + jr z, .okay + ld c, 11 + jr .resume +.okay + ld c, 11 +; End useless check +.resume +; Clear (2 * [wc7d3] + 1) by 11 box starting at 0,1 hlcoord 0, 1 ld a, [wc7d3] add a inc a ld b, a - ld a, $7f - call Function413fe - ld a, [wc7d0] + ld a, " " + call Pokedex_FillBox + +; Load de with wPokedexDataStart + [wDexListingPage] + ld a, [wDexListingPage] ld e, a ld d, $0 - ld hl, wc6d0 + ld hl, wPokedexDataStart add hl, de ld e, l ld d, h hlcoord 0, 2 ld a, [wc7d3] -.asm_40b3c +.loop push af ld a, [de] ld [wd265], a @@ -1504,37 +1512,38 @@ Function40b0f: ; 40b0f (10:4b0f) push hl call Function40b55 pop hl - ld de, $28 + ld de, 2 * SCREEN_WIDTH add hl, de pop de inc de pop af dec a - jr nz, .asm_40b3c + jr nz, .loop call Function4143b ret Function40b55: ; 40b55 (10:4b55) and a ret z - call Function40b6a - call Function40b8d + call Pokedex_PrintNumberIfOldMode + call Pokedex_PlaceDefaultStringIfNotSeen ret c - call Function40b82 + call Pokedex_PlaceCaughtSymbolIfCaught push hl call GetPokemonName pop hl call PlaceString ret -Function40b6a: ; 40b6a (10:4b6a) - ld a, [wc7d4] - cp $1 - jr z, .asm_40b72 +Pokedex_PrintNumberIfOldMode: ; 40b6a (10:4b6a) + ld a, [wCurrentDexMode] + cp DEXMODE_OLD + jr z, .printnum ret -.asm_40b72 + +.printnum push hl - ld de, -20 + ld de, -SCREEN_WIDTH add hl, de ld de, wd265 lb bc, PRINTNUM_LEADINGZEROS | 1, 3 @@ -1542,31 +1551,32 @@ Function40b6a: ; 40b6a (10:4b6a) pop hl ret -Function40b82: ; 40b82 (10:4b82) - call Function40bc4 - jr nz, .asm_40b89 +Pokedex_PlaceCaughtSymbolIfCaught: ; 40b82 (10:4b82) + call Pokedex_CheckCaught + jr nz, .place_caught_symbol inc hl ret -.asm_40b89 + +.place_caught_symbol ld a, $4f ld [hli], a ret -Function40b8d: ; 40b8d (10:4b8d) - call Function40bd0 +Pokedex_PlaceDefaultStringIfNotSeen: ; 40b8d (10:4b8d) + call Pokedex_CheckSeen ret nz inc hl - ld de, String_40b9a + ld de, .NameNotSeen call PlaceString scf ret ; 40b9a (10:4b9a) -String_40b9a: ; 40b9a +.NameNotSeen: ; 40b9a db "-----@" ; 40ba0 -Function40ba0: ; 40ba0 +Pokedex_DrawFootprint: ; 40ba0 hlcoord 18, 1 ld a, $62 ld [hli], a @@ -1581,13 +1591,13 @@ Function40ba0: ; 40ba0 ; 40bb1 -Function40bb1: ; 40bb1 - ld a, [wc7d1] - ld hl, wc7d0 +Pokedex_GetMonAtCursorPosition: ; 40bb1 + ld a, [wDexListingCursor] + ld hl, wDexListingPage add [hl] ld e, a ld d, $0 - ld hl, wc6d0 + ld hl, wPokedexDataStart add hl, de ld a, [hl] ld [wd265], a @@ -1595,7 +1605,7 @@ Function40bb1: ; 40bb1 ; 40bc4 -Function40bc4: ; 40bc4 (10:4bc4) +Pokedex_CheckCaught: ; 40bc4 (10:4bc4) push de push hl ld a, [wd265] @@ -1606,7 +1616,7 @@ Function40bc4: ; 40bc4 (10:4bc4) ret -Function40bd0: ; 40bd0 +Pokedex_CheckSeen: ; 40bd0 push de push hl ld a, [wd265] @@ -1619,100 +1629,100 @@ Function40bd0: ; 40bd0 -Function40bdc: ; 40bdc - ld hl, wc6d0 - ld bc, $100 +Pokedex_ChangeMode: ; 40bdc + ld hl, wPokedexDataStart + ld bc, wPokedexMetadata - wPokedexDataStart xor a call ByteFill - ld a, [wc7d4] - ld hl, Jumptable_40bf0 - call Function41432 + ld a, [wCurrentDexMode] + ld hl, .Jumptable + call Pokedex_LoadPointer jp [hl] ; 40bf0 -Jumptable_40bf0: ; 40bf0 (10:4bf0) - dw Function40bf6 - dw Function40c08 - dw Function40c30 +.Jumptable: ; 40bf0 (10:4bf0) + dw .NewMode + dw .OldMode + dw Pokedex_ABCMode -Function40bf6: ; 40bf6 (10:4bf6) +.NewMode: ; 40bf6 (10:4bf6) ld de, NewPokedexOrder - ld hl, wc6d0 + ld hl, wPokedexDataStart ld c, NUM_POKEMON -.asm_40bfe +.loopnew ld a, [de] inc de ld [hli], a dec c - jr nz, .asm_40bfe - call Function40c18 + jr nz, .loopnew + call .FindLastSeen ret -Function40c08: ; 40c08 (10:4c08) - ld hl, wc6d0 +.OldMode: ; 40c08 (10:4c08) + ld hl, wPokedexDataStart ld a, $1 ld c, NUM_POKEMON -.asm_40c0f +.loopold ld [hli], a inc a dec c - jr nz, .asm_40c0f - call Function40c18 + jr nz, .loopold + call .FindLastSeen ret -Function40c18: ; 40c18 (10:4c18) - ld hl, wc7ca +.FindLastSeen: ; 40c18 (10:4c18) + ld hl, wPokedexDataStart + NUM_POKEMON - 1 ld d, NUM_POKEMON ld e, d -.asm_40c1e +.loopfindend ld a, [hld] ld [wd265], a - call Function40bd0 - jr nz, .asm_40c2b + call Pokedex_CheckSeen + jr nz, .foundend dec d dec e - jr nz, .asm_40c1e -.asm_40c2b + jr nz, .loopfindend +.foundend ld a, d - ld [wc7d2], a + ld [wDexListingEnd], a ret -Function40c30: ; 40c30 +Pokedex_ABCMode: ; 40c30 xor a - ld [wc7d2], a - ld hl, wc6d0 + ld [wDexListingEnd], a + ld hl, wPokedexDataStart ld de, AlphabeticalPokedexOrder ld c, NUM_POKEMON -.asm_40c3c +.loop1abc push bc ld a, [de] ld [wd265], a - call Function40bd0 - jr z, .asm_40c51 + call Pokedex_CheckSeen + jr z, .skipabc ld a, [wd265] ld [hli], a - ld a, [wc7d2] + ld a, [wDexListingEnd] inc a - ld [wc7d2], a + ld [wDexListingEnd], a -.asm_40c51 +.skipabc inc de pop bc dec c - jr nz, .asm_40c3c - ld a, [wc7d2] + jr nz, .loop1abc + ld a, [wDexListingEnd] ld c, 0 -.asm_40c5b +.loop2abc cp NUM_POKEMON - jr z, .asm_40c64 + jr z, .doneabc ld [hl], c inc hl inc a - jr .asm_40c5b + jr .loop2abc -.asm_40c64 +.doneabc ret ; 40c65 @@ -1726,11 +1736,11 @@ Function40e5b: ; 40e5b xor a ld [hBGMapMode], a hlcoord 0, 12 - ld bc, $0412 - call Function40ad5 + lb bc, 4, SCREEN_WIDTH - 2 + call Pokedex_PlaceBorder ld a, [wc7d8] ld hl, Unknown_40e7d - call Function41432 + call Pokedex_LoadPointer ld e, l ld d, h hlcoord 1, 14 @@ -1741,28 +1751,28 @@ Function40e5b: ; 40e5b ; 40e7d Unknown_40e7d: ; 40e7d - dw String_40e85 - dw String_40ea6 - dw String_40ec6 - dw String_40ee4 + dw .NewMode + dw .OldMode + dw .ABCMode + dw .UnownMode ; 40e85 -String_40e85: ; 40e85 - db $e1, $e2, " are listed by" +.NewMode: ; 40e85 + db "<PK><MN> are listed by" next "evolution type.@" ; 40ea6 -String_40ea6: ; 40ea6 - db $e1, $e2, " are listed by" +.OldMode: ; 40ea6 + db "<PK><MN> are listed by" next "official type.@" ; 40ec6 -String_40ec6: ; 40ec6 - db $e1, $e2, " are listed" +.ABCMode: ; 40ec6 + db "<PK><MN> are listed" next "alphabetically.@" ; 40ee4 -String_40ee4: ; 40ee4 +.UnownMode: ; 40ee4 db "UNOWN are listed" next "in catching order.@" ; 40f08 @@ -1771,24 +1781,25 @@ Function40f08: ; 40f08 (10:4f08) xor a ld [hBGMapMode], a hlcoord 0, 12 - ld bc, $412 - call Function40ad5 - ld de, String_40f32 + lb bc, 4, SCREEN_WIDTH - 2 + call Pokedex_PlaceBorder + ld de, String_ChangingModesPleaseWait hlcoord 1, 14 call PlaceString ld a, $1 ld [hBGMapMode], a - ld c, $40 + ld c, 64 call DelayFrames ld de, SFX_CHANGE_DEX_MODE call PlaySFX - ld c, $40 + ld c, 64 call DelayFrames ret ; 40f32 (10:4f32) -String_40f32: ; 40f32 - db "Changing modes.", $4e, "Please wait.@" +String_ChangingModesPleaseWait: ; 40f32 + db "Changing modes." + next "Please wait.@" ; 40f4f Function40f4f: ; 40f4f (10:4f4f) @@ -1861,7 +1872,7 @@ Function40fa8: ; 40fa8 (10:4fa8) hlcoord 9, 3 ld bc, $408 ld a, $7f - call Function413fe + call Pokedex_FillBox ld a, [wc7d5] hlcoord 9, 4 call Function40fcd @@ -1926,8 +1937,8 @@ Function41095: ; 41095 add hl, de ld a, [hl] ld [wc7df], a - ld hl, wc6d0 - ld de, wc6d0 + ld hl, wPokedexDataStart + ld de, wPokedexDataStart ld c, NUM_POKEMON xor a ld [wc7d7], a @@ -1938,7 +1949,7 @@ Function41095: ; 41095 jr z, .asm_410e0 ld [wd265], a ld [CurSpecies], a - call Function40bc4 + call Pokedex_CheckCaught jr z, .asm_410e0 push hl push de @@ -2008,7 +2019,7 @@ Function41107: ; 41107 ld [hBGMapMode], a hlcoord 0, 12 ld bc, $0412 - call Function40ad5 + call Pokedex_PlaceBorder ld de, String_41126 hlcoord 1, 14 call PlaceString @@ -2025,7 +2036,7 @@ String_41126: ; 41126 ; 41148 Function41148: ; 41148 (10:5148) - ld a, [wc7d4] + ld a, [wCurrentDexMode] cp $1 jp z, Function41157 call Function41229 @@ -2034,7 +2045,7 @@ Function41148: ; 41148 (10:5148) Function41157: ; 41157 (10:5157) ld hl, Unknown_41167 - ld a, [wc7d1] + ld a, [wDexListingCursor] or a jr nz, .asm_41163 ld hl, Unknown_411c8 @@ -2133,7 +2144,7 @@ Unknown_41230: ; 41230 ; 41281 Function41281: ; 41281 (10:5281) - ld a, [wc7d4] + ld a, [wCurrentDexMode] cp $1 jp z, Function41157 ld hl, Unknown_41290 @@ -2176,7 +2187,7 @@ Function412f1: ; 412f1 (10:52f1) ld a, [hl] cp $ff ret z - ld a, [wc7d1] + ld a, [wDexListingCursor] and $7 swap a add [hl] @@ -2196,11 +2207,11 @@ Function412f1: ; 412f1 (10:52f1) Function4130e: ; 4130e (10:530e) push de - ld a, [wc7d2] + ld a, [wDexListingEnd] dec a ld e, a - ld a, [wc7d1] - ld hl, wc7d0 + ld a, [wDexListingCursor] + ld hl, wDexListingPage add [hl] cp e jr z, .asm_4133f @@ -2213,7 +2224,7 @@ Function4130e: ; 4130e (10:530e) ld a, d or e jr z, .asm_41341 - ld a, [wc7d2] + ld a, [wDexListingEnd] ld c, a .asm_41333 ld a, e @@ -2247,6 +2258,7 @@ Function4134f: ; 4134f (10:534f) ret Function4135a: ; 4135a (10:535a) +; bc = [de] - 1 ld a, [de] ld b, a inc de @@ -2254,74 +2266,79 @@ Function4135a: ; 4135a (10:535a) dec a ld c, a inc de - call Function413e0 + call Pokedex_BlinkInfoScreenCursor + ld hl, hJoyPressed ; $ffa7 ld a, [hl] and D_LEFT | D_UP and b - jr nz, .asm_4138f + jr nz, .MoveCursorLeft ld a, [hl] and D_RIGHT | D_DOWN and b - jr nz, .asm_413a0 + jr nz, .MoveCursorRight ld a, [hl] and SELECT and b - jr nz, .asm_413c1 - call Function413f5 - jr c, .asm_413bf + jr nz, .Select + call Pokedex_CursorFrameDelay + jr c, .NoAction ld hl, hJoyLast ld a, [hl] and D_LEFT | D_UP and b - jr nz, .asm_4138f + jr nz, .MoveCursorLeft ld a, [hl] and D_RIGHT | D_DOWN and b - jr nz, .asm_413a0 - jr .asm_413bf -.asm_4138f + jr nz, .MoveCursorRight + jr .NoAction + +.MoveCursorLeft ld a, [wc7d8] and a - jr z, .asm_413bf - call Function413d4 - ld [hl], $7f + jr z, .NoAction + call Pokedex_GetCursorPosition + ld [hl], " " ld hl, wc7d8 dec [hl] - jr .asm_413af -.asm_413a0 + jr .UpdateCursorPosition + +.MoveCursorRight ld a, [wc7d8] cp c - jr nc, .asm_413bf - call Function413d4 - ld [hl], $7f + jr nc, .NoAction + call Pokedex_GetCursorPosition + ld [hl], " " ld hl, wc7d8 inc [hl] -.asm_413af - call Function413d4 - ld [hl], $ed +.UpdateCursorPosition + call Pokedex_GetCursorPosition + ld [hl], "▶" ld a, $c ld [wc7d9], a xor a ld [wc7da], a scf ret -.asm_413bf + +.NoAction and a ret -.asm_413c1 - call Function413d4 - ld [hl], $7f + +.Select + call Pokedex_GetCursorPosition + ld [hl], " " ld a, [wc7d8] cp c - jr c, .asm_413ce + jr c, .Update ld a, $ff -.asm_413ce +.Update inc a ld [wc7d8], a - jr .asm_413af + jr .UpdateCursorPosition -Function413d4: ; 413d4 (10:53d4) +Pokedex_GetCursorPosition: ; 413d4 (10:53d4) ld a, [wc7d8] add a ld l, a @@ -2332,30 +2349,32 @@ Function413d4: ; 413d4 (10:53d4) ld l, a ret -Function413e0: ; 413e0 (10:53e0) +Pokedex_BlinkInfoScreenCursor: ; 413e0 (10:53e0) ld hl, wc7da ld a, [hl] inc [hl] and $8 - jr z, .asm_413ef - call Function413d4 - ld [hl], $7f + jr z, .blink_on + call Pokedex_GetCursorPosition + ld [hl], " " ret -.asm_413ef - call Function413d4 - ld [hl], $ed + +.blink_on + call Pokedex_GetCursorPosition + ld [hl], "▶" ret -Function413f5: ; 413f5 (10:53f5) +Pokedex_CursorFrameDelay: ; 413f5 (10:53f5) ld hl, wc7d9 ld a, [hl] and a ret z + dec [hl] scf ret -Function413fe: ; 413fe (10:53fe) +Pokedex_FillBox: ; 413fe (10:53fe) jp FillBoxWithByte Function41401: ; 41401 (10:5401) @@ -2391,7 +2410,7 @@ Function41427: ; 41427 ; 41432 -Function41432: ; 41432 +Pokedex_LoadPointer: ; 41432 ld e, a ld d, 0 rept 2 @@ -2404,10 +2423,10 @@ endr ; 4143b Function4143b: ; 4143b - call Function40bb1 - call Function40bd0 - jr z, .asm_4145b - ld a, [wdef4] + call Pokedex_GetMonAtCursorPosition + call Pokedex_CheckSeen + jr z, .QuestionMark + ld a, [wFirstUnownSeen] ld [UnownLetter], a ld a, [wd265] ld [CurPartySpecies], a @@ -2416,10 +2435,10 @@ Function4143b: ; 4143b predef GetFrontpic ret -.asm_4145b +.QuestionMark ld a, BANK(sScratch) call GetSRAMBank - callba Function1de0d7 + callba LoadQuestionMarkPic ld hl, VTiles2 ld de, sScratch ld c, 7 * 7 @@ -2431,13 +2450,13 @@ Function4143b: ; 4143b ; 41478 -Function41478: ; 41478 (10:5478) - call Function40bb1 +Pokedex_LoadCurrentFootprint: ; 41478 (10:5478) + call Pokedex_GetMonAtCursorPosition -Function4147b: ; 4147b +Pokedex_LoadAnyFootprint: ; 4147b ld a, [wd265] dec a - and $f8 + and ($ff ^ $07) ; $f8 ; $1f << 3 srl a srl a srl a @@ -2463,7 +2482,7 @@ Function4147b: ; 4147b ; Whoever was editing footprints forgot to fix their ; tile editor. Now each bottom half is 8 tiles off. - ld de, $80 + ld de, 8 tiles add hl, de ld e, l @@ -2476,28 +2495,28 @@ Function4147b: ; 4147b ; 414b7 -Function414b7: ; 414b7 +Pokedex_LoadGFX: ; 414b7 call DisableLCD ld hl, VTiles2 - ld bc, $0310 + ld bc, $31 tiles xor a call ByteFill - call Function414fb + call Pokedex_LoadInvertedFont call LoadFontsExtra ld hl, VTiles2 tile $60 - ld bc, $0200 - call Function41504 - call Function41a24 - jr nz, .asm_414e0 - callba Function1ddf1c - jr .asm_414e9 - -.asm_414e0 + ld bc, $20 tiles + call Pokedex_InvertTiles + call Pokedex_CheckSGB + jr nz, .LoadPokedexLZ + callba LoadSGBPokedexGFX + jr .LoadPokedexSlowpokeLZ + +.LoadPokedexLZ ld hl, PokedexLZ ld de, VTiles2 tile $31 call Decompress -.asm_414e9 +.LoadPokedexSlowpokeLZ ld hl, PokedexSlowpokeLZ ld de, VTiles0 call Decompress @@ -2506,30 +2525,31 @@ Function414b7: ; 414b7 call EnableLCD ret -Function414fb: ; 414fb +Pokedex_LoadInvertedFont: ; 414fb call LoadStandardFont ld hl, VTiles1 - ld bc, $0800 + ld bc, $80 tiles -Function41504: ; 41504 +Pokedex_InvertTiles: ; 41504 +.loop ld a, [hl] xor $ff ld [hli], a dec bc ld a, b or c - jr nz, Function41504 + jr nz, .loop ret ; 4150e PokedexLZ: ; 4150e -INCBIN "gfx/unknown/04150e.2bpp.lz" +INCBIN "gfx/pokedex/pokedex.2bpp.lz" ; 416b0 PokedexSlowpokeLZ: ; 416b0 INCBIN "gfx/pokedex/slowpoke.2bpp.lz" -Function41a24: ; 41a24 +Pokedex_CheckSGB: ; 41a24 ld a, [hCGB] or a ret nz @@ -2538,26 +2558,25 @@ Function41a24: ; 41a24 ret ; 41a2c -Function41a2c: ; 41a2c +Pokedex_LoadUnownFont: ; 41a2c ld a, BANK(sScratch) call GetSRAMBank ld hl, UnownFont ld de, sScratch + $188 - ld bc, $270 + ld bc, 39 tiles ld a, BANK(UnownFont) call FarCopyBytes ld hl, sScratch + $188 - ld bc, $1b0 - call Function41504 + ld bc, 27 tiles + call Pokedex_InvertTiles ld de, sScratch + $188 ld hl, VTiles2 tile $40 - lb bc, BANK(Function41a2c), $1b + lb bc, BANK(Pokedex_LoadUnownFont), 27 call Request2bpp call CloseSRAM ret ; 41a58 - Function41a58: ; 41a58 (10:5a58) ld a, [UnownLetter] push af @@ -2576,3 +2595,68 @@ Function41a58: ; 41a58 (10:5a58) pop af ld [UnownLetter], a ret +; 41a7f + +_NewPokedexEntry: ; 41a7f + xor a + ld [hBGMapMode], a + callba Function1de247 + call Pokedex_ResetBGMapMode + call DisableLCD + call LoadStandardFont + call LoadFontsExtra + call Pokedex_LoadGFX + call Pokedex_LoadAnyFootprint + ld a, [wd265] + ld [CurPartySpecies], a + call Function407fd + call Pokedex_DrawFootprint + hlcoord 0, 17 + ld [hl], $3b + inc hl + ld bc, 19 + ld a, " " + call ByteFill + callba DisplayDexEntry + call EnableLCD + call WaitBGMap + call GetBaseData + ld de, VTiles2 + predef GetFrontpic + ld a, $4 + call Function41423 + ld a, [CurPartySpecies] + call PlayCry + ret +; 41ad7 + + +Pokedex_SetBGMapMode3: ; 41ad7 (10:5ad7) + ld a, $3 + ld [hBGMapMode], a + ld c, 4 + call DelayFrames + ret + +Pokedex_SetBGMapMode4: ; 41ae1 (10:5ae1) + ld a, $4 + ld [hBGMapMode], a + ld c, 4 + call DelayFrames + ret + +Pokedex_SetBGMapMode_3ifDMG_4ifCGB: ; 41aeb (10:5aeb) + ld a, [hCGB] + and a + jr z, .DMG + call Pokedex_SetBGMapMode4 +.DMG + call Pokedex_SetBGMapMode3 + ret + + +Pokedex_ResetBGMapMode: ; 41af7 + xor a + ld [hBGMapMode], a + ret +; 41afb diff --git a/engine/pokegear.asm b/engine/pokegear.asm index da6006853..a89e48b5e 100755 --- a/engine/pokegear.asm +++ b/engine/pokegear.asm @@ -24,7 +24,7 @@ PokeGear: ; 90b8d (24:4b8d) bit 7, a jr nz, .done call Function90f04 - callba Function8cf69 + callba PlaySpriteAnimations call DelayFrame jr .loop @@ -1966,7 +1966,7 @@ _FlyMap: ; 91af3 jr nz, .pressedA call FlyMapScroll call GetMapCursorCoordinates - callba Function8cf69 + callba PlaySpriteAnimations call DelayFrame jr .loop @@ -2901,7 +2901,7 @@ Function92311: ; unreferenced jr nz, .pressedA call Function923b8 call GetMapCursorCoordinates - callba Function8cf69 + callba PlaySpriteAnimations call DelayFrame jr .loop diff --git a/engine/printer.asm b/engine/printer.asm index 5330d6b3c..5db2f9ff2 100755 --- a/engine/printer.asm +++ b/engine/printer.asm @@ -672,7 +672,7 @@ PrintDexEntry: ; 8442c call Function84000 ld a, $10 ld [wcbfa], a - callba Function1dc1b0 + callba PrintPage1 call ClearTileMap ld a, $e4 call DmgToCgbBGPals @@ -694,7 +694,7 @@ PrintDexEntry: ; 8442c call Function84000 ld a, $3 ld [wcbfa], a - callba Function1dc213 + callba PrintPage2 call Function84742 ld a, $4 ld [wcf65], a diff --git a/engine/save.asm b/engine/save.asm index 20f59c042..0feb9fd84 100644 --- a/engine/save.asm +++ b/engine/save.asm @@ -182,7 +182,7 @@ AskOverwriteSaveFile: ; 14b89 ld a, [wSaveFileExists] and a jr z, .erase - call Function14bcb + call CompareLoadedAndSavedPlayerID jr z, .yoursavefile ld hl, UnknownText_0x15297 call SaveTheGame_yesorno @@ -223,7 +223,7 @@ SaveTheGame_yesorno: ; 14baf ret ; 14bcb -Function14bcb: ; 14bcb +CompareLoadedAndSavedPlayerID: ; 14bcb ld a, BANK(sPlayerData) call GetSRAMBank ld hl, sPlayerData + (PlayerID - wPlayerData) @@ -291,7 +291,7 @@ SaveGameData_: ; 14c10 ld a, BANK(sBattleTowerChallengeState) call GetSRAMBank ld a, [sBattleTowerChallengeState] - cp $4 + cp BATTLETOWER_RECEIVED_REWARD jr nz, .ok xor a ld [sBattleTowerChallengeState], a @@ -373,7 +373,7 @@ ErasePreviousSave: ; 14cbb call EraseLinkBattleStats call EraseMysteryGift call SaveData - call Function14d5c + call EraseBattleTowerStatus ld a, BANK(sStackTop) call GetSRAMBank xor a @@ -437,7 +437,7 @@ Unknown_14d2c: ; 14d2c db $11, $0c, $0c, $06, $06, $04 ; 14d5c -Function14d5c: ; 14d5c +EraseBattleTowerStatus: ; 14d5c ld a, BANK(sBattleTowerChallengeState) call GetSRAMBank xor a @@ -486,7 +486,7 @@ Function14d93: ; 14d93 ; 14da0 -Function14da0: ; 14da0 +HallOfFame_InitSaveIfNeeded: ; 14da0 ld a, [wSavedAtLeastOnce] and a ret nz @@ -512,7 +512,7 @@ SaveOptions: ; 14dbb ld bc, OptionsEnd - Options call CopyBytes ld a, [Options] - and $ef + and $ff ^ (1 << NO_TEXT_SCROLL) ld [sOptions], a jp CloseSRAM ; 14dd7 @@ -791,9 +791,9 @@ LoadPlayerData: ; 14fd7 (5:4fd7) ld a, BANK(sBattleTowerChallengeState) call GetSRAMBank ld a, [sBattleTowerChallengeState] - cp $4 + cp BATTLETOWER_RECEIVED_REWARD jr nz, .not_4 - ld a, $3 + ld a, BATTLETOWER_WON_CHALLENGE ld [sBattleTowerChallengeState], a .not_4 call CloseSRAM diff --git a/engine/scripting.asm b/engine/scripting.asm index c80343a4c..698508cf4 100644 --- a/engine/scripting.asm +++ b/engine/scripting.asm @@ -143,7 +143,7 @@ ScriptCommandTable: ; 96cb1 dw Script_pocketisfull dw Script_loadfont dw Script_refreshscreen - dw Script_loadmovesprites + dw Script_closetext dw Script_loadbytec2cf dw Script_farwritetext dw Script_writetext @@ -156,26 +156,26 @@ IF _CRYSTAL dw Script_farjumptext ENDC dw Script_jumptext - dw Script_closetext + dw Script_waitbutton dw Script_keeptextopen dw Script_pokepic - dw Script_pokepicyesorno + dw Script_closepokepic dw Script_interpretmenu dw Script_interpretmenu2 dw Script_loadpikachudata - dw Script_battlecheck - dw Script_loadtrainerdata - dw Script_loadpokedata - dw Script_loadtrainer + dw Script_setup_random_encounter + dw Script_memtrainerdata + dw Script_scriptedpokedata + dw Script_scriptedtrainerdata dw Script_startbattle dw Script_returnafterbattle dw Script_catchtutorial dw Script_trainertext - dw Script_trainerstatus + dw Script_trainerflagaction dw Script_winlosstext dw Script_scripttalkafter - dw Script_talkaftercancel - dw Script_talkaftercheck + dw Script_end_if_just_battled + dw Script_check_just_battled dw Script_setlasttalked dw Script_applymovement dw Script_applymovement2 @@ -200,13 +200,13 @@ ENDC dw Script_writecmdqueue dw Script_delcmdqueue dw Script_playmusic - dw Script_playrammusic + dw Script_encountermusic dw Script_musicfadeout dw Script_playmapmusic dw Script_reloadmapmusic dw Script_cry dw Script_playsound - dw Script_waitbutton + dw Script_waitsfx dw Script_warpsound dw Script_specialsound dw Script_passtoengine @@ -316,11 +316,11 @@ Script_jumptextfaceplayer: ; 96e45 ; text_pointer (RawTextPointerLabelParam) ld a, [ScriptBank] - ld [wd44e], a + ld [wScriptTextBank], a call GetScriptByte - ld [wd44f], a + ld [wScriptTextAddr], a call GetScriptByte - ld [wd450], a + ld [wScriptTextAddr + 1], a ld b, BANK(JumpTextFacePlayerScript) ld hl, JumpTextFacePlayerScript jp ScriptJump @@ -332,11 +332,11 @@ Script_jumptext: ; 96e5f ; text_pointer (RawTextPointerLabelParam) ld a, [ScriptBank] - ld [wd44e], a + ld [wScriptTextBank], a call GetScriptByte - ld [wd44f], a + ld [wScriptTextAddr], a call GetScriptByte - ld [wd450], a + ld [wScriptTextAddr + 1], a ld b, BANK(JumpTextScript) ld hl, JumpTextScript jp ScriptJump @@ -347,8 +347,8 @@ JumpTextFacePlayerScript: ; 96e79 JumpTextScript: ; 96e7a loadfont repeattext -1, -1 + waitbutton closetext - loadmovesprites end ; 96e81 @@ -361,11 +361,11 @@ Script_farjumptext: ; 96e81 ; text_pointer (PointerLabelBeforeBank) call GetScriptByte - ld [wd44e], a + ld [wScriptTextBank], a call GetScriptByte - ld [wd44f], a + ld [wScriptTextAddr], a call GetScriptByte - ld [wd450], a + ld [wScriptTextAddr + 1], a ld b, BANK(JumpTextScript) ld hl, JumpTextScript jp ScriptJump @@ -419,7 +419,7 @@ Script_repeattext: ; 96ebb ld a, l cp -1 jr nz, .done - ld hl, wd44e + ld hl, wScriptTextBank ld a, [hli] ld b, a ld a, [hli] @@ -427,14 +427,15 @@ Script_repeattext: ; 96ebb ld l, a call MapTextbox ret + .done ret ; 96ed9 -Script_closetext: ; 96ed9 +Script_waitbutton: ; 96ed9 ; script command 0x54 - jp CloseText + jp WaitButton ; 96edc Script_keeptextopen: ; 96edc @@ -455,9 +456,9 @@ Script_yesorno: ; 96eed ; script command 0x4e call YesNoBox - ld a, 0 + ld a, FALSE jr c, .no - ld a, 1 + ld a, TRUE .no ld [ScriptVar], a ret @@ -502,10 +503,10 @@ Script_pokepic: ; 96f16 ret ; 96f29 -Script_pokepicyesorno: ; 96f29 +Script_closepokepic: ; 96f29 ; script command 0x57 - callba PokepicYesOrNo + callba ClosePokepic ret ; 96f30 @@ -575,9 +576,9 @@ GiveItemScript: ; 96f77 callasm ret_96f76 writetext ReceivedItemText iffalse .Full - waitbutton + waitsfx specialsound - closetext + waitbutton itemnotify end @@ -611,7 +612,7 @@ Script_verbosegiveitem2: ; 96f8e ld [wItemQuantityChangeBuffer], a ld hl, NumItems call ReceiveItem - ld a, 1 + ld a, TRUE jr c, .ok2 xor a .ok2 @@ -748,7 +749,7 @@ Script_elevator: ; 9707c ld b, a callba Elevator ret c - ld a, $1 + ld a, TRUE ld [ScriptVar], a ret ; 97099 @@ -885,7 +886,7 @@ Script_scripttalkafter: ; 97125 jp ScriptJump ; 97132 -Script_trainerstatus: ; 97132 +Script_trainerflagaction: ; 97132 ; script command 0x63 ; parameters: ; action (SingleByteParam) @@ -902,7 +903,7 @@ Script_trainerstatus: ; 97132 ld a, c and a ret z - ld a, 1 + ld a, TRUE ld [ScriptVar], a ret ; 9714c @@ -926,7 +927,7 @@ Script_winlosstext: ; 9714c ret ; 97163 -Script_talkaftercancel: ; 97163 +Script_end_if_just_battled: ; 97163 ; script command 0x66 ld a, [wRunningTrainerBattleScript] @@ -935,10 +936,10 @@ Script_talkaftercancel: ; 97163 jp Script_end ; 9716b -Script_talkaftercheck: ; 9716b +Script_check_just_battled: ; 9716b ; script command 0x67 - ld a, 1 + ld a, TRUE ld [ScriptVar], a ld a, [wRunningTrainerBattleScript] and a @@ -948,7 +949,7 @@ Script_talkaftercheck: ; 9716b ret ; 9717a -Script_playrammusic: ; 9717a +Script_encountermusic: ; 9717a ; script command 0x80 ld a, [OtherTrainerClass] @@ -1011,7 +1012,7 @@ Script_playsound: ; 971b7 ret ; 971c3 -Script_waitbutton: ; 971c3 +Script_waitsfx: ; 971c3 ; script command 0x86 call WaitSFX @@ -1481,7 +1482,7 @@ Script_loadpikachudata: ; 973f0 ret ; 973fb -Script_battlecheck: ; 973fb +Script_setup_random_encounter: ; 973fb ; script command 0x5b xor a @@ -1489,7 +1490,7 @@ Script_battlecheck: ; 973fb ret ; 97400 -Script_loadtrainerdata: ; 97400 +Script_memtrainerdata: ; 97400 ; script command 0x5c ld a, (1 << 7) | 1 @@ -1501,7 +1502,7 @@ Script_loadtrainerdata: ; 97400 ret ; 97412 -Script_loadpokedata: ; 97412 +Script_scriptedpokedata: ; 97412 ; script command 0x5d ; parameters: ; pokemon (PokemonParam) @@ -1516,7 +1517,7 @@ Script_loadpokedata: ; 97412 ret ; 97424 -Script_loadtrainer: ; 97424 +Script_scriptedtrainerdata: ; 97424 ; script command 0x5e ; parameters: ; trainer_group (TrainerGroupParam) @@ -1862,11 +1863,11 @@ Script_priorityjump: ; 975aa ; pointer (ScriptPointerLabelParam) ld a, [ScriptBank] - ld [wd44e], a + ld [wPriorityScriptBank], a call GetScriptByte - ld [wd44f], a + ld [wPriorityScriptAddr], a call GetScriptByte - ld [wd450], a + ld [wPriorityScriptAddr + 1], a ld hl, ScriptFlags set 3, [hl] ret @@ -2362,7 +2363,7 @@ Script_giveitem: ; 977ca ld hl, NumItems call ReceiveItem jr nc, .full - ld a, $1 + ld a, TRUE ld [ScriptVar], a ret .full @@ -2388,7 +2389,7 @@ Script_takeitem: ; 977f0 ld hl, NumItems call TossItem ret nc - ld a, $1 + ld a, TRUE ld [ScriptVar], a ret ; 97812 @@ -2405,7 +2406,7 @@ Script_checkitem: ; 97812 ld hl, NumItems call CheckItem ret nc - ld a, 1 + ld a, TRUE ld [ScriptVar], a ret ; 97829 @@ -2534,7 +2535,7 @@ Script_checktime: ; 978ae call GetScriptByte and c ret z - ld a, $1 + ld a, TRUE ld [ScriptVar], a ret ; 978c3 @@ -2551,7 +2552,7 @@ Script_checkpoke: ; 978c3 ld de, 1 call IsInArray ret nc - ld a, 1 + ld a, TRUE ld [ScriptVar], a ret ; 978da @@ -2567,7 +2568,7 @@ Script_addcellnum: ; 978da ld c, a callba AddPhoneNumber ret nc - ld a, $1 + ld a, TRUE ld [ScriptVar], a ret ; 978ef @@ -2583,7 +2584,7 @@ Script_delcellnum: ; 978ef ld c, a callba DelCellNum ret nc - ld a, $1 + ld a, TRUE ld [ScriptVar], a ret ; 97904 @@ -2600,7 +2601,7 @@ Script_checkcellnum: ; 97904 ld c, a callba CheckCellNum ret nc - ld a, $1 + ld a, TRUE ld [ScriptVar], a ret ; 97919 @@ -2624,7 +2625,7 @@ Script_checkphonecall: ; 97926 ld a, [wSpecialPhoneCallID] and a jr z, .ok - ld a, 1 + ld a, TRUE .ok ld [ScriptVar], a ret @@ -2728,7 +2729,7 @@ Script_checkevent: ; 979a4 ld a, c and a jr z, .false - ld a, 1 + ld a, TRUE .false ld [ScriptVar], a ret @@ -2743,7 +2744,7 @@ Script_setflag: ; 979bb ld e, a call GetScriptByte ld d, a - ld b, 1 ; set + ld b, SET_FLAG call _EngineFlagAction ret ; 979c9 @@ -2757,7 +2758,7 @@ Script_clearflag: ; 979c9 ld e, a call GetScriptByte ld d, a - ld b, 0 ; clear + ld b, RESET_FLAG call _EngineFlagAction ret ; 979d7 @@ -2776,7 +2777,7 @@ Script_checkflag: ; 979d7 ld a, c and a jr z, .false - ld a, 1 + ld a, TRUE .false ld [ScriptVar], a ret @@ -3053,15 +3054,15 @@ Script_loadbytec2cf: ; 97b27 ; 97b2e -LoadMoveSpritesScript: ; 97b2e - loadmovesprites +CloseTextScript: ; 97b2e + closetext ; 97b2f -Script_loadmovesprites: ; 97b2f +Script_closetext: ; 97b2f ; script command 0x49 call Function2e20 - call LoadMoveSprites + call CloseText ret ; 97b36 @@ -3217,8 +3218,6 @@ Script_credits: ; 97bf3 ; script command 0xa2 callba RedCredits - ; fallthrough - DisplayCredits: call Script_resetfuncs ld a, $3 diff --git a/engine/selectmenu.asm b/engine/selectmenu.asm index 916e48b3c..9de31192b 100755 --- a/engine/selectmenu.asm +++ b/engine/selectmenu.asm @@ -9,8 +9,8 @@ SelectMenu:: ; 13327 ld b, BANK(ItemMayBeRegisteredText) ld hl, ItemMayBeRegisteredText call MapTextbox - call CloseText - jp LoadMoveSprites + call WaitButton + jp CloseText ; 13340 @@ -141,7 +141,7 @@ UseRegisteredItem: ; 133c3 .NoFunction ; 133df call LoadFont call CantUseItem - call LoadMoveSprites + call CloseText and a ret ; 133ea @@ -149,7 +149,7 @@ UseRegisteredItem: ; 133c3 .Current ; 133ea call LoadFont call DoItemEffect - call LoadMoveSprites + call CloseText and a ret ; 133f5 @@ -159,7 +159,7 @@ UseRegisteredItem: ; 133c3 call FadeToMenu call DoItemEffect call ReturnToCallingMenu - call LoadMoveSprites + call CloseText and a ret ; 13406 @@ -185,7 +185,7 @@ UseRegisteredItem: ; 133c3 ._cantuse call CantUseItem - call LoadMoveSprites + call CloseText and a ret ; 1342d diff --git a/engine/sprites.asm b/engine/sprites.asm index f12ed1de8..77e3b68b7 100755 --- a/engine/sprites.asm +++ b/engine/sprites.asm @@ -12,12 +12,12 @@ Function8cf53: ; 8cf53 ; 8cf62 Function8cf62: ; 8cf62 - call Function8cf69 + call PlaySpriteAnimations call DelayFrame ret ; 8cf69 -Function8cf69: ; 8cf69 +PlaySpriteAnimations: ; 8cf69 push hl push de push bc @@ -35,7 +35,7 @@ Function8cf69: ; 8cf69 ; 8cf7a Function8cf7a: ; 8cf7a - ld hl, wc314 + ld hl, wSpriteAnimationStructs ld e, 10 ; There are 10 structs here. .loop @@ -114,10 +114,10 @@ Function8cfa8: ; 8cfa8 (23:4fa8) ret InitSpriteAnimStruct:: ; 8cfd6 -; Find if there's any room in the wc314 array, which is 10x16 +; Find if there's any room in the wSpriteAnimationStructs array, which is 10x16 push de push af - ld hl, wc314 + ld hl, wSpriteAnimationStructs ld e, 10 .loop ld a, [hl] @@ -221,8 +221,8 @@ Function8d036: ; 8d036 Function8d03d: ; 8d03d (23:503d) -; Clear the index field of every struct in the wc314 array. - ld hl, wc314 +; Clear the index field of every struct in the wSpriteAnimationStructs array. + ld hl, wSpriteAnimationStructs ld bc, $10 ld e, 10 xor a @@ -622,7 +622,7 @@ endr dw .sixteen dw .seventeen dw .eighteen - dw .nineteen + dw .nineteen ; finish egg hatching animation dw .twenty dw .twentyone dw .twentytwo ; flying sprite @@ -761,7 +761,7 @@ endr ld a, [hl] add $3 ld [hl], a - call .asm_8d6de + call .ApplyYOffset ld hl, $7 add hl, bc ld [hl], a @@ -779,7 +779,7 @@ endr inc a ld [hl], a ld d, $2 - call .asm_8d6de + call .ApplyYOffset ld hl, $7 add hl, bc ld [hl], a @@ -818,13 +818,13 @@ endr ld a, [hl] push af push de - call .asm_8d6de + call .ApplyYOffset ld hl, $7 add hl, bc ld [hl], a pop de pop af - call .asm_8d6e2 + call .ApplyXOffset ld hl, $6 add hl, bc ld [hl], a @@ -856,13 +856,13 @@ endr ld a, [hl] push af push de - call .asm_8d6de + call .ApplyYOffset ld hl, $7 add hl, bc ld [hl], a pop de pop af - call .asm_8d6e2 + call .ApplyXOffset ld hl, $6 add hl, bc ld [hl], a @@ -947,14 +947,14 @@ endr .asm_8d462 ld a, e ld d, $20 - call .asm_8d6de + call .ApplyYOffset ld hl, $7 add hl, bc ld [hl], a ret .thirteen: ; 8d46e (23:546e) - callab Functione00ed + callab ret_e00ed ret .fifteen: ; 8d475 (23:5475) @@ -1014,7 +1014,7 @@ endr jr c, .asm_8d4cd dec [hl] ld d, $28 - call .asm_8d6de + call .ApplyYOffset ld hl, $7 add hl, bc ld [hl], a @@ -1049,7 +1049,7 @@ endr ld hl, $c add hl, bc ld a, [hl] - call Function8e72c + call ApplyYOffset ld hl, $7 add hl, bc ld [hl], a @@ -1108,33 +1108,36 @@ endr ret .nineteen: ; 8d54a (23:554a) - ld hl, $c + ld hl, SpriteAnim1Sprite0c - SpriteAnim1 add hl, bc ld a, [hl] cp $80 - jr nc, .asm_8d574 + jr nc, .finish_nineteen ld d, a add $8 ld [hl], a - ld hl, $b + ld hl, SpriteAnim1Sprite0b - SpriteAnim1 add hl, bc ld a, [hl] xor $20 ld [hl], a + push af push de - call .asm_8d6de - ld hl, $7 + call .ApplyYOffset + ld hl, SpriteAnim1YOffset - SpriteAnim1 add hl, bc ld [hl], a + pop de pop af - call .asm_8d6e2 - ld hl, $6 + call .ApplyXOffset + ld hl, SpriteAnim1XOffset - SpriteAnim1 add hl, bc ld [hl], a ret -.asm_8d574 + +.finish_nineteen call Function8d036 ret @@ -1165,13 +1168,13 @@ rept 3 endr push af push de - call .asm_8d6de + call .ApplyYOffset ld hl, $7 add hl, bc ld [hl], a pop de pop af - call .asm_8d6e2 + call .ApplyXOffset ld hl, $6 add hl, bc ld [hl], a @@ -1207,7 +1210,7 @@ endr add hl, bc ld a, [hl] inc [hl] - call .asm_8d6e2 + call .ApplyXOffset ld hl, $6 add hl, bc ld [hl], a @@ -1230,7 +1233,7 @@ endr add hl, bc ld a, [hl] inc [hl] - call .asm_8d6e2 + call .ApplyXOffset ld hl, $6 add hl, bc ld [hl], a @@ -1263,7 +1266,7 @@ endr add hl, bc ld a, [hl] inc [hl] - call .asm_8d6e2 + call .ApplyXOffset ld hl, $6 add hl, bc ld [hl], a @@ -1294,7 +1297,7 @@ endr xor $ff inc a ld d, $20 - call .asm_8d6de + call .ApplyYOffset ld hl, $7 add hl, bc ld [hl], a @@ -1313,7 +1316,7 @@ endr xor $ff inc a ld d, $20 - call .asm_8d6de + call .ApplyYOffset ld hl, $7 add hl, bc ld [hl], a @@ -1332,13 +1335,13 @@ endr ld a, [hl] push af push de - call .asm_8d6de + call .ApplyYOffset ld hl, $7 add hl, bc ld [hl], a pop de pop af - call .asm_8d6e2 + call .ApplyXOffset ld hl, $6 add hl, bc ld [hl], a @@ -1393,12 +1396,12 @@ endr ret ; 8d6de -.asm_8d6de: ; 8d6de (23:56de) - call Function8e72c +.ApplyYOffset: ; 8d6de (23:56de) + call ApplyYOffset ret -.asm_8d6e2: ; 8d6e2 (23:56e2) - call Function8e72a +.ApplyXOffset: ; 8d6e2 (23:56e2) + call ApplyXOffset ret ; 8d6e6 (23:56e6) @@ -2839,17 +2842,17 @@ Unknown_8e706: ; Broken 2bpp pointers dbbw $10, $24, $672a ; 16-tile 2bpp at 24:672a (inside Function926f7) dbbw $10, $21, $672a ; 16-tile 2bpp at 21:672a (inside Function8671c) -Function8e72a: ; 8e72a +ApplyXOffset: ; 8e72a add $10 -Function8e72c: ; 8e72c +ApplyYOffset: ; 8e72c and $3f cp $20 - jr nc, .asm_8e737 + jr nc, .xflip call Function8e741 ld a, h ret -.asm_8e737 +.xflip and $1f call Function8e741 ld a, h @@ -2862,7 +2865,7 @@ Function8e741: ; 8e741 ld e, a ld a, d ld d, 0 - ld hl, Unknown_8e75d + ld hl, .sinewave rept 2 add hl, de endr @@ -2870,54 +2873,54 @@ endr inc hl ld d, [hl] ld hl, 0 -.asm_8e750 +.loop srl a - jr nc, .asm_8e755 + jr nc, .skip_add add hl, de -.asm_8e755 +.skip_add sla e rl d and a - jr nz, .asm_8e750 + jr nz, .loop ret ; 8e75d -Unknown_8e75d: ; 8e75d +.sinewave: ; 8e75d sine_wave $100 -Function8e79d: ; 8e79d +AnimateEndOfExpBar: ; 8e79d ld a, [hSGB] - ld de, GFX_8e7f4 + ld de, EndOfExpBarGFX and a - jr z, .asm_8e7a8 - ld de, GFX_8e804 + jr z, .load + ld de, SGBEndOfExpBarGFX -.asm_8e7a8 - ld hl, VTiles0 - lb bc, BANK(GFX_8e7f4), 1 +.load + ld hl, VTiles0 tile $00 + lb bc, BANK(EndOfExpBarGFX), 1 call Request2bpp ld c, $8 ld d, $0 -.asm_8e7b5 +.loop push bc - call Function8e7c6 + call .AnimateFrame call DelayFrame pop bc rept 2 inc d endr dec c - jr nz, .asm_8e7b5 + jr nz, .loop call ClearSprites ret ; 8e7c6 -Function8e7c6: ; 8e7c6 +.AnimateFrame: ; 8e7c6 ld hl, Sprites ld c, $8 -.asm_8e7cb +.anim_loop ld a, c and a ret z @@ -2927,32 +2930,35 @@ Function8e7c6: ; 8e7c6 sla a sla a push af + push de push hl - call Function8e72c + call ApplyYOffset pop hl pop de - add $68 + add 13 * 8 ld [hli], a + pop af push de push hl - call Function8e72a + call ApplyXOffset pop hl pop de - add $54 + add 10 * 8 + 4 ld [hli], a + ld a, $0 ld [hli], a - ld a, $6 + ld a, $6 ; OBJ 6 ld [hli], a - jr .asm_8e7cb + jr .anim_loop ; 8e7f4 -GFX_8e7f4: ; 8e7f4 -INCBIN "gfx/unknown/08e7f4.2bpp" -GFX_8e804: ; 8e804 -INCBIN "gfx/unknown/08e804.2bpp" +EndOfExpBarGFX: ; 8e7f4 +INCBIN "gfx/battle/expbarend.2bpp" +SGBEndOfExpBarGFX: ; 8e804 +INCBIN "gfx/battle/expbarend_sgb.2bpp" ClearSpriteAnims: ; 8e814 push hl diff --git a/engine/startmenu.asm b/engine/startmenu.asm index a40aa734e..a0b6c5c0e 100755 --- a/engine/startmenu.asm +++ b/engine/startmenu.asm @@ -61,8 +61,8 @@ endr .MenuReturns dw .Reopen dw .Exit - dw .ExitMenuCallFuncLoadMoveSprites - dw .ExitMenuRunScriptLoadMoveSprites + dw .ExitMenuCallFuncCloseText + dw .ExitMenuRunScriptCloseText dw .ExitMenuRunScript dw .ReturnEnd dw .ReturnRedraw @@ -78,7 +78,7 @@ endr .ReturnEnd call ExitMenu .ReturnEnd2 - call LoadMoveSprites + call CloseText call UpdateTimePals ret @@ -115,14 +115,14 @@ endr ret ; 12699 -.ExitMenuRunScriptLoadMoveSprites ; 12699 +.ExitMenuRunScriptCloseText ; 12699 call ExitMenu ld a, HMENURETURN_SCRIPT ld [hMenuReturn], a jr .ReturnEnd2 ; 126a2 -.ExitMenuCallFuncLoadMoveSprites ; 126a2 +.ExitMenuCallFuncCloseText ; 126a2 call ExitMenu ld hl, wQueuedScriptAddr ld a, [hli] diff --git a/engine/std_scripts.asm b/engine/std_scripts.asm index a886dbbf3..93a5ec2f5 100644 --- a/engine/std_scripts.asm +++ b/engine/std_scripts.asm @@ -138,8 +138,8 @@ PokeCenterNurseScript: spriteface LAST_TALKED, DOWN pause 10 + waitbutton closetext - loadmovesprites end .pokerus @@ -148,14 +148,14 @@ PokeCenterNurseScript: iftrue .pokerus_comcenter farwritetext UnknownText_0x1b0241 + waitbutton closetext - loadmovesprites jump .pokerus_done .pokerus_comcenter farwritetext UnknownText_0x1b02d6 + waitbutton closetext - loadmovesprites .pokerus_done setflag ENGINE_POKERUS @@ -183,9 +183,9 @@ MerchandiseShelfScript: TownMapScript: loadfont farwritetext TownMapText - closetext + waitbutton special Special_TownMap - loadmovesprites + closetext end WindowScript: @@ -194,8 +194,8 @@ WindowScript: TVScript: loadfont farwritetext TVText + waitbutton closetext - loadmovesprites end HomepageScript: @@ -205,7 +205,7 @@ Radio1Script: loadfont writebyte $0 special MapRadio - loadmovesprites + closetext end Radio2Script: @@ -213,7 +213,7 @@ Radio2Script: loadfont writebyte $4 special MapRadio - loadmovesprites + closetext end TrashCanScript: ; 0xbc1a5 @@ -222,7 +222,7 @@ TrashCanScript: ; 0xbc1a5 PCScript: loadfont special PokemonCenterPC - loadmovesprites + closetext end ElevatorButtonScript: @@ -319,7 +319,7 @@ BugContestResultsScript: clearevent EVENT_CONTEST_OFFICER_HAS_BERRY loadfont farwritetext ContestResults_ReadyToJudgeText - closetext + waitbutton special BugContestJudging RAM2MEM $0 if_equal 1, BugContestResults_FirstPlace @@ -327,7 +327,7 @@ BugContestResultsScript: if_equal 3, BugContestResults_ThirdPlace farwritetext ContestResults_ConsolationPrizeText keeptextopen - waitbutton + waitsfx verbosegiveitem BERRY iffalse BugContestResults_NoRoomForBerry @@ -345,16 +345,16 @@ BugContestResults_FinishUp checkevent EVENT_LEFT_MONS_WITH_CONTEST_OFFICER iffalse BugContestResults_DidNotLeaveMons farwritetext ContestResults_ReturnPartyText - closetext + waitbutton special ContestReturnMons BugContestResults_DidNotLeaveMons special CheckPartyFullAfterContest if_equal $0, BugContestResults_CleanUp if_equal $2, BugContestResults_CleanUp farwritetext ContestResults_PartyFullText - closetext + waitbutton BugContestResults_CleanUp - loadmovesprites + closetext dotrigger $0 domaptrigger ROUTE_35_NATIONAL_PARK_GATE, $0 setevent EVENT_BUG_CATCHING_CONTESTANT_1A @@ -386,7 +386,7 @@ BugContestResults_FirstPlace ; 0xbc31e setevent EVENT_GAVE_KURT_APRICORNS itemtotext SUN_STONE, $1 farwritetext ContestResults_PlayerWonAPrizeText - closetext + waitbutton verbosegiveitem SUN_STONE iffalse BugContestResults_NoRoomForSunStone jump BugContestResults_ReturnAfterWinnersPrize @@ -395,7 +395,7 @@ BugContestResults_FirstPlace ; 0xbc31e BugContestResults_SecondPlace ; 0xbc332 itemtotext EVERSTONE, $1 farwritetext ContestResults_PlayerWonAPrizeText - closetext + waitbutton verbosegiveitem EVERSTONE iffalse BugContestResults_NoRoomForEverstone jump BugContestResults_ReturnAfterWinnersPrize @@ -404,7 +404,7 @@ BugContestResults_SecondPlace ; 0xbc332 BugContestResults_ThirdPlace ; 0xbc343 itemtotext GOLD_BERRY, $1 farwritetext ContestResults_PlayerWonAPrizeText - closetext + waitbutton verbosegiveitem GOLD_BERRY iffalse BugContestResults_NoRoomForGoldBerry jump BugContestResults_ReturnAfterWinnersPrize @@ -793,7 +793,7 @@ AskNumber2MScript: RegisteredNumberMScript: farwritetext RegisteredNumber1Text playsound SFX_REGISTER_PHONE_NUMBER - waitbutton + waitsfx keeptextopen end @@ -822,103 +822,103 @@ NumberAcceptedMScript: .Jack farwritetext JackNumberAcceptedText + waitbutton closetext - loadmovesprites end .Huey farwritetext HueyNumberAcceptedText + waitbutton closetext - loadmovesprites end .Gaven farwritetext GavenNumberAcceptedText + waitbutton closetext - loadmovesprites end .Jose farwritetext JoseNumberAcceptedText + waitbutton closetext - loadmovesprites end .Joey farwritetext JoeyNumberAcceptedText + waitbutton closetext - loadmovesprites end .Wade farwritetext WadeNumberAcceptedText + waitbutton closetext - loadmovesprites end .Ralph farwritetext RalphNumberAcceptedText + waitbutton closetext - loadmovesprites end .Anthony farwritetext AnthonyNumberAcceptedText + waitbutton closetext - loadmovesprites end .Todd farwritetext ToddNumberAcceptedText + waitbutton closetext - loadmovesprites end .Irwin farwritetext IrwinNumberAcceptedText + waitbutton closetext - loadmovesprites end .Arnie farwritetext ArnieNumberAcceptedText + waitbutton closetext - loadmovesprites end .Alan farwritetext AlanNumberAcceptedText + waitbutton closetext - loadmovesprites end .Chad farwritetext ChadNumberAcceptedText + waitbutton closetext - loadmovesprites end .Derek farwritetext DerekNumberAcceptedText + waitbutton closetext - loadmovesprites end .Tully farwritetext TullyNumberAcceptedText + waitbutton closetext - loadmovesprites end .Brent farwritetext BrentNumberAcceptedText + waitbutton closetext - loadmovesprites end .Vance farwritetext VanceNumberAcceptedText + waitbutton closetext - loadmovesprites end .Wilton farwritetext WiltonNumberAcceptedText + waitbutton closetext - loadmovesprites end .Kenji farwritetext KenjiNumberAcceptedText + waitbutton closetext - loadmovesprites end .Parry farwritetext ParryNumberAcceptedText + waitbutton closetext - loadmovesprites end NumberDeclinedMScript: @@ -946,103 +946,103 @@ NumberDeclinedMScript: .Jack farwritetext JackNumberDeclinedText + waitbutton closetext - loadmovesprites end .Huey farwritetext HueyNumberDeclinedText + waitbutton closetext - loadmovesprites end .Gaven farwritetext GavenNumberDeclinedText + waitbutton closetext - loadmovesprites end .Jose farwritetext JoseNumberDeclinedText + waitbutton closetext - loadmovesprites end .Joey farwritetext JoeyNumberDeclinedText + waitbutton closetext - loadmovesprites end .Wade farwritetext WadeNumberDeclinedText + waitbutton closetext - loadmovesprites end .Ralph farwritetext RalphNumberDeclinedText + waitbutton closetext - loadmovesprites end .Anthony farwritetext AnthonyNumberDeclinedText + waitbutton closetext - loadmovesprites end .Todd farwritetext ToddNumberDeclinedText + waitbutton closetext - loadmovesprites end .Irwin farwritetext IrwinNumberDeclinedText + waitbutton closetext - loadmovesprites end .Arnie farwritetext ArnieNumberDeclinedText + waitbutton closetext - loadmovesprites end .Alan farwritetext AlanNumberDeclinedText + waitbutton closetext - loadmovesprites end .Chad farwritetext ChadNumberDeclinedText + waitbutton closetext - loadmovesprites end .Derek farwritetext DerekNumberDeclinedText + waitbutton closetext - loadmovesprites end .Tully farwritetext TullyNumberDeclinedText + waitbutton closetext - loadmovesprites end .Brent farwritetext BrentNumberDeclinedText + waitbutton closetext - loadmovesprites end .Vance farwritetext VanceNumberDeclinedText + waitbutton closetext - loadmovesprites end .Wilton farwritetext WiltonNumberDeclinedText + waitbutton closetext - loadmovesprites end .Kenji farwritetext KenjiNumberDeclinedText + waitbutton closetext - loadmovesprites end .Parry farwritetext ParryNumberDeclinedText + waitbutton closetext - loadmovesprites end PhoneFullMScript: @@ -1070,103 +1070,103 @@ PhoneFullMScript: .Jack farwritetext JackPhoneFullText + waitbutton closetext - loadmovesprites end .Huey farwritetext HueyPhoneFullText + waitbutton closetext - loadmovesprites end .Gaven farwritetext GavenPhoneFullText + waitbutton closetext - loadmovesprites end .Jose farwritetext JosePhoneFullText + waitbutton closetext - loadmovesprites end .Joey farwritetext JoeyPhoneFullText + waitbutton closetext - loadmovesprites end .Wade farwritetext WadePhoneFullText + waitbutton closetext - loadmovesprites end .Ralph farwritetext RalphPhoneFullText + waitbutton closetext - loadmovesprites end .Anthony farwritetext AnthonyPhoneFullText + waitbutton closetext - loadmovesprites end .Todd farwritetext ToddPhoneFullText + waitbutton closetext - loadmovesprites end .Irwin farwritetext IrwinPhoneFullText + waitbutton closetext - loadmovesprites end .Arnie farwritetext ArniePhoneFullText + waitbutton closetext - loadmovesprites end .Alan farwritetext AlanPhoneFullText + waitbutton closetext - loadmovesprites end .Chad farwritetext ChadPhoneFullText + waitbutton closetext - loadmovesprites end .Derek farwritetext DerekPhoneFullText + waitbutton closetext - loadmovesprites end .Tully farwritetext TullyPhoneFullText + waitbutton closetext - loadmovesprites end .Brent farwritetext BrentPhoneFullText + waitbutton closetext - loadmovesprites end .Vance farwritetext VancePhoneFullText + waitbutton closetext - loadmovesprites end .Wilton farwritetext WiltonPhoneFullText + waitbutton closetext - loadmovesprites end .Kenji farwritetext KenjiPhoneFullText + waitbutton closetext - loadmovesprites end .Parry farwritetext ParryPhoneFullText + waitbutton closetext - loadmovesprites end RematchMScript: @@ -1191,88 +1191,88 @@ RematchMScript: .Jack farwritetext JackRematchText + waitbutton closetext - loadmovesprites end .Huey farwritetext HueyRematchText + waitbutton closetext - loadmovesprites end .Gaven farwritetext GavenRematchText + waitbutton closetext - loadmovesprites end .Jose farwritetext JoseRematchText + waitbutton closetext - loadmovesprites end .Joey farwritetext JoeyRematchText + waitbutton closetext - loadmovesprites end .Wade farwritetext WadeRematchText + waitbutton closetext - loadmovesprites end .Ralph farwritetext RalphRematchText + waitbutton closetext - loadmovesprites end .Anthony farwritetext AnthonyRematchText + waitbutton closetext - loadmovesprites end .Todd farwritetext ToddRematchText + waitbutton closetext - loadmovesprites end .Arnie farwritetext ArnieRematchText + waitbutton closetext - loadmovesprites end .Alan farwritetext AlanRematchText + waitbutton closetext - loadmovesprites end .Chad farwritetext ChadRematchText + waitbutton closetext - loadmovesprites end .Tully farwritetext TullyRematchText + waitbutton closetext - loadmovesprites end .Brent farwritetext BrentRematchText + waitbutton closetext - loadmovesprites end .Vance farwritetext VanceRematchText + waitbutton closetext - loadmovesprites end .Wilton farwritetext WiltonRematchText + waitbutton closetext - loadmovesprites end .Parry farwritetext ParryRematchText + waitbutton closetext - loadmovesprites end GiftMScript: @@ -1330,58 +1330,58 @@ PackFullMScript: .Huey farwritetext HueyPackFullText + waitbutton closetext - loadmovesprites end .Jose farwritetext JosePackFullText + waitbutton closetext - loadmovesprites end .Joey farwritetext JoeyPackFullText + waitbutton closetext - loadmovesprites end .Wade farwritetext WadePackFullText + waitbutton closetext - loadmovesprites end .Alan farwritetext AlanPackFullText + waitbutton closetext - loadmovesprites end .Derek farwritetext DerekPackFullText + waitbutton closetext - loadmovesprites end .Tully farwritetext TullyPackFullText + waitbutton closetext - loadmovesprites end .Vance farwritetext VancePackFullText + waitbutton closetext - loadmovesprites end .Wilton farwritetext WiltonPackFullText + waitbutton closetext - loadmovesprites end .Kenji farwritetext KenjiPackFullText + waitbutton closetext - loadmovesprites end .Parry farwritetext ParryPackFullText + waitbutton closetext - loadmovesprites end RematchGiftMScript: @@ -1484,7 +1484,7 @@ AskNumber2FScript: RegisteredNumberFScript: farwritetext RegisteredNumber2Text playsound SFX_REGISTER_PHONE_NUMBER - waitbutton + waitsfx keeptextopen end @@ -1501,43 +1501,43 @@ NumberAcceptedFScript: ; 0xbcbd3 .Beverly farwritetext BeverlyNumberAcceptedText + waitbutton closetext - loadmovesprites end .Beth farwritetext BethNumberAcceptedText + waitbutton closetext - loadmovesprites end .Reena farwritetext ReenaNumberAcceptedText + waitbutton closetext - loadmovesprites end .Liz farwritetext LizNumberAcceptedText + waitbutton closetext - loadmovesprites end .Gina farwritetext GinaNumberAcceptedText + waitbutton closetext - loadmovesprites end .Dana farwritetext DanaNumberAcceptedText + waitbutton closetext - loadmovesprites end .Tiffany farwritetext TiffanyNumberAcceptedText + waitbutton closetext - loadmovesprites end .Erin farwritetext ErinNumberAcceptedText + waitbutton closetext - loadmovesprites end NumberDeclinedFScript: @@ -1553,43 +1553,43 @@ NumberDeclinedFScript: .Beverly farwritetext BeverlyNumberDeclinedText + waitbutton closetext - loadmovesprites end .Beth farwritetext BethNumberDeclinedText + waitbutton closetext - loadmovesprites end .Reena farwritetext ReenaNumberDeclinedText + waitbutton closetext - loadmovesprites end .Liz farwritetext LizNumberDeclinedText + waitbutton closetext - loadmovesprites end .Gina farwritetext GinaNumberDeclinedText + waitbutton closetext - loadmovesprites end .Dana farwritetext DanaNumberDeclinedText + waitbutton closetext - loadmovesprites end .Tiffany farwritetext TiffanyNumberDeclinedText + waitbutton closetext - loadmovesprites end .Erin farwritetext ErinNumberDeclinedText + waitbutton closetext - loadmovesprites end PhoneFullFScript: @@ -1605,43 +1605,43 @@ PhoneFullFScript: .Beverly farwritetext BeverlyPhoneFullText + waitbutton closetext - loadmovesprites end .Beth farwritetext BethPhoneFullText + waitbutton closetext - loadmovesprites end .Reena farwritetext ReenaPhoneFullText + waitbutton closetext - loadmovesprites end .Liz farwritetext LizPhoneFullText + waitbutton closetext - loadmovesprites end .Gina farwritetext GinaPhoneFullText + waitbutton closetext - loadmovesprites end .Dana farwritetext DanaPhoneFullText + waitbutton closetext - loadmovesprites end .Tiffany farwritetext TiffanyPhoneFullText + waitbutton closetext - loadmovesprites end .Erin farwritetext ErinPhoneFullText + waitbutton closetext - loadmovesprites end RematchFScript: @@ -1656,38 +1656,38 @@ RematchFScript: .Beth farwritetext BethRematchText + waitbutton closetext - loadmovesprites end .Reena farwritetext ReenaRematchText + waitbutton closetext - loadmovesprites end .Liz farwritetext LizRematchText + waitbutton closetext - loadmovesprites end .Gina farwritetext GinaRematchText + waitbutton closetext - loadmovesprites end .Dana farwritetext DanaRematchText + waitbutton closetext - loadmovesprites end .Tiffany farwritetext TiffanyRematchText + waitbutton closetext - loadmovesprites end .Erin farwritetext ErinRematchText + waitbutton closetext - loadmovesprites end GiftFScript: @@ -1724,28 +1724,28 @@ PackFullFScript: .Beverly farwritetext BeverlyPackFullText + waitbutton closetext - loadmovesprites end .Gina farwritetext GinaPackFullText + waitbutton closetext - loadmovesprites end .Dana farwritetext DanaPackFullText + waitbutton closetext - loadmovesprites end .Tiffany farwritetext TiffanyPackFullText + waitbutton closetext - loadmovesprites end .Erin farwritetext ErinPackFullText + waitbutton closetext - loadmovesprites end RematchGiftFScript: @@ -1762,8 +1762,8 @@ GymStatue1Script: mapnametotext $0 loadfont farwritetext GymStatue_CityGymText + waitbutton closetext - loadmovesprites end GymStatue2Script: @@ -1772,23 +1772,23 @@ GymStatue2Script: farwritetext GymStatue_CityGymText keeptextopen farwritetext GymStatue_WinningTrainersText + waitbutton closetext - loadmovesprites end ReceiveItemScript: ; 0xbcdb9 - waitbutton + waitsfx farwritetext ReceivedItemText playsound SFX_ITEM - waitbutton + waitsfx end ; 0xbcdc3 ReceiveTogepiEggScript: ; 0xbcdc3 - waitbutton + waitsfx farwritetext ReceivedItemText playsound SFX_GET_EGG_FROM_DAYCARE_LADY - waitbutton + waitsfx end ; 0xbcdcd @@ -1800,8 +1800,8 @@ GameCornerCoinVendorScript: ; 0xbcdcd checkitem COIN_CASE iftrue CoinVendor_IntroScript farwritetext CoinVendor_NoCoinCaseText + waitbutton closetext - loadmovesprites end ; 0xbcde0 @@ -1825,10 +1825,10 @@ CoinVendor_Buy50CoinsScript: ; 0xbcdf7 if_equal $2, CoinVendor_NotEnoughMoneyScript givecoins 50 takemoney $0, 1000 - waitbutton + waitsfx playsound SFX_TRANSACTION farwritetext CoinVendor_Buy50CoinsText - closetext + waitbutton jump CoinVendor_SellCoinsMenuScript ; 0xbce1b @@ -1839,31 +1839,31 @@ CoinVendor_Buy500CoinsScript: ; 0xbce1b if_equal $2, CoinVendor_NotEnoughMoneyScript givecoins 500 takemoney $0, 10000 - waitbutton + waitsfx playsound SFX_TRANSACTION farwritetext CoinVendor_Buy500CoinsText - closetext + waitbutton jump CoinVendor_SellCoinsMenuScript ; 0xbce3f CoinVendor_NotEnoughMoneyScript: ; 0xbce3f farwritetext CoinVendor_NotEnoughMoneyText + waitbutton closetext - loadmovesprites end ; 0xbce46 CoinVendor_CoinCaseFullScript: ; 0xbce46 farwritetext CoinVendor_CoinCaseFullText + waitbutton closetext - loadmovesprites end ; 0xbce4d CoinVendor_CancelScript: ; 0xbce4d farwritetext CoinVendor_CancelText + waitbutton closetext - loadmovesprites end ; 0xbce54 @@ -1892,20 +1892,20 @@ HappinessCheckScript: if_less_than 50, .Unhappy if_less_than 150, .KindaHappy farwritetext HappinessText3 + waitbutton closetext - loadmovesprites end .KindaHappy farwritetext HappinessText2 + waitbutton closetext - loadmovesprites end .Unhappy farwritetext HappinessText1 + waitbutton closetext - loadmovesprites end Movement_ContestResults_WalkAfterWarp: ; bcea1 diff --git a/engine/time_capsule/conversion.asm b/engine/time_capsule/conversion.asm index 10f7ab5f3..cd2d68da1 100755 --- a/engine/time_capsule/conversion.asm +++ b/engine/time_capsule/conversion.asm @@ -355,18 +355,18 @@ NewPokedexEntry: ; fb877 ld [hSCX], a xor a ld [wPokedexStatus], a - callba Function41a7f + callba _NewPokedexEntry call WaitPressAorB_BlinkCursor ld a, $1 ld [wPokedexStatus], a - callba Function4424d + callba DisplayDexEntry call WaitPressAorB_BlinkCursor pop af ld [wPokedexStatus], a call MaxVolume call RotateThreePalettesRight ld a, [hSCX] - add $fb + add -5 ; 251 ; NUM_POKEMON ld [hSCX], a call Functionfb8c8 pop af @@ -378,7 +378,7 @@ Functionfb8c8: ; fb8c8 call ClearTileMap call LoadFontsExtra call LoadStandardFont - callba Function40ab2 + callba Pokedex_PlaceFrontpicTopLeftCorner call Function3200 callba GetEnemyMonDVs ld a, [hli] diff --git a/engine/town_map.asm b/engine/town_map.asm index c821e793a..e9a3a5001 100755 --- a/engine/town_map.asm +++ b/engine/town_map.asm @@ -92,7 +92,7 @@ Function919b0: ; 919b0 jr nz, .pressed_down .loop2 push de - callba Function8cf69 + callba PlaySpriteAnimations pop de call DelayFrame jr .loop diff --git a/engine/trade/animation.asm b/engine/trade/animation.asm index 0aaf0cb8b..ec02fc667 100755 --- a/engine/trade/animation.asm +++ b/engine/trade/animation.asm @@ -206,7 +206,7 @@ DoTradeAnimation: ; 29082 bit 7, a jr nz, .finished call .DoTradeAnimCommand - callab Function8cf69 + callab PlaySpriteAnimations ld hl, wcf65 inc [hl] call DelayFrame diff --git a/engine/warp_connection.asm b/engine/warp_connection.asm new file mode 100755 index 000000000..e9a38257d --- /dev/null +++ b/engine/warp_connection.asm @@ -0,0 +1,440 @@ + +RunCallback_05_03: ; 1045b0 + call Clearwc7e8 + call ResetMapBufferEventFlags + call ResetFlashIfOutOfCave + call GetCurrentMapTrigger + call ResetBikeFlags + ld a, $5 + call RunMapCallback + +RunCallback_03: ; 1045c4 + callba ClearCmdQueue + ld a, $3 + call RunMapCallback + call GetMapHeaderTimeOfDayNybble + ld [wc2d0], a + ret + + +EnterMapConnection: ; 1045d6 +; Return carry if a connection has been entered. + ld a, [wPlayerStepDirection] + and a + jp z, EnterSouthConnection + cp 1 + jp z, EnterNorthConnection + cp 2 + jp z, EnterWestConnection + cp 3 + jp z, EnterEastConnection + ret +; 1045ed + + +EnterWestConnection: ; 1045ed + ld a, [WestConnectedMapGroup] + ld [MapGroup], a + ld a, [WestConnectedMapNumber] + ld [MapNumber], a + ld a, [WestConnectionStripXOffset] + ld [XCoord], a + ld a, [WestConnectionStripYOffset] + ld hl, YCoord + add [hl] + ld [hl], a + ld c, a + ld hl, WestConnectionWindow + ld a, [hli] + ld h, [hl] + ld l, a + srl c + jr z, .skip_to_load + ld a, [WestConnectedMapWidth] + add 6 + ld e, a + ld d, 0 + +.loop + add hl, de + dec c + jr nz, .loop + +.skip_to_load + ld a, l + ld [wd194], a + ld a, h + ld [wd194 + 1], a + jp EnteredConnection +; 104629 + + +EnterEastConnection: ; 104629 + ld a, [EastConnectedMapGroup] + ld [MapGroup], a + ld a, [EastConnectedMapNumber] + ld [MapNumber], a + ld a, [EastConnectionStripXOffset] + ld [XCoord], a + ld a, [EastConnectionStripYOffset] + ld hl, YCoord + add [hl] + ld [hl], a + ld c, a + ld hl, EastConnectionWindow + ld a, [hli] + ld h, [hl] + ld l, a + srl c + jr z, .skip_to_load + ld a, [EastConnectedMapWidth] + add 6 + ld e, a + ld d, 0 + +.loop + add hl, de + dec c + jr nz, .loop + +.skip_to_load + ld a, l + ld [wd194], a + ld a, h + ld [wd194 + 1], a + jp EnteredConnection +; 104665 + + +EnterNorthConnection: ; 104665 + ld a, [NorthConnectedMapGroup] + ld [MapGroup], a + ld a, [NorthConnectedMapNumber] + ld [MapNumber], a + ld a, [NorthConnectionStripYOffset] + ld [YCoord], a + ld a, [NorthConnectionStripXOffset] + ld hl, XCoord + add [hl] + ld [hl], a + ld c, a + ld hl, NorthConnectionWindow + ld a, [hli] + ld h, [hl] + ld l, a + ld b, 0 + srl c + add hl, bc + ld a, l + ld [wd194], a + ld a, h + ld [wd194 + 1], a + jp EnteredConnection +; 104696 + + +EnterSouthConnection: ; 104696 + ld a, [SouthConnectedMapGroup] + ld [MapGroup], a + ld a, [SouthConnectedMapNumber] + ld [MapNumber], a + ld a, [SouthConnectionStripYOffset] + ld [YCoord], a + ld a, [SouthConnectionStripXOffset] + ld hl, XCoord + add [hl] + ld [hl], a + ld c, a + ld hl, SouthConnectionWindow + ld a, [hli] + ld h, [hl] + ld l, a + ld b, 0 + srl c + add hl, bc + ld a, l + ld [wd194], a + ld a, h + ld [wd194 + 1], a + ; fallthrough +; 1046c4 + +EnteredConnection: ; 1046c4 + scf + ret +; 1046c6 + +LoadWarpData: ; 1046c6 + call .SaveDigWarp + call .SetSpawn + ld a, [wNextWarp] + ld [WarpNumber], a + ld a, [wNextMapGroup] + ld [MapGroup], a + ld a, [wNextMapNumber] + ld [MapNumber], a + ret + +.SaveDigWarp: ; 1046df (41:46df) + call GetMapPermission + call CheckOutdoorMap + ret nz + ld a, [wNextMapGroup] + ld b, a + ld a, [wNextMapNumber] + ld c, a + call GetAnyMapPermission + call CheckIndoorMap + ret nz + ld a, [wPrevMapGroup] + cp GROUP_MOUNT_MOON_SQUARE + jr nz, .not_mt_moon_or_tin_tower + ld a, [wPrevMapNumber] + cp MAP_MOUNT_MOON_SQUARE + ret z + cp MAP_TIN_TOWER_ROOF + ret z +.not_mt_moon_or_tin_tower + ld a, [wPrevWarp] + ld [wDigWarp], a + ld a, [wPrevMapGroup] + ld [wDigMapGroup], a + ld a, [wPrevMapNumber] + ld [wDigMapNumber], a + ret + +.SetSpawn: ; 104718 (41:4718) + call GetMapPermission + call CheckOutdoorMap + ret nz + ld a, [wNextMapGroup] + ld b, a + ld a, [wNextMapNumber] + ld c, a + call GetAnyMapPermission + call CheckIndoorMap + ret nz + ld a, [wNextMapGroup] + ld b, a + ld a, [wNextMapNumber] + ld c, a + call GetAnyMapTileset + ld a, c + cp TILESET_POKECENTER + jr z, .pokecenter_pokecom + cp TILESET_POKECOM_CENTER + jr z, .pokecenter_pokecom + ret +.pokecenter_pokecom + ld a, [wPrevMapGroup] + ld [wLastSpawnMapGroup], a + ld a, [wPrevMapNumber] + ld [wLastSpawnMapNumber], a + ret + +LoadMapTimeOfDay: ; 104750 + ld hl, VramState + res 6, [hl] + ld a, $1 + ld [wSpriteUpdatesEnabled], a + callba Function8c0e5 + callba Function8c001 + call OverworldTextModeSwitch + call Function104770 + call Function1047a3 + ret + +Function104770: ; 104770 (41:4770) + ld a, VBGMap0 / $100 + ld [wBGMapAnchor + 1], a + xor a + ld [wBGMapAnchor], a + ld [hSCY], a + ld [hSCX], a + callba Function5958 + ld a, [rVBK] + push af + ld a, $1 + ld [rVBK], a + xor a + lb bc, 4, 0 + hlbgcoord 0, 0 + call ByteFill + pop af + ld [rVBK], a + ld a, $60 + lb bc, 4, 0 + hlbgcoord 0, 0 + call ByteFill + ret + +Function1047a3: ; 1047a3 (41:47a3) + decoord 0, 0 + call .copy + ld a, [hCGB] + and a + ret z + + decoord 0, 0, AttrMap + ld a, $1 + ld [rVBK], a +.copy: + hlbgcoord 0, 0 + ld c, SCREEN_WIDTH + ld b, SCREEN_HEIGHT +.row + push bc +.column + ld a, [de] + inc de + ld [hli], a + dec c + jr nz, .column + ld bc, $20 - SCREEN_WIDTH + add hl, bc + pop bc + dec b + jr nz, .row + ld a, $0 + ld [rVBK], a + ret + +LoadGraphics: ; 1047cf + call LoadTilesetHeader + call LoadTileset + xor a + ld [hMapAnims], a + xor a + ld [hTileAnimFrame], a + callba RefreshSprites + call LoadFontsExtra + callba Function106594 + ret + +LoadMapPalettes: ; 1047eb + ld b, SCGB_09 + jp GetSGBLayout +; 1047f0 + +RefreshMapSprites: ; 1047f0 + call ClearSprites + callba ReturnFromMapSetupScript + call GetMovementPermissions + callba Function579d + callba CheckReplaceKrisSprite + ld hl, wPlayerSpriteSetupFlags + bit 6, [hl] + jr nz, .skip + ld hl, VramState + set 0, [hl] + call Function2e31 +.skip + ld a, [wPlayerSpriteSetupFlags] + and $1c + ld [wPlayerSpriteSetupFlags], a + ret + +CheckMovingOffEdgeOfMap:: ; 104820 (41:4820) + ld a, [wPlayerStepDirection] + cp STANDING + ret z + and a ; DOWN + jr z, .down + cp UP + jr z, .up + cp LEFT + jr z, .left + cp RIGHT + jr z, .right + and a + ret + +.down + ld a, [PlayerNextMapY] + sub 4 + ld b, a + ld a, [MapHeight] + add a + cp b + jr z, .ok + and a + ret + +.up + ld a, [PlayerNextMapY] + sub 4 + cp -1 + jr z, .ok + and a + ret + +.left + ld a, [PlayerNextMapX] + sub $4 + cp -1 + jr z, .ok + and a + ret + +.right + ld a, [PlayerNextMapX] + sub 4 + ld b, a + ld a, [MapWidth] + add a + cp b + jr z, .ok + and a + ret + +.ok + scf + ret + + +GetCoordOfUpperLeftCorner:: ; 10486d + ld hl, OverworldMap + ld a, [XCoord] + bit 0, a + jr nz, .increment_then_halve1 + srl a + add $1 + jr .resume + +.increment_then_halve1 + add $1 + srl a + +.resume + ld c, a + ld b, $0 + add hl, bc + ld a, [MapWidth] + add $6 + ld c, a + ld b, $0 + ld a, [YCoord] + bit 0, a + jr nz, .increment_then_halve2 + srl a + add $1 + jr .resume2 + +.increment_then_halve2 + add $1 + srl a + +.resume2 + call AddNTimes + ld a, l + ld [wd194], a + ld a, h + ld [wd194 + 1], a + ld a, [YCoord] + and $1 + ld [wd196], a + ld a, [XCoord] + and $1 + ld [wd197], a + ret +; 1048ba |