Main Page | Alphabetical List | Compound List | File List | Compound Members | File Members

Genvs.c File Reference

#include <Stdio.h>
#include <Dos.h>
#include <Math.h>
#include <Windows.H>
#include <MMSystem.H>
#include <StdLib.h>
#include <Assert.h>
#include <Time.h>
#include <direct.h>
#include "Genesis.h"
#include "bitmap.h"
#include "Errorlog.h"
#include "GameMgr.h"
#include "NetMgr.h"
#include "Host.h"
#include "Client.h"
#include "Console.h"
#include "DrvList.h"
#include "Menu.h"
#include "GMenu.h"
#include "Text.h"
#include "AutoSelect.h"

Go to the source code of this file.

Defines

#define CLIP_CURSOR
#define STARTING_WIDTH   (500)
#define STARTING_HEIGHT   (400)
#define DEFAULT_LEVEL   "Levels\\GenVS.BSP"

Functions

void GenVS_Error (const char *Msg,...)
LRESULT CALLBACK WndProc (HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam)
char * GetCommandText (char *CmdLine, char *Data, geBoolean Cmd)
void ShutdownAll (void)
geBoolean NewKeyDown (int KeyCode)
void GetMouseInput (HWND hWnd, int Width, int Height)
void AdjustPriority (int adjustment)
void SubLarge (LARGE_INTEGER *start, LARGE_INTEGER *end, LARGE_INTEGER *delta)
void PickMode (HWND hwnd, HANDLE hInstance, geBoolean NoSelection, geBoolean ManualSelection, ModeList *List, int ModeListLength, int *Selection)
int WINAPI WinMain (HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpszCmdParam, int nCmdShow)
geBoolean IsAMenuActive (void)

Variables

geBoolean PopupD3DLog = GE_FALSE
BOOL Running = TRUE
BOOL GameRunning = FALSE
BOOL ResetMouse = TRUE
char AppName [256] = "Genesis3D Sample Game"
geFloat EffectScale
geBoolean ChangingDisplayMode = GE_FALSE
int ChangeDisplaySelection
GameMgrGMgr = NULL
geEngineEngine = NULL
Console_ConsoleConsole = NULL
Host_HostHost = NULL
geSound_SystemSoundSys = NULL
char PlayerName [MENU_MAXSTRINGSIZE]
char IPAddress [MENU_MAXSTRINGSIZE]
float MainTime
geBoolean MenusCreated
ModeListDriverModeList
int DriverModeListLength
float GlobalMouseSpeedX
float GlobalMouseSpeedY
uint32 GlobalMouseFlags
Host_Init HostInit
geBoolean ShowStats
geBoolean Mute
geVFileMainFS
uint32 GlobalButtonBits
geBoolean ErrorHandled = GE_FALSE


Define Documentation

#define CLIP_CURSOR
 

Definition at line 43 of file Genvs.c.

#define DEFAULT_LEVEL   "Levels\\GenVS.BSP"
 

Definition at line 67 of file Genvs.c.

Referenced by WinMain().

#define STARTING_HEIGHT   (400)
 

Definition at line 58 of file Genvs.c.

Referenced by PickMode(), and WinMain().

#define STARTING_WIDTH   (500)
 

Definition at line 57 of file Genvs.c.

Referenced by PickMode(), and WinMain().


Function Documentation

void AdjustPriority int  adjustment  ) 
 

Definition at line 174 of file Genvs.c.

Referenced by WinMain(), and WndProc().

00175 {
00176         //HANDLE thread = GetCurrentThread();
00177         //SetThreadPriority(thread,adjustment);
00178 }

void GenVS_Error const char *  Msg,
... 
 

char * GetCommandText char *  CmdLine,
char *  Data,
geBoolean  Cmd
[static]
 

Definition at line 97 of file Genvs.c.

References GE_FALSE, GE_TRUE, geBoolean, int32, and NULL.

Referenced by WinMain().

00098 {
00099         geBoolean       Quote;
00100         int32           dp;
00101         char            ch;
00102 
00103         while (1)
00104         {
00105                 ch = *CmdLine;
00106                 
00107                 if (ch == 0 || ch == '\n')
00108                         return NULL;
00109 
00110                 if (ch == ' ')                          // Skip white space
00111                 {
00112                         CmdLine++;
00113                         continue;
00114                 }
00115 
00116                 if (ch == '-')
00117                 {
00118                         if (!Cmd)
00119                                 return NULL;            // FIXME:  Return error!!!
00120                         CmdLine++;
00121                         break;
00122                 }
00123                 else 
00124                 {
00125                         if (Cmd)
00126                                 return NULL;                    // FIXME:  Return error!!!
00127                         break;
00128                 }
00129 
00130                 CmdLine++;
00131         }
00132 
00133         if (ch == 0 || ch == '\n')
00134                 return NULL;
00135 
00136         if (ch == '"')
00137         {
00138                 Quote = GE_TRUE;
00139                 ch = *++CmdLine;
00140         }
00141         else
00142                 Quote = GE_FALSE;
00143 
00144         dp = 0;
00145 
00146         while (1)
00147         {
00148                 if (Quote)
00149                 {
00150                         if (ch == '"')
00151                         {
00152                                 break;
00153                         }
00154                         
00155                         if (ch == '\n' || ch == 0)
00156                                 return NULL;            // Quote not found!!!
00157                 }
00158                 else
00159                 {
00160                         if (ch == ' ' || ch == '\n' || ch == 0)
00161                                 break;
00162                 }
00163                 
00164                 ch = *CmdLine++;
00165                 Data[dp++] = ch;
00166         }
00167 
00168         Data[dp-1] = 0;
00169 
00170         return CmdLine;
00171                 
00172 }

void GetMouseInput HWND  hWnd,
int  Width,
int  Height
[static]
 

Definition at line 1218 of file Genvs.c.

References geErrorLog_AddString, GlobalMouseSpeedX, GlobalMouseSpeedY, int32, NULL, ResetMouse, and y.

Referenced by WinMain().

01219 {
01220         POINT   Point;
01221         float   dx, dy;
01222         int32   x, y;
01223         
01224         assert( Width > 0 );
01225         assert( Height > 0 );
01226         GetCursorPos(&Point);
01227   
01228         if (ScreenToClient( hWnd, &Point)==0)
01229                 {
01230                         geErrorLog_AddString(0,"GetMouseInput:  ScreenToClient failed",NULL); 
01231                         return;
01232                 }
01233         x = Point.x;
01234         y = Point.y;
01235 
01236         dx = ((float) (((float)Width/2.0f) - Point.x) / 350.0f);
01237         dy = ((float) (((float)Height/2.0f) - Point.y) / 350.0f);
01238 
01239         Point.x = Width/2;
01240         Point.y = Height/2;
01241 
01242         if (ClientToScreen( hWnd, &Point)==0)
01243                 {
01244                         geErrorLog_AddString(0,"GetMouseInput:  ClientToScreen failed",NULL); 
01245                         return;
01246                 }
01247         if(ResetMouse)
01248         {
01249                 SetCursorPos(Point.x,Point.y);
01250         }
01251 
01252         GlobalMouseSpeedX = dx;
01253         GlobalMouseSpeedY = dy;
01254 }

geBoolean IsAMenuActive void   ) 
 

Definition at line 1209 of file Genvs.c.

References geBoolean, and GMenu_IsAMenuActive().

01210 {
01211         // intentionally falls through if required
01212         return(GMenu_IsAMenuActive());
01213 }

geBoolean NewKeyDown int  KeyCode  )  [static]
 

Definition at line 211 of file Genvs.c.

References GE_FALSE, GE_TRUE, and geBoolean.

Referenced by Client_SendMove(), and WinMain().

00212 {
00213         if (GetAsyncKeyState(KeyCode) & 1)
00214                         return GE_TRUE;
00215 
00216         return GE_FALSE;
00217 }

void PickMode HWND  hwnd,
HANDLE  hInstance,
geBoolean  NoSelection,
geBoolean  ManualSelection,
ModeList List,
int  ModeListLength,
int *  Selection
[static]
 

Definition at line 724 of file Genvs.c.

References AutoSelect_PickDriver(), DrvList_PickDriver(), EffectScale, Engine, GameMgr_GethWnd(), GameMgr_PrepareToChangeMode(), GameMgr_ResetMainWindow(), GameMgr_SetDriverAndMode(), GE_FALSE, GE_TRUE, geEngine_SetDriverAndMode(), geEngine_ShutdownDriver(), geErrorLog_AddString, GenVS_Error(), GMgr, List, MODELIST_TYPE_D3D_3DFX, MODELIST_TYPE_D3D_PRIMARY, MODELIST_TYPE_D3D_SECONDARY, NULL, PopupD3DLog, ShutdownAll(), STARTING_HEIGHT, and STARTING_WIDTH.

Referenced by WinMain().

00726 {
00727 
00728         assert( hwnd != 0 );
00729         assert( hInstance != 0 );
00730         assert( List != NULL );
00731         assert( ListSelection != NULL );
00732 
00733         GameMgr_PrepareToChangeMode(GMgr);
00734 
00735         if (!NoSelection && !ManualSelection)
00736                         {
00737                                 if (AutoSelect_PickDriver(GameMgr_GethWnd(GMgr),Engine,List, ListLength, ListSelection)==GE_FALSE)
00738                                         {
00739                                                 geErrorLog_AddString(-1,"Automatic video mode selection failed to find good mode.  Trying manual selection.",NULL);
00740                                                 ManualSelection = GE_TRUE;
00741                                         }
00742                         }
00743 
00744         
00745         if (NoSelection || ManualSelection)
00746                 {
00747                         while (1)
00748                                 {
00749                                         if (!NoSelection)
00750                                                 {
00751                                                         if (DrvList_PickDriver(hInstance, GameMgr_GethWnd(GMgr), List, ListLength, ListSelection)==GE_FALSE)
00752                                                                 {
00753                                                                         geErrorLog_AddString(-1,"Driver pick dialog failed",NULL);
00754                                                                         ShutdownAll();
00755                                                                         exit(1);
00756                                                                 }
00757                                                 }
00758                                         NoSelection = GE_FALSE;
00759 
00760                                         if ( *ListSelection < 0 )       // no selection made
00761                                                 {
00762                                                         ShutdownAll();
00763                                                         exit(1);
00764                                                 }
00765 
00766                                         geEngine_ShutdownDriver(Engine);
00767 
00768                                         if(List[*ListSelection].InAWindow)
00769                                                 {
00770                                                         GameMgr_ResetMainWindow(hwnd,List[*ListSelection].Width,List[*ListSelection].Height);
00771                                                 }
00772                                         if ( (List[*ListSelection].DriverType == MODELIST_TYPE_D3D_PRIMARY)   ||
00773                                                  (List[*ListSelection].DriverType == MODELIST_TYPE_D3D_SECONDARY) ||
00774                                                  (List[*ListSelection].DriverType == MODELIST_TYPE_D3D_3DFX) )
00775                                                 {
00776                                                         PopupD3DLog = GE_TRUE;
00777                                                 }
00778                                         else
00779                                                 {
00780                                                         PopupD3DLog = GE_FALSE;
00781                                                 }
00782                                         if (!geEngine_SetDriverAndMode(Engine, List[*ListSelection].Driver, List[*ListSelection].Mode))
00783                                                 {
00784                                                         if ( GetCapture() )  // just in case
00785                                                                 {
00786                                                                         ReleaseCapture();
00787                                                                 }
00788                                                         GameMgr_ResetMainWindow(hwnd,STARTING_WIDTH,STARTING_HEIGHT);
00789                                                         geErrorLog_AddString(-1, "geEngine_SetDriverAndMode failed. (continuing)", NULL);
00790                                                         MessageBox(GameMgr_GethWnd(GMgr), "Driver failed to properly set the selected mode.","Error:",MB_OK);
00791                                                 }
00792                                         else
00793                                                 { 
00794                                                         break;
00795                                                 }
00796                                 }
00797                 }
00798 
00799 
00800 
00801         // Set the driver and the mode through the game manager...
00802         if (!GameMgr_SetDriverAndMode(GMgr, List[*ListSelection].Driver, List[*ListSelection].Mode, 
00803                                                                                 List[*ListSelection].Width,  List[*ListSelection].Height))
00804                 GenVS_Error("GameMgr_SetDriverAndMode failed.");
00805         
00806 
00807         EffectScale     = 0.3f; // this is always 0.3 ?
00808 
00809 }

void ShutdownAll void   ) 
 

Definition at line 814 of file Genvs.c.

References Console, Engine, GameMgr_Destroy(), GameMgr_GethWnd(), GE_FALSE, geVFile_Close(), GMenu_Destroy(), GMgr, Host, Host_Destroy(), HWND, MainFS, MenusCreated, NULL, SoundSys, Text_Destroy(), TRUE, and uint32.

Referenced by GenVS_Error(), PickMode(), and WinMain().

00815 {
00816         if ( GetCapture() )
00817         {
00818                 ReleaseCapture();
00819         }
00820         ShowCursor(TRUE);
00821 
00822         // Free each object (sub objects are freed by their parents...)
00823         if (MenusCreated)
00824         {
00825                 Text_Destroy();
00826                 GMenu_Destroy();
00827                 MenusCreated = GE_FALSE;
00828         }
00829 
00830         if (Host)
00831         {
00832                 Host_Destroy(Host);
00833                 Host = NULL;
00834         }
00835 
00836         if (GMgr)
00837                 {
00838                         HWND hWnd = GameMgr_GethWnd(GMgr);
00839                         if (hWnd)
00840                                 {
00841                                         ShowWindow(hWnd, SW_HIDE);
00842                                         UpdateWindow(hWnd);
00843                                 }
00844                 }
00845 
00846         if (GMgr)
00847                 GameMgr_Destroy(GMgr);
00848         
00849         geVFile_Close(MainFS);
00850 
00851         GMgr                    = NULL;
00852         Engine                  = NULL;
00853         Console                 = NULL;
00854         SoundSys                = NULL;
00855         Host                    = NULL;
00856 
00857         #ifdef _DEBUG
00858         {
00859                 char    Str[1024];
00860                 uint32  Count;
00861 
00862                 Count = geBitmap_Debug_GetCount();
00863 
00864                 sprintf(Str, "Final Bitmap count: %i\n", Count);
00865                 OutputDebugString(Str);
00866 
00867                 MessageBox(NULL, Str,
00868                         "GenVS MSG",MB_OK | MB_TASKMODAL);
00869 
00870         }
00871         #endif
00872 
00873         #ifdef CLIP_CURSOR      
00874                 ClipCursor(NULL);
00875         #endif
00876 
00877 }

void SubLarge LARGE_INTEGER *  start,
LARGE_INTEGER *  end,
LARGE_INTEGER *  delta
[static]
 

Definition at line 185 of file Genvs.c.

00186 {
00187         _asm {
00188                 mov ebx,dword ptr [start]
00189                 mov esi,dword ptr [end]
00190 
00191                 mov eax,dword ptr [esi+0]
00192                 sub eax,dword ptr [ebx+0]
00193 
00194                 mov edx,dword ptr [esi+4]
00195                 sbb edx,dword ptr [ebx+4]
00196 
00197                 mov ebx,dword ptr [delta]
00198                 mov dword ptr [ebx+0],eax
00199                 mov dword ptr [ebx+4],edx
00200         }
00201 }

int WINAPI WinMain HANDLE  hInstance,
HANDLE  hPrevInstance,
LPSTR  lpszCmdParam,
int  nCmdShow
 

Definition at line 227 of file Genvs.c.

References AdjustPriority(), AppName, AutoSelect_SortDriverList(), tagRECT::bottom, ChangeDisplaySelection, ChangingDisplayMode, Host_Init::ClientName, Console, Console_Frame(), Console_XYPrintf(), DEFAULT_LEVEL, Host_Init::DemoFile, Host_Init::DemoMode, DriverModeList, DriverModeListLength, Engine, FALSE, GameMgr_BeginFrame(), GameMgr_ClearBackground(), GameMgr_Create(), GameMgr_EndFrame(), GameMgr_Frame(), GameMgr_GetCamera(), GameMgr_GetConsole(), GameMgr_GetEngine(), GameMgr_GethWnd(), GameMgr_GetSoundSystem(), GameMgr_GetVidMode(), GameMgr_GetWorld(), GameRunning, GE_FALSE, GE_TRUE, GE_VFILE_OPEN_DIRECTORY, GE_VFILE_OPEN_READONLY, GE_VFILE_TYPE_DOS, geBoolean, geEngine_EnableFrameRateCounter(), geEngine_SetGamma(), GenVS_Error(), geSound_SetMasterVolume(), GetCommandText(), GetMouseInput(), geVFile_OpenNewSystem(), GMenu_Create(), GMenu_Destroy(), GMenu_Draw(), GMenu_GetMenu(), GMenu_IPEntry, GMenu_NameEntry, GMenu_SetActive(), GMgr, Host, Host_Create(), HOST_DEMO_NONE, HOST_DEMO_PLAY, HOST_DEMO_RECORD, Host_Destroy(), Host_Frame(), HOST_MODE_CLIENT, HOST_MODE_SERVER_CLIENT, HOST_MODE_SERVER_DEDICATED, HOST_MODE_SINGLE_PLAYER, Host_RenderFrame(), HostInit, Host_Init::hWnd, HWND, int32, IPAddress, tagRECT::left, Host_Init::LevelHack, MainFS, MainTime, Menu_SetStringText(), MenusCreated, Host_Init::Mode, ModeList_Create(), Mute, NETMGR_MAX_IP_ADDRESS, NewKeyDown(), NULL, PathLight, PickMode(), PlayerName, tagRECT::right, Running, ShowStats, ShutdownAll(), SoundSys, STARTING_HEIGHT, STARTING_WIDTH, SubLarge(), Text_Create(), Text_Destroy(), tagRECT::top, TRUE, UserGamma, VidMode, and VidMode_GetResolution().

00229 {
00230 #pragma warning (default: 4028)
00231         geDriver                *Driver     = NULL;
00232         geDriver_Mode   *DriverMode = NULL;
00233 
00234         SYSTEMTIME              SystemTime;
00235         MSG                             Msg;
00236         char                    *CmdLine = lpszCmdParam;
00237         int32                   i;
00238         LARGE_INTEGER   Freq, OldTick, CurTick;
00239         char                    TempName[256];
00240         int32                   TempNameLength;
00241         geBoolean               ManualPick=GE_FALSE;
00242 
00243         MainTime = 0.0f;
00244 
00245         AdjustPriority(THREAD_PRIORITY_NORMAL);
00246 
00247         for (i=0; i<255; i++)
00248         {
00249                 NewKeyDown(i);          // Need to flush all the keys
00250         }
00251 
00252         GetSystemTime(&SystemTime);
00253 
00254 #if 0
00255         if      (SystemTime.wYear > 1999 || SystemTime.wMonth > 11)
00256         {
00257                 MessageBox(NULL,"The time limit on this demo has expired. \n" 
00258                         "Please contact Eclipse Entertainment for more information.",
00259                         "Notice",MB_OK | MB_TASKMODAL);
00260                 return 0;
00261         }
00262 #endif
00263 
00264 
00265 // set the currrent directory to where the exe is
00266         {
00267                 int i;
00268                 char    PathBuf[_MAX_PATH];
00269 
00270                 // get the exe's path and name
00271                 if (GetModuleFileName(hInstance,PathBuf,_MAX_PATH-1)==0)
00272                 {
00273                         GenVS_Error("Could not get exe file name.");
00274                 }
00275 
00276                 // strip off exe name to leave path
00277                 for (i=strlen(PathBuf)-1; i>0; i--)
00278                         {
00279                                 if (PathBuf[i]=='\\')
00280                                         {
00281                                                 PathBuf[i]=0;
00282                                                 break;
00283                                         }
00284                         }
00285                 if (i==0)
00286                         {
00287                                 GenVS_Error("Could not parse exe's path from exe name.");
00288                         }
00289                 // move the current working directory to the executables directory.
00290                 // this is a little rude
00291                 if (_chdir(PathBuf)==-1)
00292                         {
00293                                 GenVS_Error("Could not change current working directory to exe's path.");
00294                         }
00295         }
00296         
00297 
00298         // Setup the appname
00299         sprintf(AppName, "GTest v1.0 "__DATE__","__TIME__"");
00300 
00301         // Get defaults
00302         ShowStats = Mute = GE_FALSE;
00303 
00304         strcpy(IPAddress, "");                                                  // Deafult our IP address to blank (LAN game)
00305         TempNameLength = sizeof(TempName);
00306         if( GetUserName( TempName, &TempNameLength ) == 0 )
00307         {
00308                 strcpy( PlayerName, "Player" );
00309         }
00310         else
00311         {
00312                 strncpy( PlayerName, TempName, sizeof( PlayerName ) );
00313                 PlayerName[ sizeof( PlayerName ) - 1 ] = '\0';
00314         }
00315 
00316 
00317         HostInit.Mode = HOST_MODE_SINGLE_PLAYER;
00318         HostInit.DemoMode = HOST_DEMO_NONE;
00319         HostInit.LevelHack[0] = 0;
00320         HostInit.DemoFile[0] = 0;
00321 
00322         GetCurrentDirectory(sizeof(TempName), TempName);
00323         MainFS = geVFile_OpenNewSystem(NULL,
00324                                                                    GE_VFILE_TYPE_DOS,
00325                                                                    TempName,
00326                                                                    NULL,
00327                                                                    GE_VFILE_OPEN_READONLY | GE_VFILE_OPEN_DIRECTORY);
00328         assert(MainFS);
00329         
00330 
00331         while (1)
00332         {       
00333                 char                    Data[MAX_PATH];
00334 
00335                 if (!(CmdLine = GetCommandText(CmdLine, Data, GE_TRUE)))
00336                         break;
00337 
00338                 if (!stricmp(Data, "Server"))
00339                 {
00340                         if (!HostInit.LevelHack[0])     
00341                                 strcpy(HostInit.LevelHack, DEFAULT_LEVEL);
00342 
00343                         HostInit.Mode = HOST_MODE_SERVER_CLIENT;
00344                 }
00345                 else if (!stricmp(Data, "Dedicated"))
00346                 {
00347                         HostInit.Mode = HOST_MODE_SERVER_DEDICATED;
00348                 }
00349                 else if (!stricmp(Data, "Client"))
00350                 {
00351                         HostInit.Mode = HOST_MODE_CLIENT;
00352                 }
00353                 else if (!stricmp(Data, "BotPathDebug"))
00354                 {
00355                         extern geBoolean PathLight; // hacked in
00356                         PathLight = GE_TRUE;
00357                 }
00358                 else if (!stricmp(Data, "Record"))
00359                 {
00360                         HostInit.DemoMode = HOST_DEMO_RECORD;
00361 
00362                         if (!(CmdLine = GetCommandText(CmdLine, Data, GE_FALSE)))
00363                                 GenVS_Error("No demo name specified on command line.");
00364 
00365                         strcpy(HostInit.DemoFile, Data);
00366                 }
00367                 else if (!stricmp(Data, "Play"))
00368                 {
00369                         HostInit.DemoMode = HOST_DEMO_PLAY;
00370 
00371                         if (!(CmdLine = GetCommandText(CmdLine, Data, GE_FALSE)))
00372                                 GenVS_Error("No demo name specified on command line.");
00373 
00374                         strcpy(HostInit.DemoFile, Data);
00375                 }
00376                 else if (!stricmp(Data, "Name"))
00377                 {
00378                         // Get name
00379                         if (!(CmdLine = GetCommandText(CmdLine, Data, GE_FALSE)))
00380                                 GenVS_Error("No name specified on command line.");
00381                         
00382                         strcpy(PlayerName, Data);
00383                 }
00384                 else if (!stricmp(Data, "IP"))
00385                 {
00386                         // Get name
00387                         if (!(CmdLine = GetCommandText(CmdLine, Data, GE_FALSE)))
00388                                 GenVS_Error("No IP Address specified on command line.");
00389                         
00390                         if (strlen(Data) >= NETMGR_MAX_IP_ADDRESS)
00391                                 GenVS_Error("MaxIP Address string on command line.\n");
00392 
00393                         strcpy(IPAddress, Data);                // User wants to override IP at command line
00394                 }
00395                 else if (!stricmp(Data, "Map"))
00396                 {
00397                         // Get name
00398                         if (!(CmdLine = GetCommandText(CmdLine, Data, GE_FALSE)))
00399                                 GenVS_Error("No map name specified on command line.");
00400                         sprintf(HostInit.LevelHack, "Levels\\%s", Data);
00401                         //sprintf(HostInit.UserLevel, "Levels\\%s", Data);
00402                 }
00403                 else if (!stricmp(Data, "Gamma"))
00404                 {
00405                         // Get name
00406                         if (!(CmdLine = GetCommandText(CmdLine, Data, GE_FALSE)))
00407                                 GenVS_Error("No gamma value specified on command line.");
00408                         
00409                         // <>
00410                         UserGamma = (float)atof(Data);
00411                 }
00412                 else if (!stricmp(Data, "ShowStats"))
00413                 {
00414                         ShowStats = GE_TRUE;
00415                 }
00416                 else if (!stricmp(Data, "Mute"))
00417                 {
00418                         Mute = GE_TRUE;
00419                 }
00420                 else if (!stricmp(Data, "VidMode"))
00421                 {
00422                         GenVS_Error("VidMode Parameter no longer supported");
00423                 }
00424                 else if (!stricmp(Data,"PickMode"))
00425                 {
00426                         ManualPick=GE_TRUE;
00427                 }
00428                 else
00429                         GenVS_Error("Unknown Option: %s.", Data);
00430         }
00431 
00432 
00433         
00434         //
00435         //      Create the Game Mgr
00436         //
00437         GMgr = GameMgr_Create(hInstance, STARTING_WIDTH, STARTING_HEIGHT, AppName);
00438         
00439         if (!GMgr)
00440                 GenVS_Error("Could not create the game mgr.");
00441 
00442         Engine = GameMgr_GetEngine(GMgr);
00443         if (!Engine)
00444                 GenVS_Error("Failed to create the geEngine Object");
00445 
00446         DriverModeList = ModeList_Create(Engine,&DriverModeListLength);
00447         if (DriverModeList == NULL)
00448                 {
00449                         GenVS_Error("Failed to create a list of available drivers - Make sure the driver dll's are in the right directory.");
00450                 }
00451         AutoSelect_SortDriverList(DriverModeList, DriverModeListLength);
00452 
00453         geEngine_EnableFrameRateCounter(Engine, ShowStats);
00454 
00455         
00456         do 
00457                 {
00458                         HWND hWnd;
00459                         VidMode VidMode;
00460 
00461                         // Pick mode
00462                         PickMode(GameMgr_GethWnd(GMgr),hInstance,ChangingDisplayMode, ManualPick, 
00463                                          DriverModeList, DriverModeListLength, &ChangeDisplaySelection);
00464                         ChangingDisplayMode = 0;                
00465 
00466                         // Text, and Menu should go in GameMgr to make the hierarchy clean
00467                         // Client, and Host could then look down on Menu, and grab default items out of it...
00468                         if (!Text_Create( Engine ))
00469                                 GenVS_Error("Text_Create failed.");
00470 
00471                         if (!GMenu_Create( Engine , DriverModeList, DriverModeListLength, ChangeDisplaySelection))
00472                                 GenVS_Error("GMenu_Create failed.");
00473                         
00474                         MenusCreated = GE_TRUE;
00475 
00476                         // Set the text in the menus for the name/ipaddress etc...
00477                         {
00478                                 Menu_SetStringText( GMenu_GetMenu(GMenu_NameEntry), GMenu_NameEntry, PlayerName );
00479                                 Menu_SetStringText( GMenu_GetMenu(GMenu_IPEntry), GMenu_IPEntry, IPAddress );
00480                         }
00481 
00482                         // Get the sound system
00483                         SoundSys = GameMgr_GetSoundSystem(GMgr);
00484                         //assert(SoundSys);
00485 
00486                         if (SoundSys)
00487                                 {
00488                                         if ( Mute )
00489                                                 geSound_SetMasterVolume(SoundSys, 0.0f );
00490                                 }
00491 
00492                         // Get the console
00493                         Console = GameMgr_GetConsole(GMgr);
00494                         assert(Console);
00495                         
00496                         HostInit.hWnd = GameMgr_GethWnd(GMgr);
00497                         strcpy(HostInit.ClientName, PlayerName);
00498 
00499                         if (!GameMgr_ClearBackground(GMgr, 0, 0, NULL))
00500                                 GenVS_Error("GameMgr_ClearBackground failed.");
00501 
00502                         // If a map has not been set, and not recording a demo, then play demos...
00503                         if (HostInit.DemoMode != HOST_DEMO_RECORD && !HostInit.LevelHack[0] && HostInit.Mode != HOST_MODE_CLIENT)
00504                                 HostInit.DemoMode = HOST_DEMO_PLAY;
00505                         else
00506                                 GMenu_SetActive(GE_FALSE);                      // Menu should start out as non active when recording a demo...
00507 
00508                         // If the user wants to load a level at the command prompt, or wants to play back a demo
00509                         // then load a host now, else just let them do it through the menus later...
00510                         if (HostInit.LevelHack[0] || HostInit.DemoMode != HOST_DEMO_NONE || HostInit.Mode == HOST_MODE_CLIENT)
00511                         {
00512                                 if (!HostInit.LevelHack[0])     
00513                                         strcpy(HostInit.LevelHack, DEFAULT_LEVEL);
00514 
00515                                 Host = Host_Create(Engine, &HostInit, GMgr, GameMgr_GetVidMode(GMgr));
00516 
00517                                 if (!Host)
00518                                         GenVS_Error("Could not create the host!\n");
00519                         }
00520                         else            // Make sure a defrault level is set!!!
00521                                 strcpy(HostInit.LevelHack, DEFAULT_LEVEL);
00522 
00523                 #if 1
00524                         // <>
00525                         geEngine_SetGamma(Engine, UserGamma);
00526                 #endif
00527 
00528                         QueryPerformanceFrequency(&Freq);
00529                         QueryPerformanceCounter(&OldTick);
00530 
00531                         //SetCapture(GameMgr_GethWnd(GMgr));
00532                         ShowCursor(FALSE);
00533                         
00534                         #ifdef CLIP_CURSOR      
00535                         {
00536                                 RECT    ClipRect;
00537                                 RECT    ClientRect;
00538                                 POINT   RPoint;
00539 
00540                                 GetClientRect(GameMgr_GethWnd(GMgr), &ClientRect);
00541                                 RPoint.x                =ClientRect.left;
00542                                 RPoint.y                =ClientRect.top;
00543                                 ClientToScreen(GameMgr_GethWnd(GMgr), &RPoint);
00544                                 ClipRect.left   =RPoint.x;
00545                                 ClipRect.top    =RPoint.y;
00546 
00547                                 RPoint.x                =ClientRect.right;
00548                                 RPoint.y                =ClientRect.bottom;
00549                                 ClientToScreen(GameMgr_GethWnd(GMgr), &RPoint);
00550                                 ClipRect.right  =RPoint.x;
00551                                 ClipRect.bottom =RPoint.y;
00552                                 ClipCursor(&ClipRect);
00553                         }
00554                         #endif
00555                         
00556                         Running = TRUE;
00557                         VidMode = GameMgr_GetVidMode(GMgr);
00558                         hWnd    = GameMgr_GethWnd(GMgr);
00559 
00560 
00561                         while (Running)
00562                         {
00563                                 LARGE_INTEGER   DeltaTick;
00564                                 float                   ElapsedTime;
00565                                 geWorld                 *World;
00566                                 geCamera                *Camera;
00567 
00568                                 GameRunning     =TRUE;
00569 
00570                                 // see runtime menu options for stats and video mode changing.  (Mike)
00571 
00572                                 SetCursor(NULL);
00573                                 #ifdef DO_CAPTURE
00574                                 SetCapture(hWnd);
00575                                 #endif
00576 
00577                                 // Get timing info
00578                                 QueryPerformanceCounter(&CurTick);
00579 
00580                                 SubLarge(&OldTick, &CurTick, &DeltaTick);
00581 
00582                                 OldTick = CurTick;
00583 
00584                                 if (DeltaTick.LowPart > 0)
00585                                         ElapsedTime =  1.0f / (((float)Freq.LowPart / (float)DeltaTick.LowPart));
00586                                 else 
00587                                         ElapsedTime = 0.001f;
00588 
00589                                 //MainTime += ElapsedTime;
00590 
00591                                 // Get the mouse input (FIXME:  Move this into client?)
00592                                 {
00593                                         int Width, Height;
00594                                         VidMode_GetResolution(VidMode,&Width,&Height);
00595                                         GetMouseInput(hWnd,Width,Height);
00596                                 }
00597 
00598                                 // Do a host frame (physics, etc)
00599                                 if (Host)
00600                                 {
00601                                         if (!Host_Frame(Host, ElapsedTime))
00602                                                 GenVS_Error("Host_Frame failed...");
00603                                 }
00604 
00605                                 // Get the world, and the camera from the GameMgr
00606                                 World = GameMgr_GetWorld(GMgr);
00607                                 Camera = GameMgr_GetCamera(GMgr);;
00608 
00609                                 if (!GameMgr_Frame(GMgr, ElapsedTime))
00610                                         GenVS_Error("GameMgr_Frame failed...");
00611 
00612                                 // Begin frame
00613                                 if (!GameMgr_BeginFrame(GMgr, World, GE_FALSE))
00614                                 {
00615                                         GenVS_Error("GameMgr_BeginFrame failed.\n");
00616                                 }
00617 
00618                                 if (!Host || !World)
00619                                         GameMgr_ClearBackground(GMgr, 0, 0, NULL);
00620 
00621                                 if (Host)
00622                                 {
00623                                         if (!Host_RenderFrame(Host, ElapsedTime))
00624                                                 GenVS_Error("Host_RenderFrame failed in main game loop.\n");
00625                                 }
00626 
00627                                 Console_Frame(Console, ElapsedTime);
00628 
00629                                 /*
00630                                 if (Host)
00631                                 {
00632                                         if (!World)
00633                                                 GameMgr_ClearBackground(GMgr, 0, 0, NULL);
00634 
00635                                         if (Host_RenderFrame(Host, ElapsedTime)==GE_FALSE)
00636                                                 GenVS_Error("Host_RenderFrame failed in main game loop.\n");
00637 
00638                                         Console_Frame(Console, ElapsedTime);
00639                                 }
00640                                 else
00641                                         GameMgr_ClearBackground(GMgr, 0, 0, NULL);
00642                                 */
00643 
00644                                 if (!ShowStats && World)
00645                                 {
00646                                         Console_XYPrintf(Console,0,0,0,"Driver: %s %s",
00647                                                 DriverModeList[ChangeDisplaySelection].DriverNamePtr,
00648                                                 DriverModeList[ChangeDisplaySelection].ModeNamePtr);
00649                                         
00650                                         if (!SoundSys)
00651                                         {
00652                                                 Console_XYPrintf(Console,0,1,0,"(No sound device found)");
00653                                         }
00654                                 }
00655                                 
00656                                 // Draw manu
00657                                 GMenu_Draw();
00658 
00659                                 //      End Engine frame
00660                                 if (!GameMgr_EndFrame(GMgr))
00661                                 {
00662                                         GenVS_Error("GameMgr_EndFrame failed.\n");
00663                                 }
00664 
00665                                 // Do the'ol message pump
00666                                 
00667                                 while (PeekMessage( &Msg, NULL, 0, 0, PM_NOREMOVE))
00668                                 {
00669                                         if (!GetMessage(&Msg, NULL, 0, 0 ))
00670                                         {
00671                                                 PostQuitMessage(0);
00672                                                 Running=0;
00673                                                 break;
00674                                         }
00675 
00676                                         TranslateMessage(&Msg); 
00677                                         DispatchMessage(&Msg);
00678                                         if (ChangingDisplayMode)
00679                                                 {
00680                                                         break;
00681                                                 }
00682                                 }
00683                                 
00684                                 
00685 
00686                                 if (ChangingDisplayMode)
00687                                         {
00688                                                 Running = 0;            
00689                                                 GameRunning     = FALSE;
00690                                         }
00691                         } 
00692                         
00693                                 if (ChangingDisplayMode)
00694                                         {
00695                                                 if (MenusCreated)
00696                                                         {
00697                                                                 Text_Destroy();
00698                                                                 GMenu_Destroy();
00699                                                                 MenusCreated = GE_FALSE;
00700                                                         }
00701 
00702                                                 if (Host)
00703                                                         {
00704                                                                 Host_Destroy(Host);
00705                                                                 Host = NULL;
00706                                                         }
00707                                                 
00708                                                 if ( GetCapture() )
00709                                                         {
00710                                                                 ReleaseCapture();
00711                                                         }
00712                                                 ShowCursor(TRUE);
00713                                         }
00714 
00715                         
00716                 }
00717         while (ChangingDisplayMode != GE_FALSE);
00718 
00719         ShutdownAll();
00720         return (0);
00721 }

LRESULT CALLBACK WndProc HWND  hWnd,
UINT  iMessage,
WPARAM  wParam,
LPARAM  lParam
 


Variable Documentation

char AppName[256] = "Genesis3D Sample Game"
 

Definition at line 65 of file Genvs.c.

Referenced by CreateMainWindow(), GameMgr_Create(), geEngine_CreateWithVersion(), Sys_EngineCreate(), and WinMain().

int ChangeDisplaySelection
 

Definition at line 71 of file Genvs.c.

Referenced by GMenu_Key(), WinMain(), and WndProc().

geBoolean ChangingDisplayMode = GE_FALSE
 

Definition at line 70 of file Genvs.c.

Referenced by GMenu_Key(), WinMain(), and WndProc().

Console_Console* Console = NULL [static]
 

Definition at line 80 of file Genvs.c.

Referenced by ShutdownAll(), WinMain(), and WndProc().

ModeList* DriverModeList
 

Definition at line 91 of file Genvs.c.

Referenced by WinMain(), and WndProc().

int DriverModeListLength
 

Definition at line 92 of file Genvs.c.

Referenced by WinMain().

geFloat EffectScale
 

Definition at line 69 of file Genvs.c.

geEngine* Engine = NULL
 

Definition at line 77 of file Genvs.c.

Referenced by AutoSelect_PickDriver(), BuildLightLUTS(), Client_Create(), Console_Create(), Corona_Init(), DoSplashScreen(), Electric_Init(), Engine_CreateTHandle(), Engine_DestroyTHandle(), Engine_DrawFontBuffer(), Engine_InitDriver(), Engine_SetupPixelFormats(), Engine_Tick(), GameMgr_BeginFrame(), GameMgr_ClearBackground(), GameMgr_ConsolePrintf(), GameMgr_EndFrame(), geActor_Render(), geActor_RenderThroughFrustum(), geEngine_Activate(), geEngine_AddBitmap(), geEngine_AddWorld(), geEngine_AttachAll(), geEngine_AttachAllWorlds(), geEngine_BeginFrame(), geEngine_BitmapListInit(), geEngine_BitmapListShutdown(), geEngine_CreateWorldLightmapTHandles(), geEngine_DestroyWorldLightmapTHandles(), geEngine_DetachAll(), geEngine_DetachAllWorlds(), geEngine_DrawAlphaBitmap(), geEngine_DrawBitmap(), geEngine_EnableFrameRateCounter(), geEngine_EndFrame(), geEngine_FillRect(), geEngine_Free(), geEngine_GetDriverSystem(), geEngine_GetGamma(), geEngine_HasWorld(), geEngine_InitFonts(), geEngine_Prep(), geEngine_Printf(), geEngine_Puts(), geEngine_RebuildFastWorldList(), geEngine_RemoveAllWorlds(), geEngine_RemoveBitmap(), geEngine_RemoveWorld(), geEngine_RenderPoly(), geEngine_RenderPolyArray(), geEngine_RenderWorld(), geEngine_ResetDriver(), geEngine_ScreenShot(), geEngine_SetAllWorldChangedFlag(), geEngine_SetDriverAndMode(), geEngine_SetFogEnable(), geEngine_SetGamma(), geEngine_ShutdownDriver(), geEngine_ShutdownFonts(), geEngine_UpdateFogEnable(), geEngine_UpdateGamma(), geEngine_UpdateWindow(), geFont_Create(), gePuppet_DrawShadow(), gePuppet_Render(), gePuppet_RenderThroughFrustum(), geSprite_RenderThroughFrustum(), geTClip_SetupEdges(), GMenu_BuildDisplayModeMenus(), GMenu_Create(), GMenu_Key(), Host_Create(), Light_EngineInit(), Light_SetEngine(), Menu_Create(), ModeList_Create(), PickMode(), Plane_SetEngine(), RenderScene(), RenderWorld(), Server_Frame(), ShutdownAll(), Surf_SetEngine(), Sys_EngineFree(), Text_Create(), Text_Destroy(), Text_Out(), User_EngineFillRect(), User_EngineInit(), User_EngineShutdown(), User_SetCameraInfo(), Vis_VisWorld(), VisFog(), WinMain(), WndProc(), World_SetEngine(), and World_WorldRenderQ().

geBoolean ErrorHandled = GE_FALSE [static]
 

Definition at line 1260 of file Genvs.c.

Referenced by GenVS_Error().

BOOL GameRunning = FALSE
 

Definition at line 63 of file Genvs.c.

Referenced by WinMain(), and WndProc().

uint32 GlobalButtonBits
 

Definition at line 879 of file Genvs.c.

uint32 GlobalMouseFlags
 

Definition at line 183 of file Genvs.c.

Referenced by WndProc().

float GlobalMouseSpeedX
 

Definition at line 181 of file Genvs.c.

Referenced by Client_SendMove(), and GetMouseInput().

float GlobalMouseSpeedY
 

Definition at line 182 of file Genvs.c.

Referenced by Client_SendMove(), and GetMouseInput().

GameMgr* GMgr = NULL [static]
 

Definition at line 74 of file Genvs.c.

Referenced by PickMode(), ShutdownAll(), WinMain(), and WndProc().

Host_Host* Host = NULL [static]
 

Definition at line 81 of file Genvs.c.

Referenced by ShutdownAll(), WinMain(), and WndProc().

Host_Init HostInit
 

Definition at line 203 of file Genvs.c.

Referenced by GMenu_Create(), WinMain(), and WndProc().

char IPAddress[MENU_MAXSTRINGSIZE] [static]
 

Definition at line 86 of file Genvs.c.

Referenced by WinMain().

geVFile* MainFS
 

Definition at line 206 of file Genvs.c.

float MainTime
 

Definition at line 88 of file Genvs.c.

Referenced by WinMain().

geBoolean MenusCreated [static]
 

Definition at line 90 of file Genvs.c.

Referenced by ShutdownAll(), and WinMain().

geBoolean Mute
 

Definition at line 204 of file Genvs.c.

Referenced by WinMain().

char PlayerName[MENU_MAXSTRINGSIZE] [static]
 

Definition at line 85 of file Genvs.c.

Referenced by WinMain().

geBoolean PopupD3DLog = GE_FALSE
 

Definition at line 61 of file Genvs.c.

Referenced by GenVS_Error(), and PickMode().

BOOL ResetMouse = TRUE
 

Definition at line 64 of file Genvs.c.

Referenced by GetMouseInput(), and WndProc().

BOOL Running = TRUE
 

Definition at line 62 of file Genvs.c.

Referenced by WinMain(), and WndProc().

geBoolean ShowStats
 

Definition at line 204 of file Genvs.c.

Referenced by GMenu_Create(), GMenu_Key(), Server_Frame(), and WinMain().

geSound_System* SoundSys = NULL
 

Definition at line 83 of file Genvs.c.

Referenced by GMenu_Key(), ReadServerMessages(), ShutdownAll(), and WinMain().


Generated on Tue Sep 30 12:37:38 2003 for GTestAndEngine by doxygen 1.3.2