/* main.cpp - Don Yang (uguu.org) 12/21/00 */ #include"global.h" #include"bg.h" #include"dd.h" #include"game.h" #include"gfx.h" #include"input.h" #include"main.h" #include"sound.h" #include"sprite.h" #include"term.h" #include"windoze.h" static BOOL StartUp(HINSTANCE inst, int state); /***************************************************************** WinMain */ int WINAPI WinMain(HINSTANCE cinst, HINSTANCE pinst, LPSTR argv, int state) { MSG msg; // Initialize if( !StartUp(cinst, state) ) { Shutdown(); return 0; } // Start terminal mode if( strstr(argv, "term") != NULL ) GameState = TERMINAL_STATE; // Message loop do { if( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) ) { TranslateMessage(&msg); DispatchMessage(&msg); } else { if( AppActive ) { UpdateState(); // (game.cpp) if( !Animate() ) // (gfx.cpp) DestroyWindow(AppWindow); } } } while( msg.message != WM_QUIT ); Shutdown(); return msg.wParam; } // WinMain() /********************************************************************* Croak Display and log general error message. */ BOOL Croak(char *message) { ShowCursor(TRUE); LogMessage(message); MessageBox(AppWindow, message, "Error", MB_OK | MB_ICONSTOP); return FALSE; } // Croak() /****************************************************************** Shutdown Clean up. */ void Shutdown(void) { UninitGame(); // (game.cpp) UninitSprites(); // (sprite.cpp) UninitSound(); // (sound.cpp) UninitInput(); // (input.cpp) UninitDD(); // (dd.cpp) ReleaseBackground(); // (bg.cpp) StopLog(); // (log.cpp) } // Shutdown() /******************************************************************* StartUp Initialize. */ static BOOL StartUp(HINSTANCE inst, int state) { srand((unsigned)time(NULL)); if( !InitGame() ) // (game.cpp) ResetOptions(); // (game.cpp) if( !StartLog() ) return FALSE; // (log.cpp) if( !InitInstance(inst, state) ) return FALSE; // (windoze.cpp) if( !InitDD() ) return FALSE; // (dd.cpp) if( !InitInput() ) return FALSE; // (input.cpp) if( !InitSprites() ) return FALSE; // (sprite.cpp) if( !InitSound() ) return FALSE; // (sound.cpp) InitTerm(); // (term.cpp) MouseX = ScreenWidth / 2; MouseY = ScreenHeight / 2; return TRUE; } // StartUp() char *MainObjTime = __TIME__ " " __DATE__; int MainObjLines = __LINE__;