1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054 |
- #define MAIN_CPP
- #ifdef WIN32
- #include <direct.h>
- #else
- #include <sys/time.h>
- #endif
- #include "RSPiX.h"
- #include "WishPiX/Prefs/prefs.h"
- #include "localize.h"
- #include "game.h"
- #include "main.h"
- #include "menus.h"
- #include "title.h"
- #include "input.h"
- #include "ORANGE/Debug/profile.h"
- #if PLATFORM_MACOSX
- #include "SDL.h"
- #endif
- #if WITH_STEAMWORKS
- #ifdef WIN32
- #define WIN32_LEAN_AND_MEAN 1
- #include <windows.h>
- #endif
- #include "steam/steam_api.h"
- #include "WishPiX/Menu/menu.h"
- #endif
- #define AUDIO_RETRY_TIME 5000
- int wideScreenWidth;
- static short SetupVideo(
- short sUseCurrentDeviceDimensions,
- short sDeviceWidth,
- short sDeviceHeight)
- {
- short sResult = 0;
- #ifdef MOBILE
- wideScreenWidth = 850;
- #elif defined(PANDORA)
- wideScreenWidth = 800;
- #else
-
-
- short sDepth, sWidth, sHeight;
- rspQueryVideoModeReset();
- while (!rspQueryVideoMode(&sDepth, &sWidth, &sHeight));
- TRACE("rspQueryVideoMode result: %ix%ix%i\n", sWidth, sHeight, sDepth);
-
- if (sHeight > 480 && sWidth > 640)
- wideScreenWidth = 480 * sWidth / sHeight;
- else
- wideScreenWidth = 480 * sDeviceWidth / sDeviceHeight;
- #endif
-
-
- if (sUseCurrentDeviceDimensions != FALSE)
- rspGetVideoMode(NULL, &sDeviceWidth, &sDeviceHeight);
-
- sResult = rspSetVideoMode(
- MAIN_SCREEN_DEPTH,
- sDeviceWidth,
- sDeviceHeight,
- MAIN_WINDOW_WIDTH,
- MAIN_WINDOW_HEIGHT,
- MAIN_SCREEN_PAGES,
- MAIN_SCREEN_SCALING);
- if (sResult != 0)
- {
-
- char acVideoMode[100];
- sprintf(acVideoMode, "%hd by %hd Pixels", (short)MAIN_WINDOW_WIDTH, (short)MAIN_WINDOW_HEIGHT);
- if (MAIN_SCREEN_DEPTH <= 16)
- sprintf(&(acVideoMode[strlen(acVideoMode)]), ", %hd Colors", (short)pow(2.0, (double)MAIN_SCREEN_DEPTH));
- else if (MAIN_SCREEN_DEPTH == 24)
- sprintf(&(acVideoMode[strlen(acVideoMode)]), ", True Color (24 bit)");
- else
- sprintf(&(acVideoMode[strlen(acVideoMode)]), ", True Color (32 bit)");
- if (MAIN_SCREEN_PAGES > 1)
- sprintf(&(acVideoMode[strlen(acVideoMode)]), ", %hd Pages", (short)MAIN_SCREEN_PAGES);
-
- short sCurrentDeviceDepth;
- rspGetVideoMode(&sCurrentDeviceDepth);
-
-
-
-
-
- sResult = rspSuggestVideoMode(
- MAIN_SCREEN_DEPTH,
- MAIN_WINDOW_WIDTH,
- MAIN_WINDOW_HEIGHT,
- MAIN_SCREEN_PAGES,
- MAIN_SCREEN_SCALING,
- &sDeviceWidth,
- &sDeviceHeight,
- NULL);
- if (sResult == 0)
- {
-
- sResult = rspSetVideoMode(
- MAIN_SCREEN_DEPTH,
- sDeviceWidth,
- sDeviceHeight,
- MAIN_WINDOW_WIDTH,
- MAIN_WINDOW_HEIGHT,
- MAIN_SCREEN_PAGES,
- MAIN_SCREEN_SCALING);
- if (sResult != 0)
- {
-
-
- if (sCurrentDeviceDepth != MAIN_SCREEN_DEPTH)
- {
- rspMsgBox(RSP_MB_ICN_STOP | RSP_MB_BUT_OK,
- g_pszCriticalErrorTitle,
- g_pszVideoChangeDepthError,
- acVideoMode);
- TRACE("SetupVideo(): Error returned by rspSetVideoMode() -- most likely due to attempted change in depth!\n");
- }
- else
- {
- TRACE("SetupVideo(): Error returned by rspSetVideoMode()!\n");
- rspMsgBox(RSP_MB_ICN_STOP | RSP_MB_BUT_OK,
- g_pszCriticalErrorTitle,
- g_pszVideoModeError,
- acVideoMode);
- }
- }
- }
- else
- {
-
-
-
-
-
- rspQueryVideoModeReset();
- short sDeviceDepth;
- short sDevicePages;
- do {
- sResult = rspQueryVideoMode(
- &sDeviceDepth,
- &sDeviceWidth,
- &sDeviceHeight,
- &sDevicePages);
- } while ((sResult == 0) && (sDeviceDepth < MAIN_SCREEN_DEPTH));
- if ((sResult == 0) && (sDeviceDepth == MAIN_SCREEN_DEPTH))
- {
-
-
- while ( (sResult == 0) &&
- (sDeviceDepth == MAIN_SCREEN_DEPTH) &&
- ((sDeviceWidth < MAIN_WINDOW_WIDTH) || (sDeviceHeight < MAIN_WINDOW_HEIGHT)) )
- {
- sResult = rspQueryVideoMode(
- &sDeviceDepth,
- &sDeviceWidth,
- &sDeviceHeight,
- &sDevicePages);
- }
- if ( (sResult == 0) &&
- (sDeviceDepth == MAIN_SCREEN_DEPTH) &&
- (sDeviceWidth >= MAIN_WINDOW_WIDTH) &&
- (sDeviceHeight >= MAIN_WINDOW_HEIGHT) )
- {
-
-
-
-
- ASSERT(MAIN_SCREEN_SCALING == 0);
- sResult = -1;
- TRACE("SetupVideo(): No video modes available at %dx%d, %d-bit, with %d pages!\n",
- MAIN_WINDOW_WIDTH , MAIN_WINDOW_HEIGHT, MAIN_SCREEN_DEPTH, MAIN_SCREEN_PAGES);
- rspMsgBox(
- RSP_MB_ICN_STOP | RSP_MB_BUT_OK,
- g_pszCriticalErrorTitle,
- g_pszVideoPagesError,
- acVideoMode);
- }
- else
- {
- sResult = -1;
- TRACE("SetupVideo(): No %hd-bit video modes go up to %hdx%hd resolution!\n",
- (short)MAIN_SCREEN_DEPTH, (short)MAIN_WINDOW_WIDTH, (short)MAIN_WINDOW_HEIGHT);
- rspMsgBox(
- RSP_MB_ICN_STOP | RSP_MB_BUT_OK,
- g_pszCriticalErrorTitle,
- g_pszVideoResolutionError,
- acVideoMode);
- }
- }
- else
- {
- sResult = -1;
- TRACE("SetupVideo(): No %hd-bit video modes are available!\n",
- (short)MAIN_SCREEN_DEPTH);
- rspMsgBox(
- RSP_MB_ICN_STOP | RSP_MB_BUT_OK,
- g_pszCriticalErrorTitle,
- g_pszVideoDepthError,
- acVideoMode);
- }
- }
- }
- return sResult;
- }
- static char* CreateChunk(
-
-
- long lChunkSize)
- {
- char* pcOrig = (char*)malloc(lChunkSize);
- char* pcReAlloc = (char*)realloc(pcOrig, 1024);
- ASSERT(pcOrig == pcReAlloc);
- if (pcReAlloc)
- {
- return pcReAlloc;
- }
- else
- {
- return pcOrig;
- }
- }
- static void assert_types_are_sane(void)
- {
- ASSERT(sizeof (S8) == 1);
- ASSERT(sizeof (U8) == 1);
- ASSERT(sizeof (S16) == 2);
- ASSERT(sizeof (U16) == 2);
- ASSERT(sizeof (S32) == 4);
- ASSERT(sizeof (U32) == 4);
- ASSERT(sizeof (S64) == 8);
- ASSERT(sizeof (U64) == 8);
- U32 val = 0x02000001;
- #if SYS_ENDIAN_BIG
- ASSERT(*((U8*) &val) == 0x02);
- #else
- ASSERT(*((U8*) &val) == 0x01);
- #endif
- }
- int _argc = 0;
- char **_argv = NULL;
- long playthroughMS = 0;
- #if WITH_STEAMWORKS
- bool WaitingForInitialSteamStats = true;
- bool EnableSteamAchievements = true;
- bool EnableSteamCloud = true;
- bool StoreSteamStatsPending = false;
- bool EarnedSteamAchievements[ACHIEVEMENT_MAX];
- uint32 SteamAppID = 0;
- static const char *GetAchievementName(const Achievement ach)
- {
- switch (ach)
- {
- #define ACH_CASE(name) case ACHIEVEMENT_##name: return #name
- ACH_CASE(KILL_FIRST_VICTIM);
- ACH_CASE(START_SECOND_LEVEL);
- ACH_CASE(DUCK_UNDER_ROCKET);
- ACH_CASE(RUN_5_MINUTES);
- ACH_CASE(PERFORM_FIRST_EXECUTION);
- ACH_CASE(KILL_100);
- ACH_CASE(KILL_1000);
- ACH_CASE(KILL_10000);
- ACH_CASE(COMPLETE_LEVEL_10);
- ACH_CASE(COMPLETE_GAME);
- ACH_CASE(FIRE_1000000_BULLETS);
- ACH_CASE(HIT_100000_TARGETS);
- ACH_CASE(TAKE_10000_HITS);
- ACH_CASE(KILL_EVERYTHING);
- ACH_CASE(KILL_ONLY_HOSTILES);
- ACH_CASE(USE_ONLY_M16);
- ACH_CASE(USE_EVERY_WEAPON);
- ACH_CASE(COMPLETE_LEVEL_ON_LOW_HEALTH);
- ACH_CASE(FIGHT_AN_OSTRICH);
- ACH_CASE(WATCH_ALL_CREDITS);
- ACH_CASE(PLAY_ON_NON_WINDOWS_PLATFORM);
- ACH_CASE(FIREBOMB_THE_BAND);
- ACH_CASE(ROCKET_TO_THE_FACE);
- ACH_CASE(KILL_A_NAKED_PERSON);
- ACH_CASE(ENABLE_CHEATS);
- ACH_CASE(COMMIT_SUICIDE);
- ACH_CASE(TOUCH_SOMEONE_WHILE_BURNING);
- ACH_CASE(COMPLETE_GAME_IN_X_MINUTES);
- ACH_CASE(COMPLETE_GAME_ON_HARDEST);
- #undef ACH_CASE
- case ACHIEVEMENT_MAX: break;
- }
- return NULL;
- }
- class SteamworksEvents
- {
- public:
- SteamworksEvents()
- : m_CallbackUserStatsReceived(this, &SteamworksEvents::OnUserStatsReceived)
- {}
- STEAM_CALLBACK(SteamworksEvents, OnUserStatsReceived, UserStatsReceived_t , m_CallbackUserStatsReceived)
- {
-
- if (pParam->m_nGameID != SteamAppID)
- return;
- else if (pParam->m_eResult != k_EResultOK)
- return;
-
-
- int32 val;
- ISteamUserStats *stats = SteamUserStats();
- #define UPDATESTAT(st) { \
- stats->GetStat(#st, &val); \
- \
- Stat_##st += (int) val; \
- if (Stat_##st < 0) Stat_##st = 0x7FFFFFFF; \
- }
- UPDATESTAT(BulletsFired);
- UPDATESTAT(BulletsHit);
- UPDATESTAT(BulletsMissed);
- UPDATESTAT(Deaths);
- UPDATESTAT(Suicides);
- UPDATESTAT(Executions);
- UPDATESTAT(HitsTaken);
- UPDATESTAT(DamageTaken);
- UPDATESTAT(Burns);
- UPDATESTAT(TimeRunning);
- UPDATESTAT(KilledHostiles);
- UPDATESTAT(KilledCivilians);
- UPDATESTAT(TotalKilled);
- UPDATESTAT(LevelsPlayed);
- #undef UPDATESTAT
- for (int i = 0; i < ACHIEVEMENT_MAX; i++)
- {
- const char *name = GetAchievementName((Achievement) i);
- if (!name) break; // just in case.
- bool unlocked = false;
- if (!stats->GetAchievement(name, &unlocked))
- unlocked = false;
-
- EarnedSteamAchievements[i] = unlocked;
- }
- WaitingForInitialSteamStats = false;
- }
- };
- static bool touchFile(const char *fname, const int64 stamp)
- {
- #ifdef WIN32
- HANDLE hFile = CreateFileA(fname, GENERIC_READ | FILE_WRITE_ATTRIBUTES,
- FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
- if (hFile == INVALID_HANDLE_VALUE)
- return false;
- ULARGE_INTEGER val;
- val.QuadPart = (ULONGLONG) stamp;
- val.QuadPart += 11644473600LL;
- val.QuadPart *= 10000000LL;
- FILETIME ft;
- ft.dwLowDateTime = val.LowPart;
- ft.dwHighDateTime = val.HighPart;
- const BOOL rc = SetFileTime(hFile, NULL, NULL, &ft);
- CloseHandle(hFile);
- return (rc != 0);
- #else
- timeval ft[2];
- ft[0].tv_sec = ft[1].tv_sec = (time_t) stamp;
- ft[0].tv_usec = ft[1].tv_usec = 0;
- return (utimes(fname, ft) == 0);
- #endif
- }
- static bool prepareSteamworks()
- {
- ISteamUtils *utils;
- if ((!SteamAPI_Init()) || ((utils = SteamUtils()) == NULL))
- {
- rspMsgBox(RSP_MB_BUT_OK | RSP_MB_ICN_STOP,
- "Error!", "%s", "Can't initialize Steamworks, aborting...");
- return false;
- }
- SteamAppID = utils->GetAppID();
- new SteamworksEvents;
- ISteamUserStats *stats = SteamUserStats();
- if ((!stats) || (rspCommandLine("nosteamachievements")))
- EnableSteamAchievements = false;
- if (EnableSteamAchievements)
- {
- bool nukeAchievements = rspCommandLine("nukesteamachievements") != 0;
- if (nukeAchievements)
- {
- if (rspMsgBox(RSP_MB_BUT_OKCANCEL | RSP_MB_ICN_QUERY, "Whoa!", "%s", "Really nuke your Steam Achievements? This can't be undone!") != RSP_MB_RET_OK)
- nukeAchievements = false;
- }
- if (nukeAchievements)
- {
- stats->ResetAllStats(true);
- stats->StoreStats();
- }
- stats->RequestCurrentStats();
- }
- ISteamRemoteStorage *cloud = SteamRemoteStorage();
- if ((!cloud) || (rspCommandLine("nosteamcloud")))
- EnableSteamCloud = false;
- if (EnableSteamCloud)
- {
- bool nukeCloud = rspCommandLine("nukesteamcloud") != 0;
- if (nukeCloud)
- {
- if (rspMsgBox(RSP_MB_BUT_OKCANCEL | RSP_MB_ICN_QUERY, "Whoa!", "%s", "Really nuke the Steam Cloud? This can't be undone!") != RSP_MB_RET_OK)
- nukeCloud = false;
- }
- if (nukeCloud)
- {
- const int Max = cloud->GetFileCount();
- for (int i = 0; i < Max; i++)
- {
- int32 fsize = 0;
- const char *fname = cloud->GetFileNameAndSize(i, &fsize);
- if (fname)
- cloud->FileDelete(fname);
- }
- }
-
- if (cloud->GetFileCount() == 0)
- {
- const int Max = MAX_SAVE_SLOTS;
- for (int i = 0; i < Max; i++)
- {
- char fname[64];
- snprintf(fname, sizeof (fname), "savegame/%d.gme", i);
- FILE *io = fopen(FindCorrectFile(fname, "rb"), "rb");
- if (io != NULL)
- {
- char buf[1024];
- const size_t br = fread(buf, 1, sizeof (buf), io);
- fclose(io);
- if (br > 0)
- {
- snprintf(fname, sizeof (fname), "savegame_%d.gme", i);
- cloud->FileWrite(fname, buf, (int32) br);
- }
- }
- }
- }
-
- const int Max = MAX_SAVE_SLOTS;
- for (int i = 0; i < Max; i++)
- {
- char src[64];
- snprintf(src, sizeof (src), "savegame_%d.gme", i);
- char dst[64];
- snprintf(dst, sizeof (dst), "steamcloud/%d.gme", i);
- remove(FindCorrectFile(dst, "wb"));
- if (!cloud->FileExists(src))
- continue;
- char buf[1024];
- const int32 br = cloud->FileRead(src, buf, (int32) sizeof (buf));
- if (br <= 0)
- continue;
- FILE *io = fopen(FindCorrectFile(dst, "wb"), "wb");
- if (!io)
- continue;
- const size_t bw = fwrite(buf, (size_t) br, 1, io);
- fclose(io);
- if (bw != 1)
- remove(FindCorrectFile(dst, "wb"));
- else
- {
- const int64 stamp = cloud->GetFileTimestamp(src);
- if (stamp > 0)
- touchFile(FindCorrectFile(dst, "wb"), stamp);
- }
- }
- }
- return true;
- }
- void RequestSteamStatsStore()
- {
- if (EnableSteamAchievements)
- StoreSteamStatsPending = true;
- }
- void UnlockAchievement(const Achievement ach)
- {
-
-
- if (Flag_Achievements & FLAG_USED_CHEATS)
- return;
- else if (EarnedSteamAchievements[ach])
- return;
- else if (!EnableSteamAchievements)
- return;
- else if (GetInputMode() == INPUT_MODE_PLAYBACK)
- return;
- const char *achstr = GetAchievementName(ach);
- if (!achstr)
- return;
- ISteamUserStats *stats = SteamUserStats();
- if (!stats)
- return;
-
- EarnedSteamAchievements[ach] = true;
- stats->SetAchievement(achstr);
- RequestSteamStatsStore();
- }
- void RunSteamworksUpkeep()
- {
- SteamAPI_RunCallbacks();
- if ((StoreSteamStatsPending) && (!WaitingForInitialSteamStats))
- {
- ISteamUserStats *stats = SteamUserStats();
- if (stats)
- {
-
-
- #define SETSTAT(st) { \
- \
- stats->SetStat(#st, Stat_##st); \
- }
- SETSTAT(BulletsFired);
- SETSTAT(BulletsHit);
- SETSTAT(BulletsMissed);
- SETSTAT(Deaths);
- SETSTAT(Suicides);
- SETSTAT(Executions);
- SETSTAT(HitsTaken);
- SETSTAT(DamageTaken);
- SETSTAT(Burns);
- SETSTAT(TimeRunning);
- SETSTAT(KilledHostiles);
- SETSTAT(KilledCivilians);
- SETSTAT(TotalKilled);
- SETSTAT(LevelsPlayed);
- #undef SETSTAT
- if (stats->StoreStats())
- StoreSteamStatsPending = false;
- }
- }
- }
- #endif
- int main(int argc, char **argv)
- {
- short sResult = 0;
- _argc = argc;
- _argv = argv;
- assert_types_are_sane();
- rspPlatformInit();
- #if WITH_STEAMWORKS
- if (!prepareSteamworks())
- return 1;
- #endif
-
-
-
-
-
-
-
-
-
- RPrefs prefs;
- if (prefs.Open(g_pszPrefFileName, "rt") == 0)
- {
-
- short sDeviceWidth;
- short sDeviceHeight;
- short sUseCurrentDeviceDimensions;
- prefs.GetVal("Video", "DeviceWidth", MAIN_SCREEN_MIN_WIDTH, &sDeviceWidth);
- prefs.GetVal("Video", "DeviceHeight", MAIN_SCREEN_MIN_HEIGHT, &sDeviceHeight);
- prefs.GetVal("Video", "UseCurrentDeviceDimensions", 1, &sUseCurrentDeviceDimensions);
-
- short sAudioSamplesPerSec;
- short sDeviceBitsPerSample;
- short sBufTime;
- short sMixBitsPerSample;
- prefs.GetVal("Audio", "DeviceRate", MAIN_AUDIO_RATE, &sAudioSamplesPerSec);
- prefs.GetVal("Audio", "DeviceBits", MAIN_AUDIO_BITS, &sDeviceBitsPerSample);
- prefs.GetVal("Audio", "DeviceBufTime", MAIN_AUDIO_BUFTIME, &sBufTime);
- prefs.GetVal("Audio", "MixBits", 16, &sMixBitsPerSample);
-
- prefs.Close();
-
- if (prefs.IsError() == 0)
- {
-
-
-
- if (rspInitBlue() == 0)
- {
- rspProfileOn();
- rspSetProfileOutput("profile.out");
-
-
-
-
- rspSetApplicationName(g_pszAppName);
- #if defined(_DEBUG)
-
- rspSetDoSystemMode(RSP_DOSYSTEM_SLEEP);
- #else
-
- rspSetDoSystemMode(RSP_DOSYSTEM_HOGCPU);
- #endif
-
-
-
- sResult = SetupVideo(
- sUseCurrentDeviceDimensions,
- sDeviceWidth,
- sDeviceHeight);
- if (sResult == 0)
- {
-
- rspSetWin32StaticColors(1);
-
-
-
-
-
-
- bool bSwitchedToVanillaSettings = false;
-
-
-
-
-
-
-
- bool bRetry = true;
- while (bRetry)
- {
-
- long lTime = rspGetMilliseconds();
- bool bDone = false;
- do {
-
- sResult = RMix::SetMode(
- sAudioSamplesPerSec,
- sDeviceBitsPerSample,
- MAIN_AUDIO_CHANNELS,
- sBufTime,
- MAIN_AUDIO_MAXBUFTIME,
- sMixBitsPerSample,
- sMixBitsPerSample);
- switch (sResult)
- {
- case 0:
-
- bDone = true;
- break;
- case BLU_ERR_DEVICE_IN_USE:
-
- if ((rspGetMilliseconds() - lTime) < AUDIO_RETRY_TIME)
- {
-
- }
- else
- {
-
- bDone = true;
- }
- break;
- case BLU_ERR_NO_DEVICE:
-
-
-
- bDone = true;
- break;
- case BLU_ERR_NOT_SUPPORTED:
-
-
- bDone = true;
- break;
- }
- } while (bDone == false);
-
- if (sResult == 0)
- {
- bRetry = false;
- }
- else
- {
- TRACE("main(): Audio didn't work, using msgbox to find out what to do...\n");
- char buf[100];
- sprintf(buf, "%.3f kHz, %hd Bit, %s",
- (float)sAudioSamplesPerSec/(float)1000,
- (short)sDeviceBitsPerSample,
- (MAIN_AUDIO_CHANNELS == 1) ? "Mono" : "Stereo");
-
-
- char* pszMsg;
- USHORT usFlags;
-
- switch (sResult)
- {
- case BLU_ERR_DEVICE_IN_USE:
- pszMsg = g_pszAudioModeInUseError_s;
- usFlags = RSP_MB_ICN_QUERY | RSP_MB_BUT_ABORTRETRYIGNORE;
- break;
- case BLU_ERR_NO_DEVICE:
- pszMsg = g_pszAudioModeNoDeviceError_s;
- usFlags = RSP_MB_ICN_QUERY | RSP_MB_BUT_YESNO;
- break;
- case BLU_ERR_NOT_SUPPORTED:
-
- if (bSwitchedToVanillaSettings == false)
- {
- pszMsg = g_pszAudioModeNotSupportedError_s;
- usFlags = RSP_MB_ICN_QUERY | RSP_MB_BUT_ABORTRETRYIGNORE;
-
- sAudioSamplesPerSec = MAIN_VANILLA_AUDIO_RATE;
- sDeviceBitsPerSample = MAIN_VANILLA_AUDIO_BITS;
-
-
-
-
-
-
- bSwitchedToVanillaSettings = true;
- }
- else
- {
- pszMsg = g_pszAudioVanillaModeNotSupportedError_s;
- usFlags = RSP_MB_ICN_QUERY | RSP_MB_BUT_YESNO;
- }
- break;
- default:
- pszMsg = g_pszAudioModeGeneralError_s;
- usFlags = RSP_MB_ICN_QUERY | RSP_MB_BUT_ABORTRETRYIGNORE;
- break;
- }
- short sButton = rspMsgBox(
- usFlags,
- g_pszCriticalErrorTitle,
- pszMsg,
- buf);
- switch (sButton)
- {
- case RSP_MB_RET_NO:
- case RSP_MB_RET_ABORT:
-
-
- bRetry = false;
- break;
- case RSP_MB_RET_RETRY:
-
- sResult = 0;
- break;
- case RSP_MB_RET_YES:
- case RSP_MB_RET_IGNORE:
-
- sResult = 0;
- bRetry = false;
- break;
- }
- }
- }
- if (sResult == 0)
- {
-
-
-
-
- rspHideMouseCursor();
-
- TheGame();
-
- rspShowMouseCursor();
-
-
- RMix::KillMode();
- }
-
- rspKillVideoMode();
- }
- rspProfileOff();
-
- rspKillBlue();
- }
- else
- {
-
- TRACE("main(): Error returned by rspInitBlue()!\n");
- rspMsgBox(RSP_MB_ICN_STOP | RSP_MB_BUT_OK, g_pszCriticalErrorTitle, g_pszBadBlueInit);
- }
- }
- else
- {
-
- TRACE("main(): Error reading prefs file!\n");
- rspMsgBox(RSP_MB_ICN_STOP | RSP_MB_BUT_OK, g_pszCriticalErrorTitle, g_pszPrefReadError);
- }
- }
- else
- {
-
- TRACE("main(): Couldn't open prefs file: %s !\n", g_pszPrefFileName);
- rspMsgBox(RSP_MB_ICN_STOP | RSP_MB_BUT_OK, g_pszCriticalErrorTitle, g_pszPrefOpenError);
- }
- return 0;
- }
|