ScummVM API documentation
ads.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 DGDS_ADS_H
23#define DGDS_ADS_H
24
25#include "dgds/scripts.h"
26#include "dgds/ttm.h"
27
28namespace Dgds {
29
30class ADSData : public ScriptParserData {
31public:
32 ADSData() : _maxSegments(0), _scriptDelay(-1), _hitTTMOp0110(false), _hitBranchOp(false),
33 _gotoTarget(-1), _runningSegmentIdx(0) {
34 for (int i = 0; i < ARRAYSIZE(_state); i++)
35 _state[i] = 8;
36
37 for (int i = 0; i < ARRAYSIZE(_segments); i++)
38 _segments[i] = -1;
39
40 ARRAYCLEAR(_countdown);
41 ARRAYCLEAR(_charWhile);
42 }
44 Common::Array<TTMEnviro> _scriptEnvs;
45 Common::Array<Common::SharedPtr<TTMSeq>> _ttmSeqs; // Pointers as we need to shuffle them but keep _usedSeqs below valid
46 int _maxSegments;
47 // TODO: replace these with dynamic arrays - fixed arrays inherited from original.
48 int _state[80];
49 int _countdown[80];
50 // note: originals uses char * but we use offsets into script for less pointers. -1 is nullptr
51 int32 _segments[80];
52 int32 _charWhile[80];
54 int32 _scriptDelay;
55 int32 _gotoTarget;
56 bool _hitTTMOp0110;
57 bool _hitBranchOp;
58 int16 _runningSegmentIdx;
59
61};
62
64public:
67
68 bool load(const Common::String &filename);
69 void unload();
70 bool run();
71 int numArgs(uint16 opcode) const;
72 void segmentOrState(int16 seg, uint16 val);
73 void segmentSetState(int16 seg, uint16 val);
74
75 void setHitTTMOp0110(bool val = true); // TODO: better name for this global?
76 bool getHitTTMOp0110() const { return _adsData->_hitTTMOp0110; }
77 void setGotoTarget(int32 target);
78 int16 getStateForSceneOp(uint16 segnum);
79 void setScriptDelay(int16 delay) { _adsData->_scriptDelay = delay; }
80
82
83protected:
84 bool handleOperation(uint16 code, Common::SeekableReadStream *scr);
85 void handleRandomOp(Common::SeekableReadStream *scr);
86 bool handleLogicOp(uint16 code, Common::SeekableReadStream *scr);
87 bool logicOpResult(uint16 code, const TTMEnviro *env, const TTMSeq *seq, uint16 arg);
88 int16 randomOpGetProportion(uint16 code, Common::SeekableReadStream *scr);
89 bool playScene();
90 bool skipToElseOrEndif();
91 bool skipToEndIf();
92 bool skipToEndWhile();
93 bool skipSceneLogicBranch();
94 Common::SharedPtr<TTMSeq> findTTMSeq(int16 enviro, int16 seq);
95 TTMEnviro *findTTMEnviro(int16 enviro);
96 bool runUntilBranchOpOrEnd();
97 void findUsedSequencesForSegment(int segno);
98 void findEndOrInitOp();
99 bool updateSeqTimeAndFrame(const TTMEnviro *env, Common::SharedPtr<TTMSeq> seq);
100 int getArrIndexOfSegNum(uint16 segnum);
101
102 DgdsEngine *_vm;
103 TTMInterpreter *_ttmInterpreter;
104
106 ADSData *_adsData;
107
108 Common::SharedPtr<TTMSeq> _currentTTMSeq;
109};
110
111} // end namespace Dgds
112
113#endif // DGDS_ADS_H
Definition: error.h:81
Definition: hashmap.h:85
Definition: stream.h:745
Definition: serializer.h:80
Definition: ptr.h:159
Definition: str.h:59
Definition: ads.h:30
Definition: ads.h:63
Definition: dgds.h:120
Definition: scripts.h:29
Definition: ttm.h:40
Definition: ttm.h:119
#define ARRAYSIZE(x)
Definition: util.h:114
void ARRAYCLEAR(T(&array)[N], const T &value=T())
Definition: util.h:124
Definition: ttm.h:82