Skip to Content
The Alchemy Project

src/field/field_player_control.c

Player control: the configured keys, and SC_PLAYER, the leader moved by the pad (fdActorUpdatePlayerControl). More…

Included by field.c.

Macros

NameDescription
#defineFIELD_SHORTCUT_ID_MASK 0x3fffA shortcut assignment's request, bits 13..0, and its kind above them.
#defineFIELD_SHORTCUT_KIND_SHIFT 14
#defineGROUND_EFFECTS_FOOTPRINTS_MASK 0x03MAP_STATE.groundEffects' footprints, its bits 1..0: whether the leader leaves them.
#defineFIELD_PROBE_RADIUS toFIXED(8)How far ahead of the leader the field map and the world map test the ground, 16.16 pixels.
#defineWORLD_MAP_PROBE_RADIUS toFIXED(8)
#defineFIELD_PUSH_REACH 4The leader pushes what lies this far ahead of him, in pixels, and a pushed actor first tests the way this far beyond it.
#defineFIELD_PUSHED_PROBE 10
#defineWADING_SPLASH_ANIMATION 1SPRITE_WADING_SPLASH's splash, a burst of water over 18 ticks (wading_splash.tsv; animation 0 is the same).
#defineWADING_SPLASH_INTERVAL_RUN 8Ticks between two splashes as the leader wades, and between two footprints, running and walking.
#defineWADING_SPLASH_INTERVAL_WALK 12
#defineFOOTPRINT_INTERVAL_RUN 12
#defineFOOTPRINT_INTERVAL_WALK 18
#definePROBE_CLEAR (check, actor, radius, heading, position)Sets position radius out from actor along heading and tests it with check (fdMapGridCheckCollision, fdWorldMapIsSailable and the like, 0 where the way is open); true when it is open.
#defineSIDE_PROBES_CLEAR (check, actor, radius, heading, probe)The four probes beside heading, FIELD_PROBE_ANGLE and 45 degrees to each side, made in probe: true when all four are open, so the actor moving along heading grazes nothing it passes.
#defineFIELD_WALK_SPEED toFIXED(1)The leader's speeds and accelerations, in pixels a tick as 16.16 fixed point, as The Broken Seal's; on the world map this game runs with twice the walk's acceleration.
#defineFIELD_RUN_SPEED (toFIXED(3) / 2)1.5, with a dash key held
#defineFIELD_ACCELERATION (toFIXED(1) / 4)a quarter pixel faster each tick
#defineFIELD_FAST_WALK_SPEED toFIXED(4)4, B held with FLAG_FAST_WALK
#defineFIELD_FAST_WALK_ACCELERATION toFIXED(1)
#defineWORLD_MAP_WALK_SPEED (toFIXED(1) / 2)half a pixel a tick
#defineWORLD_MAP_RUN_SPEED toFIXED(1)1, with a dash key held
#defineWORLD_MAP_RUN_ACCELERATION (toFIXED(1) / 2)
#defineWORLD_MAP_ACCELERATION (toFIXED(1) / 4)
#defineWORLD_MAP_YAW_STEP_MAX (TRIG_TURN / 128)The world map camera turns toward the pad's yaw by at most about 2.8 degrees a tick.

Enumerations

NameDescription
enumFIELD_SHORTCUT_KIND { FIELD_SHORTCUT_PSYNERGY, FIELD_SHORTCUT_ITEM }What a shortcut key's assignment requests, bits 15..14 (fdRequestShortcut), as The Broken Seal's.

Functions

NameDescription
static inline voidfdTurnToward (ACTOR *actor, Uint16 angle)Turns a blocked actor toward angle, the heading the pad asks for, by at most FIELD_BLOCKED_TURN_MAX.
Sint32fdActorUpdateWalkingControl (ACTOR *actor)SC_WALK (LEADER_MOVEMENT_WALKING): the leader's control at one pace, a pixel a tick whatever the keys.
Sint32fdRequestShortcut (Uint32 assignment)Passes on a shortcut key's assignment, as The Broken Seal's: bits 15..14 say whether the request is a field Psynergy or an item, bits 13..0 which.
Sint32fdCheckConfiguredKeys (void)Checks the keys the player has configured: the menu, examine and start keys set their request and return 1, the two shortcut keys pass on their assignment (fdRequestShortcut).
Sint32fdCheckSpheresOverlap (FIXED *posA, Sint32 radiusA, FIXED *posB, Sint32 radiusB)Returns 0 when two spheres overlap: at posA and posB (16.16 pixels) with radii radiusA and radiusB (pixels); -1 otherwise.
voidfdActorSpawnWaterSplash (ACTOR *actor, Sint32 wading)A splash at the feet of an actor wading through water (MAP_METATILE_WATER): SPRITE_WADING_SPLASH started on its splash script, its sound every other step; wading is the map's kind of wading (GROUND_EFFECTS_WADING).
Sint32fdActorUpdatePlayerControl (ACTOR *actor)SC_PLAYER: moves the player on the field by the direction pad: walking or running, sliding around walls, pushing movable actors, turning, playing the matching animation and leaving footprints.

Description

Player control: the configured keys, and SC_PLAYER, the leader moved by the pad (fdActorUpdatePlayerControl). Part of field.c. PerWork.data is the keys held and PerWork.push the keys pressed this tick, SGL's PerDigital names.

Macros in detail

FIELD_SHORTCUT_ID_MASK

#define FIELD_SHORTCUT_ID_MASK 0x3fff

A shortcut assignment's request, bits 13..0, and its kind above them.

Referenced by fdRequestShortcut().

Definition at line 17 of file field_player_control.c.

FIELD_SHORTCUT_KIND_SHIFT

#define FIELD_SHORTCUT_KIND_SHIFT 14

Referenced by fdRequestShortcut().

Definition at line 18 of file field_player_control.c.

GROUND_EFFECTS_FOOTPRINTS_MASK

#define GROUND_EFFECTS_FOOTPRINTS_MASK 0x03

MAP_STATE.groundEffects' footprints, its bits 1..0: whether the leader leaves them.

Referenced by fdActorUpdatePlayerControl().

Definition at line 21 of file field_player_control.c.

FIELD_PROBE_RADIUS

#define FIELD_PROBE_RADIUS toFIXED(8)

How far ahead of the leader the field map and the world map test the ground, 16.16 pixels.

Referenced by fdActorCrossRope(), fdActorCrossTightrope(), fdActorMoveAsSand(), fdActorMoveByKeys(), fdActorUpdatePlayerControl() and fdActorUpdateWalkingControl().

Definition at line 25 of file field_player_control.c.

WORLD_MAP_PROBE_RADIUS

#define WORLD_MAP_PROBE_RADIUS toFIXED(8)

Referenced by fdActorFlyOnWorldMap(), fdActorMoveAsSandOnWorldMap(), fdActorMoveOnWorldMap() and fdActorSailOnWorldMap().

Definition at line 26 of file field_player_control.c.

FIELD_PUSH_REACH

#define FIELD_PUSH_REACH 4

The leader pushes what lies this far ahead of him, in pixels, and a pushed actor first tests the way this far beyond it.

Referenced by fdActorUpdatePlayerControl() and fdActorUpdateWalkingControl().

Definition at line 29 of file field_player_control.c.

FIELD_PUSHED_PROBE

#define FIELD_PUSHED_PROBE 10

Referenced by fdActorUpdatePlayerControl() and fdActorUpdateWalkingControl().

Definition at line 30 of file field_player_control.c.

WADING_SPLASH_ANIMATION

#define WADING_SPLASH_ANIMATION 1

SPRITE_WADING_SPLASH's splash, a burst of water over 18 ticks (wading_splash.tsv; animation 0 is the same).

Referenced by fdActorSpawnWaterSplash().

Definition at line 34 of file field_player_control.c.

WADING_SPLASH_INTERVAL_RUN

#define WADING_SPLASH_INTERVAL_RUN 8

Ticks between two splashes as the leader wades, and between two footprints, running and walking.

Referenced by fdActorUpdatePlayerControl().

Definition at line 37 of file field_player_control.c.

WADING_SPLASH_INTERVAL_WALK

#define WADING_SPLASH_INTERVAL_WALK 12

Referenced by fdActorUpdatePlayerControl().

Definition at line 38 of file field_player_control.c.

FOOTPRINT_INTERVAL_RUN

#define FOOTPRINT_INTERVAL_RUN 12

Referenced by fdActorUpdatePlayerControl().

Definition at line 39 of file field_player_control.c.

FOOTPRINT_INTERVAL_WALK

#define FOOTPRINT_INTERVAL_WALK 18

Referenced by fdActorUpdatePlayerControl().

Definition at line 40 of file field_player_control.c.

PROBE_CLEAR

#define PROBE_CLEAR(check, actor, radius, heading, position)

Sets position radius out from actor along heading and tests it with check (fdMapGridCheckCollision, fdWorldMapIsSailable and the like, 0 where the way is open); true when it is open.

Referenced by fdActorFlyOnWorldMap(), fdActorMoveAsSand(), fdActorSailOnMap(), fdActorSailOnWorldMap(), fdActorUpdatePlayerControl() and fdActorUpdateWalkingControl().

Definition at line 45 of file field_player_control.c.

SIDE_PROBES_CLEAR

#define SIDE_PROBES_CLEAR(check, actor, radius, heading, probe)

The four probes beside heading, FIELD_PROBE_ANGLE and 45 degrees to each side, made in probe: true when all four are open, so the actor moving along heading grazes nothing it passes.

Referenced by fdActorFlyOnWorldMap(), fdActorMoveAsSand(), fdActorSailOnMap(), fdActorSailOnWorldMap(), fdActorUpdatePlayerControl() and fdActorUpdateWalkingControl().

Definition at line 53 of file field_player_control.c.

FIELD_WALK_SPEED

#define FIELD_WALK_SPEED toFIXED(1)

The leader's speeds and accelerations, in pixels a tick as 16.16 fixed point, as The Broken Seal's; on the world map this game runs with twice the walk's acceleration.

1 pixel a tick

Referenced by fdActorSailOnMap() and fdActorUpdatePlayerControl().

Definition at line 63 of file field_player_control.c.

FIELD_RUN_SPEED

#define FIELD_RUN_SPEED (toFIXED(3) / 2)

1.5, with a dash key held

Referenced by fdActorUpdatePlayerControl().

Definition at line 64 of file field_player_control.c.

FIELD_ACCELERATION

#define FIELD_ACCELERATION (toFIXED(1) / 4)

a quarter pixel faster each tick

Referenced by fdActorSailOnMap() and fdActorUpdatePlayerControl().

Definition at line 65 of file field_player_control.c.

FIELD_FAST_WALK_SPEED

#define FIELD_FAST_WALK_SPEED toFIXED(4)

4, B held with FLAG_FAST_WALK

Referenced by fdActorSailOnMap().

Definition at line 66 of file field_player_control.c.

FIELD_FAST_WALK_ACCELERATION

#define FIELD_FAST_WALK_ACCELERATION toFIXED(1)

Referenced by fdActorSailOnMap().

Definition at line 67 of file field_player_control.c.

WORLD_MAP_WALK_SPEED

#define WORLD_MAP_WALK_SPEED (toFIXED(1) / 2)

half a pixel a tick

Referenced by fdActorMoveOnWorldMap().

Definition at line 68 of file field_player_control.c.

WORLD_MAP_RUN_SPEED

#define WORLD_MAP_RUN_SPEED toFIXED(1)

1, with a dash key held

Referenced by fdActorMoveOnWorldMap().

Definition at line 69 of file field_player_control.c.

WORLD_MAP_RUN_ACCELERATION

#define WORLD_MAP_RUN_ACCELERATION (toFIXED(1) / 2)

Referenced by fdActorMoveOnWorldMap().

Definition at line 70 of file field_player_control.c.

WORLD_MAP_ACCELERATION

#define WORLD_MAP_ACCELERATION (toFIXED(1) / 4)

Referenced by fdActorMoveOnWorldMap().

Definition at line 71 of file field_player_control.c.

WORLD_MAP_YAW_STEP_MAX

#define WORLD_MAP_YAW_STEP_MAX (TRIG_TURN / 128)

The world map camera turns toward the pad's yaw by at most about 2.8 degrees a tick.

Referenced by fdActorMoveAsSandOnWorldMap(), fdActorMoveOnWorldMap() and fdActorSailOnWorldMap().

Definition at line 75 of file field_player_control.c.

Enumerations in detail

FIELD_SHORTCUT_KIND

enum FIELD_SHORTCUT_KIND

What a shortcut key's assignment requests, bits 15..14 (fdRequestShortcut), as The Broken Seal's.

EnumeratorValueDescription
FIELD_SHORTCUT_PSYNERGY0FIELD_STATE.psynergy, an ability
FIELD_SHORTCUT_ITEM1FIELD_STATE.item

Definition at line 10 of file field_player_control.c.

Functions in detail

fdTurnToward

static inline void fdTurnToward(ACTOR *actor, Uint16 angle)

Turns a blocked actor toward angle, the heading the pad asks for, by at most FIELD_BLOCKED_TURN_MAX.

Referenced by fdActorCrossTightrope(), fdActorMoveAsSand(), fdActorMoveAsSandOnWorldMap(), fdActorMoveOnWorldMap(), fdActorUpdatePlayerControl() and fdActorUpdateWalkingControl().

Definition at line 79 of file field_player_control.c.

fdActorUpdateWalkingControl

Sint32 fdActorUpdateWalkingControl(ACTOR *actor)

SC_WALK (LEADER_MOVEMENT_WALKING): the leader's control at one pace, a pixel a tick whatever the keys. Unused: nothing sets LEADER_MOVEMENT_WALKING. It is SC_PLAYER (fdActorUpdatePlayerControl) without the run, the wading, the footprints or the steered velocity, a script command of its own, so both stay.

References DebugMode, fdActorScriptCheckOverlap(), fdActorSelectAnimation(), fdActorSetMoveTarget(), fdCheckConfiguredKeys(), fdCheckSpheresOverlap(), fdMapGridCheckCollision(), fdTurnToward(), gmUnitGet(), MainRoutineStateWork, PerWork, Sint32, syAtan(), syVectorAddPolarOffset() and WorldMapKeyHeadings.

Referenced by ActorScriptCommandTable.

Definition at line 95 of file field_player_control.c.

fdRequestShortcut

Sint32 fdRequestShortcut(Uint32 assignment)

Passes on a shortcut key's assignment, as The Broken Seal's: bits 15..14 say whether the request is a field Psynergy or an item, bits 13..0 which. On the world map R and L raise the map screen and the zoom instead, and while FLAG_MENUS_RAISE_CUE is set the scene's raised cue. Returns the request.

References PerWork, Sint32 and syGameFlagGet().

Referenced by fdCheckConfiguredKeys().

Definition at line 351 of file field_player_control.c.

fdCheckConfiguredKeys

Sint32 fdCheckConfiguredKeys(void)

Checks the keys the player has configured: the menu, examine and start keys set their request and return 1, the two shortcut keys pass on their assignment (fdRequestShortcut). While the Ring is out, any of the five asks for the Ring again (ABILITY_MAGNET, packed), which ends it. Returns 0 when none is pressed.

References fdRequestShortcut(), MainRoutineStateWork, PerWork, result and Sint32.

Referenced by fdActorMoveOnWorldMap(), fdActorSailOnMap(), fdActorSailOnWorldMap(), fdActorScriptCheckKeys(), fdActorUpdatePlayerControl() and fdActorUpdateWalkingControl().

Definition at line 384 of file field_player_control.c.

fdCheckSpheresOverlap

Sint32 fdCheckSpheresOverlap(FIXED *posA, Sint32 radiusA, FIXED *posB, Sint32 radiusB)

Returns 0 when two spheres overlap: at posA and posB (16.16 pixels) with radii radiusA and radiusB (pixels); -1 otherwise.

References Sint32.

Referenced by fdActorFlyOnWorldMap(), fdActorSailOnMap(), fdActorScriptCheckOverlap(), fdActorScriptFindOverlappingActor(), fdActorUpdateHoverControl(), fdActorUpdatePlayerControl(), fdActorUpdateWalkingControl() and scScriptCheckSpheresOverlap().

Definition at line 435 of file field_player_control.c.

fdActorSpawnWaterSplash

void fdActorSpawnWaterSplash(ACTOR *actor, Sint32 wading)

A splash at the feet of an actor wading through water (MAP_METATILE_WATER): SPRITE_WADING_SPLASH started on its splash script, its sound every other step; wading is the map's kind of wading (GROUND_EFFECTS_WADING). In Taopo Swamp's mud the splash is drawn in the mud's colour, at half speed.

References ActorSplashScript, fdActorCreate(), fdActorStartScript(), fdSpriteSetAnimationColorModes(), fdSpriteSetAnimationSpeed(), fdSpriteStartAnimation(), Sint32 and sySoundPlayStub().

Referenced by fdActorUpdatePlayerControl().

Definition at line 460 of file field_player_control.c.

fdActorUpdatePlayerControl

Sint32 fdActorUpdatePlayerControl(ACTOR *actor)

SC_PLAYER: moves the player on the field by the direction pad: walking or running, sliding around walls, pushing movable actors, turning, playing the matching animation and leaving footprints.

References ActorFootprintScript, DebugMode, fdActorCreate(), fdActorScriptCheckOverlap(), fdActorSelectAnimation(), fdActorSetMoveTarget(), fdActorSpawnWaterSplash(), fdActorStartScript(), fdCheckConfiguredKeys(), fdCheckSpheresOverlap(), fdMapGridCheckCollision(), fdSpriteStartAnimation(), fdTurnToward(), gmUnitGet(), MainRoutineStateWork, MapGridMetatileBuffer, PerWork, Sint32, syAtan(), sySquartFX(), syVectorAddPolarOffset() and WorldMapKeyHeadings.

Referenced by ActorScriptCommandTable.

Definition at line 496 of file field_player_control.c.