wVramState -> wStateFlags and define flag constants (from pokecrystal f72f078c0e68736adf81f6c45c84f0c1e127a231)

This commit is contained in:
xCrystal 2024-02-11 00:34:46 +01:00
parent b1fd8f941a
commit e44744c587
27 changed files with 88 additions and 82 deletions

View File

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

View File

@ -104,8 +104,8 @@ BoardMenuScript::
.EnterViewMapMode: .EnterViewMapMode:
call BackupMapObjectsOnEnterViewMapMode call BackupMapObjectsOnEnterViewMapMode
ld hl, wVramState ld hl, wStateFlags
res 2, [hl] res DONT_CLEAR_SHADOW_OAM_IN_SPRITE_ANIMS_F, [hl]
ld a, BOARDEVENT_VIEW_MAP_MODE ld a, BOARDEVENT_VIEW_MAP_MODE
ldh [hCurBoardEvent], a ldh [hCurBoardEvent], a
ld a, 100 ld a, 100
@ -347,8 +347,8 @@ BoardMenu_BreakDieAnimation:
ld hl, wDisplaySecondarySprites ld hl, wDisplaySecondarySprites
res SECONDARYSPRITES_DIE_ROLL_F, [hl] res SECONDARYSPRITES_DIE_ROLL_F, [hl]
ld hl, wVramState ld hl, wStateFlags
set 2, [hl] ; do not clear wShadowOAM during DoNextFrameForAllSprites set DONT_CLEAR_SHADOW_OAM_IN_SPRITE_ANIMS_F, [hl]
; animation plays above NPCs so draw the graphics at the beginning of OAM. ; animation plays above NPCs so draw the graphics at the beginning of OAM.
; begin placing NPC sprites in OAM after all objects allocated to animations. ; begin placing NPC sprites in OAM after all objects allocated to animations.
ld a, [wSpriteAnim2Index] ld a, [wSpriteAnim2Index]
@ -400,8 +400,8 @@ BoardMenu_BreakDieAnimation:
jr .loop2 jr .loop2
.done .done
ld hl, wVramState ld hl, wStateFlags
res 2, [hl] res DONT_CLEAR_SHADOW_OAM_IN_SPRITE_ANIMS_F, [hl]
farcall ClearSpriteAnims farcall ClearSpriteAnims
ld hl, wDisplaySecondarySprites ld hl, wDisplaySecondarySprites
set SECONDARYSPRITES_SPACES_LEFT_F, [hl] set SECONDARYSPRITES_SPACES_LEFT_F, [hl]

View File

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

View File

@ -149,11 +149,11 @@ OWCutAnimation_WithCutTreeAsObject:
.got_oam_addr .got_oam_addr
ld [wCurSpriteOAMAddr], a ld [wCurSpriteOAMAddr], a
ld [wCutTreeOAMAddr], a ld [wCutTreeOAMAddr], a
ld hl, wVramState ld hl, wStateFlags
set 2, [hl] ; do not clear wShadowOAM during DoNextFrameForAllSprites set DONT_CLEAR_SHADOW_OAM_IN_SPRITE_ANIMS_F, [hl]
callfar DoNextFrameForAllSprites callfar DoNextFrameForAllSprites
ld hl, wVramState ld hl, wStateFlags
res 2, [hl] res DONT_CLEAR_SHADOW_OAM_IN_SPRITE_ANIMS_F, [hl]
call .OWCutJumptable call .OWCutJumptable
call DelayFrame call DelayFrame
jr .loop jr .loop
@ -448,10 +448,10 @@ Cut_Headbutt_GetPixelFacing:
FlyFromAnim: FlyFromAnim:
call DelayFrame call DelayFrame
ld a, [wVramState] ld a, [wStateFlags]
push af push af
xor a xor a
ld [wVramState], a ld [wStateFlags], a
call FlyFunction_InitGFX call FlyFunction_InitGFX
depixel 10, 10, 4, 0 depixel 10, 10, 4, 0
ld a, SPRITE_ANIM_OBJ_RED_WALK ld a, SPRITE_ANIM_OBJ_RED_WALK
@ -477,15 +477,15 @@ FlyFromAnim:
.exit .exit
pop af pop af
ld [wVramState], a ld [wStateFlags], a
ret ret
FlyToAnim: FlyToAnim:
call DelayFrame call DelayFrame
ld a, [wVramState] ld a, [wStateFlags]
push af push af
xor a xor a
ld [wVramState], a ld [wStateFlags], a
call FlyFunction_InitGFX call FlyFunction_InitGFX
depixel 31, 10, 4, 0 depixel 31, 10, 4, 0
ld a, SPRITE_ANIM_OBJ_RED_WALK ld a, SPRITE_ANIM_OBJ_RED_WALK
@ -514,7 +514,7 @@ FlyToAnim:
.exit .exit
pop af pop af
ld [wVramState], a ld [wStateFlags], a
call .RestorePlayerSprite_DespawnLeaves call .RestorePlayerSprite_DespawnLeaves
ret ret

View File

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

View File

@ -4,8 +4,8 @@ LevelSelectionMenu::
ldh [hMapAnims], a ldh [hMapAnims], a
ldh [hSCY], a ldh [hSCY], a
ldh [hSCX], a ldh [hSCX], a
ld a, 1 << 2 ; do not clear wShadowOAM during DoNextFrameForAllSprites ld a, 1 << DONT_CLEAR_SHADOW_OAM_IN_SPRITE_ANIMS_F
ld [wVramState], a ld [wStateFlags], a
call ClearBGPalettes call ClearBGPalettes
call ClearTilemap call ClearTilemap
@ -306,7 +306,7 @@ LevelSelectionMenu::
farcall ClearSpriteAnims farcall ClearSpriteAnims
call ClearSprites call ClearSprites
xor a xor a
ld [wVramState], a ld [wStateFlags], a
ret ; nc ret ; nc
LevelSelectionMenu_LoadGFX: LevelSelectionMenu_LoadGFX:

View File

@ -614,7 +614,7 @@ _ExitMenu::
ret ret
RestoreOverworldMapTiles: ; unreferenced RestoreOverworldMapTiles: ; unreferenced
ld a, [wVramState] ld a, [wStateFlags]
bit 0, a bit 0, a
ret z ret z
xor a ; sScratch xor a ; sScratch

View File

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

View File

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

View File

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

View File

@ -2167,7 +2167,7 @@ CopyTempObjectData:
ret ret
UpdateAllObjectsFrozen:: UpdateAllObjectsFrozen::
ld a, [wVramState] ld a, [wStateFlags]
bit 0, a bit 0, a
ret z ret z
ld bc, wObjectStructs ld bc, wObjectStructs
@ -2766,13 +2766,13 @@ SetObjectToRemainHidden:
ret ret
_UpdateActiveSpritesAfterOffset:: _UpdateActiveSpritesAfterOffset::
ld a, [wVramState] ld a, [wStateFlags]
bit 0, a bit 0, a
ret z ret z
jr _UpdateActiveSprites.go jr _UpdateActiveSprites.go
_UpdateActiveSprites:: _UpdateActiveSprites::
ld a, [wVramState] ld a, [wStateFlags]
bit 0, a bit 0, a
ret z ret z
xor a xor a
@ -2789,7 +2789,7 @@ _UpdateActiveSprites::
ret ret
.fill .fill
ld a, [wVramState] ld a, [wStateFlags]
bit 1, a bit 1, a
ld b, NUM_SPRITE_OAM_STRUCTS * SPRITEOAMSTRUCT_LENGTH ld b, NUM_SPRITE_OAM_STRUCTS * SPRITEOAMSTRUCT_LENGTH
jr z, .ok jr z, .ok
@ -3095,7 +3095,7 @@ _UpdateSecondarySprites::
; which would require to displace primary (NPC) sprites in OAM. ; which would require to displace primary (NPC) sprites in OAM.
; if it is detected that the size of secondary sprites has increased in the end, ; if it is detected that the size of secondary sprites has increased in the end,
; fall back to calling _UpdateActiveSprites to avoid corruption. ; fall back to calling _UpdateActiveSprites to avoid corruption.
ld a, [wVramState] ld a, [wStateFlags]
bit 0, a bit 0, a
ret z ret z
ld a, [hUsedSpriteIndex] ld a, [hUsedSpriteIndex]

View File

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

View File

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

View File

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

View File

@ -213,7 +213,7 @@ EnterMapWarp:
ret ret
LoadMapTimeOfDay: LoadMapTimeOfDay:
ld hl, wVramState ld hl, wStateFlags
res 6, [hl] res 6, [hl]
ld a, $1 ld a, $1
ld [wSpriteUpdatesEnabled], a ld [wSpriteUpdatesEnabled], a
@ -300,7 +300,7 @@ RefreshMapSprites:
ld hl, wPlayerSpriteSetupFlags ld hl, wPlayerSpriteSetupFlags
bit PLAYERSPRITESETUP_SKIP_RELOAD_GFX_F, [hl] bit PLAYERSPRITESETUP_SKIP_RELOAD_GFX_F, [hl]
jr nz, .skip jr nz, .skip
ld hl, wVramState ld hl, wStateFlags
set 0, [hl] set 0, [hl]
call SafeUpdateSprites call SafeUpdateSprites
.skip .skip

View File

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

View File

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

View File

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

View File

@ -348,7 +348,7 @@ HatchEggs:
; Huh? @ @ ; Huh? @ @
text_far Text_BreedHuh text_far Text_BreedHuh
text_asm text_asm
ld hl, wVramState ld hl, wStateFlags
res 0, [hl] res 0, [hl]
push hl push hl
push de push de

View File

@ -55,7 +55,7 @@ DoNextFrameForAllSprites:
dec e dec e
jr nz, .loop jr nz, .loop
ld a, [wVramState] ld a, [wStateFlags]
bit 2, a bit 2, a
ret nz ret nz

View File

@ -2203,7 +2203,7 @@ ReturnToMapWithSpeechTextbox::
call ClearSprites call ClearSprites
call ReloadTilesetAndPalettes call ReloadTilesetAndPalettes
call SpeechTextbox ; 1bpp or 2bpp according to wTextboxFlags[TEXT_2BPP_F] call SpeechTextbox ; 1bpp or 2bpp according to wTextboxFlags[TEXT_2BPP_F]
ld hl, wVramState ld hl, wStateFlags
set 0, [hl] set 0, [hl]
call UpdateSprites call UpdateSprites
call WaitBGMap2 call WaitBGMap2

View File

@ -390,7 +390,7 @@ LoadMovementDataPointer::
add hl, bc add hl, bc
ld [hl], STEP_TYPE_RESET ld [hl], STEP_TYPE_RESET
ld hl, wVramState ld hl, wStateFlags
set 7, [hl] set 7, [hl]
and a and a
ret ret
@ -553,7 +553,7 @@ _GetMovementIndex::
ret ret
UpdateSprites:: UpdateSprites::
ld a, [wVramState] ld a, [wStateFlags]
bit 0, a bit 0, a
ret z ret z
farcall UpdateAllObjectsFrozen farcall UpdateAllObjectsFrozen
@ -561,14 +561,14 @@ UpdateSprites::
ret ret
UpdateActiveSprites:: UpdateActiveSprites::
ld a, [wVramState] ld a, [wStateFlags]
bit 0, a bit 0, a
ret z ret z
farcall _UpdateActiveSprites farcall _UpdateActiveSprites
ret ret
UpdateSecondarySprites:: UpdateSecondarySprites::
ld a, [wVramState] ld a, [wStateFlags]
bit 0, a bit 0, a
ret z ret z
farcall _UpdateSecondarySprites farcall _UpdateSecondarySprites

View File

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

View File

@ -1,9 +1,9 @@
DisableSpriteUpdates:: DisableSpriteUpdates::
xor a xor a
ldh [hMapAnims], a ldh [hMapAnims], a
ld a, [wVramState] ld a, [wStateFlags]
res 0, a res 0, a
ld [wVramState], a ld [wStateFlags], a
ld a, $0 ld a, $0
ld [wSpriteUpdatesEnabled], a ld [wSpriteUpdatesEnabled], a
ret ret
@ -11,9 +11,9 @@ DisableSpriteUpdates::
EnableSpriteUpdates:: EnableSpriteUpdates::
ld a, $1 ld a, $1
ld [wSpriteUpdatesEnabled], a ld [wSpriteUpdatesEnabled], a
ld a, [wVramState] ld a, [wStateFlags]
set 0, a set 0, a
ld [wVramState], a ld [wStateFlags], a
ld a, $1 ld a, $1
ldh [hMapAnims], a ldh [hMapAnims], a
ret ret

View File

@ -7,7 +7,7 @@ UpdateTimeSensitivePals::
ret z ret z
; obj update on? ; obj update on?
ld a, [wVramState] ld a, [wStateFlags]
bit 0, a ; obj update bit 0, a ; obj update
ret z ret z

View File

@ -35,7 +35,7 @@ CloseText::
pop af pop af
ldh [hOAMUpdate], a ldh [hOAMUpdate], a
ld hl, wVramState ld hl, wStateFlags
res 6, [hl] res 6, [hl]
ret ret

View File

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