ScummVM API documentation
console.h
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 modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (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, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef SCI_CONSOLE_H
23 #define SCI_CONSOLE_H
24 
25 #include "gui/debugger.h"
26 #include "sci/engine/vm.h"
27 
28 namespace Sci {
29 
30 class SciEngine;
31 struct List;
32 
33 reg_t disassemble(EngineState *s, reg_t pos, const Object *obj, bool printBWTag, bool printBytecode, bool printCSyntax);
34 bool isJumpOpcode(EngineState *s, reg_t pos, reg_t& jumpOffset);
35 
36 class Console : public GUI::Debugger {
37 public:
38  Console(SciEngine *engine);
39  ~Console() override;
40 
45  void attach(const char *entry = nullptr) override;
46 
47 private:
48  void preEnter() override;
49  void postEnter() override;
50 
51  // General
52  bool cmdHelp(int argc, const char **argv);
53  // Kernel
54  bool cmdOpcodes(int argc, const char **argv);
55  bool cmdSelector(int argc, const char **argv);
56  bool cmdSelectors(int argc, const char **argv);
57  bool cmdKernelFunctions(int argc, const char **argv);
58  bool cmdKernelCall(int argc, const char **argv);
59  bool cmdClassTable(int argc, const char **argv);
60  // Parser
61  bool cmdSuffixes(int argc, const char **argv);
62  bool cmdParseGrammar(int argc, const char **argv);
63  bool cmdParserNodes(int argc, const char **argv);
64  bool cmdParserWords(int argc, const char **argv);
65  bool cmdSentenceFragments(int argc, const char **argv);
66  bool cmdParse(int argc, const char **argv);
67  bool cmdSetParseNodes(int argc, const char **argv);
68  bool cmdSaid(int argc, const char **argv);
69  // Resources
70  bool cmdDiskDump(int argc, const char **argv);
71  void cmdDiskDumpWorker(ResourceType resourceType, int resourceNumber, uint32 resourceTuple);
72  bool cmdHexDump(int argc, const char **argv);
73  bool cmdResourceId(int argc, const char **argv);
74  bool cmdResourceInfo(int argc, const char **argv);
75  bool cmdResourceTypes(int argc, const char **argv);
76  bool cmdList(int argc, const char **argv);
77  bool cmdResourceIntegrityDump(int argc, const char **argv);
78  bool cmdAllocList(int argc, const char **argv);
79  bool cmdHexgrep(int argc, const char **argv);
80  bool cmdVerifyScripts(int argc, const char **argv);
81  // Game
82  bool cmdSaveGame(int argc, const char **argv);
83  bool cmdRestoreGame(int argc, const char **argv);
84  bool cmdRestartGame(int argc, const char **argv);
85  bool cmdGetVersion(int argc, const char **argv);
86  bool cmdRoomNumber(int argc, const char **argv);
87  bool cmdQuit(int argc, const char **argv);
88  bool cmdListSaves(int argc, const char **argv);
89  // Screen
90  bool cmdShowMap(int argc, const char **argv);
91  // Graphics
92  bool cmdSetPalette(int argc, const char **argv);
93  bool cmdDrawPic(int argc, const char **argv);
94  bool cmdDrawCel(int argc, const char **argv);
95  bool cmdUndither(int argc, const char **argv);
96  bool cmdPicVisualize(int argc, const char **argv);
97  bool cmdPlayVideo(int argc, const char **argv);
98  bool cmdAnimateList(int argc, const char **argv);
99  bool cmdWindowList(int argc, const char **argv);
100  bool cmdPlaneList(int argc, const char **argv);
101  bool cmdVisiblePlaneList(int argc, const char **argv);
102  bool cmdPlaneItemList(int argc, const char **argv);
103  bool cmdVisiblePlaneItemList(int argc, const char **argv);
104  bool cmdSavedBits(int argc, const char **argv);
105  bool cmdShowSavedBits(int argc, const char **argv);
106  // Segments
107  bool cmdPrintSegmentTable(int argc, const char **argv);
108  bool cmdSegmentInfo(int argc, const char **argv);
109  bool cmdKillSegment(int argc, const char **argv);
110  // Garbage collection
111  bool cmdGCInvoke(int argc, const char **argv);
112  bool cmdGCObjects(int argc, const char **argv);
113  bool cmdGCShowReachable(int argc, const char **argv);
114  bool cmdGCShowFreeable(int argc, const char **argv);
115  bool cmdGCNormalize(int argc, const char **argv);
116  // Music/SFX
117  bool cmdSongLib(int argc, const char **argv);
118  bool cmdSongInfo(int argc, const char **argv);
119  bool cmdIsSample(int argc, const char **argv);
120  bool cmdStartSound(int argc, const char **argv);
121  bool cmdToggleSound(int argc, const char **argv);
122  bool cmdStopAllSounds(int argc, const char **argv);
123  bool cmdSfx01Header(int argc, const char **argv);
124  bool cmdSfx01Track(int argc, const char **argv);
125  bool cmdShowInstruments(int argc, const char **argv);
126  bool cmdMapInstrument(int argc, const char **argv);
127  bool cmdAudioList(int argc, const char **argv);
128  bool cmdAudioDump(int argc, const char **argv);
129  // Script
130  bool cmdAddresses(int argc, const char **argv);
131  bool cmdRegisters(int argc, const char **argv);
132  bool cmdDissectScript(int argc, const char **argv);
133  bool cmdBacktrace(int argc, const char **argv);
134  bool cmdTrace(int argc, const char **argv);
135  bool cmdStepOver(int argc, const char **argv);
136  bool cmdStepEvent(int argc, const char **argv);
137  bool cmdStepRet(int argc, const char **argv);
138  bool cmdStepGlobal(int argc, const char **argv);
139  bool cmdStepCallk(int argc, const char **argv);
140  bool cmdDisassemble(int argc, const char **argv);
141  bool cmdDisassembleAddress(int argc, const char **argv);
142  bool cmdFindKernelFunctionCall(int argc, const char **argv);
143  bool cmdSend(int argc, const char **argv);
144  bool cmdGo(int argc, const char **argv);
145  bool cmdLogKernel(int argc, const char **argv);
146  bool cmdMapVocab994(int argc, const char **argv);
147  bool cmdGameFlagsInit(int argc, const char **argv);
148  bool cmdGameFlagsTest(int argc, const char **argv);
149  bool cmdGameFlagsSet(int argc, const char **argv);
150  bool cmdGameFlagsClear(int argc, const char **argv);
151  // Breakpoints
152  bool cmdBreakpointList(int argc, const char **argv);
153  bool cmdBreakpointDelete(int argc, const char **argv);
154  bool cmdBreakpointAction(int argc, const char **argv);
155  bool cmdBreakpointMethod(int argc, const char **argv);
156  bool cmdBreakpointRead(int argc, const char **argv);
157  bool cmdBreakpointWrite(int argc, const char **argv);
158  bool cmdBreakpointKernel(int argc, const char **argv);
159  bool cmdBreakpointFunction(int argc, const char **argv);
160  bool cmdBreakpointAddress(int argc, const char **argv);
161  // VM
162  bool cmdScriptSteps(int argc, const char **argv);
163  bool cmdScriptObjects(int argc, const char **argv);
164  bool cmdScriptStrings(int argc, const char **argv);
165  bool cmdScriptSaid(int argc, const char **argv);
166  bool cmdVMVarlist(int argc, const char **argv);
167  bool cmdVMVars(int argc, const char **argv);
168  bool cmdLocalVars(int argc, const char **argv);
169  bool cmdStack(int argc, const char **argv);
170  bool cmdValueType(int argc, const char **argv);
171  bool cmdViewListNode(int argc, const char **argv);
172  bool cmdViewReference(int argc, const char **argv);
173  bool cmdDumpReference(int argc, const char **argv);
174  bool cmdViewObject(int argc, const char **argv);
175  bool cmdViewActiveObject(int argc, const char **argv);
176  bool cmdViewAccumulatorObject(int argc, const char **argv);
177  // Variables
178  bool cmdSpeedThrottle(int argc, const char **argv);
179 
180  bool parseInteger(const char *argument, int &result);
181  bool parseResourceNumber36(const char *userParameter, uint16 &resourceNumber, uint32 &resourceTuple);
182 
183  void printBasicVarInfo(reg_t variable);
184 
185  bool segmentInfo(int nr);
186  void printList(reg_t addr);
187  void printList(const List &list);
188  int printNode(reg_t addr);
189  void hexDumpReg(const reg_t *data, int len, int regsPerLine = 4, int startOffset = 0, bool isArray = false);
190  void printOffsets(int scriptNr, uint16 showType);
191 
192 private:
198  void printKernelCallsFound(int kernelFuncNum, bool showFoundScripts);
199 
200  void printBreakpoint(int index, const Breakpoint &bp);
201  void printReference(reg_t reg, reg_t reg_end = NULL_REG);
202 #ifdef ENABLE_SCI32
203  void printArray(reg_t reg);
204  void printBitmap(reg_t reg);
205 #endif
206 
207  void writeIntegrityDumpLine(const Common::String &statusName, const Common::String &resourceName, Common::WriteStream &out, Common::ReadStream *const data, const int size, const bool writeHash);
208 
209  enum GameFlagsOperation {
210  kGameFlagsTest,
211  kGameFlagsSet,
212  kGameFlagsClear
213  };
214  bool processGameFlagsOperation(GameFlagsOperation operation, int argc, const char **argv);
215 
216  SciEngine *_engine;
217  DebugState &_debugState;
218  Common::Path _videoFile;
219  int _videoFrameDelay;
220  uint16 _gameFlagsGlobal;
221 };
222 
223 } // End of namespace Sci
224 
225 #endif
Definition: state.h:100
Definition: str.h:59
Definition: debug.h:74
Definition: stream.h:77
Definition: debugger.h:41
Definition: path.h:52
Definition: segment.h:202
Definition: object.h:69
Definition: console.h:28
void attach(const char *entry=nullptr) override
Definition: stream.h:385
Definition: sci.h:135
Definition: vm_types.h:39
Definition: console.h:36
Definition: debug.h:57