1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifdef ENABLE_EOB
24 
25 #ifndef KYRA_SCRIPT_EOB_H
26 #define KYRA_SCRIPT_EOB_H
27 
28 #include "common/func.h"
29 #include "common/substream.h"
30 #include "common/savefile.h"
31 
32 namespace Kyra {
33 
34 class KyraRpgEngine;
35 
36 class EoBInfProcessor {
37 public:
38 	EoBInfProcessor(EoBCoreEngine *engine, Screen_EoB *_screen);
39 	~EoBInfProcessor();
40 
41 	void loadData(const uint8 *data, uint32 dataSize);
42 	void run(int func, int flags);
43 
44 	void setFlags(uint32 flags);
45 	void clearFlags(uint32 flags);
46 	bool checkFlags(uint32 flags) const;
47 	bool preventRest() const;
48 
49 	void loadState(Common::SeekableSubReadStreamEndian &in, bool origFile = false);
50 	void saveState(Common::OutSaveFile *out, bool origFile = false);
51 	void reset();
52 
53 private:
54 	const char *getString(uint16 index);
55 
56 	int oeob_setWallType(int8 *data);
57 	int oeob_toggleWallState(int8 *data);
58 	int oeob_openDoor(int8 *data);
59 	int oeob_closeDoor(int8 *data);
60 	int oeob_replaceMonster(int8 *data);
61 	int oeob_movePartyOrObject(int8 *data);
62 	int oeob_moveInventoryItemToBlock(int8 *data);
63 	int oeob_printMessage_v1(int8 *data);
64 	int oeob_printMessage_v2(int8 *data);
65 	int oeob_setFlags(int8 *data);
66 	int oeob_playSoundEffect(int8 *data);
67 	int oeob_removeFlags(int8 *data);
68 	int oeob_modifyCharacterHitPoints(int8 *data);
69 	int oeob_calcAndInflictCharacterDamage(int8 *data);
70 	int oeob_jump(int8 *data);
71 	int oeob_end(int8 *data);
72 	int oeob_returnFromSubroutine(int8 *data);
73 	int oeob_callSubroutine(int8 *data);
74 	int oeob_eval_v1(int8 *data);
75 	int oeob_eval_v2(int8 *data);
76 	int oeob_deleteItem(int8 *data);
77 	int oeob_loadNewLevelOrMonsters(int8 *data);
78 	int oeob_increasePartyExperience(int8 *data);
79 	int oeob_createItem_v1(int8 *data);
80 	int oeob_createItem_v2(int8 *data);
81 	int oeob_launchObject(int8 *data);
82 	int oeob_changeDirection(int8 *data);
83 	int oeob_identifyItems(int8 *data);
84 	int oeob_sequence(int8 *data);
85 	int oeob_delay(int8 *data);
86 	int oeob_drawScene(int8 *data);
87 	int oeob_dialogue(int8 *data);
88 	int oeob_specialEvent(int8 *data);
89 
90 	EoBCoreEngine *_vm;
91 	Screen_EoB *_screen;
92 
93 	typedef Common::Functor1Mem<int8 *, int, EoBInfProcessor> InfProc;
94 	struct InfOpcode : private Common::NonCopyable {
InfOpcodeInfOpcode95 		InfOpcode(InfProc *p, const char *d) : proc(p), desc(d) {}
~InfOpcodeInfOpcode96 		~InfOpcode() { delete proc; }
97 
98 		InfProc *proc;
99 		Common::String desc;
100 	};
101 	Common::Array<const InfOpcode *> _opcodes;
102 
103 	int8 *_scriptData;
104 	uint16 _scriptSize;
105 
106 	uint8 _abortScript;
107 	uint16 _abortAfterSubroutine;
108 	int _dlgResult;
109 	uint8 _preventRest;
110 
111 	uint16 _lastScriptFunc;
112 	uint16 _lastScriptFlags;
113 
114 	int8 **_subroutineStack;
115 	int _subroutineStackPos;
116 
117 	uint32 *_flagTable;
118 
119 	int16 *_stack;
120 	int _stackIndex;
121 
122 	int8 _activeCharacter;
123 
124 	static const uint8 _amigaColorMap[16];
125 
126 	const int _commandMin;
127 };
128 
129 } // End of namespace Kyra
130 
131 #endif
132 
133 #endif // ENABLE_EOB
134