Commit abf4a36f authored by Steven Fuller's avatar Steven Fuller

More cleanups, id_ca should be good enough for now

parent 349df00f
...@@ -41,7 +41,7 @@ void *grsegs[NUMCHUNKS]; ...@@ -41,7 +41,7 @@ void *grsegs[NUMCHUNKS];
byte grneeded[NUMCHUNKS]; byte grneeded[NUMCHUNKS];
byte ca_levelbit,ca_levelnum; byte ca_levelbit,ca_levelnum;
int profilehandle,debughandle; memptr bufferseg;
/* /*
============================================================================= =============================================================================
...@@ -51,7 +51,7 @@ int profilehandle,debughandle; ...@@ -51,7 +51,7 @@ int profilehandle,debughandle;
============================================================================= =============================================================================
*/ */
char extension[5], // Need a string, not constant to change cache files char extension[5],
gheadname[10]="vgahead.", gheadname[10]="vgahead.",
gfilename[10]="vgagraph.", gfilename[10]="vgagraph.",
gdictname[10]="vgadict.", gdictname[10]="vgadict.",
...@@ -62,8 +62,8 @@ char extension[5], // Need a string, not constant to change cache files ...@@ -62,8 +62,8 @@ char extension[5], // Need a string, not constant to change cache files
void CA_CannotOpen(char *string); void CA_CannotOpen(char *string);
long *grstarts; // array of offsets in vgagraph, -1 for sparse long *grstarts; /* array of offsets in vgagraph, -1 for sparse */
long *audiostarts; // array of offsets in audio / audiot long *audiostarts; /* array of offsets in audio / audiot */
huffnode grhuffman[255]; huffnode grhuffman[255];
...@@ -81,8 +81,9 @@ void CAL_CarmackExpand (word *source, word *dest, word length); ...@@ -81,8 +81,9 @@ void CAL_CarmackExpand (word *source, word *dest, word length);
#define FILEPOSSIZE 3 #define FILEPOSSIZE 3
/*
//#define GRFILEPOS(c) (*(long *)(((byte *)grstarts)+(c)*3)&0xffffff) #define GRFILEPOS(c) (*(long *)(((byte *)grstarts)+(c)*3)&0xffffff)
*/
long GRFILEPOS(int c) long GRFILEPOS(int c)
{ {
long value; long value;
...@@ -283,21 +284,19 @@ boolean CA_LoadFile (char *filename, memptr *ptr) ...@@ -283,21 +284,19 @@ boolean CA_LoadFile (char *filename, memptr *ptr)
= CAL_HuffExpand = CAL_HuffExpand
= =
= Length is the length of the EXPANDED data = Length is the length of the EXPANDED data
= If screenhack, the data is decompressed in four planes directly
= to the screen
= =
====================== ======================
*/ */
/* From Ryan C. Gordon -- ryan_gordon@hotmail.com */ /* From Ryan C. Gordon -- ryan_gordon@hotmail.com */
void CAL_HuffExpand(byte *source, byte *dest, long length, huffnode *htable) void CAL_HuffExpand(byte *source, byte *dest, long length, huffnode *htable)
{ {
huffnode *headptr; // remains constant head of huffman tree. huffnode *headptr;
huffnode *nodeon; // for trailing down node trees... huffnode *nodeon;
byte mask = 0x0001; // for bitwise testing. byte mask = 0x0001;
word path; // stores branch of huffman node. word path;
byte *endoff = dest + length; // ptr to where uncompressed ends. byte *endoff = dest + length;
nodeon = headptr = htable + 254; // head node is always node 254. nodeon = headptr = htable + 254;
do { do {
if (*source & mask) if (*source & mask)
...@@ -305,17 +304,17 @@ void CAL_HuffExpand(byte *source, byte *dest, long length, huffnode *htable) ...@@ -305,17 +304,17 @@ void CAL_HuffExpand(byte *source, byte *dest, long length, huffnode *htable)
else else
path = nodeon->bit0; path = nodeon->bit0;
mask <<= 1; mask <<= 1;
if (mask == 0x0000) { // fully cycled bit positions? Get next char. if (mask == 0x0000) {
mask = 0x0001; mask = 0x0001;
source++; source++;
} }
if (path < 256) { // if (path < 256) it's a byte, else move node. if (path < 256) {
*dest = (byte) path; *dest = (byte) path;
dest++; dest++;
nodeon = headptr; nodeon = headptr;
} else } else
nodeon = (htable + (path - 256)); nodeon = (htable + (path - 256));
} while (dest != endoff); // written all data to *dest? } while (dest != endoff);
} }
/* /*
...@@ -331,12 +330,14 @@ void CAL_HuffExpand(byte *source, byte *dest, long length, huffnode *htable) ...@@ -331,12 +330,14 @@ void CAL_HuffExpand(byte *source, byte *dest, long length, huffnode *htable)
#define NEARTAG 0xa7 #define NEARTAG 0xa7
#define FARTAG 0xa8 #define FARTAG 0xa8
/* TODO: very correctness of byteinc */
void CAL_CarmackExpand(word *source, word *dest, word length) void CAL_CarmackExpand(word *source, word *dest, word length)
{ {
word ch, chhigh, count, offset; word ch, chhigh, count, offset;
word *copyptr, *inptr, *outptr; word *copyptr, *inptr, *outptr;
byte **byteinc = (byte **)&inptr;
length/=2;
length /= 2;
inptr = source; inptr = source;
outptr = dest; outptr = dest;
...@@ -347,12 +348,16 @@ void CAL_CarmackExpand(word *source, word *dest, word length) ...@@ -347,12 +348,16 @@ void CAL_CarmackExpand(word *source, word *dest, word length)
if (chhigh == NEARTAG) { if (chhigh == NEARTAG) {
count = ch&0xff; count = ch&0xff;
if (!count) { if (!count) {
// have to insert a word containing the tag byte /* have to insert a word containing the tag byte */
ch |= *((unsigned char *)inptr)++; ch |= **byteinc;
(*byteinc)++;
/* ch |= *((unsigned char *)inptr)++; */
*outptr++ = ch; *outptr++ = ch;
length--; length--;
} else { } else {
offset = *((unsigned char *)inptr)++; offset = **byteinc;
(*byteinc)++;
/* offset = *((unsigned char *)inptr)++; */
copyptr = outptr - offset; copyptr = outptr - offset;
length -= count; length -= count;
while (count--) while (count--)
...@@ -361,8 +366,10 @@ void CAL_CarmackExpand(word *source, word *dest, word length) ...@@ -361,8 +366,10 @@ void CAL_CarmackExpand(word *source, word *dest, word length)
} else if (chhigh == FARTAG) { } else if (chhigh == FARTAG) {
count = ch&0xff; count = ch&0xff;
if (!count) { if (!count) {
// have to insert a word containing the tag byte /* have to insert a word containing the tag byte */
ch |= *((unsigned char *)inptr)++; ch |= **byteinc;
(*byteinc)++;
/* ch |= *((unsigned char *)inptr)++; */
*outptr++ = ch; *outptr++ = ch;
length --; length --;
} else { } else {
...@@ -387,53 +394,39 @@ void CAL_CarmackExpand(word *source, word *dest, word length) ...@@ -387,53 +394,39 @@ void CAL_CarmackExpand(word *source, word *dest, word length)
====================== ======================
*/ */
/* TODO: actually this isn't used so it can be removed from here */
long CA_RLEWCompress(word *source, long length, word *dest, word rlewtag) long CA_RLEWCompress(word *source, long length, word *dest, word rlewtag)
{ {
long complength; word value, count, i;
word value,count,i; word *start, *end;
word *start, *end;
start = dest; start = dest;
end = source + (length+1)/2; end = source + (length + 1)/2;
//
// compress it
//
do
{
count = 1;
value = *source++;
while (*source == value && source<end)
{
count++;
source++;
}
if (count>3 || value == rlewtag)
{
//
// send a tag / count / value string
//
*dest++ = rlewtag;
*dest++ = count;
*dest++ = value;
}
else
{
//
// send word without compressing
//
for (i=1;i<=count;i++)
*dest++ = value;
}
} while (source<end); /* compress it */
do {
count = 1;
value = *source++;
while ( (*source == value) && (source < end) ) {
count++;
source++;
}
if ( (count > 3) || (value == rlewtag) ) {
/* send a tag / count / value string */
*dest++ = rlewtag;
*dest++ = count;
*dest++ = value;
} else {
/* send word without compressing */
for (i = 1; i <= count; i++)
*dest++ = value;
}
} while (source < end);
complength = 2*(dest-start); return 2*(dest-start);
return complength;
} }
/* /*
====================== ======================
= =
...@@ -445,35 +438,26 @@ long CA_RLEWCompress(word *source, long length, word *dest, word rlewtag) ...@@ -445,35 +438,26 @@ long CA_RLEWCompress(word *source, long length, word *dest, word rlewtag)
void CA_RLEWexpand(word *source, word *dest, long length, word rlewtag) void CA_RLEWexpand(word *source, word *dest, long length, word rlewtag)
{ {
word value, count,i; word value, count, i;
word *end = dest + length / 2; word *end = dest + length / 2;
//
// expand it /* expand it */
// do {
do value = *source++;
{
value = *source++; if (value != rlewtag)
if (value != rlewtag) /* uncompressed */
// *dest++=value;
// uncompressed else {
// /* compressed string */
*dest++=value; count = *source++;
else value = *source++;
{ for (i = 1; i <= count; i++)
// *dest++ = value;
// compressed string }
// } while (dest < end);
count = *source++;
value = *source++;
for (i=1;i<=count;i++)
*dest++ = value;
}
} while (dest<end);
} }
/* /*
============================================================================= =============================================================================
...@@ -482,7 +466,6 @@ void CA_RLEWexpand(word *source, word *dest, long length, word rlewtag) ...@@ -482,7 +466,6 @@ void CA_RLEWexpand(word *source, word *dest, long length, word rlewtag)
============================================================================= =============================================================================
*/ */
/* /*
====================== ======================
= =
...@@ -674,21 +657,15 @@ void CAL_SetupAudioFile (void) ...@@ -674,21 +657,15 @@ void CAL_SetupAudioFile (void)
====================== ======================
*/ */
void CA_Startup (void) void CA_Startup(void)
{ {
#ifdef PROFILE CAL_SetupMapFile();
unlink ("PROFILE.TXT"); CAL_SetupGrFile();
profilehandle = open("PROFILE.TXT", O_CREAT | O_WRONLY | O_TEXT); CAL_SetupAudioFile();
#endif
CAL_SetupMapFile ();
CAL_SetupGrFile ();
CAL_SetupAudioFile ();
mapon = -1; mapon = -1;
ca_levelbit = 1; ca_levelbit = 1;
ca_levelnum = 0; ca_levelnum = 0;
} }
//========================================================================== //==========================================================================
...@@ -706,10 +683,6 @@ void CA_Startup (void) ...@@ -706,10 +683,6 @@ void CA_Startup (void)
void CA_Shutdown (void) void CA_Shutdown (void)
{ {
#ifdef PROFILE
close (profilehandle);
#endif
close (maphandle); close (maphandle);
close (grhandle); close (grhandle);
close (audiohandle); close (audiohandle);
...@@ -744,13 +717,9 @@ void CA_CacheAudioChunk (int chunk) ...@@ -744,13 +717,9 @@ void CA_CacheAudioChunk (int chunk)
lseek(audiohandle,pos,SEEK_SET); lseek(audiohandle,pos,SEEK_SET);
MM_GetPtr ((memptr)&audiosegs[chunk],compressed); MM_GetPtr ((memptr)&audiosegs[chunk],compressed);
if (mmerror)
return;
CA_FarRead(audiohandle,audiosegs[chunk],compressed); CA_FarRead(audiohandle,audiosegs[chunk],compressed);
} }
//=========================================================================== //===========================================================================
...@@ -860,8 +829,6 @@ void CAL_ExpandGrChunk (int chunk, byte *source) ...@@ -860,8 +829,6 @@ void CAL_ExpandGrChunk (int chunk, byte *source)
// Sprites need to have shifts made and various other junk // Sprites need to have shifts made and various other junk
// //
MM_GetPtr (&grsegs[chunk],expanded); MM_GetPtr (&grsegs[chunk],expanded);
if (mmerror)
return;
CAL_HuffExpand (source,grsegs[chunk],expanded,grhuffman); CAL_HuffExpand (source,grsegs[chunk],expanded,grhuffman);
} }
...@@ -895,8 +862,8 @@ void CA_CacheGrChunk (int chunk) ...@@ -895,8 +862,8 @@ void CA_CacheGrChunk (int chunk)
// a larger buffer // a larger buffer
// //
pos = GRFILEPOS(chunk); pos = GRFILEPOS(chunk);
if (pos<0) /* $FFFFFFFF start is a sparse tile */ if (pos < 0) /* $FFFFFFFF start is a sparse tile */
return; return;
next = chunk +1; next = chunk +1;
while (GRFILEPOS(next) == -1) // skip past any sparse tiles while (GRFILEPOS(next) == -1) // skip past any sparse tiles
...@@ -969,8 +936,8 @@ void CA_CacheScreen (int chunk) ...@@ -969,8 +936,8 @@ void CA_CacheScreen (int chunk)
// allocate final space, decompress it, and free bigbuffer // allocate final space, decompress it, and free bigbuffer
// Sprites need to have shifts made and various other junk // Sprites need to have shifts made and various other junk
// //
/* TODO: show screen! */ /* TODO: this cheats and expands to the 320x200 screen buffer */
CAL_HuffExpand (source, MK_FP(SCREENSEG,bufferofs),expanded,grhuffman); CAL_HuffExpand(source, gfxbuf, expanded, grhuffman);
VW_MarkUpdateBlock (0,0,319,199); VW_MarkUpdateBlock (0,0,319,199);
MM_FreePtr(&bigbufferseg); MM_FreePtr(&bigbufferseg);
} }
...@@ -1022,12 +989,12 @@ void CA_CacheMap(int mapnum) ...@@ -1022,12 +989,12 @@ void CA_CacheMap(int mapnum)
} }
CA_FarRead(maphandle,(byte *)source,compressed); CA_FarRead(maphandle,(byte *)source,compressed);
// /*
// unhuffman, then unRLEW // unhuffman, then unRLEW
// The huffman'd chunk has a two byte expanded length first // The huffman'd chunk has a two byte expanded length first
// The resulting RLEW chunk also does, even though it's not really // The resulting RLEW chunk also does, even though it's not really
// needed // needed
// */
expanded = *source; expanded = *source;
source++; source++;
MM_GetPtr (&buffer2seg,expanded); MM_GetPtr (&buffer2seg,expanded);
...@@ -1133,7 +1100,6 @@ void CA_ClearAllMarks (void) ...@@ -1133,7 +1100,6 @@ void CA_ClearAllMarks (void)
//=========================================================================== //===========================================================================
/* /*
====================== ======================
= =
...@@ -1142,7 +1108,6 @@ void CA_ClearAllMarks (void) ...@@ -1142,7 +1108,6 @@ void CA_ClearAllMarks (void)
====================== ======================
*/ */
void CA_SetGrPurge (void) void CA_SetGrPurge (void)
{ {
int i; int i;
...@@ -1157,8 +1122,6 @@ void CA_SetGrPurge (void) ...@@ -1157,8 +1122,6 @@ void CA_SetGrPurge (void)
MM_SetPurge ((memptr)&grsegs[i],3); MM_SetPurge ((memptr)&grsegs[i],3);
} }
/* /*
====================== ======================
= =
...@@ -1290,8 +1253,6 @@ void CA_CacheMarks (void) ...@@ -1290,8 +1253,6 @@ void CA_CacheMarks (void)
{ {
// big chunk, allocate temporary buffer // big chunk, allocate temporary buffer
MM_GetPtr(&bigbufferseg,compressed); MM_GetPtr(&bigbufferseg,compressed);
if (mmerror)
return;
MM_SetLock (&bigbufferseg,true); MM_SetLock (&bigbufferseg,true);
lseek(grhandle,pos,SEEK_SET); lseek(grhandle,pos,SEEK_SET);
CA_FarRead(grhandle,bigbufferseg,compressed); CA_FarRead(grhandle,bigbufferseg,compressed);
...@@ -1299,8 +1260,6 @@ void CA_CacheMarks (void) ...@@ -1299,8 +1260,6 @@ void CA_CacheMarks (void)
} }
CAL_ExpandGrChunk (i,source); CAL_ExpandGrChunk (i,source);
if (mmerror)
return;
if (compressed>BUFFERSIZE) if (compressed>BUFFERSIZE)
MM_FreePtr(&bigbufferseg); MM_FreePtr(&bigbufferseg);
...@@ -1318,50 +1277,6 @@ void CA_CannotOpen(char *string) ...@@ -1318,50 +1277,6 @@ void CA_CannotOpen(char *string)
Quit (str); Quit (str);
} }
/* TODO: totally remove */
/*
=============================================================================
LOCAL INFO
=============================================================================
*/
#define LOCKBIT 0x80 // if set in attributes, block cannot be moved
#define PURGEBITS 3 // 0-3 level, 0= unpurgable, 3= purge first
#define PURGEMASK 0xfffc
#define BASEATTRIBUTES 0 // unlocked, non purgable
#define MAXUMBS 10
typedef struct mmblockstruct
{
unsigned start,length;
unsigned attributes;
memptr *useptr; // pointer to the segment start
struct mmblockstruct *next;
} mmblocktype;
#define GETNEWBLOCK {if(!mmfree)MML_ClearBlock();mmnew=mmfree;mmfree=mmfree->next;}
#define FREEBLOCK(x) {*x->useptr=NULL;x->next=mmfree;mmfree=x;}
/*
=============================================================================
GLOBAL VARIABLES
=============================================================================
*/
mminfotype mminfo;
memptr bufferseg;
boolean mmerror;
void (* beforesort) (void);
void (* aftersort) (void);
/* /*
============================================================================= =============================================================================
...@@ -1370,23 +1285,6 @@ void (* aftersort) (void); ...@@ -1370,23 +1285,6 @@ void (* aftersort) (void);
============================================================================= =============================================================================
*/ */
boolean mmstarted;
void *farheap;
void *nearheap;
mmblocktype mmblocks[MAXBLOCKS], *mmhead, *mmfree, *mmrover, *mmnew;
boolean bombonerror;
//unsigned totalEMSpages,freeEMSpages,EMSpageframe,EMSpagesmapped,EMShandle;
void (* XMSaddr) (void); // far pointer to XMS driver
unsigned numUMBs,UMBbase[MAXUMBS];
//==========================================================================
/* /*
=================== ===================
= =
...@@ -1400,7 +1298,7 @@ unsigned numUMBs,UMBbase[MAXUMBS]; ...@@ -1400,7 +1298,7 @@ unsigned numUMBs,UMBbase[MAXUMBS];
void MM_Startup (void) void MM_Startup (void)
{ {
MM_GetPtr (&bufferseg,BUFFERSIZE); MM_GetPtr (&bufferseg, BUFFERSIZE);
} }
/* /*
...@@ -1559,42 +1457,16 @@ long MM_TotalFree (void) ...@@ -1559,42 +1457,16 @@ long MM_TotalFree (void)
void MM_BombOnError(boolean bomb) void MM_BombOnError(boolean bomb)
{ {
bombonerror = bomb;
} }
// Main Mem specific variables boolean PMStarted;
boolean MainPresent; char PageFileName[13] = {"vswap."};
memptr MainMemPages[PMMaxMainMem];
PMBlockAttr MainMemUsed[PMMaxMainMem];
int MainPagesAvail;
// EMS specific variables
boolean EMSPresent;
word EMSAvail,EMSPagesAvail,EMSHandle,
EMSPageFrame,EMSPhysicalPage;
EMSListStruct EMSList[EMSFrameCount];
// XMS specific variables
boolean XMSPresent;
word XMSAvail,XMSPagesAvail,XMSHandle;
longword XMSDriver;
int XMSProtectPage = -1;
// File specific variables
char PageFileName[13] = {"VSWAP."};
int PageFile = -1; int PageFile = -1;
word ChunksInFile; word ChunksInFile;
word PMSpriteStart,PMSoundStart; word PMSpriteStart,PMSoundStart;
// General usage variables word PMNumBlocks;
boolean PMStarted, long PMFrameCount;
PMPanicMode,
PMThrashing;
word XMSPagesUsed,
EMSPagesUsed,
MainPagesUsed,
PMNumBlocks;
long PMFrameCount;
PageListStruct *PMPages, *PMSegPages; PageListStruct *PMPages, *PMSegPages;
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
...@@ -1641,9 +1513,8 @@ void PML_OpenPageFile(void) ...@@ -1641,9 +1513,8 @@ void PML_OpenPageFile(void)
// Allocate and clear the page list // Allocate and clear the page list
PMNumBlocks = ChunksInFile; PMNumBlocks = ChunksInFile;
MM_GetPtr((memptr)&PMSegPages,sizeof(PageListStruct) * PMNumBlocks); MM_GetPtr((memptr)&PMPages,sizeof(PageListStruct) * PMNumBlocks);
MM_SetLock((memptr)&PMSegPages,true); MM_SetLock((memptr)&PMPages,true);
PMPages = (PageListStruct *)PMSegPages;
memset(PMPages,0,sizeof(PageListStruct) * PMNumBlocks); memset(PMPages,0,sizeof(PageListStruct) * PMNumBlocks);
// Read in the chunk offsets // Read in the chunk offsets
...@@ -1674,10 +1545,10 @@ void PML_ClosePageFile(void) ...@@ -1674,10 +1545,10 @@ void PML_ClosePageFile(void)
{ {
if (PageFile != -1) if (PageFile != -1)
close(PageFile); close(PageFile);
if (PMSegPages)
{ if (PMPages) {
MM_SetLock((memptr)&PMSegPages,false); MM_SetLock((memptr)&PMPages,false);
MM_FreePtr((memptr)&PMSegPages); MM_FreePtr((memptr)&PMPages);
} }
} }
...@@ -1690,7 +1561,7 @@ void PML_ClosePageFile(void) ...@@ -1690,7 +1561,7 @@ void PML_ClosePageFile(void)
// //
// PM_GetPageAddress() - Returns the address of a given page // PM_GetPageAddress() - Returns the address of a given page
// Maps in EMS if necessary // Maps in EMS if necessary
// Returns nil if block isn't cached into Main Memory or EMS // Returns nil if block is not cached into Main Memory or EMS
// //
// //
memptr PM_GetPageAddress(int pagenum) memptr PM_GetPageAddress(int pagenum)
......
// ID_CA.H #ifndef __ID_CA_H__
#define __ID_CA_H__
//=========================================================================== //===========================================================================
#define NUMMAPS 60 #define NUMMAPS 60
...@@ -14,7 +16,7 @@ typedef struct ...@@ -14,7 +16,7 @@ typedef struct
word planelength[3]; word planelength[3];
word width,height; word width,height;
char name[16]; char name[16];
} maptype; } PACKED maptype;
//=========================================================================== //===========================================================================
...@@ -31,8 +33,6 @@ extern byte ca_levelbit,ca_levelnum; ...@@ -31,8 +33,6 @@ extern byte ca_levelbit,ca_levelnum;
extern char *titleptr[8]; extern char *titleptr[8];
extern int profilehandle,debughandle;
extern char extension[5], extern char extension[5],
gheadname[10], gheadname[10],
gfilename[10], gfilename[10],
...@@ -42,7 +42,7 @@ extern char extension[5], ...@@ -42,7 +42,7 @@ extern char extension[5],
aheadname[10], aheadname[10],
afilename[10]; afilename[10];
extern long *grstarts; // array of offsets in egagraph, -1 for sparse extern long *grstarts; // array of offsets in vgagraph, -1 for sparse
extern long *audiostarts; // array of offsets in audio / audiot extern long *audiostarts; // array of offsets in audio / audiot
//=========================================================================== //===========================================================================
...@@ -80,76 +80,12 @@ void CA_CacheMarks (void); ...@@ -80,76 +80,12 @@ void CA_CacheMarks (void);
void CA_CacheScreen (int chunk); void CA_CacheScreen (int chunk);
#define SAVENEARHEAP 0x400 // space to leave in data segment
#define SAVEFARHEAP 0 // space to leave in far heap
#define BUFFERSIZE 0x1000 // miscelanious, allways available buffer #define BUFFERSIZE 0x1000 // miscelanious, allways available buffer
#define MAXBLOCKS 700
//--------
#define EMS_INT 0x67
#define EMS_STATUS 0x40
#define EMS_GETFRAME 0x41
#define EMS_GETPAGES 0x42
#define EMS_ALLOCPAGES 0x43
#define EMS_MAPPAGE 0x44
#define EMS_FREEPAGES 0x45
#define EMS_VERSION 0x46
//--------
#define XMS_INT 0x2f
#define XMS_CALL(v) _AH = (v);\
asm call [DWORD PTR XMSDriver]
#define XMS_VERSION 0x00
#define XMS_ALLOCHMA 0x01
#define XMS_FREEHMA 0x02
#define XMS_GENABLEA20 0x03
#define XMS_GDISABLEA20 0x04
#define XMS_LENABLEA20 0x05
#define XMS_LDISABLEA20 0x06
#define XMS_QUERYA20 0x07
#define XMS_QUERYFREE 0x08
#define XMS_ALLOC 0x09
#define XMS_FREE 0x0A
#define XMS_MOVE 0x0B
#define XMS_LOCK 0x0C
#define XMS_UNLOCK 0x0D
#define XMS_GETINFO 0x0E
#define XMS_RESIZE 0x0F
#define XMS_ALLOCUMB 0x10
#define XMS_FREEUMB 0x11
//==========================================================================
typedef struct
{
long nearheap,farheap,EMSmem,XMSmem,mainmem;
} mminfotype;
//==========================================================================
extern mminfotype mminfo;
extern memptr bufferseg;
extern boolean mmerror;
extern void (* beforesort) (void);
extern void (* aftersort) (void);
//========================================================================== //==========================================================================
void MM_Startup (void); void MM_Startup (void);
void MM_Shutdown (void); void MM_Shutdown (void);
void MM_MapEMS (void);
void MM_GetPtr (memptr *baseptr, unsigned long size); void MM_GetPtr (memptr *baseptr, unsigned long size);
void MM_FreePtr (memptr *baseptr); void MM_FreePtr (memptr *baseptr);
...@@ -165,22 +101,7 @@ long MM_TotalFree (void); ...@@ -165,22 +101,7 @@ long MM_TotalFree (void);
void MM_BombOnError (boolean bomb); void MM_BombOnError (boolean bomb);
void MML_UseSpace (unsigned segstart, unsigned seglength); #define PMPageSize 4096
#define EMSPageSize 16384
#define EMSPageSizeSeg (EMSPageSize >> 4)
#define EMSPageSizeKB (EMSPageSize >> 10)
#define EMSFrameCount 4
#define PMPageSize 4096
#define PMPageSizeSeg (PMPageSize >> 4)
#define PMPageSizeKB (PMPageSize >> 10)
#define PMEMSSubPage (EMSPageSize / PMPageSize)
#define PMMinMainMem 10 // Min acceptable # of pages from main
#define PMMaxMainMem 100 // Max number of pages in main memory
#define PMThrashThreshold 1 // Number of page thrashes before panic mode
#define PMUnThrashThreshold 5 // Number of non-thrashing frames before leaving panic mode
typedef enum typedef enum
{ {
...@@ -188,30 +109,14 @@ typedef enum ...@@ -188,30 +109,14 @@ typedef enum
pml_Locked pml_Locked
} PMLockType; } PMLockType;
typedef enum
{
pmba_Unused = 0,
pmba_Used = 1,
pmba_Allocated = 2
} PMBlockAttr;
typedef struct { typedef struct {
longword offset; // Offset of chunk into file longword offset; // Offset of chunk into file
word length; // Length of the chunk word length; // Length of the chunk
PMLockType locked; // If set, this page can't be purged PMLockType locked; // If set, this page cannot be purged
memptr addr; memptr addr;
longword lastHit; // Last frame number of hit longword lastHit; // Last frame number of hit
} PageListStruct; } PageListStruct;
typedef struct
{
int baseEMSPage; // Base EMS page for this phys frame
longword lastHit; // Last frame number of hit
} EMSListStruct;
extern boolean XMSPresent,EMSPresent;
extern word XMSPagesAvail,EMSPagesAvail;
extern word ChunksInFile, extern word ChunksInFile,
PMSpriteStart,PMSoundStart; PMSpriteStart,PMSoundStart;
extern PageListStruct *PMPages; extern PageListStruct *PMPages;
...@@ -219,10 +124,6 @@ extern PageListStruct *PMPages; ...@@ -219,10 +124,6 @@ extern PageListStruct *PMPages;
#define PM_GetSoundPage(v) PM_GetPage(PMSoundStart + (v)) #define PM_GetSoundPage(v) PM_GetPage(PMSoundStart + (v))
#define PM_GetSpritePage(v) PM_GetPage(PMSpriteStart + (v)) #define PM_GetSpritePage(v) PM_GetPage(PMSpriteStart + (v))
#define PM_LockMainMem() PM_SetMainMemPurge(0)
#define PM_UnlockMainMem() PM_SetMainMemPurge(3)
extern char PageFileName[13]; extern char PageFileName[13];
...@@ -237,4 +138,6 @@ void PM_Startup(void), ...@@ -237,4 +138,6 @@ void PM_Startup(void),
memptr PM_GetPageAddress(int pagenum), memptr PM_GetPageAddress(int pagenum),
PM_GetPage(int pagenum); // Use this one to cache page PM_GetPage(int pagenum); // Use this one to cache page
void PM_SetMainMemPurge(int level); #elif
#error "fix me TODO"
#endif
...@@ -72,6 +72,8 @@ ...@@ -72,6 +72,8 @@
//=========================================================================== //===========================================================================
extern byte *gfxbuf;
extern unsigned bufferofs; // all drawing is reletive to this extern unsigned bufferofs; // all drawing is reletive to this
extern unsigned displayofs; // last setscreen coordinates extern unsigned displayofs; // last setscreen coordinates
......
#ifndef __VERSION_H__ #ifndef __VERSION_H__
#define __VERSION_H__ #define __VERSION_H__
//#define SPEAR /* #define SPEAR */
//#define JAPAN /* #define SPEARDEMO */
/* #define JAPAN */
#define GOODTIMES #define GOODTIMES
#define DEMOSEXTERN #define DEMOSEXTERN
//#define UPLOAD /* #define UPLOAD */
#elif #elif
#error "fix me: TODO" #error "fix me: TODO"
......
/* wl_draw.c */ /* wl_draw.c */
#include "wl_def.h" #include "wl_def.h"
#include <dos.h>
/* /*
============================================================================= =============================================================================
...@@ -1243,14 +1242,6 @@ void CalcTics (void) ...@@ -1243,14 +1242,6 @@ void CalcTics (void)
lasttimecount = newtime; lasttimecount = newtime;
#ifdef FILEPROFILE
strcpy (scratch,"\tTics:");
itoa (tics,str,10);
strcat (scratch,str);
strcat (scratch,"\n");
write (profilehandle,scratch,strlen(scratch));
#endif
if (tics>MAXTICS) if (tics>MAXTICS)
{ {
TimeCount -= (tics-MAXTICS); TimeCount -= (tics-MAXTICS);
......
...@@ -1189,18 +1189,6 @@ void InitGame (void) ...@@ -1189,18 +1189,6 @@ void InitGame (void)
BuildTables (); // trig tables BuildTables (); // trig tables
SetupWalls (); SetupWalls ();
#if 0
{
int temp,i;
temp = viewsize;
profilehandle = open("SCALERS.TXT", O_CREAT | O_WRONLY | O_TEXT);
for (i=1;i<20;i++)
NewViewSize(i);
viewsize = temp;
close(profilehandle);
}
#endif
NewViewSize (viewsize); NewViewSize (viewsize);
......
...@@ -2,8 +2,5 @@ ...@@ -2,8 +2,5 @@
#define JAPAN #define JAPAN
#define JAPDEMO #define JAPDEMO
#define UPLOAD #define UPLOAD
#define ARTSEXTERN
#define DEMOSEXTERN #define DEMOSEXTERN
//#define MYPROFILE
//#define DEBCHECK
#define CARMACIZED #define CARMACIZED
//#define SPEAR //#define SPEAR
#define JAPAN #define JAPAN
#define ARTSEXTERN
#define DEMOSEXTERN #define DEMOSEXTERN
//#define MYPROFILE
//#define DEBCHECK
#define CARMACIZED #define CARMACIZED
//#define UPLOAD //#define UPLOAD
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