Commit d5ae0bf8 authored by Steven Fuller's avatar Steven Fuller

Pretty much resolved the "latch" issue.

parent a69bba1d
......@@ -45,9 +45,6 @@ CA_FarRead hit EOF?
* if possible fix/or at least add ViewMap?
* remove the #else at the end of each header since nothing is being doubly
included now (if ever)
* fix those tiles that do not wish to be extracted (latches or whathaveyou)
* i don't like this latch nonsense. i think it was for originally storing
data in vga memory. so figure it out, fix it, and remove
* especially with the video functions, there are functions/defines which
just call a different function (most are left from the update block code)
rename/remove them
......@@ -86,6 +83,7 @@ screen update
* dga 1 and 2
* make sure none of the code tries to handle gfx/sound data directly
* GL_shared_texture_palette for opengl
* if window looses focus, should it clear the keys ?
Specific:
* memory/sound intro screen goes
......
......@@ -194,7 +194,7 @@ typedef enum {
#define NUMPICS 125
#define NUMPICM 0
#define NUMSPRITES 0
#define NUMTILE8 72
#define NUMTILE8 35
#define NUMTILE8M 0
#define NUMTILE16 0
#define NUMTILE16M 0
......
......@@ -250,7 +250,7 @@ typedef enum {
#define NUMPICS 147
#define NUMPICM 0
#define NUMSPRITES 0
#define NUMTILE8 72
#define NUMTILE8 35
#define NUMTILE8M 0
#define NUMTILE16 0
#define NUMTILE16M 0
......
......@@ -192,7 +192,7 @@ typedef enum {
#define NUMPICS 144
#define NUMPICM 0
#define NUMSPRITES 0
#define NUMTILE8 72
#define NUMTILE8 35
#define NUMTILE8M 0
#define NUMTILE16 0
#define NUMTILE16M 0
......
......@@ -186,7 +186,7 @@ typedef enum {
#define NUMPICS 132
#define NUMPICM 0
#define NUMSPRITES 0
#define NUMTILE8 72
#define NUMTILE8 35
#define NUMTILE8M 0
#define NUMTILE16 0
#define NUMTILE16M 0
......
......@@ -54,7 +54,6 @@ char extension[5],
gfilename[10]="vgagraph.",
gdictname[10]="vgadict.",
mheadname[10]="maphead.",
mfilename[10]="maptemp.",
aheadname[10]="audiohed.",
afilename[10]="audiot.";
......@@ -111,7 +110,7 @@ void CA_CannotOpen(char *string)
=
= CA_FarRead
=
= Read from a file to a far pointer
= Read from a file to a pointer
=
==========================
*/
......@@ -140,7 +139,7 @@ boolean CA_FarRead(int handle, byte *dest, long length)
=
= CA_FarWrite
=
= Write from a file to a far pointer
= Write from a file to a pointer
=
==========================
*/
......@@ -266,8 +265,9 @@ boolean CA_LoadFile (char *filename, memptr *ptr)
=
======================
*/
/* From Ryan C. Gordon -- ryan_gordon@hotmail.com */
#if 1
/* From Ryan C. Gordon -- ryan_gordon@hotmail.com */
void CAL_HuffExpand(byte *source, byte *dest, long length, huffnode *htable)
{
huffnode *headptr;
......@@ -308,7 +308,7 @@ void CAL_HuffExpand(byte *source, byte *dest, long length, huffnode *hufftable)
ptrd = dest;
headptr = hufftable + 254; /* head node is allways node 254 */
headptr = hufftable + 254; /* head node is always node 254 */
nodeon = headptr;
ptr = source;
......@@ -339,6 +339,7 @@ void CAL_HuffExpand(byte *source, byte *dest, long length, huffnode *hufftable)
}
}
#endif
/*
======================
=
......@@ -352,7 +353,6 @@ void CAL_HuffExpand(byte *source, byte *dest, long length, huffnode *hufftable)
#define NEARTAG 0xa7
#define FARTAG 0xa8
/* TODO: verify correctness of byteinc */
void CAL_CarmackExpand(word *source, word *dest, word length)
{
word ch, chhigh, count, offset;
......@@ -373,13 +373,11 @@ void CAL_CarmackExpand(word *source, word *dest, word length)
/* have to insert a word containing the tag byte */
ch |= **byteinc;
(*byteinc)++;
/* ch |= *((unsigned char *)inptr)++; */
*outptr++ = ch;
length--;
} else {
offset = **byteinc;
(*byteinc)++;
/* offset = *((unsigned char *)inptr)++; */
copyptr = outptr - offset;
length -= count;
while (count--)
......@@ -391,7 +389,6 @@ void CAL_CarmackExpand(word *source, word *dest, word length)
/* have to insert a word containing the tag byte */
ch |= **byteinc;
(*byteinc)++;
/* ch |= *((unsigned char *)inptr)++; */
*outptr++ = ch;
length --;
} else {
......@@ -502,7 +499,7 @@ void CA_RLEWexpand(word *source, word *dest, long length, word rlewtag)
long CAL_GetGrChunkLength(int chunk)
{
long chunkexplen; /* temp var */
long chunkexplen;
lseek(grhandle,GRFILEPOS(chunk),SEEK_SET);
read(grhandle,&chunkexplen,sizeof(chunkexplen));
......@@ -572,7 +569,7 @@ void CAL_SetupGrFile (void)
chunkcomplen = CAL_GetGrChunkLength(STRUCTPIC);
MM_GetPtr(&compseg,chunkcomplen);
CA_FarRead(grhandle,compseg,chunkcomplen);
CAL_HuffExpand (compseg, (byte *)pictable,NUMPICS*sizeof(pictabletype),grhuffman);
CAL_HuffExpand(compseg, (byte *)pictable,NUMPICS*sizeof(pictabletype),grhuffman);
MM_FreePtr(&compseg);
}
......@@ -846,6 +843,7 @@ cachein:
void CAL_ExpandGrChunk(int chunk, byte *source)
{
int tilecount = 0;
long expanded;
int width = 0, height = 0;
......@@ -855,13 +853,15 @@ void CAL_ExpandGrChunk(int chunk, byte *source)
//
// expanded sizes of tile8/16/32 are implicit
//
#define BLOCK 64
#define MASKBLOCK 128
if (chunk<STARTTILE8M) // tile 8s are all in one chunk!
expanded = BLOCK*NUMTILE8 / 4; /* hmm */
else if (chunk<STARTTILE16)
if (chunk<STARTTILE8M) { /* tile 8s are all in one chunk! */
expanded = BLOCK*NUMTILE8;
width = 8;
height = 8;
tilecount = NUMTILE8;
} else if (chunk<STARTTILE16) /* TODO: This is removable */
expanded = MASKBLOCK*NUMTILE8M;
else if (chunk<STARTTILE16M) // all other tiles are one/chunk
expanded = BLOCK*4;
......@@ -871,6 +871,7 @@ void CAL_ExpandGrChunk(int chunk, byte *source)
expanded = BLOCK*16;
else
expanded = MASKBLOCK*16;
} else if (chunk >= STARTPICS && chunk < STARTSPRITES) {
width = pictable[chunk - STARTPICS].width;
height = pictable[chunk - STARTPICS].height;
......@@ -889,8 +890,14 @@ void CAL_ExpandGrChunk(int chunk, byte *source)
//
MM_GetPtr(&grsegs[chunk], expanded);
CAL_HuffExpand(source, grsegs[chunk], expanded, grhuffman);
if (width && height)
VL_DeModeXize(grsegs[chunk], width, height);
if (width && height) {
if (tilecount) {
int i;
for (i = 0; i < tilecount; i++)
VL_DeModeXize(grsegs[chunk]+(width*height)*i, width, height);
} else
VL_DeModeXize(grsegs[chunk], width, height);
}
}
......@@ -922,8 +929,7 @@ void CA_CacheGrChunk(int chunk)
}
//
// load the chunk into a buffer, either the miscbuffer if it fits, or allocate
// a larger buffer
// load the chunk into a buffer
//
pos = GRFILEPOS(chunk);
if (pos < 0) /* $FFFFFFFF start is a sparse tile */
......@@ -941,7 +947,7 @@ void CA_CacheGrChunk(int chunk)
CA_FarRead(grhandle, source, compressed);
CAL_ExpandGrChunk(chunk, source);
MM_FreePtr((memptr)&source);
}
......
......@@ -31,14 +31,11 @@ extern void *grsegs[NUMCHUNKS];
extern byte grneeded[NUMCHUNKS];
extern byte ca_levelbit,ca_levelnum;
extern char *titleptr[8];
extern char extension[5],
gheadname[10],
gfilename[10],
gdictname[10],
mheadname[10],
mfilename[10],
aheadname[10],
afilename[10];
......
......@@ -10,11 +10,6 @@ int px,py;
byte fontcolor,backcolor;
int fontnumber;
/* TODO: more latch nonsense
unsigned freelatch;
unsigned latchpics[NUMLATCHPICS];
*/
boolean screenfaded;
byte palette1[256][3], palette2[256][3];
......@@ -75,8 +70,7 @@ void VW_MeasurePropString (char *string, word *width, word *height)
void VWB_DrawTile8(int x, int y, int tile)
{
/* TODO: 'latches' do not work */
/* LatchDrawChar(x,y,tile); */
VL_MemToScreen(grsegs[STARTTILE8]+(tile*64), 8, 8, x, y);
}
void VWB_DrawPic(int x, int y, int chunknum)
......@@ -142,64 +136,15 @@ void LatchDrawPic(unsigned x, unsigned y, unsigned picnum)
void LoadLatchMem(void)
{
int i,j,p,m,width,height,start,end;
byte *src;
word destoff;
int i;
/*
tile 8s
*/
#if 0 /* I can't get these to extract, if at all */
latchpics[0] = freelatch;
/* tile 8s */
CA_CacheGrChunk (STARTTILE8);
src = (byte *)grsegs[STARTTILE8];
destoff = freelatch;
for (i=0;i<NUMTILE8;i++)
{
VL_MemToLatch (src,8,8,destoff);
src += 64;
destoff +=16;
}
UNCACHEGRCHUNK (STARTTILE8);
#endif
#if 0
/*
tile 16s
*/
src = (byte *)grsegs[STARTTILE16];
latchpics[1] = destoff;
for (i=0;i<NUMTILE16;i++)
{
CA_CacheGrChunk (STARTTILE16+i);
src = (byte *)grsegs[STARTTILE16+i];
VL_MemToLatch (src,16,16,destoff);
destoff+=64;
if (src)
UNCACHEGRCHUNK (STARTTILE16+i);
}
#endif
/*
pics
*/
start = LATCHPICS_LUMP_START;
end = LATCHPICS_LUMP_END;
for (i=start;i<=end;i++)
{
/* pics */
for (i = LATCHPICS_LUMP_START; i <= LATCHPICS_LUMP_END; i++) {
/* TODO: this just caches them for eternity */
CA_CacheGrChunk (i);
#if 0
latchpics[2+i-start] = destoff;
width = pictable[i-STARTPICS].width;
height = pictable[i-STARTPICS].height;
VL_MemToLatch (grsegs[i],width,height,destoff);
destoff += width/4 *height;
UNCACHEGRCHUNK(i);
#endif
}
}
......
......@@ -59,15 +59,6 @@ void VL_FadeIn(int start, int end, byte *palette, int steps);
void LatchDrawPic(unsigned x, unsigned y, unsigned picnum);
void LoadLatchMem(void);
#if 0 /* TODO: find some way to remove this ... */
#define LatchDrawChar(x,y,p) VL_LatchToScreen(latchpics[0]+(p)*16,2,8,x,y)
#define LatchDrawTile(x,y,p) VL_LatchToScreen(latchpics[1]+(p)*64,4,16,x,y)
#define NUMLATCHPICS 100
extern unsigned latchpics[NUMLATCHPICS];
extern unsigned freelatch;
#endif
#else
#error "fix me: TODO"
#endif
......@@ -22,7 +22,6 @@ void VL_Hlin(unsigned x, unsigned y, unsigned width, unsigned color);
void VL_Vlin(int x, int y, int height, int color);
void VL_Bar(int x, int y, int width, int height, int color);
void VL_MemToLatch(byte *source, int width, int height, word dest);
void VL_MemToScreen(byte *source, int width, int height, int x, int y);
void VL_DeModeXize(byte *buf, int width, int height);
......
......@@ -20,7 +20,6 @@ Display *dpy;
int screen;
Window root, win;
XVisualInfo *vi;
XImage *img;
Colormap cmap;
Atom wmDeleteWindow;
GLXContext ctx;
......@@ -171,10 +170,7 @@ void VL_Startup()
{
if (gfxbuf == NULL)
gfxbuf = malloc(320 * 200 * 1);
img = XCreateImage(dpy, vi->visual, 8, ZPixmap, 0, (char *)gfxbuf, 320, 200,
8, 320);
XMapWindow(dpy, win);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
......
......@@ -520,6 +520,8 @@ void OverheadRefresh (void)
tile = (unsigned)actorat[x][y];
break;
}
#define LatchDrawChar(x,y,p) VL_LatchToScreen(latchpics[0]+(p)*16,2,8,x,y)
#define LatchDrawTile(x,y,p) VL_LatchToScreen(latchpics[1]+(p)*64,4,16,x,y)
if (tile<MAXWALLTILES)
LatchDrawTile(sx,sy,tile);
......
......@@ -2,15 +2,6 @@
#include "wl_def.h"
/*
=============================================================================
LOCAL CONSTANTS
=============================================================================
*/
/*
=============================================================================
......@@ -33,12 +24,6 @@ boolean spearflag;
//
int ElevatorBackTo[]={1,1,7,3,5,3};
void ScanInfoPlane (void);
void SetupGameLevel (void);
void DrawPlayScreen (void);
void LoadLatchMem (void);
void GameLoop (void);
/*
=============================================================================
......@@ -104,8 +89,7 @@ byte lefttable[ATABLEMAX][ATABLEMAX * 2] = {
{ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8}
};
void
SetSoundLoc(fixed gx,fixed gy)
void SetSoundLoc(fixed gx,fixed gy)
{
fixed xt,yt;
int x,y;
......
......@@ -2738,7 +2738,7 @@ int HandleMenu(CP_iteminfo *item_i,CP_itemtype *items,void (*routine)(int w))
y=basey+which*13;
VWB_DrawPic(x,y,C_CURSOR1PIC);
SetTextColor(items+which,1);
SetMenuTextColor(items+which,1);
if (redrawitem)
{
PrintX=item_i->x+item_i->indent;
......@@ -2973,7 +2973,7 @@ int HandleMenu(CP_iteminfo *item_i,CP_itemtype *items,void (*routine)(int w))
void EraseGun(CP_iteminfo *item_i,CP_itemtype *items,int x,int y,int which)
{
VWB_Bar(x-1,y,25,16,BKGDCOLOR);
SetTextColor(items+which,0);
SetMenuTextColor(items+which,0);
PrintX=item_i->x+item_i->indent;
PrintY=item_i->y+which*13;
......@@ -3003,7 +3003,7 @@ void DrawGun(CP_iteminfo *item_i,CP_itemtype *items,int x,int *y,int which,int b
VWB_Bar(x-1,*y,25,16,BKGDCOLOR);
*y=basey+which*13;
VWB_DrawPic(x,*y,C_CURSOR1PIC);
SetTextColor(items+which,1);
SetMenuTextColor(items+which,1);
PrintX=item_i->x+item_i->indent;
PrintY=item_i->y+which*13;
......@@ -3051,7 +3051,7 @@ void DrawMenu(CP_iteminfo *item_i,CP_itemtype *items)
for (i=0;i<item_i->amount;i++)
{
SetTextColor(items+i,which==i);
SetMenuTextColor(items+i,which==i);
PrintY=item_i->y+i*13;
if ((items+i)->active)
......@@ -3073,7 +3073,7 @@ void DrawMenu(CP_iteminfo *item_i,CP_itemtype *items)
// SET TEXT COLOR (HIGHLIGHT OR NO)
//
////////////////////////////////////////////////////////////////////
void SetTextColor(CP_itemtype *items,int hlight)
void SetMenuTextColor(CP_itemtype *items,int hlight)
{
if (hlight)
{SETFONTCOLOR(color_hlite[items->active],BKGDCOLOR);}
......
......@@ -136,7 +136,7 @@ void BossKey(void);
void DrawGun(CP_iteminfo *item_i,CP_itemtype *items,int x,int *y,int which,int basey,void (*routine)(int w));
void DrawHalfStep(int x,int y);
void EraseGun(CP_iteminfo *item_i,CP_itemtype *items,int x,int y,int which);
void SetTextColor(CP_itemtype *items,int hlight);
void SetMenuTextColor(CP_itemtype *items,int hlight);
void DrawMenuGun(CP_iteminfo *iteminfo);
void DrawStripes(int y);
......
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