aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2009-02-21 04:43:49 +0000
committerMax Horn2009-02-21 04:43:49 +0000
commitfa75bd23e6b710d2f225c9162ca651e7e518ce75 (patch)
tree75c0b4137b18230fed9d606d7740b0d42b02a88a
parent7c87b4901dd6de93511cf7995931b64e59d13fef (diff)
downloadscummvm-rg350-fa75bd23e6b710d2f225c9162ca651e7e518ce75.tar.gz
scummvm-rg350-fa75bd23e6b710d2f225c9162ca651e7e518ce75.tar.bz2
scummvm-rg350-fa75bd23e6b710d2f225c9162ca651e7e518ce75.zip
SCI: Yet more cleanup
svn-id: r38661
-rw-r--r--engines/sci/engine/klists.cpp4
-rw-r--r--engines/sci/engine/kscripts.cpp2
-rw-r--r--engines/sci/include/kdebug.h22
-rw-r--r--engines/sci/include/kernel.h68
-rw-r--r--engines/sci/include/resource.h11
-rw-r--r--engines/sci/scicore/resource_patch.cpp14
-rw-r--r--engines/sci/scicore/tools.cpp56
7 files changed, 42 insertions, 135 deletions
diff --git a/engines/sci/engine/klists.cpp b/engines/sci/engine/klists.cpp
index 66216fe813..0e17b3a083 100644
--- a/engines/sci/engine/klists.cpp
+++ b/engines/sci/engine/klists.cpp
@@ -91,10 +91,6 @@ list_t *lookup_list(state_t *s, reg_t addr, const char *file, int line) {
return _lookup_list(s, addr, file, line, 0);
}
-int listp(state_t *s, reg_t addr) {
- return (s->seg_manager.heap[addr.segment]->type == MEM_OBJ_LISTS && ENTRY_IS_VALID(&(s->seg_manager.heap[addr.segment]->data.lists), addr.offset));
-}
-
#ifdef DISABLE_VALIDATIONS
#define sane_nodep(a, b) 1
diff --git a/engines/sci/engine/kscripts.cpp b/engines/sci/engine/kscripts.cpp
index eb00bb9573..560c9d6b8b 100644
--- a/engines/sci/engine/kscripts.cpp
+++ b/engines/sci/engine/kscripts.cpp
@@ -104,7 +104,7 @@ int invoke_selector(state_t *s, reg_t object, int selector_id, int noinvalid, in
return 0;
}
-int is_object(state_t *s, reg_t object) {
+bool is_object(state_t *s, reg_t object) {
return obj_get(s, object) != NULL;
}
diff --git a/engines/sci/include/kdebug.h b/engines/sci/include/kdebug.h
index 1fa839b573..68a9e51755 100644
--- a/engines/sci/include/kdebug.h
+++ b/engines/sci/include/kdebug.h
@@ -77,31 +77,15 @@ struct _state;
-#ifdef __GNUC__XXX
-
-#define SCIkwarn(arguments...) _SCIGNUkdebug(__PRETTY_FUNCTION__, ## arguments)
-
-#else /* !__GNUC__ */
-
-#define SCIkwarn _SCIkwarn
-
-#endif /* !__GNUC__ */
-
/* Internal functions */
-void
-_SCIkwarn(struct _state *s, const char *file, int line, int area, const char *format, ...);
-void
-_SCIkdebug(struct _state *s, const char *file, int line, int area, const char *format, ...);
-void
-_SCIGNUkdebug(const char *funcname, struct _state *s, const char *file, int line, int area, const char *format, ...);
+void _SCIkdebug(struct _state *s, const char *file, int line, int area, const char *format, ...);
+void _SCIGNUkdebug(const char *funcname, struct _state *s, const char *file, int line, int area, const char *format, ...);
/* If mode=1, enables debugging for specified areas. If mode=0, disables
** debugging for specified areas.
** Valid area characters: ulgcmfbad
*/
-
-void
-set_debug_mode(struct _state *s, int mode, const char *areas);
+void set_debug_mode(struct _state *s, int mode, const char *areas);
extern int sci_debug_flags;
diff --git a/engines/sci/include/kernel.h b/engines/sci/include/kernel.h
index 071aee7b46..587582d9b7 100644
--- a/engines/sci/include/kernel.h
+++ b/engines/sci/include/kernel.h
@@ -83,21 +83,17 @@ typedef struct {
*/
-reg_t
-read_selector(struct _state *s, reg_t object, selector_t selector_id, const char *fname, int line);
-void
-write_selector(struct _state *s, reg_t object, selector_t selector_id, reg_t value,
+reg_t read_selector(struct _state *s, reg_t object, selector_t selector_id, const char *fname, int line);
+void write_selector(struct _state *s, reg_t object, selector_t selector_id, reg_t value,
const char *fname, int line);
-int
-invoke_selector(struct _state *s, reg_t object, int selector_id, int noinvalid, int kfunct,
+int invoke_selector(struct _state *s, reg_t object, int selector_id, int noinvalid, int kfunct,
stack_ptr_t k_argp, int k_argc, const char *fname, int line, int argc, ...);
/******************** Text functionality ********************/
-char *
-kernel_lookup_text(struct _state *s, reg_t address, int index);
+char *kernel_lookup_text(struct _state *s, reg_t address, int index);
/* Looks up text referenced by scripts
** Parameters: (state_t *s): The current state
** (reg_t) address: The address to look up
@@ -133,16 +129,7 @@ kernel_lookup_text(struct _state *s, reg_t address, int index);
#endif /* !SCI_KERNEL_DEBUG */
-int
-listp(struct _state *s, reg_t address);
-/* Determines whether the object at <address> is a list
-** Parameters: (state_t *) s: The state to use
-** (reg_t) address: The address to check
-** Returns : (int) 0 if not, non-zero if it is a list.
-*/
-
-int
-is_object(struct _state *s, reg_t obj);
+bool is_object(struct _state *s, reg_t obj);
/* Checks whether a heap address contains an object
** Parameters: (state_t *) s: The current state
** (reg_t) obj: The address to check
@@ -150,15 +137,6 @@ is_object(struct _state *s, reg_t obj);
*/
-/* Functions for internal macro use */
-void
-_SCIkvprintf(FILE *file, const char *format, va_list args);
-void
-_SCIkprintf(FILE *file, const char *format, ...) GCC_PRINTF(2, 3);
-
-
-
-
/******************** Kernel function parameter macros ********************/
@@ -175,10 +153,8 @@ _SCIkprintf(FILE *file, const char *format, ...) GCC_PRINTF(2, 3);
#define SKPV_OR_ALT(x,a) KP_SINT(KP_ALT(x, make_reg(0, a)))
#define UKPV_OR_ALT(x,a) KP_UINT(KP_ALT(x, make_reg(0, a)))
-reg_t *
-kernel_dereference_reg_pointer(struct _state *s, reg_t pointer, int entries);
-byte *
-kernel_dereference_bulk_pointer(struct _state *s, reg_t pointer, int entries);
+reg_t *kernel_dereference_reg_pointer(struct _state *s, reg_t pointer, int entries);
+byte *kernel_dereference_bulk_pointer(struct _state *s, reg_t pointer, int entries);
#define kernel_dereference_char_pointer(state, pointer, entries) (char*)kernel_dereference_bulk_pointer(state, pointer, entries)
/* Dereferences a heap pointer
** Parameters: (state_t *) s: The state to operate on
@@ -202,8 +178,7 @@ kernel_dereference_bulk_pointer(struct _state *s, reg_t pointer, int entries);
-int
-kernel_oops(struct _state *s, const char *file, int line, const char *reason);
+int kernel_oops(struct _state *s, const char *file, int line, const char *reason);
/* Halts script execution and informs the user about an internal kernel error or failed assertion
** Paramters: (state_t *) s: The state to use
** (const char *) file: The file the oops occured in
@@ -220,16 +195,14 @@ struct _state;
extern int sci01_priority_table_flags; /* 1: delete, 2: print */
-int
-_find_priority_band(struct _state *s, int band);
+int _find_priority_band(struct _state *s, int band);
/* Finds the position of the priority band specified
** Parameters: (state_t *) s: State to search in
** (int) band: Band to look for
** Returns : (int) Offset at which the band starts
*/
-int
-_find_view_priority(struct _state *s, int y);
+int _find_view_priority(struct _state *s, int y);
/* Does the opposite of _find_priority_band
** Parameters: (state_t *) s: State
** (int) y: Coordinate to check
@@ -257,16 +230,14 @@ _find_view_priority(struct _state *s, int y);
/******************** Dynamic view list functions ********************/
-abs_rect_t
-set_base(struct _state *s, reg_t object);
+abs_rect_t set_base(struct _state *s, reg_t object);
/* Determines the base rectangle of the specified view object
** Parameters: (state_t *) s: The state to use
** (reg_t) object: The object to set
** Returns : (abs_rect) The absolute base rectangle
*/
-extern abs_rect_t
- get_nsrect(struct _state *s, reg_t object, byte clip);
+extern abs_rect_t get_nsrect(struct _state *s, reg_t object, byte clip);
/* Determines the now-seen rectangle of a view object
** Parameters: (state_t *) s: The state to use
** (reg_t) object: The object to check
@@ -276,11 +247,9 @@ extern abs_rect_t
** now-seen area.
*/
-void
-_k_dyn_view_list_prepare_change(struct _state *s);
+void _k_dyn_view_list_prepare_change(struct _state *s);
/* Removes all views in anticipation of a new window or text */
-void
-_k_dyn_view_list_accept_change(struct _state *s);
+void _k_dyn_view_list_accept_change(struct _state *s);
/* Redraws all views after a new window or text was added */
@@ -288,14 +257,12 @@ _k_dyn_view_list_accept_change(struct _state *s);
/******************** Misc functions ********************/
-void
-process_sound_events(struct _state *s); /* Get all sound events, apply their changes to the heap */
+void process_sound_events(struct _state *s); /* Get all sound events, apply their changes to the heap */
#define LOOKUP_NODE(addr) lookup_node(s, (addr), __FILE__, __LINE__)
#define LOOKUP_LIST(addr) lookup_list(s, addr, __FILE__, __LINE__)
-node_t *
-lookup_node(struct _state *s, reg_t addr, const char *file, int line);
+node_t *lookup_node(struct _state *s, reg_t addr, const char *file, int line);
/* Resolves an address into a list node
** Parameters: (state_t *) s: The state to operate on
** (reg_t) addr: The address to resolve
@@ -305,8 +272,7 @@ lookup_node(struct _state *s, reg_t addr, const char *file, int line);
*/
-list_t *
-lookup_list(struct _state *s, reg_t addr, const char *file, int line);
+list_t *lookup_list(struct _state *s, reg_t addr, const char *file, int line);
/* Resolves a list pointer to a list
** Parameters: (state_t *) s: The state to operate on
** (reg_t) addr: The address to resolve
diff --git a/engines/sci/include/resource.h b/engines/sci/include/resource.h
index ebaa23f642..8db6ef9185 100644
--- a/engines/sci/include/resource.h
+++ b/engines/sci/include/resource.h
@@ -260,15 +260,10 @@ int is_print_str(char *str);
# define sci_unlink unlink
# define sci_rmdir rmdir
-#ifndef HAVE_FFS
-int sci_ffs(int _mask);
-#else
-#define sci_ffs ffs
-#endif
+/** Find first set bit in bits and return its index. Returns 0 if bits is 0. */
+int sci_ffs(int bits);
-
-void
-sci_sched_yield(void);
+void sci_sched_yield(void);
/* Yields the running process/thread to the scheduler
** Parameters: (void)
** Returns : after a while.
diff --git a/engines/sci/scicore/resource_patch.cpp b/engines/sci/scicore/resource_patch.cpp
index 1ba016a9cd..c861bd9adc 100644
--- a/engines/sci/scicore/resource_patch.cpp
+++ b/engines/sci/scicore/resource_patch.cpp
@@ -104,11 +104,6 @@ static void process_patch(ResourceSource *source,
int sci0_read_resource_patches(ResourceSource *source, resource_t **resource_p, int *resource_nr_p) {
- // FIXME: Use only one specific dir, instead of SearchMan?
- //chdir(source->location_dir_name.c_str());
- //sci_init_dir(&dir);
- //entry = sci_find_first(&dir, "*.???");
-
Common::ArchiveMemberList files;
SearchMan.listMatchingMembers(files, "*.???");
@@ -119,7 +114,6 @@ int sci0_read_resource_patches(ResourceSource *source, resource_t **resource_p,
int i;
unsigned int resname_len;
char *endptr;
-printf("sci0_read_resource_patches: scanning '%s'\n", name.c_str());
for (i = sci_view; i < sci_invalid_resource; i++)
if (scumm_strnicmp(sci_resource_types[i], name.c_str(),
@@ -148,13 +142,7 @@ printf("sci0_read_resource_patches: scanning '%s'\n", name.c_str());
return 0;
}
-int
-sci1_read_resource_patches(ResourceSource *source, resource_t **resource_p, int *resource_nr_p) {
- // FIXME: Use only one specific dir, instead of SearchMan?
- //chdir(source->location_dir_name.c_str());
- //sci_init_dir(&dir);
- //entry = sci_find_first(&dir, "*.*");
-
+int sci1_read_resource_patches(ResourceSource *source, resource_t **resource_p, int *resource_nr_p) {
Common::ArchiveMemberList files;
SearchMan.listMatchingMembers(files, "*.*");
diff --git a/engines/sci/scicore/tools.cpp b/engines/sci/scicore/tools.cpp
index b7a2327d75..ae1c343336 100644
--- a/engines/sci/scicore/tools.cpp
+++ b/engines/sci/scicore/tools.cpp
@@ -96,7 +96,8 @@ int sci_debug_flags = 0; /* Special flags */
int sci_ffs(int _mask) {
int retval = 0;
- if (!_mask) return 0;
+ if (!_mask)
+ return 0;
retval++;
while (!(_mask & 1)) {
retval++;
@@ -109,45 +110,22 @@ int sci_ffs(int _mask) {
/******************** Debug functions ********************/
-void
-_SCIkvprintf(FILE *file, const char *format, va_list args) {
- vfprintf(file, format, args);
- if (con_file) vfprintf(con_file, format, args);
-}
-void
-_SCIkprintf(FILE *file, const char *format, ...) {
- va_list args;
-
- va_start(args, format);
- _SCIkvprintf(file, format, args);
- va_end(args);
-}
+/* Functions for internal macro use */
+void _SCIkvprintf(FILE *file, const char *format, va_list args);
+void _SCIkprintf(FILE *file, const char *format, ...) GCC_PRINTF(2, 3);
-void
-_SCIkwarn(state_t *s, const char *file, int line, int area, const char *format, ...) {
- va_list args;
-
- if (area == SCIkERROR_NR)
- _SCIkprintf(stderr, "ERROR: ");
- else
- _SCIkprintf(stderr, "Warning: ");
-
- va_start(args, format);
- _SCIkvprintf(stderr, format, args);
- va_end(args);
- fflush(NULL);
-
- if (sci_debug_flags & _DEBUG_FLAG_BREAK_ON_WARNINGS) script_debug_flag = 1;
+void _SCIkvprintf(FILE *file, const char *format, va_list args) {
+ vfprintf(file, format, args);
+ if (con_file) vfprintf(con_file, format, args);
}
-void
-_SCIkdebug(state_t *s, const char *file, int line, int area, const char *format, ...) {
+void _SCIkdebug(state_t *s, const char *file, int line, int area, const char *format, ...) {
va_list args;
if (s->debug_mode & (1 << area)) {
- _SCIkprintf(stdout, " kernel: (%s L%d): ", file, line);
+ fprintf(stdout, " kernel: (%s L%d): ", file, line);
va_start(args, format);
_SCIkvprintf(stdout, format, args);
va_end(args);
@@ -155,22 +133,22 @@ _SCIkdebug(state_t *s, const char *file, int line, int area, const char *format,
}
}
-void
-_SCIGNUkdebug(const char *funcname, state_t *s, const char *file, int line, int area, const char *format, ...) {
+void _SCIGNUkdebug(const char *funcname, state_t *s, const char *file, int line, int area, const char *format, ...) {
va_list xargs;
int error = ((area == SCIkWARNING_NR) || (area == SCIkERROR_NR));
if (error || (s->debug_mode & (1 << area))) { /* Is debugging enabled for this area? */
- _SCIkprintf(stderr, "FSCI: ");
+ fprintf(stderr, "FSCI: ");
if (area == SCIkERROR_NR)
- _SCIkprintf(stderr, "ERROR in %s ", funcname);
+ fprintf(stderr, "ERROR in %s ", funcname);
else if (area == SCIkWARNING_NR)
- _SCIkprintf(stderr, "%s: Warning ", funcname);
- else _SCIkprintf(stderr, funcname);
+ fprintf(stderr, "%s: Warning ", funcname);
+ else
+ fprintf(stderr, funcname);
- _SCIkprintf(stderr, "(%s L%d): ", file, line);
+ fprintf(stderr, "(%s L%d): ", file, line);
va_start(xargs, format);
_SCIkvprintf(stderr, format, xargs);