summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README10
-rw-r--r--src/main.c159
-rw-r--r--src/menus.c40
-rw-r--r--src/stubs.c2
4 files changed, 162 insertions, 49 deletions
diff --git a/README b/README
index c220433..5f90570 100644
--- a/README
+++ b/README
@@ -31,9 +31,9 @@ http://www.avpnews.com/mods/tools/
Yes, the code does something. No, it's not ready for a release. No, it is not
-vaporware. I hope to at least complete the single portion of the game before
-making an official release. Check out the TODO to see what's needed to be
-done.
+vaporware. I hope to at least complete the single player part of the game
+before making an official release. Check out the TODO to see what's needed to
+be done.
If you are really itching to try this out, either install the Gold Ed. in
@@ -89,8 +89,8 @@ http://www.aliensvpredator.com/ubb/Forum2/HTML/001680.html
The full motion sequences cannot be played because they are encoded with
-proprietary codecs (Bink and Smacker). But I do not think they will be
-greatly missed.
+proprietary codecs (Bink and Smacker - http://www.radgametools.com). But I
+do not think they will be greatly missed.
More information about the game and the series can be found at
diff --git a/src/main.c b/src/main.c
index e1a838c..30d6ce2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -37,7 +37,7 @@ int MouseVelX;
int MouseVelY;
extern int ScanDrawMode; /* to fix image loading */
-extern SCREENDESCRIPTORBLOCK ScreenDescriptorBlock; /* this should be put in a header file */
+extern SCREENDESCRIPTORBLOCK ScreenDescriptorBlock;
extern unsigned char KeyboardInput[MAX_NUMBER_OF_INPUT_KEYS];
extern unsigned char GotAnyKey;
extern int NormalFrameTime;
@@ -65,20 +65,90 @@ PROCESSORTYPES ReadProcessorType()
return PType_PentiumMMX;
}
-int SetVideoMode(int Width, int Height)
+int SetSoftVideoMode(int Width, int Height, int Depth)
{
+ SDL_GrabMode isgrab;
+ int isfull;
+
+ ScanDrawMode = ScanDrawD3DHardwareRGB;
+ GotMouse = 1;
+
+ if (surface != NULL) {
+ isfull = (surface->flags & SDL_FULLSCREEN);
+ isgrab = SDL_WM_GrabInput(SDL_GRAB_QUERY);
+
+ SDL_FreeSurface(surface);
+ } else {
+ isfull = 0;
+ isgrab = SDL_GRAB_OFF;
+ }
+
+ if ((surface = SDL_SetVideoMode(Width, Height, Depth, SDL_SWSURFACE|SDL_DOUBLEBUF)) == NULL) {
+ fprintf(stderr, "SDL SetVideoMode failed: %s\n", SDL_GetError());
+ SDL_Quit();
+ exit(EXIT_FAILURE);
+ }
+
+ SDL_WM_SetCaption("Aliens vs Predator", "Aliens vs Predator");
+
+ /* this is for supporting keyboard input processing with little hassle */
+ SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
+ SDL_EnableUNICODE(1); /* toggle it to ON */
+
+ /* -w will disable first fullscreen, -f will turn it on */
+// SDL_WM_ToggleFullScreen(surface);
+// SDL_WM_GrabInput(SDL_GRAB_ON);
+// SDL_ShowCursor(0);
+
+ if (isfull) {
+ SDL_WM_ToggleFullScreen(surface);
+ if (surface->flags & SDL_FULLSCREEN)
+ SDL_ShowCursor(0);
+ }
+
+ if (isgrab == SDL_GRAB_ON) {
+ SDL_WM_GrabInput(SDL_GRAB_ON);
+ SDL_WM_ToggleFullScreen(surface);
+ }
+
+ ScreenDescriptorBlock.SDB_Width = Width;
+ ScreenDescriptorBlock.SDB_Height = Height;
+ ScreenDescriptorBlock.SDB_CentreX = Width/2;
+ ScreenDescriptorBlock.SDB_CentreY = Height/2;
+ ScreenDescriptorBlock.SDB_ProjX = Width/2;
+ ScreenDescriptorBlock.SDB_ProjY = Height/2;
+ ScreenDescriptorBlock.SDB_ClipLeft = 0;
+ ScreenDescriptorBlock.SDB_ClipRight = Width;
+ ScreenDescriptorBlock.SDB_ClipUp = 0;
+ ScreenDescriptorBlock.SDB_ClipDown = Height;
+
+ return 0;
+}
+
+int SetOGLVideoMode(int Width, int Height)
+{
+ SDL_GrabMode isgrab;
+ int isfull;
+
ScanDrawMode = ScanDrawD3DHardwareRGB;
GotMouse = 1;
+ if (surface != NULL) {
+ isfull = (surface->flags & SDL_FULLSCREEN);
+ isgrab = SDL_WM_GrabInput(SDL_GRAB_QUERY);
+
+ SDL_FreeSurface(surface);
+ } else {
+ isfull = 0;
+ isgrab = SDL_GRAB_OFF;
+ }
+
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);
- if (surface != NULL)
- SDL_FreeSurface(surface);
-
if ((surface = SDL_SetVideoMode(Width, Height, 0, SDL_OPENGL)) == NULL) {
fprintf(stderr, "SDL SetVideoMode failed: %s\n", SDL_GetError());
SDL_Quit();
@@ -91,11 +161,22 @@ int SetVideoMode(int Width, int Height)
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
SDL_EnableUNICODE(1); /* toggle it to ON */
- /* -w will disable to first fullscreen, -f will turn it on */
+ /* -w will disable first fullscreen, -f will turn it on */
// SDL_WM_ToggleFullScreen(surface);
// SDL_WM_GrabInput(SDL_GRAB_ON);
// SDL_ShowCursor(0);
-
+
+ if (isfull) {
+ SDL_WM_ToggleFullScreen(surface);
+ if (surface->flags & SDL_FULLSCREEN)
+ SDL_ShowCursor(0);
+ }
+
+ if (isgrab == SDL_GRAB_ON) {
+ SDL_WM_GrabInput(SDL_GRAB_ON);
+ SDL_WM_ToggleFullScreen(surface);
+ }
+
glViewport(0, 0, Width, Height);
glMatrixMode(GL_PROJECTION);
@@ -402,8 +483,10 @@ static void handle_keypress(int key, int unicode, int press)
RE_ENTRANT_QUEUE_WinProc_AddMessage_WM_KEYDOWN(VK_TAB);
break;
default:
- if (unicode && !(unicode & 0xFF80))
+ if (unicode && !(unicode & 0xFF80)) {
RE_ENTRANT_QUEUE_WinProc_AddMessage_WM_CHAR(unicode);
+ KeyboardEntryQueue_Add(unicode);
+ }
break;
}
}
@@ -551,16 +634,49 @@ int ExitWindowsSystem()
return 0;
}
-int main(int argc, char *argv[])
+int InitSDL()
{
- int menusActive = 0;
- int thisLevelHasBeenCompleted = 0;
-
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
fprintf(stderr, "SDL Init failed: %s\n", SDL_GetError());
exit(EXIT_FAILURE);
}
+
+#if 0
+ if ((surface = SDL_SetVideoMode(640, 480, 16, SDL_SWSURFACE|SDL_DOUBLEBUF)) == NULL) {
+ fprintf(stderr, "SDL SetVideoMode failed: %s\n", SDL_GetError());
+ SDL_Quit();
+ exit(EXIT_FAILURE);
+ }
+
+ SDL_FreeSurface(surface);
+ 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);
+
+ if ((surface = SDL_SetVideoMode(640, 480, 0, SDL_OPENGL)) == NULL) {
+ fprintf(stderr, "SDL SetVideoMode failed: %s\n", SDL_GetError());
+ SDL_Quit();
+ exit(EXIT_FAILURE);
+ }
+
+ SDL_FreeSurface(surface);
+#endif
+
+ surface = NULL;
+
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ int menusActive = 0;
+ int thisLevelHasBeenCompleted = 0;
+
+ InitSDL();
+
LoadCDTrackList();
SetFastRandom();
@@ -581,7 +697,7 @@ int main(int argc, char *argv[])
#endif
InitGame();
- SetVideoMode(640, 480);
+ SetOGLVideoMode(640, 480);
InitialVideoMode();
@@ -667,20 +783,7 @@ while(AvP_MainMenus()) {
d3d_light_ctrl.ctrl = LCCM_NORMAL;
d3d_overlay_ctrl.ctrl = OCCM_NORMAL;
- SetVideoMode(MyWidth, MyHeight);
-#if 0
- /* this was in windows SetGameVideoMode: */
- 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;
- ScreenDescriptorBlock.SDB_ClipLeft = 0;
- ScreenDescriptorBlock.SDB_ClipRight = MyWidth;
- ScreenDescriptorBlock.SDB_ClipUp = 0;
- ScreenDescriptorBlock.SDB_ClipDown = MyHeight;
-#endif
+ SetOGLVideoMode(MyWidth, MyHeight);
InitialiseGammaSettings(RequestedGammaSetting);
@@ -821,7 +924,7 @@ while(AvP_MainMenus()) {
ClearMemoryPool();
- SetVideoMode(640, 480);
+ SetOGLVideoMode(640, 480);
}
SoundSys_StopAll();
diff --git a/src/menus.c b/src/menus.c
index a249edc..4d0ff6e 100644
--- a/src/menus.c
+++ b/src/menus.c
@@ -22,6 +22,15 @@
extern int AAFontImageNumber;
+int PlayMenuBackgroundBink()
+{
+ fprintf(stderr, "PlayMenuBackgroundBink()\n");
+
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ return 0;
+}
+
AVPMENUGFX AvPMenuGfxStorage[MAX_NO_OF_AVPMENUGFXS] =
{
{"Menus\\fractal.rim"},
@@ -118,17 +127,16 @@ int LengthOfMenuText(char *textPtr)
int RenderMenuText(char *textPtr, int x, int y, int alpha, enum AVPMENUFORMAT_ID format)
{
- fprintf(stderr, "RenderMenuText(%s, %d, %d, %d, %d)\n", textPtr, x, y, alpha, format);
+
return Hardware_RenderSmallMenuText(textPtr, x, y, alpha, format);
-/*
+
fprintf(stderr, "RenderMenuText(%s, %d, %d, %d, %d)\n", textPtr, x, y, alpha, format);
return 0;
-*/
}
int RenderMenuText_Clipped(char *textPtr, int x, int y, int alpha, enum AVPMENUFORMAT_ID format, int topY, int bottomY)
-{
+{
fprintf(stderr, "RenderMenuText_Clipped(%s, %d, %d, %d, %d, %d, %d)\n", textPtr, x, y, alpha, format, topY, bottomY);
return 0;
@@ -136,40 +144,40 @@ int RenderMenuText_Clipped(char *textPtr, int x, int y, int alpha, enum AVPMENUF
int RenderSmallMenuText(char *textPtr, int x, int y, int alpha, enum AVPMENUFORMAT_ID format)
{
+
return Hardware_RenderSmallMenuText(textPtr, x, y, alpha, format);
-/*
+
fprintf(stderr, "RenderSmallMenuText(%s, %d, %d, %d, %d)\n", textPtr, x, y, alpha, format);
return 0;
-*/
}
int RenderSmallMenuText_Coloured(char *textPtr, int x, int y, int alpha, enum AVPMENUFORMAT_ID format, int red, int green, int blue)
{
+
return Hardware_RenderSmallMenuText_Coloured(textPtr, x, y, alpha, format, red, green, blue);
-/*
+
fprintf(stderr, "RenderSmallMenuText_Coloured(%s, %d, %d, %d, %d, %d, %d, %d)\n", textPtr, x, y, alpha, format, red, green, blue);
- return 0;
-*/
+ return 0;
}
void RenderKeyConfigRectangle(int alpha)
{
+
void Hardware_RenderKeyConfigRectangle(int alpha);
Hardware_RenderKeyConfigRectangle(alpha);
-/*
- fprintf(stderr, "RenderKeyConfigRectangle(%d)\n", alpha);
-*/
+
+ fprintf(stderr, "RenderKeyConfigRectangle(%d)\n", alpha);
}
void RenderHighlightRectangle(int x1, int y1, int x2, int y2, int r, int g, int b)
{
+
void Hardware_RenderHighlightRectangle(int x1,int y1,int x2,int y2,int r, int g, int b);
Hardware_RenderHighlightRectangle(x1, y1, x2, y2, r, g, b);
-/*
+
fprintf(stderr, "RenderHighlightRectangle(%d, %d, %d, %d, %d, %d, %d)\n", x1, y1, x2, y2, r, g, b);
-*/
}
void RenderSmallFontString_Wrapped(char *textPtr,RECT* area,int alpha,int* output_x,int* output_y)
@@ -191,7 +199,7 @@ void LoadAvPMenuGfx(enum AVPMENUGFX_ID menuGfxID)
/* TODO: make sure this doesn't cause a leak */
InitialiseTextures();
CL_GetImageFileName(buffer, 100, gfxPtr->FilenamePtr, LIO_RELATIVEPATH);
-
+
pFastFileData = ffreadbuf(buffer, &fastFileLength);
if (pFastFileData) {
@@ -273,7 +281,7 @@ void InitialiseMenuGfx()
AvPMenuGfxStorage[i].ImagePtr = NULL;
}
- glDisable(GL_BLEND);
+ glEnable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);
diff --git a/src/stubs.c b/src/stubs.c
index a762868..1737635 100644
--- a/src/stubs.c
+++ b/src/stubs.c
@@ -127,12 +127,14 @@ void StartMenuBackgroundBink()
fprintf(stderr, "StartMenuBackgroundBink()\n");
}
+#if 0
int PlayMenuBackgroundBink()
{
fprintf(stderr, "PlayMenuBackgroundBink()\n");
return 0;
}
+#endif
void EndMenuBackgroundBink()
{