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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef CRUISE_CRUISE_MAIN_H
24 #define CRUISE_CRUISE_MAIN_H
25 
26 #include "common/scummsys.h"
27 #include "common/savefile.h"
28 
29 #include "cruise/overlay.h"
30 #include "cruise/object.h"
31 #include "cruise/ctp.h"
32 #include "cruise/actor.h"
33 #include "cruise/vars.h"
34 #include "cruise/font.h"
35 #include "cruise/volume.h"
36 #include "cruise/stack.h"
37 #include "cruise/script.h"
38 #include "cruise/various.h"
39 #include "cruise/function.h"
40 #include "cruise/saveload.h"
41 #include "cruise/linker.h"
42 #include "cruise/mouse.h"
43 #include "cruise/gfxModule.h"
44 #include "cruise/dataLoader.h"
45 #include "cruise/perso.h"
46 #include "cruise/menu.h"
47 
48 #include "cruise/background.h"
49 #include "cruise/backgroundIncrust.h"
50 
51 #include "cruise/mainDraw.h"
52 
53 namespace Cruise {
54 
55 enum MouseButton {
56 	CRS_MB_LEFT = 1,
57 	CRS_MB_RIGHT = 2,
58 	CRS_MB_MIDDLE = 4,
59 	CRS_MB_BOTH = CRS_MB_LEFT | CRS_MB_RIGHT
60 };
61 
62 /*#define DUMP_SCRIPT
63 #define DUMP_OBJECT*/
64 
65 enum ResType {
66 	OBJ_TYPE_LINE = 0,
67 	OBJ_TYPE_MASK = 1,
68 	OBJ_TYPE_BGMASK = 2,
69 	OBJ_TYPE_VIRTUAL = 3,
70 	OBJ_TYPE_SPRITE = 4,
71 	OBJ_TYPE_MESSAGE = 5,
72 	OBJ_TYPE_SOUND = 6,
73 	OBJ_TYPE_FONT = 7,
74 	OBJ_TYPE_POLY = 8,
75 	OBJ_TYPE_EXIT = 9
76 };
77 
78 extern gfxEntryStruct* linkedMsgList;
79 
80 extern int buttonDown;
81 extern int selectDown;
82 extern int menuDown;
83 
84 bool delphineUnpack(byte *dst, const byte *src, int len);
85 int findHighColor();
86 ovlData3Struct *getOvlData3Entry(int32 scriptNumber, int32 param);
87 ovlData3Struct *scriptFunc1Sub2(int32 scriptNumber, int32 param);
88 void resetFileEntry(int32 entryNumber);
89 uint8 *mainProc14(uint16 overlay, uint16 idx);
90 void printInfoBlackBox(const char *string);
91 void waitForPlayerInput();
92 void loadPackedFileToMem(int fileIdx, uint8 * buffer);
93 int getNumObjectsByClass(int scriptIdx, int param);
94 void resetFileEntryRange(int param1, int param2);
95 int getProcParam(int overlayIdx, int param2, const char * name);
96 void changeScriptParamInList(int param1, int param2, scriptInstanceStruct * pScriptInstance, int newValue, int param3);
97 uint8 *getDataFromData3(ovlData3Struct * ptr, int param);
98 void removeExtention(const char *name, char *buffer);
99 void resetPtr2(scriptInstanceStruct * ptr);
100 void getFileExtention(const char *name, char *buffer);
101 void *allocAndZero(int size);
102 void freeStuff2();
103 void mainLoop();
104 void getMouseStatus(int16 *pMouseVar, int16 *pMouseX, int16 *pMouseButton, int16 *pMouseY);
105 bool testMask(int x, int y, unsigned char* pData, int stride);
106 menuElementSubStruct *getSelectedEntryInMenu(menuStruct *pMenu);
107 void closeAllMenu();
108 int removeFinishedScripts(scriptInstanceStruct *ptrHandle);
109 void initBigVar3();
110 void resetActorPtr(actorStruct *ptr);
111 void removeAllScripts(scriptInstanceStruct *ptrHandle);
112 
113 void MemoryList();
114 void *MemoryAlloc(uint32 size, bool clearFlag, int32 lineNum, const char *fname);
115 void MemoryFree(void *v);
116 
117 #define mallocAndZero(size) MemoryAlloc(size, true, __LINE__, __FILE__)
118 #define MemAlloc(size) MemoryAlloc(size, false, __LINE__, __FILE__)
119 #define MemFree(v) MemoryFree(v)
120 
121 } // End of namespace Cruise
122 
123 #endif
124