ScummVM API documentation
ttm.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_TTM_H
23 #define DGDS_TTM_H
24 
25 #include "dgds/scripts.h"
26 #include "dgds/font.h"
27 
28 namespace Dgds {
29 
30 class SoundRaw;
31 
32 class GetPutRegion {
33 public:
34  Common::Rect _area;
36 
37  void reset();
38 };
39 
40 class TTMEnviro : public ScriptParserData {
41 public:
42  TTMEnviro() : _totalFrames(330), _enviro(0), _creditScrollMeasure(0),
43  _creditScrollYOffset(0), _xOff(0), _yOff(0), _xScroll(0), _yScroll(0),
44  _cdsSeqNum(-1), _cdsJumped(false), _cdsDelay(0), ScriptParserData() {
45  ARRAYCLEAR(_scriptPals);
46  }
47 
48  Common::Error syncState(Common::Serializer &s);
49 
50  uint16 _enviro;
51  uint16 _totalFrames;
52  Common::Array<int> _frameOffsets;
53  Common::SharedPtr<Image> _scriptShapes[6];
55  int _scriptPals[6];
56  Common::String _strings[10];
58  int16 _creditScrollMeasure;
59  int16 _creditScrollYOffset;
60  // The below are all globals in the original, but never get access from
61  // multiple environments so cleaner to keep here?
62  int16 _xOff;
63  int16 _yOff;
64  Common::SharedPtr<Image> _scrollShape;
65  int16 _xScroll;
66  int16 _yScroll;
68  int16 _cdsSeqNum; // The GOTO target to use in the CDS script (Willy Beamish talkie)
69  int16 _cdsDelay;
70  bool _cdsJumped;
71 };
72 
73 enum TTMRunType {
74  kRunTypeStopped = 0,
75  kRunType1 = 1,
76  kRunTypeMulti = 2,
77  kRunTypeTimeLimited = 3,
78  kRunTypeFinished = 4,
79  kRunTypePaused = 5,
80 };
81 
82 
83 // Note: this object needs to be safely copy-able - ADS opcodes 0x4000 and 0x4010 require it.
84 struct TTMSeq {
85  TTMSeq() : _enviro(0), _seqNum(0), _startFrame(0), _lastFrame(0), _timeCut(0) {
86  // Other members are initialized in the reset function.
87  reset();
88  }
89 
90  void reset();
91  Common::Error syncState(Common::Serializer &s);
92 
93  int16 _enviro;
94  int16 _seqNum;
95  int16 _startFrame; // first frame in this sequence
96  int16 _gotoFrame; // frame to GOTO (or -1 if not currently set)
97  int16 _currentFrame; // currently executing frame
98  int16 _lastFrame; // previous frame processed (-1 if none)
99  bool _selfLoop; // does the script frame loop back on itself
100  bool _executed; // has the current frame already been run
101  uint32 _timeNext; // time the next frame should be run
102  uint32 _timeCut; // time to finish execution
103  Common::Rect _drawWin;
104  // these current ids are called "slot"s in the original
105  int16 _currentFontId; // aka slot 0
106  int16 _currentPalId; // aka slot 1
107  int16 _currentSongId; // aka slot 3
108  int16 _currentBmpId; // aka slot 4
109  int16 _currentGetPutId; // aka slot 5
110  int16 _brushNum;
111  byte _drawColFG;
112  byte _drawColBG;
113  int16 _runPlayed; // number of times the sequence has been started from ADS
114  int16 _runCount; // number of times to play the sequence before stopping
115  int16 _timeInterval; // interval between frames
116  TTMRunType _runFlag;
117  int16 _scriptFlag;
118 };
119 
121 public:
123 
124  bool load(const Common::String &filename, TTMEnviro &env);
125  void unload();
126  bool run(TTMEnviro &env, TTMSeq &seq);
127  void findAndAddSequences(TTMEnviro &scriptData, Common::Array<Common::SharedPtr<TTMSeq>> &seqArray);
128 
129  static Common::String readTTMStringVal(Common::SeekableReadStream *scr);
130 
131 protected:
132  bool handleOperation(TTMEnviro &env, TTMSeq &seq, uint16 op, byte count, const int16 *ivals, const Common::String &sval, const Common::Array<Common::Point> &pts);
133  int32 findGOTOTarget(const TTMEnviro &env, const TTMSeq &seq, int16 frame);
134  void doWipeOp(uint16 code, const TTMEnviro &env, const TTMSeq &seq, const Common::Rect &r);
135  int16 doOpInitCreditScroll(const Image *img);
136  bool doOpCreditsScroll(const Image *img, int16 ygap, int16 ymax, int16 xoff, int16 measuredWidth, const Common::Rect &clipRect);
137  void doDrawDialogForStrings(const TTMEnviro &env, const TTMSeq &seq, int16 x, int16 y, int16 width, int16 height);
138 
139  DgdsEngine *_vm;
140  int _stackDepth;
141 };
142 
143 } // end namespace Dgds
144 
145 #endif // DGDS_TTM_H
void ARRAYCLEAR(T(&array) [N], const T &value=T())
Definition: util.h:101
Definition: str.h:59
Definition: ttm.h:40
Definition: ttm.h:32
Definition: error.h:84
Definition: ads.h:28
Definition: rect.h:144
Definition: stream.h:745
Definition: serializer.h:79
Definition: scripts.h:29
Definition: dgds.h:116
Definition: movie_decoder.h:32
Definition: ttm.h:84
Definition: ttm.h:120