Identify and eliminate wEngineBuffer1-5

This commit is contained in:
Rangi
2019-04-08 18:50:10 -04:00
parent ec8869584f
commit 2184b60a0c
19 changed files with 194 additions and 164 deletions

View File

@@ -602,8 +602,8 @@ TryObjectEvent:
ld h, [hl]
ld l, a
call GetMapScriptsBank
ld de, wEngineBuffer1
ld bc, 2
ld de, wItemBallData
ld bc, wItemBallDataEnd - wItemBallData
call FarCopyBytes
ld a, PLAYEREVENT_ITEMBALL
scf
@@ -638,7 +638,7 @@ TryBGEvent:
ret
.is_bg_event:
ld a, [wEngineBuffer3]
ld a, [wCurBGEventType]
ld hl, .bg_events
rst JumpTable
ret
@@ -675,7 +675,7 @@ TryBGEvent:
.read
call PlayTalkObject
ld hl, wEngineBuffer4
ld hl, wCurBGEventScriptAddr
ld a, [hli]
ld h, [hl]
ld l, a
@@ -689,8 +689,8 @@ TryBGEvent:
jp nz, .dontread
call PlayTalkObject
call GetMapScriptsBank
ld de, wEngineBuffer1
ld bc, 3
ld de, wHiddenItemData
ld bc, wHiddenItemDataEnd - wHiddenItemData
call FarCopyBytes
ld a, BANK(HiddenItemScript)
ld hl, HiddenItemScript
@@ -702,8 +702,8 @@ TryBGEvent:
call CheckBGEventFlag
jr nz, .dontread
call GetMapScriptsBank
ld de, wEngineBuffer1
ld bc, 3
ld de, wHiddenItemData
ld bc, wHiddenItemDataEnd - wHiddenItemData
call FarCopyBytes
jr .dontread
@@ -734,7 +734,7 @@ TryBGEvent:
ret
CheckBGEventFlag:
ld hl, wEngineBuffer4
ld hl, wCurBGEventScriptAddr
ld a, [hli]
ld h, [hl]
ld l, a
@@ -1076,7 +1076,7 @@ LoadScriptBDE::
TryTileCollisionEvent::
call GetFacingTileCoord
ld [wEngineBuffer1], a
ld [wFacingTileID], a
ld c, a
farcall CheckFacingTileForStdScript
jr c, .done
@@ -1087,21 +1087,21 @@ TryTileCollisionEvent::
jr .done
.whirlpool
ld a, [wEngineBuffer1]
ld a, [wFacingTileID]
call CheckWhirlpoolTile
jr nz, .waterfall
farcall TryWhirlpoolOW
jr .done
.waterfall
ld a, [wEngineBuffer1]
ld a, [wFacingTileID]
call CheckWaterfallTile
jr nz, .headbutt
farcall TryWaterfallOW
jr .done
.headbutt
ld a, [wEngineBuffer1]
ld a, [wFacingTileID]
call CheckHeadbuttTreeTile
jr nz, .surf
farcall TryHeadbuttOW

View File

@@ -4,7 +4,7 @@ DoPlayerMovement::
ld a, movement_step_sleep
ld [wMovementAnimation], a
xor a
ld [wd041], a
ld [wWalkingIntoEdgeWarp], a
call .TranslateIntoMovement
ld c, a
ld a, [wMovementAnimation]
@@ -98,7 +98,7 @@ DoPlayerMovement::
jr z, .Standing
; Walking into an edge warp won't bump.
ld a, [wEngineBuffer4]
ld a, [wWalkingIntoEdgeWarp]
and a
jr nz, .CantMove
call .BumpSound
@@ -321,17 +321,17 @@ DoPlayerMovement::
.TrySurf:
call .CheckSurfPerms
ld [wd040], a
ld [wWalkingIntoLand], a
jr c, .surf_bump
call .CheckNPC
ld [wd03f], a
ld [wWalkingIntoNPC], a
and a
jr z, .surf_bump
cp 2
jr z, .surf_bump
ld a, [wd040]
ld a, [wWalkingIntoLand]
and a
jr nz, .ExitWater
@@ -395,7 +395,7 @@ DoPlayerMovement::
.CheckWarp:
; Bug: Since no case is made for STANDING here, it will check
; [.edgewarps + $ff]. This resolves to $3e at $8035a.
; This causes wd041 to be nonzero when standing on tile $3e,
; This causes wWalkingIntoEdgeWarp to be nonzero when standing on tile $3e,
; making bumps silent.
ld a, [wWalkingDirection]
@@ -409,8 +409,8 @@ DoPlayerMovement::
cp [hl]
jr nz, .not_warp
ld a, 1
ld [wd041], a
ld a, TRUE
ld [wWalkingIntoEdgeWarp], a
ld a, [wWalkingDirection]
; This is in the wrong place.
cp STANDING

View File

@@ -518,7 +518,7 @@ TrainerWalkToPlayer:
call InitMovementBuffer
ld a, movement_step_sleep
call AppendToMovementBuffer
ld a, [wd03f]
ld a, [wWalkingIntoNPC]
dec a
jr z, .TerminateStep
ldh a, [hLastTalked]

View File

@@ -637,7 +637,7 @@ PocketIsFullText:
Script_pokemart:
; script command 0x94
; parameters: dialog_id, mart_id
; parameters: mart_type, mart_id
call GetScriptByte
ld c, a
@@ -765,7 +765,7 @@ Script_trainertext:
ld a, [hli]
ld h, [hl]
ld l, a
ld a, [wEngineBuffer1]
ld a, [wSeenTrainerBank]
ld b, a
call MapTextbox
ret
@@ -777,7 +777,7 @@ Script_scripttalkafter:
ld a, [hli]
ld h, [hl]
ld l, a
ld a, [wEngineBuffer1]
ld a, [wSeenTrainerBank]
ld b, a
jp ScriptJump
@@ -787,7 +787,7 @@ Script_trainerflagaction:
xor a
ld [wScriptVar], a
ld hl, wd041
ld hl, wTempTrainerEventFlag
ld e, [hl]
inc hl
ld d, [hl]