2001-07-29 20:57:33 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2001-08-08 06:14:20 +00:00
|
|
|
#include <SDL/SDL.h>
|
|
|
|
#include <GL/gl.h>
|
|
|
|
|
2001-07-29 20:57:33 +00:00
|
|
|
#include "fixer.h"
|
|
|
|
|
2001-08-04 15:46:22 +00:00
|
|
|
#include "3dc.h"
|
2001-08-05 05:51:56 +00:00
|
|
|
#include "platform.h"
|
2001-08-13 01:20:45 +00:00
|
|
|
#include "inline.h"
|
2001-08-05 05:51:56 +00:00
|
|
|
#include "gamedef.h"
|
|
|
|
#include "gameplat.h"
|
|
|
|
#include "ffstdio.h"
|
|
|
|
#include "vision.h"
|
|
|
|
#include "comp_shp.h"
|
|
|
|
#include "avp_envinfo.h"
|
2001-08-06 19:50:26 +00:00
|
|
|
#include "stratdef.h"
|
|
|
|
#include "bh_types.h"
|
|
|
|
#include "avp_userprofile.h"
|
|
|
|
#include "pldnet.h"
|
2001-08-04 15:46:22 +00:00
|
|
|
#include "cdtrackselection.h"
|
2001-08-10 02:37:25 +00:00
|
|
|
#include "gammacontrol.h"
|
|
|
|
|
|
|
|
#define MyWidth 1024
|
|
|
|
#define MyHeight 768
|
2001-08-04 15:46:22 +00:00
|
|
|
|
2001-08-06 04:07:44 +00:00
|
|
|
char LevelName[] = {"predbit6\0QuiteALongNameActually"}; /* the real way to load levels */
|
2001-08-05 05:51:56 +00:00
|
|
|
|
2001-08-13 01:20:45 +00:00
|
|
|
int DebouncedGotAnyKey;
|
|
|
|
unsigned char DebouncedKeyboardInput[MAX_NUMBER_OF_INPUT_KEYS];
|
|
|
|
int GotJoystick;
|
|
|
|
int GotMouse;
|
|
|
|
int JoystickEnabled;
|
|
|
|
int MouseVelX;
|
|
|
|
int MouseVelY;
|
|
|
|
|
2001-08-05 05:51:56 +00:00
|
|
|
extern int ScanDrawMode; /* to fix image loading */
|
2001-08-06 04:07:44 +00:00
|
|
|
extern SCREENDESCRIPTORBLOCK ScreenDescriptorBlock; /* this should be put in a header file */
|
2001-08-08 22:42:43 +00:00
|
|
|
extern unsigned char KeyboardInput[MAX_NUMBER_OF_INPUT_KEYS];
|
|
|
|
extern unsigned char GotAnyKey;
|
2001-08-13 01:20:45 +00:00
|
|
|
extern int NormalFrameTime;
|
|
|
|
|
|
|
|
static SDL_Surface *surface;
|
|
|
|
|
|
|
|
void DirectReadKeyboard()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void DirectReadMouse()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReadJoysticks()
|
|
|
|
{
|
|
|
|
}
|
2001-08-05 05:51:56 +00:00
|
|
|
|
2001-07-31 04:06:01 +00:00
|
|
|
PROCESSORTYPES ReadProcessorType()
|
|
|
|
{
|
|
|
|
return PType_PentiumMMX;
|
|
|
|
}
|
|
|
|
|
|
|
|
int InitialiseWindowsSystem()
|
|
|
|
{
|
2001-08-05 05:51:56 +00:00
|
|
|
ScanDrawMode = ScanDrawD3DHardwareRGB;
|
2001-08-13 01:20:45 +00:00
|
|
|
GotMouse = 1;
|
2001-08-09 06:23:42 +00:00
|
|
|
|
2001-08-08 06:14:20 +00:00
|
|
|
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
|
|
|
fprintf(stderr, "SDL Init failed: %s\n", SDL_GetError());
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
|
|
|
|
2001-08-13 01:20:45 +00:00
|
|
|
if ((surface = SDL_SetVideoMode(MyWidth, MyHeight, 0, SDL_OPENGL)) == NULL) {
|
2001-08-08 06:14:20 +00:00
|
|
|
fprintf(stderr, "SDL SetVideoMode failed: %s\n", SDL_GetError());
|
|
|
|
SDL_Quit();
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
2001-08-12 04:42:44 +00:00
|
|
|
SDL_WM_SetCaption("Aliens vs Predator", "Aliens vs Predator");
|
2001-08-13 01:20:45 +00:00
|
|
|
|
|
|
|
/* -w will disable to first fullscreen, -f will turn it on */
|
|
|
|
SDL_WM_ToggleFullScreen(surface);
|
|
|
|
SDL_WM_GrabInput(SDL_GRAB_ON);
|
|
|
|
SDL_ShowCursor(0);
|
2001-08-12 04:42:44 +00:00
|
|
|
|
2001-08-10 02:37:25 +00:00
|
|
|
glViewport(0, 0, MyWidth, MyHeight);
|
2001-08-08 06:14:20 +00:00
|
|
|
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
glLoadIdentity();
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
glLoadIdentity();
|
2001-08-08 15:49:59 +00:00
|
|
|
|
|
|
|
glEnable(GL_BLEND);
|
2001-08-11 07:10:38 +00:00
|
|
|
|
2001-08-08 15:49:59 +00:00
|
|
|
glEnable(GL_DEPTH_TEST);
|
2001-08-11 07:10:38 +00:00
|
|
|
glDepthFunc(GL_LEQUAL);
|
|
|
|
|
2001-08-11 03:36:48 +00:00
|
|
|
glEnable(GL_TEXTURE_2D);
|
2001-08-11 21:04:45 +00:00
|
|
|
|
|
|
|
/*
|
2001-08-11 07:10:38 +00:00
|
|
|
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
2001-08-11 21:04:45 +00:00
|
|
|
*/
|
2001-07-31 04:06:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-08-08 22:42:43 +00:00
|
|
|
static int KeySymToKey(int keysym)
|
|
|
|
{
|
|
|
|
switch(keysym) {
|
|
|
|
case SDLK_ESCAPE:
|
|
|
|
return KEY_ESCAPE;
|
|
|
|
|
2001-08-09 22:34:20 +00:00
|
|
|
case SDLK_0:
|
|
|
|
return KEY_0;
|
|
|
|
case SDLK_1:
|
|
|
|
return KEY_1;
|
|
|
|
case SDLK_2:
|
|
|
|
return KEY_2;
|
|
|
|
case SDLK_3:
|
|
|
|
return KEY_3;
|
|
|
|
case SDLK_4:
|
|
|
|
return KEY_4;
|
|
|
|
case SDLK_5:
|
|
|
|
return KEY_5;
|
|
|
|
case SDLK_6:
|
|
|
|
return KEY_6;
|
|
|
|
case SDLK_7:
|
|
|
|
return KEY_7;
|
|
|
|
case SDLK_8:
|
|
|
|
return KEY_8;
|
|
|
|
case SDLK_9:
|
|
|
|
return KEY_9;
|
|
|
|
|
|
|
|
case SDLK_a:
|
|
|
|
return KEY_A;
|
|
|
|
case SDLK_b:
|
|
|
|
return KEY_B;
|
|
|
|
case SDLK_c:
|
|
|
|
return KEY_C;
|
|
|
|
case SDLK_d:
|
|
|
|
return KEY_D;
|
|
|
|
case SDLK_e:
|
|
|
|
return KEY_E;
|
|
|
|
case SDLK_f:
|
|
|
|
return KEY_F;
|
|
|
|
case SDLK_g:
|
|
|
|
return KEY_G;
|
|
|
|
case SDLK_h:
|
|
|
|
return KEY_H;
|
|
|
|
case SDLK_i:
|
|
|
|
return KEY_I;
|
|
|
|
case SDLK_j:
|
|
|
|
return KEY_J;
|
|
|
|
case SDLK_k:
|
|
|
|
return KEY_K;
|
|
|
|
case SDLK_l:
|
|
|
|
return KEY_L;
|
|
|
|
case SDLK_m:
|
|
|
|
return KEY_M;
|
|
|
|
case SDLK_n:
|
|
|
|
return KEY_N;
|
|
|
|
case SDLK_o:
|
|
|
|
return KEY_O;
|
|
|
|
case SDLK_p:
|
|
|
|
return KEY_P;
|
|
|
|
case SDLK_q:
|
|
|
|
return KEY_Q;
|
|
|
|
case SDLK_r:
|
|
|
|
return KEY_R;
|
|
|
|
case SDLK_s:
|
|
|
|
return KEY_S;
|
|
|
|
case SDLK_t:
|
|
|
|
return KEY_T;
|
|
|
|
case SDLK_u:
|
|
|
|
return KEY_U;
|
|
|
|
case SDLK_v:
|
|
|
|
return KEY_V;
|
|
|
|
case SDLK_w:
|
|
|
|
return KEY_W;
|
|
|
|
case SDLK_x:
|
|
|
|
return KEY_X;
|
|
|
|
case SDLK_y:
|
|
|
|
return KEY_Y;
|
|
|
|
case SDLK_z:
|
|
|
|
return KEY_Z;
|
|
|
|
|
2001-08-08 22:42:43 +00:00
|
|
|
case SDLK_LEFT:
|
|
|
|
return KEY_LEFT;
|
|
|
|
case SDLK_RIGHT:
|
|
|
|
return KEY_RIGHT;
|
|
|
|
case SDLK_UP:
|
|
|
|
return KEY_UP;
|
|
|
|
case SDLK_DOWN:
|
2001-08-09 22:34:20 +00:00
|
|
|
return KEY_DOWN;
|
|
|
|
case SDLK_RETURN:
|
|
|
|
return KEY_CR;
|
|
|
|
case SDLK_TAB:
|
|
|
|
return KEY_TAB;
|
|
|
|
case SDLK_INSERT:
|
|
|
|
return KEY_INS;
|
|
|
|
case SDLK_DELETE:
|
|
|
|
return KEY_DEL;
|
|
|
|
case SDLK_END:
|
|
|
|
return KEY_END;
|
|
|
|
case SDLK_HOME:
|
|
|
|
return KEY_HOME;
|
|
|
|
case SDLK_PAGEUP:
|
|
|
|
return KEY_PAGEUP;
|
|
|
|
case SDLK_PAGEDOWN:
|
|
|
|
return KEY_PAGEDOWN;
|
|
|
|
case SDLK_BACKSPACE:
|
|
|
|
return KEY_BACKSPACE;
|
|
|
|
case SDLK_COMMA:
|
|
|
|
return KEY_COMMA;
|
|
|
|
case SDLK_PERIOD:
|
|
|
|
return KEY_FSTOP; /* fstop? */
|
|
|
|
case SDLK_SPACE:
|
|
|
|
return KEY_SPACE;
|
|
|
|
|
|
|
|
case SDLK_LSHIFT:
|
|
|
|
return KEY_LEFTSHIFT;
|
|
|
|
case SDLK_RSHIFT:
|
|
|
|
return KEY_RIGHTSHIFT;
|
|
|
|
case SDLK_LALT:
|
|
|
|
return KEY_LEFTALT;
|
|
|
|
case SDLK_RALT:
|
|
|
|
return KEY_RIGHTALT;
|
|
|
|
case SDLK_LCTRL:
|
|
|
|
return KEY_LEFTCTRL;
|
|
|
|
case SDLK_RCTRL:
|
|
|
|
return KEY_RIGHTCTRL;
|
|
|
|
|
|
|
|
case SDLK_CAPSLOCK:
|
|
|
|
return KEY_CAPS;
|
|
|
|
case SDLK_NUMLOCK:
|
|
|
|
return KEY_NUMLOCK;
|
|
|
|
case SDLK_SCROLLOCK:
|
|
|
|
return KEY_SCROLLOK;
|
|
|
|
|
|
|
|
case SDLK_KP0:
|
|
|
|
return KEY_NUMPAD0;
|
|
|
|
case SDLK_KP1:
|
|
|
|
return KEY_NUMPAD1;
|
|
|
|
case SDLK_KP2:
|
|
|
|
return KEY_NUMPAD2;
|
|
|
|
case SDLK_KP3:
|
|
|
|
return KEY_NUMPAD3;
|
|
|
|
case SDLK_KP4:
|
|
|
|
return KEY_NUMPAD4;
|
|
|
|
case SDLK_KP5:
|
|
|
|
return KEY_NUMPAD5;
|
|
|
|
case SDLK_KP6:
|
|
|
|
return KEY_NUMPAD6;
|
|
|
|
case SDLK_KP7:
|
|
|
|
return KEY_NUMPAD7;
|
|
|
|
case SDLK_KP8:
|
|
|
|
return KEY_NUMPAD8;
|
|
|
|
case SDLK_KP9:
|
|
|
|
return KEY_NUMPAD9;
|
|
|
|
case SDLK_KP_MINUS:
|
|
|
|
return KEY_NUMPADSUB;
|
|
|
|
case SDLK_KP_PLUS:
|
|
|
|
return KEY_NUMPADADD;
|
|
|
|
case SDLK_KP_PERIOD:
|
|
|
|
return KEY_NUMPADDEL;
|
|
|
|
case SDLK_KP_ENTER:
|
|
|
|
return KEY_NUMPADENTER;
|
|
|
|
case SDLK_KP_DIVIDE:
|
|
|
|
return KEY_NUMPADDIVIDE;
|
|
|
|
case SDLK_KP_MULTIPLY:
|
|
|
|
return KEY_NUMPADMULTIPLY;
|
|
|
|
|
|
|
|
case SDLK_LEFTBRACKET:
|
|
|
|
return KEY_LBRACKET;
|
|
|
|
case SDLK_RIGHTBRACKET:
|
|
|
|
return KEY_RBRACKET;
|
|
|
|
case SDLK_SEMICOLON:
|
|
|
|
return KEY_SEMICOLON;
|
|
|
|
case SDLK_QUOTE:
|
|
|
|
return KEY_APOSTROPHE;
|
|
|
|
case SDLK_BACKQUOTE:
|
|
|
|
return KEY_GRAVE;
|
|
|
|
case SDLK_BACKSLASH:
|
|
|
|
return KEY_BACKSLASH;
|
|
|
|
case SDLK_SLASH:
|
|
|
|
return KEY_SLASH;
|
|
|
|
/* case SDLK_
|
|
|
|
return KEY_CAPITAL; */
|
|
|
|
case SDLK_MINUS:
|
|
|
|
return KEY_MINUS;
|
|
|
|
case SDLK_EQUALS:
|
|
|
|
return KEY_EQUALS;
|
|
|
|
case SDLK_LSUPER:
|
|
|
|
return KEY_LWIN;
|
|
|
|
case SDLK_RSUPER:
|
|
|
|
return KEY_RWIN;
|
|
|
|
/* case SDLK_
|
|
|
|
return KEY_APPS; */
|
|
|
|
|
|
|
|
case SDLK_F1:
|
|
|
|
return KEY_F1;
|
|
|
|
case SDLK_F2:
|
|
|
|
return KEY_F2;
|
|
|
|
case SDLK_F3:
|
|
|
|
return KEY_F3;
|
|
|
|
case SDLK_F4:
|
|
|
|
return KEY_F4;
|
|
|
|
case SDLK_F5:
|
|
|
|
return KEY_F5;
|
|
|
|
case SDLK_F6:
|
|
|
|
return KEY_F6;
|
|
|
|
case SDLK_F7:
|
|
|
|
return KEY_F7;
|
|
|
|
case SDLK_F8:
|
|
|
|
return KEY_F8;
|
|
|
|
case SDLK_F9:
|
|
|
|
return KEY_F9;
|
|
|
|
case SDLK_F10:
|
|
|
|
return KEY_F10;
|
|
|
|
case SDLK_F11:
|
|
|
|
return KEY_F11;
|
|
|
|
case SDLK_F12:
|
|
|
|
return KEY_F12;
|
|
|
|
|
|
|
|
/* finish foreign keys */
|
2001-08-08 22:42:43 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-08-13 01:20:45 +00:00
|
|
|
static void handle_keypress(int key, int press)
|
|
|
|
{
|
2001-08-08 22:42:43 +00:00
|
|
|
if (key == -1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (press && !KeyboardInput[key]) {
|
|
|
|
DebouncedKeyboardInput[key] = 1;
|
|
|
|
DebouncedGotAnyKey = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
GotAnyKey = 1;
|
|
|
|
KeyboardInput[key] = press;
|
|
|
|
}
|
|
|
|
|
2001-08-13 02:20:08 +00:00
|
|
|
static void handle_buttonpress(int button, int press)
|
|
|
|
{
|
|
|
|
int key;
|
|
|
|
|
|
|
|
switch(button) {
|
|
|
|
case 4: /* mouse wheel up */
|
|
|
|
key = KEY_MOUSEWHEELUP;
|
|
|
|
break;
|
|
|
|
case 5: /* mouse wheel down */
|
|
|
|
key = KEY_MOUSEWHEELDOWN;
|
|
|
|
break;
|
|
|
|
default: /* other buttons are handled elsewhere */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* since this currently only handles wheel up/down */
|
|
|
|
if (press == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (press && !KeyboardInput[key]) {
|
|
|
|
DebouncedKeyboardInput[key] = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
KeyboardInput[key] = press;
|
|
|
|
}
|
|
|
|
|
2001-08-08 06:14:20 +00:00
|
|
|
void CheckForWindowsMessages()
|
|
|
|
{
|
|
|
|
SDL_Event event;
|
2001-08-13 04:17:09 +00:00
|
|
|
int x, y, buttons, wantmouse;
|
2001-08-08 06:14:20 +00:00
|
|
|
|
2001-08-08 22:42:43 +00:00
|
|
|
GotAnyKey = 0;
|
|
|
|
DebouncedGotAnyKey = 0;
|
|
|
|
memset(DebouncedKeyboardInput, 0, sizeof(DebouncedKeyboardInput));
|
|
|
|
|
2001-08-13 04:17:09 +00:00
|
|
|
wantmouse = (surface->flags & SDL_FULLSCREEN) ||
|
|
|
|
(SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON);
|
|
|
|
|
2001-08-13 02:20:08 +00:00
|
|
|
KeyboardInput[KEY_MOUSEWHEELUP] = 0;
|
|
|
|
KeyboardInput[KEY_MOUSEWHEELDOWN] = 0;
|
|
|
|
|
2001-08-08 06:14:20 +00:00
|
|
|
if (SDL_PollEvent(&event)) {
|
|
|
|
do {
|
|
|
|
switch(event.type) {
|
2001-08-13 02:20:08 +00:00
|
|
|
case SDL_MOUSEBUTTONDOWN:
|
2001-08-13 04:17:09 +00:00
|
|
|
if (wantmouse)
|
|
|
|
handle_buttonpress(event.button.button, 1);
|
2001-08-13 02:20:08 +00:00
|
|
|
break;
|
|
|
|
case SDL_MOUSEBUTTONUP:
|
|
|
|
break;
|
2001-08-08 06:14:20 +00:00
|
|
|
case SDL_KEYDOWN:
|
2001-08-13 01:20:45 +00:00
|
|
|
handle_keypress(KeySymToKey(event.key.keysym.sym), 1);
|
2001-08-08 06:14:20 +00:00
|
|
|
break;
|
|
|
|
case SDL_KEYUP:
|
2001-08-13 01:20:45 +00:00
|
|
|
handle_keypress(KeySymToKey(event.key.keysym.sym), 0);
|
2001-08-08 06:14:20 +00:00
|
|
|
break;
|
|
|
|
case SDL_QUIT:
|
2001-08-13 01:20:45 +00:00
|
|
|
// SDL_Quit();
|
|
|
|
// exit(17); /* TODO tempy! */
|
|
|
|
AvP.MainLoopRunning = 0; /* TODO */
|
2001-08-08 06:14:20 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (SDL_PollEvent(&event));
|
|
|
|
}
|
2001-08-13 01:20:45 +00:00
|
|
|
|
|
|
|
buttons = SDL_GetRelativeMouseState(&x, &y);
|
2001-08-13 02:20:08 +00:00
|
|
|
|
2001-08-13 04:17:09 +00:00
|
|
|
if (wantmouse) {
|
|
|
|
if (buttons & SDL_BUTTON(1))
|
|
|
|
handle_keypress(KEY_LMOUSE, 1);
|
|
|
|
else
|
|
|
|
handle_keypress(KEY_LMOUSE, 0);
|
|
|
|
if (buttons & SDL_BUTTON(2))
|
|
|
|
handle_keypress(KEY_MMOUSE, 1);
|
|
|
|
else
|
|
|
|
handle_keypress(KEY_MMOUSE, 0);
|
|
|
|
if (buttons & SDL_BUTTON(3))
|
|
|
|
handle_keypress(KEY_RMOUSE, 1);
|
|
|
|
else
|
|
|
|
handle_keypress(KEY_RMOUSE, 0);
|
|
|
|
|
|
|
|
MouseVelX = DIV_FIXED(x, NormalFrameTime);
|
|
|
|
MouseVelY = DIV_FIXED(y, NormalFrameTime);
|
|
|
|
} else {
|
|
|
|
KeyboardInput[KEY_LMOUSE] = 0;
|
|
|
|
KeyboardInput[KEY_MMOUSE] = 0;
|
|
|
|
KeyboardInput[KEY_RMOUSE] = 0;
|
|
|
|
MouseVelX = 0;
|
|
|
|
MouseVelY = 0;
|
|
|
|
}
|
2001-08-13 01:20:45 +00:00
|
|
|
|
|
|
|
if (KeyboardInput[KEY_LEFTALT] && DebouncedKeyboardInput[KEY_CR]) {
|
2001-08-13 04:17:09 +00:00
|
|
|
SDL_GrabMode gm;
|
|
|
|
|
2001-08-13 01:20:45 +00:00
|
|
|
SDL_WM_ToggleFullScreen(surface);
|
2001-08-13 04:17:09 +00:00
|
|
|
|
|
|
|
gm = SDL_WM_GrabInput(SDL_GRAB_QUERY);
|
|
|
|
if (gm == SDL_GRAB_OFF && !(surface->flags & SDL_FULLSCREEN))
|
|
|
|
SDL_ShowCursor(1);
|
|
|
|
else
|
|
|
|
SDL_ShowCursor(0);
|
2001-08-13 01:20:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (KeyboardInput[KEY_LEFTCTRL] && DebouncedKeyboardInput[KEY_G]) {
|
|
|
|
SDL_GrabMode gm;
|
|
|
|
|
|
|
|
gm = SDL_WM_GrabInput(SDL_GRAB_QUERY);
|
|
|
|
SDL_WM_GrabInput((gm == SDL_GRAB_ON) ? SDL_GRAB_OFF : SDL_GRAB_ON);
|
2001-08-13 04:17:09 +00:00
|
|
|
|
|
|
|
gm = SDL_WM_GrabInput(SDL_GRAB_QUERY);
|
|
|
|
if (gm == SDL_GRAB_OFF && !(surface->flags & SDL_FULLSCREEN))
|
|
|
|
SDL_ShowCursor(1);
|
|
|
|
else
|
|
|
|
SDL_ShowCursor(0);
|
2001-08-13 01:20:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (DebouncedKeyboardInput[KEY_ESCAPE])
|
|
|
|
AvP.MainLoopRunning = 0;
|
|
|
|
|
|
|
|
/* ctrl-z for iconify window? */
|
2001-08-08 06:14:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void InGameFlipBuffers()
|
|
|
|
{
|
|
|
|
SDL_GL_SwapBuffers();
|
2001-08-12 19:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FlipBuffers()
|
|
|
|
{
|
|
|
|
SDL_GL_SwapBuffers();
|
2001-08-08 06:14:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ThisFramesRenderingHasBegun()
|
|
|
|
{
|
2001-08-10 02:37:25 +00:00
|
|
|
/* fprintf(stderr, "ThisFramesRenderingHasBegun()\n"); */
|
2001-08-09 06:23:42 +00:00
|
|
|
|
2001-08-10 02:37:25 +00:00
|
|
|
/* TODO: this should be in D3D_DrawBackdrop */
|
2001-08-11 03:36:48 +00:00
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
2001-08-08 06:14:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ThisFramesRenderingHasFinished()
|
|
|
|
{
|
2001-08-10 02:37:25 +00:00
|
|
|
/* fprintf(stderr, "ThisFramesRenderingHasFinished()\n"); */
|
|
|
|
|
|
|
|
/* This is where the queued drawing commands' execution takes place */
|
|
|
|
|
|
|
|
LightBlockDeallocation();
|
2001-08-08 06:14:20 +00:00
|
|
|
}
|
|
|
|
|
2001-08-03 05:30:40 +00:00
|
|
|
int ExitWindowsSystem()
|
|
|
|
{
|
2001-08-08 06:14:20 +00:00
|
|
|
SDL_Quit();
|
2001-08-12 19:48:15 +00:00
|
|
|
|
2001-08-03 05:30:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-07-29 20:57:33 +00:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2001-08-06 19:50:26 +00:00
|
|
|
int menusActive = 0;
|
|
|
|
int thisLevelHasBeenCompleted = 0;
|
|
|
|
|
2001-08-04 15:46:22 +00:00
|
|
|
LoadCDTrackList();
|
|
|
|
|
2001-08-05 05:51:56 +00:00
|
|
|
SetFastRandom();
|
|
|
|
|
|
|
|
GetPathFromRegistry();
|
|
|
|
|
|
|
|
#if MARINE_DEMO
|
|
|
|
ffInit("fastfile/mffinfo.txt","fastfile/");
|
|
|
|
#elif ALIEN_DEMO
|
|
|
|
ffInit("alienfastfile/ffinfo.txt","alienfastfile/");
|
|
|
|
#else
|
|
|
|
ffInit("fastfile/ffinfo.txt","fastfile/");
|
|
|
|
#endif
|
|
|
|
InitGame();
|
|
|
|
|
|
|
|
InitialVideoMode();
|
|
|
|
|
2001-08-06 04:07:44 +00:00
|
|
|
/* Env_List can probably be removed */
|
2001-08-06 19:50:26 +00:00
|
|
|
// Env_List[0] = &(ELOLevelToLoad); /* overwrite the first entry of crappy env_list with LevelName */
|
2001-08-06 04:07:44 +00:00
|
|
|
Env_List[0]->main = LevelName;
|
2001-08-05 05:51:56 +00:00
|
|
|
|
|
|
|
InitialiseSystem();
|
|
|
|
InitialiseRenderer();
|
|
|
|
|
2001-08-10 02:37:25 +00:00
|
|
|
RequestedGammaSetting = 128;
|
|
|
|
|
2001-08-05 05:51:56 +00:00
|
|
|
/* InitOptionsMenu(); NOT YET */
|
|
|
|
|
2001-08-09 22:34:20 +00:00
|
|
|
// LoadDefaultPrimaryConfigs(); /* load the configs! yes! */
|
|
|
|
MarineInputPrimaryConfig = DefaultMarineInputPrimaryConfig;
|
|
|
|
PredatorInputPrimaryConfig = DefaultPredatorInputPrimaryConfig;
|
|
|
|
AlienInputPrimaryConfig = DefaultAlienInputPrimaryConfig;
|
|
|
|
MarineInputSecondaryConfig = DefaultMarineInputSecondaryConfig;
|
|
|
|
PredatorInputSecondaryConfig = DefaultPredatorInputSecondaryConfig;
|
|
|
|
AlienInputSecondaryConfig = DefaultAlienInputSecondaryConfig;
|
2001-08-13 01:20:45 +00:00
|
|
|
|
|
|
|
ControlMethods = DefaultControlMethods; /* raise the default sensitivity for now */
|
|
|
|
ControlMethods.MouseXSensitivity = DEFAULT_MOUSEX_SENSITIVITY*2;
|
|
|
|
ControlMethods.MouseYSensitivity = DEFAULT_MOUSEY_SENSITIVITY*2;
|
2001-08-09 22:34:20 +00:00
|
|
|
|
2001-08-05 05:51:56 +00:00
|
|
|
LoadKeyConfiguration();
|
|
|
|
|
2001-08-09 22:34:20 +00:00
|
|
|
|
2001-08-05 05:51:56 +00:00
|
|
|
SoundSys_Start();
|
|
|
|
CDDA_Start();
|
|
|
|
|
|
|
|
InitTextStrings();
|
|
|
|
|
|
|
|
BuildMultiplayerLevelNameArray();
|
|
|
|
|
|
|
|
ChangeDirectDrawObject();
|
|
|
|
AvP.LevelCompleted = 0;
|
|
|
|
LoadSounds("PLAYER");
|
|
|
|
|
2001-08-06 04:07:44 +00:00
|
|
|
AvP.CurrentEnv = AvP.StartingEnv = 0; /* are these even used? */
|
2001-08-10 02:37:25 +00:00
|
|
|
|
2001-08-12 19:48:15 +00:00
|
|
|
// AvP.PlayerType = I_Alien;
|
|
|
|
// SetLevelToLoad(AVP_ENVIRONMENT_FERARCO); /* starting alien level */
|
2001-08-11 03:36:48 +00:00
|
|
|
|
2001-08-12 19:48:15 +00:00
|
|
|
AvP.PlayerType = I_Marine;
|
2001-08-12 02:30:17 +00:00
|
|
|
// SetLevelToLoad(AVP_ENVIRONMENT_DERELICT); /* starting marine level */
|
2001-08-11 03:36:48 +00:00
|
|
|
|
2001-08-11 07:10:38 +00:00
|
|
|
// AvP.PlayerType = I_Predator;
|
|
|
|
// SetLevelToLoad(AVP_ENVIRONMENT_WATERFALL); /* starting predator level */
|
2001-08-11 03:36:48 +00:00
|
|
|
|
2001-08-12 19:48:15 +00:00
|
|
|
SetLevelToLoad(AVP_ENVIRONMENT_LEADWORKS_MP); /* multiplayer */
|
2001-08-11 07:10:38 +00:00
|
|
|
|
|
|
|
// SetLevelToLoad(AVP_ENVIRONMENT_E3DEMOSP); /* demo level */
|
2001-08-12 02:30:17 +00:00
|
|
|
|
2001-08-05 05:51:56 +00:00
|
|
|
// while(AvP_MainMenus()) {
|
|
|
|
|
|
|
|
d3d_light_ctrl.ctrl = LCCM_NORMAL;
|
|
|
|
d3d_overlay_ctrl.ctrl = OCCM_NORMAL;
|
|
|
|
|
2001-08-06 04:07:44 +00:00
|
|
|
/* this was in windows SetGameVideoMode: */
|
2001-08-10 02:37:25 +00:00
|
|
|
ScreenDescriptorBlock.SDB_Width = MyWidth;
|
|
|
|
ScreenDescriptorBlock.SDB_Height = MyHeight;
|
|
|
|
ScreenDescriptorBlock.SDB_CentreX = MyWidth/2;
|
|
|
|
ScreenDescriptorBlock.SDB_CentreY = MyHeight/2;
|
|
|
|
ScreenDescriptorBlock.SDB_ProjX = MyWidth/2;
|
|
|
|
ScreenDescriptorBlock.SDB_ProjY = MyHeight/2;
|
2001-08-06 04:07:44 +00:00
|
|
|
ScreenDescriptorBlock.SDB_ClipLeft = 0;
|
2001-08-10 02:37:25 +00:00
|
|
|
ScreenDescriptorBlock.SDB_ClipRight = MyWidth;
|
2001-08-06 04:07:44 +00:00
|
|
|
ScreenDescriptorBlock.SDB_ClipUp = 0;
|
2001-08-10 02:37:25 +00:00
|
|
|
ScreenDescriptorBlock.SDB_ClipDown = MyHeight;
|
2001-08-06 04:07:44 +00:00
|
|
|
|
2001-08-05 05:51:56 +00:00
|
|
|
// GetCorrectDirectDrawObject();
|
|
|
|
|
2001-08-10 02:37:25 +00:00
|
|
|
InitialiseGammaSettings(RequestedGammaSetting);
|
|
|
|
|
2001-08-05 05:51:56 +00:00
|
|
|
start_of_loaded_shapes = load_precompiled_shapes();
|
|
|
|
|
|
|
|
InitCharacter();
|
|
|
|
|
|
|
|
LoadRifFile(); /* sets up a map */
|
|
|
|
|
|
|
|
AssignAllSBNames();
|
|
|
|
|
|
|
|
StartGame();
|
|
|
|
|
|
|
|
ffcloseall();
|
|
|
|
|
|
|
|
AvP.MainLoopRunning = 1;
|
|
|
|
|
|
|
|
/* ScanImagesForFMVs(); NOT YET */
|
|
|
|
|
|
|
|
ResetFrameCounter();
|
2001-08-12 19:48:15 +00:00
|
|
|
|
|
|
|
Game_Has_Loaded();
|
2001-08-05 05:51:56 +00:00
|
|
|
|
|
|
|
ResetFrameCounter();
|
|
|
|
|
|
|
|
/* IngameKeyboardInput_ClearBuffer(); NOT YET */
|
|
|
|
|
|
|
|
while(AvP.MainLoopRunning) {
|
|
|
|
CheckForWindowsMessages();
|
|
|
|
|
|
|
|
switch(AvP.GameMode) {
|
|
|
|
case I_GM_Playing:
|
2001-08-06 19:50:26 +00:00
|
|
|
if ((!menusActive || (AvP.Network!=I_No_Network && !netGameData.skirmishMode)) && !AvP.LevelCompleted) {
|
|
|
|
/* TODO: print some debugging stuff */
|
|
|
|
|
|
|
|
DoAllShapeAnimations();
|
|
|
|
|
|
|
|
UpdateGame();
|
|
|
|
|
|
|
|
AvpShowViews();
|
|
|
|
|
|
|
|
MaintainHUD();
|
|
|
|
|
|
|
|
CheckCDAndChooseTrackIfNeeded();
|
|
|
|
|
|
|
|
if(InGameMenusAreRunning() && ( (AvP.Network!=I_No_Network && netGameData.skirmishMode) || (AvP.Network==I_No_Network)) ) {
|
|
|
|
SoundSys_StopAll();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ReadUserInput();
|
|
|
|
|
|
|
|
/* UpdateAllFMVTextures(); NOT YET */
|
|
|
|
|
|
|
|
SoundSys_Management();
|
|
|
|
|
|
|
|
FlushD3DZBuffer();
|
|
|
|
|
|
|
|
ThisFramesRenderingHasBegun();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* NOT YET
|
|
|
|
menusActive = AvP_InGameMenus();
|
|
|
|
if (AvP.RestartLevel) menusActive=0;
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (AvP.LevelCompleted) {
|
|
|
|
SoundSys_FadeOutFast();
|
|
|
|
DoCompletedLevelStatisticsScreen();
|
|
|
|
thisLevelHasBeenCompleted = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ThisFramesRenderingHasFinished();
|
|
|
|
|
|
|
|
InGameFlipBuffers();
|
|
|
|
|
|
|
|
FrameCounterHandler();
|
|
|
|
{
|
|
|
|
PLAYER_STATUS *playerStatusPtr = (PLAYER_STATUS *) (Player->ObStrategyBlock->SBdataptr);
|
|
|
|
|
|
|
|
if (!menusActive && playerStatusPtr->IsAlive && !AvP.LevelCompleted) {
|
|
|
|
DealWithElapsedTime();
|
|
|
|
}
|
|
|
|
}
|
2001-08-05 05:51:56 +00:00
|
|
|
break;
|
2001-08-06 19:50:26 +00:00
|
|
|
|
2001-08-05 05:51:56 +00:00
|
|
|
case I_GM_Menus:
|
|
|
|
AvP.GameMode = I_GM_Playing;
|
|
|
|
break;
|
|
|
|
case I_GM_Paused:
|
2001-08-06 19:50:26 +00:00
|
|
|
// break;
|
2001-08-05 05:51:56 +00:00
|
|
|
default:
|
|
|
|
fprintf(stderr, "AvP.MainLoopRunning: gamemode = %d\n", AvP.GameMode);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2001-08-06 19:50:26 +00:00
|
|
|
|
|
|
|
if (AvP.RestartLevel) {
|
|
|
|
AvP.RestartLevel = 0;
|
|
|
|
AvP.LevelCompleted = 0;
|
|
|
|
/* NOT YET
|
|
|
|
FixCheatModesInUserProfile(UserProfilePtr);
|
|
|
|
*/
|
|
|
|
RestartLevel();
|
|
|
|
}
|
|
|
|
|
2001-08-08 06:14:20 +00:00
|
|
|
// break; /* TODO -- remove when loop works */
|
2001-08-05 05:51:56 +00:00
|
|
|
}
|
2001-08-06 19:50:26 +00:00
|
|
|
|
|
|
|
AvP.LevelCompleted = thisLevelHasBeenCompleted;
|
|
|
|
|
|
|
|
/* NOT YET
|
|
|
|
FixCheatModesInUserProfile(UserProfilePtr);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* NOT YET
|
|
|
|
CloseFMV();
|
|
|
|
ReleaseAllFMVTextures();
|
|
|
|
*/
|
|
|
|
|
|
|
|
CONSBIND_WriteKeyBindingsToConfigFile();
|
|
|
|
|
|
|
|
DeInitialisePlayer();
|
|
|
|
|
|
|
|
DeallocatePlayersMirrorImage();
|
|
|
|
|
|
|
|
KillHUD();
|
|
|
|
|
|
|
|
Destroy_CurrentEnvironment();
|
|
|
|
|
|
|
|
DeallocateAllImages();
|
|
|
|
|
|
|
|
EndNPCs();
|
|
|
|
|
|
|
|
ExitGame();
|
|
|
|
|
|
|
|
SoundSys_StopAll();
|
|
|
|
|
|
|
|
SoundSys_ResetFadeLevel();
|
|
|
|
|
|
|
|
CDDA_Stop();
|
|
|
|
|
|
|
|
if (AvP.Network != I_No_Network) {
|
|
|
|
/* NOT YET
|
|
|
|
EndAVPNetGame();
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
ClearMemoryPool();
|
2001-08-05 05:51:56 +00:00
|
|
|
|
2001-08-06 04:07:44 +00:00
|
|
|
// }
|
|
|
|
|
2001-08-06 19:50:26 +00:00
|
|
|
SoundSys_StopAll();
|
|
|
|
SoundSys_RemoveAll();
|
|
|
|
|
|
|
|
ExitSystem();
|
|
|
|
|
|
|
|
CDDA_End();
|
|
|
|
ClearMemoryPool();
|
|
|
|
|
2001-08-06 04:07:44 +00:00
|
|
|
fprintf(stderr, "Now exiting Aliens vs Predator! At least it didn't crash!\n");
|
|
|
|
|
2001-07-29 20:57:33 +00:00
|
|
|
return 0;
|
|
|
|
}
|