build: delete unused files

Co-authored-by: Jonathan <jonno.5000@gmail.com>
This commit is contained in:
Eric Wasylishen 2021-10-02 17:32:21 -06:00
parent d4464a6503
commit 5135ba05b6
9 changed files with 0 additions and 1220 deletions

View File

@ -24,14 +24,10 @@ set(COMMON_INCLUDES
${CMAKE_SOURCE_DIR}/include/common/qvec.hh
${CMAKE_SOURCE_DIR}/include/common/bspfile.hh
${CMAKE_SOURCE_DIR}/include/common/cmdlib.hh
${CMAKE_SOURCE_DIR}/include/common/lbmlib.hh
${CMAKE_SOURCE_DIR}/include/common/log.hh
${CMAKE_SOURCE_DIR}/include/common/mathlib.hh
${CMAKE_SOURCE_DIR}/include/common/polylib.hh
${CMAKE_SOURCE_DIR}/include/common/scriplib.hh
${CMAKE_SOURCE_DIR}/include/common/threads.hh
${CMAKE_SOURCE_DIR}/include/common/trilib.hh
${CMAKE_SOURCE_DIR}/include/common/wadlib.hh
${CMAKE_SOURCE_DIR}/include/common/bsputils.hh)
set(QBSP_INCLUDES

View File

@ -1,448 +0,0 @@
/* common/lbmlib.c */
#include <common/cmdlib.h>
#include <common/lbmlib.h>
/*
* ============================================================================
* LBM STUFF
* ============================================================================
*/
#define FORMID ('F'+('O'<<8)+((int)'R'<<16)+((int)'M'<<24))
#define ILBMID ('I'+('L'<<8)+((int)'B'<<16)+((int)'M'<<24))
#define PBMID ('P'+('B'<<8)+((int)'M'<<16)+((int)' '<<24))
#define BMHDID ('B'+('M'<<8)+((int)'H'<<16)+((int)'D'<<24))
#define BODYID ('B'+('O'<<8)+((int)'D'<<16)+((int)'Y'<<24))
#define CMAPID ('C'+('M'<<8)+((int)'A'<<16)+((int)'P'<<24))
bmhd_t bmhd;
int
Align(int l)
{
if (l & 1)
return l + 1;
return l;
}
/*
* ================
* LBMRLEdecompress
* Source must be evenly aligned!
* ================
*/
uint8_t *
LBMRLEDecompress(uint8_t *source, uint8_t *unpacked, int bpwidth)
{
int count;
uint8_t b, rept;
count = 0;
do {
rept = *source++;
if (rept > 0x80) {
rept = (rept ^ 0xff) + 2;
b = *source++;
memset(unpacked, b, rept);
unpacked += rept;
} else if (rept < 0x80) {
rept++;
memcpy(unpacked, source, rept);
unpacked += rept;
source += rept;
} else
rept = 0; /* rept of 0x80 is NOP */
count += rept;
} while (count < bpwidth);
if (count > bpwidth)
Error("Decompression exceeded width!\n");
return source;
}
#define BPLANESIZE 128
uint8_t bitplanes[9][BPLANESIZE]; /* max size 1024 by 9 bit planes */
/*
* =================
* MungeBitPlanes8
* This destroys the bit plane data!
* =================
*/
void
MungeBitPlanes8(int width, uint8_t *dest)
{
*dest = width; /* shut up the compiler warning */
Error("MungeBitPlanes8 not rewritten!");
#if 0
asm les di,[dest]
asm mov si, -1 asm mov cx,[width]
mungebyte:asm inc si
asm mov dx, 8
mungebit:asm shl[BYTE PTR bitplanes + BPLANESIZE * 7 + si], 1
asm rcl al, 1
asm shl[BYTE PTR bitplanes + BPLANESIZE * 6 + si], 1
asm rcl al, 1
asm shl[BYTE PTR bitplanes + BPLANESIZE * 5 + si], 1
asm rcl al, 1
asm shl[BYTE PTR bitplanes + BPLANESIZE * 4 + si], 1
asm rcl al, 1
asm shl[BYTE PTR bitplanes + BPLANESIZE * 3 + si], 1
asm rcl al, 1
asm shl[BYTE PTR bitplanes + BPLANESIZE * 2 + si], 1
asm rcl al, 1
asm shl[BYTE PTR bitplanes + BPLANESIZE * 1 + si], 1
asm rcl al, 1
asm shl[BYTE PTR bitplanes + BPLANESIZE * 0 + si], 1
asm rcl al, 1
asm stosb
asm dec cx
asm jz done asm dec dx asm jnz mungebit asm jmp mungebyte done:
#endif
} void
MungeBitPlanes4(int width, uint8_t *dest)
{
*dest = width; /* shut up the compiler warning */
Error("MungeBitPlanes4 not rewritten!");
#if 0
asm les di,[dest]
asm mov si, -1 asm mov cx,[width]
mungebyte:asm inc si
asm mov dx, 8
mungebit:asm xor al, al
asm shl[BYTE PTR bitplanes + BPLANESIZE * 3 + si], 1
asm rcl al, 1
asm shl[BYTE PTR bitplanes + BPLANESIZE * 2 + si], 1
asm rcl al, 1
asm shl[BYTE PTR bitplanes + BPLANESIZE * 1 + si], 1
asm rcl al, 1
asm shl[BYTE PTR bitplanes + BPLANESIZE * 0 + si], 1
asm rcl al, 1
asm stosb
asm dec cx
asm jz done asm dec dx asm jnz mungebit asm jmp mungebyte done:
#endif
} void
MungeBitPlanes2(int width, uint8_t *dest)
{
*dest = width; /* shut up the compiler warning */
Error("MungeBitPlanes2 not rewritten!");
#if 0
asm les di,[dest]
asm mov si, -1 asm mov cx,[width]
mungebyte:asm inc si
asm mov dx, 8
mungebit:asm xor al, al
asm shl[BYTE PTR bitplanes + BPLANESIZE * 1 + si], 1
asm rcl al, 1
asm shl[BYTE PTR bitplanes + BPLANESIZE * 0 + si], 1
asm rcl al, 1
asm stosb
asm dec cx
asm jz done asm dec dx asm jnz mungebit asm jmp mungebyte done:
#endif
} void
MungeBitPlanes1(int width, uint8_t *dest)
{
*dest = width; /* shut up the compiler warning */
Error("MungeBitPlanes1 not rewritten!");
#if 0
asm les di,[dest]
asm mov si, -1 asm mov cx,[width]
mungebyte:asm inc si
asm mov dx, 8
mungebit:asm xor al, al
asm shl[BYTE PTR bitplanes + BPLANESIZE * 0 + si], 1
asm rcl al, 1
asm stosb
asm dec cx
asm jz done asm dec dx asm jnz mungebit asm jmp mungebyte done:
#endif
}
/*
* =================
* LoadLBM
* =================
*/ void
LoadLBM(char *filename, uint8_t **picture, uint8_t **palette)
{
uint8_t *LBMbuffer, *picbuffer, *cmapbuffer;
int y, p, planes;
uint8_t *LBM_P, *LBMEND_P;
uint8_t *pic_p;
uint8_t *body_p;
unsigned rowsize;
int formtype, formlength;
int chunktype, chunklength;
void (*mungecall) (int, uint8_t *);
/* quiet compiler warnings */
picbuffer = NULL;
cmapbuffer = NULL;
mungecall = NULL;
/* load the LBM */
LoadFile(filename, &LBMbuffer);
/* parse the LBM header */
LBM_P = LBMbuffer;
if (*(int *)LBMbuffer != LittleLong(FORMID))
Error("No FORM ID at start of file!\n");
LBM_P += 4;
formlength = BigLong(*(int *)LBM_P);
LBM_P += 4;
LBMEND_P = LBM_P + Align(formlength);
formtype = LittleLong(*(int *)LBM_P);
if (formtype != ILBMID && formtype != PBMID)
Error("Unrecognized form type: %c%c%c%c\n", formtype & 0xff,
(formtype >> 8) & 0xff, (formtype >> 16) & 0xff,
(formtype >> 24) & 0xff);
LBM_P += 4;
/* parse chunks */
while (LBM_P < LBMEND_P) {
chunktype =
LBM_P[0] + (LBM_P[1] << 8) + (LBM_P[2] << 16) + (LBM_P[3] << 24);
LBM_P += 4;
chunklength =
LBM_P[3] + (LBM_P[2] << 8) + (LBM_P[1] << 16) + (LBM_P[0] << 24);
LBM_P += 4;
switch (chunktype) {
case BMHDID:
memcpy(&bmhd, LBM_P, sizeof(bmhd));
bmhd.w = BigShort(bmhd.w);
bmhd.h = BigShort(bmhd.h);
bmhd.x = BigShort(bmhd.x);
bmhd.y = BigShort(bmhd.y);
bmhd.pageWidth = BigShort(bmhd.pageWidth);
bmhd.pageHeight = BigShort(bmhd.pageHeight);
break;
case CMAPID:
cmapbuffer = malloc(768);
memset(cmapbuffer, 0, 768);
memcpy(cmapbuffer, LBM_P, chunklength);
break;
case BODYID:
body_p = LBM_P;
pic_p = picbuffer = malloc(bmhd.w * bmhd.h);
if (formtype == PBMID) {
/* unpack PBM */
for (y = 0; y < bmhd.h; y++, pic_p += bmhd.w) {
if (bmhd.compression == cm_rle1) {
body_p = LBMRLEDecompress((uint8_t *)body_p,
pic_p, bmhd.w);
} else if (bmhd.compression == cm_none) {
memcpy(pic_p, body_p, bmhd.w);
body_p += Align(bmhd.w);
}
}
} else {
/* unpack ILBM */
planes = bmhd.nPlanes;
if (bmhd.masking == ms_mask)
planes++;
rowsize = (bmhd.w + 15) / 16 * 2;
switch (bmhd.nPlanes) {
case 1:
mungecall = MungeBitPlanes1;
break;
case 2:
mungecall = MungeBitPlanes2;
break;
case 4:
mungecall = MungeBitPlanes4;
break;
case 8:
mungecall = MungeBitPlanes8;
break;
default:
Error("Can't munge %i bit planes!\n", bmhd.nPlanes);
}
for (y = 0; y < bmhd.h; y++, pic_p += bmhd.w) {
for (p = 0; p < planes; p++)
if (bmhd.compression == cm_rle1) {
body_p = LBMRLEDecompress((uint8_t *)body_p,
bitplanes[p], rowsize);
} else if (bmhd.compression == cm_none) {
memcpy(bitplanes[p], body_p, rowsize);
body_p += rowsize;
}
mungecall(bmhd.w, pic_p);
}
}
break;
}
LBM_P += Align(chunklength);
}
free(LBMbuffer);
*picture = picbuffer;
*palette = cmapbuffer;
}
/*
* ============================================================================
* WRITE LBM
* ============================================================================
*/
/*
* ==============
* WriteLBMfile
* ==============
*/
void
WriteLBMfile(char *filename, uint8_t *data, int width, int height, uint8_t *palette)
{
uint8_t *lbm, *lbmptr;
int *formlength, *bmhdlength, *cmaplength, *bodylength;
int length;
bmhd_t basebmhd;
lbm = lbmptr = malloc(width * height + 1000);
/* start FORM */
*lbmptr++ = 'F';
*lbmptr++ = 'O';
*lbmptr++ = 'R';
*lbmptr++ = 'M';
formlength = (int *)lbmptr;
lbmptr += 4; /* leave space for length */
*lbmptr++ = 'P';
*lbmptr++ = 'B';
*lbmptr++ = 'M';
*lbmptr++ = ' ';
/* write BMHD */
*lbmptr++ = 'B';
*lbmptr++ = 'M';
*lbmptr++ = 'H';
*lbmptr++ = 'D';
bmhdlength = (int *)lbmptr;
lbmptr += 4; /* leave space for length */
memset(&basebmhd, 0, sizeof(basebmhd));
basebmhd.w = BigShort((short)width);
basebmhd.h = BigShort((short)height);
basebmhd.nPlanes = BigShort(8);
basebmhd.xAspect = BigShort(5);
basebmhd.yAspect = BigShort(6);
basebmhd.pageWidth = BigShort((short)width);
basebmhd.pageHeight = BigShort((short)height);
memcpy(lbmptr, &basebmhd, sizeof(basebmhd));
lbmptr += sizeof(basebmhd);
length = lbmptr - (uint8_t *)bmhdlength - 4;
*bmhdlength = BigLong(length);
if (length & 1)
*lbmptr++ = 0; /* pad chunk to even offset */
/* write CMAP */
*lbmptr++ = 'C';
*lbmptr++ = 'M';
*lbmptr++ = 'A';
*lbmptr++ = 'P';
cmaplength = (int *)lbmptr;
lbmptr += 4; /* leave space for length */
memcpy(lbmptr, palette, 768);
lbmptr += 768;
length = lbmptr - (uint8_t *)cmaplength - 4;
*cmaplength = BigLong(length);
if (length & 1)
*lbmptr++ = 0; /* pad chunk to even offset */
/* write BODY */
*lbmptr++ = 'B';
*lbmptr++ = 'O';
*lbmptr++ = 'D';
*lbmptr++ = 'Y';
bodylength = (int *)lbmptr;
lbmptr += 4; /* leave space for length */
memcpy(lbmptr, data, width * height);
lbmptr += width * height;
length = lbmptr - (uint8_t *)bodylength - 4;
*bodylength = BigLong(length);
if (length & 1)
*lbmptr++ = 0; /* pad chunk to even offset */
/* done */
length = lbmptr - (uint8_t *)formlength - 4;
*formlength = BigLong(length);
if (length & 1)
*lbmptr++ = 0; /* pad chunk to even offset */
/* write output file */
SaveFile(filename, lbm, lbmptr - lbm);
free(lbm);
}

View File

@ -1,159 +0,0 @@
/* scriplib.c */
#include <common/cmdlib.h>
#include <common/scriplib.h>
/*
* ============================================================================
* PARSING STUFF
* ============================================================================
*/
char token[MAXTOKEN];
char *scriptbuffer, *script_p, *scriptend_p;
int grabbed;
int scriptline;
qboolean endofscript;
qboolean tokenready; /* only true if UnGetToken was just called */
/*
* ==============
* LoadScriptFile
* ==============
*/
void
LoadScriptFile(char *filename)
{
int size;
size = LoadFile(filename, &scriptbuffer);
script_p = scriptbuffer;
scriptend_p = script_p + size;
scriptline = 1;
endofscript = false;
tokenready = false;
}
/*
* ==============
* UnGetToken
* Signals that the current token was not used, and should be reported
* for the next GetToken. Note that
*
* GetToken (true);
* UnGetToken ();
* GetToken (false);
*
* could cross a line boundary.
* ==============
*/
void
UnGetToken(void)
{
tokenready = true;
}
/*
* ==============
* GetToken
* ==============
*/
qboolean
GetToken(qboolean crossline)
{
char *token_p;
if (tokenready) { /* is a token allready waiting? */
tokenready = false;
return true;
}
if (script_p >= scriptend_p) {
if (!crossline)
Error("Line %i is incomplete\n", scriptline);
endofscript = true;
return false;
}
/* skip space */
skipspace:
while (*script_p <= 32) {
if (script_p >= scriptend_p) {
if (!crossline)
Error("Line %i is incomplete\n", scriptline);
endofscript = true;
return true;
}
if (*script_p++ == '\n') {
if (!crossline)
Error("Line %i is incomplete\n", scriptline);
scriptline++;
}
}
if (script_p >= scriptend_p) {
if (!crossline)
Error("Line %i is incomplete\n", scriptline);
endofscript = true;
return true;
}
if (*script_p == ';' || *script_p == '#') { /* semicolon is comment field */
/* also make # comment field */
if (!crossline)
Error("Line %i is incomplete\n", scriptline);
while (*script_p++ != '\n')
if (script_p >= scriptend_p) {
endofscript = true;
return false;
}
goto skipspace;
}
/* copy token */
token_p = token;
while (*script_p > 32 && *script_p != ';') {
*token_p++ = *script_p++;
if (script_p == scriptend_p)
break;
if (token_p == &token[MAXTOKEN])
Error("Token too large on line %i\n", scriptline);
}
*token_p = 0;
return true;
}
/*
* ==============
* TokenAvailable
* Returns true if there is another token on the line
* ==============
*/
qboolean
TokenAvailable(void)
{
char *search_p;
search_p = script_p;
if (search_p >= scriptend_p)
return false;
while (*search_p <= 32) {
if (*search_p == '\n')
return false;
search_p++;
if (search_p == scriptend_p)
return false;
}
if (*search_p == ';')
return false;
return true;
}

View File

@ -1,165 +0,0 @@
/*
* common/trilib.c
*
* library for loading triangles from an Alias triangle file
*
*/
#include <stdio.h>
#include <common/cmdlib.h>
#include <common/mathlib.h>
#include <common/trilib.h>
/* on disk representation of a face */
#define FLOAT_START 99999.0
#define FLOAT_END -FLOAT_START
#define MAGIC 123322
/* #define NOISY 1 */
typedef struct {
float v[3];
} vector;
typedef struct {
vector n; /* normal */
vector p; /* point */
vector c; /* color */
float u; /* u */
float v; /* v */
} aliaspoint_t;
typedef struct {
aliaspoint_t pt[3];
} tf_triangle;
void
ByteSwapTri(tf_triangle * tri)
{
int i;
for (i = 0; i < sizeof(tf_triangle) / 4; i++) {
((int *)tri)[i] = BigLong(((int *)tri)[i]);
}
}
void
LoadTriangleList(char *filename, triangle_t ** pptri, int *numtriangles)
{
FILE *input;
float start;
char name[256], tex[256];
int i, count, magic;
tf_triangle tri;
triangle_t *ptri;
int iLevel;
int exitpattern;
float t;
t = -FLOAT_START;
*((unsigned char *)&exitpattern + 0) = *((unsigned char *)&t + 3);
*((unsigned char *)&exitpattern + 1) = *((unsigned char *)&t + 2);
*((unsigned char *)&exitpattern + 2) = *((unsigned char *)&t + 1);
*((unsigned char *)&exitpattern + 3) = *((unsigned char *)&t + 0);
if ((input = fopen(filename, "rb")) == 0) {
fprintf(stderr, "reader: could not open file '%s'\n", filename);
exit(0);
}
iLevel = 0;
fread(&magic, sizeof(int), 1, input);
if (BigLong(magic) != MAGIC) {
fprintf(stderr, "File is not a Alias object separated triangle file,"
" magic number is wrong.\n");
exit(0);
}
ptri = malloc(MAXTRIANGLES * sizeof(triangle_t));
*pptri = ptri;
while (feof(input) == 0) {
fread(&start, sizeof(float), 1, input);
*(int *)&start = BigLong(*(int *)&start);
if (*(int *)&start != exitpattern) {
if (start == FLOAT_START) {
/* Start of an object or group of objects. */
i = -1;
do {
/* There are probably better ways to read a string from */
/* a file, but this does allow you to do error checking */
/* (which I'm not doing) on a per character basis. */
++i;
fread(&(name[i]), sizeof(char), 1, input);
} while (name[i] != '\0');
/* indent(); */
/* fprintf(stdout,"OBJECT START: %s\n",name); */
fread(&count, sizeof(int), 1, input);
count = BigLong(count);
++iLevel;
if (count != 0) {
/* indent(); */
/* fprintf(stdout,"NUMBER OF TRIANGLES: %d\n",count); */
i = -1;
do {
++i;
fread(&(tex[i]), sizeof(char), 1, input);
} while (tex[i] != '\0');
/* indent(); */
/* fprintf(stdout," Object texture name: '%s'\n",tex); */
}
/* Else (count == 0) this is the start of a group, and */
/* no texture name is present. */
} else if (start == FLOAT_END) {
/* End of an object or group. Yes, the name should be */
/* obvious from context, but it is in here just to be */
/* safe and to provide a little extra information for */
/* those who do not wish to write a recursive reader. */
/* Mia culpa. */
--iLevel;
i = -1;
do {
++i;
fread(&(name[i]), sizeof(char), 1, input);
} while (name[i] != '\0');
/* indent(); */
/* fprintf(stdout,"OBJECT END: %s\n",name); */
continue;
}
}
/* read the triangles */
for (i = 0; i < count; ++i) {
int j;
fread(&tri, sizeof(tf_triangle), 1, input);
ByteSwapTri(&tri);
for (j = 0; j < 3; j++) {
int k;
for (k = 0; k < 3; k++) {
ptri->verts[j][k] = tri.pt[j].p.v[k];
}
}
ptri++;
if ((ptri - *pptri) >= MAXTRIANGLES)
Error("Error: too many triangles; increase MAXTRIANGLES\n");
}
}
*numtriangles = ptri - *pptri;
fclose(input);
}

View File

@ -1,311 +0,0 @@
/* common/wadlib.c */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
/* #include <sys/file.h> */
#include <stdarg.h>
#ifdef NeXT
#include <libc.h>
#endif
#include <common/cmdlib.h>
#include <common/wadlib.h>
/* ============================================================================
* WAD READING
* ============================================================================
*/
lumpinfo_t *lumpinfo; /* location of each lump on disk */
int numlumps;
wadinfo_t header;
FILE *wadhandle;
/*
* ====================
* W_OpenWad
* ====================
*/
void
W_OpenWad(char *filename)
{
lumpinfo_t *lump_p;
unsigned i;
int length;
/* open the file and add to directory */
wadhandle = SafeOpenRead(filename);
SafeRead(wadhandle, &header, sizeof(header));
if (strncmp(header.identification, "WAD2", 4))
Error("Wad file %s doesn't have WAD2 id\n", filename);
header.numlumps = LittleLong(header.numlumps);
header.infotableofs = LittleLong(header.infotableofs);
numlumps = header.numlumps;
length = numlumps * sizeof(lumpinfo_t);
lumpinfo = malloc(length);
lump_p = lumpinfo;
fseek(wadhandle, header.infotableofs, SEEK_SET);
SafeRead(wadhandle, lumpinfo, length);
/* Fill in lumpinfo */
for (i = 0; i < numlumps; i++, lump_p++) {
lump_p->filepos = LittleLong(lump_p->filepos);
lump_p->size = LittleLong(lump_p->size);
}
}
void
CleanupName(char *in, char *out)
{
int i;
for (i = 0; i < sizeof(((lumpinfo_t *) 0)->name); i++) {
if (!in[i])
break;
out[i] = toupper(in[i]);
}
for (; i < sizeof(((lumpinfo_t *) 0)->name); i++)
out[i] = 0;
}
/*
* ====================
* W_CheckNumForName
* Returns -1 if name not found
* ====================
*/
int
W_CheckNumForName(char *name)
{
char cleanname[16];
int v1, v2, v3, v4;
int i;
lumpinfo_t *lump_p;
CleanupName(name, cleanname);
/* make the name into four integers for easy compares */
v1 = *(int *)cleanname;
v2 = *(int *)&cleanname[4];
v3 = *(int *)&cleanname[8];
v4 = *(int *)&cleanname[12];
/* find it */
lump_p = lumpinfo;
for (i = 0; i < numlumps; i++, lump_p++) {
if (*(int *)lump_p->name == v1
&& *(int *)&lump_p->name[4] == v2
&& *(int *)&lump_p->name[8] == v3
&& *(int *)&lump_p->name[12] == v4)
return i;
}
return -1;
}
/*
* ====================
* W_GetNumForName
*
* Calls W_CheckNumForName, but bombs out if not found
* ====================
*/
int
W_GetNumForName(char *name)
{
int i;
i = W_CheckNumForName(name);
if (i != -1)
return i;
Error("%s: %s not found!", __func__, name);
return -1;
}
/*
* ====================
* W_LumpLength
* Returns the buffer size needed to load the given lump
* ====================
*/
int
W_LumpLength(int lump)
{
if (lump >= numlumps)
Error("%s: %i >= numlumps", __func__, lump);
return lumpinfo[lump].size;
}
/*
* ====================
* W_ReadLumpNum
* Loads the lump into the given buffer, which must be >= W_LumpLength()
* ====================
*/
void
W_ReadLumpNum(int lump, void *dest)
{
lumpinfo_t *l;
if (lump >= numlumps)
Error("%s: %i >= numlumps", __func__, lump);
l = lumpinfo + lump;
fseek(wadhandle, l->filepos, SEEK_SET);
SafeRead(wadhandle, dest, l->size);
}
/*
* ====================
* W_LoadLumpNum
* ====================
*/
void *
W_LoadLumpNum(int lump)
{
void *buf;
if ((unsigned)lump >= numlumps)
Error("%s: %i >= numlumps", __func__, lump);
buf = malloc(W_LumpLength(lump));
W_ReadLumpNum(lump, buf);
return buf;
}
/*
* ====================
* W_LoadLumpName
* ====================
*/
void *
W_LoadLumpName(char *name)
{
return W_LoadLumpNum(W_GetNumForName(name));
}
/*
* ============================================================================
* WAD CREATION
* ============================================================================
*/
FILE *outwad;
lumpinfo_t outinfo[4096];
int outlumps;
short (*wadshort) (short l);
int (*wadlong) (int l);
/*
* ===============
* NewWad
* ===============
*/
void
NewWad(char *pathname, qboolean bigendien)
{
outwad = SafeOpenWrite(pathname);
fseek(outwad, sizeof(wadinfo_t), SEEK_SET);
memset(outinfo, 0, sizeof(outinfo));
if (bigendien) {
wadshort = BigShort;
wadlong = BigLong;
} else {
wadshort = LittleShort;
wadlong = LittleLong;
}
outlumps = 0;
}
/*
* ===============
* AddLump
* ===============
*/
void
AddLump(char *name, void *buffer, int length, int type, int compress)
{
lumpinfo_t *info;
int ofs;
info = &outinfo[outlumps];
outlumps++;
memset(info, 0, sizeof(info));
strcpy(info->name, name);
Q_strupr(info->name);
ofs = ftell(outwad);
info->filepos = wadlong(ofs);
info->size = info->disksize = wadlong(length);
info->type = type;
info->compression = compress;
/* FIXME: do compression */
SafeWrite(outwad, buffer, length);
}
/*
* ===============
* WriteWad
* ===============
*/
void
WriteWad(void)
{
wadinfo_t header;
int ofs;
/* write the lumpingo */
ofs = ftell(outwad);
SafeWrite(outwad, outinfo, outlumps * sizeof(lumpinfo_t));
/* write the header */
/* a program will be able to tell the ednieness of a wad by the id */
header.identification[0] = 'W';
header.identification[1] = 'A';
header.identification[2] = 'D';
header.identification[3] = '2';
header.numlumps = wadlong(outlumps);
header.infotableofs = wadlong(ofs);
fseek(outwad, 0, SEEK_SET);
SafeWrite(outwad, &header, sizeof(header));
fclose(outwad);
}

View File

@ -1,42 +0,0 @@
/* common/lbmlib.h */
#ifndef __COMMON_LBMLIB_H__
#define __COMMON_LBMLIB_H__
typedef unsigned char UBYTE;
typedef short WORD;
typedef unsigned short UWORD;
typedef long LONG;
typedef enum {
ms_none,
ms_mask,
ms_transcolor,
ms_lasso
} mask_t;
typedef enum {
cm_none,
cm_rle1
} compress_t;
typedef struct {
UWORD w, h;
WORD x, y;
UBYTE nPlanes;
UBYTE masking;
UBYTE compression;
UBYTE pad1;
UWORD transparentColor;
UBYTE xAspect, yAspect;
WORD pageWidth, pageHeight;
} bmhd_t;
extern bmhd_t bmhd; /* will be in native byte order */
void LoadLBM(char *filename, uint8_t **picture, uint8_t **palette);
void WriteLBMfile(char *filename, uint8_t *data, int width, int height,
uint8_t *palette);
#endif /* __COMMON_LBMLIB_H__ */

View File

@ -1,21 +0,0 @@
/* common/scriplib.h */
#ifndef __COMMON_SCRIPLIB_H__
#define __COMMON_SCRIPLIB_H__
#include <common/cmdlib.h>
#define MAXTOKEN 128
extern char token[MAXTOKEN];
extern char *scriptbuffer, *script_p, *scriptend_p;
extern int grabbed;
extern int scriptline;
extern qboolean endofscript;
void LoadScriptFile(char *filename);
qboolean GetToken(qboolean crossline);
void UnGetToken(void);
qboolean TokenAvailable(void);
#endif /* __COMMON_SCRIPLIB_H__ */

View File

@ -1,18 +0,0 @@
/* common/trilib.h
*
* Header file for loading triangles from an Alias triangle file
*
*/
#ifndef __COMMON_TRILIB_H__
#define __COMMON_TRILIB_H__
#define MAXTRIANGLES 2048
typedef struct {
vec3_t verts[3];
} triangle_t;
void LoadTriangleList(char *filename, triangle_t ** pptri, int *numtriangles);
#endif /* __COMMON_TRILIB_H__ */

View File

@ -1,52 +0,0 @@
/* common/wadlib.h */
#ifndef __COMMON_WADLIB_H__
#define __COMMON_WADLIB_H__
/* wad reading */
#define CMP_NONE 0
#define CMP_LZSS 1
#define TYP_NONE 0
#define TYP_LABEL 1
#define TYP_LUMPY 64 /* 64 + grab command number */
typedef struct {
char identification[4]; /* should be WAD2 or 2DAW */
int numlumps;
int infotableofs;
} wadinfo_t;
typedef struct {
int filepos;
int disksize;
int size; /* uncompressed */
char type;
char compression;
char pad1, pad2;
char name[16]; /* must be null terminated */
} lumpinfo_t;
extern lumpinfo_t *lumpinfo; /* location of each lump on disk */
extern int numlumps;
extern wadinfo_t header;
void W_OpenWad(char *filename);
int W_CheckNumForName(char *name);
int W_GetNumForName(char *name);
int W_LumpLength(int lump);
void W_ReadLumpNum(int lump, void *dest);
void *W_LoadLumpNum(int lump);
void *W_LoadLumpName(char *name);
void CleanupName(char *in, char *out);
/* wad creation */
void NewWad(char *pathname, qboolean bigendien);
void AddLump(char *name, void *buffer, int length, int type, int compress);
void WriteWad(void);
#endif /* __COMMON_WADLIB_H__ */