[Scummvm-cvs-logs] CVS: scummvm/kyra codecs.cpp,1.11,1.12 codecs.h,1.5,1.6 cpsimage.cpp,1.8,1.9 font.cpp,1.10,1.11 kyra.cpp,1.32,1.33 kyra.h,1.9,1.10 palette.cpp,1.8,1.9 resource.cpp,1.13,1.14 resource.h,1.9,1.10 script.cpp,1.14,1.15 script.h,1.6,1.7 script_v1.cpp,1.10,1.11 sound.cpp,1.5,1.6 sound.h,1.4,1.5 wsamovie.cpp,1.9,1.10 wsamovie.h,1.6,1.7
Eugene Sandulenko
sev at users.sourceforge.net
Sat Jul 30 14:15:11 CEST 2005
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/common array.h,1.5,1.6 config-file.cpp,1.26,1.27 config-file.h,1.13,1.14 config-manager.cpp,1.37,1.38 config-manager.h,1.24,1.25 debugger.h,1.8,1.9 endian.h,1.1,1.2 file.h,1.37,1.38 list.h,1.27,1.28 map.h,1.25,1.26 md5.cpp,1.9,1.10 mutex.cpp,1.3,1.4 rect.h,1.26,1.27 savefile.cpp,1.27,1.28 savefile.h,1.21,1.22 scaler.cpp,1.70,1.71 scummsys.h,1.64,1.65 singleton.h,1.15,1.16 stack.h,1.5,1.6 str.cpp,1.36,1.37 str.h,1.27,1.28 stream.cpp,1.9,1.10 stream.h,1.21,1.22 system.h,1.103,1.104 timer.cpp,1.35,1.36 util.cpp,1.57,1.58 util.h,1.53,1.54
- Next message: [Scummvm-cvs-logs] CVS: scummvm/gui Actions.cpp,1.1,1.2 Actions.h,1.1,1.2 EditTextWidget.cpp,1.35,1.36 EditTextWidget.h,1.20,1.21 KeysDialog.cpp,1.1,1.2 ListWidget.cpp,1.55,1.56 ListWidget.h,1.33,1.34 PopUpWidget.cpp,1.38,1.39 PopUpWidget.h,1.15,1.16 ScrollBarWidget.h,1.10,1.11 TabWidget.cpp,1.18,1.19 about.cpp,1.38,1.39 about.h,1.15,1.16 browser.cpp,1.34,1.35 chooser.cpp,1.18,1.19 console.h,1.33,1.34 dialog.h,1.40,1.41 editable.cpp,1.8,1.9 editable.h,1.5,1.6 launcher.cpp,1.126,1.127 launcher.h,1.23,1.24 message.cpp,1.29,1.30 newgui.cpp,1.118,1.119 newgui.h,1.61,1.62 options.cpp,1.92,1.93 widget.cpp,1.53,1.54 widget.h,1.46,1.47
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/kyra
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9428/kyra
Modified Files:
codecs.cpp codecs.h cpsimage.cpp font.cpp kyra.cpp kyra.h
palette.cpp resource.cpp resource.h script.cpp script.h
script_v1.cpp sound.cpp sound.h wsamovie.cpp wsamovie.h
Log Message:
Remove trailing whitespaces.
Index: codecs.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/codecs.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- codecs.cpp 24 Jun 2005 16:01:42 -0000 1.11
+++ codecs.cpp 30 Jul 2005 21:11:01 -0000 1.12
@@ -23,7 +23,7 @@
#include "kyra/codecs.h"
/*****************************************************************************
- * decode.c - Decoding routines for format80, format40, format20
+ * decode.c - Decoding routines for format80, format40, format20
* and format3 type graphics
* Author: Olaf van der spek
* Modified for FreeCNC by Kareem Dana
@@ -83,7 +83,7 @@
copyp = (const uint8*)&image_out[READ_LE_UINT16(readp)];
readp += 2;
- // FIXME: Using memmove sometimes segfaults
+ // FIXME: Using memmove sometimes segfaults
// (reproducably for Ender), which suggests something Bad here
//memmove(writep, copyp, count);
//writep += count;
@@ -197,26 +197,26 @@
*/
int Compression::decode3(const uint8* image_in, uint8* image_out, int size) {
/* Untested on BIG-Endian machines */
-
+
/*
0 copy
- 1 fill
- 2 fill
+ 1 fill
+ 2 fill
*/
const uint8* readp = image_in;
uint8* writep = image_out;
int16 code;
int16 count;
-
+
do {
code = *const_cast<int8*>((const int8*)readp++);
- if (code > 0) { // Copy
+ if (code > 0) { // Copy
count = code ;
while (count--)
*writep++ = *readp++;
} else if (code == 0) { // Fill(1)
count = READ_BE_UINT16(readp);
-
+
readp += 2;
code = *readp++;
while (count--)
@@ -227,10 +227,10 @@
while (count--)
*writep++ = (uint8)code;
}
- } while ((writep - image_out) < size);
-
- //and, to be uniform to other decomp. functions...
- return (writep - image_out);
+ } while ((writep - image_out) < size);
+
+ //and, to be uniform to other decomp. functions...
+ return (writep - image_out);
}
/** decompress format 20 compressed data.
Index: codecs.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/codecs.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- codecs.h 9 Jan 2005 16:06:29 -0000 1.5
+++ codecs.h 30 Jul 2005 21:11:01 -0000 1.6
@@ -29,7 +29,7 @@
#include "common/scummsys.h"
namespace Kyra {
-class Compression
+class Compression
{
public:
static int decode80(const uint8* image_in, uint8* image_out);
Index: cpsimage.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/cpsimage.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- cpsimage.cpp 24 Jun 2005 16:01:42 -0000 1.8
+++ cpsimage.cpp 30 Jul 2005 21:11:01 -0000 1.9
@@ -35,7 +35,7 @@
static const CPSResource CPSResourceTable[] = {
{ 64000, 320 }, { 7740, 180 }, { 46080, 320 }, { 0, 0 }
};
-
+
static int16 getWidthFromCPSRes(uint32 size) {
int16 c = 0;
@@ -53,32 +53,32 @@
}
_ownPalette = 0;
Common::MemoryReadStream bufferstream(buffer, size);
-
+
// reads in the Header
_cpsHeader._filesize = bufferstream.readUint16LE() + 2;
_cpsHeader._format = bufferstream.readUint16LE();
_cpsHeader._imagesize = bufferstream.readUint16LE();
_cpsHeader._pal = bufferstream.readUint32LE();
-
+
// lets check a bit
if (_cpsHeader._pal == 0x3000000) {
// if this was a compressed palette you should have strange graphics
-
+
uint8* palbuffer = new uint8[768];
assert(palbuffer);
-
+
bufferstream.read(palbuffer, 768 * sizeof(uint8));
-
+
_ownPalette = new Palette(palbuffer, 768);
assert(palbuffer);
}
-
+
_image = new uint8[_cpsHeader._imagesize];
assert(_image);
-
+
uint8* imagebuffer = &buffer[bufferstream.pos()];
assert(imagebuffer);
-
+
if (_cpsHeader._format == 4) {
Compression::decode80(imagebuffer, _image);
} else if (_cpsHeader._format == 3) {
@@ -86,36 +86,36 @@
} else {
error("unknown CPS format %d", _cpsHeader._format);
}
-
+
int16 width = getWidthFromCPSRes(_cpsHeader._imagesize);
-
+
if (width == -1) {
warning("unknown CPS width(imagesize: %d)", _cpsHeader._imagesize);
delete [] buffer;
return;
}
-
+
_width = (uint16)width;
_height = _cpsHeader._imagesize / _width;
-
+
_transparency = -1;
-
+
delete [] buffer;
}
-
+
CPSImage::~CPSImage() {
delete [] _image;
delete _ownPalette;
}
-
+
void CPSImage::drawToPlane(uint8* plane, uint16 planepitch, uint16 planeheight, uint16 x, uint16 y) {
uint8* src = _image;
uint8* dst = &plane[y * planepitch + x];
uint32 copysize = planepitch - x;
-
+
if (copysize > _width)
copysize = _width;
-
+
if (_transparency == -1) {
// 'fast' blitting
for (uint16 y_ = 0; y_ < _height && y + y_ < planeheight; ++y_) {
@@ -123,10 +123,10 @@
dst += planepitch;
src += _width;
}
-
+
} else {
// oh no! we have transparency so we have a very slow copy :/
-
+
for (uint16 yadd = 0; yadd < _height; ++yadd) {
for (uint16 xadd = 0; xadd < copysize; ++xadd) {
if (*src == _transparency) {
@@ -136,25 +136,25 @@
*dst++ = *src++;
}
}
-
+
src += _width - copysize;
dst += planepitch - copysize;
}
}
}
-
+
void CPSImage::drawToPlane(uint8* plane, uint16 planepitch, uint16 planeheight, uint16 x, uint16 y,
uint16 srcx, uint16 srcy, uint16 srcwidth, uint16 srcheight) {
uint8* src = &_image[srcy * _width + srcx];
uint8* dst = &plane[y * planepitch + x];
uint32 copysize = planepitch - x;
-
+
if (srcwidth > _width)
srcwidth = _width;
-
+
if (copysize > srcwidth)
copysize = srcwidth;
-
+
if (_transparency == -1) {
// 'fast' blitting
for (uint16 y_ = 0; y_ < srcheight && y + y_ < planeheight; ++y_) {
@@ -162,10 +162,10 @@
dst += planepitch;
src += _width;
}
-
+
} else {
// oh no! we have transparency so we have a very slow copy :/
-
+
for (uint16 yadd = 0; yadd < srcheight; ++yadd) {
for (uint16 xadd = 0; xadd < copysize; ++xadd) {
if (*src == _transparency) {
@@ -175,7 +175,7 @@
*dst++ = *src++;
}
}
-
+
dst += planepitch - copysize;
src += _width - copysize;
}
Index: font.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/font.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- font.cpp 24 Jun 2005 16:01:42 -0000 1.10
+++ font.cpp 30 Jul 2005 21:11:01 -0000 1.11
@@ -37,9 +37,9 @@
if (!buffer) {
error("resource created without data");
}
-
+
_buffer = buffer;
-
+
Common::MemoryReadStream bufferstream(buffer, size);
_fontHeader._size = bufferstream.readUint16LE();
@@ -52,8 +52,8 @@
_fontHeader._version = bufferstream.readUint16LE();
_fontHeader._countChars = bufferstream.readUint16LE();
_fontHeader._width = bufferstream.readByte();
- _fontHeader._height = bufferstream.readByte();
-
+ _fontHeader._height = bufferstream.readByte();
+
// tests for the magic values
if (_fontHeader._magic1 != FontHeader_Magic1 || _fontHeader._magic2 != FontHeader_Magic2 ||
_fontHeader._magic3 != FontHeader_Magic3) {
@@ -61,13 +61,13 @@
"_magic1 = 0x%x, _magic2 = 0x%x, _magic3 = 0x%x",
_fontHeader._magic1, _fontHeader._magic2, _fontHeader._magic3);
}
-
+
// init all the pointers
_offsetTable = (uint16*)&buffer[bufferstream.pos()];
_charWidth = &buffer[_fontHeader._charWidthOffset];
_charHeight = (uint16*)&buffer[_fontHeader._charHeightOffset];
_charBits = &buffer[_fontHeader._charBitsOffset];
-
+
// now prerender =)
preRenderAllChars(bufferstream.pos());
@@ -77,7 +77,7 @@
// Russian Floppy: 0x1010
// German Floppy and English/German CD: 0x1011
debug("Font::_version = 0x%x", _fontHeader._version);
-
+
delete [] _buffer;
_buffer = 0;
_offsetTable = 0;
@@ -85,54 +85,54 @@
_charWidth = 0;
_charBits = 0;
}
-
+
Font::~Font() {
// FIXME: Release memory of the prerendered chars
}
-
+
uint32 Font::getStringWidth(const char* string, char terminator) {
uint32 strsize;
-
+
for (strsize = 0; string[strsize] != terminator && string[strsize] != '\0'; ++strsize)
;
-
+
uint32 stringwidth = 0;
-
+
for (uint32 pos = 0; pos < strsize; ++pos) {
stringwidth += _preRenderedChars[string[pos]].width;
}
-
+
return stringwidth;
}
-
+
const uint8* Font::getChar(char c, uint8* width, uint8* height, uint8* heightadd) {
PreRenderedChar& c_ = _preRenderedChars[c];
-
+
*width = c_.width;
*height = c_.height;
*heightadd = c_.heightadd;
-
+
return c_.c;
}
-
-// splits up the String in a word
+
+// splits up the String in a word
const char* Font::getNextWord(const char* string, uint32* size) {
uint32 startpos = 0;
*size = 0;
-
+
// gets start of the word
for (; string[startpos] == ' '; ++startpos)
;
-
+
// not counting size
for (*size = 0; string[startpos + *size] != ' ' && string[startpos + *size] != '\0'; ++(*size))
;
-
+
++(*size);
-
+
return &string[startpos];
}
-
+
// Move this to Font declaration?
struct WordChunk {
const char* _string;
@@ -142,36 +142,36 @@
void Font::drawStringToPlane(const char* string,
uint8* plane, uint16 planewidth, uint16 planeheight,
uint16 x, uint16 y, uint8 color) {
-
+
// lets do it word after word
Common::Array<WordChunk> words;
-
+
uint32 lastPos = 0;
uint32 lastSize = 0;
uint32 strlgt = strlen(string);
-
+
while (true) {
WordChunk newchunk;
newchunk._string = getNextWord(&string[lastPos], &lastSize);
newchunk._size = lastSize;
- lastPos += lastSize;
-
+ lastPos += lastSize;
+
words.push_back(newchunk);
-
+
if (lastPos >= strlgt)
break;
}
-
+
uint16 current_x = x, current_y = y;
uint8 heighest = 0;
-
+
const uint8* src = 0;
uint8 width = 0, height = 0, heightadd = 0;
-
+
// now the have alle of these words
for (uint32 tmp = 0; tmp < words.size(); ++tmp) {
lastSize = getStringWidth(words[tmp]._string, ' ');
-
+
// adjust x position
if (current_x + lastSize >= planewidth) {
// hmm lets move it a bit to the left
@@ -179,93 +179,93 @@
current_x = planewidth - lastSize;
} else {
current_x = x;
- if (heighest)
+ if (heighest)
current_y += heighest + 2;
else // now we are using just the fist char :)
current_y += _preRenderedChars[words[tmp]._string[0]].height;
heighest = 0;
}
}
-
+
// TODO: maybe test if current_y >= planeheight ?
-
+
// output word :)
for (lastPos = 0; lastPos < words[tmp]._size; ++lastPos) {
if (words[tmp]._string[lastPos] == '\0')
break;
-
+
// gets our char :)
src = getChar(words[tmp]._string[lastPos], &width, &height, &heightadd);
-
+
// lets draw our char
drawCharToPlane(src, color, width, height, plane, planewidth, planeheight, current_x, current_y + heightadd);
-
+
current_x += width;
heighest = MAX(heighest, height);
}
}
}
-
+
void Font::drawCharToPlane(const uint8* c, uint8 color, uint8 width, uint8 height,
uint8* plane, uint16 planewidth, uint16 planeheight, uint16 x, uint16 y) {
- const uint8* src = c;
-
+ const uint8* src = c;
+
// blit them to the screen
for (uint8 yadd = 0; yadd < height; ++yadd) {
for (uint8 xadd = 0; xadd < width; ++xadd) {
- switch(*src) {
+ switch(*src) {
case 1:
plane[(y + yadd) * planewidth + x + xadd] = color;
break;
-
+
case 2:
plane[(y + yadd) * planewidth + x + xadd] = 14;
break;
-
+
case 3:
plane[(y + yadd) * planewidth + x + xadd] = 0;
break;
-
+
default:
// nothing to do now
break;
};
-
+
++src;
}
}
}
-
+
void Font::preRenderAllChars(uint16 offsetTableOffset) {
uint16 startOffset = _offsetTable[0];
uint16 currentOffset = offsetTableOffset;
uint8 currentChar = 0;
-
+
for (; currentOffset < startOffset; ++currentChar, currentOffset += sizeof(uint16)) {
// lets prerender the char :)
-
+
PreRenderedChar newChar;
-
+
newChar.height = READ_LE_UINT16(&_charHeight[currentChar]) >> 8;
newChar.width = _charWidth[currentChar];
newChar.heightadd = READ_LE_UINT16(&_charHeight[currentChar]) & 0xFF;
newChar.c = new uint8[newChar.height * newChar.width];
assert(newChar.c);
memset(newChar.c, 0, sizeof(uint8) * newChar.height * newChar.width);
-
+
uint8* src = _buffer + READ_LE_UINT16(&_offsetTable[currentChar]);
uint8* dst = &newChar.c[0];
uint8 index = 0;
-
+
#ifdef DUMP_FILES
static char filename[32] = { 0 };
sprintf(filename, "dumps/char%d.dmp", currentChar);
FILE* dump = fopen(filename, "w+");
assert(dump);
-
+
fprintf(dump, "This should be a '%c'\n", currentChar);
#endif
-
+
// prerender the char
for (uint8 yadd = 0; yadd < newChar.height; ++yadd) {
for (uint8 xadd = 0; xadd < newChar.width; ++xadd) {
@@ -275,7 +275,7 @@
} else {
index = (*src) & 0x0F;
}
-
+
switch(index) {
case 1:
#ifdef DUMP_FILES
@@ -283,21 +283,21 @@
#endif
dst[yadd * newChar.width + xadd] = 1;
break;
-
+
case 2:
#ifdef DUMP_FILES
fprintf(dump, "$");
#endif
dst[yadd * newChar.width + xadd] = 2;
break;
-
+
case 3:
#ifdef DUMP_FILES
fprintf(dump, "§");
#endif
dst[yadd * newChar.width + xadd] = 3;
break;
-
+
default:
#ifdef DUMP_FILES
fprintf(dump, "%d", index);
@@ -305,7 +305,7 @@
break;
};
}
-
+
if (newChar.width % 2) {
++src;
}
@@ -313,7 +313,7 @@
fprintf(dump, "\n");
#endif
}
-
+
#ifdef DUMP_FILES
fprintf(dump, "\nThis is the created map:\n");
// now print the whole thing again
@@ -325,9 +325,9 @@
}
fclose(dump);
#endif
-
+
_preRenderedChars[currentChar] = newChar;
-
+
if (currentChar == 255) {
break;
}
Index: kyra.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/kyra.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- kyra.cpp 24 Jun 2005 16:01:42 -0000 1.32
+++ kyra.cpp 30 Jul 2005 21:11:01 -0000 1.33
@@ -165,7 +165,7 @@
// loads the Font
_font = _resMgr->loadFont("8FAT.FNT");
-
+
_npcScript = _resMgr->loadScript("_NPC.EMC");
// loads the scripts (only Kyrandia 1)
@@ -174,10 +174,10 @@
} else {
error("game start files not known");
}
-
+
assert(_npcScript);
assert(_currentScript);
-
+
return 0;
}
@@ -209,7 +209,7 @@
warning("init script returned: %d", _currentScript->state());
}
}*/
-
+
Movie* movie = _resMgr->loadMovie("MAL-KAL.WSA");
assert(movie);
CPSImage* image = _resMgr->loadImage("GEMCUT.CPS");
@@ -234,12 +234,12 @@
_midiDriver->playMusic("KYRA2A.XMI");
_midiDriver->playTrack(3);
}
-
+
while (true) {
OSystem::Event event;
//if (_debugger->isAttached())
// _debugger->onFrame();
-
+
memcpy(_screen, _buffer, 320 * 200);
if (lastFrameChange + movie->frameChange() < _system->getMillis()) {
lastFrameChange = _system->getMillis();
@@ -249,7 +249,7 @@
currentFrame = 0;
}
}
-
+
movie->renderFrame(_screen, 320, 200, currentFrame);
_font->drawStringToPlane("This is only a test!", _screen, 320, 200, 75, 179, 136);
_font->drawStringToPlane("Nothing scripted!", _screen, 320, 200, 85, 189, 136);
@@ -265,11 +265,11 @@
}
_system->delayMillis(10);
}
-
+
delete movie;
delete image;
delete [] _buffer;
-
+
return 0;
}
Index: kyra.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/kyra.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- kyra.h 9 Jan 2005 16:06:29 -0000 1.9
+++ kyra.h 30 Jul 2005 21:11:01 -0000 1.10
@@ -63,7 +63,7 @@
Resourcemanager* resManager(void) { return _resMgr; }
MusicPlayer* midiDriver(void) { return _midiDriver; }
-
+
uint8 game(void) { return _game; }
protected:
Index: palette.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/palette.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- palette.cpp 24 Jun 2005 16:01:42 -0000 1.8
+++ palette.cpp 30 Jul 2005 21:11:01 -0000 1.9
@@ -31,39 +31,39 @@
if (!data) {
error("resource created without data");
}
-
+
if (size != 768) {
Common::MemoryReadStream datastream(data, size);
-
+
datastream.readSint32LE();
int imageSize = datastream.readSint16LE();
-
+
if (imageSize != 768) {
error("decompresed palette is not 768 byte long!");
}
-
+
// lets uncompress this palette :)
_palette = new uint8[imageSize];
assert(_palette);
-
+
// made decompression
if (Compression::decode80(data + 10, _palette) != 768) {
error("decode80 decompressesize != 768 bytes");
}
-
+
delete [] data;
data = _palette;
}
-
+
// hmm.. common/system.h Docu is wrong or SDL Backend has a bug :)
// a palette should have this order:
// R1-G1-B1-A1-R2-G2-B2-A2-...
// so we need 4 bytes per color
_palette = new uint8[256 * 4];
-
+
uint8* currentpossrc = &data[0];
uint8* currentposdst = &_palette[0];
-
+
// creates the original pallette (only first 6 bits are used)
for (uint32 i = 0; i < 256; i++) {
currentposdst[0] = currentpossrc[0] << 2;
@@ -72,7 +72,7 @@
currentpossrc += 3;
currentposdst += 4;
}
-
+
delete [] data;
}
Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/resource.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- resource.cpp 24 Jun 2005 16:01:42 -0000 1.13
+++ resource.cpp 30 Jul 2005 21:11:01 -0000 1.14
@@ -29,9 +29,9 @@
namespace Kyra {
Resourcemanager::Resourcemanager(KyraEngine* engine) {
_engine = engine;
-
+
// prefetches all PAK Files
-
+
// ugly a hardcoded list
// TODO: use the FS Backend to get all .PAK Files and load them
// or any other thing to get all files
@@ -40,7 +40,7 @@
"S_Z.PAK", "WSA1.PAK", "WSA2.PAK", "WSA3.PAK", "WSA4.PAK", "WSA5.PAK",
"WSA6.PAK", 0
};
-
+
static const char* kyra1CDFilelist[] = {
"ADL.PAK", "BRINS.PAK", "CLIFF.PAK", "ENTER.PAK", "FORESTA.PAK", "GEM.PAK", "INTRO1.PAK",
"LEPHOLE.PAK", "OAKS.PAK", "SPELL.PAK", "WILLOW.PAK", "ALCHEMY.PAK", "BROKEN.PAK", "COL.PAK",
@@ -57,9 +57,9 @@
"NWCLIFB.PAK", "SONG.PAK", "UPSTAIR.PAK", "BRIDGE.PAK", "CHASM.PAK", "EMCAV.PAK", "FNORTH.PAK",
"GATECV.PAK", "HEALER.PAK", "LAVA.PAK", "NWCLIFF.PAK", "SORROW.PAK", "WELL.PAK", 0
};
-
+
const char** usedFilelist = 0;
-
+
if (_engine->game() == KYRA1)
usedFilelist = kyra1Filelist;
else if (_engine->game() == KYRA1CD)
@@ -70,39 +70,39 @@
for (uint32 tmp = 0; usedFilelist[tmp]; ++tmp) {
// prefetch file
PAKFile* file = new PAKFile(usedFilelist[tmp]);
- assert(file);
-
+ assert(file);
+
if (file->isOpen() && file->isValid())
_pakfiles.push_back(file);
else
debug("couldn't load file '%s' correctly", usedFilelist[tmp]);
}
}
-
+
Resourcemanager::~Resourcemanager() {
Common::List<PAKFile*>::iterator start = _pakfiles.begin();
-
+
for (;start != _pakfiles.end(); ++start) {
delete *start;
*start = 0;
}
}
-
+
uint8* Resourcemanager::fileData(const char* file, uint32* size) {
uint8* buffer = 0;
Common::File file_;
-
+
// test to open it in the main dir
if (file_.open(file)) {
-
+
*size = file_.size();
buffer = new uint8[*size];
assert(buffer);
-
+
file_.read(buffer, *size);
-
+
file_.close();
-
+
} else {
// opens the file in a PAK File
Common::List<PAKFile*>::iterator start = _pakfiles.begin();
@@ -121,16 +121,16 @@
break;
}
-
+
}
-
+
if (!buffer || !(*size)) {
return 0;
}
-
+
return buffer;
}
-
+
Palette* Resourcemanager::loadPalette(const char* file) {
uint32 size = 0;
uint8* buffer = 0;
@@ -141,7 +141,7 @@
}
return new Palette(buffer, size);
}
-
+
CPSImage* Resourcemanager::loadImage(const char* file) {
uint32 size = 0;
uint8* buffer = 0;
@@ -150,7 +150,7 @@
return 0;
return new CPSImage(buffer, size);
}
-
+
Font* Resourcemanager::loadFont(const char* file) {
uint32 size = 0;
uint8* buffer = 0;
@@ -159,7 +159,7 @@
return 0;
return new Font(buffer, size);
}
-
+
Movie* Resourcemanager::loadMovie(const char* file) {
// TODO: we have to check the Extenion to create the right movie
uint32 size = 0;
@@ -178,7 +178,7 @@
context->loadScript(file);
return context;
}
-
+
///////////////////////////////////////////
// Pak file manager
#define PAKFile_Iterate Common::List<PakChunk*>::iterator start=_files.begin();start != _files.end(); ++start
@@ -186,7 +186,7 @@
Common::File pakfile;
_buffer = 0;
_open = false;
-
+
if (!pakfile.open(file.c_str())){ /*, Common::File::kFileReadMode, path.c_str())) {*/
printf("pakfile couldn't open %s\n", file.c_str());
return;
@@ -217,7 +217,7 @@
endoffset = READ_LE_UINT32(_buffer + pos);
pos += 4;
-
+
if (endoffset == 0) {
endoffset = filesize;
}
@@ -226,7 +226,7 @@
chunk->_size = endoffset - startoffset;
_files.push_back(chunk);
-
+
if (endoffset == filesize)
break;
@@ -260,7 +260,7 @@
if (!scumm_stricmp((*start)->_name, file))
return (*start)->_size;
}
-
+
return 0;
}
} // end of namespace Kyra
Index: resource.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/resource.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- resource.h 24 Jun 2005 16:01:42 -0000 1.9
+++ resource.h 30 Jul 2005 21:11:01 -0000 1.10
@@ -90,7 +90,7 @@
class Palette {
public:
-
+
Palette(uint8* data, uint32 size);
~Palette() { delete [] _palette; }
@@ -121,7 +121,7 @@
// only for testing :)
uint8 getColor(uint16 x, uint16 y) { return _image[y * _width + x]; }
-
+
uint8& operator[](uint16 index) { if (index > _width * _height) return _image[0]; return _image[index]; }
protected:
Index: script.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/script.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- script.cpp 24 Jun 2005 16:01:42 -0000 1.14
+++ script.cpp 30 Jul 2005 21:11:01 -0000 1.15
@@ -34,7 +34,7 @@
VMContext::VMContext(KyraEngine* engine) {
_engine = engine;
_error = false;
-
+
// now we create a list of all Command/Opcode procs and so
static CommandEntry commandProcs[] = {
// 0x00
@@ -43,7 +43,7 @@
COMMAND(c1_pushRetRec),
COMMAND(c1_push),
// 0x04
- COMMAND(c1_push),
+ COMMAND(c1_push),
COMMAND(c1_pushVar),
COMMAND(c1_pushFrameNeg),
COMMAND(c1_pushFramePos),
@@ -63,7 +63,7 @@
};
_numCommands = ARRAYSIZE(commandProcs);
_commands = commandProcs;
-
+
static OpcodeEntry opcodeProcs[] = {
// 0x00
OPCODE(o1_unknownOpcode),
@@ -392,40 +392,40 @@
_scriptFile = NULL;
_scriptFileSize = 0;
}
-
+
void VMContext::loadScript(const char* file) {
if (_scriptFile) {
delete [] _scriptFile;
_scriptFileSize = 0;
}
-
+
memset(_stack, 0, sizeof(int32) * ARRAYSIZE(_stack));
// loads the new file
_scriptFile = _engine->resManager()->fileData(file, &_scriptFileSize);
-
+
if (!_scriptFileSize || !_scriptFile) {
error("couldn't load script file '%s'", file);
}
-
+
Common::MemoryReadStream script(_scriptFile, _scriptFileSize);
memset(_chunks, 0, sizeof(ScriptChunk) * kCountChunkTypes);
uint8 chunkName[sizeof("EMC2ORDR") + 1];
-
+
// so lets look for our chunks :)
while (!script.eos()) {
// lets read only the first 4 chars
script.read(chunkName, sizeof(uint8) * 4);
chunkName[4] = '\0';
-
+
// check name of chunk
- if (!scumm_stricmp((const char *)chunkName, "FORM")) {
+ if (!scumm_stricmp((const char *)chunkName, "FORM")) {
// FreeKyra swaps the size I only read it in BigEndian :)
_chunks[kForm]._size = script.readUint32BE();
} else if (!scumm_stricmp((const char *)chunkName, "TEXT")) {
uint32 text_size = script.readUint32BE();
text_size += text_size % 2 != 0 ? 1 : 0;
-
+
_chunks[kText]._data = _scriptFile + script.pos();
_chunks[kText]._size = READ_BE_UINT16(_chunks[kText]._data) >> 1;
_chunks[kText]._additional = _chunks[kText]._data + (_chunks[kText]._size << 1);
@@ -439,7 +439,7 @@
// read next 4 chars
script.read(&chunkName[4], sizeof(uint8) * 4);
chunkName[8] = '\0';
-
+
if (!scumm_stricmp((const char *)chunkName, "EMC2ORDR")) {
_chunks[kEmc2Ordr]._size = script.readUint32BE() >> 1;
_chunks[kEmc2Ordr]._data = _scriptFile + script.pos();
@@ -451,35 +451,35 @@
}
}
}
-
+
int32 VMContext::param(int32 index) {
if (_stackPos - index - 1 >= ARRAYSIZE(_stack) || _stackPos - index - 1 < 0)
return -0xFFFF;
return _stack[_stackPos - index - 1];
}
-
+
const char* VMContext::stringAtIndex(int32 index) {
if (index < 0 || (uint32)index >= _chunks[kText]._size)
return 0;
-
+
return (const char *)(_chunks[kText]._additional + _chunks[kText]._data[index]);
}
-
+
bool VMContext::startScript(int32 func) {
if ((uint32)func >= _chunks[kEmc2Ordr]._size || func < 0) {
debug("script doesn't support function %d", func);
return false;
}
-
+
_instructionPos = READ_BE_UINT16(&_chunks[kEmc2Ordr]._data[func]) << 1;
_stackPos = 0;
_tempPos = 0;
_delay = 0;
_error = false;
_scriptState = kScriptRunning;
-
+
uint32 pos = 0xFFFFFFFE;
-
+
// get start of next script
for (uint32 tmp = 0; tmp < _chunks[kEmc2Ordr]._size; ++tmp) {
if ((uint32)((READ_BE_UINT16(&_chunks[kEmc2Ordr]._data[tmp]) << 1)) > (uint32)_instructionPos &&
@@ -487,22 +487,22 @@
pos = ((READ_BE_UINT16(&_chunks[kEmc2Ordr]._data[tmp]) << 1));
}
}
-
+
if (pos > _scriptFileSize) {
pos = _scriptFileSize;
}
-
+
_nextScriptPos = pos;
return true;
}
-
+
uint32 VMContext::contScript(void) {
uint8* script_start = _chunks[kData]._data;
assert(script_start);
-
+
uint32 scriptStateAtStart = _scriptState;
-
+
// runs the script
while (true) {
if ((uint32)_instructionPos > _chunks[kData]._size) {
@@ -513,10 +513,10 @@
_scriptState = kScriptStopped;
break;
}
-
+
_currentCommand = *(script_start + _instructionPos++);
-
- // gets out
+
+ // gets out
if (_currentCommand & 0x80) {
_argument = ((_currentCommand & 0x0F) << 8) | *(script_start + _instructionPos++);
_currentCommand &= 0xF0;
@@ -524,10 +524,10 @@
_argument = *(script_start + _instructionPos++);
} else if (_currentCommand & 0x20) {
_instructionPos++;
-
+
uint16 tmp = *(uint16*)(script_start + _instructionPos);
tmp &= 0xFF7F;
-
+
_argument = READ_BE_UINT16(&tmp);
_instructionPos += 2;
} else {
@@ -535,21 +535,21 @@
// next thing
continue;
}
-
+
_currentCommand &= 0x1f;
-
+
if (_currentCommand < _numCommands) {
CommandProc currentProc = _commands[_currentCommand].proc;
(this->*currentProc)();
} else {
c1_unknownCommand();
}
-
+
if (_error) {
_scriptState = kScriptError;
break;
}
-
+
if (scriptStateAtStart != _scriptState) {
break;
}
Index: script.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/script.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- script.h 9 Jan 2005 16:06:29 -0000 1.6
+++ script.h 30 Jul 2005 21:11:02 -0000 1.7
@@ -40,26 +40,26 @@
kScriptWaiting = 2,
kScriptError = 3
};
-
-
+
+
class VMContext {
public:
VMContext(KyraEngine* engine);
~VMContext() { delete [] _scriptFile; }
-
+
void loadScript(const char* file);
-
+
const char* stringAtIndex(int32 index);
-
+
// TODO: check for 'over'flow
- void pushStack(int32 value) { _stack[_stackPos++] = value; }
+ void pushStack(int32 value) { _stack[_stackPos++] = value; }
void registerValue(int32 reg, int32 value) { _registers[reg] = value; }
int32 checkReg(int32 reg) { return _registers[reg]; }
-
+
uint32 state(void) { return _scriptState; }
-
+
bool startScript(int32 func);
uint32 contScript(void);
@@ -67,34 +67,34 @@
KyraEngine* _engine;
uint8* _scriptFile;
uint32 _scriptFileSize;
-
+
uint32 _scriptState;
uint32 _delay;
-
+
int32 _registers[32]; // registers of the interpreter
int32 _stack[64]; // our stack
-
+
// TODO: check for 'under'flow
int32 popStack(void) { return _stack[--_stackPos]; }
int32& topStack(void) { return _stack[_stackPos]; }
-
+
uint32 _returnValue;
-
+
int32 _nextScriptPos;
int32 _instructionPos;
int32 _stackPos;
int32 _tempPos;
-
+
// used by command & opcode procs
uint16 _argument;
uint8 _currentCommand;
uint32 _currentOpcode;
-
+
int32 param(int32 index);
const char* paramString(int32 index) { return stringAtIndex(param(index)); }
-
+
bool _error; // used by all command- and opcodefuncs
-
+
enum ScriptChunkTypes {
kForm = 0,
kEmc2Ordr = 1,
@@ -102,13 +102,13 @@
kData = 3,
kCountChunkTypes
};
-
+
struct ScriptChunk {
uint32 _size;
uint8* _data; // by TEXT used for count of texts, by EMC2ODRD it is used for a count of somewhat
uint8* _additional; // currently only used for TEXT
};
-
+
ScriptChunk _chunks[kCountChunkTypes];
typedef void (VMContext::*CommandProc)();
@@ -116,18 +116,18 @@
CommandProc proc;
const char* desc;
};
-
+
typedef void (VMContext::*OpcodeProc)();
struct OpcodeEntry {
OpcodeProc proc;
const char* desc;
};
-
+
uint16 _numCommands;
const CommandEntry* _commands;
uint16 _numOpcodes;
const OpcodeEntry* _opcodes;
-
+
protected:
// the command procs
void c1_goToLine(void); // 0x00
@@ -148,7 +148,7 @@
void c1_negate(void); // 0x10
void c1_evaluate(void); // 0x11
void c1_unknownCommand(void);
-
+
// the opcode procs
void o1_0x68(void); // 0x68
void o1_unknownOpcode(void);
Index: script_v1.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/script_v1.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- script_v1.cpp 24 Jun 2005 16:01:42 -0000 1.10
+++ script_v1.cpp 30 Jul 2005 21:11:02 -0000 1.11
@@ -30,7 +30,7 @@
void VMContext::c1_unknownCommand(void) {
debug("unknown command '0x%x'.", _currentCommand);
debug("\targument: '0x%x'", _argument);
-
+
_error = true;
}
@@ -76,7 +76,7 @@
_scriptState = kScriptStopped;
}
int32 rec = popStack();
-
+
_tempPos = (int16)((rec & 0xFFFF0000) >> 16);
_instructionPos = (rec & 0x0000FFFF) * 2;
}
@@ -122,15 +122,15 @@
case 0:
topStack() = !topStack();
break;
-
+
case 1:
topStack() = -topStack();
break;
-
+
case 2:
topStack() = ~topStack();
break;
-
+
default:
debug("unkown negate instruction %d", _argument);
_error = true;
@@ -141,98 +141,98 @@
void VMContext::c1_evaluate(void) {
int32 x, y;
int32 res = false;
-
+
x = popStack();
y = popStack();
-
+
switch(_argument) {
case 0:
res = x && y;
break;
-
+
case 1:
res = x || y;
break;
-
+
case 3:
res = x != y;
break;
-
+
case 4:
res = x < y;
break;
-
+
case 5:
res = x <= y;
break;
-
+
case 6:
res = x > y;
break;
-
+
case 7:
res = x >= y;
break;
-
+
case 8:
res = x + y;
break;
-
+
case 9:
res = x - y;
break;
-
+
case 10:
res = x * y;
break;
-
+
case 11:
res = x / y;
break;
-
+
case 12:
res = x >> y;
break;
-
+
case 13:
res = x << y;
break;
-
+
case 14:
res = x & y;
break;
-
+
case 15:
res = x | y;
break;
-
+
case 16:
res = x % y;
break;
-
+
case 17:
res = x ^ y;
break;
-
+
default:
debug("unknown evaluate command");
break;
};
-
+
pushStack(res);
}
// opcode procs
void VMContext::o1_unknownOpcode(void) {
_error = true;
-
+
debug("unknown opcode '0x%x'.", _argument);
debug("parameters:\n"
"Param0: %d\nParam1: %d\nParam2: %d\nParam3: %d\nParam4: %d\nParam5: %d\n"
"Param0 as a string: %s\nParam1 as a string: %s\nParam2 as a string: %s\n"
"Param3 as a string: %s\nParam4 as a string: %s\nParam5 as a string: %s\n",
param(0), param(1), param(2), param(3), param(5), param(5),
- paramString(0), paramString(1), paramString(2), paramString(3),
+ paramString(0), paramString(1), paramString(2), paramString(3),
paramString(4), paramString(5));
}
Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/sound.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- sound.cpp 24 Jun 2005 16:01:42 -0000 1.5
+++ sound.cpp 30 Jul 2005 21:11:02 -0000 1.6
@@ -28,22 +28,22 @@
_driver = driver;
_passThrough = false;
_isPlaying = _nativeMT32 = false;
-
+
memset(_channel, 0, sizeof(MidiChannel*) * 16);
memset(_channelVolume, 255, sizeof(uint8) * 16);
_volume = 0;
-
+
int ret = open();
if (ret != MERR_ALREADY_OPEN && ret != 0) {
error("couldn't open midi driver");
}
}
-
+
MusicPlayer::~MusicPlayer() {
_driver->setTimerCallback(NULL, NULL);
close();
}
-
+
void MusicPlayer::setVolume(int volume) {
if (volume < 0)
volume = 0;
@@ -61,7 +61,7 @@
}
}
}
-
+
int MusicPlayer::open() {
// Don't ever call open without first setting the output driver!
if (!_driver)
@@ -80,7 +80,7 @@
_driver->close();
_driver = 0;
}
-
+
void MusicPlayer::send(uint32 b) {
if (_passThrough) {
_driver->send(b);
@@ -120,28 +120,28 @@
break;
}
}
-
+
void MusicPlayer::playMusic(const char* file) {
uint32 size;
uint8* data = 0;
-
+
data = (_engine->resManager())->fileData(file, &size);
-
+
if (!data) {
warning("couldn't load '%s'", file);
return;
}
-
+
playMusic(data, size);
}
-
+
void MusicPlayer::playMusic(uint8* data, uint32 size) {
if (_isPlaying)
stopMusic();
-
+
_parser = MidiParser::createParser_XMIDI();
assert(_parser);
-
+
if (!_parser->loadMusic(data, size)) {
warning("Error reading track!");
delete _parser;
@@ -164,13 +164,13 @@
_parser = NULL;
}
}
-
+
void MusicPlayer::onTimer(void *refCon) {
MusicPlayer *music = (MusicPlayer *)refCon;
if (music->_isPlaying)
music->_parser->onTimer();
}
-
+
void MusicPlayer::playTrack(uint8 track) {
if (_parser) {
_isPlaying = true;
Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/sound.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- sound.h 24 Jun 2005 16:01:42 -0000 1.4
+++ sound.h 30 Jul 2005 21:11:02 -0000 1.5
@@ -30,21 +30,21 @@
namespace Kyra {
class MusicPlayer : public MidiDriver {
-
+
public:
-
+
MusicPlayer(MidiDriver* driver, KyraEngine* engine);
~MusicPlayer();
-
+
void setVolume(int volume);
int getVolume() { return _volume; }
-
+
void hasNativeMT32(bool nativeMT32) { _nativeMT32 = nativeMT32; }
void playMusic(const char* file);
void playMusic(uint8* data, uint32 size);
void stopMusic();
-
+
void playTrack(uint8 track);
void setPassThrough(bool b) { _passThrough = b; }
@@ -60,11 +60,11 @@
//Channel allocation functions
MidiChannel *allocateChannel() { return 0; }
MidiChannel *getPercussionChannel() { return 0; }
-
+
protected:
-
+
static void onTimer(void *data);
-
+
MidiChannel* _channel[16];
uint8 _channelVolume[16];
MidiDriver* _driver;
Index: wsamovie.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/wsamovie.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- wsamovie.cpp 24 Jun 2005 16:01:42 -0000 1.9
+++ wsamovie.cpp 30 Jul 2005 21:11:02 -0000 1.10
@@ -41,10 +41,10 @@
_offsetTable = 0;
_prefetchedFrame = 0xFFFE;
_buffer = data;
-
+
// I like these Streams .... =)
Common::MemoryReadStream datastream(data, size);
-
+
_wsaHeader._numFrames = datastream.readUint16LE();
_wsaHeader._width = datastream.readUint16LE();
_wsaHeader._height = datastream.readUint16LE();
@@ -52,11 +52,11 @@
_wsaHeader._yPos = datastream.readByte();
_wsaHeader._delta = datastream.readUint16LE();
_wsaHeader._type = datastream.readUint16LE();
-
+
#ifdef DUMP_FILES
// TODO: make Linux/BSD conform
FILE* wsaheader = fopen("dumps/wsaheader.txt", "w+");
-
+
if (wsaheader) {
for (uint32 pos = 0; pos < sizeof(_wsaHeader); ++pos)
fprintf(wsaheader, "%d pos. byte: %d\n", pos + 1, ((uint8*)&_wsaHeader)[pos]);
@@ -74,11 +74,11 @@
uint16 tmp = _wsaHeader._delta;
_wsaHeader._delta = _wsaHeader._type;
_wsaHeader._type = tmp;
-
+
// skip 2 bytes
datastream.readUint16LE();
}
-
+
debug("_wsaHeader._numFrames = %d", _wsaHeader._numFrames);
debug("_wsaHeader._width = %d", _wsaHeader._width);
debug("_wsaHeader._height = %d", _wsaHeader._height);
@@ -86,40 +86,40 @@
debug("_wsaHeader._yPos = %d", _wsaHeader._yPos);
debug("_wsaHeader._delta = %d", _wsaHeader._delta);
debug("_wsaHeader._type = %d", _wsaHeader._type);
-
+
// check for version
if (_wsaHeader._type) {
error("loading a WSA version 2 with the WSA version 1 loader");
}
-
+
uint16 offsetAdd = 0;
-
+
// checks now for own palette
if (_wsaHeader._type % 2) {
// don't now if this will work right, because a few lines before we use
// _wsaHeader._type for detect the version of the WSA movie,
// but this code was from FreeKyra Tools so I think it will work
-
+
// if this is a packed palette we have a problem :)
offsetAdd = 768 /* 0x300 */;
}
-
+
// last frame seems every time to be a empty one
_frameCount = _wsaHeader._numFrames - 1;
_offsetTable = new uint32[_wsaHeader._numFrames + 2];
assert(_offsetTable);
-
+
// loads the offset table
for (uint32 tmp = 0; tmp < (uint32)_wsaHeader._numFrames + 2; ++tmp) {
_offsetTable[tmp] = datastream.readUint32LE() + offsetAdd;
}
-
+
if (offsetAdd) {
uint8* palbuffer = new uint8[offsetAdd];
assert(palbuffer);
-
+
datastream.read(palbuffer, offsetAdd);
-
+
_ownPalette = new Palette(palbuffer, offsetAdd);
assert(_ownPalette);
}
@@ -128,18 +128,18 @@
// LordHoto: What is the 'default' value? 0?
_transparency = -1;
}
-
+
WSAMovieV1::~WSAMovieV1() {
delete [] _buffer;
delete [] _offsetTable;
delete [] _currentFrame;
delete _ownPalette;
}
-
+
const uint8* WSAMovieV1::loadFrame(uint16 frame, uint16* width, uint16* height) {
if (width) *width = _wsaHeader._width;
if (height) *height = _wsaHeader._height;
-
+
if (frame == _prefetchedFrame) {
return _currentFrame;
} else {
@@ -148,14 +148,14 @@
assert(_currentFrame);
memset(_currentFrame, 0, sizeof(uint8) * _wsaHeader._width * _wsaHeader._height);
}
-
+
if (frame >= _wsaHeader._numFrames)
return 0;
-
+
uint8* frameData = 0;
static uint8 image40[64000]; // I think this will crash on Plam OS :)
memset(image40, 0, ARRAYSIZE(image40));
-
+
if (frame == _prefetchedFrame + 1) {
frameData = _buffer + _offsetTable[frame];
Compression::decode80(frameData, image40);
@@ -166,7 +166,7 @@
} else {
memset(_currentFrame, 0, sizeof(uint8) * _wsaHeader._width * _wsaHeader._height);
}
-
+
for (uint32 i = 0; i <= frame; ++i)
{
frameData = _buffer + _offsetTable[i];
@@ -174,14 +174,14 @@
Compression::decode40(image40, _currentFrame);
}
}
-
+
_prefetchedFrame = frame;
return _currentFrame;
}
-
+
return 0;
}
-
+
void WSAMovieV1::renderFrame(uint8* plane, uint16 planepitch, uint16 planeheight, uint16 frame) {
if (!loadFrame(frame, 0, 0))
return;
@@ -189,10 +189,10 @@
uint8* src = _currentFrame;
uint8* dst = &plane[_wsaHeader._yPos * planepitch + _wsaHeader._xPos];
uint32 copysize = planepitch - _wsaHeader._xPos;
-
+
if (copysize > _wsaHeader._width)
copysize = _wsaHeader._width;
-
+
if (_transparency == -1) {
for (uint16 y_ = 0; y_ < _wsaHeader._height && _wsaHeader._yPos + y_ < planeheight; ++y_) {
memcpy(dst, src, copysize * sizeof(uint8));
@@ -209,16 +209,16 @@
*dst++ = *src++;
}
}
-
+
src += _wsaHeader._width - copysize;
dst += planepitch - copysize;
}
}
}
-
+
void WSAMovieV1::setImageBackground(uint8* plane, uint16 planepitch, uint16 height) {
assert(plane);
-
+
_background = plane;
_backWidth = planepitch; _backHeight = height;
@@ -226,38 +226,38 @@
_currentFrame = new uint8[_wsaHeader._width * _wsaHeader._height];
assert(_currentFrame);
}
-
+
memset(_currentFrame, 0, sizeof(uint8) * _wsaHeader._width * _wsaHeader._height);
-
+
uint8* src = &plane[_wsaHeader._yPos * planepitch + _wsaHeader._xPos];
uint8* dst = _currentFrame;
uint32 copysize = planepitch - _wsaHeader._xPos;
-
+
if (copysize > _wsaHeader._width)
copysize = _wsaHeader._width;
-
+
// now copy the rect of the plane
for (uint16 y_ = 0; y_ < _wsaHeader._height && _wsaHeader._yPos + y_ < height; ++y_) {
memcpy(dst, src, copysize * sizeof(uint8));
dst += _wsaHeader._width;
src += planepitch;
}
-
+
for (uint16 y_ = 0; y_ < _wsaHeader._height && _wsaHeader._yPos + y_ < height; ++y_) {
for (uint16 x = 0; x < _wsaHeader._width; ++x) {
_currentFrame[y_ * _wsaHeader._width + x] ^= 0;
}
}
-
+
_prefetchedFrame = 0xFFFE;
}
-
+
// Kyrandia 2+ Movies
WSAMovieV2::WSAMovieV2(uint8* data, uint32 size) {
if (!data) {
error("resource created without data");
}
-
+
_background = 0;
_currentFrame = 0;
_ownPalette = 0;
@@ -265,55 +265,55 @@
_prefetchedFrame = 0xFFFE;
_looping = false;
_buffer = data;
-
+
// I like these Streams .... =)
Common::MemoryReadStream datastream(data, size);
-
+
datastream.read(&_wsaHeader, sizeof(_wsaHeader));
-
+
// check for version
if (!_wsaHeader._type) {
error("loading a WSA version 1 with the WSA version 2 loader");
}
-
+
uint16 offsetAdd = 0;
-
+
// checks now for own palette
if (_wsaHeader._type % 2) {
// don't now if this will work right, because a few lines before we use
// _wsaHeader._type for detect the version of the WSA movie,
// but this code was from FreeKyra Tools so I think it will work
-
+
// if this is a packed palette we have a problem :)
offsetAdd = 768 /* 0x300 */;
}
-
+
_offsetTable = new uint32[_wsaHeader._numFrames + 2];
assert(_offsetTable);
-
+
// loads the offset table
for (uint32 tmp = 0; tmp < (uint32)_wsaHeader._numFrames + 2; ++tmp) {
_offsetTable[tmp] = datastream.readUint32LE() + offsetAdd;
}
-
+
if (offsetAdd) {
uint8* palbuffer = new uint8[offsetAdd];
assert(palbuffer);
-
+
datastream.read(palbuffer, offsetAdd);
-
+
_ownPalette = new Palette(palbuffer, offsetAdd);
assert(_ownPalette);
}
-
+
if (_offsetTable[_wsaHeader._numFrames + 1] - offsetAdd) {
++_wsaHeader._numFrames;
_looping = true;
}
-
+
_frameCount = _wsaHeader._numFrames;
}
-
+
WSAMovieV2::~WSAMovieV2() {
delete [] _buffer;
delete [] _offsetTable;
@@ -324,7 +324,7 @@
const uint8* WSAMovieV2::loadFrame(uint16 frame, uint16* width, uint16* height) {
if (width) *width = _wsaHeader._width;
if (height) *height = _wsaHeader._height;
-
+
if (frame == _prefetchedFrame) {
return _currentFrame;
} else {
@@ -333,14 +333,14 @@
assert(_currentFrame);
memset(_currentFrame, 0, sizeof(uint8) * _wsaHeader._width * _wsaHeader._height);
}
-
+
if (frame >= _wsaHeader._numFrames)
return 0;
-
+
uint8* frameData = 0;
static uint8 image40[64000]; // I think this will crash on Plam OS :)
memset(image40, 0, ARRAYSIZE(image40));
-
+
if (frame == _prefetchedFrame + 1) {
frameData = _buffer + _offsetTable[frame];
Compression::decode80(frameData, image40);
@@ -351,7 +351,7 @@
} else {
memset(_currentFrame, 0, sizeof(uint8) * _wsaHeader._width * _wsaHeader._height);
}
-
+
for (uint32 i = 0; i <= frame; ++i)
{
frameData = _buffer + _offsetTable[i];
@@ -359,25 +359,25 @@
Compression::decode40(image40, _currentFrame);
}
}
-
+
_prefetchedFrame = frame;
return _currentFrame;
}
-
+
return 0;
}
-
+
void WSAMovieV2::renderFrame(uint8* plane, uint16 planepitch, uint16 planeheight, uint16 frame) {
if (!loadFrame(frame, 0, 0))
return;
-
+
uint8* src = _currentFrame;
uint8* dst = &plane[_wsaHeader._yPos * planepitch + _wsaHeader._xPos];
uint32 copysize = planepitch - _wsaHeader._xPos;
-
+
if (copysize > _wsaHeader._width)
copysize = _wsaHeader._width;
-
+
if (_transparency == -1) {
for (uint16 y_ = 0; y_ < _wsaHeader._height && _wsaHeader._yPos + y_ < planeheight; ++y_) {
memcpy(dst, src, copysize * sizeof(uint8));
@@ -394,46 +394,46 @@
*dst++ = *src++;
}
}
-
+
src += _wsaHeader._width - copysize;
dst += planepitch - copysize;
}
}
}
-
+
void WSAMovieV2::setImageBackground(uint8* plane, uint16 planepitch, uint16 height) {
assert(plane);
-
+
_background = plane;
_backWidth = planepitch; _backHeight = height;
-
+
if (!_currentFrame) {
_currentFrame = new uint8[_wsaHeader._width * _wsaHeader._height];
assert(_currentFrame);
}
-
+
memset(_currentFrame, 0, sizeof(uint8) * _wsaHeader._width * _wsaHeader._height);
-
+
uint8* src = &plane[_wsaHeader._yPos * planepitch + _wsaHeader._xPos];
uint8* dst = _currentFrame;
uint32 copysize = planepitch - _wsaHeader._xPos;
-
+
if (copysize > _wsaHeader._width)
copysize = _wsaHeader._width;
-
+
// now copy the rect of the plane
for (uint16 y_ = 0; y_ < _wsaHeader._height && _wsaHeader._yPos + y_ < height; ++y_) {
memcpy(dst, src, copysize * sizeof(uint8));
dst += _wsaHeader._width;
src += planepitch;
}
-
+
for (uint16 y_ = 0; y_ < _wsaHeader._height && _wsaHeader._yPos + y_ < height; ++y_) {
for (uint16 x = 0; x < _wsaHeader._width; ++x) {
_currentFrame[y_ * _wsaHeader._width + x] ^= 0;
}
}
-
+
_prefetchedFrame = 0xFFFE;
}
} // end of namespace Kyra
Index: wsamovie.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/wsamovie.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- wsamovie.h 24 Jun 2005 16:01:42 -0000 1.6
+++ wsamovie.h 30 Jul 2005 21:11:02 -0000 1.7
@@ -28,26 +28,26 @@
// a generic movie
class Movie {
-
+
public:
-
+
virtual ~Movie() { _transparency = -1; _ownPalette = 0; _frameCount = 0; }
-
+
virtual void renderFrame(uint8* plane, uint16 planepitch, uint16 planeheight, uint16 frame) = 0;
virtual const uint8* loadFrame(uint16 frame, uint16* width = 0, uint16* height = 0) = 0;
virtual uint16 countFrames(void) { return _frameCount; }
-
+
// could be deleted(not imdiantly maybe it's needed sometime)
virtual void transparency(int16 color) { _transparency = color; }
virtual void position(uint16 x, uint16 y) = 0;
-
+
virtual bool hasPalette(void) { return (_ownPalette != 0); }
virtual Palette* palette(void) { return _ownPalette; }
-
+
virtual bool looping(void) { return false; }
- virtual uint32 frameChange(void) { return 100; }
+ virtual uint32 frameChange(void) { return 100; }
virtual void setImageBackground(uint8* plane, uint16 planepitch, uint16 height) {};
-
+
protected:
int16 _transparency;
uint16 _frameCount;
@@ -56,22 +56,22 @@
// movie format for Kyrandia 1
class WSAMovieV1 : public Movie {
-
+
public:
-
+
WSAMovieV1(uint8* data, uint32 size, uint8 gameid);
~WSAMovieV1();
-
+
void renderFrame(uint8* plane, uint16 planepitch, uint16 planeheight, uint16 frame);
const uint8* loadFrame(uint16 frame, uint16* width, uint16* height);
void setImageBackground(uint8* plane, uint16 planepitch, uint16 height);
-
+
void position(uint16 x, uint16 y) { _wsaHeader._xPos = x; _wsaHeader._yPos = y; }
protected:
-
+
uint8* _buffer;
-
-#pragma START_PACK_STRUCTS
+
+#pragma START_PACK_STRUCTS
struct WSAHeader {
uint16 _numFrames; // All right
uint16 _width; // All right
@@ -84,31 +84,31 @@
#pragma END_PACK_STRUCTS
uint32* _offsetTable;
-
+
uint8* _currentFrame;
uint16 _prefetchedFrame;
-
+
uint8* _background; // only a pointer to the screen
uint16 _backWidth, _backHeight;
};
-
+
// movie format for Kyrandia 2+
class WSAMovieV2 : public Movie {
-
+
public:
WSAMovieV2(uint8* data, uint32 size);
~WSAMovieV2();
-
+
void renderFrame(uint8* plane, uint16 planepitch, uint16 planeheight, uint16 frame);
const uint8* loadFrame(uint16 frame, uint16* width, uint16* height);
void setImageBackground(uint8* plane, uint16 planepitch, uint16 height);
-
+
void position(uint16 x, uint16 y) { _wsaHeader._xPos = x; _wsaHeader._yPos = y; }
bool looping(void) { return _looping; }
protected:
-
+
uint8* _buffer;
-
+
struct WSAHeader {
uint16 _numFrames; // All right
uint16 _width; // should be right
@@ -118,15 +118,15 @@
uint16 _delta; // could be wrong
uint16 _type; // should be right
} GCC_PACK _wsaHeader;
-
+
uint32* _offsetTable;
-
+
uint8* _currentFrame;
uint16 _prefetchedFrame;
-
+
uint8* _background; // only a pointer to the screen
uint16 _backWidth, _backHeight;
-
+
bool _looping;
};
} // end of namespace Kyra
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/common array.h,1.5,1.6 config-file.cpp,1.26,1.27 config-file.h,1.13,1.14 config-manager.cpp,1.37,1.38 config-manager.h,1.24,1.25 debugger.h,1.8,1.9 endian.h,1.1,1.2 file.h,1.37,1.38 list.h,1.27,1.28 map.h,1.25,1.26 md5.cpp,1.9,1.10 mutex.cpp,1.3,1.4 rect.h,1.26,1.27 savefile.cpp,1.27,1.28 savefile.h,1.21,1.22 scaler.cpp,1.70,1.71 scummsys.h,1.64,1.65 singleton.h,1.15,1.16 stack.h,1.5,1.6 str.cpp,1.36,1.37 str.h,1.27,1.28 stream.cpp,1.9,1.10 stream.h,1.21,1.22 system.h,1.103,1.104 timer.cpp,1.35,1.36 util.cpp,1.57,1.58 util.h,1.53,1.54
- Next message: [Scummvm-cvs-logs] CVS: scummvm/gui Actions.cpp,1.1,1.2 Actions.h,1.1,1.2 EditTextWidget.cpp,1.35,1.36 EditTextWidget.h,1.20,1.21 KeysDialog.cpp,1.1,1.2 ListWidget.cpp,1.55,1.56 ListWidget.h,1.33,1.34 PopUpWidget.cpp,1.38,1.39 PopUpWidget.h,1.15,1.16 ScrollBarWidget.h,1.10,1.11 TabWidget.cpp,1.18,1.19 about.cpp,1.38,1.39 about.h,1.15,1.16 browser.cpp,1.34,1.35 chooser.cpp,1.18,1.19 console.h,1.33,1.34 dialog.h,1.40,1.41 editable.cpp,1.8,1.9 editable.h,1.5,1.6 launcher.cpp,1.126,1.127 launcher.h,1.23,1.24 message.cpp,1.29,1.30 newgui.cpp,1.118,1.119 newgui.h,1.61,1.62 options.cpp,1.92,1.93 widget.cpp,1.53,1.54 widget.h,1.46,1.47
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list