Skip to Content
The Alchemy Project

src/system/system_event.c

Events: per-tick and VBlank functions in priority order. More…

Included by system.c.

Typedefs

NameDescription
typedef Sint32 (*EVENT_INT_FUNC )(void);

Functions

NameDescription
voidsyInitEvent (void)Empties the event table: every slot gets no function, priority EVENT_PRIORITY_EMPTY and no flags.
voidsyCopyEventWords (Uint32 *dest, Uint32 *src, Uint32 byteCount)Unused: copies byteCount bytes a word at a time.
voidsySortEvents (void)Bubble-sorts the event table by priority, highest first, so each pass runs its events from the highest priority down; removed events (EVENT_PRIORITY_REMOVED) rise to the front.
Sint32syFindEvent (EVENT_FUNC callback)Unused: returns the table index of the event running callback, or -1.
Sint32sySetEvent (EVENT_FUNC callback, Sint32 priority)Adds an event running callback with priority priority, or gives an event already running it the new priority, and re-sorts the table.
voidsyEventNoOperationA (void)Unused: an empty function.
voidsyEventNoOperationB (void)Unused: an empty function.
Sint32syCloseEvent (EVENT_FUNC callback)Removes the event running callback: clears its function and gives it priority EVENT_PRIORITY_REMOVED, which no pass matches.
Sint32sySuspendEvent (EVENT_FUNC callback)Suspends the event running callback, or every event when callback is null, by setting EVENT_SUSPENDED in its priority's high byte, which then matches neither pass.
Sint32sySuspendOverlayEvents (void)Suspends every event whose function is in an overlay (EVENT_IN_OVERLAY) unless its flags hold EVENT_FLAG_KEEP_RUNNING, as sySuspendEvent does.
Sint32sySetEventFlags (EVENT_FUNC callback, Uint32 mask)Stores mask as the flags of the event running callback (EVENT_FLAG_KEEP_RUNNING).
Sint32syResumeEvent (EVENT_FUNC callback)Resumes the event running callback, or every event when callback is null, by clearing EVENT_SUSPENDED.
Sint32syResumeOverlayEvents (void)Resumes every event whose function is in an overlay, flagged or not.
voidsyExecuteEvent (Sint32 pass)Runs one pass of the events: every event whose priority's high byte matches pass's (EVENT_PASS_VBLANK or EVENT_PASS_TICK), in table order.
Sint32syCountEventsInPass (Sint32 pass)Returns how many events run in pass pass (EVENT_PASS_VBLANK or EVENT_PASS_TICK); before the event table is set up, the pass's high byte.
voidsyRunPassBeforeTickEvents (Sint32 pass)Runs pass pass's events in table order, up to the first event of the tick pass: the VBlank handler's pass, whose events sort before the tick's.

Description

Events: per-tick and VBlank functions in priority order. Part of system.c.

Typedefs in detail

EVENT_INT_FUNC

typedef Sint32 (*EVENT_INT_FUNC)(void);

Definition at line 6 of file system_event.c.

Functions in detail

syInitEvent

void syInitEvent(void)

Empties the event table: every slot gets no function, priority EVENT_PRIORITY_EMPTY and no flags.

References EventBuf, EventsInitialized, EventsRunning and Sint32.

Referenced by btDebugBattleRunMenu(), btRun(), fdEngineRun(), fdLuckyDiceRun(), fdLuckyWheelsRun(), fdMapScreenShow(), fdSpriteViewerRun(), fdSuperLuckyDiceRun(), gmMainRoutineRun(), mnCreditsRun(), mnEndingImageStart(), mnTitleIntroRun(), mnTitleShowCamelotLogo(), mnTitleShowPublisherLogo(), mnTitleShowTitleScreen() and syInit().

Definition at line 10 of file system_event.c.

syCopyEventWords

void syCopyEventWords(Uint32 *dest, Uint32 *src, Uint32 byteCount)

Unused: copies byteCount bytes a word at a time.

Definition at line 28 of file system_event.c.

sySortEvents

void sySortEvents(void)

Bubble-sorts the event table by priority, highest first, so each pass runs its events from the highest priority down; removed events (EVENT_PRIORITY_REMOVED) rise to the front.

References EventBuf, memcpy() and Sint32.

Referenced by sySetEvent().

Definition at line 39 of file system_event.c.

syFindEvent

Sint32 syFindEvent(EVENT_FUNC callback)

Unused: returns the table index of the event running callback, or -1.

References EventBuf, result and Sint32.

Referenced by fdTilesetAnimationStartAll(), scAnkohlRuinsStartGreatFaceSliding() and scAnkohlRuinsStartGreatFaceSlidingUpClose().

Definition at line 70 of file system_event.c.

sySetEvent

Sint32 sySetEvent(EVENT_FUNC callback, Sint32 priority)

Adds an event running callback with priority priority, or gives an event already running it the new priority, and re-sorts the table. Returns its slot, or -1 when all EVENT_COUNT slots are taken.

References EventBuf, EventsRunning, Sint32 and sySortEvents().

Referenced by btBackgroundLoad(), btBackgroundSetMode(), btEffectOpenCanvasLayer(), btEffectRunAnnihilation(), btEffectRunAstralBlast(), btEffectRunAtalanta(), btEffectRunAzul(), btEffectRunBackstab(), btEffectRunBallLightning(), btEffectRunBladeRain(), btEffectRunBoreas(), btEffectRunBubbleColumn(), btEffectRunBurstShower(), btEffectRunCards(), btEffectRunCastingImpact(), btEffectRunCatastrophe(), btEffectRunCharon(), btEffectRunCloudSwirl(), btEffectRunCoatlicue(), btEffectRunCondemn(), btEffectRunCrescentSlash(), btEffectRunCriticalHit(), btEffectRunCruelRuin(), btEffectRunCrystal(), btEffectRunCurse(), btEffectRunDaedalus(), btEffectRunDeathPlunge(), btEffectRunDjinniSign(), btEffectRunDouse(), btEffectRunDrainMotes(), btEffectRunEclipse(), btEffectRunFire(), btEffectRunFlare(), btEffectRunFlora(), btEffectRunFlurry(), btEffectRunFroth(), btEffectRunGaspFamily(), btEffectRunGatheringLights(), btEffectRunGeode(), btEffectRunGeyser(), btEffectRunHaunt(), btEffectRunHaures(), btEffectRunHeavyBlow(), btEffectRunHelmSplitter(), btEffectRunIce(), btEffectRunJudgment(), btEffectRunJuggle(), btEffectRunKirin(), btEffectRunLeapingStrike(), btEffectRunLobbedShells() and 186 more.

Definition at line 95 of file system_event.c.

syEventNoOperationA

void syEventNoOperationA(void)

Unused: an empty function.

Definition at line 139 of file system_event.c.

syEventNoOperationB

void syEventNoOperationB(void)

Unused: an empty function.

Definition at line 144 of file system_event.c.

syCloseEvent

Sint32 syCloseEvent(EVENT_FUNC callback)

Removes the event running callback: clears its function and gives it priority EVENT_PRIORITY_REMOVED, which no pass matches. Returns its old index, or -1.

References EventBuf, result and Sint32.

Referenced by btEffectEndCanvasLayer(), btEffectEndElementStreaks(), btEffectRunAnnihilation(), btEffectRunAtalanta(), btEffectRunAttackSlash(), btEffectRunAzul(), btEffectRunBackgroundFadeIn(), btEffectRunBackstab(), btEffectRunBind(), btEffectRunBoreas(), btEffectRunBreaths(), btEffectRunBubbleColumn(), btEffectRunBurstShower(), btEffectRunCanvasBurst(), btEffectRunCards(), btEffectRunCastingImpact(), btEffectRunCharon(), btEffectRunCloudSwirl(), btEffectRunCoatlicue(), btEffectRunCondemn(), btEffectRunCool(), btEffectRunCriticalHit(), btEffectRunCybele(), btEffectRunDaedalus(), btEffectRunDaedalusStrike(), btEffectRunDjinnBeams(), btEffectRunDjinniCharge(), btEffectRunDjinniEntrance(), btEffectRunDjinniSign(), btEffectRunDouse(), btEffectRunDragonFire(), btEffectRunEclipse(), btEffectRunElementBurst(), btEffectRunElementPillar(), btEffectRunFire(), btEffectRunFirePuppet(), btEffectRunFlare(), btEffectRunFlashingStrike(), btEffectRunFlora(), btEffectRunFlurry(), btEffectRunFormChange(), btEffectRunFrost(), btEffectRunFroth(), btEffectRunFume(), btEffectRunGaia(), btEffectRunGaspFamily(), btEffectRunGatheringLights(), btEffectRunGeode(), btEffectRunGeyser(), btEffectRunHaunt() and 147 more.

Definition at line 151 of file system_event.c.

sySuspendEvent

Sint32 sySuspendEvent(EVENT_FUNC callback)

Suspends the event running callback, or every event when callback is null, by setting EVENT_SUSPENDED in its priority's high byte, which then matches neither pass. Returns the last slot suspended, or -1.

References EventBuf, result and Sint32.

Referenced by btRun(), fdActorSystemSuspendProjectionAndShowSprites(), fdBlankOverlaySuspend(), fdBlendScriptSuspend(), fdFadeOverlaySuspend(), fdScreenTransitionSuspendCallbacks(), fdTilesetAnimationSuspendAll(), fdWorldMapStartStillImage() and scApojiiIslandsPauseSeaColors().

Definition at line 178 of file system_event.c.

sySuspendOverlayEvents

Sint32 sySuspendOverlayEvents(void)

Suspends every event whose function is in an overlay (EVENT_IN_OVERLAY) unless its flags hold EVENT_FLAG_KEEP_RUNNING, as sySuspendEvent does.

References EventBuf, result and Sint32.

Referenced by mnSuspendFieldEvents().

Definition at line 205 of file system_event.c.

sySetEventFlags

Sint32 sySetEventFlags(EVENT_FUNC callback, Uint32 mask)

Stores mask as the flags of the event running callback (EVENT_FLAG_KEEP_RUNNING). Returns its slot, or -1.

References EventBuf, result and Sint32.

Referenced by scInit() and scLinkLobbyEnterBattle().

Definition at line 231 of file system_event.c.

syResumeEvent

Sint32 syResumeEvent(EVENT_FUNC callback)

Resumes the event running callback, or every event when callback is null, by clearing EVENT_SUSPENDED. Returns the last slot resumed, or -1.

References EventBuf, result and Sint32.

Referenced by fdActorSystemResumeProjectionAndHideLayers(), fdBlankOverlayResume(), fdBlendScriptResume(), fdFadeOverlayResume(), fdTilesetAnimationResumeAll(), fdWorldMapLoadAreaGraphics(), fdWorldMapLoadDefaultMetatilesAndUpdateBlock() and scApojiiIslandsResumeSeaColors().

Definition at line 256 of file system_event.c.

syResumeOverlayEvents

Sint32 syResumeOverlayEvents(void)

Resumes every event whose function is in an overlay, flagged or not. Returns the last index changed, or -1.

References EventBuf, result and Sint32.

Referenced by mnResumeFieldEvents().

Definition at line 280 of file system_event.c.

syExecuteEvent

void syExecuteEvent(Sint32 pass)

Runs one pass of the events: every event whose priority's high byte matches pass's (EVENT_PASS_VBLANK or EVENT_PASS_TICK), in table order.

References EventBuf, EventsInitialized and Sint32.

Referenced by sySynch().

Definition at line 304 of file system_event.c.

syCountEventsInPass

Sint32 syCountEventsInPass(Sint32 pass)

Returns how many events run in pass pass (EVENT_PASS_VBLANK or EVENT_PASS_TICK); before the event table is set up, the pass's high byte.

References EventBuf, EventsInitialized and Sint32.

Definition at line 340 of file system_event.c.

syRunPassBeforeTickEvents

void syRunPassBeforeTickEvents(Sint32 pass)

Runs pass pass's events in table order, up to the first event of the tick pass: the VBlank handler's pass, whose events sort before the tick's.

References EventBuf, EventsInitialized and Sint32.

Referenced by syVBlankHandler().

Definition at line 372 of file system_event.c.