- more work on making Exhumed compile.

Almost done, down to 20 compile errors.
This commit is contained in:
Christoph Oelckers 2019-11-24 13:59:36 +01:00
parent 40772d9f0c
commit 8d11990494
22 changed files with 271 additions and 977 deletions

View file

@ -91,7 +91,6 @@ enum GameFunction_t
gamefunc_Zoom_In, // Map controls should not pollute the global button namespace.
gamefunc_Zoom_Out,
gamefunc_Escape, // this shouldn't be a button.
NUMGAMEFUNCTIONS
};

View file

@ -239,7 +239,7 @@ public:
void ClearKeysDown(void)
{
KB_LastScan = 0;
ClearLastScanCode();
ClearAllKeyStatus();
}

View file

@ -374,9 +374,10 @@ FTexture* BuildTiles::ValidateCustomTile(int tilenum, int type)
else if (type == FTexture::Restorable)
{
// This is for modifying an existing tile.
// It only gets used for the crosshair and two specific effects:
// It only gets used for the crosshair and a few specific effects:
// A) the fire in Blood.
// B) the pin display in Redneck Rampage's bowling lanes.
// C) Exhumed's menu plus one special effect tile.
// All of these effects should probably be redone without actual texture hacking...
if (tile->GetWidth() == 0 || tile->GetHeight() == 0) return nullptr; // The base must have a size for this to work.
// todo: invalidate hardware textures for tile.

View file

@ -583,7 +583,7 @@ inline uint8_t* tileData(int num)
return tex->GetWritableBuffer();
}
// Some hacks to allow accessing the no lpnger existing arrays as if they still were arrays to avoid changing hundreds of lines of code.
// Some hacks to allow accessing the no longer existing arrays as if they still were arrays to avoid changing hundreds of lines of code.
struct TileSiz
{
const vec2_16_t &operator[](size_t index)

View file

@ -1182,7 +1182,6 @@ void G_DisplayRest(int32_t smoothratio)
GameStats GameInterface::getStats()
{
GameStats stats;
DukePlayer_t* p = g_player[myconnectindex].ps;
return { p->actors_killed, p->max_actors_killed, p->secret_rooms, p->max_secret_rooms, p->player_par / REALGAMETICSPERSEC };
}

View file

@ -45,10 +45,7 @@ unsigned int dword_1B82E0 = 0;
int32_t FXVolume;
int32_t MusicVolume;
int32_t MixRate;
int32_t MidiPort;
int32_t NumVoices;
int32_t NumChannels;
int32_t NumBits;
int32_t ReverseStereo;
int32_t MusicDevice;
@ -59,8 +56,6 @@ int32_t scripthandle;
int32_t setupread;
// TODO: implement precaching toggle
int32_t useprecache;
int32_t MouseDeadZone, MouseBias;
int32_t SmoothInput;
void CONFIG_SetDefaults()
{
@ -87,26 +82,13 @@ void CONFIG_SetDefaults()
// currently settings.cfg is only read after the startup window launches the game,
// and rereading binds might be fickle so just enable this
gSetup.usejoystick = 1;
gSetup.forcesetup = 1;
gSetup.noautoload = 1;
gSetup.fullscreen = 1;
gSetup.usemouse = 1;
MixRate = 44100;
FXVolume = 255;
MusicVolume = 255;
NumChannels = 2;
NumBits = 16;
NumVoices = 32;
mouseaiming = 0;
aimmode = 1;
mouseflip = 1;
runkey_mode = 0;
auto_run = 1;
}
int CONFIG_ReadSetup(void)

View file

@ -27,8 +27,6 @@ BEGIN_PS_NS
typedef struct {
int32_t usejoystick;
int32_t usemouse;
int32_t fullscreen;
int32_t xdim;
int32_t ydim;

View file

@ -460,10 +460,6 @@ int32_t g_groupFileHandle;
static struct strllist *CommandPaths, *CommandGrps;
void G_ExtPreInit(int32_t argc,char const * const * argv)
{
}
void G_ExtInit(void)
{
}
@ -651,7 +647,6 @@ int8_t vely[97 * 106];
short nMouthTile;
short nPupData = 0;
int headfd = -1;
short word_964E8 = 0;
short word_964EA = 0;
@ -679,7 +674,6 @@ short nBackgroundPic;
short nShadowPic;
short nCreaturesLeft = 0;
short bNoSound = kFalse;
short nFreeze;
short bFullScreen;
@ -799,9 +793,6 @@ char debugBuffer[256];
short wConsoleNode; // TODO - move me into network file
int mouseaiming, aimmode, mouseflip;
int runkey_mode, auto_run;
ClockTicks tclocks, tclocks2;
void DebugOut(const char *fmt, ...)
@ -1567,10 +1558,10 @@ void DrawClock()
{
int ebp = 49;
tileLoad(kTile3603);
auto pixels = TileFiles.tileMakeWritable(kTile3603);
// nRedTicks = 0;
memset((void*)waloff[kTile3603], -1, 4096);
memset(pixels, -1, 4096);
if (lCountDown / 30 != nClockVal)
{
@ -1623,8 +1614,6 @@ static inline int32_t calc_smoothratio(ClockTicks totalclk, ClockTicks ototalclk
return clamp(tabledivide64(65536*elapsedFrames*30, rfreq), 0, 65536);
}
int r_showfps;
#define COLOR_RED redcol
#define COLOR_WHITE whitecol
@ -1773,111 +1762,25 @@ static int32_t check_filename_casing(void)
}
#endif
int32_t r_maxfps = 60;
int32_t r_maxfpsoffset = 0;
double g_frameDelay = 0.0;
int G_FPSLimit(void)
{
if (!r_maxfps)
return 1;
static double nextPageDelay;
static uint64_t lastFrameTicks;
uint64_t const frameTicks = timerGetTicksU64();
uint64_t const elapsedTime = frameTicks - lastFrameTicks;
double const dElapsedTime = elapsedTime;
if (dElapsedTime >= floor(nextPageDelay))
{
if (dElapsedTime <= nextPageDelay+g_frameDelay)
nextPageDelay += g_frameDelay-dElapsedTime;
lastFrameTicks = frameTicks;
return 1;
}
return 0;
}
static int32_t nonsharedtimer;
int app_main(int argc, char const* const* argv)
void CheckCommandLine(int argc, char const* const* argv, int &doTitle)
{
char tempbuf[256];
#ifdef _WIN32
#ifndef DEBUGGINGAIDS
if (!G_CheckCmdSwitch(argc, argv, "-noinstancechecking") && !windowsCheckAlreadyRunning())
{
#ifdef EDUKE32_STANDALONE
if (!wm_ynbox(APPNAME, "It looks like " APPNAME " is already running.\n\n"
#else
if (!wm_ynbox(APPNAME, "It looks like the game is already running.\n\n"
#endif
"Are you sure you want to start another copy?"))
return 3;
}
#endif
// Check for any command line arguments
for (int i = 1; i < argc; i++)
{
const char* pChar = argv[i];
#ifndef USE_PHYSFS
#ifdef DEBUGGINGAIDS
extern int32_t (*check_filename_casing_fn)(void);
check_filename_casing_fn = check_filename_casing;
#endif
#endif
#endif
if (*pChar == '/')
{
pChar++;
//strlwr(pChar);
G_ExtPreInit(argc, argv);
OSD_SetLogFile(APPBASENAME ".log");
OSD_SetFunctions(NULL,
NULL,
NULL,
NULL,
NULL,
GAME_clearbackground,
BGetTime,
GAME_onshowosd);
wm_setapptitle(APPNAME);
initprintf("Exhumed %s\n", s_buildRev);
PrintBuildInfo();
int i;
//int esi = 1;
//int edi = esi;
int doTitle = kTrue; // REVERT kTrue;
int stopTitle = kFalse;
levelnew = 1;
// REVERT - change back to kTrue
// short bDoTitle = kFalse;
wConsoleNode = 0;
int nMenu = 0; // TEMP
// Check for any command line arguments
for (i = 1; i < argc; i++)
{
const char *pChar = argv[i];
if (*pChar == '/')
{
pChar++;
//strlwr(pChar);
if (Bstrcasecmp(pChar, "nocreatures") == 0) {
bNoCreatures = kTrue;
}
else if (Bstrcasecmp(pChar, "nosound") == 0) {
bNoSound = kTrue;
if (Bstrcasecmp(pChar, "nocreatures") == 0) {
bNoCreatures = kTrue;
}
else if (Bstrcasecmp(pChar, "record") == 0)
{
@ -2014,6 +1917,30 @@ int app_main(int argc, char const* const* argv)
}
}
}
}
int app_main(int argc, char const* const* argv)
{
char tempbuf[256];
initprintf("Exhumed %s\n", s_buildRev);
int i;
//int esi = 1;
//int edi = esi;
int doTitle = kTrue; // REVERT kTrue;
int stopTitle = kFalse;
levelnew = 1;
// REVERT - change back to kTrue
// short bDoTitle = kFalse;
wConsoleNode = 0;
int nMenu = 0; // TEMP
if (nNetPlayerCount && forcelevel == -1) {
forcelevel = 1;
@ -2028,15 +1955,6 @@ int app_main(int argc, char const* const* argv)
if (forcegl) initprintf("GL driver blacklist disabled.\n");
#endif
// used with binds for fast function lookup
hash_init(&h_gamefuncs);
for (bssize_t i=kMaxGameFunctions-1; i>=0; i--)
{
if (gamefunctions[i][0] == '\0')
continue;
hash_add(&h_gamefuncs,gamefunctions[i],i,0);
}
#ifdef STARTUP_SETUP_WINDOW
int const readSetup =
@ -2051,68 +1969,7 @@ int app_main(int argc, char const* const* argv)
Bexit(2);
}
if (Bstrcmp(setupfilename, kSetupFilename))
initprintf("Using config file \"%s\".\n",setupfilename);
G_ScanGroups();
#ifdef STARTUP_SETUP_WINDOW
if (readSetup < 0 || (!g_noSetup && gSetup.forcesetup) || g_commandSetup)
{
if (quitevent || !startwin_run())
{
engineUnInit();
Bexit(0);
}
}
#endif
G_LoadGroups(!g_noAutoLoad && !gSetup.noautoload);
// Decrypt strings code would normally be here
#if 0
for (int i = 0; ; i++)
{
int j = i - 1;
while (j >= 0)
{
if (gString_Enc[i] == gString_Enc[j]) {
break;
}
j--;
}
if (j < 0)
{
int k = 0;
while (1)
{
uint8_t v27 = gString_Enc[i + k];
if (v27)
{
gString_Enc[i + k] = v27 ^ 0xFF;
k++;
}
else {
break;
}
}
// strupr(gString[j]);
int blah = 123;
// if (!strcmp(*(char **)((char *)gString + v29), "EOF", v27, v30))
// break;
}
}
#endif
// loc_115F5:
nItemTextIndex = FindGString("ITEMS");
@ -2129,33 +1986,13 @@ int app_main(int argc, char const* const* argv)
// GetCurPal(NULL);
CONFIG_WriteSetup(1);
CONFIG_ReadSetup();
initprintf("Initializing OSD...\n");
Bsprintf(tempbuf, "Exhumed %s", s_buildRev);
OSD_SetVersion(tempbuf, 10,0);
OSD_SetParameters(0, 0, 0, 0, 0, 0, OSD_ERROR, OSDTEXT_RED, gamefunctions[gamefunc_Show_Console][0] == '\0' ? OSD_PROTECTED : 0);
registerosdcommands();
SetupInput();
char *const setupFileName = Xstrdup(setupfilename);
char *const p = strtok(setupFileName, ".");
if (!p || !Bstrcmp(setupfilename, kSetupFilename))
Bsprintf(tempbuf, "settings.cfg");
else
Bsprintf(tempbuf, "%s_settings.cfg", p);
Xfree(setupFileName);
OSD_Exec(tempbuf);
OSD_Exec("autoexec.cfg");
CONFIG_SetDefaultKeys(keydefaults, true);
system_getcvars();
if (nNetPlayerCount == -1)
@ -2290,8 +2127,8 @@ MENU:
bInDemo = kTrue;
bPlayback = kTrue;
KB_FlushKeyboardQueue();
KB_ClearKeysDown();
inputState.keyFlushChars();
inputState.ClearAllKeyStatus();
break;
}
STARTGAME1:
@ -2400,8 +2237,8 @@ LOOP3:
{
EraseScreen(overscanindex);
Query(2, 0, "Insert CD into drive", "(ESC to abort)");
KB_ClearKeysDown();
if (KB_GetCh() == asc_Escape) {
inputState.ClearAllKeyStatus();
if (inputState.keyGetChar() == asc_Escape) {
I_Error("Aborted\n");
}
}
@ -2509,10 +2346,10 @@ LOOP3:
if (bPlayback)
{
// YELLOW
if ((bInDemo && KB_KeyWaiting() || !ReadPlaybackInputs()) && KB_GetCh())
if ((bInDemo && inputState.keyBufferWaiting() || !ReadPlaybackInputs()) && inputState.keyGetChar())
{
KB_FlushKeyboardQueue();
KB_ClearKeysDown();
inputState.keyFlushChars();
inputState.ClearAllKeyStatus();
bPlayback = kFalse;
bInDemo = kFalse;
@ -2657,9 +2494,9 @@ LOOP3:
}
if (!bInDemo)
{
if (buttonMap.ButtonDown(gamefunc_Escape))
if (inputState.GetKeyStatus(sc_Escape))
{
buttonMap.ClearButton(gamefunc_Escape);
inputState.ClearKeyStatus(sc_Escape);
// MENU2:
CONTROL_BindsEnabled = 0;
bInMove = kTrue;
@ -2693,11 +2530,6 @@ LOOP3:
CONTROL_BindsEnabled = 1;
RefreshStatus();
}
else if (KB_UnBoundKeyPressed(sc_F12))
{
KB_ClearKeyDown(sc_F12);
videoCaptureScreen("captxxxx.png", 0);
}
else if (buttonMap.ButtonDown(gamefunc_Map)) // e.g. TAB (to show 2D map)
{
buttonMap.ClearButton(gamefunc_Map);
@ -3001,7 +2833,8 @@ void CopyTileToBitmap(short nSrcTile, short nDestTile, int xPos, int yPos)
{
int nOffs = tilesiz[nDestTile].y * xPos;
uint8_t *pDest = (uint8_t*)waloff[nDestTile] + nOffs + yPos;
auto pixels = TileFiles.tileMakeWritable(nDestTile);
uint8_t *pDest = pixels + nOffs + yPos;
uint8_t *pDestB = pDest;
tileLoad(nSrcTile);
@ -3009,7 +2842,7 @@ void CopyTileToBitmap(short nSrcTile, short nDestTile, int xPos, int yPos)
int destYSize = tilesiz[nDestTile].y;
int srcYSize = tilesiz[nSrcTile].y;
uint8_t *pSrc = (uint8_t*)waloff[nSrcTile];
const uint8_t *pSrc = tilePtr(nSrcTile);
for (int x = 0; x < tilesiz[nSrcTile].x; x++)
{
@ -3164,13 +2997,13 @@ int Query(short nLines, short nKeys, ...)
if (nKeys)
{
KB_FlushKeyboardQueue();
inputState.keyFlushChars();
while (1)
{
HandleAsync();
char key = toupper(KB_GetCh());
char key = toupper(inputState.keyGetChar());
for (i = 0; i < nKeys; i++)
{
@ -3196,7 +3029,6 @@ void InitSpiritHead()
nPixels = 0;
tileLoad(kTileRamsesNormal); // Ramses Normal Head
for (int i = 0; i < kMaxSprites; i++)
{
@ -3206,15 +3038,15 @@ void InitSpiritHead()
}
}
uint8_t *pTile = (uint8_t*)waloff[kTileRamsesNormal];
auto pTile = tilePtr(kTileRamsesNormal); // Ramses Normal Head
auto pGold = tilePtr(kTileRamsesGold);
for (int x = 0; x < 97; x++)
{
for (int y = 0; y < 106; y++)
{
if (*pTile != 255)
{
pixelval[nPixels] = *(uint8_t*)(waloff[kTileRamsesGold] + x * 106 + y);
pixelval[nPixels] = *(pGold + x * 106 + y);
origx[nPixels] = x - 48;
origy[nPixels] = y - 53;
curx[nPixels] = 0;
@ -3241,7 +3073,6 @@ void InitSpiritHead()
}
}
waloff[kTileRamsesWorkTile] = (intptr_t)worktile;
sprite[nSpiritSprite].yrepeat = 140;
sprite[nSpiritSprite].xrepeat = 140;
@ -3250,8 +3081,7 @@ void InitSpiritHead()
nHeadStage = 0;
// work tile is twice as big as the normal head size
tilesiz[kTileRamsesWorkTile].x = 97 * 2; // 194;
tilesiz[kTileRamsesWorkTile].y = 106 * 2; // 212;
TileFiles.tileSetExternal(kTileRamsesWorkTile, 97 * 2, 106 * 2, worktile);
sprite[nSpiritSprite].cstat &= 0x7FFF;
@ -3285,11 +3115,16 @@ void InitSpiritHead()
lNextStateChange = (int)totalclock;
lHeadStartClock = (int)totalclock;
headfd = kopen4load(filename, 512); // 512??
nPupData = kread(headfd, cPupData, sizeof(cPupData));
pPupData = cPupData;
kclose(headfd);
headfd = -1;
auto headfd = kopenFileReader(filename, 512); // 512??
if (!headfd.isOpen())
{
memset(cPupData, 0, sizeof(cPupData));
}
else
{
nPupData = headfd.Read(cPupData, sizeof(cPupData));
pPupData = cPupData;
}
nMouthTile = 0;
nTalkTime = 1;
}
@ -3317,9 +3152,7 @@ void DimSector(short nSector)
void CopyHeadToWorkTile(short nTile)
{
tileLoad(nTile);
uint8_t *pSrc = (uint8_t*)waloff[nTile];
const uint8_t* pSrc = tilePtr(nTile);
uint8_t *pDest = (uint8_t*)&worktile[212 * 49 + 53];
for (int i = 0; i < 97; i++)
@ -3670,11 +3503,9 @@ int DoSpiritHead()
ebx += word_964EA;
tileLoad(ebx);
// TODO - fixme. How big is worktile?
uint8_t *pDest = (uint8_t*)&worktile[10441];
uint8_t *pSrc = (uint8_t*)waloff[ebx];
const uint8_t* pSrc = tilePtr(ebx);
for (int i = 0; i < 97; i++)
{
@ -3697,8 +3528,6 @@ int DoSpiritHead()
if (nMouthTile)
{
tileLoad(nMouthTile + 598);
short nTileSizeX = tilesiz[nMouthTile + 598].x;
short nTileSizeY = tilesiz[nMouthTile + 598].y;
@ -3707,7 +3536,7 @@ int DoSpiritHead()
// pDest += (212 * (97 - nTileSizeX / 2)) + (159 - nTileSizeY);
uint8_t *pDest = (uint8_t*)&worktile[212 * (97 - nTileSizeX / 2)] + (159 - nTileSizeY);
uint8_t *pSrc = (uint8_t*)waloff[nMouthTile + 598];
const uint8_t *pSrc = tilePtr(nMouthTile + 598);
while (nTileSizeX > 0)
{

View file

@ -188,8 +188,6 @@ extern short bSlipMode;
extern short nItemTextIndex;
extern const char *gString[];
extern short bNoSound;
extern int bVanilla;
extern int32_t g_gameType;
@ -197,8 +195,6 @@ extern int32_t g_gameType;
#define POWERSLAVE (g_gameType & GAMEFLAG_POWERSLAVE)
#define EXHUMED (g_gameType & GAMEFLAG_EXHUMED)
extern int mouseaiming, aimmode, mouseflip;
extern int runkey_mode, auto_run;
extern int32_t r_maxfps;
extern int32_t r_maxfpsoffset;
extern double g_frameDelay;
@ -221,7 +217,6 @@ enum {
};
extern char g_modDir[BMAX_PATH];
extern int r_showfps;
extern struct grpfile_t const* g_selectedGrp;

View file

@ -213,173 +213,6 @@ uint8_t LoadLevel(int nMap)
return kFalse;
}
#if 0
{
// going to load the map without loadboard() - to take care of version 6 to 7 map conversion
//int hFile = kopen4load(fileName_1, 1);
int hFile = kopen4load(fileName_1, 0);
// int hFile = open(fileName_1, O_BINARY | O_RDONLY);
if (hFile == -1) {
return kFalse;
}
int version;
kread(hFile, &version, sizeof(version));
if (version != 6) {
bIsVersion6 = kFalse;
}
initspritelists();
memset(show2dsector, 0, sizeof(show2dsector));
memset(show2dsprite, 0, sizeof(show2dsprite));
memset(show2dwall, 0, sizeof(show2dwall));
// replacement for build's loadboard()
kread(hFile, &initx, 4);
kread(hFile, &inity, 4);
kread(hFile, &initz, 4);
kread(hFile, &inita, 2);
kread(hFile, &initsect, 2);
// sectors
short nSectors;
kread(hFile, &nSectors, sizeof(nSectors));
if (bIsVersion6) {
kread(hFile, sector_6, sizeof(Sector_6) * nSectors);
}
else {
kread(hFile, sector, sizeof(SECTOR) * nSectors);
}
// walls
short nWalls;
kread(hFile, &nWalls, sizeof(nWalls));
if (bIsVersion6) {
kread(hFile, wall_6, sizeof(Wall_6) * nWalls);
}
else {
kread(hFile, wall, sizeof(WALL) * nWalls);
}
// sprites
short nSprites;
kread(hFile, &nSprites, sizeof(nSprites));
if (bIsVersion6) {
kread(hFile, sprite_6, sizeof(Sprite_6) * nSprites);
}
else {
kread(hFile, sprite, sizeof(SPRITE) * nSprites);
}
// set engine variables
numsectors = nSectors;
numwalls = nWalls;
// load in our version 6 structs to the engines v7 structs if required
if (bIsVersion6)
{
for (int nSector = 0; nSector < nSectors; nSector++)
{
sector[nSector].ceilingz = sector_6[nSector].ceilingz;
sector[nSector].floorz = sector_6[nSector].floorz;
sector[nSector].wallptr = sector_6[nSector].wallptr;
sector[nSector].wallnum = sector_6[nSector].wallnum;
sector[nSector].ceilingpicnum = sector_6[nSector].ceilingpicnum;
sector[nSector].ceilingheinum = Max(Min(((int)sector_6[nSector].ceilingheinum) << 5, 32767), -32768);
if ((sector_6[nSector].ceilingstat & 2) == 0) {
sector[nSector].ceilingheinum = 0;
}
sector[nSector].ceilingshade = sector_6[nSector].ceilingshade;
sector[nSector].ceilingpal = sector_6[nSector].ceilingpal;
sector[nSector].ceilingxpanning = sector_6[nSector].ceilingxpanning;
sector[nSector].ceilingypanning = sector_6[nSector].ceilingypanning;
sector[nSector].floorpicnum = sector_6[nSector].floorpicnum;
sector[nSector].floorheinum = Max(Min(((int)sector_6[nSector].floorheinum) << 5, 32767), -32768);
if ((sector_6[nSector].floorstat & 2) == 0) {
sector[nSector].floorheinum = 0;
}
sector[nSector].floorshade = sector_6[nSector].floorshade;
sector[nSector].floorpal = sector_6[nSector].floorpal;
sector[nSector].floorxpanning = sector_6[nSector].floorxpanning;
sector[nSector].floorypanning = sector_6[nSector].floorypanning;
sector[nSector].ceilingstat = sector_6[nSector].ceilingstat;
sector[nSector].floorstat = sector_6[nSector].floorstat;
sector[nSector].visibility = sector_6[nSector].visibility;
sector[nSector].filler = 0;
sector[nSector].lotag = sector_6[nSector].lotag;
sector[nSector].hitag = sector_6[nSector].hitag;
sector[nSector].extra = sector_6[nSector].extra;
}
for (int nWall = 0; nWall < nWalls; nWall++)
{
wall[nWall].x = wall_6[nWall].x;
wall[nWall].y = wall_6[nWall].y;
wall[nWall].point2 = wall_6[nWall].point2;
wall[nWall].nextwall = wall_6[nWall].nextwall;
wall[nWall].nextsector = wall_6[nWall].nextsector;
wall[nWall].cstat = wall_6[nWall].cstat;
wall[nWall].picnum = wall_6[nWall].picnum;
wall[nWall].overpicnum = wall_6[nWall].overpicnum;
wall[nWall].shade = wall_6[nWall].shade;
wall[nWall].pal = wall_6[nWall].pal;
wall[nWall].xrepeat = wall_6[nWall].xrepeat;
wall[nWall].yrepeat = wall_6[nWall].yrepeat;
wall[nWall].xpanning = wall_6[nWall].xpanning;
wall[nWall].ypanning = wall_6[nWall].ypanning;
wall[nWall].lotag = wall_6[nWall].lotag;
wall[nWall].hitag = wall_6[nWall].hitag;
wall[nWall].extra = wall_6[nWall].extra;
}
for (int nSprite = 0; nSprite < nSprites; nSprite++)
{
sprite[nSprite].x = sprite_6[nSprite].x;
sprite[nSprite].y = sprite_6[nSprite].y;
sprite[nSprite].z = sprite_6[nSprite].z;
sprite[nSprite].cstat = sprite_6[nSprite].cstat;
sprite[nSprite].picnum = sprite_6[nSprite].picnum;
sprite[nSprite].shade = sprite_6[nSprite].shade;
sprite[nSprite].pal = sprite_6[nSprite].pal;
sprite[nSprite].clipdist = sprite_6[nSprite].clipdist;
sprite[nSprite].filler = 0;
sprite[nSprite].xrepeat = sprite_6[nSprite].xrepeat;
sprite[nSprite].yrepeat = sprite_6[nSprite].yrepeat;
sprite[nSprite].xoffset = sprite_6[nSprite].xoffset;
sprite[nSprite].yoffset = sprite_6[nSprite].yoffset;
sprite[nSprite].sectnum = sprite_6[nSprite].sectnum;
sprite[nSprite].statnum = sprite_6[nSprite].statnum;
sprite[nSprite].ang = sprite_6[nSprite].ang;
sprite[nSprite].owner = sprite_6[nSprite].owner;
sprite[nSprite].xvel = sprite_6[nSprite].xvel;
sprite[nSprite].yvel = sprite_6[nSprite].yvel;
sprite[nSprite].zvel = sprite_6[nSprite].zvel;
sprite[nSprite].lotag = sprite_6[nSprite].lotag;
sprite[nSprite].hitag = sprite_6[nSprite].hitag;
sprite[nSprite].extra = sprite_6[nSprite].extra;
}
}
for (int nSprite = 0; nSprite < nSprites; nSprite++) {
insertsprite(sprite[nSprite].sectnum, sprite[nSprite].statnum);
}
updatesector(initx, inity, &initsect);
kclose(hFile);
hFile = -1;
}
// loadboard has finished
#endif
vec3_t startPos;
int status = engineLoadBoard(fileName_1, 0, &startPos, &inita, &initsect);
if (status == -2)
@ -439,27 +272,9 @@ void ResetEngine()
void InstallEngine()
{
// initgroupfile("stuff.dat");
TileFiles.LoadArtSet("tiles%03d.art");
char *cwd;
if (g_modDir[0] != '/' && (cwd = buildvfs_getcwd(NULL, 0)))
{
buildvfs_chdir(g_modDir);
if (artLoadFiles("tiles000.art", MAXCACHE1DSIZE) < 0)
{
buildvfs_chdir(cwd);
if (artLoadFiles("tiles000.art", MAXCACHE1DSIZE) < 0)
I_Error("Failed loading art.");
}
buildvfs_chdir(cwd);
#ifndef __ANDROID__ //This crashes on *some* Android devices. Small onetime memory leak. TODO fix above function
Xfree(cwd);
#endif
}
else if (artLoadFiles("tiles000.art",MAXCACHE1DSIZE) < 0)
I_Error("Failed loading art.");
// TEMP
// TEMP
//nScreenWidth *= 2;
//nScreenHeight *= 2;
@ -522,7 +337,6 @@ void InstallEngine()
void RemoveEngine()
{
engineUnInit();
uninitgroupfile();
}
void SetBelow(short nCurSector, short nBelowSector)

View file

@ -168,8 +168,8 @@ ClearSpaceBar_
void ClearAllKeys()
{
KB_ClearKeysDown();
KB_FlushKeyboardQueue();
inputState.ClearAllKeyStatus();
inputState.keyFlushChars();
}
void WaitNoKey(int nSecs, void (*pFunc) (void))

View file

@ -84,19 +84,18 @@ int LoadPaletteLookups()
for (int i = 0; i < kMaxGrads; i++)
{
int hFile = kopen4load(GradList[i], 1);
if (hFile == -1)
auto hFile = kopenFileReader(GradList[i], 1);
if (!hFile.isOpen())
{
initprintf("Error reading palette lookup '%s'\n", GradList[i]);
return 0;
}
kread(hFile, buffer, 256*64);
hFile.Read(buffer, 256*64);
// TODO: dumb hack
if (palookup[i])
ALIGNED_FREE_AND_NULL(palookup[i]);
paletteSetLookupTable(i, buffer);
kclose(hFile);
// origpalookup[i] = palookup[i];
bGreenPal = 0;

View file

@ -559,7 +559,7 @@ static void G_DrawOverheadMap(int32_t cposx, int32_t cposy, int32_t czoom, int16
}
}
renderEnableFog();
//renderEnableFog();
videoSetCorrectedAspect();

View file

@ -38,6 +38,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "light.h"
#include "cd.h"
#include "cdaudio.h"
#include "input.h"
#include <string>
#include <assert.h>
@ -779,9 +780,9 @@ int menu_DrawTheMap(int nLevel, int nLevelNew, int nLevelBest)
if (curYPos == destYPos)
{
if (KB_KeyDown[sc_UpArrow])
if (I_MenuUp())
{
KB_KeyDown[sc_UpArrow] = 0;
I_MenuUpClear();
if (nLevelNew <= nLevelBest)
{
@ -801,9 +802,9 @@ int menu_DrawTheMap(int nLevel, int nLevelNew, int nLevelBest)
}
}
if (KB_KeyDown[sc_DownArrow])
{
KB_KeyDown[sc_DownArrow] = 0;
if (I_MenuDown())
{
I_MenuDownClear();
if (nLevelNew > 0)
{
@ -823,11 +824,9 @@ int menu_DrawTheMap(int nLevel, int nLevelNew, int nLevelBest)
}
}
if (KB_KeyDown[sc_Escape] || KB_KeyDown[sc_Space] || KB_KeyDown[sc_Return])
if (I_AdvanceTrigger())
{
KB_KeyDown[sc_Escape] = 0;
KB_KeyDown[sc_Return] = 0;
KB_KeyDown[sc_Space] = 0;
I_AdvanceTriggerClear();
return nLevelNew + 1;
}
}
@ -841,15 +840,13 @@ int menu_DrawTheMap(int nLevel, int nLevelNew, int nLevelBest)
//curYPos += var_2C * (((int)totalclock - moveTimer) / 2);
if (KB_KeyDown[sc_Escape] || KB_KeyDown[sc_Space] || KB_KeyDown[sc_Return])
{
if (var_2C < 8) {
if (I_AdvanceTrigger())
{
I_AdvanceTriggerClear();
if (var_2C < 8) {
var_2C *= 2;
}
KB_KeyDown[sc_Escape] = 0;
KB_KeyDown[sc_Return] = 0;
KB_KeyDown[sc_Space] = 0;
}
if (curYPos > destYPos&& var_2C > 0) {
@ -908,35 +905,31 @@ void menu_AdjustVolume()
videoNextPage();
if (KB_KeyDown[sc_Escape] || KB_KeyDown[sc_Return] || KB_KeyDown[sc_Space])
{
PlayLocalSound(StaticSound[kSound33], 0);
KB_KeyDown[sc_Escape] = 0;
KB_KeyDown[sc_Space] = 0;
KB_KeyDown[sc_Return] = 0;
if (I_AdvanceTrigger())
{
I_AdvanceTriggerClear();
PlayLocalSound(StaticSound[kSound33], 0);
return;
}
if (KB_KeyDown[sc_UpArrow])
if (I_MenuUp())
{
I_MenuUpClear();
if (nOption > 0)
{
nOption--;
PlayLocalSound(StaticSound[kSound35], 0);
}
KB_KeyDown[sc_UpArrow] = 0;
}
if (KB_KeyDown[sc_DownArrow])
{
if (nOption < 1)
if (I_MenuDown())
{
I_MenuDownClear();
if (nOption < 1)
{
nOption++;
PlayLocalSound(StaticSound[kSound35], 0);
}
KB_KeyDown[sc_DownArrow] = 0;
}
if ((int)totalclock <= var_8) {
@ -945,9 +938,10 @@ void menu_AdjustVolume()
var_8 = (int)totalclock + 5;
if (KB_KeyDown[sc_LeftArrow])
{
switch (nOption)
if (I_MenuLeft())
{
I_MenuLeftClear();
switch (nOption)
{
case 0:
{
@ -977,9 +971,10 @@ void menu_AdjustVolume()
}
}
if (KB_KeyDown[sc_RightArrow])
{
switch (nOption)
if (I_MenuRight())
{
I_MenuRightClear();
switch (nOption)
{
case 0:
{
@ -1103,16 +1098,17 @@ int menu_NewGameMenu()
// continue;
//}
if (KB_KeyDown[sc_Escape])
if (I_EscapeTrigger())
{
PlayLocalSound(StaticSound[kSound33], 0);
KB_KeyDown[sc_Escape] = 0;
I_EscapeTriggerClear();
return -1;
}
if (KB_KeyDown[sc_UpArrow])
{
PlayLocalSound(StaticSound[kSound35], 0);
if (I_MenuUp())
{
I_MenuUpClear();
PlayLocalSound(StaticSound[kSound35], 0);
if (nSlot <= 0) {
nSlot = 4;
}
@ -1120,14 +1116,14 @@ int menu_NewGameMenu()
nSlot--;
}
KB_KeyDown[sc_UpArrow] = 0;
ClearAllKeys();
continue;
}
if (KB_KeyDown[sc_DownArrow])
{
PlayLocalSound(StaticSound[kSound35], 0);
if (I_MenuDown())
{
I_MenuDownClear();
PlayLocalSound(StaticSound[kSound35], 0);
if (nSlot >= 4) {
nSlot = 0;
}
@ -1135,12 +1131,11 @@ int menu_NewGameMenu()
nSlot++;
}
KB_KeyDown[sc_DownArrow] = 0;
ClearAllKeys();
inputState.ClearAllKeyStatus();
continue;
}
if (KB_KeyDown[sc_Return] || KB_KeyWaiting())
if (I_AdvanceTrigger() || inputState.keyBufferWaiting())
{
break;
}
@ -1148,8 +1143,8 @@ int menu_NewGameMenu()
}
PlayLocalSound(StaticSound[kSound33], 0);
if (KB_KeyDown[sc_Return]) {
ClearAllKeys();
if (!inputState.keyBufferWaiting()) {
inputState.ClearAllKeyStatus();
}
char *pName = nameList[nSlot];
@ -1186,14 +1181,14 @@ int menu_NewGameMenu()
char ch = 0;
check_keys:
if (KB_KeyWaiting())
if (inputState.keyBufferWaiting())
{
HandleAsync();
ch = KB_GetCh();
ch = inputState.keyGetChar();
if (!ch)
{
KB_GetCh();
inputState.keyGetChar(); //???
goto check_keys;
}
@ -1204,7 +1199,7 @@ check_keys:
nameList[nSlot][nNameOffset] = 0;
PlayLocalSound(StaticSound[kSound33], 0);
KB_KeyDown[sc_Return] = 0;
inputState.ClearKeyStatus(sc_Return);
if (nameList[nSlot][0] == 0) {
return -1;
@ -1252,9 +1247,8 @@ check_keys:
else if (ch == asc_Escape)
{
PlayLocalSound(StaticSound[kSound33], 0);
KB_ClearKeysDown();
KB_FlushKeyboardQueue();
KB_KeyDown[sc_Escape] = 0;
inputState.ClearAllKeyStatus();
inputState.keyFlushChars();
return -1;
}
else
@ -1353,15 +1347,16 @@ int menu_LoadGameMenu()
overwritesprite(233, y, kMenuCursorTile, 0, 10, kPalNormal);
videoNextPage();
if (KB_KeyDown[sc_Escape])
if (I_EscapeTrigger())
{
I_EscapeTriggerClear();
PlayLocalSound(StaticSound[kSound33], 0);
KB_KeyDown[sc_Escape] = 0;
return -1;
}
if (KB_KeyDown[sc_UpArrow])
if (I_MenuUp())
{
I_MenuUpClear();
PlayLocalSound(StaticSound[kSound35], 0);
if (nSlot > 0) {
nSlot--;
@ -1369,31 +1364,28 @@ int menu_LoadGameMenu()
else {
nSlot = kMaxSaveSlots - 1;
}
KB_KeyDown[sc_UpArrow] = 0;
}
if (KB_KeyDown[sc_DownArrow]) // checkme - is 0x5b in disassembly
{
PlayLocalSound(StaticSound[kSound35], 0);
if (I_MenuDown())
{
I_MenuDownClear();
PlayLocalSound(StaticSound[kSound35], 0);
if (nSlot < kMaxSaveSlots - 1) {
nSlot++;
}
else {
nSlot = 0;
}
KB_KeyDown[sc_DownArrow] = 0;
}
if (!KB_KeyDown[sc_Return]) {
if (!I_AdvanceTrigger()) {
continue;
}
PlayLocalSound(StaticSound[kSound33], 0);
KB_KeyDown[sc_Return] = 0;
KB_ClearKeysDown();
KB_FlushKeyboardQueue();
I_AdvanceTriggerClear();
inputState.ClearAllKeyStatus();
inputState.keyFlushChars();
if (nameList[nSlot][0] != '\0')
{
@ -1499,15 +1491,13 @@ int menu_Menu(int nVal)
videoSetViewableArea(0, 0, xdim - 1, ydim - 1);
KB_KeyDown[sc_Escape] = 0;
StopAllSounds();
StopLocalSound();
menu_ResetKeyTimer();
KB_FlushKeyboardQueue();
KB_ClearKeysDown();
inputState.keyFlushChars();
inputState.ClearAllKeyStatus();
menu_ResetZoom();
@ -1598,19 +1588,19 @@ int menu_Menu(int nVal)
break;
}
if (KB_KeyDown[nKey])
if (inputState.GetKeyStatus(nKey))
{
goto LABEL_21; // TEMP
}
}
// loc_3A0A7
while (KB_KeyDown[sc_Escape])
while (I_EscapeTrigger())
{
HandleAsync();
PlayLocalSound(StaticSound[kSound33], 0);
KB_KeyDown[sc_Escape] = 0;
I_EscapeTriggerClear();
if (nVal)
{
@ -1628,13 +1618,14 @@ LABEL_21:
if (l != nMenu)
{
PlayLocalSound(StaticSound[kSound35], 0);
KB_KeyDown[nMenuKeys[l]] = 0;
inputState.ClearKeyStatus(nMenuKeys[l]);
nMenu = l;
}
}
if (KB_KeyDown[sc_Space] || KB_KeyDown[sc_Return])
if (I_AdvanceTrigger())
{
I_AdvanceTriggerClear();
var_1C = 1;
}
else if (var_1C)
@ -1731,8 +1722,9 @@ LABEL_21:
}
}
if (KB_KeyDown[sc_UpArrow])
if (I_MenuUp())
{
I_MenuUpClear();
PlayLocalSound(StaticSound[kSound35], 0);
if (nMenu <= 0) {
nMenu = 4;
@ -1741,13 +1733,13 @@ LABEL_21:
nMenu--;
}
KB_KeyDown[sc_UpArrow] = 0;
menu_ResetKeyTimer();
}
if (KB_KeyDown[sc_DownArrow]) // FIXME - is this down arrow? value is '5B' in disassembly
{
PlayLocalSound(StaticSound[kSound35], 0);
if (I_MenuDown())
{
I_MenuDownClear();
PlayLocalSound(StaticSound[kSound35], 0);
if (nMenu >= 4) {
nMenu = 0;
}
@ -1755,11 +1747,12 @@ LABEL_21:
nMenu++;
}
KB_KeyDown[sc_DownArrow] = 0;
menu_ResetKeyTimer();
}
// TODO - change to #defines
/* why are these cleares although they are never used anywhere?
if (KB_KeyDown[0x5c]) {
KB_KeyDown[0x5c] = 0;
}
@ -1767,6 +1760,7 @@ LABEL_21:
if (KB_KeyDown[0x5d]) {
KB_KeyDown[0x5d] = 0;
}
*/
}
return 0;// todo
@ -1810,18 +1804,16 @@ int LoadCinemaPalette(int nPal)
// original code strcpy'd into a buffer first...
int hFile = kopen4load(cinpalfname[nPal], 1);
if (hFile < 0) {
auto hFile = kopenFileReader(cinpalfname[nPal], 1);
if (!hFile.isOpen()) {
return -2;
}
kread(hFile, cinemapal, sizeof(cinemapal));
hFile.Read(cinemapal, sizeof(cinemapal));
for (auto &c : cinemapal)
c <<= 2;
kclose(hFile);
return nPal;
}
@ -1958,7 +1950,9 @@ uint8_t AdvanceCinemaText()
{
HandleAsync();
if (KB_KeyDown[sc_Escape] || KB_KeyDown[sc_Return] || KB_KeyDown[sc_Space]) {
if (I_AdvanceTrigger())
{
I_AdvanceTriggerClear();
break;
}
@ -2229,7 +2223,7 @@ int FindGString(const char *str)
uint8_t CheckForEscape()
{
if (!KB_KeyWaiting() || (KB_GetCh() != 27)) {
if (!inputState.keyBufferWaiting() || (inputState.keyGetChar() != 27)) {
return kFalse;
}
@ -2240,7 +2234,7 @@ void DoStatic(int a, int b)
{
RandomLong(); // nothing done with the result of this?
tileLoad(kTileLoboLaptop);
auto pixels = TileFiles.tileMakeWritable(kTileLoboLaptop);
int v2 = 160 - a / 2;
int v4 = 81 - b / 2;
@ -2248,7 +2242,7 @@ void DoStatic(int a, int b)
int var_18 = v2 + a;
int v5 = v4 + b;
uint8_t *pTile = (uint8_t*)(waloff[kTileLoboLaptop] + (200 * v2)) + v4;
auto pTile = (pixels + (200 * v2)) + v4;
while (v2 < var_18)
{
@ -2267,6 +2261,7 @@ void DoStatic(int a, int b)
v2++;
}
tileInvalidate(kTileLoboLaptop, 0, 0);
overwritesprite(0, 0, kTileLoboLaptop, 0, 2, kPalNormal);
videoNextPage();
}
@ -2285,17 +2280,17 @@ void DoLastLevelCinema()
PlayLocalSound(StaticSound[kSound75], 0);
tileLoad(kTileLoboLaptop);
memcpy((void*)waloff[kTileLoboLaptop], (void*)waloff[kTileLoboLaptop], tilesiz[kTileLoboLaptop].x * tilesiz[kTileLoboLaptop].y);
auto pixels = TileFiles.tileMakeWritable(kTileLoboLaptop);
// uh, what?
//memcpy((void*)waloff[kTileLoboLaptop], (void*)waloff[kTileLoboLaptop], tilesiz[kTileLoboLaptop].x * tilesiz[kTileLoboLaptop].y);
int var_24 = 16;
int var_28 = 12;
int nEndTime = (int)totalclock + 240;
while (KB_KeyWaiting()) {
KB_GetCh();
while (inputState.keyBufferWaiting()) {
inputState.keyGetChar();
}
while (nEndTime > (int)totalclock)
@ -2315,10 +2310,6 @@ void DoLastLevelCinema()
DoStatic(var_28, var_24);
}
// loadtilelockmode = 1;
tileLoad(kTileLoboLaptop);
// loadtilelockmode = 0;
// loc_3AD75
do
@ -2330,8 +2321,6 @@ LABEL_11:
int esi = nString;
tileLoad(kTileLoboLaptop);
while (strlen(gString[esi]) != 0)
esi++;
@ -2356,6 +2345,7 @@ LABEL_11:
nString++;
TileFiles.tileMakeWritable(kTileLoboLaptop);
while (*nChar)
{
HandleAsync();
@ -2380,8 +2370,8 @@ LABEL_11:
nString++;
KB_FlushKeyboardQueue();
KB_ClearKeysDown();
inputState.keyFlushChars();
inputState.ClearAllKeyStatus();
int v11 = kTimerTicks * (var_1C + 2) + (int)totalclock;
@ -2391,9 +2381,9 @@ LABEL_11:
if (v11 <= (int)totalclock)
goto LABEL_11;
} while (!KB_KeyWaiting());
} while (!inputState.keyBufferWaiting());
}
while (KB_GetCh() != 27);
while (inputState.keyGetChar() != 27);
LABEL_28:
PlayLocalSound(StaticSound[kSound75], 0);

View file

@ -27,6 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "baselayer.h"
#include "typedefs.h"
#include "keyboard.h"
#include "cache1d.h"
BEGIN_PS_NS
@ -55,7 +56,7 @@ int serve_sample()
palette_t moviepal[256];
int ReadFrame(FILE *fp)
int ReadFrame(FileReader &fp)
{
static int nFrame = 0;
Printf("Reading frame %d...\n", nFrame);
@ -71,11 +72,11 @@ int ReadFrame(FILE *fp)
while (1)
{
if (fread(&nType, 1, sizeof(nType), fp) == 0) {
if (fp.Read(&nType, sizeof(nType)) == 0) {
return 0;
}
fread(&nSize, sizeof(nSize), 1, fp);
fp.Read(&nSize, sizeof(nSize));
nType--;
if (nType > 3) {
@ -86,8 +87,8 @@ int ReadFrame(FILE *fp)
{
case kFramePalette:
{
fread(palette, sizeof(palette[0]), sizeof(palette) / sizeof(palette[0]), fp);
fread(&var_1C, sizeof(var_1C), 1, fp);
fp.Read(palette, sizeof(palette));
fp.Read(&var_1C, sizeof(var_1C));
for (auto &c : palette)
c <<= 2;
@ -102,7 +103,7 @@ int ReadFrame(FILE *fp)
{
Printf("Reading sound block size %d...\n", nSize);
// TODO - just skip for now
fseek(fp, nSize, SEEK_CUR);
fp.Seek(nSize, FileReader::SeekCur);
continue;
}
case kFrameImage:
@ -114,22 +115,22 @@ int ReadFrame(FILE *fp)
uint8_t *pFrame = CurFrame;
int nRead = fread(&yOffset, 1, sizeof(yOffset), fp);
int nRead = fp.Read(&yOffset, sizeof(yOffset));
nSize -= nRead;
pFrame += yOffset * 200; // row position
while (nSize > 0)
{
fread(&xOffset, sizeof(xOffset), 1, fp);
fread(&nPixels, sizeof(nPixels), 1, fp);
fp.Read(&xOffset, sizeof(xOffset));
fp.Read(&nPixels, sizeof(nPixels));
nSize -= 2;
pFrame += xOffset;
if (nPixels)
{
int nRead = fread(pFrame, 1, nPixels, fp);
int nRead = fp.Read(pFrame, nPixels);
pFrame += nRead;
nSize -= nRead;
}
@ -150,11 +151,12 @@ int ReadFrame(FILE *fp)
void PlayMovie(const char *fileName)
{
char buffer[256];
int bDoFade = 1;
if (bNoCDCheck)
#if 0 // What's the point of preserving this? Let's just read the movie from the game directory and ignore the other locations!
char buffer[256];
if (bNoCDCheck)
{
sprintf(buffer, "C:\\PS\\%s", fileName);
}
@ -167,10 +169,7 @@ void PlayMovie(const char *fileName)
sprintf(buffer, "%c:%s", driveLetter, fileName);
}
tileLoad(kMovieTile);
CurFrame = (uint8_t*)waloff[kMovieTile];
FILE *fp = fopen(buffer, "rb");
FILE *fp = fopen(buffer, "rb");
if (fp == NULL)
{
Printf("Can't open movie file '%s' on CD-ROM\n", buffer);
@ -181,16 +180,28 @@ void PlayMovie(const char *fileName)
return;
}
}
#else
auto fp = kopenFileReader(fileName, 0);
if (!fp.isOpen())
{
Printf("Unable to open %s\n", fileName);
return;
}
#endif
fread(lh, sizeof(lh), 1, fp);
tileLoad(kMovieTile);
CurFrame = TileFiles.tileMakeWritable(kMovieTile);
fp.Read(lh, sizeof(lh));
memset(streambuf, 0, sizeof(streambuf));
memset(byte_1C6DF5, 0, sizeof(byte_1C6DF5));
// sound stuff
// clear keys
KB_FlushKeyboardQueue();
KB_ClearKeysDown();
inputState.keyFlushChars();
inputState.ClearAllKeyStatus();
if (bDoFade) {
StartFadeIn();
@ -203,7 +214,7 @@ void PlayMovie(const char *fileName)
if (ReadFrame(fp))
{
while (!KB_KeyWaiting())
while (!inputState.keyBufferWaiting())
{
handleevents();
@ -231,10 +242,8 @@ void PlayMovie(const char *fileName)
}
}
if (KB_KeyWaiting()) {
KB_GetCh();
if (inputState.keyBufferWaiting()) {
inputState.keyGetChar();
}
fclose(fp);
}
END_PS_NS

View file

@ -29,20 +29,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "config.h"
#include "osdcmds.h"
#include "vfs.h"
BEGIN_PS_NS
static inline int osdcmd_quit(osdcmdptr_t UNUSED(parm))
{
UNREFERENCED_CONST_PARAMETER(parm);
OSD_ShowDisplay(0);
ShutDown();
return OSDCMD_OK;
}
int osdcmd_restartvid(osdcmdptr_t UNUSED(parm))
{
UNREFERENCED_CONST_PARAMETER(parm);
@ -103,219 +92,14 @@ static int osdcmd_vidmode(osdcmdptr_t parm)
return OSDCMD_OK;
}
static int osdcmd_addpath(osdcmdptr_t parm)
{
if (parm->numparms != 1)
return OSDCMD_SHOWHELP;
addsearchpath(parm->parms[0]);
return OSDCMD_OK;
}
static int osdcmd_initgroupfile(osdcmdptr_t parm)
{
if (parm->numparms != 1)
return OSDCMD_SHOWHELP;
initgroupfile(parm->parms[0]);
return OSDCMD_OK;
}
void onvideomodechange(int32_t newmode)
{
uint8_t palid = BASEPAL;
videoSetPalette(0, palid, 0);
}
static int osdcmd_button(osdcmdptr_t parm)
{
static char const s_gamefunc_[] = "gamefunc_";
int constexpr strlen_gamefunc_ = ARRAY_SIZE(s_gamefunc_) - 1;
char const *p = parm->name + strlen_gamefunc_;
// if (g_player[myconnectindex].ps->gm == MODE_GAME) // only trigger these if in game
CONTROL_ButtonFlags[CONFIG_FunctionNameToNum(p)] = 1; // FIXME
return OSDCMD_OK;
}
static int osdcmd_cvar_set_game(osdcmdptr_t parm)
{
int const r = osdcmd_cvar_set(parm);
if (r != OSDCMD_OK) return r;
if (!Bstrcasecmp(parm->name, "r_maxfps") || !Bstrcasecmp(parm->name, "r_maxfpsoffset"))
{
if (r_maxfps != 0) r_maxfps = clamp(r_maxfps, 30, 1000);
g_frameDelay = calcFrameDelay(r_maxfps + r_maxfpsoffset);
}
if (!Bstrcasecmp(parm->name, "in_mouse"))
{
CONTROL_MouseEnabled = (gSetup.usemouse && CONTROL_MousePresent);
}
else if (!Bstrcasecmp(parm->name, "in_joystick"))
{
CONTROL_JoystickEnabled = (gSetup.usejoystick && CONTROL_JoyPresent);
}
return r;
}
int32_t registerosdcommands(void)
{
char tempbuf[256];
static osdcvardata_t cvars_game[] =
{
// TODO:
//{ "benchmarkmode", "Set the benchmark mode (0: off, 1: performance test, 2: generate reference screenshots for correctness testing)", (void *) &g_BenchmarkMode, CVAR_INT|CVAR_NOSAVE, 0, 2 },
//{ "crosshair", "enable/disable crosshair", (void *)&ud.crosshair, CVAR_BOOL, 0, 1 },
//{ "cl_autoaim", "enable/disable weapon autoaim", (void *)&ud.config.AutoAim, CVAR_INT|CVAR_MULTI, 0, 3 },
//{ "cl_automsg", "enable/disable automatically sending messages to all players", (void *)&ud.automsg, CVAR_BOOL, 0, 1 },
{ "cl_autorun", "enable/disable autorun", (void *)&auto_run, CVAR_BOOL, 0, 1 },
//{ "cl_autosave", "enable/disable autosaves", (void *) &ud.autosave, CVAR_BOOL, 0, 1 },
//{ "cl_autosavedeletion", "enable/disable automatic deletion of autosaves", (void *) &ud.autosavedeletion, CVAR_BOOL, 0, 1 },
//{ "cl_maxautosaves", "number of autosaves to keep before deleting the oldest", (void *) &ud.maxautosaves, CVAR_INT, 1, 100 },
//{ "cl_autovote", "enable/disable automatic voting", (void *)&ud.autovote, CVAR_INT, 0, 2 },
//{ "cl_cheatmask", "configure what cheats show in the cheats menu", (void *)&cl_cheatmask, CVAR_UINT, 0, ~0 },
//{ "cl_obituaries", "enable/disable multiplayer death messages", (void *)&ud.obituaries, CVAR_BOOL, 0, 1 },
//{ "cl_democams", "enable/disable demo playback cameras", (void *)&ud.democams, CVAR_BOOL, 0, 1 },
//{ "cl_idplayers", "enable/disable name display when aiming at opponents", (void *)&ud.idplayers, CVAR_BOOL, 0, 1 },
{ "cl_runmode", "enable/disable modernized run key operation", (void *)&runkey_mode, CVAR_BOOL, 0, 1 },
// { "cl_showcoords", "show your position in the game world", (void *)&ud.coords, CVAR_INT, 0,
//#ifdef USE_OPENGL
// 2
//#else
// 1
//#endif
// },
//{ "cl_viewbob", "enable/disable player head bobbing", (void *)&ud.viewbob, CVAR_BOOL, 0, 1 },
//{ "cl_weaponsway", "enable/disable player weapon swaying", (void *)&ud.weaponsway, CVAR_BOOL, 0, 1 },
//{ "cl_weaponswitch", "enable/disable auto weapon switching", (void *)&ud.weaponswitch, CVAR_INT|CVAR_MULTI, 0, 7 },
//{ "color", "changes player palette", (void *)&ud.color, CVAR_INT|CVAR_MULTI, 0, MAXPALOOKUPS-1 },
//{ "crosshairscale","changes the size of the crosshair", (void *)&ud.crosshairscale, CVAR_INT, 10, 100 },
//{ "demorec_diffs","enable/disable diff recording in demos",(void *)&demorec_diffs_cvar, CVAR_BOOL, 0, 1 },
//{ "demorec_force","enable/disable forced demo recording",(void *)&demorec_force_cvar, CVAR_BOOL|CVAR_NOSAVE, 0, 1 },
//{
// "demorec_difftics","sets game tic interval after which a diff is recorded",
// (void *)&demorec_difftics_cvar, CVAR_INT, 2, 60*REALGAMETICSPERSEC
//},
//{ "demorec_diffcompress","Compression method for diffs. (0: none, 1: KSLZW)",(void *)&demorec_diffcompress_cvar, CVAR_BOOL, 0, 1 },
//{ "demorec_synccompress","Compression method for input. (0: none, 1: KSLZW)",(void *)&demorec_synccompress_cvar, CVAR_BOOL, 0, 1 },
//{ "demorec_seeds","enable/disable recording of random seed for later sync checking",(void *)&demorec_seeds_cvar, CVAR_BOOL, 0, 1 },
//{ "demoplay_diffs","enable/disable application of diffs in demo playback",(void *)&demoplay_diffs, CVAR_BOOL, 0, 1 },
//{ "demoplay_showsync","enable/disable display of sync status",(void *)&demoplay_showsync, CVAR_BOOL, 0, 1 },
//{ "fov", "change the field of view", (void *)&ud.fov, CVAR_INT|CVAR_FUNCPTR, 60, 120 },
//{ "hud_althud", "enable/disable alternate mini-hud", (void *)&ud.althud, CVAR_BOOL, 0, 1 },
//{ "hud_custom", "change the custom hud", (void *)&ud.statusbarcustom, CVAR_INT, 0, ud.statusbarrange },
//{ "hud_position", "aligns the status bar to the bottom/top", (void *)&ud.hudontop, CVAR_BOOL, 0, 1 },
//{ "hud_bgstretch", "enable/disable background image stretching in wide resolutions", (void *)&ud.bgstretch, CVAR_BOOL, 0, 1 },
//{ "hud_messagetime", "length of time to display multiplayer chat messages", (void *)&ud.msgdisptime, CVAR_INT, 0, 3600 },
//{ "hud_numbertile", "first tile in alt hud number set", (void *)&althud_numbertile, CVAR_INT, 0, MAXUSERTILES-10 },
//{ "hud_numberpal", "pal for alt hud numbers", (void *)&althud_numberpal, CVAR_INT, 0, MAXPALOOKUPS-1 },
//{ "hud_shadows", "enable/disable althud shadows", (void *)&althud_shadows, CVAR_BOOL, 0, 1 },
//{ "hud_flashing", "enable/disable althud flashing", (void *)&althud_flashing, CVAR_BOOL, 0, 1 },
//{ "hud_glowingquotes", "enable/disable \"glowing\" quote text", (void *)&hud_glowingquotes, CVAR_BOOL, 0, 1 },
//{ "hud_scale","changes the hud scale", (void *)&ud.statusbarscale, CVAR_INT|CVAR_FUNCPTR, 36, 100 },
//{ "hud_showmapname", "enable/disable map name display on load", (void *)&hud_showmapname, CVAR_BOOL, 0, 1 },
//{ "hud_stats", "enable/disable level statistics display", (void *)&ud.levelstats, CVAR_BOOL, 0, 1 },
//{ "hud_textscale", "sets multiplayer chat message size", (void *)&ud.textscale, CVAR_INT, 100, 400 },
//{ "hud_weaponscale","changes the weapon scale", (void *)&ud.weaponscale, CVAR_INT, 10, 100 },
//{ "hud_statusbarmode", "change overlay mode of status bar", (void *)&ud.statusbarmode, CVAR_BOOL|CVAR_FUNCPTR, 0, 1 },
//#ifdef EDUKE32_TOUCH_DEVICES
// { "hud_hidestick", "hide the touch input stick", (void *)&droidinput.hideStick, CVAR_BOOL, 0, 1 },
//#endif
{ "in_joystick","enables input from the joystick if it is present",(void *)&gSetup.usejoystick, CVAR_BOOL|CVAR_FUNCPTR, 0, 1 },
{ "in_mouse","enables input from the mouse if it is present",(void *)&gSetup.usemouse, CVAR_BOOL|CVAR_FUNCPTR, 0, 1 },
{ "in_aimmode", "0:toggle, 1:hold to aim", (void *)&mouseaiming, CVAR_BOOL, 0, 1 },
{
"in_mousebias", "emulates the original mouse code's weighting of input towards whichever axis is moving the most at any given time",
(void *)&MouseBias, CVAR_INT, 0, 32
},
{ "in_mousedeadzone", "amount of mouse movement to filter out", (void *)&MouseDeadZone, CVAR_INT, 0, 512 },
{ "in_mouseflip", "invert vertical mouse movement", (void *)&mouseflip, CVAR_BOOL, 0, 1 },
{ "in_mousemode", "toggles vertical mouse view", (void *)&aimmode, CVAR_BOOL, 0, 1 },
{ "in_mousesmoothing", "enable/disable mouse input smoothing", (void *)&SmoothInput, CVAR_BOOL, 0, 1 },
//{ "mus_enabled", "enables/disables music", (void *)&ud.config.MusicToggle, CVAR_BOOL, 0, 1 },
//{ "mus_volume", "controls music volume", (void *)&ud.config.MusicVolume, CVAR_INT, 0, 255 },
//{ "osdhightile", "enable/disable hires art replacements for console text", (void *)&osdhightile, CVAR_BOOL, 0, 1 },
//{ "osdscale", "adjust console text size", (void *)&osdscale, CVAR_FLOAT|CVAR_FUNCPTR, 1, 4 },
//{ "r_camrefreshdelay", "minimum delay between security camera sprite updates, 120 = 1 second", (void *)&ud.camera_time, CVAR_INT, 1, 240 },
//{ "r_drawweapon", "enable/disable weapon drawing", (void *)&ud.drawweapon, CVAR_INT, 0, 2 },
{ "r_showfps", "show the frame rate counter", (void *)&r_showfps, CVAR_INT, 0, 3 },
//{ "r_showfpsperiod", "time in seconds before averaging min and max stats for r_showfps 2+", (void *)&ud.frameperiod, CVAR_INT, 0, 5 },
//{ "r_shadows", "enable/disable sprite and model shadows", (void *)&ud.shadows, CVAR_BOOL, 0, 1 },
//{ "r_size", "change size of viewable area", (void *)&ud.screen_size, CVAR_INT|CVAR_FUNCPTR, 0, 64 },
//{ "r_rotatespritenowidescreen", "pass bit 1024 to all CON rotatesprite calls", (void *)&g_rotatespriteNoWidescreen, CVAR_BOOL|CVAR_FUNCPTR, 0, 1 },
//{ "r_upscalefactor", "increase performance by rendering at upscalefactor less than the screen resolution and upscale to the full resolution in the software renderer", (void *)&ud.detail, CVAR_INT|CVAR_FUNCPTR, 1, 16 },
{ "r_precache", "enable/disable the pre-level caching routine", (void *)&useprecache, CVAR_BOOL, 0, 1 },
// { "r_ambientlight", "sets the global map light level",(void *)&r_ambientlight, CVAR_FLOAT|CVAR_FUNCPTR, 0, 10 },
{ "r_maxfps", "limit the frame rate",(void *)&r_maxfps, CVAR_INT|CVAR_FUNCPTR, 0, 1000 },
{ "r_maxfpsoffset", "menu-controlled offset for r_maxfps",(void *)&r_maxfpsoffset, CVAR_INT|CVAR_FUNCPTR, -10, 10 },
{ "sensitivity","changes the mouse sensitivity", (void *)&CONTROL_MouseSensitivity, CVAR_FLOAT|CVAR_FUNCPTR, 0, 25 },
//{ "skill","changes the game skill setting", (void *)&ud.m_player_skill, CVAR_INT|CVAR_FUNCPTR|CVAR_NOSAVE/*|CVAR_NOMULTI*/, 0, 5 },
//{ "snd_ambience", "enables/disables ambient sounds", (void *)&ud.config.AmbienceToggle, CVAR_BOOL, 0, 1 },
//{ "snd_enabled", "enables/disables sound effects", (void *)&ud.config.SoundToggle, CVAR_BOOL, 0, 1 },
//{ "snd_fxvolume", "controls volume for sound effects", (void *)&ud.config.FXVolume, CVAR_INT, 0, 255 },
//{ "snd_mixrate", "sound mixing rate", (void *)&ud.config.MixRate, CVAR_INT, 0, 48000 },
//{ "snd_numchannels", "the number of sound channels", (void *)&ud.config.NumChannels, CVAR_INT, 0, 2 },
//{ "snd_numvoices", "the number of concurrent sounds", (void *)&ud.config.NumVoices, CVAR_INT, 1, 128 },
//{ "snd_reversestereo", "reverses the stereo channels", (void *)&ud.config.ReverseStereo, CVAR_BOOL, 0, 1 },
//{ "snd_speech", "enables/disables player speech", (void *)&ud.config.VoiceToggle, CVAR_INT, 0, 5 },
//{ "team","change team in multiplayer", (void *)&ud.team, CVAR_INT|CVAR_MULTI, 0, 3 },
{ "vid_gamma","adjusts gamma component of gamma ramp",(void *)&g_videoGamma, CVAR_FLOAT|CVAR_FUNCPTR, 0, 10 },
{ "vid_contrast","adjusts contrast component of gamma ramp",(void *)&g_videoContrast, CVAR_FLOAT|CVAR_FUNCPTR, 0, 10 },
{ "vid_brightness","adjusts brightness component of gamma ramp",(void *)&g_videoBrightness, CVAR_FLOAT|CVAR_FUNCPTR, 0, 10 },
//{ "wchoice","sets weapon autoselection order", (void *)ud.wchoice, CVAR_STRING|CVAR_FUNCPTR, 0, MAX_WEAPONS },
};
//osdcmd_cheatsinfo_stat.cheatnum = -1;
for (auto & cv : cvars_game)
{
switch (cv.flags & (CVAR_FUNCPTR|CVAR_MULTI))
{
case CVAR_FUNCPTR:
OSD_RegisterCvar(&cv, osdcmd_cvar_set_game); break;
//case CVAR_MULTI:
//case CVAR_FUNCPTR|CVAR_MULTI:
// OSD_RegisterCvar(&cv, osdcmd_cvar_set_multi); break;
default:
OSD_RegisterCvar(&cv, osdcmd_cvar_set); break;
}
}
//if (VOLUMEONE)
// OSD_RegisterFunction("changelevel","changelevel <level>: warps to the given level", osdcmd_changelevel);
//else
@ -325,33 +109,14 @@ int32_t registerosdcommands(void)
// OSD_RegisterFunction("demo","demo <demofile or demonum>: starts the given demo", osdcmd_demo);
//}
OSD_RegisterFunction("addpath","addpath <path>: adds path to game filesystem", osdcmd_addpath);
OSD_RegisterFunction("bind",R"(bind <key> <string>: associates a keypress with a string of console input. Type "bind showkeys" for a list of keys and "listsymbols" for a list of valid console commands.)", osdcmd_bind);
//OSD_RegisterFunction("cmenu","cmenu <#>: jumps to menu", osdcmd_cmenu);
//OSD_RegisterFunction("crosshaircolor","crosshaircolor: changes the crosshair color", osdcmd_crosshaircolor);
for (auto & func : gamefunctions)
{
if (func[0] == '\0')
continue;
// if (!Bstrcmp(gamefunctions[i],"Show_Console")) continue;
Bsprintf(tempbuf, "gamefunc_%s", func);
char *const t = Bstrtolower(Xstrdup(tempbuf));
Bstrcat(tempbuf, ": game button");
OSD_RegisterFunction(t, Xstrdup(tempbuf), osdcmd_button);
}
//OSD_RegisterFunction("give","give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item", osdcmd_give);
//OSD_RegisterFunction("god","god: toggles god mode", osdcmd_god);
//OSD_RegisterFunction("activatecheat","activatecheat <id>: activates a cheat code", osdcmd_activatecheat);
OSD_RegisterFunction("initgroupfile","initgroupfile <path>: adds a grp file into the game filesystem", osdcmd_initgroupfile);
//OSD_RegisterFunction("restartmap", "restartmap: restarts the current map", osdcmd_restartmap);
//OSD_RegisterFunction("restartsound","restartsound: reinitializes the sound system",osdcmd_restartsound);
OSD_RegisterFunction("restartvid","restartvid: reinitializes the video mode",osdcmd_restartvid);

View file

@ -49,6 +49,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "cdaudio.h"
#include "map.h"
#include "sound.h"
#include "textures.h"
#include <assert.h>
#include <stdio.h>
#include <string.h>
@ -160,29 +161,29 @@ fixed droll;
void PlayerInterruptKeys()
{
ControlInfo info;
CONTROL_ProcessBinds();
memset(&info, 0, sizeof(ControlInfo)); // this is done within CONTROL_GetInput() anyway
memset(&info, 0, sizeof(ControlInfo)); // this is done within CONTROL_GetInput() anyway
CONTROL_GetInput(&info);
D_ProcessEvents();
if (MouseDeadZone)
if (in_mousedeadzone)
{
if (info.mousey > 0)
info.mousey = max(info.mousey - MouseDeadZone, 0);
info.mousey = max(info.mousey - in_mousedeadzone, 0);
else if (info.mousey < 0)
info.mousey = min(info.mousey + MouseDeadZone, 0);
info.mousey = min(info.mousey + in_mousedeadzone, 0);
if (info.mousex > 0)
info.mousex = max(info.mousex - MouseDeadZone, 0);
info.mousex = max(info.mousex - in_mousedeadzone, 0);
else if (info.mousex < 0)
info.mousex = min(info.mousex + MouseDeadZone, 0);
info.mousex = min(info.mousex + in_mousedeadzone, 0);
}
if (MouseBias)
if (in_mousebias)
{
if (klabs(info.mousex) > klabs(info.mousey))
info.mousey = tabledivide32_noinline(info.mousey, MouseBias);
info.mousey = tabledivide32_noinline(info.mousey, in_mousebias);
else
info.mousex = tabledivide32_noinline(info.mousex, MouseBias);
info.mousex = tabledivide32_noinline(info.mousex, in_mousebias);
}
if (PlayerList[nLocalPlayer].nHealth == 0)
@ -194,7 +195,7 @@ void PlayerInterruptKeys()
}
// JBF: Run key behaviour is selectable
int const playerRunning = (runkey_mode) ? (buttonMap.ButtonDown(gamefunc_Run) | auto_run) : (auto_run ^ buttonMap.ButtonDown(gamefunc_Run));
int const playerRunning = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run));
int const turnAmount = playerRunning ? 12 : 8;
int const keyMove = playerRunning ? 12 : 6;
constexpr int const analogTurnAmount = 12;
@ -217,12 +218,12 @@ void PlayerInterruptKeys()
q16avel += fix16_from_int(info.dyaw) / analogExtent * (analogTurnAmount << 1);
}
if (aimmode)
if (g_MyAimMode)
q16horz = fix16_div(fix16_from_int(info.mousey), F16(64));
else
fvel = -(info.mousey >> 6);
if (mouseflip) q16horz = -q16horz;
if (!in_mouseflip) q16horz = -q16horz;
q16horz -= fix16_from_int(info.dpitch) / analogExtent * analogTurnAmount;
svel -= info.dx * keyMove / analogExtent;
@ -607,9 +608,9 @@ void InitPlayerInventory(short nPlayer)
nPlayerScore[nPlayer] = 0;
tileLoad(kTile3571 + nPlayer);
auto pixels = tilePtr(kTile3571 + nPlayer);
nPlayerColor[nPlayer] = *(uint8_t*)(waloff[nPlayer + kTile3571] + tilesiz[nPlayer + kTile3571].x * tilesiz[nPlayer + kTile3571].y / 2);
nPlayerColor[nPlayer] = pixels[tilesiz[nPlayer + kTile3571].x * tilesiz[nPlayer + kTile3571].y / 2];
}
// done
@ -2850,7 +2851,7 @@ do_default_b:
FinishLevel();
}
else {
keySetState(32, 1);
inputState.keySetState(32, 1);
}
DestroyItemAnim(nValB);
@ -3137,13 +3138,13 @@ do_default_b:
bPlayerPan = kFalse;
}
if (aimmode)
if (g_MyAimMode)
bLockPan = kTrue;
// loc_1C05E
fix16_t ecx = nDestVertPan[nPlayer] - nVertPan[nPlayer];
if (aimmode)
if (g_MyAimMode)
{
ecx = 0;
}

View file

@ -166,35 +166,32 @@ int seq_ReadSequence(const char *seqName)
strcat(buffer, seqName);
strcat(buffer, ".seq");
int hFile = kopen4load(buffer, 1);
if (hFile == -1)
auto hFile = kopenFileReader(buffer, 1);
if (!hFile.isOpen())
{
initprintf("Unable to open '%s'!\n", buffer);
kclose(hFile);
return 0;
}
short tag;
kread(hFile, &tag, sizeof(tag));
hFile.Read(&tag, sizeof(tag));
if (tag < 'HI' || tag > 'HI' && tag != 'SD')
{
initprintf("Unsupported sequence version!\n");
kclose(hFile);
return 0;
}
short centerx, centery; // TODO - are global vars?
short nSeqs;
kread(hFile, &centerx, sizeof(centerx));
kread(hFile, &centery, sizeof(centery));
kread(hFile, &nSeqs, sizeof(nSeqs));
hFile.Read(&centerx, sizeof(centerx));
hFile.Read(&centery, sizeof(centery));
hFile.Read(&nSeqs, sizeof(nSeqs));
if (nSeqs <= 0 || sequences + nSeqs >= kMaxSequences)
{
if (nSeqs < 0)
{
initprintf("Invalid sequence count!\n");
kclose(hFile);
return 0;
}
else {
@ -202,9 +199,9 @@ int seq_ReadSequence(const char *seqName)
}
}
kread(hFile, &SeqBase[sequences], nSeqs * sizeof(SeqBase[0]));
kread(hFile, &SeqSize[sequences], nSeqs * sizeof(SeqSize[0]));
kread(hFile, &SeqFlag[sequences], nSeqs * sizeof(SeqFlag[0]));
hFile.Read(&SeqBase[sequences], nSeqs * sizeof(SeqBase[0]));
hFile.Read(&SeqSize[sequences], nSeqs * sizeof(SeqSize[0]));
hFile.Read(&SeqFlag[sequences], nSeqs * sizeof(SeqFlag[0]));
for (i = 0; i < nSeqs; i++)
{
@ -214,14 +211,13 @@ int seq_ReadSequence(const char *seqName)
short vdi = frames;
int16_t nFrames;
kread(hFile, &nFrames, sizeof(nFrames));
hFile.Read(&nFrames, sizeof(nFrames));
if (nFrames <= 0 || frames + nFrames >= kMaxSEQFrames)
{
if (nFrames < 0 )
{
initprintf("Invalid frame count!\n");
kclose(hFile);
return 0;
}
else {
@ -229,9 +225,9 @@ int seq_ReadSequence(const char *seqName)
}
}
kread(hFile, &FrameBase[frames], nFrames * sizeof(FrameBase[0]));
kread(hFile, &FrameSize[frames], nFrames * sizeof(FrameSize[0]));
kread(hFile, &FrameFlag[frames], nFrames * sizeof(FrameFlag[0]));
hFile.Read(&FrameBase[frames], nFrames * sizeof(FrameBase[0]));
hFile.Read(&FrameSize[frames], nFrames * sizeof(FrameSize[0]));
hFile.Read(&FrameFlag[frames], nFrames * sizeof(FrameFlag[0]));
memset(&FrameSound[frames], -1, nFrames * sizeof(FrameSound[0]));
for (i = 0; i < nFrames; i++)
@ -240,14 +236,13 @@ int seq_ReadSequence(const char *seqName)
}
int16_t nChunks;
kread(hFile, &nChunks, sizeof(nChunks));
hFile.Read(&nChunks, sizeof(nChunks));
if (nChunks < 0 || chunks + nChunks >= kMaxSEQChunks)
{
if (nChunks < 0 )
{
initprintf("Invalid chunk count!\n");
kclose(hFile);
return 0;
}
else {
@ -255,10 +250,10 @@ int seq_ReadSequence(const char *seqName)
}
}
kread(hFile, &ChunkXpos[chunks], nChunks * sizeof(ChunkXpos[0]));
kread(hFile, &ChunkYpos[chunks], nChunks * sizeof(ChunkYpos[0]));
kread(hFile, &ChunkPict[chunks], nChunks * sizeof(ChunkPict[0]));
kread(hFile, &ChunkFlag[chunks], nChunks * sizeof(ChunkFlag[0]));
hFile.Read(&ChunkXpos[chunks], nChunks * sizeof(ChunkXpos[0]));
hFile.Read(&ChunkYpos[chunks], nChunks * sizeof(ChunkYpos[0]));
hFile.Read(&ChunkPict[chunks], nChunks * sizeof(ChunkPict[0]));
hFile.Read(&ChunkFlag[chunks], nChunks * sizeof(ChunkFlag[0]));
for (i = 0; i < nChunks; i++)
{
@ -275,21 +270,21 @@ int seq_ReadSequence(const char *seqName)
if (tag == 'SD')
{
short var_20;
kread(hFile, &var_20, sizeof(var_20));
hFile.Read(&var_20, sizeof(var_20));
for (i = 0; i < var_20; i++)
{
kread(hFile, &buffer[i * 10], 8);
hFile.Read(&buffer[i * 10], 8);
}
short var_24;
kread(hFile, &var_24, sizeof(var_24));
hFile.Read(&var_24, sizeof(var_24));
for (i = 0; i < var_24; i++)
{
short var_28, var_2C;
kread(hFile, &var_28, sizeof(var_28));
kread(hFile, &var_2C, sizeof(var_2C));
hFile.Read(&var_28, sizeof(var_28));
hFile.Read(&var_2C, sizeof(var_2C));
int hSound = LoadSound(&buffer[(var_2C&0x1FF)*10]);
@ -297,7 +292,6 @@ int seq_ReadSequence(const char *seqName)
}
}
kclose(hFile);
return nSeqs;
}

View file

@ -293,7 +293,7 @@ void CalcASSPan(int nPan, int nVolume, int *pLeft, int *pRight)
*pRight = mulscale6(nPanTable[127-nPan], nVolume);
}
void ASSCallback(uint32_t num)
void ASSCallback(intptr_t num)
{
// TODO: add mutex?
if ((int32_t)num == -1)
@ -345,10 +345,10 @@ void InitFX(void)
dig = 0;
if (bNoSound)
if (!SoundEnabled())
return;
if (FX_Init(NumVoices, NumChannels, MixRate, initdata) != FX_Ok)
if (FX_Init(snd_numvoices, snd_numchannels, snd_mixrate, initdata) != FX_Ok)
{
Printf("Error initializing sound card!\n");
initprintf("Error initializing sound card!\n");
@ -395,70 +395,6 @@ void UnInitFX()
FX_Shutdown();
}
#if 0
void InitMusic()
{
if (bNoSound)
{
mdi = 0;
return;
}
mdi = AIL_install_MDI_INI();
if (!mdi)
{
initprintf("AIL_install midi failed\n");
return;
}
S = AIL_allocate_sequence_handle(mdi);
if (!S)
{
initprintf("Midi handle failed");
return;
}
}
void UnInitMusic()
{
if (mdi)
AIL_end_sequence(S);
}
void FadeSong()
{
AIL_set_sequence_volume(S, 0, 1000);
}
int LoadSong(const char *song)
{
FILE *f;
if (!mdi)
return 0;
AIL_end_sequence(S);
f = fopen(song, "rb");
if (!f)
{
sprintf(message_text, "Unable to midi open file '%s'!\n", song);
message_timer = 1000;
return 0;
}
if (fread(pMusicBuf, sizeof(pMusicBuf), 1, f) == sizeof(pMusicBuf))
{
sprintf(message_text, "Programmer error: not enough memory allocated for song file.\n");
message_timer = 1000;
fclose(f);
return 0;
}
fclose(f);
AIL_init_sequence(S, pMusicBuf, 0);
AIL_start_sequence(S);
AIL_set_sequence_loop_count(S, 0);
AIL_set_sequence_volume(S, gMusicVolume>>1, 0);
}
#else
void InitMusic()
{
}
@ -476,7 +412,6 @@ int LoadSong(const char *song)
UNREFERENCED_PARAMETER(song);
return 0;
}
#endif
int LoadSound(const char *sound)
{
@ -506,29 +441,28 @@ int LoadSound(const char *sound)
strcat(buffer, ".voc");
buildvfs_kfd hVoc = kopen4loadfrommod(buffer, 0);
auto hVoc = kopenFileReader(buffer, 0);
if (hVoc != buildvfs_kfd_invalid)
if (!hVoc.isOpen())
{
int nSize = kfilelength(hVoc);
SoundLock[i] = 255; // TODO: implement cache lock properly
int nSize = hVoc.GetLength();
//SoundLock[i] = 255; // crap we don't need.
SoundLen[i] = nSize;
g_cache.allocateBlock((intptr_t*)&SoundBuf[i], nSize, &SoundLock[i]);
cacheAllocateBlock((intptr_t*)&SoundBuf[i], nSize, nullptr);
if (!SoundBuf[i])
I_Error("Error allocating buf '%s' to %lld (size=%ld)!\n", buffer, (intptr_t)&SoundBuf[i], nSize);
if (kread(hVoc, SoundBuf[i], nSize) != nSize)
I_Error("Error reading '%s'!\n", buffer);
if (hVoc.Read(SoundBuf[i], nSize) != nSize)
Printf("Error reading '%s'!\n", buffer);
}
else
{
I_Error("Unable to open sound '%s'!\n", buffer);
Printf("Unable to open sound '%s'!\n", buffer);
SoundBuf[i] = NULL;
SoundLen[i] = 0;
//return hVoc;
return -1;
}
kclose(hVoc);
nSoundCount++;
return i;
}

View file

@ -41,6 +41,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "engine.h"
#include "trigdat.h"
#include "runlist.h"
#include "input.h"
#include <string.h>
BEGIN_PS_NS
@ -586,8 +587,9 @@ void DrawView(int smoothRatio)
}
else
{
if ((bSubTitles && !AdvanceCinemaText()) || KB_KeyDown[sc_Escape] || KB_KeyDown[sc_Return] || KB_KeyDown[sc_Space])
if ((bSubTitles && !AdvanceCinemaText()) || I_AdvanceTrigger())
{
I_AdvanceTriggerClear();
levelnew = levelnum + 1;
if (CDplaying())

View file

@ -56,22 +56,6 @@ BEGIN_SW_NS
int32_t NumberPlayers,CommPort,PortSpeed,IrqNumber,UartAddress;
//
// Sound variables
//
int32_t UseMouse = 1, UseJoystick = 0;
//
// Screen variables
//
/*
===================
=

View file

@ -68,7 +68,6 @@ extern char UserPath[MAXUSERLEVELPATHLENGTH];
#endif
// controller externs
extern int32_t UseMouse, UseJoystick;
extern int32_t EnableRudder;