diff --git a/src/autorun.cc b/src/autorun.cc index c5229f2..1384296 100644 --- a/src/autorun.cc +++ b/src/autorun.cc @@ -1,16 +1,20 @@ #include "autorun.h" +#ifdef _WIN32 // 0x530010 HANDLE gInterplayGenericAutorunMutex; +#endif // 0x4139C0 bool autorunMutexCreate() { +#ifdef _WIN32 gInterplayGenericAutorunMutex = CreateMutexA(NULL, FALSE, "InterplayGenericAutorunMutex"); if (GetLastError() == ERROR_ALREADY_EXISTS) { CloseHandle(gInterplayGenericAutorunMutex); return false; } +#endif return true; } @@ -18,7 +22,9 @@ bool autorunMutexCreate() // 0x413A00 void autorunMutexClose() { +#ifdef _WIN32 if (gInterplayGenericAutorunMutex != NULL) { CloseHandle(gInterplayGenericAutorunMutex); } +#endif } diff --git a/src/autorun.h b/src/autorun.h index 46ecd03..438af79 100644 --- a/src/autorun.h +++ b/src/autorun.h @@ -1,11 +1,13 @@ #ifndef AUTORUN_H #define AUTORUN_H +#ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #define NOMINMAX #include extern HANDLE gInterplayGenericAutorunMutex; +#endif bool autorunMutexCreate(); void autorunMutexClose(); diff --git a/src/debug.cc b/src/debug.cc index bb0ba39..b448310 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -8,8 +8,10 @@ #include #include +#ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include +#endif // 0x51DEF8 FILE* _fd = NULL; @@ -137,7 +139,11 @@ int debugPrint(const char* format, ...) #ifdef _DEBUG char string[260]; vsprintf(string, format, args); +#ifdef _WIN32 OutputDebugStringA(string); +#else + printf(string); +#endif #endif rc = -1; } diff --git a/src/electronic_registration.cc b/src/electronic_registration.cc index b296000..fa8c926 100644 --- a/src/electronic_registration.cc +++ b/src/electronic_registration.cc @@ -3,8 +3,10 @@ #include "game_config.h" #include "platform_compat.h" +#ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include +#endif // 0x440DD0 void runElectronicRegistration() @@ -12,6 +14,7 @@ void runElectronicRegistration() int timesRun = 0; configGetInt(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_TIMES_RUN_KEY, ×Run); if (timesRun > 0 && timesRun < 5) { +#ifdef _WIN32 char path[COMPAT_MAX_PATH]; if (GetModuleFileNameA(NULL, path, sizeof(path)) != 0) { char* pch = strrchr(path, '\\'); @@ -33,6 +36,7 @@ void runElectronicRegistration() WaitForSingleObject(processInfo.hProcess, INFINITE); } } +#endif configSetInt(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_TIMES_RUN_KEY, timesRun + 1); } else { diff --git a/src/game_sound.h b/src/game_sound.h index 0bbc598..bff2bcf 100644 --- a/src/game_sound.h +++ b/src/game_sound.h @@ -5,10 +5,6 @@ #include "platform_compat.h" #include "sound.h" -#define WIN32_LEAN_AND_MEAN -#define NOMINMAX -#include - typedef enum WeaponSoundEffect { WEAPON_SOUND_EFFECT_READY, WEAPON_SOUND_EFFECT_ATTACK, diff --git a/src/sound.cc b/src/sound.cc index 7673221..3c17c2d 100644 --- a/src/sound.cc +++ b/src/sound.cc @@ -1532,6 +1532,7 @@ int _soundSetMasterVolume(int volume) return gSoundLastError; } +#ifdef HAVE_DSOUND // 0x4AE5C8 void CALLBACK _doTimerEvent(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2) { @@ -1551,6 +1552,7 @@ void _removeTimedEvent(unsigned int* timerId) *timerId = -1; } } +#endif // 0x4AE634 int _soundGetPosition(Sound* sound) diff --git a/src/sound.h b/src/sound.h index caf1d45..34d3aee 100644 --- a/src/sound.h +++ b/src/sound.h @@ -95,7 +95,9 @@ typedef struct Sound { int field_68; int readLimit; int field_70; +#ifdef HAVE_DSOUND DWORD field_74; +#endif int field_78; int field_7C; int field_80; @@ -183,8 +185,10 @@ int soundResume(Sound* sound); int soundSetFileIO(Sound* sound, SoundOpenProc* openProc, SoundCloseProc* closeProc, SoundReadProc* readProc, SoundWriteProc* writeProc, SoundSeekProc* seekProc, SoundTellProc* tellProc, SoundFileLengthProc* fileLengthProc); void soundDeleteInternal(Sound* sound); int _soundSetMasterVolume(int value); +#ifdef HAVE_DSOUND void CALLBACK _doTimerEvent(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2); void _removeTimedEvent(unsigned int* timerId); +#endif int _soundGetPosition(Sound* sound); int _soundSetPosition(Sound* sound, int a2); void _removeFadeSound(STRUCT_51D478* a1); diff --git a/src/win32.cc b/src/win32.cc index 5e55a10..32d5da0 100644 --- a/src/win32.cc +++ b/src/win32.cc @@ -7,6 +7,7 @@ #include #include +#ifdef _WIN32 #ifdef HAVE_DSOUND // 0x51E430 DirectSoundCreateProc* gDirectSoundCreateProc = NULL; @@ -78,3 +79,13 @@ void _UnloadDirectX(void) } #endif } +#else +bool gProgramIsActive = false; + +int main(int argc, char* argv[]) +{ + SDL_ShowCursor(SDL_DISABLE); + gProgramIsActive = true; + return falloutMain(argc, argv); +} +#endif diff --git a/src/win32.h b/src/win32.h index d44564d..3d0bf6d 100644 --- a/src/win32.h +++ b/src/win32.h @@ -3,6 +3,7 @@ #include "dsound_compat.h" +#ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #define NOMINMAX #include @@ -22,5 +23,8 @@ extern HMODULE gDSoundDLL; #endif bool _LoadDirectX(); void _UnloadDirectX(void); +#else +extern bool gProgramIsActive; +#endif #endif /* WIN32_H */ diff --git a/src/window_manager.cc b/src/window_manager.cc index d4c20cf..b7e69e2 100644 --- a/src/window_manager.cc +++ b/src/window_manager.cc @@ -21,8 +21,10 @@ char _path_patches[] = ""; // 0x51E3D8 bool _GNW95_already_running = false; +#ifdef _WIN32 // 0x51E3DC HANDLE _GNW95_title_mutex = INVALID_HANDLE_VALUE; +#endif // 0x51E3E0 bool gWindowSystemInitialized = false; @@ -82,16 +84,20 @@ RadioGroup gRadioGroups[RADIO_GROUP_LIST_CAPACITY]; // 0x4D5C30 int windowManagerInit(VideoSystemInitProc* videoSystemInitProc, VideoSystemExitProc* videoSystemExitProc, int a3) { +#ifdef _WIN32 CloseHandle(_GNW95_mutex); _GNW95_mutex = INVALID_HANDLE_VALUE; +#endif if (_GNW95_already_running) { return WINDOW_MANAGER_ERR_ALREADY_RUNNING; } +#ifdef _WIN32 if (_GNW95_title_mutex == INVALID_HANDLE_VALUE) { return WINDOW_MANAGER_ERR_TITLE_NOT_SET; } +#endif if (gWindowSystemInitialized) { return WINDOW_MANAGER_ERR_WINDOW_SYSTEM_ALREADY_INITIALIZED; @@ -260,8 +266,10 @@ void windowManagerExit(void) gWindowSystemInitialized = false; +#ifdef _WIN32 CloseHandle(_GNW95_title_mutex); _GNW95_title_mutex = INVALID_HANDLE_VALUE; +#endif } _insideWinExit = false; } @@ -1232,6 +1240,7 @@ void programWindowSetTitle(const char* title) return; } +#ifdef _WIN32 if (_GNW95_title_mutex == INVALID_HANDLE_VALUE) { _GNW95_title_mutex = CreateMutexA(NULL, TRUE, title); if (GetLastError() != ERROR_SUCCESS) { @@ -1239,6 +1248,7 @@ void programWindowSetTitle(const char* title) return; } } +#endif strncpy(gProgramWindowTitle, title, 256); gProgramWindowTitle[256 - 1] = '\0'; diff --git a/src/window_manager.h b/src/window_manager.h index 0504dfd..99397f4 100644 --- a/src/window_manager.h +++ b/src/window_manager.h @@ -5,9 +5,11 @@ #include +#ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #define NOMINMAX #include +#endif #define MAX_WINDOW_COUNT (50) @@ -156,7 +158,9 @@ typedef void(VideoSystemExitProc)(); extern char _path_patches[]; extern bool _GNW95_already_running; +#ifdef _WIN32 extern HANDLE _GNW95_title_mutex; +#endif extern bool gWindowSystemInitialized; extern int _GNW_wcolor[6]; extern unsigned char* _screen_buffer;