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

@ -65,7 +65,7 @@
const PHONE_CONTACT_SCRIPT2_BANK const PHONE_CONTACT_SCRIPT2_BANK
const PHONE_CONTACT_SCRIPT2_ADDR_LO const PHONE_CONTACT_SCRIPT2_ADDR_LO
const PHONE_CONTACT_SCRIPT2_ADDR_HI const PHONE_CONTACT_SCRIPT2_ADDR_HI
PHONE_TABLE_WIDTH EQU const_value PHONE_CONTACT_SIZE EQU const_value
; maximum number of pokegear contacts ; maximum number of pokegear contacts
CONTACT_LIST_SIZE EQU 10 CONTACT_LIST_SIZE EQU 10

View File

@ -1276,7 +1276,7 @@ Finally, edit [engine/battle/read_trainer_party.asm](https://github.com/pret/pok
.CheckWarp: .CheckWarp:
-; Bug: Since no case is made for STANDING here, it will check -; Bug: Since no case is made for STANDING here, it will check
-; [.edgewarps + $ff]. This resolves to $3e at $8035a. -; [.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. -; making bumps silent.
- -
ld a, [wWalkingDirection] ld a, [wWalkingDirection]
@ -1292,8 +1292,8 @@ Finally, edit [engine/battle/read_trainer_party.asm](https://github.com/pret/pok
cp [hl] cp [hl]
jr nz, .not_warp jr nz, .not_warp
ld a, 1 ld a, TRUE
ld [wd041], a ld [wWalkingIntoEdgeWarp], a
ld a, [wWalkingDirection] ld a, [wWalkingDirection]
- ; This is in the wrong place. - ; This is in the wrong place.
- cp STANDING - cp STANDING

View File

@ -489,7 +489,7 @@ If <code><i>item_id</i></code> = `USE_SCRIPT_VAR`, then it uses `[wScriptVar]` i
## `$93`: `endall` ## `$93`: `endall`
## `$94`: <code>pokemart <i>dialog_id</i>, <i>mart_id</i></code> ## `$94`: <code>pokemart <i>mart_type</i>, <i>mart_id</i></code>
## `$95`: <code>elevator <i>floor_list</i></code> ## `$95`: <code>elevator <i>floor_list</i></code>

View File

@ -28,7 +28,7 @@ Elevator::
.LoadFloors: .LoadFloors:
ld de, wCurElevator ld de, wCurElevator
ld bc, 4 ld bc, wElevatorDataEnd - wElevatorData
ld hl, wElevatorPointer ld hl, wElevatorPointer
ld a, [hli] ld a, [hli]
ld h, [hl] ld h, [hl]
@ -104,12 +104,12 @@ Elevator_GoToFloor:
ld l, a ld l, a
inc hl inc hl
pop af pop af
ld bc, 4 ld bc, wElevatorDataEnd - wElevatorData
call AddNTimes call AddNTimes
inc hl inc hl
ld de, wBackupWarpNumber ld de, wBackupWarpNumber
ld a, [wElevatorPointerBank] ld a, [wElevatorPointerBank]
ld bc, 3 ld bc, wElevatorDataEnd - wElevatorData - 1
call FarCopyBytes call FarCopyBytes
ret ret

View File

@ -40,14 +40,14 @@ FindItemInBallScript::
.TryReceiveItem: .TryReceiveItem:
xor a xor a
ld [wScriptVar], a ld [wScriptVar], a
ld a, [wEngineBuffer1] ld a, [wItemBallItemID]
ld [wNamedObjectIndexBuffer], a ld [wNamedObjectIndexBuffer], a
call GetItemName call GetItemName
ld hl, wStringBuffer3 ld hl, wStringBuffer3
call CopyName2 call CopyName2
ld a, [wEngineBuffer1] ld a, [wItemBallItemID]
ld [wCurItem], a ld [wCurItem], a
ld a, [wCurFruit] ld a, [wItemBallQuantity]
ld [wItemQuantityChangeBuffer], a ld [wItemQuantityChangeBuffer], a
ld hl, wNumItems ld hl, wNumItems
call ReceiveItem call ReceiveItem

View File

@ -12,7 +12,7 @@ RepelWoreOffScript::
HiddenItemScript:: HiddenItemScript::
opentext opentext
readmem wEngineBuffer3 readmem wHiddenItemID
getitemname STRING_BUFFER_3, USE_SCRIPT_VAR getitemname STRING_BUFFER_3, USE_SCRIPT_VAR
writetext .found_text writetext .found_text
giveitem ITEM_FROM_MEM giveitem ITEM_FROM_MEM
@ -42,7 +42,7 @@ HiddenItemScript::
text_end text_end
SetMemEvent: SetMemEvent:
ld hl, wEngineBuffer1 ld hl, wHiddenItemEvent
ld a, [hli] ld a, [hli]
ld d, [hl] ld d, [hl]
ld e, a ld e, a

View File

@ -39,13 +39,13 @@ MomTriesToBuySomething::
.ok .ok
ld a, PHONE_MOM ld a, PHONE_MOM
ld [wCurCaller], a ld [wCurCaller], a
ld bc, wEngineBuffer2 ld bc, wCallerContact
ld hl, 0 ld hl, PHONE_CONTACT_TRAINER_CLASS
add hl, bc add hl, bc
ld [hl], 0 ld [hl], TRAINER_NONE
inc hl inc hl
ld [hl], 1 ld [hl], PHONE_MOM
ld hl, wPhoneScriptPointer - wEngineBuffer2 ld hl, PHONE_CONTACT_SCRIPT2_BANK
add hl, bc add hl, bc
ld a, BANK(Mom_GetScriptPointer) ld a, BANK(Mom_GetScriptPointer)
ld [hli], a ld [hli], a

View File

@ -500,7 +500,7 @@ TrySurfOW::
jr z, .quit jr z, .quit
; Must be facing water. ; Must be facing water.
ld a, [wEngineBuffer1] ld a, [wFacingTileID]
call GetTileCollision call GetTileCollision
cp WATERTILE cp WATERTILE
jr nz, .quit jr nz, .quit

View File

@ -4,29 +4,29 @@ DoPoisonStep::
jr z, .no_faint jr z, .no_faint
xor a xor a
ld c, 7 ld c, wPoisonStepDataEnd - wPoisonStepData
ld hl, wEngineBuffer1 ld hl, wPoisonStepData
.loop_clearEngineBuffer1 .loop_clearPoisonStepData
ld [hli], a ld [hli], a
dec c dec c
jr nz, .loop_clearEngineBuffer1 jr nz, .loop_clearPoisonStepData
xor a xor a
ld [wCurPartyMon], a ld [wCurPartyMon], a
.loop_check_poison .loop_check_poison
call .DamageMonIfPoisoned call .DamageMonIfPoisoned
jr nc, .not_poisoned jr nc, .not_poisoned
; the output flag is stored in c, copy it to the ([wCurPartyMon] + 2)nd EngineBuffer ; the output flag is stored in c, copy it to [wPoisonStepPartyFlags + [wCurPartyMon]]
; and set the corresponding flag in wEngineBuffer1 ; and set the corresponding flag in wPoisonStepFlagSum
ld a, [wCurPartyMon] ld a, [wCurPartyMon]
ld e, a ld e, a
ld d, 0 ld d, 0
ld hl, wEngineBuffer2 ld hl, wPoisonStepPartyFlags
add hl, de add hl, de
ld [hl], c ld [hl], c
ld a, [wEngineBuffer1] ld a, [wPoisonStepFlagSum]
or c or c
ld [wEngineBuffer1], a ld [wPoisonStepFlagSum], a
.not_poisoned .not_poisoned
ld a, [wPartyCount] ld a, [wPartyCount]
@ -35,10 +35,10 @@ DoPoisonStep::
cp [hl] cp [hl]
jr nz, .loop_check_poison jr nz, .loop_check_poison
ld a, [wEngineBuffer1] ld a, [wPoisonStepFlagSum]
and %10 and %10
jr nz, .someone_has_fainted jr nz, .someone_has_fainted
ld a, [wEngineBuffer1] ld a, [wPoisonStepFlagSum]
and %01 and %01
jr z, .no_faint jr z, .no_faint
call .PlayPoisonSFX call .PlayPoisonSFX
@ -120,7 +120,7 @@ DoPoisonStep::
.CheckWhitedOut: .CheckWhitedOut:
xor a xor a
ld [wCurPartyMon], a ld [wCurPartyMon], a
ld de, wEngineBuffer2 ld de, wPoisonStepPartyFlags
.party_loop .party_loop
push de push de
ld a, [de] ld a, [de]

View File

@ -9,9 +9,9 @@
OpenMartDialog:: OpenMartDialog::
call GetMart call GetMart
ld a, c ld a, c
ld [wEngineBuffer1], a ld [wMartType], a
call LoadMartPointer call LoadMartPointer
ld a, [wEngineBuffer1] ld a, [wMartType]
ld hl, .dialogs ld hl, .dialogs
rst JumpTable rst JumpTable
ret ret
@ -24,10 +24,10 @@ OpenMartDialog::
dw RooftopSale dw RooftopSale
MartDialog: MartDialog:
ld a, 0 ld a, MARTTYPE_STANDARD
ld [wEngineBuffer1], a ld [wMartType], a
xor a ; STANDARDMART_HOWMAYIHELPYOU xor a ; STANDARDMART_HOWMAYIHELPYOU
ld [wEngineBuffer5], a ld [wMartJumptableIndex], a
call StandardMart call StandardMart
ret ret
@ -105,8 +105,8 @@ LoadMartPointer:
xor a xor a
ld bc, wCurMartEnd - wCurMart ld bc, wCurMartEnd - wCurMart
call ByteFill call ByteFill
xor a xor a ; STANDARDMART_HOWMAYIHELPYOU
ld [wEngineBuffer5], a ld [wMartJumptableIndex], a
ld [wBargainShopFlags], a ld [wBargainShopFlags], a
ld [wFacingDirection], a ld [wFacingDirection], a
ret ret
@ -138,13 +138,15 @@ GetMart:
const STANDARDMART_QUIT ; 4 const STANDARDMART_QUIT ; 4
const STANDARDMART_ANYTHINGELSE ; 5 const STANDARDMART_ANYTHINGELSE ; 5
STANDARDMART_EXIT EQU -1
StandardMart: StandardMart:
.loop .loop
ld a, [wEngineBuffer5] ld a, [wMartJumptableIndex]
ld hl, .MartFunctions ld hl, .MartFunctions
rst JumpTable rst JumpTable
ld [wEngineBuffer5], a ld [wMartJumptableIndex], a
cp -1 cp STANDARDMART_EXIT
jr nz, .loop jr nz, .loop
ret ret
@ -202,7 +204,7 @@ StandardMart:
call ExitMenu call ExitMenu
ld hl, Text_Mart_ComeAgain ld hl, Text_Mart_ComeAgain
call MartTextBox call MartTextBox
ld a, -1 ld a, STANDARDMART_EXIT
ret ret
.AnythingElse: .AnythingElse:
@ -346,7 +348,7 @@ BuyMenu:
LoadBuyMenuText: LoadBuyMenuText:
; load text from a nested table ; load text from a nested table
; which table is in wEngineBuffer1 ; which table is in wMartType
; which entry is in register a ; which entry is in register a
push af push af
call GetMartDialogGroup ; gets a pointer from GetMartDialogGroup.MartTextFunctionPointers call GetMartDialogGroup ; gets a pointer from GetMartDialogGroup.MartTextFunctionPointers
@ -376,7 +378,7 @@ MartAskPurchaseQuantity:
jp RooftopSaleAskPurchaseQuantity jp RooftopSaleAskPurchaseQuantity
GetMartDialogGroup: GetMartDialogGroup:
ld a, [wEngineBuffer1] ld a, [wMartType]
ld e, a ld e, a
ld d, 0 ld d, 0
ld hl, .MartTextFunctionPointers ld hl, .MartTextFunctionPointers

View File

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

View File

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

View File

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

View File

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

View File

@ -163,12 +163,13 @@ CheckPhoneContactTimeOfDay:
ChooseRandomCaller: ChooseRandomCaller:
; If no one is available to call, don't return anything. ; If no one is available to call, don't return anything.
ld a, [wEngineBuffer3] ld a, [wNumAvailableCallers]
and a and a
jr z, .NothingToSample jr z, .NothingToSample
; Sample a random number between 0 and 31. ; Store the number of available callers in c.
ld c, a ld c, a
; Sample a random number between 0 and 31.
call Random call Random
ldh a, [hRandomAdd] ldh a, [hRandomAdd]
swap a swap a
@ -178,7 +179,7 @@ ChooseRandomCaller:
; Return the caller ID you just sampled. ; Return the caller ID you just sampled.
ld c, a ld c, a
ld b, 0 ld b, 0
ld hl, wEngineBuffer4 ld hl, wAvailableCallers
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
scf scf
@ -191,23 +192,23 @@ ChooseRandomCaller:
GetAvailableCallers: GetAvailableCallers:
farcall CheckTime farcall CheckTime
ld a, c ld a, c
ld [wEngineBuffer1], a ld [wCheckedTime], a
ld hl, wEngineBuffer3 ld hl, wNumAvailableCallers
ld bc, 11 ld bc, CONTACT_LIST_SIZE + 1
xor a xor a
call ByteFill call ByteFill
ld de, wPhoneList ld de, wPhoneList
ld a, CONTACT_LIST_SIZE ld a, CONTACT_LIST_SIZE
.loop .loop
ld [wEngineBuffer2], a ld [wPhoneListIndex], a
ld a, [de] ld a, [de]
and a and a
jr z, .not_good_for_call jr z, .not_good_for_call
ld hl, PhoneContacts + PHONE_CONTACT_SCRIPT2_TIME ld hl, PhoneContacts + PHONE_CONTACT_SCRIPT2_TIME
ld bc, PHONE_TABLE_WIDTH ld bc, PHONE_CONTACT_SIZE
call AddNTimes call AddNTimes
ld a, [wEngineBuffer1] ld a, [wCheckedTime]
and [hl] and [hl]
jr z, .not_good_for_call jr z, .not_good_for_call
ld bc, PHONE_CONTACT_MAP_GROUP - PHONE_CONTACT_SCRIPT2_TIME ld bc, PHONE_CONTACT_MAP_GROUP - PHONE_CONTACT_SCRIPT2_TIME
@ -220,18 +221,18 @@ GetAvailableCallers:
cp [hl] cp [hl]
jr z, .not_good_for_call jr z, .not_good_for_call
.different_map .different_map
ld a, [wEngineBuffer3] ld a, [wNumAvailableCallers]
ld c, a ld c, a
ld b, $0 ld b, $0
inc a inc a
ld [wEngineBuffer3], a ld [wNumAvailableCallers], a
ld hl, wEngineBuffer4 ld hl, wAvailableCallers
add hl, bc add hl, bc
ld a, [de] ld a, [de]
ld [hl], a ld [hl], a
.not_good_for_call .not_good_for_call
inc de inc de
ld a, [wEngineBuffer2] ld a, [wPhoneListIndex]
dec a dec a
jr nz, .loop jr nz, .loop
ret ret
@ -261,7 +262,7 @@ CheckSpecialPhoneCall::
push hl push hl
call LoadCallerScript call LoadCallerScript
pop hl pop hl
ld de, wPhoneScriptPointer ld de, wCallerContact + PHONE_CONTACT_SCRIPT2_BANK
ld a, [hli] ld a, [hli]
ld [de], a ld [de], a
inc de inc de
@ -323,7 +324,7 @@ Function90199:
ld a, b ld a, b
ld [wCurCaller], a ld [wCurCaller], a
ld hl, PhoneContacts ld hl, PhoneContacts
ld bc, PHONE_TABLE_WIDTH ld bc, PHONE_CONTACT_SIZE
call AddNTimes call AddNTimes
ld d, h ld d, h
ld e, l ld e, l
@ -398,13 +399,13 @@ LoadCallerScript:
.actualcaller .actualcaller
ld hl, PhoneContacts ld hl, PhoneContacts
ld bc, 12 ld bc, PHONE_CONTACT_SIZE
ld a, e ld a, e
call AddNTimes call AddNTimes
ld a, BANK(PhoneContacts) ld a, BANK(PhoneContacts)
.proceed .proceed
ld de, wEngineBuffer2 ld de, wCallerContact
ld bc, 12 ld bc, PHONE_CONTACT_SIZE
call FarCopyBytes call FarCopyBytes
ret ret
@ -422,7 +423,7 @@ WrongNumber:
Script_ReceivePhoneCall: Script_ReceivePhoneCall:
refreshscreen refreshscreen
callasm RingTwice_StartCall callasm RingTwice_StartCall
memcall wPhoneScriptPointer memcall wCallerContact + PHONE_CONTACT_SCRIPT2_BANK
waitbutton waitbutton
callasm HangUp callasm HangUp
closetext closetext
@ -620,7 +621,7 @@ CheckCanDeletePhoneNumber:
GetCallerTrainerClass: GetCallerTrainerClass:
push hl push hl
ld hl, PhoneContacts + PHONE_CONTACT_TRAINER_CLASS ld hl, PhoneContacts + PHONE_CONTACT_TRAINER_CLASS
ld bc, PHONE_TABLE_WIDTH ld bc, PHONE_CONTACT_SIZE
call AddNTimes call AddNTimes
ld a, [hli] ld a, [hli]
ld b, [hl] ld b, [hl]
@ -687,7 +688,7 @@ GetCallerLocation:
push de push de
ld a, [wCurCaller] ld a, [wCurCaller]
ld hl, PhoneContacts + PHONE_CONTACT_MAP_GROUP ld hl, PhoneContacts + PHONE_CONTACT_MAP_GROUP
ld bc, PHONE_TABLE_WIDTH ld bc, PHONE_CONTACT_SIZE
call AddNTimes call AddNTimes
ld b, [hl] ld b, [hl]
inc hl inc hl

View File

@ -1782,7 +1782,7 @@ CheckFacingBGEvent::
ret ret
CheckIfFacingTileCoordIsBGEvent:: CheckIfFacingTileCoordIsBGEvent::
; Checks to see if you are facing a BG event. If so, copies it into wEngineBuffer1 and sets carry. ; Checks to see if you are facing a BG event. If so, copies it into wCurBGEvent and sets carry.
ld hl, wCurMapBGEventsPointer ld hl, wCurMapBGEventsPointer
ld a, [hli] ld a, [hli]
ld h, [hl] ld h, [hl]
@ -1813,7 +1813,7 @@ CheckIfFacingTileCoordIsBGEvent::
.copysign .copysign
pop hl pop hl
ld de, wCurBGEventYCoord ld de, wCurBGEvent
ld bc, BG_EVENT_SIZE ld bc, BG_EVENT_SIZE
call CopyBytes call CopyBytes
scf scf
@ -1836,7 +1836,7 @@ CheckCurrentMapCoordEvents::
ret ret
.CoordEventCheck: .CoordEventCheck:
; Checks to see if you are standing on a coord event. If yes, copies the event to wEngineBuffer1 and sets carry. ; Checks to see if you are standing on a coord event. If yes, copies the event to wCurCoordEvent and sets carry.
ld hl, wCurMapCoordEventsPointer ld hl, wCurMapCoordEventsPointer
ld a, [hli] ld a, [hli]
ld h, [hl] ld h, [hl]
@ -1885,7 +1885,7 @@ CheckCurrentMapCoordEvents::
.copy_coord_event .copy_coord_event
pop hl pop hl
ld de, wCurCoordEventSceneID ld de, wCurCoordEvent
ld bc, COORD_EVENT_SIZE ld bc, COORD_EVENT_SIZE
call CopyBytes call CopyBytes
scf scf

View File

@ -95,31 +95,31 @@ _CheckTrainerBattle::
pop af pop af
ldh [hLastTalked], a ldh [hLastTalked], a
ld a, b ld a, b
ld [wEngineBuffer2], a ld [wSeenTrainerDistance], a
ld a, c ld a, c
ld [wEngineBuffer3], a ld [wSeenTrainerDirection], a
jr LoadTrainer_continue jr LoadTrainer_continue
TalkToTrainer:: TalkToTrainer::
ld a, 1 ld a, 1
ld [wEngineBuffer2], a ld [wSeenTrainerDistance], a
ld a, -1 ld a, -1
ld [wEngineBuffer3], a ld [wSeenTrainerDirection], a
LoadTrainer_continue:: LoadTrainer_continue::
call GetMapScriptsBank call GetMapScriptsBank
ld [wEngineBuffer1], a ld [wSeenTrainerBank], a
ldh a, [hLastTalked] ldh a, [hLastTalked]
call GetMapObject call GetMapObject
ld hl, MAPOBJECT_SCRIPT_POINTER ld hl, MAPOBJECT_SCRIPT_POINTER
add hl, bc add hl, bc
ld a, [wEngineBuffer1] ld a, [wSeenTrainerBank]
call GetFarHalfword call GetFarHalfword
ld de, wTempTrainer ld de, wTempTrainer
ld bc, wTempTrainerEnd - wTempTrainer ld bc, wTempTrainerEnd - wTempTrainer
ld a, [wEngineBuffer1] ld a, [wSeenTrainerBank]
call FarCopyBytes call FarCopyBytes
xor a xor a
ld [wRunningTrainerBattleScript], a ld [wRunningTrainerBattleScript], a
@ -136,7 +136,7 @@ FacingPlayerDistance_bc::
FacingPlayerDistance:: FacingPlayerDistance::
; Return carry if the sprite at bc is facing the player, ; Return carry if the sprite at bc is facing the player,
; and its distance in d. ; its distance in d, and its direction in e.
ld hl, OBJECT_NEXT_MAP_X ; x ld hl, OBJECT_NEXT_MAP_X ; x
add hl, bc add hl, bc

View File

@ -692,10 +692,10 @@ Function171ccd:
ld de, wBGPals1 ld de, wBGPals1
ld bc, 8 palettes ld bc, 8 palettes
call CopyBytes call CopyBytes
ld hl, wEngineBuffer5 ld hl, wOBPals1 palette 0 color 1
ld a, $ff ld a, LOW(PALRGB_WHITE)
ld [hli], a ld [hli], a
ld a, $7f ld a, HIGH(PALRGB_WHITE)
ld [hl], a ld [hl], a
call SetPalettes call SetPalettes
pop af pop af

143
wram.asm
View File

@ -755,7 +755,6 @@ wc668:: ds 32
wc688:: ds 2 wc688:: ds 2
wc68a:: ds 4 wc68a:: ds 4
ds 66 ds 66
ENDU ; c6d0 ENDU ; c6d0
; This union spans 280 bytes from c6d0 to c7e8. ; This union spans 280 bytes from c6d0 to c7e8.
@ -1765,55 +1764,10 @@ wd036:: ds 2
ds 6 ds 6
UNION ; d03e UNION ; d03e
; engine buffers
wEngineBuffer1:: db
wEngineBuffer2:: db
wEngineBuffer3:: db
wEngineBuffer4:: db
wEngineBuffer5:: db
NEXTU ; d03e
; menu items list
wMenuItemsList:: ds 16
wMenuItemsListEnd::
NEXTU ; d03e
; fruit tree data
wCurFruitTree:: db
wCurFruit:: db
NEXTU ; d03e
; elevator data
wElevatorPointerBank:: db
wElevatorPointer:: dw
wElevatorOriginFloor:: db
NEXTU ; d03e
; coord event data
wCurCoordEventSceneID:: db
wCurCoordEventMapY:: db
wCurCoordEventMapX:: db
ds 1
wCurCoordEventScriptAddr:: dw
NEXTU ; d03e
; BG event data
wCurBGEventYCoord:: db
wCurBGEventXCoord:: db
wCurBGEventType:: db
wCurBGEventScriptAddr:: dw
NEXTU ; d03e
; mart data
ds 1
wMartPointerBank:: db
wMartPointer:: dw
ds 1
wBargainShopFlags:: db
NEXTU ; d03e
; trainer data ; trainer data
ds 3 wSeenTrainerBank:: db
wSeenTrainerDistance:: db
wSeenTrainerDirection:: db
wTempTrainer:: wTempTrainer::
wTempTrainerEventFlag:: dw wTempTrainerEventFlag:: dw
wTempTrainerClass:: db wTempTrainerClass:: db
@ -1825,12 +1779,70 @@ wScriptAfterPointer:: dw
wRunningTrainerBattleScript:: db wRunningTrainerBattleScript:: db
wTempTrainerEnd:: wTempTrainerEnd::
NEXTU ; d03e
; menu items list
wMenuItemsList:: ds 16
wMenuItemsListEnd::
NEXTU ; d03e
; fruit tree data
wCurFruitTree:: db
wCurFruit:: db
NEXTU ; d03e
; item ball data
wItemBallData::
wItemBallItemID:: db
wItemBallQuantity:: db
wItemBallDataEnd::
NEXTU ; d03e
; hidden item data
wHiddenItemData::
wHiddenItemEvent:: dw
wHiddenItemID:: db
wHiddenItemDataEnd::
NEXTU ; d03e
; elevator data
wElevatorData::
wElevatorPointerBank:: db
wElevatorPointer:: dw
wElevatorOriginFloor:: db
wElevatorDataEnd::
NEXTU ; d03e
; coord event data
wCurCoordEvent::
wCurCoordEventSceneID:: db
wCurCoordEventMapY:: db
wCurCoordEventMapX:: db
ds 1
wCurCoordEventScriptAddr:: dw
NEXTU ; d03e
; BG event data
wCurBGEvent::
wCurBGEventYCoord:: db
wCurBGEventXCoord:: db
wCurBGEventType:: db
wCurBGEventScriptAddr:: dw
NEXTU ; d03e
; mart data
wMartType:: db
wMartPointerBank:: db
wMartPointer:: dw
wMartJumptableIndex:: db
wBargainShopFlags:: db
NEXTU ; d03e NEXTU ; d03e
; player movement data ; player movement data
wCurInput:: db wCurInput::
wd03f:: db wFacingTileID:: db
wd040:: db wWalkingIntoNPC:: db
wd041:: db wWalkingIntoLand:: db
wWalkingIntoEdgeWarp:: db
wMovementAnimation:: db wMovementAnimation:: db
wWalkingDirection:: db wWalkingDirection:: db
wFacingDirection:: db wFacingDirection:: db
@ -1846,17 +1858,32 @@ NEXTU ; d03e
wJumpStdScriptBuffer:: ds 3 wJumpStdScriptBuffer:: ds 3
NEXTU ; d03e NEXTU ; d03e
; phone script pointer ; phone script data
ds 10 wCheckedTime:: db
wPhoneScriptPointer:: dw wPhoneListIndex:: db
wNumAvailableCallers:: db
wAvailableCallers:: ds CONTACT_LIST_SIZE
NEXTU ; d03e
; phone caller contact
ds 1
wCallerContact:: ds PHONE_CONTACT_SIZE
NEXTU ; d03e NEXTU ; d03e
; backup menu data ; backup menu data
ds 7 ds 7
wMenuCursorBufferBackup:: db wMenuCursorBufferBackup:: db
wMenuScrollPositionBackup:: db wMenuScrollPositionBackup:: db
ds 31
ENDU ; d066 NEXTU ; d03e
; poison step data
wPoisonStepData::
wPoisonStepFlagSum:: db
wPoisonStepPartyFlags:: ds PARTY_LENGTH
wPoisonStepDataEnd::
ENDU ; d04f
ds 23
ENDU ; d066 ENDU ; d066
wTMHMMoveNameBackup:: ds MOVE_NAME_LENGTH ; d066 wTMHMMoveNameBackup:: ds MOVE_NAME_LENGTH ; d066