mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-27 13:42:02 +00:00
GLK: MAGNETIC: Making functions all class methods, statics into class fields
This commit is contained in:
parent
9af0d15194
commit
9df3c85184
@ -1,469 +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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MAGNETIC_DEFS_H
|
||||
#define MAGNETIC_DEFS_H
|
||||
|
||||
#include "common/scummsys.h"
|
||||
#include "glk/magnetic/magnetic_types.h"
|
||||
|
||||
namespace Glk {
|
||||
namespace Magnetic {
|
||||
|
||||
/*****************************************************************************\
|
||||
* Type definitions for Magnetic
|
||||
*
|
||||
* Note: When running into trouble please ensure that these types have the
|
||||
* correct number of bits on your system !!!
|
||||
\*****************************************************************************/
|
||||
|
||||
typedef byte type8;
|
||||
typedef int8 type8s;
|
||||
typedef uint16 type16;
|
||||
typedef int16 type16s;
|
||||
typedef uint32 type32;
|
||||
typedef int32 type32s;
|
||||
|
||||
/****************************************************************************\
|
||||
* Compile time switches
|
||||
\****************************************************************************/
|
||||
|
||||
/* Switch: SAVEMEM
|
||||
Purpose: Magnetic loads a complete graphics file into memory by default.
|
||||
Setting this switch you tell Magnetic to load images on request
|
||||
(saving memory, wasting load time)
|
||||
|
||||
#define SAVEMEM
|
||||
*/
|
||||
|
||||
/* Switch: NO_ANIMATION
|
||||
Purpose: By default Magnetic plays animated graphics.
|
||||
Setting this switch to ignore animations, Magnetic shows the
|
||||
static parts of the images anyway!
|
||||
|
||||
#define NO_ANIMATION
|
||||
*/
|
||||
|
||||
/****************************************************************************\
|
||||
* Abstract functions
|
||||
*
|
||||
* Note: These functions MUST be implemented by each port of Magnetic!
|
||||
\****************************************************************************/
|
||||
|
||||
/****************************************************************************\
|
||||
* Function: ms_load_file
|
||||
*
|
||||
* Purpose: Load a save game file and restore game
|
||||
*
|
||||
* Parameters: type8s* name zero terminated string of filename
|
||||
* typed by player
|
||||
* type8* ptr pointer to data to save
|
||||
* type16 size number of bytes to save
|
||||
*
|
||||
* Result: 0 is successful
|
||||
*
|
||||
* Note: You probably want to put in a file requester!
|
||||
\****************************************************************************/
|
||||
|
||||
extern type8 ms_load_file(const char *name, type8 *ptr, type16 size);
|
||||
|
||||
/****************************************************************************\
|
||||
* Function: ms_save_file
|
||||
*
|
||||
* Purpose: Save the current game to file
|
||||
*
|
||||
* Parameters: type8s* name zero terminated string of filename
|
||||
* typed by player
|
||||
* type8* ptr pointer to data to save
|
||||
* type16 size number of bytes to save
|
||||
*
|
||||
* Result: 0 is successful
|
||||
*
|
||||
* Note: You probably want to put in a file requester!
|
||||
\****************************************************************************/
|
||||
|
||||
extern type8 ms_save_file(const char *name, type8 *ptr, type16 size);
|
||||
|
||||
/****************************************************************************\
|
||||
* Function: ms_statuschar
|
||||
*
|
||||
* Purpose: Output a single character to the status bar
|
||||
*
|
||||
* Parameters: type8 c character to be printed
|
||||
*
|
||||
* Note: All characters are printed as provided except for:
|
||||
* 0x0A resets the x position to zero
|
||||
* 0x09 moves the cursor to the right half of the bar, ie 'width-11'
|
||||
\****************************************************************************/
|
||||
|
||||
extern void ms_statuschar(type8 c);
|
||||
|
||||
/****************************************************************************\
|
||||
* Function: ms_putchar
|
||||
*
|
||||
* Purpose: Output a single character to the game/text windows
|
||||
*
|
||||
* Parameters: type8 c character to be printed
|
||||
*
|
||||
* Note: It is highly recommended to buffer the output, see also ms_flush()
|
||||
\****************************************************************************/
|
||||
|
||||
extern void ms_putchar(type8 c);
|
||||
|
||||
/****************************************************************************\
|
||||
* Function: ms_flush
|
||||
*
|
||||
* Purpose: Flush the output buffer (if applicable)
|
||||
*
|
||||
* Note: see also ms_putchar
|
||||
\****************************************************************************/
|
||||
|
||||
extern void ms_flush(void);
|
||||
|
||||
/****************************************************************************\
|
||||
* Function: ms_getchar
|
||||
*
|
||||
* Purpose: Read user input, buffered
|
||||
*
|
||||
* Parameters: type8 trans if not 0, translate any #undo
|
||||
* input to a return code of 0
|
||||
*
|
||||
* Return: One character
|
||||
*
|
||||
* Note: The first time it is called a string should be read and then given
|
||||
* back one byte at a time (ie. one for each call) until a '\n' is
|
||||
* reached (which will be the last byte sent back before it all restarts)
|
||||
* Returning a zero means 'undo' and the rest of the line must then be
|
||||
* ignored.
|
||||
* Returning 1 means that the opcode should return immediately. This is
|
||||
* needed to prevent possible corruption of the game's memory in
|
||||
* interpreters which allow a new game to be loaded without restarting.
|
||||
\****************************************************************************/
|
||||
|
||||
extern type8 ms_getchar(type8 trans);
|
||||
|
||||
/****************************************************************************\
|
||||
* Function: ms_showpic
|
||||
*
|
||||
* Purpose: Displays or hides a picture
|
||||
*
|
||||
* Parameter: type32 c number of image to be displayed
|
||||
* type8 mode mode == 0 means gfx off,
|
||||
* mode == 1 gfx on thumbnails,
|
||||
* mode == 2 gfx on normal.
|
||||
*
|
||||
* Note: For retrieving the raw data of a picture call ms_extract (see below)
|
||||
\****************************************************************************/
|
||||
|
||||
extern void ms_showpic(type32 c, type8 mode);
|
||||
|
||||
/****************************************************************************\
|
||||
* Function: ms_fatal
|
||||
*
|
||||
* Purpose: Handle fatal interpreter error
|
||||
*
|
||||
* Parameter: type8s* txt message
|
||||
\****************************************************************************/
|
||||
|
||||
extern void ms_fatal(const char *txt);
|
||||
|
||||
/****************************************************************************\
|
||||
* Magnetic core functions
|
||||
*
|
||||
* Note: These functions SHOULD be used somewhere in your port!
|
||||
\****************************************************************************/
|
||||
|
||||
/****************************************************************************\
|
||||
* Function: ms_extract
|
||||
*
|
||||
* Purpose: Extract a picture and return a pointer to a raw bitmap
|
||||
*
|
||||
* Parameters: type32 c number of the picture
|
||||
* type16* w width of picture
|
||||
* type16* h height pf picture
|
||||
* type16* pal array for the palette (16 colours)
|
||||
* type8* is_anim 1 if animated picture, otherwise 0
|
||||
* OR null (!)
|
||||
*
|
||||
* Return: Pointer to bitmap data if successful, otherwise null (also if gfx
|
||||
* are disabled!)
|
||||
*
|
||||
* Note: All pictures have 16 colours and the palette entries use 3-bit RGB
|
||||
* encoded as 00000RRR0GGG0BBB, that is, bits 0-2 give the blue
|
||||
* component, bits 4-6 the green and bits 8-10 the red. The bitmap is
|
||||
* one byte per pixel, with each byte giving the pixel's index into the
|
||||
* palette. The data is given starting from the upper left corner. The
|
||||
* image buffer is reused when the next picture is requested, so take
|
||||
* care! More information on animated pictures are below!
|
||||
\****************************************************************************/
|
||||
|
||||
extern type8 *ms_extract(type32 c, type16 *w, type16 *h, type16 *pal, type8 *is_anim);
|
||||
|
||||
/****************************************************************************\
|
||||
* Magnetic animated pictures support
|
||||
*
|
||||
* Note: Some of the pictures for Wonderland and the Collection Volume 1 games
|
||||
* are animations. To detect these, pass a pointer to a type8 as the is_anim
|
||||
* argument to ms_extract().
|
||||
*
|
||||
* There are two types of animated images, however almost all images are type1.
|
||||
* A type1 image consists of four main elements:
|
||||
* 1) A static picture which is loaded straight at the beginning
|
||||
* 2) A set of frames with a mask. These frames are just "small pictures", which
|
||||
* are coded like the normal static pictures. The image mask determines
|
||||
* how the frame is removed after it has been displayed. A mask is exactly
|
||||
* 1/8 the size of the image and holds 1 bit per pixel, saying "remove pixel"
|
||||
* or leave pixel set when frame gets removed. It might be a good idea to check
|
||||
* your system documentation for masking operations as your system might be
|
||||
* able to use this mask data directly.
|
||||
* 3) Positioning tables. These hold animation sequences consisting of commands
|
||||
* like "Draw frame 12 at (123,456)"
|
||||
* 4) A playback script, which determines how to use the positioning tables.
|
||||
* These scripts are handled inside Magnetic, so no need to worry about.
|
||||
* However, details can be found in the ms_animate() function.
|
||||
*
|
||||
* A type2 image is like a type1 image, but it does not have a static
|
||||
* picture, nor does it have frame masking. It just consists of frames.
|
||||
*
|
||||
* How to support animations?
|
||||
* After getting is_anim == 1 you should call ms_animate() immediately, and at
|
||||
* regular intervals until ms_animate() returns 0. An appropriate interval
|
||||
* between calls is about 100 milliseconds.
|
||||
* Each call to ms_animate() will fill in the arguments with the address
|
||||
* and size of an array of ms_position structures (see below), each of
|
||||
* which holds an an animation frame number and x and y co-ordinates. To
|
||||
* display the animation, decode all the animation frames (discussed below)
|
||||
* from a single call to ms_animate() and display each one over the main picture.
|
||||
* If your port does not support animations, define NO_ANIMATION.
|
||||
\****************************************************************************/
|
||||
|
||||
/****************************************************************************\
|
||||
* Function: ms_animate
|
||||
*
|
||||
* Purpose: Generate the next frame of an animation
|
||||
*
|
||||
* Parameters: ms_position** positions array of ms_position structs
|
||||
* type16* count size of array
|
||||
*
|
||||
* Return: 1 if animation continues, 0 if animation is finfished
|
||||
*
|
||||
* Note: The positions array holds size ms_positions structures. BEFORE calling
|
||||
* ms_animate again, retrieve the frames for all the ms_positions
|
||||
* structures with ms_get_anim_frame and display each one on the static
|
||||
* main picture.
|
||||
\****************************************************************************/
|
||||
|
||||
extern type8 ms_animate(struct ms_position **positions, type16 *count);
|
||||
|
||||
/****************************************************************************\
|
||||
* Function: ms_get_anim_frame
|
||||
*
|
||||
* Purpose: Extracts the bitmap data of a single animation frame
|
||||
*
|
||||
* Parameters: type16s number number of frame (see ms_position struct)
|
||||
* type16* width width of frame
|
||||
* type16* height height of frame
|
||||
* type8** mask pointer to masking data, might be NULL
|
||||
*
|
||||
* Return: 1 if animation continues, 0 if animation is finfished
|
||||
*
|
||||
* Note: The format of the frame is identical to the main pictures' returned by
|
||||
* ms_extract. The mask has one-bit-per-pixel, determing how to handle the
|
||||
* removal of the frame.
|
||||
\****************************************************************************/
|
||||
|
||||
extern type8 *ms_get_anim_frame(type16s number, type16 *width, type16 *height, type8 **mask);
|
||||
|
||||
/****************************************************************************\
|
||||
* Function: ms_anim_is_repeating
|
||||
*
|
||||
* Purpose: Detects whether an animation is repeating
|
||||
*
|
||||
* Return: True if repeating
|
||||
\****************************************************************************/
|
||||
|
||||
extern type8 ms_anim_is_repeating(void);
|
||||
|
||||
/****************************************************************************\
|
||||
* Magnetic Windows hint support
|
||||
*
|
||||
* The windowed Magnetic Scolls games included online hints. To add support
|
||||
* for the hints to your magnetic port, you should implement the ms_showhints
|
||||
* function. It retrieves a pointer to an array of ms_hint structs
|
||||
* The root element is always hints[0]. The elcount determines the number
|
||||
* of items in this topic. You probably want to display those in some kind
|
||||
* of list interface. The content pointer points to the actual description of
|
||||
* the items, separated by '\0' terminators. The nodetype is 1 if the items are
|
||||
* "folders" and 2 if the items are hints. Hints should be displayed one after
|
||||
* another. For "folder" items, the links array holds the index of the hint in
|
||||
* the array which is to be displayed on selection. One hint block has exactly
|
||||
* one type. The parent element determines the "back" target.
|
||||
\****************************************************************************/
|
||||
|
||||
/****************************************************************************\
|
||||
* Function: ms_showhints
|
||||
* Purpose: Show the player a hint
|
||||
*
|
||||
* Parameters: ms_hint* hints pointer to array of ms_hint structs
|
||||
*
|
||||
* Return: 0 on error, 1 on success
|
||||
\****************************************************************************/
|
||||
|
||||
extern type8 ms_showhints(struct ms_hint *hints);
|
||||
|
||||
/****************************************************************************\
|
||||
* Magnetic Windows sound support
|
||||
*
|
||||
* Wonderland contains music scores that are played when entering specific
|
||||
* locations in the game. The music data are actually MIDI events and can be
|
||||
* played through normal MIDI devices. The original game plays the MIDI score
|
||||
* until the end, even if the location is changed while playing. The playback
|
||||
* tempo is not included with the MIDI data. The ms_sndextract function
|
||||
* returns a recommended tempo, however depending on the MIDI implementation
|
||||
* and operating system, you might need to adapt it.
|
||||
\****************************************************************************/
|
||||
|
||||
/****************************************************************************\
|
||||
* Function: ms_playmusic
|
||||
*
|
||||
* Purpose: Plays (or stops playing) a MIDI music score.
|
||||
*
|
||||
* Parameter: type8 * midi_data the MIDI data to play
|
||||
* type32 length the length of the MIDI data
|
||||
* type16 tempo the suggested tempo for playing
|
||||
*
|
||||
* Note: If midi_data is NULL, all that should happen is that any currently
|
||||
* playing music is stopped.
|
||||
* Note: The data returned contain a complete MIDI file header, so if pure
|
||||
* memory processing is not applicable you can write the data to a
|
||||
* temporary file and use external players or libraries.
|
||||
\****************************************************************************/
|
||||
|
||||
extern void ms_playmusic(type8 *midi_data, type32 length, type16 tempo);
|
||||
|
||||
/****************************************************************************\
|
||||
* Function: ms_init
|
||||
*
|
||||
* Purpose: Loads the interpreter with a game
|
||||
*
|
||||
* Parameters: type8s* name filename of story file
|
||||
* type8s* gfxname filename of graphics file (optional)
|
||||
* type8s* hntname filename of hints file (optional)
|
||||
* type8s* sndname filename of music file (optional)
|
||||
*
|
||||
* Return: 0 = failure
|
||||
* 1 = success (without graphics or graphics failed)
|
||||
* 2 = success (with graphics)
|
||||
*
|
||||
* Note: You must call this function before starting the ms_rungame loop
|
||||
\****************************************************************************/
|
||||
|
||||
extern type8 ms_init(const char *name, const char *gfxname, const char *hntname, const char *sndname);
|
||||
|
||||
/****************************************************************************\
|
||||
* Function: ms_rungame
|
||||
*
|
||||
* Purpose: Executes an interpreter instruction
|
||||
*
|
||||
* Return: True if successful
|
||||
*
|
||||
* Note: You must call this function in a loop like this:
|
||||
* while (running) {running=ms_rungame();}
|
||||
\****************************************************************************/
|
||||
|
||||
extern type8 ms_rungame(void);
|
||||
|
||||
/****************************************************************************\
|
||||
* Function: ms_freemen
|
||||
*
|
||||
* Purpose: Frees all allocated ressources
|
||||
\****************************************************************************/
|
||||
|
||||
extern void ms_freemem(void);
|
||||
|
||||
/****************************************************************************\
|
||||
* Function: ms_seed
|
||||
*
|
||||
* Purpose: Initializes the interpreter's random number generator with
|
||||
* the given seed
|
||||
*
|
||||
* Parameter: type32 seed seed
|
||||
\****************************************************************************/
|
||||
|
||||
extern void ms_seed(type32 seed);
|
||||
|
||||
/****************************************************************************\
|
||||
* Function: ms_is_running
|
||||
*
|
||||
* Purpose: Detects if game is running
|
||||
*
|
||||
* Return: True, if game is currently running
|
||||
\****************************************************************************/
|
||||
|
||||
extern type8 ms_is_running(void);
|
||||
|
||||
/****************************************************************************\
|
||||
* Function: ms_is_magwin
|
||||
*
|
||||
* Purpose: Detects Magnetic Windows games (Wonderland, Collection)
|
||||
*
|
||||
* Return: True, if Magnetic Windows game
|
||||
\****************************************************************************/
|
||||
|
||||
extern type8 ms_is_magwin(void);
|
||||
|
||||
/****************************************************************************\
|
||||
* Function: ms_stop
|
||||
*
|
||||
* Purpose: Stops further processing of opcodes
|
||||
\****************************************************************************/
|
||||
|
||||
extern void ms_stop(void);
|
||||
|
||||
/****************************************************************************\
|
||||
* Function: ms_status
|
||||
*
|
||||
* Purpose: Dumps interperetr state to stderr, ie. registers
|
||||
\****************************************************************************/
|
||||
|
||||
extern void ms_status(void);
|
||||
|
||||
/****************************************************************************\
|
||||
* Function: ms_count
|
||||
*
|
||||
* Purpose: Returns the number of executed intructions
|
||||
*
|
||||
* Return: Instruction count
|
||||
\****************************************************************************/
|
||||
|
||||
extern type32 ms_count(void);
|
||||
|
||||
extern void write(const char *fmt, ...);
|
||||
|
||||
extern void writeChar(char c);
|
||||
|
||||
extern void gms_main();
|
||||
|
||||
} // End of namespace Magnetic
|
||||
} // End of namespace Glk
|
||||
|
||||
#endif
|
@ -75,7 +75,7 @@ bool MagneticMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames
|
||||
gameFile.close();
|
||||
|
||||
// Check for known games
|
||||
const MagneticGameDescription *p = MAGNETIC_GAMES;
|
||||
const GlkDetectionEntry *p = MAGNETIC_GAMES;
|
||||
while (p->_gameId && (md5 != p->_md5 || filesize != p->_filesize))
|
||||
++p;
|
||||
|
||||
@ -99,5 +99,16 @@ void MagneticMetaEngine::detectClashes(Common::StringMap &map) {
|
||||
}
|
||||
}
|
||||
|
||||
const gms_game_table_t *gms_gameid_lookup_game(uint32 undo_size, uint32 undo_pc) {
|
||||
const gms_game_table_t *game;
|
||||
|
||||
for (game = GMS_GAME_TABLE; game->name; game++) {
|
||||
if (game->undo_size == undo_size && game->undo_pc == undo_pc)
|
||||
break;
|
||||
}
|
||||
|
||||
return game->name ? game : nullptr;
|
||||
}
|
||||
|
||||
} // End of namespace Magnetic
|
||||
} // End of namespace Glk
|
||||
|
@ -31,6 +31,18 @@
|
||||
namespace Glk {
|
||||
namespace Magnetic {
|
||||
|
||||
/**
|
||||
* The following game database is built from Generic/games.txt, and is used
|
||||
* to identify the game being run. Magnetic Scrolls games don't generally
|
||||
* supply a status line, so this data can be used instead.
|
||||
*/
|
||||
struct gms_game_table_t {
|
||||
const uint32 undo_size; ///< Header word at offset 0x22
|
||||
const uint32 undo_pc; ///< Header word at offset 0x26
|
||||
const char *const name; ///< Game title and platform
|
||||
};
|
||||
typedef const gms_game_table_t *gms_game_tableref_t;
|
||||
|
||||
/**
|
||||
* Meta engine for Magnetic interpreter
|
||||
*/
|
||||
@ -57,6 +69,12 @@ public:
|
||||
static void detectClashes(Common::StringMap &map);
|
||||
};
|
||||
|
||||
/**
|
||||
* Look up and return the game table entry given a game's undo size and
|
||||
* undo pc values. Returns the entry, or NULL if not found.
|
||||
*/
|
||||
extern const gms_game_table_t *gms_gameid_lookup_game(uint32 undo_size, uint32 undo_pc);
|
||||
|
||||
} // End of namespace Magnetic
|
||||
} // End of namespace Glk
|
||||
|
||||
|
@ -27,17 +27,6 @@
|
||||
namespace Glk {
|
||||
namespace Magnetic {
|
||||
|
||||
/**
|
||||
* Game description
|
||||
*/
|
||||
struct MagneticGameDescription {
|
||||
const char *const _gameId;
|
||||
const char *const _extra;
|
||||
const char *const _md5;
|
||||
size_t _filesize;
|
||||
Common::Language _language;
|
||||
};
|
||||
|
||||
const PlainGameDescriptor MAGNETIC_GAME_LIST[] = {
|
||||
{ "magnetic", "Magnetic Scrolls Game" },
|
||||
|
||||
@ -51,21 +40,62 @@ const PlainGameDescriptor MAGNETIC_GAME_LIST[] = {
|
||||
{ nullptr, nullptr }
|
||||
};
|
||||
|
||||
#define ENTRY0(ID, MD5, FILESIZE) { ID, nullptr, MD5, FILESIZE, Common::EN_ANY }
|
||||
#define ENTRY1(ID, EXTRA, MD5, FILESIZE) { ID, EXTRA, MD5, FILESIZE, Common::EN_ANY }
|
||||
#define TABLE_END_MARKER { nullptr, nullptr, nullptr, 0, Common::EN_ANY }
|
||||
const GlkDetectionEntry MAGNETIC_GAMES[] = {
|
||||
DT_ENTRY0("corruption", "313880cbe0f15bfa259ebaf228b4d0e9", 167466),
|
||||
DT_ENTRY1("corruption", "Collection", "6fe35b357fa0311450d3a9c809e60ba8", 177185),
|
||||
DT_ENTRY0("fish", "2efb8118f4cb9a36bb54646ce41a950e", 162858),
|
||||
DT_ENTRY1("fish", "Collection", "cfe333306597d36c8aa3fc64f6be94ba", 172517),
|
||||
DT_ENTRY0("guild", "bab78740d39ee5e058faf4912fdbf33d", 130858),
|
||||
DT_ENTRY1("guild", "Collection", "36af907a4ec9db909148f308287586f1", 141766),
|
||||
DT_ENTRY0("myth", "9c2a5272a9c0b1e173401ba4df32567a", 99370),
|
||||
DT_ENTRY0("pawn", "4a7847980f9e942acd7aa51ea12a6586", 103466),
|
||||
DT_ENTRY0("wonderland", "2cea8fccf42d570be8836416c2802613", 183916),
|
||||
|
||||
DT_END_MARKER
|
||||
};
|
||||
|
||||
const MagneticGameDescription MAGNETIC_GAMES[] = {
|
||||
ENTRY0("corruption", "313880cbe0f15bfa259ebaf228b4d0e9", 167466),
|
||||
ENTRY1("corruption", "Collection", "6fe35b357fa0311450d3a9c809e60ba8", 177185),
|
||||
ENTRY0("fish", "2efb8118f4cb9a36bb54646ce41a950e", 162858),
|
||||
ENTRY1("fish", "Collection", "cfe333306597d36c8aa3fc64f6be94ba", 172517),
|
||||
ENTRY0("guild", "bab78740d39ee5e058faf4912fdbf33d", 130858),
|
||||
ENTRY1("guild", "Collection", "36af907a4ec9db909148f308287586f1", 141766),
|
||||
ENTRY0("myth", "9c2a5272a9c0b1e173401ba4df32567a", 99370),
|
||||
ENTRY0("pawn", "4a7847980f9e942acd7aa51ea12a6586", 103466),
|
||||
ENTRY0("wonderland", "2cea8fccf42d570be8836416c2802613", 183916),
|
||||
TABLE_END_MARKER
|
||||
const gms_game_table_t GMS_GAME_TABLE[] = {
|
||||
{0x2100, 0x427e, "Corruption v1.11 (Amstrad CPC)"},
|
||||
{0x2100, 0x43a0, "Corruption v1.11 (Archimedes)"},
|
||||
{0x2100, 0x43a0, "Corruption v1.11 (DOS)"},
|
||||
{0x2100, 0x4336, "Corruption v1.11 (Commodore 64)"},
|
||||
{0x2100, 0x4222, "Corruption v1.11 (Spectrum +3)"},
|
||||
{0x2100, 0x4350, "Corruption v1.12 (Archimedes)"},
|
||||
{0x2500, 0x6624, "Corruption v1.12 (DOS, Magnetic Windows)"},
|
||||
|
||||
{0x2300, 0x3fa0, "Fish v1.02 (DOS)"},
|
||||
{0x2400, 0x4364, "Fish v1.03 (Spectrum +3)"},
|
||||
{0x2300, 0x3f72, "Fish v1.07 (Commodore 64)"},
|
||||
{0x2200, 0x3f9c, "Fish v1.08 (Archimedes)"},
|
||||
{0x2a00, 0x583a, "Fish v1.10 (DOS, Magnetic Windows)"},
|
||||
|
||||
{0x5000, 0x6c30, "Guild v1.0 (Amstrad CPC)"},
|
||||
{0x5000, 0x6cac, "Guild v1.0 (Commodore 64)"},
|
||||
{0x5000, 0x6d5c, "Guild v1.1 (DOS)"},
|
||||
{0x3300, 0x698a, "Guild v1.3 (Archimedes)"},
|
||||
{0x3200, 0x6772, "Guild v1.3 (Spectrum +3)"},
|
||||
{0x3400, 0x6528, "Guild v1.3 (DOS, Magnetic Windows)"},
|
||||
|
||||
{0x2b00, 0x488c, "Jinxter v1.05 (Commodore 64)"},
|
||||
{0x2c00, 0x4a08, "Jinxter v1.05 (DOS)"},
|
||||
{0x2c00, 0x487a, "Jinxter v1.05 (Spectrum +3)"},
|
||||
{0x2c00, 0x4a56, "Jinxter v1.10 (DOS)"},
|
||||
{0x2b00, 0x4924, "Jinxter v1.22 (Amstrad CPC)"},
|
||||
{0x2c00, 0x4960, "Jinxter v1.30 (Archimedes)"},
|
||||
|
||||
{0x1600, 0x3940, "Myth v1.0 (Commodore 64)"},
|
||||
{0x1500, 0x3a0a, "Myth v1.0 (DOS)"},
|
||||
|
||||
{0x3600, 0x42cc, "Pawn v2.3 (Amstrad CPC)"},
|
||||
{0x3600, 0x4420, "Pawn v2.3 (Archimedes)"},
|
||||
{0x3600, 0x3fb0, "Pawn v2.3 (Commodore 64)"},
|
||||
{0x3600, 0x4420, "Pawn v2.3 (DOS)"},
|
||||
{0x3900, 0x42e4, "Pawn v2.3 (Spectrum 128)"},
|
||||
{0x3900, 0x42f4, "Pawn v2.4 (Spectrum +3)"},
|
||||
|
||||
{0x3900, 0x75f2, "Wonderland v1.21 (DOS, Magnetic Windows)"},
|
||||
{0x3900, 0x75f8, "Wonderland v1.27 (Archimedes)"},
|
||||
{0, 0, NULL}
|
||||
};
|
||||
|
||||
} // End of namespace Magnetic
|
||||
|
@ -20,57 +20,20 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "glk/magnetic/defs.h"
|
||||
#include "glk/magnetic/magnetic_defs.h"
|
||||
#include "glk/magnetic/magnetic.h"
|
||||
#include "common/file.h"
|
||||
#include "common/textconsole.h"
|
||||
|
||||
namespace Glk {
|
||||
namespace Magnetic {
|
||||
|
||||
type32 dreg[8], areg[8], i_count, string_size, rseed = 0, pc, arg1i, mem_size;
|
||||
type16 properties, fl_sub, fl_tab, fl_size, fp_tab, fp_size;
|
||||
type8 zflag, nflag, cflag, vflag, byte1, byte2, regnr, admode, opsize;
|
||||
type8 *arg1, *arg2, is_reversible, running = 0, tmparg[4] = {0, 0, 0, 0};
|
||||
type8 lastchar = 0, version = 0, sd = 0;
|
||||
type8 *decode_table, *restart = 0, *code = 0, *string = 0, *string2 = 0;
|
||||
type8 *string3 = 0, *dict = 0;
|
||||
type8 quick_flag = 0, gfx_ver = 0, *gfx_buf = nullptr, *gfx_data = 0;
|
||||
type8 *gfx2_hdr = 0, *gfx2_buf = nullptr;
|
||||
const char *gfx2_name = nullptr;
|
||||
type16 gfx2_hsize = 0;
|
||||
Common::File *gfx_fp = nullptr;
|
||||
type8 *snd_buf = nullptr, *snd_hdr = nullptr;
|
||||
type16 snd_hsize = 0;
|
||||
Common::File *snd_fp = nullptr;
|
||||
|
||||
const char *const undo_ok = "\n[Previous turn undone.]";
|
||||
const char *const undo_fail = "\n[You can't \"undo\" what hasn't been done!]";
|
||||
type32 undo_regs[2][18], undo_pc, undo_size;
|
||||
type8 *undo[2] = {0, 0}, undo_stat[2] = {0, 0};
|
||||
type16 gfxtable = 0, table_dist = 0;
|
||||
type16 v4_id = 0, next_table = 1;
|
||||
|
||||
#ifndef NO_ANIMATION
|
||||
|
||||
struct picture anim_frame_table[MAX_ANIMS];
|
||||
type16 pos_table_size = 0;
|
||||
type16 pos_table_count[MAX_POSITIONS];
|
||||
struct ms_position pos_table[MAX_POSITIONS][MAX_ANIMS];
|
||||
type8 *command_table = 0;
|
||||
type16s command_index = -1;
|
||||
struct lookup anim_table[MAX_POSITIONS];
|
||||
type16s pos_table_index = -1;
|
||||
type16s pos_table_max = -1;
|
||||
struct ms_position pos_array[MAX_FRAMES];
|
||||
type8 anim_repeat = 0;
|
||||
|
||||
#endif
|
||||
|
||||
/* Hint support */
|
||||
struct ms_hint *hints = 0;
|
||||
type8 *hint_contents = 0;
|
||||
const char *const no_hints = "[Hints are not available.]\n";
|
||||
const char *const not_supported = "[This function is not supported.]\n";
|
||||
const char *const undo_ok = "\n[Previous turn undone.]";
|
||||
const char *const undo_fail = "\n[You can't \"undo\" what hasn't been done!]";
|
||||
|
||||
#define ms_fatal error
|
||||
|
||||
#if defined(LOGEMU) || defined(LOGGFX) || defined(LOGHNT)
|
||||
FILE *dbg_log;
|
||||
@ -79,14 +42,6 @@ FILE *dbg_log;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* prototypes */
|
||||
type32 read_reg(int, int);
|
||||
void write_reg(int, int, type32);
|
||||
|
||||
#define MAX_STRING_SIZE 0xFF00
|
||||
#define MAX_PICTURE_SIZE 0xC800
|
||||
#define MAX_MUSIC_SIZE 0x4E20
|
||||
|
||||
#ifdef LOGEMU
|
||||
void out(char *format, ...) {
|
||||
va_list a;
|
||||
@ -108,7 +63,7 @@ void out2(char *format, ...) {
|
||||
#endif
|
||||
|
||||
/* Convert virtual pointer to effective pointer */
|
||||
type8 *effective(type32 ptr) {
|
||||
type8 *Magnetic::effective(type32 ptr) {
|
||||
if ((version < 4) && (mem_size == 0x10000))
|
||||
return &(code[ptr & 0xffff]);
|
||||
if (ptr >= mem_size) {
|
||||
@ -119,16 +74,7 @@ type8 *effective(type32 ptr) {
|
||||
return &(code[ptr]);
|
||||
}
|
||||
|
||||
type32 read_l(type8 *ptr) {
|
||||
|
||||
return (type32)((type32) ptr[0] << 24 | (type32) ptr[1] << 16 | (type32) ptr[2] << 8 | (type32) ptr[3]);
|
||||
}
|
||||
|
||||
type16 read_w(type8 *ptr) {
|
||||
return (type16)(ptr[0] << 8 | ptr[1]);
|
||||
}
|
||||
|
||||
void write_l(type8 *ptr, type32 val) {
|
||||
void Magnetic::write_l(type8 *ptr, type32 val) {
|
||||
ptr[3] = (type8) val;
|
||||
val >>= 8;
|
||||
ptr[2] = (type8) val;
|
||||
@ -138,32 +84,18 @@ void write_l(type8 *ptr, type32 val) {
|
||||
ptr[0] = (type8) val;
|
||||
}
|
||||
|
||||
void write_w(type8 *ptr, type16 val) {
|
||||
void Magnetic::write_w(type8 *ptr, type16 val) {
|
||||
ptr[1] = (type8) val;
|
||||
val >>= 8;
|
||||
ptr[0] = (type8) val;
|
||||
}
|
||||
|
||||
type32 read_l2(type8 *ptr) {
|
||||
return ((type32) ptr[1] << 24 | (type32) ptr[0] << 16 | (type32) ptr[3] << 8 | (type32) ptr[2]);
|
||||
}
|
||||
|
||||
type16 read_w2(type8 *ptr) {
|
||||
return (type16)(ptr[1] << 8 | ptr[0]);
|
||||
}
|
||||
|
||||
/* Standard rand - for equal cross-platform behaviour */
|
||||
|
||||
void ms_seed(type32 seed) {
|
||||
rseed = seed;
|
||||
}
|
||||
|
||||
type32 rand_emu(void) {
|
||||
type32 Magnetic::rand_emu() {
|
||||
rseed = 1103515245L * rseed + 12345L;
|
||||
return rseed & 0x7fffffffL;
|
||||
}
|
||||
|
||||
void ms_freemem(void) {
|
||||
void Magnetic::ms_freemem() {
|
||||
if (code)
|
||||
free(code);
|
||||
if (string)
|
||||
@ -219,19 +151,7 @@ void ms_freemem(void) {
|
||||
snd_buf = nullptr;
|
||||
}
|
||||
|
||||
type8 ms_is_running(void) {
|
||||
return running;
|
||||
}
|
||||
|
||||
type8 ms_is_magwin(void) {
|
||||
return (version == 4) ? 1 : 0;
|
||||
}
|
||||
|
||||
void ms_stop(void) {
|
||||
running = 0;
|
||||
}
|
||||
|
||||
type8 init_gfx1(type8 *header) {
|
||||
type8 Magnetic::init_gfx1(type8 *header) {
|
||||
#ifdef SAVEMEM
|
||||
type32 i;
|
||||
#endif
|
||||
@ -278,7 +198,7 @@ type8 init_gfx1(type8 *header) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
type8 init_gfx2(type8 *header) {
|
||||
type8 Magnetic::init_gfx2(type8 *header) {
|
||||
if (!(gfx_buf = (type8 *)malloc(MAX_PICTURE_SIZE))) {
|
||||
delete gfx_fp;
|
||||
gfx_fp = nullptr;
|
||||
@ -309,7 +229,7 @@ type8 init_gfx2(type8 *header) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
type8 init_snd(type8 *header) {
|
||||
type8 Magnetic::init_snd(type8 *header) {
|
||||
if (!(snd_buf = (type8 *)malloc(MAX_MUSIC_SIZE))) {
|
||||
delete snd_fp;
|
||||
snd_fp = nullptr;
|
||||
@ -339,9 +259,7 @@ type8 init_snd(type8 *header) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* zero all registers and flags and load the game */
|
||||
|
||||
type8 ms_init(const char *name, const char *gfxname, const char *hntname, const char *sndname) {
|
||||
type8 Magnetic::ms_init(const char *name, const char *gfxname, const char *hntname, const char *sndname) {
|
||||
Common::File fp;
|
||||
type8 header[42], header2[8], header3[4];
|
||||
type32 i, dict_size, string2_size, code_size, dec;
|
||||
@ -601,7 +519,7 @@ type8 ms_init(const char *name, const char *gfxname, const char *hntname, const
|
||||
return 1;
|
||||
}
|
||||
|
||||
type8 is_blank(type16 line, type16 width) {
|
||||
type8 Magnetic::is_blank(type16 line, type16 width) {
|
||||
type32s i;
|
||||
|
||||
for (i = line * width; i < (line + 1) * width; i++)
|
||||
@ -610,8 +528,8 @@ type8 is_blank(type16 line, type16 width) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
type8 *ms_extract1(type8 pic, type16 *w, type16 *h, type16 *pal) {
|
||||
type8 *decodeTable, *data, bit, val, *buffer;
|
||||
type8 *Magnetic::ms_extract1(type8 pic, type16 *w, type16 *h, type16 *pal) {
|
||||
type8 *decodeTable, *data, bit, val, *buf;
|
||||
type16 tablesize, count;
|
||||
type32 i, j, upsize, offset;
|
||||
|
||||
@ -622,22 +540,22 @@ type8 *ms_extract1(type8 pic, type16 *w, type16 *h, type16 *pal) {
|
||||
if (fseek(gfx_fp, offset, SEEK_SET) < 0)
|
||||
return 0;
|
||||
datasize = read_l(gfx_data + 4 * (pic + 1)) - offset;
|
||||
if (!(buffer = (type8 *)malloc(datasize)))
|
||||
if (!(buf = (type8 *)malloc(datasize)))
|
||||
return 0;
|
||||
if (fp.read(buffer, 1, datasize, gfx_fp) != datasize)
|
||||
if (fp.read(buf, 1, datasize, gfx_fp) != datasize)
|
||||
return 0;
|
||||
#else
|
||||
buffer = gfx_data + offset - 8;
|
||||
buf = gfx_data + offset - 8;
|
||||
#endif
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
pal[i] = read_w(buffer + 0x1c + 2 * i);
|
||||
w[0] = (type16)(read_w(buffer + 4) - read_w(buffer + 2));
|
||||
h[0] = read_w(buffer + 6);
|
||||
pal[i] = read_w(buf + 0x1c + 2 * i);
|
||||
w[0] = (type16)(read_w(buf + 4) - read_w(buf + 2));
|
||||
h[0] = read_w(buf + 6);
|
||||
|
||||
tablesize = read_w(buffer + 0x3c);
|
||||
//datasize = read_l(buffer + 0x3e);
|
||||
decodeTable = buffer + 0x42;
|
||||
tablesize = read_w(buf + 0x3c);
|
||||
//datasize = read_l(buf + 0x3e);
|
||||
decodeTable = buf + 0x42;
|
||||
data = decodeTable + tablesize * 2 + 2;
|
||||
upsize = h[0] * w[0];
|
||||
|
||||
@ -667,14 +585,14 @@ type8 *ms_extract1(type8 pic, type16 *w, type16 *h, type16 *pal) {
|
||||
gfx_buf[j] ^= gfx_buf[j - w[0]];
|
||||
|
||||
#ifdef SAVEMEM
|
||||
free(buffer);
|
||||
free(buf);
|
||||
#endif
|
||||
for (; h[0] > 0 && is_blank((type16)(h[0] - 1), w[0]); h[0]--);
|
||||
for (i = 0; h[0] > 0 && is_blank((type16)i, w[0]); h[0]--, i++);
|
||||
return gfx_buf + i * w[0];
|
||||
}
|
||||
|
||||
type16s find_name_in_header(const char *name, type8 upper) {
|
||||
type16s Magnetic::find_name_in_header(const char *name, type8 upper) {
|
||||
type16s header_pos = 0;
|
||||
char pic_name[8];
|
||||
type8 i;
|
||||
@ -696,7 +614,7 @@ type16s find_name_in_header(const char *name, type8 upper) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
void extract_frame(struct picture *pic) {
|
||||
void Magnetic::extract_frame(struct picture *pic) {
|
||||
type32 i, x, y, bit_x, mask, ywb, yw, value, values[4];
|
||||
|
||||
if (pic->width * pic->height > MAX_PICTURE_SIZE) {
|
||||
@ -727,7 +645,7 @@ void extract_frame(struct picture *pic) {
|
||||
}
|
||||
}
|
||||
|
||||
type8 *ms_extract2(const char *name, type16 *w, type16 *h, type16 *pal, type8 *is_anim) {
|
||||
type8 *Magnetic::ms_extract2(const char *name, type16 *w, type16 *h, type16 *pal, type8 *is_anim) {
|
||||
struct picture main_pic;
|
||||
type32 offset = 0, length = 0, i;
|
||||
type16s header_pos = -1;
|
||||
@ -885,7 +803,7 @@ type8 *ms_extract2(const char *name, type16 *w, type16 *h, type16 *pal, type8 *i
|
||||
return 0;
|
||||
}
|
||||
|
||||
type8 *ms_extract(type32 pic, type16 *w, type16 *h, type16 *pal, type8 *is_anim) {
|
||||
type8 *Magnetic::ms_extract(type32 pic, type16 *w, type16 *h, type16 *pal, type8 *is_anim) {
|
||||
if (is_anim)
|
||||
*is_anim = 0;
|
||||
|
||||
@ -902,7 +820,7 @@ type8 *ms_extract(type32 pic, type16 *w, type16 *h, type16 *pal, type8 *is_anim)
|
||||
return 0;
|
||||
}
|
||||
|
||||
type8 ms_animate(struct ms_position **positions, type16 *count) {
|
||||
type8 Magnetic::ms_animate(struct ms_position **positions, type16 *count) {
|
||||
#ifndef NO_ANIMATION
|
||||
type8 got_anim = 0;
|
||||
type16 i, j, ttable;
|
||||
@ -1054,7 +972,7 @@ type8 ms_animate(struct ms_position **positions, type16 *count) {
|
||||
#endif
|
||||
}
|
||||
|
||||
type8 *ms_get_anim_frame(type16s number, type16 *width, type16 *height, type8 **mask) {
|
||||
type8 *Magnetic::ms_get_anim_frame(type16s number, type16 *width, type16 *height, type8 **mask) {
|
||||
#ifndef NO_ANIMATION
|
||||
if (number >= 0) {
|
||||
extract_frame(anim_frame_table + number);
|
||||
@ -1067,7 +985,7 @@ type8 *ms_get_anim_frame(type16s number, type16 *width, type16 *height, type8 **
|
||||
return 0;
|
||||
}
|
||||
|
||||
type8 ms_anim_is_repeating(void) {
|
||||
type8 Magnetic::ms_anim_is_repeating() const {
|
||||
#ifndef NO_ANIMATION
|
||||
return anim_repeat;
|
||||
#else
|
||||
@ -1075,7 +993,7 @@ type8 ms_anim_is_repeating(void) {
|
||||
#endif
|
||||
}
|
||||
|
||||
type16s find_name_in_sndheader(const char *name) {
|
||||
type16s Magnetic::find_name_in_sndheader(const char *name) {
|
||||
type16s header_pos = 0;
|
||||
|
||||
while (header_pos < snd_hsize) {
|
||||
@ -1088,7 +1006,7 @@ type16s find_name_in_sndheader(const char *name) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
type8 *sound_extract(const char *name, type32 *length, type16 *tempo) {
|
||||
type8 *Magnetic::sound_extract(const char *name, type32 *length, type16 *tempo) {
|
||||
type32 offset = 0;
|
||||
type16s header_pos = -1;
|
||||
|
||||
@ -1113,7 +1031,7 @@ type8 *sound_extract(const char *name, type32 *length, type16 *tempo) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void save_undo(void) {
|
||||
void Magnetic::save_undo() {
|
||||
type8 *tmp, i;
|
||||
type32 tmp32;
|
||||
|
||||
@ -1139,7 +1057,7 @@ void save_undo(void) {
|
||||
undo_stat[1] = 1;
|
||||
}
|
||||
|
||||
type8 ms_undo(void) {
|
||||
type8 Magnetic::ms_undo() {
|
||||
type8 i;
|
||||
|
||||
ms_flush();
|
||||
@ -1158,7 +1076,7 @@ type8 ms_undo(void) {
|
||||
}
|
||||
|
||||
#ifdef LOGEMU
|
||||
void log_status(void) {
|
||||
void Magnetic::log_status() {
|
||||
int j;
|
||||
|
||||
fprintf(dbg_log, "\nD0:");
|
||||
@ -1172,7 +1090,7 @@ void log_status(void) {
|
||||
}
|
||||
#endif
|
||||
|
||||
void ms_status(void) {
|
||||
void Magnetic::ms_status() {
|
||||
int j;
|
||||
|
||||
Common::String s = "D0:";
|
||||
@ -1187,13 +1105,7 @@ void ms_status(void) {
|
||||
warning("%s", s.c_str());
|
||||
}
|
||||
|
||||
type32 ms_count(void) {
|
||||
return i_count;
|
||||
}
|
||||
|
||||
/* align register pointer for word/byte accesses */
|
||||
|
||||
type8 *reg_align(type8 *ptr, type8 size) {
|
||||
type8 *Magnetic::reg_align(type8 *ptr, type8 size) {
|
||||
if (size == 1)
|
||||
ptr += 2;
|
||||
if (size == 0)
|
||||
@ -1201,7 +1113,7 @@ type8 *reg_align(type8 *ptr, type8 size) {
|
||||
return ptr;
|
||||
}
|
||||
|
||||
type32 read_reg(int i, int s) {
|
||||
type32 Magnetic::read_reg(int i, int s) {
|
||||
type8 *ptr;
|
||||
|
||||
if (i > 15) {
|
||||
@ -1223,7 +1135,7 @@ type32 read_reg(int i, int s) {
|
||||
}
|
||||
}
|
||||
|
||||
void write_reg(int i, int s, type32 val) {
|
||||
void Magnetic::write_reg(int i, int s, type32 val) {
|
||||
type8 *ptr;
|
||||
|
||||
if (i > 15) {
|
||||
@ -1248,9 +1160,7 @@ void write_reg(int i, int s, type32 val) {
|
||||
}
|
||||
}
|
||||
|
||||
/* [35c4] */
|
||||
|
||||
void char_out(type8 c) {
|
||||
void Magnetic::char_out(type8 c) {
|
||||
static type8 big = 0, period = 0, pipe = 0;
|
||||
|
||||
if (c == 0xff) {
|
||||
@ -1327,18 +1237,13 @@ void char_out(type8 c) {
|
||||
ms_putchar(c);
|
||||
}
|
||||
|
||||
|
||||
/* extract addressing mode information [1c6f] */
|
||||
|
||||
void set_info(type8 b) {
|
||||
void Magnetic::set_info(type8 b) {
|
||||
regnr = (type8)(b & 0x07);
|
||||
admode = (type8)((b >> 3) & 0x07);
|
||||
opsize = (type8)(b >> 6);
|
||||
}
|
||||
|
||||
/* read a word and increase pc */
|
||||
|
||||
void read_word(void) {
|
||||
void Magnetic::read_word() {
|
||||
type8 *epc;
|
||||
|
||||
epc = effective(pc);
|
||||
@ -1347,9 +1252,7 @@ void read_word(void) {
|
||||
pc += 2;
|
||||
}
|
||||
|
||||
/* get addressing mode and set arg1 [1c84] */
|
||||
|
||||
void set_arg1(void) {
|
||||
void Magnetic::set_arg1() {
|
||||
type8 tmp[2], l1c;
|
||||
|
||||
is_reversible = 1;
|
||||
@ -1479,9 +1382,7 @@ void set_arg1(void) {
|
||||
arg1 = effective(arg1i);
|
||||
}
|
||||
|
||||
/* get addressing mode and set arg2 [1bc5] */
|
||||
|
||||
void set_arg2_nosize(int use_dx, type8 b) {
|
||||
void Magnetic::set_arg2_nosize(int use_dx, type8 b) {
|
||||
if (use_dx)
|
||||
arg2 = (type8 *) dreg;
|
||||
else
|
||||
@ -1489,14 +1390,12 @@ void set_arg2_nosize(int use_dx, type8 b) {
|
||||
arg2 += (b & 0x0e) << 1;
|
||||
}
|
||||
|
||||
void set_arg2(int use_dx, type8 b) {
|
||||
void Magnetic::set_arg2(int use_dx, type8 b) {
|
||||
set_arg2_nosize(use_dx, b);
|
||||
arg2 = reg_align(arg2, opsize);
|
||||
}
|
||||
|
||||
/* [1b9e] */
|
||||
|
||||
void swap_args(void) {
|
||||
void Magnetic::swap_args() {
|
||||
type8 *tmp;
|
||||
|
||||
tmp = arg1;
|
||||
@ -1504,16 +1403,12 @@ void swap_args(void) {
|
||||
arg2 = tmp;
|
||||
}
|
||||
|
||||
/* [1cdc] */
|
||||
|
||||
void push(type32 c) {
|
||||
void Magnetic::push(type32 c) {
|
||||
write_reg(15, 2, read_reg(15, 2) - 4);
|
||||
write_l(effective(read_reg(15, 2)), c);
|
||||
}
|
||||
|
||||
/* [1cd1] */
|
||||
|
||||
type32 pop(void) {
|
||||
type32 Magnetic::pop() {
|
||||
type32 c;
|
||||
|
||||
c = read_l(effective(read_reg(15, 2)));
|
||||
@ -1521,9 +1416,7 @@ type32 pop(void) {
|
||||
return c;
|
||||
}
|
||||
|
||||
/* check addressing mode and get argument [2e85] */
|
||||
|
||||
void get_arg(void) {
|
||||
void Magnetic::get_arg() {
|
||||
#ifdef LOGEMU
|
||||
out(" %.4X", pc);
|
||||
#endif
|
||||
@ -1537,7 +1430,7 @@ void get_arg(void) {
|
||||
set_arg1();
|
||||
}
|
||||
|
||||
void set_flags(void) {
|
||||
void Magnetic::set_flags() {
|
||||
type16 i;
|
||||
type32 j;
|
||||
|
||||
@ -1566,9 +1459,7 @@ void set_flags(void) {
|
||||
}
|
||||
}
|
||||
|
||||
/* [263a] */
|
||||
|
||||
int condition(type8 b) {
|
||||
int Magnetic::condition(type8 b) {
|
||||
switch (b & 0x0f) {
|
||||
case 0:
|
||||
return 0xff;
|
||||
@ -1604,9 +1495,7 @@ int condition(type8 b) {
|
||||
return 0x00;
|
||||
}
|
||||
|
||||
/* [26dc] */
|
||||
|
||||
void branch(type8 b) {
|
||||
void Magnetic::branch(type8 b) {
|
||||
if (b == 0)
|
||||
pc += (type16s) read_w(effective(pc));
|
||||
else
|
||||
@ -1616,9 +1505,7 @@ void branch(type8 b) {
|
||||
#endif
|
||||
}
|
||||
|
||||
/* [2869] */
|
||||
|
||||
void do_add(type8 adda) {
|
||||
void Magnetic::do_add(type8 adda) {
|
||||
if (adda) {
|
||||
if (opsize == 0)
|
||||
write_l(arg1, read_l(arg1) + (type8s) arg2[0]);
|
||||
@ -1651,9 +1538,7 @@ void do_add(type8 adda) {
|
||||
}
|
||||
}
|
||||
|
||||
/* [2923] */
|
||||
|
||||
void do_sub(type8 suba) {
|
||||
void Magnetic::do_sub(type8 suba) {
|
||||
if (suba) {
|
||||
if (opsize == 0)
|
||||
write_l(arg1, read_l(arg1) - (type8s) arg2[0]);
|
||||
@ -1686,9 +1571,7 @@ void do_sub(type8 suba) {
|
||||
}
|
||||
}
|
||||
|
||||
/* [283b] */
|
||||
|
||||
void do_eor(void) {
|
||||
void Magnetic::do_eor() {
|
||||
if (opsize == 0)
|
||||
arg1[0] ^= arg2[0];
|
||||
if (opsize == 1)
|
||||
@ -1699,9 +1582,7 @@ void do_eor(void) {
|
||||
set_flags();
|
||||
}
|
||||
|
||||
/* [280d] */
|
||||
|
||||
void do_and(void) {
|
||||
void Magnetic::do_and() {
|
||||
if (opsize == 0)
|
||||
arg1[0] &= arg2[0];
|
||||
if (opsize == 1)
|
||||
@ -1712,9 +1593,7 @@ void do_and(void) {
|
||||
set_flags();
|
||||
}
|
||||
|
||||
/* [27df] */
|
||||
|
||||
void do_or(void) {
|
||||
void Magnetic::do_or() {
|
||||
if (opsize == 0)
|
||||
arg1[0] |= arg2[0];
|
||||
if (opsize == 1)
|
||||
@ -1725,9 +1604,7 @@ void do_or(void) {
|
||||
set_flags(); /* [1c2b] */
|
||||
}
|
||||
|
||||
/* [289f] */
|
||||
|
||||
void do_cmp(void) {
|
||||
void Magnetic::do_cmp() {
|
||||
type8 *tmp;
|
||||
|
||||
tmp = arg1;
|
||||
@ -1741,9 +1618,7 @@ void do_cmp(void) {
|
||||
arg1 = tmp;
|
||||
}
|
||||
|
||||
/* [2973] */
|
||||
|
||||
void do_move(void) {
|
||||
void Magnetic::do_move() {
|
||||
|
||||
if (opsize == 0)
|
||||
arg1[0] = arg2[0];
|
||||
@ -1758,7 +1633,7 @@ void do_move(void) {
|
||||
}
|
||||
}
|
||||
|
||||
type8 do_btst(type8 a) {
|
||||
type8 Magnetic::do_btst(type8 a) {
|
||||
a &= admode ? 0x7 : 0x1f;
|
||||
while (admode == 0 && a >= 8) {
|
||||
a -= 8;
|
||||
@ -1770,9 +1645,7 @@ type8 do_btst(type8 a) {
|
||||
return a;
|
||||
}
|
||||
|
||||
/* bit operation entry point [307c] */
|
||||
|
||||
void do_bop(type8 b, type8 a) {
|
||||
void Magnetic::do_bop(type8 b, type8 a) {
|
||||
#ifdef LOGEMU
|
||||
out("bop (%.2x,%.2x) ", (int) b, (int) a);
|
||||
#endif
|
||||
@ -1802,7 +1675,7 @@ void do_bop(type8 b, type8 a) {
|
||||
}
|
||||
}
|
||||
|
||||
void check_btst(void) {
|
||||
void Magnetic::check_btst() {
|
||||
#ifdef LOGEMU
|
||||
out("btst");
|
||||
#endif
|
||||
@ -1812,7 +1685,7 @@ void check_btst(void) {
|
||||
do_bop(byte2, arg2[0]);
|
||||
}
|
||||
|
||||
void check_lea(void) {
|
||||
void Magnetic::check_lea() {
|
||||
#ifdef LOGEMU
|
||||
out("lea");
|
||||
#endif
|
||||
@ -1831,9 +1704,7 @@ void check_lea(void) {
|
||||
}
|
||||
}
|
||||
|
||||
/* [33cc] */
|
||||
|
||||
void check_movem(void) {
|
||||
void Magnetic::check_movem() {
|
||||
type8 l1c;
|
||||
|
||||
#ifdef LOGEMU
|
||||
@ -1861,9 +1732,7 @@ void check_movem(void) {
|
||||
}
|
||||
}
|
||||
|
||||
/* [3357] */
|
||||
|
||||
void check_movem2(void) {
|
||||
void Magnetic::check_movem2() {
|
||||
type8 l1c;
|
||||
|
||||
#ifdef LOGEMU
|
||||
@ -1891,10 +1760,7 @@ void check_movem2(void) {
|
||||
}
|
||||
}
|
||||
|
||||
/* [30e4] in Jinxter, ~540 lines of 6510 spaghetti-code */
|
||||
/* The mother of all bugs, but hey - no gotos used :-) */
|
||||
|
||||
void dict_lookup(void) {
|
||||
void Magnetic::dict_lookup() {
|
||||
type16 dtab, doff, output, output_bak, bank, word, output2;
|
||||
type16 tmp16, i, obj_adj, adjlist, adjlist_bak;
|
||||
type8 c, c2, c3, flag, matchlen, longest, flag2;
|
||||
@ -2066,9 +1932,7 @@ void dict_lookup(void) {
|
||||
write_reg(8 + 6, 1, read_reg(8 + 5, 1) + 1);
|
||||
}
|
||||
|
||||
/* A0=findproperties(D0) [2b86], properties_ptr=[2b78] A0FE */
|
||||
|
||||
void do_findprop(void) {
|
||||
void Magnetic::do_findprop() {
|
||||
type16 tmp;
|
||||
|
||||
if ((version > 2) && ((read_reg(0, 1) & 0x3fff) > fp_size)) {
|
||||
@ -2086,7 +1950,7 @@ void do_findprop(void) {
|
||||
write_reg(8 + 0, 2, tmp * 14 + properties);
|
||||
}
|
||||
|
||||
void write_string(void) {
|
||||
void Magnetic::write_string() {
|
||||
static type32 offset_bak;
|
||||
static type8 mask_bak;
|
||||
type8 c, b, mask;
|
||||
@ -2142,7 +2006,7 @@ void write_string(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void output_number(type16 number) {
|
||||
void Magnetic::output_number(type16 number) {
|
||||
type16 tens = number / 10;
|
||||
|
||||
if (tens > 0)
|
||||
@ -2151,7 +2015,7 @@ void output_number(type16 number) {
|
||||
ms_putchar('0' + number);
|
||||
}
|
||||
|
||||
type16 output_text(const char *text) {
|
||||
type16 Magnetic::output_text(const char *text) {
|
||||
type16 i;
|
||||
|
||||
for (i = 0; text[i] != 0; i++)
|
||||
@ -2159,7 +2023,7 @@ type16 output_text(const char *text) {
|
||||
return i;
|
||||
}
|
||||
|
||||
type16s hint_input(void) {
|
||||
type16s Magnetic::hint_input() {
|
||||
type8 c1, c2, c3;
|
||||
|
||||
output_text(">>");
|
||||
@ -2208,7 +2072,7 @@ type16s hint_input(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
type16 show_hints_text(ms_hint *hintsData, type16 index) {
|
||||
type16 Magnetic::show_hints_text(ms_hint *hintsData, type16 index) {
|
||||
type16 i = 0, j = 0;
|
||||
type16s input;
|
||||
ms_hint *hint = hintsData + index;
|
||||
@ -2282,7 +2146,7 @@ type16 show_hints_text(ms_hint *hintsData, type16 index) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void do_line_a(void) {
|
||||
void Magnetic::do_line_a() {
|
||||
type8 l1c;
|
||||
char *str;
|
||||
type16 ptr, ptr2, tmp16, dtype;
|
||||
@ -2656,9 +2520,7 @@ void do_line_a(void) {
|
||||
}
|
||||
}
|
||||
|
||||
/* emulate an instruction [1b7e] */
|
||||
|
||||
type8 ms_rungame(void) {
|
||||
type8 Magnetic::ms_rungame() {
|
||||
type8 l1c;
|
||||
type16 ptr;
|
||||
type32 tmp32;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -21,7 +21,7 @@
|
||||
*/
|
||||
|
||||
#include "glk/magnetic/magnetic.h"
|
||||
#include "glk/magnetic/defs.h"
|
||||
#include "glk/magnetic/magnetic_defs.h"
|
||||
#include "common/config-manager.h"
|
||||
|
||||
namespace Glk {
|
||||
@ -32,7 +32,57 @@ Magnetic *g_vm;
|
||||
Magnetic::Magnetic(OSystem *syst, const GlkGameDescription &gameDesc) : GlkAPI(syst, gameDesc),
|
||||
gms_gamma_mode(GAMMA_NORMAL), gms_animation_enabled(true),
|
||||
gms_prompt_enabled(true), gms_abbreviations_enabled(true), gms_commands_enabled(true),
|
||||
gms_graphics_enabled(false) {
|
||||
gms_graphics_enabled(false), GMS_PORT_VERSION(0x00010601),
|
||||
gms_main_window(nullptr), gms_status_window(nullptr), gms_graphics_window(nullptr),
|
||||
gms_hint_menu_window(nullptr), gms_hint_text_window(nullptr),
|
||||
gms_transcript_stream(nullptr), gms_readlog_stream(nullptr),
|
||||
gms_inputlog_stream(nullptr), gms_graphics_possible(true),
|
||||
GMS_INPUT_PROMPT(">"), gms_gameid_game_name(nullptr), gms_graphics_bitmap(nullptr),
|
||||
gms_graphics_width(0), gms_graphics_height(0), gms_graphics_animated(false),
|
||||
gms_graphics_picture(0), gms_graphics_new_picture(false),
|
||||
gms_graphics_repaint(false), gms_graphics_active(false),
|
||||
gms_graphics_interpreter(false), gms_graphics_off_screen(nullptr),
|
||||
gms_graphics_on_screen(nullptr),// gms_graphics_current_gamma(Magnetic::GMS_GAMMA_TABLE),
|
||||
gms_graphics_color_count(GMS_PALETTE_SIZE), gms_status_length(0),
|
||||
gms_help_requested(false), gms_help_hints_silenced(false),
|
||||
gms_output_buffer(nullptr), gms_output_allocation(0),gms_output_length(0),
|
||||
gms_output_prompt(false), gms_hints(nullptr), gms_current_hint_node(0),
|
||||
gms_hint_cursor(nullptr), gms_input_length(0), gms_input_cursor(0),
|
||||
gms_undo_notification(false), gms_game_message(nullptr), gms_startup_called(false),
|
||||
gms_main_called(false), gms_graphics_current_gamma(nullptr),
|
||||
i_count(0), string_size(0), rseed(0), pc(0), arg1i(0), mem_size(0), properties(0),
|
||||
fl_sub(0), fl_tab(0), fl_size(0), fp_tab(0), fp_size(0), zflag(0), nflag(0),
|
||||
cflag(0), vflag(0), byte1(0), byte2(0), regnr(0), admode(0), opsize(0),
|
||||
arg1(nullptr), arg2(nullptr), is_reversible(0), running(0), lastchar(0), version(0),
|
||||
sd(0), decode_table(nullptr), restart(nullptr), code(nullptr), string(nullptr),
|
||||
string2(nullptr), string3(nullptr), dict(nullptr), quick_flag(0), gfx_ver(0),
|
||||
gfx_buf(nullptr), gfx_data(nullptr), gfx2_hdr(nullptr), gfx2_buf(nullptr),
|
||||
gfx2_name(nullptr), gfx2_hsize(0), gfx_fp(nullptr), snd_buf(nullptr), snd_hdr(nullptr),
|
||||
snd_hsize(0), snd_fp(nullptr), undo_pc(0), undo_size(0), gfxtable(0), table_dist(0),
|
||||
v4_id(0), next_table(1)
|
||||
#ifndef NO_ANIMATION
|
||||
, pos_table_size(0), command_table(nullptr), command_index(-1),
|
||||
pos_table_index(-1), pos_table_max(-1), anim_repeat(0)
|
||||
#endif
|
||||
, hints(nullptr), hint_contents(nullptr), xpos(0), bufpos(0), log_on(0),
|
||||
ms_gfx_enabled(0), log1(nullptr), log2(nullptr) {
|
||||
|
||||
Common::fill(&gms_graphics_palette[0], &gms_graphics_palette[GMS_PALETTE_SIZE], 0);
|
||||
Common::fill(&gms_status_buffer[0], &gms_status_buffer[GMS_STATBUFFER_LENGTH], '\0');
|
||||
Common::fill(&gms_input_buffer[0], &gms_input_buffer[GMS_INPUTBUFFER_LENGTH], '\0');
|
||||
Common::fill(&dreg[0], &dreg[8], 0);
|
||||
Common::fill(&areg[0], &areg[8], 0);
|
||||
Common::fill(&tmparg[0], &tmparg[4], 0);
|
||||
Common::fill(&undo_regs[0][0], &undo_regs[3][0], 0);
|
||||
undo[0] = undo[1] = nullptr;
|
||||
undo_stat[0] = undo_stat[1] = 0;
|
||||
Common::fill(&buffer[0], &buffer[80], 0);
|
||||
Common::fill(&filename[0], &filename[256], 0);
|
||||
|
||||
#ifndef NO_ANIMATION
|
||||
Common::fill(&pos_table_count[0], &pos_table_count[MAX_POSITIONS], 0);
|
||||
#endif
|
||||
|
||||
g_vm = this;
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
113
engines/glk/magnetic/magnetic_defs.h
Normal file
113
engines/glk/magnetic/magnetic_defs.h
Normal file
@ -0,0 +1,113 @@
|
||||
/* 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 MAGNETIC_DEFS_H
|
||||
#define MAGNETIC_DEFS_H
|
||||
|
||||
#include "common/scummsys.h"
|
||||
|
||||
namespace Glk {
|
||||
namespace Magnetic {
|
||||
|
||||
/*****************************************************************************\
|
||||
* Type definitions for Magnetic
|
||||
*
|
||||
* Note: When running into trouble please ensure that these types have the
|
||||
* correct number of bits on your system !!!
|
||||
\*****************************************************************************/
|
||||
|
||||
typedef byte type8;
|
||||
typedef int8 type8s;
|
||||
typedef uint16 type16;
|
||||
typedef int16 type16s;
|
||||
typedef uint32 type32;
|
||||
typedef int32 type32s;
|
||||
|
||||
#ifndef BYTE_MAX
|
||||
#define BYTE_MAX 255
|
||||
#endif
|
||||
#ifndef CHAR_BIT
|
||||
#define CHAR_BIT 8
|
||||
#endif
|
||||
#ifndef UINT16_MAX
|
||||
#define UINT16_MAX 0xffff
|
||||
#endif
|
||||
#ifndef INT32_MAX
|
||||
#define INT32_MAX 0x7fffffff
|
||||
#endif
|
||||
|
||||
#define MAX_HINTS 260
|
||||
#define MAX_HCONTENTS 30000
|
||||
|
||||
#define MAX_POSITIONS 20
|
||||
#define MAX_ANIMS 200
|
||||
#define MAX_FRAMES 20
|
||||
#define MAX_STRING_SIZE 0xFF00
|
||||
#define MAX_PICTURE_SIZE 0xC800
|
||||
#define MAX_MUSIC_SIZE 0x4E20
|
||||
#define MAX_HITEMS 25
|
||||
|
||||
/****************************************************************************\
|
||||
* Compile time switches
|
||||
\****************************************************************************/
|
||||
|
||||
/* Switch: SAVEMEM
|
||||
Purpose: Magnetic loads a complete graphics file into memory by default.
|
||||
Setting this switch you tell Magnetic to load images on request
|
||||
(saving memory, wasting load time)
|
||||
|
||||
#define SAVEMEM
|
||||
*/
|
||||
|
||||
/* Switch: NO_ANIMATION
|
||||
Purpose: By default Magnetic plays animated graphics.
|
||||
Setting this switch to ignore animations, Magnetic shows the
|
||||
static parts of the images anyway!
|
||||
|
||||
#define NO_ANIMATION
|
||||
*/
|
||||
|
||||
/****************************************************************************\
|
||||
* Miscellaneous enums/types
|
||||
*
|
||||
\****************************************************************************/
|
||||
|
||||
enum { GMS_PALETTE_SIZE = 16 };
|
||||
|
||||
enum { GMS_INPUTBUFFER_LENGTH = 256 };
|
||||
|
||||
enum { GMS_STATBUFFER_LENGTH = 1024 };
|
||||
|
||||
enum GammaMode {
|
||||
GAMMA_OFF, GAMMA_NORMAL, GAMMA_HIGH
|
||||
};
|
||||
|
||||
/* Hint type definitions. */
|
||||
enum {
|
||||
GMS_HINT_TYPE_FOLDER = 1,
|
||||
GMS_HINT_TYPE_TEXT = 2
|
||||
};
|
||||
|
||||
} // End of namespace Magnetic
|
||||
} // End of namespace Glk
|
||||
|
||||
#endif
|
@ -24,22 +24,11 @@
|
||||
#define GLK_MAGNETIC_TYPES
|
||||
|
||||
#include "common/scummsys.h"
|
||||
#include "common/algorithm.h"
|
||||
#include "glk/magnetic/magnetic_defs.h"
|
||||
|
||||
namespace Glk {
|
||||
namespace Magnetic {
|
||||
|
||||
#define MAX_HINTS 260
|
||||
#define MAX_HCONTENTS 30000
|
||||
|
||||
#define MAX_POSITIONS 20
|
||||
#define MAX_ANIMS 200
|
||||
#define MAX_FRAMES 20
|
||||
#define MAX_STRING_SIZE 0xFF00
|
||||
#define MAX_PICTURE_SIZE 0xC800
|
||||
#define MAX_MUSIC_SIZE 0x4E20
|
||||
#define MAX_HITEMS 25
|
||||
|
||||
struct lookup {
|
||||
int16 flag;
|
||||
int16 count;
|
||||
@ -131,6 +120,34 @@ struct ms_hint {
|
||||
}
|
||||
};
|
||||
|
||||
struct gms_gamma_t {
|
||||
const char *const level; ///< Gamma correction level
|
||||
const unsigned char table[8]; ///< Color lookup table
|
||||
const bool is_corrected; ///< Flag if non-linear
|
||||
};
|
||||
typedef const gms_gamma_t *gms_gammaref_t;
|
||||
|
||||
/* R,G,B color triple definition. */
|
||||
struct gms_rgb_t {
|
||||
int red, green, blue;
|
||||
};
|
||||
typedef gms_rgb_t *gms_rgbref_t;
|
||||
|
||||
#ifndef GARGLK
|
||||
struct gms_layering_t {
|
||||
long complexity; /* Count of vertices for this color. */
|
||||
long usage; /* Color usage count. */
|
||||
int color; /* Color index into palette. */
|
||||
};
|
||||
#endif
|
||||
|
||||
/* Table of single-character command abbreviations. */
|
||||
struct gms_abbreviation_t {
|
||||
const char abbreviation; /* Abbreviation character. */
|
||||
const char *const expansion; /* Expansion string. */
|
||||
};
|
||||
typedef gms_abbreviation_t *gms_abbreviationref_t;
|
||||
|
||||
} // End of namespace Magnetic
|
||||
} // End of namespace Glk
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "glk/magnetic/defs.h"
|
||||
#include "glk/magnetic/magnetic.h"
|
||||
#include "common/file.h"
|
||||
#include "common/savefile.h"
|
||||
#include "common/system.h"
|
||||
@ -30,10 +30,7 @@ namespace Magnetic {
|
||||
|
||||
#define WIDTH 78
|
||||
|
||||
static type8 buffer[80], xpos = 0, bufpos = 0, log_on = 0, ms_gfx_enabled, filename[256];
|
||||
static Common::DumpFile *log1 = 0, *log2 = 0;
|
||||
|
||||
type8 ms_load_file(const char *name, type8 *ptr, type16 size) {
|
||||
type8 Magnetic::ms_load_file(const char *name, type8 *ptr, type16 size) {
|
||||
assert(name);
|
||||
Common::InSaveFile *file = g_system->getSavefileManager()->openForLoading(name);
|
||||
if (!file)
|
||||
@ -48,7 +45,7 @@ type8 ms_load_file(const char *name, type8 *ptr, type16 size) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
type8 ms_save_file(const char *name, type8 *ptr, type16 size) {
|
||||
type8 Magnetic::ms_save_file(const char *name, type8 *ptr, type16 size) {
|
||||
assert(name);
|
||||
Common::OutSaveFile *file = g_system->getSavefileManager()->openForSaving(name);
|
||||
if (!file)
|
||||
@ -64,113 +61,15 @@ type8 ms_save_file(const char *name, type8 *ptr, type16 size) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void script_write(type8 c) {
|
||||
void Magnetic::script_write(type8 c) {
|
||||
if (log_on == 2)
|
||||
log1->writeByte(c);
|
||||
}
|
||||
|
||||
void transcript_write(type8 c) {
|
||||
void Magnetic::transcript_write(type8 c) {
|
||||
if (log2)
|
||||
log2->writeByte(c);
|
||||
}
|
||||
|
||||
void ms_fatal(const char *txt) {
|
||||
error("Fatal error: %s", txt);
|
||||
}
|
||||
|
||||
#if 0
|
||||
main(int argc, char **argv) {
|
||||
type8 running, i, *gamename = 0, *gfxname = 0, *hintname = 0;
|
||||
type32 dlimit, slimit;
|
||||
|
||||
if (sizeof(type8) != 1 || sizeof(type16) != 2 || sizeof(type32) != 4) {
|
||||
fprintf(stderr,
|
||||
"You have incorrect typesizes, please edit the typedefs and recompile\n"
|
||||
"or proceed on your own risk...\n");
|
||||
exit(1);
|
||||
}
|
||||
dlimit = slimit = 0xffffffff;
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (argv[i][0] == '-') {
|
||||
switch (tolower(argv[i][1])) {
|
||||
case 'd':
|
||||
if (strlen(argv[i]) > 2)
|
||||
dlimit = atoi(&argv[i][2]);
|
||||
else
|
||||
dlimit = 0;
|
||||
break;
|
||||
case 's':
|
||||
if (strlen(argv[i]) > 2)
|
||||
slimit = atoi(&argv[i][2]);
|
||||
else
|
||||
slimit = 655360;
|
||||
break;
|
||||
case 't':
|
||||
if (!(log2 = fopen(&argv[i][2], "w")))
|
||||
printf("Failed to open \"%s\" for writing.\n", &argv[i][2]);
|
||||
break;
|
||||
case 'r':
|
||||
if (log1 = fopen(&argv[i][2], "r"))
|
||||
log_on = 1;
|
||||
else
|
||||
printf("Failed to open \"%s\" for reading.\n", &argv[i][2]);
|
||||
break;
|
||||
case 'w':
|
||||
if (log1 = fopen(&argv[i][2], "w"))
|
||||
log_on = 2;
|
||||
else
|
||||
printf("Failed to open \"%s\" for writing.\n", &argv[i][2]);
|
||||
break;
|
||||
default:
|
||||
printf("Unknown option -%c, ignoring.\n", argv[i][1]);
|
||||
break;
|
||||
}
|
||||
} else if (!gamename)
|
||||
gamename = argv[i];
|
||||
else if (!gfxname)
|
||||
gfxname = argv[i];
|
||||
else if (!hintname)
|
||||
hintname = argv[i];
|
||||
}
|
||||
if (!gamename) {
|
||||
printf("Magnetic 2.3 - a Magnetic Scrolls interpreter\n\n");
|
||||
printf("Usage: %s [options] game [gfxfile] [hintfile]\n\n"
|
||||
"Where the options are:\n"
|
||||
" -dn activate register dump (after n instructions)\n"
|
||||
" -rname read script file\n"
|
||||
" -sn safety mode, exits automatically (after n instructions)\n"
|
||||
" -tname write transcript file\n"
|
||||
" -wname write script file\n\n"
|
||||
"The interpreter commands are:\n"
|
||||
" #undo undo - don't use it near are_you_sure prompts\n"
|
||||
" #logoff turn off script writing\n\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!(ms_gfx_enabled = ms_init(gamename, gfxname, hintname, 0))) {
|
||||
printf("Couldn't start up game \"%s\".\n", gamename);
|
||||
exit(1);
|
||||
}
|
||||
ms_gfx_enabled--;
|
||||
running = 1;
|
||||
while ((ms_count() < slimit) && running) {
|
||||
if (ms_count() >= dlimit)
|
||||
ms_status();
|
||||
running = ms_rungame();
|
||||
}
|
||||
if (ms_count() == slimit) {
|
||||
printf("\n\nSafety limit (%d) reached.\n", slimit);
|
||||
ms_status();
|
||||
}
|
||||
ms_freemem();
|
||||
if (log_on)
|
||||
fclose(log1);
|
||||
if (log2)
|
||||
fclose(log2);
|
||||
printf("\nExiting.\n");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
} // End of namespace Magnetic
|
||||
} // End of namespace Glk
|
||||
|
Loading…
x
Reference in New Issue
Block a user