Identify some more uses of wBuffer1-6

This commit is contained in:
Rangi 2020-11-03 22:45:12 -05:00
parent c88c4a8340
commit 9f62d7911b
6 changed files with 110 additions and 75 deletions

View File

@ -3226,13 +3226,13 @@ AddBattleParticipant:
FindMonInOTPartyToSwitchIntoBattle: FindMonInOTPartyToSwitchIntoBattle:
ld b, -1 ld b, -1
ld a, $1 ld a, %000001
ld [wBuffer1], a ld [wEnemyEffectivenessVsPlayerMons], a
ld [wBuffer2], a ld [wPlayerEffectivenessVsEnemyMons], a
.loop .loop
ld hl, wBuffer1 ld hl, wEnemyEffectivenessVsPlayerMons
sla [hl] sla [hl]
inc hl inc hl ; wPlayerEffectivenessVsEnemyMons
sla [hl] sla [hl]
inc b inc b
ld a, [wOTPartyCount] ld a, [wOTPartyCount]
@ -3256,7 +3256,7 @@ FindMonInOTPartyToSwitchIntoBattle:
jr .loop jr .loop
.discourage .discourage
ld hl, wBuffer2 ld hl, wPlayerEffectivenessVsEnemyMons
set 0, [hl] set 0, [hl]
jr .loop jr .loop
@ -3291,7 +3291,7 @@ LookUpTheEffectivenessOfEveryMove:
ld a, [wTypeMatchup] ld a, [wTypeMatchup]
cp EFFECTIVE + 1 cp EFFECTIVE + 1
jr c, .loop jr c, .loop
ld hl, wBuffer1 ld hl, wEnemyEffectivenessVsPlayerMons
set 0, [hl] set 0, [hl]
ret ret
.done .done
@ -3334,10 +3334,10 @@ IsThePlayerMonTypesEffectiveAgainstOTMon:
.super_effective .super_effective
pop bc pop bc
ld hl, wBuffer1 ld hl, wEnemyEffectivenessVsPlayerMons
bit 0, [hl] bit 0, [hl]
jr nz, .reset jr nz, .reset
inc hl inc hl ; wPlayerEffectivenessVsEnemyMons
set 0, [hl] set 0, [hl]
ret ret
@ -3347,9 +3347,9 @@ IsThePlayerMonTypesEffectiveAgainstOTMon:
ScoreMonTypeMatchups: ScoreMonTypeMatchups:
.loop1 .loop1
ld hl, wBuffer1 ld hl, wEnemyEffectivenessVsPlayerMons
sla [hl] sla [hl]
inc hl inc hl ; wPlayerEffectivenessVsEnemyMons
sla [hl] sla [hl]
jr nc, .loop1 jr nc, .loop1
ld a, [wOTPartyCount] ld a, [wOTPartyCount]
@ -3363,7 +3363,7 @@ ScoreMonTypeMatchups:
jr .loop2 jr .loop2
.okay .okay
ld a, [wBuffer1] ld a, [wEnemyEffectivenessVsPlayerMons]
and a and a
jr z, .okay2 jr z, .okay2
ld b, -1 ld b, -1
@ -3376,7 +3376,7 @@ ScoreMonTypeMatchups:
.okay2 .okay2
ld b, -1 ld b, -1
ld a, [wBuffer2] ld a, [wPlayerEffectivenessVsEnemyMons]
ld c, a ld c, a
.loop4 .loop4
inc b inc b

View File

@ -8,12 +8,12 @@ GetPokeBallWobble:
ld d, a ld d, a
push de push de
ld a, BANK(wBuffer2) ld a, BANK(wThrownBallWobbleCount) ; aka BANK(wFinalCatchRate)
ldh [rSVBK], a ldh [rSVBK], a
ld a, [wBuffer2] ld a, [wThrownBallWobbleCount]
inc a inc a
ld [wBuffer2], a ld [wThrownBallWobbleCount], a
; Wobble up to 3 times. ; Wobble up to 3 times.
cp 3 + 1 cp 3 + 1
@ -25,7 +25,7 @@ GetPokeBallWobble:
jr nz, .done jr nz, .done
ld hl, WobbleProbabilities ld hl, WobbleProbabilities
ld a, [wBuffer1] ld a, [wFinalCatchRate]
ld b, a ld b, a
.loop .loop
ld a, [hli] ld a, [hli]

View File

@ -1,14 +1,14 @@
CheckForHiddenItems: CheckForHiddenItems:
; Checks to see if there are hidden items on the screen that have not yet been found. If it finds one, returns carry. ; 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 call GetMapScriptsBank
ld [wBuffer1], a ld [wCurMapScriptBank], a
; Get the coordinate of the bottom right corner of the screen, and load it in wBuffer3/wBuffer4. ; Get the coordinate of the bottom right corner of the screen, and load it in wBottomRightYCoord/wBottomRightXCoord.
ld a, [wXCoord] ld a, [wXCoord]
add SCREEN_WIDTH / 4 add SCREEN_WIDTH / 4
ld [wBuffer4], a ld [wBottomRightXCoord], a
ld a, [wYCoord] ld a, [wYCoord]
add SCREEN_HEIGHT / 4 add SCREEN_HEIGHT / 4
ld [wBuffer3], a ld [wBottomRightYCoord], a
; Get the pointer for the first bg_event in the map... ; Get the pointer for the first bg_event in the map...
ld hl, wCurMapBGEventsPointer ld hl, wCurMapBGEventsPointer
ld a, [hli] ld a, [hli]
@ -20,14 +20,14 @@ CheckForHiddenItems:
jr z, .nobgeventitems jr z, .nobgeventitems
; For i = 1:wCurMapBGEventCount... ; For i = 1:wCurMapBGEventCount...
.loop .loop
; Store the counter in wBuffer2, and store the bg_event pointer in the stack. ; Store the counter in wRemainingBGEventCount, and store the bg_event pointer in the stack.
ld [wBuffer2], a ld [wRemainingBGEventCount], a
push hl push hl
; Get the Y coordinate of the BG event. ; Get the Y coordinate of the BG event.
call .GetFarByte call .GetFarByte
ld e, a ld e, a
; Is the Y coordinate of the BG event on the screen? If not, go to the next BG event. ; 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 sub e
jr c, .next jr c, .next
cp SCREEN_HEIGHT / 2 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. ; Is the X coordinate of the BG event on the screen? If not, go to the next BG event.
call .GetFarByte call .GetFarByte
ld d, a ld d, a
ld a, [wBuffer4] ld a, [wBottomRightXCoord]
sub d sub d
jr c, .next jr c, .next
cp SCREEN_WIDTH / 2 cp SCREEN_WIDTH / 2
@ -45,9 +45,9 @@ CheckForHiddenItems:
cp BGEVENT_ITEM cp BGEVENT_ITEM
jr nz, .next jr nz, .next
; Has this item already been found? If not, set off the Itemfinder. ; Has this item already been found? If not, set off the Itemfinder.
ld a, [wBuffer1] ld a, [wCurMapScriptBank]
call GetFarHalfword call GetFarHalfword
ld a, [wBuffer1] ld a, [wCurMapScriptBank]
call GetFarHalfword call GetFarHalfword
ld d, h ld d, h
ld e, l ld e, l
@ -63,7 +63,7 @@ CheckForHiddenItems:
ld bc, BG_EVENT_SIZE ld bc, BG_EVENT_SIZE
add hl, bc add hl, bc
; Restore the BG event counter and decrement it. If it hits zero, there are no hidden items in range. ; 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 dec a
jr nz, .loop jr nz, .loop
@ -77,7 +77,7 @@ CheckForHiddenItems:
ret ret
.GetFarByte: .GetFarByte:
ld a, [wBuffer1] ld a, [wCurMapScriptBank]
call GetFarByte call GetFarByte
inc hl inc hl
ret ret

View File

@ -1,14 +1,14 @@
FieldMoveJumptableReset: FieldMoveJumptableReset:
xor a xor a
ld hl, wBuffer1 ld hl, wFieldMoveData
ld bc, 7 ld bc, wFieldMoveDataEnd - wFieldMoveData
call ByteFill call ByteFill
ret ret
FieldMoveJumptable: FieldMoveJumptable:
ld a, [wBuffer1] ld a, [wFieldMoveJumptableIndex]
rst JumpTable rst JumpTable
ld [wBuffer1], a ld [wFieldMoveJumptableIndex], a
bit 7, a bit 7, a
jr nz, .okay jr nz, .okay
and a and a
@ -183,17 +183,15 @@ CheckMapForSomethingToCut:
call CheckOverworldTileArrays call CheckOverworldTileArrays
pop hl pop hl
jr nc, .fail jr nc, .fail
; Back up the wOverworldMapBlocks address to wBuffer3 ; Save the Cut field move data
ld a, l ld a, l
ld [wBuffer3], a ld [wCutWhirlpoolOverworldBlockAddr], a
ld a, h ld a, h
ld [wBuffer4], a ld [wCutWhirlpoolOverworldBlockAddr + 1], a
; Back up the replacement tile to wBuffer5
ld a, b ld a, b
ld [wBuffer5], a ld [wCutWhirlpoolReplacementBlock], a
; Back up the animation index to wBuffer6
ld a, c ld a, c
ld [wBuffer6], a ld [wCutWhirlpoolAnimationType], a
xor a xor a
ret ret
@ -214,18 +212,18 @@ Script_Cut:
end end
CutDownTreeOrGrass: CutDownTreeOrGrass:
ld hl, wBuffer3 ; OverworldMapTile ld hl, wCutWhirlpoolOverworldBlockAddr
ld a, [hli] ld a, [hli]
ld h, [hl] ld h, [hl]
ld l, a ld l, a
ld a, [wBuffer5] ; ReplacementTile ld a, [wCutWhirlpoolReplacementBlock]
ld [hl], a ld [hl], a
xor a xor a
ldh [hBGMapMode], a ldh [hBGMapMode], a
call OverworldTextModeSwitch call OverworldTextModeSwitch
call UpdateSprites call UpdateSprites
call DelayFrame call DelayFrame
ld a, [wBuffer6] ; Animation type ld a, [wCutWhirlpoolAnimationType]
ld e, a ld e, a
farcall OWCutAnimation farcall OWCutAnimation
call BufferScreen call BufferScreen
@ -380,7 +378,7 @@ SurfFunction:
.DoSurf: .DoSurf:
call GetSurfType call GetSurfType
ld [wBuffer2], a ld [wSurfingPlayerState], a
call GetPartyNick call GetPartyNick
ld hl, SurfFromMenuScript ld hl, SurfFromMenuScript
call QueueScript call QueueScript
@ -409,7 +407,7 @@ UsedSurfScript:
callasm .stubbed_fn callasm .stubbed_fn
readmem wBuffer2 readmem wSurfingPlayerState
writevar VAR_MOVEMENT writevar VAR_MOVEMENT
special UpdatePlayerSprite special UpdatePlayerSprite
@ -517,7 +515,7 @@ TrySurfOW::
jr nz, .quit jr nz, .quit
call GetSurfType call GetSurfType
ld [wBuffer2], a ld [wSurfingPlayerState], a
call GetPartyNick call GetPartyNick
ld a, BANK(AskSurfScript) ld a, BANK(AskSurfScript)
@ -757,7 +755,7 @@ DigFunction:
ld a, $2 ld a, $2
EscapeRopeOrDig: EscapeRopeOrDig:
ld [wBuffer2], a ld [wEscapeRopeOrDigType], a
.loop .loop
ld hl, .DigTable ld hl, .DigTable
call FieldMoveJumptable call FieldMoveJumptable
@ -801,7 +799,7 @@ EscapeRopeOrDig:
ld bc, 3 ld bc, 3
call CopyBytes call CopyBytes
call GetPartyNick call GetPartyNick
ld a, [wBuffer2] ld a, [wEscapeRopeOrDigType]
cp $2 cp $2
jr nz, .escaperope jr nz, .escaperope
ld hl, .UsedDigScript ld hl, .UsedDigScript
@ -817,7 +815,7 @@ EscapeRopeOrDig:
ret ret
.FailDig: .FailDig:
ld a, [wBuffer2] ld a, [wEscapeRopeOrDigType]
cp $2 cp $2
jr nz, .failescaperope jr nz, .failescaperope
ld hl, .CantUseDigText ld hl, .CantUseDigText
@ -1000,7 +998,7 @@ SetStrengthFlag:
ld hl, wPartySpecies ld hl, wPartySpecies
add hl, de add hl, de
ld a, [hl] ld a, [hl]
ld [wBuffer6], a ld [wStrengthSpecies], a
call GetPartyNick call GetPartyNick
ret ret
@ -1011,8 +1009,8 @@ Script_StrengthFromMenu:
Script_UsedStrength: Script_UsedStrength:
callasm SetStrengthFlag callasm SetStrengthFlag
writetext .UseStrengthText writetext .UseStrengthText
readmem wBuffer6 readmem wStrengthSpecies
cry 0 cry 0 ; plays [wStrengthSpecies] cry
pause 3 pause 3
writetext .MoveBoulderText writetext .MoveBoulderText
closetext closetext
@ -1147,14 +1145,15 @@ TryWhirlpoolMenu:
call CheckOverworldTileArrays call CheckOverworldTileArrays
pop hl pop hl
jr nc, .failed jr nc, .failed
; Save the Whirlpool field move data
ld a, l ld a, l
ld [wBuffer3], a ld [wCutWhirlpoolOverworldBlockAddr], a
ld a, h ld a, h
ld [wBuffer4], a ld [wCutWhirlpoolOverworldBlockAddr + 1], a
ld a, b ld a, b
ld [wBuffer5], a ld [wCutWhirlpoolReplacementBlock], a
ld a, c ld a, c
ld [wBuffer6], a ld [wCutWhirlpoolAnimationType], a
xor a xor a
ret ret
@ -1175,16 +1174,16 @@ Script_UsedWhirlpool:
end end
DisappearWhirlpool: DisappearWhirlpool:
ld hl, wBuffer3 ld hl, wCutWhirlpoolOverworldBlockAddr
ld a, [hli] ld a, [hli]
ld h, [hl] ld h, [hl]
ld l, a ld l, a
ld a, [wBuffer5] ld a, [wCutWhirlpoolReplacementBlock]
ld [hl], a ld [hl], a
xor a xor a
ldh [hBGMapMode], a ldh [hBGMapMode], a
call OverworldTextModeSwitch call OverworldTextModeSwitch
ld a, [wBuffer6] ld a, [wCutWhirlpoolAnimationType]
ld e, a ld e, a
farcall PlayWhirlpoolSound farcall PlayWhirlpoolSound
call BufferScreen call BufferScreen
@ -1429,7 +1428,7 @@ FishFunction:
push af push af
call FieldMoveJumptableReset call FieldMoveJumptableReset
pop af pop af
ld [wBuffer2], a ld [wFishingRodUsed], a
.loop .loop
ld hl, .FishTable ld hl, .FishTable
call FieldMoveJumptable call FieldMoveJumptable
@ -1468,7 +1467,7 @@ FishFunction:
.goodtofish .goodtofish
ld d, a ld d, a
ld a, [wBuffer2] ld a, [wFishingRodUsed]
ld e, a ld e, a
farcall Fish farcall Fish
ld a, d ld a, d
@ -1492,7 +1491,7 @@ FishFunction:
.FishGotSomething: .FishGotSomething:
ld a, $1 ld a, $1
ld [wBuffer6], a ld [wFishingResult], a
ld hl, Script_GotABite ld hl, Script_GotABite
call QueueScript call QueueScript
ld a, $81 ld a, $81
@ -1500,7 +1499,7 @@ FishFunction:
.FishNoBite: .FishNoBite:
ld a, $2 ld a, $2
ld [wBuffer6], a ld [wFishingResult], a
ld hl, Script_NotEvenANibble ld hl, Script_NotEvenANibble
call QueueScript call QueueScript
ld a, $81 ld a, $81
@ -1508,7 +1507,7 @@ FishFunction:
.FishNoFish: .FishNoFish:
ld a, $0 ld a, $0
ld [wBuffer6], a ld [wFishingResult], a
ld hl, Script_NotEvenANibble2 ld hl, Script_NotEvenANibble2
call QueueScript call QueueScript
ld a, $81 ld a, $81

View File

@ -360,7 +360,7 @@ PokeBallEffect:
.skip_hp_calc .skip_hp_calc
ld b, a ld b, a
ld [wBuffer1], a ld [wFinalCatchRate], a
call Random call Random
cp b cp b
@ -390,28 +390,28 @@ PokeBallEffect:
ld [wFXAnimID + 1], a ld [wFXAnimID + 1], a
xor a xor a
ldh [hBattleTurn], a ldh [hBattleTurn], a
ld [wBuffer2], a ld [wThrownBallWobbleCount], a
ld [wNumHits], a ld [wNumHits], a
predef PlayBattleAnim predef PlayBattleAnim
ld a, [wWildMon] ld a, [wWildMon]
and a and a
jr nz, .caught jr nz, .caught
ld a, [wBuffer2] ld a, [wThrownBallWobbleCount]
cp $1 cp 1
ld hl, BallBrokeFreeText ld hl, BallBrokeFreeText
jp z, .shake_and_break_free jp z, .shake_and_break_free
cp $2 cp 2
ld hl, BallAppearedCaughtText ld hl, BallAppearedCaughtText
jp z, .shake_and_break_free jp z, .shake_and_break_free
cp $3 cp 3
ld hl, BallAlmostHadItText ld hl, BallAlmostHadItText
jp z, .shake_and_break_free jp z, .shake_and_break_free
cp $4 cp 4
ld hl, BallSoCloseText ld hl, BallSoCloseText
jp z, .shake_and_break_free jp z, .shake_and_break_free
.caught
.caught
ld hl, wEnemyMonStatus ld hl, wEnemyMonStatus
ld a, [hli] ld a, [hli]
push af push af
@ -2723,12 +2723,12 @@ ApplyPPUp:
ld a, MON_MOVES ld a, MON_MOVES
call GetPartyParamLocation call GetPartyParamLocation
push hl push hl
ld de, wBuffer1 ld de, wPPUpPPBuffer
predef FillPP predef FillPP
pop hl pop hl
ld bc, MON_PP - MON_MOVES ld bc, MON_PP - MON_MOVES
add hl, bc add hl, bc
ld de, wBuffer1 ld de, wPPUpPPBuffer
ld b, 0 ld b, 0
.loop .loop
inc b inc b

View File

@ -2248,13 +2248,23 @@ wCurHPAnimLowHP:: db
wCurHPAnimHighHP:: db wCurHPAnimHighHP:: db
NEXTU NEXTU
; battle AI ; move AI
wEnemyAIMoveScores:: ds NUM_MOVES wEnemyAIMoveScores:: ds NUM_MOVES
NEXTU
; switch AI
wEnemyEffectivenessVsPlayerMons:: flag_array PARTY_LENGTH
wPlayerEffectivenessVsEnemyMons:: flag_array PARTY_LENGTH
NEXTU NEXTU
; battle HUD ; battle HUD
wBattleHUDTiles:: ds PARTY_LENGTH wBattleHUDTiles:: ds PARTY_LENGTH
NEXTU
; thrown ball data
wFinalCatchRate:: db
wThrownBallWobbleCount:: db
NEXTU NEXTU
; evolution data ; evolution data
wEvolutionOldSpecies:: db wEvolutionOldSpecies:: db
@ -2266,6 +2276,10 @@ NEXTU
; experience ; experience
wExpToNextLevel:: ds 3 wExpToNextLevel:: ds 3
NEXTU
; PP Up
wPPUpPPBuffer:: ds NUM_MOVES
NEXTU NEXTU
; lucky number show ; lucky number show
wMonIDDigitsBuffer:: ds 5 wMonIDDigitsBuffer:: ds 5
@ -2275,6 +2289,28 @@ NEXTU
wMonSubmenuCount:: db wMonSubmenuCount:: db
wMonSubmenuItems:: ds NUM_MONMENU_ITEMS + 1 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 NEXTU
; heal machine anim ; heal machine anim
wHealMachineAnimType:: db wHealMachineAnimType:: db