diff options
Diffstat (limited to 'engines/sci/engine')
-rw-r--r-- | engines/sci/engine/game.cpp | 6 | ||||
-rw-r--r-- | engines/sci/engine/gc.cpp | 14 | ||||
-rw-r--r-- | engines/sci/engine/heap.h | 4 | ||||
-rw-r--r-- | engines/sci/engine/klists.cpp | 4 | ||||
-rw-r--r-- | engines/sci/engine/message.h | 16 | ||||
-rw-r--r-- | engines/sci/engine/scriptconsole.cpp | 16 | ||||
-rw-r--r-- | engines/sci/engine/scriptdebug.cpp | 8 | ||||
-rw-r--r-- | engines/sci/engine/seg_manager.h | 14 | ||||
-rw-r--r-- | engines/sci/engine/vm.cpp | 26 |
9 files changed, 57 insertions, 51 deletions
diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp index 9be70390ce..870f27829d 100644 --- a/engines/sci/engine/game.cpp +++ b/engines/sci/engine/game.cpp @@ -615,8 +615,10 @@ int game_init(EngineState *s) { // Initialize send_calls buffer - if (!send_calls_allocated) - send_calls = (calls_struct_t*)sci_calloc(sizeof(calls_struct_t), send_calls_allocated = 16); + if (!send_calls_allocated) { + send_calls_allocated = 16; + send_calls = (calls_struct_t*)sci_calloc(sizeof(calls_struct_t), send_calls_allocated); + } if (s->gfx_state && _reset_graphics_input(s)) return 1; diff --git a/engines/sci/engine/gc.cpp b/engines/sci/engine/gc.cpp index 5cca5bd34e..0a0097aad5 100644 --- a/engines/sci/engine/gc.cpp +++ b/engines/sci/engine/gc.cpp @@ -32,11 +32,11 @@ namespace Sci { //#define DEBUG_GC //#define DEBUG_GC_VERBOSE -typedef struct _worklist { +struct worklist_t { int used; reg_t entries[WORKLIST_CHUNK_SIZE]; - struct _worklist *next; -} worklist_t; + worklist_t *next; +}; static worklist_t *fresh_worklist(worklist_t *old) { worklist_t *retval = (worklist_t*)sci_malloc(sizeof(worklist_t)); @@ -118,10 +118,10 @@ static reg_t_hash_map * normalise_hashmap_ptrs(reg_t_hash_map *nonnormal_map, se } -typedef struct { +struct worklist_manager_t { reg_t_hash_map *nonnormal_map; worklist_t **worklist_ref; -} worklist_manager_t; +}; void add_outgoing_refs(void *pre_wm, reg_t addr) { worklist_manager_t *wm = (worklist_manager_t *) pre_wm; @@ -228,14 +228,14 @@ reg_t_hash_map *find_all_used_references(EngineState *s) { return normal_map; } -typedef struct { +struct deallocator_t { seg_interface_t *interfce; #ifdef DEBUG_GC char *segnames[MEM_OBJ_MAX + 1]; int segcount[MEM_OBJ_MAX + 1]; #endif reg_t_hash_map *use_map; -} deallocator_t; +}; void free_unless_used(void *pre_use_map, reg_t addr) { deallocator_t *deallocator = (deallocator_t *)pre_use_map; diff --git a/engines/sci/engine/heap.h b/engines/sci/engine/heap.h index b89d03a684..bb8df540fb 100644 --- a/engines/sci/engine/heap.h +++ b/engines/sci/engine/heap.h @@ -34,12 +34,12 @@ namespace Sci { typedef uint16 heap_ptr; -typedef struct { +struct heap_t { byte *start; byte *base; unsigned int first_free; int old_ff; -} heap_t; +}; heap_t *heap_new(); /* Allocates a new heap. diff --git a/engines/sci/engine/klists.cpp b/engines/sci/engine/klists.cpp index db2deebbcd..e2cd12d7c7 100644 --- a/engines/sci/engine/klists.cpp +++ b/engines/sci/engine/klists.cpp @@ -427,10 +427,10 @@ reg_t kDeleteKey(EngineState *s, int funct_nr, int argc, reg_t *argv) { return make_reg(0, 1); // Signal success } -typedef struct { +struct sort_temp_t { reg_t key, value; reg_t order; -} sort_temp_t; +}; int sort_temp_cmp(const void *p1, const void *p2) { sort_temp_t *st1 = (sort_temp_t *)p1; diff --git a/engines/sci/engine/message.h b/engines/sci/engine/message.h index 572501c00f..759b0f4b75 100644 --- a/engines/sci/engine/message.h +++ b/engines/sci/engine/message.h @@ -27,18 +27,18 @@ namespace Sci { -typedef struct { +struct message_tuple_t { int noun; int verb; int cond; int seq; -} message_tuple_t; +}; -typedef struct { +struct index_record_cursor_t { byte *index_record; int index; byte *resource_beginning; -} index_record_cursor_t; +}; typedef int index_record_size_t(); typedef void parse_index_record_t(index_record_cursor_t *index_record, message_tuple_t *t); @@ -46,7 +46,7 @@ typedef int get_talker_t(index_record_cursor_t *cursor); typedef void get_text_t(index_record_cursor_t *cursor, char *buffer, int buffer_size); typedef int index_record_count_t(byte *header); -typedef struct { +struct message_handler_t { int version_id; parse_index_record_t *parse; get_talker_t *get_talker; @@ -55,9 +55,9 @@ typedef struct { int header_size; int index_record_size; -} message_handler_t; +}; -typedef struct { +struct message_state_t { int initialized; message_handler_t *handler; ResourceManager *resmgr; @@ -66,7 +66,7 @@ typedef struct { int record_count; byte *index_records; index_record_cursor_t engine_cursor; -} message_state_t; +}; int message_get_specific(message_state_t *state, message_tuple_t *t); int message_get_next(message_state_t *state); diff --git a/engines/sci/engine/scriptconsole.cpp b/engines/sci/engine/scriptconsole.cpp index 6bd7ca9b70..f710619457 100644 --- a/engines/sci/engine/scriptconsole.cpp +++ b/engines/sci/engine/scriptconsole.cpp @@ -51,21 +51,21 @@ static int c_selectornames(EngineState *s); // Displays all selector names static int c_kernelnames(EngineState *s); // Displays all kernel function names static int c_dissectscript(EngineState *s); // Splits a script into objects and explains them -typedef struct { +struct cmd_mm_entry_t { const char *name; const char *description; -} cmd_mm_entry_t; // All later structures must "extend" this +}; // All later structures must "extend" this typedef cmd_mm_entry_t cmd_page_t; // Simple info page -typedef struct { +struct cmd_command_t { const char *name; const char *description; int (*command)(EngineState *); const char *param; -} cmd_command_t; +}; -typedef struct { +struct cmd_var_t { const char *name; const char *description; union { @@ -73,19 +73,19 @@ typedef struct { char **charpp; reg_t *reg; } var; -} cmd_var_t; +}; typedef void printfunc_t(cmd_mm_entry_t *data, int full); -typedef struct { +struct cmd_mm_struct_t { const char *name; void *data; // cmd_mm_entry_t size_t size_per_entry; printfunc_t *print; int entries; // Number of used entries int allocated; // Number of allocated entries -} cmd_mm_struct_t; +}; #define CMD_MM_ENTRIES 3 // command console memory and manual page manager #define CMD_MM_DEFAULT_ALLOC 4 // Number of table entries to allocate per default diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp index 717042f983..4760fdf286 100644 --- a/engines/sci/engine/scriptdebug.cpp +++ b/engines/sci/engine/scriptdebug.cpp @@ -49,7 +49,7 @@ int _debug_seeking = 0; // Stepping forward until some special condition is met int _debug_seek_level = 0; // Used for seekers that want to check their exec stack depth int _debug_seek_special = 0; // Used for special seeks(1) int _weak_validations = 1; // Some validation errors are reduced to warnings if non-0 -reg_t _debug_seek_reg = NULL_REG_INITIALIZER; // Used for special seeks(2) +reg_t _debug_seek_reg = NULL_REG; // Used for special seeks(2) #define _DEBUG_SEEK_NOTHING 0 #define _DEBUG_SEEK_CALLK 1 // Step forward until callk is found @@ -338,7 +338,7 @@ static void print_obj_head(EngineState *s, object_t *obj) { static void print_list(EngineState *s, list_t *l) { reg_t pos = l->first; - reg_t my_prev = NULL_REG_INITIALIZER; + reg_t my_prev = NULL_REG; sciprintf("\t<\n"); @@ -2223,11 +2223,11 @@ static int c_listclones(EngineState *s) { return 0; } -typedef struct { +struct generic_config_flag_t { const char *name; const char option; unsigned int flag; -} generic_config_flag_t; +}; static void handle_config_update(const generic_config_flag_t *flags_list, int flags_nr, const char *subsystem, int *active_options_p, char *changestring /* or NULL to display*/) { diff --git a/engines/sci/engine/seg_manager.h b/engines/sci/engine/seg_manager.h index 42d9dfc809..54b6a5ce97 100644 --- a/engines/sci/engine/seg_manager.h +++ b/engines/sci/engine/seg_manager.h @@ -452,39 +452,39 @@ byte *sm_dereference(SegManager *self, reg_t reg, int *size); // 11. Segment interface, primarily for GC -typedef struct _seg_interface { +struct seg_interface_t { SegManager *segmgr; mem_obj_t *mobj; seg_id_t seg_id; mem_obj_enum type_id; // Segment type const char *type; // String description of the segment type - reg_t (*find_canonic_address)(struct _seg_interface *self, reg_t sub_addr); + reg_t (*find_canonic_address)(seg_interface_t *self, reg_t sub_addr); // Finds the canonic address associated with sub_reg // Parameters: (reg_t) sub_addr: The base address whose canonic address is to be found // For each valid address a, there exists a canonic address c(a) such that c(a) = c(c(a)). // This address "governs" a in the sense that deallocating c(a) will deallocate a. - void (*free_at_address)(struct _seg_interface *self, reg_t sub_addr); + void (*free_at_address)(seg_interface_t *self, reg_t sub_addr); // Deallocates all memory associated with the specified address // Parameters: (reg_t) sub_addr: The address (within the given segment) to deallocate - void (*list_all_deallocatable)(struct _seg_interface *self, void *param, void (*note)(void *param, reg_t addr)); + void (*list_all_deallocatable)(seg_interface_t *self, void *param, void (*note)(void *param, reg_t addr)); // Iterates over and reports all addresses within the current segment // Parameters: note : (voidptr * addr) -> (): Invoked for each address on which free_at_address() // makes sense // (void *) param: Parameter passed to 'note' - void (*list_all_outgoing_references)(struct _seg_interface *self, EngineState *s, reg_t object, void *param, void (*note)(void *param, reg_t addr)); + void (*list_all_outgoing_references)(seg_interface_t *self, EngineState *s, reg_t object, void *param, void (*note)(void *param, reg_t addr)); // Iterates over all references reachable from the specified object // Parameters: (reg_t) object: The object (within the current segment) to analyse // (void *) param: Parameter passed to 'note' // note : (voidptr * addr) -> (): Invoked for each outgoing reference within the object // Note: This function may also choose to report numbers (segment 0) as adresses - void (*deallocate_self)(struct _seg_interface *self); + void (*deallocate_self)(seg_interface_t *self); // Deallocates the segment interface -} seg_interface_t; +}; seg_interface_t *get_seg_interface(SegManager *self, seg_id_t segid); // Retrieves the segment interface to the specified segment diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index 45f8954ad7..3c5b1f5393 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -57,18 +57,18 @@ extern int _weak_validations; calls_struct_t *send_calls = NULL; int send_calls_allocated = 0; int bp_flag = 0; -static reg_t _dummy_register = NULL_REG_INITIALIZER; +static reg_t _dummy_register; // validation functionality #ifndef DISABLE_VALIDATIONS -static inline reg_t *validate_property(object_t *obj, int index) { +static inline reg_t &validate_property(object_t *obj, int index) { if (!obj) { if (sci_debug_flags & 4) sciprintf("[VM] Sending to disposed object!\n"); _dummy_register = NULL_REG; - return &_dummy_register; + return _dummy_register; } if (index < 0 || index >= obj->variables_nr) { @@ -77,10 +77,10 @@ static inline reg_t *validate_property(object_t *obj, int index) { obj->variables_nr); _dummy_register = NULL_REG; - return &_dummy_register; + return _dummy_register; } - return obj->variables + index; + return obj->variables[index]; } static inline stack_ptr_t validate_stack_addr(EngineState *s, stack_ptr_t sp) { @@ -175,7 +175,7 @@ static inline void validate_write_var(reg_t *r, reg_t *stack_base, int type, int # define validate_variable(r, sb, t, m, i, l) # define validate_read_var(r, sb, t, m, i, l) ((r)[i]) # define validate_write_var(r, sb, t, m, i, l, v) ((r)[i] = (v)) -# define validate_property(o, p) (&((o)->variables[p])) +# define validate_property(o, p) ((o)->variables[p]) # define ASSERT_ARITHMETIC(v) (v).offset #endif @@ -188,7 +188,7 @@ static inline void validate_write_var(reg_t *r, reg_t *stack_base, int type, int #define ACC_AUX_LOAD() aux_acc = signed_validate_arithmetic(s->r_acc) #define ACC_AUX_STORE() s->r_acc = make_reg(0, aux_acc) -#define OBJ_PROPERTY(o, p) (*validate_property(o, p)) +#define OBJ_PROPERTY(o, p) (validate_property(o, p)) int script_error(EngineState *s, const char *file, int line, const char *reason) { sciprintf("Script error in file %s, line %d: %s\n", file, line, reason); @@ -368,8 +368,10 @@ exec_stack_t *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, stac sciprintf("Send to "PREG", selector %04x (%s):", PRINT_REG(send_obj), selector, s->selector_names[selector]); #endif // VM_DEBUG_SEND - if (++send_calls_nr == (send_calls_allocated - 1)) - send_calls = (calls_struct_t *)sci_realloc(send_calls, sizeof(calls_struct_t) * (send_calls_allocated *= 2)); + if (++send_calls_nr == (send_calls_allocated - 1)) { + send_calls_allocated *= 2; + send_calls = (calls_struct_t *)sci_realloc(send_calls, sizeof(calls_struct_t) * send_calls_allocated); + } switch (lookup_selector(s, send_obj, selector, &varp, &funcp)) { case SELECTOR_NONE: @@ -2052,8 +2054,10 @@ static EngineState *_game_run(EngineState *s, int restoring) { free(s); s = successor; - if (!send_calls_allocated) - send_calls = (calls_struct_t *)sci_calloc(sizeof(calls_struct_t), send_calls_allocated = 16); + if (!send_calls_allocated) { + send_calls_allocated = 16; + send_calls = (calls_struct_t *)sci_calloc(sizeof(calls_struct_t), 16); + } if (script_abort_flag == SCRIPT_ABORT_WITH_REPLAY) { sciprintf("Restarting with replay()\n"); |