ScummVM API documentation
redraw.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 TWINE_RENDERER_REDRAW_H
23 #define TWINE_RENDERER_REDRAW_H
24 
25 #include "common/scummsys.h"
26 #include "common/rect.h"
27 #include "common/str.h"
28 #include "twine/shared.h"
29 
30 namespace TwinE {
31 
32 // MAX_INCRUST_DISP
33 #define OVERLAY_MAX_ENTRIES 10
34 
35 enum class OverlayType {
36  koSprite = 0, // INCRUST_SPRITE
37  koNumber = 1, // INCRUST_NUM
38  koNumberRange = 2, // INCRUST_CMPT
39  koInventoryItem = 3, // INCRUST_OBJ
40  koText = 4, // INCRUST_TEXT
41  koInventory = 5, // lba2 (INCRUST_INVENTORY)
42  koSysText = 6, // lba2 (INCRUST_SYS_TEXT)
43  koFlash = 7, // lba2 (INCRUST_ECLAIR)
44  koRain = 8, // lba2 (INCRUST_PLUIE)
45  koMax
46 };
47 
48 // lba2
49 #define INCRUST_YCLIP (1 << 8)
50 
51 enum class OverlayPosType {
52  koNormal = 0,
53  koFollowActor = 1
54 };
55 
58  int16 num = 0; // sprite/3d model entry | number | number range
59  int16 x = 0;
60  int16 y = 0;
61  OverlayType type = OverlayType::koSprite;
62  int16 info = 0; // text = actor | total coins
63  OverlayPosType move = OverlayPosType::koNormal;
64  int16 timerEnd = 0; // life time in ticks - see toSeconds()
65 };
66 
68  int16 z = 0; // depth sorting value
69  uint32 type = 0;
70  // NumObj was also used with mask of type and numObj - we are
71  // not masking the value in numObj, but store the type in type
72  uint16 numObj = 0;
73 
74  uint16 xw = 0;
75  uint16 yw = 0;
76  uint16 zw = 0;
77  uint16 num = 0;
78 
79  inline bool operator==(const DrawListStruct& other) const {
80  return z == other.z;
81  }
82 
83  inline bool operator<(const DrawListStruct& other) const {
84  return z < other.z;
85  }
86 };
87 
88 #define TYPE_OBJ_SHIFT (10)
89 #define TYPE_OBJ_FIRST (1 << TYPE_OBJ_SHIFT) // 1024
90 #define NUM_OBJ_MASK (TYPE_OBJ_FIRST - 1)
91 
92 class TwinEEngine;
93 class Redraw {
94 private:
95  TwinEEngine *_engine;
96  enum DrawListType {
97  DrawObject3D = (0 << TYPE_OBJ_SHIFT), // TYPE_OBJ_3D
98  DrawFlagRed = (1 << TYPE_OBJ_SHIFT),
99  DrawFlagYellow = (2 << TYPE_OBJ_SHIFT),
100  DrawShadows = (3 << TYPE_OBJ_SHIFT), // TYPE_SHADOW
101  DrawActorSprites = (4 << TYPE_OBJ_SHIFT), // TYPE_OBJ_SPRITE
102  DrawZoneDec = (5 << TYPE_OBJ_SHIFT),
103  DrawExtras = (6 << TYPE_OBJ_SHIFT), // TYPE_EXTRA
104  DrawPrimitive = (7 << TYPE_OBJ_SHIFT)
105  };
106 
107  Common::Rect _currentRedrawList[300];
108  Common::Rect _nextRedrawList[300];
109 
110  int16 _overlayRotation = 0;
111 
113  int32 _bubbleActor = -1;
114  int32 _bubbleSpriteIndex;
115 
116  // big font shadow text in the lower left corner
117  Common::String _text;
118  int32 _textDisappearTime = -1;
119 
124  void addRedrawCurrentArea(const Common::Rect &redrawArea);
129  void moveNextAreas();
130  void updateOverlayTypePosition(int16 x1, int16 y1, int16 x2, int16 y2);
131 
132  void processDrawListShadows(const DrawListStruct& drawCmd);
133  void processDrawListActors(const DrawListStruct& drawCmd, bool bgRedraw);
134  void processDrawListActorSprites(const DrawListStruct& drawCmd, bool bgRedraw);
135  void processDrawListExtras(const DrawListStruct& drawCmd);
136 
137  int32 fillActorDrawingList(DrawListStruct *drawList, bool bgRedraw);
138  int32 fillExtraDrawingList(DrawListStruct *drawList, int32 drawListPos);
139  void correctZLevels(DrawListStruct *drawList, int32 drawListPos);
140  void processDrawList(DrawListStruct *drawList, int32 drawListPos, bool bgRedraw);
141  void renderOverlays();
142  void renderText();
143 
144 public:
145  Redraw(TwinEEngine *engine);
146 
147  bool _flagMCGA = false;
148 
150  bool _firstTime = false;
151 
152  IVec3 _projPosScreen; // XpOrgw, YpOrgw
153 
155  int32 _nbPhysBox = 0; // fullRedrawVar8
157  int32 _nbOptPhysBox = 0;
158 
159  int _sceneryViewX = 0; // xmin
160  int _sceneryViewY = 0; // ymin
161 
162  OverlayListStruct overlayList[OVERLAY_MAX_ENTRIES];
163 
164  void setRenderText(const Common::String &text);
165 
166  // InitIncrustDisp
167  int32 addOverlay(OverlayType type, int16 info0, int16 x, int16 y, int16 info1, OverlayPosType posType, int16 lifeTime);
168  void posObjIncrust(OverlayListStruct *ptrdisp, int32 num); // lba2
169 
177  void addRedrawArea(int32 left, int32 top, int32 right, int32 bottom); // AddPhysBox
178  void addPhysBox(const Common::Rect &rect); // AddPhysBox
179 
184  void flipBoxes();
185 
187  void clsBoxes();
188 
193  void drawScene(bool bgRedraw);
194 
196  void drawBubble(int32 actorIdx);
197 
203  void sortDrawingList(DrawListStruct *list, int32 listSize) const;
204 };
205 
206 } // namespace TwinE
207 
208 #endif
Definition: str.h:59
Definition: shared.h:122
Definition: rect.h:144
Definition: twine.h:207
Definition: achievements_tables.h:27
Out move(In first, In last, Out dst)
Definition: algorithm.h:109
Definition: redraw.h:93
Definition: redraw.h:57
Definition: redraw.h:67