ref: e25a7148d0a78549de4f33fa72d519dcaf660e97
parent: b509b48a7f5a9a80225b9c030d7334b26b521c62
parent: 5d3b958763d48e6049e13b068d2f2d5382cdcad2
author: dannye <corrnondacqb@yahoo.com>
date: Mon Jul 13 20:58:09 EDT 2015
Merge branch 'master' of https://github.com/YamaArashi/pokered Conflicts: engine/town_map.asm
--- a/constants/list_constants.asm
+++ b/constants/list_constants.asm
@@ -12,3 +12,9 @@
PLAYEROT_NAME EQU 5
ENEMYOT_NAME EQU 6
TRAINER_NAME EQU 7
+
+INIT_ENEMYOT_LIST EQU 1
+INIT_BAG_ITEM_LIST EQU 2
+INIT_OTHER_ITEM_LIST EQU 3
+INIT_PLAYEROT_LIST EQU 4
+INIT_MON_LIST EQU 5
--- a/constants/misc_constants.asm
+++ b/constants/misc_constants.asm
@@ -58,6 +58,57 @@
HEAL_CANCEL_MENU EQU 6
NO_YES_MENU EQU 7
+; menu exit method constants for list menus and the buy/sell/quit menu
+CHOSE_MENU_ITEM EQU 1 ; pressed A
+CANCELLED_MENU EQU 2 ; pressed B
+
+; menu exit method constants for two-option menus
+CHOSE_FIRST_ITEM EQU 1
+CHOSE_SECOND_ITEM EQU 2
+
+; move mon constants
+BOX_TO_PARTY EQU 0
+PARTY_TO_BOX EQU 1
+DAYCARE_TO_PARTY EQU 2
+PARTY_TO_DAYCARE EQU 3
+
+; emotion bubbles
+EXCLAMATION_BUBBLE EQU 0
+QUESTION_BUBBLE EQU 1
+SMILE_BUBBLE EQU 2
+
+; slot symbols
+SLOTS7 EQU $0200
+SLOTSBAR EQU $0604
+SLOTSCHERRY EQU $0A08
+SLOTSFISH EQU $0E0C
+SLOTSBIRD EQU $1210
+SLOTSMOUSE EQU $1614
+
+; party menu types
+NORMAL_PARTY_MENU EQU 0
+USE_ITEM_PARTY_MENU EQU 1
+BATTLE_PARTY_MENU EQU 2
+TMHM_PARTY_MENU EQU 3
+SWAP_MONS_PARTY_MENU EQU 4
+EVO_STONE_PARTY_MENU EQU 5
+
+; party memu message IDs
+ANTIDOTE_MSG EQU $F0
+BURN_HEAL_MSG EQU $F1
+ICE_HEAL_MSG EQU $F2
+AWAKENING_MSG EQU $F3
+PARALYZ_HEAL_MSG EQU $F4
+POTION_MSG EQU $F5
+FULL_HEAL_MSG EQU $F6
+REVIVE_MSG EQU $F7
+RARE_CANDY_MSG EQU $F8
+
+; naming screen types
+NAME_PLAYER_SCREEN EQU 0
+NAME_RIVAL_SCREEN EQU 1
+NAME_MON_SCREEN EQU 2
+
; serial
ESTABLISH_CONNECTION_WITH_INTERNAL_CLOCK EQU $01
--- a/engine/HoF_room_pc.asm
+++ b/engine/HoF_room_pc.asm
@@ -77,7 +77,7 @@
call Func_74164
call FillMiddleOfScreenWithWhite
ld a,$FC
- ld [$FF47],a
+ ld [rBGP],a
ld bc,7
.next
call Func_74140
@@ -94,7 +94,7 @@
xor a
ld [hWY],a
ld a,$C0
- ld [$FF47],a
+ ld [rBGP],a
ret
INCLUDE "data/credit_mons.asm"
@@ -133,7 +133,7 @@
ld a, l
ld [H_AUTOBGTRANSFERDEST], a
ld a, h
- ld [$ffbd], a
+ ld [H_AUTOBGTRANSFERDEST + 1], a
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
jp Delay3
--- a/engine/battle/animations.asm
+++ b/engine/battle/animations.asm
@@ -336,7 +336,7 @@
ld d,0
add hl,de
ld a,[hli]
- ld [wd07d],a ; number of tiles
+ ld [wTempTilesetNumTiles],a ; number of tiles
ld a,[hli]
ld e,a
ld a,[hl]
@@ -343,7 +343,7 @@
ld d,a ; de = address of tileset
ld hl,vSprites + $310
ld b, BANK(AnimationTileset1) ; ROM bank
- ld a,[wd07d]
+ ld a,[wTempTilesetNumTiles]
ld c,a ; number of tiles
jp CopyVideoData ; load tileset
@@ -835,9 +835,9 @@
; if the subaninmation counter is between 8 and 11, shake the screen horizontally and vertically
.shakeScreen
ld b,1
- predef Func_48125 ; shake horizontally
+ predef PredefShakeScreenHorizontally ; shake horizontally
ld b,1
- predef_jump Func_480ff ; shake vertically
+ predef_jump PredefShakeScreenVertically ; shake vertically
FlashScreenEveryEightFrameBlocks: ; 78ff7 (1e:4ff7)
ld a,[W_SUBANIMCOUNTER]
@@ -1225,7 +1225,7 @@
ld b, $5
AnimationShakeScreenVertically: ; 79209 (1e:5209)
- predef_jump Func_480ff
+ predef_jump PredefShakeScreenVertically
AnimationShakeScreen: ; 7920e (1e:520e)
; Shakes the screen for a while. Used in Earthquake/Fissure/etc. animations.
@@ -1232,7 +1232,7 @@
ld b, $8
AnimationShakeScreenHorizontallyFast: ; 79210 (1e:5210)
- predef_jump Func_48125
+ predef_jump PredefShakeScreenHorizontally
AnimationWaterDropletsEverywhere: ; 79215 (1e:5215)
; Draws water droplets all over the screen and makes them
@@ -1292,12 +1292,12 @@
ld c, $7
ld a, [H_WHOSETURN]
and a
- ld hl, wTileMap + $79
- ld de, wTileMap + $65
+ hlCoord 1, 6
+ deCoord 1, 5
ld a, $30
jr z, .asm_79291
- ld hl, wTileMap + $20
- ld de, wTileMap + $c
+ hlCoord 12, 1
+ deCoord 12, 0
ld a, $ff
.asm_79291
ld [wd09f], a
@@ -1345,7 +1345,7 @@
call CopyData
pop de
pop hl
- ld bc, $0028
+ ld bc, SCREEN_WIDTH * 2
add hl, bc
pop bc
dec b
@@ -1352,9 +1352,9 @@
jr nz, .asm_792c4
ld a, [H_WHOSETURN]
and a
- ld hl, wTileMap + $dd
+ hlCoord 1, 11
jr z, .asm_792e2
- ld hl, wTileMap + $84
+ hlCoord 12, 6
.asm_792e2
ld a, [wd09f]
inc a
@@ -1513,11 +1513,11 @@
; The mon's sprite disappears after this animation.
ld a, [H_WHOSETURN]
and a
- ld hl, wTileMap + $64
- ld de, wTileMap + $66
+ hlCoord 0, 5
+ deCoord 2, 5
jr z, .asm_793c2
- ld hl, wTileMap + $b
- ld de, wTileMap + $d
+ hlCoord 11, 0
+ deCoord 13, 0
.asm_793c2
xor a
@@ -2061,23 +2061,24 @@
ld a, BANK(SlowbroSprite)
jp FarCopyData2
-Func_79747: ; 79747 (1e:5747)
+HideSubstituteShowMonAnim: ; 79747 (1e:5747)
ld a, [H_WHOSETURN]
and a
- ld hl, wccf7
+ ld hl, wPlayerMonMinimized
ld a, [W_PLAYERBATTSTATUS2]
- jr z, .asm_79758
- ld hl, wccf3
+ jr z, .next1
+ ld hl, wEnemyMonMinimized
ld a, [W_ENEMYBATTSTATUS2]
-.asm_79758
+.next1
push hl
- bit 4, a
- jr nz, .asm_79762
+; if the substitute broke, slide it down, else slide it offscreen horizontally
+ bit HasSubstituteUp, a
+ jr nz, .substituteStillUp
call AnimationSlideMonDown
- jr .asm_79765
-.asm_79762
+ jr .next2
+.substituteStillUp
call AnimationSlideMonOut
-.asm_79765
+.next2
pop hl
ld a, [hl]
and a
@@ -2085,7 +2086,7 @@
call AnimationFlashMonPic
jp AnimationShowMonPic
-Func_79771: ; 79771 (1e:5771)
+ReshowSubstituteAnim: ; 79771 (1e:5771)
call AnimationSlideMonOut
call AnimationSubstitute
jp AnimationShowMonPic
@@ -2644,16 +2645,16 @@
AnimationLeavesFalling: ; 79c74 (1e:5c74)
; Makes leaves float down from the top of the screen. This is used
; in Razor Leaf's animation.
- ld a, [$ff48]
+ ld a, [rOBP0]
push af
ld a, [wcc79]
- ld [$ff48], a
+ ld [rOBP0], a
ld d, $37
ld a, $3
ld [W_SUBANIMTRANSFORM], a
call Func_79c97
pop af
- ld [$ff48], a
+ ld [rOBP0], a
ret
AnimationPetalsFalling: ; 79c8a (1e:5c8a)
@@ -2870,7 +2871,7 @@
Func_79e0d: ; 79e0d (1e:5e0d)
ld a, h
- ld [$ffbd], a
+ ld [H_AUTOBGTRANSFERDEST + 1], a
ld a, l
ld [H_AUTOBGTRANSFERDEST], a
jp Delay3
--- a/engine/battle/bank_e_misc.asm
+++ b/engine/battle/bank_e_misc.asm
@@ -53,8 +53,8 @@
; XXX this is called in a few places, but it doesn't appear to do anything useful
InitList: ; 39bd5 (e:5bd5)
- ld a, [wd11b]
- cp $1
+ ld a, [wInitListType]
+ cp INIT_ENEMYOT_LIST
jr nz, .notEnemy
ld hl, wEnemyPartyCount
ld de, wEnemyMonOT
@@ -61,7 +61,7 @@
ld a, ENEMYOT_NAME
jr .done
.notEnemy
- cp $4
+ cp INIT_PLAYEROT_LIST
jr nz, .notPlayer
ld hl, wPartyCount
ld de, wPartyMonOT
@@ -68,7 +68,7 @@
ld a, PLAYEROT_NAME
jr .done
.notPlayer
- cp $5
+ cp INIT_MON_LIST
jr nz, .notMonster
ld hl, wStringBuffer2 + 11
ld de, MonsterNames
@@ -75,7 +75,7 @@
ld a, MONSTER_NAME
jr .done
.notMonster
- cp $2
+ cp INIT_BAG_ITEM_LIST
jr nz, .notBag
ld hl, wNumBagItems
ld de, ItemNames
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -848,7 +848,7 @@
ld [hl], a
ld [W_ENEMYDISABLEDMOVE], a
ld [wEnemyDisabledMoveNumber], a
- ld [wccf3], a
+ ld [wEnemyMonMinimized], a
ld hl, wPlayerUsedMove
ld [hli], a
ld [hl], a
@@ -1142,8 +1142,8 @@
ld a, TWO_OPTION_MENU
ld [wTextBoxID], a
call DisplayTextBoxID
- ld a, [wd12e]
- cp $2 ; did the player choose NO?
+ ld a, [wMenuExitMethod]
+ cp CHOSE_SECOND_ITEM ; did the player choose NO?
jr z, .tryRunning ; if the player chose NO, try running
and a ; reset carry
ret
@@ -1162,8 +1162,8 @@
; choose next player mon to send out
; stores whether enemy mon has no HP left in Z flag
ChooseNextMon: ; 3c7d8 (f:47d8)
- ld a, $2
- ld [wd07d], a
+ ld a, BATTLE_PARTY_MENU
+ ld [wPartyMenuTypeOrMessageID], a
call DisplayPartyMenu
.checkIfMonChosen
jr nc, .monChosen
@@ -1376,7 +1376,7 @@
ld [hl],a
ld [W_ENEMYDISABLEDMOVE],a
ld [wEnemyDisabledMoveNumber],a
- ld [wccf3],a
+ ld [wEnemyMonMinimized],a
ld hl,wPlayerUsedMove
ld [hli],a
ld [hl],a
@@ -1462,8 +1462,8 @@
ld a,[wCurrentMenuItem]
and a
jr nz,.next4
- ld a,2
- ld [wd07d],a
+ ld a,BATTLE_PARTY_MENU
+ ld [wPartyMenuTypeOrMessageID],a
call DisplayPartyMenu
.next9
ld a,1
@@ -1826,7 +1826,7 @@
ld [hl], a
ld [W_PLAYERDISABLEDMOVE], a
ld [wPlayerDisabledMoveNumber], a
- ld [wccf7], a
+ ld [wPlayerMonMinimized], a
ld b, $1
call GoPAL_SET
ld hl, W_ENEMYBATTSTATUS1
@@ -2296,7 +2296,7 @@
DisplayBagMenu:
xor a
- ld [wcf93], a
+ ld [wPrintItemPrices], a
ld a, ITEMLISTMENU
ld [wListMenuID], a
ld a, [wcc2c]
@@ -2305,7 +2305,7 @@
ld a, [wCurrentMenuItem]
ld [wcc2c], a
ld a, $0
- ld [wcc37], a
+ ld [wMenuWatchMovingOutOfBounds], a
ld [wMenuItemToSwap], a
jp c, DisplayBattleMenu ; go back to battle menu if an item was not selected
@@ -2384,8 +2384,8 @@
jp UseBagItem
.partyMenuWasSelected
call LoadScreenTilesFromBuffer1
- xor a
- ld [wd07d], a
+ xor a ; NORMAL_PARTY_MENU
+ ld [wPartyMenuTypeOrMessageID], a
ld [wMenuItemToSwap], a
call DisplayPartyMenu
.checkIfPartyMonWasSelected
@@ -2403,8 +2403,8 @@
ld bc, $81
ld a, $7f
call FillMemory
- xor a
- ld [wd07d], a
+ xor a ; NORMAL_PARTY_MENU
+ ld [wPartyMenuTypeOrMessageID], a
call GoBackToPartyMenu
jr .checkIfPartyMonWasSelected
.partyMonWasSelected
@@ -2448,7 +2448,7 @@
ld hl, AnimationSubstitute
jr nz, .doEnemyMonAnimation
; enemy mon doesn't have substitute
- ld a, [wccf3]
+ ld a, [wEnemyMonMinimized]
and a ; has the enemy mon used Minimise?
ld hl, AnimationMinimizeMon
jr nz, .doEnemyMonAnimation
@@ -3215,9 +3215,9 @@
playPlayerMoveAnimation
push af
ld a,[W_PLAYERBATTSTATUS2]
- bit 4,a
- ld hl,Func_79747
- ld b,BANK(Func_79747)
+ bit HasSubstituteUp,a
+ ld hl,HideSubstituteShowMonAnim
+ ld b,BANK(HideSubstituteShowMonAnim)
call nz,Bankswitch
pop af
ld [wAnimationType],a
@@ -3226,9 +3226,9 @@
call HandleExplodingAnimation
call DrawPlayerHUDAndHPBar
ld a,[W_PLAYERBATTSTATUS2]
- bit 4,a
- ld hl,Func_79771
- ld b,BANK(Func_79771)
+ bit HasSubstituteUp,a
+ ld hl,ReshowSubstituteAnim
+ ld b,BANK(ReshowSubstituteAnim)
call nz,Bankswitch
jr MirrorMoveCheck
playerCheckIfFlyOrChargeEffect
@@ -3958,7 +3958,7 @@
ld hl, KeptGoingAndCrashedText
call PrintText
ld b, $4
- predef Func_48125
+ predef PredefShakeScreenHorizontally
ld a, [H_WHOSETURN]
and a
jr nz, .enemyTurn
@@ -5089,7 +5089,7 @@
ld a,[H_WHOSETURN]
xor a,$01
ld [H_WHOSETURN],a
- callab Func_79747 ; animate the substitute breaking
+ callab HideSubstituteShowMonAnim ; animate the substitute breaking
; flip the turn back to the way it was
ld a,[H_WHOSETURN]
xor a,$01
@@ -5767,8 +5767,8 @@
push af
ld a, [W_ENEMYBATTSTATUS2]
bit HasSubstituteUp, a ; does mon have a substitute?
- ld hl, Func_79747
- ld b, BANK(Func_79747)
+ ld hl, HideSubstituteShowMonAnim
+ ld b, BANK(HideSubstituteShowMonAnim)
call nz, Bankswitch
pop af
ld [wAnimationType], a
@@ -5778,8 +5778,8 @@
call DrawEnemyHUDAndHPBar
ld a, [W_ENEMYBATTSTATUS2]
bit HasSubstituteUp, a ; does mon have a substitute?
- ld hl, Func_79771
- ld b, BANK(Func_79771)
+ ld hl, ReshowSubstituteAnim
+ ld b, BANK(ReshowSubstituteAnim)
call nz, Bankswitch ; slide the substitute's sprite out
jr EnemyCheckIfMirrorMoveEffect
@@ -6943,12 +6943,12 @@
call SaveScreenTilesToBuffer1
call ClearScreen
ld a, $98
- ld [$ffbd], a
+ ld [H_AUTOBGTRANSFERDEST + 1], a
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
call Delay3
ld a, $9c
- ld [$ffbd], a
+ ld [H_AUTOBGTRANSFERDEST + 1], a
call LoadScreenTilesFromBuffer1
hlCoord 9, 7
ld bc, $50a
@@ -7657,24 +7657,26 @@
call PrintStatText
ld hl, W_PLAYERBATTSTATUS2
ld de, W_PLAYERMOVENUM
- ld bc, wccf7
+ ld bc, wPlayerMonMinimized
ld a, [H_WHOSETURN]
and a
jr z, .asm_3f4e6
ld hl, W_ENEMYBATTSTATUS2
ld de, W_ENEMYMOVENUM
- ld bc, wccf3
+ ld bc, wEnemyMonMinimized
.asm_3f4e6
ld a, [de]
cp MINIMIZE
jr nz, .asm_3f4f9
- bit HasSubstituteUp, [hl] ; substitute
+ ; if a substitute is up, slide off the substitute and show the mon pic before
+ ; playing the minimize animation
+ bit HasSubstituteUp, [hl]
push af
push bc
- ld hl, Func_79747
- ld b, BANK(Func_79747)
+ ld hl, HideSubstituteShowMonAnim
+ ld b, BANK(HideSubstituteShowMonAnim)
push de
- call nz, Bankswitch ; play Minimize animation unless there's Substitute involved
+ call nz, Bankswitch
pop de
.asm_3f4f9
call PlayCurrentMoveAnimation
@@ -7684,8 +7686,8 @@
pop bc
ld a, $1
ld [bc], a
- ld hl, Func_79771
- ld b, BANK(Func_79771)
+ ld hl, ReshowSubstituteAnim
+ ld b, BANK(ReshowSubstituteAnim)
pop af
call nz, Bankswitch
.applyBadgeBoostsAndStatusPenalties
--- a/engine/battle/moveEffects/transform_effect.asm
+++ b/engine/battle/moveEffects/transform_effect.asm
@@ -26,8 +26,8 @@
; animation(s) played are different if target has Substitute up
bit HasSubstituteUp, [hl]
push af
- ld hl, Func_79747
- ld b, BANK(Func_79747)
+ ld hl, HideSubstituteShowMonAnim
+ ld b, BANK(HideSubstituteShowMonAnim)
call nz, Bankswitch
ld a, [W_OPTIONS]
add a
@@ -38,8 +38,8 @@
ld b, BANK(AnimationTransformMon)
.gotAnimToPlay
call Bankswitch
- ld hl, Func_79771
- ld b, BANK(Func_79771)
+ ld hl, ReshowSubstituteAnim
+ ld b, BANK(ReshowSubstituteAnim)
pop af
call nz, Bankswitch
pop bc
--- a/engine/cable_club.asm
+++ b/engine/cable_club.asm
@@ -317,7 +317,7 @@
ld [hli], a
ld [hli], a
ld [hl], a
- ld [wcc37], a
+ ld [wMenuWatchMovingOutOfBounds], a
ld [wCurrentMenuItem], a
ld [wLastMenuItem], a
ld [wMenuJoypadPollCount], a
@@ -326,7 +326,7 @@
jp .playerMonMenu
.enemyMonMenu
xor a
- ld [wcc37], a
+ ld [wMenuWatchMovingOutOfBounds], a
inc a
ld [wWhichTradeMonSelectionMenu], a
ld a, D_DOWN | D_LEFT | A_BUTTON
@@ -357,9 +357,9 @@
dec a
ld [wCurrentMenuItem], a
.displayEnemyMonStats
- ld a, $1
- ld [wd11b], a
- callab InitList
+ ld a, INIT_ENEMYOT_LIST
+ ld [wInitListType], a
+ callab InitList ; the list isn't used
ld hl, wEnemyMons
call TradeCenter_DisplayStats
jp .getNewInput
@@ -390,7 +390,7 @@
.playerMonMenu
xor a ; player mon menu
ld [wWhichTradeMonSelectionMenu], a
- ld [wcc37], a
+ ld [wMenuWatchMovingOutOfBounds], a
ld a, D_DOWN | D_RIGHT | A_BUTTON
ld [wMenuWatchedKeys], a
ld a, [wPartyCount]
@@ -416,9 +416,9 @@
jr z, .playerMonMenu_ANotPressed
jp .chosePlayerMon ; jump if A button pressed
; unreachable code
- ld a, $4
- ld [wd11b], a
- callab InitList
+ ld a, INIT_PLAYEROT_LIST
+ ld [wInitListType], a
+ callab InitList ; the list isn't used
call TradeCenter_DisplayStats
jp .getNewInput
.playerMonMenu_ANotPressed
@@ -511,9 +511,9 @@
.displayPlayerMonStats
pop af
ld [wCurrentMenuItem], a
- ld a, $4
- ld [wd11b], a
- callab InitList
+ ld a, INIT_PLAYEROT_LIST
+ ld [wInitListType], a
+ callab InitList ; the list isn't used
call TradeCenter_DisplayStats
call LoadScreenTilesFromBuffer1
jp .playerMonMenu
@@ -682,7 +682,7 @@
xor a
ld [wSerialExchangeNybbleSendData + 1], a ; unnecessary
ld [wSerialExchangeNybbleReceiveData], a
- ld [wcc37], a
+ ld [wMenuWatchMovingOutOfBounds], a
ld [wMenuJoypadPollCount], a
hlCoord 0, 12
ld b, 4
@@ -793,7 +793,7 @@
ld a, [hl]
ld [wTradedPlayerMonSpecies], a
xor a
- ld [wcf95], a
+ ld [wRemoveMonFromBox], a
call RemovePokemon
ld a, [wTradingWhichEnemyMon]
ld c, a
--- a/engine/game_corner_slots.asm
+++ b/engine/game_corner_slots.asm
@@ -1,5 +1,5 @@
StartSlotMachine: ; 37e2d (d:7e2d)
- ld a, [wTrainerSpriteOffset]
+ ld a, [wHiddenObjectFunctionArgument]
cp $fd
jr z, .printOutOfOrder
cp $fe
@@ -7,23 +7,23 @@
cp $ff
jr z, .printSomeonesKeys
callba AbleToPlaySlotsCheck
- ld a, [wTrainerSpriteOffset]
+ ld a, [wHiddenObjectFunctionArgument]
and a
ret z
- ld a, [wUnknownSlotVar]
+ ld a, [wLuckySlotHiddenObjectIndex]
ld b, a
- ld a, [wTrainerFacingDirection]
+ ld a, [wHiddenObjectIndex]
inc a
cp b
- jr z, .asm_37e58
- ld a, $fd
- jr .asm_37e5a
-.asm_37e58
- ld a, $fa
-.asm_37e5a
- ld [wcc5b], a
+ jr z, .match
+ ld a, 253
+ jr .next
+.match
+ ld a, 250
+.next
+ ld [wSlotMachineSevenAndBarModeChance], a
ld a, [H_LOADEDROMBANK]
- ld [wcc5e], a
+ ld [wSlotMachineSavedROMBank], a
call PromptUserToPlaySlots
ret
.printOutOfOrder
--- a/engine/in_game_trades.asm
+++ b/engine/in_game_trades.asm
@@ -87,8 +87,8 @@
INCLUDE "data/trades.asm"
InGameTrade_DoTrade: ; 71c07 (1c:5c07)
- xor a
- ld [wd07d],a
+ xor a ; NORMAL_PARTY_MENU
+ ld [wPartyMenuTypeOrMessageID],a
dec a
ld [wUpdateSpritesEnabled],a
call DisplayPartyMenu
@@ -131,7 +131,7 @@
ld [wcf91],a
xor a
ld [wcc49],a
- ld [wcf95],a
+ ld [wRemoveMonFromBox],a
call RemovePokemon
ld a,$80
ld [wcc49],a
--- a/engine/items/items.asm
+++ b/engine/items/items.asm
@@ -450,7 +450,7 @@
ret nz
ld hl,wNumBagItems
inc a
- ld [wcf96],a
+ ld [wItemQuantity],a
jp RemoveItemFromInventory
ItemUseBallText00: ; d937 (3:5937)
;"It dodged the thrown ball!"
@@ -633,8 +633,8 @@
ld a,[wcf91]
ld [wd156],a
push af
- ld a,$05 ; evolution stone party menu
- ld [wd07d],a
+ ld a,EVO_STONE_PARTY_MENU
+ ld [wPartyMenuTypeOrMessageID],a
ld a,$ff
ld [wUpdateSpritesEnabled],a
call DisplayPartyMenu
@@ -655,7 +655,7 @@
ld [wWhichPokemon],a
ld hl,wNumBagItems
ld a,1 ; remove 1 stone
- ld [wcf96],a
+ ld [wItemQuantity],a
jp RemoveItemFromInventory
.noEffect
call ItemUseNoEffect
@@ -678,8 +678,8 @@
push af
ld a,[wcf91]
push af
- ld a,$01
- ld [wd07d],a ; item use party menu
+ ld a,USE_ITEM_PARTY_MENU
+ ld [wPartyMenuTypeOrMessageID],a
ld a,$ff
ld [wUpdateSpritesEnabled],a
ld a,[wd152]
@@ -737,22 +737,22 @@
ld bc,4
add hl,bc ; hl now points to status
ld a,[wcf91]
- ld bc,$f008
+ ld bc, (ANTIDOTE_MSG << 8) | (1 << PSN)
cp a,ANTIDOTE
jr z,.checkMonStatus
- ld bc,$f110
+ ld bc, (BURN_HEAL_MSG << 8) | (1 << BRN)
cp a,BURN_HEAL
jr z,.checkMonStatus
- ld bc,$f220
+ ld bc, (ICE_HEAL_MSG << 8) | (1 << FRZ)
cp a,ICE_HEAL
jr z,.checkMonStatus
- ld bc,$f307
+ ld bc, (AWAKENING_MSG << 8) | SLP
cp a,AWAKENING
jr z,.checkMonStatus
- ld bc,$f440
+ ld bc, (PARALYZ_HEAL_MSG << 8) | (1 << PAR)
cp a,PARLYZ_HEAL
jr z,.checkMonStatus
- ld bc,$f6ff ; Full Heal
+ ld bc, (FULL_HEAL_MSG << 8) | $ff ; Full Heal
.checkMonStatus
ld a,[hl] ; pokemon's status
and c ; does the pokemon have a status ailment the item can cure?
@@ -761,7 +761,7 @@
xor a
ld [hl],a ; remove the status ailment in the party data
ld a,b
- ld [wd07d],a ; the message to display for the item used
+ ld [wPartyMenuTypeOrMessageID],a ; the message to display for the item used
ld a,[wPlayerMonNumber]
cp d ; is pokemon the item was used on active in battle?
jp nz,.doneHealing
@@ -1078,15 +1078,15 @@
ld a,[hFlags_0xFFF6]
res 0,a
ld [hFlags_0xFFF6],a
- ld a,$f7 ; revived message
- ld [wd07d],a
+ ld a,REVIVE_MSG
+ ld [wPartyMenuTypeOrMessageID],a
ld a,[wcf91]
cp a,REVIVE
jr z,.showHealingItemMessage
cp a,MAX_REVIVE
jr z,.showHealingItemMessage
- ld a,$f5 ; standard HP healed message
- ld [wd07d],a
+ ld a,POTION_MSG
+ ld [wPartyMenuTypeOrMessageID],a
jr .showHealingItemMessage
.playStatusAilmentCuringSound
ld a,(SFX_02_3e - SFX_Headers_02) / 3 ; status ailment curing sound
@@ -1257,8 +1257,8 @@
ld a,[hl]
adc b
ld [hl],a
- ld a,$f8 ; level up message
- ld [wd07d],a
+ ld a,RARE_CANDY_MSG
+ ld [wPartyMenuTypeOrMessageID],a
call RedrawPartyMenu
pop de
ld a,d
@@ -1878,8 +1878,8 @@
.chooseMon
xor a
ld [wUpdateSpritesEnabled],a
- ld a,$01 ; item use party menu
- ld [wd07d],a
+ ld a,USE_ITEM_PARTY_MENU
+ ld [wPartyMenuTypeOrMessageID],a
call DisplayPartyMenu
jr nc,.chooseMove
jp .itemNotUsed
@@ -2118,8 +2118,8 @@
call CopyData
ld a,$ff
ld [wUpdateSpritesEnabled],a
- ld a,$03 ; teach TM/HM party menu
- ld [wd07d],a
+ ld a,TMHM_PARTY_MENU
+ ld [wPartyMenuTypeOrMessageID],a
call DisplayPartyMenu
push af
ld hl,wd036
@@ -2193,7 +2193,7 @@
RemoveUsedItem: ; e571 (3:6571)
ld hl,wNumBagItems
ld a,1 ; one item
- ld [wcf96],a ; store quantity
+ ld [wItemQuantity],a
jp RemoveItemFromInventory
ItemUseNoEffect: ; e57c (3:657c)
@@ -2464,7 +2464,7 @@
; hl = address of inventory (either wNumBagItems or wNumBoxItems)
; [wcf91] = item ID
; [wWhichPokemon] = index of item within inventory
-; [wcf96] = quantity to toss
+; [wItemQuantity] = quantity to toss
; OUTPUT:
; clears carry flag if the item is tossed, sets carry flag if not
TossItem_: ; e6f1 (3:66f1)
@@ -2475,7 +2475,7 @@
jr c,.tooImportantToToss
push hl
call IsKeyItem_
- ld a,[wd124]
+ ld a,[wIsKeyItem]
pop hl
and a
jr nz,.tooImportantToToss
@@ -2491,11 +2491,11 @@
ld a,TWO_OPTION_MENU
ld [wTextBoxID],a
call DisplayTextBoxID ; yes/no menu
- ld a,[wd12e]
- cp a,2
+ ld a,[wMenuExitMethod]
+ cp a,CHOSE_SECOND_ITEM
pop hl
scf
- ret z
+ ret z ; return if the player chose No
; if the player chose Yes
push hl
ld a,[wWhichPokemon]
@@ -2533,12 +2533,12 @@
; INPUT:
; [wcf91] = item ID
; OUTPUT:
-; [wd124] = result
+; [wIsKeyItem] = result
; 00: item is not key item
; 01: item is key item
IsKeyItem_: ; e764 (3:6764)
ld a,$01
- ld [wd124],a
+ ld [wIsKeyItem],a
ld a,[wcf91]
cp a,HM_01 ; is the item an HM or TM?
jr nc,.checkIfItemIsHM
@@ -2562,7 +2562,7 @@
call IsItemHM
ret c
xor a
- ld [wd124],a
+ ld [wIsKeyItem],a
ret
INCLUDE "data/key_items.asm"
@@ -2650,8 +2650,8 @@
jr nz, .asm_e817
.asm_e82a
ld hl, wBoxMonNicks
- ld a, $2
- ld [wd07d], a
+ ld a, NAME_MON_SCREEN
+ ld [wNamingScreenType], a
predef AskName
ld a, [W_NUMINBOX]
dec a
--- a/engine/menu/bills_pc.asm
+++ b/engine/menu/bills_pc.asm
@@ -229,11 +229,11 @@
ld a, [wcf91]
call GetCryData
call PlaySoundWaitForCurrent
- ld a, $1
- ld [wcf95], a
- call Func_3a68
+ ld a, PARTY_TO_BOX
+ ld [wMoveMonType], a
+ call MoveMon
xor a
- ld [wcf95], a
+ ld [wRemoveMonFromBox], a
call RemovePokemon
call WaitForSoundToFinish
ld hl, wWhichTrade
@@ -281,11 +281,11 @@
ld a, [wcf91]
call GetCryData
call PlaySoundWaitForCurrent
- xor a
- ld [wcf95], a
- call Func_3a68
- ld a, $1
- ld [wcf95], a
+ xor a ; BOX_TO_PARTY
+ ld [wMoveMonType], a
+ call MoveMon
+ ld a, 1
+ ld [wRemoveMonFromBox], a
call RemovePokemon
call WaitForSoundToFinish
ld hl, MonIsTakenOutText
@@ -310,7 +310,7 @@
and a
jr nz, .asm_21682
inc a
- ld [wcf95], a
+ ld [wRemoveMonFromBox], a
call RemovePokemon
call WaitForSoundToFinish
ld a, [wcf91]
@@ -329,7 +329,7 @@
ld a, h
ld [wList + 1], a
xor a
- ld [wcf93], a
+ ld [wPrintItemPrices], a
ld [wListMenuID], a
inc a ; MONSTER_NAME
ld [wNameListType], a
--- a/engine/menu/diploma.asm
+++ b/engine/menu/diploma.asm
@@ -56,7 +56,7 @@
call Delay3
call GBPalNormal
ld a, $90
- ld [$ff48], a
+ ld [rOBP0], a
call WaitForTextScrollButtonPress
ld hl, wd730
res 6, [hl]
--- a/engine/menu/naming_screen.asm
+++ b/engine/menu/naming_screen.asm
@@ -27,8 +27,8 @@
xor a
ld [wUpdateSpritesEnabled], a
push hl
- ld a, $2
- ld [wd07d], a
+ ld a, NAME_MON_SCREEN
+ ld [wNamingScreenType], a
call DisplayNamingScreen
ld a, [W_ISINBATTLE]
and a
@@ -53,12 +53,12 @@
TX_FAR _DoYouWantToNicknameText
db "@"
-Func_655c: ; 655c (1:655c)
+DisplayNameRaterScreen: ; 655c (1:655c)
ld hl, wHPBarMaxHP
xor a
ld [wUpdateSpritesEnabled], a
- ld a, $2
- ld [wd07d], a
+ ld a, NAME_MON_SCREEN
+ ld [wNamingScreenType], a
call DisplayNamingScreen
call GBPalWhiteOutWithDelay3
call RestoreScreenTilesAndReloadTilePatterns
@@ -114,7 +114,7 @@
ld hl, wHPBarMaxHP + 1
ld [hli], a
ld [hli], a
- ld [wPartyMonAnimCounter], a
+ ld [wAnimCounter], a
.asm_65ed
call PrintAlphabet
call GBPalNormal
@@ -236,8 +236,8 @@
cp $e4
ld de, Handakutens
jr z, .asm_66e3
- ld a, [wd07d]
- cp $2
+ ld a, [wNamingScreenType]
+ cp NAME_MON_SCREEN
jr nc, .checkMonNameLength
ld a, [wHPBarMaxHP]
cp $7 ; max length of player/rival names
@@ -377,8 +377,8 @@
ld de, wcf4b
call PlaceString
hlCoord 10, 3
- ld a, [wd07d]
- cp $2
+ ld a, [wNamingScreenType]
+ cp NAME_MON_SCREEN
jr nc, .asm_6835
ld b, $7
jr .asm_6837
@@ -390,8 +390,8 @@
ld [hli], a
dec b
jr nz, .asm_6839
- ld a, [wd07d]
- cp $2
+ ld a, [wNamingScreenType]
+ cp NAME_MON_SCREEN
ld a, [wHPBarMaxHP]
jr nc, .asm_684b
cp $7
@@ -405,8 +405,8 @@
ld [wTopMenuItemX], a
ld a, $5
ld [wCurrentMenuItem], a
- ld a, [wd07d]
- cp $2
+ ld a, [wNamingScreenType]
+ cp NAME_MON_SCREEN
ld a, $9
jr nc, .asm_6867
ld a, $6
@@ -462,7 +462,7 @@
PrintNamingText: ; 68f8 (1:68f8)
hlCoord 0, 1
- ld a, [wd07d]
+ ld a, [wNamingScreenType]
ld de, YourTextString
and a
jr z, .notNickname
--- a/engine/menu/party_menu.asm
+++ b/engine/menu/party_menu.asm
@@ -1,4 +1,4 @@
-; [wd07d] = menu type / message ID
+; [wPartyMenuTypeOrMessageID] = menu type / message ID
; if less than $F0, it is a menu type
; menu types:
; 00: normal pokemon menu (e.g. Start menu)
@@ -25,11 +25,11 @@
callba LoadMonPartySpriteGfxWithLCDDisabled ; load pokemon icon graphics
RedrawPartyMenu_: ; 12ce3 (4:6ce3)
- ld a,[wd07d]
- cp a,$04
+ ld a,[wPartyMenuTypeOrMessageID]
+ cp a,SWAP_MONS_PARTY_MENU
jp z,.printMessage
call ErasePartyMenuCursors
- callba SendBlkPacket_PartyMenu ; loads some data to wcf2e
+ callba SendBlkPacket_PartyMenu
hlCoord 3, 0
ld de,wPartySpecies
xor a
@@ -75,10 +75,10 @@
inc hl
inc hl
.skipUnfilledRightArrow
- ld a,[wd07d] ; menu type
- cp a,$03
+ ld a,[wPartyMenuTypeOrMessageID] ; menu type
+ cp a,TMHM_PARTY_MENU
jr z,.teachMoveMenu
- cp a,$05
+ cp a,EVO_STONE_PARTY_MENU
jr z,.evolutionStoneMenu
push hl
ld bc,14 ; 14 columns to the right
@@ -196,7 +196,7 @@
push af
push hl
set 6,[hl] ; turn off letter printing delay
- ld a,[wd07d] ; message ID
+ ld a,[wPartyMenuTypeOrMessageID] ; message ID
cp a,$F0
jr nc,.printItemUseMessage
add a
--- a/engine/menu/pc.asm
+++ b/engine/menu/pc.asm
@@ -135,7 +135,7 @@
jr .asm_17f40
.asm_17f4f
ld a, $1
- ld [wcf96], a
+ ld [wItemQuantity], a
ld a, [$ffdc]
ld [wWhichPokemon], a
ld hl, wNumBagItems
--- a/engine/menu/players_pc.asm
+++ b/engine/menu/players_pc.asm
@@ -101,7 +101,7 @@
ld a, h
ld [wList + 1], a
xor a
- ld [wcf93], a
+ ld [wPrintItemPrices], a
ld a, $3
ld [wListMenuID], a
call DisplayListMenuID
@@ -108,8 +108,8 @@
jp c, Func_790c
call IsKeyItem
ld a, $1
- ld [wcf96], a
- ld a, [wd124]
+ ld [wItemQuantity], a
+ ld a, [wIsKeyItem]
and a
jr nz, .asm_79e7
ld hl, DepositHowManyText
@@ -155,7 +155,7 @@
ld a, h
ld [wList + 1], a
xor a
- ld [wcf93], a
+ ld [wPrintItemPrices], a
ld a, $3
ld [wListMenuID], a
call DisplayListMenuID
@@ -162,8 +162,8 @@
jp c, Func_790c
call IsKeyItem
ld a, $1
- ld [wcf96], a
- ld a, [wd124]
+ ld [wItemQuantity], a
+ ld a, [wIsKeyItem]
and a
jr nz, .asm_7a64
ld hl, WithdrawHowManyText
@@ -209,7 +209,7 @@
ld a, h
ld [wList + 1], a
xor a
- ld [wcf93], a
+ ld [wPrintItemPrices], a
ld a, $3
ld [wListMenuID], a
push hl
@@ -220,8 +220,8 @@
call IsKeyItem
pop hl
ld a, $1
- ld [wcf96], a
- ld a, [wd124]
+ ld [wItemQuantity], a
+ ld a, [wIsKeyItem]
and a
jr nz, .asm_7aef
ld a, [wcf91]
--- a/engine/menu/pokedex.asm
+++ b/engine/menu/pokedex.asm
@@ -22,7 +22,7 @@
xor a
ld [hli],a ; top menu item X
inc a
- ld [wcc37],a
+ ld [wMenuWatchMovingOutOfBounds],a
inc hl
inc hl
ld a,6
@@ -32,7 +32,7 @@
jr c,.goToSideMenu ; if the player chose a pokemon from the list
.exitPokedex
xor a
- ld [wcc37],a
+ ld [wMenuWatchMovingOutOfBounds],a
ld [wCurrentMenuItem],a
ld [wLastMenuItem],a
ld [hJoy7],a
@@ -91,7 +91,7 @@
ld [hli],a ; menu watched keys (A button and B button)
xor a
ld [hli],a ; old menu item ID
- ld [wcc37],a
+ ld [wMenuWatchMovingOutOfBounds],a
.handleMenuInput
call HandleMenuInput
bit 1,a ; was the B button pressed?
--- a/engine/menu/start_sub_menus.asm
+++ b/engine/menu/start_sub_menus.asm
@@ -12,7 +12,7 @@
jp z,RedisplayStartMenu
xor a
ld [wMenuItemToSwap],a
- ld [wd07d],a
+ ld [wPartyMenuTypeOrMessageID],a
ld [wUpdateSpritesEnabled],a
call DisplayPartyMenu
jr .checkIfPokemonChosen
@@ -19,7 +19,7 @@
.loop
xor a
ld [wMenuItemToSwap],a
- ld [wd07d],a
+ ld [wPartyMenuTypeOrMessageID],a
call GoBackToPartyMenu
.checkIfPokemonChosen
jr nc,.chosePokemon
@@ -89,8 +89,8 @@
cp a,2 ; is there more than one pokemon in the party?
jp c,StartMenu_Pokemon ; if not, no switching
call SwitchPartyMon_Stats
- ld a,$04 ; swap pokemon positions menu
- ld [wd07d],a
+ ld a,SWAP_MONS_PARTY_MENU
+ ld [wPartyMenuTypeOrMessageID],a
call GoBackToPartyMenu
jp .checkIfPokemonChosen
.choseStats
@@ -313,7 +313,7 @@
ld [hli],a
ld [hl],b ; store item bag pointer at wList (for DisplayListMenuID)
xor a
- ld [wcf93],a
+ ld [wPrintItemPrices],a
ld a,ITEMLISTMENU
ld [wListMenuID],a
ld a,[wcc2c]
@@ -423,7 +423,7 @@
jp ItemMenuLoop
.tossItem
call IsKeyItem
- ld a,[wd124]
+ ld a,[wIsKeyItem]
and a
jr nz,.skipAskingQuantity
ld a,[wcf91]
@@ -747,7 +747,7 @@
ret
.asm_13661
xor a
- ld [wd07d], a
+ ld [wPartyMenuTypeOrMessageID], a
ld a, [wMenuItemToSwap]
dec a
ld b, a
@@ -757,7 +757,7 @@
jr nz, .asm_1367b
xor a
ld [wMenuItemToSwap], a
- ld [wd07d], a
+ ld [wPartyMenuTypeOrMessageID], a
ret
.asm_1367b
ld a, b
@@ -845,7 +845,7 @@
ld [wWhichTrade], a
xor a
ld [wMenuItemToSwap], a
- ld [wd07d], a
+ ld [wPartyMenuTypeOrMessageID], a
pop de
pop hl
ret
--- a/engine/mon_party_sprites.asm
+++ b/engine/mon_party_sprites.asm
@@ -27,7 +27,7 @@
ld c, a
add a
ld b, a
- ld a, [wPartyMonAnimCounter]
+ ld a, [wAnimCounter]
and a
jr z, .resetSprites
cp c
@@ -38,7 +38,7 @@
jr nz, .skipResetTimer
xor a ; reset timer
.skipResetTimer
- ld [wPartyMonAnimCounter], a
+ ld [wAnimCounter], a
jp DelayFrame
.resetSprites
push bc
@@ -315,7 +315,7 @@
add hl, de
ld a, [hl]
call GetPartyMonSpriteID
- ld [wcd5b], a
+ ld [wOAMBaseTile], a
call WriteMonPartySpriteOAM
pop bc
pop de
@@ -329,7 +329,7 @@
ld [hPartyMonIndex], a
ld a, [wMonPartySpriteSpecies]
call GetPartyMonSpriteID
- ld [wcd5b], a
+ ld [wOAMBaseTile], a
jr WriteMonPartySpriteOAM
UnusedPartyMonSpriteFunction: ; 71890 (1c:5890)
--- a/engine/oak_speech.asm
+++ b/engine/oak_speech.asm
@@ -46,7 +46,7 @@
ld a,POTION
ld [wcf91],a
ld a,1
- ld [wcf96],a
+ ld [wItemQuantity],a
call AddItemToInventory ; give one potion
ld a,[W_ANIMATIONID]
ld [wDestinationMap],a
--- a/engine/oak_speech2.asm
+++ b/engine/oak_speech2.asm
@@ -12,8 +12,8 @@
jr .asm_6999
.asm_697a
ld hl, wPlayerName
- xor a
- ld [wd07d], a
+ xor a ; NAME_PLAYER_SCREEN
+ ld [wNamingScreenType], a
call DisplayNamingScreen
ld a, [wcf4b]
cp $50
@@ -45,8 +45,8 @@
jr .asm_69e1
.asm_69c1
ld hl, W_RIVALNAME
- ld a, $1
- ld [wd07d], a
+ ld a, NAME_RIVAL_SCREEN
+ ld [wNamingScreenType], a
call DisplayNamingScreen
ld a, [wcf4b]
cp $50
--- a/engine/overworld/pokemart.asm
+++ b/engine/overworld/pokemart.asm
@@ -1,9 +1,9 @@
DisplayPokemartDialogue_: ; 6c20 (1:6c20)
ld a,[wListScrollOffset]
- ld [wd07e],a
+ ld [wSavedListScrollOffset],a
call UpdateSprites
xor a
- ld [wcf0a],a ; flag that is set if something is sold or bought
+ ld [wBoughtOrSoldItemInMart],a
.loop
xor a
ld [wListScrollOffset],a
@@ -10,21 +10,25 @@
ld [wCurrentMenuItem],a
ld [wPlayerMonNumber],a
inc a
- ld [wcf93],a
+ ld [wPrintItemPrices],a
ld a,MONEY_BOX
ld [wTextBoxID],a
- call DisplayTextBoxID ; draw money text box
+ call DisplayTextBoxID
ld a,BUY_SELL_QUIT_MENU
ld [wTextBoxID],a
- call DisplayTextBoxID ; do buy/sell/quit menu
- ld hl,wd128 ; pointer to this pokemart's inventory
+ 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 ; hl = address of inventory
- ld a,[wd12e]
- cp a,$02
+ ld h,a
+
+ ld a,[wMenuExitMethod]
+ cp a,CANCELLED_MENU
jp z,.done
- ld a,[wd12d] ; ID of the chosen menu item
+ ld a,[wChosenMenuItem]
and a ; buying?
jp z,.buyMenu
dec a ; selling?
@@ -32,11 +36,14 @@
dec a ; quitting?
jp z,.done
.sellMenu
+
+; the same variables are set again below, so this code has no effect
xor a
- ld [wcf93],a
- ld a,$02
- ld [wd11b],a
+ ld [wPrintItemPrices],a
+ ld a,INIT_BAG_ITEM_LIST
+ ld [wInitListType],a
callab InitList
+
ld a,[wNumBagItems]
and a
jp z,.bagEmpty
@@ -54,7 +61,7 @@
ld a,h
ld [wList + 1],a
xor a
- ld [wcf93],a
+ ld [wPrintItemPrices],a
ld [wCurrentMenuItem],a
ld a,ITEMLISTMENU
ld [wListMenuID],a
@@ -61,8 +68,8 @@
call DisplayListMenuID
jp c,.returnToMainPokemartMenu ; if the player closed the menu
.confirmItemSale ; if the player is trying to sell a specific item
- call IsKeyItem ; check if item is unsellable
- ld a,[wd124]
+ call IsKeyItem
+ ld a,[wIsKeyItem]
and a
jr nz,.unsellableItem
ld a,[wcf91]
@@ -70,7 +77,7 @@
jr c,.unsellableItem
ld a,PRICEDITEMLISTMENU
ld [wListMenuID],a
- ld [$ff8e],a ; halve prices when selling
+ 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
@@ -82,18 +89,22 @@
ld a,TWO_OPTION_MENU
ld [wTextBoxID],a
call DisplayTextBoxID ; yes/no menu
- ld a,[wd12e]
- cp a,$02
- jr z,.sellMenuLoop ; if the player pressed the B button
- ld a,[wd12d] ; ID of the chosen menu item
+ ld a,[wMenuExitMethod]
+ cp a,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]
dec a
- jr z,.sellMenuLoop ; if the player chose No
+ jr z,.sellMenuLoop
+
.sellItem
- ld a,[wcf0a] ; flag that is set if something is sold or bought
+ ld a,[wBoughtOrSoldItemInMart]
and a
jr nz,.skipSettingFlag1
inc a
- ld [wcf0a],a
+ ld [wBoughtOrSoldItemInMart],a
.skipSettingFlag1
call AddAmountSoldToMoney
ld hl,wNumBagItems
@@ -106,22 +117,25 @@
.bagEmpty
ld hl,PokemartItemBagEmptyText
call PrintText
- call SaveScreenTilesToBuffer1 ; save screen
+ call SaveScreenTilesToBuffer1
jp .returnToMainPokemartMenu
.buyMenu
- ld a,$01
- ld [wcf93],a
- ld a,$03
- ld [wd11b],a
+
+; 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
callab InitList
+
ld hl,PokemartBuyingGreetingText
call PrintText
- call SaveScreenTilesToBuffer1 ; save screen
+ call SaveScreenTilesToBuffer1
.buyMenuLoop
- call LoadScreenTilesFromBuffer1 ; restore saved screen
+ call LoadScreenTilesFromBuffer1
ld a,MONEY_BOX
ld [wTextBoxID],a
- call DisplayTextBoxID ; draw money text box
+ call DisplayTextBoxID
ld hl,wStringBuffer2 + 11
ld a,l
ld [wList],a
@@ -130,15 +144,15 @@
xor a
ld [wCurrentMenuItem],a
inc a
- ld [wcf93],a
+ ld [wPrintItemPrices],a
inc a ; a = 2 (PRICEDITEMLISTMENU)
ld [wListMenuID],a
call DisplayListMenuID
jr c,.returnToMainPokemartMenu ; if the player closed the menu
- ld a,$63
- ld [wcf97],a
+ ld a,99
+ ld [wMaxItemQuantity],a
xor a
- ld [$ff8e],a
+ 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
@@ -153,12 +167,16 @@
ld a,TWO_OPTION_MENU
ld [wTextBoxID],a
call DisplayTextBoxID ; yes/no menu
- ld a,[wd12e]
- cp a,$02
- jp z,.buyMenuLoop ; if the player pressed the B button
- ld a,[wd12d] ; ID of the chosen menu item
+ ld a,[wMenuExitMethod]
+ cp a,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]
dec a
- jr z,.buyMenuLoop ; if the player chose No
+ jr z,.buyMenuLoop
+
.buyItem
call .isThereEnoughMoney
jr c,.notEnoughMoney
@@ -166,11 +184,11 @@
call AddItemToInventory
jr nc,.bagFull
call SubtractAmountPaidFromMoney
- ld a,[wcf0a] ; flag that is set if something is sold or bought
+ ld a,[wBoughtOrSoldItemInMart]
and a
jr nz,.skipSettingFlag2
- ld a,$01
- ld [wcf0a],a
+ ld a,1
+ ld [wBoughtOrSoldItemInMart],a
.skipSettingFlag2
ld a,(SFX_02_5a - SFX_Headers_02) / 3
call PlaySoundWaitForCurrent
@@ -182,7 +200,7 @@
call LoadScreenTilesFromBuffer1
ld a,MONEY_BOX
ld [wTextBoxID],a
- call DisplayTextBoxID ; draw money text box
+ call DisplayTextBoxID
ld hl,PokemartAnythingElseText
call PrintText
jp .loop
@@ -202,10 +220,10 @@
.done
ld hl,PokemartThankYouText
call PrintText
- ld a,$01
+ ld a,1
ld [wUpdateSpritesEnabled],a
call UpdateSprites
- ld a,[wd07e]
+ ld a,[wSavedListScrollOffset]
ld [wListScrollOffset],a
ret
--- a/engine/predefs.asm
+++ b/engine/predefs.asm
@@ -85,10 +85,10 @@
dbw $03,GiveItem
add_predef ChangeBGPalColor0_4Frames
add_predef FindPathToPlayer
- add_predef Func_480ff
+ add_predef PredefShakeScreenVertically
add_predef CalcPositionOfPlayerRelativeToNPC
add_predef ConvertNPCMovementDirectionsToJoypadMasks
- add_predef Func_48125
+ add_predef PredefShakeScreenHorizontally
add_predef UpdateHPBar
add_predef HPBarLength
add_predef Diploma_TextBoxBorder
--- a/engine/predefs12.asm
+++ b/engine/predefs12.asm
@@ -11,55 +11,61 @@
ld [rBGP], a
ret
-Func_480ff: ; 480ff (12:40ff)
+PredefShakeScreenVertically: ; 480ff (12:40ff)
+; Moves the window down and then back in a sequence of progressively smaller
+; numbers of pixels, starting at b.
call GetPredefRegisters
- ld a, $1
- ld [wd0a0], a
+ ld a, 1
+ ld [wDisableVBlankWYUpdate], a
xor a
-.asm_48108
- ld [H_NUMTOPRINT], a ; (aliases: H_MULTIPLICAND)
- call Func_48119
- call Func_48119
+.loop
+ ld [$ff96], a
+ call .MutateWY
+ call .MutateWY
dec b
ld a, b
- jr nz, .asm_48108
+ jr nz, .loop
xor a
- ld [wd0a0], a
+ ld [wDisableVBlankWYUpdate], a
ret
-Func_48119: ; 48119 (12:4119)
- ld a, [H_NUMTOPRINT] ; (aliases: H_MULTIPLICAND)
+.MutateWY ; 48119 (12:4119)
+ ld a, [$ff96]
xor b
- ld [H_NUMTOPRINT], a ; (aliases: H_MULTIPLICAND)
+ ld [$ff96], a
ld [rWY], a
ld c, 3
jp DelayFrames
-Func_48125: ; 48125 (12:4125)
+PredefShakeScreenHorizontally: ; 48125 (12:4125)
+; Moves the window right and then back in a sequence of progressively smaller
+; numbers of pixels, starting at b.
call GetPredefRegisters
xor a
-.asm_48129
+.loop
ld [$ff97], a
- call Func_4813f
+ call .MutateWX
ld c, 1
call DelayFrames
- call Func_4813f
+ call .MutateWX
dec b
ld a, b
- jr nz, .asm_48129
- ld a, $7
+ jr nz, .loop
+
+; restore normal WX
+ ld a, 7
ld [rWX], a
ret
-Func_4813f: ; 4813f (12:413f)
+.MutateWX ; 4813f (12:413f)
ld a, [$ff97]
xor b
ld [$ff97], a
bit 7, a
- jr z, .asm_48149
- xor a
-.asm_48149
- add $7
+ jr z, .skipZeroing
+ xor a ; zero a if it's negative
+.skipZeroing
+ add 7
ld [rWX], a
ld c, 4
jp DelayFrames
--- a/engine/predefs7.asm
+++ b/engine/predefs7.asm
@@ -11,7 +11,7 @@
xor a
ld [wCurrentMenuItem], a
ld [wListScrollOffset], a
- ld [wcf93], a
+ ld [wPrintItemPrices], a
ld a, $4
ld [wListMenuID], a
call DisplayListMenuID
--- a/engine/save.asm
+++ b/engine/save.asm
@@ -421,7 +421,7 @@
ld a, $c
ld [wTopMenuItemX], a
xor a
- ld [wcc37], a
+ ld [wMenuWatchMovingOutOfBounds], a
ld a, [wd5a0]
and $7f
ld [wCurrentMenuItem], a
--- a/engine/slot_machine.asm
+++ b/engine/slot_machine.asm
@@ -10,13 +10,13 @@
call YesNoChoice
ld a, [wCurrentMenuItem]
and a
- jr nz, .skip
+ jr nz, .done ; if player chose No
dec a
ld [wUpdateSpritesEnabled], a
- ld hl, wcd4f
+ ld hl, wSlotMachineRerollCounter
xor a
ld [hli], a
- ld [hl], $2
+ ld [hl], SMILE_BUBBLE
predef EmotionBubble
call GBPalWhiteOutWithDelay3
call LoadSlotMachineTiles
@@ -25,12 +25,12 @@
call GoPAL_SET
call GBPalNormal
ld a, $e4
- ld [$ff48], a
+ ld [rOBP0], a
ld hl, wd730
set 6, [hl]
xor a
- ld [W_SUBANIMSUBENTRYADDR], a
- ld hl, wTrainerSpriteOffset
+ ld [wSlotMachineAllowMatchesCounter], a
+ ld hl, wStoppingWhichSlotMachineWheel
ld bc, $0014
call FillMemory
call MainSlotMachineLoop
@@ -37,7 +37,7 @@
ld hl, wd730
res 6, [hl]
xor a
- ld [W_SUBANIMSUBENTRYADDR], a
+ ld [wSlotMachineAllowMatchesCounter], a
call GBPalWhiteOutWithDelay3
ld a, $1
ld [wUpdateSpritesEnabled], a
@@ -44,11 +44,11 @@
call GoPAL_SET_CF1C
call ReloadMapSpriteTilePatterns
call ReloadTilesetTilePatterns
-.skip
+.done
call LoadScreenTilesFromBuffer2
call Delay3
call GBPalNormal
- ld a, [wcc5e]
+ ld a, [wSlotMachineSavedROMBank]
push af
jp CloseTextDisplay
@@ -57,43 +57,43 @@
db "@"
MainSlotMachineLoop: ; 37395 (d:7395)
- call SlotMachine_37754
+ call SlotMachine_PrintCreditCoins
xor a
- ld hl, wcd4a
+ ld hl, wPayoutCoins
ld [hli], a
ld [hl], a
- call SlotMachine_3775f
+ call SlotMachine_PrintPayoutCoins
ld hl, BetHowManySlotMachineText
call PrintText
call SaveScreenTilesToBuffer1
.loop
- ld a, $3
+ ld a, A_BUTTON | B_BUTTON
ld [wMenuWatchedKeys], a
- ld a, $2
+ ld a, 2
ld [wMaxMenuItem], a
- ld a, $c
+ ld a, 12
ld [wTopMenuItemY], a
- ld a, $f
+ ld a, 15
ld [wTopMenuItemX], a
xor a
ld [wCurrentMenuItem], a
ld [wLastMenuItem], a
- ld [wcc37], a
- ld hl, wTileMap + $ea
- ld b, $5
- ld c, $4
+ ld [wMenuWatchMovingOutOfBounds], a
+ hlCoord 14, 11
+ ld b, 5
+ ld c, 4
call TextBoxBorder
- ld hl, wTileMap + $100
+ hlCoord 16, 12
ld de, CoinMultiplierSlotMachineText
call PlaceString
call HandleMenuInput
- and $2
+ and B_BUTTON
jp nz, LoadScreenTilesFromBuffer1
ld a, [wCurrentMenuItem]
ld b, a
- ld a, $3
+ ld a, 3
sub b
- ld [wcd50], a
+ ld [wSlotMachineBet], a
ld hl, wPlayerCoins
ld c, a
ld a, [hli]
@@ -107,11 +107,11 @@
jr .loop
.skip1
call LoadScreenTilesFromBuffer1
- call SlotMachine_37741
- call SlotMachine_377d5
- call SlotMachine_37480
- ld a, $4
- ld hl, wcd4d
+ call SlotMachine_SubtractBetFromPlayerCoins
+ call SlotMachine_LightBalls
+ call SlotMachine_SetFlags
+ ld a, 4
+ ld hl, wSlotMachineWheel1SlipCounter
ld [hli], a
ld [hli], a
ld [hl], a
@@ -120,8 +120,8 @@
call PlaySound
ld hl, StartSlotMachineText
call PrintText
- call SlotMachine_374ad
- call SlotMachine_37588
+ call SlotMachine_SpinWheels
+ call SlotMachine_CheckForMatches
ld hl, wPlayerCoins
ld a, [hli]
or [hl]
@@ -143,7 +143,7 @@
ld a, [wCurrentMenuItem]
and a
ret nz
- call SlotMachine_377ce
+ call SlotMachine_PutOutLitBalls
jp MainSlotMachineLoop
CoinMultiplierSlotMachineText: ; 3745e (d:745e)
@@ -171,43 +171,43 @@
TX_FAR _OneMoreGoSlotMachineText
db "@"
-SlotMachine_37480: ; 37480 (d:7480)
- ld hl, wcd4c
+SlotMachine_SetFlags: ; 37480 (d:7480)
+ ld hl, wSlotMachineFlags
bit 7, [hl]
ret nz
- ld a, [W_SUBANIMSUBENTRYADDR]
+ ld a, [wSlotMachineAllowMatchesCounter]
and a
- jr nz, .skip1
+ jr nz, .allowMatches
call Random
and a
- jr z, .skip2
+ jr z, .setAllowMatchesCounter ; 1/256 (~0.4%) chance
ld b, a
- ld a, [wcc5b]
+ ld a, [wSlotMachineSevenAndBarModeChance]
cp b
- jr c, .skip3
- ld a, $d2
+ jr c, .allowSevenAndBarMatches
+ ld a, 210
cp b
- jr c, .skip1
- ld [hl], $0
+ jr c, .allowMatches ; 55/256 (~21.5%) chance
+ ld [hl], 0
ret
-.skip1
+.allowMatches
set 6, [hl]
ret
-.skip2
- ld a, $3c
- ld [W_SUBANIMSUBENTRYADDR], a
+.setAllowMatchesCounter
+ ld a, 60
+ ld [wSlotMachineAllowMatchesCounter], a
ret
-.skip3
+.allowSevenAndBarMatches
set 7, [hl]
ret
-SlotMachine_374ad: ; 374ad (d:74ad)
+SlotMachine_SpinWheels: ; 374ad (d:74ad)
ld c, 20
.loop1
push bc
- call SlotMachine_37813
- call SlotMachine_37823
- call SlotMachine_37833
+ call SlotMachine_AnimWheel1
+ call SlotMachine_AnimWheel2
+ call SlotMachine_AnimWheel3
ld c, 2
call DelayFrames
pop bc
@@ -214,12 +214,12 @@
dec c
jr nz, .loop1
xor a
- ld [wTrainerSpriteOffset], a
+ ld [wStoppingWhichSlotMachineWheel], a
.loop2
- call SlotMachine_37882
- call SlotMachine_374df
- call SlotMachine_374fb
- call SlotMachine_37517
+ call SlotMachine_HandleInputWhileWheelsSpin
+ call SlotMachine_StopOrAnimWheel1
+ call SlotMachine_StopOrAnimWheel2
+ call SlotMachine_StopOrAnimWheel3
ret c
ld a, [wOnSGB]
xor $1
@@ -228,194 +228,214 @@
call DelayFrames
jr .loop2
-SlotMachine_374df: ; 374df (d:74df)
- ld a, [wTrainerSpriteOffset]
- cp $1
- jr c, .skip
- ld de, wTrainerEngageDistance
+; Note that the wheels can only stop when a symbol is centred in the wheel
+; and thus 3 full symbols rather than 2 full symbols and 2 half symbols are
+; visible. The 3 functions below ensure this by checking if the wheel offset
+; is even before stopping the wheel.
+
+SlotMachine_StopOrAnimWheel1: ; 374df (d:74df)
+ ld a, [wStoppingWhichSlotMachineWheel]
+ cp 1
+ jr c, .animWheel
+ ld de, wSlotMachineWheel1Offset
ld a, [de]
rra
- jr nc, .skip
- ld hl, wcd4d
+ jr nc, .animWheel ; check that a symbol is centred in the wheel
+ ld hl, wSlotMachineWheel1SlipCounter
ld a, [hl]
and a
ret z
dec [hl]
- call SlotMachine_3752c
+ call SlotMachine_StopWheel1Early
ret nz
-.skip
- jp SlotMachine_37813
+.animWheel
+ jp SlotMachine_AnimWheel1
-SlotMachine_374fb: ; 374fb (d:74fb)
- ld a, [wTrainerSpriteOffset]
- cp $2
- jr c, .skip
- ld de, wTrainerFacingDirection
+SlotMachine_StopOrAnimWheel2: ; 374fb (d:74fb)
+ ld a, [wStoppingWhichSlotMachineWheel]
+ cp 2
+ jr c, .animWheel
+ ld de, wSlotMachineWheel2Offset
ld a, [de]
rra
- jr nc, .skip
- ld hl, wcd4e
+ jr nc, .animWheel ; check that a symbol is centred in the wheel
+ ld hl, wSlotMachineWheel2SlipCounter
ld a, [hl]
and a
ret z
dec [hl]
- call SlotMachine_37552
+ call SlotMachine_StopWheel2Early
ret z
-.skip
- jp SlotMachine_37823
+.animWheel
+ jp SlotMachine_AnimWheel2
-SlotMachine_37517: ; 37517 (d:7517)
- ld a, [wTrainerSpriteOffset]
- cp $3
- jr c, .skip
- ld de, wTrainerScreenY
+SlotMachine_StopOrAnimWheel3: ; 37517 (d:7517)
+ ld a, [wStoppingWhichSlotMachineWheel]
+ cp 3
+ jr c, .animWheel
+ ld de, wSlotMachineWheel3Offset
ld a, [de]
rra
- jr nc, .skip
+ jr nc, .animWheel ; check that a symbol is centred in the wheel
+; wheel 3 stops as soon as possible
scf
ret
-.skip
- call SlotMachine_37833
+.animWheel
+ call SlotMachine_AnimWheel3
and a
ret
-SlotMachine_3752c: ; 3752c (d:752c)
- call SlotMachine_GetWheelOneTile
- ld hl, wTrainerScreenX
- ld a, [wcd4c]
+SlotMachine_StopWheel1Early: ; 3752c (d:752c)
+ call SlotMachine_GetWheel1Tiles
+ ld hl, wSlotMachineWheel1BottomTile
+ ld a, [wSlotMachineFlags]
and $80
- jr nz, .skip1
+ jr nz, .sevenAndBarMode
+; Stop early if the middle symbol is not a cherry.
inc hl
ld a, [hl]
- cp $a
- jr nz, .skip2
+ cp SLOTSCHERRY >> 8
+ jr nz, .stopWheel
ret
-.skip1
+; It looks like this was intended to make the wheel stop when a 7 symbol was
+; visible, but it has a bug and so the wheel stops randomly.
+.sevenAndBarMode
ld c, $3
.loop
ld a, [hli]
- cp $2
- jr c, .skip2
+ cp SLOTS7 >> 8
+ jr c, .stopWheel ; condition never true
dec c
jr nz, .loop
ret
-.skip2
+.stopWheel
inc a
- ld hl, wcd4d
- ld [hl], $0
+ ld hl, wSlotMachineWheel1SlipCounter
+ ld [hl], 0
ret
-SlotMachine_37552: ; 37552 (d:7552)
- call SlotMachine_GetWheelTwoTile
- ld a, [wcd4c]
+SlotMachine_StopWheel2Early: ; 37552 (d:7552)
+ call SlotMachine_GetWheel2Tiles
+ ld a, [wSlotMachineFlags]
and $80
- jr nz, .skip1
- call SlotMachine_3756e
+ jr nz, .sevenAndBarMode
+; Stop early if any symbols are lined up in the first two wheels.
+ call SlotMachine_FindWheel1Wheel2Matches
ret nz
- jr .skip2
-.skip1
- call SlotMachine_3756e
+ jr .stopWheel
+; Stop early if two 7 symbols or two bar symbols are lined up in the first two
+; wheels OR if no symbols are lined up and the bottom symbol in wheel 2 is a
+; 7 symbol or bar symbol. The second part could be a bug or a way to reduce the
+; player's odds.
+.sevenAndBarMode
+ call SlotMachine_FindWheel1Wheel2Matches
ld a, [de]
- cp $7
+ cp (SLOTSBAR >> 8) + 1
ret nc
-.skip2
+.stopWheel
xor a
- ld [wcd4e], a
+ ld [wSlotMachineWheel2SlipCounter], a
ret
-SlotMachine_3756e: ; 3756e (d:756e)
- ld hl, wTrainerScreenX
- ld de, wcd44
+SlotMachine_FindWheel1Wheel2Matches: ; 3756e (d:756e)
+; return whether wheel 1 and wheel 2's current positions allow a match (given
+; that wheel 3 stops in a good position) in Z
+ ld hl, wSlotMachineWheel1BottomTile
+ ld de, wSlotMachineWheel2BottomTile
ld a, [de]
- cp [hl]
+ cp [hl] ; wheel 1 bottom, wheel 2 bottom
ret z
inc de
ld a, [de]
- cp [hl]
+ cp [hl] ; wheel 1 bottom, wheel 2 middle
ret z
inc hl
- cp [hl]
+ cp [hl] ; wheel 1 middle, wheel 2 middle
ret z
inc hl
- cp [hl]
+ cp [hl] ; wheel 1 top, wheel 2 middle
ret z
inc de
ld a, [de]
- cp [hl]
+ cp [hl] ; wheel 1 top, wheel 2 top
ret z
dec de
dec de
ret
-SlotMachine_37588: ; 37588 (d:7588)
- call SlotMachine_GetWheelThreeTile
- ld a, [wcd50]
- cp $2
- jr z, .skip1
- cp $1
- jr z, .skip2
- ld hl, wTrainerScreenX
- ld de, wcd45
- ld bc, wcd49
+SlotMachine_CheckForMatches: ; 37588 (d:7588)
+ call SlotMachine_GetWheel3Tiles
+ ld a, [wSlotMachineBet]
+ cp 2
+ jr z, .checkMatchesFor2CoinBet
+ cp 1
+ jr z, .checkMatchFor1CoinBet
+; 3 coin bet allows diagonal matches (plus the matches for 1/2 coin bets)
+ ld hl, wSlotMachineWheel1BottomTile
+ ld de, wSlotMachineWheel2MiddleTile
+ ld bc, wSlotMachineWheel3TopTile
call SlotMachine_CheckForMatch
- jp z, .skip5
- ld hl, wcd43
- ld de, wcd45
- ld bc, wcd47
+ jp z, .foundMatch
+ ld hl, wSlotMachineWheel1TopTile
+ ld de, wSlotMachineWheel2MiddleTile
+ ld bc, wSlotMachineWheel3BottomTile
call SlotMachine_CheckForMatch
- jr z, .skip5
-.skip1
- ld hl, wcd43
- ld de, wcd46
- ld bc, wcd49
+ jr z, .foundMatch
+; 2 coin bet allows top/bottom horizontal matches (plus the match for a 1 coin bet)
+.checkMatchesFor2CoinBet
+ ld hl, wSlotMachineWheel1TopTile
+ ld de, wSlotMachineWheel2TopTile
+ ld bc, wSlotMachineWheel3TopTile
call SlotMachine_CheckForMatch
- jr z, .skip5
- ld hl, wTrainerScreenX
- ld de, wcd44
- ld bc, wcd47
+ jr z, .foundMatch
+ ld hl, wSlotMachineWheel1BottomTile
+ ld de, wSlotMachineWheel2BottomTile
+ ld bc, wSlotMachineWheel3BottomTile
call SlotMachine_CheckForMatch
- jr z, .skip5
-.skip2
- ld hl, wcd42
- ld de, wcd45
- ld bc, wcd48
+ jr z, .foundMatch
+; 1 coin bet only allows a middle horizontal match
+.checkMatchFor1CoinBet
+ ld hl, wSlotMachineWheel1MiddleTile
+ ld de, wSlotMachineWheel2MiddleTile
+ ld bc, wSlotMachineWheel3MiddleTile
call SlotMachine_CheckForMatch
- jr z, .skip5
- ld a, [wcd4c]
+ jr z, .foundMatch
+ ld a, [wSlotMachineFlags]
and $c0
- jr z, .skip3
- ld hl, wcd4f
+ jr z, .noMatch
+ ld hl, wSlotMachineRerollCounter
dec [hl]
- jr nz, .skip4
-.skip3
+ jr nz, .rollWheel3DownByOneSymbol
+.noMatch
ld hl, NotThisTimeText
call PrintText
-.loop
+.done
xor a
ld [wc002], a
ret
-.skip4
- call SlotMachine_37833
+.rollWheel3DownByOneSymbol
+ call SlotMachine_AnimWheel3
call DelayFrame
- call SlotMachine_37833
+ call SlotMachine_AnimWheel3
call DelayFrame
- jp SlotMachine_37588
-.skip5
- ld a, [wcd4c]
+ jp SlotMachine_CheckForMatches
+.foundMatch
+ ld a, [wSlotMachineFlags]
and $c0
- jr z, .skip4
+ jr z, .rollWheel3DownByOneSymbol ; roll wheel if player isn't allowed to win
and $80
- jr nz, .skip6
+ jr nz, .acceptMatch
+; if 7/bar matches aren't enabled and the match was a 7/bar symbol, roll wheel
ld a, [hl]
- cp $7
- jr c, .skip4
-.skip6
+ cp (SLOTSBAR >> 8) + 1
+ jr c, .rollWheel3DownByOneSymbol
+.acceptMatch
ld a, [hl]
sub $2
- ld [wTrainerScreenX], a
+ ld [wSlotMachineWinningSymbol], a
ld hl, SlotRewardPointers
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc
ld a, [hli]
ld e, a
@@ -426,39 +446,39 @@
ld h, [hl]
ld l, a
ld de, wcf4b
- ld bc, $0004
+ ld bc, 4
call CopyData
pop hl
- ld de, .asm_37638
+ ld de, .flashScreenLoop
push de
jp [hl]
-.asm_37638
- ld a, [$ff47]
+.flashScreenLoop
+ ld a, [rBGP]
xor $40
- ld [$ff47], a
+ ld [rBGP], a
ld c, 5
call DelayFrames
dec b
- jr nz, .asm_37638
- ld hl, wcd4a
+ jr nz, .flashScreenLoop
+ ld hl, wPayoutCoins
ld [hl], d
inc hl
ld [hl], e
- call SlotMachine_3775f
- ld hl, SlotsMachineText_37665
+ call SlotMachine_PrintPayoutCoins
+ ld hl, SymbolLinedUpSlotMachineText
call PrintText
call WaitForTextScrollButtonPress
- call SlotMachine_3776b
- call SlotMachine_3775f
+ call SlotMachine_PayCoinsToPlayer
+ call SlotMachine_PrintPayoutCoins
ld a, $e4
- ld [$ff48], a
- jp .loop
+ ld [rOBP0], a
+ jp .done
-SlotsMachineText_37665: ; 37665 (d:7665)
+SymbolLinedUpSlotMachineText: ; 37665 (d:7665)
TX_ASM
push bc
- call SlotMachine_37728
+ call SlotMachine_PrintWinningSymbol
ld hl, LinedUpText
pop bc
inc bc
@@ -510,28 +530,28 @@
cp [hl]
ret
-SlotMachine_GetWheelThreeTile: ; 376a8 (d:76a8)
- ld de, wcd47
+SlotMachine_GetWheel3Tiles: ; 376a8 (d:76a8)
+ ld de, wSlotMachineWheel3BottomTile
ld hl, SlotMachineWheel3
- ld a, [wTrainerScreenY]
- call SlotMachine_GetWheelTile
+ ld a, [wSlotMachineWheel3Offset]
+ call SlotMachine_GetWheelTiles
-SlotMachine_GetWheelTwoTile: ; 376b4 (d:76b4)
- ld de, wcd44
+SlotMachine_GetWheel2Tiles: ; 376b4 (d:76b4)
+ ld de, wSlotMachineWheel2BottomTile
ld hl, SlotMachineWheel2
- ld a, [wTrainerFacingDirection]
- call SlotMachine_GetWheelTile
+ ld a, [wSlotMachineWheel2Offset]
+ call SlotMachine_GetWheelTiles
-SlotMachine_GetWheelOneTile: ; 376c0 (d:76c0)
- ld de, wTrainerScreenX
+SlotMachine_GetWheel1Tiles: ; 376c0 (d:76c0)
+ ld de, wSlotMachineWheel1BottomTile
ld hl, SlotMachineWheel1
- ld a, [wTrainerEngageDistance]
+ ld a, [wSlotMachineWheel1Offset]
-SlotMachine_GetWheelTile: ; 376c9 (d:76c9)
+SlotMachine_GetWheelTiles: ; 376c9 (d:76c9)
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc
- ld c, $3
+ ld c, 3
.loop
ld a, [hli]
ld [de], a
@@ -542,7 +562,7 @@
ret
SlotReward8Func: ; 376d7 (d:76d7)
- ld hl, W_SUBANIMSUBENTRYADDR
+ ld hl, wSlotMachineAllowMatchesCounter
ld a, [hl]
and a
jr z, .skip
@@ -553,7 +573,7 @@
ret
SlotReward15Func: ; 376e5 (d:76e5)
- ld hl, W_SUBANIMSUBENTRYADDR
+ ld hl, wSlotMachineAllowMatchesCounter
ld a, [hl]
and a
jr z, .skip
@@ -567,7 +587,7 @@
ld a, (SFX_1f_42 - SFX_Headers_1f) / 3
call PlaySound
xor a
- ld [wcd4c], a
+ ld [wSlotMachineFlags], a
ld b, $8
ld de, 100
ret
@@ -581,9 +601,9 @@
cp $80
ld a, $0
jr c, .skip
- ld [wcd4c], a
+ ld [wSlotMachineFlags], a
.skip
- ld [W_SUBANIMSUBENTRYADDR], a
+ ld [wSlotMachineAllowMatchesCounter], a
ld b, $14
ld de, 300
ret
@@ -592,26 +612,27 @@
TX_FAR _YeahText
db $0a, "@"
-SlotMachine_37728: ; 37728 (d:7728)
- ld hl, wTileMap + $11a
- ld a, [wTrainerScreenX]
+SlotMachine_PrintWinningSymbol: ; 37728 (d:7728)
+; prints winning symbol and down arrow in text box
+ hlCoord 2, 14
+ ld a, [wSlotMachineWinningSymbol]
add $25
ld [hli], a
inc a
ld [hld], a
inc a
- ld de, $ffec
+ ld de, -SCREEN_WIDTH
add hl, de
ld [hli], a
inc a
ld [hl], a
- ld hl, wTileMap + $152
- ld [hl], $ee
+ hlCoord 18, 16
+ ld [hl], $ee ; down arrow
ret
-SlotMachine_37741: ; 37741 (d:7741)
- ld hl, wcd4b
- ld a, [wcd50]
+SlotMachine_SubtractBetFromPlayerCoins: ; 37741 (d:7741)
+ ld hl, wTempCoins2 + 1
+ ld a, [wSlotMachineBet]
ld [hld], a
xor a
ld [hli], a
@@ -619,136 +640,143 @@
ld c, $2
predef SubBCDPredef
-SlotMachine_37754: ; 37754 (d:7754)
- ld hl, wTileMap + $19
+SlotMachine_PrintCreditCoins: ; 37754 (d:7754)
+ hlCoord 5, 1
ld de, wPlayerCoins
ld c, $2
jp PrintBCDNumber
-SlotMachine_3775f: ; 3775f (d:775f)
- ld hl, wTileMap + $1f
- ld de, wcd4a
- ld bc, $8204
+SlotMachine_PrintPayoutCoins: ; 3775f (d:775f)
+ hlCoord 11, 1
+ ld de, wPayoutCoins
+ ld bc, $8204 ; 2 bytes, 4 digits, leading zeroes
jp PrintNumber
-SlotMachine_3776b: ; 3776b (d:776b)
+SlotMachine_PayCoinsToPlayer: ; 3776b (d:776b)
ld a, $1
ld [wc002], a
call WaitForSoundToFinish
- ld hl, wcd46
+
+; Put 1 in the temp coins variable. This value is added to the player's coins
+; repeatedly so the player can watch the value go up 1 coin at a time.
+ ld hl, wTempCoins1
xor a
ld [hli], a
inc a
ld [hl], a
- ld a, $5
- ld [W_SUBANIMTRANSFORM], a
+
+ ld a, 5
+ ld [wAnimCounter], a
+
+; Subtract 1 from the payout amount and add 1 to the player's coins each
+; iteration until the payout amount reaches 0.
.loop
- ld a, [wcd4b]
+ ld a, [wPayoutCoins + 1]
ld l, a
- ld a, [wcd4a]
+ ld a, [wPayoutCoins]
ld h, a
or l
ret z
- ld de, $ffff
+ ld de, -1
add hl, de
ld a, l
- ld [wcd4b], a
+ ld [wPayoutCoins + 1], a
ld a, h
- ld [wcd4a], a
- ld hl, wcd47
+ ld [wPayoutCoins], a
+ ld hl, wTempCoins1 + 1
ld de, wPlayerCoins + 1
ld c, $2
predef AddBCDPredef
- call SlotMachine_37754
- call SlotMachine_3775f
+ call SlotMachine_PrintCreditCoins
+ call SlotMachine_PrintPayoutCoins
ld a, (SFX_1f_65 - SFX_Headers_1f) / 3
call PlaySound
- ld a, [W_SUBANIMTRANSFORM]
+ ld a, [wAnimCounter]
dec a
jr nz, .skip1
- ld a, [$ff48]
- xor $40
- ld [$ff48], a
- ld a, $5
+ ld a, [rOBP0]
+ xor $40 ; make the slot wheel symbols flash
+ ld [rOBP0], a
+ ld a, 5
.skip1
- ld [W_SUBANIMTRANSFORM], a
- ld a, [wTrainerScreenX]
- cp $7
+ ld [wAnimCounter], a
+ ld a, [wSlotMachineWinningSymbol]
+ cp (SLOTSBAR >> 8) + 1
ld c, 8
jr nc, .skip2
- srl c
+ srl c ; c = 4 (make the the coins transfer faster if the symbol was 7 or bar)
.skip2
call DelayFrames
jr .loop
-SlotMachine_377ce: ; 377ce (d:77ce)
+SlotMachine_PutOutLitBalls: ; 377ce (d:77ce)
ld a, $23
ld [wd08a], a
- jr SlotMachine_377e3
+ jr SlotMachine_UpdateThreeCoinBallTiles
-SlotMachine_377d5: ; 377d5 (d:77d5)
+SlotMachine_LightBalls: ; 377d5 (d:77d5)
ld a, $14
ld [wd08a], a
- ld a, [wcd50]
+ ld a, [wSlotMachineBet]
dec a
- jr z, SlotMachine_377fb
+ jr z, SlotMachine_UpdateOneCoinBallTiles
dec a
- jr z, SlotMachine_377ef
+ jr z, SlotMachine_UpdateTwoCoinBallTiles
-SlotMachine_377e3: ; 377e3 (d:77e3)
- ld hl, wTileMap + $2b
- call SlotMachine_377fe
- ld hl, wTileMap + $cb
- call SlotMachine_377fe
+SlotMachine_UpdateThreeCoinBallTiles: ; 377e3 (d:77e3)
+ hlCoord 3, 2
+ call SlotMachine_UpdateBallTiles
+ hlCoord 3, 10
+ call SlotMachine_UpdateBallTiles
-SlotMachine_377ef: ; 377ef (d:77ef)
- ld hl, wTileMap + $53
- call SlotMachine_377fe
- ld hl, wTileMap + $a3
- call SlotMachine_377fe
+SlotMachine_UpdateTwoCoinBallTiles: ; 377ef (d:77ef)
+ hlCoord 3, 4
+ call SlotMachine_UpdateBallTiles
+ hlCoord 3, 8
+ call SlotMachine_UpdateBallTiles
-SlotMachine_377fb: ; 377fb (d:77fb)
- ld hl, wTileMap + $7b
+SlotMachine_UpdateOneCoinBallTiles: ; 377fb (d:77fb)
+ hlCoord 3, 6
-SlotMachine_377fe: ; 377fe (d:77fe)
+SlotMachine_UpdateBallTiles: ; 377fe (d:77fe)
ld a, [wd08a]
ld [hl], a
- ld bc, $000d
+ ld bc, 13
add hl, bc
ld [hl], a
- ld bc, $0007
+ ld bc, 7
add hl, bc
inc a
ld [hl], a
- ld bc, $000d
+ ld bc, 13
add hl, bc
ld [hl], a
ret
-SlotMachine_37813: ; 37813 (d:7813)
+SlotMachine_AnimWheel1: ; 37813 (d:7813)
ld bc, SlotMachineWheel1
- ld de, wTrainerEngageDistance
+ ld de, wSlotMachineWheel1Offset
ld hl, wOAMBuffer
ld a, $30
ld [W_BASECOORDX], a
- jr SlotMachine_37841
+ jr SlotMachine_AnimWheel
-SlotMachine_37823: ; 37823 (d:7823)
+SlotMachine_AnimWheel2: ; 37823 (d:7823)
ld bc, SlotMachineWheel2
- ld de, wTrainerFacingDirection
+ ld de, wSlotMachineWheel2Offset
ld hl, wOAMBuffer + $30
ld a, $50
ld [W_BASECOORDX], a
- jr SlotMachine_37841
+ jr SlotMachine_AnimWheel
-SlotMachine_37833: ; 37833 (d:7833)
+SlotMachine_AnimWheel3: ; 37833 (d:7833)
ld bc, SlotMachineWheel3
- ld de, wTrainerScreenY
+ ld de, wSlotMachineWheel3Offset
ld hl, wOAMBuffer + $60
ld a, $70
ld [W_BASECOORDX], a
-SlotMachine_37841: ; 37841 (d:7841)
+SlotMachine_AnimWheel: ; 37841 (d:7841)
ld a, $58
ld [W_BASECOORDY], a
push de
@@ -756,10 +784,9 @@
ld d, b
add c
ld e, a
- jr nc, SlotMachine_3784e
+ jr nc, .loop
inc d
-
-SlotMachine_3784e: ; 3784e (d:784e)
+.loop
ld a, [W_BASECOORDY]
ld [hli], a
ld a, [W_BASECOORDX]
@@ -783,30 +810,30 @@
sub $8
ld [W_BASECOORDY], a
cp $28
- jr nz, SlotMachine_3784e
+ jr nz, .loop
pop de
ld a, [de]
- inc a
- cp $1e
+ inc a ; advance the offset so that the wheel animates
+ cp 30
jr nz, .skip
- xor a
+ xor a ; wrap around to 0 when the offset reaches 30
.skip
ld [de], a
ret
-SlotMachine_37882: ; 37882 (d:7882)
+SlotMachine_HandleInputWhileWheelsSpin: ; 37882 (d:7882)
call DelayFrame
call JoypadLowSensitivity
ld a, [hJoy5]
- and $1
+ and A_BUTTON
ret z
- ld hl, wTrainerSpriteOffset
+ ld hl, wStoppingWhichSlotMachineWheel
ld a, [hl]
dec a
- ld de, wcd4d
+ ld de, wSlotMachineWheel1SlipCounter
jr z, .skip
dec a
- ld de, wcd4e
+ ld de, wSlotMachineWheel2SlipCounter
jr z, .skip
.loop
inc [hl]
@@ -845,19 +872,12 @@
ld [hli], a
ld [hli], a
ld [hl], a
- call SlotMachine_37813
- call SlotMachine_37823
- jp SlotMachine_37833
+ call SlotMachine_AnimWheel1
+ call SlotMachine_AnimWheel2
+ jp SlotMachine_AnimWheel3
SlotMachineMap: ; 378f5 (d:78f5)
INCBIN "gfx/tilemaps/slotmachine.map"
-
-SLOTS7 EQU $0200
-SLOTSBAR EQU $0604
-SLOTSCHERRY EQU $0A08
-SLOTSFISH EQU $0E0C
-SLOTSBIRD EQU $1210
-SLOTSMOUSE EQU $1614
INCLUDE "data/slot_machine_wheels.asm"
--- a/engine/titlescreen.asm
+++ b/engine/titlescreen.asm
@@ -348,7 +348,7 @@
jp LoadFrontSpriteByMonIndex
Func_4533: ; 4533 (1:4533)
- ld [$ffbd], a
+ ld [H_AUTOBGTRANSFERDEST + 1], a
jp Delay3
LoadCopyrightAndTextBoxTiles: ; 4538 (1:4538)
--- a/engine/town_map.asm
+++ b/engine/town_map.asm
@@ -10,7 +10,7 @@
ld a, [W_CURMAP]
push af
ld b, $0
- call Func_711c4
+ call DrawPlayerOrBirdSprite ; player sprite
hlCoord 1, 0
ld de, wcd6d
call PlaceString
@@ -23,7 +23,7 @@
ld bc, (BANK(TownMapCursor) << 8) + $04
call CopyVideoDataDouble
xor a
- ld [wWhichTrade], a
+ ld [wWhichTownMapLocation], a
pop af
jr .enterLoop
@@ -32,29 +32,29 @@
ld bc, $114
call ClearScreenArea
ld hl, TownMapOrder
- ld a, [wWhichTrade]
+ ld a, [wWhichTownMapLocation]
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc
ld a, [hl]
.enterLoop
- ld de, wHPBarMaxHP
- call FindTownMapCoords
+ ld de, wTownMapCoords
+ call LoadTownMapEntry
ld a, [de]
push hl
- call SetTownMapOAMCoords
+ call TownMapCoordsToOAMCoords
ld a, $4
- ld [wcd5b], a
+ ld [wOAMBaseTile], a
ld hl, wOAMBuffer + $10
- call Func_71279
+ call WriteTownMapSpriteOAM ; town map cursor sprite
pop hl
ld de, wcd6d
-.asm_70eac
+.copyMapName
ld a, [hli]
ld [de], a
inc de
cp $50
- jr nz, .asm_70eac
+ jr nz, .copyMapName
hlCoord 1, 0
ld de, wcd6d
call PlaceString
@@ -72,35 +72,35 @@
ld a, (SFX_02_3c - SFX_Headers_02) / 3
call PlaySound
bit 6, b
- jr nz, .upPressed
+ jr nz, .pressedUp
bit 7, b
- jr nz, .downPressed
+ jr nz, .pressedDown
xor a
ld [wTownMapSpriteBlinkingEnabled], a
ld [hJoy7], a
- ld [wTownMapSpriteBlinkingCounter], a
+ ld [wAnimCounter], a
call ExitTownMap
pop hl
pop af
ld [hl], a
ret
-.upPressed
- ld a, [wWhichTrade]
+.pressedUp
+ ld a, [wWhichTownMapLocation]
inc a
cp TownMapOrderEnd - TownMapOrder ; number of list items + 1
jr nz, .noOverflow
xor a
.noOverflow
- ld [wWhichTrade], a
+ ld [wWhichTownMapLocation], a
jp .townMapLoop
-.downPressed
- ld a, [wWhichTrade]
+.pressedDown
+ ld a, [wWhichTownMapLocation]
dec a
- cp $ff
+ cp -1
jr nz, .noUnderflow
ld a, TownMapOrderEnd - TownMapOrder - 1 ; number of list items
.noUnderflow
- ld [wWhichTrade], a
+ ld [wWhichTownMapLocation], a
jp .townMapLoop
INCLUDE "data/town_map_order.asm"
@@ -146,7 +146,7 @@
ld hl, vChars1 + $6d0
ld bc, (BANK(TownMapUpArrow) << 8) + $01
call CopyVideoDataDouble
- call SetupVisitedTownsList
+ call BuildFlyLocationsList
ld hl, wUpdateSpritesEnabled
ld a, [hl]
push af
@@ -157,10 +157,9 @@
call PlaceString
ld a, [W_CURMAP]
ld b, $0
- call Func_711c4
- ld hl, wTrainerEngageDistance
+ call DrawPlayerOrBirdSprite
+ ld hl, wFlyLocationsList
deCoord 18, 0
-
.townMapFlyLoop
ld a, $7f
ld [de], a
@@ -172,7 +171,7 @@
pop hl
ld a, [hl]
ld b, $4
- call Func_711c4
+ call DrawPlayerOrBirdSprite ; draw bird sprite
hlCoord 3, 0
ld de, wcd6d
call PlaceString
@@ -193,15 +192,15 @@
and A_BUTTON | B_BUTTON | D_UP | D_DOWN
jr z, .inputLoop
bit 0, b
- jr nz, .aButtonPressed
+ jr nz, .pressedA
ld a, (SFX_02_3c - SFX_Headers_02) / 3
call PlaySound
bit 6, b
- jr nz, .upPressed
+ jr nz, .pressedUp
bit 7, b
- jr nz, .downPressed
- jr .bButtonPressed
-.aButtonPressed
+ jr nz, .pressedDown
+ jr .pressedB
+.pressedA
ld a, (SFX_02_3e - SFX_Headers_02) / 3
call PlaySound
ld a, [hl]
@@ -210,7 +209,7 @@
set 3, [hl]
inc hl
set 7, [hl]
-.bButtonPressed
+.pressedB
xor a
ld [wTownMapSpriteBlinkingEnabled], a
call GBPalWhiteOutWithDelay3
@@ -218,36 +217,36 @@
pop af
ld [hl], a
ret
-.upPressed
+.pressedUp
deCoord 18, 0
inc hl
ld a, [hl]
cp $ff
- jr z, .asm_71052
+ jr z, .wrapToStartOfList
cp $fe
- jr z, .upPressed
+ jr z, .pressedUp ; skip past unvisited towns
jp .townMapFlyLoop
-.asm_71052
- ld hl, wTrainerEngageDistance
+.wrapToStartOfList
+ ld hl, wFlyLocationsList
jp .townMapFlyLoop
-.downPressed
+.pressedDown
deCoord 19, 0
dec hl
ld a, [hl]
cp $ff
- jr z, .asm_71068
+ jr z, .wrapToEndOfList
cp $fe
- jr z, .downPressed
+ jr z, .pressedDown ; skip past unvisited towns
jp .townMapFlyLoop
-.asm_71068
- ld hl, wcd49
- jr .downPressed
+.wrapToEndOfList
+ ld hl, wFlyLocationsList + 11
+ jr .pressedDown
ToText: ; 7106d (1c:506d)
db "To@"
-SetupVisitedTownsList: ; 71070 (1c:5070)
- ld hl, wWhichTrade
+BuildFlyLocationsList: ; 71070 (1c:5070)
+ ld hl, wFlyLocationsList - 1
ld [hl], $ff
inc hl
ld a, [W_TOWNVISITEDFLAG]
@@ -258,9 +257,9 @@
.loop
srl d
rr e
- ld a, $fe
+ ld a, $fe ; store $fe if the town hasn't been visited
jr nc, .notVisited
- ld a, b
+ ld a, b ; store the map number of the town if it has been visited
.notVisited
ld [hl], a
inc hl
@@ -305,10 +304,10 @@
swap a
and $f
add $60
-.uncompressTile
+.writeRunLoop
ld [hli], a
dec c
- jr nz, .uncompressTile
+ jr nz, .writeRunLoop
inc de
jr .nextTile
.done
@@ -318,7 +317,7 @@
call Delay3
call GBPalNormal
xor a
- ld [wTownMapSpriteBlinkingCounter], a
+ ld [wAnimCounter], a
inc a
ld [wTownMapSpriteBlinkingEnabled], a
ret
@@ -328,6 +327,7 @@
INCBIN "gfx/town_map.rle"
ExitTownMap: ; 711ab (1c:51ab)
+; clear town map graphics data and load usual graphics data
xor a
ld [wTownMapSpriteBlinkingEnabled], a
call GBPalWhiteOut
@@ -338,17 +338,19 @@
call UpdateSprites
jp GoPAL_SET_CF1C
-Func_711c4: ; 711c4 (1c:51c4)
+DrawPlayerOrBirdSprite: ; 711c4 (1c:51c4)
+; a = map number
+; b = OAM base tile
push af
ld a, b
- ld [wcd5b], a
+ ld [wOAMBaseTile], a
pop af
- ld de, wHPBarMaxHP
- call FindTownMapCoords
+ ld de, wTownMapCoords
+ call LoadTownMapEntry
ld a, [de]
push hl
- call SetTownMapOAMCoords
- call Func_7126d
+ call TownMapCoordsToOAMCoords
+ call WritePlayerOrBirdSpriteOAM
pop hl
ld de, wcd6d
.asm_711dc
@@ -364,33 +366,34 @@
DisplayWildLocations: ; 711ef (1c:51ef)
callba FindWildLocationsOfMon
- call Func_712d9
+ call ZeroOutDuplicatesInList
ld hl, wOAMBuffer
- ld de, wBuffer
+ ld de, wTownMapCoords
.loop
ld a, [de]
cp $ff
jr z, .exitLoop
and a
- jr z, .next
+ jr z, .nextEntry
push hl
- call FindTownMapCoords
+ call LoadTownMapEntry
pop hl
ld a, [de]
- cp $19
- jr z, .next
- call SetTownMapOAMCoords
+ cp $19 ; Cerulean Cave's coordinates
+ jr z, .nextEntry ; skip Cerulean Cave
+ call TownMapCoordsToOAMCoords
ld a, $4 ; nest icon tile no.
ld [hli], a
xor a
ld [hli], a
-.next
+.nextEntry
inc de
jr .loop
.exitLoop
ld a, l
- and a
- jr nz, .locationKnown
+ and a ; were any OAM entries written?
+ jr nz, .drawPlayerSprite
+; if no OAM entries were written, print area unknown text
hlCoord 1, 7
ld b, $2
ld c, $f
@@ -399,10 +402,10 @@
ld de, AreaUnknownText
call PlaceString
jr .done
-.locationKnown
+.drawPlayerSprite
ld a, [W_CURMAP]
ld b, $0
- call Func_711c4
+ call DrawPlayerOrBirdSprite
.done
ld hl, wOAMBuffer
ld de, wTileMapBackup
@@ -412,11 +415,13 @@
AreaUnknownText: ; 7124a (1c:524a)
db " AREA UNKNOWN@"
-SetTownMapOAMCoords: ; 71258 (1c:5258)
+TownMapCoordsToOAMCoords: ; 71258 (1c:5258)
+; in: lower nybble of a = x, upper nybble of a = y
+; out: b and [hl] = (y * 8) + 24, c and [hl+1] = (x * 8) + 24
push af
and $f0
srl a
- add $18
+ add 24
ld b, a
ld [hli], a
pop af
@@ -423,28 +428,28 @@
and $f
swap a
srl a
- add $18
+ add 24
ld c, a
ld [hli], a
ret
-Func_7126d: ; 7126d (1c:526d)
- ld a, [wcd5b]
+WritePlayerOrBirdSpriteOAM: ; 7126d (1c:526d)
+ ld a, [wOAMBaseTile]
and a
- ld hl, wOAMBuffer + $90
- jr z, Func_71279
- ld hl, wOAMBuffer + $80
+ ld hl, wOAMBuffer + $90 ; for player sprite
+ jr z, WriteTownMapSpriteOAM
+ ld hl, wOAMBuffer + $80 ; for bird sprite
-Func_71279: ; 71279 (1c:5279)
+WriteTownMapSpriteOAM: ; 71279 (1c:5279)
push hl
ld hl, $fcfc
- add hl, bc
+ add hl, bc ; subtract 4 from c (X coord) and 3 from b (Y coord)
ld b, h
ld c, l
pop hl
WriteAsymmetricMonPartySpriteOAM: ; 71281 (1c:5281)
-; Writes 4 OAM blocks for a helix mon party sprite, since is does not have
+; Writes 4 OAM blocks for a helix mon party sprite, since it does not have
; a vertical line of symmetry.
ld de, $202
.loop
@@ -455,10 +460,10 @@
ld [hli], a
ld a, c
ld [hli], a
- ld a, [wcd5b]
+ ld a, [wOAMBaseTile]
ld [hli], a
inc a
- ld [wcd5b], a
+ ld [wOAMBaseTile], a
xor a
ld [hli], a
inc d
@@ -492,7 +497,7 @@
ld [hli], a
ld a, c
ld [hli], a
- ld a, [wcd5b]
+ ld a, [wOAMBaseTile]
ld [hli], a
ld a, [wcd5c]
ld [hli], a
@@ -507,7 +512,7 @@
pop bc
pop de
push hl
- ld hl, wcd5b
+ ld hl, wOAMBaseTile
inc [hl]
inc [hl]
pop hl
@@ -518,9 +523,10 @@
jr nz, .loop
ret
-Func_712d9: ; 712d9 (1c:52d9)
- ld de, wHPBarMaxHP
-.asm_712dc
+ZeroOutDuplicatesInList: ; 712d9 (1c:52d9)
+; replace duplicate bytes in the list of wild pokemon locations with 0
+ ld de, wBuffer
+.loop
ld a, [de]
inc de
cp $ff
@@ -528,39 +534,41 @@
ld c, a
ld l, e
ld h, d
-.asm_712e4
+.zeroDuplicatesLoop
ld a, [hl]
cp $ff
- jr z, .asm_712dc
+ jr z, .loop
cp c
- jr nz, .asm_712ee
+ jr nz, .skipZeroing
xor a
ld [hl], a
-.asm_712ee
+.skipZeroing
inc hl
- jr .asm_712e4
+ jr .zeroDuplicatesLoop
-FindTownMapCoords: ; 712f1 (1c:52f1)
+LoadTownMapEntry: ; 712f1 (1c:52f1)
+; in: a = map number
+; out: lower nybble of [de] = x, upper nybble of [de] = y, hl = address of name
cp REDS_HOUSE_1F
- jr c, .townOrRoute
- ld bc, $4
+ jr c, .external
+ ld bc, 4
ld hl, InternalMapEntries
.loop
cp [hl]
- jr c, .match
+ jr c, .foundEntry
add hl, bc
jr .loop
-.match
+.foundEntry
inc hl
- jr .done
-.townOrRoute
+ jr .readEntry
+.external
ld hl, ExternalMapEntries
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc
add hl, bc
add hl, bc
-.done
+.readEntry
ld a, [hli]
ld [de], a
ld a, [hli]
@@ -576,7 +584,7 @@
INCBIN "gfx/mon_nest_icon.1bpp"
TownMapSpriteBlinkingAnimation: ; 716c6 (1c:56c6)
- ld a, [wTownMapSpriteBlinkingCounter]
+ ld a, [wAnimCounter]
inc a
cp 25
jr z, .hideSprites
@@ -600,5 +608,5 @@
jr nz, .hideSpritesLoop
ld a, 25
.done
- ld [wTownMapSpriteBlinkingCounter], a
+ ld [wAnimCounter], a
jp DelayFrame
--- a/engine/trade.asm
+++ b/engine/trade.asm
@@ -13,7 +13,7 @@
; Externally clocked link cable trades use this.
ld a, [wTradedEnemyMonSpecies]
ld [wLeftGBMonSpecies], a
- ld a, [wTrainerSpriteOffset]
+ ld a, [wTradedPlayerMonSpecies]
ld [wRightGBMonSpecies], a
ld de, ExternalClockTradeFuncSequence
@@ -259,7 +259,7 @@
ld a, TRADE_BALL_POOF_ANIM
call Trade_ShowAnimation
ld a, TRADE_BALL_DROP_ANIM
- call Trade_ShowAnimation
+ call Trade_ShowAnimation ; clears mon pic
ld a, [wTradedPlayerMonSpecies]
call PlayCry
xor a
@@ -272,8 +272,12 @@
call CopyScreenTileBufferToVRAM
ld b, $8
call GoPAL_SET
+
+; This function call is pointless. It just copies blank tiles to VRAM that was
+; already filled with blank tiles.
ld hl, vBGMap1 + $8c
call Trade_CopyCableTilesOffScreen
+
ld a, $a0
ld [hSCX], a
call DelayFrame
@@ -754,7 +758,10 @@
ret
Trade_SlideTextBoxOffScreen: ; 415df (10:55df)
-; Slides the window right until it's off screen.
+; Slides the window right until it's off screen. The window usually just has
+; a text box at the bottom when this is called. However, when this is called
+; after Trade_ShowEnemyMon in the external clock sequence, there is a mon pic
+; above the text box and it is also scrolled off the screen.
ld c, 50
call DelayFrames
.loop
--- a/home.asm
+++ b/home.asm
@@ -378,7 +378,7 @@
set 6, [hl] ; turn off letter printing delay
xor a
ld [wcc49], a
- ld [wcc37], a
+ ld [wMenuWatchMovingOutOfBounds], a
ld hl, wTopMenuItemY
inc a
ld [hli], a ; top menu item Y
@@ -456,7 +456,7 @@
callba ErasePartyMenuCursors
xor a
ld [wMenuItemToSwap],a
- ld [wd07d],a
+ ld [wPartyMenuTypeOrMessageID],a
call RedrawPartyMenu
jr HandlePartyMenuInput
.handleSwap
@@ -1201,8 +1201,8 @@
pop hl
inc hl
call LoadItemList
- ld a,$02
- ld [wListMenuID],a ; selects between subtypes of menus
+ ld a,PRICEDITEMLISTMENU
+ ld [wListMenuID],a
ld a,[H_LOADEDROMBANK]
push af
ld a,Bank(DisplayPokemartDialogue_)
@@ -1219,12 +1219,12 @@
db "@"
LoadItemList:: ; 2a5a (0:2a5a)
- ld a,$01
+ ld a,1
ld [wUpdateSpritesEnabled],a
ld a,h
- ld [wd128],a
+ ld [wItemListPointer],a
ld a,l
- ld [wd129],a
+ ld [wItemListPointer + 1],a
ld de,wStringBuffer2 + 11
.loop
ld a,[hli]
@@ -1336,7 +1336,7 @@
; INPUT:
; HL = address of inventory (either wNumBagItems or wNumBoxItems)
; [wWhichPokemon] = index (within the inventory) of the item to remove
-; [wcf96] = quantity to remove
+; [wItemQuantity] = quantity to remove
RemoveItemFromInventory:: ; 2bbb (0:2bbb)
ld a,[H_LOADEDROMBANK]
push af
@@ -1353,7 +1353,7 @@
; INPUT:
; HL = address of inventory (either wNumBagItems or wNumBoxItems)
; [wcf91] = item ID
-; [wcf96] = item quantity
+; [wItemQuantity] = item quantity
; sets carry flag if successful, unsets carry flag if unsuccessful
AddItemToInventory:: ; 2bcf (0:2bcf)
push bc
@@ -1391,13 +1391,13 @@
set 6,[hl] ; turn off letter printing delay
xor a
ld [wMenuItemToSwap],a ; 0 means no item is currently being swapped
- ld [wd12a],a
+ ld [wListCount],a
ld a,[wList]
ld l,a
ld a,[wList + 1]
ld h,a ; hl = address of the list
- ld a,[hl]
- ld [wd12a],a ; [wd12a] = number of list entries
+ ld a,[hl] ; the first byte is the number of entries in the list
+ ld [wListCount],a
ld a,LIST_MENU_BOX
ld [wTextBoxID],a
call DisplayTextBoxID ; draw the menu text box
@@ -1411,8 +1411,8 @@
call UpdateSprites
.skipMovingSprites
ld a,1 ; max menu item ID is 1 if the list has less than 2 entries
- ld [wcc37],a
- ld a,[wd12a]
+ ld [wMenuWatchMovingOutOfBounds],a
+ ld a,[wListCount]
cp a,2 ; does the list have less than 2 entries?
jr c,.setMenuVariables
ld a,2 ; max menu item ID is 2 if the list has at least 2 entries
@@ -1461,17 +1461,20 @@
.buttonAPressed
ld a,[wCurrentMenuItem]
call PlaceUnfilledArrowMenuCursor
+
+; pointless because both values are overwritten before they are read
ld a,$01
- ld [wd12e],a
- ld [wd12d],a
+ ld [wMenuExitMethod],a
+ ld [wChosenMenuItem],a
+
xor a
- ld [wcc37],a
+ ld [wMenuWatchMovingOutOfBounds],a
ld a,[wCurrentMenuItem]
ld c,a
ld a,[wListScrollOffset]
add c
ld c,a
- ld a,[wd12a] ; number of list entries
+ ld a,[wListCount]
and a ; is the list empty?
jp z,ExitListMenu ; if so, exit the menu
dec a
@@ -1506,7 +1509,7 @@
; if it's an item menu
inc hl
ld a,[hl] ; a = item quantity
- ld [wcf97],a
+ ld [wMaxItemQuantity],a
.skipGettingQuantity
ld a,[wcf91]
ld [wd0b5],a
@@ -1527,10 +1530,10 @@
.storeChosenEntry ; store the menu entry that the player chose and return
ld de,wcd6d
call CopyStringToCF4B ; copy name to wcf4b
- ld a,$01
- ld [wd12e],a
+ ld a,CHOSE_MENU_ITEM
+ ld [wMenuExitMethod],a
ld a,[wCurrentMenuItem]
- ld [wd12d],a
+ ld [wChosenMenuItem],a
xor a
ld [hJoy7],a ; joypad state update flag
ld hl,wd730
@@ -1549,7 +1552,7 @@
ld a,[hl]
add a,3
ld b,a
- ld a,[wd12a] ; number of list entries
+ ld a,[wListCount]
cp b ; will going down scroll past the Cancel button?
jp c,DisplayListMenuIDLoop
inc [hl] ; if not, go down
@@ -1584,7 +1587,7 @@
ld de,InitialQuantityText
call PlaceString
xor a
- ld [wcf96],a ; initialize current quantity to 0
+ ld [wItemQuantity],a ; initialize current quantity to 0
jp .incrementQuantity
.waitForKeyPressLoop
call JoypadLowSensitivity
@@ -1599,10 +1602,10 @@
jr nz,.decrementQuantity
jr .waitForKeyPressLoop
.incrementQuantity
- ld a,[wcf97] ; max quantity
+ ld a,[wMaxItemQuantity]
inc a
ld b,a
- ld hl,wcf96 ; current quantity
+ ld hl,wItemQuantity ; current quantity
inc [hl]
ld a,[hl]
cp b
@@ -1612,11 +1615,11 @@
ld [hl],a
jr .handleNewQuantity
.decrementQuantity
- ld hl,wcf96 ; current quantity
+ ld hl,wItemQuantity ; current quantity
dec [hl]
jr nz,.handleNewQuantity
; wrap to the max quantity if the player goes below 1
- ld a,[wcf97] ; max quantity
+ ld a,[wMaxItemQuantity]
ld [hl],a
.handleNewQuantity
hlCoord 17, 10
@@ -1625,7 +1628,7 @@
jr nz,.printQuantity
.printPrice
ld c,$03
- ld a,[wcf96]
+ ld a,[wItemQuantity]
ld b,a
ld hl,$ff9f ; total price
; initialize total price to 0
@@ -1641,7 +1644,7 @@
pop bc
dec b
jr nz,.addLoop
- ld a,[$ff8e]
+ ld a,[hHalveItemPrices]
and a ; should the price be halved (for selling items)?
jr z,.skipHalvingPrice
xor a
@@ -1666,7 +1669,7 @@
call PrintBCDNumber
hlCoord 9, 10
.printQuantity
- ld de,wcf96 ; current quantity
+ ld de,wItemQuantity ; current quantity
ld bc,$8102 ; print leading zeroes, 1 byte, 2 digits
call PrintNumber
jp .waitForKeyPressLoop
@@ -1688,10 +1691,10 @@
ExitListMenu:: ; 2e3b (0:2e3b)
ld a,[wCurrentMenuItem]
- ld [wd12d],a
- ld a,$02
- ld [wd12e],a
- ld [wcc37],a
+ ld [wChosenMenuItem],a
+ ld a,CANCELLED_MENU
+ ld [wMenuExitMethod],a
+ ld [wMenuWatchMovingOutOfBounds],a
xor a
ld [hJoy7],a
ld hl,wd730
@@ -1775,7 +1778,7 @@
call PlaceString
pop de
pop hl
- ld a,[wcf93]
+ ld a,[wPrintItemPrices]
and a ; should prices be printed?
jr z,.skipPrintingItemPrice
.printItemPrice
@@ -1839,7 +1842,7 @@
ld a,[wd11e]
ld [wcf91],a
call IsKeyItem ; check if item is unsellable
- ld a,[wd124]
+ ld a,[wIsKeyItem]
and a ; is the item unsellable?
jr nz,.skipPrintingItemQuantity ; if so, don't print the quantity
push hl
@@ -1850,7 +1853,7 @@
ld a,[wd11e]
push af
ld a,[de]
- ld [wcf97],a
+ ld [wMaxItemQuantity],a
push de
ld de,wd11e
ld [de],a
@@ -2101,7 +2104,7 @@
; hl = address of inventory (either wNumBagItems or wNumBoxItems)
; [wcf91] = item ID
; [wWhichPokemon] = index of item within inventory
-; [wcf96] = quantity to toss
+; [wItemQuantity] = quantity to toss
; OUTPUT:
; clears carry flag if the item is tossed, sets carry flag if not
TossItem:: ; 30c4 (0:30c4)
@@ -2121,7 +2124,7 @@
; INPUT:
; [wcf91] = item ID
; OUTPUT:
-; [wd124] = result
+; [wIsKeyItem] = result
; 00: item is not key item
; 01: item is key item
IsKeyItem:: ; 30d9 (0:30d9)
@@ -3596,8 +3599,8 @@
; Function to remove a pokemon from the party or the current box.
; wWhichPokemon determines the pokemon.
-; [wcf95] == 0 specifies the party.
-; [wcf95] != 0 specifies the current box.
+; [wRemoveMonFromBox] == 0 specifies the party.
+; [wRemoveMonFromBox] != 0 specifies the current box.
RemovePokemon:: ; 391f (0:391f)
ld hl, _RemovePokemon
ld b, BANK(_RemovePokemon)
@@ -3826,13 +3829,13 @@
ld [MBC1RomBank], a
ret
-Func_3a68:: ; 3a68 (0:3a68)
+MoveMon:: ; 3a68 (0:3a68)
ld a, [H_LOADEDROMBANK]
push af
- ld a, BANK(MoveMon)
+ ld a, BANK(_MoveMon)
ld [H_LOADEDROMBANK], a
ld [MBC1RomBank], a
- call MoveMon
+ call _MoveMon
pop bc
ld a, b
ld [H_LOADEDROMBANK], a
@@ -3925,7 +3928,7 @@
ld [H_DOWNARROWBLINKCNT2],a ; blinking down arrow timing value 2
.loop1
xor a
- ld [wPartyMonAnimCounter],a ; counter for pokemon shaking animation
+ ld [wAnimCounter],a ; counter for pokemon shaking animation
call PlaceMenuCursor
call Delay3
.loop2
@@ -4023,7 +4026,7 @@
ld a,[hJoy5]
ret
.noWrappingAround
- ld a,[wcc37]
+ ld a,[wMenuWatchMovingOutOfBounds]
and a ; should we return if the user tried to go past the top or bottom?
jr z,.checkOtherKeys
jr .checkIfAButtonOrBButtonPressed
@@ -4568,7 +4571,7 @@
ld [wd11e], a
ld [wcf91], a
ld a, c
- ld [wcf96], a
+ ld [wItemQuantity], a
ld hl,wNumBagItems
call AddItemToInventory
ret nc
--- a/home/init.asm
+++ b/home/init.asm
@@ -31,8 +31,8 @@
ld [$ff4a], a
ld [$ff06], a
ld [$ff07], a
- ld [$ff47], a
- ld [$ff48], a
+ ld [rBGP], a
+ ld [rOBP0], a
ld [$ff49], a
ld a, rLCDC_ENABLE_MASK
@@ -101,9 +101,9 @@
ld [wc0ef], a
ld [wc0f0], a
ld a, $9c
- ld [$ffbd], a
+ ld [H_AUTOBGTRANSFERDEST + 1], a
xor a
- ld [$ffbc], a
+ ld [H_AUTOBGTRANSFERDEST], a
dec a
ld [wUpdateSpritesEnabled], a
--- a/home/overworld.asm
+++ b/home/overworld.asm
@@ -301,7 +301,7 @@
and a
jp nz,CheckWarpsNoCollision
predef ApplyOutOfBattlePoisonDamage ; also increment daycare mon exp
- ld a,[wd12d]
+ ld a,[wOutOfBattleBlackout]
and a
jp nz,HandleBlackOut ; if all pokemon fainted
.newBattle
--- a/home/vblank.asm
+++ b/home/vblank.asm
@@ -13,7 +13,7 @@
ld a, [hSCY]
ld [rSCY], a
- ld a, [wd0a0]
+ ld a, [wDisableVBlankWYUpdate]
and a
jr nz, .ok
ld a, [hWY]
--- a/hram.asm
+++ b/hram.asm
@@ -26,6 +26,8 @@
hPartyMonIndex EQU $FF8C
+hHalveItemPrices EQU $FF8E
+
; Multiplcation and division variables are meant
; to overlap for back-to-back usage. Big endian.
--- a/main.asm
+++ b/main.asm
@@ -922,7 +922,7 @@
ld l,a
dec [hl] ; decrease the number of items
ld a,[hl]
- ld [wd12a],a ; update number of items variable
+ 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
@@ -1094,7 +1094,7 @@
ld [wCurrentMenuItem],a
ld [wLastMenuItem],a
xor a
- ld [wcc37],a
+ ld [wMenuWatchMovingOutOfBounds],a
ld hl,wd730
set 6,[hl] ; no pauses between printing each letter
hlCoord 12, 2
@@ -1457,7 +1457,7 @@
set 6, a ; no printing delay
ld [wd730], a
xor a
- ld [wd12d], a
+ ld [wChosenMenuItem], a
ld a, BUY_SELL_QUIT_MENU_TEMPLATE
ld [wTextBoxID], a
call DisplayTextBoxID
@@ -1472,7 +1472,7 @@
xor a
ld [wCurrentMenuItem], a
ld [wLastMenuItem], a
- ld [wcc37], a
+ ld [wMenuWatchMovingOutOfBounds], a
ld a, [wd730]
res 6, a ; turn on the printing delay
ld [wd730], a
@@ -1482,14 +1482,14 @@
jr nz, .pressedA
bit 1, a ; was B pressed? (always true since only A/B are watched)
jr z, .pressedA
- ld a, $2
- ld [wd12e], a
+ ld a, CANCELLED_MENU
+ ld [wMenuExitMethod], a
jr .quit
.pressedA
- ld a, $1
- ld [wd12e], a
+ ld a, CHOSE_MENU_ITEM
+ ld [wMenuExitMethod], a
ld a, [wCurrentMenuItem]
- ld [wd12d], a
+ ld [wChosenMenuItem], a
ld b, a
ld a, [wMaxMenuItem]
cp b
@@ -1496,10 +1496,10 @@
jr z, .quit
ret
.quit
- ld a, $2
- ld [wd12e], a
+ ld a, CANCELLED_MENU
+ ld [wMenuExitMethod], a
ld a, [wCurrentMenuItem]
- ld [wd12d], a
+ ld [wChosenMenuItem], a
scf
ret
@@ -1512,9 +1512,12 @@
ld a, [wd730]
set 6, a ; no printing delay
ld [wd730], a
+
+; pointless because both values are overwritten before they are read
xor a
- ld [wd12d], a
- ld [wd12e], a
+ ld [wChosenMenuItem], a
+ ld [wMenuExitMethod], a
+
ld a, A_BUTTON | B_BUTTON
ld [wMenuWatchedKeys], a
ld a, $1
@@ -1525,7 +1528,7 @@
ld [wTopMenuItemX], a
xor a
ld [wLastMenuItem], a
- ld [wcc37], a
+ ld [wMenuWatchMovingOutOfBounds], a
push hl
ld hl, wTwoOptionMenuID
bit 7, [hl] ; select second menu item by default?
@@ -1614,12 +1617,12 @@
jr nz, .choseSecondMenuItem ; automatically choose the second option if B is pressed
.pressedAButton
ld a, [wCurrentMenuItem]
- ld [wd12d], a
+ ld [wChosenMenuItem], a
and a
jr nz, .choseSecondMenuItem
; chose first menu item
- ld a, $1
- ld [wd12e], a
+ ld a, CHOSE_FIRST_ITEM
+ ld [wMenuExitMethod], a
ld c, 15
call DelayFrames
call TwoOptionMenu_RestoreScreenTiles
@@ -1626,11 +1629,11 @@
and a
ret
.choseSecondMenuItem
- ld a, $1
+ ld a, 1
ld [wCurrentMenuItem], a
- ld [wd12d], a
- ld a, $2
- ld [wd12e], a
+ ld [wChosenMenuItem], a
+ ld a, CHOSE_SECOND_ITEM
+ ld [wMenuExitMethod], a
ld c, 15
call DelayFrames
call TwoOptionMenu_RestoreScreenTiles
@@ -1913,7 +1916,7 @@
_RemovePokemon: ; 7b68 (1:7b68)
ld hl, wPartyCount
- ld a, [wcf95]
+ ld a, [wRemoveMonFromBox]
and a
jr z, .asm_7b74
ld hl, W_NUMINBOX
@@ -1936,7 +1939,7 @@
jr nz, .asm_7b81
ld hl, wPartyMonOT
ld d, $5
- ld a, [wcf95]
+ ld a, [wRemoveMonFromBox]
and a
jr z, .asm_7b97
ld hl, wBoxMonOT
@@ -1955,7 +1958,7 @@
ld bc, $b
add hl, bc
ld bc, wPartyMonNicks
- ld a, [wcf95]
+ ld a, [wRemoveMonFromBox]
and a
jr z, .asm_7bb8
ld bc, wBoxMonNicks
@@ -1963,7 +1966,7 @@
call CopyDataUntil
ld hl, wPartyMons
ld bc, wPartyMon2 - wPartyMon1
- ld a, [wcf95]
+ ld a, [wRemoveMonFromBox]
and a
jr z, .asm_7bcd
ld hl, wBoxMons
@@ -1973,7 +1976,7 @@
call AddNTimes
ld d, h
ld e, l
- ld a, [wcf95]
+ ld a, [wRemoveMonFromBox]
and a
jr z, .asm_7be4
ld bc, wBoxMon2 - wBoxMon1
@@ -1987,7 +1990,7 @@
.asm_7beb
call CopyDataUntil
ld hl, wPartyMonNicks
- ld a, [wcf95]
+ ld a, [wRemoveMonFromBox]
and a
jr z, .asm_7bfa
ld hl, wBoxMonNicks
@@ -2000,7 +2003,7 @@
ld bc, $b
add hl, bc
ld bc, wPokedexOwned
- ld a, [wcf95]
+ ld a, [wRemoveMonFromBox]
and a
jr z, .asm_7c15
ld bc, wBoxMonNicksEnd
@@ -2631,7 +2634,7 @@
.noBlackOut
xor a
.done
- ld [wd12d], a
+ ld [wOutOfBattleBlackout], a
ret
LoadTilesetHeader: ; c754 (3:4754)
@@ -2777,10 +2780,10 @@
; INPUT:
; hl = address of inventory (either wNumBagItems or wNumBoxItems)
; [wcf91] = item ID
-; [wcf96] = item quantity
+; [wItemQuantity] = item quantity
; sets carry flag if successful, unsets carry flag if unsuccessful
AddItemToInventory_: ; ce04 (3:4e04)
- ld a,[wcf96] ; a = item quantity
+ ld a,[wItemQuantity] ; a = item quantity
push af
push bc
push de
@@ -2827,12 +2830,12 @@
add hl,bc ; hl = address to store the item
ld a,[wcf91]
ld [hli],a ; store item ID
- ld a,[wcf96]
+ 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,[wcf96]
+ ld a,[wItemQuantity]
ld b,a ; b = quantity to add
ld a,[hl] ; a = existing item quantity
add b ; a = new item quantity
@@ -2841,7 +2844,7 @@
; 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 [wcf96],a ; a = amount left over (to put in the new slot)
+ 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
@@ -2864,7 +2867,7 @@
pop bc
pop bc
ld a,b
- ld [wcf96],a ; restore the initial value from when the function was called
+ 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
@@ -2871,7 +2874,7 @@
; INPUT:
; hl = address of inventory (either wNumBagItems or wNumBoxItems)
; [wWhichPokemon] = index (within the inventory) of the item to remove
-; [wcf96] = quantity to remove
+; [wItemQuantity] = quantity to remove
RemoveItemFromInventory_: ; ce74 (3:4e74)
push hl
inc hl
@@ -2883,12 +2886,12 @@
inc h
.noCarry
inc hl
- ld a,[wcf96] ; quantity being removed
+ ld a,[wItemQuantity] ; quantity being removed
ld e,a
ld a,[hl] ; a = current quantity
sub e
ld [hld],a ; store new quantity
- ld [wcf97],a
+ ld [wMaxItemQuantity],a
and a
jr nz,.skipMovingUpSlots
; if the remaining quantity is 0,
@@ -2909,12 +2912,12 @@
ld [wListScrollOffset],a
ld [wCurrentMenuItem],a
ld [wcc2c],a
- ld [wd07e],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 [wd12a],a
+ ld [wListCount],a
cp a,2
jr c,.done
ld [wMaxMenuItem],a
@@ -3579,8 +3582,8 @@
ld a, [$ffe4]
dec a
call SkipFixedLengthTextEntries
- ld a, $2
- ld [wd07d], a
+ ld a, NAME_MON_SCREEN
+ ld [wNamingScreenType], a
predef AskName
.asm_f33f
ld hl, wPartyMons
@@ -3863,13 +3866,13 @@
and a
ret ; return success
-MoveMon: ; f51e (3:751e)
- ld a, [wcf95]
+_MoveMon: ; f51e (3:751e)
+ ld a, [wMoveMonType]
and a
jr z, .checkPartyMonSlots
- cp $2
+ cp DAYCARE_TO_PARTY
jr z, .checkPartyMonSlots
- cp $3
+ cp PARTY_TO_DAYCARE
ld hl, wDayCareMon
jr z, .asm_f575
ld hl, W_NUMINBOX
@@ -3889,10 +3892,10 @@
inc a
ld [hl], a ; increment number of mons in party/box
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc
- ld a, [wcf95]
- cp $2
+ ld a, [wMoveMonType]
+ cp DAYCARE_TO_PARTY
ld a, [wDayCareMon]
jr z, .asm_f556
ld a, [wcf91]
@@ -3899,7 +3902,7 @@
.asm_f556
ld [hli], a ; write new mon ID
ld [hl], $ff ; write new sentinel
- ld a, [wcf95]
+ ld a, [wMoveMonType]
dec a
ld hl, wPartyMons
ld bc, wPartyMon2 - wPartyMon1 ; $2c
@@ -3915,12 +3918,12 @@
push hl
ld e, l
ld d, h
- ld a, [wcf95]
+ ld a, [wMoveMonType]
and a
ld hl, wBoxMons
ld bc, wBoxMon2 - wBoxMon1 ; $21
jr z, .asm_f591
- cp $2
+ cp DAYCARE_TO_PARTY
ld hl, wDayCareMon
jr z, .asm_f597
ld hl, wPartyMons
@@ -3935,10 +3938,10 @@
call CopyData
pop de
pop hl
- ld a, [wcf95]
+ ld a, [wMoveMonType]
and a
jr z, .asm_f5b4
- cp $2
+ cp DAYCARE_TO_PARTY
jr z, .asm_f5b4
ld bc, wBoxMon2 - wBoxMon1
add hl, bc
@@ -3948,8 +3951,8 @@
inc de
ld [de], a
.asm_f5b4
- ld a, [wcf95]
- cp $3
+ ld a, [wMoveMonType]
+ cp PARTY_TO_DAYCARE
ld de, W_DAYCAREMONOT
jr z, .asm_f5d3
dec a
@@ -3965,11 +3968,11 @@
ld e, l
.asm_f5d3
ld hl, wBoxMonOT
- ld a, [wcf95]
+ ld a, [wMoveMonType]
and a
jr z, .asm_f5e6
ld hl, W_DAYCAREMONOT
- cp $2
+ cp DAYCARE_TO_PARTY
jr z, .asm_f5ec
ld hl, wPartyMonOT
.asm_f5e6
@@ -3978,8 +3981,8 @@
.asm_f5ec
ld bc, $b
call CopyData
- ld a, [wcf95]
- cp $3
+ ld a, [wMoveMonType]
+ cp PARTY_TO_DAYCARE
ld de, W_DAYCAREMONNAME
jr z, .asm_f611
dec a
@@ -3995,11 +3998,11 @@
ld e, l
.asm_f611
ld hl, wBoxMonNicks
- ld a, [wcf95]
+ ld a, [wMoveMonType]
and a
jr z, .asm_f624
ld hl, W_DAYCAREMONNAME
- cp $2
+ cp DAYCARE_TO_PARTY
jr z, .asm_f62a
ld hl, wPartyMonNicks
.asm_f624
@@ -4009,10 +4012,10 @@
ld bc, $b
call CopyData
pop hl
- ld a, [wcf95]
- cp $1
+ ld a, [wMoveMonType]
+ cp PARTY_TO_BOX
jr z, .asm_f664
- cp $3
+ cp PARTY_TO_DAYCARE
jr z, .asm_f664
push hl
srl a
--- a/scripts/celadongamecorner.asm
+++ b/scripts/celadongamecorner.asm
@@ -12,7 +12,7 @@
res 6, [hl]
ret z
call Random
- ld a, [$ffd3]
+ ld a, [hRandomAdd]
cp $7
jr nc, .asm_48be2
ld a, $8
@@ -20,7 +20,7 @@
srl a
srl a
srl a
- ld [wUnknownSlotVar], a
+ ld [wLuckySlotHiddenObjectIndex], a
ret
CeladonGameCornerScript_48bec: ; 48bec (12:4bec)
--- a/scripts/ceruleanhouse2.asm
+++ b/scripts/ceruleanhouse2.asm
@@ -26,7 +26,7 @@
ld a, h
ld [wList + 1], a
xor a
- ld [wcf93], a
+ ld [wPrintItemPrices], a
ld [wMenuItemToSwap], a
ld a, SPECIALLISTMENU
ld [wListMenuID], a
--- a/scripts/daycarem.asm
+++ b/scripts/daycarem.asm
@@ -25,7 +25,7 @@
call PrintText
xor a
ld [wUpdateSpritesEnabled], a
- ld [wd07d], a
+ ld [wPartyMenuTypeOrMessageID], a
ld [wMenuItemToSwap], a
call DisplayPartyMenu
push af
@@ -45,13 +45,13 @@
call GetPartyMonName
ld hl, DayCareMText_56419
call PrintText
- ld a, $1
+ ld a, 1
ld [W_DAYCARE_IN_USE], a
- ld a, $3
- ld [wcf95], a
- call Func_3a68
+ ld a, PARTY_TO_DAYCARE
+ ld [wMoveMonType], a
+ call MoveMon
xor a
- ld [wcf95], a
+ ld [wRemoveMonFromBox], a
call RemovePokemon
ld a, [wcf91]
call PlayCry
@@ -158,26 +158,26 @@
predef SubBCDPredef
ld a, (SFX_02_5a - SFX_Headers_02) / 3
call PlaySoundWaitForCurrent
- ld a, $13
+ ld a, MONEY_BOX
ld [wTextBoxID], a
call DisplayTextBoxID
ld hl, DayCareMText_5644f
call PrintText
- ld a, $2
- ld [wcf95], a
- call Func_3a68
+ ld a, DAYCARE_TO_PARTY
+ ld [wMoveMonType], a
+ call MoveMon
ld a, [wDayCareMonSpecies]
ld [wcf91], a
ld a, [wPartyCount]
dec a
push af
- ld bc, $002c
+ ld bc, wPartyMon2 - wPartyMon1
push bc
ld hl, wPartyMon1Moves
call AddNTimes
ld d, h
ld e, l
- ld a, $1
+ ld a, 1
ld [wHPBarMaxHP], a
predef WriteMonMoves
pop bc
@@ -186,7 +186,7 @@
call AddNTimes
ld d, h
ld e, l
- ld bc, $0021
+ ld bc, wPartyMon1MaxHP - wPartyMon1HP
add hl, bc
ld a, [hli]
ld [de], a
--- a/scripts/namerater.asm
+++ b/scripts/namerater.asm
@@ -49,7 +49,7 @@
ld hl, NameRaterText_1dab8
call PrintText
xor a
- ld [wd07d], a
+ ld [wPartyMenuTypeOrMessageID], a
ld [wUpdateSpritesEnabled], a
ld [wMenuItemToSwap], a
call DisplayPartyMenu
@@ -68,7 +68,7 @@
jr nz, .asm_1daae
ld hl, NameRaterText_1dac2
call PrintText
- callba Func_655c
+ callba DisplayNameRaterScreen
jr c, .asm_1daae
ld hl, NameRaterText_1dac7
.asm_1daa8
--- a/scripts/oakslab.asm
+++ b/scripts/oakslab.asm
@@ -641,7 +641,7 @@
ld a, c
ld [wWhichPokemon], a
ld a, $1
- ld [wcf96], a
+ ld [wItemQuantity], a
jp RemoveItemFromInventory
OaksLabScript_1d02b: ; 1d02b (7:502b)
--- a/wram.asm
+++ b/wram.asm
@@ -266,7 +266,12 @@
; keeps track of what section of the list is on screen
ds 1
-wcc37:: ds 1 ; menu related thing, used in pokedex and dialog boxes
+wMenuWatchMovingOutOfBounds:: ; cc37
+; If non-zero, then when wrapping is disabled and the player tries to go past
+; the top or bottom of the menu, return from HandleMenuInput. This is useful for
+; menus that have too many items to display at once on the screen because it
+; allows the caller to scroll the entire menu up or down when this happens.
+ ds 1
wTradeCenterPointerTableIndex:: ; cc38
ds 1
@@ -352,6 +357,13 @@
ds 2
+wSlotMachineSevenAndBarModeChance:: ; cc5b
+; If a random number greater than this value is generated, then the player is
+; allowed to have three 7 symbols or bar symbols line up.
+; So, this value is actually the chance of NOT entering that mode.
+; If the slot is lucky, it equals 250, giving a 5/256 (~2%) chance.
+; Otherwise, it equals 253, giving a 2/256 (~0.8%) chance.
+
wHallOfFame:: ; cc5b
wBoostExpByExpAll:: ; cc5b
wAnimationType:: ; cc5b
@@ -360,8 +372,13 @@
wcc5b:: ds 1 ; these upcoming values below are miscellaneous storage values
wcc5c:: ds 1 ; used in pokedex evaluation as well
wcc5d:: ds 1 ; used in pokedex evaluation
-wcc5e:: ds 13 ; as well as used as miscellaneous storage value, this is also used for the game corner slots
+wSlotMachineSavedROMBank:: ; cc5e
+; ROM back to return to when the player is done with the slot machine
+ ds 1
+
+ ds 12
+
wcc6b:: ds 14 ; doesn't seem to be used for anything, probably just more storage
wcc79:: ds 30 ; used in battle animations
@@ -445,7 +462,7 @@
wPlayerUsedMove:: ds 1 ; ccf1
wEnemyUsedMove:: ds 1 ; ccf2
-wccf3:: ds 1 ; used with the move minimize
+wEnemyMonMinimized:: ds 1 ; ccf3
wMoveDidntMiss:: ds 1 ; ccf4
@@ -454,10 +471,12 @@
flag_array 6
wccf6:: ds 1 ; used in some hp bar thing
-wccf7:: ds 14 ; used with substitute move sliding thing? (not sure)
+wPlayerMonMinimized:: ds 1 ; ccf7
-wUnknownSlotVar:: ; cd05
+ds 13
+wLuckySlotHiddenObjectIndex:: ; cd05
+
wEnemyNumHits:: ; cd05
; number of hits by enemy in attacks like Double Slap, etc.
@@ -581,6 +600,12 @@
ds 1
+wWhichTownMapLocation:: ; cd3d
+
+wStoppingWhichSlotMachineWheel:: ; cd3d
+; which wheel the player is trying to stop
+; 0 = none, 1 = wheel 1, 2 = wheel 2, 3 or greater = wheel 3
+
wTradedPlayerMonSpecies:: ; cd3d
wTradingWhichPlayerMon:: ; cd3d
@@ -604,6 +629,11 @@
wTrainerSpriteOffset:: ; cd3d
ds 1
+wFlyLocationsList:: ; cd3e
+; 11 bytes plus $ff sentinel values at each end
+
+wSlotMachineWheel1Offset:: ; cd3e
+
wTradedEnemyMonSpecies:: ; cd3e
wTradingWhichEnemyMon:: ; cd3e
@@ -619,6 +649,8 @@
wTrainerEngageDistance:: ; cd3e
ds 1
+wSlotMachineWheel2Offset:: ; cd3f
+
wNameOfPlayerMonToBeTraded:: ; cd3f
wFlyAnimBirdSpriteImageIndex:: ; cd3f
@@ -633,6 +665,8 @@
wcd3f:: ; used with daycare text for money amount
ds 1
+wSlotMachineWheel3Offset:: ; cd40
+
wPlayerSpinInPlaceAnimSoundID:: ; cd40
wHiddenObjectY:: ; cd40
@@ -644,35 +678,96 @@
wHiddenObjectX:: ; cd41
+wSlotMachineWinningSymbol:: ; cd42
+; the OAM tile number of the upper left corner of the winning symbol minus 2
+
+wSlotMachineWheel1BottomTile:: ; cd41
+
wTrainerScreenX:: ; cd41
ds 1
; a lot of the uses for these values use more than the said address
+wSlotMachineWheel1MiddleTile:: ; cd42
+
wcd42:: ds 1 ; used in pewter center script, printing field mon moves, slot machines and HoF PC
+
+wSlotMachineWheel1TopTile:: ; cd43
+
wcd43:: ds 1 ; slot machine stuff and GetMonFieldMoves
-wcd44:: ds 1 ; just slot machine
-wcd45:: ds 1 ; slot machine...
-wcd46:: ds 1 ; slot machine...
+
+wSlotMachineWheel2BottomTile:: ; cd44
+ ds 1
+
+wSlotMachineWheel2MiddleTile:: ; cd45
+ ds 1
+
+wTempCoins1:: ; cd46
+; 2 bytes
+; temporary variable used to add payout amount to the player's coins
+
+wSlotMachineWheel2TopTile:: ; cd46
+ ds 1
+
+wSlotMachineWheel3BottomTile:: ; cd47
+
wcd47:: ds 1 ; used in slot machine and spinning player sprite
+
+wSlotMachineWheel3MiddleTile:: ; cd48
+
wcd48:: ds 1 ; same as above
+
+wSlotMachineWheel3TopTile:: ; cd49
+
wcd49:: ds 1 ; used in slot machine, displaying the gym leaders/badges on the trainer card, and displaying the town map
-wcd4a:: ds 1 ; probably used in one of the above mentioned functions
-wcd4b:: ds 1 ; same as above
+wTempCoins2:: ; cd4a
+; 2 bytes
+; temporary variable used to subtract the bet amount from the player's coins
+
+wPayoutCoins:: ; cd4a
+; 2 bytes
+ ds 1
+
+wcd4b:: ; cd4b
+; used in player animations
+ ds 1
+
wTradedPlayerMonOTID:: ; cd4c
-wcd4c:: ds 1 ; slot machine and probably other above stuff
+wSlotMachineFlags:: ; cd4c
+; These flags are set randomly and control when the wheels stop.
+; bit 6: allow the player to win in general
+; bit 7: allow the player to win with 7 or bar (plus the effect of bit 6)
+ ds 1
+
+wSlotMachineWheel1SlipCounter:: ; cd4d
+; wheel 1 can "slip" while this is non-zero
+
wcd4d:: ds 1 ; used with cut and slot machine
+wSlotMachineWheel2SlipCounter:: ; cd4e
+; wheel 2 can "slip" while this is non-zero
+
wTradedEnemyMonOT:: ; cd4e
wcd4e:: ds 1 ; used with in-game trades and slot machine
+
+wSlotMachineRerollCounter:: ; cd4f
+; The remaining number of times wheel 3 will roll down a symbol until a match is
+; found, when winning is enabled. It's initialized to 4 each bet.
+
wcd4f:: ds 1 ; used with in-game trades, emotion bubbles, and player animations
+
+wSlotMachineBet:: ; cd50
+; how many coins the player bet on the slot machine (1 to 3)
+
wcd50:: ds 9 ; used with in-game trades, emotion bubbles, and player and miscellaneous sprite animations
wTradedEnemyMonOTID:: ; cd59
ds 2
+wOAMBaseTile:: ; cd5b
+
wcd5b:: ds 1 ; used in some sprite stuff, town map and surge gym trash cans
wcd5c:: ds 1 ; used in town map
@@ -719,6 +814,10 @@
wBuffer:: ; cee9
; Temporary storage area of 30 bytes.
+
+wTownMapCoords:: ; cee9
+; lower nybble is x, upper nybble is y
+
wHPBarMaxHP:: ; cee9
ds 2
wHPBarOldHP:: ; ceeb
@@ -744,7 +843,13 @@
wcf08:: ds 1 ; used as a storage value for the bank to return to after a BankswitchHome (bankswitch in homebank)
wcf09:: ds 1 ; used as a temp storage value for the bank to switch to
-wcf0a:: ds 1 ; used as flags for Poke Mart
+
+wBoughtOrSoldItemInMart:: ; cf0a
+; 0 = nothing bought or sold in pokemart
+; 1 = bought or sold something in pokemart
+; this value is not used for anything
+ ds 1
+
wBattleResult:: ; cf0b
; $00 - win
; $01 - lose
@@ -829,7 +934,9 @@
; which pokemon you selected
ds 1
-wcf93:: ds 1 ; used with lists
+wPrintItemPrices:: ; cf93
+; if non-zero, then print item prices when displaying lists
+ ds 1
wHPBarType:: ; cf94
; type of HP bar
@@ -841,10 +948,23 @@
; ID used by DisplayListMenuID
ds 1
-wcf95:: ds 1 ; used with RemovePokemon (BoxMons, Daycare, Trades, etc.)
-wcf96:: ds 1 ; used with removing items
-wcf97:: ds 1 ; used with printing item quantities?
+wRemoveMonFromBox:: ; cf95
+; if non-zero, RemovePokemon will remove the mon from the current box,
+; else it will remove the mon from the party
+wMoveMonType:: ; cf95
+; 0 = move from box to party
+; 1 = move from party to box
+; 2 = move from daycare to party
+; 3 = move from party to daycare
+ ds 1
+
+wItemQuantity:: ; cf96
+ ds 1
+
+wMaxItemQuantity:: ; cf97
+ ds 1
+
; LoadMonData copies mon data here
wLoadedMon:: party_struct wLoadedMon ; cf98
@@ -1123,9 +1243,21 @@
; ID number of the current battle animation
ds 1
-wd07d:: ds 1 ; used with naming functions and party display type
-wd07e:: ds 3 ; used with mart and inventory
+wNamingScreenType:: ; d07d
+wPartyMenuTypeOrMessageID:: ; d07d
+
+wTempTilesetNumTiles:: ; d07d
+; temporary storage for the number of tiles in a tileset
+ ds 1
+
+wSavedListScrollOffset:: ; d07e
+; used by the pokemart code to save the existing value of wListScrollOffset
+; so that it can be restored when the player is done with the pokemart NPC
+ ds 1
+
+ ds 2
+
; base coordinates of frame block
W_BASECOORDX:: ; d081
ds 1
@@ -1160,10 +1292,9 @@
wd08a:: ds 1 ; used with sprites and displaying the option menu on the main menu screen?
-wTownMapSpriteBlinkingCounter:: ; d08b
+wAnimCounter:: ; d08b
+; generic counter variable for various animations
-wPartyMonAnimCounter:: ; d08b
-
W_SUBANIMTRANSFORM:: ; d08b
; controls what transformations are applied to the subanimation
; 01: flip horizontally and vertically
@@ -1188,6 +1319,13 @@
W_SUBANIMADDRPTR:: ; d094
; the address _of the address_ of the current subanimation entry
ds 2
+
+wSlotMachineAllowMatchesCounter:: ; d096
+; If non-zero, the allow matches flag is always set.
+; There is a 1/256 (~0.4%) chance that this value will be set to 60, which is
+; the only way it can increase. Winning certain payout amounts will decrement it
+; or zero it.
+
W_SUBANIMSUBENTRYADDR:: ; d096
; the address of the current subentry of the current subanimation
ds 2
@@ -1221,7 +1359,7 @@
wNewTileBlockID:: ; d09f
wd09f:: ds 1 ; used with predef ReplaceTileBlock
-wd0a0:: ds 1 ; used in VBlank and ChangeBGPalColor0_4Frames
+wDisableVBlankWYUpdate:: ds 1 ; if non-zero, don't update WY during V-blank
W_SPRITECURPOSX:: ; d0a1
ds 1
@@ -1351,7 +1489,10 @@
; wWalkBikeSurfState is sometimes copied here, but it doesn't seem to be used for anything
ds 1
-wd11b:: ds 1 ; used with mart text box and cable club
+wInitListType:: ; d11b
+; the type of list for InitList to init
+ ds 1
+
wd11c:: ds 1 ; temp storage value for catching pokemon
wd11d:: ds 1 ; used with battle switchout and testing if the enemy mon fainted
wd11e:: ds 1 ; used as a Pokemon and Item storage value. Also used as an output value for CountSetBits
@@ -1363,7 +1504,7 @@
wd121:: ds 1 ; used with evolving pokemon
wd122:: ds 2 ; saved ROM bank number for vblank
-wd124:: ds 1 ; used as an output value when determining if an item is a key item
+wIsKeyItem:: ds 1 ; d124
wTextBoxID:: ; d125
ds 1
@@ -1373,16 +1514,37 @@
W_CURENEMYLVL:: ; d127
ds 1
-wd128:: ds 1 ; used as a pointer to displaying Poke Mart inventory, also used to store the pointer of LoadItemList (pointer to item list initially in hl)
-wd129:: ds 1 ; second half of above mentioned pointer
-wd12a:: ds 1 ; Number of list entries for displaying a list
+wItemListPointer:: ; d128
+; pointer to list of items terminated by $FF
+ ds 2
+wListCount::
+; number of entries in a list
+ ds 1
+
wLinkState:: ; d12b
ds 1
-wTwoOptionMenuID:: ds 1
-wd12d:: ds 1 ; used with item menus and pokemart menu, also used with testing if all Pokemon Fainted?
-wd12e:: ds 1 ; used as an output value to determine if A or B was pressed in a yes/no box
+wTwoOptionMenuID:: ; d12c
+ ds 1
+
+wChosenMenuItem:: ; d12d
+; the id of the menu item the player ultimately chose
+
+wOutOfBattleBlackout:: ; d12d
+; non-zero when the whole party has fainted due to out-of-battle poison damage
+ ds 1
+
+wMenuExitMethod:: ; d12e
+; the way the user exited a menu
+; for list menus and the buy/sell/quit menu:
+; $01 = the user pressed A to choose a menu item
+; $02 = the user pressed B to cancel
+; for two-option menus:
+; $01 = the user pressed A with the first menu item selected
+; $02 = the user pressed B or pressed A with the second menu item selected
+ ds 1
+
wd12f:: ds 1 ; used in some coordinatestuff, npc pathstuff, and game corner prize stuff
wd130:: ds 1 ; saved value of screen Y coord of trainer sprite
wd131:: ds 1 ; saved value of screen X coord of trainer sprite