Skip to Content
The Alchemy Project

src/system/system_vram_cache.c

The sprite VRAM cache, which hands out sprite tile VRAM to the actors, icons and portraits on screen and loads their pictures into it; then the affine matrix builder that follows it. 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.
Sint32syVRAMCacheCountFreeBlocks (void)Returns how many of sprite VRAM's blocks are free.
Sint32syVRAMCacheFreeBlocks (Sint32 id)Frees every block entry id owns in VramCacheBlockOwners.
Sint32syVRAMCacheFreeEntry (Uint32 id)Frees cache entry id and the VRAM it holds; returns -1 for an entry out of range.
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)Loads size bytes from src into the sprite VRAM of cache entry id, reusing its blocks when the size is unchanged (src 0 loads nothing, VRAM_CACHE_CLEAR clears); returns the first sprite tile number, or 0 when it does not fit.
voidsyVRAMCacheReset (void)Frees every VRAM block and every cache entry.
Sint32syVRAMCacheFindFreeEntry (void)Returns the first free cache entry, or VRAM_CACHE_ENTRY_COUNT when all are in use.
Sint32syVRAMCacheAllocateEntry (Sint32 size)Takes a free cache entry, gives it size bytes of sprite VRAM and returns its number.
Sint32syVRAMCacheReload (Sint32 id, const void *src)Copies src again into entry id's VRAM, keeping its size.
Sint32syAffineMatrixBuild (Sint32 angle, Sint32 xScale, Sint32 yScale)Takes the next of the OBJ_AFFINE_MATRIX_COUNT sprite affine matrices and fills it with a rotation by angle and the scales; returns its index, or the last matrix's when all are taken.

Description

The sprite VRAM cache, which hands out sprite tile VRAM to the actors, icons and portraits on screen and loads their pictures into it; then the affine matrix builder that follows it. 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. Returns the run's byte offset, or -1 when no run fits.

References Sint32, VramCacheBlockOwners and VramCacheEntries.

Referenced by syVRAMCacheLoad().

Definition at line 13 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 62 of file system_vram_cache.c.

syVRAMCacheCountFreeBlocks

Sint32 syVRAMCacheCountFreeBlocks(void)

Returns how many of sprite VRAM's blocks are free.

References Sint32 and VramCacheBlockOwners.

Definition at line 85 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 100 of file system_vram_cache.c.

syVRAMCacheFreeEntry

Sint32 syVRAMCacheFreeEntry(Uint32 id)

Frees cache entry id and the VRAM it holds; returns -1 for an entry out of range.

References Sint32, syVRAMCacheFreeBlocks() and VramCacheEntries.

Referenced by btEffectRunCatastrophe(), btEffectRunDaedalus(), btEffectRunEclipse(), btMessageWaitForAdvance(), btMessageWaitForAdvanceAt(), btRun(), dbPsynergyTest2EndRocks(), dbPsynergyTestUpdateRings(), fdActorAppearInSparks(), fdActorShadowFreeTiles(), fdAvoidDropRing(), fdBattleEffectEndArcEffect(), fdDjinnRunMercuryJoinEffect(), fdMapScreenRelease(), fdParticleBurstEnd(), fdPsynergyArrow(), fdPsynergyAvoid(), fdPsynergyBlaze(), fdPsynergyBurst(), fdPsynergyEndHover(), fdPsynergyEndRing(), fdPsynergyEndSand(), fdPsynergyForce(), fdPsynergyGrindOnTarget(), fdPsynergyHover(), fdPsynergyLash(), fdPsynergyParch(), fdPsynergyPly(), fdPsynergyPound(), fdPsynergyReleaseSceneSprite(), fdPsynergyRing(), fdPsynergySand(), fdPsynergyScoop(), fdPsynergyTremorOnTarget(), fdScriptSpawnActorTable(), fdSpriteDestroy(), fdSpriteShareVRAMCacheEntry(), fdSummonTabletPlayRunes(), fdTeleportPlaySparks(), fdTeleportPlayWhirl(), mnArrowRelease(), mnBattleCollectPartyCommands(), mnBattleCommandRowRun(), mnBattleDjinnMenuRun(), mnBattleItemMenuRun(), mnBattlePsynergyMenuRun(), mnBattleStatusScreenRun(), mnBattleSummonMenuRun(), mnBattleTargetRunSelection(), mnConfirmSelection() and 38 more.

Definition at line 124 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() and scTrialRoadDrawRaceMap().

Definition at line 141 of file system_vram_cache.c.

syVRAMCacheLoad

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

Loads size bytes from src into the sprite VRAM of cache entry id, reusing its blocks when the size is unchanged (src 0 loads nothing, VRAM_CACHE_CLEAR clears); returns the first sprite tile number, or 0 when it does not fit.

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

Referenced by btEffectSpriteCreateWithTiles(), fdActorAppearInSparks(), fdActorSetItemIcon(), fdActorShadowLoadTiles(), fdActorShowItemIconById(), fdActorSystemConfigure(), fdBattleEffectStartArcEffect(), fdEffectInitSparkles(), fdEffectStartBlankOverlay(), fdEffectStartFadeOverlay(), fdFadeOverlayFillTiles(), fdGroundParticlesStart(), fdHangingVineInit(), fdItemDisplayShowItem(), fdItemDisplayShowItemInFront(), fdMapScreenInit(), fdMotesStart(), fdParticleBurstStart(), fdPsynergyArrow(), fdPsynergyAvoid(), fdPsynergyBlaze(), fdPsynergyBurst(), fdPsynergyEndRing(), fdPsynergyEndSand(), fdPsynergyGrindOnTarget(), fdPsynergyHover(), fdPsynergyLash(), fdPsynergyParch(), fdPsynergyPound(), fdPsynergyRing(), fdPsynergySand(), fdPsynergyScoop(), fdPsynergyStartSceneSprite(), fdPsynergyTremorOnTarget(), fdRisingParticlesStart(), fdRopeInit(), fdSpriteComposePicture(), fdSpriteCreate(), fdSummonTabletPlayRunes(), fdTeleportPlaySparks(), fdTeleportPlayWhirl(), fdTightropeInit(), fdWeatherStartRain(), mnArrowCreate(), mnCommandIconLoad(), mnCommandIconLoadIntoSlot(), mnEndingImageInitStrips(), mnIconBuildAbilityIconTiles(), mnIconBuildCommandIconTiles(), mnIconBuildItemIconTiles() and 43 more.

Definition at line 159 of file system_vram_cache.c.

syVRAMCacheReset

void syVRAMCacheReset(void)

Frees every VRAM block and every cache entry.

References VramCacheBlockOwners and VramCacheEntries.

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

Definition at line 207 of file system_vram_cache.c.

syVRAMCacheFindFreeEntry

Sint32 syVRAMCacheFindFreeEntry(void)

Returns the first free cache entry, or VRAM_CACHE_ENTRY_COUNT when all are in use.

References Sint32 and VramCacheEntries.

Referenced by btEffectSpriteCreateWithTiles(), dbPsynergyTest2StartRocks(), dbPsynergyTestStartRings(), fdActorAppearInSparks(), fdBattleEffectStartArcEffect(), fdEffectInitSparkles(), fdGroundParticlesStart(), fdHangingVineInit(), fdMapScreenInit(), fdMotesStart(), fdParticleBurstStart(), fdPsynergyArrow(), fdPsynergyAvoid(), fdPsynergyBlaze(), fdPsynergyBurst(), fdPsynergyEndRing(), fdPsynergyEndSand(), fdPsynergyGrindOnTarget(), fdPsynergyHover(), fdPsynergyLash(), fdPsynergyParch(), fdPsynergyPound(), fdPsynergyRing(), fdPsynergySand(), fdPsynergyScoop(), fdPsynergyStartSceneSprite(), fdPsynergyTremorOnTarget(), fdRisingParticlesStart(), fdRopeInit(), fdSpriteCreate(), fdSummonTabletPlayRunes(), fdTeleportPlaySparks(), fdTeleportPlayWhirl(), fdTightropeInit(), fdWeatherStartRain(), mnArrowCreate(), mnCommandIconCreate(), mnCursorCreate(), mnDebugBrowserIcons(), mnEndingImageInitStrips(), mnGlyphDraw(), mnIconBuildAbilityIconTiles(), mnIconBuildCommandIconTiles(), mnIconBuildItemIconTiles(), mnIconCreateHandCursor(), mnIconCreatePsynergyIcon(), mnIconLoadSlots(), mnIconLoadWithPalette(), mnIconMenuAddIcon(), mnItemIconGridLoadItems() and 60 more.

Definition at line 225 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 btEffectRunCatastrophe(), btEffectRunDaedalus(), btEffectRunEclipse(), btMessageWaitForAdvance(), btMessageWaitForAdvanceAt(), btRun(), mnBattleCollectPartyCommands(), mnBattleCommandRowRun(), mnBattleDjinnMenuRun(), mnBattleDjinnMenuShowChangePreview(), mnBattleItemMenuRun(), mnBattlePsynergyMenuRun(), mnBattleStatusScreenRun(), mnBattleSummonMenuRun() and mnBattleTargetRunSelection().

Definition at line 244 of file system_vram_cache.c.

syVRAMCacheReload

Sint32 syVRAMCacheReload(Sint32 id, const void *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 mnMiscellaneousIconLoadIntoSlot().

Definition at line 255 of file system_vram_cache.c.

syAffineMatrixBuild

Sint32 syAffineMatrixBuild(Sint32 angle, Sint32 xScale, Sint32 yScale)

Takes the next of the OBJ_AFFINE_MATRIX_COUNT sprite affine matrices and fills it with a rotation by angle and the scales; returns its index, or the last matrix's when all are taken. The body is syOAMMatrixAllocateFromTransform's.

References OamMatrices, OamMatrixCount, Sint32, syCos(), syIntegerDivide() and sySin().

Referenced by fdRenderPlaceProjectedSprite().

Definition at line 264 of file system_vram_cache.c.