The sprite VRAM cache: blocks, entries and loading pictures. More...
Go to the source code of this file.
Functions | |
| s32 | VramCache_AllocateBlocks (u32 id, u32 size) |
| Finds the first run of free blocks that holds size bytes and gives it to entry id, writing id into gResourceBlockOwners for each block. | |
| s32 | VramCache_GetLongestFreeRun (void) |
| Returns the length, in blocks, of the longest run of free blocks. | |
| s32 | VramCache_FreeBlocks (s32 id) |
| Frees every block entry id owns in gResourceBlockOwners. | |
| s32 | Resource_ResetEntry (u32 no) |
| Frees cache entry no: its blocks go back and the entry is marked free (offset 0xffff). | |
| s32 | VramCache_ReleaseVram (u32 no) |
| Gives back entry no's blocks but keeps the entry taken, with size 1, so a later VramCache_Load can refill it. | |
| s32 | VramCache_Load (u32 no, u32 size, const void *src) |
| Gives cache entry no size bytes of sprite VRAM and copies src there. | |
| void | VramCache_Reset (void) |
| Frees every block and every cache entry. | |
| s32 | Resource_FindFreeEntry (void) |
| Returns the number of the first free cache entry, or VRAM_CACHE_ENTRY_COUNT when all are taken. | |
| s32 | VramCache_AllocEntry (s32 size) |
| Takes a free cache entry, gives it size bytes of sprite VRAM and returns its number. | |
| s32 | VramCache_Reload (s32 no, s32 src) |
| Copies src again into entry no's VRAM, keeping its size. | |
The sprite VRAM cache: blocks, entries and loading pictures.
Part of runtime.c, the runtime object, compiled only through it.
Definition in file vram_cache.c.
Finds the first run of free blocks that holds size bytes and gives it to entry id, writing id into gResourceBlockOwners for each block.
Called by VramCache_Load. Returns its byte offset in sprite VRAM, or -1 when no run is long enough.
Definition at line 16 of file vram_cache.c.
Referenced by System_GetLanguage(), VramCache_AllocateBlocks(), and VramCache_Load().
| s32 VramCache_GetLongestFreeRun | ( | void | ) |
Returns the length, in blocks, of the longest run of free blocks.
Nothing in ☀️ calls it.
Definition at line 57 of file vram_cache.c.
Referenced by System_GetLanguage(), and VramCache_GetLongestFreeRun().
Frees every block entry id owns in gResourceBlockOwners.
Called by Resource_ResetEntry and VramCache_ReleaseVram. Returns -1 when it freed any (or id is out of range) and 0 when the entry owned none.
Definition at line 79 of file vram_cache.c.
Referenced by Resource_ResetEntry(), System_GetLanguage(), VramCache_FreeBlocks(), and VramCache_ReleaseVram().
Frees cache entry no: its blocks go back and the entry is marked free (offset 0xffff).
Called throughout the game when a sprite's picture is no longer shown.
Definition at line 106 of file vram_cache.c.
Referenced by Battle_CollectPartyCommands(), Battle_RunEncounter(), Battle_SelectAbility(), BattleEffect_CleanupSceneObjects(), BattleFx_CleanupResourcesAndWindow(), BattleFx_RunMercuryDjinnCapture(), BattleFx_SpawnDescendingArcParticles(), BattleFx_SpawnScaledArcObjects(), BattleMenu_RunActionSelection(), BattlePresentation_WaitForAdvance(), BattlePresentation_WaitForPromptAt(), BattleTarget_RunSelection(), Colosso_HidePointer(), Colosso_UpdateLettering(), Djinn_ShowJoinedMessage(), DjinnMenu_ShowHelp(), Event_SpawnObjectTable(), FieldFx_RunAvoid(), FieldFx_RunForce(), FieldFx_RunPly(), ItemList_SelectEntry(), KolimaForestTree_UpdateOrbitSpark(), Menu_ConfirmSelection(), Menu_EndResourceSelection(), Menu_ReleaseSelectionWorkspace(), Menu_ResetTwoResourceEntries(), Menu_RunCommandRow(), Menu_ScrollSelectionList(), Party_ShowJoinedMessage(), Party_ShowPairJoinedMessage(), PartyTalkMenu_Choose(), RenderOutput_Create(), RenderOutput_Release(), Resource_ResetEntry(), Resource_ResetOwnerEntries(), Resource_ResetPendingTransfer(), ResourceObject_Release(), Shop_ReleaseCursorWork(), SolSanctumEruption_SpawnEffectPair(), Sprite_ShareVramCache(), SummonMenu_SelectSummon(), System_GetLanguage(), TretTreeInteriors_UpdateSwirlSpark(), Ui_RunOwnerStatusScreen(), UiTextResource_Release(), UiWork_StepChannelScript(), ValeBabi_SpawnEffectPair(), ValeHome_SpawnEffectPair(), ValeStorm_SpawnEffectPair(), VenusLighthouseAerie_SpawnLinkedPairEffects(), VramCache_Load(), and WorldMap_CreateLinkedEffects().
Gives back entry no's blocks but keeps the entry taken, with size 1, so a later VramCache_Load can refill it.
Called by the field sprites and cameras.
Definition at line 122 of file vram_cache.c.
Referenced by Colosso_DrawGauge(), HeatGauge_Draw(), ObjectSystem_UpdateCamera(), Render_PlaceProjectedSprite(), System_GetLanguage(), and VramCache_ReleaseVram().
Gives cache entry no size bytes of sprite VRAM and copies src there.
An entry that already holds VRAM of the same size keeps it. A null src copies nothing and (void *)-1 clears the memory. Writes the entry's offset and size into gVramBlockCache. Called throughout the game to load sprite pictures. Returns the first sprite tile number (32-byte units), or 0 when there was no room.
Definition at line 143 of file vram_cache.c.
Referenced by BattleFx_LoadActionEffectResources(), BattleFx_SetupResourcesAndWindow(), BattleFx_StartEffectObject22(), BattleFx_StartFadeOverlay(), BattleFx_StartRandomParticleEmitter(), Debug_SelectAbilityPair(), FieldEffect_InitSparkles(), FieldFx_RunAvoid(), FieldFx_StartGroundParticles(), FieldMotes_Start(), ItemMenu_SelectGiveQuantity(), Menu_LoadResourceSlot(), NameEntry_EditOwnerName(), ObjectSystem_Configure(), OptionMenu_AnimateCursors(), OptionMenu_Open(), PartyTalkMenu_Choose(), RenderResource_LoadFrame(), RenderResource_LoadPair(), RenderResource_LoadTableEntry(), Resource_CopyFixedBlockA(), Resource_CopyFixedBlockB(), Resource_LoadFixedBlockBIntoFreeSlot(), Resource_LoadPairedBlocks(), Resource_LoadPairedBlocksIfAvailable(), ResourceObject_Create(), SaveMenu_SelectSlot(), SelectionScreen_Draw(), SelectionScreen_DrawArrow(), SelectionScreen_LoadLargeIcon(), SelectionScreen_SetupArrow(), Shop_CreatePriceSprite(), Shop_InitializeCursorWork(), Shop_SelectQuantity(), System_GetLanguage(), SystemMenu_Open(), Title_ShowIntro(), Ui_BuildPairedPatternsToSlot(), Ui_BuildPatternToSlot(), UiGlyph_LoadEntryWithPalette(), UiGlyph_ResetWorkState(), UiIcon_BuildAbilityIconTiles(), UiIcon_BuildItemIconTiles(), UiIcon_CopyResourceToSlot(), UiIcon_CreateWithResource(), UiIcon_CreateWithResourceVariant(), UiTextResource_Initialize(), UiWork_AnimateSpriteSlots(), UiWork_InitCountersAndScheduleRefresh(), UiWork_InitCountersWithResourceAndScheduleRefresh(), VramCache_AllocEntry(), VramCache_Load(), and VramCache_Reload().
| void VramCache_Reset | ( | void | ) |
Frees every block and every cache entry.
Called by System_Initialize, Game_ResetForNewGame and the debug modes that start over.
Definition at line 184 of file vram_cache.c.
Referenced by DebugBattle_RunMenu(), Game_ResetForNewGame(), System_GetLanguage(), System_Initialize(), Title_ShowIntro(), Ui_RunIconMonitor(), and VramCache_Reset().
| s32 Resource_FindFreeEntry | ( | void | ) |
Returns the number of the first free cache entry, or VRAM_CACHE_ENTRY_COUNT when all are taken.
Called before VramCache_Load by code that keeps the entry number.
Definition at line 211 of file vram_cache.c.
Referenced by BattleFx_LoadActionEffectResources(), BattleFx_SetupResourcesAndWindow(), Colosso_LoadLettering(), Colosso_StartRaceGauge(), Curtain_Start(), Debug_SelectAbilityPair(), DebugMenu_BrowseIcons(), FieldEffect_InitSparkles(), FieldFx_RunAvoid(), FieldFx_StartGroundParticles(), FieldMotes_Start(), FieldScene_BuildDescriptorAndInstallTask(), HeatGauge_Start(), ItemMenu_SelectGiveQuantity(), Menu_AppendResourceEntry(), NameEntry_EditOwnerName(), OptionMenu_Open(), PartyTalkMenu_Choose(), RenderOutput_CreateFromTable(), RenderOutput_CreateLoaded(), RenderOutput_CreateWithTransform(), RenderResource_CreateFrame(), RenderResource_CreatePair(), Resource_FindFreeEntry(), Resource_LoadByMode(), Resource_LoadByModeIntoSlot(), Resource_LoadFixedBlockBIntoFreeSlot(), Resource_LoadPairedBlocks(), Resource_LoadPairedBlocksIfAvailable(), ResourceObject_Create(), SaveMenu_SelectSlot(), SelectionScreen_LoadLargeIcon(), SelectionScreen_SetupArrow(), Shop_CreatePriceSprite(), Shop_InitializeCursorWork(), Shop_SelectQuantity(), SolSanctumStatue_InitializeScrollingSprites(), System_GetLanguage(), SystemMenu_Open(), Title_LoadSprites(), Title_ShowIntro(), Ui_BuildPairedPatternsToSlot(), Ui_CreateOutputFromResourceSlot(), UiGlyph_LoadEntryWithPalette(), UiGlyph_ResetWorkState(), UiIcon_BuildAbilityIconTiles(), UiIcon_BuildItemIconTiles(), UiIcon_CreateWithLoadedResource(), UiIcon_CreateWithResource(), UiIcon_CreateWithResourceVariant(), UiText_DrawGlyph(), UiTextResource_Initialize(), UiWindow_PutGlyph(), and VramCache_AllocEntry().
Takes a free cache entry, gives it size bytes of sprite VRAM and returns its number.
Called by the battle prompts and the menus' command rows.
Definition at line 227 of file vram_cache.c.
Referenced by Battle_CollectPartyCommands(), Battle_RunEncounter(), Battle_SelectAbility(), BattleMenu_RunActionSelection(), BattlePresentation_WaitForAdvance(), BattlePresentation_WaitForPromptAt(), BattleTarget_RunSelection(), DjinnMenu_ShowChangePreview(), ItemList_SelectEntry(), Menu_RunCommandRow(), SummonMenu_SelectSummon(), System_GetLanguage(), Ui_RunOwnerStatusScreen(), and VramCache_AllocEntry().
Copies src again into entry no's VRAM, keeping its size.
Called by code that redraws a sprite picture in place, such as the battle prompts. Returns the first sprite tile number.
Definition at line 238 of file vram_cache.c.
Referenced by Battle_SelectAbility(), BattleEvent_Playback(), BattleMenu_RunActionSelection(), BattlePresentation_WaitForAdvance(), BattlePresentation_WaitForPromptAt(), BattleTarget_RunSelection(), DjinnMenu_ShowChangePreview(), ItemIcon_LoadIntoSlot(), ItemList_SelectEntry(), Resource_LoadIndexedEntryToBuffer(), Resource_LoadIndexedIntoBuffer(), Resource_LoadTableEntryToBuffer(), SummonMenu_SelectSummon(), System_GetLanguage(), Ui_RunOwnerStatusScreen(), UiIcon_LoadResourceIntoSlot(), and VramCache_Reload().