Skip to Content
The Alchemy Project

src/field/field_psynergy_sand.c

Sand: the leader sinking into the ground and moving as sand, the grains it throws up, the event that ends it off sand, and the dust puff it ends with. More…

Included by field_psynergy.c.

Structures

NameDescription
structSAND_STATESand's state (heap slot HEAP_SLOT_BATTLE_EFFECT): the leader's picture and the copy it sinks into the ground, the grains of sand thrown up round it and the sprite the sinking leader is drawn with.
structPICTURE_SOURCEA sprite layer (SPR_ANIMATION) as fdPsynergyDecodePicture reads it: how its pictures are coded and the one shown.

Macros

NameDescription
#defineSAND_GRAIN_COUNT 64The grains of sand thrown up round the leader, and how many of them are drawn as it sinks and as it rises.
#defineSAND_SINK_GRAINS 33
#defineSAND_RISE_GRAINS 30
#defineSAND_PICTURE_SIZE 32The leader's picture, 32 pixels square; Sand takes only a leader drawn so.
#defineSAND_RISE_PHASE 92The phase the leader's sunk picture rises from, 1.5 less each tick.
#defineOAM_BELOW_SHAPE_OR_SIZE 63An OAM attribute's high byte: the bits below its top two, the shape in attribute 0 and the size in attribute 1, and the size bits of a sprite 32 pixels square.
#defineOAM_SIZE_32X32_BYTE (OBJ_SIZE_32X32 >> 24)
#defineBLOCKED_BY_ACTOR 2fdActorCheckBlocked's bit for another solid actor overlapping the actor.
#definePICTURE_FORMAT_TAGGED_LZ 1How a picture is stored.
#definePICTURE_FORMAT_COMPRESSED 3compressed, then run through the decoder

Typedefs

NameDescription
typedef void (*PICTURE_DECODER )(const void *source, void *destination, Sint32 mode);

Enumerations

NameDescription
enumSAND_END { SAND_GOES_ON, SAND_END_UPPER_LEVEL, SAND_END_OFF_SAND, SAND_ … }Why the Sand ends (fdPsynergyWatchSandGround).

Functions

NameDescription
Sint32fdMapGridIsClimbableMetatile (Sint32 x, Sint32 z, Sint32 layer)The ROM's callers here are compiled against this form, which returns an Sint32 where the definition returns a Uint8.
voidfdPsynergyWatchSandGround (void)Event of the Sand: ends it (sound ABILITY_SAND | ACT_PACKED) when the leader, not blocked by another actor, stands off sand or on a scene's upper level (MainRoutineStateWork.onUpperLevel), or while it climbs as sand it leaves a climbable metatile or faces one that is not.
voidfdPsynergyDecodePicture (PICTURE_SOURCE *src, void *buf, Sint32 size)Draws the current picture into a cleared buffer of the given size.
voidfdPictureSinkColumnsByWave (Uint8 *src, Uint8 *dest, Sint32 phase)fdPictureShiftColumnsByWave as the Sand sinks the leader into the ground: each column's pixels below a wave line move down by phase (1.3 pixels a step), those above it stay.
voidfdSandInitLeaderSprite (EFFECT_SPR *sprite, Sint32 tiles)Sets up the sprite the Sand draws the sinking leader as: the leader's depth, priority, scale (three quarters on the world map) and place.
voidfdSandDrawLeaderSprite (void *sprite)Draws fdSandInitLeaderSprite's sprite.
voidfdSandSpawnGrain (EFFECT_SPR *sprite, FIELD_PSYNERGY_PARTICLE *particle, Sint32 unused, Sint32 tiles, Sint32 high)One grain of sand thrown up round the leader as it sinks: 4 pixels out, or, cast off sand (high), 2 pixels up and 2 out and drifting more slowly; drawn small just in front of the leader.
voidfdGrowingParticleUpdate (EFFECT_SPR *sprite, FIELD_PSYNERGY_PARTICLE *particle, Sint32 unused, Sint32 tiles)Advances one particle by a tick.
voidfdActorSetFirstSpriteAnimationStub (ACTOR *actor, Sint32 index)Gives an actor's first sprite layer another sprite's animations.
voidfdSpriteSetFirstAnimationColorModeStub (void *animation, Sint32 value)Sets a sprite's first layer to a SPR_COL_MODE and redraws it.
voidfdPsynergyEndSand (void)Ends Sand: the leader rises out of the ground in a spray of grains and takes its own sprite back; on sand, the place's Sand script then runs.
voidfdPsynergySandOnTarget (void)Sand cast on a target: runs fdPsynergySand.
voidfdPsynergySand (void)Sand: the leader spins and sinks into the ground in a spray of grains, then moves on as a mound of sand (LEADER_MOVEMENT_SAND, or LEADER_MOVEMENT_WORLD_SAND on the World Map) until fdPsynergyWatchSandGround ends it.

Variables

NameDescription
extern const Uint8BattleEffectDecodePictureCode []The ARM picture decoder fdPsynergyDecodePicture copies into RAM.
extern const Uint8BattleEffectDecodePictureCopyEnd []The end of the part of the decoder that is copied.
extern Uint8BattleEffectDecodePictureBlockSize []The decoder with its tables and its state (ld_script.ld).

Description

Sand: the leader sinking into the ground and moving as sand, the grains it throws up, the event that ends it off sand, and the dust puff it ends with. Part of field_psynergy.c.

Macros in detail

SAND_GRAIN_COUNT

#define SAND_GRAIN_COUNT 64

The grains of sand thrown up round the leader, and how many of them are drawn as it sinks and as it rises.

Referenced by fdPsynergyEndSand() and fdPsynergySand().

Definition at line 7 of file field_psynergy_sand.c.

SAND_SINK_GRAINS

#define SAND_SINK_GRAINS 33

Referenced by fdPsynergySand().

Definition at line 8 of file field_psynergy_sand.c.

SAND_RISE_GRAINS

#define SAND_RISE_GRAINS 30

Referenced by fdPsynergyEndSand().

Definition at line 9 of file field_psynergy_sand.c.

SAND_PICTURE_SIZE

#define SAND_PICTURE_SIZE 32

The leader's picture, 32 pixels square; Sand takes only a leader drawn so.

Referenced by fdPictureSinkColumnsByWave(), fdPsynergyEndSand() and fdPsynergySand().

Definition at line 11 of file field_psynergy_sand.c.

SAND_RISE_PHASE

#define SAND_RISE_PHASE 92

The phase the leader's sunk picture rises from, 1.5 less each tick.

Referenced by fdPsynergyEndSand().

Definition at line 13 of file field_psynergy_sand.c.

OAM_BELOW_SHAPE_OR_SIZE

#define OAM_BELOW_SHAPE_OR_SIZE 63

An OAM attribute's high byte: the bits below its top two, the shape in attribute 0 and the size in attribute 1, and the size bits of a sprite 32 pixels square.

Referenced by fdPsynergyEndSand().

Definition at line 17 of file field_psynergy_sand.c.

OAM_SIZE_32X32_BYTE

#define OAM_SIZE_32X32_BYTE (OBJ_SIZE_32X32 >> 24)

Referenced by fdPsynergyEndSand().

Definition at line 18 of file field_psynergy_sand.c.

BLOCKED_BY_ACTOR

#define BLOCKED_BY_ACTOR 2

fdActorCheckBlocked's bit for another solid actor overlapping the actor.

Referenced by fdPsynergyWatchSandGround().

Definition at line 41 of file field_psynergy_sand.c.

PICTURE_FORMAT_TAGGED_LZ

#define PICTURE_FORMAT_TAGGED_LZ 1

How a picture is stored.

one tagged LZ stream

Referenced by fdPsynergyDecodePicture().

Definition at line 90 of file field_psynergy_sand.c.

PICTURE_FORMAT_COMPRESSED

#define PICTURE_FORMAT_COMPRESSED 3

compressed, then run through the decoder

Referenced by fdPsynergyDecodePicture().

Definition at line 91 of file field_psynergy_sand.c.

Typedefs in detail

PICTURE_DECODER

typedef void (*PICTURE_DECODER)(const void *source, void *destination, Sint32 mode);

Referenced by fdPsynergyDecodePicture().

Definition at line 106 of file field_psynergy_sand.c.

Enumerations in detail

SAND_END

enum SAND_END

Why the Sand ends (fdPsynergyWatchSandGround).

EnumeratorValueDescription
SAND_GOES_ON0
SAND_END_UPPER_LEVEL1the leader is on a scene's upper level
SAND_END_OFF_SAND2
SAND_END_OFF_CLIMB3climbing as sand, it left the climbable metatiles
SAND_END_FACING_WALL4climbing as sand, the metatile above is not one

Definition at line 44 of file field_psynergy_sand.c.

Functions in detail

fdPsynergyWatchSandGround

void fdPsynergyWatchSandGround(void)

Event of the Sand: ends it (sound ABILITY_SAND | ACT_PACKED) when the leader, not blocked by another actor, stands off sand or on a scene's upper level (MainRoutineStateWork.onUpperLevel), or while it climbs as sand it leaves a climbable metatile or faces one that is not.

References fdActorCheckBlocked(), fdActorLookup(), fdMapGridIsClimbableMetatile(), fdMapGridIsSandMetatile(), MainRoutineStateWork and Sint32.

Referenced by fdPsynergyEndSand() and fdPsynergySand().

Definition at line 58 of file field_psynergy_sand.c.

fdPsynergyDecodePicture

void fdPsynergyDecodePicture(PICTURE_SOURCE *src, void *buf, Sint32 size)

Draws the current picture into a cleared buffer of the given size. The ARM picture decoder runs from RAM: when no copy is loaded yet, this loads one for the call and releases it afterwards.

References BattleEffectDecodePictureBlockSize, BattleEffectDecodePictureCode, BattleEffectDecodePictureCopyEnd, Sint32, syDecompressSpritePicture(), syDecompressTaggedLZ(), syDMAXCopy(), syHeapSlotAllocate() and syHeapSlotRelease().

Referenced by fdPsynergyEndSand(), fdPsynergyGrindOnTarget(), fdPsynergySand() and fdPsynergyTremorOnTarget().

Definition at line 121 of file field_psynergy_sand.c.

fdPictureSinkColumnsByWave

void fdPictureSinkColumnsByWave(Uint8 *src, Uint8 *dest, Sint32 phase)

fdPictureShiftColumnsByWave as the Sand sinks the leader into the ground: each column's pixels below a wave line move down by phase (1.3 pixels a step), those above it stay.

References Sint32, sySin() and syWordsClear().

Referenced by fdPsynergyEndSand() and fdPsynergySand().

Definition at line 169 of file field_psynergy_sand.c.

fdSandInitLeaderSprite

void fdSandInitLeaderSprite(EFFECT_SPR *sprite, Sint32 tiles)

Sets up the sprite the Sand draws the sinking leader as: the leader's depth, priority, scale (three quarters on the world map) and place.

References fdActorGetSpriteDepth(), fdActorGetSpritePriority(), fdCameraWorldToScreen(), fdEffectSpriteInit() and Sint32.

Referenced by fdPsynergyEndSand() and fdPsynergySand().

Definition at line 202 of file field_psynergy_sand.c.

fdSandDrawLeaderSprite

void fdSandDrawLeaderSprite(void *sprite)

Draws fdSandInitLeaderSprite's sprite.

References fdEffectSpriteDraw().

Referenced by fdPsynergyEndSand() and fdPsynergySand().

Definition at line 232 of file field_psynergy_sand.c.

fdSandSpawnGrain

void fdSandSpawnGrain(EFFECT_SPR *sprite, FIELD_PSYNERGY_PARTICLE *particle, Sint32 unused, Sint32 tiles, Sint32 high)

One grain of sand thrown up round the leader as it sinks: 4 pixels out, or, cast off sand (high), 2 pixels up and 2 out and drifting more slowly; drawn small just in front of the leader.

References fdActorGetSpriteDepth(), fdActorGetSpritePriority(), fdEffectSpriteInit(), Sint32, syRandom() and syVectorAddPolarOffset().

Referenced by fdPsynergyEndSand() and fdPsynergySand().

Definition at line 240 of file field_psynergy_sand.c.

fdGrowingParticleUpdate

void fdGrowingParticleUpdate(EFFECT_SPR *sprite, FIELD_PSYNERGY_PARTICLE *particle, Sint32 unused, Sint32 tiles)

Advances one particle by a tick. For its first 32 ticks its sprite steps through eight pictures of eight tiles from tiles, four ticks each, grows by a tenth of its size a tick to full size, is placed on screen at the particle's position and drawn, and the particle moves on; after that only its age counts on. Reached from fdPsynergyEndSand and fdPsynergySand.

References fdAdvanceWithGravity2D(), fdCameraWorldToScreen(), fdEffectSpriteDraw() and Sint32.

Referenced by fdPsynergyEndSand() and fdPsynergySand().

Definition at line 287 of file field_psynergy_sand.c.

fdActorSetFirstSpriteAnimationStub

void fdActorSetFirstSpriteAnimationStub(ACTOR *actor, Sint32 index)

Gives an actor's first sprite layer another sprite's animations.

Referenced by fdPsynergyEndSand() and fdPsynergySand().

Definition at line 321 of file field_psynergy_sand.c.

fdSpriteSetFirstAnimationColorModeStub

void fdSpriteSetFirstAnimationColorModeStub(void *animation, Sint32 value)

Sets a sprite's first layer to a SPR_COL_MODE and redraws it.

Referenced by fdPsynergyEndSand() and fdPsynergySand().

Definition at line 323 of file field_psynergy_sand.c.

fdPsynergyEndSand

void fdPsynergyEndSand(void)

Ends Sand: the leader rises out of the ground in a spray of grains and takes its own sprite back; on sand, the place's Sand script then runs.

References fdActorGetById(), fdActorSelectAnimationStub(), fdActorSetFirstSpriteAnimationStub(), fdActorSetOthersPaused(), fdActorSetPosAndResetMotionStub(), fdActorSetSpriteFlagsStub(), fdCameraFollowActor(), fdCameraMoveWithinMapBounds(), fdFindPsynergyCue(), fdGrowingParticleUpdate(), fdPictureSinkColumnsByWave(), fdPsynergyDecodePicture(), fdPsynergyMarkWorldMapTilesUsed(), fdPsynergyWatchSandGround(), fdRunPsynergyScript(), fdSandDrawLeaderSprite(), fdSandInitLeaderSprite(), fdSandSpawnGrain(), fdSelectPsynergyTarget(), fdSpriteSetFirstAnimationColorModeStub(), MainRoutineStateWork, Sint32, syCloseEvent(), syDecompressTaggedLZ(), syHeapSlotAllocate(), syHeapSlotRelease(), syResourceGetTableEntry(), sySoundPlayStub(), sySynch(), syVRAMCacheFindFreeEntry(), syVRAMCacheFreeEntry() and syVRAMCacheLoad().

Referenced by fdPsynergyRunEnd() and fdPsynergySand().

Definition at line 327 of file field_psynergy_sand.c.

fdPsynergySandOnTarget

void fdPsynergySandOnTarget(void)

Sand cast on a target: runs fdPsynergySand.

References fdPsynergySand().

Referenced by fdPsynergyDispatch().

Definition at line 459 of file field_psynergy_sand.c.

fdPsynergySand

void fdPsynergySand(void)

Sand: the leader spins and sinks into the ground in a spray of grains, then moves on as a mound of sand (LEADER_MOVEMENT_SAND, or LEADER_MOVEMENT_WORLD_SAND on the World Map) until fdPsynergyWatchSandGround ends it. Off sand it rises again at once; a leader whose sprite is not 32 by 32 pixels does nothing.

References fdActorGetById(), fdActorSelectAnimationStub(), fdActorSetFirstSpriteAnimationStub(), fdActorSetOthersPaused(), fdActorSetPosAndResetMotionStub(), fdActorSetSpriteFlagsStub(), fdBattleEffectSetObjectUpdateMode(), fdCameraFollowActor(), fdCameraMoveWithinMapBounds(), fdGrowingParticleUpdate(), fdMapGridIsSandMetatile(), fdPictureSinkColumnsByWave(), fdPsynergyDecodePicture(), fdPsynergyEndSand(), fdPsynergyFadeFromCastColor(), fdPsynergyFadeToCastColor(), fdPsynergyMarkWorldMapTilesUsed(), fdPsynergyWatchSandGround(), fdSandDrawLeaderSprite(), fdSandInitLeaderSprite(), fdSandSpawnGrain(), fdSpriteSetFirstAnimationColorModeStub(), MainRoutineStateWork, Sint32, syDecompressTaggedLZ(), syHeapSlotAllocate(), syHeapSlotRelease(), syResourceGetTableEntry(), sySetEvent(), sySoundPlayStub(), sySynch(), syVRAMCacheFindFreeEntry(), syVRAMCacheFreeEntry() and syVRAMCacheLoad().

Referenced by fdPsynergyRun() and fdPsynergySandOnTarget().

Definition at line 469 of file field_psynergy_sand.c.

Variables in detail

BattleEffectDecodePictureCode

extern const Uint8 BattleEffectDecodePictureCode[]

The ARM picture decoder fdPsynergyDecodePicture copies into RAM.

Referenced by fdPsynergyDecodePicture().

Definition at line 111 of file field_psynergy_sand.c.

BattleEffectDecodePictureCopyEnd

extern const Uint8 BattleEffectDecodePictureCopyEnd[]

The end of the part of the decoder that is copied.

Referenced by fdPsynergyDecodePicture().

Definition at line 113 of file field_psynergy_sand.c.

BattleEffectDecodePictureBlockSize

extern Uint8 BattleEffectDecodePictureBlockSize[]

The decoder with its tables and its state (ld_script.ld). The block is larger than the copy, which stops before the state.

Referenced by fdPsynergyDecodePicture().

Definition at line 116 of file field_psynergy_sand.c.