aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine
diff options
context:
space:
mode:
authorMax Horn2009-02-27 02:23:00 +0000
committerMax Horn2009-02-27 02:23:00 +0000
commit170916201c2dd8b75dccefb9a39c6fee572a4ec9 (patch)
treedca874754c2d3f12b47afde12e0bcd54b42ba467 /engines/sci/engine
parentbf0860fc5e2013883292dc8efabde1e2f919d9d7 (diff)
downloadscummvm-rg350-170916201c2dd8b75dccefb9a39c6fee572a4ec9.tar.gz
scummvm-rg350-170916201c2dd8b75dccefb9a39c6fee572a4ec9.tar.bz2
scummvm-rg350-170916201c2dd8b75dccefb9a39c6fee572a4ec9.zip
SCI: Moved almost all files from include/ to other dirs; only include/engine.h remains
svn-id: r38920
Diffstat (limited to 'engines/sci/engine')
-rw-r--r--engines/sci/engine/game.cpp4
-rw-r--r--engines/sci/engine/gc.h2
-rw-r--r--engines/sci/engine/grammar.cpp2
-rw-r--r--engines/sci/engine/heapmgr.h113
-rw-r--r--engines/sci/engine/kernel.cpp2
-rw-r--r--engines/sci/engine/kernel.h2
-rw-r--r--engines/sci/engine/kernel_types.h2
-rw-r--r--engines/sci/engine/kgraphics.cpp2
-rw-r--r--engines/sci/engine/kmenu.cpp2
-rw-r--r--engines/sci/engine/kmovement.cpp2
-rw-r--r--engines/sci/engine/kscripts.cpp2
-rw-r--r--engines/sci/engine/kstring.cpp2
-rw-r--r--engines/sci/engine/message.h2
-rw-r--r--engines/sci/engine/script.h224
-rw-r--r--engines/sci/engine/scriptdebug.cpp16
-rw-r--r--engines/sci/engine/vm.cpp4
-rw-r--r--engines/sci/engine/vm.h6
-rw-r--r--engines/sci/engine/vm_types.h64
18 files changed, 427 insertions, 26 deletions
diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp
index 2252573ccb..68e86b48f6 100644
--- a/engines/sci/engine/game.cpp
+++ b/engines/sci/engine/game.cpp
@@ -26,9 +26,9 @@
#include "common/system.h"
#include "common/file.h"
-#include "sci/include/sciresource.h"
+#include "sci/scicore/resource.h"
#include "sci/include/engine.h"
-#include "sci/include/versions.h"
+#include "sci/scicore/versions.h"
#include "sci/engine/kernel.h"
#include "sci/engine/kernel_types.h"
#include "sci/gfx/gfx_widgets.h"
diff --git a/engines/sci/engine/gc.h b/engines/sci/engine/gc.h
index 094d4669d9..c0d9c1cfe2 100644
--- a/engines/sci/engine/gc.h
+++ b/engines/sci/engine/gc.h
@@ -28,7 +28,7 @@
#define SCI_ENGINE_GC_H
#include "common/hashmap.h"
-#include "sci/include/vm_types.h"
+#include "sci/engine/vm_types.h"
#include "sci/include/engine.h"
namespace Sci {
diff --git a/engines/sci/engine/grammar.cpp b/engines/sci/engine/grammar.cpp
index 899defa373..ceab5df8e6 100644
--- a/engines/sci/engine/grammar.cpp
+++ b/engines/sci/engine/grammar.cpp
@@ -29,7 +29,7 @@
*/
#include "sci/tools.h"
-#include "sci/include/vocabulary.h"
+#include "sci/scicore/vocabulary.h"
#include "sci/scicore/sciconsole.h"
namespace Sci {
diff --git a/engines/sci/engine/heapmgr.h b/engines/sci/engine/heapmgr.h
new file mode 100644
index 0000000000..70e963ce80
--- /dev/null
+++ b/engines/sci/engine/heapmgr.h
@@ -0,0 +1,113 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+/* Heap-like managed structure */
+
+#ifndef SCI_ENGINE_HEAPMGR_H
+#define SCI_ENGINE_HEAPMGR_H
+
+#include "sci/tools.h"
+#include "sci/sci_memory.h"
+
+namespace Sci {
+
+#define HEAPENTRY_INVALID -1
+
+// FIXME: We write (i == 0 || i > 0) instead of (i >= 0) to silence certain annoying warnings:
+// generated by GCC: "comparison is always true due to limited range of data type".
+#define ENTRY_IS_VALID(t, i) ((i == 0 || i > 0) && (i) < (t)->max_entry && (t)->table[(i)].next_free == (i))
+
+#define DECLARE_HEAPENTRY(ENTRY) \
+typedef struct { \
+ int next_free; /* Only used for free entries */ \
+ ENTRY##_t entry; \
+} ENTRY##_entry_t; \
+ \
+typedef struct { \
+ int entries_nr; /* Number of entries allocated */ \
+ int first_free; /* Beginning of a singly linked list for entries */ \
+ int entries_used; /* Statistical information */ \
+ int max_entry; /* Highest entry used */ \
+ ENTRY##_entry_t *table; \
+} ENTRY##_table_t; \
+ \
+void init_##ENTRY##_table(ENTRY##_table_t *table); \
+int alloc_##ENTRY##_entry(ENTRY##_table_t *table); \
+void free_##ENTRY##_entry(ENTRY##_table_t *table, int index);
+
+
+
+#define DEFINE_HEAPENTRY_WITH_CLEANUP(ENTRY, INITIAL, INCREMENT, CLEANUP_FN) \
+void init_##ENTRY##_table(ENTRY##_table_t *table) { \
+ table->entries_nr = INITIAL; \
+ table->max_entry = 0; \
+ table->entries_used = 0; \
+ table->first_free = HEAPENTRY_INVALID; \
+ table->table = (ENTRY##_entry_t *)sci_malloc(sizeof(ENTRY##_entry_t) * INITIAL);\
+ memset(table->table, 0, sizeof(ENTRY##_entry_t) * INITIAL); \
+} \
+ \
+void free_##ENTRY##_entry(ENTRY##_table_t *table, int index) { \
+ ENTRY##_entry_t *e = table->table + index; \
+ \
+ if (index < 0 || index >= table->max_entry) { \
+ fprintf(stderr, "heapmgr: Attempt to release" \
+ " invalid table index %d!\n", index); \
+ BREAKPOINT(); \
+ } \
+ CLEANUP_FN(&(e->entry)); \
+ \
+ e->next_free = table->first_free; \
+ table->first_free = index; \
+ table->entries_used--; \
+} \
+ \
+int alloc_##ENTRY##_entry(ENTRY##_table_t *table) { \
+ table->entries_used++; \
+ if (table->first_free != HEAPENTRY_INVALID) { \
+ int oldff = table->first_free; \
+ table->first_free = table->table[oldff].next_free; \
+ \
+ table->table[oldff].next_free = oldff; \
+ return oldff; \
+ } else { \
+ if (table->max_entry == table->entries_nr) { \
+ table->entries_nr += INCREMENT; \
+ \
+ table->table = (ENTRY##_entry_t*)sci_realloc(table->table,\
+ sizeof(ENTRY##_entry_t) * table->entries_nr); \
+ memset(&table->table[table->entries_nr-INCREMENT], 0, INCREMENT*sizeof(ENTRY##_entry_t)); \
+ } \
+ table->table[table->max_entry].next_free = table->max_entry; /* Tag as 'valid' */ \
+ return table->max_entry++; \
+ } \
+}
+
+#define _HEAPENTRY_IGNORE_ME(x)
+#define DEFINE_HEAPENTRY(e, i, p) DEFINE_HEAPENTRY_WITH_CLEANUP(e, i, p, _HEAPENTRY_IGNORE_ME)
+
+} // End of namespace Sci
+
+#endif // SCI_ENGINE_HEAPMGR_H
diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp
index d163b2c48c..55b593ed7b 100644
--- a/engines/sci/engine/kernel.cpp
+++ b/engines/sci/engine/kernel.cpp
@@ -31,7 +31,7 @@
#include "sci/engine/intmap.h"
#include "sci/engine/gc.h"
#include "sci/engine/kernel.h"
-#include "sci/include/sciresource.h"
+#include "sci/scicore/resource.h"
#include "sci/include/engine.h"
#include "sci/gfx/operations.h"
#include "sci/engine/kernel_types.h"
diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h
index e3cb8ad1c9..a9f21dfa18 100644
--- a/engines/sci/engine/kernel.h
+++ b/engines/sci/engine/kernel.h
@@ -30,7 +30,7 @@
#include "common/debug.h"
#include "sci/engine/kdebug.h"
-#include "sci/include/uinput.h"
+#include "sci/uinput.h"
#include "sci/scicore/sciconsole.h" /* sciprintf() */
namespace Sci {
diff --git a/engines/sci/engine/kernel_types.h b/engines/sci/engine/kernel_types.h
index 576ba37d3a..24478c9119 100644
--- a/engines/sci/engine/kernel_types.h
+++ b/engines/sci/engine/kernel_types.h
@@ -26,7 +26,7 @@
#ifndef SCI_ENGINE_KERNEL_TYPES_H
#define SCI_ENGINE_KERNEL_TYPES_H
-#include "sci/include/vm_types.h"
+#include "sci/engine/vm_types.h"
namespace Sci {
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp
index f062ac78b9..e210e20158 100644
--- a/engines/sci/engine/kgraphics.cpp
+++ b/engines/sci/engine/kgraphics.cpp
@@ -25,7 +25,7 @@
#include "common/system.h"
-#include "sci/include/sciresource.h"
+#include "sci/scicore/resource.h"
#include "sci/include/engine.h"
#include "sci/gfx/sci_widgets.h"
#include "sci/gfx/gfx_widgets.h"
diff --git a/engines/sci/engine/kmenu.cpp b/engines/sci/engine/kmenu.cpp
index 061c90e18c..88458bfaa4 100644
--- a/engines/sci/engine/kmenu.cpp
+++ b/engines/sci/engine/kmenu.cpp
@@ -23,7 +23,7 @@
*
*/
-#include "sci/include/sciresource.h"
+#include "sci/scicore/resource.h"
#include "sci/include/engine.h"
#include "sci/gfx/sci_widgets.h"
#include "sci/gfx/menubar.h"
diff --git a/engines/sci/engine/kmovement.cpp b/engines/sci/engine/kmovement.cpp
index 114ddaa1a2..3b175e4592 100644
--- a/engines/sci/engine/kmovement.cpp
+++ b/engines/sci/engine/kmovement.cpp
@@ -23,7 +23,7 @@
*
*/
-#include "sci/include/sciresource.h"
+#include "sci/scicore/resource.h"
#include "sci/include/engine.h"
#include "sci/engine/kernel.h"
diff --git a/engines/sci/engine/kscripts.cpp b/engines/sci/engine/kscripts.cpp
index b6f2df2104..88b3dbbc9d 100644
--- a/engines/sci/engine/kscripts.cpp
+++ b/engines/sci/engine/kscripts.cpp
@@ -23,7 +23,7 @@
*
*/
-#include "sci/include/sciresource.h"
+#include "sci/scicore/resource.h"
#include "sci/include/engine.h"
#include "sci/engine/kernel_types.h"
#include "sci/engine/kernel.h"
diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp
index 242300cb21..8327eef539 100644
--- a/engines/sci/engine/kstring.cpp
+++ b/engines/sci/engine/kstring.cpp
@@ -25,7 +25,7 @@
/* String and parser handling */
-#include "sci/include/sciresource.h"
+#include "sci/scicore/resource.h"
#include "sci/include/engine.h"
#include "sci/engine/message.h"
#include "sci/engine/kernel.h"
diff --git a/engines/sci/engine/message.h b/engines/sci/engine/message.h
index f63575f5ab..dd41b5a7f9 100644
--- a/engines/sci/engine/message.h
+++ b/engines/sci/engine/message.h
@@ -26,7 +26,7 @@
#ifndef SCI_ENGINE_MESSAGE_H
#define SCI_ENGINE_MESSAGE_H
-#include "sci/include/sciresource.h"
+#include "sci/scicore/resource.h"
namespace Sci {
diff --git a/engines/sci/engine/script.h b/engines/sci/engine/script.h
new file mode 100644
index 0000000000..d30a0cd41b
--- /dev/null
+++ b/engines/sci/engine/script.h
@@ -0,0 +1,224 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef SCI_ENGINE_SCRIPT_H
+#define SCI_ENGINE_SCRIPT_H
+
+#include "common/str.h"
+
+namespace Sci {
+
+struct EngineState;
+struct ResourceManager;
+
+/*#define SCRIPT_DEBUG */
+
+#define SCI_SCRIPTS_NR 1000
+
+struct script_opcode {
+ unsigned opcode;
+ int arg1, arg2, arg3;
+ int pos, size;
+};
+
+
+enum script_object_types {
+ sci_obj_terminator,
+ sci_obj_object,
+ sci_obj_code,
+ sci_obj_synonyms,
+ sci_obj_said,
+ sci_obj_strings,
+ sci_obj_class,
+ sci_obj_exports,
+ sci_obj_pointers,
+ sci_obj_preload_text, /* This is really just a flag. */
+ sci_obj_localvars
+};
+
+void script_dissect(ResourceManager *resmgr, int res_no, const Common::StringList &selectorNames);
+
+/* Opcode formats as used by script.c */
+enum opcode_format {
+ Script_Invalid = -1,
+ Script_None = 0,
+ Script_Byte,
+ Script_SByte,
+ Script_Word,
+ Script_SWord,
+ Script_Variable,
+ Script_SVariable,
+ Script_SRelative,
+ Script_Property,
+ Script_Global,
+ Script_Local,
+ Script_Temp,
+ Script_Param,
+ Script_Offset,
+ Script_End
+};
+
+enum sci_opcodes { /* FIXME */
+ op_bnot = 0,
+ op_add,
+ op_sub,
+ op_mul,
+ op_div,
+ op_mod,
+ op_shr,
+ op_shl,
+ op_xor,
+ op_and,
+ op_or,
+ op_neg,
+ op_not,
+ op_eq,
+ op_ne_,
+ op_gt_,
+ op_ge_,
+ op_lt_,
+ op_le_,
+ op_ugt_,
+ op_uge_,
+ op_ult_,
+ op_ule_,
+ op_bt,
+ op_bnt,
+ op_jmp,
+ op_ldi,
+ op_push,
+ op_pushi,
+ op_toss,
+ op_dup,
+ op_link,
+ op_call = 0x20,
+ op_callk,
+ op_callb,
+ op_calle,
+ op_ret,
+ op_send,
+ op_class = 0x28,
+ op_self = 0x2a,
+ op_super,
+ op_rest,
+ op_lea,
+ op_selfID,
+ op_pprev = 0x30,
+ op_pToa,
+ op_aTop,
+ op_pTos,
+ op_sTop,
+ op_ipToa,
+ op_dpToa,
+ op_ipTos,
+ op_dpTos,
+ op_lofsa,
+ op_lofss,
+ op_push0,
+ op_push1,
+ op_push2,
+ op_pushSelf,
+ op_lag = 0x40,
+ op_lal,
+ op_lat,
+ op_lap,
+ op_lagi,
+ op_lali,
+ op_lati,
+ op_lapi,
+ op_lsg,
+ op_lsl,
+ op_lst,
+ op_lsp,
+ op_lsgi,
+ op_lsli,
+ op_lsti,
+ op_lspi,
+ op_sag,
+ op_sal,
+ op_sat,
+ op_sap,
+ op_sagi,
+ op_sali,
+ op_sati,
+ op_sapi,
+ op_ssg,
+ op_ssl,
+ op_sst,
+ op_ssp,
+ op_ssgi,
+ op_ssli,
+ op_ssti,
+ op_sspi,
+ op_plusag,
+ op_plusal,
+ op_plusat,
+ op_plusap,
+ op_plusagi,
+ op_plusali,
+ op_plusati,
+ op_plusapi,
+ op_plussg,
+ op_plussl,
+ op_plusst,
+ op_plussp,
+ op_plussgi,
+ op_plussli,
+ op_plussti,
+ op_plusspi,
+ op_minusag,
+ op_minusal,
+ op_minusat,
+ op_minusap,
+ op_minusagi,
+ op_minusali,
+ op_minusati,
+ op_minusapi,
+ op_minussg,
+ op_minussl,
+ op_minusst,
+ op_minussp,
+ op_minussgi,
+ op_minussli,
+ op_minussti,
+ op_minusspi
+};
+
+extern opcode_format formats[128][4];
+
+void script_adjust_opcode_formats(int res_version);
+
+int script_find_selector(EngineState *s, const char *selector_name);
+/* Determines the selector ID of a selector by its name
+** Parameters: (state_t *) s: VM state
+** (char *) selector_name: Name of the selector to look up
+** Returns : (int) The appropriate selector ID, or -1 on error
+*/
+
+void script_free_breakpoints(EngineState *s);
+
+} // End of namespace Sci
+
+#endif // SCI_ENGINE_SCRIPT_H
diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp
index 6e89868db2..1551edab59 100644
--- a/engines/sci/engine/scriptdebug.cpp
+++ b/engines/sci/engine/scriptdebug.cpp
@@ -25,18 +25,18 @@
// Script debugger functionality. Absolutely not threadsafe.
-#include "sci/engine/gc.h"
-#include "sci/include/sciresource.h"
+#include "sci/sci.h"
#include "sci/include/engine.h"
-#include "sci/scicore/sciconsole.h"
+#include "sci/engine/gc.h"
#include "sci/engine/kdebug.h"
-#include "sci/include/vocabulary.h"
-#include "sci/engine/kernel.h"
#include "sci/engine/kernel_types.h"
-#include "sci/include/sci_midi.h"
-#include "sci/gfx/sci_widgets.h"
-#include "sci/sci.h"
+#include "sci/engine/kernel.h"
#include "sci/gfx/gfx_widgets.h"
+#include "sci/gfx/sci_widgets.h"
+#include "sci/scicore/resource.h"
+#include "sci/scicore/sciconsole.h"
+#include "sci/scicore/vocabulary.h"
+#include "sci/sfx/sci_midi.h"
#include "common/util.h"
#include "common/savefile.h"
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp
index d6f1afc45d..250f78f2cc 100644
--- a/engines/sci/engine/vm.cpp
+++ b/engines/sci/engine/vm.cpp
@@ -25,9 +25,9 @@
#include "common/debug.h"
-#include "sci/include/sciresource.h"
+#include "sci/scicore/resource.h"
#include "sci/include/engine.h"
-#include "sci/include/versions.h"
+#include "sci/scicore/versions.h"
#include "sci/engine/intmap.h"
#include "sci/engine/kdebug.h"
#include "sci/engine/kernel.h"
diff --git a/engines/sci/engine/vm.h b/engines/sci/engine/vm.h
index 50d2032b44..bd71dc6438 100644
--- a/engines/sci/engine/vm.h
+++ b/engines/sci/engine/vm.h
@@ -28,9 +28,9 @@
/* VM and kernel declarations */
-#include "sci/include/versions.h" // for sci_version_t
-#include "sci/include/vm_types.h" // for reg_t
-#include "sci/include/heapmgr.h"
+#include "sci/scicore/versions.h" // for sci_version_t
+#include "sci/engine/vm_types.h" // for reg_t
+#include "sci/engine/heapmgr.h"
namespace Sci {
diff --git a/engines/sci/engine/vm_types.h b/engines/sci/engine/vm_types.h
new file mode 100644
index 0000000000..016ab7504a
--- /dev/null
+++ b/engines/sci/engine/vm_types.h
@@ -0,0 +1,64 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef SCI_ENGINE_VM_TYPES_H
+#define SCI_ENGINE_VM_TYPES_H
+
+#include "common/scummsys.h"
+
+namespace Sci {
+
+typedef int seg_id_t; /* Segment ID type */
+
+struct reg_t {
+ uint16 segment;
+ uint16 offset;
+};
+
+#define PREG "%04x:%04x"
+#define PRINT_REG(r) (0xffff) & (unsigned) (r).segment, (unsigned) (r).offset
+
+typedef reg_t *stack_ptr_t; /* Stack pointer type */
+typedef int selector_t; /* Selector ID */
+#define NULL_SELECTOR -1
+
+#define PSTK "ST:%04x"
+#define PRINT_STK(v) (unsigned) (v - s->stack_base)
+
+static inline reg_t make_reg(int segment, int offset) {
+ reg_t r;
+ r.offset = offset;
+ r.segment = segment;
+ return r;
+}
+
+#define IS_NULL_REG(r) (!((r).offset || (r).segment))
+#define REG_EQ(a, b) (((a).offset == (b).offset) && ((a).segment == (b).segment))
+#define NULL_REG_INITIALIZER {0, 0}
+extern reg_t NULL_REG;
+
+} // End of namespace Sci
+
+#endif // SCI_ENGINE_VM_TYPES_H