Commit 95ee2e54 authored by Steven Fuller's avatar Steven Fuller

More cleanups...

parent 7df8774f
///////////////////////////////////////////////////////////////////////////
//
// SDL_CheckSB() - Checks to see if a SoundBlaster resides at a
// particular I/O location
//
///////////////////////////////////////////////////////////////////////////
static boolean
SDL_CheckSB(int port)
{
int i;
sbLocation = port << 4; // Initialize stuff for later use
sbOut(sbReset,true); // Reset the SoundBlaster DSP
asm mov dx,0x388 // Wait >4usec
asm in al, dx
asm in al, dx
asm in al, dx
asm in al, dx
asm in al, dx
asm in al, dx
asm in al, dx
asm in al, dx
asm in al, dx
sbOut(sbReset,false); // Turn off sb DSP reset
asm mov dx,0x388 // Wait >100usec
asm mov cx,100
usecloop:
asm in al,dx
asm loop usecloop
for (i = 0;i < 100;i++)
{
if (sbIn(sbDataAvail) & 0x80) // If data is available...
{
if (sbIn(sbReadData) == 0xaa) // If it matches correct value
return(true);
else
{
sbLocation = -1; // Otherwise not a SoundBlaster
return(false);
}
}
}
sbLocation = -1; // Retry count exceeded - fail
return(false);
}
///////////////////////////////////////////////////////////////////////////
//
// Checks to see if a SoundBlaster is in the system. If the port passed is
// -1, then it scans through all possible I/O locations. If the port
// passed is 0, then it uses the default (2). If the port is >0, then
// it just passes it directly to SDL_CheckSB()
//
///////////////////////////////////////////////////////////////////////////
static boolean
SDL_DetectSoundBlaster(int port)
{
int i;
if (port == 0) // If user specifies default, use 2
port = 2;
if (port == -1)
{
if (SDL_CheckSB(2)) // Check default before scanning
return(true);
if (SDL_CheckSB(4)) // Check other SB Pro location before scan
return(true);
for (i = 1;i <= 6;i++) // Scan through possible SB locations
{
if ((i == 2) || (i == 4))
continue;
if (SDL_CheckSB(i)) // If found at this address,
return(true); // return success
}
return(false); // All addresses failed, return failure
}
else
return(SDL_CheckSB(port)); // User specified address or default
}
...@@ -332,18 +332,16 @@ void CAL_HuffExpand(byte *source, byte *dest, long length, huffnode *htable) ...@@ -332,18 +332,16 @@ void CAL_HuffExpand(byte *source, byte *dest, long length, huffnode *htable)
if (mask == 0x0000) { // fully cycled bit positions? Get next char. if (mask == 0x0000) { // fully cycled bit positions? Get next char.
mask = 0x0001; mask = 0x0001;
source++; source++;
} // if }
if (path < 256) { // if (path < 256) it's a byte, else move node. if (path < 256) { // if (path < 256) it's a byte, else move node.
*dest = (byte) path; *dest = (byte) path;
dest++; dest++;
nodeon = headptr; nodeon = headptr;
} else // if } else
nodeon = (htable + (path - 256)); nodeon = (htable + (path - 256));
} while (dest != endoff); // written all data to *dest? } while (dest != endoff); // written all data to *dest?
} }
/* /*
====================== ======================
= =
...@@ -367,56 +365,44 @@ void CAL_CarmackExpand (unsigned *source, unsigned *dest, unsigned length) ...@@ -367,56 +365,44 @@ void CAL_CarmackExpand (unsigned *source, unsigned *dest, unsigned length)
inptr = source; inptr = source;
outptr = dest; outptr = dest;
while (length) while (length) {
{
ch = *inptr++; ch = *inptr++;
chhigh = ch>>8; chhigh = ch>>8;
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 |= *((unsigned char *)inptr)++;
*outptr++ = ch; *outptr++ = ch;
length--; length--;
} } else {
else
{
offset = *((unsigned char *)inptr)++; offset = *((unsigned char *)inptr)++;
copyptr = outptr - offset; copyptr = outptr - offset;
length -= count; length -= count;
while (count--) while (count--)
*outptr++ = *copyptr++; *outptr++ = *copyptr++;
} }
} } 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 |= *((unsigned char *)inptr)++;
*outptr++ = ch; *outptr++ = ch;
length --; length --;
} } else {
else
{
offset = *inptr++; offset = *inptr++;
copyptr = dest + offset; copyptr = dest + offset;
length -= count; length -= count;
while (count--) while (count--)
*outptr++ = *copyptr++; *outptr++ = *copyptr++;
} }
} } else {
else
{
*outptr++ = ch; *outptr++ = ch;
length --; length--;
} }
} }
} }
/* /*
====================== ======================
= =
...@@ -425,12 +411,11 @@ void CAL_CarmackExpand (unsigned *source, unsigned *dest, unsigned length) ...@@ -425,12 +411,11 @@ void CAL_CarmackExpand (unsigned *source, unsigned *dest, unsigned length)
====================== ======================
*/ */
long CA_RLEWCompress (unsigned *source, long length, unsigned *dest, long CA_RLEWCompress(word *source, long length, word *dest, word rlewtag)
unsigned rlewtag)
{ {
long complength; long complength;
unsigned value,count,i; word value,count,i;
unsigned *start, *end; word *start, *end;
start = dest; start = dest;
...@@ -482,18 +467,13 @@ long CA_RLEWCompress (unsigned *source, long length, unsigned *dest, ...@@ -482,18 +467,13 @@ long CA_RLEWCompress (unsigned *source, long length, unsigned *dest,
====================== ======================
*/ */
void CA_RLEWexpand (unsigned *source, unsigned *dest,long length, void CA_RLEWexpand(word *source, word *dest, long length, word rlewtag)
unsigned rlewtag)
{ {
// unsigned value,count,i; word value, count,i;
unsigned *end; word *end = dest + length / 2;
unsigned sourceseg,sourceoff,destseg,destoff,endseg,endoff;
// //
// expand it // expand it
// //
#if 0
do do
{ {
value = *source++; value = *source++;
...@@ -513,80 +493,6 @@ void CA_RLEWexpand (unsigned *source, unsigned *dest,long length, ...@@ -513,80 +493,6 @@ void CA_RLEWexpand (unsigned *source, unsigned *dest,long length,
*dest++ = value; *dest++ = value;
} }
} while (dest<end); } while (dest<end);
#endif
end = dest + (length)/2;
sourceseg = FP_SEG(source);
sourceoff = FP_OFF(source);
destseg = FP_SEG(dest);
destoff = FP_OFF(dest);
endseg = FP_SEG(end);
endoff = FP_OFF(end);
//
// ax = source value
// bx = tag value
// cx = repeat counts
// dx = scratch
//
// NOTE: A repeat count that produces 0xfff0 bytes can blow this!
//
asm mov bx,rlewtag
asm mov si,sourceoff
asm mov di,destoff
asm mov es,destseg
asm mov ds,sourceseg
expand:
asm lodsw
asm cmp ax,bx
asm je repeat
asm stosw
asm jmp next
repeat:
asm lodsw
asm mov cx,ax // repeat count
asm lodsw // repeat value
asm rep stosw
next:
asm cmp si,0x10 // normalize ds:si
asm jb sinorm
asm mov ax,si
asm shr ax,1
asm shr ax,1
asm shr ax,1
asm shr ax,1
asm mov dx,ds
asm add dx,ax
asm mov ds,dx
asm and si,0xf
sinorm:
asm cmp di,0x10 // normalize es:di
asm jb dinorm
asm mov ax,di
asm shr ax,1
asm shr ax,1
asm shr ax,1
asm shr ax,1
asm mov dx,es
asm add dx,ax
asm mov es,dx
asm and di,0xf
dinorm:
asm cmp di,ss:endoff
asm jne expand
asm mov ax,es
asm cmp ax,ss:endseg
asm jb expand
asm mov ax,ss
asm mov ds,ax
} }
...@@ -631,7 +537,7 @@ void CAL_SetupGrFile (void) ...@@ -631,7 +537,7 @@ void CAL_SetupGrFile (void)
// //
// load the data offsets from ???head.ext // load the data offsets from ???head.ext
// //
MM_GetPtr (&(memptr)grstarts,(NUMCHUNKS+1)*FILEPOSSIZE); MM_GetPtr ((memptr)&grstarts,(NUMCHUNKS+1)*FILEPOSSIZE);
strcpy(fname,gheadname); strcpy(fname,gheadname);
strcat(fname,extension); strcat(fname,extension);
...@@ -659,11 +565,11 @@ void CAL_SetupGrFile (void) ...@@ -659,11 +565,11 @@ void CAL_SetupGrFile (void)
// //
// load the pic and sprite headers into the arrays in the data segment // load the pic and sprite headers into the arrays in the data segment
// //
MM_GetPtr(&(memptr)pictable,NUMPICS*sizeof(pictabletype)); MM_GetPtr((memptr)&pictable,NUMPICS*sizeof(pictabletype));
CAL_GetGrChunkLength(STRUCTPIC); // position file pointer CAL_GetGrChunkLength(STRUCTPIC); // position file pointer
MM_GetPtr(&compseg,chunkcomplen); MM_GetPtr(&compseg,chunkcomplen);
CA_FarRead (grhandle,compseg,chunkcomplen); CA_FarRead(grhandle,compseg,chunkcomplen);
CAL_HuffExpand (compseg, (byte *)pictable,NUMPICS*sizeof(pictabletype),grhuffman,false); CAL_HuffExpand (compseg, (byte *)pictable,NUMPICS*sizeof(pictabletype),grhuffman);
MM_FreePtr(&compseg); MM_FreePtr(&compseg);
} }
...@@ -696,28 +602,19 @@ void CAL_SetupMapFile (void) ...@@ -696,28 +602,19 @@ void CAL_SetupMapFile (void)
CA_CannotOpen(fname); CA_CannotOpen(fname);
length = filelength(handle); length = filelength(handle);
MM_GetPtr (&(memptr)tinf,length); MM_GetPtr ((memptr)&tinf,length);
CA_FarRead(handle, tinf, length); CA_FarRead(handle, tinf, length);
close(handle); close(handle);
// //
// open the data file // open the data file
// //
#ifdef CARMACIZED strcpy(fname,"gamemaps.");
strcpy(fname,"GAMEMAPS.");
strcat(fname,extension);
if ((maphandle = open(fname,
O_RDONLY | O_BINARY, S_IREAD)) == -1)
CA_CannotOpen(fname);
#else
strcpy(fname,mfilename);
strcat(fname,extension); strcat(fname,extension);
if ((maphandle = open(fname, if ((maphandle = open(fname,
O_RDONLY | O_BINARY, S_IREAD)) == -1) O_RDONLY | O_BINARY, S_IREAD)) == -1)
CA_CannotOpen(fname); CA_CannotOpen(fname);
#endif
// //
// load all map header // load all map header
...@@ -735,7 +632,7 @@ void CAL_SetupMapFile (void) ...@@ -735,7 +632,7 @@ void CAL_SetupMapFile (void)
} }
// //
// allocate space for 3 64*64 planes // allocate space for 2 64*64 planes
// //
for (i=0;i<MAPPLANES;i++) for (i=0;i<MAPPLANES;i++)
{ {
...@@ -988,7 +885,7 @@ void CAL_ExpandGrChunk (int chunk, byte *source) ...@@ -988,7 +885,7 @@ void CAL_ExpandGrChunk (int chunk, byte *source)
MM_GetPtr (&grsegs[chunk],expanded); MM_GetPtr (&grsegs[chunk],expanded);
if (mmerror) if (mmerror)
return; return;
CAL_HuffExpand (source,grsegs[chunk],expanded,grhuffman,false); CAL_HuffExpand (source,grsegs[chunk],expanded,grhuffman);
} }
...@@ -1095,7 +992,8 @@ void CA_CacheScreen (int chunk) ...@@ -1095,7 +992,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
// //
CAL_HuffExpand (source,MK_FP(SCREENSEG,bufferofs),expanded,grhuffman,true); /* TODO: show screen! */
CAL_HuffExpand (source,MK_FP(SCREENSEG,bufferofs),expanded,grhuffman);
VW_MarkUpdateBlock (0,0,319,199); VW_MarkUpdateBlock (0,0,319,199);
MM_FreePtr(&bigbufferseg); MM_FreePtr(&bigbufferseg);
} }
...@@ -1119,10 +1017,8 @@ void CA_CacheMap (int mapnum) ...@@ -1119,10 +1017,8 @@ void CA_CacheMap (int mapnum)
memptr *dest,bigbufferseg; memptr *dest,bigbufferseg;
unsigned size; unsigned size;
unsigned *source; unsigned *source;
#ifdef CARMACIZED
memptr buffer2seg; memptr buffer2seg;
long expanded; long expanded;
#endif
mapon = mapnum; mapon = mapnum;
...@@ -1149,7 +1045,6 @@ void CA_CacheMap (int mapnum) ...@@ -1149,7 +1045,6 @@ void CA_CacheMap (int mapnum)
} }
CA_FarRead(maphandle,(byte *)source,compressed); CA_FarRead(maphandle,(byte *)source,compressed);
#ifdef CARMACIZED
// //
// 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
...@@ -1164,14 +1059,6 @@ void CA_CacheMap (int mapnum) ...@@ -1164,14 +1059,6 @@ void CA_CacheMap (int mapnum)
((mapfiletype *)tinf)->RLEWtag); ((mapfiletype *)tinf)->RLEWtag);
MM_FreePtr (&buffer2seg); MM_FreePtr (&buffer2seg);
#else
//
// unRLEW, skipping expanded length
//
CA_RLEWexpand (source+1, *dest,size,
((mapfiletype *)tinf)->RLEWtag);
#endif
if (compressed>BUFFERSIZE) if (compressed>BUFFERSIZE)
MM_FreePtr(&bigbufferseg); MM_FreePtr(&bigbufferseg);
} }
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
typedef struct typedef struct
{ {
long planestart[3]; long planestart[3];
unsigned planelength[3]; word planelength[3];
unsigned width,height; word width,height;
char name[16]; char name[16];
} maptype; } maptype;
...@@ -55,11 +55,8 @@ boolean CA_ReadFile(char *filename, memptr *ptr); ...@@ -55,11 +55,8 @@ boolean CA_ReadFile(char *filename, memptr *ptr);
boolean CA_LoadFile(char *filename, memptr *ptr); boolean CA_LoadFile(char *filename, memptr *ptr);
boolean CA_WriteFile(char *filename, void *ptr, long length); boolean CA_WriteFile(char *filename, void *ptr, long length);
long CA_RLEWCompress (unsigned *source, long length, unsigned *dest, long CA_RLEWCompress(word *source, long length, word *dest, word rlewtag);
unsigned rlewtag); void CA_RLEWexpand(word *source, word *dest, long length, word rlewtag);
void CA_RLEWexpand (unsigned *source, unsigned *dest,long length,
unsigned rlewtag);
void CA_Startup (void); void CA_Startup (void);
void CA_Shutdown (void); void CA_Shutdown (void);
...@@ -156,7 +153,7 @@ void MM_Startup (void); ...@@ -156,7 +153,7 @@ void MM_Startup (void);
void MM_Shutdown (void); void MM_Shutdown (void);
void MM_MapEMS (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);
void MM_SetPurge (memptr *baseptr, int purge); void MM_SetPurge (memptr *baseptr, int purge);
......
...@@ -72,7 +72,7 @@ extern char signon; ...@@ -72,7 +72,7 @@ extern char signon;
typedef enum {false,true} boolean; typedef enum {false,true} boolean;
typedef unsigned char byte; typedef unsigned char byte;
typedef unsigned int word; typedef unsigned short int word;
typedef unsigned long longword; typedef unsigned long longword;
typedef byte * Ptr; typedef byte * Ptr;
......
...@@ -4,11 +4,7 @@ ...@@ -4,11 +4,7 @@
//#define SPEAR //#define SPEAR
//#define JAPAN //#define JAPAN
#define GOODTIMES #define GOODTIMES
#define ARTSEXTERN
#define DEMOSEXTERN #define DEMOSEXTERN
//#define MYPROFILE
//#define DEBCHECK
#define CARMACIZED
//#define UPLOAD //#define UPLOAD
#elif #elif
......
...@@ -768,9 +768,7 @@ void CheckKeys (void) ...@@ -768,9 +768,7 @@ void CheckKeys (void)
// F1-F7/ESC to enter control panel // F1-F7/ESC to enter control panel
// //
if ( if (
#ifndef DEBCHECK
scan == sc_F10 || scan == sc_F10 ||
#endif
scan == sc_F9 || scan == sc_F9 ||
scan == sc_F7 || scan == sc_F7 ||
scan == sc_F8) // pop up quit dialog scan == sc_F8) // pop up quit dialog
......
...@@ -726,12 +726,10 @@ void ShowArticle (char *article) ...@@ -726,12 +726,10 @@ void ShowArticle (char *article)
//=========================================================================== //===========================================================================
#ifndef JAPAN #ifndef JAPAN
#ifdef ARTSEXTERN
int endextern = T_ENDART1; int endextern = T_ENDART1;
#ifndef SPEAR #ifndef SPEAR
int helpextern = T_HELPART; int helpextern = T_HELPART;
#endif #endif
#endif
char helpfilename[13] = "HELPART.", char helpfilename[13] = "HELPART.",
endfilename[13] = "ENDART1."; endfilename[13] = "ENDART1.";
#endif #endif
...@@ -761,29 +759,14 @@ void HelpScreens (void) ...@@ -761,29 +759,14 @@ void HelpScreens (void)
MM_SortMem (); MM_SortMem ();
#else #else
#ifdef ARTSEXTERN
artnum = helpextern; artnum = helpextern;
CA_CacheGrChunk (artnum); CA_CacheGrChunk (artnum);
text = (char *)grsegs[artnum]; text = (char *)grsegs[artnum];
MM_SetLock (&grsegs[artnum], true); MM_SetLock (&grsegs[artnum], true);
#else
CA_LoadFile (helpfilename,&layout);
text = (char *)layout;
MM_SetLock (&layout, true);
#endif
ShowArticle (text); ShowArticle (text);
#ifdef ARTSEXTERN
MM_FreePtr (&grsegs[artnum]); MM_FreePtr (&grsegs[artnum]);
#else
MM_FreePtr (&layout);
#endif
VW_FadeOut(); VW_FadeOut();
...@@ -823,28 +806,14 @@ void EndText (void) ...@@ -823,28 +806,14 @@ void EndText (void)
MM_SortMem (); MM_SortMem ();
#else #else
#ifdef ARTSEXTERN
artnum = endextern+gamestate.episode; artnum = endextern+gamestate.episode;
CA_CacheGrChunk (artnum); CA_CacheGrChunk (artnum);
text = (char *)grsegs[artnum]; text = (char *)grsegs[artnum];
MM_SetLock (&grsegs[artnum], true); MM_SetLock (&grsegs[artnum], true);
#else
endfilename[6] = '1'+gamestate.episode;
CA_LoadFile (endfilename,&layout);
text = (char *)layout;
MM_SetLock (&layout, true);
#endif
ShowArticle (text); ShowArticle (text);
#ifdef ARTSEXTERN
MM_FreePtr (&grsegs[artnum]); MM_FreePtr (&grsegs[artnum]);
#else
MM_FreePtr (&layout);
#endif
VW_FadeOut(); VW_FadeOut();
SETFONTCOLOR(0,15); SETFONTCOLOR(0,15);
......
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