H_CONSTANTNAMES -> hConstantNames

This commit is contained in:
Rangi 2020-07-03 19:59:41 -04:00
parent 55bb99580e
commit 35deb77113
104 changed files with 1163 additions and 1164 deletions

View file

@ -308,7 +308,7 @@ LoadSubanimation:
; sets the transform to the subanimation type if it's the enemy's turn ; sets the transform to the subanimation type if it's the enemy's turn
GetSubanimationTransform1: GetSubanimationTransform1:
ld b, a ld b, a
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld a, b ld a, b
ret nz ret nz
@ -319,7 +319,7 @@ GetSubanimationTransform1:
; sets the transform to 2 (i.e. horizontal and vertical flip) if it's the player's turn ; sets the transform to 2 (i.e. horizontal and vertical flip) if it's the player's turn
; sets the transform to 0 (i.e. no transform) if it's the enemy's turn ; sets the transform to 0 (i.e. no transform) if it's the enemy's turn
GetSubanimationTransform2: GetSubanimationTransform2:
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld a, 2 << 5 ld a, 2 << 5
ret z ret z
@ -421,7 +421,7 @@ MoveAnimation:
ShareMoveAnimations: ShareMoveAnimations:
; some moves just reuse animations from status conditions ; some moves just reuse animations from status conditions
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ret z ret z
@ -920,16 +920,16 @@ AnimationDelay10:
; calls a function with the turn flipped from player to enemy or vice versa ; calls a function with the turn flipped from player to enemy or vice versa
; input - hl - address of function to call ; input - hl - address of function to call
CallWithTurnFlipped: CallWithTurnFlipped:
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
push af push af
xor 1 xor 1
ld [H_WHOSETURN], a ld [hWhoseTurn], a
ld de, .returnAddress ld de, .returnAddress
push de push de
jp hl jp hl
.returnAddress .returnAddress
pop af pop af
ld [H_WHOSETURN], a ld [hWhoseTurn], a
ret ret
; flashes the screen for an extended period (48 frames) ; flashes the screen for an extended period (48 frames)
@ -1133,7 +1133,7 @@ _AnimationWaterDroplets:
AnimationSlideMonUp: AnimationSlideMonUp:
; Slides the mon's sprite upwards. ; Slides the mon's sprite upwards.
ld c, 7 ld c, 7
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
coord hl, 1, 6 coord hl, 1, 6
coord de, 1, 5 coord de, 1, 5
@ -1201,7 +1201,7 @@ _AnimationSlideMonUp:
jr nz, .slideLoop jr nz, .slideLoop
; Fill in the bottom row of the mon pic with the next row's tile IDs. ; Fill in the bottom row of the mon pic with the next row's tile IDs.
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
coord hl, 1, 11 coord hl, 1, 11
jr z, .next jr z, .next
@ -1370,7 +1370,7 @@ AnimationShowEnemyMonPic:
AnimationShakeBackAndForth: AnimationShakeBackAndForth:
; Shakes the mon's sprite back and forth rapidly. This is used in Double Team. ; Shakes the mon's sprite back and forth rapidly. This is used in Double Team.
; The mon's sprite disappears after this animation. ; The mon's sprite disappears after this animation.
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
coord hl, 0, 5 coord hl, 0, 5
coord de, 2, 5 coord de, 2, 5
@ -1418,7 +1418,7 @@ AnimationMoveMonHorizontally:
; Shifts the mon's sprite horizontally to a fixed location. Used by lots of ; Shifts the mon's sprite horizontally to a fixed location. Used by lots of
; animations like Tackle/Body Slam. ; animations like Tackle/Body Slam.
call AnimationHideMonPic call AnimationHideMonPic
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
coord hl, 2, 5 coord hl, 2, 5
jr z, .next jr z, .next
@ -1434,7 +1434,7 @@ AnimationMoveMonHorizontally:
AnimationResetMonPosition: AnimationResetMonPosition:
; Resets the mon's sprites to be located at the normal coordinates. ; Resets the mon's sprites to be located at the normal coordinates.
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld a, 5 * SCREEN_WIDTH + 2 ld a, 5 * SCREEN_WIDTH + 2
jr z, .next jr z, .next
@ -1446,7 +1446,7 @@ AnimationResetMonPosition:
AnimationSpiralBallsInward: AnimationSpiralBallsInward:
; Creates an effect that looks like energy balls spiralling into the ; Creates an effect that looks like energy balls spiralling into the
; player mon's sprite. Used in Focus Energy, for example. ; player mon's sprite. Used in Focus Energy, for example.
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .playerTurn jr z, .playerTurn
ld a, -40 ld a, -40
@ -1530,7 +1530,7 @@ AnimationSquishMonPic:
ld c, 4 ld c, 4
.loop .loop
push bc push bc
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .playerTurn jr z, .playerTurn
coord hl, 16, 0 coord hl, 16, 0
@ -1583,7 +1583,7 @@ _AnimationSquishMonPic:
AnimationShootBallsUpward: AnimationShootBallsUpward:
; Shoots one pillar of "energy" balls upwards. Used in Teleport/Sky Attack ; Shoots one pillar of "energy" balls upwards. Used in Teleport/Sky Attack
; animations. ; animations.
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .playerTurn jr z, .playerTurn
lb bc, 0, 16 * 8 lb bc, 0, 16 * 8
@ -1651,7 +1651,7 @@ _AnimationShootBallsUpward:
AnimationShootManyBallsUpward: AnimationShootManyBallsUpward:
; Shoots several pillars of "energy" balls upward. ; Shoots several pillars of "energy" balls upward.
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld hl, UpwardBallsAnimXCoordinatesPlayerTurn ld hl, UpwardBallsAnimXCoordinatesPlayerTurn
ld a, $50 ; y coordinate for "energy" ball pillar ld a, $50 ; y coordinate for "energy" ball pillar
@ -1743,7 +1743,7 @@ AnimationSlideMonDownAndHide:
_AnimationSlideMonOff: _AnimationSlideMonOff:
; Slides the mon's sprite off the screen horizontally by e tiles and waits ; Slides the mon's sprite off the screen horizontally by e tiles and waits
; [wSlideMonDelay] V-blanks each time the pic is slid by one tile. ; [wSlideMonDelay] V-blanks each time the pic is slid by one tile.
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .playerTurn jr z, .playerTurn
coord hl, 12, 0 coord hl, 12, 0
@ -1758,7 +1758,7 @@ _AnimationSlideMonOff:
.rowLoop ; iterates once for each row .rowLoop ; iterates once for each row
ld c, 8 ld c, 8
.tileLoop ; iterates once for each tile in the row .tileLoop ; iterates once for each tile in the row
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .playerTurn2 jr z, .playerTurn2
call .EnemyNextTile call .EnemyNextTile
@ -1821,7 +1821,7 @@ AnimationSlideMonHalfOff:
jp Delay3 jp Delay3
CopyTempPicToMonPic: CopyTempPicToMonPic:
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld hl, vBackPic ; player turn ld hl, vBackPic ; player turn
jr z, .next jr z, .next
@ -1837,7 +1837,7 @@ AnimationWavyScreen:
call BattleAnimCopyTileMapToVRAM call BattleAnimCopyTileMapToVRAM
call Delay3 call Delay3
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ld a, SCREEN_HEIGHT_PIXELS ld a, SCREEN_HEIGHT_PIXELS
ld [hWY], a ld [hWY], a
ld d, $80 ; terminator ld d, $80 ; terminator
@ -1865,7 +1865,7 @@ AnimationWavyScreen:
call SaveScreenTilesToBuffer2 call SaveScreenTilesToBuffer2
call ClearScreen call ClearScreen
ld a, 1 ld a, 1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
call Delay3 call Delay3
call LoadScreenTilesFromBuffer2 call LoadScreenTilesFromBuffer2
ld hl, vBGMap1 ld hl, vBGMap1
@ -1898,7 +1898,7 @@ AnimationSubstitute:
xor a xor a
ld bc, $0310 ld bc, $0310
call FillMemory call FillMemory
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .playerTurn jr z, .playerTurn
ld hl, SlowbroSprite ; facing down sprite ld hl, SlowbroSprite ; facing down sprite
@ -1937,7 +1937,7 @@ CopySlowbroSpriteData:
jp FarCopyData2 jp FarCopyData2
HideSubstituteShowMonAnim: HideSubstituteShowMonAnim:
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld hl, wPlayerMonMinimized ld hl, wPlayerMonMinimized
ld a, [wPlayerBattleStatus2] ld a, [wPlayerBattleStatus2]
@ -1987,7 +1987,7 @@ AnimationTransformMon:
ld [wChangeMonPicEnemyTurnSpecies], a ld [wChangeMonPicEnemyTurnSpecies], a
ChangeMonPic: ChangeMonPic:
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .playerTurn jr z, .playerTurn
ld a, [wChangeMonPicEnemyTurnSpecies] ld a, [wChangeMonPicEnemyTurnSpecies]
@ -2020,11 +2020,11 @@ ChangeMonPic:
AnimationHideEnemyMonPic: AnimationHideEnemyMonPic:
; Hides the enemy mon's sprite ; Hides the enemy mon's sprite
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ld hl, AnimationHideMonPic ld hl, AnimationHideMonPic
call CallWithTurnFlipped call CallWithTurnFlipped
ld a, $1 ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
jp Delay3 jp Delay3
InitMultipleObjectsOAM: InitMultipleObjectsOAM:
@ -2050,7 +2050,7 @@ InitMultipleObjectsOAM:
AnimationHideMonPic: AnimationHideMonPic:
; Hides the mon's sprite. ; Hides the mon's sprite.
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .playerTurn jr z, .playerTurn
ld a, 12 ld a, 12
@ -2078,7 +2078,7 @@ ClearMonPicFromTileMap:
; in order to show only a portion of the mon sprite. ; in order to show only a portion of the mon sprite.
GetMonSpriteTileMapPointerFromRowCount: GetMonSpriteTileMapPointerFromRowCount:
push de push de
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr nz, .enemyTurn jr nz, .enemyTurn
ld a, 20 * 5 + 1 ld a, 20 * 5 + 1
@ -2166,7 +2166,7 @@ GetMoveSound:
ld b, a ld b, a
call IsCryMove call IsCryMove
jr nc, .NotCryMove jr nc, .NotCryMove
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr nz, .next jr nz, .next
ld a, [wBattleMonSpecies] ; get number of current monster ld a, [wBattleMonSpecies] ; get number of current monster
@ -2211,7 +2211,7 @@ IsCryMove:
INCLUDE "data/moves/sfx.asm" INCLUDE "data/moves/sfx.asm"
CopyPicTiles: CopyPicTiles:
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld a, $31 ; base tile ID of player mon sprite ld a, $31 ; base tile ID of player mon sprite
jr z, .next jr z, .next
@ -2235,7 +2235,7 @@ CopyDownscaledMonTiles:
CopyTileIDs_NoBGTransfer: CopyTileIDs_NoBGTransfer:
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
; fall through ; fall through
; b = number of rows ; b = number of rows
@ -2261,7 +2261,7 @@ CopyTileIDs:
dec b dec b
jr nz, .rowLoop jr nz, .rowLoop
ld a, $1 ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
pop hl pop hl
ret ret
@ -2624,9 +2624,9 @@ ShakeEnemyHUD_ShakeBG:
BattleAnimCopyTileMapToVRAM: BattleAnimCopyTileMapToVRAM:
ld a, h ld a, h
ld [H_AUTOBGTRANSFERDEST + 1], a ld [hAutoBGTransferDest + 1], a
ld a, l ld a, l
ld [H_AUTOBGTRANSFERDEST], a ld [hAutoBGTransferDest], a
jp Delay3 jp Delay3
TossBallAnimation: TossBallAnimation:

View file

@ -1,6 +1,6 @@
BattleTransition: BattleTransition:
ld a, 1 ld a, 1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
call Delay3 call Delay3
xor a xor a
ld [hWY], a ld [hWY], a
@ -349,7 +349,7 @@ BattleTransition_Shrink:
.loop .loop
push bc push bc
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
coord hl, 0, 7 coord hl, 0, 7
coord de, 0, 8 coord de, 0, 8
ld bc, -SCREEN_WIDTH * 2 ld bc, -SCREEN_WIDTH * 2
@ -367,7 +367,7 @@ BattleTransition_Shrink:
ld bc, 2 ld bc, 2
call BattleTransition_CopyTiles2 call BattleTransition_CopyTiles2
ld a, $1 ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ld c, 6 ld c, 6
call DelayFrames call DelayFrames
pop bc pop bc
@ -381,7 +381,7 @@ BattleTransition_Shrink:
BattleTransition_Split: BattleTransition_Split:
ld c, SCREEN_HEIGHT / 2 ld c, SCREEN_HEIGHT / 2
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
.loop .loop
push bc push bc
coord hl, 0, 16 coord hl, 0, 16
@ -496,7 +496,7 @@ BattleTransition_VerticalStripes:
coord hl, 0, 0 coord hl, 0, 0
coord de, 1, 17 coord de, 1, 17
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
.loop .loop
push bc push bc
push hl push hl
@ -535,7 +535,7 @@ BattleTransition_HorizontalStripes:
coord hl, 0, 0 coord hl, 0, 0
coord de, 19, 1 coord de, 19, 1
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
.loop .loop
push bc push bc
push hl push hl
@ -582,7 +582,7 @@ BattleTransition_FlashScreen:
ld b, $3 ld b, $3
call BattleTransition_FlashScreen_ call BattleTransition_FlashScreen_
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ret ret
BattleTransition_Circle_Sub1: BattleTransition_Circle_Sub1:
@ -601,10 +601,10 @@ BattleTransition_Circle_Sub1:
BattleTransition_TransferDelay3: BattleTransition_TransferDelay3:
ld a, 1 ld a, 1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
call Delay3 call Delay3
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ret ret
; used for low level wild non-dungeon battles ; used for low level wild non-dungeon battles

View file

@ -101,16 +101,16 @@ PrintSendOutMonMessage:
ld hl, GoText ld hl, GoText
jr z, .printText jr z, .printText
xor a xor a
ld [H_MULTIPLICAND], a ld [hMultiplicand], a
ld hl, wEnemyMonHP ld hl, wEnemyMonHP
ld a, [hli] ld a, [hli]
ld [wLastSwitchInEnemyMonHP], a ld [wLastSwitchInEnemyMonHP], a
ld [H_MULTIPLICAND + 1], a ld [hMultiplicand + 1], a
ld a, [hl] ld a, [hl]
ld [wLastSwitchInEnemyMonHP + 1], a ld [wLastSwitchInEnemyMonHP + 1], a
ld [H_MULTIPLICAND + 2], a ld [hMultiplicand + 2], a
ld a, 25 ld a, 25
ld [H_MULTIPLIER], a ld [hMultiplier], a
call Multiply call Multiply
ld hl, wEnemyMonMaxHP ld hl, wEnemyMonMaxHP
ld a, [hli] ld a, [hli]
@ -121,9 +121,9 @@ PrintSendOutMonMessage:
rr b rr b
ld a, b ld a, b
ld b, 4 ld b, 4
ld [H_DIVISOR], a ; enemy mon max HP divided by 4 ld [hDivisor], a ; enemy mon max HP divided by 4
call Divide call Divide
ld a, [H_QUOTIENT + 3] ; a = (enemy mon current HP * 25) / (enemy max HP / 4); this approximates the current percentage of max HP ld a, [hQuotient + 3] ; a = (enemy mon current HP * 25) / (enemy max HP / 4); this approximates the current percentage of max HP
ld hl, GoText ; 70% or greater ld hl, GoText ; 70% or greater
cp 70 cp 70
jr nc, .printText jr nc, .printText
@ -179,14 +179,14 @@ PlayerMon2Text:
dec hl dec hl
ld a, [de] ld a, [de]
sub b sub b
ld [H_MULTIPLICAND + 2], a ld [hMultiplicand + 2], a
dec de dec de
ld b, [hl] ld b, [hl]
ld a, [de] ld a, [de]
sbc b sbc b
ld [H_MULTIPLICAND + 1], a ld [hMultiplicand + 1], a
ld a, 25 ld a, 25
ld [H_MULTIPLIER], a ld [hMultiplier], a
call Multiply call Multiply
ld hl, wEnemyMonMaxHP ld hl, wEnemyMonMaxHP
ld a, [hli] ld a, [hli]
@ -197,11 +197,11 @@ PlayerMon2Text:
rr b rr b
ld a, b ld a, b
ld b, 4 ld b, 4
ld [H_DIVISOR], a ld [hDivisor], a
call Divide call Divide
pop bc pop bc
pop de pop de
ld a, [H_QUOTIENT + 3] ; a = ((LastSwitchInEnemyMonHP - CurrentEnemyMonHP) / 25) / (EnemyMonMaxHP / 4) ld a, [hQuotient + 3] ; a = ((LastSwitchInEnemyMonHP - CurrentEnemyMonHP) / 25) / (EnemyMonMaxHP / 4)
; Assuming that the enemy mon hasn't gained HP since the last switch in, ; Assuming that the enemy mon hasn't gained HP since the last switch in,
; a approximates the percentage that the enemy mon's total HP has decreased ; a approximates the percentage that the enemy mon's total HP has decreased
; since the last switch in. ; since the last switch in.

View file

@ -57,7 +57,7 @@ SlidePlayerAndEnemySilhouettesOnScreen:
ld [wUpdateSpritesEnabled], a ld [wUpdateSpritesEnabled], a
call Delay3 call Delay3
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ld b, $70 ld b, $70
ld c, $90 ld c, $90
ld a, c ld a, c
@ -83,7 +83,7 @@ SlidePlayerAndEnemySilhouettesOnScreen:
dec c dec c
jr nz, .slideSilhouettesLoop jr nz, .slideSilhouettesLoop
ld a, $1 ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ld a, $31 ld a, $31
ld [hStartTileID], a ld [hStartTileID], a
coord hl, 1, 5 coord hl, 1, 5
@ -92,7 +92,7 @@ SlidePlayerAndEnemySilhouettesOnScreen:
ld [hWY], a ld [hWY], a
ld [rWY], a ld [rWY], a
inc a inc a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
call Delay3 call Delay3
ld b, SET_PAL_BATTLE ld b, SET_PAL_BATTLE
call RunPaletteCommand call RunPaletteCommand
@ -266,7 +266,7 @@ EnemyRan:
ld a, SFX_RUN ld a, SFX_RUN
call PlaySoundWaitForCurrent call PlaySoundWaitForCurrent
xor a xor a
ld [H_WHOSETURN], a ld [hWhoseTurn], a
jpab AnimationSlideEnemyMonOff jpab AnimationSlideEnemyMonOff
WildRanText: WildRanText:
@ -412,7 +412,7 @@ MainInBattleLoop:
jr .playerMovesFirst jr .playerMovesFirst
.enemyMovesFirst .enemyMovesFirst
ld a, $1 ld a, $1
ld [H_WHOSETURN], a ld [hWhoseTurn], a
callab TrainerAI callab TrainerAI
jr c, .AIActionUsedEnemyFirst jr c, .AIActionUsedEnemyFirst
call ExecuteEnemyMove call ExecuteEnemyMove
@ -450,7 +450,7 @@ MainInBattleLoop:
jp z, HandlePlayerMonFainted jp z, HandlePlayerMonFainted
call DrawHUDsAndHPBars call DrawHUDsAndHPBars
ld a, $1 ld a, $1
ld [H_WHOSETURN], a ld [hWhoseTurn], a
callab TrainerAI callab TrainerAI
jr c, .AIActionUsedPlayerFirst jr c, .AIActionUsedPlayerFirst
call ExecuteEnemyMove call ExecuteEnemyMove
@ -470,7 +470,7 @@ MainInBattleLoop:
HandlePoisonBurnLeechSeed: HandlePoisonBurnLeechSeed:
ld hl, wBattleMonHP ld hl, wBattleMonHP
ld de, wBattleMonStatus ld de, wBattleMonStatus
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .playersTurn jr z, .playersTurn
ld hl, wEnemyMonHP ld hl, wEnemyMonHP
@ -495,7 +495,7 @@ HandlePoisonBurnLeechSeed:
call HandlePoisonBurnLeechSeed_DecreaseOwnHP call HandlePoisonBurnLeechSeed_DecreaseOwnHP
.notBurnedOrPoisoned .notBurnedOrPoisoned
ld de, wPlayerBattleStatus2 ld de, wPlayerBattleStatus2
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .playersTurn2 jr z, .playersTurn2
ld de, wEnemyBattleStatus2 ld de, wEnemyBattleStatus2
@ -504,16 +504,16 @@ HandlePoisonBurnLeechSeed:
add a add a
jr nc, .notLeechSeeded jr nc, .notLeechSeeded
push hl push hl
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
push af push af
xor $1 xor $1
ld [H_WHOSETURN], a ld [hWhoseTurn], a
xor a xor a
ld [wAnimationType], a ld [wAnimationType], a
ld a, ABSORB ld a, ABSORB
call PlayMoveAnimation ; play leech seed animation (from opposing mon) call PlayMoveAnimation ; play leech seed animation (from opposing mon)
pop af pop af
ld [H_WHOSETURN], a ld [hWhoseTurn], a
pop hl pop hl
call HandlePoisonBurnLeechSeed_DecreaseOwnHP call HandlePoisonBurnLeechSeed_DecreaseOwnHP
call HandlePoisonBurnLeechSeed_IncreaseEnemyHP call HandlePoisonBurnLeechSeed_IncreaseEnemyHP
@ -571,7 +571,7 @@ HandlePoisonBurnLeechSeed_DecreaseOwnHP:
.nonZeroDamage .nonZeroDamage
ld hl, wPlayerBattleStatus3 ld hl, wPlayerBattleStatus3
ld de, wPlayerToxicCounter ld de, wPlayerToxicCounter
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .playersTurn jr z, .playersTurn
ld hl, wEnemyBattleStatus3 ld hl, wEnemyBattleStatus3
@ -618,7 +618,7 @@ HandlePoisonBurnLeechSeed_DecreaseOwnHP:
HandlePoisonBurnLeechSeed_IncreaseEnemyHP: HandlePoisonBurnLeechSeed_IncreaseEnemyHP:
push hl push hl
ld hl, wEnemyMonMaxHP ld hl, wEnemyMonMaxHP
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .playersTurn jr z, .playersTurn
ld hl, wBattleMonMaxHP ld hl, wBattleMonMaxHP
@ -655,19 +655,19 @@ HandlePoisonBurnLeechSeed_IncreaseEnemyHP:
ld [hl], a ld [hl], a
ld [wHPBarNewHP], a ld [wHPBarNewHP], a
.noOverfullHeal .noOverfullHeal
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
xor $1 xor $1
ld [H_WHOSETURN], a ld [hWhoseTurn], a
call UpdateCurMonHPBar call UpdateCurMonHPBar
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
xor $1 xor $1
ld [H_WHOSETURN], a ld [hWhoseTurn], a
pop hl pop hl
ret ret
UpdateCurMonHPBar: UpdateCurMonHPBar:
coord hl, 10, 9 ; tile pointer to player HP bar coord hl, 10, 9 ; tile pointer to player HP bar
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld a, $1 ld a, $1
jr z, .playersTurn jr z, .playersTurn
@ -1177,7 +1177,7 @@ LinkBattleLostText:
db "@" db "@"
; slides pic of fainted mon downwards until it disappears ; slides pic of fainted mon downwards until it disappears
; bug: when this is called, [H_AUTOBGTRANSFERENABLED] is non-zero, so there is screen tearing ; bug: when this is called, [hAutoBGTransferEnabled] is non-zero, so there is screen tearing
SlideDownFaintedMonPic: SlideDownFaintedMonPic:
ld a, [wd730] ld a, [wd730]
push af push af
@ -1230,7 +1230,7 @@ SevenSpacesText:
; slides the player or enemy trainer off screen ; slides the player or enemy trainer off screen
; a is the number of tiles to slide it horizontally (always 9 for the player trainer or 8 for the enemy trainer) ; a is the number of tiles to slide it horizontally (always 9 for the player trainer or 8 for the enemy trainer)
; if a is 8, the slide is to the right, else it is to the left ; if a is 8, the slide is to the right, else it is to the left
; bug: when this is called, [H_AUTOBGTRANSFERENABLED] is non-zero, so there is screen tearing ; bug: when this is called, [hAutoBGTransferEnabled] is non-zero, so there is screen tearing
SlideTrainerPicOffScreen: SlideTrainerPicOffScreen:
ld [hSlideAmount], a ld [hSlideAmount], a
ld c, a ld c, a
@ -1508,29 +1508,29 @@ TryRunningFromBattle:
inc a inc a
ld [wNumRunAttempts], a ld [wNumRunAttempts], a
ld a, [hli] ld a, [hli]
ld [H_MULTIPLICAND + 1], a ld [hMultiplicand + 1], a
ld a, [hl] ld a, [hl]
ld [H_MULTIPLICAND + 2], a ld [hMultiplicand + 2], a
ld a, [de] ld a, [de]
ld [hEnemySpeed], a ld [hEnemySpeed], a
inc de inc de
ld a, [de] ld a, [de]
ld [hEnemySpeed + 1], a ld [hEnemySpeed + 1], a
call LoadScreenTilesFromBuffer1 call LoadScreenTilesFromBuffer1
ld de, H_MULTIPLICAND + 1 ld de, hMultiplicand + 1
ld hl, hEnemySpeed ld hl, hEnemySpeed
ld c, 2 ld c, 2
call StringCmp call StringCmp
jr nc, .canEscape ; jump if player speed greater than enemy speed jr nc, .canEscape ; jump if player speed greater than enemy speed
xor a xor a
ld [H_MULTIPLICAND], a ld [hMultiplicand], a
ld a, 32 ld a, 32
ld [H_MULTIPLIER], a ld [hMultiplier], a
call Multiply ; multiply player speed by 32 call Multiply ; multiply player speed by 32
ld a, [H_PRODUCT + 2] ld a, [hProduct + 2]
ld [H_DIVIDEND], a ld [hDividend], a
ld a, [H_PRODUCT + 3] ld a, [hProduct + 3]
ld [H_DIVIDEND + 1], a ld [hDividend + 1], a
ld a, [hEnemySpeed] ld a, [hEnemySpeed]
ld b, a ld b, a
ld a, [hEnemySpeed + 1] ld a, [hEnemySpeed + 1]
@ -1541,10 +1541,10 @@ TryRunningFromBattle:
rr a rr a
and a and a
jr z, .canEscape ; jump if enemy speed divided by 4, mod 256 is 0 jr z, .canEscape ; jump if enemy speed divided by 4, mod 256 is 0
ld [H_DIVISOR], a ; ((enemy speed / 4) % 256) ld [hDivisor], a ; ((enemy speed / 4) % 256)
ld b, $2 ld b, $2
call Divide ; divide (player speed * 32) by ((enemy speed / 4) % 256) call Divide ; divide (player speed * 32) by ((enemy speed / 4) % 256)
ld a, [H_QUOTIENT + 2] ld a, [hQuotient + 2]
and a ; is the quotient greater than 256? and a ; is the quotient greater than 256?
jr nz, .canEscape ; if so, the player can escape jr nz, .canEscape ; if so, the player can escape
ld a, [wNumRunAttempts] ld a, [wNumRunAttempts]
@ -1554,15 +1554,15 @@ TryRunningFromBattle:
dec c dec c
jr z, .compareWithRandomValue jr z, .compareWithRandomValue
ld b, 30 ld b, 30
ld a, [H_QUOTIENT + 3] ld a, [hQuotient + 3]
add b add b
ld [H_QUOTIENT + 3], a ld [hQuotient + 3], a
jr c, .canEscape jr c, .canEscape
jr .loop jr .loop
.compareWithRandomValue .compareWithRandomValue
call BattleRandom call BattleRandom
ld b, a ld b, a
ld a, [H_QUOTIENT + 3] ld a, [hQuotient + 3]
cp b cp b
jr nc, .canEscape ; if the random value was less than or equal to the quotient jr nc, .canEscape ; if the random value was less than or equal to the quotient
; plus 30 times the number of attempts, the player can escape ; plus 30 times the number of attempts, the player can escape
@ -1754,7 +1754,7 @@ SendOutMon:
ld hl, wEnemyBattleStatus1 ld hl, wEnemyBattleStatus1
res USING_TRAPPING_MOVE, [hl] res USING_TRAPPING_MOVE, [hl]
ld a, $1 ld a, $1
ld [H_WHOSETURN], a ld [hWhoseTurn], a
ld a, POOF_ANIM ld a, POOF_ANIM
call PlayMoveAnimation call PlayMoveAnimation
coord hl, 4, 11 coord hl, 4, 11
@ -1812,7 +1812,7 @@ DrawHUDsAndHPBars:
DrawPlayerHUDAndHPBar: DrawPlayerHUDAndHPBar:
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
coord hl, 9, 7 coord hl, 9, 7
lb bc, 5, 11 lb bc, 5, 11
call ClearScreenArea call ClearScreenArea
@ -1845,7 +1845,7 @@ DrawPlayerHUDAndHPBar:
coord hl, 10, 9 coord hl, 10, 9
predef DrawHP predef DrawHP
ld a, $1 ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ld hl, wPlayerHPBarColor ld hl, wPlayerHPBarColor
call GetBattleHealthBarColor call GetBattleHealthBarColor
ld hl, wBattleMonHP ld hl, wBattleMonHP
@ -1873,7 +1873,7 @@ DrawPlayerHUDAndHPBar:
DrawEnemyHUDAndHPBar: DrawEnemyHUDAndHPBar:
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
coord hl, 0, 0 coord hl, 0, 0
lb bc, 4, 12 lb bc, 4, 12
call ClearScreenArea call ClearScreenArea
@ -1895,9 +1895,9 @@ DrawEnemyHUDAndHPBar:
.skipPrintLevel .skipPrintLevel
ld hl, wEnemyMonHP ld hl, wEnemyMonHP
ld a, [hli] ld a, [hli]
ld [H_MULTIPLICAND + 1], a ld [hMultiplicand + 1], a
ld a, [hld] ld a, [hld]
ld [H_MULTIPLICAND + 2], a ld [hMultiplicand + 2], a
or [hl] ; is current HP zero? or [hl] ; is current HP zero?
jr nz, .hpNonzero jr nz, .hpNonzero
; current HP is 0 ; current HP is 0
@ -1908,45 +1908,45 @@ DrawEnemyHUDAndHPBar:
jp .drawHPBar jp .drawHPBar
.hpNonzero .hpNonzero
xor a xor a
ld [H_MULTIPLICAND], a ld [hMultiplicand], a
ld a, 48 ld a, 48
ld [H_MULTIPLIER], a ld [hMultiplier], a
call Multiply ; multiply current HP by 48 call Multiply ; multiply current HP by 48
ld hl, wEnemyMonMaxHP ld hl, wEnemyMonMaxHP
ld a, [hli] ld a, [hli]
ld b, a ld b, a
ld a, [hl] ld a, [hl]
ld [H_DIVISOR], a ld [hDivisor], a
ld a, b ld a, b
and a ; is max HP > 255? and a ; is max HP > 255?
jr z, .doDivide jr z, .doDivide
; if max HP > 255, scale both (current HP * 48) and max HP by dividing by 4 so that max HP fits in one byte ; if max HP > 255, scale both (current HP * 48) and max HP by dividing by 4 so that max HP fits in one byte
; (it needs to be one byte so it can be used as the divisor for the Divide function) ; (it needs to be one byte so it can be used as the divisor for the Divide function)
ld a, [H_DIVISOR] ld a, [hDivisor]
srl b srl b
rr a rr a
srl b srl b
rr a rr a
ld [H_DIVISOR], a ld [hDivisor], a
ld a, [H_PRODUCT + 2] ld a, [hProduct + 2]
ld b, a ld b, a
srl b srl b
ld a, [H_PRODUCT + 3] ld a, [hProduct + 3]
rr a rr a
srl b srl b
rr a rr a
ld [H_PRODUCT + 3], a ld [hProduct + 3], a
ld a, b ld a, b
ld [H_PRODUCT + 2], a ld [hProduct + 2], a
.doDivide .doDivide
ld a, [H_PRODUCT + 2] ld a, [hProduct + 2]
ld [H_DIVIDEND], a ld [hDividend], a
ld a, [H_PRODUCT + 3] ld a, [hProduct + 3]
ld [H_DIVIDEND + 1], a ld [hDividend + 1], a
ld a, $2 ld a, $2
ld b, a ld b, a
call Divide ; divide (current HP * 48) by max HP call Divide ; divide (current HP * 48) by max HP
ld a, [H_QUOTIENT + 3] ld a, [hQuotient + 3]
; set variables for DrawHPBar ; set variables for DrawHPBar
ld e, a ld e, a
ld a, $6 ld a, $6
@ -1958,7 +1958,7 @@ DrawEnemyHUDAndHPBar:
coord hl, 2, 2 coord hl, 2, 2
call DrawHPBar call DrawHPBar
ld a, $1 ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ld hl, wEnemyHPBarColor ld hl, wEnemyHPBarColor
GetBattleHealthBarColor: GetBattleHealthBarColor:
@ -2469,13 +2469,13 @@ MoveSelectionMenu:
.writemoves .writemoves
ld de, wMovesString ld de, wMovesString
ld a, [hFlags_0xFFF6] ld a, [hFlagsFFF6]
set 2, a set 2, a
ld [hFlags_0xFFF6], a ld [hFlagsFFF6], a
call PlaceString call PlaceString
ld a, [hFlags_0xFFF6] ld a, [hFlagsFFF6]
res 2, a res 2, a
ld [hFlags_0xFFF6], a ld [hFlagsFFF6], a
ret ret
.regularmenu .regularmenu
@ -2595,10 +2595,10 @@ SelectMenuItem:
call AddNTimes call AddNTimes
ld [hl], "▷" ld [hl], "▷"
.select .select
ld hl, hFlags_0xFFF6 ld hl, hFlagsFFF6
set 1, [hl] set 1, [hl]
call HandleMenuInput call HandleMenuInput
ld hl, hFlags_0xFFF6 ld hl, hFlagsFFF6
res 1, [hl] res 1, [hl]
bit 6, a bit 6, a
jp nz, SelectMenuItem_CursorUp ; up jp nz, SelectMenuItem_CursorUp ; up
@ -2825,7 +2825,7 @@ SwapMovesInMenu:
PrintMenuItem: PrintMenuItem:
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
coord hl, 0, 8 coord hl, 0, 8
ld b, 3 ld b, 3
ld c, 9 ld c, 9
@ -2847,7 +2847,7 @@ PrintMenuItem:
ld hl, wCurrentMenuItem ld hl, wCurrentMenuItem
dec [hl] dec [hl]
xor a xor a
ld [H_WHOSETURN], a ld [hWhoseTurn], a
ld hl, wBattleMonMoves ld hl, wBattleMonMoves
ld a, [wCurrentMenuItem] ld a, [wCurrentMenuItem]
ld c, a ld c, a
@ -2891,7 +2891,7 @@ PrintMenuItem:
predef PrintMoveType predef PrintMoveType
.moveDisabled .moveDisabled
ld a, $1 ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
jp Delay3 jp Delay3
DisabledText: DisabledText:
@ -3043,7 +3043,7 @@ LinkBattleExchangeData:
ExecutePlayerMove: ExecutePlayerMove:
xor a xor a
ld [H_WHOSETURN], a ; set player's turn ld [hWhoseTurn], a ; set player's turn
ld a, [wPlayerSelectedMove] ld a, [wPlayerSelectedMove]
inc a inc a
jp z, ExecutePlayerMoveDone ; for selected move = FF, skip most of player's turn jp z, ExecutePlayerMoveDone ; for selected move = FF, skip most of player's turn
@ -3252,7 +3252,7 @@ PrintGhostText:
; print the ghost battle messages ; print the ghost battle messages
call IsGhostBattle call IsGhostBattle
ret nz ret nz
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr nz, .Ghost jr nz, .Ghost
ld a, [wBattleMonStatus] ; players turn ld a, [wBattleMonStatus] ; players turn
@ -3619,7 +3619,7 @@ CantMoveText:
PrintMoveIsDisabledText: PrintMoveIsDisabledText:
ld hl, wPlayerSelectedMove ld hl, wPlayerSelectedMove
ld de, wPlayerBattleStatus1 ld de, wPlayerBattleStatus1
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .removeChargingUp jr z, .removeChargingUp
inc hl inc hl
@ -3675,11 +3675,11 @@ HandleSelfConfusionDamage:
xor a xor a
ld [wAnimationType], a ld [wAnimationType], a
inc a inc a
ld [H_WHOSETURN], a ld [hWhoseTurn], a
call PlayMoveAnimation call PlayMoveAnimation
call DrawPlayerHUDAndHPBar call DrawPlayerHUDAndHPBar
xor a xor a
ld [H_WHOSETURN], a ld [hWhoseTurn], a
jp ApplyDamageToPlayerPokemon jp ApplyDamageToPlayerPokemon
PrintMonName1Text: PrintMonName1Text:
@ -3694,7 +3694,7 @@ PrintMonName1Text:
MonName1Text: MonName1Text:
TX_FAR _MonName1Text TX_FAR _MonName1Text
TX_ASM TX_ASM
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld a, [wPlayerMoveNum] ld a, [wPlayerMoveNum]
ld hl, wPlayerUsedMove ld hl, wPlayerUsedMove
@ -3818,7 +3818,7 @@ INCLUDE "data/moves/grammar.asm"
PrintMoveFailureText: PrintMoveFailureText:
ld de, wPlayerMoveEffect ld de, wPlayerMoveEffect
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .playersTurn jr z, .playersTurn
ld de, wEnemyMoveEffect ld de, wEnemyMoveEffect
@ -3866,7 +3866,7 @@ PrintMoveFailureText:
call PrintText call PrintText
ld b, $4 ld b, $4
predef PredefShakeScreenHorizontally predef PredefShakeScreenHorizontally
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr nz, .enemyTurn jr nz, .enemyTurn
jp ApplyDamageToPlayerPokemon jp ApplyDamageToPlayerPokemon
@ -4160,9 +4160,9 @@ GetDamageVarsForPlayerAttack:
; in the case of a critical hit, reset the player's attack and the enemy's defense to their base values ; in the case of a critical hit, reset the player's attack and the enemy's defense to their base values
ld c, 3 ; defense stat ld c, 3 ; defense stat
call GetEnemyMonStat call GetEnemyMonStat
ld a, [H_PRODUCT + 2] ld a, [hProduct + 2]
ld b, a ld b, a
ld a, [H_PRODUCT + 3] ld a, [hProduct + 3]
ld c, a ld c, a
push bc push bc
ld hl, wPartyMon1Attack ld hl, wPartyMon1Attack
@ -4192,9 +4192,9 @@ GetDamageVarsForPlayerAttack:
; in the case of a critical hit, reset the player's and enemy's specials to their base values ; in the case of a critical hit, reset the player's and enemy's specials to their base values
ld c, 5 ; special stat ld c, 5 ; special stat
call GetEnemyMonStat call GetEnemyMonStat
ld a, [H_PRODUCT + 2] ld a, [hProduct + 2]
ld b, a ld b, a
ld a, [H_PRODUCT + 3] ld a, [hProduct + 3]
ld c, a ld c, a
push bc push bc
ld hl, wPartyMon1Special ld hl, wPartyMon1Special
@ -4281,7 +4281,7 @@ GetDamageVarsForEnemyAttack:
push bc push bc
ld c, 2 ; attack stat ld c, 2 ; attack stat
call GetEnemyMonStat call GetEnemyMonStat
ld hl, H_PRODUCT + 2 ld hl, hProduct + 2
pop bc pop bc
jr .scaleStats jr .scaleStats
.specialAttack .specialAttack
@ -4313,7 +4313,7 @@ GetDamageVarsForEnemyAttack:
push bc push bc
ld c, 5 ; special stat ld c, 5 ; special stat
call GetEnemyMonStat call GetEnemyMonStat
ld hl, H_PRODUCT + 2 ld hl, hProduct + 2
pop bc pop bc
; if either the offensive or defensive stat is too large to store in a byte, scale both stats by dividing them by 4 ; if either the offensive or defensive stat is too large to store in a byte, scale both stats by dividing them by 4
; this allows values with up to 10 bits (values up to 1023) to be handled ; this allows values with up to 10 bits (values up to 1023) to be handled
@ -4371,9 +4371,9 @@ GetEnemyMonStat:
ld bc, wEnemyMon2 - wEnemyMon1 ld bc, wEnemyMon2 - wEnemyMon1
call AddNTimes call AddNTimes
ld a, [hli] ld a, [hli]
ld [H_MULTIPLICAND + 1], a ld [hMultiplicand + 1], a
ld a, [hl] ld a, [hl]
ld [H_MULTIPLICAND + 2], a ld [hMultiplicand + 2], a
pop bc pop bc
pop de pop de
ret ret
@ -4404,7 +4404,7 @@ CalculateDamage:
; d: base power ; d: base power
; e: level ; e: level
ld a, [H_WHOSETURN] ; whose turn? ld a, [hWhoseTurn] ; whose turn?
and a and a
ld a, [wPlayerMoveEffect] ld a, [wPlayerMoveEffect]
jr z, .effect jr z, .effect
@ -4436,7 +4436,7 @@ CalculateDamage:
.skipbp .skipbp
xor a xor a
ld hl, H_DIVIDEND ld hl, hDividend
ldi [hl], a ldi [hl], a
ldi [hl], a ldi [hl], a
ld [hl], a ld [hl], a
@ -4487,41 +4487,41 @@ CalculateDamage:
ld hl, wDamage ld hl, wDamage
ld b, [hl] ld b, [hl]
ld a, [H_QUOTIENT + 3] ld a, [hQuotient + 3]
add b add b
ld [H_QUOTIENT + 3], a ld [hQuotient + 3], a
jr nc, .asm_3dfd0 jr nc, .asm_3dfd0
ld a, [H_QUOTIENT + 2] ld a, [hQuotient + 2]
inc a inc a
ld [H_QUOTIENT + 2], a ld [hQuotient + 2], a
and a and a
jr z, .asm_3e004 jr z, .asm_3e004
.asm_3dfd0 .asm_3dfd0
ld a, [H_QUOTIENT] ld a, [hQuotient]
ld b, a ld b, a
ld a, [H_QUOTIENT + 1] ld a, [hQuotient + 1]
or a or a
jr nz, .asm_3e004 jr nz, .asm_3e004
ld a, [H_QUOTIENT + 2] ld a, [hQuotient + 2]
cp 998 / $100 cp 998 / $100
jr c, .asm_3dfe8 jr c, .asm_3dfe8
cp 998 / $100 + 1 cp 998 / $100 + 1
jr nc, .asm_3e004 jr nc, .asm_3e004
ld a, [H_QUOTIENT + 3] ld a, [hQuotient + 3]
cp 998 % $100 cp 998 % $100
jr nc, .asm_3e004 jr nc, .asm_3e004
.asm_3dfe8 .asm_3dfe8
inc hl inc hl
ld a, [H_QUOTIENT + 3] ld a, [hQuotient + 3]
ld b, [hl] ld b, [hl]
add b add b
ld [hld], a ld [hld], a
ld a, [H_QUOTIENT + 2] ld a, [hQuotient + 2]
ld b, [hl] ld b, [hl]
adc b adc b
ld [hl], a ld [hl], a
@ -4573,7 +4573,7 @@ INCLUDE "data/battle/unused_critical_hit_moves.asm"
CriticalHitTest: CriticalHitTest:
xor a xor a
ld [wCriticalHitOrOHKO], a ld [wCriticalHitOrOHKO], a
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld a, [wEnemyMonSpecies] ld a, [wEnemyMonSpecies]
jr nz, .handleEnemy jr nz, .handleEnemy
@ -4584,7 +4584,7 @@ CriticalHitTest:
ld a, [wMonHBaseSpeed] ld a, [wMonHBaseSpeed]
ld b, a ld b, a
srl b ; (effective (base speed/2)) srl b ; (effective (base speed/2))
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld hl, wPlayerMovePower ld hl, wPlayerMovePower
ld de, wPlayerBattleStatus2 ld de, wPlayerBattleStatus2
@ -4646,7 +4646,7 @@ HandleCounterMove:
; the outcome may be affected by the player's actions in the move selection menu prior to switching the Pokemon. ; the outcome may be affected by the player's actions in the move selection menu prior to switching the Pokemon.
; This might also lead to desync glitches in link battles. ; This might also lead to desync glitches in link battles.
ld a, [H_WHOSETURN] ; whose turn ld a, [hWhoseTurn] ; whose turn
and a and a
; player's turn ; player's turn
ld hl, wEnemySelectedMove ld hl, wEnemySelectedMove
@ -4954,7 +4954,7 @@ AttackSubstitute:
; values for player turn ; values for player turn
ld de, wEnemySubstituteHP ld de, wEnemySubstituteHP
ld bc, wEnemyBattleStatus2 ld bc, wEnemyBattleStatus2
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .applyDamageToSubstitute jr z, .applyDamageToSubstitute
; values for enemy turn ; values for enemy turn
@ -4979,14 +4979,14 @@ AttackSubstitute:
ld hl, SubstituteBrokeText ld hl, SubstituteBrokeText
call PrintText call PrintText
; flip whose turn it is for the next function call ; flip whose turn it is for the next function call
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
xor $01 xor $01
ld [H_WHOSETURN], a ld [hWhoseTurn], a
callab HideSubstituteShowMonAnim ; animate the substitute breaking callab HideSubstituteShowMonAnim ; animate the substitute breaking
; flip the turn back to the way it was ; flip the turn back to the way it was
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
xor $01 xor $01
ld [H_WHOSETURN], a ld [hWhoseTurn], a
ld hl, wPlayerMoveEffect ; value for player's turn ld hl, wPlayerMoveEffect ; value for player's turn
and a and a
jr z, .nullifyEffect jr z, .nullifyEffect
@ -5010,7 +5010,7 @@ HandleBuildingRage:
ld hl, wEnemyBattleStatus2 ld hl, wEnemyBattleStatus2
ld de, wEnemyMonStatMods ld de, wEnemyMonStatMods
ld bc, wEnemyMoveNum ld bc, wEnemyMoveNum
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .next jr z, .next
; values for the enemy turn ; values for the enemy turn
@ -5023,9 +5023,9 @@ HandleBuildingRage:
ld a, [de] ld a, [de]
cp $0d ; maximum stat modifier value cp $0d ; maximum stat modifier value
ret z ; return if attack modifier is already maxed ret z ; return if attack modifier is already maxed
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
xor $01 ; flip turn for the stat modifier raising function xor $01 ; flip turn for the stat modifier raising function
ld [H_WHOSETURN], a ld [hWhoseTurn], a
; temporarily change the target pokemon's move to $00 and the effect to the one ; temporarily change the target pokemon's move to $00 and the effect to the one
; that causes the attack modifier to go up one stage ; that causes the attack modifier to go up one stage
ld h, b ld h, b
@ -5042,9 +5042,9 @@ HandleBuildingRage:
ldd [hl], a ; null move effect ldd [hl], a ; null move effect
ld a, RAGE ld a, RAGE
ld [hl], a ; restore the target pokemon's move number to Rage ld [hl], a ; restore the target pokemon's move number to Rage
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
xor $01 ; flip turn back to the way it was xor $01 ; flip turn back to the way it was
ld [H_WHOSETURN], a ld [hWhoseTurn], a
ret ret
BuildingRageText: BuildingRageText:
@ -5060,7 +5060,7 @@ MirrorMoveCopyMove:
; wPlayerUsedMove is also set to 0 whenever the player is fast asleep or frozen solid. ; wPlayerUsedMove is also set to 0 whenever the player is fast asleep or frozen solid.
; wEnemyUsedMove is also set to 0 whenever the enemy is fast asleep or frozen solid. ; wEnemyUsedMove is also set to 0 whenever the enemy is fast asleep or frozen solid.
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
; values for player turn ; values for player turn
ld a, [wEnemyUsedMove] ld a, [wEnemyUsedMove]
@ -5113,7 +5113,7 @@ MetronomePickMove:
; values for player turn ; values for player turn
ld de, wPlayerMoveNum ld de, wPlayerMoveNum
ld hl, wPlayerSelectedMove ld hl, wPlayerSelectedMove
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .pickMoveLoop jr z, .pickMoveLoop
; values for enemy turn ; values for enemy turn
@ -5135,7 +5135,7 @@ MetronomePickMove:
; it's used to prevent moves that run another move within the same turn ; it's used to prevent moves that run another move within the same turn
; (like Mirror Move and Metronome) from losing 2 PP ; (like Mirror Move and Metronome) from losing 2 PP
IncrementMovePP: IncrementMovePP:
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
; values for player turn ; values for player turn
ld hl, wBattleMonPP ld hl, wBattleMonPP
@ -5154,7 +5154,7 @@ IncrementMovePP:
ld h, d ld h, d
ld l, e ld l, e
add hl, bc add hl, bc
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld a, [wPlayerMonNumber] ; value for player turn ld a, [wPlayerMonNumber] ; value for player turn
jr z, .updatePP jr z, .updatePP
@ -5178,7 +5178,7 @@ AdjustDamageForMoveType:
ld e, [hl] ; e = type 2 of defender ld e, [hl] ; e = type 2 of defender
ld a, [wPlayerMoveType] ld a, [wPlayerMoveType]
ld [wMoveType], a ld [wMoveType], a
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .next jr z, .next
; values for enemy turn ; values for enemy turn
@ -5242,25 +5242,25 @@ AdjustDamageForMoveType:
and $80 and $80
ld b, a ld b, a
ld a, [hl] ; a = damage multiplier ld a, [hl] ; a = damage multiplier
ld [H_MULTIPLIER], a ld [hMultiplier], a
add b add b
ld [wDamageMultipliers], a ld [wDamageMultipliers], a
xor a xor a
ld [H_MULTIPLICAND], a ld [hMultiplicand], a
ld hl, wDamage ld hl, wDamage
ld a, [hli] ld a, [hli]
ld [H_MULTIPLICAND + 1], a ld [hMultiplicand + 1], a
ld a, [hld] ld a, [hld]
ld [H_MULTIPLICAND + 2], a ld [hMultiplicand + 2], a
call Multiply call Multiply
ld a, 10 ld a, 10
ld [H_DIVISOR], a ld [hDivisor], a
ld b, $04 ld b, $04
call Divide call Divide
ld a, [H_QUOTIENT + 2] ld a, [hQuotient + 2]
ld [hli], a ld [hli], a
ld b, a ld b, a
ld a, [H_QUOTIENT + 3] ld a, [hQuotient + 3]
ld [hl], a ld [hl], a
or b ; is damage 0? or b ; is damage 0?
jr nz, .skipTypeImmunity jr nz, .skipTypeImmunity
@ -5325,7 +5325,7 @@ MoveHitTest:
ld hl, wEnemyBattleStatus1 ld hl, wEnemyBattleStatus1
ld de, wPlayerMoveEffect ld de, wPlayerMoveEffect
ld bc, wEnemyMonStatus ld bc, wEnemyMonStatus
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .dreamEaterCheck jr z, .dreamEaterCheck
; enemy's turn ; enemy's turn
@ -5354,7 +5354,7 @@ MoveHitTest:
.checkForDigOrFlyStatus .checkForDigOrFlyStatus
bit INVULNERABLE, [hl] bit INVULNERABLE, [hl]
jp nz, .moveMissed jp nz, .moveMissed
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr nz, .enemyTurn jr nz, .enemyTurn
.playerTurn .playerTurn
@ -5408,7 +5408,7 @@ MoveHitTest:
call CalcHitChance ; scale the move accuracy according to attacker's accuracy and target's evasion call CalcHitChance ; scale the move accuracy according to attacker's accuracy and target's evasion
ld a, [wPlayerMoveAccuracy] ld a, [wPlayerMoveAccuracy]
ld b, a ld b, a
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .doAccuracyCheck jr z, .doAccuracyCheck
ld a, [wEnemyMoveAccuracy] ld a, [wEnemyMoveAccuracy]
@ -5427,7 +5427,7 @@ MoveHitTest:
ld [hl], a ld [hl], a
inc a inc a
ld [wMoveMissed], a ld [wMoveMissed], a
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .playerTurn2 jr z, .playerTurn2
.enemyTurn2 .enemyTurn2
@ -5442,7 +5442,7 @@ MoveHitTest:
; values for player turn ; values for player turn
CalcHitChance: CalcHitChance:
ld hl, wPlayerMoveAccuracy ld hl, wPlayerMoveAccuracy
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld a, [wPlayerMonAccuracyMod] ld a, [wPlayerMonAccuracyMod]
ld b, a ld b, a
@ -5462,10 +5462,10 @@ CalcHitChance:
; decreases the hit chance instead of increasing the hit chance) ; decreases the hit chance instead of increasing the hit chance)
; zero the high bytes of the multiplicand ; zero the high bytes of the multiplicand
xor a xor a
ld [H_MULTIPLICAND], a ld [hMultiplicand], a
ld [H_MULTIPLICAND + 1], a ld [hMultiplicand + 1], a
ld a, [hl] ld a, [hl]
ld [H_MULTIPLICAND + 2], a ; set multiplicand to move accuracy ld [hMultiplicand + 2], a ; set multiplicand to move accuracy
push hl push hl
ld d, $02 ; loop has two iterations ld d, $02 ; loop has two iterations
; loop to do the calculations, the first iteration multiplies by the accuracy ratio and ; loop to do the calculations, the first iteration multiplies by the accuracy ratio and
@ -5480,29 +5480,29 @@ CalcHitChance:
add hl, bc ; hl = address of stat modifier ratio add hl, bc ; hl = address of stat modifier ratio
pop bc pop bc
ld a, [hli] ld a, [hli]
ld [H_MULTIPLIER], a ; set multiplier to the numerator of the ratio ld [hMultiplier], a ; set multiplier to the numerator of the ratio
call Multiply call Multiply
ld a, [hl] ld a, [hl]
ld [H_DIVISOR], a ; set divisor to the the denominator of the ratio ld [hDivisor], a ; set divisor to the the denominator of the ratio
; (the dividend is the product of the previous multiplication) ; (the dividend is the product of the previous multiplication)
ld b, $04 ; number of bytes in the dividend ld b, $04 ; number of bytes in the dividend
call Divide call Divide
ld a, [H_QUOTIENT + 3] ld a, [hQuotient + 3]
ld b, a ld b, a
ld a, [H_QUOTIENT + 2] ld a, [hQuotient + 2]
or b or b
jp nz, .nextCalculation jp nz, .nextCalculation
; make sure the result is always at least one ; make sure the result is always at least one
ld [H_QUOTIENT + 2], a ld [hQuotient + 2], a
ld a, $01 ld a, $01
ld [H_QUOTIENT + 3], a ld [hQuotient + 3], a
.nextCalculation .nextCalculation
ld b, c ld b, c
dec d dec d
jr nz, .loop jr nz, .loop
ld a, [H_QUOTIENT + 2] ld a, [hQuotient + 2]
and a ; is the calculated hit chance over 0xFF? and a ; is the calculated hit chance over 0xFF?
ld a, [H_QUOTIENT + 3] ld a, [hQuotient + 3]
jr z, .storeAccuracy jr z, .storeAccuracy
; if calculated hit chance over 0xFF ; if calculated hit chance over 0xFF
ld a, $ff ; set the hit chance to 0xFF ld a, $ff ; set the hit chance to 0xFF
@ -5522,29 +5522,29 @@ RandomizeDamage:
ret c ; return if damage is equal to 0 or 1 ret c ; return if damage is equal to 0 or 1
.DamageGreaterThanOne .DamageGreaterThanOne
xor a xor a
ld [H_MULTIPLICAND], a ld [hMultiplicand], a
dec hl dec hl
ld a, [hli] ld a, [hli]
ld [H_MULTIPLICAND + 1], a ld [hMultiplicand + 1], a
ld a, [hl] ld a, [hl]
ld [H_MULTIPLICAND + 2], a ld [hMultiplicand + 2], a
; loop until a random number greater than or equal to 217 is generated ; loop until a random number greater than or equal to 217 is generated
.loop .loop
call BattleRandom call BattleRandom
rrca rrca
cp 217 cp 217
jr c, .loop jr c, .loop
ld [H_MULTIPLIER], a ld [hMultiplier], a
call Multiply ; multiply damage by the random number, which is in the range [217, 255] call Multiply ; multiply damage by the random number, which is in the range [217, 255]
ld a, 255 ld a, 255
ld [H_DIVISOR], a ld [hDivisor], a
ld b, $4 ld b, $4
call Divide ; divide the result by 255 call Divide ; divide the result by 255
; store the modified damage ; store the modified damage
ld a, [H_QUOTIENT + 2] ld a, [hQuotient + 2]
ld hl, wDamage ld hl, wDamage
ld [hli], a ld [hli], a
ld a, [H_QUOTIENT + 3] ld a, [hQuotient + 3]
ld [hl], a ld [hl], a
ret ret
@ -5900,11 +5900,11 @@ CheckEnemyStatusConditions:
ld [hl], a ld [hl], a
xor a xor a
ld [wAnimationType], a ld [wAnimationType], a
ld [H_WHOSETURN], a ld [hWhoseTurn], a
ld a, POUND ld a, POUND
call PlayMoveAnimation call PlayMoveAnimation
ld a, $1 ld a, $1
ld [H_WHOSETURN], a ld [hWhoseTurn], a
call ApplyDamageToEnemyPokemon call ApplyDamageToEnemyPokemon
jr .monHurtItselfOrFullyParalysed jr .monHurtItselfOrFullyParalysed
.checkIfTriedToUseDisabledMove .checkIfTriedToUseDisabledMove
@ -6051,7 +6051,7 @@ CheckEnemyStatusConditions:
ret ret
GetCurrentMove: GetCurrentMove:
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jp z, .player jp z, .player
ld de, wEnemyMoveNum ld de, wEnemyMoveNum
@ -6257,13 +6257,13 @@ DoBattleTransitionAndInitBattleVariables:
predef BattleTransition predef BattleTransition
callab LoadHudAndHpBarAndStatusTilePatterns callab LoadHudAndHpBarAndStatusTilePatterns
ld a, $1 ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ld a, $ff ld a, $ff
ld [wUpdateSpritesEnabled], a ld [wUpdateSpritesEnabled], a
call ClearSprites call ClearSprites
call ClearScreen call ClearScreen
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ld [hWY], a ld [hWY], a
ld [rWY], a ld [rWY], a
ld [hTilesetType], a ld [hTilesetType], a
@ -6340,7 +6340,7 @@ LoadPlayerBackPic:
ld [$4000], a ld [$4000], a
ld hl, vSprites ld hl, vSprites
ld de, sSpriteBuffer1 ld de, sSpriteBuffer1
ld a, [H_LOADEDROMBANK] ld a, [hLoadedROMBank]
ld b, a ld b, a
ld c, 7 * 7 ld c, 7 * 7
call CopyVideoData call CopyVideoData
@ -6367,12 +6367,12 @@ ApplyBurnAndParalysisPenaltiesToEnemy:
xor a xor a
ApplyBurnAndParalysisPenalties: ApplyBurnAndParalysisPenalties:
ld [H_WHOSETURN], a ld [hWhoseTurn], a
call QuarterSpeedDueToParalysis call QuarterSpeedDueToParalysis
jp HalveAttackDueToBurn jp HalveAttackDueToBurn
QuarterSpeedDueToParalysis: QuarterSpeedDueToParalysis:
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .playerTurn jr z, .playerTurn
.enemyTurn ; quarter the player's speed .enemyTurn ; quarter the player's speed
@ -6415,7 +6415,7 @@ QuarterSpeedDueToParalysis:
ret ret
HalveAttackDueToBurn: HalveAttackDueToBurn:
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .playerTurn jr z, .playerTurn
.enemyTurn ; halve the player's attack .enemyTurn ; halve the player's attack
@ -6505,35 +6505,35 @@ CalculateModifiedStat:
ld b, 0 ld b, 0
add hl, bc add hl, bc
xor a xor a
ld [H_MULTIPLICAND], a ld [hMultiplicand], a
ld a, [de] ld a, [de]
ld [H_MULTIPLICAND + 1], a ld [hMultiplicand + 1], a
inc de inc de
ld a, [de] ld a, [de]
ld [H_MULTIPLICAND + 2], a ld [hMultiplicand + 2], a
ld a, [hli] ld a, [hli]
ld [H_MULTIPLIER], a ld [hMultiplier], a
call Multiply call Multiply
ld a, [hl] ld a, [hl]
ld [H_DIVISOR], a ld [hDivisor], a
ld b, $4 ld b, $4
call Divide call Divide
pop hl pop hl
ld a, [H_DIVIDEND + 3] ld a, [hDividend + 3]
sub 999 % $100 sub 999 % $100
ld a, [H_DIVIDEND + 2] ld a, [hDividend + 2]
sbc 999 / $100 sbc 999 / $100
jp c, .storeNewStatValue jp c, .storeNewStatValue
; cap the stat at 999 ; cap the stat at 999
ld a, 999 / $100 ld a, 999 / $100
ld [H_DIVIDEND + 2], a ld [hDividend + 2], a
ld a, 999 % $100 ld a, 999 % $100
ld [H_DIVIDEND + 3], a ld [hDividend + 3], a
.storeNewStatValue .storeNewStatValue
ld a, [H_DIVIDEND + 2] ld a, [hDividend + 2]
ld [hli], a ld [hli], a
ld b, a ld b, a
ld a, [H_DIVIDEND + 3] ld a, [hDividend + 3]
ld [hl], a ld [hl], a
or b or b
jr nz, .done jr nz, .done
@ -6683,7 +6683,7 @@ BattleRandom:
HandleExplodingAnimation: HandleExplodingAnimation:
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld hl, wEnemyMonType1 ld hl, wEnemyMonType1
ld de, wEnemyBattleStatus1 ld de, wEnemyBattleStatus1
@ -6826,18 +6826,18 @@ _InitBattleCommon:
call RunPaletteCommand call RunPaletteCommand
call SlidePlayerAndEnemySilhouettesOnScreen call SlidePlayerAndEnemySilhouettesOnScreen
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ld hl, .emptyString ld hl, .emptyString
call PrintText call PrintText
call SaveScreenTilesToBuffer1 call SaveScreenTilesToBuffer1
call ClearScreen call ClearScreen
ld a, $98 ld a, $98
ld [H_AUTOBGTRANSFERDEST + 1], a ld [hAutoBGTransferDest + 1], a
ld a, $1 ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
call Delay3 call Delay3
ld a, $9c ld a, $9c
ld [H_AUTOBGTRANSFERDEST + 1], a ld [hAutoBGTransferDest + 1], a
call LoadScreenTilesFromBuffer1 call LoadScreenTilesFromBuffer1
coord hl, 9, 7 coord hl, 9, 7
lb bc, 5, 10 lb bc, 5, 10
@ -6998,6 +6998,6 @@ LoadMonBackPic:
ld hl, vSprites ld hl, vSprites
ld de, vBackPic ld de, vBackPic
ld c, (2*SPRITEBUFFERSIZE)/16 ; count of 16-byte chunks to be copied ld c, (2*SPRITEBUFFERSIZE)/16 ; count of 16-byte chunks to be copied
ld a, [H_LOADEDROMBANK] ld a, [hLoadedROMBank]
ld b, a ld b, a
jp CopyVideoData jp CopyVideoData

View file

@ -4,7 +4,7 @@ JumpMoveEffect:
ret ret
_JumpMoveEffect: _JumpMoveEffect:
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld a, [wPlayerMoveEffect] ld a, [wPlayerMoveEffect]
jr z, .next1 jr z, .next1
@ -26,7 +26,7 @@ INCLUDE "data/moves/effects_pointers.asm"
SleepEffect: SleepEffect:
ld de, wEnemyMonStatus ld de, wEnemyMonStatus
ld bc, wEnemyBattleStatus2 ld bc, wEnemyBattleStatus2
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jp z, .sleepEffect jp z, .sleepEffect
ld de, wBattleMonStatus ld de, wBattleMonStatus
@ -78,7 +78,7 @@ AlreadyAsleepText:
PoisonEffect: PoisonEffect:
ld hl, wEnemyMonStatus ld hl, wEnemyMonStatus
ld de, wPlayerMoveEffect ld de, wPlayerMoveEffect
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .poisonEffect jr z, .poisonEffect
ld hl, wBattleMonStatus ld hl, wBattleMonStatus
@ -121,7 +121,7 @@ PoisonEffect:
set 3, [hl] ; mon is now poisoned set 3, [hl] ; mon is now poisoned
push de push de
dec de dec de
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld b, ANIM_C7 ld b, ANIM_C7
ld hl, wPlayerBattleStatus3 ld hl, wPlayerBattleStatus3
@ -175,7 +175,7 @@ DrainHPEffect:
ExplodeEffect: ExplodeEffect:
ld hl, wBattleMonHP ld hl, wBattleMonHP
ld de, wPlayerBattleStatus2 ld de, wPlayerBattleStatus2
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .faintUser jr z, .faintUser
ld hl, wEnemyMonHP ld hl, wEnemyMonHP
@ -196,7 +196,7 @@ FreezeBurnParalyzeEffect:
ld [wAnimationType], a ld [wAnimationType], a
call CheckTargetSubstitute ; test bit 4 of d063/d068 flags [target has substitute flag] call CheckTargetSubstitute ; test bit 4 of d063/d068 flags [target has substitute flag]
ret nz ; return if they have a substitute, can't effect them ret nz ; return if they have a substitute, can't effect them
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jp nz, opponentAttacker jp nz, opponentAttacker
ld a, [wEnemyMonStatus] ld a, [wEnemyMonStatus]
@ -308,7 +308,7 @@ CheckDefrost:
; any fire-type move that has a chance inflict burn (all but Fire Spin) will defrost a frozen target ; any fire-type move that has a chance inflict burn (all but Fire Spin) will defrost a frozen target
and 1 << FRZ ; are they frozen? and 1 << FRZ ; are they frozen?
ret z ; return if so ret z ; return if so
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr nz, .opponent jr nz, .opponent
;player [attacker] ;player [attacker]
@ -346,7 +346,7 @@ FireDefrostedText:
StatModifierUpEffect: StatModifierUpEffect:
ld hl, wPlayerMonStatMods ld hl, wPlayerMonStatMods
ld de, wPlayerMoveEffect ld de, wPlayerMoveEffect
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .statModifierUpEffect jr z, .statModifierUpEffect
ld hl, wEnemyMonStatMods ld hl, wEnemyMonStatMods
@ -382,7 +382,7 @@ StatModifierUpEffect:
push hl push hl
ld hl, wBattleMonAttack + 1 ld hl, wBattleMonAttack + 1
ld de, wPlayerMonUnmodifiedAttack ld de, wPlayerMonUnmodifiedAttack
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .pointToStats jr z, .pointToStats
ld hl, wEnemyMonAttack + 1 ld hl, wEnemyMonAttack + 1
@ -417,35 +417,35 @@ StatModifierUpEffect:
add hl, bc add hl, bc
pop bc pop bc
xor a xor a
ld [H_MULTIPLICAND], a ld [hMultiplicand], a
ld a, [de] ld a, [de]
ld [H_MULTIPLICAND + 1], a ld [hMultiplicand + 1], a
inc de inc de
ld a, [de] ld a, [de]
ld [H_MULTIPLICAND + 2], a ld [hMultiplicand + 2], a
ld a, [hli] ld a, [hli]
ld [H_MULTIPLIER], a ld [hMultiplier], a
call Multiply call Multiply
ld a, [hl] ld a, [hl]
ld [H_DIVISOR], a ld [hDivisor], a
ld b, $4 ld b, $4
call Divide call Divide
pop hl pop hl
; cap at 999 ; cap at 999
ld a, [H_PRODUCT + 3] ld a, [hProduct + 3]
sub 999 % $100 sub 999 % $100
ld a, [H_PRODUCT + 2] ld a, [hProduct + 2]
sbc 999 / $100 sbc 999 / $100
jp c, UpdateStat jp c, UpdateStat
ld a, 999 / $100 ld a, 999 / $100
ld [H_MULTIPLICAND + 1], a ld [hMultiplicand + 1], a
ld a, 999 % $100 ld a, 999 % $100
ld [H_MULTIPLICAND + 2], a ld [hMultiplicand + 2], a
UpdateStat: UpdateStat:
ld a, [H_PRODUCT + 2] ld a, [hProduct + 2]
ld [hli], a ld [hli], a
ld a, [H_PRODUCT + 3] ld a, [hProduct + 3]
ld [hl], a ld [hl], a
pop hl pop hl
UpdateStatDone: UpdateStatDone:
@ -455,7 +455,7 @@ UpdateStatDone:
ld hl, wPlayerBattleStatus2 ld hl, wPlayerBattleStatus2
ld de, wPlayerMoveNum ld de, wPlayerMoveNum
ld bc, wPlayerMonMinimized ld bc, wPlayerMonMinimized
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .asm_3f4e6 jr z, .asm_3f4e6
ld hl, wEnemyBattleStatus2 ld hl, wEnemyBattleStatus2
@ -488,7 +488,7 @@ UpdateStatDone:
pop af pop af
call nz, Bankswitch call nz, Bankswitch
.applyBadgeBoostsAndStatusPenalties .applyBadgeBoostsAndStatusPenalties
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
call z, ApplyBadgeStatBoosts ; whenever the player uses a stat-up move, badge boosts get reapplied again to every stat, call z, ApplyBadgeStatBoosts ; whenever the player uses a stat-up move, badge boosts get reapplied again to every stat,
; even to those not affected by the stat-up move (will be boosted further) ; even to those not affected by the stat-up move (will be boosted further)
@ -511,7 +511,7 @@ MonsStatsRoseText:
TX_FAR _MonsStatsRoseText TX_FAR _MonsStatsRoseText
TX_ASM TX_ASM
ld hl, GreatlyRoseText ld hl, GreatlyRoseText
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld a, [wPlayerMoveEffect] ld a, [wPlayerMoveEffect]
jr z, .playerTurn jr z, .playerTurn
@ -534,7 +534,7 @@ StatModifierDownEffect:
ld hl, wEnemyMonStatMods ld hl, wEnemyMonStatMods
ld de, wPlayerMoveEffect ld de, wPlayerMoveEffect
ld bc, wEnemyBattleStatus1 ld bc, wEnemyBattleStatus1
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .statModifierDownEffect jr z, .statModifierDownEffect
ld hl, wPlayerMonStatMods ld hl, wPlayerMonStatMods
@ -601,7 +601,7 @@ StatModifierDownEffect:
push de push de
ld hl, wEnemyMonAttack + 1 ld hl, wEnemyMonAttack + 1
ld de, wEnemyMonUnmodifiedAttack ld de, wEnemyMonUnmodifiedAttack
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .pointToStat jr z, .pointToStat
ld hl, wBattleMonAttack + 1 ld hl, wBattleMonAttack + 1
@ -637,33 +637,33 @@ StatModifierDownEffect:
add hl, bc add hl, bc
pop bc pop bc
xor a xor a
ld [H_MULTIPLICAND], a ld [hMultiplicand], a
ld a, [de] ld a, [de]
ld [H_MULTIPLICAND + 1], a ld [hMultiplicand + 1], a
inc de inc de
ld a, [de] ld a, [de]
ld [H_MULTIPLICAND + 2], a ld [hMultiplicand + 2], a
ld a, [hli] ld a, [hli]
ld [H_MULTIPLIER], a ld [hMultiplier], a
call Multiply call Multiply
ld a, [hl] ld a, [hl]
ld [H_DIVISOR], a ld [hDivisor], a
ld b, $4 ld b, $4
call Divide call Divide
pop hl pop hl
ld a, [H_PRODUCT + 3] ld a, [hProduct + 3]
ld b, a ld b, a
ld a, [H_PRODUCT + 2] ld a, [hProduct + 2]
or b or b
jp nz, UpdateLoweredStat jp nz, UpdateLoweredStat
ld [H_MULTIPLICAND + 1], a ld [hMultiplicand + 1], a
ld a, $1 ld a, $1
ld [H_MULTIPLICAND + 2], a ld [hMultiplicand + 2], a
UpdateLoweredStat: UpdateLoweredStat:
ld a, [H_PRODUCT + 2] ld a, [hProduct + 2]
ld [hli], a ld [hli], a
ld a, [H_PRODUCT + 3] ld a, [hProduct + 3]
ld [hl], a ld [hl], a
pop de pop de
pop hl pop hl
@ -678,7 +678,7 @@ UpdateLoweredStatDone:
jr nc, .ApplyBadgeBoostsAndStatusPenalties jr nc, .ApplyBadgeBoostsAndStatusPenalties
call PlayCurrentMoveAnimation2 call PlayCurrentMoveAnimation2
.ApplyBadgeBoostsAndStatusPenalties .ApplyBadgeBoostsAndStatusPenalties
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
call nz, ApplyBadgeStatBoosts ; whenever the player uses a stat-down move, badge boosts get reapplied again to every stat, call nz, ApplyBadgeStatBoosts ; whenever the player uses a stat-down move, badge boosts get reapplied again to every stat,
; even to those not affected by the stat-up move (will be boosted further) ; even to those not affected by the stat-up move (will be boosted further)
@ -713,7 +713,7 @@ MonsStatsFellText:
TX_FAR _MonsStatsFellText TX_FAR _MonsStatsFellText
TX_ASM TX_ASM
ld hl, FellText ld hl, FellText
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld a, [wPlayerMoveEffect] ld a, [wPlayerMoveEffect]
jr z, .playerTurn jr z, .playerTurn
@ -759,7 +759,7 @@ BideEffect:
ld hl, wPlayerBattleStatus1 ld hl, wPlayerBattleStatus1
ld de, wPlayerBideAccumulatedDamage ld de, wPlayerBideAccumulatedDamage
ld bc, wPlayerNumAttacksLeft ld bc, wPlayerNumAttacksLeft
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .bideEffect jr z, .bideEffect
ld hl, wEnemyBattleStatus1 ld hl, wEnemyBattleStatus1
@ -778,14 +778,14 @@ BideEffect:
inc a inc a
inc a inc a
ld [bc], a ; set Bide counter to 2 or 3 at random ld [bc], a ; set Bide counter to 2 or 3 at random
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
add XSTATITEM_ANIM add XSTATITEM_ANIM
jp PlayBattleAnimation2 jp PlayBattleAnimation2
ThrashPetalDanceEffect: ThrashPetalDanceEffect:
ld hl, wPlayerBattleStatus1 ld hl, wPlayerBattleStatus1
ld de, wPlayerNumAttacksLeft ld de, wPlayerNumAttacksLeft
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .thrashPetalDanceEffect jr z, .thrashPetalDanceEffect
ld hl, wEnemyBattleStatus1 ld hl, wEnemyBattleStatus1
@ -797,12 +797,12 @@ ThrashPetalDanceEffect:
inc a inc a
inc a inc a
ld [de], a ; set thrash/petal dance counter to 2 or 3 at random ld [de], a ; set thrash/petal dance counter to 2 or 3 at random
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
add ANIM_B0 add ANIM_B0
jp PlayBattleAnimation2 jp PlayBattleAnimation2
SwitchAndTeleportEffect: SwitchAndTeleportEffect:
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr nz, .handleEnemy jr nz, .handleEnemy
ld a, [wIsInBattle] ld a, [wIsInBattle]
@ -920,7 +920,7 @@ TwoToFiveAttacksEffect:
ld hl, wPlayerBattleStatus1 ld hl, wPlayerBattleStatus1
ld de, wPlayerNumAttacksLeft ld de, wPlayerNumAttacksLeft
ld bc, wPlayerNumHits ld bc, wPlayerNumHits
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .twoToFiveAttacksEffect jr z, .twoToFiveAttacksEffect
ld hl, wEnemyBattleStatus1 ld hl, wEnemyBattleStatus1
@ -931,7 +931,7 @@ TwoToFiveAttacksEffect:
ret nz ret nz
set ATTACKING_MULTIPLE_TIMES, [hl] ; mon is now attacking multiple times set ATTACKING_MULTIPLE_TIMES, [hl] ; mon is now attacking multiple times
ld hl, wPlayerMoveEffect ld hl, wPlayerMoveEffect
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .setNumberOfHits jr z, .setNumberOfHits
ld hl, wEnemyMoveEffect ld hl, wEnemyMoveEffect
@ -967,7 +967,7 @@ FlinchSideEffect:
ret nz ret nz
ld hl, wEnemyBattleStatus1 ld hl, wEnemyBattleStatus1
ld de, wPlayerMoveEffect ld de, wPlayerMoveEffect
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .flinchSideEffect jr z, .flinchSideEffect
ld hl, wPlayerBattleStatus1 ld hl, wPlayerBattleStatus1
@ -992,7 +992,7 @@ OneHitKOEffect:
ChargeEffect: ChargeEffect:
ld hl, wPlayerBattleStatus1 ld hl, wPlayerBattleStatus1
ld de, wPlayerMoveEffect ld de, wPlayerMoveEffect
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld b, XSTATITEM_ANIM ld b, XSTATITEM_ANIM
jr z, .chargeEffect jr z, .chargeEffect
@ -1074,7 +1074,7 @@ DugAHoleText:
TrappingEffect: TrappingEffect:
ld hl, wPlayerBattleStatus1 ld hl, wPlayerBattleStatus1
ld de, wPlayerNumAttacksLeft ld de, wPlayerNumAttacksLeft
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .trappingEffect jr z, .trappingEffect
ld hl, wEnemyBattleStatus1 ld hl, wEnemyBattleStatus1
@ -1120,7 +1120,7 @@ ConfusionEffect:
jr nz, ConfusionEffectFailed jr nz, ConfusionEffectFailed
ConfusionSideEffectSuccess: ConfusionSideEffectSuccess:
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld hl, wEnemyBattleStatus1 ld hl, wEnemyBattleStatus1
ld bc, wEnemyConfusedCounter ld bc, wEnemyConfusedCounter
@ -1164,7 +1164,7 @@ SubstituteEffect:
HyperBeamEffect: HyperBeamEffect:
ld hl, wPlayerBattleStatus2 ld hl, wPlayerBattleStatus2
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .hyperBeamEffect jr z, .hyperBeamEffect
ld hl, wEnemyBattleStatus2 ld hl, wEnemyBattleStatus2
@ -1175,7 +1175,7 @@ HyperBeamEffect:
ClearHyperBeam: ClearHyperBeam:
push hl push hl
ld hl, wEnemyBattleStatus2 ld hl, wEnemyBattleStatus2
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .playerTurn jr z, .playerTurn
ld hl, wPlayerBattleStatus2 ld hl, wPlayerBattleStatus2
@ -1186,7 +1186,7 @@ ClearHyperBeam:
RageEffect: RageEffect:
ld hl, wPlayerBattleStatus2 ld hl, wPlayerBattleStatus2
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .player jr z, .player
ld hl, wEnemyBattleStatus2 ld hl, wEnemyBattleStatus2
@ -1201,7 +1201,7 @@ MimicEffect:
ld a, [wMoveMissed] ld a, [wMoveMissed]
and a and a
jr nz, .mimicMissed jr nz, .mimicMissed
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld hl, wBattleMonMoves ld hl, wBattleMonMoves
ld a, [wPlayerBattleStatus1] ld a, [wPlayerBattleStatus1]
@ -1226,7 +1226,7 @@ MimicEffect:
and a and a
jr z, .getRandomMove jr z, .getRandomMove
ld d, a ld d, a
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld hl, wBattleMonMoves ld hl, wBattleMonMoves
ld a, [wPlayerMoveListIndex] ld a, [wPlayerMoveListIndex]
@ -1284,7 +1284,7 @@ DisableEffect:
jr nz, .moveMissed jr nz, .moveMissed
ld de, wEnemyDisabledMove ld de, wEnemyDisabledMove
ld hl, wEnemyMonMoves ld hl, wEnemyMonMoves
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .disableEffect jr z, .disableEffect
ld de, wPlayerDisabledMove ld de, wPlayerDisabledMove
@ -1307,7 +1307,7 @@ DisableEffect:
jr z, .pickMoveToDisable ; loop until a non-00 move slot is found jr z, .pickMoveToDisable ; loop until a non-00 move slot is found
ld [wd11e], a ; store move number ld [wd11e], a ; store move number
push hl push hl
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld hl, wBattleMonPP ld hl, wBattleMonPP
jr nz, .enemyTurn jr nz, .enemyTurn
@ -1345,7 +1345,7 @@ DisableEffect:
ld [de], a ld [de], a
call PlayCurrentMoveAnimation2 call PlayCurrentMoveAnimation2
ld hl, wPlayerDisabledMoveNumber ld hl, wPlayerDisabledMoveNumber
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr nz, .printDisableText jr nz, .printDisableText
inc hl ; wEnemyDisabledMoveNumber inc hl ; wEnemyDisabledMoveNumber
@ -1430,7 +1430,7 @@ ParalyzedMayNotAttackText:
CheckTargetSubstitute: CheckTargetSubstitute:
push hl push hl
ld hl, wEnemyBattleStatus2 ld hl, wEnemyBattleStatus2
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .next1 jr z, .next1
ld hl, wPlayerBattleStatus2 ld hl, wPlayerBattleStatus2
@ -1442,7 +1442,7 @@ CheckTargetSubstitute:
PlayCurrentMoveAnimation2: PlayCurrentMoveAnimation2:
; animation at MOVENUM will be played unless MOVENUM is 0 ; animation at MOVENUM will be played unless MOVENUM is 0
; plays wAnimationType 3 or 6 ; plays wAnimationType 3 or 6
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld a, [wPlayerMoveNum] ld a, [wPlayerMoveNum]
jr z, .notEnemyTurn jr z, .notEnemyTurn
@ -1454,7 +1454,7 @@ PlayCurrentMoveAnimation2:
PlayBattleAnimation2: PlayBattleAnimation2:
; play animation ID at a and animation type 6 or 3 ; play animation ID at a and animation type 6 or 3
ld [wAnimationID], a ld [wAnimationID], a
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld a, $6 ld a, $6
jr z, .storeAnimationType jr z, .storeAnimationType
@ -1468,7 +1468,7 @@ PlayCurrentMoveAnimation:
; resets wAnimationType ; resets wAnimationType
xor a xor a
ld [wAnimationType], a ld [wAnimationType], a
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld a, [wPlayerMoveNum] ld a, [wPlayerMoveNum]
jr z, .notEnemyTurn jr z, .notEnemyTurn

View file

@ -55,15 +55,15 @@ GainExperience:
jr .gainStatExpLoop jr .gainStatExpLoop
.statExpDone .statExpDone
xor a xor a
ld [H_MULTIPLICAND], a ld [hMultiplicand], a
ld [H_MULTIPLICAND + 1], a ld [hMultiplicand + 1], a
ld a, [wEnemyMonBaseExp] ld a, [wEnemyMonBaseExp]
ld [H_MULTIPLICAND + 2], a ld [hMultiplicand + 2], a
ld a, [wEnemyMonLevel] ld a, [wEnemyMonLevel]
ld [H_MULTIPLIER], a ld [hMultiplier], a
call Multiply call Multiply
ld a, 7 ld a, 7
ld [H_DIVISOR], a ld [hDivisor], a
ld b, 4 ld b, 4
call Divide call Divide
ld hl, wPartyMon1OTID - (wPartyMon1DVs - 1) ld hl, wPartyMon1OTID - (wPartyMon1DVs - 1)
@ -91,12 +91,12 @@ GainExperience:
inc hl inc hl
; add the gained exp to the party mon's exp ; add the gained exp to the party mon's exp
ld b, [hl] ld b, [hl]
ld a, [H_QUOTIENT + 3] ld a, [hQuotient + 3]
ld [wExpAmountGained + 1], a ld [wExpAmountGained + 1], a
add b add b
ld [hld], a ld [hld], a
ld b, [hl] ld b, [hl]
ld a, [H_QUOTIENT + 2] ld a, [hQuotient + 2]
ld [wExpAmountGained], a ld [wExpAmountGained], a
adc b adc b
ld [hl], a ld [hl], a
@ -311,14 +311,14 @@ DivideExpDataByNumMonsGainingExp:
ld c, wEnemyMonBaseExp + 1 - wEnemyMonBaseStats ld c, wEnemyMonBaseExp + 1 - wEnemyMonBaseStats
.divideLoop .divideLoop
xor a xor a
ld [H_DIVIDEND], a ld [hDividend], a
ld a, [hl] ld a, [hl]
ld [H_DIVIDEND + 1], a ld [hDividend + 1], a
ld a, [wd11e] ld a, [wd11e]
ld [H_DIVISOR], a ld [hDivisor], a
ld b, $2 ld b, $2
call Divide ; divide value by number of mons gaining exp call Divide ; divide value by number of mons gaining exp
ld a, [H_QUOTIENT + 3] ld a, [hQuotient + 3]
ld [hli], a ld [hli], a
dec c dec c
jr nz, .divideLoop jr nz, .divideLoop
@ -326,17 +326,17 @@ DivideExpDataByNumMonsGainingExp:
; multiplies exp by 1.5 ; multiplies exp by 1.5
BoostExp: BoostExp:
ld a, [H_QUOTIENT + 2] ld a, [hQuotient + 2]
ld b, a ld b, a
ld a, [H_QUOTIENT + 3] ld a, [hQuotient + 3]
ld c, a ld c, a
srl b srl b
rr c rr c
add c add c
ld [H_QUOTIENT + 3], a ld [hQuotient + 3], a
ld a, [H_QUOTIENT + 2] ld a, [hQuotient + 2]
adc b adc b
ld [H_QUOTIENT + 2], a ld [hQuotient + 2], a
ret ret
GainedText: GainedText:

View file

@ -9,12 +9,12 @@ MarowakAnim:
call ClearScreenArea call ClearScreenArea
call Delay3 call Delay3
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ; disable BG transfer so we don't see the Marowak too soon ld [hAutoBGTransferEnabled], a ; disable BG transfer so we don't see the Marowak too soon
; replace ghost pic with Marowak in BG ; replace ghost pic with Marowak in BG
ld a, MAROWAK ld a, MAROWAK
ld [wChangeMonPicEnemyTurnSpecies], a ld [wChangeMonPicEnemyTurnSpecies], a
ld a, $1 ld a, $1
ld [H_WHOSETURN], a ld [hWhoseTurn], a
callab ChangeMonPic callab ChangeMonPic
; alternate between black and light grey 8 times. ; alternate between black and light grey 8 times.
; this makes the ghost's body appear to flash ; this makes the ghost's body appear to flash
@ -44,7 +44,7 @@ MarowakAnim:
and a and a
jr nz, .fadeInMarowakLoop jr nz, .fadeInMarowakLoop
ld a, $1 ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a ; enable BG transfer so the BG Marowak pic will be visible after the sprite one is cleared ld [hAutoBGTransferEnabled], a ; enable BG transfer so the BG Marowak pic will be visible after the sprite one is cleared
call Delay3 call Delay3
jp ClearSprites jp ClearSprites

View file

@ -1,7 +1,7 @@
ConversionEffect_: ConversionEffect_:
ld hl, wEnemyMonType1 ld hl, wEnemyMonType1
ld de, wBattleMonType1 ld de, wBattleMonType1
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld a, [wEnemyBattleStatus1] ld a, [wEnemyBattleStatus1]
jr z, .conversionEffect jr z, .conversionEffect

View file

@ -14,7 +14,7 @@ DrainHPEffect_:
.getAttackerHP .getAttackerHP
ld hl, wBattleMonHP ld hl, wBattleMonHP
ld de, wBattleMonMaxHP ld de, wBattleMonMaxHP
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jp z, .addDamageToAttackerHP jp z, .addDamageToAttackerHP
ld hl, wEnemyMonHP ld hl, wEnemyMonHP
@ -69,7 +69,7 @@ DrainHPEffect_:
ld [wHPBarNewHP+1], a ld [wHPBarNewHP+1], a
inc de inc de
.next .next
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
coord hl, 10, 9 coord hl, 10, 9
ld a, $1 ld a, $1
@ -83,7 +83,7 @@ DrainHPEffect_:
predef DrawEnemyHUDAndHPBar predef DrawEnemyHUDAndHPBar
callab ReadPlayerMonCurHPAndStatus callab ReadPlayerMonCurHPAndStatus
ld hl, SuckedHealthText ld hl, SuckedHealthText
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld a, [wPlayerMoveEffect] ld a, [wPlayerMoveEffect]
jr z, .next3 jr z, .next3

View file

@ -1,6 +1,6 @@
FocusEnergyEffect_: FocusEnergyEffect_:
ld hl, wPlayerBattleStatus2 ld hl, wPlayerBattleStatus2
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .notEnemy jr z, .notEnemy
ld hl, wEnemyBattleStatus2 ld hl, wEnemyBattleStatus2

View file

@ -15,7 +15,7 @@ HazeEffect_:
; cure non-volatile status, but only for the target ; cure non-volatile status, but only for the target
ld hl, wEnemyMonStatus ld hl, wEnemyMonStatus
ld de, wEnemySelectedMove ld de, wEnemySelectedMove
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .cureStatuses jr z, .cureStatuses
ld hl, wBattleMonStatus ld hl, wBattleMonStatus

View file

@ -1,5 +1,5 @@
HealEffect_: HealEffect_:
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld de, wBattleMonHP ld de, wBattleMonHP
ld hl, wBattleMonMaxHP ld hl, wBattleMonMaxHP
@ -27,7 +27,7 @@ HealEffect_:
ld c, 50 ld c, 50
call DelayFrames call DelayFrames
ld hl, wBattleMonStatus ld hl, wBattleMonStatus
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .restEffect jr z, .restEffect
ld hl, wEnemyMonStatus ld hl, wEnemyMonStatus
@ -87,7 +87,7 @@ HealEffect_:
.playAnim .playAnim
ld hl, PlayCurrentMoveAnimation ld hl, PlayCurrentMoveAnimation
call BankswitchEtoF call BankswitchEtoF
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
coord hl, 10, 9 coord hl, 10, 9
ld a, $1 ld a, $1

View file

@ -5,7 +5,7 @@ LeechSeedEffect_:
jr nz, .moveMissed jr nz, .moveMissed
ld hl, wEnemyBattleStatus2 ld hl, wEnemyBattleStatus2
ld de, wEnemyMonType1 ld de, wEnemyMonType1
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .leechSeedEffect jr z, .leechSeedEffect
ld hl, wPlayerBattleStatus2 ld hl, wPlayerBattleStatus2

View file

@ -1,6 +1,6 @@
MistEffect_: MistEffect_:
ld hl, wPlayerBattleStatus2 ld hl, wPlayerBattleStatus2
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .mistEffect jr z, .mistEffect
ld hl, wEnemyBattleStatus2 ld hl, wEnemyBattleStatus2

View file

@ -7,7 +7,7 @@ OneHitKOEffect_:
ld [wCriticalHitOrOHKO], a ld [wCriticalHitOrOHKO], a
ld hl, wBattleMonSpeed + 1 ld hl, wBattleMonSpeed + 1
ld de, wEnemyMonSpeed + 1 ld de, wEnemyMonSpeed + 1
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .compareSpeed jr z, .compareSpeed
ld hl, wEnemyMonSpeed + 1 ld hl, wEnemyMonSpeed + 1

View file

@ -1,7 +1,7 @@
ParalyzeEffect_: ParalyzeEffect_:
ld hl, wEnemyMonStatus ld hl, wEnemyMonStatus
ld de, wPlayerMoveType ld de, wPlayerMoveType
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jp z, .next jp z, .next
ld hl, wBattleMonStatus ld hl, wBattleMonStatus

View file

@ -2,7 +2,7 @@ PayDayEffect_:
xor a xor a
ld hl, wcd6d ld hl, wcd6d
ld [hli], a ld [hli], a
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld a, [wBattleMonLevel] ld a, [wBattleMonLevel]
jr z, .payDayEffect jr z, .payDayEffect
@ -10,28 +10,28 @@ PayDayEffect_:
.payDayEffect .payDayEffect
; level * 2 ; level * 2
add a add a
ld [H_DIVIDEND + 3], a ld [hDividend + 3], a
xor a xor a
ld [H_DIVIDEND], a ld [hDividend], a
ld [H_DIVIDEND + 1], a ld [hDividend + 1], a
ld [H_DIVIDEND + 2], a ld [hDividend + 2], a
; convert to BCD ; convert to BCD
ld a, 100 ld a, 100
ld [H_DIVISOR], a ld [hDivisor], a
ld b, $4 ld b, $4
call Divide call Divide
ld a, [H_QUOTIENT + 3] ld a, [hQuotient + 3]
ld [hli], a ld [hli], a
ld a, [H_REMAINDER] ld a, [hRemainder]
ld [H_DIVIDEND + 3], a ld [hDividend + 3], a
ld a, 10 ld a, 10
ld [H_DIVISOR], a ld [hDivisor], a
ld b, $4 ld b, $4
call Divide call Divide
ld a, [H_QUOTIENT + 3] ld a, [hQuotient + 3]
swap a swap a
ld b, a ld b, a
ld a, [H_REMAINDER] ld a, [hRemainder]
add b add b
ld [hl], a ld [hl], a
ld de, wTotalPayDayMoney + 2 ld de, wTotalPayDayMoney + 2

View file

@ -1,5 +1,5 @@
RecoilEffect_: RecoilEffect_:
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld a, [wPlayerMoveNum] ld a, [wPlayerMoveNum]
ld hl, wBattleMonMaxHP ld hl, wBattleMonMaxHP
@ -54,7 +54,7 @@ RecoilEffect_:
ld [hl], a ld [hl], a
.getHPBarCoords .getHPBarCoords
coord hl, 10, 9 coord hl, 10, 9
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld a, $1 ld a, $1
jr z, .updateHPBar jr z, .updateHPBar

View file

@ -1,7 +1,7 @@
ReflectLightScreenEffect_: ReflectLightScreenEffect_:
ld hl, wPlayerBattleStatus3 ld hl, wPlayerBattleStatus3
ld de, wPlayerMoveEffect ld de, wPlayerMoveEffect
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .reflectLightScreenEffect jr z, .reflectLightScreenEffect
ld hl, wEnemyBattleStatus3 ld hl, wEnemyBattleStatus3

View file

@ -4,7 +4,7 @@ SubstituteEffect_:
ld hl, wBattleMonMaxHP ld hl, wBattleMonMaxHP
ld de, wPlayerSubstituteHP ld de, wPlayerSubstituteHP
ld bc, wPlayerBattleStatus2 ld bc, wPlayerBattleStatus2
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .notEnemy jr z, .notEnemy
ld hl, wEnemyMonMaxHP ld hl, wEnemyMonMaxHP

View file

@ -3,7 +3,7 @@ TransformEffect_:
ld de, wEnemyMonSpecies ld de, wEnemyMonSpecies
ld bc, wEnemyBattleStatus3 ld bc, wEnemyBattleStatus3
ld a, [wEnemyBattleStatus1] ld a, [wEnemyBattleStatus1]
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr nz, .hitTest jr nz, .hitTest
ld hl, wEnemyMonSpecies ld hl, wEnemyMonSpecies
@ -18,7 +18,7 @@ TransformEffect_:
push de push de
push bc push bc
ld hl, wPlayerBattleStatus2 ld hl, wPlayerBattleStatus2
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .transformEffect jr z, .transformEffect
ld hl, wEnemyBattleStatus2 ld hl, wEnemyBattleStatus2
@ -64,7 +64,7 @@ TransformEffect_:
inc bc inc bc
inc bc inc bc
call CopyData call CopyData
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .next jr z, .next
; save enemy mon DVs at wTransformedEnemyMonOriginalDVs ; save enemy mon DVs at wTransformedEnemyMonOriginalDVs
@ -128,7 +128,7 @@ TransformEffect_:
jp PrintText jp PrintText
.copyBasedOnTurn .copyBasedOnTurn
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
jr z, .gotStatsOrModsToCopy jr z, .gotStatsOrModsToCopy
push hl push hl

View file

@ -41,16 +41,16 @@ ScaleFirstThreeSpriteColumnsByTwo:
ScaleLastSpriteColumnByTwo: ScaleLastSpriteColumnByTwo:
ld a, 4*8 - 4 ; $1c, 4 tiles minus 4 unused rows ld a, 4*8 - 4 ; $1c, 4 tiles minus 4 unused rows
ld [H_SPRITEINTERLACECOUNTER], a ld [hSpriteInterlaceCounter], a
ld bc, -1 ld bc, -1
.columnInnerLoop .columnInnerLoop
ld a, [de] ld a, [de]
dec de dec de
swap a ; only high nybble contains information swap a ; only high nybble contains information
call ScalePixelsByTwo call ScalePixelsByTwo
ld a, [H_SPRITEINTERLACECOUNTER] ld a, [hSpriteInterlaceCounter]
dec a dec a
ld [H_SPRITEINTERLACECOUNTER], a ld [hSpriteInterlaceCounter], a
jr nz, .columnInnerLoop jr nz, .columnInnerLoop
dec de ; skip last 4 rows of new column dec de ; skip last 4 rows of new column
dec de dec de

View file

@ -655,17 +655,17 @@ AIUseDireHit: ; unused
AICheckIfHPBelowFraction: AICheckIfHPBelowFraction:
; return carry if enemy trainer's current HP is below 1 / a of the maximum ; return carry if enemy trainer's current HP is below 1 / a of the maximum
ld [H_DIVISOR], a ld [hDivisor], a
ld hl, wEnemyMonMaxHP ld hl, wEnemyMonMaxHP
ld a, [hli] ld a, [hli]
ld [H_DIVIDEND], a ld [hDividend], a
ld a, [hl] ld a, [hl]
ld [H_DIVIDEND + 1], a ld [hDividend + 1], a
ld b, 2 ld b, 2
call Divide call Divide
ld a, [H_QUOTIENT + 3] ld a, [hQuotient + 3]
ld c, a ld c, a
ld a, [H_QUOTIENT + 2] ld a, [hQuotient + 2]
ld b, a ld b, a
ld hl, wEnemyMonHP + 1 ld hl, wEnemyMonHP + 1
ld a, [hld] ld a, [hld]

View file

@ -1,6 +1,6 @@
; does nothing since no stats are ever selected (barring glitches) ; does nothing since no stats are ever selected (barring glitches)
DoubleSelectedStats: DoubleSelectedStats:
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld a, [wPlayerStatsToDouble] ld a, [wPlayerStatsToDouble]
ld hl, wBattleMonAttack + 1 ld hl, wBattleMonAttack + 1
@ -30,7 +30,7 @@ DoubleSelectedStats:
; does nothing since no stats are ever selected (barring glitches) ; does nothing since no stats are ever selected (barring glitches)
HalveSelectedStats: HalveSelectedStats:
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
and a and a
ld a, [wPlayerStatsToHalve] ld a, [wPlayerStatsToHalve]
ld hl, wBattleMonAttack ld hl, wBattleMonAttack

View file

@ -41,5 +41,5 @@ TestBattle:
; do it all again. ; do it all again.
ld a, 1 ld a, 1
ld [wUpdateSpritesEnabled], a ld [wUpdateSpritesEnabled], a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
jr .loop jr .loop

View file

@ -26,7 +26,7 @@ DisplayMonFrontSpriteInBox:
; Displays a pokemon's front sprite in a pop-up window. ; Displays a pokemon's front sprite in a pop-up window.
; [wcf91] = pokemon internal id number ; [wcf91] = pokemon internal id number
ld a, 1 ld a, 1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
call Delay3 call Delay3
xor a xor a
ld [hWY], a ld [hWY], a

View file

@ -10,13 +10,13 @@ TownMapText::
xor a xor a
ld [hWY], a ld [hWY], a
inc a inc a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
call LoadFontTilePatterns call LoadFontTilePatterns
callba DisplayTownMap callba DisplayTownMap
ld hl, wd730 ld hl, wd730
res 6, [hl] res 6, [hl]
ld de, TextScriptEnd ld de, TextScriptEnd
push de push de
ld a, [H_LOADEDROMBANK] ld a, [hLoadedROMBank]
push af push af
jp CloseTextDisplay jp CloseTextDisplay

View file

@ -6,7 +6,7 @@ HPBarLength:
GetHPBarLength: GetHPBarLength:
push hl push hl
xor a xor a
ld hl, H_MULTIPLICAND ld hl, hMultiplicand
ld [hli], a ld [hli], a
ld a, b ld a, b
ld [hli], a ld [hli], a
@ -21,22 +21,22 @@ GetHPBarLength:
rr e rr e
srl d srl d
rr e rr e
ld a, [H_MULTIPLICAND+1] ld a, [hMultiplicand+1]
ld b, a ld b, a
ld a, [H_MULTIPLICAND+2] ld a, [hMultiplicand+2]
srl b ; divide multiplication result as well srl b ; divide multiplication result as well
rr a rr a
srl b srl b
rr a rr a
ld [H_MULTIPLICAND+2], a ld [hMultiplicand+2], a
ld a, b ld a, b
ld [H_MULTIPLICAND+1], a ld [hMultiplicand+1], a
.maxHPSmaller256 .maxHPSmaller256
ld a, e ld a, e
ld [H_DIVISOR], a ld [hDivisor], a
ld b, $4 ld b, $4
call Divide call Divide
ld a, [H_MULTIPLICAND+2] ld a, [hMultiplicand+2]
ld e, a ; e = bc * 48 / de (num of pixels of HP bar) ld e, a ; e = bc * 48 / de (num of pixels of HP bar)
pop hl pop hl
and a and a
@ -213,7 +213,7 @@ UpdateHPBar_PrintHPNumber:
ld a, [wHPBarOldHP + 1] ld a, [wHPBarOldHP + 1]
ld [wHPBarTempHP], a ld [wHPBarTempHP], a
push hl push hl
ld a, [hFlags_0xFFF6] ld a, [hFlagsFFF6]
bit 0, a bit 0, a
jr z, .asm_fb15 jr z, .asm_fb15
ld de, $9 ld de, $9

View file

@ -239,14 +239,14 @@ ItemUseBall:
; Calculate MaxHP * 255. ; Calculate MaxHP * 255.
xor a xor a
ld [H_MULTIPLICAND], a ld [hMultiplicand], a
ld hl, wEnemyMonMaxHP ld hl, wEnemyMonMaxHP
ld a, [hli] ld a, [hli]
ld [H_MULTIPLICAND + 1], a ld [hMultiplicand + 1], a
ld a, [hl] ld a, [hl]
ld [H_MULTIPLICAND + 2], a ld [hMultiplicand + 2], a
ld a, 255 ld a, 255
ld [H_MULTIPLIER], a ld [hMultiplier], a
call Multiply call Multiply
; Determine BallFactor. It's 8 for Great Balls and 12 for the others. ; Determine BallFactor. It's 8 for Great Balls and 12 for the others.
@ -260,7 +260,7 @@ ItemUseBall:
; Note that the results of all division operations are floored. ; Note that the results of all division operations are floored.
; Calculate (MaxHP * 255) / BallFactor. ; Calculate (MaxHP * 255) / BallFactor.
ld [H_DIVISOR], a ld [hDivisor], a
ld b, 4 ; number of bytes in dividend ld b, 4 ; number of bytes in dividend
call Divide call Divide
@ -281,17 +281,17 @@ ItemUseBall:
.skip2 .skip2
; Let W = ((MaxHP * 255) / BallFactor) / max(HP / 4, 1). Calculate W. ; Let W = ((MaxHP * 255) / BallFactor) / max(HP / 4, 1). Calculate W.
ld [H_DIVISOR], a ld [hDivisor], a
ld b, 4 ld b, 4
call Divide call Divide
; If W > 255, store 255 in [H_QUOTIENT + 3]. ; If W > 255, store 255 in [hQuotient + 3].
; Let X = min(W, 255) = [H_QUOTIENT + 3]. ; Let X = min(W, 255) = [hQuotient + 3].
ld a, [H_QUOTIENT + 2] ld a, [hQuotient + 2]
and a and a
jr z, .skip3 jr z, .skip3
ld a, 255 ld a, 255
ld [H_QUOTIENT + 3], a ld [hQuotient + 3], a
.skip3 .skip3
pop bc ; b = Rand1 - Status pop bc ; b = Rand1 - Status
@ -302,7 +302,7 @@ ItemUseBall:
jr c, .failedToCapture jr c, .failedToCapture
; If W > 255, the ball captures the Pokémon. ; If W > 255, the ball captures the Pokémon.
ld a, [H_QUOTIENT + 2] ld a, [hQuotient + 2]
and a and a
jr nz, .captured jr nz, .captured
@ -310,7 +310,7 @@ ItemUseBall:
; If Rand2 > X, the ball fails to capture the Pokémon. ; If Rand2 > X, the ball fails to capture the Pokémon.
ld b, a ld b, a
ld a, [H_QUOTIENT + 3] ld a, [hQuotient + 3]
cp b cp b
jr c, .failedToCapture jr c, .failedToCapture
@ -318,17 +318,17 @@ ItemUseBall:
jr .skipShakeCalculations jr .skipShakeCalculations
.failedToCapture .failedToCapture
ld a, [H_QUOTIENT + 3] ld a, [hQuotient + 3]
ld [wPokeBallCaptureCalcTemp], a ; Save X. ld [wPokeBallCaptureCalcTemp], a ; Save X.
; Calculate CatchRate * 100. ; Calculate CatchRate * 100.
xor a xor a
ld [H_MULTIPLICAND], a ld [hMultiplicand], a
ld [H_MULTIPLICAND + 1], a ld [hMultiplicand + 1], a
ld a, [wEnemyMonActualCatchRate] ld a, [wEnemyMonActualCatchRate]
ld [H_MULTIPLICAND + 2], a ld [hMultiplicand + 2], a
ld a, 100 ld a, 100
ld [H_MULTIPLIER], a ld [hMultiplier], a
call Multiply call Multiply
; Determine BallFactor2. ; Determine BallFactor2.
@ -349,26 +349,26 @@ ItemUseBall:
.skip4 .skip4
; Let Y = (CatchRate * 100) / BallFactor2. Calculate Y. ; Let Y = (CatchRate * 100) / BallFactor2. Calculate Y.
ld a, b ld a, b
ld [H_DIVISOR], a ld [hDivisor], a
ld b, 4 ld b, 4
call Divide call Divide
; If Y > 255, there are 3 shakes. ; If Y > 255, there are 3 shakes.
; Note that this shouldn't be possible. ; Note that this shouldn't be possible.
; The maximum value of Y is (255 * 100) / 150 = 170. ; The maximum value of Y is (255 * 100) / 150 = 170.
ld a, [H_QUOTIENT + 2] ld a, [hQuotient + 2]
and a and a
ld b, $63 ; 3 shakes ld b, $63 ; 3 shakes
jr nz, .setAnimData jr nz, .setAnimData
; Calculate X * Y. ; Calculate X * Y.
ld a, [wPokeBallCaptureCalcTemp] ld a, [wPokeBallCaptureCalcTemp]
ld [H_MULTIPLIER], a ld [hMultiplier], a
call Multiply call Multiply
; Calculate (X * Y) / 255. ; Calculate (X * Y) / 255.
ld a, 255 ld a, 255
ld [H_DIVISOR], a ld [hDivisor], a
ld b, 4 ld b, 4
call Divide call Divide
@ -386,19 +386,19 @@ ItemUseBall:
.addAilmentValue .addAilmentValue
; If the Pokémon has a status ailment, add Status2. ; If the Pokémon has a status ailment, add Status2.
ld a, [H_QUOTIENT + 3] ld a, [hQuotient + 3]
add b add b
ld [H_QUOTIENT + 3], a ld [hQuotient + 3], a
.skip5 .skip5
; Finally determine the number of shakes. ; Finally determine the number of shakes.
; Let Z = ((X * Y) / 255) + Status2 = [H_QUOTIENT + 3]. ; Let Z = ((X * Y) / 255) + Status2 = [hQuotient + 3].
; The number of shakes depend on the range Z is in. ; The number of shakes depend on the range Z is in.
; 0 ≤ Z < 10: 0 shakes (the ball misses) ; 0 ≤ Z < 10: 0 shakes (the ball misses)
; 10 ≤ Z < 30: 1 shake ; 10 ≤ Z < 30: 1 shake
; 30 ≤ Z < 70: 2 shakes ; 30 ≤ Z < 70: 2 shakes
; 70 ≤ Z: 3 shakes ; 70 ≤ Z: 3 shakes
ld a, [H_QUOTIENT + 3] ld a, [hQuotient + 3]
cp 10 cp 10
ld b, $20 ld b, $20
jr c, .setAnimData jr c, .setAnimData
@ -422,7 +422,7 @@ ItemUseBall:
ld a, TOSS_ANIM ld a, TOSS_ANIM
ld [wAnimationID], a ld [wAnimationID], a
xor a xor a
ld [H_WHOSETURN], a ld [hWhoseTurn], a
ld [wAnimationType], a ld [wAnimationType], a
ld [wDamageMultipliers], a ld [wDamageMultipliers], a
ld a, [wWhichPokemon] ld a, [wWhichPokemon]
@ -1018,18 +1018,18 @@ ItemUseMedicine:
call AddNTimes call AddNTimes
ld a, [hli] ld a, [hli]
ld [wHPBarMaxHP + 1], a ld [wHPBarMaxHP + 1], a
ld [H_DIVIDEND], a ld [hDividend], a
ld a, [hl] ld a, [hl]
ld [wHPBarMaxHP], a ld [wHPBarMaxHP], a
ld [H_DIVIDEND + 1], a ld [hDividend + 1], a
ld a, 5 ld a, 5
ld [H_DIVISOR], a ld [hDivisor], a
ld b, 2 ; number of bytes ld b, 2 ; number of bytes
call Divide ; get 1/5 of max HP of pokemon that used Softboiled call Divide ; get 1/5 of max HP of pokemon that used Softboiled
ld bc, (wPartyMon1HP + 1) - (wPartyMon1MaxHP + 1) ld bc, (wPartyMon1HP + 1) - (wPartyMon1MaxHP + 1)
add hl, bc ; hl now points to LSB of current HP of pokemon that used Softboiled add hl, bc ; hl now points to LSB of current HP of pokemon that used Softboiled
; subtract 1/5 of max HP from current HP of pokemon that used Softboiled ; subtract 1/5 of max HP from current HP of pokemon that used Softboiled
ld a, [H_QUOTIENT + 3] ld a, [hQuotient + 3]
push af push af
ld b, a ld b, a
ld a, [hl] ld a, [hl]
@ -1037,7 +1037,7 @@ ItemUseMedicine:
sub b sub b
ld [hld], a ld [hld], a
ld [wHPBarNewHP], a ld [wHPBarNewHP], a
ld a, [H_QUOTIENT + 2] ld a, [hQuotient + 2]
ld b, a ld b, a
ld a, [hl] ld a, [hl]
ld [wHPBarOldHP+1], a ld [wHPBarOldHP+1], a
@ -1050,15 +1050,15 @@ ItemUseMedicine:
call AddNTimes ; calculate coordinates of HP bar of pokemon that used Softboiled call AddNTimes ; calculate coordinates of HP bar of pokemon that used Softboiled
ld a, SFX_HEAL_HP ld a, SFX_HEAL_HP
call PlaySoundWaitForCurrent call PlaySoundWaitForCurrent
ld a, [hFlags_0xFFF6] ld a, [hFlagsFFF6]
set 0, a set 0, a
ld [hFlags_0xFFF6], a ld [hFlagsFFF6], a
ld a, $02 ld a, $02
ld [wHPBarType], a ld [wHPBarType], a
predef UpdateHPBar2 ; animate HP bar decrease of pokemon that used Softboiled predef UpdateHPBar2 ; animate HP bar decrease of pokemon that used Softboiled
ld a, [hFlags_0xFFF6] ld a, [hFlagsFFF6]
res 0, a res 0, a
ld [hFlags_0xFFF6], a ld [hFlagsFFF6], a
pop af pop af
ld b, a ; store heal amount (1/5 of max HP) ld b, a ; store heal amount (1/5 of max HP)
ld hl, wHPBarOldHP + 1 ld hl, wHPBarOldHP + 1
@ -1200,15 +1200,15 @@ ItemUseMedicine:
jr z, .playStatusAilmentCuringSound jr z, .playStatusAilmentCuringSound
ld a, SFX_HEAL_HP ld a, SFX_HEAL_HP
call PlaySoundWaitForCurrent call PlaySoundWaitForCurrent
ld a, [hFlags_0xFFF6] ld a, [hFlagsFFF6]
set 0, a set 0, a
ld [hFlags_0xFFF6], a ld [hFlagsFFF6], a
ld a, $02 ld a, $02
ld [wHPBarType], a ld [wHPBarType], a
predef UpdateHPBar2 ; animate the HP bar lengthening predef UpdateHPBar2 ; animate the HP bar lengthening
ld a, [hFlags_0xFFF6] ld a, [hFlagsFFF6]
res 0, a res 0, a
ld [hFlags_0xFFF6], a ld [hFlagsFFF6], a
ld a, REVIVE_MSG ld a, REVIVE_MSG
ld [wPartyMenuTypeOrMessageID], a ld [wPartyMenuTypeOrMessageID], a
ld a, [wcf91] ld a, [wcf91]
@ -1224,13 +1224,13 @@ ItemUseMedicine:
call PlaySoundWaitForCurrent call PlaySoundWaitForCurrent
.showHealingItemMessage .showHealingItemMessage
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
call ClearScreen call ClearScreen
dec a dec a
ld [wUpdateSpritesEnabled], a ld [wUpdateSpritesEnabled], a
call RedrawPartyMenu ; redraws the party menu and displays the message call RedrawPartyMenu ; redraws the party menu and displays the message
ld a, 1 ld a, 1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ld c, 50 ld c, 50
call DelayFrames call DelayFrames
call WaitForTextScrollButtonPress call WaitForTextScrollButtonPress
@ -1459,7 +1459,7 @@ BaitRockCommon:
ld [wAnimationID], a ld [wAnimationID], a
xor a xor a
ld [wAnimationType], a ld [wAnimationType], a
ld [H_WHOSETURN], a ld [hWhoseTurn], a
ld [de], a ; zero escape factor (for bait), zero bait factor (for rock) ld [de], a ; zero escape factor (for bait), zero bait factor (for rock)
.randomLoop ; loop until a random number less than 5 is generated .randomLoop ; loop until a random number less than 5 is generated
call Random call Random
@ -1698,7 +1698,7 @@ ItemUseXStat:
call LoadScreenTilesFromBuffer1 ; restore saved screen call LoadScreenTilesFromBuffer1 ; restore saved screen
call Delay3 call Delay3
xor a xor a
ld [H_WHOSETURN], a ; set turn to player's turn ld [hWhoseTurn], a ; set turn to player's turn
callba StatModifierUpEffect ; do stat increase move callba StatModifierUpEffect ; do stat increase move
pop hl pop hl
pop af pop af
@ -2463,13 +2463,13 @@ RestoreBonusPP:
AddBonusPP: AddBonusPP:
push bc push bc
ld a, [de] ; normal max PP of move ld a, [de] ; normal max PP of move
ld [H_DIVIDEND + 3], a ld [hDividend + 3], a
xor a xor a
ld [H_DIVIDEND], a ld [hDividend], a
ld [H_DIVIDEND + 1], a ld [hDividend + 1], a
ld [H_DIVIDEND + 2], a ld [hDividend + 2], a
ld a, 5 ld a, 5
ld [H_DIVISOR], a ld [hDivisor], a
ld b, 4 ld b, 4
call Divide call Divide
ld a, [hl] ; move PP ld a, [hl] ; move PP
@ -2480,7 +2480,7 @@ AddBonusPP:
srl a srl a
ld c, a ; c = number of PP Ups used ld c, a ; c = number of PP Ups used
.loop .loop
ld a, [H_QUOTIENT + 3] ld a, [hQuotient + 3]
cp 8 ; is the amount greater than or equal to 8? cp 8 ; is the amount greater than or equal to 8?
jr c, .addAmount jr c, .addAmount
ld a, 7 ; cap the amount at 7 ld a, 7 ; cap the amount at 7

View file

@ -338,10 +338,10 @@ TradeCenter_SelectMon:
ld a, 1 ld a, 1
ld [wTopMenuItemX], a ld [wTopMenuItemX], a
.enemyMonMenu_HandleInput .enemyMonMenu_HandleInput
ld hl, hFlags_0xFFF6 ld hl, hFlagsFFF6
set 1, [hl] set 1, [hl]
call HandleMenuInput call HandleMenuInput
ld hl, hFlags_0xFFF6 ld hl, hFlagsFFF6
res 1, [hl] res 1, [hl]
and a and a
jp z, .getNewInput jp z, .getNewInput
@ -403,10 +403,10 @@ TradeCenter_SelectMon:
lb bc, 6, 1 lb bc, 6, 1
call ClearScreenArea call ClearScreenArea
.playerMonMenu_HandleInput .playerMonMenu_HandleInput
ld hl, hFlags_0xFFF6 ld hl, hFlagsFFF6
set 1, [hl] set 1, [hl]
call HandleMenuInput call HandleMenuInput
ld hl, hFlags_0xFFF6 ld hl, hFlagsFFF6
res 1, [hl] res 1, [hl]
and a ; was anything pressed? and a ; was anything pressed?
jr nz, .playerMonMenu_SomethingPressed jr nz, .playerMonMenu_SomethingPressed

View file

@ -2,142 +2,142 @@ _Multiply::
ld a, $8 ld a, $8
ld b, a ld b, a
xor a xor a
ld [H_PRODUCT], a ld [hProduct], a
ld [H_MULTIPLYBUFFER], a ld [hMultiplyBuffer], a
ld [H_MULTIPLYBUFFER+1], a ld [hMultiplyBuffer+1], a
ld [H_MULTIPLYBUFFER+2], a ld [hMultiplyBuffer+2], a
ld [H_MULTIPLYBUFFER+3], a ld [hMultiplyBuffer+3], a
.loop .loop
ld a, [H_MULTIPLIER] ld a, [hMultiplier]
srl a srl a
ld [H_MULTIPLIER], a ; (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) ld [hMultiplier], a ; (aliases: hDivisor, hMultiplier, hPowerOf10)
jr nc, .smallMultiplier jr nc, .smallMultiplier
ld a, [H_MULTIPLYBUFFER+3] ld a, [hMultiplyBuffer+3]
ld c, a ld c, a
ld a, [H_MULTIPLICAND+2] ld a, [hMultiplicand+2]
add c add c
ld [H_MULTIPLYBUFFER+3], a ld [hMultiplyBuffer+3], a
ld a, [H_MULTIPLYBUFFER+2] ld a, [hMultiplyBuffer+2]
ld c, a ld c, a
ld a, [H_MULTIPLICAND+1] ld a, [hMultiplicand+1]
adc c adc c
ld [H_MULTIPLYBUFFER+2], a ld [hMultiplyBuffer+2], a
ld a, [H_MULTIPLYBUFFER+1] ld a, [hMultiplyBuffer+1]
ld c, a ld c, a
ld a, [H_MULTIPLICAND] ; (aliases: H_MULTIPLICAND) ld a, [hMultiplicand] ; (aliases: hMultiplicand)
adc c adc c
ld [H_MULTIPLYBUFFER+1], a ld [hMultiplyBuffer+1], a
ld a, [H_MULTIPLYBUFFER] ld a, [hMultiplyBuffer]
ld c, a ld c, a
ld a, [H_PRODUCT] ; (aliases: H_PRODUCT, H_PASTLEADINGZEROES, H_QUOTIENT) ld a, [hProduct] ; (aliases: hProduct, hPastLeadingZeros, hQuotient)
adc c adc c
ld [H_MULTIPLYBUFFER], a ld [hMultiplyBuffer], a
.smallMultiplier .smallMultiplier
dec b dec b
jr z, .done jr z, .done
ld a, [H_MULTIPLICAND+2] ld a, [hMultiplicand+2]
sla a sla a
ld [H_MULTIPLICAND+2], a ld [hMultiplicand+2], a
ld a, [H_MULTIPLICAND+1] ld a, [hMultiplicand+1]
rl a rl a
ld [H_MULTIPLICAND+1], a ld [hMultiplicand+1], a
ld a, [H_MULTIPLICAND] ld a, [hMultiplicand]
rl a rl a
ld [H_MULTIPLICAND], a ld [hMultiplicand], a
ld a, [H_PRODUCT] ld a, [hProduct]
rl a rl a
ld [H_PRODUCT], a ld [hProduct], a
jr .loop jr .loop
.done .done
ld a, [H_MULTIPLYBUFFER+3] ld a, [hMultiplyBuffer+3]
ld [H_PRODUCT+3], a ld [hProduct+3], a
ld a, [H_MULTIPLYBUFFER+2] ld a, [hMultiplyBuffer+2]
ld [H_PRODUCT+2], a ld [hProduct+2], a
ld a, [H_MULTIPLYBUFFER+1] ld a, [hMultiplyBuffer+1]
ld [H_PRODUCT+1], a ld [hProduct+1], a
ld a, [H_MULTIPLYBUFFER] ld a, [hMultiplyBuffer]
ld [H_PRODUCT], a ld [hProduct], a
ret ret
_Divide:: _Divide::
xor a xor a
ld [H_DIVIDEBUFFER], a ld [hDivideBuffer], a
ld [H_DIVIDEBUFFER+1], a ld [hDivideBuffer+1], a
ld [H_DIVIDEBUFFER+2], a ld [hDivideBuffer+2], a
ld [H_DIVIDEBUFFER+3], a ld [hDivideBuffer+3], a
ld [H_DIVIDEBUFFER+4], a ld [hDivideBuffer+4], a
ld a, $9 ld a, $9
ld e, a ld e, a
.asm_37db3 .asm_37db3
ld a, [H_DIVIDEBUFFER] ld a, [hDivideBuffer]
ld c, a ld c, a
ld a, [H_DIVIDEND+1] ; (aliases: H_MULTIPLICAND) ld a, [hDividend+1] ; (aliases: hMultiplicand)
sub c sub c
ld d, a ld d, a
ld a, [H_DIVISOR] ; (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) ld a, [hDivisor] ; (aliases: hDivisor, hMultiplier, hPowerOf10)
ld c, a ld c, a
ld a, [H_DIVIDEND] ; (aliases: H_PRODUCT, H_PASTLEADINGZEROES, H_QUOTIENT) ld a, [hDividend] ; (aliases: hProduct, hPastLeadingZeros, hQuotient)
sbc c sbc c
jr c, .asm_37dce jr c, .asm_37dce
ld [H_DIVIDEND], a ; (aliases: H_PRODUCT, H_PASTLEADINGZEROES, H_QUOTIENT) ld [hDividend], a ; (aliases: hProduct, hPastLeadingZeros, hQuotient)
ld a, d ld a, d
ld [H_DIVIDEND+1], a ; (aliases: H_MULTIPLICAND) ld [hDividend+1], a ; (aliases: hMultiplicand)
ld a, [H_DIVIDEBUFFER+4] ld a, [hDivideBuffer+4]
inc a inc a
ld [H_DIVIDEBUFFER+4], a ld [hDivideBuffer+4], a
jr .asm_37db3 jr .asm_37db3
.asm_37dce .asm_37dce
ld a, b ld a, b
cp $1 cp $1
jr z, .asm_37e18 jr z, .asm_37e18
ld a, [H_DIVIDEBUFFER+4] ld a, [hDivideBuffer+4]
sla a sla a
ld [H_DIVIDEBUFFER+4], a ld [hDivideBuffer+4], a
ld a, [H_DIVIDEBUFFER+3] ld a, [hDivideBuffer+3]
rl a rl a
ld [H_DIVIDEBUFFER+3], a ld [hDivideBuffer+3], a
ld a, [H_DIVIDEBUFFER+2] ld a, [hDivideBuffer+2]
rl a rl a
ld [H_DIVIDEBUFFER+2], a ld [hDivideBuffer+2], a
ld a, [H_DIVIDEBUFFER+1] ld a, [hDivideBuffer+1]
rl a rl a
ld [H_DIVIDEBUFFER+1], a ld [hDivideBuffer+1], a
dec e dec e
jr nz, .asm_37e04 jr nz, .asm_37e04
ld a, $8 ld a, $8
ld e, a ld e, a
ld a, [H_DIVIDEBUFFER] ld a, [hDivideBuffer]
ld [H_DIVISOR], a ; (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) ld [hDivisor], a ; (aliases: hDivisor, hMultiplier, hPowerOf10)
xor a xor a
ld [H_DIVIDEBUFFER], a ld [hDivideBuffer], a
ld a, [H_DIVIDEND+1] ; (aliases: H_MULTIPLICAND) ld a, [hDividend+1] ; (aliases: hMultiplicand)
ld [H_DIVIDEND], a ; (aliases: H_PRODUCT, H_PASTLEADINGZEROES, H_QUOTIENT) ld [hDividend], a ; (aliases: hProduct, hPastLeadingZeros, hQuotient)
ld a, [H_DIVIDEND+2] ld a, [hDividend+2]
ld [H_DIVIDEND+1], a ; (aliases: H_MULTIPLICAND) ld [hDividend+1], a ; (aliases: hMultiplicand)
ld a, [H_DIVIDEND+3] ld a, [hDividend+3]
ld [H_DIVIDEND+2], a ld [hDividend+2], a
.asm_37e04 .asm_37e04
ld a, e ld a, e
cp $1 cp $1
jr nz, .asm_37e0a jr nz, .asm_37e0a
dec b dec b
.asm_37e0a .asm_37e0a
ld a, [H_DIVISOR] ; (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) ld a, [hDivisor] ; (aliases: hDivisor, hMultiplier, hPowerOf10)
srl a srl a
ld [H_DIVISOR], a ; (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) ld [hDivisor], a ; (aliases: hDivisor, hMultiplier, hPowerOf10)
ld a, [H_DIVIDEBUFFER] ld a, [hDivideBuffer]
rr a rr a
ld [H_DIVIDEBUFFER], a ld [hDivideBuffer], a
jr .asm_37db3 jr .asm_37db3
.asm_37e18 .asm_37e18
ld a, [H_DIVIDEND+1] ; (aliases: H_MULTIPLICAND) ld a, [hDividend+1] ; (aliases: hMultiplicand)
ld [H_REMAINDER], a ; (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) ld [hRemainder], a ; (aliases: hDivisor, hMultiplier, hPowerOf10)
ld a, [H_DIVIDEBUFFER+4] ld a, [hDivideBuffer+4]
ld [H_QUOTIENT+3], a ld [hQuotient+3], a
ld a, [H_DIVIDEBUFFER+3] ld a, [hDivideBuffer+3]
ld [H_QUOTIENT+2], a ld [hQuotient+2], a
ld a, [H_DIVIDEBUFFER+2] ld a, [hDivideBuffer+2]
ld [H_QUOTIENT+1], a ; (aliases: H_MULTIPLICAND) ld [hQuotient+1], a ; (aliases: hMultiplicand)
ld a, [H_DIVIDEBUFFER+1] ld a, [hDivideBuffer+1]
ld [H_DIVIDEND], a ; (aliases: H_PRODUCT, H_PASTLEADINGZEROES, H_QUOTIENT) ld [hDividend], a ; (aliases: hProduct, hPastLeadingZeros, hQuotient)
ret ret

View file

@ -74,5 +74,5 @@ DisplayTextIDInit::
ld [hWY], a ; put the window on the screen ld [hWY], a ; put the window on the screen
call LoadFontTilePatterns call LoadFontTilePatterns
ld a, $01 ld a, $01
ld [H_AUTOBGTRANSFERENABLED], a ; enable continuous WRAM to VRAM transfer each V-blank ld [hAutoBGTransferEnabled], a ; enable continuous WRAM to VRAM transfer each V-blank
ret ret

View file

@ -342,7 +342,7 @@ CableClubOptionsText:
DisplayContinueGameInfo: DisplayContinueGameInfo:
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
coord hl, 4, 7 coord hl, 4, 7
ld b, 8 ld b, 8
ld c, 14 ld c, 14
@ -360,13 +360,13 @@ DisplayContinueGameInfo:
coord hl, 13, 15 coord hl, 13, 15
call PrintPlayTime call PrintPlayTime
ld a, 1 ld a, 1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ld c, 30 ld c, 30
jp DelayFrames jp DelayFrames
PrintSaveScreenText: PrintSaveScreenText:
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
coord hl, 4, 0 coord hl, 4, 0
ld b, $8 ld b, $8
ld c, $e ld c, $e
@ -386,7 +386,7 @@ PrintSaveScreenText:
coord hl, 13, 8 coord hl, 13, 8
call PrintPlayTime call PrintPlayTime
ld a, $1 ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ld c, 30 ld c, 30
jp DelayFrames jp DelayFrames
@ -463,7 +463,7 @@ DisplayOptionMenu:
ld a, [wOptionsTextSpeedCursorX] ; text speed cursor X coordinate ld a, [wOptionsTextSpeedCursorX] ; text speed cursor X coordinate
ld [wTopMenuItemX], a ld [wTopMenuItemX], a
ld a, $01 ld a, $01
ld [H_AUTOBGTRANSFERENABLED], a ; enable auto background transfer ld [hAutoBGTransferEnabled], a ; enable auto background transfer
call Delay3 call Delay3
.loop .loop
call PlaceMenuCursor call PlaceMenuCursor

View file

@ -337,7 +337,7 @@ ED_TileEnd:
PrintAlphabet: PrintAlphabet:
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ld a, [wAlphabetCase] ld a, [wAlphabetCase]
and a and a
ld de, LowerCaseAlphabet ld de, LowerCaseAlphabet
@ -362,7 +362,7 @@ PrintAlphabet:
jr nz, .outerLoop jr nz, .outerLoop
call PlaceString call PlaceString
ld a, $1 ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
jp Delay3 jp Delay3
INCLUDE "data/text/alphabets.asm" INCLUDE "data/text/alphabets.asm"

View file

@ -19,7 +19,7 @@
; f8: leveled up ; f8: leveled up
DrawPartyMenu_:: DrawPartyMenu_::
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
call ClearScreen call ClearScreen
call UpdateSprites call UpdateSprites
callba LoadMonPartySpriteGfxWithLCDDisabled ; load pokemon icon graphics callba LoadMonPartySpriteGfxWithLCDDisabled ; load pokemon icon graphics
@ -88,14 +88,14 @@ RedrawPartyMenu_::
pop hl pop hl
push hl push hl
ld bc, SCREEN_WIDTH + 1 ; down 1 row and right 1 column ld bc, SCREEN_WIDTH + 1 ; down 1 row and right 1 column
ld a, [hFlags_0xFFF6] ld a, [hFlagsFFF6]
set 0, a set 0, a
ld [hFlags_0xFFF6], a ld [hFlagsFFF6], a
add hl, bc add hl, bc
predef DrawHP2 ; draw HP bar and prints current / max HP predef DrawHP2 ; draw HP bar and prints current / max HP
ld a, [hFlags_0xFFF6] ld a, [hFlagsFFF6]
res 0, a res 0, a
ld [hFlags_0xFFF6], a ld [hFlagsFFF6], a
call SetPartyMenuHPBarColor ; color the HP bar (on SGB) call SetPartyMenuHPBarColor ; color the HP bar (on SGB)
pop hl pop hl
jr .printLevel jr .printLevel
@ -213,7 +213,7 @@ RedrawPartyMenu_::
pop af pop af
ld [hl], a ld [hl], a
ld a, 1 ld a, 1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
call Delay3 call Delay3
jp GBPalNormal jp GBPalNormal
.printItemUseMessage .printItemUseMessage

View file

@ -156,7 +156,7 @@ HandlePokedexSideMenu:
; sets carry flag if player presses A, unsets carry flag if player presses B ; sets carry flag if player presses A, unsets carry flag if player presses B
HandlePokedexListMenu: HandlePokedexListMenu:
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
; draw the horizontal line separating the seen and owned amounts from the menu ; draw the horizontal line separating the seen and owned amounts from the menu
coord hl, 15, 8 coord hl, 15, 8
ld a, "─" ld a, "─"
@ -216,7 +216,7 @@ HandlePokedexListMenu:
ld [wDexMaxSeenMon], a ld [wDexMaxSeenMon], a
.loop .loop
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
coord hl, 4, 2 coord hl, 4, 2
lb bc, 14, 10 lb bc, 14, 10
call ClearScreenArea call ClearScreenArea
@ -280,7 +280,7 @@ HandlePokedexListMenu:
dec d dec d
jr nz, .printPokemonLoop jr nz, .printPokemonLoop
ld a, 01 ld a, 01
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
call Delay3 call Delay3
call GBPalNormal call GBPalNormal
call HandleMenuInput call HandleMenuInput

View file

@ -351,10 +351,10 @@ ChangeBox::
call z, EmptyAllSRAMBoxes ; if so, empty all boxes in SRAM call z, EmptyAllSRAMBoxes ; if so, empty all boxes in SRAM
call DisplayChangeBoxMenu call DisplayChangeBoxMenu
call UpdateSprites call UpdateSprites
ld hl, hFlags_0xFFF6 ld hl, hFlagsFFF6
set 1, [hl] set 1, [hl]
call HandleMenuInput call HandleMenuInput
ld hl, hFlags_0xFFF6 ld hl, hFlagsFFF6
res 1, [hl] res 1, [hl]
bit 1, a ; pressed b bit 1, a ; pressed b
ret nz ret nz
@ -420,7 +420,7 @@ CopyBoxToOrFromSRAM:
DisplayChangeBoxMenu: DisplayChangeBoxMenu:
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ld a, A_BUTTON | B_BUTTON ld a, A_BUTTON | B_BUTTON
ld [wMenuWatchedKeys], a ld [wMenuWatchedKeys], a
ld a, 11 ld a, 11
@ -445,12 +445,12 @@ DisplayChangeBoxMenu:
ld b, 12 ld b, 12
ld c, 7 ld c, 7
call TextBoxBorder call TextBoxBorder
ld hl, hFlags_0xFFF6 ld hl, hFlagsFFF6
set 2, [hl] set 2, [hl]
ld de, BoxNames ld de, BoxNames
coord hl, 13, 1 coord hl, 13, 1
call PlaceString call PlaceString
ld hl, hFlags_0xFFF6 ld hl, hFlagsFFF6
res 2, [hl] res 2, [hl]
ld a, [wCurrentBoxNum] ld a, [wCurrentBoxNum]
and $7f and $7f
@ -486,7 +486,7 @@ DisplayChangeBoxMenu:
dec a dec a
jr nz, .loop jr nz, .loop
ld a, 1 ld a, 1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ret ret
ChooseABoxText: ChooseABoxText:

View file

@ -239,21 +239,21 @@ StartMenu_Pokemon::
ld bc, wPartyMon2 - wPartyMon1 ld bc, wPartyMon2 - wPartyMon1
call AddNTimes call AddNTimes
ld a, [hli] ld a, [hli]
ld [H_DIVIDEND], a ld [hDividend], a
ld a, [hl] ld a, [hl]
ld [H_DIVIDEND + 1], a ld [hDividend + 1], a
ld a, 5 ld a, 5
ld [H_DIVISOR], a ld [hDivisor], a
ld b, 2 ; number of bytes ld b, 2 ; number of bytes
call Divide call Divide
ld bc, wPartyMon1HP - wPartyMon1MaxHP ld bc, wPartyMon1HP - wPartyMon1MaxHP
add hl, bc add hl, bc
ld a, [hld] ld a, [hld]
ld b, a ld b, a
ld a, [H_QUOTIENT + 3] ld a, [hQuotient + 3]
sub b sub b
ld b, [hl] ld b, [hl]
ld a, [H_QUOTIENT + 2] ld a, [hQuotient + 2]
sbc b sbc b
jp nc, .notHealthyEnough jp nc, .notHealthyEnough
ld a, [wPartyAndBillsPCSavedMenuItem] ld a, [wPartyAndBillsPCSavedMenuItem]
@ -648,7 +648,7 @@ StartMenu_SaveReset::
StartMenu_Option:: StartMenu_Option::
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
call ClearScreen call ClearScreen
call UpdateSprites call UpdateSprites
callab DisplayOptionMenu callab DisplayOptionMenu

View file

@ -47,7 +47,7 @@ FadeInCreditsText:
DisplayCreditsMon: DisplayCreditsMon:
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
call SaveScreenTilesToBuffer1 call SaveScreenTilesToBuffer1
call FillMiddleOfScreenWithWhite call FillMiddleOfScreenWithWhite
@ -67,7 +67,7 @@ DisplayCreditsMon:
ld hl, vBGMap0 + $c ld hl, vBGMap0 + $c
call CreditsCopyTileMapToVRAM call CreditsCopyTileMapToVRAM
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
call LoadScreenTilesFromBuffer1 call LoadScreenTilesFromBuffer1
ld hl, vBGMap0 ld hl, vBGMap0
call CreditsCopyTileMapToVRAM call CreditsCopyTileMapToVRAM
@ -138,11 +138,11 @@ HoFGBPalettes:
CreditsCopyTileMapToVRAM: CreditsCopyTileMapToVRAM:
ld a, l ld a, l
ld [H_AUTOBGTRANSFERDEST], a ld [hAutoBGTransferDest], a
ld a, h ld a, h
ld [H_AUTOBGTRANSFERDEST + 1], a ld [hAutoBGTransferDest + 1], a
ld a, 1 ld a, 1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
jp Delay3 jp Delay3
ZeroMemory: ZeroMemory:

View file

@ -13,12 +13,12 @@ EvolveMon:
ld [wNewSoundID], a ld [wNewSoundID], a
call PlaySound call PlaySound
ld a, $1 ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ld a, SFX_TINK ld a, SFX_TINK
call PlaySound call PlaySound
call Delay3 call Delay3
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ld [hTilesetType], a ld [hTilesetType], a
ld a, [wEvoOldSpecies] ld a, [wEvoOldSpecies]
ld [wWholeScreenPaletteMonSpecies], a ld [wWholeScreenPaletteMonSpecies], a
@ -37,7 +37,7 @@ EvolveMon:
ld [wd0b5], a ld [wd0b5], a
call Evolution_LoadPic call Evolution_LoadPic
ld a, $1 ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ld a, [wEvoOldSpecies] ld a, [wEvoOldSpecies]
call PlayCry call PlayCry
call WaitForSoundToFinish call WaitForSoundToFinish
@ -117,7 +117,7 @@ Evolution_BackAndForthAnim:
Evolution_ChangeMonPic: Evolution_ChangeMonPic:
push bc push bc
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
coord hl, 7, 2 coord hl, 7, 2
lb bc, 7, 7 lb bc, 7, 7
ld de, SCREEN_WIDTH - 7 ld de, SCREEN_WIDTH - 7
@ -134,7 +134,7 @@ Evolution_ChangeMonPic:
dec b dec b
jr nz, .loop jr nz, .loop
ld a, 1 ld a, 1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
call Delay3 call Delay3
pop bc pop bc
ret ret

View file

@ -24,7 +24,7 @@ AnimateHallOfFame:
ld [wLetterPrintingDelayFlags], a ; no delay ld [wLetterPrintingDelayFlags], a ; no delay
ld [wHoFMonOrPlayer], a ; mon ld [wHoFMonOrPlayer], a ; mon
inc a inc a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ld hl, wNumHoFTeams ld hl, wNumHoFTeams
ld a, [hl] ld a, [hl]
inc a inc a

View file

@ -14,13 +14,13 @@ PlayIntro:
xor a xor a
ld [hJoyHeld], a ld [hJoyHeld], a
inc a inc a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
call PlayShootingStar call PlayShootingStar
call PlayIntroScene call PlayIntroScene
call GBFadeOutToWhite call GBFadeOutToWhite
xor a xor a
ld [hSCX], a ld [hSCX], a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
call ClearSprites call ClearSprites
call DelayFrame call DelayFrame
ret ret

View file

@ -104,12 +104,12 @@ OakSpeech:
ld hl, OakSpeechText3 ld hl, OakSpeechText3
call PrintText call PrintText
.next .next
ld a, [H_LOADEDROMBANK] ld a, [hLoadedROMBank]
push af push af
ld a, SFX_SHRINK ld a, SFX_SHRINK
call PlaySound call PlaySound
pop af pop af
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
ld c, 4 ld c, 4
call DelayFrames call DelayFrames
@ -126,7 +126,7 @@ OakSpeech:
lb bc, BANK(ShrinkPic2), $00 lb bc, BANK(ShrinkPic2), $00
call IntroDisplayPicCenteredOrUpperRight call IntroDisplayPicCenteredOrUpperRight
call ResetPlayerSpriteData call ResetPlayerSpriteData
ld a, [H_LOADEDROMBANK] ld a, [hLoadedROMBank]
push af push af
ld a, BANK(Music_PalletTown) ld a, BANK(Music_PalletTown)
ld [wAudioROMBank], a ld [wAudioROMBank], a
@ -137,7 +137,7 @@ OakSpeech:
ld [wNewSoundID], a ld [wNewSoundID], a
call PlaySound call PlaySound
pop af pop af
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
ld c, 20 ld c, 20
call DelayFrames call DelayFrames

View file

@ -107,7 +107,7 @@ OakSpeechSlidePicCommon:
ld e, l ld e, l
.loop .loop
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ld a, [hSlideDirection] ld a, [hSlideDirection]
and a and a
jr nz, .slideLeft jr nz, .slideLeft
@ -134,7 +134,7 @@ OakSpeechSlidePicCommon:
ld [hl], a ld [hl], a
.next3 .next3
ld a, 1 ld a, 1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
call Delay3 call Delay3
ld a, [hSlidingRegionSize] ld a, [hSlidingRegionSize]
ld c, a ld c, a

View file

@ -24,7 +24,7 @@ SetDefaultNamesBeforeTitlescreen::
DisplayTitleScreen: DisplayTitleScreen:
call GBPalWhiteOut call GBPalWhiteOut
ld a, $1 ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
xor a xor a
ld [hTilesetType], a ld [hTilesetType], a
ld [hSCX], a ld [hSCX], a
@ -239,7 +239,7 @@ ENDC
xor a xor a
ld [hWY], a ld [hWY], a
inc a inc a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
call ClearScreen call ClearScreen
ld a, vBGMap0 / $100 ld a, vBGMap0 / $100
call TitleScreenCopyTileMapToVRAM call TitleScreenCopyTileMapToVRAM
@ -358,7 +358,7 @@ LoadTitleMonSprite:
jp LoadFrontSpriteByMonIndex jp LoadFrontSpriteByMonIndex
TitleScreenCopyTileMapToVRAM: TitleScreenCopyTileMapToVRAM:
ld [H_AUTOBGTRANSFERDEST + 1], a ld [hAutoBGTransferDest + 1], a
jp Delay3 jp Delay3
LoadCopyrightAndTextBoxTiles: LoadCopyrightAndTextBoxTiles:

View file

@ -137,10 +137,10 @@ Trade_Delay100:
Trade_CopyTileMapToVRAM: Trade_CopyTileMapToVRAM:
ld a, $1 ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
call Delay3 call Delay3
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ret ret
Trade_Delay80: Trade_Delay80:
@ -184,7 +184,7 @@ LoadTradingGFXAndMonNames:
ld [rOBP0], a ld [rOBP0], a
call EnableLCD call EnableLCD
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ld a, [wTradedPlayerMonSpecies] ld a, [wTradedPlayerMonSpecies]
ld [wd11e], a ld [wd11e], a
call GetMonName call GetMonName
@ -231,7 +231,7 @@ Trade_ShowPlayerMon:
ld [rWX], a ld [rWX], a
ld [hSCX], a ld [hSCX], a
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
coord hl, 4, 0 coord hl, 4, 0
ld b, 6 ld b, 6
ld c, 10 ld c, 10
@ -261,7 +261,7 @@ Trade_ShowPlayerMon:
ld a, [wTradedPlayerMonSpecies] ld a, [wTradedPlayerMonSpecies]
call PlayCry call PlayCry
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ret ret
Trade_DrawOpenEndOfLinkCable: Trade_DrawOpenEndOfLinkCable:
@ -336,13 +336,13 @@ Trade_AnimateBallEnteringLinkCable:
.ballSpriteReachedEdgeOfScreen .ballSpriteReachedEdgeOfScreen
call ClearSprites call ClearSprites
ld a, $1 ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
call ClearScreen call ClearScreen
ld b, $98 ld b, $98
call CopyScreenTileBufferToVRAM call CopyScreenTileBufferToVRAM
call Delay3 call Delay3
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ret ret
Trade_BallInsideLinkCableOAM: Trade_BallInsideLinkCableOAM:
@ -360,13 +360,13 @@ Trade_ShowEnemyMon:
call Trade_PrintEnemyMonInfoText call Trade_PrintEnemyMonInfoText
call Trade_CopyTileMapToVRAM call Trade_CopyTileMapToVRAM
ld a, $1 ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ld a, [wTradedEnemyMonSpecies] ld a, [wTradedEnemyMonSpecies]
call Trade_LoadMonSprite call Trade_LoadMonSprite
ld a, TRADE_BALL_POOF_ANIM ld a, TRADE_BALL_POOF_ANIM
call Trade_ShowAnimation call Trade_ShowAnimation
ld a, $1 ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ld a, [wTradedEnemyMonSpecies] ld a, [wTradedEnemyMonSpecies]
call PlayCry call PlayCry
call Trade_Delay100 call Trade_Delay100
@ -397,7 +397,7 @@ Trade_AnimLeftToRight:
ld b, $6 ld b, $6
call Trade_AnimMonMoveHorizontal call Trade_AnimMonMoveHorizontal
ld a, $1 ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
call Trade_DrawCableAcrossScreen call Trade_DrawCableAcrossScreen
ld b, $4 ld b, $4
call Trade_AnimMonMoveHorizontal call Trade_AnimMonMoveHorizontal
@ -405,7 +405,7 @@ Trade_AnimLeftToRight:
ld b, $6 ld b, $6
call Trade_AnimMonMoveHorizontal call Trade_AnimMonMoveHorizontal
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
call Trade_AnimMonMoveVertical call Trade_AnimMonMoveVertical
jp ClearSprites jp ClearSprites
@ -430,7 +430,7 @@ Trade_AnimRightToLeft:
ld b, $6 ld b, $6
call Trade_AnimMonMoveHorizontal call Trade_AnimMonMoveHorizontal
ld a, $1 ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
call Trade_DrawCableAcrossScreen call Trade_DrawCableAcrossScreen
ld b, $4 ld b, $4
call Trade_AnimMonMoveHorizontal call Trade_AnimMonMoveHorizontal
@ -438,16 +438,16 @@ Trade_AnimRightToLeft:
ld b, $6 ld b, $6
call Trade_AnimMonMoveHorizontal call Trade_AnimMonMoveHorizontal
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
jp ClearSprites jp ClearSprites
Trade_InitGameboyTransferGfx: Trade_InitGameboyTransferGfx:
; Initialises the graphics for showing a mon moving between gameboys. ; Initialises the graphics for showing a mon moving between gameboys.
ld a, $1 ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
call ClearScreen call ClearScreen
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
call Trade_LoadMonPartySpriteGfx call Trade_LoadMonPartySpriteGfx
call DelayFrame call DelayFrame
ld a, %10101011 ld a, %10101011
@ -731,9 +731,9 @@ Trade_LoadMonSprite:
ld b, SET_PAL_POKEMON_WHOLE_SCREEN ld b, SET_PAL_POKEMON_WHOLE_SCREEN
ld c, 0 ld c, 0
call RunPaletteCommand call RunPaletteCommand
ld a, [H_AUTOBGTRANSFERENABLED] ld a, [hAutoBGTransferEnabled]
xor $1 xor $1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
call GetMonHeader call GetMonHeader
coord hl, 7, 2 coord hl, 7, 2
call LoadFlippedFrontSpriteByMonIndex call LoadFlippedFrontSpriteByMonIndex
@ -743,7 +743,7 @@ Trade_LoadMonSprite:
Trade_ShowClearedWindow: Trade_ShowClearedWindow:
; clears the window and covers the BG entirely with the window ; clears the window and covers the BG entirely with the window
ld a, $1 ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
call ClearScreen call ClearScreen
ld a, %11100011 ld a, %11100011
ld [rLCDC], a ld [rLCDC], a

View file

@ -66,7 +66,7 @@ PalletMovementScript_OakMoveLeft:
call FillMemory call FillMemory
ld [hl], $ff ld [hl], $ff
ld a, [wSpriteIndex] ld a, [wSpriteIndex]
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
ld de, wNPCMovementDirections2 ld de, wNPCMovementDirections2
call MoveSprite call MoveSprite
ld a, $1 ld a, $1
@ -282,7 +282,7 @@ FreezeEnemyTrainerSprite::
jr .loop jr .loop
.notRival .notRival
ld a, [wSpriteIndex] ld a, [wSpriteIndex]
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
jp SetSpriteMovementBytesToFF jp SetSpriteMovementBytesToFF
RivalIDs: RivalIDs:

View file

@ -3,7 +3,7 @@ ClearVariablesOnEnterMap::
ld [hWY], a ld [hWY], a
ld [rWY], a ld [rWY], a
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ld [wStepCounter], a ld [wStepCounter], a
ld [wLoneAttackNo], a ld [wLoneAttackNo], a
ld [hJoyPressed], a ld [hJoyPressed], a

View file

@ -31,19 +31,19 @@ LoadMissableObjects:
sub d sub d
ld h, a ld h, a
ld a, h ld a, h
ld [H_DIVIDEND], a ld [hDividend], a
ld a, l ld a, l
ld [H_DIVIDEND+1], a ld [hDividend+1], a
xor a xor a
ld [H_DIVIDEND+2], a ld [hDividend+2], a
ld [H_DIVIDEND+3], a ld [hDividend+3], a
ld a, $3 ld a, $3
ld [H_DIVISOR], a ld [hDivisor], a
ld b, $2 ld b, $2
call Divide ; divide difference by 3, resulting in the global offset (number of missable items before ours) call Divide ; divide difference by 3, resulting in the global offset (number of missable items before ours)
ld a, [wCurMap] ld a, [wCurMap]
ld b, a ld b, a
ld a, [H_DIVIDEND+3] ld a, [hDividend+3]
ld c, a ; store global offset in c ld c, a ; store global offset in c
ld de, wMissableObjectList ld de, wMissableObjectList
pop hl pop hl
@ -99,7 +99,7 @@ InitializeMissableObjectsFlags:
; tests if current sprite is a missable object that is hidden/has been removed ; tests if current sprite is a missable object that is hidden/has been removed
IsObjectHidden: IsObjectHidden:
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
swap a swap a
ld b, a ld b, a
ld hl, wMissableObjectList ld hl, wMissableObjectList

View file

@ -63,7 +63,7 @@ UpdatePlayerSprite:
ld a, [wd736] ld a, [wd736]
bit 7, a ; is the player sprite spinning due to a spin tile? bit 7, a ; is the player sprite spinning due to a spin tile?
jr nz, .skipSpriteAnim jr nz, .skipSpriteAnim
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $7 add $7
ld l, a ld l, a
ld a, [hl] ld a, [hl]
@ -103,7 +103,7 @@ UpdatePlayerSprite:
UnusedReadSpriteDataFunction: UnusedReadSpriteDataFunction:
push bc push bc
push af push af
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
ld c, a ld c, a
pop af pop af
add c add c
@ -112,7 +112,7 @@ UnusedReadSpriteDataFunction:
ret ret
UpdateNPCSprite: UpdateNPCSprite:
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
swap a swap a
dec a dec a
add a add a
@ -122,7 +122,7 @@ UpdateNPCSprite:
ld a, [hl] ; read movement byte 2 ld a, [hl] ; read movement byte 2
ld [wCurSpriteMovement2], a ld [wCurSpriteMovement2], a
ld h, $c1 ld h, $c1
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
ld l, a ld l, a
inc l inc l
ld a, [hl] ; c1x1 ld a, [hl] ; c1x1
@ -131,7 +131,7 @@ UpdateNPCSprite:
call CheckSpriteAvailability call CheckSpriteAvailability
ret c ; if sprite is invisible, on tile >=MAP_TILESET_SIZE, in grass or player is currently walking ret c ; if sprite is invisible, on tile >=MAP_TILESET_SIZE, in grass or player is currently walking
ld h, $c1 ld h, $c1
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
ld l, a ld l, a
inc l inc l
ld a, [hl] ; c1x1 ld a, [hl] ; c1x1
@ -151,7 +151,7 @@ UpdateNPCSprite:
ret nz ; don't do anything yet if player is currently moving (redundant, already tested in CheckSpriteAvailability) ret nz ; don't do anything yet if player is currently moving (redundant, already tested in CheckSpriteAvailability)
call InitializeSpriteScreenPosition call InitializeSpriteScreenPosition
ld h, $c2 ld h, $c2
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $6 add $6
ld l, a ld l, a
ld a, [hl] ; c2x6: movement byte 1 ld a, [hl] ; c2x6: movement byte 1
@ -264,11 +264,11 @@ ChangeFacingDirection:
TryWalking: TryWalking:
push hl push hl
ld h, $c1 ld h, $c1
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $9 add $9
ld l, a ld l, a
ld [hl], c ; c1x9 (update facing direction) ld [hl], c ; c1x9 (update facing direction)
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $3 add $3
ld l, a ld l, a
ld [hl], d ; c1x3 (update Y movement delta) ld [hl], d ; c1x3 (update Y movement delta)
@ -282,7 +282,7 @@ TryWalking:
pop de pop de
ret c ; cannot walk there (reinitialization of delay values already done) ret c ; cannot walk there (reinitialization of delay values already done)
ld h, $c2 ld h, $c2
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $4 add $4
ld l, a ld l, a
ld a, [hl] ; c2x4: Y position ld a, [hl] ; c2x4: Y position
@ -291,7 +291,7 @@ TryWalking:
ld a, [hl] ; c2x5: X position ld a, [hl] ; c2x5: X position
add e add e
ld [hl], a ; update X position ld [hl], a ; update X position
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
ld l, a ld l, a
ld [hl], $10 ; c2x0=16: walk animation counter ld [hl], $10 ; c2x0=16: walk animation counter
dec h dec h
@ -301,7 +301,7 @@ TryWalking:
; update the walking animation parameters for a sprite that is currently walking ; update the walking animation parameters for a sprite that is currently walking
UpdateSpriteInWalkingAnimation: UpdateSpriteInWalkingAnimation:
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $7 add $7
ld l, a ld l, a
ld a, [hl] ; c1x7 (counter until next walk animation frame) ld a, [hl] ; c1x7 (counter until next walk animation frame)
@ -317,7 +317,7 @@ UpdateSpriteInWalkingAnimation:
and $3 and $3
ld [hl], a ; advance to next animation frame every 4 ticks (16 ticks total for one step) ld [hl], a ; advance to next animation frame every 4 ticks (16 ticks total for one step)
.noNextAnimationFrame .noNextAnimationFrame
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $3 add $3
ld l, a ld l, a
ld a, [hli] ; c1x3 (movement Y delta) ld a, [hli] ; c1x3 (movement Y delta)
@ -330,7 +330,7 @@ UpdateSpriteInWalkingAnimation:
ld a, [hl] ; c1x6 (screen X position) ld a, [hl] ; c1x6 (screen X position)
add b add b
ld [hl], a ; update screen X position ld [hl], a ; update screen X position
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
ld l, a ld l, a
inc h inc h
ld a, [hl] ; c2x0 (walk animation counter) ld a, [hl] ; c2x0 (walk animation counter)
@ -343,7 +343,7 @@ UpdateSpriteInWalkingAnimation:
ld a, [hl] ; c2x6 (movement byte 1) ld a, [hl] ; c2x6 (movement byte 1)
cp $fe cp $fe
jr nc, .initNextMovementCounter ; values $fe and $ff jr nc, .initNextMovementCounter ; values $fe and $ff
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
inc a inc a
ld l, a ld l, a
dec h dec h
@ -351,14 +351,14 @@ UpdateSpriteInWalkingAnimation:
ret ret
.initNextMovementCounter .initNextMovementCounter
call Random call Random
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $8 add $8
ld l, a ld l, a
ld a, [hRandomAdd] ld a, [hRandomAdd]
and $7f and $7f
ld [hl], a ; c2x8: set next movement delay to a random value in [0,$7f] ld [hl], a ; c2x8: set next movement delay to a random value in [0,$7f]
dec h ; note that value 0 actually makes the delay $100 (bug?) dec h ; note that value 0 actually makes the delay $100 (bug?)
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
inc a inc a
ld l, a ld l, a
ld [hl], $2 ; c1x1 = 2 (movement status) ld [hl], $2 ; c1x1 = 2 (movement status)
@ -375,7 +375,7 @@ UpdateSpriteInWalkingAnimation:
; update delay value (c2x8) for sprites in the delayed state (c1x1) ; update delay value (c2x8) for sprites in the delayed state (c1x1)
UpdateSpriteMovementDelay: UpdateSpriteMovementDelay:
ld h, $c2 ld h, $c2
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $6 add $6
ld l, a ld l, a
ld a, [hl] ; c2x6: movement byte 1 ld a, [hl] ; c2x6: movement byte 1
@ -390,13 +390,13 @@ UpdateSpriteMovementDelay:
jr nz, notYetMoving jr nz, notYetMoving
.moving .moving
dec h dec h
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
inc a inc a
ld l, a ld l, a
ld [hl], $1 ; c1x1 = 1 (mark as ready to move) ld [hl], $1 ; c1x1 = 1 (mark as ready to move)
notYetMoving: notYetMoving:
ld h, wSpriteStateData1 / $100 ld h, wSpriteStateData1 / $100
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $8 add $8
ld l, a ld l, a
ld [hl], $0 ; c1x8 = 0 (walk animation frame) ld [hl], $0 ; c1x8 = 0 (walk animation frame)
@ -429,7 +429,7 @@ MakeNPCFacePlayer:
.notFacingRight .notFacingRight
ld c, SPRITE_FACING_LEFT ld c, SPRITE_FACING_LEFT
.facingDirectionDetermined .facingDirectionDetermined
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $9 add $9
ld l, a ld l, a
ld [hl], c ; c1x9: set facing direction ld [hl], c ; c1x9: set facing direction
@ -440,7 +440,7 @@ InitializeSpriteStatus:
inc l inc l
ld [hl], $ff ; $c1x2: set sprite image to $ff (invisible/off screen) ld [hl], $ff ; $c1x2: set sprite image to $ff (invisible/off screen)
inc h inc h
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $2 add $2
ld l, a ld l, a
ld a, $8 ld a, $8
@ -451,7 +451,7 @@ InitializeSpriteStatus:
; calculates the sprite's screen position form its map position and the player position ; calculates the sprite's screen position form its map position and the player position
InitializeSpriteScreenPosition: InitializeSpriteScreenPosition:
ld h, wSpriteStateData2 / $100 ld h, wSpriteStateData2 / $100
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $4 add $4
ld l, a ld l, a
ld a, [wYCoord] ld a, [wYCoord]
@ -479,13 +479,13 @@ CheckSpriteAvailability:
and a and a
jp nz, .spriteInvisible jp nz, .spriteInvisible
ld h, wSpriteStateData2 / $100 ld h, wSpriteStateData2 / $100
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $6 add $6
ld l, a ld l, a
ld a, [hl] ; c2x6: movement byte 1 ld a, [hl] ; c2x6: movement byte 1
cp $fe cp $fe
jr c, .skipXVisibilityTest ; movement byte 1 < $fe (i.e. the sprite's movement is scripted) jr c, .skipXVisibilityTest ; movement byte 1 < $fe (i.e. the sprite's movement is scripted)
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $4 add $4
ld l, a ld l, a
ld b, [hl] ; c2x4: Y pos (+4) ld b, [hl] ; c2x4: Y pos (+4)
@ -527,7 +527,7 @@ CheckSpriteAvailability:
jr c, .spriteVisible ; standing on tile with ID >=MAP_TILESET_SIZE (top right tile) jr c, .spriteVisible ; standing on tile with ID >=MAP_TILESET_SIZE (top right tile)
.spriteInvisible .spriteInvisible
ld h, wSpriteStateData1 / $100 ld h, wSpriteStateData1 / $100
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $2 add $2
ld l, a ld l, a
ld [hl], $ff ; c1x2 ld [hl], $ff ; c1x2
@ -540,7 +540,7 @@ CheckSpriteAvailability:
jr nz, .done ; if player is currently walking, we're done jr nz, .done ; if player is currently walking, we're done
call UpdateSpriteImage call UpdateSpriteImage
inc h inc h
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $7 add $7
ld l, a ld l, a
ld a, [wGrassTile] ld a, [wGrassTile]
@ -556,7 +556,7 @@ CheckSpriteAvailability:
UpdateSpriteImage: UpdateSpriteImage:
ld h, $c1 ld h, $c1
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $8 add $8
ld l, a ld l, a
ld a, [hli] ; c1x8: walk animation frame ld a, [hli] ; c1x8: walk animation frame
@ -567,7 +567,7 @@ UpdateSpriteImage:
ld a, [$ff93] ; current sprite offset ld a, [$ff93] ; current sprite offset
add b add b
ld b, a ld b, a
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $2 add $2
ld l, a ld l, a
ld [hl], b ; c1x2: sprite to display ld [hl], b ; c1x2: sprite to display
@ -581,7 +581,7 @@ UpdateSpriteImage:
; set carry on failure, clears carry on success ; set carry on failure, clears carry on success
CanWalkOntoTile: CanWalkOntoTile:
ld h, wSpriteStateData2 / $100 ld h, wSpriteStateData2 / $100
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $6 add $6
ld l, a ld l, a
ld a, [hl] ; c2x6 (movement byte 1) ld a, [hl] ; c2x6 (movement byte 1)
@ -602,14 +602,14 @@ CanWalkOntoTile:
cp c cp c
jr nz, .tilePassableLoop jr nz, .tilePassableLoop
ld h, $c2 ld h, $c2
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $6 add $6
ld l, a ld l, a
ld a, [hl] ; $c2x6 (movement byte 1) ld a, [hl] ; $c2x6 (movement byte 1)
inc a inc a
jr z, .impassable ; if $ff, no movement allowed (however, changing direction is) jr z, .impassable ; if $ff, no movement allowed (however, changing direction is)
ld h, wSpriteStateData1 / $100 ld h, wSpriteStateData1 / $100
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $4 add $4
ld l, a ld l, a
ld a, [hli] ; c1x4 (screen Y pos) ld a, [hli] ; c1x4 (screen Y pos)
@ -628,14 +628,14 @@ CanWalkOntoTile:
pop bc pop bc
pop de pop de
ld h, wSpriteStateData1 / $100 ld h, wSpriteStateData1 / $100
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $c add $c
ld l, a ld l, a
ld a, [hl] ; c1xc (directions in which sprite collision would occur) ld a, [hl] ; c1xc (directions in which sprite collision would occur)
and b ; check against chosen direction (1,2,4 or 8) and b ; check against chosen direction (1,2,4 or 8)
jr nz, .impassable ; collision between sprites, don't go there jr nz, .impassable ; collision between sprites, don't go there
ld h, wSpriteStateData2 / $100 ld h, wSpriteStateData2 / $100
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $2 add $2
ld l, a ld l, a
ld a, [hli] ; c2x2 (sprite Y displacement, initialized at $8, keep track of where a sprite did go) ld a, [hli] ; c2x2 (sprite Y displacement, initialized at $8, keep track of where a sprite did go)
@ -666,7 +666,7 @@ CanWalkOntoTile:
ret ret
.impassable .impassable
ld h, $c1 ld h, $c1
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
inc a inc a
ld l, a ld l, a
ld [hl], $2 ; c1x1 = 2 (set movement status to delayed) ld [hl], $2 ; c1x1 = 2 (set movement status to delayed)
@ -677,7 +677,7 @@ CanWalkOntoTile:
inc l inc l
ld [hl], a ; c1x5 = 0 (clear X movement delta) ld [hl], a ; c1x5 = 0 (clear X movement delta)
inc h inc h
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $8 add $8
ld l, a ld l, a
call Random call Random
@ -692,7 +692,7 @@ CanWalkOntoTile:
; hl: output pointer ; hl: output pointer
GetTileSpriteStandsOn: GetTileSpriteStandsOn:
ld h, wSpriteStateData1 / $100 ld h, wSpriteStateData1 / $100
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $4 add $4
ld l, a ld l, a
ld a, [hli] ; c1x4: screen Y position ld a, [hli] ; c1x4: screen Y position
@ -784,7 +784,7 @@ DoScriptedNPCMovement:
ld a, [hl] ld a, [hl]
add b add b
ld [hl], a ld [hl], a
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $9 add $9
ld l, a ld l, a
ld a, c ld a, c
@ -817,7 +817,7 @@ GetSpriteScreenXPointer:
GetSpriteScreenXYPointerCommon: GetSpriteScreenXYPointerCommon:
ld hl, wSpriteStateData1 ld hl, wSpriteStateData1
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add l add l
add b add b
ld l, a ld l, a
@ -825,7 +825,7 @@ GetSpriteScreenXYPointerCommon:
AnimScriptedNPCMovement: AnimScriptedNPCMovement:
ld hl, wSpriteStateData2 ld hl, wSpriteStateData2
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $e add $e
ld l, a ld l, a
ld a, [hl] ; VRAM slot ld a, [hl] ; VRAM slot
@ -833,7 +833,7 @@ AnimScriptedNPCMovement:
swap a swap a
ld b, a ld b, a
ld hl, wSpriteStateData1 ld hl, wSpriteStateData1
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $9 add $9
ld l, a ld l, a
ld a, [hl] ; facing direction ld a, [hl] ; facing direction
@ -852,7 +852,7 @@ AnimScriptedNPCMovement:
ld [hSpriteVRAMSlotAndFacing], a ld [hSpriteVRAMSlotAndFacing], a
call AdvanceScriptedNPCAnimFrameCounter call AdvanceScriptedNPCAnimFrameCounter
ld hl, wSpriteStateData1 ld hl, wSpriteStateData1
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $2 add $2
ld l, a ld l, a
ld a, [hSpriteVRAMSlotAndFacing] ld a, [hSpriteVRAMSlotAndFacing]
@ -863,7 +863,7 @@ AnimScriptedNPCMovement:
ret ret
AdvanceScriptedNPCAnimFrameCounter: AdvanceScriptedNPCAnimFrameCounter:
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $7 add $7
ld l, a ld l, a
ld a, [hl] ; intra-animation frame counter ld a, [hl] ; intra-animation frame counter

View file

@ -92,7 +92,7 @@ DoBoulderDustAnimation::
call ResetBoulderPushFlags call ResetBoulderPushFlags
set 7, [hl] set 7, [hl]
ld a, [wBoulderSpriteIndex] ld a, [wBoulderSpriteIndex]
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call GetSpriteMovementByte2Pointer call GetSpriteMovementByte2Pointer
ld [hl], $10 ld [hl], $10
ld a, SFX_CUT ld a, SFX_CUT

View file

@ -6,7 +6,7 @@ _UpdateSprites::
ld l, a ld l, a
sub $e sub $e
ld c, a ld c, a
ld [H_CURRENTSPRITEOFFSET], a ld [hCurrentSpriteOffset], a
ld a, [hl] ld a, [hl]
and a and a
jr z, .skipSprite ; tests $c2Xe jr z, .skipSprite ; tests $c2Xe
@ -34,14 +34,14 @@ UpdateNonPlayerSprite:
ld [$ff93], a ; $10 * sprite# ld [$ff93], a ; $10 * sprite#
ld a, [wNPCMovementScriptSpriteOffset] ; some sprite offset? ld a, [wNPCMovementScriptSpriteOffset] ; some sprite offset?
ld b, a ld b, a
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
cp b cp b
jr nz, .unequal jr nz, .unequal
jp DoScriptedNPCMovement jp DoScriptedNPCMovement
.unequal .unequal
jp UpdateNPCSprite jp UpdateNPCSprite
; This detects if the current sprite (whose offset is at H_CURRENTSPRITEOFFSET) ; This detects if the current sprite (whose offset is at hCurrentSpriteOffset)
; is going to collide with another sprite by looping over the other sprites. ; is going to collide with another sprite by looping over the other sprites.
; The current sprite's offset will be labelled with i (e.g. $c1i0). ; The current sprite's offset will be labelled with i (e.g. $c1i0).
; The loop sprite's offset will labelled with j (e.g. $c1j0). ; The loop sprite's offset will labelled with j (e.g. $c1j0).
@ -54,7 +54,7 @@ DetectCollisionBetweenSprites:
nop nop
ld h, wSpriteStateData1 / $100 ld h, wSpriteStateData1 / $100
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add wSpriteStateData1 % $100 add wSpriteStateData1 % $100
ld l, a ld l, a
@ -113,7 +113,7 @@ DetectCollisionBetweenSprites:
ld [$ff8f], a ; store loop counter ld [$ff8f], a ; store loop counter
swap a swap a
ld e, a ld e, a
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
cp e ; does the loop sprite match the current sprite? cp e ; does the loop sprite match the current sprite?
jp z, .next ; go to the next sprite if they match jp z, .next ; go to the next sprite if they match
@ -128,7 +128,7 @@ DetectCollisionBetweenSprites:
inc a inc a
jp z, .next ; go the next sprite if offscreen jp z, .next ; go the next sprite if offscreen
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add 10 add 10
ld l, a ld l, a

View file

@ -2,7 +2,7 @@ _GetSpritePosition1::
ld hl, wSpriteStateData1 ld hl, wSpriteStateData1
ld de, $4 ld de, $4
ld a, [wSpriteIndex] ld a, [wSpriteIndex]
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call GetSpriteDataPointer call GetSpriteDataPointer
ld a, [hli] ; c1x4 (screen Y pos) ld a, [hli] ; c1x4 (screen Y pos)
ld [$ffeb], a ld [$ffeb], a
@ -21,7 +21,7 @@ _GetSpritePosition2::
ld hl, wSpriteStateData1 ld hl, wSpriteStateData1
ld de, $4 ld de, $4
ld a, [wSpriteIndex] ld a, [wSpriteIndex]
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call GetSpriteDataPointer call GetSpriteDataPointer
ld a, [hli] ; c1x4 (screen Y pos) ld a, [hli] ; c1x4 (screen Y pos)
ld [wSavedSpriteScreenY], a ld [wSavedSpriteScreenY], a
@ -40,7 +40,7 @@ _SetSpritePosition1::
ld hl, wSpriteStateData1 ld hl, wSpriteStateData1
ld de, $4 ld de, $4
ld a, [wSpriteIndex] ld a, [wSpriteIndex]
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call GetSpriteDataPointer call GetSpriteDataPointer
ld a, [$ffeb] ; c1x4 (screen Y pos) ld a, [$ffeb] ; c1x4 (screen Y pos)
ld [hli], a ld [hli], a
@ -59,7 +59,7 @@ _SetSpritePosition2::
ld hl, wSpriteStateData1 ld hl, wSpriteStateData1
ld de, 4 ld de, 4
ld a, [wSpriteIndex] ld a, [wSpriteIndex]
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call GetSpriteDataPointer call GetSpriteDataPointer
ld a, [wSavedSpriteScreenY] ld a, [wSavedSpriteScreenY]
ld [hli], a ; c1x4 (screen Y pos) ld [hli], a ; c1x4 (screen Y pos)
@ -144,7 +144,7 @@ TrainerWalkUpToPlayer::
call FillMemory ; write the necessary steps to reach player call FillMemory ; write the necessary steps to reach player
ld [hl], $ff ; write end of list sentinel ld [hl], $ff ; write end of list sentinel
ld a, [wSpriteIndex] ld a, [wSpriteIndex]
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
jp MoveSprite_ jp MoveSprite_
; input: de = offset within sprite entry ; input: de = offset within sprite entry
@ -152,7 +152,7 @@ TrainerWalkUpToPlayer::
GetSpriteDataPointer: GetSpriteDataPointer:
push de push de
add hl, de add hl, de
ld a, [H_SPRITEINDEX] ld a, [hSpriteIndex]
swap a swap a
ld d, $0 ld d, $0
ld e, a ld e, a

View file

@ -1,12 +1,12 @@
UpdateSpriteFacingOffsetAndDelayMovement:: UpdateSpriteFacingOffsetAndDelayMovement::
ld h, $c2 ld h, $c2
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $8 add $8
ld l, a ld l, a
ld a, $7f ; maximum movement delay ld a, $7f ; maximum movement delay
ld [hl], a ; c2x8 (movement delay) ld [hl], a ; c2x8 (movement delay)
dec h dec h
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $9 add $9
ld l, a ld l, a
ld a, [hld] ; c1x9 (facing direction) ld a, [hld] ; c1x9 (facing direction)
@ -14,7 +14,7 @@ UpdateSpriteFacingOffsetAndDelayMovement::
xor a xor a
ld [hld], a ld [hld], a
ld [hl], a ; c1x8 (walk animation frame) ld [hl], a ; c1x8 (walk animation frame)
ld a, [H_CURRENTSPRITEOFFSET] ld a, [hCurrentSpriteOffset]
add $2 add $2
ld l, a ld l, a
ld a, [hl] ; c1x2 (facing and animation table offset) ld a, [hl] ; c1x2 (facing and animation table offset)

View file

@ -50,12 +50,12 @@ RedrawMapView:
ld a, [wIsInBattle] ld a, [wIsInBattle]
inc a inc a
ret z ret z
ld a, [H_AUTOBGTRANSFERENABLED] ld a, [hAutoBGTransferEnabled]
push af push af
ld a, [hTilesetType] ld a, [hTilesetType]
push af push af
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ld [hTilesetType], a ; no flower/water BG tile animations ld [hTilesetType], a ; no flower/water BG tile animations
call LoadCurrentMapView call LoadCurrentMapView
call RunDefaultPaletteCommand call RunDefaultPaletteCommand
@ -114,7 +114,7 @@ RedrawMapView:
pop af pop af
ld [hTilesetType], a ld [hTilesetType], a
pop af pop af
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ret ret
CompareHLWithBC: CompareHLWithBC:

View file

@ -129,10 +129,10 @@ _AddPartyMon::
xor a xor a
ld b, a ld b, a
call CalcStat ; calc HP stat (set cur Hp to max HP) call CalcStat ; calc HP stat (set cur Hp to max HP)
ld a, [H_MULTIPLICAND+1] ld a, [hMultiplicand+1]
ld [de], a ld [de], a
inc de inc de
ld a, [H_MULTIPLICAND+2] ld a, [hMultiplicand+2]
ld [de], a ld [de], a
inc de inc de
xor a xor a

View file

@ -1,6 +1,6 @@
DisplayPCMainMenu:: DisplayPCMainMenu::
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
call SaveScreenTilesToBuffer2 call SaveScreenTilesToBuffer2
ld a, [wNumHoFTeams] ld a, [wNumHoFTeams]
and a and a
@ -82,7 +82,7 @@ DisplayPCMainMenu::
ld [wCurrentMenuItem], a ld [wCurrentMenuItem], a
ld [wLastMenuItem], a ld [wLastMenuItem], a
ld a, 1 ld a, 1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ret ret
SomeonesPCText: db "SOMEONE's PC@" SomeonesPCText: db "SOMEONE's PC@"
@ -168,7 +168,7 @@ BillsPCMenu:
ld de, BoxNoPCText ld de, BoxNoPCText
call PlaceString call PlaceString
ld a, 1 ld a, 1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
call Delay3 call Delay3
call HandleMenuInput call HandleMenuInput
bit 1, a bit 1, a

View file

@ -120,12 +120,12 @@ Evolution_PartyMonLoop: ; loop over party mons
ld c, 50 ld c, 50
call DelayFrames call DelayFrames
xor a xor a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
coord hl, 0, 0 coord hl, 0, 0
lb bc, 12, 20 lb bc, 12, 20
call ClearScreenArea call ClearScreenArea
ld a, $1 ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ld a, $ff ld a, $ff
ld [wUpdateSpritesEnabled], a ld [wUpdateSpritesEnabled], a
call ClearSprites call ClearSprites

View file

@ -38,58 +38,58 @@ CalcExperience::
add hl, bc add hl, bc
call CalcDSquared call CalcDSquared
ld a, d ld a, d
ld [H_MULTIPLIER], a ld [hMultiplier], a
call Multiply call Multiply
ld a, [hl] ld a, [hl]
and $f0 and $f0
swap a swap a
ld [H_MULTIPLIER], a ld [hMultiplier], a
call Multiply call Multiply
ld a, [hli] ld a, [hli]
and $f and $f
ld [H_DIVISOR], a ld [hDivisor], a
ld b, $4 ld b, $4
call Divide call Divide
ld a, [H_QUOTIENT + 1] ld a, [hQuotient + 1]
push af push af
ld a, [H_QUOTIENT + 2] ld a, [hQuotient + 2]
push af push af
ld a, [H_QUOTIENT + 3] ld a, [hQuotient + 3]
push af push af
call CalcDSquared call CalcDSquared
ld a, [hl] ld a, [hl]
and $7f and $7f
ld [H_MULTIPLIER], a ld [hMultiplier], a
call Multiply call Multiply
ld a, [H_PRODUCT + 1] ld a, [hProduct + 1]
push af push af
ld a, [H_PRODUCT + 2] ld a, [hProduct + 2]
push af push af
ld a, [H_PRODUCT + 3] ld a, [hProduct + 3]
push af push af
ld a, [hli] ld a, [hli]
push af push af
xor a xor a
ld [H_MULTIPLICAND], a ld [hMultiplicand], a
ld [H_MULTIPLICAND + 1], a ld [hMultiplicand + 1], a
ld a, d ld a, d
ld [H_MULTIPLICAND + 2], a ld [hMultiplicand + 2], a
ld a, [hli] ld a, [hli]
ld [H_MULTIPLIER], a ld [hMultiplier], a
call Multiply call Multiply
ld b, [hl] ld b, [hl]
ld a, [H_PRODUCT + 3] ld a, [hProduct + 3]
sub b sub b
ld [H_PRODUCT + 3], a ld [hProduct + 3], a
ld b, $0 ld b, $0
ld a, [H_PRODUCT + 2] ld a, [hProduct + 2]
sbc b sbc b
ld [H_PRODUCT + 2], a ld [hProduct + 2], a
ld a, [H_PRODUCT + 1] ld a, [hProduct + 1]
sbc b sbc b
ld [H_PRODUCT + 1], a ld [hProduct + 1], a
; The difference of the linear term and the constant term consists of 3 bytes ; The difference of the linear term and the constant term consists of 3 bytes
; starting at H_PRODUCT + 1. Below, hExperience (an alias of that address) will ; starting at hProduct + 1. Below, hExperience (an alias of that address) will
; be used instead for the further work of adding or subtracting the squared ; be used instead for the further work of adding or subtracting the squared
; term and adding the cubed term. ; term and adding the cubed term.
pop af pop af
@ -139,11 +139,11 @@ CalcExperience::
; calculates d*d ; calculates d*d
CalcDSquared: CalcDSquared:
xor a xor a
ld [H_MULTIPLICAND], a ld [hMultiplicand], a
ld [H_MULTIPLICAND + 1], a ld [hMultiplicand + 1], a
ld a, d ld a, d
ld [H_MULTIPLICAND + 2], a ld [hMultiplicand + 2], a
ld [H_MULTIPLIER], a ld [hMultiplier], a
jp Multiply jp Multiply
INCLUDE "data/growth_rates.asm" INCLUDE "data/growth_rates.asm"

View file

@ -126,13 +126,13 @@ TryingToLearn:
call TextBoxBorder call TextBoxBorder
coord hl, 6, 8 coord hl, 6, 8
ld de, wMovesString ld de, wMovesString
ld a, [hFlags_0xFFF6] ld a, [hFlagsFFF6]
set 2, a set 2, a
ld [hFlags_0xFFF6], a ld [hFlagsFFF6], a
call PlaceString call PlaceString
ld a, [hFlags_0xFFF6] ld a, [hFlagsFFF6]
res 2, a res 2, a
ld [hFlags_0xFFF6], a ld [hFlagsFFF6], a
ld hl, wTopMenuItemY ld hl, wTopMenuItemY
ld a, 8 ld a, 8
ld [hli], a ; wTopMenuItemY ld [hli], a ; wTopMenuItemY
@ -146,10 +146,10 @@ TryingToLearn:
ld a, A_BUTTON | B_BUTTON ld a, A_BUTTON | B_BUTTON
ld [hli], a ; wMenuWatchedKeys ld [hli], a ; wMenuWatchedKeys
ld [hl], 0 ; wLastMenuItem ld [hl], 0 ; wLastMenuItem
ld hl, hFlags_0xFFF6 ld hl, hFlagsFFF6
set 1, [hl] set 1, [hl]
call HandleMenuInput call HandleMenuInput
ld hl, hFlags_0xFFF6 ld hl, hFlagsFFF6
res 1, [hl] res 1, [hl]
push af push af
call LoadScreenTilesFromBuffer1 call LoadScreenTilesFromBuffer1

View file

@ -40,7 +40,7 @@ DrawHP_:
push hl push hl
call DrawHPBar call DrawHPBar
pop hl pop hl
ld a, [hFlags_0xFFF6] ld a, [hFlagsFFF6]
bit 0, a bit 0, a
jr z, .printFractionBelowBar jr z, .printFractionBelowBar
ld bc, $9 ; right of bar ld bc, $9 ; right of bar
@ -299,7 +299,7 @@ StatusScreen2:
push af push af
xor a xor a
ld [hTilesetType], a ld [hTilesetType], a
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ld bc, NUM_MOVES + 1 ld bc, NUM_MOVES + 1
ld hl, wMoves ld hl, wMoves
call FillMemory call FillMemory
@ -424,7 +424,7 @@ StatusScreen2:
coord hl, 9, 1 coord hl, 9, 1
call PlaceString call PlaceString
ld a, $1 ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
call Delay3 call Delay3
call WaitForTextScrollButtonPress ; wait for button call WaitForTextScrollButtonPress ; wait for button
pop af pop af

View file

@ -22,7 +22,7 @@ StartSlotMachine:
ld a, 250 ld a, 250
.next .next
ld [wSlotMachineSevenAndBarModeChance], a ld [wSlotMachineSevenAndBarModeChance], a
ld a, [H_LOADEDROMBANK] ld a, [hLoadedROMBank]
ld [wSlotMachineSavedROMBank], a ld [wSlotMachineSavedROMBank], a
call PromptUserToPlaySlots call PromptUserToPlaySlots
ret ret

432
home.asm

File diff suppressed because it is too large Load diff

View file

@ -170,10 +170,10 @@ PlaySound::
.noFadeOut .noFadeOut
xor a xor a
ld [wNewSoundID], a ld [wNewSoundID], a
ld a, [H_LOADEDROMBANK] ld a, [hLoadedROMBank]
ld [hSavedROMBank], a ld [hSavedROMBank], a
ld a, [wAudioROMBank] ld a, [wAudioROMBank]
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
cp BANK(Audio1_PlaySound) cp BANK(Audio1_PlaySound)
jr nz, .checkForAudio2 jr nz, .checkForAudio2
@ -198,7 +198,7 @@ PlaySound::
.next2 .next2
ld a, [hSavedROMBank] ld a, [hSavedROMBank]
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
jr .done jr .done

View file

@ -1,14 +1,14 @@
FarCopyData:: FarCopyData::
; Copy bc bytes from a:hl to de. ; Copy bc bytes from a:hl to de.
ld [wBuffer], a ld [wBuffer], a
ld a, [H_LOADEDROMBANK] ld a, [hLoadedROMBank]
push af push af
ld a, [wBuffer] ld a, [wBuffer]
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
call CopyData call CopyData
pop af pop af
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
ret ret

View file

@ -2,24 +2,24 @@ FarCopyData2::
; Identical to FarCopyData, but uses hROMBankTemp ; Identical to FarCopyData, but uses hROMBankTemp
; as temp space instead of wBuffer. ; as temp space instead of wBuffer.
ld [hROMBankTemp], a ld [hROMBankTemp], a
ld a, [H_LOADEDROMBANK] ld a, [hLoadedROMBank]
push af push af
ld a, [hROMBankTemp] ld a, [hROMBankTemp]
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
call CopyData call CopyData
pop af pop af
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
ret ret
FarCopyData3:: FarCopyData3::
; Copy bc bytes from a:de to hl. ; Copy bc bytes from a:de to hl.
ld [hROMBankTemp], a ld [hROMBankTemp], a
ld a, [H_LOADEDROMBANK] ld a, [hLoadedROMBank]
push af push af
ld a, [hROMBankTemp] ld a, [hROMBankTemp]
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
push hl push hl
push de push de
@ -31,7 +31,7 @@ FarCopyData3::
pop de pop de
pop hl pop hl
pop af pop af
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
ret ret
@ -39,10 +39,10 @@ FarCopyDataDouble::
; Expand bc bytes of 1bpp image data ; Expand bc bytes of 1bpp image data
; from a:hl to 2bpp data at de. ; from a:hl to 2bpp data at de.
ld [hROMBankTemp], a ld [hROMBankTemp], a
ld a, [H_LOADEDROMBANK] ld a, [hLoadedROMBank]
push af push af
ld a, [hROMBankTemp] ld a, [hROMBankTemp]
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
.loop .loop
ld a, [hli] ld a, [hli]
@ -55,7 +55,7 @@ FarCopyDataDouble::
or b or b
jr nz, .loop jr nz, .loop
pop af pop af
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
ret ret
@ -64,27 +64,27 @@ CopyVideoData::
; tiles from b:de to hl, 8 tiles at a time. ; tiles from b:de to hl, 8 tiles at a time.
; This takes c/8 frames. ; This takes c/8 frames.
ld a, [H_AUTOBGTRANSFERENABLED] ld a, [hAutoBGTransferEnabled]
push af push af
xor a ; disable auto-transfer while copying xor a ; disable auto-transfer while copying
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ld a, [H_LOADEDROMBANK] ld a, [hLoadedROMBank]
ld [hROMBankTemp], a ld [hROMBankTemp], a
ld a, b ld a, b
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
ld a, e ld a, e
ld [H_VBCOPYSRC], a ld [hVBlankCopySource], a
ld a, d ld a, d
ld [H_VBCOPYSRC + 1], a ld [hVBlankCopySource + 1], a
ld a, l ld a, l
ld [H_VBCOPYDEST], a ld [hVBlankCopyDest], a
ld a, h ld a, h
ld [H_VBCOPYDEST + 1], a ld [hVBlankCopyDest + 1], a
.loop .loop
ld a, c ld a, c
@ -92,18 +92,18 @@ CopyVideoData::
jr nc, .keepgoing jr nc, .keepgoing
.done .done
ld [H_VBCOPYSIZE], a ld [hVBlankCopySize], a
call DelayFrame call DelayFrame
ld a, [hROMBankTemp] ld a, [hROMBankTemp]
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
pop af pop af
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ret ret
.keepgoing .keepgoing
ld a, 8 ld a, 8
ld [H_VBCOPYSIZE], a ld [hVBlankCopySize], a
call DelayFrame call DelayFrame
ld a, c ld a, c
sub 8 sub 8
@ -114,26 +114,26 @@ CopyVideoDataDouble::
; Wait for the next VBlank, then copy c 1bpp ; Wait for the next VBlank, then copy c 1bpp
; tiles from b:de to hl, 8 tiles at a time. ; tiles from b:de to hl, 8 tiles at a time.
; This takes c/8 frames. ; This takes c/8 frames.
ld a, [H_AUTOBGTRANSFERENABLED] ld a, [hAutoBGTransferEnabled]
push af push af
xor a ; disable auto-transfer while copying xor a ; disable auto-transfer while copying
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ld a, [H_LOADEDROMBANK] ld a, [hLoadedROMBank]
ld [hROMBankTemp], a ld [hROMBankTemp], a
ld a, b ld a, b
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
ld a, e ld a, e
ld [H_VBCOPYDOUBLESRC], a ld [hVBlankCopyDoubleSource], a
ld a, d ld a, d
ld [H_VBCOPYDOUBLESRC + 1], a ld [hVBlankCopyDoubleSource + 1], a
ld a, l ld a, l
ld [H_VBCOPYDOUBLEDEST], a ld [hVBlankCopyDoubleDest], a
ld a, h ld a, h
ld [H_VBCOPYDOUBLEDEST + 1], a ld [hVBlankCopyDoubleDest + 1], a
.loop .loop
ld a, c ld a, c
@ -141,18 +141,18 @@ CopyVideoDataDouble::
jr nc, .keepgoing jr nc, .keepgoing
.done .done
ld [H_VBCOPYDOUBLESIZE], a ld [hVBlankCopyDoubleSize], a
call DelayFrame call DelayFrame
ld a, [hROMBankTemp] ld a, [hROMBankTemp]
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
pop af pop af
ld [H_AUTOBGTRANSFERENABLED], a ld [hAutoBGTransferEnabled], a
ret ret
.keepgoing .keepgoing
ld a, 8 ld a, 8
ld [H_VBCOPYDOUBLESIZE], a ld [hVBlankCopyDoubleSize], a
call DelayFrame call DelayFrame
ld a, c ld a, c
sub 8 sub 8
@ -200,16 +200,16 @@ CopyScreenTileBufferToVRAM::
.setup .setup
ld a, d ld a, d
ld [H_VBCOPYBGSRC+1], a ld [hVBlankCopyBGSource+1], a
call GetRowColAddressBgMap call GetRowColAddressBgMap
ld a, l ld a, l
ld [H_VBCOPYBGDEST], a ld [hVBlankCopyBGDest], a
ld a, h ld a, h
ld [H_VBCOPYBGDEST+1], a ld [hVBlankCopyBGDest+1], a
ld a, c ld a, c
ld [H_VBCOPYBGNUMROWS], a ld [hVBlankCopyBGNumRows], a
ld a, e ld a, e
ld [H_VBCOPYBGSRC], a ld [hVBlankCopyBGSource], a
ret ret
ClearScreen:: ClearScreen::

View file

@ -60,7 +60,7 @@ rLCDC_DEFAULT EQU %11100011
call ClearSprites call ClearSprites
ld a, Bank(WriteDMACodeToHRAM) ld a, Bank(WriteDMACodeToHRAM)
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
call WriteDMACodeToHRAM call WriteDMACodeToHRAM
@ -101,9 +101,9 @@ rLCDC_DEFAULT EQU %11100011
ld [wAudioROMBank], a ld [wAudioROMBank], a
ld [wAudioSavedROMBank], a ld [wAudioSavedROMBank], a
ld a, $9c ld a, $9c
ld [H_AUTOBGTRANSFERDEST + 1], a ld [hAutoBGTransferDest + 1], a
xor a xor a
ld [H_AUTOBGTRANSFERDEST], a ld [hAutoBGTransferDest], a
dec a dec a
ld [wUpdateSpritesEnabled], a ld [wUpdateSpritesEnabled], a

View file

@ -763,7 +763,7 @@ HandleBlackOut::
ld hl, wd72e ld hl, wd72e
res 5, [hl] res 5, [hl]
ld a, Bank(ResetStatusAndHalveMoneyOnBlackout) ; also Bank(SpecialWarpIn) and Bank(SpecialEnterMap) ld a, Bank(ResetStatusAndHalveMoneyOnBlackout) ; also Bank(SpecialWarpIn) and Bank(SpecialEnterMap)
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
call ResetStatusAndHalveMoneyOnBlackout call ResetStatusAndHalveMoneyOnBlackout
call SpecialWarpIn call SpecialWarpIn
@ -794,7 +794,7 @@ HandleFlyWarpOrDungeonWarp::
res 5, [hl] ; forced to ride bike res 5, [hl] ; forced to ride bike
call LeaveMapAnim call LeaveMapAnim
ld a, Bank(SpecialWarpIn) ld a, Bank(SpecialWarpIn)
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
call SpecialWarpIn call SpecialWarpIn
jp SpecialEnterMap jp SpecialEnterMap
@ -1372,10 +1372,10 @@ TilePairCollisionsWater::
; this builds a tile map from the tile block map based on the current X/Y coordinates of the player's character ; this builds a tile map from the tile block map based on the current X/Y coordinates of the player's character
LoadCurrentMapView:: LoadCurrentMapView::
ld a, [H_LOADEDROMBANK] ld a, [hLoadedROMBank]
push af push af
ld a, [wTilesetBank] ; tile data ROM bank ld a, [wTilesetBank] ; tile data ROM bank
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ; switch to ROM bank that contains tile data ld [MBC1RomBank], a ; switch to ROM bank that contains tile data
ld a, [wCurrentTileBlockMapViewPointer] ; address of upper left corner of current map view ld a, [wCurrentTileBlockMapViewPointer] ; address of upper left corner of current map view
ld e, a ld e, a
@ -1457,7 +1457,7 @@ LoadCurrentMapView::
dec b dec b
jr nz, .rowLoop2 jr nz, .rowLoop2
pop af pop af
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ; restore previous ROM bank ld [MBC1RomBank], a ; restore previous ROM bank
ret ret
@ -2291,10 +2291,10 @@ LoadMapHeader::
ld a, [wCurMap] ld a, [wCurMap]
ld c, a ld c, a
ld b, $00 ld b, $00
ld a, [H_LOADEDROMBANK] ld a, [hLoadedROMBank]
push af push af
ld a, BANK(MapSongBanks) ld a, BANK(MapSongBanks)
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
ld hl, MapSongBanks ld hl, MapSongBanks
add hl, bc add hl, bc
@ -2304,7 +2304,7 @@ LoadMapHeader::
ld a, [hl] ld a, [hl]
ld [wMapMusicROMBank], a ; music 2 ld [wMapMusicROMBank], a ; music 2
pop af pop af
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
ret ret
@ -2322,7 +2322,7 @@ CopyMapConnectionHeader::
; function to load map data ; function to load map data
LoadMapData:: LoadMapData::
ld a, [H_LOADEDROMBANK] ld a, [hLoadedROMBank]
push af push af
call DisableLCD call DisableLCD
ld a, $98 ld a, $98
@ -2377,7 +2377,7 @@ LoadMapData::
call PlayDefaultMusicFadeOutCurrent call PlayDefaultMusicFadeOutCurrent
.restoreRomBank .restoreRomBank
pop af pop af
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
ret ret
@ -2396,7 +2396,7 @@ SwitchToMapRomBank::
ld [$ffe8], a ; save map ROM bank ld [$ffe8], a ; save map ROM bank
call BankswitchBack call BankswitchBack
ld a, [$ffe8] ld a, [$ffe8]
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ; switch to map ROM bank ld [MBC1RomBank], a ; switch to map ROM bank
pop bc pop bc
pop hl pop hl

View file

@ -2,10 +2,10 @@
; bank is given in a, sprite input stream is pointed to in wSpriteInputPtr ; bank is given in a, sprite input stream is pointed to in wSpriteInputPtr
UncompressSpriteData:: UncompressSpriteData::
ld b, a ld b, a
ld a, [H_LOADEDROMBANK] ld a, [hLoadedROMBank]
push af push af
ld a, b ld a, b
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
ld a, SRAM_ENABLE ld a, SRAM_ENABLE
ld [MBC1SRamEnable], a ld [MBC1SRamEnable], a
@ -13,7 +13,7 @@ UncompressSpriteData::
ld [MBC1SRamBank], a ld [MBC1SRamBank], a
call _UncompressSpriteData call _UncompressSpriteData
pop af pop af
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
ret ret

View file

@ -8,18 +8,18 @@ Predef::
; A hack for LoadDestinationWarpPosition. ; A hack for LoadDestinationWarpPosition.
; See LoadTilesetHeader (predef $19). ; See LoadTilesetHeader (predef $19).
ld a, [H_LOADEDROMBANK] ld a, [hLoadedROMBank]
ld [wPredefParentBank], a ld [wPredefParentBank], a
push af push af
ld a, BANK(GetPredefPointer) ld a, BANK(GetPredefPointer)
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
call GetPredefPointer call GetPredefPointer
ld a, [wPredefBank] ld a, [wPredefBank]
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
ld de, .done ld de, .done
@ -28,7 +28,7 @@ Predef::
.done .done
pop af pop af
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
ret ret

View file

@ -1,6 +1,6 @@
DisplayStartMenu:: DisplayStartMenu::
ld a, BANK(StartMenu_Pokedex) ld a, BANK(StartMenu_Pokedex)
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
ld a, [wWalkBikeSurfState] ; walking/biking/surfing ld a, [wWalkBikeSurfState] ; walking/biking/surfing
ld [wWalkBikeSurfStateCopy], a ld [wWalkBikeSurfStateCopy], a

View file

@ -62,7 +62,7 @@ Char4ETest::
cp $4E ; next cp $4E ; next
jr nz, .char4FTest jr nz, .char4FTest
ld bc, 2 * SCREEN_WIDTH ld bc, 2 * SCREEN_WIDTH
ld a, [hFlags_0xFFF6] ld a, [hFlagsFFF6]
bit 2, a bit 2, a
jr z, .ok jr z, .ok
ld bc, SCREEN_WIDTH ld bc, SCREEN_WIDTH
@ -180,7 +180,7 @@ Char59::
; or ; or
; player active monsters name ; player active monsters name
; (like Char5A but flipped) ; (like Char5A but flipped)
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
xor 1 xor 1
jr MonsterNameCharsCommon jr MonsterNameCharsCommon
@ -189,7 +189,7 @@ Char5A::
; player active monsters name ; player active monsters name
; or ; or
; enemy active monsters name, prefixed with “Enemy ” ; enemy active monsters name, prefixed with “Enemy ”
ld a, [H_WHOSETURN] ld a, [hWhoseTurn]
MonsterNameCharsCommon:: MonsterNameCharsCommon::
push de push de
and a and a
@ -675,14 +675,14 @@ TextCommand0D::
; BB = bank ; BB = bank
TextCommand17:: TextCommand17::
pop hl pop hl
ld a, [H_LOADEDROMBANK] ld a, [hLoadedROMBank]
push af push af
ld a, [hli] ld a, [hli]
ld e, a ld e, a
ld a, [hli] ld a, [hli]
ld d, a ld d, a
ld a, [hli] ld a, [hli]
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
push hl push hl
ld l, e ld l, e
@ -690,7 +690,7 @@ TextCommand17::
call TextCommandProcessor call TextCommandProcessor
pop hl pop hl
pop af pop af
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
jp NextTextCommand jp NextTextCommand

View file

@ -5,7 +5,7 @@ VBlank::
push de push de
push hl push hl
ld a, [H_LOADEDROMBANK] ld a, [hLoadedROMBank]
ld [wVBlankSavedROMBank], a ld [wVBlankSavedROMBank], a
ld a, [hSCX] ld a, [hSCX]
@ -28,7 +28,7 @@ VBlank::
call UpdateMovingBgTiles call UpdateMovingBgTiles
call $ff80 ; hOAMDMA call $ff80 ; hOAMDMA
ld a, BANK(PrepareOAMData) ld a, BANK(PrepareOAMData)
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
call PrepareOAMData call PrepareOAMData
@ -36,24 +36,24 @@ VBlank::
call Random call Random
ld a, [H_VBLANKOCCURRED] ld a, [hVBlankOccurred]
and a and a
jr z, .skipZeroing jr z, .skipZeroing
xor a xor a
ld [H_VBLANKOCCURRED], a ld [hVBlankOccurred], a
.skipZeroing .skipZeroing
ld a, [H_FRAMECOUNTER] ld a, [hFrameCounter]
and a and a
jr z, .skipDec jr z, .skipDec
dec a dec a
ld [H_FRAMECOUNTER], a ld [hFrameCounter], a
.skipDec .skipDec
call FadeOutAudio call FadeOutAudio
ld a, [wAudioROMBank] ; music ROM bank ld a, [wAudioROMBank] ; music ROM bank
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
cp BANK(Audio1_UpdateMusic) cp BANK(Audio1_UpdateMusic)
@ -79,7 +79,7 @@ VBlank::
call z, ReadJoypad call z, ReadJoypad
ld a, [wVBlankSavedROMBank] ld a, [wVBlankSavedROMBank]
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
pop hl pop hl
@ -96,10 +96,10 @@ DelayFrame::
NOT_VBLANKED EQU 1 NOT_VBLANKED EQU 1
ld a, NOT_VBLANKED ld a, NOT_VBLANKED
ld [H_VBLANKOCCURRED], a ld [hVBlankOccurred], a
.halt .halt
halt halt
ld a, [H_VBLANKOCCURRED] ld a, [hVBlankOccurred]
and a and a
jr nz, .halt jr nz, .halt
ret ret

View file

@ -120,15 +120,15 @@ RedrawRowOrColumn::
; the above function, RedrawRowOrColumn, is used when walking to ; the above function, RedrawRowOrColumn, is used when walking to
; improve efficiency. ; improve efficiency.
AutoBgMapTransfer:: AutoBgMapTransfer::
ld a, [H_AUTOBGTRANSFERENABLED] ld a, [hAutoBGTransferEnabled]
and a and a
ret z ret z
ld hl, sp + 0 ld hl, sp + 0
ld a, h ld a, h
ld [H_SPTEMP], a ld [hSPTemp], a
ld a, l ld a, l
ld [H_SPTEMP + 1], a ; save stack pinter ld [hSPTemp + 1], a ; save stack pinter
ld a, [H_AUTOBGTRANSFERPORTION] ld a, [hAutoBGTransferPortion]
and a and a
jr z, .transferTopThird jr z, .transferTopThird
dec a dec a
@ -136,9 +136,9 @@ AutoBgMapTransfer::
.transferBottomThird .transferBottomThird
coord hl, 0, 12 coord hl, 0, 12
ld sp, hl ld sp, hl
ld a, [H_AUTOBGTRANSFERDEST + 1] ld a, [hAutoBGTransferDest + 1]
ld h, a ld h, a
ld a, [H_AUTOBGTRANSFERDEST] ld a, [hAutoBGTransferDest]
ld l, a ld l, a
ld de, (12 * 32) ld de, (12 * 32)
add hl, de add hl, de
@ -147,24 +147,24 @@ AutoBgMapTransfer::
.transferTopThird .transferTopThird
coord hl, 0, 0 coord hl, 0, 0
ld sp, hl ld sp, hl
ld a, [H_AUTOBGTRANSFERDEST + 1] ld a, [hAutoBGTransferDest + 1]
ld h, a ld h, a
ld a, [H_AUTOBGTRANSFERDEST] ld a, [hAutoBGTransferDest]
ld l, a ld l, a
ld a, TRANSFERMIDDLE ld a, TRANSFERMIDDLE
jr .doTransfer jr .doTransfer
.transferMiddleThird .transferMiddleThird
coord hl, 0, 6 coord hl, 0, 6
ld sp, hl ld sp, hl
ld a, [H_AUTOBGTRANSFERDEST + 1] ld a, [hAutoBGTransferDest + 1]
ld h, a ld h, a
ld a, [H_AUTOBGTRANSFERDEST] ld a, [hAutoBGTransferDest]
ld l, a ld l, a
ld de, (6 * 32) ld de, (6 * 32)
add hl, de add hl, de
ld a, TRANSFERBOTTOM ld a, TRANSFERBOTTOM
.doTransfer .doTransfer
ld [H_AUTOBGTRANSFERPORTION], a ; store next portion ld [hAutoBGTransferPortion], a ; store next portion
ld b, 6 ld b, 6
TransferBgRows:: TransferBgRows::
@ -192,73 +192,73 @@ TransferBgRows::
dec b dec b
jr nz, TransferBgRows jr nz, TransferBgRows
ld a, [H_SPTEMP] ld a, [hSPTemp]
ld h, a ld h, a
ld a, [H_SPTEMP + 1] ld a, [hSPTemp + 1]
ld l, a ld l, a
ld sp, hl ld sp, hl
ret ret
; Copies [H_VBCOPYBGNUMROWS] rows from H_VBCOPYBGSRC to H_VBCOPYBGDEST. ; Copies [hVBlankCopyBGNumRows] rows from hVBlankCopyBGSource to hVBlankCopyBGDest.
; If H_VBCOPYBGSRC is XX00, the transfer is disabled. ; If hVBlankCopyBGSource is XX00, the transfer is disabled.
VBlankCopyBgMap:: VBlankCopyBgMap::
ld a, [H_VBCOPYBGSRC] ; doubles as enabling byte ld a, [hVBlankCopyBGSource] ; doubles as enabling byte
and a and a
ret z ret z
ld hl, sp + 0 ld hl, sp + 0
ld a, h ld a, h
ld [H_SPTEMP], a ld [hSPTemp], a
ld a, l ld a, l
ld [H_SPTEMP + 1], a ; save stack pointer ld [hSPTemp + 1], a ; save stack pointer
ld a, [H_VBCOPYBGSRC] ld a, [hVBlankCopyBGSource]
ld l, a ld l, a
ld a, [H_VBCOPYBGSRC + 1] ld a, [hVBlankCopyBGSource + 1]
ld h, a ld h, a
ld sp, hl ld sp, hl
ld a, [H_VBCOPYBGDEST] ld a, [hVBlankCopyBGDest]
ld l, a ld l, a
ld a, [H_VBCOPYBGDEST + 1] ld a, [hVBlankCopyBGDest + 1]
ld h, a ld h, a
ld a, [H_VBCOPYBGNUMROWS] ld a, [hVBlankCopyBGNumRows]
ld b, a ld b, a
xor a xor a
ld [H_VBCOPYBGSRC], a ; disable transfer so it doesn't continue next V-blank ld [hVBlankCopyBGSource], a ; disable transfer so it doesn't continue next V-blank
jr TransferBgRows jr TransferBgRows
VBlankCopyDouble:: VBlankCopyDouble::
; Copy [H_VBCOPYDOUBLESIZE] 1bpp tiles ; Copy [hVBlankCopyDoubleSize] 1bpp tiles
; from H_VBCOPYDOUBLESRC to H_VBCOPYDOUBLEDEST. ; from hVBlankCopyDoubleSource to hVBlankCopyDoubleDest.
; While we're here, convert to 2bpp. ; While we're here, convert to 2bpp.
; The process is straightforward: ; The process is straightforward:
; copy each byte twice. ; copy each byte twice.
ld a, [H_VBCOPYDOUBLESIZE] ld a, [hVBlankCopyDoubleSize]
and a and a
ret z ret z
ld hl, sp + 0 ld hl, sp + 0
ld a, h ld a, h
ld [H_SPTEMP], a ld [hSPTemp], a
ld a, l ld a, l
ld [H_SPTEMP + 1], a ld [hSPTemp + 1], a
ld a, [H_VBCOPYDOUBLESRC] ld a, [hVBlankCopyDoubleSource]
ld l, a ld l, a
ld a, [H_VBCOPYDOUBLESRC + 1] ld a, [hVBlankCopyDoubleSource + 1]
ld h, a ld h, a
ld sp, hl ld sp, hl
ld a, [H_VBCOPYDOUBLEDEST] ld a, [hVBlankCopyDoubleDest]
ld l, a ld l, a
ld a, [H_VBCOPYDOUBLEDEST + 1] ld a, [hVBlankCopyDoubleDest + 1]
ld h, a ld h, a
ld a, [H_VBCOPYDOUBLESIZE] ld a, [hVBlankCopyDoubleSize]
ld b, a ld b, a
xor a ; transferred xor a ; transferred
ld [H_VBCOPYDOUBLESIZE], a ld [hVBlankCopyDoubleSize], a
.loop .loop
rept 3 rept 3
@ -286,19 +286,19 @@ VBlankCopyDouble::
jr nz, .loop jr nz, .loop
ld a, l ld a, l
ld [H_VBCOPYDOUBLEDEST], a ld [hVBlankCopyDoubleDest], a
ld a, h ld a, h
ld [H_VBCOPYDOUBLEDEST + 1], a ld [hVBlankCopyDoubleDest + 1], a
ld hl, sp + 0 ld hl, sp + 0
ld a, l ld a, l
ld [H_VBCOPYDOUBLESRC], a ld [hVBlankCopyDoubleSource], a
ld a, h ld a, h
ld [H_VBCOPYDOUBLESRC + 1], a ld [hVBlankCopyDoubleSource + 1], a
ld a, [H_SPTEMP] ld a, [hSPTemp]
ld h, a ld h, a
ld a, [H_SPTEMP + 1] ld a, [hSPTemp + 1]
ld l, a ld l, a
ld sp, hl ld sp, hl
@ -306,37 +306,37 @@ VBlankCopyDouble::
VBlankCopy:: VBlankCopy::
; Copy [H_VBCOPYSIZE] 2bpp tiles (or 16 * [H_VBCOPYSIZE] tile map entries) ; Copy [hVBlankCopySize] 2bpp tiles (or 16 * [hVBlankCopySize] tile map entries)
; from H_VBCOPYSRC to H_VBCOPYDEST. ; from hVBlankCopySource to hVBlankCopyDest.
; Source and destination addresses are updated, ; Source and destination addresses are updated,
; so transfer can continue in subsequent calls. ; so transfer can continue in subsequent calls.
ld a, [H_VBCOPYSIZE] ld a, [hVBlankCopySize]
and a and a
ret z ret z
ld hl, sp + 0 ld hl, sp + 0
ld a, h ld a, h
ld [H_SPTEMP], a ld [hSPTemp], a
ld a, l ld a, l
ld [H_SPTEMP + 1], a ld [hSPTemp + 1], a
ld a, [H_VBCOPYSRC] ld a, [hVBlankCopySource]
ld l, a ld l, a
ld a, [H_VBCOPYSRC + 1] ld a, [hVBlankCopySource + 1]
ld h, a ld h, a
ld sp, hl ld sp, hl
ld a, [H_VBCOPYDEST] ld a, [hVBlankCopyDest]
ld l, a ld l, a
ld a, [H_VBCOPYDEST + 1] ld a, [hVBlankCopyDest + 1]
ld h, a ld h, a
ld a, [H_VBCOPYSIZE] ld a, [hVBlankCopySize]
ld b, a ld b, a
xor a ; transferred xor a ; transferred
ld [H_VBCOPYSIZE], a ld [hVBlankCopySize], a
.loop .loop
rept 7 rept 7
@ -356,19 +356,19 @@ VBlankCopy::
jr nz, .loop jr nz, .loop
ld a, l ld a, l
ld [H_VBCOPYDEST], a ld [hVBlankCopyDest], a
ld a, h ld a, h
ld [H_VBCOPYDEST + 1], a ld [hVBlankCopyDest + 1], a
ld hl, sp + 0 ld hl, sp + 0
ld a, l ld a, l
ld [H_VBCOPYSRC], a ld [hVBlankCopySource], a
ld a, h ld a, h
ld [H_VBCOPYSRC + 1], a ld [hVBlankCopySource + 1], a
ld a, [H_SPTEMP] ld a, [hSPTemp]
ld h, a ld h, a
ld a, [H_SPTEMP + 1] ld a, [hSPTemp + 1]
ld l, a ld l, a
ld sp, hl ld sp, hl

View file

@ -26,17 +26,17 @@ hSlideAmount EQU $FF8B
hRLEByteValue EQU $FF8B hRLEByteValue EQU $FF8B
H_SPRITEWIDTH EQU $FF8B ; in tiles hSpriteWidth EQU $FF8B ; in tiles
H_SPRITEINTERLACECOUNTER EQU $FF8B hSpriteInterlaceCounter EQU $FF8B
H_SPRITEHEIGHT EQU $FF8C ; in tiles hSpriteHeight EQU $FF8C ; in tiles
H_SPRITEOFFSET EQU $FF8D hSpriteOffset EQU $FF8D
; counters for blinking down arrow ; counters for blinking down arrow
H_DOWNARROWBLINKCNT1 EQU $FF8B hDownArrowBlinkCount1 EQU $FF8B
H_DOWNARROWBLINKCNT2 EQU $FF8C hDownArrowBlinkCount2 EQU $FF8C
H_SPRITEDATAOFFSET EQU $FF8B hSpriteDataOffset EQU $FF8B
H_SPRITEINDEX EQU $FF8C hSpriteIndex EQU $FF8C
hMapStride EQU $FF8B hMapStride EQU $FF8B
hMapWidth EQU $FF8C hMapWidth EQU $FF8C
@ -101,24 +101,24 @@ hExperience EQU $FF96 ; 3 bytes, big endian
; Multiplication and division variables are meant ; Multiplication and division variables are meant
; to overlap for back-to-back usage. Big endian. ; to overlap for back-to-back usage. Big endian.
H_MULTIPLICAND EQU $FF96 ; 3 bytes hMultiplicand EQU $FF96 ; 3 bytes
H_MULTIPLIER EQU $FF99 ; 1 byte hMultiplier EQU $FF99 ; 1 byte
H_PRODUCT EQU $FF95 ; 4 bytes hProduct EQU $FF95 ; 4 bytes
H_DIVIDEND EQU $FF95 ; 4 bytes hDividend EQU $FF95 ; 4 bytes
H_DIVISOR EQU $FF99 ; 1 byte hDivisor EQU $FF99 ; 1 byte
H_QUOTIENT EQU $FF95 ; 4 bytes hQuotient EQU $FF95 ; 4 bytes
H_REMAINDER EQU $FF99 ; 1 byte hRemainder EQU $FF99 ; 1 byte
H_DIVIDEBUFFER EQU $FF9A hDivideBuffer EQU $FF9A
H_MULTIPLYBUFFER EQU $FF9B hMultiplyBuffer EQU $FF9B
; PrintNumber (big endian). ; PrintNumber (big endian).
H_PASTLEADINGZEROES EQU $FF95 ; last char printed hPastLeadingZeros EQU $FF95 ; last char printed
H_NUMTOPRINT EQU $FF96 ; 3 bytes hNumToPrint EQU $FF96 ; 3 bytes
H_POWEROFTEN EQU $FF99 ; 3 bytes hPowerOf10 EQU $FF99 ; 3 bytes
H_SAVEDNUMTOPRINT EQU $FF9C ; 3 bytes hSavedNumToPrint EQU $FF9C ; 3 bytes
; distance in steps between NPC and player ; distance in steps between NPC and player
hNPCPlayerYDistance EQU $FF95 hNPCPlayerYDistance EQU $FF95
@ -183,14 +183,14 @@ hJoy5 EQU $FFB5
hJoy6 EQU $FFB6 hJoy6 EQU $FFB6
hJoy7 EQU $FFB7 hJoy7 EQU $FFB7
H_LOADEDROMBANK EQU $FFB8 hLoadedROMBank EQU $FFB8
hSavedROMBank EQU $FFB9 hSavedROMBank EQU $FFB9
; is automatic background transfer during V-blank enabled? ; is automatic background transfer during V-blank enabled?
; if nonzero, yes ; if nonzero, yes
; if zero, no ; if zero, no
H_AUTOBGTRANSFERENABLED EQU $FFBA hAutoBGTransferEnabled EQU $FFBA
TRANSFERTOP EQU 0 TRANSFERTOP EQU 0
TRANSFERMIDDLE EQU 1 TRANSFERMIDDLE EQU 1
@ -199,45 +199,45 @@ TRANSFERBOTTOM EQU 2
; 00 = top third of background ; 00 = top third of background
; 01 = middle third of background ; 01 = middle third of background
; 02 = bottom third of background ; 02 = bottom third of background
H_AUTOBGTRANSFERPORTION EQU $FFBB hAutoBGTransferPortion EQU $FFBB
; the destination address of the automatic background transfer ; the destination address of the automatic background transfer
H_AUTOBGTRANSFERDEST EQU $FFBC ; 2 bytes hAutoBGTransferDest EQU $FFBC ; 2 bytes
; temporary storage for stack pointer during memory transfers that use pop ; temporary storage for stack pointer during memory transfers that use pop
; to increase speed ; to increase speed
H_SPTEMP EQU $FFBF ; 2 bytes hSPTemp EQU $FFBF ; 2 bytes
; source address for VBlankCopyBgMap function ; source address for VBlankCopyBgMap function
; the first byte doubles as the byte that enabled the transfer. ; the first byte doubles as the byte that enabled the transfer.
; if it is 0, the transfer is disabled ; if it is 0, the transfer is disabled
; if it is not 0, the transfer is enabled ; if it is not 0, the transfer is enabled
; this means that XX00 is not a valid source address ; this means that XX00 is not a valid source address
H_VBCOPYBGSRC EQU $FFC1 ; 2 bytes hVBlankCopyBGSource EQU $FFC1 ; 2 bytes
; destination address for VBlankCopyBgMap function ; destination address for VBlankCopyBgMap function
H_VBCOPYBGDEST EQU $FFC3 ; 2 bytes hVBlankCopyBGDest EQU $FFC3 ; 2 bytes
; number of rows for VBlankCopyBgMap to copy ; number of rows for VBlankCopyBgMap to copy
H_VBCOPYBGNUMROWS EQU $FFC5 hVBlankCopyBGNumRows EQU $FFC5
; size of VBlankCopy transfer in 16-byte units ; size of VBlankCopy transfer in 16-byte units
H_VBCOPYSIZE EQU $FFC6 hVBlankCopySize EQU $FFC6
; source address for VBlankCopy function ; source address for VBlankCopy function
H_VBCOPYSRC EQU $FFC7 hVBlankCopySource EQU $FFC7
; destination address for VBlankCopy function ; destination address for VBlankCopy function
H_VBCOPYDEST EQU $FFC9 hVBlankCopyDest EQU $FFC9
; size of source data for VBlankCopyDouble in 8-byte units ; size of source data for VBlankCopyDouble in 8-byte units
H_VBCOPYDOUBLESIZE EQU $FFCB hVBlankCopyDoubleSize EQU $FFCB
; source address for VBlankCopyDouble function ; source address for VBlankCopyDouble function
H_VBCOPYDOUBLESRC EQU $FFCC hVBlankCopyDoubleSource EQU $FFCC
; destination address for VBlankCopyDouble function ; destination address for VBlankCopyDouble function
H_VBCOPYDOUBLEDEST EQU $FFCE hVBlankCopyDoubleDest EQU $FFCE
; controls whether a row or column of 2x2 tile blocks is redrawn in V-blank ; controls whether a row or column of 2x2 tile blocks is redrawn in V-blank
; 00 = no redraw ; 00 = no redraw
@ -253,12 +253,12 @@ hRedrawRowOrColumnDest EQU $FFD1
hRandomAdd EQU $FFD3 hRandomAdd EQU $FFD3
hRandomSub EQU $FFD4 hRandomSub EQU $FFD4
H_FRAMECOUNTER EQU $FFD5 ; decremented every V-blank (used for delays) hFrameCounter EQU $FFD5 ; decremented every V-blank (used for delays)
; V-blank sets this to 0 each time it runs. ; V-blank sets this to 0 each time it runs.
; So, by setting it to a nonzero value and waiting for it to become 0 again, ; So, by setting it to a nonzero value and waiting for it to become 0 again,
; you can detect that the V-blank handler has run since then. ; you can detect that the V-blank handler has run since then.
H_VBLANKOCCURRED EQU $FFD6 hVBlankOccurred EQU $FFD6
; 00 = indoor ; 00 = indoor
; 01 = cave ; 01 = cave
@ -268,7 +268,7 @@ hTilesetType EQU $FFD7
hMovingBGTilesCounter1 EQU $FFD8 hMovingBGTilesCounter1 EQU $FFD8
H_CURRENTSPRITEOFFSET EQU $FFDA ; multiple of $10 hCurrentSpriteOffset EQU $FFDA ; multiple of $10
hItemCounter EQU $FFDB hItemCounter EQU $FFDB
@ -310,15 +310,14 @@ hCoordsInFrontOfPlayerMatch EQU $FFEA
hSpriteAnimFrameCounter EQU $FFEA hSpriteAnimFrameCounter EQU $FFEA
H_WHOSETURN EQU $FFF3 ; 0 on players turn, 1 on enemys turn hWhoseTurn EQU $FFF3 ; 0 on players turn, 1 on enemys turn
; bit 0: draw HP fraction to the right of bar instead of below (for party menu) ; bit 0: draw HP fraction to the right of bar instead of below (for party menu)
; bit 1: menu is double spaced ; bit 1: menu is double spaced
hFlags_0xFFF6 EQU $FFF6 hFlagsFFF6 EQU $FFF6
hFieldMoveMonMenuTopMenuItemX EQU $FFF7 hFieldMoveMonMenuTopMenuItemX EQU $FFF7
hDisableJoypadPolling EQU $FFF9 hDisableJoypadPolling EQU $FFF9
hJoyInput EQU $FFF8 hJoyInput EQU $FFF8

View file

@ -25,13 +25,13 @@ jpab: MACRO
ENDM ENDM
homecall: MACRO homecall: MACRO
ld a, [H_LOADEDROMBANK] ld a, [hLoadedROMBank]
push af push af
ld a, BANK(\1) ld a, BANK(\1)
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
call \1 call \1
pop af pop af
ld [H_LOADEDROMBANK], a ld [hLoadedROMBank], a
ld [MBC1RomBank], a ld [MBC1RomBank], a
ENDM ENDM

View file

@ -23,7 +23,7 @@ BillsHouseScript1:
ld de, MovementData_1e7a0 ld de, MovementData_1e7a0
.notDown .notDown
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call MoveSprite call MoveSprite
ld a, $2 ld a, $2
ld [wBillsHouseCurScript], a ld [wBillsHouseCurScript], a
@ -80,7 +80,7 @@ BillsHouseScript3:
ld c, 8 ld c, 8
call DelayFrames call DelayFrames
ld a, $2 ld a, $2
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
ld de, MovementData_1e807 ld de, MovementData_1e807
call MoveSprite call MoveSprite
ld a, $4 ld a, $4

View file

@ -170,7 +170,7 @@ CeladonGymText1:
ld hl, CeladonGymText_48a63 ld hl, CeladonGymText_48a63
ld de, CeladonGymText_48a63 ld de, CeladonGymText_48a63
call SaveEndBattleTextPointers call SaveEndBattleTextPointers
ld a, [H_SPRITEINDEX] ld a, [hSpriteIndex]
ld [wSpriteIndex], a ld [wSpriteIndex], a
call EngageMapTrainer call EngageMapTrainer
call InitBattleEnemyParameters call InitBattleEnemyParameters

View file

@ -79,9 +79,9 @@ CeruleanCityScript0:
cp $14 cp $14
jr z, .asm_19535 jr z, .asm_19535
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
ld a, $5 ld a, $5
ld [H_SPRITEDATAOFFSET], a ld [hSpriteDataOffset], a
call GetPointerWithinSpriteStateData2 call GetPointerWithinSpriteStateData2
ld [hl], $19 ld [hl], $19
.asm_19535 .asm_19535
@ -90,7 +90,7 @@ CeruleanCityScript0:
predef ShowObject predef ShowObject
ld de, CeruleanCityMovement1 ld de, CeruleanCityMovement1
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call MoveSprite call MoveSprite
ld a, $1 ld a, $1
ld [wCeruleanCityCurScript], a ld [wCeruleanCityCurScript], a
@ -114,7 +114,7 @@ CeruleanCityMovement1:
CeruleanCityScript_1955d: CeruleanCityScript_1955d:
ld a, 1 ld a, 1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
xor a ; SPRITE_FACING_DOWN xor a ; SPRITE_FACING_DOWN
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a
jp SetSpriteFacingDirectionAndDelay ; face object jp SetSpriteFacingDirectionAndDelay ; face object
@ -176,7 +176,7 @@ CeruleanCityScript2:
call PlaySound call PlaySound
callba Music_RivalAlternateStart callba Music_RivalAlternateStart
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call SetSpriteMovementBytesToFF call SetSpriteMovementBytesToFF
ld a, [wXCoord] ld a, [wXCoord]
cp $14 cp $14
@ -187,7 +187,7 @@ CeruleanCityScript2:
ld de, CeruleanCityMovement3 ld de, CeruleanCityMovement3
.asm_195f3 .asm_195f3
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call MoveSprite call MoveSprite
ld a, $3 ld a, $3
ld [wCeruleanCityCurScript], a ld [wCeruleanCityCurScript], a

View file

@ -121,7 +121,7 @@ CeruleanGymText1:
ld hl, CeruleanGymText_5c7d8 ld hl, CeruleanGymText_5c7d8
ld de, CeruleanGymText_5c7d8 ld de, CeruleanGymText_5c7d8
call SaveEndBattleTextPointers call SaveEndBattleTextPointers
ld a, [H_SPRITEINDEX] ld a, [hSpriteIndex]
ld [wSpriteIndex], a ld [wSpriteIndex], a
call EngageMapTrainer call EngageMapTrainer
call InitBattleEnemyParameters call InitBattleEnemyParameters

View file

@ -101,7 +101,7 @@ GaryScript3:
ld [hSpriteIndexOrTextID], a ld [hSpriteIndexOrTextID], a
call GaryScript_760c8 call GaryScript_760c8
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call SetSpriteMovementBytesToFF call SetSpriteMovementBytesToFF
ld a, $4 ld a, $4
ld [wChampionsRoomCurScript], a ld [wChampionsRoomCurScript], a
@ -113,11 +113,11 @@ GaryScript4:
ld [hSpriteIndexOrTextID], a ld [hSpriteIndexOrTextID], a
call GaryScript_760c8 call GaryScript_760c8
ld a, $2 ld a, $2
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call SetSpriteMovementBytesToFF call SetSpriteMovementBytesToFF
ld de, OakEntranceAfterVictoryMovement ld de, OakEntranceAfterVictoryMovement
ld a, $2 ld a, $2
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call MoveSprite call MoveSprite
ld a, HS_CHAMPIONS_ROOM_OAK ld a, HS_CHAMPIONS_ROOM_OAK
ld [wMissableObjectIndex], a ld [wMissableObjectIndex], a
@ -141,12 +141,12 @@ GaryScript5:
ld a, PLAYER_DIR_LEFT ld a, PLAYER_DIR_LEFT
ld [wPlayerMovingDirection], a ld [wPlayerMovingDirection], a
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
ld a, SPRITE_FACING_LEFT ld a, SPRITE_FACING_LEFT
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a
call SetSpriteFacingDirectionAndDelay call SetSpriteFacingDirectionAndDelay
ld a, $2 ld a, $2
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
xor a ; SPRITE_FACING_DOWN xor a ; SPRITE_FACING_DOWN
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a
call SetSpriteFacingDirectionAndDelay call SetSpriteFacingDirectionAndDelay
@ -159,7 +159,7 @@ GaryScript5:
GaryScript6: GaryScript6:
ld a, $2 ld a, $2
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
ld a, SPRITE_FACING_RIGHT ld a, SPRITE_FACING_RIGHT
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a
call SetSpriteFacingDirectionAndDelay call SetSpriteFacingDirectionAndDelay
@ -172,7 +172,7 @@ GaryScript6:
GaryScript7: GaryScript7:
ld a, $2 ld a, $2
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
xor a ; SPRITE_FACING_DOWN xor a ; SPRITE_FACING_DOWN
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a
call SetSpriteFacingDirectionAndDelay call SetSpriteFacingDirectionAndDelay
@ -181,7 +181,7 @@ GaryScript7:
call GaryScript_760c8 call GaryScript_760c8
ld de, OakExitGaryRoomMovement ld de, OakExitGaryRoomMovement
ld a, $2 ld a, $2
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call MoveSprite call MoveSprite
ld a, $8 ld a, $8
ld [wChampionsRoomCurScript], a ld [wChampionsRoomCurScript], a

View file

@ -50,7 +50,7 @@ CinnabarGymScript0:
ld a, [wOpponentAfterWrongAnswer] ld a, [wOpponentAfterWrongAnswer]
and a and a
ret z ret z
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
cp $4 cp $4
jr nz, .asm_757c3 jr nz, .asm_757c3
ld a, PLAYER_DIR_DOWN ld a, PLAYER_DIR_DOWN

View file

@ -43,7 +43,7 @@ FightingDojoScript1:
ld a, PLAYER_DIR_RIGHT ld a, PLAYER_DIR_RIGHT
ld [wPlayerMovingDirection], a ld [wPlayerMovingDirection], a
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
ld a, SPRITE_FACING_LEFT ld a, SPRITE_FACING_LEFT
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a
call SetSpriteFacingDirectionAndDelay call SetSpriteFacingDirectionAndDelay
@ -62,7 +62,7 @@ FightingDojoScript3:
ld a, PLAYER_DIR_RIGHT ld a, PLAYER_DIR_RIGHT
ld [wPlayerMovingDirection], a ld [wPlayerMovingDirection], a
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
ld a, SPRITE_FACING_LEFT ld a, SPRITE_FACING_LEFT
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a
call SetSpriteFacingDirectionAndDelay call SetSpriteFacingDirectionAndDelay

View file

@ -161,7 +161,7 @@ FuchsiaGymText1:
ld hl, KogaAfterBattleText ld hl, KogaAfterBattleText
ld de, KogaAfterBattleText ld de, KogaAfterBattleText
call SaveEndBattleTextPointers call SaveEndBattleTextPointers
ld a, [H_SPRITEINDEX] ld a, [hSpriteIndex]
ld [wSpriteIndex], a ld [wSpriteIndex], a
call EngageMapTrainer call EngageMapTrainer
call InitBattleEnemyParameters call InitBattleEnemyParameters

View file

@ -60,7 +60,7 @@ CeladonGameCornerScript1:
ld [hSpriteIndexOrTextID], a ld [hSpriteIndexOrTextID], a
call DisplayTextID call DisplayTextID
ld a, $b ld a, $b
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call SetSpriteMovementBytesToFF call SetSpriteMovementBytesToFF
ld de, MovementData_48c5a ld de, MovementData_48c5a
ld a, [wYCoord] ld a, [wYCoord]
@ -75,7 +75,7 @@ CeladonGameCornerScript1:
ld de, MovementData_48c63 ld de, MovementData_48c63
.asm_48c4d .asm_48c4d
ld a, $b ld a, $b
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call MoveSprite call MoveSprite
ld a, $2 ld a, $2
ld [wGameCornerCurScript], a ld [wGameCornerCurScript], a
@ -418,7 +418,7 @@ CeladonGameCornerText11:
ld hl, CeladonGameCornerText_48ed3 ld hl, CeladonGameCornerText_48ed3
ld de, CeladonGameCornerText_48ed3 ld de, CeladonGameCornerText_48ed3
call SaveEndBattleTextPointers call SaveEndBattleTextPointers
ld a, [H_SPRITEINDEX] ld a, [hSpriteIndex]
ld [wSpriteIndex], a ld [wSpriteIndex], a
call EngageMapTrainer call EngageMapTrainer
call InitBattleEnemyParameters call InitBattleEnemyParameters

View file

@ -79,7 +79,7 @@ HallofFameRoomScript1:
ld a, PLAYER_DIR_RIGHT ld a, PLAYER_DIR_RIGHT
ld [wPlayerMovingDirection], a ld [wPlayerMovingDirection], a
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call SetSpriteMovementBytesToFF call SetSpriteMovementBytesToFF
ld a, SPRITE_FACING_LEFT ld a, SPRITE_FACING_LEFT
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a

View file

@ -88,7 +88,7 @@ MtMoon3Script3:
MtMoon3Script4: MtMoon3Script4:
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call SetSpriteMovementBytesToFF call SetSpriteMovementBytesToFF
ld hl, CoordsData_49dea ld hl, CoordsData_49dea
call ArePlayerCoordsInArray call ArePlayerCoordsInArray
@ -102,7 +102,7 @@ MtMoon3Script4:
ld de, MovementData_49df8 ld de, MovementData_49df8
.asm_49dda .asm_49dda
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call MoveSprite call MoveSprite
ld a, $5 ld a, $5
ld [wMtMoonB2FCurScript], a ld [wMtMoonB2FCurScript], a
@ -222,7 +222,7 @@ MtMoon3Text1:
ld hl, MtMoon3Text_49f8a ld hl, MtMoon3Text_49f8a
ld de, MtMoon3Text_49f8a ld de, MtMoon3Text_49f8a
call SaveEndBattleTextPointers call SaveEndBattleTextPointers
ld a, [H_SPRITEINDEX] ld a, [hSpriteIndex]
ld [wSpriteIndex], a ld [wSpriteIndex], a
call EngageMapTrainer call EngageMapTrainer
call InitBattleEnemyParameters call InitBattleEnemyParameters

View file

@ -48,7 +48,7 @@ OaksLabScript0:
OaksLabScript1: OaksLabScript1:
ld a, $8 ld a, $8
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
ld de, OakEntryMovement ld de, OakEntryMovement
call MoveSprite call MoveSprite
@ -86,12 +86,12 @@ OaksLabScript3:
ld [wSimulatedJoypadStatesIndex], a ld [wSimulatedJoypadStatesIndex], a
call StartSimulatingJoypadStates call StartSimulatingJoypadStates
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
xor a xor a
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a
call SetSpriteFacingDirectionAndDelay call SetSpriteFacingDirectionAndDelay
ld a, $5 ld a, $5
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
xor a xor a
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a
call SetSpriteFacingDirectionAndDelay call SetSpriteFacingDirectionAndDelay
@ -111,7 +111,7 @@ OaksLabScript4:
SetEvent EVENT_FOLLOWED_OAK_INTO_LAB SetEvent EVENT_FOLLOWED_OAK_INTO_LAB
SetEvent EVENT_FOLLOWED_OAK_INTO_LAB_2 SetEvent EVENT_FOLLOWED_OAK_INTO_LAB_2
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
ld a, SPRITE_FACING_UP ld a, SPRITE_FACING_UP
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a
call SetSpriteFacingDirectionAndDelay call SetSpriteFacingDirectionAndDelay
@ -155,12 +155,12 @@ OaksLabScript6:
cp $6 cp $6
ret nz ret nz
ld a, $5 ld a, $5
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
xor a ; SPRITE_FACING_DOWN xor a ; SPRITE_FACING_DOWN
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a
call SetSpriteFacingDirectionAndDelay call SetSpriteFacingDirectionAndDelay
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
xor a xor a
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a
call SetSpriteFacingDirectionAndDelay call SetSpriteFacingDirectionAndDelay
@ -254,9 +254,9 @@ OaksLabScript8:
jr nz, .moveBlue jr nz, .moveBlue
push hl push hl
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
ld a, $4 ld a, $4
ld [H_SPRITEDATAOFFSET], a ld [hSpriteDataOffset], a
call GetPointerWithinSpriteStateData1 call GetPointerWithinSpriteStateData1
push hl push hl
ld [hl], $4c ld [hl], $4c
@ -281,7 +281,7 @@ OaksLabScript8:
.moveBlue .moveBlue
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call MoveSprite call MoveSprite
ld a, $9 ld a, $9
@ -295,7 +295,7 @@ OaksLabScript9:
ld a, $fc ld a, $fc
ld [wJoyIgnore], a ld [wJoyIgnore], a
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
ld a, SPRITE_FACING_UP ld a, SPRITE_FACING_UP
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a
call SetSpriteFacingDirectionAndDelay call SetSpriteFacingDirectionAndDelay
@ -324,7 +324,7 @@ OaksLabScript9:
ld [wd11e], a ld [wd11e], a
call GetMonName call GetMonName
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
ld a, SPRITE_FACING_UP ld a, SPRITE_FACING_UP
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a
call SetSpriteFacingDirectionAndDelay call SetSpriteFacingDirectionAndDelay
@ -344,7 +344,7 @@ OaksLabScript10:
cp $6 cp $6
ret nz ret nz
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
xor a ; SPRITE_FACING_DOWN xor a ; SPRITE_FACING_DOWN
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a
call SetSpriteFacingDirectionAndDelay call SetSpriteFacingDirectionAndDelay
@ -368,7 +368,7 @@ OaksLabScript10:
predef FindPathToPlayer predef FindPathToPlayer
ld de, wNPCMovementDirections2 ld de, wNPCMovementDirections2
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call MoveSprite call MoveSprite
ld a, $b ld a, $b
@ -424,7 +424,7 @@ OaksLabScript12:
ld [wSpriteIndex], a ld [wSpriteIndex], a
call SetSpritePosition1 call SetSpritePosition1
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
xor a ; SPRITE_FACING_DOWN xor a ; SPRITE_FACING_DOWN
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a
call SetSpriteFacingDirectionAndDelay call SetSpriteFacingDirectionAndDelay
@ -443,7 +443,7 @@ OaksLabScript13:
call DisplayTextID call DisplayTextID
callba Music_RivalAlternateStart callba Music_RivalAlternateStart
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
ld de, .RivalExitMovement ld de, .RivalExitMovement
call MoveSprite call MoveSprite
ld a, [wXCoord] ld a, [wXCoord]
@ -530,7 +530,7 @@ OaksLabScript15:
call FillMemory call FillMemory
ld [hl], $ff ld [hl], $ff
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
ld de, wNPCMovementDirections2 ld de, wNPCMovementDirections2
call MoveSprite call MoveSprite
@ -540,12 +540,12 @@ OaksLabScript15:
OaksLabScript_1cefd: OaksLabScript_1cefd:
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
ld a, SPRITE_FACING_UP ld a, SPRITE_FACING_UP
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a
call SetSpriteFacingDirectionAndDelay call SetSpriteFacingDirectionAndDelay
ld a, $8 ld a, $8
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
xor a ; SPRITE_FACING_DOWN xor a ; SPRITE_FACING_DOWN
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a
jp SetSpriteFacingDirectionAndDelay jp SetSpriteFacingDirectionAndDelay
@ -588,7 +588,7 @@ OaksLabScript16:
ld [hSpriteIndexOrTextID], a ld [hSpriteIndexOrTextID], a
call DisplayTextID call DisplayTextID
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
ld a, SPRITE_FACING_RIGHT ld a, SPRITE_FACING_RIGHT
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a
call SetSpriteFacingDirectionAndDelay call SetSpriteFacingDirectionAndDelay
@ -616,7 +616,7 @@ OaksLabScript16:
call PlaySound call PlaySound
callba Music_RivalAlternateStart callba Music_RivalAlternateStart
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
ld de, wNPCMovementDirections2 ld de, wNPCMovementDirections2
call MoveSprite call MoveSprite
@ -840,15 +840,15 @@ OaksLabText39:
OaksLabScript_1d157: OaksLabScript_1d157:
ld a, $5 ld a, $5
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
ld a, $9 ld a, $9
ld [H_SPRITEDATAOFFSET], a ld [hSpriteDataOffset], a
call GetPointerWithinSpriteStateData1 call GetPointerWithinSpriteStateData1
ld [hl], SPRITE_FACING_DOWN ld [hl], SPRITE_FACING_DOWN
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
ld a, $9 ld a, $9
ld [H_SPRITEDATAOFFSET], a ld [hSpriteDataOffset], a
call GetPointerWithinSpriteStateData1 call GetPointerWithinSpriteStateData1
ld [hl], SPRITE_FACING_RIGHT ld [hl], SPRITE_FACING_RIGHT
ld hl, wd730 ld hl, wd730
@ -947,9 +947,9 @@ OaksLabReceivedMonText:
OaksLabScript_1d22d: OaksLabScript_1d22d:
ld a, $5 ld a, $5
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
ld a, $9 ld a, $9
ld [H_SPRITEDATAOFFSET], a ld [hSpriteDataOffset], a
call GetPointerWithinSpriteStateData1 call GetPointerWithinSpriteStateData1
ld [hl], $0 ld [hl], $0
ld hl, OaksLabLastMonText ld hl, OaksLabLastMonText

View file

@ -61,7 +61,7 @@ PalletTownScript1:
PalletTownScript2: PalletTownScript2:
ld a, 1 ld a, 1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
ld a, SPRITE_FACING_UP ld a, SPRITE_FACING_UP
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a
call SetSpriteFacingDirectionAndDelay call SetSpriteFacingDirectionAndDelay
@ -79,7 +79,7 @@ PalletTownScript2:
predef FindPathToPlayer ; load Oaks movement into wNPCMovementDirections2 predef FindPathToPlayer ; load Oaks movement into wNPCMovementDirections2
ld de, wNPCMovementDirections2 ld de, wNPCMovementDirections2
ld a, 1 ; oak ld a, 1 ; oak
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call MoveSprite call MoveSprite
ld a, $FF ld a, $FF
ld [wJoyIgnore], a ld [wJoyIgnore], a
@ -111,7 +111,7 @@ PalletTownScript3:
ld [wNPCMovementScriptFunctionNum], a ld [wNPCMovementScriptFunctionNum], a
ld a, 1 ld a, 1
ld [wNPCMovementScriptPointerTableNum], a ld [wNPCMovementScriptPointerTableNum], a
ld a, [H_LOADEDROMBANK] ld a, [hLoadedROMBank]
ld [wNPCMovementScriptBank], a ld [wNPCMovementScriptBank], a
; trigger the next script ; trigger the next script

View file

@ -44,7 +44,7 @@ PewterCityScript1:
and a and a
ret nz ret nz
ld a, $3 ld a, $3
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
ld a, SPRITE_FACING_UP ld a, SPRITE_FACING_UP
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a
call SetSpriteFacingDirectionAndDelay call SetSpriteFacingDirectionAndDelay
@ -69,7 +69,7 @@ PewterCityScript1:
ld [wSpriteIndex], a ld [wSpriteIndex], a
call SetSpritePosition1 call SetSpritePosition1
ld a, $3 ld a, $3
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
ld de, MovementData_PewterMuseumGuyExit ld de, MovementData_PewterMuseumGuyExit
call MoveSprite call MoveSprite
ld a, $2 ld a, $2
@ -112,7 +112,7 @@ PewterCityScript4:
and a and a
ret nz ret nz
ld a, $5 ld a, $5
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
ld a, SPRITE_FACING_LEFT ld a, SPRITE_FACING_LEFT
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a
call SetSpriteFacingDirectionAndDelay call SetSpriteFacingDirectionAndDelay
@ -137,7 +137,7 @@ PewterCityScript4:
ld [wSpriteIndex], a ld [wSpriteIndex], a
call SetSpritePosition1 call SetSpritePosition1
ld a, $5 ld a, $5
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
ld de, MovementData_PewterGymGuyExit ld de, MovementData_PewterGymGuyExit
call MoveSprite call MoveSprite
ld a, $5 ld a, $5
@ -220,7 +220,7 @@ PewterCityText3:
ld [wNPCMovementScriptFunctionNum], a ld [wNPCMovementScriptFunctionNum], a
ld a, $2 ld a, $2
ld [wNPCMovementScriptPointerTableNum], a ld [wNPCMovementScriptPointerTableNum], a
ld a, [H_LOADEDROMBANK] ld a, [hLoadedROMBank]
ld [wNPCMovementScriptBank], a ld [wNPCMovementScriptBank], a
ld a, $3 ld a, $3
ld [wSpriteIndex], a ld [wSpriteIndex], a
@ -284,7 +284,7 @@ PewterCityText5:
ld [wNPCMovementScriptFunctionNum], a ld [wNPCMovementScriptFunctionNum], a
ld a, $3 ld a, $3
ld [wNPCMovementScriptPointerTableNum], a ld [wNPCMovementScriptPointerTableNum], a
ld a, [H_LOADEDROMBANK] ld a, [hLoadedROMBank]
ld [wNPCMovementScriptBank], a ld [wNPCMovementScriptBank], a
ld a, $5 ld a, $5
ld [wSpriteIndex], a ld [wSpriteIndex], a

View file

@ -120,7 +120,7 @@ PewterGymText1:
ld hl, PewterGymText_5c4bc ld hl, PewterGymText_5c4bc
ld de, PewterGymText_5c4bc ld de, PewterGymText_5c4bc
call SaveEndBattleTextPointers call SaveEndBattleTextPointers
ld a, [H_SPRITEINDEX] ld a, [hSpriteIndex]
ld [wSpriteIndex], a ld [wSpriteIndex], a
call EngageMapTrainer call EngageMapTrainer
call InitBattleEnemyParameters call InitBattleEnemyParameters

View file

@ -41,7 +41,7 @@ PokemonTower2Script0:
.asm_60544 .asm_60544
ld [wPlayerMovingDirection], a ld [wPlayerMovingDirection], a
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
ld a, b ld a, b
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a
call SetSpriteFacingDirectionAndDelay call SetSpriteFacingDirectionAndDelay
@ -74,7 +74,7 @@ PokemonTower2Script1:
ld de, MovementData_605a9 ld de, MovementData_605a9
.asm_60589 .asm_60589
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call MoveSprite call MoveSprite
ld a, SFX_STOP_ALL_MUSIC ld a, SFX_STOP_ALL_MUSIC
ld [wNewSoundID], a ld [wNewSoundID], a

View file

@ -107,7 +107,7 @@ PokemonTower7Script_60db6:
ld d, [hl] ld d, [hl]
ld e, a ld e, a
ld a, [wSpriteIndex] ld a, [wSpriteIndex]
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
jp MoveSprite jp MoveSprite
.asm_60dde .asm_60dde
inc hl inc hl

View file

@ -125,7 +125,7 @@ RocketHideout4Text1:
ld hl, RocketHideout4Text_4557f ld hl, RocketHideout4Text_4557f
ld de, RocketHideout4Text_4557f ld de, RocketHideout4Text_4557f
call SaveEndBattleTextPointers call SaveEndBattleTextPointers
ld a, [H_SPRITEINDEX] ld a, [hSpriteIndex]
ld [wSpriteIndex], a ld [wSpriteIndex], a
call EngageMapTrainer call EngageMapTrainer
call InitBattleEnemyParameters call InitBattleEnemyParameters

View file

@ -96,7 +96,7 @@ Route22Script0:
ld a, MUSIC_MEET_RIVAL ld a, MUSIC_MEET_RIVAL
call PlayMusic call PlayMusic
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call Route22MoveRivalSprite call Route22MoveRivalSprite
ld a, $1 ld a, $1
ld [wRoute22CurScript], a ld [wRoute22CurScript], a
@ -118,7 +118,7 @@ Route22Script1:
.asm_50f7a .asm_50f7a
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call SetSpriteFacingDirectionAndDelay call SetSpriteFacingDirectionAndDelay
xor a xor a
ld [wJoyIgnore], a ld [wJoyIgnore], a
@ -159,7 +159,7 @@ Route22Script2:
.done .done
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call SetSpriteFacingDirectionAndDelay call SetSpriteFacingDirectionAndDelay
ld a, $f0 ld a, $f0
ld [wJoyIgnore], a ld [wJoyIgnore], a
@ -191,7 +191,7 @@ Route22Script_5100d:
ld de, Route22RivalExitMovementData2 ld de, Route22RivalExitMovementData2
Route22MoveRival1: Route22MoveRival1:
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
jp MoveSprite jp MoveSprite
Route22RivalExitMovementData1: Route22RivalExitMovementData1:
@ -250,7 +250,7 @@ Route22Script_5104e:
call PlaySound call PlaySound
callba Music_RivalAlternateTempo callba Music_RivalAlternateTempo
ld a, $2 ld a, $2
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call Route22MoveRivalSprite call Route22MoveRivalSprite
ld a, $4 ld a, $4
ld [wRoute22CurScript], a ld [wRoute22CurScript], a
@ -261,7 +261,7 @@ Route22Script4:
bit 0, a bit 0, a
ret nz ret nz
ld a, $2 ld a, $2
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
ld a, [wcf0d] ld a, [wcf0d]
cp $1 cp $1
jr nz, .asm_510a1 jr nz, .asm_510a1
@ -305,7 +305,7 @@ Route22Script5:
cp $ff cp $ff
jp z, Route22Script_50ece jp z, Route22Script_50ece
ld a, $2 ld a, $2
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
ld a, [wcf0d] ld a, [wcf0d]
cp $1 cp $1
jr nz, .asm_510fb jr nz, .asm_510fb
@ -350,7 +350,7 @@ Route22Script_51142:
ld de, MovementData_5114d ld de, MovementData_5114d
Route22MoveRival2: Route22MoveRival2:
ld a, $2 ld a, $2
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
jp MoveSprite jp MoveSprite
MovementData_5114c: MovementData_5114c:

View file

@ -37,7 +37,7 @@ SSAnne2Script0:
predef ShowObject predef ShowObject
call Delay3 call Delay3
ld a, $2 ld a, $2
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call SetSpriteMovementBytesToFF call SetSpriteMovementBytesToFF
xor a xor a
ld [hJoyHeld], a ld [hJoyHeld], a
@ -83,7 +83,7 @@ SSAnne2Script_61416:
.asm_61427 .asm_61427
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a
ld a, $2 ld a, $2
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
jp SetSpriteFacingDirectionAndDelay jp SetSpriteFacingDirectionAndDelay
SSAnne2Script1: SSAnne2Script1:
@ -132,7 +132,7 @@ SSAnne2Script2:
ld [hSpriteIndexOrTextID], a ld [hSpriteIndexOrTextID], a
call DisplayTextID call DisplayTextID
ld a, $2 ld a, $2
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call SetSpriteMovementBytesToFF call SetSpriteMovementBytesToFF
ld a, [wXCoord] ld a, [wXCoord]
cp $25 cp $25
@ -143,7 +143,7 @@ SSAnne2Script2:
ld de, MovementData_614b7 ld de, MovementData_614b7
.asm_6149a .asm_6149a
ld a, $2 ld a, $2
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call MoveSprite call MoveSprite
ld a, SFX_STOP_ALL_MUSIC ld a, SFX_STOP_ALL_MUSIC
ld [wNewSoundID], a ld [wNewSoundID], a

View file

@ -171,7 +171,7 @@ SaffronGymText1:
ld hl, SaffronGymText_5d167 ld hl, SaffronGymText_5d167
ld de, SaffronGymText_5d167 ld de, SaffronGymText_5d167
call SaveEndBattleTextPointers call SaveEndBattleTextPointers
ld a, [H_SPRITEINDEX] ld a, [hSpriteIndex]
ld [wSpriteIndex], a ld [wSpriteIndex], a
call EngageMapTrainer call EngageMapTrainer
call InitBattleEnemyParameters call InitBattleEnemyParameters

View file

@ -178,7 +178,7 @@ SilphCo11Script0:
ld [hSpriteIndexOrTextID], a ld [hSpriteIndexOrTextID], a
call DisplayTextID call DisplayTextID
ld a, $3 ld a, $3
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call SetSpriteMovementBytesToFF call SetSpriteMovementBytesToFF
ld de, MovementData_62216 ld de, MovementData_62216
call MoveSprite call MoveSprite
@ -199,7 +199,7 @@ MovementData_62216:
SilphCo11Script_6221a: SilphCo11Script_6221a:
ld [wPlayerMovingDirection], a ld [wPlayerMovingDirection], a
ld a, $3 ld a, $3
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
ld a, b ld a, b
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a
jp SetSpriteFacingDirectionAndDelay jp SetSpriteFacingDirectionAndDelay
@ -239,7 +239,7 @@ SilphCo11Script3:
bit 0, a bit 0, a
ret nz ret nz
ld a, $3 ld a, $3
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call SetSpriteMovementBytesToFF call SetSpriteMovementBytesToFF
ld a, [wcf0d] ld a, [wcf0d]
cp $1 cp $1
@ -263,7 +263,7 @@ SilphCo11Script4:
ld hl, SilphCo10Text_62330 ld hl, SilphCo10Text_62330
ld de, SilphCo10Text_62330 ld de, SilphCo10Text_62330
call SaveEndBattleTextPointers call SaveEndBattleTextPointers
ld a, [H_SPRITEINDEX] ld a, [hSpriteIndex]
ld [wSpriteIndex], a ld [wSpriteIndex], a
call EngageMapTrainer call EngageMapTrainer
call InitBattleEnemyParameters call InitBattleEnemyParameters

View file

@ -140,7 +140,7 @@ SilphCo7Script0:
ld [hSpriteIndexOrTextID], a ld [hSpriteIndexOrTextID], a
call DisplayTextID call DisplayTextID
ld a, $9 ld a, $9
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call SetSpriteMovementBytesToFF call SetSpriteMovementBytesToFF
ld de, MovementData_51c7d ld de, MovementData_51c7d
ld a, [wCoordIndex] ld a, [wCoordIndex]
@ -150,7 +150,7 @@ SilphCo7Script0:
inc de inc de
.asm_51c6c .asm_51c6c
ld a, $9 ld a, $9
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call MoveSprite call MoveSprite
ld a, $3 ld a, $3
jp SilphCo7Text_51c10 jp SilphCo7Text_51c10
@ -212,7 +212,7 @@ SilphCo7Script4:
ld a, PLAYER_DIR_DOWN ld a, PLAYER_DIR_DOWN
ld [wPlayerMovingDirection], a ld [wPlayerMovingDirection], a
ld a, $9 ld a, $9
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
ld a, SPRITE_FACING_UP ld a, SPRITE_FACING_UP
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a
call SetSpriteFacingDirectionAndDelay call SetSpriteFacingDirectionAndDelay
@ -230,7 +230,7 @@ SilphCo7Script4:
ld de, MovementData_51d1a ld de, MovementData_51d1a
.asm_51d0e .asm_51d0e
ld a, $9 ld a, $9
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call MoveSprite call MoveSprite
ld a, $5 ld a, $5
jp SilphCo7Text_51c10 jp SilphCo7Text_51c10

View file

@ -8,7 +8,7 @@ TradeCenter_Script:
.next .next
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [hSpriteIndex], a
call SetSpriteFacingDirection call SetSpriteFacingDirection
ld hl, wd72d ld hl, wd72d
bit 0, [hl] bit 0, [hl]

Some files were not shown because too many files have changed in this diff Show more