From d611e81672962a4941f00c2bb6c9e22580311706 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 18 Mar 2007 12:08:13 +0000 Subject: - little 'cleanup' - finished MSC file support for Amiga version svn-id: r26204 --- engines/kyra/kyra.h | 2 +- engines/kyra/scene.cpp | 7 +++--- engines/kyra/screen.cpp | 61 +++++++++++++++++++++++++++++++----------------- engines/kyra/screen.h | 3 +-- engines/kyra/sprites.cpp | 2 +- engines/kyra/sprites.h | 2 +- 6 files changed, 48 insertions(+), 29 deletions(-) diff --git a/engines/kyra/kyra.h b/engines/kyra/kyra.h index 21d32988ef..ea3a67c02f 100644 --- a/engines/kyra/kyra.h +++ b/engines/kyra/kyra.h @@ -503,7 +503,7 @@ protected: int setCharacterPosition(int character, int *facingTable); void setCharacterPositionHelper(int character, int *facingTable); int getOppositeFacingDirection(int dir); - void loadSceneMSC(); + void loadSceneMsc(); void startSceneScript(int brandonAlive); void setupSceneItems(); void initSceneData(int facing, int unk1, int brandonAlive); diff --git a/engines/kyra/scene.cpp b/engines/kyra/scene.cpp index f3212d517a..067edfc0e7 100644 --- a/engines/kyra/scene.cpp +++ b/engines/kyra/scene.cpp @@ -156,10 +156,10 @@ void KyraEngine::enterNewScene(int sceneId, int facing, int unk1, int unk2, int char fileNameBuffer[32]; strcpy(fileNameBuffer, _roomFilenameTable[tableId]); strcat(fileNameBuffer, ".DAT"); - _sprites->loadDAT(fileNameBuffer, _sceneExits); + _sprites->loadDat(fileNameBuffer, _sceneExits); _sprites->setupSceneAnims(); _scriptInterpreter->unloadScript(_scriptClickData); - loadSceneMSC(); + loadSceneMsc(); _walkBlockNorth = currentRoom->northExit; _walkBlockEast = currentRoom->eastExit; @@ -429,7 +429,7 @@ int KyraEngine::getOppositeFacingDirection(int dir) { return 0; } -void KyraEngine::loadSceneMSC() { +void KyraEngine::loadSceneMsc() { assert(_currentCharacter->sceneId < _roomTableSize); int tableId = _roomTable[_currentCharacter->sceneId].nameIndex; assert(tableId < _roomFilenameTableSize); @@ -448,6 +448,7 @@ void KyraEngine::startSceneScript(int brandonAlive) { char fileNameBuffer[32]; strcpy(fileNameBuffer, _roomFilenameTable[tableId]); strcat(fileNameBuffer, ".CPS"); + _screen->clearPage(3); // FIXME: check this hack for amiga version _screen->loadBitmap(fileNameBuffer, 3, 3, (_flags.platform == Common::kPlatformAmiga ? _screen->getPalette(1) : 0)); _sprites->loadSceneShapes(); diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp index 6b4006e523..feded31d80 100644 --- a/engines/kyra/screen.cpp +++ b/engines/kyra/screen.cpp @@ -1692,7 +1692,7 @@ void Screen::decodeFrameDeltaPage(uint8 *dst, const uint8 *src, int pitch, bool } } -void Screen::convertAmigaGfx(uint8 *data, int w, int h, bool offscreen, int planeOffset) { +void Screen::convertAmigaGfx(uint8 *data, int w, int h, bool offscreen) { static uint8 tmp[320*200]; if (offscreen) { @@ -1701,10 +1701,10 @@ void Screen::convertAmigaGfx(uint8 *data, int w, int h, bool offscreen, int plan int hC = h; while (hC--) { uint8 *dst1 = curLine; - uint8 *dst2 = dst1 + planeOffset; - uint8 *dst3 = dst2 + planeOffset; - uint8 *dst4 = dst3 + planeOffset; - uint8 *dst5 = dst4 + planeOffset; + uint8 *dst2 = dst1 + 8000; + uint8 *dst3 = dst2 + 8000; + uint8 *dst4 = dst3 + 8000; + uint8 *dst5 = dst4 + 8000; int width = w >> 3; while (width--) { @@ -1727,30 +1727,49 @@ void Screen::convertAmigaGfx(uint8 *data, int w, int h, bool offscreen, int plan int bitPos = 7-x&7; byte colorIndex = 0; - colorIndex |= (((tmp[bytePos + planeOffset * 0] & (1 << bitPos)) >> bitPos) & 0x1) << 0; - colorIndex |= (((tmp[bytePos + planeOffset * 1] & (1 << bitPos)) >> bitPos) & 0x1) << 1; - colorIndex |= (((tmp[bytePos + planeOffset * 2] & (1 << bitPos)) >> bitPos) & 0x1) << 2; - colorIndex |= (((tmp[bytePos + planeOffset * 3] & (1 << bitPos)) >> bitPos) & 0x1) << 3; - colorIndex |= (((tmp[bytePos + planeOffset * 4] & (1 << bitPos)) >> bitPos) & 0x1) << 4; + colorIndex |= (((tmp[bytePos + 8000 * 0] & (1 << bitPos)) >> bitPos) & 0x1) << 0; + colorIndex |= (((tmp[bytePos + 8000 * 1] & (1 << bitPos)) >> bitPos) & 0x1) << 1; + colorIndex |= (((tmp[bytePos + 8000 * 2] & (1 << bitPos)) >> bitPos) & 0x1) << 2; + colorIndex |= (((tmp[bytePos + 8000 * 3] & (1 << bitPos)) >> bitPos) & 0x1) << 3; + colorIndex |= (((tmp[bytePos + 8000 * 4] & (1 << bitPos)) >> bitPos) & 0x1) << 4; *data++ = colorIndex; } } } void Screen::convertAmigaMsc(uint8 *data) { - Screen::convertAmigaGfx(data, 320, 200, false, 5760); - for (int i = 0; i < 64000; ++i) { - byte src = *data; - byte dst = 0; - if (!(src & 0x1)) { - dst |= 0x80; + byte *plane1 = data + 5760 * 1; + byte *plane2 = data + 5760 * 2; + byte *plane3 = data + 5760 * 3; + byte *plane4 = data + 5760 * 4; + byte *plane5 = data + 5760 * 5; + byte *plane6 = data + 5760 * 6; + for (int i = 0; i < 5760; ++i) { + byte d = plane6[i]; + d = (plane5[i] |= d); + d = (plane4[i] |= d); + d = (plane3[i] |= d); + d = (plane2[i] |= d); + d = (plane1[i] |= d); + } + byte dst[320*144]; + memset(dst, 0, sizeof(dst)); + static const byte flagTable[] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; + for (int y = 0; y < 144; ++y) { + for (int x = 0; x < 320; ++x) { + if (!(flagTable[x&7] & data[y*40+(x>>3)])) + dst[y*320+x] |= 0x80; + + int layer = 0; + for (int i = 0; i < 7; ++i) { + if (flagTable[x&7] & data[y*40+(x>>3)+i*5760]) + layer = i; + } + if (layer) + dst[y*320+x] |= (layer+1); } - // FIXME: this is totally wrong, correct this - src >>= 1; - src &= 0x7; - dst |= src; - *data++ = dst; } + memcpy(data, dst, 320*144); } template diff --git a/engines/kyra/screen.h b/engines/kyra/screen.h index 5d317e0035..b59c09d3d8 100644 --- a/engines/kyra/screen.h +++ b/engines/kyra/screen.h @@ -167,7 +167,6 @@ public: int setNewShapeHeight(uint8 *shape, int height); int resetShapeHeight(uint8 *shape); - void drawShapePlotPixelCallback1(uint8 *dst, uint8 color); void drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int sd, int flags, ...); // mouse handling @@ -231,7 +230,7 @@ public: static uint decodeFrame4(const uint8 *src, uint8 *dst, uint32 dstSize); static void decodeFrameDelta(uint8 *dst, const uint8 *src, bool noXor = false); static void decodeFrameDeltaPage(uint8 *dst, const uint8 *src, const int pitch, bool noXor); - static void convertAmigaGfx(uint8 *data, int w, int h, bool offscreen = true, int planeOffset = 8000); + static void convertAmigaGfx(uint8 *data, int w, int h, bool offscreen = true); static void convertAmigaMsc(uint8 *data); // maybe subclass screen for kyra3 diff --git a/engines/kyra/sprites.cpp b/engines/kyra/sprites.cpp index 409958da18..a6a069cf98 100644 --- a/engines/kyra/sprites.cpp +++ b/engines/kyra/sprites.cpp @@ -396,7 +396,7 @@ void Sprites::updateSceneAnims() { } } -void Sprites::loadDAT(const char *filename, SceneExits &exits) { +void Sprites::loadDat(const char *filename, SceneExits &exits) { debugC(9, kDebugLevelSprites, "Sprites::loadDat('%s')", filename); uint32 fileSize; diff --git a/engines/kyra/sprites.h b/engines/kyra/sprites.h index 393dd99043..8a8149f237 100644 --- a/engines/kyra/sprites.h +++ b/engines/kyra/sprites.h @@ -66,7 +66,7 @@ public: void updateSceneAnims(); void setupSceneAnims(); - void loadDAT(const char *filename, SceneExits &exits); + void loadDat(const char *filename, SceneExits &exits); void loadSceneShapes(); Anim _anims[MAX_NUM_ANIMS]; -- cgit v1.2.3