aboutsummaryrefslogtreecommitdiff
path: root/engines/glk/magnetic
diff options
context:
space:
mode:
authorPaul Gilbert2019-05-05 18:16:27 +1000
committerPaul Gilbert2019-05-07 15:02:00 +1000
commit7c536e1026971bc83048582ea137f290e5328747 (patch)
treeb0f43b0b98c34999b2a545cadf9e5d299f55ebb8 /engines/glk/magnetic
parent724137d696f36a0630c4ec0ddeaea6312a041a8b (diff)
downloadscummvm-rg350-7c536e1026971bc83048582ea137f290e5328747.tar.gz
scummvm-rg350-7c536e1026971bc83048582ea137f290e5328747.tar.bz2
scummvm-rg350-7c536e1026971bc83048582ea137f290e5328747.zip
GLK: MAGNETIC: Graphics initialization
Diffstat (limited to 'engines/glk/magnetic')
-rw-r--r--engines/glk/magnetic/emu.cpp17
-rw-r--r--engines/glk/magnetic/graphics.cpp79
-rw-r--r--engines/glk/magnetic/magnetic.h37
3 files changed, 111 insertions, 22 deletions
diff --git a/engines/glk/magnetic/emu.cpp b/engines/glk/magnetic/emu.cpp
index b3d6445ed3..76d0fa754e 100644
--- a/engines/glk/magnetic/emu.cpp
+++ b/engines/glk/magnetic/emu.cpp
@@ -29,8 +29,8 @@ static const char *no_hints = "[Hints are not available.]\n";
static const char *not_supported = "[This function is not supported.]\n";
int Magnetic::ms_init(bool restarting) {
- byte header[42], header2[8];
- uint32 i, dict_size, string2_size, code_size, dec;
+ byte header[42];
+ uint32 i, j, dict_size, string2_size, code_size, dec;
ms_stop();
@@ -145,8 +145,7 @@ int Magnetic::ms_init(bool restarting) {
_hintFile.seek(0);
if (_hintFile.readUint32BE() == MKTAG('M', 'a', 'H', 't')) {
- byte buf[8];
- uint16 i, j, blkcnt, elcnt, ntype, elsize, conidx;
+ uint16 blkcnt, elcnt, ntype, elsize, conidx;
// Allocate memory for hints
hints = new ms_hint[MAX_HINTS];
@@ -210,12 +209,12 @@ int Magnetic::ms_init(bool restarting) {
if (!_gfxFile.isOpen() || _gfxFile.size() < 8)
return 1;
_gfxFile.seek(0);
- _gfxFile.read(header2, 8);
+ uint tag = _gfxFile.readUint32BE();
- if (version < 4 && READ_BE_UINT32(header2) == MKTAG('M', 'a', 'P', 'i'))
- return init_gfx1(header2);
- else if (version == 4 && READ_BE_UINT32(header2) == MKTAG('M', 'a', 'P', '2'))
- return init_gfx2(header2);
+ if (version < 4 && tag == MKTAG('M', 'a', 'P', 'i'))
+ return init_gfx1(_gfxFile.readUint32LE() - 8);
+ else if (version == 4 && tag == MKTAG('M', 'a', 'P', '2'))
+ return init_gfx2(_gfxFile.readUint16LE());
return 1;
}
diff --git a/engines/glk/magnetic/graphics.cpp b/engines/glk/magnetic/graphics.cpp
new file mode 100644
index 0000000000..d10dc3d1b7
--- /dev/null
+++ b/engines/glk/magnetic/graphics.cpp
@@ -0,0 +1,79 @@
+/* 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 "glk/magnetic/magnetic.h"
+
+namespace Glk {
+namespace Magnetic {
+
+
+byte Magnetic::init_gfx1(size_t size) {
+ if (!(gfx_buf = new byte[MAX_PICTURE_SIZE]))
+ return 1;
+
+ if (!(gfx_data = new byte[size])) {
+ delete[] gfx_buf;
+ gfx_buf = nullptr;
+ return 1;
+ }
+
+ if (_gfxFile.read(gfx_data, size) != size) {
+ delete[] gfx_data;
+ delete[] gfx_buf;
+ gfx_data = gfx_buf = nullptr;
+ return 1;
+ }
+
+ gfx_ver = 1;
+ return 2;
+}
+
+byte Magnetic::init_gfx2(size_t size) {
+ if (!(gfx_buf = new byte[MAX_PICTURE_SIZE])) {
+ return 1;
+ }
+
+ gfx2_hsize = size;
+ if (!(gfx2_hdr = new byte[gfx2_hsize])) {
+ delete[] gfx_buf;
+ gfx_buf = nullptr;
+ return 1;
+ }
+
+ if (_gfxFile.read(gfx2_hdr, gfx2_hsize) != gfx2_hsize) {
+ delete[] gfx_buf;
+ delete[] gfx2_hdr;
+ gfx_buf = nullptr;
+ gfx2_hdr = nullptr;
+ return 1;
+ }
+
+ gfx_ver = 2;
+ return 2;
+}
+
+void Magnetic::ms_showpic(int c, byte mode) {
+ // TODO
+}
+
+} // End of namespace Magnetic
+} // End of namespace Glk
diff --git a/engines/glk/magnetic/magnetic.h b/engines/glk/magnetic/magnetic.h
index a791ca806c..ebebbc1b24 100644
--- a/engines/glk/magnetic/magnetic.h
+++ b/engines/glk/magnetic/magnetic.h
@@ -84,6 +84,11 @@ private:
bool is_gamefile_valid();
/**
+ * \defgroup Emu
+ * @{
+ */
+
+ /**
* Loads the interpreter with a game
* @return 0 = failure, 1 = success(without graphics or graphics failed),
* 2 = success(with graphics)
@@ -105,7 +110,16 @@ private:
*/
void ms_freemem();
- // Graphics
+ /**@}*/
+
+ /**
+ * \defgroup Graphics support methods
+ * @{
+ */
+
+ byte init_gfx1(size_t size);
+
+ byte init_gfx2(size_t size);
/**
* Displays or hides a picture
@@ -114,28 +128,25 @@ private:
*
* @remarks For retrieving the raw data of a picture call ms_extract
*/
- void ms_showpic(int c, byte mode) {
- // TODO
- }
+ void ms_showpic(int c, byte mode);
void write_reg(int i, int s, uint32 val) {
// TODO
}
- // Sound
+ /**@}*/
+
+ /**
+ * \defgroup Sound support methods
+ * @{
+ */
+
void init_snd(uint param) {
// TODO
}
- byte init_gfx1(byte *header) {
- // TODO
- return 0;
- }
- byte init_gfx2(byte *header) {
- // TODO
- return 0;
- }
+ /**@}*/
public:
/**
* Constructor