Skip to Content
The Alchemy Project

src/system/system_vram_cache.c

The sprite VRAM cache: blocks, entries and loading pictures. More…

Included by system.c.

Functions

NameDescription
Sint32syVRAMCacheAllocateBlocks (Uint32 id, Uint32 size)Finds the first run of free blocks that holds size bytes and gives it to entry id, writing id into VramCacheBlockOwners for each block.
Sint32syVRAMCacheGetLongestFreeRun (void)Unused: returns the length, in blocks, of the longest run of free blocks.
Sint32syVRAMCacheFreeBlocks (Sint32 id)Frees every block entry id owns in VramCacheBlockOwners.
Sint32syVRAMCacheFreeEntry (Uint32 id)Frees cache entry id: its blocks go back and the entry is marked free (offset VRAM_CACHE_OFFSET_FREE).
Sint32syVRAMCacheReleaseVRAM (Uint32 id)Gives back entry id's blocks but keeps the entry taken, with size 1, so a later syVRAMCacheLoad can refill it.
Sint32syVRAMCacheLoad (Uint32 id, Uint32 size, const void *src)Gives cache entry id size bytes of sprite VRAM and copies src there, or clears them for VRAM_CACHE_CLEAR, or leaves them for a null src.
voidsyVRAMCacheReset (void)Frees every block and every cache entry.
Sint32syVRAMCacheFindFreeEntry (void)Returns the number of the first free cache entry, or VRAM_CACHE_ENTRY_COUNT when all are taken.
Sint32syVRAMCacheAllocateEntry (Sint32 size)Takes a free cache entry, gives it size bytes of sprite VRAM and returns its number.
Sint32syVRAMCacheReload (Sint32 id, Sint32 src)Copies src again into entry id's VRAM, keeping its size.

Description

The sprite VRAM cache: blocks, entries and loading pictures. Part of system.c.

Functions in detail

syVRAMCacheAllocateBlocks

Sint32 syVRAMCacheAllocateBlocks(Uint32 id, Uint32 size)

Finds the first run of free blocks that holds size bytes and gives it to entry id, writing id into VramCacheBlockOwners for each block.

References Sint32, VramCacheBlockOwners and VramCacheEntries.

Referenced by syVRAMCacheLoad().

Definition at line 11 of file system_vram_cache.c.

syVRAMCacheGetLongestFreeRun

Sint32 syVRAMCacheGetLongestFreeRun(void)

Unused: returns the length, in blocks, of the longest run of free blocks.

References Sint32 and VramCacheBlockOwners.

Definition at line 59 of file system_vram_cache.c.

syVRAMCacheFreeBlocks

Sint32 syVRAMCacheFreeBlocks(Sint32 id)

Frees every block entry id owns in VramCacheBlockOwners. Returns -1 when it freed any (or id is out of range) and 0 when the entry owned none.

References Sint32 and VramCacheBlockOwners.

Referenced by syVRAMCacheFreeEntry() and syVRAMCacheReleaseVRAM().

Definition at line 83 of file system_vram_cache.c.

syVRAMCacheFreeEntry

Sint32 syVRAMCacheFreeEntry(Uint32 id)

Frees cache entry id: its blocks go back and the entry is marked free (offset VRAM_CACHE_OFFSET_FREE).

References Sint32, syVRAMCacheFreeBlocks() and VramCacheEntries.

Referenced by btMessageWaitForAdvance(), btMessageWaitForAdvanceAt(), btRun(), fdDjinnRunMercuryJoinEffect(), fdEffectSpawnDescendingArcParticles(), fdEffectSpawnScaledArcActors(), fdMapScreenRelease(), fdPsynergyAvoid(), fdPsynergyEnd(), fdPsynergyForce(), fdPsynergyPly(), fdScriptSpawnActorPlacements(), fdSpriteDestroy(), fdSpriteShareVRAMCacheEntry(), mnArrowRelease(), mnBattleCollectPartyCommands(), mnBattleCommandRowRun(), mnBattleDjinnMenuRun(), mnBattleItemMenuRun(), mnBattlePsynergyMenuRun(), mnBattleStatusScreenRun(), mnBattleSummonMenuRun(), mnBattleTargetRunSelection(), mnColossoMenuChoose(), mnConfirmSelection(), mnDjinnMenuShowHelp(), mnDjinnShowJoinedMessage(), mnIconMenuClose(), mnIconMenuReleaseArrows(), mnMessageType(), mnPartyShowJoinedMessage(), mnPartyShowPairJoinedMessage(), mnReleaseSelectionState(), mnSelectionMenuClose(), mnSelectionMenuFreeLargeIcon(), mnSelectionMenuScroll(), mnShopReleaseState(), mnWindowSpriteCreate(), mnWindowSpriteRelease(), scColossoHidePointer(), scColossoUpdateLettering(), scCottageRoomsBSpawnRingPair(), scKolimaForestTreeUpdateOrbitSpark(), scSolSanctumEruptionRaiseGoldenRings(), scSpawnGoldenRing(), scSpawnPsynergyRings(), scTreeRoomsUpdateSwirlSpark(), scValePlazaSpawnEffectPair() and syVRAMCacheLoad().

Definition at line 107 of file system_vram_cache.c.

syVRAMCacheReleaseVRAM

Sint32 syVRAMCacheReleaseVRAM(Uint32 id)

Gives back entry id's blocks but keeps the entry taken, with size 1, so a later syVRAMCacheLoad can refill it.

References Sint32, syVRAMCacheFreeBlocks() and VramCacheEntries.

Referenced by fdActorSystemPlaceSprites(), fdRenderPlaceProjectedSprite(), scColossoDrawGauge() and scHeatGaugeDraw().

Definition at line 124 of file system_vram_cache.c.

syVRAMCacheLoad

Sint32 syVRAMCacheLoad(Uint32 id, Uint32 size, const void *src)

Gives cache entry id size bytes of sprite VRAM and copies src there, or clears them for VRAM_CACHE_CLEAR, or leaves them for a null src. An entry that already holds VRAM of the same size keeps it. Returns the first sprite tile number of its VRAM, or 0 when it cannot.

References Sint32, syDMAXCopy(), syVRAMCacheAllocateBlocks(), syVRAMCacheFreeEntry(), syWordsClear() and VramCacheEntries.

Referenced by fdActorSystemConfigure(), fdEffectInitSparkles(), fdEffectStartGroundMask(), fdItemDisplayShowItem(), fdItemDisplayShowItemInFront(), fdMapScreenInit(), fdMotesStart(), fdPsynergyAvoid(), fdPsynergyLoadResources(), fdSpriteComposePicture(), fdSpriteCreate(), fdWeatherStartRain(), mnArrowCreate(), mnColossoMenuChoose(), mnCommandIconLoad(), mnCommandIconLoadIntoSlot(), mnDebugSelectShortcuts(), mnIconBuildAbilityIconTiles(), mnIconBuildCommandIconTiles(), mnIconBuildItemIconTiles(), mnIconBuildMiscellaneousIconTiles(), mnIconCreateHandCursor(), mnIconCreateHandCursorUnusedArgument(), mnIconLoadWithPalette(), mnItemIconLoadLayersIntoSlot(), mnItemMenuSelectGiveQuantity(), mnLoadDjinnArrows(), mnLoadStatArrows(), mnNameEntryEditMemberName(), mnNameEntryLoadCaretTiles(), mnNameEntryLoadPointingHandTiles(), mnPauseMenuOpen(), mnPointingHandLoadIntoFreeSlot(), mnSelectionMenuCreate(), mnSelectionMenuDraw(), mnSelectionMenuDrawArrow(), mnSelectionMenuLoadLargeIcon(), mnSelectionMenuSetupArrow(), mnSettingsMenuAnimateCursors(), mnSettingsMenuOpen(), mnShopCreatePriceSprite(), mnShopInitState(), mnShopSelectQuantity(), mnTitleLoad(), mnTitleLoadFirstTile(), mnTitleShowTitleScreen(), mnVRAMLoad(), mnWindowSpriteUpdateAll(), mnWindowSystemStartBattleUpdate(), mnWindowSystemStartFieldUpdate() and 20 more.

Definition at line 142 of file system_vram_cache.c.

syVRAMCacheReset

void syVRAMCacheReset(void)

Frees every block and every cache entry.

References VramCacheBlockOwners and VramCacheEntries.

Referenced by btDebugBattleRunMenu(), fdSpriteViewerRun(), gmMainRoutineRun(), mnTitleShowTitleScreen() and syInit().

Definition at line 194 of file system_vram_cache.c.

syVRAMCacheFindFreeEntry

Sint32 syVRAMCacheFindFreeEntry(void)

Returns the number of the first free cache entry, or VRAM_CACHE_ENTRY_COUNT when all are taken.

References Sint32 and VramCacheEntries.

Referenced by fdEffectInitSparkles(), fdMapScreenInit(), fdMotesStart(), fdPsynergyAvoid(), fdPsynergyLoadResources(), fdSpriteCreate(), fdWeatherStartRain(), mnArrowCreate(), mnColossoMenuChoose(), mnCommandIconCreate(), mnDebugBrowserIcons(), mnDebugSelectShortcuts(), mnGlyphDraw(), mnIconBuildAbilityIconTiles(), mnIconBuildCommandIconTiles(), mnIconBuildItemIconTiles(), mnIconCreateHandCursor(), mnIconCreateHandCursorUnusedArgument(), mnIconCreatePsynergyIcon(), mnIconLoadWithPalette(), mnIconMenuAddIcon(), mnItemMenuSelectGiveQuantity(), mnLoadDjinnArrows(), mnLoadStatArrows(), mnNameEntryEditMemberName(), mnPauseMenuOpen(), mnPointingHandLoadIntoFreeSlot(), mnSelectionIconLoad(), mnSelectionIconLoadIntoSlot(), mnSelectionMenuCreate(), mnSelectionMenuLoadLargeIcon(), mnSelectionMenuSetupArrow(), mnSettingsMenuOpen(), mnShopCreatePriceSprite(), mnShopInitState(), mnShopSelectQuantity(), mnTitleCreate(), mnTitleShowTitleScreen(), mnWindowPutGlyph(), mnWindowSpriteCreateAbilityIcon(), mnWindowSpriteCreateFromTable(), mnWindowSpriteCreateLoaded(), mnWindowSpriteCreateOverlaidIcon(), scColosseumSatrageMatchStartRaceGauge(), scColossoLoadLettering(), scColossoStartRaceGauge(), scHeatGaugeStart(), scLemurianShipStartCurtains(), scSolSanctumStatueInitScrollingSprites(), scTitleLoadSprites() and 1 more.

Definition at line 219 of file system_vram_cache.c.

syVRAMCacheAllocateEntry

Sint32 syVRAMCacheAllocateEntry(Sint32 size)

Takes a free cache entry, gives it size bytes of sprite VRAM and returns its number.

References Sint32, syVRAMCacheFindFreeEntry() and syVRAMCacheLoad().

Referenced by btMessageWaitForAdvance(), btMessageWaitForAdvanceAt(), btRun(), mnBattleCollectPartyCommands(), mnBattleCommandRowRun(), mnBattleDjinnMenuRun(), mnBattleDjinnMenuShowChangePreview(), mnBattleItemMenuRun(), mnBattlePsynergyMenuRun(), mnBattleStatusScreenRun(), mnBattleSummonMenuRun() and mnBattleTargetRunSelection().

Definition at line 238 of file system_vram_cache.c.

syVRAMCacheReload

Sint32 syVRAMCacheReload(Sint32 id, Sint32 src)

Copies src again into entry id's VRAM, keeping its size. Returns the first sprite tile number.

References Sint32, syVRAMCacheLoad() and VramCacheEntries.

Referenced by btMessageWaitForAdvance(), btMessageWaitForAdvanceAt(), btPlaybackRun(), mnAbilityIconLoadIntoSlot(), mnBattleDjinnMenuRun(), mnBattleDjinnMenuShowChangePreview(), mnBattleItemMenuRun(), mnBattlePsynergyMenuRun(), mnBattleStatusScreenRun(), mnBattleSummonMenuRun(), mnBattleTargetRunSelection(), mnCommandIconReloadSlot(), mnIconLoadResourceIntoSlot(), mnItemIconLoadIntoSlot() and mnStatusIconLoadIntoSlot().

Definition at line 249 of file system_vram_cache.c.