ScummVM API documentation
gr_series.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 M4_GRAPHICS_GR_SERIES_H
23 #define M4_GRAPHICS_GR_SERIES_H
24 
25 #include "m4/m4_types.h"
26 #include "m4/wscript/ws_machine.h"
27 
28 namespace M4 {
29 
30 constexpr uint32 SERIES_FORWARD = 0;
31 constexpr uint32 SERIES_PINGPONG = 1;
32 constexpr uint32 SERIES_BACKWARD = 2;
33 constexpr uint32 SERIES_RANDOM = 4; // series is played in random order, trigger after number of frames in range played
34 constexpr uint32 SERIES_NO_TOSS = 8; // series is not tossed at the end of playing
35 constexpr uint32 SERIES_STICK = 16; // series sticks on last frame, then sends trigger
36 constexpr uint32 SERIES_LOOP_TRIGGER = 32; // get trigger back every loop
37 constexpr uint32 SERIES_LOAD_PALETTE = 64; // load master_palette with colours?
38 constexpr uint32 SERIES_HORZ_FLIP = 128; // horizontal flip
39 
40 // Old constants
41 constexpr uint32 FORWARD = 0;
42 constexpr uint32 PINGPONG = 1;
43 constexpr uint32 BACKWARD = 2;
44 constexpr uint32 STICK = 4;
45 constexpr uint32 NO_TOSS = 8;
46 
47 enum {
48  HASH_SERIES_PLAY_MACHINE = 0,
49  HASH_SERIES_SHOW_MACHINE = 1,
50  // HASH_TIMER_MACHINE = 2, // defined in adv.h
51 
52  HASH_STREAM_MACHINE = 6
53 };
54 
58 struct Series {
59  machine *_series = nullptr;
60  machine *_seriesS = nullptr;
61 
62  void play(const char *seriesName, frac16 layer, uint32 flags = 0,
63  int16 triggerNum = -1, int32 frameRate = 6, int32 loopCount = 0, int32 s = 100,
64  int32 x = 0, int32 y = 0, int32 firstFrame = 0, int32 lastFrame = -1);
65  void show(const char *seriesName, frac16 layer, uint32 flags = 0,
66  int16 triggerNum = -1, int32 duration = -1, int32 index = 0, int32 s = 100,
67  int32 x = 0, int32 y = 0);
68  void show(const char *series1, const char *series2, int layer);
69  void show_index2(const char *series1, const char *series2, int layer, int index1, int index2);
70  void terminate();
71 
72  operator bool() const {
73  return _series != nullptr;
74  }
75 
76  machine *&operator[](uint idx) {
77  return (idx == 0) ? _series : _seriesS;
78  }
79 
80  frac16 *regs() const {
81  return _series->myAnim8->myRegs;
82  }
83 
84  static void series_play(const char *seriesName, frac16 layer, uint32 flags = 0,
85  int16 triggerNum = -1, int32 frameRate = 6, int32 loopCount = 0, int32 s = 100,
86  int32 x = 0, int32 y = 0, int32 firstFrame = 0, int32 lastFrame = -1);
87  static void series_show(const char *seriesName, frac16 layer, uint32 flags = 0,
88  int16 triggerNum = -1, int32 duration = -1, int32 index = 0, int32 s = 100,
89  int32 x = 0, int32 y = 0);
90 };
91 
92 int32 series_load(const char *seriesName, int32 assetIndex = -1, RGB8 *myPal = nullptr);
93 void series_unload(int32 assetIndex);
94 bool series_draw_sprite(int32 spriteHash, int32 index, Buffer *destBuff, int32 x, int32 y);
95 
96 bool series_show_frame(int32 spriteHash, int32 index, Buffer *destBuff, int32 x, int32 y);
97 machine *series_place_sprite(const char *seriesName, int32 index, int32 x, int32 y, int32 s, int32 layer);
98 machine *series_show_sprite(const char *seriesName, int32 index, int32 layer);
99 
100 machine *series_play(const char *seriesName, frac16 layer, uint32 flags = 0,
101  int16 triggerNum = -1, int32 frameRate = 6, int32 loopCount = 0, int32 s = 100,
102  int32 x = 0, int32 y = 0, int32 firstFrame = 0, int32 lastFrame = -1);
103 machine *series_simple_play(const char *seriesName, frac16 layer, bool stickWhenDone);
104 
105 machine *series_show(const char *seriesName, frac16 layer, uint32 flags = 0,
106  int16 triggerNum = -1, int32 duration = -1, int32 index = 0, int32 s = 100,
107  int32 x = 0, int32 y = 0);
108 
109 machine *series_ranged_play(const char *seriesName, int32 loopCount, uint32 flags,
110  int32 firstFrame, int32 lastFrame, int32 s, uint32 layer,
111  int32 frameRate, int32 trigger = -1, bool stick_when_done = false);
112 machine *series_ranged_play_xy(const char *seriesName, int loopCount, int flags,
113  int firstFrame, int lastFrame, int x, int y, int s, int layer,
114  int frameRate, int trigger = -1, bool stick_when_done = false);
115 machine *series_plain_play(const char *seriesName, int32 loopCount, uint32 flags,
116  int32 s, int32 layer, int32 frameRate, int32 trigger = -1, bool stickWhenDone = false);
117 machine *series_play_xy(const char *seriesName, int loopCount, int flags,
118  int x, int y, int scale, int layer, int frameRate, int trigger);
119 
120 machine *series_stream(const char *seriesName, int32 frameRate, int32 layer, int32 trigger);
121 bool series_stream_break_on_frame(machine *m, int32 frameNum, int32 trigger);
122 void series_set_frame_rate(machine *m, int32 newFrameRate);
123 
124 } // namespace M4
125 
126 #endif
Definition: ws_machine.h:153
Definition: gr_series.h:58
intptr frac16
Definition: m4_types.h:46
Graphics::Surface * scale(const Graphics::Surface &srcImage, int xSize, int ySize)
Definition: m4_types.h:88
Definition: m4_types.h:67
Definition: database.h:28