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 "twine/shared.h"
28 
29 namespace TwinE {
30 
31 #define OVERLAY_MAX_ENTRIES 10
32 
33 enum class OverlayType {
34  koSprite = 0,
35  koNumber = 1,
36  koNumberRange = 2,
37  koInventoryItem = 3,
38  koText = 4,
39  koInventory = 5, // lba2
40  koSysText = 6, // lba2
41  koFlash = 7, //lba2
42  koRain = 8, //lba2
43  koMax
44 };
45 
46 enum class OverlayPosType {
47  koNormal = 0,
48  koFollowActor = 1
49 };
50 
53  OverlayType type = OverlayType::koSprite;
54  int16 info0 = 0; // sprite/3d model entry | number | number range
55  int16 x = 0;
56  int16 y = 0;
57  int16 info1 = 0; // text = actor | total coins
58  OverlayPosType posType = OverlayPosType::koNormal;
59  int16 lifeTime = 0; // life time in ticks - see toSeconds()
60 };
61 
63  // DrawActorSprites, DrawShadows, DrawExtras
64  int16 posValue = 0; // sorting value
65  uint32 type = 0;
66  uint16 actorIdx = 0;
67 
68  // DrawShadows
69  uint16 x = 0;
70  uint16 y = 0;
71  uint16 z = 0;
72  uint16 offset = 0;
73 
74  inline bool operator==(const DrawListStruct& other) const {
75  return posValue == other.posValue;
76  }
77 
78  inline bool operator<(const DrawListStruct& other) const {
79  return posValue < other.posValue;
80  }
81 };
82 
83 #define TYPE_OBJ_SHIFT (10)
84 #define TYPE_OBJ_FIRST (1 << TYPE_OBJ_SHIFT) // 1024
85 #define NUM_OBJ_MASK (TYPE_OBJ_FIRST - 1)
86 
87 class TwinEEngine;
88 class Redraw {
89 private:
90  TwinEEngine *_engine;
91  enum DrawListType {
92  DrawObject3D = (0 << TYPE_OBJ_SHIFT),
93  DrawFlagRed = (1 << TYPE_OBJ_SHIFT),
94  DrawFlagYellow = (2 << TYPE_OBJ_SHIFT),
95  DrawShadows = (3 << TYPE_OBJ_SHIFT),
96  DrawActorSprites = (4 << TYPE_OBJ_SHIFT),
97  DrawZoneDec = (5 << TYPE_OBJ_SHIFT),
98  DrawExtras = (6 << TYPE_OBJ_SHIFT),
99  DrawPrimitive = (7 << TYPE_OBJ_SHIFT)
100  };
101 
102  Common::Rect _currentRedrawList[300];
103  Common::Rect _nextRedrawList[300];
104 
105  int16 _overlayRotation = 0;
106 
108  int32 _bubbleActor = -1;
109  int32 _bubbleSpriteIndex;
110 
111  IVec3 _projPosScreen;
112 
113  // big font shadow text in the lower left corner
114  Common::String _text;
115  int32 _textDisappearTime = -1;
116 
121  void addRedrawCurrentArea(const Common::Rect &redrawArea);
126  void moveNextAreas();
127  void updateOverlayTypePosition(int16 x1, int16 y1, int16 x2, int16 y2);
128 
129  void processDrawListShadows(const DrawListStruct& drawCmd);
130  void processDrawListActors(const DrawListStruct& drawCmd, bool bgRedraw);
131  void processDrawListActorSprites(const DrawListStruct& drawCmd, bool bgRedraw);
132  void processDrawListExtras(const DrawListStruct& drawCmd);
133 
134  int32 fillActorDrawingList(DrawListStruct *drawList, bool bgRedraw);
135  int32 fillExtraDrawingList(DrawListStruct *drawList, int32 drawListPos);
136  void correctZLevels(DrawListStruct *drawList, int32 drawListPos);
137  void processDrawList(DrawListStruct *drawList, int32 drawListPos, bool bgRedraw);
138  void renderOverlays();
139  void renderText();
140 
141 public:
142  Redraw(TwinEEngine *engine);
143 
144  bool _flagMCGA = false;
145 
147  bool _firstTime = false;
148 
150  int32 _currNumOfRedrawBox = 0; // fullRedrawVar8
152  int32 _numOfRedrawBox = 0;
153 
154  int _sceneryViewX = 0; // xmin
155  int _sceneryViewY = 0; // ymin
156 
157  OverlayListStruct overlayList[OVERLAY_MAX_ENTRIES];
158 
159  void setRenderText(const Common::String &text);
160 
161  // InitIncrustDisp
162  int32 addOverlay(OverlayType type, int16 info0, int16 x, int16 y, int16 info1, OverlayPosType posType, int16 lifeTime);
163  void posObjIncrust(OverlayListStruct *ptrdisp, int32 num); // lba2
164 
172  void addRedrawArea(int32 left, int32 top, int32 right, int32 bottom);
173  void addRedrawArea(const Common::Rect &rect);
174 
179  void flipRedrawAreas();
180 
182  void blitBackgroundAreas();
183 
188  void redrawEngineActions(bool bgRedraw);
189 
191  void drawBubble(int32 actorIdx);
192 
198  void sortDrawingList(DrawListStruct *list, int32 listSize) const;
199 };
200 
201 } // namespace TwinE
202 
203 #endif
Definition: str.h:59
Definition: shared.h:113
Definition: rect.h:144
Definition: twine.h:200
Definition: achievements_tables.h:27
Definition: redraw.h:88
Definition: redraw.h:52
Definition: redraw.h:62