![]() |
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) |
| #define | SCRIPT_CB_TABLE_23(f) |
| DISABLE: Disable Scripting Interactions with the MOBILE running this script, while still executing script instructions. | |
| #define | SCRIPT_CB_TABLE_22(f) |
| WARP: Warp to a tilemap identified by the string at the arg index in current TILEMAP::strpool. | |
| #define | SCRIPT_CB_TABLE_21(f) |
| #define | SCRIPT_CB_TABLE_20(f) |
| #define | SCRIPT_CB_TABLE_19(f) |
| #define | SCRIPT_CB_TABLE_18(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) |
| 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) |
| 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) |
| 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) |
| 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) |
| GIVE: Give an ITEM to DSEKAI_STATE::player based on ITEM::gid from TILEMAP::item_defs. | |
| #define | SCRIPT_CB_TABLE_12(f) |
| TAKE: Give an ITEM to DSEKAI_STATE::player based on ITEM::gid from TILEMAP::item_defs. | |
| #define | SCRIPT_CB_TABLE_11(f) |
| DIE: Trigger death animation for MOBILE running this script and then vanish, becoming inactive. | |
| #define | SCRIPT_CB_TABLE_10(f) |
| GGET: Push a copy of a value from the global table at onto MOBILE::script_stack. | |
| #define | SCRIPT_CB_TABLE_9(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) |
| FACE: Set the actor to face one of the Cardinal Directions. | |
| #define | SCRIPT_CB_TABLE_7(f) |
| RETURN: Return from an interaction subroutine to the main script. | |
| #define | SCRIPT_CB_TABLE_6(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) |
| GOTO: Move script execution to a label defined by START. | |
| #define | SCRIPT_CB_TABLE_4(f) |
| START: Define a label index that can be jumped to. | |
| #define | SCRIPT_CB_TABLE_3(f) |
| SLEEP: Don't do anything for arg number of frames. | |
| #define | SCRIPT_CB_TABLE_2(f) |
| WALK: The actor walks in the direction specified on the stack. | |
| #define | SCRIPT_CB_TABLE_1(f) |
| INTERACT: Define a Scripting Interactions callback label. | |
| #define | SCRIPT_CB_TABLE(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) |
| Define prototypes for the script action callbacks. | |
| #define | SCRIPT_CB_TABLE_CONSTS(idx, name, c) |
| 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.