From 170916201c2dd8b75dccefb9a39c6fee572a4ec9 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 27 Feb 2009 02:23:00 +0000 Subject: SCI: Moved almost all files from include/ to other dirs; only include/engine.h remains svn-id: r38920 --- engines/sci/console.cpp | 4 +- engines/sci/detection.cpp | 2 +- engines/sci/engine/game.cpp | 4 +- engines/sci/engine/gc.h | 2 +- engines/sci/engine/grammar.cpp | 2 +- engines/sci/engine/heapmgr.h | 113 +++++++++ engines/sci/engine/kernel.cpp | 2 +- engines/sci/engine/kernel.h | 2 +- engines/sci/engine/kernel_types.h | 2 +- engines/sci/engine/kgraphics.cpp | 2 +- engines/sci/engine/kmenu.cpp | 2 +- engines/sci/engine/kmovement.cpp | 2 +- engines/sci/engine/kscripts.cpp | 2 +- engines/sci/engine/kstring.cpp | 2 +- engines/sci/engine/message.h | 2 +- engines/sci/engine/script.h | 224 +++++++++++++++++ engines/sci/engine/scriptdebug.cpp | 16 +- engines/sci/engine/vm.cpp | 4 +- engines/sci/engine/vm.h | 6 +- engines/sci/engine/vm_types.h | 64 +++++ engines/sci/exereader.cpp | 2 +- engines/sci/gfx/gfx_driver.h | 2 +- engines/sci/gfx/menubar.h | 2 +- engines/sci/gfx/operations.h | 2 +- engines/sci/gfx/resource/sci_resmgr.cpp | 2 +- engines/sci/include/engine.h | 8 +- engines/sci/include/heapmgr.h | 113 --------- engines/sci/include/sci_midi.h | 55 ----- engines/sci/include/sciresource.h | 423 -------------------------------- engines/sci/include/script.h | 224 ----------------- engines/sci/include/uinput.h | 127 ---------- engines/sci/include/versions.h | 147 ----------- engines/sci/include/vm_types.h | 64 ----- engines/sci/include/vocabulary.h | 399 ------------------------------ engines/sci/sci.h | 2 +- engines/sci/scicore/decompress0.cpp | 2 +- engines/sci/scicore/decompress01.cpp | 2 +- engines/sci/scicore/decompress1.cpp | 2 +- engines/sci/scicore/decompress11.cpp | 2 +- engines/sci/scicore/resource.cpp | 4 +- engines/sci/scicore/resource.h | 423 ++++++++++++++++++++++++++++++++ engines/sci/scicore/resource_map.cpp | 2 +- engines/sci/scicore/resource_patch.cpp | 2 +- engines/sci/scicore/sciconsole.h | 2 +- engines/sci/scicore/script.cpp | 2 +- engines/sci/scicore/versions.cpp | 2 +- engines/sci/scicore/versions.h | 147 +++++++++++ engines/sci/scicore/vocab.cpp | 3 +- engines/sci/scicore/vocab_debug.cpp | 2 +- engines/sci/scicore/vocabulary.h | 398 ++++++++++++++++++++++++++++++ engines/sci/sfx/core.cpp | 2 +- engines/sci/sfx/sci_midi.h | 55 +++++ engines/sci/sfx/seq/instrument-map.cpp | 2 +- engines/sci/sfx/seq/map-mt32-to-gm.cpp | 2 +- engines/sci/sfx/sfx_engine.h | 2 +- engines/sci/sfx/sfx_iterator_internal.h | 2 +- engines/sci/sfx/sfx_player.h | 2 +- engines/sci/sfx/softseq/SN76496.cpp | 2 +- engines/sci/sfx/softseq/pcspeaker.cpp | 2 +- engines/sci/uinput.h | 124 ++++++++++ 60 files changed, 1609 insertions(+), 1612 deletions(-) create mode 100644 engines/sci/engine/heapmgr.h create mode 100644 engines/sci/engine/script.h create mode 100644 engines/sci/engine/vm_types.h delete mode 100644 engines/sci/include/heapmgr.h delete mode 100644 engines/sci/include/sci_midi.h delete mode 100644 engines/sci/include/sciresource.h delete mode 100644 engines/sci/include/script.h delete mode 100644 engines/sci/include/uinput.h delete mode 100644 engines/sci/include/versions.h delete mode 100644 engines/sci/include/vm_types.h delete mode 100644 engines/sci/include/vocabulary.h create mode 100644 engines/sci/scicore/resource.h create mode 100644 engines/sci/scicore/versions.h create mode 100644 engines/sci/scicore/vocabulary.h create mode 100644 engines/sci/sfx/sci_midi.h create mode 100644 engines/sci/uinput.h (limited to 'engines/sci') diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp index 30ae55f801..558121f133 100644 --- a/engines/sci/console.cpp +++ b/engines/sci/console.cpp @@ -27,8 +27,8 @@ #include "sci/sci.h" #include "sci/console.h" -#include "sci/include/sciresource.h" -#include "sci/include/versions.h" +#include "sci/scicore/resource.h" +#include "sci/scicore/versions.h" namespace Sci { diff --git a/engines/sci/detection.cpp b/engines/sci/detection.cpp index 375d999c28..8112d8a446 100644 --- a/engines/sci/detection.cpp +++ b/engines/sci/detection.cpp @@ -28,7 +28,7 @@ #include "sci/sci.h" #include "sci/exereader.h" -#include "sci/include/versions.h" +#include "sci/scicore/versions.h" namespace Sci { 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 diff --git a/engines/sci/exereader.cpp b/engines/sci/exereader.cpp index 61f0e556dc..773c6a377c 100644 --- a/engines/sci/exereader.cpp +++ b/engines/sci/exereader.cpp @@ -26,7 +26,7 @@ #include "common/endian.h" #include "sci/exereader.h" -#include "sci/include/versions.h" +#include "sci/scicore/versions.h" namespace Sci { diff --git a/engines/sci/gfx/gfx_driver.h b/engines/sci/gfx/gfx_driver.h index 343d0199d0..38451ad3ef 100644 --- a/engines/sci/gfx/gfx_driver.h +++ b/engines/sci/gfx/gfx_driver.h @@ -27,7 +27,7 @@ #define SCI_GFX_GFX_DRIVER_H #include "sci/gfx/gfx_system.h" -#include "sci/include/uinput.h" +#include "sci/uinput.h" namespace Sci { diff --git a/engines/sci/gfx/menubar.h b/engines/sci/gfx/menubar.h index 5255ccb96a..2ccd6f8a5e 100644 --- a/engines/sci/gfx/menubar.h +++ b/engines/sci/gfx/menubar.h @@ -28,7 +28,7 @@ #ifndef SCI_GFX_SCI_MENUBAR_H #define SCI_GFX_SCI_MENUBAR_H -#include "sci/include/vm_types.h" +#include "sci/engine/vm_types.h" #include "sci/gfx/operations.h" #include "sci/gfx/gfx_widgets.h" diff --git a/engines/sci/gfx/operations.h b/engines/sci/gfx/operations.h index decd90e077..1928baf3a3 100644 --- a/engines/sci/gfx/operations.h +++ b/engines/sci/gfx/operations.h @@ -32,7 +32,7 @@ #include "sci/gfx/gfx_tools.h" #include "sci/gfx/gfx_options.h" #include "sci/gfx/gfx_system.h" -#include "sci/include/uinput.h" +#include "sci/uinput.h" #include "common/list.h" diff --git a/engines/sci/gfx/resource/sci_resmgr.cpp b/engines/sci/gfx/resource/sci_resmgr.cpp index 4e2b1e2410..a3817a4947 100644 --- a/engines/sci/gfx/resource/sci_resmgr.cpp +++ b/engines/sci/gfx/resource/sci_resmgr.cpp @@ -26,7 +26,7 @@ // The interpreter-specific part of the resource manager, for SCI #include "sci/sci_memory.h" -#include "sci/include/sciresource.h" +#include "sci/scicore/resource.h" #include "sci/gfx/gfx_widgets.h" #include "sci/gfx/gfx_resmgr.h" #include "sci/gfx/gfx_options.h" diff --git a/engines/sci/include/engine.h b/engines/sci/include/engine.h index 8035b16025..8d49b0b184 100644 --- a/engines/sci/include/engine.h +++ b/engines/sci/include/engine.h @@ -34,11 +34,11 @@ namespace Common { class WriteStream; } -#include "sci/include/vocabulary.h" -#include "sci/include/sciresource.h" -#include "sci/include/script.h" +#include "sci/scicore/vocabulary.h" +#include "sci/scicore/resource.h" +#include "sci/engine/script.h" #include "sci/scicore/sciconsole.h" -#include "sci/include/versions.h" +#include "sci/scicore/versions.h" #include "sci/engine/seg_manager.h" #include "sci/gfx/gfx_state_internal.h" #include "sci/sfx/sfx_engine.h" diff --git a/engines/sci/include/heapmgr.h b/engines/sci/include/heapmgr.h deleted file mode 100644 index 074dfc695e..0000000000 --- a/engines/sci/include/heapmgr.h +++ /dev/null @@ -1,113 +0,0 @@ -/* 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_INCLUDE_HEAPMGR_H -#define SCI_INCLUDE_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_INCLUDE_HEAPMGR_H diff --git a/engines/sci/include/sci_midi.h b/engines/sci/include/sci_midi.h deleted file mode 100644 index 6996cd29b3..0000000000 --- a/engines/sci/include/sci_midi.h +++ /dev/null @@ -1,55 +0,0 @@ -/* 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_INCLUDE_MIDI_H -#define SCI_INCLUDE_MIDI_H - -namespace Sci { - -#define MIDI_RHYTHM_CHANNEL 9 - -/* Special SCI sound stuff */ - -#define SCI_MIDI_TIME_EXPANSION_PREFIX 0xF8 -#define SCI_MIDI_TIME_EXPANSION_LENGTH 240 - -#define SCI_MIDI_EOT 0xFC -#define SCI_MIDI_SET_SIGNAL 0xCF -#define SCI_MIDI_SET_POLYPHONY 0x4B -#define SCI_MIDI_RESET_ON_SUSPEND 0x4C -#define SCI_MIDI_CHANNEL_MUTE 0x4E -#define SCI_MIDI_SET_REVERB 0x50 -#define SCI_MIDI_HOLD 0x52 -#define SCI_MIDI_CUMULATIVE_CUE 0x60 -#define SCI_MIDI_CHANNEL_NOTES_OFF 0x7B /* all-notes-off for Bn */ - -#define SCI_MIDI_SET_SIGNAL_LOOP 0x7F -/* If this is the parameter of 0xCF, the loop point is set here */ - -#define SCI_MIDI_CONTROLLER(status) ((status & 0xF0) == 0xB0) - -} // End of namespace Sci - -#endif // SCI_INCLUDE_MIDI_H diff --git a/engines/sci/include/sciresource.h b/engines/sci/include/sciresource.h deleted file mode 100644 index f7efc4c50c..0000000000 --- a/engines/sci/include/sciresource.h +++ /dev/null @@ -1,423 +0,0 @@ -/* 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_INCLUDE_SCIRESOURCE_H -#define SCI_INCLUDE_SCIRESOURCE_H - -#include "common/str.h" - -namespace Common { - class ReadStream; -} - -namespace Sci { - -/** The maximum allowed size for a compressed or decompressed resource */ -#define SCI_MAX_RESOURCE_SIZE 0x0400000 - -/*** RESOURCE STATUS TYPES ***/ -#define SCI_STATUS_NOMALLOC 0 -#define SCI_STATUS_ALLOCATED 1 -#define SCI_STATUS_ENQUEUED 2 /* In the LRU queue */ -#define SCI_STATUS_LOCKED 3 /* Allocated and in use */ - -#define SCI_RES_FILE_NR_PATCH -1 /* Resource was read from a patch file rather than from a resource */ - - -/*** INITIALIZATION RESULT TYPES ***/ -#define SCI_ERROR_IO_ERROR 1 -#define SCI_ERROR_EMPTY_OBJECT 2 -#define SCI_ERROR_INVALID_RESMAP_ENTRY 3 -/* Invalid resource.map entry */ -#define SCI_ERROR_RESMAP_NOT_FOUND 4 -#define SCI_ERROR_NO_RESOURCE_FILES_FOUND 5 -/* No resource at all was found */ -#define SCI_ERROR_UNKNOWN_COMPRESSION 6 -#define SCI_ERROR_DECOMPRESSION_OVERFLOW 7 -/* decompression failed: Buffer overflow (wrong SCI version?) */ -#define SCI_ERROR_DECOMPRESSION_INSANE 8 -/* sanity checks failed during decompression */ -#define SCI_ERROR_RESOURCE_TOO_BIG 9 -/* Resource size exceeds SCI_MAX_RESOURCE_SIZE */ -#define SCI_ERROR_UNSUPPORTED_VERSION 10 -#define SCI_ERROR_INVALID_SCRIPT_VERSION 11 - -#define SCI_ERROR_CRITICAL SCI_ERROR_NO_RESOURCE_FILES_FOUND -/* the first critical error number */ - -/*** SCI VERSION NUMBERS ***/ -#define SCI_VERSION_AUTODETECT 0 -#define SCI_VERSION_0 1 -#define SCI_VERSION_01 2 -#define SCI_VERSION_01_VGA 3 -#define SCI_VERSION_01_VGA_ODD 4 -#define SCI_VERSION_1_EARLY 5 -#define SCI_VERSION_1_LATE 6 -#define SCI_VERSION_1_1 7 -#define SCI_VERSION_32 8 -#define SCI_VERSION_LAST SCI_VERSION_1_LATE /* The last supported SCI version */ - -#define SCI_VERSION_1 SCI_VERSION_1_EARLY - -enum ResourceType { - RESSOURCE_TYPE_DIRECTORY = 0, - RESSOURCE_TYPE_VOLUME = 2, - RESSOURCE_TYPE_EXTERNAL_MAP = 3, - RESSOURCE_TYPE_INTERNAL_MAP = 4, - RESSOURCE_TYPE_MASK = 127 -}; - -#define RESSOURCE_ADDRESSING_BASIC 0 -#define RESSOURCE_ADDRESSING_EXTENDED 128 -#define RESSOURCE_ADDRESSING_MASK 128 - -extern const char* sci_error_types[]; -extern const char* sci_version_types[]; -extern const char* sci_resource_types[]; -extern const char* sci_resource_type_suffixes[]; /* Suffixes for SCI1 patch files */ -extern const int sci_max_resource_nr[]; /* Highest possible resource numbers */ - - -enum ResourceTypes { - sci_view = 0, sci_pic, sci_script, sci_text, - sci_sound, sci_memory, sci_vocab, sci_font, - sci_cursor, sci_patch, sci_bitmap, sci_palette, - sci_cdaudio, sci_audio, sci_sync, sci_message, - sci_map, sci_heap, sci_invalid_resource -}; - -#define sci0_last_resource sci_patch -#define sci1_last_resource sci_heap -/* Used for autodetection */ - - -struct resource_index_struct { - unsigned short resource_id; - unsigned int resource_location; -}; /* resource type as stored in the resource.map file */ - -typedef struct resource_index_struct resource_index_t; - -struct ResourceSource { - ResourceType source_type; - bool scanned; - Common::String location_name; // FIXME: Replace by FSNode ? - Common::String location_dir_name; // FIXME: Get rid of this again, only a temporary HACK! - int volume_number; - ResourceSource *associated_map; - ResourceSource *next; -}; - -struct resource_altsource_t { - ResourceSource *source; - unsigned int file_offset; - resource_altsource_t *next; -}; - - -/** Struct for storing resources in memory */ -struct resource_t { - unsigned char *data; - - unsigned short number; - unsigned short type; - uint16 id; /* contains number and type */ - - unsigned int size; - - unsigned int file_offset; /* Offset in file */ - ResourceSource *source; - - unsigned char status; - unsigned short lockers; /* Number of places where this resource was locked */ - - resource_t *next; /* Position marker for the LRU queue */ - resource_t *prev; - - resource_altsource_t *alt_sources; /* SLL of alternative resource data sources */ -}; - - -struct ResourceManager { - int _maxMemory; /* Config option: Maximum total byte number allocated */ - int sci_version; /* SCI resource version to use */ - - int _resourcesNr; - ResourceSource *_sources; - resource_t *_resources; - - int memory_locked; /* Amount of resource bytes in locked memory */ - int memory_lru; /* Amount of resource bytes under LRU control */ - - resource_t *lru_first, *lru_last; /* Pointers to the first and last LRU queue entries */ - /* LRU queue: lru_first points to the most recent entry */ - -public: - /** - * Creates a new FreeSCI resource manager. - * @param version The SCI version to look for; use SCI_VERSION_AUTODETECT - * in the default case. - * @param maxMemory Maximum number of bytes to allow allocated for resources - * - * @note maxMemory will not be interpreted as a hard limit, only as a restriction - * for resources which are not explicitly locked. However, a warning will be - * issued whenever this limit is exceeded. - */ - ResourceManager(int version, int maxMemory); - ~ResourceManager(); -}; - -/**** FUNCTION DECLARATIONS ****/ - -/**--- New Resource manager ---**/ - -ResourceSource *scir_add_patch_dir(ResourceManager *mgr, const char *path); -/* Add a path to the resource manager's list of sources. -** Parameters: (ResourceManager *) mgr: The resource manager to look up in -** (const char *) path: The path to add -** Returns: A pointer to the added source structure, or NULL if an error occurred. -*/ - -ResourceSource *scir_get_volume(ResourceManager *mgr, ResourceSource *map, int volume_nr); - -ResourceSource *scir_add_volume(ResourceManager *mgr, ResourceSource *map, const char *filename, - int number, int extended_addressing); -/* Add a volume to the resource manager's list of sources. -** Parameters: (ResourceManager *) mgr: The resource manager to look up in -** (ResourceSource *) map: The map associated with this volume -** (char *) filename: The name of the volume to add -** (int) extended_addressing: 1 if this volume uses extended addressing, -** 0 otherwise. -** Returns: A pointer to the added source structure, or NULL if an error occurred. -*/ - -ResourceSource *scir_add_external_map(ResourceManager *mgr, const char *file_name); -/* Add an external (i.e. separate file) map resource to the resource manager's list of sources. -** Parameters: (ResourceManager *) mgr: The resource manager to look up in -** (const char *) file_name: The name of the volume to add -** Returns: A pointer to the added source structure, or NULL if an error occurred. -*/ - -int scir_scan_new_sources(ResourceManager *mgr, int *detected_version); -/* Scans newly registered resource sources for resources, earliest addition first. -** Parameters: (ResourceManager *) mgr: The resource manager to look up in -** (int *) detected_version: Pointer to the detected version number, -** used during startup. May be NULL. -** Returns: One of SCI_ERROR_*. -*/ - -resource_t *scir_find_resource(ResourceManager *mgr, int type, int number, int lock); -/* Looks up a resource's data -** Parameters: (ResourceManager *) mgr: The resource manager to look up in -** (int) type: The resource type to look for -** (int) number: The resource number to search -** (int) lock: non-zero iff the resource should be locked -** Returns : (resource_t *): The resource, or NULL if it doesn't exist -** Locked resources are guaranteed not to have their contents freed until -** they are unlocked explicitly (by scir_unlock_resource). -*/ - -void scir_unlock_resource(ResourceManager *mgr, resource_t *res, int restype, int resnum); -/* Unlocks a previously locked resource -** Parameters: (ResourceManager *) mgr: The manager the resource should be freed from -** (resource_t *) res: The resource to free -** (int) type: Type of the resource to check (for error checking) -** (int) number: Number of the resource to check (ditto) -** Returns : (void) -*/ - -resource_t *scir_test_resource(ResourceManager *mgr, int type, int number); -/* Tests whether a resource exists -** Parameters: (ResourceManager *) mgr: The resource manager to search in -** (int) type: Type of the resource to check -** (int) number: Number of the resource to check -** Returns : (resource_t *) non-NULL if the resource exists, NULL otherwise -** This function may often be much faster than finding the resource -** and should be preferred for simple tests. -** The resource object returned is, indeed, the resource in question, but -** it should be used with care, as it may be unallocated. -** Use scir_find_resource() if you want to use the data contained in the resource. -*/ - -/**--- Resource map decoding functions ---*/ - -int sci0_read_resource_map(ResourceManager *mgr, ResourceSource *map, resource_t **resources, int *resource_nr_p, int *sci_version); -/* Reads the SCI0 resource.map file from a local directory -** Parameters: (char *) path: (unused) -** (resource_t **) resources: Pointer to a pointer -** that will be set to the -** location of the resources -** (in one large chunk) -** (int *) resource_nr_p: Pointer to an int the number of resources -** read is stored in -** (int) sci_version: SCI resource version -** Returns : (int) 0 on success, an SCI_ERROR_* code otherwise -*/ - -int sci1_read_resource_map(ResourceManager *mgr, ResourceSource *map, ResourceSource *vol, - resource_t **resource_p, int *resource_nr_p, int *sci_version); -/* Reads the SCI1 resource.map file from a local directory -** Parameters: (char *) path: (unused) -** (resource_t **) resources: Pointer to a pointer -** that will be set to the -** location of the resources -** (in one large chunk) -** (int *) resource_nr_p: Pointer to an int the number of resources -** read is stored in -** (int) sci_version: SCI resource version -** Returns : (int) 0 on success, an SCI_ERROR_* code otherwise -*/ - -/**--- Patch management functions ---*/ - -void sci0_sprintf_patch_file_name(char *string, resource_t *res); -/* Prints the name of a matching patch to a string buffer -** Parameters: (char *) string: The buffer to print to -** (resource_t *) res: Resource containing the number and type of the -** resource whose name is to be print -** Returns : (void) -*/ - -void sci1_sprintf_patch_file_name(char *string, resource_t *res); -/* Prints the name of a matching patch to a string buffer -** Parameters: (char *) string: The buffer to print to -** (resource_t *) res: Resource containing the number and type of the -** resource whose name is to be print -** Returns : (void) -*/ - -int sci0_read_resource_patches(ResourceSource *source, resource_t **resources, int *resource_nr_p); -/* Reads SCI0 patch files from a local directory -** Parameters: (char *) path: (unused) -** (resource_t **) resources: Pointer to a pointer -** that will be set to the -** location of the resources -** (in one large chunk) -** (int *) resource_nr_p: Pointer to an int the number of resources -** read is stored in -** Returns : (int) 0 on success, an SCI_ERROR_* code otherwise -*/ - -int sci1_read_resource_patches(ResourceSource *source, resource_t **resources, int *resource_nr_p); -/* Reads SCI1 patch files from a local directory -** Parameters: (char *) path: (unused) -** (resource_t **) resources: Pointer to a pointer -** that will be set to the -** location of the resources -** (in one large chunk) -** (int *) resource_nr_p: Pointer to an int the number of resources -** read is stored in -** Returns : (int) 0 on success, an SCI_ERROR_* code otherwise -*/ - - -/**--- Decompression functions ---**/ - - -int decompress0(resource_t *result, Common::ReadStream &stream, int sci_version); -/* Decrypts resource data and stores the result for SCI0-style compression. -** Parameters : result: The resource_t the decompressed data is stored in. -** stream: Stream of the resource file -** sci_version : Actual SCI resource version -** Returns : (int) 0 on success, one of SCI_ERROR_* if a problem was -** encountered. -*/ - -int decompress01(resource_t *result, Common::ReadStream &stream, int sci_version); -/* Decrypts resource data and stores the result for SCI01-style compression. -** Parameters : result: The resource_t the decompressed data is stored in. -** stream: Stream of the resource file -** sci_version : Actual SCI resource version -** Returns : (int) 0 on success, one of SCI_ERROR_* if a problem was -** encountered. -*/ - -int decompress1(resource_t *result, Common::ReadStream &stream, int sci_version); -/* Decrypts resource data and stores the result for SCI1.1-style compression. -** Parameters : result: The resource_t the decompressed data is stored in. -** sci_version : Actual SCI resource version -** stream: Stream of the resource file -** Returns : (int) 0 on success, one of SCI_ERROR_* if a problem was -** encountered. -*/ - - -int decompress11(resource_t *result, Common::ReadStream &stream, int sci_version); -/* Decrypts resource data and stores the result for SCI1.1-style compression. -** Parameters : result: The resource_t the decompressed data is stored in. -** sci_version : Actual SCI resource version -** stream: Stream of the resource file -** Returns : (int) 0 on success, one of SCI_ERROR_* if a problem was -** encountered. -*/ - - -int decrypt2(uint8* dest, uint8* src, int length, int complength); -/* Huffman token decryptor - defined in decompress0.c and used in decompress01.c -*/ - -int decrypt4(uint8* dest, uint8* src, int length, int complength); -/* DCL inflate- implemented in decompress1.c -*/ - -byte *view_reorder(byte *inbuffer, int dsize); -/* SCI1 style view compression */ - -byte *pic_reorder(byte *inbuffer, int dsize); -/* SCI1 style pic compression */ - -/*--- Internal helper functions ---*/ - -void _scir_free_resources(resource_t *resources, int _resourcesNr); -/* Frees a block of resources and associated data -** Parameters: (resource_t *) resources: The resources to free -** (int) _resourcesNr: Number of resources in the block -** Returns : (void) -*/ - -resource_t *_scir_find_resource_unsorted(resource_t *res, int res_nr, int type, int number); -/* Finds a resource matching type.number in an unsorted resource_t block -** To be used during initial resource loading, when the resource list -** may not have been sorted yet. -** Parameters: (resource_t *) res: Pointer to the block to search in -** (int) res_nr: Number of resource_t structs allocated and defined -** in the block pointed to by res -** (int) type: Type of the resource to look for -** (int) number: Number of the resource to look for -** Returns : (resource_t) The matching resource entry, or NULL if not found -*/ - -void _scir_add_altsource(resource_t *res, ResourceSource *source, unsigned int file_offset); -/* Adds an alternative source to a resource -** Parameters: (resource_t *) res: The resource to add to -** (ResourceSource *) source: The source of the resource -** (unsigned int) file_offset: Offset in the file the resource -** is stored at -** Returns : (void) -*/ - -} // End of namespace Sci - -#endif // SCI_INCLUDE_SCIRESOURCE_H diff --git a/engines/sci/include/script.h b/engines/sci/include/script.h deleted file mode 100644 index 51b535b903..0000000000 --- a/engines/sci/include/script.h +++ /dev/null @@ -1,224 +0,0 @@ -/* 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_INCLUDE_SCRIPT_H -#define SCI_INCLUDE_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_INCLUDE_SCRIPT_H diff --git a/engines/sci/include/uinput.h b/engines/sci/include/uinput.h deleted file mode 100644 index 5c003f3c06..0000000000 --- a/engines/sci/include/uinput.h +++ /dev/null @@ -1,127 +0,0 @@ -/* 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$ - * - */ - -/* unified input header file */ - -#ifndef SCI_INCLUDE_UINPUT_H -#define SCI_INCLUDE_UINPUT_H - - -namespace Sci { - -#define SCI_INPUT_DEFAULT_CLOCKTIME 100000 -#define SCI_INPUT_DEFAULT_REDRAWTIME 30000 - - -struct sci_event_t { - short type; - short data; - short buckybits; - short character; /* for keyboard events: 'data' after applying - ** the effects of 'buckybits', e.g. if - ** type == SCI_EVT_KEYBOARD - ** data == 'a' - ** buckybits == SCI_EVM_LSHIFT - ** then - ** character == 'A' - ** For 'Alt', characters are interpreted by their - ** PC keyboard scancodes. - */ -}; - -/*Values for type*/ -#define SCI_EVT_NONE 0 -#define SCI_EVT_MOUSE_PRESS (1<<0) -#define SCI_EVT_MOUSE_RELEASE (1<<1) -#define SCI_EVT_KEYBOARD (1<<2) -#define SCI_EVT_JOYSTICK (1<<6) -#define SCI_EVT_SAID (1<<7) -/*Fake values for other events*/ -#define SCI_EVT_ERROR (1<<10) -#define SCI_EVT_QUIT (1<<11) -#define SCI_EVT_PEEK (1<<15) -/* The QUIT event may be used to signal an external 'quit' command being -** issued to the gfx driver. */ -#define SCI_EVT_ANY 0x7fff - - - -/* Keycodes of special keys: */ -#define SCI_K_ESC 27 -#define SCI_K_BACKSPACE 8 -#define SCI_K_ENTER 13 -#define SCI_K_TAB '\t' -#define SCI_K_SHIFT_TAB (0xf << 8) - -#define SCI_K_END (79 << 8) -#define SCI_K_DOWN (80 << 8) -#define SCI_K_PGDOWN (81 << 8) -#define SCI_K_LEFT (75 << 8) -#define SCI_K_CENTER (76 << 8) -#define SCI_K_RIGHT (77 << 8) -#define SCI_K_HOME (71 << 8) -#define SCI_K_UP (72 << 8) -#define SCI_K_PGUP (73 << 8) -#define SCI_K_INSERT (82 << 8) -#define SCI_K_DELETE (83 << 8) - -#define SCI_K_F1 (59<<8) -#define SCI_K_F2 (60<<8) -#define SCI_K_F3 (61<<8) -#define SCI_K_F4 (62<<8) -#define SCI_K_F5 (63<<8) -#define SCI_K_F6 (64<<8) -#define SCI_K_F7 (65<<8) -#define SCI_K_F8 (66<<8) -#define SCI_K_F9 (67<<8) -#define SCI_K_F10 (68<<8) - -#define SCI_K_SHIFT_F1 (84<<8) -#define SCI_K_SHIFT_F2 (85<<8) -#define SCI_K_SHIFT_F3 (86<<8) -#define SCI_K_SHIFT_F4 (87<<8) -#define SCI_K_SHIFT_F5 (88<<8) -#define SCI_K_SHIFT_F6 (89<<8) -#define SCI_K_SHIFT_F7 (90<<8) -#define SCI_K_SHIFT_F8 (91<<8) -#define SCI_K_SHIFT_F9 (92<<8) -#define SCI_K_SHIFT_F10 (93<<8) - -/*Values for buckybits */ -#define SCI_EVM_RSHIFT (1<<0) -#define SCI_EVM_LSHIFT (1<<1) -#define SCI_EVM_CTRL (1<<2) -#define SCI_EVM_ALT (1<<3) -#define SCI_EVM_SCRLOCK (1<<4) -#define SCI_EVM_NUMLOCK (1<<5) -#define SCI_EVM_CAPSLOCK (1<<6) -#define SCI_EVM_INSERT (1<<7) - -#define SCI_EVM_NO_FOOLOCK (~(SCI_EVM_SCRLOCK | SCI_EVM_NUMLOCK | SCI_EVM_CAPSLOCK | SCI_EVM_INSERT)) -#define SCI_EVM_ALL 0xFF - -} // End of namespace Sci - -#endif // SCI_INCLUDE_UINPUT_H diff --git a/engines/sci/include/versions.h b/engines/sci/include/versions.h deleted file mode 100644 index 716135577e..0000000000 --- a/engines/sci/include/versions.h +++ /dev/null @@ -1,147 +0,0 @@ -/* 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$ - * - */ - -/* Versions management */ - -#ifndef SCI_INCLUDE_VERSIONS_H -#define SCI_INCLUDE_VERSIONS_H - -namespace Sci { - -#define SCI_VERSION(_major_, _minor_, _patchlevel_) (((_major_)<<20) | ((_minor_)<<10) | _patchlevel_) -/* This allows version numbers to be compared directly */ - -#define SCI_VERSION_MAJOR(_version_) ((_version_) >> 20) -#define SCI_VERSION_MINOR(_version_) (((_version_) >> 10) & 0x3ff) -#define SCI_VERSION_PATCHLEVEL(_version_) ((_version_) & 0x3ff) -#define SCI_VERSION_IGNORE_PATCHLEVEL(_version_) ((_version) & ~0x3ff) - -/* Version number guide: -** - Always use the version number of the first known version to have a special feature. -** - Don't assume that special feature changes are linked just because they appeared to change -** simultaneously. -** - Put all the magic version numbers here, into THIS file. -** - "FTU" means "First To Use" -*/ - -#define SCI_VERSION_LAST_SCI0 SCI_VERSION(0,000,685) - -#define SCI_VERSION_DEFAULT_SCI0 SCI_VERSION_LAST_SCI0 -/* AFAIK this is the last published SCI0 version */ -#define SCI_VERSION_DEFAULT_SCI01 SCI_VERSION(1,000,72) -/* The version used by my implementation of QfG2 */ - - -#define SCI_VERSION_FTU_CENTERED_TEXT_AS_DEFAULT SCI_VERSION(0,000,629) -/* Last version known not to do this: 0.000.502 */ - -#define SCI_VERSION_FTU_NEW_GETTIME SCI_VERSION(0,000,629) -/* These versions of SCI has a different set of subfunctions in GetTime() */ - -#define SCI_VERSION_FTU_NEWER_DRAWPIC_PARAMETERS SCI_VERSION(0,000,502) -/* Last version known not to do this: 0.000.435 -** Old SCI versions used to interpret the third DrawPic() parameter inversely, -** with the opposite default value (obviously) -*/ - -#define SCI_VERSION_FTU_PRIORITY_14_ZONES SCI_VERSION(0,000,502) -/* Last version known to do this: 0.000.490 - * Uses 14 zones from 42 to 190 instead of 15 zones from 42 to 200. -*/ - - -#define SCI_VERSION_FTU_NEW_SCRIPT_HEADER SCI_VERSION(0,000,395) -/* Last version known not to do this: 0.000.343 -** Old SCI versions used two word header for script blocks (first word equal -** to 0x82, meaning of the second one unknown). New SCI versions used one -** word header. -*/ - -#define SCI_VERSION_LTU_BASE_OB1 SCI_VERSION(0,000,256) -/* First version version known not to have this bug: ? -** When doing CanBeHere(), augment y offset by 1 -*/ - -#define SCI_VERSION_FTU_2ND_ANGLES SCI_VERSION(0,000,395) -/* Last version known not to use this: ? -** Earlier versions assign 120 degrees to left & right , and 60 to up and down. -** Later versions use an even 90 degree distribution. -*/ - -#define SCI_VERSION_RESUME_SUSPENDED_SONG SCI_VERSION(0,000,490) -/* First version (PQ2-new) known to use the different song resumption - mechanism -- When a new song is initialized, we store its state and - resume it when the new one finishes. Older versions completely - clobbered the old songs. -*/ - -#define SCI_VERSION_FTU_INVERSE_CANBEHERE SCI_VERSION(1,000,510) -/* FIXME: This shouldn't be a version number. - * But it'll do for now. - */ - -#define SCI_VERSION_FTU_LOFS_ABSOLUTE SCI_VERSION(1,000,200) -/* First version known to do this: ? - In later versions (SCI1 and beyond), the argument of lofs[as] - instructions is absolute rather than relative. -*/ - -#define SCI_VERSION_FTU_DISPLAY_COORDS_FUZZY SCI_VERSION(1,000,510) -/* First version known to do this: ? - In later versions of SCI1 kDisplay(), if the text would not fit on - the screen, the text is moved to the left and upwards until it - fits. -*/ - -#define SCI_VERSION_FTU_DOSOUND_VARIANT_1 SCI_VERSION(1,000,000) -#define SCI_VERSION_FTU_DOSOUND_VARIANT_2 SCI_VERSION(1,000,510) - - -typedef int sci_version_t; - -struct EngineState; - -void version_require_earlier_than(EngineState *s, sci_version_t version); -/* Function used in autodetection -** Parameters: (EngineState *) s: EngineState containing the version -** (sci_version_t) version: The version that we're earlier than -*/ - -void version_require_later_than(EngineState *s, sci_version_t version); -/* Function used in autodetection (read this function "version_require_later_than_or_equal_to") -** Parameters: (EngineState *) s: EngineState containing the version -** (sci_version_t) version: The version that we're later than -*/ - -int version_parse(const char *vn, sci_version_t *result); -/* Parse a string containing an SCI version number -** Parameters: (char *) vn: The string to parse -** Returns : (int) 0 on success, 1 on failure -** (sci_version_t) *result: The resulting version number on success -*/ - -} // End of namespace Sci - -#endif // SCI_INCLUDE_VERSIONS_H diff --git a/engines/sci/include/vm_types.h b/engines/sci/include/vm_types.h deleted file mode 100644 index 60de6a3108..0000000000 --- a/engines/sci/include/vm_types.h +++ /dev/null @@ -1,64 +0,0 @@ -/* 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_INCLUDE_VM_TYPES_H -#define SCI_INCLUDE_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_INCLUDE_VM_TYPES_H diff --git a/engines/sci/include/vocabulary.h b/engines/sci/include/vocabulary.h deleted file mode 100644 index 5af4487b74..0000000000 --- a/engines/sci/include/vocabulary.h +++ /dev/null @@ -1,399 +0,0 @@ -/* 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_INCLUDE_VOCABULARY_H -#define SCI_INCLUDE_VOCABULARY_H - -#include "common/str.h" - -#include "sci/include/versions.h" - -namespace Sci { - -struct ResourceManager; - -/*#define VOCABULARY_DEBUG */ -/*#define SCI_SIMPLE_SAID_CODE */ /* Whether the simplified Said() matching should be used */ -/*#define SCI_SIMPLE_SAID_DEBUG */ /* uncomment to enable simple said debugging */ - - -#define SCRIPT_UNKNOWN_FUNCTION_STRING "[Unknown]" -/* The string used to identify the "unknown" SCI0 function for each game */ - -#define PARSE_HEAP_SIZE 64 -/* Number of bytes allocated on the heap to store bad words if parsing fails */ - - -struct opcode { - int type; - int number; - char* name; -}; - -#define VOCAB_RESOURCE_OPCODES 998 -#define VOCAB_RESOURCE_KNAMES 999 - -#define VOCAB_RESOURCE_SCI0_MAIN_VOCAB 0 -#define VOCAB_RESOURCE_SCI0_PARSE_TREE_BRANCHES 900 -#define VOCAB_RESOURCE_SCI0_SUFFIX_VOCAB 901 - -#define VOCAB_RESOURCE_SCI1_MAIN_VOCAB 900 -#define VOCAB_RESOURCE_SCI1_PARSE_TREE_BRANCHES 901 -#define VOCAB_RESOURCE_SCI1_SUFFIX_VOCAB 902 -#define VOCAB_RESOURCE_SCI1_CHAR_TRANSFORMS 913 - -#define VOCAB_CLASS_PREPOSITION 0x01 -#define VOCAB_CLASS_ARTICLE 0x02 -#define VOCAB_CLASS_ADJECTIVE 0x04 -#define VOCAB_CLASS_PRONOUN 0x08 -#define VOCAB_CLASS_NOUN 0x10 -#define VOCAB_CLASS_INDICATIVE_VERB 0x20 -#define VOCAB_CLASS_ADVERB 0x40 -#define VOCAB_CLASS_IMPERATIVE_VERB 0x80 -#define VOCAB_CLASS_NUMBER 0x001 - -extern const char *class_names[]; /* Vocabulary class names */ - -#define VOCAB_CLASS_ANYWORD 0xff -/* Anywords are ignored by the parser */ - -#define VOCAB_MAGIC_NUMBER_GROUP 0xffd /* 0xffe ? */ -/* This word class is used for numbers */ - -#define VOCAB_TREE_NODES 500 -/* Number of nodes for each parse_tree_node structure */ - -#define VOCAB_TREE_NODE_LAST_WORD_STORAGE 0x140 -#define VOCAB_TREE_NODE_COMPARE_TYPE 0x146 -#define VOCAB_TREE_NODE_COMPARE_GROUP 0x14d -#define VOCAB_TREE_NODE_FORCE_STORAGE 0x154 - -#define SAID_COMMA 0xf0 -#define SAID_AMP 0xf1 -#define SAID_SLASH 0xf2 -#define SAID_PARENO 0xf3 -#define SAID_PARENC 0xf4 -#define SAID_BRACKO 0xf5 -#define SAID_BRACKC 0xf6 -#define SAID_HASH 0xf7 -#define SAID_LT 0xf8 -#define SAID_GT 0xf9 -#define SAID_TERM 0xff - -#define SAID_FIRST SAID_COMMA - -/* There was no 'last matching word': */ -#define SAID_FULL_MATCH 0xffff -#define SAID_NO_MATCH 0xfffe -#define SAID_PARTIAL_MATCH 0xfffd - -#define SAID_LONG(x) ((x) << 8) - -struct word_t { - - int w_class; /* Word class */ - int group; /* Word group */ - char word[1]; /* The actual word */ - -}; - - -struct parse_rule_t { - int id; /* non-terminal ID */ - int first_special; /* first terminal or non-terminal */ - int specials_nr; /* number of terminals and non-terminals */ - int length; - int data[1]; /* actual data (size 1 to avoid compiler warnings) */ -}; - - -struct parse_rule_list_t { - int terminal; /* Terminal character this rule matches against or 0 for a non-terminal rule */ - parse_rule_t *rule; - parse_rule_list_t *next; -}; - - -struct suffix_t { - - int class_mask; /* the word class this suffix applies to */ - int result_class; /* the word class a word is morphed to if it doesn't fail this check */ - - int alt_suffix_length; /* String length of the suffix */ - int word_suffix_length; /* String length of the other suffix */ - - char *alt_suffix; /* The alternative suffix */ - char *word_suffix; /* The suffix as used in the word vocabulary */ - -}; - - -struct result_word_t { - - int w_class; /* Word class */ - int group; /* Word group */ - -}; - - -struct synonym_t { - int replaceant; /* The word group to replace */ - int replacement; /* The replacement word group for this one */ -}; - - -struct parse_tree_branch_t { - - int id; - - int data[10]; - -}; - -#define PARSE_TREE_NODE_LEAF 0 -#define PARSE_TREE_NODE_BRANCH 1 - - -struct parse_tree_node_t { - - short type; /* leaf or branch */ - - union { - - int value; /* For leaves */ - short branches[2]; /* For branches */ - - } content; - -}; - - - - -/*FIXME: These need freeing functions...*/ - -int *vocabulary_get_classes(ResourceManager *resmgr, int *count); - -int vocabulary_get_class_count(ResourceManager *resmgr); - -/** - * Fills the given StringList with selector names. - * Returns true upon success, false oterwise. - */ -bool vocabulary_get_snames(ResourceManager *resmgr, sci_version_t version, Common::StringList &selectorNames); - -/* Look up a selector name in an array, return the index */ -int vocabulary_lookup_sname(const Common::StringList &selectorNames, const char *sname); - - -/** - * Returns a null terminated array of opcodes. - */ -opcode *vocabulary_get_opcodes(ResourceManager *resmgr); - -void vocabulary_free_opcodes(opcode *opcodes); -/* Frees a previously allocated list of opcodes -** Parameters: (opcode *) opcodes: Opcodes to free -** Returns : (void) -*/ - -/** - * Returns a null terminated array of kernel function names. - * - * This function reads the kernel function name table from resource_map, - * and returns a null terminated array of deep copies of them. - * The returned array has the same format regardless of the format of the - * name table of the resource (the format changed between version 0 and 1). - */ -char **vocabulary_get_knames(ResourceManager *resmgr, int* count); -void vocabulary_free_knames(char** names); - - - -word_t **vocab_get_words(ResourceManager *resmgr, int *word_counter); -/* Gets all words from the main vocabulary -** Parameters: (ResourceManager *) resmr: The resource manager to read from -** (int *) word_counter: The int which the number of words is stored in -** Returns : (word_t **): A list of all words, dynamically allocated -*/ - - -void -vocab_free_words(word_t **words, int words_nr); -/* Frees memory allocated by vocab_get_words -** Parameters: (word_t **) words: The words to free -** (int) words_nr: Number of words in the structure -** Returns : (void) -*/ - - -suffix_t **vocab_get_suffices(ResourceManager *resmgr, int *suffices_nr); -/* Gets all suffixes from the suffix vocabulary -** Parameters: (ResourceManager*) resmgr: Resource manager the resources are -** read from -** (int *) suffices_nr: The variable to store the number of suffices in -** Returns : (suffix_t **): A list of suffixes -*/ - -void vocab_free_suffices(ResourceManager *resmgr, suffix_t **suffices, int suffices_nr); -/* Frees suffices_nr suffices -** Parameters: (ResourceManager *) resmgr: The resource manager to free from -** (suffix_t **) suffices: The suffixes to free -** (int) suffices_nr: Number of entrie sin suffices -** Returns : (void) -*/ - -parse_tree_branch_t *vocab_get_branches(ResourceManager *resmgr, int *branches_nr); -/* Retrieves all grammar rules from the resource data -** Parameters: (ResourceManager*) resmgr: Resource manager the rules are -** read from -** (int *) branches_nr: Pointer to the variable which the number of entries is to be -** stored in -** Returns : (parse_tree_branch_t *): The rules, or NULL on error -*/ - -void vocab_free_branches(parse_tree_branch_t *parser_branches); -/* Frees all branches -** Parameters: (parse_tree_branch_t *) parser_branches: The branches to free -** Returns : (null) -*/ - -result_word_t *vocab_lookup_word(char *word, int word_len, - word_t **words, int words_nr, suffix_t **suffices, int suffices_nr); -/* Looks up a single word in the words and suffixes list -** Parameters: (char *) word: Pointer to the word to look up -** (int) word_len: Length of the word to look up -** (word_t **) words: List of words -** (int) words_nr: Number of elements in 'words' -** (suffix_t **) suffices: List of suffices -** (int) suffices_nr: Number of entries in 'suffices' -** Returns : (result_word_t *) A malloc'd result_word_t, or NULL if the word -** could not be found. -*/ - - -result_word_t *vocab_tokenize_string(char *sentence, int *result_nr, - word_t **words, int words_nr, suffix_t **suffices, int suffices_nr, char **error); -/* Tokenizes a string and compiles it into word_ts. -** Parameters: (char *) sentence: The sentence to examine -** (int *) result_nr: The variable to store the resulting number of words in -** (word_t **) words: The words to scan for -** (int) words_nr: Number of words to scan for -** (suffix_t **) suffices: suffixes to scan for -** (int) suffices_nr: Number of suffices to scan for -** (char **) error: Points to a malloc'd copy of the offending text or to NULL on error -** Returns : (word_t *): A list of word_ts containing the result, or NULL. -** On error, NULL is returned. If *error is NULL, the sentence did not contain any useful words; -** if not, *error points to a malloc'd copy of the offending word. -** The returned list may contain anywords. -*/ - - -parse_rule_list_t *vocab_build_gnf(parse_tree_branch_t *branches, int branches_nr); -/* Constructs the Greibach Normal Form of the grammar supplied in 'branches' -** Parameters: (parse_tree_branch_t *) branches: The parser's branches -** (int) branches_nr: Number of parser branches -** Returns : (parse_rule_list_t *): Pointer to a list of singly linked -** GNF rules describing the same language -** that was described by 'branches' -** The original SCI rules are in almost-CNF (Chomsky Normal Form). Note that -** branch[0] is used only for a few magical incantations, as it is treated -** specially by the SCI parser. -*/ - - -void vocab_free_rule_list(parse_rule_list_t *rule_list); -/* Frees a parser rule list as returned by vocab_build_gnf() -** Parameters: (parse_rule_list_t *) rule_list: The rule list to free -** Returns : (void) -*/ - - -int vocab_build_parse_tree(parse_tree_node_t *nodes, result_word_t *words, int words_nr, - parse_tree_branch_t *branch0, parse_rule_list_t *rules); -/* Builds a parse tree from a list of words -** Parameters: (parse_tree_node_t *) nodes: A node list to store the tree in (must have -** at least VOCAB_TREE_NODES entries) -** (result_word_t *) words: The words to build the tree from -** (int) words_nr: The number of words -** (parse_tree_branch_t *) branche0: The zeroeth original branch of the -** original CNF parser grammar -** (parse_rule_list *) rules: The GNF ruleset to parse with -** Returns : 0 on success, 1 if the tree couldn't be built in VOCAB_TREE_NODES nodes -** or if the sentence structure in 'words' is not part of the language -** described by the grammar passed in 'rules'. -*/ - -void vocab_dump_parse_tree(const char *tree_name, parse_tree_node_t *nodes); -/* Prints a parse tree -** Parameters: (const char *) tree_name: Name of the tree to dump (free-form) -** (parse_tree_node_t *) nodes: The nodes containing the parse tree -** Returns : (void) -*/ - - - - -int said(EngineState *s, byte *spec, int verbose); -/* Builds a parse tree from a spec and compares it to a parse tree -** Parameters: (EngineState *) s: The affected state -** (byte *) spec: Pointer to the spec to build -** (int) verbose: Whether to display the parse tree after building it -** Returns : (int) 1 on a match, 0 otherwise -*/ - -const char *vocab_get_any_group_word(int group, word_t **words, int words_nr); -/* Gets any word from the specified group. -** Parameters: (int) group: Group number. -** (word_t **) words: List of words -** (int) words_nr: Count of words in the list. -** For debugging only. -*/ - - -void vocab_decypher_said_block(EngineState *s, byte *pos); -/* Decyphers a said block and dumps its content via sciprintf. -** Parameters: (EngineState *) s: The state to use -** (byte *) pos: Pointer to the data to dump -** For debugging only. -*/ - - -void vocab_synonymize_tokens(result_word_t *words, int words_nr, synonym_t *synonyms, int synonyms_nr); -/* Synonymizes a token list -** Parameters: (result_wort_t *) words: The word list to synonymize -** (int) words_nr: Number of word_ts in the list -** (synonym_t *) synonyms: Synonym list -** (int) synonyms_nr: Number of synonyms in the list -*/ - -int vocab_gnf_parse(parse_tree_node_t *nodes, result_word_t *words, int words_nr, - parse_tree_branch_t *branch0, parse_rule_list_t *tlist, int verbose); - -void vocab_gnf_dump(parse_tree_branch_t *branches, int branches_nr); - -} // End of namespace Sci - -#endif // SCI_INCLUDE_VOCABULARY_H diff --git a/engines/sci/sci.h b/engines/sci/sci.h index 4d4ad53fb6..1764d9dfab 100644 --- a/engines/sci/sci.h +++ b/engines/sci/sci.h @@ -30,7 +30,7 @@ #include "engines/advancedDetector.h" #include "sci/console.h" -#include "sci/include/sciresource.h" +#include "sci/scicore/resource.h" namespace Sci { diff --git a/engines/sci/scicore/decompress0.cpp b/engines/sci/scicore/decompress0.cpp index 2f6bcd117f..bed2fab7cb 100644 --- a/engines/sci/scicore/decompress0.cpp +++ b/engines/sci/scicore/decompress0.cpp @@ -31,7 +31,7 @@ #include "common/endian.h" #include "sci/sci_memory.h" -#include "sci/include/sciresource.h" +#include "sci/scicore/resource.h" namespace Sci { diff --git a/engines/sci/scicore/decompress01.cpp b/engines/sci/scicore/decompress01.cpp index f318d7b197..effbec7e89 100644 --- a/engines/sci/scicore/decompress01.cpp +++ b/engines/sci/scicore/decompress01.cpp @@ -29,7 +29,7 @@ #include "common/endian.h" #include "sci/sci_memory.h" -#include "sci/include/sciresource.h" +#include "sci/scicore/resource.h" namespace Sci { diff --git a/engines/sci/scicore/decompress1.cpp b/engines/sci/scicore/decompress1.cpp index 7b9924f9ec..0b156272ba 100644 --- a/engines/sci/scicore/decompress1.cpp +++ b/engines/sci/scicore/decompress1.cpp @@ -29,7 +29,7 @@ #include "common/util.h" #include "sci/sci_memory.h" -#include "sci/include/sciresource.h" +#include "sci/scicore/resource.h" namespace Sci { diff --git a/engines/sci/scicore/decompress11.cpp b/engines/sci/scicore/decompress11.cpp index 13364be262..b7515d1aa2 100644 --- a/engines/sci/scicore/decompress11.cpp +++ b/engines/sci/scicore/decompress11.cpp @@ -28,7 +28,7 @@ #include "common/stream.h" #include "sci/sci_memory.h" -#include "sci/include/sciresource.h" +#include "sci/scicore/resource.h" namespace Sci { diff --git a/engines/sci/scicore/resource.cpp b/engines/sci/scicore/resource.cpp index dc58db5a5e..0081926311 100644 --- a/engines/sci/scicore/resource.cpp +++ b/engines/sci/scicore/resource.cpp @@ -31,8 +31,8 @@ #include "sci/tools.h" #include "sci/sci_memory.h" -#include "sci/include/sciresource.h" -#include "sci/include/vocabulary.h" +#include "sci/scicore/resource.h" +#include "sci/scicore/vocabulary.h" namespace Sci { diff --git a/engines/sci/scicore/resource.h b/engines/sci/scicore/resource.h new file mode 100644 index 0000000000..2b6c4b0474 --- /dev/null +++ b/engines/sci/scicore/resource.h @@ -0,0 +1,423 @@ +/* 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_SCICORE_RESOURCE_H +#define SCI_SCICORE_RESOURCE_H + +#include "common/str.h" + +namespace Common { + class ReadStream; +} + +namespace Sci { + +/** The maximum allowed size for a compressed or decompressed resource */ +#define SCI_MAX_RESOURCE_SIZE 0x0400000 + +/*** RESOURCE STATUS TYPES ***/ +#define SCI_STATUS_NOMALLOC 0 +#define SCI_STATUS_ALLOCATED 1 +#define SCI_STATUS_ENQUEUED 2 /* In the LRU queue */ +#define SCI_STATUS_LOCKED 3 /* Allocated and in use */ + +#define SCI_RES_FILE_NR_PATCH -1 /* Resource was read from a patch file rather than from a resource */ + + +/*** INITIALIZATION RESULT TYPES ***/ +#define SCI_ERROR_IO_ERROR 1 +#define SCI_ERROR_EMPTY_OBJECT 2 +#define SCI_ERROR_INVALID_RESMAP_ENTRY 3 +/* Invalid resource.map entry */ +#define SCI_ERROR_RESMAP_NOT_FOUND 4 +#define SCI_ERROR_NO_RESOURCE_FILES_FOUND 5 +/* No resource at all was found */ +#define SCI_ERROR_UNKNOWN_COMPRESSION 6 +#define SCI_ERROR_DECOMPRESSION_OVERFLOW 7 +/* decompression failed: Buffer overflow (wrong SCI version?) */ +#define SCI_ERROR_DECOMPRESSION_INSANE 8 +/* sanity checks failed during decompression */ +#define SCI_ERROR_RESOURCE_TOO_BIG 9 +/* Resource size exceeds SCI_MAX_RESOURCE_SIZE */ +#define SCI_ERROR_UNSUPPORTED_VERSION 10 +#define SCI_ERROR_INVALID_SCRIPT_VERSION 11 + +#define SCI_ERROR_CRITICAL SCI_ERROR_NO_RESOURCE_FILES_FOUND +/* the first critical error number */ + +/*** SCI VERSION NUMBERS ***/ +#define SCI_VERSION_AUTODETECT 0 +#define SCI_VERSION_0 1 +#define SCI_VERSION_01 2 +#define SCI_VERSION_01_VGA 3 +#define SCI_VERSION_01_VGA_ODD 4 +#define SCI_VERSION_1_EARLY 5 +#define SCI_VERSION_1_LATE 6 +#define SCI_VERSION_1_1 7 +#define SCI_VERSION_32 8 +#define SCI_VERSION_LAST SCI_VERSION_1_LATE /* The last supported SCI version */ + +#define SCI_VERSION_1 SCI_VERSION_1_EARLY + +enum ResourceType { + RESSOURCE_TYPE_DIRECTORY = 0, + RESSOURCE_TYPE_VOLUME = 2, + RESSOURCE_TYPE_EXTERNAL_MAP = 3, + RESSOURCE_TYPE_INTERNAL_MAP = 4, + RESSOURCE_TYPE_MASK = 127 +}; + +#define RESSOURCE_ADDRESSING_BASIC 0 +#define RESSOURCE_ADDRESSING_EXTENDED 128 +#define RESSOURCE_ADDRESSING_MASK 128 + +extern const char* sci_error_types[]; +extern const char* sci_version_types[]; +extern const char* sci_resource_types[]; +extern const char* sci_resource_type_suffixes[]; /* Suffixes for SCI1 patch files */ +extern const int sci_max_resource_nr[]; /* Highest possible resource numbers */ + + +enum ResourceTypes { + sci_view = 0, sci_pic, sci_script, sci_text, + sci_sound, sci_memory, sci_vocab, sci_font, + sci_cursor, sci_patch, sci_bitmap, sci_palette, + sci_cdaudio, sci_audio, sci_sync, sci_message, + sci_map, sci_heap, sci_invalid_resource +}; + +#define sci0_last_resource sci_patch +#define sci1_last_resource sci_heap +/* Used for autodetection */ + + +struct resource_index_struct { + unsigned short resource_id; + unsigned int resource_location; +}; /* resource type as stored in the resource.map file */ + +typedef struct resource_index_struct resource_index_t; + +struct ResourceSource { + ResourceType source_type; + bool scanned; + Common::String location_name; // FIXME: Replace by FSNode ? + Common::String location_dir_name; // FIXME: Get rid of this again, only a temporary HACK! + int volume_number; + ResourceSource *associated_map; + ResourceSource *next; +}; + +struct resource_altsource_t { + ResourceSource *source; + unsigned int file_offset; + resource_altsource_t *next; +}; + + +/** Struct for storing resources in memory */ +struct resource_t { + unsigned char *data; + + unsigned short number; + unsigned short type; + uint16 id; /* contains number and type */ + + unsigned int size; + + unsigned int file_offset; /* Offset in file */ + ResourceSource *source; + + unsigned char status; + unsigned short lockers; /* Number of places where this resource was locked */ + + resource_t *next; /* Position marker for the LRU queue */ + resource_t *prev; + + resource_altsource_t *alt_sources; /* SLL of alternative resource data sources */ +}; + + +struct ResourceManager { + int _maxMemory; /* Config option: Maximum total byte number allocated */ + int sci_version; /* SCI resource version to use */ + + int _resourcesNr; + ResourceSource *_sources; + resource_t *_resources; + + int memory_locked; /* Amount of resource bytes in locked memory */ + int memory_lru; /* Amount of resource bytes under LRU control */ + + resource_t *lru_first, *lru_last; /* Pointers to the first and last LRU queue entries */ + /* LRU queue: lru_first points to the most recent entry */ + +public: + /** + * Creates a new FreeSCI resource manager. + * @param version The SCI version to look for; use SCI_VERSION_AUTODETECT + * in the default case. + * @param maxMemory Maximum number of bytes to allow allocated for resources + * + * @note maxMemory will not be interpreted as a hard limit, only as a restriction + * for resources which are not explicitly locked. However, a warning will be + * issued whenever this limit is exceeded. + */ + ResourceManager(int version, int maxMemory); + ~ResourceManager(); +}; + +/**** FUNCTION DECLARATIONS ****/ + +/**--- New Resource manager ---**/ + +ResourceSource *scir_add_patch_dir(ResourceManager *mgr, const char *path); +/* Add a path to the resource manager's list of sources. +** Parameters: (ResourceManager *) mgr: The resource manager to look up in +** (const char *) path: The path to add +** Returns: A pointer to the added source structure, or NULL if an error occurred. +*/ + +ResourceSource *scir_get_volume(ResourceManager *mgr, ResourceSource *map, int volume_nr); + +ResourceSource *scir_add_volume(ResourceManager *mgr, ResourceSource *map, const char *filename, + int number, int extended_addressing); +/* Add a volume to the resource manager's list of sources. +** Parameters: (ResourceManager *) mgr: The resource manager to look up in +** (ResourceSource *) map: The map associated with this volume +** (char *) filename: The name of the volume to add +** (int) extended_addressing: 1 if this volume uses extended addressing, +** 0 otherwise. +** Returns: A pointer to the added source structure, or NULL if an error occurred. +*/ + +ResourceSource *scir_add_external_map(ResourceManager *mgr, const char *file_name); +/* Add an external (i.e. separate file) map resource to the resource manager's list of sources. +** Parameters: (ResourceManager *) mgr: The resource manager to look up in +** (const char *) file_name: The name of the volume to add +** Returns: A pointer to the added source structure, or NULL if an error occurred. +*/ + +int scir_scan_new_sources(ResourceManager *mgr, int *detected_version); +/* Scans newly registered resource sources for resources, earliest addition first. +** Parameters: (ResourceManager *) mgr: The resource manager to look up in +** (int *) detected_version: Pointer to the detected version number, +** used during startup. May be NULL. +** Returns: One of SCI_ERROR_*. +*/ + +resource_t *scir_find_resource(ResourceManager *mgr, int type, int number, int lock); +/* Looks up a resource's data +** Parameters: (ResourceManager *) mgr: The resource manager to look up in +** (int) type: The resource type to look for +** (int) number: The resource number to search +** (int) lock: non-zero iff the resource should be locked +** Returns : (resource_t *): The resource, or NULL if it doesn't exist +** Locked resources are guaranteed not to have their contents freed until +** they are unlocked explicitly (by scir_unlock_resource). +*/ + +void scir_unlock_resource(ResourceManager *mgr, resource_t *res, int restype, int resnum); +/* Unlocks a previously locked resource +** Parameters: (ResourceManager *) mgr: The manager the resource should be freed from +** (resource_t *) res: The resource to free +** (int) type: Type of the resource to check (for error checking) +** (int) number: Number of the resource to check (ditto) +** Returns : (void) +*/ + +resource_t *scir_test_resource(ResourceManager *mgr, int type, int number); +/* Tests whether a resource exists +** Parameters: (ResourceManager *) mgr: The resource manager to search in +** (int) type: Type of the resource to check +** (int) number: Number of the resource to check +** Returns : (resource_t *) non-NULL if the resource exists, NULL otherwise +** This function may often be much faster than finding the resource +** and should be preferred for simple tests. +** The resource object returned is, indeed, the resource in question, but +** it should be used with care, as it may be unallocated. +** Use scir_find_resource() if you want to use the data contained in the resource. +*/ + +/**--- Resource map decoding functions ---*/ + +int sci0_read_resource_map(ResourceManager *mgr, ResourceSource *map, resource_t **resources, int *resource_nr_p, int *sci_version); +/* Reads the SCI0 resource.map file from a local directory +** Parameters: (char *) path: (unused) +** (resource_t **) resources: Pointer to a pointer +** that will be set to the +** location of the resources +** (in one large chunk) +** (int *) resource_nr_p: Pointer to an int the number of resources +** read is stored in +** (int) sci_version: SCI resource version +** Returns : (int) 0 on success, an SCI_ERROR_* code otherwise +*/ + +int sci1_read_resource_map(ResourceManager *mgr, ResourceSource *map, ResourceSource *vol, + resource_t **resource_p, int *resource_nr_p, int *sci_version); +/* Reads the SCI1 resource.map file from a local directory +** Parameters: (char *) path: (unused) +** (resource_t **) resources: Pointer to a pointer +** that will be set to the +** location of the resources +** (in one large chunk) +** (int *) resource_nr_p: Pointer to an int the number of resources +** read is stored in +** (int) sci_version: SCI resource version +** Returns : (int) 0 on success, an SCI_ERROR_* code otherwise +*/ + +/**--- Patch management functions ---*/ + +void sci0_sprintf_patch_file_name(char *string, resource_t *res); +/* Prints the name of a matching patch to a string buffer +** Parameters: (char *) string: The buffer to print to +** (resource_t *) res: Resource containing the number and type of the +** resource whose name is to be print +** Returns : (void) +*/ + +void sci1_sprintf_patch_file_name(char *string, resource_t *res); +/* Prints the name of a matching patch to a string buffer +** Parameters: (char *) string: The buffer to print to +** (resource_t *) res: Resource containing the number and type of the +** resource whose name is to be print +** Returns : (void) +*/ + +int sci0_read_resource_patches(ResourceSource *source, resource_t **resources, int *resource_nr_p); +/* Reads SCI0 patch files from a local directory +** Parameters: (char *) path: (unused) +** (resource_t **) resources: Pointer to a pointer +** that will be set to the +** location of the resources +** (in one large chunk) +** (int *) resource_nr_p: Pointer to an int the number of resources +** read is stored in +** Returns : (int) 0 on success, an SCI_ERROR_* code otherwise +*/ + +int sci1_read_resource_patches(ResourceSource *source, resource_t **resources, int *resource_nr_p); +/* Reads SCI1 patch files from a local directory +** Parameters: (char *) path: (unused) +** (resource_t **) resources: Pointer to a pointer +** that will be set to the +** location of the resources +** (in one large chunk) +** (int *) resource_nr_p: Pointer to an int the number of resources +** read is stored in +** Returns : (int) 0 on success, an SCI_ERROR_* code otherwise +*/ + + +/**--- Decompression functions ---**/ + + +int decompress0(resource_t *result, Common::ReadStream &stream, int sci_version); +/* Decrypts resource data and stores the result for SCI0-style compression. +** Parameters : result: The resource_t the decompressed data is stored in. +** stream: Stream of the resource file +** sci_version : Actual SCI resource version +** Returns : (int) 0 on success, one of SCI_ERROR_* if a problem was +** encountered. +*/ + +int decompress01(resource_t *result, Common::ReadStream &stream, int sci_version); +/* Decrypts resource data and stores the result for SCI01-style compression. +** Parameters : result: The resource_t the decompressed data is stored in. +** stream: Stream of the resource file +** sci_version : Actual SCI resource version +** Returns : (int) 0 on success, one of SCI_ERROR_* if a problem was +** encountered. +*/ + +int decompress1(resource_t *result, Common::ReadStream &stream, int sci_version); +/* Decrypts resource data and stores the result for SCI1.1-style compression. +** Parameters : result: The resource_t the decompressed data is stored in. +** sci_version : Actual SCI resource version +** stream: Stream of the resource file +** Returns : (int) 0 on success, one of SCI_ERROR_* if a problem was +** encountered. +*/ + + +int decompress11(resource_t *result, Common::ReadStream &stream, int sci_version); +/* Decrypts resource data and stores the result for SCI1.1-style compression. +** Parameters : result: The resource_t the decompressed data is stored in. +** sci_version : Actual SCI resource version +** stream: Stream of the resource file +** Returns : (int) 0 on success, one of SCI_ERROR_* if a problem was +** encountered. +*/ + + +int decrypt2(uint8* dest, uint8* src, int length, int complength); +/* Huffman token decryptor - defined in decompress0.c and used in decompress01.c +*/ + +int decrypt4(uint8* dest, uint8* src, int length, int complength); +/* DCL inflate- implemented in decompress1.c +*/ + +byte *view_reorder(byte *inbuffer, int dsize); +/* SCI1 style view compression */ + +byte *pic_reorder(byte *inbuffer, int dsize); +/* SCI1 style pic compression */ + +/*--- Internal helper functions ---*/ + +void _scir_free_resources(resource_t *resources, int _resourcesNr); +/* Frees a block of resources and associated data +** Parameters: (resource_t *) resources: The resources to free +** (int) _resourcesNr: Number of resources in the block +** Returns : (void) +*/ + +resource_t *_scir_find_resource_unsorted(resource_t *res, int res_nr, int type, int number); +/* Finds a resource matching type.number in an unsorted resource_t block +** To be used during initial resource loading, when the resource list +** may not have been sorted yet. +** Parameters: (resource_t *) res: Pointer to the block to search in +** (int) res_nr: Number of resource_t structs allocated and defined +** in the block pointed to by res +** (int) type: Type of the resource to look for +** (int) number: Number of the resource to look for +** Returns : (resource_t) The matching resource entry, or NULL if not found +*/ + +void _scir_add_altsource(resource_t *res, ResourceSource *source, unsigned int file_offset); +/* Adds an alternative source to a resource +** Parameters: (resource_t *) res: The resource to add to +** (ResourceSource *) source: The source of the resource +** (unsigned int) file_offset: Offset in the file the resource +** is stored at +** Returns : (void) +*/ + +} // End of namespace Sci + +#endif // SCI_SCICORE_RESOURCE_H diff --git a/engines/sci/scicore/resource_map.cpp b/engines/sci/scicore/resource_map.cpp index e06fe11578..aa0932f8c9 100644 --- a/engines/sci/scicore/resource_map.cpp +++ b/engines/sci/scicore/resource_map.cpp @@ -24,7 +24,7 @@ */ #include "sci/sci_memory.h" -#include "sci/include/sciresource.h" +#include "sci/scicore/resource.h" #include "sci/tools.h" #include "common/file.h" diff --git a/engines/sci/scicore/resource_patch.cpp b/engines/sci/scicore/resource_patch.cpp index c062a2f782..25a36deb41 100644 --- a/engines/sci/scicore/resource_patch.cpp +++ b/engines/sci/scicore/resource_patch.cpp @@ -26,7 +26,7 @@ #include "common/archive.h" #include "common/file.h" -#include "sci/include/sciresource.h" +#include "sci/scicore/resource.h" #include "sci/sci_memory.h" namespace Sci { diff --git a/engines/sci/scicore/sciconsole.h b/engines/sci/scicore/sciconsole.h index 8ea75cc053..25b8907a50 100644 --- a/engines/sci/scicore/sciconsole.h +++ b/engines/sci/scicore/sciconsole.h @@ -36,7 +36,7 @@ #include "sci/sci_memory.h" #include "sci/tools.h" -#include "sci/include/vm_types.h" +#include "sci/engine/vm_types.h" #define SCI_CONSOLE #include "sci/gfx/operations.h" diff --git a/engines/sci/scicore/script.cpp b/engines/sci/scicore/script.cpp index 8f8aee23bd..879a0a7aff 100644 --- a/engines/sci/scicore/script.cpp +++ b/engines/sci/scicore/script.cpp @@ -23,7 +23,7 @@ * */ -#include "sci/include/sciresource.h" +#include "sci/scicore/resource.h" #include "sci/include/engine.h" #include "common/util.h" diff --git a/engines/sci/scicore/versions.cpp b/engines/sci/scicore/versions.cpp index 54bcc5acff..6d58c62147 100644 --- a/engines/sci/scicore/versions.cpp +++ b/engines/sci/scicore/versions.cpp @@ -28,7 +28,7 @@ #include "common/system.h" #include "common/config-manager.h" -#include "sci/include/versions.h" +#include "sci/scicore/versions.h" #include "sci/include/engine.h" #include "sci/tools.h" diff --git a/engines/sci/scicore/versions.h b/engines/sci/scicore/versions.h new file mode 100644 index 0000000000..fe11160449 --- /dev/null +++ b/engines/sci/scicore/versions.h @@ -0,0 +1,147 @@ +/* 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$ + * + */ + +/* Versions management */ + +#ifndef SCI_SCICORE_VERSIONS_H +#define SCI_SCICORE_VERSIONS_H + +namespace Sci { + +#define SCI_VERSION(_major_, _minor_, _patchlevel_) (((_major_)<<20) | ((_minor_)<<10) | _patchlevel_) +/* This allows version numbers to be compared directly */ + +#define SCI_VERSION_MAJOR(_version_) ((_version_) >> 20) +#define SCI_VERSION_MINOR(_version_) (((_version_) >> 10) & 0x3ff) +#define SCI_VERSION_PATCHLEVEL(_version_) ((_version_) & 0x3ff) +#define SCI_VERSION_IGNORE_PATCHLEVEL(_version_) ((_version) & ~0x3ff) + +/* Version number guide: +** - Always use the version number of the first known version to have a special feature. +** - Don't assume that special feature changes are linked just because they appeared to change +** simultaneously. +** - Put all the magic version numbers here, into THIS file. +** - "FTU" means "First To Use" +*/ + +#define SCI_VERSION_LAST_SCI0 SCI_VERSION(0,000,685) + +#define SCI_VERSION_DEFAULT_SCI0 SCI_VERSION_LAST_SCI0 +/* AFAIK this is the last published SCI0 version */ +#define SCI_VERSION_DEFAULT_SCI01 SCI_VERSION(1,000,72) +/* The version used by my implementation of QfG2 */ + + +#define SCI_VERSION_FTU_CENTERED_TEXT_AS_DEFAULT SCI_VERSION(0,000,629) +/* Last version known not to do this: 0.000.502 */ + +#define SCI_VERSION_FTU_NEW_GETTIME SCI_VERSION(0,000,629) +/* These versions of SCI has a different set of subfunctions in GetTime() */ + +#define SCI_VERSION_FTU_NEWER_DRAWPIC_PARAMETERS SCI_VERSION(0,000,502) +/* Last version known not to do this: 0.000.435 +** Old SCI versions used to interpret the third DrawPic() parameter inversely, +** with the opposite default value (obviously) +*/ + +#define SCI_VERSION_FTU_PRIORITY_14_ZONES SCI_VERSION(0,000,502) +/* Last version known to do this: 0.000.490 + * Uses 14 zones from 42 to 190 instead of 15 zones from 42 to 200. +*/ + + +#define SCI_VERSION_FTU_NEW_SCRIPT_HEADER SCI_VERSION(0,000,395) +/* Last version known not to do this: 0.000.343 +** Old SCI versions used two word header for script blocks (first word equal +** to 0x82, meaning of the second one unknown). New SCI versions used one +** word header. +*/ + +#define SCI_VERSION_LTU_BASE_OB1 SCI_VERSION(0,000,256) +/* First version version known not to have this bug: ? +** When doing CanBeHere(), augment y offset by 1 +*/ + +#define SCI_VERSION_FTU_2ND_ANGLES SCI_VERSION(0,000,395) +/* Last version known not to use this: ? +** Earlier versions assign 120 degrees to left & right , and 60 to up and down. +** Later versions use an even 90 degree distribution. +*/ + +#define SCI_VERSION_RESUME_SUSPENDED_SONG SCI_VERSION(0,000,490) +/* First version (PQ2-new) known to use the different song resumption + mechanism -- When a new song is initialized, we store its state and + resume it when the new one finishes. Older versions completely + clobbered the old songs. +*/ + +#define SCI_VERSION_FTU_INVERSE_CANBEHERE SCI_VERSION(1,000,510) +/* FIXME: This shouldn't be a version number. + * But it'll do for now. + */ + +#define SCI_VERSION_FTU_LOFS_ABSOLUTE SCI_VERSION(1,000,200) +/* First version known to do this: ? + In later versions (SCI1 and beyond), the argument of lofs[as] + instructions is absolute rather than relative. +*/ + +#define SCI_VERSION_FTU_DISPLAY_COORDS_FUZZY SCI_VERSION(1,000,510) +/* First version known to do this: ? + In later versions of SCI1 kDisplay(), if the text would not fit on + the screen, the text is moved to the left and upwards until it + fits. +*/ + +#define SCI_VERSION_FTU_DOSOUND_VARIANT_1 SCI_VERSION(1,000,000) +#define SCI_VERSION_FTU_DOSOUND_VARIANT_2 SCI_VERSION(1,000,510) + + +typedef int sci_version_t; + +struct EngineState; + +void version_require_earlier_than(EngineState *s, sci_version_t version); +/* Function used in autodetection +** Parameters: (EngineState *) s: EngineState containing the version +** (sci_version_t) version: The version that we're earlier than +*/ + +void version_require_later_than(EngineState *s, sci_version_t version); +/* Function used in autodetection (read this function "version_require_later_than_or_equal_to") +** Parameters: (EngineState *) s: EngineState containing the version +** (sci_version_t) version: The version that we're later than +*/ + +int version_parse(const char *vn, sci_version_t *result); +/* Parse a string containing an SCI version number +** Parameters: (char *) vn: The string to parse +** Returns : (int) 0 on success, 1 on failure +** (sci_version_t) *result: The resulting version number on success +*/ + +} // End of namespace Sci + +#endif // SCI_SCICORE_VERSIONS_H diff --git a/engines/sci/scicore/vocab.cpp b/engines/sci/scicore/vocab.cpp index 6ef1eacdb5..d3ad53832d 100644 --- a/engines/sci/scicore/vocab.cpp +++ b/engines/sci/scicore/vocab.cpp @@ -25,7 +25,8 @@ // Main vocabulary support functions and word lookup -#include "sci/include/sciresource.h" +#include "sci/scicore/vocabulary.h" +#include "sci/scicore/resource.h" #include "sci/include/engine.h" #include "sci/engine/kernel.h" diff --git a/engines/sci/scicore/vocab_debug.cpp b/engines/sci/scicore/vocab_debug.cpp index 81b8a19928..e7b81d2ba5 100644 --- a/engines/sci/scicore/vocab_debug.cpp +++ b/engines/sci/scicore/vocab_debug.cpp @@ -25,7 +25,7 @@ #include "sci/include/engine.h" -#include "sci/include/sciresource.h" +#include "sci/scicore/resource.h" namespace Sci { diff --git a/engines/sci/scicore/vocabulary.h b/engines/sci/scicore/vocabulary.h new file mode 100644 index 0000000000..ec785a9c30 --- /dev/null +++ b/engines/sci/scicore/vocabulary.h @@ -0,0 +1,398 @@ +/* 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_SCICORE_VOCABULARY_H +#define SCI_SCICORE_VOCABULARY_H + +#include "common/str.h" + +#include "sci/scicore/versions.h" + +namespace Sci { + +struct ResourceManager; + +/*#define VOCABULARY_DEBUG */ +/*#define SCI_SIMPLE_SAID_CODE */ /* Whether the simplified Said() matching should be used */ +/*#define SCI_SIMPLE_SAID_DEBUG */ /* uncomment to enable simple said debugging */ + + +#define SCRIPT_UNKNOWN_FUNCTION_STRING "[Unknown]" +/* The string used to identify the "unknown" SCI0 function for each game */ + +#define PARSE_HEAP_SIZE 64 +/* Number of bytes allocated on the heap to store bad words if parsing fails */ + + +struct opcode { + int type; + int number; + char* name; +}; + +#define VOCAB_RESOURCE_OPCODES 998 +#define VOCAB_RESOURCE_KNAMES 999 + +#define VOCAB_RESOURCE_SCI0_MAIN_VOCAB 0 +#define VOCAB_RESOURCE_SCI0_PARSE_TREE_BRANCHES 900 +#define VOCAB_RESOURCE_SCI0_SUFFIX_VOCAB 901 + +#define VOCAB_RESOURCE_SCI1_MAIN_VOCAB 900 +#define VOCAB_RESOURCE_SCI1_PARSE_TREE_BRANCHES 901 +#define VOCAB_RESOURCE_SCI1_SUFFIX_VOCAB 902 +#define VOCAB_RESOURCE_SCI1_CHAR_TRANSFORMS 913 + +#define VOCAB_CLASS_PREPOSITION 0x01 +#define VOCAB_CLASS_ARTICLE 0x02 +#define VOCAB_CLASS_ADJECTIVE 0x04 +#define VOCAB_CLASS_PRONOUN 0x08 +#define VOCAB_CLASS_NOUN 0x10 +#define VOCAB_CLASS_INDICATIVE_VERB 0x20 +#define VOCAB_CLASS_ADVERB 0x40 +#define VOCAB_CLASS_IMPERATIVE_VERB 0x80 +#define VOCAB_CLASS_NUMBER 0x001 + +extern const char *class_names[]; /* Vocabulary class names */ + +#define VOCAB_CLASS_ANYWORD 0xff +/* Anywords are ignored by the parser */ + +#define VOCAB_MAGIC_NUMBER_GROUP 0xffd /* 0xffe ? */ +/* This word class is used for numbers */ + +#define VOCAB_TREE_NODES 500 +/* Number of nodes for each parse_tree_node structure */ + +#define VOCAB_TREE_NODE_LAST_WORD_STORAGE 0x140 +#define VOCAB_TREE_NODE_COMPARE_TYPE 0x146 +#define VOCAB_TREE_NODE_COMPARE_GROUP 0x14d +#define VOCAB_TREE_NODE_FORCE_STORAGE 0x154 + +#define SAID_COMMA 0xf0 +#define SAID_AMP 0xf1 +#define SAID_SLASH 0xf2 +#define SAID_PARENO 0xf3 +#define SAID_PARENC 0xf4 +#define SAID_BRACKO 0xf5 +#define SAID_BRACKC 0xf6 +#define SAID_HASH 0xf7 +#define SAID_LT 0xf8 +#define SAID_GT 0xf9 +#define SAID_TERM 0xff + +#define SAID_FIRST SAID_COMMA + +/* There was no 'last matching word': */ +#define SAID_FULL_MATCH 0xffff +#define SAID_NO_MATCH 0xfffe +#define SAID_PARTIAL_MATCH 0xfffd + +#define SAID_LONG(x) ((x) << 8) + +struct word_t { + + int w_class; /* Word class */ + int group; /* Word group */ + char word[1]; /* The actual word */ + +}; + + +struct parse_rule_t { + int id; /* non-terminal ID */ + int first_special; /* first terminal or non-terminal */ + int specials_nr; /* number of terminals and non-terminals */ + int length; + int data[1]; /* actual data (size 1 to avoid compiler warnings) */ +}; + + +struct parse_rule_list_t { + int terminal; /* Terminal character this rule matches against or 0 for a non-terminal rule */ + parse_rule_t *rule; + parse_rule_list_t *next; +}; + + +struct suffix_t { + + int class_mask; /* the word class this suffix applies to */ + int result_class; /* the word class a word is morphed to if it doesn't fail this check */ + + int alt_suffix_length; /* String length of the suffix */ + int word_suffix_length; /* String length of the other suffix */ + + char *alt_suffix; /* The alternative suffix */ + char *word_suffix; /* The suffix as used in the word vocabulary */ + +}; + + +struct result_word_t { + + int w_class; /* Word class */ + int group; /* Word group */ + +}; + + +struct synonym_t { + int replaceant; /* The word group to replace */ + int replacement; /* The replacement word group for this one */ +}; + + +struct parse_tree_branch_t { + + int id; + + int data[10]; + +}; + +#define PARSE_TREE_NODE_LEAF 0 +#define PARSE_TREE_NODE_BRANCH 1 + + +struct parse_tree_node_t { + + short type; /* leaf or branch */ + + union { + + int value; /* For leaves */ + short branches[2]; /* For branches */ + + } content; + +}; + + + +/*FIXME: These need freeing functions...*/ + +int *vocabulary_get_classes(ResourceManager *resmgr, int *count); + +int vocabulary_get_class_count(ResourceManager *resmgr); + +/** + * Fills the given StringList with selector names. + * Returns true upon success, false oterwise. + */ +bool vocabulary_get_snames(ResourceManager *resmgr, sci_version_t version, Common::StringList &selectorNames); + +/* Look up a selector name in an array, return the index */ +int vocabulary_lookup_sname(const Common::StringList &selectorNames, const char *sname); + + +/** + * Returns a null terminated array of opcodes. + */ +opcode *vocabulary_get_opcodes(ResourceManager *resmgr); + +void vocabulary_free_opcodes(opcode *opcodes); +/* Frees a previously allocated list of opcodes +** Parameters: (opcode *) opcodes: Opcodes to free +** Returns : (void) +*/ + +/** + * Returns a null terminated array of kernel function names. + * + * This function reads the kernel function name table from resource_map, + * and returns a null terminated array of deep copies of them. + * The returned array has the same format regardless of the format of the + * name table of the resource (the format changed between version 0 and 1). + */ +char **vocabulary_get_knames(ResourceManager *resmgr, int* count); +void vocabulary_free_knames(char** names); + + + +word_t **vocab_get_words(ResourceManager *resmgr, int *word_counter); +/* Gets all words from the main vocabulary +** Parameters: (ResourceManager *) resmr: The resource manager to read from +** (int *) word_counter: The int which the number of words is stored in +** Returns : (word_t **): A list of all words, dynamically allocated +*/ + + +void +vocab_free_words(word_t **words, int words_nr); +/* Frees memory allocated by vocab_get_words +** Parameters: (word_t **) words: The words to free +** (int) words_nr: Number of words in the structure +** Returns : (void) +*/ + + +suffix_t **vocab_get_suffices(ResourceManager *resmgr, int *suffices_nr); +/* Gets all suffixes from the suffix vocabulary +** Parameters: (ResourceManager*) resmgr: Resource manager the resources are +** read from +** (int *) suffices_nr: The variable to store the number of suffices in +** Returns : (suffix_t **): A list of suffixes +*/ + +void vocab_free_suffices(ResourceManager *resmgr, suffix_t **suffices, int suffices_nr); +/* Frees suffices_nr suffices +** Parameters: (ResourceManager *) resmgr: The resource manager to free from +** (suffix_t **) suffices: The suffixes to free +** (int) suffices_nr: Number of entrie sin suffices +** Returns : (void) +*/ + +parse_tree_branch_t *vocab_get_branches(ResourceManager *resmgr, int *branches_nr); +/* Retrieves all grammar rules from the resource data +** Parameters: (ResourceManager*) resmgr: Resource manager the rules are +** read from +** (int *) branches_nr: Pointer to the variable which the number of entries is to be +** stored in +** Returns : (parse_tree_branch_t *): The rules, or NULL on error +*/ + +void vocab_free_branches(parse_tree_branch_t *parser_branches); +/* Frees all branches +** Parameters: (parse_tree_branch_t *) parser_branches: The branches to free +** Returns : (null) +*/ + +result_word_t *vocab_lookup_word(char *word, int word_len, + word_t **words, int words_nr, suffix_t **suffices, int suffices_nr); +/* Looks up a single word in the words and suffixes list +** Parameters: (char *) word: Pointer to the word to look up +** (int) word_len: Length of the word to look up +** (word_t **) words: List of words +** (int) words_nr: Number of elements in 'words' +** (suffix_t **) suffices: List of suffices +** (int) suffices_nr: Number of entries in 'suffices' +** Returns : (result_word_t *) A malloc'd result_word_t, or NULL if the word +** could not be found. +*/ + + +result_word_t *vocab_tokenize_string(char *sentence, int *result_nr, + word_t **words, int words_nr, suffix_t **suffices, int suffices_nr, char **error); +/* Tokenizes a string and compiles it into word_ts. +** Parameters: (char *) sentence: The sentence to examine +** (int *) result_nr: The variable to store the resulting number of words in +** (word_t **) words: The words to scan for +** (int) words_nr: Number of words to scan for +** (suffix_t **) suffices: suffixes to scan for +** (int) suffices_nr: Number of suffices to scan for +** (char **) error: Points to a malloc'd copy of the offending text or to NULL on error +** Returns : (word_t *): A list of word_ts containing the result, or NULL. +** On error, NULL is returned. If *error is NULL, the sentence did not contain any useful words; +** if not, *error points to a malloc'd copy of the offending word. +** The returned list may contain anywords. +*/ + + +parse_rule_list_t *vocab_build_gnf(parse_tree_branch_t *branches, int branches_nr); +/* Constructs the Greibach Normal Form of the grammar supplied in 'branches' +** Parameters: (parse_tree_branch_t *) branches: The parser's branches +** (int) branches_nr: Number of parser branches +** Returns : (parse_rule_list_t *): Pointer to a list of singly linked +** GNF rules describing the same language +** that was described by 'branches' +** The original SCI rules are in almost-CNF (Chomsky Normal Form). Note that +** branch[0] is used only for a few magical incantations, as it is treated +** specially by the SCI parser. +*/ + + +void vocab_free_rule_list(parse_rule_list_t *rule_list); +/* Frees a parser rule list as returned by vocab_build_gnf() +** Parameters: (parse_rule_list_t *) rule_list: The rule list to free +** Returns : (void) +*/ + + +int vocab_build_parse_tree(parse_tree_node_t *nodes, result_word_t *words, int words_nr, + parse_tree_branch_t *branch0, parse_rule_list_t *rules); +/* Builds a parse tree from a list of words +** Parameters: (parse_tree_node_t *) nodes: A node list to store the tree in (must have +** at least VOCAB_TREE_NODES entries) +** (result_word_t *) words: The words to build the tree from +** (int) words_nr: The number of words +** (parse_tree_branch_t *) branche0: The zeroeth original branch of the +** original CNF parser grammar +** (parse_rule_list *) rules: The GNF ruleset to parse with +** Returns : 0 on success, 1 if the tree couldn't be built in VOCAB_TREE_NODES nodes +** or if the sentence structure in 'words' is not part of the language +** described by the grammar passed in 'rules'. +*/ + +void vocab_dump_parse_tree(const char *tree_name, parse_tree_node_t *nodes); +/* Prints a parse tree +** Parameters: (const char *) tree_name: Name of the tree to dump (free-form) +** (parse_tree_node_t *) nodes: The nodes containing the parse tree +** Returns : (void) +*/ + + + + +int said(EngineState *s, byte *spec, int verbose); +/* Builds a parse tree from a spec and compares it to a parse tree +** Parameters: (EngineState *) s: The affected state +** (byte *) spec: Pointer to the spec to build +** (int) verbose: Whether to display the parse tree after building it +** Returns : (int) 1 on a match, 0 otherwise +*/ + +const char *vocab_get_any_group_word(int group, word_t **words, int words_nr); +/* Gets any word from the specified group. +** Parameters: (int) group: Group number. +** (word_t **) words: List of words +** (int) words_nr: Count of words in the list. +** For debugging only. +*/ + + +void vocab_decypher_said_block(EngineState *s, byte *pos); +/* Decyphers a said block and dumps its content via sciprintf. +** Parameters: (EngineState *) s: The state to use +** (byte *) pos: Pointer to the data to dump +** For debugging only. +*/ + + +void vocab_synonymize_tokens(result_word_t *words, int words_nr, synonym_t *synonyms, int synonyms_nr); +/* Synonymizes a token list +** Parameters: (result_wort_t *) words: The word list to synonymize +** (int) words_nr: Number of word_ts in the list +** (synonym_t *) synonyms: Synonym list +** (int) synonyms_nr: Number of synonyms in the list +*/ + +int vocab_gnf_parse(parse_tree_node_t *nodes, result_word_t *words, int words_nr, + parse_tree_branch_t *branch0, parse_rule_list_t *tlist, int verbose); + +void vocab_gnf_dump(parse_tree_branch_t *branches, int branches_nr); + +} // End of namespace Sci + +#endif // SCI_SCICORE_VOCABULARY_H diff --git a/engines/sci/sfx/core.cpp b/engines/sci/sfx/core.cpp index fba63c6722..77f0a0c17a 100644 --- a/engines/sci/sfx/core.cpp +++ b/engines/sci/sfx/core.cpp @@ -30,7 +30,7 @@ #include "sci/sfx/sfx_iterator_internal.h" #include "sci/sfx/sfx_player.h" #include "sci/sfx/mixer.h" -#include "sci/include/sci_midi.h" +#include "sci/sfx/sci_midi.h" #include "common/mutex.h" #include "common/system.h" diff --git a/engines/sci/sfx/sci_midi.h b/engines/sci/sfx/sci_midi.h new file mode 100644 index 0000000000..68650f738a --- /dev/null +++ b/engines/sci/sfx/sci_midi.h @@ -0,0 +1,55 @@ +/* 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_SFX_MIDI_H +#define SCI_SFX_MIDI_H + +namespace Sci { + +#define MIDI_RHYTHM_CHANNEL 9 + +/* Special SCI sound stuff */ + +#define SCI_MIDI_TIME_EXPANSION_PREFIX 0xF8 +#define SCI_MIDI_TIME_EXPANSION_LENGTH 240 + +#define SCI_MIDI_EOT 0xFC +#define SCI_MIDI_SET_SIGNAL 0xCF +#define SCI_MIDI_SET_POLYPHONY 0x4B +#define SCI_MIDI_RESET_ON_SUSPEND 0x4C +#define SCI_MIDI_CHANNEL_MUTE 0x4E +#define SCI_MIDI_SET_REVERB 0x50 +#define SCI_MIDI_HOLD 0x52 +#define SCI_MIDI_CUMULATIVE_CUE 0x60 +#define SCI_MIDI_CHANNEL_NOTES_OFF 0x7B /* all-notes-off for Bn */ + +#define SCI_MIDI_SET_SIGNAL_LOOP 0x7F +/* If this is the parameter of 0xCF, the loop point is set here */ + +#define SCI_MIDI_CONTROLLER(status) ((status & 0xF0) == 0xB0) + +} // End of namespace Sci + +#endif // SCI_SFX_MIDI_H diff --git a/engines/sci/sfx/seq/instrument-map.cpp b/engines/sci/sfx/seq/instrument-map.cpp index b24a8c2e0f..07179fbaeb 100644 --- a/engines/sci/sfx/seq/instrument-map.cpp +++ b/engines/sci/sfx/seq/instrument-map.cpp @@ -24,7 +24,7 @@ */ #include "common/scummsys.h" -#include "sci/include/sci_midi.h" +#include "sci/sfx/sci_midi.h" #include "sci/sci_memory.h" #include "sci/sfx/seq/instrument-map.h" #include "sci/sfx/sfx_engine.h" diff --git a/engines/sci/sfx/seq/map-mt32-to-gm.cpp b/engines/sci/sfx/seq/map-mt32-to-gm.cpp index 83bfd444f9..c6b66491e9 100644 --- a/engines/sci/sfx/seq/map-mt32-to-gm.cpp +++ b/engines/sci/sfx/seq/map-mt32-to-gm.cpp @@ -24,7 +24,7 @@ */ #include "common/scummsys.h" -#include "sci/include/sciresource.h" +#include "sci/scicore/resource.h" #include "sci/include/engine.h" #include "sci/sfx/seq/instrument-map.h" diff --git a/engines/sci/sfx/sfx_engine.h b/engines/sci/sfx/sfx_engine.h index 642c84c068..02db4152b8 100644 --- a/engines/sci/sfx/sfx_engine.h +++ b/engines/sci/sfx/sfx_engine.h @@ -30,7 +30,7 @@ #include "sci/sfx/sfx_core.h" #include "sci/sfx/sfx_songlib.h" #include "sci/sfx/sfx_iterator.h" -#include "sci/include/sciresource.h" +#include "sci/scicore/resource.h" namespace Sci { diff --git a/engines/sci/sfx/sfx_iterator_internal.h b/engines/sci/sfx/sfx_iterator_internal.h index c0b59a7822..1f5733f79c 100644 --- a/engines/sci/sfx/sfx_iterator_internal.h +++ b/engines/sci/sfx/sfx_iterator_internal.h @@ -27,7 +27,7 @@ #define SCI_SFX_SFX_ITERATOR_INTERNAL #include "sci/sfx/sfx_iterator.h" -#include "sci/include/sci_midi.h" +#include "sci/sfx/sci_midi.h" namespace Sci { diff --git a/engines/sci/sfx/sfx_player.h b/engines/sci/sfx/sfx_player.h index 8718622428..8aee0d0979 100644 --- a/engines/sci/sfx/sfx_player.h +++ b/engines/sci/sfx/sfx_player.h @@ -30,7 +30,7 @@ #include "sci/sfx/sfx_engine.h" #include "sci/sfx/sfx_iterator.h" -#include "sci/include/sciresource.h" +#include "sci/scicore/resource.h" #include "common/scummsys.h" diff --git a/engines/sci/sfx/softseq/SN76496.cpp b/engines/sci/sfx/softseq/SN76496.cpp index f9ecd12aaf..d4a2a05da3 100644 --- a/engines/sci/sfx/softseq/SN76496.cpp +++ b/engines/sci/sfx/softseq/SN76496.cpp @@ -26,7 +26,7 @@ /* Tandy/PCJr sequencer for FreeSCI */ #include "sci/sfx/softseq.h" -#include "sci/include/sci_midi.h" +#include "sci/sfx/sci_midi.h" namespace Sci { diff --git a/engines/sci/sfx/softseq/pcspeaker.cpp b/engines/sci/sfx/softseq/pcspeaker.cpp index 82486c28a1..6b6da1f001 100644 --- a/engines/sci/sfx/softseq/pcspeaker.cpp +++ b/engines/sci/sfx/softseq/pcspeaker.cpp @@ -26,7 +26,7 @@ /* PC speaker software sequencer for FreeSCI */ #include "sci/sfx/softseq.h" -#include "sci/include/sci_midi.h" +#include "sci/sfx/sci_midi.h" namespace Sci { diff --git a/engines/sci/uinput.h b/engines/sci/uinput.h new file mode 100644 index 0000000000..165396a889 --- /dev/null +++ b/engines/sci/uinput.h @@ -0,0 +1,124 @@ +/* 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_UINPUT_H +#define SCI_UINPUT_H + +namespace Sci { + +#define SCI_INPUT_DEFAULT_CLOCKTIME 100000 +#define SCI_INPUT_DEFAULT_REDRAWTIME 30000 + + +struct sci_event_t { + short type; + short data; + short buckybits; + short character; /* for keyboard events: 'data' after applying + ** the effects of 'buckybits', e.g. if + ** type == SCI_EVT_KEYBOARD + ** data == 'a' + ** buckybits == SCI_EVM_LSHIFT + ** then + ** character == 'A' + ** For 'Alt', characters are interpreted by their + ** PC keyboard scancodes. + */ +}; + +/*Values for type*/ +#define SCI_EVT_NONE 0 +#define SCI_EVT_MOUSE_PRESS (1<<0) +#define SCI_EVT_MOUSE_RELEASE (1<<1) +#define SCI_EVT_KEYBOARD (1<<2) +#define SCI_EVT_JOYSTICK (1<<6) +#define SCI_EVT_SAID (1<<7) +/*Fake values for other events*/ +#define SCI_EVT_ERROR (1<<10) +#define SCI_EVT_QUIT (1<<11) +#define SCI_EVT_PEEK (1<<15) +/* The QUIT event may be used to signal an external 'quit' command being +** issued to the gfx driver. */ +#define SCI_EVT_ANY 0x7fff + + + +/* Keycodes of special keys: */ +#define SCI_K_ESC 27 +#define SCI_K_BACKSPACE 8 +#define SCI_K_ENTER 13 +#define SCI_K_TAB '\t' +#define SCI_K_SHIFT_TAB (0xf << 8) + +#define SCI_K_END (79 << 8) +#define SCI_K_DOWN (80 << 8) +#define SCI_K_PGDOWN (81 << 8) +#define SCI_K_LEFT (75 << 8) +#define SCI_K_CENTER (76 << 8) +#define SCI_K_RIGHT (77 << 8) +#define SCI_K_HOME (71 << 8) +#define SCI_K_UP (72 << 8) +#define SCI_K_PGUP (73 << 8) +#define SCI_K_INSERT (82 << 8) +#define SCI_K_DELETE (83 << 8) + +#define SCI_K_F1 (59<<8) +#define SCI_K_F2 (60<<8) +#define SCI_K_F3 (61<<8) +#define SCI_K_F4 (62<<8) +#define SCI_K_F5 (63<<8) +#define SCI_K_F6 (64<<8) +#define SCI_K_F7 (65<<8) +#define SCI_K_F8 (66<<8) +#define SCI_K_F9 (67<<8) +#define SCI_K_F10 (68<<8) + +#define SCI_K_SHIFT_F1 (84<<8) +#define SCI_K_SHIFT_F2 (85<<8) +#define SCI_K_SHIFT_F3 (86<<8) +#define SCI_K_SHIFT_F4 (87<<8) +#define SCI_K_SHIFT_F5 (88<<8) +#define SCI_K_SHIFT_F6 (89<<8) +#define SCI_K_SHIFT_F7 (90<<8) +#define SCI_K_SHIFT_F8 (91<<8) +#define SCI_K_SHIFT_F9 (92<<8) +#define SCI_K_SHIFT_F10 (93<<8) + +/*Values for buckybits */ +#define SCI_EVM_RSHIFT (1<<0) +#define SCI_EVM_LSHIFT (1<<1) +#define SCI_EVM_CTRL (1<<2) +#define SCI_EVM_ALT (1<<3) +#define SCI_EVM_SCRLOCK (1<<4) +#define SCI_EVM_NUMLOCK (1<<5) +#define SCI_EVM_CAPSLOCK (1<<6) +#define SCI_EVM_INSERT (1<<7) + +#define SCI_EVM_NO_FOOLOCK (~(SCI_EVM_SCRLOCK | SCI_EVM_NUMLOCK | SCI_EVM_CAPSLOCK | SCI_EVM_INSERT)) +#define SCI_EVM_ALL 0xFF + +} // End of namespace Sci + +#endif // SCI_UINPUT_H -- cgit v1.2.3