Skip to Content
The Alchemy Project

src/field/field_psynergy_ring.c

The Ring, the field Psynergy of the unused ability "Ma????" (named here for the ring of light it draws): its event, its burst of sparkles, and moving the view (opening the whole map to it, swinging it and giving the bounds back). More…

Included by field_psynergy.c.

Structures

NameDescription
structRING_STATEThe Ring's state (heap slot battleEffect): the sparkle picture, the 64 sparkles that rise round the caster as the ring is drawn and burst when it ends, the motes that circle it after, and what the per-tick event shows.
structMAP_BOUNDSA map's view bounds, in 8-pixel units.

Macros

NameDescription
#defineRING_SPARK_COUNT 64The sparkles that rise round the caster as the Ring is drawn.
#defineRING_MOTE_COUNT 32The motes the Ring places, and the first 16 that twinkle on it.
#defineRING_CIRCLING_MOTES 16
#defineRING_TICKS 600The ticks the Ring lasts once it is drawn, or cast again.
#defineRING_PALETTE 15The OBJ and BG palette the Ring's colours cycle in.
#defineRING_RADIUS 52The ring's inner radius in pixels: its four bands run out to 3 more.
#defineRING_BAND_COLOR (n) (RING_PALETTE * PALETTE_COLORS + (n) * 4 + 3)The colour of the ring's band n, 0 innermost: every fourth colour of the cycling palette, so the bands shimmer one after another.
#defineRING_ARC_STEP (TRIG_TURN / 64)The arc the sparkles sweep, and the ring is drawn over, each tick: half a turn in 32 ticks, the picture's lower half being its upper half turned round (RingPictureTiles).
#defineVIEW_EDGE_MARGIN 12How far the view stays from the edge it is beside, in pixels.
#defineSWING_SINE (angle) (sySin(angle) >= 0 ? sySin(angle) : -sySin(angle))The swing's size at an angle: its sine without the sign.

Enumerations

NameDescription
enumRING_DRAW_PHASE { RING_SPARKS_CIRCLE, RING_DRAWN, RING_SPARKS_DIE_OUT }The stages of drawing the Ring, 32, 32 and 16 ticks.

Functions

NameDescription
voidfdPsynergyUpdateRing (void)Event of the Ring: its motes and colours each tick.
voidfdPsynergyRing (void)The Ring: a ring of light is drawn round the caster among rising sparkles, then motes twinkle on it as it sways.
voidfdPsynergyEndRing (void)Ends the Ring, if one is up: the ring gives way to a burst of 64 sparkles from round the leader, four more setting off each tick, that fly out and fall for 40 ticks, and the window graphics come back to BG0.
voidfdMapGetCameraBoundsStub (Sint32 map, MAP_BOUNDS *bounds)Writes a map's view bounds from its header, in 8-pixel units.
voidfdViewMoveStart (Sint32 direction)Opens the whole map to the view: keeps the view centre's position and the map's view bounds for fdViewMoveEnd to restore, notes which edges the view is beside, and sets the bounds to the map's own.
voidfdViewMoveSwing (Sint32 direction, Sint32 phase, FIXED amplitude)Swings the view centre away from where fdViewMoveStart found it, along the asked directions, by amplitude times the sine of the phase.
voidfdViewMoveEnd (void)Ends a view move: gives the map back the view bounds fdViewMoveStart kept and lets the view follow the caster again.
voidfdViewMoveSaveNearbySprites (void)Gathers up to eight actors near enough to the caster to shake (fdMeasurePsynergyReach), with each one's sprite rotation, for Tremor's sway to rock.
voidfdViewMoveRestoreNearbySprites (void)Gives each gathered actor's sprite its saved rotation back.

Description

The Ring, the field Psynergy of the unused ability "Ma????" (named here for the ring of light it draws): its event, its burst of sparkles, and moving the view (opening the whole map to it, swinging it and giving the bounds back). Part of field_psynergy.c.

Macros in detail

RING_SPARK_COUNT

#define RING_SPARK_COUNT 64

The sparkles that rise round the caster as the Ring is drawn.

Referenced by fdPsynergyEndRing() and fdPsynergyRing().

Definition at line 10 of file field_psynergy_ring.c.

RING_MOTE_COUNT

#define RING_MOTE_COUNT 32

The motes the Ring places, and the first 16 that twinkle on it.

Referenced by fdPsynergyRing().

Definition at line 12 of file field_psynergy_ring.c.

RING_CIRCLING_MOTES

#define RING_CIRCLING_MOTES 16

Referenced by fdPsynergyUpdateRing().

Definition at line 13 of file field_psynergy_ring.c.

RING_TICKS

#define RING_TICKS 600

The ticks the Ring lasts once it is drawn, or cast again.

Referenced by fdPsynergyRing().

Definition at line 15 of file field_psynergy_ring.c.

RING_PALETTE

#define RING_PALETTE 15

The OBJ and BG palette the Ring's colours cycle in.

Referenced by fdPsynergyRing() and fdPsynergyUpdateRing().

Definition at line 17 of file field_psynergy_ring.c.

RING_RADIUS

#define RING_RADIUS 52

The ring's inner radius in pixels: its four bands run out to 3 more.

Referenced by fdPsynergyEndRing(), fdPsynergyRing() and fdPsynergyUpdateRing().

Definition at line 19 of file field_psynergy_ring.c.

RING_BAND_COLOR

#define RING_BAND_COLOR(n) (RING_PALETTE * PALETTE_COLORS + (n) * 4 + 3)

The colour of the ring's band n, 0 innermost: every fourth colour of the cycling palette, so the bands shimmer one after another.

Referenced by fdPsynergyRing().

Definition at line 22 of file field_psynergy_ring.c.

RING_ARC_STEP

#define RING_ARC_STEP (TRIG_TURN / 64)

The arc the sparkles sweep, and the ring is drawn over, each tick: half a turn in 32 ticks, the picture's lower half being its upper half turned round (RingPictureTiles).

Referenced by fdPsynergyRing().

Definition at line 26 of file field_psynergy_ring.c.

VIEW_EDGE_MARGIN

#define VIEW_EDGE_MARGIN 12

How far the view stays from the edge it is beside, in pixels.

Referenced by fdViewMoveStart().

Definition at line 467 of file field_psynergy_ring.c.

SWING_SINE

#define SWING_SINE(angle) (sySin(angle) >= 0 ? sySin(angle) : -sySin(angle))

The swing's size at an angle: its sine without the sign.

Referenced by fdViewMoveSwing().

Definition at line 568 of file field_psynergy_ring.c.

Enumerations in detail

RING_DRAW_PHASE

enum RING_DRAW_PHASE

The stages of drawing the Ring, 32, 32 and 16 ticks.

EnumeratorValueDescription
RING_SPARKS_CIRCLE0The sparkles rise from two points sweeping half a turn round the caster.
RING_DRAWN1They sweep the half turn again, and the ring is drawn behind them.
RING_SPARKS_DIE_OUT2no new sparkles start; the last ones rise away

Definition at line 29 of file field_psynergy_ring.c.

Functions in detail

fdPsynergyUpdateRing

void fdPsynergyUpdateRing(void)

Event of the Ring: its motes and colours each tick.

References BgScrollWork, fdActorGetById(), fdBgMapDrawClipped16x16(), fdCameraWorldToScreen(), fdEffectSpriteDrawAtWorldPos(), MainRoutineStateWork, Sint32, syRandom(), sySin() and syVectorAddPolarOffset().

Referenced by fdPsynergyEndRing() and fdPsynergyRing().

Definition at line 69 of file field_psynergy_ring.c.

fdPsynergyRing

void fdPsynergyRing(void)

The Ring: a ring of light is drawn round the caster among rising sparkles, then motes twinkle on it as it sways. fdPsynergyUpdateRing keeps it for RING_TICKS ticks, then casts it again without PP (ABILITY_MAGNET | ACT_PACKED), and that cast ends it (fdPsynergyEndRing). Cast again by the player while it lasts, it only starts its ticks again.

References BgScrollWork, CpuLoadDisplayEnabled, fdBattleEffectStartCanvasSprite(), fdCameraWorldToScreen(), fdCanvasPlotPolarPixel(), fdEffectSpriteDrawAtWorldPos(), fdEffectSpriteInit(), fdPsynergyFadeFromCastColor(), fdPsynergyFadeToCastColor(), fdPsynergyUpdateRing(), Sint32, syDecompressTaggedLZ(), syDMAXCopy(), syHeapSlotAllocateEWRAM(), syHeapSlotRelease(), syRandom(), syResourceGetTableEntry(), sySetEvent(), sySynch(), syVectorAddPolarOffset(), syVRAMCacheFindFreeEntry(), syVRAMCacheFreeEntry() and syVRAMCacheLoad().

Referenced by fdPsynergyDispatch() and fdPsynergyRun().

Definition at line 168 of file field_psynergy_ring.c.

fdPsynergyEndRing

void fdPsynergyEndRing(void)

Ends the Ring, if one is up: the ring gives way to a burst of 64 sparkles from round the leader, four more setting off each tick, that fly out and fall for 40 ticks, and the window graphics come back to BG0.

References BgScrollWork, CpuLoadDisplayEnabled, fdActorGetById(), fdAdvanceWithGravity3D(), fdBattleEffectEndCanvasSprite(), fdEffectSpriteDrawAtWorldPos(), fdEffectSpriteInit(), fdPsynergyUpdateRing(), MainRoutineStateWork, Sint32, syCloseEvent(), syDecompressTaggedLZ(), syHeapSlotRelease(), syRandom(), syResourceGetTableEntry(), sySoundPlayStub(), sySynch(), syVectorAddPolarOffset(), syVRAMCacheFindFreeEntry(), syVRAMCacheFreeEntry(), syVRAMCacheLoad() and syWindowLoadGraphics().

Referenced by fdPsynergyRunEnd().

Definition at line 383 of file field_psynergy_ring.c.

fdMapGetCameraBoundsStub

void fdMapGetCameraBoundsStub(Sint32 map, MAP_BOUNDS *bounds)

Writes a map's view bounds from its header, in 8-pixel units.

Referenced by fdViewMoveStart().

Definition at line 479 of file field_psynergy_ring.c.

fdViewMoveStart

void fdViewMoveStart(Sint32 direction)

Opens the whole map to the view: keeps the view centre's position and the map's view bounds for fdViewMoveEnd to restore, notes which edges the view is beside, and sets the bounds to the map's own. Where the view may not move (on the World Map, and outside the Japanese release on a map whose view keeps to its camera boxes), it shakes the screen along the asked direction instead.

References fdMapGetCameraBoundsStub(), fdMapGridSetScreenShakeStub(), MainRoutineStateWork and Sint32.

Referenced by fdPsynergyGrind(), fdPsynergyGrindOnTarget(), fdPsynergyTremor() and fdPsynergyTremorOnTarget().

Definition at line 486 of file field_psynergy_ring.c.

fdViewMoveSwing

void fdViewMoveSwing(Sint32 direction, Sint32 phase, FIXED amplitude)

Swings the view centre away from where fdViewMoveStart found it, along the asked directions, by amplitude times the sine of the phase. The swing goes into the room: away from the edge the view is beside, or forward when it is beside neither. Where fdViewMoveStart shook the screen instead, nothing moves.

References Sint32.

Referenced by fdPsynergyGrind(), fdPsynergyGrindOnTarget(), fdPsynergyTremor() and fdPsynergyTremorOnTarget().

Definition at line 575 of file field_psynergy_ring.c.

fdViewMoveEnd

void fdViewMoveEnd(void)

Ends a view move: gives the map back the view bounds fdViewMoveStart kept and lets the view follow the caster again. Where fdViewMoveStart shook the screen instead, it only stops the shake.

References fdCameraFollowActor() and fdMapGridSetScreenShakeStub().

Referenced by fdPsynergyGrind(), fdPsynergyGrindOnTarget(), fdPsynergyTremor() and fdPsynergyTremorOnTarget().

Definition at line 634 of file field_psynergy_ring.c.

fdViewMoveSaveNearbySprites

void fdViewMoveSaveNearbySprites(void)

Gathers up to eight actors near enough to the caster to shake (fdMeasurePsynergyReach), with each one's sprite rotation, for Tremor's sway to rock.

References fdMeasurePsynergyReach() and Sint32.

Referenced by fdPsynergyTremor() and fdPsynergyTremorOnTarget().

Definition at line 663 of file field_psynergy_ring.c.

fdViewMoveRestoreNearbySprites

void fdViewMoveRestoreNearbySprites(void)

Gives each gathered actor's sprite its saved rotation back.

References Sint32.

Referenced by fdPsynergyTremor() and fdPsynergyTremorOnTarget().

Definition at line 693 of file field_psynergy_ring.c.