diff options
Diffstat (limited to 'engine')
122 files changed, 2034 insertions, 2053 deletions
diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index fcc3c99f..ee476ce9 100755 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -163,7 +163,7 @@ DrawFrameBlock: PlayAnimation: xor a - ld [$FF8B], a ; it looks like nothing reads this + ld [hROMBankTemp], a ; it looks like nothing reads this ld [wSubAnimTransform], a ld a, [wAnimationID] ; get animation number dec a @@ -308,7 +308,7 @@ LoadSubanimation: ; sets the transform to the subanimation type if it's the enemy's turn GetSubanimationTransform1: ld b, a - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld a, b 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 0 (i.e. no transform) if it's the enemy's turn GetSubanimationTransform2: - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld a, 2 << 5 ret z @@ -421,7 +421,7 @@ MoveAnimation: ShareMoveAnimations: ; some moves just reuse animations from status conditions - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ret z @@ -649,7 +649,7 @@ DoSpecialEffectByAnimationId: pop hl ret -INCLUDE "data/move_animation_special_effects.asm" +INCLUDE "data/moves/animation_special_effects.asm" DoBallTossSpecialEffects: ld a, [wcf91] @@ -911,7 +911,7 @@ TailWhipAnimationUnused: ld c, 20 jp DelayFrames -INCLUDE "data/move_animation_pointers.asm" +INCLUDE "data/moves/animation_special_effect_pointers.asm" AnimationDelay10: ld c, 10 @@ -920,16 +920,16 @@ AnimationDelay10: ; calls a function with the turn flipped from player to enemy or vice versa ; input - hl - address of function to call CallWithTurnFlipped: - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] push af xor 1 - ld [H_WHOSETURN], a + ld [hWhoseTurn], a ld de, .returnAddress push de jp hl .returnAddress pop af - ld [H_WHOSETURN], a + ld [hWhoseTurn], a ret ; flashes the screen for an extended period (48 frames) @@ -1133,7 +1133,7 @@ _AnimationWaterDroplets: AnimationSlideMonUp: ; Slides the mon's sprite upwards. ld c, 7 - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a coord hl, 1, 6 coord de, 1, 5 @@ -1201,7 +1201,7 @@ _AnimationSlideMonUp: jr nz, .slideLoop ; 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 coord hl, 1, 11 jr z, .next @@ -1370,7 +1370,7 @@ AnimationShowEnemyMonPic: AnimationShakeBackAndForth: ; Shakes the mon's sprite back and forth rapidly. This is used in Double Team. ; The mon's sprite disappears after this animation. - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a coord hl, 0, 5 coord de, 2, 5 @@ -1418,7 +1418,7 @@ AnimationMoveMonHorizontally: ; Shifts the mon's sprite horizontally to a fixed location. Used by lots of ; animations like Tackle/Body Slam. call AnimationHideMonPic - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a coord hl, 2, 5 jr z, .next @@ -1434,7 +1434,7 @@ AnimationMoveMonHorizontally: AnimationResetMonPosition: ; Resets the mon's sprites to be located at the normal coordinates. - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld a, 5 * SCREEN_WIDTH + 2 jr z, .next @@ -1446,7 +1446,7 @@ AnimationResetMonPosition: AnimationSpiralBallsInward: ; Creates an effect that looks like energy balls spiralling into the ; player mon's sprite. Used in Focus Energy, for example. - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .playerTurn ld a, -40 @@ -1530,7 +1530,7 @@ AnimationSquishMonPic: ld c, 4 .loop push bc - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .playerTurn coord hl, 16, 0 @@ -1583,7 +1583,7 @@ _AnimationSquishMonPic: AnimationShootBallsUpward: ; Shoots one pillar of "energy" balls upwards. Used in Teleport/Sky Attack ; animations. - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .playerTurn lb bc, 0, 16 * 8 @@ -1651,7 +1651,7 @@ _AnimationShootBallsUpward: AnimationShootManyBallsUpward: ; Shoots several pillars of "energy" balls upward. - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld hl, UpwardBallsAnimXCoordinatesPlayerTurn ld a, $50 ; y coordinate for "energy" ball pillar @@ -1735,7 +1735,7 @@ AnimationSlideMonDownAndHide: jr nz, .loop call AnimationHideMonPic ld hl, wTempPic - ld bc, $0310 + ld bc, $310 xor a call FillMemory jp CopyTempPicToMonPic @@ -1743,7 +1743,7 @@ AnimationSlideMonDownAndHide: _AnimationSlideMonOff: ; 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. - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .playerTurn coord hl, 12, 0 @@ -1758,7 +1758,7 @@ _AnimationSlideMonOff: .rowLoop ; iterates once for each row ld c, 8 .tileLoop ; iterates once for each tile in the row - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .playerTurn2 call .EnemyNextTile @@ -1821,7 +1821,7 @@ AnimationSlideMonHalfOff: jp Delay3 CopyTempPicToMonPic: - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld hl, vBackPic ; player turn jr z, .next @@ -1837,7 +1837,7 @@ AnimationWavyScreen: call BattleAnimCopyTileMapToVRAM call Delay3 xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ld a, SCREEN_HEIGHT_PIXELS ld [hWY], a ld d, $80 ; terminator @@ -1865,7 +1865,7 @@ AnimationWavyScreen: call SaveScreenTilesToBuffer2 call ClearScreen ld a, 1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a call Delay3 call LoadScreenTilesFromBuffer2 ld hl, vBGMap1 @@ -1896,9 +1896,9 @@ AnimationSubstitute: ; Changes the pokemon's sprite to the mini sprite ld hl, wTempPic xor a - ld bc, $0310 + ld bc, $310 call FillMemory - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .playerTurn ld hl, SlowbroSprite ; facing down sprite @@ -1932,12 +1932,12 @@ AnimationSubstitute: jp AnimationShowMonPic CopySlowbroSpriteData: - ld bc, $0010 + ld bc, $10 ld a, BANK(SlowbroSprite) jp FarCopyData2 HideSubstituteShowMonAnim: - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld hl, wPlayerMonMinimized ld a, [wPlayerBattleStatus2] @@ -1987,7 +1987,7 @@ AnimationTransformMon: ld [wChangeMonPicEnemyTurnSpecies], a ChangeMonPic: - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .playerTurn ld a, [wChangeMonPicEnemyTurnSpecies] @@ -2020,11 +2020,11 @@ ChangeMonPic: AnimationHideEnemyMonPic: ; Hides the enemy mon's sprite xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ld hl, AnimationHideMonPic call CallWithTurnFlipped ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a jp Delay3 InitMultipleObjectsOAM: @@ -2050,7 +2050,7 @@ InitMultipleObjectsOAM: AnimationHideMonPic: ; Hides the mon's sprite. - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .playerTurn ld a, 12 @@ -2078,7 +2078,7 @@ ClearMonPicFromTileMap: ; in order to show only a portion of the mon sprite. GetMonSpriteTileMapPointerFromRowCount: push de - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr nz, .enemyTurn ld a, 20 * 5 + 1 @@ -2166,7 +2166,7 @@ GetMoveSound: ld b, a call IsCryMove jr nc, .NotCryMove - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr nz, .next ld a, [wBattleMonSpecies] ; get number of current monster @@ -2208,10 +2208,10 @@ IsCryMove: scf ret -INCLUDE "data/move_sfx.asm" +INCLUDE "data/moves/sfx.asm" CopyPicTiles: - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld a, $31 ; base tile ID of player mon sprite jr z, .next @@ -2235,7 +2235,7 @@ CopyDownscaledMonTiles: CopyTileIDs_NoBGTransfer: xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ; fall through ; b = number of rows @@ -2261,7 +2261,7 @@ CopyTileIDs: dec b jr nz, .rowLoop ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a pop hl ret @@ -2624,9 +2624,9 @@ ShakeEnemyHUD_ShakeBG: BattleAnimCopyTileMapToVRAM: ld a, h - ld [H_AUTOBGTRANSFERDEST + 1], a + ld [hAutoBGTransferDest + 1], a ld a, l - ld [H_AUTOBGTRANSFERDEST], a + ld [hAutoBGTransferDest], a jp Delay3 TossBallAnimation: diff --git a/engine/battle/battle_transitions.asm b/engine/battle/battle_transitions.asm index 62b023b0..98e87dc0 100644 --- a/engine/battle/battle_transitions.asm +++ b/engine/battle/battle_transitions.asm @@ -1,6 +1,6 @@ BattleTransition: ld a, 1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a call Delay3 xor a ld [hWY], a @@ -151,7 +151,7 @@ GetBattleTransitionID_IsDungeonMap: res 2, c ret -INCLUDE "data/dungeon_maps.asm" +INCLUDE "data/maps/dungeon_maps.asm" LoadBattleTransitionTile: ld hl, vChars1 + $7f0 @@ -349,7 +349,7 @@ BattleTransition_Shrink: .loop push bc xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a coord hl, 0, 7 coord de, 0, 8 ld bc, -SCREEN_WIDTH * 2 @@ -367,7 +367,7 @@ BattleTransition_Shrink: ld bc, 2 call BattleTransition_CopyTiles2 ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ld c, 6 call DelayFrames pop bc @@ -381,7 +381,7 @@ BattleTransition_Shrink: BattleTransition_Split: ld c, SCREEN_HEIGHT / 2 xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a .loop push bc coord hl, 0, 16 @@ -496,7 +496,7 @@ BattleTransition_VerticalStripes: coord hl, 0, 0 coord de, 1, 17 xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a .loop push bc push hl @@ -535,7 +535,7 @@ BattleTransition_HorizontalStripes: coord hl, 0, 0 coord de, 19, 1 xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a .loop push bc push hl @@ -582,7 +582,7 @@ BattleTransition_FlashScreen: ld b, $3 call BattleTransition_FlashScreen_ xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ret BattleTransition_Circle_Sub1: @@ -601,10 +601,10 @@ BattleTransition_Circle_Sub1: BattleTransition_TransferDelay3: ld a, 1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a call Delay3 xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ret ; used for low level wild non-dungeon battles diff --git a/engine/battle/common_text.asm b/engine/battle/common_text.asm index e541d604..e8998414 100644 --- a/engine/battle/common_text.asm +++ b/engine/battle/common_text.asm @@ -101,16 +101,16 @@ PrintSendOutMonMessage: ld hl, GoText jr z, .printText xor a - ld [H_MULTIPLICAND], a + ld [hMultiplicand], a ld hl, wEnemyMonHP ld a, [hli] ld [wLastSwitchInEnemyMonHP], a - ld [H_MULTIPLICAND + 1], a + ld [hMultiplicand + 1], a ld a, [hl] ld [wLastSwitchInEnemyMonHP + 1], a - ld [H_MULTIPLICAND + 2], a + ld [hMultiplicand + 2], a ld a, 25 - ld [H_MULTIPLIER], a + ld [hMultiplier], a call Multiply ld hl, wEnemyMonMaxHP ld a, [hli] @@ -121,9 +121,9 @@ PrintSendOutMonMessage: rr b ld a, b 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 - 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 cp 70 jr nc, .printText @@ -179,14 +179,14 @@ PlayerMon2Text: dec hl ld a, [de] sub b - ld [H_MULTIPLICAND + 2], a + ld [hMultiplicand + 2], a dec de ld b, [hl] ld a, [de] sbc b - ld [H_MULTIPLICAND + 1], a + ld [hMultiplicand + 1], a ld a, 25 - ld [H_MULTIPLIER], a + ld [hMultiplier], a call Multiply ld hl, wEnemyMonMaxHP ld a, [hli] @@ -197,11 +197,11 @@ PlayerMon2Text: rr b ld a, b ld b, 4 - ld [H_DIVISOR], a + ld [hDivisor], a call Divide pop bc 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, ; a approximates the percentage that the enemy mon's total HP has decreased ; since the last switch in. diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 75841ccf..6881aef5 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -57,7 +57,7 @@ SlidePlayerAndEnemySilhouettesOnScreen: ld [wUpdateSpritesEnabled], a call Delay3 xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ld b, $70 ld c, $90 ld a, c @@ -83,7 +83,7 @@ SlidePlayerAndEnemySilhouettesOnScreen: dec c jr nz, .slideSilhouettesLoop ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ld a, $31 ld [hStartTileID], a coord hl, 1, 5 @@ -92,7 +92,7 @@ SlidePlayerAndEnemySilhouettesOnScreen: ld [hWY], a ld [rWY], a inc a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a call Delay3 ld b, SET_PAL_BATTLE call RunPaletteCommand @@ -266,7 +266,7 @@ EnemyRan: ld a, SFX_RUN call PlaySoundWaitForCurrent xor a - ld [H_WHOSETURN], a + ld [hWhoseTurn], a jpab AnimationSlideEnemyMonOff WildRanText: @@ -412,7 +412,7 @@ MainInBattleLoop: jr .playerMovesFirst .enemyMovesFirst ld a, $1 - ld [H_WHOSETURN], a + ld [hWhoseTurn], a callab TrainerAI jr c, .AIActionUsedEnemyFirst call ExecuteEnemyMove @@ -450,7 +450,7 @@ MainInBattleLoop: jp z, HandlePlayerMonFainted call DrawHUDsAndHPBars ld a, $1 - ld [H_WHOSETURN], a + ld [hWhoseTurn], a callab TrainerAI jr c, .AIActionUsedPlayerFirst call ExecuteEnemyMove @@ -470,7 +470,7 @@ MainInBattleLoop: HandlePoisonBurnLeechSeed: ld hl, wBattleMonHP ld de, wBattleMonStatus - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .playersTurn ld hl, wEnemyMonHP @@ -495,7 +495,7 @@ HandlePoisonBurnLeechSeed: call HandlePoisonBurnLeechSeed_DecreaseOwnHP .notBurnedOrPoisoned ld de, wPlayerBattleStatus2 - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .playersTurn2 ld de, wEnemyBattleStatus2 @@ -504,16 +504,16 @@ HandlePoisonBurnLeechSeed: add a jr nc, .notLeechSeeded push hl - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] push af xor $1 - ld [H_WHOSETURN], a + ld [hWhoseTurn], a xor a ld [wAnimationType], a ld a, ABSORB call PlayMoveAnimation ; play leech seed animation (from opposing mon) pop af - ld [H_WHOSETURN], a + ld [hWhoseTurn], a pop hl call HandlePoisonBurnLeechSeed_DecreaseOwnHP call HandlePoisonBurnLeechSeed_IncreaseEnemyHP @@ -571,7 +571,7 @@ HandlePoisonBurnLeechSeed_DecreaseOwnHP: .nonZeroDamage ld hl, wPlayerBattleStatus3 ld de, wPlayerToxicCounter - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .playersTurn ld hl, wEnemyBattleStatus3 @@ -582,7 +582,7 @@ HandlePoisonBurnLeechSeed_DecreaseOwnHP: ld a, [de] ; increment toxic counter inc a ld [de], a - ld hl, $0000 + ld hl, 0 .toxicTicksLoop add hl, bc dec a @@ -618,7 +618,7 @@ HandlePoisonBurnLeechSeed_DecreaseOwnHP: HandlePoisonBurnLeechSeed_IncreaseEnemyHP: push hl ld hl, wEnemyMonMaxHP - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .playersTurn ld hl, wBattleMonMaxHP @@ -655,19 +655,19 @@ HandlePoisonBurnLeechSeed_IncreaseEnemyHP: ld [hl], a ld [wHPBarNewHP], a .noOverfullHeal - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] xor $1 - ld [H_WHOSETURN], a + ld [hWhoseTurn], a call UpdateCurMonHPBar - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] xor $1 - ld [H_WHOSETURN], a + ld [hWhoseTurn], a pop hl ret UpdateCurMonHPBar: coord hl, 10, 9 ; tile pointer to player HP bar - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld a, $1 jr z, .playersTurn @@ -958,7 +958,7 @@ TrainerDefeatedText: PlayBattleVictoryMusic: push af - ld a, $ff + ld a, SFX_STOP_ALL_MUSIC ld [wNewSoundID], a call PlaySoundWaitForCurrent ld c, BANK(Music_DefeatedTrainer) @@ -1177,7 +1177,7 @@ LinkBattleLostText: db "@" ; 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: ld a, [wd730] push af @@ -1230,7 +1230,7 @@ SevenSpacesText: ; 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) ; 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: ld [hSlideAmount], a ld c, a @@ -1508,29 +1508,29 @@ TryRunningFromBattle: inc a ld [wNumRunAttempts], a ld a, [hli] - ld [H_MULTIPLICAND + 1], a + ld [hMultiplicand + 1], a ld a, [hl] - ld [H_MULTIPLICAND + 2], a + ld [hMultiplicand + 2], a ld a, [de] ld [hEnemySpeed], a inc de ld a, [de] ld [hEnemySpeed + 1], a call LoadScreenTilesFromBuffer1 - ld de, H_MULTIPLICAND + 1 + ld de, hMultiplicand + 1 ld hl, hEnemySpeed ld c, 2 call StringCmp jr nc, .canEscape ; jump if player speed greater than enemy speed xor a - ld [H_MULTIPLICAND], a + ld [hMultiplicand], a ld a, 32 - ld [H_MULTIPLIER], a + ld [hMultiplier], a call Multiply ; multiply player speed by 32 - ld a, [H_PRODUCT + 2] - ld [H_DIVIDEND], a - ld a, [H_PRODUCT + 3] - ld [H_DIVIDEND + 1], a + ld a, [hProduct + 2] + ld [hDividend], a + ld a, [hProduct + 3] + ld [hDividend + 1], a ld a, [hEnemySpeed] ld b, a ld a, [hEnemySpeed + 1] @@ -1541,10 +1541,10 @@ TryRunningFromBattle: rr a and a 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 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? jr nz, .canEscape ; if so, the player can escape ld a, [wNumRunAttempts] @@ -1554,15 +1554,15 @@ TryRunningFromBattle: dec c jr z, .compareWithRandomValue ld b, 30 - ld a, [H_QUOTIENT + 3] + ld a, [hQuotient + 3] add b - ld [H_QUOTIENT + 3], a + ld [hQuotient + 3], a jr c, .canEscape jr .loop .compareWithRandomValue call BattleRandom ld b, a - ld a, [H_QUOTIENT + 3] + ld a, [hQuotient + 3] cp b 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 @@ -1754,7 +1754,7 @@ SendOutMon: ld hl, wEnemyBattleStatus1 res USING_TRAPPING_MOVE, [hl] ld a, $1 - ld [H_WHOSETURN], a + ld [hWhoseTurn], a ld a, POOF_ANIM call PlayMoveAnimation coord hl, 4, 11 @@ -1812,7 +1812,7 @@ DrawHUDsAndHPBars: DrawPlayerHUDAndHPBar: xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a coord hl, 9, 7 lb bc, 5, 11 call ClearScreenArea @@ -1845,7 +1845,7 @@ DrawPlayerHUDAndHPBar: coord hl, 10, 9 predef DrawHP ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ld hl, wPlayerHPBarColor call GetBattleHealthBarColor ld hl, wBattleMonHP @@ -1873,7 +1873,7 @@ DrawPlayerHUDAndHPBar: DrawEnemyHUDAndHPBar: xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a coord hl, 0, 0 lb bc, 4, 12 call ClearScreenArea @@ -1895,9 +1895,9 @@ DrawEnemyHUDAndHPBar: .skipPrintLevel ld hl, wEnemyMonHP ld a, [hli] - ld [H_MULTIPLICAND + 1], a + ld [hMultiplicand + 1], a ld a, [hld] - ld [H_MULTIPLICAND + 2], a + ld [hMultiplicand + 2], a or [hl] ; is current HP zero? jr nz, .hpNonzero ; current HP is 0 @@ -1908,45 +1908,45 @@ DrawEnemyHUDAndHPBar: jp .drawHPBar .hpNonzero xor a - ld [H_MULTIPLICAND], a + ld [hMultiplicand], a ld a, 48 - ld [H_MULTIPLIER], a + ld [hMultiplier], a call Multiply ; multiply current HP by 48 ld hl, wEnemyMonMaxHP ld a, [hli] ld b, a ld a, [hl] - ld [H_DIVISOR], a + ld [hDivisor], a ld a, b and a ; is max HP > 255? 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 ; (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 rr a srl b rr a - ld [H_DIVISOR], a - ld a, [H_PRODUCT + 2] + ld [hDivisor], a + ld a, [hProduct + 2] ld b, a srl b - ld a, [H_PRODUCT + 3] + ld a, [hProduct + 3] rr a srl b rr a - ld [H_PRODUCT + 3], a + ld [hProduct + 3], a ld a, b - ld [H_PRODUCT + 2], a + ld [hProduct + 2], a .doDivide - ld a, [H_PRODUCT + 2] - ld [H_DIVIDEND], a - ld a, [H_PRODUCT + 3] - ld [H_DIVIDEND + 1], a + ld a, [hProduct + 2] + ld [hDividend], a + ld a, [hProduct + 3] + ld [hDividend + 1], a ld a, $2 ld b, a call Divide ; divide (current HP * 48) by max HP - ld a, [H_QUOTIENT + 3] + ld a, [hQuotient + 3] ; set variables for DrawHPBar ld e, a ld a, $6 @@ -1958,7 +1958,7 @@ DrawEnemyHUDAndHPBar: coord hl, 2, 2 call DrawHPBar ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ld hl, wEnemyHPBarColor GetBattleHealthBarColor: @@ -2469,13 +2469,13 @@ MoveSelectionMenu: .writemoves ld de, wMovesString - ld a, [hFlags_0xFFF6] + ld a, [hFlagsFFF6] set 2, a - ld [hFlags_0xFFF6], a + ld [hFlagsFFF6], a call PlaceString - ld a, [hFlags_0xFFF6] + ld a, [hFlagsFFF6] res 2, a - ld [hFlags_0xFFF6], a + ld [hFlagsFFF6], a ret .regularmenu @@ -2595,10 +2595,10 @@ SelectMenuItem: call AddNTimes ld [hl], "▷" .select - ld hl, hFlags_0xFFF6 + ld hl, hFlagsFFF6 set 1, [hl] call HandleMenuInput - ld hl, hFlags_0xFFF6 + ld hl, hFlagsFFF6 res 1, [hl] bit 6, a jp nz, SelectMenuItem_CursorUp ; up @@ -2825,7 +2825,7 @@ SwapMovesInMenu: PrintMenuItem: xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a coord hl, 0, 8 ld b, 3 ld c, 9 @@ -2847,7 +2847,7 @@ PrintMenuItem: ld hl, wCurrentMenuItem dec [hl] xor a - ld [H_WHOSETURN], a + ld [hWhoseTurn], a ld hl, wBattleMonMoves ld a, [wCurrentMenuItem] ld c, a @@ -2891,7 +2891,7 @@ PrintMenuItem: predef PrintMoveType .moveDisabled ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a jp Delay3 DisabledText: @@ -3043,7 +3043,7 @@ LinkBattleExchangeData: ExecutePlayerMove: xor a - ld [H_WHOSETURN], a ; set player's turn + ld [hWhoseTurn], a ; set player's turn ld a, [wPlayerSelectedMove] inc a jp z, ExecutePlayerMoveDone ; for selected move = FF, skip most of player's turn @@ -3252,7 +3252,7 @@ PrintGhostText: ; print the ghost battle messages call IsGhostBattle ret nz - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr nz, .Ghost ld a, [wBattleMonStatus] ; player’s turn @@ -3619,7 +3619,7 @@ CantMoveText: PrintMoveIsDisabledText: ld hl, wPlayerSelectedMove ld de, wPlayerBattleStatus1 - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .removeChargingUp inc hl @@ -3675,11 +3675,11 @@ HandleSelfConfusionDamage: xor a ld [wAnimationType], a inc a - ld [H_WHOSETURN], a + ld [hWhoseTurn], a call PlayMoveAnimation call DrawPlayerHUDAndHPBar xor a - ld [H_WHOSETURN], a + ld [hWhoseTurn], a jp ApplyDamageToPlayerPokemon PrintMonName1Text: @@ -3694,7 +3694,7 @@ PrintMonName1Text: MonName1Text: TX_FAR _MonName1Text TX_ASM - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld a, [wPlayerMoveNum] ld hl, wPlayerUsedMove @@ -3814,11 +3814,11 @@ DetermineExclamationPointTextNum: pop bc ret -INCLUDE "data/move_grammar.asm" +INCLUDE "data/moves/grammar.asm" PrintMoveFailureText: ld de, wPlayerMoveEffect - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .playersTurn ld de, wEnemyMoveEffect @@ -3866,7 +3866,7 @@ PrintMoveFailureText: call PrintText ld b, $4 predef PredefShakeScreenHorizontally - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr nz, .enemyTurn jp ApplyDamageToPlayerPokemon @@ -4139,7 +4139,7 @@ GetDamageVarsForPlayerAttack: ld d, a ; d = move power ret z ; return if move power is zero ld a, [hl] ; a = [wPlayerMoveType] - cp FIRE ; types >= FIRE are all special + cp SPECIAL ; types >= SPECIAL are all special jr nc, .specialAttack .physicalAttack ld hl, wEnemyMonDefense @@ -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 ld c, 3 ; defense stat call GetEnemyMonStat - ld a, [H_PRODUCT + 2] + ld a, [hProduct + 2] ld b, a - ld a, [H_PRODUCT + 3] + ld a, [hProduct + 3] ld c, a push bc 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 ld c, 5 ; special stat call GetEnemyMonStat - ld a, [H_PRODUCT + 2] + ld a, [hProduct + 2] ld b, a - ld a, [H_PRODUCT + 3] + ld a, [hProduct + 3] ld c, a push bc ld hl, wPartyMon1Special @@ -4252,7 +4252,7 @@ GetDamageVarsForEnemyAttack: and a ret z ; return if move power is zero ld a, [hl] ; a = [wEnemyMoveType] - cp FIRE ; types >= FIRE are all special + cp SPECIAL ; types >= SPECIAL are all special jr nc, .specialAttack .physicalAttack ld hl, wBattleMonDefense @@ -4281,7 +4281,7 @@ GetDamageVarsForEnemyAttack: push bc ld c, 2 ; attack stat call GetEnemyMonStat - ld hl, H_PRODUCT + 2 + ld hl, hProduct + 2 pop bc jr .scaleStats .specialAttack @@ -4313,7 +4313,7 @@ GetDamageVarsForEnemyAttack: push bc ld c, 5 ; special stat call GetEnemyMonStat - ld hl, H_PRODUCT + 2 + ld hl, hProduct + 2 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 ; this allows values with up to 10 bits (values up to 1023) to be handled @@ -4371,9 +4371,9 @@ GetEnemyMonStat: ld bc, wEnemyMon2 - wEnemyMon1 call AddNTimes ld a, [hli] - ld [H_MULTIPLICAND + 1], a + ld [hMultiplicand + 1], a ld a, [hl] - ld [H_MULTIPLICAND + 2], a + ld [hMultiplicand + 2], a pop bc pop de ret @@ -4404,7 +4404,7 @@ CalculateDamage: ; d: base power ; e: level - ld a, [H_WHOSETURN] ; whose turn? + ld a, [hWhoseTurn] ; whose turn? and a ld a, [wPlayerMoveEffect] jr z, .effect @@ -4436,7 +4436,7 @@ CalculateDamage: .skipbp xor a - ld hl, H_DIVIDEND + ld hl, hDividend ldi [hl], a ldi [hl], a ld [hl], a @@ -4487,41 +4487,41 @@ CalculateDamage: ld hl, wDamage ld b, [hl] - ld a, [H_QUOTIENT + 3] + ld a, [hQuotient + 3] add b - ld [H_QUOTIENT + 3], a + ld [hQuotient + 3], a jr nc, .asm_3dfd0 - ld a, [H_QUOTIENT + 2] + ld a, [hQuotient + 2] inc a - ld [H_QUOTIENT + 2], a + ld [hQuotient + 2], a and a jr z, .asm_3e004 .asm_3dfd0 - ld a, [H_QUOTIENT] + ld a, [hQuotient] ld b, a - ld a, [H_QUOTIENT + 1] + ld a, [hQuotient + 1] or a jr nz, .asm_3e004 - ld a, [H_QUOTIENT + 2] + ld a, [hQuotient + 2] cp 998 / $100 jr c, .asm_3dfe8 cp 998 / $100 + 1 jr nc, .asm_3e004 - ld a, [H_QUOTIENT + 3] + ld a, [hQuotient + 3] cp 998 % $100 jr nc, .asm_3e004 .asm_3dfe8 inc hl - ld a, [H_QUOTIENT + 3] + ld a, [hQuotient + 3] ld b, [hl] add b ld [hld], a - ld a, [H_QUOTIENT + 2] + ld a, [hQuotient + 2] ld b, [hl] adc b ld [hl], a @@ -4573,7 +4573,7 @@ INCLUDE "data/battle/unused_critical_hit_moves.asm" CriticalHitTest: xor a ld [wCriticalHitOrOHKO], a - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld a, [wEnemyMonSpecies] jr nz, .handleEnemy @@ -4584,7 +4584,7 @@ CriticalHitTest: ld a, [wMonHBaseSpeed] ld b, a srl b ; (effective (base speed/2)) - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld hl, wPlayerMovePower 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. ; This might also lead to desync glitches in link battles. - ld a, [H_WHOSETURN] ; whose turn + ld a, [hWhoseTurn] ; whose turn and a ; player's turn ld hl, wEnemySelectedMove @@ -4954,7 +4954,7 @@ AttackSubstitute: ; values for player turn ld de, wEnemySubstituteHP ld bc, wEnemyBattleStatus2 - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .applyDamageToSubstitute ; values for enemy turn @@ -4979,14 +4979,14 @@ AttackSubstitute: ld hl, SubstituteBrokeText call PrintText ; flip whose turn it is for the next function call - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] xor $01 - ld [H_WHOSETURN], a + ld [hWhoseTurn], a callab HideSubstituteShowMonAnim ; animate the substitute breaking ; flip the turn back to the way it was - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] xor $01 - ld [H_WHOSETURN], a + ld [hWhoseTurn], a ld hl, wPlayerMoveEffect ; value for player's turn and a jr z, .nullifyEffect @@ -5010,7 +5010,7 @@ HandleBuildingRage: ld hl, wEnemyBattleStatus2 ld de, wEnemyMonStatMods ld bc, wEnemyMoveNum - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .next ; values for the enemy turn @@ -5023,9 +5023,9 @@ HandleBuildingRage: ld a, [de] cp $0d ; maximum stat modifier value 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 - ld [H_WHOSETURN], a + ld [hWhoseTurn], a ; 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 ld h, b @@ -5042,9 +5042,9 @@ HandleBuildingRage: ldd [hl], a ; null move effect ld a, 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 - ld [H_WHOSETURN], a + ld [hWhoseTurn], a ret BuildingRageText: @@ -5060,7 +5060,7 @@ MirrorMoveCopyMove: ; 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. - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ; values for player turn ld a, [wEnemyUsedMove] @@ -5113,7 +5113,7 @@ MetronomePickMove: ; values for player turn ld de, wPlayerMoveNum ld hl, wPlayerSelectedMove - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .pickMoveLoop ; values for enemy turn @@ -5135,7 +5135,7 @@ MetronomePickMove: ; it's used to prevent moves that run another move within the same turn ; (like Mirror Move and Metronome) from losing 2 PP IncrementMovePP: - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ; values for player turn ld hl, wBattleMonPP @@ -5154,7 +5154,7 @@ IncrementMovePP: ld h, d ld l, e add hl, bc - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld a, [wPlayerMonNumber] ; value for player turn jr z, .updatePP @@ -5178,7 +5178,7 @@ AdjustDamageForMoveType: ld e, [hl] ; e = type 2 of defender ld a, [wPlayerMoveType] ld [wMoveType], a - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .next ; values for enemy turn @@ -5242,25 +5242,25 @@ AdjustDamageForMoveType: and $80 ld b, a ld a, [hl] ; a = damage multiplier - ld [H_MULTIPLIER], a + ld [hMultiplier], a add b ld [wDamageMultipliers], a xor a - ld [H_MULTIPLICAND], a + ld [hMultiplicand], a ld hl, wDamage ld a, [hli] - ld [H_MULTIPLICAND + 1], a + ld [hMultiplicand + 1], a ld a, [hld] - ld [H_MULTIPLICAND + 2], a + ld [hMultiplicand + 2], a call Multiply ld a, 10 - ld [H_DIVISOR], a + ld [hDivisor], a ld b, $04 call Divide - ld a, [H_QUOTIENT + 2] + ld a, [hQuotient + 2] ld [hli], a ld b, a - ld a, [H_QUOTIENT + 3] + ld a, [hQuotient + 3] ld [hl], a or b ; is damage 0? jr nz, .skipTypeImmunity @@ -5317,7 +5317,7 @@ AIGetTypeEffectiveness: ld [wTypeEffectiveness], a ; store damage multiplier ret -INCLUDE "data/type_effects.asm" +INCLUDE "data/types/type_matchups.asm" ; some tests that need to pass for a move to hit MoveHitTest: @@ -5325,7 +5325,7 @@ MoveHitTest: ld hl, wEnemyBattleStatus1 ld de, wPlayerMoveEffect ld bc, wEnemyMonStatus - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .dreamEaterCheck ; enemy's turn @@ -5345,8 +5345,8 @@ MoveHitTest: ret z ; Swift never misses (interestingly, Azure Heights lists this is a myth, but it appears to be true) call CheckTargetSubstitute ; substitute check (note that this overwrites a) jr z, .checkForDigOrFlyStatus -; this code is buggy. it's supposed to prevent HP draining moves from working on substitutes. -; since $7b79 overwrites a with either $00 or $01, it never works. +; This code is buggy. It's supposed to prevent HP draining moves from working on substitutes. +; Since CheckTargetSubstitute overwrites a with either $00 or $01, it never works. cp DRAIN_HP_EFFECT jp z, .moveMissed cp DREAM_EATER_EFFECT @@ -5354,7 +5354,7 @@ MoveHitTest: .checkForDigOrFlyStatus bit INVULNERABLE, [hl] jp nz, .moveMissed - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr nz, .enemyTurn .playerTurn @@ -5408,7 +5408,7 @@ MoveHitTest: call CalcHitChance ; scale the move accuracy according to attacker's accuracy and target's evasion ld a, [wPlayerMoveAccuracy] ld b, a - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .doAccuracyCheck ld a, [wEnemyMoveAccuracy] @@ -5427,7 +5427,7 @@ MoveHitTest: ld [hl], a inc a ld [wMoveMissed], a - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .playerTurn2 .enemyTurn2 @@ -5442,7 +5442,7 @@ MoveHitTest: ; values for player turn CalcHitChance: ld hl, wPlayerMoveAccuracy - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld a, [wPlayerMonAccuracyMod] ld b, a @@ -5462,10 +5462,10 @@ CalcHitChance: ; decreases the hit chance instead of increasing the hit chance) ; zero the high bytes of the multiplicand xor a - ld [H_MULTIPLICAND], a - ld [H_MULTIPLICAND + 1], a + ld [hMultiplicand], a + ld [hMultiplicand + 1], a ld a, [hl] - ld [H_MULTIPLICAND + 2], a ; set multiplicand to move accuracy + ld [hMultiplicand + 2], a ; set multiplicand to move accuracy push hl ld d, $02 ; loop has two iterations ; 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 pop bc 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 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) ld b, $04 ; number of bytes in the dividend call Divide - ld a, [H_QUOTIENT + 3] + ld a, [hQuotient + 3] ld b, a - ld a, [H_QUOTIENT + 2] + ld a, [hQuotient + 2] or b jp nz, .nextCalculation ; make sure the result is always at least one - ld [H_QUOTIENT + 2], a + ld [hQuotient + 2], a ld a, $01 - ld [H_QUOTIENT + 3], a + ld [hQuotient + 3], a .nextCalculation ld b, c dec d jr nz, .loop - ld a, [H_QUOTIENT + 2] + ld a, [hQuotient + 2] and a ; is the calculated hit chance over 0xFF? - ld a, [H_QUOTIENT + 3] + ld a, [hQuotient + 3] jr z, .storeAccuracy ; if calculated hit chance over 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 .DamageGreaterThanOne xor a - ld [H_MULTIPLICAND], a + ld [hMultiplicand], a dec hl ld a, [hli] - ld [H_MULTIPLICAND + 1], a + ld [hMultiplicand + 1], a 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 call BattleRandom rrca cp 217 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] ld a, 255 - ld [H_DIVISOR], a + ld [hDivisor], a ld b, $4 call Divide ; divide the result by 255 ; store the modified damage - ld a, [H_QUOTIENT + 2] + ld a, [hQuotient + 2] ld hl, wDamage ld [hli], a - ld a, [H_QUOTIENT + 3] + ld a, [hQuotient + 3] ld [hl], a ret @@ -5900,11 +5900,11 @@ CheckEnemyStatusConditions: ld [hl], a xor a ld [wAnimationType], a - ld [H_WHOSETURN], a + ld [hWhoseTurn], a ld a, POUND call PlayMoveAnimation ld a, $1 - ld [H_WHOSETURN], a + ld [hWhoseTurn], a call ApplyDamageToEnemyPokemon jr .monHurtItselfOrFullyParalysed .checkIfTriedToUseDisabledMove @@ -6051,7 +6051,7 @@ CheckEnemyStatusConditions: ret GetCurrentMove: - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jp z, .player ld de, wEnemyMoveNum @@ -6257,13 +6257,13 @@ DoBattleTransitionAndInitBattleVariables: predef BattleTransition callab LoadHudAndHpBarAndStatusTilePatterns ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ld a, $ff ld [wUpdateSpritesEnabled], a call ClearSprites call ClearScreen xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ld [hWY], a ld [rWY], a ld [hTilesetType], a @@ -6335,17 +6335,17 @@ LoadPlayerBackPic: ld de, vBackPic call InterlaceMergeSpriteBuffers ld a, $a - ld [$0], a + ld [MBC1SRamEnable], a xor a - ld [$4000], a + ld [MBC1SRamBank], a ld hl, vSprites ld de, sSpriteBuffer1 - ld a, [H_LOADEDROMBANK] + ld a, [hLoadedROMBank] ld b, a ld c, 7 * 7 call CopyVideoData xor a - ld [$0], a + ld [MBC1SRamEnable], a ld a, $31 ld [hStartTileID], a coord hl, 1, 5 @@ -6367,12 +6367,12 @@ ApplyBurnAndParalysisPenaltiesToEnemy: xor a ApplyBurnAndParalysisPenalties: - ld [H_WHOSETURN], a + ld [hWhoseTurn], a call QuarterSpeedDueToParalysis jp HalveAttackDueToBurn QuarterSpeedDueToParalysis: - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .playerTurn .enemyTurn ; quarter the player's speed @@ -6415,7 +6415,7 @@ QuarterSpeedDueToParalysis: ret HalveAttackDueToBurn: - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .playerTurn .enemyTurn ; halve the player's attack @@ -6505,35 +6505,35 @@ CalculateModifiedStat: ld b, 0 add hl, bc xor a - ld [H_MULTIPLICAND], a + ld [hMultiplicand], a ld a, [de] - ld [H_MULTIPLICAND + 1], a + ld [hMultiplicand + 1], a inc de ld a, [de] - ld [H_MULTIPLICAND + 2], a + ld [hMultiplicand + 2], a ld a, [hli] - ld [H_MULTIPLIER], a + ld [hMultiplier], a call Multiply ld a, [hl] - ld [H_DIVISOR], a + ld [hDivisor], a ld b, $4 call Divide pop hl - ld a, [H_DIVIDEND + 3] + ld a, [hDividend + 3] sub 999 % $100 - ld a, [H_DIVIDEND + 2] + ld a, [hDividend + 2] sbc 999 / $100 jp c, .storeNewStatValue ; cap the stat at 999 ld a, 999 / $100 - ld [H_DIVIDEND + 2], a + ld [hDividend + 2], a ld a, 999 % $100 - ld [H_DIVIDEND + 3], a + ld [hDividend + 3], a .storeNewStatValue - ld a, [H_DIVIDEND + 2] + ld a, [hDividend + 2] ld [hli], a ld b, a - ld a, [H_DIVIDEND + 3] + ld a, [hDividend + 3] ld [hl], a or b jr nz, .done @@ -6683,7 +6683,7 @@ BattleRandom: HandleExplodingAnimation: - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld hl, wEnemyMonType1 ld de, wEnemyBattleStatus1 @@ -6826,18 +6826,18 @@ _InitBattleCommon: call RunPaletteCommand call SlidePlayerAndEnemySilhouettesOnScreen xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ld hl, .emptyString call PrintText call SaveScreenTilesToBuffer1 call ClearScreen ld a, $98 - ld [H_AUTOBGTRANSFERDEST + 1], a + ld [hAutoBGTransferDest + 1], a ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a call Delay3 ld a, $9c - ld [H_AUTOBGTRANSFERDEST + 1], a + ld [hAutoBGTransferDest + 1], a call LoadScreenTilesFromBuffer1 coord hl, 9, 7 lb bc, 5, 10 @@ -6870,9 +6870,9 @@ _LoadTrainerPic: ld d, a ; de contains pointer to trainer pic ld a, [wLinkState] and a - ld a, Bank(TrainerPics) ; this is where all the trainer pics are (not counting Red's) + ld a, BANK(TrainerPics) ; this is where all the trainer pics are (not counting Red's) jr z, .loadSprite - ld a, Bank(RedPicFront) + ld a, BANK(RedPicFront) .loadSprite call UncompressSpriteFromDE ld de, vFrontPic @@ -6998,6 +6998,6 @@ LoadMonBackPic: ld hl, vSprites ld de, vBackPic ld c, (2*SPRITEBUFFERSIZE)/16 ; count of 16-byte chunks to be copied - ld a, [H_LOADEDROMBANK] + ld a, [hLoadedROMBank] ld b, a jp CopyVideoData diff --git a/engine/battle/effects.asm b/engine/battle/effects.asm index 8bb22a1c..0a1eb61c 100644 --- a/engine/battle/effects.asm +++ b/engine/battle/effects.asm @@ -4,7 +4,7 @@ JumpMoveEffect: ret _JumpMoveEffect: - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld a, [wPlayerMoveEffect] jr z, .next1 @@ -21,12 +21,12 @@ _JumpMoveEffect: ld l, a jp hl ; jump to special effect handler -INCLUDE "data/effects_pointers.asm" +INCLUDE "data/moves/effects_pointers.asm" SleepEffect: ld de, wEnemyMonStatus ld bc, wEnemyBattleStatus2 - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jp z, .sleepEffect ld de, wBattleMonStatus @@ -78,7 +78,7 @@ AlreadyAsleepText: PoisonEffect: ld hl, wEnemyMonStatus ld de, wPlayerMoveEffect - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .poisonEffect ld hl, wBattleMonStatus @@ -121,7 +121,7 @@ PoisonEffect: set 3, [hl] ; mon is now poisoned push de dec de - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld b, ANIM_C7 ld hl, wPlayerBattleStatus3 @@ -175,7 +175,7 @@ DrainHPEffect: ExplodeEffect: ld hl, wBattleMonHP ld de, wPlayerBattleStatus2 - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .faintUser ld hl, wEnemyMonHP @@ -196,7 +196,7 @@ FreezeBurnParalyzeEffect: ld [wAnimationType], a 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 - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jp nz, opponentAttacker 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 and 1 << FRZ ; are they frozen? ret z ; return if so - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr nz, .opponent ;player [attacker] @@ -346,7 +346,7 @@ FireDefrostedText: StatModifierUpEffect: ld hl, wPlayerMonStatMods ld de, wPlayerMoveEffect - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .statModifierUpEffect ld hl, wEnemyMonStatMods @@ -382,7 +382,7 @@ StatModifierUpEffect: push hl ld hl, wBattleMonAttack + 1 ld de, wPlayerMonUnmodifiedAttack - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .pointToStats ld hl, wEnemyMonAttack + 1 @@ -417,35 +417,35 @@ StatModifierUpEffect: add hl, bc pop bc xor a - ld [H_MULTIPLICAND], a + ld [hMultiplicand], a ld a, [de] - ld [H_MULTIPLICAND + 1], a + ld [hMultiplicand + 1], a inc de ld a, [de] - ld [H_MULTIPLICAND + 2], a + ld [hMultiplicand + 2], a ld a, [hli] - ld [H_MULTIPLIER], a + ld [hMultiplier], a call Multiply ld a, [hl] - ld [H_DIVISOR], a + ld [hDivisor], a ld b, $4 call Divide pop hl ; cap at 999 - ld a, [H_PRODUCT + 3] + ld a, [hProduct + 3] sub 999 % $100 - ld a, [H_PRODUCT + 2] + ld a, [hProduct + 2] sbc 999 / $100 jp c, UpdateStat ld a, 999 / $100 - ld [H_MULTIPLICAND + 1], a + ld [hMultiplicand + 1], a ld a, 999 % $100 - ld [H_MULTIPLICAND + 2], a + ld [hMultiplicand + 2], a UpdateStat: - ld a, [H_PRODUCT + 2] + ld a, [hProduct + 2] ld [hli], a - ld a, [H_PRODUCT + 3] + ld a, [hProduct + 3] ld [hl], a pop hl UpdateStatDone: @@ -455,7 +455,7 @@ UpdateStatDone: ld hl, wPlayerBattleStatus2 ld de, wPlayerMoveNum ld bc, wPlayerMonMinimized - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .asm_3f4e6 ld hl, wEnemyBattleStatus2 @@ -488,7 +488,7 @@ UpdateStatDone: pop af call nz, Bankswitch .applyBadgeBoostsAndStatusPenalties - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a 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) @@ -511,7 +511,7 @@ MonsStatsRoseText: TX_FAR _MonsStatsRoseText TX_ASM ld hl, GreatlyRoseText - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld a, [wPlayerMoveEffect] jr z, .playerTurn @@ -534,7 +534,7 @@ StatModifierDownEffect: ld hl, wEnemyMonStatMods ld de, wPlayerMoveEffect ld bc, wEnemyBattleStatus1 - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .statModifierDownEffect ld hl, wPlayerMonStatMods @@ -601,7 +601,7 @@ StatModifierDownEffect: push de ld hl, wEnemyMonAttack + 1 ld de, wEnemyMonUnmodifiedAttack - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .pointToStat ld hl, wBattleMonAttack + 1 @@ -637,33 +637,33 @@ StatModifierDownEffect: add hl, bc pop bc xor a - ld [H_MULTIPLICAND], a + ld [hMultiplicand], a ld a, [de] - ld [H_MULTIPLICAND + 1], a + ld [hMultiplicand + 1], a inc de ld a, [de] - ld [H_MULTIPLICAND + 2], a + ld [hMultiplicand + 2], a ld a, [hli] - ld [H_MULTIPLIER], a + ld [hMultiplier], a call Multiply ld a, [hl] - ld [H_DIVISOR], a + ld [hDivisor], a ld b, $4 call Divide pop hl - ld a, [H_PRODUCT + 3] + ld a, [hProduct + 3] ld b, a - ld a, [H_PRODUCT + 2] + ld a, [hProduct + 2] or b jp nz, UpdateLoweredStat - ld [H_MULTIPLICAND + 1], a + ld [hMultiplicand + 1], a ld a, $1 - ld [H_MULTIPLICAND + 2], a + ld [hMultiplicand + 2], a UpdateLoweredStat: - ld a, [H_PRODUCT + 2] + ld a, [hProduct + 2] ld [hli], a - ld a, [H_PRODUCT + 3] + ld a, [hProduct + 3] ld [hl], a pop de pop hl @@ -678,7 +678,7 @@ UpdateLoweredStatDone: jr nc, .ApplyBadgeBoostsAndStatusPenalties call PlayCurrentMoveAnimation2 .ApplyBadgeBoostsAndStatusPenalties - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a 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) @@ -713,7 +713,7 @@ MonsStatsFellText: TX_FAR _MonsStatsFellText TX_ASM ld hl, FellText - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld a, [wPlayerMoveEffect] jr z, .playerTurn @@ -751,7 +751,7 @@ PrintStatText: ld bc, $a jp CopyData -INCLUDE "text/stat_names.asm" +INCLUDE "data/battle/stat_names.asm" INCLUDE "data/battle/stat_modifiers.asm" @@ -759,7 +759,7 @@ BideEffect: ld hl, wPlayerBattleStatus1 ld de, wPlayerBideAccumulatedDamage ld bc, wPlayerNumAttacksLeft - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .bideEffect ld hl, wEnemyBattleStatus1 @@ -778,14 +778,14 @@ BideEffect: inc a inc a ld [bc], a ; set Bide counter to 2 or 3 at random - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] add XSTATITEM_ANIM jp PlayBattleAnimation2 ThrashPetalDanceEffect: ld hl, wPlayerBattleStatus1 ld de, wPlayerNumAttacksLeft - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .thrashPetalDanceEffect ld hl, wEnemyBattleStatus1 @@ -797,12 +797,12 @@ ThrashPetalDanceEffect: inc a inc a ld [de], a ; set thrash/petal dance counter to 2 or 3 at random - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] add ANIM_B0 jp PlayBattleAnimation2 SwitchAndTeleportEffect: - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr nz, .handleEnemy ld a, [wIsInBattle] @@ -920,7 +920,7 @@ TwoToFiveAttacksEffect: ld hl, wPlayerBattleStatus1 ld de, wPlayerNumAttacksLeft ld bc, wPlayerNumHits - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .twoToFiveAttacksEffect ld hl, wEnemyBattleStatus1 @@ -931,7 +931,7 @@ TwoToFiveAttacksEffect: ret nz set ATTACKING_MULTIPLE_TIMES, [hl] ; mon is now attacking multiple times ld hl, wPlayerMoveEffect - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .setNumberOfHits ld hl, wEnemyMoveEffect @@ -967,7 +967,7 @@ FlinchSideEffect: ret nz ld hl, wEnemyBattleStatus1 ld de, wPlayerMoveEffect - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .flinchSideEffect ld hl, wPlayerBattleStatus1 @@ -992,7 +992,7 @@ OneHitKOEffect: ChargeEffect: ld hl, wPlayerBattleStatus1 ld de, wPlayerMoveEffect - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld b, XSTATITEM_ANIM jr z, .chargeEffect @@ -1074,7 +1074,7 @@ DugAHoleText: TrappingEffect: ld hl, wPlayerBattleStatus1 ld de, wPlayerNumAttacksLeft - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .trappingEffect ld hl, wEnemyBattleStatus1 @@ -1120,7 +1120,7 @@ ConfusionEffect: jr nz, ConfusionEffectFailed ConfusionSideEffectSuccess: - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld hl, wEnemyBattleStatus1 ld bc, wEnemyConfusedCounter @@ -1164,7 +1164,7 @@ SubstituteEffect: HyperBeamEffect: ld hl, wPlayerBattleStatus2 - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .hyperBeamEffect ld hl, wEnemyBattleStatus2 @@ -1175,7 +1175,7 @@ HyperBeamEffect: ClearHyperBeam: push hl ld hl, wEnemyBattleStatus2 - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .playerTurn ld hl, wPlayerBattleStatus2 @@ -1186,7 +1186,7 @@ ClearHyperBeam: RageEffect: ld hl, wPlayerBattleStatus2 - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .player ld hl, wEnemyBattleStatus2 @@ -1201,7 +1201,7 @@ MimicEffect: ld a, [wMoveMissed] and a jr nz, .mimicMissed - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld hl, wBattleMonMoves ld a, [wPlayerBattleStatus1] @@ -1226,7 +1226,7 @@ MimicEffect: and a jr z, .getRandomMove ld d, a - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld hl, wBattleMonMoves ld a, [wPlayerMoveListIndex] @@ -1284,7 +1284,7 @@ DisableEffect: jr nz, .moveMissed ld de, wEnemyDisabledMove ld hl, wEnemyMonMoves - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .disableEffect ld de, wPlayerDisabledMove @@ -1307,7 +1307,7 @@ DisableEffect: jr z, .pickMoveToDisable ; loop until a non-00 move slot is found ld [wd11e], a ; store move number push hl - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld hl, wBattleMonPP jr nz, .enemyTurn @@ -1345,7 +1345,7 @@ DisableEffect: ld [de], a call PlayCurrentMoveAnimation2 ld hl, wPlayerDisabledMoveNumber - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr nz, .printDisableText inc hl ; wEnemyDisabledMoveNumber @@ -1430,7 +1430,7 @@ ParalyzedMayNotAttackText: CheckTargetSubstitute: push hl ld hl, wEnemyBattleStatus2 - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .next1 ld hl, wPlayerBattleStatus2 @@ -1442,7 +1442,7 @@ CheckTargetSubstitute: PlayCurrentMoveAnimation2: ; animation at MOVENUM will be played unless MOVENUM is 0 ; plays wAnimationType 3 or 6 - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld a, [wPlayerMoveNum] jr z, .notEnemyTurn @@ -1454,7 +1454,7 @@ PlayCurrentMoveAnimation2: PlayBattleAnimation2: ; play animation ID at a and animation type 6 or 3 ld [wAnimationID], a - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld a, $6 jr z, .storeAnimationType @@ -1468,7 +1468,7 @@ PlayCurrentMoveAnimation: ; resets wAnimationType xor a ld [wAnimationType], a - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld a, [wPlayerMoveNum] jr z, .notEnemyTurn diff --git a/engine/battle/experience.asm b/engine/battle/experience.asm index 24748338..c628ae32 100644 --- a/engine/battle/experience.asm +++ b/engine/battle/experience.asm @@ -55,15 +55,15 @@ GainExperience: jr .gainStatExpLoop .statExpDone xor a - ld [H_MULTIPLICAND], a - ld [H_MULTIPLICAND + 1], a + ld [hMultiplicand], a + ld [hMultiplicand + 1], a ld a, [wEnemyMonBaseExp] - ld [H_MULTIPLICAND + 2], a + ld [hMultiplicand + 2], a ld a, [wEnemyMonLevel] - ld [H_MULTIPLIER], a + ld [hMultiplier], a call Multiply ld a, 7 - ld [H_DIVISOR], a + ld [hDivisor], a ld b, 4 call Divide ld hl, wPartyMon1OTID - (wPartyMon1DVs - 1) @@ -91,12 +91,12 @@ GainExperience: inc hl ; add the gained exp to the party mon's exp ld b, [hl] - ld a, [H_QUOTIENT + 3] + ld a, [hQuotient + 3] ld [wExpAmountGained + 1], a add b ld [hld], a ld b, [hl] - ld a, [H_QUOTIENT + 2] + ld a, [hQuotient + 2] ld [wExpAmountGained], a adc b ld [hl], a @@ -311,14 +311,14 @@ DivideExpDataByNumMonsGainingExp: ld c, wEnemyMonBaseExp + 1 - wEnemyMonBaseStats .divideLoop xor a - ld [H_DIVIDEND], a + ld [hDividend], a ld a, [hl] - ld [H_DIVIDEND + 1], a + ld [hDividend + 1], a ld a, [wd11e] - ld [H_DIVISOR], a + ld [hDivisor], a ld b, $2 call Divide ; divide value by number of mons gaining exp - ld a, [H_QUOTIENT + 3] + ld a, [hQuotient + 3] ld [hli], a dec c jr nz, .divideLoop @@ -326,17 +326,17 @@ DivideExpDataByNumMonsGainingExp: ; multiplies exp by 1.5 BoostExp: - ld a, [H_QUOTIENT + 2] + ld a, [hQuotient + 2] ld b, a - ld a, [H_QUOTIENT + 3] + ld a, [hQuotient + 3] ld c, a srl b rr c add c - ld [H_QUOTIENT + 3], a - ld a, [H_QUOTIENT + 2] + ld [hQuotient + 3], a + ld a, [hQuotient + 2] adc b - ld [H_QUOTIENT + 2], a + ld [hQuotient + 2], a ret GainedText: diff --git a/engine/battle/ghost_marowak_anim.asm b/engine/battle/ghost_marowak_anim.asm index 7adb20d8..28f536ca 100644 --- a/engine/battle/ghost_marowak_anim.asm +++ b/engine/battle/ghost_marowak_anim.asm @@ -9,12 +9,12 @@ MarowakAnim: call ClearScreenArea call Delay3 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 ld a, MAROWAK ld [wChangeMonPicEnemyTurnSpecies], a ld a, $1 - ld [H_WHOSETURN], a + ld [hWhoseTurn], a callab ChangeMonPic ; alternate between black and light grey 8 times. ; this makes the ghost's body appear to flash @@ -44,7 +44,7 @@ MarowakAnim: and a jr nz, .fadeInMarowakLoop 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 jp ClearSprites diff --git a/engine/battle/move_effects/conversion.asm b/engine/battle/move_effects/conversion.asm index f23c3d70..8c41f914 100644 --- a/engine/battle/move_effects/conversion.asm +++ b/engine/battle/move_effects/conversion.asm @@ -1,7 +1,7 @@ ConversionEffect_: ld hl, wEnemyMonType1 ld de, wBattleMonType1 - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld a, [wEnemyBattleStatus1] jr z, .conversionEffect diff --git a/engine/battle/move_effects/drain_hp.asm b/engine/battle/move_effects/drain_hp.asm index e5f4681a..60d23a95 100644 --- a/engine/battle/move_effects/drain_hp.asm +++ b/engine/battle/move_effects/drain_hp.asm @@ -14,7 +14,7 @@ DrainHPEffect_: .getAttackerHP ld hl, wBattleMonHP ld de, wBattleMonMaxHP - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jp z, .addDamageToAttackerHP ld hl, wEnemyMonHP @@ -69,7 +69,7 @@ DrainHPEffect_: ld [wHPBarNewHP+1], a inc de .next - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a coord hl, 10, 9 ld a, $1 @@ -83,7 +83,7 @@ DrainHPEffect_: predef DrawEnemyHUDAndHPBar callab ReadPlayerMonCurHPAndStatus ld hl, SuckedHealthText - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld a, [wPlayerMoveEffect] jr z, .next3 diff --git a/engine/battle/move_effects/focus_energy.asm b/engine/battle/move_effects/focus_energy.asm index 16dad7bb..af4a6521 100644 --- a/engine/battle/move_effects/focus_energy.asm +++ b/engine/battle/move_effects/focus_energy.asm @@ -1,6 +1,6 @@ FocusEnergyEffect_: ld hl, wPlayerBattleStatus2 - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .notEnemy ld hl, wEnemyBattleStatus2 diff --git a/engine/battle/move_effects/haze.asm b/engine/battle/move_effects/haze.asm index 47723ba2..bd73d249 100644 --- a/engine/battle/move_effects/haze.asm +++ b/engine/battle/move_effects/haze.asm @@ -15,7 +15,7 @@ HazeEffect_: ; cure non-volatile status, but only for the target ld hl, wEnemyMonStatus ld de, wEnemySelectedMove - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .cureStatuses ld hl, wBattleMonStatus diff --git a/engine/battle/move_effects/heal.asm b/engine/battle/move_effects/heal.asm index 2e68acc0..8042bc63 100644 --- a/engine/battle/move_effects/heal.asm +++ b/engine/battle/move_effects/heal.asm @@ -1,5 +1,5 @@ HealEffect_: - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld de, wBattleMonHP ld hl, wBattleMonMaxHP @@ -27,7 +27,7 @@ HealEffect_: ld c, 50 call DelayFrames ld hl, wBattleMonStatus - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .restEffect ld hl, wEnemyMonStatus @@ -87,7 +87,7 @@ HealEffect_: .playAnim ld hl, PlayCurrentMoveAnimation call BankswitchEtoF - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a coord hl, 10, 9 ld a, $1 diff --git a/engine/battle/move_effects/leech_seed.asm b/engine/battle/move_effects/leech_seed.asm index f4d3ee9c..981f5da9 100644 --- a/engine/battle/move_effects/leech_seed.asm +++ b/engine/battle/move_effects/leech_seed.asm @@ -5,7 +5,7 @@ LeechSeedEffect_: jr nz, .moveMissed ld hl, wEnemyBattleStatus2 ld de, wEnemyMonType1 - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .leechSeedEffect ld hl, wPlayerBattleStatus2 diff --git a/engine/battle/move_effects/mist.asm b/engine/battle/move_effects/mist.asm index 65070a3e..6373770d 100644 --- a/engine/battle/move_effects/mist.asm +++ b/engine/battle/move_effects/mist.asm @@ -1,6 +1,6 @@ MistEffect_: ld hl, wPlayerBattleStatus2 - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .mistEffect ld hl, wEnemyBattleStatus2 diff --git a/engine/battle/move_effects/one_hit_ko.asm b/engine/battle/move_effects/one_hit_ko.asm index 827e2197..347a4c7b 100644 --- a/engine/battle/move_effects/one_hit_ko.asm +++ b/engine/battle/move_effects/one_hit_ko.asm @@ -7,7 +7,7 @@ OneHitKOEffect_: ld [wCriticalHitOrOHKO], a ld hl, wBattleMonSpeed + 1 ld de, wEnemyMonSpeed + 1 - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .compareSpeed ld hl, wEnemyMonSpeed + 1 diff --git a/engine/battle/move_effects/paralyze.asm b/engine/battle/move_effects/paralyze.asm index 95979ae6..b01aa5cf 100644 --- a/engine/battle/move_effects/paralyze.asm +++ b/engine/battle/move_effects/paralyze.asm @@ -1,7 +1,7 @@ ParalyzeEffect_: ld hl, wEnemyMonStatus ld de, wPlayerMoveType - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jp z, .next ld hl, wBattleMonStatus diff --git a/engine/battle/move_effects/pay_day.asm b/engine/battle/move_effects/pay_day.asm index e5daf014..5bdb86da 100644 --- a/engine/battle/move_effects/pay_day.asm +++ b/engine/battle/move_effects/pay_day.asm @@ -2,7 +2,7 @@ PayDayEffect_: xor a ld hl, wcd6d ld [hli], a - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld a, [wBattleMonLevel] jr z, .payDayEffect @@ -10,28 +10,28 @@ PayDayEffect_: .payDayEffect ; level * 2 add a - ld [H_DIVIDEND + 3], a + ld [hDividend + 3], a xor a - ld [H_DIVIDEND], a - ld [H_DIVIDEND + 1], a - ld [H_DIVIDEND + 2], a + ld [hDividend], a + ld [hDividend + 1], a + ld [hDividend + 2], a ; convert to BCD ld a, 100 - ld [H_DIVISOR], a + ld [hDivisor], a ld b, $4 call Divide - ld a, [H_QUOTIENT + 3] + ld a, [hQuotient + 3] ld [hli], a - ld a, [H_REMAINDER] - ld [H_DIVIDEND + 3], a + ld a, [hRemainder] + ld [hDividend + 3], a ld a, 10 - ld [H_DIVISOR], a + ld [hDivisor], a ld b, $4 call Divide - ld a, [H_QUOTIENT + 3] + ld a, [hQuotient + 3] swap a ld b, a - ld a, [H_REMAINDER] + ld a, [hRemainder] add b ld [hl], a ld de, wTotalPayDayMoney + 2 diff --git a/engine/battle/move_effects/recoil.asm b/engine/battle/move_effects/recoil.asm index 0f2f087b..e94f8043 100644 --- a/engine/battle/move_effects/recoil.asm +++ b/engine/battle/move_effects/recoil.asm @@ -1,5 +1,5 @@ RecoilEffect_: - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld a, [wPlayerMoveNum] ld hl, wBattleMonMaxHP @@ -54,7 +54,7 @@ RecoilEffect_: ld [hl], a .getHPBarCoords coord hl, 10, 9 - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld a, $1 jr z, .updateHPBar diff --git a/engine/battle/move_effects/reflect_light_screen.asm b/engine/battle/move_effects/reflect_light_screen.asm index 2805a969..7693a348 100644 --- a/engine/battle/move_effects/reflect_light_screen.asm +++ b/engine/battle/move_effects/reflect_light_screen.asm @@ -1,7 +1,7 @@ ReflectLightScreenEffect_: ld hl, wPlayerBattleStatus3 ld de, wPlayerMoveEffect - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .reflectLightScreenEffect ld hl, wEnemyBattleStatus3 diff --git a/engine/battle/move_effects/substitute.asm b/engine/battle/move_effects/substitute.asm index 1bb6c887..a1cd11b2 100644 --- a/engine/battle/move_effects/substitute.asm +++ b/engine/battle/move_effects/substitute.asm @@ -4,7 +4,7 @@ SubstituteEffect_: ld hl, wBattleMonMaxHP ld de, wPlayerSubstituteHP ld bc, wPlayerBattleStatus2 - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .notEnemy ld hl, wEnemyMonMaxHP diff --git a/engine/battle/move_effects/transform.asm b/engine/battle/move_effects/transform.asm index 9a5de9cc..1b459910 100644 --- a/engine/battle/move_effects/transform.asm +++ b/engine/battle/move_effects/transform.asm @@ -3,7 +3,7 @@ TransformEffect_: ld de, wEnemyMonSpecies ld bc, wEnemyBattleStatus3 ld a, [wEnemyBattleStatus1] - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr nz, .hitTest ld hl, wEnemyMonSpecies @@ -18,7 +18,7 @@ TransformEffect_: push de push bc ld hl, wPlayerBattleStatus2 - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .transformEffect ld hl, wEnemyBattleStatus2 @@ -64,7 +64,7 @@ TransformEffect_: inc bc inc bc call CopyData - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .next ; save enemy mon DVs at wTransformedEnemyMonOriginalDVs @@ -128,7 +128,7 @@ TransformEffect_: jp PrintText .copyBasedOnTurn - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a jr z, .gotStatsOrModsToCopy push hl diff --git a/engine/battle/print_type.asm b/engine/battle/print_type.asm index f717f871..7da0dc8c 100644 --- a/engine/battle/print_type.asm +++ b/engine/battle/print_type.asm @@ -49,4 +49,4 @@ PrintType_: pop hl jp PlaceString -INCLUDE "text/type_names.asm" +INCLUDE "data/types/names.asm" diff --git a/engine/battle/save_trainer_name.asm b/engine/battle/save_trainer_name.asm index 78e53b87..4d40fd82 100644 --- a/engine/battle/save_trainer_name.asm +++ b/engine/battle/save_trainer_name.asm @@ -18,4 +18,4 @@ SaveTrainerName:: jr nz, .CopyCharacter ret -INCLUDE "text/trainer_name_pointers.asm" +INCLUDE "data/trainers/name_pointers.asm" diff --git a/engine/battle/scale_sprites.asm b/engine/battle/scale_sprites.asm index 98521528..11967ba1 100644 --- a/engine/battle/scale_sprites.asm +++ b/engine/battle/scale_sprites.asm @@ -17,7 +17,7 @@ ScaleFirstThreeSpriteColumnsByTwo: .columnInnerLoop push bc ld a, [de] - ld bc, -(7*8)+1 ; $ffc9, scale lower nybble and seek to previous output column + ld bc, -(7*8)+1 ; -$37, scale lower nybble and seek to previous output column call ScalePixelsByTwo ld a, [de] dec de @@ -32,7 +32,7 @@ ScaleFirstThreeSpriteColumnsByTwo: dec de dec de ld a, b - ld bc, -7*8 ; $ffc8, skip one output column (which has already been written along with the current one) + ld bc, -7*8 ; -$38, skip one output column (which has already been written along with the current one) add hl, bc ld b, a dec b @@ -41,16 +41,16 @@ ScaleFirstThreeSpriteColumnsByTwo: ScaleLastSpriteColumnByTwo: ld a, 4*8 - 4 ; $1c, 4 tiles minus 4 unused rows - ld [H_SPRITEINTERLACECOUNTER], a + ld [hSpriteInterlaceCounter], a ld bc, -1 .columnInnerLoop ld a, [de] dec de swap a ; only high nybble contains information call ScalePixelsByTwo - ld a, [H_SPRITEINTERLACECOUNTER] + ld a, [hSpriteInterlaceCounter] dec a - ld [H_SPRITEINTERLACECOUNTER], a + ld [hSpriteInterlaceCounter], a jr nz, .columnInnerLoop dec de ; skip last 4 rows of new column dec de diff --git a/engine/battle/trainer_ai.asm b/engine/battle/trainer_ai.asm index 2850b9c2..d61b44f8 100644 --- a/engine/battle/trainer_ai.asm +++ b/engine/battle/trainer_ai.asm @@ -134,7 +134,7 @@ AIMoveChoiceModification1: push de push bc ld hl, StatusAilmentMoveEffects - ld de, $0001 + ld de, 1 call IsInArray pop bc pop de @@ -273,19 +273,19 @@ ReadMove: pop hl ret -INCLUDE "data/trainer_move_choices.asm" +INCLUDE "data/trainers/move_choices.asm" -INCLUDE "data/trainer_pic_money_pointers.asm" +INCLUDE "data/trainers/pic_pointers_money.asm" -INCLUDE "text/trainer_names.asm" +INCLUDE "data/trainers/names.asm" INCLUDE "engine/battle/misc.asm" INCLUDE "engine/battle/read_trainer_party.asm" -INCLUDE "data/trainer_moves.asm" +INCLUDE "data/trainers/special_moves.asm" -INCLUDE "data/trainer_parties.asm" +INCLUDE "data/trainers/parties.asm" TrainerAI: and a @@ -319,7 +319,7 @@ TrainerAI: call Random jp hl -INCLUDE "data/trainer_ai_pointers.asm" +INCLUDE "data/trainers/ai_pointers.asm" JugglerAI: cp 25 percent + 1 @@ -655,17 +655,17 @@ AIUseDireHit: ; unused AICheckIfHPBelowFraction: ; 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 a, [hli] - ld [H_DIVIDEND], a + ld [hDividend], a ld a, [hl] - ld [H_DIVIDEND + 1], a + ld [hDividend + 1], a ld b, 2 call Divide - ld a, [H_QUOTIENT + 3] + ld a, [hQuotient + 3] ld c, a - ld a, [H_QUOTIENT + 2] + ld a, [hQuotient + 2] ld b, a ld hl, wEnemyMonHP + 1 ld a, [hld] diff --git a/engine/battle/unused_stats_functions.asm b/engine/battle/unused_stats_functions.asm index 55f78fd3..fb3422c7 100644 --- a/engine/battle/unused_stats_functions.asm +++ b/engine/battle/unused_stats_functions.asm @@ -1,6 +1,6 @@ ; does nothing since no stats are ever selected (barring glitches) DoubleSelectedStats: - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld a, [wPlayerStatsToDouble] ld hl, wBattleMonAttack + 1 @@ -30,7 +30,7 @@ DoubleSelectedStats: ; does nothing since no stats are ever selected (barring glitches) HalveSelectedStats: - ld a, [H_WHOSETURN] + ld a, [hWhoseTurn] and a ld a, [wPlayerStatsToHalve] ld hl, wBattleMonAttack diff --git a/engine/battle/wild_encounters.asm b/engine/battle/wild_encounters.asm index 93409051..9d6fcb8d 100644 --- a/engine/battle/wild_encounters.asm +++ b/engine/battle/wild_encounters.asm @@ -101,4 +101,4 @@ TryDoWildEncounter: xor a ret -INCLUDE "data/wild_probabilities.asm" +INCLUDE "data/wild/probabilities.asm" diff --git a/engine/debug/test_battle.asm b/engine/debug/test_battle.asm index d9dcf1fa..92d6e4a9 100644 --- a/engine/debug/test_battle.asm +++ b/engine/debug/test_battle.asm @@ -41,5 +41,5 @@ TestBattle: ; do it all again. ld a, 1 ld [wUpdateSpritesEnabled], a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a jr .loop diff --git a/engine/events/cinnabar_lab.asm b/engine/events/cinnabar_lab.asm index e642840d..e1598f98 100755 --- a/engine/events/cinnabar_lab.asm +++ b/engine/events/cinnabar_lab.asm @@ -35,7 +35,7 @@ GiveFossilToCinnabarLab:: ld e, a add hl, de ld a, [hl] - ld [$ffdb], a + ld [hItemToRemoveID], a cp DOME_FOSSIL jr z, .choseDomeFossil cp HELIX_FOSSIL diff --git a/engine/events/diploma.asm b/engine/events/diploma.asm index e53ef58f..53d78e57 100755 --- a/engine/events/diploma.asm +++ b/engine/events/diploma.asm @@ -9,7 +9,7 @@ DisplayDiploma:: call DisableLCD ld hl, CircleTile ld de, vChars2 + $700 - ld bc, $0010 + ld bc, $10 ld a, BANK(CircleTile) call FarCopyData2 coord hl, 0, 0 @@ -73,7 +73,7 @@ UnusedPlayerNameLengthFunc: ; Unused function that does a calculation involving the length of the player's ; name. ld hl, wPlayerName - ld bc, $ff00 + lb bc, $ff, $00 .loop ld a, [hli] cp "@" diff --git a/engine/events/hidden_items.asm b/engine/events/hidden_items.asm index e40b0ac7..ad954c9f 100755 --- a/engine/events/hidden_items.asm +++ b/engine/events/hidden_items.asm @@ -18,7 +18,7 @@ HiddenItems: call GetItemName tx_pre_jump FoundHiddenItemText -INCLUDE "data/hidden_item_coords.asm" +INCLUDE "data/events/hidden_item_coords.asm" FoundHiddenItemText:: TX_FAR _FoundHiddenItemText @@ -118,7 +118,7 @@ HiddenCoins: .done jp PrintPredefTextID -INCLUDE "data/hidden_coins.asm" +INCLUDE "data/events/hidden_coins.asm" FoundHiddenCoinsText:: TX_FAR _FoundHiddenCoinsText diff --git a/engine/events/hidden_object_functions17.asm b/engine/events/hidden_object_functions17.asm deleted file mode 100755 index bb2a358c..00000000 --- a/engine/events/hidden_object_functions17.asm +++ /dev/null @@ -1,475 +0,0 @@ -PrintRedSNESText: - call EnableAutoTextBoxDrawing - tx_pre_jump RedBedroomSNESText - -RedBedroomSNESText:: - TX_FAR _RedBedroomSNESText - db "@" - -OpenRedsPC: - call EnableAutoTextBoxDrawing - tx_pre_jump RedBedroomPCText - -RedBedroomPCText:: - TX_PLAYERS_PC - -Route15GateLeftBinoculars: - ld a, [wSpriteStateData1 + 9] - cp SPRITE_FACING_UP - ret nz - call EnableAutoTextBoxDrawing - tx_pre Route15UpstairsBinocularsText - ld a, ARTICUNO - ld [wcf91], a - call PlayCry - jp DisplayMonFrontSpriteInBox - -Route15UpstairsBinocularsText:: - TX_FAR _Route15UpstairsBinocularsText - db "@" - -AerodactylFossil: - ld a, FOSSIL_AERODACTYL - ld [wcf91], a - call DisplayMonFrontSpriteInBox - call EnableAutoTextBoxDrawing - tx_pre AerodactylFossilText - ret - -AerodactylFossilText:: - TX_FAR _AerodactylFossilText - db "@" - -KabutopsFossil: - ld a, FOSSIL_KABUTOPS - ld [wcf91], a - call DisplayMonFrontSpriteInBox - call EnableAutoTextBoxDrawing - tx_pre KabutopsFossilText - ret - -KabutopsFossilText:: - TX_FAR _KabutopsFossilText - db "@" - -DisplayMonFrontSpriteInBox: -; Displays a pokemon's front sprite in a pop-up window. -; [wcf91] = pokemon internal id number - ld a, 1 - ld [H_AUTOBGTRANSFERENABLED], a - call Delay3 - xor a - ld [hWY], a - call SaveScreenTilesToBuffer1 - ld a, MON_SPRITE_POPUP - ld [wTextBoxID], a - call DisplayTextBoxID - call UpdateSprites - ld a, [wcf91] - ld [wd0b5], a - call GetMonHeader - ld de, vChars1 + $310 - call LoadMonFrontSprite - ld a, $80 - ld [hStartTileID], a - coord hl, 10, 11 - predef AnimateSendingOutMon - call WaitForTextScrollButtonPress - call LoadScreenTilesFromBuffer1 - call Delay3 - ld a, $90 - ld [hWY], a - ret - -PrintBlackboardLinkCableText: - call EnableAutoTextBoxDrawing - ld a, $1 - ld [wDoNotWaitForButtonPressAfterDisplayingText], a - ld a, [wHiddenObjectFunctionArgument] - call PrintPredefTextID - ret - -LinkCableHelp:: - TX_ASM - call SaveScreenTilesToBuffer1 - ld hl, LinkCableHelpText1 - call PrintText - xor a - ld [wMenuItemOffset], a ; not used - ld [wCurrentMenuItem], a - ld [wLastMenuItem], a - ld a, A_BUTTON | B_BUTTON - ld [wMenuWatchedKeys], a - ld a, 3 - ld [wMaxMenuItem], a - ld a, 2 - ld [wTopMenuItemY], a - ld a, 1 - ld [wTopMenuItemX], a -.linkHelpLoop - ld hl, wd730 - set 6, [hl] - coord hl, 0, 0 - ld b, 8 - ld c, 13 - call TextBoxBorder - coord hl, 2, 2 - ld de, HowToLinkText - call PlaceString - ld hl, LinkCableHelpText2 - call PrintText - call HandleMenuInput - bit 1, a ; pressed b - jr nz, .exit - ld a, [wCurrentMenuItem] - cp 3 ; pressed a on "STOP READING" - jr z, .exit - ld hl, wd730 - res 6, [hl] - ld hl, LinkCableInfoTexts - add a - ld d, 0 - ld e, a - add hl, de - ld a, [hli] - ld h, [hl] - ld l, a - call PrintText - jp .linkHelpLoop -.exit - ld hl, wd730 - res 6, [hl] - call LoadScreenTilesFromBuffer1 - jp TextScriptEnd - -LinkCableHelpText1: - TX_FAR _LinkCableHelpText1 - db "@" - -LinkCableHelpText2: - TX_FAR _LinkCableHelpText2 - db "@" - -HowToLinkText: - db "HOW TO LINK" - next "COLOSSEUM" - next "TRADE CENTER" - next "STOP READING@" - -LinkCableInfoTexts: - dw LinkCableInfoText1 - dw LinkCableInfoText2 - dw LinkCableInfoText3 - -LinkCableInfoText1: - TX_FAR _LinkCableInfoText1 - db "@" - -LinkCableInfoText2: - TX_FAR _LinkCableInfoText2 - db "@" - -LinkCableInfoText3: - TX_FAR _LinkCableInfoText3 - db "@" - -ViridianSchoolBlackboard:: - TX_ASM - call SaveScreenTilesToBuffer1 - ld hl, ViridianSchoolBlackboardText1 - call PrintText - xor a - ld [wMenuItemOffset], a - ld [wCurrentMenuItem], a - ld [wLastMenuItem], a - ld a, D_LEFT | D_RIGHT | A_BUTTON | B_BUTTON - ld [wMenuWatchedKeys], a - ld a, 2 - ld [wMaxMenuItem], a - ld a, 2 - ld [wTopMenuItemY], a - ld a, 1 - ld [wTopMenuItemX], a -.blackboardLoop - ld hl, wd730 - set 6, [hl] - coord hl, 0, 0 - lb bc, 6, 10 - call TextBoxBorder - coord hl, 1, 2 - ld de, StatusAilmentText1 - call PlaceString - coord hl, 6, 2 - ld de, StatusAilmentText2 - call PlaceString - ld hl, ViridianSchoolBlackboardText2 - call PrintText - call HandleMenuInput ; pressing up and down is handled in here - bit 1, a ; pressed b - jr nz, .exitBlackboard - bit 4, a ; pressed right - jr z, .didNotPressRight - ; move cursor to right column - ld a, 2 - ld [wMaxMenuItem], a - ld a, 2 - ld [wTopMenuItemY], a - ld a, 6 - ld [wTopMenuItemX], a - ld a, 3 ; in the the right column, use an offset to prevent overlap - ld [wMenuItemOffset], a - jr .blackboardLoop -.didNotPressRight - bit 5, a ; pressed left - jr z, .didNotPressLeftOrRight - ; move cursor to left column - ld a, 2 - ld [wMaxMenuItem], a - ld a, 2 - ld [wTopMenuItemY], a - ld a, 1 - ld [wTopMenuItemX], a - xor a - ld [wMenuItemOffset], a - jr .blackboardLoop -.didNotPressLeftOrRight - ld a, [wCurrentMenuItem] - ld b, a - ld a, [wMenuItemOffset] - add b - cp 5 ; cursor is pointing to "QUIT" - jr z, .exitBlackboard - ; we must have pressed a on a status condition - ; so print the text - ld hl, wd730 - res 6, [hl] - ld hl, ViridianBlackboardStatusPointers - add a - ld d, 0 - ld e, a - add hl, de - ld a, [hli] - ld h, [hl] - ld l, a - call PrintText - jp .blackboardLoop -.exitBlackboard - ld hl, wd730 - res 6, [hl] - call LoadScreenTilesFromBuffer1 - jp TextScriptEnd - -ViridianSchoolBlackboardText1: - TX_FAR _ViridianSchoolBlackboardText1 - db "@" - -ViridianSchoolBlackboardText2: - TX_FAR _ViridianSchoolBlackboardText2 - db "@" - -StatusAilmentText1: - db " SLP" - next " PSN" - next " PAR@" - -StatusAilmentText2: - db " BRN" - next " FRZ" - next " QUIT@@" - -ViridianBlackboardStatusPointers: - dw ViridianBlackboardSleepText - dw ViridianBlackboardPoisonText - dw ViridianBlackboardPrlzText - dw ViridianBlackboardBurnText - dw ViridianBlackboardFrozenText - -ViridianBlackboardSleepText: - TX_FAR _ViridianBlackboardSleepText - db "@" - -ViridianBlackboardPoisonText: - TX_FAR _ViridianBlackboardPoisonText - db "@" - -ViridianBlackboardPrlzText: - TX_FAR _ViridianBlackboardPrlzText - db "@" - -ViridianBlackboardBurnText: - TX_FAR _ViridianBlackboardBurnText - db "@" - -ViridianBlackboardFrozenText: - TX_FAR _ViridianBlackboardFrozenText - db "@" - -PrintTrashText: - call EnableAutoTextBoxDrawing - tx_pre_jump VermilionGymTrashText - -VermilionGymTrashText:: - TX_FAR _VermilionGymTrashText - db "@" - -GymTrashScript: - call EnableAutoTextBoxDrawing - ld a, [wHiddenObjectFunctionArgument] - ld [wGymTrashCanIndex], a - -; Don't do the trash can puzzle if it's already been done. - CheckEvent EVENT_2ND_LOCK_OPENED - jr z, .ok - - tx_pre_jump VermilionGymTrashText - -.ok - CheckEventReuseA EVENT_1ST_LOCK_OPENED - jr nz, .trySecondLock - - ld a, [wFirstLockTrashCanIndex] - ld b, a - ld a, [wGymTrashCanIndex] - cp b - jr z, .openFirstLock - - tx_pre_id VermilionGymTrashText - jr .done - -.openFirstLock -; Next can is trying for the second switch. - SetEvent EVENT_1ST_LOCK_OPENED - - ld hl, GymTrashCans - ld a, [wGymTrashCanIndex] - ; * 5 - ld b, a - add a - add a - add b - - ld d, 0 - ld e, a - add hl, de - ld a, [hli] - -; There is a bug in this code. It should calculate a value in the range [0, 3] -; but if the mask and random number don't have any 1 bits in common, then -; the result of the AND will be 0. When 1 is subtracted from that, the value -; will become $ff. This will result in 255 being added to hl, which will cause -; hl to point to one of the zero bytes that pad the end of the ROM bank. -; Trash can 0 was intended to be able to have the second lock only when the -; first lock was in trash can 1 or 3. However, due to this bug, trash can 0 can -; have the second lock regardless of which trash can had the first lock. - - ld [hGymTrashCanRandNumMask], a - push hl - call Random - swap a - ld b, a - ld a, [hGymTrashCanRandNumMask] - and b - dec a - pop hl - - ld d, 0 - ld e, a - add hl, de - ld a, [hl] - and $f - ld [wSecondLockTrashCanIndex], a - - tx_pre_id VermilionGymTrashSuccessText1 - jr .done - -.trySecondLock - ld a, [wSecondLockTrashCanIndex] - ld b, a - ld a, [wGymTrashCanIndex] - cp b - jr z, .openSecondLock - -; Reset the cans. - ResetEvent EVENT_1ST_LOCK_OPENED - call Random - - and $e - ld [wFirstLockTrashCanIndex], a - - tx_pre_id VermilionGymTrashFailText - jr .done - -.openSecondLock -; Completed the trash can puzzle. - SetEvent EVENT_2ND_LOCK_OPENED - ld hl, wCurrentMapScriptFlags - set 6, [hl] - - tx_pre_id VermilionGymTrashSuccessText3 - -.done - jp PrintPredefTextID - -GymTrashCans: -; byte 0: mask for random number -; bytes 1-4: indices of the trash cans that can have the second lock -; (but see the comment above explaining a bug regarding this) -; Note that the mask is simply the number of valid trash can indices that -; follow. The remaining bytes are filled with 0 to pad the length of each entry -; to 5 bytes. - db 2, 1, 3, 0, 0 ; 0 - db 3, 0, 2, 4, 0 ; 1 - db 2, 1, 5, 0, 0 ; 2 - db 3, 0, 4, 6, 0 ; 3 - db 4, 1, 3, 5, 7 ; 4 - db 3, 2, 4, 8, 0 ; 5 - db 3, 3, 7, 9, 0 ; 6 - db 4, 4, 6, 8, 10 ; 7 - db 3, 5, 7, 11, 0 ; 8 - db 3, 6, 10, 12, 0 ; 9 - db 4, 7, 9, 11, 13 ; 10 - db 3, 8, 10, 14, 0 ; 11 - db 2, 9, 13, 0, 0 ; 12 - db 3, 10, 12, 14, 0 ; 13 - db 2, 11, 13, 0, 0 ; 14 - -VermilionGymTrashSuccessText1:: - TX_FAR _VermilionGymTrashSuccessText1 - TX_ASM - call WaitForSoundToFinish - ld a, SFX_SWITCH - call PlaySound - call WaitForSoundToFinish - jp TextScriptEnd - -; unused -VermilionGymTrashSuccessText2:: - TX_FAR _VermilionGymTrashSuccessText2 - db "@" - -; unused -VermilionGymTrashSuccesPlaySfx: - TX_ASM - call WaitForSoundToFinish - ld a, SFX_SWITCH - call PlaySound - call WaitForSoundToFinish - jp TextScriptEnd - -VermilionGymTrashSuccessText3:: - TX_FAR _VermilionGymTrashSuccessText3 - TX_ASM - call WaitForSoundToFinish - ld a, SFX_GO_INSIDE - call PlaySound - call WaitForSoundToFinish - jp TextScriptEnd - -VermilionGymTrashFailText:: - TX_FAR _VermilionGymTrashFailText - TX_ASM - call WaitForSoundToFinish - ld a, SFX_DENIED - call PlaySound - call WaitForSoundToFinish - jp TextScriptEnd diff --git a/engine/events/hidden_object_functions3.asm b/engine/events/hidden_object_functions3.asm deleted file mode 100755 index 1237e960..00000000 --- a/engine/events/hidden_object_functions3.asm +++ /dev/null @@ -1,117 +0,0 @@ -; prints text for bookshelves in buildings without sign events -PrintBookshelfText:: - ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction - cp SPRITE_FACING_UP - jr nz, .noMatch -; facing up - ld a, [wCurMapTileset] - ld b, a - aCoord 8, 7 - ld c, a - ld hl, BookshelfTileIDs -.loop - ld a, [hli] - cp $ff - jr z, .noMatch - cp b - jr nz, .nextBookshelfEntry1 - ld a, [hli] - cp c - jr nz, .nextBookshelfEntry2 - ld a, [hl] - push af - call EnableAutoTextBoxDrawing - pop af - call PrintPredefTextID - xor a - ld [$ffdb], a - ret -.nextBookshelfEntry1 - inc hl -.nextBookshelfEntry2 - inc hl - jr .loop -.noMatch - ld a, $ff - ld [$ffdb], a - jpba PrintCardKeyText - -INCLUDE "data/bookshelf_tile_ids.asm" - -IndigoPlateauStatues:: - TX_ASM - ld hl, IndigoPlateauStatuesText1 - call PrintText - ld a, [wXCoord] - bit 0, a - ld hl, IndigoPlateauStatuesText2 - jr nz, .ok - ld hl, IndigoPlateauStatuesText3 -.ok - call PrintText - jp TextScriptEnd - -IndigoPlateauStatuesText1: - TX_FAR _IndigoPlateauStatuesText1 - db "@" - -IndigoPlateauStatuesText2: - TX_FAR _IndigoPlateauStatuesText2 - db "@" - -IndigoPlateauStatuesText3: - TX_FAR _IndigoPlateauStatuesText3 - db "@" - -BookOrSculptureText:: - TX_ASM - ld hl, PokemonBooksText - ld a, [wCurMapTileset] - cp MANSION ; Celadon Mansion tileset - jr nz, .ok - aCoord 8, 6 - cp $38 - jr nz, .ok - ld hl, DiglettSculptureText -.ok - call PrintText - jp TextScriptEnd - -PokemonBooksText: - TX_FAR _PokemonBooksText - db "@" - -DiglettSculptureText: - TX_FAR _DiglettSculptureText - db "@" - -ElevatorText:: - TX_FAR _ElevatorText - db "@" - -TownMapText:: - TX_FAR _TownMapText - TX_BLINK - TX_ASM - ld a, $1 - ld [wDoNotWaitForButtonPressAfterDisplayingText], a - ld hl, wd730 - set 6, [hl] - call GBPalWhiteOutWithDelay3 - xor a - ld [hWY], a - inc a - ld [H_AUTOBGTRANSFERENABLED], a - call LoadFontTilePatterns - callba DisplayTownMap - ld hl, wd730 - res 6, [hl] - ld de, TextScriptEnd - push de - ld a, [H_LOADEDROMBANK] - push af - jp CloseTextDisplay - -PokemonStuffText:: - TX_FAR _PokemonStuffText - db "@" diff --git a/engine/events/hidden_object_functions7.asm b/engine/events/hidden_object_functions7.asm deleted file mode 100755 index e18b9570..00000000 --- a/engine/events/hidden_object_functions7.asm +++ /dev/null @@ -1,467 +0,0 @@ -PrintNewBikeText: - call EnableAutoTextBoxDrawing - tx_pre_jump NewBicycleText - -NewBicycleText:: - TX_FAR _NewBicycleText - db "@" - -DisplayOakLabLeftPoster: - call EnableAutoTextBoxDrawing - tx_pre_jump PushStartText - -PushStartText:: - TX_FAR _PushStartText - db "@" - -DisplayOakLabRightPoster: - call EnableAutoTextBoxDrawing - ld hl, wPokedexOwned - ld b, wPokedexOwnedEnd - wPokedexOwned - call CountSetBits - ld a, [wNumSetBits] - cp 2 - tx_pre_id SaveOptionText - jr c, .ownLessThanTwo - ; own two or more mon - tx_pre_id StrengthsAndWeaknessesText -.ownLessThanTwo - jp PrintPredefTextID - -SaveOptionText:: - TX_FAR _SaveOptionText - db "@" - -StrengthsAndWeaknessesText:: - TX_FAR _StrengthsAndWeaknessesText - db "@" - -SafariZoneCheck:: - CheckEventHL EVENT_IN_SAFARI_ZONE ; if we are not in the Safari Zone, - jr z, SafariZoneGameStillGoing ; don't bother printing game over text - ld a, [wNumSafariBalls] - and a - jr z, SafariZoneGameOver - jr SafariZoneGameStillGoing - -SafariZoneCheckSteps:: - ld a, [wSafariSteps] - ld b, a - ld a, [wSafariSteps + 1] - ld c, a - or b - jr z, SafariZoneGameOver - dec bc - ld a, b - ld [wSafariSteps], a - ld a, c - ld [wSafariSteps + 1], a -SafariZoneGameStillGoing: - xor a - ld [wSafariZoneGameOver], a - ret - -SafariZoneGameOver: - call EnableAutoTextBoxDrawing - xor a - ld [wAudioFadeOutControl], a - dec a - call PlaySound - ld c, BANK(SFX_Safari_Zone_PA) - ld a, SFX_SAFARI_ZONE_PA - call PlayMusic -.waitForMusicToPlay - ld a, [wChannelSoundIDs + Ch5] - cp SFX_SAFARI_ZONE_PA - jr nz, .waitForMusicToPlay - ld a, TEXT_SAFARI_GAME_OVER - ld [hSpriteIndexOrTextID], a - call DisplayTextID - xor a - ld [wPlayerMovingDirection], a - ld a, SAFARI_ZONE_GATE - ld [hWarpDestinationMap], a - ld a, $3 - ld [wDestinationWarpID], a - ld a, $5 - ld [wSafariZoneGateCurScript], a - SetEvent EVENT_SAFARI_GAME_OVER - ld a, 1 - ld [wSafariZoneGameOver], a - ret - -PrintSafariGameOverText:: - xor a - ld [wJoyIgnore], a - ld hl, SafariGameOverText - jp PrintText - -SafariGameOverText: - TX_ASM - ld a, [wNumSafariBalls] - and a - jr z, .noMoreSafariBalls - ld hl, TimesUpText - call PrintText -.noMoreSafariBalls - ld hl, GameOverText - call PrintText - jp TextScriptEnd - -TimesUpText: - TX_FAR _TimesUpText - db "@" - -GameOverText: - TX_FAR _GameOverText - db "@" - -PrintCinnabarQuiz: - ld a, [wSpriteStateData1 + 9] - cp SPRITE_FACING_UP - ret nz - call EnableAutoTextBoxDrawing - tx_pre_jump CinnabarGymQuiz - -CinnabarGymQuiz:: - TX_ASM - xor a - ld [wOpponentAfterWrongAnswer], a - ld a, [wHiddenObjectFunctionArgument] - push af - and $f - ld [hGymGateIndex], a - pop af - and $f0 - swap a - ld [$ffdc], a - ld hl, CinnabarGymQuizIntroText - call PrintText - ld a, [hGymGateIndex] - dec a - add a - ld d, 0 - ld e, a - ld hl, CinnabarQuizQuestions - add hl, de - ld a, [hli] - ld h, [hl] - ld l, a - call PrintText - ld a, 1 - ld [wDoNotWaitForButtonPressAfterDisplayingText], a - call CinnabarGymQuiz_1ea92 - jp TextScriptEnd - -CinnabarGymQuizIntroText: - TX_FAR _CinnabarGymQuizIntroText - db "@" - -CinnabarQuizQuestions: - dw CinnabarQuizQuestionsText1 - dw CinnabarQuizQuestionsText2 - dw CinnabarQuizQuestionsText3 - dw CinnabarQuizQuestionsText4 - dw CinnabarQuizQuestionsText5 - dw CinnabarQuizQuestionsText6 - -CinnabarQuizQuestionsText1: - TX_FAR _CinnabarQuizQuestionsText1 - db "@" - -CinnabarQuizQuestionsText2: - TX_FAR _CinnabarQuizQuestionsText2 - db "@" - -CinnabarQuizQuestionsText3: - TX_FAR _CinnabarQuizQuestionsText3 - db "@" - -CinnabarQuizQuestionsText4: - TX_FAR _CinnabarQuizQuestionsText4 - db "@" - -CinnabarQuizQuestionsText5: - TX_FAR _CinnabarQuizQuestionsText5 - db "@" - -CinnabarQuizQuestionsText6: - TX_FAR _CinnabarQuizQuestionsText6 - db "@" - -CinnabarGymGateFlagAction: - EventFlagAddress hl, EVENT_CINNABAR_GYM_GATE0_UNLOCKED - predef_jump FlagActionPredef - -CinnabarGymQuiz_1ea92: - call YesNoChoice - ld a, [$ffdc] - ld c, a - ld a, [wCurrentMenuItem] - cp c - jr nz, .wrongAnswer - ld hl, wCurrentMapScriptFlags - set 5, [hl] - ld a, [hGymGateIndex] - ld [$ffe0], a - ld hl, CinnabarGymQuizCorrectText - call PrintText - ld a, [$ffe0] - AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0 - ld c, a - ld b, FLAG_SET - call CinnabarGymGateFlagAction - jp UpdateCinnabarGymGateTileBlocks_ -.wrongAnswer - call WaitForSoundToFinish - ld a, SFX_DENIED - call PlaySound - call WaitForSoundToFinish - ld hl, CinnabarGymQuizIncorrectText - call PrintText - ld a, [hGymGateIndex] - add $2 - AdjustEventBit EVENT_BEAT_CINNABAR_GYM_TRAINER_0, 2 - ld c, a - ld b, FLAG_TEST - EventFlagAddress hl, EVENT_BEAT_CINNABAR_GYM_TRAINER_0 - predef FlagActionPredef - ld a, c - and a - ret nz - ld a, [hGymGateIndex] - add $2 - ld [wOpponentAfterWrongAnswer], a - ret - -CinnabarGymQuizCorrectText: - TX_SFX_ITEM_1 - TX_FAR _CinnabarGymQuizCorrectText - TX_BLINK - TX_ASM - - ld a, [$ffe0] - AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0 - ld c, a - ld b, FLAG_TEST - call CinnabarGymGateFlagAction - ld a, c - and a - jp nz, TextScriptEnd - call WaitForSoundToFinish - ld a, SFX_GO_INSIDE - call PlaySound - call WaitForSoundToFinish - jp TextScriptEnd - -CinnabarGymQuizIncorrectText: - TX_FAR _CinnabarGymQuizIncorrectText - db "@" - -UpdateCinnabarGymGateTileBlocks_:: -; Update the overworld map with open floor blocks or locked gate blocks -; depending on event flags. - ld a, 6 - ld [hGymGateIndex], a -.loop - ld a, [hGymGateIndex] - dec a - add a - add a - ld d, 0 - ld e, a - ld hl, CinnabarGymGateCoords - add hl, de - ld a, [hli] - ld b, [hl] - ld c, a - inc hl - ld a, [hl] - ld [wGymGateTileBlock], a - push bc - ld a, [hGymGateIndex] - ld [$ffe0], a - AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0 - ld c, a - ld b, FLAG_TEST - call CinnabarGymGateFlagAction - ld a, c - and a - jr nz, .unlocked - ld a, [wGymGateTileBlock] - jr .next -.unlocked - ld a, $e -.next - pop bc - ld [wNewTileBlockID], a - predef ReplaceTileBlock - ld hl, hGymGateIndex - dec [hl] - jr nz, .loop - ret - -CinnabarGymGateCoords: - ; format: x-coord, y-coord, direction, padding - ; direction: $54 = horizontal gate, $5f = vertical gate - db $09,$03,$54,$00 - db $06,$03,$54,$00 - db $06,$06,$54,$00 - db $03,$08,$5f,$00 - db $02,$06,$54,$00 - db $02,$03,$54,$00 - -PrintMagazinesText: - call EnableAutoTextBoxDrawing - tx_pre MagazinesText - ret - -MagazinesText:: - TX_FAR _MagazinesText - db "@" - -BillsHousePC: - call EnableAutoTextBoxDrawing - ld a, [wSpriteStateData1 + 9] - cp SPRITE_FACING_UP - ret nz - CheckEvent EVENT_LEFT_BILLS_HOUSE_AFTER_HELPING - jr nz, .displayBillsHousePokemonList - CheckEventReuseA EVENT_USED_CELL_SEPARATOR_ON_BILL - jr nz, .displayBillsHouseMonitorText - CheckEventReuseA EVENT_BILL_SAID_USE_CELL_SEPARATOR - jr nz, .doCellSeparator -.displayBillsHouseMonitorText - tx_pre_jump BillsHouseMonitorText -.doCellSeparator - ld a, $1 - ld [wDoNotWaitForButtonPressAfterDisplayingText], a - tx_pre BillsHouseInitiatedText - ld c, 32 - call DelayFrames - ld a, SFX_TINK - call PlaySound - call WaitForSoundToFinish - ld c, 80 - call DelayFrames - ld a, SFX_SHRINK - call PlaySound - call WaitForSoundToFinish - ld c, 48 - call DelayFrames - ld a, SFX_TINK - call PlaySound - call WaitForSoundToFinish - ld c, 32 - call DelayFrames - ld a, SFX_GET_ITEM_1 - call PlaySound - call WaitForSoundToFinish - call PlayDefaultMusic - SetEvent EVENT_USED_CELL_SEPARATOR_ON_BILL - ret -.displayBillsHousePokemonList - ld a, $1 - ld [wDoNotWaitForButtonPressAfterDisplayingText], a - tx_pre BillsHousePokemonList - ret - -BillsHouseMonitorText:: - TX_FAR _BillsHouseMonitorText - db "@" - -BillsHouseInitiatedText:: - TX_FAR _BillsHouseInitiatedText - TX_BLINK - TX_ASM - ld a, $ff - ld [wNewSoundID], a - call PlaySound - ld c, 16 - call DelayFrames - ld a, SFX_SWITCH - call PlaySound - call WaitForSoundToFinish - ld c, 60 - call DelayFrames - jp TextScriptEnd - -BillsHousePokemonList:: - TX_ASM - call SaveScreenTilesToBuffer1 - ld hl, BillsHousePokemonListText1 - call PrintText - xor a - ld [wMenuItemOffset], a ; not used - ld [wCurrentMenuItem], a - ld [wLastMenuItem], a - ld a, A_BUTTON | B_BUTTON - ld [wMenuWatchedKeys], a - ld a, 4 - ld [wMaxMenuItem], a - ld a, 2 - ld [wTopMenuItemY], a - ld a, 1 - ld [wTopMenuItemX], a -.billsPokemonLoop - ld hl, wd730 - set 6, [hl] - coord hl, 0, 0 - ld b, 10 - ld c, 9 - call TextBoxBorder - coord hl, 2, 2 - ld de, BillsMonListText - call PlaceString - ld hl, BillsHousePokemonListText2 - call PrintText - call SaveScreenTilesToBuffer2 - call HandleMenuInput - bit 1, a ; pressed b - jr nz, .cancel - ld a, [wCurrentMenuItem] - add EEVEE - cp EEVEE - jr z, .displayPokedex - cp FLAREON - jr z, .displayPokedex - cp JOLTEON - jr z, .displayPokedex - cp VAPOREON - jr z, .displayPokedex - jr .cancel -.displayPokedex - call DisplayPokedex - call LoadScreenTilesFromBuffer2 - jr .billsPokemonLoop -.cancel - ld hl, wd730 - res 6, [hl] - call LoadScreenTilesFromBuffer2 - jp TextScriptEnd - -BillsHousePokemonListText1: - TX_FAR _BillsHousePokemonListText1 - db "@" - -BillsMonListText: - db "EEVEE" - next "FLAREON" - next "JOLTEON" - next "VAPOREON" - next "CANCEL@" - -BillsHousePokemonListText2: - TX_FAR _BillsHousePokemonListText2 - db "@" - -DisplayOakLabEmailText: - ld a, [wSpriteStateData1 + 9] - cp SPRITE_FACING_UP - ret nz - call EnableAutoTextBoxDrawing - tx_pre_jump OakLabEmailText - -OakLabEmailText:: - TX_FAR _OakLabEmailText - db "@" diff --git a/engine/events/hidden_object_functions18.asm b/engine/events/hidden_objects/bench_guys.asm index c0e5aa34..995b5929 100755..100644 --- a/engine/events/hidden_object_functions18.asm +++ b/engine/events/hidden_objects/bench_guys.asm @@ -1,52 +1,3 @@ -GymStatues: -; if in a gym and have the corresponding badge, a = GymStatueText2_id and jp PrintPredefTextID -; if in a gym and don’t have the corresponding badge, a = GymStatueText1_id and jp PrintPredefTextID -; else ret - call EnableAutoTextBoxDrawing - ld a, [wSpriteStateData1 + 9] - cp SPRITE_FACING_UP - ret nz - ld hl, .BadgeFlags - ld a, [wCurMap] - ld b, a -.loop - ld a, [hli] - cp $ff - ret z - cp b - jr z, .match - inc hl - jr .loop -.match - ld b, [hl] - ld a, [wBeatGymFlags] - and b - cp b - tx_pre_id GymStatueText2 - jr z, .haveBadge - tx_pre_id GymStatueText1 -.haveBadge - jp PrintPredefTextID - -.BadgeFlags: - db PEWTER_GYM, %00000001 - db CERULEAN_GYM, %00000010 - db VERMILION_GYM,%00000100 - db CELADON_GYM, %00001000 - db FUCHSIA_GYM, %00010000 - db SAFFRON_GYM, %00100000 - db CINNABAR_GYM, %01000000 - db VIRIDIAN_GYM, %10000000 - db $ff - -GymStatueText1:: - TX_FAR _GymStatueText1 - db "@" - -GymStatueText2:: - TX_FAR _GymStatueText2 - db "@" - PrintBenchGuyText: call EnableAutoTextBoxDrawing ld hl, BenchGuyTextPointers @@ -171,28 +122,3 @@ SaffronCityPokecenterBenchGuyText2: CeladonCityHotelText:: TX_FAR _CeladonCityHotelText db "@" - - ret - -UnusedPredefText:: - db "@" - -PrintBookcaseText: - call EnableAutoTextBoxDrawing - tx_pre_jump BookcaseText - -BookcaseText:: - TX_FAR _BookcaseText - db "@" - -OpenPokemonCenterPC: - ld a, [wSpriteStateData1 + 9] - cp SPRITE_FACING_UP ; check to see if player is facing up - ret nz - call EnableAutoTextBoxDrawing - ld a, $1 - ld [wAutoTextBoxDrawingControl], a - tx_pre_jump PokemonCenterPCText - -PokemonCenterPCText:: - TX_POKECENTER_PC diff --git a/engine/events/hidden_objects/bills_house_pc.asm b/engine/events/hidden_objects/bills_house_pc.asm new file mode 100644 index 00000000..836aace0 --- /dev/null +++ b/engine/events/hidden_objects/bills_house_pc.asm @@ -0,0 +1,134 @@ +BillsHousePC: + call EnableAutoTextBoxDrawing + ld a, [wSpriteStateData1 + 9] + cp SPRITE_FACING_UP + ret nz + CheckEvent EVENT_LEFT_BILLS_HOUSE_AFTER_HELPING + jr nz, .displayBillsHousePokemonList + CheckEventReuseA EVENT_USED_CELL_SEPARATOR_ON_BILL + jr nz, .displayBillsHouseMonitorText + CheckEventReuseA EVENT_BILL_SAID_USE_CELL_SEPARATOR + jr nz, .doCellSeparator +.displayBillsHouseMonitorText + tx_pre_jump BillsHouseMonitorText +.doCellSeparator + ld a, $1 + ld [wDoNotWaitForButtonPressAfterDisplayingText], a + tx_pre BillsHouseInitiatedText + ld c, 32 + call DelayFrames + ld a, SFX_TINK + call PlaySound + call WaitForSoundToFinish + ld c, 80 + call DelayFrames + ld a, SFX_SHRINK + call PlaySound + call WaitForSoundToFinish + ld c, 48 + call DelayFrames + ld a, SFX_TINK + call PlaySound + call WaitForSoundToFinish + ld c, 32 + call DelayFrames + ld a, SFX_GET_ITEM_1 + call PlaySound + call WaitForSoundToFinish + call PlayDefaultMusic + SetEvent EVENT_USED_CELL_SEPARATOR_ON_BILL + ret +.displayBillsHousePokemonList + ld a, $1 + ld [wDoNotWaitForButtonPressAfterDisplayingText], a + tx_pre BillsHousePokemonList + ret + +BillsHouseMonitorText:: + TX_FAR _BillsHouseMonitorText + db "@" + +BillsHouseInitiatedText:: + TX_FAR _BillsHouseInitiatedText + TX_BLINK + TX_ASM + ld a, SFX_STOP_ALL_MUSIC + ld [wNewSoundID], a + call PlaySound + ld c, 16 + call DelayFrames + ld a, SFX_SWITCH + call PlaySound + call WaitForSoundToFinish + ld c, 60 + call DelayFrames + jp TextScriptEnd + +BillsHousePokemonList:: + TX_ASM + call SaveScreenTilesToBuffer1 + ld hl, BillsHousePokemonListText1 + call PrintText + xor a + ld [wMenuItemOffset], a ; not used + ld [wCurrentMenuItem], a + ld [wLastMenuItem], a + ld a, A_BUTTON | B_BUTTON + ld [wMenuWatchedKeys], a + ld a, 4 + ld [wMaxMenuItem], a + ld a, 2 + ld [wTopMenuItemY], a + ld a, 1 + ld [wTopMenuItemX], a +.billsPokemonLoop + ld hl, wd730 + set 6, [hl] + coord hl, 0, 0 + ld b, 10 + ld c, 9 + call TextBoxBorder + coord hl, 2, 2 + ld de, BillsMonListText + call PlaceString + ld hl, BillsHousePokemonListText2 + call PrintText + call SaveScreenTilesToBuffer2 + call HandleMenuInput + bit 1, a ; pressed b + jr nz, .cancel + ld a, [wCurrentMenuItem] + add EEVEE + cp EEVEE + jr z, .displayPokedex + cp FLAREON + jr z, .displayPokedex + cp JOLTEON + jr z, .displayPokedex + cp VAPOREON + jr z, .displayPokedex + jr .cancel +.displayPokedex + call DisplayPokedex + call LoadScreenTilesFromBuffer2 + jr .billsPokemonLoop +.cancel + ld hl, wd730 + res 6, [hl] + call LoadScreenTilesFromBuffer2 + jp TextScriptEnd + +BillsHousePokemonListText1: + TX_FAR _BillsHousePokemonListText1 + db "@" + +BillsMonListText: + db "EEVEE" + next "FLAREON" + next "JOLTEON" + next "VAPOREON" + next "CANCEL@" + +BillsHousePokemonListText2: + TX_FAR _BillsHousePokemonListText2 + db "@" diff --git a/engine/events/hidden_objects/blues_room.asm b/engine/events/hidden_objects/blues_room.asm new file mode 100644 index 00000000..879a7ac8 --- /dev/null +++ b/engine/events/hidden_objects/blues_room.asm @@ -0,0 +1,13 @@ + + ret ; unused + +UnusedPredefText:: + db "@" + +PrintBookcaseText: + call EnableAutoTextBoxDrawing + tx_pre_jump BookcaseText + +BookcaseText:: + TX_FAR _BookcaseText + db "@" diff --git a/engine/events/hidden_objects/book_or_sculpture.asm b/engine/events/hidden_objects/book_or_sculpture.asm new file mode 100644 index 00000000..2d6f278a --- /dev/null +++ b/engine/events/hidden_objects/book_or_sculpture.asm @@ -0,0 +1,21 @@ +BookOrSculptureText:: + TX_ASM + ld hl, PokemonBooksText + ld a, [wCurMapTileset] + cp MANSION ; Celadon Mansion tileset + jr nz, .ok + aCoord 8, 6 + cp $38 + jr nz, .ok + ld hl, DiglettSculptureText +.ok + call PrintText + jp TextScriptEnd + +PokemonBooksText: + TX_FAR _PokemonBooksText + db "@" + +DiglettSculptureText: + TX_FAR _DiglettSculptureText + db "@" diff --git a/engine/events/hidden_objects/bookshelves.asm b/engine/events/hidden_objects/bookshelves.asm new file mode 100644 index 00000000..eaf744ff --- /dev/null +++ b/engine/events/hidden_objects/bookshelves.asm @@ -0,0 +1,39 @@ +; prints text for bookshelves in buildings without sign events +PrintBookshelfText:: + ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction + cp SPRITE_FACING_UP + jr nz, .noMatch +; facing up + ld a, [wCurMapTileset] + ld b, a + aCoord 8, 7 + ld c, a + ld hl, BookshelfTileIDs +.loop + ld a, [hli] + cp $ff + jr z, .noMatch + cp b + jr nz, .nextBookshelfEntry1 + ld a, [hli] + cp c + jr nz, .nextBookshelfEntry2 + ld a, [hl] + push af + call EnableAutoTextBoxDrawing + pop af + call PrintPredefTextID + xor a + ld [hFFDB], a + ret +.nextBookshelfEntry1 + inc hl +.nextBookshelfEntry2 + inc hl + jr .loop +.noMatch + ld a, $ff + ld [hFFDB], a + jpba PrintCardKeyText + +INCLUDE "data/tilesets/bookshelf_tile_ids.asm" diff --git a/engine/events/hidden_objects/cinnabar_gym_quiz.asm b/engine/events/hidden_objects/cinnabar_gym_quiz.asm new file mode 100644 index 00000000..6404717e --- /dev/null +++ b/engine/events/hidden_objects/cinnabar_gym_quiz.asm @@ -0,0 +1,194 @@ +PrintCinnabarQuiz: + ld a, [wSpriteStateData1 + 9] + cp SPRITE_FACING_UP + ret nz + call EnableAutoTextBoxDrawing + tx_pre_jump CinnabarGymQuiz + +CinnabarGymQuiz:: + TX_ASM + xor a + ld [wOpponentAfterWrongAnswer], a + ld a, [wHiddenObjectFunctionArgument] + push af + and $f + ld [hGymGateIndex], a + pop af + and $f0 + swap a + ld [hGymGateAnswer], a + ld hl, CinnabarGymQuizIntroText + call PrintText + ld a, [hGymGateIndex] + dec a + add a + ld d, 0 + ld e, a + ld hl, CinnabarQuizQuestions + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + call PrintText + ld a, 1 + ld [wDoNotWaitForButtonPressAfterDisplayingText], a + call CinnabarGymQuiz_1ea92 + jp TextScriptEnd + +CinnabarGymQuizIntroText: + TX_FAR _CinnabarGymQuizIntroText + db "@" + +CinnabarQuizQuestions: + dw CinnabarQuizQuestionsText1 + dw CinnabarQuizQuestionsText2 + dw CinnabarQuizQuestionsText3 + dw CinnabarQuizQuestionsText4 + dw CinnabarQuizQuestionsText5 + dw CinnabarQuizQuestionsText6 + +CinnabarQuizQuestionsText1: + TX_FAR _CinnabarQuizQuestionsText1 + db "@" + +CinnabarQuizQuestionsText2: + TX_FAR _CinnabarQuizQuestionsText2 + db "@" + +CinnabarQuizQuestionsText3: + TX_FAR _CinnabarQuizQuestionsText3 + db "@" + +CinnabarQuizQuestionsText4: + TX_FAR _CinnabarQuizQuestionsText4 + db "@" + +CinnabarQuizQuestionsText5: + TX_FAR _CinnabarQuizQuestionsText5 + db "@" + +CinnabarQuizQuestionsText6: + TX_FAR _CinnabarQuizQuestionsText6 + db "@" + +CinnabarGymGateFlagAction: + EventFlagAddress hl, EVENT_CINNABAR_GYM_GATE0_UNLOCKED + predef_jump FlagActionPredef + +CinnabarGymQuiz_1ea92: + call YesNoChoice + ld a, [hGymGateAnswer] + ld c, a + ld a, [wCurrentMenuItem] + cp c + jr nz, .wrongAnswer + ld hl, wCurrentMapScriptFlags + set 5, [hl] + ld a, [hGymGateIndex] + ld [hBackupGymGateIndex], a + ld hl, CinnabarGymQuizCorrectText + call PrintText + ld a, [hBackupGymGateIndex] + AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0 + ld c, a + ld b, FLAG_SET + call CinnabarGymGateFlagAction + jp UpdateCinnabarGymGateTileBlocks_ +.wrongAnswer + call WaitForSoundToFinish + ld a, SFX_DENIED + call PlaySound + call WaitForSoundToFinish + ld hl, CinnabarGymQuizIncorrectText + call PrintText + ld a, [hGymGateIndex] + add $2 + AdjustEventBit EVENT_BEAT_CINNABAR_GYM_TRAINER_0, 2 + ld c, a + ld b, FLAG_TEST + EventFlagAddress hl, EVENT_BEAT_CINNABAR_GYM_TRAINER_0 + predef FlagActionPredef + ld a, c + and a + ret nz + ld a, [hGymGateIndex] + add $2 + ld [wOpponentAfterWrongAnswer], a + ret + +CinnabarGymQuizCorrectText: + TX_SFX_ITEM_1 + TX_FAR _CinnabarGymQuizCorrectText + TX_BLINK + TX_ASM + + ld a, [hBackupGymGateIndex] + AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0 + ld c, a + ld b, FLAG_TEST + call CinnabarGymGateFlagAction + ld a, c + and a + jp nz, TextScriptEnd + call WaitForSoundToFinish + ld a, SFX_GO_INSIDE + call PlaySound + call WaitForSoundToFinish + jp TextScriptEnd + +CinnabarGymQuizIncorrectText: + TX_FAR _CinnabarGymQuizIncorrectText + db "@" + +UpdateCinnabarGymGateTileBlocks_:: +; Update the overworld map with open floor blocks or locked gate blocks +; depending on event flags. + ld a, 6 + ld [hGymGateIndex], a +.loop + ld a, [hGymGateIndex] + dec a + add a + add a + ld d, 0 + ld e, a + ld hl, CinnabarGymGateCoords + add hl, de + ld a, [hli] + ld b, [hl] + ld c, a + inc hl + ld a, [hl] + ld [wGymGateTileBlock], a + push bc + ld a, [hGymGateIndex] + ld [hBackupGymGateIndex], a + AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0 + ld c, a + ld b, FLAG_TEST + call CinnabarGymGateFlagAction + ld a, c + and a + jr nz, .unlocked + ld a, [wGymGateTileBlock] + jr .next +.unlocked + ld a, $e +.next + pop bc + ld [wNewTileBlockID], a + predef ReplaceTileBlock + ld hl, hGymGateIndex + dec [hl] + jr nz, .loop + ret + +CinnabarGymGateCoords: + ; format: x-coord, y-coord, direction, padding + ; direction: $54 = horizontal gate, $5f = vertical gate + db $09,$03,$54,$00 + db $06,$03,$54,$00 + db $06,$06,$54,$00 + db $03,$08,$5f,$00 + db $02,$06,$54,$00 + db $02,$03,$54,$00 diff --git a/engine/events/hidden_objects/elevator.asm b/engine/events/hidden_objects/elevator.asm new file mode 100644 index 00000000..e72ca44b --- /dev/null +++ b/engine/events/hidden_objects/elevator.asm @@ -0,0 +1,3 @@ +ElevatorText:: + TX_FAR _ElevatorText + db "@" diff --git a/engine/events/hidden_objects/fighting_dojo.asm b/engine/events/hidden_objects/fighting_dojo.asm new file mode 100644 index 00000000..94d4871d --- /dev/null +++ b/engine/events/hidden_objects/fighting_dojo.asm @@ -0,0 +1,23 @@ +PrintFightingDojoText2: + call EnableAutoTextBoxDrawing + tx_pre_jump EnemiesOnEverySideText + +EnemiesOnEverySideText:: + TX_FAR _EnemiesOnEverySideText + db "@" + +PrintFightingDojoText3: + call EnableAutoTextBoxDrawing + tx_pre_jump WhatGoesAroundComesAroundText + +WhatGoesAroundComesAroundText:: + TX_FAR _WhatGoesAroundComesAroundText + db "@" + +PrintFightingDojoText: + call EnableAutoTextBoxDrawing + tx_pre_jump FightingDojoText + +FightingDojoText:: + TX_FAR _FightingDojoText + db "@" diff --git a/engine/events/hidden_objects/gym_statues.asm b/engine/events/hidden_objects/gym_statues.asm new file mode 100644 index 00000000..e9a407b2 --- /dev/null +++ b/engine/events/hidden_objects/gym_statues.asm @@ -0,0 +1,48 @@ +GymStatues: +; if in a gym and have the corresponding badge, a = GymStatueText2_id and jp PrintPredefTextID +; if in a gym and don’t have the corresponding badge, a = GymStatueText1_id and jp PrintPredefTextID +; else ret + call EnableAutoTextBoxDrawing + ld a, [wSpriteStateData1 + 9] + cp SPRITE_FACING_UP + ret nz + ld hl, .BadgeFlags + ld a, [wCurMap] + ld b, a +.loop + ld a, [hli] + cp $ff + ret z + cp b + jr z, .match + inc hl + jr .loop +.match + ld b, [hl] + ld a, [wBeatGymFlags] + and b + cp b + tx_pre_id GymStatueText2 + jr z, .haveBadge + tx_pre_id GymStatueText1 +.haveBadge + jp PrintPredefTextID + +.BadgeFlags: + db PEWTER_GYM, %00000001 + db CERULEAN_GYM, %00000010 + db VERMILION_GYM,%00000100 + db CELADON_GYM, %00001000 + db FUCHSIA_GYM, %00010000 + db SAFFRON_GYM, %00100000 + db CINNABAR_GYM, %01000000 + db VIRIDIAN_GYM, %10000000 + db $ff + +GymStatueText1:: + TX_FAR _GymStatueText1 + db "@" + +GymStatueText2:: + TX_FAR _GymStatueText2 + db "@" diff --git a/engine/events/hidden_objects/indigo_plateau_hq.asm b/engine/events/hidden_objects/indigo_plateau_hq.asm new file mode 100644 index 00000000..d0d0b8c2 --- /dev/null +++ b/engine/events/hidden_objects/indigo_plateau_hq.asm @@ -0,0 +1,10 @@ +PrintIndigoPlateauHQText: + ld a, [wSpriteStateData1 + 9] + cp SPRITE_FACING_UP + ret nz + call EnableAutoTextBoxDrawing + tx_pre_jump IndigoPlateauHQText + +IndigoPlateauHQText:: + TX_FAR _IndigoPlateauHQText + db "@" diff --git a/engine/events/hidden_objects/indigo_plateau_statues.asm b/engine/events/hidden_objects/indigo_plateau_statues.asm new file mode 100644 index 00000000..62b31e0a --- /dev/null +++ b/engine/events/hidden_objects/indigo_plateau_statues.asm @@ -0,0 +1,24 @@ +IndigoPlateauStatues:: + TX_ASM + ld hl, IndigoPlateauStatuesText1 + call PrintText + ld a, [wXCoord] + bit 0, a + ld hl, IndigoPlateauStatuesText2 + jr nz, .ok + ld hl, IndigoPlateauStatuesText3 +.ok + call PrintText + jp TextScriptEnd + +IndigoPlateauStatuesText1: + TX_FAR _IndigoPlateauStatuesText1 + db "@" + +IndigoPlateauStatuesText2: + TX_FAR _IndigoPlateauStatuesText2 + db "@" + +IndigoPlateauStatuesText3: + TX_FAR _IndigoPlateauStatuesText3 + db "@" diff --git a/engine/events/hidden_objects/magazines.asm b/engine/events/hidden_objects/magazines.asm new file mode 100644 index 00000000..af31b317 --- /dev/null +++ b/engine/events/hidden_objects/magazines.asm @@ -0,0 +1,8 @@ +PrintMagazinesText: + call EnableAutoTextBoxDrawing + tx_pre MagazinesText + ret + +MagazinesText:: + TX_FAR _MagazinesText + db "@" diff --git a/engine/events/hidden_objects/museum_fossils.asm b/engine/events/hidden_objects/museum_fossils.asm new file mode 100644 index 00000000..8636418c --- /dev/null +++ b/engine/events/hidden_objects/museum_fossils.asm @@ -0,0 +1,52 @@ +AerodactylFossil: + ld a, FOSSIL_AERODACTYL + ld [wcf91], a + call DisplayMonFrontSpriteInBox + call EnableAutoTextBoxDrawing + tx_pre AerodactylFossilText + ret + +AerodactylFossilText:: + TX_FAR _AerodactylFossilText + db "@" + +KabutopsFossil: + ld a, FOSSIL_KABUTOPS + ld [wcf91], a + call DisplayMonFrontSpriteInBox + call EnableAutoTextBoxDrawing + tx_pre KabutopsFossilText + ret + +KabutopsFossilText:: + TX_FAR _KabutopsFossilText + db "@" + +DisplayMonFrontSpriteInBox: +; Displays a pokemon's front sprite in a pop-up window. +; [wcf91] = pokemon internal id number + ld a, 1 + ld [hAutoBGTransferEnabled], a + call Delay3 + xor a + ld [hWY], a + call SaveScreenTilesToBuffer1 + ld a, MON_SPRITE_POPUP + ld [wTextBoxID], a + call DisplayTextBoxID + call UpdateSprites + ld a, [wcf91] + ld [wd0b5], a + call GetMonHeader + ld de, vChars1 + $310 + call LoadMonFrontSprite + ld a, $80 + ld [hStartTileID], a + coord hl, 10, 11 + predef AnimateSendingOutMon + call WaitForTextScrollButtonPress + call LoadScreenTilesFromBuffer1 + call Delay3 + ld a, $90 + ld [hWY], a + ret diff --git a/engine/events/hidden_objects/new_bike.asm b/engine/events/hidden_objects/new_bike.asm new file mode 100644 index 00000000..7836262e --- /dev/null +++ b/engine/events/hidden_objects/new_bike.asm @@ -0,0 +1,7 @@ +PrintNewBikeText: + call EnableAutoTextBoxDrawing + tx_pre_jump NewBicycleText + +NewBicycleText:: + TX_FAR _NewBicycleText + db "@" diff --git a/engine/events/hidden_objects/oaks_lab_email.asm b/engine/events/hidden_objects/oaks_lab_email.asm new file mode 100644 index 00000000..c59ff9ac --- /dev/null +++ b/engine/events/hidden_objects/oaks_lab_email.asm @@ -0,0 +1,10 @@ +DisplayOakLabEmailText: + ld a, [wSpriteStateData1 + 9] + cp SPRITE_FACING_UP + ret nz + call EnableAutoTextBoxDrawing + tx_pre_jump OakLabEmailText + +OakLabEmailText:: + TX_FAR _OakLabEmailText + db "@" diff --git a/engine/events/hidden_objects/oaks_lab_posters.asm b/engine/events/hidden_objects/oaks_lab_posters.asm new file mode 100644 index 00000000..0fe21cf3 --- /dev/null +++ b/engine/events/hidden_objects/oaks_lab_posters.asm @@ -0,0 +1,29 @@ +DisplayOakLabLeftPoster: + call EnableAutoTextBoxDrawing + tx_pre_jump PushStartText + +PushStartText:: + TX_FAR _PushStartText + db "@" + +DisplayOakLabRightPoster: + call EnableAutoTextBoxDrawing + ld hl, wPokedexOwned + ld b, wPokedexOwnedEnd - wPokedexOwned + call CountSetBits + ld a, [wNumSetBits] + cp 2 + tx_pre_id SaveOptionText + jr c, .ownLessThanTwo + ; own two or more mon + tx_pre_id StrengthsAndWeaknessesText +.ownLessThanTwo + jp PrintPredefTextID + +SaveOptionText:: + TX_FAR _SaveOptionText + db "@" + +StrengthsAndWeaknessesText:: + TX_FAR _StrengthsAndWeaknessesText + db "@" diff --git a/engine/events/hidden_objects/pokecenter_pc.asm b/engine/events/hidden_objects/pokecenter_pc.asm new file mode 100644 index 00000000..c1225d3a --- /dev/null +++ b/engine/events/hidden_objects/pokecenter_pc.asm @@ -0,0 +1,11 @@ +OpenPokemonCenterPC: + ld a, [wSpriteStateData1 + 9] + cp SPRITE_FACING_UP ; check to see if player is facing up + ret nz + call EnableAutoTextBoxDrawing + ld a, $1 + ld [wAutoTextBoxDrawingControl], a + tx_pre_jump PokemonCenterPCText + +PokemonCenterPCText:: + TX_POKECENTER_PC diff --git a/engine/events/hidden_objects/pokemon_stuff.asm b/engine/events/hidden_objects/pokemon_stuff.asm new file mode 100644 index 00000000..b78b2500 --- /dev/null +++ b/engine/events/hidden_objects/pokemon_stuff.asm @@ -0,0 +1,3 @@ +PokemonStuffText:: + TX_FAR _PokemonStuffText + db "@" diff --git a/engine/events/hidden_objects/reds_room.asm b/engine/events/hidden_objects/reds_room.asm new file mode 100644 index 00000000..b124f9c6 --- /dev/null +++ b/engine/events/hidden_objects/reds_room.asm @@ -0,0 +1,14 @@ +PrintRedSNESText: + call EnableAutoTextBoxDrawing + tx_pre_jump RedBedroomSNESText + +RedBedroomSNESText:: + TX_FAR _RedBedroomSNESText + db "@" + +OpenRedsPC: + call EnableAutoTextBoxDrawing + tx_pre_jump RedBedroomPCText + +RedBedroomPCText:: + TX_PLAYERS_PC diff --git a/engine/events/hidden_objects/route_15_binoculars.asm b/engine/events/hidden_objects/route_15_binoculars.asm new file mode 100644 index 00000000..b380bb33 --- /dev/null +++ b/engine/events/hidden_objects/route_15_binoculars.asm @@ -0,0 +1,14 @@ +Route15GateLeftBinoculars: + ld a, [wSpriteStateData1 + 9] + cp SPRITE_FACING_UP + ret nz + call EnableAutoTextBoxDrawing + tx_pre Route15UpstairsBinocularsText + ld a, ARTICUNO + ld [wcf91], a + call PlayCry + jp DisplayMonFrontSpriteInBox + +Route15UpstairsBinocularsText:: + TX_FAR _Route15UpstairsBinocularsText + db "@" diff --git a/engine/events/hidden_objects/safari_game.asm b/engine/events/hidden_objects/safari_game.asm new file mode 100644 index 00000000..68fc943f --- /dev/null +++ b/engine/events/hidden_objects/safari_game.asm @@ -0,0 +1,79 @@ +SafariZoneCheck:: + CheckEventHL EVENT_IN_SAFARI_ZONE ; if we are not in the Safari Zone, + jr z, SafariZoneGameStillGoing ; don't bother printing game over text + ld a, [wNumSafariBalls] + and a + jr z, SafariZoneGameOver + jr SafariZoneGameStillGoing + +SafariZoneCheckSteps:: + ld a, [wSafariSteps] + ld b, a + ld a, [wSafariSteps + 1] + ld c, a + or b + jr z, SafariZoneGameOver + dec bc + ld a, b + ld [wSafariSteps], a + ld a, c + ld [wSafariSteps + 1], a +SafariZoneGameStillGoing: + xor a + ld [wSafariZoneGameOver], a + ret + +SafariZoneGameOver: + call EnableAutoTextBoxDrawing + xor a + ld [wAudioFadeOutControl], a + dec a ; SFX_STOP_ALL_MUSIC + call PlaySound + ld c, BANK(SFX_Safari_Zone_PA) + ld a, SFX_SAFARI_ZONE_PA + call PlayMusic +.waitForMusicToPlay + ld a, [wChannelSoundIDs + Ch5] + cp SFX_SAFARI_ZONE_PA + jr nz, .waitForMusicToPlay + ld a, TEXT_SAFARI_GAME_OVER + ld [hSpriteIndexOrTextID], a + call DisplayTextID + xor a + ld [wPlayerMovingDirection], a + ld a, SAFARI_ZONE_GATE + ld [hWarpDestinationMap], a + ld a, $3 + ld [wDestinationWarpID], a + ld a, $5 + ld [wSafariZoneGateCurScript], a + SetEvent EVENT_SAFARI_GAME_OVER + ld a, 1 + ld [wSafariZoneGameOver], a + ret + +PrintSafariGameOverText:: + xor a + ld [wJoyIgnore], a + ld hl, SafariGameOverText + jp PrintText + +SafariGameOverText: + TX_ASM + ld a, [wNumSafariBalls] + and a + jr z, .noMoreSafariBalls + ld hl, TimesUpText + call PrintText +.noMoreSafariBalls + ld hl, GameOverText + call PrintText + jp TextScriptEnd + +TimesUpText: + TX_FAR _TimesUpText + db "@" + +GameOverText: + TX_FAR _GameOverText + db "@" diff --git a/engine/events/hidden_objects/school_blackboard.asm b/engine/events/hidden_objects/school_blackboard.asm new file mode 100644 index 00000000..4cd48d23 --- /dev/null +++ b/engine/events/hidden_objects/school_blackboard.asm @@ -0,0 +1,222 @@ +PrintBlackboardLinkCableText: + call EnableAutoTextBoxDrawing + ld a, $1 + ld [wDoNotWaitForButtonPressAfterDisplayingText], a + ld a, [wHiddenObjectFunctionArgument] + call PrintPredefTextID + ret + +LinkCableHelp:: + TX_ASM + call SaveScreenTilesToBuffer1 + ld hl, LinkCableHelpText1 + call PrintText + xor a + ld [wMenuItemOffset], a ; not used + ld [wCurrentMenuItem], a + ld [wLastMenuItem], a + ld a, A_BUTTON | B_BUTTON + ld [wMenuWatchedKeys], a + ld a, 3 + ld [wMaxMenuItem], a + ld a, 2 + ld [wTopMenuItemY], a + ld a, 1 + ld [wTopMenuItemX], a +.linkHelpLoop + ld hl, wd730 + set 6, [hl] + coord hl, 0, 0 + ld b, 8 + ld c, 13 + call TextBoxBorder + coord hl, 2, 2 + ld de, HowToLinkText + call PlaceString + ld hl, LinkCableHelpText2 + call PrintText + call HandleMenuInput + bit 1, a ; pressed b + jr nz, .exit + ld a, [wCurrentMenuItem] + cp 3 ; pressed a on "STOP READING" + jr z, .exit + ld hl, wd730 + res 6, [hl] + ld hl, LinkCableInfoTexts + add a + ld d, 0 + ld e, a + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + call PrintText + jp .linkHelpLoop +.exit + ld hl, wd730 + res 6, [hl] + call LoadScreenTilesFromBuffer1 + jp TextScriptEnd + +LinkCableHelpText1: + TX_FAR _LinkCableHelpText1 + db "@" + +LinkCableHelpText2: + TX_FAR _LinkCableHelpText2 + db "@" + +HowToLinkText: + db "HOW TO LINK" + next "COLOSSEUM" + next "TRADE CENTER" + next "STOP READING@" + +LinkCableInfoTexts: + dw LinkCableInfoText1 + dw LinkCableInfoText2 + dw LinkCableInfoText3 + +LinkCableInfoText1: + TX_FAR _LinkCableInfoText1 + db "@" + +LinkCableInfoText2: + TX_FAR _LinkCableInfoText2 + db "@" + +LinkCableInfoText3: + TX_FAR _LinkCableInfoText3 + db "@" + +ViridianSchoolBlackboard:: + TX_ASM + call SaveScreenTilesToBuffer1 + ld hl, ViridianSchoolBlackboardText1 + call PrintText + xor a + ld [wMenuItemOffset], a + ld [wCurrentMenuItem], a + ld [wLastMenuItem], a + ld a, D_LEFT | D_RIGHT | A_BUTTON | B_BUTTON + ld [wMenuWatchedKeys], a + ld a, 2 + ld [wMaxMenuItem], a + ld a, 2 + ld [wTopMenuItemY], a + ld a, 1 + ld [wTopMenuItemX], a +.blackboardLoop + ld hl, wd730 + set 6, [hl] + coord hl, 0, 0 + lb bc, 6, 10 + call TextBoxBorder + coord hl, 1, 2 + ld de, StatusAilmentText1 + call PlaceString + coord hl, 6, 2 + ld de, StatusAilmentText2 + call PlaceString + ld hl, ViridianSchoolBlackboardText2 + call PrintText + call HandleMenuInput ; pressing up and down is handled in here + bit 1, a ; pressed b + jr nz, .exitBlackboard + bit 4, a ; pressed right + jr z, .didNotPressRight + ; move cursor to right column + ld a, 2 + ld [wMaxMenuItem], a + ld a, 2 + ld [wTopMenuItemY], a + ld a, 6 + ld [wTopMenuItemX], a + ld a, 3 ; in the the right column, use an offset to prevent overlap + ld [wMenuItemOffset], a + jr .blackboardLoop +.didNotPressRight + bit 5, a ; pressed left + jr z, .didNotPressLeftOrRight + ; move cursor to left column + ld a, 2 + ld [wMaxMenuItem], a + ld a, 2 + ld [wTopMenuItemY], a + ld a, 1 + ld [wTopMenuItemX], a + xor a + ld [wMenuItemOffset], a + jr .blackboardLoop +.didNotPressLeftOrRight + ld a, [wCurrentMenuItem] + ld b, a + ld a, [wMenuItemOffset] + add b + cp 5 ; cursor is pointing to "QUIT" + jr z, .exitBlackboard + ; we must have pressed a on a status condition + ; so print the text + ld hl, wd730 + res 6, [hl] + ld hl, ViridianBlackboardStatusPointers + add a + ld d, 0 + ld e, a + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + call PrintText + jp .blackboardLoop +.exitBlackboard + ld hl, wd730 + res 6, [hl] + call LoadScreenTilesFromBuffer1 + jp TextScriptEnd + +ViridianSchoolBlackboardText1: + TX_FAR _ViridianSchoolBlackboardText1 + db "@" + +ViridianSchoolBlackboardText2: + TX_FAR _ViridianSchoolBlackboardText2 + db "@" + +StatusAilmentText1: + db " SLP" + next " PSN" + next " PAR@" + +StatusAilmentText2: + db " BRN" + next " FRZ" + next " QUIT@@" + +ViridianBlackboardStatusPointers: + dw ViridianBlackboardSleepText + dw ViridianBlackboardPoisonText + dw ViridianBlackboardPrlzText + dw ViridianBlackboardBurnText + dw ViridianBlackboardFrozenText + +ViridianBlackboardSleepText: + TX_FAR _ViridianBlackboardSleepText + db "@" + +ViridianBlackboardPoisonText: + TX_FAR _ViridianBlackboardPoisonText + db "@" + +ViridianBlackboardPrlzText: + TX_FAR _ViridianBlackboardPrlzText + db "@" + +ViridianBlackboardBurnText: + TX_FAR _ViridianBlackboardBurnText + db "@" + +ViridianBlackboardFrozenText: + TX_FAR _ViridianBlackboardFrozenText + db "@" diff --git a/engine/events/hidden_object_functions14.asm b/engine/events/hidden_objects/school_notebooks.asm index 9e14c6a7..f5cc1341 100755..100644 --- a/engine/events/hidden_object_functions14.asm +++ b/engine/events/hidden_objects/school_notebooks.asm @@ -63,38 +63,3 @@ ViridianSchoolNotebookText3: ViridianSchoolNotebookText4: TX_FAR _ViridianSchoolNotebookText4 db "@" - -PrintFightingDojoText2: - call EnableAutoTextBoxDrawing - tx_pre_jump EnemiesOnEverySideText - -EnemiesOnEverySideText:: - TX_FAR _EnemiesOnEverySideText - db "@" - -PrintFightingDojoText3: - call EnableAutoTextBoxDrawing - tx_pre_jump WhatGoesAroundComesAroundText - -WhatGoesAroundComesAroundText:: - TX_FAR _WhatGoesAroundComesAroundText - db "@" - -PrintFightingDojoText: - call EnableAutoTextBoxDrawing - tx_pre_jump FightingDojoText - -FightingDojoText:: - TX_FAR _FightingDojoText - db "@" - -PrintIndigoPlateauHQText: - ld a, [wSpriteStateData1 + 9] - cp SPRITE_FACING_UP - ret nz - call EnableAutoTextBoxDrawing - tx_pre_jump IndigoPlateauHQText - -IndigoPlateauHQText:: - TX_FAR _IndigoPlateauHQText - db "@" diff --git a/engine/events/hidden_objects/town_map.asm b/engine/events/hidden_objects/town_map.asm new file mode 100644 index 00000000..31e75d0d --- /dev/null +++ b/engine/events/hidden_objects/town_map.asm @@ -0,0 +1,22 @@ +TownMapText:: + TX_FAR _TownMapText + TX_BLINK + TX_ASM + ld a, $1 + ld [wDoNotWaitForButtonPressAfterDisplayingText], a + ld hl, wd730 + set 6, [hl] + call GBPalWhiteOutWithDelay3 + xor a + ld [hWY], a + inc a + ld [hAutoBGTransferEnabled], a + call LoadFontTilePatterns + callba DisplayTownMap + ld hl, wd730 + res 6, [hl] + ld de, TextScriptEnd + push de + ld a, [hLoadedROMBank] + push af + jp CloseTextDisplay diff --git a/engine/events/hidden_objects/vermilion_gym_trash.asm b/engine/events/hidden_objects/vermilion_gym_trash.asm new file mode 100644 index 00000000..c2d22cd5 --- /dev/null +++ b/engine/events/hidden_objects/vermilion_gym_trash.asm @@ -0,0 +1,169 @@ +PrintTrashText: + call EnableAutoTextBoxDrawing + tx_pre_jump VermilionGymTrashText + +VermilionGymTrashText:: + TX_FAR _VermilionGymTrashText + db "@" + +GymTrashScript: + call EnableAutoTextBoxDrawing + ld a, [wHiddenObjectFunctionArgument] + ld [wGymTrashCanIndex], a + +; Don't do the trash can puzzle if it's already been done. + CheckEvent EVENT_2ND_LOCK_OPENED + jr z, .ok + + tx_pre_jump VermilionGymTrashText + +.ok + CheckEventReuseA EVENT_1ST_LOCK_OPENED + jr nz, .trySecondLock + + ld a, [wFirstLockTrashCanIndex] + ld b, a + ld a, [wGymTrashCanIndex] + cp b + jr z, .openFirstLock + + tx_pre_id VermilionGymTrashText + jr .done + +.openFirstLock +; Next can is trying for the second switch. + SetEvent EVENT_1ST_LOCK_OPENED + + ld hl, GymTrashCans + ld a, [wGymTrashCanIndex] + ; * 5 + ld b, a + add a + add a + add b + + ld d, 0 + ld e, a + add hl, de + ld a, [hli] + +; There is a bug in this code. It should calculate a value in the range [0, 3] +; but if the mask and random number don't have any 1 bits in common, then +; the result of the AND will be 0. When 1 is subtracted from that, the value +; will become $ff. This will result in 255 being added to hl, which will cause +; hl to point to one of the zero bytes that pad the end of the ROM bank. +; Trash can 0 was intended to be able to have the second lock only when the +; first lock was in trash can 1 or 3. However, due to this bug, trash can 0 can +; have the second lock regardless of which trash can had the first lock. + + ld [hGymTrashCanRandNumMask], a + push hl + call Random + swap a + ld b, a + ld a, [hGymTrashCanRandNumMask] + and b + dec a + pop hl + + ld d, 0 + ld e, a + add hl, de + ld a, [hl] + and $f + ld [wSecondLockTrashCanIndex], a + + tx_pre_id VermilionGymTrashSuccessText1 + jr .done + +.trySecondLock + ld a, [wSecondLockTrashCanIndex] + ld b, a + ld a, [wGymTrashCanIndex] + cp b + jr z, .openSecondLock + +; Reset the cans. + ResetEvent EVENT_1ST_LOCK_OPENED + call Random + + and $e + ld [wFirstLockTrashCanIndex], a + + tx_pre_id VermilionGymTrashFailText + jr .done + +.openSecondLock +; Completed the trash can puzzle. + SetEvent EVENT_2ND_LOCK_OPENED + ld hl, wCurrentMapScriptFlags + set 6, [hl] + + tx_pre_id VermilionGymTrashSuccessText3 + +.done + jp PrintPredefTextID + +GymTrashCans: +; byte 0: mask for random number +; bytes 1-4: indices of the trash cans that can have the second lock +; (but see the comment above explaining a bug regarding this) +; Note that the mask is simply the number of valid trash can indices that +; follow. The remaining bytes are filled with 0 to pad the length of each entry +; to 5 bytes. + db 2, 1, 3, 0, 0 ; 0 + db 3, 0, 2, 4, 0 ; 1 + db 2, 1, 5, 0, 0 ; 2 + db 3, 0, 4, 6, 0 ; 3 + db 4, 1, 3, 5, 7 ; 4 + db 3, 2, 4, 8, 0 ; 5 + db 3, 3, 7, 9, 0 ; 6 + db 4, 4, 6, 8, 10 ; 7 + db 3, 5, 7, 11, 0 ; 8 + db 3, 6, 10, 12, 0 ; 9 + db 4, 7, 9, 11, 13 ; 10 + db 3, 8, 10, 14, 0 ; 11 + db 2, 9, 13, 0, 0 ; 12 + db 3, 10, 12, 14, 0 ; 13 + db 2, 11, 13, 0, 0 ; 14 + +VermilionGymTrashSuccessText1:: + TX_FAR _VermilionGymTrashSuccessText1 + TX_ASM + call WaitForSoundToFinish + ld a, SFX_SWITCH + call PlaySound + call WaitForSoundToFinish + jp TextScriptEnd + +; unused +VermilionGymTrashSuccessText2:: + TX_FAR _VermilionGymTrashSuccessText2 + db "@" + +; unused +VermilionGymTrashSuccesPlaySfx: + TX_ASM + call WaitForSoundToFinish + ld a, SFX_SWITCH + call PlaySound + call WaitForSoundToFinish + jp TextScriptEnd + +VermilionGymTrashSuccessText3:: + TX_FAR _VermilionGymTrashSuccessText3 + TX_ASM + call WaitForSoundToFinish + ld a, SFX_GO_INSIDE + call PlaySound + call WaitForSoundToFinish + jp TextScriptEnd + +VermilionGymTrashFailText:: + TX_FAR _VermilionGymTrashFailText + TX_ASM + call WaitForSoundToFinish + ld a, SFX_DENIED + call PlaySound + call WaitForSoundToFinish + jp TextScriptEnd diff --git a/engine/events/in_game_trades.asm b/engine/events/in_game_trades.asm index c01bc3c3..c1466485 100755 --- a/engine/events/in_game_trades.asm +++ b/engine/events/in_game_trades.asm @@ -84,7 +84,7 @@ InGameTrade_GetMonName: ld bc, NAME_LENGTH jp CopyData -INCLUDE "data/trades.asm" +INCLUDE "data/events/trades.asm" InGameTrade_DoTrade: xor a ; NORMAL_PARTY_MENU diff --git a/engine/events/pick_up_item.asm b/engine/events/pick_up_item.asm index 9f19100a..5a658f22 100644 --- a/engine/events/pick_up_item.asm +++ b/engine/events/pick_up_item.asm @@ -15,7 +15,7 @@ PickUpItem: .isMissable ld a, [hl] - ld [$ffdb], a + ld [hMissableObjectIndex], a ld hl, wMapSpriteExtraData ld a, [hSpriteIndexOrTextID] @@ -30,7 +30,7 @@ PickUpItem: call GiveItem jr nc, .BagFull - ld a, [$ffdb] + ld a, [hMissableObjectIndex] ld [wMissableObjectIndex], a predef HideObject ld a, 1 diff --git a/engine/events/prize_menu.asm b/engine/events/prize_menu.asm index 5e08bb8f..5a00a89e 100755 --- a/engine/events/prize_menu.asm +++ b/engine/events/prize_menu.asm @@ -131,10 +131,8 @@ GetPrizeMenuId: coord hl, 13, 5 ; reg. c: ; [low nybble] number of bytes -; [bit 765 = %100] space-padding (not zero-padding) +; [bits 765 = %100] space-padding (not zero-padding) ld c, (1 << 7 | 2) -; Function $15CD displays BCD value (same routine -; used by text-command $02) call PrintBCDNumber ld de, wPrize2Price coord hl, 13, 7 @@ -145,7 +143,7 @@ GetPrizeMenuId: ld c, (1 << 7 | 2) jp PrintBCDNumber -INCLUDE "data/prizes.asm" +INCLUDE "data/events/prizes.asm" PrintPrizePrice: coord hl, 11, 0 @@ -303,4 +301,4 @@ GetPrizeMonLevel: ld [wCurEnemyLVL], a ret -INCLUDE "data/prize_mon_levels.asm" +INCLUDE "data/events/prize_mon_levels.asm" diff --git a/engine/events/saffron_guards.asm b/engine/events/saffron_guards.asm index 091cfa1a..59c2725c 100755 --- a/engine/events/saffron_guards.asm +++ b/engine/events/saffron_guards.asm @@ -2,7 +2,7 @@ RemoveGuardDrink:: ld hl, GuardDrinksList .drinkLoop ld a, [hli] - ld [$ffdb], a + ld [hItemToRemoveID], a and a ret z push hl @@ -12,4 +12,4 @@ RemoveGuardDrink:: jr z, .drinkLoop jpba RemoveItemByID -INCLUDE "data/guard_drink_items.asm" +INCLUDE "data/items/guard_drink_items.asm" diff --git a/engine/events/set_blackout_map.asm b/engine/events/set_blackout_map.asm index 14f0ba28..e8460240 100644 --- a/engine/events/set_blackout_map.asm +++ b/engine/events/set_blackout_map.asm @@ -22,4 +22,4 @@ SetLastBlackoutMap: pop hl ret -INCLUDE "data/rest_house_maps.asm" +INCLUDE "data/maps/rest_house_maps.asm" diff --git a/engine/events/vending_machine.asm b/engine/events/vending_machine.asm index 554c5d4f..4a39f7b9 100755 --- a/engine/events/vending_machine.asm +++ b/engine/events/vending_machine.asm @@ -130,4 +130,4 @@ LoadVendingMachineItem: ld [hVendingMachinePrice + 2], a ret -INCLUDE "data/vending_prices.asm" +INCLUDE "data/items/vending_prices.asm" diff --git a/engine/gfx/hp_bar.asm b/engine/gfx/hp_bar.asm index 221bd7a9..4b91da58 100755 --- a/engine/gfx/hp_bar.asm +++ b/engine/gfx/hp_bar.asm @@ -6,7 +6,7 @@ HPBarLength: GetHPBarLength: push hl xor a - ld hl, H_MULTIPLICAND + ld hl, hMultiplicand ld [hli], a ld a, b ld [hli], a @@ -21,22 +21,22 @@ GetHPBarLength: rr e srl d rr e - ld a, [H_MULTIPLICAND+1] + ld a, [hMultiplicand+1] ld b, a - ld a, [H_MULTIPLICAND+2] + ld a, [hMultiplicand+2] srl b ; divide multiplication result as well rr a srl b rr a - ld [H_MULTIPLICAND+2], a + ld [hMultiplicand+2], a ld a, b - ld [H_MULTIPLICAND+1], a + ld [hMultiplicand+1], a .maxHPSmaller256 ld a, e - ld [H_DIVISOR], a + ld [hDivisor], a ld b, $4 call Divide - ld a, [H_MULTIPLICAND+2] + ld a, [hMultiplicand+2] ld e, a ; e = bc * 48 / de (num of pixels of HP bar) pop hl and a @@ -213,7 +213,7 @@ UpdateHPBar_PrintHPNumber: ld a, [wHPBarOldHP + 1] ld [wHPBarTempHP], a push hl - ld a, [hFlags_0xFFF6] + ld a, [hFlagsFFF6] bit 0, a jr z, .asm_fb15 ld de, $9 diff --git a/engine/gfx/mon_icons.asm b/engine/gfx/mon_icons.asm index d2913715..7a96b36c 100755 --- a/engine/gfx/mon_icons.asm +++ b/engine/gfx/mon_icons.asm @@ -162,7 +162,7 @@ LoadMonPartySpriteGfxWithLCDDisabled: jr nz, .loop jp EnableLCD -INCLUDE "data/mon_party_sprite_pointers.asm" +INCLUDE "data/icon_pointers.asm" WriteMonPartySpriteOAMByPartyIndex: ; Write OAM blocks for the party mon in [hPartyMonIndex]. @@ -278,7 +278,7 @@ GetPartyMonSpriteID: srl a ret -INCLUDE "data/mon_party_sprites.asm" +INCLUDE "data/pokemon/menu_icons.asm" INC_FRAME_1 EQUS "0, $20" INC_FRAME_2 EQUS "$20, $20" diff --git a/engine/gfx/oam_dma.asm b/engine/gfx/oam_dma.asm index b0d64675..aeea4c01 100644 --- a/engine/gfx/oam_dma.asm +++ b/engine/gfx/oam_dma.asm @@ -1,12 +1,12 @@ WriteDMACodeToHRAM:: ; Since no other memory is available during OAM DMA, ; DMARoutine is copied to HRAM and executed there. - ld c, $ff80 % $100 + ld c, hDMARoutine % $100 ld b, DMARoutineEnd - DMARoutine ld hl, DMARoutine .copy ld a, [hli] - ld [$ff00+c], a + ldh [c], a inc c dec b jr nz, .copy diff --git a/engine/gfx/palettes.asm b/engine/gfx/palettes.asm index 39991d48..58e08e86 100755 --- a/engine/gfx/palettes.asm +++ b/engine/gfx/palettes.asm @@ -1,11 +1,11 @@ _RunPaletteCommand: call GetPredefRegisters ld a, b - cp $ff - jr nz, .next - ld a, [wDefaultPaletteCommand] ; use default command if command ID is $ff -.next - cp UPDATE_PARTY_MENU_BLK_PACKET + cp SET_PAL_DEFAULT + jr nz, .not_default + ld a, [wDefaultPaletteCommand] +.not_default + cp SET_PAL_PARTY_MENU_HP_BARS jp z, UpdatePartyMenuBlkPacket ld l, a ld h, 0 @@ -632,10 +632,10 @@ CopySGBBorderTiles: jr nz, .tileLoop ret -INCLUDE "data/sgb_packets.asm" +INCLUDE "data/sgb/sgb_packets.asm" -INCLUDE "data/mon_palettes.asm" +INCLUDE "data/pokemon/palettes.asm" -INCLUDE "data/super_palettes.asm" +INCLUDE "data/sgb/sgb_palettes.asm" -INCLUDE "data/sgb_border.asm" +INCLUDE "data/sgb/sgb_border.asm" diff --git a/engine/gfx/screen_effects.asm b/engine/gfx/screen_effects.asm index 95f0ea25..0d3806c1 100755 --- a/engine/gfx/screen_effects.asm +++ b/engine/gfx/screen_effects.asm @@ -19,7 +19,7 @@ PredefShakeScreenVertically: ld [wDisableVBlankWYUpdate], a xor a .loop - ld [$ff96], a + ld [hMutateWY], a call .MutateWY call .MutateWY dec b @@ -30,9 +30,9 @@ PredefShakeScreenVertically: ret .MutateWY - ld a, [$ff96] + ld a, [hMutateWY] xor b - ld [$ff96], a + ld [hMutateWY], a ld [rWY], a ld c, 3 jp DelayFrames @@ -43,7 +43,7 @@ PredefShakeScreenHorizontally: call GetPredefRegisters xor a .loop - ld [$ff97], a + ld [hMutateWX], a call .MutateWX ld c, 1 call DelayFrames @@ -58,9 +58,9 @@ PredefShakeScreenHorizontally: ret .MutateWX - ld a, [$ff97] + ld a, [hMutateWX] xor b - ld [$ff97], a + ld [hMutateWX], a bit 7, a jr z, .skipZeroing xor a ; zero a if it's negative diff --git a/engine/items/item_effects.asm b/engine/items/item_effects.asm index 6e7bed1e..7e2aa227 100755 --- a/engine/items/item_effects.asm +++ b/engine/items/item_effects.asm @@ -239,14 +239,14 @@ ItemUseBall: ; Calculate MaxHP * 255. xor a - ld [H_MULTIPLICAND], a + ld [hMultiplicand], a ld hl, wEnemyMonMaxHP ld a, [hli] - ld [H_MULTIPLICAND + 1], a + ld [hMultiplicand + 1], a ld a, [hl] - ld [H_MULTIPLICAND + 2], a + ld [hMultiplicand + 2], a ld a, 255 - ld [H_MULTIPLIER], a + ld [hMultiplier], a call Multiply ; 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. ; Calculate (MaxHP * 255) / BallFactor. - ld [H_DIVISOR], a + ld [hDivisor], a ld b, 4 ; number of bytes in dividend call Divide @@ -281,17 +281,17 @@ ItemUseBall: .skip2 ; Let W = ((MaxHP * 255) / BallFactor) / max(HP / 4, 1). Calculate W. - ld [H_DIVISOR], a + ld [hDivisor], a ld b, 4 call Divide -; If W > 255, store 255 in [H_QUOTIENT + 3]. -; Let X = min(W, 255) = [H_QUOTIENT + 3]. - ld a, [H_QUOTIENT + 2] +; If W > 255, store 255 in [hQuotient + 3]. +; Let X = min(W, 255) = [hQuotient + 3]. + ld a, [hQuotient + 2] and a jr z, .skip3 ld a, 255 - ld [H_QUOTIENT + 3], a + ld [hQuotient + 3], a .skip3 pop bc ; b = Rand1 - Status @@ -302,7 +302,7 @@ ItemUseBall: jr c, .failedToCapture ; If W > 255, the ball captures the Pokémon. - ld a, [H_QUOTIENT + 2] + ld a, [hQuotient + 2] and a jr nz, .captured @@ -310,7 +310,7 @@ ItemUseBall: ; If Rand2 > X, the ball fails to capture the Pokémon. ld b, a - ld a, [H_QUOTIENT + 3] + ld a, [hQuotient + 3] cp b jr c, .failedToCapture @@ -318,17 +318,17 @@ ItemUseBall: jr .skipShakeCalculations .failedToCapture - ld a, [H_QUOTIENT + 3] + ld a, [hQuotient + 3] ld [wPokeBallCaptureCalcTemp], a ; Save X. ; Calculate CatchRate * 100. xor a - ld [H_MULTIPLICAND], a - ld [H_MULTIPLICAND + 1], a + ld [hMultiplicand], a + ld [hMultiplicand + 1], a ld a, [wEnemyMonActualCatchRate] - ld [H_MULTIPLICAND + 2], a + ld [hMultiplicand + 2], a ld a, 100 - ld [H_MULTIPLIER], a + ld [hMultiplier], a call Multiply ; Determine BallFactor2. @@ -349,26 +349,26 @@ ItemUseBall: .skip4 ; Let Y = (CatchRate * 100) / BallFactor2. Calculate Y. ld a, b - ld [H_DIVISOR], a + ld [hDivisor], a ld b, 4 call Divide ; If Y > 255, there are 3 shakes. ; Note that this shouldn't be possible. ; The maximum value of Y is (255 * 100) / 150 = 170. - ld a, [H_QUOTIENT + 2] + ld a, [hQuotient + 2] and a ld b, $63 ; 3 shakes jr nz, .setAnimData ; Calculate X * Y. ld a, [wPokeBallCaptureCalcTemp] - ld [H_MULTIPLIER], a + ld [hMultiplier], a call Multiply ; Calculate (X * Y) / 255. ld a, 255 - ld [H_DIVISOR], a + ld [hDivisor], a ld b, 4 call Divide @@ -386,19 +386,19 @@ ItemUseBall: .addAilmentValue ; If the Pokémon has a status ailment, add Status2. - ld a, [H_QUOTIENT + 3] + ld a, [hQuotient + 3] add b - ld [H_QUOTIENT + 3], a + ld [hQuotient + 3], a .skip5 ; 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. ; 0 ≤ Z < 10: 0 shakes (the ball misses) ; 10 ≤ Z < 30: 1 shake ; 30 ≤ Z < 70: 2 shakes ; 70 ≤ Z: 3 shakes - ld a, [H_QUOTIENT + 3] + ld a, [hQuotient + 3] cp 10 ld b, $20 jr c, .setAnimData @@ -422,7 +422,7 @@ ItemUseBall: ld a, TOSS_ANIM ld [wAnimationID], a xor a - ld [H_WHOSETURN], a + ld [hWhoseTurn], a ld [wAnimationType], a ld [wDamageMultipliers], a ld a, [wWhichPokemon] @@ -1018,18 +1018,18 @@ ItemUseMedicine: call AddNTimes ld a, [hli] ld [wHPBarMaxHP + 1], a - ld [H_DIVIDEND], a + ld [hDividend], a ld a, [hl] ld [wHPBarMaxHP], a - ld [H_DIVIDEND + 1], a + ld [hDividend + 1], a ld a, 5 - ld [H_DIVISOR], a + ld [hDivisor], a ld b, 2 ; number of bytes call Divide ; get 1/5 of max HP of pokemon that used Softboiled ld bc, (wPartyMon1HP + 1) - (wPartyMon1MaxHP + 1) 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 - ld a, [H_QUOTIENT + 3] + ld a, [hQuotient + 3] push af ld b, a ld a, [hl] @@ -1037,7 +1037,7 @@ ItemUseMedicine: sub b ld [hld], a ld [wHPBarNewHP], a - ld a, [H_QUOTIENT + 2] + ld a, [hQuotient + 2] ld b, a ld a, [hl] ld [wHPBarOldHP+1], a @@ -1050,15 +1050,15 @@ ItemUseMedicine: call AddNTimes ; calculate coordinates of HP bar of pokemon that used Softboiled ld a, SFX_HEAL_HP call PlaySoundWaitForCurrent - ld a, [hFlags_0xFFF6] + ld a, [hFlagsFFF6] set 0, a - ld [hFlags_0xFFF6], a + ld [hFlagsFFF6], a ld a, $02 ld [wHPBarType], a predef UpdateHPBar2 ; animate HP bar decrease of pokemon that used Softboiled - ld a, [hFlags_0xFFF6] + ld a, [hFlagsFFF6] res 0, a - ld [hFlags_0xFFF6], a + ld [hFlagsFFF6], a pop af ld b, a ; store heal amount (1/5 of max HP) ld hl, wHPBarOldHP + 1 @@ -1200,15 +1200,15 @@ ItemUseMedicine: jr z, .playStatusAilmentCuringSound ld a, SFX_HEAL_HP call PlaySoundWaitForCurrent - ld a, [hFlags_0xFFF6] + ld a, [hFlagsFFF6] set 0, a - ld [hFlags_0xFFF6], a + ld [hFlagsFFF6], a ld a, $02 ld [wHPBarType], a predef UpdateHPBar2 ; animate the HP bar lengthening - ld a, [hFlags_0xFFF6] + ld a, [hFlagsFFF6] res 0, a - ld [hFlags_0xFFF6], a + ld [hFlagsFFF6], a ld a, REVIVE_MSG ld [wPartyMenuTypeOrMessageID], a ld a, [wcf91] @@ -1224,13 +1224,13 @@ ItemUseMedicine: call PlaySoundWaitForCurrent .showHealingItemMessage xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a call ClearScreen dec a ld [wUpdateSpritesEnabled], a call RedrawPartyMenu ; redraws the party menu and displays the message ld a, 1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ld c, 50 call DelayFrames call WaitForTextScrollButtonPress @@ -1341,7 +1341,7 @@ ItemUseMedicine: push hl push de ld d, a - callab CalcExperience ; calculate experience for next level and store it at $ff96 + callab CalcExperience ; calculate experience for next level and store it at hExperience pop de pop hl ld bc, wPartyMon1Exp - wPartyMon1Level @@ -1459,7 +1459,7 @@ BaitRockCommon: ld [wAnimationID], a xor a ld [wAnimationType], a - ld [H_WHOSETURN], a + ld [hWhoseTurn], a ld [de], a ; zero escape factor (for bait), zero bait factor (for rock) .randomLoop ; loop until a random number less than 5 is generated call Random @@ -1698,7 +1698,7 @@ ItemUseXStat: call LoadScreenTilesFromBuffer1 ; restore saved screen call Delay3 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 pop hl pop af @@ -1844,8 +1844,8 @@ PlayedFluteHadEffectText: and a jr nz, .done ; play out-of-battle pokeflute music - ld a, $ff - call PlaySound ; turn off music + ld a, SFX_STOP_ALL_MUSIC + call PlaySound ld a, SFX_POKEFLUTE ld c, BANK(SFX_Pokeflute) call PlayMusic @@ -1901,7 +1901,7 @@ ItemUseGoodRod: xor 1 jr RodResponse -INCLUDE "data/good_rod.asm" +INCLUDE "data/wild/good_rod.asm" ItemUseSuperRod: call FishingInit @@ -2463,13 +2463,13 @@ RestoreBonusPP: AddBonusPP: push bc ld a, [de] ; normal max PP of move - ld [H_DIVIDEND + 3], a + ld [hDividend + 3], a xor a - ld [H_DIVIDEND], a - ld [H_DIVIDEND + 1], a - ld [H_DIVIDEND + 2], a + ld [hDividend], a + ld [hDividend + 1], a + ld [hDividend + 2], a ld a, 5 - ld [H_DIVISOR], a + ld [hDivisor], a ld b, 4 call Divide ld a, [hl] ; move PP @@ -2480,7 +2480,7 @@ AddBonusPP: srl a ld c, a ; c = number of PP Ups used .loop - ld a, [H_QUOTIENT + 3] + ld a, [hQuotient + 3] cp 8 ; is the amount greater than or equal to 8? jr c, .addAmount ld a, 7 ; cap the amount at 7 @@ -2686,7 +2686,7 @@ IsKeyItem_:: ld [wIsKeyItem], a ret -INCLUDE "data/key_items.asm" +INCLUDE "data/items/key_items.asm" SendNewMonToBox: ld de, wNumInBox @@ -2881,7 +2881,7 @@ IsNextTileShoreOrWater: and a ret -INCLUDE "data/water_tilesets.asm" +INCLUDE "data/tilesets/water_tilesets.asm" ReadSuperRodData: ; return e = 2 if no fish on this map @@ -2928,7 +2928,7 @@ ReadSuperRodData: ld e, $1 ; $1 if there's a bite ret -INCLUDE "data/super_rod.asm" +INCLUDE "data/wild/super_rod.asm" ; reloads map view and processes sprite data ; for items that cause the overworld to be displayed diff --git a/engine/items/tm_prices.asm b/engine/items/tm_prices.asm index c359dc1d..85531bab 100755 --- a/engine/items/tm_prices.asm +++ b/engine/items/tm_prices.asm @@ -22,4 +22,4 @@ GetMachinePrice:: ld [hItemPrice + 2], a ret -INCLUDE "data/tm_prices.asm" +INCLUDE "data/items/tm_prices.asm" diff --git a/engine/items/tms.asm b/engine/items/tms.asm index da1b5e72..ea7fbcad 100755 --- a/engine/items/tms.asm +++ b/engine/items/tms.asm @@ -33,4 +33,4 @@ TMToMove: ld [wd11e], a ret -INCLUDE "data/tms.asm" +INCLUDE "data/moves/tmhm_moves.asm" diff --git a/engine/items/town_map.asm b/engine/items/town_map.asm index 84a92994..285dbfa5 100755 --- a/engine/items/town_map.asm +++ b/engine/items/town_map.asm @@ -103,7 +103,7 @@ DisplayTownMap: ld [wWhichTownMapLocation], a jp .townMapLoop -INCLUDE "data/town_map_order.asm" +INCLUDE "data/maps/town_map_order.asm" TownMapCursor: INCBIN "gfx/town_map/town_map_cursor.1bpp" @@ -581,9 +581,9 @@ LoadTownMapEntry: ld l, a ret -INCLUDE "data/town_map_entries.asm" +INCLUDE "data/maps/town_map_entries.asm" -INCLUDE "text/map_names.asm" +INCLUDE "data/maps/names.asm" MonNestIcon: INCBIN "gfx/town_map/mon_nest_icon.1bpp" diff --git a/engine/link/cable_club.asm b/engine/link/cable_club.asm index 141ed396..58008a94 100755 --- a/engine/link/cable_club.asm +++ b/engine/link/cable_club.asm @@ -139,7 +139,7 @@ CableClub_DoBattleOrTradeAgain: call Serial_ExchangeBytes ld a, (1 << SERIAL) | (1 << TIMER) | (1 << VBLANK) ld [rIE], a - ld a, $ff + ld a, SFX_STOP_ALL_MUSIC call PlaySound ld a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK @@ -261,7 +261,7 @@ CableClub_DoBattleOrTradeAgain: ld [wUnusedCF8D + 1], a xor a ld [wTradeCenterPointerTableIndex], a - ld a, $ff + ld a, SFX_STOP_ALL_MUSIC call PlaySound ld a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK @@ -338,10 +338,10 @@ TradeCenter_SelectMon: ld a, 1 ld [wTopMenuItemX], a .enemyMonMenu_HandleInput - ld hl, hFlags_0xFFF6 + ld hl, hFlagsFFF6 set 1, [hl] call HandleMenuInput - ld hl, hFlags_0xFFF6 + ld hl, hFlagsFFF6 res 1, [hl] and a jp z, .getNewInput @@ -403,10 +403,10 @@ TradeCenter_SelectMon: lb bc, 6, 1 call ClearScreenArea .playerMonMenu_HandleInput - ld hl, hFlags_0xFFF6 + ld hl, hFlagsFFF6 set 1, [hl] call HandleMenuInput - ld hl, hFlags_0xFFF6 + ld hl, hFlagsFFF6 res 1, [hl] and a ; was anything pressed? jr nz, .playerMonMenu_SomethingPressed @@ -663,7 +663,7 @@ TradeCenter_PrintPartyListNames: push de push hl ld a, c - ld [$ff95], a + ld [hPastLeadingZeros], a call GetMonName pop hl call PlaceString @@ -903,7 +903,7 @@ CableClub_Run: ld [wTilesetGfxPtr + 1], a ld a, l ld [wTilesetGfxPtr], a - ld a, Bank(Club_GFX) + ld a, BANK(Club_GFX) ld [wTilesetBank], a ld hl, Club_Coll ld a, h diff --git a/engine/math/multiply_divide.asm b/engine/math/multiply_divide.asm index 6cdc6c87..8bbc20a1 100755 --- a/engine/math/multiply_divide.asm +++ b/engine/math/multiply_divide.asm @@ -2,142 +2,142 @@ _Multiply:: ld a, $8 ld b, a xor a - ld [H_PRODUCT], a - ld [H_MULTIPLYBUFFER], a - ld [H_MULTIPLYBUFFER+1], a - ld [H_MULTIPLYBUFFER+2], a - ld [H_MULTIPLYBUFFER+3], a + ld [hProduct], a + ld [hMultiplyBuffer], a + ld [hMultiplyBuffer+1], a + ld [hMultiplyBuffer+2], a + ld [hMultiplyBuffer+3], a .loop - ld a, [H_MULTIPLIER] + ld a, [hMultiplier] srl a - ld [H_MULTIPLIER], a ; (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) + ld [hMultiplier], a ; (aliases: hDivisor, hMultiplier, hPowerOf10) jr nc, .smallMultiplier - ld a, [H_MULTIPLYBUFFER+3] + ld a, [hMultiplyBuffer+3] ld c, a - ld a, [H_MULTIPLICAND+2] + ld a, [hMultiplicand+2] add c - ld [H_MULTIPLYBUFFER+3], a - ld a, [H_MULTIPLYBUFFER+2] + ld [hMultiplyBuffer+3], a + ld a, [hMultiplyBuffer+2] ld c, a - ld a, [H_MULTIPLICAND+1] + ld a, [hMultiplicand+1] adc c - ld [H_MULTIPLYBUFFER+2], a - ld a, [H_MULTIPLYBUFFER+1] + ld [hMultiplyBuffer+2], a + ld a, [hMultiplyBuffer+1] ld c, a - ld a, [H_MULTIPLICAND] ; (aliases: H_MULTIPLICAND) + ld a, [hMultiplicand] ; (aliases: hMultiplicand) adc c - ld [H_MULTIPLYBUFFER+1], a - ld a, [H_MULTIPLYBUFFER] + ld [hMultiplyBuffer+1], a + ld a, [hMultiplyBuffer] ld c, a - ld a, [H_PRODUCT] ; (aliases: H_PRODUCT, H_PASTLEADINGZEROES, H_QUOTIENT) + ld a, [hProduct] ; (aliases: hProduct, hPastLeadingZeros, hQuotient) adc c - ld [H_MULTIPLYBUFFER], a + ld [hMultiplyBuffer], a .smallMultiplier dec b jr z, .done - ld a, [H_MULTIPLICAND+2] + ld a, [hMultiplicand+2] sla a - ld [H_MULTIPLICAND+2], a - ld a, [H_MULTIPLICAND+1] + ld [hMultiplicand+2], a + ld a, [hMultiplicand+1] rl a - ld [H_MULTIPLICAND+1], a - ld a, [H_MULTIPLICAND] + ld [hMultiplicand+1], a + ld a, [hMultiplicand] rl a - ld [H_MULTIPLICAND], a - ld a, [H_PRODUCT] + ld [hMultiplicand], a + ld a, [hProduct] rl a - ld [H_PRODUCT], a + ld [hProduct], a jr .loop .done - ld a, [H_MULTIPLYBUFFER+3] - ld [H_PRODUCT+3], a - ld a, [H_MULTIPLYBUFFER+2] - ld [H_PRODUCT+2], a - ld a, [H_MULTIPLYBUFFER+1] - ld [H_PRODUCT+1], a - ld a, [H_MULTIPLYBUFFER] - ld [H_PRODUCT], a + ld a, [hMultiplyBuffer+3] + ld [hProduct+3], a + ld a, [hMultiplyBuffer+2] + ld [hProduct+2], a + ld a, [hMultiplyBuffer+1] + ld [hProduct+1], a + ld a, [hMultiplyBuffer] + ld [hProduct], a ret _Divide:: xor a - ld [H_DIVIDEBUFFER], a - ld [H_DIVIDEBUFFER+1], a - ld [H_DIVIDEBUFFER+2], a - ld [H_DIVIDEBUFFER+3], a - ld [H_DIVIDEBUFFER+4], a + ld [hDivideBuffer], a + ld [hDivideBuffer+1], a + ld [hDivideBuffer+2], a + ld [hDivideBuffer+3], a + ld [hDivideBuffer+4], a ld a, $9 ld e, a .asm_37db3 - ld a, [H_DIVIDEBUFFER] + ld a, [hDivideBuffer] ld c, a - ld a, [H_DIVIDEND+1] ; (aliases: H_MULTIPLICAND) + ld a, [hDividend+1] ; (aliases: hMultiplicand) sub c 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 a, [H_DIVIDEND] ; (aliases: H_PRODUCT, H_PASTLEADINGZEROES, H_QUOTIENT) + ld a, [hDividend] ; (aliases: hProduct, hPastLeadingZeros, hQuotient) sbc c 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 [H_DIVIDEND+1], a ; (aliases: H_MULTIPLICAND) - ld a, [H_DIVIDEBUFFER+4] + ld [hDividend+1], a ; (aliases: hMultiplicand) + ld a, [hDivideBuffer+4] inc a - ld [H_DIVIDEBUFFER+4], a + ld [hDivideBuffer+4], a jr .asm_37db3 .asm_37dce ld a, b cp $1 jr z, .asm_37e18 - ld a, [H_DIVIDEBUFFER+4] + ld a, [hDivideBuffer+4] sla a - ld [H_DIVIDEBUFFER+4], a - ld a, [H_DIVIDEBUFFER+3] + ld [hDivideBuffer+4], a + ld a, [hDivideBuffer+3] rl a - ld [H_DIVIDEBUFFER+3], a - ld a, [H_DIVIDEBUFFER+2] + ld [hDivideBuffer+3], a + ld a, [hDivideBuffer+2] rl a - ld [H_DIVIDEBUFFER+2], a - ld a, [H_DIVIDEBUFFER+1] + ld [hDivideBuffer+2], a + ld a, [hDivideBuffer+1] rl a - ld [H_DIVIDEBUFFER+1], a + ld [hDivideBuffer+1], a dec e jr nz, .asm_37e04 ld a, $8 ld e, a - ld a, [H_DIVIDEBUFFER] - ld [H_DIVISOR], a ; (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) + ld a, [hDivideBuffer] + ld [hDivisor], a ; (aliases: hDivisor, hMultiplier, hPowerOf10) xor a - ld [H_DIVIDEBUFFER], a - ld a, [H_DIVIDEND+1] ; (aliases: H_MULTIPLICAND) - ld [H_DIVIDEND], a ; (aliases: H_PRODUCT, H_PASTLEADINGZEROES, H_QUOTIENT) - ld a, [H_DIVIDEND+2] - ld [H_DIVIDEND+1], a ; (aliases: H_MULTIPLICAND) - ld a, [H_DIVIDEND+3] - ld [H_DIVIDEND+2], a + ld [hDivideBuffer], a + ld a, [hDividend+1] ; (aliases: hMultiplicand) + ld [hDividend], a ; (aliases: hProduct, hPastLeadingZeros, hQuotient) + ld a, [hDividend+2] + ld [hDividend+1], a ; (aliases: hMultiplicand) + ld a, [hDividend+3] + ld [hDividend+2], a .asm_37e04 ld a, e cp $1 jr nz, .asm_37e0a dec b .asm_37e0a - ld a, [H_DIVISOR] ; (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) + ld a, [hDivisor] ; (aliases: hDivisor, hMultiplier, hPowerOf10) srl a - ld [H_DIVISOR], a ; (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) - ld a, [H_DIVIDEBUFFER] + ld [hDivisor], a ; (aliases: hDivisor, hMultiplier, hPowerOf10) + ld a, [hDivideBuffer] rr a - ld [H_DIVIDEBUFFER], a + ld [hDivideBuffer], a jr .asm_37db3 .asm_37e18 - ld a, [H_DIVIDEND+1] ; (aliases: H_MULTIPLICAND) - ld [H_REMAINDER], a ; (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) - ld a, [H_DIVIDEBUFFER+4] - ld [H_QUOTIENT+3], a - ld a, [H_DIVIDEBUFFER+3] - ld [H_QUOTIENT+2], a - ld a, [H_DIVIDEBUFFER+2] - ld [H_QUOTIENT+1], a ; (aliases: H_MULTIPLICAND) - ld a, [H_DIVIDEBUFFER+1] - ld [H_DIVIDEND], a ; (aliases: H_PRODUCT, H_PASTLEADINGZEROES, H_QUOTIENT) + ld a, [hDividend+1] ; (aliases: hMultiplicand) + ld [hRemainder], a ; (aliases: hDivisor, hMultiplier, hPowerOf10) + ld a, [hDivideBuffer+4] + ld [hQuotient+3], a + ld a, [hDivideBuffer+3] + ld [hQuotient+2], a + ld a, [hDivideBuffer+2] + ld [hQuotient+1], a ; (aliases: hMultiplicand) + ld a, [hDivideBuffer+1] + ld [hDividend], a ; (aliases: hProduct, hPastLeadingZeros, hQuotient) ret diff --git a/engine/menus/display_text_id_init.asm b/engine/menus/display_text_id_init.asm index 5043ad22..45c76f9c 100644 --- a/engine/menus/display_text_id_init.asm +++ b/engine/menus/display_text_id_init.asm @@ -43,7 +43,7 @@ DisplayTextIDInit:: ; the original direction they were facing must be restored after the dialogue is over ld hl, wSpriteStateData1 + $19 ld c, $0f - ld de, $0010 + ld de, $10 .spriteFacingDirectionCopyLoop ld a, [hl] inc h @@ -55,7 +55,7 @@ DisplayTextIDInit:: ; loop to force all the sprites in the middle of animation to stand still ; (so that they don't like they're frozen mid-step during the dialogue) ld hl, wSpriteStateData1 + 2 - ld de, $0010 + ld de, $10 ld c, e .spriteStandStillLoop ld a, [hl] @@ -74,5 +74,5 @@ DisplayTextIDInit:: ld [hWY], a ; put the window on the screen call LoadFontTilePatterns 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 diff --git a/engine/menus/main_menu.asm b/engine/menus/main_menu.asm index 8eda6744..fe82ec4a 100755 --- a/engine/menus/main_menu.asm +++ b/engine/menus/main_menu.asm @@ -342,7 +342,7 @@ CableClubOptionsText: DisplayContinueGameInfo: xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a coord hl, 4, 7 ld b, 8 ld c, 14 @@ -360,13 +360,13 @@ DisplayContinueGameInfo: coord hl, 13, 15 call PrintPlayTime ld a, 1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ld c, 30 jp DelayFrames PrintSaveScreenText: xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a coord hl, 4, 0 ld b, $8 ld c, $e @@ -386,7 +386,7 @@ PrintSaveScreenText: coord hl, 13, 8 call PrintPlayTime ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ld c, 30 jp DelayFrames @@ -463,7 +463,7 @@ DisplayOptionMenu: ld a, [wOptionsTextSpeedCursorX] ; text speed cursor X coordinate ld [wTopMenuItemX], a ld a, $01 - ld [H_AUTOBGTRANSFERENABLED], a ; enable auto background transfer + ld [hAutoBGTransferEnabled], a ; enable auto background transfer call Delay3 .loop call PlaceMenuCursor diff --git a/engine/menus/naming_screen.asm b/engine/menus/naming_screen.asm index 2b86d6f4..efeab4c3 100755 --- a/engine/menus/naming_screen.asm +++ b/engine/menus/naming_screen.asm @@ -337,7 +337,7 @@ ED_TileEnd: PrintAlphabet: xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ld a, [wAlphabetCase] and a ld de, LowerCaseAlphabet @@ -362,10 +362,10 @@ PrintAlphabet: jr nz, .outerLoop call PlaceString ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a jp Delay3 -INCLUDE "text/alphabets.asm" +INCLUDE "data/text/alphabets.asm" PrintNicknameAndUnderscores: call CalcStringLength @@ -435,7 +435,7 @@ DakutensAndHandakutens: ld [wNamingScreenLetter], a ret -INCLUDE "text/dakutens.asm" +INCLUDE "data/text/dakutens.asm" ; calculates the length of the string at wcf4b and stores it in c CalcStringLength: diff --git a/engine/menus/party_menu.asm b/engine/menus/party_menu.asm index 41b6074b..9ae5706e 100755 --- a/engine/menus/party_menu.asm +++ b/engine/menus/party_menu.asm @@ -19,7 +19,7 @@ ; f8: leveled up DrawPartyMenu_:: xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a call ClearScreen call UpdateSprites callba LoadMonPartySpriteGfxWithLCDDisabled ; load pokemon icon graphics @@ -88,14 +88,14 @@ RedrawPartyMenu_:: pop hl push hl ld bc, SCREEN_WIDTH + 1 ; down 1 row and right 1 column - ld a, [hFlags_0xFFF6] + ld a, [hFlagsFFF6] set 0, a - ld [hFlags_0xFFF6], a + ld [hFlagsFFF6], a add hl, bc predef DrawHP2 ; draw HP bar and prints current / max HP - ld a, [hFlags_0xFFF6] + ld a, [hFlagsFFF6] res 0, a - ld [hFlags_0xFFF6], a + ld [hFlagsFFF6], a call SetPartyMenuHPBarColor ; color the HP bar (on SGB) pop hl jr .printLevel @@ -213,7 +213,7 @@ RedrawPartyMenu_:: pop af ld [hl], a ld a, 1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a call Delay3 jp GBPalNormal .printItemUseMessage @@ -318,7 +318,7 @@ SetPartyMenuHPBarColor: ld b, 0 add hl, bc call GetHealthBarColor - ld b, UPDATE_PARTY_MENU_BLK_PACKET + ld b, SET_PAL_PARTY_MENU_HP_BARS call RunPaletteCommand ld hl, wWhichPartyMenuHPBar inc [hl] diff --git a/engine/menus/pokedex.asm b/engine/menus/pokedex.asm index 8e1fd480..baf656b6 100755 --- a/engine/menus/pokedex.asm +++ b/engine/menus/pokedex.asm @@ -156,7 +156,7 @@ HandlePokedexSideMenu: ; sets carry flag if player presses A, unsets carry flag if player presses B HandlePokedexListMenu: xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ; draw the horizontal line separating the seen and owned amounts from the menu coord hl, 15, 8 ld a, "─" @@ -216,7 +216,7 @@ HandlePokedexListMenu: ld [wDexMaxSeenMon], a .loop xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a coord hl, 4, 2 lb bc, 14, 10 call ClearScreenArea @@ -280,7 +280,7 @@ HandlePokedexListMenu: dec d jr nz, .printPokemonLoop ld a, 01 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a call Delay3 call GBPalNormal call HandleMenuInput @@ -566,11 +566,11 @@ ShowPokedexDataInternal: pop hl inc hl ; hl = address of pokedex description text coord bc, 1, 11 - ld a, 2 - ld [$fff4], a + ld a, %10 + ld [hClearLetterPrintingDelayFlags], a call TextCommandProcessor ; print pokedex description text xor a - ld [$fff4], a + ld [hClearLetterPrintingDelayFlags], a .waitForButtonPress call JoypadLowSensitivity ld a, [hJoy5] @@ -623,7 +623,7 @@ DrawTileLine: pop bc ret -INCLUDE "data/pokedex_entries.asm" +INCLUDE "data/pokemon/dex_entries.asm" PokedexToIndex: ; converts the Pokédex number at wd11e to an index @@ -662,4 +662,4 @@ IndexToPokedex: pop bc ret -INCLUDE "data/pokedex_order.asm" +INCLUDE "data/pokemon/dex_order.asm" diff --git a/engine/menus/save.asm b/engine/menus/save.asm index 33a7ba8d..ee73c850 100755 --- a/engine/menus/save.asm +++ b/engine/menus/save.asm @@ -351,10 +351,10 @@ ChangeBox:: call z, EmptyAllSRAMBoxes ; if so, empty all boxes in SRAM call DisplayChangeBoxMenu call UpdateSprites - ld hl, hFlags_0xFFF6 + ld hl, hFlagsFFF6 set 1, [hl] call HandleMenuInput - ld hl, hFlags_0xFFF6 + ld hl, hFlagsFFF6 res 1, [hl] bit 1, a ; pressed b ret nz @@ -420,7 +420,7 @@ CopyBoxToOrFromSRAM: DisplayChangeBoxMenu: xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ld a, A_BUTTON | B_BUTTON ld [wMenuWatchedKeys], a ld a, 11 @@ -445,12 +445,12 @@ DisplayChangeBoxMenu: ld b, 12 ld c, 7 call TextBoxBorder - ld hl, hFlags_0xFFF6 + ld hl, hFlagsFFF6 set 2, [hl] ld de, BoxNames coord hl, 13, 1 call PlaceString - ld hl, hFlags_0xFFF6 + ld hl, hFlagsFFF6 res 2, [hl] ld a, [wCurrentBoxNum] and $7f @@ -486,7 +486,7 @@ DisplayChangeBoxMenu: dec a jr nz, .loop ld a, 1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ret ChooseABoxText: @@ -601,9 +601,9 @@ GetMonCountsForBoxesInBank: ret SAVCheckRandomID: -;checks if Sav file is the same by checking player's name 1st letter ($a598) +; checks if Sav file is the same by checking player's name 1st letter ; and the two random numbers generated at game beginning -;(which are stored at wPlayerID)s +; (which are stored at wPlayerID)s ld a, $0a ld [MBC1SRamEnable], a ld a, $01 @@ -702,7 +702,7 @@ ClearSAV: PadSRAM_FF: ld [MBC1SRamBank], a - ld hl, $a000 - ld bc, $2000 + ld hl, SRAM_Begin + ld bc, SRAM_End - SRAM_Begin ld a, $ff jp FillMemory diff --git a/engine/menus/start_sub_menus.asm b/engine/menus/start_sub_menus.asm index b81769a2..526540df 100755 --- a/engine/menus/start_sub_menus.asm +++ b/engine/menus/start_sub_menus.asm @@ -239,21 +239,21 @@ StartMenu_Pokemon:: ld bc, wPartyMon2 - wPartyMon1 call AddNTimes ld a, [hli] - ld [H_DIVIDEND], a + ld [hDividend], a ld a, [hl] - ld [H_DIVIDEND + 1], a + ld [hDividend + 1], a ld a, 5 - ld [H_DIVISOR], a + ld [hDivisor], a ld b, 2 ; number of bytes call Divide ld bc, wPartyMon1HP - wPartyMon1MaxHP add hl, bc ld a, [hld] ld b, a - ld a, [H_QUOTIENT + 3] + ld a, [hQuotient + 3] sub b ld b, [hl] - ld a, [H_QUOTIENT + 2] + ld a, [hQuotient + 2] sbc b jp nc, .notHealthyEnough ld a, [wPartyAndBillsPCSavedMenuItem] @@ -446,9 +446,9 @@ CannotGetOffHereText: TX_FAR _CannotGetOffHereText db "@" -INCLUDE "data/party_items.asm" +INCLUDE "data/items/use_party.asm" -INCLUDE "data/overworld_items.asm" +INCLUDE "data/items/use_overworld.asm" StartMenu_TrainerInfo:: call GBPalWhiteOut @@ -491,12 +491,12 @@ DrawTrainerInfo: call CopyData ld hl, TrainerInfoTextBoxTileGraphics ; trainer info text box tile patterns ld de, vChars2 + $770 - ld bc, $0080 + ld bc, $80 push bc call TrainerInfo_FarCopyData ld hl, BlankLeaderNames ld de, vChars2 + $600 - ld bc, $0170 + ld bc, $170 call TrainerInfo_FarCopyData pop bc ld hl, BadgeNumbersTileGraphics ; badge number tile patterns @@ -504,14 +504,14 @@ DrawTrainerInfo: call TrainerInfo_FarCopyData ld hl, GymLeaderFaceAndBadgeTileGraphics ; gym leader face and badge tile patterns ld de, vChars2 + $200 - ld bc, $0400 + ld bc, $400 ld a, $03 call FarCopyData2 ld hl, TextBoxGraphics - ld de, $00d0 + ld de, $d0 add hl, de ; hl = colon tile pattern ld de, vChars1 + $560 - ld bc, $0010 + ld bc, $10 ld a, $04 push bc call FarCopyData2 @@ -648,7 +648,7 @@ StartMenu_SaveReset:: StartMenu_Option:: xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a call ClearScreen call UpdateSprites callab DisplayOptionMenu diff --git a/engine/menus/swap_items.asm b/engine/menus/swap_items.asm index 826fe60b..8b793ea1 100644 --- a/engine/menus/swap_items.asm +++ b/engine/menus/swap_items.asm @@ -77,18 +77,18 @@ HandleItemListSwapping:: cp b jr z, .swapSameItemType .swapDifferentItems - ld [$ff95], a ; [$ff95] = second item ID + ld [hSwapItemID], a ; save second item ID ld a, [hld] - ld [$ff96], a ; [$ff96] = second item quantity + ld [hSwapItemQuantity], a ; save second item quantity ld a, [de] ld [hli], a ; put first item ID in second item slot inc de ld a, [de] ld [hl], a ; put first item quantity in second item slot - ld a, [$ff96] + ld a, [hSwapItemQuantity] ld [de], a ; put second item quantity in first item slot dec de - ld a, [$ff95] + ld a, [hSwapItemID] ld [de], a ; put second item ID in first item slot xor a ld [wMenuItemToSwap], a ; 0 means no item is currently being swapped diff --git a/engine/movie/credits.asm b/engine/movie/credits.asm index f820aae3..4ba50615 100755 --- a/engine/movie/credits.asm +++ b/engine/movie/credits.asm @@ -21,7 +21,7 @@ HallOfFamePC: ld a, %11000000 ld [rBGP], a call EnableLCD - ld a, $ff + ld a, SFX_STOP_ALL_MUSIC call PlaySoundWaitForCurrent ld c, BANK(Music_Credits) ld a, MUSIC_CREDITS @@ -47,7 +47,7 @@ FadeInCreditsText: DisplayCreditsMon: xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a call SaveScreenTilesToBuffer1 call FillMiddleOfScreenWithWhite @@ -67,7 +67,7 @@ DisplayCreditsMon: ld hl, vBGMap0 + $c call CreditsCopyTileMapToVRAM xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a call LoadScreenTilesFromBuffer1 ld hl, vBGMap0 call CreditsCopyTileMapToVRAM @@ -104,7 +104,7 @@ DisplayCreditsMon: ld [rBGP], a ret -INCLUDE "data/credit_mons.asm" +INCLUDE "data/credits/credits_mons.asm" ScrollCreditsMonLeft: ld h, b @@ -138,11 +138,11 @@ HoFGBPalettes: CreditsCopyTileMapToVRAM: ld a, l - ld [H_AUTOBGTRANSFERDEST], a + ld [hAutoBGTransferDest], a ld a, h - ld [H_AUTOBGTRANSFERDEST + 1], a + ld [hAutoBGTransferDest + 1], a ld a, 1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a jp Delay3 ZeroMemory: @@ -261,9 +261,9 @@ TheEndTextString: db $60," ",$62," ",$64," ",$64," ",$66," ",$68,"@" db $61," ",$63," ",$65," ",$65," ",$67," ",$69,"@" -INCLUDE "data/credits_order.asm" +INCLUDE "data/credits/credits_order.asm" -INCLUDE "text/credits_text.asm" +INCLUDE "data/credits/credits_text.asm" TheEndGfx: INCBIN "gfx/intro_credits/the_end.2bpp" diff --git a/engine/movie/evolution.asm b/engine/movie/evolution.asm index 731735c5..1e3aaad4 100755 --- a/engine/movie/evolution.asm +++ b/engine/movie/evolution.asm @@ -9,16 +9,16 @@ EvolveMon: xor a ld [wLowHealthAlarm], a ld [wChannelSoundIDs + Ch5], a - dec a + dec a ; SFX_STOP_ALL_MUSIC ld [wNewSoundID], a call PlaySound ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ld a, SFX_TINK call PlaySound call Delay3 xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ld [hTilesetType], a ld a, [wEvoOldSpecies] ld [wWholeScreenPaletteMonSpecies], a @@ -37,7 +37,7 @@ EvolveMon: ld [wd0b5], a call Evolution_LoadPic ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ld a, [wEvoOldSpecies] call PlayCry call WaitForSoundToFinish @@ -67,7 +67,7 @@ EvolveMon: ld a, [wEvoNewSpecies] .done ld [wWholeScreenPaletteMonSpecies], a - ld a, $ff + ld a, SFX_STOP_ALL_MUSIC ld [wNewSoundID], a call PlaySound ld a, [wWholeScreenPaletteMonSpecies] @@ -117,7 +117,7 @@ Evolution_BackAndForthAnim: Evolution_ChangeMonPic: push bc xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a coord hl, 7, 2 lb bc, 7, 7 ld de, SCREEN_WIDTH - 7 @@ -134,7 +134,7 @@ Evolution_ChangeMonPic: dec b jr nz, .loop ld a, 1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a call Delay3 pop bc ret diff --git a/engine/movie/hall_of_fame.asm b/engine/movie/hall_of_fame.asm index 3c9b1723..d874b2fd 100755 --- a/engine/movie/hall_of_fame.asm +++ b/engine/movie/hall_of_fame.asm @@ -24,7 +24,7 @@ AnimateHallOfFame: ld [wLetterPrintingDelayFlags], a ; no delay ld [wHoFMonOrPlayer], a ; mon inc a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ld hl, wNumHoFTeams ld a, [hl] inc a diff --git a/engine/movie/intro.asm b/engine/movie/intro.asm index 9a13c96f..a8151ab4 100755 --- a/engine/movie/intro.asm +++ b/engine/movie/intro.asm @@ -14,13 +14,13 @@ PlayIntro: xor a ld [hJoyHeld], a inc a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a call PlayShootingStar call PlayIntroScene call GBFadeOutToWhite xor a ld [hSCX], a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a call ClearSprites call DelayFrame ret diff --git a/engine/movie/oak_speech/oak_speech.asm b/engine/movie/oak_speech/oak_speech.asm index b1acfb65..578cf3b2 100755 --- a/engine/movie/oak_speech/oak_speech.asm +++ b/engine/movie/oak_speech/oak_speech.asm @@ -32,8 +32,8 @@ SetDefaultNames: jp CopyData OakSpeech: - ld a, $FF - call PlaySound ; stop music + ld a, SFX_STOP_ALL_MUSIC + call PlaySound ld a, BANK(Music_Routes2) ld c, a ld a, MUSIC_ROUTES2 @@ -57,7 +57,7 @@ OakSpeech: bit 1, a ; possibly a debug mode bit jp nz, .skipChoosingNames ld de, ProfOakPic - lb bc, Bank(ProfOakPic), $00 + lb bc, BANK(ProfOakPic), $00 call IntroDisplayPicCenteredOrUpperRight call FadeInIntroPic ld hl, OakSpeechText1 @@ -76,7 +76,7 @@ OakSpeech: call GBFadeOutToWhite call ClearScreen ld de, RedPicFront - lb bc, Bank(RedPicFront), $00 + lb bc, BANK(RedPicFront), $00 call IntroDisplayPicCenteredOrUpperRight call MovePicLeft ld hl, IntroducePlayerText @@ -85,7 +85,7 @@ OakSpeech: call GBFadeOutToWhite call ClearScreen ld de, Rival1Pic - lb bc, Bank(Rival1Pic), $00 + lb bc, BANK(Rival1Pic), $00 call IntroDisplayPicCenteredOrUpperRight call FadeInIntroPic ld hl, IntroduceRivalText @@ -95,7 +95,7 @@ OakSpeech: call GBFadeOutToWhite call ClearScreen ld de, RedPicFront - lb bc, Bank(RedPicFront), $00 + lb bc, BANK(RedPicFront), $00 call IntroDisplayPicCenteredOrUpperRight call GBFadeInFromWhite ld a, [wd72d] @@ -104,12 +104,12 @@ OakSpeech: ld hl, OakSpeechText3 call PrintText .next - ld a, [H_LOADEDROMBANK] + ld a, [hLoadedROMBank] push af ld a, SFX_SHRINK call PlaySound pop af - ld [H_LOADEDROMBANK], a + ld [hLoadedROMBank], a ld [MBC1RomBank], a ld c, 4 call DelayFrames @@ -126,18 +126,18 @@ OakSpeech: lb bc, BANK(ShrinkPic2), $00 call IntroDisplayPicCenteredOrUpperRight call ResetPlayerSpriteData - ld a, [H_LOADEDROMBANK] + ld a, [hLoadedROMBank] push af ld a, BANK(Music_PalletTown) ld [wAudioROMBank], a ld [wAudioSavedROMBank], a ld a, 10 ld [wAudioFadeOutControl], a - ld a, $FF + ld a, SFX_STOP_ALL_MUSIC ld [wNewSoundID], a - call PlaySound ; stop music + call PlaySound pop af - ld [H_LOADEDROMBANK], a + ld [hLoadedROMBank], a ld [MBC1RomBank], a ld c, 20 call DelayFrames diff --git a/engine/movie/oak_speech/oak_speech2.asm b/engine/movie/oak_speech/oak_speech2.asm index fdc9ffa3..8c4a896b 100755 --- a/engine/movie/oak_speech/oak_speech2.asm +++ b/engine/movie/oak_speech/oak_speech2.asm @@ -107,7 +107,7 @@ OakSpeechSlidePicCommon: ld e, l .loop xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ld a, [hSlideDirection] and a jr nz, .slideLeft @@ -134,7 +134,7 @@ OakSpeechSlidePicCommon: ld [hl], a .next3 ld a, 1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a call Delay3 ld a, [hSlidingRegionSize] ld c, a @@ -187,7 +187,7 @@ DisplayIntroNameTextBox: .namestring db "NAME@" -INCLUDE "text/player_names.asm" +INCLUDE "data/player_names.asm" GetDefaultName: ; a = name index @@ -213,7 +213,7 @@ GetDefaultName: ld bc, $14 jp CopyData -INCLUDE "text/player_names_list.asm" +INCLUDE "data/player_names_list.asm" TextTerminator_6b20: db "@" diff --git a/engine/movie/titlescreen.asm b/engine/movie/title.asm index c30f83a9..9cbe5494 100755 --- a/engine/movie/titlescreen.asm +++ b/engine/movie/title.asm @@ -24,7 +24,7 @@ SetDefaultNamesBeforeTitlescreen:: DisplayTitleScreen: call GBPalWhiteOut ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a xor a ld [hTilesetType], a ld [hSCX], a @@ -239,7 +239,7 @@ ENDC xor a ld [hWY], a inc a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a call ClearScreen ld a, vBGMap0 / $100 call TitleScreenCopyTileMapToVRAM @@ -317,7 +317,7 @@ DrawPlayerCharacter: xor a ld [wPlayerCharacterOAMTile], a ld hl, wOAMBuffer - ld de, $605a + lb de, $60, $5a ld b, 7 .loop push de @@ -358,7 +358,7 @@ LoadTitleMonSprite: jp LoadFrontSpriteByMonIndex TitleScreenCopyTileMapToVRAM: - ld [H_AUTOBGTRANSFERDEST + 1], a + ld [hAutoBGTransferDest + 1], a jp Delay3 LoadCopyrightAndTextBoxTiles: @@ -382,7 +382,7 @@ CopyrightTextString: next $60,$61,$62,$61,$63,$61,$64,$7F,$73,$74,$75,$76,$77,$78,$79,$7A,$7B ; ©'95.'96.'98 GAME FREAK inc. db "@" -INCLUDE "data/title_mons.asm" +INCLUDE "data/pokemon/title_mons.asm" ; prints version text (red, blue) PrintGameVersionOnTitleScreen: diff --git a/engine/movie/titlescreen2.asm b/engine/movie/title2.asm index 2346fcc5..2346fcc5 100755 --- a/engine/movie/titlescreen2.asm +++ b/engine/movie/title2.asm diff --git a/engine/movie/trade.asm b/engine/movie/trade.asm index 8bc8e3bc..6af6f2e3 100755 --- a/engine/movie/trade.asm +++ b/engine/movie/trade.asm @@ -137,10 +137,10 @@ Trade_Delay100: Trade_CopyTileMapToVRAM: ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a call Delay3 xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ret Trade_Delay80: @@ -184,7 +184,7 @@ LoadTradingGFXAndMonNames: ld [rOBP0], a call EnableLCD xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ld a, [wTradedPlayerMonSpecies] ld [wd11e], a call GetMonName @@ -231,7 +231,7 @@ Trade_ShowPlayerMon: ld [rWX], a ld [hSCX], a xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a coord hl, 4, 0 ld b, 6 ld c, 10 @@ -261,7 +261,7 @@ Trade_ShowPlayerMon: ld a, [wTradedPlayerMonSpecies] call PlayCry xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ret Trade_DrawOpenEndOfLinkCable: @@ -336,13 +336,13 @@ Trade_AnimateBallEnteringLinkCable: .ballSpriteReachedEdgeOfScreen call ClearSprites ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a call ClearScreen ld b, $98 call CopyScreenTileBufferToVRAM call Delay3 xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ret Trade_BallInsideLinkCableOAM: @@ -360,13 +360,13 @@ Trade_ShowEnemyMon: call Trade_PrintEnemyMonInfoText call Trade_CopyTileMapToVRAM ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ld a, [wTradedEnemyMonSpecies] call Trade_LoadMonSprite ld a, TRADE_BALL_POOF_ANIM call Trade_ShowAnimation ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ld a, [wTradedEnemyMonSpecies] call PlayCry call Trade_Delay100 @@ -397,7 +397,7 @@ Trade_AnimLeftToRight: ld b, $6 call Trade_AnimMonMoveHorizontal ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a call Trade_DrawCableAcrossScreen ld b, $4 call Trade_AnimMonMoveHorizontal @@ -405,7 +405,7 @@ Trade_AnimLeftToRight: ld b, $6 call Trade_AnimMonMoveHorizontal xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a call Trade_AnimMonMoveVertical jp ClearSprites @@ -430,7 +430,7 @@ Trade_AnimRightToLeft: ld b, $6 call Trade_AnimMonMoveHorizontal ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a call Trade_DrawCableAcrossScreen ld b, $4 call Trade_AnimMonMoveHorizontal @@ -438,16 +438,16 @@ Trade_AnimRightToLeft: ld b, $6 call Trade_AnimMonMoveHorizontal xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a jp ClearSprites Trade_InitGameboyTransferGfx: ; Initialises the graphics for showing a mon moving between gameboys. ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a call ClearScreen xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a call Trade_LoadMonPartySpriteGfx call DelayFrame ld a, %10101011 @@ -731,9 +731,9 @@ Trade_LoadMonSprite: ld b, SET_PAL_POKEMON_WHOLE_SCREEN ld c, 0 call RunPaletteCommand - ld a, [H_AUTOBGTRANSFERENABLED] + ld a, [hAutoBGTransferEnabled] xor $1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a call GetMonHeader coord hl, 7, 2 call LoadFlippedFrontSpriteByMonIndex @@ -743,7 +743,7 @@ Trade_LoadMonSprite: Trade_ShowClearedWindow: ; clears the window and covers the BG entirely with the window ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a call ClearScreen ld a, %11100011 ld [rLCDC], a diff --git a/engine/overworld/auto_movement.asm b/engine/overworld/auto_movement.asm index e478c9ad..421e3180 100755 --- a/engine/overworld/auto_movement.asm +++ b/engine/overworld/auto_movement.asm @@ -66,7 +66,7 @@ PalletMovementScript_OakMoveLeft: call FillMemory ld [hl], $ff ld a, [wSpriteIndex] - ld [H_SPRITEINDEX], a + ld [hSpriteIndex], a ld de, wNPCMovementDirections2 call MoveSprite ld a, $1 @@ -282,7 +282,7 @@ FreezeEnemyTrainerSprite:: jr .loop .notRival ld a, [wSpriteIndex] - ld [H_SPRITEINDEX], a + ld [hSpriteIndex], a jp SetSpriteMovementBytesToFF RivalIDs: diff --git a/engine/overworld/clear_variables.asm b/engine/overworld/clear_variables.asm index 32dc85cd..b5a1f4a0 100644 --- a/engine/overworld/clear_variables.asm +++ b/engine/overworld/clear_variables.asm @@ -3,7 +3,7 @@ ClearVariablesOnEnterMap:: ld [hWY], a ld [rWY], a xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ld [wStepCounter], a ld [wLoneAttackNo], a ld [hJoyPressed], a diff --git a/engine/overworld/cut.asm b/engine/overworld/cut.asm index f61ca65f..c75fbbb6 100755 --- a/engine/overworld/cut.asm +++ b/engine/overworld/cut.asm @@ -248,4 +248,4 @@ ReplaceTreeTileBlock: ld [hl], a ret -INCLUDE "data/cut_tree_blocks.asm" +INCLUDE "data/tilesets/cut_tree_blocks.asm" diff --git a/engine/overworld/doors.asm b/engine/overworld/doors.asm index 1339430a..ed893773 100755 --- a/engine/overworld/doors.asm +++ b/engine/overworld/doors.asm @@ -25,4 +25,4 @@ IsPlayerStandingOnDoorTile: and a ret -INCLUDE "data/door_tile_ids.asm" +INCLUDE "data/tilesets/door_tile_ids.asm" diff --git a/engine/overworld/elevator.asm b/engine/overworld/elevator.asm index d36e2f2c..05ca08c9 100755 --- a/engine/overworld/elevator.asm +++ b/engine/overworld/elevator.asm @@ -4,7 +4,7 @@ ShakeElevator:: ld de, SCREEN_HEIGHT * $20 call ShakeElevatorRedrawRow call Delay3 - ld a, $ff + ld a, SFX_STOP_ALL_MUSIC call PlaySound ld a, [hSCY] ld d, a @@ -27,7 +27,7 @@ ShakeElevator:: jr nz, .shakeLoop ld a, d ld [hSCY], a - ld a, $ff + ld a, SFX_STOP_ALL_MUSIC call PlaySound ld c, BANK(SFX_Safari_Zone_PA) ld a, SFX_SAFARI_ZONE_PA diff --git a/engine/overworld/healing_machine.asm b/engine/overworld/healing_machine.asm index 510f963b..836af44d 100755 --- a/engine/overworld/healing_machine.asm +++ b/engine/overworld/healing_machine.asm @@ -17,7 +17,7 @@ AnimateHealingMachine: call CopyHealingMachineOAM ld a, 4 ld [wAudioFadeOutControl], a - ld a, $ff + ld a, SFX_STOP_ALL_MUSIC ld [wNewSoundID], a call PlaySound .waitLoop @@ -38,7 +38,7 @@ AnimateHealingMachine: cp BANK(Audio3_UpdateMusic) ld [wAudioSavedROMBank], a jr nz, .next - ld a, $ff + ld a, SFX_STOP_ALL_MUSIC ld [wNewSoundID], a call PlaySound ld a, BANK(Music_PkmnHealed) diff --git a/engine/overworld/hidden_objects.asm b/engine/overworld/hidden_objects.asm index c93f2e1b..a19694e0 100755 --- a/engine/overworld/hidden_objects.asm +++ b/engine/overworld/hidden_objects.asm @@ -14,14 +14,14 @@ IsPlayerOnDungeonWarp:: set 4, [hl] ret -; if a hidden object was found, stores $00 in [$ffee], else stores $ff +; if a hidden object was found, stores $00 in [hFoundHiddenObject], else stores $ff CheckForHiddenObject:: - ld hl, $ffeb + ld hl, hFoundHiddenObjectOrBookshelf xor a - ld [hli], a - ld [hli], a - ld [hli], a - ld [hl], a + ld [hli], a ; [hFoundHiddenObjectOrBookshelf] + ld [hli], a ; [hSavedMapTextPtr] + ld [hli], a ; [hSavedMapTextPtr + 1] + ld [hl], a ; [hFoundHiddenObject] ld de, $0 ld hl, HiddenObjectMaps .hiddenMapLoop @@ -81,7 +81,7 @@ CheckForHiddenObject:: ret .noMatch ld a, $ff - ld [$ffee], a + ld [hFoundHiddenObject], a ret ; checks if the coordinates in front of the player's sprite match Y in b and X in c @@ -130,4 +130,4 @@ CheckIfCoordsInFrontOfPlayerMatch: ld [hCoordsInFrontOfPlayerMatch], a ret -INCLUDE "data/hidden_objects.asm" +INCLUDE "data/events/hidden_objects.asm" diff --git a/engine/overworld/ledges.asm b/engine/overworld/ledges.asm index 290c8c80..c56914f6 100755 --- a/engine/overworld/ledges.asm +++ b/engine/overworld/ledges.asm @@ -54,7 +54,7 @@ HandleLedges:: call PlaySound ret -INCLUDE "data/ledge_tiles.asm" +INCLUDE "data/tilesets/ledge_tiles.asm" LoadHoppingShadowOAM: ld hl, vChars1 + $7f0 diff --git a/engine/overworld/map_sprites.asm b/engine/overworld/map_sprites.asm index 19e25435..904e9b04 100755 --- a/engine/overworld/map_sprites.asm +++ b/engine/overworld/map_sprites.asm @@ -133,8 +133,7 @@ LoadMapSpriteTilePatterns: jr nc, .fourTileSpriteVRAMAddr ld d, a dec d -; Equivalent to multiplying $C0 (number of bytes in 12 tiles) times the VRAM -; slot and adding the result to $8000 (the VRAM base address). +; vSprites += [hVRAMSlot] * $C0 (the number of bytes in 12 tiles) .calculateVRAMAddrLoop add hl, bc dec d @@ -437,4 +436,6 @@ GetSplitMapSpriteSetID: ld a, $01 ret -INCLUDE "data/sprite_sets.asm" +INCLUDE "data/maps/sprite_sets.asm" + +INCLUDE "data/sprites/sprites.asm" diff --git a/engine/overworld/missable_objects.asm b/engine/overworld/missable_objects.asm index 7d6de545..a89fcb54 100644 --- a/engine/overworld/missable_objects.asm +++ b/engine/overworld/missable_objects.asm @@ -31,19 +31,19 @@ LoadMissableObjects: sub d ld h, a ld a, h - ld [H_DIVIDEND], a + ld [hDividend], a ld a, l - ld [H_DIVIDEND+1], a + ld [hDividend+1], a xor a - ld [H_DIVIDEND+2], a - ld [H_DIVIDEND+3], a + ld [hDividend+2], a + ld [hDividend+3], a ld a, $3 - ld [H_DIVISOR], a + ld [hDivisor], a ld b, $2 call Divide ; divide difference by 3, resulting in the global offset (number of missable items before ours) ld a, [wCurMap] ld b, a - ld a, [H_DIVIDEND+3] + ld a, [hDividend+3] ld c, a ; store global offset in c ld de, wMissableObjectList pop hl @@ -99,7 +99,7 @@ InitializeMissableObjectsFlags: ; tests if current sprite is a missable object that is hidden/has been removed IsObjectHidden: - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] swap a ld b, a ld hl, wMissableObjectList @@ -120,7 +120,7 @@ IsObjectHidden: .notHidden xor a .hidden - ld [$ffe5], a + ld [hIsHiddenMissableObject], a ret ; adds missable object (items, leg. pokemon, etc.) to the map diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm index f272f497..6c354779 100644 --- a/engine/overworld/movement.asm +++ b/engine/overworld/movement.asm @@ -63,7 +63,7 @@ UpdatePlayerSprite: ld a, [wd736] bit 7, a ; is the player sprite spinning due to a spin tile? jr nz, .skipSpriteAnim - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $7 ld l, a ld a, [hl] @@ -103,7 +103,7 @@ UpdatePlayerSprite: UnusedReadSpriteDataFunction: push bc push af - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] ld c, a pop af add c @@ -112,7 +112,7 @@ UnusedReadSpriteDataFunction: ret UpdateNPCSprite: - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] swap a dec a add a @@ -122,7 +122,7 @@ UpdateNPCSprite: ld a, [hl] ; read movement byte 2 ld [wCurSpriteMovement2], a ld h, $c1 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] ld l, a inc l ld a, [hl] ; c1x1 @@ -131,7 +131,7 @@ UpdateNPCSprite: call CheckSpriteAvailability ret c ; if sprite is invisible, on tile >=MAP_TILESET_SIZE, in grass or player is currently walking ld h, $c1 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] ld l, a inc l 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) call InitializeSpriteScreenPosition ld h, $c2 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $6 ld l, a ld a, [hl] ; c2x6: movement byte 1 @@ -264,11 +264,11 @@ ChangeFacingDirection: TryWalking: push hl ld h, $c1 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $9 ld l, a ld [hl], c ; c1x9 (update facing direction) - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $3 ld l, a ld [hl], d ; c1x3 (update Y movement delta) @@ -282,7 +282,7 @@ TryWalking: pop de ret c ; cannot walk there (reinitialization of delay values already done) ld h, $c2 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $4 ld l, a ld a, [hl] ; c2x4: Y position @@ -291,7 +291,7 @@ TryWalking: ld a, [hl] ; c2x5: X position add e ld [hl], a ; update X position - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] ld l, a ld [hl], $10 ; c2x0=16: walk animation counter dec h @@ -301,7 +301,7 @@ TryWalking: ; update the walking animation parameters for a sprite that is currently walking UpdateSpriteInWalkingAnimation: - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $7 ld l, a ld a, [hl] ; c1x7 (counter until next walk animation frame) @@ -317,7 +317,7 @@ UpdateSpriteInWalkingAnimation: and $3 ld [hl], a ; advance to next animation frame every 4 ticks (16 ticks total for one step) .noNextAnimationFrame - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $3 ld l, a ld a, [hli] ; c1x3 (movement Y delta) @@ -330,7 +330,7 @@ UpdateSpriteInWalkingAnimation: ld a, [hl] ; c1x6 (screen X position) add b ld [hl], a ; update screen X position - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] ld l, a inc h ld a, [hl] ; c2x0 (walk animation counter) @@ -343,7 +343,7 @@ UpdateSpriteInWalkingAnimation: ld a, [hl] ; c2x6 (movement byte 1) cp $fe jr nc, .initNextMovementCounter ; values $fe and $ff - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] inc a ld l, a dec h @@ -351,14 +351,14 @@ UpdateSpriteInWalkingAnimation: ret .initNextMovementCounter call Random - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $8 ld l, a ld a, [hRandomAdd] and $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?) - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] inc a ld l, a ld [hl], $2 ; c1x1 = 2 (movement status) @@ -375,7 +375,7 @@ UpdateSpriteInWalkingAnimation: ; update delay value (c2x8) for sprites in the delayed state (c1x1) UpdateSpriteMovementDelay: ld h, $c2 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $6 ld l, a ld a, [hl] ; c2x6: movement byte 1 @@ -390,13 +390,13 @@ UpdateSpriteMovementDelay: jr nz, notYetMoving .moving dec h - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] inc a ld l, a ld [hl], $1 ; c1x1 = 1 (mark as ready to move) notYetMoving: ld h, wSpriteStateData1 / $100 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $8 ld l, a ld [hl], $0 ; c1x8 = 0 (walk animation frame) @@ -429,7 +429,7 @@ MakeNPCFacePlayer: .notFacingRight ld c, SPRITE_FACING_LEFT .facingDirectionDetermined - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $9 ld l, a ld [hl], c ; c1x9: set facing direction @@ -440,7 +440,7 @@ InitializeSpriteStatus: inc l ld [hl], $ff ; $c1x2: set sprite image to $ff (invisible/off screen) inc h - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $2 ld l, a ld a, $8 @@ -451,7 +451,7 @@ InitializeSpriteStatus: ; calculates the sprite's screen position form its map position and the player position InitializeSpriteScreenPosition: ld h, wSpriteStateData2 / $100 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $4 ld l, a ld a, [wYCoord] @@ -475,17 +475,17 @@ InitializeSpriteScreenPosition: ; tests if sprite is off screen or otherwise unable to do anything CheckSpriteAvailability: predef IsObjectHidden - ld a, [$ffe5] + ld a, [hIsHiddenMissableObject] and a jp nz, .spriteInvisible ld h, wSpriteStateData2 / $100 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $6 ld l, a ld a, [hl] ; c2x6: movement byte 1 cp $fe jr c, .skipXVisibilityTest ; movement byte 1 < $fe (i.e. the sprite's movement is scripted) - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $4 ld l, a 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) .spriteInvisible ld h, wSpriteStateData1 / $100 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $2 ld l, a ld [hl], $ff ; c1x2 @@ -540,7 +540,7 @@ CheckSpriteAvailability: jr nz, .done ; if player is currently walking, we're done call UpdateSpriteImage inc h - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $7 ld l, a ld a, [wGrassTile] @@ -556,7 +556,7 @@ CheckSpriteAvailability: UpdateSpriteImage: ld h, $c1 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $8 ld l, a ld a, [hli] ; c1x8: walk animation frame @@ -564,10 +564,10 @@ UpdateSpriteImage: ld a, [hl] ; c1x9: facing direction add b ld b, a - ld a, [$ff93] ; current sprite offset + ld a, [hTilePlayerStandingOn] add b ld b, a - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $2 ld l, a ld [hl], b ; c1x2: sprite to display @@ -581,7 +581,7 @@ UpdateSpriteImage: ; set carry on failure, clears carry on success CanWalkOntoTile: ld h, wSpriteStateData2 / $100 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $6 ld l, a ld a, [hl] ; c2x6 (movement byte 1) @@ -602,14 +602,14 @@ CanWalkOntoTile: cp c jr nz, .tilePassableLoop ld h, $c2 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $6 ld l, a ld a, [hl] ; $c2x6 (movement byte 1) inc a jr z, .impassable ; if $ff, no movement allowed (however, changing direction is) ld h, wSpriteStateData1 / $100 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $4 ld l, a ld a, [hli] ; c1x4 (screen Y pos) @@ -628,14 +628,14 @@ CanWalkOntoTile: pop bc pop de ld h, wSpriteStateData1 / $100 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $c ld l, a ld a, [hl] ; c1xc (directions in which sprite collision would occur) and b ; check against chosen direction (1,2,4 or 8) jr nz, .impassable ; collision between sprites, don't go there ld h, wSpriteStateData2 / $100 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $2 ld l, a ld a, [hli] ; c2x2 (sprite Y displacement, initialized at $8, keep track of where a sprite did go) @@ -666,7 +666,7 @@ CanWalkOntoTile: ret .impassable ld h, $c1 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] inc a ld l, a ld [hl], $2 ; c1x1 = 2 (set movement status to delayed) @@ -677,7 +677,7 @@ CanWalkOntoTile: inc l ld [hl], a ; c1x5 = 0 (clear X movement delta) inc h - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $8 ld l, a call Random @@ -692,7 +692,7 @@ CanWalkOntoTile: ; hl: output pointer GetTileSpriteStandsOn: ld h, wSpriteStateData1 / $100 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $4 ld l, a ld a, [hli] ; c1x4: screen Y position @@ -784,7 +784,7 @@ DoScriptedNPCMovement: ld a, [hl] add b ld [hl], a - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $9 ld l, a ld a, c @@ -817,7 +817,7 @@ GetSpriteScreenXPointer: GetSpriteScreenXYPointerCommon: ld hl, wSpriteStateData1 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add l add b ld l, a @@ -825,7 +825,7 @@ GetSpriteScreenXYPointerCommon: AnimScriptedNPCMovement: ld hl, wSpriteStateData2 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $e ld l, a ld a, [hl] ; VRAM slot @@ -833,7 +833,7 @@ AnimScriptedNPCMovement: swap a ld b, a ld hl, wSpriteStateData1 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $9 ld l, a ld a, [hl] ; facing direction @@ -852,7 +852,7 @@ AnimScriptedNPCMovement: ld [hSpriteVRAMSlotAndFacing], a call AdvanceScriptedNPCAnimFrameCounter ld hl, wSpriteStateData1 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $2 ld l, a ld a, [hSpriteVRAMSlotAndFacing] @@ -863,7 +863,7 @@ AnimScriptedNPCMovement: ret AdvanceScriptedNPCAnimFrameCounter: - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $7 ld l, a ld a, [hl] ; intra-animation frame counter diff --git a/engine/overworld/player_animations.asm b/engine/overworld/player_animations.asm index 0ac4f3b2..a3f6e051 100755 --- a/engine/overworld/player_animations.asm +++ b/engine/overworld/player_animations.asm @@ -373,7 +373,7 @@ IsPlayerStandingOnWarpPadOrHole:: ld [wStandingOnWarpPadOrHole], a ret -INCLUDE "data/warp_pad_hole_tile_ids.asm" +INCLUDE "data/tilesets/warp_pad_hole_tile_ids.asm" FishingAnim: ld c, 10 diff --git a/engine/overworld/player_state.asm b/engine/overworld/player_state.asm index 23da664c..ea24fdc1 100644 --- a/engine/overworld/player_state.asm +++ b/engine/overworld/player_state.asm @@ -82,7 +82,7 @@ CheckForceBikeOrSurf:: ld [wWalkBikeSurfStateCopy], a jp ForceBikeOrSurf -INCLUDE "data/force_bike_surf.asm" +INCLUDE "data/maps/force_bike_surf.asm" IsPlayerFacingEdgeOfMap:: push hl @@ -176,7 +176,7 @@ IsWarpTileInFrontOfPlayer:: pop hl ret -INCLUDE "data/warp_carpet_tile_ids.asm" +INCLUDE "data/tilesets/warp_carpet_tile_ids.asm" IsSSAnneBowWarpTileInFrontOfPlayer: ld a, [wTileInFrontOfPlayer] @@ -215,7 +215,7 @@ IsPlayerStandingOnDoorTileOrWarpTile:: pop hl ret -INCLUDE "data/warp_tile_ids.asm" +INCLUDE "data/tilesets/warp_tile_ids.asm" PrintSafariZoneSteps:: ld a, [wCurMap] @@ -297,7 +297,7 @@ _GetTileAndCoordsInFrontOfPlayer: GetTileTwoStepsInFrontOfPlayer: xor a - ld [$ffdb], a + ld [hPlayerFacing], a ld hl, wYCoord ld a, [hli] ld d, a @@ -306,7 +306,7 @@ GetTileTwoStepsInFrontOfPlayer: and a ; cp SPRITE_FACING_DOWN jr nz, .notFacingDown ; facing down - ld hl, $ffdb + ld hl, hPlayerFacing set 0, [hl] aCoord 8, 13 inc d @@ -315,7 +315,7 @@ GetTileTwoStepsInFrontOfPlayer: cp SPRITE_FACING_UP jr nz, .notFacingUp ; facing up - ld hl, $ffdb + ld hl, hPlayerFacing set 1, [hl] aCoord 8, 5 dec d @@ -324,7 +324,7 @@ GetTileTwoStepsInFrontOfPlayer: cp SPRITE_FACING_LEFT jr nz, .notFacingLeft ; facing left - ld hl, $ffdb + ld hl, hPlayerFacing set 2, [hl] aCoord 4, 9 dec e @@ -333,7 +333,7 @@ GetTileTwoStepsInFrontOfPlayer: cp SPRITE_FACING_RIGHT jr nz, .storeTile ; facing right - ld hl, $ffdb + ld hl, hPlayerFacing set 3, [hl] aCoord 12, 9 inc e @@ -378,33 +378,33 @@ CheckForBoulderCollisionWithSprites: ld hl, wSpriteStateData2 + $14 add hl, de ld a, [hli] ; map Y position - ld [$ffdc], a + ld [hPlayerYCoord], a ld a, [hl] ; map X position - ld [$ffdd], a + ld [hPlayerXCoord], a ld a, [wNumSprites] ld c, a ld de, $f ld hl, wSpriteStateData2 + $14 - ld a, [$ffdb] + ld a, [hPlayerFacing] and $3 ; facing up or down? jr z, .pushingHorizontallyLoop .pushingVerticallyLoop inc hl - ld a, [$ffdd] + ld a, [hPlayerXCoord] cp [hl] jr nz, .nextSprite1 ; if X coordinates don't match dec hl ld a, [hli] ld b, a - ld a, [$ffdb] + ld a, [hPlayerFacing] rrca jr c, .pushingDown ; pushing up - ld a, [$ffdc] + ld a, [hPlayerYCoord] dec a jr .compareYCoords .pushingDown - ld a, [$ffdc] + ld a, [hPlayerYCoord] inc a .compareYCoords cp b @@ -417,19 +417,19 @@ CheckForBoulderCollisionWithSprites: .pushingHorizontallyLoop ld a, [hli] ld b, a - ld a, [$ffdc] + ld a, [hPlayerYCoord] cp b jr nz, .nextSprite2 ld b, [hl] - ld a, [$ffdb] + ld a, [hPlayerFacing] bit 2, a jr nz, .pushingLeft ; pushing right - ld a, [$ffdd] + ld a, [hPlayerXCoord] inc a jr .compareXCoords .pushingLeft - ld a, [$ffdd] + ld a, [hPlayerXCoord] dec a .compareXCoords cp b diff --git a/engine/overworld/push_boulder.asm b/engine/overworld/push_boulder.asm index c45554f1..e4dd91cf 100644 --- a/engine/overworld/push_boulder.asm +++ b/engine/overworld/push_boulder.asm @@ -92,7 +92,7 @@ DoBoulderDustAnimation:: call ResetBoulderPushFlags set 7, [hl] ld a, [wBoulderSpriteIndex] - ld [H_SPRITEINDEX], a + ld [hSpriteIndex], a call GetSpriteMovementByte2Pointer ld [hl], $10 ld a, SFX_CUT diff --git a/engine/overworld/special_warps.asm b/engine/overworld/special_warps.asm index eee85402..042146f9 100644 --- a/engine/overworld/special_warps.asm +++ b/engine/overworld/special_warps.asm @@ -146,4 +146,4 @@ LoadSpecialWarpData: ld [wDestinationWarpID], a ret -INCLUDE "data/special_warps.asm" +INCLUDE "data/maps/special_warps.asm" diff --git a/engine/overworld/sprite_collisions.asm b/engine/overworld/sprite_collisions.asm index 0e6b2d06..c5ff8ebb 100644 --- a/engine/overworld/sprite_collisions.asm +++ b/engine/overworld/sprite_collisions.asm @@ -6,7 +6,7 @@ _UpdateSprites:: ld l, a sub $e ld c, a - ld [H_CURRENTSPRITEOFFSET], a + ld [hCurrentSpriteOffset], a ld a, [hl] and a jr z, .skipSprite ; tests $c2Xe @@ -31,17 +31,17 @@ _UpdateSprites:: UpdateNonPlayerSprite: dec a swap a - ld [$ff93], a ; $10 * sprite# + ld [hTilePlayerStandingOn], a ; $10 * sprite# ld a, [wNPCMovementScriptSpriteOffset] ; some sprite offset? ld b, a - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] cp b jr nz, .unequal jp DoScriptedNPCMovement .unequal 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. ; 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). @@ -54,7 +54,7 @@ DetectCollisionBetweenSprites: nop ld h, wSpriteStateData1 / $100 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add wSpriteStateData1 % $100 ld l, a @@ -79,7 +79,7 @@ DetectCollisionBetweenSprites: and $f0 or c - ld [$ff90], a ; store Y coordinate adjusted for direction of movement + ld [hFF90], a ; store Y coordinate adjusted for direction of movement ld a, [hli] ; a = [$c1i5] (delta X) (-1, 0, or 1) call SetSpriteCollisionValues @@ -92,7 +92,7 @@ DetectCollisionBetweenSprites: and $f0 or c - ld [$ff91], a ; store X coordinate adjusted for direction of movement + ld [hFF91], a ; store X coordinate adjusted for direction of movement ld a, l add 7 @@ -102,18 +102,18 @@ DetectCollisionBetweenSprites: ld [hld], a ; zero [$c1id] XXX what's [$c1id] for? ld [hld], a ; zero [$c1ic] (directions in which collisions occurred) - ld a, [$ff91] + ld a, [hFF91] ld [hld], a ; [$c1ib] = adjusted X coordinate - ld a, [$ff90] + ld a, [hFF90] ld [hl], a ; [$c1ia] = adjusted Y coordinate xor a ; zero the loop counter .loop - ld [$ff8f], a ; store loop counter + ld [hFF8F], a ; store loop counter swap a ld e, a - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] cp e ; does the loop sprite match the current sprite? jp z, .next ; go to the next sprite if they match @@ -128,7 +128,7 @@ DetectCollisionBetweenSprites: inc a jp z, .next ; go the next sprite if offscreen - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add 10 ld l, a @@ -154,7 +154,7 @@ DetectCollisionBetweenSprites: cpl inc a .noCarry1 - ld [$ff90], a ; store the distance between the two sprites' adjusted Y values + ld [hFF90], a ; store the distance between the two sprites' adjusted Y values ; Use the carry flag set by the above subtraction to determine which sprite's ; Y coordinate is larger. This information is used later to set [$c1ic], @@ -176,11 +176,11 @@ DetectCollisionBetweenSprites: ld b, 9 .next1 - ld a, [$ff90] ; a = distance between adjusted Y coordinates + ld a, [hFF90] ; a = distance between adjusted Y coordinates sub b - ld [$ff92], a ; store distance adjusted using sprite i's direction + ld [hFF92], a ; store distance adjusted using sprite i's direction ld a, b - ld [$ff90], a ; store 7 or 9 depending on sprite i's delta Y + ld [hFF90], a ; store 7 or 9 depending on sprite i's delta Y jr c, .checkXDistance ; If sprite j's delta Y is 0, then b = 7, else b = 9. @@ -193,7 +193,7 @@ DetectCollisionBetweenSprites: ld b, 9 .next2 - ld a, [$ff92] ; a = distance adjusted using sprite i's direction + ld a, [hFF92] ; a = distance adjusted using sprite i's direction sub b ; adjust distance using sprite j's direction jr z, .checkXDistance jr nc, .next ; go to next sprite if distance is still positive after both adjustments @@ -225,7 +225,7 @@ DetectCollisionBetweenSprites: cpl inc a .noCarry2 - ld [$ff91], a ; store the distance between the two sprites' adjusted X values + ld [hFF91], a ; store the distance between the two sprites' adjusted X values ; Use the carry flag set by the above subtraction to determine which sprite's ; X coordinate is larger. This information is used later to set [$c1ic], @@ -247,11 +247,11 @@ DetectCollisionBetweenSprites: ld b, 9 .next3 - ld a, [$ff91] ; a = distance between adjusted X coordinates + ld a, [hFF91] ; a = distance between adjusted X coordinates sub b - ld [$ff92], a ; store distance adjusted using sprite i's direction + ld [hFF92], a ; store distance adjusted using sprite i's direction ld a, b - ld [$ff91], a ; store 7 or 9 depending on sprite i's delta X + ld [hFF91], a ; store 7 or 9 depending on sprite i's delta X jr c, .collision ; If sprite j's delta X is 0, then b = 7, else b = 9. @@ -264,15 +264,15 @@ DetectCollisionBetweenSprites: ld b, 9 .next4 - ld a, [$ff92] ; a = distance adjusted using sprite i's direction + ld a, [hFF92] ; a = distance adjusted using sprite i's direction sub b ; adjust distance using sprite j's direction jr z, .collision jr nc, .next ; go to next sprite if distance is still positive after both adjustments .collision - ld a, [$ff91] ; a = 7 or 9 depending on sprite i's delta X + ld a, [hFF91] ; a = 7 or 9 depending on sprite i's delta X ld b, a - ld a, [$ff90] ; a = 7 or 9 depending on sprite i's delta Y + ld a, [hFF90] ; a = 7 or 9 depending on sprite i's delta Y inc l ; If delta X isn't 0 and delta Y is 0, then b = %0011, else b = %1100. @@ -294,7 +294,7 @@ DetectCollisionBetweenSprites: ; set bit in [$c1ie] or [$c1if] to indicate which sprite the collision occurred with inc l inc l - ld a, [$ff8f] ; a = loop counter + ld a, [hFF8F] ; a = loop counter ld de, SpriteCollisionBitTable add a add e @@ -311,7 +311,7 @@ DetectCollisionBetweenSprites: ld [hl], a .next - ld a, [$ff8f] ; a = loop counter + ld a, [hFF8F] ; a = loop counter inc a cp $10 jp nz, .loop diff --git a/engine/overworld/tilesets.asm b/engine/overworld/tilesets.asm index 6e33974f..88147233 100644 --- a/engine/overworld/tilesets.asm +++ b/engine/overworld/tilesets.asm @@ -25,7 +25,7 @@ LoadTilesetHeader: ld a, [hl] ld [hTilesetType], a xor a - ld [$ffd8], a + ld [hMovingBGTilesCounter1], a pop hl ld a, [wCurMapTileset] push hl @@ -55,6 +55,6 @@ LoadTilesetHeader: .done ret -INCLUDE "data/dungeon_tilesets.asm" +INCLUDE "data/tilesets/dungeon_tilesets.asm" -INCLUDE "data/tileset_headers.asm" +INCLUDE "data/tilesets/tileset_headers.asm" diff --git a/engine/overworld/trainer_sight.asm b/engine/overworld/trainer_sight.asm index 5a68b627..81978c35 100755 --- a/engine/overworld/trainer_sight.asm +++ b/engine/overworld/trainer_sight.asm @@ -2,26 +2,26 @@ _GetSpritePosition1:: ld hl, wSpriteStateData1 ld de, $4 ld a, [wSpriteIndex] - ld [H_SPRITEINDEX], a + ld [hSpriteIndex], a call GetSpriteDataPointer ld a, [hli] ; c1x4 (screen Y pos) - ld [$ffeb], a + ld [hSpriteScreenYCoord], a inc hl ld a, [hl] ; c1x6 (screen X pos) - ld [$ffec], a + ld [hSpriteScreenXCoord], a ld de, (wSpriteStateData2 + $4) - (wSpriteStateData1 + $6) add hl, de ld a, [hli] ; c2x4 (map Y pos) - ld [$ffed], a + ld [hSpriteMapYCoord], a ld a, [hl] ; c2x5 (map X pos) - ld [$ffee], a + ld [hSpriteMapXCoord], a ret _GetSpritePosition2:: ld hl, wSpriteStateData1 ld de, $4 ld a, [wSpriteIndex] - ld [H_SPRITEINDEX], a + ld [hSpriteIndex], a call GetSpriteDataPointer ld a, [hli] ; c1x4 (screen Y pos) ld [wSavedSpriteScreenY], a @@ -40,18 +40,18 @@ _SetSpritePosition1:: ld hl, wSpriteStateData1 ld de, $4 ld a, [wSpriteIndex] - ld [H_SPRITEINDEX], a + ld [hSpriteIndex], a call GetSpriteDataPointer - ld a, [$ffeb] ; c1x4 (screen Y pos) + ld a, [hSpriteScreenYCoord] ; c1x4 (screen Y pos) ld [hli], a inc hl - ld a, [$ffec] ; c1x6 (screen X pos) + ld a, [hSpriteScreenXCoord] ; c1x6 (screen X pos) ld [hl], a ld de, (wSpriteStateData2 + $4) - (wSpriteStateData1 + $6) add hl, de - ld a, [$ffed] ; c2x4 (map Y pos) + ld a, [hSpriteMapYCoord] ; c2x4 (map Y pos) ld [hli], a - ld a, [$ffee] ; c2x5 (map X pos) + ld a, [hSpriteMapXCoord] ; c2x5 (map X pos) ld [hl], a ret @@ -59,7 +59,7 @@ _SetSpritePosition2:: ld hl, wSpriteStateData1 ld de, 4 ld a, [wSpriteIndex] - ld [H_SPRITEINDEX], a + ld [hSpriteIndex], a call GetSpriteDataPointer ld a, [wSavedSpriteScreenY] ld [hli], a ; c1x4 (screen Y pos) @@ -144,7 +144,7 @@ TrainerWalkUpToPlayer:: call FillMemory ; write the necessary steps to reach player ld [hl], $ff ; write end of list sentinel ld a, [wSpriteIndex] - ld [H_SPRITEINDEX], a + ld [hSpriteIndex], a jp MoveSprite_ ; input: de = offset within sprite entry @@ -152,7 +152,7 @@ TrainerWalkUpToPlayer:: GetSpriteDataPointer: push de add hl, de - ld a, [H_SPRITEINDEX] + ld a, [hSpriteIndex] swap a ld d, $0 ld e, a diff --git a/engine/overworld/turn_sprite.asm b/engine/overworld/turn_sprite.asm index c7f7712b..bef26537 100755 --- a/engine/overworld/turn_sprite.asm +++ b/engine/overworld/turn_sprite.asm @@ -1,12 +1,12 @@ UpdateSpriteFacingOffsetAndDelayMovement:: ld h, $c2 - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $8 ld l, a ld a, $7f ; maximum movement delay ld [hl], a ; c2x8 (movement delay) dec h - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $9 ld l, a ld a, [hld] ; c1x9 (facing direction) @@ -14,7 +14,7 @@ UpdateSpriteFacingOffsetAndDelayMovement:: xor a ld [hld], a ld [hl], a ; c1x8 (walk animation frame) - ld a, [H_CURRENTSPRITEOFFSET] + ld a, [hCurrentSpriteOffset] add $2 ld l, a ld a, [hl] ; c1x2 (facing and animation table offset) diff --git a/engine/overworld/update_map.asm b/engine/overworld/update_map.asm index 8577b9e7..92ae2b10 100644 --- a/engine/overworld/update_map.asm +++ b/engine/overworld/update_map.asm @@ -50,12 +50,12 @@ RedrawMapView: ld a, [wIsInBattle] inc a ret z - ld a, [H_AUTOBGTRANSFERENABLED] + ld a, [hAutoBGTransferEnabled] push af ld a, [hTilesetType] push af xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ld [hTilesetType], a ; no flower/water BG tile animations call LoadCurrentMapView call RunDefaultPaletteCommand @@ -63,7 +63,7 @@ RedrawMapView: ld a, [hli] ld h, [hl] ld l, a - ld de, -2 * 32 + ld de, -2 * BG_MAP_WIDTH add hl, de ld a, h and $3 @@ -73,23 +73,23 @@ RedrawMapView: ld a, h ld [wBuffer + 1], a ; this copy of the address is not used ld a, 2 - ld [$ffbe], a - ld c, 9 ; number of rows of 2x2 tiles (this covers the whole screen) + ld [hRedrawMapViewRowOffset], a + ld c, SCREEN_HEIGHT / 2 ; number of rows of 2x2 tiles (this covers the whole screen) .redrawRowLoop push bc push hl push hl ld hl, wTileMap - 2 * SCREEN_WIDTH ld de, SCREEN_WIDTH - ld a, [$ffbe] + ld a, [hRedrawMapViewRowOffset] .calcWRAMAddrLoop add hl, de dec a jr nz, .calcWRAMAddrLoop call CopyToRedrawRowOrColumnSrcTiles pop hl - ld de, $20 - ld a, [$ffbe] + ld de, BG_MAP_WIDTH + ld a, [hRedrawMapViewRowOffset] ld c, a .calcVRAMAddrLoop add hl, de @@ -104,7 +104,7 @@ RedrawMapView: ld a, REDRAW_ROW ld [hRedrawRowOrColumnMode], a call DelayFrame - ld hl, $ffbe + ld hl, hRedrawMapViewRowOffset inc [hl] inc [hl] pop hl @@ -114,7 +114,7 @@ RedrawMapView: pop af ld [hTilesetType], a pop af - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ret CompareHLWithBC: diff --git a/engine/overworld/wild_mons.asm b/engine/overworld/wild_mons.asm index df4d3121..2593e0ec 100644 --- a/engine/overworld/wild_mons.asm +++ b/engine/overworld/wild_mons.asm @@ -16,10 +16,10 @@ LoadWildData:: jr z, .NoGrassData ; if no grass data, skip to surfing data push hl ld de, wGrassMons ; otherwise, load grass data - ld bc, $0014 + ld bc, $14 call CopyData pop hl - ld bc, $0014 + ld bc, $14 add hl, bc .NoGrassData ld a, [hli] @@ -27,7 +27,7 @@ LoadWildData:: and a ret z ; if no water data, we're done ld de, wWaterMons ; otherwise, load surfing data - ld bc, $0014 + ld bc, $14 jp CopyData -INCLUDE "data/wild_mons.asm" +INCLUDE "data/wild/grass_water.asm" diff --git a/engine/pokemon/add_mon.asm b/engine/pokemon/add_mon.asm index 7627136b..8d0a6495 100644 --- a/engine/pokemon/add_mon.asm +++ b/engine/pokemon/add_mon.asm @@ -129,10 +129,10 @@ _AddPartyMon:: xor a ld b, a call CalcStat ; calc HP stat (set cur Hp to max HP) - ld a, [H_MULTIPLICAND+1] + ld a, [hMultiplicand+1] ld [de], a inc de - ld a, [H_MULTIPLICAND+2] + ld a, [hMultiplicand+2] ld [de], a inc de xor a diff --git a/engine/pokemon/bills_pc.asm b/engine/pokemon/bills_pc.asm index e5855f1d..d9a329f5 100644 --- a/engine/pokemon/bills_pc.asm +++ b/engine/pokemon/bills_pc.asm @@ -1,6 +1,6 @@ DisplayPCMainMenu:: xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a call SaveScreenTilesToBuffer2 ld a, [wNumHoFTeams] and a @@ -82,7 +82,7 @@ DisplayPCMainMenu:: ld [wCurrentMenuItem], a ld [wLastMenuItem], a ld a, 1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ret SomeonesPCText: db "SOMEONE's PC@" @@ -168,7 +168,7 @@ BillsPCMenu: ld de, BoxNoPCText call PlaceString ld a, 1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a call Delay3 call HandleMenuInput bit 1, a @@ -376,7 +376,8 @@ KnowsHMMove:: and a ret -INCLUDE "data/hm_moves.asm" +HMMoveArray: +INCLUDE "data/moves/hm_moves.asm" DisplayDepositWithdrawMenu: coord hl, 9, 10 diff --git a/engine/pokemon/evos_moves.asm b/engine/pokemon/evos_moves.asm index f50f8081..36f135cc 100755 --- a/engine/pokemon/evos_moves.asm +++ b/engine/pokemon/evos_moves.asm @@ -120,12 +120,12 @@ Evolution_PartyMonLoop: ; loop over party mons ld c, 50 call DelayFrames xor a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a coord hl, 0, 0 lb bc, 12, 20 call ClearScreenArea ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ld a, $ff ld [wUpdateSpritesEnabled], a call ClearSprites @@ -510,4 +510,4 @@ WriteMonMoves_ShiftMoveData: Evolution_FlagAction: predef_jump FlagActionPredef -INCLUDE "data/evos_moves.asm" +INCLUDE "data/pokemon/evos_moves.asm" diff --git a/engine/pokemon/experience.asm b/engine/pokemon/experience.asm index 3ee4b2a8..76e6b88b 100755 --- a/engine/pokemon/experience.asm +++ b/engine/pokemon/experience.asm @@ -38,58 +38,58 @@ CalcExperience:: add hl, bc call CalcDSquared ld a, d - ld [H_MULTIPLIER], a + ld [hMultiplier], a call Multiply ld a, [hl] and $f0 swap a - ld [H_MULTIPLIER], a + ld [hMultiplier], a call Multiply ld a, [hli] and $f - ld [H_DIVISOR], a + ld [hDivisor], a ld b, $4 call Divide - ld a, [H_QUOTIENT + 1] + ld a, [hQuotient + 1] push af - ld a, [H_QUOTIENT + 2] + ld a, [hQuotient + 2] push af - ld a, [H_QUOTIENT + 3] + ld a, [hQuotient + 3] push af call CalcDSquared ld a, [hl] and $7f - ld [H_MULTIPLIER], a + ld [hMultiplier], a call Multiply - ld a, [H_PRODUCT + 1] + ld a, [hProduct + 1] push af - ld a, [H_PRODUCT + 2] + ld a, [hProduct + 2] push af - ld a, [H_PRODUCT + 3] + ld a, [hProduct + 3] push af ld a, [hli] push af xor a - ld [H_MULTIPLICAND], a - ld [H_MULTIPLICAND + 1], a + ld [hMultiplicand], a + ld [hMultiplicand + 1], a ld a, d - ld [H_MULTIPLICAND + 2], a + ld [hMultiplicand + 2], a ld a, [hli] - ld [H_MULTIPLIER], a + ld [hMultiplier], a call Multiply ld b, [hl] - ld a, [H_PRODUCT + 3] + ld a, [hProduct + 3] sub b - ld [H_PRODUCT + 3], a + ld [hProduct + 3], a ld b, $0 - ld a, [H_PRODUCT + 2] + ld a, [hProduct + 2] sbc b - ld [H_PRODUCT + 2], a - ld a, [H_PRODUCT + 1] + ld [hProduct + 2], a + ld a, [hProduct + 1] 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 -; 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 ; term and adding the cubed term. pop af @@ -139,11 +139,11 @@ CalcExperience:: ; calculates d*d CalcDSquared: xor a - ld [H_MULTIPLICAND], a - ld [H_MULTIPLICAND + 1], a + ld [hMultiplicand], a + ld [hMultiplicand + 1], a ld a, d - ld [H_MULTIPLICAND + 2], a - ld [H_MULTIPLIER], a + ld [hMultiplicand + 2], a + ld [hMultiplier], a jp Multiply INCLUDE "data/growth_rates.asm" diff --git a/engine/pokemon/learn_move.asm b/engine/pokemon/learn_move.asm index 53c7f87e..09413c9b 100755 --- a/engine/pokemon/learn_move.asm +++ b/engine/pokemon/learn_move.asm @@ -126,13 +126,13 @@ TryingToLearn: call TextBoxBorder coord hl, 6, 8 ld de, wMovesString - ld a, [hFlags_0xFFF6] + ld a, [hFlagsFFF6] set 2, a - ld [hFlags_0xFFF6], a + ld [hFlagsFFF6], a call PlaceString - ld a, [hFlags_0xFFF6] + ld a, [hFlagsFFF6] res 2, a - ld [hFlags_0xFFF6], a + ld [hFlagsFFF6], a ld hl, wTopMenuItemY ld a, 8 ld [hli], a ; wTopMenuItemY @@ -146,10 +146,10 @@ TryingToLearn: ld a, A_BUTTON | B_BUTTON ld [hli], a ; wMenuWatchedKeys ld [hl], 0 ; wLastMenuItem - ld hl, hFlags_0xFFF6 + ld hl, hFlagsFFF6 set 1, [hl] call HandleMenuInput - ld hl, hFlags_0xFFF6 + ld hl, hFlagsFFF6 res 1, [hl] push af call LoadScreenTilesFromBuffer1 diff --git a/engine/pokemon/status_screen.asm b/engine/pokemon/status_screen.asm index 20bee0ee..b262a8b7 100755 --- a/engine/pokemon/status_screen.asm +++ b/engine/pokemon/status_screen.asm @@ -40,7 +40,7 @@ DrawHP_: push hl call DrawHPBar pop hl - ld a, [hFlags_0xFFF6] + ld a, [hFlagsFFF6] bit 0, a jr z, .printFractionBelowBar ld bc, $9 ; right of bar @@ -254,7 +254,7 @@ PrintStatsBox: ld c, 8 call TextBoxBorder ; Draws the box coord hl, 1, 9 ; Start printing stats from here - ld bc, $0019 ; Number offset + ld bc, $19 ; Number offset jr .PrintStats .DifferentBox coord hl, 9, 2 @@ -262,7 +262,7 @@ PrintStatsBox: ld c, 9 call TextBoxBorder coord hl, 11, 3 - ld bc, $0018 + ld bc, $18 .PrintStats push bc push hl @@ -299,7 +299,7 @@ StatusScreen2: push af xor a ld [hTilesetType], a - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a ld bc, NUM_MOVES + 1 ld hl, wMoves call FillMemory @@ -424,7 +424,7 @@ StatusScreen2: coord hl, 9, 1 call PlaceString ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a + ld [hAutoBGTransferEnabled], a call Delay3 call WaitForTextScrollButtonPress ; wait for button pop af diff --git a/engine/slots/game_corner_slots.asm b/engine/slots/game_corner_slots.asm index 2108695f..d95d20a3 100755 --- a/engine/slots/game_corner_slots.asm +++ b/engine/slots/game_corner_slots.asm @@ -22,7 +22,7 @@ StartSlotMachine: ld a, 250 .next ld [wSlotMachineSevenAndBarModeChance], a - ld a, [H_LOADEDROMBANK] + ld a, [hLoadedROMBank] ld [wSlotMachineSavedROMBank], a call PromptUserToPlaySlots ret diff --git a/engine/slots/slot_machine.asm b/engine/slots/slot_machine.asm index 0a92c69b..c3de5dd2 100755 --- a/engine/slots/slot_machine.asm +++ b/engine/slots/slot_machine.asm @@ -31,7 +31,7 @@ PromptUserToPlaySlots: xor a ld [wSlotMachineAllowMatchesCounter], a ld hl, wStoppingWhichSlotMachineWheel - ld bc, $0014 + ld bc, $14 call FillMemory call MainSlotMachineLoop ld hl, wd730 @@ -881,7 +881,7 @@ SlotMachineMap: INCBIN "gfx/slots/slots.tilemap" SlotMachineMapEnd: -INCLUDE "data/slot_machine_wheels.asm" +INCLUDE "data/events/slot_machine_wheels.asm" SlotMachineTiles1: IF DEF(_RED) |