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),
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 };
69 
70 enum TTMRunType {
71  kRunTypeStopped = 0,
72  kRunType1 = 1,
73  kRunTypeMulti = 2,
74  kRunTypeTimeLimited = 3,
75  kRunTypeFinished = 4,
76  kRunType5 = 5,
77 };
78 
79 
80 // Note: this object needs to be safely copy-able - ADS opcodes 0x4000 and 0x4010 require it.
81 struct TTMSeq {
82  TTMSeq() : _enviro(0), _seqNum(0), _startFrame(0), _lastFrame(0), _timeCut(0) {
83  // Other members are initialized in the reset function.
84  reset();
85  }
86 
87  void reset();
88  Common::Error syncState(Common::Serializer &s);
89 
90  int16 _enviro;
91  int16 _seqNum;
92  int16 _startFrame; // first frame in this sequence
93  int16 _gotoFrame; // frame to GOTO (or -1 if not currently set)
94  int16 _currentFrame; // currently executing frame
95  int16 _lastFrame; // previous frame processed (-1 if none)
96  bool _selfLoop; // does the script frame loop back on itself
97  bool _executed; // has the current frame already been run
98  uint32 _timeNext; // time the next frame should be run
99  uint32 _timeCut; // time to finish execution
100  Common::Rect _drawWin;
101  // these current ids are called "slot"s in the original
102  int16 _currentFontId; // aka slot 0
103  int16 _currentPalId; // aka slot 1
104  int16 _currentSongId; // aka slot 3
105  int16 _currentBmpId; // aka slot 4
106  int16 _currentGetPutId; // aka slot 5
107  int16 _brushNum;
108  byte _drawColFG;
109  byte _drawColBG;
110  int16 _runPlayed; // number of times the sequence has been started from ADS
111  int16 _runCount; // number of times to play the sequence before stopping
112  int16 _timeInterval; // interval between frames
113  TTMRunType _runFlag;
114  int16 _scriptFlag;
115 };
116 
118 public:
120 
121  bool load(const Common::String &filename, TTMEnviro &env);
122  void unload();
123  bool run(TTMEnviro &env, TTMSeq &seq);
124  void findAndAddSequences(TTMEnviro &scriptData, Common::Array<TTMSeq> &seqArray);
125 
126 protected:
127  void handleOperation(TTMEnviro &env, TTMSeq &seq, uint16 op, byte count, const int16 *ivals, const Common::String &sval, const Common::Array<Common::Point> &pts);
128  int32 findGOTOTarget(TTMEnviro &env, TTMSeq &seq, int16 frame);
129  void doWipeOp(uint16 code, TTMEnviro &env, TTMSeq &seq, const Common::Rect &r);
130  int16 doOpInitCreditScroll(const Image *img);
131  bool doOpCreditsScroll(const Image *img, int16 ygap, int16 ymax, int16 xoff, int16 measuredWidth, const Common::Rect &clipRect);
132  void doDrawDialogForStrings(TTMEnviro &env, TTMSeq &seq, int16 x, int16 y, int16 width, int16 height);
133 
134  DgdsEngine *_vm;
135  int _stackDepth;
136 };
137 
138 } // end namespace Dgds
139 
140 #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: serializer.h:79
Definition: scripts.h:29
Definition: dgds.h:93
Definition: movie_decoder.h:32
Definition: ttm.h:81
Definition: ttm.h:117