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
|
||||
#define GLK_ALAN2_ACODE
|
||||
|
||||
#include "common/stream.h"
|
||||
|
||||
namespace Glk {
|
||||
namespace Alan2 {
|
||||
|
||||
typedef size_t Aptr; /* Type for an ACODE memory address */
|
||||
|
||||
typedef unsigned int Aword; /* Type for an ACODE word */
|
||||
typedef unsigned int Aaddr; /* Type for an ACODE address */
|
||||
typedef unsigned int Abool; /* Type for an ACODE Boolean value */
|
||||
typedef signed int Aint; /* Type for an ACODE Integer value */
|
||||
typedef uint32 Aword; /* Type for an ACODE word */
|
||||
typedef uint32 Aaddr; /* Type for an ACODE address */
|
||||
typedef uint32 Abool; /* Type for an ACODE Boolean value */
|
||||
typedef int32 Aint; /* Type for an ACODE Integer value */
|
||||
typedef int CodeValue; /* Definition for the packing process */
|
||||
|
||||
#ifdef UNUSED
|
||||
|
@ -208,45 +210,55 @@ typedef enum VarClass {
|
|||
#define I_OP(x) ((x&0x8000000)?(x)|0x0f0000000:(x)&0x0fffffff)
|
||||
|
||||
|
||||
typedef struct AcdHdr {
|
||||
/* Important info */
|
||||
char vers[4]; /* 01 - Version of compiler */
|
||||
Aword size; /* 02 - Size of ACD-file in Awords */
|
||||
/* Options */
|
||||
Abool pack; /* 03 - Is the text packed ? */
|
||||
Aword paglen; /* 04 - Length of a page */
|
||||
Aword pagwidth; /* 05 - and width */
|
||||
Aword debug; /* 06 - Option debug */
|
||||
/* Data structures */
|
||||
Aaddr dict; /* 07 - Dictionary */
|
||||
Aaddr oatrs; /* 08 - Object default attributes */
|
||||
Aaddr latrs; /* 09 - Location default attributes */
|
||||
Aaddr aatrs; /* 0a - Actor default attributes */
|
||||
Aaddr acts; /* 0b - Actor table */
|
||||
Aaddr objs; /* 0c - Object table */
|
||||
Aaddr locs; /* 0d - Location table */
|
||||
Aaddr stxs; /* 0e - Syntax table */
|
||||
Aaddr vrbs; /* 0f - Verb table */
|
||||
Aaddr evts; /* 10 - Event table */
|
||||
Aaddr cnts; /* 11 - Container table */
|
||||
Aaddr ruls; /* 12 - Rule table */
|
||||
Aaddr init; /* 13 - String init table */
|
||||
Aaddr start; /* 14 - Start code */
|
||||
Aword msgs; /* 15 - Messages table */
|
||||
/* Miscellaneous */
|
||||
Aword objmin, objmax; /* 16 - Interval for object codes */
|
||||
Aword actmin, actmax; /* 18 - Interval for actor codes */
|
||||
Aword cntmin, cntmax; /* 1a - Interval for container codes */
|
||||
Aword locmin, locmax; /* 1c - Interval for location codes */
|
||||
Aword dirmin, dirmax; /* 1e - Interval for direction codes */
|
||||
Aword evtmin, evtmax; /* 20 - Interval for event codes */
|
||||
Aword rulmin, rulmax; /* 22 - Interval for rule codes */
|
||||
Aword maxscore; /* 24 - Maximum score */
|
||||
Aaddr scores; /* 25 - Score table */
|
||||
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 */
|
||||
} AcdHdr;
|
||||
struct AcdHdr {
|
||||
/* Important info */
|
||||
char vers[4]; /* 01 - Version of compiler */
|
||||
Aword size; /* 02 - Size of ACD-file in Awords */
|
||||
/* Options */
|
||||
Abool pack; /* 03 - Is the text packed ? */
|
||||
Aword paglen; /* 04 - Length of a page */
|
||||
Aword pagwidth; /* 05 - and width */
|
||||
Aword debug; /* 06 - Option debug */
|
||||
/* Data structures */
|
||||
Aaddr dict; /* 07 - Dictionary */
|
||||
Aaddr oatrs; /* 08 - Object default attributes */
|
||||
Aaddr latrs; /* 09 - Location default attributes */
|
||||
Aaddr aatrs; /* 0a - Actor default attributes */
|
||||
Aaddr acts; /* 0b - Actor table */
|
||||
Aaddr objs; /* 0c - Object table */
|
||||
Aaddr locs; /* 0d - Location table */
|
||||
Aaddr stxs; /* 0e - Syntax table */
|
||||
Aaddr vrbs; /* 0f - Verb table */
|
||||
Aaddr evts; /* 10 - Event table */
|
||||
Aaddr cnts; /* 11 - Container table */
|
||||
Aaddr ruls; /* 12 - Rule table */
|
||||
Aaddr init; /* 13 - String init table */
|
||||
Aaddr start; /* 14 - Start code */
|
||||
Aword msgs; /* 15 - Messages table */
|
||||
/* Miscellaneous */
|
||||
Aword objmin, objmax; /* 16 - Interval for object codes */
|
||||
Aword actmin, actmax; /* 18 - Interval for actor codes */
|
||||
Aword cntmin, cntmax; /* 1a - Interval for container codes */
|
||||
Aword locmin, locmax; /* 1c - Interval for location codes */
|
||||
Aword dirmin, dirmax; /* 1e - Interval for direction codes */
|
||||
Aword evtmin, evtmax; /* 20 - Interval for event codes */
|
||||
Aword rulmin, rulmax; /* 22 - Interval for rule codes */
|
||||
Aword maxscore; /* 24 - Maximum score */
|
||||
Aaddr scores; /* 25 - Score table */
|
||||
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 */
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
AcdHdr();
|
||||
|
||||
/**
|
||||
* Loads the header from the passed stream
|
||||
*/
|
||||
void load(Common::SeekableReadStream &s);
|
||||
};
|
||||
|
||||
/* Error message numbers */
|
||||
typedef enum MsgKind {
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
*/
|
||||
|
||||
#include "glk/alan2/alan2.h"
|
||||
#include "glk/alan2/main.h"
|
||||
#include "common/config-manager.h"
|
||||
#include "common/translation.h"
|
||||
#include "common/error.h"
|
||||
|
@ -45,7 +46,16 @@ void Alan2::runGame() {
|
|||
if (!is_gamefile_valid())
|
||||
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) {
|
||||
|
|
|
@ -65,6 +65,7 @@ static void switches(argc, argv)
|
|||
char *argv[];
|
||||
#endif
|
||||
{
|
||||
#ifndef GLK
|
||||
uint i;
|
||||
|
||||
advnam = "";
|
||||
|
@ -111,6 +112,7 @@ static void switches(argc, argv)
|
|||
advnam[strlen(advnam)-4] = '\0';
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
namespace Glk {
|
||||
namespace Alan2 {
|
||||
|
||||
winid_t glkMainWin;
|
||||
winid_t glkStatusWin;
|
||||
|
||||
void glkio_printf(char *fmt, ...) {
|
||||
va_list argp;
|
||||
va_start(argp, fmt);
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
namespace Glk {
|
||||
namespace Alan2 {
|
||||
|
||||
winid_t glkMainWin;
|
||||
winid_t glkStatusWin;
|
||||
extern winid_t glkMainWin;
|
||||
extern winid_t glkStatusWin;
|
||||
|
||||
/* 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 */
|
||||
extern Common::File *txtfil;
|
||||
extern Common::WriteStream *logfil;
|
||||
extern Common::SeekableReadStream *codfil;
|
||||
|
||||
#undef ftell
|
||||
#undef fgetc
|
||||
|
@ -79,7 +80,8 @@ extern Common::WriteStream *logfil;
|
|||
|
||||
|
||||
/* File names */
|
||||
extern char *advnam;
|
||||
extern const char *advnam;
|
||||
extern char codfnm[256];
|
||||
|
||||
/* Screen formatting info */
|
||||
extern int col, lin;
|
||||
|
|
|
@ -30,6 +30,17 @@
|
|||
namespace Glk {
|
||||
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_
|
||||
extern void syserr(char str[]);
|
||||
#endif
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
*/
|
||||
|
||||
#include "common/scummsys.h"
|
||||
#include "common/stream.h"
|
||||
|
||||
namespace Glk {
|
||||
namespace Alan2 {
|
||||
|
@ -55,7 +56,7 @@ namespace Alan2 {
|
|||
#undef rand
|
||||
#define rand() g_vm->getRandomNumber(0x7fffffff)
|
||||
#undef fprintf
|
||||
#define fprintf(FP, STR) FP->write(STR, strlen(STR) + 1)
|
||||
extern void fprintf(Common::WriteStream *ws, const char *fmt, ...);
|
||||
#endif
|
||||
|
||||
/* Place definitions of OS and compiler here if necessary */
|
||||
|
|
|
@ -31,6 +31,7 @@ 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 \
|
||||
|
@ -41,6 +42,7 @@ MODULE_OBJS := \
|
|||
alan2/glkio.o \
|
||||
alan2/glkstart.o \
|
||||
alan2/inter.o \
|
||||
alan2/main.o \
|
||||
alan2/params.o \
|
||||
alan2/parse.o \
|
||||
alan2/readline.o \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue