![]() |
dsekai
World engine for retrocomputers.
|
Functions and macros for executing in-world behavior. More...
#include "scstruct.h"
Go to the source code of this file.
Macros | |
#define | SCRIPT_ARG_STACK_P 32763 |
STACK_P: Argument indicating the instruction should pop its arg from MOBILE::script_stack, and then push it back when it's done. | |
#define | SCRIPT_ARG_STACK_I 32767 |
STACK_I: Argument indicating the instruction should pop its arg from MOBILE::script_stack, and then call mobile_incr_icount() to increment interaction count in MOBILE::flags on the actor. | |
#define | SCRIPT_ARG_STACK 32765 |
STACK: Argument indicating the instruction should pop its arg from MOBILE::script_stack. | |
#define | SCRIPT_ARG_RANDOM 32766 |
RANDOM: Argument indicating the instruction should use graphics_get_random() as its argument. | |
#define | SCRIPT_ARG_FOLLOW 32764 |
FOLLOW: Argument indicating the WALK (SCRIPT_CB_TABLE_2) instruction or FACE (SCRIPT_CB_TABLE_8) instruction should use the direction which will bring it closer to the player mobile determined by mobile_pathfind(). | |
#define | SCRIPT_ARG_MAX 32750 |
The maximum script argument guaranteed to be taken literally. Numbers above this may be interpreted as special instructions. | |
#define | SCRIPT_GLOBALS_MAX 20 |
Maximum number of global script flags available. | |
#define | SCRIPT_STACK_MAX 127 |
Maximum value an item stored on MOBILE::script_stack. | |
#define | SCRIPT_ERROR_OVERFLOW -1 |
#define | script_trace_printf(...) |
Alias for debug_printf() enabled when SCRIPT_TRACE is defined. | |
#define | SCRIPT_CB_TABLE_24(f) f( 23, SHAKE, 'y' ) |
#define | SCRIPT_CB_TABLE_23(f) f( 23, DISABLE, 'd' ) SCRIPT_CB_TABLE_24( f ) |
DISABLE: Disable Scripting Interactions with the MOBILE running this script, while still executing script instructions. | |
#define | SCRIPT_CB_TABLE_22(f) f( 22, WARP, 'w' ) SCRIPT_CB_TABLE_23( f ) |
WARP: Warp to a tilemap identified by the string at the arg index in current TILEMAP::strpool. | |
#define | SCRIPT_CB_TABLE_21(f) f( 21, ANIM, 'n' ) SCRIPT_CB_TABLE_22( f ) |
#define | SCRIPT_CB_TABLE_20(f) f( 20, PUSH, 'v' ) SCRIPT_CB_TABLE_21( f ) |
#define | SCRIPT_CB_TABLE_19(f) f( 19, POP, '^' ) SCRIPT_CB_TABLE_20( f ) |
#define | SCRIPT_CB_TABLE_18(f) f( 18, EQJMP, '=' ) SCRIPT_CB_TABLE_19( f ) |
EQJMP: Move script execution to a label defined by START if the last value pushed to MOBILE::script_stack is EQUAL TO the value pushed before it. | |
#define | SCRIPT_CB_TABLE_17(f) f( 17, GTJMP, '>' ) SCRIPT_CB_TABLE_18( f ) |
GTJMP: Move script execution to a label defined by START if the last value pushed to MOBILE::script_stack is GREATER THAN the value pushed before it. | |
#define | SCRIPT_CB_TABLE_16(f) f( 16, LTJMP, '<' ) SCRIPT_CB_TABLE_17( f ) |
LTJMP: Move script execution to a label defined by START if the last value pushed to MOBILE::script_stack is LESS THAN the value pushed before it. | |
#define | SCRIPT_CB_TABLE_15(f) f( 15, ADD, '+' ) SCRIPT_CB_TABLE_16( f ) |
ADD: Add the argument to the last value pushed to the stack, and push the result back onto the stack. | |
#define | SCRIPT_CB_TABLE_14(f) f( 14, SUB, '-' ) SCRIPT_CB_TABLE_15( f ) |
SUB: Subtract the argument from the last value pushed to the stack, and push the result back onto the stack. | |
#define | SCRIPT_CB_TABLE_13(f) f( 13, GIVE, 'h' ) SCRIPT_CB_TABLE_14( f ) |
GIVE: Give an ITEM to DSEKAI_STATE::player based on ITEM::gid from TILEMAP::item_defs. | |
#define | SCRIPT_CB_TABLE_12(f) f( 12, TAKE, 'k' ) SCRIPT_CB_TABLE_13( f ) |
TAKE: Give an ITEM to DSEKAI_STATE::player based on ITEM::gid from TILEMAP::item_defs. | |
#define | SCRIPT_CB_TABLE_11(f) f( 11, DIE, 'z' ) SCRIPT_CB_TABLE_12( f ) |
DIE: Trigger death animation for MOBILE running this script and then vanish, becoming inactive. | |
#define | SCRIPT_CB_TABLE_10(f) f( 10, GGET, 'a' ) SCRIPT_CB_TABLE_11( f ) |
GGET: Push a copy of a value from the global table at onto MOBILE::script_stack. | |
#define | SCRIPT_CB_TABLE_9(f) f( 9, GSET, 'b' ) SCRIPT_CB_TABLE_10( f ) |
GSET: Pop a value from MOBILE::script_stack into the global table, overriding any previous value at that index. | |
#define | SCRIPT_CB_TABLE_8(f) f( 8, FACE, 'f' ) SCRIPT_CB_TABLE_9( f ) |
FACE: Set the actor to face one of the Cardinal Directions. | |
#define | SCRIPT_CB_TABLE_7(f) f( 7, RETURN, 'x' ) SCRIPT_CB_TABLE_8( f ) |
RETURN: Return from an interaction subroutine to the main script. | |
#define | SCRIPT_CB_TABLE_6(f) f( 6, SPEAK, 'p' ) SCRIPT_CB_TABLE_7( f ) |
SPEAK: Display a dialog window with the actor's MOBILE::sprite_id and a line of text from TILEMAP::strpool. | |
#define | SCRIPT_CB_TABLE_5(f) f( 5, GOTO, 'g' ) SCRIPT_CB_TABLE_6( f ) |
GOTO: Move script execution to a label defined by START. | |
#define | SCRIPT_CB_TABLE_4(f) f( 4, START, 't' ) SCRIPT_CB_TABLE_5( f ) |
START: Define a label index that can be jumped to. | |
#define | SCRIPT_CB_TABLE_3(f) f( 3, SLEEP, 's' ) SCRIPT_CB_TABLE_4( f ) |
SLEEP: Don't do anything for arg number of frames. | |
#define | SCRIPT_CB_TABLE_2(f) f( 2, WALK, 'u' ) SCRIPT_CB_TABLE_3( f ) |
WALK: The actor walks in the direction specified on the stack. | |
#define | SCRIPT_CB_TABLE_1(f) f( 1, INTERACT,'i' ) SCRIPT_CB_TABLE_2( f ) |
INTERACT: Define a Scripting Interactions callback label. | |
#define | SCRIPT_CB_TABLE(f) f( 0, NOOP, '\0' ) SCRIPT_CB_TABLE_1( f ) |
NOOP: Not a valid instruction. Beginning of the script callback table, used to implement script parsing. | |
#define | SCRIPT_CB_TABLE_PROTOTYPES(idx, name, c) uint16_t script_handle_ ## name( uint16_t pc, int16_t arg, struct SCRIPT* script, struct MOBILE* actor, struct MOBILE* actee, struct TILEMAP_COORDS* tile, struct DSEKAI_STATE* state ); |
Define prototypes for the script action callbacks. | |
#define | SCRIPT_CB_TABLE_CONSTS(idx, name, c) extern RES_CONST uint16_t SCRIPT_ACTION_ ## name; |
Define extern constants that can be used e.g. in spawners. | |
Typedefs | |
typedef uint16_t(* | SCRIPT_CB) (uint16_t pc, int16_t arg, struct SCRIPT *script, struct MOBILE *actor, struct MOBILE *actee, struct TILEMAP_COORDS *tile, struct DSEKAI_STATE *state) |
Callback to execute a behavior action. Step in a script. | |
Functions | |
uint16_t | script_parse_str (int8_t script_idx, char *script_txt, int16_t script_txt_sz, struct SCRIPT *script) SECTION_SCRIPT |
Parse the given script string into an in-memory script. | |
uint8_t | script_init () SECTION_SCRIPT |
Script subsystem init function that should be called in main(). | |
void | script_shutdown () SECTION_SCRIPT |
Script subsystem cleanup function that should be called in main(). | |
uint16_t | script_goto_label (uint16_t pc, struct SCRIPT *script, uint16_t label_type, uint16_t label_id) |
Find a label of the given type and return the program counter (e.g. MOBILE::script_pc) at which it exists. | |
Variables | |
int8_t | g_script_globals [SCRIPT_GLOBALS_MAX] |
Global flag storage for all scripts. | |
RES_CONST SCRIPT_CB | gc_script_handlers [] |
Functions and macros for executing in-world behavior.