aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorĽubomír Remák2018-02-14 21:41:09 +0100
committerEugene Sandulenko2018-08-25 23:12:01 +0200
commit95cd6b74426b555e58577be0c46006a60fd77979 (patch)
tree574a1eff3f142e92c1f9ef511f27acc5e9adb674 /engines
parent764ee3a5a3f9f600b8d369d8474d2702b22f73f7 (diff)
downloadscummvm-rg350-95cd6b74426b555e58577be0c46006a60fd77979.tar.gz
scummvm-rg350-95cd6b74426b555e58577be0c46006a60fd77979.tar.bz2
scummvm-rg350-95cd6b74426b555e58577be0c46006a60fd77979.zip
MUTATIONOFJB: Load and draw scene background
Diffstat (limited to 'engines')
-rw-r--r--engines/mutationofjb/encryptedfile.cpp64
-rw-r--r--engines/mutationofjb/encryptedfile.h32
-rw-r--r--engines/mutationofjb/module.mk4
-rw-r--r--engines/mutationofjb/mutationofjb.cpp24
-rw-r--r--engines/mutationofjb/mutationofjb.h7
-rw-r--r--engines/mutationofjb/room.cpp129
-rw-r--r--engines/mutationofjb/room.h49
7 files changed, 305 insertions, 4 deletions
diff --git a/engines/mutationofjb/encryptedfile.cpp b/engines/mutationofjb/encryptedfile.cpp
new file mode 100644
index 0000000000..0796811dda
--- /dev/null
+++ b/engines/mutationofjb/encryptedfile.cpp
@@ -0,0 +1,64 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * 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
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "encryptedfile.h"
+
+static const uint8 XOR_TABLE[] = {
+ 0x41, 0x2b, 0x7a, 0x0c, 0xc8, 0xe5, 0x0c, 0xde, 0x45, 0xa8, 0x00, 0xad,
+ 0x70, 0xac, 0x23, 0xe0, 0x0c, 0xde, 0xac, 0x16, 0xa1, 0x1a, 0x70, 0x17,
+ 0x1b, 0x90, 0x34, 0x6e, 0x53, 0xfe, 0xdd, 0x3c, 0xef, 0x74, 0x75, 0x3e,
+ 0x2e, 0xb0, 0x3d, 0x2b, 0x74, 0x6d, 0x59, 0xde, 0xc6, 0x20, 0xb8, 0xf3,
+ 0x7d, 0xfa, 0x4d, 0xbd, 0xdb, 0x3c, 0xc5, 0xcb, 0x57, 0x13, 0x40, 0x6b,
+ 0xb8, 0xad, 0xb9, 0xc1, 0x6a, 0x37, 0x39, 0x80, 0x94, 0xd3, 0xdf, 0x4b,
+ 0xe4, 0xe4, 0x7a, 0x4c, 0x0f, 0x21, 0x27, 0x9a, 0x7e, 0x52, 0x35, 0x58,
+ 0xb4, 0xbc, 0x5a, 0xc9, 0x48, 0x7f, 0xcc, 0xb6, 0x97, 0x7b, 0xf1, 0xd5,
+ 0x88, 0x8c, 0xa9, 0x27, 0xf7, 0x20, 0x68, 0x65, 0xad, 0x6f, 0x9e, 0x07,
+ 0xf8, 0xf6, 0x2c, 0x65, 0x4a, 0xe9, 0xd8, 0x13, 0x6a, 0xb5, 0x14, 0x6f,
+ 0x29, 0xdc, 0x68, 0xf8, 0xa0, 0xb6, 0x73, 0x03, 0x69, 0xe3, 0x4f, 0xb6,
+ 0x59, 0x79, 0xae, 0x93, 0xad, 0x40, 0x27, 0xd0, 0xb5, 0x7a, 0x68, 0x5d,
+ 0x5e, 0x19, 0x53, 0x4f, 0x40, 0x56, 0x3d, 0x10, 0xf8, 0x0a, 0xc6, 0x90,
+ 0x06, 0x45, 0x13, 0x4a, 0x6a, 0xfe, 0x56, 0xeb, 0xbc, 0xd9, 0xee, 0xe0,
+ 0x85, 0x5e, 0x98, 0x23, 0xf9, 0x19, 0x60, 0xf9, 0x7e, 0x8d, 0x61, 0xa0,
+ 0x7c, 0xe1, 0x84, 0xf2, 0x7a, 0xb8, 0xbe, 0x8e, 0x81, 0x9e, 0x87, 0x20,
+ 0x32, 0xf3, 0x8c, 0xb4, 0x2c, 0x4d, 0xc8, 0x50, 0x9b, 0xa5, 0x9c, 0x27,
+ 0x02, 0xd6, 0x7f, 0x2a, 0xaf, 0x46, 0x65, 0xd0, 0x6a, 0xae, 0xfa, 0x53,
+ 0x37, 0x6c, 0x49, 0xb9, 0x4d, 0xcd, 0x6c, 0x6b, 0xa7, 0x2d, 0x66, 0x32,
+ 0xb4, 0xf5, 0x41, 0xd5, 0x18, 0xc4, 0xfd, 0xbe, 0x8a, 0x47, 0x11, 0x50,
+ 0x3d, 0x97, 0x64, 0xda, 0x5a, 0x27, 0x18, 0x60, 0x78, 0x80, 0x86, 0x8a,
+ 0x2a, 0x72, 0x40, 0x89
+};
+
+namespace MutationOfJB {
+
+uint32 EncryptedFile::read(void *dataPtr, uint32 dataSize) {
+ uint8 xorPos = pos() % 256;
+ const uint32 readBytes = Common::File::read(dataPtr, dataSize);
+
+ for (uint32 i = 0; i < readBytes; ++i) {
+ static_cast<uint8 *>(dataPtr)[i] ^= XOR_TABLE[xorPos];
+ xorPos++;
+ }
+
+ return readBytes;
+}
+
+}
diff --git a/engines/mutationofjb/encryptedfile.h b/engines/mutationofjb/encryptedfile.h
new file mode 100644
index 0000000000..69f6f6251e
--- /dev/null
+++ b/engines/mutationofjb/encryptedfile.h
@@ -0,0 +1,32 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * 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
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/file.h"
+
+namespace MutationOfJB {
+
+class EncryptedFile : public Common::File {
+public:
+ virtual uint32 read(void *dataPtr, uint32 dataSize) override;
+};
+
+}
diff --git a/engines/mutationofjb/module.mk b/engines/mutationofjb/module.mk
index 2e28d41eee..fcb9478bb7 100644
--- a/engines/mutationofjb/module.mk
+++ b/engines/mutationofjb/module.mk
@@ -1,8 +1,10 @@
MODULE := engines/mutationofjb
MODULE_OBJS := \
+ encryptedfile.o \
detection.o \
- mutationofjb.o
+ mutationofjb.o \
+ room.o
# This module can be built as a plugin
ifeq ($(ENABLE_MUTATIONOFJB), DYNAMIC_PLUGIN)
diff --git a/engines/mutationofjb/mutationofjb.cpp b/engines/mutationofjb/mutationofjb.cpp
index f50ba70792..04068646e4 100644
--- a/engines/mutationofjb/mutationofjb.cpp
+++ b/engines/mutationofjb/mutationofjb.cpp
@@ -24,15 +24,23 @@
#include "common/debug.h"
#include "common/error.h"
+#include "common/system.h"
+#include "common/events.h"
+#include "graphics/screen.h"
#include "engines/util.h"
#include "mutationofjb/mutationofjb.h"
+#include "mutationofjb/room.h"
namespace MutationOfJB {
MutationOfJBEngine::MutationOfJBEngine(OSystem *syst)
-: Engine(syst), _console(nullptr) {
+: Engine(syst),
+ _console(nullptr),
+ _room(nullptr),
+ _screen(nullptr)
+{
debug("MutationOfJBEngine::MutationOfJBEngine");
}
@@ -41,10 +49,20 @@ MutationOfJBEngine::~MutationOfJBEngine() {
}
Common::Error MutationOfJBEngine::run() {
- initGraphics(320, 200, false);
- _console = new Console(this);
debug("MutationOfJBEngine::run");
+ initGraphics(320, 200);
+ _console = new Console(this);
+ _screen = new Graphics::Screen;
+ _room = new Room(_screen);
+ _room->load(13, false);
+
+ while(!shouldQuit()) {
+ Common::Event event;
+ while (_eventMan->pollEvent(event));
+ _system->delayMillis(100);
+ }
+
return Common::kNoError;
}
}
diff --git a/engines/mutationofjb/mutationofjb.h b/engines/mutationofjb/mutationofjb.h
index 1c87fe46f0..815baf8b5c 100644
--- a/engines/mutationofjb/mutationofjb.h
+++ b/engines/mutationofjb/mutationofjb.h
@@ -26,9 +26,14 @@
#include "engines/engine.h"
#include "gui/debugger.h"
+namespace Graphics {
+ class Screen;
+}
+
namespace MutationOfJB {
class Console;
+class Room;
class MutationOfJBEngine : public Engine {
public:
@@ -38,6 +43,8 @@ public:
virtual Common::Error run();
private:
Console *_console;
+ Room *_room;
+ Graphics::Screen *_screen;
};
class Console : public GUI::Debugger {
diff --git a/engines/mutationofjb/room.cpp b/engines/mutationofjb/room.cpp
new file mode 100644
index 0000000000..e927971858
--- /dev/null
+++ b/engines/mutationofjb/room.cpp
@@ -0,0 +1,129 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * 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
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "mutationofjb/room.h"
+#include "mutationofjb/encryptedfile.h"
+#include "graphics/screen.h"
+#include "engines/engine.h"
+#include "common/translation.h"
+
+namespace MutationOfJB {
+
+Room::Room(Graphics::Screen *screen) : _screen(screen) {}
+
+bool Room::load(uint8 roomNumber, bool roomB) {
+ EncryptedFile file;
+ Common::String fileName = Common::String::format("room%d%s.dat", roomNumber, roomB ? "b" : "");
+
+ file.open(fileName);
+
+ if (!file.isOpen()) {
+ Common::String errorMessage = Common::String::format(_("Unable to locate the '%s' engine data file."), fileName.c_str());
+ GUIErrorMessage(errorMessage);
+ warning("%s", errorMessage.c_str());
+
+ return false;
+ }
+
+ file.seek(0x80);
+
+ while (!file.eos()) {
+ // Record.
+ const uint32 length = file.readUint32LE();
+ uint8 info[4] = {0};
+ file.read(info, 4);
+
+ // TODO Find out what these are.
+ uint32 unknown;
+ unknown = file.readUint32LE();
+ unknown = file.readUint32LE();
+
+ // Subrecords.
+ if (info[0] == 0xFA && info[1] == 0xF1) {
+ for (int i = 0; i < info[2]; ++i) {
+ const uint32 subLength = file.readUint32LE();
+ const uint16 type = file.readUint16LE();
+
+ if (type == 0x0B) {
+ loadPalette(file);
+ } else if (type == 0x0F) {
+ loadBackground(file, subLength - 6);
+ }
+ }
+ }
+ }
+
+ file.close();
+
+ return true;
+}
+
+void Room::loadPalette(EncryptedFile &file) {
+ uint32 unknown;
+
+ // TODO Find out what this is.
+ unknown = file.readUint32LE();
+
+ uint8 palette[PALETTE_SIZE];
+ file.read(palette, PALETTE_SIZE);
+
+ for (int j = 0; j < PALETTE_SIZE; ++j) {
+ palette[j] <<= 2; // Uses 6-bit colors.
+ }
+
+ _screen->setPalette(palette);
+}
+
+void Room::loadBackground(EncryptedFile &file, uint32 size) {
+ _screen->clear();
+
+ uint8 * const pixels = static_cast<uint8 *>(_screen->getPixels());
+ uint8 *ptr = pixels;
+ uint32 readBytes = 0;
+
+ while (readBytes != size) {
+ uint8 no = file.readByte();
+ readBytes++;
+ while (no--) {
+ uint8 n = file.readByte();
+ readBytes++;
+ if (n < 0x80) {
+ // RLE - Copy color n times.
+ uint8 color = file.readByte();
+ readBytes++;
+ while(n--) {
+ *ptr++ = color;
+ }
+ } else {
+ // Take next 0x100 - n bytes as they are.
+ const uint32 rawlen = 0x100 - n;
+ file.read(ptr, rawlen);
+ readBytes += rawlen;
+ ptr += rawlen;
+ }
+ }
+ }
+
+ _screen->update();
+}
+
+}
diff --git a/engines/mutationofjb/room.h b/engines/mutationofjb/room.h
new file mode 100644
index 0000000000..7158580831
--- /dev/null
+++ b/engines/mutationofjb/room.h
@@ -0,0 +1,49 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * 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
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef MUTATIONOFJB_ROOM_H
+#define MUTATIONOFJB_ROOM_H
+
+#include "common/scummsys.h"
+
+namespace Graphics {
+ class Screen;
+}
+
+namespace MutationOfJB {
+
+class EncryptedFile;
+
+class Room {
+public:
+ Room(Graphics::Screen *screen);
+ bool load(uint8 roomNumber, bool roomB);
+private:
+ void loadPalette(EncryptedFile &file);
+ void loadBackground(EncryptedFile &file, uint32 size);
+
+ Graphics::Screen *_screen;
+};
+
+}
+
+#endif