summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engine')
-rw-r--r--engine/add_mon.asm (renamed from engine/add_party_mon.asm)177
-rw-r--r--engine/bank3c.asm129
-rw-r--r--engine/bank3d.asm205
-rwxr-xr-xengine/battle/animations.asm168
-rw-r--r--engine/battle/bank3d_battle.asm2
-rw-r--r--engine/battle/battle_transitions.asm30
-rw-r--r--engine/battle/common_text.asm4
-rwxr-xr-xengine/battle/core.asm1943
-rw-r--r--engine/battle/decrement_pp.asm8
-rw-r--r--engine/battle/display_effectiveness.asm4
-rw-r--r--engine/battle/draw_hud_pokeball_gfx.asm2
-rwxr-xr-xengine/battle/end_of_battle.asm2
-rw-r--r--engine/battle/experience.asm8
-rw-r--r--engine/battle/init_battle_variables.asm2
-rw-r--r--engine/battle/moveEffects/conversion_effect.asm2
-rw-r--r--engine/battle/moveEffects/focus_energy_effect.asm6
-rw-r--r--engine/battle/moveEffects/haze_effect.asm10
-rw-r--r--engine/battle/moveEffects/heal_effect.asm2
-rw-r--r--engine/battle/moveEffects/leech_seed_effect.asm4
-rw-r--r--engine/battle/moveEffects/mist_effect.asm4
-rw-r--r--engine/battle/moveEffects/recoil_effect.asm2
-rw-r--r--engine/battle/moveEffects/reflect_light_screen_effect.asm8
-rw-r--r--engine/battle/moveEffects/substitute_effect.asm8
-rw-r--r--engine/battle/moveEffects/transform_effect.asm6
-rwxr-xr-xengine/battle/read_trainer_party.asm80
-rwxr-xr-xengine/battle/safari_zone.asm2
-rw-r--r--engine/battle/save_trainer_name.asm26
-rw-r--r--engine/battle/trainer_ai.asm338
-rw-r--r--engine/bcd.asm66
-rw-r--r--engine/black_out.asm48
-rwxr-xr-xengine/cable_club.asm12
-rw-r--r--engine/display_text_id_init.asm75
-rwxr-xr-xengine/evolution.asm2
-rw-r--r--engine/flag_action.asm (renamed from engine/flag_action_predef.asm)0
-rwxr-xr-xengine/give_pokemon.asm2
-rwxr-xr-xengine/hall_of_fame.asm2
-rwxr-xr-xengine/hidden_object_functions14.asm4
-rwxr-xr-xengine/hidden_object_functions17.asm2
-rwxr-xr-xengine/hidden_object_functions18.asm6
-rwxr-xr-xengine/hidden_object_functions3.asm2
-rwxr-xr-xengine/hidden_object_functions7.asm12
-rwxr-xr-xengine/in_game_trades.asm152
-rwxr-xr-xengine/intro.asm34
-rw-r--r--engine/items/inventory.asm151
-rwxr-xr-xengine/items/items.asm588
-rwxr-xr-xengine/learn_move.asm8
-rwxr-xr-xengine/load_pokedex_tiles.asm8
-rw-r--r--engine/menu/bills_pc.asm4
-rw-r--r--engine/menu/diploma.asm (renamed from engine/menu/diploma_1.asm)0
-rw-r--r--engine/menu/draw_badges.asm (renamed from engine/draw_badges.asm)0
-rw-r--r--engine/menu/draw_start_menu.asm87
-rw-r--r--engine/menu/link_menu.asm2
-rwxr-xr-xengine/menu/main_menu.asm146
-rwxr-xr-xengine/menu/naming_screen.asm6
-rwxr-xr-xengine/menu/oaks_pc.asm3
-rwxr-xr-xengine/menu/party_menu.asm208
-rwxr-xr-xengine/menu/pc.asm16
-rwxr-xr-xengine/menu/pokedex.asm18
-rwxr-xr-xengine/menu/prize_menu.asm86
-rwxr-xr-xengine/menu/start_menu.asm14
-rwxr-xr-xengine/menu/start_sub_menus.asm558
-rwxr-xr-xengine/menu/status_screen.asm7
-rw-r--r--engine/menu/swap_items.asm180
-rw-r--r--engine/menu/text_box.asm (renamed from engine/menu/text_ids2.asm)122
-rw-r--r--engine/menu/text_ids1.asm163
-rwxr-xr-xengine/menu/vending_machine.asm3
-rw-r--r--engine/move_mon.asm172
-rwxr-xr-xengine/oak_speech.asm126
-rw-r--r--engine/overworld/boulders.asm94
-rwxr-xr-xengine/overworld/cable_club_npc.asm3
-rwxr-xr-xengine/overworld/card_key.asm2
-rw-r--r--engine/overworld/check_player_state.asm236
-rw-r--r--engine/overworld/clear_variables.asm (renamed from engine/overworld/clear_loadmapdata_vars.asm)10
-rwxr-xr-xengine/overworld/elevator.asm2
-rw-r--r--engine/overworld/field_move_messages.asm57
-rw-r--r--engine/overworld/get_coords_tile_in_front_of_player.asm87
-rwxr-xr-xengine/overworld/hidden_items.asm5
-rw-r--r--engine/overworld/item.asm2
-rw-r--r--engine/overworld/load_wild_data.asm33
-rwxr-xr-xengine/overworld/map_sprites.asm14
-rw-r--r--engine/overworld/movement.asm24
-rwxr-xr-xengine/overworld/npc_movement.asm2
-rwxr-xr-xengine/overworld/npc_movement_2.asm2
-rwxr-xr-xengine/overworld/oaks_aide.asm2
-rw-r--r--engine/overworld/player_state.asm456
-rw-r--r--engine/overworld/poison.asm (renamed from engine/overworld/step_functions.asm)6
-rwxr-xr-xengine/overworld/pokecenter.asm4
-rwxr-xr-xengine/overworld/pokemart.asm228
-rw-r--r--engine/overworld/print_safari_steps.asm36
-rw-r--r--engine/overworld/push_boulder.asm (renamed from engine/overworld/try_pushing_boulder.asm)0
-rw-r--r--engine/overworld/set_blackout_map.asm6
-rw-r--r--engine/overworld/tileset_header.asm (renamed from engine/overworld/load_tileset_header.asm)0
-rw-r--r--engine/overworld/update_map.asm (renamed from engine/overworld/replace_tile_block.asm)0
-rw-r--r--engine/overworld/wild_mons.asm33
-rwxr-xr-xengine/palettes.asm8
-rw-r--r--engine/pathfinding.asm (renamed from engine/overworld/npc_pathfinding.asm)0
-rwxr-xr-xengine/pikachu_emotions.asm4
-rwxr-xr-xengine/pikachu_follow.asm34
-rwxr-xr-xengine/pikachu_pcm.asm8
-rwxr-xr-xengine/pikachu_pic_animation.asm2
-rwxr-xr-xengine/pokedex_rating.asm4
-rwxr-xr-xengine/predefs.asm2
-rw-r--r--engine/predefsA.asm2
-rwxr-xr-xengine/save.asm54
-rwxr-xr-xengine/slot_machine.asm5
-rw-r--r--engine/special_warps.asm (renamed from engine/overworld/special_warps.asm)32
-rwxr-xr-xengine/surfing_minigame.asm6
-rw-r--r--engine/test_battle.asm45
-rwxr-xr-xengine/town_map.asm2
-rwxr-xr-xengine/trade2.asm33
-rwxr-xr-xengine/yellow_intro.asm4
111 files changed, 3978 insertions, 3888 deletions
diff --git a/engine/add_party_mon.asm b/engine/add_mon.asm
index 1aa6bd16..40b776d4 100644
--- a/engine/add_party_mon.asm
+++ b/engine/add_mon.asm
@@ -343,3 +343,180 @@ _AddEnemyMonToPlayerParty:
call FlagAction ; add to seen pokemon
and a
ret ; return success
+
+_MoveMon:
+ ld a, [wMoveMonType]
+ and a ; BOX_TO_PARTY
+ jr z, .checkPartyMonSlots
+ cp DAYCARE_TO_PARTY
+ jr z, .checkPartyMonSlots
+ cp PARTY_TO_DAYCARE
+ ld hl, wDayCareMon
+ jr z, .findMonDataSrc
+ ; else it's PARTY_TO_BOX
+ ld hl, wNumInBox
+ ld a, [hl]
+ cp MONS_PER_BOX
+ jr nz, .partyOrBoxNotFull
+ jr .boxFull
+.checkPartyMonSlots
+ ld hl, wPartyCount
+ ld a, [hl]
+ cp PARTY_LENGTH
+ jr nz, .partyOrBoxNotFull
+.boxFull
+ scf
+ ret
+.partyOrBoxNotFull
+ inc a
+ ld [hl], a ; increment number of mons in party/box
+ ld c, a
+ ld b, 0
+ add hl, bc
+ ld a, [wMoveMonType]
+ cp DAYCARE_TO_PARTY
+ ld a, [wDayCareMon]
+ jr z, .copySpecies
+ ld a, [wcf91]
+.copySpecies
+ ld [hli], a ; write new mon ID
+ ld [hl], $ff ; write new sentinel
+.findMonDataDest
+ ld a, [wMoveMonType]
+ dec a
+ ld hl, wPartyMons
+ ld bc, wPartyMon2 - wPartyMon1 ; $2c
+ ld a, [wPartyCount]
+ jr nz, .addMonOffset
+ ; if it's PARTY_TO_BOX
+ ld hl, wBoxMons
+ ld bc, wBoxMon2 - wBoxMon1 ; $21
+ ld a, [wNumInBox]
+.addMonOffset
+ dec a
+ call AddNTimes
+.findMonDataSrc
+ push hl
+ ld e, l
+ ld d, h
+ ld a, [wMoveMonType]
+ and a
+ ld hl, wBoxMons
+ ld bc, wBoxMon2 - wBoxMon1 ; $21
+ jr z, .addMonOffset2
+ cp DAYCARE_TO_PARTY
+ ld hl, wDayCareMon
+ jr z, .copyMonData
+ ld hl, wPartyMons
+ ld bc, wPartyMon2 - wPartyMon1 ; $2c
+.addMonOffset2
+ ld a, [wWhichPokemon]
+ call AddNTimes
+.copyMonData
+ push hl
+ push de
+ ld bc, wBoxMon2 - wBoxMon1
+ call CopyData
+ pop de
+ pop hl
+ ld a, [wMoveMonType]
+ and a ; BOX_TO_PARTY
+ jr z, .findOTdest
+ cp DAYCARE_TO_PARTY
+ jr z, .findOTdest
+ ld bc, wBoxMon2 - wBoxMon1
+ add hl, bc
+ ld a, [hl] ; hl = Level
+ inc de
+ inc de
+ inc de
+ ld [de], a ; de = BoxLevel
+.findOTdest
+ ld a, [wMoveMonType]
+ cp PARTY_TO_DAYCARE
+ ld de, wDayCareMonOT
+ jr z, .findOTsrc
+ dec a
+ ld hl, wPartyMonOT
+ ld a, [wPartyCount]
+ jr nz, .addOToffset
+ ld hl, wBoxMonOT
+ ld a, [wNumInBox]
+.addOToffset
+ dec a
+ call SkipFixedLengthTextEntries
+ ld d, h
+ ld e, l
+.findOTsrc
+ ld hl, wBoxMonOT
+ ld a, [wMoveMonType]
+ and a
+ jr z, .addOToffset2
+ ld hl, wDayCareMonOT
+ cp DAYCARE_TO_PARTY
+ jr z, .copyOT
+ ld hl, wPartyMonOT
+.addOToffset2
+ ld a, [wWhichPokemon]
+ call SkipFixedLengthTextEntries
+.copyOT
+ ld bc, NAME_LENGTH
+ call CopyData
+ ld a, [wMoveMonType]
+.findNickDest
+ cp PARTY_TO_DAYCARE
+ ld de, wDayCareMonName
+ jr z, .findNickSrc
+ dec a
+ ld hl, wPartyMonNicks
+ ld a, [wPartyCount]
+ jr nz, .addNickOffset
+ ld hl, wBoxMonNicks
+ ld a, [wNumInBox]
+.addNickOffset
+ dec a
+ call SkipFixedLengthTextEntries
+ ld d, h
+ ld e, l
+.findNickSrc
+ ld hl, wBoxMonNicks
+ ld a, [wMoveMonType]
+ and a
+ jr z, .addNickOffset2
+ ld hl, wDayCareMonName
+ cp DAYCARE_TO_PARTY
+ jr z, .copyNick
+ ld hl, wPartyMonNicks
+.addNickOffset2
+ ld a, [wWhichPokemon]
+ call SkipFixedLengthTextEntries
+.copyNick
+ ld bc, NAME_LENGTH
+ call CopyData
+ pop hl
+ ld a, [wMoveMonType]
+ cp PARTY_TO_BOX
+ jr z, .done
+ cp PARTY_TO_DAYCARE
+ jr z, .done
+ push hl
+ srl a
+ add $2
+ ld [wMonDataLocation], a
+ call LoadMonData
+ callba CalcLevelFromExperience
+ ld a, d
+ ld [wCurEnemyLVL], a
+ pop hl
+ ld bc, wBoxMon2 - wBoxMon1
+ add hl, bc
+ ld [hli], a
+ ld d, h
+ ld e, l
+ ld bc, -18
+ add hl, bc
+ ld b, $1
+ call CalcStats
+.done
+ and a
+ ret
diff --git a/engine/bank3c.asm b/engine/bank3c.asm
index 10f7ffdd..9c0e281f 100644
--- a/engine/bank3c.asm
+++ b/engine/bank3c.asm
@@ -1,54 +1,7 @@
INCLUDE "engine/pikachu_pcm.asm"
INCLUDE "engine/overworld/advance_player_sprite.asm"
-ResetStatusAndHalveMoneyOnBlackout:
-; Reset player status on blackout.
- xor a
- ld [wd435], a
- xor a ; gamefreak copypasting functions (double xor a)
- ld [wBattleResult], a
- ld [wWalkBikeSurfState], a
- ld [wIsInBattle], a
- ld [wMapPalOffset], a
- ld [wNPCMovementScriptFunctionNum], a
- ld [hJoyHeld], a
- ld [wNPCMovementScriptPointerTableNum], a
- ld [wFlags_0xcd60], a
-
- ld [hMoney], a
- ld [hMoney + 1], a
- ld [hMoney + 2], a
- call HasEnoughMoney
- jr c, .lostmoney ; never happens
-
- ; Halve the player's money.
- ld a, [wPlayerMoney]
- ld [hMoney], a
- ld a, [wPlayerMoney + 1]
- ld [hMoney + 1], a
- ld a, [wPlayerMoney + 2]
- ld [hMoney + 2], a
- xor a
- ld [hDivideBCDDivisor], a
- ld [hDivideBCDDivisor + 1], a
- ld a, 2
- ld [hDivideBCDDivisor + 2], a
- predef DivideBCDPredef3
- ld a, [hDivideBCDQuotient]
- ld [wPlayerMoney], a
- ld a, [hDivideBCDQuotient + 1]
- ld [wPlayerMoney + 1], a
- ld a, [hDivideBCDQuotient + 2]
- ld [wPlayerMoney + 2], a
-
-.lostmoney
- ld hl, wd732
- set 2, [hl]
- res 3, [hl]
- set 6, [hl]
- ld a, %11111111
- ld [wJoyIgnore], a
- predef_jump HealParty
+INCLUDE "engine/black_out.asm"
SetMapSpecificScriptFlagsOnMapReload:
ld a, [wCurMap]
@@ -85,17 +38,17 @@ SetMapSpecificScriptFlagsOnMapReload:
db SILPH_CO_9F
db SILPH_CO_10F
db SILPH_CO_11F
- db MANSION_2
- db MANSION_3
- db MANSION_4
- db MANSION_1
+ db POKEMON_MANSION_2F
+ db POKEMON_MANSION_3F
+ db POKEMON_MANSION_B1F
+ db POKEMON_MANSION_1F
db CINNABAR_GYM
db GAME_CORNER
- db ROCKET_HIDEOUT_1
- db ROCKET_HIDEOUT_4
- db VICTORY_ROAD_3
- db VICTORY_ROAD_1
- db VICTORY_ROAD_2
+ db ROCKET_HIDEOUT_B1F
+ db ROCKET_HIDEOUT_B4F
+ db VICTORY_ROAD_3F
+ db VICTORY_ROAD_1F
+ db VICTORY_ROAD_2F
db LANCES_ROOM
db LORELEIS_ROOM
db BRUNOS_ROOM
@@ -200,37 +153,37 @@ NurseChanseyText:
db "@"
INCLUDE "engine/HoF_room_pc.asm"
-INCLUDE "scripts/viridiancity2.asm"
-INCLUDE "scripts/vermilioncity2.asm"
-INCLUDE "scripts/celadoncity2.asm"
-INCLUDE "scripts/route1_2.asm"
-INCLUDE "scripts/route22_2.asm"
-INCLUDE "scripts/redshouse1f2.asm"
-INCLUDE "scripts/oakslab2.asm"
-INCLUDE "scripts/school2.asm"
-INCLUDE "scripts/museum1f2.asm"
-INCLUDE "scripts/pewterpokecenter2.asm"
-INCLUDE "scripts/pokemontower2_2.asm"
-INCLUDE "scripts/celadonmart3_2.asm"
-INCLUDE "scripts/celadonmansion1_2.asm"
-INCLUDE "scripts/celadonmansion3_2.asm"
-INCLUDE "scripts/celadongamecorner2.asm"
-INCLUDE "scripts/celadondiner2.asm"
-INCLUDE "scripts/safarizoneentrance2.asm"
-INCLUDE "scripts/cinnabargym3.asm"
-INCLUDE "scripts/mtmoonpokecenter2.asm"
-
-INCLUDE "data/mapHeaders/beach_house.asm"
-INCLUDE "scripts/beach_house.asm"
-BeachHouseBlockdata:
-INCBIN "maps/beach_house.blk"
-INCLUDE "data/mapObjects/beach_house.asm"
-
-INCLUDE "scripts/beach_house2.asm"
-INCLUDE "scripts/billshouse2.asm"
-INCLUDE "scripts/viridianforest2.asm"
-INCLUDE "scripts/ssanne9_2.asm"
-INCLUDE "scripts/silphco11_2.asm"
+INCLUDE "scripts/ViridianCity2.asm"
+INCLUDE "scripts/VermilionCity2.asm"
+INCLUDE "scripts/CeladonCity2.asm"
+INCLUDE "scripts/Route1_2.asm"
+INCLUDE "scripts/Route22_2.asm"
+INCLUDE "scripts/RedsHouse1F2.asm"
+INCLUDE "scripts/OaksLab2.asm"
+INCLUDE "scripts/ViridianSchoolHouse2.asm"
+INCLUDE "scripts/Museum1F2.asm"
+INCLUDE "scripts/PewterPokecenter2.asm"
+INCLUDE "scripts/PokemonTower2F_2.asm"
+INCLUDE "scripts/CeladonMart3F_2.asm"
+INCLUDE "scripts/CeladonMansion1F_2.asm"
+INCLUDE "scripts/CeladonMansion3F_2.asm"
+INCLUDE "scripts/GameCorner2.asm"
+INCLUDE "scripts/CeladonDiner2.asm"
+INCLUDE "scripts/SafariZoneGate2.asm"
+INCLUDE "scripts/CinnabarGym3.asm"
+INCLUDE "scripts/MtMoonPokecenter2.asm"
+
+INCLUDE "data/mapHeaders/BeachHouse.asm"
+INCLUDE "scripts/BeachHouse.asm"
+BeachHouse_Blocks:
+INCBIN "maps/BeachHouse.blk"
+INCLUDE "data/mapObjects/BeachHouse.asm"
+
+INCLUDE "scripts/BeachHouse2.asm"
+INCLUDE "scripts/BillsHouse2.asm"
+INCLUDE "scripts/ViridianForest2.asm"
+INCLUDE "scripts/SSAnne2FRooms_2.asm"
+INCLUDE "scripts/SilphCo11F_2.asm"
INCLUDE "engine/overworld/hidden_objects.asm"
INCLUDE "engine/vermilion_gym_trash_cans.asm"
diff --git a/engine/bank3d.asm b/engine/bank3d.asm
index b37bdd00..0cfdea08 100644
--- a/engine/bank3d.asm
+++ b/engine/bank3d.asm
@@ -435,210 +435,9 @@ HandleMenuInputPokemonSelectionDouble:
ld [wLastMenuItem], a
ret
-PrintStrengthTxt:
- ld hl, wd728
- set 0, [hl]
- ld hl, Text_f5b17
- call PrintText
- ld hl, Text_f5b28
- jp PrintText
-
-Text_f5b17:
- TX_FAR _UsedStrengthText
- TX_ASM
- ld a, [wcf91]
- call PlayCry
- call Delay3
- jp TextScriptEnd
-
-Text_f5b28:
- TX_FAR _CanMoveBouldersText
- db "@"
-
-IsSurfingAllowed:
-; Returns whether surfing is allowed in bit 1 of wd728.
-; Surfing isn't allowed on the Cycling Road or in the lowest level of the
-; Seafoam Islands before the current has been slowed with boulders.
- ld hl, wd728
- set 1, [hl]
- ld a, [wd732]
- bit 5, a
- jr nz, .forcedToRideBike
- ld a, [wCurMap]
- cp SEAFOAM_ISLANDS_5
- ret nz
- CheckBothEventsSet EVENT_SEAFOAM4_BOULDER1_DOWN_HOLE, EVENT_SEAFOAM4_BOULDER2_DOWN_HOLE
- ret z
- ld hl, CoordsData_f5b64
- call ArePlayerCoordsInArray
- ret nc
- ld hl, wd728
- res 1, [hl]
- ld hl, CurrentTooFastText
- jp PrintText
-.forcedToRideBike
- ld hl, wd728
- res 1, [hl]
- ld hl, CyclingIsFunText
- jp PrintText
-
-CoordsData_f5b64:
- db 11, 07
- db $ff
-
-CurrentTooFastText:
- TX_FAR _CurrentTooFastText
- db "@"
-
-CyclingIsFunText:
- TX_FAR _CyclingIsFunText
- db "@"
-
-AddItemToInventory_:
- ld a, [wItemQuantity] ; a = item quantity
- push af
- push bc
- push de
- push hl
- push hl
- ld d, PC_ITEM_CAPACITY ; how many items the PC can hold
- ld a, wNumBagItems & $FF
- cp l
- jr nz, .checkIfInventoryFull
- ld a, wNumBagItems >> 8
- cp h
- jr nz, .checkIfInventoryFull
-; if the destination is the bag
- ld d, BAG_ITEM_CAPACITY ; how many items the bag can hold
-.checkIfInventoryFull
- ld a, [hl]
- sub d
- ld d, a
- ld a, [hli]
- and a
- jr z, .addNewItem
-.notAtEndOfInventory
- ld a, [hli]
- ld b, a ; b = ID of current item in table
- ld a, [wcf91] ; a = ID of item being added
- cp b ; does the current item in the table match the item being added?
- jp z, .increaseItemQuantity ; if so, increase the item's quantity
- inc hl
-.loop
- ld a, [hl]
- cp a, $ff ; is it the end of the table?
- jr nz, .notAtEndOfInventory
-.addNewItem ; add an item not yet in the inventory
- pop hl
- ld a, d
- and a ; is there room for a new item slot?
- jr z, .done
-; if there is room
- inc [hl] ; increment the number of items in the inventory
- ld a, [hl] ; the number of items will be the index of the new item
- add a
- dec a
- ld c, a
- ld b, 0
- add hl, bc ; hl = address to store the item
- ld a, [wcf91]
- ld [hli], a ; store item ID
- ld a, [wItemQuantity]
- ld [hli], a ; store item quantity
- ld [hl], $ff ; store terminator
- jp .success
-.increaseItemQuantity ; increase the quantity of an item already in the inventory
- ld a, [wItemQuantity]
- ld b, a ; b = quantity to add
- ld a, [hl] ; a = existing item quantity
- add b ; a = new item quantity
- cp a, 100
- jp c, .storeNewQuantity ; if the new quantity is less than 100, store it
-; if the new quantity is greater than or equal to 100,
-; try to max out the current slot and add the rest in a new slot
- sub a, 99
- ld [wItemQuantity], a ; a = amount left over (to put in the new slot)
- ld a, d
- and a ; is there room for a new item slot?
- jr z, .increaseItemQuantityFailed
-; if so, store 99 in the current slot and store the rest in a new slot
- ld a, 99
- ld [hli], a
- jp .loop
-.increaseItemQuantityFailed
- pop hl
- and a
- jr .done
-.storeNewQuantity
- ld [hl], a
- pop hl
-.success
- scf
-.done
- pop hl
- pop de
- pop bc
- pop bc
- ld a, b
- ld [wItemQuantity], a ; restore the initial value from when the function was called
- ret
+INCLUDE "engine/overworld/field_move_messages.asm"
-; function to remove an item (in varying quantities) from the player's bag or PC box
-; INPUT:
-; hl = address of inventory (either wNumBagItems or wNumBoxItems)
-; [wWhichPokemon] = index (within the inventory) of the item to remove
-; [wItemQuantity] = quantity to remove
-RemoveItemFromInventory_:
- push hl
- inc hl
- ld a, [wWhichPokemon] ; index (within the inventory) of the item being removed
- add a
- add l
- ld l, a
- jr nc, .noCarry
- inc h
-.noCarry
- inc hl
- ld a, [wItemQuantity] ; quantity being removed
- ld e, a
- ld a, [hl] ; a = current quantity
- sub e
- ld [hld], a ; store new quantity
- ld [wMaxItemQuantity], a
- and a
- jr nz, .skipMovingUpSlots
-; if the remaining quantity is 0,
-; remove the emptied item slot and move up all the following item slots
-.moveSlotsUp
- ld e, l
- ld d, h
- inc de
- inc de ; de = address of the slot following the emptied one
-.loop ; loop to move up the following slots
- ld a, [de]
- inc de
- ld [hli], a
- cp a, $ff
- jr nz, .loop
-; update menu info
- xor a
- ld [wListScrollOffset], a
- ld [wCurrentMenuItem], a
- ld [wBagSavedMenuItem], a
- ld [wSavedListScrollOffset], a
- pop hl
- ld a, [hl] ; a = number of items in inventory
- dec a ; decrement the number of items
- ld [hl], a ; store new number of items
- ld [wListCount], a
- cp a, 2
- jr c, .done
- ld [wMaxMenuItem], a
- jr .done
-.skipMovingUpSlots
- pop hl
-.done
- ret
+INCLUDE "engine/items/inventory.asm"
TrainerInfoTextBoxTileGraphics: INCBIN "gfx/trainer_info.2bpp"
TrainerInfoTextBoxTileGraphicsEnd:
diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm
index 629aa8cd..de1e67b9 100755
--- a/engine/battle/animations.asm
+++ b/engine/battle/animations.asm
@@ -115,7 +115,7 @@ DrawFrameBlock:
.flipHorizontalTranslateDown
ld a, [wBaseCoordY]
add [hl]
- add a, 40 ; translate Y coordinate downwards
+ add 40 ; translate Y coordinate downwards
ld [de], a ; store Y
inc hl
inc de
@@ -134,7 +134,7 @@ DrawFrameBlock:
inc hl
inc de
ld a, [hli]
- add a, $31 ; base tile ID for battle animations
+ add $31 ; base tile ID for battle animations
ld [de], a ; store tile ID
inc de
ld a, [hli]
@@ -159,18 +159,18 @@ DrawFrameBlock:
jp nz, .loop ; go back up if there are more tiles to draw
.afterDrawingTiles
ld a, [wFBMode]
- cp a, 2
+ cp 2
jr z, .advanceFrameBlockDestAddr; skip delay and don't clean OAM buffer
ld a, [wSubAnimFrameDelay]
ld c, a
call DelayFrames
ld a, [wFBMode]
- cp a, 3
+ cp 3
jr z, .advanceFrameBlockDestAddr ; skip cleaning OAM buffer
- cp a, 4
+ cp 4
jr z, .done ; skip cleaning OAM buffer and don't advance the frame block destination address
ld a, [wAnimationID]
- cp a, GROWL
+ cp GROWL
jr z, .resetFrameBlockDestAddr
call AnimationCleanOAM
.resetFrameBlockDestAddr
@@ -204,9 +204,9 @@ PlayAnimation:
ld l, a
.animationLoop
ld a, [hli]
- cp a, $FF
+ cp $FF
jr z, .AnimationOver
- cp a, $C0 ; is this subanimation or a special effect?
+ cp $C0 ; is this subanimation or a special effect?
jr c, .playSubanimation
.doSpecialEffect
ld c, a
@@ -221,7 +221,7 @@ PlayAnimation:
jr .searchSpecialEffectTableLoop
.foundMatch
ld a, [hli]
- cp a, $FF ; is there a sound to play?
+ cp $FF ; is there a sound to play?
jr z, .skipPlayingSound
ld [wAnimSoundID], a ; store sound
push hl
@@ -243,7 +243,7 @@ PlayAnimation:
jp hl ; jump to special effect function
.playSubanimation
ld c, a
- and a, %00111111
+ and %00111111
ld [wSubAnimFrameDelay], a
xor a
sla c
@@ -296,11 +296,11 @@ LoadSubanimation:
ld d, a ; de = address of subanimation
ld a, [de]
ld b, a
- and a, 31
+ and 31
ld [wSubAnimCounter], a ; number of frame blocks
ld a, b
- and a, %11100000
- cp a, 5 << 5 ; is subanimation type 5?
+ and %11100000
+ cp 5 << 5 ; is subanimation type 5?
jr nz, .isNotType5
.isType5
call GetSubanimationTransform2
@@ -312,7 +312,7 @@ LoadSubanimation:
srl a
swap a
ld [wSubAnimTransform], a
- cp a, 4 ; is the animation reversed?
+ cp 4 ; is the animation reversed?
ld hl, 0
jr nz, .storeSubentryAddr
; if the animation is reversed, then place the initial subentry address at the end of the list of subentries
@@ -410,7 +410,7 @@ MoveAnimation:
jr z, .animationFinished
; if throwing a Poké Ball, skip the regular animation code
- cp a, TOSS_ANIM
+ cp TOSS_ANIM
jr nz, .moveAnimation
ld de, .animationFinished
push de
@@ -453,11 +453,11 @@ ShareMoveAnimations:
ld a, [wAnimationID]
- cp a, AMNESIA
+ cp AMNESIA
ld b, CONF_ANIM
jr z, .replaceAnim
- cp a, REST
+ cp REST
ld b, SLP_ANIM
ret nz
@@ -596,7 +596,7 @@ WriteLowerByteOfBGMapAndEnableBGTransfer:
PlaySubanimation:
ld a, [wAnimSoundID]
- cp a, $FF
+ cp $FF
jr z, .skipPlayingSound
call GetMoveSound
call PlaySound
@@ -648,7 +648,7 @@ PlaySubanimation:
ld a, [wSubAnimSubEntryAddr]
ld l, a
ld a, [wSubAnimTransform]
- cp a, 4 ; is the animation reversed?
+ cp 4 ; is the animation reversed?
ld bc, 3
jr nz, .nextSubanimationSubentry
ld bc, -3
@@ -775,34 +775,34 @@ AnimationIdSpecialEffects:
DoBallTossSpecialEffects:
ld a, [wcf91]
- cp a, 3 ; is it a Master Ball or Ultra Ball?
+ cp 3 ; is it a Master Ball or Ultra Ball?
jr nc, .skipFlashingEffect
.flashingEffect ; do a flashing effect if it's Master Ball or Ultra Ball
ld a, [rOBP0]
- xor a, %00111100 ; complement colors 1 and 2
+ xor %00111100 ; complement colors 1 and 2
ld [rOBP0], a
call UpdateGBCPal_OBP0
.skipFlashingEffect
ld a, [wSubAnimCounter]
- cp a, 11 ; is it the beginning of the subanimation?
+ cp 11 ; is it the beginning of the subanimation?
jr nz, .skipPlayingSound
; if it is the beginning of the subanimation, play a sound
ld a, SFX_BALL_TOSS
call PlaySound
.skipPlayingSound
ld a, [wIsInBattle]
- cp a, 02 ; is it a trainer battle?
+ cp 02 ; is it a trainer battle?
jr z, .isTrainerBattle
ld a, [wd11e]
- cp a, $10 ; is the enemy pokemon the Ghost Marowak?
+ cp $10 ; is the enemy pokemon the Ghost Marowak?
ret nz
; if the enemy pokemon is the Ghost Marowak, make it dodge during the last 3 frames
ld a, [wSubAnimCounter]
- cp a, 3
+ cp 3
jr z, .moveGhostMarowakLeft
- cp a, 2
+ cp 2
jr z, .moveGhostMarowakLeft
- cp a, 1
+ cp 1
ret nz
.moveGhostMarowakLeft
coord hl, 17, 0
@@ -822,7 +822,7 @@ DoBallTossSpecialEffects:
ret
.isTrainerBattle ; if it's a trainer battle, shorten the animation by one frame
ld a, [wSubAnimCounter]
- cp a, 3
+ cp 3
ret nz
dec a
ld [wSubAnimCounter], a
@@ -830,7 +830,7 @@ DoBallTossSpecialEffects:
DoBallShakeSpecialEffects:
ld a, [wSubAnimCounter]
- cp a, 4 ; is it the beginning of a shake?
+ cp 4 ; is it the beginning of a shake?
jr nz, .skipPlayingSound
; if it is the beginning of a shake, play a sound and wait 2/3 of a second
ld a, SFX_TINK
@@ -864,21 +864,21 @@ DoBallShakeSpecialEffects:
; plays a sound after the second frame of the poof animation
DoPoofSpecialEffects:
ld a, [wSubAnimCounter]
- cp a, 5
+ cp 5
ret nz
ld a, SFX_BALL_POOF
jp PlaySound
DoRockSlideSpecialEffects:
ld a, [wSubAnimCounter]
- cp a, 12
+ cp 12
ret nc
- cp a, 8
+ cp 8
jr nc, .shakeScreen
- cp a, 1
+ cp 1
jp z, AnimationFlashScreen ; if it's the end of the subanimation, flash the screen
ret
-; if the subaninmation counter is between 8 and 11, shake the screen horizontally and vertically
+; if the subanimation counter is between 8 and 11, shake the screen horizontally and vertically
.shakeScreen
ld b, 1
predef PredefShakeScreenHorizontally ; shake horizontally
@@ -887,21 +887,21 @@ DoRockSlideSpecialEffects:
FlashScreenEveryEightFrameBlocks:
ld a, [wSubAnimCounter]
- and a, 7 ; is the subanimation counter exactly 8?
+ and 7 ; is the subanimation counter exactly 8?
call z, AnimationFlashScreen ; if so, flash the screen
ret
; flashes the screen if the subanimation counter is divisible by 4
FlashScreenEveryFourFrameBlocks:
ld a, [wSubAnimCounter]
- and a, 3
+ and 3
call z, AnimationFlashScreen
ret
; used for Explosion and Selfdestruct
DoExplodeSpecialEffects:
ld a, [wSubAnimCounter]
- cp a, 1 ; is it the end of the subanimation?
+ cp 1 ; is it the end of the subanimation?
jr nz, FlashScreenEveryFourFrameBlocks
; if it's the end of the subanimation, make the attacking pokemon disappear
coord hl, 1, 5
@@ -910,13 +910,13 @@ DoExplodeSpecialEffects:
; flashes the screen when subanimation counter is 1 modulo 4
DoBlizzardSpecialEffects:
ld a, [wSubAnimCounter]
- cp a, 13
+ cp 13
jp z, AnimationFlashScreen
- cp a, 9
+ cp 9
jp z, AnimationFlashScreen
- cp a, 5
+ cp 5
jp z, AnimationFlashScreen
- cp a, 1
+ cp 1
jp z, AnimationFlashScreen
ret
@@ -924,18 +924,18 @@ DoBlizzardSpecialEffects:
; unused
FlashScreenUnused:
ld a, [wSubAnimCounter]
- cp a, 14
+ cp 14
jp z, AnimationFlashScreen
- cp a, 9
+ cp 9
jp z, AnimationFlashScreen
- cp a, 2
+ cp 2
jp z, AnimationFlashScreen
ret
; function to make the pokemon disappear at the beginning of the animation
TradeHidePokemon:
ld a, [wSubAnimCounter]
- cp a, 6
+ cp 6
ret nz
ld a, 2 * SCREEN_WIDTH + 7
jp ClearMonPicFromTileMap ; make pokemon disappear
@@ -943,7 +943,7 @@ TradeHidePokemon:
; function to make a shaking pokeball jump up at the end of the animation
TradeShakePokeball:
ld a, [wSubAnimCounter]
- cp a, 1
+ cp 1
ret nz
; if it's the end of the animation, make the ball jump up
ld de, BallMoveDistances1
@@ -952,13 +952,13 @@ TradeShakePokeball:
ld bc, 4
.innerLoop
ld a, [de]
- cp a, $ff
+ cp $ff
jr z, .done
add [hl] ; add to Y value of OAM entry
ld [hl], a
add hl, bc
ld a, l
- cp a, 4 * 4 ; there are 4 entries, each 4 bytes
+ cp 4 * 4 ; there are 4 entries, each 4 bytes
jr nz, .innerLoop
inc de
push bc
@@ -982,20 +982,20 @@ TradeJumpPokeball:
ld bc, 4
.innerLoop
ld a, [de]
- cp a, $ff
+ cp $ff
jp z, ClearScreen
add [hl]
ld [hl], a
add hl, bc
ld a, l
- cp a, 4 * 4 ; there are 4 entries, each 4 bytes
+ cp 4 * 4 ; there are 4 entries, each 4 bytes
jr nz, .innerLoop
inc de
push de
ld a, [de]
- cp a, 12
+ cp 12
jr z, .playSound
- cp a, $ff
+ cp $ff
jr nz, .skipPlayingSound
.playSound ; play sound if next move distance is 12 or this is the last one
ld a, SFX_BATTLE_18
@@ -1006,7 +1006,7 @@ TradeJumpPokeball:
call DelayFrames
pop bc
ld a, [hSCX] ; background scroll X
- sub a, 8 ; scroll to the left
+ sub 8 ; scroll to the left
ld [hSCX], a
pop de
jr .loop
@@ -1125,7 +1125,7 @@ AnimationDelay10:
CallWithTurnFlipped:
ld a, [H_WHOSETURN]
push af
- xor a, 1
+ xor 1
ld [H_WHOSETURN], a
ld de, .returnAddress
push de
@@ -1148,7 +1148,7 @@ AnimationFlashScreenLong:
push hl
.innerLoop
ld a, [hli]
- cp a, $01 ; is it the end of the palettes?
+ cp $01 ; is it the end of the palettes?
jr z, .endOfPalettes
ld [rBGP], a
call UpdateGBCPal_BGP
@@ -1198,13 +1198,13 @@ FlashScreenLongSGB:
; causes a delay of 1 frame for the second and third cycles
FlashScreenLongDelay:
ld a, [wFlashScreenLongCounter]
- cp a, 4 ; never true since [wFlashScreenLongCounter] starts at 3
+ cp 4 ; never true since [wFlashScreenLongCounter] starts at 3
ld c, 4
jr z, .delayFrames
- cp a, 3
+ cp 3
ld c, 2
jr z, .delayFrames
- cp a, 2 ; nothing is done with this
+ cp 2 ; nothing is done with this
ld c, 1
.delayFrames
jp DelayFrames
@@ -1599,7 +1599,7 @@ AnimationShowMonPic:
jp Delay3
AnimationShowEnemyMonPic:
-; Shows the emenmy mon's front sprite. Used in animations like Seismic Toss
+; Shows the enemy mon's front sprite. Used in animations like Seismic Toss
; to make the mon's sprite reappear after disappears offscreen.
ld hl, AnimationShowMonPic
jp CallWithTurnFlipped
@@ -2201,7 +2201,7 @@ HideSubstituteShowMonAnim:
push de
push bc
; if the substitute broke, slide it down, else slide it offscreen horizontally
- bit HasSubstituteUp, a
+ bit HAS_SUBSTITUTE_UP, a
jr nz, .substituteStillUp
call AnimationSlideMonDown
jr .next2
@@ -2211,7 +2211,7 @@ HideSubstituteShowMonAnim:
pop bc
pop de
ld a, [de]
- bit Invulnerable, a
+ bit INVULNERABLE, a
pop hl
jr nz, .invulnerable
ld a, [bc]
@@ -2524,9 +2524,9 @@ GetMoveSound:
IsCryMove:
; set carry if the move animation involves playing a monster cry
ld a, [wAnimationID]
- cp a, GROWL
+ cp GROWL
jr z, .CryMove
- cp a, ROAR
+ cp ROAR
jr z, .CryMove
and a ; clear carry
ret
@@ -2589,12 +2589,12 @@ MoveSoundTable:
db SFX_BATTLE_2A, $80, $c0 ; ACID
db SFX_BATTLE_19, $10, $a0 ; EMBER
db SFX_BATTLE_19, $21, $e0 ; FLAMETHROWER
- db SFX_EARTHQUAKE, $00, $80 ; MIST
+ db SFX_BATTLE_29, $00, $80 ; MIST
db SFX_BATTLE_24, $20, $60 ; WATER_GUN
db SFX_BATTLE_2A, $00, $80 ; HYDRO_PUMP
db SFX_BATTLE_2C, $00, $80 ; SURF
db SFX_BATTLE_28, $40, $80 ; ICE_BEAM
- db SFX_EARTHQUAKE, $f0, $e0 ; BLIZZARD
+ db SFX_BATTLE_29, $f0, $e0 ; BLIZZARD
db SFX_PSYBEAM, $00, $80 ; PSYBEAM
db SFX_BATTLE_2A, $f0, $60 ; BUBBLEBEAM
db SFX_BATTLE_28, $00, $80 ; AURORA_BEAM
@@ -2617,15 +2617,15 @@ MoveSoundTable:
db SFX_BATTLE_1C, $01, $c0 ; SLEEP_POWDER
db SFX_BATTLE_13, $14, $c0 ; PETAL_DANCE
db SFX_BATTLE_1B, $02, $a0 ; STRING_SHOT
- db SFX_EARTHQUAKE, $f0, $80 ; DRAGON_RAGE
- db SFX_EARTHQUAKE, $20, $c0 ; FIRE_SPIN
- db SFX_THUNDERBOLT, $00, $20 ; THUNDERSHOCK
- db SFX_THUNDERBOLT, $20, $80 ; THUNDERBOLT
+ db SFX_BATTLE_29, $f0, $80 ; DRAGON_RAGE
+ db SFX_BATTLE_29, $20, $c0 ; FIRE_SPIN
+ db SFX_BATTLE_2F, $00, $20 ; THUNDERSHOCK
+ db SFX_BATTLE_2F, $20, $80 ; THUNDERBOLT
db SFX_BATTLE_2E, $12, $60 ; THUNDER_WAVE
db SFX_BATTLE_26, $00, $80 ; THUNDER
db SFX_BATTLE_14, $01, $e0 ; ROCK_THROW
- db SFX_EARTHQUAKE, $0f, $e0 ; EARTHQUAKE
- db SFX_EARTHQUAKE, $11, $20 ; FISSURE
+ db SFX_BATTLE_29, $0f, $e0 ; EARTHQUAKE
+ db SFX_BATTLE_29, $11, $20 ; FISSURE
db SFX_DAMAGE, $10, $40 ; DIG
db SFX_BATTLE_0F, $10, $c0 ; TOXIC
db SFX_BATTLE_14, $00, $20 ; CONFUSION
@@ -2661,7 +2661,7 @@ MoveSoundTable:
db SFX_NOT_VERY_EFFECTIVE, $10, $ff ; SMOG
db SFX_BATTLE_2A, $20, $20 ; SLUDGE
db SFX_BATTLE_32, $00, $80 ; BONE_CLUB
- db SFX_EARTHQUAKE, $1f, $20 ; FIRE_BLAST
+ db SFX_BATTLE_29, $1f, $20 ; FIRE_BLAST
db SFX_BATTLE_25, $2f, $80 ; WATERFALL
db SFX_BATTLE_0F, $1f, $ff ; CLAMP
db SFX_BATTLE_2B, $1f, $60 ; SWIFT
@@ -2696,7 +2696,7 @@ MoveSoundTable:
db SFX_BATTLE_1E, $12, $ff ; HYPER_FANG
db SFX_BATTLE_31, $80, $04 ; SHARPEN
db SFX_BATTLE_33, $f0, $10 ; CONVERSION
- db SFX_EARTHQUAKE, $f8, $ff ; TRI_ATTACK
+ db SFX_BATTLE_29, $f8, $ff ; TRI_ATTACK
db SFX_BATTLE_26, $f0, $ff ; SUPER_FANG
db SFX_NOT_VERY_EFFECTIVE, $01, $ff ; SLASH
db SFX_BATTLE_2C, $d8, $04 ; SUBSTITUTE
@@ -2765,11 +2765,11 @@ TileIDListPointerTable:
dn 5, 7
dw DownscaledMonTiles_3x7
dn 3, 7
- dw DownscaledMonTiles_79ce9
+ dw GengarIntroTiles1
dn 7, 7
- dw DownscaledMonTiles_79d1a
+ dw GengarIntroTiles2
dn 7, 7
- dw DownscaledMonTiles_79d4b
+ dw GengarIntroTiles3
dn 7, 7
dw DownscaledMonTiles_79d7c
dn 8, 6
@@ -2809,7 +2809,7 @@ DownscaledMonTiles_3x7:
db $02, $09, $10, $17, $1E, $25, $2C
db $04, $0B, $12, $19, $20, $27, $2E
-DownscaledMonTiles_79ce9:
+GengarIntroTiles1:
db $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $19, $00
db $02, $06, $0B, $10, $14, $1A, $00
@@ -2818,7 +2818,7 @@ DownscaledMonTiles_79ce9:
db $04, $09, $0E, $13, $17, $1D, $1F
db $05, $0A, $0F, $01, $18, $1E, $20
-DownscaledMonTiles_79d1a:
+GengarIntroTiles2:
db $00, $00, $00, $30, $00, $37, $00
db $00, $00, $2B, $31, $34, $38, $3D
db $21, $26, $2C, $01, $35, $39, $3E
@@ -2827,7 +2827,7 @@ DownscaledMonTiles_79d1a:
db $24, $29, $2F, $01, $01, $3B, $00
db $25, $2A, $01, $01, $01, $3C, $00
-DownscaledMonTiles_79d4b:
+GengarIntroTiles3:
db $00, $00, $00, $00, $00, $00, $00
db $00, $00, $47, $4D, $00, $00, $00
db $00, $00, $48, $4E, $52, $56, $5B
@@ -3158,30 +3158,30 @@ BattleAnimCopyTileMapToVRAM:
TossBallAnimation:
ld a, [wIsInBattle]
- cp a, 2
+ cp 2
jr z, .BlockBall ; if in trainer battle, play different animation
ld a, [wPokeBallAnimData]
ld b, a
; upper nybble: how many animations (from PokeBallAnimations) to play
; this will be 4 for successful capture, 6 for breakout
- and a, $F0
+ and $F0
swap a
ld c, a
; lower nybble: number of shakes
; store these for later
ld a, b
- and a, $F
+ and $F
ld [wNumShakes], a
ld hl, .PokeBallAnimations
; choose which toss animation to use
ld a, [wcf91]
- cp a, POKE_BALL
+ cp POKE_BALL
ld b, TOSS_ANIM
jr z, .done
- cp a, GREAT_BALL
+ cp GREAT_BALL
ld b, GREATTOSS_ANIM
jr z, .done
ld b, ULTRATOSS_ANIM
diff --git a/engine/battle/bank3d_battle.asm b/engine/battle/bank3d_battle.asm
index 740fc71a..0cf24fe1 100644
--- a/engine/battle/bank3d_battle.asm
+++ b/engine/battle/bank3d_battle.asm
@@ -30,7 +30,7 @@ asm_f601d:
res 1, [hl]
call InitBattleVariables
ld a, [wEnemyMonSpecies2]
- sub $c8
+ sub OPP_ID_OFFSET
jp c, InitWildBattle
ld [wTrainerClass], a
call GetTrainerInformation
diff --git a/engine/battle/battle_transitions.asm b/engine/battle/battle_transitions.asm
index ec95a5d9..e4392a01 100644
--- a/engine/battle/battle_transitions.asm
+++ b/engine/battle/battle_transitions.asm
@@ -82,7 +82,7 @@ BattleTransitions:
GetBattleTransitionID_WildOrTrainer:
ld a, [wCurOpponent]
- cp 200
+ cp OPP_ID_OFFSET
jr nc, .trainer
res 0, c
ret
@@ -118,8 +118,8 @@ GetBattleTransitionID_CompareLevels:
ld [wBattleTransitionSpiralDirection], a
ret
-; fails to recognize VICTORY_ROAD_2, VICTORY_ROAD_3, all ROCKET_HIDEOUT maps,
-; MANSION_1, SEAFOAM_ISLANDS_[2-5], POWER_PLANT, DIGLETTS_CAVE
+; fails to recognize VICTORY_ROAD_2F, VICTORY_ROAD_3F, all ROCKET_HIDEOUT maps,
+; POKEMON_MANSION_1F, SEAFOAM_ISLANDS_[B1F-B4F], POWER_PLANT, DIGLETTS_CAVE
; and SILPH_CO_[9-11]F as dungeon maps
GetBattleTransitionID_IsDungeonMap:
ld a, [wCurMap]
@@ -155,30 +155,30 @@ GetBattleTransitionID_IsDungeonMap:
; is equal to one of these maps
DungeonMaps1:
db VIRIDIAN_FOREST
- db ROCK_TUNNEL_1
- db SEAFOAM_ISLANDS_1
- db ROCK_TUNNEL_2
+ db ROCK_TUNNEL_1F
+ db SEAFOAM_ISLANDS_1F
+ db ROCK_TUNNEL_B1F
db $FF
; GetBattleTransitionID_IsDungeonMap checks if wCurMap
; is in between or equal to each pair of maps
DungeonMaps2:
; all MT_MOON maps
- db MT_MOON_1
- db MT_MOON_3
+ db MT_MOON_1F
+ db MT_MOON_B2F
- ; all SS_ANNE maps, VICTORY_ROAD_1, LANCES_ROOM, and HALL_OF_FAME
- db SS_ANNE_1
+ ; all SS_ANNE maps, VICTORY_ROAD_1F, LANCES_ROOM, and HALL_OF_FAME
+ db SS_ANNE_1F
db HALL_OF_FAME
- ; all POKEMONTOWER maps and Lavender Town buildings
+ ; all POKEMON_TOWER maps and Lavender Town buildings
db LAVENDER_POKECENTER
- db LAVENDER_HOUSE_2
+ db LAVENDER_CUBONE_HOUSE
- ; SILPH_CO_[2-8]F, MANSION[2-4], SAFARI_ZONE, and UNKNOWN_DUNGEON maps,
- ; except for SILPH_CO_1F
+ ; SILPH_CO_[2-8]F, POKEMON_MANSION[2F-B1F], SAFARI_ZONE, and
+ ; CERULEAN_CAVE maps, except for SILPH_CO_1F
db SILPH_CO_2F
- db UNKNOWN_DUNGEON_1
+ db CERULEAN_CAVE_1F
db $FF
LoadBattleTransitionTile:
diff --git a/engine/battle/common_text.asm b/engine/battle/common_text.asm
index d84d0300..e8f4f002 100644
--- a/engine/battle/common_text.asm
+++ b/engine/battle/common_text.asm
@@ -3,9 +3,9 @@ PrintBeginningBattleText:
dec a
jr nz, .trainerBattle
ld a, [wCurMap]
- cp POKEMONTOWER_3
+ cp POKEMON_TOWER_3F
jr c, .notPokemonTower
- cp LAVENDER_HOUSE_1
+ cp MR_FUJIS_HOUSE
jr c, .pokemonTower
.notPokemonTower
ld a,[wBattleType]
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index f23dd649..60146902 100755
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -390,15 +390,15 @@ MainInBattleLoop:
xor a
ld [wFirstMonsNotOutYet], a
ld a, [wPlayerBattleStatus2]
- and (1 << NeedsToRecharge) | (1 << UsingRage) ; check if the player is using Rage or needs to recharge
+ and (1 << NEEDS_TO_RECHARGE) | (1 << USING_RAGE) ; check if the player is using Rage or needs to recharge
jr nz, .selectEnemyMove
; the player is not using Rage and doesn't need to recharge
ld hl, wEnemyBattleStatus1
- res Flinched, [hl] ; reset flinch bit
+ res FLINCHED, [hl] ; reset flinch bit
ld hl, wPlayerBattleStatus1
- res Flinched, [hl] ; reset flinch bit
+ res FLINCHED, [hl] ; reset flinch bit
ld a, [hl]
- and (1 << ThrashingAbout) | (1 << ChargingUp) ; check if the player is thrashing about or charging for an attack
+ and (1 << THRASHING_ABOUT) | (1 << CHARGING_UP) ; check if the player is thrashing about or charging for an attack
jr nz, .selectEnemyMove ; if so, jump
; the player is neither thrashing about nor charging for an attack
call DisplayBattleMenu ; show battle menu
@@ -410,12 +410,12 @@ MainInBattleLoop:
and (1 << FRZ) | SLP ; is mon frozen or asleep?
jr nz, .selectEnemyMove ; if so, jump
ld a, [wPlayerBattleStatus1]
- and (1 << StoringEnergy) | (1 << UsingTrappingMove) ; check player is using Bide or using a multi-turn attack like wrap
+ and (1 << STORING_ENERGY) | (1 << USING_TRAPPING_MOVE) ; check player is using Bide or using a multi-turn attack like wrap
jr nz, .selectEnemyMove ; if so, jump
ld a, [wEnemyBattleStatus1]
- bit UsingTrappingMove, a ; check if enemy is using a multi-turn attack like wrap
+ bit USING_TRAPPING_MOVE, a ; check if enemy is using a multi-turn attack like wrap
jr z, .selectPlayerMove ; if not, jump
-; enemy is using a mult-turn attack like wrap, so player is trapped and cannot execute a move
+; enemy is using a multi-turn attack like wrap, so player is trapped and cannot execute a move
ld a, $ff
ld [wPlayerSelectedMove], a
jr .selectEnemyMove
@@ -441,17 +441,17 @@ MainInBattleLoop:
jr nz, .noLinkBattle
; link battle
ld a, [wSerialExchangeNybbleReceiveData]
- cp $f
+ cp LINKBATTLE_RUN
jp z, EnemyRan
- cp $e
+ cp LINKBATTLE_STRUGGLE
jr z, .noLinkBattle
- cp $d
+ cp LINKBATTLE_NO_ACTION
jr z, .noLinkBattle
- sub $4
+ sub 4
jr c, .noLinkBattle
; the link battle enemy has switched mons
ld a, [wPlayerBattleStatus1]
- bit UsingTrappingMove, a ; check if using multi-turn move like Wrap
+ bit USING_TRAPPING_MOVE, a ; check if using multi-turn move like Wrap
jr z, .specialMoveNotUsed
ld a, [wPlayerMoveListIndex]
ld hl, wBattleMonMoves
@@ -497,8 +497,8 @@ MainInBattleLoop:
jr nc, .playerMovesFirst ; if player is faster
jr .enemyMovesFirst ; if enemy is faster
.speedEqual ; 50/50 chance for both players
- ld a, [$ffaa]
- cp $2
+ ld a, [hSerialConnectionStatus]
+ cp USING_INTERNAL_CLOCK
jr z, .invertOutcome
call BattleRandom
cp $80
@@ -588,7 +588,7 @@ HandlePoisonBurnLeechSeed:
call PrintText
xor a
ld [wAnimationType], a
- ld a,BURN_PSN_ANIM
+ ld a, BURN_PSN_ANIM
call PlayMoveAnimation ; play burn/poison animation
pop hl
call HandlePoisonBurnLeechSeed_DecreaseOwnHP
@@ -609,7 +609,7 @@ HandlePoisonBurnLeechSeed:
ld [H_WHOSETURN], a
xor a
ld [wAnimationType], a
- ld a,ABSORB
+ ld a, ABSORB
call PlayMoveAnimation ; play leech seed animation (from opposing mon)
pop af
ld [H_WHOSETURN], a
@@ -676,7 +676,7 @@ HandlePoisonBurnLeechSeed_DecreaseOwnHP:
ld hl, wEnemyBattleStatus3
ld de, wEnemyToxicCounter
.playersTurn
- bit BadlyPoisoned, [hl]
+ bit BADLY_POISONED, [hl]
jr z, .noToxic
ld a, [de] ; increment toxic counter
inc a
@@ -713,7 +713,7 @@ HandlePoisonBurnLeechSeed_DecreaseOwnHP:
ret
; adds bc to enemy HP
-; bc isn't updated if HP substracted was capped to prevent overkill
+; bc isn't updated if HP subtracted was capped to prevent overkill
HandlePoisonBurnLeechSeed_IncreaseEnemyHP:
push hl
ld hl, wEnemyMonMaxHP
@@ -785,14 +785,14 @@ CheckNumAttacksLeft:
jr nz, .checkEnemy
; player has 0 attacks left
ld hl, wPlayerBattleStatus1
- res UsingTrappingMove, [hl] ; player not using multi-turn attack like wrap any more
+ res USING_TRAPPING_MOVE, [hl] ; player not using multi-turn attack like wrap any more
.checkEnemy
ld a, [wEnemyNumAttacksLeft]
and a
ret nz
; enemy has 0 attacks left
ld hl, wEnemyBattleStatus1
- res UsingTrappingMove, [hl] ; enemy not using multi-turn attack like wrap any more
+ res USING_TRAPPING_MOVE, [hl] ; enemy not using multi-turn attack like wrap any more
ret
HandleEnemyMonFainted:
@@ -842,7 +842,7 @@ FaintEnemyPokemon:
ld [hl], a
.wild
ld hl, wPlayerBattleStatus1
- res AttackingMultipleTimes, [hl]
+ res ATTACKING_MULTIPLE_TIMES, [hl]
; Bug. This only zeroes the high byte of the player's accumulated damage,
; setting the accumulated damage to itself mod 256 instead of 0 as was probably
; intended. That alone is problematic, but this mistake has another more severe
@@ -881,7 +881,7 @@ FaintEnemyPokemon:
ld a, SFX_FAINT_FALL
call PlaySoundWaitForCurrent
.sfxwait
- ld a, [wChannelSoundIDs + CH4]
+ ld a, [wChannelSoundIDs + Ch5]
cp SFX_FAINT_FALL
jr z, .sfxwait
ld a, SFX_FAINT_THUD
@@ -965,7 +965,7 @@ EndLowHealthAlarm:
; the low health alarm and prevents it from reactivating until the next battle.
xor a
ld [wLowHealthAlarm], a ; turn off low health alarm
- ld [wChannelSoundIDs + CH4], a
+ ld [wChannelSoundIDs + Ch5], a
inc a
ld [wLowHealthAlarmDisabled], a ; prevent it from reactivating
ret
@@ -1004,7 +1004,7 @@ ReplaceFaintedEnemyMon:
; link battle
call LinkBattleExchangeData
ld a, [wSerialExchangeNybbleReceiveData]
- cp $f
+ cp LINKBATTLE_RUN
ret z
call LoadScreenTilesFromBuffer1
.notLinkBattle
@@ -1257,7 +1257,7 @@ ChooseNextMon:
ret
; called when player is out of usable mons.
-; prints approriate lose message, sets carry flag if player blacked out (special case for initial rival fight)
+; prints appropriate lose message, sets carry flag if player blacked out (special case for initial rival fight)
HandlePlayerBlackOut:
ld a, [wLinkState]
cp LINK_STATE_BATTLING
@@ -1402,138 +1402,138 @@ SlideTrainerPicOffScreen:
; send out a trainer's mon
EnemySendOut:
- ld hl,wPartyGainExpFlags
+ ld hl, wPartyGainExpFlags
xor a
- ld [hl],a
- ld a,[wPlayerMonNumber]
- ld c,a
- ld b,FLAG_SET
+ ld [hl], a
+ ld a, [wPlayerMonNumber]
+ ld c, a
+ ld b, FLAG_SET
push bc
predef FlagActionPredef
- ld hl,wPartyFoughtCurrentEnemyFlags
+ ld hl, wPartyFoughtCurrentEnemyFlags
xor a
- ld [hl],a
+ ld [hl], a
pop bc
predef FlagActionPredef
; don't change wPartyGainExpFlags or wPartyFoughtCurrentEnemyFlags
EnemySendOutFirstMon:
xor a
- ld hl,wEnemyStatsToDouble ; clear enemy statuses
- ld [hli],a
- ld [hli],a
- ld [hli],a
- ld [hli],a
- ld [hl],a
- ld [wEnemyDisabledMove],a
- ld [wEnemyDisabledMoveNumber],a
- ld [wEnemyMonMinimized],a
- ld hl,wPlayerUsedMove
- ld [hli],a
- ld [hl],a
+ ld hl, wEnemyStatsToDouble ; clear enemy statuses
+ ld [hli], a
+ ld [hli], a
+ ld [hli], a
+ ld [hli], a
+ ld [hl], a
+ ld [wEnemyDisabledMove], a
+ ld [wEnemyDisabledMoveNumber], a
+ ld [wEnemyMonMinimized], a
+ ld hl, wPlayerUsedMove
+ ld [hli], a
+ ld [hl], a
dec a
- ld [wAICount],a
- ld hl,wPlayerBattleStatus1
- res 5,[hl]
+ ld [wAICount], a
+ ld hl, wPlayerBattleStatus1
+ res 5, [hl]
coord hl, 18, 0
- ld a,8
+ ld a, 8
call SlideTrainerPicOffScreen
call PrintEmptyString
call SaveScreenTilesToBuffer1
- ld a,[wLinkState]
+ ld a, [wLinkState]
cp LINK_STATE_BATTLING
- jr nz,.next
- ld a,[wSerialExchangeNybbleReceiveData]
+ jr nz, .next
+ ld a, [wSerialExchangeNybbleReceiveData]
sub 4
- ld [wWhichPokemon],a
+ ld [wWhichPokemon], a
jr .next3
.next
- ld b,$FF
+ ld b, $FF
.next2
inc b
- ld a,[wEnemyMonPartyPos]
+ ld a, [wEnemyMonPartyPos]
cp b
- jr z,.next2
- ld hl,wEnemyMon1
- ld a,b
- ld [wWhichPokemon],a
+ jr z, .next2
+ ld hl, wEnemyMon1
+ ld a, b
+ ld [wWhichPokemon], a
push bc
- ld bc,wEnemyMon2 - wEnemyMon1
+ ld bc, wEnemyMon2 - wEnemyMon1
call AddNTimes
pop bc
inc hl
- ld a,[hli]
- ld c,a
- ld a,[hl]
+ ld a, [hli]
+ ld c, a
+ ld a, [hl]
or c
- jr z,.next2
+ jr z, .next2
.next3
- ld a,[wWhichPokemon]
- ld hl,wEnemyMon1Level
- ld bc,wEnemyMon2 - wEnemyMon1
+ ld a, [wWhichPokemon]
+ ld hl, wEnemyMon1Level
+ ld bc, wEnemyMon2 - wEnemyMon1
call AddNTimes
- ld a,[hl]
- ld [wCurEnemyLVL],a
- ld a,[wWhichPokemon]
+ ld a, [hl]
+ ld [wCurEnemyLVL], a
+ ld a, [wWhichPokemon]
inc a
- ld hl,wEnemyPartyCount
- ld c,a
- ld b,0
- add hl,bc
- ld a,[hl]
- ld [wEnemyMonSpecies2],a
- ld [wcf91],a
+ ld hl, wEnemyPartyCount
+ ld c, a
+ ld b, 0
+ add hl, bc
+ ld a, [hl]
+ ld [wEnemyMonSpecies2], a
+ ld [wcf91], a
call LoadEnemyMonData
- ld hl,wEnemyMonHP
- ld a,[hli]
- ld [wLastSwitchInEnemyMonHP],a
- ld a,[hl]
- ld [wLastSwitchInEnemyMonHP + 1],a
- ld a,1
- ld [wCurrentMenuItem],a
- ld a,[wFirstMonsNotOutYet]
+ ld hl, wEnemyMonHP
+ ld a, [hli]
+ ld [wLastSwitchInEnemyMonHP], a
+ ld a, [hl]
+ ld [wLastSwitchInEnemyMonHP + 1], a
+ ld a, 1
+ ld [wCurrentMenuItem], a
+ ld a, [wFirstMonsNotOutYet]
dec a
- jr z,.next4
- ld a,[wPartyCount]
+ jr z, .next4
+ ld a, [wPartyCount]
dec a
- jr z,.next4
- ld a,[wLinkState]
+ jr z, .next4
+ ld a, [wLinkState]
cp LINK_STATE_BATTLING
- jr z,.next4
- ld a,[wOptions]
- bit 6,a
- jr nz,.next4
+ jr z, .next4
+ ld a, [wOptions]
+ bit 6, a
+ jr nz, .next4
ld hl, TrainerAboutToUseText
call PrintText
coord hl, 0, 7
lb bc, 8, 1
- ld a,TWO_OPTION_MENU
- ld [wTextBoxID],a
+ ld a, TWO_OPTION_MENU
+ ld [wTextBoxID], a
call DisplayTextBoxID
- ld a,[wCurrentMenuItem]
+ ld a, [wCurrentMenuItem]
and a
- jr nz,.next4
- ld a,BATTLE_PARTY_MENU
- ld [wPartyMenuTypeOrMessageID],a
+ jr nz, .next4
+ ld a, BATTLE_PARTY_MENU
+ ld [wPartyMenuTypeOrMessageID], a
call DisplayPartyMenu
.next9
- ld a,1
- ld [wCurrentMenuItem],a
- jr c,.next7
- ld hl,wPlayerMonNumber
- ld a,[wWhichPokemon]
+ ld a, 1
+ ld [wCurrentMenuItem], a
+ jr c, .next7
+ ld hl, wPlayerMonNumber
+ ld a, [wWhichPokemon]
cp [hl]
- jr nz,.next6
- ld hl,AlreadyOutText
+ jr nz, .next6
+ ld hl, AlreadyOutText
call PrintText
.next8
call GoBackToPartyMenu
jr .next9
.next6
call HasMonFainted
- jr z,.next8
+ jr z, .next8
xor a
- ld [wCurrentMenuItem],a
+ ld [wCurrentMenuItem], a
.next7
call GBPalWhiteOut
call LoadHudTilePatterns
@@ -1546,27 +1546,27 @@ EnemySendOutFirstMon:
ld b, SET_PAL_BATTLE
call RunPaletteCommand
call GBPalNormal
- ld hl,TrainerSentOutText
+ ld hl, TrainerSentOutText
call PrintText
- ld a,[wEnemyMonSpecies2]
- ld [wcf91],a
- ld [wd0b5],a
+ ld a, [wEnemyMonSpecies2]
+ ld [wcf91], a
+ ld [wd0b5], a
call GetMonHeader
- ld de,vFrontPic
+ ld de, vFrontPic
call LoadMonFrontSprite
- ld a,-$31
- ld [hStartTileID],a
+ ld a, -$31
+ ld [hStartTileID], a
coord hl, 15, 6
predef AnimateSendingOutMon
- ld a,[wEnemyMonSpecies2]
+ ld a, [wEnemyMonSpecies2]
call PlayCry
call DrawEnemyHUDAndHPBar
- ld a,[wCurrentMenuItem]
+ ld a, [wCurrentMenuItem]
and a
ret nz
xor a
- ld [wPartyGainExpFlags],a
- ld [wPartyFoughtCurrentEnemyFlags],a
+ ld [wPartyGainExpFlags], a
+ ld [wPartyFoughtCurrentEnemyFlags], a
call SaveScreenTilesToBuffer1
jp SwitchPlayerMon
@@ -1720,12 +1720,12 @@ TryRunningFromBattle:
call SaveScreenTilesToBuffer1
xor a
ld [wActionResultOrTookBattleTurn], a
- ld a, $f
+ ld a, LINKBATTLE_RUN
ld [wPlayerMoveListIndex], a
call LinkBattleExchangeData
call LoadScreenTilesFromBuffer1
ld a, [wSerialExchangeNybbleReceiveData]
- cp $f
+ cp LINKBATTLE_RUN
ld a, $2
jr z, .playSound
dec a
@@ -1883,7 +1883,7 @@ SendOutMon:
ld b, SET_PAL_BATTLE
call RunPaletteCommand
ld hl, wEnemyBattleStatus1
- res UsingTrappingMove, [hl]
+ res USING_TRAPPING_MOVE, [hl]
callab IsThisPartymonStarterPikachu
jr c, .starterPikachu
ld a, $1
@@ -2029,7 +2029,7 @@ DrawPlayerHUDAndHPBar:
ld [hl], $0
ret z
xor a
- ld [wChannelSoundIDs + CH4], a
+ ld [wChannelSoundIDs + Ch5], a
ret
.setLowHealthAlarm
ld hl, wLowHealthAlarm
@@ -2215,7 +2215,7 @@ DisplayBattleMenu:
ld [hl], "▶"
ld c, 20
call DelayFrames
- ld [hl], $ec
+ ld [hl], "▷"
ld a, $2 ; select the "ITEM" menu
jp .upperLeftMenuItemWasNotSelected
.oldManName
@@ -2449,13 +2449,13 @@ UseBagItem:
jp z, BagWasSelected ; if not, go back to the bag menu
ld a, [wPlayerBattleStatus1]
- bit UsingTrappingMove, a ; is the player using a multi-turn move like wrap?
+ bit USING_TRAPPING_MOVE, a ; is the player using a multi-turn move like wrap?
jr z, .checkIfMonCaptured
ld hl, wPlayerNumAttacksLeft
dec [hl]
jr nz, .checkIfMonCaptured
ld hl, wPlayerBattleStatus1
- res UsingTrappingMove, [hl] ; not using multi-turn move any more
+ res USING_TRAPPING_MOVE, [hl] ; not using multi-turn move any more
.checkIfMonCaptured
ld a, [wCapturedMonSpecies]
@@ -2564,7 +2564,7 @@ PartyMenuOrRockOrRun:
ld a, 1
ld [H_WHOSETURN], a
ld a, [wEnemyBattleStatus2]
- bit HasSubstituteUp, a ; does the enemy mon have a substitute?
+ bit HAS_SUBSTITUTE_UP, a ; does the enemy mon have a substitute?
ld hl, AnimationSubstitute
jr nz, .doEnemyMonAnimation
; enemy mon doesn't have substitute
@@ -2786,7 +2786,7 @@ SelectMenuItem:
dec a
ld bc, SCREEN_WIDTH
call AddNTimes
- ld [hl], $ec
+ ld [hl], "▷"
.select
ld hl, hFlags_0xFFFA
set 1, [hl]
@@ -2994,7 +2994,7 @@ NoMovesLeftText:
SwapMovesInMenu:
ld a, [wPlayerBattleStatus3]
- bit Transformed, a
+ bit TRANSFORMED, a
jp nz, MoveSelectionMenu
ld a, [wMenuItemToSwap]
and a
@@ -3156,35 +3156,35 @@ SelectEnemyMove:
call LinkBattleExchangeData
call LoadScreenTilesFromBuffer1
ld a, [wSerialExchangeNybbleReceiveData]
- cp $e
+ cp LINKBATTLE_STRUGGLE
jp z, .linkedOpponentUsedStruggle
- cp $d
+ cp LINKBATTLE_NO_ACTION
jr z, .unableToSelectMove
- cp $4
+ cp 4
ret nc
ld [wEnemyMoveListIndex], a
ld c, a
ld hl, wEnemyMonMoves
- ld b, $0
+ ld b, 0
add hl, bc
ld a, [hl]
jr .done
.noLinkBattle
ld a, [wEnemyBattleStatus2]
- and (1 << NeedsToRecharge) | (1 << UsingRage) ; need to recharge or using rage
+ and (1 << NEEDS_TO_RECHARGE) | (1 << USING_RAGE) ; need to recharge or using rage
ret nz
ld hl, wEnemyBattleStatus1
ld a, [hl]
- and (1 << ChargingUp) | (1 << ThrashingAbout) ; using a charging move or thrash/petal dance
+ and (1 << CHARGING_UP) | (1 << THRASHING_ABOUT) ; using a charging move or thrash/petal dance
ret nz
ld a, [wEnemyMonStatus]
and SLP | 1 << FRZ ; sleeping or frozen
ret nz
ld a, [wEnemyBattleStatus1]
- and (1 << UsingTrappingMove) | (1 << StoringEnergy) ; using a trapping move like wrap or bide
+ and (1 << USING_TRAPPING_MOVE) | (1 << STORING_ENERGY) ; using a trapping move like wrap or bide
ret nz
ld a, [wPlayerBattleStatus1]
- bit UsingTrappingMove, a ; caught in player's trapping move (e.g. wrap)
+ bit USING_TRAPPING_MOVE, a ; caught in player's trapping move (e.g. wrap)
jr z, .canSelectMove
.unableToSelectMove
ld a, $ff
@@ -3244,7 +3244,7 @@ LinkBattleExchangeData:
ld a, $ff
ld [wSerialExchangeNybbleReceiveData], a
ld a, [wPlayerMoveListIndex]
- cp $f ; is the player running from battle?
+ cp LINKBATTLE_RUN ; is the player running from battle?
jr z, .doExchange
ld a, [wActionResultOrTookBattleTurn]
and a ; is the player switching in another mon?
@@ -3252,10 +3252,10 @@ LinkBattleExchangeData:
; the player used a move
ld a, [wPlayerSelectedMove]
cp STRUGGLE
- ld b, $e
+ ld b, LINKBATTLE_STRUGGLE
jr z, .next
- dec b
- inc a
+ dec b ; LINKBATTLE_NO_ACTION
+ inc a ; does move equal -1 (i.e. no action)?
jr z, .next
ld a, [wPlayerMoveListIndex]
jr .doExchange
@@ -3311,7 +3311,7 @@ ExecutePlayerMove:
.playerHasNoSpecialCondition
call GetCurrentMove
ld hl, wPlayerBattleStatus1
- bit ChargingUp, [hl] ; charging up for attack
+ bit CHARGING_UP, [hl] ; charging up for attack
jr nz, PlayerCanExecuteChargingMove
call CheckForDisobedience
jp z, ExecutePlayerMoveDone
@@ -3326,160 +3326,160 @@ CheckIfPlayerNeedsToChargeUp:
; in-battle stuff
PlayerCanExecuteChargingMove:
- ld hl,wPlayerBattleStatus1
- res ChargingUp,[hl] ; reset charging up and invulnerability statuses if mon was charging up for an attack
+ ld hl, wPlayerBattleStatus1
+ res CHARGING_UP, [hl] ; reset charging up and invulnerability statuses if mon was charging up for an attack
; being fully paralyzed or hurting oneself in confusion removes charging up status
; resulting in the Pokemon being invulnerable for the whole battle
- res Invulnerable,[hl]
+ res INVULNERABLE, [hl]
PlayerCanExecuteMove:
call PrintMonName1Text
- ld hl,DecrementPP
- ld de,wPlayerSelectedMove ; pointer to the move just used
- ld b,BANK(DecrementPP)
+ ld hl, DecrementPP
+ ld de, wPlayerSelectedMove ; pointer to the move just used
+ ld b, BANK(DecrementPP)
call Bankswitch
- ld a,[wPlayerMoveEffect] ; effect of the move just used
- ld hl,ResidualEffects1
- ld de,1
+ ld a, [wPlayerMoveEffect] ; effect of the move just used
+ ld hl, ResidualEffects1
+ ld de, 1
call IsInArray
- jp c,JumpMoveEffect ; ResidualEffects1 moves skip damage calculation and accuracy tests
+ jp c, JumpMoveEffect ; ResidualEffects1 moves skip damage calculation and accuracy tests
; unless executed as part of their exclusive effect functions
- ld a,[wPlayerMoveEffect]
- ld hl,SpecialEffectsCont
- ld de,1
+ ld a, [wPlayerMoveEffect]
+ ld hl, SpecialEffectsCont
+ ld de, 1
call IsInArray
- call c,JumpMoveEffect ; execute the effects of SpecialEffectsCont moves (e.g. Wrap, Thrash) but don't skip anything
+ call c, JumpMoveEffect ; execute the effects of SpecialEffectsCont moves (e.g. Wrap, Thrash) but don't skip anything
PlayerCalcMoveDamage:
- ld a,[wPlayerMoveEffect]
- ld hl,SetDamageEffects
- ld de,1
+ ld a, [wPlayerMoveEffect]
+ ld hl, SetDamageEffects
+ ld de, 1
call IsInArray
- jp c,.moveHitTest ; SetDamageEffects moves (e.g. Seismic Toss and Super Fang) skip damage calculation
+ jp c, .moveHitTest ; SetDamageEffects moves (e.g. Seismic Toss and Super Fang) skip damage calculation
call CriticalHitTest
call HandleCounterMove
- jr z,handleIfPlayerMoveMissed
+ jr z, handleIfPlayerMoveMissed
call GetDamageVarsForPlayerAttack
call CalculateDamage
- jp z,playerCheckIfFlyOrChargeEffect ; for moves with 0 BP, skip any further damage calculation and, for now, skip MoveHitTest
+ jp z, playerCheckIfFlyOrChargeEffect ; for moves with 0 BP, skip any further damage calculation and, for now, skip MoveHitTest
; for these moves, accuracy tests will only occur if they are called as part of the effect itself
call AdjustDamageForMoveType
call RandomizeDamage
.moveHitTest
call MoveHitTest
handleIfPlayerMoveMissed:
- ld a,[wMoveMissed]
+ ld a, [wMoveMissed]
and a
- jr z,getPlayerAnimationType
- ld a,[wPlayerMoveEffect]
- sub a,EXPLODE_EFFECT
- jr z,playPlayerMoveAnimation ; don't play any animation if the move missed, unless it was EXPLODE_EFFECT
+ jr z, getPlayerAnimationType
+ ld a, [wPlayerMoveEffect]
+ sub EXPLODE_EFFECT
+ jr z, playPlayerMoveAnimation ; don't play any animation if the move missed, unless it was EXPLODE_EFFECT
jr playerCheckIfFlyOrChargeEffect
getPlayerAnimationType:
- ld a,[wPlayerMoveEffect]
+ ld a, [wPlayerMoveEffect]
and a
- ld a,4 ; move has no effect other than dealing damage
- jr z,playPlayerMoveAnimation
- ld a,5 ; move has effect
+ ld a, 4 ; move has no effect other than dealing damage
+ jr z, playPlayerMoveAnimation
+ ld a, 5 ; move has effect
playPlayerMoveAnimation:
push af
- ld a,[wPlayerBattleStatus2]
- bit HasSubstituteUp,a
- ld hl,HideSubstituteShowMonAnim
- ld b,BANK(HideSubstituteShowMonAnim)
- call nz,Bankswitch
+ ld a, [wPlayerBattleStatus2]
+ bit HAS_SUBSTITUTE_UP, a
+ ld hl, HideSubstituteShowMonAnim
+ ld b, BANK(HideSubstituteShowMonAnim)
+ call nz, Bankswitch
pop af
- ld [wAnimationType],a
- ld a,[wPlayerMoveNum]
+ ld [wAnimationType], a
+ ld a, [wPlayerMoveNum]
call PlayMoveAnimation
call HandleExplodingAnimation
call DrawPlayerHUDAndHPBar
- ld a,[wPlayerBattleStatus2]
- bit HasSubstituteUp,a
- ld hl,ReshowSubstituteAnim
- ld b,BANK(ReshowSubstituteAnim)
- call nz,Bankswitch
+ ld a, [wPlayerBattleStatus2]
+ bit HAS_SUBSTITUTE_UP, a
+ ld hl, ReshowSubstituteAnim
+ ld b, BANK(ReshowSubstituteAnim)
+ call nz, Bankswitch
jr MirrorMoveCheck
playerCheckIfFlyOrChargeEffect:
- ld c,30
+ ld c, 30
call DelayFrames
- ld a,[wPlayerMoveEffect]
- cp a,FLY_EFFECT
- jr z,.playAnim
- cp a,CHARGE_EFFECT
- jr z,.playAnim
+ ld a, [wPlayerMoveEffect]
+ cp FLY_EFFECT
+ jr z, .playAnim
+ cp CHARGE_EFFECT
+ jr z, .playAnim
jr MirrorMoveCheck
.playAnim
xor a
- ld [wAnimationType],a
- ld a,STATUS_AFFECTED_ANIM
+ ld [wAnimationType], a
+ ld a, STATUS_AFFECTED_ANIM
call PlayMoveAnimation
MirrorMoveCheck:
- ld a,[wPlayerMoveEffect]
- cp a,MIRROR_MOVE_EFFECT
- jr nz,.metronomeCheck
+ ld a, [wPlayerMoveEffect]
+ cp MIRROR_MOVE_EFFECT
+ jr nz, .metronomeCheck
call MirrorMoveCopyMove
- jp z,ExecutePlayerMoveDone
+ jp z, ExecutePlayerMoveDone
xor a
- ld [wMonIsDisobedient],a
+ ld [wMonIsDisobedient], a
jp CheckIfPlayerNeedsToChargeUp ; if Mirror Move was successful go back to damage calculation for copied move
.metronomeCheck
- cp a,METRONOME_EFFECT
- jr nz,.next
+ cp METRONOME_EFFECT
+ jr nz, .next
call MetronomePickMove
jp CheckIfPlayerNeedsToChargeUp ; Go back to damage calculation for the move picked by Metronome
.next
- ld a,[wPlayerMoveEffect]
- ld hl,ResidualEffects2
- ld de,1
+ ld a, [wPlayerMoveEffect]
+ ld hl, ResidualEffects2
+ ld de, 1
call IsInArray
- jp c,JumpMoveEffect ; done here after executing effects of ResidualEffects2
- ld a,[wMoveMissed]
+ jp c, JumpMoveEffect ; done here after executing effects of ResidualEffects2
+ ld a, [wMoveMissed]
and a
- jr z,.moveDidNotMiss
+ jr z, .moveDidNotMiss
call PrintMoveFailureText
- ld a,[wPlayerMoveEffect]
- cp a,EXPLODE_EFFECT ; even if Explosion or Selfdestruct missed, its effect still needs to be activated
- jr z,.notDone
+ ld a, [wPlayerMoveEffect]
+ cp EXPLODE_EFFECT ; even if Explosion or Selfdestruct missed, its effect still needs to be activated
+ jr z, .notDone
jp ExecutePlayerMoveDone ; otherwise, we're done if the move missed
.moveDidNotMiss
call ApplyAttackToEnemyPokemon
call PrintCriticalOHKOText
callab DisplayEffectiveness
- ld a,1
- ld [wMoveDidntMiss],a
+ ld a, 1
+ ld [wMoveDidntMiss], a
.notDone
- ld a,[wPlayerMoveEffect]
- ld hl,AlwaysHappenSideEffects
- ld de,1
+ ld a, [wPlayerMoveEffect]
+ ld hl, AlwaysHappenSideEffects
+ ld de, 1
call IsInArray
- call c,JumpMoveEffect ; not done after executing effects of AlwaysHappenSideEffects
- ld hl,wEnemyMonHP
- ld a,[hli]
- ld b,[hl]
+ call c, JumpMoveEffect ; not done after executing effects of AlwaysHappenSideEffects
+ ld hl, wEnemyMonHP
+ ld a, [hli]
+ ld b, [hl]
or b
ret z ; don't do anything else if the enemy fainted
call HandleBuildingRage
- ld hl,wPlayerBattleStatus1
- bit AttackingMultipleTimes,[hl]
- jr z,.executeOtherEffects
- ld a,[wPlayerNumAttacksLeft]
+ ld hl, wPlayerBattleStatus1
+ bit ATTACKING_MULTIPLE_TIMES, [hl]
+ jr z, .executeOtherEffects
+ ld a, [wPlayerNumAttacksLeft]
dec a
- ld [wPlayerNumAttacksLeft],a
- jp nz,getPlayerAnimationType ; for multi-hit moves, apply attack until PlayerNumAttacksLeft hits 0 or the enemy faints.
+ ld [wPlayerNumAttacksLeft], a
+ jp nz, getPlayerAnimationType ; for multi-hit moves, apply attack until PlayerNumAttacksLeft hits 0 or the enemy faints.
; damage calculation and accuracy tests only happen for the first hit
- res AttackingMultipleTimes,[hl] ; clear attacking multiple times status when all attacks are over
- ld hl,MultiHitText
+ res ATTACKING_MULTIPLE_TIMES, [hl] ; clear attacking multiple times status when all attacks are over
+ ld hl, MultiHitText
call PrintText
xor a
- ld [wPlayerNumHits],a
+ ld [wPlayerNumHits], a
.executeOtherEffects
- ld a,[wPlayerMoveEffect]
+ ld a, [wPlayerMoveEffect]
and a
- jp z,ExecutePlayerMoveDone
- ld hl,SpecialEffects
- ld de,1
+ jp z, ExecutePlayerMoveDone
+ ld hl, SpecialEffects
+ ld de, 1
call IsInArray
- call nc,JumpMoveEffect ; move effects not included in SpecialEffects or in either of the ResidualEffect arrays,
+ call nc, JumpMoveEffect ; move effects not included in SpecialEffects or in either of the ResidualEffect arrays,
; which are the effects not covered yet. Rage effect will be executed for a second time (though it's irrelevant).
; Includes side effects that only need to be called if the target didn't faint.
; Responsible for executing Twineedle's second side effect (poison).
@@ -3491,26 +3491,26 @@ MultiHitText:
ExecutePlayerMoveDone:
xor a
- ld [wActionResultOrTookBattleTurn],a
- ld b,1
+ ld [wActionResultOrTookBattleTurn], a
+ ld b, 1
ret
PrintGhostText:
; print the ghost battle messages
call IsGhostBattle
ret nz
- ld a,[H_WHOSETURN]
+ ld a, [H_WHOSETURN]
and a
- jr nz,.Ghost
- ld a,[wBattleMonStatus] ; player’s turn
- and a,SLP | (1 << FRZ)
+ jr nz, .Ghost
+ ld a, [wBattleMonStatus] ; player’s turn
+ and SLP | (1 << FRZ)
ret nz
- ld hl,ScaredText
+ ld hl, ScaredText
call PrintText
xor a
ret
.Ghost ; ghost’s turn
- ld hl,GetOutText
+ ld hl, GetOutText
call PrintText
xor a
ret
@@ -3524,266 +3524,266 @@ GetOutText:
db "@"
IsGhostBattle:
- ld a,[wIsInBattle]
+ ld a, [wIsInBattle]
dec a
ret nz
- ld a,[wCurMap]
- cp a,POKEMONTOWER_1
- jr c,.next
- cp a,LAVENDER_HOUSE_1
- jr nc,.next
- ld b,SILPH_SCOPE
+ ld a, [wCurMap]
+ cp POKEMON_TOWER_1F
+ jr c, .next
+ cp MR_FUJIS_HOUSE
+ jr nc, .next
+ ld b, SILPH_SCOPE
call IsItemInBag
ret z
.next
- ld a,1
+ ld a, 1
and a
ret
; checks for various status conditions affecting the player mon
; stores whether the mon cannot use a move this turn in Z flag
CheckPlayerStatusConditions:
- ld hl,wBattleMonStatus
- ld a,[hl]
- and a,SLP ; sleep mask
- jr z,.FrozenCheck
+ ld hl, wBattleMonStatus
+ ld a, [hl]
+ and SLP ; sleep mask
+ jr z, .FrozenCheck
; sleeping
dec a
- ld [wBattleMonStatus],a ; decrement number of turns left
+ ld [wBattleMonStatus], a ; decrement number of turns left
and a
- jr z,.WakeUp ; if the number of turns hit 0, wake up
+ jr z, .WakeUp ; if the number of turns hit 0, wake up
; fast asleep
xor a
- ld [wAnimationType],a
- ld a,SLP_ANIM - 1
+ ld [wAnimationType], a
+ ld a, SLP_ANIM - 1
call PlayMoveAnimation
- ld hl,FastAsleepText
+ ld hl, FastAsleepText
call PrintText
jr .sleepDone
.WakeUp
- ld hl,WokeUpText
+ ld hl, WokeUpText
call PrintText
.sleepDone
xor a
- ld [wPlayerUsedMove],a
- ld hl,ExecutePlayerMoveDone ; player can't move this turn
+ ld [wPlayerUsedMove], a
+ ld hl, ExecutePlayerMoveDone ; player can't move this turn
jp .returnToHL
.FrozenCheck
- bit FRZ,[hl] ; frozen?
- jr z,.HeldInPlaceCheck
- ld hl,IsFrozenText
+ bit FRZ, [hl] ; frozen?
+ jr z, .HeldInPlaceCheck
+ ld hl, IsFrozenText
call PrintText
xor a
- ld [wPlayerUsedMove],a
- ld hl,ExecutePlayerMoveDone ; player can't move this turn
+ ld [wPlayerUsedMove], a
+ ld hl, ExecutePlayerMoveDone ; player can't move this turn
jp .returnToHL
.HeldInPlaceCheck
- ld a,[wEnemyBattleStatus1]
- bit UsingTrappingMove,a ; is enemy using a mult-turn move like wrap?
- jp z,.FlinchedCheck
- ld hl,CantMoveText
+ ld a, [wEnemyBattleStatus1]
+ bit USING_TRAPPING_MOVE, a ; is enemy using a mult-turn move like wrap?
+ jp z, .FlinchedCheck
+ ld hl, CantMoveText
call PrintText
- ld hl,ExecutePlayerMoveDone ; player can't move this turn
+ ld hl, ExecutePlayerMoveDone ; player can't move this turn
jp .returnToHL
.FlinchedCheck
- ld hl,wPlayerBattleStatus1
- bit Flinched,[hl]
- jp z,.HyperBeamCheck
- res Flinched,[hl] ; reset player's flinch status
- ld hl,FlinchedText
+ ld hl, wPlayerBattleStatus1
+ bit FLINCHED, [hl]
+ jp z, .HyperBeamCheck
+ res FLINCHED, [hl] ; reset player's flinch status
+ ld hl, FlinchedText
call PrintText
- ld hl,ExecutePlayerMoveDone ; player can't move this turn
+ ld hl, ExecutePlayerMoveDone ; player can't move this turn
jp .returnToHL
.HyperBeamCheck
- ld hl,wPlayerBattleStatus2
- bit NeedsToRecharge,[hl]
- jr z,.AnyMoveDisabledCheck
- res NeedsToRecharge,[hl] ; reset player's recharge status
- ld hl,MustRechargeText
+ ld hl, wPlayerBattleStatus2
+ bit NEEDS_TO_RECHARGE, [hl]
+ jr z, .AnyMoveDisabledCheck
+ res NEEDS_TO_RECHARGE, [hl] ; reset player's recharge status
+ ld hl, MustRechargeText
call PrintText
- ld hl,ExecutePlayerMoveDone ; player can't move this turn
+ ld hl, ExecutePlayerMoveDone ; player can't move this turn
jp .returnToHL
.AnyMoveDisabledCheck
- ld hl,wPlayerDisabledMove
- ld a,[hl]
+ ld hl, wPlayerDisabledMove
+ ld a, [hl]
and a
- jr z,.ConfusedCheck
+ jr z, .ConfusedCheck
dec a
- ld [hl],a
+ ld [hl], a
and $f ; did Disable counter hit 0?
- jr nz,.ConfusedCheck
- ld [hl],a
- ld [wPlayerDisabledMoveNumber],a
- ld hl,DisabledNoMoreText
+ jr nz, .ConfusedCheck
+ ld [hl], a
+ ld [wPlayerDisabledMoveNumber], a
+ ld hl, DisabledNoMoreText
call PrintText
.ConfusedCheck
- ld a,[wPlayerBattleStatus1]
+ ld a, [wPlayerBattleStatus1]
add a ; is player confused?
- jr nc,.TriedToUseDisabledMoveCheck
- ld hl,wPlayerConfusedCounter
+ jr nc, .TriedToUseDisabledMoveCheck
+ ld hl, wPlayerConfusedCounter
dec [hl]
- jr nz,.IsConfused
- ld hl,wPlayerBattleStatus1
- res Confused,[hl] ; if confused counter hit 0, reset confusion status
- ld hl,ConfusedNoMoreText
+ jr nz, .IsConfused
+ ld hl, wPlayerBattleStatus1
+ res CONFUSED, [hl] ; if confused counter hit 0, reset confusion status
+ ld hl, ConfusedNoMoreText
call PrintText
jr .TriedToUseDisabledMoveCheck
.IsConfused
- ld hl,IsConfusedText
+ ld hl, IsConfusedText
call PrintText
xor a
- ld [wAnimationType],a
- ld a,CONF_ANIM - 1
+ ld [wAnimationType], a
+ ld a, CONF_ANIM - 1
call PlayMoveAnimation
call BattleRandom
- cp a,$80 ; 50% chance to hurt itself
- jr c,.TriedToUseDisabledMoveCheck
- ld hl,wPlayerBattleStatus1
- ld a,[hl]
- and a, 1 << Confused ; if mon hurts itself, clear every other status from wPlayerBattleStatus1
- ld [hl],a
+ cp $80 ; 50% chance to hurt itself
+ jr c, .TriedToUseDisabledMoveCheck
+ ld hl, wPlayerBattleStatus1
+ ld a, [hl]
+ and 1 << CONFUSED ; if mon hurts itself, clear every other status from wPlayerBattleStatus1
+ ld [hl], a
call HandleSelfConfusionDamage
jr .MonHurtItselfOrFullyParalysed
.TriedToUseDisabledMoveCheck
; prevents a disabled move that was selected before being disabled from being used
- ld a,[wPlayerDisabledMoveNumber]
+ ld a, [wPlayerDisabledMoveNumber]
and a
- jr z,.ParalysisCheck
- ld hl,wPlayerSelectedMove
+ jr z, .ParalysisCheck
+ ld hl, wPlayerSelectedMove
cp [hl]
- jr nz,.ParalysisCheck
+ jr nz, .ParalysisCheck
call PrintMoveIsDisabledText
- ld hl,ExecutePlayerMoveDone ; if a disabled move was somehow selected, player can't move this turn
+ ld hl, ExecutePlayerMoveDone ; if a disabled move was somehow selected, player can't move this turn
jp .returnToHL
.ParalysisCheck
- ld hl,wBattleMonStatus
- bit PAR,[hl]
- jr z,.BideCheck
+ ld hl, wBattleMonStatus
+ bit PAR, [hl]
+ jr z, .BideCheck
call BattleRandom
- cp a,$3F ; 25% to be fully paralyzed
- jr nc,.BideCheck
- ld hl,FullyParalyzedText
+ cp $3F ; 25% to be fully paralyzed
+ jr nc, .BideCheck
+ ld hl, FullyParalyzedText
call PrintText
.MonHurtItselfOrFullyParalysed
- ld hl,wPlayerBattleStatus1
- ld a,[hl]
+ ld hl, wPlayerBattleStatus1
+ ld a, [hl]
; clear bide, thrashing, charging up, and trapping moves such as warp (already cleared for confusion damage)
- and $ff ^ ((1 << StoringEnergy) | (1 << ThrashingAbout) | (1 << ChargingUp) | (1 << UsingTrappingMove))
- ld [hl],a
- ld a,[wPlayerMoveEffect]
- cp a,FLY_EFFECT
- jr z,.FlyOrChargeEffect
- cp a,CHARGE_EFFECT
- jr z,.FlyOrChargeEffect
+ and $ff ^ ((1 << STORING_ENERGY) | (1 << THRASHING_ABOUT) | (1 << CHARGING_UP) | (1 << USING_TRAPPING_MOVE))
+ ld [hl], a
+ ld a, [wPlayerMoveEffect]
+ cp FLY_EFFECT
+ jr z, .FlyOrChargeEffect
+ cp CHARGE_EFFECT
+ jr z, .FlyOrChargeEffect
jr .NotFlyOrChargeEffect
.FlyOrChargeEffect
xor a
- ld [wAnimationType],a
- ld a,STATUS_AFFECTED_ANIM
+ ld [wAnimationType], a
+ ld a, STATUS_AFFECTED_ANIM
call PlayMoveAnimation
.NotFlyOrChargeEffect
- ld hl,ExecutePlayerMoveDone
+ ld hl, ExecutePlayerMoveDone
jp .returnToHL ; if using a two-turn move, we need to recharge the first turn
.BideCheck
- ld hl,wPlayerBattleStatus1
- bit StoringEnergy,[hl] ; is mon using bide?
- jr z,.ThrashingAboutCheck
- xor a
- ld [wPlayerMoveNum],a
- ld hl,wDamage
- ld a,[hli]
- ld b,a
- ld c,[hl]
- ld hl,wPlayerBideAccumulatedDamage + 1
- ld a,[hl]
- add c ; acumulate damage taken
- ld [hld],a
- ld a,[hl]
+ ld hl, wPlayerBattleStatus1
+ bit STORING_ENERGY, [hl] ; is mon using bide?
+ jr z, .ThrashingAboutCheck
+ xor a
+ ld [wPlayerMoveNum], a
+ ld hl, wDamage
+ ld a, [hli]
+ ld b, a
+ ld c, [hl]
+ ld hl, wPlayerBideAccumulatedDamage + 1
+ ld a, [hl]
+ add c ; accumulate damage taken
+ ld [hld], a
+ ld a, [hl]
adc b
- ld [hl],a
- ld hl,wPlayerNumAttacksLeft
+ ld [hl], a
+ ld hl, wPlayerNumAttacksLeft
dec [hl] ; did Bide counter hit 0?
- jr z,.UnleashEnergy
- ld hl,ExecutePlayerMoveDone
+ jr z, .UnleashEnergy
+ ld hl, ExecutePlayerMoveDone
jp .returnToHL ; unless mon unleashes energy, can't move this turn
.UnleashEnergy
- ld hl,wPlayerBattleStatus1
- res StoringEnergy,[hl] ; not using bide any more
- ld hl,UnleashedEnergyText
+ ld hl, wPlayerBattleStatus1
+ res STORING_ENERGY, [hl] ; not using bide any more
+ ld hl, UnleashedEnergyText
call PrintText
- ld a,1
- ld [wPlayerMovePower],a
- ld hl,wPlayerBideAccumulatedDamage + 1
- ld a,[hld]
+ ld a, 1
+ ld [wPlayerMovePower], a
+ ld hl, wPlayerBideAccumulatedDamage + 1
+ ld a, [hld]
add a
- ld b,a
- ld [wDamage + 1],a
- ld a,[hl]
+ ld b, a
+ ld [wDamage + 1], a
+ ld a, [hl]
rl a ; double the damage
- ld [wDamage],a
+ ld [wDamage], a
or b
- jr nz,.next
- ld a,1
- ld [wMoveMissed],a
+ jr nz, .next
+ ld a, 1
+ ld [wMoveMissed], a
.next
xor a
- ld [hli],a
- ld [hl],a
- ld a,BIDE
- ld [wPlayerMoveNum],a
- ld hl,handleIfPlayerMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest
+ ld [hli], a
+ ld [hl], a
+ ld a, BIDE
+ ld [wPlayerMoveNum], a
+ ld hl, handleIfPlayerMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest
jp .returnToHL
.ThrashingAboutCheck
- bit ThrashingAbout,[hl] ; is mon using thrash or petal dance?
- jr z,.MultiturnMoveCheck
- ld a,THRASH
- ld [wPlayerMoveNum],a
- ld hl,ThrashingAboutText
+ bit THRASHING_ABOUT, [hl] ; is mon using thrash or petal dance?
+ jr z, .MultiturnMoveCheck
+ ld a, THRASH
+ ld [wPlayerMoveNum], a
+ ld hl, ThrashingAboutText
call PrintText
- ld hl,wPlayerNumAttacksLeft
+ ld hl, wPlayerNumAttacksLeft
dec [hl] ; did Thrashing About counter hit 0?
- ld hl,PlayerCalcMoveDamage ; skip DecrementPP
- jp nz,.returnToHL
+ ld hl, PlayerCalcMoveDamage ; skip DecrementPP
+ jp nz, .returnToHL
push hl
- ld hl,wPlayerBattleStatus1
- res ThrashingAbout,[hl] ; no longer thrashing about
- set Confused,[hl] ; confused
+ ld hl, wPlayerBattleStatus1
+ res THRASHING_ABOUT, [hl] ; no longer thrashing about
+ set CONFUSED, [hl] ; confused
call BattleRandom
- and a,3
+ and 3
inc a
inc a ; confused for 2-5 turns
- ld [wPlayerConfusedCounter],a
+ ld [wPlayerConfusedCounter], a
pop hl ; skip DecrementPP
jp .returnToHL
.MultiturnMoveCheck
- bit UsingTrappingMove,[hl] ; is mon using multi-turn move?
- jp z,.RageCheck
- ld hl,AttackContinuesText
+ bit USING_TRAPPING_MOVE, [hl] ; is mon using multi-turn move?
+ jp z, .RageCheck
+ ld hl, AttackContinuesText
call PrintText
- ld a,[wPlayerNumAttacksLeft]
+ ld a, [wPlayerNumAttacksLeft]
dec a ; did multi-turn move end?
- ld [wPlayerNumAttacksLeft],a
- ld hl,getPlayerAnimationType ; if it didn't, skip damage calculation (deal damage equal to last hit),
+ ld [wPlayerNumAttacksLeft], a
+ ld hl, getPlayerAnimationType ; if it didn't, skip damage calculation (deal damage equal to last hit),
; DecrementPP and MoveHitTest
- jp nz,.returnToHL
+ jp nz, .returnToHL
jp .returnToHL
.RageCheck
ld a, [wPlayerBattleStatus2]
- bit UsingRage, a ; is mon using rage?
+ bit USING_RAGE, a ; is mon using rage?
jp z, .checkPlayerStatusConditionsDone ; if we made it this far, mon can move normally this turn
ld a, RAGE
ld [wd11e], a
@@ -3873,7 +3873,7 @@ PrintMoveIsDisabledText:
ld de, wEnemyBattleStatus1
.removeChargingUp
ld a, [de]
- res ChargingUp, a ; end the pokemon's
+ res CHARGING_UP, a ; end the pokemon's
ld [de], a
ld a, [hl]
ld [wd11e], a
@@ -4409,7 +4409,7 @@ GetDamageVarsForPlayerAttack:
ld b, a
ld c, [hl] ; bc = enemy defense
ld a, [wEnemyBattleStatus3]
- bit HasReflectUp, a ; check for Reflect
+ bit HAS_REFLECT_UP, a ; check for Reflect
jr z, .physicalAttackCritCheck
; if the enemy has used Reflect, double the enemy's defense
sla c
@@ -4439,13 +4439,13 @@ GetDamageVarsForPlayerAttack:
ld b, a
ld c, [hl] ; bc = enemy special
ld a, [wEnemyBattleStatus3]
- bit HasLightScreenUp, a ; check for Light Screen
+ bit HAS_LIGHT_SCREEN_UP, a ; check for Light Screen
jr z, .specialAttackCritCheck
; if the enemy has used Light Screen, double the enemy's special
sla c
rl b
; reflect and light screen boosts do not cap the stat at 999, so weird things will happen during stats scaling if
-; a Pokemon with 512 or more Defense has ued Reflect, or if a Pokemon with 512 or more Special has used Light Screen
+; a Pokemon with 512 or more Defense has used Reflect, or if a Pokemon with 512 or more Special has used Light Screen
.specialAttackCritCheck
ld hl, wBattleMonSpecial
ld a, [wCriticalHitOrOHKO]
@@ -4522,7 +4522,7 @@ GetDamageVarsForEnemyAttack:
ld b, a
ld c, [hl] ; bc = player defense
ld a, [wPlayerBattleStatus3]
- bit HasReflectUp, a ; check for Reflect
+ bit HAS_REFLECT_UP, a ; check for Reflect
jr z, .physicalAttackCritCheck
; if the player has used Reflect, double the player's defense
sla c
@@ -4552,13 +4552,13 @@ GetDamageVarsForEnemyAttack:
ld b, a
ld c, [hl]
ld a, [wPlayerBattleStatus3]
- bit HasLightScreenUp, a ; check for Light Screen
+ bit HAS_LIGHT_SCREEN_UP, a ; check for Light Screen
jr z, .specialAttackCritCheck
; if the player has used Light Screen, double the player's special
sla c
rl b
; reflect and light screen boosts do not cap the stat at 999, so weird things will happen during stats scaling if
-; a Pokemon with 512 or more Defense has ued Reflect, or if a Pokemon with 512 or more Special has used Light Screen
+; a Pokemon with 512 or more Defense has used Reflect, or if a Pokemon with 512 or more Special has used Light Screen
.specialAttackCritCheck
ld hl, wEnemyMonSpecial
ld a, [wCriticalHitOrOHKO]
@@ -4661,10 +4661,10 @@ GetEnemyMonStat:
CalculateDamage:
; input:
-; b: attack
-; c: opponent defense
-; d: base power
-; e: level
+; b: attack
+; c: opponent defense
+; d: base power
+; e: level
ld a, [H_WHOSETURN] ; whose turn?
and a
@@ -4674,7 +4674,7 @@ CalculateDamage:
.effect
; EXPLODE_EFFECT halves defense.
- cp a, EXPLODE_EFFECT
+ cp EXPLODE_EFFECT
jr nz, .ok
srl c
jr nz, .ok
@@ -4682,13 +4682,13 @@ CalculateDamage:
.ok
; Multi-hit attacks may or may not have 0 bp.
- cp a, TWO_TO_FIVE_ATTACKS_EFFECT
+ cp TWO_TO_FIVE_ATTACKS_EFFECT
jr z, .skipbp
- cp a, $1e
+ cp $1e
jr z, .skipbp
; Calculate OHKO damage based on remaining HP.
- cp a, OHKO_EFFECT
+ cp OHKO_EFFECT
jp z, JumpToOHKOMoveEffect
; Don't calculate damage for moves that don't do any.
@@ -4866,7 +4866,7 @@ CriticalHitTest:
dec hl
ld c, [hl] ; read move id
ld a, [de]
- bit GettingPumped, a ; test for focus energy
+ bit GETTING_PUMPED, a ; test for focus energy
jr nz, .focusEnergyUsed ; bug: using focus energy causes a shift to the right instead of left,
; resulting in 1/4 the usual crit chance
sla b ; (effective (base speed/2)*2)
@@ -4921,297 +4921,297 @@ HandleCounterMove:
; the outcome may be affected by the player's actions in the move selection menu prior to switching the Pokemon.
; This might also lead to desync glitches in link battles.
- ld a,[H_WHOSETURN] ; whose turn
+ ld a, [H_WHOSETURN] ; whose turn
and a
; player's turn
- ld hl,wEnemySelectedMove
- ld de,wEnemyMovePower
- ld a,[wPlayerSelectedMove]
- jr z,.next
+ ld hl, wEnemySelectedMove
+ ld de, wEnemyMovePower
+ ld a, [wPlayerSelectedMove]
+ jr z, .next
; enemy's turn
- ld hl,wPlayerSelectedMove
- ld de,wPlayerMovePower
- ld a,[wEnemySelectedMove]
+ ld hl, wPlayerSelectedMove
+ ld de, wPlayerMovePower
+ ld a, [wEnemySelectedMove]
.next
- cp a,COUNTER
+ cp COUNTER
ret nz ; return if not using Counter
- ld a,$01
- ld [wMoveMissed],a ; initialize the move missed variable to true (it is set to false below if the move hits)
- ld a,[hl]
- cp a,COUNTER
+ ld a, $01
+ ld [wMoveMissed], a ; initialize the move missed variable to true (it is set to false below if the move hits)
+ ld a, [hl]
+ cp COUNTER
ret z ; miss if the opponent's last selected move is Counter.
- ld a,[de]
+ ld a, [de]
and a
ret z ; miss if the opponent's last selected move's Base Power is 0.
; check if the move the target last selected was Normal or Fighting type
inc de
- ld a,[de]
+ ld a, [de]
and a ; normal type
- jr z,.counterableType
- cp a,FIGHTING
- jr z,.counterableType
+ jr z, .counterableType
+ cp FIGHTING
+ jr z, .counterableType
; if the move wasn't Normal or Fighting type, miss
xor a
ret
.counterableType
- ld hl,wDamage
- ld a,[hli]
+ ld hl, wDamage
+ ld a, [hli]
or [hl]
ret z ; If we made it here, Counter still misses if the last move used in battle did no damage to its target.
; wDamage is shared by both players, so Counter may strike back damage dealt by the Counter user itself
; if the conditions meet, even though 99% of the times damage will come from the target.
; if it did damage, double it
- ld a,[hl]
+ ld a, [hl]
add a
- ldd [hl],a
- ld a,[hl]
+ ldd [hl], a
+ ld a, [hl]
adc a
- ld [hl],a
- jr nc,.noCarry
+ ld [hl], a
+ jr nc, .noCarry
; damage is capped at 0xFFFF
- ld a,$ff
- ld [hli],a
- ld [hl],a
+ ld a, $ff
+ ld [hli], a
+ ld [hl], a
.noCarry
xor a
- ld [wMoveMissed],a
+ ld [wMoveMissed], a
call MoveHitTest ; do the normal move hit test in addition to Counter's special rules
xor a
ret
ApplyAttackToEnemyPokemon:
- ld a,[wPlayerMoveEffect]
- cp a,OHKO_EFFECT
- jr z,ApplyDamageToEnemyPokemon
- cp a,SUPER_FANG_EFFECT
- jr z,.superFangEffect
- cp a,SPECIAL_DAMAGE_EFFECT
- jr z,.specialDamage
- ld a,[wPlayerMovePower]
- and a
- jp z,ApplyAttackToEnemyPokemonDone ; no attack to apply if base power is 0
+ ld a, [wPlayerMoveEffect]
+ cp OHKO_EFFECT
+ jr z, ApplyDamageToEnemyPokemon
+ cp SUPER_FANG_EFFECT
+ jr z, .superFangEffect
+ cp SPECIAL_DAMAGE_EFFECT
+ jr z, .specialDamage
+ ld a, [wPlayerMovePower]
+ and a
+ jp z, ApplyAttackToEnemyPokemonDone ; no attack to apply if base power is 0
jr ApplyDamageToEnemyPokemon
.superFangEffect
; set the damage to half the target's HP
- ld hl,wEnemyMonHP
- ld de,wDamage
- ld a,[hli]
+ ld hl, wEnemyMonHP
+ ld de, wDamage
+ ld a, [hli]
srl a
- ld [de],a
+ ld [de], a
inc de
- ld b,a
- ld a,[hl]
+ ld b, a
+ ld a, [hl]
rr a
- ld [de],a
+ ld [de], a
or b
- jr nz,ApplyDamageToEnemyPokemon
+ jr nz, ApplyDamageToEnemyPokemon
; make sure Super Fang's damage is always at least 1
- ld a,$01
- ld [de],a
+ ld a, $01
+ ld [de], a
jr ApplyDamageToEnemyPokemon
.specialDamage
- ld hl,wBattleMonLevel
- ld a,[hl]
- ld b,a ; Seismic Toss deals damage equal to the user's level
- ld a,[wPlayerMoveNum]
- cp a,SEISMIC_TOSS
- jr z,.storeDamage
- cp a,NIGHT_SHADE
- jr z,.storeDamage
- ld b,SONICBOOM_DAMAGE ; 20
- cp a,SONICBOOM
- jr z,.storeDamage
- ld b,DRAGON_RAGE_DAMAGE ; 40
- cp a,DRAGON_RAGE
- jr z,.storeDamage
+ ld hl, wBattleMonLevel
+ ld a, [hl]
+ ld b, a ; Seismic Toss deals damage equal to the user's level
+ ld a, [wPlayerMoveNum]
+ cp SEISMIC_TOSS
+ jr z, .storeDamage
+ cp NIGHT_SHADE
+ jr z, .storeDamage
+ ld b, SONICBOOM_DAMAGE ; 20
+ cp SONICBOOM
+ jr z, .storeDamage
+ ld b, DRAGON_RAGE_DAMAGE ; 40
+ cp DRAGON_RAGE
+ jr z, .storeDamage
; Psywave
- ld a,[hl]
- ld b,a
+ ld a, [hl]
+ ld b, a
srl a
add b
- ld b,a ; b = level * 1.5
+ ld b, a ; b = level * 1.5
; loop until a random number in the range [1, b) is found
.loop
call BattleRandom
and a
- jr z,.loop
+ jr z, .loop
cp b
- jr nc,.loop
- ld b,a
+ jr nc, .loop
+ ld b, a
.storeDamage ; store damage value at b
- ld hl,wDamage
+ ld hl, wDamage
xor a
- ld [hli],a
- ld a,b
- ld [hl],a
+ ld [hli], a
+ ld a, b
+ ld [hl], a
ApplyDamageToEnemyPokemon:
- ld hl,wDamage
- ld a,[hli]
- ld b,a
- ld a,[hl]
+ ld hl, wDamage
+ ld a, [hli]
+ ld b, a
+ ld a, [hl]
or b
- jr z,ApplyAttackToEnemyPokemonDone ; we're done if damage is 0
- ld a,[wEnemyBattleStatus2]
- bit HasSubstituteUp,a ; does the enemy have a substitute?
- jp nz,AttackSubstitute
+ jr z, ApplyAttackToEnemyPokemonDone ; we're done if damage is 0
+ ld a, [wEnemyBattleStatus2]
+ bit HAS_SUBSTITUTE_UP, a ; does the enemy have a substitute?
+ jp nz, AttackSubstitute
; subtract the damage from the pokemon's current HP
; also, save the current HP at wHPBarOldHP
- ld a,[hld]
- ld b,a
- ld a,[wEnemyMonHP + 1]
- ld [wHPBarOldHP],a
+ ld a, [hld]
+ ld b, a
+ ld a, [wEnemyMonHP + 1]
+ ld [wHPBarOldHP], a
sub b
- ld [wEnemyMonHP + 1],a
- ld a,[hl]
- ld b,a
- ld a,[wEnemyMonHP]
- ld [wHPBarOldHP+1],a
+ ld [wEnemyMonHP + 1], a
+ ld a, [hl]
+ ld b, a
+ ld a, [wEnemyMonHP]
+ ld [wHPBarOldHP+1], a
sbc b
- ld [wEnemyMonHP],a
- jr nc,.animateHpBar
+ ld [wEnemyMonHP], a
+ jr nc, .animateHpBar
; if more damage was done than the current HP, zero the HP and set the damage (wDamage)
; equal to how much HP the pokemon had before the attack
- ld a,[wHPBarOldHP+1]
- ld [hli],a
- ld a,[wHPBarOldHP]
- ld [hl],a
- xor a
- ld hl,wEnemyMonHP
- ld [hli],a
- ld [hl],a
+ ld a, [wHPBarOldHP+1]
+ ld [hli], a
+ ld a, [wHPBarOldHP]
+ ld [hl], a
+ xor a
+ ld hl, wEnemyMonHP
+ ld [hli], a
+ ld [hl], a
.animateHpBar
- ld hl,wEnemyMonMaxHP
- ld a,[hli]
- ld [wHPBarMaxHP+1],a
- ld a,[hl]
- ld [wHPBarMaxHP],a
- ld hl,wEnemyMonHP
- ld a,[hli]
- ld [wHPBarNewHP+1],a
- ld a,[hl]
- ld [wHPBarNewHP],a
+ ld hl, wEnemyMonMaxHP
+ ld a, [hli]
+ ld [wHPBarMaxHP+1], a
+ ld a, [hl]
+ ld [wHPBarMaxHP], a
+ ld hl, wEnemyMonHP
+ ld a, [hli]
+ ld [wHPBarNewHP+1], a
+ ld a, [hl]
+ ld [wHPBarNewHP], a
coord hl, 2, 2
xor a
- ld [wHPBarType],a
+ ld [wHPBarType], a
predef UpdateHPBar2 ; animate the HP bar shortening
ApplyAttackToEnemyPokemonDone:
jp DrawHUDsAndHPBars
ApplyAttackToPlayerPokemon:
- ld a,[wEnemyMoveEffect]
- cp a,OHKO_EFFECT
- jr z,ApplyDamageToPlayerPokemon
- cp a,SUPER_FANG_EFFECT
- jr z,.superFangEffect
- cp a,SPECIAL_DAMAGE_EFFECT
- jr z,.specialDamage
- ld a,[wEnemyMovePower]
- and a
- jp z,ApplyAttackToPlayerPokemonDone
+ ld a, [wEnemyMoveEffect]
+ cp OHKO_EFFECT
+ jr z, ApplyDamageToPlayerPokemon
+ cp SUPER_FANG_EFFECT
+ jr z, .superFangEffect
+ cp SPECIAL_DAMAGE_EFFECT
+ jr z, .specialDamage
+ ld a, [wEnemyMovePower]
+ and a
+ jp z, ApplyAttackToPlayerPokemonDone
jr ApplyDamageToPlayerPokemon
.superFangEffect
; set the damage to half the target's HP
- ld hl,wBattleMonHP
- ld de,wDamage
- ld a,[hli]
+ ld hl, wBattleMonHP
+ ld de, wDamage
+ ld a, [hli]
srl a
- ld [de],a
+ ld [de], a
inc de
- ld b,a
- ld a,[hl]
+ ld b, a
+ ld a, [hl]
rr a
- ld [de],a
+ ld [de], a
or b
- jr nz,ApplyDamageToPlayerPokemon
+ jr nz, ApplyDamageToPlayerPokemon
; make sure Super Fang's damage is always at least 1
- ld a,$01
- ld [de],a
+ ld a, $01
+ ld [de], a
jr ApplyDamageToPlayerPokemon
.specialDamage
- ld hl,wEnemyMonLevel
- ld a,[hl]
- ld b,a
- ld a,[wEnemyMoveNum]
- cp a,SEISMIC_TOSS
- jr z,.storeDamage
- cp a,NIGHT_SHADE
- jr z,.storeDamage
- ld b,SONICBOOM_DAMAGE
- cp a,SONICBOOM
- jr z,.storeDamage
- ld b,DRAGON_RAGE_DAMAGE
- cp a,DRAGON_RAGE
- jr z,.storeDamage
+ ld hl, wEnemyMonLevel
+ ld a, [hl]
+ ld b, a
+ ld a, [wEnemyMoveNum]
+ cp SEISMIC_TOSS
+ jr z, .storeDamage
+ cp NIGHT_SHADE
+ jr z, .storeDamage
+ ld b, SONICBOOM_DAMAGE
+ cp SONICBOOM
+ jr z, .storeDamage
+ ld b, DRAGON_RAGE_DAMAGE
+ cp DRAGON_RAGE
+ jr z, .storeDamage
; Psywave
- ld a,[hl]
- ld b,a
+ ld a, [hl]
+ ld b, a
srl a
add b
- ld b,a ; b = attacker's level * 1.5
+ ld b, a ; b = attacker's level * 1.5
; loop until a random number in the range [0, b) is found
; this differs from the range when the player attacks, which is [1, b)
; it's possible for the enemy to do 0 damage with Psywave, but the player always does at least 1 damage
.loop
call BattleRandom
cp b
- jr nc,.loop
- ld b,a
+ jr nc, .loop
+ ld b, a
.storeDamage
- ld hl,wDamage
+ ld hl, wDamage
xor a
- ld [hli],a
- ld a,b
- ld [hl],a
+ ld [hli], a
+ ld a, b
+ ld [hl], a
ApplyDamageToPlayerPokemon:
- ld hl,wDamage
- ld a,[hli]
- ld b,a
- ld a,[hl]
+ ld hl, wDamage
+ ld a, [hli]
+ ld b, a
+ ld a, [hl]
or b
- jr z,ApplyAttackToPlayerPokemonDone ; we're done if damage is 0
- ld a,[wPlayerBattleStatus2]
- bit HasSubstituteUp,a ; does the player have a substitute?
- jp nz,AttackSubstitute
+ jr z, ApplyAttackToPlayerPokemonDone ; we're done if damage is 0
+ ld a, [wPlayerBattleStatus2]
+ bit HAS_SUBSTITUTE_UP, a ; does the player have a substitute?
+ jp nz, AttackSubstitute
; subtract the damage from the pokemon's current HP
; also, save the current HP at wHPBarOldHP and the new HP at wHPBarNewHP
- ld a,[hld]
- ld b,a
- ld a,[wBattleMonHP + 1]
- ld [wHPBarOldHP],a
+ ld a, [hld]
+ ld b, a
+ ld a, [wBattleMonHP + 1]
+ ld [wHPBarOldHP], a
sub b
- ld [wBattleMonHP + 1],a
- ld [wHPBarNewHP],a
- ld b,[hl]
- ld a,[wBattleMonHP]
- ld [wHPBarOldHP+1],a
+ ld [wBattleMonHP + 1], a
+ ld [wHPBarNewHP], a
+ ld b, [hl]
+ ld a, [wBattleMonHP]
+ ld [wHPBarOldHP+1], a
sbc b
- ld [wBattleMonHP],a
- ld [wHPBarNewHP+1],a
- jr nc,.animateHpBar
+ ld [wBattleMonHP], a
+ ld [wHPBarNewHP+1], a
+ jr nc, .animateHpBar
; if more damage was done than the current HP, zero the HP and set the damage (wDamage)
; equal to how much HP the pokemon had before the attack
- ld a,[wHPBarOldHP+1]
- ld [hli],a
- ld a,[wHPBarOldHP]
- ld [hl],a
- xor a
- ld hl,wBattleMonHP
- ld [hli],a
- ld [hl],a
- ld hl,wHPBarNewHP
- ld [hli],a
- ld [hl],a
+ ld a, [wHPBarOldHP+1]
+ ld [hli], a
+ ld a, [wHPBarOldHP]
+ ld [hl], a
+ xor a
+ ld hl, wBattleMonHP
+ ld [hli], a
+ ld [hl], a
+ ld hl, wHPBarNewHP
+ ld [hli], a
+ ld [hl], a
.animateHpBar
- ld hl,wBattleMonMaxHP
- ld a,[hli]
- ld [wHPBarMaxHP+1],a
- ld a,[hl]
- ld [wHPBarMaxHP],a
+ ld hl, wBattleMonMaxHP
+ ld a, [hli]
+ ld [wHPBarMaxHP+1], a
+ ld a, [hl]
+ ld [wHPBarMaxHP], a
coord hl, 10, 9
- ld a,$01
- ld [wHPBarType],a
+ ld a, $01
+ ld [wHPBarType], a
predef UpdateHPBar2 ; animate the HP bar shortening
ApplyAttackToPlayerPokemonDone:
jp DrawHUDsAndHPBars
@@ -5224,51 +5224,51 @@ AttackSubstitute:
; Normal recoil such as from Double-Edge isn't affected by this glitch,
; because this function is never called in that case.
- ld hl,SubstituteTookDamageText
+ ld hl, SubstituteTookDamageText
call PrintText
; values for player turn
- ld de,wEnemySubstituteHP
- ld bc,wEnemyBattleStatus2
- ld a,[H_WHOSETURN]
+ ld de, wEnemySubstituteHP
+ ld bc, wEnemyBattleStatus2
+ ld a, [H_WHOSETURN]
and a
- jr z,.applyDamageToSubstitute
+ jr z, .applyDamageToSubstitute
; values for enemy turn
- ld de,wPlayerSubstituteHP
- ld bc,wPlayerBattleStatus2
+ ld de, wPlayerSubstituteHP
+ ld bc, wPlayerBattleStatus2
.applyDamageToSubstitute
- ld hl,wDamage
- ld a,[hli]
+ ld hl, wDamage
+ ld a, [hli]
and a
- jr nz,.substituteBroke ; damage > 0xFF always breaks substitutes
+ jr nz, .substituteBroke ; damage > 0xFF always breaks substitutes
; subtract damage from HP of substitute
- ld a,[de]
+ ld a, [de]
sub [hl]
- ld [de],a
+ ld [de], a
ret nc
.substituteBroke
; If the target's Substitute breaks, wDamage isn't updated with the amount of HP
; the Substitute had before being attacked.
- ld h,b
- ld l,c
- res HasSubstituteUp,[hl] ; unset the substitute bit
- ld hl,SubstituteBrokeText
+ ld h, b
+ ld l, c
+ res HAS_SUBSTITUTE_UP, [hl] ; unset the substitute bit
+ ld hl, SubstituteBrokeText
call PrintText
; flip whose turn it is for the next function call
- ld a,[H_WHOSETURN]
- xor a,$01
- ld [H_WHOSETURN],a
+ ld a, [H_WHOSETURN]
+ xor $01
+ ld [H_WHOSETURN], a
callab Func_79929 ; animate the substitute breaking
; flip the turn back to the way it was
- ld a,[H_WHOSETURN]
- xor a,$01
- ld [H_WHOSETURN],a
- ld hl,wPlayerMoveEffect ; value for player's turn
+ ld a, [H_WHOSETURN]
+ xor $01
+ ld [H_WHOSETURN], a
+ ld hl, wPlayerMoveEffect ; value for player's turn
and a
- jr z,.nullifyEffect
- ld hl,wEnemyMoveEffect ; value for enemy's turn
+ jr z, .nullifyEffect
+ ld hl, wEnemyMoveEffect ; value for enemy's turn
.nullifyEffect
xor a
- ld [hl],a ; zero the effect of the attacker's move
+ ld [hl], a ; zero the effect of the attacker's move
jp DrawHUDsAndHPBars
SubstituteTookDamageText:
@@ -5282,44 +5282,44 @@ SubstituteBrokeText:
; this function raises the attack modifier of a pokemon using Rage when that pokemon is attacked
HandleBuildingRage:
; values for the player turn
- ld hl,wEnemyBattleStatus2
- ld de,wEnemyMonStatMods
- ld bc,wEnemyMoveNum
- ld a,[H_WHOSETURN]
+ ld hl, wEnemyBattleStatus2
+ ld de, wEnemyMonStatMods
+ ld bc, wEnemyMoveNum
+ ld a, [H_WHOSETURN]
and a
- jr z,.next
+ jr z, .next
; values for the enemy turn
- ld hl,wPlayerBattleStatus2
- ld de,wPlayerMonStatMods
- ld bc,wPlayerMoveNum
+ ld hl, wPlayerBattleStatus2
+ ld de, wPlayerMonStatMods
+ ld bc, wPlayerMoveNum
.next
- bit UsingRage,[hl] ; is the pokemon being attacked under the effect of Rage?
+ bit USING_RAGE, [hl] ; is the pokemon being attacked under the effect of Rage?
ret z ; return if not
- ld a,[de]
- cp a,$0d ; maximum stat modifier value
+ ld a, [de]
+ cp $0d ; maximum stat modifier value
ret z ; return if attack modifier is already maxed
- ld a,[H_WHOSETURN]
- xor a,$01 ; flip turn for the stat modifier raising function
- ld [H_WHOSETURN],a
+ ld a, [H_WHOSETURN]
+ xor $01 ; flip turn for the stat modifier raising function
+ ld [H_WHOSETURN], a
; temporarily change the target pokemon's move to $00 and the effect to the one
; that causes the attack modifier to go up one stage
- ld h,b
- ld l,c
- ld [hl],$00 ; null move number
+ ld h, b
+ ld l, c
+ ld [hl], $00 ; null move number
inc hl
- ld [hl],ATTACK_UP1_EFFECT
+ ld [hl], ATTACK_UP1_EFFECT
push hl
- ld hl,BuildingRageText
+ ld hl, BuildingRageText
call PrintText
call StatModifierUpEffect ; stat modifier raising function
pop hl
xor a
- ldd [hl],a ; null move effect
- ld a,RAGE
- ld [hl],a ; restore the target pokemon's move number to Rage
- ld a,[H_WHOSETURN]
- xor a,$01 ; flip turn back to the way it was
- ld [H_WHOSETURN],a
+ ldd [hl], a ; null move effect
+ ld a, RAGE
+ ld [hl], a ; restore the target pokemon's move number to Rage
+ ld a, [H_WHOSETURN]
+ xor $01 ; flip turn back to the way it was
+ ld [H_WHOSETURN], a
ret
BuildingRageText:
@@ -5335,25 +5335,25 @@ MirrorMoveCopyMove:
; ccf1 is also set to 0 whenever the player is fast asleep or frozen solid.
; ccf2 is also set to 0 whenever the enemy is fast asleep or frozen solid.
- ld a,[H_WHOSETURN]
+ ld a, [H_WHOSETURN]
and a
; values for player turn
- ld a,[wEnemyUsedMove]
- ld hl,wPlayerSelectedMove
- ld de,wPlayerMoveNum
- jr z,.next
+ ld a, [wEnemyUsedMove]
+ ld hl, wPlayerSelectedMove
+ ld de, wPlayerMoveNum
+ jr z, .next
; values for enemy turn
- ld a,[wPlayerUsedMove]
- ld de,wEnemyMoveNum
- ld hl,wEnemySelectedMove
+ ld a, [wPlayerUsedMove]
+ ld de, wEnemyMoveNum
+ ld hl, wEnemySelectedMove
.next
- ld [hl],a
- cp a,MIRROR_MOVE ; did the target Pokemon last use Mirror Move, and miss?
- jr z,.mirrorMoveFailed
+ ld [hl], a
+ cp MIRROR_MOVE ; did the target Pokemon last use Mirror Move, and miss?
+ jr z, .mirrorMoveFailed
and a ; has the target selected any move yet?
- jr nz,ReloadMoveData
+ jr nz, ReloadMoveData
.mirrorMoveFailed
- ld hl,MirrorMoveFailedText
+ ld hl, MirrorMoveFailedText
call PrintText
xor a
ret
@@ -5364,78 +5364,78 @@ MirrorMoveFailedText:
; function used to reload move data for moves like Mirror Move and Metronome
ReloadMoveData:
- ld [wd11e],a
+ ld [wd11e], a
dec a
- ld hl,Moves
- ld bc,MoveEnd - Moves
+ ld hl, Moves
+ ld bc, MoveEnd - Moves
call AddNTimes
- ld a,BANK(Moves)
+ ld a, BANK(Moves)
call FarCopyData ; copy the move's stats
call IncrementMovePP
; the follow two function calls are used to reload the move name
call GetMoveName
call CopyStringToCF4B
- ld a,$01
+ ld a, $01
and a
ret
; function that picks a random move for metronome
MetronomePickMove:
xor a
- ld [wAnimationType],a
- ld a,METRONOME
+ ld [wAnimationType], a
+ ld a, METRONOME
call PlayMoveAnimation ; play Metronome's animation
; values for player turn
- ld de,wPlayerMoveNum
- ld hl,wPlayerSelectedMove
- ld a,[H_WHOSETURN]
+ ld de, wPlayerMoveNum
+ ld hl, wPlayerSelectedMove
+ ld a, [H_WHOSETURN]
and a
- jr z,.pickMoveLoop
+ jr z, .pickMoveLoop
; values for enemy turn
- ld de,wEnemyMoveNum
- ld hl,wEnemySelectedMove
+ ld de, wEnemyMoveNum
+ ld hl, wEnemySelectedMove
; loop to pick a random number in the range [1, $a5) to be the move used by Metronome
.pickMoveLoop
call BattleRandom
and a
- jr z,.pickMoveLoop
- cp a,NUM_ATTACKS + 1 ; max normal move number + 1 (this is Struggle's move number)
- jr nc,.pickMoveLoop
- cp a,METRONOME
- jr z,.pickMoveLoop
- ld [hl],a
+ jr z, .pickMoveLoop
+ cp NUM_ATTACKS + 1 ; max normal move number + 1 (this is Struggle's move number)
+ jr nc, .pickMoveLoop
+ cp METRONOME
+ jr z, .pickMoveLoop
+ ld [hl], a
jr ReloadMoveData
; this function increments the current move's PP
; it's used to prevent moves that run another move within the same turn
; (like Mirror Move and Metronome) from losing 2 PP
IncrementMovePP:
- ld a,[H_WHOSETURN]
+ ld a, [H_WHOSETURN]
and a
; values for player turn
- ld hl,wBattleMonPP
- ld de,wPartyMon1PP
- ld a,[wPlayerMoveListIndex]
- jr z,.next
+ ld hl, wBattleMonPP
+ ld de, wPartyMon1PP
+ ld a, [wPlayerMoveListIndex]
+ jr z, .next
; values for enemy turn
- ld hl,wEnemyMonPP
- ld de,wEnemyMon1PP
- ld a,[wEnemyMoveListIndex]
+ ld hl, wEnemyMonPP
+ ld de, wEnemyMon1PP
+ ld a, [wEnemyMoveListIndex]
.next
- ld b,$00
- ld c,a
- add hl,bc
+ ld b, $00
+ ld c, a
+ add hl, bc
inc [hl] ; increment PP in the currently battling pokemon memory location
- ld h,d
- ld l,e
- add hl,bc
- ld a,[H_WHOSETURN]
- and a
- ld a,[wPlayerMonNumber] ; value for player turn
- jr z,.updatePP
- ld a,[wEnemyMonPartyPos] ; value for enemy turn
+ ld h, d
+ ld l, e
+ add hl, bc
+ ld a, [H_WHOSETURN]
+ and a
+ ld a, [wPlayerMonNumber] ; value for player turn
+ jr z, .updatePP
+ ld a, [wEnemyMonPartyPos] ; value for enemy turn
.updatePP
- ld bc,wEnemyMon2 - wEnemyMon1
+ ld bc, wEnemyMon2 - wEnemyMon1
call AddNTimes
inc [hl] ; increment PP in the party memory location
ret
@@ -5443,107 +5443,107 @@ IncrementMovePP:
; function to adjust the base damage of an attack to account for type effectiveness
AdjustDamageForMoveType:
; values for player turn
- ld hl,wBattleMonType
- ld a,[hli]
- ld b,a ; b = type 1 of attacker
- ld c,[hl] ; c = type 2 of attacker
- ld hl,wEnemyMonType
- ld a,[hli]
- ld d,a ; d = type 1 of defender
- ld e,[hl] ; e = type 2 of defender
- ld a,[wPlayerMoveType]
- ld [wMoveType],a
- ld a,[H_WHOSETURN]
- and a
- jr z,.next
+ ld hl, wBattleMonType
+ ld a, [hli]
+ ld b, a ; b = type 1 of attacker
+ ld c, [hl] ; c = type 2 of attacker
+ ld hl, wEnemyMonType
+ ld a, [hli]
+ ld d, a ; d = type 1 of defender
+ ld e, [hl] ; e = type 2 of defender
+ ld a, [wPlayerMoveType]
+ ld [wMoveType], a
+ ld a, [H_WHOSETURN]
+ and a
+ jr z, .next
; values for enemy turn
- ld hl,wEnemyMonType
- ld a,[hli]
- ld b,a ; b = type 1 of attacker
- ld c,[hl] ; c = type 2 of attacker
- ld hl,wBattleMonType
- ld a,[hli]
- ld d,a ; d = type 1 of defender
- ld e,[hl] ; e = type 2 of defender
- ld a,[wEnemyMoveType]
- ld [wMoveType],a
+ ld hl, wEnemyMonType
+ ld a, [hli]
+ ld b, a ; b = type 1 of attacker
+ ld c, [hl] ; c = type 2 of attacker
+ ld hl, wBattleMonType
+ ld a, [hli]
+ ld d, a ; d = type 1 of defender
+ ld e, [hl] ; e = type 2 of defender
+ ld a, [wEnemyMoveType]
+ ld [wMoveType], a
.next
- ld a,[wMoveType]
+ ld a, [wMoveType]
cp b ; does the move type match type 1 of the attacker?
- jr z,.sameTypeAttackBonus
+ jr z, .sameTypeAttackBonus
cp c ; does the move type match type 2 of the attacker?
- jr z,.sameTypeAttackBonus
+ jr z, .sameTypeAttackBonus
jr .skipSameTypeAttackBonus
.sameTypeAttackBonus
; if the move type matches one of the attacker's types
- ld hl,wDamage + 1
- ld a,[hld]
- ld h,[hl]
- ld l,a ; hl = damage
- ld b,h
- ld c,l ; bc = damage
+ ld hl, wDamage + 1
+ ld a, [hld]
+ ld h, [hl]
+ ld l, a ; hl = damage
+ ld b, h
+ ld c, l ; bc = damage
srl b
rr c ; bc = floor(0.5 * damage)
- add hl,bc ; hl = floor(1.5 * damage)
+ add hl, bc ; hl = floor(1.5 * damage)
; store damage
- ld a,h
- ld [wDamage],a
- ld a,l
- ld [wDamage + 1],a
- ld hl,wDamageMultipliers
- set 7,[hl]
+ ld a, h
+ ld [wDamage], a
+ ld a, l
+ ld [wDamage + 1], a
+ ld hl, wDamageMultipliers
+ set 7, [hl]
.skipSameTypeAttackBonus
- ld a,[wMoveType]
- ld b,a
- ld hl,TypeEffects
+ ld a, [wMoveType]
+ ld b, a
+ ld hl, TypeEffects
.loop
- ld a,[hli] ; a = "attacking type" of the current type pair
- cp a,$ff
- jr z,.done
+ ld a, [hli] ; a = "attacking type" of the current type pair
+ cp $ff
+ jr z, .done
cp b ; does move type match "attacking type"?
- jr nz,.nextTypePair
- ld a,[hl] ; a = "defending type" of the current type pair
+ jr nz, .nextTypePair
+ ld a, [hl] ; a = "defending type" of the current type pair
cp d ; does type 1 of defender match "defending type"?
- jr z,.matchingPairFound
+ jr z, .matchingPairFound
cp e ; does type 2 of defender match "defending type"?
- jr z,.matchingPairFound
+ jr z, .matchingPairFound
jr .nextTypePair
.matchingPairFound
; if the move type matches the "attacking type" and one of the defender's types matches the "defending type"
push hl
push bc
inc hl
- ld a,[wDamageMultipliers]
- and a,$80
- ld b,a
- ld a,[hl] ; a = damage multiplier
- ld [H_MULTIPLIER],a
+ ld a, [wDamageMultipliers]
+ and $80
+ ld b, a
+ ld a, [hl] ; a = damage multiplier
+ ld [H_MULTIPLIER], a
add b
- ld [wDamageMultipliers],a
- xor a
- ld [H_MULTIPLICAND],a
- ld hl,wDamage
- ld a,[hli]
- ld [H_MULTIPLICAND + 1],a
- ld a,[hld]
- ld [H_MULTIPLICAND + 2],a
+ ld [wDamageMultipliers], a
+ xor a
+ ld [H_MULTIPLICAND], a
+ ld hl, wDamage
+ ld a, [hli]
+ ld [H_MULTIPLICAND + 1], a
+ ld a, [hld]
+ ld [H_MULTIPLICAND + 2], a
call Multiply
- ld a,10
- ld [H_DIVISOR],a
- ld b,$04
+ ld a, 10
+ ld [H_DIVISOR], a
+ ld b, $04
call Divide
- ld a,[H_QUOTIENT + 2]
- ld [hli],a
- ld b,a
- ld a,[H_QUOTIENT + 3]
- ld [hl],a
+ ld a, [H_QUOTIENT + 2]
+ ld [hli], a
+ ld b, a
+ ld a, [H_QUOTIENT + 3]
+ ld [hl], a
or b ; is damage 0?
- jr nz,.skipTypeImmunity
+ jr nz, .skipTypeImmunity
.typeImmunity
; if damage is 0, make the move miss
; this only occurs if a move that would do 2 or 3 damage is 0.25x effective against the target
inc a
- ld [wMoveMissed],a
+ ld [wMoveMissed], a
.skipTypeImmunity
pop bc
pop hl
@@ -5555,26 +5555,26 @@ AdjustDamageForMoveType:
ret
AIGetTypeEffectiveness:
- ld a,[wEnemyMoveType]
- ld d,a ; d = type of enemy move
- ld hl,wBattleMonType
- ld b,[hl] ; b = type 1 of player's pokemon
+ ld a, [wEnemyMoveType]
+ ld d, a ; d = type of enemy move
+ ld hl, wBattleMonType
+ ld b, [hl] ; b = type 1 of player's pokemon
inc hl
- ld c,[hl] ; c = type 2 of player's pokemon
- ld a,$10
- ld [wd11e],a ; initialize [wd11e] to neutral effectiveness
- ld hl,TypeEffects
+ ld c, [hl] ; c = type 2 of player's pokemon
+ ld a, $10
+ ld [wd11e], a ; initialize [wd11e] to neutral effectiveness
+ ld hl, TypeEffects
.loop
- ld a,[hli]
- cp a,$ff
+ ld a, [hli]
+ cp $ff
ret z
cp d ; match the type of the move
- jr nz,.nextTypePair1
- ld a,[hli]
+ jr nz, .nextTypePair1
+ ld a, [hli]
cp b ; match with type 1 of pokemon
- jr z,.done
+ jr z, .done
cp c ; or match with type 2 of pokemon
- jr z,.done
+ jr z, .done
jr .nextTypePair2
.nextTypePair1
inc hl
@@ -5594,8 +5594,8 @@ AIGetTypeEffectiveness:
ret c
.ok
- ld a,[hl]
- ld [wd11e],a ; store damage multiplier
+ ld a, [hl]
+ ld [wd11e], a ; store damage multiplier
ret
INCLUDE "data/type_effects.asm"
@@ -5603,52 +5603,52 @@ INCLUDE "data/type_effects.asm"
; some tests that need to pass for a move to hit
MoveHitTest:
; player's turn
- ld hl,wEnemyBattleStatus1
- ld de,wPlayerMoveEffect
- ld bc,wEnemyMonStatus
- ld a,[H_WHOSETURN]
+ ld hl, wEnemyBattleStatus1
+ ld de, wPlayerMoveEffect
+ ld bc, wEnemyMonStatus
+ ld a, [H_WHOSETURN]
and a
- jr z,.dreamEaterCheck
+ jr z, .dreamEaterCheck
; enemy's turn
- ld hl,wPlayerBattleStatus1
- ld de,wEnemyMoveEffect
- ld bc,wBattleMonStatus
+ ld hl, wPlayerBattleStatus1
+ ld de, wEnemyMoveEffect
+ ld bc, wBattleMonStatus
.dreamEaterCheck
- ld a,[de]
- cp a,DREAM_EATER_EFFECT
- jr nz,.swiftCheck
- ld a,[bc]
- and a,SLP ; is the target pokemon sleeping?
- jp z,.moveMissed
+ ld a, [de]
+ cp DREAM_EATER_EFFECT
+ jr nz, .swiftCheck
+ ld a, [bc]
+ and SLP ; is the target pokemon sleeping?
+ jp z, .moveMissed
.swiftCheck
- ld a,[de]
- cp a,SWIFT_EFFECT
+ ld a, [de]
+ cp SWIFT_EFFECT
ret z ; Swift never misses (interestingly, Azure Heights lists this is a myth, but it appears to be true)
call CheckTargetSubstitute ; substitute check (note that this overwrites a)
- jr z,.checkForDigOrFlyStatus
+ jr z, .checkForDigOrFlyStatus
; this code is buggy. it's supposed to prevent HP draining moves from working on substitutes.
; since $7b79 overwrites a with either $00 or $01, it never works.
- cp a,DRAIN_HP_EFFECT
- jp z,.moveMissed
- cp a,DREAM_EATER_EFFECT
- jp z,.moveMissed
+ cp DRAIN_HP_EFFECT
+ jp z, .moveMissed
+ cp DREAM_EATER_EFFECT
+ jp z, .moveMissed
.checkForDigOrFlyStatus
- bit Invulnerable,[hl]
- jp nz,.moveMissed
- ld a,[H_WHOSETURN]
+ bit INVULNERABLE, [hl]
+ jp nz, .moveMissed
+ ld a, [H_WHOSETURN]
and a
- jr nz,.enemyTurn
+ jr nz, .enemyTurn
.playerTurn
; this checks if the move effect is disallowed by mist
- ld a,[wPlayerMoveEffect]
- cp a,ATTACK_DOWN1_EFFECT
- jr c,.skipEnemyMistCheck
- cp a,HAZE_EFFECT + 1
- jr c,.enemyMistCheck
- cp a,ATTACK_DOWN2_EFFECT
- jr c,.skipEnemyMistCheck
- cp a,REFLECT_EFFECT + 1
- jr c,.enemyMistCheck
+ ld a, [wPlayerMoveEffect]
+ cp ATTACK_DOWN1_EFFECT
+ jr c, .skipEnemyMistCheck
+ cp HAZE_EFFECT + 1
+ jr c, .enemyMistCheck
+ cp ATTACK_DOWN2_EFFECT
+ jr c, .skipEnemyMistCheck
+ cp REFLECT_EFFECT + 1
+ jr c, .enemyMistCheck
jr .skipEnemyMistCheck
.enemyMistCheck
; if move effect is from $12 to $19 inclusive or $3a to $41 inclusive
@@ -5657,98 +5657,98 @@ MoveHitTest:
; FLASH, CONVERSION*, HAZE*, SCREECH, LIGHT SCREEN*, REFLECT*
; the moves that are marked with an asterisk are not affected since this
; function is not called when those moves are used
- ld a,[wEnemyBattleStatus2]
- bit ProtectedByMist,a ; is mon protected by mist?
- jp nz,.moveMissed
+ ld a, [wEnemyBattleStatus2]
+ bit PROTECTED_BY_MIST, a ; is mon protected by mist?
+ jp nz, .moveMissed
.skipEnemyMistCheck
- ld a,[wPlayerBattleStatus2]
- bit UsingXAccuracy,a ; is the player using X Accuracy?
+ ld a, [wPlayerBattleStatus2]
+ bit USING_X_ACCURACY, a ; is the player using X Accuracy?
ret nz ; if so, always hit regardless of accuracy/evasion
jr .calcHitChance
.enemyTurn
- ld a,[wEnemyMoveEffect]
- cp a,ATTACK_DOWN1_EFFECT
- jr c,.skipPlayerMistCheck
- cp a,HAZE_EFFECT + 1
- jr c,.playerMistCheck
- cp a,ATTACK_DOWN2_EFFECT
- jr c,.skipPlayerMistCheck
- cp a,REFLECT_EFFECT + 1
- jr c,.playerMistCheck
+ ld a, [wEnemyMoveEffect]
+ cp ATTACK_DOWN1_EFFECT
+ jr c, .skipPlayerMistCheck
+ cp HAZE_EFFECT + 1
+ jr c, .playerMistCheck
+ cp ATTACK_DOWN2_EFFECT
+ jr c, .skipPlayerMistCheck
+ cp REFLECT_EFFECT + 1
+ jr c, .playerMistCheck
jr .skipPlayerMistCheck
.playerMistCheck
; similar to enemy mist check
- ld a,[wPlayerBattleStatus2]
- bit ProtectedByMist,a ; is mon protected by mist?
- jp nz,.moveMissed
+ ld a, [wPlayerBattleStatus2]
+ bit PROTECTED_BY_MIST, a ; is mon protected by mist?
+ jp nz, .moveMissed
.skipPlayerMistCheck
- ld a,[wEnemyBattleStatus2]
- bit UsingXAccuracy,a ; is the enemy using X Accuracy?
+ ld a, [wEnemyBattleStatus2]
+ bit USING_X_ACCURACY, a ; is the enemy using X Accuracy?
ret nz ; if so, always hit regardless of accuracy/evasion
.calcHitChance
call CalcHitChance ; scale the move accuracy according to attacker's accuracy and target's evasion
- ld a,[wPlayerMoveAccuracy]
- ld b,a
- ld a,[H_WHOSETURN]
+ ld a, [wPlayerMoveAccuracy]
+ ld b, a
+ ld a, [H_WHOSETURN]
and a
- jr z,.doAccuracyCheck
- ld a,[wEnemyMoveAccuracy]
- ld b,a
+ jr z, .doAccuracyCheck
+ ld a, [wEnemyMoveAccuracy]
+ ld b, a
.doAccuracyCheck
; if the random number generated is greater than or equal to the scaled accuracy, the move misses
; note that this means that even the highest accuracy is still just a 255/256 chance, not 100%
call BattleRandom
cp b
- jr nc,.moveMissed
+ jr nc, .moveMissed
ret
.moveMissed
xor a
- ld hl,wDamage ; zero the damage
- ld [hli],a
- ld [hl],a
+ ld hl, wDamage ; zero the damage
+ ld [hli], a
+ ld [hl], a
inc a
- ld [wMoveMissed],a
- ld a,[H_WHOSETURN]
+ ld [wMoveMissed], a
+ ld a, [H_WHOSETURN]
and a
- jr z,.playerTurn2
+ jr z, .playerTurn2
.enemyTurn2
- ld hl,wEnemyBattleStatus1
- res UsingTrappingMove,[hl] ; end multi-turn attack e.g. wrap
+ ld hl, wEnemyBattleStatus1
+ res USING_TRAPPING_MOVE, [hl] ; end multi-turn attack e.g. wrap
ret
.playerTurn2
- ld hl,wPlayerBattleStatus1
- res UsingTrappingMove,[hl] ; end multi-turn attack e.g. wrap
+ ld hl, wPlayerBattleStatus1
+ res USING_TRAPPING_MOVE, [hl] ; end multi-turn attack e.g. wrap
ret
; values for player turn
CalcHitChance:
- ld hl,wPlayerMoveAccuracy
- ld a,[H_WHOSETURN]
- and a
- ld a,[wPlayerMonAccuracyMod]
- ld b,a
- ld a,[wEnemyMonEvasionMod]
- ld c,a
- jr z,.next
+ ld hl, wPlayerMoveAccuracy
+ ld a, [H_WHOSETURN]
+ and a
+ ld a, [wPlayerMonAccuracyMod]
+ ld b, a
+ ld a, [wEnemyMonEvasionMod]
+ ld c, a
+ jr z, .next
; values for enemy turn
- ld hl,wEnemyMoveAccuracy
- ld a,[wEnemyMonAccuracyMod]
- ld b,a
- ld a,[wPlayerMonEvasionMod]
- ld c,a
+ ld hl, wEnemyMoveAccuracy
+ ld a, [wEnemyMonAccuracyMod]
+ ld b, a
+ ld a, [wPlayerMonEvasionMod]
+ ld c, a
.next
- ld a,$0e
+ ld a, $0e
sub c
- ld c,a ; c = 14 - EVASIONMOD (this "reflects" the value over 7, so that an increase in the target's evasion
+ ld c, a ; c = 14 - EVASIONMOD (this "reflects" the value over 7, so that an increase in the target's evasion
; decreases the hit chance instead of increasing the hit chance)
; zero the high bytes of the multiplicand
xor a
- ld [H_MULTIPLICAND],a
- ld [H_MULTIPLICAND + 1],a
- ld a,[hl]
- ld [H_MULTIPLICAND + 2],a ; set multiplicand to move accuracy
+ ld [H_MULTIPLICAND], a
+ ld [H_MULTIPLICAND + 1], a
+ ld a, [hl]
+ ld [H_MULTIPLICAND + 2], a ; set multiplicand to move accuracy
push hl
- ld d,$02 ; loop has two iterations
+ ld d, $02 ; loop has two iterations
; loop to do the calculations, the first iteration multiplies by the accuracy ratio and
; the second iteration multiplies by the evasion ratio
.loop
@@ -5756,40 +5756,40 @@ CalcHitChance:
ld hl, StatModifierRatios ; stat modifier ratios
dec b
sla b
- ld c,b
- ld b,$00
- add hl,bc ; hl = address of stat modifier ratio
+ ld c, b
+ ld b, $00
+ add hl, bc ; hl = address of stat modifier ratio
pop bc
- ld a,[hli]
- ld [H_MULTIPLIER],a ; set multiplier to the numerator of the ratio
+ ld a, [hli]
+ ld [H_MULTIPLIER], a ; set multiplier to the numerator of the ratio
call Multiply
- ld a,[hl]
- ld [H_DIVISOR],a ; set divisor to the the denominator of the ratio
+ ld a, [hl]
+ ld [H_DIVISOR], a ; set divisor to the the denominator of the ratio
; (the dividend is the product of the previous multiplication)
- ld b,$04 ; number of bytes in the dividend
+ ld b, $04 ; number of bytes in the dividend
call Divide
- ld a,[H_QUOTIENT + 3]
- ld b,a
- ld a,[H_QUOTIENT + 2]
+ ld a, [H_QUOTIENT + 3]
+ ld b, a
+ ld a, [H_QUOTIENT + 2]
or b
- jp nz,.nextCalculation
+ jp nz, .nextCalculation
; make sure the result is always at least one
- ld [H_QUOTIENT + 2],a
- ld a,$01
- ld [H_QUOTIENT + 3],a
+ ld [H_QUOTIENT + 2], a
+ ld a, $01
+ ld [H_QUOTIENT + 3], a
.nextCalculation
- ld b,c
+ ld b, c
dec d
- jr nz,.loop
- ld a,[H_QUOTIENT + 2]
+ jr nz, .loop
+ ld a, [H_QUOTIENT + 2]
and a ; is the calculated hit chance over 0xFF?
- ld a,[H_QUOTIENT + 3]
- jr z,.storeAccuracy
+ ld a, [H_QUOTIENT + 3]
+ jr z, .storeAccuracy
; if calculated hit chance over 0xFF
- ld a,$ff ; set the hit chance to 0xFF
+ ld a, $ff ; set the hit chance to 0xFF
.storeAccuracy
pop hl
- ld [hl],a ; store the hit chance in the move accuracy variable
+ ld [hl], a ; store the hit chance in the move accuracy variable
ret
; multiplies damage by a random percentage from ~85% to 100%
@@ -5841,9 +5841,9 @@ ExecuteEnemyMove:
jr nz, .executeEnemyMove
ld b, $1
ld a, [wSerialExchangeNybbleReceiveData]
- cp $e
+ cp LINKBATTLE_STRUGGLE
jr z, .executeEnemyMove
- cp $4
+ cp 4
ret nc
.executeEnemyMove
ld hl, wAILayer2Encouragement
@@ -5858,7 +5858,7 @@ ExecuteEnemyMove:
jp hl
.enemyHasNoSpecialConditions
ld hl, wEnemyBattleStatus1
- bit ChargingUp, [hl] ; is the enemy charging up for attack?
+ bit CHARGING_UP, [hl] ; is the enemy charging up for attack?
jr nz, EnemyCanExecuteChargingMove ; if so, jump
call GetCurrentMove
@@ -5871,8 +5871,8 @@ CheckIfEnemyNeedsToChargeUp:
jr EnemyCanExecuteMove
EnemyCanExecuteChargingMove:
ld hl, wEnemyBattleStatus1
- res ChargingUp, [hl] ; no longer charging up for attack
- res Invulnerable, [hl] ; no longer invulnerable to typical attacks
+ res CHARGING_UP, [hl] ; no longer charging up for attack
+ res INVULNERABLE, [hl] ; no longer invulnerable to typical attacks
ld a, [wEnemyMoveNum]
ld [wd0b5], a
ld a, BANK(MoveNames)
@@ -5940,7 +5940,7 @@ handleExplosionMiss:
playEnemyMoveAnimation:
push af
ld a, [wEnemyBattleStatus2]
- bit HasSubstituteUp, a ; does mon have a substitute?
+ bit HAS_SUBSTITUTE_UP, a ; does mon have a substitute?
ld hl, HideSubstituteShowMonAnim
ld b, BANK(HideSubstituteShowMonAnim)
call nz, Bankswitch
@@ -5951,7 +5951,7 @@ playEnemyMoveAnimation:
call HandleExplodingAnimation
call DrawEnemyHUDAndHPBar
ld a, [wEnemyBattleStatus2]
- bit HasSubstituteUp, a ; does mon have a substitute?
+ bit HAS_SUBSTITUTE_UP, a ; does mon have a substitute?
ld hl, ReshowSubstituteAnim
ld b, BANK(ReshowSubstituteAnim)
call nz, Bankswitch ; slide the substitute's sprite out
@@ -5970,7 +5970,7 @@ EnemyCheckIfFlyOrChargeEffect:
.playAnim
xor a
ld [wAnimationType], a
- ld a,STATUS_AFFECTED_ANIM
+ ld a, STATUS_AFFECTED_ANIM
call PlayMoveAnimation
EnemyCheckIfMirrorMoveEffect:
ld a, [wEnemyMoveEffect]
@@ -6017,14 +6017,14 @@ EnemyCheckIfMirrorMoveEffect:
ret z
call HandleBuildingRage
ld hl, wEnemyBattleStatus1
- bit AttackingMultipleTimes, [hl] ; is mon hitting multiple times? (example: double kick)
+ bit ATTACKING_MULTIPLE_TIMES, [hl] ; is mon hitting multiple times? (example: double kick)
jr z, .notMultiHitMove
push hl
ld hl, wEnemyNumAttacksLeft
dec [hl]
pop hl
jp nz, GetEnemyAnimationType
- res AttackingMultipleTimes, [hl] ; mon is no longer hitting multiple times
+ res ATTACKING_MULTIPLE_TIMES, [hl] ; mon is no longer hitting multiple times
ld hl, HitXTimesText
call PrintText
xor a
@@ -6062,7 +6062,7 @@ CheckEnemyStatusConditions:
call PrintText
xor a
ld [wAnimationType], a
- ld a,SLP_ANIM
+ ld a, SLP_ANIM
call PlayMoveAnimation
jr .sleepDone
.wokeUp
@@ -6084,7 +6084,7 @@ CheckEnemyStatusConditions:
jp .enemyReturnToHL
.checkIfTrapped
ld a, [wPlayerBattleStatus1]
- bit UsingTrappingMove, a ; is the player using a multi-turn attack like warp
+ bit USING_TRAPPING_MOVE, a ; is the player using a multi-turn attack like warp
jp z, .checkIfFlinched
ld hl, CantMoveText
call PrintText
@@ -6092,18 +6092,18 @@ CheckEnemyStatusConditions:
jp .enemyReturnToHL
.checkIfFlinched
ld hl, wEnemyBattleStatus1
- bit Flinched, [hl] ; check if enemy mon flinched
+ bit FLINCHED, [hl] ; check if enemy mon flinched
jp z, .checkIfMustRecharge
- res Flinched, [hl]
+ res FLINCHED, [hl]
ld hl, FlinchedText
call PrintText
ld hl, ExecuteEnemyMoveDone ; enemy can't move this turn
jp .enemyReturnToHL
.checkIfMustRecharge
ld hl, wEnemyBattleStatus2
- bit NeedsToRecharge, [hl] ; check if enemy mon has to recharge after using a move
+ bit NEEDS_TO_RECHARGE, [hl] ; check if enemy mon has to recharge after using a move
jr z, .checkIfAnyMoveDisabled
- res NeedsToRecharge, [hl]
+ res NEEDS_TO_RECHARGE, [hl]
ld hl, MustRechargeText
call PrintText
ld hl, ExecuteEnemyMoveDone ; enemy can't move this turn
@@ -6129,7 +6129,7 @@ CheckEnemyStatusConditions:
dec [hl]
jr nz, .isConfused
ld hl, wEnemyBattleStatus1
- res Confused, [hl] ; if confused counter hit 0, reset confusion status
+ res CONFUSED, [hl] ; if confused counter hit 0, reset confusion status
ld hl, ConfusedNoMoreText
call PrintText
jp .checkIfTriedToUseDisabledMove
@@ -6138,14 +6138,14 @@ CheckEnemyStatusConditions:
call PrintText
xor a
ld [wAnimationType], a
- ld a,CONF_ANIM
+ ld a, CONF_ANIM
call PlayMoveAnimation
call BattleRandom
cp $80
jr c, .checkIfTriedToUseDisabledMove
ld hl, wEnemyBattleStatus1
ld a, [hl]
- and 1 << Confused ; if mon hurts itself, clear every other status from wEnemyBattleStatus1
+ and 1 << CONFUSED ; if mon hurts itself, clear every other status from wEnemyBattleStatus1
ld [hl], a
ld hl, HurtItselfText
call PrintText
@@ -6212,7 +6212,7 @@ CheckEnemyStatusConditions:
ld hl, wEnemyBattleStatus1
ld a, [hl]
; clear bide, thrashing about, charging up, and multi-turn moves such as warp
- and $ff ^ ((1 << StoringEnergy) | (1 << ThrashingAbout) | (1 << ChargingUp) | (1 << UsingTrappingMove))
+ and $ff ^ ((1 << STORING_ENERGY) | (1 << THRASHING_ABOUT) | (1 << CHARGING_UP) | (1 << USING_TRAPPING_MOVE))
ld [hl], a
ld a, [wEnemyMoveEffect]
cp FLY_EFFECT
@@ -6230,7 +6230,7 @@ CheckEnemyStatusConditions:
jp .enemyReturnToHL ; if using a two-turn move, enemy needs to recharge the first turn
.checkIfUsingBide
ld hl, wEnemyBattleStatus1
- bit StoringEnergy, [hl] ; is mon using bide?
+ bit STORING_ENERGY, [hl] ; is mon using bide?
jr z, .checkIfThrashingAbout
xor a
ld [wEnemyMoveNum], a
@@ -6252,7 +6252,7 @@ CheckEnemyStatusConditions:
jp .enemyReturnToHL ; unless mon unleashes energy, can't move this turn
.unleashEnergy
ld hl, wEnemyBattleStatus1
- res StoringEnergy, [hl] ; not using bide any more
+ res STORING_ENERGY, [hl] ; not using bide any more
ld hl, UnleashedEnergyText
call PrintText
ld a, $1
@@ -6279,7 +6279,7 @@ CheckEnemyStatusConditions:
ld hl, handleIfEnemyMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest
jp .enemyReturnToHL
.checkIfThrashingAbout
- bit ThrashingAbout, [hl] ; is mon using thrash or petal dance?
+ bit THRASHING_ABOUT, [hl] ; is mon using thrash or petal dance?
jr z, .checkIfUsingMultiturnMove
ld a, THRASH
ld [wEnemyMoveNum], a
@@ -6291,8 +6291,8 @@ CheckEnemyStatusConditions:
jp nz, .enemyReturnToHL
push hl
ld hl, wEnemyBattleStatus1
- res ThrashingAbout, [hl] ; mon is no longer using thrash or petal dance
- set Confused, [hl] ; mon is now confused
+ res THRASHING_ABOUT, [hl] ; mon is no longer using thrash or petal dance
+ set CONFUSED, [hl] ; mon is now confused
call BattleRandom
and $3
inc a
@@ -6301,7 +6301,7 @@ CheckEnemyStatusConditions:
pop hl ; skip DecrementPP
jp .enemyReturnToHL
.checkIfUsingMultiturnMove
- bit UsingTrappingMove, [hl] ; is mon using multi-turn move?
+ bit USING_TRAPPING_MOVE, [hl] ; is mon using multi-turn move?
jp z, .checkIfUsingRage
ld hl, AttackContinuesText
call PrintText
@@ -6313,7 +6313,7 @@ CheckEnemyStatusConditions:
jp .enemyReturnToHL
.checkIfUsingRage
ld a, [wEnemyBattleStatus2]
- bit UsingRage, a ; is mon using rage?
+ bit USING_RAGE, a ; is mon using rage?
jp z, .checkEnemyStatusConditionsDone ; if we made it this far, mon can move normally this turn
ld a, RAGE
ld [wd11e], a
@@ -6371,7 +6371,7 @@ LoadEnemyMonData:
ld [wd0b5], a
call GetMonHeader
ld a, [wEnemyBattleStatus3]
- bit Transformed, a ; is enemy mon transformed?
+ bit TRANSFORMED, a ; is enemy mon transformed?
ld hl, wTransformedEnemyMonOriginalDVs ; original DVs before transforming
ld a, [hli]
ld b, [hl]
@@ -6403,7 +6403,7 @@ LoadEnemyMonData:
cp $2 ; is it a trainer battle?
jr z, .copyHPAndStatusFromPartyData
ld a, [wEnemyBattleStatus3]
- bit Transformed, a ; is enemy mon transformed?
+ bit TRANSFORMED, a ; is enemy mon transformed?
jr nz, .copyTypes ; if transformed, jump
; if it's a wild mon and not transformed, init the current HP to max HP and the status to 0
ld a, [wEnemyMonMaxHP]
@@ -6982,7 +6982,7 @@ HandleExplodingAnimation:
ret nz
.isExplodingMove
ld a, [de]
- bit Invulnerable, a ; fly/dig
+ bit INVULNERABLE, a ; fly/dig
ret nz
ld a, [hli]
cp GHOST
@@ -6997,7 +6997,7 @@ HandleExplodingAnimation:
ld [wAnimationType], a
PlayMoveAnimation:
- ld [wAnimationID],a
+ ld [wAnimationID], a
call Delay3
predef MoveAnimation
callab Func_78e98
@@ -7125,8 +7125,8 @@ SleepEffect:
.sleepEffect
ld a, [bc]
- bit NeedsToRecharge, a ; does the target need to recharge? (hyper beam)
- res NeedsToRecharge, a ; target no longer needs to recharge
+ bit NEEDS_TO_RECHARGE, a ; does the target need to recharge? (hyper beam)
+ res NEEDS_TO_RECHARGE, a ; target no longer needs to recharge
ld [bc], a
jr nz, .setSleepCounter ; if the target had to recharge, all hit tests will be skipped
; including the event where the target already has another status
@@ -7186,16 +7186,16 @@ PoisonEffect:
ld de, wEnemyMoveEffect
.poisonEffect
call CheckTargetSubstitute
- jr nz, .noEffect ; can't posion a substitute target
+ jr nz, .noEffect ; can't poison a substitute target
ld a, [hli]
ld b, a
and a
jr nz, .noEffect ; miss if target is already statused
ld a, [hli]
- cp POISON ; can't posion a poison-type target
+ cp POISON ; can't poison a poison-type target
jr z, .noEffect
ld a, [hld]
- cp POISON ; can't posion a poison-type target
+ cp POISON ; can't poison a poison-type target
jr z, .noEffect
ld a, [de]
cp POISON_SIDE_EFFECT1
@@ -7235,7 +7235,7 @@ PoisonEffect:
.ok
cp TOXIC
jr nz, .normalPoison ; done if move is not Toxic
- set BadlyPoisoned, [hl] ; else set Toxic battstatus
+ set BADLY_POISONED, [hl] ; else set Toxic battstatus
xor a
ld [de], a
ld hl, BadlyPoisonedText
@@ -7288,7 +7288,7 @@ ExplodeEffect:
inc hl
ld [hl], a ; set mon's status to 0
ld a, [de]
- res Seeded, a ; clear mon's leech seed status
+ res SEEDED, a ; clear mon's leech seed status
ld [de], a
ret
@@ -7326,7 +7326,7 @@ FreezeBurnParalyzeEffect:
ld b, $1a ; 0x1A/0x100 or 26/256 = 10.2%~ chance
jr c, .next1 ; branch ahead if this is a 10% chance effect..
ld b, $4d ; else use 0x4D/0x100 or 77/256 = 30.1%~ chance
- sub a, $1e ; subtract $1E to map to equivalent 10% chance effects
+ sub $1e ; subtract $1E to map to equivalent 10% chance effects
.next1
push af
call BattleRandom ; get random 8bit value for probability test
@@ -7334,9 +7334,9 @@ FreezeBurnParalyzeEffect:
pop bc
ret nc ; do nothing if random value is >= 1A or 4D [no status applied]
ld a, b ; what type of effect is this?
- cp a, BURN_SIDE_EFFECT1
+ cp BURN_SIDE_EFFECT1
jr z, .burn1
- cp a, FREEZE_SIDE_EFFECT
+ cp FREEZE_SIDE_EFFECT
jr z, .freeze1
; .paralyze
ld a, 1 << PAR
@@ -7388,7 +7388,7 @@ FreezeBurnParalyzeEffect:
ld b, $1a
jr c, .next2
ld b, $4d
- sub a, $1e
+ sub $1e
.next2
push af
call BattleRandom
@@ -7396,9 +7396,9 @@ FreezeBurnParalyzeEffect:
pop bc
ret nc
ld a, b
- cp a, BURN_SIDE_EFFECT1
+ cp BURN_SIDE_EFFECT1
jr z, .burn2
- cp a, FREEZE_SIDE_EFFECT
+ cp FREEZE_SIDE_EFFECT
jr z, .freeze2
ld a, 1 << PAR
ld [wBattleMonStatus], a
@@ -7433,16 +7433,16 @@ FrozenText:
CheckDefrost:
; any fire-type move that has a chance inflict burn (all but Fire Spin) will defrost a frozen target
- and a, 1 << FRZ ; are they frozen?
+ and 1 << FRZ ; are they frozen?
ret z ; return if so
ld a, [H_WHOSETURN]
and a
jr nz, .opponent
;player [attacker]
ld a, [wPlayerMoveType]
- sub a, FIRE
+ sub FIRE
ret nz ; return if type of move used isn't fire
- ld [wEnemyMonStatus], a ; set opponent status to 00 ["defrost" a frozen monster]
+ ld [wEnemyMonStatus], a ; set opponent status to 00 ["defrost" a frozen monster]
ld hl, wEnemyMon1Status
ld a, [wEnemyMonPartyPos]
ld bc, wEnemyMon2 - wEnemyMon1
@@ -7452,8 +7452,8 @@ CheckDefrost:
ld hl, FireDefrostedText
jr .common
.opponent
- ld a, [wEnemyMoveType] ; same as above with addresses swapped
- sub a, FIRE
+ ld a, [wEnemyMoveType] ; same as above with addresses swapped
+ sub FIRE
ret nz
ld [wBattleMonStatus], a
ld hl, wPartyMon1Status
@@ -7594,7 +7594,7 @@ UpdateStatDone:
jr nz, .notMinimize
; if a substitute is up, slide off the substitute and show the mon pic before
; playing the minimize animation
- bit HasSubstituteUp, [hl]
+ bit HAS_SUBSTITUTE_UP, [hl]
push af
push bc
push de
@@ -7650,7 +7650,7 @@ MonsStatsRoseText:
ret
GreatlyRoseText:
- db $0a
+ TX_DELAY
TX_FAR _GreatlyRoseText
; fallthrough
RoseText:
@@ -7697,11 +7697,11 @@ StatModifierDownEffect:
and a
jp nz, MoveMissed
ld a, [bc]
- bit Invulnerable, a ; fly/dig
+ bit INVULNERABLE, a ; fly/dig
jp nz, MoveMissed
ld a, [de]
sub ATTACK_DOWN1_EFFECT
- cp EVASION_DOWN1_EFFECT + $3 - ATTACK_DOWN1_EFFECT ; covers al -1 effects
+ cp EVASION_DOWN1_EFFECT + $3 - ATTACK_DOWN1_EFFECT ; covers all -1 effects
jr c, .decrementStatMod
sub ATTACK_DOWN2_EFFECT - ATTACK_DOWN1_EFFECT ; map -2 effects to corresponding -1 effect
.decrementStatMod
@@ -7855,7 +7855,7 @@ MonsStatsFellText:
ret
GreatlyFellText:
- db $0a
+ TX_DELAY
TX_FAR _GreatlyFellText
; fallthrough
FellText:
@@ -7913,7 +7913,7 @@ BideEffect:
ld de, wEnemyBideAccumulatedDamage
ld bc, wEnemyNumAttacksLeft
.bideEffect
- set StoringEnergy, [hl] ; mon is now using bide
+ set STORING_ENERGY, [hl] ; mon is now using bide
xor a
ld [de], a
inc de
@@ -7938,7 +7938,7 @@ ThrashPetalDanceEffect:
ld hl, wEnemyBattleStatus1
ld de, wEnemyNumAttacksLeft
.thrashPetalDanceEffect
- set ThrashingAbout, [hl] ; mon is now using thrash/petal dance
+ set THRASHING_ABOUT, [hl] ; mon is now using thrash/petal dance
call BattleRandom
and $1
inc a
@@ -7968,9 +7968,8 @@ SwitchAndTeleportEffect:
cp c ; get a random number between 0 and c
jr nc, .rejectionSampleLoop1
srl b
- srl b ; b = enemy level * 4
-; bug: does not account for overflow, so levels above 63 can lead to erroneousness results
- cp b ; is rand[0, playerLevel + enemyLevel] > enemyLevel?
+ srl b ; b = enemyLevel / 4
+ cp b ; is rand[0, playerLevel + enemyLevel) >= (enemyLevel / 4)?
jr nc, .playerMoveWasSuccessful ; if so, allow teleporting
ld c, 50
call DelayFrames
@@ -8075,9 +8074,9 @@ TwoToFiveAttacksEffect:
ld de, wEnemyNumAttacksLeft
ld bc, wEnemyNumHits
.twoToFiveAttacksEffect
- bit AttackingMultipleTimes, [hl] ; is mon attacking multiple times?
+ bit ATTACKING_MULTIPLE_TIMES, [hl] ; is mon attacking multiple times?
ret nz
- set AttackingMultipleTimes, [hl] ; mon is now attacking multiple times
+ set ATTACKING_MULTIPLE_TIMES, [hl] ; mon is now attacking multiple times
ld hl, wPlayerMoveEffect
ld a, [H_WHOSETURN]
and a
@@ -8133,7 +8132,7 @@ FlinchSideEffect:
call BattleRandom
cp b
ret nc
- set Flinched, [hl] ; set mon's status to flinching
+ set FLINCHED, [hl] ; set mon's status to flinching
call ClearHyperBeam
ret
@@ -8151,18 +8150,18 @@ ChargeEffect:
ld de, wEnemyMoveEffect
ld b, ANIM_AF
.chargeEffect
- set ChargingUp, [hl]
+ set CHARGING_UP, [hl]
ld a, [de]
dec de ; de contains enemy or player MOVENUM
cp FLY_EFFECT
jr nz, .notFly
- set Invulnerable, [hl] ; mon is now invulnerable to typical attacks (fly/dig)
+ set INVULNERABLE, [hl] ; mon is now invulnerable to typical attacks (fly/dig)
ld b, TELEPORT ; load Teleport's animation
.notFly
ld a, [de]
cp DIG
jr nz, .notDigOrFly
- set Invulnerable, [hl] ; mon is now invulnerable to typical attacks (fly/dig)
+ set INVULNERABLE, [hl] ; mon is now invulnerable to typical attacks (fly/dig)
ld b, ANIM_C0
.notDigOrFly
push de
@@ -8170,7 +8169,7 @@ ChargeEffect:
inc hl ; battle status 2
push hl
ld a, [hl]
- bit HasSubstituteUp, a
+ bit HAS_SUBSTITUTE_UP, a
ld hl, HideSubstituteShowMonAnim
ld b, BANK(HideSubstituteShowMonAnim)
call nz, Bankswitch
@@ -8181,7 +8180,7 @@ ChargeEffect:
ld a, b
call PlayBattleAnimation
ld a, [hl]
- bit HasSubstituteUp, a
+ bit HAS_SUBSTITUTE_UP, a
ld hl, ReshowSubstituteAnim
ld b, BANK(ReshowSubstituteAnim)
call nz, Bankswitch
@@ -8248,11 +8247,11 @@ TrappingEffect:
ld hl, wEnemyBattleStatus1
ld de, wEnemyNumAttacksLeft
.trappingEffect
- bit UsingTrappingMove, [hl]
+ bit USING_TRAPPING_MOVE, [hl]
ret nz
call ClearHyperBeam ; since this effect is called before testing whether the move will hit,
; the target won't need to recharge even if the trapping move missed
- set UsingTrappingMove, [hl] ; mon is now using a trapping move
+ set USING_TRAPPING_MOVE, [hl] ; mon is now using a trapping move
call BattleRandom ; 3/8 chance for 2 and 3 attacks, and 1/8 chance for 4 and 5 attacks
and $3
cp $2
@@ -8298,9 +8297,9 @@ ConfusionSideEffectSuccess:
ld bc, wPlayerConfusedCounter
ld a, [wEnemyMoveEffect]
.confuseTarget
- bit Confused, [hl] ; is mon confused?
+ bit CONFUSED, [hl] ; is mon confused?
jr nz, ConfusionEffectFailed
- set Confused, [hl] ; mon is now confused
+ set CONFUSED, [hl] ; mon is now confused
push af
call BattleRandom
and $3
@@ -8337,7 +8336,7 @@ HyperBeamEffect:
jr z, .hyperBeamEffect
ld hl, wEnemyBattleStatus2
.hyperBeamEffect
- set NeedsToRecharge, [hl] ; mon now needs to recharge
+ set NEEDS_TO_RECHARGE, [hl] ; mon now needs to recharge
ret
ClearHyperBeam:
@@ -8348,7 +8347,7 @@ ClearHyperBeam:
jr z, .playerTurn
ld hl, wPlayerBattleStatus2
.playerTurn
- res NeedsToRecharge, [hl] ; mon no longer needs to recharge
+ res NEEDS_TO_RECHARGE, [hl] ; mon no longer needs to recharge
pop hl
ret
@@ -8359,7 +8358,7 @@ RageEffect:
jr z, .player
ld hl, wEnemyBattleStatus2
.player
- set UsingRage, [hl] ; mon is now in "rage" mode
+ set USING_RAGE, [hl] ; mon is now in "rage" mode
ret
MimicEffect:
@@ -8380,7 +8379,7 @@ MimicEffect:
ld hl, wEnemyMonMoves
ld a, [wEnemyBattleStatus1]
.enemyTurn
- bit Invulnerable, a
+ bit INVULNERABLE, a
jr nz, .mimicMissed
.getRandomMove
push hl
@@ -8404,7 +8403,7 @@ MimicEffect:
jr .playerTurn
.letPlayerChooseMove
ld a, [wEnemyBattleStatus1]
- bit Invulnerable, a
+ bit INVULNERABLE, a
jr nz, .mimicMissed
ld a, [wCurrentMenuItem]
push af
@@ -8603,7 +8602,7 @@ CheckTargetSubstitute:
jr z, .next1
ld hl, wPlayerBattleStatus2
.next1
- bit HasSubstituteUp, [hl]
+ bit HAS_SUBSTITUTE_UP, [hl]
pop hl
ret
diff --git a/engine/battle/decrement_pp.asm b/engine/battle/decrement_pp.asm
index e23a85ba..b7c428f7 100644
--- a/engine/battle/decrement_pp.asm
+++ b/engine/battle/decrement_pp.asm
@@ -1,15 +1,15 @@
DecrementPP:
; after using a move, decrement pp in battle and (if not transformed?) in party
ld a, [de]
- cp a, STRUGGLE
+ cp STRUGGLE
ret z ; if the pokemon is using "struggle", there's nothing to do
; we don't decrement PP for "struggle"
ld hl, wPlayerBattleStatus1
ld a, [hli] ; load the wPlayerBattleStatus1 pokemon status flags and increment hl to load the
; wPlayerBattleStatus2 status flags later
- and a, (1 << StoringEnergy) | (1 << ThrashingAbout) | (1 << AttackingMultipleTimes)
+ and (1 << STORING_ENERGY) | (1 << THRASHING_ABOUT) | (1 << ATTACKING_MULTIPLE_TIMES)
ret nz ; if any of these statuses are true, don't decrement PP
- bit UsingRage, [hl]
+ bit USING_RAGE, [hl]
ret nz ; don't decrement PP either if Pokemon is using Rage
ld hl, wBattleMonPP ; PP of first move (in battle)
@@ -18,7 +18,7 @@ DecrementPP:
; decrement PP in the party struct
ld a, [wPlayerBattleStatus3]
- bit Transformed, a
+ bit TRANSFORMED, a
ret nz ; Return if transformed. Pokemon Red stores the "current pokemon's" PP
; separately from the "Pokemon in your party's" PP. This is
; duplication -- in all cases *other* than Pokemon with Transform.
diff --git a/engine/battle/display_effectiveness.asm b/engine/battle/display_effectiveness.asm
index 85f2bc3e..1bf14460 100644
--- a/engine/battle/display_effectiveness.asm
+++ b/engine/battle/display_effectiveness.asm
@@ -1,7 +1,7 @@
DisplayEffectiveness:
ld a, [wDamageMultipliers]
- and a, $7F
- cp a, $0A
+ and $7F
+ cp $0A
ret z
ld hl, SuperEffectiveText
jr nc, .done
diff --git a/engine/battle/draw_hud_pokeball_gfx.asm b/engine/battle/draw_hud_pokeball_gfx.asm
index 8f9dce46..96294774 100644
--- a/engine/battle/draw_hud_pokeball_gfx.asm
+++ b/engine/battle/draw_hud_pokeball_gfx.asm
@@ -194,7 +194,7 @@ SetupPlayerAndEnemyPokeballs:
ld hl, wOAMBuffer + $18
jp WritePokeballOAMData
-; four tiles: pokeball, black pokeball (status ailment), crossed out pokeball (faited) and pokeball slot (no mon)
+; four tiles: pokeball, black pokeball (status ailment), crossed out pokeball (fainted) and pokeball slot (no mon)
PokeballTileGraphics::
INCBIN "gfx/pokeball.2bpp"
PokeballTileGraphicsEnd:
diff --git a/engine/battle/end_of_battle.asm b/engine/battle/end_of_battle.asm
index 47c9fa5d..5c0c3991 100755
--- a/engine/battle/end_of_battle.asm
+++ b/engine/battle/end_of_battle.asm
@@ -50,7 +50,7 @@ EndOfBattle:
.resetVariables
xor a
ld [wLowHealthAlarm], a ;disable low health alarm
- ld [wChannelSoundIDs + CH4], a
+ ld [wChannelSoundIDs + Ch5], a
ld [wIsInBattle], a
ld [wBattleType], a
ld [wMoveMissed], a
diff --git a/engine/battle/experience.asm b/engine/battle/experience.asm
index 9946c6c6..722685c2 100644
--- a/engine/battle/experience.asm
+++ b/engine/battle/experience.asm
@@ -119,11 +119,11 @@ GainExperience:
ld d, MAX_LEVEL
callab CalcExperience ; get max exp
; compare max exp with current exp
- ld a, [$ff96]
+ ld a, [hExperience]
ld b, a
- ld a, [$ff97]
+ ld a, [hExperience + 1]
ld c, a
- ld a, [$ff98]
+ ld a, [hExperience + 2]
ld d, a
pop hl
ld a, [hld]
@@ -378,5 +378,5 @@ ExpPointsText:
GrewLevelText:
TX_FAR _GrewLevelText
- db $0b
+ TX_SFX_LEVEL_UP
db "@"
diff --git a/engine/battle/init_battle_variables.asm b/engine/battle/init_battle_variables.asm
index bdd5d8f4..7bc912d2 100644
--- a/engine/battle/init_battle_variables.asm
+++ b/engine/battle/init_battle_variables.asm
@@ -30,7 +30,7 @@ InitBattleVariables:
ld a, [wCurMap]
cp SAFARI_ZONE_EAST
jr c, .notSafariBattle
- cp SAFARI_ZONE_REST_HOUSE_1
+ cp SAFARI_ZONE_CENTER_REST_HOUSE
jr nc, .notSafariBattle
ld a, BATTLE_TYPE_SAFARI
ld [wBattleType], a
diff --git a/engine/battle/moveEffects/conversion_effect.asm b/engine/battle/moveEffects/conversion_effect.asm
index 9c347876..f23c3d70 100644
--- a/engine/battle/moveEffects/conversion_effect.asm
+++ b/engine/battle/moveEffects/conversion_effect.asm
@@ -11,7 +11,7 @@ ConversionEffect_:
pop de
ld a, [wPlayerBattleStatus1]
.conversionEffect
- bit Invulnerable, a ; is mon immune to typical attacks (dig/fly)
+ bit INVULNERABLE, a ; is mon immune to typical attacks (dig/fly)
jr nz, PrintButItFailedText
; copy target's types to user
ld a, [hli]
diff --git a/engine/battle/moveEffects/focus_energy_effect.asm b/engine/battle/moveEffects/focus_energy_effect.asm
index 9ba0ade0..16dad7bb 100644
--- a/engine/battle/moveEffects/focus_energy_effect.asm
+++ b/engine/battle/moveEffects/focus_energy_effect.asm
@@ -5,9 +5,9 @@ FocusEnergyEffect_:
jr z, .notEnemy
ld hl, wEnemyBattleStatus2
.notEnemy
- bit GettingPumped, [hl] ; is mon already using focus energy?
+ bit GETTING_PUMPED, [hl] ; is mon already using focus energy?
jr nz, .alreadyUsing
- set GettingPumped, [hl] ; mon is now using focus energy
+ set GETTING_PUMPED, [hl] ; mon is now using focus energy
callab PlayCurrentMoveAnimation
ld hl, GettingPumpedText
jp PrintText
@@ -17,6 +17,6 @@ FocusEnergyEffect_:
jpab PrintButItFailedText_
GettingPumpedText:
- db $0a
+ TX_DELAY
TX_FAR _GettingPumpedText
db "@"
diff --git a/engine/battle/moveEffects/haze_effect.asm b/engine/battle/moveEffects/haze_effect.asm
index bd20f231..47723ba2 100644
--- a/engine/battle/moveEffects/haze_effect.asm
+++ b/engine/battle/moveEffects/haze_effect.asm
@@ -12,6 +12,7 @@ HazeEffect_:
ld hl, wEnemyMonUnmodifiedAttack
ld de, wEnemyMonAttack
call ResetStats
+; cure non-volatile status, but only for the target
ld hl, wEnemyMonStatus
ld de, wEnemySelectedMove
ld a, [H_WHOSETURN]
@@ -46,15 +47,14 @@ HazeEffect_:
jp PrintText
CureVolatileStatuses:
-; only cures statuses of the Pokemon not using Haze
- res Confused, [hl]
+ res CONFUSED, [hl]
inc hl ; BATTSTATUS2
ld a, [hl]
- ; clear UsingXAccuracy, ProtectedByMist, GettingPumped, and Seeded statuses
- and $ff ^((1 << UsingXAccuracy) | (1 << ProtectedByMist) | (1 << GettingPumped) | (1 << Seeded))
+ ; clear USING_X_ACCURACY, PROTECTED_BY_MIST, GETTING_PUMPED, and SEEDED statuses
+ and $ff ^((1 << USING_X_ACCURACY) | (1 << PROTECTED_BY_MIST) | (1 << GETTING_PUMPED) | (1 << SEEDED))
ld [hli], a ; BATTSTATUS3
ld a, [hl]
- and %11110000 | (1 << Transformed) ; clear Bad Poison, Reflect and Light Screen statuses
+ and %11110000 | (1 << TRANSFORMED) ; clear Bad Poison, Reflect and Light Screen statuses
ld [hl], a
ret
diff --git a/engine/battle/moveEffects/heal_effect.asm b/engine/battle/moveEffects/heal_effect.asm
index 377c14c4..97afa394 100644
--- a/engine/battle/moveEffects/heal_effect.asm
+++ b/engine/battle/moveEffects/heal_effect.asm
@@ -76,7 +76,7 @@ HealEffect_:
ld a, [de]
sbc [hl]
jr c, .playAnim
-; copy max HP to current HP if an overflow ocurred
+; copy max HP to current HP if an overflow occurred
ld a, [hli]
ld [de], a
ld [wHPBarNewHP+1], a
diff --git a/engine/battle/moveEffects/leech_seed_effect.asm b/engine/battle/moveEffects/leech_seed_effect.asm
index 0f3a2666..f4d3ee9c 100644
--- a/engine/battle/moveEffects/leech_seed_effect.asm
+++ b/engine/battle/moveEffects/leech_seed_effect.asm
@@ -19,9 +19,9 @@ LeechSeedEffect_:
ld a, [de]
cp GRASS
jr z, .moveMissed
- bit Seeded, [hl]
+ bit SEEDED, [hl]
jr nz, .moveMissed
- set Seeded, [hl]
+ set SEEDED, [hl]
callab PlayCurrentMoveAnimation
ld hl, WasSeededText
jp PrintText
diff --git a/engine/battle/moveEffects/mist_effect.asm b/engine/battle/moveEffects/mist_effect.asm
index b92777de..65070a3e 100644
--- a/engine/battle/moveEffects/mist_effect.asm
+++ b/engine/battle/moveEffects/mist_effect.asm
@@ -5,9 +5,9 @@ MistEffect_:
jr z, .mistEffect
ld hl, wEnemyBattleStatus2
.mistEffect
- bit ProtectedByMist, [hl] ; is mon protected by mist?
+ bit PROTECTED_BY_MIST, [hl] ; is mon protected by mist?
jr nz, .mistAlreadyInUse
- set ProtectedByMist, [hl] ; mon is now protected by mist
+ set PROTECTED_BY_MIST, [hl] ; mon is now protected by mist
callab PlayCurrentMoveAnimation
ld hl, ShroudedInMistText
jp PrintText
diff --git a/engine/battle/moveEffects/recoil_effect.asm b/engine/battle/moveEffects/recoil_effect.asm
index 7fc90c44..0f2f087b 100644
--- a/engine/battle/moveEffects/recoil_effect.asm
+++ b/engine/battle/moveEffects/recoil_effect.asm
@@ -25,7 +25,7 @@ RecoilEffect_:
jr nz, .updateHP
inc c ; minimum recoil damage is 1
.updateHP
-; substract HP from user due to the recoil damage
+; subtract HP from user due to the recoil damage
ld a, [hli]
ld [wHPBarMaxHP+1], a
ld a, [hl]
diff --git a/engine/battle/moveEffects/reflect_light_screen_effect.asm b/engine/battle/moveEffects/reflect_light_screen_effect.asm
index f2165956..e5748b19 100644
--- a/engine/battle/moveEffects/reflect_light_screen_effect.asm
+++ b/engine/battle/moveEffects/reflect_light_screen_effect.asm
@@ -10,15 +10,15 @@ ReflectLightScreenEffect_:
ld a, [de]
cp LIGHT_SCREEN_EFFECT
jr nz, .reflect
- bit HasLightScreenUp, [hl] ; is mon already protected by light screen?
+ bit HAS_LIGHT_SCREEN_UP, [hl] ; is mon already protected by light screen?
jr nz, .moveFailed
- set HasLightScreenUp, [hl] ; mon is now protected by light screen
+ set HAS_LIGHT_SCREEN_UP, [hl] ; mon is now protected by light screen
ld hl, LightScreenProtectedText
jr .playAnim
.reflect
- bit HasReflectUp, [hl] ; is mon already protected by reflect?
+ bit HAS_REFLECT_UP, [hl] ; is mon already protected by reflect?
jr nz, .moveFailed
- set HasReflectUp, [hl] ; mon is now protected by reflect
+ set HAS_REFLECT_UP, [hl] ; mon is now protected by reflect
ld hl, ReflectGainedArmorText
.playAnim
push hl
diff --git a/engine/battle/moveEffects/substitute_effect.asm b/engine/battle/moveEffects/substitute_effect.asm
index 03314ebf..b5d006fc 100644
--- a/engine/battle/moveEffects/substitute_effect.asm
+++ b/engine/battle/moveEffects/substitute_effect.asm
@@ -12,7 +12,7 @@ SubstituteEffect_:
ld bc, wEnemyBattleStatus2
.notEnemy
ld a, [bc]
- bit HasSubstituteUp, a ; user already has substitute?
+ bit HAS_SUBSTITUTE_UP, a ; user already has substitute?
jr nz, .alreadyHasSubstitute
; quarter health to remove from user
; assumes max HP is 1023 or lower
@@ -37,13 +37,13 @@ SubstituteEffect_:
sbc 0
pop bc
jr c, .notEnoughHP ; underflow means user would be left with negative health
- ; bug: since it only brances on carry, it will possibly leave user with 0 HP
+ ; bug: since it only branches on carry, it will possibly leave user with 0 HP
.userHasZeroOrMoreHP
- ldi [hl], a ; save resulting HP after substraction into current HP
+ ldi [hl], a ; save resulting HP after subtraction into current HP
ld [hl], d
ld h, b
ld l, c
- set HasSubstituteUp, [hl]
+ set HAS_SUBSTITUTE_UP, [hl]
ld a, [wOptions]
bit 7, a ; battle animation is enabled?
ld hl, PlayCurrentMoveAnimation
diff --git a/engine/battle/moveEffects/transform_effect.asm b/engine/battle/moveEffects/transform_effect.asm
index 2906de11..ec07b303 100644
--- a/engine/battle/moveEffects/transform_effect.asm
+++ b/engine/battle/moveEffects/transform_effect.asm
@@ -12,7 +12,7 @@ TransformEffect_:
ld [wPlayerMoveListIndex], a
ld a, [wPlayerBattleStatus1]
.hitTest
- bit Invulnerable, a ; is mon invulnerable to typical attacks? (fly/dig)
+ bit INVULNERABLE, a ; is mon invulnerable to typical attacks? (fly/dig)
jp nz, .failed
push hl
push de
@@ -24,7 +24,7 @@ TransformEffect_:
ld hl, wEnemyBattleStatus2
.transformEffect
; animation(s) played are different if target has Substitute up
- bit HasSubstituteUp, [hl]
+ bit HAS_SUBSTITUTE_UP, [hl]
push af
ld hl, HideSubstituteShowMonAnim
ld b, BANK(HideSubstituteShowMonAnim)
@@ -44,7 +44,7 @@ TransformEffect_:
call nz, Bankswitch
pop bc
ld a, [bc]
- set Transformed, a ; mon is now Transformed
+ set TRANSFORMED, a ; mon is now transformed
ld [bc], a
pop de
pop hl
diff --git a/engine/battle/read_trainer_party.asm b/engine/battle/read_trainer_party.asm
index 3f10a85d..b4ee46a0 100755
--- a/engine/battle/read_trainer_party.asm
+++ b/engine/battle/read_trainer_party.asm
@@ -1,43 +1,43 @@
ReadTrainer:
; don't change any moves in a link battle
- ld a,[wLinkState]
+ ld a, [wLinkState]
and a
ret nz
; set [wEnemyPartyCount] to 0, [wEnemyPartyMons] to FF
; XXX first is total enemy pokemon?
; XXX second is species of first pokemon?
- ld hl,wEnemyPartyCount
+ ld hl, wEnemyPartyCount
xor a
- ld [hli],a
+ ld [hli], a
dec a
- ld [hl],a
+ ld [hl], a
; get the pointer to trainer data for this class
- ld a,[wTrainerClass] ; get trainer class
+ ld a, [wTrainerClass] ; get trainer class
dec a
add a
- ld hl,TrainerDataPointers
- ld c,a
- ld b,0
- add hl,bc ; hl points to trainer class
- ld a,[hli]
- ld h,[hl]
- ld l,a
- ld a,[wTrainerNo]
- ld b,a
+ ld hl, TrainerDataPointers
+ ld c, a
+ ld b, 0
+ add hl, bc ; hl points to trainer class
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, [wTrainerNo]
+ ld b, a
; At this point b contains the trainer number,
; and hl points to the trainer class.
; Our next task is to iterate through the trainers,
; decrementing b each time, until we get to the right one.
.outer
dec b
- jr z,.IterateTrainer
+ jr z, .IterateTrainer
.inner
- ld a,[hli]
+ ld a, [hli]
and a
- jr nz,.inner
+ jr nz, .inner
jr .outer
; if the first byte of trainer data is FF,
@@ -46,17 +46,17 @@ ReadTrainer:
; - if [wLoneAttackNo] != 0, one pokemon on the team has a special move
; else the first byte is the level of every pokemon on the team
.IterateTrainer
- ld a,[hli]
+ ld a, [hli]
cp $FF ; is the trainer special?
- jr z,.SpecialTrainer ; if so, check for special moves
- ld [wCurEnemyLVL],a
+ jr z, .SpecialTrainer ; if so, check for special moves
+ ld [wCurEnemyLVL], a
.LoopTrainerData
- ld a,[hli]
+ ld a, [hli]
and a ; have we reached the end of the trainer data?
jp z, .AddAdditionalMoveData
- ld [wcf91],a ; write species somewhere (XXX why?)
- ld a,ENEMY_PARTY_DATA
- ld [wMonDataLocation],a
+ ld [wcf91], a ; write species somewhere (XXX why?)
+ ld a, ENEMY_PARTY_DATA
+ ld [wMonDataLocation], a
push hl
call AddPartyMon
pop hl
@@ -66,14 +66,14 @@ ReadTrainer:
; - each pokemon has a specific level
; (as opposed to the whole team being of the same level)
; - if [wLoneAttackNo] != 0, one pokemon on the team has a special move
- ld a,[hli]
+ ld a, [hli]
and a ; have we reached the end of the trainer data?
- jr z,.AddAdditionalMoveData
- ld [wCurEnemyLVL],a
- ld a,[hli]
- ld [wcf91],a
- ld a,ENEMY_PARTY_DATA
- ld [wMonDataLocation],a
+ jr z, .AddAdditionalMoveData
+ ld [wCurEnemyLVL], a
+ ld a, [hli]
+ ld [wcf91], a
+ ld a, ENEMY_PARTY_DATA
+ ld [wMonDataLocation], a
push hl
call AddPartyMon
pop hl
@@ -123,23 +123,23 @@ ReadTrainer:
.FinishUp
; clear wAmountMoneyWon addresses
xor a
- ld de,wAmountMoneyWon
- ld [de],a
+ ld de, wAmountMoneyWon
+ ld [de], a
inc de
- ld [de],a
+ ld [de], a
inc de
- ld [de],a
- ld a,[wCurEnemyLVL]
- ld b,a
+ ld [de], a
+ ld a, [wCurEnemyLVL]
+ ld b, a
.LastLoop
; update wAmountMoneyWon addresses (money to win) based on enemy's level
- ld hl,wTrainerBaseMoney + 1
- ld c,2 ; wAmountMoneyWon is a 3-byte number
+ ld hl, wTrainerBaseMoney + 1
+ ld c, 2 ; wAmountMoneyWon is a 3-byte number
push bc
predef AddBCDPredef
pop bc
inc de
inc de
dec b
- jr nz,.LastLoop ; repeat wCurEnemyLVL times
+ jr nz, .LastLoop ; repeat wCurEnemyLVL times
ret
diff --git a/engine/battle/safari_zone.asm b/engine/battle/safari_zone.asm
index c6c0fa80..88064f9a 100755
--- a/engine/battle/safari_zone.asm
+++ b/engine/battle/safari_zone.asm
@@ -19,7 +19,7 @@ PrintSafariZoneBattleText:
ld [wd0b5], a
call GetMonHeader
ld a, [wMonHCatchRate]
- ld [wEnemyMonCatchRate], a
+ ld [wEnemyMonActualCatchRate], a
pop hl
.asm_4138
push hl
diff --git a/engine/battle/save_trainer_name.asm b/engine/battle/save_trainer_name.asm
index 7e2c911c..49d0429f 100644
--- a/engine/battle/save_trainer_name.asm
+++ b/engine/battle/save_trainer_name.asm
@@ -1,21 +1,21 @@
SaveTrainerName:
- ld hl,TrainerNamePointers
- ld a,[wTrainerClass]
+ ld hl, TrainerNamePointers
+ ld a, [wTrainerClass]
dec a
- ld c,a
- ld b,0
- add hl,bc
- add hl,bc
- ld a,[hli]
- ld h,[hl]
- ld l,a
- ld de,wcd6d
+ ld c, a
+ ld b, 0
+ add hl, bc
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld de, wcd6d
.CopyCharacter
- ld a,[hli]
- ld [de],a
+ ld a, [hli]
+ ld [de], a
inc de
cp "@"
- jr nz,.CopyCharacter
+ jr nz, .CopyCharacter
ret
TrainerNamePointers:
diff --git a/engine/battle/trainer_ai.asm b/engine/battle/trainer_ai.asm
index ddaf1350..c8fdfb29 100644
--- a/engine/battle/trainer_ai.asm
+++ b/engine/battle/trainer_ai.asm
@@ -51,7 +51,7 @@ AIEnemyTrainerChooseMoves:
ld l, a
ld de, .nextMoveChoiceModification ; set return address
push de
- jp hl ; execute modification function
+ jp hl ; execute modification function
.loopFindMinimumEntries ; all entries will be decremented sequentially until one of them is zero
ld hl, wBuffer ; temp move selection array
ld de, wEnemyMonMoves ; enemy moves
@@ -114,7 +114,7 @@ AIMoveChoiceModification1:
ld a, [wBattleMonStatus]
and a
ret z ; return if no status ailment on player's mon
- ld hl, wBuffer - 1 ; temp move selection array (-1 byte offest)
+ ld hl, wBuffer - 1 ; temp move selection array (-1 byte offset)
ld de, wEnemyMonMoves ; enemy moves
ld b, NUM_MOVES + 1
.nextMove
@@ -154,7 +154,7 @@ StatusAilmentMoveEffects:
; slightly encourage moves with specific effects.
; in particular, stat-modifying moves and other move effects
-; that fall in-bewteen
+; that fall in-between
AIMoveChoiceModification2:
ld a, [wAILayer2Encouragement]
cp $1
@@ -212,7 +212,7 @@ AIMoveChoiceModification3:
cp $10
jr z, .nextMove
jr c, .notEffectiveMove
- dec [hl] ; sligthly encourage this move
+ dec [hl] ; slightly encourage this move
jr .nextMove
.notEffectiveMove ; discourages non-effective moves if better moves are available
push hl
@@ -253,7 +253,7 @@ AIMoveChoiceModification3:
pop hl
and a
jr z, .nextMove
- inc [hl] ; sligthly discourage this move
+ inc [hl] ; slightly discourage this move
jr .nextMove
AIMoveChoiceModification4:
ret
@@ -263,10 +263,10 @@ ReadMove:
push de
push bc
dec a
- ld hl,Moves
- ld bc,MoveEnd - Moves
+ ld hl, Moves
+ ld bc, MoveEnd - Moves
call AddNTimes
- ld de,wEnemyMoveNum
+ ld de, wEnemyMoveNum
call CopyData
pop bc
pop de
@@ -337,40 +337,40 @@ INCLUDE "data/trainer_moves.asm"
INCLUDE "data/trainer_parties.asm"
TrainerAI:
- ld a,[wIsInBattle]
+ ld a, [wIsInBattle]
dec a
jr z, .done ; if not a trainer, we're done here
- ld a,[wLinkState]
+ ld a, [wLinkState]
cp LINK_STATE_BATTLING
jr z, .done ; if in a link battle, we're done as well
ld a, [wEnemyBattleStatus1]
- and 1 << ChargingUp | 1 << ThrashingAbout | 1 << StoringEnergy ; %10011
+ and 1 << CHARGING_UP | 1 << THRASHING_ABOUT | 1 << STORING_ENERGY ; %10011
jr nz, .done ; don't follow trainer ai if opponent is in a locked state
ld a, [wEnemyBattleStatus2]
- and 1 << UsingRage ; %1000000
+ and 1 << USING_RAGE ; %1000000
jr nz, .done ; don't follow trainer ai if opponent is locked in rage
; note that this doesn't check for hyper beam recharge which can cause problems
ld a,[wTrainerClass] ; what trainer class is this?
dec a
- ld c,a
- ld b,0
- ld hl,TrainerAIPointers
- add hl,bc
- add hl,bc
- add hl,bc
- ld a,[wAICount]
+ ld c, a
+ ld b, 0
+ ld hl, TrainerAIPointers
+ add hl, bc
+ add hl, bc
+ add hl, bc
+ ld a, [wAICount]
and a
jr z, .done; if no AI uses left, we're done here
inc hl
inc a
- jr nz,.getpointer
+ jr nz, .getpointer
dec hl
- ld a,[hli]
- ld [wAICount],a
+ ld a, [hli]
+ ld [wAICount], a
.getpointer
- ld a,[hli]
- ld h,[hl]
- ld l,a
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
call Random
jp hl
.done
@@ -451,17 +451,17 @@ CooltrainerMAI:
CooltrainerFAI:
cp 25 percent + 1
- ld a,10
+ ld a, 10
call AICheckIfHPBelowFraction
- jp c,AIUseHyperPotion
- ld a,5
+ jp c, AIUseHyperPotion
+ ld a, 5
call AICheckIfHPBelowFraction
ret nc
jp AISwitchIfEnoughMons
BrockAI:
; if his active monster has a status condition, use a full heal
- ld a,[wEnemyMonStatus]
+ ld a, [wEnemyMonStatus]
and a
ret z
jp AIUseFullHeal
@@ -479,7 +479,7 @@ LtSurgeAI:
ErikaAI:
cp 50 percent + 1
ret nc
- ld a,10
+ ld a, 10
call AICheckIfHPBelowFraction
ret nc
jp AIUseSuperPotion
@@ -492,7 +492,7 @@ KogaAI:
BlaineAI:
cp 25 percent + 1
ret nc
- ld a,10
+ ld a, 10
call AICheckIfHPBelowFraction
ret nc
jp AIUseSuperPotion
@@ -505,7 +505,7 @@ SabrinaAI:
Sony2AI:
cp 13 percent - 1
ret nc
- ld a,5
+ ld a, 5
call AICheckIfHPBelowFraction
ret nc
jp AIUsePotion
@@ -513,7 +513,7 @@ Sony2AI:
Sony3AI:
cp 13 percent - 1
ret nc
- ld a,5
+ ld a, 5
call AICheckIfHPBelowFraction
ret nc
jp AIUseFullRestore
@@ -521,7 +521,7 @@ Sony3AI:
LoreleiAI:
cp 50 percent + 1
ret nc
- ld a,5
+ ld a, 5
call AICheckIfHPBelowFraction
ret nc
jp AIUseSuperPotion
@@ -533,10 +533,10 @@ BrunoAI:
AgathaAI:
cp 8 percent
- jp c,AISwitchIfEnoughMons
+ jp c, AISwitchIfEnoughMons
cp 50 percent + 1
ret nc
- ld a,4
+ ld a, 4
call AICheckIfHPBelowFraction
ret nc
jp AIUseSuperPotion
@@ -544,7 +544,7 @@ AgathaAI:
LanceAI:
cp 50 percent + 1
ret nc
- ld a,5
+ ld a, 5
call AICheckIfHPBelowFraction
ret nc
jp AIUseHyperPotion
@@ -556,133 +556,133 @@ GenericAI:
; end of individual trainer AI routines
DecrementAICount:
- ld hl,wAICount
+ ld hl, wAICount
dec [hl]
scf
ret
AIPlayRestoringSFX:
- ld a,SFX_HEAL_AILMENT
+ ld a, SFX_HEAL_AILMENT
jp PlaySoundWaitForCurrent
AIUseFullRestore:
call AICureStatus
- ld a,FULL_RESTORE
- ld [wAIItem],a
- ld de,wHPBarOldHP
- ld hl,wEnemyMonHP + 1
- ld a,[hld]
- ld [de],a
+ ld a, FULL_RESTORE
+ ld [wAIItem], a
+ ld de, wHPBarOldHP
+ ld hl, wEnemyMonHP + 1
+ ld a, [hld]
+ ld [de], a
inc de
- ld a,[hl]
- ld [de],a
+ ld a, [hl]
+ ld [de], a
inc de
- ld hl,wEnemyMonMaxHP + 1
- ld a,[hld]
- ld [de],a
+ ld hl, wEnemyMonMaxHP + 1
+ ld a, [hld]
+ ld [de], a
inc de
- ld [wHPBarMaxHP],a
- ld [wEnemyMonHP + 1],a
- ld a,[hl]
- ld [de],a
- ld [wHPBarMaxHP+1],a
- ld [wEnemyMonHP],a
+ ld [wHPBarMaxHP], a
+ ld [wEnemyMonHP + 1], a
+ ld a, [hl]
+ ld [de], a
+ ld [wHPBarMaxHP+1], a
+ ld [wEnemyMonHP], a
jr AIPrintItemUseAndUpdateHPBar
AIUsePotion:
; enemy trainer heals his monster with a potion
- ld a,POTION
- ld b,20
+ ld a, POTION
+ ld b, 20
jr AIRecoverHP
AIUseSuperPotion:
; enemy trainer heals his monster with a super potion
- ld a,SUPER_POTION
- ld b,50
+ ld a, SUPER_POTION
+ ld b, 50
jr AIRecoverHP
AIUseHyperPotion:
; enemy trainer heals his monster with a hyper potion
- ld a,HYPER_POTION
- ld b,200
+ ld a, HYPER_POTION
+ ld b, 200
; fallthrough
AIRecoverHP:
; heal b HP and print "trainer used $(a) on pokemon!"
- ld [wAIItem],a
- ld hl,wEnemyMonHP + 1
- ld a,[hl]
- ld [wHPBarOldHP],a
+ ld [wAIItem], a
+ ld hl, wEnemyMonHP + 1
+ ld a, [hl]
+ ld [wHPBarOldHP], a
add b
- ld [hld],a
- ld [wHPBarNewHP],a
- ld a,[hl]
- ld [wHPBarOldHP+1],a
- ld [wHPBarNewHP+1],a
- jr nc,.next
+ ld [hld], a
+ ld [wHPBarNewHP], a
+ ld a, [hl]
+ ld [wHPBarOldHP+1], a
+ ld [wHPBarNewHP+1], a
+ jr nc, .next
inc a
- ld [hl],a
- ld [wHPBarNewHP+1],a
+ ld [hl], a
+ ld [wHPBarNewHP+1], a
.next
inc hl
- ld a,[hld]
- ld b,a
- ld de,wEnemyMonMaxHP + 1
- ld a,[de]
+ ld a, [hld]
+ ld b, a
+ ld de, wEnemyMonMaxHP + 1
+ ld a, [de]
dec de
- ld [wHPBarMaxHP],a
+ ld [wHPBarMaxHP], a
sub b
- ld a,[hli]
- ld b,a
- ld a,[de]
- ld [wHPBarMaxHP+1],a
+ ld a, [hli]
+ ld b, a
+ ld a, [de]
+ ld [wHPBarMaxHP+1], a
sbc b
- jr nc,AIPrintItemUseAndUpdateHPBar
+ jr nc, AIPrintItemUseAndUpdateHPBar
inc de
- ld a,[de]
+ ld a, [de]
dec de
- ld [hld],a
- ld [wHPBarNewHP],a
- ld a,[de]
- ld [hl],a
- ld [wHPBarNewHP+1],a
+ ld [hld], a
+ ld [wHPBarNewHP], a
+ ld a, [de]
+ ld [hl], a
+ ld [wHPBarNewHP+1], a
; fallthrough
AIPrintItemUseAndUpdateHPBar:
call AIPrintItemUse_
coord hl, 2, 2
xor a
- ld [wHPBarType],a
+ ld [wHPBarType], a
predef UpdateHPBar2
jp DecrementAICount
AISwitchIfEnoughMons:
; enemy trainer switches if there are 3 or more unfainted mons in party
- ld a,[wEnemyPartyCount]
- ld c,a
- ld hl,wEnemyMon1HP
+ ld a, [wEnemyPartyCount]
+ ld c, a
+ ld hl, wEnemyMon1HP
- ld d,0 ; keep count of unfainted monsters
+ ld d, 0 ; keep count of unfainted monsters
; count how many monsters haven't fainted yet
.loop
- ld a,[hli]
- ld b,a
- ld a,[hld]
+ ld a, [hli]
+ ld b, a
+ ld a, [hld]
or b
- jr z,.Fainted ; has monster fainted?
+ jr z, .Fainted ; has monster fainted?
inc d
.Fainted
push bc
ld bc, wEnemyMon2 - wEnemyMon1
- add hl,bc
+ add hl, bc
pop bc
dec c
- jr nz,.loop
+ jr nz, .loop
- ld a,d ; how many available monsters are there?
+ ld a, d ; how many available monsters are there?
cp 2 ; don't bother if only 1 or 2
- jp nc,SwitchEnemyMon
+ jp nc, SwitchEnemyMon
and a
ret
@@ -690,14 +690,14 @@ SwitchEnemyMon:
; prepare to withdraw the active monster: copy hp, number, and status to roster
- ld a,[wEnemyMonPartyPos]
- ld hl,wEnemyMon1HP
- ld bc,wEnemyMon2 - wEnemyMon1
+ ld a, [wEnemyMonPartyPos]
+ ld hl, wEnemyMon1HP
+ ld bc, wEnemyMon2 - wEnemyMon1
call AddNTimes
- ld d,h
- ld e,l
- ld hl,wEnemyMonHP
- ld bc,4
+ ld d, h
+ ld e, l
+ ld hl, wEnemyMonHP
+ ld bc, 4
call CopyData
ld hl, AIBattleWithdrawText
@@ -705,13 +705,13 @@ SwitchEnemyMon:
; This wFirstMonsNotOutYet variable is abused to prevent the player from
; switching in a new mon in response to this switch.
- ld a,1
- ld [wFirstMonsNotOutYet],a
+ ld a, 1
+ ld [wFirstMonsNotOutYet], a
callab EnemySendOut
xor a
- ld [wFirstMonsNotOutYet],a
+ ld [wFirstMonsNotOutYet], a
- ld a,[wLinkState]
+ ld a, [wLinkState]
cp LINK_STATE_BATTLING
ret z
scf
@@ -724,120 +724,120 @@ AIBattleWithdrawText:
AIUseFullHeal:
call AIPlayRestoringSFX
call AICureStatus
- ld a,FULL_HEAL
+ ld a, FULL_HEAL
jp AIPrintItemUse
AICureStatus:
; cures the status of enemy's active pokemon
- ld a,[wEnemyMonPartyPos]
- ld hl,wEnemyMon1Status
- ld bc,wEnemyMon2 - wEnemyMon1
+ ld a, [wEnemyMonPartyPos]
+ ld hl, wEnemyMon1Status
+ ld bc, wEnemyMon2 - wEnemyMon1
call AddNTimes
xor a
- ld [hl],a ; clear status in enemy team roster
- ld [wEnemyMonStatus],a ; clear status of active enemy
- ld hl,wEnemyBattleStatus3
- res 0,[hl]
+ ld [hl], a ; clear status in enemy team roster
+ ld [wEnemyMonStatus], a ; clear status of active enemy
+ ld hl, wEnemyBattleStatus3
+ res 0, [hl]
ret
AIUseXAccuracy: ; unused
call AIPlayRestoringSFX
- ld hl,wEnemyBattleStatus2
- set 0,[hl]
- ld a,X_ACCURACY
+ ld hl, wEnemyBattleStatus2
+ set 0, [hl]
+ ld a, X_ACCURACY
jp AIPrintItemUse
AIUseGuardSpec:
call AIPlayRestoringSFX
- ld hl,wEnemyBattleStatus2
- set 1,[hl]
- ld a,GUARD_SPEC
+ ld hl, wEnemyBattleStatus2
+ set 1, [hl]
+ ld a, GUARD_SPEC
jp AIPrintItemUse
AIUseDireHit: ; unused
call AIPlayRestoringSFX
- ld hl,wEnemyBattleStatus2
- set 2,[hl]
- ld a,DIRE_HIT
+ ld hl, wEnemyBattleStatus2
+ set 2, [hl]
+ ld a, DIRE_HIT
jp AIPrintItemUse
AICheckIfHPBelowFraction:
; return carry if enemy trainer's current HP is below 1 / a of the maximum
- ld [H_DIVISOR],a
- ld hl,wEnemyMonMaxHP
- ld a,[hli]
- ld [H_DIVIDEND],a
- ld a,[hl]
- ld [H_DIVIDEND + 1],a
- ld b,2
+ ld [H_DIVISOR], a
+ ld hl, wEnemyMonMaxHP
+ ld a, [hli]
+ ld [H_DIVIDEND], a
+ ld a, [hl]
+ ld [H_DIVIDEND + 1], a
+ ld b, 2
call Divide
- ld a,[H_QUOTIENT + 3]
- ld c,a
- ld a,[H_QUOTIENT + 2]
- ld b,a
- ld hl,wEnemyMonHP + 1
- ld a,[hld]
- ld e,a
- ld a,[hl]
- ld d,a
- ld a,d
+ ld a, [H_QUOTIENT + 3]
+ ld c, a
+ ld a, [H_QUOTIENT + 2]
+ ld b, a
+ ld hl, wEnemyMonHP + 1
+ ld a, [hld]
+ ld e, a
+ ld a, [hl]
+ ld d, a
+ ld a, d
sub b
ret nz
- ld a,e
+ ld a, e
sub c
ret
AIUseXAttack:
- ld b,$A
- ld a,X_ATTACK
+ ld b, $A
+ ld a, X_ATTACK
jr AIIncreaseStat
AIUseXDefend:
- ld b,$B
- ld a,X_DEFEND
+ ld b, $B
+ ld a, X_DEFEND
jr AIIncreaseStat
AIUseXSpeed:
- ld b,$C
- ld a,X_SPEED
+ ld b, $C
+ ld a, X_SPEED
jr AIIncreaseStat
AIUseXSpecial:
- ld b,$D
- ld a,X_SPECIAL
+ ld b, $D
+ ld a, X_SPECIAL
; fallthrough
AIIncreaseStat:
- ld [wAIItem],a
+ ld [wAIItem], a
push bc
call AIPrintItemUse_
pop bc
- ld hl,wEnemyMoveEffect
- ld a,[hld]
+ ld hl, wEnemyMoveEffect
+ ld a, [hld]
push af
- ld a,[hl]
+ ld a, [hl]
push af
push hl
- ld a,ANIM_AF
- ld [hli],a
- ld [hl],b
+ ld a, ANIM_AF
+ ld [hli], a
+ ld [hl], b
callab StatModifierUpEffect
pop hl
pop af
- ld [hli],a
+ ld [hli], a
pop af
- ld [hl],a
+ ld [hl], a
jp DecrementAICount
AIPrintItemUse:
- ld [wAIItem],a
+ ld [wAIItem], a
call AIPrintItemUse_
jp DecrementAICount
AIPrintItemUse_:
; print "x used [wAIItem] on z!"
- ld a,[wAIItem]
- ld [wd11e],a
+ ld a, [wAIItem]
+ ld [wd11e], a
call GetItemName
ld hl, AIBattleUseItemText
jp PrintText
diff --git a/engine/bcd.asm b/engine/bcd.asm
index 204c2e40..d84e504b 100644
--- a/engine/bcd.asm
+++ b/engine/bcd.asm
@@ -13,10 +13,12 @@ DivideBCD::
ld [hDivideBCDBuffer + 1], a
ld [hDivideBCDBuffer + 2], a
ld d, $1
-.loop1
+.mulBy10Loop
+; multiply the divisor by 10 until the leading digit is nonzero
+; to set up the standard long division algorithm
ld a, [hDivideBCDDivisor]
and $f0
- jr nz, .go
+ jr nz, .next
inc d
ld a, [hDivideBCDDivisor]
swap a
@@ -40,85 +42,85 @@ DivideBCD::
ld a, [hDivideBCDDivisor + 2]
and $f0
ld [hDivideBCDDivisor + 2], a
- jr .loop1
+ jr .mulBy10Loop
-.go
+.next
push de
push de
- call DivideBCD_f686
+ call DivideBCD_getNextDigit
pop de
ld a, b
swap a
and $f0
ld [hDivideBCDBuffer], a
dec d
- jr z, .skip
+ jr z, .next2
push de
- call DivideBCD_f65d
- call DivideBCD_f686
+ call DivideBCD_divDivisorBy10
+ call DivideBCD_getNextDigit
pop de
ld a, [hDivideBCDBuffer]
or b
ld [hDivideBCDBuffer], a
dec d
- jr z, .skip
+ jr z, .next2
push de
- call DivideBCD_f65d
- call DivideBCD_f686
+ call DivideBCD_divDivisorBy10
+ call DivideBCD_getNextDigit
pop de
ld a, b
swap a
and $f0
ld [hDivideBCDBuffer + 1], a
dec d
- jr z, .skip
+ jr z, .next2
push de
- call DivideBCD_f65d
- call DivideBCD_f686
+ call DivideBCD_divDivisorBy10
+ call DivideBCD_getNextDigit
pop de
ld a, [hDivideBCDBuffer + 1]
or b
ld [hDivideBCDBuffer + 1], a
dec d
- jr z, .skip
+ jr z, .next2
push de
- call DivideBCD_f65d
- call DivideBCD_f686
+ call DivideBCD_divDivisorBy10
+ call DivideBCD_getNextDigit
pop de
ld a, b
swap a
and $f0
ld [hDivideBCDBuffer + 2], a
dec d
- jr z, .skip
+ jr z, .next2
push de
- call DivideBCD_f65d
- call DivideBCD_f686
+ call DivideBCD_divDivisorBy10
+ call DivideBCD_getNextDigit
pop de
ld a, [hDivideBCDBuffer + 2]
or b
ld [hDivideBCDBuffer + 2], a
-.skip
+.next2
ld a, [hDivideBCDBuffer]
- ld [hDivideBCDQuotient], a
+ ld [hDivideBCDQuotient], a ; the same memory location as hDivideBCDDivisor
ld a, [hDivideBCDBuffer + 1]
ld [hDivideBCDQuotient + 1], a
ld a, [hDivideBCDBuffer + 2]
ld [hDivideBCDQuotient + 2], a
pop de
- ld a, $6
+ ld a, $6
sub d
and a
ret z
-.loop2
+.divResultBy10loop
push af
- call DivideBCD_f65d
+ call DivideBCD_divDivisorBy10
pop af
dec a
- jr nz, .loop2
+ jr nz, .divResultBy10loop
ret
-DivideBCD_f65d:
+DivideBCD_divDivisorBy10:
ld a, [hDivideBCDDivisor + 2]
swap a
and $f
@@ -143,22 +145,22 @@ DivideBCD_f65d:
ld [hDivideBCDDivisor], a
ret
-DivideBCD_f686:
+DivideBCD_getNextDigit:
ld bc, $3
-.asm_f689
- ld de, hMoney
+.loop
+ ld de, hMoney ; the dividend
ld hl, hDivideBCDDivisor
push bc
call StringCmp
pop bc
ret c
inc b
- ld de, hMoney + 2
+ ld de, hMoney + 2 ; since SubBCD works starting from the least significant digit
ld hl, hDivideBCDDivisor + 2
push bc
call SubBCD
pop bc
- jr .asm_f689
+ jr .loop
AddBCDPredef::
diff --git a/engine/black_out.asm b/engine/black_out.asm
new file mode 100644
index 00000000..0daa084b
--- /dev/null
+++ b/engine/black_out.asm
@@ -0,0 +1,48 @@
+ResetStatusAndHalveMoneyOnBlackout::
+; Reset player status on blackout.
+ xor a
+ ld [wd435], a
+ xor a ; gamefreak copypasting functions (double xor a)
+ ld [wBattleResult], a
+ ld [wWalkBikeSurfState], a
+ ld [wIsInBattle], a
+ ld [wMapPalOffset], a
+ ld [wNPCMovementScriptFunctionNum], a
+ ld [hJoyHeld], a
+ ld [wNPCMovementScriptPointerTableNum], a
+ ld [wFlags_0xcd60], a
+
+ ld [hMoney], a
+ ld [hMoney + 1], a
+ ld [hMoney + 2], a
+ call HasEnoughMoney
+ jr c, .lostmoney ; never happens
+
+ ; Halve the player's money.
+ ld a, [wPlayerMoney]
+ ld [hMoney], a
+ ld a, [wPlayerMoney + 1]
+ ld [hMoney + 1], a
+ ld a, [wPlayerMoney + 2]
+ ld [hMoney + 2], a
+ xor a
+ ld [hDivideBCDDivisor], a
+ ld [hDivideBCDDivisor + 1], a
+ ld a, 2
+ ld [hDivideBCDDivisor + 2], a
+ predef DivideBCDPredef3
+ ld a, [hDivideBCDQuotient]
+ ld [wPlayerMoney], a
+ ld a, [hDivideBCDQuotient + 1]
+ ld [wPlayerMoney + 1], a
+ ld a, [hDivideBCDQuotient + 2]
+ ld [wPlayerMoney + 2], a
+
+.lostmoney
+ ld hl, wd732
+ set 2, [hl]
+ res 3, [hl]
+ set 6, [hl]
+ ld a, %11111111
+ ld [wJoyIgnore], a
+ predef_jump HealParty
diff --git a/engine/cable_club.asm b/engine/cable_club.asm
index 7ff5fda1..a8dc5d8d 100755
--- a/engine/cable_club.asm
+++ b/engine/cable_club.asm
@@ -554,11 +554,11 @@ TradeCenter_SelectMon:
ld a, " "
ld [hl], a
.cancelMenuItem_Loop
- ld a, $ed ; filled arrow cursor
+ ld a, "▶" ; filled arrow cursor
Coorda 1, 16
.cancelMenuItem_JoypadLoop
call JoypadLowSensitivity
- ld a, [$ffb5]
+ ld a, [hJoy5]
and a ; pressed anything?
jr z, .cancelMenuItem_JoypadLoop
bit 0, a ; A button pressed?
@@ -573,7 +573,7 @@ TradeCenter_SelectMon:
ld [wCurrentMenuItem], a
jp .playerMonMenu
.cancelMenuItem_APressed
- ld a, $ec ; unfilled arrow cursor
+ ld a, "▷" ; unfilled arrow cursor
Coorda 1, 16
ld a, $f
ld [wSerialExchangeNybbleSendData], a
@@ -595,7 +595,7 @@ ReturnToCableClubRoom:
dec a
ld [wDestinationWarpID], a
call LoadMapData
- callba ClearVariablesAfterLoadingMapData
+ callba ClearVariablesOnEnterMap
pop hl
pop af
ld [hl], a
@@ -622,7 +622,7 @@ TradeCenter_PlaceSelectedEnemyMonMenuCursor:
coord hl, 1, 9
ld bc, SCREEN_WIDTH
call AddNTimes
- ld [hl], $ec ; cursor
+ ld [hl], "▷" ; cursor
ret
TradeCenter_DisplayStats:
@@ -921,7 +921,7 @@ CableClub_Run:
ld [wGrassRate], a
inc a ; LINK_STATE_IN_CABLE_CLUB
ld [wLinkState], a
- ld [$ffb5], a
+ ld [hJoy5], a
ld a, 10
ld [wAudioFadeOutControl], a
ld a, BANK(Music_Celadon)
diff --git a/engine/display_text_id_init.asm b/engine/display_text_id_init.asm
new file mode 100644
index 00000000..0ef37370
--- /dev/null
+++ b/engine/display_text_id_init.asm
@@ -0,0 +1,75 @@
+; function that performs initialization for DisplayTextID
+DisplayTextIDInit:
+ xor a
+ ld [wListMenuID], a
+ ld a, [wAutoTextBoxDrawingControl]
+ bit 0, a
+ jr nz, .skipDrawingTextBoxBorder
+ ld a, [hSpriteIndexOrTextID] ; text ID (or sprite ID)
+ and a
+ jr nz, .notStartMenu
+; if text ID is 0 (i.e. the start menu)
+; Note that the start menu text border is also drawn in the function directly
+; below this, so this seems unnecessary.
+ CheckEvent EVENT_GOT_POKEDEX
+; start menu with pokedex
+ coord hl, 10, 0
+ lb bc, 14, 8
+ jr nz, .drawTextBoxBorder
+; start menu without pokedex
+ coord hl, 10, 0
+ lb bc, 12, 8
+ jr .drawTextBoxBorder
+; if text ID is not 0 (i.e. not the start menu) then do a standard dialogue text box
+.notStartMenu
+ coord hl, 0, 12
+ lb bc, 4, 18
+.drawTextBoxBorder
+ call TextBoxBorder
+.skipDrawingTextBoxBorder
+ ld hl, wFontLoaded
+ set 0, [hl]
+ ld hl, wFlags_0xcd60
+ bit 4, [hl]
+ res 4, [hl]
+ jr nz, .skipMovingSprites
+ call UpdateSprites
+.skipMovingSprites
+; loop to copy C1X9 (direction the sprite is facing) to C2X9 for each sprite
+; this is done because when you talk to an NPC, they turn to look your way
+; the original direction they were facing must be restored after the dialogue is over
+ ld hl, wSpriteStateData1 + $19
+ ld c, $0f
+ ld de, $0010
+.spriteFacingDirectionCopyLoop
+ ld a, [hl]
+ inc h
+ ld [hl], a
+ dec h
+ add hl, de
+ dec c
+ jr nz, .spriteFacingDirectionCopyLoop
+; loop to force all the sprites in the middle of animation to stand still
+; (so that they don't like they're frozen mid-step during the dialogue)
+ ld hl, wSpriteStateData1 + 2
+ ld de, $0010
+ ld c, e
+.spriteStandStillLoop
+ ld a, [hl]
+ cp $ff ; is the sprite visible?
+ jr z, .nextSprite
+; if it is visible
+ and $fc
+ ld [hl], a
+.nextSprite
+ add hl, de
+ dec c
+ jr nz, .spriteStandStillLoop
+ ld b, $9c ; window background address
+ call CopyScreenTileBufferToVRAM ; transfer background in WRAM to VRAM
+ xor a
+ ld [hWY], a ; put the window on the screen
+ call LoadFontTilePatterns
+ ld a, $01
+ ld [H_AUTOBGTRANSFERENABLED], a ; enable continuous WRAM to VRAM transfer each V-blank
+ ret
diff --git a/engine/evolution.asm b/engine/evolution.asm
index 9cefff27..7277e991 100755
--- a/engine/evolution.asm
+++ b/engine/evolution.asm
@@ -8,7 +8,7 @@ EvolveMon:
push af
xor a
ld [wLowHealthAlarm], a
- ld [wChannelSoundIDs + CH4], a
+ ld [wChannelSoundIDs + Ch5], a
call StopAllMusic
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
diff --git a/engine/flag_action_predef.asm b/engine/flag_action.asm
index dc516887..dc516887 100644
--- a/engine/flag_action_predef.asm
+++ b/engine/flag_action.asm
diff --git a/engine/give_pokemon.asm b/engine/give_pokemon.asm
index 9cbb4039..6fdca2ef 100755
--- a/engine/give_pokemon.asm
+++ b/engine/give_pokemon.asm
@@ -75,7 +75,7 @@ UnknownTerminator_f6794:
GotMonText:
TX_FAR _GotMonText
- db $0b
+ TX_SFX_ITEM_1
db "@"
SetToBoxText:
diff --git a/engine/hall_of_fame.asm b/engine/hall_of_fame.asm
index f0749a06..39a7a2e3 100755
--- a/engine/hall_of_fame.asm
+++ b/engine/hall_of_fame.asm
@@ -6,7 +6,7 @@ AnimateHallOfFame:
call LoadFontTilePatterns
call LoadTextBoxTilePatterns
call DisableLCD
- ld hl,vBGMap0
+ ld hl, vBGMap0
ld bc, $800
ld a, " "
call FillMemory
diff --git a/engine/hidden_object_functions14.asm b/engine/hidden_object_functions14.asm
index 4bb76433..04f9cb35 100755
--- a/engine/hidden_object_functions14.asm
+++ b/engine/hidden_object_functions14.asm
@@ -7,7 +7,7 @@ PrintNotebookText:
TMNotebook:
TX_FAR TMNotebookText
- db $0d
+ TX_WAIT
db "@"
ViridianSchoolNotebook:
@@ -45,7 +45,7 @@ TurnPageText:
ViridianSchoolNotebookText5:
TX_FAR _ViridianSchoolNotebookText5
- db $0d
+ TX_WAIT
db "@"
ViridianSchoolNotebookText1:
diff --git a/engine/hidden_object_functions17.asm b/engine/hidden_object_functions17.asm
index 6019eb4a..8775fd39 100755
--- a/engine/hidden_object_functions17.asm
+++ b/engine/hidden_object_functions17.asm
@@ -81,7 +81,7 @@ FanClubPicture2Text:
DisplayMonFrontSpriteInBox:
; Displays a pokemon's front sprite in a pop-up window.
-; [wcf91] = pokemon interal id number
+; [wcf91] = pokemon internal id number
ld a, 1
ld [H_AUTOBGTRANSFERENABLED], a
call Delay3
diff --git a/engine/hidden_object_functions18.asm b/engine/hidden_object_functions18.asm
index 8d468988..3fd5dd47 100755
--- a/engine/hidden_object_functions18.asm
+++ b/engine/hidden_object_functions18.asm
@@ -96,11 +96,11 @@ BenchGuyTextPointers:
db_tx_pre MtMoonPokecenterBenchGuyText
db ROCK_TUNNEL_POKECENTER, SPRITE_FACING_LEFT
db_tx_pre RockTunnelPokecenterBenchGuyText
- db SAFARI_ZONE_REST_HOUSE_2,SPRITE_FACING_LEFT
+ db SAFARI_ZONE_WEST_REST_HOUSE,SPRITE_FACING_LEFT
db_tx_pre UnusedBenchGuyText1
- db SAFARI_ZONE_REST_HOUSE_3,SPRITE_FACING_LEFT
+ db SAFARI_ZONE_EAST_REST_HOUSE,SPRITE_FACING_LEFT
db_tx_pre UnusedBenchGuyText2
- db SAFARI_ZONE_REST_HOUSE_4,SPRITE_FACING_LEFT
+ db SAFARI_ZONE_NORTH_REST_HOUSE,SPRITE_FACING_LEFT
db_tx_pre UnusedBenchGuyText3
db $FF
diff --git a/engine/hidden_object_functions3.asm b/engine/hidden_object_functions3.asm
index 03836917..11aecd5b 100755
--- a/engine/hidden_object_functions3.asm
+++ b/engine/hidden_object_functions3.asm
@@ -127,7 +127,7 @@ ElevatorText:
TownMapText:
TX_FAR _TownMapText
- db $06
+ TX_BLINK
TX_ASM
ld a, $1
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
diff --git a/engine/hidden_object_functions7.asm b/engine/hidden_object_functions7.asm
index 9d27ad20..2498c167 100755
--- a/engine/hidden_object_functions7.asm
+++ b/engine/hidden_object_functions7.asm
@@ -70,7 +70,7 @@ SafariZoneGameOver:
ld a, SFX_SAFARI_ZONE_PA
call PlayMusic
.waitForMusicToPlay
- ld a, [wChannelSoundIDs + CH4]
+ ld a, [wChannelSoundIDs + Ch5]
cp SFX_SAFARI_ZONE_PA
jr nz, .waitForMusicToPlay
ld a, TEXT_SAFARI_GAME_OVER
@@ -78,12 +78,12 @@ SafariZoneGameOver:
call DisplayTextID
xor a
ld [wPlayerMovingDirection], a
- ld a, SAFARI_ZONE_ENTRANCE
+ ld a, SAFARI_ZONE_GATE
ld [hWarpDestinationMap], a
ld a, $3
ld [wDestinationWarpID], a
ld a, $5
- ld [wSafariZoneEntranceCurScript], a
+ ld [wSafariZoneGateCurScript], a
SetEvent EVENT_SAFARI_GAME_OVER
ld a, 1
ld [wSafariZoneGameOver], a
@@ -247,9 +247,9 @@ CinnabarGymQuiz_1ea92:
ret
CinnabarGymQuizCorrectText:
- db $0b
+ TX_SFX_ITEM_1
TX_FAR _CinnabarGymQuizCorrectText
- db $06
+ TX_BLINK
TX_ASM
ld a, [$ffe0]
@@ -417,7 +417,7 @@ BillsHouseMonitorText:
BillsHouseInitiatedText:
TX_FAR _BillsHouseInitiatedText
- db $06
+ TX_BLINK
TX_ASM
call StopAllMusic
ld c, 16
diff --git a/engine/in_game_trades.asm b/engine/in_game_trades.asm
index 60719c7e..720920df 100755
--- a/engine/in_game_trades.asm
+++ b/engine/in_game_trades.asm
@@ -1,77 +1,77 @@
DoInGameTradeDialogue:
; trigger the trade offer/action specified by wWhichTrade
call SaveScreenTilesToBuffer2
- ld hl,TradeMons
- ld a,[wWhichTrade]
- ld bc,$e
+ ld hl, TradeMons
+ ld a, [wWhichTrade]
+ ld bc, $e
call AddNTimes
- ld a,[hli]
- ld [wInGameTradeGiveMonSpecies],a
- ld a,[hli]
- ld [wInGameTradeReceiveMonSpecies],a
- ld a,[hli]
+ ld a, [hli]
+ ld [wInGameTradeGiveMonSpecies], a
+ ld a, [hli]
+ ld [wInGameTradeReceiveMonSpecies], a
+ ld a, [hli]
push af
- ld de,wInGameTradeMonNick
+ ld de, wInGameTradeMonNick
ld bc, NAME_LENGTH
call CopyData
pop af
- ld l,a
- ld h,0
- ld de,InGameTradeTextPointers
- add hl,hl
- add hl,de
- ld a,[hli]
- ld [wInGameTradeTextPointerTablePointer],a
- ld a,[hl]
- ld [wInGameTradeTextPointerTablePointer + 1],a
- ld a,[wInGameTradeGiveMonSpecies]
- ld de,wInGameTradeGiveMonName
+ ld l, a
+ ld h, 0
+ ld de, InGameTradeTextPointers
+ add hl, hl
+ add hl, de
+ ld a, [hli]
+ ld [wInGameTradeTextPointerTablePointer], a
+ ld a, [hl]
+ ld [wInGameTradeTextPointerTablePointer + 1], a
+ ld a, [wInGameTradeGiveMonSpecies]
+ ld de, wInGameTradeGiveMonName
call InGameTrade_GetMonName
- ld a,[wInGameTradeReceiveMonSpecies]
- ld de,wInGameTradeReceiveMonName
+ ld a, [wInGameTradeReceiveMonSpecies]
+ ld de, wInGameTradeReceiveMonName
call InGameTrade_GetMonName
- ld a,$4
- ld [wInGameTradeTextPointerTableIndex],a
- ld b,FLAG_TEST
+ ld a, $4
+ ld [wInGameTradeTextPointerTableIndex], a
+ ld b, FLAG_TEST
call InGameTrade_FlagActionPredef
- ld a,c
+ ld a, c
and a
- jr nz,.printText
+ jr nz, .printText
; if the trade hasn't been done yet
- ld a,$0
- ld [wInGameTradeTextPointerTableIndex],a
+ ld a, $0
+ ld [wInGameTradeTextPointerTableIndex], a
call .printText
- ld a,$1
- ld [wInGameTradeTextPointerTableIndex],a
+ ld a, $1
+ ld [wInGameTradeTextPointerTableIndex], a
call YesNoChoice
- ld a,[wCurrentMenuItem]
+ ld a, [wCurrentMenuItem]
and a
- jr nz,.printText
+ jr nz, .printText
call InGameTrade_DoTrade
- jr c,.printText
+ jr c, .printText
ld hl, TradedForText
call PrintText
.printText
- ld hl,wInGameTradeTextPointerTableIndex
- ld a,[hld] ; wInGameTradeTextPointerTableIndex
- ld e,a
- ld d,0
- ld a,[hld] ; wInGameTradeTextPointerTablePointer + 1
- ld l,[hl] ; wInGameTradeTextPointerTablePointer
- ld h,a
- add hl,de
- add hl,de
- ld a,[hli]
- ld h,[hl]
- ld l,a
+ ld hl, wInGameTradeTextPointerTableIndex
+ ld a, [hld] ; wInGameTradeTextPointerTableIndex
+ ld e, a
+ ld d, 0
+ ld a, [hld] ; wInGameTradeTextPointerTablePointer + 1
+ ld l, [hl] ; wInGameTradeTextPointerTablePointer
+ ld h, a
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
jp PrintText
; copies name of species a to hl
InGameTrade_GetMonName:
push de
- ld [wd11e],a
+ ld [wd11e], a
call GetMonName
- ld hl,wcd6d
+ ld hl, wcd6d
pop de
ld bc, NAME_LENGTH
jp CopyData
@@ -80,50 +80,50 @@ INCLUDE "data/trades.asm"
InGameTrade_DoTrade:
xor a ; NORMAL_PARTY_MENU
- ld [wPartyMenuTypeOrMessageID],a
+ ld [wPartyMenuTypeOrMessageID], a
dec a
- ld [wUpdateSpritesEnabled],a
+ ld [wUpdateSpritesEnabled], a
call DisplayPartyMenu
push af
call InGameTrade_RestoreScreen
pop af
- ld a,$1
- jp c,.tradeFailed ; jump if the player didn't select a pokemon
- ld a,[wInGameTradeGiveMonSpecies]
- ld b,a
- ld a,[wcf91]
+ ld a, $1
+ jp c, .tradeFailed ; jump if the player didn't select a pokemon
+ ld a, [wInGameTradeGiveMonSpecies]
+ ld b, a
+ ld a, [wcf91]
cp b
- ld a,$2
- jr nz,.tradeFailed ; jump if the selected mon's species is not the required one
- ld a,[wWhichPokemon]
- ld hl,wPartyMon1Level
+ ld a, $2
+ jr nz, .tradeFailed ; jump if the selected mon's species is not the required one
+ ld a, [wWhichPokemon]
+ ld hl, wPartyMon1Level
ld bc, wPartyMon2 - wPartyMon1
call AddNTimes
- ld a,[hl]
- ld [wCurEnemyLVL],a
- ld b,FLAG_SET
+ ld a, [hl]
+ ld [wCurEnemyLVL], a
+ ld b, FLAG_SET
call InGameTrade_FlagActionPredef
ld hl, ConnectCableText
call PrintText
- ld a,[wWhichPokemon]
+ ld a, [wWhichPokemon]
push af
- ld a,[wCurEnemyLVL]
+ ld a, [wCurEnemyLVL]
push af
call LoadHpBarAndStatusTilePatterns
call InGameTrade_PrepareTradeData
predef InternalClockTradeAnim
pop af
- ld [wCurEnemyLVL],a
+ ld [wCurEnemyLVL], a
pop af
- ld [wWhichPokemon],a
- ld a,[wInGameTradeReceiveMonSpecies]
- ld [wcf91],a
+ ld [wWhichPokemon], a
+ ld a, [wInGameTradeReceiveMonSpecies]
+ ld [wcf91], a
xor a
- ld [wMonDataLocation],a ; not used
- ld [wRemoveMonFromBox],a
+ ld [wMonDataLocation], a ; not used
+ ld [wRemoveMonFromBox], a
call RemovePokemon
- ld a,$80 ; prevent the player from naming the mon
- ld [wMonDataLocation],a
+ ld a, $80 ; prevent the player from naming the mon
+ ld [wMonDataLocation], a
call AddPartyMon
call InGameTrade_CopyDataToReceivedMon
call InGameTrade_CheckForTradeEvo
@@ -131,12 +131,12 @@ InGameTrade_DoTrade:
call InGameTrade_RestoreScreen
callba RedrawMapView
and a
- ld a,$3
+ ld a, $3
jr .tradeSucceeded
.tradeFailed
scf
.tradeSucceeded
- ld [wInGameTradeTextPointerTableIndex],a
+ ld [wInGameTradeTextPointerTableIndex], a
ret
InGameTrade_RestoreScreen:
@@ -285,7 +285,9 @@ ConnectCableText:
TradedForText:
TX_FAR _TradedForText
- db $11, $a, "@"
+ TX_SFX_KEY_ITEM
+ TX_DELAY
+ db "@"
WannaTrade1Text:
TX_FAR _WannaTrade1Text
diff --git a/engine/intro.asm b/engine/intro.asm
index 37bd0151..00e892da 100755
--- a/engine/intro.asm
+++ b/engine/intro.asm
@@ -1,6 +1,14 @@
-MOVE_GENGAR_RIGHT EQU $00
-MOVE_GENGAR_LEFT EQU $01
-MOVE_NIDORINO_RIGHT EQU $ff
+const_value = -1
+ const MOVE_NIDORINO_RIGHT
+ const MOVE_GENGAR_RIGHT
+ const MOVE_GENGAR_LEFT
+
+ANIMATION_END EQU 80
+
+const_value = 3
+ const GENGAR_INTRO_TILES1
+ const GENGAR_INTRO_TILES2
+ const GENGAR_INTRO_TILES3
PlayIntro:
xor a
@@ -32,7 +40,7 @@ InitIntroNidorinoOAM:
ld [hli], a ; X
ld a, d
ld [hli], a ; tile
- ld a, $80
+ ld a, OAM_BEHIND_BG
ld [hli], a ; attributes
inc d
dec c
@@ -47,7 +55,7 @@ InitIntroNidorinoOAM:
IntroClearScreen:
ld hl, vBGMap1
- ld bc, $240
+ ld bc, BG_MAP_WIDTH * SCREEN_HEIGHT
jr IntroClearCommon
IntroClearMiddleOfScreen:
@@ -56,7 +64,7 @@ IntroClearMiddleOfScreen:
ld bc, SCREEN_WIDTH * 10
IntroClearCommon:
- ld [hl], $0
+ ld [hl], 0
inc hl
dec bc
ld a, b
@@ -65,7 +73,7 @@ IntroClearCommon:
ret
IntroPlaceBlackTiles:
- ld a, $1
+ ld a, 1
.loop
ld [hli], a
dec c
@@ -80,7 +88,7 @@ PlayShootingStar:
ld b, SET_PAL_GAME_FREAK_INTRO
call RunPaletteCommand
callba LoadCopyrightAndTextBoxTiles
- ld a, %11100100
+ ldPal a, BLACK, DARK_GRAY, LIGHT_GRAY, WHITE
ld [rBGP], a
call UpdateGBCPal_BGP
ld c, 180
@@ -138,10 +146,10 @@ IntroDrawBlackBars:
ld c, SCREEN_WIDTH * 4
call IntroPlaceBlackTiles
ld hl, vBGMap1
- ld c, $80
+ ld c, BG_MAP_WIDTH * 4
call IntroPlaceBlackTiles
- ld hl, vBGMap1 + $1c0
- ld c, $80
+ ld hl, vBGMap1 + BG_MAP_WIDTH * 14
+ ld c, BG_MAP_WIDTH * 4
jp IntroPlaceBlackTiles
EmptyFunc4:
@@ -150,5 +158,7 @@ EmptyFunc4:
GameFreakIntro:
INCBIN "gfx/gamefreak_intro.2bpp"
INCBIN "gfx/gamefreak_logo.2bpp"
- ds $10 ; blank tile
+ rept 16
+ db $00 ; blank tile
+ endr
GameFreakIntroEnd:
diff --git a/engine/items/inventory.asm b/engine/items/inventory.asm
new file mode 100644
index 00000000..58bcf7e9
--- /dev/null
+++ b/engine/items/inventory.asm
@@ -0,0 +1,151 @@
+; function to add an item (in varying quantities) to the player's bag or PC box
+; INPUT:
+; hl = address of inventory (either wNumBagItems or wNumBoxItems)
+; [wcf91] = item ID
+; [wItemQuantity] = item quantity
+; sets carry flag if successful, unsets carry flag if unsuccessful
+AddItemToInventory_:
+ ld a, [wItemQuantity] ; a = item quantity
+ push af
+ push bc
+ push de
+ push hl
+ push hl
+ ld d, PC_ITEM_CAPACITY ; how many items the PC can hold
+ ld a, wNumBagItems & $FF
+ cp l
+ jr nz, .checkIfInventoryFull
+ ld a, wNumBagItems >> 8
+ cp h
+ jr nz, .checkIfInventoryFull
+; if the destination is the bag
+ ld d, BAG_ITEM_CAPACITY ; how many items the bag can hold
+.checkIfInventoryFull
+ ld a, [hl]
+ sub d
+ ld d, a
+ ld a, [hli]
+ and a
+ jr z, .addNewItem
+.notAtEndOfInventory
+ ld a, [hli]
+ ld b, a ; b = ID of current item in table
+ ld a, [wcf91] ; a = ID of item being added
+ cp b ; does the current item in the table match the item being added?
+ jp z, .increaseItemQuantity ; if so, increase the item's quantity
+ inc hl
+.loop
+ ld a, [hl]
+ cp a, $ff ; is it the end of the table?
+ jr nz, .notAtEndOfInventory
+.addNewItem ; add an item not yet in the inventory
+ pop hl
+ ld a, d
+ and a ; is there room for a new item slot?
+ jr z, .done
+; if there is room
+ inc [hl] ; increment the number of items in the inventory
+ ld a, [hl] ; the number of items will be the index of the new item
+ add a
+ dec a
+ ld c, a
+ ld b, 0
+ add hl, bc ; hl = address to store the item
+ ld a, [wcf91]
+ ld [hli], a ; store item ID
+ ld a, [wItemQuantity]
+ ld [hli], a ; store item quantity
+ ld [hl], $ff ; store terminator
+ jp .success
+.increaseItemQuantity ; increase the quantity of an item already in the inventory
+ ld a, [wItemQuantity]
+ ld b, a ; b = quantity to add
+ ld a, [hl] ; a = existing item quantity
+ add b ; a = new item quantity
+ cp 100
+ jp c, .storeNewQuantity ; if the new quantity is less than 100, store it
+; if the new quantity is greater than or equal to 100,
+; try to max out the current slot and add the rest in a new slot
+ sub 99
+ ld [wItemQuantity], a ; a = amount left over (to put in the new slot)
+ ld a, d
+ and a ; is there room for a new item slot?
+ jr z, .increaseItemQuantityFailed
+; if so, store 99 in the current slot and store the rest in a new slot
+ ld a, 99
+ ld [hli], a
+ jp .loop
+.increaseItemQuantityFailed
+ pop hl
+ and a
+ jr .done
+.storeNewQuantity
+ ld [hl], a
+ pop hl
+.success
+ scf
+.done
+ pop hl
+ pop de
+ pop bc
+ pop bc
+ ld a, b
+ ld [wItemQuantity], a ; restore the initial value from when the function was called
+ ret
+
+; function to remove an item (in varying quantities) from the player's bag or PC box
+; INPUT:
+; hl = address of inventory (either wNumBagItems or wNumBoxItems)
+; [wWhichPokemon] = index (within the inventory) of the item to remove
+; [wItemQuantity] = quantity to remove
+RemoveItemFromInventory_:
+ push hl
+ inc hl
+ ld a, [wWhichPokemon] ; index (within the inventory) of the item being removed
+ add a
+ add l
+ ld l, a
+ jr nc, .noCarry
+ inc h
+.noCarry
+ inc hl
+ ld a, [wItemQuantity] ; quantity being removed
+ ld e, a
+ ld a, [hl] ; a = current quantity
+ sub e
+ ld [hld], a ; store new quantity
+ ld [wMaxItemQuantity], a
+ and a
+ jr nz, .skipMovingUpSlots
+; if the remaining quantity is 0,
+; remove the emptied item slot and move up all the following item slots
+.moveSlotsUp
+ ld e, l
+ ld d, h
+ inc de
+ inc de ; de = address of the slot following the emptied one
+.loop ; loop to move up the following slots
+ ld a, [de]
+ inc de
+ ld [hli], a
+ cp $ff
+ jr nz, .loop
+; update menu info
+ xor a
+ ld [wListScrollOffset], a
+ ld [wCurrentMenuItem], a
+ ld [wBagSavedMenuItem], a
+ ld [wSavedListScrollOffset], a
+ pop hl
+ ld a, [hl] ; a = number of items in inventory
+ dec a ; decrement the number of items
+ ld [hl], a ; store new number of items
+ ld [wListCount], a
+ cp 2
+ jr c, .done
+ ld [wMaxMenuItem], a
+ jr .done
+.skipMovingUpSlots
+ pop hl
+.done
+ ret
diff --git a/engine/items/items.asm b/engine/items/items.asm
index 8cce45f0..15c7c24f 100755
--- a/engine/items/items.asm
+++ b/engine/items/items.asm
@@ -1,7 +1,7 @@
UseItem_:
ld a, 1
ld [wActionResultOrTookBattleTurn], a ; initialise to success value
- ld a, [wcf91] ;contains item_ID
+ ld a, [wcf91] ;contains item_ID
cp HM_01
jp nc, ItemUseTMHM
ld hl, ItemUsePtrTable
@@ -103,67 +103,67 @@ ItemUsePtrTable:
ItemUseBall:
; Balls can't be used out of battle.
- ld a,[wIsInBattle]
+ ld a, [wIsInBattle]
and a
- jp z,ItemUseNotTime
+ jp z, ItemUseNotTime
; Balls can't catch trainers' Pokémon.
dec a
- jp nz,ThrowBallAtTrainerMon
+ jp nz, ThrowBallAtTrainerMon
; If this is for the old man battle, skip checking if the party & box are full.
- ld a,[wBattleType]
+ ld a, [wBattleType]
cp BATTLE_TYPE_OLD_MAN
- jr z,.canUseBall
+ jr z, .canUseBall
cp BATTLE_TYPE_PIKACHU
- jr z,.canUseBall
+ jr z, .canUseBall
- ld a,[wPartyCount] ; is party full?
- cp a,PARTY_LENGTH
- jr nz,.canUseBall
- ld a,[wNumInBox] ; is box full?
- cp a,MONS_PER_BOX
- jp z,BoxFullCannotThrowBall
+ ld a, [wPartyCount] ; is party full?
+ cp PARTY_LENGTH
+ jr nz, .canUseBall
+ ld a, [wNumInBox] ; is box full?
+ cp MONS_PER_BOX
+ jp z, BoxFullCannotThrowBall
.canUseBall
xor a
- ld [wCapturedMonSpecies],a
+ ld [wCapturedMonSpecies], a
- ld a,[wBattleType]
- cp a,BATTLE_TYPE_SAFARI
- jr nz,.skipSafariZoneCode
+ ld a, [wBattleType]
+ cp BATTLE_TYPE_SAFARI
+ jr nz, .skipSafariZoneCode
.safariZone
- ld hl,wNumSafariBalls
+ ld hl, wNumSafariBalls
dec [hl] ; remove a Safari Ball
.skipSafariZoneCode
call RunDefaultPaletteCommand
- ld a,$43 ; successful capture value
- ld [wPokeBallAnimData],a
+ ld a, $43 ; successful capture value
+ ld [wPokeBallAnimData], a
call LoadScreenTilesFromBuffer1
- ld hl,ItemUseText00
+ ld hl, ItemUseText00
call PrintText
; If the player is fighting an unidentified ghost, set the value that indicates
; the Pokémon can't be caught and skip the capture calculations.
callab IsGhostBattle
- ld b,$10 ; can't be caught value
- jp z,.setAnimData
+ ld b, $10 ; can't be caught value
+ jp z, .setAnimData
- ld a,[wBattleType]
+ ld a, [wBattleType]
cp BATTLE_TYPE_OLD_MAN
- jr z,.oldManBattle
+ jr z, .oldManBattle
cp BATTLE_TYPE_PIKACHU
- jr z,.oldManBattle ; pikachu battle technically old man battle
+ jr z, .oldManBattle ; pikachu battle technically old man battle
jr .notOldManBattle
.oldManBattle
- ld hl,wGrassRate
- ld de,wPlayerName
- ld bc,NAME_LENGTH
+ ld hl, wGrassRate
+ ld de, wPlayerName
+ ld bc, NAME_LENGTH
call CopyData ; save the player's name in the Wild Monster data (part of the Cinnabar Island Missingno. glitch)
ld a, [wBattleType]
cp BATTLE_TYPE_OLD_MAN
@@ -177,13 +177,13 @@ ItemUseBall:
.notOldManBattle
; If the player is fighting the ghost Marowak, set the value that indicates the
; Pokémon can't be caught and skip the capture calculations.
- ld a,[wCurMap]
- cp a,POKEMONTOWER_6
- jr nz,.loop
- ld a,[wEnemyMonSpecies2]
- cp a,MAROWAK
- ld b,$10 ; can't be caught value
- jp z,.setAnimData
+ ld a, [wCurMap]
+ cp POKEMON_TOWER_6F
+ jr nz, .loop
+ ld a, [wEnemyMonSpecies2]
+ cp MAROWAK
+ ld b, $10 ; can't be caught value
+ jp z, .setAnimData
; Get the first random number. Let it be called Rand1.
; Rand1 must be within a certain range according the kind of ball being thrown.
@@ -195,35 +195,34 @@ ItemUseBall:
.loop
call Random
- ld b,a
+ ld b, a
; Get the item ID.
- ld hl,wcf91
-.asm_d54a
- ld a,[hl]
+ ld hl, wcf91
+ ld a, [hl]
; The Master Ball always succeeds.
- cp a,MASTER_BALL
- jp z,.captured
+ cp MASTER_BALL
+ jp z, .captured
; Anything will do for the basic Poké Ball.
- cp a,POKE_BALL
- jr z,.checkForAilments
+ cp POKE_BALL
+ jr z, .checkForAilments
; If it's a Great/Ultra/Safari Ball and Rand1 is greater than 200, try again.
- ld a,200
+ ld a, 200
cp b
- jr c,.loop
+ jr c, .loop
; Less than or equal to 200 is good enough for a Great Ball.
- ld a,[hl]
- cp a,GREAT_BALL
- jr z,.checkForAilments
+ ld a, [hl]
+ cp GREAT_BALL
+ jr z, .checkForAilments
; If it's an Ultra/Safari Ball and Rand1 is greater than 150, try again.
- ld a,150
+ ld a, 150
cp b
- jr c,.loop
+ jr c, .loop
.checkForAilments
; Pokémon can be caught more easily with a status ailment.
@@ -234,176 +233,176 @@ ItemUseBall:
; Burn/Paralysis/Poison: Status = 12
; Freeze/Sleep: Status = 25
; If Status is greater than Rand1, the Pokémon will be caught for sure.
- ld a,[wEnemyMonStatus]
+ ld a, [wEnemyMonStatus]
and a
- jr z,.skipAilmentValueSubtraction ; no ailments
- and a, 1 << FRZ | SLP
- ld c,12
- jr z,.notFrozenOrAsleep
- ld c,25
+ jr z, .skipAilmentValueSubtraction ; no ailments
+ and 1 << FRZ | SLP
+ ld c, 12
+ jr z, .notFrozenOrAsleep
+ ld c, 25
.notFrozenOrAsleep
ld a, b
sub c
- jp c,.captured
- ld b,a
+ jp c, .captured
+ ld b, a
.skipAilmentValueSubtraction
- push bc ; save (Rand1 - Status)
+ push bc ; save (Rand1 - Status)
; Calculate MaxHP * 255.
xor a
- ld [H_MULTIPLICAND],a
- ld hl,wEnemyMonMaxHP
- ld a,[hli]
- ld [H_MULTIPLICAND + 1],a
- ld a,[hl]
- ld [H_MULTIPLICAND + 2],a
- ld a,255
- ld [H_MULTIPLIER],a
+ ld [H_MULTIPLICAND], a
+ ld hl, wEnemyMonMaxHP
+ ld a, [hli]
+ ld [H_MULTIPLICAND + 1], a
+ ld a, [hl]
+ ld [H_MULTIPLICAND + 2], a
+ ld a, 255
+ ld [H_MULTIPLIER], a
call Multiply
; Determine BallFactor. It's 8 for Great Balls and 12 for the others.
- ld a,[wcf91]
+ ld a, [wcf91]
cp GREAT_BALL
- ld a,12
- jr nz,.skip1
- ld a,8
+ ld a, 12
+ jr nz, .skip1
+ ld a, 8
.skip1
; Note that the results of all division operations are floored.
; Calculate (MaxHP * 255) / BallFactor.
- ld [H_DIVISOR],a
- ld b,4 ; number of bytes in dividend
+ ld [H_DIVISOR], a
+ ld b, 4 ; number of bytes in dividend
call Divide
; Divide the enemy's current HP by 4. HP is not supposed to exceed 999 so
; the result should fit in a. If the division results in a quotient of 0,
; change it to 1.
- ld hl,wEnemyMonHP
- ld a,[hli]
- ld b,a
- ld a,[hl]
+ ld hl, wEnemyMonHP
+ ld a, [hli]
+ ld b, a
+ ld a, [hl]
srl b
rr a
srl b
rr a
and a
- jr nz,.skip2
+ jr nz, .skip2
inc a
.skip2
; Let W = ((MaxHP * 255) / BallFactor) / max(HP / 4, 1). Calculate W.
- ld [H_DIVISOR],a
- ld b,4
+ ld [H_DIVISOR], a
+ ld b, 4
call Divide
; If W > 255, store 255 in [H_QUOTIENT + 3].
; Let X = min(W, 255) = [H_QUOTIENT + 3].
- ld a,[H_QUOTIENT + 2]
+ ld a, [H_QUOTIENT + 2]
and a
- jr z,.skip3
- ld a,255
- ld [H_QUOTIENT + 3],a
+ jr z, .skip3
+ ld a, 255
+ ld [H_QUOTIENT + 3], a
.skip3
pop bc ; b = Rand1 - Status
; If Rand1 - Status > CatchRate, the ball fails to capture the Pokémon.
- ld a,[wEnemyMonCatchRate]
+ ld a, [wEnemyMonActualCatchRate]
cp b
- jr c,.failedToCapture
+ jr c, .failedToCapture
; If W > 255, the ball captures the Pokémon.
- ld a,[H_QUOTIENT + 2]
+ ld a, [H_QUOTIENT + 2]
and a
- jr nz,.captured
+ jr nz, .captured
call Random ; Let this random number be called Rand2.
; If Rand2 > X, the ball fails to capture the Pokémon.
- ld b,a
- ld a,[H_QUOTIENT + 3]
+ ld b, a
+ ld a, [H_QUOTIENT + 3]
cp b
- jr c,.failedToCapture
+ jr c, .failedToCapture
.captured
jr .skipShakeCalculations
.failedToCapture
- ld a,[H_QUOTIENT + 3]
- ld [wPokeBallCaptureCalcTemp],a ; Save X.
+ ld a, [H_QUOTIENT + 3]
+ ld [wPokeBallCaptureCalcTemp], a ; Save X.
; Calculate CatchRate * 100.
xor a
- ld [H_MULTIPLICAND],a
- ld [H_MULTIPLICAND + 1],a
- ld a,[wEnemyMonCatchRate]
- ld [H_MULTIPLICAND + 2],a
- ld a,100
- ld [H_MULTIPLIER],a
+ ld [H_MULTIPLICAND], a
+ ld [H_MULTIPLICAND + 1], a
+ ld a, [wEnemyMonActualCatchRate]
+ ld [H_MULTIPLICAND + 2], a
+ ld a, 100
+ ld [H_MULTIPLIER], a
call Multiply
; Determine BallFactor2.
; Poké Ball: BallFactor2 = 255
; Great Ball: BallFactor2 = 200
; Ultra/Safari Ball: BallFactor2 = 150
- ld a,[wcf91]
- ld b,255
+ ld a, [wcf91]
+ ld b, 255
cp POKE_BALL
- jr z,.skip4
- ld b,200
+ jr z, .skip4
+ ld b, 200
cp GREAT_BALL
- jr z,.skip4
- ld b,150
+ jr z, .skip4
+ ld b, 150
cp ULTRA_BALL
- jr z,.skip4
+ jr z, .skip4
.skip4
; Let Y = (CatchRate * 100) / BallFactor2. Calculate Y.
- ld a,b
- ld [H_DIVISOR],a
- ld b,4
+ ld a, b
+ ld [H_DIVISOR], a
+ ld b, 4
call Divide
; If Y > 255, there are 3 shakes.
; Note that this shouldn't be possible.
; The maximum value of Y is (255 * 100) / 150 = 170.
- ld a,[H_QUOTIENT + 2]
+ ld a, [H_QUOTIENT + 2]
and a
- ld b,$63 ; 3 shakes
- jr nz,.setAnimData
+ ld b, $63 ; 3 shakes
+ jr nz, .setAnimData
; Calculate X * Y.
- ld a,[wPokeBallCaptureCalcTemp]
- ld [H_MULTIPLIER],a
+ ld a, [wPokeBallCaptureCalcTemp]
+ ld [H_MULTIPLIER], a
call Multiply
; Calculate (X * Y) / 255.
- ld a,255
- ld [H_DIVISOR],a
- ld b,4
+ ld a, 255
+ ld [H_DIVISOR], a
+ ld b, 4
call Divide
; Determine Status2.
; no status ailment: Status2 = 0
; Burn/Paralysis/Poison: Status2 = 5
; Freeze/Sleep: Status2 = 10
- ld a,[wEnemyMonStatus]
+ ld a, [wEnemyMonStatus]
and a
- jr z,.skip5
+ jr z, .skip5
and 1 << FRZ | SLP
- ld b,5
- jr z,.addAilmentValue
- ld b,10
+ ld b, 5
+ jr z, .addAilmentValue
+ ld b, 10
.addAilmentValue
; If the Pokémon has a status ailment, add Status2.
- ld a,[H_QUOTIENT + 3]
+ ld a, [H_QUOTIENT + 3]
add b
- ld [H_QUOTIENT + 3],a
+ ld [H_QUOTIENT + 3], a
.skip5
; Finally determine the number of shakes.
@@ -413,29 +412,29 @@ ItemUseBall:
; 10 ≤ Z < 30: 1 shake
; 30 ≤ Z < 70: 2 shakes
; 70 ≤ Z: 3 shakes
- ld a,[H_QUOTIENT + 3]
- cp a,10
- ld b,$20
- jr c,.setAnimData
- cp a,30
- ld b,$61
- jr c,.setAnimData
- cp a,70
- ld b,$62
- jr c,.setAnimData
- ld b,$63
+ ld a, [H_QUOTIENT + 3]
+ cp 10
+ ld b, $20
+ jr c, .setAnimData
+ cp 30
+ ld b, $61
+ jr c, .setAnimData
+ cp 70
+ ld b, $62
+ jr c, .setAnimData
+ ld b, $63
.setAnimData
- ld a,b
- ld [wPokeBallAnimData],a
+ ld a, b
+ ld [wPokeBallAnimData], a
.skipShakeCalculations
- ld c,20
+ ld c, 20
call DelayFrames
; Do the animation.
- ld a,TOSS_ANIM
- ld [wAnimationID],a
+ ld a, TOSS_ANIM
+ ld [wAnimationID], a
xor a
ld [H_WHOSETURN], a
ld [wAnimationType], a
@@ -448,36 +447,36 @@ ItemUseBall:
pop af
ld [wcf91], a
pop af
- ld [wWhichPokemon],a
+ ld [wWhichPokemon], a
; Determine the message to display from the animation.
- ld a,[wPokeBallAnimData]
- cp a,$10
- ld hl,ItemUseBallText00
- jp z,.printMessage
- cp a,$20
- ld hl,ItemUseBallText01
- jp z,.printMessage
- cp a,$61
- ld hl,ItemUseBallText02
- jp z,.printMessage
- cp a,$62
- ld hl,ItemUseBallText03
- jp z,.printMessage
- cp a,$63
- ld hl,ItemUseBallText04
- jp z,.printMessage
+ ld a, [wPokeBallAnimData]
+ cp $10
+ ld hl, ItemUseBallText00
+ jp z, .printMessage
+ cp $20
+ ld hl, ItemUseBallText01
+ jp z, .printMessage
+ cp $61
+ ld hl, ItemUseBallText02
+ jp z, .printMessage
+ cp $62
+ ld hl, ItemUseBallText03
+ jp z, .printMessage
+ cp $63
+ ld hl, ItemUseBallText04
+ jp z, .printMessage
; Save current HP.
- ld hl,wEnemyMonHP
- ld a,[hli]
+ ld hl, wEnemyMonHP
+ ld a, [hli]
push af
- ld a,[hli]
+ ld a, [hli]
push af
; Save status ailment.
inc hl
- ld a,[hl]
+ ld a, [hl]
push af
push hl
@@ -485,26 +484,26 @@ ItemUseBall:
; If the Pokémon is transformed, the Pokémon is assumed to be a Ditto.
; This is a bug because a wild Pokémon could have used Transform via
; Mirror Move even though the only wild Pokémon that knows Transform is Ditto.
- ld hl,wEnemyBattleStatus3
- bit Transformed,[hl]
- jr z,.notTransformed
- ld a,DITTO
- ld [wEnemyMonSpecies2],a
+ ld hl, wEnemyBattleStatus3
+ bit TRANSFORMED, [hl]
+ jr z, .notTransformed
+ ld a, DITTO
+ ld [wEnemyMonSpecies2], a
jr .skip6
.notTransformed
; If the Pokémon is not transformed, set the transformed bit and copy the
; DVs to wTransformedEnemyMonOriginalDVs so that LoadEnemyMonData won't generate
; new DVs.
- set Transformed,[hl]
- ld hl,wTransformedEnemyMonOriginalDVs
- ld a,[wEnemyMonDVs]
- ld [hli],a
- ld a,[wEnemyMonDVs + 1]
- ld [hl],a
+ set TRANSFORMED, [hl]
+ ld hl, wTransformedEnemyMonOriginalDVs
+ ld a, [wEnemyMonDVs]
+ ld [hli], a
+ ld a, [wEnemyMonDVs + 1]
+ ld [hl], a
.skip6
- ld a,[wcf91]
+ ld a, [wcf91]
push af
ld a, [wEnemyMonSpecies2]
ld [wcf91], a
@@ -520,17 +519,17 @@ ItemUseBall:
pop af
ld [hld], a
pop af
- ld [hl],a
- ld a,[wEnemyMonSpecies]
- ld [wCapturedMonSpecies],a
- ld [wcf91],a
- ld [wd11e],a
- ld a,[wBattleType]
+ ld [hl], a
+ ld a, [wEnemyMonSpecies]
+ ld [wCapturedMonSpecies], a
+ ld [wcf91], a
+ ld [wd11e], a
+ ld a, [wBattleType]
cp BATTLE_TYPE_OLD_MAN ; is this the old man battle?
- jp z,.oldManCaughtMon ; if so, don't give the player the caught Pokémon
+ jp z, .oldManCaughtMon ; if so, don't give the player the caught Pokémon
cp BATTLE_TYPE_PIKACHU
- jr z,.oldManCaughtMon ; same with Pikachu battle
- ld hl,ItemUseBallText05
+ jr z, .oldManCaughtMon ; same with Pikachu battle
+ ld hl, ItemUseBallText05
call PrintText
; Add the caught Pokémon to the Pokédex.
@@ -551,13 +550,13 @@ ItemUseBall:
pop af
and a ; was the Pokémon already in the Pokédex?
- jr nz,.skipShowingPokedexData ; if so, don't show the Pokédex data
+ jr nz, .skipShowingPokedexData ; if so, don't show the Pokédex data
- ld hl,ItemUseBallText06
+ ld hl, ItemUseBallText06
call PrintText
call ClearSprites
- ld a,[wEnemyMonSpecies]
- ld [wd11e],a
+ ld a, [wEnemyMonSpecies]
+ ld [wd11e], a
predef ShowPokedexData
.skipShowingPokedexData
@@ -565,9 +564,9 @@ ItemUseBall:
ld [wd49c], a
ld a, $85
ld [wPikachuMood], a
- ld a,[wPartyCount]
+ ld a, [wPartyCount]
cp PARTY_LENGTH ; is party full?
- jr z,.sendToBox
+ jr z, .sendToBox
xor a ; PLAYER_PARTY_DATA
ld [wMonDataLocation], a
call ClearSprites
@@ -579,28 +578,28 @@ ItemUseBall:
.sendToBox
call ClearSprites
call SendNewMonToBox
- ld hl,ItemUseBallText07
+ ld hl, ItemUseBallText07
CheckEvent EVENT_MET_BILL
- jr nz,.printTransferredToPCText
- ld hl,ItemUseBallText08
+ jr nz, .printTransferredToPCText
+ ld hl, ItemUseBallText08
.printTransferredToPCText
call PrintText
jr .done
.oldManCaughtMon
- ld hl,ItemUseBallText05
+ ld hl, ItemUseBallText05
.printMessage
call PrintText
call ClearSprites
.done
- ld a,[wBattleType]
+ ld a, [wBattleType]
and a ; is this the old man battle?
ret nz ; if so, don't remove a ball from the bag
; Remove a ball from the bag.
- ld hl,wNumBagItems
+ ld hl, wNumBagItems
inc a
ld [wItemQuantity], a
jp RemoveItemFromInventory
@@ -633,7 +632,8 @@ ItemUseBallText05:
;"All right! {MonName} was caught!"
;play sound
TX_FAR _ItemUseBallText05
- db $12, $06
+ TX_SFX_CAUGHT_MON
+ TX_BLINK
db "@"
ItemUseBallText07:
;"X was transferred to Bill's PC"
@@ -648,7 +648,8 @@ ItemUseBallText06:
;"New DEX data will be added..."
;play sound
TX_FAR _ItemUseBallText06
- db $13, $06
+ TX_SFX_DEX_PAGE_ADDED
+ TX_BLINK
db "@"
ItemUseTownMap:
@@ -916,7 +917,6 @@ ItemUseMedicine:
; if using softboiled
call GoBackToPartyMenu
jr .getPartyMonDataAddress
-
.notUsingSoftboiled
call DisplayPartyMenu
.getPartyMonDataAddress
@@ -962,11 +962,11 @@ ItemUseMedicine:
jp nc, .useVitamin ; if it's a vitamin or Rare Candy
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
+; fall through if it's one of the status-specific healing items
.cureStatusAilment
- ld bc,wPartyMon1Status - wPartyMon1
- add hl,bc ; hl now points to status
- ld a,[wcf91]
+ ld bc, wPartyMon1Status - wPartyMon1
+ add hl, bc ; hl now points to status
+ ld a, [wcf91]
lb bc, ANTIDOTE_MSG, 1 << PSN
cp ANTIDOTE
jr z, .checkMonStatus
@@ -1000,12 +1000,12 @@ ItemUseMedicine:
ld [wBattleMonStatus], a ; remove the status ailment in the in-battle pokemon data
push hl
ld hl, wPlayerBattleStatus3
- res BadlyPoisoned, [hl] ; heal Toxic status
+ res BADLY_POISONED, [hl] ; heal Toxic status
pop hl
- ld bc,wPartyMon1Stats - wPartyMon1Status
- add hl,bc ; hl now points to party stats
- ld de,wBattleMonStats
- ld bc,NUM_STATS * 2
+ ld bc, wPartyMon1Stats - wPartyMon1Status
+ add hl, bc ; hl now points to party stats
+ ld de, wBattleMonStats
+ ld bc, NUM_STATS * 2
call CopyData ; copy party stats to in-battle stat data
predef DoubleOrHalveSelectedStats
jp .doneHealing
@@ -1077,8 +1077,8 @@ ItemUseMedicine:
.compareCurrentHPToMaxHP
push hl
push bc
- ld bc,wPartyMon1MaxHP - (wPartyMon1HP + 1)
- add hl,bc ; hl now points to max HP
+ ld bc, wPartyMon1MaxHP - (wPartyMon1HP + 1)
+ add hl, bc ; hl now points to max HP
pop bc
ld a, [hli]
cp b
@@ -1107,16 +1107,16 @@ ItemUseMedicine:
.notFullHP ; if the pokemon's current HP doesn't equal its max HP
xor a
ld [wLowHealthAlarm], a ;disable low health alarm
- ld [wChannelSoundIDs + CH4], a
+ ld [wChannelSoundIDs + Ch5], a
push hl
push de
- ld bc,wPartyMon1MaxHP - (wPartyMon1HP + 1)
- add hl,bc ; hl now points to max HP
- ld a,[hli]
- ld [wHPBarMaxHP+1],a
- ld a,[hl]
- ld [wHPBarMaxHP],a ; max HP stored at wHPBarMaxHP (2 bytes, big-endian)
- ld a,[wPseudoItemID]
+ ld bc, wPartyMon1MaxHP - (wPartyMon1HP + 1)
+ add hl, bc ; hl now points to max HP
+ ld a, [hli]
+ ld [wHPBarMaxHP+1], a
+ ld a, [hl]
+ ld [wHPBarMaxHP], a ; max HP stored at wHPBarMaxHP (2 bytes, big-endian)
+ ld a, [wPseudoItemID]
and a ; using Softboiled?
jp z, .notUsingSoftboiled2
; if using softboiled
@@ -1143,8 +1143,8 @@ ItemUseMedicine:
ld [H_DIVISOR], a
ld b, 2 ; number of bytes
call Divide ; get 1/5 of max HP of pokemon that used Softboiled
- ld bc,(wPartyMon1HP + 1) - (wPartyMon1MaxHP + 1)
- add hl,bc ; hl now points to LSB of current HP of pokemon that used Softboiled
+ ld bc, (wPartyMon1HP + 1) - (wPartyMon1MaxHP + 1)
+ add hl, bc ; hl now points to LSB of current HP of pokemon that used Softboiled
; subtract 1/5 of max HP from current HP of pokemon that used Softboiled
ld a, [H_QUOTIENT + 3]
push af
@@ -1221,16 +1221,16 @@ ItemUseMedicine:
.noCarry
push de
inc hl
- ld d,h
- ld e,l ; de now points to current HP
- ld hl,(wPartyMon1MaxHP + 1) - (wPartyMon1HP + 1)
- add hl,de ; hl now points to max HP
- ld a,[wcf91]
- cp a,REVIVE
- jr z,.setCurrentHPToHalfMaxHP
- ld a,[hld]
- ld b,a
- ld a,[de]
+ ld d, h
+ ld e, l ; de now points to current HP
+ ld hl, (wPartyMon1MaxHP + 1) - (wPartyMon1HP + 1)
+ add hl, de ; hl now points to max HP
+ ld a, [wcf91]
+ cp REVIVE
+ jr z, .setCurrentHPToHalfMaxHP
+ ld a, [hld]
+ ld b, a
+ ld a, [de]
sub b
dec de
ld b, [hl]
@@ -1269,11 +1269,11 @@ ItemUseMedicine:
ld [wHPBarNewHP], a
dec de
.doneHealingPartyHP ; done updating the pokemon's current HP in the party data structure
- ld a,[wcf91]
- cp a,FULL_RESTORE
- jr nz,.updateInBattleData
- ld bc,wPartyMon1Status - (wPartyMon1MaxHP + 1)
- add hl,bc
+ ld a, [wcf91]
+ cp FULL_RESTORE
+ jr nz, .updateInBattleData
+ ld bc, wPartyMon1Status - (wPartyMon1MaxHP + 1)
+ add hl, bc
xor a
ld [hl], a ; remove the status ailment in the party data
.updateInBattleData
@@ -1294,8 +1294,8 @@ ItemUseMedicine:
xor a
ld [wBattleMonStatus], a ; remove the status ailment in the in-battle pokemon data
.calculateHPBarCoords
- ld hl,wOAMBuffer + $90
- ld bc,2 * SCREEN_WIDTH
+ ld hl, wOAMBuffer + $90
+ ld bc, 2 * SCREEN_WIDTH
inc d
.calculateHPBarCoordsLoop
add hl, bc
@@ -1377,13 +1377,13 @@ ItemUseMedicine:
.useVitamin
push hl
- ld a,[hl]
- ld [wd0b5],a
- ld [wd11e],a
- ld bc,wPartyMon1Level - wPartyMon1
- add hl,bc ; hl now points to level
- ld a,[hl] ; a = level
- ld [wCurEnemyLVL],a ; store level
+ ld a, [hl]
+ ld [wd0b5], a
+ ld [wd11e], a
+ ld bc, wPartyMon1Level - wPartyMon1
+ add hl, bc ; hl now points to level
+ ld a, [hl] ; a = level
+ ld [wCurEnemyLVL], a ; store level
call GetMonHeader
push de
ld a, d
@@ -1397,8 +1397,8 @@ ItemUseMedicine:
push hl
sub HP_UP
add a
- ld bc,wPartyMon1HPExp - wPartyMon1
- add hl,bc
+ ld bc, wPartyMon1HPExp - wPartyMon1
+ add hl, bc
add l
ld l, a
jr nc, .noCarry2
@@ -1448,21 +1448,21 @@ ItemUseMedicine:
jp GBPalWhiteOut
.recalculateStats
- ld bc,wPartyMon1Stats - wPartyMon1
- add hl,bc
- ld d,h
- ld e,l ; de now points to stats
- ld bc,(wPartyMon1Exp + 2) - wPartyMon1Stats
- add hl,bc ; hl now points to LSB of experience
- ld b,1
+ ld bc, wPartyMon1Stats - wPartyMon1
+ add hl, bc
+ ld d, h
+ ld e, l ; de now points to stats
+ ld bc, (wPartyMon1Exp + 2) - wPartyMon1Stats
+ add hl, bc ; hl now points to LSB of experience
+ ld b, 1
jp CalcStats ; recalculate stats
.useRareCandy
push hl
- ld bc,wPartyMon1Level - wPartyMon1
- add hl,bc ; hl now points to level
- ld a,[hl] ; a = level
- cp a, MAX_LEVEL
- jr z,.vitaminNoEffect ; can't raise level above 100
+ ld bc, wPartyMon1Level - wPartyMon1
+ add hl, bc ; hl now points to level
+ ld a, [hl] ; a = level
+ cp MAX_LEVEL
+ jr z, .vitaminNoEffect ; can't raise level above 100
inc a
ld [hl], a ; store incremented level
ld [wCurEnemyLVL], a
@@ -1472,8 +1472,8 @@ ItemUseMedicine:
callab CalcExperience ; calculate experience for next level and store it at $ff96
pop de
pop hl
- ld bc,wPartyMon1Exp - wPartyMon1Level
- add hl,bc ; hl now points to MSB of experience
+ ld bc, wPartyMon1Exp - wPartyMon1Level
+ add hl, bc ; hl now points to MSB of experience
; update experience to minimum for new level
ld a, [hExperience]
ld [hli], a
@@ -1488,18 +1488,18 @@ ItemUseMedicine:
push af
push de
push hl
- ld bc,wPartyMon1MaxHP - wPartyMon1
- add hl,bc ; hl now points to MSB of max HP
- ld a,[hli]
- ld b,a
- ld c,[hl]
+ ld bc, wPartyMon1MaxHP - wPartyMon1
+ add hl, bc ; hl now points to MSB of max HP
+ ld a, [hli]
+ ld b, a
+ ld c, [hl]
pop hl
push bc
push hl
call .recalculateStats
pop hl
- ld bc,(wPartyMon1MaxHP + 1) - wPartyMon1
- add hl,bc ; hl now points to LSB of max HP
+ ld bc, (wPartyMon1MaxHP + 1) - wPartyMon1
+ add hl, bc ; hl now points to LSB of max HP
pop bc
ld a, [hld]
sub c
@@ -1508,9 +1508,9 @@ ItemUseMedicine:
sbc b
ld b, a ; bc = the amount of max HP gained from leveling up
; add the amount gained to the current HP
- ld de,(wPartyMon1HP + 1) - wPartyMon1MaxHP
- add hl,de ; hl now points to LSB of current HP
- ld a,[hl]
+ ld de, (wPartyMon1HP + 1) - wPartyMon1MaxHP
+ add hl, de ; hl now points to LSB of current HP
+ ld a, [hl]
add c
ld [hld], a
ld a, [hl]
@@ -1572,7 +1572,7 @@ VitaminText:
ItemUseBait:
ld hl, ThrewBaitText
call PrintText
- ld hl, wEnemyMonCatchRate ; catch rate
+ ld hl, wEnemyMonActualCatchRate ; catch rate
srl [hl] ; halve catch rate
ld a, BAIT_ANIM
ld hl, wSafariBaitFactor ; bait factor
@@ -1582,7 +1582,7 @@ ItemUseBait:
ItemUseRock:
ld hl, ThrewRockText
call PrintText
- ld hl, wEnemyMonCatchRate ; catch rate
+ ld hl, wEnemyMonActualCatchRate ; catch rate
ld a, [hl]
add a ; double catch rate
jr nc, .noCarry
@@ -1654,7 +1654,7 @@ ItemUseEscapeRope:
ResetEvent EVENT_IN_SAFARI_ZONE
xor a
ld [wNumSafariBalls], a
- ld [wSafariZoneEntranceCurScript], a
+ ld [wSafariZoneGateCurScript], a
inc a
ld [wEscapedFromBattle], a
ld [wActionResultOrTookBattleTurn], a ; item used
@@ -1690,7 +1690,7 @@ ItemUseXAccuracy:
and a
jp z, ItemUseNotTime
ld hl, wPlayerBattleStatus2
- set UsingXAccuracy, [hl] ; X Accuracy bit
+ set USING_X_ACCURACY, [hl] ; X Accuracy bit
callabd_ModifyPikachuHappiness PIKAHAPPY_USEDXITEM
jp PrintItemUseTextAndRemoveItem
@@ -1700,10 +1700,10 @@ ItemUseCardKey:
xor a
ld [wUnusedD71F], a
call GetTileAndCoordsInFrontOfPlayer
- ld a,[GetTileAndCoordsInFrontOfPlayer]
- cp a,$18
- jr nz,.next0
- ld hl,CardKeyTable1
+ ld a, [GetTileAndCoordsInFrontOfPlayer]
+ cp $18
+ jr nz, .next0
+ ld hl, CardKeyTable1
jr .next1
.next0
@@ -1813,7 +1813,7 @@ ItemUseGuardSpec:
ld [wWhichPokemon], a
ld hl, wPlayerBattleStatus2
- set ProtectedByMist, [hl] ; Mist bit
+ set PROTECTED_BY_MIST, [hl] ; Mist bit
jp PrintItemUseTextAndRemoveItem
ItemUseSuperRepel:
@@ -1838,7 +1838,7 @@ ItemUseDireHit:
ld [wWhichPokemon], a
ld hl, wPlayerBattleStatus2
- set GettingPumped, [hl] ; Focus Energy bit
+ set GETTING_PUMPED, [hl] ; Focus Energy bit
jp PrintItemUseTextAndRemoveItem
ItemUseXStat:
@@ -1939,7 +1939,7 @@ ItemUsePokeflute:
.inBattle
xor a
ld [wWereAnyMonsAsleep], a
- ld b, $ff ^ SLP
+ ld b, ~SLP & $ff
ld hl, wPartyMon1Status
call WakeUpEntireParty
ld a, [wIsInBattle]
@@ -1978,7 +1978,7 @@ ItemUsePokeflute:
call WaitForSoundToFinish ; wait for sound to end
callba Music_PokeFluteInBattle ; play in-battle pokeflute music
.musicWaitLoop ; wait for music to finish playing
- ld a, [wChannelSoundIDs + CH6]
+ ld a, [wChannelSoundIDs + Ch7]
and a ; music off?
jr nz, .musicWaitLoop
.skipMusic
@@ -2039,7 +2039,7 @@ FluteWokeUpText:
PlayedFluteHadEffectText:
TX_FAR _PlayedFluteHadEffectText
- db $06
+ TX_BLINK
TX_ASM
ld a, [wIsInBattle]
and a
@@ -2050,7 +2050,7 @@ PlayedFluteHadEffectText:
ld c, BANK(SFX_Pokeflute)
call PlayMusic
.musicWaitLoop ; wait for music to finish playing
- ld a, [wChannelSoundIDs + CH2]
+ ld a, [wChannelSoundIDs + Ch3]
cp SFX_POKEFLUTE
jr z, .musicWaitLoop
call PlayDefaultMusic ; start playing normal music again
@@ -2241,7 +2241,7 @@ ItemUsePPRestore:
cp b
jr nz, .usePPItem
ld a, [wPlayerBattleStatus3]
- bit Transformed, a
+ bit TRANSFORMED, a
jr z, .usePPItem
call ItemUseNotTime
jp .itemNotUsed
@@ -2278,12 +2278,12 @@ ItemUsePPRestore:
cp ETHER
jr nc, .useEther ; if Ether or Max Ether
.usePPUp
- ld bc,wPartyMon1PP - wPartyMon1Moves
- add hl,bc
- ld a,[hl] ; move PP
- cp a,3 << 6 ; have 3 PP Ups already been used?
- jr c,.PPNotMaxedOut
- ld hl,PPMaxedOutText
+ ld bc, wPartyMon1PP - wPartyMon1Moves
+ add hl, bc
+ ld a, [hl] ; move PP
+ cp 3 << 6 ; have 3 PP Ups already been used?
+ jr c, .PPNotMaxedOut
+ ld hl, PPMaxedOutText
call PrintText
jr .chooseMove
@@ -2678,19 +2678,19 @@ DontHavePokemonText:
ItemUseText00:
TX_FAR _ItemUseText001
- db $05
+ TX_LINE
TX_FAR _ItemUseText002
db "@"
GotOnBicycleText:
TX_FAR _GotOnBicycleText1
- db $05
+ TX_LINE
TX_FAR _GotOnBicycleText2
db "@"
GotOffBicycleText:
TX_FAR _GotOffBicycleText1
- db $05
+ TX_LINE
TX_FAR _GotOffBicycleText2
db "@"
@@ -2756,7 +2756,7 @@ AddBonusPP:
ld a, [hl] ; move PP
ld b, a
swap a
- and %1111
+ and %00001111
srl a
srl a
ld c, a ; c = number of PP Ups used
diff --git a/engine/learn_move.asm b/engine/learn_move.asm
index dcaf4235..021d0eeb 100755
--- a/engine/learn_move.asm
+++ b/engine/learn_move.asm
@@ -184,7 +184,9 @@ TryingToLearn:
LearnedMove1Text:
TX_FAR _LearnedMove1Text
- db $b,6,"@"
+ TX_SFX_ITEM_1 ; plays SFX_GET_ITEM_1 in the party menu (rare candy) and plays SFX_LEVEL_UP in battle
+ TX_BLINK
+ db "@"
WhichMoveToForgetText:
TX_FAR _WhichMoveToForgetText
@@ -206,7 +208,7 @@ OneTwoAndText:
; bugfix: In Red/Blue, the SFX_SWAP sound was played in the wrong bank, which played an incorrect sound
; Yellow has fixed this by swapping to the correct bank
TX_FAR _OneTwoAndText
- db $a
+ TX_DELAY
TX_ASM
push af
push bc
@@ -238,7 +240,7 @@ OneTwoAndText:
PoofText:
TX_FAR _PoofText
- db $a
+ TX_DELAY
ForgotAndText:
TX_FAR _ForgotAndText
db "@"
diff --git a/engine/load_pokedex_tiles.asm b/engine/load_pokedex_tiles.asm
index 637b7a24..70bcf04d 100755
--- a/engine/load_pokedex_tiles.asm
+++ b/engine/load_pokedex_tiles.asm
@@ -1,11 +1,11 @@
; Loads tile patterns for tiles used in the pokedex.
LoadPokedexTilePatterns:
call LoadHpBarAndStatusTilePatterns
- ld de,PokedexTileGraphics
- ld hl,vChars2 + $600
+ ld de, PokedexTileGraphics
+ ld hl, vChars2 + $600
lb bc, BANK(PokedexTileGraphics), (PokedexTileGraphicsEnd - PokedexTileGraphics) / $10
call CopyVideoData
- ld de,PokeballTileGraphics
- ld hl,vChars2 + $720
+ ld de, PokeballTileGraphics
+ ld hl, vChars2 + $720
lb bc, BANK(PokeballTileGraphics), $01
jp CopyVideoData ; load pokeball tile for marking caught mons
diff --git a/engine/menu/bills_pc.asm b/engine/menu/bills_pc.asm
index 2f7dcaa9..41626310 100644
--- a/engine/menu/bills_pc.asm
+++ b/engine/menu/bills_pc.asm
@@ -103,7 +103,7 @@ BillsPC_::
bit 3, a ; accessing Bill's PC through another PC?
jr nz, BillsPCMenu
; accessing it directly
- ld a, $99
+ ld a, SFX_TURN_ON_PC
call PlaySound
ld hl, SwitchOnText
call PrintText
@@ -190,7 +190,7 @@ ExitBillsPC:
jr nz, .next
; accessing it directly
call LoadTextBoxTilePatterns
- ld a, $9a
+ ld a, SFX_TURN_OFF_PC
call PlaySound
call WaitForSoundToFinish
.next
diff --git a/engine/menu/diploma_1.asm b/engine/menu/diploma.asm
index 3f309bd2..3f309bd2 100644
--- a/engine/menu/diploma_1.asm
+++ b/engine/menu/diploma.asm
diff --git a/engine/draw_badges.asm b/engine/menu/draw_badges.asm
index 9e6262a0..9e6262a0 100644
--- a/engine/draw_badges.asm
+++ b/engine/menu/draw_badges.asm
diff --git a/engine/menu/draw_start_menu.asm b/engine/menu/draw_start_menu.asm
new file mode 100644
index 00000000..632b8c3a
--- /dev/null
+++ b/engine/menu/draw_start_menu.asm
@@ -0,0 +1,87 @@
+; function that displays the start menu
+DrawStartMenu:
+ CheckEvent EVENT_GOT_POKEDEX
+; menu with pokedex
+ coord hl, 10, 0
+ lb bc, 14, 8
+ jr nz,.drawTextBoxBorder
+; shorter menu if the player doesn't have the pokedex
+ coord hl, 10, 0
+ lb bc, 12, 8
+.drawTextBoxBorder
+ call TextBoxBorder
+ ld a, D_DOWN | D_UP | START | B_BUTTON | A_BUTTON
+ ld [wMenuWatchedKeys], a
+ ld a, $02
+ ld [wTopMenuItemY], a ; Y position of first menu choice
+ ld a, $0b
+ ld [wTopMenuItemX], a ; X position of first menu choice
+ ld a, [wBattleAndStartSavedMenuItem] ; remembered menu selection from last time
+ ld [wCurrentMenuItem], a
+ ld [wLastMenuItem], a
+ xor a
+ ld [wMenuWatchMovingOutOfBounds], a
+ ld hl, wd730
+ set 6, [hl] ; no pauses between printing each letter
+ coord hl, 12, 2
+ CheckEvent EVENT_GOT_POKEDEX
+; case for not having pokedex
+ ld a, $06
+ jr z, .storeMenuItemCount
+; case for having pokedex
+ ld de, StartMenuPokedexText
+ call PrintStartMenuItem
+ ld a, $07
+.storeMenuItemCount
+ ld [wMaxMenuItem], a ; number of menu items
+ ld de, StartMenuPokemonText
+ call PrintStartMenuItem
+ ld de, StartMenuItemText
+ call PrintStartMenuItem
+ ld de, wPlayerName ; player's name
+ call PrintStartMenuItem
+ ld a, [wd72e]
+ bit 6, a ; is the player using the link feature?
+; case for not using link feature
+ ld de, StartMenuSaveText
+ jr z, .printSaveOrResetText
+; case for using link feature
+ ld de, StartMenuResetText
+.printSaveOrResetText
+ call PrintStartMenuItem
+ ld de, StartMenuOptionText
+ call PrintStartMenuItem
+ ld de, StartMenuExitText
+ call PlaceString
+ ld hl, wd730
+ res 6, [hl] ; turn pauses between printing letters back on
+ ret
+
+StartMenuPokedexText:
+ db "POKéDEX@"
+
+StartMenuPokemonText:
+ db "#MON@"
+
+StartMenuItemText:
+ db "ITEM@"
+
+StartMenuSaveText:
+ db "SAVE@"
+
+StartMenuResetText:
+ db "RESET@"
+
+StartMenuExitText:
+ db "EXIT@"
+
+StartMenuOptionText:
+ db "OPTION@"
+
+PrintStartMenuItem:
+ push hl
+ call PlaceString
+ pop hl
+ ld de, SCREEN_WIDTH * 2
+ add hl, de
+ ret
diff --git a/engine/menu/link_menu.asm b/engine/menu/link_menu.asm
index 3782e93e..9bc28b31 100644
--- a/engine/menu/link_menu.asm
+++ b/engine/menu/link_menu.asm
@@ -904,7 +904,7 @@ TextTerminator_f5a16:
db "@"
TradeCenterText:
- db "TRADE CENTER"
+ db "TRADE CENTER"
next "COLOSSEUM"
next "COLOSSEUM2"
next "CANCEL@"
diff --git a/engine/menu/main_menu.asm b/engine/menu/main_menu.asm
index 5ff9cc7d..ce27ebba 100755
--- a/engine/menu/main_menu.asm
+++ b/engine/menu/main_menu.asm
@@ -2,42 +2,42 @@ MainMenu:
; Check save file
call InitOptions
xor a
- ld [wOptionsInitialized],a
+ ld [wOptionsInitialized], a
inc a
- ld [wSaveFileStatus],a
+ ld [wSaveFileStatus], a
call CheckForPlayerNameInSRAM
- jr nc,.mainMenuLoop
+ jr nc, .mainMenuLoop
predef LoadSAV
.mainMenuLoop
- ld c,20
+ ld c, 20
call DelayFrames
xor a ; LINK_STATE_NONE
- ld [wLinkState],a
- ld hl,wPartyAndBillsPCSavedMenuItem
- ld [hli],a
- ld [hli],a
- ld [hli],a
- ld [hl],a
- ld [wDefaultMap],a
- ld hl,wd72e
- res 6,[hl]
+ ld [wLinkState], a
+ ld hl, wPartyAndBillsPCSavedMenuItem
+ ld [hli], a
+ ld [hli], a
+ ld [hli], a
+ ld [hl], a
+ ld [wDefaultMap], a
+ ld hl, wd72e
+ res 6, [hl]
call ClearScreen
call RunDefaultPaletteCommand
call LoadTextBoxTilePatterns
call LoadFontTilePatterns
- ld hl,wd730
- set 6,[hl]
- ld a,[wSaveFileStatus]
- cp a,1
- jr z,.noSaveFile
+ ld hl, wd730
+ set 6, [hl]
+ ld a, [wSaveFileStatus]
+ cp 1
+ jr z, .noSaveFile
; there's a save file
coord hl, 0, 0
lb bc, 6, 13
call TextBoxBorder
coord hl, 2, 2
- ld de,ContinueText
+ ld de, ContinueText
call PlaceString
jr .next2
.noSaveFile
@@ -45,89 +45,89 @@ MainMenu:
lb bc, 4, 13
call TextBoxBorder
coord hl, 2, 2
- ld de,NewGameText
+ ld de, NewGameText
call PlaceString
.next2
- ld hl,wd730
- res 6,[hl]
+ ld hl, wd730
+ res 6, [hl]
call UpdateSprites
xor a
- ld [wCurrentMenuItem],a
- ld [wLastMenuItem],a
- ld [wMenuJoypadPollCount],a
+ ld [wCurrentMenuItem], a
+ ld [wLastMenuItem], a
+ ld [wMenuJoypadPollCount], a
inc a
- ld [wTopMenuItemX],a
+ ld [wTopMenuItemX], a
inc a
- ld [wTopMenuItemY],a
- ld a,A_BUTTON | B_BUTTON | START
- ld [wMenuWatchedKeys],a
- ld a,[wSaveFileStatus]
- ld [wMaxMenuItem],a
+ ld [wTopMenuItemY], a
+ ld a, A_BUTTON | B_BUTTON | START
+ ld [wMenuWatchedKeys], a
+ ld a, [wSaveFileStatus]
+ ld [wMaxMenuItem], a
call HandleMenuInput
- bit 1,a ; pressed B?
- jp nz,DisplayTitleScreen ; if so, go back to the title screen
- ld c,20
+ bit 1, a ; pressed B?
+ jp nz, DisplayTitleScreen ; if so, go back to the title screen
+ ld c, 20
call DelayFrames
- ld a,[wCurrentMenuItem]
- ld b,a
- ld a,[wSaveFileStatus]
- cp a,2
- jp z,.skipInc
+ ld a, [wCurrentMenuItem]
+ ld b, a
+ ld a, [wSaveFileStatus]
+ cp 2
+ jp z, .skipInc
; If there's no save file, increment the current menu item so that the numbers
; are the same whether or not there's a save file.
inc b
.skipInc
- ld a,b
+ ld a, b
and a
- jr z,.choseContinue
- cp a,1
- jp z,StartNewGame
+ jr z, .choseContinue
+ cp 1
+ jp z, StartNewGame
call DisplayOptionMenu
- ld a,1
- ld [wOptionsInitialized],a
+ ld a, 1
+ ld [wOptionsInitialized], a
jp .mainMenuLoop
.choseContinue
call DisplayContinueGameInfo
- ld hl,wCurrentMapScriptFlags
- set 5,[hl]
+ ld hl, wCurrentMapScriptFlags
+ set 5, [hl]
.inputLoop
xor a
- ld [hJoyPressed],a
- ld [hJoyReleased],a
- ld [hJoyHeld],a
+ ld [hJoyPressed], a
+ ld [hJoyReleased], a
+ ld [hJoyHeld], a
call Joypad
- ld a,[hJoyHeld]
- bit 0,a
- jr nz,.pressedA
- bit 1,a
- jp nz,.mainMenuLoop ; pressed B
+ ld a, [hJoyHeld]
+ bit 0, a
+ jr nz, .pressedA
+ bit 1, a
+ jp nz, .mainMenuLoop ; pressed B
jr .inputLoop
.pressedA
call GBPalWhiteOutWithDelay3
call ClearScreen
- ld a,PLAYER_DIR_DOWN
- ld [wPlayerDirection],a
- ld c,10
+ ld a, PLAYER_DIR_DOWN
+ ld [wPlayerDirection], a
+ ld c, 10
call DelayFrames
- ld a,[wNumHoFTeams]
+ ld a, [wNumHoFTeams]
and a
- jp z,SpecialEnterMap
- ld a,[wCurMap] ; map ID
- cp a,HALL_OF_FAME
- jp nz,SpecialEnterMap
+ jp z, SpecialEnterMap
+ ld a, [wCurMap] ; map ID
+ cp HALL_OF_FAME
+ jp nz, SpecialEnterMap
xor a
- ld [wDestinationMap],a
- ld hl,wd732
- set 2,[hl] ; fly warp or dungeon warp
+ ld [wDestinationMap], a
+ ld hl, wd732
+ set 2, [hl] ; fly warp or dungeon warp
call SpecialWarpIn
jp SpecialEnterMap
InitOptions:
- ld a,1 ; no delay
- ld [wLetterPrintingDelayFlags],a
- ld a,3 ; medium speed
- ld [wOptions],a
- ld a,64 ; audio?
+ ld a, 1 ; no delay
+ ld [wLetterPrintingDelayFlags], a
+ ld a, 3 ; medium speed
+ ld [wOptions], a
+ ld a, 64 ; audio?
ld [wPrinterSettings], a
ret
@@ -175,8 +175,8 @@ ContinueText:
db "CONTINUE", $4e
NewGameText:
- db "NEW GAME", $4e
- db "OPTION@"
+ db "NEW GAME"
+ next "OPTION@"
DisplayContinueGameInfo:
xor a
diff --git a/engine/menu/naming_screen.asm b/engine/menu/naming_screen.asm
index 911c4e99..2560677a 100755
--- a/engine/menu/naming_screen.asm
+++ b/engine/menu/naming_screen.asm
@@ -380,10 +380,10 @@ PrintAlphabet:
jp Delay3
LowerCaseAlphabet:
- db "abcdefghijklmnopqrstuvwxyz ×():;[]",$e1,$e2,"-?!♂♀/",$f2,",¥UPPER CASE@"
+ db "abcdefghijklmnopqrstuvwxyz ×():;[]",$e1,$e2,"-?!♂♀/⠄,¥UPPER CASE@"
UpperCaseAlphabet:
- db "ABCDEFGHIJKLMNOPQRSTUVWXYZ ×():;[]",$e1,$e2,"-?!♂♀/",$f2,",¥lower case@"
+ db "ABCDEFGHIJKLMNOPQRSTUVWXYZ ×():;[]",$e1,$e2,"-?!♂♀/⠄,¥lower case@"
PrintNicknameAndUnderscores:
call CalcStringLength
@@ -423,7 +423,7 @@ PrintNicknameAndUnderscores:
call EraseMenuCursor
ld a, $11 ; "ED" x coord
ld [wTopMenuItemX], a
- ld a, $5 ; "ED" y corrd
+ ld a, $5 ; "ED" y coord
ld [wCurrentMenuItem], a
ld a, [wNamingScreenType]
cp NAME_MON_SCREEN
diff --git a/engine/menu/oaks_pc.asm b/engine/menu/oaks_pc.asm
index e4172ec7..03c9b8f1 100755
--- a/engine/menu/oaks_pc.asm
+++ b/engine/menu/oaks_pc.asm
@@ -20,7 +20,8 @@ GetDexRatedText:
ClosedOaksPCText:
TX_FAR _ClosedOaksPCText
- db $0d,"@"
+ TX_WAIT
+ db "@"
AccessedOaksPCText:
TX_FAR _AccessedOaksPCText
diff --git a/engine/menu/party_menu.asm b/engine/menu/party_menu.asm
index 669d49db..00c757be 100755
--- a/engine/menu/party_menu.asm
+++ b/engine/menu/party_menu.asm
@@ -19,38 +19,38 @@
; f8: leveled up
DrawPartyMenu_:
xor a
- ld [H_AUTOBGTRANSFERENABLED],a
+ ld [H_AUTOBGTRANSFERENABLED], a
call ClearScreen
call UpdateSprites
callba LoadMonPartySpriteGfxWithLCDDisabled ; load pokemon icon graphics
RedrawPartyMenu_:
- ld a,[wPartyMenuTypeOrMessageID]
- cp a,SWAP_MONS_PARTY_MENU
- jp z,.printMessage
+ ld a, [wPartyMenuTypeOrMessageID]
+ cp SWAP_MONS_PARTY_MENU
+ jp z, .printMessage
call ErasePartyMenuCursors
callba InitPartyMenuBlkPacket
coord hl, 3, 0
- ld de,wPartySpecies
+ ld de, wPartySpecies
xor a
- ld c,a
- ld [hPartyMonIndex],a
- ld [wWhichPartyMenuHPBar],a
+ ld c, a
+ ld [hPartyMonIndex], a
+ ld [wWhichPartyMenuHPBar], a
.loop
- ld a,[de]
- cp a,$FF ; reached the terminator?
- jp z,.afterDrawingMonEntries
+ ld a, [de]
+ cp $FF ; reached the terminator?
+ jp z, .afterDrawingMonEntries
push bc
push de
push hl
- ld a,c
+ ld a, c
push hl
- ld hl,wPartyMonNicks
+ ld hl, wPartyMonNicks
call GetPartyMonName
pop hl
call PlaceString ; print the pokemon's name
- ld a,[hPartyMonIndex]
- ld [wWhichPokemon],a
+ ld a, [hPartyMonIndex]
+ ld [wWhichPokemon], a
callab IsThisPartymonStarterPikachu_Party
jr nc, .regularMon
call CheckPikachuFollowingPlayer
@@ -61,49 +61,49 @@ RedrawPartyMenu_:
callba WriteMonPartySpriteOAMByPartyIndex ; place the appropriate pokemon icon
ld a, [wWhichPokemon]
inc a
- ld [hPartyMonIndex],a
+ ld [hPartyMonIndex], a
call LoadMonData
pop hl
push hl
- ld a,[wMenuItemToSwap]
+ ld a, [wMenuItemToSwap]
and a ; is the player swapping pokemon positions?
- jr z,.skipUnfilledRightArrow
+ jr z, .skipUnfilledRightArrow
; if the player is swapping pokemon positions
dec a
- ld b,a
- ld a,[wWhichPokemon]
+ ld b, a
+ ld a, [wWhichPokemon]
cp b ; is the player swapping the current pokemon in the list?
- jr nz,.skipUnfilledRightArrow
+ jr nz, .skipUnfilledRightArrow
; the player is swapping the current pokemon in the list
dec hl
dec hl
dec hl
- ld a,$EC ; unfilled right arrow menu cursor
- ld [hli],a ; place the cursor
+ ld a, "▷" ; unfilled right arrow menu cursor
+ ld [hli], a ; place the cursor
inc hl
inc hl
.skipUnfilledRightArrow
- ld a,[wPartyMenuTypeOrMessageID] ; menu type
- cp a,TMHM_PARTY_MENU
- jr z,.teachMoveMenu
- cp a,EVO_STONE_PARTY_MENU
- jr z,.evolutionStoneMenu
+ ld a, [wPartyMenuTypeOrMessageID] ; menu type
+ cp TMHM_PARTY_MENU
+ jr z, .teachMoveMenu
+ cp EVO_STONE_PARTY_MENU
+ jr z, .evolutionStoneMenu
push hl
- ld bc,14 ; 14 columns to the right
- add hl,bc
- ld de,wLoadedMonStatus
+ ld bc, 14 ; 14 columns to the right
+ add hl, bc
+ ld de, wLoadedMonStatus
call PrintStatusCondition
pop hl
push hl
- ld bc,20 + 1 ; down 1 row and right 1 column
- ld a,[hFlags_0xFFFA]
- set 0,a
- ld [hFlags_0xFFFA],a
- add hl,bc
+ ld bc, SCREEN_WIDTH + 1 ; down 1 row and right 1 column
+ ld a, [hFlags_0xFFFA]
+ set 0, a
+ ld [hFlags_0xFFFA], a
+ add hl, bc
predef DrawHP2 ; draw HP bar and prints current / max HP
- ld a,[hFlags_0xFFFA]
- res 0,a
- ld [hFlags_0xFFFA],a
+ ld a, [hFlags_0xFFFA]
+ res 0, a
+ ld [hFlags_0xFFFA], a
call SetPartyMenuHPBarColor ; color the HP bar (on SGB)
pop hl
jr .printLevel
@@ -111,26 +111,26 @@ RedrawPartyMenu_:
push hl
predef CanLearnTM ; check if the pokemon can learn the move
pop hl
- ld de,.ableToLearnMoveText
- ld a,c
+ ld de, .ableToLearnMoveText
+ ld a, c
and a
- jr nz,.placeMoveLearnabilityString
- ld de,.notAbleToLearnMoveText
+ jr nz, .placeMoveLearnabilityString
+ ld de, .notAbleToLearnMoveText
.placeMoveLearnabilityString
push hl
- ld bc,20 + 9 ; down 1 row and right 9 columns
- add hl,bc
+ ld bc, 20 + 9 ; down 1 row and right 9 columns
+ add hl, bc
call PlaceString
pop hl
.printLevel
- ld bc,10 ; move 10 columns to the right
- add hl,bc
+ ld bc, 10 ; move 10 columns to the right
+ add hl, bc
call PrintLevel
pop hl
pop de
inc de
- ld bc,2 * 20
- add hl,bc
+ ld bc, 2 * 20
+ add hl, bc
pop bc
inc c
jp .loop
@@ -140,54 +140,54 @@ RedrawPartyMenu_:
db "NOT ABLE@"
.evolutionStoneMenu
push hl
- ld hl,EvosMovesPointerTable
- ld b,0
- ld a,[wLoadedMonSpecies]
+ ld hl, EvosMovesPointerTable
+ ld b, 0
+ ld a, [wLoadedMonSpecies]
dec a
add a
rl b
- ld c,a
- add hl,bc
- ld de,wcd6d
- ld a,BANK(EvosMovesPointerTable)
- ld bc,2
+ ld c, a
+ add hl, bc
+ ld de, wEvosMoves
+ ld a, BANK(EvosMovesPointerTable)
+ ld bc, 2
call FarCopyData
- ld hl,wcd6d
- ld a,[hli]
- ld h,[hl]
- ld l,a
- ld de,wcd6d
- ld a,BANK(EvosMovesPointerTable)
- ld bc, $0d ; Mon133_EvosEnd - Mon133_EvosMoves
+ ld hl, wEvosMoves
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld de, wEvosMoves
+ ld a, BANK(EvosMovesPointerTable)
+ ld bc, wEvosMoves.end - wEvosMoves
call FarCopyData
- ld hl,wcd6d
- ld de,.notAbleToEvolveText
+ ld hl, wEvosMoves
+ ld de, .notAbleToEvolveText
; loop through the pokemon's evolution entries
.checkEvolutionsLoop
- ld a,[hli]
+ ld a, [hli]
and a ; reached terminator?
- jr z,.placeEvolutionStoneString ; if so, place the "NOT ABLE" string
+ jr z, .placeEvolutionStoneString ; if so, place the "NOT ABLE" string
inc hl
inc hl
- cp a,EV_ITEM
- jr nz,.checkEvolutionsLoop
+ cp EV_ITEM
+ jr nz, .checkEvolutionsLoop
; if it's a stone evolution entry
dec hl
dec hl
- ld b,[hl]
- ld a,[wEvoStoneItemID] ; the stone the player used
+ ld b, [hl]
+ ld a, [wEvoStoneItemID] ; the stone the player used
inc hl
inc hl
inc hl
cp b ; does the player's stone match this evolution entry's stone?
- jr nz,.checkEvolutionsLoop
+ jr nz, .checkEvolutionsLoop
; if it does match
- ld de,.ableToEvolveText
+ ld de, .ableToEvolveText
.placeEvolutionStoneString
pop hl
push hl
- ld bc,20 + 9 ; down 1 row and right 9 columns
- add hl,bc
+ ld bc, 20 + 9 ; down 1 row and right 9 columns
+ add hl, bc
call PlaceString
pop hl
jr .printLevel
@@ -199,44 +199,44 @@ RedrawPartyMenu_:
ld b, SET_PAL_PARTY_MENU
call RunPaletteCommand
.printMessage
- ld hl,wd730
- ld a,[hl]
+ ld hl, wd730
+ ld a, [hl]
push af
push hl
- set 6,[hl] ; turn off letter printing delay
- ld a,[wPartyMenuTypeOrMessageID] ; message ID
- cp a,$F0
- jr nc,.printItemUseMessage
+ set 6, [hl] ; turn off letter printing delay
+ ld a, [wPartyMenuTypeOrMessageID] ; message ID
+ cp $F0
+ jr nc, .printItemUseMessage
add a
- ld hl,PartyMenuMessagePointers
- ld b,0
- ld c,a
- add hl,bc
- ld a,[hli]
- ld h,[hl]
- ld l,a
+ ld hl, PartyMenuMessagePointers
+ ld b, 0
+ ld c, a
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
call PrintText
.done
pop hl
pop af
- ld [hl],a
- ld a,1
- ld [H_AUTOBGTRANSFERENABLED],a
+ ld [hl], a
+ ld a, 1
+ ld [H_AUTOBGTRANSFERENABLED], a
call Delay3
jp GBPalNormal
.printItemUseMessage
- and a,$0F
- ld hl,PartyMenuItemUseMessagePointers
+ and $0F
+ ld hl, PartyMenuItemUseMessagePointers
add a
- ld c,a
- ld b,0
- add hl,bc
- ld a,[hli]
- ld h,[hl]
- ld l,a
+ ld c, a
+ ld b, 0
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
push hl
- ld a,[wUsedItemOnWhichPokemon]
- ld hl,wPartyMonNicks
+ ld a, [wUsedItemOnWhichPokemon]
+ ld hl, wPartyMonNicks
call GetPartyMonName
pop hl
call PrintText
@@ -315,8 +315,8 @@ ReviveText:
RareCandyText:
TX_FAR _RareCandyText
- db $0B
- db $06
+ TX_SFX_ITEM_1 ; probably supposed to play SFX_LEVEL_UP but the wrong music bank is loaded
+ TX_BLINK
db "@"
SetPartyMenuHPBarColor:
diff --git a/engine/menu/pc.asm b/engine/menu/pc.asm
index c9e2cf08..5639bd99 100755
--- a/engine/menu/pc.asm
+++ b/engine/menu/pc.asm
@@ -17,34 +17,34 @@ PCMainMenu:
bit 1, a ;if player pressed B
jp nz, LogOff
ld a, [wMaxMenuItem]
- cp a, 2
+ cp 2
jr nz, .next ;if not 2 menu items (not counting log off) (2 occurs before you get the pokedex)
ld a, [wCurrentMenuItem]
and a
jp z, BillsPC ;if current menu item id is 0, it's bills pc
- cp a, 1
+ cp 1
jr z, .playersPC ;if current menu item id is 1, it's players pc
jp LogOff ;otherwise, it's 2, and you're logging off
.next
- cp a, 3
+ cp 3
jr nz, .next2 ;if not 3 menu items (not counting log off) (3 occurs after you get the pokedex, before you beat the pokemon league)
ld a, [wCurrentMenuItem]
and a
jp z, BillsPC ;if current menu item id is 0, it's bills pc
- cp a, 1
+ cp 1
jr z, .playersPC ;if current menu item id is 1, it's players pc
- cp a, 2
+ cp 2
jp z, OaksPC ;if current menu item id is 2, it's oaks pc
jp LogOff ;otherwise, it's 3, and you're logging off
.next2
ld a, [wCurrentMenuItem]
and a
jp z, BillsPC ;if current menu item id is 0, it's bills pc
- cp a, 1
+ cp 1
jr z, .playersPC ;if current menu item id is 1, it's players pc
- cp a, 2
+ cp 2
jp z, OaksPC ;if current menu item id is 2, it's oaks pc
- cp a, 3
+ cp 3
jp z, PKMNLeague ;if current menu item id is 3, it's pkmnleague
jp LogOff ;otherwise, it's 4, and you're logging off
.playersPC
diff --git a/engine/menu/pokedex.asm b/engine/menu/pokedex.asm
index 166e026d..bc2a7e9b 100755
--- a/engine/menu/pokedex.asm
+++ b/engine/menu/pokedex.asm
@@ -260,7 +260,7 @@ Pokedex_DrawInterface:
ld [H_AUTOBGTRANSFERENABLED], a
; draw the horizontal line separating the seen and owned amounts from the menu
coord hl, 15, 6
- ld a, $7a ; horizontal line tile
+ ld a, "─"
ld [hli], a
ld [hli], a
ld [hli], a
@@ -356,7 +356,7 @@ Pokedex_PlacePokemonList:
ld [wd11e], a
ld d, 7
ld a, [wDexMaxSeenMon]
- cp a, 7
+ cp 7
jr nc, .printPokemonLoop
ld d, a
dec a
@@ -403,7 +403,7 @@ Pokedex_PlacePokemonList:
inc hl
call PlaceString
pop hl
- ld bc, 2 * 20
+ ld bc, 2 * SCREEN_WIDTH
add hl, bc
pop de
pop af
@@ -475,7 +475,7 @@ ShowPokedexDataInternal:
ret
HeightWeightText:
- db "HT ?", $60, "??", $61
+ db "HT ?", $60, "??", $61
next "WT ???lb@"
; XXX does anything point to this?
@@ -556,7 +556,7 @@ DrawDexEntryOnScreen:
coord hl, 2, 8
ld a, "№"
ld [hli], a
- ld a, $f2
+ ld a, "⠄"
ld [hli], a
ld de, wd11e
lb bc, LEADING_ZEROES | 1, 3
@@ -628,16 +628,16 @@ DrawDexEntryOnScreen:
call PrintNumber ; print weight
coord hl, 14, 8
ld a, [hDexWeight + 1]
- sub a, 10
+ sub 10
ld a, [hDexWeight]
- sbc a, 0
+ sbc 0
jr nc, .next
ld [hl], "0" ; if the weight is less than 10, put a 0 before the decimal point
.next
inc hl
ld a, [hli]
ld [hld], a ; make space for the decimal point by moving the last digit forward one tile
- ld [hl], $f2 ; decimal point tile
+ ld [hl], "⠄" ; decimal point tile
pop af
ld [hDexWeight + 1], a ; restore original value of [hDexWeight + 1]
pop af
@@ -729,7 +729,7 @@ PokedexToIndex:
ret
IndexToPokedex:
- ; converts the indexédex number at wd11e to a Pokédex number
+ ; converts the index number at wd11e to a Pokédex number
push bc
push hl
ld a, [wd11e]
diff --git a/engine/menu/prize_menu.asm b/engine/menu/prize_menu.asm
index d1b1be3c..405441c8 100755
--- a/engine/menu/prize_menu.asm
+++ b/engine/menu/prize_menu.asm
@@ -1,38 +1,38 @@
CeladonPrizeMenu:
- ld b,COIN_CASE
+ ld b, COIN_CASE
call IsItemInBag
- jr nz,.havingCoinCase
- ld hl,RequireCoinCaseTextPtr
+ jr nz, .havingCoinCase
+ ld hl, RequireCoinCaseTextPtr
jp PrintText
.havingCoinCase
- ld hl,wd730
- set 6,[hl] ; disable letter-printing delay
- ld hl,ExchangeCoinsForPrizesTextPtr
+ ld hl, wd730
+ set 6, [hl] ; disable letter-printing delay
+ ld hl, ExchangeCoinsForPrizesTextPtr
call PrintText
; the following are the menu settings
xor a
- ld [wCurrentMenuItem],a
- ld [wLastMenuItem],a
- ld a,A_BUTTON | B_BUTTON
- ld [wMenuWatchedKeys],a
- ld a,$03
- ld [wMaxMenuItem],a
- ld a,$04
- ld [wTopMenuItemY],a
- ld a,$01
- ld [wTopMenuItemX],a
+ ld [wCurrentMenuItem], a
+ ld [wLastMenuItem], a
+ ld a, A_BUTTON | B_BUTTON
+ ld [wMenuWatchedKeys], a
+ ld a, $03
+ ld [wMaxMenuItem], a
+ ld a, $04
+ ld [wTopMenuItemY], a
+ ld a, $01
+ ld [wTopMenuItemX], a
call PrintPrizePrice
coord hl, 0, 2
lb bc, 8, 16
call TextBoxBorder
call GetPrizeMenuId
call UpdateSprites
- ld hl,WhichPrizeTextPtr
+ ld hl, WhichPrizeTextPtr
call PrintText
call HandleMenuInput ; menu choice handler
- bit 1,a ; keypress = B (Cancel)
+ bit 1, a ; keypress = B (Cancel)
jr nz, .noChoice
- ld a,[wCurrentMenuItem]
+ ld a, [wCurrentMenuItem]
cp 3 ; "NO,THANKS" choice
jr z, .noChoice
call HandlePrizeChoice
@@ -43,7 +43,7 @@ CeladonPrizeMenu:
RequireCoinCaseTextPtr:
TX_FAR _RequireCoinCaseText
- db $0D
+ TX_WAIT
db "@"
ExchangeCoinsForPrizesTextPtr:
@@ -131,11 +131,11 @@ GetPrizeMenuId:
; reg. c:
; [low nybble] number of bytes
; [bit 765 = %100] space-padding (not zero-padding)
- ld c,(1 << 7 | 2)
+ ld c, (1 << 7 | 2)
; Function $15CD displays BCD value (same routine
; used by text-command $02)
call PrintBCDNumber
- ld de,wPrize2Price
+ ld de, wPrize2Price
coord hl, 13, 7
ld c, (1 << 7 | 2)
call PrintBCDNumber
@@ -161,8 +161,8 @@ PrintPrizePrice:
ld de, .SixSpacesString
call PlaceString
coord hl, 13, 1
- ld de,wPlayerCoins
- ld c, (1 << 7 | 2)
+ ld de, wPlayerCoins
+ ld c, %10000010
call PrintBCDNumber
ret
@@ -173,7 +173,7 @@ PrintPrizePrice:
db " @"
LoadCoinsToSubtract:
- ld a,[wWhichPrize]
+ ld a, [wWhichPrize]
add a
ld d, 0
ld e, a
@@ -204,7 +204,7 @@ HandlePrizeChoice:
.getMonName
call GetMonName
.givePrize
- ld hl,SoYouWantPrizeTextPtr
+ ld hl, SoYouWantPrizeTextPtr
call PrintText
call YesNoChoice
ld a, [wCurrentMenuItem] ; yes/no answer (Y=0, N=1)
@@ -216,7 +216,7 @@ HandlePrizeChoice:
ld a, [wWhichPrizeWindow]
cp $02
jr nz, .giveMon
- ld a,[wd11e]
+ ld a, [wd11e]
ld b, a
ld a, 1
ld c, a
@@ -224,20 +224,20 @@ HandlePrizeChoice:
jr nc, .bagFull
jr .subtractCoins
.giveMon
- ld a,[wd11e]
- ld [wcf91],a
+ ld a, [wd11e]
+ ld [wcf91], a
push af
call GetPrizeMonLevel
- ld c,a
+ ld c, a
pop af
- ld b,a
+ ld b, a
call GivePokemon
; If either the party or box was full, wait after displaying message.
push af
- ld a,[wAddedToParty]
+ ld a, [wAddedToParty]
and a
- call z,WaitForTextScrollButtonPress
+ call z, WaitForTextScrollButtonPress
pop af
; If the mon couldn't be given to the player (because both the party and box
@@ -246,19 +246,19 @@ HandlePrizeChoice:
.subtractCoins
call LoadCoinsToSubtract
- ld hl,hCoins + 1
- ld de,wPlayerCoins + 1
- ld c,$02 ; how many bytes
+ ld hl, hCoins + 1
+ ld de, wPlayerCoins + 1
+ ld c, $02 ; how many bytes
predef SubBCDPredef
jp PrintPrizePrice
.bagFull
- ld hl,PrizeRoomBagIsFullTextPtr
+ ld hl, PrizeRoomBagIsFullTextPtr
jp PrintText
.notEnoughCoins
- ld hl,SorryNeedMoreCoinsText
+ ld hl, SorryNeedMoreCoinsText
jp PrintText
.printOhFineThen
- ld hl,OhFineThenTextPtr
+ ld hl, OhFineThenTextPtr
jp PrintText
UnknownPrizeData:
@@ -267,7 +267,7 @@ UnknownPrizeData:
HereYouGoTextPtr:
TX_FAR _HereYouGoText
- db $0D
+ TX_WAIT
db "@"
SoYouWantPrizeTextPtr:
@@ -276,17 +276,17 @@ SoYouWantPrizeTextPtr:
SorryNeedMoreCoinsText:
TX_FAR _SorryNeedMoreCoinsText
- db $0D
+ TX_WAIT
db "@"
PrizeRoomBagIsFullTextPtr:
TX_FAR _OopsYouDontHaveEnoughRoomText
- db $0D
+ TX_WAIT
db "@"
OhFineThenTextPtr:
TX_FAR _OhFineThenText
- db $0D ; wait keypress (A/B) without blink
+ TX_WAIT
db "@"
GetPrizeMonLevel:
diff --git a/engine/menu/start_menu.asm b/engine/menu/start_menu.asm
index af687432..498d1467 100755
--- a/engine/menu/start_menu.asm
+++ b/engine/menu/start_menu.asm
@@ -53,7 +53,7 @@ RedisplayStartMenu_DoNotDrawStartMenu:
ld a, [wCurrentMenuItem]
ld [wBattleAndStartSavedMenuItem], a ; save current menu selection
ld a, b
- and a, %00001010 ; was the Start button or B button pressed?
+ and %00001010 ; was the Start button or B button pressed?
jp nz, CloseStartMenu
call SaveScreenTilesToBuffer2 ; copy background from wTileMap to wTileMapBackup2
CheckEvent EVENT_GOT_POKEDEX
@@ -61,17 +61,17 @@ RedisplayStartMenu_DoNotDrawStartMenu:
jr nz, .displayMenuItem
inc a ; adjust position to account for missing pokedex menu item
.displayMenuItem
- cp a, 0
+ cp 0
jp z, StartMenu_Pokedex
- cp a, 1
+ cp 1
jp z, StartMenu_Pokemon
- cp a, 2
+ cp 2
jp z, StartMenu_Item
- cp a, 3
+ cp 3
jp z, StartMenu_TrainerInfo
- cp a, 4
+ cp 4
jp z, StartMenu_SaveReset
- cp a, 5
+ cp 5
jp z, StartMenu_Option
; EXIT falls through to here
diff --git a/engine/menu/start_sub_menus.asm b/engine/menu/start_sub_menus.asm
index a93fb2e3..abc8f000 100755
--- a/engine/menu/start_sub_menus.asm
+++ b/engine/menu/start_sub_menus.asm
@@ -7,22 +7,22 @@ StartMenu_Pokedex:
jp RedisplayStartMenu
StartMenu_Pokemon:
- ld a,[wPartyCount]
+ ld a, [wPartyCount]
and a
- jp z,RedisplayStartMenu
+ jp z, RedisplayStartMenu
xor a
- ld [wMenuItemToSwap],a
- ld [wPartyMenuTypeOrMessageID],a
- ld [wUpdateSpritesEnabled],a
+ ld [wMenuItemToSwap], a
+ ld [wPartyMenuTypeOrMessageID], a
+ ld [wUpdateSpritesEnabled], a
call DisplayPartyMenu
jr .checkIfPokemonChosen
.loop
xor a
- ld [wMenuItemToSwap],a
- ld [wPartyMenuTypeOrMessageID],a
+ ld [wMenuItemToSwap], a
+ ld [wPartyMenuTypeOrMessageID], a
call GoBackToPartyMenu
.checkIfPokemonChosen
- jr nc,.chosePokemon
+ jr nc, .chosePokemon
.exitMenu
call GBPalWhiteOutWithDelay3
call RestoreScreenTilesAndReloadTilePatterns
@@ -30,94 +30,94 @@ StartMenu_Pokemon:
jp RedisplayStartMenu
.chosePokemon
call SaveScreenTilesToBuffer1
- ld a,FIELD_MOVE_MON_MENU
- ld [wTextBoxID],a
+ ld a, FIELD_MOVE_MON_MENU
+ ld [wTextBoxID], a
call DisplayTextBoxID ; display pokemon menu options
- ld hl,wFieldMoves
+ ld hl, wFieldMoves
lb bc, 2, 12 ; max menu item ID, top menu item Y
- ld e,5
+ ld e, 5
.adjustMenuVariablesLoop
dec e
- jr z,.storeMenuVariables
- ld a,[hli]
+ jr z, .storeMenuVariables
+ ld a, [hli]
and a ; end of field moves?
- jr z,.storeMenuVariables
+ jr z, .storeMenuVariables
inc b
dec c
dec c
jr .adjustMenuVariablesLoop
.storeMenuVariables
- ld hl,wTopMenuItemY
- ld a,c
- ld [hli],a ; top menu item Y
- ld a,[hFieldMoveMonMenuTopMenuItemX]
- ld [hli],a ; top menu item X
+ ld hl, wTopMenuItemY
+ ld a, c
+ ld [hli], a ; top menu item Y
+ ld a, [hFieldMoveMonMenuTopMenuItemX]
+ ld [hli], a ; top menu item X
xor a
- ld [hli],a ; current menu item ID
+ ld [hli], a ; current menu item ID
inc hl
- ld a,b
- ld [hli],a ; max menu item ID
- ld a,A_BUTTON | B_BUTTON
- ld [hli],a ; menu watched keys
+ ld a, b
+ ld [hli], a ; max menu item ID
+ ld a, A_BUTTON | B_BUTTON
+ ld [hli], a ; menu watched keys
xor a
- ld [hl],a
+ ld [hl], a
call HandleMenuInput
push af
call LoadScreenTilesFromBuffer1 ; restore saved screen
pop af
- bit 1,a ; was the B button pressed?
- jp nz,.loop
+ bit 1, a ; was the B button pressed?
+ jp nz, .loop
; if the B button wasn't pressed
- ld a,[wMaxMenuItem]
- ld b,a
- ld a,[wCurrentMenuItem] ; menu selection
+ ld a, [wMaxMenuItem]
+ ld b, a
+ ld a, [wCurrentMenuItem] ; menu selection
cp b
- jp z,.exitMenu ; if the player chose Cancel
+ jp z, .exitMenu ; if the player chose Cancel
dec b
cp b
- jr z,.choseSwitch
+ jr z, .choseSwitch
dec b
cp b
- jp z,.choseStats
- ld c,a
- ld b,0
- ld hl,wFieldMoves
- add hl,bc
+ jp z, .choseStats
+ ld c, a
+ ld b, 0
+ ld hl, wFieldMoves
+ add hl, bc
jp .choseOutOfBattleMove
.choseSwitch
- ld a,[wPartyCount]
- cp a,2 ; is there more than one pokemon in the party?
- jp c,StartMenu_Pokemon ; if not, no switching
+ ld a, [wPartyCount]
+ cp 2 ; is there more than one pokemon in the party?
+ jp c, StartMenu_Pokemon ; if not, no switching
call SwitchPartyMon_InitVarOrSwapData ; init [wMenuItemToSwap]
- ld a,SWAP_MONS_PARTY_MENU
- ld [wPartyMenuTypeOrMessageID],a
+ ld a, SWAP_MONS_PARTY_MENU
+ ld [wPartyMenuTypeOrMessageID], a
call GoBackToPartyMenu
jp .checkIfPokemonChosen
.choseStats
call ClearSprites
xor a ; PLAYER_PARTY_DATA
- ld [wMonDataLocation],a
+ ld [wMonDataLocation], a
predef StatusScreen
predef StatusScreen2
call ReloadMapData
jp StartMenu_Pokemon
.choseOutOfBattleMove
push hl
- ld a,[wWhichPokemon]
- ld hl,wPartyMonNicks
+ ld a, [wWhichPokemon]
+ ld hl, wPartyMonNicks
call GetPartyMonName
pop hl
- ld a,[hl]
+ ld a, [hl]
dec a
add a
- ld b,0
- ld c,a
- ld hl,.outOfBattleMovePointers
- add hl,bc
- ld a,[hli]
- ld h,[hl]
- ld l,a
- ld a,[wObtainedBadges] ; badges obtained
+ ld b, 0
+ ld c, a
+ ld hl, .outOfBattleMovePointers
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, [wObtainedBadges] ; badges obtained
jp hl
.outOfBattleMovePointers
dw .cut
@@ -130,44 +130,44 @@ StartMenu_Pokemon:
dw .teleport
dw .softboiled
.fly
- bit 2,a ; does the player have the Thunder Badge?
- jp z,.newBadgeRequired
+ bit 2, a ; does the player have the Thunder Badge?
+ jp z, .newBadgeRequired
call CheckIfInOutsideMap
- jr z,.canFly
- ld a,[wWhichPokemon]
- ld hl,wPartyMonNicks
+ jr z, .canFly
+ ld a, [wWhichPokemon]
+ ld hl, wPartyMonNicks
call GetPartyMonName
- ld hl,.cannotFlyHereText
+ ld hl, .cannotFlyHereText
call PrintText
jp .loop
.canFly
call ChooseFlyDestination
- ld a,[wd732]
- bit 3,a ; did the player decide to fly?
- jr nz,.asm_5d4c
+ ld a, [wd732]
+ bit 3, a ; did the player decide to fly?
+ jr nz, .asm_5d4c
call LoadFontTilePatterns
- ld hl,wd72e
- set 1,[hl]
+ ld hl, wd72e
+ set 1, [hl]
jp StartMenu_Pokemon
.asm_5d4c
call Func_1510
jp .goBackToMap
.cut
- bit 1,a ; does the player have the Cascade Badge?
- jp z,.newBadgeRequired
+ bit 1, a ; does the player have the Cascade Badge?
+ jp z, .newBadgeRequired
predef UsedCut
- ld a,[wActionResultOrTookBattleTurn]
+ ld a, [wActionResultOrTookBattleTurn]
and a
- jp z,.loop
+ jp z, .loop
jp CloseTextDisplay
.surf
- bit 4,a ; does the player have the Soul Badge?
- jp z,.newBadgeRequired
+ bit 4, a ; does the player have the Soul Badge?
+ jp z, .newBadgeRequired
callba IsSurfingAllowed
- ld hl,wd728
- bit 1,[hl]
- res 1,[hl]
- jp z,.loop
+ ld hl, wd728
+ bit 1, [hl]
+ res 1, [hl]
+ jp z, .loop
ld a, [wcf91]
cp PIKACHU ; is this surfing pikachu?
jr z, .surfingPikachu
@@ -178,12 +178,12 @@ StartMenu_Pokemon:
.continue
ld [wd473], a
ld a,SURFBOARD
- ld [wcf91],a
- ld [wPseudoItemID],a
+ ld [wcf91], a
+ ld [wPseudoItemID], a
call UseItem
- ld a,[wActionResultOrTookBattleTurn]
+ ld a, [wActionResultOrTookBattleTurn]
and a
- jr z,.reloadNormalSprite
+ jr z, .reloadNormalSprite
call GBPalWhiteOutWithDelay3
jp .goBackToMap
.reloadNormalSprite
@@ -191,17 +191,17 @@ StartMenu_Pokemon:
ld [wd473], a
jp .loop
.strength
- bit 3,a ; does the player have the Rainbow Badge?
- jp z,.newBadgeRequired
+ bit 3, a ; does the player have the Rainbow Badge?
+ jp z, .newBadgeRequired
predef PrintStrengthTxt
call GBPalWhiteOutWithDelay3
jp .goBackToMap
.flash
- bit 0,a ; does the player have the Boulder Badge?
- jp z,.newBadgeRequired
+ bit 0, a ; does the player have the Boulder Badge?
+ jp z, .newBadgeRequired
xor a
- ld [wMapPalOffset],a
- ld hl,.flashLightsAreaText
+ ld [wMapPalOffset], a
+ ld hl, .flashLightsAreaText
call PrintText
call GBPalWhiteOutWithDelay3
jp .goBackToMap
@@ -209,35 +209,35 @@ StartMenu_Pokemon:
TX_FAR _FlashLightsAreaText
db "@"
.dig
- ld a,ESCAPE_ROPE
- ld [wcf91],a
- ld [wPseudoItemID],a
+ ld a, ESCAPE_ROPE
+ ld [wcf91], a
+ ld [wPseudoItemID], a
call UseItem
- ld a,[wActionResultOrTookBattleTurn]
+ ld a, [wActionResultOrTookBattleTurn]
and a
- jp z,.loop
+ jp z, .loop
call GBPalWhiteOutWithDelay3
jp .goBackToMap
.teleport
call CheckIfInOutsideMap
- jr z,.canTeleport
- ld a,[wWhichPokemon]
- ld hl,wPartyMonNicks
+ jr z, .canTeleport
+ ld a, [wWhichPokemon]
+ ld hl, wPartyMonNicks
call GetPartyMonName
- ld hl,.cannotUseTeleportNowText
+ ld hl, .cannotUseTeleportNowText
call PrintText
jp .loop
.canTeleport
- ld hl,.warpToLastPokemonCenterText
+ ld hl, .warpToLastPokemonCenterText
call PrintText
- ld hl,wd732
- set 3,[hl]
- set 6,[hl]
+ ld hl, wd732
+ set 3, [hl]
+ set 6, [hl]
call Func_1510
- ld hl,wd72e
- set 1,[hl]
- res 4,[hl]
- ld c,60
+ ld hl, wd72e
+ set 1, [hl]
+ res 4, [hl]
+ ld c, 60
call DelayFrames
call GBPalWhiteOutWithDelay3
jp .goBackToMap
@@ -251,39 +251,39 @@ StartMenu_Pokemon:
TX_FAR _CannotFlyHereText
db "@"
.softboiled
- ld hl,wPartyMon1MaxHP
- ld a,[wWhichPokemon]
- ld bc,wPartyMon2 - wPartyMon1
+ ld hl, wPartyMon1MaxHP
+ ld a, [wWhichPokemon]
+ ld bc, wPartyMon2 - wPartyMon1
call AddNTimes
- ld a,[hli]
- ld [H_DIVIDEND],a
- ld a,[hl]
- ld [H_DIVIDEND + 1],a
- ld a,5
- ld [H_DIVISOR],a
- ld b,2 ; number of bytes
+ ld a, [hli]
+ ld [H_DIVIDEND], a
+ ld a, [hl]
+ ld [H_DIVIDEND + 1], a
+ ld a, 5
+ ld [H_DIVISOR], a
+ ld b, 2 ; number of bytes
call Divide
- ld bc,wPartyMon1HP - wPartyMon1MaxHP
- add hl,bc
- ld a,[hld]
- ld b,a
- ld a,[H_QUOTIENT + 3]
+ ld bc, wPartyMon1HP - wPartyMon1MaxHP
+ add hl, bc
+ ld a, [hld]
+ ld b, a
+ ld a, [H_QUOTIENT + 3]
sub b
- ld b,[hl]
- ld a,[H_QUOTIENT + 2]
+ ld b, [hl]
+ ld a, [H_QUOTIENT + 2]
sbc b
- jp nc,.notHealthyEnough
- ld a,[wPartyAndBillsPCSavedMenuItem]
+ jp nc, .notHealthyEnough
+ ld a, [wPartyAndBillsPCSavedMenuItem]
push af
- ld a,POTION
- ld [wcf91],a
- ld [wPseudoItemID],a
+ ld a, POTION
+ ld [wcf91], a
+ ld [wPseudoItemID], a
call UseItem
pop af
- ld [wPartyAndBillsPCSavedMenuItem],a
+ ld [wPartyAndBillsPCSavedMenuItem], a
jp .loop
.notHealthyEnough ; if current HP is less than 1/5 of max HP
- ld hl,.notHealthyEnoughText
+ ld hl, .notHealthyEnoughText
call PrintText
jp .loop
.notHealthyEnoughText
@@ -293,7 +293,7 @@ StartMenu_Pokemon:
call RestoreScreenTilesAndReloadTilePatterns
jp CloseTextDisplay
.newBadgeRequired
- ld hl,.newBadgeRequiredText
+ ld hl, .newBadgeRequiredText
call PrintText
jp .loop
.newBadgeRequiredText
@@ -303,13 +303,13 @@ StartMenu_Pokemon:
; writes a blank tile to all possible menu cursor positions on the party menu
ErasePartyMenuCursors:
coord hl, 0, 1
- ld bc,2 * 20 ; menu cursor positions are 2 rows apart
- ld a,6 ; 6 menu cursor positions
+ ld bc, 2 * 20 ; menu cursor positions are 2 rows apart
+ ld a, 6 ; 6 menu cursor positions
.loop
- ld [hl]," "
- add hl,bc
+ ld [hl], " "
+ add hl, bc
dec a
- jr nz,.loop
+ jr nz, .loop
ret
ItemMenuLoop:
@@ -317,27 +317,27 @@ ItemMenuLoop:
call RunDefaultPaletteCommand
StartMenu_Item:
- ld a,[wLinkState]
+ ld a, [wLinkState]
dec a ; is the player in the Colosseum or Trade Centre?
- jr nz,.notInCableClubRoom
- ld hl,CannotUseItemsHereText
+ jr nz, .notInCableClubRoom
+ ld hl, CannotUseItemsHereText
call PrintText
jr .exitMenu
.notInCableClubRoom
- ld hl,wListPointer
+ ld hl, wListPointer
ld [hl], wNumBagItems & $ff
inc hl
ld [hl], wNumBagItems / $100 ; store item bag pointer in wListPointer (for DisplayListMenuID)
xor a
- ld [wPrintItemPrices],a
- ld a,ITEMLISTMENU
- ld [wListMenuID],a
- ld a,[wBagSavedMenuItem]
- ld [wCurrentMenuItem],a
+ ld [wPrintItemPrices], a
+ ld a, ITEMLISTMENU
+ ld [wListMenuID], a
+ ld a, [wBagSavedMenuItem]
+ ld [wCurrentMenuItem], a
call DisplayListMenuID
- ld a,[wCurrentMenuItem]
- ld [wBagSavedMenuItem],a
- jr nc,.choseItem
+ ld a, [wCurrentMenuItem]
+ ld [wBagSavedMenuItem], a
+ jr nc, .choseItem
.exitMenu
call LoadScreenTilesFromBuffer2 ; restore saved screen
call LoadTextBoxTilePatterns
@@ -345,111 +345,111 @@ StartMenu_Item:
jp RedisplayStartMenu
.choseItem
; erase menu cursor (blank each tile in front of an item name)
- ld a," "
+ ld a, " "
Coorda 5, 4
Coorda 5, 6
Coorda 5, 8
Coorda 5, 10
call PlaceUnfilledArrowMenuCursor
xor a
- ld [wMenuItemToSwap],a
- ld a,[wcf91]
- cp a,BICYCLE
- jp z,.useOrTossItem
+ ld [wMenuItemToSwap], a
+ ld a, [wcf91]
+ cp BICYCLE
+ jp z, .useOrTossItem
.notBicycle1
- ld a,USE_TOSS_MENU_TEMPLATE
- ld [wTextBoxID],a
+ ld a, USE_TOSS_MENU_TEMPLATE
+ ld [wTextBoxID], a
call DisplayTextBoxID
- ld hl,wTopMenuItemY
- ld a,11
- ld [hli],a ; top menu item Y
- ld a,14
- ld [hli],a ; top menu item X
+ ld hl, wTopMenuItemY
+ ld a, 11
+ ld [hli], a ; top menu item Y
+ ld a, 14
+ ld [hli], a ; top menu item X
xor a
- ld [hli],a ; current menu item ID
+ ld [hli], a ; current menu item ID
inc hl
inc a ; a = 1
- ld [hli],a ; max menu item ID
- ld a,A_BUTTON | B_BUTTON
- ld [hli],a ; menu watched keys
+ ld [hli], a ; max menu item ID
+ ld a, A_BUTTON | B_BUTTON
+ ld [hli], a ; menu watched keys
xor a
- ld [hl],a ; old menu item id
+ ld [hl], a ; old menu item id
call HandleMenuInput
call PlaceUnfilledArrowMenuCursor
- bit 1,a ; was the B button pressed?
- jr z,.useOrTossItem
+ bit 1, a ; was the B button pressed?
+ jr z, .useOrTossItem
jp ItemMenuLoop
.useOrTossItem ; if the player made the choice to use or toss the item
- ld a,[wcf91]
- ld [wd11e],a
+ ld a, [wcf91]
+ ld [wd11e], a
call GetItemName
call CopyStringToCF4B ; copy name to wcf4b
- ld a,[wcf91]
- cp a,BICYCLE
- jr nz,.notBicycle2
- ld a,[wd732]
- bit 5,a
- jr z,.useItem_closeMenu
- ld hl,CannotGetOffHereText
+ ld a, [wcf91]
+ cp BICYCLE
+ jr nz, .notBicycle2
+ ld a, [wd732]
+ bit 5, a
+ jr z, .useItem_closeMenu
+ ld hl, CannotGetOffHereText
call PrintText
jp ItemMenuLoop
.notBicycle2
- ld a,[wCurrentMenuItem]
+ ld a, [wCurrentMenuItem]
and a
- jr nz,.tossItem
+ jr nz, .tossItem
; use item
- ld [wPseudoItemID],a ; a must be 0 due to above conditional jump
- ld a,[wcf91]
- cp a,HM_01
- jr nc,.useItem_partyMenu
- ld hl,UsableItems_CloseMenu
- ld de,1
+ ld [wPseudoItemID], a ; a must be 0 due to above conditional jump
+ ld a, [wcf91]
+ cp HM_01
+ jr nc, .useItem_partyMenu
+ ld hl, UsableItems_CloseMenu
+ ld de, 1
call IsInArray
- jr c,.useItem_closeMenu
- ld a,[wcf91]
- ld hl,UsableItems_PartyMenu
- ld de,1
+ jr c, .useItem_closeMenu
+ ld a, [wcf91]
+ ld hl, UsableItems_PartyMenu
+ ld de, 1
call IsInArray
- jr c,.useItem_partyMenu
+ jr c, .useItem_partyMenu
call UseItem
jp ItemMenuLoop
.useItem_closeMenu
xor a
- ld [wPseudoItemID],a
+ ld [wPseudoItemID], a
call UseItem
- ld a,[wActionResultOrTookBattleTurn]
+ ld a, [wActionResultOrTookBattleTurn]
and a
- jp z,ItemMenuLoop
+ jp z, ItemMenuLoop
jp CloseStartMenu
.useItem_partyMenu
- ld a,[wUpdateSpritesEnabled]
+ ld a, [wUpdateSpritesEnabled]
push af
call UseItem
- ld a,[wActionResultOrTookBattleTurn]
- cp a,$02
- jp z,.partyMenuNotDisplayed
+ ld a, [wActionResultOrTookBattleTurn]
+ cp $02
+ jp z, .partyMenuNotDisplayed
call GBPalWhiteOutWithDelay3
call RestoreScreenTilesAndReloadTilePatterns
pop af
- ld [wUpdateSpritesEnabled],a
+ ld [wUpdateSpritesEnabled], a
jp StartMenu_Item
.partyMenuNotDisplayed
pop af
- ld [wUpdateSpritesEnabled],a
+ ld [wUpdateSpritesEnabled], a
jp ItemMenuLoop
.tossItem
call IsKeyItem
- ld a,[wIsKeyItem]
+ ld a, [wIsKeyItem]
and a
- jr nz,.skipAskingQuantity
- ld a,[wcf91]
+ jr nz, .skipAskingQuantity
+ ld a, [wcf91]
call IsItemHM
- jr c,.skipAskingQuantity
+ jr c, .skipAskingQuantity
call DisplayChooseQuantityMenu
inc a
- jr z,.tossZeroItems
+ jr z, .tossZeroItems
.skipAskingQuantity
- ld hl,wNumBagItems
+ ld hl, wNumBagItems
call TossItem
.tossZeroItems
jp ItemMenuLoop
@@ -516,10 +516,10 @@ StartMenu_TrainerInfo:
call GBPalWhiteOut
call ClearScreen
call UpdateSprites
- ld a,[hTilesetType]
+ ld a, [hTilesetType]
push af
xor a
- ld [hTilesetType],a
+ ld [hTilesetType], a
call DrawTrainerInfo
predef DrawBadges ; draw badges
ld b, SET_PAL_TRAINER_CARD
@@ -534,101 +534,101 @@ StartMenu_TrainerInfo:
callba DrawStartMenu ; XXX what difference does this make?
call LoadGBPal
pop af
- ld [hTilesetType],a
+ ld [hTilesetType], a
jp RedisplayStartMenu_DoNotDrawStartMenu
; loads tile patterns and draws everything except for gym leader faces / badges
DrawTrainerInfo:
- ld de,RedPicFront
+ ld de, RedPicFront
lb bc, BANK(RedPicFront), $01
predef DisplayPicCenteredOrUpperRight
call DisableLCD
coord hl, 0, 2
- ld a," "
+ ld a, " "
call TrainerInfo_DrawVerticalLine
coord hl, 1, 2
call TrainerInfo_DrawVerticalLine
- ld hl,vChars2 + $70
- ld de,vChars2
- ld bc,$70 * 4
+ ld hl, vChars2 + $70
+ ld de, vChars2
+ ld bc, $70 * 4
call CopyData
- ld hl,TrainerInfoTextBoxTileGraphics ; trainer info text box tile patterns
- ld de,vChars2 + $770
- ld bc,$0080
+ ld hl, TrainerInfoTextBoxTileGraphics ; trainer info text box tile patterns
+ ld de, vChars2 + $770
+ ld bc, $0080
push bc
call TrainerInfo_FarCopyData
- ld hl,BlankLeaderNames
- ld de,vChars2 + $600
- ld bc,$0170
+ ld hl, BlankLeaderNames
+ ld de, vChars2 + $600
+ ld bc, $0170
call TrainerInfo_FarCopyData
pop bc
- ld hl,BadgeNumbersTileGraphics ; badge number tile patterns
- ld de,vChars1 + $580
+ ld hl, BadgeNumbersTileGraphics ; badge number tile patterns
+ ld de, vChars1 + $580
call TrainerInfo_FarCopyData
- ld hl,GymLeaderFaceAndBadgeTileGraphics ; gym leader face and badge tile patterns
- ld de,vChars2 + $200
- ld bc,$0400
- ld a,$03
+ ld hl, GymLeaderFaceAndBadgeTileGraphics ; gym leader face and badge tile patterns
+ ld de, vChars2 + $200
+ ld bc, $0400
+ ld a, $03
call FarCopyData
- ld hl,TextBoxGraphics
- ld de,$00d0
- add hl,de ; hl = colon tile pattern
- ld de,vChars1 + $560
- ld bc,$0010
- ld a,$04
+ ld hl, TextBoxGraphics
+ ld de, $00d0
+ add hl, de ; hl = colon tile pattern
+ ld de, vChars1 + $560
+ ld bc, $0010
+ ld a, $04
push bc
call FarCopyData
pop bc
- ld hl,TrainerInfoTextBoxTileGraphics + $80 ; background tile pattern
- ld de,vChars1 + $570
+ ld hl, TrainerInfoTextBoxTileGraphics + $80 ; background tile pattern
+ ld de, vChars1 + $570
call TrainerInfo_FarCopyData
call EnableLCD
- ld hl,wTrainerInfoTextBoxWidthPlus1
- ld a,18 + 1
- ld [hli],a
+ ld hl, wTrainerInfoTextBoxWidthPlus1
+ ld a, 18 + 1
+ ld [hli], a
dec a
- ld [hli],a
- ld [hl],1
+ ld [hli], a
+ ld [hl], 1
coord hl, 0, 0
call TrainerInfo_DrawTextBox
- ld hl,wTrainerInfoTextBoxWidthPlus1
- ld a,16 + 1
- ld [hli],a
+ ld hl, wTrainerInfoTextBoxWidthPlus1
+ ld a, 16 + 1
+ ld [hli], a
dec a
- ld [hli],a
- ld [hl],3
+ ld [hli], a
+ ld [hl], 3
coord hl, 1, 10
call TrainerInfo_DrawTextBox
coord hl, 0, 10
- ld a,$d7
+ ld a, $d7
call TrainerInfo_DrawVerticalLine
coord hl, 19, 10
call TrainerInfo_DrawVerticalLine
coord hl, 6, 9
- ld de,TrainerInfo_BadgesText
+ ld de, TrainerInfo_BadgesText
call PlaceString
coord hl, 2, 2
- ld de,TrainerInfo_NameMoneyTimeText
+ ld de, TrainerInfo_NameMoneyTimeText
call PlaceString
coord hl, 7, 2
- ld de,wPlayerName
+ ld de, wPlayerName
call PlaceString
coord hl, 8, 4
- ld de,wPlayerMoney
- ld c,$e3
+ ld de, wPlayerMoney
+ ld c, $e3
call PrintBCDNumber
coord hl, 9, 6
- ld de,wPlayTimeHours ; hours
+ ld de, wPlayTimeHours ; hours
lb bc, LEFT_ALIGN | 1, 3
call PrintNumber
- ld [hl],$d6 ; colon tile ID
+ ld [hl], $d6 ; colon tile ID
inc hl
- ld de,wPlayTimeMinutes ; minutes
+ ld de, wPlayTimeMinutes ; minutes
lb bc, LEADING_ZEROES | 1, 2
jp PrintNumber
TrainerInfo_FarCopyData:
- ld a,BANK(TrainerInfoTextBoxTileGraphics)
+ ld a, BANK(TrainerInfoTextBoxTileGraphics)
jp FarCopyData
TrainerInfo_NameMoneyTimeText:
@@ -648,43 +648,43 @@ TrainerInfo_BadgesText:
; [wTrainerInfoTextBoxWidth] = width - 1
; [wTrainerInfoTextBoxNextRowOffset] = distance from the end of a text box row to the start of the next
TrainerInfo_DrawTextBox:
- ld a,$79 ; upper left corner tile ID
+ ld a, $79 ; upper left corner tile ID
lb de, $7a, $7b ; top edge and upper right corner tile ID's
call TrainerInfo_DrawHorizontalEdge ; draw top edge
call TrainerInfo_NextTextBoxRow
- ld a,[wTrainerInfoTextBoxWidthPlus1]
- ld e,a
- ld d,0
- ld c,6 ; height of the text box
+ ld a, [wTrainerInfoTextBoxWidthPlus1]
+ ld e, a
+ ld d, 0
+ ld c, 6 ; height of the text box
.loop
- ld [hl],$7c ; left edge tile ID
- add hl,de
- ld [hl],$78 ; right edge tile ID
+ ld [hl], $7c ; left edge tile ID
+ add hl, de
+ ld [hl], $78 ; right edge tile ID
call TrainerInfo_NextTextBoxRow
dec c
- jr nz,.loop
- ld a,$7d ; lower left corner tile ID
- lb de,$77, $7e ; bottom edge and lower right corner tile ID's
+ jr nz, .loop
+ ld a, $7d ; lower left corner tile ID
+ lb de, $77, $7e ; bottom edge and lower right corner tile ID's
TrainerInfo_DrawHorizontalEdge:
- ld [hli],a ; place left corner tile
- ld a,[wTrainerInfoTextBoxWidth]
- ld c,a
- ld a,d
+ ld [hli], a ; place left corner tile
+ ld a, [wTrainerInfoTextBoxWidth]
+ ld c, a
+ ld a, d
.loop
- ld [hli],a ; place edge tile
+ ld [hli], a ; place edge tile
dec c
- jr nz,.loop
- ld a,e
- ld [hl],a ; place right corner tile
+ jr nz, .loop
+ ld a, e
+ ld [hl], a ; place right corner tile
ret
TrainerInfo_NextTextBoxRow:
- ld a,[wTrainerInfoTextBoxNextRowOffset] ; distance to the start of the next row
+ ld a, [wTrainerInfoTextBoxNextRowOffset] ; distance to the start of the next row
.loop
inc hl
dec a
- jr nz,.loop
+ jr nz, .loop
ret
; draws a vertical line
@@ -692,26 +692,26 @@ TrainerInfo_NextTextBoxRow:
; hl = address of top tile in the line
; a = tile ID
TrainerInfo_DrawVerticalLine:
- ld de,20
- ld c,8
+ ld de, SCREEN_WIDTH
+ ld c, 8
.loop
- ld [hl],a
- add hl,de
+ ld [hl], a
+ add hl, de
dec c
- jr nz,.loop
+ jr nz, .loop
ret
StartMenu_SaveReset:
- ld a,[wd72e]
- bit 6,a ; is the player using the link feature?
- jp nz,Init
+ ld a, [wd72e]
+ bit 6, a ; is the player using the link feature?
+ jp nz, Init
predef SaveSAV ; save the game
call LoadScreenTilesFromBuffer2 ; restore saved screen
jp HoldTextDisplayOpen
StartMenu_Option:
xor a
- ld [H_AUTOBGTRANSFERENABLED],a
+ ld [H_AUTOBGTRANSFERENABLED], a
call ClearScreen
call UpdateSprites
callab DisplayOptionMenu
diff --git a/engine/menu/status_screen.asm b/engine/menu/status_screen.asm
index 4adfb543..1e2ba889 100755
--- a/engine/menu/status_screen.asm
+++ b/engine/menu/status_screen.asm
@@ -110,7 +110,7 @@ StatusScreen:
call DrawLineBox ; Draws the box around name, HP and status
ld de, -6
add hl, de
- ld [hl], $f2 ; . after No ("." is a different one)
+ ld [hl], "⠄" ; . after No ("." is a different one)
dec hl
ld [hl], "№"
coord hl, 19, 9
@@ -228,10 +228,11 @@ Type2Text:
db "TYPE2/", $4e
IDNoText:
- db $73, "№", "/", $4e
+ db $73, "№/", $4e
OTText:
- db "OT/", $4e, "@"
+ db "OT/"
+ next "@"
StatusText:
db "STATUS/@"
diff --git a/engine/menu/swap_items.asm b/engine/menu/swap_items.asm
index b1fa78be..563fc7d5 100644
--- a/engine/menu/swap_items.asm
+++ b/engine/menu/swap_items.asm
@@ -1,149 +1,149 @@
HandleItemListSwapping:
- ld a,[wListMenuID]
- cp a,ITEMLISTMENU
- jp nz,DisplayListMenuIDLoop ; only rearrange item list menus
+ ld a, [wListMenuID]
+ cp ITEMLISTMENU
+ jp nz, DisplayListMenuIDLoop ; only rearrange item list menus
push hl
- ld hl,wListPointer
- ld a,[hli]
- ld h,[hl]
- ld l,a
+ ld hl, wListPointer
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
inc hl ; hl = beginning of list entries
- ld a,[wCurrentMenuItem]
- ld b,a
- ld a,[wListScrollOffset]
+ ld a, [wCurrentMenuItem]
+ ld b, a
+ ld a, [wListScrollOffset]
add b
add a
- ld c,a
- ld b,0
- add hl,bc ; hl = address of currently selected item entry
- ld a,[hl]
+ ld c, a
+ ld b, 0
+ add hl, bc ; hl = address of currently selected item entry
+ ld a, [hl]
pop hl
inc a
- jp z,DisplayListMenuIDLoop ; ignore attempts to swap the Cancel menu item
- ld a,[wMenuItemToSwap] ; ID of item chosen for swapping (counts from 1)
+ jp z, DisplayListMenuIDLoop ; ignore attempts to swap the Cancel menu item
+ ld a, [wMenuItemToSwap] ; ID of item chosen for swapping (counts from 1)
and a ; has the first item to swap already been chosen?
- jr nz,.swapItems
+ jr nz, .swapItems
; if not, set the currently selected item as the first item
- ld a,[wCurrentMenuItem]
+ ld a, [wCurrentMenuItem]
inc a
- ld b,a
- ld a,[wListScrollOffset] ; index of top (visible) menu item within the list
+ ld b, a
+ ld a, [wListScrollOffset] ; index of top (visible) menu item within the list
add b
- ld [wMenuItemToSwap],a ; ID of item chosen for swapping (counts from 1)
- ld c,20
+ ld [wMenuItemToSwap], a ; ID of item chosen for swapping (counts from 1)
+ ld c, 20
call DelayFrames
jp DisplayListMenuIDLoop
.swapItems
- ld a,[wCurrentMenuItem]
+ ld a, [wCurrentMenuItem]
inc a
- ld b,a
- ld a,[wListScrollOffset]
+ ld b, a
+ ld a, [wListScrollOffset]
add b
- ld b,a
- ld a,[wMenuItemToSwap] ; ID of item chosen for swapping (counts from 1)
+ ld b, a
+ ld a, [wMenuItemToSwap] ; ID of item chosen for swapping (counts from 1)
cp b ; is the currently selected item the same as the first item to swap?
- jp z,DisplayListMenuIDLoop ; ignore attempts to swap an item with itself
+ jp z, DisplayListMenuIDLoop ; ignore attempts to swap an item with itself
dec a
- ld [wMenuItemToSwap],a ; ID of item chosen for swapping (counts from 1)
- ld c,20
+ ld [wMenuItemToSwap], a ; ID of item chosen for swapping (counts from 1)
+ ld c, 20
call DelayFrames
push hl
push de
- ld hl,wListPointer
- ld a,[hli]
- ld h,[hl]
- ld l,a
+ ld hl, wListPointer
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
inc hl ; hl = beginning of list entries
- ld d,h
- ld e,l ; de = beginning of list entries
- ld a,[wCurrentMenuItem]
- ld b,a
- ld a,[wListScrollOffset]
+ ld d, h
+ ld e, l ; de = beginning of list entries
+ ld a, [wCurrentMenuItem]
+ ld b, a
+ ld a, [wListScrollOffset]
add b
add a
- ld c,a
- ld b,0
- add hl,bc ; hl = address of currently selected item entry
- ld a,[wMenuItemToSwap] ; ID of item chosen for swapping (counts from 1)
+ ld c, a
+ ld b, 0
+ add hl, bc ; hl = address of currently selected item entry
+ ld a, [wMenuItemToSwap] ; ID of item chosen for swapping (counts from 1)
add a
add e
- ld e,a
- jr nc,.noCarry
+ ld e, a
+ jr nc, .noCarry
inc d
.noCarry ; de = address of first item to swap
- ld a,[de]
- ld b,a
- ld a,[hli]
+ ld a, [de]
+ ld b, a
+ ld a, [hli]
cp b
- jr z,.swapSameItemType
+ jr z, .swapSameItemType
.swapDifferentItems
- ld [$ff95],a ; [$ff95] = second item ID
- ld a,[hld]
- ld [$ff96],a ; [$ff96] = second item quantity
- ld a,[de]
- ld [hli],a ; put first item ID in second item slot
+ ld [$ff95], a ; [$ff95] = second item ID
+ ld a, [hld]
+ ld [$ff96], a ; [$ff96] = second item quantity
+ ld a, [de]
+ ld [hli], a ; put first item ID in second item slot
inc de
- ld a,[de]
- ld [hl],a ; put first item quantity in second item slot
- ld a,[$ff96]
- ld [de],a ; put second item quantity in first item slot
+ ld a, [de]
+ ld [hl], a ; put first item quantity in second item slot
+ ld a, [$ff96]
+ ld [de], a ; put second item quantity in first item slot
dec de
- ld a,[$ff95]
- ld [de],a ; put second item ID in first item slot
+ ld a, [$ff95]
+ ld [de], a ; put second item ID in first item slot
xor a
- ld [wMenuItemToSwap],a ; 0 means no item is currently being swapped
+ ld [wMenuItemToSwap], a ; 0 means no item is currently being swapped
pop de
pop hl
jp DisplayListMenuIDLoop
.swapSameItemType
inc de
- ld a,[hl]
- ld b,a
- ld a,[de]
+ ld a, [hl]
+ ld b, a
+ ld a, [de]
add b ; a = sum of both item quantities
- cp a,100 ; is the sum too big for one item slot?
- jr c,.combineItemSlots
+ cp 100 ; is the sum too big for one item slot?
+ jr c, .combineItemSlots
; swap enough items from the first slot to max out the second slot if they can't be combined
- sub a,99
- ld [de],a
- ld a,99
- ld [hl],a
+ sub 99
+ ld [de], a
+ ld a, 99
+ ld [hl], a
jr .done
.combineItemSlots
- ld [hl],a ; put the sum in the second item slot
- ld hl,wListPointer
- ld a,[hli]
- ld h,[hl]
- ld l,a
+ ld [hl], a ; put the sum in the second item slot
+ ld hl, wListPointer
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
dec [hl] ; decrease the number of items
- ld a,[hl]
- ld [wListCount],a ; update number of items variable
- cp a,1
- jr nz,.skipSettingMaxMenuItemID
- ld [wMaxMenuItem],a ; if the number of items is only one now, update the max menu item ID
+ ld a, [hl]
+ ld [wListCount], a ; update number of items variable
+ cp 1
+ jr nz, .skipSettingMaxMenuItemID
+ ld [wMaxMenuItem], a ; if the number of items is only one now, update the max menu item ID
.skipSettingMaxMenuItemID
dec de
- ld h,d
- ld l,e
+ ld h, d
+ ld l, e
inc hl
inc hl ; hl = address of item after first item to swap
.moveItemsUpLoop ; erase the first item slot and move up all the following item slots to fill the gap
- ld a,[hli]
- ld [de],a
+ ld a, [hli]
+ ld [de], a
inc de
inc a ; reached the $ff terminator?
- jr z,.afterMovingItemsUp
- ld a,[hli]
- ld [de],a
+ jr z, .afterMovingItemsUp
+ ld a, [hli]
+ ld [de], a
inc de
jr .moveItemsUpLoop
.afterMovingItemsUp
xor a
- ld [wListScrollOffset],a
- ld [wCurrentMenuItem],a
+ ld [wListScrollOffset], a
+ ld [wCurrentMenuItem], a
.done
xor a
- ld [wMenuItemToSwap],a ; 0 means no item is currently being swapped
+ ld [wMenuItemToSwap], a ; 0 means no item is currently being swapped
pop de
pop hl
jp DisplayListMenuIDLoop
diff --git a/engine/menu/text_ids2.asm b/engine/menu/text_box.asm
index b22c9507..a109bff2 100644
--- a/engine/menu/text_ids2.asm
+++ b/engine/menu/text_box.asm
@@ -1,28 +1,28 @@
; function to draw various text boxes
DisplayTextBoxID_:
- ld a,[wTextBoxID]
- cp a,TWO_OPTION_MENU
- jp z,DisplayTwoOptionMenu
- ld c,a
- ld hl,TextBoxFunctionTable
- ld de,3
+ ld a, [wTextBoxID]
+ cp TWO_OPTION_MENU
+ jp z, DisplayTwoOptionMenu
+ ld c, a
+ ld hl, TextBoxFunctionTable
+ ld de, 3
call SearchTextBoxTable
- jr c,.functionTableMatch
- ld hl,TextBoxCoordTable
- ld de,5
+ jr c, .functionTableMatch
+ ld hl, TextBoxCoordTable
+ ld de, 5
call SearchTextBoxTable
- jr c,.coordTableMatch
- ld hl,TextBoxTextAndCoordTable
- ld de,9
+ jr c, .coordTableMatch
+ ld hl, TextBoxTextAndCoordTable
+ ld de, 9
call SearchTextBoxTable
- jr c,.textAndCoordTableMatch
+ jr c, .textAndCoordTableMatch
.done
ret
.functionTableMatch
- ld a,[hli]
- ld h,[hl]
- ld l,a ; hl = address of function
- ld de,.done
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a ; hl = address of function
+ ld de, .done
push de
jp hl ; jump to the function
.coordTableMatch
@@ -37,14 +37,14 @@ DisplayTextBoxID_:
call TextBoxBorder
pop hl
call GetTextBoxIDText
- ld a,[wd730]
+ ld a, [wd730]
push af
- ld a,[wd730]
- set 6,a ; no pauses between printing each letter
- ld [wd730],a
+ ld a, [wd730]
+ set 6, a ; no pauses between printing each letter
+ ld [wd730], a
call PlaceString
pop af
- ld [wd730],a
+ ld [wd730], a
call UpdateSprites
ret
@@ -53,12 +53,12 @@ DisplayTextBoxID_:
SearchTextBoxTable:
dec de
.loop
- ld a,[hli]
- cp a,$ff
- jr z,.notFound
+ ld a, [hli]
+ cp $ff
+ jr z, .notFound
cp c
- jr z,.found
- add hl,de
+ jr z, .found
+ add hl, de
jr .loop
.found
scf
@@ -74,31 +74,31 @@ SearchTextBoxTable:
; d = row of upper left corner
; e = column of upper left corner
GetTextBoxIDCoords:
- ld a,[hli] ; column of upper left corner
- ld e,a
- ld a,[hli] ; row of upper left corner
- ld d,a
- ld a,[hli] ; column of lower right corner
+ ld a, [hli] ; column of upper left corner
+ ld e, a
+ ld a, [hli] ; row of upper left corner
+ ld d, a
+ ld a, [hli] ; column of lower right corner
sub e
dec a
- ld c,a ; c = width
- ld a,[hli] ; row of lower right corner
+ ld c, a ; c = width
+ ld a, [hli] ; row of lower right corner
sub d
dec a
- ld b,a ; b = height
+ ld b, a ; b = height
ret
; function to load a text address and text coordinates from the TextBoxTextAndCoordTable
GetTextBoxIDText:
- ld a,[hli]
- ld e,a
- ld a,[hli]
- ld d,a ; de = address of text
+ ld a, [hli]
+ ld e, a
+ ld a, [hli]
+ ld d, a ; de = address of text
push de ; save text address
- ld a,[hli]
- ld e,a ; column of upper left corner of text
- ld a,[hl]
- ld d,a ; row of upper left corner of text
+ ld a, [hli]
+ ld e, a ; column of upper left corner of text
+ ld a, [hl]
+ ld d, a ; row of upper left corner of text
call GetAddressOfScreenCoords
pop de ; restore text address
ret
@@ -112,17 +112,17 @@ GetTextBoxIDText:
GetAddressOfScreenCoords:
push bc
coord hl, 0, 0
- ld bc,20
+ ld bc, 20
.loop ; loop to add d rows to the base address
- ld a,d
+ ld a, d
and a
- jr z,.addedRows
- add hl,bc
+ jr z, .addedRows
+ add hl, bc
dec d
jr .loop
.addedRows
pop bc
- add hl,de
+ add hl, de
ret
; Format:
@@ -418,7 +418,7 @@ DisplayTwoOptionMenu:
xor a
ld [wTwoOptionMenuID], a
ld hl, wd730
- res 6, [hl]
+ res 6, [hl] ; turn on the printing delay
call HandleMenuInput
pop hl
bit 1, a ; A button pressed?
@@ -513,19 +513,26 @@ TwoOptionMenuStrings:
dw .NoYesMenu
.NoYesMenu
- db "NO",$4E,"YES@"
+ db "NO"
+ next "YES@"
.YesNoMenu
- db "YES",$4E,"NO@"
+ db "YES"
+ next "NO@"
.NorthWestMenu
- db "NORTH",$4E,"WEST@"
+ db "NORTH"
+ next "WEST@"
.SouthEastMenu
- db "SOUTH",$4E,"EAST@"
+ db "SOUTH"
+ next "EAST@"
.NorthEastMenu
- db "NORTH",$4E,"EAST@"
+ db "NORTH"
+ next "EAST@"
.TradeCancelMenu
- db "TRADE",$4E,"CANCEL@"
+ db "TRADE"
+ next "CANCEL@"
.HealCancelMenu
- db "HEAL",$4E,"CANCEL@"
+ db "HEAL"
+ next "CANCEL@"
DisplayFieldMoveMonMenu:
xor a
@@ -547,7 +554,7 @@ DisplayFieldMoveMonMenu:
call TextBoxBorder
call UpdateSprites
ld a, 12
- ld [hFieldMoveMonMenuTopMenuItemX], a ; fffb, not fff7
+ ld [hFieldMoveMonMenuTopMenuItemX], a
coord hl, 13, 12
ld de, PokemonMenuEntries
jp PlaceString
@@ -730,4 +737,3 @@ FieldMoveDisplayData:
db TELEPORT, $08, $0A
db SOFTBOILED, $09, $08
db $ff ; list terminator
-
diff --git a/engine/menu/text_ids1.asm b/engine/menu/text_ids1.asm
deleted file mode 100644
index e2fd76f4..00000000
--- a/engine/menu/text_ids1.asm
+++ /dev/null
@@ -1,163 +0,0 @@
-; function that performs initialization for DisplayTextID
-DisplayTextIDInit:
- xor a
- ld [wListMenuID],a
- ld a,[wAutoTextBoxDrawingControl]
- bit 0,a
- jr nz,.skipDrawingTextBoxBorder
- ld a,[hSpriteIndexOrTextID] ; text ID (or sprite ID)
- and a
- jr nz,.notStartMenu
-; if text ID is 0 (i.e. the start menu)
-; Note that the start menu text border is also drawn in the function directly
-; below this, so this seems unnecessary.
- CheckEvent EVENT_GOT_POKEDEX
-; start menu with pokedex
- coord hl, 10, 0
- lb bc, 14, 8
- jr nz,.drawTextBoxBorder
-; start menu without pokedex
- coord hl, 10, 0
- lb bc, 12, 8
- jr .drawTextBoxBorder
-; if text ID is not 0 (i.e. not the start menu) then do a standard dialogue text box
-.notStartMenu
- coord hl, 0, 12
- lb bc, 4, 18
-.drawTextBoxBorder
- call TextBoxBorder
-.skipDrawingTextBoxBorder
- ld hl,wFontLoaded
- set 0,[hl]
- ld hl,wFlags_0xcd60
- bit 4,[hl]
- res 4,[hl]
- jr nz,.skipMovingSprites
- call UpdateSprites
-.skipMovingSprites
-; loop to copy C1X9 (direction the sprite is facing) to C2X9 for each sprite
-; this is done because when you talk to an NPC, they turn to look your way
-; the original direction they were facing must be restored after the dialogue is over
- ld hl,wSpriteStateData1 + $19
- ld c,$0f
- ld de,$0010
-.spriteFacingDirectionCopyLoop
- ld a,[hl]
- inc h
- ld [hl],a
- dec h
- add hl,de
- dec c
- jr nz,.spriteFacingDirectionCopyLoop
-; loop to force all the sprites in the middle of animation to stand still
-; (so that they don't like they're frozen mid-step during the dialogue)
- ld hl,wSpriteStateData1 + 2
- ld de,$0010
- ld c,e
-.spriteStandStillLoop
- ld a,[hl]
- cp a,$ff ; is the sprite visible?
- jr z,.nextSprite
-; if it is visible
- and a,$fc
- ld [hl],a
-.nextSprite
- add hl,de
- dec c
- jr nz,.spriteStandStillLoop
- ld b,vBGMap1 / $100 ; window background address
- call CopyScreenTileBufferToVRAM ; transfer background in WRAM to VRAM
- xor a
- ld [hWY],a ; put the window on the screen
- call LoadFontTilePatterns
- ld a,$01
- ld [H_AUTOBGTRANSFERENABLED],a ; enable continuous WRAM to VRAM transfer each V-blank
- ret
-
-; function that displays the start menu
-DrawStartMenu:
- CheckEvent EVENT_GOT_POKEDEX
-; menu with pokedex
- coord hl, 10, 0
- lb bc, 14, 8
- jr nz,.drawTextBoxBorder
-; shorter menu if the player doesn't have the pokedex
- coord hl, 10, 0
- lb bc, 12, 8
-.drawTextBoxBorder
- call TextBoxBorder
- ld a,D_DOWN | D_UP | START | B_BUTTON | A_BUTTON
- ld [wMenuWatchedKeys],a
- ld a,$02
- ld [wTopMenuItemY],a ; Y position of first menu choice
- ld a,$0b
- ld [wTopMenuItemX],a ; X position of first menu choice
- ld a,[wBattleAndStartSavedMenuItem] ; remembered menu selection from last time
- ld [wCurrentMenuItem],a
- ld [wLastMenuItem],a
- xor a
- ld [wMenuWatchMovingOutOfBounds],a
- ld hl,wd730
- set 6,[hl] ; no pauses between printing each letter
- coord hl, 12, 2
- CheckEvent EVENT_GOT_POKEDEX
-; case for not having pokdex
- ld a,$06
- jr z,.storeMenuItemCount
-; case for having pokedex
- ld de,StartMenuPokedexText
- call PrintStartMenuItem
- ld a,$07
-.storeMenuItemCount
- ld [wMaxMenuItem],a ; number of menu items
- ld de,StartMenuPokemonText
- call PrintStartMenuItem
- ld de,StartMenuItemText
- call PrintStartMenuItem
- ld de,wPlayerName ; player's name
- call PrintStartMenuItem
- ld a,[wd72e]
- bit 6,a ; is the player using the link feature?
-; case for not using link feature
- ld de,StartMenuSaveText
- jr z,.printSaveOrResetText
-; case for using link feature
- ld de,StartMenuResetText
-.printSaveOrResetText
- call PrintStartMenuItem
- ld de,StartMenuOptionText
- call PrintStartMenuItem
- ld de,StartMenuExitText
- call PlaceString
- ld hl,wd730
- res 6,[hl] ; turn pauses between printing letters back on
- ret
-
-StartMenuPokedexText:
- db "POKéDEX@"
-
-StartMenuPokemonText:
- db "#MON@"
-
-StartMenuItemText:
- db "ITEM@"
-
-StartMenuSaveText:
- db "SAVE@"
-
-StartMenuResetText:
- db "RESET@"
-
-StartMenuExitText:
- db "EXIT@"
-
-StartMenuOptionText:
- db "OPTION@"
-
-PrintStartMenuItem:
- push hl
- call PlaceString
- pop hl
- ld de,SCREEN_WIDTH * 2
- add hl,de
- ret
diff --git a/engine/menu/vending_machine.asm b/engine/menu/vending_machine.asm
index d864141d..37d9b9e7 100755
--- a/engine/menu/vending_machine.asm
+++ b/engine/menu/vending_machine.asm
@@ -92,7 +92,8 @@ DrinkText:
DrinkPriceText:
db "¥200"
next "¥300"
- next "¥350",$4E,"@"
+ next "¥350"
+ next "@"
VendingMachineText4:
TX_FAR _VendingMachineText4
diff --git a/engine/move_mon.asm b/engine/move_mon.asm
deleted file mode 100644
index 3471875e..00000000
--- a/engine/move_mon.asm
+++ /dev/null
@@ -1,172 +0,0 @@
-_MoveMon:
- ld a, [wMoveMonType]
- and a
- jr z, .checkPartyMonSlots
- cp DAYCARE_TO_PARTY
- jr z, .checkPartyMonSlots
- cp PARTY_TO_DAYCARE
- ld hl, wDayCareMon
- jr z, .asm_f3fb
- ld hl, wNumInBox
- ld a, [hl]
- cp MONS_PER_BOX
- jr nz, .partyOrBoxNotFull
- jr .boxFull
-.checkPartyMonSlots
- ld hl, wPartyCount
- ld a, [hl]
- cp PARTY_LENGTH
- jr nz, .partyOrBoxNotFull
-.boxFull
- scf
- ret
-.partyOrBoxNotFull
- inc a
- ld [hl], a ; increment number of mons in party/box
- ld c, a
- ld b, 0
- add hl, bc
- ld a, [wMoveMonType]
- cp DAYCARE_TO_PARTY
- ld a, [wDayCareMon]
- jr z, .asm_f3dc
- ld a, [wcf91]
-.asm_f3dc
- ld [hli], a ; write new mon ID
- ld [hl], $ff ; write new sentinel
- ld a, [wMoveMonType]
- dec a
- ld hl, wPartyMons
- ld bc, wPartyMon2 - wPartyMon1 ; $2c
- ld a, [wPartyCount]
- jr nz, .skipToNewMonEntry
- ld hl, wBoxMons
- ld bc, wBoxMon2 - wBoxMon1 ; $21
- ld a, [wNumInBox]
-.skipToNewMonEntry
- dec a
- call AddNTimes
-.asm_f3fb
- push hl
- ld e, l
- ld d, h
- ld a, [wMoveMonType]
- and a
- ld hl, wBoxMons
- ld bc, wBoxMon2 - wBoxMon1 ; $21
- jr z, .asm_f417
- cp DAYCARE_TO_PARTY
- ld hl, wDayCareMon
- jr z, .asm_f41d
- ld hl, wPartyMons
- ld bc, wPartyMon2 - wPartyMon1 ; $2c
-.asm_f417
- ld a, [wWhichPokemon]
- call AddNTimes
-.asm_f41d
- push hl
- push de
- ld bc, wBoxMon2 - wBoxMon1
- call CopyData
- pop de
- pop hl
- ld a, [wMoveMonType]
- and a
- jr z, .asm_f43a
- cp DAYCARE_TO_PARTY
- jr z, .asm_f43a
- ld bc, wBoxMon2 - wBoxMon1
- add hl, bc
- ld a, [hl]
- inc de
- inc de
- inc de
- ld [de], a
-.asm_f43a
- ld a, [wMoveMonType]
- cp PARTY_TO_DAYCARE
- ld de, wDayCareMonOT
- jr z, .asm_f459
- dec a
- ld hl, wPartyMonOT
- ld a, [wPartyCount]
- jr nz, .asm_f453
- ld hl, wBoxMonOT
- ld a, [wNumInBox]
-.asm_f453
- dec a
- call SkipFixedLengthTextEntries
- ld d, h
- ld e, l
-.asm_f459
- ld hl, wBoxMonOT
- ld a, [wMoveMonType]
- and a
- jr z, .asm_f46c
- ld hl, wDayCareMonOT
- cp DAYCARE_TO_PARTY
- jr z, .asm_f472
- ld hl, wPartyMonOT
-.asm_f46c
- ld a, [wWhichPokemon]
- call SkipFixedLengthTextEntries
-.asm_f472
- ld bc, NAME_LENGTH
- call CopyData
- ld a, [wMoveMonType]
- cp PARTY_TO_DAYCARE
- ld de, wDayCareMonName
- jr z, .asm_f497
- dec a
- ld hl, wPartyMonNicks
- ld a, [wPartyCount]
- jr nz, .asm_f491
- ld hl, wBoxMonNicks
- ld a, [wNumInBox]
-.asm_f491
- dec a
- call SkipFixedLengthTextEntries
- ld d, h
- ld e, l
-.asm_f497
- ld hl, wBoxMonNicks
- ld a, [wMoveMonType]
- and a
- jr z, .asm_f4aa
- ld hl, wDayCareMonName
- cp DAYCARE_TO_PARTY
- jr z, .asm_f4b0
- ld hl, wPartyMonNicks
-.asm_f4aa
- ld a, [wWhichPokemon]
- call SkipFixedLengthTextEntries
-.asm_f4b0
- ld bc, NAME_LENGTH
- call CopyData
- pop hl
- ld a, [wMoveMonType]
- cp PARTY_TO_BOX
- jr z, .asm_f4ea
- cp PARTY_TO_DAYCARE
- jr z, .asm_f4ea
- push hl
- srl a
- add $2
- ld [wMonDataLocation], a
- call LoadMonData
- callba CalcLevelFromExperience
- ld a, d
- ld [wCurEnemyLVL], a
- pop hl
- ld bc, wBoxMon2 - wBoxMon1
- add hl, bc
- ld [hli], a
- ld d, h
- ld e, l
- ld bc, -18
- add hl, bc
- ld b, $1
- call CalcStats
-.asm_f4ea
- and a
- ret
diff --git a/engine/oak_speech.asm b/engine/oak_speech.asm
index 38fe66f9..8a537579 100755
--- a/engine/oak_speech.asm
+++ b/engine/oak_speech.asm
@@ -43,116 +43,116 @@ SetDefaultNames:
OakSpeech:
call StopAllMusic ; stop music
ld a, BANK(Music_Routes2)
- ld c,a
+ ld c, a
ld a, MUSIC_ROUTES2
call PlayMusic
call ClearScreen
call LoadTextBoxTilePatterns
call SetDefaultNames
predef InitPlayerData2
- ld hl,wNumBoxItems
- ld a,POTION
- ld [wcf91],a
- ld a,1
- ld [wItemQuantity],a
+ ld hl, wNumBoxItems
+ ld a, POTION
+ ld [wcf91], a
+ ld a, 1
+ ld [wItemQuantity], a
call AddItemToInventory ; give one potion
- ld a,[wDefaultMap]
- ld [wDestinationMap],a
+ ld a, [wDefaultMap]
+ ld [wDestinationMap], a
call SpecialWarpIn
xor a
- ld [hTilesetType],a
- ld a,[wd732]
- bit 1,a ; possibly a debug mode bit
- jp nz,.skipChoosingNames
- ld de,ProfOakPic
+ ld [hTilesetType], a
+ ld a, [wd732]
+ bit 1, a ; possibly a debug mode bit
+ jp nz, .skipChoosingNames
+ ld de, ProfOakPic
lb bc, Bank(ProfOakPic), $00
call IntroDisplayPicCenteredOrUpperRight
call FadeInIntroPic
- ld hl,OakSpeechText1
+ ld hl, OakSpeechText1
call PrintText
call GBFadeOutToWhite
call ClearScreen
- ld a,PIKACHU
- ld [wd0b5],a
- ld [wcf91],a
+ ld a, PIKACHU
+ ld [wd0b5], a
+ ld [wcf91], a
call GetMonHeader
coord hl, 6, 4
call LoadFlippedFrontSpriteByMonIndex
call MovePicLeft
- ld hl,OakSpeechText2
+ ld hl, OakSpeechText2
call PrintText
call GBFadeOutToWhite
call ClearScreen
- ld de,RedPicFront
+ ld de, RedPicFront
lb bc, Bank(RedPicFront), $00
call IntroDisplayPicCenteredOrUpperRight
call MovePicLeft
- ld hl,IntroducePlayerText
+ ld hl, IntroducePlayerText
call PrintText
call ChoosePlayerName
call GBFadeOutToWhite
call ClearScreen
- ld de,Rival1Pic
+ ld de, Rival1Pic
lb bc, Bank(Rival1Pic), $00
call IntroDisplayPicCenteredOrUpperRight
call FadeInIntroPic
- ld hl,IntroduceRivalText
+ ld hl, IntroduceRivalText
call PrintText
call ChooseRivalName
.skipChoosingNames
call GBFadeOutToWhite
call ClearScreen
- ld de,RedPicFront
+ ld de, RedPicFront
lb bc, Bank(RedPicFront), $00
call IntroDisplayPicCenteredOrUpperRight
call GBFadeInFromWhite
- ld a,[wd72d]
+ ld a, [wd72d]
and a
- jr nz,.next
- ld hl,OakSpeechText3
+ jr nz, .next
+ ld hl, OakSpeechText3
call PrintText
.next
- ld a,[H_LOADEDROMBANK]
+ ld a, [H_LOADEDROMBANK]
push af
- ld a,SFX_SHRINK
+ ld a, SFX_SHRINK
call PlaySound
pop af
call BankswitchCommon
- ld c,4
+ ld c, 4
call DelayFrames
- ld hl,vSprites
- ld de,RedSprite
+ ld hl, vSprites
+ ld de, RedSprite
ld b, BANK(RedSprite)
ld c, $0C
call CopyVideoData
- ld de,ShrinkPic1
+ ld de, ShrinkPic1
lb bc, BANK(ShrinkPic1), $00
call IntroDisplayPicCenteredOrUpperRight
- ld c,4
+ ld c, 4
call DelayFrames
- ld de,ShrinkPic2
+ ld de, ShrinkPic2
lb bc, BANK(ShrinkPic2), $00
call IntroDisplayPicCenteredOrUpperRight
call ResetPlayerSpriteData
- ld a,[H_LOADEDROMBANK]
+ ld a, [H_LOADEDROMBANK]
push af
ld a, BANK(Music_PalletTown)
- ld [wAudioROMBank],a
- ld [wAudioSavedROMBank],a
+ ld [wAudioROMBank], a
+ ld [wAudioSavedROMBank], a
ld a, 10
- ld [wAudioFadeOutControl],a
+ ld [wAudioFadeOutControl], a
call StopAllMusic ; stop music
pop af
call BankswitchCommon
- ld c,20
+ ld c, 20
call DelayFrames
coord hl, 6, 5
lb bc, 7, 7
call ClearScreenArea
call LoadTextBoxTilePatterns
- ld a,1
- ld [wUpdateSpritesEnabled],a
- ld c,50
+ ld a, 1
+ ld [wUpdateSpritesEnabled], a
+ ld c, 50
call DelayFrames
call GBFadeOutToWhite
call ClearScreen ; rip more tail-end optimizations
@@ -163,7 +163,7 @@ OakSpeechText1:
db "@"
OakSpeechText2:
TX_FAR _OakSpeechText2A
- db $14 ; play NIDORINA cry from TextCommandSounds
+ TX_CRY_NIDORINA
TX_FAR _OakSpeechText2B
db "@"
IntroducePlayerText:
@@ -177,16 +177,16 @@ OakSpeechText3:
db "@"
FadeInIntroPic:
- ld hl,IntroFadePalettes
- ld b,6
+ ld hl, IntroFadePalettes
+ ld b, 6
.next
- ld a,[hli]
- ld [rBGP],a
+ ld a, [hli]
+ ld [rBGP], a
call UpdateGBCPal_BGP
- ld c,10
+ ld c, 10
call DelayFrames
dec b
- jr nz,.next
+ jr nz, .next
ret
IntroFadePalettes:
@@ -198,20 +198,20 @@ IntroFadePalettes:
db %11100100
MovePicLeft:
- ld a,119
- ld [rWX],a
+ ld a, 119
+ ld [rWX], a
call DelayFrame
- ld a,%11100100
- ld [rBGP],a
+ ld a, %11100100
+ ld [rBGP], a
call UpdateGBCPal_BGP
.next
call DelayFrame
- ld a,[rWX]
+ ld a, [rWX]
sub 8
cp $FF
ret z
- ld [rWX],a
+ ld [rWX], a
jr .next
DisplayPicCenteredOrUpperRight:
@@ -221,24 +221,24 @@ IntroDisplayPicCenteredOrUpperRight:
; de = address of compressed pic
; c: 0 = centred, non-zero = upper-right
push bc
- ld a,b
+ ld a, b
call UncompressSpriteFromDE
ld a, $0
call SwitchSRAMBankAndLatchClockData
- ld hl,sSpriteBuffer1
- ld de,sSpriteBuffer0
- ld bc,$310
+ ld hl, sSpriteBuffer1
+ ld de, sSpriteBuffer0
+ ld bc, $310
call CopyData
call PrepareRTCDataAndDisableSRAM
- ld de,vFrontPic
+ ld de, vFrontPic
call InterlaceMergeSpriteBuffers
pop bc
- ld a,c
+ ld a, c
and a
coord hl, 15, 1
- jr nz,.next
+ jr nz, .next
coord hl, 6, 4
.next
xor a
- ld [hStartTileID],a
+ ld [hStartTileID], a
predef_jump CopyUncompressedPicToTilemap
diff --git a/engine/overworld/boulders.asm b/engine/overworld/boulders.asm
deleted file mode 100644
index 669b7b83..00000000
--- a/engine/overworld/boulders.asm
+++ /dev/null
@@ -1,94 +0,0 @@
-CheckForCollisionWhenPushingBoulder:
- call GetTileTwoStepsInFrontOfPlayer
- call IsTilePassable
- jr c, .done
- ld hl, TilePairCollisionsLand
- call CheckForTilePairCollisions2
- ld a, $ff
- jr c, .done ; if there is an elevation difference between the current tile and the one two steps ahead
- ld a, [wTileInFrontOfBoulderAndBoulderCollisionResult]
- cp $15 ; stairs tile
- ld a, $ff
- jr z, .done ; if the tile two steps ahead is stairs
- call CheckForBoulderCollisionWithSprites
-.done
- ld [wTileInFrontOfBoulderAndBoulderCollisionResult], a
- ret
-
-; sets a to $ff if there is a collision and $00 if there is no collision
-CheckForBoulderCollisionWithSprites:
- ld a, [wBoulderSpriteIndex]
- dec a
- swap a
- ld d, 0
- ld e, a
- ld hl, wSpriteStateData2 + $14
- add hl, de
- ld a, [hli] ; map Y position
- ld [$ffdc], a
- ld a, [hl] ; map X position
- ld [$ffdd], a
- ld a, [wNumSprites]
- ld c, a
- ld de, $f
- ld hl, wSpriteStateData2 + $14
- ld a, [$ffdb]
- and $3 ; facing up or down?
- jr z, .pushingHorizontallyLoop
-.pushingVerticallyLoop
- inc hl
- ld a, [$ffdd]
- cp [hl]
- jr nz, .nextSprite1 ; if X coordinates don't match
- dec hl
- ld a, [hli]
- ld b, a
- ld a, [$ffdb]
- rrca
- jr c, .pushingDown
-; pushing up
- ld a, [$ffdc]
- dec a
- jr .compareYCoords
-.pushingDown
- ld a, [$ffdc]
- inc a
-.compareYCoords
- cp b
- jr z, .failure
-.nextSprite1
- dec c
- jr z, .success
- add hl, de
- jr .pushingVerticallyLoop
-.pushingHorizontallyLoop
- ld a, [hli]
- ld b, a
- ld a, [$ffdc]
- cp b
- jr nz, .nextSprite2
- ld b, [hl]
- ld a, [$ffdb]
- bit 2, a
- jr nz, .pushingLeft
-; pushing right
- ld a, [$ffdd]
- inc a
- jr .compareXCoords
-.pushingLeft
- ld a, [$ffdd]
- dec a
-.compareXCoords
- cp b
- jr z, .failure
-.nextSprite2
- dec c
- jr z, .success
- add hl, de
- jr .pushingHorizontallyLoop
-.failure
- ld a, $ff
- ret
-.success
- xor a
- ret
diff --git a/engine/overworld/cable_club_npc.asm b/engine/overworld/cable_club_npc.asm
index e3ce8e8d..12ce64a4 100755
--- a/engine/overworld/cable_club_npc.asm
+++ b/engine/overworld/cable_club_npc.asm
@@ -180,7 +180,8 @@ CableClubNPCPleaseApplyHereHaveToSaveText:
CableClubNPCPleaseWaitText:
TX_FAR _CableClubNPCPleaseWaitText
- db $a, "@"
+ TX_DELAY
+ db "@"
CableClubNPCLinkClosedBecauseOfInactivityText:
TX_FAR _CableClubNPCLinkClosedBecauseOfInactivityText
diff --git a/engine/overworld/card_key.asm b/engine/overworld/card_key.asm
index 9026960c..a4452b4a 100755
--- a/engine/overworld/card_key.asm
+++ b/engine/overworld/card_key.asm
@@ -74,7 +74,7 @@ SilphCoMapList:
CardKeySuccessText:
TX_FAR _CardKeySuccessText1
- TX_SFX_ITEM
+ TX_SFX_ITEM_1
TX_FAR _CardKeySuccessText2
db "@"
diff --git a/engine/overworld/check_player_state.asm b/engine/overworld/check_player_state.asm
deleted file mode 100644
index 2fcb5b9d..00000000
--- a/engine/overworld/check_player_state.asm
+++ /dev/null
@@ -1,236 +0,0 @@
-; only used for setting bit 2 of wd736 upon entering a new map
-IsPlayerStandingOnWarp:
- ld a, [wNumberOfWarps]
- and a
- ret z
- ld c, a
- ld hl, wWarpEntries
-.loop
- ld a, [wYCoord]
- cp [hl]
- jr nz, .nextWarp1
- inc hl
- ld a, [wXCoord]
- cp [hl]
- jr nz, .nextWarp2
- inc hl
- ld a, [hli] ; target warp
- ld [wDestinationWarpID], a
- ld a, [hl] ; target map
- ld [$ff8b], a
- ld hl, wd736
- set 2, [hl] ; standing on warp flag
- ret
-.nextWarp1
- inc hl
-.nextWarp2
- inc hl
- inc hl
- inc hl
- dec c
- jr nz, .loop
- ret
-
-CheckForceBikeOrSurf:
- ld hl, wd732
- bit 5, [hl]
- ret nz
- ld hl, ForcedBikeOrSurfMaps
- ld a, [wYCoord]
- ld b, a
- ld a, [wXCoord]
- ld c, a
- ld a, [wCurMap]
- ld d, a
-.loop
- ld a, [hli]
- cp $ff
- ret z ;if we reach FF then it's not part of the list
- cp d ;compare to current map
- jr nz, .incorrectMap
- ld a, [hli]
- cp b ;compare y-coord
- jr nz, .incorrectY
- ld a, [hli]
- cp c ;compare x-coord
- jr nz, .loop ; incorrect x-coord, check next item
- ld a, [wCurMap]
- cp SEAFOAM_ISLANDS_4
- ld a, $2
- ld [wSeafoamIslands4CurScript], a
- jr z, .forceSurfing
- ld a, [wCurMap]
- cp SEAFOAM_ISLANDS_5
- ld a, $2
- ld [wSeafoamIslands5CurScript], a
- jr z, .forceSurfing
- ;force bike riding
- ld hl, wd732
- set 5, [hl]
- ld a, $1
- ld [wWalkBikeSurfState], a
- ld [wWalkBikeSurfStateCopy], a
- call ForceBikeOrSurf
- ret
-.incorrectMap
- inc hl
-.incorrectY
- inc hl
- jr .loop
-.forceSurfing
- ld a, $2
- ld [wWalkBikeSurfState], a
- ld [wWalkBikeSurfStateCopy], a
- call ForceBikeOrSurf
- ret
-
-INCLUDE "data/force_bike_surf.asm"
-
-IsPlayerFacingEdgeOfMap:
- push hl
- push de
- push bc
- ld a, [wSpritePlayerStateData1FacingDirection] ; player sprite's facing direction
- srl a
- ld c, a
- ld b, $0
- ld hl, .functionPointerTable
- add hl, bc
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld a, [wYCoord]
- ld b, a
- ld a, [wXCoord]
- ld c, a
- ld de, .returnaddress
- push de
- jp hl
-.returnaddress
- pop bc
- pop de
- pop hl
- ret
-
-.functionPointerTable
- dw .facingDown
- dw .facingUp
- dw .facingLeft
- dw .facingRight
-
-.facingDown
- ld a, [wCurMapHeight]
- add a
- dec a
- cp b
- jr z, .setCarry
- jr .resetCarry
-
-.facingUp
- ld a, b
- and a
- jr z, .setCarry
- jr .resetCarry
-
-.facingLeft
- ld a, c
- and a
- jr z, .setCarry
- jr .resetCarry
-
-.facingRight
- ld a, [wCurMapWidth]
- add a
- dec a
- cp c
- jr z, .setCarry
- jr .resetCarry
-.resetCarry
- and a
- ret
-.setCarry
- scf
- ret
-
-IsWarpTileInFrontOfPlayer:
- push hl
- push de
- push bc
- call _GetTileAndCoordsInFrontOfPlayer
- ld a, [wCurMap]
- cp SS_ANNE_5
- jr z, .ssAnne5
- ld a, [wSpritePlayerStateData1FacingDirection] ; player sprite's facing direction
- srl a
- ld c, a
- ld b, 0
- ld hl, .warpTileListPointers
- add hl, bc
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld a, [wTileInFrontOfPlayer]
- ld de, $1
- call IsInArray
-.done
- pop bc
- pop de
- pop hl
- ret
-
-.warpTileListPointers:
- dw .facingDownWarpTiles
- dw .facingUpWarpTiles
- dw .facingLeftWarpTiles
- dw .facingRightWarpTiles
-
-.facingDownWarpTiles
- db $01,$12,$17,$3D,$04,$18,$33,$FF
-
-.facingUpWarpTiles
- db $01,$5C,$FF
-
-.facingLeftWarpTiles
- db $1A,$4B,$FF
-
-.facingRightWarpTiles
- db $0F,$4E,$FF
-
-.ssAnne5
- ld a, [wTileInFrontOfPlayer]
- cp $15
- jr nz, .notSSAnne5Warp
- scf
- jr .done
-.notSSAnne5Warp
- and a
- jr .done
-
-IsPlayerStandingOnDoorTileOrWarpTile:
- push hl
- push de
- push bc
- callba IsPlayerStandingOnDoorTile
- jr c, .done
- ld a, [wCurMapTileset]
- add a
- ld c, a
- ld b, $0
- ld hl, WarpTileIDPointers
- add hl, bc
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld de, $1
- aCoord 8, 9
- call IsInArray
- jr nc, .done
- ld hl, wd736
- res 2, [hl]
-.done
- pop bc
- pop de
- pop hl
- ret
-
-INCLUDE "data/warp_tile_ids.asm"
diff --git a/engine/overworld/clear_loadmapdata_vars.asm b/engine/overworld/clear_variables.asm
index c5dc21fa..9a59cc7c 100644
--- a/engine/overworld/clear_loadmapdata_vars.asm
+++ b/engine/overworld/clear_variables.asm
@@ -1,11 +1,11 @@
-ClearVariablesAfterLoadingMapData:
- ld a, $90
+ClearVariablesOnEnterMap:
+ ld a, SCREEN_HEIGHT_PIXELS
ld [hWY], a
ld [rWY], a
xor a
ld [H_AUTOBGTRANSFERENABLED], a
ld [wStepCounter], a
- ld [wLoneAttackNo], a ; wGymLeaderNo
+ ld [wLoneAttackNo], a
ld [hJoyPressed], a
ld [hJoyReleased], a
ld [hJoyHeld], a
@@ -14,7 +14,7 @@ ClearVariablesAfterLoadingMapData:
ld hl, wCardKeyDoorY
ld [hli], a
ld [hl], a
- ld hl, wUnusedCD3D
- ld bc, wStandingOnWarpPadOrHole - wUnusedCD3D
+ ld hl, wWhichTrade
+ ld bc, wStandingOnWarpPadOrHole - wWhichTrade
call FillMemory
ret
diff --git a/engine/overworld/elevator.asm b/engine/overworld/elevator.asm
index cd7bf5ba..47ec78f9 100755
--- a/engine/overworld/elevator.asm
+++ b/engine/overworld/elevator.asm
@@ -31,7 +31,7 @@ ShakeElevator:
ld a, SFX_SAFARI_ZONE_PA
call PlayMusic
.musicLoop
- ld a, [wChannelSoundIDs + CH4]
+ ld a, [wChannelSoundIDs + Ch5]
cp SFX_SAFARI_ZONE_PA
jr z, .musicLoop
call UpdateSprites
diff --git a/engine/overworld/field_move_messages.asm b/engine/overworld/field_move_messages.asm
new file mode 100644
index 00000000..1d111917
--- /dev/null
+++ b/engine/overworld/field_move_messages.asm
@@ -0,0 +1,57 @@
+PrintStrengthTxt:
+ ld hl, wd728
+ set 0, [hl]
+ ld hl, UsedStrengthText
+ call PrintText
+ ld hl, CanMoveBouldersText
+ jp PrintText
+
+UsedStrengthText:
+ TX_FAR _UsedStrengthText
+ TX_ASM
+ ld a, [wcf91]
+ call PlayCry
+ call Delay3
+ jp TextScriptEnd
+
+CanMoveBouldersText:
+ TX_FAR _CanMoveBouldersText
+ db "@"
+
+IsSurfingAllowed:
+; Returns whether surfing is allowed in bit 1 of wd728.
+; Surfing isn't allowed on the Cycling Road or in the lowest level of the
+; Seafoam Islands before the current has been slowed with boulders.
+ ld hl, wd728
+ set 1, [hl]
+ ld a, [wd732]
+ bit 5, a
+ jr nz, .forcedToRideBike
+ ld a, [wCurMap]
+ cp SEAFOAM_ISLANDS_B4F
+ ret nz
+ CheckBothEventsSet EVENT_SEAFOAM4_BOULDER1_DOWN_HOLE, EVENT_SEAFOAM4_BOULDER2_DOWN_HOLE
+ ret z
+ ld hl, CoordsData_f5b64
+ call ArePlayerCoordsInArray
+ ret nc
+ ld hl, wd728
+ res 1, [hl]
+ ld hl, CurrentTooFastText
+ jp PrintText
+.forcedToRideBike
+ ld hl, wd728
+ res 1, [hl]
+ ld hl, CyclingIsFunText
+ jp PrintText
+
+CoordsData_f5b64:
+ db $0B,$07,$FF
+
+CurrentTooFastText:
+ TX_FAR _CurrentTooFastText
+ db "@"
+
+CyclingIsFunText:
+ TX_FAR _CyclingIsFunText
+ db "@"
diff --git a/engine/overworld/get_coords_tile_in_front_of_player.asm b/engine/overworld/get_coords_tile_in_front_of_player.asm
deleted file mode 100644
index 67f154bc..00000000
--- a/engine/overworld/get_coords_tile_in_front_of_player.asm
+++ /dev/null
@@ -1,87 +0,0 @@
-GetTileAndCoordsInFrontOfPlayer:
- call GetPredefRegisters
-
-_GetTileAndCoordsInFrontOfPlayer:
- ld a, [wYCoord]
- ld d, a
- ld a, [wXCoord]
- ld e, a
- ld a, [wSpritePlayerStateData1FacingDirection] ; player's sprite facing direction
- and a ; cp SPRITE_FACING_DOWN
- jr nz, .notFacingDown
-; facing down
- aCoord 8, 11
- inc d
- jr .storeTile
-.notFacingDown
- cp SPRITE_FACING_UP
- jr nz, .notFacingUp
-; facing up
- aCoord 8, 7
- dec d
- jr .storeTile
-.notFacingUp
- cp SPRITE_FACING_LEFT
- jr nz, .notFacingLeft
-; facing left
- aCoord 6, 9
- dec e
- jr .storeTile
-.notFacingLeft
- cp SPRITE_FACING_RIGHT
- jr nz, .storeTile
-; facing right
- aCoord 10, 9
- inc e
-.storeTile
- ld c, a
- ld [wTileInFrontOfPlayer], a
- ret
-
-GetTileTwoStepsInFrontOfPlayer:
- xor a
- ld [$ffdb], a
- ld hl, wYCoord
- ld a, [hli]
- ld d, a
- ld e, [hl]
- ld a, [wSpritePlayerStateData1FacingDirection] ; player's sprite facing direction
- and a ; cp SPRITE_FACING_DOWN
- jr nz, .notFacingDown
-; facing down
- ld hl, $ffdb
- set 0, [hl]
- aCoord 8, 13
- inc d
- jr .storeTile
-.notFacingDown
- cp SPRITE_FACING_UP
- jr nz, .notFacingUp
-; facing up
- ld hl, $ffdb
- set 1, [hl]
- aCoord 8, 5
- dec d
- jr .storeTile
-.notFacingUp
- cp SPRITE_FACING_LEFT
- jr nz, .notFacingLeft
-; facing left
- ld hl, $ffdb
- set 2, [hl]
- aCoord 4, 9
- dec e
- jr .storeTile
-.notFacingLeft
- cp SPRITE_FACING_RIGHT
- jr nz, .storeTile
-; facing right
- ld hl, $ffdb
- set 3, [hl]
- aCoord 12, 9
- inc e
-.storeTile
- ld c, a
- ld [wTileInFrontOfBoulderAndBoulderCollisionResult], a
- ld [wTileInFrontOfPlayer], a
- ret
diff --git a/engine/overworld/hidden_items.asm b/engine/overworld/hidden_items.asm
index 15082847..b64411c7 100755
--- a/engine/overworld/hidden_items.asm
+++ b/engine/overworld/hidden_items.asm
@@ -133,11 +133,12 @@ INCLUDE "data/hidden_coins.asm"
FoundHiddenCoinsText:
TX_FAR _FoundHiddenCoinsText
- db $10,"@"
+ TX_SFX_ITEM_2
+ db "@"
DroppedHiddenCoinsText:
TX_FAR _FoundHiddenCoins2Text
- db $10
+ TX_SFX_ITEM_2
TX_FAR _DroppedHiddenCoinsText
db "@"
diff --git a/engine/overworld/item.asm b/engine/overworld/item.asm
index 63eecef9..9f19100a 100644
--- a/engine/overworld/item.asm
+++ b/engine/overworld/item.asm
@@ -46,7 +46,7 @@ PickUpItem:
FoundItemText:
TX_FAR _FoundItemText
- db $0B
+ TX_SFX_ITEM_1
db "@"
NoMoreRoomForItemText:
diff --git a/engine/overworld/load_wild_data.asm b/engine/overworld/load_wild_data.asm
deleted file mode 100644
index 6444ab7e..00000000
--- a/engine/overworld/load_wild_data.asm
+++ /dev/null
@@ -1,33 +0,0 @@
-LoadWildData:
- ld hl,WildDataPointers
- ld a,[wCurMap]
-
- ; get wild data for current map
- ld c,a
- ld b,0
- add hl,bc
- add hl,bc
- ld a,[hli]
- ld h,[hl]
- ld l,a ; hl now points to wild data for current map
- ld a,[hli]
- ld [wGrassRate],a
- and a
- jr z,.NoGrassData ; if no grass data, skip to surfing data
- push hl
- ld de,wGrassMons ; otherwise, load grass data
- ld bc,$0014
- call CopyData
- pop hl
- ld bc,$0014
- add hl,bc
-.NoGrassData
- ld a,[hli]
- ld [wWaterRate],a
- and a
- ret z ; if no water data, we're done
- ld de,wWaterMons ; otherwise, load surfing data
- ld bc,$0014
- jp CopyData
-
-INCLUDE "data/wild_mons.asm"
diff --git a/engine/overworld/map_sprites.asm b/engine/overworld/map_sprites.asm
index 1a877b4a..3e2c3912 100755
--- a/engine/overworld/map_sprites.asm
+++ b/engine/overworld/map_sprites.asm
@@ -7,7 +7,7 @@
; $C1X* and $C2X* are used to denote wSpriteStateData1-wSpriteStateData1 + $ff and wSpriteStateData2 + $00-wSpriteStateData2 + $ff sprite slot
; fields, respectively, within loops. The X is the loop index.
; If there is an inner loop, Y is the inner loop index, i.e. $C1Y* and $C2Y*
-; denote fields of the sprite slots interated over in the inner loop.
+; denote fields of the sprite slots iterated over in the inner loop.
_InitMapSprites:
call InitOutsideMapSprites
ret c ; return if the map is an outside map (already handled by above call)
@@ -308,10 +308,10 @@ GetSplitMapSpriteSetID:
ret c
; Chooses the correct sprite set ID depending on the player's position within
; the map for maps with two sprite sets.
- cp a, $f8
+ cp $f8
jr z, .route20
ld hl, SplitMapSpriteSets
- and a, $0f
+ and $0f
dec a
add a
add a
@@ -321,7 +321,7 @@ GetSplitMapSpriteSetID:
inc h
.noCarry
ld a, [hli] ; determines whether the map is split East/West or North/South
- cp a, $01
+ cp $01
ld a, [hli] ; position of dividing line
ld b, a
jr z, .eastWestDivide
@@ -344,15 +344,15 @@ GetSplitMapSpriteSetID:
.route20
ld hl, wXCoord
ld a, [hl]
- cp a, $2b
+ cp $2b
ld a, $01
ret c
ld a, [hl]
- cp a, $3e
+ cp $3e
ld a, $0a
ret nc
ld a, [hl]
- cp a, $37
+ cp $37
ld b, $08
jr nc, .next
ld b, $0d
diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm
index 6fb388fd..f2334479 100644
--- a/engine/overworld/movement.asm
+++ b/engine/overworld/movement.asm
@@ -1,3 +1,5 @@
+MAP_TILESET_SIZE EQU $60
+
UpdatePlayerSprite:
ld a, [wSpriteStateData2]
and a
@@ -13,7 +15,7 @@ UpdatePlayerSprite:
.checkIfTextBoxInFrontOfSprite
aCoord 8, 9
ld [hTilePlayerStandingOn], a
- cp $60
+ cp MAP_TILESET_SIZE
jr c, .lowerLeftTileIsMapTile
.disableSprite
ld a, $ff
@@ -112,7 +114,7 @@ UpdateNPCSprite:
and a
jp z, InitializeSpriteStatus
call CheckSpriteAvailability
- ret c ; if sprite is invisible, on tile >=$60, in grass or player is currently walking
+ ret c ; if sprite is invisible, on tile >=MAP_TILESET_SIZE, in grass or player is currently walking
ld h, wSpriteStateData1 / $100
ld a, [H_CURRENTSPRITEOFFSET]
ld l, a
@@ -290,9 +292,9 @@ UpdateSpriteInWalkingAnimation:
ld a, [H_CURRENTSPRITEOFFSET]
ld l, a
inc h
- ld a, [hl] ; c2x0 (walk animantion counter)
+ ld a, [hl] ; c2x0 (walk animation counter)
dec a
- ld [hl], a ; update walk animantion counter
+ ld [hl], a ; update walk animation counter
ret nz
ld a, $6 ; walking finished, update state
add l
@@ -406,7 +408,7 @@ InitializeSpriteStatus:
call InitializeSpriteScreenPosition ; could have done fallthrough here
ret
-; calculates the spprite's scrren position form its map position and the player position
+; calculates the sprite's screen position form its map position and the player position
InitializeSpriteScreenPosition:
ld h, wSpriteStateData2 / $100
ld a, [H_CURRENTSPRITEOFFSET]
@@ -480,21 +482,21 @@ CheckSpriteAvailability:
; make the sprite invisible if a text box is in front of it
; $5F is the maximum number for map tiles
call GetTileSpriteStandsOn
- ld d, $60
+ ld d, MAP_TILESET_SIZE
ld a, [hli]
cp d
- jr nc, .spriteInvisible ; standing on tile with ID >=$60 (bottom left tile)
+ jr nc, .spriteInvisible ; standing on tile with ID >=MAP_TILESET_SIZE (bottom left tile)
ld a, [hld]
cp d
- jr nc, .spriteInvisible ; standing on tile with ID >=$60 (bottom right tile)
+ jr nc, .spriteInvisible ; standing on tile with ID >=MAP_TILESET_SIZE (bottom right tile)
ld bc, -20
add hl, bc ; go back one row of tiles
ld a, [hli]
cp d
- jr nc, .spriteInvisible ; standing on tile with ID >=$60 (top left tile)
+ jr nc, .spriteInvisible ; standing on tile with ID >=MAP_TILESET_SIZE (top left tile)
ld a, [hl]
cp d
- jr c, .spriteVisible ; standing on tile with ID >=$60 (top right tile)
+ jr c, .spriteVisible ; standing on tile with ID >=MAP_TILESET_SIZE (top right tile)
.spriteInvisible
ld h, wSpriteStateData1 / $100
ld a, [H_CURRENTSPRITEOFFSET]
@@ -655,7 +657,7 @@ CanWalkOntoTile:
scf ; set carry (marking failure to walk)
ret
-; calculates the tile pointer pointing to the tile the current sprite stancs on
+; calculates the tile pointer pointing to the tile the current sprite stands on
; this is always the lower left tile of the 2x2 tile blocks all sprites are snapped to
; hl: output pointer
GetTileSpriteStandsOn:
diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm
index 333779fa..670cb121 100755
--- a/engine/overworld/npc_movement.asm
+++ b/engine/overworld/npc_movement.asm
@@ -153,7 +153,7 @@ PalletMovementScript_Done:
ld a, [wSimulatedJoypadStatesIndex]
and a
ret nz
- ld a, $0
+ ld a, HS_PALLET_TOWN_OAK
ld [wMissableObjectIndex], a
predef HideObject
ld hl, wd730
diff --git a/engine/overworld/npc_movement_2.asm b/engine/overworld/npc_movement_2.asm
index 06ee9319..93d1afce 100755
--- a/engine/overworld/npc_movement_2.asm
+++ b/engine/overworld/npc_movement_2.asm
@@ -1,6 +1,6 @@
FreezeEnemyTrainerSprite:
ld a, [wCurMap]
- cp POKEMONTOWER_7
+ cp POKEMON_TOWER_7F
ret z ; the Rockets on Pokemon Tower 7F leave after battling, so don't freeze them
ld hl, RivalIDs
ld a, [wEngagedTrainerClass]
diff --git a/engine/overworld/oaks_aide.asm b/engine/overworld/oaks_aide.asm
index 54ba6b7a..f5068fda 100755
--- a/engine/overworld/oaks_aide.asm
+++ b/engine/overworld/oaks_aide.asm
@@ -63,7 +63,7 @@ OaksAideHereYouGoText:
OaksAideGotItemText:
TX_FAR _OaksAideGotItemText
- db $0b
+ TX_SFX_ITEM_1
db "@"
OaksAideNoRoomText:
diff --git a/engine/overworld/player_state.asm b/engine/overworld/player_state.asm
new file mode 100644
index 00000000..8cbacc61
--- /dev/null
+++ b/engine/overworld/player_state.asm
@@ -0,0 +1,456 @@
+; only used for setting bit 2 of wd736 upon entering a new map
+IsPlayerStandingOnWarp:
+ ld a, [wNumberOfWarps]
+ and a
+ ret z
+ ld c, a
+ ld hl, wWarpEntries
+.loop
+ ld a, [wYCoord]
+ cp [hl]
+ jr nz, .nextWarp1
+ inc hl
+ ld a, [wXCoord]
+ cp [hl]
+ jr nz, .nextWarp2
+ inc hl
+ ld a, [hli] ; target warp
+ ld [wDestinationWarpID], a
+ ld a, [hl] ; target map
+ ld [hWarpDestinationMap], a
+ ld hl, wd736
+ set 2, [hl] ; standing on warp flag
+ ret
+.nextWarp1
+ inc hl
+.nextWarp2
+ inc hl
+ inc hl
+ inc hl
+ dec c
+ jr nz, .loop
+ ret
+
+CheckForceBikeOrSurf:
+ ld hl, wd732
+ bit 5, [hl]
+ ret nz
+ ld hl, ForcedBikeOrSurfMaps
+ ld a, [wYCoord]
+ ld b, a
+ ld a, [wXCoord]
+ ld c, a
+ ld a, [wCurMap]
+ ld d, a
+.loop
+ ld a, [hli]
+ cp $ff
+ ret z ;if we reach FF then it's not part of the list
+ cp d ;compare to current map
+ jr nz, .incorrectMap
+ ld a, [hli]
+ cp b ;compare y-coord
+ jr nz, .incorrectY
+ ld a, [hli]
+ cp c ;compare x-coord
+ jr nz, .loop ; incorrect x-coord, check next item
+ ld a, [wCurMap]
+ cp SEAFOAM_ISLANDS_B3F
+ ld a, $2
+ ld [wSeafoamIslandsB3FCurScript], a
+ jr z, .forceSurfing
+ ld a, [wCurMap]
+ cp SEAFOAM_ISLANDS_B4F
+ ld a, $2
+ ld [wSeafoamIslandsB4FCurScript], a
+ jr z, .forceSurfing
+ ;force bike riding
+ ld hl, wd732
+ set 5, [hl]
+ ld a, $1
+ ld [wWalkBikeSurfState], a
+ ld [wWalkBikeSurfStateCopy], a
+ call ForceBikeOrSurf
+ ret
+.incorrectMap
+ inc hl
+.incorrectY
+ inc hl
+ jr .loop
+.forceSurfing
+ ld a, $2
+ ld [wWalkBikeSurfState], a
+ ld [wWalkBikeSurfStateCopy], a
+ call ForceBikeOrSurf
+ ret
+
+INCLUDE "data/force_bike_surf.asm"
+
+IsPlayerFacingEdgeOfMap:
+ push hl
+ push de
+ push bc
+ ld a, [wSpriteStateData1 + 9] ; player sprite's facing direction
+ srl a
+ ld c, a
+ ld b, $0
+ ld hl, .functionPointerTable
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, [wYCoord]
+ ld b, a
+ ld a, [wXCoord]
+ ld c, a
+ ld de, .returnaddress
+ push de
+ jp hl
+.returnaddress
+ pop bc
+ pop de
+ pop hl
+ ret
+
+.functionPointerTable
+ dw .facingDown
+ dw .facingUp
+ dw .facingLeft
+ dw .facingRight
+
+.facingDown
+ ld a, [wCurMapHeight]
+ add a
+ dec a
+ cp b
+ jr z, .setCarry
+ jr .resetCarry
+
+.facingUp
+ ld a, b
+ and a
+ jr z, .setCarry
+ jr .resetCarry
+
+.facingLeft
+ ld a, c
+ and a
+ jr z, .setCarry
+ jr .resetCarry
+
+.facingRight
+ ld a, [wCurMapWidth]
+ add a
+ dec a
+ cp c
+ jr z, .setCarry
+ jr .resetCarry
+.resetCarry
+ and a
+ ret
+.setCarry
+ scf
+ ret
+
+IsWarpTileInFrontOfPlayer:
+ push hl
+ push de
+ push bc
+ call _GetTileAndCoordsInFrontOfPlayer
+ ld a, [wCurMap]
+ cp SS_ANNE_BOW
+ jr z, .ssAnne5
+ ld a, [wSpriteStateData1 + 9] ; player sprite's facing direction
+ srl a
+ ld c, a
+ ld b, 0
+ ld hl, .warpTileListPointers
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, [wTileInFrontOfPlayer]
+ ld de, $1
+ call IsInArray
+.done
+ pop bc
+ pop de
+ pop hl
+ ret
+
+.warpTileListPointers:
+ dw .facingDownWarpTiles
+ dw .facingUpWarpTiles
+ dw .facingLeftWarpTiles
+ dw .facingRightWarpTiles
+
+.facingDownWarpTiles
+ db $01,$12,$17,$3D,$04,$18,$33,$FF
+
+.facingUpWarpTiles
+ db $01,$5C,$FF
+
+.facingLeftWarpTiles
+ db $1A,$4B,$FF
+
+.facingRightWarpTiles
+ db $0F,$4E,$FF
+
+.ssAnne5
+ ld a, [wTileInFrontOfPlayer]
+ cp $15
+ jr nz, .notSSAnne5Warp
+ scf
+ jr .done
+.notSSAnne5Warp
+ and a
+ jr .done
+
+IsPlayerStandingOnDoorTileOrWarpTile:
+ push hl
+ push de
+ push bc
+ callba IsPlayerStandingOnDoorTile
+ jr c, .done
+ ld a, [wCurMapTileset]
+ add a
+ ld c, a
+ ld b, $0
+ ld hl, WarpTileIDPointers
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld de, $1
+ aCoord 8, 9
+ call IsInArray
+ jr nc, .done
+ ld hl, wd736
+ res 2, [hl]
+.done
+ pop bc
+ pop de
+ pop hl
+ ret
+
+INCLUDE "data/warp_tile_ids.asm"
+
+PrintSafariZoneSteps:
+ ld a, [wCurMap]
+ cp SAFARI_ZONE_EAST
+ ret c
+ cp CERULEAN_CAVE_2F
+ ret nc
+ coord hl, 0, 0
+ lb bc, 3, 7
+ call TextBoxBorder
+ coord hl, 1, 1
+ ld de, wSafariSteps
+ lb bc, 2, 3
+ call PrintNumber
+ coord hl, 4, 1
+ ld de, SafariSteps
+ call PlaceString
+ coord hl, 1, 3
+ ld de, SafariBallText
+ call PlaceString
+ ld a, [wNumSafariBalls]
+ cp 10
+ jr nc, .numSafariBallsTwoDigits
+ coord hl, 5, 3
+ ld a, " "
+ ld [hl], a
+.numSafariBallsTwoDigits
+ coord hl, 6, 3
+ ld de, wNumSafariBalls
+ lb bc, 1, 2
+ jp PrintNumber
+
+SafariSteps:
+ db "/500@"
+
+SafariBallText:
+ db "BALL×× @"
+
+GetTileAndCoordsInFrontOfPlayer:
+ call GetPredefRegisters
+
+_GetTileAndCoordsInFrontOfPlayer:
+ ld a, [wYCoord]
+ ld d, a
+ ld a, [wXCoord]
+ ld e, a
+ ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
+ and a ; cp SPRITE_FACING_DOWN
+ jr nz, .notFacingDown
+; facing down
+ aCoord 8, 11
+ inc d
+ jr .storeTile
+.notFacingDown
+ cp SPRITE_FACING_UP
+ jr nz, .notFacingUp
+; facing up
+ aCoord 8, 7
+ dec d
+ jr .storeTile
+.notFacingUp
+ cp SPRITE_FACING_LEFT
+ jr nz, .notFacingLeft
+; facing left
+ aCoord 6, 9
+ dec e
+ jr .storeTile
+.notFacingLeft
+ cp SPRITE_FACING_RIGHT
+ jr nz, .storeTile
+; facing right
+ aCoord 10, 9
+ inc e
+.storeTile
+ ld c, a
+ ld [wTileInFrontOfPlayer], a
+ ret
+
+GetTileTwoStepsInFrontOfPlayer:
+ xor a
+ ld [$ffdb], a
+ ld hl, wYCoord
+ ld a, [hli]
+ ld d, a
+ ld e, [hl]
+ ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
+ and a ; cp SPRITE_FACING_DOWN
+ jr nz, .notFacingDown
+; facing down
+ ld hl, $ffdb
+ set 0, [hl]
+ aCoord 8, 13
+ inc d
+ jr .storeTile
+.notFacingDown
+ cp SPRITE_FACING_UP
+ jr nz, .notFacingUp
+; facing up
+ ld hl, $ffdb
+ set 1, [hl]
+ aCoord 8, 5
+ dec d
+ jr .storeTile
+.notFacingUp
+ cp SPRITE_FACING_LEFT
+ jr nz, .notFacingLeft
+; facing left
+ ld hl, $ffdb
+ set 2, [hl]
+ aCoord 4, 9
+ dec e
+ jr .storeTile
+.notFacingLeft
+ cp SPRITE_FACING_RIGHT
+ jr nz, .storeTile
+; facing right
+ ld hl, $ffdb
+ set 3, [hl]
+ aCoord 12, 9
+ inc e
+.storeTile
+ ld c, a
+ ld [wTileInFrontOfBoulderAndBoulderCollisionResult], a
+ ld [wTileInFrontOfPlayer], a
+ ret
+
+CheckForCollisionWhenPushingBoulder:
+ call GetTileTwoStepsInFrontOfPlayer
+ call IsTilePassable
+ jr c, .done
+ ld hl, TilePairCollisionsLand
+ call CheckForTilePairCollisions2
+ ld a, $ff
+ jr c, .done ; if there is an elevation difference between the current tile and the one two steps ahead
+ ld a, [wTileInFrontOfBoulderAndBoulderCollisionResult]
+ cp $15 ; stairs tile
+ ld a, $ff
+ jr z, .done ; if the tile two steps ahead is stairs
+ call CheckForBoulderCollisionWithSprites
+.done
+ ld [wTileInFrontOfBoulderAndBoulderCollisionResult], a
+ ret
+
+; sets a to $ff if there is a collision and $00 if there is no collision
+CheckForBoulderCollisionWithSprites:
+ ld a, [wBoulderSpriteIndex]
+ dec a
+ swap a
+ ld d, 0
+ ld e, a
+ ld hl, wSpriteStateData2 + $14
+ add hl, de
+ ld a, [hli] ; map Y position
+ ld [$ffdc], a
+ ld a, [hl] ; map X position
+ ld [$ffdd], a
+ ld a, [wNumSprites]
+ ld c, a
+ ld de, $f
+ ld hl, wSpriteStateData2 + $14
+ ld a, [$ffdb]
+ and $3 ; facing up or down?
+ jr z, .pushingHorizontallyLoop
+.pushingVerticallyLoop
+ inc hl
+ ld a, [$ffdd]
+ cp [hl]
+ jr nz, .nextSprite1 ; if X coordinates don't match
+ dec hl
+ ld a, [hli]
+ ld b, a
+ ld a, [$ffdb]
+ rrca
+ jr c, .pushingDown
+; pushing up
+ ld a, [$ffdc]
+ dec a
+ jr .compareYCoords
+.pushingDown
+ ld a, [$ffdc]
+ inc a
+.compareYCoords
+ cp b
+ jr z, .failure
+.nextSprite1
+ dec c
+ jr z, .success
+ add hl, de
+ jr .pushingVerticallyLoop
+.pushingHorizontallyLoop
+ ld a, [hli]
+ ld b, a
+ ld a, [$ffdc]
+ cp b
+ jr nz, .nextSprite2
+ ld b, [hl]
+ ld a, [$ffdb]
+ bit 2, a
+ jr nz, .pushingLeft
+; pushing right
+ ld a, [$ffdd]
+ inc a
+ jr .compareXCoords
+.pushingLeft
+ ld a, [$ffdd]
+ dec a
+.compareXCoords
+ cp b
+ jr z, .failure
+.nextSprite2
+ dec c
+ jr z, .success
+ add hl, de
+ jr .pushingHorizontallyLoop
+.failure
+ ld a, $ff
+ ret
+.success
+ xor a
+ ret
diff --git a/engine/overworld/step_functions.asm b/engine/overworld/poison.asm
index 84b09291..03fb8a65 100644
--- a/engine/overworld/step_functions.asm
+++ b/engine/overworld/poison.asm
@@ -58,7 +58,7 @@ ApplyOutOfBattlePoisonDamage:
xor a
ld [wJoyIgnore], a
call EnableAutoTextBoxDrawing
- ld a, $d0
+ ld a, TEXT_MON_FAINTED
ld [hSpriteIndexOrTextID], a
call DisplayTextID
callab IsThisPartymonStarterPikachu_Party
@@ -102,7 +102,7 @@ ApplyOutOfBattlePoisonDamage:
and a ; are any party members poisoned?
jr z, .skipPoisonEffectAndSound
ld b, $2
- predef InvertBGPal_4Frames ; change BG white to dark grey for 4 frames
+ predef ChangeBGPalColor0_4Frames ; change BG white to dark grey for 4 frames
ld a, SFX_POISONED
call PlaySound
.skipPoisonEffectAndSound
@@ -111,7 +111,7 @@ ApplyOutOfBattlePoisonDamage:
and a
jr nz, .noBlackOut
call EnableAutoTextBoxDrawing
- ld a, $d1
+ ld a, TEXT_BLACKED_OUT
ld [hSpriteIndexOrTextID], a
call DisplayTextID
ld hl, wd72e
diff --git a/engine/overworld/pokecenter.asm b/engine/overworld/pokecenter.asm
index 1801d9e9..cf0159f9 100755
--- a/engine/overworld/pokecenter.asm
+++ b/engine/overworld/pokecenter.asm
@@ -127,7 +127,7 @@ PokemonCenterWelcomeText:
db "@"
ShallWeHealYourPokemonText:
- db $a
+ TX_DELAY
TX_FAR _ShallWeHealYourPokemonText
db "@"
@@ -140,7 +140,7 @@ PokemonFightingFitText:
db "@"
PokemonCenterFarewellText:
- db $a
+ TX_DELAY
TX_FAR _PokemonCenterFarewellText
db "@"
diff --git a/engine/overworld/pokemart.asm b/engine/overworld/pokemart.asm
index 823939b1..dc5b29b5 100755
--- a/engine/overworld/pokemart.asm
+++ b/engine/overworld/pokemart.asm
@@ -1,230 +1,230 @@
DisplayPokemartDialogue_:
- ld a,[wListScrollOffset]
- ld [wSavedListScrollOffset],a
+ ld a, [wListScrollOffset]
+ ld [wSavedListScrollOffset], a
call UpdateSprites
xor a
- ld [wBoughtOrSoldItemInMart],a
+ ld [wBoughtOrSoldItemInMart], a
.loop
xor a
- ld [wListScrollOffset],a
- ld [wCurrentMenuItem],a
- ld [wPlayerMonNumber],a
+ ld [wListScrollOffset], a
+ ld [wCurrentMenuItem], a
+ ld [wPlayerMonNumber], a
inc a
- ld [wPrintItemPrices],a
- ld a,MONEY_BOX
- ld [wTextBoxID],a
+ ld [wPrintItemPrices], a
+ ld a, MONEY_BOX
+ ld [wTextBoxID], a
call DisplayTextBoxID
- ld a,BUY_SELL_QUIT_MENU
- ld [wTextBoxID],a
+ ld a, BUY_SELL_QUIT_MENU
+ ld [wTextBoxID], a
call DisplayTextBoxID
; This code is useless. It copies the address of the pokemart's inventory to hl,
; but the address is never used.
- ld hl,wItemListPointer
- ld a,[hli]
- ld l,[hl]
- ld h,a
+ ld hl, wItemListPointer
+ ld a, [hli]
+ ld l, [hl]
+ ld h, a
- ld a,[wMenuExitMethod]
- cp a,CANCELLED_MENU
- jp z,.done
- ld a,[wChosenMenuItem]
+ ld a, [wMenuExitMethod]
+ cp CANCELLED_MENU
+ jp z, .done
+ ld a, [wChosenMenuItem]
and a ; buying?
- jp z,.buyMenu
+ jp z, .buyMenu
dec a ; selling?
- jp z,.sellMenu
+ jp z, .sellMenu
dec a ; quitting?
- jp z,.done
+ jp z, .done
.sellMenu
; the same variables are set again below, so this code has no effect
xor a
- ld [wPrintItemPrices],a
- ld a,INIT_BAG_ITEM_LIST
- ld [wInitListType],a
+ ld [wPrintItemPrices], a
+ ld a, INIT_BAG_ITEM_LIST
+ ld [wInitListType], a
callab InitList
- ld a,[wNumBagItems]
+ ld a, [wNumBagItems]
and a
- jp z,.bagEmpty
- ld hl,PokemonSellingGreetingText
+ jp z, .bagEmpty
+ ld hl, PokemonSellingGreetingText
call PrintText
call SaveScreenTilesToBuffer1 ; save screen
.sellMenuLoop
call LoadScreenTilesFromBuffer1 ; restore saved screen
- ld a,MONEY_BOX
- ld [wTextBoxID],a
+ ld a, MONEY_BOX
+ ld [wTextBoxID], a
call DisplayTextBoxID ; draw money text box
- ld hl,wNumBagItems
- ld a,l
- ld [wListPointer],a
- ld a,h
- ld [wListPointer + 1],a
+ ld hl, wNumBagItems
+ ld a, l
+ ld [wListPointer], a
+ ld a, h
+ ld [wListPointer + 1], a
xor a
- ld [wPrintItemPrices],a
- ld [wCurrentMenuItem],a
- ld a,ITEMLISTMENU
- ld [wListMenuID],a
+ ld [wPrintItemPrices], a
+ ld [wCurrentMenuItem], a
+ ld a, ITEMLISTMENU
+ ld [wListMenuID], a
call DisplayListMenuID
- jp c,.returnToMainPokemartMenu ; if the player closed the menu
+ jp c, .returnToMainPokemartMenu ; if the player closed the menu
.confirmItemSale ; if the player is trying to sell a specific item
call IsKeyItem
- ld a,[wIsKeyItem]
+ ld a, [wIsKeyItem]
and a
- jr nz,.unsellableItem
- ld a,[wcf91]
+ jr nz, .unsellableItem
+ ld a, [wcf91]
call IsItemHM
- jr c,.unsellableItem
- ld a,PRICEDITEMLISTMENU
- ld [wListMenuID],a
- ld [hHalveItemPrices],a ; halve prices when selling
+ jr c, .unsellableItem
+ ld a, PRICEDITEMLISTMENU
+ ld [wListMenuID], a
+ ld [hHalveItemPrices], a ; halve prices when selling
call DisplayChooseQuantityMenu
inc a
- jr z,.sellMenuLoop ; if the player closed the choose quantity menu with the B button
- ld hl,PokemartTellSellPriceText
+ jr z, .sellMenuLoop ; if the player closed the choose quantity menu with the B button
+ ld hl, PokemartTellSellPriceText
lb bc, 14, 1 ; location that PrintText always prints to, this is useless
call PrintText
coord hl, 14, 7
lb bc, 8, 15
- ld a,TWO_OPTION_MENU
- ld [wTextBoxID],a
+ ld a, TWO_OPTION_MENU
+ ld [wTextBoxID], a
call DisplayTextBoxID ; yes/no menu
- ld a,[wMenuExitMethod]
- cp a,CHOSE_SECOND_ITEM
- jr z,.sellMenuLoop ; if the player chose No or pressed the B button
+ ld a, [wMenuExitMethod]
+ cp CHOSE_SECOND_ITEM
+ jr z, .sellMenuLoop ; if the player chose No or pressed the B button
; The following code is supposed to check if the player chose No, but the above
; check already catches it.
- ld a,[wChosenMenuItem]
+ ld a, [wChosenMenuItem]
dec a
- jr z,.sellMenuLoop
+ jr z, .sellMenuLoop
.sellItem
- ld a,[wBoughtOrSoldItemInMart]
+ ld a, [wBoughtOrSoldItemInMart]
and a
- jr nz,.skipSettingFlag1
+ jr nz, .skipSettingFlag1
inc a
- ld [wBoughtOrSoldItemInMart],a
+ ld [wBoughtOrSoldItemInMart], a
.skipSettingFlag1
call AddAmountSoldToMoney
- ld hl,wNumBagItems
+ ld hl, wNumBagItems
call RemoveItemFromInventory
jp .sellMenuLoop
.unsellableItem
- ld hl,PokemartUnsellableItemText
+ ld hl, PokemartUnsellableItemText
call PrintText
jp .returnToMainPokemartMenu
.bagEmpty
- ld hl,PokemartItemBagEmptyText
+ ld hl, PokemartItemBagEmptyText
call PrintText
call SaveScreenTilesToBuffer1
jp .returnToMainPokemartMenu
.buyMenu
; the same variables are set again below, so this code has no effect
- ld a,1
- ld [wPrintItemPrices],a
- ld a,INIT_OTHER_ITEM_LIST
- ld [wInitListType],a
+ ld a, 1
+ ld [wPrintItemPrices], a
+ ld a, INIT_OTHER_ITEM_LIST
+ ld [wInitListType], a
callab InitList
- ld hl,PokemartBuyingGreetingText
+ ld hl, PokemartBuyingGreetingText
call PrintText
call SaveScreenTilesToBuffer1
.buyMenuLoop
call LoadScreenTilesFromBuffer1
- ld a,MONEY_BOX
- ld [wTextBoxID],a
+ ld a, MONEY_BOX
+ ld [wTextBoxID], a
call DisplayTextBoxID
- ld hl,wItemList
- ld a,l
- ld [wListPointer],a
- ld a,h
- ld [wListPointer + 1],a
+ ld hl, wItemList
+ ld a, l
+ ld [wListPointer], a
+ ld a, h
+ ld [wListPointer + 1], a
xor a
- ld [wCurrentMenuItem],a
+ ld [wCurrentMenuItem], a
inc a
- ld [wPrintItemPrices],a
+ ld [wPrintItemPrices], a
inc a ; a = 2 (PRICEDITEMLISTMENU)
- ld [wListMenuID],a
+ ld [wListMenuID], a
call DisplayListMenuID
- jr c,.returnToMainPokemartMenu ; if the player closed the menu
- ld a,99
- ld [wMaxItemQuantity],a
+ jr c, .returnToMainPokemartMenu ; if the player closed the menu
+ ld a, 99
+ ld [wMaxItemQuantity], a
xor a
- ld [hHalveItemPrices],a ; don't halve item prices when buying
+ ld [hHalveItemPrices], a ; don't halve item prices when buying
call DisplayChooseQuantityMenu
inc a
- jr z,.buyMenuLoop ; if the player closed the choose quantity menu with the B button
- ld a,[wcf91] ; item ID
- ld [wd11e],a ; store item ID for GetItemName
+ jr z, .buyMenuLoop ; if the player closed the choose quantity menu with the B button
+ ld a, [wcf91] ; item ID
+ ld [wd11e], a ; store item ID for GetItemName
call GetItemName
call CopyStringToCF4B ; copy name to wcf4b
- ld hl,PokemartTellBuyPriceText
+ ld hl, PokemartTellBuyPriceText
call PrintText
coord hl, 14, 7
lb bc, 8, 15
- ld a,TWO_OPTION_MENU
- ld [wTextBoxID],a
+ ld a, TWO_OPTION_MENU
+ ld [wTextBoxID], a
call DisplayTextBoxID ; yes/no menu
- ld a,[wMenuExitMethod]
- cp a,CHOSE_SECOND_ITEM
- jp z,.buyMenuLoop ; if the player chose No or pressed the B button
+ ld a, [wMenuExitMethod]
+ cp CHOSE_SECOND_ITEM
+ jp z, .buyMenuLoop ; if the player chose No or pressed the B button
; The following code is supposed to check if the player chose No, but the above
; check already catches it.
- ld a,[wChosenMenuItem]
+ ld a, [wChosenMenuItem]
dec a
- jr z,.buyMenuLoop
+ jr z, .buyMenuLoop
.buyItem
call .isThereEnoughMoney
- jr c,.notEnoughMoney
- ld hl,wNumBagItems
+ jr c, .notEnoughMoney
+ ld hl, wNumBagItems
call AddItemToInventory
- jr nc,.bagFull
+ jr nc, .bagFull
call SubtractAmountPaidFromMoney
- ld a,[wBoughtOrSoldItemInMart]
+ ld a, [wBoughtOrSoldItemInMart]
and a
- jr nz,.skipSettingFlag2
- ld a,1
- ld [wBoughtOrSoldItemInMart],a
+ jr nz, .skipSettingFlag2
+ ld a, 1
+ ld [wBoughtOrSoldItemInMart], a
.skipSettingFlag2
- ld a,SFX_PURCHASE
+ ld a, SFX_PURCHASE
call PlaySoundWaitForCurrent
call WaitForSoundToFinish
- ld hl,PokemartBoughtItemText
+ ld hl, PokemartBoughtItemText
call PrintText
jp .buyMenuLoop
.returnToMainPokemartMenu
call LoadScreenTilesFromBuffer1
- ld a,MONEY_BOX
- ld [wTextBoxID],a
+ ld a, MONEY_BOX
+ ld [wTextBoxID], a
call DisplayTextBoxID
- ld hl,PokemartAnythingElseText
+ ld hl, PokemartAnythingElseText
call PrintText
jp .loop
.isThereEnoughMoney
- ld de,wPlayerMoney
- ld hl,hMoney
- ld c,3 ; length of money in bytes
+ ld de, wPlayerMoney
+ ld hl, hMoney
+ ld c, 3 ; length of money in bytes
jp StringCmp
.notEnoughMoney
- ld hl,PokemartNotEnoughMoneyText
+ ld hl, PokemartNotEnoughMoneyText
call PrintText
jr .returnToMainPokemartMenu
.bagFull
- ld hl,PokemartItemBagFullText
+ ld hl, PokemartItemBagFullText
call PrintText
jr .returnToMainPokemartMenu
.done
- ld hl,PokemartThankYouText
+ ld hl, PokemartThankYouText
call PrintText
- ld a,1
- ld [wUpdateSpritesEnabled],a
+ ld a, 1
+ ld [wUpdateSpritesEnabled], a
call UpdateSprites
- ld a,[wSavedListScrollOffset]
- ld [wListScrollOffset],a
+ ld a, [wSavedListScrollOffset]
+ ld [wListScrollOffset], a
ret
PokemartBuyingGreetingText:
diff --git a/engine/overworld/print_safari_steps.asm b/engine/overworld/print_safari_steps.asm
deleted file mode 100644
index 01dd34e0..00000000
--- a/engine/overworld/print_safari_steps.asm
+++ /dev/null
@@ -1,36 +0,0 @@
-PrintSafariZoneSteps:
- ld a, [wCurMap]
- cp SAFARI_ZONE_EAST
- ret c
- cp UNKNOWN_DUNGEON_2
- ret nc
- coord hl, 0, 0
- lb bc, 3, 7
- call TextBoxBorder
- coord hl, 1, 1
- ld de, wSafariSteps
- lb bc, 2, 3
- call PrintNumber
- coord hl, 4, 1
- ld de, SafariSteps
- call PlaceString
- coord hl, 1, 3
- ld de, SafariBallText
- call PlaceString
- ld a, [wNumSafariBalls]
- cp 10
- jr nc, .numSafariBallsTwoDigits
- coord hl, 5, 3
- ld a, " "
- ld [hl], a
-.numSafariBallsTwoDigits
- coord hl, 6, 3
- ld de, wNumSafariBalls
- lb bc, 1, 2
- jp PrintNumber
-
-SafariSteps:
- db "/500@"
-
-SafariBallText:
- db "BALL×× @"
diff --git a/engine/overworld/try_pushing_boulder.asm b/engine/overworld/push_boulder.asm
index 8a385345..8a385345 100644
--- a/engine/overworld/try_pushing_boulder.asm
+++ b/engine/overworld/push_boulder.asm
diff --git a/engine/overworld/set_blackout_map.asm b/engine/overworld/set_blackout_map.asm
index 9bfe82bd..bac2f0ca 100644
--- a/engine/overworld/set_blackout_map.asm
+++ b/engine/overworld/set_blackout_map.asm
@@ -23,7 +23,7 @@ SetLastBlackoutMap:
ret
SafariZoneRestHouses:
- db SAFARI_ZONE_REST_HOUSE_2
- db SAFARI_ZONE_REST_HOUSE_3
- db SAFARI_ZONE_REST_HOUSE_4
+ db SAFARI_ZONE_WEST_REST_HOUSE
+ db SAFARI_ZONE_EAST_REST_HOUSE
+ db SAFARI_ZONE_NORTH_REST_HOUSE
db -1
diff --git a/engine/overworld/load_tileset_header.asm b/engine/overworld/tileset_header.asm
index 05061651..05061651 100644
--- a/engine/overworld/load_tileset_header.asm
+++ b/engine/overworld/tileset_header.asm
diff --git a/engine/overworld/replace_tile_block.asm b/engine/overworld/update_map.asm
index 8577b9e7..8577b9e7 100644
--- a/engine/overworld/replace_tile_block.asm
+++ b/engine/overworld/update_map.asm
diff --git a/engine/overworld/wild_mons.asm b/engine/overworld/wild_mons.asm
new file mode 100644
index 00000000..dae57f23
--- /dev/null
+++ b/engine/overworld/wild_mons.asm
@@ -0,0 +1,33 @@
+LoadWildData:
+ ld hl, WildDataPointers
+ ld a, [wCurMap]
+
+ ; get wild data for current map
+ ld c, a
+ ld b, 0
+ add hl, bc
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a ; hl now points to wild data for current map
+ ld a, [hli]
+ ld [wGrassRate], a
+ and a
+ jr z, .NoGrassData ; if no grass data, skip to surfing data
+ push hl
+ ld de, wGrassMons ; otherwise, load grass data
+ ld bc, $0014
+ call CopyData
+ pop hl
+ ld bc, $0014
+ add hl, bc
+.NoGrassData
+ ld a, [hli]
+ ld [wWaterRate], a
+ and a
+ ret z ; if no water data, we're done
+ ld de, wWaterMons ; otherwise, load surfing data
+ ld bc, $0014
+ jp CopyData
+
+INCLUDE "data/wild_mons.asm"
diff --git a/engine/palettes.asm b/engine/palettes.asm
index 3c25d4d2..ec9816ab 100755
--- a/engine/palettes.asm
+++ b/engine/palettes.asm
@@ -78,7 +78,7 @@ SetPal_StatusScreen:
ld bc, $10
call CopyData
ld a, [wcf91]
- cp VICTREEBEL + 1
+ cp NUM_POKEMON_INDEXES + 1
jr c, .pokemon
ld a, $1 ; not pokemon
.pokemon
@@ -155,7 +155,7 @@ SetPal_Overworld:
ld a, [wCurMap]
cp REDS_HOUSE_1F
jr c, .townOrRoute
- cp UNKNOWN_DUNGEON_2
+ cp CERULEAN_CAVE_2F
jr c, .normalDungeonOrBuilding
cp NAME_RATERS_HOUSE
jr c, .caveOrBruno
@@ -401,7 +401,7 @@ GetPal_Pikachu::
ld a, [wCurMap]
cp REDS_HOUSE_1F
jr c, .townOrRoute
- cp UNKNOWN_DUNGEON_2
+ cp CERULEAN_CAVE_2F
jr c, .normalDungeonOrBuilding
cp NAME_RATERS_HOUSE
jr c, .caveOrBruno
@@ -484,7 +484,7 @@ SendSGBPacket:
_SendSGBPacket:
;check number of packets
ld a, [hl]
- and a, $07
+ and $07
ret z
; store number of packets in B
ld b, a
diff --git a/engine/overworld/npc_pathfinding.asm b/engine/pathfinding.asm
index f3d23b7c..f3d23b7c 100644
--- a/engine/overworld/npc_pathfinding.asm
+++ b/engine/pathfinding.asm
diff --git a/engine/pikachu_emotions.asm b/engine/pikachu_emotions.asm
index b3b64970..1518b28e 100755
--- a/engine/pikachu_emotions.asm
+++ b/engine/pikachu_emotions.asm
@@ -281,9 +281,9 @@ MapSpecificPikachuExpression:
ldpikaemotion a, PikachuEmotion28
jr c, .play_emotion
ld a, [wCurMap]
- cp POKEMONTOWER_1
+ cp POKEMON_TOWER_1F
jr c, .notInLavenderTower
- cp POKEMONTOWER_7 + 1
+ cp POKEMON_TOWER_7F + 1
ldpikaemotion a, PikachuEmotion22
jr c, .play_emotion
.notInLavenderTower
diff --git a/engine/pikachu_follow.asm b/engine/pikachu_follow.asm
index db5fa0ee..d9dc91df 100755
--- a/engine/pikachu_follow.asm
+++ b/engine/pikachu_follow.asm
@@ -188,9 +188,9 @@ SetPikachuSpawnOutside::
jr z, .oaks_lab
cp ROUTE_22_GATE
jr z, .route_22_gate
- cp MT_MOON_2
+ cp MT_MOON_B1F
jr z, .mt_moon_2
- cp ROCK_TUNNEL_1
+ cp ROCK_TUNNEL_1F
jr z, .rock_tunnel_1
ld a, [wCurMap]
ld hl, Pointer_fc64b
@@ -235,7 +235,7 @@ SetPikachuSpawnOutside::
ret
Pointer_fc64b::
- db VICTORY_ROAD_2
+ db VICTORY_ROAD_2F
db ROUTE_7_GATE
db ROUTE_8_GATE
db ROUTE_16_GATE_1F
@@ -245,20 +245,20 @@ Pointer_fc64b::
db $ff
Pointer_fc653::
- db VIRIDIAN_FOREST_EXIT
- db CERULEAN_HOUSE_2
- db TRASHED_HOUSE
+ db VIRIDIAN_FOREST_NORTH_GATE
+ db CERULEAN_BADGE_HOUSE
+ db CERULEAN_TRASHED_HOUSE
db VERMILION_DOCK
- db CELADON_MANSION_1
+ db CELADON_MANSION_1F
db ROUTE_2_GATE
- db FUCHSIA_HOUSE_3
+ db FUCHSIA_GOOD_ROD_HOUSE
db $ff
SetPikachuSpawnWarpPad::
ld a, [wCurMap]
- cp VIRIDIAN_FOREST_EXIT
+ cp VIRIDIAN_FOREST_NORTH_GATE
jr z, .viridian_forest_exit
- cp VIRIDIAN_FOREST_ENTRANCE
+ cp VIRIDIAN_FOREST_SOUTH_GATE
jr z, .viridian_forest_entrance
ld a, [wCurMap]
ld hl, Pointer_fc68e
@@ -290,16 +290,16 @@ SetPikachuSpawnWarpPad::
Pointer_fc68e::
db VIRIDIAN_FOREST
- db SAFARI_ZONE_REST_HOUSE_1
- db SAFARI_ZONE_REST_HOUSE_2
- db SAFARI_ZONE_REST_HOUSE_3
- db SAFARI_ZONE_REST_HOUSE_4
+ db SAFARI_ZONE_CENTER_REST_HOUSE
+ db SAFARI_ZONE_WEST_REST_HOUSE
+ db SAFARI_ZONE_EAST_REST_HOUSE
+ db SAFARI_ZONE_NORTH_REST_HOUSE
db SAFARI_ZONE_SECRET_HOUSE
db SILPH_CO_ELEVATOR
db CELADON_MART_ELEVATOR
- db CINNABAR_LAB_2
- db CINNABAR_LAB_3
- db CINNABAR_LAB_4
+ db CINNABAR_LAB_TRADE_ROOM
+ db CINNABAR_LAB_METRONOME_ROOM
+ db CINNABAR_LAB_FOSSIL_ROOM
db $ff
SetPikachuSpawnBackOutside::
diff --git a/engine/pikachu_pcm.asm b/engine/pikachu_pcm.asm
index bb2c089c..1e6f8dc2 100755
--- a/engine/pikachu_pcm.asm
+++ b/engine/pikachu_pcm.asm
@@ -77,10 +77,10 @@ PlayPikachuSoundClip::
and $bb
ld [rNR51], a
xor a
- ld [wChannelSoundIDs+CH4], a
- ld [wChannelSoundIDs+CH5], a
- ld [wChannelSoundIDs+CH6], a
- ld [wChannelSoundIDs+CH7], a
+ ld [wChannelSoundIDs + Ch5], a
+ ld [wChannelSoundIDs + Ch6], a
+ ld [wChannelSoundIDs + Ch7], a
+ ld [wChannelSoundIDs + Ch8], a
ld a, [H_LOADEDROMBANK]
ei
ret
diff --git a/engine/pikachu_pic_animation.asm b/engine/pikachu_pic_animation.asm
index 0da8e499..c79d9add 100755
--- a/engine/pikachu_pic_animation.asm
+++ b/engine/pikachu_pic_animation.asm
@@ -792,7 +792,7 @@ PikaPicAnimCommand_thunderbolt:
call DelayFrame
ld a, [wAudioROMBank]
push af
- ld a, BANK(SFX_Thunderbolt)
+ ld a, BANK(SFX_Battle_2F)
ld [wAudioROMBank], a
ld [wAudioSavedROMBank], a
call .LoadAudio
diff --git a/engine/pokedex_rating.asm b/engine/pokedex_rating.asm
index 97bbfc24..4dfb6b39 100755
--- a/engine/pokedex_rating.asm
+++ b/engine/pokedex_rating.asm
@@ -42,7 +42,7 @@ DisplayDexRating:
inc de
.copyRatingTextLoop
ld a, [hli]
- cp a, "@"
+ cp "@"
jr z, .doneCopying
ld [de], a
inc de
@@ -86,7 +86,7 @@ DexRatingsTable:
dw DexRatingText_Own130To139
db 150
dw DexRatingText_Own140To149
- db 152
+ db NUM_POKEMON + 1
dw DexRatingText_Own150To151
DexRatingText_Own0To9:
diff --git a/engine/predefs.asm b/engine/predefs.asm
index e752a7ef..cc6af5ac 100755
--- a/engine/predefs.asm
+++ b/engine/predefs.asm
@@ -88,7 +88,7 @@ PredefPointers::
dbw $03, CheckForHiddenObjectOrBookshelfOrCardKeyDoor ; home bank
dbw $03, GiveItem ; home bank
- add_predef InvertBGPal_4Frames
+ add_predef ChangeBGPalColor0_4Frames
add_predef FindPathToPlayer
add_predef PredefShakeScreenVertically
add_predef CalcPositionOfPlayerRelativeToNPC
diff --git a/engine/predefsA.asm b/engine/predefsA.asm
index eb28b646..e25735c5 100644
--- a/engine/predefsA.asm
+++ b/engine/predefsA.asm
@@ -1,5 +1,5 @@
; inverts the BGP for 4 (6 on CGB due to lag) frames
-InvertBGPal_4Frames:
+ChangeBGPalColor0_4Frames:
call GetPredefRegisters ; leftover of red/blue, has no use here
ld a, [rBGP]
xor $ff
diff --git a/engine/save.asm b/engine/save.asm
index c28ba1f6..7f453bf0 100755
--- a/engine/save.asm
+++ b/engine/save.asm
@@ -131,37 +131,37 @@ LoadSAVIgnoreBadCheckSum:
SaveSAV:
callba PrintSaveScreenText
- ld c,10
+ ld c, 10
call DelayFrames
- ld hl,WouldYouLikeToSaveText
+ ld hl, WouldYouLikeToSaveText
call SaveSAVConfirm
and a ;|0 = Yes|1 = No|
ret nz
- ld c,10
+ ld c, 10
call DelayFrames
- ld a,[wSaveFileStatus]
+ ld a, [wSaveFileStatus]
cp $1
- jr z,.save
+ jr z, .save
call SAVCheckRandomID
- jr z,.save
- ld hl,OlderFileWillBeErasedText
+ jr z, .save
+ ld hl, OlderFileWillBeErasedText
call SaveSAVConfirm
and a
ret nz
.save
call SaveSAVtoSRAM
- ld hl,SavingText
+ ld hl, SavingText
call PrintText
- ld c,128
+ ld c, 128
call DelayFrames
- ld hl,GameSavedText
+ ld hl, GameSavedText
call PrintText
ld c,10
call DelayFrames
ld a, SFX_SAVE
call PlaySoundWaitForCurrent
call WaitForSoundToFinish
- ld c,30
+ ld c, 30
call DelayFrames
ret
@@ -169,10 +169,10 @@ SaveSAVConfirm:
call PrintText
coord hl, 0, 7
lb bc, 8, 1
- ld a,TWO_OPTION_MENU
- ld [wTextBoxID],a
+ ld a, TWO_OPTION_MENU
+ ld [wTextBoxID], a
call DisplayTextBoxID ; yes/no menu
- ld a,[wCurrentMenuItem]
+ ld a, [wCurrentMenuItem]
ret
WouldYouLikeToSaveText:
@@ -587,23 +587,23 @@ SAVCheckRandomID:
ld hl, sPlayerName
ld bc, sMainDataCheckSum - sPlayerName
call SAVCheckSum
- ld c,a
- ld a,[sMainDataCheckSum]
+ ld c, a
+ ld a, [sMainDataCheckSum]
cp c
- jr nz,.next
- ld hl,sMainData + 98 ; player ID
- ld a,[hli]
- ld h,[hl]
- ld l,a
- ld a,[wPlayerID]
+ jr nz, .next
+ ld hl, sMainData + (wPlayerID - wMainDataStart) ; player ID
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, [wPlayerID]
cp l
- jr nz,.next
- ld a,[wPlayerID + 1]
+ jr nz, .next
+ ld a, [wPlayerID + 1]
cp h
.next
- ld a,$00
- ld [MBC1SRamBankingMode],a
- ld [MBC1SRamEnable],a
+ ld a, $00
+ ld [MBC1SRamBankingMode], a
+ ld [MBC1SRamEnable], a
ret
SaveHallOfFameTeams:
diff --git a/engine/slot_machine.asm b/engine/slot_machine.asm
index 292bb809..b4514618 100755
--- a/engine/slot_machine.asm
+++ b/engine/slot_machine.asm
@@ -613,7 +613,8 @@ SlotReward300Func:
YeahText:
TX_FAR _YeahText
- db $0a, "@"
+ TX_DELAY
+ db "@"
SlotMachine_PrintWinningSymbol:
; prints winning symbol and down arrow in text box
@@ -630,7 +631,7 @@ SlotMachine_PrintWinningSymbol:
inc a
ld [hl], a
coord hl, 18, 16
- ld [hl], $ee ; down arrow
+ ld [hl], "▼"
ret
SlotMachine_SubtractBetFromPlayerCoins:
diff --git a/engine/overworld/special_warps.asm b/engine/special_warps.asm
index 4814e668..3a8b8b86 100644
--- a/engine/overworld/special_warps.asm
+++ b/engine/special_warps.asm
@@ -1,31 +1,31 @@
SpecialWarpIn:
call LoadSpecialWarpData
predef LoadTilesetHeader
- ld hl,wd732
- bit 2,[hl] ; dungeon warp or fly warp?
- res 2,[hl]
- jr z,.next
+ ld hl, wd732
+ bit 2, [hl] ; dungeon warp or fly warp?
+ res 2, [hl]
+ jr z, .next
; if dungeon warp or fly warp
- ld a,[wDestinationMap]
+ ld a, [wDestinationMap]
jr .next2
.next
- bit 1,[hl]
- jr z,.next3
+ bit 1, [hl]
+ jr z, .next3
call EmptyFunc
.next3
- ld a,0
+ ld a, 0
.next2
- ld b,a
- ld a,[wd72d]
+ ld b, a
+ ld a, [wd72d]
and a
- jr nz,.next4
- ld a,b
+ jr nz, .next4
+ ld a, b
.next4
- ld hl,wd732
- bit 4,[hl] ; dungeon warp?
+ ld hl, wd732
+ bit 4, [hl] ; dungeon warp?
ret nz
; if not dungeon warp
- ld [wLastMap],a
+ ld [wLastMap], a
ret
; gets the map ID, tile block map view pointer, tileset, and coordinates
@@ -145,3 +145,5 @@ LoadSpecialWarpData:
ld a, $ff ; the player's coordinates have already been updated using a special warp, so don't use any of the normal warps
ld [wDestinationWarpID], a
ret
+
+INCLUDE "data/special_warps.asm"
diff --git a/engine/surfing_minigame.asm b/engine/surfing_minigame.asm
index 6bfcfb7c..81e5296d 100755
--- a/engine/surfing_minigame.asm
+++ b/engine/surfing_minigame.asm
@@ -715,7 +715,7 @@ Func_f848d:
ld [wSurfingMinigameRadnessMeter], a
ld [wSurfingMinigameTrickFlags], a
xor a
- ld [wChannelSoundIDs + CH7], a
+ ld [wChannelSoundIDs + Ch8], a
ld a, SFX_SURFING_JUMP
call PlaySound
ret
@@ -751,7 +751,7 @@ SurfingMinigame_ScoreCurrentWave:
ld a, $10
call SetCurrentAnimatedObjectCallbackAndResetFrameStateRegisters
xor a
- ld [wChannelSoundIDs + CH7], a
+ ld [wChannelSoundIDs + Ch8], a
ld a, SFX_SURFING_LAND
call PlaySound
ret
@@ -1010,7 +1010,7 @@ SurfingMinigame_TileInteraction:
call SufingMinigame_ReduceSpeedBy64
.action_3
xor a
- ld [wChannelSoundIDs + CH7], a
+ ld [wChannelSoundIDs + Ch8], a
ld a, SFX_SURFING_CRASH
call PlaySound
and a
diff --git a/engine/test_battle.asm b/engine/test_battle.asm
new file mode 100644
index 00000000..d9dcf1fa
--- /dev/null
+++ b/engine/test_battle.asm
@@ -0,0 +1,45 @@
+TestBattle:
+ ret
+
+.loop
+ call GBPalNormal
+
+ ; Don't mess around
+ ; with obedience.
+ ld a, %10000000 ; EARTHBADGE
+ ld [wObtainedBadges], a
+
+ ld hl, wFlags_D733
+ set BIT_TEST_BATTLE, [hl]
+
+ ; Reset the party.
+ ld hl, wPartyCount
+ xor a
+ ld [hli], a
+ dec a
+ ld [hl], a
+
+ ; Give the player a
+ ; level 20 Rhydon.
+ ld a, RHYDON
+ ld [wcf91], a
+ ld a, 20
+ ld [wCurEnemyLVL], a
+ xor a
+ ld [wMonDataLocation], a
+ ld [wCurMap], a
+ call AddPartyMon
+
+ ; Fight against a
+ ; level 20 Rhydon.
+ ld a, RHYDON
+ ld [wCurOpponent], a
+
+ predef InitOpponent
+
+ ; When the battle ends,
+ ; do it all again.
+ ld a, 1
+ ld [wUpdateSpritesEnabled], a
+ ld [H_AUTOBGTRANSFERENABLED], a
+ jr .loop
diff --git a/engine/town_map.asm b/engine/town_map.asm
index cf09be7c..7d32b5fe 100755
--- a/engine/town_map.asm
+++ b/engine/town_map.asm
@@ -191,7 +191,7 @@ LoadTownMap_Fly:
coord hl, 18, 0
ld [hl], "▶"
coord hl, 19, 0
- ld [hl], $ee
+ ld [hl], "▼"
pop hl
.inputLoop
push hl
diff --git a/engine/trade2.asm b/engine/trade2.asm
index c47da36a..2c79e077 100755
--- a/engine/trade2.asm
+++ b/engine/trade2.asm
@@ -1,49 +1,48 @@
Trade_PrintPlayerMonInfoText:
coord hl, 5, 0
- ld de,Trade_MonInfoText
+ ld de, Trade_MonInfoText
call PlaceString
- ld a,[wTradedPlayerMonSpecies]
- ld [wd11e],a
+ ld a, [wTradedPlayerMonSpecies]
+ ld [wd11e], a
predef IndexToPokedex
coord hl, 9, 0
- ld de,wd11e
+ ld de, wd11e
lb bc, LEADING_ZEROES | 1, 3
call PrintNumber
coord hl, 5, 2
- ld de,wcf4b
+ ld de, wcf4b
call PlaceString
coord hl, 8, 4
- ld de,wTradedPlayerMonOT
+ ld de, wTradedPlayerMonOT
call PlaceString
coord hl, 8, 6
- ld de,wTradedPlayerMonOTID
+ ld de, wTradedPlayerMonOTID
lb bc, LEADING_ZEROES | 2, 5
jp PrintNumber
Trade_PrintEnemyMonInfoText:
coord hl, 5, 10
- ld de,Trade_MonInfoText
+ ld de, Trade_MonInfoText
call PlaceString
- ld a,[wTradedEnemyMonSpecies]
- ld [wd11e],a
+ ld a, [wTradedEnemyMonSpecies]
+ ld [wd11e], a
predef IndexToPokedex
coord hl, 9, 10
- ld de,wd11e
+ ld de, wd11e
lb bc, LEADING_ZEROES | 1, 3
call PrintNumber
coord hl, 5, 12
- ld de,wcd6d
+ ld de, wcd6d
call PlaceString
coord hl, 8, 14
- ld de,wTradedEnemyMonOT
+ ld de, wTradedEnemyMonOT
call PlaceString
coord hl, 8, 16
- ld de,wTradedEnemyMonOTID
+ ld de, wTradedEnemyMonOTID
lb bc, LEADING_ZEROES | 2, 5
jp PrintNumber
Trade_MonInfoText:
- db "──",$74,$F2
- db $4e ; next
+ db "──№⠄",$4E
next "OT/"
- next $73,"№",$F2,"@"
+ next $73,"№⠄","@"
diff --git a/engine/yellow_intro.asm b/engine/yellow_intro.asm
index 60135134..9c9e26b3 100755
--- a/engine/yellow_intro.asm
+++ b/engine/yellow_intro.asm
@@ -851,8 +851,8 @@ InitYellowIntroGFXAndMusic:
ld [hli], a
ld [hli], a
ld [hl], a
- ld a, MUSIC_INTRO_BATTLE
- ld c, BANK(Music_IntroBattle)
+ ld a, MUSIC_YELLOW_INTRO
+ ld c, BANK(Music_YellowIntro)
call PlayMusic
ret