diff options
| author | dannye <33dannye@gmail.com> | 2026-01-17 22:38:33 -0600 |
|---|---|---|
| committer | dannye <33dannye@gmail.com> | 2026-01-17 22:38:33 -0600 |
| commit | bc2354dd6626ce28bb9561547ed2107cfa56c18e (patch) | |
| tree | 5902d4c3389253c76b7c3351e0d7dfecb551c28d /engine | |
| parent | Identify characters in `_OakSpeechText2B` and `Printer_GetMonStats.IDNo` (#144) (diff) | |
| parent | Use macros for `WildMonEncounterSlotChances` (#562) (diff) | |
| download | pokeyellow-bc2354dd6626ce28bb9561547ed2107cfa56c18e.tar.gz pokeyellow-bc2354dd6626ce28bb9561547ed2107cfa56c18e.tar.xz pokeyellow-bc2354dd6626ce28bb9561547ed2107cfa56c18e.zip | |
Merge branch 'master' of https://github.com/pret/pokered
Diffstat (limited to 'engine')
105 files changed, 756 insertions, 735 deletions
diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index 5adecbd7..aafb966e 100644 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -24,7 +24,7 @@ DrawFrameBlock: jp z, .flipHorizontalTranslateDown ; SUBANIMTYPE_HFLIP dec a jr z, .flipBaseCoords ; SUBANIMTYPE_COORDFLIP -.noTransformation +; no transformation ld a, [wBaseCoordY] add [hl] ld [de], a ; store Y @@ -157,7 +157,7 @@ DrawFrameBlock: ld a, [wNumFBTiles] cp c jp nz, .loop ; go back up if there are more tiles to draw -.afterDrawingTiles +; after drawing tiles ld a, [wFBMode] cp FRAMEBLOCKMODE_02 jr z, .advanceFrameBlockDestAddr ; skip delay and don't clean OAM buffer @@ -210,7 +210,7 @@ PlayAnimation: jr z, .AnimationOver cp FIRST_SE_ID ; is this subanimation or a special effect? jr c, .playSubanimation -.doSpecialEffect +; do Special Effect ld c, a ld de, SpecialEffectPointers .searchSpecialEffectTableLoop @@ -315,11 +315,11 @@ LoadSubanimation: and %11100000 cp SUBANIMTYPE_ENEMY << 5 vc_hook Reduce_move_anim_flashing_Reflect - jr nz, .isNotType5 -.isType5 + jr nz, .isNotTypeEnemy +; subanim type enemy call GetSubanimationTransform2 jr .saveTransformation -.isNotType5 +.isNotTypeEnemy vc_hook Reduce_move_anim_flashing_Self_Destruct call GetSubanimationTransform1 .saveTransformation @@ -440,11 +440,11 @@ MoveAnimation: jr nz, .animationsDisabled call ShareMoveAnimations call PlayAnimation - jr .next4 + jr .next .animationsDisabled ld c, 30 call DelayFrames -.next4 +.next vc_hook Stop_reducing_move_anim_flashing_Reflect call PlayApplyingAttackAnimation ; shake the screen or flash the pic in and out (to show damage) .animationFinished @@ -968,7 +968,7 @@ BallMoveDistances2: DoGrowlSpecialEffects: ld hl, wShadowOAM ld de, wShadowOAMSprite04 - ld bc, $10 + ld bc, OBJ_SIZE * 4 call CopyData ; copy the musical note graphic ld a, [wSubAnimCounter] dec a @@ -1141,6 +1141,8 @@ SetAnimationBGPalette: call UpdateCGBPal_BGP ret +AnimationUnusedShakeScreen: ; unreferenced +; Shakes the screen for a while. ld b, $5 AnimationShakeScreenVertically: @@ -1272,12 +1274,12 @@ _AnimationSlideMonUp: push bc ; In each iteration, slide up all rows but the top one (which is overwritten). - ld b, 6 + ld b, PIC_HEIGHT - 1 .slideLoop push bc push de push hl - ld bc, 7 + ld bc, PIC_WIDTH call CopyData ; Note that de and hl are popped in the same order they are pushed, swapping ; their values. When CopyData is called, hl points to a tile 1 row below @@ -1301,10 +1303,10 @@ _AnimationSlideMonUp: ld a, [wSlideMonUpBottomRowLeftTile] inc a ld [wSlideMonUpBottomRowLeftTile], a - ld c, 7 + ld c, PIC_WIDTH .fillBottomRowLoop ld [hli], a - add 7 + add PIC_WIDTH dec c jr nz, .fillBottomRowLoop @@ -1381,7 +1383,7 @@ AdjustOAMBlockXPos: ld h, d AdjustOAMBlockXPos2: - ld de, 4 + ld de, OBJ_SIZE .loop ld a, [wCoordAdjustmentAmount] ld b, a @@ -1391,7 +1393,7 @@ AdjustOAMBlockXPos2: jr c, .skipPuttingEntryOffScreen ; put off-screen if X >= 168 dec hl - ld a, 160 + ld a, SCREEN_HEIGHT_PX + OAM_Y_OFS ld [hli], a .skipPuttingEntryOffScreen ld [hl], a @@ -1405,7 +1407,7 @@ AdjustOAMBlockYPos: ld h, d AdjustOAMBlockYPos2: - ld de, 4 + ld de, OBJ_SIZE .loop ld a, [wCoordAdjustmentAmount] ld b, a @@ -1756,7 +1758,7 @@ _AnimationShootBallsUpward: dec a ld [wNumShootingBalls], a .next - ld de, 4 + ld de, OBJ_SIZE add hl, de ; next OAM entry dec b jr nz, .innerLoop @@ -1809,10 +1811,10 @@ AnimationMinimizeMon: ld hl, wTempPic push hl xor a - ld bc, 7 * 7 * $10 + ld bc, PIC_SIZE tiles call FillMemory pop hl - ld de, 7 * 3 * $10 + 4 * $10 + 4 + ld de, (PIC_WIDTH * 3 + 4) tiles + TILE_SIZE / 4 add hl, de ld de, MinimizedMonSprite ld c, MinimizedMonSpriteEnd - MinimizedMonSprite @@ -1860,7 +1862,7 @@ AnimationSlideMonDownAndHide: jr nz, .loop call AnimationHideMonPic ld hl, wTempPic - ld bc, 7 * 7 tiles + ld bc, PIC_SIZE tiles xor a call FillMemory jp CopyTempPicToMonPic @@ -1951,7 +1953,7 @@ CopyTempPicToMonPic: ld hl, vFrontPic ; enemy turn .next ld de, wTempPic - ld bc, 7 * 7 + ld bc, PIC_SIZE jp CopyVideoData AnimationWavyScreen: @@ -2019,7 +2021,7 @@ AnimationSubstitute: ; Changes the pokemon's sprite to the mini sprite ld hl, wTempPic xor a - ld bc, 7 * 7 tiles + ld bc, PIC_SIZE tiles call FillMemory ldh a, [hWhoseTurn] and a @@ -2055,7 +2057,7 @@ AnimationSubstitute: jp AnimationShowMonPic CopyMonsterSpriteData: - ld bc, 1 tiles + ld bc, TILE_SIZE ld a, BANK(MonsterSprite) jp FarCopyData @@ -2538,7 +2540,7 @@ FallingObjects_UpdateOAMEntry: inc a cp 112 jr c, .next - ld a, 160 ; if Y >= 112, put it off-screen + ld a, SCREEN_HEIGHT_PX + OAM_Y_OFS ; if Y >= 112, put it off-screen .next ld [hli], a ; Y cp 40 @@ -2655,7 +2657,7 @@ AnimationShakeEnemyHUD: ; Make a copy of the back pic's tile patterns in sprite tile pattern VRAM. ld de, vBackPic ld hl, vSprites - ld bc, 7 * 7 + ld bc, PIC_SIZE call CopyVideoData xor a diff --git a/engine/battle/battle_transitions.asm b/engine/battle/battle_transitions.asm index 8a340bf7..cd0af180 100644 --- a/engine/battle/battle_transitions.asm +++ b/engine/battle/battle_transitions.asm @@ -14,7 +14,7 @@ BattleTransition: ldh a, [hSpriteIndex] ; enemy trainer sprite index (0 if wild battle) ld c, a ld b, 0 - ld de, $10 + ld de, SPRITESTATEDATA1_LENGTH .loop1 ld a, [hl] cp $ff @@ -35,13 +35,13 @@ BattleTransition: jr z, .skip2 ; skip clearing the block if the enemy trainer is using it push hl push bc - ld bc, $10 + ld bc, OBJ_SIZE * 4 xor a call FillMemory pop bc pop hl .skip2 - ld de, $10 + ld de, OBJ_SIZE * 4 add hl, de dec c jr nz, .loop2 @@ -104,11 +104,11 @@ GetBattleTransitionID_CompareLevels: ld a, [hli] or [hl] jr nz, .notFainted - ld de, wPartyMon2 - (wPartyMon1 + 1) + ld de, PARTYMON_STRUCT_LENGTH - 1 add hl, de jr .faintedLoop .notFainted - ld de, wPartyMon1Level - (wPartyMon1HP + 1) + ld de, MON_LEVEL - (MON_HP + 1) add hl, de ld a, [hl] add $3 diff --git a/engine/battle/core.asm b/engine/battle/core.asm index a1a989e4..33301e58 100644 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -109,8 +109,8 @@ SlidePlayerAndEnemySilhouettesOnScreen: SlidePlayerHeadLeft: push bc ld hl, wShadowOAMSprite00XCoord - ld c, $15 ; number of OAM entries - ld de, $4 ; size of OAM entry + ld c, 7 * 3 ; number of OAM entries + ld de, OBJ_SIZE .loop dec [hl] ; decrement X dec [hl] ; decrement X @@ -140,7 +140,7 @@ StartBattle: inc a ld [wFirstMonsNotOutYet], a ld hl, wEnemyMon1HP - ld bc, wEnemyMon2 - wEnemyMon1 - 1 + ld bc, PARTYMON_STRUCT_LENGTH - 1 ld d, $3 .findFirstAliveEnemyMonLoop inc d @@ -745,7 +745,7 @@ FaintEnemyPokemon: jr z, .wild ld a, [wEnemyMonPartyPos] ld hl, wEnemyMon1HP - ld bc, wEnemyMon2 - wEnemyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes xor a ld [hli], a @@ -885,7 +885,7 @@ AnyEnemyPokemonAliveCheck: ld b, a xor a ld hl, wEnemyMon1HP - ld de, wEnemyMon2 - wEnemyMon1 + ld de, PARTYMON_STRUCT_LENGTH .nextPokemon or [hl] inc hl @@ -1222,17 +1222,17 @@ SlideDownFaintedMonPic: push af set BIT_NO_TEXT_DELAY, a ld [wStatusFlags5], a - ld b, 7 ; number of times to slide + ld b, PIC_HEIGHT ; number of times to slide .slideStepLoop ; each iteration, the mon is slid down one row push bc push de push hl - ld b, 6 ; number of rows + ld b, PIC_HEIGHT - 1 ; number of rows .rowLoop push bc push hl push de - ld bc, $7 + ld bc, PIC_WIDTH call CopyData pop de pop hl @@ -1264,7 +1264,8 @@ SlideDownFaintedMonPic: ret SevenSpacesText: - db " @" + ds PIC_WIDTH, ' ' + db "@" ; 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) @@ -1276,7 +1277,7 @@ SlideTrainerPicOffScreen: .slideStepLoop ; each iteration, the trainer pic is slid one tile left/right push bc push hl - ld b, 7 ; number of rows + ld b, PIC_HEIGHT ; number of rows .rowLoop push hl ldh a, [hSlideAmount] @@ -1285,7 +1286,7 @@ SlideTrainerPicOffScreen: ldh a, [hSlideAmount] cp 8 jr z, .slideRight -.slideLeft ; slide player sprite off screen +; slide player sprite left off screen ld a, [hld] ld [hli], a inc hl @@ -1368,7 +1369,7 @@ EnemySendOutFirstMon: ld a, b ld [wWhichPokemon], a push bc - ld bc, wEnemyMon2 - wEnemyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes pop bc inc hl @@ -1380,7 +1381,7 @@ EnemySendOutFirstMon: .next3 ld a, [wWhichPokemon] ld hl, wEnemyMon1Level - ld bc, wEnemyMon2 - wEnemyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld a, [hl] ld [wCurEnemyLevel], a @@ -1495,7 +1496,7 @@ AnyPartyAlive:: ld e, a xor a ld hl, wPartyMon1HP - ld bc, wPartyMon2 - wPartyMon1 - 1 + ld bc, PARTYMON_STRUCT_LENGTH - 1 .partyMonsLoop or [hl] inc hl @@ -1511,7 +1512,7 @@ AnyPartyAlive:: HasMonFainted: ld a, [wWhichPokemon] ld hl, wPartyMon1HP - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld a, [hli] or [hl] @@ -1665,16 +1666,16 @@ GotAwayText: ; copies from party data to battle mon data when sending out a new player mon LoadBattleMonFromParty: ld a, [wWhichPokemon] - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH ld hl, wPartyMon1Species call AddNTimes ld de, wBattleMonSpecies ld bc, wBattleMonDVs - wBattleMonSpecies call CopyData - ld bc, wPartyMon1DVs - wPartyMon1OTID + ld bc, MON_DVS - MON_OTID add hl, bc ld de, wBattleMonDVs - ld bc, wPartyMon1PP - wPartyMon1DVs + ld bc, MON_PP - MON_DVS call CopyData ld de, wBattleMonPP ld bc, NUM_MOVES @@ -1709,16 +1710,16 @@ LoadBattleMonFromParty: ; copies from enemy party data to current enemy mon data when sending out a new enemy mon LoadEnemyMonFromParty: ld a, [wWhichPokemon] - ld bc, wEnemyMon2 - wEnemyMon1 + ld bc, PARTYMON_STRUCT_LENGTH ld hl, wEnemyMons call AddNTimes ld de, wEnemyMonSpecies ld bc, wEnemyMonDVs - wEnemyMonSpecies call CopyData - ld bc, wEnemyMon1DVs - wEnemyMon1OTID + ld bc, MON_DVS - MON_OTID add hl, bc ld de, wEnemyMonDVs - ld bc, wEnemyMon1PP - wEnemyMon1DVs + ld bc, MON_PP - MON_DVS call CopyData ld de, wEnemyMonPP ld bc, NUM_MOVES @@ -1869,17 +1870,17 @@ AnimateRetreatingPlayerMon: call ClearScreenArea ret -; Copies player's current pokemon's current HP and status into the party +; Copies player's current pokemon's current HP, party pos, and status into the party ; struct data so it stays after battle or switching ReadPlayerMonCurHPAndStatus: ld a, [wPlayerMonNumber] ld hl, wPartyMon1HP - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld d, h ld e, l ld hl, wBattleMonHP - ld bc, $4 ; 2 bytes HP, 1 byte unknown (unused?), 1 byte status + ld bc, MON_STATUS + 1 - MON_HP ; also copies party pos in-between HP and status jp CopyData DrawHUDsAndHPBars: @@ -2623,7 +2624,7 @@ MoveSelectionMenu: .relearnmenu ld a, [wWhichPokemon] ld hl, wPartyMon1Moves - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes call .loadmoves hlcoord 4, 7 @@ -2969,12 +2970,12 @@ ENDC .swapMovesInPartyMon ld hl, wPartyMon1Moves ld a, [wPlayerMonNumber] - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes push hl call .swapBytes ; swap moves pop hl - ld bc, wPartyMon1PP - wPartyMon1Moves + ld bc, MON_PP - MON_MOVES add hl, bc call .swapBytes ; swap move PP xor a @@ -3285,7 +3286,7 @@ PlayerCanExecuteChargingMove: ; resulting in the Pokemon being invulnerable for the whole battle res INVULNERABLE, [hl] PlayerCanExecuteMove: - call PrintMonName1Text + call DisplayUsedMoveText ld hl, DecrementPP ld de, wPlayerSelectedMove ; pointer to the move just used ld b, BANK(DecrementPP) @@ -3621,7 +3622,7 @@ CheckPlayerStatusConditions: bit PAR, [hl] jr z, .BideCheck call BattleRandom - cp $3F ; 25% to be fully paralyzed + cp 25 percent ; chance to be fully paralyzed jr nc, .BideCheck ld hl, FullyParalyzedText call PrintText @@ -3727,11 +3728,12 @@ CheckPlayerStatusConditions: ld hl, AttackContinuesText call PrintText ld a, [wPlayerNumAttacksLeft] - dec a ; did multi-turn move end? + dec a ld [wPlayerNumAttacksLeft], a - ld hl, GetPlayerAnimationType ; if it didn't, skip damage calculation (deal damage equal to last hit), - ; DecrementPP and MoveHitTest - jp nz, .returnToHL + ld hl, GetPlayerAnimationType ; skip damage calculation (deal damage equal to last hit), + ; DecrementPP and MoveHitTest + jp nz, .returnToHL ; redundant leftover code, the case wEnemyNumAttacksLeft == 0 + ; is handled within CheckNumAttacksLeft jp .returnToHL .RageCheck @@ -3796,7 +3798,7 @@ ConfusedNoMoreText: text_far _ConfusedNoMoreText text_end -SavingEnergyText: +SavingEnergyText: ; unreferenced text_far _SavingEnergyText text_end @@ -3882,139 +3884,7 @@ HandleSelfConfusionDamage: ldh [hWhoseTurn], a jp ApplyDamageToPlayerPokemon -PrintMonName1Text: - ld hl, MonName1Text - jp PrintText - -; this function wastes time calling DetermineExclamationPointTextNum -; and choosing between Used1Text and Used2Text, even though -; those text strings are identical and both continue at PrintInsteadText -; this likely had to do with Japanese grammar that got translated, -; but the functionality didn't get removed -MonName1Text: - text_far _MonName1Text - text_asm - ldh a, [hWhoseTurn] - and a - ld a, [wPlayerMoveNum] - ld hl, wPlayerUsedMove - jr z, .playerTurn - ld a, [wEnemyMoveNum] - ld hl, wEnemyUsedMove -.playerTurn - ld [hl], a - ld [wMoveGrammar], a - call DetermineExclamationPointTextNum - ld a, [wMonIsDisobedient] - and a - ld hl, Used2Text - ret nz - ld a, [wMoveGrammar] - cp 3 - ld hl, Used2Text - ret c - ld hl, Used1Text - ret - -Used1Text: - text_far _Used1Text - text_asm - jr PrintInsteadText - -Used2Text: - text_far _Used2Text - text_asm - ; fall through - -PrintInsteadText: - ld a, [wMonIsDisobedient] - and a - jr z, PrintMoveName - ld hl, InsteadText - ret - -InsteadText: - text_far _InsteadText - text_asm - ; fall through - -PrintMoveName: - ld hl, _PrintMoveName - ret - -_PrintMoveName: - text_far _MoveNameText - text_asm - ld hl, ExclamationPointPointerTable - ld a, [wMoveGrammar] - add a - push bc - ld b, $0 - ld c, a - add hl, bc - pop bc - ld a, [hli] - ld h, [hl] - ld l, a - ret - -ExclamationPointPointerTable: - dw ExclamationPoint1Text - dw ExclamationPoint2Text - dw ExclamationPoint3Text - dw ExclamationPoint4Text - dw ExclamationPoint5Text - -ExclamationPoint1Text: - text_far _ExclamationPoint1Text - text_end - -ExclamationPoint2Text: - text_far _ExclamationPoint2Text - text_end - -ExclamationPoint3Text: - text_far _ExclamationPoint3Text - text_end - -ExclamationPoint4Text: - text_far _ExclamationPoint4Text - text_end - -ExclamationPoint5Text: - text_far _ExclamationPoint5Text - text_end - -; this function does nothing useful -; if the move being used is in set [1-4] from ExclamationPointMoveSets, -; use ExclamationPoint[1-4]Text -; otherwise, use ExclamationPoint5Text -; but all five text strings are identical -; this likely had to do with Japanese grammar that got translated, -; but the functionality didn't get removed -DetermineExclamationPointTextNum: - push bc - ld a, [wMoveGrammar] ; move ID - ld c, a - ld b, $0 - ld hl, ExclamationPointMoveSets -.loop - ld a, [hli] - cp $ff - jr z, .done - cp c - jr z, .done - and a - jr nz, .loop - inc b - jr .loop -.done - ld a, b - ld [wMoveGrammar], a - pop bc - ret - -INCLUDE "data/moves/grammar.asm" +INCLUDE "engine/battle/used_move_text.asm" PrintMoveFailureText: ld de, wPlayerMoveEffect @@ -4140,7 +4010,7 @@ CheckForDisobedience: ; compare the mon's original trainer ID with the player's ID to see if it was traded .checkIfMonIsTraded ld hl, wPartyMon1OTID - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH ld a, [wPlayerMonNumber] call AddNTimes ld a, [wPlayerID] @@ -4341,7 +4211,7 @@ GetDamageVarsForPlayerAttack: ld a, [hl] ; a = [wPlayerMoveType] cp SPECIAL ; types >= SPECIAL are all special jr nc, .specialAttack -.physicalAttack +; physical attack ld hl, wEnemyMonDefense ld a, [hli] ld b, a @@ -4367,7 +4237,7 @@ GetDamageVarsForPlayerAttack: push bc ld hl, wPartyMon1Attack ld a, [wPlayerMonNumber] - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes pop bc jr .scaleStats @@ -4399,7 +4269,7 @@ GetDamageVarsForPlayerAttack: push bc ld hl, wPartyMon1Special ld a, [wPlayerMonNumber] - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes 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 @@ -4454,7 +4324,7 @@ GetDamageVarsForEnemyAttack: ld a, [hl] ; a = [wEnemyMoveType] cp SPECIAL ; types >= SPECIAL are all special jr nc, .specialAttack -.physicalAttack +; physical attack ld hl, wBattleMonDefense ld a, [hli] ld b, a @@ -4473,7 +4343,7 @@ GetDamageVarsForEnemyAttack: ; in the case of a critical hit, reset the player's defense and the enemy's attack to their base values ld hl, wPartyMon1Defense ld a, [wPlayerMonNumber] - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld a, [hli] ld b, a @@ -4505,7 +4375,7 @@ GetDamageVarsForEnemyAttack: ; in the case of a critical hit, reset the player's and enemy's specials to their base values ld hl, wPartyMon1Special ld a, [wPlayerMonNumber] - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld a, [hli] ld b, a @@ -4568,7 +4438,7 @@ GetEnemyMonStat: ld b, $0 add hl, bc ld a, [wEnemyMonPartyPos] - ld bc, wEnemyMon2 - wEnemyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld a, [hli] ldh [hMultiplicand + 1], a @@ -5367,7 +5237,7 @@ IncrementMovePP: jr z, .updatePP ld a, [wEnemyMonPartyPos] ; value for enemy turn .updatePP - ld bc, wEnemyMon2 - wEnemyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes inc [hl] ; increment PP in the party memory location ret @@ -5471,7 +5341,6 @@ AdjustDamageForMoveType: ld [hl], a or b ; is damage 0? jr nz, .skipTypeImmunity -.typeImmunity ; if damage is 0, make the move miss ; this only occurs if a move that would do 2 or 3 damage is 0.25x effective against the target inc a @@ -5575,7 +5444,7 @@ MoveHitTest: ldh a, [hWhoseTurn] and a jr nz, .enemyTurn -.playerTurn +; player's turn ; this checks if the move effect is disallowed by mist ld a, [wPlayerMoveEffect] cp ATTACK_DOWN1_EFFECT @@ -5647,12 +5516,12 @@ MoveHitTest: ld [wMoveMissed], a ldh a, [hWhoseTurn] and a - jr z, .playerTurn2 -.enemyTurn2 + jr z, .playerTurn +; enemy's turn ld hl, wEnemyBattleStatus1 res USING_TRAPPING_MOVE, [hl] ; end multi-turn attack e.g. wrap ret -.playerTurn2 +.playerTurn ld hl, wPlayerBattleStatus1 res USING_TRAPPING_MOVE, [hl] ; end multi-turn attack e.g. wrap ret @@ -5823,7 +5692,7 @@ EnemyCanExecuteChargingMove: EnemyCanExecuteMove: xor a ld [wMonIsDisobedient], a - call PrintMonName1Text + call DisplayUsedMoveText ld a, [wEnemyMoveEffect] ld hl, ResidualEffects1 ld de, $1 @@ -6244,10 +6113,11 @@ CheckEnemyStatusConditions: ld hl, AttackContinuesText call PrintText ld hl, wEnemyNumAttacksLeft - dec [hl] ; did multi-turn move end? - ld hl, GetEnemyAnimationType ; if it didn't, skip damage calculation (deal damage equal to last hit), + dec [hl] + ld hl, GetEnemyAnimationType ; skip damage calculation (deal damage equal to last hit), ; DecrementPP and MoveHitTest - jp nz, .enemyReturnToHL + jp nz, .enemyReturnToHL ; redundant leftover code, the case wEnemyNumAttacksLeft == 0 + ; is handled within CheckNumAttacksLeft jp .enemyReturnToHL .checkIfUsingRage ld a, [wEnemyBattleStatus2] @@ -6387,7 +6257,7 @@ LoadEnemyMonData: ; if it's a trainer battle, copy moves from enemy party data ld hl, wEnemyMon1Moves ld a, [wWhichPokemon] - ld bc, wEnemyMon2 - wEnemyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld bc, NUM_MOVES call CopyData @@ -6538,7 +6408,7 @@ LoadPlayerBackPic: ld [hl], d ; OAM Y inc hl ld [hl], e ; OAM X - ld a, $8 ; height of tile + ld a, TILE_HEIGHT add d ; increase Y by height of tile ld d, a inc hl @@ -6554,7 +6424,7 @@ LoadPlayerBackPic: ldh a, [hOAMTile] add $4 ; increase tile number by 4 ldh [hOAMTile], a - ld a, $8 ; width of tile + ld a, TILE_WIDTH add e ; increase X by width of tile ld e, a dec b @@ -6567,7 +6437,7 @@ LoadPlayerBackPic: ld de, sSpriteBuffer1 ldh a, [hLoadedROMBank] ld b, a - ld c, 7 * 7 + ld c, PIC_SIZE call CopyVideoData call CloseSRAM ld a, $31 @@ -6599,7 +6469,7 @@ QuarterSpeedDueToParalysis: ldh a, [hWhoseTurn] and a jr z, .playerTurn -.enemyTurn ; quarter the player's speed +; enemy's turn, quarter the player's speed ld a, [wBattleMonStatus] and 1 << PAR ret z ; return if player not paralysed @@ -6642,7 +6512,7 @@ HalveAttackDueToBurn: ldh a, [hWhoseTurn] and a jr z, .playerTurn -.enemyTurn ; halve the player's attack +; enemy's turn, halve the player's attack ld a, [wBattleMonStatus] and 1 << BRN ret z ; return if player not burnt @@ -6826,7 +6696,7 @@ LoadHudTilePatterns: ldh a, [rLCDC] add a ; is LCD disabled? jr c, .lcdEnabled -.lcdDisabled +; LCD disabled ld hl, BattleHudTiles1 ld de, vChars2 tile $6d ld bc, BattleHudTiles1End - BattleHudTiles1 @@ -6840,11 +6710,11 @@ LoadHudTilePatterns: .lcdEnabled ld de, BattleHudTiles1 ld hl, vChars2 tile $6d - lb bc, BANK(BattleHudTiles1), (BattleHudTiles1End - BattleHudTiles1) / $8 + lb bc, BANK(BattleHudTiles1), (BattleHudTiles1End - BattleHudTiles1) / TILE_1BPP_SIZE call CopyVideoDataDouble ld de, BattleHudTiles2 ld hl, vChars2 tile $73 - lb bc, BANK(BattleHudTiles2), (BattleHudTiles3End - BattleHudTiles2) / $8 + lb bc, BANK(BattleHudTiles2), (BattleHudTiles3End - BattleHudTiles2) / TILE_1BPP_SIZE jp CopyVideoDataDouble PrintEmptyString: diff --git a/engine/battle/decrement_pp.asm b/engine/battle/decrement_pp.asm index 441bbb81..93515224 100644 --- a/engine/battle/decrement_pp.asm +++ b/engine/battle/decrement_pp.asm @@ -31,7 +31,7 @@ DecrementPP: ld hl, wPartyMon1PP ; PP of first move (in party) ld a, [wPlayerMonNumber] ; which mon in party is active - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ; calculate address of the mon to modify .DecrementPP: ld a, [wPlayerMoveListIndex] ; which move (0, 1, 2, 3) did we use? diff --git a/engine/battle/draw_hud_pokeball_gfx.asm b/engine/battle/draw_hud_pokeball_gfx.asm index 0b0aac7d..bf955040 100644 --- a/engine/battle/draw_hud_pokeball_gfx.asm +++ b/engine/battle/draw_hud_pokeball_gfx.asm @@ -13,12 +13,12 @@ DrawEnemyPokeballs: LoadPartyPokeballGfx: ld de, PokeballTileGraphics ld hl, vSprites tile $31 - lb bc, BANK(PokeballTileGraphics), (PokeballTileGraphicsEnd - PokeballTileGraphics) / $10 + lb bc, BANK(PokeballTileGraphics), (PokeballTileGraphicsEnd - PokeballTileGraphics) / TILE_SIZE jp CopyVideoData SetupOwnPartyPokeballs: call PlacePlayerHUDTiles - ld hl, wPartyMon1 + ld hl, wPartyMons ld de, wPartyCount call SetupPokeballs ld a, $60 @@ -94,7 +94,7 @@ PickPokeball: .done ld a, b ld [de], a - ld bc, wPartyMon2 - wPartyMon1Status + ld bc, PARTYMON_STRUCT_LENGTH - MON_STATUS add hl, bc ; next mon struct ret @@ -123,7 +123,7 @@ WritePokeballOAMData: PlacePlayerHUDTiles: ld hl, PlayerBattleHUDGraphicsTiles ld de, wHUDGraphicsTiles - ld bc, $3 + ld bc, wHUDGraphicsTilesEnd - wHUDGraphicsTiles call CopyData hlcoord 18, 10 ld de, -1 @@ -138,7 +138,7 @@ PlayerBattleHUDGraphicsTiles: PlaceEnemyHUDTiles: ld hl, EnemyBattleHUDGraphicsTiles ld de, wHUDGraphicsTiles - ld bc, $3 + ld bc, wHUDGraphicsTilesEnd - wHUDGraphicsTiles call CopyData hlcoord 1, 2 ld de, $1 @@ -154,7 +154,7 @@ PlaceHUDTiles: ld [hl], $73 ld bc, SCREEN_WIDTH add hl, bc - ld a, [wHUDGraphicsTiles + 1] ; leftmost tile + ld a, [wHUDCornerTile] ; leftmost tile ld [hl], a ld a, 8 .loop @@ -163,7 +163,7 @@ PlaceHUDTiles: dec a jr nz, .loop add hl, de - ld a, [wHUDGraphicsTiles + 2] ; rightmost tile + ld a, [wHUDTriangleTile] ; rightmost tile ld [hl], a ret diff --git a/engine/battle/effects.asm b/engine/battle/effects.asm index 2babf7f1..185b7dad 100644 --- a/engine/battle/effects.asm +++ b/engine/battle/effects.asm @@ -41,7 +41,7 @@ SleepEffect: ; including the event where the target already has another status ld a, [de] ld b, a - and $7 + and SLP_MASK jr z, .notAlreadySleeping ; can't affect a mon that is already asleep ld hl, AlreadyAsleepText jp PrintText @@ -58,7 +58,7 @@ SleepEffect: .setSleepCounter ; set target's sleep counter to a random number between 1 and 7 call BattleRandom - and $7 + and SLP_MASK jr z, .setSleepCounter ld b, a ld a, [wUnknownSerialFlag_d499] @@ -250,7 +250,7 @@ FreezeBurnParalyzeEffect: jr z, .burn1 cp FREEZE_SIDE_EFFECT1 jr z, .freeze1 -; .paralyze1 +; paralyze1 ld a, 1 << PAR ld [wEnemyMonStatus], a call QuarterSpeedDueToParalysis ; quarter speed of affected mon @@ -313,7 +313,7 @@ FreezeBurnParalyzeEffect: jr z, .burn2 cp FREEZE_SIDE_EFFECT1 jr z, .freeze2 -; .paralyze2 +; paralyze2 ld a, 1 << PAR ld [wBattleMonStatus], a call QuarterSpeedDueToParalysis @@ -359,7 +359,7 @@ CheckDefrost: ld [wEnemyMonStatus], a ; set opponent status to 00 ["defrost" a frozen monster] ld hl, wEnemyMon1Status ld a, [wEnemyMonPartyPos] - ld bc, wEnemyMon2 - wEnemyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes xor a ld [hl], a ; clear status in roster @@ -372,7 +372,7 @@ CheckDefrost: ld [wBattleMonStatus], a ld hl, wPartyMon1Status ld a, [wPlayerMonNumber] - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes xor a ld [hl], a @@ -629,7 +629,7 @@ StatModifierDownEffect: ld a, [de] cp ATTACK_DOWN2_EFFECT - $16 ; $24 jr c, .ok - cp EVASION_DOWN2_EFFECT + $5 ; $44 + cp ATTACK_DOWN_SIDE_EFFECT ; move side effects, stat mod decrease is always 1 jr nc, .ok dec b ; stat down 2 effects only (dec mod again) jr nz, .ok @@ -722,7 +722,7 @@ UpdateLoweredStatDone: .ApplyBadgeBoostsAndStatusPenalties ldh a, [hWhoseTurn] and a - call nz, ApplyBadgeStatBoosts ; whenever the player uses a stat-down move, badge boosts get reapplied again to every stat, + call nz, ApplyBadgeStatBoosts ; whenever the opponent uses a stat-down move, badge boosts get reapplied again to every stat, ; even to those not affected by the stat-down move (will be boosted further) ld hl, MonsStatsFellText call PrintText @@ -747,7 +747,7 @@ CantLowerAnymore: MoveMissed: ld a, [de] - cp $44 + cp ATTACK_DOWN_SIDE_EFFECT ret nc jp ConditionalPrintButItFailed @@ -790,7 +790,7 @@ PrintStatText: jr .findStatName_inner .foundStatName ld de, wStringBuffer - ld bc, $a + ld bc, STAT_NAME_LENGTH jp CopyData INCLUDE "data/battle/stat_mod_names.asm" @@ -1377,7 +1377,7 @@ DisableEffect: cp LINK_STATE_BATTLING pop hl ; wEnemyMonMoves jr nz, .playerTurnNotLinkBattle -; .playerTurnLinkBattle +; player's turn, Link Battle push hl ld hl, wEnemyMonPP .enemyTurn @@ -1512,6 +1512,7 @@ PlayCurrentMoveAnimation2: .notEnemyTurn and a ret z +; fallthrough PlayBattleAnimation2: ; play animation ID at a and animation type 6 or 3 @@ -1538,6 +1539,7 @@ PlayCurrentMoveAnimation: .notEnemyTurn and a ret z +; fallthrough PlayBattleAnimation: ; play animation ID at a and predefined animation type diff --git a/engine/battle/end_of_battle.asm b/engine/battle/end_of_battle.asm index 53946250..2ae3f71f 100644 --- a/engine/battle/end_of_battle.asm +++ b/engine/battle/end_of_battle.asm @@ -5,7 +5,7 @@ EndOfBattle: ; link battle ld a, [wEnemyMonPartyPos] ld hl, wEnemyMon1Status - ld bc, wEnemyMon2 - wEnemyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld a, [wEnemyMonStatus] ld [hl], a @@ -64,8 +64,8 @@ EndOfBattle: ld [hli], a ld [hl], a ld [wListScrollOffset], a - ld hl, wPlayerStatsToDouble - ld b, $18 + ld hl, wBattleStatusData + ld b, wBattleStatusDataEnd - wBattleStatusData .loop ld [hli], a dec b diff --git a/engine/battle/experience.asm b/engine/battle/experience.asm index 32afc017..55d8d782 100644 --- a/engine/battle/experience.asm +++ b/engine/battle/experience.asm @@ -21,7 +21,7 @@ GainExperience: and a ; is mon's gain exp flag set? pop hl jp z, .nextMon ; if mon's gain exp flag not set, go to next mon - ld de, (wPartyMon1HPExp + 1) - (wPartyMon1HP + 1) + ld de, (MON_HP_EXP + 1) - (MON_HP + 1) add hl, de ld d, h ld e, l @@ -66,9 +66,9 @@ GainExperience: ldh [hDivisor], a ld b, 4 call Divide - ld hl, wPartyMon1OTID - (wPartyMon1DVs - 1) + ld hl, MON_OTID - (MON_DVS - 1) add hl, de - ld b, [hl] ; party mon OTID + ld b, [hl] ; wPartyMon*OTID inc hl ld a, [wPlayerID] cp b @@ -152,7 +152,7 @@ GainExperience: ld [wMonDataLocation], a call LoadMonData pop hl - ld bc, wPartyMon1Level - wPartyMon1Exp + ld bc, MON_LEVEL - MON_EXP add hl, bc push hl farcall CalcLevelFromExperience @@ -166,13 +166,13 @@ GainExperience: ld a, d ld [wCurEnemyLevel], a ld [hl], a - ld bc, wPartyMon1Species - wPartyMon1Level + ld bc, MON_SPECIES - MON_LEVEL add hl, bc ld a, [hl] ld [wCurSpecies], a ld [wPokedexNum], a call GetMonHeader - ld bc, (wPartyMon1MaxHP + 1) - wPartyMon1Species + ld bc, (MON_MAXHP + 1) - MON_SPECIES add hl, bc push hl ld a, [hld] @@ -181,7 +181,7 @@ GainExperience: push bc ; push max HP (from before levelling up) ld d, h ld e, l - ld bc, (wPartyMon1HPExp - 1) - wPartyMon1MaxHP + ld bc, (MON_HP_EXP - 1) - MON_MAXHP add hl, bc ld b, $1 ; consider stat exp when calculating stats call CalcStats @@ -193,15 +193,15 @@ GainExperience: ld a, [hl] sbc b ld b, a ; bc = difference between old max HP and new max HP after levelling - ld de, (wPartyMon1HP + 1) - wPartyMon1MaxHP + ld de, (MON_HP + 1) - MON_MAXHP add hl, de ; add to the current HP the amount of max HP gained when levelling - ld a, [hl] ; wPartyMon1HP + 1 + ld a, [hl] ; wPartyMon*HP + 1 add c ld [hld], a - ld a, [hl] ; wPartyMon1HP + 1 + ld a, [hl] ; wPartyMon*HP + 1 adc b - ld [hl], a ; wPartyMon1HP + ld [hl], a ; wPartyMon*HP ld a, [wPlayerMonNumber] ld b, a ld a, [wWhichPokemon] @@ -216,7 +216,7 @@ GainExperience: ld a, [hl] ld [de], a ; copy other stats from party mon to battle mon - ld bc, wPartyMon1Level - (wPartyMon1HP + 1) + ld bc, MON_LEVEL - (MON_HP + 1) add hl, bc push hl ld de, wBattleMonLevel @@ -251,7 +251,7 @@ GainExperience: xor a ; PLAYER_PARTY_DATA ld [wMonDataLocation], a call LoadMonData - ld d, $1 + ld d, LEVEL_UP_STATS_BOX callfar PrintStatsBox call WaitForTextScrollButtonPress call LoadScreenTilesFromBuffer1 @@ -277,7 +277,7 @@ GainExperience: cp b jr z, .done ld [wWhichPokemon], a - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH ld hl, wPartyMon1 call AddNTimes jp .partyMonLoop diff --git a/engine/battle/get_trainer_name.asm b/engine/battle/get_trainer_name.asm index a0e869fc..1983b08a 100644 --- a/engine/battle/get_trainer_name.asm +++ b/engine/battle/get_trainer_name.asm @@ -20,5 +20,5 @@ GetTrainerName_:: ld hl, wNameBuffer .foundName ld de, wTrainerName - ld bc, ITEM_NAME_LENGTH + ld bc, TRAINER_NAME_LENGTH jp CopyData diff --git a/engine/battle/ghost_marowak_anim.asm b/engine/battle/ghost_marowak_anim.asm index 6514ccaa..ab5f9017 100644 --- a/engine/battle/ghost_marowak_anim.asm +++ b/engine/battle/ghost_marowak_anim.asm @@ -51,11 +51,11 @@ MarowakAnim: call Delay3 jp ClearSprites -; copies a mon pic's from background VRAM to sprite VRAM and sets up OAM +; copies a mon pic's from background VRAM to sprite VRAM and sets up OAM CopyMonPicFromBGToSpriteVRAM: ld de, vFrontPic ld hl, vSprites - ld bc, 7 * 7 + ld bc, PIC_SIZE call CopyVideoData ld a, $10 ld [wBaseCoordY], a diff --git a/engine/battle/init_battle.asm b/engine/battle/init_battle.asm index a291880c..15dbb3d1 100644 --- a/engine/battle/init_battle.asm +++ b/engine/battle/init_battle.asm @@ -76,17 +76,7 @@ InitWildBattle: ld [hli], a ; write front sprite pointer ld [hl], b ld hl, wEnemyMonNick ; set name to "GHOST" - ld a, 'G' - ld [hli], a - ld a, 'H' - ld [hli], a - ld a, 'O' - ld [hli], a - ld a, 'S' - ld [hli], a - ld a, 'T' - ld [hli], a - ld [hl], '@' + ld_hli_a_string "GHOST@" ld a, [wCurPartySpecies] push af ld a, MON_GHOST diff --git a/engine/battle/link_battle_versus_text.asm b/engine/battle/link_battle_versus_text.asm index e5dd42ea..40c1aad9 100644 --- a/engine/battle/link_battle_versus_text.asm +++ b/engine/battle/link_battle_versus_text.asm @@ -12,9 +12,7 @@ DisplayLinkBattleVersusTextBox: call PlaceString ; place bold "VS" tiles between the names hlcoord 9, 8 - ld a, '<BOLD_V>' - ld [hli], a - ld [hl], '<BOLD_S>' + ld_hli_a_string "<BOLD_V><BOLD_S>" xor a ld [wUpdateSpritesEnabled], a callfar SetupPlayerAndEnemyPokeballs diff --git a/engine/battle/move_effects/haze.asm b/engine/battle/move_effects/haze.asm index 76722d0e..0f89ad19 100644 --- a/engine/battle/move_effects/haze.asm +++ b/engine/battle/move_effects/haze.asm @@ -59,7 +59,7 @@ CureVolatileStatuses: ret ResetStatMods: - ld b, $8 + ld b, NUM_STAT_MODS .loop ld [hli], a dec b @@ -67,7 +67,7 @@ ResetStatMods: ret ResetStats: - ld b, $8 + ld b, (NUM_STATS - 1) * 2 ; doesn't reset STAT_HEALTH .loop ld a, [hli] ld [de], a diff --git a/engine/battle/move_effects/substitute.asm b/engine/battle/move_effects/substitute.asm index e4311209..01d5a8a3 100644 --- a/engine/battle/move_effects/substitute.asm +++ b/engine/battle/move_effects/substitute.asm @@ -37,8 +37,8 @@ SubstituteEffect_: sbc 0 pop bc jr c, .notEnoughHP ; underflow means user would be left with negative health - ; bug: since it only branches on carry, it will possibly leave user with 0 HP -.userHasZeroOrMoreHP + ; bug: since it only branches on carry, it will possibly leave user with 0 HP +; user has 0 or more HP ld [hli], a ; save resulting HP after subtraction into current HP ld [hl], d ld h, b diff --git a/engine/battle/move_effects/transform.asm b/engine/battle/move_effects/transform.asm index 775816c7..e8bafe04 100644 --- a/engine/battle/move_effects/transform.asm +++ b/engine/battle/move_effects/transform.asm @@ -2,17 +2,22 @@ TransformEffect_: ld hl, wBattleMonSpecies ld de, wEnemyMonSpecies ld bc, wEnemyBattleStatus3 + ; bug: on enemy's turn, a is overloaded with hWhoseTurn, + ; before the check for INVULNERABLE ld a, [wEnemyBattleStatus1] ldh a, [hWhoseTurn] and a jr nz, .hitTest +; player's turn ld hl, wEnemyMonSpecies ld de, wBattleMonSpecies ld bc, wPlayerBattleStatus3 ld [wPlayerMoveListIndex], a + ; bug: this should be target's BattleStatus1 (i.e. wEnemyBattleStatus1) ld a, [wPlayerBattleStatus1] .hitTest bit INVULNERABLE, a ; is mon invulnerable to typical attacks? (fly/dig) + ; this check doesn't work due to above bugs jp nz, .failed push hl push de @@ -82,14 +87,15 @@ TransformEffect_: ld a, [hli] ld [de], a inc de -; Attack, Defense, Speed, and Special stats +; Skip level and max HP inc hl inc hl inc hl inc de inc de inc de - ld bc, $8 +; Attack, Defense, Speed, and Special stats + ld bc, (NUM_STATS - 1) * 2 call CopyData ld bc, wBattleMonMoves - wBattleMonPP add hl, bc ; ld hl, wBattleMonMoves @@ -99,7 +105,7 @@ TransformEffect_: ld a, [hli] and a jr z, .lessThanFourMoves - ld a, $5 + ld a, 5 .lessThanFourMoves ld [de], a inc de @@ -129,7 +135,7 @@ TransformEffect_: ld l, e pop de .gotStatsOrModsToCopy - ld bc, $8 + ld bc, (NUM_STATS - 1) * 2 jp CopyData .failed diff --git a/engine/battle/read_trainer_party.asm b/engine/battle/read_trainer_party.asm index c8ee8fda..f4a2bef9 100644 --- a/engine/battle/read_trainer_party.asm +++ b/engine/battle/read_trainer_party.asm @@ -103,7 +103,7 @@ ReadTrainer: jp z, .FinishUp dec a ld hl, wEnemyMon1Moves - ld bc, wEnemyMon2 - wEnemyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld a, [de] inc de diff --git a/engine/battle/trainer_ai.asm b/engine/battle/trainer_ai.asm index 7081fdfd..d97ee076 100644 --- a/engine/battle/trainer_ai.asm +++ b/engine/battle/trainer_ai.asm @@ -578,7 +578,7 @@ AISwitchIfEnoughMons: inc d .Fainted push bc - ld bc, wEnemyMon2 - wEnemyMon1 + ld bc, PARTYMON_STRUCT_LENGTH add hl, bc pop bc dec c @@ -592,16 +592,16 @@ AISwitchIfEnoughMons: SwitchEnemyMon: -; prepare to withdraw the active monster: copy hp, number, and status to roster +; prepare to withdraw the active monster: copy HP, party pos, and status to roster ld a, [wEnemyMonPartyPos] ld hl, wEnemyMon1HP - ld bc, wEnemyMon2 - wEnemyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld d, h ld e, l ld hl, wEnemyMonHP - ld bc, 4 + ld bc, MON_STATUS + 1 - MON_HP ; also copies party pos in-between HP and status call CopyData ld hl, AIBattleWithdrawText @@ -635,7 +635,7 @@ AICureStatus: ; cures the status of enemy's active pokemon ld a, [wEnemyMonPartyPos] ld hl, wEnemyMon1Status - ld bc, wEnemyMon2 - wEnemyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes xor a ld [hl], a ; clear status in enemy team roster diff --git a/engine/battle/used_move_text.asm b/engine/battle/used_move_text.asm new file mode 100644 index 00000000..abb35e67 --- /dev/null +++ b/engine/battle/used_move_text.asm @@ -0,0 +1,139 @@ +DisplayUsedMoveText: + ld hl, UsedMoveText + jp PrintText + +UsedMoveText: + text_far _ActorNameText + text_asm + + ldh a, [hWhoseTurn] + and a + ld a, [wPlayerMoveNum] + ld hl, wPlayerUsedMove + jr z, .playerTurn + + ld a, [wEnemyMoveNum] + ld hl, wEnemyUsedMove + +.playerTurn + ld [hl], a + ld [wMoveGrammar], a + call GetMoveGrammar + ld a, [wMonIsDisobedient] + and a + ld hl, UsedMove2Text + ret nz + + ; check move grammar + ld a, [wMoveGrammar] + cp $3 + ld hl, UsedMove2Text + ret c + ld hl, UsedMove1Text + ret + +UsedMove1Text: + text_far _UsedMove1Text + text_asm + jr UsedMoveText_CheckObedience + +UsedMove2Text: + text_far _UsedMove2Text + text_asm + ; fall through + +UsedMoveText_CheckObedience: +; check obedience + ld a, [wMonIsDisobedient] + and a + jr z, .GetMoveNameText +; print "instead," + ld hl, .UsedInsteadText + ret + +.UsedInsteadText: + text_far _UsedInsteadText + text_asm + ; fall through + +.GetMoveNameText: + ld hl, MoveNameText + ret + +MoveNameText: + text_far _MoveNameText + text_asm + ld hl, .endusedmovetexts + ld a, [wMoveGrammar] + add a + push bc + ld b, $0 + ld c, a + add hl, bc + pop bc + ld a, [hli] + ld h, [hl] + ld l, a + ret + +.endusedmovetexts: +; entries correspond to MoveGrammar sets + dw EndUsedMove1Text + dw EndUsedMove2Text + dw EndUsedMove3Text + dw EndUsedMove4Text + dw EndUsedMove5Text + +EndUsedMove1Text: + text_far _EndUsedMove1Text + text_end + +EndUsedMove2Text: + text_far _EndUsedMove2Text + text_end + +EndUsedMove3Text: + text_far _EndUsedMove3Text + text_end + +EndUsedMove4Text: + text_far _EndUsedMove4Text + text_end + +EndUsedMove5Text: + text_far _EndUsedMove5Text + text_end + +; This function is redundant in the English localization. +; In Japanese, it selects one of 5 distinct sentence structures. +; In English, all of these sentences have the exact same structure, +; so this serves no purpose. +GetMoveGrammar: + push bc + ld a, [wMoveGrammar] ; move ID + ld c, a + ld b, $0 + ld hl, MoveGrammar +.loop + ld a, [hli] +; end of table? + cp -1 + jr z, .end +; match? + cp c + jr z, .end +; advance grammar type at 0 + and a + jr nz, .loop +; next grammar type + inc b + jr .loop + +.end +; wMoveGrammar now contains move grammar + ld a, b + ld [wMoveGrammar], a + pop bc + ret + +INCLUDE "data/moves/grammar.asm" diff --git a/engine/events/heal_party.asm b/engine/events/heal_party.asm index e6551bcd..5532fd92 100644 --- a/engine/events/heal_party.asm +++ b/engine/events/heal_party.asm @@ -11,7 +11,7 @@ HealParty: push hl push de - ld hl, wPartyMon1Status - wPartyMon1HP + ld hl, MON_STATUS - MON_HP add hl, de xor a ld [hl], a @@ -19,7 +19,7 @@ HealParty: push de ld b, NUM_MOVES ; A Pokémon has 4 moves .pp - ld hl, wPartyMon1Moves - wPartyMon1HP + ld hl, MON_MOVES - MON_HP add hl, de ld a, [hl] @@ -27,7 +27,7 @@ HealParty: jr z, .nextmove dec a - ld hl, wPartyMon1PP - wPartyMon1HP + ld hl, MON_PP - MON_HP add hl, de push hl @@ -60,7 +60,7 @@ HealParty: jr nz, .pp pop de - ld hl, wPartyMon1MaxHP - wPartyMon1HP + ld hl, MON_MAXHP - MON_HP add hl, de ld a, [hli] ld [de], a @@ -72,7 +72,7 @@ HealParty: pop hl push hl - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH ld h, d ld l, e add hl, bc diff --git a/engine/events/hidden_objects/bench_guys.asm b/engine/events/hidden_events/bench_guys.asm index 81519f2f..81519f2f 100644 --- a/engine/events/hidden_objects/bench_guys.asm +++ b/engine/events/hidden_events/bench_guys.asm diff --git a/engine/events/hidden_objects/bills_house_pc.asm b/engine/events/hidden_events/bills_house_pc.asm index fefb66dd..fefb66dd 100644 --- a/engine/events/hidden_objects/bills_house_pc.asm +++ b/engine/events/hidden_events/bills_house_pc.asm diff --git a/engine/events/hidden_objects/blues_room.asm b/engine/events/hidden_events/blues_room.asm index bcbad556..bcbad556 100644 --- a/engine/events/hidden_objects/blues_room.asm +++ b/engine/events/hidden_events/blues_room.asm diff --git a/engine/events/hidden_objects/book_or_sculpture.asm b/engine/events/hidden_events/book_or_sculpture.asm index e04f4047..e04f4047 100644 --- a/engine/events/hidden_objects/book_or_sculpture.asm +++ b/engine/events/hidden_events/book_or_sculpture.asm diff --git a/engine/events/hidden_objects/bookshelves.asm b/engine/events/hidden_events/bookshelves.asm index 813cfc49..813cfc49 100644 --- a/engine/events/hidden_objects/bookshelves.asm +++ b/engine/events/hidden_events/bookshelves.asm diff --git a/engine/events/hidden_objects/cinnabar_gym_quiz.asm b/engine/events/hidden_events/cinnabar_gym_quiz.asm index da280345..c76a97c8 100644 --- a/engine/events/hidden_objects/cinnabar_gym_quiz.asm +++ b/engine/events/hidden_events/cinnabar_gym_quiz.asm @@ -11,7 +11,7 @@ CinnabarGymQuiz:: ld [wOpponentAfterWrongAnswer], a ld hl, wd474 res 7, [hl] - ld a, [wHiddenObjectFunctionArgument] + ld a, [wHiddenEventFunctionArgument] push af and $f ldh [hGymGateIndex], a diff --git a/engine/events/hidden_objects/elevator.asm b/engine/events/hidden_events/elevator.asm index ab0f731f..ab0f731f 100644 --- a/engine/events/hidden_objects/elevator.asm +++ b/engine/events/hidden_events/elevator.asm diff --git a/engine/events/hidden_objects/fanclub_pictures.asm b/engine/events/hidden_events/fanclub_pictures.asm index 2a3db4bc..2a3db4bc 100644 --- a/engine/events/hidden_objects/fanclub_pictures.asm +++ b/engine/events/hidden_events/fanclub_pictures.asm diff --git a/engine/events/hidden_objects/fighting_dojo.asm b/engine/events/hidden_events/fighting_dojo.asm index b4f89985..b4f89985 100644 --- a/engine/events/hidden_objects/fighting_dojo.asm +++ b/engine/events/hidden_events/fighting_dojo.asm diff --git a/engine/events/hidden_objects/gym_statues.asm b/engine/events/hidden_events/gym_statues.asm index 1c7eb970..1c7eb970 100644 --- a/engine/events/hidden_objects/gym_statues.asm +++ b/engine/events/hidden_events/gym_statues.asm diff --git a/engine/events/hidden_objects/indigo_plateau_hq.asm b/engine/events/hidden_events/indigo_plateau_hq.asm index e8fd0220..e8fd0220 100644 --- a/engine/events/hidden_objects/indigo_plateau_hq.asm +++ b/engine/events/hidden_events/indigo_plateau_hq.asm diff --git a/engine/events/hidden_objects/indigo_plateau_statues.asm b/engine/events/hidden_events/indigo_plateau_statues.asm index f78a5a72..f78a5a72 100644 --- a/engine/events/hidden_objects/indigo_plateau_statues.asm +++ b/engine/events/hidden_events/indigo_plateau_statues.asm diff --git a/engine/events/hidden_objects/magazines.asm b/engine/events/hidden_events/magazines.asm index b58636ff..b58636ff 100644 --- a/engine/events/hidden_objects/magazines.asm +++ b/engine/events/hidden_events/magazines.asm diff --git a/engine/events/hidden_objects/museum_fossils.asm b/engine/events/hidden_events/museum_fossils.asm index 9e02aeba..9e02aeba 100644 --- a/engine/events/hidden_objects/museum_fossils.asm +++ b/engine/events/hidden_events/museum_fossils.asm diff --git a/engine/events/hidden_objects/museum_fossils2.asm b/engine/events/hidden_events/museum_fossils2.asm index 240b7ece..240b7ece 100644 --- a/engine/events/hidden_objects/museum_fossils2.asm +++ b/engine/events/hidden_events/museum_fossils2.asm diff --git a/engine/events/hidden_objects/new_bike.asm b/engine/events/hidden_events/new_bike.asm index 5bce5937..5bce5937 100644 --- a/engine/events/hidden_objects/new_bike.asm +++ b/engine/events/hidden_events/new_bike.asm diff --git a/engine/events/hidden_objects/oaks_lab_email.asm b/engine/events/hidden_events/oaks_lab_email.asm index bd4c66d7..bd4c66d7 100644 --- a/engine/events/hidden_objects/oaks_lab_email.asm +++ b/engine/events/hidden_events/oaks_lab_email.asm diff --git a/engine/events/hidden_objects/oaks_lab_posters.asm b/engine/events/hidden_events/oaks_lab_posters.asm index 502cf951..502cf951 100644 --- a/engine/events/hidden_objects/oaks_lab_posters.asm +++ b/engine/events/hidden_events/oaks_lab_posters.asm diff --git a/engine/events/hidden_objects/pokecenter_pc.asm b/engine/events/hidden_events/pokecenter_pc.asm index 59867d1a..59867d1a 100644 --- a/engine/events/hidden_objects/pokecenter_pc.asm +++ b/engine/events/hidden_events/pokecenter_pc.asm diff --git a/engine/events/hidden_objects/pokemon_stuff.asm b/engine/events/hidden_events/pokemon_stuff.asm index 267a191a..267a191a 100644 --- a/engine/events/hidden_objects/pokemon_stuff.asm +++ b/engine/events/hidden_events/pokemon_stuff.asm diff --git a/engine/events/hidden_objects/reds_room.asm b/engine/events/hidden_events/reds_room.asm index 7b8d51a0..7b8d51a0 100644 --- a/engine/events/hidden_objects/reds_room.asm +++ b/engine/events/hidden_events/reds_room.asm diff --git a/engine/events/hidden_objects/route_15_binoculars.asm b/engine/events/hidden_events/route_15_binoculars.asm index a9b8ca37..a9b8ca37 100644 --- a/engine/events/hidden_objects/route_15_binoculars.asm +++ b/engine/events/hidden_events/route_15_binoculars.asm diff --git a/engine/events/hidden_objects/safari_game.asm b/engine/events/hidden_events/safari_game.asm index 7fd59ea9..7fd59ea9 100644 --- a/engine/events/hidden_objects/safari_game.asm +++ b/engine/events/hidden_events/safari_game.asm diff --git a/engine/events/hidden_objects/school_blackboard.asm b/engine/events/hidden_events/school_blackboard.asm index 75811035..23022398 100644 --- a/engine/events/hidden_objects/school_blackboard.asm +++ b/engine/events/hidden_events/school_blackboard.asm @@ -2,7 +2,7 @@ PrintBlackboardLinkCableText: call EnableAutoTextBoxDrawing ld a, $1 ld [wDoNotWaitForButtonPressAfterDisplayingText], a - ld a, [wHiddenObjectFunctionArgument] + ld a, [wHiddenEventFunctionArgument] call PrintPredefTextID ret diff --git a/engine/events/hidden_objects/school_notebooks.asm b/engine/events/hidden_events/school_notebooks.asm index 96a44ab5..2387c089 100644 --- a/engine/events/hidden_objects/school_notebooks.asm +++ b/engine/events/hidden_events/school_notebooks.asm @@ -2,7 +2,7 @@ PrintNotebookText: call EnableAutoTextBoxDrawing ld a, $1 ld [wDoNotWaitForButtonPressAfterDisplayingText], a - ld a, [wHiddenObjectFunctionArgument] + ld a, [wHiddenEventFunctionArgument] jp PrintPredefTextID TMNotebook:: diff --git a/engine/events/hidden_objects/town_map.asm b/engine/events/hidden_events/town_map.asm index 11f7cbc7..11f7cbc7 100644 --- a/engine/events/hidden_objects/town_map.asm +++ b/engine/events/hidden_events/town_map.asm diff --git a/engine/events/hidden_objects/vermilion_gym_trash.asm b/engine/events/hidden_events/vermilion_gym_trash.asm index 5f13a0e4..e83bef51 100644 --- a/engine/events/hidden_objects/vermilion_gym_trash.asm +++ b/engine/events/hidden_events/vermilion_gym_trash.asm @@ -8,7 +8,7 @@ VermilionGymTrashText:: GymTrashScript: call EnableAutoTextBoxDrawing - ld a, [wHiddenObjectFunctionArgument] + ld a, [wHiddenEventFunctionArgument] ld [wGymTrashCanIndex], a ; Don't do the trash can puzzle if it's already been done. diff --git a/engine/events/hidden_objects/vermilion_gym_trash2.asm b/engine/events/hidden_events/vermilion_gym_trash2.asm index 1bc0590b..1bc0590b 100644 --- a/engine/events/hidden_objects/vermilion_gym_trash2.asm +++ b/engine/events/hidden_events/vermilion_gym_trash2.asm diff --git a/engine/events/hidden_items.asm b/engine/events/hidden_items.asm index 62c40ce4..3ce8b716 100644 --- a/engine/events/hidden_items.asm +++ b/engine/events/hidden_items.asm @@ -13,7 +13,7 @@ HiddenItems: call EnableAutoTextBoxDrawing ld a, 1 ld [wDoNotWaitForButtonPressAfterDisplayingText], a - ld a, [wHiddenObjectFunctionArgument] ; item ID + ld a, [wHiddenEventFunctionArgument] ; item ID ld [wNamedObjectIndex], a call GetItemName tx_pre_jump FoundHiddenItemText @@ -28,7 +28,7 @@ INCLUDE "data/events/hidden_item_coords.asm" FoundHiddenItemText:: text_far _FoundHiddenItemText text_asm - ld a, [wHiddenObjectFunctionArgument] ; item ID + ld a, [wHiddenEventFunctionArgument] ; item ID ld b, a ld c, 1 call GiveItem @@ -75,7 +75,7 @@ HiddenCoins: ldh [hUnusedCoinsByte], a ldh [hCoins], a ldh [hCoins + 1], a - ld a, [wHiddenObjectFunctionArgument] + ld a, [wHiddenEventFunctionArgument] sub COIN cp 10 jr z, .bcd10 @@ -143,9 +143,9 @@ DroppedHiddenCoinsText:: text_end FindHiddenItemOrCoinsIndex: - ld a, [wHiddenObjectY] + ld a, [wHiddenEventY] ld d, a - ld a, [wHiddenObjectX] + ld a, [wHiddenEventX] ld e, a ld a, [wCurMap] ld b, a diff --git a/engine/events/in_game_trades.asm b/engine/events/in_game_trades.asm index 8c5f4e5c..fab80ada 100644 --- a/engine/events/in_game_trades.asm +++ b/engine/events/in_game_trades.asm @@ -106,7 +106,7 @@ InGameTrade_DoTrade: jr nz, .tradeFailed ; jump if the selected mon's species is not the required one ld a, [wWhichPokemon] ld hl, wPartyMon1Level - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld a, [hl] ld [wCurEnemyLevel], a @@ -178,7 +178,7 @@ InGameTrade_PrepareTradeData: ld de, wLinkEnemyTrainerName call InGameTrade_CopyData ld hl, wPartyMon1OTID - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH ld a, [wWhichPokemon] call AddNTimes ld de, wTradedPlayerMonOTID @@ -211,10 +211,10 @@ InGameTrade_CopyDataToReceivedMon: ld bc, NAME_LENGTH call CopyData ld hl, wPartyMon1OTID - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call InGameTrade_GetReceivedMonPointer ld hl, wTradedEnemyMonOTID - ld bc, $2 + ld bc, 2 jp CopyData ; the received mon's index is (partyCount - 1), diff --git a/engine/events/pick_up_item.asm b/engine/events/pick_up_item.asm index 8fbdcfa2..a55c604a 100644 --- a/engine/events/pick_up_item.asm +++ b/engine/events/pick_up_item.asm @@ -3,19 +3,19 @@ PickUpItem: ldh a, [hSpriteIndex] ld b, a - ld hl, wMissableObjectList -.missableObjectsListLoop + ld hl, wToggleableObjectList +.toggleableObjectsListLoop ld a, [hli] cp $ff ret z cp b - jr z, .isMissable + jr z, .isToggleable inc hl - jr .missableObjectsListLoop + jr .toggleableObjectsListLoop -.isMissable +.isToggleable ld a, [hl] - ldh [hMissableObjectIndex], a + ldh [hToggleableObjectIndex], a ld hl, wMapSpriteExtraData ldh a, [hSpriteIndex] @@ -30,8 +30,8 @@ PickUpItem: call GiveItem jr nc, .BagFull - ldh a, [hMissableObjectIndex] - ld [wMissableObjectIndex], a + ldh a, [hToggleableObjectIndex] + ld [wToggleableObjectIndex], a predef HideObject ld a, 1 ld [wDoNotWaitForButtonPressAfterDisplayingText], a diff --git a/engine/events/poison.asm b/engine/events/poison.asm index 6dfe1376..3a26df8f 100644 --- a/engine/events/poison.asm +++ b/engine/events/poison.asm @@ -78,7 +78,7 @@ ApplyOutOfBattlePoisonDamage: ld a, [de] inc a jr z, .applyDamageLoopDone - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH add hl, bc push hl ld hl, wWhichPokemon @@ -95,7 +95,7 @@ ApplyOutOfBattlePoisonDamage: and 1 << PSN or e ld e, a - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH add hl, bc dec d jr nz, .countPoisonedLoop diff --git a/engine/events/pokemart.asm b/engine/events/pokemart.asm index b280c711..cb25ab4c 100644 --- a/engine/events/pokemart.asm +++ b/engine/events/pokemart.asm @@ -99,7 +99,7 @@ DisplayPokemartDialogue_:: dec a jr z, .sellMenuLoop -.sellItem +; sell item ld a, [wBoughtOrSoldItemInMart] and a jr nz, .skipSettingFlag1 @@ -177,7 +177,7 @@ DisplayPokemartDialogue_:: dec a jr z, .buyMenuLoop -.buyItem +; buy item call .isThereEnoughMoney jr c, .notEnoughMoney ld hl, wNumBagItems diff --git a/engine/events/prize_menu.asm b/engine/events/prize_menu.asm index 16ada216..8f25f272 100644 --- a/engine/events/prize_menu.asm +++ b/engine/events/prize_menu.asm @@ -196,7 +196,7 @@ HandlePrizeChoice: .getMonName call GetMonName .givePrize - ld hl, SoYouWantPrizeTextPtr + ld hl, SoYouWantPrizeText call PrintText call YesNoChoice ld a, [wCurrentMenuItem] ; yes/no answer (Y=0, N=1) @@ -244,25 +244,25 @@ HandlePrizeChoice: predef SubBCDPredef jp PrintPrizePrice .bagFull - ld hl, PrizeRoomBagIsFullTextPtr + ld hl, PrizeRoomBagIsFullText jp PrintText .notEnoughCoins ld hl, SorryNeedMoreCoinsText jp PrintText .printOhFineThen - ld hl, OhFineThenTextPtr + ld hl, OhFineThenText jp PrintText UnknownPrizeData: ; XXX what's this? db $00,$01,$00,$01,$00,$01,$00,$00,$01 -HereYouGoTextPtr: +HereYouGoText: ; unreferenced text_far _HereYouGoText text_waitbutton text_end -SoYouWantPrizeTextPtr: +SoYouWantPrizeText: text_far _SoYouWantPrizeText text_end @@ -271,12 +271,12 @@ SorryNeedMoreCoinsText: text_waitbutton text_end -PrizeRoomBagIsFullTextPtr: +PrizeRoomBagIsFullText: text_far _OopsYouDontHaveEnoughRoomText text_waitbutton text_end -OhFineThenTextPtr: +OhFineThenText: text_far _OhFineThenText text_waitbutton text_end diff --git a/engine/flag_action.asm b/engine/flag_action.asm index dc516887..150bebab 100644 --- a/engine/flag_action.asm +++ b/engine/flag_action.asm @@ -43,10 +43,10 @@ FlagAction: ld a, b and a jr z, .reset - cp 2 + cp FLAG_TEST jr z, .read -.set +; set ld b, [hl] ld a, d or b diff --git a/engine/gfx/load_pokedex_tiles.asm b/engine/gfx/load_pokedex_tiles.asm index a3f69171..b0857137 100644 --- a/engine/gfx/load_pokedex_tiles.asm +++ b/engine/gfx/load_pokedex_tiles.asm @@ -3,7 +3,7 @@ LoadPokedexTilePatterns: call LoadHpBarAndStatusTilePatterns ld de, PokedexTileGraphics ld hl, vChars2 tile $60 - lb bc, BANK(PokedexTileGraphics), (PokedexTileGraphicsEnd - PokedexTileGraphics) / $10 + lb bc, BANK(PokedexTileGraphics), (PokedexTileGraphicsEnd - PokedexTileGraphics) / TILE_SIZE call CopyVideoData ld de, PokeballTileGraphics ld hl, vChars2 tile $72 diff --git a/engine/gfx/mon_icons.asm b/engine/gfx/mon_icons.asm index 4cc11284..4775084f 100644 --- a/engine/gfx/mon_icons.asm +++ b/engine/gfx/mon_icons.asm @@ -44,7 +44,7 @@ GetAnimationSpeed: push bc ld hl, wMonPartySpritesSavedOAM ld de, wShadowOAM - ld bc, $60 + ld bc, OBJ_SIZE * 4 * PARTY_LENGTH call CopyData pop bc xor a @@ -52,7 +52,7 @@ GetAnimationSpeed: .animateSprite push bc ld hl, wShadowOAMSprite00TileID - ld bc, $10 + ld bc, OBJ_SIZE * 4 ld a, [wCurrentMenuItem] call AddNTimes ld c, ICONOFFSET @@ -68,8 +68,8 @@ GetAnimationSpeed: ld c, $1 ; amount to increase the y coord by ; otherwise, load a second sprite frame .editTileIDS - ld b, $4 - ld de, $4 + ld b, 4 + ld de, OBJ_SIZE .loop ld a, [hl] add c @@ -266,7 +266,7 @@ WriteMonPartySpriteOAM: .makeCopy ld hl, wShadowOAM ld de, wMonPartySpritesSavedOAM - ld bc, $60 + ld bc, OBJ_SIZE * 4 * PARTY_LENGTH jp CopyData GetPartyMonSpriteID: diff --git a/engine/gfx/palettes.asm b/engine/gfx/palettes.asm index e46c6715..359f235c 100644 --- a/engine/gfx/palettes.asm +++ b/engine/gfx/palettes.asm @@ -1071,7 +1071,7 @@ CopySGBBorderTiles: ld b, 128 .tileLoop ; Copy bit planes 1 and 2 of the tile data. - ld c, 16 + ld c, TILE_SIZE .copyLoop ld a, [hli] ld [de], a diff --git a/engine/gfx/sprite_oam.asm b/engine/gfx/sprite_oam.asm index a1549c6c..3b869394 100644 --- a/engine/gfx/sprite_oam.asm +++ b/engine/gfx/sprite_oam.asm @@ -141,12 +141,12 @@ PrepareOAMData:: .asm_4a41 ld a, [wMovementFlags] bit BIT_LEDGE_OR_FISHING, a - ld c, $a0 + ld c, LOW(wShadowOAMEnd) jr z, .clear ; Don't clear the last 4 entries because they are used for the shadow in the ; jumping down ledge animation and the rod in the fishing animation. - ld c, $90 + ld c, LOW(wShadowOAMSprite36) .clear ldh a, [hOAMBufferOffset] diff --git a/engine/items/inventory.asm b/engine/items/inventory.asm index 758c81d7..caa9dd22 100644 --- a/engine/items/inventory.asm +++ b/engine/items/inventory.asm @@ -119,7 +119,6 @@ RemoveItemFromInventory_:: jr nz, .skipMovingUpSlots ; if the remaining quantity is 0, ; remove the emptied item slot and move up all the following item slots -.moveSlotsUp ld e, l ld d, h inc de diff --git a/engine/items/item_effects.asm b/engine/items/item_effects.asm index 31684719..0cbb0c48 100644 --- a/engine/items/item_effects.asm +++ b/engine/items/item_effects.asm @@ -669,7 +669,7 @@ ItemUseBicycle: jp z, ItemUseNotTime dec a ; is player already bicycling? jr nz, .tryToGetOnBike -.getOffBike +; get off bike call ItemUseReloadOverworldData xor a ld [wWalkBikeSurfState], a ; change player state to walking @@ -702,13 +702,13 @@ ItemUseSurfboard: ld [wWalkBikeSurfStateCopy], a cp 2 ; is the player already surfing? jr z, .tryToStopSurfing -.tryToSurf +; try to Surf call IsNextTileShoreOrWater jp nc, SurfingAttemptFailed ld hl, TilePairCollisionsWater call CheckForTilePairCollisions jp c, SurfingAttemptFailed -.surf +; surfing call .makePlayerMoveForward ld hl, wStatusFlags5 set BIT_SCRIPTED_MOVEMENT_STATE, [hl] @@ -923,7 +923,7 @@ ItemUseMedicine: .getPartyMonDataAddress jp c, .canceledItemUse ld hl, wPartyMons - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH ld a, [wWhichPokemon] call AddNTimes ld a, [wWhichPokemon] @@ -965,7 +965,7 @@ ItemUseMedicine: jr nc, .healHP ; if it's a Full Restore or one of the potions ; fall through if it's one of the status-specific healing items .cureStatusAilment - ld bc, wPartyMon1Status - wPartyMon1 + ld bc, MON_STATUS add hl, bc ; hl now points to status ld a, [wCurItem] lb bc, ANTIDOTE_MSG, 1 << PSN @@ -1003,7 +1003,7 @@ ItemUseMedicine: ld hl, wPlayerBattleStatus3 res BADLY_POISONED, [hl] ; heal Toxic status pop hl - ld bc, wPartyMon1Stats - wPartyMon1Status + ld bc, MON_STATS - MON_STATUS add hl, bc ; hl now points to party stats ld de, wBattleMonStats ld bc, NUM_STATS * 2 @@ -1021,7 +1021,7 @@ ItemUseMedicine: ld [wHPBarOldHP], a ; current HP stored at wHPBarOldHP (2 bytes, big-endian) or b jr nz, .notFainted -.fainted +; fainted ld a, [wCurItem] cp REVIVE jr z, .updateInBattleFaintedData @@ -1078,7 +1078,7 @@ ItemUseMedicine: .compareCurrentHPToMaxHP push hl push bc - ld bc, wPartyMon1MaxHP - (wPartyMon1HP + 1) + ld bc, MON_MAXHP - (MON_HP + 1) add hl, bc ; hl now points to max HP pop bc ld a, [hli] @@ -1089,7 +1089,7 @@ ItemUseMedicine: .skipComparingLSB pop hl jr nz, .notFullHP -.fullHP ; if the pokemon's current HP equals its max HP +; if the pokemon's current HP equals its max HP ld a, [wCurItem] cp FULL_RESTORE jp nz, .healingItemNoEffect @@ -1111,7 +1111,7 @@ ItemUseMedicine: ld [wChannelSoundIDs + CHAN5], a push hl push de - ld bc, wPartyMon1MaxHP - (wPartyMon1HP + 1) + ld bc, MON_MAXHP - (MON_HP + 1) add hl, bc ; hl now points to max HP ld a, [hli] ld [wHPBarMaxHP+1], a @@ -1132,7 +1132,7 @@ ItemUseMedicine: push af ld hl, wPartyMon1MaxHP ld a, [wWhichPokemon] - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld a, [hli] ld [wHPBarMaxHP + 1], a @@ -1144,7 +1144,7 @@ ItemUseMedicine: ldh [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) + ld bc, (MON_HP + 1) - (MON_MAXHP + 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 ldh a, [hQuotient + 3] @@ -1224,7 +1224,7 @@ ItemUseMedicine: inc hl ld d, h ld e, l ; de now points to current HP - ld hl, (wPartyMon1MaxHP + 1) - (wPartyMon1HP + 1) + ld hl, (MON_MAXHP + 1) - (MON_HP + 1) add hl, de ; hl now points to max HP ld a, [wCurItem] cp REVIVE @@ -1273,7 +1273,7 @@ ItemUseMedicine: ld a, [wCurItem] cp FULL_RESTORE jr nz, .updateInBattleData - ld bc, wPartyMon1Status - (wPartyMon1MaxHP + 1) + ld bc, MON_STATUS - (MON_MAXHP + 1) add hl, bc xor a ld [hl], a ; remove the status ailment in the party data @@ -1381,7 +1381,7 @@ ItemUseMedicine: ld a, [hl] ld [wCurSpecies], a ld [wPokedexNum], a - ld bc, wPartyMon1Level - wPartyMon1 + ld bc, MON_LEVEL add hl, bc ; hl now points to level ld a, [hl] ; a = level ld [wCurEnemyLevel], a ; store level @@ -1398,7 +1398,7 @@ ItemUseMedicine: push hl sub HP_UP add a - ld bc, wPartyMon1HPExp - wPartyMon1 + ld bc, MON_HP_EXP add hl, bc add l ld l, a @@ -1427,14 +1427,14 @@ ItemUseMedicine: .statNameInnerLoop ld a, [hli] ld b, a - ld a, $50 + ld a, '@' cp b jr nz, .statNameInnerLoop jr .statNameLoop .gotStatName ld de, wStringBuffer - ld bc, 10 + ld bc, STAT_NAME_LENGTH call CopyData ; copy the stat's name to wStringBuffer ld a, SFX_HEAL_AILMENT call PlaySound @@ -1449,17 +1449,17 @@ ItemUseMedicine: jp GBPalWhiteOut .recalculateStats - ld bc, wPartyMon1Stats - wPartyMon1 + ld bc, MON_STATS add hl, bc ld d, h ld e, l ; de now points to stats - ld bc, (wPartyMon1Exp + 2) - wPartyMon1Stats + ld bc, (MON_EXP + 2) - MON_STATS add hl, bc ; hl now points to LSB of experience ld b, 1 jp CalcStats ; recalculate stats .useRareCandy push hl - ld bc, wPartyMon1Level - wPartyMon1 + ld bc, MON_LEVEL add hl, bc ; hl now points to level ld a, [hl] ; a = level cp MAX_LEVEL @@ -1473,7 +1473,7 @@ ItemUseMedicine: callfar CalcExperience ; calculate experience for next level and store it at hExperience pop de pop hl - ld bc, wPartyMon1Exp - wPartyMon1Level + ld bc, MON_EXP - MON_LEVEL add hl, bc ; hl now points to MSB of experience ; update experience to minimum for new level ldh a, [hExperience] @@ -1489,7 +1489,7 @@ ItemUseMedicine: push af push de push hl - ld bc, wPartyMon1MaxHP - wPartyMon1 + ld bc, MON_MAXHP add hl, bc ; hl now points to MSB of max HP ld a, [hli] ld b, a @@ -1499,7 +1499,7 @@ ItemUseMedicine: push hl call .recalculateStats pop hl - ld bc, (wPartyMon1MaxHP + 1) - wPartyMon1 + ld bc, (MON_MAXHP + 1) add hl, bc ; hl now points to LSB of max HP pop bc ld a, [hld] @@ -1509,7 +1509,7 @@ ItemUseMedicine: sbc b ld b, a ; bc = the amount of max HP gained from leveling up ; add the amount gained to the current HP - ld de, (wPartyMon1HP + 1) - wPartyMon1MaxHP + ld de, (MON_HP + 1) - MON_MAXHP add hl, de ; hl now points to LSB of current HP ld a, [hl] add c @@ -1528,12 +1528,12 @@ ItemUseMedicine: xor a ; PLAYER_PARTY_DATA ld [wMonDataLocation], a call LoadMonData - ld d, $01 - callfar PrintStatsBox ; display new stats text box - call WaitForTextScrollButtonPress ; wait for button press + ld d, LEVEL_UP_STATS_BOX + callfar PrintStatsBox + call WaitForTextScrollButtonPress xor a ; PLAYER_PARTY_DATA ld [wMonDataLocation], a - predef LearnMoveFromLevelUp ; learn level up move, if any + predef LearnMoveFromLevelUp xor a ld [wForceEvolution], a @@ -1542,7 +1542,7 @@ ItemUseMedicine: push af ld a, [wUsedItemOnWhichPokemon] ld [wWhichPokemon], a - callfar RespawnOverworldPikachu ; evolve pokemon, if appropriate + callfar RespawnOverworldPikachu pop af ld [wWhichPokemon], a @@ -1571,11 +1571,11 @@ INCLUDE "data/battle/stat_names.asm" ItemUseBait: ld hl, ThrewBaitText call PrintText - ld hl, wEnemyMonActualCatchRate ; catch rate + ld hl, wEnemyMonActualCatchRate srl [hl] ; halve catch rate ld a, BAIT_ANIM - ld hl, wSafariBaitFactor ; bait factor - ld de, wSafariEscapeFactor ; escape factor + ld hl, wSafariBaitFactor + ld de, wSafariEscapeFactor jr BaitRockCommon ; for CASCADEBADGE when used from the @@ -1584,7 +1584,7 @@ ItemUseBait: ItemUseRock: ld hl, ThrewRockText call PrintText - ld hl, wEnemyMonActualCatchRate ; catch rate + ld hl, wEnemyMonActualCatchRate ld a, [hl] add a ; double catch rate jr nc, .noCarry @@ -1592,8 +1592,8 @@ ItemUseRock: .noCarry ld [hl], a ld a, ROCK_ANIM - ld hl, wSafariEscapeFactor ; escape factor - ld de, wSafariBaitFactor ; bait factor + ld hl, wSafariEscapeFactor + ld de, wSafariBaitFactor BaitRockCommon: ld [wAnimationID], a @@ -1954,8 +1954,8 @@ ItemUsePokeFlute: ; OUTPUT: ; [wWereAnyMonsAsleep]: set to 1 if any pokemon were asleep WakeUpEntireParty: - ld de, 44 - ld c, 6 + ld de, PARTYMON_STRUCT_LENGTH + ld c, PARTY_LENGTH .loop ld a, [hl] push af @@ -2221,7 +2221,7 @@ ItemUsePPRestore: ld [wPlayerMoveListIndex], a jr nz, .chooseMon ld hl, wPartyMon1Moves - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call GetSelectedMoveOffset push hl ld a, [hl] @@ -2232,8 +2232,8 @@ ItemUsePPRestore: ld a, [wPPRestoreItem] cp ETHER jr nc, .useEther ; if Ether or Max Ether -.usePPUp - ld bc, wPartyMon1PP - wPartyMon1Moves +; use PP Up + ld bc, MON_PP - MON_MOVES add hl, bc ld a, [hl] ; move PP cp 3 << 6 ; have 3 PP Ups already been used? @@ -2267,10 +2267,10 @@ ItemUsePPRestore: cp b ; is the pokemon whose PP was restored active in battle? jr nz, .skipUpdatingInBattleData ld hl, wPartyMon1PP - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld de, wBattleMonPP - ld bc, 4 + ld bc, NUM_MOVES call CopyData ; copy party data to in-battle data .skipUpdatingInBattleData ld a, SFX_HEAL_AILMENT @@ -2291,9 +2291,9 @@ ItemUsePPRestore: ld [wMonDataLocation], a call GetMaxPP ld hl, wPartyMon1Moves - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call GetSelectedMoveOffset - ld bc, wPartyMon1PP - wPartyMon1Moves + ld bc, MON_PP - MON_MOVES add hl, bc ; hl now points to move's PP ld a, [wMaxPP] ld b, a @@ -2343,7 +2343,7 @@ ItemUsePPRestore: .elixirLoop push bc ld hl, wPartyMon1Moves - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call GetSelectedMoveOffset ld a, [hl] and a ; does the current slot have a move? @@ -2441,7 +2441,7 @@ ItemUseTMHM: .chooseMon ld hl, wStringBuffer ld de, wTempMoveNameBuffer - ld bc, ITEM_NAME_LENGTH + 1 + ld bc, MOVE_NAME_LENGTH call CopyData ; save the move name because DisplayPartyMenu will overwrite it ld a, $ff ld [wUpdateSpritesEnabled], a @@ -2451,7 +2451,7 @@ ItemUseTMHM: push af ld hl, wTempMoveNameBuffer ld de, wStringBuffer - ld bc, ITEM_NAME_LENGTH + 1 + ld bc, MOVE_NAME_LENGTH call CopyData pop af jr nc, .checkIfAbleToLearnMove @@ -2656,14 +2656,14 @@ GotOffBicycleText: ; [wCurrentMenuItem] = index of move (when using a PP Up) RestoreBonusPP: ld hl, wPartyMon1Moves - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH ld a, [wWhichPokemon] call AddNTimes push hl ld de, wNormalMaxPPList - 1 predef LoadMovePPs ; loads the normal max PP of each of the pokemon's moves to wNormalMaxPPList pop hl - ld c, wPartyMon1PP - wPartyMon1Moves + ld c, MON_PP - MON_MOVES ld b, 0 add hl, bc ; hl now points to move 1 PP ld de, wNormalMaxPPList @@ -2749,13 +2749,13 @@ GetMaxPP: ld a, [wMonDataLocation] and a ld hl, wPartyMon1Moves - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH jr z, .sourceWithMultipleMon ld hl, wEnemyMon1Moves dec a jr z, .sourceWithMultipleMon ld hl, wBoxMon1Moves - ld bc, wBoxMon2 - wBoxMon1 + ld bc, BOXMON_STRUCT_LENGTH dec a jr z, .sourceWithMultipleMon ld hl, wDayCareMonMoves @@ -2783,7 +2783,7 @@ GetMaxPP: ld b, a ; b = normal max PP pop hl push bc - ld bc, wPartyMon1PP - wPartyMon1Moves ; PP offset if not player's in-battle pokemon data + ld bc, MON_PP - MON_MOVES ; PP offset if not player's in-battle pokemon data ld a, [wMonDataLocation] cp 4 ; player's in-battle pokemon? jr nz, .addPPOffset @@ -2928,29 +2928,33 @@ IsKeyItem_:: INCLUDE "data/items/key_items.asm" +; store the new mon in the first slot, shifting all existing box data down SendNewMonToBox: ld de, wBoxCount ld a, [de] inc a ld [de], a + ld a, [wCurPartySpecies] ld [wCurSpecies], a ld c, a -.loop +.shiftSpeciesLoop inc de ld a, [de] ld b, a ld a, c ld c, b ld [de], a - cp $ff - jr nz, .loop + cp -1 + jr nz, .shiftSpeciesLoop + call GetMonHeader ld hl, wBoxMonOT ld bc, NAME_LENGTH ld a, [wBoxCount] dec a - jr z, .skip + jr z, .skipOTshift ; if the box was empty, there is nothing to shift + dec a call AddNTimes push hl @@ -2962,7 +2966,7 @@ SendNewMonToBox: ld a, [wBoxCount] dec a ld b, a -.loop2 +.shiftMonOTLoop push bc push hl ld bc, NAME_LENGTH @@ -2974,15 +2978,18 @@ SendNewMonToBox: add hl, bc pop bc dec b - jr nz, .loop2 -.skip + jr nz, .shiftMonOTLoop + +.skipOTshift ld hl, wPlayerName - ld de, wBoxMonOT + ld de, wBoxMon1OT ld bc, NAME_LENGTH call CopyData + ld a, [wBoxCount] dec a - jr z, .skip2 + jr z, .skipNickShift + ld hl, wBoxMonNicks ld bc, NAME_LENGTH dec a @@ -2996,7 +3003,7 @@ SendNewMonToBox: ld a, [wBoxCount] dec a ld b, a -.loop3 +.shiftNickLoop push bc push hl ld bc, NAME_LENGTH @@ -3008,21 +3015,24 @@ SendNewMonToBox: add hl, bc pop bc dec b - jr nz, .loop3 -.skip2 - ld hl, wBoxMonNicks + jr nz, .shiftNickLoop + +.skipNickShift + ld hl, wBoxMon1Nick ld a, NAME_MON_SCREEN ld [wNamingScreenType], a predef AskName + ld a, [wBoxCount] dec a - jr z, .skip3 + jr z, .skipMonDataShift + ld hl, wBoxMons - ld bc, wBoxMon2 - wBoxMon1 + ld bc, BOXMON_STRUCT_LENGTH dec a call AddNTimes push hl - ld bc, wBoxMon2 - wBoxMon1 + ld bc, BOXMON_STRUCT_LENGTH add hl, bc ld d, h ld e, l @@ -3030,20 +3040,21 @@ SendNewMonToBox: ld a, [wBoxCount] dec a ld b, a -.loop4 +.shiftMonDataLoop push bc push hl - ld bc, wBoxMon2 - wBoxMon1 + ld bc, BOXMON_STRUCT_LENGTH call CopyData pop hl ld d, h ld e, l - ld bc, wBoxMon1 - wBoxMon2 + ld bc, -BOXMON_STRUCT_LENGTH add hl, bc pop bc dec b - jr nz, .loop4 -.skip3 + jr nz, .shiftMonDataLoop + +.skipMonDataShift ld a, [wEnemyMonLevel] ld [wEnemyMonBoxLevel], a ld hl, wEnemyMon @@ -3073,11 +3084,12 @@ SendNewMonToBox: inc de xor a ld b, NUM_STATS * 2 -.loop5 +.statLoop ld [de], a inc de dec b - jr nz, .loop5 + jr nz, .statLoop + ld hl, wEnemyMonDVs ld a, [hli] ld [de], a @@ -3086,12 +3098,12 @@ SendNewMonToBox: ld [de], a ld hl, wEnemyMonPP ld b, NUM_MOVES -.loop6 +.movePPLoop ld a, [hli] inc de ld [de], a dec b - jr nz, .loop6 + jr nz, .movePPLoop ld a, [wCurPartySpecies] cp KADABRA jr nz, .notKadabra diff --git a/engine/items/tmhm.asm b/engine/items/tmhm.asm index a11cd736..bac92f5d 100644 --- a/engine/items/tmhm.asm +++ b/engine/items/tmhm.asm @@ -2,7 +2,7 @@ CheckIfMoveIsKnown: ld a, [wWhichPokemon] ld hl, wPartyMon1Moves - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld a, [wMoveNum] ld b, a diff --git a/engine/items/town_map.asm b/engine/items/town_map.asm index a7093cfc..fe274579 100644 --- a/engine/items/town_map.asm +++ b/engine/items/town_map.asm @@ -20,11 +20,11 @@ DisplayTownMap: call PlaceString ld hl, wShadowOAMSprite00 ld de, wShadowOAMBackupSprite00 - ld bc, 4 * 4 + ld bc, OBJ_SIZE * 4 call CopyData ld hl, vSprites tile BIRD_BASE_TILE ld de, TownMapCursor - lb bc, BANK(TownMapCursor), (TownMapCursorEnd - TownMapCursor) / $8 + lb bc, BANK(TownMapCursor), (TownMapCursorEnd - TownMapCursor) / TILE_1BPP_SIZE call CopyVideoDataDouble xor a ld [wWhichTownMapLocation], a @@ -64,7 +64,7 @@ DisplayTownMap: call PlaceString ld hl, wShadowOAMSprite04 ld de, wShadowOAMBackupSprite04 - ld bc, 4 * 4 + ld bc, OBJ_SIZE * 4 call CopyData .inputLoop call TownMapSpriteBlinkingAnimation @@ -159,7 +159,7 @@ LoadTownMap_Fly:: call CopyVideoData ld de, TownMapUpArrow ld hl, vChars1 tile $6d - lb bc, BANK(TownMapUpArrow), (TownMapUpArrowEnd - TownMapUpArrow) / $8 + lb bc, BANK(TownMapUpArrow), (TownMapUpArrowEnd - TownMapUpArrow) / TILE_1BPP_SIZE call CopyVideoDataDouble call BuildFlyLocationsList ld hl, wUpdateSpritesEnabled @@ -618,11 +618,11 @@ TownMapSpriteBlinkingAnimation:: xor a jr .done .hideSprites - ld hl, wShadowOAM + ld hl, wShadowOAMSprite00YCoord ld b, OAM_COUNT - 4 - ld de, $4 + ld de, OBJ_SIZE .hideSpritesLoop - ld [hl], $a0 + ld [hl], SCREEN_HEIGHT_PX + OAM_Y_OFS add hl, de dec b jr nz, .hideSpritesLoop diff --git a/engine/link/cable_club.asm b/engine/link/cable_club.asm index d66dc608..716b1441 100644 --- a/engine/link/cable_club.asm +++ b/engine/link/cable_club.asm @@ -679,7 +679,7 @@ TradeCenter_PrintPartyListNames: pop de inc de pop hl - ld bc, 20 + ld bc, SCREEN_WIDTH add hl, bc pop bc inc c @@ -766,9 +766,9 @@ TradeCenter_Trade: call CopyData ld hl, wPartyMon1Species ld a, [wTradingWhichPlayerMon] - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes - ld bc, wPartyMon1OTID - wPartyMon1 + ld bc, MON_OTID add hl, bc ld a, [hli] ld [wTradedPlayerMonOTID], a @@ -782,9 +782,9 @@ TradeCenter_Trade: call CopyData ld hl, wEnemyMons ld a, [wTradingWhichEnemyMon] - ld bc, wEnemyMon2 - wEnemyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes - ld bc, wEnemyMon1OTID - wEnemyMon1 + ld bc, MON_OTID add hl, bc ld a, [hli] ld [wTradedEnemyMonOTID], a @@ -813,10 +813,10 @@ TradeCenter_Trade: ld [wCurPartySpecies], a ld hl, wEnemyMons ld a, c - ld bc, wEnemyMon2 - wEnemyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld de, wLoadedMon - ld bc, wEnemyMon2 - wEnemyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call CopyData call AddEnemyMonToPlayerParty ld a, [wPartyCount] @@ -983,5 +983,5 @@ CableClub_DrawHorizontalLine: LoadTrainerInfoTextBoxTiles: ld de, TrainerInfoTextBoxTileGraphics ld hl, vChars2 tile $76 - lb bc, BANK(TrainerInfoTextBoxTileGraphics), (TrainerInfoTextBoxTileGraphicsEnd - TrainerInfoTextBoxTileGraphics) / $10 + lb bc, BANK(TrainerInfoTextBoxTileGraphics), (TrainerInfoTextBoxTileGraphicsEnd - TrainerInfoTextBoxTileGraphics) / TILE_SIZE jp CopyVideoData diff --git a/engine/menus/display_text_id_init.asm b/engine/menus/display_text_id_init.asm index ca828006..1dda338d 100644 --- a/engine/menus/display_text_id_init.asm +++ b/engine/menus/display_text_id_init.asm @@ -40,8 +40,8 @@ DisplayTextIDInit:: ; this is done because when you talk to an NPC, they turn to look your way ; the original direction they were facing must be restored after the dialogue is over ld hl, wSprite01StateData1FacingDirection - ld c, $0f - ld de, $10 + ld c, NUM_SPRITESTATEDATA_STRUCTS - 1 + ld de, SPRITESTATEDATA1_LENGTH .spriteFacingDirectionCopyLoop ld a, [hl] ; x#SPRITESTATEDATA1_FACINGDIRECTION inc h @@ -53,7 +53,8 @@ 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, wSpritePlayerStateData1ImageIndex - ld de, $10 + ld de, SPRITESTATEDATA1_LENGTH + ASSERT NUM_SPRITESTATEDATA_STRUCTS == SPRITESTATEDATA1_LENGTH ld c, e .spriteStandStillLoop ld a, [hl] diff --git a/engine/menus/naming_screen.asm b/engine/menus/naming_screen.asm index 38da8afe..5b4b2415 100644 --- a/engine/menus/naming_screen.asm +++ b/engine/menus/naming_screen.asm @@ -239,11 +239,11 @@ DisplayNamingScreen: cp NAME_MON_SCREEN jr nc, .checkMonNameLength ld a, [wNamingScreenNameLength] - cp $7 ; max length of player/rival names + cp PLAYER_NAME_LENGTH - 1 jr .checkNameLength .checkMonNameLength ld a, [wNamingScreenNameLength] - cp $a ; max length of pokemon nicknames + cp NAME_LENGTH - 1 .checkNameLength jr c, .addLetter ret @@ -394,12 +394,13 @@ PrintNicknameAndUnderscores: hlcoord 10, 3 ld a, [wNamingScreenType] cp NAME_MON_SCREEN - jr nc, .pokemon1 - ld b, 7 ; player or rival max name length - jr .playerOrRival1 -.pokemon1 - ld b, 10 ; pokemon max name length -.playerOrRival1 + jr nc, .pokemon +; player or rival + ld b, PLAYER_NAME_LENGTH - 1 + jr .gotUnderscoreCount +.pokemon + ld b, NAME_LENGTH - 1 +.gotUnderscoreCount ld a, $76 ; underscore tile id .placeUnderscoreLoop ld [hli], a @@ -409,13 +410,15 @@ PrintNicknameAndUnderscores: cp NAME_MON_SCREEN ld a, [wNamingScreenNameLength] jr nc, .pokemon2 - cp 7 ; player or rival max name length - jr .playerOrRival2 +; player or rival + cp PLAYER_NAME_LENGTH - 1 + jr .checkEmptySpaces .pokemon2 - cp 10 ; pokemon max name length -.playerOrRival2 - jr nz, .emptySpacesRemaining - ; when all spaces are filled, force the cursor onto the ED tile + cp NAME_LENGTH - 1 +.checkEmptySpaces + jr nz, .placeRaisedUnderscore ; jump if empty spaces remain + ; when all spaces are filled, force the cursor onto the ED tile, + ; and keep the last underscore raised call EraseMenuCursor ld a, $11 ; "ED" x coord ld [wTopMenuItemX], a @@ -423,11 +426,10 @@ PrintNicknameAndUnderscores: ld [wCurrentMenuItem], a ld a, [wNamingScreenType] cp NAME_MON_SCREEN - ld a, 9 ; keep the last underscore raised - jr nc, .pokemon3 - ld a, 6 ; keep the last underscore raised -.pokemon3 -.emptySpacesRemaining + ld a, NAME_LENGTH - 2 + jr nc, .placeRaisedUnderscore + ld a, PLAYER_NAME_LENGTH - 2 +.placeRaisedUnderscore ld c, a ld b, $0 hlcoord 10, 3 diff --git a/engine/menus/party_menu.asm b/engine/menus/party_menu.asm index d994c15f..24d2aa13 100644 --- a/engine/menus/party_menu.asm +++ b/engine/menus/party_menu.asm @@ -110,7 +110,7 @@ RedrawPartyMenu_:: pop hl pop de inc de - ld bc, 2 * 20 + ld bc, 2 * SCREEN_WIDTH add hl, bc pop bc inc c diff --git a/engine/menus/pokedex.asm b/engine/menus/pokedex.asm index 48c5ab01..dcf55820 100644 --- a/engine/menus/pokedex.asm +++ b/engine/menus/pokedex.asm @@ -118,7 +118,7 @@ ELSE jr z, .chosePrint ENDC vc_patch_end -.choseQuit +; chose Quit ld b, 1 .exitSideMenu pop af @@ -484,8 +484,8 @@ HeightWeightText: db "HT ?′??″" next "WT ???lb@" -; XXX does anything point to this? -PokeText: +; leftover from JPN Pokedex, where species have the suffix "Pokemon" +PokeText: ; unreferenced db "#@" ; horizontal line that divides the pokedex text description from the rest of the data diff --git a/engine/menus/save.asm b/engine/menus/save.asm index 768b6e8b..bc427936 100644 --- a/engine/menus/save.asm +++ b/engine/menus/save.asm @@ -214,15 +214,15 @@ SaveMainData: ld de, sSpriteData ld bc, wSpriteDataEnd - wSpriteDataStart call CopyData - ld hl, wBoxDataStart ; this part is redundant, SaveCurrentBoxData is always called next + ld hl, wBoxDataStart ld de, sCurBoxData ld bc, wBoxDataEnd - wBoxDataStart call CopyData + ldh a, [hTileAnimations] ld [sTileAnimations], a - ld hl, sGameData ld bc, sGameDataEnd - sGameData call CalcCheckSum diff --git a/engine/menus/start_sub_menus.asm b/engine/menus/start_sub_menus.asm index 7e801068..dfbb0f13 100644 --- a/engine/menus/start_sub_menus.asm +++ b/engine/menus/start_sub_menus.asm @@ -253,7 +253,7 @@ StartMenu_Pokemon:: .softboiled ld hl, wPartyMon1MaxHP ld a, [wWhichPokemon] - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld a, [hli] ldh [hDividend], a @@ -263,7 +263,7 @@ StartMenu_Pokemon:: ldh [hDivisor], a ld b, 2 ; number of bytes call Divide - ld bc, wPartyMon1HP - wPartyMon1MaxHP + ld bc, MON_HP - MON_MAXHP add hl, bc ld a, [hld] ld b, a @@ -357,7 +357,7 @@ StartMenu_Item:: ld a, [wCurItem] cp BICYCLE jp z, .useOrTossItem -.notBicycle1 +; not Bicycle ld a, USE_TOSS_MENU_TEMPLATE ld [wTextBoxID], a call DisplayTextBoxID @@ -387,14 +387,14 @@ StartMenu_Item:: call CopyToStringBuffer ld a, [wCurItem] cp BICYCLE - jr nz, .notBicycle2 + jr nz, .notBicycle ld a, [wStatusFlags6] bit BIT_ALWAYS_ON_BIKE, a jr z, .useItem_closeMenu ld hl, CannotGetOffHereText call PrintText jp ItemMenuLoop -.notBicycle2 +.notBicycle ld a, [wCurrentMenuItem] and a jr nz, .tossItem @@ -529,7 +529,7 @@ DrawTrainerInfo: ld de, 13 tiles add hl, de ; hl = colon tile pattern ld de, vChars1 tile $56 - ld bc, 1 tiles + ld bc, TILE_SIZE ld a, BANK(TextBoxGraphics) push bc call FarCopyData @@ -695,13 +695,13 @@ SwitchPartyMon_ClearGfx: dec c jr nz, .clearMonBGLoop pop af - ld hl, wShadowOAM - ld bc, $10 + ld hl, wShadowOAMSprite00YCoord + ld bc, OBJ_SIZE * 4 call AddNTimes - ld de, $4 + ld de, OBJ_SIZE ld c, e .clearMonOAMLoop - ld [hl], $a0 + ld [hl], SCREEN_HEIGHT_PX + OAM_Y_OFS add hl, de dec c jr nz, .clearMonOAMLoop @@ -761,24 +761,24 @@ SwitchPartyMon_InitVarOrSwapData: ldh a, [hSwapTemp] ld [de], a ld hl, wPartyMons - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH ld a, [wCurrentMenuItem] call AddNTimes push hl ld de, wSwitchPartyMonTempBuffer - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call CopyData ld hl, wPartyMons - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH ld a, [wMenuItemToSwap] call AddNTimes pop de push hl - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call CopyData pop de ld hl, wSwitchPartyMonTempBuffer - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call CopyData ld hl, wPartyMonOT ld a, [wCurrentMenuItem] diff --git a/engine/menus/swap_items.asm b/engine/menus/swap_items.asm index 2d506ce2..dc54b645 100644 --- a/engine/menus/swap_items.asm +++ b/engine/menus/swap_items.asm @@ -76,7 +76,7 @@ HandleItemListSwapping:: ld a, [hli] cp b jr z, .swapSameItemType -.swapDifferentItems +; swap different items ldh [hSwapItemID], a ; save second item ID ld a, [hld] ldh [hSwapItemQuantity], a ; save second item quantity diff --git a/engine/menus/text_box.asm b/engine/menus/text_box.asm index a9d5b4c9..d3144386 100644 --- a/engine/menus/text_box.asm +++ b/engine/menus/text_box.asm @@ -481,7 +481,7 @@ PokemonMenuEntries: GetMonFieldMoves: ld a, [wWhichPokemon] ld hl, wPartyMon1Moves - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld d, h ld e, l diff --git a/engine/movie/credits.asm b/engine/movie/credits.asm index 149f51a7..dd8050bf 100644 --- a/engine/movie/credits.asm +++ b/engine/movie/credits.asm @@ -38,7 +38,7 @@ HallOfFamePC: ld [wNumCreditsMonsDisplayed], a jp Credits -FadeInCreditsText: +FadeInCredits: ld a, 1 ldh [hAutoBGTransferEnabled], a ld hl, HoFGBPalettes @@ -137,30 +137,33 @@ CreditsCopyTileMapToVRAM: CreditsLoadFont: call LoadFontTilePatterns - ld hl, vChars1 + ld hl, vFont ld bc, ($80 tiles) / 2 - call ZeroMemory + call ShiftFontColorIndex call LoadTextBoxTilePatterns ld hl, vChars2 tile $60 ld bc, ($20 tiles) / 2 - call ZeroMemory + call ShiftFontColorIndex ld hl, vChars2 tile $7e - ld bc, 1 tiles + ld bc, TILE_SIZE ld a, $ff ; solid black call FillMemory ret -ZeroMemory: -; zero bc bytes at hl +ShiftFontColorIndex: +; Zero every second byte at hl, writing a total of bc bytes. +; When used on VRAM font characters that contain only black and white shades, +; it shifts the color index: black -> light gray, allowing palette-controlled +; text fade-in during the Credits roll, while the black bars remain solid. ld [hl], 0 inc hl inc hl dec bc ld a, b or c - jr nz, ZeroMemory + jr nz, ShiftFontColorIndex ret FillFourRowsWithBlack: @@ -243,7 +246,7 @@ Credits: ; Roll credits .fadeInTextAndShowMon - call FadeInCreditsText + call FadeInCredits ld c, 102 jr .next1 @@ -255,7 +258,7 @@ Credits: ; Roll credits jr .nextCreditsScreen .fadeInText - call FadeInCreditsText + call FadeInCredits ld c, 132 jr .next2 @@ -275,7 +278,7 @@ ShowTheEndGFX: call FillMiddleOfScreenWithWhite ld de, TheEndGfx ld hl, vChars2 tile $60 - lb bc, BANK(TheEndGfx), (TheEndGfxEnd - TheEndGfx) / $10 + lb bc, BANK(TheEndGfx), (TheEndGfxEnd - TheEndGfx) / TILE_SIZE call CopyVideoData hlcoord 4, 8 ld de, TheEndTextString @@ -283,7 +286,7 @@ ShowTheEndGFX: hlcoord 4, 9 inc de call PlaceString - jp FadeInCreditsText + jp FadeInCredits TheEndTextString: ; "T H E E N D" diff --git a/engine/movie/evolution.asm b/engine/movie/evolution.asm index 9d24c0d5..d3b91b4f 100644 --- a/engine/movie/evolution.asm +++ b/engine/movie/evolution.asm @@ -28,7 +28,7 @@ EvolveMon: call Evolution_LoadPic ld de, vFrontPic ld hl, vBackPic - ld bc, 7 * 7 + ld bc, PIC_SIZE call CopyVideoData ld a, [wEvoOldSpecies] ld [wCurPartySpecies], a diff --git a/engine/movie/hall_of_fame.asm b/engine/movie/hall_of_fame.asm index 4afb23d3..7e0a419a 100644 --- a/engine/movie/hall_of_fame.asm +++ b/engine/movie/hall_of_fame.asm @@ -49,7 +49,7 @@ AnimateHallOfFame: ld a, c ld [wHoFPartyMonIndex], a ld hl, wPartyMon1Level - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld a, [hl] ld [wHoFMonLevel], a diff --git a/engine/movie/intro.asm b/engine/movie/intro.asm index f018d860..1381d396 100644 --- a/engine/movie/intro.asm +++ b/engine/movie/intro.asm @@ -158,5 +158,5 @@ LoadPresentsGraphic: ; unreferenced GameFreakIntro: INCBIN "gfx/splash/gamefreak_presents.2bpp" INCBIN "gfx/splash/gamefreak_logo.2bpp" - ds 16, $00 ; blank tile + ds TILE_SIZE, $00 ; blank tile GameFreakIntroEnd: diff --git a/engine/movie/oak_speech/init_player_data.asm b/engine/movie/oak_speech/init_player_data.asm index 9994be51..90fb8f0e 100644 --- a/engine/movie/oak_speech/init_player_data.asm +++ b/engine/movie/oak_speech/init_player_data.asm @@ -50,7 +50,7 @@ DEF START_MONEY EQU $3000 ld bc, wGameProgressFlagsEnd - wGameProgressFlags call FillMemory ; clear all game progress flags - jp InitializeMissableObjectsFlags + jp InitializeToggleableObjectsFlags InitializeEmptyList: xor a ; count diff --git a/engine/movie/oak_speech/oak_speech.asm b/engine/movie/oak_speech/oak_speech.asm index 5cc80745..4d615126 100644 --- a/engine/movie/oak_speech/oak_speech.asm +++ b/engine/movie/oak_speech/oak_speech.asm @@ -125,6 +125,9 @@ OakSpeech: ld a, SFX_SHRINK call PlaySound pop af +; bug: switching ROM Bank should not happen outside of Home Bank +; This code does nothing, as PlaySound does all necessary Bank switch +; It looks like a leftover from an early development stage call BankswitchCommon ld c, 4 call DelayFrames @@ -151,6 +154,7 @@ OakSpeech: ld [wAudioFadeOutControl], a call StopAllMusic pop af +; bug: switching ROM Bank should not happen outside of Home Bank call BankswitchCommon ld c, 20 call DelayFrames @@ -163,23 +167,27 @@ OakSpeech: ld c, 50 call DelayFrames call GBFadeOutToWhite - call ClearScreen ; rip more tail-end optimizations + call ClearScreen ret OakSpeechText1: text_far _OakSpeechText1 text_end + OakSpeechText2: text_far _OakSpeechText2A sound_cry_pikachu text_far _OakSpeechText2B text_end + IntroducePlayerText: text_far _IntroducePlayerText text_end + IntroduceRivalText: text_far _IntroduceRivalText text_end + OakSpeechText3: text_far _OakSpeechText3 text_end diff --git a/engine/movie/oak_speech/oak_speech2.asm b/engine/movie/oak_speech/oak_speech2.asm index cedc8be7..9beb4945 100644 --- a/engine/movie/oak_speech/oak_speech2.asm +++ b/engine/movie/oak_speech/oak_speech2.asm @@ -187,7 +187,7 @@ DisplayIntroNameTextBox: .namestring db "NAME@" -INCLUDE "data/player_names.asm" +INCLUDE "data/player/names.asm" GetDefaultName: ; a = name index @@ -213,7 +213,7 @@ GetDefaultName: ld bc, NAME_BUFFER_LENGTH jp CopyData -INCLUDE "data/player_names_list.asm" +INCLUDE "data/player/names_list.asm" LinkMenuEmptyText: text_end diff --git a/engine/movie/splash.asm b/engine/movie/splash.asm index 5b837591..8ac0c26e 100644 --- a/engine/movie/splash.asm +++ b/engine/movie/splash.asm @@ -15,7 +15,7 @@ LoadShootingStarGraphics: call CopyVideoData ld de, FallingStar ld hl, vChars1 tile $22 - lb bc, BANK(FallingStar), (FallingStarEnd - FallingStar) / $10 + lb bc, BANK(FallingStar), (FallingStarEnd - FallingStar) / TILE_SIZE call CopyVideoData ld hl, GameFreakLogoOAMData ld de, wShadowOAMSprite24 @@ -62,11 +62,11 @@ AnimateShootingStar: jr nz, .bigStarLoop ; Clear big star OAM. - ld hl, wShadowOAM + ld hl, wShadowOAMSprite00YCoord ld c, 4 - ld de, 4 + ld de, OBJ_SIZE .clearOAMLoop - ld [hl], 160 + ld [hl], SCREEN_HEIGHT_PX + OAM_Y_OFS add hl, de dec c jr nz, .clearOAMLoop @@ -145,7 +145,7 @@ AnimateShootingStar: ; shift the existing OAM entries down to make room for the next wave ld hl, wShadowOAMSprite04 ld de, wShadowOAM - ld bc, $50 + ld bc, OBJ_SIZE * 20 call CopyData pop af diff --git a/engine/movie/title.asm b/engine/movie/title.asm index 0e9b651e..4ff22800 100644 --- a/engine/movie/title.asm +++ b/engine/movie/title.asm @@ -253,7 +253,7 @@ LoadCopyrightAndTextBoxTiles: LoadCopyrightTiles: ld de, NintendoCopyrightLogoGraphics ld hl, vChars2 tile $60 - lb bc, BANK(NintendoCopyrightLogoGraphics), (TextBoxGraphics + $10 - NintendoCopyrightLogoGraphics) / $10 ; bug: overflows into text box graphics and copies the "A" tile + lb bc, BANK(NintendoCopyrightLogoGraphics), (TextBoxGraphics + $10 - NintendoCopyrightLogoGraphics) / TILE_SIZE ; bug: overflows into text box graphics and copies the "A" tile call CopyVideoData hlcoord 2, 7 ld de, CopyrightTextString diff --git a/engine/movie/trade.asm b/engine/movie/trade.asm index 1af97969..f0c813bc 100644 --- a/engine/movie/trade.asm +++ b/engine/movie/trade.asm @@ -319,7 +319,7 @@ Trade_AnimateBallEnteringLinkCable: ld [wLinkCableAnimBulgeToggle], a add $7e ld hl, wShadowOAMSprite00TileID - ld de, 4 + ld de, OBJ_SIZE ld c, e .cycleLinkCableBulgeTile ld [hl], a @@ -606,7 +606,7 @@ Trade_AnimCircledMon: ldh [rBGP], a call UpdateCGBPal_BGP ld hl, wShadowOAMSprite00TileID - ld de, $4 + ld de, OBJ_SIZE ld c, $14 .loop ld a, [hl] diff --git a/engine/overworld/advance_player_sprite.asm b/engine/overworld/advance_player_sprite.asm index 4ebdac84..314883dd 100644 --- a/engine/overworld/advance_player_sprite.asm +++ b/engine/overworld/advance_player_sprite.asm @@ -3,7 +3,7 @@ _AdvancePlayerSprite:: ld b, a ld a, [wSpritePlayerStateData1XStepVector] ld c, a - ld hl, wWalkCounter ; walking animation counter + ld hl, wWalkCounter dec [hl] jr nz, .afterUpdateMapCoords ; if it's the end of the animation, update the player's map coordinates @@ -16,7 +16,7 @@ _AdvancePlayerSprite:: add c ld [wXCoord], a .afterUpdateMapCoords - ld a, [wWalkCounter] ; walking animation counter + ld a, [wWalkCounter] cp $07 jp nz, .scrollBackgroundAndSprites ; if this is the first iteration of the animation diff --git a/engine/overworld/auto_movement.asm b/engine/overworld/auto_movement.asm index cdc7e28a..2266e866 100644 --- a/engine/overworld/auto_movement.asm +++ b/engine/overworld/auto_movement.asm @@ -1,6 +1,6 @@ PlayerStepOutFromDoor:: - ld hl, wStatusFlags5 ; should this be wMovementFlags? - res BIT_EXITING_DOOR, [hl] + ld hl, wStatusFlags5 + res BIT_UNKNOWN_5_1, [hl] call IsPlayerStandingOnDoorTile jr nc, .notStandingOnDoor ld a, PAD_SELECT | PAD_START | PAD_CTRL_PAD @@ -153,8 +153,8 @@ PalletMovementScript_Done: ld a, [wSimulatedJoypadStatesIndex] and a ret nz - ld a, HS_PALLET_TOWN_OAK - ld [wMissableObjectIndex], a + ld a, TOGGLE_PALLET_TOWN_OAK + ld [wToggleableObjectIndex], a predef HideObject ld hl, wStatusFlags5 res BIT_SCRIPTED_MOVEMENT_STATE, [hl] diff --git a/engine/overworld/cut.asm b/engine/overworld/cut.asm index 1b5b85bd..dea23cc5 100644 --- a/engine/overworld/cut.asm +++ b/engine/overworld/cut.asm @@ -101,13 +101,13 @@ InitCutAnimOAM: call LoadCutGrassAnimationTilePattern call WriteCutOrBoulderDustAnimationOAMBlock ld hl, wShadowOAMSprite36Attributes - ld de, 4 - ld a, $30 + ld de, OBJ_SIZE + ld a, OAM_XFLIP | OAM_PAL1 ld c, e .loop ld [hl], a add hl, de - xor $60 + xor OAM_YFLIP | OAM_XFLIP dec c jr nz, .loop ret diff --git a/engine/overworld/cut2.asm b/engine/overworld/cut2.asm index a6effff5..9d6124e4 100644 --- a/engine/overworld/cut2.asm +++ b/engine/overworld/cut2.asm @@ -79,13 +79,13 @@ AnimCutGrass_UpdateOAMEntries: AnimCutGrass_SwapOAMEntries: ld hl, wShadowOAMSprite36 ld de, wBuffer - ld bc, $8 + ld bc, 2 * OBJ_SIZE call CopyData ld hl, wShadowOAMSprite38 ld de, wShadowOAMSprite36 - ld bc, $8 + ld bc, 2 * OBJ_SIZE call CopyData ld hl, wBuffer ld de, wShadowOAMSprite38 - ld bc, $8 + ld bc, 2 * OBJ_SIZE jp CopyData diff --git a/engine/overworld/dust_smoke.asm b/engine/overworld/dust_smoke.asm index 669e1166..2e6576a8 100644 --- a/engine/overworld/dust_smoke.asm +++ b/engine/overworld/dust_smoke.asm @@ -72,7 +72,7 @@ LoadSmokeTileFourTimes:: push hl call LoadSmokeTile pop hl - ld bc, 1 tiles + ld bc, TILE_SIZE add hl, bc pop bc dec c @@ -81,7 +81,7 @@ LoadSmokeTileFourTimes:: LoadSmokeTile: ld de, SSAnneSmokePuffTile - lb bc, BANK(SSAnneSmokePuffTile), (SSAnneSmokePuffTileEnd - SSAnneSmokePuffTile) / $10 + lb bc, BANK(SSAnneSmokePuffTile), (SSAnneSmokePuffTileEnd - SSAnneSmokePuffTile) / TILE_SIZE jp CopyVideoData SSAnneSmokePuffTile: diff --git a/engine/overworld/hidden_objects.asm b/engine/overworld/hidden_events.asm index 84108986..b7c803e5 100644 --- a/engine/overworld/hidden_objects.asm +++ b/engine/overworld/hidden_events.asm @@ -1,12 +1,12 @@ -; if a hidden object was found, stores $00 in [hDidntFindAnyHiddenObject], else stores $ff -CheckForHiddenObject:: +; if a hidden event was found, stores $00 in [hDidntFindAnyHiddenEvent], else stores $ff +CheckForHiddenEvent:: ld hl, hItemAlreadyFound xor a ld [hli], a ; [hItemAlreadyFound] ld [hli], a ; [hSavedMapTextPtr] ld [hli], a ; [hSavedMapTextPtr + 1] - ld [hl], a ; [hDidntFindAnyHiddenObject] - ld hl, HiddenObjectMaps + ld [hl], a ; [hDidntFindAnyHiddenEvent] + ld hl, HiddenEventMaps ld de, 3 ld a, [wCurMap] call IsInArray @@ -16,46 +16,46 @@ CheckForHiddenObject:: ld h, [hl] ld l, a push hl - ld hl, wHiddenObjectFunctionArgument + ld hl, wHiddenEventFunctionArgument xor a ld [hli], a ld [hli], a ld [hl], a pop hl -.hiddenObjectLoop +.hiddenEventLoop ld a, [hli] cp $ff jr z, .noMatch - ld [wHiddenObjectY], a + ld [wHiddenEventY], a ld b, a ld a, [hli] - ld [wHiddenObjectX], a + ld [wHiddenEventX], a ld c, a call CheckIfCoordsInFrontOfPlayerMatch ldh a, [hCoordsInFrontOfPlayerMatch] and a - jr z, .foundMatchingObject + jr z, .foundMatchingEvent inc hl inc hl inc hl inc hl push hl - ld hl, wHiddenObjectIndex + ld hl, wHiddenEventIndex inc [hl] pop hl - jr .hiddenObjectLoop -.foundMatchingObject + jr .hiddenEventLoop +.foundMatchingEvent ld a, [hli] - ld [wHiddenObjectFunctionArgument], a + ld [wHiddenEventFunctionArgument], a ld a, [hli] - ld [wHiddenObjectFunctionRomBank], a + ld [wHiddenEventFunctionRomBank], a ld a, [hli] ld h, [hl] ld l, a ret .noMatch ld a, $ff - ldh [hDidntFindAnyHiddenObject], a + ldh [hDidntFindAnyHiddenEvent], a ret ; checks if the coordinates in front of the player's sprite match Y in b and X in c @@ -104,4 +104,4 @@ CheckIfCoordsInFrontOfPlayerMatch: ldh [hCoordsInFrontOfPlayerMatch], a ret -INCLUDE "data/events/hidden_objects.asm" +INCLUDE "data/events/hidden_events.asm" diff --git a/engine/overworld/ledges.asm b/engine/overworld/ledges.asm index 9f8de983..5cb2d5fc 100644 --- a/engine/overworld/ledges.asm +++ b/engine/overworld/ledges.asm @@ -59,7 +59,7 @@ INCLUDE "data/tilesets/ledge_tiles.asm" LoadHoppingShadowOAM: ld hl, vChars1 tile $7f ld de, LedgeHoppingShadow - lb bc, BANK(LedgeHoppingShadow), (LedgeHoppingShadowEnd - LedgeHoppingShadow) / $8 + lb bc, BANK(LedgeHoppingShadow), (LedgeHoppingShadowEnd - LedgeHoppingShadow) / TILE_1BPP_SIZE call CopyVideoDataDouble ld hl, LedgeHoppingShadowOAM ld de, wShadowOAMSprite36 diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm index fbe8e5df..165208eb 100644 --- a/engine/overworld/movement.asm +++ b/engine/overworld/movement.asm @@ -125,7 +125,7 @@ UpdateNPCSprite: ld b, a ld a, [wFontLoaded] bit BIT_FONT_LOADED, a - jp nz, notYetMoving + jp nz, NotYetMoving ld a, b cp $2 jp z, UpdateSpriteMovementDelay ; [x#SPRITESTATEDATA1_MOVEMENTSTATUS] == 2 @@ -347,14 +347,15 @@ UpdateSpriteMovementDelay: jr .moving .tickMoveCounter dec [hl] ; x#SPRITESTATEDATA2_MOVEMENTDELAY - jr nz, notYetMoving + jr nz, NotYetMoving .moving dec h ldh a, [hCurrentSpriteOffset] inc a ld l, a ld [hl], $1 ; [x#SPRITESTATEDATA1_MOVEMENTSTATUS] = 1 (mark as ready to move) -notYetMoving: + ; fallthrough +NotYetMoving: ld h, HIGH(wSpriteStateData1) ldh a, [hCurrentSpriteOffset] add SPRITESTATEDATA1_ANIMFRAMECOUNTER @@ -369,7 +370,7 @@ MakeNPCFacePlayer: ; disabled. This is only done when rubbing the S.S. Anne captain's back. ld a, [wStatusFlags3] bit BIT_NO_NPC_FACE_PLAYER, a - jr nz, notYetMoving + jr nz, NotYetMoving res BIT_FACE_PLAYER, [hl] ld a, [wPlayerDirection] bit PLAYER_DIR_BIT_UP, a @@ -393,7 +394,7 @@ MakeNPCFacePlayer: add $9 ld l, a ld [hl], c ; [x#SPRITESTATEDATA1_FACINGDIRECTION]: set facing direction - jr notYetMoving + jr NotYetMoving InitializeSpriteStatus: ld [hl], $1 ; [x#SPRITESTATEDATA1_MOVEMENTSTATUS] = ready @@ -448,7 +449,7 @@ Func_5033: ; tests if sprite is off screen or otherwise unable to do anything CheckSpriteAvailability: predef IsObjectHidden - ldh a, [hIsHiddenMissableObject] + ldh a, [hIsToggleableObjectOff] and a jp nz, .spriteInvisible ld h, HIGH(wSpriteStateData2) diff --git a/engine/overworld/pathfinding.asm b/engine/overworld/pathfinding.asm index 878ca07d..d6e0d009 100644 --- a/engine/overworld/pathfinding.asm +++ b/engine/overworld/pathfinding.asm @@ -94,7 +94,7 @@ CalcPositionOfPlayerRelativeToNPC: ld a, [hli] ; NPC sprite screen Y position in pixels call CalcDifference jr nc, .NPCSouthOfOrAlignedWithPlayer -.NPCNorthOfPlayer +; NPC north of player push hl ld hl, hNPCPlayerRelativePosFlags bit BIT_PLAYER_LOWER_Y, [hl] @@ -122,7 +122,7 @@ CalcPositionOfPlayerRelativeToNPC: ld a, [hl] ; NPC sprite screen X position in pixels call CalcDifference jr nc, .NPCEastOfOrAlignedWithPlayer -.NPCWestOfPlayer +; NPC west of player push hl ld hl, hNPCPlayerRelativePosFlags bit BIT_PLAYER_LOWER_X, [hl] diff --git a/engine/overworld/player_animations.asm b/engine/overworld/player_animations.asm index b63b12cc..1948f68d 100644 --- a/engine/overworld/player_animations.asm +++ b/engine/overworld/player_animations.asm @@ -213,13 +213,13 @@ LeaveMapThroughHoleAnim: ld [wShadowOAMSprite02TileID], a ld a, [wShadowOAMSprite01TileID] ld [wShadowOAMSprite03TileID], a - ld a, $a0 + ld a, SCREEN_HEIGHT_PX + OAM_Y_OFS ld [wShadowOAMSprite00YCoord], a ld [wShadowOAMSprite01YCoord], a ld c, 2 call DelayFrames ; hide upper half of player's sprite - ld a, $a0 + ld a, SCREEN_HEIGHT_PX + OAM_Y_OFS ld [wShadowOAMSprite02YCoord], a ld [wShadowOAMSprite03YCoord], a call GBFadeOutToWhite @@ -270,7 +270,7 @@ InitFacingDirectionList: ld [wSavedPlayerScreenY], a ld hl, PlayerSpinningFacingOrder ld de, wFacingDirectionList - ld bc, 4 + ld bc, OBJ_SIZE call CopyData ld a, [wSpritePlayerStateData1ImageIndex] ; (image index is locked to standing images) ld hl, wFacingDirectionList @@ -294,7 +294,7 @@ SpinPlayerSprite: push hl ld hl, wFacingDirectionList ld de, wFacingDirectionList - 1 - ld bc, 4 + ld bc, OBJ_SIZE call CopyData ld a, [wFacingDirectionList - 1] ld [wFacingDirectionList + 3], a @@ -400,7 +400,7 @@ FishingAnim: ld hl, FishingRodOAM add hl, bc ld de, wShadowOAMSprite39 - ld bc, $4 + ld bc, OBJ_SIZE call CopyData ld c, 100 call DelayFrames @@ -430,7 +430,7 @@ FishingAnim: ld a, [wSpritePlayerStateData1ImageIndex] ; (image index is locked to standing images) cp SPRITE_FACING_UP jr nz, .skipHidingFishingRod - ld a, $a0 + ld a, SCREEN_HEIGHT_PX + OAM_Y_OFS ld [wShadowOAMSprite39YCoord], a .skipHidingFishingRod diff --git a/engine/overworld/push_boulder.asm b/engine/overworld/push_boulder.asm index 2328b07a..5e7393d2 100644 --- a/engine/overworld/push_boulder.asm +++ b/engine/overworld/push_boulder.asm @@ -43,7 +43,7 @@ TryPushingBoulder:: jr z, .pushBoulderLeft cp SPRITE_FACING_RIGHT jr z, .pushBoulderRight -.pushBoulderDown +; push boulder down bit B_PAD_DOWN, b ret z ld de, PushBoulderDownMovementData diff --git a/engine/overworld/missable_objects.asm b/engine/overworld/toggleable_objects.asm index bcaa731b..a97f2bd2 100644 --- a/engine/overworld/missable_objects.asm +++ b/engine/overworld/toggleable_objects.asm @@ -1,4 +1,4 @@ -MarkTownVisitedAndLoadMissableObjects:: +MarkTownVisitedAndLoadToggleableObjects:: ld a, [wCurMap] cp FIRST_ROUTE_MAP jr nc, .notInTown @@ -7,22 +7,23 @@ MarkTownVisitedAndLoadMissableObjects:: ld hl, wTownVisitedFlag ; mark town as visited (for flying) predef FlagActionPredef .notInTown - ld hl, MapHSPointers + ld hl, ToggleableObjectMapPointers ld a, [wCurMap] ld b, $0 ld c, a add hl, bc add hl, bc - ld a, [hli] ; load missable objects pointer in hl + ld a, [hli] ; load toggleable objects pointer in hl ld h, [hl] ld l, a push hl ld a, l - sub LOW(MissableObjects) ; calculate difference between out pointer and the base pointer + sub LOW(ToggleableObjectStates) ; calculate difference between out pointer and the base pointer ld l, a ld a, h - sbc HIGH(MissableObjects) + sbc HIGH(ToggleableObjectStates) ld h, a + ; divide difference by 3, resulting in the global offset (number of toggleable items before ours) ld a, h ldh [hDividend], a ld a, l @@ -33,14 +34,14 @@ MarkTownVisitedAndLoadMissableObjects:: ld a, $3 ldh [hDivisor], a ld b, $2 - call Divide ; divide difference by 3, resulting in the global offset (number of missable items before ours) + call Divide ld a, [wCurMap] ld b, a ldh a, [hDividend+3] ld c, a ; store global offset in c - ld de, wMissableObjectList + ld de, wToggleableObjectList pop hl -.writeMissableObjectsListLoop +.writeToggleableObjectsListLoop ld a, [hli] cp -1 jr z, .done ; end of list @@ -52,92 +53,92 @@ MarkTownVisitedAndLoadMissableObjects:: inc de ld a, c inc c - ld [de], a ; write (global) missable object index + ld [de], a ; write (global) toggleable object index inc de - jr .writeMissableObjectsListLoop + jr .writeToggleableObjectsListLoop .done ld a, -1 ld [de], a ; write sentinel ret -InitializeMissableObjectsFlags: - ld hl, wMissableObjectFlags - ld bc, wMissableObjectFlagsEnd - wMissableObjectFlags +InitializeToggleableObjectsFlags: + ld hl, wToggleableObjectFlags + ld bc, wToggleableObjectFlagsEnd - wToggleableObjectFlags xor a - call FillMemory ; clear missable objects flags - ld hl, MissableObjects + call FillMemory ; clear toggleable objects flags + ld hl, ToggleableObjectStates xor a - ld [wMissableObjectCounter], a -.missableObjectsLoop + ld [wToggleableObjectCounter], a +.toggleableObjectsLoop ld a, [hli] - cp -1 ; end of list + cp -1 ; end of list ret z push hl inc hl ld a, [hl] - cp HIDE + cp OFF jr nz, .skip - ld hl, wMissableObjectFlags - ld a, [wMissableObjectCounter] + ld hl, wToggleableObjectFlags + ld a, [wToggleableObjectCounter] ld c, a ld b, FLAG_SET - call MissableObjectFlagAction ; set flag if Item is hidden + call ToggleableObjectFlagAction ; set flag if object is toggled off .skip - ld hl, wMissableObjectCounter + ld hl, wToggleableObjectCounter inc [hl] pop hl inc hl inc hl - jr .missableObjectsLoop + jr .toggleableObjectsLoop -; tests if current sprite is a missable object that is hidden/has been removed +; tests if current object is toggled off/has been hidden IsObjectHidden: ldh a, [hCurrentSpriteOffset] swap a ld b, a - ld hl, wMissableObjectList + ld hl, wToggleableObjectList .loop ld a, [hli] cp -1 - jr z, .notHidden ; not missable -> not hidden + jr z, .notHidden ; not toggleable -> not hidden cp b ld a, [hli] jr nz, .loop ld c, a ld b, FLAG_TEST - ld hl, wMissableObjectFlags - call MissableObjectFlagAction + ld hl, wToggleableObjectFlags + call ToggleableObjectFlagAction ld a, c and a jr nz, .hidden .notHidden xor a .hidden - ldh [hIsHiddenMissableObject], a + ldh [hIsToggleableObjectOff], a ret -; adds missable object (items, leg. pokemon, etc.) to the map -; [wMissableObjectIndex]: index of the missable object to be added (global index) +; adds toggleable object (items, leg. pokemon, etc.) to the map +; [wToggleableObjectIndex]: index of the toggleable object to be added (global index) ShowObject: ShowObject2: - ld hl, wMissableObjectFlags - ld a, [wMissableObjectIndex] + ld hl, wToggleableObjectFlags + ld a, [wToggleableObjectIndex] ld c, a ld b, FLAG_RESET - call MissableObjectFlagAction ; reset "removed" flag + call ToggleableObjectFlagAction ; reset "removed" flag jp UpdateSprites -; removes missable object (items, leg. pokemon, etc.) from the map -; [wMissableObjectIndex]: index of the missable object to be removed (global index) +; removes toggleable object (items, leg. pokemon, etc.) from the map +; [wToggleableObjectIndex]: index of the toggleable object to be removed (global index) HideObject: - ld hl, wMissableObjectFlags - ld a, [wMissableObjectIndex] + ld hl, wToggleableObjectFlags + ld a, [wToggleableObjectIndex] ld c, a ld b, FLAG_SET - call MissableObjectFlagAction ; set "removed" flag + call ToggleableObjectFlagAction ; set "removed" flag jp UpdateSprites -MissableObjectFlagAction: +ToggleableObjectFlagAction: ; identical to FlagAction push hl @@ -174,10 +175,10 @@ MissableObjectFlagAction: ld a, b and a jr z, .reset - cp 2 + cp FLAG_TEST jr z, .read -.set +; set ld a, [hl] ld b, a ld a, d diff --git a/engine/overworld/unused_load_missable_object_data.asm b/engine/overworld/unused_load_toggleable_object_data.asm index 8a519350..cf53f80a 100644 --- a/engine/overworld/unused_load_missable_object_data.asm +++ b/engine/overworld/unused_load_toggleable_object_data.asm @@ -1,9 +1,9 @@ Func_f0a54: ; unreferenced ret -LoadMissableObjectData:: +LoadToggleableObjectData:: ; farcalled by an unreferenced function - ld hl, .MissableObjectsMaps + ld hl, .ToggleableObjectsMaps .loop ld a, [hli] cp -1 @@ -24,23 +24,23 @@ LoadMissableObjectData:: ld a, [hli] ld h, [hl] ld l, a - ld de, wMissableObjectList + ld de, wToggleableObjectList call CopyData ret -MACRO missable_object_map +MACRO toggleable_object_map db \1 db \3 - \2 dw \2 ENDM -.MissableObjectsMaps: - missable_object_map BLUES_HOUSE, .BluesHouse, .BluesHouseEnd +.ToggleableObjectsMaps: + toggleable_object_map BLUES_HOUSE, .BluesHouse, .BluesHouseEnd db -1 ; end .BluesHouse: - db 1, HS_DAISY_SITTING_COPY - db 2, HS_DAISY_WALKING_COPY - db 3, HS_TOWN_MAP_COPY + db 1, TOGGLE_DAISY_SITTING_COPY + db 2, TOGGLE_DAISY_WALKING_COPY + db 3, TOGGLE_TOWN_MAP_COPY db -1 ; end .BluesHouseEnd: diff --git a/engine/pokemon/add_mon.asm b/engine/pokemon/add_mon.asm index a0b1ef0a..24d360b2 100644 --- a/engine/pokemon/add_mon.asm +++ b/engine/pokemon/add_mon.asm @@ -59,7 +59,7 @@ _AddPartyMon:: .next3 ldh a, [hNewPartyLength] dec a - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld e, l ld d, h @@ -117,12 +117,12 @@ _AddPartyMon:: .next4 push bc - ld bc, wPartyMon1DVs - wPartyMon1 + ld bc, MON_DVS add hl, bc pop bc ld [hli], a ld [hl], b ; write IVs - ld bc, (wPartyMon1HPExp - 1) - (wPartyMon1DVs + 1) + ld bc, (MON_HP_EXP - 1) - (MON_DVS + 1) add hl, bc ld a, 1 ld c, a @@ -142,7 +142,7 @@ _AddPartyMon:: inc de jr .copyMonTypesAndMoves .copyEnemyMonData - ld bc, wEnemyMon1DVs - wEnemyMon1 + ld bc, MON_DVS add hl, bc ld a, [wEnemyMonDVs] ; copy IVs from cur enemy mon ld [hli], a @@ -237,13 +237,13 @@ _AddPartyMon:: dec a jr nz, .calcFreshStats ld hl, wEnemyMonMaxHP - ld bc, $a + ld bc, NUM_STATS * 2 call CopyData ; copy stats of cur enemy mon pop hl jr .done .calcFreshStats pop hl - ld bc, wPartyMon1HPExp - 1 - wPartyMon1 + ld bc, MON_HP_EXP - 1 add hl, bc ld b, $0 call CalcStats ; calculate fresh set of stats @@ -300,7 +300,7 @@ _AddEnemyMonToPlayerParty:: ld hl, wPartyMons ld a, [wPartyCount] dec a - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld e, l ld d, h @@ -381,16 +381,16 @@ _MoveMon:: .copySpecies ld [hli], a ; write new mon ID ld [hl], $ff ; write new sentinel -.findMonDataDest +; find mon data dest ld a, [wMoveMonType] dec a ld hl, wPartyMons - ld bc, wPartyMon2 - wPartyMon1 ; $2c + ld bc, PARTYMON_STRUCT_LENGTH ld a, [wPartyCount] jr nz, .addMonOffset ; if it's PARTY_TO_BOX ld hl, wBoxMons - ld bc, wBoxMon2 - wBoxMon1 ; $21 + ld bc, BOXMON_STRUCT_LENGTH ld a, [wBoxCount] .addMonOffset dec a @@ -402,20 +402,20 @@ _MoveMon:: ld a, [wMoveMonType] and a ld hl, wBoxMons - ld bc, wBoxMon2 - wBoxMon1 ; $21 + ld bc, BOXMON_STRUCT_LENGTH jr z, .addMonOffset2 cp DAYCARE_TO_PARTY ld hl, wDayCareMon jr z, .copyMonData ld hl, wPartyMons - ld bc, wPartyMon2 - wPartyMon1 ; $2c + ld bc, PARTYMON_STRUCT_LENGTH .addMonOffset2 ld a, [wWhichPokemon] call AddNTimes .copyMonData push hl push de - ld bc, wBoxMon2 - wBoxMon1 + ld bc, BOXMON_STRUCT_LENGTH call CopyData pop de pop hl @@ -424,7 +424,7 @@ _MoveMon:: jr z, .findOTdest cp DAYCARE_TO_PARTY jr z, .findOTdest - ld bc, wBoxMon2 - wBoxMon1 + ld bc, BOXMON_STRUCT_LENGTH add hl, bc ld a, [hl] ; hl = Level inc de @@ -463,7 +463,7 @@ _MoveMon:: ld bc, NAME_LENGTH call CopyData ld a, [wMoveMonType] -.findNickDest +; find nick dest cp PARTY_TO_DAYCARE ld de, wDayCareMonName jr z, .findNickSrc @@ -499,6 +499,7 @@ _MoveMon:: jr z, .done cp PARTY_TO_DAYCARE jr z, .done + ; returning mon to party, compute level and stats push hl srl a add $2 @@ -508,13 +509,13 @@ _MoveMon:: ld a, d ld [wCurEnemyLevel], a pop hl - ld bc, wBoxMon2 - wBoxMon1 - add hl, bc + ld bc, BOXMON_STRUCT_LENGTH + add hl, bc ; hl = wPartyMon*Level ld [hli], a ld d, h ld e, l - ld bc, -18 - add hl, bc + ld bc, (MON_HP_EXP - 1) - MON_STATS + add hl, bc ; hl = wPartyMon*HPExp - 1 ld b, $1 call CalcStats .done diff --git a/engine/pokemon/bills_pc.asm b/engine/pokemon/bills_pc.asm index e82b41b0..c8f24560 100644 --- a/engine/pokemon/bills_pc.asm +++ b/engine/pokemon/bills_pc.asm @@ -393,11 +393,11 @@ BoxNoPCText: KnowsHMMove:: ; returns whether mon with party index [wWhichPokemon] knows an HM move ld hl, wPartyMon1Moves - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH jr .next ; unreachable ld hl, wBoxMon1Moves - ld bc, wBoxMon2 - wBoxMon1 + ld bc, BOXMON_STRUCT_LENGTH .next ld a, [wWhichPokemon] call AddNTimes diff --git a/engine/pokemon/evos_moves.asm b/engine/pokemon/evos_moves.asm index 1f0d265f..f4d5039a 100644 --- a/engine/pokemon/evos_moves.asm +++ b/engine/pokemon/evos_moves.asm @@ -179,13 +179,13 @@ Evolution_PartyMonLoop: ; loop over party mons call CalcStats ld a, [wWhichPokemon] ld hl, wPartyMon1 - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld e, l ld d, h push hl push bc - ld bc, wPartyMon1MaxHP - wPartyMon1 + ld bc, MON_MAXHP add hl, bc ld a, [hli] ld b, a @@ -345,7 +345,7 @@ LearnMoveFromLevelUp: ; If it is not 0, this function will not work properly. ld hl, wPartyMon1Moves ld a, [wWhichPokemon] - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes .next ld b, NUM_MOVES @@ -559,7 +559,7 @@ WriteMonMoves: ; shift PP as well if learning moves from day care push de - ld bc, wPartyMon1PP - (wPartyMon1Moves + 3) + ld bc, MON_PP - (MON_MOVES + 3) add hl, bc ld d, h ld e, l @@ -578,7 +578,7 @@ WriteMonMoves: ; write move PP value if learning moves from day care push hl ld a, [hl] - ld hl, wPartyMon1PP - wPartyMon1Moves + ld hl, MON_PP - MON_MOVES add hl, de push hl dec a diff --git a/engine/pokemon/learn_move.asm b/engine/pokemon/learn_move.asm index e40b3573..7843cc59 100644 --- a/engine/pokemon/learn_move.asm +++ b/engine/pokemon/learn_move.asm @@ -10,7 +10,7 @@ LearnMove: DontAbandonLearning: ld hl, wPartyMon1Moves - ld bc, wPartyMon2Moves - wPartyMon1Moves + ld bc, PARTYMON_STRUCT_LENGTH ld a, [wWhichPokemon] call AddNTimes ld d, h @@ -38,7 +38,7 @@ DontAbandonLearning: .next ld a, [wMoveNum] ld [hl], a - ld bc, wPartyMon1PP - wPartyMon1Moves + ld bc, MON_PP - MON_MOVES add hl, bc push hl push de @@ -66,7 +66,7 @@ DontAbandonLearning: ld de, wBattleMonMoves ld bc, NUM_MOVES call CopyData - ld bc, wPartyMon1PP - wPartyMon1OTID + ld bc, MON_PP - MON_OTID add hl, bc ld de, wBattleMonPP ld bc, NUM_MOVES diff --git a/engine/pokemon/load_mon_data.asm b/engine/pokemon/load_mon_data.asm index 964db2e4..e46dc2db 100644 --- a/engine/pokemon/load_mon_data.asm +++ b/engine/pokemon/load_mon_data.asm @@ -23,7 +23,7 @@ LoadMonData_:: call GetMonHeader ld hl, wPartyMons - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH ld a, [wMonDataLocation] cp ENEMY_PARTY_DATA jr c, .getMonEntry @@ -31,9 +31,9 @@ LoadMonData_:: ld hl, wEnemyMons jr z, .getMonEntry - cp 2 + cp BOX_DATA ld hl, wBoxMons - ld bc, wBoxMon2 - wBoxMon1 + ld bc, BOXMON_STRUCT_LENGTH jr z, .getMonEntry ld hl, wDayCareMon @@ -45,7 +45,7 @@ LoadMonData_:: .copyMonData ld de, wLoadedMon - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH jp CopyData ; get species of mon e in list [wMonDataLocation] for LoadMonData diff --git a/engine/pokemon/remove_mon.asm b/engine/pokemon/remove_mon.asm index 60ec8c27..ee47f0c8 100644 --- a/engine/pokemon/remove_mon.asm +++ b/engine/pokemon/remove_mon.asm @@ -2,15 +2,16 @@ _RemovePokemon:: ld hl, wPartyCount ld a, [wRemoveMonFromBox] and a - jr z, .usePartyCount + jr z, .gotCount ld hl, wBoxCount -.usePartyCount +.gotCount ld a, [hl] dec a ld [hli], a + ld a, [wWhichPokemon] ld c, a - ld b, $0 + ld b, 0 add hl, bc ld e, l ld d, h @@ -21,21 +22,27 @@ _RemovePokemon:: ld [hli], a inc a ; reached terminator? jr nz, .shiftMonSpeciesLoop ; if not, continue shifting species + ld hl, wPartyMonOT ld d, PARTY_LENGTH - 1 ; max number of pokemon to shift ld a, [wRemoveMonFromBox] and a - jr z, .usePartyMonOTs + jr z, .gotOTsPointer ld hl, wBoxMonOT ld d, MONS_PER_BOX - 1 -.usePartyMonOTs +.gotOTsPointer ld a, [wWhichPokemon] call SkipFixedLengthTextEntries ld a, [wWhichPokemon] cp d ; are we removing the last pokemon? jr nz, .notRemovingLastMon ; if not, shift the pokemon below - ld [hl], $ff ; else, write the terminator and return + + ; bug: to erase a string, this should be ld [hl], '@' + ; This is not needed, as wBoxSpecies/wPartySpecies determine if a slot is used. + ; Besides, existing mon nick is left untouched + ld [hl], $ff ret + .notRemovingLastMon ld d, h ld e, l @@ -44,44 +51,49 @@ _RemovePokemon:: ld bc, wPartyMonNicks ld a, [wRemoveMonFromBox] and a - jr z, .usePartyMonNicks + jr z, .gotNicksPointer ld bc, wBoxMonNicks -.usePartyMonNicks +.gotNicksPointer call CopyDataUntil + ld hl, wPartyMons - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH ld a, [wRemoveMonFromBox] and a - jr z, .usePartyMonStructs + jr z, .gotMonStructs ld hl, wBoxMons - ld bc, wBoxMon2 - wBoxMon1 -.usePartyMonStructs + ld bc, BOXMON_STRUCT_LENGTH +.gotMonStructs ld a, [wWhichPokemon] call AddNTimes ; get address of the pokemon removed - ld d, h ; store in de for CopyDataUntil + + ld d, h ; de = start address for CopyDataUntil ld e, l ld a, [wRemoveMonFromBox] and a - jr z, .copyUntilPartyMonOTs - ld bc, wBoxMon2 - wBoxMon1 - add hl, bc ; get address of pokemon after the pokemon removed - ld bc, wBoxMonOT ; address of when to stop copying - jr .continue -.copyUntilPartyMonOTs - ld bc, wPartyMon2 - wPartyMon1 - add hl, bc ; get address of pokemon after the pokemon removed - ld bc, wPartyMonOT ; address of when to stop copying -.continue - call CopyDataUntil ; shift all pokemon data after the removed mon to the removed mon's location + jr z, .copyUntilPartyMonOT +; copy until wBoxMonOT + ld bc, BOXMON_STRUCT_LENGTH + add hl, bc ; get address of next slot + ld bc, wBoxMonOT + jr .shiftOTs +.copyUntilPartyMonOT + ld bc, PARTYMON_STRUCT_LENGTH + add hl, bc ; get address of next slot + ld bc, wPartyMonOT +.shiftOTs + call CopyDataUntil ; shift all pokemon data up one slot + ld hl, wPartyMonNicks ld a, [wRemoveMonFromBox] and a - jr z, .usePartyMonNicks2 + jr z, .gotNicksPointer2 ld hl, wBoxMonNicks -.usePartyMonNicks2 +.gotNicksPointer2 ld bc, NAME_LENGTH ld a, [wWhichPokemon] call AddNTimes + ld d, h ld e, l ld bc, NAME_LENGTH @@ -89,7 +101,7 @@ _RemovePokemon:: ld bc, wPartyMonNicksEnd ld a, [wRemoveMonFromBox] and a - jr z, .copyUntilPartyMonNicksEnd + jr z, .shiftMonNicks ld bc, wBoxMonNicksEnd -.copyUntilPartyMonNicksEnd - jp CopyDataUntil +.shiftMonNicks + jp CopyDataUntil ; shift all pokemon nicknames up one slot diff --git a/engine/pokemon/set_types.asm b/engine/pokemon/set_types.asm index 2cf8f14c..d42c3cf3 100644 --- a/engine/pokemon/set_types.asm +++ b/engine/pokemon/set_types.asm @@ -1,7 +1,7 @@ ; updates the types of a party mon (pointed to in hl) to the ones of the mon specified in [wPokedexNum] SetPartyMonTypes: call GetPredefRegisters - ld bc, wPartyMon1Type - wPartyMon1 ; $5 + ld bc, MON_TYPE add hl, bc ld a, [wPokedexNum] ld [wCurSpecies], a diff --git a/engine/pokemon/status_ailments.asm b/engine/pokemon/status_ailments.asm index 2c5b3bcd..3cc2d490 100644 --- a/engine/pokemon/status_ailments.asm +++ b/engine/pokemon/status_ailments.asm @@ -10,37 +10,17 @@ PrintStatusAilment:: jr nz, .par and SLP_MASK ret z - ld a, 'S' - ld [hli], a - ld a, 'L' - ld [hli], a - ld [hl], 'P' + ld_hli_a_string "SLP" ret .psn - ld a, 'P' - ld [hli], a - ld a, 'S' - ld [hli], a - ld [hl], 'N' + ld_hli_a_string "PSN" ret .brn - ld a, 'B' - ld [hli], a - ld a, 'R' - ld [hli], a - ld [hl], 'N' + ld_hli_a_string "BRN" ret .frz - ld a, 'F' - ld [hli], a - ld a, 'R' - ld [hli], a - ld [hl], 'Z' + ld_hli_a_string "FRZ" ret .par - ld a, 'P' - ld [hli], a - ld a, 'A' - ld [hli], a - ld [hl], 'R' + ld_hli_a_string "PAR" ret diff --git a/engine/pokemon/status_screen.asm b/engine/pokemon/status_screen.asm index 638f4c41..7e8ad615 100644 --- a/engine/pokemon/status_screen.asm +++ b/engine/pokemon/status_screen.asm @@ -61,8 +61,6 @@ DrawHP_: pop de ret - -; Predef 0x37 StatusScreen: call LoadMonData ld a, [wMonDataLocation] @@ -75,7 +73,7 @@ StatusScreen: ld hl, wLoadedMonHPExp - 1 ld de, wLoadedMonStats ld b, $1 - call CalcStats ; Recalculate stats + call CalcStats .DontRecalculate ld hl, wStatusFlags2 set BIT_NO_AUDIO_FADE_OUT, [hl] @@ -117,8 +115,8 @@ StatusScreen: lb bc, 8, 6 call DrawLineBox ; Draws the box around types, ID No. and OT hlcoord 10, 9 - ld de, Type1Text - call PlaceString ; "TYPE1/" + ld de, TypesIDNoOTText + call PlaceString hlcoord 11, 3 predef DrawHP ld hl, wStatusScreenHPBarColor @@ -137,7 +135,7 @@ StatusScreen: ld de, StatusText call PlaceString ; "STATUS/" hlcoord 14, 2 - call PrintLevel ; Pokémon level + call PrintLevel ld a, [wMonHIndex] ld [wPokedexNum], a ld [wCurSpecies], a @@ -164,7 +162,7 @@ StatusScreen: ld de, wLoadedMonOTID lb bc, LEADING_ZEROES | 2, 5 call PrintNumber ; ID Number - ld d, $0 + ld d, STATUS_SCREEN_STATS_BOX call PrintStatsBox call Delay3 call GBPalNormal @@ -221,20 +219,11 @@ NamePointers2: dw wBoxMonNicks dw wDayCareMonName -Type1Text: +TypesIDNoOTText: db "TYPE1/" - next "" - ; fallthrough -Type2Text: - db "TYPE2/" - next "" - ; fallthrough -IDNoText: - db "<ID>№/" - next "" - ; fallthrough -OTText: - db "OT/" + next "TYPE2/" + next "<ID>№/" + next "OT/" next "@" StatusText: @@ -265,38 +254,40 @@ PTile: INCBIN "gfx/font/P.1bpp" PrintStatsBox: ld a, d - and a ; a is 0 from the status screen - jr nz, .DifferentBox + ASSERT STATUS_SCREEN_STATS_BOX == 0 + and a + jr nz, .LevelUpStatsBox ; battle or Rare Candy hlcoord 0, 8 lb bc, 8, 8 - call TextBoxBorder ; Draws the box - hlcoord 1, 9 ; Start printing stats from here - ld bc, $19 ; Number offset + call TextBoxBorder + hlcoord 1, 9 + ld bc, SCREEN_WIDTH + 5 ; one row down and 5 columns right jr .PrintStats -.DifferentBox +.LevelUpStatsBox hlcoord 9, 2 lb bc, 8, 9 call TextBoxBorder hlcoord 11, 3 - ld bc, $18 + ld bc, SCREEN_WIDTH + 4 ; one row down and 4 columns right .PrintStats push bc push hl - ld de, StatsText + ld de, .StatsText call PlaceString pop hl pop bc add hl, bc ld de, wLoadedMonAttack lb bc, 2, 3 - call PrintStat + call .PrintStat ld de, wLoadedMonDefense - call PrintStat + call .PrintStat ld de, wLoadedMonSpeed - call PrintStat + call .PrintStat ld de, wLoadedMonSpecial jp PrintNumber -PrintStat: + +.PrintStat: push hl call PrintNumber pop hl @@ -304,7 +295,7 @@ PrintStat: add hl, de ret -StatsText: +.StatsText: db "ATTACK" next "DEFENSE" next "SPEED" @@ -337,10 +328,10 @@ StatusScreen2: call PlaceString ; Print moves ld a, [wNumMovesMinusOne] inc a - ld c, a - ld a, $4 + ld c, a ; number of known moves + ld a, NUM_MOVES sub c - ld b, a ; Number of moves ? + ld b, a ; number of blank moves hlcoord 11, 10 ld de, SCREEN_WIDTH * 2 ld a, '<BOLD_P>' @@ -375,7 +366,7 @@ StatusScreen2: pop de pop hl push hl - ld bc, wPartyMon1PP - wPartyMon1Moves - 1 + ld bc, MON_PP - MON_MOVES - 1 add hl, bc ld a, [hl] and PP_MASK @@ -400,7 +391,7 @@ StatusScreen2: pop bc inc b ld a, b - cp $4 + cp NUM_MOVES jr nz, .PrintPP .PPDone hlcoord 9, 3 @@ -429,8 +420,11 @@ StatusScreen2: hlcoord 7, 6 lb bc, 3, 7 call PrintNumber ; exp needed to level up + + ; unneeded, this clears the diacritic characters in JPN versions hlcoord 9, 0 call StatusScreen_ClearName + hlcoord 9, 1 call StatusScreen_ClearName ld a, [wMonHIndex] @@ -482,7 +476,7 @@ StatusScreenExpText: next "LEVEL UP@" StatusScreen_ClearName: - ld bc, 10 + ld bc, NAME_LENGTH - 1 ld a, ' ' jp FillMemory diff --git a/engine/slots/game_corner_slots.asm b/engine/slots/game_corner_slots.asm index 48321974..d83d9d6a 100644 --- a/engine/slots/game_corner_slots.asm +++ b/engine/slots/game_corner_slots.asm @@ -1,5 +1,5 @@ StartSlotMachine: - ld a, [wHiddenObjectFunctionArgument] + ld a, [wHiddenEventFunctionArgument] cp SLOTS_OUTOFORDER jr z, .printOutOfOrder cp SLOTS_OUTTOLUNCH @@ -10,9 +10,9 @@ StartSlotMachine: ld a, [wCanPlaySlots] and a ret z - ld a, [wLuckySlotHiddenObjectIndex] + ld a, [wLuckySlotHiddenEventIndex] ld b, a - ld a, [wHiddenObjectIndex] + ld a, [wHiddenEventIndex] inc a cp b jr z, .match diff --git a/engine/slots/slot_machine.asm b/engine/slots/slot_machine.asm index e3363db3..fbbdbcb6 100644 --- a/engine/slots/slot_machine.asm +++ b/engine/slots/slot_machine.asm @@ -448,7 +448,7 @@ SlotMachine_CheckForMatches: ld h, [hl] ld l, a ld de, wStringBuffer - ld bc, 4 + ld bc, 4 ; every SlotReward*Text is at most 4 bytes call CopyData pop hl ld de, .flashScreenLoop |
