src/system/system_heap.c
The heap: its two bump allocators and heap slots. More…
Included by system.c.
Functions
| Name | Description | |
|---|---|---|
void | syHeapInit (void) | Empties the heap: clears the 64 words of HeapSlots (both pool pointers and every heap slot) and sets the pools' next addresses to IwramHeap and EwramHeap. |
Sint32 | syHeapGetRemainingIWRAM (void) | Returns the IWRAM bytes left to allocate, up to RamIWRAMHeapEnd (the address of CartridgeResetMarker), the end the allocators test. |
Sint32 | syHeapGetRemainingEWRAM (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. |
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. |
void | syHeapReservedNoOperation (void) | Unused: reserved empty memory export. |
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 64 words of HeapSlots (both pool pointers and
every heap slot) and sets the pools' next addresses to IwramHeap and
EwramHeap.
References EwramHeap, HeapSlots, IwramHeap and state.
Referenced by btDebugBattleRunMenu(), fdSpriteViewerRun(), gmMainRoutineRun() and syInit().
Definition at line 10 of file system_heap.c.
syHeapGetRemainingIWRAM
Sint32 syHeapGetRemainingIWRAM(void)
Returns the IWRAM bytes left to allocate, up to RamIWRAMHeapEnd (the address
of CartridgeResetMarker), the end the allocators test.
References CartridgeResetMarker, HeapSlots, Sint32 and state.
Referenced by btRun().
Definition at line 21 of file system_heap.c.
syHeapGetRemainingEWRAM
Sint32 syHeapGetRemainingEWRAM(void)
Returns the EWRAM bytes left to allocate, up to the end of EWRAM. btRun calls
it around each action and ignores the result.
References HeapSlots, Sint32 and state.
Referenced by btRun().
Definition at line 31 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 HeapSlots, Sint32 and state.
Referenced by btEffectBuildBlitter(), btEffectRunByIdRange(), btEffectRunElementBurst(), btEffectRunElementPillar(), btEffectRunFromTable(), btEffectRunShatteringOpening(), btEffectRunSummon(), btEffectStartElementStreaks(), btElementGlowInitStarField(), btTransitionRun(), fdActorSystemConfigure(), fdEffectInitSlots(), fdEffectStartGroundMask(), fdItemDisplayShowItem(), fdItemDisplayShowItemInFront(), fdLuckyDiceRun(), fdLuckyWheelsRun(), fdPsynergyLoadResources(), fdSpriteComposePicture(), fdWorldMapInitPerspective(), fdWorldMapWriteLayerMetatileTile(), mnBattleCommandRowLoadIconTiles(), mnCommandIconReloadSlot(), mnDjinnMenuRun(), mnFileListSelectFile(), mnIconBuildAbilityIconTiles(), mnIconBuildCommandIconTiles(), mnIconBuildItemIconTiles(), mnIconBuildMiscellaneousIconTiles(), mnIconLoadWithPalette(), mnItemIconLoadLayersIntoSlot(), mnItemMenuRun(), mnPartyMemberChooserOpen(), mnPsynergyMenuRun(), mnSelectionMenuLoadLargeIcon(), mnShopInitState(), mnStatusScreenRun(), mnTitleShowTitleScreen(), scColossoShowItemIcon(), scCottageRoomsBShowMythrilBag(), scFloatNut(), scImilFuchinFallsPlaceDragonsEye(), scInit(), scKalayPrepareTown(), scSanctumRaiseItemIcon(), scShipRoomsPlaceAnchorCharm(), scSolSanctumElementalStarRoomPresentStarFX(), scSolSanctumEruptionPlayWiseOneRescue(), scVaultPlaceItemIcon(), scVenusLighthouseAerieCombineSaturosAndMenardi() and 2 more.
Definition at line 40 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 HeapSlots, Sint32 and state.
Referenced by btBackgroundInit(), btEffectRunByIdRange(), btElementGlowInitStarField(), btRun(), fdActorSystemConfigure(), fdActorSystemInit(), fdCameraFollow(), fdCameraFollowActor(), fdCameraGetActor(), fdCameraMoveToActorById(), fdCameraMoveWithinMapBounds(), fdCameraSetSpeedParams(), fdCameraWaitForArrival(), fdEffectInitSparkles(), fdEffectStartGroundMask(), fdEngineRun(), fdLuckyDiceRun(), fdLuckyWheelsRun(), fdMapGridLoadMap(), fdMapScreenShow(), fdMotesStart(), fdPaletteCycleInit(), fdPaletteFadeInit(), fdPsynergyStartMindReadWave(), fdScreenTransitionAllocateAndClearState(), fdScreenTransitionStartDissolveHeld(), fdScreenTransitionStartHeldWindow(), fdScriptWaitForZoomTransition(), fdSpriteViewerRun(), fdWeatherLastLightning(), fdWeatherResumeLightning(), fdWeatherStartLightning(), fdWeatherStartLightningFlash(), fdWeatherStartRain(), fdWeatherStopLightning(), fdWorldMapFreeze(), fdWorldMapInitPerspective(), fdWorldMapStartZoom(), fdWorldMapStepZoom(), fdWorldMapUnfreeze(), fdWorldMapZoomOutWhileLHeld(), mnAbilityIconLoadIntoSlot(), mnAllocateSelectionState(), mnBattleCollectPartyCommands(), mnCommandIconLoad(), mnIconLoadResourceIntoSlot(), mnIconMenuOpen(), mnItemIconLoadIntoSlot(), mnItemMenuSelectGiveQuantity(), mnPartyStatusCreateWindow() and 26 more.
Definition at line 78 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 HeapSlots, Sint32 and state.
Referenced by btAbilityApplyToTarget(), fdMapGridLoadMap(), fdSpriteComposePicture(), fdWorldMapLoadGraphics(), mnBattleCollectPartyCommands(), mnBattleCommandRowLoadIconTiles(), mnBattleDjinnMenuShowChangePreview(), mnBattleStatusScreenRun(), mnCommandIconLoadIntoSlot(), mnDebugSelectShortcuts(), mnDjinnMenuDrawStatPreview(), mnItemMenuConfirmEquip(), mnItemMenuDrawEquipPreview(), mnItemMenuRunCommands(), mnPsynergyMenuSelectMember(), mnStatusPanelDraw(), mnStatusScreenShowMemberProgressMessage(), mnTextDrawStringAsTiles() and scHeatGaugeDraw().
Definition at line 115 of file system_heap.c.
syHeapAllocateEWRAM
void *syHeapAllocateEWRAM(Sint32 size)
As syHeapAllocate, but tries EWRAM first. Called mostly by the battle code
and the credits for buffers too large to want IWRAM.
References HeapSlots, Sint32 and state.
Referenced by btAppendLinkedActions(), btAwardSpoils(), btBuildPartyActions(), btEnemyAdjustLevel(), btFormationSelectLevelMatchedCandidate(), btLinkBattleReceiveParty(), btLinkBattleSendParty(), btUnitProcessActionEnd(), fdMapScreenInit(), fdTileMapConvertBuffer(), gmUnitCalculate(), gmUnitLevelUp(), mnBattleCommandRowRun(), mnBattleDjinnMenuRun(), mnBattleDjinnMenuShowChangePreview(), mnCreditsDrawLine(), mnCreditsInitTextSprites(), mnDjinnMenuRun(), mnDjinnMenuRunPreview(), mnDjinnMenuShowMemberStatus(), mnItemMenuRun(), mnPsynergyMenuRun(), mnSaveWriteLinkTallies(), mnStatusScreenRun(), mnTextDrawString(), mnTextDrawStringAtOffset(), mnTextDrawStringInWindow(), mnWindowCopyTilemapRegion(), scBattleArenaReceivePartyRecords(), scBattleArenaSendPartyRecords(), scColosseumSatrageMatchStartRaceGauge(), scColossoDrawGauge(), scColossoLoadLettering(), scColossoStartRaceGauge(), scFileScreenFillTileGridByGridWidth(), scFileScreenFillTileGridByWindowWidth(), scLemurianShipStartCurtains(), scTitleLoadSprites() and scWorldMapPlayLighthouseTransition().
Definition at line 145 of file system_heap.c.
syHeapReservedNoOperation
void syHeapReservedNoOperation(void)
Unused: reserved empty memory export.
Definition at line 174 of file system_heap.c.