- first steps trying to get the game to work.

This commit is contained in:
Christoph Oelckers 2019-12-13 00:19:34 +01:00
parent 4d28940d2f
commit b13ee90aa0
8 changed files with 45 additions and 114 deletions

View file

@ -1559,7 +1559,7 @@ int32_t videoUpdatePalette(int32_t start, int32_t num)
#ifdef USE_OPENGL #ifdef USE_OPENGL
if (!nogl) if (!nogl)
glsurface_setPalette(curpalettefaded); glsurface_setPalette(curpalette);
else else
#endif #endif
{ {

View file

@ -200,6 +200,10 @@ namespace ShadowWarrior
{ {
::GameInterface* CreateInterface(); ::GameInterface* CreateInterface();
} }
namespace Powerslave
{
::GameInterface* CreateInterface();
}
void CheckFrontend(int flags) void CheckFrontend(int flags)
{ {
@ -215,6 +219,10 @@ void CheckFrontend(int flags)
{ {
gi = ShadowWarrior::CreateInterface(); gi = ShadowWarrior::CreateInterface();
} }
else if (flags & GAMEFLAG_PSEXHUMED)
{
gi = Powerslave::CreateInterface();
}
else else
{ {
gi = Duke::CreateInterface(); gi = Duke::CreateInterface();

View file

@ -662,6 +662,8 @@ static TArray<GrpInfo> ParseGrpInfo(const char *fn, FileReader &fr, TMap<FString
FlagMap.Insert("GAMEFLAG_RRRA", GAMEFLAG_RRRA); FlagMap.Insert("GAMEFLAG_RRRA", GAMEFLAG_RRRA);
FlagMap.Insert("GAMEFLAG_BLOOD", GAMEFLAG_BLOOD); FlagMap.Insert("GAMEFLAG_BLOOD", GAMEFLAG_BLOOD);
FlagMap.Insert("GAMEFLAG_SW", GAMEFLAG_SW); FlagMap.Insert("GAMEFLAG_SW", GAMEFLAG_SW);
FlagMap.Insert("GAMEFLAG_POWERSLAVE", GAMEFLAG_POWERSLAVE);
FlagMap.Insert("GAMEFLAG_EXHUMED", GAMEFLAG_EXHUMED);
FScanner sc; FScanner sc;
auto mem = fr.Read(); auto mem = fr.Read();

View file

@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "exhumed.h" #include "exhumed.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "z_music.h"
BEGIN_PS_NS BEGIN_PS_NS
@ -57,61 +58,14 @@ bool playCDtrack(int nTrack, bool bLoop)
char filename[128]; 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 // try ogg vorbis now
sprintf(filename, "exhumed%02d.ogg", nTrack); sprintf(filename, "exhumed%02d.ogg", nTrack);
hFile = kopen4load(filename, 0); trackhandle = Mus_Play(nullptr, filename, true);
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;
}
return true; return true;
} }
void StartfadeCDaudio() void StartfadeCDaudio()
{ {
if (CDplaying()) {
nLastVolumeSet = gMusicVolume;
}
} }
int StepFadeCDaudio() int StepFadeCDaudio()
@ -119,23 +73,8 @@ int StepFadeCDaudio()
if (!CDplaying()) { if (!CDplaying()) {
return 0; return 0;
} }
Mus_Stop();
if (nLastVolumeSet <= 0) { trackhandle = 0;
return 0;
}
nLastVolumeSet -= 8;
if (nLastVolumeSet <= 0) {
nLastVolumeSet = 0;
}
setCDaudiovolume(nLastVolumeSet);
if (nLastVolumeSet == 0) {
StopCD();
}
return 1; return 1;
} }
@ -145,22 +84,13 @@ bool CDplaying()
return false; return false;
} }
else { else {
return FX_SoundActive(trackhandle); return true;
} }
} }
void StopCD() void StopCD()
{ {
if (trackhandle > 0) { Mus_Stop();
FX_StopSound(trackhandle);
trackhandle = -1;
}
if (pTrack)
{
Xaligned_free(pTrack);
pTrack = NULL;
}
} }
END_PS_NS END_PS_NS

View file

@ -75,18 +75,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <ctype.h> #include <ctype.h>
#include <time.h> #include <time.h>
#include <assert.h> #include <assert.h>
#include "gamecvars.h"
BEGIN_PS_NS BEGIN_PS_NS
#ifdef __cplusplus
extern "C" {
#endif
extern const char* s_buildRev; extern const char* s_buildRev;
extern const char* s_buildTimestamp; extern const char* s_buildTimestamp;
#ifdef __cplusplus
}
#endif
const char* AppProperName = APPNAME; const char* AppProperName = APPNAME;
const char* AppTechnicalName = APPBASENAME; const char* AppTechnicalName = APPBASENAME;
@ -817,6 +812,7 @@ void ShutDown(void)
void I_Error(const char *fmt, ...) void I_Error(const char *fmt, ...)
{ {
char buf[256]; char buf[256];
#ifdef __WATCOMC__ #ifdef __WATCOMC__
@ -832,19 +828,7 @@ void I_Error(const char *fmt, ...)
va_end(args); va_end(args);
initprintf(buf); throw std::runtime_error(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);
} }
void faketimerhandler() void faketimerhandler()
@ -1729,7 +1713,6 @@ static int32_t check_filename_casing(void)
#endif #endif
int32_t r_maxfpsoffset = 0; int32_t r_maxfpsoffset = 0;
double g_frameDelay = 0.0;
static int32_t nonsharedtimer; 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]; char tempbuf[256];
initprintf("Exhumed %s\n", s_buildRev);
int i; int i;
@ -1953,7 +1934,6 @@ int app_main(int argc, char const* const* argv)
initprintf("Initializing OSD...\n"); initprintf("Initializing OSD...\n");
Bsprintf(tempbuf, "Exhumed %s", s_buildRev);
registerosdcommands(); registerosdcommands();
//SetupInput(); //SetupInput();
@ -2017,8 +1997,6 @@ int app_main(int argc, char const* const* argv)
if (enginePostInit()) if (enginePostInit())
ShutDown(); ShutDown();
g_frameDelay = calcFrameDelay(r_maxfps + r_maxfpsoffset);
// loc_11745: // loc_11745:
// FadeOut(0); // FadeOut(0);
// InstallEngine(); // InstallEngine();
@ -3509,4 +3487,11 @@ int DoSpiritHead()
return 0; return 0;
} }
::GameInterface* CreateInterface()
{
return new GameInterface;
}
END_PS_NS END_PS_NS

View file

@ -240,13 +240,9 @@ extern const char *gString[];
extern int bVanilla; extern int bVanilla;
extern int32_t g_gameType;
#define POWERSLAVE (g_gameType & GAMEFLAG_POWERSLAVE) #define POWERSLAVE (g_gameType & GAMEFLAG_POWERSLAVE)
#define EXHUMED (g_gameType & GAMEFLAG_EXHUMED) #define EXHUMED (g_gameType & GAMEFLAG_EXHUMED)
extern int32_t r_maxfps;
extern int32_t r_maxfpsoffset;
extern double g_frameDelay; extern double g_frameDelay;
static inline double calcFrameDelay(int const maxFPS) { return maxFPS > 0 ? (timerGetFreqU64()/(double)maxFPS) : 0.0; } 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_LoadGroupsInDir(const char* dirname);
void G_DoAutoload(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 END_PS_NS
#endif #endif

View file

@ -117,7 +117,7 @@ int ReadFrame(FileReader &fp)
{ {
mutex_lock(&mutex); mutex_lock(&mutex);
int nRead = fread((char*)bankbuf + bankptr, 1, nSize, fp); int nRead = fp.Read((char*)bankbuf + bankptr, nSize);
lSoundBytesRead += nRead; lSoundBytesRead += nRead;
bankptr += nSize; bankptr += nSize;
@ -200,7 +200,7 @@ void PlayMovie(const char* fileName)
char buffer[256]; char buffer[256];
int bDoFade = kTrue; int bDoFade = kTrue;
int hFx = -1; int hFx = -1;
#if 0
if (bNoCDCheck) if (bNoCDCheck)
{ {
sprintf(buffer, "C:\\PS\\%s", fileName); sprintf(buffer, "C:\\PS\\%s", fileName);
@ -226,7 +226,7 @@ void PlayMovie(const char* fileName)
} }
} }
#else #else
auto fp = kopenFileReader(fileName, 0); auto fp = fileSystem.OpenFileReader(fileSystem.FindFile(fileName));
if (!fp.isOpen()) if (!fp.isOpen())
{ {
Printf("Unable to open %s\n", fileName); Printf("Unable to open %s\n", fileName);
@ -241,7 +241,6 @@ void PlayMovie(const char* fileName)
fp.Read(lh, sizeof(lh)); fp.Read(lh, sizeof(lh));
// sound stuff // sound stuff
mutex_init(&mutex);
bankptr = 0; bankptr = 0;
banktail = 0; banktail = 0;

View file

@ -448,7 +448,7 @@ int LoadSound(const char *sound)
auto hVoc = kopenFileReader(buffer, 0); auto hVoc = kopenFileReader(buffer, 0);
if (!hVoc.isOpen()) if (hVoc.isOpen())
{ {
int nSize = hVoc.GetLength(); int nSize = hVoc.GetLength();
//SoundLock[i] = 255; // crap we don't need. //SoundLock[i] = 255; // crap we don't need.