summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRangi <remy.oukaour+rangi42@gmail.com>2020-11-03 22:45:10 -0500
committerRangi <remy.oukaour+rangi42@gmail.com>2020-11-03 22:45:10 -0500
commit2b9c37e74f73af67d809b539daa26c612dfedeb0 (patch)
tree51593ace85d342c3cc349f3789c4424278994f14
parent5c143ed970c969832953699e80b1fcaab182c5a1 (diff)
Identify some more uses of wBuffer1-6
-rw-r--r--engine/battle/core.asm26
-rw-r--r--engine/battle_anims/pokeball_wobble.asm6
-rw-r--r--engine/events/checkforhiddenitems.asm24
-rw-r--r--engine/events/overworld.asm69
-rw-r--r--engine/items/item_effects.asm20
-rw-r--r--wram.asm38
6 files changed, 109 insertions, 74 deletions
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index 8ec5f469..fb4daecc 100644
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -3037,13 +3037,13 @@ AddBattleParticipant:
FindMonInOTPartyToSwitchIntoBattle:
ld b, -1
- ld a, $1
- ld [wBuffer1], a
- ld [wBuffer2], a
+ ld a, %000001
+ ld [wEnemyEffectivenessVsPlayerMons], a
+ ld [wPlayerEffectivenessVsEnemyMons], a
.loop
- ld hl, wBuffer1
+ ld hl, wEnemyEffectivenessVsPlayerMons
sla [hl]
- inc hl
+ inc hl ; wPlayerEffectivenessVsEnemyMons
sla [hl]
inc b
ld a, [wOTPartyCount]
@@ -3067,7 +3067,7 @@ FindMonInOTPartyToSwitchIntoBattle:
jr .loop
.discourage
- ld hl, wBuffer2
+ ld hl, wPlayerEffectivenessVsEnemyMons
set 0, [hl]
jr .loop
@@ -3102,7 +3102,7 @@ LookUpTheEffectivenessOfEveryMove:
ld a, [wTypeMatchup]
cp EFFECTIVE + 1
jr c, .loop
- ld hl, wBuffer1
+ ld hl, wEnemyEffectivenessVsPlayerMons
set 0, [hl]
ret
.done
@@ -3145,10 +3145,10 @@ IsThePlayerMonTypesEffectiveAgainstOTMon:
.super_effective
pop bc
- ld hl, wBuffer1
+ ld hl, wEnemyEffectivenessVsPlayerMons
bit 0, [hl]
jr nz, .reset
- inc hl
+ inc hl ; wPlayerEffectivenessVsEnemyMons
set 0, [hl]
ret
@@ -3158,9 +3158,9 @@ IsThePlayerMonTypesEffectiveAgainstOTMon:
ScoreMonTypeMatchups:
.loop1
- ld hl, wBuffer1
+ ld hl, wEnemyEffectivenessVsPlayerMons
sla [hl]
- inc hl
+ inc hl ; wPlayerEffectivenessVsEnemyMons
sla [hl]
jr nc, .loop1
ld a, [wOTPartyCount]
@@ -3174,7 +3174,7 @@ ScoreMonTypeMatchups:
jr .loop2
.okay
- ld a, [wBuffer1]
+ ld a, [wEnemyEffectivenessVsPlayerMons]
and a
jr z, .okay2
ld b, -1
@@ -3187,7 +3187,7 @@ ScoreMonTypeMatchups:
.okay2
ld b, -1
- ld a, [wBuffer2]
+ ld a, [wPlayerEffectivenessVsEnemyMons]
ld c, a
.loop4
inc b
diff --git a/engine/battle_anims/pokeball_wobble.asm b/engine/battle_anims/pokeball_wobble.asm
index c430e513..ad0ae875 100644
--- a/engine/battle_anims/pokeball_wobble.asm
+++ b/engine/battle_anims/pokeball_wobble.asm
@@ -2,9 +2,9 @@ GetPokeBallWobble:
; Returns whether a Poke Ball will wobble in the catch animation.
; Whether a Pokemon is caught is determined beforehand.
- ld a, [wBuffer2]
+ ld a, [wThrownBallWobbleCount]
inc a
- ld [wBuffer2], a
+ ld [wThrownBallWobbleCount], a
; Wobble up to 3 times.
cp 3 + 1
@@ -16,7 +16,7 @@ GetPokeBallWobble:
ret nz
ld hl, WobbleProbabilities
- ld a, [wBuffer1]
+ ld a, [wFinalCatchRate]
ld b, a
.loop
ld a, [hli]
diff --git a/engine/events/checkforhiddenitems.asm b/engine/events/checkforhiddenitems.asm
index c71bd290..0e0e282c 100644
--- a/engine/events/checkforhiddenitems.asm
+++ b/engine/events/checkforhiddenitems.asm
@@ -1,14 +1,14 @@
CheckForHiddenItems:
; Checks to see if there are hidden items on the screen that have not yet been found. If it finds one, returns carry.
call GetMapScriptsBank
- ld [wBuffer1], a
-; Get the coordinate of the bottom right corner of the screen, and load it in wBuffer3/wBuffer4.
+ ld [wCurMapScriptBank], a
+; Get the coordinate of the bottom right corner of the screen, and load it in wBottomRightYCoord/wBottomRightXCoord.
ld a, [wXCoord]
add SCREEN_WIDTH / 4
- ld [wBuffer4], a
+ ld [wBottomRightXCoord], a
ld a, [wYCoord]
add SCREEN_HEIGHT / 4
- ld [wBuffer3], a
+ ld [wBottomRightYCoord], a
; Get the pointer for the first bg_event in the map...
ld hl, wCurMapBGEventsPointer
ld a, [hli]
@@ -20,14 +20,14 @@ CheckForHiddenItems:
jr z, .nobgeventitems
; For i = 1:wCurMapBGEventCount...
.loop
-; Store the counter in wBuffer2, and store the bg_event pointer in the stack.
- ld [wBuffer2], a
+; Store the counter in wRemainingBGEventCount, and store the bg_event pointer in the stack.
+ ld [wRemainingBGEventCount], a
push hl
; Get the Y coordinate of the BG event.
call .GetFarByte
ld e, a
; Is the Y coordinate of the BG event on the screen? If not, go to the next BG event.
- ld a, [wBuffer3]
+ ld a, [wBottomRightYCoord]
sub e
jr c, .next
cp SCREEN_HEIGHT / 2
@@ -35,7 +35,7 @@ CheckForHiddenItems:
; Is the X coordinate of the BG event on the screen? If not, go to the next BG event.
call .GetFarByte
ld d, a
- ld a, [wBuffer4]
+ ld a, [wBottomRightXCoord]
sub d
jr c, .next
cp SCREEN_WIDTH / 2
@@ -45,9 +45,9 @@ CheckForHiddenItems:
cp BGEVENT_ITEM
jr nz, .next
; Has this item already been found? If not, set off the Itemfinder.
- ld a, [wBuffer1]
+ ld a, [wCurMapScriptBank]
call GetFarHalfword
- ld a, [wBuffer1]
+ ld a, [wCurMapScriptBank]
call GetFarHalfword
ld d, h
ld e, l
@@ -63,7 +63,7 @@ CheckForHiddenItems:
ld bc, BG_EVENT_SIZE
add hl, bc
; Restore the BG event counter and decrement it. If it hits zero, there are no hidden items in range.
- ld a, [wBuffer2]
+ ld a, [wRemainingBGEventCount]
dec a
jr nz, .loop
@@ -77,7 +77,7 @@ CheckForHiddenItems:
ret
.GetFarByte:
- ld a, [wBuffer1]
+ ld a, [wCurMapScriptBank]
call GetFarByte
inc hl
ret
diff --git a/engine/events/overworld.asm b/engine/events/overworld.asm
index e5b90447..1a12bfe3 100644
--- a/engine/events/overworld.asm
+++ b/engine/events/overworld.asm
@@ -1,14 +1,14 @@
FieldMoveJumptableReset:
xor a
- ld hl, wBuffer1
- ld bc, 7
+ ld hl, wFieldMoveData
+ ld bc, wFieldMoveDataEnd - wFieldMoveData
call ByteFill
ret
FieldMoveJumptable:
- ld a, [wBuffer1]
+ ld a, [wFieldMoveJumptableIndex]
rst JumpTable
- ld [wBuffer1], a
+ ld [wFieldMoveJumptableIndex], a
bit 7, a
jr nz, .okay
and a
@@ -183,17 +183,15 @@ CheckMapForSomethingToCut:
call CheckOverworldTileArrays
pop hl
jr nc, .fail
- ; Back up the wOverworldMapBlocks address to wBuffer3
+ ; Save the Cut field move data
ld a, l
- ld [wBuffer3], a
+ ld [wCutWhirlpoolOverworldBlockAddr], a
ld a, h
- ld [wBuffer4], a
- ; Back up the replacement tile to wBuffer5
+ ld [wCutWhirlpoolOverworldBlockAddr + 1], a
ld a, b
- ld [wBuffer5], a
- ; Back up the animation index to wBuffer6
+ ld [wCutWhirlpoolReplacementBlock], a
ld a, c
- ld [wBuffer6], a
+ ld [wCutWhirlpoolAnimationType], a
xor a
ret
@@ -214,18 +212,18 @@ Script_Cut:
end
CutDownTreeOrGrass:
- ld hl, wBuffer3 ; OverworldMapTile
+ ld hl, wCutWhirlpoolOverworldBlockAddr
ld a, [hli]
ld h, [hl]
ld l, a
- ld a, [wBuffer5] ; ReplacementTile
+ ld a, [wCutWhirlpoolReplacementBlock]
ld [hl], a
xor a
ldh [hBGMapMode], a
call OverworldTextModeSwitch
call UpdateSprites
call DelayFrame
- ld a, [wBuffer6] ; Animation type
+ ld a, [wCutWhirlpoolAnimationType]
ld e, a
farcall OWCutAnimation
call BufferScreen
@@ -370,7 +368,7 @@ SurfFunction:
.DoSurf:
call GetSurfType
- ld [wBuffer2], a
+ ld [wSurfingPlayerState], a
call GetPartyNick
ld hl, SurfFromMenuScript
call QueueScript
@@ -397,7 +395,7 @@ UsedSurfScript:
waitbutton
closetext
- readmem wBuffer2
+ readmem wSurfingPlayerState
writevar VAR_MOVEMENT
special UpdatePlayerSprite
@@ -501,7 +499,7 @@ TrySurfOW::
jr nz, .quit
call GetSurfType
- ld [wBuffer2], a
+ ld [wSurfingPlayerState], a
call GetPartyNick
ld a, BANK(AskSurfScript)
@@ -734,7 +732,7 @@ DigFunction:
ld a, $2
EscapeRopeOrDig:
- ld [wBuffer2], a
+ ld [wEscapeRopeOrDigType], a
.loop
ld hl, .DigTable
call FieldMoveJumptable
@@ -778,7 +776,7 @@ EscapeRopeOrDig:
ld bc, 3
call CopyBytes
call GetPartyNick
- ld a, [wBuffer2]
+ ld a, [wEscapeRopeOrDigType]
cp $2
jr nz, .escaperope
ld hl, .UsedDigScript
@@ -793,7 +791,7 @@ EscapeRopeOrDig:
ret
.FailDig:
- ld a, [wBuffer2]
+ ld a, [wEscapeRopeOrDigType]
cp $2
jr nz, .failescaperope
ld hl, .CantUseDigText
@@ -976,7 +974,7 @@ SetStrengthFlag:
ld hl, wPartySpecies
add hl, de
ld a, [hl]
- ld [wBuffer6], a
+ ld [wStrengthSpecies], a
call GetPartyNick
ret
@@ -987,8 +985,8 @@ Script_StrengthFromMenu:
Script_UsedStrength:
callasm SetStrengthFlag
writetext .UseStrengthText
- readmem wBuffer6
- cry 0
+ readmem wStrengthSpecies
+ cry 0 ; plays [wStrengthSpecies] cry
pause 3
writetext .MoveBoulderText
closetext
@@ -1123,14 +1121,15 @@ TryWhirlpoolMenu:
call CheckOverworldTileArrays
pop hl
jr nc, .failed
+ ; Save the Whirlpool field move data
ld a, l
- ld [wBuffer3], a
+ ld [wCutWhirlpoolOverworldBlockAddr], a
ld a, h
- ld [wBuffer4], a
+ ld [wCutWhirlpoolOverworldBlockAddr + 1], a
ld a, b
- ld [wBuffer5], a
+ ld [wCutWhirlpoolReplacementBlock], a
ld a, c
- ld [wBuffer6], a
+ ld [wCutWhirlpoolAnimationType], a
xor a
ret
@@ -1151,16 +1150,16 @@ Script_UsedWhirlpool:
end
DisappearWhirlpool:
- ld hl, wBuffer3
+ ld hl, wCutWhirlpoolOverworldBlockAddr
ld a, [hli]
ld h, [hl]
ld l, a
- ld a, [wBuffer5]
+ ld a, [wCutWhirlpoolReplacementBlock]
ld [hl], a
xor a
ldh [hBGMapMode], a
call OverworldTextModeSwitch
- ld a, [wBuffer6]
+ ld a, [wCutWhirlpoolAnimationType]
ld e, a
farcall PlayWhirlpoolSound
call BufferScreen
@@ -1405,7 +1404,7 @@ FishFunction:
push af
call FieldMoveJumptableReset
pop af
- ld [wBuffer2], a
+ ld [wFishingRodUsed], a
.loop
ld hl, .FishTable
call FieldMoveJumptable
@@ -1444,7 +1443,7 @@ FishFunction:
.goodtofish
ld d, a
- ld a, [wBuffer2]
+ ld a, [wFishingRodUsed]
ld e, a
farcall Fish
ld a, d
@@ -1468,7 +1467,7 @@ FishFunction:
.FishGotSomething:
ld a, $1
- ld [wBuffer6], a
+ ld [wFishingResult], a
ld hl, Script_GotABite
call QueueScript
ld a, $81
@@ -1476,7 +1475,7 @@ FishFunction:
.FishNoBite:
ld a, $2
- ld [wBuffer6], a
+ ld [wFishingResult], a
ld hl, Script_NotEvenANibble
call QueueScript
ld a, $81
@@ -1484,7 +1483,7 @@ FishFunction:
.FishNoFish:
ld a, $0
- ld [wBuffer6], a
+ ld [wFishingResult], a
ld hl, Script_NotEvenANibble2
call QueueScript
ld a, $81
diff --git a/engine/items/item_effects.asm b/engine/items/item_effects.asm
index 721819a7..d0f736ec 100644
--- a/engine/items/item_effects.asm
+++ b/engine/items/item_effects.asm
@@ -360,7 +360,7 @@ PokeBallEffect:
.skip_hp_calc
ld b, a
- ld [wBuffer1], a
+ ld [wFinalCatchRate], a
call Random
cp b
@@ -390,28 +390,28 @@ PokeBallEffect:
ld [wFXAnimID + 1], a
xor a
ldh [hBattleTurn], a
- ld [wBuffer2], a
+ ld [wThrownBallWobbleCount], a
ld [wNumHits], a
predef PlayBattleAnim
ld a, [wWildMon]
and a
jr nz, .caught
- ld a, [wBuffer2]
- cp $1
+ ld a, [wThrownBallWobbleCount]
+ cp 1
ld hl, BallBrokeFreeText
jp z, .shake_and_break_free
- cp $2
+ cp 2
ld hl, BallAppearedCaughtText
jp z, .shake_and_break_free
- cp $3
+ cp 3
ld hl, BallAlmostHadItText
jp z, .shake_and_break_free
- cp $4
+ cp 4
ld hl, BallSoCloseText
jp z, .shake_and_break_free
-.caught
+.caught
ld hl, wEnemyMonStatus
ld a, [hli]
push af
@@ -2685,12 +2685,12 @@ ApplyPPUp:
ld a, MON_MOVES
call GetPartyParamLocation
push hl
- ld de, wBuffer1
+ ld de, wPPUpPPBuffer
predef FillPP
pop hl
ld bc, MON_PP - MON_MOVES
add hl, bc
- ld de, wBuffer1
+ ld de, wPPUpPPBuffer
ld b, 0
.loop
inc b
diff --git a/wram.asm b/wram.asm
index 1a2f7ebb..5c08fa08 100644
--- a/wram.asm
+++ b/wram.asm
@@ -1918,14 +1918,24 @@ wCurHPAnimLowHP:: db
wCurHPAnimHighHP:: db
NEXTU
-; battle AI
+; move AI
wEnemyAIMoveScores:: ds NUM_MOVES
NEXTU
+; switch AI
+wEnemyEffectivenessVsPlayerMons:: flag_array PARTY_LENGTH
+wPlayerEffectivenessVsEnemyMons:: flag_array PARTY_LENGTH
+
+NEXTU
; battle HUD
wBattleHUDTiles:: ds PARTY_LENGTH
NEXTU
+; thrown ball data
+wFinalCatchRate:: db
+wThrownBallWobbleCount:: db
+
+NEXTU
; evolution data
wEvolutionOldSpecies:: db
wEvolutionNewSpecies:: db
@@ -1937,6 +1947,10 @@ NEXTU
wExpToNextLevel:: ds 3
NEXTU
+; PP Up
+wPPUpPPBuffer:: ds NUM_MOVES
+
+NEXTU
; lucky number show
wMonIDDigitsBuffer:: ds 5
@@ -1946,6 +1960,28 @@ wMonSubmenuCount:: db
wMonSubmenuItems:: ds NUM_MONMENU_ITEMS + 1
NEXTU
+; field move data
+wFieldMoveData::
+wFieldMoveJumptableIndex:: db
+wEscapeRopeOrDigType::
+wSurfingPlayerState::
+wFishingRodUsed:: db
+wCutWhirlpoolOverworldBlockAddr:: dw
+wCutWhirlpoolReplacementBlock:: db
+wCutWhirlpoolAnimationType::
+wStrengthSpecies::
+wFishingResult:: db
+ ds 1
+wFieldMoveDataEnd::
+
+NEXTU
+; hidden items
+wCurMapScriptBank:: db
+wRemainingBGEventCount:: db
+wBottomRightYCoord:: db
+wBottomRightXCoord:: db
+
+NEXTU
; heal machine anim
wHealMachineAnimType:: db
wHealMachineTempOBP1:: db