Rename wVramState to wStateFlags and use flag constants (#1078)

This commit is contained in:
xCrystal 2024-01-07 14:27:22 +01:00
parent 5be9856f3a
commit f72f078c0e
31 changed files with 125 additions and 120 deletions

View File

@ -91,6 +91,12 @@ DEF RIGHT_MASK EQU 1 << RIGHT
shift_const FACE_RIGHT ; 1
DEF FACE_CURRENT EQU 0
; wStateFlags
DEF SPRITE_UPDATES_DISABLED_F EQU 0
DEF LAST_12_SPRITE_OAM_STRUCTS_RESERVED_F EQU 1
DEF TEXT_STATE_F EQU 6
DEF SCRIPTED_MOVEMENT_STATE_F EQU 7
; wPokemonWithdrawDepositParameter::
DEF PC_WITHDRAW EQU 0
DEF PC_DEPOSIT EQU 1

View File

@ -8,10 +8,10 @@ INCBIN "gfx/tilesets/forest-tree/4.2bpp"
CelebiShrineEvent:
call DelayFrame
ld a, [wVramState]
ld a, [wStateFlags]
push af
xor a
ld [wVramState], a
ld [wStateFlags], a
call LoadCelebiGFX
depixel 0, 10, 7, 0
ld a, SPRITE_ANIM_OBJ_CELEBI
@ -49,7 +49,7 @@ CelebiShrineEvent:
.done
pop af
ld [wVramState], a
ld [wStateFlags], a
call .RestorePlayerSprite_DespawnLeaves
call CelebiEvent_SetBattleType
ret

View File

@ -298,10 +298,10 @@ Cut_Headbutt_GetPixelFacing:
FlyFromAnim:
call DelayFrame
ld a, [wVramState]
ld a, [wStateFlags]
push af
xor a
ld [wVramState], a
ld [wStateFlags], a
call FlyFunction_InitGFX
depixel 10, 10, 4, 0
ld a, SPRITE_ANIM_OBJ_RED_WALK
@ -327,15 +327,15 @@ FlyFromAnim:
.exit
pop af
ld [wVramState], a
ld [wStateFlags], a
ret
FlyToAnim:
call DelayFrame
ld a, [wVramState]
ld a, [wStateFlags]
push af
xor a
ld [wVramState], a
ld [wStateFlags], a
call FlyFunction_InitGFX
depixel 31, 10, 4, 0
ld a, SPRITE_ANIM_OBJ_RED_WALK
@ -364,7 +364,7 @@ FlyToAnim:
.exit
pop af
ld [wVramState], a
ld [wStateFlags], a
call .RestorePlayerSprite_DespawnLeaves
ret

View File

@ -43,7 +43,7 @@ RedCredits::
ld [wMusicFade], a
farcall FadeOutToWhite
xor a
ld [wVramState], a
ld [wStateFlags], a
ldh [hMapAnims], a
farcall InitDisplayForRedCredits
ld c, 8
@ -65,7 +65,7 @@ HallOfFame_FadeOutMusic:
ld [wMusicFade], a
farcall FadeOutToWhite
xor a
ld [wVramState], a
ld [wStateFlags], a
ldh [hMapAnims], a
farcall InitDisplayForHallOfFame
ld c, 100

View File

@ -693,8 +693,8 @@ _ExitMenu::
ret
RestoreOverworldMapTiles: ; unreferenced
ld a, [wVramState]
bit 0, a
ld a, [wStateFlags]
bit SPRITE_UPDATES_DISABLED_F, a
ret z
xor a ; sScratch
call OpenSRAM

View File

@ -9,10 +9,10 @@
const TRAINERCARDSTATE_QUIT ; 6
TrainerCard:
ld a, [wVramState]
ld a, [wStateFlags]
push af
xor a
ld [wVramState], a
ld [wStateFlags], a
ld hl, wOptions
ld a, [hl]
push af
@ -35,7 +35,7 @@ TrainerCard:
pop af
ld [wOptions], a
pop af
ld [wVramState], a
ld [wStateFlags], a
ret
.InitRAM:

View File

@ -128,10 +128,10 @@ RunTradeAnimScript:
push af
xor a
ldh [hMapAnims], a
ld hl, wVramState
ld hl, wStateFlags
ld a, [hl]
push af
res 0, [hl]
res SPRITE_UPDATES_DISABLED_F, [hl]
ld hl, wOptions
ld a, [hl]
push af
@ -148,7 +148,7 @@ RunTradeAnimScript:
pop af
ld [wOptions], a
pop af
ld [wVramState], a
ld [wStateFlags], a
pop af
ldh [hMapAnims], a
ret

View File

@ -17,8 +17,8 @@ ReanchorBGMap_NoOAMUpdate::
pop af
ldh [hOAMUpdate], a
ld hl, wVramState
set 6, [hl]
ld hl, wStateFlags
set TEXT_STATE_F, [hl]
ret
.ReanchorBGMap:

View File

@ -2167,8 +2167,8 @@ CopyTempObjectData:
ret
UpdateAllObjectsFrozen::
ld a, [wVramState]
bit 0, a
ld a, [wStateFlags]
bit SPRITE_UPDATES_DISABLED_F, a
ret z
ld bc, wObjectStructs
xor a
@ -2728,8 +2728,8 @@ ResetObject:
db SPRITEMOVEDATA_STANDING_RIGHT
_UpdateSprites::
ld a, [wVramState]
bit 0, a
ld a, [wStateFlags]
bit SPRITE_UPDATES_DISABLED_F, a
ret z
xor a
ldh [hUsedSpriteIndex], a
@ -2744,8 +2744,8 @@ _UpdateSprites::
ret
.fill
ld a, [wVramState]
bit 1, a
ld a, [wStateFlags]
bit LAST_12_SPRITE_OAM_STRUCTS_RESERVED_F, a
ld b, NUM_SPRITE_OAM_STRUCTS * SPRITEOAMSTRUCT_LENGTH
jr z, .ok
ld b, (NUM_SPRITE_OAM_STRUCTS - 12) * SPRITEOAMSTRUCT_LENGTH

View File

@ -205,8 +205,8 @@ Movement_step_end:
add hl, bc
ld [hl], $0
ld hl, wVramState
res 7, [hl]
ld hl, wStateFlags
res SCRIPTED_MOVEMENT_STATE_F, [hl]
ld hl, OBJECT_STEP_TYPE
add hl, bc
@ -232,8 +232,8 @@ Movement_48:
add hl, bc
ld [hl], STEP_TYPE_SLEEP
ld hl, wVramState
res 7, [hl]
ld hl, wStateFlags
res SCRIPTED_MOVEMENT_STATE_F, [hl]
ret
Movement_remove_object:
@ -245,8 +245,8 @@ Movement_remove_object:
ld [hl], -1
.not_leading
ld hl, wVramState
res 7, [hl]
ld hl, wStateFlags
res SCRIPTED_MOVEMENT_STATE_F, [hl]
ret
Movement_4b:
@ -258,8 +258,8 @@ Movement_4b:
add hl, bc
ld [hl], STEP_TYPE_STANDING
ld hl, wVramState
res 7, [hl]
ld hl, wStateFlags
res SCRIPTED_MOVEMENT_STATE_F, [hl]
ret
Movement_step_sleep_1:

View File

@ -153,8 +153,8 @@ CopyObjectStruct::
ld d, h
ld e, l
call CopyMapObjectToObjectStruct
ld hl, wVramState
bit 7, [hl]
ld hl, wStateFlags
bit SCRIPTED_MOVEMENT_STATE_F, [hl]
ret z
ld hl, OBJECT_FLAGS2

View File

@ -44,8 +44,8 @@ WaitScript:
WaitScriptMovement:
call StopScript
ld hl, wVramState
bit 7, [hl]
ld hl, wStateFlags
bit SCRIPTED_MOVEMENT_STATE_F, [hl]
ret nz
farcall UnfreezeAllObjects
@ -925,8 +925,8 @@ ApplyObjectFacing:
pop de
ld a, e
call SetSpriteDirection
ld hl, wVramState
bit 6, [hl]
ld hl, wStateFlags
bit TEXT_STATE_F, [hl]
jr nz, .text_state
call .DisableTextTiles
.text_state

View File

@ -226,9 +226,9 @@ EnterMapWarp:
ret
LoadMapTimeOfDay:
ld hl, wVramState
res 6, [hl]
ld a, $1
ld hl, wStateFlags
res TEXT_STATE_F, [hl]
ld a, TRUE
ld [wSpriteUpdatesEnabled], a
farcall ReplaceTimeOfDayPals
farcall UpdateTimeOfDayPal
@ -321,8 +321,8 @@ RefreshMapSprites:
ld hl, wPlayerSpriteSetupFlags
bit PLAYERSPRITESETUP_SKIP_RELOAD_GFX_F, [hl]
jr nz, .skip
ld hl, wVramState
set 0, [hl]
ld hl, wStateFlags
set SPRITE_UPDATES_DISABLED_F, [hl]
call SafeUpdateSprites
.skip
ld a, [wPlayerSpriteSetupFlags]

View File

@ -3,7 +3,7 @@ PhoneRing_CopyTilemapAtOnce:
and a
jp z, WaitBGMap
ld a, [wSpriteUpdatesEnabled]
cp $0
cp FALSE
jp z, WaitBGMap
; The following is a modified version of _CopyTilemapAtOnce

View File

@ -30,10 +30,10 @@ Pokedex:
ld a, [hl]
push af
set NO_TEXT_SCROLL, [hl]
ld a, [wVramState]
ld a, [wStateFlags]
push af
xor a
ld [wVramState], a
ld [wStateFlags], a
ldh a, [hInMenu]
push af
ld a, $1
@ -64,7 +64,7 @@ Pokedex:
pop af
ldh [hInMenu], a
pop af
ld [wVramState], a
ld [wStateFlags], a
pop af
ld [wOptions], a
pop af

View File

@ -33,10 +33,10 @@ PokeGear:
push af
ld a, $1
ldh [hInMenu], a
ld a, [wVramState]
ld a, [wStateFlags]
push af
xor a
ld [wVramState], a
ld [wStateFlags], a
call .InitTilemap
call DelayFrame
.loop
@ -55,7 +55,7 @@ PokeGear:
call PlaySFX
call WaitSFX
pop af
ld [wVramState], a
ld [wStateFlags], a
pop af
ldh [hInMenu], a
pop af
@ -1764,10 +1764,10 @@ _TownMap:
ld a, $1
ldh [hInMenu], a
ld a, [wVramState]
ld a, [wStateFlags]
push af
xor a
ld [wVramState], a
ld [wStateFlags], a
call ClearBGPalettes
call ClearTilemap
@ -1819,7 +1819,7 @@ _TownMap:
.resume
pop af
ld [wVramState], a
ld [wStateFlags], a
pop af
ldh [hInMenu], a
pop af

View File

@ -3,10 +3,10 @@ _DepositPKMN:
ld a, [hl]
push af
set NO_TEXT_SCROLL, [hl]
ld a, [wVramState]
ld a, [wStateFlags]
push af
xor a
ld [wVramState], a
ld [wStateFlags], a
ldh a, [hInMenu]
push af
ld a, $1
@ -30,7 +30,7 @@ _DepositPKMN:
pop af
ldh [hInMenu], a
pop af
ld [wVramState], a
ld [wStateFlags], a
pop af
ld [wOptions], a
ret
@ -259,10 +259,10 @@ _WithdrawPKMN:
ld a, [hl]
push af
set NO_TEXT_SCROLL, [hl]
ld a, [wVramState]
ld a, [wStateFlags]
push af
xor a
ld [wVramState], a
ld [wStateFlags], a
ldh a, [hInMenu]
push af
ld a, $1
@ -286,7 +286,7 @@ _WithdrawPKMN:
pop af
ldh [hInMenu], a
pop af
ld [wVramState], a
ld [wStateFlags], a
pop af
ld [wOptions], a
ret
@ -497,10 +497,10 @@ _MovePKMNWithoutMail:
ld a, [hl]
push af
set NO_TEXT_SCROLL, [hl]
ld a, [wVramState]
ld a, [wStateFlags]
push af
xor a
ld [wVramState], a
ld [wStateFlags], a
ldh a, [hInMenu]
push af
ld a, $1
@ -527,7 +527,7 @@ _MovePKMNWithoutMail:
pop af
ldh [hInMenu], a
pop af
ld [wVramState], a
ld [wStateFlags], a
pop af
ld [wOptions], a
ret

View File

@ -358,8 +358,8 @@ HatchEggs:
; Huh? @ @
text_far Text_BreedHuh
text_asm
ld hl, wVramState
res 0, [hl]
ld hl, wStateFlags
res SPRITE_UPDATES_DISABLED_F, [hl]
push hl
push de
push bc

View File

@ -8,7 +8,7 @@ InitClock:
ld a, $1
ldh [hInMenu], a
ld a, $0
ld a, FALSE
ld [wSpriteUpdatesEnabled], a
ld a, $10
ld [wMusicFade], a

View File

@ -1941,7 +1941,7 @@ FinishExitMenu::
ReturnToMapWithSpeechTextbox::
push af
ld a, $1
ld a, TRUE
ld [wSpriteUpdatesEnabled], a
call ClearBGPalettes
call ClearSprites
@ -1949,8 +1949,8 @@ ReturnToMapWithSpeechTextbox::
hlcoord 0, 12
lb bc, 4, 18
call Textbox
ld hl, wVramState
set 0, [hl]
ld hl, wStateFlags
set SPRITE_UPDATES_DISABLED_F, [hl]
call UpdateSprites
call WaitBGMap2
ld b, SCGB_MAPPALS

View File

@ -412,8 +412,8 @@ LoadMovementDataPointer::
add hl, bc
ld [hl], STEP_TYPE_RESET
ld hl, wVramState
set 7, [hl]
ld hl, wStateFlags
set SCRIPTED_MOVEMENT_STATE_F, [hl]
and a
ret
@ -574,19 +574,19 @@ _GetMovementIndex::
ld a, h
ret
SetVramState_Bit0:: ; unreferenced
ld hl, wVramState
set 0, [hl]
SetVramState_SpriteUpdatesDisabled:: ; unreferenced
ld hl, wStateFlags
set SPRITE_UPDATES_DISABLED_F, [hl]
ret
ResetVramState_Bit0:: ; unreferenced
ld hl, wVramState
res 0, [hl]
ResetVramState_SpriteUpdatesDisabled:: ; unreferenced
ld hl, wStateFlags
res SPRITE_UPDATES_DISABLED_F, [hl]
ret
UpdateSprites::
ld a, [wVramState]
bit 0, a
ld a, [wStateFlags]
bit SPRITE_UPDATES_DISABLED_F, a
ret z
farcall UpdateAllObjectsFrozen

View File

@ -17,8 +17,8 @@ ScrollingMenu::
ret
.UpdatePalettes:
ld hl, wVramState
bit 0, [hl]
ld hl, wStateFlags
bit SPRITE_UPDATES_DISABLED_F, [hl]
jp nz, UpdateTimePals
jp SetDefaultBGPAndOBP

View File

@ -1,19 +1,19 @@
DisableSpriteUpdates::
xor a
ldh [hMapAnims], a
ld a, [wVramState]
res 0, a
ld [wVramState], a
ld a, $0
ld a, [wStateFlags]
res SPRITE_UPDATES_DISABLED_F, a
ld [wStateFlags], a
ld a, FALSE
ld [wSpriteUpdatesEnabled], a
ret
EnableSpriteUpdates::
ld a, $1
ld a, TRUE
ld [wSpriteUpdatesEnabled], a
ld a, [wVramState]
set 0, a
ld [wVramState], a
ld a, $1
ld a, [wStateFlags]
set SPRITE_UPDATES_DISABLED_F, a
ld [wStateFlags], a
ld a, TRUE
ldh [hMapAnims], a
ret

View File

@ -37,7 +37,7 @@ ApplyTilemap::
jr z, .dmg
ld a, [wSpriteUpdatesEnabled]
cp 0
cp FALSE
jr z, .dmg
ld a, 1

View File

@ -3,14 +3,14 @@ UpdateTimeAndPals::
; rtc enabled?
ld a, [wSpriteUpdatesEnabled]
cp 0
cp FALSE
ret z
call UpdateTime
; obj update on?
ld a, [wVramState]
bit 0, a ; obj update
ld a, [wStateFlags]
bit SPRITE_UPDATES_DISABLED_F, a ; obj update
ret z
TimeOfDayPals::

View File

@ -23,8 +23,8 @@ CloseText::
pop af
ldh [hOAMUpdate], a
ld hl, wVramState
res 6, [hl]
ld hl, wStateFlags
res TEXT_STATE_F, [hl]
ret
.CloseText:

View File

@ -143,12 +143,12 @@ Function891fe:
ret
Mobile_EnableSpriteUpdates:
ld a, 1
ld a, TRUE
ld [wSpriteUpdatesEnabled], a
ret
Mobile_DisableSpriteUpdates:
ld a, 0
ld a, FALSE
ld [wSpriteUpdatesEnabled], a
ret

View File

@ -40,15 +40,15 @@ Function100022:
farcall Stubbed_Function106462
farcall Function106464 ; load broken gfx
farcall Function11615a ; init RAM
ld hl, wVramState
set 1, [hl]
ld hl, wStateFlags
set LAST_12_SPRITE_OAM_STRUCTS_RESERVED_F, [hl]
ret
Function100057:
call DisableMobile
call ReturnToMapFromSubmenu
ld hl, wVramState
res 1, [hl]
ld hl, wStateFlags
res LAST_12_SPRITE_OAM_STRUCTS_RESERVED_F, [hl]
ret
SetRAMStateForMobile:

View File

@ -95,10 +95,10 @@ RunMobileTradeAnim_Frontpics:
push af
xor a
ldh [hMapAnims], a
ld hl, wVramState
ld hl, wStateFlags
ld a, [hl]
push af
res 0, [hl]
res SPRITE_UPDATES_DISABLED_F, [hl]
ld hl, wOptions
ld a, [hl]
push af
@ -110,7 +110,7 @@ RunMobileTradeAnim_Frontpics:
pop af
ld [wOptions], a
pop af
ld [wVramState], a
ld [wStateFlags], a
pop af
ldh [hMapAnims], a
ret
@ -124,7 +124,7 @@ RunMobileTradeAnim_NoFrontpics:
push af
xor a
ldh [hMapAnims], a
ld hl, wVramState
ld hl, wStateFlags
ld a, [hl]
push af
res 0, [hl]
@ -139,7 +139,7 @@ RunMobileTradeAnim_NoFrontpics:
pop af
ld [wOptions], a
pop af
ld [wVramState], a
ld [wStateFlags], a
pop af
ldh [hMapAnims], a
ret

View File

@ -463,10 +463,10 @@ BattleTowerRoomMenu_InitRAM:
ld [wc3ed], a
ld [wc3ee], a
ld [wc3ef], a
ld hl, wVramState
ld hl, wStateFlags
ld a, [hl]
ld [wcd7f], a
set 1, [hl]
set LAST_12_SPRITE_OAM_STRUCTS_RESERVED_F, [hl]
ld a, (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK)
ldh [rIE], a
ld a, $1
@ -508,7 +508,7 @@ BattleTowerRoomMenu_Cleanup:
ldh [rIE], a
ei
ld a, [wcd7f]
ld [wVramState], a
ld [wStateFlags], a
ld a, [wMobileErrorCodeBuffer]
ld [wScriptVar], a
ret
@ -5535,10 +5535,10 @@ Function11ac51:
ld a, [hl]
push af
set 4, [hl]
ld a, [wVramState]
ld a, [wStateFlags]
push af
xor a
ld [wVramState], a
ld [wStateFlags], a
ldh a, [hInMenu]
push af
ld a, $1
@ -5571,7 +5571,7 @@ Function11ac51:
pop af
ldh [hInMenu], a
pop af
ld [wVramState], a
ld [wStateFlags], a
pop af
ld [wOptions], a
ret

View File

@ -2304,12 +2304,11 @@ wBattlePlayerAction::
wSolvedUnownPuzzle::
db
wVramState::
wStateFlags::
; bit 0: overworld sprite updating on/off
; bit 1: something to do with sprite updates
; bit 6: something to do with text
; bit 7: on when surf initiates
; flickers when climbing waterfall
; bit 1: last 12 sprite OAM structs reserved
; bit 6: in text state
; bit 7: in scripted movement
db
wBattleResult::