[Scummvm-cvs-logs] SF.net SVN: scummvm: [25083] scummvm/trunk
sev at users.sourceforge.net
sev at users.sourceforge.net
Sun Jan 14 22:29:13 CET 2007
Revision: 25083
http://scummvm.svn.sourceforge.net/scummvm/?rev=25083&view=rev
Author: sev
Date: 2007-01-14 13:29:12 -0800 (Sun, 14 Jan 2007)
Log Message:
-----------
Initial import of Parallaction engine
Modified Paths:
--------------
scummvm/trunk/base/plugins.cpp
scummvm/trunk/configure
scummvm/trunk/engines/engines.mk
Added Paths:
-----------
scummvm/trunk/engines/parallaction/
scummvm/trunk/engines/parallaction/animation.cpp
scummvm/trunk/engines/parallaction/archive.cpp
scummvm/trunk/engines/parallaction/callables.cpp
scummvm/trunk/engines/parallaction/commands.cpp
scummvm/trunk/engines/parallaction/commands.h
scummvm/trunk/engines/parallaction/debug.cpp
scummvm/trunk/engines/parallaction/defs.h
scummvm/trunk/engines/parallaction/detection.cpp
scummvm/trunk/engines/parallaction/dialogue.cpp
scummvm/trunk/engines/parallaction/disk.h
scummvm/trunk/engines/parallaction/graphics.cpp
scummvm/trunk/engines/parallaction/graphics.h
scummvm/trunk/engines/parallaction/intro.cpp
scummvm/trunk/engines/parallaction/inventory.cpp
scummvm/trunk/engines/parallaction/inventory.h
scummvm/trunk/engines/parallaction/loadsave.cpp
scummvm/trunk/engines/parallaction/location.cpp
scummvm/trunk/engines/parallaction/menu.cpp
scummvm/trunk/engines/parallaction/menu.h
scummvm/trunk/engines/parallaction/module.mk
scummvm/trunk/engines/parallaction/music.cpp
scummvm/trunk/engines/parallaction/music.h
scummvm/trunk/engines/parallaction/parallaction.cpp
scummvm/trunk/engines/parallaction/parallaction.h
scummvm/trunk/engines/parallaction/parser.cpp
scummvm/trunk/engines/parallaction/parser.h
scummvm/trunk/engines/parallaction/staticres.cpp
scummvm/trunk/engines/parallaction/table.cpp
scummvm/trunk/engines/parallaction/walk.cpp
scummvm/trunk/engines/parallaction/zone.cpp
scummvm/trunk/engines/parallaction/zone.h
Modified: scummvm/trunk/base/plugins.cpp
===================================================================
--- scummvm/trunk/base/plugins.cpp 2007-01-14 20:52:14 UTC (rev 25082)
+++ scummvm/trunk/base/plugins.cpp 2007-01-14 21:29:12 UTC (rev 25083)
@@ -153,6 +153,9 @@
#ifndef DISABLE_TOUCHE
LINK_PLUGIN(TOUCHE)
#endif
+ #ifndef DISABLE_PARALLACTION
+ LINK_PLUGIN(PARALLACTION)
+ #endif
return pl;
}
Modified: scummvm/trunk/configure
===================================================================
--- scummvm/trunk/configure 2007-01-14 20:52:14 UTC (rev 25082)
+++ scummvm/trunk/configure 2007-01-14 21:29:12 UTC (rev 25083)
@@ -61,6 +61,7 @@
_build_cine=yes
_build_agi=yes
_build_touche=yes
+_build_parallaction=yes
_need_memalign=no
_build_plugins=no
_nasm=auto
@@ -334,6 +335,7 @@
--disable-cine don't build the Cinematique engine evo 1
--disable-agi don't build the AGI engine
--disable-touche don't build the Touche: The Adventures of the Fifth Musketeer engine
+ --enable-parallaction build the Parallaction engine
--enable-plugins build engines as loadable modules instead of
static linking them
--disable-mt32emu don't enable the integrated MT-32 emulator
@@ -403,6 +405,7 @@
--disable-cine) _build_cine=no ;;
--disable-agi) _build_agi=no ;;
--disable-touche) _build_touche=no ;;
+ --enable-parallaction) _build_parallaction=yes ;;
--disable-hq-scalers) _build_hq_scalers=no ;;
--disable-scalers) _build_scalers=no ;;
--enable-alsa) _alsa=yes ;;
@@ -674,23 +677,24 @@
#
# Engine selection
#
-add_flag_to_config_mk $_build_scumm 'DISABLE_SCUMM'
-add_flag_to_config_mk $_build_scumm_7_8 'DISABLE_SCUMM_7_8'
-add_flag_to_config_mk $_build_he 'DISABLE_HE'
-add_flag_to_config_mk $_build_agos 'DISABLE_AGOS'
-add_flag_to_config_mk $_build_sky 'DISABLE_SKY'
-add_flag_to_config_mk $_build_sword1 'DISABLE_SWORD1'
-add_flag_to_config_mk $_build_sword2 'DISABLE_SWORD2'
-add_flag_to_config_mk $_build_queen 'DISABLE_QUEEN'
-add_flag_to_config_mk $_build_kyra 'DISABLE_KYRA'
-add_flag_to_config_mk $_build_saga 'DISABLE_SAGA'
-add_flag_to_config_mk $_build_gob 'DISABLE_GOB'
-add_flag_to_config_mk $_build_lure 'DISABLE_LURE'
-add_flag_to_config_mk $_build_cine 'DISABLE_CINE'
-add_flag_to_config_mk $_build_agi 'DISABLE_AGI'
-add_flag_to_config_mk $_build_touche 'DISABLE_TOUCHE'
-add_flag_to_config_mk $_build_hq_scalers 'DISABLE_HQ_SCALERS'
-add_flag_to_config_mk $_build_scalers 'DISABLE_SCALERS'
+add_flag_to_config_mk $_build_scumm 'DISABLE_SCUMM'
+add_flag_to_config_mk $_build_scumm_7_8 'DISABLE_SCUMM_7_8'
+add_flag_to_config_mk $_build_he 'DISABLE_HE'
+add_flag_to_config_mk $_build_agos 'DISABLE_AGOS'
+add_flag_to_config_mk $_build_sky 'DISABLE_SKY'
+add_flag_to_config_mk $_build_sword1 'DISABLE_SWORD1'
+add_flag_to_config_mk $_build_sword2 'DISABLE_SWORD2'
+add_flag_to_config_mk $_build_queen 'DISABLE_QUEEN'
+add_flag_to_config_mk $_build_kyra 'DISABLE_KYRA'
+add_flag_to_config_mk $_build_saga 'DISABLE_SAGA'
+add_flag_to_config_mk $_build_gob 'DISABLE_GOB'
+add_flag_to_config_mk $_build_lure 'DISABLE_LURE'
+add_flag_to_config_mk $_build_cine 'DISABLE_CINE'
+add_flag_to_config_mk $_build_agi 'DISABLE_AGI'
+add_flag_to_config_mk $_build_touche 'DISABLE_TOUCHE'
+add_flag_to_config_mk $_build_parallaction 'DISABLE_PARALLACTION'
+add_flag_to_config_mk $_build_hq_scalers 'DISABLE_HQ_SCALERS'
+add_flag_to_config_mk $_build_scalers 'DISABLE_SCALERS'
if test -n "$_host"; then
# Cross-compiling mode - add your target here if needed
@@ -1291,6 +1295,9 @@
if test "$_build_touche" = yes ; then
echo " Touche: The Adventures of the Fifth Musketeer"
fi
+if test "$_build_parallaction" = yes ; then
+ echo " Parallaction"
+fi
echo
Modified: scummvm/trunk/engines/engines.mk
===================================================================
--- scummvm/trunk/engines/engines.mk 2007-01-14 20:52:14 UTC (rev 25082)
+++ scummvm/trunk/engines/engines.mk 2007-01-14 21:29:12 UTC (rev 25083)
@@ -84,3 +84,9 @@
else
MODULES += engines/touche
endif
+
+ifdef DISABLE_PARALLACTION
+DEFINES += -DDISABLE_PARALLACTION
+else
+MODULES += engines/parallaction
+endif
Added: scummvm/trunk/engines/parallaction/animation.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/animation.cpp (rev 0)
+++ scummvm/trunk/engines/parallaction/animation.cpp 2007-01-14 21:29:12 UTC (rev 25083)
@@ -0,0 +1,728 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2006 The ScummVM project
+ *
+ * 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$
+ *
+ */
+
+#include "parallaction/disk.h"
+#include "parallaction/parallaction.h"
+#include "parallaction/graphics.h"
+#include "parallaction/music.h"
+#include "parallaction/parser.h"
+#include "parallaction/zone.h"
+
+
+namespace Parallaction {
+
+
+#define INST_ON 1
+#define INST_OFF 2
+#define INST_X 3
+#define INST_Y 4
+#define INST_Z 5
+#define INST_F 6
+#define INST_LOOP 7
+#define INST_ENDLOOP 8
+#define INST_SHOW 9
+#define INST_INC 10
+#define INST_DEC 11
+#define INST_SET 12
+#define INST_PUT 13
+#define INST_CALL 14
+#define INST_WAIT 15
+#define INST_START 16
+#define INST_SOUND 17
+#define INST_MOVE 18
+#define INST_END 1000
+
+
+void wrapLocalVar(LocalVariable *local);
+void sortAnimations();
+
+LValue getLValue(Instruction *inst, char *str, LocalVariable *locals, Animation *a);
+
+int16 scriptFillBuffers(ArchivedFile *file);
+
+uint16 _numLocals = 0;
+char _localNames[10][10];
+
+Animation *findAnimation(const char *name) {
+
+ Animation *v4 = (Animation*)_animations._next;
+
+ while (v4) {
+ if (!scumm_stricmp(name, v4->_zone._name)) return v4;
+ v4 = (Animation*)v4->_zone._node._next;
+ }
+
+ return NULL;
+}
+
+
+Animation *Parallaction::parseAnimation(ArchivedFile *file, Node *list, char *name) {
+// printf("parseAnimation(%s)\n", name);
+
+ Animation *vD0 = (Animation*)memAlloc(sizeof(Animation));
+ memset(vD0, 0, sizeof(Animation));
+
+ vD0->_zone._name = (char*)memAlloc(strlen(name)+1);
+ strcpy(vD0->_zone._name, name);
+
+ addNode(list, &vD0->_zone._node);
+
+ parseFillBuffers();
+ while (scumm_stricmp(_tokens[0], "endanimation")) {
+// printf("token[0] = %s\n", _tokens[0]);
+
+ if (!scumm_stricmp(_tokens[0], "script")) {
+ loadProgram(vD0, _tokens[1]);
+ }
+ if (!scumm_stricmp(_tokens[0], "commands")) {
+ vD0->_zone._commands = parseCommands(file);
+ }
+ if (!scumm_stricmp(_tokens[0], "type")) {
+ if (_tokens[2][0] != '\0') {
+ vD0->_zone._type = ((4 + searchTable(_tokens[2], _objectsNames)) << 16) & 0xFFFF0000;
+ }
+ int16 _si = searchTable(_tokens[1], _zoneTypeNames);
+ if (_si != -1) {
+ vD0->_zone._type |= 1 << (_si-1);
+ if (((vD0->_zone._type & 0xFFFF) != kZoneNone) && ((vD0->_zone._type & 0xFFFF) != kZoneCommand)) {
+ parseZoneTypeBlock(file, &vD0->_zone);
+ }
+ }
+ }
+ if (!scumm_stricmp(_tokens[0], "label")) {
+ _vm->_graphics->makeCnvFromString(&vD0->_zone._label, _tokens[1]);
+ }
+ if (!scumm_stricmp(_tokens[0], "flags")) {
+ uint16 _si = 1;
+
+ do {
+ byte _al = searchTable(_tokens[_si], _zoneFlagNames);
+ _si++;
+ vD0->_zone._flags |= 1 << (_al - 1);
+ } while (!scumm_stricmp(_tokens[_si++], "|"));
+ }
+ if (!scumm_stricmp(_tokens[0], "file")) {
+ char vC8[200];
+ strcpy(vC8, _tokens[1]);
+ if (_engineFlags & kEngineMiniDonna) {
+ if (!scumm_stricmp(_tokens[1], "donnap") || !scumm_stricmp(_tokens[1], "donnapa")) {
+ strcat(vC8, "tras");
+ }
+ }
+
+ _vm->_graphics->loadCnv(vC8, &vD0->_cnv);
+// int16 _ax = _vm->_graphics->loadCnv(vC8, &vD0->_cnv);
+// if (_ax == -1) exit(-1);
+ }
+ if (!scumm_stricmp(_tokens[0], "position")) {
+ vD0->_zone.pos._position._x = atoi(_tokens[1]);
+ vD0->_zone.pos._position._y = atoi(_tokens[2]);
+ vD0->_z = atoi(_tokens[3]);
+ }
+ if (!scumm_stricmp(_tokens[0], "moveto")) {
+ vD0->_zone._moveTo._x = atoi(_tokens[1]);
+ vD0->_zone._moveTo._y = atoi(_tokens[2]);
+ }
+
+ parseFillBuffers();
+ }
+
+ vD0->_zone.pos._oldposition._x = -1000;
+ vD0->_zone.pos._oldposition._y = -1000;
+
+ vD0->_zone._flags |= 0x1000000;
+
+ return vD0;
+}
+
+
+
+void freeScript(Program *program) {
+
+ if (!program) return;
+
+ memFree(program->_locals);
+ freeNodeList(&program->_node);
+
+ return;
+}
+
+
+
+void freeAnimations() {
+ Animation *v4 = (Animation*)_animations._next;
+ while (v4) {
+ freeScript(v4->_program);
+ _vm->_graphics->freeCnv(&v4->_cnv);
+ v4 = (Animation*)v4->_zone._node._next;
+ }
+
+ return;
+}
+
+
+
+void jobDisplayAnimations(void *parm, Job *j) {
+// printf("jobDisplayAnimations()...\n");
+
+ Animation *v18 = (Animation*)_animations._next;
+ StaticCnv v14;
+
+ uint16 _si = 0;
+
+ for ( ; v18; v18 = (Animation*)v18->_zone._node._next) {
+
+ if ((v18->_zone._flags & kFlagsActive) && ((v18->_zone._flags & kFlagsRemove) == 0)) {
+ v14._width = v18->_cnv._width;
+ v14._height = v18->_cnv._height;
+ v14._data0 = v18->_cnv._array[v18->_frame];
+// v14._data1 = v18->_cnv.field_8[v18->_frame];
+
+ if (v18->_zone._flags & kFlagsNoMasked)
+ _si = 3;
+ else
+ _si = _vm->_graphics->queryMask(v18->_zone.pos._position._y + v18->_cnv._height);
+
+// printf("jobDisplayAnimations %s, x: %i, y: %i, w: %i, h: %i\n", v18->_zone._name, v18->_zone.pos._position._x, v18->_zone.pos._position._y, v14._width, v14._height);
+ _vm->_graphics->blitCnv(&v14, v18->_zone.pos._position._x, v18->_zone.pos._position._y, _si, Graphics::kBitBack, Graphics::kMask0);
+
+ }
+
+ if (((v18->_zone._flags & kFlagsActive) == 0) && (v18->_zone._flags & kFlagsRemove)) {
+ v18->_zone._flags &= ~kFlagsRemove;
+ v18->_zone.pos._oldposition._x = -1000;
+ }
+
+ if ((v18->_zone._flags & kFlagsActive) && (v18->_zone._flags & kFlagsRemove)) {
+ v18->_zone._flags &= ~kFlagsActive;
+ v18->_zone._flags |= kFlagsRemove;
+ }
+
+ }
+
+// printf("done\n");
+
+ return;
+}
+
+
+void jobEraseAnimations(void *arg_0, Job *j) {
+// printf("jobEraseAnimations()...\n");
+
+ Animation *a = (Animation*)_animations._next;
+
+ for (; a; a=(Animation*)a->_zone._node._next) {
+
+ if (((a->_zone._flags & kFlagsActive) == 0) && ((a->_zone._flags & kFlagsRemove) == 0)) continue;
+
+ // printf("jobEraseAnimations %s, x: %i, y: %i, w: %i, h: %i\n", a->_zone._name, a->_zone.pos._oldposition._x, a->_zone.pos._oldposition._y, a->_cnv._width, a->_cnv._height);
+ _vm->_graphics->restoreBackground(a->_zone.pos._oldposition._x, a->_zone.pos._oldposition._y, a->_cnv._width, a->_cnv._height);
+ if (arg_0) {
+ a->_zone.pos._oldposition._x = a->_zone.pos._position._x;
+ a->_zone.pos._oldposition._y = a->_zone.pos._position._y;
+ }
+
+ }
+
+// printf("done\n");
+
+ return;
+}
+
+
+void Parallaction::loadProgram(Animation *a, char *filename) {
+// printf("loadProgram(%s)\n", filename);
+
+
+ char vC8[PATH_LEN];
+
+ sprintf(vC8, "%s.script", filename);
+
+ ArchivedFile *file = openArchivedFile(vC8);
+ if (!file) errorFileNotFound(vC8);
+
+ _numLocals = 0;
+ scriptFillBuffers(file);
+
+ a->_program = (Program*)memAlloc(sizeof(Program));
+ memset(a->_program, 0, sizeof(Program));
+ a->_program->_locals = (LocalVariable*)memAlloc(sizeof(LocalVariable)*10);
+ Node *vD0 = &a->_program->_node;
+
+ Instruction *vCC = (Instruction*)memAlloc(sizeof(Instruction));
+ memset(vCC, 0, sizeof(Instruction));
+
+ while (scumm_stricmp(_tokens[0], "endscript")) {
+
+ parseScriptLine(vCC, a, a->_program->_locals);
+ addNode(vD0, &vCC->_node);
+ vD0 = &vCC->_node;
+
+ vCC = (Instruction*)memAlloc(sizeof(Instruction));
+ memset(vCC, 0, sizeof(Instruction));
+ scriptFillBuffers(file);
+ }
+
+ vCC->_index = INST_END;
+ addNode(vD0, &vCC->_node);
+
+ a->_program->_ip = (Instruction*)a->_program->_node._next;
+
+ closeArchivedFile(file);
+
+ return;
+}
+
+
+
+// FIXME
+// this function does the same Job as parseFillBuffers, except that
+// it gets input from an ArchivedFile instead of a memory buffer
+//
+int16 scriptFillBuffers(ArchivedFile *file) {
+// printf("scriptFillBuffers()\n");
+ char v2[] = "\"\0";
+
+ for (uint16 _si = 0; _si < 15; _si++)
+ _tokens[_si][0] = '\0';
+
+ int16 _si = 0;
+
+ char vCA[200];
+ char *vCE = NULL;
+ do {
+ vCE = readArchivedFileText(vCA, 200, file);
+ if (vCE == 0) return 0;
+
+ skip_whitespace(vCE);
+ } while (strlen(vCE) == 0 || vCE[0] == '#');
+
+ while (strlen(vCE) > 0 && _si < 20) {
+ vCE = parseNextToken(vCE, _tokens[_si], 40, " \t\n");
+ if (_tokens[_si][0] == '"' && _tokens[_si][strlen(_tokens[_si])-1] != '"') {
+
+ vCE = parseNextToken(vCE, _tokens[_si], 40, v2);
+ strcat(_tokens[_si], _tokens[_si+1]);
+ _tokens[_si][0] = ' ';
+ vCE++;
+
+ }
+
+ vCE = skip_whitespace(vCE);
+ _si++;
+ }
+
+ return _si;
+}
+
+
+
+void Parallaction::parseScriptLine(Instruction *inst, Animation *a, LocalVariable *locals) {
+// printf("parseScriptLine()\n");
+
+ if (_tokens[0][1] == '.') {
+ _tokens[0][1] = '\0';
+ a = findAnimation(&_tokens[0][2]);
+ }
+
+ if (_tokens[1][1] == '.') {
+ _tokens[1][1] = '\0';
+ a = findAnimation(&_tokens[1][2]);
+ }
+
+ int16 _si = searchTable(_tokens[0], _instructionNames);
+ inst->_index = _si;
+
+// printf("token[0] = %s (%i)\n", _tokens[0], inst->_index);
+
+ switch (inst->_index) {
+ case INST_ON: // on
+ case INST_OFF: // off
+ case INST_START: // start
+ if (!scumm_stricmp(_tokens[1], a->_zone._name)) {
+ inst->_opBase._a = a;
+ } else {
+ inst->_opBase._a = findAnimation(_tokens[1]);
+ }
+ break;
+
+ case INST_LOOP: // loop
+ inst->_opBase._loopCounter = getLValue(inst, _tokens[1], locals, a);
+ break;
+
+ case INST_X: // x
+ inst->_opA._pvalue = &a->_zone.pos._position._x;
+ inst->_opB = getLValue(inst, _tokens[1], locals, a);
+ break;
+
+ case INST_Y: // y
+ inst->_opA._pvalue = &a->_zone.pos._position._y;
+ inst->_opB = getLValue(inst, _tokens[1], locals, a);
+ break;
+
+ case INST_Z: // z
+ inst->_opA._pvalue = &a->_z;
+ inst->_opB = getLValue(inst, _tokens[1], locals, a);
+ break;
+
+ case INST_F: // f
+ inst->_opA._pvalue = &a->_frame;
+ inst->_opB = getLValue(inst, _tokens[1], locals, a);
+ break;
+
+ case INST_INC: // inc
+ case INST_DEC: // dec
+ if (!scumm_stricmp(_tokens[1], "X")) {
+ inst->_opA._pvalue = &a->_zone.pos._position._x;
+ } else
+ if (!scumm_stricmp(_tokens[1], "Y")) {
+ inst->_opA._pvalue = &a->_zone.pos._position._y;
+ } else
+ if (!scumm_stricmp(_tokens[1], "Z")) {
+ inst->_opA._pvalue = &a->_z;
+ } else
+ if (!scumm_stricmp(_tokens[1], "F")) {
+ inst->_opA._pvalue = &a->_frame;
+ } else {
+ inst->_flags |= kInstUsesLocal;
+ inst->_opA = getLValue(inst, _tokens[1], locals, a);
+ }
+
+ inst->_opB = getLValue(inst, _tokens[2], locals, a);
+
+ if (!scumm_stricmp(_tokens[3], "mod")) {
+ inst->_flags |= kInstMod;
+ }
+ break;
+
+ case INST_SET: // set
+ inst->_opA = getLValue(inst, _tokens[1], locals, a);
+ inst->_flags |= kInstUsesLocal;
+ inst->_opB = getLValue(inst, _tokens[2], locals, a);
+ break;
+
+ case INST_MOVE: // move
+ inst->_opA = getLValue(inst, _tokens[1], locals, a);
+ inst->_opB = getLValue(inst, _tokens[2], locals, a);
+ break;
+
+ case INST_PUT: // put
+ if (!scumm_stricmp(_tokens[1], a->_zone._name)) {
+ inst->_opBase._a = a;
+ } else {
+ inst->_opBase._a = findAnimation(_tokens[1]);
+ }
+
+ inst->_opA = getLValue(inst, _tokens[2], locals, a);
+ inst->_opB = getLValue(inst, _tokens[3], locals, a);
+ if (!scumm_stricmp(_tokens[4], "masked")) {
+ inst->_flags |= kInstMaskedPut;
+ }
+ break;
+
+ case INST_CALL: { // call
+ int16 _ax = searchTable(_tokens[1], _callableNames);
+ inst->_opBase._index = _ax - 1;
+ if (_ax - 1 < 0) exit(0);
+ }
+ break;
+
+ case INST_SOUND: // sound
+ inst->_opBase._z = findZone(_tokens[1]);
+ break;
+
+ case INST_ENDLOOP: // endloop
+ case INST_SHOW: // show
+ case INST_WAIT: // wait
+ break;
+
+ default: // local definition
+ strcpy(_localNames[_numLocals], _tokens[0]);
+ locals[_numLocals]._value = atoi(_tokens[2]);
+
+ if (_tokens[3][0] != '\0') {
+ locals[_numLocals]._min = atoi(_tokens[3]);
+ locals[_numLocals]._max = atoi(_tokens[4]);
+ } else {
+ locals[_numLocals]._min = -10000;
+ locals[_numLocals]._max = 10000;
+ }
+
+ inst->_opA._local = &locals[_numLocals];
+ inst->_opB._value = locals[_numLocals]._value;
+
+ inst->_flags = kInstUsesLiteral | kInstUsesLocal;
+ inst->_index = INST_SET;
+ _numLocals++;
+ break;
+
+ }
+
+
+ return;
+}
+
+LValue getLValue(Instruction *inst, char *str, LocalVariable *locals, Animation *a) {
+
+ LValue v;
+
+ if (isdigit(str[0]) || str[0] == '-') {
+ inst->_flags |= kInstUsesLiteral;
+ v._value = atoi(str);
+ return v;
+ }
+
+ for (uint16 _si = 0; _si < 10; _si++) {
+ if (!scumm_stricmp(str, _localNames[_si])) {
+ v._local = &locals[_si];
+ return v;
+ }
+ }
+
+ if (str[1] == '.') {
+ a = findAnimation(&str[2]);
+ }
+
+ if (str[0] == 'X') {
+ v._pvalue = &a->_zone.pos._position._x;
+ } else
+ if (str[0] == 'Y') {
+ v._pvalue = &a->_zone.pos._position._y;
+ } else
+ if (str[0] == 'Z') {
+ v._pvalue = &a->_z;
+ } else
+ if (str[0] == 'F') {
+ v._pvalue = &a->_frame;
+ }
+
+ return v;
+}
+
+
+
+void jobRunScripts(void *parm, Job *j) {
+// printf("jobRunScripts()\n");
+
+ static uint16 modCounter = 0;
+
+ Animation *a = (Animation*)_animations._next;
+
+ StaticCnv v18;
+ WalkNode *v4 = NULL;
+
+ if (a->_zone._flags & kFlagsCharacter) a->_z = a->_zone.pos._position._y + a->_cnv._height;
+ for ( ; a; a = (Animation*)a->_zone._node._next) {
+
+ if ((a->_zone._flags & kFlagsActing) == 0) continue;
+ Instruction *inst = a->_program->_ip;
+
+// printf("Animation: %s, flags: %x\n", a->_zone._name, a->_zone._flags);
+
+ while ((inst->_index != INST_SHOW) && (a->_zone._flags & kFlagsActing)) {
+
+// printf("Animation: %s, instruction: %s\n", a->_zone._name, inst->_index == INST_END ? "end" : _instructionNames[inst->_index - 1]);
+
+ switch (inst->_index) {
+ case INST_ENDLOOP: // endloop
+ if (--a->_program->_loopCounter > 0) {
+ inst = a->_program->_loopStart;
+ }
+ break;
+
+ case INST_OFF: {// off
+ inst->_opBase._a->_zone._flags |= kFlagsRemove;
+// v1C = inst->_opBase;
+ }
+ break;
+
+ case INST_ON: // on
+ inst->_opBase._a->_zone._flags |= kFlagsActive;
+ inst->_opBase._a->_zone._flags &= ~kFlagsRemove;
+ break;
+
+ case INST_START: // start
+// v1C = inst->_opBase;
+ inst->_opBase._a->_zone._flags |= (kFlagsActing | kFlagsActive);
+ break;
+
+ case INST_LOOP: // loop
+ if (inst->_flags & kInstUsesLiteral) {
+ a->_program->_loopCounter = inst->_opBase._loopCounter._value;
+ } else {
+ a->_program->_loopCounter = *inst->_opBase._loopCounter._pvalue;
+ }
+ a->_program->_loopStart = inst;
+ break;
+
+ case INST_INC: // inc
+ case INST_DEC: { // dec
+ int16 _si = 0;
+ int16 _ax = 0, _bx = 0;
+ if (inst->_flags & kInstUsesLiteral) {
+ _si = inst->_opB._value;
+ } else {
+ _si = *inst->_opB._pvalue;
+ }
+ if (inst->_flags & kInstMod) { // mod
+ _bx = (_si > 0 ? _si : -_si);
+ if (modCounter % _bx != 0) break;
+
+ _si = (_si > 0 ? 1 : -1);
+ }
+ if (inst->_flags & kInstUsesLocal) { // local
+ if (inst->_index == INST_INC) _ax = _si;
+ else _ax = -_si;
+
+ inst->_opA._local->_value += _ax;
+ wrapLocalVar(inst->_opA._local);
+ break;
+ }
+
+ // built-in variable (x, y, z, f)
+ if (inst->_index == INST_INC) _ax = _si;
+ else _ax = -_si;
+ *inst->_opA._pvalue += _ax;
+ }
+ break;
+
+ case INST_MOVE: // move
+ v4 = buildWalkPath(*inst->_opA._pvalue, *inst->_opB._pvalue);
+ addJob(jobWalk, v4, JOBPRIORITY_WALK );
+ _engineFlags |= kEngineWalking;
+ break;
+
+ case INST_PUT: // put
+ v18._width = inst->_opBase._a->_cnv._width;
+ v18._height = inst->_opBase._a->_cnv._height;
+ v18._data0 = inst->_opBase._a->_cnv._array[inst->_opBase._a->_frame];
+// v18._data1 = inst->_opBase._a->_cnv.field_8[inst->_opBase._a->_frame];
+
+ if (inst->_flags & kInstMaskedPut) {
+ uint16 _si = _vm->_graphics->queryMask(inst->_opB._value);
+ _vm->_graphics->blitCnv(&v18, inst->_opA._value, inst->_opB._value, _si, Graphics::kBitBack, Graphics::kMask0 );
+ _vm->_graphics->blitCnv(&v18, inst->_opA._value, inst->_opB._value, _si, Graphics::kBit2, Graphics::kMask0 );
+ } else {
+ _vm->_graphics->flatBlitCnv(&v18, inst->_opA._value, inst->_opB._value, Graphics::kBitBack, v18._data1);
+ _vm->_graphics->flatBlitCnv(&v18, inst->_opA._value, inst->_opB._value, Graphics::kBit2, v18._data1);
+ }
+ break;
+
+ case INST_END: // exit
+ if ((a->_zone._flags & kFlagsLooping) == 0) {
+ a->_zone._flags &= ~kFlagsActing;
+ runCommands(a->_zone._commands, (Zone*)&a->_zone);
+ }
+ a->_program->_ip = (Instruction*)a->_program->_node._next;
+ goto label1;
+
+
+ case INST_CALL: // call
+ _callables[inst->_opBase._index](0);
+ break;
+
+ case INST_WAIT: // wait
+ if (_engineFlags & kEngineWalking) goto label1;
+ break;
+
+ case INST_SOUND: // sound
+ _activeZone = inst->_opBase._z;
+ break;
+
+ default: { // INST_SET, INST_X, INST_Y, INST_Z, INST_F
+ int16 _si;
+ if (inst->_flags & kInstUsesLiteral) {
+ _si = inst->_opB._value;
+ } else {
+ _si = *inst->_opB._pvalue;
+ }
+
+ if (inst->_flags & kInstUsesLocal) {
+ inst->_opA._local->_value = _si;
+ } else {
+ *inst->_opA._pvalue = _si;
+ }
+ }
+ break;
+
+ }
+
+ inst = (Instruction*)inst->_node._next;
+ }
+
+ a->_program->_ip = (Instruction*)inst->_node._next;
+
+label1:
+ if (a->_zone._flags & kFlagsCharacter) a->_z = a->_zone.pos._position._y + a->_cnv._height;
+ }
+
+ sortAnimations();
+ modCounter++;
+
+ return;
+}
+
+void wrapLocalVar(LocalVariable *local) {
+// printf("wrapLocalVar(v: %i, min: %i, max: %i)\n", local->_value, local->_min, local->_max);
+
+ if (local->_value >= local->_max) local->_value = local->_min;
+ if (local->_value < local->_min) local->_value = local->_max - 1;
+
+ return;
+}
+
+
+
+void sortAnimations() {
+ Node v14;
+ memset(&v14, 0, sizeof(Node));
+
+ _yourself._z = _yourself._cnv._height + _yourself._zone._limits._top;
+
+ Animation *vC = (Animation*)_animations._next;
+ Node *v8;
+ Animation *v4;
+
+ while (vC) {
+
+ v8 = &v14;
+
+ while ((v8->_next != NULL) && (vC->_z >= ((Animation*)(v8->_next))->_z)) {
+ v8 = v8->_next;
+ }
+
+ v4 = (Animation*)vC->_zone._node._next;
+
+ addNode(v8, &vC->_zone._node);
+
+ vC = v4;
+ }
+
+ memcpy(&_animations, &v14, sizeof(Node));
+
+ _animations._next->_prev = &_animations;
+
+ return;
+}
+
+
+} // namespace Parallaction
Property changes on: scummvm/trunk/engines/parallaction/animation.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Rev Author URL Id
Name: svn:eol-style
+ native
Added: scummvm/trunk/engines/parallaction/archive.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/archive.cpp (rev 0)
+++ scummvm/trunk/engines/parallaction/archive.cpp 2007-01-14 21:29:12 UTC (rev 25083)
@@ -0,0 +1,176 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2006 The ScummVM project
+ *
+ * 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$
+ *
+ */
+
+#include "common/file.h"
+
+#include "parallaction/disk.h"
+
+
+namespace Parallaction {
+
+#define MAX_ARCHIVE_ENTRIES 384
+
+#define DIRECTORY_OFFSET_IN_FILE 0x4000
+
+static Common::File _archive;
+static char _archiveDir[MAX_ARCHIVE_ENTRIES][32];
+static uint32 _archiveLenghts[MAX_ARCHIVE_ENTRIES];
+static uint32 _archiveOffsets[MAX_ARCHIVE_ENTRIES];
+
+static uint32 _handle = MAX_ARCHIVE_ENTRIES;
+
+
+void openArchive(const char *file) {
+// printf("openArchive(%s)\n", file);
+
+ uint32 offset = DIRECTORY_OFFSET_IN_FILE;
+ char path[PATH_LEN];
+
+ strcpy(path, file);
+ if (!_archive.open(path))
+ errorFileNotFound(path);
+
+ _archive.skip(22);
+ _archive.read(_archiveDir, MAX_ARCHIVE_ENTRIES*32);
+
+ uint16 i;
+ for (i = 0; i < MAX_ARCHIVE_ENTRIES; i++) {
+ _archiveOffsets[i] = offset;
+
+ uint32 len = _archive.readUint32BE();
+// if (len>0) printf("%i) %s - [%i bytes]\n", i, _archiveDir[i], len);
+
+ _archiveLenghts[i] = len;
+ offset += len;
+ }
+
+// printf("%i entries found\n", i);
+// printf("%i bytes of data\n", offset);
+
+ return;
+}
+
+
+
+void closeArchive() {
+// printf("closeArchive()\n");
+
+ if (!_archive.isOpen()) return;
+
+ _archive.close();
+}
+
+
+ArchivedFile *openArchivedFile(const char *name) {
+// printf("openArchivedFile(%s)\n", name);
+
+ uint16 i = 0;
+ for ( ; i < MAX_ARCHIVE_ENTRIES; i++) {
+ if (!scumm_stricmp(_archiveDir[i], name)) break;
+ }
+ if (i == MAX_ARCHIVE_ENTRIES) return NULL;
+
+ printf("found file %s in slot %i\n", name, i);
+
+ ArchivedFile *file = (ArchivedFile*)memAlloc(sizeof(ArchivedFile));
+
+ if (!file)
+ printf("can't allocate archive file\n");
+
+ file->_index = i;
+ file->_offset = _archiveOffsets[i];
+ file->_cursor = _archiveOffsets[i];
+ file->_endOffset = _archiveOffsets[i] + _archiveLenghts[i];
+
+ _handle = file->_index;
+ _archive.seek(file->_offset);
+
+ return file;
+}
+
+
+
+void closeArchivedFile(ArchivedFile *file) {
+ if (file) memFree(file);
+ _handle = MAX_ARCHIVE_ENTRIES;
+ return;
+}
+
+
+
+
+uint16 getArchivedFileLength(const char *name) {
+// printf("getArchivedFileLength(%s)\n", name);
+
+ for (uint16 i = 0; i < MAX_ARCHIVE_ENTRIES; i++) {
+ if (!scumm_stricmp(_archiveDir[i], name))
+ return _archiveLenghts[i];
+ }
+
+ return 0;
+}
+
+
+
+int16 readArchivedFile(ArchivedFile *file, void *buffer, uint16 size) {
+// printf("readArchivedFile(%i, %i)\n", file->_cursor, file->_endOffset);
+
+ if (file->_cursor == file->_endOffset) return -1;
+
+ if (file->_endOffset - file->_cursor < size)
+ size = file->_endOffset - file->_cursor;
+
+ _archive.seek(file->_cursor);
+ int16 read = _archive.read(buffer, size);
+ file->_cursor += read;
+
+ return read;
+}
+
+#if 0
+int16 readArchivedFile(ArchivedFile *file, void *buffer, uint16 size) {
+ printf("readArchivedFile(%i, %i)\n", file->_cursor, file->_endOffset);
+
+ if (file->_cursor == file->_endOffset) return -1;
+
+ _archive.seek(file->_cursor);
+ int16 read = _archive.read(buffer, size);
+ file->_cursor += read;
+
+ return read;
+}
+#endif
+
+
+char *readArchivedFileText(char *buf, uint16 size, void*) {
+
+ char *t = _archive.readLine(buf, size);
+
+ if (_archive.eof() || t == NULL) return NULL;
+
+ return t;
+}
+
+
+
+
+} // namespace Parallaction
Property changes on: scummvm/trunk/engines/parallaction/archive.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Rev Author URL Id
Name: svn:eol-style
+ native
Added: scummvm/trunk/engines/parallaction/callables.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/callables.cpp (rev 0)
+++ scummvm/trunk/engines/parallaction/callables.cpp 2007-01-14 21:29:12 UTC (rev 25083)
@@ -0,0 +1,375 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2006 The ScummVM project
+ *
+ * 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$
+ *
+ */
+
+#include "parallaction/disk.h"
+#include "parallaction/parallaction.h"
+#include "parallaction/graphics.h"
+#include "parallaction/inventory.h"
+#include "parallaction/menu.h"
+#include "parallaction/music.h"
+#include "parallaction/zone.h"
+
+#include "common/file.h"
+
+namespace Parallaction {
+
+
+
+
+static Zone *_moveSarcZones[5];
+static Zone *_moveSarcExaZones[5];
+
+void _c_null(void *parm) {
+
+ return;
+}
+
+void _c_play_boogie(void *parm) {
+
+ static uint16 flag = 1;
+
+ if (flag == 0) return;
+ flag = 0;
+
+ stopMusic();
+ loadMusic("boogie2");
+ playMusic();
+
+ return;
+}
+
+
+void _c_score(void *parm) {
+ _score += 5;
+ return;
+}
+
+void _c_fade(void *parm) {
+ byte palette[PALETTE_SIZE];
+ _vm->_graphics->getBlackPalette(palette);
+ _vm->_graphics->setPalette(palette);
+
+ _vm->_graphics->swapBuffers();
+
+ for (uint16 _di = 0; _di < 64; _di++) {
+ _vm->_graphics->fadePalette(palette);
+ _vm->_graphics->setPalette(palette);
+ }
+
+ _vm->waitTime( 1 );
+
+ return;
+}
+
+Zone *_moveSarcZone0 = NULL;
+int16 _introSarcData1 = 0;
+Zone *_moveSarcZone1 = NULL;
+
+void _c_moveSarc(void *parm) {
+
+ Animation *a;
+
+ if (_introSarcData2 != 0) {
+
+ _introSarcData2 = 0;
+ if (_moveSarcZones[0] == NULL) {
+
+ _moveSarcZones[0] = findZone("sarc1");
+ _moveSarcZones[1] = findZone("sarc2");
+ _moveSarcZones[2] = findZone("sarc3");
+ _moveSarcZones[3] = findZone("sarc4");
+ _moveSarcZones[4] = findZone("sarc5");
+
+ _moveSarcExaZones[0] = findZone("sarc1exa");
+ _moveSarcExaZones[1] = findZone("sarc2exa");
+ _moveSarcExaZones[2] = findZone("sarc3exa");
+ _moveSarcExaZones[3] = findZone("sarc4exa");
+ _moveSarcExaZones[4] = findZone("sarc5exa");
+
+ }
+
+ a = findAnimation("sposta");
+
+ _moveSarcZone1 = (Zone*)parm;
+
+ for (uint16 _si = 0; _si < 5; _si++) {
+ if (_moveSarcZones[_si] == _moveSarcZone1) {
+ _moveSarcZone0 = _moveSarcExaZones[_si];
+ }
+ }
+
+ _introSarcData1 = _introSarcData3 - _moveSarcZone1->_limits._left;
+ a->_z = _introSarcData3;
+ a->_frame = _moveSarcZone1->_limits._top - (_introSarcData1 / 20);
+ _introSarcData3 = _moveSarcZone1->_limits._left;
+
+ if (_introSarcData1 > 0) {
+ a->_zone.pos._position._x = _introSarcData1 / 2;
+ } else {
+ a->_zone.pos._position._x = -_introSarcData1 / 2;
+ }
+
+ if (_introSarcData1 > 0) {
+ a->_zone.pos._position._y = 2;
+ } else {
+ a->_zone.pos._position._y = -2;
+ }
+
+ return;
+
+ }
+
+ _introSarcData2 = 1;
+
+ _moveSarcZone1->_limits._right += _introSarcData1;
+ _moveSarcZone1->_limits._left += _introSarcData1;
+
+ _moveSarcZone1->_limits._top -= (_introSarcData1 / 20);
+ _moveSarcZone1->_limits._bottom -= (_introSarcData1 / 20);
+
+ _moveSarcZone0->_limits._right += _introSarcData1;
+ _moveSarcZone0->_limits._left += _introSarcData1;
+
+ _moveSarcZone0->_limits._top -= (_introSarcData1 / 20);
+ _moveSarcZone0->_limits._bottom -= (_introSarcData1 / 20);
+
+ if (_moveSarcZones[0]->_limits._left == 35 &&
+ _moveSarcZones[1]->_limits._left == 68 &&
+ _moveSarcZones[2]->_limits._left == 101 &&
+ _moveSarcZones[3]->_limits._left == 134 &&
+ _moveSarcZones[4]->_limits._left == 167) {
+
+ a = findAnimation("finito");
+
+ a->_zone._flags |= (kFlagsActive | kFlagsActing);
+ _localFlags[_vm->_currentLocationIndex] |= kFlagsFixed;
+ }
+
+ return;
+
+}
+
+
+static uint16 num_foglie = 0;
+
+void _c_contaFoglie(void *parm) {
+
+ num_foglie++;
+ if (num_foglie != 6) return;
+
+ _commandFlags |= 0x1000;
+
+ return;
+}
+
+void _c_zeroFoglie(void *parm) {
+ num_foglie = 0;
+ return;
+}
+
+void _c_trasformata(void *parm) {
+ _engineFlags ^= kEngineMiniDonna;
+ return;
+}
+
+void _c_offMouse(void *parm) {
+ _mouseHidden = 1;
+ _engineFlags |= kEngineMouse;
+ return;
+}
+
+void _c_onMouse(void *parm) {
+ _engineFlags &= ~kEngineMouse;
+ _mouseHidden = 0;
+ return;
+}
+
+
+
+void _c_setMask(void *parm) {
+
+ _vm->_graphics->intGrottaHackMask();
+
+ return;
+}
+
+void _c_endComment(void *parm) {
+
+}
+
+void _c_frankenstein(void *parm) {
+ byte pal0[PALETTE_SIZE], pal1[PALETTE_SIZE];
+
+ for (uint16 i = 0; i <= PALETTE_COLORS; i++) {
+ pal0[i] = _palette[i];
+ pal0[i*3+1] = 0;
+ pal0[i*3+2] = 0;
+ }
+
+ _vm->_graphics->getBlackPalette(pal1);
+
+ for (uint16 _di = 0; _di < 30; _di++) {
+ g_system->delayMillis(20);
+ _vm->_graphics->setPalette(pal0);
+ g_system->delayMillis(20);
+ _vm->_graphics->setPalette(pal1);
+ }
+
+ _vm->_graphics->setPalette(_palette);
+
+ return;
+}
+// part completion messages
+const char *endMsg0[] = {"COMPLIMENTI!", "BRAVO!", "CONGRATULATIONS!", "PRIMA!"};
+const char *endMsg1[] = {"HAI FINITO QUESTA PARTE", "TU AS COMPLETE' CETTE AVENTURE", "YOU HAVE COMPLETED THIS PART", "DU HAST EIN ABENTEUER ERFOLGREICH"};
+const char *endMsg2[] = {"ORA COMPLETA IL RESTO ", "AVEC SUCCES.", "NOW GO ON WITH THE REST OF", "ZU ENDE GEFUHRT"};
+const char *endMsg3[] = {"DELL' AVVENTURA", "CONTINUE AVEC LES AUTRES", "THIS ADVENTURE", "MACH' MIT DEN ANDEREN WEITER"};
+// game completion messages
+const char *endMsg4[] = {"COMPLIMENTI!", "BRAVO!", "CONGRATULATIONS!", "PRIMA!"};
+const char *endMsg5[] = {"HAI FINITO LE TRE PARTI", "TU AS COMPLETE' LES TROIS PARTIES", "YOU HAVE COMPLETED THE THREE PARTS", "DU HAST DREI ABENTEURE ERFOLGREICH"};
+const char *endMsg6[] = {"DELL' AVVENTURA", "DE L'AVENTURE", "OF THIS ADVENTURE", "ZU ENDE GEFUHRT"};
+const char *endMsg7[] = {"ED ORA IL GRAN FINALE ", "ET MAINTENANT LE GRAND FINAL", "NOW THE GREAT FINAL", "UND YETZT DER GROSSE SCHLUSS!"};
+
+
+void _c_finito(void *parm) {
+
+ const char **v8C = endMsg0;
+ const char **v7C = endMsg1;
+ const char **v6C = endMsg2;
+ const char **v5C = endMsg3;
+ const char **v4C = endMsg4;
+ const char **v3C = endMsg5;
+ const char **v2C = endMsg6;
+ const char **v1C = endMsg7;
+
+ Common::File stream;
+
+ stream.open(_vm->_characterName, Common::File::kFileWriteMode);
+ if (stream.isOpen()) stream.close();
+
+ Common::File streamDino, streamDough, streamDonna;
+
+ streamDino.open("dino");
+ streamDough.open("dough");
+ streamDonna.open("donna");
+
+ bool gameCompleted = streamDino.isOpen() && streamDough.isOpen() && streamDonna.isOpen();
+
+ streamDino.close();
+ streamDough.close();
+ streamDonna.close();
+
+ cleanInventory();
+ refreshInventory(_vm->_characterName);
+
+ _vm->_graphics->palUnk0(_palette);
+
+ if (gameCompleted) {
+ _vm->_graphics->loadExternalCnv("slidecnv", &Graphics::_font);
+ _vm->_graphics->_proportionalFont = false;
+ uint16 _ax = _vm->_graphics->getStringWidth(v4C[_language]);
+ _vm->_graphics->displayString((SCREEN_WIDTH - _ax)/2, 70, v4C[_language]);
+ _ax = _vm->_graphics->getStringWidth(v3C[_language]);
+ _vm->_graphics->displayString((SCREEN_WIDTH - _ax)/2, 100, v3C[_language]);
+ _ax = _vm->_graphics->getStringWidth(v2C[_language]);
+ _vm->_graphics->displayString((SCREEN_WIDTH - _ax)/2, 130, v2C[_language]);
+ _ax = _vm->_graphics->getStringWidth(v1C[_language]);
+ _vm->_graphics->displayString((SCREEN_WIDTH - _ax)/2, 160, v1C[_language]);
+
+ _vm->_graphics->copyScreen(Graphics::kBitFront, Graphics::kBitBack);
+ _vm->_graphics->copyScreen(Graphics::kBitFront, Graphics::kBit2);
+ waitUntilLeftClick();
+
+ strcpy(_location, "estgrotta.drki");
+
+ _engineFlags |= kEngineChangeLocation;
+ _vm->_graphics->freeCnv(&Graphics::_font);
+ } else {
+ _vm->_graphics->loadExternalCnv("slidecnv", &Graphics::_font);
+ _vm->_graphics->_proportionalFont = false;
+ uint16 _ax = _vm->_graphics->getStringWidth(v8C[_language]);
+ _vm->_graphics->displayString((SCREEN_WIDTH - _ax)/2, 70, v8C[_language]);
+ _ax = _vm->_graphics->getStringWidth(v7C[_language]);
+ _vm->_graphics->displayString((SCREEN_WIDTH - _ax)/2, 100, v7C[_language]);
+ _ax = _vm->_graphics->getStringWidth(v6C[_language]);
+ _vm->_graphics->displayString((SCREEN_WIDTH - _ax)/2, 130, v6C[_language]);
+ _ax = _vm->_graphics->getStringWidth(v5C[_language]);
+ _vm->_graphics->displayString((SCREEN_WIDTH - _ax)/2, 160, v5C[_language]);
+
+ _vm->_graphics->copyScreen(Graphics::kBitFront, Graphics::kBitBack);
+ _vm->_graphics->copyScreen(Graphics::kBitFront, Graphics::kBit2);
+ waitUntilLeftClick();
+
+ _vm->_graphics->freeCnv(&Graphics::_font);
+ _vm->_menu->selectCharacter();
+ }
+
+ removeNode(&_yourself._zone._node);
+ _vm->_locationNames[0][0] = '\0';
+ _vm->_numLocations = 0;
+ _commandFlags = 0;
+
+ _engineFlags |= kEngineQuit;
+
+ freeZones(_zones._next);
+ freeNodeList(_zones._next);
+ _zones._next = NULL;
+
+ freeZones(_animations._next);
+ freeNodeList(_animations._next);
+ _animations._next = NULL;
+
+ _engineFlags &= ~kEngineQuit;
+
+ addNode(&_animations, &_yourself._zone._node);
+ _score = 0;
+
+ return;
+}
+
+void _c_ridux(void *parm) {
+ _vm->changeCharacter("minidino");
+ return;
+}
+
+void _c_testResult(void *parm) {
+ _vm->_graphics->swapBuffers();
+ _vm->parseLocation("common");
+ closeArchive();
+
+ _vm->_graphics->loadExternalCnv("slidecnv", &Graphics::_font);
+ _vm->_graphics->_proportionalFont = false;
+
+ uint16 _ax = _vm->_graphics->getStringWidth(_slideText[0]);
+ _vm->_graphics->displayString((SCREEN_WIDTH - _ax)/2, 38, _slideText[0]);
+ _ax = _vm->_graphics->getStringWidth(_slideText[1]);
+ _vm->_graphics->displayString((SCREEN_WIDTH - _ax)/2, 58, _slideText[1]);
+
+ _vm->_graphics->copyScreen(Graphics::kBitFront, Graphics::kBitBack);
+ _vm->_graphics->copyScreen(Graphics::kBitFront, Graphics::kBit2);
+
+ _vm->_graphics->freeCnv(&Graphics::_font);
+
+ return;
+}
+
+} // namespace Parallaction
Property changes on: scummvm/trunk/engines/parallaction/callables.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Rev Author URL Id
Name: svn:eol-style
+ native
Added: scummvm/trunk/engines/parallaction/commands.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/commands.cpp (rev 0)
+++ scummvm/trunk/engines/parallaction/commands.cpp 2007-01-14 21:29:12 UTC (rev 25083)
@@ -0,0 +1,345 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2006 The ScummVM project
+ *
+ * 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$
+ *
+ */
+
+#include "parallaction/parallaction.h"
+#include "parallaction/parser.h"
+#include "parallaction/commands.h"
+#include "parallaction/zone.h"
+
+namespace Parallaction {
+
+#define CMD_SET 1
+#define CMD_CLEAR 2
+#define CMD_START 3
+#define CMD_SPEAK 4
+#define CMD_GET 5
+#define CMD_LOCATION 6
+#define CMD_OPEN 7
+#define CMD_CLOSE 8
+#define CMD_ON 9
+#define CMD_OFF 10
+#define CMD_CALL 11
+#define CMD_TOGGLE 12
+#define CMD_DROP 13
+#define CMD_QUIT 14
+#define CMD_MOVE 15
+#define CMD_STOP 16
+
+extern char *_callableNames[];
+
+
+Command *parseCommands(ArchivedFile *file) {
+// printf("parseCommands()\n");
+
+ Node root;
+ memset(&root, 0, sizeof(root));
+
+ parseFillBuffers();
+
+ while (scumm_stricmp(_tokens[0], "ENDCOMMANDS") && scumm_stricmp(_tokens[0], "ENDZONE")) {
+// printf("token[0] = %s\n", _tokens[0]);
+
+ Command *cmd = (Command*)memAlloc(sizeof(Command));
+ memset(cmd, 0, sizeof(Command));
+
+ cmd->_id = _vm->searchTable(_tokens[0], commands_names);
+ uint16 _si = 1;
+
+// printf("cmd id = %i\n", cmd->_id);
+
+ switch (cmd->_id) {
+ case CMD_SET: // set
+ case CMD_CLEAR: // clear
+ case CMD_TOGGLE: // toggle
+ if (_vm->searchTable(_tokens[1], _globalTable) == -1) {
+ do {
+ char _al = _vm->searchTable(_tokens[_si], _localFlagNames);
+ _si++;
+ cmd->u._flags |= 1 << (_al - 1);
+ } while (!scumm_stricmp(_tokens[_si++], "|"));
+ _si--;
+ } else {
+ cmd->u._flags |= kFlagsGlobal;
+ do {
+ char _al = _vm->searchTable(_tokens[1], _globalTable);
+ _si++;
+ cmd->u._flags |= 1 << (_al - 1);
+ } while (!scumm_stricmp(_tokens[_si++], "|"));
+ _si--;
+ }
+ break;
+
+ case CMD_START: // start
+ case CMD_STOP: // stop
+ cmd->u._animation = findAnimation(_tokens[_si]);
+ _si++;
+ if (cmd->u._animation == NULL) {
+ strcpy(_forwardedAnimationNames[_numForwards], _tokens[_si-1]);
+ _forwardedCommands[_numForwards] = cmd;
+ _numForwards++;
+ }
+ break;
+
+ case CMD_SPEAK: // speak
+ case CMD_GET: // get
+ case CMD_OPEN: // open
+ case CMD_CLOSE: // close
+ case CMD_ON: // on
+ case CMD_OFF: // off
+ cmd->u._zone = findZone(_tokens[_si]);
+ _si++;
+ break;
+
+ case CMD_LOCATION: // location
+ cmd->u._string = (char*)memAlloc(strlen(_tokens[_si])+1);
+ strcpy(cmd->u._string, _tokens[_si]);
+ _si++;
+ break;
+
+ case CMD_CALL: // call
+ cmd->u._callable = _vm->searchTable(_tokens[_si], _callableNames) - 1;
+ _si++;
+ break;
+
+ case CMD_DROP: // drop
+ cmd->u._object = _vm->searchTable(_tokens[_si], _objectsNames);
+ _si++;
+ break;
+
+ case CMD_QUIT: // quit
+ break;
+
+ case CMD_MOVE: // move
+ cmd->u._move._x = atoi(_tokens[_si]);
+ _si++;
+ cmd->u._move._y = atoi(_tokens[_si]);
+ _si++;
+ break;
+
+ }
+
+ if (!scumm_stricmp(_tokens[_si], "flags")) {
+ _si++;
+
+ do {
+ if (!scumm_stricmp(_tokens[_si], "exit") || !scumm_stricmp(_tokens[_si], "exittrap")) {
+ cmd->_flagsOn |= kFlagsExit;
+ } else
+ if (!scumm_stricmp(_tokens[_si], "enter") || !scumm_stricmp(_tokens[_si], "entertrap")) {
+ cmd->_flagsOn |= kFlagsEnter;
+ } else
+ if (!scumm_strnicmp(_tokens[_si], "no", 2)) {
+ byte _al = _vm->searchTable(&_tokens[_si][2], _localFlagNames);
+ cmd->_flagsOff |= 1 << (_al - 1);
+ } else {
+ byte _al = _vm->searchTable(_tokens[_si], _localFlagNames);
+ cmd->_flagsOn |= 1 << (_al - 1);
+ }
+
+ _si++;
+
+ } while (!scumm_stricmp(_tokens[_si++], "|"));
+
+ }
+
+ if (!scumm_stricmp(_tokens[_si], "gflags")) {
+ _si++;
+ cmd->_flagsOn |= kFlagsGlobal;
+
+ do {
+ if (!scumm_stricmp(_tokens[_si], "exit")) {
+ cmd->_flagsOn |= kFlagsExit;
+ } else
+ if (!scumm_stricmp(_tokens[_si], "enter")) {
+ cmd->_flagsOn |= kFlagsEnter;
+ } else
+ if (!scumm_strnicmp(_tokens[_si], "no", 2)) {
+ byte _al = _vm->searchTable(&_tokens[_si][2], _globalTable);
+ cmd->_flagsOff |= 1 << (_al - 1);
+ } else {
+ byte _al = _vm->searchTable(_tokens[_si], _localFlagNames);
+ cmd->_flagsOn |= 1 << (_al - 1);
+ }
+
+ _si++;
+
+ } while (!scumm_stricmp(_tokens[_si++], "|"));
+
+ }
+
+ addNode(&root, &cmd->_node);
+ parseFillBuffers();
+
+ }
+
+ return (Command*)root._next;
+}
+
+
+void freeCommands(Command *list) {
+
+ Command *cmd = list;
+
+ while (cmd) {
+ Command *v4 = (Command*)cmd->_node._next;
+
+ if (cmd->_id == 6) memFree(cmd->u._zone); // open
+ memFree(cmd);
+
+ cmd = v4;
+ }
+
+ return;
+}
+
+
+
+void runCommands(Command *list, Zone *z) {
+// printf("runCommands()\n");
+
+ Command *cmd = list;
+ for ( ; cmd; cmd = (Command*)cmd->_node._next) {
+ CommandData *u = &cmd->u;
+ uint32 v8 = _localFlags[_vm->_currentLocationIndex];
+
+ if (_engineFlags & kEngineQuit)
+ break;
+
+ if (cmd->_flagsOn & kFlagsGlobal) {
+ v8 = _commandFlags | kFlagsGlobal;
+ }
+
+ if ((cmd->_flagsOn & v8) != cmd->_flagsOn) continue;
+ if ((cmd->_flagsOff & ~v8) != cmd->_flagsOff) continue;
+
+// printf("localflags: %x\n", v8);
+// printf("%s (on flags: %x, off flags: %x)\n", commands_names[cmd->_id-1], cmd->_flagsOn, cmd->_flagsOff);
+
+ switch (cmd->_id) {
+
+ case CMD_SET: // set
+ if (cmd->u._flags & kFlagsGlobal) {
+ cmd->u._flags &= ~kFlagsGlobal;
+ _commandFlags |= cmd->u._flags;
+ } else {
+ _localFlags[_vm->_currentLocationIndex] |= cmd->u._flags;
+ }
+ break;
+
+ case CMD_CLEAR: // clear
+ if (cmd->u._flags & kFlagsGlobal) {
+ cmd->u._flags &= ~kFlagsGlobal;
+ _commandFlags &= ~cmd->u._flags;
+ } else {
+ _localFlags[_vm->_currentLocationIndex] &= ~cmd->u._flags;
+ }
+ break;
+
+ case CMD_TOGGLE: // toggle
+ if (cmd->u._flags & kFlagsGlobal) {
+ cmd->u._flags &= ~kFlagsGlobal;
+ _commandFlags ^= cmd->u._flags;
+ } else {
+ _localFlags[_vm->_currentLocationIndex] ^= cmd->u._flags;
+ }
+ break;
+
+ case CMD_START: // start
+ cmd->u._zone->_flags |= kFlagsActing;
+ break;
+
+ case CMD_STOP: // stop
+ cmd->u._zone->_flags &= ~kFlagsActing;
+ break;
+
+ case CMD_SPEAK: // speak
+ _activeZone = u->_zone;
+ break;
+
+ case CMD_GET: // get
+ u->_zone->_flags &= ~kFlagsFixed;
+ if (!runZone(u->_zone)) {
+ runCommands(u->_zone->_commands);
+ }
+ break;
+
+ case CMD_DROP: // drop
+ dropItem( u->_object );
+ break;
+
+ case CMD_OPEN: // open
+ u->_zone->_flags &= ~kFlagsClosed;
+ if (u->_zone->u.door->_cnv._count != 0) {
+ addJob(&jobToggleDoor, (void*)u->_zone, JOBPRIORITY_TOGGLEDOOR );
+ }
+ break;
+
+ case CMD_CLOSE: // close
+ u->_zone->_flags |= kFlagsClosed;
+ break;
+
+ case CMD_ON: // on
+ u->_zone->_flags &= ~kFlagsRemove;
+ u->_zone->_flags |= kFlagsActive;
+ if ((u->_zone->_type & 0xFFFF) == kZoneGet) {
+ addJob(&jobDisplayDroppedItem, u->_zone, JOBPRIORITY_ADDREMOVEITEMS );
+ }
+ break;
+
+ case CMD_OFF: // off
+ u->_zone->_flags |= kFlagsRemove;
+ break;
+
+ case CMD_LOCATION: // location
+ strcpy(_location, u->_string);
+ _engineFlags |= kEngineChangeLocation;
+ break;
+
+ case CMD_CALL: // call
+ _callables[u->_callable](z);
+ break;
+
+ case CMD_QUIT: // quit
+ _engineFlags |= kEngineQuit;
+ break;
+
+ case CMD_MOVE: { // move
+ if ((_yourself._zone._flags & kFlagsRemove) || (_yourself._zone._flags & kFlagsActive) == 0) {
+ continue;
+ }
+
+ WalkNode *vC = buildWalkPath(u->_move._x, u->_move._y);
+
+ addJob(&jobWalk, vC, JOBPRIORITY_WALK );
+ _engineFlags |= kEngineWalking;
+ }
+ break;
+
+ }
+ }
+
+ return;
+
+}
+
+} // namespace Parallaction
+
Property changes on: scummvm/trunk/engines/parallaction/commands.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Rev Author URL Id
Name: svn:eol-style
+ native
Added: scummvm/trunk/engines/parallaction/commands.h
===================================================================
--- scummvm/trunk/engines/parallaction/commands.h (rev 0)
+++ scummvm/trunk/engines/parallaction/commands.h 2007-01-14 21:29:12 UTC (rev 25083)
@@ -0,0 +1,61 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2006 The ScummVM project
+ *
+ * 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 PARALLACTION_COMMANDS_H
+#define PARALLACTION_COMMANDS_H
+
+#include "parallaction/defs.h"
+
+namespace Parallaction {
+
+enum CommandFlags {
+ kFlagsExit = 0x10000000,
+ kFlagsEnter = 0x20000000,
+ kFlagsGlobal = 0x40000000
+};
+
+union CommandData {
+ uint32 _flags;
+ Animation * _animation;
+ Zone* _zone;
+ char* _string;
+ uint16 _callable;
+ uint16 _object;
+ struct {
+ int16 _x;
+ int16 _y;
+ } _move;
+};
+
+struct Command {
+ Node _node;
+
+ uint16 _id;
+ CommandData u;
+ uint32 _flagsOn;
+ uint32 _flagsOff;
+
+};
+
+} // namespace Parallaction
+
+#endif
Property changes on: scummvm/trunk/engines/parallaction/commands.h
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Rev Author URL Id
Name: svn:eol-style
+ native
Added: scummvm/trunk/engines/parallaction/debug.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/debug.cpp (rev 0)
+++ scummvm/trunk/engines/parallaction/debug.cpp 2007-01-14 21:29:12 UTC (rev 25083)
@@ -0,0 +1,80 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2006 The ScummVM project
+ *
+ * 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$
+ *
+ */
+
+
+#include "common/stdafx.h"
+#include "common/system.h"
+#include "parallaction/parallaction.h"
+#include "parallaction/graphics.h"
+
+namespace Parallaction {
+
+
+const char *_jobDescriptions[] = {
+ "0 - draw label",
+ "1 - draw mouse",
+ "2 - delay remove Job (erase label) || show inventory",
+ "3 - draw animations",
+ "4 - NONE",
+ "5 - NONE",
+ "6 - NONE",
+ "7 - NONE",
+ "8 - NONE",
+ "9 - NONE",
+ "10 - NONE",
+ "11 - NONE",
+ "12 - NONE",
+ "13 - NONE",
+ "14 - NONE",
+ "15 - delay remove Job (erase label) || run scripts || erase animations",
+ "16 - NONE",
+ "17 - job_12d4 (put item on screen) || jobRemovePickedItem (remove item from screen)",
+ "18 - toggle door",
+ "19 - walk",
+ "20 - erase label || hide inventory",
+ "21 - erase mouse"
+};
+
+void *memAlloc(uint32 size) {
+ return malloc(size);
+}
+
+void memFree(void *m) {
+ free(m);
+ return;
+}
+
+
+void beep() {
+// sound(1500);
+// delay(100);
+// nosound();
+ return;
+}
+
+void errorFileNotFound(const char *s) {
+ error("File '%s' not found", s);
+}
+
+
+
+} // namespace Parallaction
Property changes on: scummvm/trunk/engines/parallaction/debug.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Rev Author URL Id
Name: svn:eol-style
+ native
Added: scummvm/trunk/engines/parallaction/defs.h
===================================================================
--- scummvm/trunk/engines/parallaction/defs.h (rev 0)
+++ scummvm/trunk/engines/parallaction/defs.h 2007-01-14 21:29:12 UTC (rev 25083)
@@ -0,0 +1,108 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2006 The ScummVM project
+ *
+ * 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 PARALLACTION_DEFS_H
+#define PARALLACTION_DEFS_H
+
+#include "common/stdafx.h"
+#include "common/system.h"
+
+namespace Parallaction {
+
+#define PATH_LEN 200
+
+
+
+
+struct Node {
+ Node* _prev;
+ Node* _next;
+};
+
+struct WalkNode {
+ Node _node;
+ int32 _x;
+ int32 _y;
+};
+
+struct Point {
+ int16 _x;
+ int16 _y;
+};
+
+struct Rect {
+ int16 _left;
+ int16 _top;
+ int16 _right;
+ int16 _bottom;
+};
+
+struct SpeakData;
+struct Question;
+typedef Question Dialogue;
+struct Instruction;
+struct LocalVariable;
+
+struct StaticCnv {
+ uint16 _width; //
+ uint16 _height; //
+ byte* _data0; // bitmap
+ byte* _data1; // unused
+ byte* _data2; // backup of underlying background
+};
+
+
+struct Cnv {
+ uint16 _width; //
+ uint16 _height; //
+ byte** _array; // frames data
+ byte** field_8; // unused
+ uint16 _count; // # of frames
+};
+
+
+struct ArchivedFile;
+struct Animation;
+struct Zone;
+
+struct Command;
+
+typedef void (*callable)(void*);
+
+struct Credit {
+ const char *_role;
+ const char *_name;
+};
+
+void *memAlloc(uint32 size);
+void memFree(void *m);
+void errorFileNotFound(const char*);
+
+void beep();
+char *skip_whitespace(char *s);
+
+} // namespace Parallaction
+
+
+#endif
+
+
Property changes on: scummvm/trunk/engines/parallaction/defs.h
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Rev Author URL Id
Name: svn:eol-style
+ native
Added: scummvm/trunk/engines/parallaction/detection.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/detection.cpp (rev 0)
+++ scummvm/trunk/engines/parallaction/detection.cpp 2007-01-14 21:29:12 UTC (rev 25083)
@@ -0,0 +1,97 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2006 The ScummVM project
+ *
+ * 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$
+ *
+ */
+
+#include "common/stdafx.h"
+
+#include "base/plugins.h"
+
+#include "common/advancedDetector.h"
+#include "common/file.h"
+
+#include "parallaction/parallaction.h"
+
+namespace Parallaction {
+static DetectedGameList GAME_detectGames(const FSList &fslist);
+}
+
+static const PlainGameDescriptor parallactionGames[] = {
+ {"nippon", "Nippon Safes Inc."},
+ {0, 0}
+};
+
+ADVANCED_DETECTOR_DEFINE_PLUGIN(PARALLACTION, Parallaction::Parallaction, Parallaction::GAME_detectGames, parallactionGames, 0);
+
+REGISTER_PLUGIN(PARALLACTION, "Parallaction engine", "Nippon Safes Inc. (C) Dynabyte");
+
+
+namespace Parallaction {
+
+#define FILE_MD5_BYTES 5000
+
+static const PARALLACTIONGameDescription gameDescriptions[] = {
+ {
+ {
+ "nippon",
+ "",
+ {
+ { "disk1", 0, "610363308258e926dbabd5a9e7bb769f"},
+ { "disk2", 0, "bfdd7bcfbc226f4acf3f67fa9efa2826"},
+ { "disk3", 0, "eec08180240888d76e3cfe3e183d5d5d"},
+ { "disk4", 0, "5bffddc7db226bdaa7dd3e10e5a15e68"},
+ { "en", 0, "65cbfa81eafe308621184796ed116700"},
+ { "fr", 0, "ac20c743ea10f2cb4491f76c5644582c"},
+ { "ge", 0, "50916bfa34aee1380e0e959b37eceb5a"},
+ { "it", 0, "89964aef04d2c53a615ee8983caf2775"},
+ { NULL, 0, NULL}
+ },
+ Common::EN_ANY,
+ Common::kPlatformPC,
+ },
+ GType_Nippon,
+ 0,
+ },
+ { { NULL, NULL, {NULL, 0, NULL}, Common::UNK_LANG, Common::kPlatformUnknown }, 0, 0 }
+};
+
+
+bool Parallaction::detectGame() {
+ int i = Common::ADVANCED_DETECTOR_DETECT_INIT_GAME(
+ (const byte *)gameDescriptions,
+ sizeof(PARALLACTIONGameDescription),
+ FILE_MD5_BYTES,
+ parallactionGames
+ );
+ _gameDescription = &gameDescriptions[i];
+ return true;
+}
+
+DetectedGameList GAME_detectGames(const FSList &fslist) {
+ return Common::ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
+ fslist,
+ (const byte *)gameDescriptions,
+ sizeof(PARALLACTIONGameDescription),
+ FILE_MD5_BYTES,
+ parallactionGames
+ );
+}
+
+} // End of namespace Parallaction
Property changes on: scummvm/trunk/engines/parallaction/detection.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Rev Author URL Id
Name: svn:eol-style
+ native
Added: scummvm/trunk/engines/parallaction/dialogue.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/dialogue.cpp (rev 0)
+++ scummvm/trunk/engines/parallaction/dialogue.cpp 2007-01-14 21:29:12 UTC (rev 25083)
@@ -0,0 +1,644 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2006 The ScummVM project
+ *
+ * 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$
+ *
+ */
+
+#include "parallaction/commands.h"
+#include "parallaction/parallaction.h"
+#include "parallaction/graphics.h"
+#include "parallaction/disk.h"
+#include "parallaction/inventory.h"
+#include "parallaction/parser.h"
+#include "parallaction/zone.h"
+
+namespace Parallaction {
+
+#define SKIPPED_ANSWER 1000
+
+#define MAX_BALLOON_WIDTH 130
+
+#define MAX_PASSWORD_LENGTH 7
+
+#define QUESTION_BALLOON_X 140
+#define QUESTION_BALLOON_Y 10
+#define QUESTION_CHARACTER_X 190
+#define QUESTION_CHARACTER_Y 80
+
+#define ANSWER_CHARACTER_X 10
+#define ANSWER_CHARACTER_Y 80
+
+
+void enterDialogue();
+void exitDialogue();
+
+int16 selectAnswer(Question *q, StaticCnv*);
+int16 getHoverAnswer(int16 x, int16 y, Question *q);
+
+int16 _answerBalloonX[10] = { 80, 120, 150, 150, 150, 0, 0, 0, 0, 0 };
+int16 _answerBalloonY[10] = { 10, 70, 130, 0, 0, 0, 0, 0, 0, 0 };
+int16 _answerBalloonW[10] = { 0 };
+int16 _answerBalloonH[10] = { 0 };
+
+
+char *parseDialogueString();
+
+Dialogue *parseDialogue(ArchivedFile *file) {
+// printf("parseDialogue()\n");
+ uint16 num_questions = 0;
+ uint16 v50[20];
+ char *_questions_names[20];
+ Question *_questions[20];
+
+ for (uint16 _si = 0; _si < 20; _si++) {
+ v50[_si] = 0;
+ }
+
+ parseFillBuffers();
+
+ while (scumm_stricmp(_tokens[0], "enddialogue")) {
+ if (scumm_stricmp(_tokens[0], "Question")) continue;
+
+ _questions[num_questions] = (Dialogue*)memAlloc(sizeof(Dialogue));
+ Dialogue *vB4 = _questions[num_questions];
+ memset(_questions[num_questions], 0, sizeof(Dialogue));
+
+ _questions_names[num_questions] = (char*)memAlloc(strlen(_tokens[1])+1);
+ strcpy(_questions_names[num_questions], _tokens[1]);
+
+ vB4->_text = parseDialogueString();
+// printf("Question: '%s'\n", vB4->_text);
+
+ parseFillBuffers();
+ vB4->_mood = atoi(_tokens[0]);
+
+ uint16 _di = 0;
+
+ parseFillBuffers();
+ while (scumm_stricmp(_tokens[0], "endquestion")) { // parse answers
+
+ char** v60 = _localFlagNames;
+ uint16 v56 = 1;
+
+ if (_tokens[1][0]) {
+
+ if (!scumm_stricmp(_tokens[1], "global")) {
+ v56 = 2;
+ v60 = _globalTable;
+ vB4->_yesFlags[_di] |= kFlagsGlobal;
+ }
+
+ do {
+
+ if (!scumm_strnicmp(_tokens[v56], "no", 2)) {
+ byte _al = _vm->searchTable(_tokens[v56]+2, v60);
+ vB4->_noFlags[_di] |= 1 << (_al - 1);
+ } else {
+ byte _al = _vm->searchTable(_tokens[v56]+2, v60);
+ vB4->_yesFlags[_di] |= 1 << (_al - 1);
+ }
+
+ v56++;
+
+ } while (!scumm_stricmp(_tokens[v56], "|"));
+
+ }
+
+ vB4->_answers[_di] = parseDialogueString();
+
+// printf("answer[%i]: '%s'\n", _di, vB4->_answers[_di]);
+
+ parseFillBuffers();
+ vB4->_answer_moods[_di] = atoi(_tokens[0]);
+ vB4->_following._names[_di] = parseDialogueString();
+
+ parseFillBuffers();
+ if (!scumm_stricmp(_tokens[0], "commands")) {
+ vB4->_commands[_di] = parseCommands(file);
+ parseFillBuffers();
+ }
+
+ _di++;
+ }
+
+ parseFillBuffers();
+ num_questions++;
+
+ }
+
+ _questions_names[num_questions] = NULL;
+
+ for (uint16 _si = 0; _si <num_questions; _si++) {
+
+ for (uint16 v5A = 0; v5A < 5; v5A++) {
+ if (_questions[_si]->_answers[v5A] == 0) continue;
+
+ int16 v58 = _vm->searchTable(_questions[_si]->_following._names[v5A], _questions_names);
+ memFree(_questions[_si]->_following._names[v5A]);
+
+ if (v58 == -1) {
+ _questions[_si]->_following._questions[v5A] = 0;
+ } else {
+ _questions[_si]->_following._questions[v5A] = _questions[v58-1];
+
+ if (v50[v58]) {
+ _questions[_si]->_answer_moods[v5A] |= 0x10;
+ }
+
+ v50[v58] = 1;
+ }
+ }
+ }
+
+ for (uint16 _si = 0; _si < num_questions; _si++)
+ memFree(_questions_names[_si]);
+
+ return _questions[0];
+}
+
+
+char *parseDialogueString() {
+
+ char vC8[200];
+ char *vD0 = NULL;
+ do {
+
+ vD0 = parseNextLine(vC8, 200);
+ if (vD0 == 0) return NULL;
+
+ vD0 = skip_whitespace(vD0);
+
+ } while (strlen(vD0) == 0);
+
+ vD0[strlen(vD0)-1] = '\0'; // deletes the trailing '0xA' inserted by parseNextLine
+ // this is critical for Graphics::displayBalloonString to work properly
+
+ char *vCC = (char*)memAlloc(strlen(vD0)+1);
+ strcpy(vCC, vD0);
+
+ return vCC;
+}
+
+
+void freeDialogue(Dialogue *d) {
+
+ if (!d) return;
+
+ uint16 _si;
+ for (_si = 0; _si < 5; _si++) {
+ if (d->_answer_moods[_si] & 0x10)
+ freeDialogue(d->_following._questions[_si]);
+ }
+
+ for (_si = 0; _si < 5; _si++) {
+ freeCommands(d->_commands[_si]);
+ memFree(d->_answers[_si]);
+ }
+
+ memFree(d->_text);
+ memFree(d);
+
+ return;
+}
+
+
+
+void runDialogue(SpeakData *data) {
+
+ enterDialogue();
+
+ if (!scumm_stricmp(_location, "museum")) {
+ _vm->_graphics->freeCnv( &_tempFrames );
+ }
+
+ char v20[PATH_LEN];
+ char *v24 = _vm->_characterName;
+ if (!scumm_strnicmp(v24, "mini", 4)) {
+ v24+=4;
+ }
+
+ if (_engineFlags & kEngineMiniDonna) {
+ sprintf(v20, "%stta", v24);
+ } else {
+ sprintf(v20, "%stal", v24);
+ }
+
+ _vm->_graphics->loadExternalCnv(v20, &_characterFace);
+ _vm->_graphics->loadExternalCnv("comiccnv", &Graphics::_font);
+
+ Cnv v6E;
+ StaticCnv v5C, v48;
+
+ if (!scumm_stricmp(data->_name, "yourself") || data->_name[0] == '\0') {
+ memcpy(&v6E, &_characterFace, sizeof(Cnv));
+ } else {
+ _vm->_graphics->loadCnv(data->_name, &v6E);
+ }
+
+ v5C._width = v6E._width;
+ v5C._height = v6E._height;
+
+ v48._width = _characterFace._width;
+ v48._height = _characterFace._height;
+
+ bool displayedAnswers = false;
+ int16 question_width = 0, question_height = 0;
+ bool askPassword = false;
+ uint16 _di = 0;
+ Command *v34 = NULL;
+
+// printf("enter Dialogue\n");
+
+ Dialogue *v60 = data->_dialogue;
+ while (v60) {
+
+ v5C._data0 = v6E._array[v60->_mood & 0xF];
+// v5C._data1 = v6E.field_8[v60->_mood & 0xF];
+ v48._data0 = _characterFace._array[v60->_mood & 0xF];
+// v48._data1 = _characterFace.field_8[v60->_mood & 0xF];
+
+ // display Question if any
+ if (scumm_stricmp(v60->_text, "NULL")) {
+ _vm->_graphics->flatBlitCnv(
+ &v5C,
+ QUESTION_CHARACTER_X,
+ QUESTION_CHARACTER_Y,
+ Graphics::kBitFront,
+ v5C._data1
+ );
+
+ _vm->_graphics->getStringExtent(
+ v60->_text,
+ MAX_BALLOON_WIDTH,
+ &question_width,
+ &question_height
+ );
+
+ _vm->_graphics->drawBalloon(
+ QUESTION_BALLOON_X,
+ QUESTION_BALLOON_Y,
+ question_width,
+ question_height,
+ v60->_mood & 0x10
+ );
+
+ _vm->_graphics->displayWrappedString(
+ v60->_text,
+ QUESTION_BALLOON_X,
+ QUESTION_BALLOON_Y,
+ MAX_BALLOON_WIDTH,
+ 0
+ );
+
+ waitUntilLeftClick();
+ _vm->_graphics->copyScreen(Graphics::kBitBack, Graphics::kBitFront);
+ }
+
+ if (v60->_answers[0] == NULL) break;
+
+ _answerBalloonY[0] = 10;
+ displayedAnswers = false;
+
+
+ if (scumm_stricmp(v60->_answers[0], "NULL")) {
+
+ uint16 _si = 0;
+ while (_si < 5 && v60->_answers[_si]) {
+
+ uint32 v28 = _localFlags[_vm->_currentLocationIndex];
+ if (v60->_yesFlags[_si] & kFlagsGlobal) {
+ v28 = _commandFlags | kFlagsGlobal;
+ }
+
+ // display suitable answers
+ if (((v60->_yesFlags[_si] & v28) == v60->_yesFlags[_si]) && ((v60->_noFlags[_si] & ~v28) == v60->_noFlags[_si])) {
+
+ _vm->_graphics->getStringExtent(
+ v60->_answers[_si],
+ MAX_BALLOON_WIDTH,
+ &_answerBalloonW[_si],
+ &_answerBalloonH[_si]
+ );
+
+ _vm->_graphics->drawBalloon(
+ _answerBalloonX[_si],
+ _answerBalloonY[_si],
+ _answerBalloonW[_si],
+ _answerBalloonH[_si],
+ 1
+ );
+
+ _answerBalloonY[_si+1] = 10 + _answerBalloonY[_si] + _answerBalloonH[_si];
+
+ askPassword = _vm->_graphics->displayWrappedString(
+ v60->_answers[_si],
+ _answerBalloonX[_si],
+ _answerBalloonY[_si],
+ MAX_BALLOON_WIDTH,
+ 3
+ );
+
+ displayedAnswers = true;
+ } else {
+ _answerBalloonY[_si+1] = _answerBalloonY[_si];
+ _answerBalloonY[_si] = SKIPPED_ANSWER;
+ }
+
+ _si++;
+
+ }
+
+ if (displayedAnswers == true) {
+
+ _vm->_graphics->flatBlitCnv(
+ &v48,
+ ANSWER_CHARACTER_X,
+ ANSWER_CHARACTER_Y,
+ Graphics::kBitFront,
+ v48._data1
+ );
+
+ if (askPassword == false) {
+
+ _di = selectAnswer(v60, &v48);
+
+ } else {
+
+ char password[100];
+ uint16 passwordLen = 0;
+
+ while (askPassword == true) {
+ strcpy(password, ".......");
+ _vm->_graphics->copyScreen(Graphics::kBitBack, Graphics::kBitFront);
+
+ _vm->_graphics->drawBalloon(
+ _answerBalloonX[0],
+ _answerBalloonY[0],
+ _answerBalloonW[0],
+ _answerBalloonH[0],
+ 1
+ );
+
+ _vm->_graphics->displayWrappedString(
+ v60->_answers[0],
+ _answerBalloonX[0],
+ _answerBalloonY[0],
+ MAX_BALLOON_WIDTH,
+ 3
+ );
+
+ _vm->_graphics->flatBlitCnv(
+ &v48,
+ ANSWER_CHARACTER_X,
+ ANSWER_CHARACTER_Y,
+ Graphics::kBitFront,
+ v48._data1
+ );
+
+ _vm->_graphics->displayBalloonString(
+ _answerBalloonX[0] + 5,
+ _answerBalloonY[0] + _answerBalloonH[0] - 15,
+ "> ",
+ 0
+ );
+
+ OSystem::Event e;
+
+ while (e.kbd.ascii != 0xD && passwordLen < MAX_PASSWORD_LENGTH) {
+
+ if (!g_system->pollEvent(e)) continue;
+ if (e.type != OSystem::EVENT_KEYDOWN) continue;
+ if (!isdigit(e.kbd.ascii)) continue;
+
+ password[passwordLen] = e.kbd.ascii;
+ passwordLen++;
+ password[passwordLen] = '\0';
+
+ _vm->_graphics->displayBalloonString(
+ _answerBalloonX[0] + 5,
+ _answerBalloonY[0] + _answerBalloonH[0] - 15,
+ password,
+ 0
+ );
+
+ g_system->delayMillis(20);
+ }
+
+ if ((!scumm_stricmp(_vm->_characterName, "dough") && !scumm_strnicmp(password, "1732461", 7)) ||
+ (!scumm_stricmp(_vm->_characterName, "donna") && !scumm_strnicmp(password, "1622", 4)) ||
+ (!scumm_stricmp(_vm->_characterName, "dino") && !scumm_strnicmp(password, "179", 3))) {
+
+ askPassword = false;
+
+ }
+
+ _di = 0;
+
+ }
+
+ }
+
+ _vm->_graphics->copyScreen(Graphics::kBitBack, Graphics::kBitFront);
+
+ v34 = v60->_commands[_di];
+ v60 = (Dialogue*)v60->_following._questions[_di];
+
+ } else {
+ v60 = NULL;
+ }
+ } else {
+
+ v60 = (Dialogue*)v60->_following._questions[_di];
+
+ }
+
+ }
+
+// printf("exit Dialogue\n");
+
+ _vm->_graphics->copyScreen(Graphics::kBitBack, Graphics::kBitFront);
+ _vm->_graphics->freeCnv(&_characterFace);
+
+ if (scumm_stricmp(data->_name, "yourself") || data->_name[0] == '\0') {
+ _vm->_graphics->freeCnv(&v6E);
+ }
+
+ _vm->_graphics->freeCnv(&Graphics::_font);
+ exitDialogue();
+
+ if (!scumm_stricmp(_location, "museum")) {
+
+ closeArchive();
+ strcpy(_vm->_disk, "disk1");
+ openArchive(_vm->_disk);
+ _vm->_graphics->loadCnv("dino", &_tempFrames);
+
+ memcpy(&_yourself._cnv, &_tempFrames, sizeof(Cnv));
+
+ }
+
+ runCommands(v34);
+
+ return;
+
+}
+
+int16 selectAnswer(Question *q, StaticCnv *cnv) {
+
+ int16 v6 = 0;
+ int16 numAvailableAnswers = 0;
+ int16 _si = 0;
+ int16 _di = 0;
+
+ for (; q->_answers[v6]; v6++) {
+ if (_answerBalloonY[v6] == SKIPPED_ANSWER) continue;
+
+ _di = v6;
+ numAvailableAnswers++;
+ }
+
+ _answerBalloonY[v6] = 2000;
+
+ if (numAvailableAnswers == 1) {
+
+ _vm->_graphics->displayWrappedString(
+ q->_answers[_di],
+ _answerBalloonX[_di],
+ _answerBalloonY[_di],
+ MAX_BALLOON_WIDTH,
+ 0
+ );
+
+ cnv->_data0 = _characterFace._array[q->_answer_moods[_di] & 0xF];
+// cnv->_data1 = _characterFace.field_8[q->_answer_moods[_di] & 0xF];
+
+ _vm->_graphics->flatBlitCnv(
+ cnv,
+ ANSWER_CHARACTER_X,
+ ANSWER_CHARACTER_Y,
+ Graphics::kBitFront,
+ cnv->_data1
+ );
+
+ waitUntilLeftClick();
+ return _di;
+ }
+
+ int16 v2 = -1;
+
+ _mouseButtons = kMouseNone;
+ while (_mouseButtons != kMouseLeftUp) {
+
+ _vm->updateInput();
+ _si = getHoverAnswer(_mousePos._x, _mousePos._y, q);
+
+ if (_si != v2) {
+ if (_si != -1) {
+ _vm->_graphics->displayWrappedString(
+ q->_answers[v2],
+ _answerBalloonX[v2],
+ _answerBalloonY[v2],
+ MAX_BALLOON_WIDTH,
+ 3
+ );
+ }
+
+ _vm->_graphics->displayWrappedString(
+ q->_answers[_si],
+ _answerBalloonX[_si],
+ _answerBalloonY[_si],
+ MAX_BALLOON_WIDTH,
+ 0
+ );
+
+ cnv->_data0 = _characterFace._array[q->_answer_moods[_si] & 0xF];
+// cnv->_data1 = _characterFace.field_8[q->_answer_moods[_si] & 0xF];
+
+ _vm->_graphics->flatBlitCnv(
+ cnv,
+ ANSWER_CHARACTER_X,
+ ANSWER_CHARACTER_Y,
+ Graphics::kBitFront,
+ cnv->_data1
+ );
+
+ }
+
+ v2 = _si;
+ }
+
+ return _si;
+}
+
+
+//
+// finds out which answer is currently selected
+//
+int16 getHoverAnswer(int16 x, int16 y, Question *q) {
+
+ int16 top = 1000;
+ int16 bottom = 1000;
+
+ for (int16 _si = 0; _si < 5; _si++) {
+ if (q->_answers[_si] == NULL) break;
+
+ if (_answerBalloonY[_si] != SKIPPED_ANSWER) {
+ top = _answerBalloonY[_si];
+ }
+
+ int16 _di = _si + 1;
+ for (; _answerBalloonY[_di] == SKIPPED_ANSWER; _di++) ;
+
+ bottom = _answerBalloonY[_di];
+
+ // mouse position is compared only with y coordinates
+ if (y > top && y < bottom) return _si;
+
+ }
+
+ return 0;
+
+}
+
+// backups background mask and path
+//
+//
+void enterDialogue() {
+
+ _vm->_graphics->backupBackgroundMask(Graphics::kMask0);
+ _vm->_graphics->backupBackgroundPath(Graphics::kPath0);
+
+ return;
+}
+
+// restores background mask and path
+// rebuilds inventory
+//
+void exitDialogue() {
+
+ _vm->_graphics->restoreBackgroundMask(Graphics::kMask0);
+ _vm->_graphics->restoreBackgroundPath(Graphics::kPath0);
+
+ refreshInventory(_vm->_characterName);
+
+ return;
+}
+
+
+} // namespace Parallaction
Property changes on: scummvm/trunk/engines/parallaction/dialogue.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Rev Author URL Id
Name: svn:eol-style
+ native
Added: scummvm/trunk/engines/parallaction/disk.h
===================================================================
--- scummvm/trunk/engines/parallaction/disk.h (rev 0)
+++ scummvm/trunk/engines/parallaction/disk.h 2007-01-14 21:29:12 UTC (rev 25083)
@@ -0,0 +1,61 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2006 The ScummVM project
+ *
+ * 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 PARALLACTION_DISK_H
+#define PARALLACTION_DISK_H
+
+#include "parallaction/defs.h"
+
+namespace Parallaction {
+
+//------------------------------------------------------
+// ARCHIVE MANAGEMENT
+//------------------------------------------------------
+
+struct ArchivedFile {
+ uint16 _index;
+ uint32 _offset;
+ uint32 _cursor;
+ uint16 field_A; // unused
+ uint16 field_C; // unused
+ uint32 _endOffset;
+};
+
+void openArchive(const char *file);
+void closeArchive();
+
+ArchivedFile *openArchivedFile(const char *name);
+void closeArchivedFile(ArchivedFile*);
+
+uint16 getArchivedFileLength(const char *name);
+
+int16 readArchivedFile(ArchivedFile*, void *buffer, uint16 size);
+char *readArchivedFileText(char *buf, uint16 size, void*);
+
+
+
+
+} // namespace Parallaction
+
+
+
+#endif
Property changes on: scummvm/trunk/engines/parallaction/disk.h
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Rev Author URL Id
Name: svn:eol-style
+ native
Added: scummvm/trunk/engines/parallaction/graphics.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.cpp (rev 0)
+++ scummvm/trunk/engines/parallaction/graphics.cpp 2007-01-14 21:29:12 UTC (rev 25083)
@@ -0,0 +1,1361 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2006 The ScummVM project
+ *
+ * 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$
+ *
+ */
+
+#include "common/file.h"
+
+#include "parallaction/graphics.h"
+#include "parallaction/parser.h"
+#include "parallaction/parallaction.h"
+#include "parallaction/inventory.h"
+#include "parallaction/disk.h"
+
+
+extern OSystem *g_system;
+
+namespace Parallaction {
+
+
+byte * _maskBackup;
+byte * _pathBackup;
+
+
+
+uint16 _bgLayers[4];
+
+// FIXME:
+extern byte _glyphWidths[];
+
+Cnv Graphics::_font;
+bool Graphics::_proportionalFont = false;
+Point Graphics::_labelPosition[2] = { { 0, 0 }, { 0, 0 } };
+StaticCnv Graphics::_mouseComposedArrow;
+byte * Graphics::_buffers[];
+
+#define PALETTE_BACKUP PALETTE_SIZE
+
+PaletteFxRange _palettefx[6];
+byte _palette[PALETTE_SIZE];
+
+byte _black_palette[PALETTE_SIZE] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+
+#define BALLOON_WIDTH 12
+#define BALLOON_HEIGHT 10
+
+byte _resBalloon[2][BALLOON_WIDTH*BALLOON_HEIGHT] = {
+ {
+ 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02,
+ 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x00, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ },
+ {
+ 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02,
+ 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x02,
+ 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x02, 0x02
+ }
+};
+
+void Graphics::drawBalloon(int16 left, int16 top, uint16 width, uint16 height, uint16 winding) {
+// printf("Graphics::drawBalloon(%i, %i, %i, %i, %i)...", left, top, width, height, winding);
+
+ width+=5;
+ floodFill(0, left, top, left+width, top+height, kBitFront);
+ floodFill(1, left+1, top+2, left+width-1, top+height-1, kBitFront);
+
+ winding = (winding == 0 ? 1 : 0);
+ byte *s = _resBalloon[winding];
+ byte *d = _buffers[kBitFront] + (left + width/2 - 5) + (top + height - 1) * SCREEN_WIDTH;
+
+ for (uint16 i = 0; i < BALLOON_HEIGHT; i++) {
+ for (uint16 j = 0; j < BALLOON_WIDTH; j++) {
+ if (*s != 2) *d = *s;
+ d++;
+ s++;
+ }
+
+ d += (SCREEN_WIDTH - BALLOON_WIDTH);
+ }
+
+// printf("done\n");
+
+ return;
+}
+
+
+
+//
+// palette management
+//
+
+void Graphics::setPalette(byte *palette) {
+// printf("setPalette()\n");
+// memcpy(_palette, palette, PALETTE_SIZE);
+
+ byte syspal[PALETTE_COLORS*4];
+
+ for (uint32 i = 0; i < PALETTE_COLORS; i++) {
+ syspal[i*4] = (palette[i*3] << 2) | (palette[i*3] >> 4);
+ syspal[i*4+1] = (palette[i*3+1] << 2) | (palette[i*3+1] >> 4);
+ syspal[i*4+2] = (palette[i*3+2] << 2) | (palette[i*3+2] >> 4);
+ syspal[i*4+3] = 0;
+ }
+
+ g_system->setPalette(syspal, 0, PALETTE_COLORS);
+ g_system->updateScreen();
+ return;
+}
+
+void Graphics::getBlackPalette(byte *palette) {
+ memcpy(palette, _black_palette, PALETTE_SIZE);
+ return;
+}
+
+void Graphics::palUnk0(byte *palette) {
+#if 0
+ for (uint16 i = 0; i < PALETTE_SIZE; i++) {
+ palette[PALETTE_BACKUP+i] = _palette[i]/2;
+ }
+#endif
+ Graphics::setPalette(palette);
+
+ return;
+}
+
+
+void Graphics::buildBWPalette(byte *palette) {
+
+ for (uint16 i = 0; i < PALETTE_COLORS; i++) {
+ byte max;
+
+ if (_palette[i*3+1] > _palette[i*3+2]) {
+ max = _palette[i*3+1];
+ } else {
+ max = _palette[i*3+2];
+ }
+
+ if (_palette[i*3] > max) {
+ max = _palette[i*3];
+ } else {
+ if (_palette[i*3+1] > _palette[i*3+2]) {
+ max = _palette[i*3+1];
+ } else {
+ max = _palette[i*3+2];
+ }
+ }
+
+ palette[i*3] = max;
+ palette[i*3+1] = max;
+ palette[i*3+2] = max;
+ }
+
+ return;
+}
+
+void Graphics::fadePalette(byte *palette) {
+
+ for (uint16 i = 0; i < PALETTE_SIZE; i++)
+ if (palette[i] < _palette[i]) palette[i]++;
+
+
+ return;
+}
+
+void Graphics::quickFadePalette(byte *palette) {
+
+ for (uint16 i = 0; i <= PALETTE_SIZE; i++) {
+ if (palette[i] == _palette[i]) continue;
+ palette[i] += (palette[i] < _palette[i] ? 4 : -4);
+ }
+
+ return;
+}
+
+//
+// palette Animation
+//
+// FIXME: the effect is different from the original
+//
+void Graphics::animatePalette(byte *palette) {
+// printf("Graphics::animatePalette()\n");
+
+ byte tmp[3];
+
+ for (uint16 i = 0; i < 4; i++) {
+
+ if ((_palettefx[i]._flags & 1) == 0) continue; // animated palette
+
+ _palettefx[i]._timer += _palettefx[i]._step * 2; // update timer
+
+ if (_palettefx[i]._timer < 0x4000) continue; // check timeout
+
+ _palettefx[i]._timer = 0; // reset timer
+
+ if (_palettefx[i]._flags & 2) { // forward
+
+ tmp[0] = _palette[_palettefx[i]._first * 3];
+ tmp[1] = _palette[_palettefx[i]._first * 3 + 1];
+ tmp[2] = _palette[_palettefx[i]._first * 3 + 2];
+
+ memmove(palette+_palettefx[i]._first*3, _palette+(_palettefx[i]._first+1)*3, (_palettefx[i]._last - _palettefx[i]._first)*3);
+
+ palette[_palettefx[i]._last * 3] = tmp[0];
+ palette[_palettefx[i]._last * 3 + 1] = tmp[1];
+ palette[_palettefx[i]._last * 3 + 2] = tmp[2];
+
+ } else { // backward
+
+ tmp[0] = _palette[_palettefx[i]._last * 3];
+ tmp[1] = _palette[_palettefx[i]._last * 3 + 1];
+ tmp[2] = _palette[_palettefx[i]._last * 3 + 2];
+
+ memmove(palette+(_palettefx[i]._first+1)*3, _palette+_palettefx[i]._first*3, (_palettefx[i]._last - _palettefx[i]._first)*3);
+
+ palette[_palettefx[i]._first * 3] = tmp[0];
+ palette[_palettefx[i]._first * 3 + 1] = tmp[1];
+ palette[_palettefx[i]._first * 3 + 2] = tmp[2];
+
+ }
+
+ }
+
+ return;
+}
+
+
+
+
+void Graphics::updateScreen() {
+// printf("Graphics::updateScreen()\n");
+ g_system->copyRectToScreen(_buffers[kBitFront], SCREEN_WIDTH, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
+ g_system->updateScreen();
+ return;
+}
+
+
+void Graphics::swapBuffers() {
+ byte *temp = _buffers[kBitFront];
+ _buffers[kBitFront] = _buffers[kBitBack];
+ _buffers[kBitBack] = temp;
+ updateScreen();
+ return;
+}
+
+
+//
+// graphic primitives
+//
+void Graphics::clearScreen(Graphics::Buffers buffer) {
+ memset(_buffers[buffer], 0, SCREEN_WIDTH*SCREEN_HEIGHT);
+
+ if (buffer == kBitFront) updateScreen();
+
+ return;
+}
+
+
+void Graphics::copyScreen(Graphics::Buffers srcbuffer, Graphics::Buffers dstbuffer) {
+ memcpy(_buffers[dstbuffer], _buffers[srcbuffer], SCREEN_WIDTH*SCREEN_HEIGHT);
+
+ if (dstbuffer == kBitFront) updateScreen();
+
+ return;
+}
+
+
+void Graphics::copyRect(Graphics::Buffers srcbuffer, uint16 sx, uint16 sy, Graphics::Buffers dstbuffer, uint16 dx, uint16 dy, uint16 w, uint16 h) {
+
+ byte *s = _buffers[srcbuffer] + (sx + sy * SCREEN_WIDTH);
+ byte *d = _buffers[dstbuffer] + (dx + dy * SCREEN_WIDTH);
+
+ for (uint16 i = 0; i < h; i++) {
+ memcpy(d, s, w);
+
+ s += SCREEN_WIDTH;
+ d += SCREEN_WIDTH;
+ }
+
+ if (dstbuffer == kBitFront) updateScreen();
+
+ return;
+
+}
+
+
+void Graphics::floodFill(byte color, uint16 left, uint16 top, uint16 right, uint16 bottom, Graphics::Buffers buffer) {
+// printf("Graphics::floodFill(%i, %i, %i, %i, %i)\n", color, left, top, right, bottom);
+
+ byte *d = _buffers[buffer] + (left + top * SCREEN_WIDTH);
+ uint16 w = right - left + 1;
+ uint16 h = bottom - top + 1;
+
+ for (uint16 i = 0; i < h; i++) {
+ memset(d, color, w);
+
+ d += SCREEN_WIDTH;
+ }
+
+ if (buffer == kBitFront) updateScreen();
+
+ return;
+}
+
+
+void Graphics::flatBlit(uint16 w, uint16 h, int16 x, int16 y, byte *data, Graphics::Buffers buffer) {
+// printf("Graphics::flatBlit(%i, %i, %i, %i)\n", w, h, x, y);
+
+ int16 left = 0, top = 0;
+ int16 right = w, bottom = h;
+
+ if (x + w > SCREEN_WIDTH) right = SCREEN_WIDTH - x;
+ if (y + h > SCREEN_HEIGHT) bottom = SCREEN_HEIGHT - y;
+
+ if (x < 0) { // partially left clipped
+ left = -x;
+ x = 0;
+ }
+
+ if (y < 0) { // partially top clipped
+ top = -y;
+ y = 0;
+ }
+
+ if (left > right || top > bottom || x >= SCREEN_WIDTH || y >= SCREEN_HEIGHT) return; // fully clipped
+
+ byte *s = data + left + top * w;
+ byte *d = _buffers[buffer] + x + y * SCREEN_WIDTH;
+
+ for (uint16 i = top; i < bottom; i++) {
+ for (uint16 j = left; j < right; j++) {
+ if (*s != 0) *d = *s;
+ s++;
+ d++;
+ }
+
+ s += (w - right + left);
+ d += (SCREEN_WIDTH - right + left);
+ }
+
+ if (buffer == kBitFront) updateScreen();
+
+ return;
+
+}
+
+
+void Graphics::blit(uint16 w, uint16 h, int16 x, int16 y, uint16 z, byte *data, Graphics::Buffers buffer, Graphics::Buffers mask) {
+// printf("Graphics::blit(%i, %i, %i, %i, %i)\n", w, h, x, y, z);
+
+ int16 left = 0, top = 0;
+ int16 right = w, bottom = h;
+
+ if (x + w > SCREEN_WIDTH) right = SCREEN_WIDTH - x;
+ if (y + h > SCREEN_HEIGHT) bottom = SCREEN_HEIGHT - y;
+
+ if (x < 0) { // partially left clipped
+ left = -x;
+ x = 0;
+ }
+
+ if (y < 0) { // partially top clipped
+ top = -y;
+ y = 0;
+ }
+
+ if (left > right || top > bottom || x >= SCREEN_WIDTH || y >= SCREEN_HEIGHT) return; // fully clipped
+
+ byte *s = data + left + top * w;
+ byte *d = _buffers[buffer] + x + y * SCREEN_WIDTH;
+
+ for (uint16 i = top; i < bottom; i++) {
+
+ uint16 r = x % 4;
+ byte *m = _buffers[mask] + x/4 + (y + i - top)*SCREENMASK_WIDTH;
+
+ for (uint16 j = left; j < right; j++) {
+ if (*s != 0) {
+ uint16 v = ((3 << (r << 1)) & *m) >> (r << 1);
+ if (z >= v) *d = *s;
+ }
+
+ r++;
+ if (r==4) m++;
+ r &= 0x3;
+
+ s++;
+ d++;
+ }
+
+ s += (w - right + left);
+ d += (SCREEN_WIDTH - right + left);
+ }
+
+ if (buffer == kBitFront) updateScreen();
+
+ return;
+
+}
+
+
+void jobDisplayLabel(void *parm, Job *j) {
+
+ StaticCnv *cnv = (StaticCnv*)parm;
+
+ if (cnv->_data0 == NULL) return;
+ _vm->_graphics->flatBlitCnv(cnv, Graphics::_labelPosition[0]._x, Graphics::_labelPosition[0]._y, Graphics::kBitBack, cnv->_data1);
+
+ return;
+}
+
+void jobEraseLabel(void *parm, Job *j) {
+ StaticCnv *cnv = (StaticCnv*)parm;
+
+ int16 _si, _di;
+
+ if (_vm->_activeItem._id != 0) {
+ _si = _mousePos._x + 16 - cnv->_width/2;
+ _di = _mousePos._y + 34;
+ } else {
+ _si = _mousePos._x + 8 - cnv->_width/2;
+ _di = _mousePos._y + 33;
+ }
+
+ if (_si < 0) _si = 0;
+ if (_di > 190) _di = 190;
+
+ if (cnv->_width > SCREEN_WIDTH)
+ _si = SCREEN_WIDTH - _si;
+
+
+ _vm->_graphics->restoreBackground(Graphics::_labelPosition[1]._x, Graphics::_labelPosition[1]._y, cnv->_width, cnv->_height);
+
+ Graphics::_labelPosition[1]._x = Graphics::_labelPosition[0]._x;
+ Graphics::_labelPosition[1]._y = Graphics::_labelPosition[0]._y;
+ Graphics::_labelPosition[0]._x = _si;
+ Graphics::_labelPosition[0]._y = _di;
+
+ return;
+}
+
+void Graphics::initMouse(uint16 arg_0) {
+
+ loadExternalStaticCnv("pointer", &_mouseComposedArrow);
+
+ byte temp[16*16];
+ memcpy(temp, _mouseArrow, 16*16);
+
+ uint16 k = 0;
+ for (uint16 i = 0; i < 4; i++) {
+ for (uint16 j = 0; j < 64; j++) _mouseArrow[k++] = temp[i + j * 4];
+ }
+
+ return;
+}
+
+void Graphics::setMousePointer(int16 index) {
+
+ if (index == kCursorArrow) { // standard mouse pointer
+
+ StaticCnv cnv;
+
+ cnv._width = 16;
+ cnv._height = 16;
+ cnv._data0 = _mouseArrow;
+
+ g_system->setMouseCursor(_mouseArrow, 16, 16, 0, 0, 0);
+ g_system->showMouse(true);
+
+ } else {
+
+ // FIXME: standard mouse arrow must be combined with item
+ // but it is not at the moment
+
+ // inventory item pointer
+ StaticCnv mouse_pointer;
+ memcpy(&mouse_pointer, &_mouseComposedArrow, sizeof(StaticCnv));
+ byte *v8 = mouse_pointer._data0;
+
+ // FIXME: target offseting is not clear
+ extractInventoryGraphics(index, v8 + 7 + 32 * 7);
+
+ g_system->setMouseCursor(v8, 32, 32, 0, 0, 0);
+
+ }
+
+ return;
+}
+
+
+
+
+//
+// Cnv management
+//
+void Graphics::flatBlitCnv(StaticCnv *cnv, int16 x, int16 y, Graphics::Buffers buffer, byte *unused) {
+ flatBlit(cnv->_width, cnv->_height, x, y, cnv->_data0, buffer);
+ return;
+}
+
+
+void Graphics::blitCnv(StaticCnv *cnv, int16 x, int16 y, uint16 z, Graphics::Buffers buffer, Graphics::Buffers mask) {
+ blit(cnv->_width, cnv->_height, x, y, z, cnv->_data0, buffer, mask);
+ return;
+}
+
+
+void Graphics::backupCnvBackground(StaticCnv *cnv, int16 x, int16 y) {
+
+ byte *s = _buffers[kBit2] + x + y * SCREEN_WIDTH;
+ byte *d = cnv->_data2;
+
+ for (uint16 i = 0; i < cnv->_height ; i++) {
+ memcpy(d, s, cnv->_width);
+
+ s += SCREEN_WIDTH;
+ d += cnv->_width;
+ }
+
+ return;
+}
+
+
+void Graphics::backupCnvBackgroundTransparent(StaticCnv *cnv, int16 x, int16 y) {
+
+ byte *t = cnv->_data0;
+ byte *s = _buffers[kBitBack] + x + y * SCREEN_WIDTH;
+ byte *d = cnv->_data2;
+
+ for (uint16 i = 0; i < cnv->_height ; i++) {
+ for (uint16 j = 0; j < cnv->_width ; j++) {
+ *d = (*t) ? *s : 0;
+
+ d++;
+ t++;
+ s++;
+ }
+
+ s += (SCREEN_WIDTH - cnv->_width);
+ }
+
+ return;
+}
+
+
+// restores a cnv backup on the background
+//
+//
+void Graphics::restoreCnvBackground(StaticCnv *cnv, int16 x, int16 y) {
+
+ byte *temp = cnv->_data0;
+ cnv->_data0 = cnv->_data2;
+
+ flatBlitCnv(cnv, x, y, kBitBack, cnv->_data1);
+ flatBlitCnv(cnv, x, y, kBit2, cnv->_data1);
+
+ cnv->_data0 = temp;
+
+ return;
+}
+
+
+
+//
+// strings
+//
+void Graphics::displayString(uint16 x, uint16 y, const char *text) {
+
+ uint16 len = strlen(text);
+ StaticCnv tmp;
+
+ for (uint16 i = 0; i < len; i++) {
+ char c = mapChar(text[i]);
+
+ tmp._width = _font._width;
+ tmp._height = _font._height;
+ tmp._data0 = _font._array[c];
+
+ flatBlitCnv(&tmp, x, y, kBitFront, NULL);
+
+ x += (_proportionalFont ? _glyphWidths[(int)c] : 8);
+
+ }
+
+ return;
+}
+
+
+void Graphics::displayBalloonString(uint16 x, uint16 y, const char *text, byte color) {
+
+ uint16 len = strlen(text);
+
+ for (uint16 i = 0; i < len; i++) {
+
+ char c = mapChar(text[i]);
+ uint16 w = _proportionalFont ? _glyphWidths[(int)c] : 8;
+ byte *s = _font._array[c];
+ byte *d = _buffers[kBitFront] + x + y*SCREEN_WIDTH;
+
+// printf("%i\n", text[i]);
+
+ for (uint16 j = 0; j < _font._height; j++) {
+ for (uint16 k = 0; k < w; k++) {
+ *d = (*s) ? 1 : color;
+ d++;
+ s++;
+ }
+
+ s += (8 - w);
+ d += (SCREEN_WIDTH - w);
+ }
+
+ x += w;
+ }
+
+ updateScreen();
+
+ return;
+}
+
+
+
+bool Graphics::displayWrappedString(char *text, uint16 x, uint16 y, uint16 maxwidth, byte color) {
+// printf("Graphics::displayWrappedString(%s, %i, %i, %i, %i)...", text, x, y, maxwidth, color);
+
+ uint16 lines = 0;
+ bool rv = false;
+ uint16 linewidth = 0;
+
+ _proportionalFont = true;
+ uint16 rx = x + 10;
+ uint16 ry = y + 4;
+
+ char token[40];
+
+ while (strlen(text) > 0) {
+
+ text = parseNextToken(text, token, 40, " ");
+ linewidth += getStringWidth(token);
+
+ if (linewidth > maxwidth) {
+ // wrap line
+ lines++;
+ rx = x + 10; // x
+ ry = y + 4 + lines*10; // y
+ linewidth = getStringWidth(token);
+ }
+
+ if (!scumm_stricmp(token, "%s")) {
+ sprintf(token, "%d", _score);
+ }
+ if (!scumm_stricmp(token, "%p")) {
+ rv = true;
+ } else
+ displayBalloonString(rx, ry, token, color);
+
+ rx += getStringWidth(token) + getStringWidth(" ");
+ linewidth += getStringWidth(" ");
+
+ text = skip_whitespace(text);
+ }
+
+// printf("done\n");
+
+ return rv;
+
+}
+
+
+
+uint16 Graphics::getStringWidth(const char *text) {
+ uint16 len = strlen(text);
+
+ if (_proportionalFont == 0) {
+ // fixed font
+ return len*8;
+ }
+
+ // proportional font
+ uint16 w = 0;
+ for (uint16 i = 0; i < len; i++) {
+ char c = mapChar(text[i]);
+ w += _glyphWidths[(int)c];
+ }
+
+ return w;
+}
+
+
+void Graphics::getStringExtent(char *text, uint16 maxwidth, int16* width, int16* height) {
+
+ uint16 lines = 0;
+ uint16 w = 0;
+ *width = 0;
+
+ _proportionalFont = true;
+
+ char token[40];
+
+ while (strlen(text) != 0) {
+
+ text = parseNextToken(text, token, 40, " ");
+ w += getStringWidth(token);
+
+ if (w > maxwidth) {
+ w -= getStringWidth(token);
+ lines++;
+ if (w > *width)
+ *width = w;
+
+ w = getStringWidth(token);
+ }
+
+ w += getStringWidth(" ");
+ text = skip_whitespace(text);
+ }
+
+ if (*width < w) *width = w;
+ *width += 10;
+
+ *height = lines * 10 + 20;
+
+ return;
+}
+
+
+// backups background mask
+//
+//
+void Graphics::backupBackgroundMask(Graphics::Buffers mask) {
+
+ byte *s = _buffers[mask];
+ byte *d = _maskBackup;
+
+ memcpy(d, s, SCREENMASK_WIDTH*SCREEN_HEIGHT);
+
+ return;
+}
+
+// restores background mask
+//
+//
+void Graphics::restoreBackgroundMask(Graphics::Buffers mask) {
+
+ byte *s = _maskBackup;
+ byte *d = _buffers[mask];
+
+ memcpy(d, s, SCREENMASK_WIDTH*SCREEN_HEIGHT);
+
+ return;
+}
+
+// backups background path
+//
+//
+void Graphics::backupBackgroundPath(Graphics::Buffers path) {
+
+ byte *s = _buffers[path];
+ byte *d = _pathBackup;
+
+ memcpy(d, s, SCREENPATH_WIDTH*SCREEN_HEIGHT);
+
+ return;
+}
+
+//
+// restores background path
+//
+void Graphics::restoreBackgroundPath(Graphics::Buffers path) {
+
+ byte *s = _pathBackup;
+ byte *d = _buffers[path];
+
+ memcpy(d, s, SCREENPATH_WIDTH*SCREEN_HEIGHT);
+
+ return;
+}
+
+//
+// decompress a graphics block
+//
+uint16 Graphics::decompressChunk(byte *src, byte *dst, uint16 size) {
+
+ uint16 written = 0;
+ uint16 read = 0;
+ uint16 len = 0;
+
+ for (; written != size; written += len) {
+
+ len = src[read];
+ read++;
+
+ if (len <= 127) {
+ // copy run
+
+ len++;
+ memcpy(dst+written, src+read, len);
+ read += len;
+
+ } else {
+ // expand run
+
+ len = 257 - len;
+ memset(dst+written, src[read], len);
+ read++;
+
+ }
+
+ }
+
+ return read;
+}
+
+void Graphics::restoreBackground(int16 left, int16 top, uint16 width, uint16 height) {
+// printf("restoreBackground(%i, %i, %i, %i)\n", left, top, width, height);
+
+ if (left < 0) left = 0;
+ if (top < 0) top = 0;
+
+ if (left >= SCREEN_WIDTH) return;
+ if (top >= SCREEN_HEIGHT) return;
+
+ if (left+width >= SCREEN_WIDTH) width = SCREEN_WIDTH - left;
+ if (top+height >= SCREEN_HEIGHT) height = SCREEN_HEIGHT - top;
+
+ copyRect(kBit2, left, top, kBitBack, left, top, width, height);
+
+ return;
+}
+
+
+void Graphics::makeCnvFromString(StaticCnv *cnv, char *text) {
+// printf("makeCnvFromString('%s')\n", text);
+
+ uint16 len = strlen(text);
+
+ cnv->_width = _font._width * len;
+ cnv->_height = _font._height;
+
+// printf("%i x %i\n", cnv->_width, cnv->_height);
+
+ cnv->_data0 = (byte*)memAlloc(cnv->_width * cnv->_height);
+
+ for (uint16 i = 0; i < len; i++) {
+ char c = mapChar(text[i]);
+
+ byte *s = _font._array[c];
+ byte *d = cnv->_data0 + _font._width * i;
+
+ for (uint16 j = 0; j < _font._height; j++) {
+ memcpy(d, s, 8);
+
+ s += 8;
+ d += cnv->_width;
+ }
+ }
+
+ return;
+}
+
+//
+// internal character mapping
+//
+char Graphics::mapChar(char c) {
+ byte b = (byte)c;
+
+ if (b == 0xA5) return 0x5F;
+ if (b == 0xDF) return 0x60;
+
+ if (b > 0x7F) return b - 0x7F;
+
+ return b - 0x20;
+}
+
+
+//
+// loads a cnv from an external file
+//
+void Graphics::loadExternalCnv(const char *filename, Cnv *cnv) {
+// printf("Graphics::loadExternalCnv(%s)...", filename);
+
+ char path[PATH_LEN];
+
+ sprintf(path, "%s.cnv", filename);
+
+ Common::File stream;
+
+ if (!stream.open(path))
+ errorFileNotFound(path);
+
+ cnv->_count = cnv->_width = cnv->_height = 0;
+
+ stream.read(&cnv->_count, 1);
+ stream.read(&cnv->_width, 1);
+ stream.read(&cnv->_height, 1);
+
+ cnv->_array = (byte**)memAlloc(cnv->_count * sizeof(byte*));
+
+ uint16 size = cnv->_width*cnv->_height;
+ for (uint16 i = 0; i < cnv->_count; i++) {
+ cnv->_array[i] = (byte*)memAlloc(size);
+ stream.read(cnv->_array[i], size);
+ }
+
+ stream.close();
+
+// printf("done\n");
+
+
+ return;
+}
+
+
+
+
+void Graphics::loadExternalStaticCnv(const char *filename, StaticCnv *cnv) {
+
+ char path[PATH_LEN];
+
+ sprintf(path, "%s.cnv", filename);
+
+ Common::File stream;
+
+ if (!stream.open(path))
+ errorFileNotFound(path);
+
+ cnv->_width = cnv->_height = 0;
+
+ stream.skip(1);
+ stream.read(&cnv->_width, 1);
+ stream.read(&cnv->_height, 1);
+
+ uint16 size = cnv->_width*cnv->_height;
+
+ cnv->_data0 = (byte*)memAlloc(size);
+ stream.read(cnv->_data0, size);
+
+ stream.close();
+
+ return;
+}
+
+
+
+
+
+void Graphics::loadStaticCnv(const char *filename, StaticCnv *cnv) {
+// printf("Graphics::loadStaticCnv(%s)\n", filename);
+
+ char path[PATH_LEN];
+
+ strcpy(path, filename);
+ ArchivedFile *file = openArchivedFile(path);
+ if (!file) {
+ sprintf(path, "%s.pp", filename);
+ file = openArchivedFile(path);
+ if (!file) errorFileNotFound(path);
+ }
+
+ cnv->_width = cnv->_height = 0;
+
+ byte unk;
+ readArchivedFile(file, &unk, 1);
+ readArchivedFile(file, &cnv->_width, 1);
+ readArchivedFile(file, &cnv->_height, 1);
+
+ uint16 compressedsize = getArchivedFileLength(path) - 3;
+ byte *compressed = (byte*)memAlloc(compressedsize);
+
+ uint16 size = cnv->_width*cnv->_height;
+ cnv->_data0 = (byte*)memAlloc(size);
+
+ readArchivedFile(file, compressed, compressedsize);
+ closeArchivedFile(file);
+
+ decompressChunk(compressed, cnv->_data0, size);
+ memFree(compressed);
+
+ return;
+}
+
+
+
+
+void Graphics::loadCnv(const char *filename, Cnv *cnv) {
+// printf("Graphics::loadCnv(%s)\n", filename);
+
+ char path[PATH_LEN];
+
+ strcpy(path, filename);
+ ArchivedFile *file = openArchivedFile(path);
+ if (!file) {
+ sprintf(path, "%s.pp", filename);
+ file = openArchivedFile(path);
+ if (!file) errorFileNotFound(path);
+ }
+
+ cnv->_count = cnv->_width = cnv->_height = 0;
+
+ readArchivedFile(file, &cnv->_count, 1);
+ readArchivedFile(file, &cnv->_width, 1);
+ readArchivedFile(file, &cnv->_height, 1);
+
+ uint16 framesize = cnv->_width*cnv->_height;
+
+ cnv->_array = (byte**)memAlloc(cnv->_count * sizeof(byte*));
+
+ uint32 size = getArchivedFileLength(path) - 3;
+
+ byte *buf = (byte*)memAlloc(size);
+ readArchivedFile(file, buf, size);
+
+ byte *s = buf;
+
+ for (uint16 i = 0; i < cnv->_count; i++) {
+ cnv->_array[i] = (byte*)memAlloc(framesize);
+ uint16 read = decompressChunk(s, cnv->_array[i], framesize);
+
+// printf("frame %i decompressed: %i --> %i\n", i, read, framesize);
+
+ s += read;
+ }
+
+ closeArchivedFile(file);
+
+ memFree(buf);
+
+ return;
+}
+
+
+
+
+
+
+
+void Graphics::freeCnv(Cnv *cnv) {
+// printf("Graphics::freeCnv()\n");
+
+ if (!cnv) return;
+
+ for (uint16 _si = 0; _si < cnv->_count; _si++) {
+ memFree(cnv->_array[_si]);
+ }
+ memFree(cnv->_array);
+
+ return;
+}
+
+
+
+void Graphics::freeStaticCnv(StaticCnv *cnv) {
+// printf("free_static_cnv()\n");
+
+ if (!cnv) return;
+
+ if (!cnv || !cnv->_data0) return;
+ memFree(cnv->_data0);
+ cnv->_data0 = NULL;
+
+ return;
+}
+
+
+//
+// slides (background images) are stored compressed by scanline in a rle fashion
+//
+// the uncompressed data must then be unpacked to get:
+// * color data [bits 0-5]
+// * mask data [bits 6-7] (z buffer)
+// * path data [bit 8] (walkable areas)
+//
+
+uint16 _swap_16(uint16 *v) {
+
+ uint16 v2 = *v;
+ uint16 v3 = *v & 0xFF;
+ *v = (v3 << 8) | ((v2 >> 8) & 0xFF);
+
+ return *v;
+}
+
+
+void unpackBackgroundScanline(byte *src, byte *screen, byte *mask, byte *path) {
+
+ // update mask, path and screen
+ for (uint16 i = 0; i < SCREEN_WIDTH; i++) {
+ path[i/8] |= ((src[i] & 0x80) >> 7) << (i & 7);
+ mask[i/4] |= ((src[i] & 0x60) >> 5) << ((i & 3) << 1);
+ screen[i] = src[i] & 0x1F;
+ }
+
+ return;
+}
+
+
+
+
+void Graphics::loadBackground(const char *filename, Graphics::Buffers buffer) {
+// printf("Graphics::loadBackground(%s)\n", filename);
+
+ ArchivedFile *file = openArchivedFile(filename);
+ if (!file) errorFileNotFound(filename);
+
+// byte palette[PALETTE_SIZE];
+ byte v150[4];
+ readArchivedFile(file, _palette, PALETTE_SIZE);
+ readArchivedFile(file, &v150, 4);
+ readArchivedFile(file, _palettefx, sizeof(PaletteFxRange)*6);
+
+// setPalette(palette);
+
+ uint16 _si;
+ for (_si = 0; _si < 4; _si++) {
+ byte _al = v150[_si];
+ _bgLayers[_si] = _al;
+ }
+
+ for (_si = 0; _si < 6; _si++) {
+ _swap_16(&_palettefx[_si]._timer);
+ _swap_16(&_palettefx[_si]._step);
+ _swap_16(&_palettefx[_si]._flags);
+ }
+
+#if 0
+ uint16 v147;
+ for (v147 = 0; v147 < PALETTE_SIZE; v147++) {
+ byte _al = _palette[v147];
+ _palette[PALETTE_SIZE+v147] = _al / 2;
+ }
+#endif
+
+ memset(_buffers[kPath0], 0, SCREENPATH_WIDTH*SCREEN_HEIGHT);
+ memset(_buffers[kMask0], 0, SCREENMASK_WIDTH*SCREEN_HEIGHT);
+
+ byte *v4 = (byte*)memAlloc(SCREEN_SIZE);
+ readArchivedFile(file, v4, SCREEN_SIZE);
+
+ byte v144[SCREEN_WIDTH];
+
+ byte *s = v4;
+ for (uint16 i = 0; i < SCREEN_HEIGHT; i++) {
+ s += decompressChunk(s, v144, SCREEN_WIDTH);
+ unpackBackgroundScanline(v144, _buffers[buffer]+SCREEN_WIDTH*i, _buffers[kMask0]+SCREENMASK_WIDTH*i, _buffers[kPath0]+SCREENPATH_WIDTH*i);
+ }
+
+ memFree(v4);
+ closeArchivedFile(file);
+
+ return;
+}
+
+//
+// read background path and mask from a file
+//
+// mask and path are normally combined (via OR) into the background picture itself
+// read the comment on the top of this file for more
+//
+void Graphics::loadMaskAndPath(const char *filename) {
+
+ ArchivedFile *file = openArchivedFile(filename);
+ if (!file) errorFileNotFound(filename);
+
+ byte v4[4];
+ readArchivedFile(file, v4, 4);
+ readArchivedFile(file, _buffers[kPath0], SCREENPATH_WIDTH*SCREEN_HEIGHT);
+ readArchivedFile(file, _buffers[kMask0], SCREENMASK_WIDTH*SCREEN_HEIGHT);
+
+ for (uint16 _si = 0; _si < 4; _si++) _bgLayers[_si] = v4[_si];
+
+ closeArchivedFile(file);
+ return;
+}
+
+
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list