- 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
if (!nogl)
glsurface_setPalette(curpalettefaded);
glsurface_setPalette(curpalette);
else
#endif
{

View file

@ -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();

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_BLOOD", GAMEFLAG_BLOOD);
FlagMap.Insert("GAMEFLAG_SW", GAMEFLAG_SW);
FlagMap.Insert("GAMEFLAG_POWERSLAVE", GAMEFLAG_POWERSLAVE);
FlagMap.Insert("GAMEFLAG_EXHUMED", GAMEFLAG_EXHUMED);
FScanner sc;
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 <stdio.h>
#include <stdlib.h>
#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

View file

@ -75,18 +75,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <ctype.h>
#include <time.h>
#include <assert.h>
#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

View file

@ -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

View file

@ -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;

View file

@ -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.