Skip to content

Commit

Permalink
Rename wVramState to wStateFlags and use flag constants (#1078)
Browse files Browse the repository at this point in the history
  • Loading branch information
xCrystal committed Jan 7, 2024
1 parent 5be9856 commit f72f078
Show file tree
Hide file tree
Showing 31 changed files with 125 additions and 120 deletions.
6 changes: 6 additions & 0 deletions constants/wram_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions engine/events/celebi.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -49,7 +49,7 @@ CelebiShrineEvent:

.done
pop af
ld [wVramState], a
ld [wStateFlags], a
call .RestorePlayerSprite_DespawnLeaves
call CelebiEvent_SetBattleType
ret
Expand Down
12 changes: 6 additions & 6 deletions engine/events/field_moves.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -364,7 +364,7 @@ FlyToAnim:

.exit
pop af
ld [wVramState], a
ld [wStateFlags], a
call .RestorePlayerSprite_DespawnLeaves
ret

Expand Down
4 changes: 2 additions & 2 deletions engine/events/halloffame.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions engine/menus/menu.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions engine/menus/trainer_card.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -35,7 +35,7 @@ TrainerCard:
pop af
ld [wOptions], a
pop af
ld [wVramState], a
ld [wStateFlags], a
ret

.InitRAM:
Expand Down
6 changes: 3 additions & 3 deletions engine/movie/trade_animation.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -148,7 +148,7 @@ RunTradeAnimScript:
pop af
ld [wOptions], a
pop af
ld [wVramState], a
ld [wStateFlags], a
pop af
ldh [hMapAnims], a
ret
Expand Down
4 changes: 2 additions & 2 deletions engine/overworld/init_map.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 6 additions & 6 deletions engine/overworld/map_objects.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
16 changes: 8 additions & 8 deletions engine/overworld/movement.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions engine/overworld/player_object.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions engine/overworld/scripting.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions engine/overworld/warp_connection.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion engine/phone/phonering_copytilemapatonce.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions engine/pokedex/pokedex.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions engine/pokegear/pokegear.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -55,7 +55,7 @@ PokeGear:
call PlaySFX
call WaitSFX
pop af
ld [wVramState], a
ld [wStateFlags], a
pop af
ldh [hInMenu], a
pop af
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1819,7 +1819,7 @@ _TownMap:

.resume
pop af
ld [wVramState], a
ld [wStateFlags], a
pop af
ldh [hInMenu], a
pop af
Expand Down

0 comments on commit f72f078

Please sign in to comment.