123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
-
-
- #ifndef _SCRIPT_H_
- #define _SCRIPT_H_
-
- #include "utils/binary.h"
-
- #include <cstdint>
- #include <functional>
- #include <string>
- #include <vector>
-
-
- class Script {
- public:
-
- typedef enum {
- S_English = 0,
- S_French = 1,
- S_German = 2,
- S_American = 3,
- S_Japanese = 4
- } ScriptLanguage;
-
- typedef enum {
- OP_PICTURE = 0,
- OP_PSX_TRACK = 1,
- OP_PSX_FMV = 2,
- OP_FMV = 3,
- OP_GAME = 4,
- OP_CUT = 5,
- OP_COMPLETE = 6,
- OP_DEMO = 7,
- OP_PSX_DEMO = 8,
- OP_END = 9,
- OP_TRACK = 10,
- OP_SUNSET = 11,
- OP_LOAD_PIC = 12,
- OP_DEADLY_WATER = 13,
- OP_REMOVE_WEAPONS = 14,
- OP_GAMECOMPLETE = 15,
- OP_CUTANGLE = 16,
- OP_NOFLOOR = 17,
- OP_STARTINV = 18,
- OP_STARTANIM = 19,
- OP_SECRETS = 20,
- OP_KILLTOCOMPLETE = 21,
- OP_REMOVE_AMMO = 22,
- OP_UNKNOWN = 23
- } ScriptOpCode;
-
-
-
-
- typedef enum {
- OP_WEAPON_PISTOLS = 0,
- OP_WEAPON_SHOTGUN = 1,
- OP_WEAPON_AUTOPISTOLS = 2,
- OP_WEAPON_UZIS = 3,
- OP_WEAPON_HARPOON = 4,
- OP_WEAPON_M16 = 5,
- OP_WEAPON_ROCKET = 6,
- OP_AMMO_PISTOLS = 7,
- OP_AMMO_SHOTGUN = 8,
- OP_AMMO_AUTOPISTOLS = 9,
- OP_AMMO_UZIS = 10,
- OP_AMMO_HARPOON = 11,
- OP_AMMO_M16 = 12,
- OP_AMMO_ROCKET = 13,
- OP_ITEM_FLARE = 14,
- OP_ITEM_MEDI = 15,
- OP_ITEM_BIGMEDI = 16,
- OP_ITEM_PICKUP1 = 17,
- OP_ITEM_PICKUP2 = 18,
- OP_ITEM_PUZZLE1 = 19,
- OP_ITEM_PUZZLE2 = 20,
- OP_ITEM_PUZZLE3 = 21,
- OP_ITEM_PUZZLE4 = 22,
- OP_ITEM_KEY1 = 23,
- OP_ITEM_KEY2 = 24,
- OP_ITEM_KEY3 = 25,
- OP_ITEM_KEY4 = 26,
- OP_ITEM_UNKNOWN = 27
- } ScriptItem;
-
- Script();
-
- int load(std::string file);
-
- unsigned int levelCount();
- std::string getLevelName(unsigned int i);
- std::string getLevelFilename(unsigned int i);
-
- unsigned int pictureCount();
- std::string getPictureFilename(unsigned int i);
-
- unsigned int cutsceneCount();
- std::string getCutsceneFilename(unsigned int i);
-
- unsigned int titleCount();
- std::string getTitleFilename(unsigned int i);
-
- unsigned int videoCount();
- std::string getVideoFilename(unsigned int i);
-
- unsigned int gameStringCount();
- std::string getGameString(unsigned int i);
-
- unsigned int pcStringCount();
- std::string getPCString(unsigned int i);
-
- std::string getPuzzleString(unsigned int i, unsigned int j);
- std::string getPickupString(unsigned int i, unsigned int j);
- std::string getKeyString(unsigned int i, unsigned int j);
-
- void registerScriptHandler(ScriptOpCode op, std::function<int (bool, uint16_t)> func);
- int runScript(unsigned int level);
-
- std::string getDescription() { return description; }
- std::string getLanguage();
-
- private:
-
- typedef enum {
- S_DemoVersion = (1 << 0),
- S_TitleDisabled = (1 << 1),
- S_CheatModeCheckDisabled = (1 << 2),
- S_NoInputTimeout = (1 << 3),
- S_LoadSaveDisabled = (1 << 4),
- S_ScreenSizingDisabled = (1 << 5),
- S_LockOutOptionRing = (1 << 6),
- S_DOZYCheatEnabled = (1 << 7),
- S_UseSecurityTag = (1 << 8),
- S_Unknown = (1 << 9),
- S_SelectAnyLevel = (1 << 10),
- S_EnableCheatCode = (1 << 11)
- } ScriptFlag;
-
- void readStringPackage(BinaryFile& f, std::vector<std::string>& v, unsigned int n);
- void readScriptPackage(BinaryFile& f, std::vector<std::vector<uint16_t>>& v, unsigned int n);
-
- const static bool opcodeHasOperand[OP_UNKNOWN];
-
-
- uint32_t version;
- std::string description;
-
-
- uint32_t firstOption;
- int32_t titleReplace;
- uint32_t onDeathDemoMode;
- uint32_t onDeathInGame;
- uint32_t noInputTime;
- uint32_t onDemoInterrupt;
- uint32_t onDemoEnd;
- uint16_t numLevels;
- uint16_t numPictures;
- uint16_t numTitles;
- uint16_t numFMVs;
- uint16_t numCutscenes;
- uint16_t numDemos;
- uint16_t titleTrack;
- int16_t singleLevel;
- uint16_t flags;
- uint8_t cypherCode;
- uint8_t language;
- uint16_t secretTrack;
-
- uint16_t numPCStrings;
- uint16_t numGameStrings;
-
-
- std::vector<std::string> levelNames;
- std::vector<std::string> pictureFilenames;
- std::vector<std::string> titleFilenames;
- std::vector<std::string> fmvFilenames;
- std::vector<std::string> levelFilenames;
- std::vector<std::string> cutsceneFilenames;
- std::vector<std::vector<uint16_t>> script;
- std::vector<std::string> gameStrings;
- std::vector<std::string> pcStrings;
- std::vector<std::vector<std::string>> puzzles;
- std::vector<std::vector<std::string>> pickups;
- std::vector<std::vector<std::string>> keys;
-
- std::function<int (bool, uint16_t)> scriptHandlers[OP_UNKNOWN];
- };
-
- #endif
|