diff options
Diffstat (limited to 'engine/battle/core.asm')
-rwxr-xr-x | engine/battle/core.asm | 579 |
1 files changed, 231 insertions, 348 deletions
diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 4628e86a..f66f509f 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -67,6 +67,9 @@ SlidePlayerAndEnemySilhouettesOnScreen: ldh [rBGP], a ldh [rOBP0], a ldh [rOBP1], a + call UpdateGBCPal_BGP + call UpdateGBCPal_OBP0 + call UpdateGBCPal_OBP1 .slideSilhouettesLoop ; slide silhouettes of the player's pic and the enemy's pic onto the screen ld h, b ld l, $40 @@ -156,10 +159,16 @@ StartBattle: call DelayFrames call SaveScreenTilesToBuffer1 .checkAnyPartyAlive + ld a, [wBattleType] + cp BATTLE_TYPE_RUN + jp z, .specialBattle + cp BATTLE_TYPE_PIKACHU + jp z, .specialBattle call AnyPartyAlive ld a, d and a jp z, HandlePlayerBlackOut ; jump if no mon is alive +.specialBattle call LoadScreenTilesFromBuffer1 ld a, [wBattleType] and a ; is it a normal battle? @@ -893,6 +902,11 @@ ReplaceFaintedEnemyMon: ld hl, wEnemyHPBarColor ld e, $30 call GetBattleHealthBarColor + setpal SHADE_BLACK, SHADE_DARK, SHADE_LIGHT, SHADE_WHITE + ldh [rOBP0], a + ldh [rOBP1], a + call UpdateGBCPal_OBP0 + call UpdateGBCPal_OBP1 callfar DrawEnemyPokeballs ld a, [wLinkState] cp LINK_STATE_BATTLING @@ -958,9 +972,7 @@ TrainerDefeatedText: PlayBattleVictoryMusic: push af - ld a, SFX_STOP_ALL_MUSIC - ld [wNewSoundID], a - call PlaySoundWaitForCurrent + call StopAllMusic ld c, BANK(Music_DefeatedTrainer) pop af call PlayMusic @@ -1014,6 +1026,7 @@ RemoveFaintedPlayerMon: ld a, $ff ld [wLowHealthAlarm], a ;disable low health alarm call WaitForSoundToFinish + xor a .skipWaitForSound ; a is 0, so this zeroes the enemy's accumulated damage. ld hl, wEnemyBideAccumulatedDamage @@ -1038,10 +1051,36 @@ RemoveFaintedPlayerMon: and a ; was this called by HandleEnemyMonFainted? ret z ; if so, return + ld a, [wPlayerMonNumber] + ld [wWhichPokemon], a + callfar IsThisPartymonStarterPikachu_Party + jr nc, .notPlayerPikachu + ld e, $3 + callfar PlayPikachuSoundClip + jr .printText +.notPlayerPikachu ld a, [wBattleMonSpecies] call PlayCry +.printText ld hl, PlayerMonFaintedText - jp PrintText + call PrintText + ld a, [wPlayerMonNumber] + ld [wWhichPokemon], a + ld a, [wBattleMonLevel] + ld b, a + ld a, [wEnemyMonLevel] + sub b ; enemylevel - playerlevel + ; are we stronger than the opposing pokemon? + jr c, .regularFaint ; if so, deduct happiness regularly + + cp 30 ; is the enemy 30 levels greater than us? + jr nc, .carelessTrainer ; if so, punish the player for being careless, as they shouldn't be fighting a very high leveled trainer with such a level difference +.regularFaint + callabd_ModifyPikachuHappiness PIKAHAPPY_FAINTED + ret +.carelessTrainer + callabd_ModifyPikachuHappiness PIKAHAPPY_CARELESSTRAINER + ret PlayerMonFaintedText: text_far _PlayerMonFaintedText @@ -1098,7 +1137,7 @@ ChooseNextMon: ld a, [wLinkState] cp LINK_STATE_BATTLING jr nz, .notLinkBattle - inc a + ld a, 1 ld [wActionResultOrTookBattleTurn], a call LinkBattleExchangeData .notLinkBattle @@ -1498,6 +1537,8 @@ TryRunningFromBattle: ld a, [wBattleType] cp BATTLE_TYPE_SAFARI jp z, .canEscape ; jump if it's a safari battle + cp BATTLE_TYPE_RUN + jp z, .canEscape ; hurry, get away? ld a, [wLinkState] cp LINK_STATE_BATTLING jp z, .canEscape @@ -1753,19 +1794,46 @@ SendOutMon: call RunPaletteCommand ld hl, wEnemyBattleStatus1 res USING_TRAPPING_MOVE, [hl] + callfar IsThisPartymonStarterPikachu + jr c, .starterPikachu ld a, $1 ldh [hWhoseTurn], a ld a, POOF_ANIM call PlayMoveAnimation hlcoord 4, 11 predef AnimateSendingOutMon + jr .playRegularCry +.starterPikachu + xor a + ldh [hWhoseTurn], a + ld a, $1 + ldh [hAutoBGTransferEnabled], a + callfar StarterPikachuBattleEntranceAnimation + callfar IsPlayerPikachuAsleepInParty + ld e, $24 + jr c, .asm_3cd81 + ld e, $a +.asm_3cd81 + callfar PlayPikachuSoundClip + jr .done +.playRegularCry ld a, [wcf91] call PlayCry +.done call PrintEmptyString jp SaveScreenTilesToBuffer1 ; show 2 stages of the player mon getting smaller before disappearing AnimateRetreatingPlayerMon: + ld a, [wWhichPokemon] + push af + ld a, [wPlayerMonNumber] + ld [wWhichPokemon], a + callfar IsThisPartymonStarterPikachu + pop bc + ld a, b + ld [wWhichPokemon], a + jr c, .starterPikachu hlcoord 1, 5 lb bc, 7, 7 call ClearScreenArea @@ -1789,10 +1857,17 @@ AnimateRetreatingPlayerMon: call .clearScreenArea ld a, $4c ldcoord_a 5, 11 + jr .clearScreenArea +.starterPikachu + xor a + ldh [hWhoseTurn], a + callfar AnimationSlideMonOff + ret .clearScreenArea hlcoord 1, 5 lb bc, 7, 7 - jp ClearScreenArea + call ClearScreenArea + ret ; reads player's current mon's HP into wBattleMonHP ReadPlayerMonCurHPAndStatus: @@ -2014,36 +2089,49 @@ DisplayBattleMenu:: ld [wTextBoxID], a call DisplayTextBoxID ld a, [wBattleType] - dec a - jp nz, .handleBattleMenuInput ; handle menu input if it's not the old man tutorial -; the following happens for the old man tutorial + cp BATTLE_TYPE_OLD_MAN + jr z, .doSimulatedMenuInput ; simulate menu input if it's the old man or prof. oak pikachu battle + cp BATTLE_TYPE_PIKACHU + jr z, .doSimulatedMenuInput + jp .handleBattleMenuInput +; the following happens for the old man tutorial and prof. oak pikachu battle +.doSimulatedMenuInput ld hl, wPlayerName ld de, wGrassRate ld bc, NAME_LENGTH call CopyData ; temporarily save the player name in unused space, ; which is supposed to get overwritten when entering a - ; map with wild Pokémon. Due to an oversight, the data + ; map with wild Pokémon. + ; In Red/Blue, due to an oversight, the data ; may not get overwritten (cinnabar) and the infamous - ; Missingno. glitch can show up. + ; Missingno. glitch can show up. However, + ; this has been fixed in yellow ld hl, .oldManName + ld a, [wBattleType] + dec a + jr z, .useOldManName + ld hl, .profOakName +.useOldManName ld de, wPlayerName ld bc, NAME_LENGTH call CopyData ; the following simulates the keystrokes by drawing menus on screen hlcoord 9, 14 ld [hl], "▶" - ld c, 80 + ld c, 20 call DelayFrames ld [hl], " " hlcoord 9, 16 ld [hl], "▶" - ld c, 50 + ld c, 20 call DelayFrames ld [hl], "▷" ld a, $2 ; select the "ITEM" menu jp .upperLeftMenuItemWasNotSelected .oldManName db "OLD MAN@" +.profOakName + db "PROF.OAK@" .handleBattleMenuInput ld a, [wBattleAndStartSavedMenuItem] ld [wCurrentMenuItem], a @@ -2126,6 +2214,9 @@ DisplayBattleMenu:: .AButtonPressed call PlaceUnfilledArrowMenuCursor ld a, [wBattleType] + cp BATTLE_TYPE_RUN + jr z, .handleUnusedBattle + ld a, [wBattleType] cp BATTLE_TYPE_SAFARI ld a, [wCurrentMenuItem] ld [wBattleAndStartSavedMenuItem], a @@ -2157,7 +2248,18 @@ DisplayBattleMenu:: .throwSafariBallWasSelected ld a, SAFARI_BALL ld [wcf91], a - jr UseBagItem + jp UseBagItem +.handleUnusedBattle + ld a, [wCurrentMenuItem] + cp $3 + jp z, BattleMenu_RunWasSelected + ld hl, .RunAwayText + call PrintText + jp DisplayBattleMenu + +.RunAwayText + text_far _RunAwayText + text_end .upperLeftMenuItemWasNotSelected ; a menu item other than the upper left item was selected cp $2 @@ -2194,19 +2296,23 @@ BagWasSelected: call DrawHUDsAndHPBars .next ld a, [wBattleType] - dec a ; is it the old man tutorial? - jr nz, DisplayPlayerBag ; no, it is a normal battle - ld hl, OldManItemList + cp BATTLE_TYPE_OLD_MAN ; is it the old man tutorial? + jr z, .simulatedInputBattle + cp BATTLE_TYPE_PIKACHU ; is it the prof oak battle with pikachu? + jr z, .simulatedInputBattle + jr DisplayPlayerBag +.simulatedInputBattle + ld hl, SimulatedInputBattleItemList ld a, l ld [wListPointer], a ld a, h ld [wListPointer + 1], a jr DisplayBagMenu -OldManItemList: - db 1 ; # items - db POKE_BALL, 50 - db -1 +SimulatedInputBattleItemList: + db 1 ; # of items + db POKE_BALL, 1 + db $ff DisplayPlayerBag: ; get the pointer to player's bag when in a normal battle @@ -2365,6 +2471,8 @@ PartyMenuOrRockOrRun: predef StatusScreen predef StatusScreen2 ; now we need to reload the enemy mon pic + ld a, 1 + ldh [hWhoseTurn], a ld a, [wEnemyBattleStatus2] bit HAS_SUBSTITUTE_UP, a ; does the enemy mon have a substitute? ld hl, AnimationSubstitute @@ -2469,13 +2577,13 @@ MoveSelectionMenu: .writemoves ld de, wMovesString - ldh a, [hFlagsFFF6] + ldh a, [hFlagsFFFA] set 2, a - ldh [hFlagsFFF6], a + ldh [hFlagsFFFA], a call PlaceString - ldh a, [hFlagsFFF6] + ldh a, [hFlagsFFFA] res 2, a - ldh [hFlagsFFF6], a + ldh [hFlagsFFFA], a ret .regularmenu @@ -2484,8 +2592,7 @@ MoveSelectionMenu: ld hl, wBattleMonMoves call .loadmoves hlcoord 4, 12 - ld b, 4 - ld c, 14 + lb bc, 4, 14 di ; out of pure coincidence, it is possible for vblank to occur between the di and ei ; so it is necessary to put the di ei block to not cause tearing call TextBoxBorder @@ -2503,8 +2610,7 @@ MoveSelectionMenu: ld hl, wEnemyMonMoves call .loadmoves hlcoord 0, 7 - ld b, 4 - ld c, 14 + lb bc, 4, 14 call TextBoxBorder hlcoord 2, 8 call .writemoves @@ -2518,8 +2624,7 @@ MoveSelectionMenu: call AddNTimes call .loadmoves hlcoord 4, 7 - ld b, 4 - ld c, 14 + lb bc, 4, 14 call TextBoxBorder hlcoord 6, 8 call .writemoves @@ -2533,8 +2638,6 @@ MoveSelectionMenu: ld a, [wMoveMenuType] cp $1 jr z, .selectedmoveknown - ld a, $1 - jr nc, .selectedmoveknown ld a, [wPlayerMoveListIndex] inc a .selectedmoveknown @@ -2595,10 +2698,10 @@ SelectMenuItem: call AddNTimes ld [hl], "▷" .select - ld hl, hFlagsFFF6 + ld hl, hFlagsFFFA set 1, [hl] call HandleMenuInput - ld hl, hFlagsFFF6 + ld hl, hFlagsFFFA res 1, [hl] bit 6, a jp nz, SelectMenuItem_CursorUp ; up @@ -2700,6 +2803,55 @@ SelectMenuItem_CursorDown: ld [wCurrentMenuItem], a jp SelectMenuItem +Func_3d4f5: + bit 3, a + ld a, $0 + jr nz, .asm_3d4fd + ld a, $1 +.asm_3d4fd + ldh [hWhoseTurn], a + call LoadScreenTilesFromBuffer1 + call Func_3d536 + ld a, [wTestBattlePlayerSelectedMove] + and a + jp z, MoveSelectionMenu + ld [wAnimationID], a + xor a + ld [wAnimationType], a + predef MoveAnimation + callfar Func_78e98 + jp MoveSelectionMenu + +Func_3d523: + ld a, [wTestBattlePlayerSelectedMove] + dec a + jr asm_3d52d +Func_3d529: + ld a, [wTestBattlePlayerSelectedMove] + inc a +asm_3d52d: + ld [wTestBattlePlayerSelectedMove], a + call Func_3d536 + jp MoveSelectionMenu + +Func_3d536: + hlcoord 10, 16 + lb bc, 2, 10 + call ClearScreenArea + hlcoord 10, 17 + ld de, wTestBattlePlayerSelectedMove + lb bc, LEADING_ZEROES | 1, 3 + call PrintNumber + ld a, [wTestBattlePlayerSelectedMove] + and a + ret z + cp STRUGGLE + ret nc + ld [wd11e], a + call GetMoveName + hlcoord 13, 17 + jp PlaceString + AnyMoveToSelect: ; return z and Struggle as the selected move if all moves have 0 PP and/or are disabled ld a, STRUGGLE @@ -2733,7 +2885,10 @@ AnyMoveToSelect: or c jr .handleDisabledMovePPLoop .allMovesChecked - and a ; any PP left? +; bugfix: only check PP value and not PP up bits +; in case all other moves have no PP left and a move has a PP up used on it +; and a non-PP up move is disabled + and $3f ; any PP left? ret nz ; return if a move has PP left .noMovesLeft ld hl, NoMovesLeftText @@ -2748,6 +2903,9 @@ NoMovesLeftText: text_end SwapMovesInMenu: + ld a, [wPlayerBattleStatus3] + bit TRANSFORMED, a + jp nz, MoveSelectionMenu ld a, [wMenuItemToSwap] and a jr z, .noMenuItemSelected @@ -2827,8 +2985,7 @@ PrintMenuItem: xor a ldh [hAutoBGTransferEnabled], a hlcoord 0, 8 - ld b, 3 - ld c, 9 + lb bc, 3, 9 call TextBoxBorder ld a, [wPlayerDisabledMove] and a @@ -2895,7 +3052,7 @@ PrintMenuItem: jp Delay3 DisabledText: - db "disabled!@" + db "Disabled!@" TypeText: db "TYPE@" @@ -4574,7 +4731,7 @@ JumpToOHKOMoveEffect: INCLUDE "data/battle/unused_critical_hit_moves.asm" ; determines if attack is a critical hit -; azure heights claims "the fastest pokémon (who are,not coincidentally, +; azure heights claims "the fastest pokémon (who are, not coincidentally, ; among the most popular) tend to CH about 20 to 25% of the time." CriticalHitTest: xor a @@ -4988,7 +5145,7 @@ AttackSubstitute: ldh a, [hWhoseTurn] xor $01 ldh [hWhoseTurn], a - callfar HideSubstituteShowMonAnim ; animate the substitute breaking + callfar Func_79929 ; animate the substitute breaking ; flip the turn back to the way it was ldh a, [hWhoseTurn] xor $01 @@ -5285,32 +5442,26 @@ AdjustDamageForMoveType: .done ret -; function to tell how effective the type of an enemy attack is on the player's current pokemon -; this doesn't take into account the effects that dual types can have -; (e.g. 4x weakness / resistance, weaknesses and resistances canceling) -; the result is stored in [wTypeEffectiveness] -; ($05 is not very effective, $10 is neutral, $14 is super effective) -; as far is can tell, this is only used once in some AI code to help decide which move to use AIGetTypeEffectiveness: ld a, [wEnemyMoveType] - ld d, a ; d = type of enemy move + ld d, a ; d = type of enemy move ld hl, wBattleMonType - ld b, [hl] ; b = type 1 of player's pokemon + ld b, [hl] ; b = type 1 of player's pokemon inc hl - ld c, [hl] ; c = type 2 of player's pokemon + ld c, [hl] ; c = type 2 of player's pokemon ld a, $10 - ld [wTypeEffectiveness], a ; initialize to neutral effectiveness + ld [wd11e], a ; initialize [wd11e] to neutral effectiveness ld hl, TypeEffects .loop ld a, [hli] cp $ff ret z - cp d ; match the type of the move + cp d ; match the type of the move jr nz, .nextTypePair1 ld a, [hli] - cp b ; match with type 1 of pokemon + cp b ; match with type 1 of pokemon jr z, .done - cp c ; or match with type 2 of pokemon + cp c ; or match with type 2 of pokemon jr z, .done jr .nextTypePair2 .nextTypePair1 @@ -5318,9 +5469,21 @@ AIGetTypeEffectiveness: .nextTypePair2 inc hl jr .loop + .done + ld a, [wTrainerClass] + cp LORELEI + jr nz, .ok + ld a, [wEnemyMonSpecies] + cp DEWGONG + jr nz, .ok + call BattleRandom + cp $66 ; 40 percent + ret c +.ok + ld a, [hl] - ld [wTypeEffectiveness], a ; store damage multiplier + ld [wd11e], a ; store damage multiplier ret INCLUDE "data/types/type_matchups.asm" @@ -6299,10 +6462,13 @@ SwapPlayerAndEnemyLevels: ; (for use when scrolling the player sprite and enemy's silhouettes on screen) LoadPlayerBackPic: ld a, [wBattleType] - dec a ; is it the old man tutorial? - ld de, RedPicBack - jr nz, .next ld de, OldManPic + cp BATTLE_TYPE_OLD_MAN ; is it the old man tutorial? + jr z, .next + ld de, ProfOakPicBack + cp BATTLE_TYPE_PIKACHU ; is it the pikachu battle at the beginning of the game? + jr z, .next + ld de, RedPicBack .next ld a, BANK(RedPicBack) call UncompressSpriteFromDE @@ -6327,6 +6493,8 @@ LoadPlayerBackPic: ld [hli], a ; OAM tile number inc a ; increment tile number ldh [hOAMTile], a + ld a, $2 + ld [hl], a inc hl dec c jr nz, .innerLoop @@ -6340,18 +6508,15 @@ LoadPlayerBackPic: jr nz, .loop ld de, vBackPic call InterlaceMergeSpriteBuffers - ld a, $a - ld [MBC1SRamEnable], a - xor a - ld [MBC1SRamBank], a + ld a, $0 + call SwitchSRAMBankAndLatchClockData ld hl, vSprites ld de, sSpriteBuffer1 ldh a, [hLoadedROMBank] ld b, a ld c, 7 * 7 call CopyVideoData - xor a - ld [MBC1SRamEnable], a + call PrepareRTCDataAndDisableSRAM ld a, $31 ldh [hStartTileID], a hlcoord 1, 5 @@ -6723,288 +6888,6 @@ HandleExplodingAnimation: PlayMoveAnimation: ld [wAnimationID], a call Delay3 - predef_jump MoveAnimation - -InitBattle:: - ld a, [wCurOpponent] - and a - jr z, DetermineWildOpponent - -InitOpponent: - ld a, [wCurOpponent] - ld [wcf91], a - ld [wEnemyMonSpecies2], a - jr InitBattleCommon - -DetermineWildOpponent: - ld a, [wd732] - bit 1, a - jr z, .asm_3ef2f - ldh a, [hJoyHeld] - bit 1, a ; B button pressed? - ret nz -.asm_3ef2f - ld a, [wNumberOfNoRandomBattleStepsLeft] - and a - ret nz - callfar TryDoWildEncounter - ret nz -InitBattleCommon: - ld a, [wMapPalOffset] - push af - ld hl, wLetterPrintingDelayFlags - ld a, [hl] - push af - res 1, [hl] - callfar InitBattleVariables - ld a, [wEnemyMonSpecies2] - sub OPP_ID_OFFSET - jp c, InitWildBattle - ld [wTrainerClass], a - call GetTrainerInformation - callfar ReadTrainer - call DoBattleTransitionAndInitBattleVariables - call _LoadTrainerPic - xor a - ld [wEnemyMonSpecies2], a - ldh [hStartTileID], a - dec a - ld [wAICount], a - hlcoord 12, 0 - predef CopyUncompressedPicToTilemap - ld a, $ff - ld [wEnemyMonPartyPos], a - ld a, $2 - ld [wIsInBattle], a - jp _InitBattleCommon - -InitWildBattle: - ld a, $1 - ld [wIsInBattle], a - call LoadEnemyMonData - call DoBattleTransitionAndInitBattleVariables - ld a, [wCurOpponent] - cp RESTLESS_SOUL - jr z, .isGhost - call IsGhostBattle - jr nz, .isNoGhost -.isGhost - ld hl, wMonHSpriteDim - ld a, $66 - ld [hli], a ; write sprite dimensions - ld bc, GhostPic - ld a, c - ld [hli], a ; write front sprite pointer - ld [hl], b - ld hl, wEnemyMonNick ; set name to "GHOST" - ld a, "G" - ld [hli], a - ld a, "H" - ld [hli], a - ld a, "O" - ld [hli], a - ld a, "S" - ld [hli], a - ld a, "T" - ld [hli], a - ld [hl], "@" - ld a, [wcf91] - push af - ld a, MON_GHOST - ld [wcf91], a - ld de, vFrontPic - call LoadMonFrontSprite ; load ghost sprite - pop af - ld [wcf91], a - jr .spriteLoaded -.isNoGhost - ld de, vFrontPic - call LoadMonFrontSprite ; load mon sprite -.spriteLoaded - xor a - ld [wTrainerClass], a - ldh [hStartTileID], a - hlcoord 12, 0 - predef CopyUncompressedPicToTilemap - -; common code that executes after init battle code specific to trainer or wild battles -_InitBattleCommon: - ld b, SET_PAL_BATTLE_BLACK - call RunPaletteCommand - call SlidePlayerAndEnemySilhouettesOnScreen - xor a - ldh [hAutoBGTransferEnabled], a - ld hl, .emptyString - call PrintText - call SaveScreenTilesToBuffer1 - call ClearScreen - ld a, $98 - ldh [hAutoBGTransferDest + 1], a - ld a, $1 - ldh [hAutoBGTransferEnabled], a - call Delay3 - ld a, $9c - ldh [hAutoBGTransferDest + 1], a - call LoadScreenTilesFromBuffer1 - hlcoord 9, 7 - lb bc, 5, 10 - call ClearScreenArea - hlcoord 1, 0 - lb bc, 4, 10 - call ClearScreenArea - call ClearSprites - ld a, [wIsInBattle] - dec a ; is it a wild battle? - call z, DrawEnemyHUDAndHPBar ; draw enemy HUD and HP bar if it's a wild battle - call StartBattle - callfar EndOfBattle - pop af - ld [wLetterPrintingDelayFlags], a - pop af - ld [wMapPalOffset], a - ld a, [wSavedTilesetType] - ldh [hTilesetType], a - scf + predef MoveAnimation + callfar Func_78e98 ret -.emptyString - db "@" - -_LoadTrainerPic: -; wd033-wd034 contain pointer to pic - ld a, [wTrainerPicPointer] - ld e, a - ld a, [wTrainerPicPointer + 1] - ld d, a ; de contains pointer to trainer pic - ld a, [wLinkState] - and a - ld a, BANK(TrainerPics) ; this is where all the trainer pics are (not counting Red's) - jr z, .loadSprite - ld a, BANK(RedPicFront) -.loadSprite - call UncompressSpriteFromDE - ld de, vFrontPic - ld a, $77 - ld c, a - jp LoadUncompressedSpriteData - -; unreferenced -ResetCryModifiers: - xor a - ld [wFrequencyModifier], a - ld [wTempoModifier], a - jp PlaySound - -; animates the mon "growing" out of the pokeball -AnimateSendingOutMon: - ld a, [wPredefRegisters] - ld h, a - ld a, [wPredefRegisters + 1] - ld l, a - ldh a, [hStartTileID] - ldh [hBaseTileID], a - ld b, $4c - ld a, [wIsInBattle] - and a - jr z, .notInBattle - add b - ld [hl], a - call Delay3 - ld bc, -(SCREEN_WIDTH * 2 + 1) - add hl, bc - ld a, 1 - ld [wDownscaledMonSize], a - lb bc, 3, 3 - predef CopyDownscaledMonTiles - ld c, 4 - call DelayFrames - ld bc, -(SCREEN_WIDTH * 2 + 1) - add hl, bc - xor a - ld [wDownscaledMonSize], a - lb bc, 5, 5 - predef CopyDownscaledMonTiles - ld c, 5 - call DelayFrames - ld bc, -(SCREEN_WIDTH * 2 + 1) - jr .next -.notInBattle - ld bc, -(SCREEN_WIDTH * 6 + 3) -.next - add hl, bc - ldh a, [hBaseTileID] - add $31 - jr CopyUncompressedPicToHL - -CopyUncompressedPicToTilemap: - ld a, [wPredefRegisters] - ld h, a - ld a, [wPredefRegisters + 1] - ld l, a - ldh a, [hStartTileID] -CopyUncompressedPicToHL:: - lb bc, 7, 7 - ld de, SCREEN_WIDTH - push af - ld a, [wSpriteFlipped] - and a - jr nz, .flipped - pop af -.loop - push bc - push hl -.innerLoop - ld [hl], a - add hl, de - inc a - dec c - jr nz, .innerLoop - pop hl - inc hl - pop bc - dec b - jr nz, .loop - ret - -.flipped - push bc - ld b, 0 - dec c - add hl, bc - pop bc - pop af -.flippedLoop - push bc - push hl -.flippedInnerLoop - ld [hl], a - add hl, de - inc a - dec c - jr nz, .flippedInnerLoop - pop hl - dec hl - pop bc - dec b - jr nz, .flippedLoop - ret - -LoadMonBackPic: -; Assumes the monster's attributes have -; been loaded with GetMonHeader. - ld a, [wBattleMonSpecies2] - ld [wcf91], a - hlcoord 1, 5 - ld b, 7 - ld c, 8 - call ClearScreenArea - ld hl, wMonHBackSprite - wMonHeader - call UncompressMonSprite - predef ScaleSpriteByTwo - ld de, vBackPic - call InterlaceMergeSpriteBuffers ; combine the two buffers to a single 2bpp sprite - ld hl, vSprites - ld de, vBackPic - ld c, (2*SPRITEBUFFERSIZE)/16 ; count of 16-byte chunks to be copied - ldh a, [hLoadedROMBank] - ld b, a - jp CopyVideoData |