|
|
1.1 ! root 1: ! 2: //************************************************************************** ! 3: //** ! 4: //** st_start.c : Heretic 2 : Raven Software, Corp. ! 5: //** ! 6: //** $RCSfile: st_start.c,v $ ! 7: //** $Revision: 1.21 $ ! 8: //** $Date: 95/12/21 15:03:51 $ ! 9: //** $Author: bgokey $ ! 10: //** ! 11: //************************************************************************** ! 12: ! 13: ! 14: // HEADER FILES ------------------------------------------------------------ ! 15: #ifdef __WATCOMC__ ! 16: #include <sys\stat.h> ! 17: #include <sys\types.h> ! 18: #include <io.h> ! 19: #else ! 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: #ifdef __WATCOMC__ ! 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: #endif ! 161: } ! 162: ! 163: ! 164: void ST_Done(void) ! 165: { ! 166: #ifdef __WATCOMC__ ! 167: ClearScreenHR(); ! 168: #endif ! 169: } ! 170: ! 171: ! 172: //========================================================================== ! 173: // ! 174: // ST_UpdateNotches ! 175: // ! 176: //========================================================================== ! 177: ! 178: void ST_UpdateNotches(int notchPosition) ! 179: { ! 180: #ifdef __WATCOMC__ ! 181: int x = ST_PROGRESS_X + notchPosition*ST_NOTCH_WIDTH; ! 182: int y = ST_PROGRESS_Y; ! 183: SlamBlockHR(x,y, ST_NOTCH_WIDTH,ST_NOTCH_HEIGHT, notchTable); ! 184: #endif ! 185: } ! 186: ! 187: ! 188: //========================================================================== ! 189: // ! 190: // ST_UpdateNetNotches - indicates network progress ! 191: // ! 192: //========================================================================== ! 193: ! 194: void ST_UpdateNetNotches(int notchPosition) ! 195: { ! 196: #ifdef __WATCOMC__ ! 197: int x = ST_NETPROGRESS_X + notchPosition*ST_NETNOTCH_WIDTH; ! 198: int y = ST_NETPROGRESS_Y; ! 199: SlamBlockHR(x,y, ST_NETNOTCH_WIDTH, ST_NETNOTCH_HEIGHT, netnotchTable); ! 200: #endif ! 201: } ! 202: ! 203: ! 204: //========================================================================== ! 205: // ! 206: // ST_Progress - increments progress indicator ! 207: // ! 208: //========================================================================== ! 209: ! 210: void ST_Progress(void) ! 211: { ! 212: #ifdef __WATCOMC__ ! 213: static int notchPosition=0; ! 214: ! 215: // Check for ESC press -- during startup all events eaten here ! 216: I_StartupReadKeys(); ! 217: ! 218: if (debugmode) ! 219: { ! 220: printf("."); ! 221: } ! 222: else ! 223: { ! 224: if(notchPosition<ST_MAX_NOTCHES) ! 225: { ! 226: ST_UpdateNotches(notchPosition); ! 227: S_StartSound(NULL, SFX_STARTUP_TICK); ! 228: notchPosition++; ! 229: } ! 230: } ! 231: #else ! 232: printf("."); ! 233: #endif ! 234: } ! 235: ! 236: ! 237: //========================================================================== ! 238: // ! 239: // ST_NetProgress - indicates network progress ! 240: // ! 241: //========================================================================== ! 242: ! 243: void ST_NetProgress(void) ! 244: { ! 245: #ifdef __WATCOMC__ ! 246: static int netnotchPosition=0; ! 247: if (debugmode) ! 248: { ! 249: printf("*"); ! 250: } ! 251: else ! 252: { ! 253: if(netnotchPosition<ST_MAX_NETNOTCHES) ! 254: { ! 255: ST_UpdateNetNotches(netnotchPosition); ! 256: S_StartSound(NULL, SFX_DRIP); ! 257: netnotchPosition++; ! 258: } ! 259: } ! 260: #endif ! 261: } ! 262: ! 263: ! 264: //========================================================================== ! 265: // ! 266: // ST_NetDone - net progress complete ! 267: // ! 268: //========================================================================== ! 269: void ST_NetDone(void) ! 270: { ! 271: S_StartSound(NULL, SFX_PICKUP_WEAPON); ! 272: } ! 273: ! 274: ! 275: //========================================================================== ! 276: // ! 277: // ST_Message - gives debug message ! 278: // ! 279: //========================================================================== ! 280: ! 281: void ST_Message(char *message, ...) ! 282: { ! 283: va_list argptr; ! 284: char buffer[80]; ! 285: ! 286: va_start(argptr, message); ! 287: vsprintf(buffer, message, argptr); ! 288: va_end(argptr); ! 289: ! 290: if ( strlen(buffer) >= 80 ) ! 291: { ! 292: I_Error("Long debug message has overwritten memory"); ! 293: } ! 294: ! 295: #ifdef __WATCOMC__ ! 296: if (debugmode) ! 297: { ! 298: printf(buffer); ! 299: } ! 300: #else ! 301: printf(buffer); ! 302: #endif ! 303: } ! 304: ! 305: //========================================================================== ! 306: // ! 307: // ST_RealMessage - gives user message ! 308: // ! 309: //========================================================================== ! 310: ! 311: void ST_RealMessage(char *message, ...) ! 312: { ! 313: va_list argptr; ! 314: char buffer[80]; ! 315: ! 316: va_start(argptr, message); ! 317: vsprintf(buffer, message, argptr); ! 318: va_end(argptr); ! 319: ! 320: if ( strlen(buffer) >= 80 ) ! 321: { ! 322: I_Error("Long debug message has overwritten memory\n"); ! 323: } ! 324: ! 325: printf(buffer); // Always print these messages ! 326: } ! 327: ! 328: ! 329: ! 330: //========================================================================== ! 331: // ! 332: // ST_LoadScreen - loads startup graphic ! 333: // ! 334: //========================================================================== ! 335: ! 336: ! 337: char *ST_LoadScreen(void) ! 338: { ! 339: int length,lump; ! 340: char *buffer; ! 341: ! 342: lump = W_GetNumForName("STARTUP"); ! 343: length = W_LumpLength(lump); ! 344: buffer = (char *)Z_Malloc(length, PU_STATIC, NULL); ! 345: W_ReadLump(lump, buffer); ! 346: return(buffer); ! 347: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.