[Scummvm-cvs-logs] SF.net SVN: scummvm: [33060] scummvm/branches/gsoc2008-tfmx
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Mon Jul 14 20:54:16 CEST 2008
Revision: 33060
http://scummvm.svn.sourceforge.net/scummvm/?rev=33060&view=rev
Author: fingolfin
Date: 2008-07-14 11:54:15 -0700 (Mon, 14 Jul 2008)
Log Message:
-----------
Merged revisions 32983,32986-32990,32992,32994,33002-33004,33006-33007,33009-33010,33014,33017,33021-33023,33030,33033,33052-33053,33056-33058 via svnmerge from
https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk
Also attempted to fix svnmerge issues
........
r32983 | peres001 | 2008-07-10 04:00:54 +0200 (Thu, 10 Jul 2008) | 1 line
Fixed destruction of sprites in BRA.
........
r32986 | lordhoto | 2008-07-10 13:25:43 +0200 (Thu, 10 Jul 2008) | 2 lines
Workaround for gcc 2.95 compiler bug.
........
r32987 | lordhoto | 2008-07-10 13:28:51 +0200 (Thu, 10 Jul 2008) | 2 lines
Fixed mem leak in MIDI related code.
........
r32988 | lordhoto | 2008-07-10 14:05:38 +0200 (Thu, 10 Jul 2008) | 2 lines
Added filename to unknown opcode/command warnings of EMC scripts.
........
r32989 | lordhoto | 2008-07-10 14:12:42 +0200 (Thu, 10 Jul 2008) | 2 lines
Added filename to unkown command/opcode warnings for TIM scripts.
........
r32990 | lordhoto | 2008-07-10 14:14:00 +0200 (Thu, 10 Jul 2008) | 2 lines
Typo.
........
r32992 | eriktorbjorn | 2008-07-10 18:19:17 +0200 (Thu, 10 Jul 2008) | 2 lines
Fixed Kyra 3 detection regression.
........
r32994 | tramboi | 2008-07-10 20:01:54 +0200 (Thu, 10 Jul 2008) | 1 line
Fixed a few warnings
........
r33002 | peres001 | 2008-07-11 14:55:08 +0200 (Fri, 11 Jul 2008) | 2 lines
Fixed leak in sound code by explicitly deleting the midi driver.
........
r33003 | peres001 | 2008-07-11 15:06:28 +0200 (Fri, 11 Jul 2008) | 3 lines
Moved program and command execution code out of the engine, into their own brand new
classes.
........
r33004 | buddha_ | 2008-07-11 15:13:28 +0200 (Fri, 11 Jul 2008) | 1 line
Update MSVC project files.
........
r33006 | peres001 | 2008-07-11 15:36:22 +0200 (Fri, 11 Jul 2008) | 1 line
Cleanup.
........
r33007 | peres001 | 2008-07-11 17:07:13 +0200 (Fri, 11 Jul 2008) | 1 line
Added a script (courtesy of salty-horse) to create/set properties for source files under version control by Subversion. Specifically, the mime-type, eol-style and keywords properties are handled.
........
r33009 | fingolfin | 2008-07-11 22:28:14 +0200 (Fri, 11 Jul 2008) | 1 line
Don't use kPlainSoundType if you don't have to
........
r33010 | fingolfin | 2008-07-11 22:28:50 +0200 (Fri, 11 Jul 2008) | 1 line
cleanup
........
r33014 | drmccoy | 2008-07-12 17:21:38 +0200 (Sat, 12 Jul 2008) | 3 lines
Changed tricky variable access from pointers to a new class that minds endianess.
This should fix a few regressions with BE games on LE systems and vice versa that I introduced when I changed how variables are stored (which was necessary to get Woodruff work on BE systems).
........
r33017 | tramboi | 2008-07-12 22:35:44 +0200 (Sat, 12 Jul 2008) | 2 lines
Minor constness fix to help with aliasing
........
r33021 | peres001 | 2008-07-13 05:30:14 +0200 (Sun, 13 Jul 2008) | 1 line
Properly implemented the OFF command. The new rendering order for graphics let this mistake finally surface.
........
r33022 | peres001 | 2008-07-13 05:39:42 +0200 (Sun, 13 Jul 2008) | 1 line
Cleanup and improved debugging output for CommandExec::run()
........
r33023 | peres001 | 2008-07-13 08:27:31 +0200 (Sun, 13 Jul 2008) | 1 line
Cleanup of walk code.
........
r33030 | athrxx | 2008-07-13 14:20:24 +0200 (Sun, 13 Jul 2008) | 1 line
- fix for bug #2016965: KYRA: does not compile in MSVC71
........
r33033 | peres001 | 2008-07-13 15:04:36 +0200 (Sun, 13 Jul 2008) | 1 line
More refactoring of walk code.
........
r33052 | peres001 | 2008-07-14 02:13:31 +0200 (Mon, 14 Jul 2008) | 1 line
Made sure characters are not removed from the rendering list during switches.
........
r33053 | peres001 | 2008-07-14 02:21:05 +0200 (Mon, 14 Jul 2008) | 1 line
Fixed regression in walk code. Now standing frames are correctly selected when the character encounters an unexpected blocking object in his/her path.
........
r33056 | fingolfin | 2008-07-14 09:54:18 +0200 (Mon, 14 Jul 2008) | 1 line
Fixed code formatting
........
r33057 | dreammaster | 2008-07-14 12:33:57 +0200 (Mon, 14 Jul 2008) | 1 line
Fix for missing data in the savegame format that could result in not being able to talk to Goewin in the apothecary after restoring a savegame
........
r33058 | peres001 | 2008-07-14 15:35:43 +0200 (Mon, 14 Jul 2008) | 1 line
Removed all labels from the rendering list to avoid random crashes after introduction is over.
........
Modified Paths:
--------------
scummvm/branches/gsoc2008-tfmx/backends/midi/quicktime.cpp
scummvm/branches/gsoc2008-tfmx/backends/platform/ds/arm9/source/osystem_ds.cpp
scummvm/branches/gsoc2008-tfmx/dists/msvc7/parallaction.vcproj
scummvm/branches/gsoc2008-tfmx/dists/msvc71/parallaction.vcproj
scummvm/branches/gsoc2008-tfmx/dists/msvc8/parallaction.vcproj
scummvm/branches/gsoc2008-tfmx/dists/msvc9/parallaction.vcproj
scummvm/branches/gsoc2008-tfmx/engines/gob/driver_vga.cpp
scummvm/branches/gsoc2008-tfmx/engines/gob/goblin.cpp
scummvm/branches/gsoc2008-tfmx/engines/gob/goblin.h
scummvm/branches/gsoc2008-tfmx/engines/gob/inter.h
scummvm/branches/gsoc2008-tfmx/engines/gob/inter_v1.cpp
scummvm/branches/gsoc2008-tfmx/engines/gob/inter_v2.cpp
scummvm/branches/gsoc2008-tfmx/engines/gob/mult.cpp
scummvm/branches/gsoc2008-tfmx/engines/gob/mult.h
scummvm/branches/gsoc2008-tfmx/engines/gob/mult_v1.cpp
scummvm/branches/gsoc2008-tfmx/engines/gob/mult_v2.cpp
scummvm/branches/gsoc2008-tfmx/engines/gob/sound/sound.h
scummvm/branches/gsoc2008-tfmx/engines/gob/sound/soundmixer.h
scummvm/branches/gsoc2008-tfmx/engines/igor/igor.cpp
scummvm/branches/gsoc2008-tfmx/engines/kyra/detection.cpp
scummvm/branches/gsoc2008-tfmx/engines/kyra/script.cpp
scummvm/branches/gsoc2008-tfmx/engines/kyra/script.h
scummvm/branches/gsoc2008-tfmx/engines/kyra/script_tim.cpp
scummvm/branches/gsoc2008-tfmx/engines/kyra/script_tim.h
scummvm/branches/gsoc2008-tfmx/engines/kyra/sound.cpp
scummvm/branches/gsoc2008-tfmx/engines/kyra/sound_towns.cpp
scummvm/branches/gsoc2008-tfmx/engines/lure/luredefs.h
scummvm/branches/gsoc2008-tfmx/engines/lure/res_struct.cpp
scummvm/branches/gsoc2008-tfmx/engines/parallaction/callables_ns.cpp
scummvm/branches/gsoc2008-tfmx/engines/parallaction/dialogue.cpp
scummvm/branches/gsoc2008-tfmx/engines/parallaction/disk_br.cpp
scummvm/branches/gsoc2008-tfmx/engines/parallaction/exec_br.cpp
scummvm/branches/gsoc2008-tfmx/engines/parallaction/exec_ns.cpp
scummvm/branches/gsoc2008-tfmx/engines/parallaction/input.cpp
scummvm/branches/gsoc2008-tfmx/engines/parallaction/parallaction.cpp
scummvm/branches/gsoc2008-tfmx/engines/parallaction/parallaction.h
scummvm/branches/gsoc2008-tfmx/engines/parallaction/parallaction_br.cpp
scummvm/branches/gsoc2008-tfmx/engines/parallaction/parallaction_ns.cpp
scummvm/branches/gsoc2008-tfmx/engines/parallaction/sound.cpp
scummvm/branches/gsoc2008-tfmx/engines/parallaction/walk.cpp
scummvm/branches/gsoc2008-tfmx/engines/scumm/detection.cpp
scummvm/branches/gsoc2008-tfmx/engines/scumm/he/resource_he.cpp
scummvm/branches/gsoc2008-tfmx/engines/scumm/saveload.cpp
Added Paths:
-----------
scummvm/branches/gsoc2008-tfmx/common/unarj.cpp
scummvm/branches/gsoc2008-tfmx/common/unarj.h
scummvm/branches/gsoc2008-tfmx/engines/drascula/actors.cpp
scummvm/branches/gsoc2008-tfmx/engines/drascula/converse.cpp
scummvm/branches/gsoc2008-tfmx/engines/drascula/graphics.cpp
scummvm/branches/gsoc2008-tfmx/engines/drascula/interface.cpp
scummvm/branches/gsoc2008-tfmx/engines/drascula/objects.cpp
scummvm/branches/gsoc2008-tfmx/engines/drascula/palette.cpp
scummvm/branches/gsoc2008-tfmx/engines/drascula/saveload.cpp
scummvm/branches/gsoc2008-tfmx/engines/drascula/sound.cpp
scummvm/branches/gsoc2008-tfmx/engines/gob/variables.cpp
scummvm/branches/gsoc2008-tfmx/engines/gob/variables.h
scummvm/branches/gsoc2008-tfmx/engines/parallaction/exec.h
scummvm/branches/gsoc2008-tfmx/tools/svnpropset.sh
Property Changed:
----------------
scummvm/branches/gsoc2008-tfmx/
Property changes on: scummvm/branches/gsoc2008-tfmx
___________________________________________________________________
Name: svnmerge-integrated
- /scummvm/trunk:1-32981
+ /scummvm/trunk:1-33058
Modified: scummvm/branches/gsoc2008-tfmx/backends/midi/quicktime.cpp
===================================================================
--- scummvm/branches/gsoc2008-tfmx/backends/midi/quicktime.cpp 2008-07-14 18:42:38 UTC (rev 33059)
+++ scummvm/branches/gsoc2008-tfmx/backends/midi/quicktime.cpp 2008-07-14 18:54:15 UTC (rev 33060)
@@ -132,8 +132,7 @@
return MERR_DEVICE_NOT_AVAILABLE;
}
-void MidiDriver_QT::close()
-{
+void MidiDriver_QT::close() {
MidiDriver_MPU401::close();
dispose();
}
@@ -248,8 +247,7 @@
NASetController(qtNoteAllocator, qtNoteChannel[channel], kControllerPitchBend, theBend);
}
-void MidiDriver_QT::dispose()
-{
+void MidiDriver_QT::dispose() {
for (int i = 0; i < 16; i++) {
if (qtNoteChannel[i] != 0)
NADisposeNoteChannel(qtNoteAllocator, qtNoteChannel[i]);
Modified: scummvm/branches/gsoc2008-tfmx/backends/platform/ds/arm9/source/osystem_ds.cpp
===================================================================
--- scummvm/branches/gsoc2008-tfmx/backends/platform/ds/arm9/source/osystem_ds.cpp 2008-07-14 18:42:38 UTC (rev 33059)
+++ scummvm/branches/gsoc2008-tfmx/backends/platform/ds/arm9/source/osystem_ds.cpp 2008-07-14 18:54:15 UTC (rev 33060)
@@ -160,13 +160,13 @@
// Ensure we copy using 16 bit quantities due to limitation of VRAM addressing
- u16* image = (u16 *) DS::get8BitBackBuffer();
+ const u16* image = (const u16 *) DS::get8BitBackBuffer();
for (int y = 0; y < DS::getGameHeight(); y++)
{
DC_FlushRange(image + (y << 8), DS::getGameWidth());
for (int x = 0; x < DS::getGameWidth() >> 1; x++)
{
- *(((u16 *) (surf->pixels)) + y * (DS::getGameWidth() >> 1) + x) = image[y << 8 + x];
+ *(((u16 *) (surf->pixels)) + y * (DS::getGameWidth() >> 1) + x) = image[(y << 8) + x];
}
}
@@ -279,7 +279,7 @@
void OSystem_DS::copyRectToOverlay (const OverlayColor *buf, int pitch, int x, int y, int w, int h) {
u16* bg = (u16 *) DS::get16BitBackBuffer();
- u16* src = (u16 *) buf;
+ const u16* src = (const u16 *) buf;
// if (x + w > 256) w = 256 - x;
//if (x + h > 256) h = 256 - y;
Added: scummvm/branches/gsoc2008-tfmx/common/unarj.cpp
===================================================================
--- scummvm/branches/gsoc2008-tfmx/common/unarj.cpp (rev 0)
+++ scummvm/branches/gsoc2008-tfmx/common/unarj.cpp 2008-07-14 18:54:15 UTC (rev 33060)
@@ -0,0 +1,701 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+// Heavily based on Unarj 2.65
+
+/* UNARJ.C, UNARJ, R JUNG, 06/05/02
+ * Main Extractor routine
+ * Copyright (c) 1991-2002 by ARJ Software, Inc. All rights reserved.
+ *
+ * This code may be freely used in programs that are NOT ARJ archivers
+ * (both compress and extract ARJ archives).
+ *
+ * If you wish to distribute a modified version of this program, you
+ * MUST indicate that it is a modified version both in the program and
+ * source code.
+ *
+ * We are holding the copyright on the source code, so please do not
+ * delete our name from the program files or from the documentation.
+ *
+ * We wish to give credit to Haruhiko Okumura for providing the
+ * basic ideas for ARJ and UNARJ in his program AR. Please note
+ * that UNARJ is significantly different from AR from an archive
+ * structural point of view.
+ *
+ */
+
+#include "common/scummsys.h"
+#include "common/util.h"
+#include "common/unarj.h"
+
+namespace Common {
+
+static uint32 CRCtable[256];
+
+static void InitCRC(void) {
+ const uint32 poly = 0xEDB88320;
+ int i, j;
+ uint32 n;
+
+ for (i = 0; i < 256; i++) {
+ n = i;
+ for (j = 0; j < 8; j++)
+ n = (n & 1) ? ((n >> 1) ^ poly) : (n >> 1);
+ CRCtable[i] = n;
+ }
+}
+
+static uint32 GetCRC(byte *data, int len) {
+ uint32 CRC = 0xFFFFFFFF;
+ int i;
+ for (i = 0; i < len; i++)
+ CRC = (CRC >> 8) ^ CRCtable[(CRC ^ data[i]) & 0xFF];
+ return CRC ^ 0xFFFFFFFF;
+}
+
+ArjFile::ArjFile() {
+ InitCRC();
+ _isOpen = false;
+ _fallBack = false;
+}
+
+ArjFile::~ArjFile() {
+ close();
+
+ for (uint i = 0; i < _headers.size(); i++)
+ delete _headers[i];
+
+ _headers.clear();
+ _fileMap.clear();
+ _archMap.clear();
+}
+
+void ArjFile::registerArchive(const String &filename) {
+ int32 first_hdr_pos;
+ ArjHeader *header;
+
+ if (!_currArchive.open(filename))
+ return;
+
+ first_hdr_pos = findHeader();
+
+ if (first_hdr_pos < 0) {
+ warning("ArjFile::registerArchive(): Could not find a valid header");
+ return;
+ }
+
+ _currArchive.seek(first_hdr_pos, SEEK_SET);
+ if (readHeader() == NULL)
+ return;
+
+ while ((header = readHeader()) != NULL) {
+ _headers.push_back(header);
+
+ _currArchive.seek(header->compSize, SEEK_CUR);
+
+ _fileMap[header->filename] = _headers.size() - 1;
+ _archMap[header->filename] = filename;
+ }
+
+ _currArchive.close();
+
+ debug(0, "ArjFile::registerArchive(%s): Located %d files", filename.c_str(), _headers.size());
+}
+
+int32 ArjFile::findHeader(void) {
+ long arcpos, lastpos;
+ int c;
+ byte header[HEADERSIZE_MAX];
+ uint32 crc;
+ uint16 headersize;
+
+ arcpos = _currArchive.pos();
+ _currArchive.seek(0L, SEEK_END);
+ lastpos = _currArchive.pos() - 2;
+ if (lastpos > MAXSFX)
+ lastpos = MAXSFX;
+
+ for ( ; arcpos < lastpos; arcpos++) {
+ _currArchive.seek(arcpos, SEEK_SET);
+ c = _currArchive.readByte();
+ while (arcpos < lastpos) {
+ if (c != HEADER_ID_LO) // low order first
+ c = _currArchive.readByte();
+ else if ((c = _currArchive.readByte()) == HEADER_ID_HI)
+ break;
+ arcpos++;
+ }
+ if (arcpos >= lastpos)
+ break;
+ if ((headersize = _currArchive.readUint16LE()) <= HEADERSIZE_MAX) {
+ _currArchive.read(header, headersize);
+ crc = GetCRC(header, headersize);
+ if (crc == _currArchive.readUint32LE()) {
+ _currArchive.seek(arcpos, SEEK_SET);
+ return arcpos;
+ }
+ }
+ }
+ return -1; // could not find a valid header
+}
+
+ArjHeader *ArjFile::readHeader() {
+ ArjHeader header;
+ ArjHeader *head;
+ byte headData[HEADERSIZE_MAX];
+
+ header.id = _currArchive.readUint16LE();
+ if (header.id != HEADER_ID) {
+ warning("ArjFile::readHeader(): Bad header ID (%x)", header.id);
+
+ return NULL;
+ }
+
+ header.headerSize = _currArchive.readUint16LE();
+ if (header.headerSize == 0)
+ return NULL; // end of archive
+ if (header.headerSize > HEADERSIZE_MAX) {
+ warning("ArjFile::readHeader(): Bad header");
+
+ return NULL;
+ }
+
+ int rSize = _currArchive.read(headData, header.headerSize);
+
+ MemoryReadStream readS(headData, rSize);
+
+ header.headerCrc = _currArchive.readUint32LE();
+ if (GetCRC(headData, header.headerSize) != header.headerCrc) {
+ warning("ArjFile::readHeader(): Bad header CRC");
+ return NULL;
+ }
+
+ header.firstHdrSize = readS.readByte();
+ header.nbr = readS.readByte();
+ header.xNbr = readS.readByte();
+ header.hostOs = readS.readByte();
+ header.flags = readS.readByte();
+ header.method = readS.readByte();
+ header.fileType = readS.readByte();
+ (void)readS.readByte();
+ header.timeStamp = readS.readUint32LE();
+ header.compSize = readS.readSint32LE();
+ header.origSize = readS.readSint32LE();
+ header.fileCRC = readS.readUint32LE();
+ header.entryPos = readS.readUint16LE();
+ header.fileMode = readS.readUint16LE();
+ header.hostData = readS.readUint16LE();
+
+ if (header.origSize < 0 || header.compSize < 0) {
+ warning("ArjFile::readHeader(): Wrong file size");
+ return NULL;
+ }
+
+ strncpy(header.filename, (const char *)&headData[header.firstHdrSize], FNAME_MAX);
+
+ strncpy(header.comment, (const char *)&headData[header.firstHdrSize + strlen(header.filename) + 1], COMMENT_MAX);
+
+ /* if extheadersize == 0 then no CRC */
+ /* otherwise read extheader data and read 4 bytes for CRC */
+
+ while ((header.extHeaderSize = _currArchive.readUint16LE()) != 0)
+ _currArchive.seek((long)(header.extHeaderSize + 4), SEEK_CUR);
+
+ header.pos = _currArchive.pos();
+
+ head = new ArjHeader(header);
+
+ return head;
+}
+
+
+bool ArjFile::open(const Common::String &filename, AccessMode mode) {
+ if (_isOpen)
+ error("Attempt to open another instance of archive");
+
+ _isOpen = false;
+
+ if (_fallBack) {
+ _currArchive.open(filename);
+ if (_currArchive.isOpen()) {
+ _isOpen = true;
+ _uncompressed = &_currArchive;
+ return true;
+ }
+ }
+
+ if (!_fileMap.contains(filename))
+ return false;
+
+ _isOpen = true;
+
+ ArjHeader *hdr = _headers[_fileMap[filename]];
+
+ _compsize = hdr->compSize;
+ _origsize = hdr->origSize;
+
+ _uncompressedData = (byte *)malloc(_origsize);
+ _outstream = new MemoryWriteStream(_uncompressedData, _origsize);
+
+ _currArchive.open(_archMap[filename]);
+ _currArchive.seek(hdr->pos, SEEK_SET);
+
+ if (hdr->method == 0) { // store
+ _currArchive.read(_uncompressedData, _origsize);
+ } else {
+ _compressedData = (byte *)malloc(_compsize);
+ _currArchive.read(_compressedData, _compsize);
+
+ _compressed = new MemoryReadStream(_compressedData, _compsize);
+
+ if (hdr->method == 1 || hdr->method == 2 || hdr->method == 3)
+ decode();
+ else if (hdr->method == 4)
+ decode_f();
+
+ delete _compressed;
+ free(_compressedData);
+ }
+
+ _currArchive.close();
+ delete _outstream;
+ _outstream = NULL;
+
+ _uncompressed = new MemoryReadStream(_uncompressedData, _origsize);
+
+ return true;
+}
+
+void ArjFile::close() {
+ if (!_isOpen)
+ return;
+
+ _isOpen = false;
+
+ if (_fallBack) {
+ _currArchive.close();
+ return;
+ } else {
+ delete _uncompressed;
+ }
+
+ _uncompressed = NULL;
+
+ free(_uncompressedData);
+ _uncompressedData = NULL;
+}
+
+uint32 ArjFile::read(void *dataPtr, uint32 dataSize) {
+ return _uncompressed->read(dataPtr, dataSize);
+}
+
+bool ArjFile::eos() {
+ return _uncompressed->eos();
+}
+
+uint32 ArjFile::pos() {
+ return _uncompressed->pos();
+}
+
+uint32 ArjFile::size() {
+ return _uncompressed->size();
+}
+
+void ArjFile::seek(int32 offset, int whence) {
+ _uncompressed->seek(offset, whence);
+}
+
+void ArjFile::init_getbits() {
+ _bitbuf = 0;
+ _subbitbuf = 0;
+ _bitcount = 0;
+ fillbuf(2 * CHAR_BIT);
+}
+
+void ArjFile::fillbuf(int n) { // Shift bitbuf n bits left, read n bits
+ _bitbuf = (_bitbuf << n) & 0xFFFF; /* lose the first n bits */
+ while (n > _bitcount) {
+ _bitbuf |= _subbitbuf << (n -= _bitcount);
+ if (_compsize != 0) {
+ _compsize--;
+ _subbitbuf = _compressed->readByte();
+ } else
+ _subbitbuf = 0;
+ _bitcount = CHAR_BIT;
+ }
+ _bitbuf |= _subbitbuf >> (_bitcount -= n);
+}
+
+uint16 ArjFile::getbits(int n) {
+ uint16 x;
+
+ x = _bitbuf >> (2 * CHAR_BIT - n);
+ fillbuf(n);
+ return x;
+}
+
+
+
+/* Huffman decode routines */
+
+void ArjFile::make_table(int nchar, byte *bitlen, int tablebits, uint16 *table, int tablesize) {
+ uint16 count[17], weight[17], start[18], *p;
+ uint i, k, len, ch, jutbits, avail, nextcode, mask;
+
+ for (i = 1; i <= 16; i++)
+ count[i] = 0;
+ for (i = 0; (int)i < nchar; i++)
+ count[bitlen[i]]++;
+
+ start[1] = 0;
+ for (i = 1; i <= 16; i++)
+ start[i + 1] = start[i] + (count[i] << (16 - i));
+ if (start[17] != (uint16) (1 << 16))
+ error("ArjFile::make_table(): bad file data");
+
+ jutbits = 16 - tablebits;
+ for (i = 1; (int)i <= tablebits; i++) {
+ start[i] >>= jutbits;
+ weight[i] = 1 << (tablebits - i);
+ }
+ while (i <= 16) {
+ weight[i] = 1 << (16 - i);
+ i++;
+ }
+
+ i = start[tablebits + 1] >> jutbits;
+ if (i != (uint16) (1 << 16)) {
+ k = 1 << tablebits;
+ while (i != k)
+ table[i++] = 0;
+ }
+
+ avail = nchar;
+ mask = 1 << (15 - tablebits);
+ for (ch = 0; (int)ch < nchar; ch++) {
+ if ((len = bitlen[ch]) == 0)
+ continue;
+ k = start[len];
+ nextcode = k + weight[len];
+ if ((int)len <= tablebits) {
+ if (nextcode > (uint)tablesize)
+ error("ArjFile::make_table(): bad file data");
+ for (i = start[len]; i < nextcode; i++)
+ table[i] = ch;
+ } else {
+ p = &table[k >> jutbits];
+ i = len - tablebits;
+ while (i != 0) {
+ if (*p == 0) {
+ _right[avail] = _left[avail] = 0;
+ *p = avail++;
+ }
+ if (k & mask)
+ p = &_right[*p];
+ else
+ p = &_left[*p];
+ k <<= 1;
+ i--;
+ }
+ *p = ch;
+ }
+ start[len] = nextcode;
+ }
+}
+
+void ArjFile::read_pt_len(int nn, int nbit, int i_special) {
+ int i, n;
+ int16 c;
+ uint16 mask;
+
+ n = getbits(nbit);
+ if (n == 0) {
+ c = getbits(nbit);
+ for (i = 0; i < nn; i++)
+ _pt_len[i] = 0;
+ for (i = 0; i < 256; i++)
+ _pt_table[i] = c;
+ } else {
+ i = 0;
+ while (i < n) {
+ c = _bitbuf >> (13);
+ if (c == 7) {
+ mask = 1 << (12);
+ while (mask & _bitbuf) {
+ mask >>= 1;
+ c++;
+ }
+ }
+ fillbuf((c < 7) ? 3 : (int)(c - 3));
+ _pt_len[i++] = (byte)c;
+ if (i == i_special) {
+ c = getbits(2);
+ while (--c >= 0)
+ _pt_len[i++] = 0;
+ }
+ }
+ while (i < nn)
+ _pt_len[i++] = 0;
+ make_table(nn, _pt_len, 8, _pt_table, PTABLESIZE); // replaced sizeof
+ }
+}
+
+void ArjFile::read_c_len() {
+ int16 i, c, n;
+ uint16 mask;
+
+ n = getbits(CBIT);
+ if (n == 0) {
+ c = getbits(CBIT);
+ for (i = 0; i < NC; i++)
+ _c_len[i] = 0;
+ for (i = 0; i < CTABLESIZE; i++)
+ _c_table[i] = c;
+ } else {
+ i = 0;
+ while (i < n) {
+ c = _pt_table[_bitbuf >> (8)];
+ if (c >= NT) {
+ mask = 1 << (7);
+ do {
+ if (_bitbuf & mask)
+ c = _right[c];
+ else
+ c = _left[c];
+ mask >>= 1;
+ } while (c >= NT);
+ }
+ fillbuf((int)(_pt_len[c]));
+ if (c <= 2) {
+ if (c == 0)
+ c = 1;
+ else if (c == 1)
+ c = getbits(4) + 3;
+ else
+ c = getbits(CBIT) + 20;
+ while (--c >= 0)
+ _c_len[i++] = 0;
+ }
+ else
+ _c_len[i++] = (byte)(c - 2);
+ }
+ while (i < NC)
+ _c_len[i++] = 0;
+ make_table(NC, _c_len, 12, _c_table, CTABLESIZE); // replaced sizeof
+ }
+}
+
+uint16 ArjFile::decode_c() {
+ uint16 j, mask;
+
+ if (_blocksize == 0) {
+ _blocksize = getbits(16);
+ read_pt_len(NT, TBIT, 3);
+ read_c_len();
+ read_pt_len(NP, PBIT, -1);
+ }
+ _blocksize--;
+ j = _c_table[_bitbuf >> 4];
+ if (j >= NC) {
+ mask = 1 << (3);
+ do {
+ if (_bitbuf & mask)
+ j = _right[j];
+ else
+ j = _left[j];
+ mask >>= 1;
+ } while (j >= NC);
+ }
+ fillbuf((int)(_c_len[j]));
+ return j;
+}
+
+uint16 ArjFile::decode_p() {
+ uint16 j, mask;
+
+ j = _pt_table[_bitbuf >> (8)];
+ if (j >= NP) {
+ mask = 1 << (7);
+ do {
+ if (_bitbuf & mask)
+ j = _right[j];
+ else
+ j = _left[j];
+ mask >>= 1;
+ } while (j >= NP);
+ }
+ fillbuf((int)(_pt_len[j]));
+ if (j != 0) {
+ j--;
+ j = (1 << j) + getbits((int)j);
+ }
+ return j;
+}
+
+void ArjFile::decode_start() {
+ _blocksize = 0;
+ init_getbits();
+}
+
+void ArjFile::decode() {
+ int16 i;
+ int16 j;
+ int16 c;
+ int16 r;
+ int32 count;
+
+ decode_start();
+ count = 0;
+ r = 0;
+
+ while (count < _origsize) {
+ if ((c = decode_c()) <= ARJ_UCHAR_MAX) {
+ _text[r] = (byte) c;
+ count++;
+ if (++r >= DDICSIZ) {
+ r = 0;
+ _outstream->write(_text, DDICSIZ);
+ }
+ } else {
+ j = c - (ARJ_UCHAR_MAX + 1 - THRESHOLD);
+ count += j;
+ i = decode_p();
+ if ((i = r - i - 1) < 0)
+ i += DDICSIZ;
+ if (r > i && r < DDICSIZ - MAXMATCH - 1) {
+ while (--j >= 0)
+ _text[r++] = _text[i++];
+ } else {
+ while (--j >= 0) {
+ _text[r] = _text[i];
+ if (++r >= DDICSIZ) {
+ r = 0;
+ _outstream->write(_text, DDICSIZ);
+ }
+ if (++i >= DDICSIZ)
+ i = 0;
+ }
+ }
+ }
+ }
+ if (r != 0)
+ _outstream->write(_text, r);
+}
+
+/* Macros */
+
+#define BFIL {_getbuf|=_bitbuf>>_getlen;fillbuf(CODE_BIT-_getlen);_getlen=CODE_BIT;}
+#define GETBIT(c) {if(_getlen<=0)BFIL c=(_getbuf&0x8000)!=0;_getbuf<<=1;_getlen--;}
+#define BPUL(l) {_getbuf<<=l;_getlen-=l;}
+#define GETBITS(c,l) {if(_getlen<l)BFIL c=(uint16)_getbuf>>(CODE_BIT-l);BPUL(l)}
+
+int16 ArjFile::decode_ptr() {
+ int16 c = 0;
+ int16 width;
+ int16 plus;
+ int16 pwr;
+
+ plus = 0;
+ pwr = 1 << (STRTP);
+ for (width = (STRTP); width < (STOPP); width++) {
+ GETBIT(c);
+ if (c == 0)
+ break;
+ plus += pwr;
+ pwr <<= 1;
+ }
+ if (width != 0)
+ GETBITS(c, width);
+ c += plus;
+ return c;
+}
+
+int16 ArjFile::decode_len() {
+ int16 c = 0;
+ int16 width;
+ int16 plus;
+ int16 pwr;
+
+ plus = 0;
+ pwr = 1 << (STRTL);
+ for (width = (STRTL); width < (STOPL); width++) {
+ GETBIT(c);
+ if (c == 0)
+ break;
+ plus += pwr;
+ pwr <<= 1;
+ }
+ if (width != 0)
+ GETBITS(c, width);
+ c += plus;
+ return c;
+}
+
+void ArjFile::decode_f() {
+ int16 i;
+ int16 j;
+ int16 c;
+ int16 r;
+ int16 pos1;
+ int32 count;
+
+ init_getbits();
+ _getlen = _getbuf = 0;
+ count = 0;
+ r = 0;
+
+ while (count < _origsize) {
+ c = decode_len();
+ if (c == 0) {
+ GETBITS(c, CHAR_BIT);
+ _text[r] = (byte)c;
+ count++;
+ if (++r >= DDICSIZ) {
+ r = 0;
+ _outstream->write(_text, DDICSIZ);
+ }
+ } else {
+ j = c - 1 + THRESHOLD;
+ count += j;
+ pos1 = decode_ptr();
+ if ((i = r - pos1 - 1) < 0)
+ i += DDICSIZ;
+ while (j-- > 0) {
+ _text[r] = _text[i];
+ if (++r >= DDICSIZ) {
+ r = 0;
+ _outstream->write(_text, DDICSIZ);
+ }
+ if (++i >= DDICSIZ)
+ i = 0;
+ }
+ }
+ }
+ if (r != 0)
+ _outstream->write(_text, r);
+}
+
+
+} // End of namespace Common
Property changes on: scummvm/branches/gsoc2008-tfmx/common/unarj.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Rev Author URL Id
Name: svn:eol-style
+ native
Added: scummvm/branches/gsoc2008-tfmx/common/unarj.h
===================================================================
--- scummvm/branches/gsoc2008-tfmx/common/unarj.h (rev 0)
+++ scummvm/branches/gsoc2008-tfmx/common/unarj.h 2008-07-14 18:54:15 UTC (rev 33060)
@@ -0,0 +1,185 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef COMMON_UNARJ_H
+#define COMMON_UNARJ_H
+
+#include "common/file.h"
+#include "common/hash-str.h"
+
+namespace Common {
+
+#define HEADER_ID 0xEA60
+#define HEADER_ID_HI 0xEA
+#define HEADER_ID_LO 0x60
+#define FIRST_HDR_SIZE 30
+#define FIRST_HDR_SIZE_V 34
+#define COMMENT_MAX 2048
+#define FNAME_MAX 512
+#define HEADERSIZE_MAX (FIRST_HDR_SIZE + 10 + FNAME_MAX + COMMENT_MAX)
+#define CRC_MASK 0xFFFFFFFFL
+#define MAXSFX 25000L
+
+#define CODE_BIT 16
+#define CHAR_BIT 8
+#define ARJ_UCHAR_MAX 255 // UCHAR_MAX is defined in limits.h in MSVC
+#define THRESHOLD 3
+#define DDICSIZ 26624
+#define MAXDICBIT 16
+#define MATCHBIT 8
+#define MAXMATCH 256
+#define NC (ARJ_UCHAR_MAX + MAXMATCH + 2 - THRESHOLD)
+#define NP (MAXDICBIT + 1)
+#define CBIT 9
+#define NT (CODE_BIT + 3)
+#define PBIT 5
+#define TBIT 5
+
+#if NT > NP
+#define NPT NT
+#else
+#define NPT NP
+#endif
+
+#define CTABLESIZE 4096
+#define PTABLESIZE 256
+
+#define STRTP 9
+#define STOPP 13
+
+#define STRTL 0
+#define STOPL 7
+
+struct ArjHeader {
+ int32 pos;
+ uint16 id;
+ uint16 headerSize;
+ //
+ byte firstHdrSize;
+ byte nbr;
+ byte xNbr;
+ byte hostOs;
+ byte flags;
+ byte method;
+ byte fileType;
+ byte pad;
+ uint32 timeStamp;
+ int32 compSize;
+ int32 origSize;
+ uint32 fileCRC;
+ uint16 entryPos;
+ uint16 fileMode;
+ uint16 hostData;
+ char filename[FNAME_MAX];
+ char comment[COMMENT_MAX];
+ uint16 extHeaderSize;
+
+ uint32 headerCrc;
+};
+
+typedef HashMap<String, int, IgnoreCase_Hash, IgnoreCase_EqualTo> ArjFilesMap;
+
+class ArjFile : public File {
+public:
+ ArjFile();
+ ~ArjFile();
+
+ void enableFallback(bool val) { _fallBack = val; }
+
+ void registerArchive(const String &filename);
+
+ bool open(const Common::String &filename, AccessMode mode = kFileReadMode);
+ void close();
+
+ uint32 read(void *dataPtr, uint32 dataSize);
+ bool eos();
+ uint32 pos();
+ uint32 size();
+ void seek(int32 offset, int whence = SEEK_SET);
+ bool isOpen() { return _isOpen; }
+
+private:
+ bool _fallBack;
+
+ File _currArchive;
+ Array<ArjHeader *> _headers;
+ ArjFilesMap _fileMap;
+ StringMap _archMap;
+ ReadStream *_stream;
+ byte *_uncompressedData;
+ byte *_compressedData;
+ MemoryWriteStream *_outstream;
+ MemoryReadStream *_compressed;
+ SeekableReadStream *_uncompressed;
+
+ bool _isOpen;
+
+ int32 findHeader(void);
+ ArjHeader *readHeader();
+
+ void decode();
+ void decode_f();
+
+ uint16 _bitbuf;
+ int32 _compsize;
+ int32 _origsize;
+ byte _subbitbuf;
+ int _bitcount;
+
+ void init_getbits();
+ void fillbuf(int n);
+ uint16 getbits(int n);
+
+
+ void make_table(int nchar, byte *bitlen, int tablebits, uint16 *table, int tablesize);
+ void read_pt_len(int nn, int nbit, int i_special);
+ void read_c_len(void);
+ uint16 decode_c(void);
+ uint16 decode_p(void);
+ void decode_start(void);
+ int16 decode_ptr(void);
+ int16 decode_len(void);
+
+private:
+ byte _text[DDICSIZ];
+
+ int16 _getlen;
+ int16 _getbuf;
+
+ uint16 _left[2 * NC - 1];
+ uint16 _right[2 * NC - 1];
+ byte _c_len[NC];
+ byte _pt_len[NPT];
+
+ uint16 _c_table[CTABLESIZE];
+ uint16 _pt_table[PTABLESIZE];
+ uint16 _blocksize;
+
+
+};
+
+} // End of namespace Common
+
+#endif
Property changes on: scummvm/branches/gsoc2008-tfmx/common/unarj.h
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Rev Author URL Id
Name: svn:eol-style
+ native
Modified: scummvm/branches/gsoc2008-tfmx/dists/msvc7/parallaction.vcproj
===================================================================
--- scummvm/branches/gsoc2008-tfmx/dists/msvc7/parallaction.vcproj 2008-07-14 18:42:38 UTC (rev 33059)
+++ scummvm/branches/gsoc2008-tfmx/dists/msvc7/parallaction.vcproj 2008-07-14 18:54:15 UTC (rev 33060)
@@ -127,6 +127,9 @@
RelativePath="..\..\engines\parallaction\disk_ns.cpp">
</File>
<File
+ RelativePath="..\..\engines\parallaction\exec.h">
+ </File>
+ <File
RelativePath="..\..\engines\parallaction\exec_br.cpp">
</File>
<File
Modified: scummvm/branches/gsoc2008-tfmx/dists/msvc71/parallaction.vcproj
===================================================================
--- scummvm/branches/gsoc2008-tfmx/dists/msvc71/parallaction.vcproj 2008-07-14 18:42:38 UTC (rev 33059)
+++ scummvm/branches/gsoc2008-tfmx/dists/msvc71/parallaction.vcproj 2008-07-14 18:54:15 UTC (rev 33060)
@@ -141,6 +141,9 @@
RelativePath="..\..\engines\parallaction\disk_ns.cpp">
</File>
<File
+ RelativePath="..\..\engines\parallaction\exec.h">
+ </File>
+ <File
RelativePath="..\..\engines\parallaction\exec_br.cpp">
</File>
<File
Modified: scummvm/branches/gsoc2008-tfmx/dists/msvc8/parallaction.vcproj
===================================================================
--- scummvm/branches/gsoc2008-tfmx/dists/msvc8/parallaction.vcproj 2008-07-14 18:42:38 UTC (rev 33059)
+++ scummvm/branches/gsoc2008-tfmx/dists/msvc8/parallaction.vcproj 2008-07-14 18:54:15 UTC (rev 33060)
@@ -201,6 +201,10 @@
>
</File>
<File
+ RelativePath="..\..\engines\parallaction\exec.h"
+ >
+ </File>
+ <File
RelativePath="..\..\engines\parallaction\exec_br.cpp"
>
</File>
Modified: scummvm/branches/gsoc2008-tfmx/dists/msvc9/parallaction.vcproj
===================================================================
--- scummvm/branches/gsoc2008-tfmx/dists/msvc9/parallaction.vcproj 2008-07-14 18:42:38 UTC (rev 33059)
+++ scummvm/branches/gsoc2008-tfmx/dists/msvc9/parallaction.vcproj 2008-07-14 18:54:15 UTC (rev 33060)
@@ -202,6 +202,10 @@
>
</File>
<File
+ RelativePath="..\..\engines\parallaction\exec.h"
+ >
+ </File>
+ <File
RelativePath="..\..\engines\parallaction\exec_br.cpp"
>
</File>
Added: scummvm/branches/gsoc2008-tfmx/engines/drascula/actors.cpp
===================================================================
--- scummvm/branches/gsoc2008-tfmx/engines/drascula/actors.cpp (rev 0)
+++ scummvm/branches/gsoc2008-tfmx/engines/drascula/actors.cpp 2008-07-14 18:54:15 UTC (rev 33060)
@@ -0,0 +1,462 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "drascula/drascula.h"
+
+namespace Drascula {
+
+void DrasculaEngine::placeIgor() {
+ int pos_igor[6] = { 1, 0, igorX, igorY, 54, 61 };
+
+ if (currentChapter == 4) {
+ pos_igor[1] = 138;
+ } else {
+ if (trackIgor == 3)
+ pos_igor[1] = 138;
+ else if (trackIgor == 1)
+ pos_igor[1] = 76;
+ }
+
+ copyRectClip(pos_igor, frontSurface, screenSurface);
+}
+
+void DrasculaEngine::placeDrascula() {
+ int pos_dr[6] = { 0, 122, drasculaX, drasculaY, 45, 77 };
+
+ if (trackDrascula == 1)
+ pos_dr[0] = 47;
+ else if (trackDrascula == 0)
+ pos_dr[0] = 1;
+ else if (trackDrascula == 3 && currentChapter == 1)
+ pos_dr[0] = 93;
+
+ if (currentChapter == 6)
+ copyRectClip(pos_dr, drawSurface2, screenSurface);
+ else
+ copyRectClip(pos_dr, backSurface, screenSurface);
+}
+
+void DrasculaEngine::placeBJ() {
+ int pos_bj[6] = { 0, 99, bjX, bjY, 26, 76 };
+
+ if (trackBJ == 3)
+ pos_bj[0] = 10;
+ else if (trackBJ == 0)
+ pos_bj[0] = 37;
+
+ copyRectClip(pos_bj, drawSurface3, screenSurface);
+}
+
+void DrasculaEngine::hiccup(int counter) {
+ int y = 0, trackCharacter = 0;
+ if (currentChapter == 3)
+ y = -1;
+
+ do {
+ counter--;
+
+ updateRoom();
+ if (currentChapter == 3)
+ updateScreen(0, 0, 0, y, 320, 200, screenSurface);
+ else
+ updateScreen(0, 1, 0, y, 320, 198, screenSurface);
+
+ if (trackCharacter == 0)
+ y++;
+ else
+ y--;
+
+ if (currentChapter == 3) {
+ if (y == 1)
+ trackCharacter = 1;
+ if (y == -1)
+ trackCharacter = 0;
+ } else {
+ if (y == 2)
+ trackCharacter = 1;
+ if (y == 0)
+ trackCharacter = 0;
+ }
+ } while (counter > 0);
+
+ updateRoom();
+ updateScreen();
+}
+
+void DrasculaEngine::startWalking() {
+ characterMoved = 1;
+
+ stepX = STEP_X;
+ stepY = STEP_Y;
+
+ if (currentChapter == 2) {
+ if ((roomX < curX) && (roomY <= (curY + curHeight)))
+ quadrant_1();
+ else if ((roomX < curX) && (roomY > (curY + curHeight)))
+ quadrant_3();
+ else if ((roomX > curX + curWidth) && (roomY <= (curY + curHeight)))
+ quadrant_2();
+ else if ((roomX > curX + curWidth) && (roomY > (curY + curHeight)))
+ quadrant_4();
+ else if (roomY < curY + curHeight)
+ walkUp();
+ else if (roomY > curY + curHeight)
+ walkDown();
+ } else {
+ if ((roomX < curX + curWidth / 2 ) && (roomY <= (curY + curHeight)))
+ quadrant_1();
+ else if ((roomX < curX + curWidth / 2) && (roomY > (curY + curHeight)))
+ quadrant_3();
+ else if ((roomX > curX + curWidth / 2) && (roomY <= (curY + curHeight)))
+ quadrant_2();
+ else if ((roomX > curX + curWidth / 2) && (roomY > (curY + curHeight)))
+ quadrant_4();
+ else
+ characterMoved = 0;
+ }
+ startTime = getTime();
+}
+
+void DrasculaEngine::moveCharacters() {
+ int curPos[6];
+ int r;
+
+ if (characterMoved == 1 && stepX == STEP_X) {
+ for (r = 0; r < stepX; r++) {
+ if (currentChapter != 2) {
+ if (trackProtagonist == 0 && roomX - r == curX + curWidth / 2) {
+ characterMoved = 0;
+ stepX = STEP_X;
+ stepY = STEP_Y;
+ }
+ if (trackProtagonist == 1 && roomX + r == curX + curWidth / 2) {
+ characterMoved = 0;
+ stepX = STEP_X;
+ stepY = STEP_Y;
+ curX = roomX - curWidth / 2;
+ curY = roomY - curHeight;
+ }
+ } else if (currentChapter == 2) {
+ if (trackProtagonist == 0 && roomX - r == curX) {
+ characterMoved = 0;
+ stepX = STEP_X;
+ stepY = STEP_Y;
+ }
+ if (trackProtagonist == 1 && roomX + r == curX + curWidth) {
+ characterMoved = 0;
+ stepX = STEP_X;
+ stepY = STEP_Y;
+ curX = roomX - curWidth + 4;
+ curY = roomY - curHeight;
+ }
+ }
+ }
+ }
+ if (characterMoved == 1 && stepY == STEP_Y) {
+ for (r = 0; r < stepY; r++) {
+ if (trackProtagonist == 2 && roomY - r == curY + curHeight) {
+ characterMoved = 0;
+ stepX = STEP_X;
+ stepY = STEP_Y;
+ }
+ if (trackProtagonist == 3 && roomY + r == curY + curHeight) {
+ characterMoved = 0;
+ stepX = STEP_X;
+ stepY = STEP_Y;
+ }
+ }
+ }
+
+ if (currentChapter == 1 || currentChapter == 4 || currentChapter == 5 || currentChapter == 6) {
+ if (hare_se_ve == 0) {
+ increaseFrameNum();
+ return;
+ }
+ }
+
+ if (characterMoved == 0) {
+ curPos[0] = 0;
+ curPos[1] = DIF_MASK_HARE;
+ curPos[2] = curX;
+ curPos[3] = curY;
+ if (currentChapter == 2) {
+ curPos[4] = curWidth;
+ curPos[5] = curHeight;
+ } else {
+ curPos[4] = CHARACTER_WIDTH;
+ curPos[5] = CHARACTER_HEIGHT;
+ }
+
+ if (trackProtagonist == 0) {
+ curPos[1] = 0;
+ if (currentChapter == 2)
+ copyRectClip(curPos, extraSurface, screenSurface);
+ else
+ reduce_hare_chico(curPos[0], curPos[1], curPos[2], curPos[3], curPos[4], curPos[5],
+ factor_red[curY + curHeight], extraSurface, screenSurface);
+ } else if (trackProtagonist == 1) {
+ if (currentChapter == 2)
+ copyRectClip(curPos, extraSurface, screenSurface);
+ else
+ reduce_hare_chico(curPos[0], curPos[1], curPos[2], curPos[3], curPos[4], curPos[5],
+ factor_red[curY + curHeight], extraSurface, screenSurface);
+ } else if (trackProtagonist == 2) {
+ if (currentChapter == 2)
+ copyRectClip(curPos, backSurface, screenSurface);
+ else
+ reduce_hare_chico(curPos[0], curPos[1], curPos[2], curPos[3], curPos[4], curPos[5],
+ factor_red[curY + curHeight], backSurface, screenSurface);
+ } else {
+ if (currentChapter == 2)
+ copyRectClip(curPos, frontSurface, screenSurface);
+ else
+ reduce_hare_chico(curPos[0], curPos[1], curPos[2], curPos[3], curPos[4], curPos[5],
+ factor_red[curY + curHeight], frontSurface, screenSurface);
+ }
+ } else if (characterMoved == 1) {
+ curPos[0] = _frameX[num_frame];
+ curPos[1] = frame_y + DIF_MASK_HARE;
+ curPos[2] = curX;
+ curPos[3] = curY;
+ if (currentChapter == 2) {
+ curPos[4] = curWidth;
+ curPos[5] = curHeight;
+ } else {
+ curPos[4] = CHARACTER_WIDTH;
+ curPos[5] = CHARACTER_HEIGHT;
+ }
+ if (trackProtagonist == 0) {
+ curPos[1] = 0;
+ if (currentChapter == 2)
+ copyRectClip(curPos, extraSurface, screenSurface);
+ else
+ reduce_hare_chico(curPos[0], curPos[1], curPos[2], curPos[3], curPos[4], curPos[5],
+ factor_red[curY + curHeight], extraSurface, screenSurface);
+ } else if (trackProtagonist == 1) {
+ if (currentChapter == 2)
+ copyRectClip(curPos, extraSurface, screenSurface);
+ else
+ reduce_hare_chico(curPos[0], curPos[1], curPos[2], curPos[3], curPos[4], curPos[5],
+ factor_red[curY + curHeight], extraSurface, screenSurface);
+ } else if (trackProtagonist == 2) {
+ if (currentChapter == 2)
+ copyRectClip(curPos, backSurface, screenSurface);
+ else
+ reduce_hare_chico(curPos[0], curPos[1], curPos[2], curPos[3], curPos[4], curPos[5],
+ factor_red[curY + curHeight], backSurface, screenSurface);
+ } else {
+ if (currentChapter == 2)
+ copyRectClip(curPos, frontSurface, screenSurface);
+ else
+ reduce_hare_chico(curPos[0], curPos[1], curPos[2], curPos[3], curPos[4], curPos[5],
+ factor_red[curY + curHeight], frontSurface, screenSurface);
+ }
+ increaseFrameNum();
+ }
+}
+
+void DrasculaEngine::quadrant_1() {
+ float distanceX, distanceY;
+
+ if (currentChapter == 2)
+ distanceX = curX - roomX;
+ else
+ distanceX = curX + curWidth / 2 - roomX;
+
+ distanceY = (curY + curHeight) - roomY;
+
+ if (distanceX < distanceY) {
+ curDirection = 0;
+ trackProtagonist = 2;
+ stepX = (int)(distanceX / (distanceY / STEP_Y));
+ } else {
+ curDirection = 7;
+ trackProtagonist = 0;
+ stepY = (int)(distanceY / (distanceX / STEP_X));
+ }
+}
+
+void DrasculaEngine::quadrant_2() {
+ float distanceX, distanceY;
+
+ if (currentChapter == 2)
+ distanceX = abs(curX + curWidth - roomX);
+ else
+ distanceX = abs(curX + curWidth / 2 - roomX);
+
+ distanceY = (curY + curHeight) - roomY;
+
+ if (distanceX < distanceY) {
+ curDirection = 1;
+ trackProtagonist = 2;
+ stepX = (int)(distanceX / (distanceY / STEP_Y));
+ } else {
+ curDirection = 2;
+ trackProtagonist = 1;
+ stepY = (int)(distanceY / (distanceX / STEP_X));
+ }
+}
+
+void DrasculaEngine::quadrant_3() {
+ float distanceX, distanceY;
+
+ if (currentChapter == 2)
+ distanceX = curX - roomX;
+ else
+ distanceX = curX + curWidth / 2 - roomX;
+
+ distanceY = roomY - (curY + curHeight);
+
+ if (distanceX < distanceY) {
+ curDirection = 5;
+ trackProtagonist = 3;
+ stepX = (int)(distanceX / (distanceY / STEP_Y));
+ } else {
+ curDirection = 6;
+ trackProtagonist = 0;
+ stepY = (int)(distanceY / (distanceX / STEP_X));
+ }
+}
+
+void DrasculaEngine::quadrant_4() {
+ float distanceX, distanceY;
+
+ if (currentChapter == 2)
+ distanceX = abs(curX + curWidth - roomX);
+ else
+ distanceX = abs(curX + curWidth / 2 - roomX);
+
+ distanceY = roomY - (curY + curHeight);
+
+ if (distanceX < distanceY) {
+ curDirection = 4;
+ trackProtagonist = 3;
+ stepX = (int)(distanceX / (distanceY / STEP_Y));
+ } else {
+ curDirection = 3;
+ trackProtagonist = 1;
+ stepY = (int)(distanceY / (distanceX / STEP_X));
+ }
+}
+
+void DrasculaEngine::increaseFrameNum() {
+ timeDiff = getTime() - startTime;
+
+ if (timeDiff >= 6) {
+ startTime = getTime();
+ num_frame++;
+ if (num_frame == 6)
+ num_frame = 0;
+
+ if (curDirection == 0 || curDirection == 7) {
+ curX -= stepX;
+ curY -= stepY;
+ } else if (curDirection == 1 || curDirection == 2) {
+ curX += stepX;
+ curY -= stepY;
+ } else if (curDirection == 3 || curDirection == 4) {
+ curX += stepX;
+ curY += stepY;
+ } else if (curDirection == 5 || curDirection == 6) {
+ curX -= stepX;
+ curY += stepY;
+ }
+ }
+
+ if (currentChapter != 2) {
+ curY += (int)(curHeight - newHeight);
+ curX += (int)(curWidth - newWidth);
+ curHeight = (int)newHeight;
+ curWidth = (int)newWidth;
+ }
+}
+
+void DrasculaEngine::walkDown() {
+ curDirection = 4;
+ trackProtagonist = 3;
+ stepX = 0;
+}
+
+void DrasculaEngine::walkUp() {
+ curDirection = 0;
+ trackProtagonist = 2;
+ stepX = 0;
+}
+
+void DrasculaEngine::moveVonBraun() {
+ int pos_vb[6];
+
+ if (vonBraunHasMoved == 0) {
+ pos_vb[0] = 256;
+ pos_vb[1] = 129;
+ pos_vb[2] = vonBraunX;
+ pos_vb[3] = 66;
+ pos_vb[4] = 33;
+ pos_vb[5] = 69;
+ if (trackVonBraun == 0)
+ pos_vb[0] = 222;
+ else if (trackVonBraun == 1)
+ pos_vb[0] = 188;
+ } else {
+ pos_vb[0] = actorFrames[kFrameVonBraun];
+ pos_vb[1] = (trackVonBraun == 0) ? 62 : 131;
+ pos_vb[2] = vonBraunX;
+ pos_vb[3] = 66;
+ pos_vb[4] = 28;
+ pos_vb[5] = 68;
+
+ actorFrames[kFrameVonBraun] += 29;
+ if (actorFrames[kFrameVonBraun] > 146)
+ actorFrames[kFrameVonBraun] = 1;
+ }
+
+ copyRectClip(pos_vb, frontSurface, screenSurface);
+}
+
+void DrasculaEngine::placeVonBraun(int pointX) {
+ trackVonBraun = (pointX < vonBraunX) ? 0 : 1;
+ vonBraunHasMoved = 1;
+
+ for (;;) {
+ updateRoom();
+ updateScreen();
+ if (trackVonBraun == 0) {
+ vonBraunX = vonBraunX - 5;
+ if (vonBraunX <= pointX)
+ break;
+ } else {
+ vonBraunX = vonBraunX + 5;
+ if (vonBraunX >= pointX)
+ break;
+ }
+ pause(5);
+ }
+
+ vonBraunHasMoved = 0;
+}
+
+
+
+} // End of namespace Drascula
Property changes on: scummvm/branches/gsoc2008-tfmx/engines/drascula/actors.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Rev Author URL Id
Name: svn:eol-style
+ native
Added: scummvm/branches/gsoc2008-tfmx/engines/drascula/converse.cpp
===================================================================
--- scummvm/branches/gsoc2008-tfmx/engines/drascula/converse.cpp (rev 0)
+++ scummvm/branches/gsoc2008-tfmx/engines/drascula/converse.cpp 2008-07-14 18:54:15 UTC (rev 33060)
@@ -0,0 +1,297 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "drascula/drascula.h"
+
+namespace Drascula {
+
+void DrasculaEngine::converse(int index) {
+ char fileName[20];
+ sprintf(fileName, "op_%d.cal", index);
+ uint h;
+ int game1 = 1, game2 = 1, game3 = 1, game4 = 1;
+ char phrase1[78];
+ char phrase2[78];
+ char phrase3[87];
+ char phrase4[78];
+ char sound1[13];
+ char sound2[13];
+ char sound3[13];
+ char sound4[13];
+ int answer1;
+ int answer2;
+ int answer3;
+ int used1 = 0;
+ int used2 = 0;
+ int used3 = 0;
+ char buffer[256];
+ uint len;
+
+ breakOut = 0;
+
+ if (currentChapter == 5)
+ withoutVerb();
+
+ _arj.open(fileName);
+ if (!_arj.isOpen()) {
+ error("missing data file %s", fileName);
+ }
+ int size = _arj.size();
+
+ getStringFromLine(buffer, size, phrase1);
+ getStringFromLine(buffer, size, phrase2);
+ getStringFromLine(buffer, size, phrase3);
+ getStringFromLine(buffer, size, phrase4);
+ getStringFromLine(buffer, size, sound1);
+ getStringFromLine(buffer, size, sound2);
+ getStringFromLine(buffer, size, sound3);
+ getStringFromLine(buffer, size, sound4);
+ getIntFromLine(buffer, size, &answer1);
+ getIntFromLine(buffer, size, &answer2);
+ getIntFromLine(buffer, size, &answer3);
+
+ _arj.close();
+
+ if (currentChapter == 2 && !strcmp(fileName, "op_5.cal") && flags[38] == 1 && flags[33] == 1) {
+ strcpy(phrase3, _text[_lang][405]);
+ strcpy(sound3, "405.als");
+ answer3 = 31;
+ }
+
+ if (currentChapter == 6 && !strcmp(fileName, "op_12.cal") && flags[7] == 1) {
+ strcpy(phrase3, _text[_lang][273]);
+ strcpy(sound3, "273.als");
+ answer3 = 14;
+ }
+
+ if (currentChapter == 6 && !strcmp(fileName, "op_12.cal") && flags[10] == 1) {
+ strcpy(phrase3, _text[_lang][274]);
+ strcpy(sound3, "274.als");
+ answer3 = 15;
+ }
+
+ len = strlen(phrase1);
+ for (h = 0; h < len; h++)
+ if (phrase1[h] == (char)0xa7)
+ phrase1[h] = ' ';
+
+ len = strlen(phrase2);
+ for (h = 0; h < len; h++)
+ if (phrase2[h] == (char)0xa7)
+ phrase2[h] = ' ';
+
+ len = strlen(phrase3);
+ for (h = 0; h < len; h++)
+ if (phrase3[h] == (char)0xa7)
+ phrase3[h] = ' ';
+
+ len = strlen(phrase4);
+ for (h = 0; h < len; h++)
+ if (phrase4[h] == (char)0xa7)
+ phrase4[h] = ' ';
+
+ loadPic("car.alg", backSurface);
+ // TODO code here should limit y position for mouse in dialog menu,
+ // but we can't implement this due lack backend functionality
+ // from 1(top) to 31
+ color_abc(kColorLightGreen);
+
+ while (breakOut == 0) {
+ updateRoom();
+
+ if (currentChapter == 1 || currentChapter == 4 || currentChapter == 6) {
+ if (musicStatus() == 0 && flags[11] == 0)
+ playMusic(roomMusic);
+ } else if (currentChapter == 2) {
+ if (musicStatus() == 0 && flags[11] == 0 && roomMusic != 0)
+ playMusic(roomMusic);
+ } else if (currentChapter == 3 || currentChapter == 5) {
+ if (musicStatus() == 0)
+ playMusic(roomMusic);
+ }
+
+ updateEvents();
+
+ if (mouseY > 0 && mouseY < 9) {
+ if (used1 == 1 && _color != kColorWhite)
+ color_abc(kColorWhite);
+ else if (used1 == 0 && _color != kColorLightGreen)
+ color_abc(kColorLightGreen);
+ } else if (mouseY > 8 && mouseY < 17) {
+ if (used2 == 1 && _color != kColorWhite)
+ color_abc(kColorWhite);
+ else if (used2 == 0 && _color != kColorLightGreen)
+ color_abc(kColorLightGreen);
+ } else if (mouseY > 16 && mouseY < 25) {
+ if (used3 == 1 && _color != kColorWhite)
+ color_abc(kColorWhite);
+ else if (used3 == 0 && _color != kColorLightGreen)
+ color_abc(kColorLightGreen);
+ } else if (_color != kColorLightGreen)
+ color_abc(kColorLightGreen);
+
+ if (mouseY > 0 && mouseY < 9)
+ game1 = 2;
+ else if (mouseY > 8 && mouseY < 17)
+ game2 = 2;
+ else if (mouseY > 16 && mouseY < 25)
+ game3 = 2;
+ else if (mouseY > 24 && mouseY < 33)
+ game4 = 2;
+
+ print_abc_opc(phrase1, 1, 2, game1);
+ print_abc_opc(phrase2, 1, 10, game2);
+ print_abc_opc(phrase3, 1, 18, game3);
+ print_abc_opc(phrase4, 1, 26, game4);
+
+ updateScreen();
+
+ if ((leftMouseButton == 1) && (game1 == 2)) {
+ delay(100);
+ used1 = 1;
+ talk(phrase1, sound1);
+ if (currentChapter == 3)
+ grr();
+ else
+ response(answer1);
+ } else if ((leftMouseButton == 1) && (game2 == 2)) {
+ delay(100);
+ used2 = 1;
+ talk(phrase2, sound2);
+ if (currentChapter == 3)
+ grr();
+ else
+ response(answer2);
+ } else if ((leftMouseButton == 1) && (game3 == 2)) {
+ delay(100);
+ used3 = 1;
+ talk(phrase3, sound3);
+ if (currentChapter == 3)
+ grr();
+ else
+ response(answer3);
+ } else if ((leftMouseButton == 1) && (game4 == 2)) {
+ delay(100);
+ talk(phrase4, sound4);
+ breakOut = 1;
+ }
+
+ if (leftMouseButton == 1) {
+ delay(100);
+ color_abc(kColorLightGreen);
+ }
+
+ game1 = (used1 == 0) ? 1 : 3;
+ game2 = (used2 == 0) ? 1 : 3;
+ game3 = (used3 == 0) ? 1 : 3;
+ game4 = 1;
+ } // while (breakOut == 0)
+
+ if (currentChapter == 2)
+ loadPic(menuBackground, backSurface);
+ else
+ loadPic(99, backSurface);
+ if (currentChapter != 5)
+ withoutVerb();
+}
+
+void DrasculaEngine::response(int function) {
+ if (currentChapter == 1) {
+ if (function >= 10 && function <= 12)
+ talk_drunk(function - 9);
+ } else if (currentChapter == 2) {
+ if (function == 8)
+ animation_8_2();
+ else if (function == 9)
+ animation_9_2();
+ else if (function == 10)
+ animation_10_2();
+ else if (function == 15)
+ animation_15_2();
+ else if (function == 16)
+ animation_16_2();
+ else if (function == 17)
+ animation_17_2();
+ else if (function == 19)
+ animation_19_2();
+ else if (function == 20)
+ animation_20_2();
+ else if (function == 21)
+ animation_21_2();
+ else if (function == 23)
+ animation_23_2();
+ else if (function == 28)
+ animation_28_2();
+ else if (function == 29)
+ animation_29_2();
+ else if (function == 30)
+ animation_30_2();
+ else if (function == 31)
+ animation_31_2();
+ } else if (currentChapter == 4) {
+ if (function == 2)
+ animation_2_4();
+ else if (function == 3)
+ animation_3_4();
+ else if (function == 4)
+ animation_4_4();
+ } else if (currentChapter == 5) {
+ if (function == 2)
+ animation_2_5();
+ else if (function == 3)
+ animation_3_5();
+ else if (function == 6)
+ animation_6_5();
+ else if (function == 7)
+ animation_7_5();
+ else if (function == 8)
+ animation_8_5();
+ else if (function == 15)
+ animation_15_5();
+ else if (function == 16)
+ animation_16_5();
+ else if (function == 17)
+ animation_17_5();
+ } else if (currentChapter == 6) {
+ if (function == 2)
+ animation_2_6();
+ else if (function == 3)
+ animation_3_6();
+ else if (function == 4)
+ animation_4_6();
+ else if (function == 11)
+ animation_11_6();
+ else if (function == 12)
+ animation_12_6();
+ else if (function == 13)
+ animation_13_6();
+ else if (function == 14)
+ animation_14_6();
+ else if (function == 15)
+ animation_15_6();
+ }
+}
+
+} // End of namespace Drascula
Property changes on: scummvm/branches/gsoc2008-tfmx/engines/drascula/converse.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Rev Author URL Id
Name: svn:eol-style
+ native
Added: scummvm/branches/gsoc2008-tfmx/engines/drascula/graphics.cpp
===================================================================
--- scummvm/branches/gsoc2008-tfmx/engines/drascula/graphics.cpp (rev 0)
+++ scummvm/branches/gsoc2008-tfmx/engines/drascula/graphics.cpp 2008-07-14 18:54:15 UTC (rev 33060)
@@ -0,0 +1,676 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "drascula/drascula.h"
+
+namespace Drascula {
+
+void DrasculaEngine::allocMemory() {
+ // FIXME: decodeOffset writes beyond 64000, so this
+ // buffer has been initialized to 64256 bytes (like
+ // the original did with the MiVideoSSN buffer)
+ screenSurface = (byte *)malloc(64256);
+ assert(screenSurface);
+ frontSurface = (byte *)malloc(64000);
+ assert(frontSurface);
+ backSurface = (byte *)malloc(64000);
+ assert(backSurface);
+ bgSurface = (byte *)malloc(64000);
+ assert(bgSurface);
+ drawSurface2 = (byte *)malloc(64000);
+ assert(drawSurface2);
+ drawSurface3 = (byte *)malloc(64000);
+ assert(drawSurface3);
+ tableSurface = (byte *)malloc(64000);
+ assert(tableSurface);
+ extraSurface = (byte *)malloc(64000);
+ assert(extraSurface);
+}
+
+void DrasculaEngine::freeMemory() {
+ free(screenSurface);
+ free(bgSurface);
+ free(backSurface);
+ free(drawSurface2);
+ free(tableSurface);
+ free(drawSurface3);
+ free(extraSurface);
+ free(frontSurface);
+}
+
+void DrasculaEngine::moveCursor() {
+ copyBackground(0, 0, 0, 0, 320, 200, bgSurface, screenSurface);
+
+ updateRefresh_pre();
+ moveCharacters();
+ updateRefresh();
+
+ if (!strcmp(textName, "hacker") && hasName == 1) {
+ if (_color != kColorRed && menuScreen == 0)
+ color_abc(kColorRed);
+ } else if (menuScreen == 0 && _color != kColorLightGreen)
+ color_abc(kColorLightGreen);
+ if (hasName == 1 && menuScreen == 0)
+ centerText(textName, mouseX, mouseY);
+ if (menuScreen == 1)
+ showMenu();
+ else if (menuBar == 1)
+ clearMenu();
+
+ int cursorPos[6] = { 0, 0, mouseX - 20, mouseY - 17, OBJWIDTH, OBJHEIGHT };
+ copyRectClip(cursorPos, drawSurface3, screenSurface);
+}
+
+void DrasculaEngine::setCursorTable() {
+ int cursorPos[6] = { 225, 56, mouseX - 20, mouseY - 12, 40, 25 };
+ copyRectClip(cursorPos, tableSurface, screenSurface);
+}
+
+void DrasculaEngine::loadPic(const char *NamePcc, byte *targetSurface, int colorCount) {
+ uint dataSize = 0;
+ byte *pcxData;
+
+ _arj.open(NamePcc);
+ if (!_arj.isOpen())
+ error("missing game data %s %c", NamePcc, 7);
+
+ dataSize = _arj.size() - 128 - (256 * 3);
+ pcxData = (byte *)malloc(dataSize);
+
+ _arj.seek(128, SEEK_SET);
+ _arj.read(pcxData, dataSize);
+
+ decodeRLE(pcxData, targetSurface);
+ free(pcxData);
+
+ for (int i = 0; i < 256; i++) {
+ cPal[i * 3 + 0] = _arj.readByte();
+ cPal[i * 3 + 1] = _arj.readByte();
+ cPal[i * 3 + 2] = _arj.readByte();
+ }
+
+ _arj.close();
+
+ setRGB((byte *)cPal, colorCount);
+}
+
+void DrasculaEngine::showFrame(bool firstFrame) {
+ int dataSize = _arj.readSint32LE();
+ byte *pcxData = (byte *)malloc(dataSize);
+ _arj.read(pcxData, dataSize);
+
+ for (int i = 0; i < 256; i++) {
+ cPal[i * 3 + 0] = _arj.readByte();
+ cPal[i * 3 + 1] = _arj.readByte();
+ cPal[i * 3 + 2] = _arj.readByte();
+ }
+
+ byte *prevFrame = (byte *)malloc(64000);
+ memcpy(prevFrame, VGA, 64000);
+
+ decodeRLE(pcxData, VGA);
+ free(pcxData);
+
+ if (!firstFrame)
+ mixVideo(VGA, prevFrame);
+
+ _system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200);
+ _system->updateScreen();
+ if (firstFrame)
+ setPalette(cPal);
+
+ free(prevFrame);
+}
+
+void DrasculaEngine::copyBackground(int xorg, int yorg, int xdes, int ydes, int width,
+ int height, byte *src, byte *dest) {
+ dest += xdes + ydes * 320;
+ src += xorg + yorg * 320;
+ for (int x = 0; x < height; x++) {
+ memcpy(dest, src, width);
+ dest += 320;
+ src += 320;
+ }
+}
+
+void DrasculaEngine::copyRect(int xorg, int yorg, int xdes, int ydes, int width,
+ int height, byte *src, byte *dest) {
+ int y, x;
+
+ dest += xdes + ydes * 320;
+ src += xorg + yorg * 320;
+
+ for (y = 0; y < height; y++)
+ for (x = 0; x < width; x++)
+ if (src[x + y * 320] != 255)
+ dest[x + y * 320] = src[x + y * 320];
+}
+
+void DrasculaEngine::copyRectClip(int *Array, byte *src, byte *dest) {
+ int y, x;
+ int xorg = Array[0];
+ int yorg = Array[1];
+ int xdes = Array[2];
+ int ydes = Array[3];
+ int width = Array[4];
+ int height = Array[5];
+
+ if (ydes < 0) {
+ yorg += -ydes;
+ height += ydes;
+ ydes = 0;
+ }
+ if (xdes < 0) {
+ xorg += -xdes;
+ width += xdes;
+ xdes = 0;
+ }
+ if ((xdes + width) > 319)
+ width -= (xdes + width) - 320;
+ if ((ydes + height) > 199)
+ height -= (ydes + height) - 200;
+
+ dest += xdes + ydes * 320;
+ src += xorg + yorg * 320;
+
+ for (y = 0; y < height; y++)
+ for (x = 0; x < width; x++)
+ if (src[x + y * 320] != 255)
+ dest[x + y * 320] = src[x + y * 320];
+}
+
+void DrasculaEngine::updateScreen(int xorg, int yorg, int xdes, int ydes, int width, int height, byte *buffer) {
+ byte *ptr = VGA;
+
+ ptr += xdes + ydes * 320;
+ buffer += xorg + yorg * 320;
+ for (int x = 0; x < height; x++) {
+ memcpy(ptr, buffer, width);
+ ptr += 320;
+ buffer += 320;
+ }
+
+ _system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200);
+ _system->updateScreen();
+}
+
+void DrasculaEngine::print_abc(const char *said, int screenX, int screenY) {
+ int letterY = 0, letterX = 0, i;
+ uint len = strlen(said);
+ byte c;
+
+ for (uint h = 0; h < len; h++) {
+ c = toupper(said[h]);
+
+ for (i = 0; i < _charMapSize; i++) {
+ if (c == _charMap[i].inChar) {
+ letterX = _charMap[i].mappedChar;
+
+ switch (_charMap[i].charType) {
+ case 0: // letters
+ letterY = (_lang == kSpanish) ? 149 : 158;
+ break;
+ case 1: // signs
+ letterY = (_lang == kSpanish) ? 160 : 169;
+ break;
+ case 2: // accented
+ letterY = 180;
+ break;
+ } // switch
+ break;
+ } // if
+ } // for
+
+ int textPos[6] = { letterX, letterY, screenX, screenY, CHAR_WIDTH, CHAR_HEIGHT };
+ copyRectClip(textPos, textSurface, screenSurface);
+
+ screenX = screenX + CHAR_WIDTH;
+ if (screenX > 317) {
+ screenX = 0;
+ screenY = screenY + CHAR_HEIGHT + 2;
+ }
+ } // for
+}
+
+void DrasculaEngine::print_abc_opc(const char *said, int screenX, int screenY, int game) {
+ int signY, letterY, letterX = 0;
+ uint len = strlen(said);
+
+ for (uint h = 0; h < len; h++) {
+ if (game == 1) {
+ letterY = 6;
+ signY = 15;
+ } else if (game == 3) {
+ letterY = 56;
+ signY = 65;
+ } else {
+ letterY = 31;
+ signY = 40;
+ }
+
+ byte c = toupper(said[h]);
+
+ // WORKAROUND: Even original did not process it correctly
+ // Fixes apostrophe rendering
+ if (_lang != kSpanish)
+ if (c == '\'')
+ c = (byte)'\244';
+
+ for (int i = 0; i < _charMapSize; i++) {
+ if (c == _charMap[i].inChar) {
+ // Convert the mapped char of the normal font to the
+ // mapped char of the dialogue font
+
+ int multiplier = (_charMap[i].mappedChar - 6) / 9;
+
+ letterX = multiplier * 7 + 10;
+
+ if (_charMap[i].charType > 0)
+ letterY = signY;
+ break;
+ } // if
+ } // for
+
+ int textPos[6] = { letterX, letterY, screenX, screenY, CHAR_WIDTH_OPC, CHAR_HEIGHT_OPC };
+ copyRectClip(textPos, backSurface, screenSurface);
+
+ screenX = screenX + CHAR_WIDTH_OPC;
+ }
+}
+
+void DrasculaEngine::centerText(const char *message, int textX, int textY) {
+ char bb[200], m2[200], m1[200], mb[10][50];
+ char m3[200];
+ int h, fil, textX3, textX2, textX1, conta_f = 0, ya = 0;
+
+ strcpy(m1, " ");
+ strcpy(m2, " ");
+ strcpy(m3, " ");
+ strcpy(bb, " ");
+
+ for (h = 0; h < 10; h++)
+ strcpy(mb[h], " ");
+
+ if (textX > 160)
+ ya = 1;
+
+ strcpy(m1, message);
+ textX = CLIP<int>(textX, 60, 255);
+
+ textX1 = textX;
+
+ if (ya == 1)
+ textX1 = 315 - textX;
+
+ textX2 = (strlen(m1) / 2) * CHAR_WIDTH;
+
+ while (true) {
+ strcpy(bb, m1);
+ scumm_strrev(bb);
+
+ if (textX1 < textX2) {
+ strcpy(m3, strrchr(m1, ' '));
+ strcpy(m1, strstr(bb, " "));
+ scumm_strrev(m1);
+ m1[strlen(m1) - 1] = '\0';
+ strcat(m3, m2);
+ strcpy(m2, m3);
+ };
+
+ textX2 = (strlen(m1) / 2) * CHAR_WIDTH;
+
+ if (textX1 < textX2)
+ continue;
+
+ strcpy(mb[conta_f], m1);
+
+ if (!strcmp(m2, ""))
+ break;
+
+ scumm_strrev(m2);
+ m2[strlen(m2) - 1] = '\0';
+ scumm_strrev(m2);
+ strcpy(m1, m2);
+ strcpy(m2, "");
+ conta_f++;
+ }
+
+ fil = textY - (((conta_f + 3) * CHAR_HEIGHT));
+
+ for (h = 0; h < conta_f + 1; h++) {
+ textX3 = strlen(mb[h]) / 2;
+ print_abc(mb[h], ((textX) - textX3 * CHAR_WIDTH) - 1, fil);
+ fil = fil + CHAR_HEIGHT + 2;
+ }
+}
+
+void DrasculaEngine::screenSaver() {
+ int xr, yr;
+ byte *copia, *ghost;
+ float coeff = 0, coeff2 = 0;
+ int count = 0;
+ int count2 = 0;
+ int tempLine[320];
+ int tempRow[200];
+
+ clearRoom();
+
+ loadPic("sv.alg", bgSurface, HALF_PAL);
+
+ // inicio_ghost();
+ copia = (byte *)malloc(64000);
+ ghost = (byte *)malloc(65536);
+
+ // carga_ghost();
+ _arj.open("ghost.drv");
+ if (!_arj.isOpen())
+ error("Cannot open file ghost.drv");
+
+ _arj.read(ghost, 65536);
+ _arj.close();
+
+ updateEvents();
+ xr = mouseX;
+ yr = mouseY;
+
+ for (;;) {
+ // efecto(bgSurface);
+
+ memcpy(copia, bgSurface, 64000);
+ coeff += 0.1f;
+ coeff2 = coeff;
+
+ if (++count > 319)
+ count = 0;
+
+ for (int i = 0; i < 320; i++) {
+ tempLine[i] = (int)(sin(coeff2) * 16);
+ coeff2 += 0.02f;
+ tempLine[i] = checkWrapY(tempLine[i]);
+ }
+
+ coeff2 = coeff;
+ for (int i = 0; i < 200; i++) {
+ tempRow[i] = (int)(sin(coeff2) * 16);
+ coeff2 += 0.02f;
+ tempRow[i] = checkWrapX(tempRow[i]);
+ }
+
+ if (++count2 > 199)
+ count2 = 0;
+
+ int x1_, y1_, off1, off2;
+
+ for (int i = 0; i < 200; i++) {
+ for (int j = 0; j < 320; j++) {
+ x1_ = j + tempRow[i];
+ x1_ = checkWrapX(x1_);
+
+ y1_ = i + count2;
+ y1_ = checkWrapY(y1_);
+
+ off1 = 320 * y1_ + x1_;
+
+ x1_ = j + count;
+ x1_ = checkWrapX(x1_);
+
+ y1_ = i + tempLine[j];
+ y1_ = checkWrapY(y1_);
+ off2 = 320 * y1_ + x1_;
+
+ VGA[320 * i + j] = ghost[bgSurface[off2] + (copia[off1] << 8)];
+ }
+ }
+ _system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200);
+ _system->updateScreen();
+
+ _system->delayMillis(20);
+
+ // end of efecto()
+
+ updateEvents();
+ if (rightMouseButton == 1 || leftMouseButton == 1)
+ break;
+ if (mouseX != xr)
+ break;
+ if (mouseY != yr)
+ break;
+ }
+ // fin_ghost();
+ free(copia);
+ free(ghost);
+
+ loadPic(roomNumber, bgSurface, HALF_PAL);
+}
+
+void DrasculaEngine::playFLI(const char *filefli, int vel) {
+ // Open file
+ globalSpeed = 1000 / vel;
+ FrameSSN = 0;
+ UsingMem = 0;
+ _arj.open(filefli);
+ mSession = TryInMem();
+ LastFrame = _system->getMillis();
+
+ while (playFrameSSN() && (!term_int)) {
+ if (getScan() == Common::KEYCODE_ESCAPE)
+ term_int = 1;
+ }
+
+ if (UsingMem)
+ free(memPtr);
+ else
+ _arj.close();
+}
+
+int DrasculaEngine::playFrameSSN() {
+ int Exit = 0;
+ uint32 length;
+ byte *BufferSSN;
+
+ if (!UsingMem)
+ CHUNK = _arj.readByte();
+ else {
+ memcpy(&CHUNK, mSession, 1);
+ mSession += 1;
+ }
+
+ switch (CHUNK) {
+ case kFrameSetPal:
+ if (!UsingMem) {
+ for (int i = 0; i < 256; i++) {
+ dacSSN[i * 3 + 0] = _arj.readByte();
+ dacSSN[i * 3 + 1] = _arj.readByte();
+ dacSSN[i * 3 + 2] = _arj.readByte();
+ }
+ } else {
+ memcpy(dacSSN, mSession, 768);
+ mSession += 768;
+ }
+ setPalette(dacSSN);
+ break;
+ case kFrameEmptyFrame:
+ waitFrameSSN();
+ break;
+ case kFrameInit:
+ if (!UsingMem) {
+ CMP = _arj.readByte();
+ length = _arj.readUint32LE();
+ } else {
+ memcpy(&CMP, mSession, 1);
+ mSession += 1;
+ length = READ_LE_UINT32(mSession);
+ mSession += 4;
+ }
+ if (CMP == kFrameCmpRle) {
+ BufferSSN = (byte *)malloc(length);
+ if (!UsingMem) {
+ _arj.read(BufferSSN, length);
+ } else {
+ memcpy(BufferSSN, mSession, length);
+ mSession += length;
+ }
+ decodeRLE(BufferSSN, screenSurface);
+ free(BufferSSN);
+ waitFrameSSN();
+ if (FrameSSN)
+ mixVideo(VGA, screenSurface);
+ else
+ memcpy(VGA, screenSurface, 64000);
+ _system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200);
+ _system->updateScreen();
+ FrameSSN++;
+ } else {
+ if (CMP == kFrameCmpOff) {
+ BufferSSN = (byte *)malloc(length);
+ if (!UsingMem) {
+ _arj.read(BufferSSN, length);
+ } else {
+ memcpy(BufferSSN, mSession, length);
+ mSession += length;
+ }
+ decodeOffset(BufferSSN, screenSurface, length);
+ free(BufferSSN);
+ waitFrameSSN();
+ if (FrameSSN)
+ mixVideo(VGA, screenSurface);
+ else
+ memcpy(VGA, screenSurface, 64000);
+ _system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200);
+ _system->updateScreen();
+ FrameSSN++;
+ }
+ }
+ break;
+ case kFrameEndAnim:
+ Exit = 1;
+ break;
+ default:
+ Exit = 1;
+ break;
+ }
+
+ return (!Exit);
+}
+
+byte *DrasculaEngine::TryInMem() {
+ int length;
+
+ _arj.seek(0, SEEK_END);
+ length = _arj.pos();
+ _arj.seek(0, SEEK_SET);
+ memPtr = (byte *)malloc(length);
+ if (memPtr == NULL)
+ return NULL;
+ _arj.read(memPtr, length);
+ UsingMem = 1;
+ _arj.close();
+
+ return memPtr;
+}
+
+void DrasculaEngine::decodeOffset(byte *BufferOFF, byte *MiVideoOFF, int length) {
+ int x = 0;
+ int size;
+ int offset;
+
+ memset(screenSurface, 0, 64000);
+ while (x < length) {
+ offset = BufferOFF[x] + BufferOFF[x + 1] * 256;
+ // FIXME: this writes beyond 64000, so the buffer has been initialized
+ // to 64256 bytes (like the original did)
+ size = BufferOFF[x + 2];
+ memcpy(MiVideoOFF + offset, &BufferOFF[x + 3], size);
+ x += 3 + size;
+ }
+}
+
+void DrasculaEngine::decodeRLE(byte* srcPtr, byte* dstPtr) {
+ bool stopProcessing = false;
+ byte pixel;
+ uint repeat;
+ int curByte = 0;
+
+ while (!stopProcessing) {
+ pixel = *srcPtr++;
+ repeat = 1;
+ if ((pixel & 192) == 192) {
+ repeat = (pixel & 63);
+ pixel = *srcPtr++;
+ }
+ for (uint j = 0; j < repeat; j++) {
+ curByte++;
+ if (curByte > 64000) {
+ stopProcessing = true;
+ break;
+ }
+ *dstPtr++ = pixel;
+ }
+ }
+}
+
+void DrasculaEngine::mixVideo(byte *OldScreen, byte *NewScreen) {
+ for (int x = 0; x < 64000; x++)
+ OldScreen[x] ^= NewScreen[x];
+}
+
+void DrasculaEngine::waitFrameSSN() {
+ uint32 now;
+ while ((now = _system->getMillis()) - LastFrame < ((uint32) globalSpeed))
+ _system->delayMillis(globalSpeed - (now - LastFrame));
+ LastFrame = LastFrame + globalSpeed;
+}
+
+bool DrasculaEngine::animate(const char *animationFile, int FPS) {
+ int NFrames = 1;
+ int cnt = 2;
+
+ _arj.open(animationFile);
+
+ if (!_arj.isOpen()) {
+ error("Animation file %s not found", animationFile);
+ }
+
+ NFrames = _arj.readSint32LE();
+ showFrame(true);
+ _system->delayMillis(1000 / FPS);
+ while (cnt < NFrames) {
+ showFrame();
+ _system->delayMillis(1000 / FPS);
+ cnt++;
+ byte key = getScan();
+ if (key == Common::KEYCODE_ESCAPE)
+ term_int = 1;
+ if (key != 0)
+ break;
+ }
+ _arj.close();
+
+ return ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE));
+}
+
+
+
+} // End of namespace Drascula
Property changes on: scummvm/branches/gsoc2008-tfmx/engines/drascula/graphics.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Rev Author URL Id
Name: svn:eol-style
+ native
Added: scummvm/branches/gsoc2008-tfmx/engines/drascula/interface.cpp
===================================================================
--- scummvm/branches/gsoc2008-tfmx/engines/drascula/interface.cpp (rev 0)
+++ scummvm/branches/gsoc2008-tfmx/engines/drascula/interface.cpp 2008-07-14 18:54:15 UTC (rev 33060)
@@ -0,0 +1,209 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "drascula/drascula.h"
+
+namespace Drascula {
+
+void DrasculaEngine::selectVerbFromBar() {
+ for (int n = 0; n < 7; n++) {
+ if (mouseX > _verbBarX[n] && mouseX < _verbBarX[n + 1] && n > 0) {
+ selectVerb(n);
+ return;
+ }
+ }
+
+ // no verb selected
+ withoutVerb();
+}
+
+void DrasculaEngine::selectVerb(int verb) {
+ int c = (menuScreen == 1) ? 0 : 171;
+
+ if (currentChapter == 5) {
+ if (takeObject == 1 && pickedObject != 16)
+ addObject(pickedObject);
+ } else {
+ if (takeObject == 1)
+ addObject(pickedObject);
+ }
+
+ copyBackground(OBJWIDTH * verb, c, 0, 0, OBJWIDTH, OBJHEIGHT, backSurface, drawSurface3);
+
+ takeObject = 1;
+ pickedObject = verb;
+}
+
+bool DrasculaEngine::confirmExit() {
+ byte key;
+
+ color_abc(kColorRed);
+ updateRoom();
+ centerText(_textsys[_lang][1], 160, 87);
+ updateScreen();
+
+ delay(100);
+ for (;;) {
+ key = getScan();
+ if (key != 0)
+ break;
+ }
+
+ if (key == Common::KEYCODE_ESCAPE) {
+ stopMusic();
+ return false;
+ }
+
+ return true;
+}
+
+void DrasculaEngine::showMenu() {
+ int h, n, x;
+ char textIcon[13];
+ byte *srcSurface = (currentChapter == 6) ? tableSurface : frontSurface;
+ x = whichObject();
+ strcpy(textIcon, iconName[x]);
+
+ for (n = 1; n < 43; n++) {
+ h = inventoryObjects[n];
+
+ if (h != 0) {
+ copyBackground(_polX[n], _polY[n], _itemLocations[n].x, _itemLocations[n].y,
+ OBJWIDTH, OBJHEIGHT, srcSurface, screenSurface);
+ }
+ copyRect(_x1d_menu[h], _y1d_menu[h], _itemLocations[n].x, _itemLocations[n].y,
+ OBJWIDTH, OBJHEIGHT, backSurface, screenSurface);
+ }
+
+ if (x < 7)
+ print_abc(textIcon, _itemLocations[x].x - 2, _itemLocations[x].y - 7);
+}
+
+void DrasculaEngine::clearMenu() {
+ int n, verbActivated = 1;
+
+ for (n = 0; n < 7; n++) {
+ if (mouseX > _verbBarX[n] && mouseX < _verbBarX[n + 1])
+ verbActivated = 0;
+ copyRect(OBJWIDTH * n, OBJHEIGHT * verbActivated, _verbBarX[n], 2,
+ OBJWIDTH, OBJHEIGHT, backSurface, screenSurface);
+ verbActivated = 1;
+ }
+}
+
+void DrasculaEngine::enterName() {
+ Common::KeyCode key;
+ int v = 0, h = 0;
+ char select2[23];
+ strcpy(select2, " ");
+ for (;;) {
+ select2[v] = '-';
+ copyBackground(115, 14, 115, 14, 176, 9, bgSurface, screenSurface);
+ print_abc(select2, 117, 15);
+ updateScreen();
+ key = getScan();
+ delay(70);
+ if (key != 0) {
+ if (key >= 0 && key <= 0xFF && isalpha(key))
+ select2[v] = tolower(key);
+ else if ((key == Common::KEYCODE_LCTRL) || (key == Common::KEYCODE_RCTRL))
+ select2[v] = '\164';
+ else if (key >= Common::KEYCODE_0 && key <= Common::KEYCODE_9)
+ select2[v] = key;
+ else if (key == Common::KEYCODE_SPACE)
+ select2[v] = '\167';
+ else if (key == Common::KEYCODE_ESCAPE)
+ break;
+ else if (key == Common::KEYCODE_RETURN) {
+ select2[v] = '\0';
+ h = 1;
+ break;
+ } else if (key == Common::KEYCODE_BACKSPACE)
+ select2[v] = '\0';
+ else
+ v--;
+
+ if (key == Common::KEYCODE_BACKSPACE)
+ v--;
+ else
+ v++;
+ }
+ if (v == 22)
+ v = 21;
+ else if (v == -1)
+ v = 0;
+ }
+ if (h == 1) {
+ strcpy(select, select2);
+ selectionMade = 1;
+ }
+}
+
+bool DrasculaEngine::checkMenuFlags() {
+ for (int n = 0; n < 43; n++) {
+ if (whichObject() == n) {
+ if (inventoryObjects[n] != 0 && checkAction(inventoryObjects[n]))
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void DrasculaEngine::showMap() {
+ hasName = 0;
+
+ for (int l = 0; l < numRoomObjs; l++) {
+ if (mouseX > x1[l] && mouseY > y1[l]
+ && mouseX < x2[l] && mouseY < y2[l]
+ && visible[l] == 1) {
+ strcpy(textName, objName[l]);
+ hasName = 1;
+ }
+ }
+}
+
+void DrasculaEngine::grr() {
+ int length = 30;
+
+ color_abc(kColorDarkGreen);
+
+ playFile("s10.als");
+
+ updateRoom();
+ copyBackground(253, 110, 150, 65, 20, 30, drawSurface3, screenSurface);
+
+ if (withVoices == 0)
+ centerText("groaaarrrrgghhhh!", 153, 65);
+
+ updateScreen();
+
+ while (!isTalkFinished(&length));
+
+ updateRoom();
+ updateScreen();
+}
+
+} // End of namespace Drascula
Property changes on: scummvm/branches/gsoc2008-tfmx/engines/drascula/interface.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Rev Author URL Id
Name: svn:eol-style
+ native
Added: scummvm/branches/gsoc2008-tfmx/engines/drascula/objects.cpp
===================================================================
--- scummvm/branches/gsoc2008-tfmx/engines/drascula/objects.cpp (rev 0)
+++ scummvm/branches/gsoc2008-tfmx/engines/drascula/objects.cpp 2008-07-14 18:54:15 UTC (rev 33060)
@@ -0,0 +1,300 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "drascula/drascula.h"
+
+namespace Drascula {
+
+void DrasculaEngine::pickObject(int object) {
+ if (currentChapter == 6)
+ loadPic("iconsp.alg", backSurface);
+ else if (currentChapter == 4)
+ loadPic("icons2.alg", backSurface);
+ else if (currentChapter == 5)
+ loadPic("icons3.alg", backSurface);
+ else
+ loadPic("icons.alg", backSurface);
+ chooseObject(object);
+ if (currentChapter == 2)
+ loadPic(menuBackground, backSurface);
+ else
+ loadPic(99, backSurface);
+}
+
+void DrasculaEngine::chooseObject(int object) {
+ if (currentChapter == 5) {
+ if (takeObject == 1 && menuScreen == 0 && pickedObject != 16)
+ addObject(pickedObject);
+ } else {
+ if (takeObject == 1 && menuScreen == 0)
+ addObject(pickedObject);
+ }
+ copyBackground(_x1d_menu[object], _y1d_menu[object], 0, 0, OBJWIDTH,OBJHEIGHT, backSurface, drawSurface3);
+ takeObject = 1;
+ pickedObject = object;
+}
+
+int DrasculaEngine::removeObject(int obj) {
+ int result = 1;
+
+ for (int h = 1; h < 43; h++) {
+ if (inventoryObjects[h] == obj) {
+ inventoryObjects[h] = 0;
+ result = 0;
+ break;
+ }
+ }
+
+ return result;
+}
+
+void DrasculaEngine::withoutVerb() {
+ int c = (menuScreen == 1) ? 0 : 171;
+
+ if (currentChapter == 5) {
+ if (takeObject == 1 && pickedObject != 16)
+ addObject(pickedObject);
+ } else {
+ if (takeObject == 1)
+ addObject(pickedObject);
+ }
+ copyBackground(0, c, 0, 0, OBJWIDTH,OBJHEIGHT, backSurface, drawSurface3);
+
+ takeObject = 0;
+ hasName = 0;
+}
+
+void DrasculaEngine::gotoObject(int pointX, int pointY) {
+ if (currentChapter == 5 || currentChapter == 6) {
+ if (hare_se_ve == 0) {
+ curX = roomX;
+ curY = roomY;
+ updateRoom();
+ updateScreen();
+ return;
+ }
+ }
+ roomX = pointX;
+ roomY = pointY;
+ startWalking();
+
+ for (;;) {
+ updateRoom();
+ updateScreen();
+ if (characterMoved == 0)
+ break;
+ }
+
+ if (walkToObject == 1) {
+ walkToObject = 0;
+ trackProtagonist = trackFinal;
+ }
+ updateRoom();
+ updateScreen();
+}
+
+void DrasculaEngine::checkObjects() {
+ int l, veo = 0;
+
+ for (l = 0; l < numRoomObjs; l++) {
+ if (mouseX > x1[l] && mouseY > y1[l]
+ && mouseX < x2[l] && mouseY < y2[l]
+ && visible[l] == 1 && isDoor[l] == 0) {
+ strcpy(textName, objName[l]);
+ hasName = 1;
+ veo = 1;
+ }
+ }
+
+ if (mouseX > curX + 2 && mouseY > curY + 2
+ && mouseX < curX + curWidth - 2 && mouseY < curY + curHeight - 2) {
+ if (currentChapter == 2 || veo == 0) {
+ strcpy(textName, "hacker");
+ hasName = 1;
+ veo = 1;
+ }
+ }
+
+ if (veo == 0)
+ hasName = 0;
+}
+
+void DrasculaEngine::removeObject() {
+ int h = 0, n;
+
+ updateRoom();
+
+ for (n = 1; n < 43; n++){
+ if (whichObject() == n) {
+ h = inventoryObjects[n];
+ inventoryObjects[n] = 0;
+ if (h != 0)
+ takeObject = 1;
+ }
+ }
+
+ updateEvents();
+
+ if (takeObject == 1)
+ chooseObject(h);
+}
+
+bool DrasculaEngine::pickupObject() {
+ int h = pickedObject;
+ checkFlags = 1;
+
+ updateRoom();
+ showMenu();
+ updateScreen();
+
+ // Objects with an ID smaller than 7 are the inventory verbs
+ if (pickedObject >= 7) {
+ for (int n = 1; n < 43; n++) {
+ if (whichObject() == n && inventoryObjects[n] == 0) {
+ inventoryObjects[n] = h;
+ takeObject = 0;
+ checkFlags = 0;
+ }
+ }
+ }
+
+ if (checkFlags == 1) {
+ if (checkMenuFlags())
+ return true;
+ }
+ updateEvents();
+ if (takeObject == 0)
+ withoutVerb();
+
+ return false;
+}
+
+void DrasculaEngine::addObject(int obj) {
+ int h, position = 0;
+
+ for (h = 1; h < 43; h++) {
+ if (inventoryObjects[h] == obj)
+ position = 1;
+ }
+
+ if (position == 0) {
+ for (h = 1; h < 43; h++) {
+ if (inventoryObjects[h] == 0) {
+ inventoryObjects[h] = obj;
+ position = 1;
+ break;
+ }
+ }
+ }
+}
+
+int DrasculaEngine::whichObject() {
+ int n = 0;
+
+ for (n = 1; n < 43; n++) {
+ if (mouseX > _itemLocations[n].x && mouseY > _itemLocations[n].y &&
+ mouseX < _itemLocations[n].x + OBJWIDTH &&
+ mouseY < _itemLocations[n].y + OBJHEIGHT)
+ break;
+ }
+
+ return n;
+}
+
+void DrasculaEngine::updateVisible() {
+ if (currentChapter == 1) {
+ // nothing
+ } else if (currentChapter == 2) {
+ if (roomNumber == 2 && flags[40] == 0)
+ visible[3] = 0;
+ else if (roomNumber == 3 && flags[3] == 1)
+ visible[8] = 0;
+ else if (roomNumber == 6 && flags[1] == 1 && flags[10] == 0) {
+ visible[2] = 0;
+ visible[4] = 1;
+ } else if (roomNumber == 7 && flags[35] == 1)
+ visible[3] = 0;
+ else if (roomNumber == 14 && flags[5] == 1)
+ visible[4] = 0;
+ else if (roomNumber == 18 && flags[28] == 1)
+ visible[2] = 0;
+ } else if (currentChapter == 3) {
+ // nothing
+ } else if (currentChapter == 4) {
+ if (roomNumber == 23 && flags[0] == 0 && flags[11] == 0)
+ visible[2] = 1;
+ if (roomNumber == 23 && flags[0] == 1 && flags[11] == 0)
+ visible[2] = 0;
+ if (roomNumber == 21 && flags[10] == 1)
+ visible[2] = 0;
+ if (roomNumber == 22 && flags[26] == 1) {
+ visible[2] = 0;
+ visible[1] = 1;
+ }
+ if (roomNumber == 22 && flags[27] == 1)
+ visible[3] = 0;
+ if (roomNumber == 26 && flags[21] == 0)
+ strcpy(objName[2], _textmisc[_lang][0]);
+ if (roomNumber == 26 && flags[18] == 1)
+ visible[2] = 0;
+ if (roomNumber == 26 && flags[12] == 1)
+ visible[1] = 0;
+ if (roomNumber == 35 && flags[14] == 1)
+ visible[2] = 0;
+ if (roomNumber == 35 && flags[17] == 1)
+ visible[3] = 1;
+ if (roomNumber == 35 && flags[15] == 1)
+ visible[1] = 0;
+ } else if (currentChapter == 5) {
+ if (roomNumber == 49 && flags[6] == 1)
+ visible[2] = 0;
+ if (roomNumber == 49 && flags[6] == 0)
+ visible[1] = 0;
+ if (roomNumber == 49 && flags[6] == 1)
+ visible[1] = 1;
+ if (roomNumber == 45 && flags[6] == 1)
+ visible[3] = 1;
+ if (roomNumber == 53 && flags[2] == 1)
+ visible[3] = 0;
+ if (roomNumber == 54 && flags[13] == 1)
+ visible[3] = 0;
+ if (roomNumber == 55 && flags[8] == 1)
+ visible[1] = 0;
+ } else if (currentChapter == 6) {
+ if (roomNumber == 58 && flags[8] == 0)
+ isDoor[1] = 0;
+ if (roomNumber == 58 && flags[8] == 1)
+ isDoor[1] = 1;
+ if (roomNumber == 59)
+ isDoor[1] = 0;
+ if (roomNumber == 60) {
+ trackDrascula = 0;
+ drasculaX = 155;
+ drasculaY = 69;
+ }
+ }
+}
+
+} // End of namespace Drascula
Property changes on: scummvm/branches/gsoc2008-tfmx/engines/drascula/objects.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Rev Author URL Id
Name: svn:eol-style
+ native
Added: scummvm/branches/gsoc2008-tfmx/engines/drascula/palette.cpp
===================================================================
--- scummvm/branches/gsoc2008-tfmx/engines/drascula/palette.cpp (rev 0)
+++ scummvm/branches/gsoc2008-tfmx/engines/drascula/palette.cpp 2008-07-14 18:54:15 UTC (rev 33060)
@@ -0,0 +1,202 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "drascula/drascula.h"
+
+namespace Drascula {
+
+void DrasculaEngine::setRGB(byte *pal, int colorCount) {
+ int x, cnt = 0;
+
+ for (x = 0; x < colorCount; x++) {
+ gamePalette[x][0] = pal[cnt++] / 4;
+ gamePalette[x][1] = pal[cnt++] / 4;
+ gamePalette[x][2] = pal[cnt++] / 4;
+ }
+ setPalette((byte *)&gamePalette);
+}
+
+void DrasculaEngine::black() {
+ int color, component;
+ DacPalette256 blackPalette;
+
+ for (color = 0; color < 256; color++)
+ for (component = 0; component < 3; component++)
+ blackPalette[color][component] = 0;
+
+ blackPalette[254][0] = 0x3F;
+ blackPalette[254][1] = 0x3F;
+ blackPalette[254][2] = 0x15;
+
+ setPalette((byte *)&blackPalette);
+}
+
+void DrasculaEngine::setPalette(byte *PalBuf) {
+ byte pal[256 * 4];
+ int i;
+
+ for (i = 0; i < 256; i++) {
+ pal[i * 4 + 0] = PalBuf[i * 3 + 0] * 4;
+ pal[i * 4 + 1] = PalBuf[i * 3 + 1] * 4;
+ pal[i * 4 + 2] = PalBuf[i * 3 + 2] * 4;
+ pal[i * 4 + 3] = 0;
+ }
+ _system->setPalette(pal, 0, 256);
+ _system->updateScreen();
+}
+
+void DrasculaEngine::color_abc(int cl) {
+ _color = cl;
+
+ char colorTable[][3] = {
+ { 0, 0, 0 }, { 0x10, 0x3E, 0x28 },
+ { 0, 0, 0 }, // unused
+ { 0x16, 0x3F, 0x16 }, { 0x09, 0x3F, 0x12 },
+ { 0x3F, 0x3F, 0x15 },
+ { 0, 0, 0 }, // unused
+ { 0x38, 0, 0 }, { 0x3F, 0x27, 0x0B },
+ { 0x2A, 0, 0x2A }, { 0x30, 0x30, 0x30 },
+ { 98, 91, 100 }
+ };
+
+ for (int i = 0; i <= 2; i++)
+ gamePalette[254][i] = colorTable[cl][i];
+
+ setPalette((byte *)&gamePalette);
+}
+
+signed char DrasculaEngine::adjustToVGA(signed char value) {
+ return (value & 0x3F) * (value > 0);
+}
+
+void DrasculaEngine::fadeToBlack(int fadeSpeed) {
+ signed char fade;
+ unsigned int color, component;
+
+ DacPalette256 palFade;
+
+ for (fade = 63; fade >= 0; fade--) {
+ for (color = 0; color < 256; color++) {
+ for (component = 0; component < 3; component++) {
+ palFade[color][component] = adjustToVGA(gamePalette[color][component] - 63 + fade);
+ }
+ }
+ pause(fadeSpeed);
+
+ setPalette((byte *)&palFade);
+ }
+}
+
+void DrasculaEngine::fadeFromBlack(int fadeSpeed) {
+ signed char fade;
+ unsigned int color, component;
+
+ DacPalette256 palFade;
+
+ for (fade = 0; fade < 64; fade++) {
+ for (color = 0; color < 256; color++) {
+ for (component = 0; component < 3; component++) {
+ palFade[color][component] = adjustToVGA(gamePalette[color][component] - 63 + fade);
+ }
+ }
+ pause(fadeSpeed);
+
+ setPalette((byte *)&palFade);
+ }
+}
+
+void DrasculaEngine::assignDefaultPalette() {
+ int color, component;
+
+ for (color = 235; color < 253; color++)
+ for (component = 0; component < 3; component++)
+ defaultPalette[color][component] = gamePalette[color][component];
+}
+
+void DrasculaEngine::assignBrightPalette() {
+ int color, component;
+
+ for (color = 235; color < 253; color++) {
+ for (component = 0; component < 3; component++)
+ brightPalette[color][component] = gamePalette[color][component];
+ }
+}
+
+void DrasculaEngine::assignDarkPalette() {
+ int color, component;
+
+ for (color = 235; color < 253; color++) {
+ for (component = 0; component < 3; component++)
+ darkPalette[color][component] = gamePalette[color][component];
+ }
+}
+
+void DrasculaEngine::setDefaultPalette() {
+ int color, component;
+
+ for (color = 235; color < 253; color++) {
+ for (component = 0; component < 3; component++) {
+ gamePalette[color][component] = defaultPalette[color][component];
+ }
+ }
+ setPalette((byte *)&gamePalette);
+}
+
+void DrasculaEngine::setBrightPalette() {
+ int color, component;
+
+ for (color = 235; color < 253; color++) {
+ for (component = 0; component < 3; component++)
+ gamePalette[color][component] = brightPalette[color][component];
+ }
+
+ setPalette((byte *)&gamePalette);
+}
+
+void DrasculaEngine::setDarkPalette() {
+ int color, component;
+
+ for (color = 235; color < 253; color++ )
+ for (component = 0; component < 3; component++)
+ gamePalette[color][component] = darkPalette[color][component];
+
+ setPalette((byte *)&gamePalette);
+}
+
+void DrasculaEngine::setPaletteBase(int darkness) {
+ signed char fade;
+ unsigned int color, component;
+
+ for (fade = darkness; fade >= 0; fade--) {
+ for (color = 235; color < 253; color++) {
+ for (component = 0; component < 3; component++)
+ gamePalette[color][component] = adjustToVGA(gamePalette[color][component] - 8 + fade);
+ }
+ }
+
+ setPalette((byte *)&gamePalette);
+}
+
+} // End of namespace Drascula
Property changes on: scummvm/branches/gsoc2008-tfmx/engines/drascula/palette.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Rev Author URL Id
Name: svn:eol-style
+ native
Added: scummvm/branches/gsoc2008-tfmx/engines/drascula/saveload.cpp
===================================================================
--- scummvm/branches/gsoc2008-tfmx/engines/drascula/saveload.cpp (rev 0)
+++ scummvm/branches/gsoc2008-tfmx/engines/drascula/saveload.cpp 2008-07-14 18:54:15 UTC (rev 33060)
@@ -0,0 +1,255 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "drascula/drascula.h"
+
+namespace Drascula {
+
+bool DrasculaEngine::saveLoadScreen() {
+ char names[10][23];
+ char file[50];
+ char fileEpa[50];
+ int n, n2, num_sav = 0, y = 27;
+ Common::InSaveFile *sav;
+
+ clearRoom();
+
+ snprintf(fileEpa, 50, "%s.epa", _targetName.c_str());
+ if (!(sav = _saveFileMan->openForLoading(fileEpa))) {
+ Common::OutSaveFile *epa;
+ if (!(epa = _saveFileMan->openForSaving(fileEpa)))
+ error("Can't open %s file", fileEpa);
+ for (n = 0; n < NUM_SAVES; n++)
+ epa->writeString("*\n");
+ epa->finalize();
+ delete epa;
+ if (!(sav = _saveFileMan->openForLoading(fileEpa))) {
+ error("Can't open %s file", fileEpa);
+ }
+ }
+ for (n = 0; n < NUM_SAVES; n++)
+ sav->readLine(names[n], 23);
+ delete sav;
+
+ loadPic("savescr.alg", bgSurface, HALF_PAL);
+
+ color_abc(kColorLightGreen);
+
+ select[0] = 0;
+
+ for (;;) {
+ y = 27;
+ copyBackground(0, 0, 0, 0, 320, 200, bgSurface, screenSurface);
+ for (n = 0; n < NUM_SAVES; n++) {
+ print_abc(names[n], 116, y);
+ y = y + 9;
+ }
+ print_abc(select, 117, 15);
+ setCursorTable();
+ updateScreen();
+ y = 27;
+
+ updateEvents();
+
+ if (leftMouseButton == 1) {
+ delay(50);
+ for (n = 0; n < NUM_SAVES; n++) {
+ if (mouseX > 115 && mouseY > y + (9 * n) && mouseX < 115 + 175 && mouseY < y + 10 + (9 * n)) {
+ strcpy(select, names[n]);
+
+ if (strcmp(select, "*"))
+ selectionMade = 1;
+ else {
+ enterName();
+ strcpy(names[n], select);
+ if (selectionMade == 1) {
+ snprintf(file, 50, "%s%02d", _targetName.c_str(), n + 1);
+ saveGame(file);
+ Common::OutSaveFile *tsav;
+ if (!(tsav = _saveFileMan->openForSaving(fileEpa))) {
+ error("Can't open %s file", fileEpa);
+ }
+ for (n = 0; n < NUM_SAVES; n++) {
+ tsav->writeString(names[n]);
+ tsav->writeString("\n");
+ }
+ tsav->finalize();
+ delete tsav;
+ }
+ }
+
+ print_abc(select, 117, 15);
+ y = 27;
+ for (n2 = 0; n2 < NUM_SAVES; n2++) {
+ print_abc(names[n2], 116, y);
+ y = y + 9;
+ }
+ if (selectionMade == 1) {
+ snprintf(file, 50, "%s%02d", _targetName.c_str(), n + 1);
+ }
+ num_sav = n;
+ }
+ }
+
+ if (mouseX > 117 && mouseY > 15 && mouseX < 295 && mouseY < 24 && selectionMade == 1) {
+ enterName();
+ strcpy(names[num_sav], select);
+ print_abc(select, 117, 15);
+ y = 27;
+ for (n2 = 0; n2 < NUM_SAVES; n2++) {
+ print_abc(names[n2], 116, y);
+ y = y + 9;
+ }
+
+ if (selectionMade == 1) {
+ snprintf(file, 50, "%s%02d", _targetName.c_str(), n + 1);
+ saveGame(file);
+ Common::OutSaveFile *tsav;
+ if (!(tsav = _saveFileMan->openForSaving(fileEpa))) {
+ error("Can't open %s file", fileEpa);
+ }
+ for (n = 0; n < NUM_SAVES; n++) {
+ tsav->writeString(names[n]);
+ tsav->writeString("\n");
+ }
+ tsav->finalize();
+ delete tsav;
+ }
+ }
+
+ if (mouseX > 125 && mouseY > 123 && mouseX < 199 && mouseY < 149 && selectionMade == 1) {
+ if (!loadGame(file))
+ return false;
+ break;
+ } else if (mouseX > 208 && mouseY > 123 && mouseX < 282 && mouseY < 149 && selectionMade == 1) {
+ saveGame(file);
+ Common::OutSaveFile *tsav;
+ if (!(tsav = _saveFileMan->openForSaving(fileEpa))) {
+ error("Can't open %s file", fileEpa);
+ }
+ for (n = 0; n < NUM_SAVES; n++) {
+ tsav->writeString(names[n]);
+ tsav->writeString("\n");
+ }
+ tsav->finalize();
+ delete tsav;
+ } else if (mouseX > 168 && mouseY > 154 && mouseX < 242 && mouseY < 180)
+ break;
+ else if (selectionMade == 0) {
+ print_abc("Please select a slot", 117, 15);
+ }
+ updateScreen();
+ delay(200);
+ }
+ y = 26;
+
+ delay(5);
+ }
+
+ clearRoom();
+ loadPic(roomNumber, bgSurface, HALF_PAL);
+ selectionMade = 0;
+
+ return true;
+}
+
+bool DrasculaEngine::loadGame(const char *gameName) {
+ int l, savedChapter, roomNum = 0;
+ Common::InSaveFile *sav;
+
+ previousMusic = roomMusic;
+ menuScreen = 0;
+ if (currentChapter != 1)
+ clearRoom();
+
+ if (!(sav = _saveFileMan->openForLoading(gameName))) {
+ error("missing savegame file");
+ }
+
+ savedChapter = sav->readSint32LE();
+ if (savedChapter != currentChapter) {
+ strcpy(saveName, gameName);
+ currentChapter = savedChapter - 1;
+ hay_que_load = 1;
+ return false;
+ }
+ sav->read(currentData, 20);
+ curX = sav->readSint32LE();
+ curY = sav->readSint32LE();
+ trackProtagonist = sav->readSint32LE();
+
+ for (l = 1; l < 43; l++) {
+ inventoryObjects[l] = sav->readSint32LE();
+ }
+
+ for (l = 0; l < NUM_FLAGS; l++) {
+ flags[l] = sav->readSint32LE();
+ }
+
+ takeObject = sav->readSint32LE();
+ pickedObject = sav->readSint32LE();
+ hay_que_load = 0;
+ sscanf(currentData, "%d.ald", &roomNum);
+ enterRoom(roomNum);
+ withoutVerb();
+
+ return true;
+}
+
+void DrasculaEngine::saveGame(char gameName[]) {
+ Common::OutSaveFile *out;
+ int l;
+
+ if (!(out = _saveFileMan->openForSaving(gameName))) {
+ error("Unable to open the file");
+ }
+ out->writeSint32LE(currentChapter);
+ out->write(currentData, 20);
+ out->writeSint32LE(curX);
+ out->writeSint32LE(curY);
+ out->writeSint32LE(trackProtagonist);
+
+ for (l = 1; l < 43; l++) {
+ out->writeSint32LE(inventoryObjects[l]);
+ }
+
+ for (l = 0; l < NUM_FLAGS; l++) {
+ out->writeSint32LE(flags[l]);
+ }
+
+ out->writeSint32LE(takeObject);
+ out->writeSint32LE(pickedObject);
+
+ out->finalize();
+ if (out->ioFailed())
+ warning("Can't write file '%s'. (Disk full?)", gameName);
+
+ delete out;
+
+ playSound(99);
+ finishSound();
+}
+
+} // End of namespace Drascula
Property changes on: scummvm/branches/gsoc2008-tfmx/engines/drascula/saveload.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Rev Author URL Id
Name: svn:eol-style
+ native
Added: scummvm/branches/gsoc2008-tfmx/engines/drascula/sound.cpp
===================================================================
--- scummvm/branches/gsoc2008-tfmx/engines/drascula/sound.cpp (rev 0)
+++ scummvm/branches/gsoc2008-tfmx/engines/drascula/sound.cpp 2008-07-14 18:54:15 UTC (rev 33060)
@@ -0,0 +1,159 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "drascula/drascula.h"
+
+namespace Drascula {
+
+void DrasculaEngine::updateVolume(Audio::Mixer::SoundType soundType, int prevVolume) {
+ int vol = _mixer->getVolumeForSoundType(soundType) / 16;
+ if (mouseY < prevVolume && vol < 15)
+ vol++;
+ if (mouseY > prevVolume && vol > 0)
+ vol--;
+ _mixer->setVolumeForSoundType(soundType, vol * 16);
+}
+
+void DrasculaEngine::volumeControls() {
+ int masterVolume, voiceVolume, musicVolume;
+
+ copyRect(1, 56, 73, 63, 177, 97, tableSurface, screenSurface);
+ updateScreen(73, 63, 73, 63, 177, 97, screenSurface);
+
+ masterVolume = 72 + 61 - ((_mixer->getVolumeForSoundType(Audio::Mixer::kPlainSoundType) / 16) * 4);
+ voiceVolume = 72 + 61 - ((_mixer->getVolumeForSoundType(Audio::Mixer::kSFXSoundType) / 16) * 4);
+ musicVolume = 72 + 61 - ((_mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType) / 16) * 4);
+
+ for (;;) {
+ updateRoom();
+
+ copyRect(1, 56, 73, 63, 177, 97, tableSurface, screenSurface);
+
+ copyBackground(183, 56, 82, masterVolume, 39, 2 + ((_mixer->getVolumeForSoundType(Audio::Mixer::kPlainSoundType) / 16) * 4), tableSurface, screenSurface);
+ copyBackground(183, 56, 138, voiceVolume, 39, 2 + ((_mixer->getVolumeForSoundType(Audio::Mixer::kSFXSoundType) / 16) * 4), tableSurface, screenSurface);
+ copyBackground(183, 56, 194, musicVolume, 39, 2 + ((_mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType) / 16) * 4), tableSurface, screenSurface);
+
+ setCursorTable();
+
+ updateScreen();
+
+ updateEvents();
+
+ if (rightMouseButton == 1) {
+ delay(100);
+ break;
+ }
+ if (leftMouseButton == 1) {
+ delay(100);
+ if (mouseX > 80 && mouseX < 121) {
+ updateVolume(Audio::Mixer::kPlainSoundType, mouseY);
+ masterVolume = 72 + 61 - ((_mixer->getVolumeForSoundType(Audio::Mixer::kPlainSoundType) / 16) * 4);
+ }
+
+ if (mouseX > 136 && mouseX < 178) {
+ updateVolume(Audio::Mixer::kSFXSoundType, mouseY);
+ voiceVolume = 72 + 61 - ((_mixer->getVolumeForSoundType(Audio::Mixer::kSFXSoundType) / 16) * 4);
+ }
+
+ if (mouseX > 192 && mouseX < 233) {
+ updateVolume(Audio::Mixer::kMusicSoundType, mouseY);
+ musicVolume = 72 + 61 - ((_mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType) / 16) * 4);
+ }
+ }
+
+ }
+
+ updateEvents();
+}
+
+void DrasculaEngine::playSound(int soundNum) {
+ char file[20];
+ sprintf(file, "s%i.als", soundNum);
+
+ playFile(file);
+}
+
+void DrasculaEngine::finishSound() {
+ delay(1);
+
+ while (soundIsActive())
+ _system->delayMillis(10);
+}
+
+void DrasculaEngine::playMusic(int p) {
+ AudioCD.stop();
+ AudioCD.play(p - 1, 1, 0, 0);
+}
+
+void DrasculaEngine::stopMusic() {
+ AudioCD.stop();
+}
+
+int DrasculaEngine::musicStatus() {
+ return AudioCD.isPlaying();
+}
+
+void DrasculaEngine::stopSound() {
+ _mixer->stopHandle(_soundHandle);
+}
+
+void DrasculaEngine::MusicFadeout() {
+ int org_vol = _mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType);
+ for (;;) {
+ int vol = _mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType);
+ vol -= 10;
+ if (vol < 0)
+ vol = 0;
+ _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, vol);
+ if (vol == 0)
+ break;
+ updateEvents();
+ _system->updateScreen();
+ _system->delayMillis(50);
+ }
+ AudioCD.stop();
+ _system->delayMillis(100);
+ _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, org_vol);
+}
+
+void DrasculaEngine::playFile(const char *fname) {
+ if (_arj.open(fname)) {
+ int soundSize = _arj.size();
+ byte *soundData = (byte *)malloc(soundSize);
+ _arj.seek(32);
+ _arj.read(soundData, soundSize);
+ _arj.close();
+
+ _mixer->playRaw(Audio::Mixer::kSFXSoundType, &_soundHandle, soundData, soundSize - 64,
+ 11025, Audio::Mixer::FLAG_AUTOFREE | Audio::Mixer::FLAG_UNSIGNED);
+ } else
+ warning("playFile: Could not open %s", fname);
+}
+
+bool DrasculaEngine::soundIsActive() {
+ return _mixer->isSoundHandleActive(_soundHandle);
+}
+
+} // End of namespace Drascula
Property changes on: scummvm/branches/gsoc2008-tfmx/engines/drascula/sound.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Rev Author URL Id
Name: svn:eol-style
+ native
Modified: scummvm/branches/gsoc2008-tfmx/engines/gob/driver_vga.cpp
===================================================================
--- scummvm/branches/gsoc2008-tfmx/engines/gob/driver_vga.cpp 2008-07-14 18:42:38 UTC (rev 33059)
+++ scummvm/branches/gsoc2008-tfmx/engines/gob/driver_vga.cpp 2008-07-14 18:54:15 UTC (rev 33060)
@@ -112,7 +112,7 @@
if ((width < 1) || (height < 1))
return;
- byte *srcPos = source->getVidMem() + (top * source->getWidth()) + left;
+ const byte *srcPos = source->getVidMem() + (top * source->getWidth()) + left;
byte *destPos = dest->getVidMem() + (y * dest->getWidth()) + x;
uint32 size = width * height;
Modified: scummvm/branches/gsoc2008-tfmx/engines/gob/goblin.cpp
===================================================================
--- scummvm/branches/gsoc2008-tfmx/engines/gob/goblin.cpp 2008-07-14 18:42:38 UTC (rev 33059)
+++ scummvm/branches/gsoc2008-tfmx/engines/gob/goblin.cpp 2008-07-14 18:54:15 UTC (rev 33060)
@@ -78,58 +78,6 @@
_pressedMapY = 0;
_pathExistence = 0;
- _some0ValPtr = 0;
-
- _gobRetVarPtr = 0;
- _curGobVarPtr = 0;
- _curGobXPosVarPtr = 0;
- _curGobYPosVarPtr = 0;
- _itemInPocketVarPtr = 0;
-
- _curGobStateVarPtr = 0;
- _curGobFrameVarPtr = 0;
- _curGobMultStateVarPtr = 0;
- _curGobNextStateVarPtr = 0;
- _curGobScrXVarPtr = 0;
- _curGobScrYVarPtr = 0;
- _curGobLeftVarPtr = 0;
- _curGobTopVarPtr = 0;
- _curGobRightVarPtr = 0;
- _curGobBottomVarPtr = 0;
- _curGobDoAnimVarPtr = 0;
- _curGobOrderVarPtr = 0;
- _curGobNoTickVarPtr = 0;
- _curGobTypeVarPtr = 0;
- _curGobMaxTickVarPtr = 0;
- _curGobTickVarPtr = 0;
- _curGobActStartStateVarPtr = 0;
- _curGobLookDirVarPtr = 0;
- _curGobPickableVarPtr = 0;
- _curGobRelaxVarPtr = 0;
- _curGobMaxFrameVarPtr = 0;
-
- _destItemStateVarPtr = 0;
- _destItemFrameVarPtr = 0;
- _destItemMultStateVarPtr = 0;
- _destItemNextStateVarPtr = 0;
- _destItemScrXVarPtr = 0;
- _destItemScrYVarPtr = 0;
- _destItemLeftVarPtr = 0;
- _destItemTopVarPtr = 0;
- _destItemRightVarPtr = 0;
- _destItemBottomVarPtr = 0;
- _destItemDoAnimVarPtr = 0;
- _destItemOrderVarPtr = 0;
- _destItemNoTickVarPtr = 0;
- _destItemTypeVarPtr = 0;
- _destItemMaxTickVarPtr = 0;
- _destItemTickVarPtr = 0;
- _destItemActStartStVarPtr = 0;
- _destItemLookDirVarPtr = 0;
- _destItemPickableVarPtr = 0;
- _destItemRelaxVarPtr = 0;
- _destItemMaxFrameVarPtr = 0;
-
_destItemType = 0;
_destItemState = 0;
for (int i = 0; i < 20; i++) {
@@ -690,7 +638,7 @@
_gobDestY = tmp;
_vm->_map->_curGoblinY = tmp;
- *_curGobVarPtr = _currentGoblin;
+ _curGobVarPtr = (uint32) _currentGoblin;
_pathExistence = 0;
_readyToAct = 0;
}
@@ -1250,172 +1198,172 @@
void Goblin::saveGobDataToVars(int16 xPos, int16 yPos, int16 someVal) {
Gob_Object *obj;
- *_some0ValPtr = someVal;
- *_curGobXPosVarPtr = xPos;
- *_curGobYPosVarPtr = yPos;
- *_itemInPocketVarPtr = _itemIndInPocket;
+ _some0ValPtr = (uint32) someVal;
+ _curGobXPosVarPtr = (uint32) xPos;
+ _curGobYPosVarPtr = (uint32) yPos;
+ _itemInPocketVarPtr = (uint32) _itemIndInPocket;
obj = _goblins[_currentGoblin];
- *_curGobStateVarPtr = obj->state;
- *_curGobFrameVarPtr = obj->curFrame;
- *_curGobMultStateVarPtr = obj->multState;
- *_curGobNextStateVarPtr = obj->nextState;
- *_curGobScrXVarPtr = obj->xPos;
- *_curGobScrYVarPtr = obj->yPos;
- *_curGobLeftVarPtr = obj->left;
- *_curGobTopVarPtr = obj->top;
- *_curGobRightVarPtr = obj->right;
- *_curGobBottomVarPtr = obj->bottom;
- *_curGobDoAnimVarPtr = obj->doAnim;
- *_curGobOrderVarPtr = obj->order;
- *_curGobNoTickVarPtr = obj->noTick;
- *_curGobTypeVarPtr = obj->type;
- *_curGobMaxTickVarPtr = obj->maxTick;
- *_curGobTickVarPtr = obj->tick;
- *_curGobActStartStateVarPtr = obj->actionStartState;
- *_curGobLookDirVarPtr = obj->curLookDir;
- *_curGobPickableVarPtr = obj->pickable;
- *_curGobRelaxVarPtr = obj->relaxTime;
- *_curGobMaxFrameVarPtr = getObjMaxFrame(obj);
+ _curGobStateVarPtr = (uint32) obj->state;
+ _curGobFrameVarPtr = (uint32) obj->curFrame;
+ _curGobMultStateVarPtr = (uint32) obj->multState;
+ _curGobNextStateVarPtr = (uint32) obj->nextState;
+ _curGobScrXVarPtr = (uint32) obj->xPos;
+ _curGobScrYVarPtr = (uint32) obj->yPos;
+ _curGobLeftVarPtr = (uint32) obj->left;
+ _curGobTopVarPtr = (uint32) obj->top;
+ _curGobRightVarPtr = (uint32) obj->right;
+ _curGobBottomVarPtr = (uint32) obj->bottom;
+ _curGobDoAnimVarPtr = (uint32) obj->doAnim;
+ _curGobOrderVarPtr = (uint32) obj->order;
+ _curGobNoTickVarPtr = (uint32) obj->noTick;
+ _curGobTypeVarPtr = (uint32) obj->type;
+ _curGobMaxTickVarPtr = (uint32) obj->maxTick;
+ _curGobTickVarPtr = (uint32) obj->tick;
+ _curGobActStartStateVarPtr = (uint32) obj->actionStartState;
+ _curGobLookDirVarPtr = (uint32) obj->curLookDir;
+ _curGobPickableVarPtr = (uint32) obj->pickable;
+ _curGobRelaxVarPtr = (uint32) obj->relaxTime;
+ _curGobMaxFrameVarPtr = (uint32) getObjMaxFrame(obj);
if (_actDestItemDesc == 0)
return;
obj = _actDestItemDesc;
- *_destItemStateVarPtr = obj->state;
- *_destItemFrameVarPtr = obj->curFrame;
- *_destItemMultStateVarPtr = obj->multState;
- *_destItemNextStateVarPtr = obj->nextState;
- *_destItemScrXVarPtr = obj->xPos;
- *_destItemScrYVarPtr = obj->yPos;
- *_destItemLeftVarPtr = obj->left;
- *_destItemTopVarPtr = obj->top;
- *_destItemRightVarPtr = obj->right;
- *_destItemBottomVarPtr = obj->bottom;
- *_destItemDoAnimVarPtr = obj->doAnim;
- *_destItemOrderVarPtr = obj->order;
- *_destItemNoTickVarPtr = obj->noTick;
- *_destItemTypeVarPtr = obj->type;
- *_destItemMaxTickVarPtr = obj->maxTick;
- *_destItemTickVarPtr = obj->tick;
- *_destItemActStartStVarPtr = obj->actionStartState;
- *_destItemLookDirVarPtr = obj->curLookDir;
- *_destItemPickableVarPtr = obj->pickable;
- *_destItemRelaxVarPtr = obj->relaxTime;
- *_destItemMaxFrameVarPtr = getObjMaxFrame(obj);
+ _destItemStateVarPtr = (uint32) obj->state;
+ _destItemFrameVarPtr = (uint32) obj->curFrame;
+ _destItemMultStateVarPtr = (uint32) obj->multState;
+ _destItemNextStateVarPtr = (uint32) obj->nextState;
+ _destItemScrXVarPtr = (uint32) obj->xPos;
+ _destItemScrYVarPtr = (uint32) obj->yPos;
+ _destItemLeftVarPtr = (uint32) obj->left;
+ _destItemTopVarPtr = (uint32) obj->top;
+ _destItemRightVarPtr = (uint32) obj->right;
+ _destItemBottomVarPtr = (uint32) obj->bottom;
+ _destItemDoAnimVarPtr = (uint32) obj->doAnim;
+ _destItemOrderVarPtr = (uint32) obj->order;
+ _destItemNoTickVarPtr = (uint32) obj->noTick;
+ _destItemTypeVarPtr = (uint32) obj->type;
+ _destItemMaxTickVarPtr = (uint32) obj->maxTick;
+ _destItemTickVarPtr = (uint32) obj->tick;
+ _destItemActStartStVarPtr = (uint32) obj->actionStartState;
+ _destItemLookDirVarPtr = (uint32) obj->curLookDir;
+ _destItemPickableVarPtr = (uint32) obj->pickable;
+ _destItemRelaxVarPtr = (uint32) obj->relaxTime;
+ _destItemMaxFrameVarPtr = (uint32) getObjMaxFrame(obj);
_destItemState = obj->state;
_destItemType = obj->type;
}
void Goblin::initVarPointers(void) {
- _gobRetVarPtr = (int32 *)VAR_ADDRESS(59);
- _curGobStateVarPtr = (int32 *)VAR_ADDRESS(60);
- _curGobFrameVarPtr = (int32 *)VAR_ADDRESS(61);
- _curGobMultStateVarPtr = (int32 *)VAR_ADDRESS(62);
- _curGobNextStateVarPtr = (int32 *)VAR_ADDRESS(63);
- _curGobScrXVarPtr = (int32 *)VAR_ADDRESS(64);
- _curGobScrYVarPtr = (int32 *)VAR_ADDRESS(65);
- _curGobLeftVarPtr = (int32 *)VAR_ADDRESS(66);
- _curGobTopVarPtr = (int32 *)VAR_ADDRESS(67);
- _curGobRightVarPtr = (int32 *)VAR_ADDRESS(68);
- _curGobBottomVarPtr = (int32 *)VAR_ADDRESS(69);
- _curGobDoAnimVarPtr = (int32 *)VAR_ADDRESS(70);
- _curGobOrderVarPtr = (int32 *)VAR_ADDRESS(71);
- _curGobNoTickVarPtr = (int32 *)VAR_ADDRESS(72);
- _curGobTypeVarPtr = (int32 *)VAR_ADDRESS(73);
- _curGobMaxTickVarPtr = (int32 *)VAR_ADDRESS(74);
- _curGobTickVarPtr = (int32 *)VAR_ADDRESS(75);
- _curGobActStartStateVarPtr = (int32 *)VAR_ADDRESS(76);
- _curGobLookDirVarPtr = (int32 *)VAR_ADDRESS(77);
- _curGobPickableVarPtr = (int32 *)VAR_ADDRESS(80);
- _curGobRelaxVarPtr = (int32 *)VAR_ADDRESS(81);
- _destItemStateVarPtr = (int32 *)VAR_ADDRESS(82);
- _destItemFrameVarPtr = (int32 *)VAR_ADDRESS(83);
- _destItemMultStateVarPtr = (int32 *)VAR_ADDRESS(84);
@@ 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