1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
|
/* 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.
*
* $URL$
* $Id$
*
*/
#ifndef GOB_INTER_H
#define GOB_INTER_H
#include "common/func.h"
#include "common/hashmap.h"
#include "gob/goblin.h"
#include "gob/variables.h"
namespace Gob {
// This is to help devices with small memory (PDA, smartphones, ...)
// to save abit of memory used by opcode names in the Scumm engine.
#ifndef REDUCE_MEMORY_USAGE
#define _OPCODEDRAW(ver, x) setProc(new Common::Functor0Mem<void, ver>(this, &ver::x), #x)
#define _OPCODEFUNC(ver, x) setProc(new Common::Functor1Mem<OpFuncParams &, bool, ver>(this, &ver::x), #x)
#define _OPCODEGOB(ver, x) setProc(new Common::Functor1Mem<OpGobParams &, void, ver>(this, &ver::x), #x)
#else
#define _OPCODEDRAW(ver, x) setProc(new Common::Functor0Mem<void, ver>(this, &ver::x), "")
#define _OPCODEFUNC(ver, x) setProc(new Common::Functor1Mem<OpFuncParams &, bool, ver>(this, &ver::x), "")
#define _OPCODEGOB(ver, x) setProc(new Common::Functor1Mem<OpGobParams &, void, ver>(this, &ver::x), "")
#endif
#define CLEAROPCODEDRAW(i) _opcodesDraw[i].setProc(0, 0)
#define CLEAROPCODEFUNC(i) _opcodesFunc[i].setProc(0, 0)
#define CLEAROPCODEGOB(i) _opcodesGob.erase(i)
typedef Common::Functor0<void> OpcodeDraw;
typedef Common::Functor1<struct OpFuncParams &, bool> OpcodeFunc;
typedef Common::Functor1<struct OpGobParams &, void> OpcodeGob;
struct OpFuncParams {
byte cmdCount;
byte counter;
int16 retFlag;
};
struct OpGobParams {
int16 extraData;
int16 paramCount;
VariableReference retVarPtr;
Goblin::Gob_Object *objDesc;
};
template<typename T>
struct OpcodeEntry : Common::NonCopyable {
T *proc;
const char *desc;
OpcodeEntry() : proc(0), desc(0) {}
~OpcodeEntry() {
setProc(0, 0);
}
void setProc(T *p, const char *d) {
if (proc != p) {
delete proc;
proc = p;
}
desc = d;
}
};
class Inter {
public:
uint8 _terminate;
int16 *_breakFromLevel;
int16 *_nestLevel;
uint32 _soundEndTimeKey;
int16 _soundStopVal;
Variables *_variables;
void setupOpcodes();
void initControlVars(char full);
void renewTimeInVars();
void storeMouse();
void storeKey(int16 key);
void writeVar(uint32 offset, uint16 type, uint32 value);
void funcBlock(int16 retFlag);
void callSub(int16 retFlag);
void allocateVars(uint32 count);
void delocateVars();
virtual int16 loadSound(int16 slot) = 0;
virtual void animPalette() = 0;
Inter(GobEngine *vm);
virtual ~Inter();
protected:
OpcodeEntry<OpcodeDraw> _opcodesDraw[256];
OpcodeEntry<OpcodeFunc> _opcodesFunc[256];
Common::HashMap<int, OpcodeEntry<OpcodeGob> > _opcodesGob;
bool _break;
int16 _animPalLowIndex[8];
int16 _animPalHighIndex[8];
int16 _animPalDir[8];
byte _varStack[300];
int16 _varStackPos;
// The busy-wait detection in o1_keyFunc breaks fast scrolling in Ween
bool _noBusyWait;
GobEngine *_vm;
void executeOpcodeDraw(byte i);
bool executeOpcodeFunc(byte i, byte j, OpFuncParams ¶ms);
void executeOpcodeGob(int i, OpGobParams ¶ms);
const char *getDescOpcodeDraw(byte i);
const char *getDescOpcodeFunc(byte i, byte j);
const char *getDescOpcodeGob(int i);
virtual void setupOpcodesDraw() = 0;
virtual void setupOpcodesFunc() = 0;
virtual void setupOpcodesGob() = 0;
virtual void checkSwitchTable(uint32 &offset) = 0;
void o_drawNOP() {}
bool o_funcNOP(OpFuncParams ¶ms) { return false; }
void o_gobNOP(OpGobParams ¶ms) {}
};
class Inter_v1 : public Inter {
public:
Inter_v1(GobEngine *vm);
virtual ~Inter_v1() {}
virtual int16 loadSound(int16 slot);
virtual void animPalette();
protected:
virtual void setupOpcodesDraw();
virtual void setupOpcodesFunc();
virtual void setupOpcodesGob();
virtual void checkSwitchTable(uint32 &offset);
void o1_loadMult();
void o1_playMult();
void o1_freeMultKeys();
void o1_initCursor();
void o1_initCursorAnim();
void o1_clearCursorAnim();
void o1_setRenderFlags();
void o1_loadAnim();
void o1_freeAnim();
void o1_updateAnim();
void o1_initMult();
void o1_freeMult();
void o1_animate();
void o1_loadMultObject();
void o1_getAnimLayerInfo();
void o1_getObjAnimSize();
void o1_loadStatic();
void o1_freeStatic();
void o1_renderStatic();
void o1_loadCurLayer();
void o1_playCDTrack();
void o1_getCDTrackPos();
void o1_stopCD();
void o1_loadFontToSprite();
void o1_freeFontToSprite();
bool o1_callSub(OpFuncParams ¶ms);
bool o1_printTotText(OpFuncParams ¶ms);
bool o1_loadCursor(OpFuncParams ¶ms);
bool o1_switch(OpFuncParams ¶ms);
bool o1_repeatUntil(OpFuncParams ¶ms);
bool o1_whileDo(OpFuncParams ¶ms);
bool o1_if(OpFuncParams ¶ms);
bool o1_assign(OpFuncParams ¶ms);
bool o1_loadSpriteToPos(OpFuncParams ¶ms);
bool o1_printText(OpFuncParams ¶ms);
bool o1_loadTot(OpFuncParams ¶ms);
bool o1_palLoad(OpFuncParams ¶ms);
bool o1_keyFunc(OpFuncParams ¶ms);
bool o1_capturePush(OpFuncParams ¶ms);
bool o1_capturePop(OpFuncParams ¶ms);
bool o1_animPalInit(OpFuncParams ¶ms);
bool o1_drawOperations(OpFuncParams ¶ms);
bool o1_setcmdCount(OpFuncParams ¶ms);
bool o1_return(OpFuncParams ¶ms);
bool o1_renewTimeInVars(OpFuncParams ¶ms);
bool o1_speakerOn(OpFuncParams ¶ms);
bool o1_speakerOff(OpFuncParams ¶ms);
bool o1_putPixel(OpFuncParams ¶ms);
bool o1_goblinFunc(OpFuncParams ¶ms);
bool o1_createSprite(OpFuncParams ¶ms);
bool o1_freeSprite(OpFuncParams ¶ms);
bool o1_returnTo(OpFuncParams ¶ms);
bool o1_loadSpriteContent(OpFuncParams ¶ms);
bool o1_copySprite(OpFuncParams ¶ms);
bool o1_fillRect(OpFuncParams ¶ms);
bool o1_drawLine(OpFuncParams ¶ms);
bool o1_strToLong(OpFuncParams ¶ms);
bool o1_invalidate(OpFuncParams ¶ms);
bool o1_setBackDelta(OpFuncParams ¶ms);
bool o1_playSound(OpFuncParams ¶ms);
bool o1_stopSound(OpFuncParams ¶ms);
bool o1_loadSound(OpFuncParams ¶ms);
bool o1_freeSoundSlot(OpFuncParams ¶ms);
bool o1_waitEndPlay(OpFuncParams ¶ms);
bool o1_playComposition(OpFuncParams ¶ms);
bool o1_getFreeMem(OpFuncParams ¶ms);
bool o1_checkData(OpFuncParams ¶ms);
bool o1_cleanupStr(OpFuncParams ¶ms);
bool o1_insertStr(OpFuncParams ¶ms);
bool o1_cutStr(OpFuncParams ¶ms);
bool o1_strstr(OpFuncParams ¶ms);
bool o1_istrlen(OpFuncParams ¶ms);
bool o1_setMousePos(OpFuncParams ¶ms);
bool o1_setFrameRate(OpFuncParams ¶ms);
bool o1_animatePalette(OpFuncParams ¶ms);
bool o1_animateCursor(OpFuncParams ¶ms);
bool o1_blitCursor(OpFuncParams ¶ms);
bool o1_loadFont(OpFuncParams ¶ms);
bool o1_freeFont(OpFuncParams ¶ms);
bool o1_readData(OpFuncParams ¶ms);
bool o1_writeData(OpFuncParams ¶ms);
bool o1_manageDataFile(OpFuncParams ¶ms);
void o1_setState(OpGobParams ¶ms);
void o1_setCurFrame(OpGobParams ¶ms);
void o1_setNextState(OpGobParams ¶ms);
void o1_setMultState(OpGobParams ¶ms);
void o1_setOrder(OpGobParams ¶ms);
void o1_setActionStartState(OpGobParams ¶ms);
void o1_setCurLookDir(OpGobParams ¶ms);
void o1_setType(OpGobParams ¶ms);
void o1_setNoTick(OpGobParams ¶ms);
void o1_setPickable(OpGobParams ¶ms);
void o1_setXPos(OpGobParams ¶ms);
void o1_setYPos(OpGobParams ¶ms);
void o1_setDoAnim(OpGobParams ¶ms);
void o1_setRelaxTime(OpGobParams ¶ms);
void o1_setMaxTick(OpGobParams ¶ms);
void o1_getState(OpGobParams ¶ms);
void o1_getCurFrame(OpGobParams ¶ms);
void o1_getNextState(OpGobParams ¶ms);
void o1_getMultState(OpGobParams ¶ms);
void o1_getOrder(OpGobParams ¶ms);
void o1_getActionStartState(OpGobParams ¶ms);
void o1_getCurLookDir(OpGobParams ¶ms);
void o1_getType(OpGobParams ¶ms);
void o1_getNoTick(OpGobParams ¶ms);
void o1_getPickable(OpGobParams ¶ms);
void o1_getObjMaxFrame(OpGobParams ¶ms);
void o1_getXPos(OpGobParams ¶ms);
void o1_getYPos(OpGobParams ¶ms);
void o1_getDoAnim(OpGobParams ¶ms);
void o1_getRelaxTime(OpGobParams ¶ms);
void o1_getMaxTick(OpGobParams ¶ms);
void o1_manipulateMap(OpGobParams ¶ms);
void o1_getItem(OpGobParams ¶ms);
void o1_manipulateMapIndirect(OpGobParams ¶ms);
void o1_getItemIndirect(OpGobParams ¶ms);
void o1_setPassMap(OpGobParams ¶ms);
void o1_setGoblinPosH(OpGobParams ¶ms);
void o1_getGoblinPosXH(OpGobParams ¶ms);
void o1_getGoblinPosYH(OpGobParams ¶ms);
void o1_setGoblinMultState(OpGobParams ¶ms);
void o1_setGoblinUnk14(OpGobParams ¶ms);
void o1_setItemIdInPocket(OpGobParams ¶ms);
void o1_setItemIndInPocket(OpGobParams ¶ms);
void o1_getItemIdInPocket(OpGobParams ¶ms);
void o1_getItemIndInPocket(OpGobParams ¶ms);
void o1_setGoblinPos(OpGobParams ¶ms);
void o1_setGoblinState(OpGobParams ¶ms);
void o1_setGoblinStateRedraw(OpGobParams ¶ms);
void o1_decRelaxTime(OpGobParams ¶ms);
void o1_getGoblinPosX(OpGobParams ¶ms);
void o1_getGoblinPosY(OpGobParams ¶ms);
void o1_clearPathExistence(OpGobParams ¶ms);
void o1_setGoblinVisible(OpGobParams ¶ms);
void o1_setGoblinInvisible(OpGobParams ¶ms);
void o1_getObjectIntersect(OpGobParams ¶ms);
void o1_getGoblinIntersect(OpGobParams ¶ms);
void o1_setItemPos(OpGobParams ¶ms);
void o1_loadObjects(OpGobParams ¶ms);
void o1_freeObjects(OpGobParams ¶ms);
void o1_animateObjects(OpGobParams ¶ms);
void o1_drawObjects(OpGobParams ¶ms);
void o1_loadMap(OpGobParams ¶ms);
void o1_moveGoblin(OpGobParams ¶ms);
void o1_switchGoblin(OpGobParams ¶ms);
void o1_loadGoblin(OpGobParams ¶ms);
void o1_writeTreatItem(OpGobParams ¶ms);
void o1_moveGoblin0(OpGobParams ¶ms);
void o1_setGoblinTarget(OpGobParams ¶ms);
void o1_setGoblinObjectsPos(OpGobParams ¶ms);
void o1_initGoblin(OpGobParams ¶ms);
void manipulateMap(int16 xPos, int16 yPos, int16 item);
};
class Inter_v2 : public Inter_v1 {
public:
Inter_v2(GobEngine *vm);
virtual ~Inter_v2() {}
virtual int16 loadSound(int16 search);
virtual void animPalette();
protected:
virtual void setupOpcodesDraw();
virtual void setupOpcodesFunc();
virtual void setupOpcodesGob();
virtual void checkSwitchTable(uint32 &offset);
void o2_playMult();
void o2_freeMultKeys();
void o2_setRenderFlags();
void o2_multSub();
void o2_initMult();
void o2_loadMultObject();
void o2_renderStatic();
void o2_loadCurLayer();
void o2_playCDTrack();
void o2_waitCDTrackEnd();
void o2_stopCD();
void o2_readLIC();
void o2_freeLIC();
void o2_getCDTrackPos();
void o2_loadFontToSprite();
void o2_totSub();
void o2_switchTotSub();
void o2_pushVars();
void o2_popVars();
void o2_loadMapObjects();
void o2_freeGoblins();
void o2_moveGoblin();
void o2_writeGoblinPos();
void o2_stopGoblin();
void o2_setGoblinState();
void o2_placeGoblin();
void o2_initScreen();
void o2_scroll();
void o2_setScrollOffset();
void o2_playImd();
void o2_getImdInfo();
void o2_openItk();
void o2_closeItk();
void o2_setImdFrontSurf();
void o2_resetImdFrontSurf();
bool o2_assign(OpFuncParams ¶ms);
bool o2_printText(OpFuncParams ¶ms);
bool o2_animPalInit(OpFuncParams ¶ms);
bool o2_addHotspot(OpFuncParams ¶ms);
bool o2_removeHotspot(OpFuncParams ¶ms);
bool o2_goblinFunc(OpFuncParams ¶ms);
bool o2_stopSound(OpFuncParams ¶ms);
bool o2_loadSound(OpFuncParams ¶ms);
bool o2_getFreeMem(OpFuncParams ¶ms);
bool o2_checkData(OpFuncParams ¶ms);
bool o2_readData(OpFuncParams ¶ms);
bool o2_writeData(OpFuncParams ¶ms);
void o2_loadInfogramesIns(OpGobParams ¶ms);
void o2_playInfogrames(OpGobParams ¶ms);
void o2_startInfogrames(OpGobParams ¶ms);
void o2_stopInfogrames(OpGobParams ¶ms);
void o2_handleGoblins(OpGobParams ¶ms);
void o2_playProtracker(OpGobParams ¶ms);
void o2_stopProtracker(OpGobParams ¶ms);
};
class Inter_Bargon : public Inter_v2 {
public:
Inter_Bargon(GobEngine *vm);
virtual ~Inter_Bargon() {}
protected:
virtual void setupOpcodesDraw();
virtual void setupOpcodesFunc();
virtual void setupOpcodesGob();
void oBargon_intro0(OpGobParams ¶ms);
void oBargon_intro1(OpGobParams ¶ms);
void oBargon_intro2(OpGobParams ¶ms);
void oBargon_intro3(OpGobParams ¶ms);
void oBargon_intro4(OpGobParams ¶ms);
void oBargon_intro5(OpGobParams ¶ms);
void oBargon_intro6(OpGobParams ¶ms);
void oBargon_intro7(OpGobParams ¶ms);
void oBargon_intro8(OpGobParams ¶ms);
void oBargon_intro9(OpGobParams ¶ms);
};
class Inter_Fascination : public Inter_v2 {
public:
Inter_Fascination(GobEngine *vm);
virtual ~Inter_Fascination() {}
protected:
virtual void setupOpcodesDraw();
virtual void setupOpcodesFunc();
virtual void setupOpcodesGob();
void oFascin_playProtracker(OpGobParams ¶ms);
void oFascin_geUnknown0(OpGobParams ¶ms);
void oFascin_geUnknown1(OpGobParams ¶ms);
void oFascin_geUnknown2(OpGobParams ¶ms);
void oFascin_geUnknown3(OpGobParams ¶ms);
void oFascin_geUnknown4(OpGobParams ¶ms);
void oFascin_geUnknown5(OpGobParams ¶ms);
void oFascin_geUnknown6(OpGobParams ¶ms);
void oFascin_geUnknown7(OpGobParams ¶ms);
void oFascin_geUnknown8(OpGobParams ¶ms);
void oFascin_geUnknown9(OpGobParams ¶ms);
void oFascin_geUnknown10(OpGobParams ¶ms);
void oFascin_geUnknown11(OpGobParams ¶ms);
void oFascin_geUnknown1000(OpGobParams ¶ms);
void oFascin_geUnknown1001(OpGobParams ¶ms);
void oFascin_geUnknown1002(OpGobParams ¶ms);
bool oFascin_feUnknown4(OpFuncParams ¶ms);
bool oFascin_feUnknown27(OpFuncParams ¶ms);
void oFascin_cdUnknown3();
void oFascin_cdUnknown4();
void oFascin_cdUnknown5();
void oFascin_cdUnknown6();
void oFascin_setRenderFlags();
void oFascin_cdUnknown11();
};
class Inter_v3 : public Inter_v2 {
public:
Inter_v3(GobEngine *vm);
virtual ~Inter_v3() {}
protected:
virtual void setupOpcodesDraw();
virtual void setupOpcodesFunc();
virtual void setupOpcodesGob();
bool o3_getTotTextItemPart(OpFuncParams ¶ms);
bool o3_copySprite(OpFuncParams ¶ms);
void o3_wobble(OpGobParams ¶ms);
};
class Inter_v4 : public Inter_v3 {
public:
Inter_v4(GobEngine *vm);
virtual ~Inter_v4() {}
protected:
virtual void setupOpcodesDraw();
virtual void setupOpcodesFunc();
virtual void setupOpcodesGob();
void o4_initScreen();
void o4_playVmdOrMusic();
};
class Inter_v5 : public Inter_v4 {
public:
Inter_v5(GobEngine *vm);
virtual ~Inter_v5() {}
protected:
byte _gob_97_98_val;
virtual void setupOpcodesDraw();
virtual void setupOpcodesFunc();
virtual void setupOpcodesGob();
void o5_deleteFile();
void o5_initScreen();
bool o5_istrlen(OpFuncParams ¶ms);
void o5_spaceShooter(OpGobParams ¶ms);
void o5_getSystemCDSpeed(OpGobParams ¶ms);
void o5_getSystemRAM(OpGobParams ¶ms);
void o5_getSystemCPUSpeed(OpGobParams ¶ms);
void o5_getSystemDrawSpeed(OpGobParams ¶ms);
void o5_totalSystemSpecs(OpGobParams ¶ms);
void o5_saveSystemSpecs(OpGobParams ¶ms);
void o5_loadSystemSpecs(OpGobParams ¶ms);
void o5_gob92(OpGobParams ¶ms);
void o5_gob95(OpGobParams ¶ms);
void o5_gob96(OpGobParams ¶ms);
void o5_gob97(OpGobParams ¶ms);
void o5_gob98(OpGobParams ¶ms);
void o5_gob100(OpGobParams ¶ms);
void o5_gob200(OpGobParams ¶ms);
};
class Inter_v6 : public Inter_v5 {
public:
Inter_v6(GobEngine *vm);
virtual ~Inter_v6() {}
protected:
bool _gotFirstPalette;
virtual void setupOpcodesDraw();
virtual void setupOpcodesFunc();
virtual void setupOpcodesGob();
void o6_totSub();
void o6_playVmdOrMusic();
void o6_openItk();
bool o6_loadCursor(OpFuncParams ¶ms);
bool o6_assign(OpFuncParams ¶ms);
bool o6_palLoad(OpFuncParams ¶ms);
bool o6_removeHotspot(OpFuncParams ¶ms);
bool o6_fillRect(OpFuncParams ¶ms);
void probe16bitMusic(char *fileName);
};
class Inter_Playtoons : public Inter_v6 {
public:
Inter_Playtoons(GobEngine *vm);
virtual ~Inter_Playtoons() {}
protected:
virtual void setupOpcodesDraw();
virtual void setupOpcodesFunc();
virtual void setupOpcodesGob();
bool Inter_Playtoons::oPlaytoons_checkData(OpFuncParams ¶ms);
void Inter_Playtoons::oPlaytoons_CD_20_23();
void Inter_Playtoons::oPlaytoons_CD_25();
};
} // End of namespace Gob
#endif // GOB_INTER_H
|