GLK: ALAN2: Added missing main code file, hooked up to Alan2 engine skeleton
This commit is contained in:
parent
08bc570308
commit
ed21388e11
11 changed files with 2098 additions and 48 deletions
81
engines/glk/alan2/acode.cpp
Normal file
81
engines/glk/alan2/acode.cpp
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
/* 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
|
|
@ -23,15 +23,17 @@
|
||||||
#ifndef GLK_ALAN2_ACODE
|
#ifndef GLK_ALAN2_ACODE
|
||||||
#define GLK_ALAN2_ACODE
|
#define GLK_ALAN2_ACODE
|
||||||
|
|
||||||
|
#include "common/stream.h"
|
||||||
|
|
||||||
namespace Glk {
|
namespace Glk {
|
||||||
namespace Alan2 {
|
namespace Alan2 {
|
||||||
|
|
||||||
typedef size_t Aptr; /* Type for an ACODE memory address */
|
typedef size_t Aptr; /* Type for an ACODE memory address */
|
||||||
|
|
||||||
typedef unsigned int Aword; /* Type for an ACODE word */
|
typedef uint32 Aword; /* Type for an ACODE word */
|
||||||
typedef unsigned int Aaddr; /* Type for an ACODE address */
|
typedef uint32 Aaddr; /* Type for an ACODE address */
|
||||||
typedef unsigned int Abool; /* Type for an ACODE Boolean value */
|
typedef uint32 Abool; /* Type for an ACODE Boolean value */
|
||||||
typedef signed int Aint; /* Type for an ACODE Integer value */
|
typedef int32 Aint; /* Type for an ACODE Integer value */
|
||||||
typedef int CodeValue; /* Definition for the packing process */
|
typedef int CodeValue; /* Definition for the packing process */
|
||||||
|
|
||||||
#ifdef UNUSED
|
#ifdef UNUSED
|
||||||
|
@ -208,16 +210,16 @@ typedef enum VarClass {
|
||||||
#define I_OP(x) ((x&0x8000000)?(x)|0x0f0000000:(x)&0x0fffffff)
|
#define I_OP(x) ((x&0x8000000)?(x)|0x0f0000000:(x)&0x0fffffff)
|
||||||
|
|
||||||
|
|
||||||
typedef struct AcdHdr {
|
struct AcdHdr {
|
||||||
/* Important info */
|
/* Important info */
|
||||||
char vers[4]; /* 01 - Version of compiler */
|
char vers[4]; /* 01 - Version of compiler */
|
||||||
Aword size; /* 02 - Size of ACD-file in Awords */
|
Aword size; /* 02 - Size of ACD-file in Awords */
|
||||||
/* Options */
|
/* Options */
|
||||||
Abool pack; /* 03 - Is the text packed ? */
|
Abool pack; /* 03 - Is the text packed ? */
|
||||||
Aword paglen; /* 04 - Length of a page */
|
Aword paglen; /* 04 - Length of a page */
|
||||||
Aword pagwidth; /* 05 - and width */
|
Aword pagwidth; /* 05 - and width */
|
||||||
Aword debug; /* 06 - Option debug */
|
Aword debug; /* 06 - Option debug */
|
||||||
/* Data structures */
|
/* Data structures */
|
||||||
Aaddr dict; /* 07 - Dictionary */
|
Aaddr dict; /* 07 - Dictionary */
|
||||||
Aaddr oatrs; /* 08 - Object default attributes */
|
Aaddr oatrs; /* 08 - Object default attributes */
|
||||||
Aaddr latrs; /* 09 - Location default attributes */
|
Aaddr latrs; /* 09 - Location default attributes */
|
||||||
|
@ -233,7 +235,7 @@ typedef struct AcdHdr {
|
||||||
Aaddr init; /* 13 - String init table */
|
Aaddr init; /* 13 - String init table */
|
||||||
Aaddr start; /* 14 - Start code */
|
Aaddr start; /* 14 - Start code */
|
||||||
Aword msgs; /* 15 - Messages table */
|
Aword msgs; /* 15 - Messages table */
|
||||||
/* Miscellaneous */
|
/* Miscellaneous */
|
||||||
Aword objmin, objmax; /* 16 - Interval for object codes */
|
Aword objmin, objmax; /* 16 - Interval for object codes */
|
||||||
Aword actmin, actmax; /* 18 - Interval for actor codes */
|
Aword actmin, actmax; /* 18 - Interval for actor codes */
|
||||||
Aword cntmin, cntmax; /* 1a - Interval for container codes */
|
Aword cntmin, cntmax; /* 1a - Interval for container codes */
|
||||||
|
@ -246,7 +248,17 @@ typedef struct AcdHdr {
|
||||||
Aaddr freq; /* 26 - Address to Char freq's for coding */
|
Aaddr freq; /* 26 - Address to Char freq's for coding */
|
||||||
Aword acdcrc; /* 27 - Checksum for acd code (excl. hdr) */
|
Aword acdcrc; /* 27 - Checksum for acd code (excl. hdr) */
|
||||||
Aword txtcrc; /* 28 - Checksum for text data file */
|
Aword txtcrc; /* 28 - Checksum for text data file */
|
||||||
} AcdHdr;
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
AcdHdr();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the header from the passed stream
|
||||||
|
*/
|
||||||
|
void load(Common::SeekableReadStream &s);
|
||||||
|
};
|
||||||
|
|
||||||
/* Error message numbers */
|
/* Error message numbers */
|
||||||
typedef enum MsgKind {
|
typedef enum MsgKind {
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "glk/alan2/alan2.h"
|
#include "glk/alan2/alan2.h"
|
||||||
|
#include "glk/alan2/main.h"
|
||||||
#include "common/config-manager.h"
|
#include "common/config-manager.h"
|
||||||
#include "common/translation.h"
|
#include "common/translation.h"
|
||||||
#include "common/error.h"
|
#include "common/error.h"
|
||||||
|
@ -45,7 +46,16 @@ void Alan2::runGame() {
|
||||||
if (!is_gamefile_valid())
|
if (!is_gamefile_valid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// TODO
|
Common::String filename = getFilename();
|
||||||
|
while (filename.contains('.'))
|
||||||
|
filename.deleteLastChar();
|
||||||
|
advnam = filename.c_str();
|
||||||
|
|
||||||
|
codfil = &_gameFile;
|
||||||
|
strncpy(codfnm, getFilename().c_str(), 255);
|
||||||
|
codfnm[255] = '\0';
|
||||||
|
|
||||||
|
run();
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::Error Alan2::readSaveData(Common::SeekableReadStream *rs) {
|
Common::Error Alan2::readSaveData(Common::SeekableReadStream *rs) {
|
||||||
|
|
|
@ -65,6 +65,7 @@ static void switches(argc, argv)
|
||||||
char *argv[];
|
char *argv[];
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
#ifndef GLK
|
||||||
uint i;
|
uint i;
|
||||||
|
|
||||||
advnam = "";
|
advnam = "";
|
||||||
|
@ -111,6 +112,7 @@ static void switches(argc, argv)
|
||||||
advnam[strlen(advnam)-4] = '\0';
|
advnam[strlen(advnam)-4] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,9 @@
|
||||||
namespace Glk {
|
namespace Glk {
|
||||||
namespace Alan2 {
|
namespace Alan2 {
|
||||||
|
|
||||||
|
winid_t glkMainWin;
|
||||||
|
winid_t glkStatusWin;
|
||||||
|
|
||||||
void glkio_printf(char *fmt, ...) {
|
void glkio_printf(char *fmt, ...) {
|
||||||
va_list argp;
|
va_list argp;
|
||||||
va_start(argp, fmt);
|
va_start(argp, fmt);
|
||||||
|
|
|
@ -31,8 +31,8 @@
|
||||||
namespace Glk {
|
namespace Glk {
|
||||||
namespace Alan2 {
|
namespace Alan2 {
|
||||||
|
|
||||||
winid_t glkMainWin;
|
extern winid_t glkMainWin;
|
||||||
winid_t glkStatusWin;
|
extern winid_t glkStatusWin;
|
||||||
|
|
||||||
/* NB: this header must be included in any file which calls print() */
|
/* NB: this header must be included in any file which calls print() */
|
||||||
|
|
||||||
|
|
1926
engines/glk/alan2/main.cpp
Normal file
1926
engines/glk/alan2/main.cpp
Normal file
File diff suppressed because it is too large
Load diff
|
@ -65,6 +65,7 @@ extern int dictsize; /* Number of entries in dictionary */
|
||||||
/* The text and message file */
|
/* The text and message file */
|
||||||
extern Common::File *txtfil;
|
extern Common::File *txtfil;
|
||||||
extern Common::WriteStream *logfil;
|
extern Common::WriteStream *logfil;
|
||||||
|
extern Common::SeekableReadStream *codfil;
|
||||||
|
|
||||||
#undef ftell
|
#undef ftell
|
||||||
#undef fgetc
|
#undef fgetc
|
||||||
|
@ -79,7 +80,8 @@ extern Common::WriteStream *logfil;
|
||||||
|
|
||||||
|
|
||||||
/* File names */
|
/* File names */
|
||||||
extern char *advnam;
|
extern const char *advnam;
|
||||||
|
extern char codfnm[256];
|
||||||
|
|
||||||
/* Screen formatting info */
|
/* Screen formatting info */
|
||||||
extern int col, lin;
|
extern int col, lin;
|
||||||
|
|
|
@ -30,6 +30,17 @@
|
||||||
namespace Glk {
|
namespace Glk {
|
||||||
namespace Alan2 {
|
namespace Alan2 {
|
||||||
|
|
||||||
|
#ifdef GLK
|
||||||
|
extern void fprintf(Common::WriteStream *ws, const char *fmt, ...) {
|
||||||
|
va_list args;
|
||||||
|
va_start(args, fmt);
|
||||||
|
Common::String s = Common::String::vformat(fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
ws->write(s.c_str(), s.size());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _PROTOTYPES_
|
#ifdef _PROTOTYPES_
|
||||||
extern void syserr(char str[]);
|
extern void syserr(char str[]);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "common/scummsys.h"
|
#include "common/scummsys.h"
|
||||||
|
#include "common/stream.h"
|
||||||
|
|
||||||
namespace Glk {
|
namespace Glk {
|
||||||
namespace Alan2 {
|
namespace Alan2 {
|
||||||
|
@ -55,7 +56,7 @@ namespace Alan2 {
|
||||||
#undef rand
|
#undef rand
|
||||||
#define rand() g_vm->getRandomNumber(0x7fffffff)
|
#define rand() g_vm->getRandomNumber(0x7fffffff)
|
||||||
#undef fprintf
|
#undef fprintf
|
||||||
#define fprintf(FP, STR) FP->write(STR, strlen(STR) + 1)
|
extern void fprintf(Common::WriteStream *ws, const char *fmt, ...);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Place definitions of OS and compiler here if necessary */
|
/* Place definitions of OS and compiler here if necessary */
|
||||||
|
|
|
@ -31,6 +31,7 @@ MODULE_OBJS := \
|
||||||
advsys/game.o \
|
advsys/game.o \
|
||||||
advsys/glk_interface.o \
|
advsys/glk_interface.o \
|
||||||
advsys/vm.o \
|
advsys/vm.o \
|
||||||
|
alan2/acode.o \
|
||||||
alan2/alan2.o \
|
alan2/alan2.o \
|
||||||
alan2/detection.o \
|
alan2/detection.o \
|
||||||
alan2/alan_version.o \
|
alan2/alan_version.o \
|
||||||
|
@ -41,6 +42,7 @@ MODULE_OBJS := \
|
||||||
alan2/glkio.o \
|
alan2/glkio.o \
|
||||||
alan2/glkstart.o \
|
alan2/glkstart.o \
|
||||||
alan2/inter.o \
|
alan2/inter.o \
|
||||||
|
alan2/main.o \
|
||||||
alan2/params.o \
|
alan2/params.o \
|
||||||
alan2/parse.o \
|
alan2/parse.o \
|
||||||
alan2/readline.o \
|
alan2/readline.o \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue