diff options
author | lukaslw | 2014-05-07 21:55:25 +0200 |
---|---|---|
committer | lukaslw | 2014-06-22 20:07:58 +0200 |
commit | 11fc17fc50d171d567e21ba49e39f10f448cb769 (patch) | |
tree | 74dba15d7acea272a8e00a52d13a535e50fdd89e /engines/prince | |
parent | 2dc0b21bea761af1e216cae768ed02529a1038ed (diff) | |
download | scummvm-rg350-11fc17fc50d171d567e21ba49e39f10f448cb769.tar.gz scummvm-rg350-11fc17fc50d171d567e21ba49e39f10f448cb769.tar.bz2 scummvm-rg350-11fc17fc50d171d567e21ba49e39f10f448cb769.zip |
PRINCE: Change init() to Graphics::drawLine(), code clean up
Diffstat (limited to 'engines/prince')
-rw-r--r-- | engines/prince/animation.cpp | 32 | ||||
-rw-r--r-- | engines/prince/debugger.cpp | 2 | ||||
-rw-r--r-- | engines/prince/flags.cpp | 2 | ||||
-rw-r--r-- | engines/prince/graphics.cpp | 21 | ||||
-rw-r--r-- | engines/prince/graphics.h | 4 | ||||
-rw-r--r-- | engines/prince/hero.cpp | 143 | ||||
-rw-r--r-- | engines/prince/hero.h | 9 | ||||
-rw-r--r-- | engines/prince/hero_set.cpp | 14 | ||||
-rw-r--r-- | engines/prince/mob.cpp | 38 | ||||
-rw-r--r-- | engines/prince/prince.cpp | 71 | ||||
-rw-r--r-- | engines/prince/prince.h | 6 | ||||
-rw-r--r-- | engines/prince/script.cpp | 6 | ||||
-rw-r--r-- | engines/prince/variatxt.h | 2 |
13 files changed, 131 insertions, 219 deletions
diff --git a/engines/prince/animation.cpp b/engines/prince/animation.cpp index 587316fc19..9911f5f99e 100644 --- a/engines/prince/animation.cpp +++ b/engines/prince/animation.cpp @@ -30,7 +30,7 @@ namespace Prince { bool Animation::loadFromStream(Common::SeekableReadStream &stream) { _dataSize = stream.size(); - _data = (byte*) malloc(_dataSize); + _data = (byte *)malloc(_dataSize); if (stream.read(_data, _dataSize) != _dataSize) { free(_data); @@ -38,17 +38,7 @@ bool Animation::loadFromStream(Common::SeekableReadStream &stream) { } return true; } -/* -const Graphics::Surface * Animation::getSurface(uint16 frameIndex) { - // bida kaszing - if (frameIndex >= _frameList.size()) { - _frameList.resize(frameIndex); - _frameList.push_back(_helper->getFrame(frameIndex)); - - } - return _frameList[frameIndex]; -} -*/ + Animation::Animation(): _data(NULL) { } @@ -135,20 +125,20 @@ Graphics::Surface *Animation::getFrame(uint frameIndex) { debug("width = %d; height = %d", width, height); Graphics::Surface *surf = new Graphics::Surface(); surf->create(width, height, Graphics::PixelFormat::createFormatCLUT8()); - debug("frameData %p", frameData); - if (READ_BE_UINT32(frameData + 4) == 0x6D61736D) { + debug("frameData %p", frameData); + if (READ_BE_UINT32(frameData + 4) == MKTAG('m', 'a', 's', 'm')) { // Compressed Decompressor dec; - uint32 ddataSize = READ_LE_UINT32(frameData + 8); - byte *ddata = new byte[ddataSize]; + uint32 ddataSize = READ_LE_UINT32(frameData + 8); + byte *ddata = (byte *)malloc(ddataSize); dec.decompress(frameData + 12, ddata, ddataSize); - for (uint16 i = 0; i < height; ++i) { - memcpy(surf->getBasePtr(0, i), ddata + width * i, width); - } - delete[] ddata; + for (uint16 i = 0; i < height; i++) { + memcpy(surf->getBasePtr(0, i), ddata + width * i, width); + } + free(ddata); } else { // Uncompressed - for (uint16 i = 0; i < height; ++i) { + for (uint16 i = 0; i < height; i++) { memcpy(surf->getBasePtr(0, i), frameData + 4 + width * i, width); } } diff --git a/engines/prince/debugger.cpp b/engines/prince/debugger.cpp index d9264cb02d..58c10f1200 100644 --- a/engines/prince/debugger.cpp +++ b/engines/prince/debugger.cpp @@ -54,7 +54,7 @@ static int strToInt(const char *s) { bool Debugger::Cmd_DebugLevel(int argc, const char **argv) { if (argc == 1) { - DebugPrintf("Debugging is currently set at level %d\n", gDebugLevel); + DebugPrintf("Debugging is currently set at level %d\n", gDebugLevel); } else { // set level gDebugLevel = atoi(argv[1]); if (0 <= gDebugLevel && gDebugLevel < 11) { diff --git a/engines/prince/flags.cpp b/engines/prince/flags.cpp index d6d577a575..18d9e212c1 100644 --- a/engines/prince/flags.cpp +++ b/engines/prince/flags.cpp @@ -24,7 +24,7 @@ namespace Prince { -const char * Flags::getFlagName(uint16 flagId) +const char *Flags::getFlagName(uint16 flagId) { switch (flagId) { default: return "unknown_flag"; diff --git a/engines/prince/graphics.cpp b/engines/prince/graphics.cpp index ea03204657..1edf22cfac 100644 --- a/engines/prince/graphics.cpp +++ b/engines/prince/graphics.cpp @@ -98,31 +98,28 @@ void GraphicsMan::makeShadowTable(int brightness, byte *shadowPallete) { int32 currColor; int shadow = brightness * 256 / 100; - byte *originalPallete = new byte[256 * 3]; + byte *originalPallete = (byte *)malloc(256 * 3); _vm->_system->getPaletteManager()->grabPalette(originalPallete, 0, 256); - Common::MemoryReadStream readFirstStream(originalPallete, 256 * 3); - Common::MemoryWriteStream writeStream(shadowPallete, 256); for (int i = 0; i < 256; i++) { - redFirstOrg = readFirstStream.readByte() * shadow / 256; - greenFirstOrg = readFirstStream.readByte() * shadow / 256; - blueFirstOrg = readFirstStream.readByte() * shadow / 256; + redFirstOrg = originalPallete[3 * i] * shadow / 256; + greenFirstOrg = originalPallete[3 * i + 1] * shadow / 256; + blueFirstOrg = originalPallete[3 * i + 2] * shadow / 256; currColor = 0; - Common::MemoryReadStream readSecondStream(originalPallete, 256 * 3); bigValue = 999999999; // infinity for (int j = 0; j < 256; j++) { - redSecondOrg = readSecondStream.readByte(); + redSecondOrg = originalPallete[3 * j]; redNew = redFirstOrg - redSecondOrg; redNew = redNew * redNew; - greenSecondOrg = readSecondStream.readByte(); + greenSecondOrg = originalPallete[3 * j + 1]; greenNew = greenFirstOrg - greenSecondOrg; greenNew = greenNew * greenNew; - blueSecondOrg = readSecondStream.readByte(); + blueSecondOrg = originalPallete[3 * j + 2]; blueNew = blueFirstOrg - blueSecondOrg; blueNew = blueNew * blueNew; @@ -137,9 +134,9 @@ void GraphicsMan::makeShadowTable(int brightness, byte *shadowPallete) { break; } } - writeStream.writeByte(currColor); + shadowPallete[i] = currColor; } - delete[] originalPallete; + free(originalPallete); } } diff --git a/engines/prince/graphics.h b/engines/prince/graphics.h index 62dd89c9ee..3e43503c58 100644 --- a/engines/prince/graphics.h +++ b/engines/prince/graphics.h @@ -34,8 +34,8 @@ class GraphicsMan { public: GraphicsMan(PrinceEngine *vm); - ~GraphicsMan(); - + ~GraphicsMan(); + void update(); void change(); diff --git a/engines/prince/hero.cpp b/engines/prince/hero.cpp index 3e89b23a70..7010b42507 100644 --- a/engines/prince/hero.cpp +++ b/engines/prince/hero.cpp @@ -35,16 +35,16 @@ Hero::Hero(PrinceEngine *vm) : _vm(vm), _number(0), _visible(false), _state(MOVE , _boreNum(1), _currHeight(0), _moveDelay(0), _shadMinus(0), _moveSetType(0) , _lastDirection(DOWN), _destDirection(DOWN), _talkTime(0), _boredomTime(0), _phase(0) , _specAnim(0), _drawX(0), _drawY(0), _randomSource("prince"), _zoomFactor(0), _scaleValue(0) - , _shadZoomFactor(0), _shadScaleValue(0) + , _shadZoomFactor(0), _shadScaleValue(0), _shadowLineLen(0) { _zoomBitmap = new Animation(); _shadowBitmap = new Animation(); - _linijka = new byte[2*1280*4]; + _shadowLine = new byte[kShadowLineArraySize]; } Hero::~Hero() { delete _zoomBitmap; - delete[] _linijka; + delete[] _shadowLine; } bool Hero::loadAnimSet(uint32 animSetNr) { @@ -242,7 +242,7 @@ void Hero::countDrawPosition() { //notfullSize debug("scaledX: %d", scaledX); debug("scaledY: %d", scaledY); - _drawX = _middleX - scaledX/2; + _drawX = _middleX - scaledX / 2; _drawY = tempMiddleY + 1 - scaledY; } else { //fullSize @@ -251,113 +251,37 @@ void Hero::countDrawPosition() { } } -void Hero::line(int x1, int y1, int x2, int y2) { - //EAX - x1 <- LightX - //EBX - y1 <- LightY - //ECX - x2 <- DestX - //EDX - y2 <- DestY - - //pushad - int dX = 1; - int vx = y2 - y1; - if(x2 <= x1) { - dX = -1; - vx = -1 * vx; - } - // pl_1 - int lvx = vx; - int dY = 1; - int vy = x1 - x2; - if (y2 <= y1) { - dY = -1; - vy = -1 * vy; - } - // pl_2 - int lvy = vy; - int lx = x1; - int ly = y1; - int lx2 = x2; - int ly2 = y2; - int lfa = 0; - - int shadowLineLen = 0; - Common::MemoryWriteStream writeStream(_linijka, 2*1280*4); - //loop - while (lx != lx2 || ly != ly2) { - //not_end - //nopik - if(shadowLineLen == 1280) { - break; - } - writeStream.writeUint16LE(lx); - writeStream.writeUint16LE(ly); - shadowLineLen++; - - int lfx = lfa + lvx; - int lfy = lfa + lvy; - int lfxy = lfx + lfy - lfa; - int abs_lfxy, abs_lfx, abs_lfy; +void Hero::plotPoint(int x, int y) { + WRITE_UINT16(&_shadowLine[_shadowLineLen * 4], x); + WRITE_UINT16(&_shadowLine[_shadowLineLen * 4 + 2], y); +} - if (lfxy < 0) { - abs_lfxy = -1 * lfxy; - } else { - abs_lfxy = lfxy; - } - //abs_fxy_done - if (lfx < 0) { - abs_lfx = -1 * lfx; - } else { - abs_lfx = lfx; - } - //abs_fx_done - if (lfy < 0) { - abs_lfy = -1 * lfy; - } else { - abs_lfy = lfy; - } - //abs_fy_done - - if (abs_lfx > abs_lfy || abs_lfx > abs_lfxy) { - //c2 - if (abs_lfy >= abs_lfx || abs_lfy > abs_lfxy) { - //c3 - ly += dY; - lx += dX; - lfa = lfxy; - } else { - ly += dY; - lfa = lfa + lvy; - } - } else { - lx += dX; - lfa = lfa + lvx; - } - //next - } +static void plot(int x, int y, int color, void *data) { + Hero *shadowLine = (Hero *)data; + shadowLine->plotPoint(x, y); + shadowLine->_shadowLineLen++; } -void Hero::showHeroShadow() { -//Graphics::Surface *Hero::showHeroShadow(Graphics::Surface *heroFrame) { +Graphics::Surface *Hero::showHeroShadow(Graphics::Surface *heroFrame) { int16 frameXSize = _moveSet[_moveSetType]->getFrameWidth(_phase); int16 frameYSize = _moveSet[_moveSetType]->getFrameHeight(_phase); - /* + Graphics::Surface *makeShadow = new Graphics::Surface(); makeShadow->create(frameXSize, frameYSize, Graphics::PixelFormat::createFormatCLUT8()); - //make_shadow: for (int y = 0; y < frameYSize; y++) { - //ms_loop: - for (int x = 0; x < frameXSize; x++) { - byte pixel = *(byte*) makeShadow->getBasePtr(x, y); - if (pixel == -1) { - *(byte*)(makeShadow->getBasePtr(x, y)) = kShadowColor; + byte *dst = (byte *)makeShadow->getBasePtr(0, y); + byte *src = (byte *)heroFrame->getBasePtr(0, y); + + for (int x = 0; x < frameXSize; x++, dst++, src++) { + if (*dst == 0xFF) { + *dst = kShadowColor; } else { - memcpy(makeShadow->getBasePtr(x, y), heroFrame->getBasePtr(x, y), 1); - //*(byte*)(makeShadow->getBasePtr(x, y)) = pixel; + *dst = *src; } } } - */ + // source Bitmap of sprite - esi int destX = _drawX; // eax int destY = _middleY - _shadMinus; // ecx @@ -379,18 +303,10 @@ void Hero::showHeroShadow() { } else { shadowDirection = 0; } - //int shadowLineLen = 0; + //int shadWallDown = 0; - // int shadowLine = Linijka(); - // push lineCode - // mov lineCode <- @@Nopik - //EAX - x1 <- LightX - //EBX - y1 <- LightY - //ECX - x2 <- DestX - //EDX - y2 <- DestY - line(_lightX, _lightY, destX, destY); - // pop lineCode - // popad + _shadowLineLen = 0; + Graphics::drawLine(_lightX, _lightY, destX, destY, 0, &plot, this); // sprShadow = shadowTable70 // sprModulo = modulo of source Bitmap @@ -408,7 +324,7 @@ void Hero::showHeroShadow() { int shadMaxY = sprDestY; // destY * kMaxPicWidth / 8 + destX / 8 int shadBitAddr = _shadowBitmap->getZoom(destY * kMaxPicWidth / 8 + destX / 8); - int shadBitMask = 128 / pow(2.0, (destX % 8)); + int shadBitMask = 128 / (2 << (destX % 8)); int shadZoomY2 = _shadScaleValue; int shadZoomY = _scaleValue; @@ -416,7 +332,8 @@ void Hero::showHeroShadow() { // lockscreen etc // banked2 - // edx = linijka() + 8 + byte *start = _shadowLine + 8; + // linear_loop //for(int i = 0; i < ; i++) { @@ -446,7 +363,7 @@ void Hero::showHeroShadow() { } //} } - //return makeShadow; + return makeShadow; } void Hero::showHeroAnimFrame() { @@ -457,7 +374,7 @@ void Hero::showHeroAnimFrame() { } countDrawPosition(); //temp: - showHeroShadow(); + //showHeroShadow(); //debug("_drawX: %d", _drawX); //debug("_drawY: %d", _drawY); //debug("_middleX: %d", _middleX); diff --git a/engines/prince/hero.h b/engines/prince/hero.h index 4016e3519b..6640bcf3df 100644 --- a/engines/prince/hero.h +++ b/engines/prince/hero.h @@ -28,6 +28,7 @@ #include "common/memstream.h" #include "graphics/surface.h" +#include "graphics/primitives.h" namespace Prince { @@ -42,6 +43,7 @@ public: static const int16 kMaxPicHeight = 480; static const int16 kZoomBitmapWidth = kMaxPicWidth / kZoomStep; static const int16 kNormalWidth = 640; + static const int16 kShadowLineArraySize = 2 * 1280 * 4; static const uint8 kShadowColor = 191; @@ -116,8 +118,8 @@ public: Graphics::Surface *zoomSprite(Graphics::Surface *heroFrame); void showHeroAnimFrame(); void line(int x1, int y1, int x2, int y2); - //Graphics::Surface *showHeroShadow(Graphics::Surface *heroFrame); - void showHeroShadow(); + void plotPoint(int x, int y); + Graphics::Surface *showHeroShadow(Graphics::Surface *heroFrame); void setShadowScale(int32 shadowScale); void specialAnim(); void getState(); @@ -140,6 +142,7 @@ public: int16 _lightY; int32 _shadZoomFactor; int32 _shadScaleValue; + int32 _shadowLineLen; // Coords array of coordinates @@ -169,7 +172,7 @@ public: // TurnAnim ?? Animation *_zoomBitmap; // change to sth else, not Animation ?? Animation *_shadowBitmap; - byte *_linijka; + byte *_shadowLine; uint32 _moveDelay; uint32 _shadMinus; diff --git a/engines/prince/hero_set.cpp b/engines/prince/hero_set.cpp index a8c05de724..1d235a567a 100644 --- a/engines/prince/hero_set.cpp +++ b/engines/prince/hero_set.cpp @@ -26,7 +26,7 @@ namespace Prince { -static HeroSetAnimNames heroSet5= { +static HeroSetAnimNames heroSet5 = { "SL_DIAB.ANI", "SR_DIAB.ANI", "SU_DIAB.ANI", @@ -55,7 +55,7 @@ static HeroSetAnimNames heroSet5= { NULL }; -static HeroSetAnimNames heroSet1= { +static HeroSetAnimNames heroSet1 = { "SL_HERO1.ANI", "SR_HERO1.ANI", "SU_HERO1.ANI", @@ -84,7 +84,7 @@ static HeroSetAnimNames heroSet1= { "KS_WLOSY.ANI" }; -static HeroSetAnimNames heroSet2= { +static HeroSetAnimNames heroSet2 = { "SL_HERO2.ANI", "SR_HERO2.ANI", "SU_HERO2.ANI", @@ -113,7 +113,7 @@ static HeroSetAnimNames heroSet2= { "KS_WLO_S.ANI" }; -static HeroSetAnimNames heroSet3= { +static HeroSetAnimNames heroSet3 = { "SL_BEAR.ANI", "SR_BEAR.ANI", "SU_BEAR.ANI", @@ -142,7 +142,7 @@ static HeroSetAnimNames heroSet3= { NULL, }; -static HeroSetAnimNames shanSet1= { +static HeroSetAnimNames shanSet1 = { "SL_SHAN.ANI", "SR_SHAN.ANI", "SU_SHAN.ANI", @@ -171,7 +171,7 @@ static HeroSetAnimNames shanSet1= { "B2_SHAN.ANI", }; -static HeroSetAnimNames shanSet2= { +static HeroSetAnimNames shanSet2 = { "SL_SHAN2.ANI", "SR_SHAN2.ANI", "SU_SHAN.ANI", @@ -200,7 +200,7 @@ static HeroSetAnimNames shanSet2= { "B2_SHAN2.ANI" }; -static HeroSetAnimNames arivSet1= { +static HeroSetAnimNames arivSet1 = { "SL_ARIV.ANI", "SR_ARIV.ANI", "SU_ARIV.ANI", diff --git a/engines/prince/mob.cpp b/engines/prince/mob.cpp index c4bb607347..1ca9931a59 100644 --- a/engines/prince/mob.cpp +++ b/engines/prince/mob.cpp @@ -71,28 +71,32 @@ bool Mob::loadFromStream(Common::SeekableReadStream &stream) { void Mob::setData(AttrId dataId, uint16 value) { switch (dataId) { - case ExamDir: - _examDirection = (Direction)value; - break; - case ExamX: - _examPosition.x = value; - break; - case ExamY: - _examPosition.y = value; - break; - default: - assert(false); + case ExamDir: + _examDirection = (Direction)value; + break; + case ExamX: + _examPosition.x = value; + break; + case ExamY: + _examPosition.y = value; + break; + default: + assert(false); } } uint16 Mob::getData(AttrId dataId) { switch (dataId) { - case Visible: return _visible; - case ExamDir: return _examDirection; - case ExamX: return _examPosition.x; - case ExamY: return _examPosition.y; - default: - assert(false); + case Visible: + return _visible; + case ExamDir: + return _examDirection; + case ExamX: + return _examPosition.x; + case ExamY: + return _examPosition.y; + default: + assert(false); } } diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index 39183d35f1..0439bae840 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -67,9 +67,9 @@ void PrinceEngine::debugEngine(const char *s, ...) { char buf[STRINGBUFLEN]; va_list va; - va_start(va, s); - vsnprintf(buf, STRINGBUFLEN, s, va); - va_end(va); + va_start(va, s); + vsnprintf(buf, STRINGBUFLEN, s, va); + va_end(va); debug("Prince::Engine frame %08ld %s", _frameNr, buf); } @@ -78,7 +78,7 @@ PrinceEngine::PrinceEngine(OSystem *syst, const PrinceGameDescription *gameDesc) Engine(syst), _gameDescription(gameDesc), _graph(nullptr), _script(nullptr), _interpreter(nullptr), _flags(nullptr), _locationNr(0), _debugger(nullptr), _midiPlayer(nullptr), _cameraX(0), _newCameraX(0), _frameNr(0), _cursor1(nullptr), _cursor2(nullptr), _font(nullptr), - _walizkaBmp(nullptr), _roomBmp(nullptr), _cursorNr(0), _picWindowX(0), _picWindowY(0) { + _suitcaseBmp(nullptr), _roomBmp(nullptr), _cursorNr(0), _picWindowX(0), _picWindowY(0) { // Debug/console setup DebugMan.addDebugChannel(DebugChannel::kScript, "script", "Prince Script debug channel"); @@ -104,14 +104,14 @@ PrinceEngine::~PrinceEngine() { delete _interpreter; delete _font; delete _roomBmp; - delete _walizkaBmp; + delete _suitcaseBmp; delete _variaTxt; delete[] _talkTxt; delete _graph; delete _mainHero; delete _secondHero; - for (uint32 i = 0; i < _objList.size(); ++i) { + for (uint i = 0; i < _objList.size(); ++i) { delete _objList[i]; } _objList.clear(); @@ -155,8 +155,8 @@ void PrinceEngine::init() { _font = new Font(); Resource::loadResource(_font, "font1.raw"); - _walizkaBmp = new MhwanhDecoder(); - Resource::loadResource(_walizkaBmp, "walizka"); + _suitcaseBmp = new MhwanhDecoder(); + Resource::loadResource(_suitcaseBmp, "walizka"); _script = new Script(); Resource::loadResource(_script, "skrypt.dat"); @@ -244,7 +244,7 @@ bool PrinceEngine::loadLocation(uint16 locationNr) { _flicPlayer.close(); memset(_textSlots, 0, sizeof(_textSlots)); - for(uint32 sampleId = 0; sampleId < MAX_SAMPLES; ++sampleId) { + for(uint32 sampleId = 0; sampleId < MAX_SAMPLES; sampleId++) { stopSample(sampleId); } @@ -284,7 +284,7 @@ bool PrinceEngine::loadLocation(uint16 locationNr) { Resource::loadResource(_mainHero->_zoomBitmap, "zoom", false); _mainHero->_shadowBitmap->clear(); - if(Resource::loadResource(_mainHero->_shadowBitmap, "shadow", false) == false) { + if (Resource::loadResource(_mainHero->_shadowBitmap, "shadow", false) == false) { Resource::loadResource(_mainHero->_shadowBitmap, "shadow2", false); } @@ -299,7 +299,7 @@ bool PrinceEngine::loadLocation(uint16 locationNr) { _mobList.clear(); Resource::loadResource(_mobList, "mob.lst", false); - for (uint32 i = 0; i < _objList.size(); ++i) { + for (uint32 i = 0; i < _objList.size(); i++) { delete _objList[i]; } _objList.clear(); @@ -323,17 +323,17 @@ void PrinceEngine::changeCursor(uint16 curId) { uint16 hotspotY = 0; switch(curId) { - case 0: - CursorMan.showMouse(false); - return; - case 1: - curSurface = _cursor1->getSurface(); - break; - case 2: - curSurface = _cursor2->getSurface(); - hotspotX = curSurface->w >> 1; - hotspotY = curSurface->h >> 1; - break; + case 0: + CursorMan.showMouse(false); + return; + case 1: + curSurface = _cursor1->getSurface(); + break; + case 2: + curSurface = _cursor2->getSurface(); + hotspotX = curSurface->w >> 1; + hotspotY = curSurface->h >> 1; + break; } CursorMan.replaceCursorPalette(_roomBmp->getPalette(), 0, 255); @@ -356,9 +356,9 @@ bool PrinceEngine::playNextFrame() { _graph->drawTransparent(0, 0, s); _graph->change(); } else if (_flicLooped) { - _flicPlayer.rewind(); - playNextFrame(); - } + _flicPlayer.rewind(); + playNextFrame(); + } return true; } @@ -414,14 +414,16 @@ bool PrinceEngine::loadVoice(uint32 slot, uint32 sampleSlot, const Common::Strin } uint32 id = _voiceStream[sampleSlot]->readUint32LE(); - if (id != 0x46464952) { + //if (id != 0x46464952) { + if (id != MKTAG('F', 'F', 'I', 'R')) { error("It's not RIFF file %s", streamName.c_str()); return false; } _voiceStream[sampleSlot]->skip(0x20); id = _voiceStream[sampleSlot]->readUint32LE(); - if (id != 0x61746164) { + //if (id != 0x61746164) { + if (id != MKTAG('a', 't', 'a', 'd')) { error("No data section in %s id %04x", streamName.c_str(), id); return false; } @@ -454,7 +456,7 @@ bool PrinceEngine::loadAnim(uint16 animNr, bool loop) { } debugEngine("%s loaded", streamName.c_str()); - _flicLooped = loop; + _flicLooped = loop; _flicPlayer.start(); playNextFrame(); return true; @@ -550,8 +552,7 @@ void PrinceEngine::hotspot() { Common::Point mousepos = _system->getEventManager()->getMousePos(); Common::Point mousePosCamera(mousepos.x + _cameraX, mousepos.y); - for (Common::Array<Mob>::const_iterator it = _mobList.begin() - ; it != _mobList.end() ; ++it) { + for (Common::Array<Mob>::const_iterator it = _mobList.begin(); it != _mobList.end() ; it++) { const Mob& mob = *it; if (mob._visible) continue; @@ -596,12 +597,12 @@ void PrinceEngine::printAt(uint32 slot, uint8 color, const char *s, uint16 x, ui } uint32 PrinceEngine::getTextWidth(const char *s) { - uint16 textW = 0; + uint16 textW = 0; while (*s) { - textW += _font->getCharWidth(*s) + _font->getKerningOffset(0, 0); - ++s; - } - return textW; + textW += _font->getCharWidth(*s) + _font->getKerningOffset(0, 0); + s++; + } + return textW; } void PrinceEngine::showTexts() { diff --git a/engines/prince/prince.h b/engines/prince/prince.h index 8213b2d32b..7793545526 100644 --- a/engines/prince/prince.h +++ b/engines/prince/prince.h @@ -137,8 +137,8 @@ public: Text _textSlots[MAXTEXTS]; uint64 _frameNr; - Hero* _mainHero; - Hero* _secondHero; + Hero *_mainHero; + Hero *_secondHero; uint16 _cameraX; uint16 _newCameraX; @@ -168,7 +168,7 @@ private: Image::BitmapDecoder *_roomBmp; Cursor *_cursor1; Cursor *_cursor2; - MhwanhDecoder *_walizkaBmp; + MhwanhDecoder *_suitcaseBmp; Debugger *_debugger; GraphicsMan *_graph; Script *_script; diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp index 11cba8fdf9..78704eb6f8 100644 --- a/engines/prince/script.cpp +++ b/engines/prince/script.cpp @@ -45,7 +45,7 @@ void Room::loadMobs(Common::SeekableReadStream &stream) { static const uint8 MAX_MOBS = 64; uint8 mobs[MAX_MOBS]; stream.read(&mobs, sizeof(mobs)); - for(uint8 i = 0; i < sizeof(mobs); ++i) { + for (uint8 i = 0; i < sizeof(mobs); i++) { debug("mob %d flag %d", i, mobs[i]); } } @@ -56,7 +56,7 @@ void Room::loadBackAnim(Common::SeekableReadStream &stream) { uint32 backAnim[MAX_BACK_ANIMS]; debug("loadBackAnim sizeof %lu", sizeof(backAnim)); stream.read(backAnim, sizeof(backAnim)); - for(uint8 i = 0; i < MAX_BACK_ANIMS; ++i) { + for (uint8 i = 0; i < MAX_BACK_ANIMS; i++) { debug("back anim offset %d", backAnim[i]); } } @@ -498,7 +498,7 @@ void Interpreter::O_COMPARE() { void Interpreter::O_JUMPZ() { int32 offset = readScript<uint32>(); - if (! _result) { + if (!_result) { _currentInstruction += offset - 4; } diff --git a/engines/prince/variatxt.h b/engines/prince/variatxt.h index dcdba7bd8a..2a7a5fda9c 100644 --- a/engines/prince/variatxt.h +++ b/engines/prince/variatxt.h @@ -32,7 +32,7 @@ public: bool loadFromStream(Common::SeekableReadStream &stream); - const char * getString(uint32 stringId); + const char *getString(uint32 stringId); private: uint32 _dataSize; |