2022-05-19 01:51:26 -07:00
|
|
|
#include "win32.h"
|
|
|
|
|
|
|
|
#include "core.h"
|
|
|
|
#include "main.h"
|
|
|
|
#include "window_manager.h"
|
|
|
|
|
2022-05-25 12:41:11 -07:00
|
|
|
#include <SDL.h>
|
2022-05-29 10:07:43 -07:00
|
|
|
#include <stdlib.h>
|
2022-05-19 01:51:26 -07:00
|
|
|
|
2022-05-29 12:08:13 -07:00
|
|
|
#ifdef _WIN32
|
2022-05-29 10:07:43 -07:00
|
|
|
#ifdef HAVE_DSOUND
|
2022-05-19 01:51:26 -07:00
|
|
|
// 0x51E430
|
|
|
|
DirectSoundCreateProc* gDirectSoundCreateProc = NULL;
|
2022-05-29 10:07:43 -07:00
|
|
|
#endif
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
// 0x51E434
|
|
|
|
HWND gProgramWindow = NULL;
|
|
|
|
|
|
|
|
// 0x51E444
|
|
|
|
bool gProgramIsActive = false;
|
|
|
|
|
|
|
|
// GNW95MUTEX
|
|
|
|
HANDLE _GNW95_mutex = NULL;
|
|
|
|
|
2022-05-29 10:07:43 -07:00
|
|
|
#ifdef HAVE_DSOUND
|
2022-05-19 01:51:26 -07:00
|
|
|
// 0x51E454
|
|
|
|
HMODULE gDSoundDLL = NULL;
|
2022-05-29 10:07:43 -07:00
|
|
|
#endif
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
// 0x4DE700
|
2022-05-25 12:41:11 -07:00
|
|
|
int main(int argc, char* argv[])
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
|
|
|
_GNW95_mutex = CreateMutexA(0, TRUE, "GNW95MUTEX");
|
|
|
|
if (GetLastError() == ERROR_SUCCESS) {
|
2022-05-25 12:41:11 -07:00
|
|
|
SDL_ShowCursor(SDL_DISABLE);
|
|
|
|
if (_LoadDirectX()) {
|
2022-05-25 13:05:51 -07:00
|
|
|
gProgramIsActive = true;
|
|
|
|
falloutMain(argc, argv);
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
CloseHandle(_GNW95_mutex);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x4DE8D0
|
|
|
|
bool _LoadDirectX()
|
|
|
|
{
|
2022-05-29 10:07:43 -07:00
|
|
|
#ifdef HAVE_DSOUND
|
2022-05-19 01:51:26 -07:00
|
|
|
gDSoundDLL = LoadLibraryA("DSOUND.DLL");
|
|
|
|
if (gDSoundDLL == NULL) {
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
gDirectSoundCreateProc = (DirectSoundCreateProc*)GetProcAddress(gDSoundDLL, "DirectSoundCreate");
|
|
|
|
if (gDirectSoundCreateProc == NULL) {
|
|
|
|
goto err;
|
|
|
|
}
|
2022-05-29 10:07:43 -07:00
|
|
|
#endif
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
atexit(_UnloadDirectX);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
err:
|
|
|
|
_UnloadDirectX();
|
2022-05-29 10:07:43 -07:00
|
|
|
|
2022-05-25 12:41:11 -07:00
|
|
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Could not load DirectX", "This program requires DirectX 3.0a or later.", NULL);
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x4DE988
|
|
|
|
void _UnloadDirectX(void)
|
|
|
|
{
|
2022-05-29 10:07:43 -07:00
|
|
|
#ifdef HAVE_DSOUND
|
2022-05-19 01:51:26 -07:00
|
|
|
if (gDSoundDLL != NULL) {
|
|
|
|
FreeLibrary(gDSoundDLL);
|
|
|
|
gDSoundDLL = NULL;
|
|
|
|
}
|
2022-05-29 10:07:43 -07:00
|
|
|
#endif
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
2022-05-29 12:08:13 -07:00
|
|
|
#else
|
|
|
|
bool gProgramIsActive = false;
|
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
SDL_ShowCursor(SDL_DISABLE);
|
|
|
|
gProgramIsActive = true;
|
|
|
|
return falloutMain(argc, argv);
|
|
|
|
}
|
|
|
|
#endif
|