Commit 609432be authored by Steven Fuller's avatar Steven Fuller

Demo loop works, time for gfx mode

parent 3665f119
......@@ -10,10 +10,8 @@ OBJS = objs.o misc.o id_ca.o id_in.o id_sd.o id_vl.o id_vh.o id_us.o \
wl_debug.o
#LFLAGS = -lm -lvga -pg
LFLAGS = -lm -lvga
LFLAGS = -lm -lvga ElectricFence-2.2.2/libefence.a -lpthread
#LFLAGS = /home/relnev/midas/lib/linux/gcdebug/libmidas.a -lpthread -lm -lvga
# /home/relnev/ElectricFence-2.0.5/libefence.a -lm -lvga
NASM = nasm
.SUFFIXES: .asm
......
......@@ -9,3 +9,5 @@ in an effort to not allocate everything to memory and forget about it
* remove virtualreality
* clean up header files, especially wl_def.h, where some externs arent in
the right place
* every structure that is read/written must be PACKED, with datatypes
specifically set! (ie, no int, but short or long int)
......@@ -58,8 +58,6 @@ char extension[5],
aheadname[10]="audiohed.",
afilename[10]="audiot.";
void CA_CannotOpen(char *string);
long *grstarts; /* array of offsets in vgagraph, -1 for sparse */
long *audiostarts; /* array of offsets in audio / audiot */
......@@ -125,6 +123,17 @@ void CAL_GetGrChunkLength (int chunk)
chunkcomplen = GRFILEPOS(chunk+1)-GRFILEPOS(chunk)-4;
}
void CA_CannotOpen(char *string)
{
/* TODO Ow, string must be a small one else boom */
char str[30];
strcpy(str, "Can't open ");
strcat(str, string);
strcat(str, "!\n");
Quit(str);
}
/*
==========================
=
......@@ -286,6 +295,7 @@ boolean CA_LoadFile (char *filename, memptr *ptr)
======================
*/
/* From Ryan C. Gordon -- ryan_gordon@hotmail.com */
#if 1
void CAL_HuffExpand(byte *source, byte *dest, long length, huffnode *htable)
{
huffnode *headptr;
......@@ -314,7 +324,49 @@ void CAL_HuffExpand(byte *source, byte *dest, long length, huffnode *htable)
nodeon = (htable + (path - 256));
} while (dest != endoff);
}
#else
void CAL_HuffExpand(byte *source, byte *dest, long length, huffnode *hufftable)
{
int x;
huffnode *headptr, *nodeon;
byte *ptr, *ptrd, *ptrm;
byte a, mask;
unsigned short int b;
ptrd = dest;
headptr = hufftable + 254; /* head node is allways node 254 */
nodeon = headptr;
ptr = source;
a = *ptr;
ptr++;
mask = 1;
for (x = 0; x < length; x++) {
again:
if (a & mask)
b = nodeon->bit1;
else
b = nodeon->bit0;
mask <<= 1;
if (mask == 0) {
a = *ptr;
ptr++;
mask = 1;
}
if (b & 0xFF00) {
nodeon = hufftable + (b - 256);
goto again;
} else {
nodeon = headptr;
*ptrd = (b & 0x00FF);
ptrd++;
}
}
}
#endif
/*
======================
=
......@@ -696,14 +748,14 @@ void CA_Shutdown (void)
======================
*/
void CA_CacheAudioChunk (int chunk)
void CA_CacheAudioChunk(int chunk)
{
long pos,compressed;
if (audiosegs[chunk])
{
MM_SetPurge ((memptr)&audiosegs[chunk],0);
return; // allready in memory
return;
}
//
......@@ -715,11 +767,22 @@ void CA_CacheAudioChunk (int chunk)
lseek(audiohandle,pos,SEEK_SET);
MM_GetPtr ((memptr)&audiosegs[chunk],compressed);
MM_GetPtr((memptr)&audiosegs[chunk],compressed);
CA_FarRead(audiohandle,audiosegs[chunk],compressed);
}
void CA_UnCacheAudioChunk(int chunk)
{
if (audiosegs[chunk] == 0) {
fprintf(stderr, "Trying to free null audio chunk %d!\n", chunk);
return;
}
MM_FreePtr((memptr *)&audiosegs[chunk]);
audiosegs[chunk] = 0;
}
//===========================================================================
/*
......@@ -786,11 +849,10 @@ cachein:
======================
*/
void CAL_ExpandGrChunk (int chunk, byte *source)
void CAL_ExpandGrChunk(int chunk, byte *source)
{
long expanded;
if (chunk >= STARTTILE8 && chunk < STARTEXTERNS)
{
//
......@@ -801,7 +863,7 @@ void CAL_ExpandGrChunk (int chunk, byte *source)
#define MASKBLOCK 128
if (chunk<STARTTILE8M) // tile 8s are all in one chunk!
expanded = BLOCK*NUMTILE8;
expanded = BLOCK*NUMTILE8 / 4; /* hmm */
else if (chunk<STARTTILE16)
expanded = MASKBLOCK*NUMTILE8M;
else if (chunk<STARTTILE16M) // all other tiles are one/chunk
......@@ -818,7 +880,7 @@ void CAL_ExpandGrChunk (int chunk, byte *source)
//
// everything else has an explicit size longword
//
expanded = *(long *)source;
expanded = *((long *)source);
source += 4; // skip over length
}
......@@ -826,8 +888,8 @@ void CAL_ExpandGrChunk (int chunk, byte *source)
// allocate final space, decompress it, and free bigbuffer
// Sprites need to have shifts made and various other junk
//
MM_GetPtr (&grsegs[chunk],expanded);
CAL_HuffExpand (source,grsegs[chunk],expanded,grhuffman);
MM_GetPtr(&grsegs[chunk], expanded);
CAL_HuffExpand(source, grsegs[chunk], expanded, grhuffman);
}
......@@ -844,18 +906,18 @@ void CAL_ExpandGrChunk (int chunk, byte *source)
void CA_CacheGrChunk(int chunk)
{
long pos,compressed;
memptr bigbufferseg;
byte *source;
int next;
/* this is due to Quit wanting to cache the error screen before this has been set up! */
if ( (grhandle == 0) || (grhandle == -1) ) /* make sure this works ok */
return;
grneeded[chunk] |= ca_levelbit; /* make sure it doesn't get removed */
if (grsegs[chunk])
{
MM_SetPurge (&grsegs[chunk],0);
return; // allready in memory
MM_SetPurge (&grsegs[chunk], 0);
return;
}
//
......@@ -874,17 +936,27 @@ void CA_CacheGrChunk(int chunk)
lseek(grhandle,pos,SEEK_SET);
MM_GetPtr(&bigbufferseg,compressed);
MM_SetLock (&bigbufferseg,true);
CA_FarRead(grhandle,bigbufferseg,compressed);
source = bigbufferseg;
MM_GetPtr((memptr)&source, compressed);
CA_FarRead(grhandle, source, compressed);
CAL_ExpandGrChunk (chunk,source);
CAL_ExpandGrChunk(chunk, source);
MM_FreePtr(&bigbufferseg);
MM_FreePtr((memptr)&source);
}
void CA_UnCacheGrChunk(int chunk)
{
if (grsegs[chunk] == 0) {
fprintf(stderr, "Trying to free null pointer %d!\n", chunk);
return;
}
MM_FreePtr(&grsegs[chunk]);
grneeded[chunk] &= ~ca_levelbit;
/* Or should MM_FreePtr set it to zero? */
grsegs[chunk] = 0;
}
//==========================================================================
......@@ -898,7 +970,7 @@ void CA_CacheGrChunk(int chunk)
======================
*/
void CA_CacheScreen (int chunk)
void CA_CacheScreen(int chunk)
{
long pos,compressed,expanded;
memptr bigbufferseg;
......@@ -1257,16 +1329,6 @@ void CA_CacheMarks (void)
}
#endif
void CA_CannotOpen(char *string)
{
char str[30];
strcpy(str,"Can't open ");
strcat(str,string);
strcat(str,"!\n");
Quit (str);
}
/*
=============================================================================
......
......@@ -6,7 +6,7 @@
#define NUMMAPS 60
#define MAPPLANES 2
#define UNCACHEGRCHUNK(chunk) {MM_FreePtr(&grsegs[chunk]);grneeded[chunk]&=~ca_levelbit;}
#define UNCACHEGRCHUNK CA_UnCacheGrChunk
//===========================================================================
......@@ -60,11 +60,13 @@ void CA_Startup (void);
void CA_Shutdown (void);
void CA_SetGrPurge (void);
void CA_CacheAudioChunk (int chunk);
void CA_CacheAudioChunk(int chunk);
void CA_UnCacheAudioChunk(int chunk);
void CA_LoadAllSounds (void);
void CA_CacheMap (int mapnum);
void CA_CacheGrChunk (int chunk);
void CA_CacheGrChunk(int chunk);
void CA_UnCacheGrChunk(int chunk);
void CA_UpLevel (void);
void CA_DownLevel (void);
......
......@@ -139,20 +139,9 @@ typedef struct
#define sf_Melodic 0
#define sf_Percussive 1
#if 1
typedef struct
{
word length,
values[1];
} MusicGroup;
#else
typedef struct
{
word flags,
count,
offsets[1];
} MusicGroup;
#endif
typedef struct {
word length, values[1];
} PACKED MusicGroup;
typedef struct
{
......
......@@ -835,12 +835,12 @@ void DrawPlayScreen (void)
VW_FadeOut ();
CA_CacheGrChunk (STATUSBARPIC);
CA_CacheGrChunk(STATUSBARPIC);
DrawPlayBorder ();
VWB_DrawPic (0,200-STATUSLINES,STATUSBARPIC);
DrawPlayBorder();
VWB_DrawPic(0,200-STATUSLINES,STATUSBARPIC);
UNCACHEGRCHUNK (STATUSBARPIC);
CA_UnCacheGrChunk(STATUSBARPIC);
DrawFace ();
DrawHealth ();
......
......@@ -1677,7 +1677,7 @@ void CopyProtection(void)
}
for (i=0;i<NUMSOUNDS;i++,start++)
MM_FreePtr ((memptr *)&audiosegs[start]);
CA_UnCacheAudioChunk(start);
return;
}
}
......
......@@ -537,7 +537,7 @@ void BuildTables (void)
sintable[i+ANGLES]=
sintable[ANGLES/2-i] = value;
sintable[ANGLES-i]=
sintable[ANGLES/2+i] = value | 0x80000000l;
sintable[ANGLES/2+i] = -value;
angle += anglestep;
}
......
......@@ -3604,24 +3604,21 @@ void StartCPMusic(int song)
{
musicnames chunk;
if (audiosegs[STARTMUSIC + lastmusic]) // JDC
MM_FreePtr ((memptr *)&audiosegs[STARTMUSIC + lastmusic]);
CA_UnCacheAudioChunk(STARTMUSIC + lastmusic);
lastmusic = song;
SD_MusicOff();
chunk = song;
MM_BombOnError (false);
CA_CacheAudioChunk(STARTMUSIC + chunk);
MM_BombOnError (true);
MM_SetLock((memptr *)&(audiosegs[STARTMUSIC + chunk]),true);
SD_StartMusic((MusicGroup *)audiosegs[STARTMUSIC + chunk]);
}
void FreeMusic (void)
void FreeMusic(void)
{
if (audiosegs[STARTMUSIC + lastmusic]) // JDC
MM_FreePtr ((memptr *)&audiosegs[STARTMUSIC + lastmusic]);
CA_UnCacheAudioChunk(STARTMUSIC + lastmusic);
}
......
......@@ -975,9 +975,7 @@ void StartMusic(void)
// if ((chunk == -1) || (MusicMode != smm_AdLib))
//DEBUG control panel return;
MM_BombOnError (false);
CA_CacheAudioChunk(STARTMUSIC + chunk);
MM_BombOnError (true);
MM_SetLock((memptr)&(audiosegs[STARTMUSIC + chunk]),true);
SD_StartMusic((MusicGroup *)audiosegs[STARTMUSIC + chunk]);
}
......
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