This commit is contained in:
dannye 2022-12-28 17:38:38 -06:00
commit 3f691fcb21
970 changed files with 15106 additions and 11361 deletions

View file

@ -147,7 +147,7 @@ DrawFrameBlock:
jr z, .resetFrameBlockDestAddr
call AnimationCleanOAM
.resetFrameBlockDestAddr
ld hl, wOAMBuffer ; OAM buffer
ld hl, wShadowOAM
ld a, l
ld [wFBDestAddr + 1], a
ld a, h
@ -176,8 +176,12 @@ PlayAnimation:
ld h, [hl]
ld l, a
.animationLoop
vc_hook Stop_reducing_move_anim_flashing_Thunderbolt
ld a, [hli]
vc_hook_red Stop_reducing_move_anim_flashing_Reflect
vc_hook_blue Stop_reducing_move_anim_flashing_Self_Destruct
cp -1
vc_hook_blue Stop_reducing_move_anim_flashing_Reflect
jr z, .AnimationOver
cp FIRST_SE_ID ; is this subanimation or a special effect?
jr c, .playSubanimation
@ -245,38 +249,58 @@ PlayAnimation:
push af
ld a, [wAnimPalette]
ldh [rOBP0], a
call LoadAnimationTileset
call LoadMoveAnimationTiles
vc_hook Reduce_move_anim_flashing_Mega_Punch_Self_Destruct_Explosion
call LoadSubanimation
call PlaySubanimation
vc_hook_red Stop_reducing_move_anim_flashing_Mega_Punch
vc_hook_blue Stop_reducing_move_anim_flashing_Mega_Punch_Explosion
pop af
vc_hook_red Stop_reducing_move_anim_flashing_Blizzard
ldh [rOBP0], a
.nextAnimationCommand
vc_hook_red Stop_reducing_move_anim_flashing_Hyper_Beam
vc_hook_blue Stop_reducing_move_anim_flashing_Bubblebeam_Hyper_Beam_Blizzard
pop hl
vc_hook Stop_reducing_move_anim_flashing_Guillotine
jr .animationLoop
.AnimationOver
ret
LoadSubanimation:
vc_hook Reduce_move_anim_flashing_Guillotine
ld a, [wSubAnimAddrPtr + 1]
vc_hook Reduce_move_anim_flashing_Mega_Kick
ld h, a
vc_hook_red Reduce_move_anim_flashing_Blizzard
ld a, [wSubAnimAddrPtr]
vc_hook_red Reduce_move_anim_flashing_Self_Destruct
ld l, a
ld a, [hli]
ld e, a
vc_hook Reduce_move_anim_flashing_Explosion
ld a, [hl]
vc_hook Reduce_move_anim_flashing_Thunderbolt
ld d, a ; de = address of subanimation
ld a, [de]
vc_hook_blue Reduce_move_anim_flashing_Rock_Slide
ld b, a
vc_hook Reduce_move_anim_flashing_Spore
and %00011111
vc_hook Reduce_move_anim_flashing_Bubblebeam
ld [wSubAnimCounter], a ; number of frame blocks
vc_hook_red Reduce_move_anim_flashing_Rock_Slide
vc_hook_blue Reduce_move_anim_flashing_Self_Destruct
ld a, b
and %11100000
cp SUBANIMTYPE_ENEMY << 5
vc_hook_blue Reduce_move_anim_flashing_Blizzard
jr nz, .isNotType5
.isType5
call GetSubanimationTransform2
jr .saveTransformation
.isNotType5
vc_hook Reduce_move_anim_flashing_Hyper_Beam
call GetSubanimationTransform1
.saveTransformation
; place the upper 3 bits of a into bits 0-2 of a before storing
@ -307,6 +331,7 @@ LoadSubanimation:
; sets the transform to SUBANIMTYPE_NORMAL if it's the player's turn
; sets the transform to the subanimation type if it's the enemy's turn
GetSubanimationTransform1:
vc_hook Reduce_move_anim_flashing_Reflect
ld b, a
ldh a, [hWhoseTurn]
and a
@ -327,11 +352,11 @@ GetSubanimationTransform2:
ret
; loads tile patterns for battle animations
LoadAnimationTileset:
LoadMoveAnimationTiles:
ld a, [wWhichBattleAnimTileset]
add a
add a
ld hl, AnimationTilesetPointers
ld hl, MoveAnimationTilesPointers
ld e, a
ld d, 0
add hl, de
@ -342,28 +367,29 @@ LoadAnimationTileset:
ld a, [hl]
ld d, a ; de = address of tileset
ld hl, vSprites tile $31
ld b, BANK(AnimationTileset1) ; ROM bank
ld b, BANK(MoveAnimationTiles0) ; ROM bank
ld a, [wTempTilesetNumTiles]
ld c, a ; number of tiles
jp CopyVideoData ; load tileset
anim_tileset: MACRO
MACRO anim_tileset
db \1
dw \2
db -1 ; padding
ENDM
AnimationTilesetPointers:
MoveAnimationTilesPointers:
; number of tiles, gfx pointer
anim_tileset 79, AnimationTileset1
anim_tileset 79, AnimationTileset2
anim_tileset 64, AnimationTileset1
anim_tileset 79, MoveAnimationTiles0
anim_tileset 79, MoveAnimationTiles1
anim_tileset 64, MoveAnimationTiles2
AnimationTileset1:
INCBIN "gfx/battle/attack_anim_1.2bpp"
MoveAnimationTiles0:
MoveAnimationTiles2:
INCBIN "gfx/battle/move_anim_0.2bpp"
AnimationTileset2:
INCBIN "gfx/battle/attack_anim_2.2bpp"
MoveAnimationTiles1:
INCBIN "gfx/battle/move_anim_1.2bpp"
SlotMachineTiles2:
IF DEF(_RED)
@ -395,15 +421,19 @@ MoveAnimation:
.moveAnimation
; check if battle animations are disabled in the options
ld a, [wOptions]
bit 7, a
bit BIT_BATTLE_ANIMATION, a
jr nz, .animationsDisabled
call ShareMoveAnimations
call PlayAnimation
vc_hook_red Stop_reducing_move_anim_flashing_Bubblebeam_Mega_Kick
vc_hook_blue Stop_reducing_move_anim_flashing_Spore
jr .next4
.animationsDisabled
ld c, 30
call DelayFrames
.next4
vc_hook_red Stop_reducing_move_anim_flashing
vc_hook_blue Stop_reducing_move_anim_flashing_Rock_Slide_Dream_Eater
call PlayApplyingAttackAnimation ; shake the screen or flash the pic in and out (to show damage)
.animationFinished
call WaitForSoundToFinish
@ -541,6 +571,7 @@ SetAnimationPalette:
.notSGB
ld a, $e4
ld [wAnimPalette], a
vc_hook Reduce_move_anim_flashing_Dream_Eater
ldh [rOBP0], a
ld a, $6c
ldh [rOBP1], a
@ -553,7 +584,7 @@ PlaySubanimation:
call GetMoveSound
call nc, PlayBattleSound
.skipPlayingSound
ld hl, wOAMBuffer ; base address of OAM buffer
ld hl, wShadowOAM
ld a, l
ld [wFBDestAddr + 1], a
ld a, h
@ -653,7 +684,7 @@ INCLUDE "data/battle_anims/special_effects.asm"
DoBallTossSpecialEffects:
ld a, [wcf91]
cp 3 ; is it a Master Ball or Ultra Ball?
cp ULTRA_BALL + 1 ; is it a Master Ball or Ultra Ball?
jr nc, .skipFlashingEffect
.flashingEffect ; do a flashing effect if it's Master Ball or Ultra Ball
ldh a, [rOBP0]
@ -668,7 +699,7 @@ DoBallTossSpecialEffects:
call PlaySound
.skipPlayingSound
ld a, [wIsInBattle]
cp 02 ; is it a trainer battle?
cp 2 ; is it a trainer battle?
jr z, .isTrainerBattle
ld a, [wd11e]
cp $10 ; is the enemy pokemon the Ghost Marowak?
@ -825,7 +856,7 @@ TradeShakePokeball:
; if it's the end of the animation, make the ball jump up
ld de, BallMoveDistances1
.loop
ld hl, wOAMBuffer ; OAM buffer
ld hl, wShadowOAM
ld bc, 4
.innerLoop
ld a, [de]
@ -855,7 +886,7 @@ BallMoveDistances1:
TradeJumpPokeball:
ld de, BallMoveDistances2
.loop
ld hl, wOAMBuffer ; OAM buffer
ld hl, wShadowOAM
ld bc, 4
.innerLoop
ld a, [de]
@ -895,8 +926,8 @@ BallMoveDistances2:
; this function copies the current musical note graphic
; so that there are two musical notes flying towards the defending pokemon
DoGrowlSpecialEffects:
ld hl, wOAMBuffer ; OAM buffer
ld de, wOAMBuffer + $10
ld hl, wShadowOAM
ld de, wShadowOAMSprite04
ld bc, $10
call CopyData ; copy the musical note graphic
ld a, [wSubAnimCounter]
@ -956,6 +987,7 @@ AnimationFlashScreenLong:
ld [wFlashScreenLongCounter], a
pop hl
jr nz, .loop
vc_hook_red Stop_reducing_move_anim_flashing_Psychic
ret
; BG palettes
@ -1083,7 +1115,7 @@ AnimationWaterDropletsEverywhere:
; in Surf/Mist/Toxic.
xor a
ld [wWhichBattleAnimTileset], a
call LoadAnimationTileset
call LoadMoveAnimationTiles
ld d, 32
ld a, -16
ld [wBaseCoordX], a
@ -1105,7 +1137,7 @@ AnimationWaterDropletsEverywhere:
ret
_AnimationWaterDroplets:
ld hl, wOAMBuffer
ld hl, wShadowOAM
.loop
ld a, [wBaseCoordY]
ld [hli], a ; Y
@ -1233,7 +1265,7 @@ ShakeEnemyHUD_WritePlayerMonPicOAM:
ld [wBaseCoordX], a
ld a, $30
ld [wBaseCoordY], a
ld hl, wOAMBuffer
ld hl, wShadowOAM
ld d, 0
ld c, 7
.loop
@ -1467,7 +1499,7 @@ AnimationSpiralBallsInward:
.loop
push hl
ld c, 3
ld de, wOAMBuffer
ld de, wShadowOAM
.innerLoop
ld a, [hl]
cp $ff
@ -1603,10 +1635,10 @@ _AnimationShootBallsUpward:
push bc
xor a
ld [wWhichBattleAnimTileset], a
call LoadAnimationTileset
call LoadMoveAnimationTiles
pop bc
ld d, $7a ; ball tile
ld hl, wOAMBuffer
ld hl, wShadowOAM
push bc
ld a, [wBaseCoordY]
ld e, a
@ -1620,7 +1652,7 @@ _AnimationShootBallsUpward:
ld [wNumShootingBalls], a
.loop
push bc
ld hl, wOAMBuffer
ld hl, wShadowOAM
.innerLoop
ld a, [wBaseCoordY]
add 8
@ -1694,7 +1726,7 @@ AnimationMinimizeMon:
ld bc, 7 * 7 * $10
call FillMemory
pop hl
ld de, $194
ld de, 7 * 3 * $10 + 4 * $10 + 4
add hl, de
ld de, MinimizedMonSprite
ld c, MinimizedMonSpriteEnd - MinimizedMonSprite
@ -1710,7 +1742,15 @@ AnimationMinimizeMon:
jp AnimationShowMonPic
MinimizedMonSprite:
INCBIN "gfx/battle/minimize.1bpp"
; 8x5 partial tile graphic
pusho
opt b.X ; . = 0, X = 1
db %...XX...
db %..XXXX..
db %.XXXXXX.
db %..XXXX..
db %..X..X..
popo
MinimizedMonSpriteEnd:
AnimationSlideMonDownAndHide:
@ -2035,13 +2075,13 @@ InitMultipleObjectsOAM:
push bc
push de
ld [wWhichBattleAnimTileset], a
call LoadAnimationTileset
call LoadMoveAnimationTiles
pop de
pop bc
xor a
ld e, a
ld [wBaseCoordX], a
ld hl, wOAMBuffer
ld hl, wShadowOAM
.loop
call BattleAnimWriteOAMEntry
dec c
@ -2316,7 +2356,7 @@ AnimationFallingObjects:
call InitMultipleObjectsOAM
call FallingObjects_InitXCoords
call FallingObjects_InitMovementData
ld hl, wOAMBuffer
ld hl, wShadowOAM
ld [hl], 0
.loop
ld hl, wFallingObjectsMovementData
@ -2343,7 +2383,7 @@ AnimationFallingObjects:
dec c
jr nz, .innerLoop
call Delay3
ld hl, wOAMBuffer
ld hl, wShadowOAM
ld a, [hl] ; Y
cp 104 ; has the top falling object reached 104 yet?
jr nz, .loop ; keep moving the falling objects down until it does
@ -2352,7 +2392,7 @@ AnimationFallingObjects:
FallingObjects_UpdateOAMEntry:
; Increases Y by 2 pixels and adjusts X and X flip based on the falling object's
; movement byte.
ld hl, wOAMBuffer
ld hl, wShadowOAM
add hl, de
ld a, [hl]
inc a
@ -2413,7 +2453,7 @@ FallingObjects_UpdateMovementByte:
ret
FallingObjects_InitXCoords:
ld hl, wOAMBuffer + $01
ld hl, wShadowOAMSprite00XCoord
ld de, FallingObjects_InitialXCoords
ld a, [wNumFallingObjects]
ld c, a

View file

@ -26,7 +26,7 @@ BattleTransition:
jr nz, .loop1
; Clear OAM except for the blocks used by the player and enemy trainer sprites.
ld hl, wOAMBuffer + $10
ld hl, wShadowOAMSprite04
ld c, 9
.loop2
ld a, b
@ -662,7 +662,7 @@ BattleTransition_Circle_Sub2:
const CIRCLE_LEFT
const CIRCLE_RIGHT
half_circle: MACRO
MACRO half_circle
; quadrant x, circle data, target coord
db \1
dw \2

View file

@ -105,7 +105,7 @@ SlidePlayerAndEnemySilhouettesOnScreen:
; instead, the enemy pic is part of the background and uses the scroll register, while the player's head is a sprite and is slid by changing its X coordinates in a loop
SlidePlayerHeadLeft:
push bc
ld hl, wOAMBuffer + $01
ld hl, wShadowOAMSprite00XCoord
ld c, $15 ; number of OAM entries
ld de, $4 ; size of OAM entry
.loop
@ -308,7 +308,7 @@ MainInBattleLoop:
and a
ret nz ; return if pokedoll was used to escape from battle
ld a, [wBattleMonStatus]
and (1 << FRZ) | SLP ; is mon frozen or asleep?
and (1 << FRZ) | SLP_MASK
jr nz, .selectEnemyMove ; if so, jump
ld a, [wPlayerBattleStatus1]
and (1 << STORING_ENERGY) | (1 << USING_TRAPPING_MOVE) ; check player is using Bide or using a multi-turn attack like wrap
@ -402,12 +402,12 @@ MainInBattleLoop:
cp USING_INTERNAL_CLOCK
jr z, .invertOutcome
call BattleRandom
cp $80
cp 50 percent + 1
jr c, .playerMovesFirst
jr .enemyMovesFirst
.invertOutcome
call BattleRandom
cp $80
cp 50 percent + 1
jr c, .enemyMovesFirst
jr .playerMovesFirst
.enemyMovesFirst
@ -790,7 +790,7 @@ FaintEnemyPokemon:
call WaitForSoundToFinish
;.sfxwait
; ld a, [wChannelSoundIDs + Ch5]
; ld a, [wChannelSoundIDs + CHAN5]
; cp SFX_FAINT_FALL
; jr z, .sfxwait
@ -875,7 +875,7 @@ EndLowHealthAlarm:
; the low health alarm and prevents it from reactivating until the next battle.
xor a
ld [wLowHealthAlarm], a ; turn off low health alarm
; ld [wChannelSoundIDs + Ch5], a
; ld [wChannelSoundIDs + CHAN5], a
inc a
ld [wLowHealthAlarmDisabled], a ; prevent it from reactivating
ret
@ -1328,7 +1328,7 @@ EnemySendOutFirstMon:
ld [wWhichPokemon], a
jr .next3
.next
ld b, $FF
ld b, $ff
.next2
inc b
ld a, [wEnemyMonPartyPos]
@ -1381,7 +1381,7 @@ EnemySendOutFirstMon:
cp LINK_STATE_BATTLING
jr z, .next4
ld a, [wOptions]
bit 6, a
bit BIT_BATTLE_SHIFT, a
jr nz, .next4
ld hl, TrainerAboutToUseText
call PrintText
@ -1873,7 +1873,7 @@ DrawPlayerHUDAndHPBar:
ld [hl], $0
ret z
xor a
; ld [wChannelSoundIDs + Ch5], a
; ld [wChannelSoundIDs + CHAN5], a
ret
.setLowHealthAlarm
ld hl, wLowHealthAlarm
@ -2096,7 +2096,7 @@ DisplayBattleMenu::
ld [hli], a ; wMaxMenuItem
ld [hl], D_RIGHT | A_BUTTON ; wMenuWatchedKeys
call HandleMenuInput
bit 4, a ; check if right was pressed
bit BIT_D_RIGHT, a
jr nz, .rightColumn
jr .AButtonPressed ; the A button was pressed
.rightColumn ; put cursor in right column of menu
@ -2248,7 +2248,7 @@ UseBagItem:
ld a, [wcf91]
ld [wd11e], a
call GetItemName
call CopyStringToCF4B ; copy name
call CopyToStringBuffer
xor a
ld [wPseudoItemID], a
call UseItem
@ -2359,7 +2359,7 @@ PartyMenuOrRockOrRun:
xor a
ld [hl], a ; wLastMenuItem
call HandleMenuInput
bit 1, a ; was A pressed?
bit BIT_B_BUTTON, a
jr nz, .partyMonDeselected ; if B was pressed, jump
; A was pressed
call PlaceUnfilledArrowMenuCursor
@ -2943,7 +2943,7 @@ SelectEnemyMove:
and (1 << CHARGING_UP) | (1 << THRASHING_ABOUT) ; using a charging move or thrash/petal dance
ret nz
ld a, [wEnemyMonStatus]
and SLP | 1 << FRZ ; sleeping or frozen
and (1 << FRZ) | SLP_MASK
ret nz
ld a, [wEnemyBattleStatus1]
and (1 << USING_TRAPPING_MOVE) | (1 << STORING_ENERGY) ; using a trapping move like wrap or bide
@ -2971,19 +2971,19 @@ SelectEnemyMove:
.chooseRandomMove
push hl
call BattleRandom
ld b, $1
cp $3f ; select move 1, [0,3e] (63/256 chance)
ld b, 1 ; 25% chance to select move 1
cp 25 percent
jr c, .moveChosen
inc hl
inc b
cp $7f ; select move 2, [3f,7e] (64/256 chance)
inc b ; 25% chance to select move 2
cp 50 percent
jr c, .moveChosen
inc hl
inc b
cp $be ; select move 3, [7f,bd] (63/256 chance)
inc b ; 25% chance to select move 3
cp 75 percent - 1
jr c, .moveChosen
inc hl
inc b ; select move 4, [be,ff] (66/256 chance)
inc b ; 25% chance to select move 4
.moveChosen
ld a, b
dec a
@ -3032,6 +3032,7 @@ LinkBattleExchangeData:
ld a, b
.doExchange
ld [wSerialExchangeNybbleSendData], a
vc_hook Wireless_start_exchange
callfar PrintWaitingText
.syncLoop1
call Serial_ExchangeNybble
@ -3039,18 +3040,33 @@ LinkBattleExchangeData:
ld a, [wSerialExchangeNybbleReceiveData]
inc a
jr z, .syncLoop1
vc_hook Wireless_end_exchange
vc_patch Wireless_net_delay_1
IF DEF(_RED_VC) || DEF(_BLUE_VC)
ld b, 26
ELSE
ld b, 10
ENDC
vc_patch_end
.syncLoop2
call DelayFrame
call Serial_ExchangeNybble
dec b
jr nz, .syncLoop2
vc_hook Wireless_start_send_zero_bytes
vc_patch Wireless_net_delay_2
IF DEF(_RED_VC) || DEF(_BLUE_VC)
ld b, 26
ELSE
ld b, 10
ENDC
vc_patch_end
.syncLoop3
call DelayFrame
call Serial_SendZeroByte
dec b
jr nz, .syncLoop3
vc_hook Wireless_end_send_zero_bytes
ret
ExecutePlayerMove:
@ -3268,7 +3284,7 @@ PrintGhostText:
and a
jr nz, .Ghost
ld a, [wBattleMonStatus] ; player's turn
and SLP | (1 << FRZ)
and (1 << FRZ) | SLP_MASK
ret nz
ld hl, ScaredText
call PrintText
@ -3295,7 +3311,7 @@ IsGhostBattle:
ld a, [wCurMap]
cp POKEMON_TOWER_1F
jr c, .next
cp MR_FUJIS_HOUSE
cp POKEMON_TOWER_7F + 1
jr nc, .next
ld b, SILPH_SCOPE
call IsItemInBag
@ -3310,7 +3326,7 @@ IsGhostBattle:
CheckPlayerStatusConditions:
ld hl, wBattleMonStatus
ld a, [hl]
and SLP ; sleep mask
and SLP_MASK
jr z, .FrozenCheck
; sleeping
dec a
@ -3346,7 +3362,7 @@ CheckPlayerStatusConditions:
.HeldInPlaceCheck
ld a, [wEnemyBattleStatus1]
bit USING_TRAPPING_MOVE, a ; is enemy using a mult-turn move like wrap?
bit USING_TRAPPING_MOVE, a ; is enemy using a multi-turn move like wrap?
jp z, .FlinchedCheck
ld hl, CantMoveText
call PrintText
@ -3407,7 +3423,7 @@ CheckPlayerStatusConditions:
ld a, CONF_ANIM - 1
call PlayMoveAnimation
call BattleRandom
cp $80 ; 50% chance to hurt itself
cp 50 percent + 1 ; chance to hurt itself
jr c, .TriedToUseDisabledMoveCheck
ld hl, wPlayerBattleStatus1
ld a, [hl]
@ -3442,7 +3458,7 @@ CheckPlayerStatusConditions:
ld hl, wPlayerBattleStatus1
ld a, [hl]
; clear bide, thrashing, charging up, and trapping moves such as warp (already cleared for confusion damage)
and $ff ^ ((1 << STORING_ENERGY) | (1 << THRASHING_ABOUT) | (1 << CHARGING_UP) | (1 << USING_TRAPPING_MOVE))
and ~((1 << STORING_ENERGY) | (1 << THRASHING_ABOUT) | (1 << CHARGING_UP) | (1 << USING_TRAPPING_MOVE))
ld [hl], a
ld a, [wPlayerMoveEffect]
cp FLY_EFFECT
@ -3553,7 +3569,7 @@ CheckPlayerStatusConditions:
ld a, RAGE
ld [wd11e], a
call GetMoveName
call CopyStringToCF4B
call CopyToStringBuffer
xor a
ld [wPlayerMoveEffect], a
ld hl, PlayerCanExecuteMove
@ -3755,7 +3771,7 @@ PrintMoveName:
ret
_PrintMoveName:
text_far _CF4BText
text_far _MoveNameText
text_asm
ld hl, ExclamationPointPointerTable
ld a, [wd11e] ; exclamation point num
@ -4022,7 +4038,7 @@ CheckForDisobedience:
call BattleRandom
add a
swap a
and SLP ; sleep mask
and SLP_MASK
jr z, .monNaps ; keep trying until we get at least 1 turn of sleep
ld [wBattleMonStatus], a
ld hl, BeganToNapText
@ -4616,7 +4632,7 @@ CriticalHitTest:
dec hl
ld c, [hl] ; read move id
ld a, [de]
bit GETTING_PUMPED, a ; test for focus energy
bit GETTING_PUMPED, a ; test for focus energy
jr nz, .focusEnergyUsed ; bug: using focus energy causes a shift to the right instead of left,
; resulting in 1/4 the usual crit chance
sla b ; (effective (base speed/2)*2)
@ -5117,7 +5133,7 @@ ReloadMoveData:
call IncrementMovePP
; the follow two function calls are used to reload the move name
call GetMoveName
call CopyStringToCF4B
call CopyToStringBuffer
ld a, $01
and a
ret
@ -5137,12 +5153,13 @@ MetronomePickMove:
; values for enemy turn
ld de, wEnemyMoveNum
ld hl, wEnemySelectedMove
; loop to pick a random number in the range [1, $a5) to be the move used by Metronome
; loop to pick a random number in the range of valid moves used by Metronome
.pickMoveLoop
call BattleRandom
and a
jr z, .pickMoveLoop
cp NUM_ATTACKS ; max move number (including Struggle)
cp STRUGGLE
assert NUM_ATTACKS == STRUGGLE ; random numbers greater than STRUGGLE are not moves
jr nc, .pickMoveLoop
cp METRONOME
jr z, .pickMoveLoop
@ -5355,15 +5372,15 @@ MoveHitTest:
cp DREAM_EATER_EFFECT
jr nz, .swiftCheck
ld a, [bc]
and SLP ; is the target pokemon sleeping?
and SLP_MASK
jp z, .moveMissed
.swiftCheck
ld a, [de]
cp SWIFT_EFFECT
ret z ; Swift never misses (interestingly, Azure Heights lists this is a myth, but it appears to be true)
ret z ; Swift never misses (this was fixed from the Japanese versions)
call CheckTargetSubstitute ; substitute check (note that this overwrites a)
jr z, .checkForDigOrFlyStatus
; This code is buggy. It's supposed to prevent HP draining moves from working on substitutes.
; The fix for Swift broke this code. It's supposed to prevent HP draining moves from working on Substitutes.
; Since CheckTargetSubstitute overwrites a with either $00 or $01, it never works.
cp DRAIN_HP_EFFECT
jp z, .moveMissed
@ -5618,7 +5635,7 @@ EnemyCanExecuteChargingMove:
ld [wNameListType], a
call GetName
ld de, wcd6d
call CopyStringToCF4B
call CopyToStringBuffer
EnemyCanExecuteMove:
xor a
ld [wMonIsDisobedient], a
@ -5789,7 +5806,7 @@ ExecuteEnemyMoveDone:
CheckEnemyStatusConditions:
ld hl, wEnemyMonStatus
ld a, [hl]
and SLP ; sleep mask
and SLP_MASK
jr z, .checkIfFrozen
dec a ; decrement number of turns left
ld [wEnemyMonStatus], a
@ -5941,7 +5958,7 @@ CheckEnemyStatusConditions:
bit PAR, [hl]
jr z, .checkIfUsingBide
call BattleRandom
cp $3f ; 25% to be fully paralysed
cp 25 percent ; chance to be fully paralysed
jr nc, .checkIfUsingBide
ld hl, FullyParalyzedText
call PrintText
@ -5949,7 +5966,7 @@ CheckEnemyStatusConditions:
ld hl, wEnemyBattleStatus1
ld a, [hl]
; clear bide, thrashing about, charging up, and multi-turn moves such as warp
and $ff ^ ((1 << STORING_ENERGY) | (1 << THRASHING_ABOUT) | (1 << CHARGING_UP) | (1 << USING_TRAPPING_MOVE))
and ~((1 << STORING_ENERGY) | (1 << THRASHING_ABOUT) | (1 << CHARGING_UP) | (1 << USING_TRAPPING_MOVE))
ld [hl], a
ld a, [wEnemyMoveEffect]
cp FLY_EFFECT
@ -6055,7 +6072,7 @@ CheckEnemyStatusConditions:
ld a, RAGE
ld [wd11e], a
call GetMoveName
call CopyStringToCF4B
call CopyToStringBuffer
xor a
ld [wEnemyMoveEffect], a
ld hl, EnemyCanExecuteMove
@ -6097,7 +6114,7 @@ GetCurrentMove:
ld [wNameListType], a
call GetName
ld de, wcd6d
jp CopyStringToCF4B
jp CopyToStringBuffer
LoadEnemyMonData:
ld a, [wLinkState]
@ -6317,9 +6334,10 @@ LoadPlayerBackPic:
ld de, OldManPicBack
.next
ld a, BANK(RedPicBack)
ASSERT BANK(RedPicBack) == BANK(OldManPicBack)
call UncompressSpriteFromDE
predef ScaleSpriteByTwo
ld hl, wOAMBuffer
ld hl, wShadowOAM
xor a
ldh [hOAMTile], a ; initial tile number
ld b, $7 ; 7 columns
@ -6669,7 +6687,14 @@ BattleRandom:
ld a, [hl]
pop bc
pop hl
vc_hook Unknown_BattleRandom_ret_c
vc_patch BattleRandom_ret
IF DEF(_RED_VC) || DEF(_BLUE_VC)
ret
ELSE
ret c
ENDC
vc_patch_end
; if we picked the last seed, we need to recalculate the nine seeds
push hl
@ -6734,7 +6759,9 @@ HandleExplodingAnimation:
PlayMoveAnimation:
ld [wAnimationID], a
vc_hook_red Reduce_move_anim_flashing_Confusion
call Delay3
vc_hook_red Reduce_move_anim_flashing_Psychic
predef_jump MoveAnimation
InitBattle::
@ -6751,11 +6778,11 @@ InitOpponent:
DetermineWildOpponent:
ld a, [wd732]
bit 1, a
jr z, .asm_3ef2f
jr z, .notDebug
ldh a, [hJoyHeld]
bit 1, a ; B button pressed?
bit BIT_B_BUTTON, a
ret nz
.asm_3ef2f
.notDebug
ld a, [wNumberOfNoRandomBattleStepsLeft]
and a
ret nz
@ -6889,7 +6916,7 @@ _LoadTrainerPic:
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)
ld a, BANK("Pics 6") ; this is where all the trainer pics are (not counting Red's)
jr z, .loadSprite
ld a, BANK(RedPicFront)
.loadSprite
@ -6908,9 +6935,9 @@ ResetCryModifiers:
; animates the mon "growing" out of the pokeball
AnimateSendingOutMon:
ld a, [wPredefRegisters]
ld a, [wPredefHL]
ld h, a
ld a, [wPredefRegisters + 1]
ld a, [wPredefHL + 1]
ld l, a
ldh a, [hStartTileID]
ldh [hBaseTileID], a
@ -6948,9 +6975,9 @@ AnimateSendingOutMon:
jr CopyUncompressedPicToHL
CopyUncompressedPicToTilemap:
ld a, [wPredefRegisters]
ld a, [wPredefHL]
ld h, a
ld a, [wPredefRegisters + 1]
ld a, [wPredefHL + 1]
ld l, a
ldh a, [hStartTileID]
CopyUncompressedPicToHL::

View file

@ -27,7 +27,7 @@ SetupOwnPartyPokeballs:
ld [hl], a
ld a, 8
ld [wHUDPokeballGfxOffsetX], a
ld hl, wOAMBuffer
ld hl, wShadowOAM
jp WritePokeballOAMData
SetupEnemyPartyPokeballs:
@ -41,7 +41,7 @@ SetupEnemyPartyPokeballs:
ld [hl], $20
ld a, -8
ld [wHUDPokeballGfxOffsetX], a
ld hl, wOAMBuffer + PARTY_LENGTH * 4
ld hl, wShadowOAMSprite06
jp WritePokeballOAMData
SetupPokeballs:
@ -174,7 +174,7 @@ SetupPlayerAndEnemyPokeballs:
ld [hl], $40
ld a, 8
ld [wHUDPokeballGfxOffsetX], a
ld hl, wOAMBuffer
ld hl, wShadowOAM
call WritePokeballOAMData
ld hl, wEnemyMons
ld de, wEnemyPartyCount
@ -183,7 +183,7 @@ SetupPlayerAndEnemyPokeballs:
ld a, $50
ld [hli], a
ld [hl], $68
ld hl, wOAMBuffer + $18
ld hl, wShadowOAMSprite06
jp WritePokeballOAMData
; four tiles: pokeball, black pokeball (status ailment), crossed out pokeball (fainted) and pokeball slot (no mon)

View file

@ -98,10 +98,10 @@ PoisonEffect:
jr z, .noEffect
ld a, [de]
cp POISON_SIDE_EFFECT1
ld b, $34 ; ~20% chance of poisoning
ld b, 20 percent + 1 ; chance of poisoning
jr z, .sideEffectTest
cp POISON_SIDE_EFFECT2
ld b, $67 ; ~40% chance of poisoning
ld b, 40 percent + 1 ; chance of poisoning
jr z, .sideEffectTest
push hl
push de
@ -548,7 +548,7 @@ StatModifierDownEffect:
cp LINK_STATE_BATTLING
jr z, .statModifierDownEffect
call BattleRandom
cp $40 ; 1/4 chance to miss by in regular battle
cp 25 percent + 1 ; chance to miss by in regular battle
jp c, MoveMissed
.statModifierDownEffect
call CheckTargetSubstitute ; can't hit through substitute
@ -557,7 +557,7 @@ StatModifierDownEffect:
cp ATTACK_DOWN_SIDE_EFFECT
jr c, .nonSideEffect
call BattleRandom
cp $55 ; 85/256 chance for side effects
cp 33 percent + 1 ; chance for side effects
jp nc, CantLowerAnymore
ld a, [de]
sub ATTACK_DOWN_SIDE_EFFECT ; map each stat to 0-3
@ -751,7 +751,7 @@ PrintStatText:
jr z, .findStatName_outer
jr .findStatName_inner
.foundStatName
ld de, wcf4b
ld de, wStringBuffer
ld bc, $a
jp CopyData
@ -819,14 +819,14 @@ SwitchAndTeleportEffect:
jr nc, .playerMoveWasSuccessful ; if so, teleport will always succeed
add b
ld c, a
inc c ; c = sum of player level and enemy level
inc c ; c = playerLevel + enemyLevel + 1
.rejectionSampleLoop1
call BattleRandom
cp c ; get a random number between 0 and c
jr nc, .rejectionSampleLoop1
srl b
srl b ; b = enemyLevel / 4
cp b ; is rand[0, playerLevel + enemyLevel) >= (enemyLevel / 4)?
cp b ; is rand[0, playerLevel + enemyLevel] >= (enemyLevel / 4)?
jr nc, .playerMoveWasSuccessful ; if so, allow teleporting
ld c, 50
call DelayFrames
@ -979,9 +979,9 @@ FlinchSideEffect:
.flinchSideEffect
ld a, [de]
cp FLINCH_SIDE_EFFECT1
ld b, $1a ; ~10% chance of flinch
ld b, 10 percent + 1 ; chance of flinch (FLINCH_SIDE_EFFECT1)
jr z, .gotEffectChance
ld b, $4d ; ~30% chance of flinch
ld b, 30 percent + 1 ; chance of flinch otherwise
.gotEffectChance
call BattleRandom
cp b
@ -1111,7 +1111,7 @@ RecoilEffect:
ConfusionSideEffect:
call BattleRandom
cp $19 ; ~10% chance
cp 10 percent ; chance of confusion
ret nc
jr ConfusionSideEffectSuccess

View file

@ -46,7 +46,7 @@ EndOfBattle:
.resetVariables
xor a
ld [wLowHealthAlarm], a ;disable low health alarm
; ld [wChannelSoundIDs + Ch5], a
; ld [wChannelSoundIDs + CHAN5], a
ld [wIsInBattle], a
ld [wBattleType], a
ld [wMoveMissed], a

View file

@ -58,7 +58,7 @@ CopyMonPicFromBGToSpriteVRAM:
ld [wBaseCoordY], a
ld a, $70
ld [wBaseCoordX], a
ld hl, wOAMBuffer
ld hl, wShadowOAM
lb bc, 6, 6
ld d, $8
.oamLoop

View file

@ -113,7 +113,7 @@ GetMonSpecies:
ld hl, wBoxSpecies
jr .getSpecies
.enemyParty
ld hl, wEnemyPartyMons
ld hl, wEnemyPartySpecies
.getSpecies
ld d, 0
add hl, de

View file

@ -24,7 +24,7 @@ HazeEffect_:
.cureStatuses
ld a, [hl]
ld [hl], $0
and SLP | (1 << FRZ)
and (1 << FRZ) | SLP_MASK
jr z, .cureVolatileStatuses
; prevent the Pokemon from executing a move if it was asleep or frozen
ld a, $ff
@ -51,7 +51,7 @@ CureVolatileStatuses:
inc hl ; BATTSTATUS2
ld a, [hl]
; clear USING_X_ACCURACY, PROTECTED_BY_MIST, GETTING_PUMPED, and SEEDED statuses
and $ff ^((1 << USING_X_ACCURACY) | (1 << PROTECTED_BY_MIST) | (1 << GETTING_PUMPED) | (1 << SEEDED))
and ~((1 << USING_X_ACCURACY) | (1 << PROTECTED_BY_MIST) | (1 << GETTING_PUMPED) | (1 << SEEDED))
ld [hli], a ; BATTSTATUS3
ld a, [hl]
and %11110000 | (1 << TRANSFORMED) ; clear Bad Poison, Reflect and Light Screen statuses

View file

@ -45,7 +45,7 @@ SubstituteEffect_:
ld l, c
set HAS_SUBSTITUTE_UP, [hl]
ld a, [wOptions]
bit 7, a ; battle animation is enabled?
bit BIT_BATTLE_ANIMATION, a
ld hl, PlayCurrentMoveAnimation
ld b, BANK(PlayCurrentMoveAnimation)
jr z, .animationEnabled

View file

@ -5,7 +5,7 @@ ReadTrainer:
and a
ret nz
; set [wEnemyPartyCount] to 0, [wEnemyPartyMons] to FF
; set [wEnemyPartyCount] to 0, [wEnemyPartySpecies] to FF
; XXX first is total enemy pokemon?
; XXX second is species of first pokemon?
ld hl, wEnemyPartyCount

View file

@ -342,7 +342,10 @@ CooltrainerMAI:
jp AIUseXAttack
CooltrainerFAI:
; The intended 25% chance to consider switching will not apply.
; Uncomment the line below to fix this.
cp 25 percent + 1
; ret nc
ld a, 10
call AICheckIfHPBelowFraction
jp c, AIUseHyperPotion