1 /*
2 
3 Copyright (C) 2015-2018 Night Dive Studios, LLC.
4 
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 
18 */
19 //====================================================================================
20 //
21 //		System Shock - ©1994-1995 Looking Glass Technologies, Inc.
22 //
23 //		Shock.h	-	Mac-specific initialization and main event loop.
24 //
25 //====================================================================================
26 
27 #include <SDL.h>
28 
29 //--------------------
30 // Defines
31 //--------------------
32 //#define TESTING		1
33 
34 //#ifdef IS_REALLY_OSX
35 
36 //--------------------
37 // Menus
38 //--------------------
39 #ifdef TESTING
40 #define kNumMenus			6
41 #else
42 #define kNumMenus			4
43 #endif
44 
45 #define mApple					128					// Menu IDs
46 #define mFile						129
47 #define mEdit						130
48 #define mOptions				131
49 #ifdef TESTING
50 #define mTests					132
51 #define mTests2					133
52 #endif
53 
54 #define fileNewGame			1						// File menu item IDs
55 #define fileOpenGame			2
56 #define fileSaveGame			3
57 #define fileSaveGameAs		4
58 #define filePlayIntro			6
59 #define fileResumeGame		8
60 #define fileEndGame			9
61 #define fileQuit					11
62 
63 #define editUndo					1						// Edit menu item IDs
64 #define editCut					3
65 #define editCopy					4
66 #define editPaste				5
67 #define editClear				6
68 
69 #define optGameOptions		1						// Options menu item IDs
70 #define optGraphicsOptions	2
71 #define optSoundOptions		3
72 
73 #ifdef TESTING
74 #define testBrowseImages		1					// Tests menu item IDs
75 #define testBrowseFonts			2
76 #define testLoadPalette			3
77 #define testMoveKeys				5
78 #define testMouse					6
79 #define testPlayMovie				8
80 #define testPlayMovie2x			9
81 #define testPlayMovieDblSpd	10
82 #define testPlayMovieHalfSpd	11
83 #define testPlayIntro				13
84 #define testPlayDeath				14
85 #define testPlayEndGame			15
86 #define testPlayCitadelVM		17
87 #define testPlayDetachVM		18
88 #define testPlayJettisonVM		19
89 #define testPlayLaserMalVM	20
90 #define testPlayShieldsVM		21
91 #define testPlayAutoDesVM		22
92 #define testPlayBark1			24
93 #define testPlayBark2			25
94 #define testPlayAlog1				26
95 #define testPlayAlog2				27
96 
97 #define testLoadLevelR			1
98 #define testLoadLevel1			2
99 #define testLoadLevel2			3
100 #define testLoadLevel3			4
101 #define testZoomIn					6
102 #define testZoomOut				7
103 #define testRender				9
104 #endif
105 
106 //--------------------
107 // Graphics Defines
108 //--------------------
109 #define screenMaxX			640L
110 #define screenMaxY			480L
111 
112 //--------------------
113 // File Types
114 //--------------------
115 #define kAppFileType 			'Shok'
116 #define kGameFileType 		'Sgam'
117 #define kRsrcFileType 		'Sres'
118 
119 //--------------------
120 //  Function Prototypes
121 //--------------------
122 typedef void* WindowPtr; // FIXME: get rid of UpdateWindow()?
123 typedef void* MenuHandle; // FIXME: what's gMainMenus about?
124 int main(int argc, char** argv);
125 void HandleEvents(void);
126 void UpdateWindow(WindowPtr wind);
127 void DoCommand(unsigned long mResult);
128 bool DoSaveGame(void);
129 bool DoSaveGameAs(void);
130 void DoQuit(void);
131 void ScrollCredits(void);
132 
133 void InitSDL();
134 void SetSDLPalette(int index, int count, uchar *pal);
135 void SDLDraw();
136 void CaptureMouse(bool capture);
137 bool CheckArgument(char* name);
138 
139 //--------------------
140 // Public Globals
141 //--------------------
142 extern WindowPtr		gMainWindow;
143 extern MenuHandle		gMainMenus[kNumMenus];
144 //extern RgnHandle		gCursorRgn;
145 //extern short				gCursorSet;
146 extern bool			gDone;
147 extern bool			gInForeground;
148 extern bool			gIsNewGame;
149 //extern FSSpec				gSavedGameFile;
150 extern long					gGameSavedTime;
151 
152 //extern Handle				gExtraMemory;
153 //extern ColorSpec*		gOriginalColors;
154 extern unsigned long	gRandSeed;
155 extern short				gMainVRef;
156 // extern Handle				gWatchCurs;
157 
158 extern short				gOriginalDepth;
159 extern short				gStartupDepth;
160 extern short				gLastAlertDepth;
161 extern char					*gScreenAddress;
162 extern long					gScreenRowbytes;
163 extern short				gScreenWide, gScreenHigh;
164 extern short				gActiveWide, gActiveHigh;
165 extern short				gActiveLeft, gActiveTop;
166 //extern Rect				gActiveArea, gOffActiveArea;
167 
168 //extern Boolean			gIsPowerPC;
169 
170 extern long					gDataDirID;
171 extern short				gDataVref;
172 extern long					gCDDataDirID;
173 extern short				gCDDataVref;
174 extern long					gAlogDirID;
175 extern short				gAlogVref;
176 extern long					gBarkDirID;
177 extern short				gBarkVref;
178 
179 
180 extern grs_screen  *cit_screen;
181 extern SDL_Window* window;
182 
183 
184 /*#else
185 extern short				gOriginalDepth;
186 extern short				gStartupDepth;
187 extern short				gLastAlertDepth;
188 extern Ptr					gScreenAddress;
189 extern long					gScreenRowbytes;
190 extern short				gScreenWide, gScreenHigh;
191 extern short				gActiveWide, gActiveHigh;
192 extern short				gActiveLeft, gActiveTop;
193 #endif*/
194