diff --git a/source/build/src/sdlayer.cpp b/source/build/src/sdlayer.cpp index eb065a378..85fa9c0f0 100644 --- a/source/build/src/sdlayer.cpp +++ b/source/build/src/sdlayer.cpp @@ -1559,7 +1559,7 @@ int32_t videoUpdatePalette(int32_t start, int32_t num) #ifdef USE_OPENGL if (!nogl) - glsurface_setPalette(curpalettefaded); + glsurface_setPalette(curpalette); else #endif { diff --git a/source/common/gamecontrol.cpp b/source/common/gamecontrol.cpp index 56e5d5ec9..4aa39351f 100644 --- a/source/common/gamecontrol.cpp +++ b/source/common/gamecontrol.cpp @@ -200,6 +200,10 @@ namespace ShadowWarrior { ::GameInterface* CreateInterface(); } +namespace Powerslave +{ + ::GameInterface* CreateInterface(); +} void CheckFrontend(int flags) { @@ -215,6 +219,10 @@ void CheckFrontend(int flags) { gi = ShadowWarrior::CreateInterface(); } + else if (flags & GAMEFLAG_PSEXHUMED) + { + gi = Powerslave::CreateInterface(); + } else { gi = Duke::CreateInterface(); diff --git a/source/common/searchpaths.cpp b/source/common/searchpaths.cpp index 0c1ba45b3..a617f9bc8 100644 --- a/source/common/searchpaths.cpp +++ b/source/common/searchpaths.cpp @@ -662,6 +662,8 @@ static TArray ParseGrpInfo(const char *fn, FileReader &fr, TMap #include +#include "z_music.h" BEGIN_PS_NS @@ -57,61 +58,14 @@ bool playCDtrack(int nTrack, bool bLoop) char filename[128]; - // prefer flac if available - sprintf(filename, "exhumed%02d.flac", nTrack); - int32_t hFile = kopen4load(filename, 0); - if (hFile < 0) - { - // try ogg vorbis now - sprintf(filename, "exhumed%02d.ogg", nTrack); - hFile = kopen4load(filename, 0); - if (hFile < 0) { - return false; - } - } - - int32_t nFileLen = kfilelength(hFile); - - pTrack = (char*)Xaligned_alloc(16, nFileLen); - if (pTrack == NULL) - { - OSD_Printf("Error allocating music track data memory for %s", filename); - kclose(hFile); - return false; - } - - int nRead = kread(hFile, pTrack, nFileLen); - if (nRead != nFileLen) - { - OSD_Printf("Error reading music track data for %s", filename); - Xaligned_free(pTrack); - pTrack = NULL; - kclose(hFile); - return false; - } - - kclose(hFile); - - trackhandle = FX_Play(pTrack, nRead, bLoop ? 0 : -1, 0, 0, gMusicVolume, gMusicVolume, gMusicVolume, FX_MUSIC_PRIORITY, fix16_one, MUSIC_ID); - if (trackhandle <= FX_Ok) - { - OSD_Printf("Error playing music track %s", filename); - if (pTrack) - { - Xaligned_free(pTrack); - pTrack = NULL; - } - return false; - } - + // try ogg vorbis now + sprintf(filename, "exhumed%02d.ogg", nTrack); + trackhandle = Mus_Play(nullptr, filename, true); return true; } void StartfadeCDaudio() { - if (CDplaying()) { - nLastVolumeSet = gMusicVolume; - } } int StepFadeCDaudio() @@ -119,23 +73,8 @@ int StepFadeCDaudio() if (!CDplaying()) { return 0; } - - if (nLastVolumeSet <= 0) { - return 0; - } - - nLastVolumeSet -= 8; - - if (nLastVolumeSet <= 0) { - nLastVolumeSet = 0; - } - - setCDaudiovolume(nLastVolumeSet); - - if (nLastVolumeSet == 0) { - StopCD(); - } - + Mus_Stop(); + trackhandle = 0; return 1; } @@ -145,22 +84,13 @@ bool CDplaying() return false; } else { - return FX_SoundActive(trackhandle); + return true; } } void StopCD() { - if (trackhandle > 0) { - FX_StopSound(trackhandle); - trackhandle = -1; - } - - if (pTrack) - { - Xaligned_free(pTrack); - pTrack = NULL; - } + Mus_Stop(); } END_PS_NS diff --git a/source/exhumed/src/exhumed.cpp b/source/exhumed/src/exhumed.cpp index adde52cfc..8026271c3 100644 --- a/source/exhumed/src/exhumed.cpp +++ b/source/exhumed/src/exhumed.cpp @@ -75,18 +75,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include #include #include +#include "gamecvars.h" BEGIN_PS_NS -#ifdef __cplusplus -extern "C" { -#endif extern const char* s_buildRev; extern const char* s_buildTimestamp; -#ifdef __cplusplus -} -#endif const char* AppProperName = APPNAME; const char* AppTechnicalName = APPBASENAME; @@ -817,6 +812,7 @@ void ShutDown(void) void I_Error(const char *fmt, ...) { + char buf[256]; #ifdef __WATCOMC__ @@ -832,19 +828,7 @@ void I_Error(const char *fmt, ...) va_end(args); - initprintf(buf); - - if (*buf != 0) - { - if (!(buf[0] == ' ' && buf[1] == 0)) - { - char titlebuf[256]; - Bsprintf(titlebuf,APPNAME " %s",s_buildRev); - wm_msgbox(titlebuf, "%s", buf); - } - } - - exit(0); + throw std::runtime_error(buf); } void faketimerhandler() @@ -1729,7 +1713,6 @@ static int32_t check_filename_casing(void) #endif int32_t r_maxfpsoffset = 0; -double g_frameDelay = 0.0; static int32_t nonsharedtimer; @@ -1885,12 +1868,10 @@ void CheckCommandLine(int argc, char const* const* argv, int &doTitle) } } -int app_main(int argc, char const* const* argv) +int GameInterface::app_main() { char tempbuf[256]; - initprintf("Exhumed %s\n", s_buildRev); - int i; @@ -1953,7 +1934,6 @@ int app_main(int argc, char const* const* argv) initprintf("Initializing OSD...\n"); - Bsprintf(tempbuf, "Exhumed %s", s_buildRev); registerosdcommands(); //SetupInput(); @@ -2017,8 +1997,6 @@ int app_main(int argc, char const* const* argv) if (enginePostInit()) ShutDown(); - g_frameDelay = calcFrameDelay(r_maxfps + r_maxfpsoffset); - // loc_11745: // FadeOut(0); // InstallEngine(); @@ -3509,4 +3487,11 @@ int DoSpiritHead() return 0; } + +::GameInterface* CreateInterface() +{ + return new GameInterface; +} + + END_PS_NS diff --git a/source/exhumed/src/exhumed.h b/source/exhumed/src/exhumed.h index 4f3adf60d..2dd1ca62d 100644 --- a/source/exhumed/src/exhumed.h +++ b/source/exhumed/src/exhumed.h @@ -240,13 +240,9 @@ extern const char *gString[]; extern int bVanilla; -extern int32_t g_gameType; - #define POWERSLAVE (g_gameType & GAMEFLAG_POWERSLAVE) #define EXHUMED (g_gameType & GAMEFLAG_EXHUMED) -extern int32_t r_maxfps; -extern int32_t r_maxfpsoffset; extern double g_frameDelay; static inline double calcFrameDelay(int const maxFPS) { return maxFPS > 0 ? (timerGetFreqU64()/(double)maxFPS) : 0.0; } @@ -274,6 +270,17 @@ extern int loaddefinitions_game(const char* fn, int32_t preload); void G_LoadGroupsInDir(const char* dirname); void G_DoAutoload(const char* dirname); +struct GameInterface : ::GameInterface +{ + int app_main() override; + bool validate_hud(int) override { return true; } + void set_hud_layout(int size) override {} + void set_hud_scale(int size) override {} + //FString statFPS() override; + //GameStats getStats() override; +}; + + END_PS_NS #endif diff --git a/source/exhumed/src/movie.cpp b/source/exhumed/src/movie.cpp index 1546a4f07..8b37e13d3 100644 --- a/source/exhumed/src/movie.cpp +++ b/source/exhumed/src/movie.cpp @@ -117,7 +117,7 @@ int ReadFrame(FileReader &fp) { mutex_lock(&mutex); - int nRead = fread((char*)bankbuf + bankptr, 1, nSize, fp); + int nRead = fp.Read((char*)bankbuf + bankptr, nSize); lSoundBytesRead += nRead; bankptr += nSize; @@ -200,7 +200,7 @@ void PlayMovie(const char* fileName) char buffer[256]; int bDoFade = kTrue; int hFx = -1; - +#if 0 if (bNoCDCheck) { sprintf(buffer, "C:\\PS\\%s", fileName); @@ -226,7 +226,7 @@ void PlayMovie(const char* fileName) } } #else - auto fp = kopenFileReader(fileName, 0); + auto fp = fileSystem.OpenFileReader(fileSystem.FindFile(fileName)); if (!fp.isOpen()) { Printf("Unable to open %s\n", fileName); @@ -241,7 +241,6 @@ void PlayMovie(const char* fileName) fp.Read(lh, sizeof(lh)); // sound stuff - mutex_init(&mutex); bankptr = 0; banktail = 0; diff --git a/source/exhumed/src/sound.cpp b/source/exhumed/src/sound.cpp index 03d40c520..2c6d57c8c 100644 --- a/source/exhumed/src/sound.cpp +++ b/source/exhumed/src/sound.cpp @@ -448,7 +448,7 @@ int LoadSound(const char *sound) auto hVoc = kopenFileReader(buffer, 0); - if (!hVoc.isOpen()) + if (hVoc.isOpen()) { int nSize = hVoc.GetLength(); //SoundLock[i] = 255; // crap we don't need.