dsekai
World engine for retrocomputers.
Loading...
Searching...
No Matches
Data Fields | Related Functions
MOBILE Struct Reference

A moving/interactive object in the world. More...

#include <mobile.h>

Collaboration diagram for MOBILE:
Collaboration graph
[legend]

Data Fields

uint16_t flags
 Mobile Object Flags affecting this mobile's display and behavior.
 
SPAWN_GID spawner_gid
 TILEMAP_SPAWN::gid of the spawner that spawned this mobile.
 
TILEMAP_GID map_gid
 TILEMAP::gid of the tilemap this mobile was spawned on.
 
char name [TILEMAP_SPAWN_NAME_SZ]
 
char sprite_name [RESOURCE_NAME_MAX]
 
int16_t mp_hp
 The combined dsekai_mobiles_mp_hp field.
 
int16_t screen_px
 Current on-screen pixel left of sprite. -1 if off-screen.
 
int16_t screen_py
 Current on-screen pixel left of sprite. -1 if off-screen.
 
int16_t sprite_cache_id
 Index of the mobile's Mobile Spritesheets loaded in the Unilayer Graphics Cache.
 
unsigned char ascii
 
int8_t coords_sz
 Number of coordinates in MOBILE::coords.
 
struct TILEMAP_COORDS coords [MOBILE_COORDS_QUEUE_SZ]
 The mobile's current location (in tiles) as well as queued future locations.
 
uint8_t steps_remaining
 Number of steps remaining in current walk animation.
 
int16_t script_id
 Index currently executing behavior script in TILEMAP::scripts.
 
int16_t script_pc
 Position in currently executing behavior script.
 
int8_t script_stack [SCRIPT_STACK_DEPTH]
 Local stack used to store state for this mobile's SCRIPT.
 
uint16_t script_wait_frames
 Delay script for this many frames.
 

Related Functions

(Note that these are not member functions.)

#define MOBILE_MAP_GID_ALL   0xffff
 MOBILE::map_gid value indicating mobile is present on all tilemaps.
 
#define MOBILE_GID_FMT   "%04d:%04d"
 Insert into logging format strings when a mobile's Globally Unique Identifiers is needed.
 
#define mobile_get_gid_fmt(m)   (m)->map_gid, (m)->spawner_gid
 Insert into the args provided to a format string using MOBILE_GID_FMT.
 
#define MOBILE_COORDS_QUEUE_SZ   5
 Number of positions available in the MOBILE::coords queue.
 
#define mobile_incr_hp(m, v)   (m)->mp_hp = (((m)->mp_hp & MOBILE_MP_MASK) | (((((m)->mp_hp & MOBILE_HP_MASK) + (v)) & MOBILE_HP_MASK) & MOBILE_HP_MASK))
 Increment just the HP half of MOBILE::mp_hp.
 
#define mobile_get_dir(m)   ((m)->flags & MOBILE_DIR_MASK)
 Get the Cardinal Directions the mobile is facing.
 
#define mobile_set_dir(m, v)   (m)->flags = (((m)->flags & ~MOBILE_DIR_MASK) | ((v) & MOBILE_DIR_MASK))
 Set MOBILE_DIR_MASK in MOBILE::flags to the specified Cardinal Directions.
 
#define mobile_get_icount(m)   (((m)->flags & MOBILE_ICOUNT_MASK) >> 12)
 Get the current interaction count of the specified MOBILE.
 
#define mobile_incr_icount(m, v)   (m)->flags = (((m)->flags & ~MOBILE_ICOUNT_MASK) | ((mobile_get_icount( m ) + (((v) << 12) & MOBILE_ICOUNT_MASK)) & MOBILE_ICOUNT_MASK))
 Increment MOBILE_ICOUNT_MASK by a given value.
 
#define mobile_get_gid(m)   (MOBILE_GID)((((MOBILE_GID)((m)->map_gid)) << (sizeof( TILEMAP_GID ) * 8)) & (m)->spawner_gid)
 Get the globally unique identifier of the given MOBILE.
 
#define mobile_get_map_gid(m, state)   ((MOBILE_GID_PLAYER == mobile_get_gid( m )) ? (state)->tilemap->gid : (m)->map_gid)
 Get the GID of the TILEMAP the given MOBILE is currently on.
 
#define mobile_get_sprite(m)   ((m)->sprite_cache_id)
 Get the pointer to the sprite graphic to use for a MOBILE.
 

Detailed Description

A moving/interactive object in the world.

Friends And Related Function Documentation

◆ mobile_get_gid

#define mobile_get_gid (   m)    (MOBILE_GID)((((MOBILE_GID)((m)->map_gid)) << (sizeof( TILEMAP_GID ) * 8)) & (m)->spawner_gid)
related

Get the globally unique identifier of the given MOBILE.

This identifier is/must be unique among all ::MOBILEs in DSEKAI_STATE::mobiles_handle and persists between Engine Locking cycles.

Parameters
mLocked MEMORY_PTR to MOBILE to query.
Returns
MOBILE_GID of the mobile m constructed from MOBILE::map_gid and MOBILE::spawner_gid.

◆ mobile_get_gid_fmt

#define mobile_get_gid_fmt (   m)    (m)->map_gid, (m)->spawner_gid
related

Insert into the args provided to a format string using MOBILE_GID_FMT.

Parameters
mLocked MEMORY_PTR to the mobile to examine.

◆ mobile_get_icount

#define mobile_get_icount (   m)    (((m)->flags & MOBILE_ICOUNT_MASK) >> 12)
related

Get the current interaction count of the specified MOBILE.

Parameters
mLocked MEMORY_PTR to MOBILE to query.

◆ mobile_get_map_gid

#define mobile_get_map_gid (   m,
  state 
)    ((MOBILE_GID_PLAYER == mobile_get_gid( m )) ? (state)->tilemap->gid : (m)->map_gid)
related

Get the GID of the TILEMAP the given MOBILE is currently on.

Parameters
mLocked MEMORY_PTR to MOBILE to query.
Warning
Engine state must be locked with Engine Locking before use here!

◆ mobile_incr_icount

#define mobile_incr_icount (   m,
 
)    (m)->flags = (((m)->flags & ~MOBILE_ICOUNT_MASK) | ((mobile_get_icount( m ) + (((v) << 12) & MOBILE_ICOUNT_MASK)) & MOBILE_ICOUNT_MASK))
related

Increment MOBILE_ICOUNT_MASK by a given value.

Parameters
mLocked MEMORY_PTR to MOBILE to modify.
vValue to increment counter by.

◆ MOBILE_MAP_GID_ALL

#define MOBILE_MAP_GID_ALL   0xffff
related

MOBILE::map_gid value indicating mobile is present on all tilemaps.

This is generally only used for the player.

◆ mobile_set_dir

#define mobile_set_dir (   m,
 
)    (m)->flags = (((m)->flags & ~MOBILE_DIR_MASK) | ((v) & MOBILE_DIR_MASK))
related

Set MOBILE_DIR_MASK in MOBILE::flags to the specified Cardinal Directions.

Parameters
mLocked MEMORY_PTR to MOBILE to modify.
vCardinal Directions to set the mobile facing.

Field Documentation

◆ coords

struct TILEMAP_COORDS MOBILE::coords[MOBILE_COORDS_QUEUE_SZ]

The mobile's current location (in tiles) as well as queued future locations.

The first two location indexes (0 and 1) should be equal if the mobile is standing still. Otherwise, 1 contains the location the mobile is moving to and 0 contains the location it is moving from. This allows 0 to become 1 and if MOBILE::coords_sz > 2, then 2 can be moved down to 1.

◆ map_gid

TILEMAP_GID MOBILE::map_gid

TILEMAP::gid of the tilemap this mobile was spawned on.

This is part of the MOBILE_GID.

◆ screen_px

int16_t MOBILE::screen_px

Current on-screen pixel left of sprite. -1 if off-screen.

This may vary, depending on the engine type, but is also used to place animations over the mobile.

◆ screen_py

int16_t MOBILE::screen_py

Current on-screen pixel left of sprite. -1 if off-screen.

This may vary, depending on the engine type, but is also used to place animations over the mobile.

◆ script_stack

int8_t MOBILE::script_stack[SCRIPT_STACK_DEPTH]

Local stack used to store state for this mobile's SCRIPT.

This should only be manipulated directly via mobile_stack_push() and mobile_stack_pop().

Values stored on the stack can go up to SCRIPT_STACK_MAX.

◆ script_wait_frames

uint16_t MOBILE::script_wait_frames

Delay script for this many frames.

This is an absolute value of frames to count down and may be safely serialized.

◆ spawner_gid

SPAWN_GID MOBILE::spawner_gid

TILEMAP_SPAWN::gid of the spawner that spawned this mobile.

This is part of the MOBILE_GID.

◆ sprite_cache_id

int16_t MOBILE::sprite_cache_id

Index of the mobile's Mobile Spritesheets loaded in the Unilayer Graphics Cache.

Warning
This should not be serialized!

◆ steps_remaining

uint8_t MOBILE::steps_remaining

Number of steps remaining in current walk animation.

This is set to SPRITE_W to start and then incrementally determined using the table gc_mobile_step_table_normal_pos on each tick.


The documentation for this struct was generated from the following files: