aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/glk/alan2/acode.cpp81
-rw-r--r--engines/glk/alan2/acode.h16
-rw-r--r--engines/glk/alan2/alan2.cpp2
-rw-r--r--engines/glk/alan2/main.cpp16
-rw-r--r--engines/glk/alan2/main.h2
-rw-r--r--engines/glk/module.mk1
6 files changed, 19 insertions, 99 deletions
diff --git a/engines/glk/alan2/acode.cpp b/engines/glk/alan2/acode.cpp
deleted file mode 100644
index b842c81ff2..0000000000
--- a/engines/glk/alan2/acode.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/* 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/alan2/acode.h"
-
-namespace Glk {
-namespace Alan2 {
-
-AcdHdr::AcdHdr() : size(0), pack(0), paglen(0), pagwidth(0), debug(0), dict(0), oatrs(0),
- latrs(0), aatrs(0), acts(0), objs(0), locs(0), stxs(0), vrbs(0), evts(0),
- cnts(0), ruls(0), init(0), start(0), msgs(0), objmin(0), objmax(0), actmin(0),
- actmax(0), cntmin(0), cntmax(0), locmin(0), locmax(0), dirmin(0), dirmax(0),
- evtmin(0), evtmax(0), rulmin(0), rulmax(0), maxscore(0), scores(0),
- freq(0), acdcrc(0), txtcrc(0) {
- vers[0] = vers[1] = vers[2] = vers[3] = 0;
-}
-
-void AcdHdr::load(Common::SeekableReadStream &s) {
- s.read(vers, 4);
- size = s.readUint32LE();
- pack = s.readUint32LE();
- paglen = s.readUint32LE();
- pagwidth = s.readUint32LE();
- debug = s.readUint32LE();
- dict = s.readUint32LE();
- oatrs = s.readUint32LE();
- latrs = s.readUint32LE();
- aatrs = s.readUint32LE();
- acts = s.readUint32LE();
- objs = s.readUint32LE();
- locs = s.readUint32LE();
- stxs = s.readUint32LE();
- vrbs = s.readUint32LE();
- evts = s.readUint32LE();
- cnts = s.readUint32LE();
- ruls = s.readUint32LE();
- init = s.readUint32LE();
- start = s.readUint32LE();
- msgs = s.readUint32LE();
- objmin = s.readUint32LE();
- objmax = s.readUint32LE();
- actmin = s.readUint32LE();
- actmax = s.readUint32LE();
- cntmin = s.readUint32LE();
- cntmax = s.readUint32LE();
- locmin = s.readUint32LE();
- locmax = s.readUint32LE();
- dirmin = s.readUint32LE();
- dirmax = s.readUint32LE();
- evtmin = s.readUint32LE();
- evtmax = s.readUint32LE();
- rulmin = s.readUint32LE();
- rulmax = s.readUint32LE();
- maxscore = s.readUint32LE();
- scores = s.readUint32LE();
- freq = s.readUint32LE();
- acdcrc = s.readUint32LE();
- txtcrc = s.readUint32LE();
-}
-
-} // End of namespace Alan2
-} // End of namespace Glk
diff --git a/engines/glk/alan2/acode.h b/engines/glk/alan2/acode.h
index fff5144298..ef218dd3a6 100644
--- a/engines/glk/alan2/acode.h
+++ b/engines/glk/alan2/acode.h
@@ -209,7 +209,11 @@ typedef enum VarClass {
#define I_CLASS(x) ((x)>>28)
#define I_OP(x) ((x&0x8000000)?(x)|0x0f0000000:(x)&0x0fffffff)
+#include "common/pack-start.h" // START STRUCT PACKING
+/**
+ * Game header
+ */
struct AcdHdr {
/* Important info */
char vers[4]; /* 01 - Version of compiler */
@@ -248,17 +252,9 @@ struct AcdHdr {
Aaddr freq; /* 26 - Address to Char freq's for coding */
Aword acdcrc; /* 27 - Checksum for acd code (excl. hdr) */
Aword txtcrc; /* 28 - Checksum for text data file */
+} PACKED_STRUCT;
- /**
- * Constructor
- */
- AcdHdr();
-
- /**
- * Loads the header from the passed stream
- */
- void load(Common::SeekableReadStream &s);
-};
+#include "common/pack-end.h" // END STRUCT PACKING
/* Error message numbers */
typedef enum MsgKind {
diff --git a/engines/glk/alan2/alan2.cpp b/engines/glk/alan2/alan2.cpp
index fec1c62a40..5a00464f0a 100644
--- a/engines/glk/alan2/alan2.cpp
+++ b/engines/glk/alan2/alan2.cpp
@@ -55,7 +55,7 @@ void Alan2::runGame() {
strncpy(codfnm, getFilename().c_str(), 255);
codfnm[255] = '\0';
- run();
+ Glk::Alan2::run();
}
Common::Error Alan2::readSaveData(Common::SeekableReadStream *rs) {
diff --git a/engines/glk/alan2/main.cpp b/engines/glk/alan2/main.cpp
index d2e8323e2c..196ff908ff 100644
--- a/engines/glk/alan2/main.cpp
+++ b/engines/glk/alan2/main.cpp
@@ -66,7 +66,7 @@ Aword *memory;
//static AcdHdr dummyHeader; /* Dummy to use until memory allocated */
AcdHdr *header;
-int memTop = 0; /* Top of load memory */
+int memTop; /* Top of load memory */
int conjWord; /* First conjunction in dictonary, for ',' */
@@ -217,12 +217,15 @@ void usage()
*/
#ifdef _PROTOTYPES_
-void syserr(char *str)
+void syserr(const char *str)
#else
void syserr(str)
char *str;
#endif
{
+#ifdef GLK
+ ::error("%s", str);
+#else
output("$n$nAs you enter the twilight zone of Adventures, you stumble \
and fall to your knees. In front of you, you can vaguely see the outlines \
of an Adventure that never was.$n$nSYSTEM ERROR: ");
@@ -247,6 +250,7 @@ of an Adventure that never was.$n$nSYSTEM ERROR: ");
#endif
terminate(0);
+#endif
}
@@ -1515,8 +1519,10 @@ static void load()
int i;
char err[100];
+ Aword *ptr = (Aword *)&tmphdr;
codfil->seek(0);
- tmphdr.load(*codfil);
+ for (i = 0; i < sizeof(tmphdr) / sizeof(Aword); ++i, ++ptr)
+ *ptr = codfil->readUint32LE();
checkvers(&tmphdr);
/* Allocate and load memory */
@@ -1535,14 +1541,14 @@ static void load()
#endif
memory = (Aword *)allocate(tmphdr.size * sizeof(Aword));
}
+ memTop = tmphdr.size;
header = (AcdHdr *) addrTo(0);
if ((tmphdr.size * sizeof(Aword)) > codfil->size())
::error("Header size is greater than filesize");
codfil->seek(0);
- Aword *ptr = addrTo(0);
- for (int idx = 0; idx < tmphdr.size; ++idx, ++ptr)
+ for (i = 0, ptr = memory; i < tmphdr.size; ++i, ++ptr)
*ptr = codfil->readUint32LE();
/* Calculate checksum */
diff --git a/engines/glk/alan2/main.h b/engines/glk/alan2/main.h
index 7262a32c05..c72549f3fb 100644
--- a/engines/glk/alan2/main.h
+++ b/engines/glk/alan2/main.h
@@ -103,7 +103,7 @@ extern void *allocate(unsigned long len);
extern void terminate(int code);
extern void usage(void);
extern void error(MsgKind msg);
-extern void syserr(char *msg);
+extern void syserr(const char *msg);
extern void statusline(void);
extern void output(char string[]);
extern void prmsg(MsgKind msg);
diff --git a/engines/glk/module.mk b/engines/glk/module.mk
index 3190b09ee6..49f44ade60 100644
--- a/engines/glk/module.mk
+++ b/engines/glk/module.mk
@@ -31,7 +31,6 @@ MODULE_OBJS := \
advsys/game.o \
advsys/glk_interface.o \
advsys/vm.o \
- alan2/acode.o \
alan2/alan2.o \
alan2/detection.o \
alan2/alan_version.o \