diff options
author | pikalaxalt <PikalaxALT@gmail.com> | 2016-06-08 01:05:34 -0400 |
---|---|---|
committer | pikalaxalt <PikalaxALT@gmail.com> | 2016-06-08 01:05:34 -0400 |
commit | 19656f9dee2671838983ab407e901bd6bb49006a (patch) | |
tree | 2bdaaa8a7093eb4216de9d7b157477003ed6375d | |
parent | 5da4ad3d5c62292f062d4f7b4382e6c09b7faaea (diff) |
No more standalone WRAM addresses in the Event Flags array
-rw-r--r-- | constants/event_constants.asm | 2 | ||||
-rw-r--r-- | constants/event_macros.asm | 10 | ||||
-rwxr-xr-x | engine/hall_of_fame.asm | 3 | ||||
-rwxr-xr-x | engine/items/items.asm | 207 | ||||
-rwxr-xr-x | engine/menu/start_menu.asm | 91 | ||||
-rw-r--r-- | home.asm | 61 | ||||
-rw-r--r-- | home/overworld.asm | 6 | ||||
-rwxr-xr-x | scripts/billshouse.asm | 3 | ||||
-rwxr-xr-x | scripts/oakslab.asm | 6 | ||||
-rwxr-xr-x | scripts/rockethideout4.asm | 3 | ||||
-rwxr-xr-x | wram.asm | 134 |
11 files changed, 197 insertions, 329 deletions
diff --git a/constants/event_constants.asm b/constants/event_constants.asm index 2d1fab45..9c40b013 100644 --- a/constants/event_constants.asm +++ b/constants/event_constants.asm @@ -2560,3 +2560,5 @@ const_value = 0 const EVENT_9FD ; 9FD, (D886, bit 5) const EVENT_9FE ; 9FE, (D886, bit 6) const EVENT_9FF ; 9FF, (D886, bit 7) + +NUM_EVENT_FLAGS EQU const_value diff --git a/constants/event_macros.asm b/constants/event_macros.asm index bf0a95b5..a3ce9746 100644 --- a/constants/event_macros.asm +++ b/constants/event_macros.asm @@ -57,6 +57,16 @@ event_byte = ((\2) / 8) ld \1, wEventFlags + event_byte ENDM +EventFlagAddressa: MACRO +event_byte = ((\1) / 8) + ld [wEventFlags + event_byte], a + ENDM + +aEventFlagAddress: MACRO +event_byte = ((\1) / 8) + ld a, [wEventFlags + event_byte] + ENDM + ;\1 = event index CheckEventHL: MACRO event_byte = ((\1) / 8) diff --git a/engine/hall_of_fame.asm b/engine/hall_of_fame.asm index 9649da5d..ee138737 100755 --- a/engine/hall_of_fame.asm +++ b/engine/hall_of_fame.asm @@ -223,8 +223,7 @@ HoFLoadMonPlayerPicTileIDs: ; 703c7 (1c:43c7) predef_jump CopyTileIDsFromList HoFDisplayPlayerStats: ; 703d1 (1c:43d1) - ld hl, wd747 - set 3, [hl] + SetEvent EVENT_HALL_OF_FAME_DEX_RATING predef DisplayDexRating coord hl, 0, 4 lb bc, 6, 10 diff --git a/engine/items/items.asm b/engine/items/items.asm index cffcb5b3..197e5e5d 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -2,7 +2,7 @@ UseItem_: ; d2ed (3:52ed) ld a, 1 ld [wActionResultOrTookBattleTurn], a ; initialise to success value ld a, [wcf91] ;contains item_ID - cp a, HM_01 + cp HM_01 jp nc, ItemUseTMHM ld hl, ItemUsePtrTable dec a @@ -112,17 +112,17 @@ ItemUseBall: ; d3ad (3:53ad) cp $4 ; pikachu battle? jr z, .UseBall ld a, [wPartyCount] ;is Party full? - cp a, PARTY_LENGTH + cp PARTY_LENGTH jr nz, .UseBall ld a, [wNumInBox] ;is Box full? - cp a, MONS_PER_BOX + cp MONS_PER_BOX jp z, BoxFullCannotThrowBall .UseBall ;ok, you can use a ball xor a ld [wCapturedMonSpecies], a ld a, [wBattleType] - cp a, 2 ;SafariBattle + cp 2 ;SafariBattle jr nz, .skipSafariZoneCode .safariZone ; remove a Safari Ball from inventory @@ -151,22 +151,21 @@ ItemUseBall: ; d3ad (3:53ad) ld bc, NAME_LENGTH call CopyData ; save the player's name in the Wild Monster data ld a, [wBattleType] - cp $1 + cp MASTER_BALL jp nz, .BallSuccess ld a, $1 ld [wCapturedMonSpecies], a - ld a, [wd74c] - bit 7, a + CheckEvent EVENT_02F ld b, $63 jp nz, .next12 jp .BallSuccess .notOldManBattle ld a, [wCurMap] - cp a, POKEMONTOWER_6 + cp POKEMONTOWER_6 jr nz, .loop ld a, [wEnemyMonSpecies2] - cp a, MAROWAK + cp MAROWAK ld b, $10 jp z, .next12 ; if not fighting ghost Marowak, loop until a random number in the current @@ -177,15 +176,15 @@ ItemUseBall: ; d3ad (3:53ad) ld hl, wcf91 .asm_d54a ld a, [hl] - cp a, MASTER_BALL + cp MASTER_BALL jp z, .BallSuccess - cp a, POKE_BALL + cp POKE_BALL jr z, .checkForAilments ld a, 200 cp b jr c, .loop ;get only numbers <= 200 for Great Ball ld a, [hl] - cp a, GREAT_BALL + cp GREAT_BALL jr z, .checkForAilments ld a, 150 ;get only numbers <= 150 for Ultra Ball cp b @@ -198,7 +197,7 @@ ItemUseBall: ; d3ad (3:53ad) ld a, [wEnemyMonStatus] ;status ailments and a jr z, .noAilments - and a, 1 << FRZ | SLP ;is frozen and/or asleep? + and 1 << FRZ | SLP ;is frozen and/or asleep? ld c, 12 jr z, .notFrozenOrAsleep ld c, 25 @@ -318,13 +317,13 @@ ItemUseBall: ; d3ad (3:53ad) ld [H_QUOTIENT + 3], a .next13 ld a, [H_QUOTIENT + 3] - cp a, 10 + cp 10 ld b, $20 jr c, .next12 - cp a, 30 + cp 30 ld b, $61 jr c, .next12 - cp a, 70 + cp 70 ld b, $62 jr c, .next12 ld b, $63 @@ -350,19 +349,19 @@ ItemUseBall: ; d3ad (3:53ad) pop af ld [wWhichPokemon], a ld a, [wPokeBallAnimData] - cp a, $10 + cp $10 ld hl, ItemUseBallText00 jp z, .printText0 - cp a, $20 + cp $20 ld hl, ItemUseBallText01 jp z, .printText0 - cp a, $61 + cp $61 ld hl, ItemUseBallText02 jp z, .printText0 - cp a, $62 + cp $62 ld hl, ItemUseBallText03 jp z, .printText0 - cp a, $63 + cp $63 ld hl, ItemUseBallText04 jp z, .printText0 ld hl, wEnemyMonHP ;current HP @@ -460,8 +459,7 @@ ItemUseBall: ; d3ad (3:53ad) call ClearSprites call SendNewMonToBox ld hl, ItemUseBallText07 - ld a, [wd7f1] - bit 0, a + CheckEvent EVENT_MET_BILL jr nz, .sendToBox2 ld hl, ItemUseBallText08 .sendToBox2 @@ -540,7 +538,7 @@ ItemUseBicycle: ; d6d7 (3:56d7) jp nz, ItemUseNotTime ld a, [wWalkBikeSurfState] ld [wWalkBikeSurfStateCopy], a - cp a, 2 ; is the player surfing? + cp 2 ; is the player surfing? jp z, ItemUseNotTime dec a ; is player already bicycling? jr nz, .tryToGetOnBike @@ -575,7 +573,7 @@ ItemUseBicycle: ; d6d7 (3:56d7) ItemUseSurfboard: ; d725 (3:5725) ld a, [wWalkBikeSurfState] ld [wWalkBikeSurfStateCopy], a - cp a, 2 ; is the player already surfing? + cp 2 ; is the player already surfing? jr z, .tryToStopSurfing .tryToSurf call IsNextTileShoreOrWater @@ -831,13 +829,13 @@ ItemUseMedicine: ; d8ae (3:58ae) jr z, ItemUseMedicine ; if so, force another choice .checkItemType ld a, [wcf91] - cp a, REVIVE + cp REVIVE jr nc, .healHP ; if it's a Revive or Max Revive - cp a, FULL_HEAL + cp FULL_HEAL jr z, .cureStatusAilment ; if it's a Full Heal - cp a, HP_UP + cp HP_UP jp nc, .useVitamin ; if it's a vitamin or Rare Candy - cp a, FULL_RESTORE + cp FULL_RESTORE jr nc, .healHP ; if it's a Full Restore or one of the potions ; fall through if it's one of the status-specifc healing items .cureStatusAilment @@ -845,19 +843,19 @@ ItemUseMedicine: ; d8ae (3:58ae) add hl, bc ; hl now points to status ld a, [wcf91] lb bc, ANTIDOTE_MSG, 1 << PSN - cp a, ANTIDOTE + cp ANTIDOTE jr z, .checkMonStatus lb bc, BURN_HEAL_MSG, 1 << BRN - cp a, BURN_HEAL + cp BURN_HEAL jr z, .checkMonStatus lb bc, ICE_HEAL_MSG, 1 << FRZ - cp a, ICE_HEAL + cp ICE_HEAL jr z, .checkMonStatus lb bc, AWAKENING_MSG, SLP - cp a, AWAKENING + cp AWAKENING jr z, .checkMonStatus lb bc, PARALYZ_HEAL_MSG, 1 << PAR - cp a, PARLYZ_HEAL + cp PARLYZ_HEAL jr z, .checkMonStatus lb bc, FULL_HEAL_MSG, $ff ; Full Heal .checkMonStatus @@ -899,9 +897,9 @@ ItemUseMedicine: ; d8ae (3:58ae) jr nz, .notFainted .fainted ld a, [wcf91] - cp a, REVIVE + cp REVIVE jr z, .updateInBattleFaintedData - cp a, MAX_REVIVE + cp MAX_REVIVE jr z, .updateInBattleFaintedData jp .healingItemNoEffect @@ -947,9 +945,9 @@ ItemUseMedicine: ; d8ae (3:58ae) .notFainted ld a, [wcf91] - cp a, REVIVE + cp REVIVE jp z, .healingItemNoEffect - cp a, MAX_REVIVE + cp MAX_REVIVE jp z, .healingItemNoEffect .compareCurrentHPToMaxHP push hl @@ -967,7 +965,7 @@ ItemUseMedicine: ; d8ae (3:58ae) jr nz, .notFullHP .fullHP ; if the pokemon's current HP equals its max HP ld a, [wcf91] - cp a, FULL_RESTORE + cp FULL_RESTORE jp nz, .healingItemNoEffect inc hl inc hl @@ -1068,15 +1066,15 @@ ItemUseMedicine: ; d8ae (3:58ae) .notUsingSoftboiled2 ld a, [wcf91] - cp a, SODA_POP + cp SODA_POP ld b, 60 ; Soda Pop heal amount jr z, .addHealAmount ld b, 80 ; Lemonade heal amount jr nc, .addHealAmount - cp a, FRESH_WATER + cp FRESH_WATER ld b, 50 ; Fresh Water heal amount jr z, .addHealAmount - cp a, SUPER_POTION + cp SUPER_POTION ld b, 200 ; Hyper Potion heal amount jr c, .addHealAmount ld b, 50 ; Super Potion heal amount @@ -1103,7 +1101,7 @@ ItemUseMedicine: ; d8ae (3:58ae) ld hl, 33 add hl, de ; hl now points to max HP ld a, [wcf91] - cp a, REVIVE + cp REVIVE jr z, .setCurrentHPToHalfMaxHP ld a, [hld] ld b, a @@ -1115,9 +1113,9 @@ ItemUseMedicine: ; d8ae (3:58ae) sbc b jr nc, .setCurrentHPToMaxHp ; if current HP exceeds max HP after healing ld a, [wcf91] - cp a, HYPER_POTION + cp HYPER_POTION jr c, .setCurrentHPToMaxHp ; if using a Full Restore or Max Potion - cp a, MAX_REVIVE + cp MAX_REVIVE jr z, .setCurrentHPToMaxHp ; if using a Max Revive jr .updateInBattleData @@ -1147,7 +1145,7 @@ ItemUseMedicine: ; d8ae (3:58ae) dec de .doneHealingPartyHP ; done updating the pokemon's current HP in the party data structure ld a, [wcf91] - cp a, FULL_RESTORE + cp FULL_RESTORE jr nz, .updateInBattleData ld bc, -31 add hl, bc @@ -1166,7 +1164,7 @@ ItemUseMedicine: ; d8ae (3:58ae) ld a, [hld] ld [wBattleMonHP + 1], a ld a, [wcf91] - cp a, FULL_RESTORE + cp FULL_RESTORE jr nz, .calculateHPBarCoords xor a ld [wBattleMonStatus], a ; remove the status ailment in the in-battle pokemon data @@ -1193,9 +1191,9 @@ ItemUseMedicine: ; d8ae (3:58ae) pop hl .skipRemovingItem ld a, [wcf91] - cp a, FULL_RESTORE + cp FULL_RESTORE jr c, .playStatusAilmentCuringSound - cp a, FULL_HEAL + cp FULL_HEAL jr z, .playStatusAilmentCuringSound ld a, SFX_HEAL_HP call PlaySoundWaitForCurrent @@ -1211,9 +1209,9 @@ ItemUseMedicine: ; d8ae (3:58ae) ld a, REVIVE_MSG ld [wPartyMenuTypeOrMessageID], a ld a, [wcf91] - cp a, REVIVE + cp REVIVE jr z, .showHealingItemMessage - cp a, MAX_REVIVE + cp MAX_REVIVE jr z, .showHealingItemMessage ld a, POTION_MSG ld [wPartyMenuTypeOrMessageID], a @@ -1269,10 +1267,10 @@ ItemUseMedicine: ; d8ae (3:58ae) pop de pop hl ld a, [wcf91] - cp a, RARE_CANDY + cp RARE_CANDY jp z, .useRareCandy push hl - sub a, HP_UP + sub HP_UP add a ld bc, 17 add hl, bc @@ -1284,7 +1282,7 @@ ItemUseMedicine: ; d8ae (3:58ae) ld a, 10 ld b, a ld a, [hl] ; a = MSB of stat experience of the appropriate stat - cp a, 100 ; is there already at least 25600 (256 * 100) stat experience? + cp 100 ; is there already at least 25600 (256 * 100) stat experience? jr nc, .vitaminNoEffect ; if so, vitamins can't add any more add b ; add 2560 (256 * 10) stat experience jr nc, .noCarry3 ; a carry should be impossible here, so this will always jump @@ -1295,7 +1293,7 @@ ItemUseMedicine: ; d8ae (3:58ae) call .recalculateStats ld hl, VitaminText ld a, [wcf91] - sub a, HP_UP - 1 + sub HP_UP - 1 ld c, a .statNameLoop ; loop to get the address of the name of the stat the vitamin increases dec c @@ -1338,7 +1336,7 @@ ItemUseMedicine: ; d8ae (3:58ae) ld bc, 33 add hl, bc ; hl now points to level ld a, [hl] ; a = level - cp a, MAX_LEVEL + cp MAX_LEVEL jr z, .vitaminNoEffect ; can't raise level above 100 inc a ld [hl], a ; store incremented level @@ -1478,8 +1476,8 @@ BaitRockCommon: ; dd9f (3:5d9f) ld [de], a ; zero escape factor (for bait), zero bait factor (for rock) .randomLoop ; loop until a random number less than 5 is generated call Random - and a, 7 - cp a, 5 + and 7 + cp 5 jr nc, .randomLoop inc a ; increment the random number, giving a range from 1 to 5 inclusive ld b, a @@ -1507,18 +1505,18 @@ ItemUseEscapeRope: ; ddcf (3:5dcf) and a jr nz, .notUsable ld a, [wCurMap] - cp a, AGATHAS_ROOM + cp AGATHAS_ROOM jr z, .notUsable - cp a, BILLS_HOUSE + cp BILLS_HOUSE jr z, .notUsable - cp a, POKEMON_FAN_CLUB + cp POKEMON_FAN_CLUB jr z, .notUsable ld a, [wCurMapTileset] ld b, a ld hl, EscapeRopeTilesets .loop ld a, [hli] - cp a, $ff + cp $ff jr z, .notUsable cp b jr nz, .loop @@ -1528,8 +1526,7 @@ ItemUseEscapeRope: ; ddcf (3:5dcf) call Func_1510 ld hl, wd72e res 4, [hl] - ld hl, wd790 - res 7, [hl] + ResetEvent EVENT_IN_SAFARI_ZONE xor a ld [wNumSafariBalls], a ld [wSafariZoneEntranceCurScript], a @@ -1579,19 +1576,19 @@ ItemUseCardKey: ; de57 (3:de57) ld [wUnusedD71F], a call GetTileAndCoordsInFrontOfPlayer ld a, [GetTileAndCoordsInFrontOfPlayer] ; $4586 - cp a, $18 + cp $18 jr nz, .next0 ld hl, CardKeyTable1 jr .next1 .next0 - cp a, $24 + cp $24 jr nz, .next2 ld hl, CardKeyTable2 jr .next1 .next2 - cp a, $5e + cp $5e jp nz, ItemUseNotTime ld hl, CardKeyTable3 .next1 @@ -1599,7 +1596,7 @@ ItemUseCardKey: ; de57 (3:de57) ld b, a .loop ld a, [hli] - cp a, $ff + cp $ff jp z, ItemUseNotTime cp b jr nz, .nextEntry1 @@ -1736,7 +1733,7 @@ ItemUseXStat: ; df69 (3:df69) push af ; save [wPlayerMoveEffect] push hl ld a, [wcf91] - sub a, X_ATTACK - ATTACK_UP1_EFFECT + sub X_ATTACK - ATTACK_UP1_EFFECT ld [hl], a ; store player move effect call PrintItemUseTextAndRemoveItem ld a, XSTATITEM_ANIM ; X stat item animation ID @@ -1769,10 +1766,9 @@ ItemUsePokeflute: ; dfbd (3:5fbd) ; if not in battle call ItemUseReloadOverworldData ld a, [wCurMap] - cp a, ROUTE_12 + cp ROUTE_12 jr nz, .notRoute12 - ld a, [wd7d8] - bit 7, a + CheckEvent EVENT_BEAT_ROUTE12_SNORLAX jr nz, .noSnorlaxOrPikachuToWakeUp ; if the player hasn't beaten Route 12 Snorlax ld hl, Route12SnorlaxFluteCoords @@ -1780,15 +1776,13 @@ ItemUsePokeflute: ; dfbd (3:5fbd) jr nc, .noSnorlaxOrPikachuToWakeUp ld hl, PlayedFluteHadEffectText call PrintText - ld hl, wd7d8 - set 6, [hl] + SetEvent EVENT_FIGHT_ROUTE12_SNORLAX ret .notRoute12 - cp a, ROUTE_16 + cp ROUTE_16 jr nz, .notRoute16 - ld a, [wd7e0] - bit 1, a + CheckEvent EVENT_BEAT_ROUTE16_SNORLAX jr nz, .noSnorlaxOrPikachuToWakeUp ; if the player hasn't beaten Route 16 Snorlax ld hl, Route16SnorlaxFluteCoords @@ -1796,12 +1790,11 @@ ItemUsePokeflute: ; dfbd (3:5fbd) jr nc, .noSnorlaxOrPikachuToWakeUp ld hl, PlayedFluteHadEffectText call PrintText - ld hl, wd7e0 - set 0, [hl] + SetEvent EVENT_FIGHT_ROUTE16_SNORLAX ret .notRoute16 - cp a, PEWTER_POKECENTER + cp PEWTER_POKECENTER jr nz, .noSnorlaxOrPikachuToWakeUp call CheckPikachuFollowingPlayer jr z, .noSnorlaxOrPikachuToWakeUp @@ -1841,7 +1834,7 @@ ItemUsePokeflute: ; dfbd (3:5fbd) and b ; remove Sleep status ld [hl], a ld a, c - and a, SLP + and SLP jr z, .asm_e063 ld a, $1 ld [wWereAnyMonsAsleep], a @@ -1855,7 +1848,7 @@ ItemUsePokeflute: ; dfbd (3:5fbd) ld hl, PlayedFluteHadEffectText call PrintText ld a, [wLowHealthAlarm] - and a, $80 + and $80 jr nz, .skipMusic call WaitForSoundToFinish ; wait for sound to end callba Music_PokeFluteInBattle ; play in-battle pokeflute music @@ -1880,7 +1873,7 @@ WakeUpEntireParty: ; e094 (3:6094) .loop ld a, [hl] push af - and a, SLP ; is pokemon asleep? + and SLP ; is pokemon asleep? jr z, .notAsleep ld a, 1 ld [wWereAnyMonsAsleep], a ; indicate that a pokemon had to be woken up @@ -1933,7 +1926,7 @@ PlayedFluteHadEffectText: ; e0c4 (3:60c4) call PlayMusic .musicWaitLoop ; wait for music to finish playing ld a, [wChannelSoundIDs + CH2] - cp a, SFX_POKEFLUTE + cp SFX_POKEFLUTE jr z, .musicWaitLoop call PlayDefaultMusic ; start playing normal music again .done @@ -2043,7 +2036,7 @@ FishingInit: ; e182 (3:6182) call IsNextTileShoreOrWater jr nc, .cannotFish ld a, [wWalkBikeSurfState] - cp a, 2 ; Surfing? + cp 2 ; Surfing? jr z, .cannotFish call ItemUseReloadOverworldData ld hl, ItemUseText00 @@ -2130,13 +2123,13 @@ ItemUsePPRestore: ; e1f7 (3:61f7) .usePPItem ld a, [wPPRestoreItem] - cp a, ELIXER + cp ELIXER jp nc, .useElixir ; if Elixir or Max Elixir ld a, $02 ld [wMoveMenuType], a ld hl, RaisePPWhichTechniqueText ld a, [wPPRestoreItem] - cp a, ETHER ; is it a PP Up? + cp ETHER ; is it a PP Up? jr c, .printWhichTechniqueMessage ; if so, print the raise PP message ld hl, RestorePPWhichTechniqueText ; otherwise, print the restore PP message .printWhichTechniqueMessage @@ -2157,13 +2150,13 @@ ItemUsePPRestore: ; e1f7 (3:61f7) call CopyStringToCF4B ; copy name to wcf4b pop hl ld a, [wPPRestoreItem] - cp a, ETHER + cp ETHER jr nc, .useEther ; if Ether or Max Ether .usePPUp ld bc, 21 add hl, bc ld a, [hl] ; move PP - cp a, 3 << 6 ; have 3 PP Ups already been used? + cp 3 << 6 ; have 3 PP Ups already been used? jr c, .PPNotMaxedOut ld hl, PPMaxedOutText call PrintText @@ -2171,7 +2164,7 @@ ItemUsePPRestore: ; e1f7 (3:61f7) .PPNotMaxedOut ld a, [hl] - add a, 1 << 6 ; increase PP Up count by 1 + add 1 << 6 ; increase PP Up count by 1 ld [hl], a ld a, 1 ; 1 PP Up used ld [wd11e], a @@ -2225,13 +2218,13 @@ ItemUsePPRestore: ; e1f7 (3:61f7) ld a, [wMaxPP] ld b, a ld a, [wPPRestoreItem] - cp a, MAX_ETHER + cp MAX_ETHER jr z, .fullyRestorePP ld a, [hl] ; move PP - and a, %00111111 ; lower 6 bit bits store current PP + and %00111111 ; lower 6 bit bits store current PP cp b ; does current PP equal max PP? ret z ; if so, return - add a, 10 ; increase current PP by 10 + add 10 ; increase current PP by 10 ; b holds the max PP amount and b will hold the new PP amount. ; So, if the new amount meets or exceeds the max amount, ; cap the amount to the max amount by leaving b unchanged. @@ -2241,7 +2234,7 @@ ItemUsePPRestore: ; e1f7 (3:61f7) ld b, a .storeNewAmount ld a, [hl] ; move PP - and a, %11000000 ; PP Up counter bits + and %11000000 ; PP Up counter bits add b ld [hl], a ret @@ -2328,10 +2321,10 @@ ItemUseTMHM: ; e374 (3:6374) and a jp nz, ItemUseNotTime ld a, [wcf91] - sub a, TM_01 + sub TM_01 push af jr nc, .skipAdding - add a, 55 ; if item is an HM, add 55 + add 55 ; if item is an HM, add 55 .skipAdding inc a ld [wd11e], a @@ -2428,9 +2421,9 @@ ItemUseTMHM: ; e374 (3:6374) callab IsThisPartymonStarterPikachu_Party jr nc, .notTeachingThunderboltOrThunderToPikachu ld a, [wcf91] - cp a, TM_24 ; are we teaching thunderbolt to the player pikachu? + cp TM_24 ; are we teaching thunderbolt to the player pikachu? jr z, .teachingThunderboltOrThunderToPlayerPikachu - cp a, TM_25 ; are we teaching thunder then? + cp TM_25 ; are we teaching thunder then? jr nz, .notTeachingThunderboltOrThunderToPikachu .teachingThunderboltOrThunderToPlayerPikachu ld a, $5 @@ -2599,7 +2592,7 @@ RestoreBonusPP: ; e54a (3:654a) .loop inc b ld a, b - cp a, 5 ; reached the end of the pokemon's moves? + cp 5 ; reached the end of the pokemon's moves? ret z ; if so, return ld a, [wUsingPPUp] dec a ; using a PP Up? @@ -2611,7 +2604,7 @@ RestoreBonusPP: ; e54a (3:654a) jr nz, .nextMove .skipMenuItemIDCheck ld a, [hl] - and a, %11000000 ; have any PP Ups been used? + and %11000000 ; have any PP Ups been used? call nz, AddBonusPP ; if so, add bonus PP .nextMove inc hl @@ -2638,13 +2631,13 @@ AddBonusPP: ; e586 (3:6586) ld a, [hl] ; move PP ld b, a swap a - and a, %1111 + and %1111 srl a srl a ld c, a ; c = number of PP Ups used .loop ld a, [H_QUOTIENT + 3] - cp a, 8 ; is the amount greater than or equal to 8? + cp 8 ; is the amount greater than or equal to 8? jr c, .addAmount ld a, 7 ; cap the amount at 7 .addAmount @@ -2712,13 +2705,13 @@ GetMaxPP: ; e5bb (3:65bb) push bc ld bc, wPartyMon1PP - wPartyMon1Moves ; PP offset if not player's in-battle pokemon data ld a, [wMonDataLocation] - cp a, 4 ; player's in-battle pokemon? + cp 4 ; player's in-battle pokemon? jr nz, .addPPOffset ld bc, wBattleMonPP - wBattleMonMoves ; PP offset if player's in-battle pokemon data .addPPOffset add hl, bc ld a, [hl] ; a = current PP - and a, %11000000 ; get PP Up count + and %11000000 ; get PP Up count pop bc or b ; place normal max PP in 6 lower bits of a ld h, d @@ -2729,7 +2722,7 @@ GetMaxPP: ; e5bb (3:65bb) ld [wUsingPPUp], a call AddBonusPP ; add bonus PP from PP Ups ld a, [hl] - and a, %00111111 ; mask out the PP Up count + and %00111111 ; mask out the PP Up count ld [wMaxPP], a ; store max PP ret @@ -2777,7 +2770,7 @@ TossItem_: ; e635 (3:6635) ld [wTextBoxID], a call DisplayTextBoxID ; yes/no menu ld a, [wMenuExitMethod] - cp a, CHOSE_SECOND_ITEM + cp CHOSE_SECOND_ITEM pop hl scf ret z ; return if the player chose No @@ -2826,7 +2819,7 @@ IsKeyItem_: ; e6a8 (3:66a8) ld a, $01 ld [wIsKeyItem], a ld a, [wcf91] - cp a, HM_01 ; is the item an HM or TM? + cp HM_01 ; is the item an HM or TM? jr nc, .checkIfItemIsHM ; if the item is not an HM or TM push af diff --git a/engine/menu/start_menu.asm b/engine/menu/start_menu.asm index 8a9ad229..3eeb1c07 100755 --- a/engine/menu/start_menu.asm +++ b/engine/menu/start_menu.asm @@ -1,7 +1,7 @@ DisplayStartMenu:: ; 29d1 (0:29d1) switchbank StartMenu_Pokedex ; also bank for other functions - ld a,[wWalkBikeSurfState] ; walking/biking/surfing - ld [wWalkBikeSurfStateCopy],a + ld a, [wWalkBikeSurfState] ; walking/biking/surfing + ld [wWalkBikeSurfStateCopy], a ld a, $8f ; (SFX_02_3f - SFX_Headers_02) / 3 ; Start menu sound call PlaySound @@ -12,76 +12,73 @@ RedisplayStartMenu_DoNotDrawStartMenu: ; 29e9 (0:29e9) call UpdateSprites .loop call HandleMenuInput - ld b,a + ld b, a .checkIfUpPressed - bit 6,a ; was Up pressed? - jr z,.checkIfDownPressed - ld a,[wCurrentMenuItem] ; menu selection + bit 6, a ; was Up pressed? + jr z, .checkIfDownPressed + ld a, [wCurrentMenuItem] ; menu selection and a - jr nz,.loop - ld a,[wLastMenuItem] + jr nz, .loop + ld a, [wLastMenuItem] and a - jr nz,.loop + jr nz, .loop ; if the player pressed tried to go past the top item, wrap around to the bottom - ld a,[wd74b] - bit 5,a ; does the player have the pokedex? - ld a,6 ; there are 7 menu items with the pokedex, so the max index is 6 - jr nz,.wrapMenuItemId + CheckEvent EVENT_GOT_POKEDEX ; does the player have the pokedex? + ld a, 6 ; there are 7 menu items with the pokedex, so the max index is 6 + jr nz, .wrapMenuItemId dec a ; there are only 6 menu items without the pokedex .wrapMenuItemId - ld [wCurrentMenuItem],a + ld [wCurrentMenuItem], a call EraseMenuCursor jr .loop .checkIfDownPressed - bit 7,a - jr z,.buttonPressed + bit 7, a + jr z, .buttonPressed ; if the player pressed tried to go past the bottom item, wrap around to the top - ld a,[wd74b] - bit 5,a ; does the player have the pokedex? - ld a,[wCurrentMenuItem] - ld c,7 ; there are 7 menu items with the pokedex - jr nz,.checkIfPastBottom + CheckEvent EVENT_GOT_POKEDEX ; does the player have the pokedex? + ld a, [wCurrentMenuItem] + ld c, 7 ; there are 7 menu items with the pokedex + jr nz, .checkIfPastBottom dec c ; there are only 6 menu items without the pokedex .checkIfPastBottom cp c - jr nz,.loop + jr nz, .loop ; the player went past the bottom, so wrap to the top xor a - ld [wCurrentMenuItem],a + ld [wCurrentMenuItem], a call EraseMenuCursor jr .loop .buttonPressed ; A, B, or Start button pressed call PlaceUnfilledArrowMenuCursor - ld a,[wCurrentMenuItem] - ld [wBattleAndStartSavedMenuItem],a ; save current menu selection - ld a,b - and a,%00001010 ; was the Start button or B button pressed? - jp nz,CloseStartMenu + ld a, [wCurrentMenuItem] + ld [wBattleAndStartSavedMenuItem], a ; save current menu selection + ld a, b + and a, %00001010 ; was the Start button or B button pressed? + jp nz, CloseStartMenu call SaveScreenTilesToBuffer2 ; copy background from wTileMap to wTileMapBackup2 - ld a,[wd74b] - bit 5,a ; does the player have the pokedex? - ld a,[wCurrentMenuItem] - jr nz,.displayMenuItem + CheckEvent EVENT_GOT_POKEDEX ; does the player have the pokedex? + ld a, [wCurrentMenuItem] + jr nz, .displayMenuItem inc a ; adjust position to account for missing pokedex menu item .displayMenuItem - cp a,0 - jp z,StartMenu_Pokedex - cp a,1 - jp z,StartMenu_Pokemon - cp a,2 - jp z,StartMenu_Item - cp a,3 - jp z,StartMenu_TrainerInfo - cp a,4 - jp z,StartMenu_SaveReset - cp a,5 - jp z,StartMenu_Option + cp a, 0 + jp z, StartMenu_Pokedex + cp a, 1 + jp z, StartMenu_Pokemon + cp a, 2 + jp z, StartMenu_Item + cp a, 3 + jp z, StartMenu_TrainerInfo + cp a, 4 + jp z, StartMenu_SaveReset + cp a, 5 + jp z, StartMenu_Option ; EXIT falls through to here CloseStartMenu:: ; 2a72 (0:2a72) call Joypad - ld a,[hJoyPressed] - bit 0,a ; was A button newly pressed? - jr nz,CloseStartMenu + ld a, [hJoyPressed] + bit 0, a ; was A button newly pressed? + jr nz, CloseStartMenu call LoadTextBoxTilePatterns jp CloseTextDisplay @@ -168,7 +168,7 @@ ReadJoypad:: ; 01c8 (0:01c8) INCLUDE "home/overworld.asm" CheckForUserInterruption:: ; 10ba (0:10ba) -; Return carry if Up+Select+B, Start or A are pressed in c frames. +; Return carry if Up + Select + B, Start or A are pressed in c frames. ; Used only in the intro and title screen. call DelayFrame @@ -780,7 +780,7 @@ UncompressMonSprite:: ; 1407 (0:1407) ld a, [hli] ld [W_SPRITEINPUTPTR], a ; fetch sprite input pointer ld a, [hl] - ld [W_SPRITEINPUTPTR+1], a + ld [W_SPRITEINPUTPTR + 1], a ; define (by index number) the bank that a pokemon's image is in ; index = Mew, bank 1 ; index = Kabutops fossil, bank $B @@ -1323,14 +1323,13 @@ DisplayPlayerBlackedOutText:: ; 2988 (0:2988) ld a, [wd732] res 5, a ; reset forced to use bike bit ld [wd732], a - ld a, [wd790] - bit 7, a + CheckEvent EVENT_IN_SAFARI_ZONE jr z, .didnotblackoutinsafari xor a ld [wNumSafariBalls], a ld [wSafariSteps], a - ld [wSafariSteps+1], a - ld [wd790], a + ld [wSafariSteps + 1], a + EventFlagAddressa EVENT_IN_SAFARI_ZONE ld [wcf0d], a ld [wSafariZoneEntranceCurScript], a .didnotblackoutinsafari @@ -2131,7 +2130,7 @@ SerialFunction:: ; 2fb7 (0:2fb7) ld a, [wPrinterOpcode] and a ret nz - ld hl, wOverworldMap+650 + ld hl, wOverworldMap + 650 inc [hl] ld a, [hl] cp $6 @@ -2351,7 +2350,7 @@ StoreTrainerHeaderPointer:: ; 30f3 (0:30f3) ld a, h ld [wTrainerHeaderPtr], a ld a, l - ld [wTrainerHeaderPtr+1], a + ld [wTrainerHeaderPtr + 1], a ret ; executes the current map script from the function pointer array provided in hl. @@ -3781,10 +3780,10 @@ CalcStats:: ; 392b (0:392b) .statsLoop inc c call CalcStat - ld a, [H_MULTIPLICAND+1] + ld a, [H_MULTIPLICAND + 1] ld [de], a inc de - ld a, [H_MULTIPLICAND+2] + ld a, [H_MULTIPLICAND + 2] ld [de], a inc de ld a, c @@ -3818,12 +3817,12 @@ CalcStat:: ; 393f (0:393f) .statExpLoop ; calculates ceil(Sqrt(stat exp)) in b xor a ld [H_MULTIPLICAND], a - ld [H_MULTIPLICAND+1], a + ld [H_MULTIPLICAND + 1], a inc b ; increment current stat exp bonus ld a, b cp $ff jr z, .statExpDone - ld [H_MULTIPLICAND+2], a + ld [H_MULTIPLICAND + 2], a ld [H_MULTIPLIER], a call Multiply ld a, [hld] @@ -3912,9 +3911,9 @@ CalcStat:: ; 393f (0:393f) jr nc, .noCarry2 inc d ; da = (Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4 .noCarry2 - ld [H_MULTIPLICAND+2], a + ld [H_MULTIPLICAND + 2], a ld a, d - ld [H_MULTIPLICAND+1], a + ld [H_MULTIPLICAND + 1], a xor a ld [H_MULTIPLICAND], a ld a, [wCurEnemyLVL] @@ -3922,10 +3921,10 @@ CalcStat:: ; 393f (0:393f) call Multiply ; ((Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4) * Level ld a, [H_MULTIPLICAND] ld [H_DIVIDEND], a - ld a, [H_MULTIPLICAND+1] - ld [H_DIVIDEND+1], a - ld a, [H_MULTIPLICAND+2] - ld [H_DIVIDEND+2], a + ld a, [H_MULTIPLICAND + 1] + ld [H_DIVIDEND + 1], a + ld a, [H_MULTIPLICAND + 2] + ld [H_DIVIDEND + 2], a ld a, $64 ld [H_DIVISOR], a ld a, $3 @@ -3937,38 +3936,38 @@ CalcStat:: ; 393f (0:393f) jr nz, .notHPStat ld a, [wCurEnemyLVL] ld b, a - ld a, [H_MULTIPLICAND+2] + ld a, [H_MULTIPLICAND + 2] add b - ld [H_MULTIPLICAND+2], a + ld [H_MULTIPLICAND + 2], a jr nc, .noCarry3 - ld a, [H_MULTIPLICAND+1] + ld a, [H_MULTIPLICAND + 1] inc a - ld [H_MULTIPLICAND+1], a ; HP: (((Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4) * Level) / 100 + Level + ld [H_MULTIPLICAND + 1], a ; HP: (((Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4) * Level) / 100 + Level .noCarry3 - ld a, 10 ; +10 for HP stat + ld a, 10 ; + 10 for HP stat .notHPStat ld b, a - ld a, [H_MULTIPLICAND+2] + ld a, [H_MULTIPLICAND + 2] add b - ld [H_MULTIPLICAND+2], a + ld [H_MULTIPLICAND + 2], a jr nc, .noCarry4 - ld a, [H_MULTIPLICAND+1] + ld a, [H_MULTIPLICAND + 1] inc a ; non-HP: (((Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4) * Level) / 100 + 5 - ld [H_MULTIPLICAND+1], a ; HP: (((Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4) * Level) / 100 + Level + 10 + ld [H_MULTIPLICAND + 1], a ; HP: (((Base + IV) * 2 + ceil(Sqrt(stat exp)) / 4) * Level) / 100 + Level + 10 .noCarry4 - ld a, [H_MULTIPLICAND+1] ; check for overflow (>999) + ld a, [H_MULTIPLICAND + 1] ; check for overflow (>999) cp 999 / $100 + 1 jr nc, .overflow cp 999 / $100 jr c, .noOverflow - ld a, [H_MULTIPLICAND+2] + ld a, [H_MULTIPLICAND + 2] cp 999 % $100 + 1 jr c, .noOverflow .overflow ld a, 999 / $100 ; overflow: cap at 999 - ld [H_MULTIPLICAND+1], a + ld [H_MULTIPLICAND + 1], a ld a, 999 % $100 - ld [H_MULTIPLICAND+2], a + ld [H_MULTIPLICAND + 2], a .noOverflow pop bc pop de diff --git a/home/overworld.asm b/home/overworld.asm index e1312df1..f29cfd51 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -255,8 +255,7 @@ OverworldLoopLessDelay:: ; 0245 (0:0245) jp nz, CheckMapConnections ; it seems like this check will never succeed (the other place where CheckMapConnections is run works) ; walking animation finished call StepCountCheck - ld a, [wd790] - bit 7, a ; in the safari zone? + CheckEvent EVENT_IN_SAFARI_ZONE ; in the safari zone? jr z, .notSafariZone callba SafariZoneCheckSteps ld a, [wSafariZoneGameOver] @@ -288,8 +287,7 @@ OverworldLoopLessDelay:: ; 0245 (0:0245) ld a, [wCurMap] cp CINNABAR_GYM jr nz, .notCinnabarGym - ld hl, wd79b - set 7, [hl] + SetEvent EVENT_2A7 .notCinnabarGym ld hl, wd72e set 5, [hl] diff --git a/scripts/billshouse.asm b/scripts/billshouse.asm index a3a86d74..b288a9fe 100755 --- a/scripts/billshouse.asm +++ b/scripts/billshouse.asm @@ -23,8 +23,7 @@ BillsHouseScript_1e09e: bit 7, [hl] set 7, [hl] ret nz - ld hl, wd7f2 - bit 5, [hl] + CheckEventHL EVENT_MET_BILL_2 jr z, .asm_1e0af jr .asm_1e0b3 diff --git a/scripts/oakslab.asm b/scripts/oakslab.asm index 71e900eb..6648acb1 100755 --- a/scripts/oakslab.asm +++ b/scripts/oakslab.asm @@ -129,8 +129,7 @@ OaksLabScript4: ; 1cbd2 (7:445f) ret OaksLabScript5: ; 1cbfd (7:4bfd) - ld hl, wd74b - set 1, [hl] + SetEvent EVENT_OAK_ASKED_TO_CHOOSE_MON ld a, $fc ld [wJoyIgnore], a ld a, $d @@ -392,8 +391,7 @@ OaksLabScript14: xor a ld [wSpriteStateData1 + 1 * $10 + 9], a predef HealParty - ld hl, wd74b - set 3, [hl] + SetEvent EVENT_BATTLED_RIVAL_IN_OAKS_LAB ld a, $f ld [W_OAKSLABCURSCRIPT], a ret diff --git a/scripts/rockethideout4.asm b/scripts/rockethideout4.asm index 30ed3f24..d0e6f567 100755 --- a/scripts/rockethideout4.asm +++ b/scripts/rockethideout4.asm @@ -266,8 +266,7 @@ RocketHideout4Script13: xor a ld [hJoyHeld], a ld [wJoyIgnore], a - ld hl, wd81b - set 2, [hl] + SetEvent EVENT_BEAT_ROCKET_HIDEOUT_4_TRAINER_0 ld a, $0 call RocketHideout4Script_4551e ret @@ -3403,143 +3403,17 @@ wSecondLockTrashCanIndex:: ; d744 ds 2 -wEventFlags:: -wd747:: ds 3 ; below here are mostly in game flags -wd74a:: ds 1 +wEventFlags:: ; d747 +; below here are mostly in game flags -wd74b:: ; d74b +; d74b ; bit 0: Prof. Oak has lead the player to the north end of his lab ; bit 1: Prof. Oak has asked the player to choose a pokemon ; bit 2: the player and the rival have received their pokemon ; bit 3: the player has battled the rival in Oak's lab ; bit 4: Prof. Oak has given the player 5 pokeballs ; bit 5: received pokedex - ds 1 - -wd74c:: ds 2 -wd74e:: ds 3 -wd751:: ds 1 -wd752:: ds 2 -wd754:: ds 1 -wd755:: ds 5 -wd75a:: ds 1 -wd75b:: ds 3 -wd75e:: ds 1 -wd75f:: ds 5 -wd764:: ds 1 -wd765:: ds 1 -wd766:: ds 1 -wd767:: ds 1 -wd768:: ds 1 -wd769:: ds 3 -wd76c:: ds 5 -wd771:: ds 2 -wd773:: ds 4 -wd777:: ds 1 -wd778:: ds 4 -wd77c:: ds 1 -wd77d:: ds 1 -wd77e:: ds 5 -wd783:: ds 11 -wd78e:: ds 2 -wd790:: ds 2 -wd792:: ds 4 -wd796:: ds 2 -wd798:: ds 2 -wd79a:: ds 1 -wd79b:: ds 1 -wd79c:: ds 5 -wd7a1:: ds 2 -wd7a3:: ds 12 -wd7af:: ds 2 -wd7b1:: ds 2 -wd7b3:: ds 1 -wd7b4:: ds 5 -wd7b9:: ds 4 -wd7bd:: ds 2 -wd7bf:: ds 3 -wd7c2:: ds 1 -wd7c3:: ds 2 -wd7c5:: ds 1 -wd7c6:: ds 3 -wd7c9:: ds 4 -wd7cd:: ds 2 -wd7cf:: ds 2 -wd7d1:: ds 1 -wd7d2:: ds 1 -wd7d3:: ds 2 -wd7d5:: ds 1 -wd7d6:: ds 1 -wd7d7:: ds 1 -wd7d8:: ds 1 -wd7d9:: ds 2 -wd7db:: ds 2 -wd7dd:: ds 2 -wd7df:: ds 1 -wd7e0:: ds 1 -wd7e1:: ds 2 -wd7e3:: ds 2 -wd7e5:: ds 2 -wd7e7:: ds 1 -wd7e8:: ds 1 -wd7e9:: ds 2 -wd7eb:: ds 2 -wd7ed:: ds 1 -wd7ee:: ds 1 -wd7ef:: ds 1 -wd7f0:: ds 1 -wd7f1:: ds 1 -wd7f2:: ds 1 -wd7f3:: ds 2 -wd7f5:: ds 1 -wd7f6:: ds 9 -wd7ff:: ds 4 -wd803:: ds 2 -wd805:: ds 2 -wd807:: ds 2 -wd809:: ds 10 -wd813:: ds 2 -wd815:: ds 1 -wd816:: ds 1 -wd817:: ds 2 -wd819:: ds 2 -wd81b:: ds 10 -wd825:: ds 1 -wd826:: ds 1 -wd827:: ds 1 -wd828:: ds 1 -wd829:: ds 1 -wd82a:: ds 1 -wd82b:: ds 1 -wd82c:: ds 1 -wd82d:: ds 1 -wd82e:: ds 1 -wd82f:: ds 1 -wd830:: ds 1 -wd831:: ds 1 -wd832:: ds 1 -wd833:: ds 1 -wd834:: ds 1 -wd835:: ds 1 -wd836:: ds 1 -wd837:: ds 1 -wd838:: ds 15 -wd847:: ds 2 -wd849:: ds 2 -wd84b:: ds 12 -wd857:: ds 8 -wd85f:: ds 4 -wd863:: ds 1 -wd864:: ds 1 -wd865:: ds 1 -wd866:: ds 1 -wd867:: ds 2 -wd869:: ds 20 -wd87d:: ds 2 -wd87f:: ds 1 -wd880:: ds 1 -wd881:: ds 1 -wd882:: ds 5 + flag_array NUM_EVENT_FLAGS wLinkEnemyTrainerName:: ; d887 ; linked game's trainer name |