2 //**************************************************************************
4 //** st_start.c : Heretic 2 : Raven Software, Corp.
11 //**************************************************************************
14 // HEADER FILES ------------------------------------------------------------
17 #include <sys/types.h>
19 /* I doubt I'll readd DOS support, but who knows */
26 #include <stdarg.h> // Needed for next as well as dos
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.
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
43 // TYPES -------------------------------------------------------------------
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);
58 // PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
60 // PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
61 char *ST_LoadScreen(void);
62 void ST_UpdateNotches(int notchPosition);
63 void ST_UpdateNetNotches(int notchPosition);
65 // EXTERNAL DATA DECLARATIONS ----------------------------------------------
67 // PUBLIC DATA DEFINITIONS -------------------------------------------------
69 // PRIVATE DATA DEFINITIONS ------------------------------------------------
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,
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,
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,
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
100 // Red Network Progress notches
101 char netnotchTable[]=
104 0x80, 0x50, 0xD0, 0xf0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xD0, 0xF0, 0xC0,
105 0x70, 0x50, 0x80, 0x60,
108 0x60, 0xE0, 0xE0, 0xA0, 0xA0, 0xA0, 0xE0, 0xA0, 0xA0, 0xA0, 0xE0, 0xA0,
109 0xA0, 0xE0, 0x60, 0x00,
112 0x80, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00,
113 0x10, 0x10, 0x80, 0x60,
116 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
117 0x00, 0x00, 0x00, 0x00
120 // CODE --------------------------------------------------------------------
124 //--------------------------------------------------------------------------
126 // Startup Screen Functions
128 //--------------------------------------------------------------------------
131 //==========================================================================
133 // ST_Init - Do the startup screen
135 //==========================================================================
145 // Set 640x480x16 mode
152 buffer = ST_LoadScreen();
154 bitmap = buffer + 16*3;
157 FadeToPaletteHR(pal);
170 //==========================================================================
174 //==========================================================================
176 void ST_UpdateNotches(int notchPosition)
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);
186 //==========================================================================
188 // ST_UpdateNetNotches - indicates network progress
190 //==========================================================================
192 void ST_UpdateNetNotches(int notchPosition)
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);
202 //==========================================================================
204 // ST_Progress - increments progress indicator
206 //==========================================================================
208 void ST_Progress(void)
211 static int notchPosition=0;
213 // Check for ESC press -- during startup all events eaten here
222 if(notchPosition<ST_MAX_NOTCHES)
224 ST_UpdateNotches(notchPosition);
225 S_StartSound(NULL, SFX_STARTUP_TICK);
234 //==========================================================================
236 // ST_NetProgress - indicates network progress
238 //==========================================================================
240 void ST_NetProgress(void)
243 static int netnotchPosition=0;
250 if(netnotchPosition<ST_MAX_NETNOTCHES)
252 ST_UpdateNetNotches(netnotchPosition);
253 S_StartSound(NULL, SFX_DRIP);
261 //==========================================================================
263 // ST_NetDone - net progress complete
265 //==========================================================================
266 void ST_NetDone(void)
268 S_StartSound(NULL, SFX_PICKUP_WEAPON);
272 //==========================================================================
274 // ST_Message - gives debug message
276 //==========================================================================
278 void ST_Message(char *message, ...)
283 va_start(argptr, message);
284 vsprintf(buffer, message, argptr);
287 if ( strlen(buffer) >= 80 )
289 I_Error("Long debug message has overwritten memory");
295 //==========================================================================
297 // ST_RealMessage - gives user message
299 //==========================================================================
301 void ST_RealMessage(char *message, ...)
306 va_start(argptr, message);
307 vsprintf(buffer, message, argptr);
310 if ( strlen(buffer) >= 80 )
312 I_Error("Long debug message has overwritten memory\n");
315 printf(buffer); // Always print these messages
320 //==========================================================================
322 // ST_LoadScreen - loads startup graphic
324 //==========================================================================
327 char *ST_LoadScreen(void)
332 lump = W_GetNumForName("STARTUP");
333 length = W_LumpLength(lump);
334 buffer = (char *)Z_Malloc(length, PU_STATIC, NULL);
335 W_ReadLump(lump, buffer);