diff options
Diffstat (limited to 'engine')
108 files changed, 2265 insertions, 2255 deletions
diff --git a/engine/battle/ai/items.asm b/engine/battle/ai/items.asm index 29bc23b20..28dfb1010 100644 --- a/engine/battle/ai/items.asm +++ b/engine/battle/ai/items.asm @@ -806,7 +806,7 @@ EnemyUsedXItem: push bc call PrintText_UsedItemOn pop bc - farcall CheckIfStatCanBeRaised + farcall RaiseStat jp AIUpdateHUD ; Parameter @@ -818,7 +818,7 @@ PrintText_UsedItemOn_AND_AIUpdateHUD: PrintText_UsedItemOn: ld a, [wCurEnemyItem] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetItemName ld hl, wStringBuffer1 ld de, wMonOrItemNameBuffer diff --git a/engine/battle/ai/scoring.asm b/engine/battle/ai/scoring.asm index 6928a3a83..752796892 100644 --- a/engine/battle/ai/scoring.asm +++ b/engine/battle/ai/scoring.asm @@ -171,10 +171,10 @@ AI_Types: pop bc pop hl - ld a, [wd265] + ld a, [wTypeMatchup] and a jr z, .immune - cp 10 ; 1.0 + cp EFFECTIVE jr z, .checkmove jr c, .noteffective @@ -415,8 +415,8 @@ AI_Smart_LeechHit: pop hl ; 60% chance to discourage this move if not very effective. - ld a, [wd265] - cp 10 ; 1.0 + ld a, [wTypeMatchup] + cp EFFECTIVE jr c, .asm_38815 ; Do nothing if effectiveness is neutral. @@ -491,8 +491,8 @@ AI_Smart_LockOn: push hl push bc farcall BattleCheckTypeMatchup - ld a, [wd265] - cp $a + ld a, [wTypeMatchup] + cp EFFECTIVE pop bc pop hl jr c, .asm_3884f @@ -1292,8 +1292,8 @@ AI_Smart_Mimic: ld [hBattleTurn], a callfar BattleCheckTypeMatchup - ld a, [wd265] - cp $a + ld a, [wTypeMatchup] + cp EFFECTIVE pop hl jr c, .asm_38bef jr z, .asm_38bd4 @@ -1408,8 +1408,8 @@ AI_Smart_Encore: predef CheckTypeMatchup pop hl - ld a, [wd265] - cp $a + ld a, [wTypeMatchup] + cp EFFECTIVE jr nc, .asm_38c68 and a @@ -1550,7 +1550,7 @@ AI_Smart_Spite: dec [hl] ret -Function_0x38d16 +Function_0x38d16: jp AIDiscourageMove AI_Smart_DestinyBond: @@ -1679,8 +1679,8 @@ AI_Smart_Conversion2: callfar BattleCheckTypeMatchup - ld a, [wd265] - cp $a + ld a, [wTypeMatchup] + cp EFFECTIVE pop hl jr c, .asm_38dc9 ret z @@ -2293,8 +2293,8 @@ AI_Smart_HiddenPower: pop hl ; Discourage Hidden Power if not very effective. - ld a, [wd265] - cp 10 + ld a, [wTypeMatchup] + cp EFFECTIVE jr c, .bad ; Discourage Hidden Power if its base power is lower than 50. @@ -2303,8 +2303,8 @@ AI_Smart_HiddenPower: jr c, .bad ; Encourage Hidden Power if super-effective. - ld a, [wd265] - cp 11 + ld a, [wTypeMatchup] + cp EFFECTIVE + 1 jr nc, .good ; Encourage Hidden Power if its base power is 70. @@ -3125,7 +3125,7 @@ AI_Status: pop bc pop hl - ld a, [wd265] + ld a, [wTypeMatchup] and a jr nz, .checkmove diff --git a/engine/battle/ai/switch.asm b/engine/battle/ai/switch.asm index b9bd2ea60..b12087e23 100644 --- a/engine/battle/ai/switch.asm +++ b/engine/battle/ai/switch.asm @@ -30,11 +30,11 @@ CheckPlayerMoveTypeMatchups: ld hl, wEnemyMonType call CheckTypeMatchup ld a, [wTypeMatchup] - cp 10 + 1 ; 1.0 + 0.1 + cp EFFECTIVE + 1 ; 1.0 + 0.1 jr nc, .super_effective and a jr z, .next - cp 10 ; 1.0 + cp EFFECTIVE ; 1.0 jr nc, .neutral .not_very_effective @@ -75,7 +75,7 @@ CheckPlayerMoveTypeMatchups: ld hl, wEnemyMonType1 call CheckTypeMatchup ld a, [wTypeMatchup] - cp 10 + 1 ; 1.0 + 0.1 + cp EFFECTIVE + 1 ; 1.0 + 0.1 jr c, .ok call .DecreaseScore .ok @@ -84,7 +84,7 @@ CheckPlayerMoveTypeMatchups: jr z, .ok2 call CheckTypeMatchup ld a, [wTypeMatchup] - cp 10 + 1 ; 1.0 + 0.1 + cp EFFECTIVE + 1 ; 1.0 + 0.1 jr c, .ok2 call .DecreaseScore .ok2 @@ -130,7 +130,7 @@ CheckPlayerMoveTypeMatchups: ; not very effective inc c - cp 10 + cp EFFECTIVE jr c, .loop2 ; neutral @@ -139,7 +139,7 @@ CheckPlayerMoveTypeMatchups: inc c inc c inc c - cp 10 + cp EFFECTIVE jr z, .loop2 ; super effective @@ -481,7 +481,7 @@ FindEnemyMonsWithASuperEffectiveMove: ; if neutral: load 1 and continue ld e, 1 - cp 10 + 1 + cp EFFECTIVE + 1 jr c, .nope ; if super-effective: load 2 and break @@ -584,7 +584,7 @@ FindEnemyMonsThatResistPlayer: ld hl, wBaseType call CheckTypeMatchup ld a, [wTypeMatchup] - cp 10 + 1 + cp EFFECTIVE + 1 jr nc, .dont_choose_mon ld a, b diff --git a/engine/battle/core.asm b/engine/battle/core.asm index c3c7e9867..2d5e85cef 100644 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -373,7 +373,7 @@ HandleBerserkGene: push bc callfar GetUserItem ld a, [hl] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a sub BERSERK_GENE pop bc pop de @@ -447,7 +447,7 @@ DetermineMoveOrder: sub BATTLEACTION_SWITCH1 jr c, .use_move ld a, [wBattlePlayerAction] - cp $2 + cp BATTLEPLAYERACTION_SWITCH jr nz, .switch ld a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK @@ -472,7 +472,7 @@ DetermineMoveOrder: .use_move ld a, [wBattlePlayerAction] - and a + and a ; BATTLEPLAYERACTION_USEMOVE? jp nz, .player_first call CompareMovePriority jr z, .equal_priority @@ -530,7 +530,7 @@ DetermineMoveOrder: ld de, wBattleMonSpeed ld hl, wEnemyMonSpeed ld c, 2 - call StringCmp + call CompareBytes jr z, .speed_tie jp nc, .player_first jp .enemy_first @@ -611,7 +611,7 @@ ParsePlayerAction: .not_encored ld a, [wBattlePlayerAction] - cp $2 + cp BATTLEPLAYERACTION_SWITCH jr z, .reset_rage and a jr nz, .reset_bide @@ -900,7 +900,7 @@ Battle_EnemyFirst: call ResidualDamage jp z, HandlePlayerMonFaint call RefreshBattleHuds - xor a + xor a ; BATTLEPLAYERACTION_USEMOVE ld [wBattlePlayerAction], a ret @@ -949,7 +949,7 @@ Battle_PlayerFirst: call ResidualDamage jp z, HandleEnemyMonFaint call RefreshBattleHuds - xor a + xor a ; BATTLEPLAYERACTION_USEMOVE ld [wBattlePlayerAction], a ret @@ -1161,7 +1161,7 @@ HandlePerishSong: ret z dec [hl] ld a, [hl] - ld [wd265], a + ld [wDeciramBuffer], a push af ld hl, PerishCountText call StdBattleTextBox @@ -1235,7 +1235,7 @@ HandleWrap: ret nz ld a, [de] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a ld [wFXAnimID], a call GetMoveName dec [hl] @@ -1288,7 +1288,7 @@ HandleLeftovers: callfar GetUserItem ld a, [hl] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetItemName ld a, b cp HELD_LEFTOVERS @@ -1397,7 +1397,7 @@ HandleMysteryberry: push bc push bc ld a, [hl] - ld [wd265], a + ld [wTempByteValue], a ld de, wBattleMonMoves - 1 ld hl, wBattleMonPP ld a, [hBattleTurn] @@ -1417,7 +1417,7 @@ HandleMysteryberry: pop de pop bc - ld a, [wd265] + ld a, [wTempByteValue] cp [hl] jr nz, .skip_checks ld a, [hBattleTurn] @@ -1434,7 +1434,7 @@ HandleMysteryberry: .skip_checks callfar GetUserItem ld a, [hl] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a xor a ld [hl], a call GetPartymonItem @@ -2048,18 +2048,18 @@ HandleEnemyMonFaint: call CheckMobileBattleError jp c, WildFled_EnemyFled_LinkBattleCanceled - ld a, $1 + ld a, BATTLEPLAYERACTION_USEITEM ld [wBattlePlayerAction], a call HandleEnemySwitch jp z, WildFled_EnemyFled_LinkBattleCanceled jr DoubleSwitch .player_mon_not_fainted - ld a, $1 + ld a, BATTLEPLAYERACTION_USEITEM ld [wBattlePlayerAction], a call HandleEnemySwitch jp z, WildFled_EnemyFled_LinkBattleCanceled - xor a + xor a ; BATTLEPLAYERACTION_USEMOVE ld [wBattlePlayerAction], a ret @@ -2088,7 +2088,7 @@ DoubleSwitch: call PlayerPartyMonEntrance .done - xor a + xor a ; BATTLEPLAYERACTION_USEMOVE ld [wBattlePlayerAction], a ret @@ -2636,7 +2636,7 @@ HandlePlayerMonFaint: ld a, c and a ret nz - ld a, $1 + ld a, BATTLEPLAYERACTION_USEITEM ld [wBattlePlayerAction], a call HandleEnemySwitch jp z, WildFled_EnemyFled_LinkBattleCanceled @@ -2716,12 +2716,12 @@ ForcePlayerMonChoice: ld a, [wLinkMode] and a jr z, .skip_link - ld a, $1 + ld a, BATTLEPLAYERACTION_USEITEM ld [wBattlePlayerAction], a call LinkBattleSendReceiveAction .skip_link - xor a + xor a ; BATTLEPLAYERACTION_USEMOVE ld [wBattlePlayerAction], a call CheckMobileBattleError jr c, .enemy_fainted_mobile_error @@ -3287,8 +3287,8 @@ LookUpTheEffectivenessOfEveryMove: pop bc pop de pop hl - ld a, [wd265] ; Get The Effectiveness Modifier - cp 10 + 1 ; 1.0 + 0.1 + ld a, [wTypeMatchup] + cp EFFECTIVE + 1 jr c, .loop ld hl, wBuffer1 set 0, [hl] @@ -3319,14 +3319,14 @@ IsThePlayerMonTypesEffectiveAgainstOTMon: ld [wPlayerMoveStruct + MOVE_TYPE], a call SetPlayerTurn callfar BattleCheckTypeMatchup - ld a, [wd265] - cp 10 + 1 ; 1.0 + 0.1 + ld a, [wTypeMatchup] + cp EFFECTIVE + 1 jr nc, .super_effective ld a, [wBattleMonType2] ld [wPlayerMoveStruct + MOVE_TYPE], a callfar BattleCheckTypeMatchup - ld a, [wd265] - cp 10 + 1 ; 1.0 + 0.1 + ld a, [wTypeMatchup] + cp EFFECTIVE + 1 jr nc, .super_effective pop bc ret @@ -3619,10 +3619,10 @@ CheckPlayerPartyForFitMon: ld e, a xor a ld hl, wPartyMon1HP - ld bc, wPartyMon2 - (wPartyMon1 + 1) + ld bc, PARTYMON_STRUCT_LENGTH - 1 .loop or [hl] - inc hl + inc hl ; + 1 or [hl] add hl, bc dec e @@ -3695,7 +3695,7 @@ TryToRunAwayFromBattle: push hl push de ld a, [wBattleMonItem] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a ld b, a callfar GetItemHeldEffect ld a, b @@ -3715,33 +3715,33 @@ TryToRunAwayFromBattle: inc a ld [wNumFleeAttempts], a ld a, [hli] - ld [hStringCmpString2 + 0], a + ld [hPartyMon1Speed + 0], a ld a, [hl] - ld [hStringCmpString2 + 1], a + ld [hPartyMon1Speed + 1], a ld a, [de] inc de - ld [hStringCmpString1 + 0], a + ld [hEnemyMonSpeed + 0], a ld a, [de] - ld [hStringCmpString1 + 1], a + ld [hEnemyMonSpeed + 1], a call Call_LoadTempTileMapToTileMap - ld de, hStringCmpString2 - ld hl, hStringCmpString1 - ld c, $2 - call StringCmp + ld de, hPartyMon1Speed + ld hl, hEnemyMonSpeed + ld c, 2 + call CompareBytes jr nc, .can_escape xor a ld [hMultiplicand], a - ld a, $20 + ld a, 32 ld [hMultiplier], a call Multiply ld a, [hProduct + 2] ld [hDividend + 0], a ld a, [hProduct + 3] ld [hDividend + 1], a - ld a, [hStringCmpString1 + 0] + ld a, [hEnemyMonSpeed + 0] ld b, a - ld a, [hStringCmpString1 + 1] + ld a, [hEnemyMonSpeed + 1] srl b rr a srl b @@ -3772,7 +3772,7 @@ TryToRunAwayFromBattle: ld a, [hQuotient + 2] cp b jr nc, .can_escape - ld a, $1 + ld a, BATTLEPLAYERACTION_USEITEM ld [wBattlePlayerAction], a ld hl, BattleText_CantEscape2 jr .print_inescapable_text @@ -3786,7 +3786,7 @@ TryToRunAwayFromBattle: .print_inescapable_text call StdBattleTextBox - ld a, $1 + ld a, TRUE ld [wFailedToFlee], a call LoadTileMapToTempTileMap and a @@ -3798,7 +3798,7 @@ TryToRunAwayFromBattle: ld a, DRAW jr z, .fled call LoadTileMapToTempTileMap - xor a + xor a ; BATTLEPLAYERACTION_USEMOVE ld [wBattlePlayerAction], a ld a, $f ld [wCurMoveNum], a @@ -4429,7 +4429,7 @@ UseConfusionHealingItem: .heal_status ld a, [hl] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a ld a, BATTLE_VARS_SUBSTATUS3_OPP call GetBattleVarAddr res SUBSTATUS_CONFUSED, [hl] @@ -4496,7 +4496,7 @@ HandleStatBoostingHeldItems: jr nz, .loop pop bc ld a, [bc] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a push bc dec hl dec hl @@ -4952,7 +4952,7 @@ BattleMenu_Pack: farcall BattlePack ld a, [wBattlePlayerAction] - and a + and a ; BATTLEPLAYERACTION_USEMOVE? jr z, .didnt_use_item jr .got_item @@ -5157,7 +5157,7 @@ TryPlayerSwitch: jp z, BattleMenuPKMN_Loop ld a, [wCurBattleMon] ld [wLastPlayerMon], a - ld a, $2 + ld a, BATTLEPLAYERACTION_SWITCH ld [wBattlePlayerAction], a call ClearPalettes call DelayFrame @@ -5270,8 +5270,8 @@ PassedBattleMonEntrance: ld [wCurBattleMon], a call AddBattleParticipant call InitBattleMon - xor a - ld [wd265], a + xor a ; FALSE + ld [wApplyStatLevelMultipliersToEnemy], a call ApplyStatLevelMultiplierOnAllStats call SendOutPlayerMon call EmptyBattleTextBox @@ -5286,11 +5286,11 @@ BattleMenu_Run: ld hl, wBattleMonSpeed ld de, wEnemyMonSpeed call TryToRunAwayFromBattle - ld a, $0 + ld a, FALSE ld [wFailedToFlee], a ret c ld a, [wBattlePlayerAction] - and a + and a ; BATTLEPLAYERACTION_USEMOVE? ret nz jp BattleMenu @@ -5770,7 +5770,7 @@ ParseEnemyAction: call EmptyBattleTextBox call LoadTileMapToTempTileMap ld a, [wBattlePlayerAction] - and a + and a ; BATTLEPLAYERACTION_USEMOVE? call z, LinkBattleSendReceiveAction call Call_LoadTempTileMapToTileMap ld a, [wBattleAction] @@ -5989,7 +5989,7 @@ LoadEnemyMon: ; Used for Ho-Oh, Lugia and Snorlax encounters ld a, [wBattleType] cp BATTLETYPE_FORCEITEM - ld a, [wBaseItems] + ld a, [wBaseItem1] jr z, .UpdateItem ; Failing that, it's all up to chance @@ -6007,9 +6007,9 @@ LoadEnemyMon: ; From there, an 8% chance for Item2 call BattleRandom cp 8 percent ; 8% of 25% = 2% Item2 - ld a, [wBaseItems] + ld a, [wBaseItem1] jr nc, .UpdateItem - ld a, [wBaseItems+1] + ld a, [wBaseItem2] .UpdateItem: ld [wEnemyMonItem], a @@ -6375,7 +6375,7 @@ LoadEnemyMon: ld [de], a ld a, [wTempEnemyMonSpecies] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetPokemonName @@ -6661,14 +6661,14 @@ ApplyStatLevelMultiplierOnAllStats: call ApplyStatLevelMultiplier inc c ld a, c - cp 5 + cp NUM_BATTLE_STATS jr nz, .stat_loop ret ApplyStatLevelMultiplier: push bc push bc - ld a, [wd265] + ld a, [wApplyStatLevelMultipliersToEnemy] and a ld a, c ld hl, wBattleMonAttack @@ -6718,7 +6718,7 @@ ApplyStatLevelMultiplier: call Multiply ld a, [hl] ld [hDivisor], a - ld b, $4 + ld b, 4 call Divide pop hl @@ -6992,7 +6992,7 @@ GiveExperiencePoints: ld a, [wCurPartyMon] ld c, a ld b, CHECK_FLAG - ld d, $0 + ld d, FALSE predef SmallFarFlagAction ld a, c and a @@ -7006,7 +7006,7 @@ GiveExperiencePoints: ld e, l ld hl, wEnemyMonBaseStats - 1 push bc - ld c, $5 + ld c, NUM_EXP_STATS .loop1 inc hl ld a, [de] @@ -7113,7 +7113,7 @@ GiveExperiencePoints: push bc call LoadTileMapToTempTileMap pop bc - ld hl, MON_STAT_EXP - 1 + ld hl, MON_EXP + 2 add hl, bc ld d, [hl] ld a, [hQuotient + 2] @@ -7145,7 +7145,7 @@ GiveExperiencePoints: ld d, MAX_LEVEL callfar CalcExpAtLevel pop bc - ld hl, MON_STAT_EXP - 1 + ld hl, MON_EXP + 2 add hl, bc push bc ld a, [hQuotient] @@ -7192,7 +7192,7 @@ GiveExperiencePoints: add hl, bc ld a, [hl] ld [wCurSpecies], a - ld [wd265], a + ld [wTempSpecies], a ; unused? call GetBaseData ld hl, MON_MAXHP + 1 add hl, bc @@ -7256,8 +7256,8 @@ GiveExperiencePoints: call CopyBytes .transformed - xor a - ld [wd265], a + xor a ; FALSE + ld [wApplyStatLevelMultipliersToEnemy], a call ApplyStatLevelMultiplierOnAllStats callfar ApplyStatusEffectOnPlayerStats callfar BadgeStatBoosts @@ -7286,20 +7286,20 @@ GiveExperiencePoints: ld [wMonType], a predef CopyMonToTempMon hlcoord 9, 0 - ld b, $a - ld c, $9 + ld b, 10 + ld c, 9 call TextBox hlcoord 11, 1 ld bc, 4 predef PrintTempMonStats - ld c, $1e + ld c, 30 call DelayFrames call WaitPressAorB_BlinkCursor call Call_LoadTempTileMapToTileMap xor a ; PARTYMON ld [wMonType], a ld a, [wCurSpecies] - ld [wd265], a + ld [wTempSpecies], a ; unused? ld a, [wCurPartyLevel] push af ld c, a @@ -7359,7 +7359,7 @@ GiveExperiencePoints: cp 2 ret c - ld [wd265], a + ld [wTempByteValue], a ld hl, wEnemyMonBaseStats ld c, wEnemyMonEnd - wEnemyMonBaseStats .count_loop2 @@ -7367,7 +7367,7 @@ GiveExperiencePoints: ld [hDividend + 0], a ld a, [hl] ld [hDividend + 1], a - ld a, [wd265] + ld a, [wTempByteValue] ld [hDivisor], a ld b, 2 call Divide @@ -8578,7 +8578,7 @@ ReadAndPrintLinkBattleRecord: db " 0 0 0@" .Format: - db " --- <LNBRK>" + db " --- <LF>" db " - - -@" .Record: db "<PLAYER>'s RECORD@" @@ -8712,7 +8712,7 @@ AddLastMobileBattleToLinkRecord: push de ld bc, 12 ld de, wStringBuffer1 - call CompareLong + call CompareBytesLong pop de pop hl jr c, .done @@ -8821,7 +8821,7 @@ AddLastMobileBattleToLinkRecord: pop hl push bc ld c, 3 - call StringCmp + call CompareBytes pop bc jr z, .equal jr nc, .done2 @@ -9094,7 +9094,7 @@ BattleStartMessage: jr .skip_cry ; cry is played during the animation .cry_no_anim - ld a, $0f + ld a, $f ld [wCryTracks], a ld a, [wTempEnemyMonSpecies] call PlayStereoCry diff --git a/engine/battle/effect_commands.asm b/engine/battle/effect_commands.asm index 3e6d928d2..91c021a72 100644 --- a/engine/battle/effect_commands.asm +++ b/engine/battle/effect_commands.asm @@ -2,7 +2,7 @@ DoPlayerTurn: call SetPlayerTurn ld a, [wBattlePlayerAction] - and a + and a ; BATTLEPLAYERACTION_USEMOVE? ret nz jr DoTurn @@ -1210,7 +1210,9 @@ BattleCommand_Critical: ld [wCriticalHit], a ret -INCLUDE "data/battle/critical_hits.asm" +INCLUDE "data/moves/critical_hit_moves.asm" + +INCLUDE "data/battle/critical_hit_chances.asm" INCLUDE "engine/battle/move_effects/triple_kick.asm" @@ -1246,7 +1248,7 @@ BattleCommand_Stab: .go ld a, BATTLE_VARS_MOVE_TYPE call GetBattleVarAddr - ld [wTypeMatchup], a + ld [wCurType], a push hl push de @@ -1262,7 +1264,7 @@ BattleCommand_Stab: pop bc pop de - ld a, [wTypeMatchup] + ld a, [wCurType] cp b jr z, .stab cp c @@ -2361,10 +2363,12 @@ BattleCommand_SuperEffectiveText: .print jp StdBattleTextBox -BattleCommand_CheckDestinyBond: -; checkdestinybond +BattleCommand_CheckFaint: +; checkfaint -; Faint the user if it fainted an opponent using Destiny Bond. +; Faint the opponent if its HP reached zero +; and faint the user along with it if it used Destiny Bond. +; Ends the move effect if the opponent faints. ld hl, wEnemyMonHP ld a, [hBattleTurn] @@ -2592,7 +2596,7 @@ PlayerAttackDamage: .physicalcrit ld hl, wBattleMonAttack - call GetDamageStatsCritical + call CheckDamageStatsCritical jr c, .thickclub ld hl, wEnemyDefense @@ -2616,7 +2620,7 @@ PlayerAttackDamage: .specialcrit ld hl, wBattleMonSpclAtk - call GetDamageStatsCritical + call CheckDamageStatsCritical jr c, .lightball ld hl, wEnemySpDef @@ -2677,7 +2681,7 @@ TruncateHL_BC: .finish ld a, [wLinkMode] - cp 3 + cp LINK_COLOSSEUM jr z, .done ; If we go back to the loop point, ; it's the same as doing this exact @@ -2690,20 +2694,16 @@ TruncateHL_BC: ld b, l ret -GetDamageStatsCritical: -; Return carry if non-critical. +CheckDamageStatsCritical: +; Return carry if boosted stats should be used in damage calculations. +; Unboosted stats should be used if the attack is a critical hit, +; and the stage of the opponent's defense is higher than the user's attack. ld a, [wCriticalHit] and a scf ret z - ; fallthrough - -GetDamageStats: -; Return the attacker's offensive stat and the defender's defensive -; stat based on whether the attacking type is physical or special. - push hl push bc ld a, [hBattleTurn] @@ -2838,7 +2838,7 @@ EnemyAttackDamage: .physicalcrit ld hl, wEnemyMonAttack - call GetDamageStatsCritical + call CheckDamageStatsCritical jr c, .thickclub ld hl, wPlayerDefense @@ -2862,7 +2862,7 @@ EnemyAttackDamage: .specialcrit ld hl, wEnemyMonSpclAtk - call GetDamageStatsCritical + call CheckDamageStatsCritical jr c, .lightball ld hl, wPlayerSpDef ld a, [hli] @@ -3581,7 +3581,7 @@ UpdateMoveData: ld a, BATTLE_VARS_MOVE call GetBattleVar - ld [wCurMove], a + ld [wCurSpecies], a ld [wNamedObjectIndexBuffer], a dec a @@ -4183,13 +4183,13 @@ BattleCommand_EvasionUp2: BattleCommand_StatUp: ; statup - call CheckIfStatCanBeRaised + call RaiseStat ld a, [wFailedMessage] and a ret nz - jp StatUpAnimation + jp MinimizeDropSub -CheckIfStatCanBeRaised: +RaiseStat: ld a, b ld [wLoweredStat], a ld hl, wPlayerStatLevels @@ -4285,7 +4285,9 @@ CheckIfStatCanBeRaised: ld [wFailedMessage], a ret -StatUpAnimation: +MinimizeDropSub: +; Lower the substitute if we're minimizing + ld bc, wPlayerMinimized ld hl, DropPlayerSub ld a, [hBattleTurn] @@ -6152,7 +6154,7 @@ BattleCommand_Heal: push de push bc ld c, 2 - call StringCmp + call CompareBytes pop bc pop de pop hl @@ -6571,7 +6573,7 @@ BattleCommand_TimeBasedHealContinue: ; Don't bother healing if HP is already full. push bc - call StringCmp + call CompareBytes pop bc jr z, .Full @@ -6682,7 +6684,7 @@ INCLUDE "engine/battle/move_effects/future_sight.asm" INCLUDE "engine/battle/move_effects/thunder.asm" CheckHiddenOpponent: -; BUG: This routine should account for Lock-On and Mind Reader. +; BUG: This routine is completely redundant and introduces a bug, since BattleCommand_CheckHit does these checks properly. ld a, BATTLE_VARS_SUBSTATUS3_OPP call GetBattleVar and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND diff --git a/engine/battle/misc.asm b/engine/battle/misc.asm index 48062f643..8985385a0 100644 --- a/engine/battle/misc.asm +++ b/engine/battle/misc.asm @@ -53,13 +53,13 @@ DoWeatherModifiers: ld de, WeatherTypeModifiers ld a, [wBattleWeather] ld b, a - ld a, [wd265] ; move type + ld a, [wCurType] ld c, a .CheckWeatherType: ld a, [de] inc de - cp $ff + cp -1 jr z, .done_weather_types cp b @@ -84,7 +84,7 @@ DoWeatherModifiers: .CheckWeatherMove: ld a, [de] inc de - cp $ff + cp -1 jr z, .done cp b @@ -116,7 +116,7 @@ DoWeatherModifiers: ld a, 10 ld [hDivisor], a - ld b, $4 + ld b, 4 call Divide ld a, [hQuotient + 0] @@ -176,7 +176,7 @@ DoBadgeTypeBoosts: rr c jr nc, .NextBadge - ld a, [wd265] ; move type + ld a, [wCurType] cp [hl] jr z, .ApplyBoost diff --git a/engine/battle/move_effects/baton_pass.asm b/engine/battle/move_effects/baton_pass.asm index 5d9f19838..7f922b214 100644 --- a/engine/battle/move_effects/baton_pass.asm +++ b/engine/battle/move_effects/baton_pass.asm @@ -68,8 +68,8 @@ BattleCommand_BatonPass: call CallBattleCore ld hl, ResetBattleParticipants call CallBattleCore - ld a, 1 - ld [wTypeMatchup], a + ld a, TRUE + ld [wApplyStatLevelMultipliersToEnemy], a ld hl, ApplyStatLevelMultiplierOnAllStats call CallBattleCore @@ -83,7 +83,7 @@ BatonPass_LinkPlayerSwitch: and a ret z - ld a, 1 + ld a, BATTLEPLAYERACTION_USEITEM ld [wBattlePlayerAction], a call LoadStandardMenuHeader @@ -91,7 +91,7 @@ BatonPass_LinkPlayerSwitch: call CallBattleCore call CloseWindow - xor a + xor a ; BATTLEPLAYERACTION_USEMOVE ld [wBattlePlayerAction], a ret diff --git a/engine/battle/move_effects/counter.asm b/engine/battle/move_effects/counter.asm index f92e1b3ac..031c399a6 100644 --- a/engine/battle/move_effects/counter.asm +++ b/engine/battle/move_effects/counter.asm @@ -36,6 +36,7 @@ BattleCommand_Counter: cp SPECIAL ret nc + ; BUG: Move should fail with all non-damaging battle actions ld hl, wCurDamage ld a, [hli] or [hl] diff --git a/engine/battle/move_effects/false_swipe.asm b/engine/battle/move_effects/false_swipe.asm index 4f4eb329c..0d3f7d47c 100644 --- a/engine/battle/move_effects/false_swipe.asm +++ b/engine/battle/move_effects/false_swipe.asm @@ -13,7 +13,7 @@ BattleCommand_FalseSwipe: ld c, 2 push hl push de - call StringCmp + call CompareBytes pop de pop hl jr c, .done diff --git a/engine/battle/move_effects/magnitude.asm b/engine/battle/move_effects/magnitude.asm index 4dcf919d7..eaa0c2a3a 100644 --- a/engine/battle/move_effects/magnitude.asm +++ b/engine/battle/move_effects/magnitude.asm @@ -18,7 +18,7 @@ BattleCommand_GetMagnitude: push de inc hl ld a, [hl] - ld [wTypeMatchup], a + ld [wDeciramBuffer], a call BattleCommand_MoveDelay ld hl, MagnitudeText call StdBattleTextBox diff --git a/engine/battle/move_effects/metronome.asm b/engine/battle/move_effects/metronome.asm index b8a6b586f..25197d7cd 100644 --- a/engine/battle/move_effects/metronome.asm +++ b/engine/battle/move_effects/metronome.asm @@ -40,4 +40,4 @@ BattleCommand_Metronome: call UpdateMoveData jp ResetTurn -INCLUDE "data/battle/metronome_exception_moves.asm" +INCLUDE "data/moves/metronome_exception_moves.asm" diff --git a/engine/battle/move_effects/mirror_coat.asm b/engine/battle/move_effects/mirror_coat.asm index 8743c389d..96afa3175 100644 --- a/engine/battle/move_effects/mirror_coat.asm +++ b/engine/battle/move_effects/mirror_coat.asm @@ -29,14 +29,15 @@ BattleCommand_MirrorCoat: ld de, wStringBuffer1 call GetMoveData - ld a, [wStringBuffer1 + 2] + ld a, [wStringBuffer1 + MOVE_POWER] and a ret z - ld a, [wStringBuffer1 + 3] + ld a, [wStringBuffer1 + MOVE_TYPE] cp SPECIAL ret c + ; BUG: Move should fail with all non-damaging battle actions ld hl, wCurDamage ld a, [hli] or [hl] diff --git a/engine/battle/move_effects/mirror_move.asm b/engine/battle/move_effects/mirror_move.asm index 089403839..89879c825 100644 --- a/engine/battle/move_effects/mirror_move.asm +++ b/engine/battle/move_effects/mirror_move.asm @@ -24,7 +24,7 @@ BattleCommand_MirrorMove: .use ld a, b ld [hl], a - ld [wd265], a + ld [wNamedObjectIndexBuffer], a push af ld a, BATTLE_VARS_MOVE_ANIM diff --git a/engine/battle/move_effects/sketch.asm b/engine/battle/move_effects/sketch.asm index 4c15dbe02..a5b0d1c03 100644 --- a/engine/battle/move_effects/sketch.asm +++ b/engine/battle/move_effects/sketch.asm @@ -34,7 +34,7 @@ BattleCommand_Sketch: .get_last_move ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP call GetBattleVar - ld [wTypeMatchup], a + ld [wNamedObjectIndexBuffer], a ld b, a ; Fail if move is invalid or is Struggle. and a diff --git a/engine/battle/move_effects/spite.asm b/engine/battle/move_effects/spite.asm index 8aba187a4..71252fe22 100644 --- a/engine/battle/move_effects/spite.asm +++ b/engine/battle/move_effects/spite.asm @@ -24,7 +24,7 @@ BattleCommand_Spite: ld a, [hli] cp b jr nz, .loop - ld [wTypeMatchup], a + ld [wNamedObjectIndexBuffer], a dec hl ld b, 0 push bc @@ -78,7 +78,7 @@ BattleCommand_Spite: call AnimateCurrentMove pop de ld a, d - ld [wTypeMatchup], a + ld [wDeciramBuffer], a ld hl, SpiteEffectText jp StdBattleTextBox diff --git a/engine/battle/move_effects/thief.asm b/engine/battle/move_effects/thief.asm index 64de1a4fe..34a9699fc 100644 --- a/engine/battle/move_effects/thief.asm +++ b/engine/battle/move_effects/thief.asm @@ -21,7 +21,7 @@ BattleCommand_Thief: ; Can't steal mail. - ld [wd265], a + ld [wNamedObjectIndexBuffer], a ld d, a farcall ItemIsMail ret c @@ -45,7 +45,7 @@ BattleCommand_Thief: ld [de], a call .playeritem - ld a, [wd265] + ld a, [wNamedObjectIndexBuffer] ld [hl], a ld [de], a jr .stole @@ -68,7 +68,7 @@ BattleCommand_Thief: ; Can't steal mail! - ld [wd265], a + ld [wNamedObjectIndexBuffer], a ld d, a farcall ItemIsMail ret c @@ -86,7 +86,7 @@ BattleCommand_Thief: ld [de], a call .enemyitem - ld a, [wd265] + ld a, [wNamedObjectIndexBuffer] ld [hl], a ld [de], a diff --git a/engine/battle/start_battle.asm b/engine/battle/start_battle.asm index 5c2a633a8..f5fc4a6b0 100644 --- a/engine/battle/start_battle.asm +++ b/engine/battle/start_battle.asm @@ -16,7 +16,7 @@ FindFirstAliveMonAndStartBattle: xor a ld [hMapAnims], a call DelayFrame - ld b, 6 + ld b, PARTY_LENGTH ld hl, wPartyMon1HP ld de, PARTYMON_STRUCT_LENGTH - 1 diff --git a/engine/battle/trainer_huds.asm b/engine/battle/trainer_huds.asm index 3930549b2..7a971e21f 100644 --- a/engine/battle/trainer_huds.asm +++ b/engine/battle/trainer_huds.asm @@ -101,7 +101,7 @@ StageBallTilesData: DrawPlayerHUDBorder: ld hl, .tiles ld de, wTrainerHUDTiles - ld bc, 4 + ld bc, .tiles_end - .tiles call CopyBytes hlcoord 18, 10 ld de, -1 ; start on right @@ -112,11 +112,12 @@ DrawPlayerHUDBorder: db $77 ; bottom right db $6f ; bottom left db $76 ; bottom side +.tiles_end DrawPlayerPartyIconHUDBorder: ld hl, .tiles ld de, wTrainerHUDTiles - ld bc, 4 + ld bc, .tiles_end - .tiles call CopyBytes hlcoord 18, 10 ld de, -1 ; start on right @@ -127,11 +128,12 @@ DrawPlayerPartyIconHUDBorder: db $5c ; bottom right db $6f ; bottom left db $76 ; bottom side +.tiles_end DrawEnemyHUDBorder: ld hl, .tiles ld de, wTrainerHUDTiles - ld bc, 4 + ld bc, .tiles_end - .tiles call CopyBytes hlcoord 1, 2 ld de, 1 ; start on left @@ -152,23 +154,24 @@ DrawEnemyHUDBorder: db $74 ; bottom left db $78 ; bottom right db $76 ; bottom side +.tiles_end PlaceHUDBorderTiles: - ld a, [wTrainerHUDTiles] + ld a, [wTrainerHUDTiles + 0] ld [hl], a ld bc, SCREEN_WIDTH add hl, bc - ld a, [wStartFlypoint] + ld a, [wTrainerHUDTiles + 1] ld [hl], a - ld b, $8 + ld b, 8 .loop add hl, de - ld a, [wMovementBuffer] + ld a, [wTrainerHUDTiles + 3] ld [hl], a dec b jr nz, .loop add hl, de - ld a, [wEndFlypoint] + ld a, [wTrainerHUDTiles + 2] ld [hl], a ret @@ -181,7 +184,7 @@ LinkBattle_TrainerHuds: ld a, 10 * 8 ld [hli], a ld [hl], 8 * 8 - ld a, $8 + ld a, 8 ld [wPlaceBallsDirection], a ld hl, wVirtualOAMSprite00 call LoadTrainerHudOAM diff --git a/engine/battle/used_move_text.asm b/engine/battle/used_move_text.asm index 9307a1a1e..8166094f2 100644 --- a/engine/battle/used_move_text.asm +++ b/engine/battle/used_move_text.asm @@ -26,7 +26,7 @@ UsedMoveText: ld a, BATTLE_VARS_MOVE_ANIM call GetBattleVar - ld [wd265], a + ld [wMoveGrammar], a push hl farcall CheckUserIsCharging @@ -34,13 +34,12 @@ UsedMoveText: jr nz, .grammar ; update last move - ld a, [wd265] + ld a, [wMoveGrammar] ld [hl], a ld [de], a .grammar - call GetMoveGrammar -; wd265 now contains MoveGrammar + call GetMoveGrammar ; convert move id to grammar index ; everything except 'instead' made redundant in localization @@ -51,7 +50,7 @@ UsedMoveText: ret nz ; check move grammar - ld a, [wd265] + ld a, [wMoveGrammar] cp $3 ld hl, UsedMove2Text ret c @@ -89,14 +88,14 @@ MoveNameText: ld hl, .endusedmovetexts ; get move id - ld a, [wd265] + ld a, [wMoveGrammar] ; 2-byte pointer add a ; seek push bc - ld b, $0 + ld b, 0 ld c, a add hl, bc pop bc @@ -132,13 +131,13 @@ EndUsedMove5Text: db "@" GetMoveGrammar: -; store move grammar type in wd265 +; store move grammar type in wMoveGrammar push bc -; c = move id - ld a, [wd265] - ld c, a - ld b, $0 +; wMoveGrammar contains move id + ld a, [wMoveGrammar] + ld c, a ; move id + ld b, 0 ; grammar index ; read grammar table ld hl, MoveGrammar @@ -158,9 +157,9 @@ GetMoveGrammar: jr .loop .end -; wd265 now contains move grammar +; wMoveGrammar now contains move grammar ld a, b - ld [wd265], a + ld [wMoveGrammar], a ; we're done pop bc diff --git a/engine/battle_anims/anim_commands.asm b/engine/battle_anims/anim_commands.asm index e68b7d774..600168a9a 100644 --- a/engine/battle_anims/anim_commands.asm +++ b/engine/battle_anims/anim_commands.asm @@ -284,7 +284,7 @@ RunBattleAnimCommand: .loop call GetBattleAnimByte - cp $ff + cp anim_ret_command jr nz, .not_done_with_anim ; Return from a subroutine. diff --git a/engine/events/battle_tower/battle_tower.asm b/engine/events/battle_tower/battle_tower.asm index e51080ae0..534e2c331 100644 --- a/engine/events/battle_tower/battle_tower.asm +++ b/engine/events/battle_tower/battle_tower.asm @@ -270,7 +270,7 @@ ReadBTTrainerParty: ; Check the nicknames for illegal characters, and replace bad nicknames ; with their species names. - ld de, wBT_OTTempMon1Name ; $c643 + ld de, wBT_OTTempMon1Name ld c, MON_NAME_LENGTH farcall CheckStringForErrors jr nc, .skip_mon_1 @@ -280,44 +280,44 @@ ReadBTTrainerParty: call GetPokemonName ld l, e ld h, d - ld de, wBT_OTTempMon1Name ; $c643 + ld de, wBT_OTTempMon1Name ld bc, MON_NAME_LENGTH call CopyBytes .skip_mon_1 - ld de, wBT_OTTempMon2Name ; $c67e + ld de, wBT_OTTempMon2Name ld c, MON_NAME_LENGTH farcall CheckStringForErrors jr nc, .skip_mon_2 - ld a, [wBT_OTTempMon2] ; [$c64e] + ld a, [wBT_OTTempMon2] ld [wNamedObjectIndexBuffer], a call GetPokemonName ld l, e ld h, d - ld de, wBT_OTTempMon2Name ; $c67e + ld de, wBT_OTTempMon2Name ld bc, MON_NAME_LENGTH call CopyBytes .skip_mon_2 - ld de, wBT_OTTempMon3Name ; $c686 + 51 = $c6b9 + ld de, wBT_OTTempMon3Name ld c, MON_NAME_LENGTH farcall CheckStringForErrors jr nc, .skip_mon_3 - ld a, [wBT_OTTempMon3] ; [$c689] + ld a, [wBT_OTTempMon3] ld [wNamedObjectIndexBuffer], a call GetPokemonName ld l, e ld h, d - ld de, wBT_OTTempMon3Name ; $c686 + 51 = $c6b9 + ld de, wBT_OTTempMon3Name ld bc, MON_NAME_LENGTH call CopyBytes .skip_mon_3 ; Add the terminator character to each of these names ld a, "@" - ld [wBT_OTTempMon1NameEnd - 1], a ; $c64d - ld [wBT_OTTempMon2NameEnd - 1], a ; $c688 - ld [wBT_OTTempMon3NameEnd - 1], a ; $c68a + 57 = $c6c3 + ld [wBT_OTTempMon1NameEnd - 1], a + ld [wBT_OTTempMon2NameEnd - 1], a + ld [wBT_OTTempMon3NameEnd - 1], a ; Fix errors in the movesets call CheckBTMonMovesForErrors ; Repair the trainer name if needed, then copy it to wOTPlayerName diff --git a/engine/events/battle_tower/load_trainer.asm b/engine/events/battle_tower/load_trainer.asm index 2f34950b6..f9be02b28 100644 --- a/engine/events/battle_tower/load_trainer.asm +++ b/engine/events/battle_tower/load_trainer.asm @@ -104,7 +104,7 @@ Function_LoadRandomBattleTowerMon: ld a, [wBTChoiceOfLvlGroup] dec a ld hl, BattleTowerMons - ld bc, BattleTowerMons2 - BattleTowerMons1 + ld bc, BattleTowerMons2 - BattleTowerMons1 ; size of one level group call AddNTimes ld a, [hRandomAdd] diff --git a/engine/events/bug_contest/caught_mon.asm b/engine/events/bug_contest/caught_mon.asm index 45212ae3e..fc170cf28 100644 --- a/engine/events/bug_contest/caught_mon.asm +++ b/engine/events/bug_contest/caught_mon.asm @@ -2,7 +2,7 @@ BugContest_SetCaughtContestMon: ld a, [wContestMon] and a jr z, .firstcatch - ld [wd265], a + ld [wNamedObjectIndexBuffer], a farcall DisplayAlreadyCaughtText farcall DisplayCaughtContestMonStats lb bc, 14, 7 @@ -12,7 +12,7 @@ BugContest_SetCaughtContestMon: .firstcatch call .generatestats ld a, [wTempEnemyMonSpecies] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetPokemonName ld hl, .caughttext call PrintText diff --git a/engine/events/bug_contest/contest_2.asm b/engine/events/bug_contest/contest_2.asm index 9cf70a03e..ddfad8644 100644 --- a/engine/events/bug_contest/contest_2.asm +++ b/engine/events/bug_contest/contest_2.asm @@ -58,9 +58,6 @@ SelectRandomBugContestContestants: CheckBugContestContestantFlag: ; Checks the flag of the Bug Catching Contestant whose index is loaded in a. -; Bug: If a >= NUM_BUG_CONTESTANTS when this is called, -; it will read beyond the table. - ld hl, BugCatchingContestantEventFlagTable ld e, a ld d, 0 diff --git a/engine/events/bug_contest/display_stats.asm b/engine/events/bug_contest/display_stats.asm index 94a5e9511..9d92f8fe3 100644 --- a/engine/events/bug_contest/display_stats.asm +++ b/engine/events/bug_contest/display_stats.asm @@ -36,7 +36,7 @@ DisplayCaughtContestMonStats: call PlaceString ld a, [wContestMon] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetPokemonName ld de, wStringBuffer1 hlcoord 1, 2 diff --git a/engine/events/bug_contest/judging.asm b/engine/events/bug_contest/judging.asm index d8f9d7657..a6ec3baf6 100644 --- a/engine/events/bug_contest/judging.asm +++ b/engine/events/bug_contest/judging.asm @@ -171,7 +171,7 @@ DetermineContestWinners: ld de, wBugContestTempScore ld hl, wBugContestFirstPlaceScore ld c, 2 - call StringCmp + call CompareBytes jr c, .not_first_place ld hl, wBugContestSecondPlaceWinnerID ld de, wBugContestThirdPlaceWinnerID @@ -189,7 +189,7 @@ DetermineContestWinners: ld de, wBugContestTempScore ld hl, wBugContestSecondPlaceScore ld c, 2 - call StringCmp + call CompareBytes jr c, .not_second_place ld hl, wBugContestSecondPlaceWinnerID ld de, wBugContestThirdPlaceWinnerID @@ -203,7 +203,7 @@ DetermineContestWinners: ld de, wBugContestTempScore ld hl, wBugContestThirdPlaceScore ld c, 2 - call StringCmp + call CompareBytes jr c, .done ld hl, wBugContestThirdPlaceWinnerID call CopyTempContestant diff --git a/engine/events/celebi.asm b/engine/events/celebi.asm index 76bdbaa76..a34f3935a 100644 --- a/engine/events/celebi.asm +++ b/engine/events/celebi.asm @@ -31,7 +31,7 @@ CelebiShrineEvent: call GetCelebiSpriteTile inc d push de - ld a, $90 + ld a, 36 * SPRITEOAMSTRUCT_LENGTH ld [wCurrSpriteOAMAddr], a farcall DoNextFrameForAllSprites call CelebiEvent_CountDown diff --git a/engine/events/daycare.asm b/engine/events/daycare.asm index 5904a476d..4e98c5382 100644 --- a/engine/events/daycare.asm +++ b/engine/events/daycare.asm @@ -558,7 +558,7 @@ DayCare_InitBreeding: bit DAYCAREMAN_HAS_MON_F, a ret z callfar CheckBreedmonCompatibility - ld a, [wd265] + ld a, [wBreedingCompatibility] and a ret z inc a diff --git a/engine/events/field_moves.asm b/engine/events/field_moves.asm index f5ad049f2..a6edbc08c 100644 --- a/engine/events/field_moves.asm +++ b/engine/events/field_moves.asm @@ -1,3 +1,7 @@ +FIELDMOVE_GRASS EQU $80 +FIELDMOVE_TREE EQU $84 +FIELDMOVE_FLY EQU $84 + PlayWhirlpoolSound: call WaitSFX ld de, SFX_SURF @@ -20,11 +24,11 @@ BlindingFlash: ShakeHeadbuttTree: farcall ClearSpriteAnims ld de, CutGrassGFX - ld hl, vTiles1 tile $00 + ld hl, vTiles0 tile FIELDMOVE_GRASS lb bc, BANK(CutGrassGFX), 4 call Request2bpp ld de, HeadbuttTreeGFX - ld hl, vTiles1 tile $04 + ld hl, vTiles0 tile FIELDMOVE_TREE lb bc, BANK(HeadbuttTreeGFX), 8 call Request2bpp call Cut_Headbutt_GetPixelFacing @@ -32,8 +36,8 @@ ShakeHeadbuttTree: call _InitSpriteAnimStruct ld hl, SPRITEANIMSTRUCT_TILE_ID add hl, bc - ld [hl], $84 - ld a, 36 * 4 + ld [hl], FIELDMOVE_TREE + ld a, 36 * SPRITEOAMSTRUCT_LENGTH ld [wCurrSpriteOAMAddr], a farcall DoNextFrameForAllSprites call HideHeadbuttTree @@ -48,7 +52,7 @@ ShakeHeadbuttTree: and a jr z, .done dec [hl] - ld a, 36 * 4 + ld a, 36 * SPRITEOAMSTRUCT_LENGTH ld [wCurrSpriteOAMAddr], a farcall DoNextFrameForAllSprites call DelayFrame @@ -111,7 +115,7 @@ OWCutAnimation: ; 0: Split tree in half ; 1: Mow the lawn ld a, e - and $1 + and 1 ld [wJumptableIndex], a call .LoadCutGFX call WaitSFX @@ -121,7 +125,7 @@ OWCutAnimation: ld a, [wJumptableIndex] bit 7, a jr nz, .finish - ld a, 36 * 4 + ld a, 36 * SPRITEOAMSTRUCT_LENGTH ld [wCurrSpriteOAMAddr], a callfar DoNextFrameForAllSprites call OWCutJumptable @@ -134,11 +138,11 @@ OWCutAnimation: .LoadCutGFX: callfar ClearSpriteAnims ; pointless to farcall ld de, CutGrassGFX - ld hl, vTiles1 tile $00 + ld hl, vTiles0 tile FIELDMOVE_GRASS lb bc, BANK(CutGrassGFX), 4 call Request2bpp ld de, CutTreeGFX - ld hl, vTiles1 tile $04 + ld hl, vTiles0 tile FIELDMOVE_TREE lb bc, BANK(CutTreeGFX), 4 call Request2bpp ret @@ -173,7 +177,7 @@ Cut_SpawnAnimateTree: call _InitSpriteAnimStruct ld hl, SPRITEANIMSTRUCT_TILE_ID add hl, bc - ld [hl], $84 + ld [hl], FIELDMOVE_TREE ld a, 32 ld [wFrameCounter], a ; Cut_StartWaiting @@ -226,7 +230,7 @@ Cut_SpawnLeaf: call _InitSpriteAnimStruct ld hl, SPRITEANIMSTRUCT_TILE_ID add hl, bc - ld [hl], $80 + ld [hl], FIELDMOVE_GRASS ld hl, SPRITEANIMSTRUCT_0E add hl, bc ld [hl], $4 @@ -313,7 +317,7 @@ FlyFromAnim: call _InitSpriteAnimStruct ld hl, SPRITEANIMSTRUCT_TILE_ID add hl, bc - ld [hl], $84 + ld [hl], FIELDMOVE_FLY ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID add hl, bc ld [hl], SPRITE_ANIM_SEQ_FLY_FROM @@ -323,7 +327,7 @@ FlyFromAnim: ld a, [wJumptableIndex] bit 7, a jr nz, .exit - ld a, 0 * 4 + ld a, 0 * SPRITEOAMSTRUCT_LENGTH ld [wCurrSpriteOAMAddr], a callfar DoNextFrameForAllSprites call FlyFunction_FrameTimer @@ -347,7 +351,7 @@ FlyToAnim: call _InitSpriteAnimStruct ld hl, SPRITEANIMSTRUCT_TILE_ID add hl, bc - ld [hl], $84 + ld [hl], FIELDMOVE_FLY ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID add hl, bc ld [hl], SPRITE_ANIM_SEQ_FLY_TO @@ -360,7 +364,7 @@ FlyToAnim: ld a, [wJumptableIndex] bit 7, a jr nz, .exit - ld a, 0 * 4 + ld a, 0 * SPRITEOAMSTRUCT_LENGTH ld [wCurrSpriteOAMAddr], a callfar DoNextFrameForAllSprites call FlyFunction_FrameTimer @@ -394,7 +398,7 @@ endr FlyFunction_InitGFX: callfar ClearSpriteAnims ld de, CutGrassGFX - ld hl, vTiles1 tile $00 + ld hl, vTiles0 tile FIELDMOVE_GRASS lb bc, BANK(CutGrassGFX), 4 call Request2bpp ld a, [wCurPartyMon] @@ -403,8 +407,8 @@ FlyFunction_InitGFX: ld d, 0 add hl, de ld a, [hl] - ld [wd265], a - ld e, $84 + ld [wTempIconSpecies], a + ld e, FIELDMOVE_FLY farcall FlyFunction_GetMonIcon xor a ld [wJumptableIndex], a @@ -446,5 +450,5 @@ FlyFunction_FrameTimer: call _InitSpriteAnimStruct ld hl, SPRITEANIMSTRUCT_TILE_ID add hl, bc - ld [hl], $80 + ld [hl], FIELDMOVE_GRASS ret diff --git a/engine/events/fish.asm b/engine/events/fish.asm index a1df536bb..c1dde87d8 100644 --- a/engine/events/fish.asm +++ b/engine/events/fish.asm @@ -93,8 +93,8 @@ GetFishGroupIndex: ; Return the index of fishgroup d in de. push hl - ld hl, wDailyFlags - bit DAILYFLAGS_FISH_SWARM_F, [hl] + ld hl, wDailyFlags1 + bit DAILYFLAGS1_FISH_SWARM_F, [hl] pop hl jr z, .done diff --git a/engine/events/fishing_gfx.asm b/engine/events/fishing_gfx.asm index 25d1ee77a..159f0022d 100644 --- a/engine/events/fishing_gfx.asm +++ b/engine/events/fishing_gfx.asm @@ -17,7 +17,7 @@ LoadFishingGFX: call .LoadGFX ld hl, vTiles0 tile $0a call .LoadGFX - ld hl, vTiles1 tile $7c + ld hl, vTiles0 tile $fc call .LoadGFX pop af diff --git a/engine/events/fruit_trees.asm b/engine/events/fruit_trees.asm index 6d5ca6a1d..15fa4f80f 100644 --- a/engine/events/fruit_trees.asm +++ b/engine/events/fruit_trees.asm @@ -41,8 +41,8 @@ GetCurTreeFruit: ret TryResetFruitTrees: - ld hl, wDailyFlags - bit DAILYFLAGS_ALL_FRUIT_TREES_F, [hl] + ld hl, wDailyFlags1 + bit DAILYFLAGS1_ALL_FRUIT_TREES_F, [hl] ret nz jp ResetFruitTrees @@ -65,8 +65,8 @@ ResetFruitTrees: ld [hli], a ld [hli], a ld [hl], a - ld hl, wDailyFlags - set DAILYFLAGS_ALL_FRUIT_TREES_F, [hl] + ld hl, wDailyFlags1 + set DAILYFLAGS1_ALL_FRUIT_TREES_F, [hl] ret GetFruitTreeFlag: diff --git a/engine/events/halloffame.asm b/engine/events/halloffame.asm index 6cbc749d5..752ec965b 100644 --- a/engine/events/halloffame.asm +++ b/engine/events/halloffame.asm @@ -124,7 +124,7 @@ AnimateHallOfFame: call PlaceString call WaitBGMap decoord 6, 5 - ld c, $6 + ld c, ANIM_MON_HOF predef HOF_AnimateFrontpic ld c, 60 call DelayFrames @@ -390,7 +390,7 @@ _HallOfFamePC: call GetSGBLayout call SetPalettes decoord 6, 5 - ld c, $6 + ld c, ANIM_MON_HOF predef HOF_AnimateFrontpic and a ret @@ -462,7 +462,7 @@ DisplayHOFMon: call TextBox ld a, [wTempMonSpecies] ld [wCurPartySpecies], a - ld [wd265], a + ld [wDeciramBuffer], a ld hl, wTempMonDVs predef GetUnownLetter xor a @@ -477,7 +477,7 @@ DisplayHOFMon: ld [hli], a ld [hl], "<DOT>" hlcoord 3, 13 - ld de, wd265 + ld de, wDeciramBuffer lb bc, PRINTNUM_LEADINGZEROS | 1, 3 call PrintNum call GetBasePokemonName diff --git a/engine/events/happiness_egg.asm b/engine/events/happiness_egg.asm index 41f9a4411..1d33edb74 100644 --- a/engine/events/happiness_egg.asm +++ b/engine/events/happiness_egg.asm @@ -11,7 +11,7 @@ GetFirstPokemonHappiness: jr .loop .done - ld [wd265], a + ld [wNamedObjectIndexBuffer], a ld a, [hl] ld [wScriptVar], a call GetPokemonName @@ -19,9 +19,9 @@ GetFirstPokemonHappiness: CheckFirstMonIsEgg: ld a, [wPartySpecies] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a cp EGG - ld a, 1 + ld a, TRUE jr z, .egg xor a @@ -196,15 +196,15 @@ DayCareStep:: call Random ld [hl], a callfar CheckBreedmonCompatibility - ld a, [wd265] + ld a, [wBreedingCompatibility] cp 230 ld b, 32 percent - 1 jr nc, .okay - ld a, [wd265] + ld a, [wBreedingCompatibility] cp 170 ld b, 16 percent jr nc, .okay - ld a, [wd265] + ld a, [wBreedingCompatibility] cp 110 ld b, 12 percent jr nc, .okay diff --git a/engine/events/lucky_number.asm b/engine/events/lucky_number.asm index c5d6d18e0..1c3a8dc02 100644 --- a/engine/events/lucky_number.asm +++ b/engine/events/lucky_number.asm @@ -1,7 +1,7 @@ CheckForLuckyNumberWinners: xor a ld [wScriptVar], a - ld [wFoundMatchingIDInParty], a + ld [wTempByteValue], a ld a, [wPartyCount] and a ret z @@ -34,8 +34,8 @@ CheckForLuckyNumberWinners: jr z, .SkipOpenBoxMon call .CompareLuckyNumberToMonID jr nc, .SkipOpenBoxMon - ld a, 1 - ld [wFoundMatchingIDInParty], a + ld a, TRUE + ld [wTempByteValue], a .SkipOpenBoxMon: push bc @@ -81,8 +81,8 @@ CheckForLuckyNumberWinners: call .CompareLuckyNumberToMonID ; sets wScriptVar and wCurPartySpecies appropriately jr nc, .SkipBoxMon - ld a, 1 - ld [wFoundMatchingIDInParty], a + ld a, TRUE + ld [wTempByteValue], a .SkipBoxMon: push bc @@ -104,7 +104,7 @@ CheckForLuckyNumberWinners: and a ret z ; found nothing farcall StubbedTrainerRankings_LuckyNumberShow - ld a, [wFoundMatchingIDInParty] + ld a, [wTempByteValue] and a push af ld a, [wCurPartySpecies] @@ -127,14 +127,14 @@ CheckForLuckyNumberWinners: ld hl, wBuffer1 lb bc, PRINTNUM_LEADINGZEROS | 2, 5 call PrintNum - ld hl, wLuckyNumberDigit1Buffer + ld hl, wLuckyNumberDigitsBuffer ld de, wLuckyIDNumber lb bc, PRINTNUM_LEADINGZEROS | 2, 5 call PrintNum ld b, 5 ld c, 0 - ld hl, wLuckyNumberDigit5Buffer - ld de, wBuffer5 + ld hl, wLuckyNumberDigitsBuffer + 4 + ld de, wBuffer1 + 4 .loop ld a, [de] cp [hl] diff --git a/engine/events/magikarp.asm b/engine/events/magikarp.asm index 7fe8adba7..db415c65e 100644 --- a/engine/events/magikarp.asm +++ b/engine/events/magikarp.asm @@ -36,7 +36,7 @@ CheckMagikarpLength: ld hl, wMagikarpLength ld de, wBestMagikarpLengthFeet ld c, 2 - call StringCmp + call CompareBytes jr nc, .not_long_enough ; NEW RECORD!!! Let's save that. @@ -185,7 +185,7 @@ CalcMagikarpLength: ld hl, MagikarpLengths ld a, 2 - ld [wd265], a + ld [wTempByteValue], a .read ld a, [hli] @@ -214,7 +214,7 @@ CalcMagikarpLength: ld [hMultiplicand + 1], a ld a, 100 ld [hMultiplicand + 2], a - ld a, [wd265] + ld a, [wTempByteValue] ld [hMultiplier], a call Multiply ld b, 0 @@ -228,9 +228,9 @@ CalcMagikarpLength: .next inc hl ; align to next triplet - ld a, [wd265] + ld a, [wTempByteValue] inc a - ld [wd265], a + ld [wTempByteValue], a cp 16 jr c, .read diff --git a/engine/events/move_deleter.asm b/engine/events/move_deleter.asm index f2b827227..2f0df5162 100644 --- a/engine/events/move_deleter.asm +++ b/engine/events/move_deleter.asm @@ -28,7 +28,7 @@ MoveDeletion: ld a, [wMenuCursorY] push af ld a, [wCurSpecies] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetMoveName ld hl, .ConfirmDeleteText call PrintText diff --git a/engine/events/move_tutor.asm b/engine/events/move_tutor.asm index 67d0ca528..681dc6adc 100644 --- a/engine/events/move_tutor.asm +++ b/engine/events/move_tutor.asm @@ -8,7 +8,7 @@ MoveTutor: xor a ld [wItemAttributeParamBuffer], a call .GetMoveTutorMove - ld [wd265], a + ld [wNamedObjectIndexBuffer], a ld [wPutativeTMHMMove], a call GetMoveName call CopyName1 diff --git a/engine/events/name_rater.asm b/engine/events/name_rater.asm index 593d51c69..2cdff4bdd 100644 --- a/engine/events/name_rater.asm +++ b/engine/events/name_rater.asm @@ -29,7 +29,7 @@ _NameRater: xor a ; PARTYMON ld [wMonType], a ld a, [wCurPartySpecies] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a ld [wCurSpecies], a call GetBaseData ld b, 0 diff --git a/engine/events/npc_trade.asm b/engine/events/npc_trade.asm index 9cff40a2b..bb71941ed 100644 --- a/engine/events/npc_trade.asm +++ b/engine/events/npc_trade.asm @@ -301,7 +301,7 @@ Trade_GetAttributeOfLastPartymon: GetTradeMonName: push de - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetBasePokemonName ld hl, wStringBuffer1 pop de diff --git a/engine/events/odd_egg.asm b/engine/events/odd_egg.asm index 10d7cf9aa..a6b244b1d 100644 --- a/engine/events/odd_egg.asm +++ b/engine/events/odd_egg.asm @@ -39,7 +39,7 @@ _GiveOddEgg: .done ld hl, OddEggs - ld a, OddEgg2 - OddEgg1 + ld a, OddEgg1End - OddEgg1 call AddNTimes ld de, wOddEggSpecies diff --git a/engine/events/pokecenter_pc.asm b/engine/events/pokecenter_pc.asm index f1a593b5a..8f73fc41e 100644 --- a/engine/events/pokecenter_pc.asm +++ b/engine/events/pokecenter_pc.asm @@ -478,21 +478,21 @@ PlayerDepositItemMenu: push af ld a, [wBuffer2] push af - call .DepositItem_ + call .DepositItem pop af ld [wBuffer2], a pop af ld [wBuffer1], a ret -.DepositItem_: +.DepositItem: farcall _CheckTossableItem ld a, [wItemAttributeParamBuffer] and a jr z, .AskQuantity ld a, $1 ld [wItemQuantityChangeBuffer], a - jr .DepositItem + jr .ContinueDeposit .AskQuantity: ld hl, .HowManyText @@ -504,7 +504,7 @@ PlayerDepositItemMenu: pop af jr c, .DeclinedToDeposit -.DepositItem: +.ContinueDeposit: ld a, [wItemQuantityChangeBuffer] ld [wBuffer1], a ld a, [wCurItemQuantity] diff --git a/engine/events/shuckle.asm b/engine/events/shuckle.asm index c6d909afe..b1c87f53a 100644 --- a/engine/events/shuckle.asm +++ b/engine/events/shuckle.asm @@ -54,8 +54,8 @@ GiveShuckle: call CopyName2 ; Engine flag for this event. - ld hl, wDailyFlags - set DAILYFLAGS_GOT_SHUCKIE_TODAY_F, [hl] + ld hl, wDailyFlags1 + set DAILYFLAGS1_GOT_SHUCKIE_TODAY_F, [hl] ld a, 1 ld [wScriptVar], a ret diff --git a/engine/events/specials.asm b/engine/events/specials.asm index 35d32dde6..be554f1bc 100644 --- a/engine/events/specials.asm +++ b/engine/events/specials.asm @@ -34,7 +34,7 @@ GameCornerPrizeMonCheckDex: call SetSeenAndCaughtMon call FadeToMenu ld a, [wScriptVar] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a farcall NewPokedexEntry call ExitAllMenus ret @@ -153,7 +153,7 @@ GetMysteryGiftItem: ld [sMysteryGiftItem], a call CloseSRAM ld a, [wCurItem] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetItemName ld hl, .ReceiveItemText call PrintText diff --git a/engine/games/unown_puzzle.asm b/engine/games/unown_puzzle.asm index fb88d93b6..40c6527d9 100644 --- a/engine/games/unown_puzzle.asm +++ b/engine/games/unown_puzzle.asm @@ -19,11 +19,11 @@ _UnownPuzzle: xor a call ByteFill ld hl, UnownPuzzleCursorGFX - ld de, vTiles1 tile $60 + ld de, vTiles0 tile $e0 ld bc, 4 tiles call CopyBytes ld hl, UnownPuzzleStartCancelLZ - ld de, vTiles1 tile $6d + ld de, vTiles0 tile $ed call Decompress call LoadUnownPuzzlePiecesGFX hlcoord 0, 0 diff --git a/engine/gfx/cgb_layouts.asm b/engine/gfx/cgb_layouts.asm index d8f53d7fc..ffd4d4c48 100644 --- a/engine/gfx/cgb_layouts.asm +++ b/engine/gfx/cgb_layouts.asm @@ -266,7 +266,7 @@ _CGB_Pokedex: jr .got_palette .is_pokemon - call GetMonPalettePointer_ + call GetMonPalettePointer call LoadPalette_White_Col1_Col2_Black ; mon palette .got_palette call WipeAttrMap @@ -352,7 +352,7 @@ _CGB_PokedexUnownMode: call GetPredefPal call LoadHLPaletteIntoDE ld a, [wCurPartySpecies] - call GetMonPalettePointer_ + call GetMonPalettePointer call LoadPalette_White_Col1_Col2_Black call WipeAttrMap hlcoord 7, 5, wAttrMap @@ -914,7 +914,7 @@ _CGB_PlayerOrMonFrontpicPals: _CGB1e: ld de, wBGPals1 ld a, [wCurPartySpecies] - call GetMonPalettePointer_ + call GetMonPalettePointer call LoadPalette_White_Col1_Col2_Black call WipeAttrMap call ApplyAttrMap diff --git a/engine/gfx/color.asm b/engine/gfx/color.asm index 9a3b4f8ef..397db9751 100644 --- a/engine/gfx/color.asm +++ b/engine/gfx/color.asm @@ -94,9 +94,9 @@ Unreferenced_Function8aa4: ld a, d ld [wSGBPals + 6], a ld hl, wSGBPals - call PushSGBPals_ + call PushSGBPals ld hl, BlkPacket_9a86 - call PushSGBPals_ + call PushSGBPals ret InitPartyMenuPalettes: @@ -173,7 +173,7 @@ Unreferenced_Function8b3f: and a ret z ld hl, BlkPacket_9a86 - jp PushSGBPals_ + jp PushSGBPals Unreferenced_Function8b4d: call CheckCGB @@ -182,7 +182,7 @@ Unreferenced_Function8b4d: and a ret z ld hl, PalPacket_BetaIntroVenusaur - jp PushSGBPals_ + jp PushSGBPals .cgb ld de, wOBPals1 @@ -197,7 +197,7 @@ Unreferenced_Function8b67: and a ret z ld hl, PalPacket_Pack - jp PushSGBPals_ + jp PushSGBPals .cgb ld de, wOBPals1 @@ -218,7 +218,7 @@ Unreferenced_Function8b81: ld bc, PALPACKET_LENGTH call CopyBytes pop af - call GetMonPalettePointer_ + call GetMonPalettePointer ld a, [hli] ld [wSGBPals + 3], a ld a, [hli] @@ -228,12 +228,12 @@ Unreferenced_Function8b81: ld a, [hl] ld [wSGBPals + 6], a ld hl, wSGBPals - jp PushSGBPals_ + jp PushSGBPals .cgb ld de, wOBPals1 ld a, c - call GetMonPalettePointer_ + call GetMonPalettePointer call LoadPalette_White_Col1_Col2_Black ret @@ -245,7 +245,7 @@ LoadTrainerClassPaletteAsNthBGPal: LoadMonPaletteAsNthBGPal: ld a, [wCurPartySpecies] - call GetMonPalettePointer + call _GetMonPalettePointer ld a, e bit 7, a jr z, got_palette_pointer_8bd7 @@ -278,7 +278,7 @@ Unreferenced_Function8bec: and a jr nz, .cgb ld hl, wPlayerLightScreenCount - jp PushSGBPals_ + jp PushSGBPals .cgb ld a, [wEnemyLightScreenCount] ; col @@ -310,7 +310,7 @@ ApplyMonOrTrainerPals: and a jr z, .get_trainer ld a, [wCurPartySpecies] - call GetMonPalettePointer_ + call GetMonPalettePointer jr .load_palettes .get_trainer @@ -426,9 +426,9 @@ LoadMailPalettes: ld a, [hli] ld [wSGBPals + 6], a ld hl, wSGBPals - call PushSGBPals_ + call PushSGBPals ld hl, BlkPacket_9a86 - call PushSGBPals_ + call PushSGBPals ret .cgb @@ -732,8 +732,8 @@ GetTrainerPalettePointer: add hl, bc ret -GetMonPalettePointer_: - call GetMonPalettePointer +GetMonPalettePointer: + call _GetMonPalettePointer ret Unreferenced_Function9779: @@ -781,7 +781,7 @@ Unreferenced_Function97cc: jr nz, .loop ret -GetMonPalettePointer: +_GetMonPalettePointer: ld l, a ld h, $0 add hl, hl @@ -793,7 +793,7 @@ GetMonPalettePointer: GetMonNormalOrShinyPalettePointer: push bc - call GetMonPalettePointer + call _GetMonPalettePointer pop bc push hl call CheckShininess @@ -804,17 +804,17 @@ rept 4 endr ret -PushSGBPals_: +PushSGBPals: ld a, [wcfbe] push af set 7, a ld [wcfbe], a - call PushSGBPals + call _PushSGBPals pop af ld [wcfbe], a ret -PushSGBPals: +_PushSGBPals: ld a, [hl] and $7 ret z @@ -878,7 +878,7 @@ InitSGBBorder: call SGBDelayCycles call SGB_ClearVRAM ld hl, MaskEnCancelPacket - call PushSGBPals + call _PushSGBPals .skip pop af @@ -950,7 +950,7 @@ _InitSGBBorderPals: push hl ld h, [hl] ld l, a - call PushSGBPals + call _PushSGBPals pop hl inc hl pop bc @@ -974,12 +974,12 @@ Unreferenced_Function9911: xor a ld [rJOYP], a ld hl, MaskEnFreezePacket - call PushSGBPals + call _PushSGBPals call PushSGBBorder call SGBDelayCycles call SGB_ClearVRAM ld hl, MaskEnCancelPacket - call PushSGBPals + call _PushSGBPals ei ret @@ -1005,7 +1005,7 @@ SGB_ClearVRAM: PushSGBBorderPalsAndWait: ld hl, MltReq2Packet - call PushSGBPals + call _PushSGBPals call SGBDelayCycles ld a, [rJOYP] and $3 @@ -1050,7 +1050,7 @@ endr .FinalPush: ld hl, MltReq1Packet - call PushSGBPals + call _PushSGBPals jp SGBDelayCycles SGBBorder_PushBGPals: @@ -1065,7 +1065,7 @@ SGBBorder_PushBGPals: ld a, LCDC_DEFAULT ld [rLCDC], a ld hl, PalTrnPacket - call PushSGBPals + call _PushSGBPals xor a ld [rBGP], a ret @@ -1099,7 +1099,7 @@ SGBBorder_MorePalPushing: ld a, LCDC_DEFAULT ld [rLCDC], a ld hl, PctTrnPacket - call PushSGBPals + call _PushSGBPals xor a ld [rBGP], a ret @@ -1123,7 +1123,7 @@ SGBBorder_YetMorePalPushing: ld a, LCDC_DEFAULT ld [rLCDC], a ld hl, ChrTrnPacket - call PushSGBPals + call _PushSGBPals xor a ld [rBGP], a ret diff --git a/engine/gfx/crystal_layouts.asm b/engine/gfx/crystal_layouts.asm index b9686701c..bdbf91118 100644 --- a/engine/gfx/crystal_layouts.asm +++ b/engine/gfx/crystal_layouts.asm @@ -284,7 +284,7 @@ _InitMG_Mobile_LinkTradePalMap: call ByteFill ret -LoadTradeRoomBGPals: +_LoadTradeRoomBGPals: ld hl, TradeRoomPalette ld de, wBGPals1 palette PAL_BG_GREEN ld bc, 6 palettes diff --git a/engine/gfx/mon_icons.asm b/engine/gfx/mon_icons.asm index 5ae2fbf8b..c4bb7294c 100644 --- a/engine/gfx/mon_icons.asm +++ b/engine/gfx/mon_icons.asm @@ -34,13 +34,14 @@ LoadMenuMonIcon: jp hl .Jumptable: - dw PartyMenu_InitAnimatedMonIcon ; party menu - dw NamingScreen_InitAnimatedMonIcon ; naming screen - dw MoveList_InitAnimatedMonIcon ; moves (?) - dw Trade_LoadMonIconGFX ; trade - dw Mobile_InitAnimatedMonIcon ; mobile - dw Mobile_InitPartyMenuBGPal71 ; mobile - dw .GetPartyMenuMonIcon ; unused +; entries correspond to MONICON_* constants + dw PartyMenu_InitAnimatedMonIcon ; MONICON_PARTYMENU + dw NamingScreen_InitAnimatedMonIcon ; MONICON_NAMINGSCREEN + dw MoveList_InitAnimatedMonIcon ; MONICON_MOVES + dw Trade_LoadMonIconGFX ; MONICON_TRADE + dw Mobile_InitAnimatedMonIcon ; MONICON_MOBILE1 + dw Mobile_InitPartyMenuBGPal71 ; MONICON_MOBILE2 + dw .GetPartyMenuMonIcon ; MONICON_UNUSED .GetPartyMenuMonIcon: call InitPartyMenuIcon @@ -65,14 +66,14 @@ LoadMenuMonIcon: pop bc pop hl jr c, .not_mail - ld a, $6 + ld a, $06 jr .got_tile .not_mail - ld a, $5 - ; jr .got_tile + ld a, $05 + ; fallthrough .no_item - ld a, $4 + ld a, $04 .got_tile ld hl, SPRITEANIMSTRUCT_FRAMESET_ID add hl, bc @@ -156,7 +157,7 @@ InitPartyMenuIcon: ld a, [hObjectStructIndexBuffer] ld hl, wPartySpecies ld e, a - ld d, $0 + ld d, 0 add hl, de ld a, [hl] call ReadMonMenuIcon @@ -214,7 +215,7 @@ SetPartyMonIconAnimSpeed: db $80 ; HP_RED NamingScreen_InitAnimatedMonIcon: - ld a, [wd265] + ld a, [wTempIconSpecies] call ReadMonMenuIcon ld [wCurIcon], a xor a @@ -228,7 +229,7 @@ NamingScreen_InitAnimatedMonIcon: ret MoveList_InitAnimatedMonIcon: - ld a, [wd265] + ld a, [wTempIconSpecies] call ReadMonMenuIcon ld [wCurIcon], a xor a @@ -243,7 +244,7 @@ MoveList_InitAnimatedMonIcon: ret Trade_LoadMonIconGFX: - ld a, [wd265] + ld a, [wTempIconSpecies] call ReadMonMenuIcon ld [wCurIcon], a ld a, $62 @@ -254,7 +255,7 @@ Trade_LoadMonIconGFX: GetSpeciesIcon: ; Load species icon into VRAM at tile a push de - ld a, [wd265] + ld a, [wTempIconSpecies] call ReadMonMenuIcon ld [wCurIcon], a pop de @@ -264,7 +265,7 @@ GetSpeciesIcon: FlyFunction_GetMonIcon: push de - ld a, [wd265] + ld a, [wTempIconSpecies] call ReadMonMenuIcon ld [wCurIcon], a pop de @@ -274,7 +275,7 @@ FlyFunction_GetMonIcon: Unreferenced_GetMonIcon2: push de - ld a, [wd265] + ld a, [wTempIconSpecies] call ReadMonMenuIcon ld [wCurIcon], a pop de diff --git a/engine/gfx/pic_animation.asm b/engine/gfx/pic_animation.asm index 843e5cba4..af0227a2a 100644 --- a/engine/gfx/pic_animation.asm +++ b/engine/gfx/pic_animation.asm @@ -40,8 +40,8 @@ AnimateMon_Hatch: call AnimateFrontpic ret -AnimateMon_Unused: - ld e, ANIM_MON_UNUSED +AnimateMon_HOF: + ld e, ANIM_MON_HOF ld d, $0 call AnimateFrontpic ret @@ -59,13 +59,14 @@ endr ENDM PokeAnims: +; entries correspond to ANIM_MON_* constants dw .Slow dw .Normal dw .Menu dw .Trade dw .Evolve dw .Hatch - dw .Unused ; same as .Menu + dw .HOF dw .Egg1 dw .Egg2 @@ -75,7 +76,7 @@ PokeAnims: .Trade: pokeanim Idle, Play2, Idle, Play, SetWait, Wait, Cry, Setup, Play .Evolve: pokeanim Idle, Play, SetWait, Wait, CryNoWait, Setup, Play .Hatch: pokeanim Idle, Play, CryNoWait, Setup, Play, SetWait, Wait, Idle, Play -.Unused: pokeanim CryNoWait, Setup, Play, SetWait, Wait, Idle, Play +.HOF: pokeanim CryNoWait, Setup, Play, SetWait, Wait, Idle, Play .Egg1: pokeanim Setup, Play .Egg2: pokeanim Idle, Play @@ -108,7 +109,7 @@ LoadMonAnimation: SetUpPokeAnim: ld a, [rSVBK] push af - ld a, BANK(wPokeAnimSceneIndex) + ld a, BANK(wPokeAnimStruct) ld [rSVBK], a ld a, [wPokeAnimSceneIndex] ld c, a @@ -283,14 +284,14 @@ AnimateMon_CheckIfPokemon: PokeAnim_InitPicAttributes: ld a, [rSVBK] push af - ld a, BANK(wPokeAnimSceneIndex) + ld a, BANK(wPokeAnimStruct) ld [rSVBK], a push bc push de push hl - ld hl, wPokeAnimSceneIndex - ld bc, wPokeAnimStructEnd - wPokeAnimSceneIndex + ld hl, wPokeAnimStruct + ld bc, wPokeAnimStructEnd - wPokeAnimStruct xor a call ByteFill pop hl diff --git a/engine/gfx/sgb_layouts.asm b/engine/gfx/sgb_layouts.asm index 538132ce2..7279f9a32 100644 --- a/engine/gfx/sgb_layouts.asm +++ b/engine/gfx/sgb_layouts.asm @@ -61,7 +61,7 @@ LoadSGBLayout: .SGB_BattleColors: ld hl, BlkPacket_Battle - call PushSGBPals_ + call PushSGBPals ld hl, PalPacket_9ce6 ld de, wSGBPals @@ -210,7 +210,7 @@ LoadSGBLayout: inc hl ld [hl], HIGH(palred 26 + palgreen 10 + palblue 6) ld a, [wCurPartySpecies] - call GetMonPalettePointer_ + call GetMonPalettePointer ld a, [hli] ld [wSGBPals + 9], a ld a, [hli] @@ -566,6 +566,6 @@ INCLUDE "data/maps/sgb_roof_pal_inds.asm" _LoadSGBLayout_ReturnFromJumpTable: push de - call PushSGBPals_ + call PushSGBPals pop hl - jp PushSGBPals_ + jp PushSGBPals diff --git a/engine/items/item_effects.asm b/engine/items/item_effects.asm index 1439b2c6d..e751b42e6 100644 --- a/engine/items/item_effects.asm +++ b/engine/items/item_effects.asm @@ -1,6 +1,6 @@ _DoItemEffect:: ld a, [wCurItem] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetItemName call CopyName1 ld a, 1 @@ -489,7 +489,7 @@ PokeBallEffect: ld a, [wEnemyMonSpecies] ld [wWildMon], a ld [wCurPartySpecies], a - ld [wd265], a + ld [wTempSpecies], a ld a, [wBattleType] cp BATTLETYPE_TUTORIAL jp z, .FinishTutorial @@ -501,13 +501,13 @@ PokeBallEffect: call ClearSprites - ld a, [wd265] + ld a, [wTempSpecies] dec a call CheckCaughtMon ld a, c push af - ld a, [wd265] + ld a, [wTempSpecies] dec a call SetSeenAndCaughtMon pop af @@ -523,7 +523,7 @@ PokeBallEffect: call ClearSprites ld a, [wEnemyMonSpecies] - ld [wd265], a + ld [wTempSpecies], a predef NewPokedexEntry .skip_pokedex @@ -566,7 +566,7 @@ PokeBallEffect: call PrintText ld a, [wCurPartySpecies] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetPokemonName call YesNoBox @@ -626,7 +626,7 @@ PokeBallEffect: call PrintText ld a, [wCurPartySpecies] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetPokemonName call YesNoBox @@ -1276,7 +1276,7 @@ Table_eeeb: RareCandy_StatBooster_GetParameters: ld a, [wCurPartySpecies] ld [wCurSpecies], a - ld [wd265], a + ld [wTempSpecies], a ld a, MON_LEVEL call GetPartyParamLocation ld a, [hl] @@ -1368,7 +1368,7 @@ RareCandyEffect: xor a ; PARTYMON ld [wMonType], a ld a, [wCurPartySpecies] - ld [wd265], a + ld [wTempSpecies], a predef LearnLevelMoves xor a @@ -2159,7 +2159,7 @@ XItemEffect: ld [hBattleTurn], a ld [wAttackMissed], a ld [wEffectFailed], a - farcall CheckIfStatCanBeRaised + farcall RaiseStat call WaitSFX farcall BattleCommand_StatUpMessage @@ -2344,7 +2344,7 @@ RestorePPEffect: push hl ld a, [hl] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetMoveName call CopyName1 pop hl @@ -2373,8 +2373,8 @@ RestorePPEffect: ld a, [hl] add PP_UP_ONE ld [hl], a - ld a, $1 - ld [wd265], a + ld a, TRUE + ld [wUsePPUp], a call ApplyPPUp call Play_SFX_FULL_HEAL @@ -2492,7 +2492,7 @@ RestorePP: ld hl, wPartyMon1PP ld bc, PARTYMON_STRUCT_LENGTH call GetMthMoveOfNthPartymon - ld a, [wd265] + ld a, [wTempPP] ld b, a ld a, [hl] and PP_MASK @@ -2765,8 +2765,8 @@ ApplyPPUp: ld a, b cp NUM_MOVES + 1 ret z - ld a, [wd265] - dec a + ld a, [wUsePPUp] + dec a ; FALSE? jr nz, .use ld a, [wMenuCursorY] inc a @@ -2822,7 +2822,7 @@ ComputeMaxPP: .okay add b ld b, a - ld a, [wd265] + ld a, [wTempPP] dec a jr z, .NoPPUp dec c @@ -2857,7 +2857,7 @@ RestoreAllPP: ld a, [de] and PP_UP_MASK ld b, a - ld a, [wd265] + ld a, [wTempPP] add b ld [de], a inc de @@ -2933,12 +2933,12 @@ GetMaxPPOfMove: ld hl, wStringBuffer1 + 1 ld [hl], a xor a - ld [wd265], a + ld [wTempPP], a ld a, b ; this gets lost anyway call ComputeMaxPP ld a, [hl] and PP_MASK - ld [wd265], a + ld [wTempPP], a pop af ld [wStringBuffer1 + 1], a diff --git a/engine/items/mart.asm b/engine/items/mart.asm index 7e185662b..8afae541a 100644 --- a/engine/items/mart.asm +++ b/engine/items/mart.asm @@ -54,8 +54,8 @@ BargainShop: ld a, [hli] or [hl] jr z, .skip_set - ld hl, wDailyFlags - set DAILYFLAGS_GOLDENROD_UNDERGROUND_BARGAIN_F, [hl] + ld hl, wDailyFlags1 + set DAILYFLAGS1_GOLDENROD_UNDERGROUND_BARGAIN_F, [hl] .skip_set ld hl, Text_BargainShop_ComeAgain diff --git a/engine/items/print_item_description.asm b/engine/items/print_item_description.asm index b0a3a0b33..5d944e206 100644 --- a/engine/items/print_item_description.asm +++ b/engine/items/print_item_description.asm @@ -9,7 +9,7 @@ PrintItemDescription: push de farcall GetTMHMItemMove pop hl - ld a, [wd265] + ld a, [wTempTMHM] ld [wCurSpecies], a predef PrintMoveDesc ret diff --git a/engine/items/tmhm.asm b/engine/items/tmhm.asm index 4958d2afc..14e481248 100644 --- a/engine/items/tmhm.asm +++ b/engine/items/tmhm.asm @@ -33,7 +33,7 @@ ConvertCurItemIntoCurTMHM: ld c, a callfar GetTMHMNumber ld a, c - ld [wCurTMHM], a + ld [wTempTMHM], a ret GetTMHMItemMove: @@ -50,7 +50,7 @@ AskTeachTMHM: cp TM01 jr c, .NotTMHM call GetTMHMItemMove - ld a, [wCurTMHM] + ld a, [wTempTMHM] ld [wPutativeTMHMMove], a call GetMoveName call CopyName1 @@ -251,9 +251,9 @@ TMHM_ShowTMMoveDescription: ld a, [wCurItem] cp NUM_TMS + NUM_HMS + 1 jr nc, TMHM_JoypadLoop - ld [wd265], a + ld [wTempTMHM], a predef GetTMHMMove - ld a, [wd265] + ld a, [wTempTMHM] ld [wCurSpecies], a hlcoord 1, 14 call PrintMoveDesc @@ -261,14 +261,14 @@ TMHM_ShowTMMoveDescription: TMHM_ChooseTMorHM: call TMHM_PlaySFX_ReadText2 - call CountTMsHMs ; This stores the count to wd265. + call CountTMsHMs ; This stores the count to wTempTMHM. ld a, [wMenuCursorY] dec a ld b, a ld a, [wTMHMPocketScrollPosition] add b ld b, a - ld a, [wd265] + ld a, [wTempTMHM] cp b jr z, _TMHM_ExitPack ; our cursor was hovering over CANCEL TMHM_CheckHoveringOverCancel: @@ -354,16 +354,16 @@ TMHM_DisplayPocketItems: jr z, .loop2 ld b, a ld a, c - ld [wd265], a + ld [wTempTMHM], a push hl push de push bc call TMHMPocket_GetCurrentLineCoord push hl - ld a, [wd265] + ld a, [wTempTMHM] cp NUM_TMS + 1 jr nc, .HM - ld de, wd265 + ld de, wTempTMHM lb bc, PRINTNUM_LEADINGZEROS | 1, 2 call PrintNum jr .okay @@ -371,17 +371,17 @@ TMHM_DisplayPocketItems: .HM: push af sub NUM_TMS - ld [wd265], a + ld [wTempTMHM], a ld [hl], "H" inc hl - ld de, wd265 + ld de, wTempTMHM lb bc, PRINTNUM_RIGHTALIGN | 1, 2 call PrintNum pop af - ld [wd265], a + ld [wTempTMHM], a .okay predef GetTMHMMove - ld a, [wd265] + ld a, [wNamedObjectIndexBuffer] ld [wPutativeTMHMMove], a call GetMoveName pop hl @@ -403,8 +403,8 @@ TMHM_DisplayPocketItems: pop bc push bc ld a, b - ld [wd265], a - ld de, wd265 + ld [wTempTMHM], a + ld de, wTempTMHM lb bc, 1, 2 call PrintNum .hm2 @@ -445,7 +445,7 @@ Unreferenced_Function2ca95: ld bc, 3 add hl, bc predef GetTMHMMove - ld a, [wd265] + ld a, [wTempTMHM] ld [wPutativeTMHMMove], a call GetMoveName push hl @@ -508,7 +508,7 @@ Unreferenced_Function2cadf: db "@" .CheckHaveRoomForTMHM: - ld a, [wd265] + ld a, [wTempTMHM] dec a ld hl, wTMsHMs ld b, 0 @@ -523,7 +523,7 @@ Unreferenced_Function2cadf: ConsumeTM: call ConvertCurItemIntoCurTMHM - ld a, [wd265] + ld a, [wTempTMHM] dec a ld hl, wTMsHMs ld b, 0 @@ -555,20 +555,5 @@ CountTMsHMs: dec c jr nz, .loop ld a, b - ld [wd265], a + ld [wTempTMHM], a ret - -PrintMoveDesc: - push hl - ld hl, MoveDescriptions - ld a, [wCurSpecies] - dec a - ld c, a - ld b, 0 - add hl, bc - add hl, bc - ld a, [hli] - ld e, a - ld d, [hl] - pop hl - jp PlaceString diff --git a/engine/items/tmhm2.asm b/engine/items/tmhm2.asm index 10206d36b..057d0b346 100644 --- a/engine/items/tmhm2.asm +++ b/engine/items/tmhm2.asm @@ -33,14 +33,14 @@ CanLearnTMHMMove: ret GetTMHMMove: - ld a, [wd265] + ld a, [wTempTMHM] dec a ld hl, TMHMMoves ld b, 0 ld c, a add hl, bc ld a, [hl] - ld [wd265], a + ld [wTempTMHM], a ret INCLUDE "data/moves/tmhm_moves.asm" diff --git a/engine/link/link.asm b/engine/link/link.asm index d72abb0a5..5363a3047 100644 --- a/engine/link/link.asm +++ b/engine/link/link.asm @@ -149,13 +149,13 @@ Gen2ToGen1LinkComms: ld a, [hli] cp -1 jr z, .done_party - ld [wd265], a + ld [wTempSpecies], a push hl push de callfar ConvertMon_1to2 pop de pop hl - ld a, [wd265] + ld a, [wTempSpecies] ld [de], a inc de jr .party_loop @@ -651,13 +651,13 @@ Link_PrepPartyData_Gen1: ld a, [hli] cp -1 jr z, .done_party - ld [wd265], a + ld [wTempSpecies], a push hl push de callfar ConvertMon_2to1 pop de pop hl - ld a, [wd265] + ld a, [wTempSpecies] ld [de], a inc de jr .loop2 @@ -692,11 +692,11 @@ Link_PrepPartyData_Gen1: push de push bc ld a, [hl] - ld [wd265], a + ld [wTempSpecies], a callfar ConvertMon_2to1 pop bc pop de - ld a, [wd265] + ld a, [wTempSpecies] ld [de], a inc de ld hl, MON_HP @@ -976,11 +976,11 @@ Function2868a: inc de push bc push de - ld [wd265], a + ld [wTempSpecies], a callfar ConvertMon_1to2 pop de pop bc - ld a, [wd265] + ld a, [wTempSpecies] ld [bc], a ld [wCurSpecies], a ld hl, MON_HP @@ -1461,7 +1461,7 @@ Function28926: ld b, 0 add hl, bc ld a, [hl] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetPokemonName hlcoord 0, 12 ld b, 4 @@ -1619,7 +1619,7 @@ LinkTrade: ld b, 0 add hl, bc ld a, [hl] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetPokemonName ld hl, wStringBuffer1 ld de, wd004 @@ -1631,7 +1631,7 @@ LinkTrade: ld b, 0 add hl, bc ld a, [hl] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetPokemonName ld hl, UnknownText_0x28eb8 bccoord 1, 14 @@ -1971,7 +1971,7 @@ LoadTradeScreenBorder: ret SetTradeRoomBGPals: - farcall LoadTradeRoomBGPals_ ; just a nested farcall; so wasteful + farcall LoadTradeRoomBGPals ; just a nested farcall; so wasteful call SetPalettes ret @@ -2039,7 +2039,7 @@ CheckTimeCapsuleCompatibility: jr nc, .move_too_new dec c jr nz, .move_next - ld de, wPartyMon2 - (wPartyMon1 + NUM_MOVES) + ld de, PARTYMON_STRUCT_LENGTH - NUM_MOVES add hl, de dec b jr nz, .move_loop @@ -2047,14 +2047,14 @@ CheckTimeCapsuleCompatibility: jr .done .mon_too_new - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetPokemonName ld a, $1 jr .done .move_too_new push bc - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetMoveName call CopyName1 pop bc @@ -2079,7 +2079,7 @@ Function29c67: ld hl, wPartyCount add hl, bc ld a, [hl] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetPokemonName ret @@ -2146,13 +2146,13 @@ WaitForOtherPlayerToExit: SetBitsForLinkTradeRequest: ld a, LINK_TRADECENTER - 1 ld [wPlayerLinkAction], a - ld [wd265], a + ld [wChosenCableClubRoom], a ret SetBitsForBattleRequest: ld a, LINK_COLOSSEUM - 1 ld [wPlayerLinkAction], a - ld [wd265], a + ld [wChosenCableClubRoom], a ret SetBitsForTimeCapsuleRequest: @@ -2166,7 +2166,7 @@ SetBitsForTimeCapsuleRequest: ld [rSC], a xor a ; LINK_TIMECAPSULE - 1 ld [wPlayerLinkAction], a - ld [wd265], a + ld [wChosenCableClubRoom], a ret WaitForLinkedFriend: @@ -2373,7 +2373,7 @@ Link_CheckCommunicationError: ret TryQuickSave: - ld a, [wd265] + ld a, [wChosenCableClubRoom] push af farcall Link_SaveGame ld a, TRUE @@ -2384,11 +2384,11 @@ TryQuickSave: ld c, 30 call DelayFrames pop af - ld [wd265], a + ld [wChosenCableClubRoom], a ret CheckBothSelectedSameRoom: - ld a, [wd265] + ld a, [wChosenCableClubRoom] call Link_EnsureSync push af call LinkDataReceived @@ -2396,10 +2396,10 @@ CheckBothSelectedSameRoom: call LinkDataReceived pop af ld b, a - ld a, [wd265] + ld a, [wChosenCableClubRoom] cp b jr nz, .fail - ld a, [wd265] + ld a, [wChosenCableClubRoom] inc a ld [wLinkMode], a xor a diff --git a/engine/link/link_trade.asm b/engine/link/link_trade.asm index a3c596bfe..a250e84fa 100644 --- a/engine/link/link_trade.asm +++ b/engine/link/link_trade.asm @@ -133,8 +133,8 @@ LinkComms_LoadPleaseWaitTextboxBorderGFX: call Get2bpp ret -LoadTradeRoomBGPals_: - farcall LoadTradeRoomBGPals +LoadTradeRoomBGPals: + farcall _LoadTradeRoomBGPals ret Function16d6ae: diff --git a/engine/link/mystery_gift.asm b/engine/link/mystery_gift.asm index 0a5dfcec3..6fba91619 100644 --- a/engine/link/mystery_gift.asm +++ b/engine/link/mystery_gift.asm @@ -1430,7 +1430,7 @@ Function105688: ld de, wMysteryGiftTrainerData farcall Function8ac70 ld a, c - ld [wd265], a + ld [wDeciramBuffer], a ld hl, Text_CardNotRegistered jr c, PrintTextAndExit_JP ld hl, Text_ListedCardAsNumber diff --git a/engine/link/mystery_gift_2.asm b/engine/link/mystery_gift_2.asm index c1b258724..b9c7eccb4 100644 --- a/engine/link/mystery_gift_2.asm +++ b/engine/link/mystery_gift_2.asm @@ -24,7 +24,7 @@ PrepMysteryGiftDataToSend: call CountSetBits pop de pop bc - ld a, [wd265] + ld a, [wNumSetBits] ld [de], a inc de ; wc80f call CloseSRAM diff --git a/engine/link/time_capsule.asm b/engine/link/time_capsule.asm index 195062c1e..499e9fc34 100644 --- a/engine/link/time_capsule.asm +++ b/engine/link/time_capsule.asm @@ -122,7 +122,7 @@ PlaceTradePartnerNamesAndParty: ld a, [de] cp -1 ret z - ld [wd265], a + ld [wNamedObjectIndexBuffer], a push bc push hl push de diff --git a/engine/link/time_capsule_2.asm b/engine/link/time_capsule_2.asm index be7027f34..6640f6b03 100644 --- a/engine/link/time_capsule_2.asm +++ b/engine/link/time_capsule_2.asm @@ -1,8 +1,10 @@ ConvertMon_2to1: -; Takes the Gen-2 Pokemon number stored in wd265, finds it in the Pokered_MonIndices table, and returns its index in wd265. +; Takes the Gen 2 Pokemon number stored in wTempSpecies, +; finds it in the Pokered_MonIndices table, +; and returns its index in wTempSpecies. push bc push hl - ld a, [wd265] + ld a, [wTempSpecies] ld b, a ld c, 0 ld hl, Pokered_MonIndices @@ -12,23 +14,24 @@ ConvertMon_2to1: cp b jr nz, .loop ld a, c - ld [wd265], a + ld [wTempSpecies], a pop hl pop bc ret ConvertMon_1to2: -; Takes the Gen-1 Pokemon number stored in wd265 and returns the corresponding value from Pokered_MonIndices in wd265. +; Takes the Gen 1 Pokemon number stored in wTempSpecies +; and returns the corresponding value from Pokered_MonIndices in wTempSpecies. push bc push hl - ld a, [wd265] + ld a, [wTempSpecies] dec a ld hl, Pokered_MonIndices ld b, 0 ld c, a add hl, bc ld a, [hl] - ld [wd265], a + ld [wTempSpecies], a pop hl pop bc ret diff --git a/engine/menus/debug.asm b/engine/menus/debug.asm index a48322488..efee45e59 100644 --- a/engine/menus/debug.asm +++ b/engine/menus/debug.asm @@ -311,9 +311,9 @@ Function81adb: ld a, [wcf66] inc a ld [wCurPartySpecies], a - ld [wd265], a + ld [wDeciramBuffer], a hlcoord 0, 1 - ld de, wd265 + ld de, wDeciramBuffer lb bc, PRINTNUM_LEADINGZEROS | 1, 3 call PrintNum ld a, [wd002] @@ -353,7 +353,7 @@ Function81adb: jr .asm_81ba9 .asm_81b7a - ld a, [wd265] + ld a, [wDeciramBuffer] ld [wTrainerClass], a callfar GetTrainerAttributes ld de, wStringBuffer1 @@ -738,9 +738,9 @@ Function81df4: call Function81e5e ld a, [wd004] inc a - ld [wd265], a + ld [wTempTMHM], a predef GetTMHMMove - ld a, [wd265] + ld a, [wTempTMHM] ld [wPutativeTMHMMove], a call GetMoveName hlcoord 10, 12 diff --git a/engine/menus/intro_menu.asm b/engine/menus/intro_menu.asm index 9652dd73e..4e145664a 100644 --- a/engine/menus/intro_menu.asm +++ b/engine/menus/intro_menu.asm @@ -593,7 +593,7 @@ Continue_DisplayBadgeCount: ld b, 2 call CountSetBits pop hl - ld de, wd265 + ld de, wNumSetBits lb bc, 1, 2 jp PrintNum @@ -610,7 +610,7 @@ else endc call CountSetBits pop hl - ld de, wd265 + ld de, wNumSetBits lb bc, 1, 3 jp PrintNum diff --git a/engine/menus/menu_2.asm b/engine/menus/menu_2.asm index b039b590f..94732d60b 100644 --- a/engine/menus/menu_2.asm +++ b/engine/menus/menu_2.asm @@ -170,7 +170,7 @@ StartMenu_PrintBugContestStatus: and a ld de, .None jr z, .no_contest_mon - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetPokemonName .no_contest_mon diff --git a/engine/menus/naming_screen.asm b/engine/menus/naming_screen.asm index 8a8303067..aa8ccddf8 100644 --- a/engine/menus/naming_screen.asm +++ b/engine/menus/naming_screen.asm @@ -84,13 +84,13 @@ NamingScreen: .Pokemon: ld a, [wCurPartySpecies] - ld [wd265], a + ld [wTempIconSpecies], a ld hl, LoadMenuMonIcon ld a, BANK(LoadMenuMonIcon) - ld e, $1 - rst FarCall ; ; indirect jump to LoadMenuMonIcon (8e83f (23:683f)) + ld e, MONICON_NAMINGSCREEN + rst FarCall ld a, [wCurPartySpecies] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetPokemonName hlcoord 5, 2 call PlaceString diff --git a/engine/menus/options_menu.asm b/engine/menus/options_menu.asm index 46fa33621..4dc6c0fe1 100644 --- a/engine/menus/options_menu.asm +++ b/engine/menus/options_menu.asm @@ -61,20 +61,20 @@ _OptionsMenu: ret StringOptions: - db "TEXT SPEED<LNBRK>" - db " :<LNBRK>" - db "BATTLE SCENE<LNBRK>" - db " :<LNBRK>" - db "BATTLE STYLE<LNBRK>" - db " :<LNBRK>" - db "SOUND<LNBRK>" - db " :<LNBRK>" - db "PRINT<LNBRK>" - db " :<LNBRK>" - db "MENU ACCOUNT<LNBRK>" - db " :<LNBRK>" - db "FRAME<LNBRK>" - db " :TYPE<LNBRK>" + db "TEXT SPEED<LF>" + db " :<LF>" + db "BATTLE SCENE<LF>" + db " :<LF>" + db "BATTLE STYLE<LF>" + db " :<LF>" + db "SOUND<LF>" + db " :<LF>" + db "PRINT<LF>" + db " :<LF>" + db "MENU ACCOUNT<LF>" + db " :<LF>" + db "FRAME<LF>" + db " :TYPE<LF>" db "CANCEL@" GetOptionPointer: @@ -165,7 +165,7 @@ GetTextSpeed: ; converts TEXT_DELAY_* value in a to OPT_TEXT_SPEED_* value in c, ; with previous/next TEXT_DELAY_* values in d/e ld a, [wOptions] - and $7 + and TEXT_DELAY_MASK cp TEXT_DELAY_SLOW jr z, .slow cp TEXT_DELAY_FAST @@ -467,7 +467,7 @@ Options_Frame: dec a .Save: - and $7 + maskbits NUM_FRAMES ld [hl], a UpdateFrame: ld a, [wTextBoxFrame] diff --git a/engine/menus/save.asm b/engine/menus/save.asm index 469c55abd..ad9f0b5b2 100644 --- a/engine/menus/save.asm +++ b/engine/menus/save.asm @@ -89,7 +89,7 @@ MoveMonWOMail_InsertMon_SaveGame: pop de ld a, e ld [wCurBox], a - ld a, $1 + ld a, TRUE ld [wSaveFileExists], a farcall StageRTCTimeForSave farcall BackupMysteryGift @@ -133,12 +133,12 @@ StartMoveMonWOMail_SaveGame: ret PauseGameLogic: - ld a, $1 + ld a, TRUE ld [wGameLogicPaused], a ret ResumeGameLogic: - xor a + xor a ; FALSE ld [wGameLogicPaused], a ret @@ -164,7 +164,7 @@ AddHallOfFameEntry: ret SaveGameData: - call SaveGameData_ + call _SaveGameData ret AskOverwriteSaveFile: @@ -228,15 +228,15 @@ CompareLoadedAndSavedPlayerID: _SavingDontTurnOffThePower: call SavingDontTurnOffThePower SavedTheGame: - call SaveGameData_ + call _SaveGameData ; wait 32 frames - ld c, $20 + ld c, 32 call DelayFrames ; copy the original text speed setting to the stack ld a, [wOptions] push af - ; set text speed super slow - ld a, 3 + ; set text speed to medium + ld a, TEXT_DELAY_MED ld [wOptions], a ; <PLAYER> saved the game! ld hl, Text_PlayerSavedTheGame @@ -248,12 +248,12 @@ SavedTheGame: call WaitPlaySFX call WaitSFX ; wait 30 frames - ld c, $1e + ld c, 30 call DelayFrames ret -SaveGameData_: - ld a, 1 +_SaveGameData: + ld a, TRUE ld [wSaveFileExists], a farcall StageRTCTimeForSave farcall BackupMysteryGift @@ -332,8 +332,8 @@ SavingDontTurnOffThePower: ; Save the text speed setting to the stack ld a, [wOptions] push af - ; Set the text speed to super slow - ld a, $3 + ; Set the text speed to medium + ld a, TEXT_DELAY_MED ld [wOptions], a ; SAVING... DON'T TURN OFF THE POWER. ld hl, Text_SavingDontTurnOffThePower @@ -342,7 +342,7 @@ SavingDontTurnOffThePower: pop af ld [wOptions], a ; Wait for 16 frames - ld c, $10 + ld c, 16 call DelayFrames ret @@ -627,7 +627,7 @@ TryLoadSaveFile: ret TryLoadSaveData: - xor a + xor a ; FALSE ld [wSaveFileExists], a call CheckPrimarySaveFile ld a, [wSaveFileExists] @@ -690,7 +690,7 @@ CheckPrimarySaveFile: ld bc, wOptionsEnd - wOptions call CopyBytes call CloseSRAM - ld a, $1 + ld a, TRUE ld [wSaveFileExists], a .nope diff --git a/engine/menus/start_menu.asm b/engine/menus/start_menu.asm index 108a4edf6..d8596840f 100644 --- a/engine/menus/start_menu.asm +++ b/engine/menus/start_menu.asm @@ -29,7 +29,7 @@ StartMenu:: call .SetUpMenuItems ld a, [wBattleMenuCursorBuffer] ld [wMenuCursorBuffer], a - call .DrawMenuAccount_ + call .DrawMenuAccount call DrawVariableLengthMenuBox call .DrawBugContestStatusBox call SafeUpdateSprites @@ -49,7 +49,7 @@ StartMenu:: .Select: call .GetInput jr c, .Exit - call .DrawMenuAccount + call ._DrawMenuAccount ld a, [wMenuCursorBuffer] ld [wBattleMenuCursorBuffer], a call PlayClickSFX @@ -96,7 +96,7 @@ StartMenu:: ; Return carry on exit, and no-carry on selection. xor a ld [hBGMapMode], a - call .DrawMenuAccount + call ._DrawMenuAccount call SetUpMenu ld a, $ff ld [wMenuSelection], a @@ -147,7 +147,7 @@ StartMenu:: call ClearBGPalettes call Call_ExitMenu call ReloadTilesetAndPalettes - call .DrawMenuAccount_ + call .DrawMenuAccount call DrawVariableLengthMenuBox call .DrawBugContestStatus call UpdateSprites @@ -360,17 +360,17 @@ endr inc c ret -.DrawMenuAccount_: - jp .DrawMenuAccount +.DrawMenuAccount: + jp ._DrawMenuAccount .PrintMenuAccount: call .IsMenuAccountOn ret z - call .DrawMenuAccount + call ._DrawMenuAccount decoord 0, 14 jp .MenuDesc -.DrawMenuAccount: +._DrawMenuAccount: call .IsMenuAccountOn ret z hlcoord 0, 13 @@ -539,1309 +539,3 @@ StartMenu_Pokemon: call ExitAllMenus pop af ret - -HasNoItems: - ld a, [wNumItems] - and a - ret nz - ld a, [wNumKeyItems] - and a - ret nz - ld a, [wNumBalls] - and a - ret nz - ld hl, wTMsHMs - ld b, NUM_TMS + NUM_HMS -.loop - ld a, [hli] - and a - jr nz, .done - dec b - jr nz, .loop - scf - ret -.done - and a - ret - -TossItemFromPC: - push de - call PartyMonItemName - farcall _CheckTossableItem - ld a, [wItemAttributeParamBuffer] - and a - jr nz, .key_item - ld hl, .TossHowMany - call MenuTextBox - farcall SelectQuantityToToss - push af - call CloseWindow - call ExitMenu - pop af - jr c, .quit - ld hl, .ConfirmToss - call MenuTextBox - call YesNoBox - push af - call ExitMenu - pop af - jr c, .quit - pop hl - ld a, [wCurItemQuantity] - call TossItem - call PartyMonItemName - ld hl, .TossedThisMany - call MenuTextBox - call ExitMenu - and a - ret - -.key_item - call .CantToss -.quit - pop hl - scf - ret - -.TossHowMany: - ; Toss out how many @ (S)? - text_jump UnknownText_0x1c1a90 - db "@" - -.ConfirmToss: - ; Throw away @ @ (S)? - text_jump UnknownText_0x1c1aad - db "@" - -.TossedThisMany: - ; Discarded @ (S). - text_jump UnknownText_0x1c1aca - db "@" - -.CantToss: - ld hl, .TooImportantToToss - call MenuTextBoxBackup - ret - -.TooImportantToToss: - ; That's too impor- tant to toss out! - text_jump UnknownText_0x1c1adf - db "@" - -CantUseItem: - ld hl, CantUseItemText - call MenuTextBoxWaitButton - ret - -CantUseItemText: - text_jump UnknownText_0x1c1b03 - db "@" - -PartyMonItemName: - ld a, [wCurItem] - ld [wd265], a - call GetItemName - call CopyName1 - ret - -CancelPokemonAction: - farcall InitPartyMenuWithCancel - farcall UnfreezeMonIcons - ld a, 1 - ret - -PokemonActionSubmenu: - hlcoord 1, 15 - lb bc, 2, 18 - call ClearBox - farcall MonSubmenu - call GetCurNick - ld a, [wMenuSelection] - ld hl, .Actions - ld de, 3 - call IsInArray - jr nc, .nothing - - inc hl - ld a, [hli] - ld h, [hl] - ld l, a - jp hl - -.nothing - ld a, 0 - ret - -.Actions: - dbw MONMENUITEM_CUT, MonMenu_Cut - dbw MONMENUITEM_FLY, MonMenu_Fly - dbw MONMENUITEM_SURF, MonMenu_Surf - dbw MONMENUITEM_STRENGTH, MonMenu_Strength - dbw MONMENUITEM_FLASH, MonMenu_Flash - dbw MONMENUITEM_WHIRLPOOL, MonMenu_Whirlpool - dbw MONMENUITEM_DIG, MonMenu_Dig - dbw MONMENUITEM_TELEPORT, MonMenu_Teleport - dbw MONMENUITEM_SOFTBOILED, MonMenu_Softboiled_MilkDrink - dbw MONMENUITEM_MILKDRINK, MonMenu_Softboiled_MilkDrink - dbw MONMENUITEM_HEADBUTT, MonMenu_Headbutt - dbw MONMENUITEM_WATERFALL, MonMenu_Waterfall - dbw MONMENUITEM_ROCKSMASH, MonMenu_RockSmash - dbw MONMENUITEM_SWEETSCENT, MonMenu_SweetScent - dbw MONMENUITEM_STATS, OpenPartyStats - dbw MONMENUITEM_SWITCH, SwitchPartyMons - dbw MONMENUITEM_ITEM, GiveTakePartyMonItem - dbw MONMENUITEM_CANCEL, CancelPokemonAction - dbw MONMENUITEM_MOVE, ManagePokemonMoves - dbw MONMENUITEM_MAIL, MonMailAction - -SwitchPartyMons: -; Don't try if there's nothing to switch! - ld a, [wPartyCount] - cp 2 - jr c, .DontSwitch - - ld a, [wCurPartyMon] - inc a - ld [wSwitchMon], a - - farcall HoldSwitchmonIcon - farcall InitPartyMenuNoCancel - - ld a, PARTYMENUACTION_MOVE - ld [wPartyMenuActionText], a - farcall WritePartyMenuTilemap - farcall PrintPartyMenuText - - hlcoord 0, 1 - ld bc, SCREEN_WIDTH * 2 - ld a, [wSwitchMon] - dec a - call AddNTimes - ld [hl], "▷" - call WaitBGMap - call SetPalettes - call DelayFrame - - farcall PartyMenuSelect - bit 1, b - jr c, .DontSwitch - - farcall _SwitchPartyMons - - xor a - ld [wPartyMenuActionText], a - - farcall LoadPartyMenuGFX - farcall InitPartyMenuWithCancel - farcall InitPartyMenuGFX - - ld a, 1 - ret - -.DontSwitch: - xor a - ld [wPartyMenuActionText], a - call CancelPokemonAction - ret - -GiveTakePartyMonItem: -; Eggs can't hold items! - ld a, [wCurPartySpecies] - cp EGG - jr z, .cancel - - ld hl, GiveTakeItemMenuData - call LoadMenuHeader - call VerticalMenu - call ExitMenu - jr c, .cancel - - call GetCurNick - ld hl, wStringBuffer1 - ld de, wMonOrItemNameBuffer - ld bc, MON_NAME_LENGTH - call CopyBytes - ld a, [wMenuCursorY] - cp 1 - jr nz, .take - - call LoadStandardMenuHeader - call ClearPalettes - call .GiveItem - call ClearPalettes - call LoadFontsBattleExtra - call ExitMenu - ld a, 0 - ret - -.take - call TakePartyItem - ld a, 3 - ret - -.cancel - ld a, 3 - ret - -.GiveItem: - farcall DepositSellInitPackBuffers - -.loop - farcall DepositSellPack - - ld a, [wcf66] - and a - jr z, .quit - - ld a, [wcf65] - cp 2 - jr z, .next - - call CheckTossableItem - ld a, [wItemAttributeParamBuffer] - and a - jr nz, .next - - call TryGiveItemToPartymon - jr .quit - -.next - ld hl, CantBeHeldText - call MenuTextBoxBackup - jr .loop - -.quit - ret - -TryGiveItemToPartymon: - call SpeechTextBox - call PartyMonItemName - call GetPartyItemLocation - ld a, [hl] - and a - jr z, .give_item_to_mon - - push hl - ld d, a - farcall ItemIsMail - pop hl - jr c, .please_remove_mail - ld a, [hl] - jr .already_holding_item - -.give_item_to_mon - call GiveItemToPokemon - ld hl, MadeHoldText - call MenuTextBoxBackup - call GivePartyItem - ret - -.please_remove_mail - ld hl, PleaseRemoveMailText - call MenuTextBoxBackup - ret - -.already_holding_item - ld [wd265], a - call GetItemName - ld hl, SwitchAlreadyHoldingText - call StartMenuYesNo - jr c, .abort - - call GiveItemToPokemon - ld a, [wd265] - push af - ld a, [wCurItem] - ld [wd265], a - pop af - ld [wCurItem], a - call ReceiveItemFromPokemon - jr nc, .bag_full - - ld hl, TookAndMadeHoldText - call MenuTextBoxBackup - ld a, [wd265] - ld [wCurItem], a - call GivePartyItem - ret - -.bag_full - ld a, [wd265] - ld [wCurItem], a - call ReceiveItemFromPokemon - ld hl, ItemStorageIsFullText - call MenuTextBoxBackup - -.abort - ret - -GivePartyItem: - call GetPartyItemLocation - ld a, [wCurItem] - ld [hl], a - ld d, a - farcall ItemIsMail - jr nc, .done - call ComposeMailMessage - -.done - ret - -TakePartyItem: - call SpeechTextBox - call GetPartyItemLocation - ld a, [hl] - and a - jr z, .asm_12c8c - - ld [wCurItem], a - call ReceiveItemFromPokemon - jr nc, .asm_12c94 - - farcall ItemIsMail - call GetPartyItemLocation - ld a, [hl] - ld [wd265], a - ld [hl], NO_ITEM - call GetItemName - ld hl, TookFromText - call MenuTextBoxBackup - jr .asm_12c9a - -.asm_12c8c - ld hl, IsntHoldingAnythingText - call MenuTextBoxBackup - jr .asm_12c9a - -.asm_12c94 - ld hl, ItemStorageIsFullText - call MenuTextBoxBackup - -.asm_12c9a - ret - -GiveTakeItemMenuData: - db MENU_SPRITE_ANIMS | MENU_BACKUP_TILES ; flags - menu_coords 12, 12, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 - dw .Items - db 1 ; default option - -.Items: - db STATICMENU_CURSOR ; flags - db 2 ; # items - db "GIVE@" - db "TAKE@" - -TookAndMadeHoldText: - text_jump UnknownText_0x1c1b2c - db "@" - -MadeHoldText: - text_jump UnknownText_0x1c1b57 - db "@" - -PleaseRemoveMailText: - text_jump UnknownText_0x1c1b6f - db "@" - -IsntHoldingAnythingText: - text_jump UnknownText_0x1c1b8e - db "@" - -ItemStorageIsFullText: - text_jump UnknownText_0x1c1baa - db "@" - -TookFromText: - text_jump UnknownText_0x1c1bc4 - db "@" - -SwitchAlreadyHoldingText: - text_jump UnknownText_0x1c1bdc - db "@" - -CantBeHeldText: - text_jump UnknownText_0x1c1c09 - db "@" - -GetPartyItemLocation: - push af - ld a, MON_ITEM - call GetPartyParamLocation - pop af - ret - -ReceiveItemFromPokemon: - ld a, 1 - ld [wItemQuantityChangeBuffer], a - ld hl, wNumItems - jp ReceiveItem - -GiveItemToPokemon: - ld a, 1 - ld [wItemQuantityChangeBuffer], a - ld hl, wNumItems - jp TossItem - -StartMenuYesNo: - call MenuTextBox - call YesNoBox - jp ExitMenu - -ComposeMailMessage: - ld de, wTempMailMessage - farcall _ComposeMailMessage - ld hl, wPlayerName - ld de, wTempMailAuthor - ld bc, NAME_LENGTH - 1 - call CopyBytes - ld hl, wPlayerID - ld bc, 2 - call CopyBytes - ld a, [wCurPartySpecies] - ld [de], a - inc de - ld a, [wCurItem] - ld [de], a - ld a, [wCurPartyMon] - ld hl, sPartyMail - ld bc, MAIL_STRUCT_LENGTH - call AddNTimes - ld d, h - ld e, l - ld hl, wTempMail - ld bc, MAIL_STRUCT_LENGTH - ld a, BANK(sPartyMail) - call GetSRAMBank - call CopyBytes - call CloseSRAM - ret - -MonMailAction: -; If in the time capsule or trade center, -; selecting the mail only allows you to -; read the mail. - ld a, [wLinkMode] - cp LINK_TIMECAPSULE - jr z, .read - cp LINK_TRADECENTER - jr z, .read - -; Show the READ/TAKE/QUIT menu. - ld hl, .MenuHeader - call LoadMenuHeader - call VerticalMenu - call ExitMenu - -; Interpret the menu. - jp c, .done - ld a, [wMenuCursorY] - cp $1 - jr z, .read - cp $2 - jr z, .take - jp .done - -.read - farcall ReadPartyMonMail - ld a, $0 - ret - -.take - ld hl, .sendmailtopctext - call StartMenuYesNo - jr c, .RemoveMailToBag - ld a, [wCurPartyMon] - ld b, a - farcall SendMailToPC - jr c, .MailboxFull - ld hl, .sentmailtopctext - call MenuTextBoxBackup - jr .done - -.MailboxFull: - ld hl, .mailboxfulltext - call MenuTextBoxBackup - jr .done - -.RemoveMailToBag: - ld hl, .mailwilllosemessagetext - call StartMenuYesNo - jr c, .done - call GetPartyItemLocation - ld a, [hl] - ld [wCurItem], a - call ReceiveItemFromPokemon - jr nc, .BagIsFull - call GetPartyItemLocation - ld [hl], $0 - call GetCurNick - ld hl, .tookmailfrommontext - call MenuTextBoxBackup - jr .done - -.BagIsFull: - ld hl, .bagfulltext - call MenuTextBoxBackup - jr .done - -.done - ld a, $3 - ret - -.MenuHeader: - db MENU_BACKUP_TILES ; flags - menu_coords 12, 10, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 - dw .MenuData - db 1 ; default option - -.MenuData: - db STATICMENU_CURSOR ; flags - db 3 ; items - db "READ@" - db "TAKE@" - db "QUIT@" - -.mailwilllosemessagetext -; The MAIL will lose its message. OK? - text_jump UnknownText_0x1c1c22 - db "@" - -.tookmailfrommontext -; MAIL detached from <POKEMON>. - text_jump UnknownText_0x1c1c47 - db "@" - -.bagfulltext -; There's no space for removing MAIL. - text_jump UnknownText_0x1c1c62 - db "@" - -.sendmailtopctext -; Send the removed MAIL to your PC? - text_jump UnknownText_0x1c1c86 - db "@" - -.mailboxfulltext -; Your PC's MAILBOX is full. - text_jump UnknownText_0x1c1ca9 - db "@" - -.sentmailtopctext -; The MAIL was sent to your PC. - text_jump UnknownText_0x1c1cc4 - db "@" - -OpenPartyStats: - call LoadStandardMenuHeader - call ClearSprites -; PartyMon - xor a - ld [wMonType], a - call LowVolume - predef StatsScreenInit - call MaxVolume - call Call_ExitMenu - ld a, 0 - ret - -MonMenu_Cut: - farcall CutFunction - ld a, [wFieldMoveSucceeded] - cp $1 - jr nz, .Fail - ld b, $4 - ld a, $2 - ret - -.Fail: - ld a, $3 - ret - -MonMenu_Fly: - farcall FlyFunction - ld a, [wFieldMoveSucceeded] - cp $2 - jr z, .Fail - cp $0 - jr z, .Error - farcall StubbedTrainerRankings_Fly - ld b, $4 - ld a, $2 - ret - -.Fail: - ld a, $3 - ret - -.Error: - ld a, $0 - ret - -.Unreferenced: - ld a, $1 - ret - -MonMenu_Flash: - farcall OWFlash - ld a, [wFieldMoveSucceeded] - cp $1 - jr nz, .Fail - ld b, $4 - ld a, $2 - ret - -.Fail: - ld a, $3 - ret - -MonMenu_Strength: - farcall StrengthFunction - ld a, [wFieldMoveSucceeded] - cp $1 - jr nz, .Fail - ld b, $4 - ld a, $2 - ret - -.Fail: - ld a, $3 - ret - -MonMenu_Whirlpool: - farcall WhirlpoolFunction - ld a, [wFieldMoveSucceeded] - cp $1 - jr nz, .Fail - ld b, $4 - ld a, $2 - ret - -.Fail: - ld a, $3 - ret - -MonMenu_Waterfall: - farcall WaterfallFunction - ld a, [wFieldMoveSucceeded] - cp $1 - jr nz, .Fail - ld b, $4 - ld a, $2 - ret - -.Fail: - ld a, $3 - ret - -MonMenu_Teleport: - farcall TeleportFunction - ld a, [wFieldMoveSucceeded] - and a - jr z, .Fail - ld b, $4 - ld a, $2 - ret - -.Fail: - ld a, $3 - ret - -MonMenu_Surf: - farcall SurfFunction - ld a, [wFieldMoveSucceeded] - and a - jr z, .Fail - ld b, $4 - ld a, $2 - ret - -.Fail: - ld a, $3 - ret - -MonMenu_Dig: - farcall DigFunction - ld a, [wFieldMoveSucceeded] - cp $1 - jr nz, .Fail - ld b, $4 - ld a, $2 - ret - -.Fail: - ld a, $3 - ret - -MonMenu_Softboiled_MilkDrink: - call .CheckMonHasEnoughHP - jr nc, .NotEnoughHP - farcall Softboiled_MilkDrinkFunction - jr .finish - -.NotEnoughHP: - ld hl, .Text_NotEnoughHP - call PrintText - -.finish - xor a - ld [wPartyMenuActionText], a - ld a, $3 - ret - -.Text_NotEnoughHP: - ; Not enough HP! - text_jump UnknownText_0x1c1ce3 - db "@" - -.CheckMonHasEnoughHP: -; Need to have at least (MaxHP / 5) HP left. - ld a, MON_MAXHP - call GetPartyParamLocation - ld a, [hli] - ld [hDividend + 0], a - ld a, [hl] - ld [hDividend + 1], a - ld a, 5 - ld [hDivisor], a - ld b, 2 - call Divide - ld a, MON_HP + 1 - call GetPartyParamLocation - ld a, [hQuotient + 2] - sub [hl] - dec hl - ld a, [hQuotient + 1] - sbc [hl] - ret - -MonMenu_Headbutt: - farcall HeadbuttFunction - ld a, [wFieldMoveSucceeded] - cp $1 - jr nz, .Fail - ld b, $4 - ld a, $2 - ret - -.Fail: - ld a, $3 - ret - -MonMenu_RockSmash: - farcall RockSmashFunction - ld a, [wFieldMoveSucceeded] - cp $1 - jr nz, .Fail - ld b, $4 - ld a, $2 - ret - -.Fail: - ld a, $3 - ret - -MonMenu_SweetScent: - farcall SweetScentFromMenu - ld b, $4 - ld a, $2 - ret - -ChooseMoveToDelete: - ld hl, wOptions - ld a, [hl] - push af - set NO_TEXT_SCROLL, [hl] - call LoadFontsBattleExtra - call .ChooseMoveToDelete - pop bc - ld a, b - ld [wOptions], a - push af - call ClearBGPalettes - pop af - ret - -.ChooseMoveToDelete - call SetUpMoveScreenBG - ld de, DeleteMoveScreenAttrs - call SetMenuAttributes - call SetUpMoveList - ld hl, w2DMenuFlags1 - set 6, [hl] - jr .enter_loop - -.loop - call ScrollingMenuJoypad - bit B_BUTTON_F, a - jp nz, .b_button - bit A_BUTTON_F, a - jp nz, .a_button - -.enter_loop - call PrepareToPlaceMoveData - call PlaceMoveData - jp .loop - -.a_button - and a - jr .finish - -.b_button - scf - -.finish - push af - xor a - ld [wSwitchMon], a - ld hl, w2DMenuFlags1 - res 6, [hl] - call ClearSprites - call ClearTileMap - pop af - ret - -DeleteMoveScreenAttrs: - db 3, 1 - db 3, 1 - db $40, $00 - dn 2, 0 - db D_UP | D_DOWN | A_BUTTON | B_BUTTON - -ManagePokemonMoves: - ld a, [wCurPartySpecies] - cp EGG - jr z, .egg - ld hl, wOptions - ld a, [hl] - push af - set NO_TEXT_SCROLL, [hl] - call MoveScreenLoop - pop af - ld [wOptions], a - call ClearBGPalettes - -.egg - ld a, $0 - ret - -MoveScreenLoop: - ld a, [wCurPartyMon] - inc a - ld [wPartyMenuCursor], a - call SetUpMoveScreenBG - call Function132d3 - ld de, MoveScreenAttributes - call SetMenuAttributes -.loop - call SetUpMoveList - ld hl, w2DMenuFlags1 - set 6, [hl] - jr .skip_joy - -.joy_loop - call ScrollingMenuJoypad - bit 1, a - jp nz, .b_button - bit 0, a - jp nz, .a_button - bit 4, a - jp nz, .d_right - bit 5, a - jp nz, .d_left - -.skip_joy - call PrepareToPlaceMoveData - ld a, [wMoveSwapBuffer] - and a - jr nz, .moving_move - call PlaceMoveData - jp .joy_loop - -.moving_move - ld a, " " - hlcoord 1, 11 - ld bc, 5 - call ByteFill - hlcoord 1, 12 - lb bc, 5, SCREEN_WIDTH - 2 - call ClearBox - hlcoord 1, 12 - ld de, String_MoveWhere - call PlaceString - jp .joy_loop -.b_button - call PlayClickSFX - call WaitSFX - ld a, [wMoveSwapBuffer] - and a - jp z, .exit - - ld a, [wMoveSwapBuffer] - ld [wMenuCursorY], a - xor a - ld [wMoveSwapBuffer], a - hlcoord 1, 2 - lb bc, 8, SCREEN_WIDTH - 2 - call ClearBox - jp .loop - -.d_right - ld a, [wMoveSwapBuffer] - and a - jp nz, .joy_loop - - ld a, [wCurPartyMon] - ld b, a - push bc - call .cycle_right - pop bc - ld a, [wCurPartyMon] - cp b - jp z, .joy_loop - jp MoveScreenLoop - -.d_left - ld a, [wMoveSwapBuffer] - and a - jp nz, .joy_loop - ld a, [wCurPartyMon] - ld b, a - push bc - call .cycle_left - pop bc - ld a, [wCurPartyMon] - cp b - jp z, .joy_loop - jp MoveScreenLoop - -.cycle_right - ld a, [wCurPartyMon] - inc a - ld [wCurPartyMon], a - ld c, a - ld b, 0 - ld hl, wPartySpecies - add hl, bc - ld a, [hl] - cp -1 - jr z, .cycle_left - cp EGG - ret nz - jr .cycle_right - -.cycle_left - ld a, [wCurPartyMon] - and a - ret z -.cycle_left_loop - ld a, [wCurPartyMon] - dec a - ld [wCurPartyMon], a - ld c, a - ld b, 0 - ld hl, wPartySpecies - add hl, bc - ld a, [hl] - cp EGG - ret nz - ld a, [wCurPartyMon] - and a - jr z, .cycle_right - jr .cycle_left_loop - -.a_button - call PlayClickSFX - call WaitSFX - ld a, [wMoveSwapBuffer] - and a - jr nz, .place_move - ld a, [wMenuCursorY] - ld [wMoveSwapBuffer], a - call PlaceHollowCursor - jp .moving_move - -.place_move - ld hl, wPartyMon1Moves - ld bc, PARTYMON_STRUCT_LENGTH - ld a, [wCurPartyMon] - call AddNTimes - push hl - call .copy_move - pop hl - ld bc, $15 - add hl, bc - call .copy_move - ld a, [wBattleMode] - jr z, .swap_moves - ld hl, wBattleMonMoves - ld bc, $20 - ld a, [wCurPartyMon] - call AddNTimes - push hl - call .copy_move - pop hl - ld bc, 6 - add hl, bc - call .copy_move - -.swap_moves - ld de, SFX_SWITCH_POKEMON - call PlaySFX - call WaitSFX - ld de, SFX_SWITCH_POKEMON - call PlaySFX - call WaitSFX - hlcoord 1, 2 - lb bc, 8, 18 - call ClearBox - hlcoord 10, 10 - lb bc, 1, 9 - call ClearBox - jp .loop - -.copy_move - push hl - ld a, [wMenuCursorY] - dec a - ld c, a - ld b, $0 - add hl, bc - ld d, h - ld e, l - pop hl - ld a, [wMoveSwapBuffer] - dec a - ld c, a - ld b, $0 - add hl, bc - ld a, [de] - ld b, [hl] - ld [hl], a - ld a, b - ld [de], a - ret - -.exit - xor a - ld [wMoveSwapBuffer], a - ld hl, w2DMenuFlags1 - res 6, [hl] - call ClearSprites - jp ClearTileMap - -MoveScreenAttributes: - db 3, 1 - db 3, 1 - db $40, $00 - dn 2, 0 - db D_UP | D_DOWN | D_LEFT | D_RIGHT | A_BUTTON | B_BUTTON - -String_MoveWhere: - db "Where?@" - -SetUpMoveScreenBG: - call ClearBGPalettes - call ClearTileMap - call ClearSprites - xor a - ld [hBGMapMode], a - farcall LoadStatsScreenPageTilesGFX - farcall ClearSpriteAnims2 - ld a, [wCurPartyMon] - ld e, a - ld d, $0 - ld hl, wPartySpecies - add hl, de - ld a, [hl] - ld [wd265], a - ld e, $2 - farcall LoadMenuMonIcon - hlcoord 0, 1 - ld b, 9 - ld c, 18 - call TextBox - hlcoord 0, 11 - ld b, 5 - ld c, 18 - call TextBox - hlcoord 2, 0 - lb bc, 2, 3 - call ClearBox - xor a - ld [wMonType], a - ld hl, wPartyMonNicknames - ld a, [wCurPartyMon] - call GetNick - hlcoord 5, 1 - call PlaceString - push bc - farcall CopyMonToTempMon - pop hl - call PrintLevel - ld hl, wPlayerHPPal - call SetHPPal - ld b, SCGB_MOVE_LIST - call GetSGBLayout - hlcoord 16, 0 - lb bc, 1, 3 - jp ClearBox - -SetUpMoveList: - xor a - ld [hBGMapMode], a - ld [wMoveSwapBuffer], a - ld [wMonType], a - predef CopyMonToTempMon - ld hl, wTempMonMoves - ld de, wListMoves_MoveIndicesBuffer - ld bc, NUM_MOVES - call CopyBytes - ld a, SCREEN_WIDTH * 2 - ld [wBuffer1], a - hlcoord 2, 3 - predef ListMoves - hlcoord 10, 4 - predef ListMovePP - call WaitBGMap - call SetPalettes - ld a, [wNumMoves] - inc a - ld [w2DMenuNumRows], a - hlcoord 0, 11 - ld b, 5 - ld c, 18 - jp TextBox - -PrepareToPlaceMoveData: - ld hl, wPartyMon1Moves - ld bc, PARTYMON_STRUCT_LENGTH - ld a, [wCurPartyMon] - call AddNTimes - ld a, [wMenuCursorY] - dec a - ld c, a - ld b, $0 - add hl, bc - ld a, [hl] - ld [wCurMove], a - hlcoord 1, 12 - lb bc, 5, 18 - jp ClearBox - -PlaceMoveData: - xor a - ld [hBGMapMode], a - hlcoord 0, 10 - ld de, String_MoveType_Top - call PlaceString - hlcoord 0, 11 - ld de, String_MoveType_Bottom - call PlaceString - hlcoord 12, 12 - ld de, String_MoveAtk - call PlaceString - ld a, [wCurMove] - ld b, a - hlcoord 2, 12 - predef PrintMoveType - ld a, [wCurMove] - dec a - ld hl, Moves + MOVE_POWER - ld bc, MOVE_LENGTH - call AddNTimes - ld a, BANK(Moves) - call GetFarByte - hlcoord 16, 12 - cp 2 - jr c, .no_power - ld [wd265], a - ld de, wd265 - lb bc, 1, 3 - call PrintNum - jr .description - -.no_power - ld de, String_MoveNoPower - call PlaceString - -.description - hlcoord 1, 14 - predef PrintMoveDesc - ld a, $1 - ld [hBGMapMode], a - ret - -String_MoveType_Top: - db "┌─────┐@" -String_MoveType_Bottom: - db "│TYPE/└@" -String_MoveAtk: - db "ATK/@" -String_MoveNoPower: - db "---@" - -Function132d3: - call Function132da - call Function132fe - ret - -Function132da: - ld a, [wCurPartyMon] - and a - ret z - ld c, a - ld e, a - ld d, 0 - ld hl, wPartyCount - add hl, de -.loop - ld a, [hl] - and a - jr z, .prev - cp EGG - jr z, .prev - cp NUM_POKEMON + 1 - jr c, .legal - -.prev - dec hl - dec c - jr nz, .loop - ret - -.legal - hlcoord 16, 0 - ld [hl], "◀" - ret - -Function132fe: - ld a, [wCurPartyMon] - inc a - ld c, a - ld a, [wPartyCount] - cp c - ret z - ld e, c - ld d, 0 - ld hl, wPartySpecies - add hl, de -.loop - ld a, [hl] - cp -1 - ret z - and a - jr z, .next - cp EGG - jr z, .next - cp NUM_POKEMON + 1 - jr c, .legal - -.next - inc hl - jr .loop - -.legal - hlcoord 18, 0 - ld [hl], "▶" - ret diff --git a/engine/menus/trainer_card.asm b/engine/menus/trainer_card.asm index f48636f67..a1b7fcd64 100644 --- a/engine/menus/trainer_card.asm +++ b/engine/menus/trainer_card.asm @@ -276,7 +276,7 @@ TrainerCard_Page1_PrintDexCaught_GameTime: ld hl, wPokedexCaught ld b, wEndPokedexCaught - wPokedexCaught call CountSetBits - ld de, wd265 + ld de, wNumSetBits hlcoord 15, 10 lb bc, 1, 3 call PrintNum diff --git a/engine/movie/credits.asm b/engine/movie/credits.asm index 97828ab58..76154a1aa 100644 --- a/engine/movie/credits.asm +++ b/engine/movie/credits.asm @@ -377,7 +377,7 @@ ParseCredits: push de ld a, [wCreditsPos] ld e, a - ld a, [wCreditsPos+1] + ld a, [wCreditsPos + 1] ld d, a ld hl, CreditsScript add hl, de @@ -386,7 +386,7 @@ ParseCredits: ld a, e ld [wCreditsPos], a ld a, d - ld [wCreditsPos+1], a + ld [wCreditsPos + 1], a ld a, [hl] pop de pop hl diff --git a/engine/movie/crystal_intro.asm b/engine/movie/crystal_intro.asm index 26fb31bb8..467c1671a 100644 --- a/engine/movie/crystal_intro.asm +++ b/engine/movie/crystal_intro.asm @@ -1481,7 +1481,7 @@ IntroScene28: cp $8 ret nz - ld de, SFX_UNKNOWN_CB + ld de, SFX_INTRO_WHOOSH call PlaySFX ret diff --git a/engine/movie/title.asm b/engine/movie/title.asm index 3717b4e73..eb639489f 100644 --- a/engine/movie/title.asm +++ b/engine/movie/title.asm @@ -246,8 +246,8 @@ SuicuneFrameIterator: ret .Frames: - db $80 ; vTiles4 tile $00 - db $88 ; vTiles4 tile $08 + db $80 ; vTiles3 tile $80 + db $88 ; vTiles3 tile $88 db $00 ; vTiles5 tile $00 db $08 ; vTiles5 tile $08 diff --git a/engine/movie/trade_animation.asm b/engine/movie/trade_animation.asm index e60344430..a225e9721 100644 --- a/engine/movie/trade_animation.asm +++ b/engine/movie/trade_animation.asm @@ -317,7 +317,7 @@ TradeAnim_TubeToOT1: ld a, TRADEANIM_RIGHT_ARROW call TradeAnim_PlaceTrademonStatsOnTubeAnim ld a, [wLinkTradeSendmonSpecies] - ld [wd265], a + ld [wTempIconSpecies], a xor a depixel 5, 11, 4, 0 ld b, $0 @@ -327,7 +327,7 @@ TradeAnim_TubeToPlayer1: ld a, TRADEANIM_LEFT_ARROW call TradeAnim_PlaceTrademonStatsOnTubeAnim ld a, [wLinkTradeGetmonSpecies] - ld [wd265], a + ld [wTempIconSpecies], a ld a, TRADEANIMSTATE_2 depixel 9, 18, 4, 4 ld b, $4 @@ -820,7 +820,7 @@ TradeAnim_GetFrontpic: TradeAnim_GetNickname: push de - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetPokemonName ld hl, wStringBuffer1 pop de @@ -1373,7 +1373,7 @@ LoadTradeBallAndCableGFX: LoadTradeBubbleGFX: call DelayFrame - ld e, $3 + ld e, MONICON_TRADE callfar LoadMenuMonIcon ld de, TradeBubbleGFX ld hl, vTiles0 tile $72 diff --git a/engine/overworld/decorations.asm b/engine/overworld/decorations.asm index 7ba177420..673d7f272 100644 --- a/engine/overworld/decorations.asm +++ b/engine/overworld/decorations.asm @@ -559,7 +559,7 @@ GetDecoName: .getpokename push bc - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetPokemonName pop bc jr .copy @@ -1085,17 +1085,18 @@ DecorationDesc_GiantOrnament: db "@" ToggleMaptileDecorations: - lb de, 0, 4 + ; tile coordinates work the same way as for changeblock + lb de, 0, 4 ; bed coordinates ld a, [wDecoBed] call SetDecorationTile - lb de, 7, 4 + lb de, 7, 4 ; plant coordinates ld a, [wDecoPlant] call SetDecorationTile - lb de, 6, 0 + lb de, 6, 0 ; poster coordinates ld a, [wDecoPoster] call SetDecorationTile call SetPosterVisibility - lb de, 0, 0 + lb de, 0, 0 ; carpet top-left coordinates call PadCoords_de ld a, [wDecoCarpet] and a @@ -1103,15 +1104,15 @@ ToggleMaptileDecorations: call _GetDecorationSprite ld [hl], a push af - lb de, 0, 2 + lb de, 0, 2 ; carpet bottom-left coordinates call PadCoords_de pop af inc a - ld [hli], a + ld [hli], a ; carpet bottom-left block inc a - ld [hli], a + ld [hli], a ; carpet bottom-middle block dec a - ld [hl], a + ld [hl], a ; carpet bottom-right block ret SetPosterVisibility: @@ -1177,6 +1178,7 @@ _GetDecorationSprite: ret PadCoords_de: +; adjusts coordinates, the same way as Script_changeblock ld a, d add 4 ld d, a diff --git a/engine/overworld/events.asm b/engine/overworld/events.asm index 707d31e66..063265e4d 100644 --- a/engine/overworld/events.asm +++ b/engine/overworld/events.asm @@ -972,17 +972,18 @@ DoPlayerEvent: ret PlayerEventScriptPointers: - dba Invalid_0x96c2d ; 0 - dba SeenByTrainerScript ; 1 - dba TalkToTrainerScript ; 2 - dba FindItemInBallScript ; 3 - dba EdgeWarpScript ; 4 - dba WarpToNewMapScript ; 5 - dba FallIntoMapScript ; 6 - dba Script_OverworldWhiteout ; 7 - dba HatchEggScript ; 8 - dba ChangeDirectionScript ; 9 - dba Invalid_0x96c2d ; 10 +; entries correspond to PLAYEREVENT_* constants + dba Invalid_0x96c2d ; PLAYEREVENT_NONE + dba SeenByTrainerScript ; PLAYEREVENT_SEENBYTRAINER + dba TalkToTrainerScript ; PLAYEREVENT_TALKTOTRAINER + dba FindItemInBallScript ; PLAYEREVENT_ITEMBALL + dba EdgeWarpScript ; PLAYEREVENT_CONNECTION + dba WarpToNewMapScript ; PLAYEREVENT_WARP + dba FallIntoMapScript ; PLAYEREVENT_FALL + dba Script_OverworldWhiteout ; PLAYEREVENT_WHITEOUT + dba HatchEggScript ; PLAYEREVENT_HATCH + dba ChangeDirectionScript ; PLAYEREVENT_JOYCHANGEFACING + dba Invalid_0x96c2d ; (NUM_PLAYER_EVENTS) Invalid_0x96c2d: end @@ -1336,8 +1337,8 @@ DoBikeStep:: ClearCmdQueue:: ld hl, wCmdQueue - ld de, 6 - ld c, 4 + ld de, CMDQUEUE_ENTRY_SIZE + ld c, CMDQUEUE_CAPACITY xor a .loop ld [hl], a @@ -1443,7 +1444,7 @@ HandleQueuedCommand: ld hl, CMDQUEUE_TYPE add hl, bc ld a, [hl] - cp 5 + cp NUM_CMDQUEUE_TYPES jr c, .okay xor a diff --git a/engine/overworld/player_movement.asm b/engine/overworld/player_movement.asm index c70357f13..a4926e7e5 100644 --- a/engine/overworld/player_movement.asm +++ b/engine/overworld/player_movement.asm @@ -562,8 +562,8 @@ DoPlayerMovement:: .GetAction: ; Poll player input and update movement info. - ld hl, .table - ld de, .table2 - .table1 + ld hl, .action_table + ld de, .action_table_1_end - .action_table_1 ld a, [wCurInput] bit D_DOWN_F, a jr nz, .d_down @@ -597,25 +597,20 @@ DoPlayerMovement:: ld [wWalkingTile], a ret -.table -; struct: -; walk direction -; facing -; x movement -; y movement -; tile collision pointer -.table1 - db STANDING, FACE_CURRENT, 0, 0 - dw wPlayerStandingTile -.table2 - db RIGHT, FACE_RIGHT, 1, 0 - dw wTileRight - db LEFT, FACE_LEFT, -1, 0 - dw wTileLeft - db UP, FACE_UP, 0, -1 - dw wTileUp - db DOWN, FACE_DOWN, 0, 1 - dw wTileDown +player_action: MACRO +; walk direction, facing, x movement, y movement, tile collision pointer + db \1, \2, \3, \4 + dw \5 +ENDM + +.action_table: +.action_table_1 + player_action STANDING, FACE_CURRENT, 0, 0, wPlayerStandingTile +.action_table_1_end + player_action RIGHT, FACE_RIGHT, 1, 0, wTileRight + player_action LEFT, FACE_LEFT, -1, 0, wTileLeft + player_action UP, FACE_UP, 0, -1, wTileUp + player_action DOWN, FACE_DOWN, 0, 1, wTileDown .CheckNPC: ; Returns 0 if there is an NPC in front that you can't move diff --git a/engine/overworld/scripting.asm b/engine/overworld/scripting.asm index f8e702eb9..248ff9978 100644 --- a/engine/overworld/scripting.asm +++ b/engine/overworld/scripting.asm @@ -623,7 +623,7 @@ INCLUDE "data/items/pocket_names.asm" CurItemName: ld a, [wCurItem] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetItemName ret @@ -1863,7 +1863,7 @@ Script_pokenamemem: jr nz, .gotit ld a, [wScriptVar] .gotit - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetPokemonName ld de, wStringBuffer1 @@ -1890,7 +1890,7 @@ Script_itemtotext: jr nz, .ok ld a, [wScriptVar] .ok - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetItemName ld de, wStringBuffer1 jr ConvertMemToText diff --git a/engine/overworld/time.asm b/engine/overworld/time.asm index abb12d87d..74bd1b6d9 100644 --- a/engine/overworld/time.asm +++ b/engine/overworld/time.asm @@ -91,9 +91,9 @@ CheckDailyResetTimer:: call CheckDayDependentEventHL ret nc xor a - ld hl, wDailyFlags - ld [hli], a ; wDailyFlags - ld [hli], a ; wWeeklyFlags + ld hl, wDailyFlags1 + ld [hli], a ; wDailyFlags1 + ld [hli], a ; wDailyFlags2 ld [hli], a ; wSwarmFlags ld [hl], a ; wSwarmFlags + 1 ld hl, wDailyRematchFlags @@ -207,14 +207,14 @@ CheckUnusedTwoDayTimer: ret ; unused - ld hl, wDailyFlags - set DAILYFLAGS_FISH_SWARM_F, [hl] + ld hl, wDailyFlags1 + set DAILYFLAGS1_FISH_SWARM_F, [hl] ret ; unused and a - ld hl, wDailyFlags - bit DAILYFLAGS_FISH_SWARM_F, [hl] + ld hl, wDailyFlags1 + bit DAILYFLAGS1_FISH_SWARM_F, [hl] ret nz scf ret diff --git a/engine/overworld/variables.asm b/engine/overworld/variables.asm index 9b5e3846c..da4b18812 100644 --- a/engine/overworld/variables.asm +++ b/engine/overworld/variables.asm @@ -72,7 +72,7 @@ _GetVarAction:: ld hl, wPokedexCaught ld b, wEndPokedexCaught - wPokedexCaught call CountSetBits - ld a, [wd265] + ld a, [wNumSetBits] jp .loadstringbuffer2 .CountSeenMons: @@ -80,7 +80,7 @@ _GetVarAction:: ld hl, wPokedexSeen ld b, wEndPokedexSeen - wPokedexSeen call CountSetBits - ld a, [wd265] + ld a, [wNumSetBits] jp .loadstringbuffer2 .CountBadges: @@ -88,7 +88,7 @@ _GetVarAction:: ld hl, wBadges ld b, 2 call CountSetBits - ld a, [wd265] + ld a, [wNumSetBits] jp .loadstringbuffer2 .PlayerFacing: diff --git a/engine/pokedex/pokedex.asm b/engine/pokedex/pokedex.asm index 5682dac35..188462bb5 100644 --- a/engine/pokedex/pokedex.asm +++ b/engine/pokedex/pokedex.asm @@ -465,7 +465,7 @@ DexEntryScreen_MenuActionJumptable: .Cry: call Pokedex_GetSelectedMon - ld a, [wd265] + ld a, [wTempSpecies] call GetCryIndex ld e, c ld d, b @@ -1088,7 +1088,7 @@ Pokedex_DrawMainScreenBG: ld hl, wPokedexSeen ld b, wEndPokedexSeen - wPokedexSeen call CountSetBits - ld de, wd265 + ld de, wNumSetBits hlcoord 5, 12 lb bc, 1, 3 call PrintNum @@ -1098,7 +1098,7 @@ Pokedex_DrawMainScreenBG: ld hl, wPokedexCaught ld b, wEndPokedexCaught - wPokedexCaught call CountSetBits - ld de, wd265 + ld de, wNumSetBits hlcoord 5, 15 lb bc, 1, 3 call PrintNum @@ -1317,7 +1317,7 @@ Pokedex_DrawUnownModeBG: call Pokedex_PlaceFrontpicAtHL ld de, 0 ld b, 0 - ld c, 26 + ld c, NUM_UNOWN .loop ld hl, wUnownDex add hl, de @@ -1492,7 +1492,7 @@ Pokedex_PrintListing: .loop push af ld a, [de] - ld [wd265], a + ld [wTempSpecies], a ; also sets wNamedObjectIndexBuffer push de push hl call .PrintEntry @@ -1531,7 +1531,7 @@ Pokedex_PrintNumberIfOldMode: push hl ld de, -SCREEN_WIDTH add hl, de - ld de, wd265 + ld de, wTempSpecies lb bc, PRINTNUM_LEADINGZEROS | 1, 3 call PrintNum pop hl @@ -1585,13 +1585,13 @@ Pokedex_GetSelectedMon: ld hl, wPokedexOrder add hl, de ld a, [hl] - ld [wd265], a + ld [wTempSpecies], a ret Pokedex_CheckCaught: push de push hl - ld a, [wd265] + ld a, [wTempSpecies] dec a call CheckCaughtMon pop hl @@ -1601,7 +1601,7 @@ Pokedex_CheckCaught: Pokedex_CheckSeen: push de push hl - ld a, [wd265] + ld a, [wTempSpecies] dec a call CheckSeenMon pop hl @@ -1654,7 +1654,7 @@ Pokedex_OrderMonsByMode: ld e, d .loopfindend ld a, [hld] - ld [wd265], a + ld [wTempSpecies], a call Pokedex_CheckSeen jr nz, .foundend dec d @@ -1674,10 +1674,10 @@ Pokedex_ABCMode: .loop1abc push bc ld a, [de] - ld [wd265], a + ld [wTempSpecies], a call Pokedex_CheckSeen jr z, .skipabc - ld a, [wd265] + ld a, [wTempSpecies] ld [hli], a ld a, [wDexListingEnd] inc a @@ -1898,7 +1898,7 @@ Pokedex_SearchForMons: ld a, [hl] and a jr z, .next_mon - ld [wd265], a + ld [wTempSpecies], a ld [wCurSpecies], a call Pokedex_CheckCaught jr z, .next_mon @@ -1917,7 +1917,7 @@ Pokedex_SearchForMons: jr nz, .next_mon .match_found - ld a, [wd265] + ld a, [wTempSpecies] ld [de], a inc de ld a, [wDexSearchResultCount] @@ -2138,40 +2138,40 @@ Pokedex_PutScrollbarOAM: ld hl, wDexListingScrollOffset add [hl] cp e - jr z, .asm_4133f - ld hl, $0 - ld bc, $79 + jr z, .max + ld hl, 0 + ld bc, 121 ; max y - min y call AddNTimes ld e, l ld d, h - ld b, $0 + ld b, 0 ld a, d or e - jr z, .asm_41341 + jr z, .done ld a, [wDexListingEnd] ld c, a -.asm_41333 +.loop ld a, e sub c ld e, a ld a, d - sbc $0 + sbc 0 ld d, a - jr c, .asm_41341 + jr c, .done inc b - jr .asm_41333 -.asm_4133f - ld b, $79 -.asm_41341 - ld a, $14 + jr .loop +.max + ld b, 121 ; max y - min y +.done + ld a, 20 ; min y add b pop hl ld [hli], a - ld a, $a1 + ld a, 161 ; x ld [hli], a - ld a, $f + ld a, $0f ; tile id ld [hli], a - ld [hl], $0 + ld [hl], 0 ; attributes ret Pokedex_InitArrowCursor: @@ -2354,7 +2354,7 @@ Pokedex_LoadSelectedMonTiles: jr z, .QuestionMark ld a, [wFirstUnownSeen] ld [wUnownLetter], a - ld a, [wd265] + ld a, [wTempSpecies] ld [wCurPartySpecies], a call GetBaseData ld de, vTiles2 @@ -2378,7 +2378,7 @@ Pokedex_LoadCurrentFootprint: call Pokedex_GetSelectedMon Pokedex_LoadAnyFootprint: - ld a, [wd265] + ld a, [wTempSpecies] dec a and %11111000 srl a @@ -2386,7 +2386,7 @@ Pokedex_LoadAnyFootprint: srl a ld e, 0 ld d, a - ld a, [wd265] + ld a, [wTempSpecies] dec a and %111 swap a ; * $10 @@ -2486,11 +2486,11 @@ Pokedex_LoadUnownFont: ld a, BANK(UnownFont) call FarCopyBytes ld hl, sScratch + $188 - ld bc, 27 tiles + ld bc, (NUM_UNOWN + 1) tiles call Pokedex_InvertTiles ld de, sScratch + $188 ld hl, vTiles2 tile $40 - lb bc, BANK(Pokedex_LoadUnownFont), 27 + lb bc, BANK(Pokedex_LoadUnownFont), NUM_UNOWN + 1 call Request2bpp call CloseSRAM ret @@ -2524,7 +2524,7 @@ _NewPokedexEntry: call LoadFontsExtra call Pokedex_LoadGFX call Pokedex_LoadAnyFootprint - ld a, [wd265] + ld a, [wTempSpecies] ld [wCurPartySpecies], a call Pokedex_DrawDexEntryScreenBG call Pokedex_DrawFootprint diff --git a/engine/pokedex/pokedex_2.asm b/engine/pokedex/pokedex_2.asm index 8105a080a..62e7e853b 100644 --- a/engine/pokedex/pokedex_2.asm +++ b/engine/pokedex/pokedex_2.asm @@ -80,7 +80,7 @@ DisplayDexEntry: call GetPokemonName hlcoord 9, 3 call PlaceString ; mon species - ld a, [wd265] + ld a, [wTempSpecies] ld b, a call GetDexEntryPointer ld a, b @@ -96,11 +96,11 @@ DisplayDexEntry: ld [hli], a ld a, $5d ; . ld [hli], a - ld de, wd265 + ld de, wTempSpecies lb bc, PRINTNUM_LEADINGZEROS | 1, 3 call PrintNum ; Check to see if we caught it. Get out of here if we haven't. - ld a, [wd265] + ld a, [wTempSpecies] dec a call CheckCaughtMon pop hl diff --git a/engine/pokegear/pokegear.asm b/engine/pokegear/pokegear.asm index 8fc5ffa3d..8dda3a237 100644 --- a/engine/pokegear/pokegear.asm +++ b/engine/pokegear/pokegear.asm @@ -1287,12 +1287,12 @@ PokegearPhoneContactSubmenu: cp 12 jr c, .am sub 12 - ld [wd265], a + ld [wTempByteValue], a scf ret .am - ld [wd265], a + ld [wTempByteValue], a and a ret @@ -2741,7 +2741,7 @@ TownMapMon: ld d, $0 add hl, de ld a, [hl] - ld [wd265], a + ld [wTempIconSpecies], a ; Get FlyMon icon ld e, $08 ; starting tile in VRAM farcall GetSpeciesIcon diff --git a/engine/pokegear/radio.asm b/engine/pokegear/radio.asm index b76cad13e..390fef28e 100644 --- a/engine/pokegear/radio.asm +++ b/engine/pokegear/radio.asm @@ -1558,8 +1558,8 @@ BuenasPassword4: jp c, BuenasPassword8 ld a, [wBuenasPassword] ; If we already generated the password today, we don't need to generate a new one. - ld hl, wWeeklyFlags - bit WEEKLYFLAGS_BUENAS_PASSWORD_F, [hl] + ld hl, wDailyFlags2 + bit DAILYFLAGS2_BUENAS_PASSWORD_F, [hl] jr nz, .AlreadyGotIt ; There are only 11 groups to choose from. .greater_than_11 @@ -1580,8 +1580,8 @@ BuenasPassword4: add e ld [wBuenasPassword], a ; Set the flag so that we don't generate a new password this week. - ld hl, wWeeklyFlags - set WEEKLYFLAGS_BUENAS_PASSWORD_F, [hl] + ld hl, wDailyFlags2 + set DAILYFLAGS2_BUENAS_PASSWORD_F, [hl] .AlreadyGotIt: ld c, a call GetBuenasPassword @@ -1701,15 +1701,15 @@ BuenasPassword7: BuenasPasswordAfterMidnight: push hl - ld hl, wWeeklyFlags - res WEEKLYFLAGS_BUENAS_PASSWORD_F, [hl] + ld hl, wDailyFlags2 + res DAILYFLAGS2_BUENAS_PASSWORD_F, [hl] pop hl ld a, BUENAS_PASSWORD_8 jp NextRadioLine BuenasPassword8: - ld hl, wWeeklyFlags - res WEEKLYFLAGS_BUENAS_PASSWORD_F, [hl] + ld hl, wDailyFlags2 + res DAILYFLAGS2_BUENAS_PASSWORD_F, [hl] ld hl, BuenaRadioMidnightText10 ld a, BUENAS_PASSWORD_9 jp NextRadioLine @@ -1776,8 +1776,8 @@ BuenasPassword20: farcall NoRadioName pop af ld [hBGMapMode], a - ld hl, wWeeklyFlags - res WEEKLYFLAGS_BUENAS_PASSWORD_F, [hl] + ld hl, wDailyFlags2 + res DAILYFLAGS2_BUENAS_PASSWORD_F, [hl] ld a, BUENAS_PASSWORD ld [wCurrentRadioLine], a xor a diff --git a/engine/pokegear/townmap_convertlinebreakcharacters.asm b/engine/pokegear/townmap_convertlinebreakcharacters.asm index e0ed55131..a881b9260 100644 --- a/engine/pokegear/townmap_convertlinebreakcharacters.asm +++ b/engine/pokegear/townmap_convertlinebreakcharacters.asm @@ -5,14 +5,14 @@ TownMap_ConvertLineBreakCharacters: cp "@" jr z, .end cp "%" - jr z, .line_break + jr z, .line_feed cp "¯" - jr z, .line_break + jr z, .line_feed inc hl jr .loop -.line_break - ld [hl], "<LNBRK>" +.line_feed + ld [hl], "<LF>" .end ld de, wStringBuffer1 diff --git a/engine/pokemon/bills_pc.asm b/engine/pokemon/bills_pc.asm index 65621192d..f0ddc0ba8 100644 --- a/engine/pokemon/bills_pc.asm +++ b/engine/pokemon/bills_pc.asm @@ -1035,7 +1035,7 @@ PCMonInfo: cp -1 ret z - ld [wd265], a + ld [wTempSpecies], a hlcoord 1, 4 xor a ld b, 7 @@ -1057,7 +1057,7 @@ PCMonInfo: jr nz, .row call BillsPC_LoadMonStats - ld a, [wd265] + ld a, [wTempSpecies] ld [wCurPartySpecies], a ld [wCurSpecies], a ld hl, wTempMonDVs @@ -1068,7 +1068,7 @@ PCMonInfo: xor a ld [wBillsPC_MonHasMail], a ld a, [wCurPartySpecies] - ld [wd265], a + ld [wTempSpecies], a cp EGG ret z @@ -1676,9 +1676,9 @@ StatsScreenDPad: and a jr z, .did_nothing call BillsPC_GetSelectedPokemonSpecies - ld [wd265], a + ld [wTempSpecies], a call BillsPC_LoadMonStats - ld a, [wd265] + ld a, [wTempSpecies] ld [wCurPartySpecies], a ld [wCurSpecies], a ld hl, wTempMonDVs @@ -1893,7 +1893,7 @@ ReleasePKMN_ByePKMN: .skip_cry ld a, [wCurPartySpecies] - ld [wd265], a + ld [wTempSpecies], a call GetPokemonName hlcoord 1, 16 ld de, PCString_ReleasedPKMN @@ -2314,9 +2314,9 @@ BillsPC_PrintBoxCountAndCapacity: ld de, .Pokemon call PlaceString call GetBoxCount - ld [wd265], a + ld [wDeciramBuffer], a hlcoord 13, 11 - ld de, wd265 + ld de, wDeciramBuffer lb bc, 1, 2 call PrintNum ld de, .out_of_20 diff --git a/engine/pokemon/breeding.asm b/engine/pokemon/breeding.asm index 7e7f0e097..dfebcd9f9 100644 --- a/engine/pokemon/breeding.asm +++ b/engine/pokemon/breeding.asm @@ -81,7 +81,7 @@ CheckBreedmonCompatibility: .done ld a, c - ld [wd265], a + ld [wBreedingCompatibility], a ret .CheckDVs: @@ -250,7 +250,7 @@ HatchEggs: ld a, [wCurPartySpecies] dec de ld [de], a - ld [wd265], a + ld [wNamedObjectIndexBuffer], a ld [wCurSpecies], a call GetPokemonName xor a @@ -676,7 +676,7 @@ EggHatch_DoAnimFrame: ret EggHatch_AnimationSequence: - ld a, [wd265] + ld a, [wNamedObjectIndexBuffer] ld [wJumptableIndex], a ld a, [wCurSpecies] push af @@ -910,7 +910,7 @@ DayCareMonCompatibilityText: call CopyBytes call CheckBreedmonCompatibility pop bc - ld a, [wd265] + ld a, [wBreedingCompatibility] ld hl, .AllAlone cp -1 jr z, .done diff --git a/engine/pokemon/caught_data.asm b/engine/pokemon/caught_data.asm index 89d22fdf6..31cfe7e75 100644 --- a/engine/pokemon/caught_data.asm +++ b/engine/pokemon/caught_data.asm @@ -38,7 +38,7 @@ CheckPartyFullAfterContest: ld hl, wPlayerName call CopyBytes ld a, [wCurPartySpecies] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetPokemonName ld hl, wStringBuffer1 ld de, wMonOrItemNameBuffer @@ -105,7 +105,7 @@ CheckPartyFullAfterContest: call CopyBytes callfar InsertPokemonIntoBox ld a, [wCurPartySpecies] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetPokemonName call GiveANickname_YesNo ld hl, wStringBuffer1 diff --git a/engine/pokemon/correct_party_errors.asm b/engine/pokemon/correct_party_errors.asm index 50a9f3562..717893b36 100644 --- a/engine/pokemon/correct_party_errors.asm +++ b/engine/pokemon/correct_party_errors.asm @@ -123,7 +123,7 @@ Unreferenced_CorrectPartyErrors: cp EGG ld hl, .TAMAGO jr z, .got_nickname - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetPokemonName ld hl, wStringBuffer1 .got_nickname diff --git a/engine/pokemon/evolve.asm b/engine/pokemon/evolve.asm index 571cff0b8..eb2645e00 100644 --- a/engine/pokemon/evolve.asm +++ b/engine/pokemon/evolve.asm @@ -99,7 +99,7 @@ EvolveAfterBattle_MasterLoop: ld de, wTempMonAttack ld hl, wTempMonDefense ld c, 2 - call StringCmp + call CompareBytes ld a, ATK_EQ_DEF jr z, .got_tyrogue_evo ld a, ATK_LT_DEF @@ -236,7 +236,7 @@ EvolveAfterBattle_MasterLoop: ld [wCurSpecies], a ld [wTempMonSpecies], a ld [wEvolutionNewSpecies], a - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetPokemonName push hl @@ -293,15 +293,15 @@ EvolveAfterBattle_MasterLoop: call CopyBytes ld a, [wCurSpecies] - ld [wd265], a + ld [wTempSpecies], a xor a ld [wMonType], a call LearnLevelMoves - ld a, [wd265] + ld a, [wTempSpecies] dec a call SetSeenAndCaughtMon - ld a, [wd265] + ld a, [wTempSpecies] cp UNOWN jr nz, .skip_unown @@ -348,7 +348,7 @@ UpdateSpeciesNameIfNotNicknamed: ld a, [wCurSpecies] push af ld a, [wBaseDexNo] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetPokemonName pop af ld [wCurSpecies], a @@ -369,7 +369,7 @@ UpdateSpeciesNameIfNotNicknamed: call AddNTimes push hl ld a, [wCurSpecies] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetPokemonName ld hl, wStringBuffer1 pop de @@ -415,7 +415,7 @@ Text_WhatEvolving: db "@" LearnLevelMoves: - ld a, [wd265] + ld a, [wTempSpecies] ld [wCurPartySpecies], a dec a ld b, 0 @@ -466,7 +466,7 @@ LearnLevelMoves: .learn ld a, d ld [wPutativeTMHMMove], a - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetMoveName call CopyName1 predef LearnMove @@ -475,7 +475,7 @@ LearnLevelMoves: .done ld a, [wCurPartySpecies] - ld [wd265], a + ld [wTempSpecies], a ret FillMoves: diff --git a/engine/pokemon/learn.asm b/engine/pokemon/learn.asm index 20294c878..9031c6857 100644 --- a/engine/pokemon/learn.asm +++ b/engine/pokemon/learn.asm @@ -36,7 +36,7 @@ LearnMove: push hl push de - ld [wd265], a + ld [wNamedObjectIndexBuffer], a ld b, a ld a, [wBattleMode] diff --git a/engine/pokemon/mail.asm b/engine/pokemon/mail.asm index 359d2ac8e..2c66ab72a 100644 --- a/engine/pokemon/mail.asm +++ b/engine/pokemon/mail.asm @@ -149,7 +149,7 @@ CheckPokeMail:: ; Compare the mail message, byte for byte, with the expected message. ld a, MAIL_MSG_LENGTH - ld [wd265], a + ld [wTempByteValue], a .loop ld a, [de] ld c, a @@ -162,9 +162,9 @@ CheckPokeMail:: jr nz, .close_sram_return inc hl inc de - ld a, [wd265] + ld a, [wTempByteValue] dec a - ld [wd265], a + ld [wTempByteValue], a jr nz, .loop .done diff --git a/engine/pokemon/mail_2.asm b/engine/pokemon/mail_2.asm index 1cc776706..b5154187a 100644 --- a/engine/pokemon/mail_2.asm +++ b/engine/pokemon/mail_2.asm @@ -59,7 +59,7 @@ ReadAnyMail: .pressed_start ld a, [wJumptableIndex] push af - callfar PrintMail ; printer + callfar PrintMailAndExit ; printer pop af ld [wJumptableIndex], a jr .loop diff --git a/engine/pokemon/mon_menu.asm b/engine/pokemon/mon_menu.asm index 2d14bd603..985546845 100644 --- a/engine/pokemon/mon_menu.asm +++ b/engine/pokemon/mon_menu.asm @@ -1,290 +1,1305 @@ -INCLUDE "data/mon_menu.asm" - -MonSubmenu: - xor a - ld [hBGMapMode], a - call GetMonSubmenuItems - farcall FreezeMonIcons - ld hl, .MenuHeader - call LoadMenuHeader - call .GetTopCoord - call PopulateMonMenu - - ld a, 1 - ld [hBGMapMode], a - call MonMenuLoop - ld [wMenuSelection], a +HasNoItems: + ld a, [wNumItems] + and a + ret nz + ld a, [wNumKeyItems] + and a + ret nz + ld a, [wNumBalls] + and a + ret nz + ld hl, wTMsHMs + ld b, NUM_TMS + NUM_HMS +.loop + ld a, [hli] + and a + jr nz, .done + dec b + jr nz, .loop + scf + ret +.done + and a + ret +TossItemFromPC: + push de + call PartyMonItemName + farcall _CheckTossableItem + ld a, [wItemAttributeParamBuffer] + and a + jr nz, .key_item + ld hl, .TossHowMany + call MenuTextBox + farcall SelectQuantityToToss + push af + call CloseWindow call ExitMenu + pop af + jr c, .quit + ld hl, .ConfirmToss + call MenuTextBox + call YesNoBox + push af + call ExitMenu + pop af + jr c, .quit + pop hl + ld a, [wCurItemQuantity] + call TossItem + call PartyMonItemName + ld hl, .TossedThisMany + call MenuTextBox + call ExitMenu + and a ret -.MenuHeader: - db MENU_BACKUP_TILES ; flags - menu_coords 6, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 - dw 0 - db 1 ; default option +.key_item + call .CantToss +.quit + pop hl + scf + ret -.GetTopCoord: -; TopCoord = 1 + BottomCoord - 2 * (NumSubmenuItems + 1) - ld a, [wBuffer1] - inc a - add a - ld b, a - ld a, [wMenuBorderBottomCoord] - sub b - inc a - ld [wMenuBorderTopCoord], a - call MenuBox +.TossHowMany: + ; Toss out how many @ (S)? + text_jump UnknownText_0x1c1a90 + db "@" + +.ConfirmToss: + ; Throw away @ @ (S)? + text_jump UnknownText_0x1c1aad + db "@" + +.TossedThisMany: + ; Discarded @ (S). + text_jump UnknownText_0x1c1aca + db "@" + +.CantToss: + ld hl, .TooImportantToToss + call MenuTextBoxBackup ret -MonMenuLoop: -.loop - ld a, MENU_UNUSED_3 | MENU_BACKUP_TILES_2 ; flags - ld [wMenuDataFlags], a - ld a, [wBuffer1] ; items - ld [wMenuDataItems], a - call InitVerticalMenuCursor - ld hl, w2DMenuFlags1 - set 6, [hl] - call StaticMenuJoypad - ld de, SFX_READ_TEXT_2 - call PlaySFX - ld a, [hJoyPressed] - bit A_BUTTON_F, a - jr nz, .select - bit B_BUTTON_F, a - jr nz, .cancel - jr .loop +.TooImportantToToss: + ; That's too impor- tant to toss out! + text_jump UnknownText_0x1c1adf + db "@" -.cancel - ld a, MONMENUITEM_CANCEL +CantUseItem: + ld hl, CantUseItemText + call MenuTextBoxWaitButton ret -.select - ld a, [wMenuCursorY] - dec a - ld c, a - ld b, 0 - ld hl, wBuffer2 - add hl, bc - ld a, [hl] +CantUseItemText: + text_jump UnknownText_0x1c1b03 + db "@" + +PartyMonItemName: + ld a, [wCurItem] + ld [wNamedObjectIndexBuffer], a + call GetItemName + call CopyName1 ret -PopulateMonMenu: - call MenuBoxCoord2Tile - ld bc, 2 * SCREEN_WIDTH + 2 - add hl, bc - ld de, wBuffer2 -.loop - ld a, [de] - inc de - cp -1 - ret z - push de - push hl - call GetMonMenuString - pop hl - call PlaceString - ld bc, 2 * SCREEN_WIDTH - add hl, bc - pop de - jr .loop +CancelPokemonAction: + farcall InitPartyMenuWithCancel + farcall UnfreezeMonIcons + ld a, 1 + ret -GetMonMenuString: - ld hl, MonMenuOptions + 1 +PokemonActionSubmenu: + hlcoord 1, 15 + lb bc, 2, 18 + call ClearBox + farcall MonSubmenu + call GetCurNick + ld a, [wMenuSelection] + ld hl, .Actions ld de, 3 call IsInArray - dec hl - ld a, [hli] - cp MONMENU_MENUOPTION - jr z, .NotMove + jr nc, .nothing + inc hl - ld a, [hl] - ld [wd265], a - call GetMoveName + ld a, [hli] + ld h, [hl] + ld l, a + jp hl + +.nothing + ld a, 0 ret -.NotMove: - inc hl - ld a, [hl] +.Actions: + dbw MONMENUITEM_CUT, MonMenu_Cut + dbw MONMENUITEM_FLY, MonMenu_Fly + dbw MONMENUITEM_SURF, MonMenu_Surf + dbw MONMENUITEM_STRENGTH, MonMenu_Strength + dbw MONMENUITEM_FLASH, MonMenu_Flash + dbw MONMENUITEM_WHIRLPOOL, MonMenu_Whirlpool + dbw MONMENUITEM_DIG, MonMenu_Dig + dbw MONMENUITEM_TELEPORT, MonMenu_Teleport + dbw MONMENUITEM_SOFTBOILED, MonMenu_Softboiled_MilkDrink + dbw MONMENUITEM_MILKDRINK, MonMenu_Softboiled_MilkDrink + dbw MONMENUITEM_HEADBUTT, MonMenu_Headbutt + dbw MONMENUITEM_WATERFALL, MonMenu_Waterfall + dbw MONMENUITEM_ROCKSMASH, MonMenu_RockSmash + dbw MONMENUITEM_SWEETSCENT, MonMenu_SweetScent + dbw MONMENUITEM_STATS, OpenPartyStats + dbw MONMENUITEM_SWITCH, SwitchPartyMons + dbw MONMENUITEM_ITEM, GiveTakePartyMonItem + dbw MONMENUITEM_CANCEL, CancelPokemonAction + dbw MONMENUITEM_MOVE, ManagePokemonMoves + dbw MONMENUITEM_MAIL, MonMailAction + +SwitchPartyMons: +; Don't try if there's nothing to switch! + ld a, [wPartyCount] + cp 2 + jr c, .DontSwitch + + ld a, [wCurPartyMon] + inc a + ld [wSwitchMon], a + + farcall HoldSwitchmonIcon + farcall InitPartyMenuNoCancel + + ld a, PARTYMENUACTION_MOVE + ld [wPartyMenuActionText], a + farcall WritePartyMenuTilemap + farcall PrintPartyMenuText + + hlcoord 0, 1 + ld bc, SCREEN_WIDTH * 2 + ld a, [wSwitchMon] dec a - ld hl, MonMenuOptionStrings - call GetNthString - ld d, h - ld e, l + call AddNTimes + ld [hl], "▷" + call WaitBGMap + call SetPalettes + call DelayFrame + + farcall PartyMenuSelect + bit 1, b + jr c, .DontSwitch + + farcall _SwitchPartyMons + + xor a + ld [wPartyMenuActionText], a + + farcall LoadPartyMenuGFX + farcall InitPartyMenuWithCancel + farcall InitPartyMenuGFX + + ld a, 1 + ret + +.DontSwitch: + xor a + ld [wPartyMenuActionText], a + call CancelPokemonAction ret -GetMonSubmenuItems: - call ResetMonSubmenu +GiveTakePartyMonItem: +; Eggs can't hold items! ld a, [wCurPartySpecies] cp EGG - jr z, .egg - ld a, [wLinkMode] - and a - jr nz, .skip_moves - ld a, MON_MOVES - call GetPartyParamLocation - ld d, h - ld e, l - ld c, NUM_MOVES + jr z, .cancel + + ld hl, GiveTakeItemMenuData + call LoadMenuHeader + call VerticalMenu + call ExitMenu + jr c, .cancel + + call GetCurNick + ld hl, wStringBuffer1 + ld de, wMonOrItemNameBuffer + ld bc, MON_NAME_LENGTH + call CopyBytes + ld a, [wMenuCursorY] + cp 1 + jr nz, .take + + call LoadStandardMenuHeader + call ClearPalettes + call .GiveItem + call ClearPalettes + call LoadFontsBattleExtra + call ExitMenu + ld a, 0 + ret + +.take + call TakePartyItem + ld a, 3 + ret + +.cancel + ld a, 3 + ret + +.GiveItem: + farcall DepositSellInitPackBuffers + .loop - push bc - push de - ld a, [de] + farcall DepositSellPack + + ld a, [wcf66] and a + jr z, .quit + + ld a, [wcf65] + cp 2 jr z, .next - push hl - call IsFieldMove - pop hl - jr nc, .next - call AddMonMenuItem + + call CheckTossableItem + ld a, [wItemAttributeParamBuffer] + and a + jr nz, .next + + call TryGiveItemToPartymon + jr .quit .next - pop de - inc de - pop bc - dec c - jr nz, .loop + ld hl, CantBeHeldText + call MenuTextBoxBackup + jr .loop -.skip_moves - ld a, MONMENUITEM_STATS - call AddMonMenuItem - ld a, MONMENUITEM_SWITCH - call AddMonMenuItem - ld a, MONMENUITEM_MOVE - call AddMonMenuItem - ld a, [wLinkMode] +.quit + ret + +TryGiveItemToPartymon: + call SpeechTextBox + call PartyMonItemName + call GetPartyItemLocation + ld a, [hl] and a - jr nz, .skip2 + jr z, .give_item_to_mon + push hl - ld a, MON_ITEM - call GetPartyParamLocation - ld d, [hl] + ld d, a farcall ItemIsMail pop hl - ld a, MONMENUITEM_MAIL - jr c, .ok - ld a, MONMENUITEM_ITEM + jr c, .please_remove_mail + ld a, [hl] + jr .already_holding_item + +.give_item_to_mon + call GiveItemToPokemon + ld hl, MadeHoldText + call MenuTextBoxBackup + call GivePartyItem + ret -.ok - call AddMonMenuItem +.please_remove_mail + ld hl, PleaseRemoveMailText + call MenuTextBoxBackup + ret -.skip2 - ld a, [wBuffer1] - cp NUM_MONMENU_ITEMS - jr z, .ok2 - ld a, MONMENUITEM_CANCEL - call AddMonMenuItem +.already_holding_item + ld [wNamedObjectIndexBuffer], a + call GetItemName + ld hl, SwitchAlreadyHoldingText + call StartMenuYesNo + jr c, .abort -.ok2 - call TerminateMonSubmenu + call GiveItemToPokemon + ld a, [wNamedObjectIndexBuffer] + push af + ld a, [wCurItem] + ld [wNamedObjectIndexBuffer], a + pop af + ld [wCurItem], a + call ReceiveItemFromPokemon + jr nc, .bag_full + + ld hl, TookAndMadeHoldText + call MenuTextBoxBackup + ld a, [wNamedObjectIndexBuffer] + ld [wCurItem], a + call GivePartyItem ret -.egg - ld a, MONMENUITEM_STATS - call AddMonMenuItem - ld a, MONMENUITEM_SWITCH - call AddMonMenuItem - ld a, MONMENUITEM_CANCEL - call AddMonMenuItem - call TerminateMonSubmenu +.bag_full + ld a, [wNamedObjectIndexBuffer] + ld [wCurItem], a + call ReceiveItemFromPokemon + ld hl, ItemStorageIsFullText + call MenuTextBoxBackup + +.abort ret -IsFieldMove: +GivePartyItem: + call GetPartyItemLocation + ld a, [wCurItem] + ld [hl], a + ld d, a + farcall ItemIsMail + jr nc, .done + call ComposeMailMessage + +.done + ret + +TakePartyItem: + call SpeechTextBox + call GetPartyItemLocation + ld a, [hl] + and a + jr z, .asm_12c8c + + ld [wCurItem], a + call ReceiveItemFromPokemon + jr nc, .asm_12c94 + + farcall ItemIsMail + call GetPartyItemLocation + ld a, [hl] + ld [wNamedObjectIndexBuffer], a + ld [hl], NO_ITEM + call GetItemName + ld hl, TookFromText + call MenuTextBoxBackup + jr .asm_12c9a + +.asm_12c8c + ld hl, IsntHoldingAnythingText + call MenuTextBoxBackup + jr .asm_12c9a + +.asm_12c94 + ld hl, ItemStorageIsFullText + call MenuTextBoxBackup + +.asm_12c9a + ret + +GiveTakeItemMenuData: + db MENU_SPRITE_ANIMS | MENU_BACKUP_TILES ; flags + menu_coords 12, 12, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 + dw .Items + db 1 ; default option + +.Items: + db STATICMENU_CURSOR ; flags + db 2 ; # items + db "GIVE@" + db "TAKE@" + +TookAndMadeHoldText: + text_jump UnknownText_0x1c1b2c + db "@" + +MadeHoldText: + text_jump UnknownText_0x1c1b57 + db "@" + +PleaseRemoveMailText: + text_jump UnknownText_0x1c1b6f + db "@" + +IsntHoldingAnythingText: + text_jump UnknownText_0x1c1b8e + db "@" + +ItemStorageIsFullText: + text_jump UnknownText_0x1c1baa + db "@" + +TookFromText: + text_jump UnknownText_0x1c1bc4 + db "@" + +SwitchAlreadyHoldingText: + text_jump UnknownText_0x1c1bdc + db "@" + +CantBeHeldText: + text_jump UnknownText_0x1c1c09 + db "@" + +GetPartyItemLocation: + push af + ld a, MON_ITEM + call GetPartyParamLocation + pop af + ret + +ReceiveItemFromPokemon: + ld a, 1 + ld [wItemQuantityChangeBuffer], a + ld hl, wNumItems + jp ReceiveItem + +GiveItemToPokemon: + ld a, 1 + ld [wItemQuantityChangeBuffer], a + ld hl, wNumItems + jp TossItem + +StartMenuYesNo: + call MenuTextBox + call YesNoBox + jp ExitMenu + +ComposeMailMessage: + ld de, wTempMailMessage + farcall _ComposeMailMessage + ld hl, wPlayerName + ld de, wTempMailAuthor + ld bc, NAME_LENGTH - 1 + call CopyBytes + ld hl, wPlayerID + ld bc, 2 + call CopyBytes + ld a, [wCurPartySpecies] + ld [de], a + inc de + ld a, [wCurItem] + ld [de], a + ld a, [wCurPartyMon] + ld hl, sPartyMail + ld bc, MAIL_STRUCT_LENGTH + call AddNTimes + ld d, h + ld e, l + ld hl, wTempMail + ld bc, MAIL_STRUCT_LENGTH + ld a, BANK(sPartyMail) + call GetSRAMBank + call CopyBytes + call CloseSRAM + ret + +MonMailAction: +; If in the time capsule or trade center, +; selecting the mail only allows you to +; read the mail. + ld a, [wLinkMode] + cp LINK_TIMECAPSULE + jr z, .read + cp LINK_TRADECENTER + jr z, .read + +; Show the READ/TAKE/QUIT menu. + ld hl, .MenuHeader + call LoadMenuHeader + call VerticalMenu + call ExitMenu + +; Interpret the menu. + jp c, .done + ld a, [wMenuCursorY] + cp $1 + jr z, .read + cp $2 + jr z, .take + jp .done + +.read + farcall ReadPartyMonMail + ld a, $0 + ret + +.take + ld hl, .sendmailtopctext + call StartMenuYesNo + jr c, .RemoveMailToBag + ld a, [wCurPartyMon] ld b, a - ld hl, MonMenuOptions -.next - ld a, [hli] - cp -1 - jr z, .nope - cp MONMENU_MENUOPTION - jr z, .nope - ld d, [hl] - inc hl + farcall SendMailToPC + jr c, .MailboxFull + ld hl, .sentmailtopctext + call MenuTextBoxBackup + jr .done + +.MailboxFull: + ld hl, .mailboxfulltext + call MenuTextBoxBackup + jr .done + +.RemoveMailToBag: + ld hl, .mailwilllosemessagetext + call StartMenuYesNo + jr c, .done + call GetPartyItemLocation + ld a, [hl] + ld [wCurItem], a + call ReceiveItemFromPokemon + jr nc, .BagIsFull + call GetPartyItemLocation + ld [hl], $0 + call GetCurNick + ld hl, .tookmailfrommontext + call MenuTextBoxBackup + jr .done + +.BagIsFull: + ld hl, .bagfulltext + call MenuTextBoxBackup + jr .done + +.done + ld a, $3 + ret + +.MenuHeader: + db MENU_BACKUP_TILES ; flags + menu_coords 12, 10, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 + dw .MenuData + db 1 ; default option + +.MenuData: + db STATICMENU_CURSOR ; flags + db 3 ; items + db "READ@" + db "TAKE@" + db "QUIT@" + +.mailwilllosemessagetext +; The MAIL will lose its message. OK? + text_jump UnknownText_0x1c1c22 + db "@" + +.tookmailfrommontext +; MAIL detached from <POKEMON>. + text_jump UnknownText_0x1c1c47 + db "@" + +.bagfulltext +; There's no space for removing MAIL. + text_jump UnknownText_0x1c1c62 + db "@" + +.sendmailtopctext +; Send the removed MAIL to your PC? + text_jump UnknownText_0x1c1c86 + db "@" + +.mailboxfulltext +; Your PC's MAILBOX is full. + text_jump UnknownText_0x1c1ca9 + db "@" + +.sentmailtopctext +; The MAIL was sent to your PC. + text_jump UnknownText_0x1c1cc4 + db "@" + +OpenPartyStats: + call LoadStandardMenuHeader + call ClearSprites +; PartyMon + xor a + ld [wMonType], a + call LowVolume + predef StatsScreenInit + call MaxVolume + call Call_ExitMenu + ld a, 0 + ret + +MonMenu_Cut: + farcall CutFunction + ld a, [wFieldMoveSucceeded] + cp $1 + jr nz, .Fail + ld b, $4 + ld a, $2 + ret + +.Fail: + ld a, $3 + ret + +MonMenu_Fly: + farcall FlyFunction + ld a, [wFieldMoveSucceeded] + cp $2 + jr z, .Fail + cp $0 + jr z, .Error + farcall StubbedTrainerRankings_Fly + ld b, $4 + ld a, $2 + ret + +.Fail: + ld a, $3 + ret + +.Error: + ld a, $0 + ret + +.Unreferenced: + ld a, $1 + ret + +MonMenu_Flash: + farcall OWFlash + ld a, [wFieldMoveSucceeded] + cp $1 + jr nz, .Fail + ld b, $4 + ld a, $2 + ret + +.Fail: + ld a, $3 + ret + +MonMenu_Strength: + farcall StrengthFunction + ld a, [wFieldMoveSucceeded] + cp $1 + jr nz, .Fail + ld b, $4 + ld a, $2 + ret + +.Fail: + ld a, $3 + ret + +MonMenu_Whirlpool: + farcall WhirlpoolFunction + ld a, [wFieldMoveSucceeded] + cp $1 + jr nz, .Fail + ld b, $4 + ld a, $2 + ret + +.Fail: + ld a, $3 + ret + +MonMenu_Waterfall: + farcall WaterfallFunction + ld a, [wFieldMoveSucceeded] + cp $1 + jr nz, .Fail + ld b, $4 + ld a, $2 + ret + +.Fail: + ld a, $3 + ret + +MonMenu_Teleport: + farcall TeleportFunction + ld a, [wFieldMoveSucceeded] + and a + jr z, .Fail + ld b, $4 + ld a, $2 + ret + +.Fail: + ld a, $3 + ret + +MonMenu_Surf: + farcall SurfFunction + ld a, [wFieldMoveSucceeded] + and a + jr z, .Fail + ld b, $4 + ld a, $2 + ret + +.Fail: + ld a, $3 + ret + +MonMenu_Dig: + farcall DigFunction + ld a, [wFieldMoveSucceeded] + cp $1 + jr nz, .Fail + ld b, $4 + ld a, $2 + ret + +.Fail: + ld a, $3 + ret + +MonMenu_Softboiled_MilkDrink: + call .CheckMonHasEnoughHP + jr nc, .NotEnoughHP + farcall Softboiled_MilkDrinkFunction + jr .finish + +.NotEnoughHP: + ld hl, .Text_NotEnoughHP + call PrintText + +.finish + xor a + ld [wPartyMenuActionText], a + ld a, $3 + ret + +.Text_NotEnoughHP: + ; Not enough HP! + text_jump UnknownText_0x1c1ce3 + db "@" + +.CheckMonHasEnoughHP: +; Need to have at least (MaxHP / 5) HP left. + ld a, MON_MAXHP + call GetPartyParamLocation ld a, [hli] - cp b - jr nz, .next - ld a, d - scf + ld [hDividend + 0], a + ld a, [hl] + ld [hDividend + 1], a + ld a, 5 + ld [hDivisor], a + ld b, 2 + call Divide + ld a, MON_HP + 1 + call GetPartyParamLocation + ld a, [hQuotient + 2] + sub [hl] + dec hl + ld a, [hQuotient + 1] + sbc [hl] + ret + +MonMenu_Headbutt: + farcall HeadbuttFunction + ld a, [wFieldMoveSucceeded] + cp $1 + jr nz, .Fail + ld b, $4 + ld a, $2 + ret -.nope +.Fail: + ld a, $3 ret -ResetMonSubmenu: +MonMenu_RockSmash: + farcall RockSmashFunction + ld a, [wFieldMoveSucceeded] + cp $1 + jr nz, .Fail + ld b, $4 + ld a, $2 + ret + +.Fail: + ld a, $3 + ret + +MonMenu_SweetScent: + farcall SweetScentFromMenu + ld b, $4 + ld a, $2 + ret + +ChooseMoveToDelete: + ld hl, wOptions + ld a, [hl] + push af + set NO_TEXT_SCROLL, [hl] + call LoadFontsBattleExtra + call .ChooseMoveToDelete + pop bc + ld a, b + ld [wOptions], a + push af + call ClearBGPalettes + pop af + ret + +.ChooseMoveToDelete + call SetUpMoveScreenBG + ld de, DeleteMoveScreenAttrs + call SetMenuAttributes + call SetUpMoveList + ld hl, w2DMenuFlags1 + set 6, [hl] + jr .enter_loop + +.loop + call ScrollingMenuJoypad + bit B_BUTTON_F, a + jp nz, .b_button + bit A_BUTTON_F, a + jp nz, .a_button + +.enter_loop + call PrepareToPlaceMoveData + call PlaceMoveData + jp .loop + +.a_button + and a + jr .finish + +.b_button + scf + +.finish + push af xor a - ld [wBuffer1], a - ld hl, wBuffer2 - ld bc, NUM_MONMENU_ITEMS + 1 - call ByteFill + ld [wSwitchMon], a + ld hl, w2DMenuFlags1 + res 6, [hl] + call ClearSprites + call ClearTileMap + pop af ret -TerminateMonSubmenu: - ld a, [wBuffer1] - ld e, a - ld d, 0 - ld hl, wBuffer2 - add hl, de - ld [hl], -1 +DeleteMoveScreenAttrs: + db 3, 1 + db 3, 1 + db $40, $00 + dn 2, 0 + db D_UP | D_DOWN | A_BUTTON | B_BUTTON + +ManagePokemonMoves: + ld a, [wCurPartySpecies] + cp EGG + jr z, .egg + ld hl, wOptions + ld a, [hl] + push af + set NO_TEXT_SCROLL, [hl] + call MoveScreenLoop + pop af + ld [wOptions], a + call ClearBGPalettes + +.egg + ld a, $0 ret -AddMonMenuItem: +MoveScreenLoop: + ld a, [wCurPartyMon] + inc a + ld [wPartyMenuCursor], a + call SetUpMoveScreenBG + call Function132d3 + ld de, MoveScreenAttributes + call SetMenuAttributes +.loop + call SetUpMoveList + ld hl, w2DMenuFlags1 + set 6, [hl] + jr .skip_joy + +.joy_loop + call ScrollingMenuJoypad + bit 1, a + jp nz, .b_button + bit 0, a + jp nz, .a_button + bit 4, a + jp nz, .d_right + bit 5, a + jp nz, .d_left + +.skip_joy + call PrepareToPlaceMoveData + ld a, [wMoveSwapBuffer] + and a + jr nz, .moving_move + call PlaceMoveData + jp .joy_loop + +.moving_move + ld a, " " + hlcoord 1, 11 + ld bc, 5 + call ByteFill + hlcoord 1, 12 + lb bc, 5, SCREEN_WIDTH - 2 + call ClearBox + hlcoord 1, 12 + ld de, String_MoveWhere + call PlaceString + jp .joy_loop +.b_button + call PlayClickSFX + call WaitSFX + ld a, [wMoveSwapBuffer] + and a + jp z, .exit + + ld a, [wMoveSwapBuffer] + ld [wMenuCursorY], a + xor a + ld [wMoveSwapBuffer], a + hlcoord 1, 2 + lb bc, 8, SCREEN_WIDTH - 2 + call ClearBox + jp .loop + +.d_right + ld a, [wMoveSwapBuffer] + and a + jp nz, .joy_loop + + ld a, [wCurPartyMon] + ld b, a + push bc + call .cycle_right + pop bc + ld a, [wCurPartyMon] + cp b + jp z, .joy_loop + jp MoveScreenLoop + +.d_left + ld a, [wMoveSwapBuffer] + and a + jp nz, .joy_loop + ld a, [wCurPartyMon] + ld b, a + push bc + call .cycle_left + pop bc + ld a, [wCurPartyMon] + cp b + jp z, .joy_loop + jp MoveScreenLoop + +.cycle_right + ld a, [wCurPartyMon] + inc a + ld [wCurPartyMon], a + ld c, a + ld b, 0 + ld hl, wPartySpecies + add hl, bc + ld a, [hl] + cp -1 + jr z, .cycle_left + cp EGG + ret nz + jr .cycle_right + +.cycle_left + ld a, [wCurPartyMon] + and a + ret z +.cycle_left_loop + ld a, [wCurPartyMon] + dec a + ld [wCurPartyMon], a + ld c, a + ld b, 0 + ld hl, wPartySpecies + add hl, bc + ld a, [hl] + cp EGG + ret nz + ld a, [wCurPartyMon] + and a + jr z, .cycle_right + jr .cycle_left_loop + +.a_button + call PlayClickSFX + call WaitSFX + ld a, [wMoveSwapBuffer] + and a + jr nz, .place_move + ld a, [wMenuCursorY] + ld [wMoveSwapBuffer], a + call PlaceHollowCursor + jp .moving_move + +.place_move + ld hl, wPartyMon1Moves + ld bc, PARTYMON_STRUCT_LENGTH + ld a, [wCurPartyMon] + call AddNTimes push hl - push de - push af - ld a, [wBuffer1] + call .copy_move + pop hl + ld bc, $15 + add hl, bc + call .copy_move + ld a, [wBattleMode] + jr z, .swap_moves + ld hl, wBattleMonMoves + ld bc, $20 + ld a, [wCurPartyMon] + call AddNTimes + push hl + call .copy_move + pop hl + ld bc, 6 + add hl, bc + call .copy_move + +.swap_moves + ld de, SFX_SWITCH_POKEMON + call PlaySFX + call WaitSFX + ld de, SFX_SWITCH_POKEMON + call PlaySFX + call WaitSFX + hlcoord 1, 2 + lb bc, 8, 18 + call ClearBox + hlcoord 10, 10 + lb bc, 1, 9 + call ClearBox + jp .loop + +.copy_move + push hl + ld a, [wMenuCursorY] + dec a + ld c, a + ld b, $0 + add hl, bc + ld d, h + ld e, l + pop hl + ld a, [wMoveSwapBuffer] + dec a + ld c, a + ld b, $0 + add hl, bc + ld a, [de] + ld b, [hl] + ld [hl], a + ld a, b + ld [de], a + ret + +.exit + xor a + ld [wMoveSwapBuffer], a + ld hl, w2DMenuFlags1 + res 6, [hl] + call ClearSprites + jp ClearTileMap + +MoveScreenAttributes: + db 3, 1 + db 3, 1 + db $40, $00 + dn 2, 0 + db D_UP | D_DOWN | D_LEFT | D_RIGHT | A_BUTTON | B_BUTTON + +String_MoveWhere: + db "Where?@" + +SetUpMoveScreenBG: + call ClearBGPalettes + call ClearTileMap + call ClearSprites + xor a + ld [hBGMapMode], a + farcall LoadStatsScreenPageTilesGFX + farcall ClearSpriteAnims2 + ld a, [wCurPartyMon] ld e, a - inc a - ld [wBuffer1], a - ld d, 0 - ld hl, wBuffer2 + ld d, $0 + ld hl, wPartySpecies add hl, de - pop af - ld [hl], a - pop de + ld a, [hl] + ld [wTempIconSpecies], a + ld e, MONICON_MOVES + farcall LoadMenuMonIcon + hlcoord 0, 1 + ld b, 9 + ld c, 18 + call TextBox + hlcoord 0, 11 + ld b, 5 + ld c, 18 + call TextBox + hlcoord 2, 0 + lb bc, 2, 3 + call ClearBox + xor a + ld [wMonType], a + ld hl, wPartyMonNicknames + ld a, [wCurPartyMon] + call GetNick + hlcoord 5, 1 + call PlaceString + push bc + farcall CopyMonToTempMon pop hl - ret + call PrintLevel + ld hl, wPlayerHPPal + call SetHPPal + ld b, SCGB_MOVE_LIST + call GetSGBLayout + hlcoord 16, 0 + lb bc, 1, 3 + jp ClearBox -BattleMonMenu: - ld hl, MenuHeader_0x24ed4 - call CopyMenuHeader +SetUpMoveList: xor a ld [hBGMapMode], a - call MenuBox - call UpdateSprites - call PlaceVerticalMenuItems + ld [wMoveSwapBuffer], a + ld [wMonType], a + predef CopyMonToTempMon + ld hl, wTempMonMoves + ld de, wListMoves_MoveIndicesBuffer + ld bc, NUM_MOVES + call CopyBytes + ld a, SCREEN_WIDTH * 2 + ld [wBuffer1], a + hlcoord 2, 3 + predef ListMoves + hlcoord 10, 4 + predef ListMovePP call WaitBGMap - call CopyMenuData - ld a, [wMenuDataFlags] - bit 7, a - jr z, .set_carry - call InitVerticalMenuCursor - ld hl, w2DMenuFlags1 - set 6, [hl] - call StaticMenuJoypad - ld de, SFX_READ_TEXT_2 - call PlaySFX - ld a, [hJoyPressed] - bit B_BUTTON_F, a - jr z, .clear_carry - ret z + call SetPalettes + ld a, [wNumMoves] + inc a + ld [w2DMenuNumRows], a + hlcoord 0, 11 + ld b, 5 + ld c, 18 + jp TextBox -.set_carry - scf +PrepareToPlaceMoveData: + ld hl, wPartyMon1Moves + ld bc, PARTYMON_STRUCT_LENGTH + ld a, [wCurPartyMon] + call AddNTimes + ld a, [wMenuCursorY] + dec a + ld c, a + ld b, $0 + add hl, bc + ld a, [hl] + ld [wCurSpecies], a + hlcoord 1, 12 + lb bc, 5, 18 + jp ClearBox + +PlaceMoveData: + xor a + ld [hBGMapMode], a + hlcoord 0, 10 + ld de, String_MoveType_Top + call PlaceString + hlcoord 0, 11 + ld de, String_MoveType_Bottom + call PlaceString + hlcoord 12, 12 + ld de, String_MoveAtk + call PlaceString + ld a, [wCurSpecies] + ld b, a + hlcoord 2, 12 + predef PrintMoveType + ld a, [wCurSpecies] + dec a + ld hl, Moves + MOVE_POWER + ld bc, MOVE_LENGTH + call AddNTimes + ld a, BANK(Moves) + call GetFarByte + hlcoord 16, 12 + cp 2 + jr c, .no_power + ld [wDeciramBuffer], a + ld de, wDeciramBuffer + lb bc, 1, 3 + call PrintNum + jr .description + +.no_power + ld de, String_MoveNoPower + call PlaceString + +.description + hlcoord 1, 14 + predef PrintMoveDesc + ld a, $1 + ld [hBGMapMode], a ret -.clear_carry +String_MoveType_Top: + db "┌─────┐@" +String_MoveType_Bottom: + db "│TYPE/└@" +String_MoveAtk: + db "ATK/@" +String_MoveNoPower: + db "---@" + +Function132d3: + call Function132da + call Function132fe + ret + +Function132da: + ld a, [wCurPartyMon] + and a + ret z + ld c, a + ld e, a + ld d, 0 + ld hl, wPartyCount + add hl, de +.loop + ld a, [hl] and a + jr z, .prev + cp EGG + jr z, .prev + cp NUM_POKEMON + 1 + jr c, .legal + +.prev + dec hl + dec c + jr nz, .loop ret -MenuHeader_0x24ed4: - db 0 ; flags - menu_coords 11, 11, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 - dw MenuData_0x24edc - db 1 ; default option +.legal + hlcoord 16, 0 + ld [hl], "◀" + ret -MenuData_0x24edc: - db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags - db 3 ; items - db "SWITCH@" - db "STATS@" - db "CANCEL@" +Function132fe: + ld a, [wCurPartyMon] + inc a + ld c, a + ld a, [wPartyCount] + cp c + ret z + ld e, c + ld d, 0 + ld hl, wPartySpecies + add hl, de +.loop + ld a, [hl] + cp -1 + ret z + and a + jr z, .next + cp EGG + jr z, .next + cp NUM_POKEMON + 1 + jr c, .legal + +.next + inc hl + jr .loop + +.legal + hlcoord 18, 0 + ld [hl], "▶" + ret diff --git a/engine/pokemon/mon_stats.asm b/engine/pokemon/mon_stats.asm index 76f09b461..74e3d2a95 100644 --- a/engine/pokemon/mon_stats.asm +++ b/engine/pokemon/mon_stats.asm @@ -295,7 +295,7 @@ ListMovePP: call PrintNum ld a, "/" ld [hli], a - ld de, wd265 + ld de, wTempPP lb bc, 1, 2 call PrintNum pop hl diff --git a/engine/pokemon/mon_submenu.asm b/engine/pokemon/mon_submenu.asm new file mode 100644 index 000000000..926c35f5d --- /dev/null +++ b/engine/pokemon/mon_submenu.asm @@ -0,0 +1,290 @@ +INCLUDE "data/mon_menu.asm" + +MonSubmenu: + xor a + ld [hBGMapMode], a + call GetMonSubmenuItems + farcall FreezeMonIcons + ld hl, .MenuHeader + call LoadMenuHeader + call .GetTopCoord + call PopulateMonMenu + + ld a, 1 + ld [hBGMapMode], a + call MonMenuLoop + ld [wMenuSelection], a + + call ExitMenu + ret + +.MenuHeader: + db MENU_BACKUP_TILES ; flags + menu_coords 6, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 + dw 0 + db 1 ; default option + +.GetTopCoord: +; TopCoord = 1 + BottomCoord - 2 * (NumSubmenuItems + 1) + ld a, [wBuffer1] + inc a + add a + ld b, a + ld a, [wMenuBorderBottomCoord] + sub b + inc a + ld [wMenuBorderTopCoord], a + call MenuBox + ret + +MonMenuLoop: +.loop + ld a, MENU_UNUSED_3 | MENU_BACKUP_TILES_2 ; flags + ld [wMenuDataFlags], a + ld a, [wBuffer1] ; items + ld [wMenuDataItems], a + call InitVerticalMenuCursor + ld hl, w2DMenuFlags1 + set 6, [hl] + call StaticMenuJoypad + ld de, SFX_READ_TEXT_2 + call PlaySFX + ld a, [hJoyPressed] + bit A_BUTTON_F, a + jr nz, .select + bit B_BUTTON_F, a + jr nz, .cancel + jr .loop + +.cancel + ld a, MONMENUITEM_CANCEL + ret + +.select + ld a, [wMenuCursorY] + dec a + ld c, a + ld b, 0 + ld hl, wBuffer2 + add hl, bc + ld a, [hl] + ret + +PopulateMonMenu: + call MenuBoxCoord2Tile + ld bc, 2 * SCREEN_WIDTH + 2 + add hl, bc + ld de, wBuffer2 +.loop + ld a, [de] + inc de + cp -1 + ret z + push de + push hl + call GetMonMenuString + pop hl + call PlaceString + ld bc, 2 * SCREEN_WIDTH + add hl, bc + pop de + jr .loop + +GetMonMenuString: + ld hl, MonMenuOptions + 1 + ld de, 3 + call IsInArray + dec hl + ld a, [hli] + cp MONMENU_MENUOPTION + jr z, .NotMove + inc hl + ld a, [hl] + ld [wNamedObjectIndexBuffer], a + call GetMoveName + ret + +.NotMove: + inc hl + ld a, [hl] + dec a + ld hl, MonMenuOptionStrings + call GetNthString + ld d, h + ld e, l + ret + +GetMonSubmenuItems: + call ResetMonSubmenu + ld a, [wCurPartySpecies] + cp EGG + jr z, .egg + ld a, [wLinkMode] + and a + jr nz, .skip_moves + ld a, MON_MOVES + call GetPartyParamLocation + ld d, h + ld e, l + ld c, NUM_MOVES +.loop + push bc + push de + ld a, [de] + and a + jr z, .next + push hl + call IsFieldMove + pop hl + jr nc, .next + call AddMonMenuItem + +.next + pop de + inc de + pop bc + dec c + jr nz, .loop + +.skip_moves + ld a, MONMENUITEM_STATS + call AddMonMenuItem + ld a, MONMENUITEM_SWITCH + call AddMonMenuItem + ld a, MONMENUITEM_MOVE + call AddMonMenuItem + ld a, [wLinkMode] + and a + jr nz, .skip2 + push hl + ld a, MON_ITEM + call GetPartyParamLocation + ld d, [hl] + farcall ItemIsMail + pop hl + ld a, MONMENUITEM_MAIL + jr c, .ok + ld a, MONMENUITEM_ITEM + +.ok + call AddMonMenuItem + +.skip2 + ld a, [wBuffer1] + cp NUM_MONMENU_ITEMS + jr z, .ok2 + ld a, MONMENUITEM_CANCEL + call AddMonMenuItem + +.ok2 + call TerminateMonSubmenu + ret + +.egg + ld a, MONMENUITEM_STATS + call AddMonMenuItem + ld a, MONMENUITEM_SWITCH + call AddMonMenuItem + ld a, MONMENUITEM_CANCEL + call AddMonMenuItem + call TerminateMonSubmenu + ret + +IsFieldMove: + ld b, a + ld hl, MonMenuOptions +.next + ld a, [hli] + cp -1 + jr z, .nope + cp MONMENU_MENUOPTION + jr z, .nope + ld d, [hl] + inc hl + ld a, [hli] + cp b + jr nz, .next + ld a, d + scf + +.nope + ret + +ResetMonSubmenu: + xor a + ld [wBuffer1], a + ld hl, wBuffer2 + ld bc, NUM_MONMENU_ITEMS + 1 + call ByteFill + ret + +TerminateMonSubmenu: + ld a, [wBuffer1] + ld e, a + ld d, 0 + ld hl, wBuffer2 + add hl, de + ld [hl], -1 + ret + +AddMonMenuItem: + push hl + push de + push af + ld a, [wBuffer1] + ld e, a + inc a + ld [wBuffer1], a + ld d, 0 + ld hl, wBuffer2 + add hl, de + pop af + ld [hl], a + pop de + pop hl + ret + +BattleMonMenu: + ld hl, MenuHeader_0x24ed4 + call CopyMenuHeader + xor a + ld [hBGMapMode], a + call MenuBox + call UpdateSprites + call PlaceVerticalMenuItems + call WaitBGMap + call CopyMenuData + ld a, [wMenuDataFlags] + bit 7, a + jr z, .set_carry + call InitVerticalMenuCursor + ld hl, w2DMenuFlags1 + set 6, [hl] + call StaticMenuJoypad + ld de, SFX_READ_TEXT_2 + call PlaySFX + ld a, [hJoyPressed] + bit B_BUTTON_F, a + jr z, .clear_carry + ret z + +.set_carry + scf + ret + +.clear_carry + and a + ret + +MenuHeader_0x24ed4: + db 0 ; flags + menu_coords 11, 11, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 + dw MenuData_0x24edc + db 1 ; default option + +MenuData_0x24edc: + db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags + db 3 ; items + db "SWITCH@" + db "STATS@" + db "CANCEL@" diff --git a/engine/pokemon/move_mon.asm b/engine/pokemon/move_mon.asm index 7074dafd8..e14a1a03a 100644 --- a/engine/pokemon/move_mon.asm +++ b/engine/pokemon/move_mon.asm @@ -52,7 +52,7 @@ TryAddMonToParty: and a jr nz, .skipnickname ld a, [wCurPartySpecies] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetPokemonName ld hl, wPartyMonNicknames ld a, [hMoveMon] @@ -185,11 +185,11 @@ endr .registerpokedex ld a, [wCurPartySpecies] - ld [wd265], a + ld [wTempSpecies], a dec a push de call CheckCaughtMon - ld a, [wd265] + ld a, [wTempSpecies] dec a call SetSeenAndCaughtMon pop de @@ -695,7 +695,7 @@ SendGetMonIntoFromBox: ld a, [sBoxCount] dec a ld b, a - call RestorePPofDepositedPokemon + call RestorePPOfDepositedPokemon .CloseSRAM_And_ClearCarryFlag: call CloseSRAM and a @@ -706,7 +706,7 @@ CloseSRAM_And_SetCarryFlag: scf ret -RestorePPofDepositedPokemon: +RestorePPOfDepositedPokemon: ld a, b ld hl, sBoxMons ld bc, BOXMON_STRUCT_LENGTH @@ -750,7 +750,7 @@ RestorePPofDepositedPokemon: farcall GetMaxPPOfMove pop de pop hl - ld a, [wd265] + ld a, [wTempPP] ld b, a ld a, [de] and %11000000 @@ -970,7 +970,7 @@ SendMonIntoBox: call CopyBytes ld a, [wCurPartySpecies] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetPokemonName ld de, sBoxMonNicknames @@ -1057,7 +1057,7 @@ SendMonIntoBox: call CopyBytes ld b, 0 - call RestorePPofDepositedPokemon + call RestorePPOfDepositedPokemon call CloseSRAM scf @@ -1403,7 +1403,7 @@ CalcMonStats: ; hl is the path to the Stat EXP ; de points to where the final stats will be saved - ld c, $0 + ld c, STAT_HP - 1 ; first stat .loop inc c call CalcMonStatC @@ -1414,7 +1414,7 @@ CalcMonStats: ld [de], a inc de ld a, c - cp STAT_SDEF + cp STAT_SDEF ; last stat jr nz, .loop ret @@ -1434,14 +1434,14 @@ CalcMonStatC: push hl ld hl, wBaseStats dec hl ; has to be decreased, because 'c' begins with 1 - ld b, $0 + ld b, 0 add hl, bc ld a, [hl] ld e, a pop hl push hl ld a, c - cp STAT_SDEF + cp STAT_SDEF ; last stat jr nz, .not_spdef dec hl dec hl @@ -1669,7 +1669,7 @@ GivePoke:: .done ld a, [wCurPartySpecies] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a ld [wTempEnemyMonSpecies], a call GetPokemonName ld hl, wStringBuffer1 diff --git a/engine/pokemon/move_mon_wo_mail.asm b/engine/pokemon/move_mon_wo_mail.asm index 1dab879c7..8166d348c 100644 --- a/engine/pokemon/move_mon_wo_mail.asm +++ b/engine/pokemon/move_mon_wo_mail.asm @@ -5,21 +5,21 @@ InsertPokemonIntoBox: call InsertSpeciesIntoBoxOrParty ld a, [sBoxCount] dec a - ld [wd265], a + ld [wNextBoxOrPartyIndex], a ld hl, sBoxMonNicknames ld bc, MON_NAME_LENGTH ld de, wBufferMonNick call InsertDataIntoBoxOrParty ld a, [sBoxCount] dec a - ld [wd265], a + ld [wNextBoxOrPartyIndex], a ld hl, sBoxMonOT ld bc, NAME_LENGTH ld de, wBufferMonOT call InsertDataIntoBoxOrParty ld a, [sBoxCount] dec a - ld [wd265], a + ld [wNextBoxOrPartyIndex], a ld hl, sBoxMons ld bc, BOXMON_STRUCT_LENGTH ld de, wBufferMon @@ -34,7 +34,7 @@ InsertPokemonIntoBox: call CopyBytes ld a, [wCurPartyMon] ld b, a - farcall RestorePPofDepositedPokemon + farcall RestorePPOfDepositedPokemon jp CloseSRAM InsertPokemonIntoParty: @@ -42,21 +42,21 @@ InsertPokemonIntoParty: call InsertSpeciesIntoBoxOrParty ld a, [wPartyCount] dec a - ld [wd265], a + ld [wNextBoxOrPartyIndex], a ld hl, wPartyMonNicknames ld bc, MON_NAME_LENGTH ld de, wBufferMonNick call InsertDataIntoBoxOrParty ld a, [wPartyCount] dec a - ld [wd265], a + ld [wNextBoxOrPartyIndex], a ld hl, wPartyMonOT ld bc, NAME_LENGTH ld de, wBufferMonOT call InsertDataIntoBoxOrParty ld a, [wPartyCount] dec a - ld [wd265], a + ld [wNextBoxOrPartyIndex], a ld hl, wPartyMons ld bc, PARTYMON_STRUCT_LENGTH ld de, wBufferMon @@ -85,7 +85,7 @@ InsertDataIntoBoxOrParty: push de push hl push bc - ld a, [wd265] + ld a, [wNextBoxOrPartyIndex] dec a call AddNTimes push hl @@ -95,7 +95,7 @@ InsertDataIntoBoxOrParty: pop hl .loop push bc - ld a, [wd265] + ld a, [wNextBoxOrPartyIndex] ld b, a ld a, [wCurPartyMon] cp b @@ -116,9 +116,9 @@ InsertDataIntoBoxOrParty: sbc b ld h, a pop de - ld a, [wd265] + ld a, [wNextBoxOrPartyIndex] dec a - ld [wd265], a + ld [wNextBoxOrPartyIndex], a jr .loop .insert diff --git a/engine/pokemon/party_menu.asm b/engine/pokemon/party_menu.asm index c3a70dbdc..814e6be55 100644 --- a/engine/pokemon/party_menu.asm +++ b/engine/pokemon/party_menu.asm @@ -596,7 +596,7 @@ InitPartyMenuGFX: push hl ld hl, LoadMenuMonIcon ld a, BANK(LoadMenuMonIcon) - ld e, $0 + ld e, MONICON_PARTYMENU rst FarCall ld a, [hObjectStructIndexBuffer] inc a diff --git a/engine/pokemon/print_move_description.asm b/engine/pokemon/print_move_description.asm new file mode 100644 index 000000000..c461f2f3d --- /dev/null +++ b/engine/pokemon/print_move_description.asm @@ -0,0 +1,14 @@ +PrintMoveDesc: + push hl + ld hl, MoveDescriptions + ld a, [wCurSpecies] + dec a + ld c, a + ld b, 0 + add hl, bc + add hl, bc + ld a, [hli] + ld e, a + ld d, [hl] + pop hl + jp PlaceString diff --git a/engine/pokemon/stats_screen.asm b/engine/pokemon/stats_screen.asm index dfc704f1a..72f895269 100644 --- a/engine/pokemon/stats_screen.asm +++ b/engine/pokemon/stats_screen.asm @@ -377,7 +377,7 @@ StatsScreen_InitUpperHalf: xor a ld [hBGMapMode], a ld a, [wBaseDexNo] - ld [wd265], a + ld [wDeciramBuffer], a ld [wCurSpecies], a hlcoord 8, 0 ld [hl], "№" @@ -386,7 +386,7 @@ StatsScreen_InitUpperHalf: inc hl hlcoord 10, 0 lb bc, PRINTNUM_LEADINGZEROS | 1, 3 - ld de, wd265 + ld de, wDeciramBuffer call PrintNum hlcoord 14, 0 call PrintLevel @@ -401,7 +401,7 @@ StatsScreen_InitUpperHalf: ld a, "/" ld [hli], a ld a, [wBaseDexNo] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetPokemonName call PlaceString call StatsScreen_PlaceHorizontalDivider @@ -483,7 +483,7 @@ StatsScreen_PlaceShinyIcon: StatsScreen_LoadGFX: ld a, [wBaseDexNo] - ld [wd265], a + ld [wTempSpecies], a ld [wCurSpecies], a xor a ld [hBGMapMode], a @@ -708,7 +708,7 @@ StatsScreen_LoadGFX: ld b, a farcall TimeCapsule_ReplaceTeruSama ld a, b - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetItemName ret diff --git a/engine/pokemon/switchpartymons.asm b/engine/pokemon/switchpartymons.asm index d612a3472..6d68ec88d 100644 --- a/engine/pokemon/switchpartymons.asm +++ b/engine/pokemon/switchpartymons.asm @@ -1,5 +1,5 @@ _SwitchPartyMons: - ld a, [wd0e3] + ld a, [wSwitchMon] dec a ld [wBuffer3], a ld b, a diff --git a/engine/pokemon/types.asm b/engine/pokemon/types.asm index 4e2ca3e45..abeeda840 100644 --- a/engine/pokemon/types.asm +++ b/engine/pokemon/types.asm @@ -74,9 +74,9 @@ PrintType: jp PlaceString GetTypeName: -; Copy the name of type [wd265] to wStringBuffer1. +; Copy the name of type [wNamedObjectIndexBuffer] to wStringBuffer1. - ld a, [wd265] + ld a, [wNamedObjectIndexBuffer] ld hl, TypeNames ld e, a ld d, 0 diff --git a/engine/printer/print_party.asm b/engine/printer/print_party.asm index eeb694d62..9aca79378 100644 --- a/engine/printer/print_party.asm +++ b/engine/printer/print_party.asm @@ -26,11 +26,11 @@ PrintPage1: hlcoord 2, 11, wPrinterTileMapBuffer lb bc, 5, 18 call ClearBox - ld a, [wd265] + ld a, [wTempSpecies] dec a call CheckCaughtMon push af - ld a, [wd265] + ld a, [wTempSpecies] ld b, a ld c, 1 ; get page 1 farcall GetDexEntryPagePointer @@ -75,11 +75,11 @@ PrintPage2: ld bc, SCREEN_WIDTH ld a, $32 call ByteFill - ld a, [wd265] + ld a, [wTempSpecies] dec a call CheckCaughtMon push af - ld a, [wd265] + ld a, [wTempSpecies] ld b, a ld c, 2 ; get page 2 farcall GetDexEntryPagePointer @@ -170,7 +170,7 @@ PrintPartyMonPage1: lb bc, 2, 3 call PrintNum ld a, [wCurPartySpecies] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a ld [wCurSpecies], a ld hl, wPartyMonNicknames call Function1dc50e @@ -186,7 +186,7 @@ PrintPartyMonPage1: inc hl ld [hl], "." inc hl - ld de, wd265 + ld de, wNamedObjectIndexBuffer lb bc, PRINTNUM_LEADINGZEROS | 1, 3 call PrintNum hlcoord 1, 9 @@ -297,7 +297,7 @@ Function1dc51a: and a jr z, .no_move - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetMoveName jr .got_string diff --git a/engine/printer/printer.asm b/engine/printer/printer.asm index 4dc74c6d2..8477ce88a 100644 --- a/engine/printer/printer.asm +++ b/engine/printer/printer.asm @@ -268,12 +268,12 @@ PrintUnownStamp: ld [wPrinterQueueLength], a ret -PrintMail: - call PrintMail_ +PrintMailAndExit: + call PrintMail call Printer_ExitPrinter ret -PrintMail_: +PrintMail: ld a, [wPrinterQueueLength] push af xor a @@ -725,7 +725,7 @@ Printer_PrintBoxListSegment: ld a, [de] cp $ff jp z, .finish - ld [wd265], a + ld [wNamedObjectIndexBuffer], a ld [wCurPartySpecies], a push bc diff --git a/engine/printer/printer_serial.asm b/engine/printer/printer_serial.asm index e8f106ac4..e8d056bf9 100644 --- a/engine/printer/printer_serial.asm +++ b/engine/printer/printer_serial.asm @@ -44,14 +44,14 @@ PrinterJumptableIteration: dw Printer_WaitUntilFinished ; 0c dw Printer_Quit ; 0d - dw Printer_NextSection_ ; 0e + dw Printer_NextSection ; 0e dw Printer_WaitSerial ; 0f dw Printer_SignalLoopBack ; 10 dw Printer_SectionOne ; 11 - dw Printer_WaitLoopBack ; 12 - dw Printer_WaitLoopBack_ ; 13 + dw Printer_NextSectionWaitLoopBack ; 12 + dw Printer_WaitLoopBack ; 13 -Printer_NextSection: +_Printer_NextSection: ld hl, wJumptableIndex inc [hl] ret @@ -68,8 +68,8 @@ Printer_Quit: set 7, [hl] ret -Printer_NextSection_: - call Printer_NextSection +Printer_NextSection: + call _Printer_NextSection ret Printer_SectionOne: @@ -86,7 +86,7 @@ Print_InitPrinterHandshake: ld [wPrinterSendByteCounter + 1], a ld a, [wPrinterQueueLength] ld [wPrinterRowIndex], a - call Printer_NextSection + call _Printer_NextSection call Printer_WaitHandshake ld a, PRINTER_STATUS_CHECKING ld [wPrinterStatus], a @@ -110,7 +110,7 @@ Printer_StartTransmittingTilemap: ld [wPrinterSendByteCounter + 1], a ; compute the checksum call Printer_ComputeChecksum - call Printer_NextSection + call _Printer_NextSection call Printer_WaitHandshake ld a, PRINTER_STATUS_TRANSMITTING ld [wPrinterStatus], a @@ -127,7 +127,7 @@ Printer_EndTilemapTransmission: xor a ld [wPrinterSendByteCounter], a ld [wPrinterSendByteCounter + 1], a - call Printer_NextSection + call _Printer_NextSection call Printer_WaitHandshake ret @@ -143,7 +143,7 @@ Printer_SignalSendHeader: ld [wPrinterSendByteCounter + 1], a ; compute the checksum call Printer_ComputeChecksum - call Printer_NextSection + call _Printer_NextSection call Printer_WaitHandshake ld a, PRINTER_STATUS_PRINTING ld [wPrinterStatus], a @@ -160,7 +160,7 @@ Printer_SignalLoopBack: ld [wPrinterSendByteCounter + 1], a ld a, [wPrinterQueueLength] ld [wPrinterRowIndex], a - call Printer_NextSection + call _Printer_NextSection call Printer_WaitHandshake ret @@ -172,7 +172,7 @@ Printer_WaitSerial: ret c xor a ld [hl], a - call Printer_NextSection + call _Printer_NextSection ret Printer_WaitSerialAndLoopBack2: @@ -211,7 +211,7 @@ Printer_CheckConnectionStatus: set 1, [hl] ld a, $5 ld [wHandshakeFrameDelay], a - call Printer_NextSection + call _Printer_NextSection ret .printer_error @@ -232,7 +232,7 @@ Printer_TransmissionLoop: ld a, [wPrinterStatusFlags] and $1 jr nz, .cycle_back - call Printer_NextSection + call _Printer_NextSection ret .cycle_back @@ -240,7 +240,7 @@ Printer_TransmissionLoop: ret .enter_wait_loop - ld a, $12 ; Printer_WaitLoopBack + ld a, $12 ; Printer_NextSectionWaitLoopBack ld [wJumptableIndex], a ret @@ -251,12 +251,12 @@ Printer_WaitUntilFinished: ld a, [wPrinterStatusFlags] and $f3 ret nz - call Printer_NextSection + call _Printer_NextSection ret +Printer_NextSectionWaitLoopBack: + call _Printer_NextSection Printer_WaitLoopBack: - call Printer_NextSection -Printer_WaitLoopBack_: ld a, [wPrinterOpcode] and a ret nz @@ -474,31 +474,31 @@ _PrinterReceive:: dw Printer_SendNextByte ; 06 dw Printer_SendwPrinterChecksumLo ; 07 dw Printer_SendwPrinterChecksumHi ; 08 - dw Printer_Send0x00 ; 09 - dw Printer_ReceiveTowPrinterHandshakeAndSend0x00 ; 0a - dw Printer_ReceiveTowPrinterStatusFlagsAndExitSendLoop ; 0b + dw Printer_Send0x00_2 ; 09 + dw Printer_ReceiveTwoPrinterHandshakeAndSend0x00 ; 0a + dw Printer_ReceiveTwoPrinterStatusFlagsAndExitSendLoop ; 0b dw Printer_Send0x33 ; 0c triggered by AskSerial dw Printer_Send0x0f ; 0d - dw Printer_Send0x00_ ; 0e - dw Printer_Send0x00_ ; 0f - dw Printer_Send0x00_ ; 10 + dw Printer_Send0x00 ; 0e + dw Printer_Send0x00 ; 0f + dw Printer_Send0x00 ; 10 dw Printer_Send0x0f ; 11 - dw Printer_Send0x00_ ; 12 - dw Printer_Send0x00 ; 13 - dw Printer_ReceiveTowPrinterHandshakeAndSend0x00 ; 14 - dw Printer_ReceiveTowPrinterStatusFlagsAndExitSendLoop_ ; 15 + dw Printer_Send0x00 ; 12 + dw Printer_Send0x00_2 ; 13 + dw Printer_ReceiveTwoPrinterHandshakeAndSend0x00 ; 14 + dw Printer_ReceiveTwoPrinterStatusFlagsAndExitSendLoop_2 ; 15 dw Printer_Send0x33 ; 16 triggered by pressing B dw Printer_Send0x08 ; 17 - dw Printer_Send0x00_ ; 18 - dw Printer_Send0x00_ ; 19 - dw Printer_Send0x00_ ; 1a + dw Printer_Send0x00 ; 18 + dw Printer_Send0x00 ; 19 + dw Printer_Send0x00 ; 1a dw Printer_Send0x08 ; 1b - dw Printer_Send0x00_ ; 1c - dw Printer_Send0x00 ; 1d - dw Printer_ReceiveTowPrinterHandshakeAndSend0x00 ; 1e - dw Printer_ReceiveTowPrinterStatusFlagsAndExitSendLoop ; 1f + dw Printer_Send0x00 ; 1c + dw Printer_Send0x00_2 ; 1d + dw Printer_ReceiveTwoPrinterHandshakeAndSend0x00 ; 1e + dw Printer_ReceiveTwoPrinterStatusFlagsAndExitSendLoop ; 1f Printer_NextInstruction: ld hl, wPrinterOpcode @@ -580,13 +580,14 @@ Printer_SendwPrinterChecksumHi: call Printer_NextInstruction ret -Printer_Send0x00: +Printer_Send0x00_2: +; identical to Printer_Send0x00, but referenced less ld a, $0 call Printer_SerialSend call Printer_NextInstruction ret -Printer_ReceiveTowPrinterHandshakeAndSend0x00: +Printer_ReceiveTwoPrinterHandshakeAndSend0x00: ld a, [rSB] ld [wPrinterHandshake], a ld a, $0 @@ -594,7 +595,7 @@ Printer_ReceiveTowPrinterHandshakeAndSend0x00: call Printer_NextInstruction ret -Printer_ReceiveTowPrinterStatusFlagsAndExitSendLoop: +Printer_ReceiveTwoPrinterStatusFlagsAndExitSendLoop: ld a, [rSB] ld [wPrinterStatusFlags], a xor a @@ -607,7 +608,7 @@ Printer_Send0x0f: call Printer_NextInstruction ret -Printer_Send0x00_: +Printer_Send0x00: ld a, $0 call Printer_SerialSend call Printer_NextInstruction @@ -627,7 +628,8 @@ Printer_SerialSend: ld [rSC], a ret -Printer_ReceiveTowPrinterStatusFlagsAndExitSendLoop_: +Printer_ReceiveTwoPrinterStatusFlagsAndExitSendLoop_2: +; identical to Printer_ReceiveTwoPrinterStatusFlagsAndExitSendLoop, but referenced less ld a, [rSB] ld [wPrinterStatusFlags], a xor a diff --git a/engine/rtc/timeset.asm b/engine/rtc/timeset.asm index 06f800c45..0b05f9c03 100644 --- a/engine/rtc/timeset.asm +++ b/engine/rtc/timeset.asm @@ -694,8 +694,8 @@ PrintHour: inc hl pop bc call AdjustHourForAMorPM - ld [wd265], a - ld de, wd265 + ld [wDeciramBuffer], a + ld de, wDeciramBuffer call PrintTwoDigitNumberRightAlign ret diff --git a/engine/tilesets/tileset_anims.asm b/engine/tilesets/tileset_anims.asm index 1e6abb968..2827b3a92 100644 --- a/engine/tilesets/tileset_anims.asm +++ b/engine/tilesets/tileset_anims.asm @@ -40,7 +40,7 @@ TilesetKantoAnim: dw NULL, WaitTileAnimation dw NULL, WaitTileAnimation dw NULL, WaitTileAnimation - dw NULL, TileAnimationPalette + dw NULL, AnimateWaterPalette dw NULL, WaitTileAnimation dw NULL, AnimateFlowerTile dw NULL, WaitTileAnimation @@ -53,7 +53,7 @@ TilesetParkAnim: dw NULL, WaitTileAnimation dw vTiles2 tile $5f, AnimateFountain dw NULL, WaitTileAnimation - dw NULL, TileAnimationPalette + dw NULL, AnimateWaterPalette dw NULL, WaitTileAnimation dw NULL, AnimateFlowerTile dw NULL, WaitTileAnimation @@ -71,7 +71,7 @@ TilesetForestAnim: dw NULL, ForestTreeRightAnimation2 dw NULL, AnimateFlowerTile dw vTiles2 tile $14, AnimateWaterTile - dw NULL, TileAnimationPalette + dw NULL, AnimateWaterPalette dw NULL, StandingTileFrame8 dw NULL, DoneTileAnimation @@ -79,7 +79,7 @@ TilesetJohtoAnim: dw vTiles2 tile $14, AnimateWaterTile dw NULL, WaitTileAnimation dw NULL, WaitTileAnimation - dw NULL, TileAnimationPalette + dw NULL, AnimateWaterPalette dw NULL, WaitTileAnimation dw NULL, AnimateFlowerTile dw WhirlpoolFrames1, AnimateWhirlpoolTile @@ -122,7 +122,7 @@ TilesetPortAnim: dw NULL, WaitTileAnimation dw NULL, WaitTileAnimation dw NULL, WaitTileAnimation - dw NULL, TileAnimationPalette + dw NULL, AnimateWaterPalette dw NULL, WaitTileAnimation dw NULL, WaitTileAnimation dw NULL, WaitTileAnimation @@ -178,7 +178,7 @@ TilesetDarkCaveAnim: dw NULL, FlickeringCaveEntrancePalette dw vTiles2 tile $14, WriteTileFromBuffer dw NULL, FlickeringCaveEntrancePalette - dw NULL, TileAnimationPalette + dw NULL, AnimateWaterPalette dw NULL, FlickeringCaveEntrancePalette dw vTiles2 tile $40, WriteTileToBuffer dw NULL, FlickeringCaveEntrancePalette @@ -199,7 +199,7 @@ TilesetIcePathAnim: dw NULL, FlickeringCaveEntrancePalette dw vTiles2 tile $35, WriteTileFromBuffer dw NULL, FlickeringCaveEntrancePalette - dw NULL, TileAnimationPalette + dw NULL, AnimateWaterPalette dw NULL, FlickeringCaveEntrancePalette dw vTiles2 tile $31, WriteTileToBuffer dw NULL, FlickeringCaveEntrancePalette @@ -852,7 +852,7 @@ endr ld sp, hl ret -TileAnimationPalette: +AnimateWaterPalette: ; Transition between color values 0-2 for color 0 in palette 3. ; No palette changes on DMG. |