summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSteven Fuller <relnev@icculus.org>2001-12-07 00:00:39 +0000
committerPatryk Obara <dreamer.tan@gmail.com>2019-08-20 02:22:37 +0200
commit790a20ef7ca9fbb88129380f5e96fa23fb13447e (patch)
tree0b0afe8f4a3a56e27aabddba37f3c9cedcd3c39c /src
parentbdb3cff6fdc8675fd38f26930181ebad8c8bbef5 (diff)
Silenced most of the debug messages.
Vidmode changing should work now.
Diffstat (limited to 'src')
-rw-r--r--src/avp/psndproj.c1
-rw-r--r--src/avp/win95/projload.cpp5
-rw-r--r--src/cdplayer.c14
-rw-r--r--src/main.c271
-rw-r--r--src/openal.c2
-rw-r--r--src/stubs.c110
-rw-r--r--src/winapi.c20
7 files changed, 279 insertions, 144 deletions
diff --git a/src/avp/psndproj.c b/src/avp/psndproj.c
index ee5a82a..9ee8da7 100644
--- a/src/avp/psndproj.c
+++ b/src/avp/psndproj.c
@@ -850,7 +850,6 @@ int FindAndLoadWavFile(int soundNum,char* wavFileName)
static char sound_name[200];
sprintf (sound_name, "%s%s", FirstSoundDir,wavFileName);
-printf("FindAndLoadWavFile: %d, %s\n", soundNum, wavFileName);
#if LOAD_SOUND_FROM_FAST_FILE
//first look in fast file
{
diff --git a/src/avp/win95/projload.cpp b/src/avp/win95/projload.cpp
index 5bb7277..e5bd32c 100644
--- a/src/avp/win95/projload.cpp
+++ b/src/avp/win95/projload.cpp
@@ -2815,10 +2815,7 @@ BOOL copy_rif_data (RIFFHANDLE h, int flags,int progress_start,int progress_inte
local_scale=env_scale;
while (random_marine_texturings.size())random_marine_texturings.delete_first_entry();
- while (random_civilian_texturings.size())random_civilian_texturings.delete_first_entry();
-
- ChangePalette(TestPalette);
- /*ConvertToDDPalette(TestPalette, LPTestPalette, palch->width, 0);*/
+ while (random_civilian_texturings.size())random_civilian_texturings.delete_first_entry();
}
//reset sound diretory pointer
diff --git a/src/cdplayer.c b/src/cdplayer.c
index 5bd3a78..55dbcde 100644
--- a/src/cdplayer.c
+++ b/src/cdplayer.c
@@ -10,6 +10,20 @@
static int HaveCDROM = 0;
static SDL_CD *cdrom = NULL;
+/* ** */
+
+/* cd_player.cpp */
+int CDPlayerVolume;
+
+void CheckCDVolume()
+{
+/*
+ fprintf(stderr, "CheckCDVolume()\n");
+*/
+}
+
+/* ** */
+
void CDDA_Start()
{
/*
diff --git a/src/main.c b/src/main.c
index 87a895e..2e36f9b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -25,9 +25,6 @@
#include "cdtrackselection.h"
#include "gammacontrol.h"
-#define MyWidth 800
-#define MyHeight 600
-
char LevelName[] = {"predbit6\0QuiteALongNameActually"}; /* the real way to load levels */
int DebouncedGotAnyKey;
@@ -158,6 +155,197 @@ PROCESSORTYPES ReadProcessorType()
return PType_PentiumMMX;
}
+/* ** */
+
+typedef struct VideoModeStruct
+{
+ int w;
+ int h;
+ int available;
+} VideoModeStruct;
+VideoModeStruct VideoModeList[] = {
+{ 512, 384, 0 },
+{ 640, 480, 0 },
+{ 800, 600, 0 },
+{ 1024, 768, 0 },
+{ 1152, 864, 0 },
+{ 1280, 1024, 0 },
+{ 1600, 1200, 0 }
+};
+
+int CurrentVideoMode;
+const int TotalVideoModes = sizeof(VideoModeList) / sizeof(VideoModeList[0]);
+
+void LoadDeviceAndVideoModePreferences()
+{
+/*
+ fprintf(stderr, "LoadDeviceAndVideoModePreferences()\n");
+*/
+ FILE *fp;
+ int mode;
+
+ fp = fopen("AvP_TempVideo.cfg", "r");
+
+ if (fp != NULL) {
+ if (fscanf(fp, "%d", &mode) == 1) {
+ fclose(fp);
+
+ if (mode >= 0 && mode < TotalVideoModes && VideoModeList[mode].available) {
+ CurrentVideoMode = mode;
+ return;
+ }
+ } else {
+ fclose(fp);
+ }
+ }
+
+ /* No, or invalid, mode found */
+
+ /* Try 640x480 first */
+ if (VideoModeList[1].available) {
+ CurrentVideoMode = 1;
+ } else {
+ int i;
+
+ for (i = 0; i < TotalVideoModes; i++) {
+ if (VideoModeList[i].available) {
+ CurrentVideoMode = i;
+ break;
+ }
+ }
+ }
+}
+
+void SaveDeviceAndVideoModePreferences()
+{
+/*
+ fprintf(stderr, "SaveDeviceAndVideoModePreferences()\n");
+*/
+ FILE *fp;
+
+ fp = fopen("AvP_TempVideo.cfg", "w");
+ if (fp != NULL) {
+ fprintf(fp, "%d\n", CurrentVideoMode);
+ fclose(fp);
+ }
+}
+
+void PreviousVideoMode2()
+{
+/*
+ fprintf(stderr, "PreviousVideoMode2()\n");
+*/
+ int cur = CurrentVideoMode;
+
+ do {
+ if (cur == 0)
+ cur = TotalVideoModes;
+ cur--;
+ if (cur == CurrentVideoMode)
+ return;
+ } while(!VideoModeList[cur].available);
+
+ CurrentVideoMode = cur;
+}
+
+void NextVideoMode2()
+{
+/*
+ fprintf(stderr, "NextVideoMode2()\n");
+*/
+ int cur = CurrentVideoMode;
+
+ do {
+ cur++;
+ if (cur == TotalVideoModes)
+ cur = 0;
+
+ if (cur == CurrentVideoMode)
+ return;
+ } while(!VideoModeList[cur].available);
+
+ CurrentVideoMode = cur;
+}
+
+char *GetVideoModeDescription2()
+{
+/*
+ fprintf(stderr, "GetVideoModeDescription2()\n");
+*/
+ return "SDL";
+}
+
+char *GetVideoModeDescription3()
+{
+/*
+ fprintf(stderr, "GetVideoModeDescription3()\n");
+*/
+ static char buf[64];
+
+ snprintf(buf, 64, "%dx%d", VideoModeList[CurrentVideoMode].w, VideoModeList[CurrentVideoMode].h);
+
+ return buf;
+}
+
+int InitSDL()
+{
+ SDL_Rect **SDL_AvailableVideoModes;
+
+ if (SDL_Init(SDL_INIT_VIDEO) < 0) {
+ fprintf(stderr, "SDL Init failed: %s\n", SDL_GetError());
+ exit(EXIT_FAILURE);
+ }
+
+ SDL_AvailableVideoModes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_OPENGL);
+ if (SDL_AvailableVideoModes == NULL)
+ return -1;
+
+ if (SDL_AvailableVideoModes != (SDL_Rect **)-1) {
+ int i, j, foundit;
+
+ foundit = 0;
+ for (i = 0; i < TotalVideoModes; i++) {
+ SDL_Rect **modes = SDL_AvailableVideoModes;
+
+ for (j = 0; modes[j]; j++) {
+ if (modes[j]->w >= VideoModeList[i].w &&
+ modes[j]->h >= VideoModeList[i].h) {
+ if (SDL_VideoModeOK(VideoModeList[i].w, VideoModeList[i].h, 16, SDL_FULLSCREEN | SDL_OPENGL)) {
+ /* assume SDL isn't lying to us */
+ VideoModeList[i].available = 1;
+
+ foundit = 1;
+ }
+ break;
+ }
+ }
+ }
+ if (foundit == 0)
+ return -1;
+ } else {
+ int i, foundit;
+
+ foundit = 0;
+ for (i = 0; i < TotalVideoModes; i++) {
+ if (SDL_VideoModeOK(VideoModeList[i].w, VideoModeList[i].h, 16, SDL_FULLSCREEN | SDL_OPENGL)) {
+ /* assume SDL isn't lying to us */
+ VideoModeList[i].available = 1;
+
+ foundit = 1;
+ }
+ }
+
+ if (foundit == 0)
+ return -1;
+ }
+
+ surface = NULL;
+
+ return 0;
+}
+
+/* ** */
+
int SetSoftVideoMode(int Width, int Height, int Depth)
{
SDL_GrabMode isgrab;
@@ -217,7 +405,6 @@ int SetSoftVideoMode(int Width, int Height, int Depth)
return 0;
}
-
int SetOGLVideoMode(int Width, int Height)
{
SDL_GrabMode isgrab;
@@ -237,8 +424,6 @@ int SetOGLVideoMode(int Width, int Height)
isgrab = SDL_GRAB_OFF;
}
-fprintf(stderr, "SDL: isfull = %d, isgrab = %d\n", isfull, isgrab);
-
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
@@ -262,14 +447,12 @@ fprintf(stderr, "SDL: isfull = %d, isgrab = %d\n", isfull, isgrab);
// SDL_WM_GrabInput(SDL_GRAB_ON);
// SDL_ShowCursor(0);
-fprintf(stderr, "SDL: before %08X\n", surface->flags);
if (isfull && !(surface->flags & SDL_FULLSCREEN)) {
-fprintf(stderr, "SDL: doing the fullscreen toggle\n");
SDL_WM_ToggleFullScreen(surface);
if (surface->flags & SDL_FULLSCREEN)
SDL_ShowCursor(0);
}
-fprintf(stderr, "SDL: after %08X\n", surface->flags);
+
if (isgrab == SDL_GRAB_ON) {
SDL_WM_GrabInput(SDL_GRAB_ON);
}
@@ -312,9 +495,9 @@ fprintf(stderr, "SDL: after %08X\n", surface->flags);
ScreenDescriptorBlock.SDB_ClipDown = Height;
ext = (char *)glGetString(GL_EXTENSIONS);
-
+/*
printf("OpenGL Extensions: %s\n", ext);
-
+*/
#if GL_EXT_secondary_color
pglSecondaryColorPointerEXT = NULL;
@@ -729,7 +912,7 @@ void CheckForWindowsMessages()
if ((KeyboardInput[KEY_LEFTALT]||KeyboardInput[KEY_RIGHTALT]) && DebouncedKeyboardInput[KEY_CR]) {
SDL_GrabMode gm;
-printf("SDL: before %08X (toggle)\n", surface->flags);
+
SDL_WM_ToggleFullScreen(surface);
gm = SDL_WM_GrabInput(SDL_GRAB_QUERY);
@@ -737,7 +920,6 @@ printf("SDL: before %08X (toggle)\n", surface->flags);
SDL_ShowCursor(1);
else
SDL_ShowCursor(0);
-printf("SDL: after %08X (toggle)\n", surface->flags);
}
if (KeyboardInput[KEY_LEFTCTRL] && DebouncedKeyboardInput[KEY_G]) {
@@ -777,45 +959,13 @@ int ExitWindowsSystem()
return 0;
}
-int InitSDL()
-{
- 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[])
{
- InitSDL();
+ if (InitSDL() == -1) {
+ fprintf(stderr, "Could not find a sutable resolution!\n");
+ fprintf(stderr, "At least 512x384 is needed. Does OpenGL work?\n");
+ exit(EXIT_FAILURE);
+ }
LoadCDTrackList();
@@ -840,7 +990,6 @@ int main(int argc, char *argv[])
InitGame();
SetSoftVideoMode(640, 480, 16);
-// SetOGLVideoMode(640, 480);
InitialVideoMode();
@@ -850,25 +999,8 @@ int main(int argc, char *argv[])
InitialiseSystem();
InitialiseRenderer();
- RequestedGammaSetting = 128;
-
-// LoadDefaultPrimaryConfigs(); /* load the configs! yes! */
- MarineInputPrimaryConfig = DefaultMarineInputPrimaryConfig;
- PredatorInputPrimaryConfig = DefaultPredatorInputPrimaryConfig;
- AlienInputPrimaryConfig = DefaultAlienInputPrimaryConfig;
- MarineInputSecondaryConfig = DefaultMarineInputSecondaryConfig;
- PredatorInputSecondaryConfig = DefaultPredatorInputSecondaryConfig;
- AlienInputSecondaryConfig = DefaultAlienInputSecondaryConfig;
-
- ControlMethods = DefaultControlMethods; /* raise the default sensitivity for now */
- ControlMethods.MouseXSensitivity = DEFAULT_MOUSEX_SENSITIVITY*2;
- ControlMethods.MouseYSensitivity = DEFAULT_MOUSEY_SENSITIVITY*2;
-
LoadKeyConfiguration();
- CheatMode_Active = CHEATMODE_NONACTIVE;
-
-
SoundSys_Start();
CDDA_Start();
@@ -926,7 +1058,7 @@ while(AvP_MainMenus())
d3d_light_ctrl.ctrl = LCCM_NORMAL;
d3d_overlay_ctrl.ctrl = OCCM_NORMAL;
- SetOGLVideoMode(MyWidth, MyHeight);
+ SetOGLVideoMode(VideoModeList[CurrentVideoMode].w, VideoModeList[CurrentVideoMode].h);
InitialiseGammaSettings(RequestedGammaSetting);
@@ -1077,7 +1209,6 @@ while(AvP_MainMenus())
ClearMemoryPool();
SetSoftVideoMode(640, 480, 16);
-// SetOGLVideoMode(640, 480);
}
SoundSys_StopAll();
diff --git a/src/openal.c b/src/openal.c
index 97ca8e2..dea3f83 100644
--- a/src/openal.c
+++ b/src/openal.c
@@ -727,7 +727,9 @@ void InitialiseBaseFrequency(SOUNDINDEX soundNum)
void PlatSetEnviroment(unsigned int env_index, float reverb_mix)
{
+/*
printf("PlatSetEnvironment(%d, %f)\n", env_index, reverb_mix);
+*/
}
void UpdateSoundFrequencies()
diff --git a/src/stubs.c b/src/stubs.c
index 49f3827..65229ce 100644
--- a/src/stubs.c
+++ b/src/stubs.c
@@ -22,72 +22,34 @@ BOOL KeepMainRifFile = FALSE;
int HWAccel = 1;
int VideoModeNotAvailable=0;
-
-/* videomodes.cpp */
-void LoadDeviceAndVideoModePreferences()
-{
- fprintf(stderr, "LoadDeviceAndVideoModePreferences()\n");
-}
-
-void SaveDeviceAndVideoModePreferences()
-{
- fprintf(stderr, "SaveDeviceAndVideoModePreferences()\n");
-}
-
-void PreviousVideoMode2()
-{
- fprintf(stderr, "PreviousVideoMode2()\n");
-}
-
-void NextVideoMode2()
-{
- fprintf(stderr, "NextVideoMode2()\n");
-}
-
-char *GetVideoModeDescription2()
-{
- fprintf(stderr, "GetVideoModeDescription2()\n");
-
- return "";
-}
-
-char *GetVideoModeDescription3()
-{
- fprintf(stderr, "GetVideoModeDescription3()\n");
-
- return "";
-}
-
-
-/* cd_player.cpp */
-int CDPlayerVolume;
-
-void CheckCDVolume()
-{
- fprintf(stderr, "CheckCDVolume()\n");
-}
-
/* bink.c */
void PlayBinkedFMV(char *filenamePtr)
{
+/*
fprintf(stderr, "PlayBinkedFMV(%s)\n", filenamePtr);
+*/
}
void StartMenuBackgroundBink()
{
+/*
fprintf(stderr, "StartMenuBackgroundBink()\n");
+*/
}
int PlayMenuBackgroundBink()
{
+/*
fprintf(stderr, "PlayMenuBackgroundBink()\n");
-
+*/
return 0;
}
void EndMenuBackgroundBink()
{
+/*
fprintf(stderr, "EndMenuBackgroundBink()\n");
+*/
}
@@ -101,32 +63,44 @@ int SmackerSoundVolume;
void GetFMVInformation(int *messageNumberPtr, int *frameNumberPtr)
{
+/*
fprintf(stderr, "GetFMVInformation(%p, %p)\n", messageNumberPtr, frameNumberPtr);
+*/
}
void InitialiseTriggeredFMVs()
{
+/*
fprintf(stderr, "InitialiseTriggeredFMVs()\n");
+*/
}
void StartFMVAtFrame(int number, int frame)
{
+/*
fprintf(stderr, "StartFMVAtFrame(%d, %d)\n", number, frame);
+*/
}
void StartTriggerPlotFMV(int number)
{
+/*
fprintf(stderr, "StartTriggerPlotFMV(%d)\n", number);
+*/
}
void UpdateAllFMVTextures()
{
+/*
fprintf(stderr, "UpdateAllFMVTextures()\n");
+*/
}
void EndMenuMusic()
{
+/*
fprintf(stderr, "EndMenuMusic()\n");
+*/
}
@@ -165,8 +139,9 @@ extern char * SecondSoundDir;
/* d3_func.cpp */
int GetTextureHandle(IMAGEHEADER *imageHeaderPtr)
{
+/*
fprintf(stderr, "GetTextureHandle(%p)\n", imageHeaderPtr);
-
+*/
return 1;
}
@@ -245,13 +220,6 @@ void MinimizeAllDDGraphics()
long BackBufferPitch;
int VideoModeColourDepth;
-int ChangePalette (unsigned char* NewPalette)
-{
- fprintf(stderr, "ChangePalette(%p)\n", NewPalette);
-
- return 0;
-}
-
void BlitWin95Char(int x, int y, unsigned char toprint)
{
fprintf(stderr, "BlitWin95Char(%d, %d, %d)\n", x, y, toprint);
@@ -325,20 +293,44 @@ int use_mmx_math = 0;
/* dxlog.c */
void dx_str_log(char const * str, int line, char const * file)
{
- fprintf(stderr, "dx_str_log: %s/%d: %s\n", file, line, str);
+ FILE *fp;
+
+ fp = fopen("dx_error.log", "a");
+ if (fp == NULL)
+ fp = stderr;
+
+ fprintf(fp, "dx_str_log: %s/%d: %s\n", file, line, str);
+
+ if (fp != stderr) fclose(fp);
}
void dx_strf_log(char const * fmt, ... )
{
va_list ap;
+ FILE *fp;
+
+ fp = fopen("dx_error.log", "a");
+ if (fp == NULL)
+ fp = stderr;
+
va_start(ap, fmt);
- fprintf(stderr, "dx_strf_log: ");
- vfprintf(stderr,fmt,ap);
- fprintf(stderr, "\n");
+ fprintf(fp, "dx_strf_log: ");
+ vfprintf(fp, fmt,ap);
+ fprintf(fp, "\n");
va_end(ap);
+
+ if (fp != stderr) fclose(fp);
}
void dx_line_log(int line, char const * file)
{
- fprintf(stderr, "dx_line_log: %s/%d\n", file, line);
+ FILE *fp;
+
+ fp = fopen("dx_error.log", "a");
+ if (fp == NULL)
+ fp = stderr;
+
+ fprintf(fp, "dx_line_log: %s/%d\n", file, line);
+
+ if (fp != stderr) fclose(fp);
}
diff --git a/src/winapi.c b/src/winapi.c
index f812cf1..c75d377 100644
--- a/src/winapi.c
+++ b/src/winapi.c
@@ -35,9 +35,9 @@ size_t _mbclen(const unsigned char *s)
HANDLE CreateFile(const char *file, int mode, int x, int y, int flags, int flags2, int z)
{
int fd;
-
+/*
fprintf(stderr, "CreateFile(%s, %d, %d, %d, %d, %d, %d)\n", file, mode, x, y, flags, flags2, z);
-
+*/
switch(mode) {
case GENERIC_READ:
if (flags != OPEN_EXISTING) {
@@ -62,7 +62,6 @@ HANDLE CreateFile(const char *file, int mode, int x, int y, int flags, int flags
}
break;
case GENERIC_READ|GENERIC_WRITE:
-// break;
default:
fprintf(stderr, "CreateFile: unknown mode %d\n", mode);
exit(EXIT_FAILURE);
@@ -79,9 +78,9 @@ HANDLE CreateFileA(const char *file, int write, int x, int y, int flags, int fla
int WriteFile(HANDLE file, const void *data, int len, /* unsigned long */ void *byteswritten, int x)
{
unsigned long *bw;
-
+/*
fprintf(stderr, "WriteFile(%d, %p, %d, %p, %d)\n", file, data, len, byteswritten, x);
-
+*/
bw = (unsigned long *)byteswritten;
*bw = write(file, data, len);
@@ -92,9 +91,9 @@ int WriteFile(HANDLE file, const void *data, int len, /* unsigned long */ void *
int ReadFile(HANDLE file, void *data, int len, /* unsigned long */ void *bytesread, int x)
{
unsigned long *br;
-
+/*
fprintf(stderr, "ReadFile(%d, %p, %d, %p, %d)\n", file, data, len, bytesread, x);
-
+*/
br = (unsigned long *)bytesread;
*br = read(file, data, len);
@@ -105,9 +104,9 @@ int ReadFile(HANDLE file, void *data, int len, /* unsigned long */ void *bytesre
int GetFileSize(HANDLE file, int x)
{
struct stat buf;
-
+/*
fprintf(stderr, "GetFileSize(%d, %d)\n", file, x);
-
+*/
if (fstat(file, &buf) == -1)
return -1;
return buf.st_size;
@@ -115,8 +114,9 @@ int GetFileSize(HANDLE file, int x)
int CloseHandle(HANDLE file)
{
+/*
fprintf(stderr, "CloseHandle(%d)\n", file);
-
+*/
close(file);
return 0;