dsekai
World engine for retrocomputers.
Loading...
Searching...
No Matches
Engines

Central state and subsystem coordination. More...

Collaboration diagram for Engines:

Topics

 DSekai Engines Configuration
 Compile-time options defining engine behaviors.
 
 Engine Transitions
 Flags for specifying screen transitions.
 
 Engine-Specific Struct
 Structs containing information only used by certain engines.
 
 Engine Locking
 
 Engine Types
 

Files

file  engines.h
 Macros, structs, and prototypes for the various engine types.
 
file  serial.h
 Functions for (de)serializing engine structs to save states.
 

Data Structures

struct  DSEKAI_STATE
 General/shared state of the running engine in memory. More...
 

Macros

#define MINIMAP_X   (SCREEN_W - TILEMAP_TW - 10)
 
#define MINIMAP_Y   (10)
 
#define DSEKAI_TITLE_TEXT_COLOR   GRAPHICS_COLOR_WHITE
 
#define DSEKAI_FLAG_INPUT_BLOCKED   0x01
 DSEKAI_STATE::flags indicating no player input should be accepted.
 
#define DSEKAI_FLAG_MENU_BLOCKED   0x02
 
#define DSEKAI_FLAG_BLANK_FRAME   0x04
 DSEKAI_STATE::flags indicating every frame should be drawn fresh on a clean black canvas (unless the menu is open).
 
#define DSEKAI_FLAG_UNLOCKED   0x08
 
#define ENGINE_STATE_OPENING   1
 DSEKAI_STATE::engine_state indicating engine is has not yet initialized its specific structures.
 
#define ENGINE_STATE_RUNNING   2
 DSEKAI_STATE::engine_state indicating engine is running.
 
#define SERIAL_ERROR   -1
 
#define serial_asn_write_seq_start(p_asn_buffer_h, p_mark, desc, idx, cleanup)
 
#define serial_asn_write_seq_end(p_asn_buffer_h, p_mark, desc, idx, cleanup)
 
#define serial_asn_write_int(p_asn_buffer_h, val, x_val_sz, desc, idx, cleanup)
 
#define serial_asn_write_string(p_asn_buffer_h, str, str_sz, desc, idx, cleanup)
 
#define serial_asn_read_seq(asn_buffer, p_type, p_sz, desc, idx, read_sz, cleanup)
 
#define serial_asn_read_int(asn_buffer, p_val, val_sz, flags, desc, idx, read_sz, cleanup)
 
#define serial_asn_read_string(asn_buffer, str_buffer, str_buffer_sz, desc, idx, read_sz, cleanup)
 

Functions

void engines_draw_loading_screen ()
 Draw a simple loading screen.
 
int16_t engines_warp_loop (MEMORY_HANDLE state_handle)
 Handle transition to a new TILEMAP.
 
void engines_animate_mobiles (struct DSEKAI_STATE *state)
 Do generic mobile animation and execute their scripts.
 
int16_t engines_loop_iter (MEMORY_HANDLE state_handle)
 Central loop iteration handler. Calls engine-specific callbacks.
 
int8_t engines_input_movement (struct MOBILE *mover, int8_t dir_move, struct DSEKAI_STATE *state)
 Handle generic player movement commmand.
 
void engines_exit_to_title (struct DSEKAI_STATE *state)
 
void engines_set_transition (struct DSEKAI_STATE *state, uint8_t trans_type, uint8_t trans_open)
 
void engines_draw_transition (struct DSEKAI_STATE *state)
 
int32_t serial_save (const char *save_name, struct DSEKAI_STATE *state) SECTION_ASN
 Serialize the engine struct to a save state and call the unilayer_save to write that save state to storage.
 
int32_t serial_load (const char *save_name, struct DSEKAI_STATE *state) SECTION_ASN
 Call the unilayer_save to provide the save state with the given name and deserialize it into the given engine struct.
 

Detailed Description

Central state and subsystem coordination.

Macro Definition Documentation

◆ serial_asn_read_int

#define serial_asn_read_int ( asn_buffer,
p_val,
val_sz,
flags,
desc,
idx,
read_sz,
cleanup )
Value:
read_sz = asn_read_int( (uint8_t*)(p_val), val_sz, flags, asn_buffer, idx ); if( 0 >= read_sz ) { error_printf( "error reading %s", desc ); idx = SERIAL_ERROR; goto cleanup; } debug_printf( 2, "(offset 0x%02x) read %s (%d bytes): %d", idx, desc, read_sz, *(p_val) ); idx += read_sz;
int16_t asn_read_int(uint8_t *int_buffer, uint8_t buffer_sz, uint8_t flags, const uint8_t *asn_buffer, int32_t idx) SECTION_ASN
Read int object in asn_buffer into buffer.

◆ serial_asn_read_seq

#define serial_asn_read_seq ( asn_buffer,
p_type,
p_sz,
desc,
idx,
read_sz,
cleanup )
Value:
read_sz = asn_read_meta_ptr( asn_buffer, idx, p_type, p_sz ); if( ASN_SEQUENCE != *(p_type) ) { error_printf( "invalid %s sequence type: 0x%02x", desc, *(p_type) ); idx = SERIAL_ERROR; goto cleanup; } debug_printf( 2, "(offset 0x%02x) read %s seq start (%d bytes)", idx, desc, *(p_sz) ); idx += read_sz;
int16_t asn_read_meta_ptr(const uint8_t *buffer, int32_t idx, uint8_t *type_out, int32_t *sz_out) SECTION_ASN
Get metadata for the object at idx in buffer.

◆ serial_asn_read_string

#define serial_asn_read_string ( asn_buffer,
str_buffer,
str_buffer_sz,
desc,
idx,
read_sz,
cleanup )
Value:
read_sz = asn_read_string( str_buffer, str_buffer_sz, asn_buffer, idx ); if( 0 >= read_sz ) { error_printf( "error reading %s", desc ); idx = SERIAL_ERROR; goto cleanup; } debug_printf( 2, "(offset 0x%02x) read %s (%d bytes): %s", idx, desc, read_sz, str_buffer ); idx += read_sz;
int16_t asn_read_string(char *str_buffer, int16_t str_buffer_sz, const uint8_t *asn_buffer, int32_t idx) SECTION_ASN
Read string object in asn_buffer into str_buffer.

◆ serial_asn_write_int

#define serial_asn_write_int ( p_asn_buffer_h,
val,
x_val_sz,
desc,
idx,
cleanup )
Value:
debug_printf( 2, "(offset 0x%02x) writing %s: %d", idx, desc, val ); idx = asn_write_int( p_asn_buffer_h, idx, val ); if( 0 > idx ) { error_printf( "error writing %s: %d", desc, idx ); goto cleanup; }

◆ serial_asn_write_seq_end

#define serial_asn_write_seq_end ( p_asn_buffer_h,
p_mark,
desc,
idx,
cleanup )
Value:
debug_printf( 2, "(offset 0x%02x) writing %s seq end", idx, desc ); idx = asn_write_seq_end( p_asn_buffer_h, idx, p_mark ); if( 0 > idx ) { error_printf( "error writing %s seq end", desc ); idx = SERIAL_ERROR; goto cleanup; }

◆ serial_asn_write_seq_start

#define serial_asn_write_seq_start ( p_asn_buffer_h,
p_mark,
desc,
idx,
cleanup )
Value:
debug_printf( 2, "(offset 0x%02x) writing %s seq start", idx, desc ); idx = asn_write_seq_start( p_asn_buffer_h, idx, p_mark ); if( 0 > idx ) { error_printf( "error writing %s seq start", desc ); idx = SERIAL_ERROR; goto cleanup; }

◆ serial_asn_write_string

#define serial_asn_write_string ( p_asn_buffer_h,
str,
str_sz,
desc,
idx,
cleanup )
Value:
debug_printf( 2, "(offset 0x%02x) writing %s: %s", idx, desc, str ); idx = asn_write_string( p_asn_buffer_h, idx, str, str_sz ); if( 0 > idx ) { error_printf( "error writing %s: %d", desc, idx ); goto cleanup; }

Function Documentation

◆ engines_animate_mobiles()

void engines_animate_mobiles ( struct DSEKAI_STATE * state)

Do generic mobile animation and execute their scripts.

Parameters
stateLocked MEMORY_PTR for current DSEKAI_STATE.

◆ engines_input_movement()

int8_t engines_input_movement ( struct MOBILE * mover,
int8_t dir_move,
struct DSEKAI_STATE * state )

Handle generic player movement commmand.

Parameters
dir_move
stateLocked MEMORY_PTR for current DSEKAI_STATE.
mapLocked MEMORY_PTR for DSEKAI_STATE::map_handle.

◆ engines_loop_iter()

int16_t engines_loop_iter ( MEMORY_HANDLE state_handle)

Central loop iteration handler. Calls engine-specific callbacks.

Parameters
state_handleUnlocked MEMORY_HANDLE for current DSEKAI_STATE.
Returns
1 if engine should continue executing or 0 if it should quit.

◆ engines_warp_loop()

int16_t engines_warp_loop ( MEMORY_HANDLE state_handle)

Handle transition to a new TILEMAP.

Parameters
state_handleUnlocked MEMORY_HANDLE for current DSEKAI_STATE.

◆ serial_load()

int32_t serial_load ( const char * save_name,
struct DSEKAI_STATE * state )

Call the unilayer_save to provide the save state with the given name and deserialize it into the given engine struct.

Returns
Number of bytes read or error code.

◆ serial_save()

int32_t serial_save ( const char * save_name,
struct DSEKAI_STATE * state )

Serialize the engine struct to a save state and call the unilayer_save to write that save state to storage.

Returns
Number of bytes written or error code.