[Scummvm-cvs-logs] SF.net SVN: scummvm: [31675] scummvm/trunk/engines/made
john_doe at users.sourceforge.net
john_doe at users.sourceforge.net
Wed Apr 23 22:12:07 CEST 2008
Revision: 31675
http://scummvm.svn.sourceforge.net/scummvm/?rev=31675&view=rev
Author: john_doe
Date: 2008-04-23 13:12:06 -0700 (Wed, 23 Apr 2008)
Log Message:
-----------
Fixed palette issues when showing the inventory and the menu.
Moved drawing code from drawFlex/drawAnimFrame to drawSurface.
Implemented opcodes:
- o1_VISUALFX
- o1_SCREENLOCK
- o1_SETTIMER
- o1_SETGROUND
- o1_SETCLIP
- o1_SETEXCLUDE
Modified Paths:
--------------
scummvm/trunk/engines/made/resource.cpp
scummvm/trunk/engines/made/resource.h
scummvm/trunk/engines/made/screen.cpp
scummvm/trunk/engines/made/screen.h
scummvm/trunk/engines/made/script.cpp
scummvm/trunk/engines/made/scriptfuncs.cpp
Modified: scummvm/trunk/engines/made/resource.cpp
===================================================================
--- scummvm/trunk/engines/made/resource.cpp 2008-04-23 19:36:21 UTC (rev 31674)
+++ scummvm/trunk/engines/made/resource.cpp 2008-04-23 20:12:06 UTC (rev 31675)
@@ -69,12 +69,14 @@
/*uint16 u = */sourceS->readUint16LE();
uint16 width = sourceS->readUint16LE();
uint16 height = sourceS->readUint16LE();
+
+ _paletteColorCount = (cmdOffs - 18) / 3; // 18 = sizeof header
debug(2, "width = %d; height = %d\n", width, height);
if (_hasPalette) {
- _picturePalette = new byte[768];
- sourceS->read(_picturePalette, 768);
+ _picturePalette = new byte[_paletteColorCount * 3];
+ sourceS->read(_picturePalette, _paletteColorCount * 3);
}
_picture = new Graphics::Surface();
@@ -196,6 +198,13 @@
delete sourceS;
}
+const char *MenuResource::getString(int index) const {
+ if (index < _strings.size())
+ return _strings[index].c_str();
+ else
+ return NULL;
+}
+
/* ProjectReader */
ProjectReader::ProjectReader() {
Modified: scummvm/trunk/engines/made/resource.h
===================================================================
--- scummvm/trunk/engines/made/resource.h 2008-04-23 19:36:21 UTC (rev 31674)
+++ scummvm/trunk/engines/made/resource.h 2008-04-23 20:12:06 UTC (rev 31675)
@@ -64,9 +64,11 @@
Graphics::Surface *getPicture() const { return _picture; }
byte *getPalette() const { return _picturePalette; }
bool hasPalette() const { return _hasPalette; }
+ int getPaletteColorCount() const { return _paletteColorCount; }
protected:
Graphics::Surface *_picture;
byte *_picturePalette;
+ int _paletteColorCount;
bool _hasPalette;
};
@@ -103,7 +105,7 @@
~MenuResource();
void load(byte *source, int size);
int getCount() const { return _strings.size(); }
- Common::String getString(int index) const { return _strings[index]; }
+ const char *getString(int index) const;
protected:
Common::Array<Common::String> _strings;
};
Modified: scummvm/trunk/engines/made/screen.cpp
===================================================================
--- scummvm/trunk/engines/made/screen.cpp 2008-04-23 19:36:21 UTC (rev 31674)
+++ scummvm/trunk/engines/made/screen.cpp 2008-04-23 20:12:06 UTC (rev 31675)
@@ -51,6 +51,19 @@
_screenLock = false;
_paletteLock = false;
+ _paletteInitialized = false;
+ _needPalette = false;
+ _oldPaletteColorCount = 256;
+ _paletteColorCount = 256;
+ memset(_newPalette, 0, 768);
+ memset(_palette, 0, 768);
+
+ _ground = 1;
+ _clip = 0;
+ _exclude = 0;
+
+ _visualEffectNum = 0;
+
clearChannels();
}
@@ -62,11 +75,31 @@
void Screen::clearScreen() {
_screen1->fillRect(Common::Rect(0, 0, 320, 200), 0);
_screen2->fillRect(Common::Rect(0, 0, 320, 200), 0);
+ _needPalette = true;
//_vm->_system->clearScreen();
}
-void Screen::drawSurface(Graphics::Surface *source, int x, int y) {
+void Screen::drawSurface(Graphics::Surface *sourceSurface, int x, int y, const ClipInfo &clipInfo) {
+ byte *source = (byte*)sourceSurface->getBasePtr(0, 0);
+ byte *dest = (byte*)clipInfo.destSurface->getBasePtr(x, y);
+
+ // FIXME: Implement actual clipping
+ if (x + sourceSurface->w > clipInfo.destSurface->w || y + sourceSurface->h > clipInfo.destSurface->h) {
+ debug(2, "CLIPPING PROBLEM: x = %d; y = %d; w = %d; h = %d; x+w = %d; y+h = %d\n",
+ x, y, sourceSurface->w, sourceSurface->h, x + sourceSurface->w, y + sourceSurface->h);
+ return;
+ }
+
+ for (int16 yc = 0; yc < sourceSurface->h; yc++) {
+ for (int16 xc = 0; xc < sourceSurface->w; xc++) {
+ if (source[xc])
+ dest[xc] = source[xc];
+ }
+ source += sourceSurface->pitch;
+ dest += clipInfo.destSurface->pitch;
+ }
+
}
void Screen::loadRGBPalette(byte *palRGB, int count) {
@@ -200,11 +233,11 @@
memcpy(_screen2->pixels, _screen1->pixels, 64000);
- //drawSpriteChannels(_clipInfo1, 3, 0x40);//CHECKME
- drawSpriteChannels(_clipInfo1, 3, 0);//CHECKME
- drawSpriteChannels(_clipInfo2, 1, 2);//CHECKME
+ drawSpriteChannels(_clipInfo1, 3, 0);
+ drawSpriteChannels(_clipInfo2, 1, 2);
_vm->_system->copyRectToScreen((const byte*)_screen2->pixels, _screen2->pitch, 0, 0, _screen2->w, _screen2->h);
+
}
void Screen::clearChannels() {
@@ -220,36 +253,19 @@
if (flexIndex == 0)
return 0;
- if (flexIndex == 1279) return 0; // HACK: fixes the first screen
-
PictureResource *flex = _vm->_res->getPicture(flexIndex);
Graphics::Surface *sourceSurface = flex->getPicture();
- byte *source = (byte*)sourceSurface->getBasePtr(0, 0);
- byte *dest = (byte*)clipInfo.destSurface->getBasePtr(x, y);
+ drawSurface(sourceSurface, x, y, clipInfo);
- if (x + sourceSurface->w > clipInfo.destSurface->w || y + sourceSurface->h > clipInfo.destSurface->h) {
- debug(2, "CLIPPING PROBLEM: x = %d; y = %d; w = %d; h = %d; x+w = %d; y+h = %d\n",
- x, y, sourceSurface->w, sourceSurface->h, x + sourceSurface->w, y + sourceSurface->h);
- //fflush(stdout); g_system->delayMillis(5000);
- return 0;
- }
-
- for (int16 yc = 0; yc < sourceSurface->h; yc++) {
- for (int16 xc = 0; xc < sourceSurface->w; xc++) {
- if (source[xc])
- dest[xc] = source[xc];
- }
- source += sourceSurface->pitch;
- dest += clipInfo.destSurface->pitch;
- }
-
// Palette is set in showPage
- if (flex->hasPalette()) {
- byte *pal = flex->getPalette();
- if (pal != 0) {
- loadRGBPalette(pal);
- }
+ if (flex->hasPalette() && !_paletteLock && _needPalette) {
+ byte *flexPalette = flex->getPalette();
+ _oldPaletteColorCount = _paletteColorCount;
+ _paletteColorCount = flex->getPaletteColorCount();
+ memcpy(_newPalette, _palette, _oldPaletteColorCount * 3);
+ memcpy(_palette, flexPalette, _paletteColorCount * 3);
+ _needPalette = false;
}
_vm->_res->freeResource(flex);
@@ -264,24 +280,15 @@
AnimationResource *anim = _vm->_res->getAnimation(animIndex);
Graphics::Surface *sourceSurface = anim->getFrame(frameNum);
- byte *source = (byte*)sourceSurface->getBasePtr(0, 0);
- byte *dest = (byte*)clipInfo.destSurface->getBasePtr(x, y);
- for (int16 yc = 0; yc < sourceSurface->h; yc++) {
- for (int16 xc = 0; xc < sourceSurface->w; xc++) {
- if (source[xc])
- dest[xc] = source[xc];
- }
- source += sourceSurface->pitch;
- dest += clipInfo.destSurface->pitch;
- }
+ drawSurface(sourceSurface, x, y, clipInfo);
_vm->_res->freeResource(anim);
}
uint16 Screen::drawPic(uint16 index, int16 x, int16 y, uint16 flag1, uint16 flag2) {
- //HACK (until clipping is impelemented)
+ //HACK (until clipping is implemented)
if (y > 200) y = 0;
drawFlex(index, x, y, flag1, flag2, _clipInfo1);
@@ -306,7 +313,6 @@
uint16 Screen::placeSprite(uint16 channelIndex, uint16 flexIndex, int16 x, int16 y) {
debug(2, "placeSprite(%d, %04X, %d, %d)\n", channelIndex, flexIndex, x, y); fflush(stdout);
- //g_system->delayMillis(5000);
if (channelIndex < 1 || channelIndex >= 100)
return 0;
@@ -445,16 +451,25 @@
// TODO
+ if (_screenLock)
+ return;
+
+ drawSpriteChannels(_clipInfo1, 3, 0);
memcpy(_screen2->pixels, _screen1->pixels, 64000);
-
- drawSpriteChannels(_clipInfo2, 0, 0);
-
- //drawSpriteChannels(_clipInfo2, 3, 0);//CHECKME
- //drawSpriteChannels(_clipInfo2, 1, 2);//CHECKME
+ drawSpriteChannels(_clipInfo2, 1, 2);
- //_vm->_system->copyRectToScreen((const byte*)_screen1->pixels, _screen1->pitch, 0, 0, _screen1->w, _screen1->h);
+ // TODO: Implement visual effects (palette fading etc.)
+ if (!_paletteLock)
+ setRGBPalette(_palette, 0, _paletteColorCount);
_vm->_system->copyRectToScreen((const byte*)_screen2->pixels, _screen2->pitch, 0, 0, _screen2->w, _screen2->h);
+ _vm->_system->updateScreen();
+ if (!_paletteInitialized) {
+ memcpy(_newPalette, _palette, _paletteColorCount * 3);
+ _oldPaletteColorCount = _paletteColorCount;
+ _paletteInitialized = true;
+ }
+
}
} // End of namespace Made
Modified: scummvm/trunk/engines/made/screen.h
===================================================================
--- scummvm/trunk/engines/made/screen.h 2008-04-23 19:36:21 UTC (rev 31674)
+++ scummvm/trunk/engines/made/screen.h 2008-04-23 20:12:06 UTC (rev 31675)
@@ -60,11 +60,16 @@
void clearScreen();
- void drawSurface(Graphics::Surface *source, int x, int y);
+ void drawSurface(Graphics::Surface *sourceSurface, int x, int y, const ClipInfo &clipInfo);
void loadRGBPalette(byte *palRGB, int count = 256);
void setRGBPalette(byte *palRGB, int start = 0, int count = 256);
bool isPaletteLocked() { return _paletteLock; }
+ void setScreenLock(bool lock) { _screenLock = lock; }
void setPaletteLock(bool lock) { _paletteLock = lock; }
+ void setVisualEffectNum(int visualEffectNum) { _visualEffectNum = visualEffectNum; }
+ void setClip(uint16 clip) { _clip = clip; }
+ void setExclude(uint16 exclude) { _exclude = exclude; }
+ void setGround(uint16 ground) { _ground = ground; }
uint16 updateChannel(uint16 channelIndex);
void deleteChannel(uint16 channelIndex);
@@ -76,7 +81,7 @@
void drawSpriteChannels(const ClipInfo &clipInfo, int16 includeStateMask, int16 excludeStateMask);
void updateSprites();
void clearChannels();
-
+
uint16 drawFlex(uint16 flexIndex, int16 x, int16 y, uint16 flag1, uint16 flag2, const ClipInfo &clipInfo);
void drawAnimFrame(uint16 animIndex, int16 x, int16 y, int16 frameNum, uint16 flag1, uint16 flag2, const ClipInfo &clipInfo);
@@ -98,10 +103,6 @@
void show();
- void setClip(uint16 clip);
- void setExclude(uint16 exclude);
- void setGround(uint16 ground);
-
byte _screenPalette[256 * 4];
protected:
@@ -110,7 +111,12 @@
bool _screenLock;
bool _paletteLock;
+ byte _palette[768], _newPalette[768];
+ int _paletteColorCount, _oldPaletteColorCount;
+ bool _paletteInitialized, _needPalette;
+
uint16 _clip, _exclude, _ground;
+ int _visualEffectNum;
Graphics::Surface *_screen1, *_screen2;
ClipInfo _clipArea, _clipInfo1, _clipInfo2;
Modified: scummvm/trunk/engines/made/script.cpp
===================================================================
--- scummvm/trunk/engines/made/script.cpp 2008-04-23 19:36:21 UTC (rev 31674)
+++ scummvm/trunk/engines/made/script.cpp 2008-04-23 20:12:06 UTC (rev 31675)
@@ -682,7 +682,7 @@
byte argc = readByte();
int16 *argv = _stack.getStackPtr();
- debug(4, "func = %d (%s); argc = %d\n", func, extendFuncNames[func], argc); fflush(stdout);
+ debug(4, "func = %d (%s); argc = %d\n", func, extendFuncNames[func], argc);
for (int i = 0; i < argc; i++)
debug(4, "argv[%02d] = %04X (%d)\n", i, argv[i], argv[i]);
Modified: scummvm/trunk/engines/made/scriptfuncs.cpp
===================================================================
--- scummvm/trunk/engines/made/scriptfuncs.cpp 2008-04-23 19:36:21 UTC (rev 31674)
+++ scummvm/trunk/engines/made/scriptfuncs.cpp 2008-04-23 20:12:06 UTC (rev 31675)
@@ -176,10 +176,6 @@
}
int16 ScriptFunctionsRtz::o1_DRAWPIC(int16 argc, int16 *argv) {
-
- fflush(stdout);
- //g_system->delayMillis(5000);
-
int16 channel = _vm->_screen->drawPic(argv[4], argv[3], argv[2], argv[1], argv[0]);
return channel;
}
@@ -190,8 +186,6 @@
}
int16 ScriptFunctionsRtz::o1_SHOWPAGE(int16 argc, int16 *argv) {
- if (!_vm->_screen->isPaletteLocked())
- _vm->_system->setPalette(_vm->_screen->_screenPalette, 0, 256);
_vm->_screen->show();
return 0;
}
@@ -272,6 +266,7 @@
}
int16 ScriptFunctionsRtz::o1_VISUALFX(int16 argc, int16 *argv) {
+ _vm->_screen->setVisualEffectNum(argv[0]);
return 0;
}
@@ -343,6 +338,7 @@
}
int16 ScriptFunctionsRtz::o1_SCREENLOCK(int16 argc, int16 *argv) {
+ _vm->_screen->setScreenLock(argv[0] != 0);
return 0;
}
@@ -377,7 +373,7 @@
}
int16 ScriptFunctionsRtz::o1_SETTIMER(int16 argc, int16 *argv) {
- //g_system->delayMillis(5000);
+ _vm->setTimer(argv[1], argv[0]);
return 0;
}
@@ -444,6 +440,7 @@
}
int16 ScriptFunctionsRtz::o1_SETGROUND(int16 argc, int16 *argv) {
+ _vm->_screen->setGround(argv[0]);
return 0;
}
@@ -456,6 +453,7 @@
}
int16 ScriptFunctionsRtz::o1_SETCLIP(int16 argc, int16 *argv) {
+ _vm->_screen->setClip(argv[0]);
return 0;
}
@@ -568,10 +566,8 @@
int16 ScriptFunctionsRtz::o1_PLACETEXT(int16 argc, int16 *argv) {
Object *obj = _vm->_dat->getObject(argv[5]);
- _vm->_dat->dumpObject(argv[5]);
const char *text = obj->getString();
debug(4, "text = %s\n", text); fflush(stdout);
- //!! g_system->delayMillis(5000);
return 0;
}
@@ -605,12 +601,11 @@
}
int16 ScriptFunctionsRtz::o1_SETEXCLUDE(int16 argc, int16 *argv) {
- g_system->delayMillis(5000);
+ _vm->_screen->setExclude(argv[0]);
return 0;
}
int16 ScriptFunctionsRtz::o1_GETSTATE(int16 argc, int16 *argv) {
- //!! g_system->delayMillis(5000);
int16 state = _vm->_screen->getChannelState(argv[0]);
return state;
}
@@ -635,8 +630,6 @@
debug(4, "anim = %04X\n", argv[0]);
int16 frameCount = _vm->_screen->getAnimFrameCount(argv[0]);
debug(4, "frameCount = %04X\n", frameCount);
- //fflush(stdout);
- //g_system->delayMillis(5000);
return frameCount;
}
@@ -681,18 +674,19 @@
}
int16 ScriptFunctionsRtz::o1_READMENU(int16 argc, int16 *argv) {
- /*
+
int16 objectIndex = argv[2];
int16 menuIndex = argv[1];
int16 textIndex = argv[0];
MenuResource *menu = _vm->_res->getMenu(menuIndex);
if (menu) {
- const char *text = menu->getString(textIndex).c_str();
+ const char *text = menu->getString(textIndex);
debug(4, "text = %s\n", text); fflush(stdout);
+ Object *obj = _vm->_dat->getObject(objectIndex);
+ obj->setString(text);
_vm->_res->freeResource(menu);
}
- g_system->delayMillis(5000);
- */
+
return 0;
}
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