]> icculus.org git repositories - theoddone33/hhexen.git/blob - base/st_start.c
Round 2: Added --help and --version, as well as HHEXEN_DATA environment variable...
[theoddone33/hhexen.git] / base / st_start.c
1
2 //**************************************************************************
3 //**
4 //** st_start.c : Heretic 2 : Raven Software, Corp.
5 //**
6 //** $RCSfile$
7 //** $Revision$
8 //** $Date$
9 //** $Author$
10 //**
11 //**************************************************************************
12
13
14 // HEADER FILES ------------------------------------------------------------
15 #ifdef __linux
16         #include <sys/stat.h>
17         #include <sys/types.h>
18 #else 
19         #include <libc.h>
20         #include <ctype.h>
21         #define O_BINARY 0
22 #endif
23 #include "h2def.h"
24 #include <fcntl.h>
25 #include <stdarg.h>                             // Needed for next as well as dos
26 #include "st_start.h"
27
28
29 // MACROS ------------------------------------------------------------------
30 #define ST_MAX_NOTCHES          32
31 #define ST_NOTCH_WIDTH          16
32 #define ST_NOTCH_HEIGHT         23
33 #define ST_PROGRESS_X           64                      // Start of notches x screen pos.
34 #define ST_PROGRESS_Y           441                     // Start of notches y screen pos.
35
36 #define ST_NETPROGRESS_X                288
37 #define ST_NETPROGRESS_Y                32
38 #define ST_NETNOTCH_WIDTH               8
39 #define ST_NETNOTCH_HEIGHT              16
40 #define ST_MAX_NETNOTCHES               8
41
42 // TYPES -------------------------------------------------------------------
43
44 // EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
45 extern void SetVideoModeHR(void);
46 extern void ClearScreenHR(void);
47 extern void SlamHR(char *buffer);
48 extern void SlamBlockHR(int x, int y, int w, int h, char *src);
49 extern void InitPaletteHR(void);
50 extern void SetPaletteHR(byte *palette);
51 extern void GetPaletteHR(byte *palette);
52 extern void FadeToPaletteHR(byte *palette);
53 extern void FadeToBlackHR(void);
54 extern void BlackPaletteHR(void);
55 extern void I_StartupReadKeys(void);
56
57 // PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
58
59 // PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
60 char *ST_LoadScreen(void);
61 void ST_UpdateNotches(int notchPosition);
62 void ST_UpdateNetNotches(int notchPosition);
63
64 // EXTERNAL DATA DECLARATIONS ----------------------------------------------
65
66 // PUBLIC DATA DEFINITIONS -------------------------------------------------
67
68 // PRIVATE DATA DEFINITIONS ------------------------------------------------
69 char *bitmap = NULL;
70
71 char notchTable[]=
72 {
73         // plane 0
74         0x00, 0x80, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40,
75         0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x03, 0xC0,
76         0x0F, 0x90, 0x1B, 0x68, 0x3D, 0xBC, 0x3F, 0xFC, 0x20, 0x08, 0x20, 0x08,
77         0x2F, 0xD8, 0x37, 0xD8, 0x37, 0xF8, 0x1F, 0xF8, 0x1C, 0x50,
78
79         // plane 1
80         0x00, 0x80, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x02, 0x40,
81         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x01, 0xA0,
82         0x30, 0x6C, 0x24, 0x94, 0x42, 0x4A, 0x60, 0x0E, 0x60, 0x06, 0x7F, 0xF6,
83         0x7F, 0xF6, 0x7F, 0xF6, 0x5E, 0xF6, 0x38, 0x16, 0x23, 0xAC,
84
85         // plane 2
86         0x00, 0x80, 0x01, 0x80, 0x01, 0x80, 0x00, 0x00, 0x02, 0x40, 0x02, 0x40,
87         0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x03, 0xE0,
88         0x30, 0x6C, 0x24, 0x94, 0x52, 0x6A, 0x7F, 0xFE, 0x60, 0x0E, 0x60, 0x0E,
89         0x6F, 0xD6, 0x77, 0xD6, 0x56, 0xF6, 0x38, 0x36, 0x23, 0xAC,
90
91         // plane 3
92         0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80,
93         0x03, 0xC0, 0x03, 0xC0, 0x03, 0xC0, 0x03, 0xC0, 0x03, 0x80, 0x02, 0x40,
94         0x0F, 0x90, 0x1B, 0x68, 0x3D, 0xB4, 0x1F, 0xF0, 0x1F, 0xF8, 0x1F, 0xF8,
95         0x10, 0x28, 0x08, 0x28, 0x29, 0x08, 0x07, 0xE8, 0x1C, 0x50
96 };
97
98
99 // Red Network Progress notches
100 char netnotchTable[]=
101 {
102         // plane 0
103         0x80, 0x50, 0xD0, 0xf0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xD0, 0xF0, 0xC0,
104         0x70, 0x50, 0x80, 0x60,
105
106         // plane 1
107         0x60, 0xE0, 0xE0, 0xA0, 0xA0, 0xA0, 0xE0, 0xA0, 0xA0, 0xA0, 0xE0, 0xA0,
108         0xA0, 0xE0, 0x60, 0x00,
109
110         // plane 2
111         0x80, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00,
112         0x10, 0x10, 0x80, 0x60,
113
114         // plane 3
115         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
116         0x00, 0x00, 0x00, 0x00
117 };
118
119 // CODE --------------------------------------------------------------------
120
121
122
123 //--------------------------------------------------------------------------
124 //
125 // Startup Screen Functions
126 //
127 //--------------------------------------------------------------------------
128
129
130 //==========================================================================
131 //
132 // ST_Init - Do the startup screen
133 //
134 //==========================================================================
135
136 void ST_Init(void)
137 {
138 /*
139         char *pal;
140         char *buffer;
141
142         if (!debugmode)
143         {
144                 // Set 640x480x16 mode
145                 SetVideoModeHR();
146                 ClearScreenHR();
147                 InitPaletteHR();
148                 BlackPaletteHR();
149
150                 // Load graphic
151                 buffer = ST_LoadScreen();
152                 pal = buffer;
153                 bitmap = buffer + 16*3;
154
155                 SlamHR(bitmap);
156                 FadeToPaletteHR(pal);
157                 Z_Free(buffer);
158         }
159 */
160 }
161
162
163 void ST_Done(void)
164 {
165 //      ClearScreenHR();
166 }
167
168
169 //==========================================================================
170 //
171 // ST_UpdateNotches
172 //
173 //==========================================================================
174
175 void ST_UpdateNotches(int notchPosition)
176 {
177 /*
178         int x = ST_PROGRESS_X + notchPosition*ST_NOTCH_WIDTH;
179         int y = ST_PROGRESS_Y;
180         SlamBlockHR(x,y, ST_NOTCH_WIDTH,ST_NOTCH_HEIGHT, notchTable);
181 */
182 }
183
184
185 //==========================================================================
186 //
187 // ST_UpdateNetNotches - indicates network progress
188 //
189 //==========================================================================
190
191 void ST_UpdateNetNotches(int notchPosition)
192 {
193 /*
194         int x = ST_NETPROGRESS_X + notchPosition*ST_NETNOTCH_WIDTH;
195         int y = ST_NETPROGRESS_Y;
196         SlamBlockHR(x,y, ST_NETNOTCH_WIDTH, ST_NETNOTCH_HEIGHT, netnotchTable);
197 */
198 }
199
200
201 //==========================================================================
202 //
203 // ST_Progress - increments progress indicator
204 //
205 //==========================================================================
206
207 void ST_Progress(void)
208 {
209 /*
210         static int notchPosition=0;
211
212         // Check for ESC press -- during startup all events eaten here
213         I_StartupReadKeys();
214
215         if (debugmode)
216         {
217                 printf(".");
218         }
219         else
220         {
221                 if(notchPosition<ST_MAX_NOTCHES)
222                 {
223                         ST_UpdateNotches(notchPosition);
224                         S_StartSound(NULL, SFX_STARTUP_TICK);
225                         notchPosition++;
226                 }
227         }
228 */
229         printf("."); 
230 }
231
232
233 //==========================================================================
234 //
235 // ST_NetProgress - indicates network progress
236 //
237 //==========================================================================
238
239 void ST_NetProgress(void)
240 {
241 /*
242         static int netnotchPosition=0;
243         if (debugmode)
244         {
245                 printf("*");
246         }
247         else
248         {
249                 if(netnotchPosition<ST_MAX_NETNOTCHES)
250                 {
251                         ST_UpdateNetNotches(netnotchPosition);
252                         S_StartSound(NULL, SFX_DRIP);
253                         netnotchPosition++;
254                 }
255         }
256 */
257 }
258
259
260 //==========================================================================
261 //
262 // ST_NetDone - net progress complete
263 //
264 //==========================================================================
265 void ST_NetDone(void)
266 {
267         S_StartSound(NULL, SFX_PICKUP_WEAPON);
268 }
269
270
271 //==========================================================================
272 //
273 // ST_Message - gives debug message
274 //
275 //==========================================================================
276
277 void ST_Message(char *message, ...)
278 {
279         va_list argptr;
280         char buffer[80];
281
282         va_start(argptr, message);
283         vsprintf(buffer, message, argptr);
284         va_end(argptr);
285
286         if ( strlen(buffer) >= 80 )
287         {
288                 I_Error("Long debug message has overwritten memory");
289         }
290
291         printf(buffer); 
292 }
293
294 //==========================================================================
295 //
296 // ST_RealMessage - gives user message
297 //
298 //==========================================================================
299
300 void ST_RealMessage(char *message, ...)
301 {
302         va_list argptr;
303         char buffer[80];
304
305         va_start(argptr, message);
306         vsprintf(buffer, message, argptr);
307         va_end(argptr);
308
309         if ( strlen(buffer) >= 80 )
310         {
311                 I_Error("Long debug message has overwritten memory\n");
312         }
313
314         printf(buffer);         // Always print these messages
315 }
316
317
318
319 //==========================================================================
320 //
321 // ST_LoadScreen - loads startup graphic
322 //
323 //==========================================================================
324
325
326 char *ST_LoadScreen(void)
327 {
328         int length,lump;
329         char *buffer;
330
331         lump = W_GetNumForName("STARTUP");
332         length = W_LumpLength(lump);
333         buffer = (char *)Z_Malloc(length, PU_STATIC, NULL);
334         W_ReadLump(lump, buffer);
335         return(buffer);
336 }