1 //=============================================================================
2 //
3 // Adventure Game Studio (AGS)
4 //
5 // Copyright (C) 1999-2011 Chris Jones and 2011-20xx others
6 // The full list of copyright holders can be found in the Copyright.txt
7 // file, which is part of this source code distribution.
8 //
9 // The AGS source code is provided under the Artistic License 2.0.
10 // A copy of this license can be found in the file License.txt and at
11 // http://www.opensource.org/licenses/artistic-license-2.0.php
12 //
13 //=============================================================================
14 
15 #ifndef __AC_ROOMSTRUCT_H
16 #define __AC_ROOMSTRUCT_H
17 
18 #include "ac/common_defines.h"
19 #include "ac/messageinfo.h"
20 #include "ac/animationstruct.h"
21 #include "ac/point.h"
22 #include "game/customproperties.h"
23 #include "game/interactions.h"
24 #include "script/cc_script.h"       // ccScript
25 #include "util/wgt2allg.h" // color (allegro RGB)
26 
27 namespace AGS { namespace Common { class Stream; } }
28 namespace AGS { namespace Common { class Bitmap; } }
29 using AGS::Common::Stream;
30 using AGS::Common::Bitmap;
31 using AGS::Common::Interaction;
32 using AGS::Common::InteractionScripts;
33 using AGS::Common::InteractionVariable;
34 
35 /* room file versions history
36 8:  final v1.14 release
37 9:  intermediate v2 alpha releases
38 10:  v2 alpha-7 release
39 11:  final v2.00 release
40 12:  v2.08, to add colour depth byte
41 13:  v2.14, add walkarea light levels
42 14:  v2.4, fixed so it saves walkable area 15
43 15:  v2.41, supports NewInteraction
44 16:  v2.5
45 17:  v2.5 - just version change to force room re-compile for new charctr struct
46 18:  v2.51 - vector scaling
47 19:  v2.53 - interaction variables
48 20:  v2.55 - shared palette backgrounds
49 21:  v2.55 - regions
50 22:  v2.61 - encrypt room messages
51 23:  v2.62 - object flags
52 24:  v2.7  - hotspot script names
53 25:  v2.72 - game id embedded
54 26:  v3.0 - new interaction format, and no script source
55 27:  v3.0 - store Y of bottom of object, not top
56 28:  v3.0.3 - remove hotspot name length limit
57 29:  v3.0.3 - high-res coords for object x/y, edges and hotspot walk-to point
58 30:  v3.4.0.4 - tint luminance for regions
59 31:  v3.4.1.5 - removed room object and hotspot name length limits
60 */
61 enum RoomFileVersion
62 {
63     kRoomVersion_Undefined  = 0,
64     kRoomVersion_pre114_3   = 3,  // exact version unknown
65     kRoomVersion_pre114_4   = 4,  // exact version unknown
66     kRoomVersion_pre114_5   = 5,  // exact version unknown
67     kRoomVersion_pre114_6   = 6,  // exact version unknown
68     kRoomVersion_114        = 8,
69     kRoomVersion_200_alpha  = 9,
70     kRoomVersion_200_alpha7 = 10,
71     kRoomVersion_200_final  = 11,
72     kRoomVersion_208        = 12,
73     kRoomVersion_214        = 13,
74     kRoomVersion_240        = 14,
75     kRoomVersion_241        = 15,
76     kRoomVersion_250a       = 16,
77     kRoomVersion_250b       = 17,
78     kRoomVersion_251        = 18,
79     kRoomVersion_253        = 19,
80     kRoomVersion_255a       = 20,
81     kRoomVersion_255b       = 21,
82     kRoomVersion_261        = 22,
83     kRoomVersion_262        = 23,
84     kRoomVersion_270        = 24,
85     kRoomVersion_272        = 25,
86     kRoomVersion_300a       = 26,
87     kRoomVersion_300b       = 27,
88     kRoomVersion_303a       = 28,
89     kRoomVersion_303b       = 29,
90     kRoomVersion_3404       = 30,
91     kRoomVersion_3415       = 31,
92     kRoomVersion_Current    = kRoomVersion_3415
93 };
94 
95 // thisroom.options[0] = startup music
96 // thisroom.options[1] = can save/load on screen (0=yes, 1=no)
97 // thisroom.options[2] = player character disabled? (0=no, 1=yes)
98 // thisroom.options[3] = player special view (0=normal)
99 //                 [4] = music volume (0=normal, <0 quiter, >0 louder)
100 
101 const int ST_TUNE = 0, ST_SAVELOAD = 1, ST_MANDISABLED = 2, ST_MANVIEW = 3, ST_VOLUME = 4;
102 
103 enum RoomVolumeAdjustment
104 {
105     kRoomVolumeQuietest = -3,
106     kRoomVolumeQuieter  = -2,
107     kRoomVolumeQuiet    = -1,
108     kRoomVolumeNormal   =  0,
109     kRoomVolumeLoud     =  1,
110     kRoomVolumeLouder   =  2,
111     kRoomVolumeLoudest  =  3,
112     // These two options are only settable at runtime by SetMusicVolume()
113     kRoomVolumeExtra1   =  4,
114     kRoomVolumeExtra2   =  5,
115 
116     kRoomVolumeMin      = kRoomVolumeQuietest,
117     kRoomVolumeMax      = kRoomVolumeExtra2,
118 };
119 
120 #pragma pack(1)
121 struct sprstruc {
122     short sprnum  ;   // number from array
123     short x,y     ;   // x,y co-ords
124     short room    ;   // room number
125     short on      ;
sprstrucsprstruc126     sprstruc() { on = 0; }
127 
128     void ReadFromFile(Common::Stream *in);
129 };
130 #pragma pack()
131 
132 #define NOT_VECTOR_SCALED -10000
133 #define LEGACY_TINT_IS_ENABLED 0x80000000
134 struct roomstruct {
135     Common::Bitmap *        walls, *object, *lookat;          // 'object' is the walk-behind
136     Common::Bitmap *        regions;
137     color         pal[256];
138     short         numobj;                         // num hotspots, not sprites
139     short         objyval[MAX_OBJ];               // baselines of walkbehind areas
140     // obsolete v2.00 action editor stuff below
141     short         whataction[NUM_CONDIT+3];       // what to do if condition appears
142     short         val1[NUM_CONDIT+3];             // variable, eg. screen number to go to
143     short         val2[NUM_CONDIT+3];             // 2nd var, optional, eg. which side of screen to come on
144     short         otcond[NUM_CONDIT+3];           // do extra misc condition
145     char          points[NUM_CONDIT+3];           // extra points for doing it
146     // end obsolete v2.00 action editor
147     short         left,right,top,bottom;          // to walk off screen
148     short         numsprs,nummes;                 // number of initial sprites and messages
149     sprstruc      sprs[MAX_INIT_SPR];             // structures for each sprite
150     Interaction  *intrObject[MAX_INIT_SPR];
151     InteractionScripts **objectScripts;
152     int           objbaseline[MAX_INIT_SPR];                // or -1 (use bottom of object graphic)
153     short         objectFlags[MAX_INIT_SPR];
154     AGS::Common::String objectnames[MAX_INIT_SPR];
155     AGS::Common::String objectscriptnames[MAX_INIT_SPR];
156     AGS::Common::StringIMap objProps[MAX_INIT_SPR];
157     char          password[11];
158     char          options[10];                    // [0]=startup music
159     char          *message[MAXMESS];
160     MessageInfo   msgi[MAXMESS];
161     short         wasversion;                     // when loaded from file
162     short         flagstates[MAX_FLAGS];
163     FullAnimation anims[MAXANIMS];
164     short         numanims;
165     short         shadinginfo[16];    // walkable area-specific view number
166     // new version 2 roommake stuff below
167     int           numwalkareas;
168     PolyPoints    wallpoints[MAX_WALK_AREAS];
169     int           numhotspots;
170     _Point        hswalkto[MAX_HOTSPOTS];
171     AGS::Common::String hotspotnames[MAX_HOTSPOTS];
172     AGS::Common::String hotspotScriptNames[MAX_HOTSPOTS];
173     Interaction  *intrHotspot[MAX_HOTSPOTS];
174     Interaction  *intrRoom;
175     Interaction  *intrRegion[MAX_REGIONS];
176     InteractionScripts **hotspotScripts;
177     InteractionScripts **regionScripts;
178     InteractionScripts *roomScripts;
179     int           numRegions;
180     short         regionLightLevel[MAX_REGIONS];
181     int           regionTintLevel[MAX_REGIONS];
182     short         width,height;                             // in 320x200 terms (scrolling room size)
183     short         resolution;                               // 1 = 320x200, 2 = 640x400
184     short         walk_area_zoom[MAX_WALK_AREAS + 1];       // 0 = 100%, 1 = 101%, -1 = 99%
185     short         walk_area_zoom2[MAX_WALK_AREAS + 1];      // for vector scaled areas
186     short         walk_area_light[MAX_WALK_AREAS + 1];      // 0 = normal, + lighter, - darker
187     short         walk_area_top[MAX_WALK_AREAS + 1];     // top YP of area
188     short         walk_area_bottom[MAX_WALK_AREAS + 1];  // bottom YP of area
189     char          *scripts;
190     PScript       compiled_script;
191     int           cscriptsize;
192     int           num_bscenes, bscene_anim_speed;
193     int           bytes_per_pixel;
194     Common::Bitmap *        ebscene[MAX_BSCENE];
195     color         bpalettes[MAX_BSCENE][256];
196     InteractionVariable *localvars;
197     int           numLocalVars;
198     char          ebpalShared[MAX_BSCENE];  // used internally by engine atm
199     AGS::Common::StringIMap roomProps;
200     AGS::Common::StringIMap hsProps[MAX_HOTSPOTS];
201     int           gameId;
202 
203     roomstruct();
204     void freemessage();
205     void freescripts();
206 
207     // Gets if the given region has light level set
208     bool has_region_lightlevel(int id) const;
209     // Gets if the given region has a tint set
210     bool has_region_tint(int id) const;
211     // Gets region's light level in -100 to 100 range value; returns 0 (default level) if region's tint is set
212     int  get_region_lightlevel(int id) const;
213     // Gets region's tint luminance in 0 to 100 range value; returns 0 if region's light level is set
214     int  get_region_tintluminance(int id) const;
215 };
216 
217 #define BLOCKTYPE_MAIN        1
218 #define BLOCKTYPE_SCRIPT      2
219 #define BLOCKTYPE_COMPSCRIPT  3
220 #define BLOCKTYPE_COMPSCRIPT2 4
221 #define BLOCKTYPE_OBJECTNAMES 5
222 #define BLOCKTYPE_ANIMBKGRND  6
223 #define BLOCKTYPE_COMPSCRIPT3 7     // new CSCOMP script instead of SeeR
224 #define BLOCKTYPE_PROPERTIES  8
225 #define BLOCKTYPE_OBJECTSCRIPTNAMES 9
226 #define BLOCKTYPE_EOF         0xff
227 
228 struct room_file_header {
229     RoomFileVersion version;
230     void ReadFromFile(Common::Stream *in);
231     void WriteFromFile(Common::Stream *out);
232 };
233 
234 extern int _acroom_bpp;  // bytes per pixel of currently loading room
235 
236 extern void load_room(const char *files, roomstruct *rstruc, bool gameIsHighRes);
237 
238 
239 // Those are, in fact, are project-dependent and are implemented in runtime and AGS.Native
240 extern void load_script_configuration(Common::Stream *in);
241 extern void save_script_configuration(Common::Stream *out);
242 extern void load_graphical_scripts(Common::Stream *in, roomstruct *);
243 extern void save_graphical_scripts(Common::Stream *out, roomstruct *);
244 //
245 
246 #endif // __AC_ROOMSTRUCT_H