diff options
-rw-r--r-- | kyra/codecs.cpp | 73 | ||||
-rw-r--r-- | kyra/font.cpp | 44 | ||||
-rw-r--r-- | kyra/kyra.cpp | 68 | ||||
-rw-r--r-- | kyra/kyra.h | 20 | ||||
-rw-r--r-- | kyra/palette.cpp | 6 | ||||
-rw-r--r-- | kyra/resource.cpp | 22 | ||||
-rw-r--r-- | kyra/script_v1.cpp | 134 |
7 files changed, 168 insertions, 199 deletions
diff --git a/kyra/codecs.cpp b/kyra/codecs.cpp index 9046072c1a..dcdb2d7531 100644 --- a/kyra/codecs.cpp +++ b/kyra/codecs.cpp @@ -54,24 +54,19 @@ int Compression::decode80(const uint8* image_in, uint8* image_out) { uint16 code; uint16 count; - while (1) - { + while (1) { code = *readp++; - if (~code & 0x80) - { + if (~code & 0x80) { //bit 7 = 0 //command 0 (0cccpppp p): copy count = (code >> 4) + 3; copyp = writep - (((code & 0xf) << 8) + *readp++); while (count--) *writep++ = *copyp++; - } - else - { + } else { //bit 7 = 1 count = code & 0x3f; - if (~code & 0x40) - { + if (~code & 0x40) { //bit 6 = 0 if (!count) //end of image @@ -79,12 +74,9 @@ int Compression::decode80(const uint8* image_in, uint8* image_out) { //command 1 (10cccccc): copy while (count--) *writep++ = *readp++; - } - else - { + } else { //bit 6 = 1 - if (count < 0x3e) - { + if (count < 0x3e) { //command 2 (11cccccc p p): copy count += 3; @@ -94,9 +86,7 @@ int Compression::decode80(const uint8* image_in, uint8* image_out) { memcpy(writep, copyp, count); writep += count; copyp += count; - } - else if (count == 0x3e) - { + } else if (count == 0x3e) { //command 3 (11111110 c c v): fill count = READ_LE_UINT16(readp); @@ -104,9 +94,7 @@ int Compression::decode80(const uint8* image_in, uint8* image_out) { code = *readp++; memset(writep, code, count); writep += count; - } - else - { + } else { //command 4 (copy 11111111 c c p p): copy count = READ_LE_UINT16(readp); @@ -146,57 +134,44 @@ int Compression::decode40(const uint8* image_in, uint8* image_out) { while (1) { code = *readp++; - if (~code & 0x80) - { + if (~code & 0x80) { //bit 7 = 0 - if (!code) - { + if (!code) { //command 0 (00000000 c v): fill count = *readp++; code = *readp++; while (count--) *writep++ ^= code; - } - else - { + } else { //command 1 (0ccccccc): copy count = code; while (count--) *writep++ ^= *readp++; } - } - else - { + } else { //bit 7 = 1 - if (!(count = code & 0x7f)) - { + if (!(count = code & 0x7f)) { count = READ_LE_UINT16(readp); readp += 2; code = count >> 8; - if (~code & 0x80) - { + if (~code & 0x80) { //bit 7 = 0 //command 2 (10000000 c 0ccccccc): skip if (!count) // end of image break; writep += count; - } - else - { + } else { //bit 7 = 1 count &= 0x3fff; - if (~code & 0x40) - { + if (~code & 0x40) { //bit 6 = 0 //command 3 (10000000 c 10cccccc): copy while (count--) *writep++ ^= *readp++; - } - else - { + } else { //bit 6 = 1 //command 4 (10000000 c 11cccccc v): fill code = *readp++; @@ -204,8 +179,7 @@ int Compression::decode40(const uint8* image_in, uint8* image_out) { *writep++ ^= code; } } - } - else //command 5 (1ccccccc): skip + } else //command 5 (1ccccccc): skip writep += count; } } @@ -232,23 +206,18 @@ int Compression::decode3(const uint8* image_in, uint8* image_out, int size) 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) - { + } else if (code == 0) { // Fill(1) count = READ_BE_UINT16(readp); readp += 2; code = *readp++; while (count--) *writep++ = (uint8)code; - } - else if (code < 0) // Fill (2) - { + } else if (code < 0) { // Fill (2) count = -code; code = *readp++; while (count--) diff --git a/kyra/font.cpp b/kyra/font.cpp index 2131774073..c802fcb2e3 100644 --- a/kyra/font.cpp +++ b/kyra/font.cpp @@ -206,20 +206,20 @@ namespace Kyra { for (uint8 yadd = 0; yadd < height; ++yadd) { for (uint8 xadd = 0; xadd < width; ++xadd) { switch(*src) { - case 1: - plane[(y + yadd) * planewidth + x + xadd] = color; + case 1: + plane[(y + yadd) * planewidth + x + xadd] = color; break; - case 2: - plane[(y + yadd) * planewidth + x + xadd] = 14; + case 2: + plane[(y + yadd) * planewidth + x + xadd] = 14; break; - case 3: - plane[(y + yadd) * planewidth + x + xadd] = 0; + case 3: + plane[(y + yadd) * planewidth + x + xadd] = 0; break; - default: - // nothing to do now + default: + // nothing to do now break; }; @@ -269,30 +269,30 @@ namespace Kyra { } switch(index) { - case 1: + case 1: #ifdef DUMP_FILES - fprintf(dump, "#"); + fprintf(dump, "#"); #endif - dst[yadd * newChar.width + xadd] = 1; + dst[yadd * newChar.width + xadd] = 1; break; - - case 2: + + case 2: #ifdef DUMP_FILES - fprintf(dump, "$"); + fprintf(dump, "$"); #endif - dst[yadd * newChar.width + xadd] = 2; + dst[yadd * newChar.width + xadd] = 2; break; - - case 3: + + case 3: #ifdef DUMP_FILES - fprintf(dump, "§"); + fprintf(dump, "§"); #endif - dst[yadd * newChar.width + xadd] = 3; + dst[yadd * newChar.width + xadd] = 3; break; - - default: + + default: #ifdef DUMP_FILES - fprintf(dump, "%d", index); + fprintf(dump, "%d", index); #endif break; }; diff --git a/kyra/kyra.cpp b/kyra/kyra.cpp index 38783bd01e..b4f53a7fef 100644 --- a/kyra/kyra.cpp +++ b/kyra/kyra.cpp @@ -34,32 +34,32 @@ #include "script.h" struct KyraGameSettings { - const char *name; - const char *description; - uint32 features; - const char *detectName; - GameSettings toGameSettings() const { - GameSettings dummy = { name, description, features }; - return dummy; - } + const char *name; + const char *description; + uint32 features; + const char *detectName; + GameSettings toGameSettings() const { + GameSettings dummy = { name, description, features }; + return dummy; + } }; static const KyraGameSettings kyra_settings[] = { - {"kyra1cd", "Legend of Kyrandia (CD)", GF_TALKIE & GF_KYRA1, "CHAPTER1.VRM"}, - {"kyra1", "Legend of Kyrandia (Floppy)", GF_FLOPPY & GF_KYRA1, "INTRO.SND"}, + {"kyra1cd", "Legend of Kyrandia (CD)", GF_TALKIE & GF_KYRA1, "CHAPTER1.VRM"}, + {"kyra1", "Legend of Kyrandia (Floppy)", GF_FLOPPY & GF_KYRA1, "INTRO.SND"}, { 0, 0, 0, 0} }; GameList Engine_KYRA_gameList() { - GameList games; - const KyraGameSettings *g = kyra_settings; + GameList games; + const KyraGameSettings *g = kyra_settings; - while (g->name) { - games.push_back(g->toGameSettings()); - g++; - } + while (g->name) { + games.push_back(g->toGameSettings()); + g++; + } - return games; + return games; } DetectedGameList Engine_KYRA_detectGames(const FSList &fslist) { @@ -79,7 +79,7 @@ DetectedGameList Engine_KYRA_detectGames(const FSList &fslist) { } } - return detectedGames; + return detectedGames; } Engine *Engine_KYRA_create(GameDetector *detector, OSystem *syst) { @@ -159,11 +159,11 @@ void KyraEngine::go() { updateScreen(); while (g_system->pollEvent(event)) { switch (event.event_code) { - case OSystem::EVENT_QUIT: - g_system->quit(); - break; - default: - break; + case OSystem::EVENT_QUIT: + g_system->quit(); + break; + default: + break; } } _system->delayMillis(10); @@ -175,23 +175,23 @@ void KyraEngine::shutdown() { } void KyraEngine::updateScreen(void) { - _system->copyRectToScreen(_screen, 320, 0, 0, 320, 240); - _system->updateScreen(); + _system->copyRectToScreen(_screen, 320, 0, 0, 320, 240); + _system->updateScreen(); } void KyraEngine::setCurrentPalette(Palette* pal, bool delNextTime) { -// if (_delPalNextTime) -// delete _currentPal; +// if (_delPalNextTime) +// delete _currentPal; -// _delPalNextTime = delNextTime; +// _delPalNextTime = delNextTime; -// _currentPal = pal; +// _currentPal = pal; - if (pal->getData()) { - _system->setPalette(pal->getData(), 0, 256); - } else { - warning("palette contains no data"); - } + if (pal->getData()) { + _system->setPalette(pal->getData(), 0, 256); + } else { + warning("palette contains no data"); + } } } // End of namespace KYRA diff --git a/kyra/kyra.h b/kyra/kyra.h index 14a5c7855e..2a6b5b1556 100644 --- a/kyra/kyra.h +++ b/kyra/kyra.h @@ -8,7 +8,7 @@ * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License @@ -48,23 +48,23 @@ public: void errorString( const char *buf_input, char *buf_output); void updateScreen(void); - void setCurrentPalette(Palette* pal, bool delNextTime = true); + void setCurrentPalette(Palette* pal, bool delNextTime = true); - Resourcemanager* resManager(void) { return _resMgr; } -// MidiDriver* midiDriver(void) { return _midiDriver; } + Resourcemanager* resManager(void) { return _resMgr; } +// MidiDriver* midiDriver(void) { return _midiDriver; } protected: void go(); void shutdown(); - Resourcemanager* _resMgr; + Resourcemanager* _resMgr; uint8 *_screen; - Font* _font; - CPSImage* _mouse; - CPSImage* _items; + Font* _font; + CPSImage* _mouse; + CPSImage* _items; - VMContext* _currentScript; // our current script - VMContext* _npcScript; // script from NPCs + VMContext* _currentScript; // our current script + VMContext* _npcScript; // script from NPCs }; } // End of namespace Kyra diff --git a/kyra/palette.cpp b/kyra/palette.cpp index a9836c8ef9..ee7826d127 100644 --- a/kyra/palette.cpp +++ b/kyra/palette.cpp @@ -71,9 +71,9 @@ namespace Kyra { currentposdst[2] = currentpossrc[2] << 2; currentpossrc += 3; currentposdst += 4; - } - - delete [] data; + } + + delete [] data; } } // end of namespace Kyra diff --git a/kyra/resource.cpp b/kyra/resource.cpp index d5d1809162..9e6afd80b8 100644 --- a/kyra/resource.cpp +++ b/kyra/resource.cpp @@ -36,8 +36,8 @@ namespace Kyra { // ugly a hardcoded list // TODO: use the FS Backend to get all .PAK Files and load them static const char* kyraFilelist[] = { - "A_E.PAK", "DAT.PAK", "F_L.PAK", "MAP_5.PAK", "MSC.PAK", "M_S.PAK", - "S_Z.PAK", "WSA1.PAK", "WSA2.PAK", "WSA3.PAK", "WSA4.PAK", "WSA5.PAK", + "A_E.PAK", "DAT.PAK", "F_L.PAK", "MAP_5.PAK", "MSC.PAK", "M_S.PAK", + "S_Z.PAK", "WSA1.PAK", "WSA2.PAK", "WSA3.PAK", "WSA4.PAK", "WSA5.PAK", "WSA6.PAK", "startup.pak", "intro1.pak", 0 }; @@ -45,7 +45,7 @@ namespace Kyra { // prefetch file PAKFile* file = new PAKFile(getPath() + kyraFilelist[tmp]); assert(file); - + if (file->isOpen() && file->isValid()) _pakfiles.push_back(file); else @@ -109,7 +109,7 @@ namespace Kyra { return buffer; } - Palette* Resourcemanager::loadPalette(const char* file) { + Palette* Resourcemanager::loadPalette(const char* file) { uint32 size = 0; uint8* buffer = 0; buffer = fileData(file, &size); @@ -146,11 +146,11 @@ namespace Kyra { return new WSAMovieV1(buffer, size); } - VMContext* Resourcemanager::loadScript(const char* file) { - VMContext* context = new VMContext(_engine); - context->loadScript(file); - return context; - } + VMContext* Resourcemanager::loadScript(const char* file) { + VMContext* context = new VMContext(_engine); + context->loadScript(file); + return context; + } Common::String Resourcemanager::getPath(void) { assert(_gameDir); @@ -223,7 +223,7 @@ namespace Kyra { _files.push_back(chunk); } _open = true; - } + } PAKFile::~PAKFile() { delete [] _buffer; @@ -231,7 +231,7 @@ namespace Kyra { _open = false; for (PAKFile_Iterate) { - delete *start; + delete *start; *start = 0; } } diff --git a/kyra/script_v1.cpp b/kyra/script_v1.cpp index a224107760..753d9484a3 100644 --- a/kyra/script_v1.cpp +++ b/kyra/script_v1.cpp @@ -115,21 +115,21 @@ namespace Kyra { void VMContext::c1_negate(void) { switch(_argument) { - case 0: - topStack() = !topStack(); + case 0: + topStack() = !topStack(); break; - - case 1: - topStack() = -topStack(); + + case 1: + topStack() = -topStack(); break; - - case 2: - topStack() = ~topStack(); + + case 2: + topStack() = ~topStack(); break; - - default: - debug("unkown negate instruction %d", _argument); - _error = true; + + default: + debug("unkown negate instruction %d", _argument); + _error = true; break; }; } @@ -142,76 +142,76 @@ namespace Kyra { y = popStack(); switch(_argument) { - case 0: - res = x && y; + case 0: + res = x && y; break; - - case 1: - res = x || y; + + case 1: + res = x || y; break; - - case 3: - res = x != y; + + case 3: + res = x != y; break; - - case 4: - res = x < y; + + case 4: + res = x < y; + break; + + case 5: + res = x <= y; break; - case 5: - res = x <= y; + case 6: + res = x > y; break; - - case 6: - res = x > y; + + case 7: + res = x >= y; break; - - case 7: - res = x >= y; + + case 8: + res = x + y; break; - case 8: - res = x + y; - break; - - case 9: - res = x - y; + case 9: + res = x - y; break; - - case 10: - res = x * y; + + case 10: + res = x * y; break; - - case 11: - res = x / y; + + case 11: + res = x / y; break; - - case 12: - res = x >> y; + + case 12: + res = x >> y; break; - - case 13: - res = x << y; + + case 13: + res = x << y; break; - - case 14: - res = x & y; + + case 14: + res = x & y; break; - - case 15: - res = x | y; + + case 15: + res = x | y; break; - - case 16: - res = x % y; + + case 16: + res = x % y; break; - - case 17: - res = x ^ y; + + case 17: + res = x ^ y; break; - - default: - debug("unknown evaluate command"); + + default: + debug("unknown evaluate command"); break; }; @@ -232,7 +232,7 @@ namespace Kyra { paramString(4), paramString(5)); } - void VMContext::o1_0x68(void) { - debug("o1_0x68 was called with param0: '%d' and param1: '%d'", param(0), param(1)); - } + void VMContext::o1_0x68(void) { + debug("o1_0x68 was called with param0: '%d' and param1: '%d'", param(0), param(1)); + } } // end of namespace Kyra |