ScummVM API documentation
room.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 /* --- What is a Room ---
23  *
24  */
25 
26 // Common/system includes basic things like Array
27 #include "common/system.h"
28 
29 // Story is needed by both immortal.h and room.h
30 #include "immortal/story.h"
31 
32 // Utilities.h contains many things used by all objects, not just immortal
33 #include "immortal/utilities.h"
34 #include "immortal/immortal.h"
35 
36 #ifndef IMMORTAL_ROOM_H
37 #define IMMORTAL_ROOM_H
38 
39 namespace Immortal {
40 
41 enum RoomTile : uint8 {
42  kTileFloor,
43  kTileUpper5,
44  kTileUpper3,
45  kTileCeiling,
46  kTileTop1,
47  kTileTop7,
48  kTileWallFace,
49  kTileTopLower13,
50  kTileTopLower75,
51  kTileLower3,
52  kTileLower5,
53  kTileCeilingTile = 2 // This duplicate is intentional
54 };
55 
56 /* Quick note:
57  * This looks entirely redundant and silly, I agree. However
58  * this is because the source does more or less the same thing.
59  * At compile time, it creates and stores in memory what are the
60  * equivalent of structs (or maybe tuples), and then at run time
61  * when creating a room, it makes room specific versions that can
62  * be changed. So essentially it creates two RAM structs and then
63  * treats the first as ROM. As such, that's what I'm doing here.
64  * The 'Story' structs are ROM, the 'Room' structs are RAM. There
65  * are also slight differences, like how the room Flame has a reference
66  * to the Cyc it is using. Although again the Story ones are ram
67  * and could do this too.
68  */
69 
70 // Temp
71 struct Object {
72 };
73 
74 // Temp
75 struct Monster {
76 };
77 
78 struct Flame {
79  FPattern _p = kFlameOff;
80  uint8 _x = 0;
81  uint8 _y = 0;
82  int _c = 0;
83 };
84 
85 struct Chest {
86 };
87 
88 struct Bullet {
89 };
90 
91 class Room {
92 private:
93  Common::RandomSource _randomSource;
94 
95 public:
96  Room(uint8 x, uint8 y, RoomFlag f);
97  ~Room() {}
98 
99  /*
100  * --- Data ---
101  *
102  */
103 
104  // Constants
105  const uint8 kLightTorchX = 10;
106  const uint8 kMaxFlameCycs = 16;
107 
108  Common::Array<SCycle> _cycPtrs;
109  Common::Array<Flame> _fset;
110  Common::Array<Monster> _monsters;
111  Common::Array<Object> _objects;
112 
113  RoomFlag _flags;
114 
115  uint8 _xPos = 0;
116  uint8 _yPos = 0;
117  uint8 _holeRoom = 0;
118  uint8 _holeCellX = 0;
119  uint8 _holeCellY = 0;
120  uint8 _candleTmp = 0; // Special case for candle in maze 0
121  uint8 _numFlames = 0;
122  uint8 _numInRoom = 0;
123 
124  /*
125  * --- Methods ---
126  *
127  */
128 
129  uint32 getRandomNumber(uint maxNum) {
130  return _randomSource.getRandomNumber(maxNum);
131  }
132 
133  /*
134  * [room.cpp] Functions from Room.GS
135  */
136 
137  //void init();
138  //void inRoomNew();
139  //void getTilePair(uint8 x, uint8 y); // Modifies a struct of the tile number, aboveTile number, and the cell coordinates of the tile
140 
141  void setHole();
142  void drawContents(uint16 vX, uint16 vY);
143  bool getTilePair(uint8 x, uint8 y, int id);
144  bool getWideWallNormal(uint8 x, uint8 y, uint8 xPrev, uint8 yPrev, int id, int spacing);
145  bool getWallNormal(uint8 x, uint8 y, uint8 xPrev, uint8 yPrev, int id);
146  void addMonster();
147  void addObject();
148  void removeObject();
149  void removeMonster();
150  Common::Array<Monster> getMonsterList();
151  Common::Array<Object> getObjectList();
152  void getXY(uint16 &x, uint16 &y);
153  void getCell(uint16 &x, uint16 &y);
154 
155 
156  /*
157  * [Cycle.cpp] Functions from Cyc
158  */
159 
160  // Init
161  int cycleNew(CycID id); // Adds a cycle to the current list
162  void cycleFree(int c);
163 
164  // Getters
165  DataSprite *cycleGetDataSprite(int c); // This takes the place of getFile + getNum
166  int cycleGetIndex(int c);
167  int cycleGetFrame(int c);
168  int cycleGetNumFrames(int c);
169 
170  // Setters
171  void cycleSetIndex(int c, int f);
172 
173  // Misc
174  bool cycleAdvance(int c);
175  CycID getCycList(int c);
176 
177  /* Unnecessary cycle functions
178  void cycleInit();
179  void cycleFree();
180  void cycleGetNumFrames();
181  void cycleGetList();*/
182 
183  /*
184  * [flameSet.cpp] Functions from flameSet.GS
185  */
186 
187  //void flameNew() does not need to exist, because we create the duplicate SFlame in Level, and the array in immortal.h is not accessible from here
188  void flameInit();
189  void flameDrawAll(uint16 vX, uint16 vY);
190  bool roomLighted();
191  void lightTorch(uint8 x, uint8 y);
192  void flameFreeAll();
193  void flameSetRoom(Common::Array<SFlame> &allFlames);
194  int flameGetCyc(Flame *f, int first);
195 
196  /*
197  * [bullet.cpp] Functions from Bullet.GS
198  */
199 
200 
201 
202  /*
203  * [object.cpp] Functions from Object.GS
204  */
205 
206 
207  /*
208  * [Univ.cpp] Functions from Univ.GS
209  */
210 
211  void univAddSprite(uint16 vX, uint16 vY, uint16 x, uint16 y, SpriteName s, int img, uint16 p);
212 };
213 
214 } // namespace Immortal
215 
216 #endif
Definition: room.h:85
Definition: room.h:71
Definition: definitions.h:25
Definition: array.h:52
Definition: random.h:44
Definition: room.h:78
Definition: room.h:91
uint getRandomNumber(uint max)
Definition: room.h:88
Definition: sprite_list.h:40
Definition: room.h:75