Skip to Content
The Alchemy Project

src/system/system_heap.c

The heap: its two bump allocators and heap slots. More…

Included by system.c.

Functions

NameDescription
voidsyHeapInit (void)Empties the heap: clears the heap slots (both pool pointers and every slot) and sets the pools' next addresses to IwramHeap and EwramHeap.
Sint32syHeapGetRemainingIWRAM (void)Returns the IWRAM bytes left to allocate, up to the sound mixer's workspace (IwramSoundMixWorkspace).
Sint32syHeapGetRemainingEWRAM (void)Returns the EWRAM bytes left to allocate, up to the end of EWRAM.
void *syHeapSlotAllocate (Sint32 slot, Sint32 size)Returns heap slot slot's block, first allocating size bytes for it (rounded up to words), from IWRAM when they fit and EWRAM otherwise.
void *syHeapSlotAllocateEWRAM (Sint32 slot, Sint32 size)As syHeapSlotAllocate, but tries EWRAM first, for blocks that need room more than speed: the battle, shop and save state, among others.
voidsyHeapFillFreeWords (Uint32 value)Fills the free space of both heaps, from each pool's next address to its end, with value.
void *syHeapAllocate (Sint32 size)Allocates size bytes (rounded up to words) with no heap slot, from IWRAM when they fit and EWRAM otherwise, and advances that pool's next address.
void *syHeapAllocateEWRAM (Sint32 size)As syHeapAllocate, but tries EWRAM first.

Description

The heap: its two bump allocators and heap slots. Part of system.c.

Functions in detail

syHeapInit

void syHeapInit(void)

Empties the heap: clears the heap slots (both pool pointers and every slot) and sets the pools' next addresses to IwramHeap and EwramHeap.

References EwramHeap and IwramHeap.

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

Definition at line 5 of file system_heap.c.

syHeapGetRemainingIWRAM

Sint32 syHeapGetRemainingIWRAM(void)

Returns the IWRAM bytes left to allocate, up to the sound mixer's workspace (IwramSoundMixWorkspace).

References IwramSoundMixWorkspace and Sint32.

Referenced by btRenderCopyTextureToIWRAM().

Definition at line 16 of file system_heap.c.

syHeapGetRemainingEWRAM

Sint32 syHeapGetRemainingEWRAM(void)

Returns the EWRAM bytes left to allocate, up to the end of EWRAM. Nothing calls it or its stub.

References Sint32.

Definition at line 25 of file system_heap.c.

syHeapSlotAllocate

void *syHeapSlotAllocate(Sint32 slot, Sint32 size)

Returns heap slot slot's block, first allocating size bytes for it (rounded up to words), from IWRAM when they fit and EWRAM otherwise.

References Sint32.

Referenced by btEffectBuildBlitter(), btEffectRunBackgroundFadeIn(), btEffectRunByIdRange(), btEffectRunElementBurst(), btEffectRunElementPillar(), btEffectRunFormChange(), btEffectRunFromTable(), btEffectRunShatteringOpening(), btEffectRunSummon(), btEffectStartElementStreaks(), btElementGlowInitStarField(), btTransitionRun(), dbPsynergyTest2StartRocks(), fdActorAppearInSparks(), fdActorSetItemIcon(), fdActorShowItemIconById(), fdActorSystemConfigure(), fdBattleEffectStartArcEffect(), fdBattleEffectStartCanvasSprite(), fdEffectInitSlots(), fdEffectStartBlankOverlay(), fdEffectStartFadeOverlay(), fdEngineRun(), fdFadeOverlayFillTiles(), fdItemDisplayShowItem(), fdItemDisplayShowItemInFront(), fdLuckyDiceRun(), fdLuckyWheelsRun(), fdPsynergyArrow(), fdPsynergyBlaze(), fdPsynergyBurst(), fdPsynergyCyclone(), fdPsynergyDecodePicture(), fdPsynergyEndSand(), fdPsynergyGrind(), fdPsynergyGrindOnTarget(), fdPsynergyHover(), fdPsynergyLash(), fdPsynergyLoadResources(), fdPsynergyParch(), fdPsynergyPound(), fdPsynergySand(), fdPsynergyScoop(), fdPsynergyTremor(), fdPsynergyTremorOnTarget(), fdSummonTabletPlayRunes(), fdSuperLuckyDiceRun(), fdTeleportPlaySparks(), fdTeleportPlayWhirl(), fdWorldMapInitPerspective() and 45 more.

Definition at line 34 of file system_heap.c.

syHeapSlotAllocateEWRAM

void *syHeapSlotAllocateEWRAM(Sint32 slot, Sint32 size)

As syHeapSlotAllocate, but tries EWRAM first, for blocks that need room more than speed: the battle, shop and save state, among others.

References Sint32.

Referenced by btBackgroundInit(), btCameraCreate(), btEffectRunByIdRange(), btElementGlowInitStarField(), btRun(), fdActorSystemConfigure(), fdActorSystemInit(), fdBattleEffectStartCanvasSprite(), fdCameraFollow(), fdCameraGetActor(), fdCameraMoveWithinMapBounds(), fdCameraSetSpeedParams(), fdCameraWaitForArrival(), fdEffectInitSparkles(), fdEffectStartBlankOverlay(), fdEffectStartFadeOverlay(), fdEngineRun(), fdGroundParticlesStart(), fdHangingVineInit(), fdLineScrollInitWave(), fdLuckyDiceRun(), fdLuckyWheelsRun(), fdMapGridLoadMap(), fdMotesStart(), fdPaletteCycleInit(), fdPaletteFadeInit(), fdPsynergyRing(), fdPsynergyStartMindReadWave(), fdRisingParticlesStart(), fdRopeInit(), fdScreenTransitionAllocateAndClearState(), fdScreenTransitionStartDissolveHeld(), fdScreenTransitionStartWindowHeld(), fdScriptWaitForZoomTransition(), fdSpriteViewerRun(), fdSuperLuckyDiceRun(), fdTightropeInit(), fdWeatherLastLightning(), fdWeatherResumeLightning(), fdWeatherStartLightning(), fdWeatherStartLightningFlash(), fdWeatherStartRain(), fdWeatherStopLightning(), fdWorldMapFreeze(), fdWorldMapInitPerspective(), fdWorldMapReloadPendingAreaGraphics(), fdWorldMapStartZoom(), fdWorldMapStepZoom(), mnAbilityIconLoadIntoSlot(), mnBattleCollectPartyCommands() and 29 more.

Definition at line 72 of file system_heap.c.

syHeapFillFreeWords

void syHeapFillFreeWords(Uint32 value)

Fills the free space of both heaps, from each pool's next address to its end, with value.

Definition at line 110 of file system_heap.c.

syHeapAllocate

void *syHeapAllocate(Sint32 size)

Allocates size bytes (rounded up to words) with no heap slot, from IWRAM when they fit and EWRAM otherwise, and advances that pool's next address.

References Sint32.

Referenced by btAbilityApplyToTarget(), btRenderCopyTextureToIWRAM(), fdHangingVineInit(), fdMapCopyPalette(), fdMapGridLoadMap(), fdPsynergyStartSceneSprite(), fdRopeInit(), fdRopeRecoil(), fdRopeThrow(), fdSpriteComposePicture(), fdTightropeInit(), fdTightropeRecoil(), fdTightropeThrow(), fdWorldMapLoadGraphics(), fdWorldMapPreloadCurrentTileBlock(), mnBattleCollectPartyCommands(), mnBattleCommandRowLoadIconTiles(), mnBattleDjinnMenuShowChangePreview(), mnBattleStatusScreenRun(), mnCommandIconLoadIntoSlot(), mnDjinnMenuDrawStatPreview(), mnItemMenuConfirmEquip(), mnItemMenuRunCommands(), mnPsynergyMenuSelectMember(), mnStatusPanelDraw(), mnStatusScreenShowMemberProgressMessage(), mnTextDrawStringAsTiles(), mnVRAMBlockLoadResource(), scAirsRockInsideWakeEntranceStatue(), scAirsRockInsideWakeHallStatue(), scAirsRockWhirlwindClearsFog(), scAirsRockWhirlwindClearsWall(), scAirsRockWhirlwindOpensTheTop(), scAnemosInnerSanctumDullahanStartLightSprites(), scAnkohlRuinsInitSand(), scAquaRockInsideStartPillars(), scAquaRockInsideStartSplashes(), scAquaRockStartBubbles(), scCrackedTileFind(), scEpilogueLoadPortraitFrame(), scJupiterLighthouseFlashSky(), scLemuriaPalaceLoadMaps(), scLightSpritesInitChannelPieces(), scLightSpritesInitEnergyBlockGlow(), scLightSpritesInitPathGlows(), scLohoFireCannon(), scMarsLighthouseEntranceStartHoleMask(), scMemAllocate(), scNorthernReachesShatterIceWall() and scShamanVillageBlowAwaySand().

Definition at line 123 of file system_heap.c.

syHeapAllocateEWRAM

void *syHeapAllocateEWRAM(Sint32 size)

As syHeapAllocate, but tries EWRAM first. Called mostly by the battle engine and the credits for buffers too large to want IWRAM.

References Sint32.

Referenced by btAppendLinkedActions(), btAwardSpoils(), btBuildUnitActions(), btEffectRunAzul(), btEffectRunBallLightning(), btEffectRunBreaths(), btEffectRunCards(), btEffectRunCastingImpact(), btEffectRunCatastrophe(), btEffectRunCharon(), btEffectRunCoatlicue(), btEffectRunCruelRuin(), btEffectRunCrystal(), btEffectRunDaedalus(), btEffectRunDaedalusStrike(), btEffectRunDeathPlunge(), btEffectRunDiamondBerg(), btEffectRunDjinniSign(), btEffectRunEclipse(), btEffectRunElementCards(), btEffectRunFlora(), btEffectRunFormChange(), btEffectRunGaspFamily(), btEffectRunGeode(), btEffectRunGeyser(), btEffectRunHaures(), btEffectRunHeavyBlow(), btEffectRunIris(), btEffectRunJudgment(), btEffectRunLeapingStrike(), btEffectRunLegend(), btEffectRunLifeShear(), btEffectRunLightSurge(), btEffectRunLiquifier(), btEffectRunMegiddo(), btEffectRunMeteorBlow(), btEffectRunMirroredWall(), btEffectRunMoloch(), btEffectRunOdyssey(), btEffectRunRadiantFire(), btEffectRunRagingHeat(), btEffectRunRushingStrike(), btEffectRunSabreDance(), btEffectRunSerac(), btEffectRunTargetStrike(), btEffectRunTrident(), btEffectRunTripleChomp(), btEffectRunTumblingQuads(), btEffectRunUlysses(), btEffectRunWaterSheet() and 59 more.

Definition at line 157 of file system_heap.c.