mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-24 02:36:27 +00:00
XEEN: Add a new iterator class for reading event parameters
This make things cleaner for reading in 16 and 32 bit parameters in different opcodes. Also, it solves a crash in the give/take opcode where the third mode/value pair isn't used for all sub-modes, so the code was previously reading beyond the end of the parameters
This commit is contained in:
parent
13f74027e8
commit
c965fccab0
File diff suppressed because it is too large
Load Diff
@ -99,13 +99,52 @@ enum Opcode {
|
||||
|
||||
class XeenEngine;
|
||||
|
||||
class EventParameters : public Common::Array<byte> {
|
||||
public:
|
||||
class Iterator {
|
||||
private:
|
||||
uint _index;
|
||||
const EventParameters &_data;
|
||||
public:
|
||||
Iterator(const EventParameters &owner) : _data(owner), _index(0) {}
|
||||
Iterator(const Iterator &it) : _data(it._data), _index(0) {}
|
||||
|
||||
/**
|
||||
* Return a byte
|
||||
*/
|
||||
byte readByte();
|
||||
|
||||
/**
|
||||
* Return a signed byte
|
||||
*/
|
||||
int8 readShort() { return (int8)readByte(); }
|
||||
|
||||
/**
|
||||
* Return a word
|
||||
*/
|
||||
uint16 readUint16LE();
|
||||
|
||||
/**
|
||||
* Return a 32-bit dword
|
||||
*/
|
||||
uint32 readUint32LE();
|
||||
};
|
||||
public:
|
||||
/**
|
||||
* Return an iterator for getting parameters
|
||||
*/
|
||||
Iterator getIterator() const {
|
||||
return Iterator(*this);
|
||||
}
|
||||
};
|
||||
|
||||
class MazeEvent {
|
||||
public:
|
||||
Common::Point _position;
|
||||
int _direction;
|
||||
int _line;
|
||||
Opcode _opcode;
|
||||
Common::Array<byte> _parameters;
|
||||
EventParameters _parameters;
|
||||
public:
|
||||
MazeEvent();
|
||||
|
||||
@ -155,6 +194,8 @@ private:
|
||||
Common::String _message;
|
||||
Common::String _displayMessage;
|
||||
|
||||
typedef EventParameters::Iterator ParamsIterator;
|
||||
|
||||
/**
|
||||
* Handles executing a given script command
|
||||
*/
|
||||
@ -163,279 +204,279 @@ private:
|
||||
/**
|
||||
* Do nothing
|
||||
*/
|
||||
bool cmdDoNothing(Common::Array<byte> ¶ms);
|
||||
bool cmdDoNothing(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Display a msesage on-screen
|
||||
*/
|
||||
bool cmdDisplay1(Common::Array<byte> ¶ms);
|
||||
bool cmdDisplay1(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Displays a door text message using the small font
|
||||
*/
|
||||
bool cmdDoorTextSml(Common::Array<byte> ¶ms);
|
||||
bool cmdDoorTextSml(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Displays a door text message using the large font
|
||||
*/
|
||||
bool cmdDoorTextLrg(Common::Array<byte> ¶ms);
|
||||
bool cmdDoorTextLrg(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Show a sign text on-screen
|
||||
*/
|
||||
bool cmdSignText(Common::Array<byte> ¶ms);
|
||||
bool cmdSignText(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Show an NPC interaction message
|
||||
*/
|
||||
bool cmdNPC(Common::Array<byte> ¶ms);
|
||||
bool cmdNPC(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Play a sound FX
|
||||
*/
|
||||
bool cmdPlayFX(Common::Array<byte> ¶ms);
|
||||
bool cmdPlayFX(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Handles teleportation
|
||||
*/
|
||||
bool cmdTeleport(Common::Array<byte> ¶ms);
|
||||
bool cmdTeleport(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Do a conditional check
|
||||
*/
|
||||
bool cmdIf(Common::Array<byte> ¶ms);
|
||||
bool cmdIf(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Moves the position of an object
|
||||
*/
|
||||
bool cmdMoveObj(Common::Array<byte> ¶ms);
|
||||
bool cmdMoveObj(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Take or give amounts from various character or party figures
|
||||
*/
|
||||
bool cmdTakeOrGive(Common::Array<byte> ¶ms);
|
||||
bool cmdTakeOrGive(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Removes an object from the playfield
|
||||
*/
|
||||
bool cmdRemove(Common::Array<byte> ¶ms);
|
||||
bool cmdRemove(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Set the currently active character for other script operations
|
||||
*/
|
||||
bool cmdSetChar(Common::Array<byte> ¶ms);
|
||||
bool cmdSetChar(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Spawn a monster
|
||||
*/
|
||||
bool cmdSpawn(Common::Array<byte> ¶ms);
|
||||
bool cmdSpawn(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Does various things that can be done within towns, like visiting
|
||||
* banks, guilds, etc.
|
||||
*/
|
||||
bool cmdDoTownEvent(Common::Array<byte> ¶ms);
|
||||
bool cmdDoTownEvent(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Stop executing the script
|
||||
*/
|
||||
bool cmdExit(Common::Array<byte> ¶ms);
|
||||
bool cmdExit(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Changes the value for the wall on a given cell
|
||||
*/
|
||||
bool cmdAlterMap(Common::Array<byte> ¶ms);
|
||||
bool cmdAlterMap(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
bool cmdGiveExtended(Common::Array<byte> ¶ms);
|
||||
bool cmdGiveExtended(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Confirms with the player for initiating the endgame
|
||||
*/
|
||||
bool cmdConfirmEnding(Common::Array<byte> ¶ms);
|
||||
bool cmdConfirmEnding(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Deals damage to a character
|
||||
*/
|
||||
bool cmdDamage(Common::Array<byte> ¶ms);
|
||||
bool cmdDamage(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Jump if a random number matches a given value
|
||||
*/
|
||||
bool cmdJumpRnd(Common::Array<byte> ¶ms);
|
||||
bool cmdJumpRnd(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Alter an existing event
|
||||
*/
|
||||
bool cmdAlterEvent(Common::Array<byte> ¶ms);
|
||||
bool cmdAlterEvent(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Stores the current location and line for later resuming, and set up to execute
|
||||
* a script at a given location
|
||||
*/
|
||||
bool cmdCallEvent(Common::Array<byte> ¶ms);
|
||||
bool cmdCallEvent(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Return from executing a script to the script location that previously
|
||||
* called the script
|
||||
*/
|
||||
bool cmdReturn(Common::Array<byte> ¶ms);
|
||||
bool cmdReturn(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Sets variables on characters like race, sex, and class
|
||||
*/
|
||||
bool cmdSetVar(Common::Array<byte> ¶ms);
|
||||
bool cmdSetVar(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Play the Clouds endgame
|
||||
*/
|
||||
bool cmdCutsceneEndClouds(Common::Array<byte> ¶ms);
|
||||
bool cmdCutsceneEndClouds(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Prompts the user for which character will do an action
|
||||
*/
|
||||
bool cmdWhoWill(Common::Array<byte> ¶ms);
|
||||
bool cmdWhoWill(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Deals a random amount of damage to a character
|
||||
*/
|
||||
bool cmdRndDamage(Common::Array<byte> ¶ms);
|
||||
bool cmdRndDamage(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Moves the wall object to the given coordinates. Doesn't change it's orientation.
|
||||
* Wall objects are only visible when viewed straight on, and were never intended
|
||||
* to be anywhere but on squares directly facing walls
|
||||
*/
|
||||
bool cmdMoveWallObj(Common::Array<byte> ¶ms);
|
||||
bool cmdMoveWallObj(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Sets the cell flag at the specified X/Y coordinate on the current map
|
||||
*/
|
||||
bool cmdAlterCellFlag(Common::Array<byte> ¶ms);
|
||||
bool cmdAlterCellFlag(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Sets the word value at the current X/Y location in the HED file
|
||||
* in memory to the given two bytes
|
||||
*/
|
||||
bool cmdAlterHed(Common::Array<byte> ¶ms);
|
||||
bool cmdAlterHed(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Displays a text string which includes some stat of the currently selected character
|
||||
*/
|
||||
bool cmdDisplayStat(Common::Array<byte> ¶ms);
|
||||
bool cmdDisplayStat(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Displays text in the scene window for various objects
|
||||
* the user interacts with
|
||||
*/
|
||||
bool cmdSignTextSml(Common::Array<byte> ¶ms);
|
||||
bool cmdSignTextSml(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* An array of six VOC filenames are hard-coded into the game executable file.
|
||||
* This function plays the VOC file at the specified index in this array
|
||||
*/
|
||||
bool cmdPlayEventVoc(Common::Array<byte> ¶ms);
|
||||
bool cmdPlayEventVoc(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Displays a large text message across the bottom of the screen
|
||||
*/
|
||||
bool cmdDisplayBottom(Common::Array<byte> ¶ms);
|
||||
bool cmdDisplayBottom(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Checks if a given map flag/monster has been set, and if so
|
||||
* jumps to a given line
|
||||
*/
|
||||
bool cmdIfMapFlag(Common::Array<byte> ¶ms);
|
||||
bool cmdIfMapFlag(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Selects a random character for further other actions
|
||||
*/
|
||||
bool cmdSelectRandomChar(Common::Array<byte> ¶ms);
|
||||
bool cmdSelectRandomChar(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Gives an enchanted item to a character
|
||||
*/
|
||||
bool cmdGiveEnchanted(Common::Array<byte> ¶ms);
|
||||
bool cmdGiveEnchanted(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Sets the item category for used in character operations
|
||||
*/
|
||||
bool cmdItemType(Common::Array<byte> ¶ms);
|
||||
bool cmdItemType(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Disable all the scripts at the party's current position
|
||||
*/
|
||||
bool cmdMakeNothingHere(Common::Array<byte> ¶ms);
|
||||
bool cmdMakeNothingHere(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Does a copy protection check
|
||||
*/
|
||||
bool cmdCheckProtection(Common::Array<byte> ¶ms);
|
||||
bool cmdCheckProtection(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Given a number of options, and a list of line numbers associated with
|
||||
* those options, jumps to whichever line for the option the user selects
|
||||
*/
|
||||
bool cmdChooseNumeric(Common::Array<byte> ¶ms);
|
||||
bool cmdChooseNumeric(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Displays a two line message at the bottom of the screen
|
||||
*/
|
||||
bool cmdDisplayBottomTwoLines(Common::Array<byte> ¶ms);
|
||||
bool cmdDisplayBottomTwoLines(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Displays a message
|
||||
*/
|
||||
bool cmdDisplayLarge(Common::Array<byte> ¶ms);
|
||||
bool cmdDisplayLarge(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Exchange the positions of two objects in the maze
|
||||
*/
|
||||
bool cmdExchObj(Common::Array<byte> ¶ms);
|
||||
bool cmdExchObj(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Handles making the player fall down to the ground
|
||||
*/
|
||||
bool cmdFallToMap(Common::Array<byte> ¶ms);
|
||||
bool cmdFallToMap(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Displays a message
|
||||
*/
|
||||
bool cmdDisplayMain(Common::Array<byte> ¶ms);
|
||||
bool cmdDisplayMain(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Jumps to a given line number if the surface at relative cell position 1 matches
|
||||
* a specified surface.
|
||||
* @remarks This opcode is apparently never actually used
|
||||
*/
|
||||
bool cmdGoto(Common::Array<byte> ¶ms);
|
||||
bool cmdGoto(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Pick a random value from the parameter list and jump to that line number
|
||||
*/
|
||||
bool cmdGotoRandom(Common::Array<byte> ¶ms);
|
||||
bool cmdGotoRandom(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Plays the Dark Side of Xeen ending
|
||||
*/
|
||||
bool cmdCutsceneEndDarkside(Common::Array<byte> ¶ms);
|
||||
bool cmdCutsceneEndDarkside(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Plays the World of Xeen ending
|
||||
*/
|
||||
bool cmdCutsceneEndWorld(Common::Array<byte> ¶ms);
|
||||
bool cmdCutsceneEndWorld(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Switches the player between the Clouds and Dark Side
|
||||
*/
|
||||
bool cmdFlipWorld(Common::Array<byte> ¶ms);
|
||||
bool cmdFlipWorld(ParamsIterator ¶ms);
|
||||
|
||||
/**
|
||||
* Plays a CD track
|
||||
*/
|
||||
bool cmdPlayCD(Common::Array<byte> ¶ms);
|
||||
bool cmdPlayCD(ParamsIterator ¶ms);
|
||||
|
||||
int whoWill(int v1, int v2, int v3);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user