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