src/field/field_player_control.c
Player control: the configured keys and moving actors by the pad. More…
Included by field.c.
Macros
| Name | Description | |
|---|---|---|
#define | FIELD_SHORTCUT_KEYS | On the World Map, the keys whose R and L open the map screen and the zoomed map (newly pressed in every edition but the Japanese, held before), and how far ahead of the leader each step is probed, in pixels. |
#define | WORLD_MAP_PROBE_RADIUS | |
#define | FIELD_WALK_SPEED toFIXED(1) | The leader's speeds and accelerations, in pixels a tick as 16.16 fixed point: the top 16 bits are whole pixels, so toFIXED(1) is one pixel. |
#define | FIELD_RUN_SPEED (toFIXED(3) / 2) | 1.5, with a dash key held |
#define | FIELD_ACCELERATION (toFIXED(1) / 4) | a quarter pixel faster each tick |
#define | FIELD_FAST_WALK_SPEED toFIXED(4) | 4, B held with FLAG_FAST_WALK |
#define | FIELD_FAST_WALK_ACCELERATION toFIXED(1) | |
#define | WORLD_MAP_WALK_SPEED (toFIXED(1) / 2) | half a pixel a tick |
#define | WORLD_MAP_RUN_SPEED toFIXED(1) | 1, with a dash key held |
#define | WORLD_MAP_RUN_ACCELERATION (toFIXED(5) / 4) | |
#define | WORLD_MAP_ACCELERATION (toFIXED(1) / 4) | |
#define | WORLD_MAP_FAST_SPEED toFIXED(4) | 4, while L repeats |
#define | FIELD_PROBE_ANGLE (TRIG_TURN / 16) | 22.5 degrees: a step is probed this far either side of its heading, and a blocked step tries headings one, two and three times this far off. |
#define | FIELD_BLOCKED_TURN_MAX (TRIG_TURN / 16) | A blocked leader turns toward the pad at most 22.5 degrees a tick. |
#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. |
#define | FOOTPRINT_RUN_INTERVAL 12 | The ticks between footprints, running and walking. |
#define | FOOTPRINT_WALK_INTERVAL 18 | |
#define | PROBE_FROM (actor, distance, heading, position) | Puts position distance along heading from actor: where a step is probed. |
#define | FIELD_SHORTCUT_KIND_SHIFT 14 | A shortcut key's assignment: its kind in the top two bits, from this one, and its request id in the bits below. |
#define | FIELD_SHORTCUT_ID_MASK ((1 << FIELD_SHORTCUT_KIND_SHIFT) - 1) | |
#define | DEBUG_RESOURCE_BEEP_FREE_BLOCKS 136 | The debug beep sounds while fewer resource blocks than this are free. |
#define | WORLD_MAP_YAW_STEP_MIN 16 | The World Map camera's turn is finished at once when its step is smaller than this. |
Enumerations
| Name | Description | |
|---|---|---|
enum | FIELD_SHORTCUT_KIND { FIELD_SHORTCUT_PSYNERGY, FIELD_SHORTCUT_ITEM } | What a shortcut key's assignment requests: its top two bits. |
enum | PLAYER_STEP_BLOCK { PLAYER_STEP_BLOCKED_BY_MAP, PLAYER_STEP_BLOCKED_BY_ACTOR, PL … } | What stopped the leader's step this tick (fdActorUpdatePlayerControl, fdActorMoveOnWorldMap). |
enum | FOOTPRINT_ANIMATION { FOOTPRINT_ONE_FOOT, FOOTPRINT_BOTH_FEET } | The footprints left in snow such as Imil's (FIELD_SPRITE_FOOTPRINT, footprints.png), and the leader's userValue that asks for the pair next. |
Functions
| Name | Description | |
|---|---|---|
void | fdActorSetUpdateValue (void *rawActor, Sint32 value) | Unused: stores value as a word in the actor's update function. |
Uint32 | fdRequestShortcut (Uint32 encodedAssignment) | Handles a shortcut key's assignment: its top two bits choose what it requests (FIELD_SHORTCUT_KIND) and the low 14 bits which one. |
Sint32 | fdCheckConfiguredKeys (void) | Checks the keys the player has configured: Select, A and Start set their flag in the field state and return 1; the two shortcut keys pass on their assignment (fdRequestShortcut) and return its request id. |
Sint32 | fdCheckSpheresOverlap (FIXED *firstPos, Sint32 radiusA, FIXED *secondPos, Sint32 radiusB) | Returns 0 when two spheres overlap: at positions a and b (16.16 pixels) with radii radiusA and radiusB (pixels); -1 otherwise. |
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. |
Sint32 | fdActorMoveOnWorldMap (ACTOR *actor) | SC_WORLD: moves the player on the World Map by the direction pad, as SC_PLAYER does on the field, and turns the World Map camera with the pad. |
Sint32 | fdActorScriptCheckKeys (ACTOR *actor) | SC_CHECK_KEYS: checks the configured keys (fdCheckConfiguredKeys). |
Sint32 | fdActorMoveByKeys (ACTOR *actor) | SC_KEYS: moves an actor 8 pixels at a time by the direction pad, with up and down changing its height (y) rather than its depth. |
Description
Player control: the configured keys and moving actors by the pad. Part of
field.c.
Macros in detail
FIELD_SHORTCUT_KEYS
#define FIELD_SHORTCUT_KEYS
On the World Map, the keys whose R and L open the map screen and the zoomed map (newly pressed in every edition but the Japanese, held before), and how far ahead of the leader each step is probed, in pixels.
Referenced by fdRequestShortcut().
Definition at line 9 of file field_player_control.c.
WORLD_MAP_PROBE_RADIUS
#define WORLD_MAP_PROBE_RADIUS
Referenced by fdActorMoveOnWorldMap().
Definition at line 11 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:
the top 16 bits are whole pixels, so toFIXED(1) is one pixel.
1 pixel a tick
Referenced by fdActorUpdatePlayerControl().
Definition at line 16 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 17 of file field_player_control.c.
FIELD_ACCELERATION
#define FIELD_ACCELERATION (toFIXED(1) / 4)
a quarter pixel faster each tick
Referenced by fdActorUpdatePlayerControl().
Definition at line 18 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 fdActorUpdatePlayerControl().
Definition at line 19 of file field_player_control.c.
FIELD_FAST_WALK_ACCELERATION
#define FIELD_FAST_WALK_ACCELERATION toFIXED(1)
Referenced by fdActorUpdatePlayerControl().
Definition at line 20 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 21 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 22 of file field_player_control.c.
WORLD_MAP_RUN_ACCELERATION
#define WORLD_MAP_RUN_ACCELERATION (toFIXED(5) / 4)
Referenced by fdActorMoveOnWorldMap().
Definition at line 23 of file field_player_control.c.
WORLD_MAP_ACCELERATION
#define WORLD_MAP_ACCELERATION (toFIXED(1) / 4)
Referenced by fdActorMoveOnWorldMap().
Definition at line 24 of file field_player_control.c.
WORLD_MAP_FAST_SPEED
#define WORLD_MAP_FAST_SPEED toFIXED(4)
4, while L repeats
Referenced by fdActorMoveOnWorldMap().
Definition at line 25 of file field_player_control.c.
FIELD_PROBE_ANGLE
#define FIELD_PROBE_ANGLE (TRIG_TURN / 16)
22.5 degrees: a step is probed this far either side of its heading, and a blocked step tries headings one, two and three times this far off.
Referenced by fdActorMoveOnWorldMap() and fdActorUpdatePlayerControl().
Definition at line 29 of file field_player_control.c.
FIELD_BLOCKED_TURN_MAX
#define FIELD_BLOCKED_TURN_MAX (TRIG_TURN / 16)
A blocked leader turns toward the pad at most 22.5 degrees a tick.
Referenced by fdActorMoveOnWorldMap() and fdActorUpdatePlayerControl().
Definition at line 31 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 fdActorMoveOnWorldMap().
Definition at line 34 of file field_player_control.c.
FOOTPRINT_RUN_INTERVAL
#define FOOTPRINT_RUN_INTERVAL 12
The ticks between footprints, running and walking.
Referenced by fdActorUpdatePlayerControl().
Definition at line 36 of file field_player_control.c.
FOOTPRINT_WALK_INTERVAL
#define FOOTPRINT_WALK_INTERVAL 18
Referenced by fdActorUpdatePlayerControl().
Definition at line 37 of file field_player_control.c.
PROBE_FROM
#define PROBE_FROM(actor, distance, heading, position)
Puts position distance along heading from actor: where a step is probed.
Referenced by fdActorMoveOnWorldMap() and fdActorUpdatePlayerControl().
Definition at line 40 of file field_player_control.c.
FIELD_SHORTCUT_KIND_SHIFT
#define FIELD_SHORTCUT_KIND_SHIFT 14
A shortcut key's assignment: its kind in the top two bits, from this one, and its request id in the bits below.
Referenced by fdRequestShortcut().
Definition at line 55 of file field_player_control.c.
FIELD_SHORTCUT_ID_MASK
#define FIELD_SHORTCUT_ID_MASK ((1 << FIELD_SHORTCUT_KIND_SHIFT) - 1)
Referenced by fdRequestShortcut().
Definition at line 56 of file field_player_control.c.
DEBUG_RESOURCE_BEEP_FREE_BLOCKS
#define DEBUG_RESOURCE_BEEP_FREE_BLOCKS 136
The debug beep sounds while fewer resource blocks than this are free.
Referenced by fdActorUpdatePlayerControl().
Definition at line 59 of file field_player_control.c.
WORLD_MAP_YAW_STEP_MIN
#define WORLD_MAP_YAW_STEP_MIN 16
The World Map camera's turn is finished at once when its step is smaller than this.
Referenced by fdActorMoveOnWorldMap().
Definition at line 63 of file field_player_control.c.
Enumerations in detail
FIELD_SHORTCUT_KIND
enum FIELD_SHORTCUT_KIND
What a shortcut key's assignment requests: its top two bits.
| Enumerator | Value | Description |
|---|---|---|
FIELD_SHORTCUT_PSYNERGY | 0 | FIELD_STATE.psynergy, an ability |
FIELD_SHORTCUT_ITEM | 1 | FIELD_STATE.item |
Definition at line 47 of file field_player_control.c.
PLAYER_STEP_BLOCK
enum PLAYER_STEP_BLOCK
What stopped the leader's step this tick (fdActorUpdatePlayerControl,
fdActorMoveOnWorldMap).
| Enumerator | Value | Description |
|---|---|---|
PLAYER_STEP_BLOCKED_BY_MAP | 1 | every heading tried runs into the map |
PLAYER_STEP_BLOCKED_BY_ACTOR | 2 | a solid actor ahead, or one with no room to be pushed |
PLAYER_STEP_BLOCKED | 3 | either of the two |
PLAYER_STEP_STOPPED | 4 | no step, not blocked: pad not held or climb hits a wall |
Definition at line 67 of file field_player_control.c.
FOOTPRINT_ANIMATION
enum FOOTPRINT_ANIMATION
The footprints left in snow such as Imil's (FIELD_SPRITE_FOOTPRINT,
footprints.png), and the leader's userValue that asks for the pair next.
| Enumerator | Value | Description |
|---|---|---|
FOOTPRINT_ONE_FOOT | 1 | one print, fading |
FOOTPRINT_BOTH_FEET | 2 | Two prints side by side, fading: laid first after a stop |
Definition at line 79 of file field_player_control.c.
Functions in detail
fdActorSetUpdateValue
void fdActorSetUpdateValue(void *rawActor, Sint32 value)
Unused: stores value as a word in the actor's update function.
References Sint32.
Definition at line 87 of file field_player_control.c.
fdRequestShortcut
Uint32 fdRequestShortcut(Uint32 encodedAssignment)
Handles a shortcut key's assignment: its top two bits choose what it requests
(FIELD_SHORTCUT_KIND) and the low 14 bits which one.
References gmFlagGetStub() and state.
Referenced by fdCheckConfiguredKeys().
Definition at line 97 of file field_player_control.c.
fdCheckConfiguredKeys
Sint32 fdCheckConfiguredKeys(void)
Checks the keys the player has configured: Select, A and Start set their flag
in the field state and return 1; the two shortcut keys pass on their
assignment (fdRequestShortcut) and return its request id.
References fdRequestShortcut(), MainRoutineStateWork, PerPush, Sint32 and state.
Referenced by fdActorMoveOnWorldMap(), fdActorScriptCheckKeys() and fdActorUpdatePlayerControl().
Definition at line 133 of file field_player_control.c.
fdCheckSpheresOverlap
Sint32 fdCheckSpheresOverlap(FIXED *firstPos, Sint32 radiusA, FIXED *secondPos, Sint32 radiusB)
Returns 0 when two spheres overlap: at positions a and b (16.16 pixels) with radii radiusA and radiusB (pixels); -1 otherwise.
References Sint32.
Referenced by fdActorScriptCheckOverlap(), fdActorScriptFindOverlappingActor() and fdActorUpdatePlayerControl().
Definition at line 168 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 DebugMode, fdActorCreate(), fdActorScriptCheckOverlap(), fdActorSelectAnimation(), fdActorSetMoveTarget(), fdActorStartScript(), fdCheckConfiguredKeys(), fdCheckSpheresOverlap(), fdMapGridCheckCollision(), fdSpriteStartAnimation(), gmFlagGetStub(), gmUnitGetStub(), MainRoutineStateWork, PerData, Sint32, syAtan(), syMulFX(), sySoundPlayStub(), sySquartFX(), syVectorAddPolarOffset(), VramCacheBlockOwners, WorldMapFootprintActions and WorldMapKeyHeadings.
Referenced by ActorScriptCommandTable.
Definition at line 194 of file field_player_control.c.
fdActorMoveOnWorldMap
Sint32 fdActorMoveOnWorldMap(ACTOR *actor)
SC_WORLD: moves the player on the World Map by the direction pad, as
SC_PLAYER does on the field, and turns the World Map camera with the pad.
References DebugMode, fdActorCreate(), fdActorSelectAnimation(), fdActorSetMoveTarget(), fdActorStartScript(), fdCheckConfiguredKeys(), fdSpriteStartAnimation(), fdWorldMapGetCollision(), fdWorldMapIsWalkable(), MainRoutineStateWork, PerData, PerRepeat, Sint32, syMulFX(), sySquartFX(), syVectorAddPolarOffset(), WorldMapFootprintActions, WorldMapKeyHeadings and WorldMapKeyYaws.
Referenced by ActorScriptCommandTable.
Definition at line 580 of file field_player_control.c.
fdActorScriptCheckKeys
Sint32 fdActorScriptCheckKeys(ACTOR *actor)
SC_CHECK_KEYS: checks the configured keys (fdCheckConfiguredKeys). Returns 1.
References fdCheckConfiguredKeys() and Sint32.
Referenced by ActorScriptCommandTable.
Definition at line 892 of file field_player_control.c.
fdActorMoveByKeys
Sint32 fdActorMoveByKeys(ACTOR *actor)
SC_KEYS: moves an actor 8 pixels at a time by the direction pad, with up and
down changing its height (y) rather than its depth.
References fdActorSelectAnimation(), fdActorSetMoveTarget(), fdMapGridGetTerrainHeight(), fdMapGridIsWallAt(), PerData, Sint32, syVectorAddPolarOffset() and WorldMapKeyHeadings.
Referenced by ActorScriptCommandTable.
Definition at line 901 of file field_player_control.c.