Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/common_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ typedef struct Evt {
/* 0x164 */ Bytecode* ptrCurLine;
/* 0x168 */ b8 debugPaused;
/* 0x169 */ s8 debugStep;
/* 0x16A */ u16 curLine;
} Evt; // size = 0x16C

typedef Evt* ScriptList[MAX_SCRIPTS];
Expand Down
8 changes: 8 additions & 0 deletions include/evt.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
// Should be at least the width of a pointer i.e. intptr_t
typedef s32 Bytecode;

// The argc word in EVT bytecode encodes both the argument count (low 16 bits)
// and the source line number (high 16 bits) for crash diagnostics.
#define EVT_CMD_ARGC(raw) ((raw) & 0xFFFF)
#define EVT_CMD_LINE(raw) ((u32)(raw) >> 16)

enum {
EVT_OP_INTERNAL_FETCH,
EVT_OP_END,
Expand Down Expand Up @@ -105,6 +110,9 @@ enum {
EVT_OP_DEBUG_BREAKPOINT,
};

/// The script currently being executed by evt_execute_next_command, or nullptr.
extern struct Evt* EvtCurrentScript;

#define MAKE_ENTITY_END 0x80000000

/* Return type of evt_execute_next_command */
Expand Down
4 changes: 2 additions & 2 deletions include/script_api/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@ extern "C" {
/// Bytecode argv[argc];
/// }
/// This macro expands to the given opcode and argv, with argc calculated automatically.

/// The line number is also encoded into the upper nibble of argc for debugging purposes.
#define EVT_CMD(opcode, argv...) \
opcode, \
(sizeof((Bytecode[]){argv})/sizeof(Bytecode)), \
(sizeof((Bytecode[]){argv})/sizeof(Bytecode)) | (__LINE__ << 16), \
##argv

/// Signals the end of EVT script data. A script missing this will likely crash on load.
Expand Down
Loading
Loading