Commit b8f18ac7 authored by Steven Fuller's avatar Steven Fuller

Part A of File IO Rewrite.

misc.c, misc.h: New functions which wrap around open/read/write/etc

id_ca.c: Updated to use these new functions.
parent faa76f57
......@@ -20,6 +20,7 @@ SD_StartMusic((MusicGroup *)audiosegs[STARTMUSIC + chunk]);
=>
SD_StartMusic(chunk);
------------------------------------------------------------------------------
* use int16_t, etc (stdint)
* serialize reads/writes
* fix fix fix different size stuff
works alright at some res, but breaks on most others currently
......
......@@ -3,14 +3,8 @@
typedef struct
{
/* 0-255 is a character, > is a pointer to a node */
word bit0, bit1;
} PACKED huffnode;
typedef struct
{
word RLEWtag;
long headeroffsets[100];
} PACKED mapfiletype;
int bit0, bit1;
} huffnode;
/*
=============================================================================
......@@ -20,13 +14,13 @@ typedef struct
=============================================================================
*/
static mapfiletype *tinf;
int RLEWtag;
int mapon;
word *mapsegs[MAPPLANES];
maptype *mapheaderseg[NUMMAPS];
byte *audiosegs[NUMSNDCHUNKS];
byte *grsegs[NUMCHUNKS];
word *mapsegs[MAPPLANES];
maptype *mapheaderseg[NUMMAPS];
byte *audiosegs[NUMSNDCHUNKS];
byte *grsegs[NUMCHUNKS];
char extension[5];
#define gheadname "vgahead."
......@@ -41,11 +35,11 @@ char extension[5];
static long *grstarts; /* array of offsets in vgagraph */
static long *audiostarts; /* array of offsets in audiot */
static huffnode grhuffman[255];
static huffnode grhuffman[256];
static int grhandle; /* handle to VGAGRAPH */
static int maphandle; /* handle to GAMEMAPS */
static int audiohandle; /* handle to AUDIOT */
static int grhandle = -1; /* handle to VGAGRAPH */
static int maphandle = -1; /* handle to GAMEMAPS */
static int audiohandle = -1; /* handle to AUDIOT */
/*
=============================================================================
......@@ -349,7 +343,7 @@ static void CAL_SetupGrFile()
long chunkcomplen;
byte *grtemp;
int i;
//
// load vgadict.ext (huffman dictionary for graphics files)
//
......@@ -357,11 +351,17 @@ static void CAL_SetupGrFile()
strcpy(fname, gdictname);
strcat(fname, extension);
if ((handle = open(fname, O_RDONLY | O_BINARY)) == -1)
handle = OpenRead(fname);
if (handle == -1)
CA_CannotOpen(fname);
read(handle, &grhuffman, sizeof(grhuffman));
close(handle);
for (i = 0; i < 256; i++) {
grhuffman[i].bit0 = ReadInt16(handle);
grhuffman[i].bit1 = ReadInt16(handle);
}
CloseRead(handle);
//
// load the data offsets from vgahead.ext
//
......@@ -371,39 +371,41 @@ static void CAL_SetupGrFile()
strcpy(fname, gheadname);
strcat(fname, extension);
if ((handle = open(fname, O_RDONLY | O_BINARY)) == -1)
handle = OpenRead(fname);
if (handle == -1)
CA_CannotOpen(fname);
CA_FarRead(handle, (memptr)grtemp, (NUMCHUNKS+1)*3);
ReadBytes(handle, grtemp, (NUMCHUNKS+1)*3);
for (i = 0; i < NUMCHUNKS+1; i++)
grstarts[i] = (grtemp[i*3+0]<<0)|(grtemp[i*3+1]<<8)|(grtemp[i*3+2]<<16);
MM_FreePtr((memptr)&grtemp);
close(handle);
CloseRead(handle);
//
// Open the graphics file, leaving it open until the game is finished
//
strcpy(fname, gfilename);
strcat(fname, extension);
grhandle = open(fname, O_RDONLY | O_BINARY);
grhandle = OpenRead(fname);
if (grhandle == -1)
CA_CannotOpen(fname);
//
// load the pic headers into pictable
//
MM_GetPtr((memptr)&pictable,NUMPICS*sizeof(pictabletype));
MM_GetPtr((memptr)&pictable, NUMPICS*sizeof(pictabletype));
chunkcomplen = grstarts[STRUCTPIC+1] - grstarts[STRUCTPIC];
lseek(grhandle, grstarts[STRUCTPIC], SEEK_SET);
ReadSeek(grhandle, grstarts[STRUCTPIC], SEEK_SET);
MM_GetPtr(&compseg, chunkcomplen);
CA_FarRead(grhandle,compseg,chunkcomplen);
CAL_HuffExpand(compseg+4, (byte *)pictable, NUMPICS*sizeof(pictabletype), grhuffman);
ReadBytes(grhandle, compseg, chunkcomplen);
CAL_HuffExpand((byte *)compseg+4, (byte *)pictable, NUMPICS*sizeof(pictabletype), grhuffman);
MM_FreePtr(&compseg);
}
......@@ -422,32 +424,24 @@ static void CAL_SetupMapFile()
{
int i;
int handle;
long length,pos;
long pos;
char fname[13];
//
// load maphead.ext (offsets and tileinfo for map file)
//
strcpy(fname, mheadname);
strcat(fname, extension);
if ((handle = open(fname, O_RDONLY | O_BINARY)) == -1)
handle = OpenRead(fname);
if (handle == -1)
CA_CannotOpen(fname);
length = filelength(handle);
MM_GetPtr((memptr)&tinf, length);
CA_FarRead(handle, (byte *)tinf, length);
close(handle);
RLEWtag = ReadInt16(handle);
//
// open the data file
//
/* open the data file */
strcpy(fname, gmapsname);
strcat(fname,extension);
strcat(fname, extension);
if ((maphandle = open(fname, O_RDONLY | O_BINARY)) == -1)
maphandle = OpenRead(fname);
if (maphandle == -1)
CA_CannotOpen(fname);
//
......@@ -455,18 +449,31 @@ static void CAL_SetupMapFile()
//
for (i = 0; i < NUMMAPS; i++)
{
pos = tinf->headeroffsets[i];
pos = ReadInt32(handle);
if (pos == 0) {
mapheaderseg[i] = NULL;
continue;
}
MM_GetPtr((memptr)&mapheaderseg[i], sizeof(maptype));
MM_SetLock((memptr)&mapheaderseg[i],true);
lseek(maphandle, pos, SEEK_SET);
CA_FarRead(maphandle, (memptr)mapheaderseg[i], sizeof(maptype));
MM_SetLock((memptr)&mapheaderseg[i], true);
ReadSeek(maphandle, pos, SEEK_SET);
mapheaderseg[i]->planestart[0] = ReadInt32(maphandle);
mapheaderseg[i]->planestart[1] = ReadInt32(maphandle);
mapheaderseg[i]->planestart[2] = ReadInt32(maphandle);
mapheaderseg[i]->planelength[0] = ReadInt16(maphandle);
mapheaderseg[i]->planelength[1] = ReadInt16(maphandle);
mapheaderseg[i]->planelength[2] = ReadInt16(maphandle);
mapheaderseg[i]->width = ReadInt16(maphandle);
mapheaderseg[i]->height = ReadInt16(maphandle);
ReadBytes(maphandle, (byte *)mapheaderseg[i]->name, 16);
}
CloseRead(handle);
//
// allocate space for 2 64*64 planes
//
......@@ -492,27 +499,31 @@ static void CAL_SetupAudioFile()
int handle;
long length;
char fname[13];
int i;
strcpy(fname, aheadname);
strcat(fname, extension);
/* load maphead.ext (offsets and tileinfo for map file) */
strcpy(fname,aheadname);
strcat(fname,extension);
if ((handle = open(fname, O_RDONLY | O_BINARY)) == -1)
handle = OpenRead(fname);
if (handle == -1)
CA_CannotOpen(fname);
length = ReadLength(handle);
MM_GetPtr((memptr)&audiostarts, length);
for (i = 0; i < (length/4); i++)
audiostarts[i] = ReadInt32(handle);
length = filelength(handle);
MM_GetPtr((memptr)&audiostarts,length);
CA_FarRead(handle, (byte *)audiostarts, length);
close(handle);
CloseRead(handle);
/* open the data file */
strcpy(fname,afilename);
strcat(fname,extension);
strcpy(fname, afilename);
strcat(fname, extension);
if ((audiohandle = open(fname, O_RDONLY | O_BINARY)) == -1)
audiohandle = OpenRead(fname);
if (audiohandle == -1)
CA_CannotOpen(fname);
}
......@@ -549,9 +560,9 @@ void CA_Startup()
void CA_Shutdown()
{
close(maphandle);
close(grhandle);
close(audiohandle);
CloseRead(maphandle);
CloseRead(grhandle);
CloseRead(audiohandle);
}
//===========================================================================
......@@ -568,9 +579,7 @@ void CA_CacheAudioChunk(int chunk)
{
long pos, length;
if (audiosegs[chunk])
{
MM_SetPurge((memptr)&audiosegs[chunk],0);
if (audiosegs[chunk]) {
return;
}
......@@ -581,16 +590,15 @@ void CA_CacheAudioChunk(int chunk)
pos = audiostarts[chunk];
length = audiostarts[chunk+1]-pos;
lseek(audiohandle, pos, SEEK_SET);
ReadSeek(audiohandle, pos, SEEK_SET);
MM_GetPtr((memptr)&audiosegs[chunk], length);
CA_FarRead(audiohandle,audiosegs[chunk], length);
ReadBytes(audiohandle, audiosegs[chunk], length);
}
void CA_UnCacheAudioChunk(int chunk)
{
/* TODO: For now the warning may be ignored since wl_menu.c causes it */
if (audiosegs[chunk] == 0) {
fprintf(stderr, "Trying to free null audio chunk %d!\n", chunk);
return;
......@@ -605,14 +613,12 @@ void CA_UnCacheAudioChunk(int chunk)
=
= CA_LoadAllSounds
=
= Purges all sounds, then loads all new ones (mode switch)
=
======================
*/
void CA_LoadAllSounds()
{
unsigned start, i;
int start, i;
for (start = STARTADLIBSOUNDS, i = 0; i < NUMSOUNDS; i++, start++)
CA_CacheAudioChunk(start);
......@@ -690,7 +696,7 @@ void CA_CacheGrChunk(int chunk)
byte *source;
/* this is due to Quit() wanting to cache the error screen before this has been set up! */
if ( (grhandle == 0) || (grhandle == -1) )
if (grhandle == -1)
return;
if (grsegs[chunk]) {
......@@ -704,10 +710,10 @@ void CA_CacheGrChunk(int chunk)
compressed = grstarts[chunk+1]-pos;
lseek(grhandle,pos,SEEK_SET);
ReadSeek(grhandle, pos, SEEK_SET);
MM_GetPtr((memptr)&source, compressed);
CA_FarRead(grhandle, source, compressed);
ReadBytes(grhandle, source, compressed);
CAL_ExpandGrChunk(chunk, source);
......@@ -776,7 +782,7 @@ void CA_CacheMap(int mapnum)
source++;
MM_GetPtr(&buffer2seg, expanded);
CAL_CarmackExpand(source, (word *)buffer2seg,expanded);
CA_RLEWexpand(((word *)buffer2seg)+1,*dest,size, tinf->RLEWtag);
CA_RLEWexpand(((word *)buffer2seg)+1,*dest,size, RLEWtag);
MM_FreePtr(&buffer2seg);
MM_FreePtr(&bigbufferseg);
......@@ -803,13 +809,13 @@ void MM_Shutdown()
void MM_GetPtr(memptr *baseptr, unsigned long size)
{
/* TODO: add some sort of linked list for purging */
/* add some sort of linked list for purging */
*baseptr = malloc(size);
}
void MM_FreePtr(memptr *baseptr)
{
/* TODO: add some sort of linked list for purging, etc */
/* add some sort of linked list for purging, etc */
free(*baseptr);
}
......@@ -828,8 +834,7 @@ void MM_SortMem()
static boolean PMStarted;
static int PageFile = -1;
word ChunksInFile;
word PMSpriteStart, PMSoundStart;
int ChunksInFile, PMSpriteStart, PMSoundStart;
PageListStruct *PMPages;
......@@ -842,9 +847,9 @@ static void PML_ReadFromFile(byte *buf, long offset, word length)
Quit("PML_ReadFromFile: Null pointer");
if (!offset)
Quit("PML_ReadFromFile: Zero offset");
if (lseek(PageFile, offset, SEEK_SET) != offset)
if (ReadSeek(PageFile, offset, SEEK_SET) != offset)
Quit("PML_ReadFromFile: Seek failed");
if (!CA_FarRead(PageFile ,buf, length))
if (ReadBytes(PageFile, buf, length) != length)
Quit("PML_ReadFromFile: Read failed");
}
......@@ -854,49 +859,34 @@ static void PML_ReadFromFile(byte *buf, long offset, word length)
static void PML_OpenPageFile()
{
int i;
long size;
void *buf;
longword *offsetptr;
word *lengthptr;
PageListStruct *page;
char fname[13];
strcpy(fname, pfilename);
strcat(fname, extension);
PageFile = open(fname, O_RDONLY | O_BINARY);
PageFile = OpenRead(fname);
if (PageFile == -1)
Quit("PML_OpenPageFile: Unable to open page file");
// Read in header variables
read(PageFile, &ChunksInFile, sizeof(ChunksInFile));
read(PageFile, &PMSpriteStart, sizeof(PMSpriteStart));
read(PageFile, &PMSoundStart, sizeof(PMSoundStart));
ChunksInFile = ReadInt16(PageFile);
PMSpriteStart = ReadInt16(PageFile);
PMSoundStart = ReadInt16(PageFile);
// Allocate and clear the page list
MM_GetPtr((memptr)&PMPages, sizeof(PageListStruct) * ChunksInFile);
MM_SetLock((memptr)&PMPages, true);
memset(PMPages, 0, sizeof(PageListStruct) * ChunksInFile);
// Read in the chunk offsets
size = sizeof(longword) * ChunksInFile;
MM_GetPtr(&buf, size);
if (!CA_FarRead(PageFile,(byte *)buf,size))
Quit("PML_OpenPageFile: Offset read failed");
offsetptr = (longword *)buf;
for (i = 0,page = PMPages;i < ChunksInFile;i++,page++)
page->offset = *offsetptr++;
MM_FreePtr(&buf);
for (i = 0, page = PMPages; i < ChunksInFile; i++, page++)
page->offset = ReadInt32(PageFile);
// Read in the chunk lengths
size = sizeof(word) * ChunksInFile;
MM_GetPtr(&buf,size);
if (!CA_FarRead(PageFile,(byte *)buf,size))
Quit("PML_OpenPageFile: Length read failed");
lengthptr = (word *)buf;
for (i = 0, page = PMPages; i < ChunksInFile; i++, page++)
page->length = *lengthptr++;
MM_FreePtr(&buf);
page->length = ReadInt16(PageFile);
}
//
......@@ -905,7 +895,7 @@ static void PML_OpenPageFile()
static void PML_ClosePageFile()
{
if (PageFile != -1)
close(PageFile);
CloseRead(PageFile);
if (PMPages) {
MM_SetLock((memptr)&PMPages,false);
......@@ -937,21 +927,12 @@ memptr PM_GetPage(int pagenum)
// page, and the total pages that need to be loaded (for thermometer).
//
void PM_Preload(boolean (*update)(word current, word total))
{
update(1, 1);
}
//
// PM_Reset() - Sets up caching structures
//
static void PM_Reset()
{
int i;
PageListStruct *page;
// Initialize page list
for (i = 0, page = PMPages; i < ChunksInFile; i++, page++)
page->addr = NULL;
for (i = 0; i < 50; i++)
update(i, 50); /* yay */
update(50, 50);
}
//
......@@ -964,8 +945,6 @@ void PM_Startup()
PML_OpenPageFile();
PM_Reset();
PMStarted = true;
}
......
......@@ -8,20 +8,20 @@
typedef struct
{
long planestart[3];
word planelength[3];
word width, height;
int planestart[3];
int planelength[3];
int width, height;
char name[16];
} PACKED maptype;
} maptype;
/* ======================================================================== */
extern int mapon;
extern int mapon;
extern word *mapsegs[MAPPLANES];
extern maptype *mapheaderseg[NUMMAPS];
extern byte *audiosegs[NUMSNDCHUNKS];
extern byte *grsegs[NUMCHUNKS];
extern word *mapsegs[MAPPLANES];
extern maptype *mapheaderseg[NUMMAPS];
extern byte *audiosegs[NUMSNDCHUNKS];
extern byte *grsegs[NUMCHUNKS];
extern char extension[5];
......@@ -63,12 +63,12 @@ void MM_SortMem();
#define PMPageSize 4096
typedef struct {
longword offset; // Offset of chunk into file
word length; // Length of the chunk
longword offset; // Offset of chunk into file
int length; // Length of the chunk
memptr addr;
} PageListStruct;
extern word ChunksInFile, PMSpriteStart, PMSoundStart;
extern int ChunksInFile, PMSpriteStart, PMSoundStart;
extern PageListStruct *PMPages;
......
......@@ -22,7 +22,7 @@ typedef bool boolean;
#endif
#define PACKED
#pragma pack(1) /* TODO: this unfortunately packs every struct... */
#pragma pack(1)
#define ssize_t SSIZE_T
......@@ -35,7 +35,6 @@ typedef bool boolean;
#include <glob.h>
#define PACKED __attribute__((packed))
#define LONGLONG long long
#ifdef __cplusplus
typedef bool boolean;
......@@ -54,13 +53,13 @@ typedef enum { false, true } boolean;
#include <time.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <stdint.h>
#include <math.h>
#ifndef O_BINARY
#define O_BINARY 0
#endif
#include "misc.h"
#include "version.h"
/* ------------------------------------------------------------------------ */
......@@ -106,6 +105,8 @@ typedef struct {
Point ul, lr;
} Rect;
#include "misc.h"
#include "vi_comm.h"
#include "sd_comm.h"
......
......@@ -103,7 +103,7 @@ boolean FizzleFade(unsigned xx, unsigned yy, unsigned width, unsigned height, un
void VL_FillPalette(int red, int green, int blue)
{
char pal[768];
byte pal[768];
int i;
for (i = 0; i < 256; i++) {
......
......@@ -38,7 +38,6 @@ unsigned long get_TimeCount()
struct timeval t1;
long secs, usecs;
long tc;
//double d;
gettimeofday(&t1, NULL);
secs = t1.tv_sec - t0.tv_sec;
......@@ -47,12 +46,9 @@ unsigned long get_TimeCount()
usecs += 1000000;
secs--;
}
//d = (double)tc0 + (double)secs * 70.0 + (double)usecs * 70.0 / 1000000.0;
//d = (double)tc0 + ((double)secs * 1000000.0 + (double)usecs) / (1000000.0/70.0);
//tc = (long)d;
tc = tc0 + secs * 70 + usecs * 70 / 1000000;
return tc;
}
......@@ -200,3 +196,132 @@ void DisplayTextSplash(byte *text, int l)
printf("\n");
}
}
/* ** */
static int16_t SwapInt16L(int16_t i)
{
#if __BYTE_ORDER == __BIG_ENDIAN
return ((uint16_t)i >> 8) | ((uint16_t)i << 8);
#else
return i;
#endif
}
static int32_t SwapInt32L(int32_t i)
{
#if __BYTE_ORDER == __BIG_ENDIAN
return ((uint32_t)(i & 0xFF000000) >> 24) |
((uint32_t)(i & 0x00FF0000) >> 8) |
((uint32_t)(i & 0x0000FF00) << 8) |
((uint32_t)(i & 0x000000FF) << 24);
#else
return i;
#endif
}
/* ** */
int OpenWrite(char *fn)
{
int fp;
/* fp = creat(fn, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH); */
fp = open(fn, O_CREAT|O_WRONLY|O_TRUNC|O_BINARY, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
return fp;
}
void CloseWrite(int fp)
{
close(fp);
}
int WriteSeek(int fp, int offset, int whence)
{
return lseek(fp, offset, whence);
}
int WriteInt8(int fp, int8_t d)
{
return write(fp, &d, 1);
}
int WriteInt16(int fp, int16_t d)
{
int16_t b = SwapInt16L(d);
return write(fp, &b, 2) / 2;
}
int WriteInt32(int fp, int32_t d)
{
int32_t b = SwapInt32L(d);
return write(fp, &b, 4) / 4;
}
int WriteBytes(int fp, byte *d, int len)
{
return write(fp, d, len);
}
int OpenRead(char *fn)
{
int fp;
fp = open(fn, O_RDONLY | O_BINARY);
return fp;
}
void CloseRead(int fp)
{
close(fp);
}
int ReadSeek(int fp, int offset, int whence)
{
return lseek(fp, offset, whence);
}
int ReadLength(int fp)
{
return filelength(fp);
}
int8_t ReadInt8(int fp)
{
int8_t d;
read(fp, &d, 1);
return d;
}
int16_t ReadInt16(int fp)
{
int16_t d;
read(fp, &d, 2);
d = SwapInt16L(d);
return d;
}
int32_t ReadInt32(int fp)
{
int32_t d;
read(fp, &d, 4);
d = SwapInt32L(d);
return d;
}
int ReadBytes(int fp, byte *d, int len)
{
return read(fp, d, len);
}
......@@ -24,4 +24,25 @@ char *ultoa(unsigned long value, char *string, int radix);
#endif /* DOSISM */
extern int OpenWrite(char *fn);
extern void CloseWrite(int fp);
extern int WriteSeek(int fp, int offset, int whence);
extern int WriteInt8(int fp, int8_t d);
extern int WriteInt16(int fp, int16_t d);
extern int WriteInt32(int fp, int32_t d);
extern int WriteBytes(int fp, byte *d, int len);
extern int OpenRead(char *fn);
extern void CloseRead(int fp);
extern int ReadSeek(int fp, int offset, int whence);
extern int ReadLength(int fp);
extern int8_t ReadInt8(int fp);
extern int16_t ReadInt16(int fp);
extern int32_t ReadInt32(int fp);
extern int ReadBytes(int fp, byte *d, int len);
#endif
......@@ -16,28 +16,41 @@
/* #define SPEAR */
/* #define SPEARDEMO */
#define UPLOAD
#define GAMENAME "Wolfenstein 3D Shareware"
#define GAMENAME "Wolfenstein 3D Shareware"
#define GAMEEXT "wl1"
#define GAMETYPE "WL1\0"
#elif WMODE == 1
/* #define SPEAR */
/* #define SPEARDEMO */
/* #define UPLOAD */
#define GAMENAME "Wolfenstein 3D"
#define GAMENAME "Wolfenstein 3D"
#define GAMEEXT "wl6"
#define GAMETYPE "WL6\0"
#elif WMODE == 2
#define SPEAR
#define SPEARDEMO
/* #define UPLOAD */
#define GAMENAME "Spear of Destiny Demo"
#define GAMENAME "Spear of Destiny Demo"
#define GAMEEXT "sdm"
#define GAMETYPE "SDM\0"
#elif WMODE == 3
#define SPEAR
/* #define SPEARDEMO */
/* #define UPLOAD */
#define GAMENAME "Spear of Destiny"
#define GAMENAME "Spear of Destiny"
#define GAMEEXT "sod"
#define GAMETYPE "SOD\0"
#else
#error "please edit version.h and fix WMODE"
#endif
#define GAMEHDR "WOLF3D\0\0"
#define SAVTYPE "SAV\0"
#define CFGTYPE "CFG\0"
#endif
......@@ -419,7 +419,7 @@ typedef enum {
typedef enum {
ac_badobject = -1,
ac_no,
ac_yes,
ac_yes
} activetype;
typedef enum {
......@@ -702,8 +702,8 @@ void NewViewSize (int width);
boolean LoadTheGame(int file,int x,int y);
boolean SaveTheGame(int file,int x,int y);
void ShowViewSize (int width);
void ShutdownId (void);
void WriteConfig(void);
void ShutdownId();
int WriteConfig();
int WolfMain(int argc, char *argv[]);
......@@ -738,6 +738,7 @@ void RecordDemo();
void DrawHighScores();
void DrawPlayBorder();
void DrawPlayBorderSides();
void DrawStatusBar();
#define PlaySoundLocTile(s,tx,ty) PlaySoundLocGlobal(s,(((long)(tx) << TILESHIFT) + (1L << (TILESHIFT - 1))),(((long)ty << TILESHIFT) + (1L << (TILESHIFT - 1))))
#define PlaySoundLocActor(s,ob) PlaySoundLocGlobal(s,(ob)->x,(ob)->y)
......
......@@ -35,7 +35,7 @@ static unsigned postx;
static void AsmRefresh();
//#define NOASM
#define NOASM
#ifndef NOASM
#define FixedByFrac(x, y) \
......
......@@ -633,6 +633,18 @@ void DrawPlayBorder()
}
}
void DrawStatusBar()
{
DrawFace();
DrawHealth();
DrawLives();
DrawLevel();
DrawAmmo();
DrawKeys();
DrawWeapon();
DrawScore();
}
/*
===================
=
......@@ -652,14 +664,7 @@ void DrawPlayScreen()
CA_UnCacheGrChunk(STATUSBARPIC);
DrawFace();
DrawHealth();
DrawLives();
DrawLevel();
DrawAmmo();
DrawKeys();
DrawWeapon();
DrawScore();
DrawStatusBar();
}
//==========================================================================
......
......@@ -60,9 +60,9 @@ char **_argv;
fixed FixedByFrac(fixed a, fixed b)
{
LONGLONG ra = a;
LONGLONG rb = b;
LONGLONG r;
int64_t ra = a;
int64_t rb = b;
int64_t r;
r = ra * rb;
r >>= 16;
......@@ -101,6 +101,7 @@ void CalcTics()
/* ======================================================================== */
#if 0
/*
====================
=
......@@ -143,21 +144,6 @@ void ReadConfig()
close(file);
if (sd == sdm_AdLib && !AdLibPresent && !SoundBlasterPresent)
{
sd = sdm_PC;
sd = smm_Off;
}
if ((sds == sds_SoundBlaster && !SoundBlasterPresent) ||
(sds == sds_SoundSource && !SoundSourcePresent))
sds = sds_Off;
if (!MousePresent)
mouseenabled = false;
if (!JoysPresent[joystickport])
joystickenabled = false;
MainMenu[6].active=1;
MainItems.curpos=0;
}
......@@ -169,34 +155,17 @@ void ReadConfig()
viewsize = 15;
}
if (SoundBlasterPresent || AdLibPresent)
{
sd = sdm_AdLib;
sm = smm_AdLib;
}
else
{
sd = sdm_PC;
sm = smm_Off;
}
if (SoundBlasterPresent)
sds = sds_SoundBlaster;
else
sds = sds_Off;
mouseenabled = false;
if (MousePresent)
mouseenabled = true;
joystickenabled = false;
joypadenabled = false;
joystickport = 0;
joystickenabled = false;
joypadenabled = false;
joystickport = 0;
mouseadjustment = 5;
mouseadjustment = 5;
SD_SetMusicMode(sm);
SD_SetSoundMode(sd);
SD_SetDigiDevice(sds);
SD_SetMusicMode(smm_AdLib);
SD_SetSoundMode(sdm_AdLib);
SD_SetDigiDevice(sds_SoundBlaster);
}
......@@ -240,31 +209,7 @@ void WriteConfig()
}
}
/*
=====================
=
= NewGame
=
= Set up new game to start from the beginning
=
=====================
*/
void NewGame(int difficulty, int episode)
{
memset(&gamestate,0,sizeof(gamestate));
gamestate.difficulty = difficulty;
gamestate.weapon = gamestate.bestweapon
= gamestate.chosenweapon = wp_pistol;
gamestate.health = 100;
gamestate.ammo = STARTAMMO;
gamestate.lives = 3;
gamestate.nextextra = EXTRAPOINTS;
gamestate.episode = episode;
startgame = true;
}
#endif
void DiskFlopAnim(int x, int y)
{
......@@ -279,7 +224,6 @@ void DiskFlopAnim(int x, int y)
which ^= 1;
}
long DoChecksum(byte *source, unsigned size, long checksum)
{
int i;
......@@ -290,6 +234,58 @@ long DoChecksum(byte *source, unsigned size, long checksum)
return checksum;
}
int WriteConfig()
{
int fd;
fd = OpenWrite(configname);
if (fd != -1) {
CloseWrite(fd);
}
return 0;
}
int ReadConfig()
{
int fd;
fd = OpenRead(configname);
if (fd != -1) {
CloseRead(fd);
#ifdef UPLOAD
MainMenu[readthis].active = 1;
MainItems.curpos = 0;
#endif
}
mouseenabled = false;
joystickenabled = false;
joypadenabled = false;
joystickport = 0;
mouseadjustment = 5;
SD_SetMusicMode(smm_AdLib);
SD_SetSoundMode(sdm_AdLib);
SD_SetDigiDevice(sds_SoundBlaster);
return 0;
}
int SaveGame()
{
return 0;
}
int LoadGame()
{
return 0;
}
/*
==================
......@@ -299,7 +295,7 @@ long DoChecksum(byte *source, unsigned size, long checksum)
==================
*/
boolean SaveTheGame(int file,int x,int y)
boolean SaveTheGame(int file, int x, int y)
{
long checksum;
objtype *ob,nullobj;
......@@ -1046,6 +1042,32 @@ void ShutdownId()
MM_Shutdown();
}
/*
=====================
=
= NewGame
=
= Set up new game to start from the beginning
=
=====================
*/
void NewGame(int difficulty, int episode)
{
memset(&gamestate, 0, sizeof(gamestate));
gamestate.difficulty = difficulty;
gamestate.weapon = gamestate.bestweapon
= gamestate.chosenweapon = wp_pistol;
gamestate.health = 100;
gamestate.ammo = STARTAMMO;
gamestate.lives = 3;
gamestate.nextextra = EXTRAPOINTS;
gamestate.episode = episode;
startgame = true;
}
/*
==========================
=
......
......@@ -90,22 +90,22 @@ CtlMenu[]=
NewEmenu[]=
{
{1,"Episode 1\n"
"Escape from Wolfenstein",0},
"Escape from Wolfenstein",0},
{0,"",0},
{3,"Episode 2\n"
"Operation: Eisenfaust",0},
"Operation: Eisenfaust",0},
{0,"",0},
{3,"Episode 3\n"
"Die, Fuhrer, Die!",0},
"Die, Fuhrer, Die!",0},
{0,"",0},
{3,"Episode 4\n"
"A Dark Secret",0},
"A Dark Secret",0},
{0,"",0},
{3,"Episode 5\n"
"Trail of the Madman",0},
"Trail of the Madman",0},
{0,"",0},
{3,"Episode 6\n"
"Confrontation",0}
"Confrontation",0}
},
#endif
......@@ -1187,14 +1187,8 @@ int CP_LoadGame(int quick)
loadedgame=false;
close(handle);
DrawFace ();
DrawHealth ();
DrawLives ();
DrawLevel ();
DrawAmmo ();
DrawKeys ();
DrawWeapon ();
DrawScore ();
DrawStatusBar();
return 1;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment