Run engine source through new version of astyle, add printf() call to OSD_Printf() to facilitate console access through stdin/stdout for dedicated server mode, minor changes to sdlayer to allow operating without actually initializing SDL

git-svn-id: https://svn.eduke32.com/eduke32@1762 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2011-01-16 02:50:27 +00:00
parent 1579d2edd3
commit ef912658a0
24 changed files with 3513 additions and 3445 deletions

View file

@ -59,12 +59,12 @@ void setupslopevlin(int32_t logylogx, intptr_t bufplc, int32_t pinc)
} }
void slopevlin(intptr_t p, int32_t i, intptr_t slopaloffs, int32_t cnt, int32_t bx, int32_t by) void slopevlin(intptr_t p, int32_t i, intptr_t slopaloffs, int32_t cnt, int32_t bx, int32_t by)
{ {
intptr_t* slopalptr; intptr_t *slopalptr;
int32_t bz, bzinc; int32_t bz, bzinc;
uint32_t u, v; uint32_t u, v;
bz = asm3; bzinc = (asm1>>3); bz = asm3; bzinc = (asm1>>3);
slopalptr = (intptr_t*)slopaloffs; slopalptr = (intptr_t *)slopaloffs;
for (; cnt>0; cnt--) for (; cnt>0; cnt--)
{ {
i = krecip(bz>>6); bz += bzinc; i = krecip(bz>>6); bz += bzinc;

View file

@ -279,22 +279,22 @@ static int32_t osdcmd_cvar_set_baselayer(const osdfuncparm_t *parm)
if (r != OSDCMD_OK) return r; if (r != OSDCMD_OK) return r;
/* /*
if (!Bstrcasecmp(parm->name, "r_scrcaptureformat")) if (!Bstrcasecmp(parm->name, "r_scrcaptureformat"))
{
const char *fmts[] = {"TGA", "PCX"};
if (showval) { OSD_Printf("r_scrcaptureformat is %s\n", fmts[captureformat]); }
else
{ {
int32_t j; const char *fmts[] = {"TGA", "PCX"};
for (j=0; j<2; j++) if (showval) { OSD_Printf("r_scrcaptureformat is %s\n", fmts[captureformat]); }
if (!Bstrcasecmp(parm->parms[0], fmts[j])) break; else
if (j == 2) return OSDCMD_SHOWHELP; {
captureformat = j; int32_t j;
for (j=0; j<2; j++)
if (!Bstrcasecmp(parm->parms[0], fmts[j])) break;
if (j == 2) return OSDCMD_SHOWHELP;
captureformat = j;
}
return OSDCMD_OK;
} }
return OSDCMD_OK; else */
}
else */
if (!Bstrcasecmp(parm->name, "vid_gamma") || !Bstrcasecmp(parm->name, "vid_brightness") || !Bstrcasecmp(parm->name, "vid_contrast")) if (!Bstrcasecmp(parm->name, "vid_gamma") || !Bstrcasecmp(parm->name, "vid_brightness") || !Bstrcasecmp(parm->name, "vid_contrast"))
{ {
@ -313,17 +313,17 @@ int32_t baselayer_init(void)
cvar_t cvars_engine[] = cvar_t cvars_engine[] =
{ {
#ifdef SUPERBUILD #ifdef SUPERBUILD
{ "r_usenewaspect","r_usenewaspect: enable/disable new screen aspect ratio determination code",(void *)&r_usenewaspect, CVAR_BOOL, 0, 1 }, { "r_usenewaspect","r_usenewaspect: enable/disable new screen aspect ratio determination code",(void *) &r_usenewaspect, CVAR_BOOL, 0, 1 },
{ "r_screenaspect","r_screenaspect: if using the new aspect code and in fullscreen, screen aspect ratio in the form XXYY, e.g. 1609 for 16:9",(void *)&r_screenxy, CVAR_UINT, 100, 9999 }, { "r_screenaspect","r_screenaspect: if using the new aspect code and in fullscreen, screen aspect ratio in the form XXYY, e.g. 1609 for 16:9",(void *) &r_screenxy, CVAR_UINT, 100, 9999 },
{ "r_novoxmips","r_novoxmips: turn off/on the use of mipmaps when rendering 8-bit voxels",(void *)&novoxmips, CVAR_BOOL, 0, 1 }, { "r_novoxmips","r_novoxmips: turn off/on the use of mipmaps when rendering 8-bit voxels",(void *) &novoxmips, CVAR_BOOL, 0, 1 },
{ "r_voxels","r_voxels: enable/disable automatic sprite->voxel rendering",(void *)&usevoxels, CVAR_BOOL, 0, 1 }, { "r_voxels","r_voxels: enable/disable automatic sprite->voxel rendering",(void *) &usevoxels, CVAR_BOOL, 0, 1 },
/* { "r_scrcaptureformat","r_scrcaptureformat: sets the output format for screenshots (TGA or PCX)",osdcmd_vars, CVAR_FUNCPTR, 0, 0 },*/ /* { "r_scrcaptureformat","r_scrcaptureformat: sets the output format for screenshots (TGA or PCX)",osdcmd_vars, CVAR_FUNCPTR, 0, 0 },*/
{ "vid_gamma","vid_gamma <gamma>: adjusts gamma ramp",(void *)&vid_gamma, CVAR_DOUBLE|CVAR_FUNCPTR, 0, 10 }, { "vid_gamma","vid_gamma <gamma>: adjusts gamma ramp",(void *) &vid_gamma, CVAR_DOUBLE|CVAR_FUNCPTR, 0, 10 },
{ "vid_contrast","vid_contrast <gamma>: adjusts gamma ramp",(void *)&vid_contrast, CVAR_DOUBLE|CVAR_FUNCPTR, 0, 10 }, { "vid_contrast","vid_contrast <gamma>: adjusts gamma ramp",(void *) &vid_contrast, CVAR_DOUBLE|CVAR_FUNCPTR, 0, 10 },
{ "vid_brightness","vid_brightness <gamma>: adjusts gamma ramp",(void *)&vid_brightness, CVAR_DOUBLE|CVAR_FUNCPTR, 0, 10 }, { "vid_brightness","vid_brightness <gamma>: adjusts gamma ramp",(void *) &vid_brightness, CVAR_DOUBLE|CVAR_FUNCPTR, 0, 10 },
#endif #endif
{ "debug1","debug counter",(void *)&debug1, CVAR_FLOAT, -100000, 100000 }, { "debug1","debug counter",(void *) &debug1, CVAR_FLOAT, -100000, 100000 },
{ "debug2","debug counter",(void *)&debug2, CVAR_FLOAT, -100000, 100000 }, { "debug2","debug counter",(void *) &debug2, CVAR_FLOAT, -100000, 100000 },
}; };
for (i=0; i<sizeof(cvars_engine)/sizeof(cvars_engine[0]); i++) for (i=0; i<sizeof(cvars_engine)/sizeof(cvars_engine[0]); i++)
@ -332,7 +332,7 @@ int32_t baselayer_init(void)
continue; continue;
OSD_RegisterFunction(cvars_engine[i].name, cvars_engine[i].helpstr, OSD_RegisterFunction(cvars_engine[i].name, cvars_engine[i].helpstr,
(cvars_engine[i].type & CVAR_FUNCPTR) ? osdcmd_cvar_set_baselayer : osdcmd_cvar_set); (cvars_engine[i].type & CVAR_FUNCPTR) ? osdcmd_cvar_set_baselayer : osdcmd_cvar_set);
} }
#ifdef POLYMOST #ifdef POLYMOST

View file

@ -1361,7 +1361,7 @@ static int32_t restore_highlighted_map(mapinfofull_t *mapinfo)
updatenumsprites(); updatenumsprites();
if (numsectors+mapinfo->numsectors>MAXSECTORS || numwalls+mapinfo->numwalls>MAXWALLS if (numsectors+mapinfo->numsectors>MAXSECTORS || numwalls+mapinfo->numwalls>MAXWALLS
|| numsprites+mapinfo->numsprites>MAXSPRITES) || numsprites+mapinfo->numsprites>MAXSPRITES)
{ {
mapinfofull_free(mapinfo); mapinfofull_free(mapinfo);
return -1; return -1;
@ -1735,9 +1735,9 @@ void overheadeditor(void)
while ((keystatus[buildkeys[BK_MODE2D_3D]]>>1) == 0) while ((keystatus[buildkeys[BK_MODE2D_3D]]>>1) == 0)
{ {
if (!((vel|angvel|svel) //DOWN_BK(MOVEFORWARD) || DOWN_BK(MOVEBACKWARD) || DOWN_BK(TURNLEFT) || DOWN_BK(TURNRIGHT) if (!((vel|angvel|svel) //DOWN_BK(MOVEFORWARD) || DOWN_BK(MOVEBACKWARD) || DOWN_BK(TURNLEFT) || DOWN_BK(TURNRIGHT)
|| DOWN_BK(MOVEUP) || DOWN_BK(MOVEDOWN) || keystatus[0x10] || keystatus[0x11] || DOWN_BK(MOVEUP) || DOWN_BK(MOVEDOWN) || keystatus[0x10] || keystatus[0x11]
|| keystatus[0x48] || keystatus[0x4b] || keystatus[0x4d] || keystatus[0x50] // keypad keys || keystatus[0x48] || keystatus[0x4b] || keystatus[0x4d] || keystatus[0x50] // keypad keys
|| bstatus || OSD_IsMoving())) || bstatus || OSD_IsMoving()))
{ {
if (totalclock > waitdelay) if (totalclock > waitdelay)
{ {
@ -1855,8 +1855,8 @@ void overheadeditor(void)
if (numwalls < 0) numwalls = tempint; if (numwalls < 0) numwalls = tempint;
if ((getticks() - lastdraw) >= 5 || (vel|angvel|svel) || DOWN_BK(MOVEUP) || DOWN_BK(MOVEDOWN) if ((getticks() - lastdraw) >= 5 || (vel|angvel|svel) || DOWN_BK(MOVEUP) || DOWN_BK(MOVEDOWN)
|| mousx || mousy || bstatus || keystatus[0x10] || keystatus[0x11] || mousx || mousy || bstatus || keystatus[0x10] || keystatus[0x11]
|| newnumwalls>=0 || OSD_IsMoving()) || newnumwalls>=0 || OSD_IsMoving())
{ {
lastdraw = getticks(); lastdraw = getticks();
@ -2186,8 +2186,8 @@ void overheadeditor(void)
if (gridlock && grid > 0) if (gridlock && grid > 0)
locktogrid(&dax, &day); locktogrid(&dax, &day);
// dax = ((dax+(GRIDMAX>>grid))&(0xffffffff-(GRIDMAX>>(grid-1))+1)); // dax = ((dax+(GRIDMAX>>grid))&(0xffffffff-(GRIDMAX>>(grid-1))+1));
// day = ((day+(GRIDMAX>>grid))&(0xffffffff-(GRIDMAX>>(grid-1))+1)); // day = ((day+(GRIDMAX>>grid))&(0xffffffff-(GRIDMAX>>(grid-1))+1));
for (i=0; i<highlightsectorcnt; i++) for (i=0; i<highlightsectorcnt; i++)
{ {
@ -2709,7 +2709,7 @@ void overheadeditor(void)
for (i=0; i<numwalls; i++) for (i=0; i<numwalls; i++)
if (wall[i].x >= highlightx1 && wall[i].x <= highlightx2 && if (wall[i].x >= highlightx1 && wall[i].x <= highlightx2 &&
wall[i].y >= highlighty1 && wall[i].y <= highlighty2) wall[i].y >= highlighty1 && wall[i].y <= highlighty2)
{ {
if (!sub) if (!sub)
show2dwall[i>>3] |= (1<<(i&7)); show2dwall[i>>3] |= (1<<(i&7));
@ -2719,8 +2719,8 @@ void overheadeditor(void)
for (i=0; i<MAXSPRITES; i++) for (i=0; i<MAXSPRITES; i++)
if (sprite[i].statnum < MAXSTATUS && if (sprite[i].statnum < MAXSTATUS &&
sprite[i].x >= highlightx1 && sprite[i].x <= highlightx2 && sprite[i].x >= highlightx1 && sprite[i].x <= highlightx2 &&
sprite[i].y >= highlighty1 && sprite[i].y <= highlighty2) sprite[i].y >= highlighty1 && sprite[i].y <= highlighty2)
{ {
if (!sub) if (!sub)
{ {
@ -2834,7 +2834,8 @@ void overheadeditor(void)
// visitedwall[j>>3] |= (1<<(j&7)); // visitedwall[j>>3] |= (1<<(j&7));
n--; n--;
} }
} while (j!=refwall && n>0); }
while (j!=refwall && n>0);
if (j!=refwall) if (j!=refwall)
{ {
message("internal error while trying to trace outer loop: j!=refwall"); message("internal error while trying to trace outer loop: j!=refwall");
@ -3051,7 +3052,7 @@ outtathis:
for (i=0; i<numwalls; i++) //make new red lines? for (i=0; i<numwalls; i++) //make new red lines?
{ {
if ((wall[i].x == dax && wall[i].y == day) if ((wall[i].x == dax && wall[i].y == day)
|| (POINT2(i).x == dax && POINT2(i).y == day)) || (POINT2(i).x == dax && POINT2(i).y == day))
{ {
checksectorpointer((int16_t)i,sectorofwall((int16_t)i)); checksectorpointer((int16_t)i,sectorofwall((int16_t)i));
fixrepeats((int16_t)i); fixrepeats((int16_t)i);
@ -3220,21 +3221,21 @@ SKIP:
vec.z = sprite[daspr].z; vec.z = sprite[daspr].z;
if (setsprite(daspr, &vec) == -1 && osec>=0) if (setsprite(daspr, &vec) == -1 && osec>=0)
Bmemcpy(&sprite[daspr], &ovec, sizeof(vec3_t)); Bmemcpy(&sprite[daspr], &ovec, sizeof(vec3_t));
/* /*
daz = ((tilesizy[sprite[daspr].picnum]*sprite[daspr].yrepeat)<<2); daz = ((tilesizy[sprite[daspr].picnum]*sprite[daspr].yrepeat)<<2);
for (i=0; i<numsectors; i++) for (i=0; i<numsectors; i++)
if (inside(dax,day,i) == 1) if (inside(dax,day,i) == 1)
if (sprite[daspr].z >= getceilzofslope(i,dax,day)) if (sprite[daspr].z >= getceilzofslope(i,dax,day))
if (sprite[daspr].z-daz <= getflorzofslope(i,dax,day)) if (sprite[daspr].z-daz <= getflorzofslope(i,dax,day))
{ {
sprite[daspr].x = dax; sprite[daspr].x = dax;
sprite[daspr].y = day; sprite[daspr].y = day;
if (sprite[daspr].sectnum != i) if (sprite[daspr].sectnum != i)
changespritesect(daspr,(int16_t)i); changespritesect(daspr,(int16_t)i);
break; break;
} }
*/ */
} }
} }
asksave = 1; asksave = 1;
@ -3873,7 +3874,7 @@ SKIP:
if ((split == 0) && (firstx == mousxplc) && (firsty == mousyplc) && (newnumwalls >= numwalls+3)) if ((split == 0) && (firstx == mousxplc) && (firsty == mousyplc) && (newnumwalls >= numwalls+3))
{ {
if (suckwall == -1) //if no connections to other sectors if (suckwall == -1) //if no connections to other sectors
{ /* No problem... */ } { /* No problem... */ }
else else
{ {
if (newnumwalls>=MAXWALLS) // still too optimistic since we can have more than one new red wall if (newnumwalls>=MAXWALLS) // still too optimistic since we can have more than one new red wall
@ -5863,7 +5864,7 @@ int32_t _getnumber256(const char *namestart, int32_t num, int32_t maxnumber, cha
// defaultstr: can be NULL // defaultstr: can be NULL
// NO overflow checks are done when copying them! // NO overflow checks are done when copying them!
// maxlen: maximum length of entry string, if ==1, enter single char // maxlen: maximum length of entry string, if ==1, enter single char
const char* getstring_simple(const char *querystr, const char *defaultstr, int32_t maxlen) const char *getstring_simple(const char *querystr, const char *defaultstr, int32_t maxlen)
{ {
static char buf[128]; static char buf[128];
int32_t ei=0, qrylen=0; int32_t ei=0, qrylen=0;

View file

@ -274,12 +274,12 @@ int32_t addsearchpath(const char *p)
} }
if (!(st.st_mode & BS_IFDIR)) return -1; if (!(st.st_mode & BS_IFDIR)) return -1;
srch = (searchpath_t*)Bmalloc(sizeof(searchpath_t)); srch = (searchpath_t *)Bmalloc(sizeof(searchpath_t));
if (!srch) return -1; if (!srch) return -1;
srch->next = searchpathhead; srch->next = searchpathhead;
srch->pathlen = strlen(p)+1; srch->pathlen = strlen(p)+1;
srch->path = (char*)Bmalloc(srch->pathlen + 1); srch->path = (char *)Bmalloc(srch->pathlen + 1);
if (!srch->path) if (!srch->path)
{ {
Bfree(srch); Bfree(srch);
@ -337,7 +337,7 @@ int32_t findfrompath(const char *fn, char **where)
} }
} }
for (pfn = (char*)fn; toupperlookup[*pfn] == '/'; pfn++); for (pfn = (char *)fn; toupperlookup[*pfn] == '/'; pfn++);
ffn = Bstrdup(pfn); ffn = Bstrdup(pfn);
if (!ffn) return -1; if (!ffn) return -1;
Bcorrectfilename(ffn,0); // compress relative paths Bcorrectfilename(ffn,0); // compress relative paths
@ -415,7 +415,7 @@ int32_t openfrompath(const char *fn, int32_t flags, int32_t mode)
return h; return h;
} }
BFILE* fopenfrompath(const char *fn, const char *mode) BFILE *fopenfrompath(const char *fn, const char *mode)
{ {
int32_t fh; int32_t fh;
BFILE *h; BFILE *h;
@ -894,7 +894,7 @@ static int32_t klistaddentry(CACHE1D_FIND_REC **rec, char *name, int32_t type, i
r = (CACHE1D_FIND_REC *)Bmalloc(sizeof(CACHE1D_FIND_REC)+strlen(name)+1); r = (CACHE1D_FIND_REC *)Bmalloc(sizeof(CACHE1D_FIND_REC)+strlen(name)+1);
if (!r) return -1; if (!r) return -1;
r->name = (char*)r + sizeof(CACHE1D_FIND_REC); strcpy(r->name, name); r->name = (char *)r + sizeof(CACHE1D_FIND_REC); strcpy(r->name, name);
r->type = type; r->type = type;
r->source = source; r->source = source;
r->usera = r->userb = NULL; r->usera = r->userb = NULL;

View file

@ -119,47 +119,47 @@ int32_t Blseek(int32_t fildes, int32_t offset, int32_t whence)
BFILE *Bfopen(const char *path, const char *mode) BFILE *Bfopen(const char *path, const char *mode)
{ {
return (BFILE*)fopen(path,mode); return (BFILE *)fopen(path,mode);
} }
int32_t Bfclose(BFILE *stream) int32_t Bfclose(BFILE *stream)
{ {
return fclose((FILE*)stream); return fclose((FILE *)stream);
} }
void Brewind(BFILE *stream) void Brewind(BFILE *stream)
{ {
rewind((FILE*)stream); rewind((FILE *)stream);
} }
int32_t Bfgetc(BFILE *stream) int32_t Bfgetc(BFILE *stream)
{ {
return fgetc((FILE*)stream); return fgetc((FILE *)stream);
} }
char *Bfgets(char *s, int32_t size, BFILE *stream) char *Bfgets(char *s, int32_t size, BFILE *stream)
{ {
return fgets(s,size,(FILE*)stream); return fgets(s,size,(FILE *)stream);
} }
int32_t Bfputc(int32_t c, BFILE *stream) int32_t Bfputc(int32_t c, BFILE *stream)
{ {
return fputc(c,(FILE*)stream); return fputc(c,(FILE *)stream);
} }
int32_t Bfputs(const char *s, BFILE *stream) int32_t Bfputs(const char *s, BFILE *stream)
{ {
return fputs(s,(FILE*)stream); return fputs(s,(FILE *)stream);
} }
bsize_t Bfread(void *ptr, bsize_t size, bsize_t nmemb, BFILE *stream) bsize_t Bfread(void *ptr, bsize_t size, bsize_t nmemb, BFILE *stream)
{ {
return fread(ptr,size,nmemb,(FILE*)stream); return fread(ptr,size,nmemb,(FILE *)stream);
} }
bsize_t Bfwrite(const void *ptr, bsize_t size, bsize_t nmemb, BFILE *stream) bsize_t Bfwrite(const void *ptr, bsize_t size, bsize_t nmemb, BFILE *stream)
{ {
return fwrite(ptr,size,nmemb,(FILE*)stream); return fwrite(ptr,size,nmemb,(FILE *)stream);
} }
@ -387,7 +387,7 @@ char *Bgethomedir(void)
str = CFURLCopyFileSystemPath(base, kCFURLPOSIXPathStyle); str = CFURLCopyFileSystemPath(base, kCFURLPOSIXPathStyle);
CFRelease(base); CFRelease(base);
if (!str) return NULL; if (!str) return NULL;
s = (char*)CFStringGetCStringPtr(str,CFStringGetSystemEncoding()); s = (char *)CFStringGetCStringPtr(str,CFStringGetSystemEncoding());
if (s) s = Bstrdup(s); if (s) s = Bstrdup(s);
CFRelease(str); CFRelease(str);
return s; return s;
@ -417,7 +417,7 @@ char *Bgetsupportdir(int32_t global)
str = CFURLCopyFileSystemPath(base, kCFURLPOSIXPathStyle); str = CFURLCopyFileSystemPath(base, kCFURLPOSIXPathStyle);
CFRelease(base); CFRelease(base);
if (!str) return NULL; if (!str) return NULL;
s = (char*)CFStringGetCStringPtr(str,CFStringGetSystemEncoding()); s = (char *)CFStringGetCStringPtr(str,CFStringGetSystemEncoding());
if (s) s = Bstrdup(s); if (s) s = Bstrdup(s);
CFRelease(str); CFRelease(str);
return s; return s;
@ -585,16 +585,16 @@ typedef struct
char name[1]; char name[1];
} BDIR_real; } BDIR_real;
BDIR* Bopendir(const char *name) BDIR *Bopendir(const char *name)
{ {
BDIR_real *dirr; BDIR_real *dirr;
#ifdef _MSC_VER #ifdef _MSC_VER
char *t,*tt; char *t,*tt;
t = (char*)Bmalloc(strlen(name)+1+4); t = (char *)Bmalloc(strlen(name)+1+4);
if (!t) return NULL; if (!t) return NULL;
#endif #endif
dirr = (BDIR_real*)Bmalloc(sizeof(BDIR_real) + strlen(name)); dirr = (BDIR_real *)Bmalloc(sizeof(BDIR_real) + strlen(name));
if (!dirr) if (!dirr)
{ {
#ifdef _MSC_VER #ifdef _MSC_VER
@ -632,12 +632,12 @@ BDIR* Bopendir(const char *name)
dirr->status = 0; dirr->status = 0;
strcpy(dirr->name, name); strcpy(dirr->name, name);
return (BDIR*)dirr; return (BDIR *)dirr;
} }
struct Bdirent* Breaddir(BDIR *dir) struct Bdirent *Breaddir(BDIR *dir)
{ {
BDIR_real *dirr = (BDIR_real*)dir; BDIR_real *dirr = (BDIR_real *)dir;
struct dirent *de; struct dirent *de;
struct stat st; struct stat st;
char *fn; char *fn;
@ -694,7 +694,7 @@ struct Bdirent* Breaddir(BDIR *dir)
int32_t Bclosedir(BDIR *dir) int32_t Bclosedir(BDIR *dir)
{ {
BDIR_real *dirr = (BDIR_real*)dir; BDIR_real *dirr = (BDIR_real *)dir;
#ifdef _MSC_VER #ifdef _MSC_VER
_findclose(dirr->dir); _findclose(dirr->dir);
@ -798,7 +798,7 @@ uint32_t Bgetsysmemsize(void)
if (lib) if (lib)
{ {
BOOL (WINAPI *aGlobalMemoryStatusEx)(LPMEMORYSTATUSEX) = BOOL (WINAPI *aGlobalMemoryStatusEx)(LPMEMORYSTATUSEX) =
(void *)GetProcAddress(lib, "GlobalMemoryStatusEx"); (void *)GetProcAddress(lib, "GlobalMemoryStatusEx");
if (aGlobalMemoryStatusEx) if (aGlobalMemoryStatusEx)

View file

@ -1502,12 +1502,12 @@ static int32_t defsparser(scriptfile *script)
klseek(fd, 0, SEEK_SET); klseek(fd, 0, SEEK_SET);
if (kread(fd, filebuf, filesize)!=filesize) if (kread(fd, filebuf, filesize)!=filesize)
{ Bfree(highpaldata); initprintf("Error: didn't read all of '%s'.\n", fn); break; } { Bfree(highpaldata); initprintf("Error: didn't read all of '%s'.\n", fn); break; }
kclose(fd); kclose(fd);
kpgetdim(filebuf, filesize, &xsiz, &ysiz); kpgetdim(filebuf, filesize, &xsiz, &ysiz);
if (xsiz != PR_HIGHPALOOKUP_DIM*PR_HIGHPALOOKUP_DIM || ysiz != PR_HIGHPALOOKUP_DIM) if (xsiz != PR_HIGHPALOOKUP_DIM *PR_HIGHPALOOKUP_DIM || ysiz != PR_HIGHPALOOKUP_DIM)
{ {
initprintf("Error: image dimensions of '%s' must be %dx%d.\n", initprintf("Error: image dimensions of '%s' must be %dx%d.\n",
fn, PR_HIGHPALOOKUP_DIM*PR_HIGHPALOOKUP_DIM, PR_HIGHPALOOKUP_DIM); fn, PR_HIGHPALOOKUP_DIM*PR_HIGHPALOOKUP_DIM, PR_HIGHPALOOKUP_DIM);
@ -1518,7 +1518,7 @@ static int32_t defsparser(scriptfile *script)
i = kprender(filebuf, filesize, (intptr_t)highpaldata, xsiz*sizeof(coltype), xsiz, ysiz, 0, 0); i = kprender(filebuf, filesize, (intptr_t)highpaldata, xsiz*sizeof(coltype), xsiz, ysiz, 0, 0);
Bfree(filebuf); Bfree(filebuf);
if (i) if (i)
{ Bfree(highpaldata); initprintf("Error: failed rendering '%s'.\n", fn); break; } { Bfree(highpaldata); initprintf("Error: failed rendering '%s'.\n", fn); break; }
} }
polymer_definehighpalookup(pal, highpaldata); polymer_definehighpalookup(pal, highpaldata);

File diff suppressed because it is too large Load diff

View file

@ -11,277 +11,277 @@
#include "sdl_inc.h" #include "sdl_inc.h"
#endif #endif
void (APIENTRY * bglClearColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); void (APIENTRY *bglClearColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
void (APIENTRY * bglClear)(GLbitfield mask); void (APIENTRY *bglClear)(GLbitfield mask);
void (APIENTRY * bglColorMask)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); void (APIENTRY *bglColorMask)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
void (APIENTRY * bglAlphaFunc)(GLenum func, GLclampf ref); void (APIENTRY *bglAlphaFunc)(GLenum func, GLclampf ref);
void (APIENTRY * bglBlendFunc)(GLenum sfactor, GLenum dfactor); void (APIENTRY *bglBlendFunc)(GLenum sfactor, GLenum dfactor);
void (APIENTRY * bglCullFace)(GLenum mode); void (APIENTRY *bglCullFace)(GLenum mode);
void (APIENTRY * bglFrontFace)(GLenum mode); void (APIENTRY *bglFrontFace)(GLenum mode);
void (APIENTRY * bglPolygonOffset)(GLfloat factor, GLfloat units); void (APIENTRY *bglPolygonOffset)(GLfloat factor, GLfloat units);
void (APIENTRY * bglPolygonMode)(GLenum face, GLenum mode); void (APIENTRY *bglPolygonMode)(GLenum face, GLenum mode);
void (APIENTRY * bglEnable)(GLenum cap); void (APIENTRY *bglEnable)(GLenum cap);
void (APIENTRY * bglDisable)(GLenum cap); void (APIENTRY *bglDisable)(GLenum cap);
void (APIENTRY * bglGetDoublev)(GLenum pname, GLdouble *params); void (APIENTRY *bglGetDoublev)(GLenum pname, GLdouble *params);
void (APIENTRY * bglGetFloatv)(GLenum pname, GLfloat *params); void (APIENTRY *bglGetFloatv)(GLenum pname, GLfloat *params);
void (APIENTRY * bglGetIntegerv)(GLenum pname, GLint *params); void (APIENTRY *bglGetIntegerv)(GLenum pname, GLint *params);
void (APIENTRY * bglPushAttrib)(GLbitfield mask); void (APIENTRY *bglPushAttrib)(GLbitfield mask);
void (APIENTRY * bglPopAttrib)(void); void (APIENTRY *bglPopAttrib)(void);
GLenum(APIENTRY * bglGetError)(void); GLenum(APIENTRY *bglGetError)(void);
const GLubyte*(APIENTRY * bglGetString)(GLenum name); const GLubyte *(APIENTRY *bglGetString)(GLenum name);
void (APIENTRY * bglHint)(GLenum target, GLenum mode); void (APIENTRY *bglHint)(GLenum target, GLenum mode);
void (APIENTRY * bglDrawBuffer)(GLenum mode); void (APIENTRY *bglDrawBuffer)(GLenum mode);
void (APIENTRY * bglReadBuffer)(GLenum mode); void (APIENTRY *bglReadBuffer)(GLenum mode);
void (APIENTRY * bglScissor)(GLint x, GLint y, GLsizei width, GLsizei height); void (APIENTRY *bglScissor)(GLint x, GLint y, GLsizei width, GLsizei height);
void (APIENTRY * bglClipPlane)(GLenum plane, const GLdouble *equation); void (APIENTRY *bglClipPlane)(GLenum plane, const GLdouble *equation);
// Depth // Depth
void (APIENTRY * bglDepthFunc)(GLenum func); void (APIENTRY *bglDepthFunc)(GLenum func);
void (APIENTRY * bglDepthMask)(GLboolean flag); void (APIENTRY *bglDepthMask)(GLboolean flag);
void (APIENTRY * bglDepthRange)(GLclampd near_val, GLclampd far_val); void (APIENTRY *bglDepthRange)(GLclampd near_val, GLclampd far_val);
// Matrix // Matrix
void (APIENTRY * bglMatrixMode)(GLenum mode); void (APIENTRY *bglMatrixMode)(GLenum mode);
void (APIENTRY * bglOrtho)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val); void (APIENTRY *bglOrtho)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val);
void (APIENTRY * bglFrustum)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val); void (APIENTRY *bglFrustum)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val);
void (APIENTRY * bglViewport)(GLint x, GLint y, GLsizei width, GLsizei height); void (APIENTRY *bglViewport)(GLint x, GLint y, GLsizei width, GLsizei height);
void (APIENTRY * bglPushMatrix)(void); void (APIENTRY *bglPushMatrix)(void);
void (APIENTRY * bglPopMatrix)(void); void (APIENTRY *bglPopMatrix)(void);
void (APIENTRY * bglLoadIdentity)(void); void (APIENTRY *bglLoadIdentity)(void);
void (APIENTRY * bglLoadMatrixf)(const GLfloat *m); void (APIENTRY *bglLoadMatrixf)(const GLfloat *m);
void (APIENTRY * bglLoadMatrixd)(const GLdouble *m); void (APIENTRY *bglLoadMatrixd)(const GLdouble *m);
void (APIENTRY * bglMultMatrixf)(const GLfloat *m); void (APIENTRY *bglMultMatrixf)(const GLfloat *m);
void (APIENTRY * bglMultMatrixd)(const GLdouble *m); void (APIENTRY *bglMultMatrixd)(const GLdouble *m);
void (APIENTRY * bglRotatef)(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); void (APIENTRY *bglRotatef)(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
void (APIENTRY * bglScalef)(GLfloat x, GLfloat y, GLfloat z); void (APIENTRY *bglScalef)(GLfloat x, GLfloat y, GLfloat z);
void (APIENTRY * bglTranslatef)(GLfloat x, GLfloat y, GLfloat z); void (APIENTRY *bglTranslatef)(GLfloat x, GLfloat y, GLfloat z);
// Drawing // Drawing
void (APIENTRY * bglBegin)(GLenum mode); void (APIENTRY *bglBegin)(GLenum mode);
void (APIENTRY * bglEnd)(void); void (APIENTRY *bglEnd)(void);
void (APIENTRY * bglVertex2f)(GLfloat x, GLfloat y); void (APIENTRY *bglVertex2f)(GLfloat x, GLfloat y);
void (APIENTRY * bglVertex2i)(GLint x, GLint y); void (APIENTRY *bglVertex2i)(GLint x, GLint y);
void (APIENTRY * bglVertex3f)(GLfloat x, GLfloat y, GLfloat z); void (APIENTRY *bglVertex3f)(GLfloat x, GLfloat y, GLfloat z);
void (APIENTRY * bglVertex3d)(GLdouble x, GLdouble y, GLdouble z); void (APIENTRY *bglVertex3d)(GLdouble x, GLdouble y, GLdouble z);
void (APIENTRY * bglVertex3fv)(const GLfloat *v); void (APIENTRY *bglVertex3fv)(const GLfloat *v);
void (APIENTRY * bglVertex3dv)(const GLdouble *v); void (APIENTRY *bglVertex3dv)(const GLdouble *v);
void (APIENTRY * bglColor4f)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); void (APIENTRY *bglColor4f)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
void (APIENTRY * bglColor4ub)(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); void (APIENTRY *bglColor4ub)(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
void (APIENTRY * bglTexCoord2d)(GLdouble s, GLdouble t); void (APIENTRY *bglTexCoord2d)(GLdouble s, GLdouble t);
void (APIENTRY * bglTexCoord2f)(GLfloat s, GLfloat t); void (APIENTRY *bglTexCoord2f)(GLfloat s, GLfloat t);
void (APIENTRY * bglTexCoord2i)(GLint s, GLint t); void (APIENTRY *bglTexCoord2i)(GLint s, GLint t);
void (APIENTRY * bglNormal3f)(GLfloat x, GLfloat y, GLfloat z); void (APIENTRY *bglNormal3f)(GLfloat x, GLfloat y, GLfloat z);
// Lighting // Lighting
void (APIENTRY * bglShadeModel)(GLenum mode); void (APIENTRY *bglShadeModel)(GLenum mode);
void (APIENTRY * bglLightfv)(GLenum light, GLenum pname, const GLfloat * params); void (APIENTRY *bglLightfv)(GLenum light, GLenum pname, const GLfloat *params);
// Raster funcs // Raster funcs
void (APIENTRY * bglReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); void (APIENTRY *bglReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);
void (APIENTRY * bglRasterPos4i)(GLint x, GLint y, GLint z, GLint w); void (APIENTRY *bglRasterPos4i)(GLint x, GLint y, GLint z, GLint w);
void (APIENTRY * bglDrawPixels)(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); void (APIENTRY *bglDrawPixels)(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
// Texture mapping // Texture mapping
void (APIENTRY * bglTexEnvf)(GLenum target, GLenum pname, GLfloat param); void (APIENTRY *bglTexEnvf)(GLenum target, GLenum pname, GLfloat param);
void (APIENTRY * bglGenTextures)(GLsizei n, GLuint *textures); // 1.1 void (APIENTRY *bglGenTextures)(GLsizei n, GLuint *textures); // 1.1
void (APIENTRY * bglDeleteTextures)(GLsizei n, const GLuint *textures); // 1.1 void (APIENTRY *bglDeleteTextures)(GLsizei n, const GLuint *textures); // 1.1
void (APIENTRY * bglBindTexture)(GLenum target, GLuint texture); // 1.1 void (APIENTRY *bglBindTexture)(GLenum target, GLuint texture); // 1.1
void (APIENTRY * bglTexImage2D)(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); void (APIENTRY *bglTexImage2D)(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
void (APIENTRY * bglTexImage3D)(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); void (APIENTRY *bglTexImage3D)(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
void (APIENTRY * bglCopyTexImage2D)(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); void (APIENTRY *bglCopyTexImage2D)(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
void (APIENTRY * bglCopyTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); void (APIENTRY *bglCopyTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
void (APIENTRY * bglTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); // 1.1 void (APIENTRY *bglTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); // 1.1
void (APIENTRY * bglTexParameterf)(GLenum target, GLenum pname, GLfloat param); void (APIENTRY *bglTexParameterf)(GLenum target, GLenum pname, GLfloat param);
void (APIENTRY * bglTexParameteri)(GLenum target, GLenum pname, GLint param); void (APIENTRY *bglTexParameteri)(GLenum target, GLenum pname, GLint param);
void (APIENTRY * bglGetTexLevelParameteriv)(GLenum target, GLint level, GLenum pname, GLint *params); void (APIENTRY *bglGetTexLevelParameteriv)(GLenum target, GLint level, GLenum pname, GLint *params);
void (APIENTRY * bglCompressedTexImage2DARB)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); void (APIENTRY *bglCompressedTexImage2DARB)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);
void (APIENTRY * bglGetCompressedTexImageARB)(GLenum, GLint, GLvoid *); void (APIENTRY *bglGetCompressedTexImageARB)(GLenum, GLint, GLvoid *);
void (APIENTRY * bglTexGenfv)(GLenum coord, GLenum pname, const GLfloat *params); void (APIENTRY *bglTexGenfv)(GLenum coord, GLenum pname, const GLfloat *params);
// Fog // Fog
void (APIENTRY * bglFogf)(GLenum pname, GLfloat param); void (APIENTRY *bglFogf)(GLenum pname, GLfloat param);
void (APIENTRY * bglFogi)(GLenum pname, GLint param); void (APIENTRY *bglFogi)(GLenum pname, GLint param);
void (APIENTRY * bglFogfv)(GLenum pname, const GLfloat *params); void (APIENTRY *bglFogfv)(GLenum pname, const GLfloat *params);
// Display Lists // Display Lists
void (APIENTRY * bglNewList)(GLuint list, GLenum mode); void (APIENTRY *bglNewList)(GLuint list, GLenum mode);
void (APIENTRY * bglEndList)(void); void (APIENTRY *bglEndList)(void);
void (APIENTRY * bglCallList)(GLuint list); void (APIENTRY *bglCallList)(GLuint list);
void (APIENTRY * bglDeleteLists)(GLuint list, GLsizei range); void (APIENTRY *bglDeleteLists)(GLuint list, GLsizei range);
// Vertex Arrays // Vertex Arrays
void (APIENTRY * bglEnableClientState)(GLenum cap); void (APIENTRY *bglEnableClientState)(GLenum cap);
void (APIENTRY * bglDisableClientState)(GLenum cap); void (APIENTRY *bglDisableClientState)(GLenum cap);
void (APIENTRY * bglVertexPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); void (APIENTRY *bglVertexPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
void (APIENTRY * bglNormalPointer)(GLenum type, GLsizei stride, const GLvoid *pointer); void (APIENTRY *bglNormalPointer)(GLenum type, GLsizei stride, const GLvoid *pointer);
void (APIENTRY * bglTexCoordPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); void (APIENTRY *bglTexCoordPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
void (APIENTRY * bglDrawArrays)(GLenum mode, GLint first, GLsizei count); void (APIENTRY *bglDrawArrays)(GLenum mode, GLint first, GLsizei count);
void (APIENTRY * bglDrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); void (APIENTRY *bglDrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
// Stencil Buffer // Stencil Buffer
void (APIENTRY * bglClearStencil)(GLint s); void (APIENTRY *bglClearStencil)(GLint s);
void (APIENTRY * bglStencilOp)(GLenum fail, GLenum zfail, GLenum zpass); void (APIENTRY *bglStencilOp)(GLenum fail, GLenum zfail, GLenum zpass);
void (APIENTRY * bglStencilFunc)(GLenum func, GLint ref, GLuint mask); void (APIENTRY *bglStencilFunc)(GLenum func, GLint ref, GLuint mask);
// GPU Programs // GPU Programs
void (APIENTRY * bglGenProgramsARB)(GLsizei, GLuint *); void (APIENTRY *bglGenProgramsARB)(GLsizei, GLuint *);
void (APIENTRY * bglBindProgramARB)(GLenum, GLuint); void (APIENTRY *bglBindProgramARB)(GLenum, GLuint);
void (APIENTRY * bglProgramStringARB)(GLenum, GLenum, GLsizei, const GLvoid *); void (APIENTRY *bglProgramStringARB)(GLenum, GLenum, GLsizei, const GLvoid *);
void (APIENTRY * bglDeleteProgramsARB)(GLsizei n, const GLuint *programs); void (APIENTRY *bglDeleteProgramsARB)(GLsizei n, const GLuint *programs);
// Multitexturing // Multitexturing
void (APIENTRY * bglActiveTextureARB)(GLenum texture); void (APIENTRY *bglActiveTextureARB)(GLenum texture);
void (APIENTRY * bglClientActiveTextureARB)(GLenum texture); void (APIENTRY *bglClientActiveTextureARB)(GLenum texture);
void (APIENTRY * bglMultiTexCoord2dARB)(GLenum target, GLdouble s, GLdouble t); void (APIENTRY *bglMultiTexCoord2dARB)(GLenum target, GLdouble s, GLdouble t);
void (APIENTRY * bglMultiTexCoord2fARB)(GLenum target, GLfloat s, GLfloat t); void (APIENTRY *bglMultiTexCoord2fARB)(GLenum target, GLfloat s, GLfloat t);
// Frame Buffer Objects // Frame Buffer Objects
void (APIENTRY * bglGenFramebuffersEXT)(GLsizei n, GLuint *framebuffers); void (APIENTRY *bglGenFramebuffersEXT)(GLsizei n, GLuint *framebuffers);
void (APIENTRY * bglBindFramebufferEXT)(GLenum target, GLuint framebuffer); void (APIENTRY *bglBindFramebufferEXT)(GLenum target, GLuint framebuffer);
void (APIENTRY * bglFramebufferTexture2DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); void (APIENTRY *bglFramebufferTexture2DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
GLenum(APIENTRY * bglCheckFramebufferStatusEXT)(GLenum target); GLenum(APIENTRY *bglCheckFramebufferStatusEXT)(GLenum target);
void (APIENTRY * bglDeleteFramebuffersEXT)(GLsizei n, const GLuint *framebuffers); void (APIENTRY *bglDeleteFramebuffersEXT)(GLsizei n, const GLuint *framebuffers);
// Vertex Buffer Objects // Vertex Buffer Objects
void (APIENTRY * bglGenBuffersARB)(GLsizei n, GLuint * buffers); void (APIENTRY *bglGenBuffersARB)(GLsizei n, GLuint *buffers);
void (APIENTRY * bglBindBufferARB)(GLenum target, GLuint buffer); void (APIENTRY *bglBindBufferARB)(GLenum target, GLuint buffer);
void (APIENTRY * bglDeleteBuffersARB)(GLsizei n, const GLuint * buffers); void (APIENTRY *bglDeleteBuffersARB)(GLsizei n, const GLuint *buffers);
void (APIENTRY * bglBufferDataARB)(GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage); void (APIENTRY *bglBufferDataARB)(GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage);
void (APIENTRY * bglBufferSubDataARB)(GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data); void (APIENTRY *bglBufferSubDataARB)(GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data);
void*(APIENTRY * bglMapBufferARB)(GLenum target, GLenum access); void *(APIENTRY *bglMapBufferARB)(GLenum target, GLenum access);
GLboolean(APIENTRY * bglUnmapBufferARB)(GLenum target); GLboolean(APIENTRY *bglUnmapBufferARB)(GLenum target);
// Occlusion queries // Occlusion queries
void (APIENTRY * bglGenQueriesARB)(GLsizei n, GLuint *ids); void (APIENTRY *bglGenQueriesARB)(GLsizei n, GLuint *ids);
void (APIENTRY * bglDeleteQueriesARB)(GLsizei n, const GLuint *ids); void (APIENTRY *bglDeleteQueriesARB)(GLsizei n, const GLuint *ids);
GLboolean(APIENTRY * bglIsQueryARB)(GLuint id); GLboolean(APIENTRY *bglIsQueryARB)(GLuint id);
void (APIENTRY * bglBeginQueryARB)(GLenum target, GLuint id); void (APIENTRY *bglBeginQueryARB)(GLenum target, GLuint id);
void (APIENTRY * bglEndQueryARB)(GLenum target); void (APIENTRY *bglEndQueryARB)(GLenum target);
void (APIENTRY * bglGetQueryivARB)(GLenum target, GLenum pname, GLint *params); void (APIENTRY *bglGetQueryivARB)(GLenum target, GLenum pname, GLint *params);
void (APIENTRY * bglGetQueryObjectivARB)(GLuint id, GLenum pname, GLint *params); void (APIENTRY *bglGetQueryObjectivARB)(GLuint id, GLenum pname, GLint *params);
void (APIENTRY * bglGetQueryObjectuivARB)(GLuint id, GLenum pname, GLuint *params); void (APIENTRY *bglGetQueryObjectuivARB)(GLuint id, GLenum pname, GLuint *params);
// Shader Objects // Shader Objects
void (APIENTRY * bglDeleteObjectARB)(GLhandleARB); void (APIENTRY *bglDeleteObjectARB)(GLhandleARB);
GLhandleARB(APIENTRY * bglGetHandleARB)(GLenum); GLhandleARB(APIENTRY *bglGetHandleARB)(GLenum);
void (APIENTRY * bglDetachObjectARB)(GLhandleARB, GLhandleARB); void (APIENTRY *bglDetachObjectARB)(GLhandleARB, GLhandleARB);
GLhandleARB(APIENTRY * bglCreateShaderObjectARB)(GLenum); GLhandleARB(APIENTRY *bglCreateShaderObjectARB)(GLenum);
void (APIENTRY * bglShaderSourceARB)(GLhandleARB, GLsizei, const GLcharARB* *, const GLint *); void (APIENTRY *bglShaderSourceARB)(GLhandleARB, GLsizei, const GLcharARB* *, const GLint *);
void (APIENTRY * bglCompileShaderARB)(GLhandleARB); void (APIENTRY *bglCompileShaderARB)(GLhandleARB);
GLhandleARB(APIENTRY * bglCreateProgramObjectARB)(void); GLhandleARB(APIENTRY *bglCreateProgramObjectARB)(void);
void (APIENTRY * bglAttachObjectARB)(GLhandleARB, GLhandleARB); void (APIENTRY *bglAttachObjectARB)(GLhandleARB, GLhandleARB);
void (APIENTRY * bglLinkProgramARB)(GLhandleARB); void (APIENTRY *bglLinkProgramARB)(GLhandleARB);
void (APIENTRY * bglUseProgramObjectARB)(GLhandleARB); void (APIENTRY *bglUseProgramObjectARB)(GLhandleARB);
void (APIENTRY * bglValidateProgramARB)(GLhandleARB); void (APIENTRY *bglValidateProgramARB)(GLhandleARB);
void (APIENTRY * bglUniform1fARB)(GLint, GLfloat); void (APIENTRY *bglUniform1fARB)(GLint, GLfloat);
void (APIENTRY * bglUniform2fARB)(GLint, GLfloat, GLfloat); void (APIENTRY *bglUniform2fARB)(GLint, GLfloat, GLfloat);
void (APIENTRY * bglUniform3fARB)(GLint, GLfloat, GLfloat, GLfloat); void (APIENTRY *bglUniform3fARB)(GLint, GLfloat, GLfloat, GLfloat);
void (APIENTRY * bglUniform4fARB)(GLint, GLfloat, GLfloat, GLfloat, GLfloat); void (APIENTRY *bglUniform4fARB)(GLint, GLfloat, GLfloat, GLfloat, GLfloat);
void (APIENTRY * bglUniform1iARB)(GLint, GLint); void (APIENTRY *bglUniform1iARB)(GLint, GLint);
void (APIENTRY * bglUniform2iARB)(GLint, GLint, GLint); void (APIENTRY *bglUniform2iARB)(GLint, GLint, GLint);
void (APIENTRY * bglUniform3iARB)(GLint, GLint, GLint, GLint); void (APIENTRY *bglUniform3iARB)(GLint, GLint, GLint, GLint);
void (APIENTRY * bglUniform4iARB)(GLint, GLint, GLint, GLint, GLint); void (APIENTRY *bglUniform4iARB)(GLint, GLint, GLint, GLint, GLint);
void (APIENTRY * bglUniform1fvARB)(GLint, GLsizei, const GLfloat *); void (APIENTRY *bglUniform1fvARB)(GLint, GLsizei, const GLfloat *);
void (APIENTRY * bglUniform2fvARB)(GLint, GLsizei, const GLfloat *); void (APIENTRY *bglUniform2fvARB)(GLint, GLsizei, const GLfloat *);
void (APIENTRY * bglUniform3fvARB)(GLint, GLsizei, const GLfloat *); void (APIENTRY *bglUniform3fvARB)(GLint, GLsizei, const GLfloat *);
void (APIENTRY * bglUniform4fvARB)(GLint, GLsizei, const GLfloat *); void (APIENTRY *bglUniform4fvARB)(GLint, GLsizei, const GLfloat *);
void (APIENTRY * bglUniform1ivARB)(GLint, GLsizei, const GLint *); void (APIENTRY *bglUniform1ivARB)(GLint, GLsizei, const GLint *);
void (APIENTRY * bglUniform2ivARB)(GLint, GLsizei, const GLint *); void (APIENTRY *bglUniform2ivARB)(GLint, GLsizei, const GLint *);
void (APIENTRY * bglUniform3ivARB)(GLint, GLsizei, const GLint *); void (APIENTRY *bglUniform3ivARB)(GLint, GLsizei, const GLint *);
void (APIENTRY * bglUniform4ivARB)(GLint, GLsizei, const GLint *); void (APIENTRY *bglUniform4ivARB)(GLint, GLsizei, const GLint *);
void (APIENTRY * bglUniformMatrix2fvARB)(GLint, GLsizei, GLboolean, const GLfloat *); void (APIENTRY *bglUniformMatrix2fvARB)(GLint, GLsizei, GLboolean, const GLfloat *);
void (APIENTRY * bglUniformMatrix3fvARB)(GLint, GLsizei, GLboolean, const GLfloat *); void (APIENTRY *bglUniformMatrix3fvARB)(GLint, GLsizei, GLboolean, const GLfloat *);
void (APIENTRY * bglUniformMatrix4fvARB)(GLint, GLsizei, GLboolean, const GLfloat *); void (APIENTRY *bglUniformMatrix4fvARB)(GLint, GLsizei, GLboolean, const GLfloat *);
void (APIENTRY * bglGetObjectParameterfvARB)(GLhandleARB, GLenum, GLfloat *); void (APIENTRY *bglGetObjectParameterfvARB)(GLhandleARB, GLenum, GLfloat *);
void (APIENTRY * bglGetObjectParameterivARB)(GLhandleARB, GLenum, GLint *); void (APIENTRY *bglGetObjectParameterivARB)(GLhandleARB, GLenum, GLint *);
void (APIENTRY * bglGetInfoLogARB)(GLhandleARB, GLsizei, GLsizei *, GLcharARB *); void (APIENTRY *bglGetInfoLogARB)(GLhandleARB, GLsizei, GLsizei *, GLcharARB *);
void (APIENTRY * bglGetAttachedObjectsARB)(GLhandleARB, GLsizei, GLsizei *, GLhandleARB *); void (APIENTRY *bglGetAttachedObjectsARB)(GLhandleARB, GLsizei, GLsizei *, GLhandleARB *);
GLint(APIENTRY * bglGetUniformLocationARB)(GLhandleARB, const GLcharARB *); GLint(APIENTRY *bglGetUniformLocationARB)(GLhandleARB, const GLcharARB *);
void (APIENTRY * bglGetActiveUniformARB)(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); void (APIENTRY *bglGetActiveUniformARB)(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *);
void (APIENTRY * bglGetUniformfvARB)(GLhandleARB, GLint, GLfloat *); void (APIENTRY *bglGetUniformfvARB)(GLhandleARB, GLint, GLfloat *);
void (APIENTRY * bglGetUniformivARB)(GLhandleARB, GLint, GLint *); void (APIENTRY *bglGetUniformivARB)(GLhandleARB, GLint, GLint *);
void (APIENTRY * bglGetShaderSourceARB)(GLhandleARB, GLsizei, GLsizei *, GLcharARB *); void (APIENTRY *bglGetShaderSourceARB)(GLhandleARB, GLsizei, GLsizei *, GLcharARB *);
// Vertex Shaders // Vertex Shaders
void (APIENTRY * bglVertexAttrib1dARB)(GLuint, GLdouble); void (APIENTRY *bglVertexAttrib1dARB)(GLuint, GLdouble);
void (APIENTRY * bglVertexAttrib1dvARB)(GLuint, const GLdouble *); void (APIENTRY *bglVertexAttrib1dvARB)(GLuint, const GLdouble *);
void (APIENTRY * bglVertexAttrib1fARB)(GLuint, GLfloat); void (APIENTRY *bglVertexAttrib1fARB)(GLuint, GLfloat);
void (APIENTRY * bglVertexAttrib1fvARB)(GLuint, const GLfloat *); void (APIENTRY *bglVertexAttrib1fvARB)(GLuint, const GLfloat *);
void (APIENTRY * bglVertexAttrib1sARB)(GLuint, GLshort); void (APIENTRY *bglVertexAttrib1sARB)(GLuint, GLshort);
void (APIENTRY * bglVertexAttrib1svARB)(GLuint, const GLshort *); void (APIENTRY *bglVertexAttrib1svARB)(GLuint, const GLshort *);
void (APIENTRY * bglVertexAttrib2dARB)(GLuint, GLdouble, GLdouble); void (APIENTRY *bglVertexAttrib2dARB)(GLuint, GLdouble, GLdouble);
void (APIENTRY * bglVertexAttrib2dvARB)(GLuint, const GLdouble *); void (APIENTRY *bglVertexAttrib2dvARB)(GLuint, const GLdouble *);
void (APIENTRY * bglVertexAttrib2fARB)(GLuint, GLfloat, GLfloat); void (APIENTRY *bglVertexAttrib2fARB)(GLuint, GLfloat, GLfloat);
void (APIENTRY * bglVertexAttrib2fvARB)(GLuint, const GLfloat *); void (APIENTRY *bglVertexAttrib2fvARB)(GLuint, const GLfloat *);
void (APIENTRY * bglVertexAttrib2sARB)(GLuint, GLshort, GLshort); void (APIENTRY *bglVertexAttrib2sARB)(GLuint, GLshort, GLshort);
void (APIENTRY * bglVertexAttrib2svARB)(GLuint, const GLshort *); void (APIENTRY *bglVertexAttrib2svARB)(GLuint, const GLshort *);
void (APIENTRY * bglVertexAttrib3dARB)(GLuint, GLdouble, GLdouble, GLdouble); void (APIENTRY *bglVertexAttrib3dARB)(GLuint, GLdouble, GLdouble, GLdouble);
void (APIENTRY * bglVertexAttrib3dvARB)(GLuint, const GLdouble *); void (APIENTRY *bglVertexAttrib3dvARB)(GLuint, const GLdouble *);
void (APIENTRY * bglVertexAttrib3fARB)(GLuint, GLfloat, GLfloat, GLfloat); void (APIENTRY *bglVertexAttrib3fARB)(GLuint, GLfloat, GLfloat, GLfloat);
void (APIENTRY * bglVertexAttrib3fvARB)(GLuint, const GLfloat *); void (APIENTRY *bglVertexAttrib3fvARB)(GLuint, const GLfloat *);
void (APIENTRY * bglVertexAttrib3sARB)(GLuint, GLshort, GLshort, GLshort); void (APIENTRY *bglVertexAttrib3sARB)(GLuint, GLshort, GLshort, GLshort);
void (APIENTRY * bglVertexAttrib3svARB)(GLuint, const GLshort *); void (APIENTRY *bglVertexAttrib3svARB)(GLuint, const GLshort *);
void (APIENTRY * bglVertexAttrib4NbvARB)(GLuint, const GLbyte *); void (APIENTRY *bglVertexAttrib4NbvARB)(GLuint, const GLbyte *);
void (APIENTRY * bglVertexAttrib4NivARB)(GLuint, const GLint *); void (APIENTRY *bglVertexAttrib4NivARB)(GLuint, const GLint *);
void (APIENTRY * bglVertexAttrib4NsvARB)(GLuint, const GLshort *); void (APIENTRY *bglVertexAttrib4NsvARB)(GLuint, const GLshort *);
void (APIENTRY * bglVertexAttrib4NubARB)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte); void (APIENTRY *bglVertexAttrib4NubARB)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte);
void (APIENTRY * bglVertexAttrib4NubvARB)(GLuint, const GLubyte *); void (APIENTRY *bglVertexAttrib4NubvARB)(GLuint, const GLubyte *);
void (APIENTRY * bglVertexAttrib4NuivARB)(GLuint, const GLuint *); void (APIENTRY *bglVertexAttrib4NuivARB)(GLuint, const GLuint *);
void (APIENTRY * bglVertexAttrib4NusvARB)(GLuint, const GLushort *); void (APIENTRY *bglVertexAttrib4NusvARB)(GLuint, const GLushort *);
void (APIENTRY * bglVertexAttrib4bvARB)(GLuint, const GLbyte *); void (APIENTRY *bglVertexAttrib4bvARB)(GLuint, const GLbyte *);
void (APIENTRY * bglVertexAttrib4dARB)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble); void (APIENTRY *bglVertexAttrib4dARB)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble);
void (APIENTRY * bglVertexAttrib4dvARB)(GLuint, const GLdouble *); void (APIENTRY *bglVertexAttrib4dvARB)(GLuint, const GLdouble *);
void (APIENTRY * bglVertexAttrib4fARB)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat); void (APIENTRY *bglVertexAttrib4fARB)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat);
void (APIENTRY * bglVertexAttrib4fvARB)(GLuint, const GLfloat *); void (APIENTRY *bglVertexAttrib4fvARB)(GLuint, const GLfloat *);
void (APIENTRY * bglVertexAttrib4ivARB)(GLuint, const GLint *); void (APIENTRY *bglVertexAttrib4ivARB)(GLuint, const GLint *);
void (APIENTRY * bglVertexAttrib4sARB)(GLuint, GLshort, GLshort, GLshort, GLshort); void (APIENTRY *bglVertexAttrib4sARB)(GLuint, GLshort, GLshort, GLshort, GLshort);
void (APIENTRY * bglVertexAttrib4svARB)(GLuint, const GLshort *); void (APIENTRY *bglVertexAttrib4svARB)(GLuint, const GLshort *);
void (APIENTRY * bglVertexAttrib4ubvARB)(GLuint, const GLubyte *); void (APIENTRY *bglVertexAttrib4ubvARB)(GLuint, const GLubyte *);
void (APIENTRY * bglVertexAttrib4uivARB)(GLuint, const GLuint *); void (APIENTRY *bglVertexAttrib4uivARB)(GLuint, const GLuint *);
void (APIENTRY * bglVertexAttrib4usvARB)(GLuint, const GLushort *); void (APIENTRY *bglVertexAttrib4usvARB)(GLuint, const GLushort *);
void (APIENTRY * bglVertexAttribPointerARB)(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); void (APIENTRY *bglVertexAttribPointerARB)(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *);
void (APIENTRY * bglEnableVertexAttribArrayARB)(GLuint); void (APIENTRY *bglEnableVertexAttribArrayARB)(GLuint);
void (APIENTRY * bglDisableVertexAttribArrayARB)(GLuint); void (APIENTRY *bglDisableVertexAttribArrayARB)(GLuint);
void (APIENTRY * bglGetVertexAttribdvARB)(GLuint, GLenum, GLdouble *); void (APIENTRY *bglGetVertexAttribdvARB)(GLuint, GLenum, GLdouble *);
void (APIENTRY * bglGetVertexAttribfvARB)(GLuint, GLenum, GLfloat *); void (APIENTRY *bglGetVertexAttribfvARB)(GLuint, GLenum, GLfloat *);
void (APIENTRY * bglGetVertexAttribivARB)(GLuint, GLenum, GLint *); void (APIENTRY *bglGetVertexAttribivARB)(GLuint, GLenum, GLint *);
void (APIENTRY * bglGetVertexAttribPointervARB)(GLuint, GLenum, GLvoid* *); void (APIENTRY *bglGetVertexAttribPointervARB)(GLuint, GLenum, GLvoid* *);
void (APIENTRY * bglBindAttribLocationARB)(GLhandleARB, GLuint, const GLcharARB *); void (APIENTRY *bglBindAttribLocationARB)(GLhandleARB, GLuint, const GLcharARB *);
void (APIENTRY * bglGetActiveAttribARB)(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); void (APIENTRY *bglGetActiveAttribARB)(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *);
GLint(APIENTRY * bglGetAttribLocationARB)(GLhandleARB, const GLcharARB *); GLint(APIENTRY *bglGetAttribLocationARB)(GLhandleARB, const GLcharARB *);
// GLU // GLU
void (APIENTRY * bgluTessBeginContour)(GLUtesselator* tess); void (APIENTRY *bgluTessBeginContour)(GLUtesselator *tess);
void (APIENTRY * bgluTessBeginPolygon)(GLUtesselator* tess, GLvoid* data); void (APIENTRY *bgluTessBeginPolygon)(GLUtesselator *tess, GLvoid *data);
void (APIENTRY * bgluTessCallback)(GLUtesselator* tess, GLenum which, void (PR_CALLBACK CallBackFunc)()); void (APIENTRY *bgluTessCallback)(GLUtesselator *tess, GLenum which, void (PR_CALLBACK CallBackFunc)());
void (APIENTRY * bgluTessEndContour)(GLUtesselator* tess); void (APIENTRY *bgluTessEndContour)(GLUtesselator *tess);
void (APIENTRY * bgluTessEndPolygon)(GLUtesselator* tess); void (APIENTRY *bgluTessEndPolygon)(GLUtesselator *tess);
void (APIENTRY * bgluTessNormal)(GLUtesselator* tess, GLdouble valueX, GLdouble valueY, GLdouble valueZ); void (APIENTRY *bgluTessNormal)(GLUtesselator *tess, GLdouble valueX, GLdouble valueY, GLdouble valueZ);
void (APIENTRY * bgluTessProperty)(GLUtesselator* tess, GLenum which, GLdouble data); void (APIENTRY *bgluTessProperty)(GLUtesselator *tess, GLenum which, GLdouble data);
void (APIENTRY * bgluTessVertex)(GLUtesselator* tess, GLdouble *location, GLvoid* data); void (APIENTRY *bgluTessVertex)(GLUtesselator *tess, GLdouble *location, GLvoid *data);
GLUtesselator*(APIENTRY * bgluNewTess)(void); GLUtesselator *(APIENTRY *bgluNewTess)(void);
void (APIENTRY * bgluPerspective)(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar); void (APIENTRY *bgluPerspective)(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar);
const GLubyte *(APIENTRY * bgluErrorString)(GLenum error); const GLubyte *(APIENTRY *bgluErrorString)(GLenum error);
GLint(APIENTRY * bgluProject)(GLdouble objX, GLdouble objY, GLdouble objZ, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble* winX, GLdouble* winY, GLdouble* winZ); GLint(APIENTRY *bgluProject)(GLdouble objX, GLdouble objY, GLdouble objZ, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble *winX, GLdouble *winY, GLdouble *winZ);
GLint (APIENTRY * bgluUnProject)(GLdouble winX, GLdouble winY, GLdouble winZ, const GLdouble * model, const GLdouble * proj, const GLint * view, GLdouble* objX, GLdouble* objY, GLdouble* objZ); GLint(APIENTRY *bgluUnProject)(GLdouble winX, GLdouble winY, GLdouble winZ, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble *objX, GLdouble *objY, GLdouble *objZ);
#ifdef RENDERTYPEWIN #ifdef RENDERTYPEWIN
// Windows // Windows
HGLRC(WINAPI * bwglCreateContext)(HDC); HGLRC(WINAPI *bwglCreateContext)(HDC);
BOOL (WINAPI * bwglDeleteContext)(HGLRC); BOOL (WINAPI *bwglDeleteContext)(HGLRC);
PROC(WINAPI * bwglGetProcAddress)(LPCSTR); PROC(WINAPI *bwglGetProcAddress)(LPCSTR);
BOOL (WINAPI * bwglMakeCurrent)(HDC,HGLRC); BOOL (WINAPI *bwglMakeCurrent)(HDC,HGLRC);
BOOL (WINAPI * bwglSwapBuffers)(HDC); BOOL (WINAPI *bwglSwapBuffers)(HDC);
int32_t (WINAPI * bwglChoosePixelFormat)(HDC,CONST PIXELFORMATDESCRIPTOR*); int32_t (WINAPI *bwglChoosePixelFormat)(HDC,CONST PIXELFORMATDESCRIPTOR *);
int32_t (WINAPI * bwglDescribePixelFormat)(HDC,int32_t,UINT,LPPIXELFORMATDESCRIPTOR); int32_t (WINAPI *bwglDescribePixelFormat)(HDC,int32_t,UINT,LPPIXELFORMATDESCRIPTOR);
int32_t (WINAPI * bwglGetPixelFormat)(HDC); int32_t (WINAPI *bwglGetPixelFormat)(HDC);
BOOL (WINAPI * bwglSetPixelFormat)(HDC,int32_t,const PIXELFORMATDESCRIPTOR*); BOOL (WINAPI *bwglSetPixelFormat)(HDC,int32_t,const PIXELFORMATDESCRIPTOR *);
BOOL (WINAPI * bwglSwapIntervalEXT)(int32_t); BOOL (WINAPI *bwglSwapIntervalEXT)(int32_t);
static HANDLE hGLDLL, hGLUDLL; static HANDLE hGLDLL, hGLUDLL;
#else #else
@ -292,15 +292,15 @@ static void *gluhandle = NULL;
char *gldriver = NULL, *glulibrary = NULL; char *gldriver = NULL, *glulibrary = NULL;
static void * getproc_(const char *s, int32_t *err, int32_t fatal, int32_t extension) static void *getproc_(const char *s, int32_t *err, int32_t fatal, int32_t extension)
{ {
void *t; void *t;
#if defined RENDERTYPESDL #if defined RENDERTYPESDL
UNREFERENCED_PARAMETER(extension); UNREFERENCED_PARAMETER(extension);
t = (void*)SDL_GL_GetProcAddress(s); t = (void *)SDL_GL_GetProcAddress(s);
#elif defined _WIN32 #elif defined _WIN32
if (extension) t = (void*)bwglGetProcAddress(s); if (extension) t = (void *)bwglGetProcAddress(s);
else t = (void*)GetProcAddress(hGLDLL,s); else t = (void *)GetProcAddress(hGLDLL,s);
#else #else
#error Need a dynamic loader for this platform... #error Need a dynamic loader for this platform...
#endif #endif
@ -889,13 +889,13 @@ int32_t unloadgldriver(void)
return 0; return 0;
} }
static void * glugetproc_(const char *s, int32_t *err, int32_t fatal) static void *glugetproc_(const char *s, int32_t *err, int32_t fatal)
{ {
void *t; void *t;
#if defined _WIN32 #if defined _WIN32
t = (void*)GetProcAddress(hGLUDLL,s); t = (void *)GetProcAddress(hGLUDLL,s);
#else #else
t = (void*)dlsym(gluhandle,s); t = (void *)dlsym(gluhandle,s);
#endif #endif
if (!t && fatal) if (!t && fatal)
{ {

View file

@ -20,7 +20,7 @@ char hicfirstinit = 0;
// //
// find the index into hicreplc[] which contains the replacement tile particulars // find the index into hicreplc[] which contains the replacement tile particulars
// //
hicreplctyp * hicfindsubst(int32_t picnum, int32_t palnum, int32_t skybox) hicreplctyp *hicfindsubst(int32_t picnum, int32_t palnum, int32_t skybox)
{ {
if (!hicfirstinit || (uint32_t)picnum >= (uint32_t)MAXTILES) return NULL; if (!hicfirstinit || (uint32_t)picnum >= (uint32_t)MAXTILES) return NULL;

View file

@ -206,7 +206,7 @@ static _inline int32_t bitrev(int32_t b, int32_t c)
mov edx, b mov edx, b
mov ecx, c mov ecx, c
xor eax, eax xor eax, eax
beg: shr edx, 1 beg: shr edx, 1
adc eax, eax adc eax, eax
sub ecx, 1 sub ecx, 1
jnz short beg jnz short beg
@ -230,7 +230,7 @@ static _inline int32_t testflag(int32_t c)
mov eax, 1 mov eax, 1
jne menostinx jne menostinx
xor eax, eax xor eax, eax
menostinx: menostinx:
} }
} }
@ -256,7 +256,7 @@ static _inline void cpuid(int32_t a, int32_t *s)
static inline uint32_t bswap(uint32_t a) static inline uint32_t bswap(uint32_t a)
{ {
__asm__ __volatile__("bswap %0" : "+r"(a) : : "cc"); __asm__ __volatile__("bswap %0" : "+r"(a) : : "cc");
return a; return a;
} }
@ -265,7 +265,7 @@ static inline int32_t bitrev(int32_t b, int32_t c)
int32_t a = 0; int32_t a = 0;
__asm__ __volatile__( __asm__ __volatile__(
"xorl %%eax, %%eax\n\t0:\n\tshrl $1, %%ebx\n\tadcl %%eax, %%eax\n\tsubl $1, %%ecx\n\tjnz 0b" "xorl %%eax, %%eax\n\t0:\n\tshrl $1, %%ebx\n\tadcl %%eax, %%eax\n\tsubl $1, %%ecx\n\tjnz 0b"
: "+a"(a), "+b"(b), "+c"(c) : : "cc"); : "+a"(a), "+b"(b), "+c"(c) : : "cc");
return a; return a;
} }
@ -276,7 +276,7 @@ static inline int32_t testflag(int32_t c)
"pushf\n\tpopl %%eax\n\tmovl %%eax, %%ebx\n\txorl %%ecx, %%eax\n\tpushl %%eax\n\t" "pushf\n\tpopl %%eax\n\tmovl %%eax, %%ebx\n\txorl %%ecx, %%eax\n\tpushl %%eax\n\t"
"popf\n\tpushf\n\tpopl %%eax\n\txorl %%ebx, %%eax\n\tmovl $1, %%eax\n\tjne 0f\n\t" "popf\n\tpushf\n\tpopl %%eax\n\txorl %%ebx, %%eax\n\tmovl $1, %%eax\n\tjne 0f\n\t"
"xorl %%eax, %%eax\n\t0:" "xorl %%eax, %%eax\n\t0:"
: "=a"(a) : "c"(c) : "ebx","cc"); : "=a"(a) : "c"(c) : "ebx","cc");
return a; return a;
} }
@ -285,7 +285,7 @@ static inline void cpuid(int32_t a, int32_t *s)
__asm__ __volatile__( __asm__ __volatile__(
"cpuid\n\tmovl %%eax, (%%esi)\n\tmovl %%ebx, 4(%%esi)\n\t" "cpuid\n\tmovl %%eax, (%%esi)\n\tmovl %%ebx, 4(%%esi)\n\t"
"movl %%ecx, 8(%%esi)\n\tmovl %%edx, 12(%%esi)" "movl %%ecx, 8(%%esi)\n\tmovl %%edx, 12(%%esi)"
: "+a"(a) : "S"(s) : "ebx","ecx","edx","memory","cc"); : "+a"(a) : "S"(s) : "ebx","ecx","edx","memory","cc");
} }
#else #else
@ -337,7 +337,8 @@ static void suckbitsnextblock()
if (!zipfilmode) if (!zipfilmode)
{ {
if (!nfilptr) if (!nfilptr)
{ //|===|===|crc|lng|typ|===|===| {
//|===|===|crc|lng|typ|===|===|
// \ fakebuf: / // \ fakebuf: /
// |===|===| // |===|===|
//----x O---x O-------- //----x O---x O--------
@ -568,26 +569,26 @@ static _inline void rgbhlineasm(int32_t c, int32_t d, int32_t t, int32_t b)
add edx, offset olinbuf add edx, offset olinbuf
cmp dword ptr trnsrgb, 0 cmp dword ptr trnsrgb, 0
jz short begit2 jz short begit2
begit: begit:
mov eax, dword ptr [ecx+edx] mov eax, dword ptr [ecx+edx]
or eax, 0xff000000 or eax, 0xff000000
cmp eax, dword ptr trnsrgb cmp eax, dword ptr trnsrgb
jne short skipit jne short skipit
and eax, 0xffffff and eax, 0xffffff
skipit: skipit:
sub ecx, 3 sub ecx, 3
mov [edi], eax mov [edi], eax
lea edi, [edi+ebx] lea edi, [edi+ebx]
jnz short begit jnz short begit
jmp short endit jmp short endit
begit2: begit2:
mov eax, dword ptr [ecx+edx] mov eax, dword ptr [ecx+edx]
or eax, 0xff000000 or eax, 0xff000000
sub ecx, 3 sub ecx, 3
mov [edi], eax mov [edi], eax
lea edi, [edi+ebx] lea edi, [edi+ebx]
jnz short begit2 jnz short begit2
endit: endit:
pop edi pop edi
pop ebx pop ebx
} }
@ -607,7 +608,7 @@ static _inline void pal8hlineasm(int32_t c, int32_t d, int32_t t, int32_t b)
mov edi, t mov edi, t
mov ebx, b mov ebx, b
add edx, offset olinbuf add edx, offset olinbuf
begit:movzx eax, byte ptr [ecx+edx] begit:movzx eax, byte ptr [ecx+edx]
mov eax, dword ptr palcol[eax*4] mov eax, dword ptr palcol[eax*4]
sub ecx, 1 sub ecx, 1
mov [edi], eax mov [edi], eax
@ -615,7 +616,7 @@ begit:movzx eax, byte ptr [ecx+edx]
jnz short begit jnz short begit
pop edi pop edi
pop ebx pop ebx
endit: endit:
} }
} }
@ -635,8 +636,8 @@ static inline int32_t Paeth686(int32_t a, int32_t b, int32_t c)
"cmovgel %%ebx, %%ecx \n" "cmovgel %%ebx, %%ecx \n"
"cmpl (%%edx,%%eax,4), %%edi \n" "cmpl (%%edx,%%eax,4), %%edi \n"
"cmovgel %%eax, %%ecx \n" "cmovgel %%eax, %%ecx \n"
: "+c"(c) : "a"(a), "b"(b) : "edx","esi","edi","memory","cc" : "+c"(c) : "a"(a), "b"(b) : "edx","esi","edi","memory","cc"
); );
return c; return c;
} }
@ -666,8 +667,8 @@ static inline void rgbhlineasm(int32_t c, int32_t d, int32_t t, int32_t b)
"leal (%%edi,%%ebx,1), %%edi \n" "leal (%%edi,%%ebx,1), %%edi \n"
"jnz 2b \n" "jnz 2b \n"
"3: \n" "3: \n"
: "+c"(c), "+d"(d), "+D"(t) : "b"(b) : "eax","memory","cc" : "+c"(c), "+d"(d), "+D"(t) : "b"(b) : "eax","memory","cc"
); );
} }
static inline void pal8hlineasm(int32_t c, int32_t d, int32_t t, int32_t b) static inline void pal8hlineasm(int32_t c, int32_t d, int32_t t, int32_t b)
@ -683,8 +684,8 @@ static inline void pal8hlineasm(int32_t c, int32_t d, int32_t t, int32_t b)
"leal (%%edi,%%ebx,1), %%edi \n" "leal (%%edi,%%ebx,1), %%edi \n"
"jnz 0b \n" "jnz 0b \n"
"1: \n" "1: \n"
: "+c"(c), "+d"(d), "+D"(t) : "b"(b) : "eax","memory","cc" : "+c"(c), "+d"(d), "+D"(t) : "b"(b) : "eax","memory","cc"
); );
} }
#else #else
@ -747,42 +748,42 @@ static void putbuf(const uint8_t *buf, int32_t leng)
switch (filt) switch (filt)
{ {
case 0: case 0:
while (i < x) { olinbuf[xplc] = buf[i]; xplc--; i++; } while (i < x) { olinbuf[xplc] = buf[i]; xplc--; i++; }
break; break;
case 1: case 1:
while (i < x) while (i < x)
{ {
olinbuf[xplc] = (uint8_t)(opixbuf1[xm] += buf[i]); olinbuf[xplc] = (uint8_t)(opixbuf1[xm] += buf[i]);
xm = xmn[xm]; xplc--; i++; xm = xmn[xm]; xplc--; i++;
} }
break; break;
case 2: case 2:
while (i < x) { olinbuf[xplc] += (uint8_t)buf[i]; xplc--; i++; } while (i < x) { olinbuf[xplc] += (uint8_t)buf[i]; xplc--; i++; }
break; break;
case 3: case 3:
while (i < x) while (i < x)
{ {
opixbuf1[xm] = olinbuf[xplc] = (uint8_t)(((opixbuf1[xm]+olinbuf[xplc])>>1)+buf[i]); opixbuf1[xm] = olinbuf[xplc] = (uint8_t)(((opixbuf1[xm]+olinbuf[xplc])>>1)+buf[i]);
xm = xmn[xm]; xplc--; i++; xm = xmn[xm]; xplc--; i++;
} }
break; break;
case 4: case 4:
while (i < x) while (i < x)
{ {
opixbuf1[xm] = (uint8_t)(Paeth(opixbuf1[xm],olinbuf[xplc],opixbuf0[xm])+buf[i]); opixbuf1[xm] = (uint8_t)(Paeth(opixbuf1[xm],olinbuf[xplc],opixbuf0[xm])+buf[i]);
opixbuf0[xm] = olinbuf[xplc]; opixbuf0[xm] = olinbuf[xplc];
olinbuf[xplc] = opixbuf1[xm]; olinbuf[xplc] = opixbuf1[xm];
xm = xmn[xm]; xplc--; i++; xm = xmn[xm]; xplc--; i++;
} }
break; break;
case 5: //Special hack for Paeth686 (Doesn't have to be case 5) case 5: //Special hack for Paeth686 (Doesn't have to be case 5)
while (i < x) while (i < x)
{ {
opixbuf1[xm] = (uint8_t)(Paeth686(opixbuf1[xm],olinbuf[xplc],opixbuf0[xm])+buf[i]); opixbuf1[xm] = (uint8_t)(Paeth686(opixbuf1[xm],olinbuf[xplc],opixbuf0[xm])+buf[i]);
opixbuf0[xm] = olinbuf[xplc]; opixbuf0[xm] = olinbuf[xplc];
olinbuf[xplc] = opixbuf1[xm]; olinbuf[xplc] = opixbuf1[xm];
xm = xmn[xm]; xplc--; i++; xm = xmn[xm]; xplc--; i++;
} }
break; break;
} }
@ -796,26 +797,26 @@ static void putbuf(const uint8_t *buf, int32_t leng)
{ {
case 2: rgbhlineasm(x,xr1,p,ixstp); break; case 2: rgbhlineasm(x,xr1,p,ixstp); break;
case 4: case 4:
for (; x>xr1; p+=ixstp,x-=2) for (; x>xr1; p+=ixstp,x-=2)
*(int32_t *)p = (palcol[olinbuf[x]]&LSWAPIB(0xffffff))|LSWAPIL((int32_t)olinbuf[x-1]); *(int32_t *)p = (palcol[olinbuf[x]]&LSWAPIB(0xffffff))|LSWAPIL((int32_t)olinbuf[x-1]);
break; break;
case 6: case 6:
for (; x>xr1; p+=ixstp,x-=4) for (; x>xr1; p+=ixstp,x-=4)
{ {
*(char *)(p) = olinbuf[x ]; //B *(char *)(p) = olinbuf[x ]; //B
*(char *)(p+1) = olinbuf[x+1]; //G *(char *)(p+1) = olinbuf[x+1]; //G
*(char *)(p+2) = olinbuf[x+2]; //R *(char *)(p+2) = olinbuf[x+2]; //R
*(char *)(p+3) = olinbuf[x-1]; //A *(char *)(p+3) = olinbuf[x-1]; //A
} }
break; break;
default: default:
switch (bitdepth) switch (bitdepth)
{ {
case 1: for (; x>xr1; p+=ixstp,x--) *(int32_t *)p = palcol[olinbuf[x>>3]>>(x&7)]; break; case 1: for (; x>xr1; p+=ixstp,x--) *(int32_t *)p = palcol[olinbuf[x>>3]>>(x&7)]; break;
case 2: for (; x>xr1; p+=ixstp,x-=2) *(int32_t *)p = palcol[olinbuf[x>>3]>>(x&6)]; break; case 2: for (; x>xr1; p+=ixstp,x-=2) *(int32_t *)p = palcol[olinbuf[x>>3]>>(x&6)]; break;
case 4: for (; x>xr1; p+=ixstp,x-=4) *(int32_t *)p = palcol[olinbuf[x>>3]>>(x&4)]; break; case 4: for (; x>xr1; p+=ixstp,x-=4) *(int32_t *)p = palcol[olinbuf[x>>3]>>(x&4)]; break;
case 8: pal8hlineasm(x,xr1,p,ixstp); break; //for(;x>xr1;p+=ixstp,x-- ) *(int32_t *)p = palcol[olinbuf[x]]; break; case 8: pal8hlineasm(x,xr1,p,ixstp); break; //for(;x>xr1;p+=ixstp,x-- ) *(int32_t *)p = palcol[olinbuf[x]]; break;
} }
break; break;
} }
nfplace += nbpl; nfplace += nbpl;
@ -916,19 +917,19 @@ static int32_t kpngrend(const char *kfilebuf, int32_t kfilength,
switch (coltype) switch (coltype)
{ {
case 0: case 4: case 0: case 4:
bakcol = (((int32_t)filptr[0]<<8)+(int32_t)filptr[1])*255/((1<<bitdepth)-1); bakcol = (((int32_t)filptr[0]<<8)+(int32_t)filptr[1])*255/((1<<bitdepth)-1);
bakcol = bakcol*0x10101+0xff000000; break; bakcol = bakcol*0x10101+0xff000000; break;
case 2: case 6: case 2: case 6:
if (bitdepth == 8) if (bitdepth == 8)
{ bakcol = (((int32_t)filptr[1])<<16)+(((int32_t)filptr[3])<<8)+((int32_t)filptr[5])+0xff000000; } { bakcol = (((int32_t)filptr[1])<<16)+(((int32_t)filptr[3])<<8)+((int32_t)filptr[5])+0xff000000; }
else else
{ {
for (i=0,bakcol=0xff000000; i<3; i++) for (i=0,bakcol=0xff000000; i<3; i++)
bakcol += ((((((int32_t)filptr[i<<1])<<8)+((int32_t)filptr[(i<<1)+1]))/257)<<(16-(i<<3))); bakcol += ((((((int32_t)filptr[i<<1])<<8)+((int32_t)filptr[(i<<1)+1]))/257)<<(16-(i<<3)));
} }
break; break;
case 3: case 3:
bakcol = palcol[filptr[0]]; break; bakcol = palcol[filptr[0]]; break;
} }
bakr = ((bakcol>>16)&255); bakr = ((bakcol>>16)&255);
bakg = ((bakcol>>8)&255); bakg = ((bakcol>>8)&255);
@ -940,18 +941,18 @@ static int32_t kpngrend(const char *kfilebuf, int32_t kfilength,
switch (coltype) switch (coltype)
{ {
case 0: case 0:
if (bitdepth <= 8) if (bitdepth <= 8)
palcol[(int32_t)filptr[1]] &= LSWAPIB(0xffffff); palcol[(int32_t)filptr[1]] &= LSWAPIB(0xffffff);
//else {} // /c0 /d16 not yet supported //else {} // /c0 /d16 not yet supported
break; break;
case 2: case 2:
if (bitdepth == 8) if (bitdepth == 8)
{ trnsrgb = LSWAPIB((((int32_t)filptr[1])<<16)+(((int32_t)filptr[3])<<8)+((int32_t)filptr[5])+0xff000000); } { trnsrgb = LSWAPIB((((int32_t)filptr[1])<<16)+(((int32_t)filptr[3])<<8)+((int32_t)filptr[5])+0xff000000); }
//else {} //WARNING: PNG docs say: MUST compare all 48 bits :( //else {} //WARNING: PNG docs say: MUST compare all 48 bits :(
break; break;
case 3: case 3:
for (i=min(leng,paleng)-1; i>=0; i--) for (i=min(leng,paleng)-1; i>=0; i--)
palcol[i] &= LSWAPIB((((int32_t)filptr[i])<<24)|0xffffff); palcol[i] &= LSWAPIB((((int32_t)filptr[i])<<24)|0xffffff);
break; break;
default:; default:;
} }
@ -1107,7 +1108,7 @@ static int32_t kpngrend(const char *kfilebuf, int32_t kfilength,
putbuf(slidebuf,slidew&32767); putbuf(slidebuf,slidew&32767);
} }
kpngrend_goodret:; kpngrend_goodret:;
if (!(filterest&~(1<<filter1st))) filtype = (int8_t)filter1st; if (!(filterest&~(1<<filter1st))) filtype = (int8_t)filter1st;
else if ((filter1st == 1) && (!(filterest&~(1<<3)))) filtype = 3; else if ((filter1st == 1) && (!(filterest&~(1<<3)))) filtype = 3;
else filtype = 5; else filtype = 5;
@ -1187,7 +1188,7 @@ static inline int32_t mulshr32(int32_t a, int32_t b)
#endif #endif
static int32_t cosqr16[8] = //cosqr16[i] = ((cos(PI*i/16)*sqrt(2))<<24); static int32_t cosqr16[8] = //cosqr16[i] = ((cos(PI*i/16)*sqrt(2))<<24);
{23726566,23270667,21920489,19727919,16777216,13181774,9079764,4628823}; {23726566,23270667,21920489,19727919,16777216,13181774,9079764,4628823};
static int32_t crmul[4096], cbmul[4096]; static int32_t crmul[4096], cbmul[4096];
static void initkpeg() static void initkpeg()
@ -1431,8 +1432,8 @@ static int32_t kpegrend(const char *kfilebuf, int32_t kfilength,
switch (marker) switch (marker)
{ {
case 0xc0: case 0xc1: case 0xc2: case 0xc0: case 0xc1: case 0xc2:
//processit! //processit!
kfileptr++; //numbits = *kfileptr++; kfileptr++; //numbits = *kfileptr++;
ydim = SSWAPIL(*(uint16_t *)&kfileptr[0]); ydim = SSWAPIL(*(uint16_t *)&kfileptr[0]);
xdim = SSWAPIL(*(uint16_t *)&kfileptr[2]); xdim = SSWAPIL(*(uint16_t *)&kfileptr[2]);
@ -1463,64 +1464,64 @@ static int32_t kpegrend(const char *kfilebuf, int32_t kfilength,
break; break;
case 0xc4: //Huffman table case 0xc4: //Huffman table
do do
{
ch = *kfileptr++; leng--;
if (ch >= 16) { index = ch-12; }
else { index = ch; }
Bmemcpy((void *)&hufnumatbit[index][1],(void *)kfileptr,16); kfileptr += 16;
leng -= 16;
v = 0; hufcnt[index] = 0;
hufquickcnt[index] = 0;
for (i=1; i<=16; i++)
{ {
hufmaxatbit[index][i] = v+hufnumatbit[index][i]; ch = *kfileptr++; leng--;
hufvalatbit[index][i] = hufcnt[index]-v; if (ch >= 16) { index = ch-12; }
Bmemcpy((void *)&huftable[index][hufcnt[index]],(void *)kfileptr,(int32_t)hufnumatbit[index][i]); else { index = ch; }
if (i <= 10) Bmemcpy((void *)&hufnumatbit[index][1],(void *)kfileptr,16); kfileptr += 16;
for (c=0; c<hufnumatbit[index][i]; c++) leng -= 16;
for (j=(1<<(10-i)); j>0; j--)
{
hufquickval[index][hufquickcnt[index]] = huftable[index][hufcnt[index]+c];
hufquickbits[index][hufquickcnt[index]] = i;
hufquickcnt[index]++;
}
kfileptr += hufnumatbit[index][i];
leng -= hufnumatbit[index][i];
hufcnt[index] += hufnumatbit[index][i];
v = ((v+hufnumatbit[index][i])<<1);
}
} v = 0; hufcnt[index] = 0;
while (leng > 0); hufquickcnt[index] = 0;
for (i=1; i<=16; i++)
{
hufmaxatbit[index][i] = v+hufnumatbit[index][i];
hufvalatbit[index][i] = hufcnt[index]-v;
Bmemcpy((void *)&huftable[index][hufcnt[index]],(void *)kfileptr,(int32_t)hufnumatbit[index][i]);
if (i <= 10)
for (c=0; c<hufnumatbit[index][i]; c++)
for (j=(1<<(10-i)); j>0; j--)
{
hufquickval[index][hufquickcnt[index]] = huftable[index][hufcnt[index]+c];
hufquickbits[index][hufquickcnt[index]] = i;
hufquickcnt[index]++;
}
kfileptr += hufnumatbit[index][i];
leng -= hufnumatbit[index][i];
hufcnt[index] += hufnumatbit[index][i];
v = ((v+hufnumatbit[index][i])<<1);
}
}
while (leng > 0);
break; break;
case 0xdb: case 0xdb:
do do
{
ch = *kfileptr++; leng--;
index = (ch&15);
prec = (ch>>4);
for (z=0; z<64; z++)
{ {
v = (int32_t)(*kfileptr++); ch = *kfileptr++; leng--;
if (prec) v = (v<<8)+((int32_t)(*kfileptr++)); index = (ch&15);
v <<= 19; prec = (ch>>4);
if (unzig[z]&7) v = mulshr24(v,cosqr16[unzig[z]&7 ]); for (z=0; z<64; z++)
if (unzig[z]>>3) v = mulshr24(v,cosqr16[unzig[z]>>3]); {
quantab[index][unzig[z]] = v; v = (int32_t)(*kfileptr++);
if (prec) v = (v<<8)+((int32_t)(*kfileptr++));
v <<= 19;
if (unzig[z]&7) v = mulshr24(v,cosqr16[unzig[z]&7 ]);
if (unzig[z]>>3) v = mulshr24(v,cosqr16[unzig[z]>>3]);
quantab[index][unzig[z]] = v;
}
leng -= 64;
if (prec) leng -= 64;
} }
leng -= 64; while (leng > 0);
if (prec) leng -= 64;
}
while (leng > 0);
break; break;
case 0xdd: case 0xdd:
restartinterval = SSWAPIL(*(uint16_t *)&kfileptr[0]); restartinterval = SSWAPIL(*(uint16_t *)&kfileptr[0]);
kfileptr += leng; kfileptr += leng;
break; break;
case 0xda: case 0xda:
if ((xdim <= 0) || (ydim <= 0)) { if (dctbuf) Bfree(dctbuf); return(-1); } if ((xdim <= 0) || (ydim <= 0)) { if (dctbuf) Bfree(dctbuf); return(-1); }
lnumcomponents = (int32_t)(*kfileptr++); if (!lnumcomponents) { if (dctbuf) Bfree(dctbuf); return(-1); } lnumcomponents = (int32_t)(*kfileptr++); if (!lnumcomponents) { if (dctbuf) Bfree(dctbuf); return(-1); }
if (lnumcomponents > 1) coltype = 2; if (lnumcomponents > 1) coltype = 2;
@ -1603,7 +1604,8 @@ static int32_t kpegrend(const char *kfilebuf, int32_t kfilength,
if (!dctbuf) quanptr = &quantab[lcompquantab[c]][0]; if (!dctbuf) quanptr = &quantab[lcompquantab[c]][0];
for (yy=0; yy<(lcompvsamp[c]<<3); yy+=8) for (yy=0; yy<(lcompvsamp[c]<<3); yy+=8)
for (xx=0; xx<(lcomphsamp[c]<<3); xx+=8) for (xx=0; xx<(lcomphsamp[c]<<3); xx+=8)
{ //NOTE: Might help to split this code into firstime vs. refinement (!Ah vs. Ah!=0) {
//NOTE: Might help to split this code into firstime vs. refinement (!Ah vs. Ah!=0)
if (dctbuf) dcs = &ldctptr[c][(((y+yy)>>lshy[c])*ldctx[c] + ((x+xx)>>lshx[c]))<<6]; if (dctbuf) dcs = &ldctptr[c][(((y+yy)>>lshy[c])*ldctx[c] + ((x+xx)>>lshx[c]))<<6];
@ -1663,11 +1665,11 @@ static int32_t kpegrend(const char *kfilebuf, int32_t kfilength,
{ {
if (Ah) if (Ah)
{ {
if (curbits < 8) //Getbits if (curbits < 8) //Getbits
{ {
ch = *kfileptr++; if (ch == 255) kfileptr++; ch = *kfileptr++; if (ch == 255) kfileptr++;
num = (num<<8)+((long)ch); curbits += 8; num = (num<<8)+((long)ch); curbits += 8;
} }
if (num&(pow2long[--curbits])) daval = Alut[0]; else daval = Alut[1]; if (num&(pow2long[--curbits])) daval = Alut[0]; else daval = Alut[1];
} }
} }
@ -1758,7 +1760,7 @@ static int32_t kpegrend(const char *kfilebuf, int32_t kfilength,
eobrun = 0; eobrun = 0;
} }
} }
kpegrend_break2:; kpegrend_break2:;
if (!dctbuf) return(0); if (!dctbuf) return(0);
passcnt++; kfileptr -= ((curbits>>3)+1); break; passcnt++; kfileptr -= ((curbits>>3)+1); break;
case 0xd9: break; case 0xd9: break;
@ -1825,7 +1827,8 @@ static int32_t kgifrend(const char *kfilebuf, int32_t kfilelength,
if (kfilebuf[10]&128) { cptr = ptr; ptr += paleng*3; } if (kfilebuf[10]&128) { cptr = ptr; ptr += paleng*3; }
transcol = -1; transcol = -1;
while ((chunkind = *ptr++) == '!') while ((chunkind = *ptr++) == '!')
{ //! 0xf9 leng flags ? ? transcol {
//! 0xf9 leng flags ? ? transcol
if (ptr[0] == 0xf9) { if (ptr[2]&1) transcol = (int32_t)(((uint8_t)ptr[5])); } if (ptr[0] == 0xf9) { if (ptr[2]&1) transcol = (int32_t)(((uint8_t)ptr[5])); }
ptr++; ptr++;
do { i = *ptr++; ptr += i; } do { i = *ptr++; ptr += i; }
@ -2181,20 +2184,20 @@ static int32_t kbmprend(const char *buf, int32_t fleng,
case 4: for (x=x0; x<x1; x++) lptr[x] = palcol[(int32_t)((cptr[x>>1]>>(((x&1)^1)<<2))&15)]; break; case 4: for (x=x0; x<x1; x++) lptr[x] = palcol[(int32_t)((cptr[x>>1]>>(((x&1)^1)<<2))&15)]; break;
case 8: for (x=x0; x<x1; x++) lptr[x] = palcol[(int32_t)(cptr[x])]; break; case 8: for (x=x0; x<x1; x++) lptr[x] = palcol[(int32_t)(cptr[x])]; break;
case 16: for (x=x0; x<x1; x++) case 16: for (x=x0; x<x1; x++)
{ {
i = ((int32_t)(*(int16_t *)&cptr[x<<1])); i = ((int32_t)(*(int16_t *)&cptr[x<<1]));
lptr[x] = (_lrotl(i,palcol[0])&palcol[3]) + lptr[x] = (_lrotl(i,palcol[0])&palcol[3]) +
(_lrotl(i,palcol[1])&palcol[4]) + (_lrotl(i,palcol[1])&palcol[4]) +
(_lrotl(i,palcol[2])&palcol[5]) + LSWAPIB(0xff000000); (_lrotl(i,palcol[2])&palcol[5]) + LSWAPIB(0xff000000);
} break; } break;
case 24: for (x=x0; x<x1; x++) lptr[x] = ((*(int32_t *)&cptr[x*3])|LSWAPIB(0xff000000)); break; case 24: for (x=x0; x<x1; x++) lptr[x] = ((*(int32_t *)&cptr[x*3])|LSWAPIB(0xff000000)); break;
case 32: for (x=x0; x<x1; x++) case 32: for (x=x0; x<x1; x++)
{ {
i = (*(int32_t *)&cptr[x<<2]); i = (*(int32_t *)&cptr[x<<2]);
lptr[x] = (_lrotl(i,palcol[0])&palcol[3]) + lptr[x] = (_lrotl(i,palcol[0])&palcol[3]) +
(_lrotl(i,palcol[1])&palcol[4]) + (_lrotl(i,palcol[1])&palcol[4]) +
(_lrotl(i,palcol[2])&palcol[5]) + LSWAPIB(0xff000000); (_lrotl(i,palcol[2])&palcol[5]) + LSWAPIB(0xff000000);
} break; } break;
} }
} }
@ -2479,7 +2482,8 @@ void kpgetdim(const char *buf, int32_t leng, int32_t *xsiz, int32_t *ysiz)
(*ysiz) = LSWAPIB(*(int32_t *)&buf[12]); (*ysiz) = LSWAPIB(*(int32_t *)&buf[12]);
} }
else else
{ //Unreliable .TGA identification - this MUST be final case! {
//Unreliable .TGA identification - this MUST be final case!
if ((leng >= 19) && (!(ubuf[1]&0xfe))) if ((leng >= 19) && (!(ubuf[1]&0xfe)))
if ((ubuf[2] < 12) && ((1<<ubuf[2])&0xe0e)) if ((ubuf[2] < 12) && ((1<<ubuf[2])&0xe0e))
if ((!(ubuf[16]&7)) && (ubuf[16] != 0) && (ubuf[16] <= 32)) if ((!(ubuf[16]&7)) && (ubuf[16] != 0) && (ubuf[16] <= 32))
@ -2818,7 +2822,7 @@ intptr_t kzopen(const char *filnam)
{ {
case 0: kzfs.i = 0; return((intptr_t)kzfs.fil); case 0: kzfs.i = 0; return((intptr_t)kzfs.fil);
case 8: case 8:
if (!pnginited) { pnginited = 1; initpngtables(); } if (!pnginited) { pnginited = 1; initpngtables(); }
kzfs.comptell = 0; kzfs.comptell = 0;
kzfs.compleng = LSWAPIB(*(int32_t *)&tempbuf[18]); kzfs.compleng = LSWAPIB(*(int32_t *)&tempbuf[18]);
@ -2896,7 +2900,7 @@ int32_t kzfindfile(char *filnam)
{ {
int32_t i; int32_t i;
kzfindfile_beg:; kzfindfile_beg:;
filnam[0] = 0; filnam[0] = 0;
if (srchstat == 0) if (srchstat == 0)
{ {
@ -3091,7 +3095,7 @@ int32_t kzread(void *buffer, int32_t leng)
case 2: goto kzreadplc2; case 2: goto kzreadplc2;
case 3: goto kzreadplc3; case 3: goto kzreadplc3;
} }
kzreadplc0:; kzreadplc0:;
do do
{ {
bfinal = getbits(1); btype = getbits(2); bfinal = getbits(1); btype = getbits(2);
@ -3131,7 +3135,7 @@ kzreadplc0:;
{ {
kzfs.jmpplc = 1; kzfs.i = i; kzfs.bfinal = bfinal; kzfs.jmpplc = 1; kzfs.i = i; kzfs.bfinal = bfinal;
goto retkzread; goto retkzread;
kzreadplc1:; i = kzfs.i; bfinal = kzfs.bfinal; kzreadplc1:; i = kzfs.i; bfinal = kzfs.bfinal;
} }
} }
slidebuf[(gslidew++)&32767] = (uint8_t)getbits(8); slidebuf[(gslidew++)&32767] = (uint8_t)getbits(8);
@ -3185,7 +3189,7 @@ kzreadplc1:; i = kzfs.i; bfinal = kzfs.bfinal;
if (gslider-16384 >= kzfs.endpos) if (gslider-16384 >= kzfs.endpos)
{ {
kzfs.jmpplc = 2; kzfs.bfinal = bfinal; goto retkzread; kzfs.jmpplc = 2; kzfs.bfinal = bfinal; goto retkzread;
kzreadplc2:; bfinal = kzfs.bfinal; kzreadplc2:; bfinal = kzfs.bfinal;
} }
} }
@ -3215,10 +3219,10 @@ kzreadplc2:; bfinal = kzfs.bfinal;
putbuf4zip(&slidebuf[gslider&32767],gslider,gslidew&~32767); putbuf4zip(&slidebuf[gslider&32767],gslider,gslidew&~32767);
putbuf4zip(slidebuf,gslidew&~32767,gslidew); putbuf4zip(slidebuf,gslidew&~32767,gslidew);
} }
kzreadplc3:; kzfs.jmpplc = 3; kzreadplc3:; kzfs.jmpplc = 3;
} }
retkzread:; retkzread:;
i = kzfs.pos; i = kzfs.pos;
kzfs.pos += leng; if (kzfs.pos > kzfs.leng) kzfs.pos = kzfs.leng; kzfs.pos += leng; if (kzfs.pos > kzfs.leng) kzfs.pos = kzfs.leng;
return(kzfs.pos-i); return(kzfs.pos-i);

View file

@ -24,7 +24,7 @@
documentation and/or software. documentation and/or software.
*/ */
typedef unsigned char * POINTER; typedef unsigned char *POINTER;
typedef unsigned short UINT2; typedef unsigned short UINT2;
typedef unsigned int UINT4; typedef unsigned int UINT4;

View file

@ -59,8 +59,8 @@ static int32_t maxmodeltris = 0, allocmodeltris = 0;
static point3d *vertlist = NULL; //temp array to store interpolated vertices for drawing static point3d *vertlist = NULL; //temp array to store interpolated vertices for drawing
static int32_t allocvbos = 0, curvbo = 0; static int32_t allocvbos = 0, curvbo = 0;
static GLuint* vertvbos = NULL; static GLuint *vertvbos = NULL;
static GLuint* indexvbos = NULL; static GLuint *indexvbos = NULL;
mdmodel_t *mdload(const char *); mdmodel_t *mdload(const char *);
int32_t mddraw(spritetype *); int32_t mddraw(spritetype *);
@ -118,13 +118,13 @@ void freeallmodels()
} }
freevbos(); freevbos();
/* /*
if (model_data_pool) if (model_data_pool)
{ {
neddestroypool(model_data_pool); neddestroypool(model_data_pool);
model_data_pool = NULL; model_data_pool = NULL;
} }
*/ */
} }
void clearskins() void clearskins()
@ -137,27 +137,27 @@ void clearskins()
m = models[i]; m = models[i];
if (m->mdnum == 1) if (m->mdnum == 1)
{ {
voxmodel_t *v = (voxmodel_t*)m; voxmodel_t *v = (voxmodel_t *)m;
for (j=0; j<MAXPALOOKUPS; j++) for (j=0; j<MAXPALOOKUPS; j++)
{ {
if (v->texid[j]) bglDeleteTextures(1,(GLuint*)&v->texid[j]); if (v->texid[j]) bglDeleteTextures(1,(GLuint *)&v->texid[j]);
v->texid[j] = 0; v->texid[j] = 0;
} }
} }
else if (m->mdnum == 2 || m->mdnum == 3) else if (m->mdnum == 2 || m->mdnum == 3)
{ {
md2model_t *m2 = (md2model_t*)m; md2model_t *m2 = (md2model_t *)m;
mdskinmap_t *sk; mdskinmap_t *sk;
for (j=0; j<m2->numskins*(HICEFFECTMASK+1); j++) for (j=0; j<m2->numskins*(HICEFFECTMASK+1); j++)
{ {
if (m2->texid[j]) bglDeleteTextures(1,(GLuint*)&m2->texid[j]); if (m2->texid[j]) bglDeleteTextures(1,(GLuint *)&m2->texid[j]);
m2->texid[j] = 0; m2->texid[j] = 0;
} }
for (sk=m2->skinmap; sk; sk=sk->next) for (sk=m2->skinmap; sk; sk=sk->next)
for (j=0; j<(HICEFFECTMASK+1); j++) for (j=0; j<(HICEFFECTMASK+1); j++)
{ {
if (sk->texid[j]) bglDeleteTextures(1,(GLuint*)&sk->texid[j]); if (sk->texid[j]) bglDeleteTextures(1,(GLuint *)&sk->texid[j]);
sk->texid[j] = 0; sk->texid[j] = 0;
} }
} }
@ -165,10 +165,10 @@ void clearskins()
for (i=0; i<MAXVOXELS; i++) for (i=0; i<MAXVOXELS; i++)
{ {
voxmodel_t *v = (voxmodel_t*)voxmodels[i]; if (!v) continue; voxmodel_t *v = (voxmodel_t *)voxmodels[i]; if (!v) continue;
for (j=0; j<MAXPALOOKUPS; j++) for (j=0; j<MAXPALOOKUPS; j++)
{ {
if (v->texid[j]) bglDeleteTextures(1,(GLuint*)&v->texid[j]); if (v->texid[j]) bglDeleteTextures(1,(GLuint *)&v->texid[j]);
v->texid[j] = 0; v->texid[j] = 0;
} }
} }
@ -191,7 +191,7 @@ int32_t md_loadmodel(const char *fn)
if (nextmodelid >= nummodelsalloced) if (nextmodelid >= nummodelsalloced)
{ {
ml = (mdmodel_t **)Brealloc(models,(nummodelsalloced+MODELALLOCGROUP)*sizeof(void*)); if (!ml) return(-1); ml = (mdmodel_t **)Brealloc(models,(nummodelsalloced+MODELALLOCGROUP)*sizeof(void *)); if (!ml) return(-1);
models = ml; nummodelsalloced += MODELALLOCGROUP; models = ml; nummodelsalloced += MODELALLOCGROUP;
} }
@ -272,7 +272,7 @@ int32_t md_defineframe(int32_t modelid, const char *framename, int32_t tilenume,
return 0; return 0;
} }
i = framename2index((mdmodel_t*)m,framename); i = framename2index((mdmodel_t *)m,framename);
if (i == m->numframes) return(-3); // frame name invalid if (i == m->numframes) return(-3); // frame name invalid
tile2model[tilenume].modelid = modelid; tile2model[tilenume].modelid = modelid;
@ -298,19 +298,19 @@ int32_t md_defineanimation(int32_t modelid, const char *framestart, const char *
if (m->mdnum < 2) return 0; if (m->mdnum < 2) return 0;
//find index of start frame //find index of start frame
i = framename2index((mdmodel_t*)m,framestart); i = framename2index((mdmodel_t *)m,framestart);
if (i == m->numframes) return -2; if (i == m->numframes) return -2;
ma.startframe = i; ma.startframe = i;
//find index of finish frame which must trail start frame //find index of finish frame which must trail start frame
i = framename2index((mdmodel_t*)m,frameend); i = framename2index((mdmodel_t *)m,frameend);
if (i == m->numframes) return -3; if (i == m->numframes) return -3;
ma.endframe = i; ma.endframe = i;
ma.fpssc = fpssc; ma.fpssc = fpssc;
ma.flags = flags; ma.flags = flags;
map = (mdanim_t*)Bcalloc(1,sizeof(mdanim_t)); map = (mdanim_t *)Bcalloc(1,sizeof(mdanim_t));
if (!map) return(-4); if (!map) return(-4);
Bmemcpy(map, &ma, sizeof(ma)); Bmemcpy(map, &ma, sizeof(ma));
@ -789,15 +789,15 @@ int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf)
willprint = 1; willprint = 1;
if (pal < (MAXPALOOKUPS - RESERVEDPALS)) m->usesalpha = hasalpha; if (pal < (MAXPALOOKUPS - RESERVEDPALS)) m->usesalpha = hasalpha;
if ((doalloc&3)==1) bglGenTextures(1,(GLuint*)texidx); if ((doalloc&3)==1) bglGenTextures(1,(GLuint *)texidx);
bglBindTexture(GL_TEXTURE_2D,*texidx); bglBindTexture(GL_TEXTURE_2D,*texidx);
//gluBuild2DMipmaps(GL_TEXTURE_2D,GL_RGBA,xsiz,ysiz,GL_BGRA_EXT,GL_UNSIGNED_BYTE,(char *)fptr); //gluBuild2DMipmaps(GL_TEXTURE_2D,GL_RGBA,xsiz,ysiz,GL_BGRA_EXT,GL_UNSIGNED_BYTE,(char *)fptr);
if (glinfo.texcompr && glusetexcompr) intexfmt = hasalpha ? GL_COMPRESSED_RGBA_ARB : GL_COMPRESSED_RGB_ARB; if (glinfo.texcompr && glusetexcompr) intexfmt = hasalpha ? GL_COMPRESSED_RGBA_ARB : GL_COMPRESSED_RGB_ARB;
else if (!hasalpha) intexfmt = GL_RGB; else if (!hasalpha) intexfmt = GL_RGB;
if (glinfo.bgra) texfmt = GL_BGRA; if (glinfo.bgra) texfmt = GL_BGRA;
uploadtexture((doalloc&1), xsiz, ysiz, intexfmt, texfmt, (coltype*)fptr, xsiz, ysiz, 0|8192); uploadtexture((doalloc&1), xsiz, ysiz, intexfmt, texfmt, (coltype *)fptr, xsiz, ysiz, 0|8192);
Bfree((void*)fptr); Bfree((void *)fptr);
} }
if (!m->skinloaded) if (!m->skinloaded)
@ -1088,20 +1088,20 @@ static md2model_t *md2load(int32_t fil, const char *filnam)
{ {
m->glcmds[i] = B_LITTLE32(m->glcmds[i]); m->glcmds[i] = B_LITTLE32(m->glcmds[i]);
} }
for (i = head.numtris-1; i>=0; i--) for (i = head.numtris-1; i>=0; i--)
{ {
m->tris[i].v[0] = B_LITTLE16(m->tris[i].v[0]); m->tris[i].v[0] = B_LITTLE16(m->tris[i].v[0]);
m->tris[i].v[1] = B_LITTLE16(m->tris[i].v[1]); m->tris[i].v[1] = B_LITTLE16(m->tris[i].v[1]);
m->tris[i].v[2] = B_LITTLE16(m->tris[i].v[2]); m->tris[i].v[2] = B_LITTLE16(m->tris[i].v[2]);
m->tris[i].u[0] = B_LITTLE16(m->tris[i].u[0]); m->tris[i].u[0] = B_LITTLE16(m->tris[i].u[0]);
m->tris[i].u[1] = B_LITTLE16(m->tris[i].u[1]); m->tris[i].u[1] = B_LITTLE16(m->tris[i].u[1]);
m->tris[i].u[2] = B_LITTLE16(m->tris[i].u[2]); m->tris[i].u[2] = B_LITTLE16(m->tris[i].u[2]);
} }
for(i = head.numuv-1; i>=0; i--) for (i = head.numuv-1; i>=0; i--)
{ {
m->uv[i].u = B_LITTLE16(m->uv[i].u); m->uv[i].u = B_LITTLE16(m->uv[i].u);
m->uv[i].v = B_LITTLE16(m->uv[i].v); m->uv[i].v = B_LITTLE16(m->uv[i].v);
} }
} }
#endif #endif
@ -1408,8 +1408,8 @@ static md3model_t *md3load(int32_t fil)
if (m->head.tags) Bfree(m->head.tags); Bfree(m->head.frames); Bfree(m); return(0); if (m->head.tags) Bfree(m->head.tags); Bfree(m->head.frames); Bfree(m); return(0);
} }
s->shaders = (md3shader_t *)(((intptr_t)s->tris)+leng[0]); s->shaders = (md3shader_t *)(((intptr_t)s->tris)+leng[0]);
s->uv = (md3uv_t *)(((intptr_t)s->shaders)+leng[1]); s->uv = (md3uv_t *)(((intptr_t)s->shaders)+leng[1]);
s->xyzn = (md3xyzn_t *)(((intptr_t)s->uv)+leng[2]); s->xyzn = (md3xyzn_t *)(((intptr_t)s->uv)+leng[2]);
klseek(fil,offs[0],SEEK_SET); kread(fil,s->tris ,leng[0]); klseek(fil,offs[0],SEEK_SET); kread(fil,s->tris ,leng[0]);
klseek(fil,offs[1],SEEK_SET); kread(fil,s->shaders,leng[1]); klseek(fil,offs[1],SEEK_SET); kread(fil,s->shaders,leng[1]);
@ -1430,7 +1430,7 @@ static md3model_t *md3load(int32_t fil)
} }
for (i=s->numverts-1; i>=0; i--) for (i=s->numverts-1; i>=0; i--)
{ {
l = (int32_t*)&s->uv[i].u; l = (int32_t *)&s->uv[i].u;
l[0] = B_LITTLE32(l[0]); l[0] = B_LITTLE32(l[0]);
l[1] = B_LITTLE32(l[1]); l[1] = B_LITTLE32(l[1]);
} }
@ -1490,7 +1490,7 @@ static md3model_t *md3load(int32_t fil)
return(m); return(m);
} }
static inline void invertmatrix(float* m, float* out) static inline void invertmatrix(float *m, float *out)
{ {
float det; float det;
@ -1513,7 +1513,7 @@ static inline void invertmatrix(float* m, float* out)
out[8] = det * (m[0] * m[4] - m[1] * m[3]); out[8] = det * (m[0] * m[4] - m[1] * m[3]);
} }
static inline void normalize(float* vec) static inline void normalize(float *vec)
{ {
double norm; double norm;
@ -1526,7 +1526,7 @@ static inline void normalize(float* vec)
vec[2] *= norm; vec[2] *= norm;
} }
static void md3postload_common(md3model_t* m) static void md3postload_common(md3model_t *m)
{ {
int framei, surfi, verti; int framei, surfi, verti;
md3frame_t *frame; md3frame_t *frame;
@ -1643,8 +1643,9 @@ static int md3postload_polymer_check(md3model_t *m)
{ {
// let the vertices know they're being referenced by a triangle // let the vertices know they're being referenced by a triangle
if (s->tris[trii].i[0] >= s->numverts || s->tris[trii].i[0] < 0 || if (s->tris[trii].i[0] >= s->numverts || s->tris[trii].i[0] < 0 ||
s->tris[trii].i[1] >= s->numverts || s->tris[trii].i[1] < 0 || s->tris[trii].i[1] >= s->numverts || s->tris[trii].i[1] < 0 ||
s->tris[trii].i[2] >= s->numverts || s->tris[trii].i[2] < 0) { s->tris[trii].i[2] >= s->numverts || s->tris[trii].i[2] < 0)
{
// corrupt model // corrupt model
OSD_Printf("Triangle index out of bounds!\n"); OSD_Printf("Triangle index out of bounds!\n");
return 0; return 0;
@ -1660,7 +1661,7 @@ static int md3postload_polymer_check(md3model_t *m)
} }
#endif #endif
int md3postload_polymer(md3model_t* m) int md3postload_polymer(md3model_t *m)
{ {
#ifdef POLYMER #ifdef POLYMER
int framei, surfi, verti, trii, i; int framei, surfi, verti, trii, i;
@ -1710,8 +1711,9 @@ int md3postload_polymer(md3model_t* m)
{ {
// let the vertices know they're being referenced by a triangle // let the vertices know they're being referenced by a triangle
if (s->tris[trii].i[0] >= s->numverts || s->tris[trii].i[0] < 0 || if (s->tris[trii].i[0] >= s->numverts || s->tris[trii].i[0] < 0 ||
s->tris[trii].i[1] >= s->numverts || s->tris[trii].i[1] < 0 || s->tris[trii].i[1] >= s->numverts || s->tris[trii].i[1] < 0 ||
s->tris[trii].i[2] >= s->numverts || s->tris[trii].i[2] < 0) { s->tris[trii].i[2] >= s->numverts || s->tris[trii].i[2] < 0)
{
// corrupt model // corrupt model
Bfree(numtris); Bfree(numtris);
OSD_Printf("Triangle index out of bounds!\n"); OSD_Printf("Triangle index out of bounds!\n");
@ -1816,9 +1818,9 @@ static int32_t md3draw(md3model_t *m, spritetype *tspr)
int32_t texunits = GL_TEXTURE0_ARB; int32_t texunits = GL_TEXTURE0_ARB;
mdskinmap_t *sk; mdskinmap_t *sk;
//PLAG : sorting stuff //PLAG : sorting stuff
void* vbotemp; void *vbotemp;
point3d* vertexhandle = NULL; point3d *vertexhandle = NULL;
uint16_t* indexhandle; uint16_t *indexhandle;
char lpal = (tspr->owner >= MAXSPRITES) ? tspr->pal : sprite[tspr->owner].pal; char lpal = (tspr->owner >= MAXSPRITES) ? tspr->pal : sprite[tspr->owner].pal;
if (r_vbos && (m->vbos == NULL)) if (r_vbos && (m->vbos == NULL))
@ -2406,7 +2408,7 @@ uint32_t gloadtex(int32_t *picbuf, int32_t xsiz, int32_t ysiz, int32_t is8bit, i
pic = (coltype *)picbuf; //Correct for GL's RGB order; also apply gamma here.. pic = (coltype *)picbuf; //Correct for GL's RGB order; also apply gamma here..
pic2 = (coltype *)Bmalloc(xsiz*ysiz*sizeof(int32_t)); if (!pic2) return((unsigned)-1); pic2 = (coltype *)Bmalloc(xsiz*ysiz*sizeof(int32_t)); if (!pic2) return((unsigned)-1);
cptr = (char*)&britable[gammabrightness ? 0 : curbrightness][0]; cptr = (char *)&britable[gammabrightness ? 0 : curbrightness][0];
if (!is8bit) if (!is8bit)
{ {
for (i=xsiz*ysiz-1; i>=0; i--) for (i=xsiz*ysiz-1; i>=0; i--)
@ -2429,7 +2431,7 @@ uint32_t gloadtex(int32_t *picbuf, int32_t xsiz, int32_t ysiz, int32_t is8bit, i
} }
} }
bglGenTextures(1,(GLuint*)&rtexid); bglGenTextures(1,(GLuint *)&rtexid);
bglBindTexture(GL_TEXTURE_2D,rtexid); bglBindTexture(GL_TEXTURE_2D,rtexid);
bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
@ -3208,7 +3210,7 @@ mdmodel_t *mdload(const char *filnam)
int32_t fil; int32_t fil;
int32_t i; int32_t i;
vm = (mdmodel_t*)voxload(filnam); if (vm) return(vm); vm = (mdmodel_t *)voxload(filnam); if (vm) return(vm);
fil = kopen4load((char *)filnam,0); if (fil < 0) return(0); fil = kopen4load((char *)filnam,0); if (fil < 0) return(0);
kread(fil,&i,4); klseek(fil,0,SEEK_SET); kread(fil,&i,4); klseek(fil,0,SEEK_SET);
@ -3217,30 +3219,30 @@ mdmodel_t *mdload(const char *filnam)
{ {
case 0x32504449: case 0x32504449:
// initprintf("Warning: model '%s' is version IDP2; wanted version IDP3\n",filnam); // initprintf("Warning: model '%s' is version IDP2; wanted version IDP3\n",filnam);
vm = (mdmodel_t*)md2load(fil,filnam); vm = (mdmodel_t *)md2load(fil,filnam);
break; //IDP2 break; //IDP2
case 0x33504449: case 0x33504449:
vm = (mdmodel_t*)md3load(fil); vm = (mdmodel_t *)md3load(fil);
break; //IDP3 break; //IDP3
default: default:
vm = (mdmodel_t*)0; break; vm = (mdmodel_t *)0; break;
} }
kclose(fil); kclose(fil);
if (vm) if (vm)
{ {
md3postload_common((md3model_t*)vm); md3postload_common((md3model_t *)vm);
#ifdef POLYMER #ifdef POLYMER
// implies defined(POLYMOST) && defined(USE_OPENGL)? // implies defined(POLYMOST) && defined(USE_OPENGL)?
if (glrendmode==4) if (glrendmode==4)
i = md3postload_polymer((md3model_t*)vm); i = md3postload_polymer((md3model_t *)vm);
else else
i = md3postload_polymer_check((md3model_t*)vm); i = md3postload_polymer_check((md3model_t *)vm);
if (!i) if (!i)
{ {
mdfree(vm); mdfree(vm);
vm = (mdmodel_t*)0; vm = (mdmodel_t *)0;
} }
#endif #endif
} }

File diff suppressed because it is too large Load diff

View file

@ -27,7 +27,7 @@ static int32_t _internal_osdfunc_alias(const osdfuncparm_t *);
static int32_t white=-1; // colour of white (used by default display routines) static int32_t white=-1; // colour of white (used by default display routines)
static void _internal_drawosdchar(int32_t, int32_t, char, int32_t, int32_t); static void _internal_drawosdchar(int32_t, int32_t, char, int32_t, int32_t);
static void _internal_drawosdstr(int32_t, int32_t, char*, int32_t, int32_t, int32_t); static void _internal_drawosdstr(int32_t, int32_t, char *, int32_t, int32_t, int32_t);
static void _internal_drawosdcursor(int32_t,int32_t,int32_t,int32_t); static void _internal_drawosdcursor(int32_t,int32_t,int32_t,int32_t);
static int32_t _internal_getcolumnwidth(int32_t); static int32_t _internal_getcolumnwidth(int32_t);
static int32_t _internal_getrowheight(int32_t); static int32_t _internal_getrowheight(int32_t);
@ -105,7 +105,7 @@ static hashtable_t h_osd = { MAXSYMBOLS<<1, NULL };
// application callbacks // application callbacks
static void (*drawosdchar)(int32_t, int32_t, char, int32_t, int32_t) = _internal_drawosdchar; static void (*drawosdchar)(int32_t, int32_t, char, int32_t, int32_t) = _internal_drawosdchar;
static void (*drawosdstr)(int32_t, int32_t, char*, int32_t, int32_t, int32_t) = _internal_drawosdstr; static void (*drawosdstr)(int32_t, int32_t, char *, int32_t, int32_t, int32_t) = _internal_drawosdstr;
static void (*drawosdcursor)(int32_t, int32_t, int32_t, int32_t) = _internal_drawosdcursor; static void (*drawosdcursor)(int32_t, int32_t, int32_t, int32_t) = _internal_drawosdcursor;
static int32_t (*getcolumnwidth)(int32_t) = _internal_getcolumnwidth; static int32_t (*getcolumnwidth)(int32_t) = _internal_getcolumnwidth;
static int32_t (*getrowheight)(int32_t) = _internal_getrowheight; static int32_t (*getrowheight)(int32_t) = _internal_getrowheight;
@ -114,7 +114,7 @@ static int32_t (*gettime)(void) = _internal_gettime;
static void (*onshowosd)(int32_t) = _internal_onshowosd; static void (*onshowosd)(int32_t) = _internal_onshowosd;
static void (*_drawosdchar)(int32_t, int32_t, char, int32_t, int32_t) = _internal_drawosdchar; static void (*_drawosdchar)(int32_t, int32_t, char, int32_t, int32_t) = _internal_drawosdchar;
static void (*_drawosdstr)(int32_t, int32_t, char*, int32_t, int32_t, int32_t) = _internal_drawosdstr; static void (*_drawosdstr)(int32_t, int32_t, char *, int32_t, int32_t, int32_t) = _internal_drawosdstr;
static void (*_drawosdcursor)(int32_t, int32_t, int32_t, int32_t) = _internal_drawosdcursor; static void (*_drawosdcursor)(int32_t, int32_t, int32_t, int32_t) = _internal_drawosdcursor;
static int32_t (*_getcolumnwidth)(int32_t) = _internal_getcolumnwidth; static int32_t (*_getcolumnwidth)(int32_t) = _internal_getcolumnwidth;
static int32_t (*_getrowheight)(int32_t) = _internal_getrowheight; static int32_t (*_getrowheight)(int32_t) = _internal_getrowheight;
@ -221,7 +221,7 @@ static int32_t OSD_CvarModified(const osdcvar_t *cvar)
// ^S# sets a shade, range is 0-7 equiv to shades 0-14 // ^S# sets a shade, range is 0-7 equiv to shades 0-14
// ^O resets formatting to defaults // ^O resets formatting to defaults
const char * OSD_StripColors(char *out, const char *in) const char *OSD_StripColors(char *out, const char *in)
{ {
const char *ptr = out; const char *ptr = out;
@ -254,7 +254,7 @@ const char * OSD_StripColors(char *out, const char *in)
int32_t OSD_Exec(const char *szScript) int32_t OSD_Exec(const char *szScript)
{ {
FILE* fp = fopenfrompath(szScript, "r"); FILE *fp = fopenfrompath(szScript, "r");
if (fp != NULL) if (fp != NULL)
{ {
@ -281,19 +281,19 @@ int32_t OSD_OSDKey(void)
return osdkey; return osdkey;
} }
char * OSD_GetTextPtr(void) char *OSD_GetTextPtr(void)
{ {
return (&osdtext[0]); return osdtext;
} }
char * OSD_GetFmtPtr(void) char *OSD_GetFmtPtr(void)
{ {
return (&osdfmt[0]); return osdfmt;
} }
char * OSD_GetFmt(char *ptr) char *OSD_GetFmt(char *ptr)
{ {
return (ptr - &osdtext[0] + &osdfmt[0]); return (ptr - osdtext + osdfmt);
} }
int32_t OSD_GetCols(void) int32_t OSD_GetCols(void)
@ -393,9 +393,9 @@ static int32_t _internal_osdfunc_fileinfo(const osdfuncparm_t *parm)
kclose(i); kclose(i);
OSD_Printf("fileinfo: %s\n" OSD_Printf("fileinfo: %s\n"
" File size: %d\n" " File size: %d\n"
" CRC-32: %08X\n", " CRC-32: %08X\n",
parm->parms[0], length, crc); parm->parms[0], length, crc);
return OSDCMD_OK; return OSDCMD_OK;
} }
@ -603,13 +603,9 @@ static int32_t _internal_osdfunc_help(const osdfuncparm_t *parm)
if (parm->numparms != 1) return OSDCMD_SHOWHELP; if (parm->numparms != 1) return OSDCMD_SHOWHELP;
symb = findexactsymbol(parm->parms[0]); symb = findexactsymbol(parm->parms[0]);
if (!symb) if (!symb)
{ OSD_Printf("Error: no help for undefined symbol \"%s\"\n", parm->parms[0]);
OSD_Printf("Help Error: \"%s\" is not a defined variable or function\n", parm->parms[0]);
}
else else
{
OSD_Printf("%s\n", symb->help); OSD_Printf("%s\n", symb->help);
}
return OSDCMD_OK; return OSDCMD_OK;
} }
@ -653,8 +649,11 @@ void OSD_Cleanup(void)
Bfree(symbols); Bfree(symbols);
} }
if (osdlog) Bfclose(osdlog); if (osdlog)
osdlog = NULL; {
Bfclose(osdlog);
osdlog = NULL;
}
if (cvars) if (cvars)
{ {
@ -717,15 +716,15 @@ void OSD_Init(void)
uint32_t i; uint32_t i;
cvar_t cvars_osd[] = cvar_t cvars_osd[] =
{ {
{ "osdeditpal","osdeditpal: sets the palette of the OSD input text",(void *)&osdeditpal, CVAR_INT, 0, MAXPALOOKUPS-1 }, { "osdeditpal","osdeditpal: sets the palette of the OSD input text",(void *) &osdeditpal, CVAR_INT, 0, MAXPALOOKUPS-1 },
{ "osdpromptpal","osdpromptpal: sets the palette of the OSD prompt",(void *)&osdpromptpal, CVAR_INT, 0, MAXPALOOKUPS-1 }, { "osdpromptpal","osdpromptpal: sets the palette of the OSD prompt",(void *) &osdpromptpal, CVAR_INT, 0, MAXPALOOKUPS-1 },
{ "osdtextpal","osdtextpal: sets the palette of the OSD text",(void *)&osdtextpal, CVAR_INT, 0, MAXPALOOKUPS-1 }, { "osdtextpal","osdtextpal: sets the palette of the OSD text",(void *) &osdtextpal, CVAR_INT, 0, MAXPALOOKUPS-1 },
{ "osdeditshade","osdeditshade: sets the shade of the OSD input text",(void *)&osdeditshade, CVAR_INT, 0, 7 }, { "osdeditshade","osdeditshade: sets the shade of the OSD input text",(void *) &osdeditshade, CVAR_INT, 0, 7 },
{ "osdtextshade","osdtextshade: sets the shade of the OSD text",(void *)&osdtextshade, CVAR_INT, 0, 7 }, { "osdtextshade","osdtextshade: sets the shade of the OSD text",(void *) &osdtextshade, CVAR_INT, 0, 7 },
{ "osdpromptshade","osdpromptshade: sets the shade of the OSD prompt",(void *)&osdpromptshade, CVAR_INT, INT8_MIN, INT8_MAX }, { "osdpromptshade","osdpromptshade: sets the shade of the OSD prompt",(void *) &osdpromptshade, CVAR_INT, INT8_MIN, INT8_MAX },
{ "osdrows","osdrows: sets the number of visible lines of the OSD",(void *)&osdrows, CVAR_INT|CVAR_FUNCPTR, 0, MAXPALOOKUPS-1 }, { "osdrows","osdrows: sets the number of visible lines of the OSD",(void *) &osdrows, CVAR_INT|CVAR_FUNCPTR, 0, MAXPALOOKUPS-1 },
{ "osdtextmode","osdtextmode: set OSD text mode (0:graphical, 1:fast)",(void *)&osdtextmode, CVAR_BOOL|CVAR_FUNCPTR, 0, 1 }, { "osdtextmode","osdtextmode: set OSD text mode (0:graphical, 1:fast)",(void *) &osdtextmode, CVAR_BOOL|CVAR_FUNCPTR, 0, 1 },
{ "logcutoff","logcutoff: sets the maximal line count of the log file",(void *)&logcutoff, CVAR_INT, 0, 262144 }, { "logcutoff","logcutoff: sets the maximal line count of the log file",(void *) &logcutoff, CVAR_INT, 0, 262144 },
}; };
mutex_init(&m_osdprintf); mutex_init(&m_osdprintf);
@ -747,7 +746,7 @@ void OSD_Init(void)
continue; continue;
OSD_RegisterFunction(cvars_osd[i].name, cvars_osd[i].helpstr, OSD_RegisterFunction(cvars_osd[i].name, cvars_osd[i].helpstr,
cvars_osd[i].type & CVAR_FUNCPTR ? osdcmd_cvar_set_osd : osdcmd_cvar_set); cvars_osd[i].type & CVAR_FUNCPTR ? osdcmd_cvar_set_osd : osdcmd_cvar_set);
} }
OSD_RegisterFunction("alias","alias: creates an alias for calling multiple commands",_internal_osdfunc_alias); OSD_RegisterFunction("alias","alias: creates an alias for calling multiple commands",_internal_osdfunc_alias);
@ -770,10 +769,14 @@ void OSD_Init(void)
// //
void OSD_SetLogFile(char *fn) void OSD_SetLogFile(char *fn)
{ {
if (osdlog) Bfclose(osdlog); if (osdlog)
osdlog = NULL; {
Bfclose(osdlog);
osdlog = NULL;
}
if (fn) osdlog = Bfopen(fn,"w"); if (fn) osdlog = Bfopen(fn,"w");
if (osdlog) setvbuf(osdlog, (char*)NULL, _IONBF, 0); if (osdlog) setvbuf(osdlog, (char *)NULL, _IONBF, 0);
} }
@ -782,7 +785,7 @@ void OSD_SetLogFile(char *fn)
// //
void OSD_SetFunctions( void OSD_SetFunctions(
void (*drawchar)(int32_t,int32_t,char,int32_t,int32_t), void (*drawchar)(int32_t,int32_t,char,int32_t,int32_t),
void (*drawstr)(int32_t,int32_t,char*,int32_t,int32_t,int32_t), void (*drawstr)(int32_t,int32_t,char *,int32_t,int32_t,int32_t),
void (*drawcursor)(int32_t,int32_t,int32_t,int32_t), void (*drawcursor)(int32_t,int32_t,int32_t,int32_t),
int32_t (*colwidth)(int32_t), int32_t (*colwidth)(int32_t),
int32_t (*rowheight)(int32_t), int32_t (*rowheight)(int32_t),
@ -983,92 +986,92 @@ int32_t OSD_HandleChar(char ch)
case 127: // handled in OSD_HandleScanCode (delete) case 127: // handled in OSD_HandleScanCode (delete)
return 0; return 0;
case 9: // tab case 9: // tab
{
int32_t commonsize = 512;
if (!lastmatch)
{ {
int32_t commonsize = 512; for (i=osdeditcursor; i>0; i--) if (osdeditbuf[i-1] == ' ') break;
for (j=0; osdeditbuf[i] != ' ' && i < osdeditlen; j++,i++)
osdedittmp[j] = osdeditbuf[i];
osdedittmp[j] = 0;
if (!lastmatch) if (j > 0)
{ {
for (i=osdeditcursor; i>0; i--) if (osdeditbuf[i-1] == ' ') break; tabc = findsymbol(osdedittmp, NULL);
for (j=0; osdeditbuf[i] != ' ' && i < osdeditlen; j++,i++)
osdedittmp[j] = osdeditbuf[i];
osdedittmp[j] = 0;
if (j > 0) if (tabc && tabc->next && findsymbol(osdedittmp, tabc->next))
{ {
tabc = findsymbol(osdedittmp, NULL); symbol_t *symb=tabc;
int32_t maxwidth = 0, x = 0, num = 0, diffpt;
if (tabc && tabc->next && findsymbol(osdedittmp, tabc->next)) while (symb && symb != lastmatch)
{ {
symbol_t *symb=tabc; num++;
int32_t maxwidth = 0, x = 0, num = 0, diffpt;
while (symb && symb != lastmatch) if (lastmatch)
{ {
num++; diffpt = OSD_FindDiffPoint(symb->name,lastmatch->name);
if (diffpt < commonsize)
if (lastmatch) commonsize = diffpt;
{
diffpt = OSD_FindDiffPoint(symb->name,lastmatch->name);
if (diffpt < commonsize)
commonsize = diffpt;
}
maxwidth = max((unsigned)maxwidth,Bstrlen(symb->name));
lastmatch = symb;
if (!lastmatch->next) break;
symb=findsymbol(osdedittmp, lastmatch->next);
} }
OSD_Printf(OSDTEXT_RED "Found %d possible completions for '%s':\n",num,osdedittmp);
maxwidth += 3; maxwidth = max((unsigned)maxwidth,Bstrlen(symb->name));
symb = tabc; lastmatch = symb;
OSD_Printf(" "); if (!lastmatch->next) break;
while (symb && (symb != lastmatch)) symb=findsymbol(osdedittmp, lastmatch->next);
{
tabc = lastmatch = symb;
OSD_Printf("%-*s",maxwidth,symb->name);
if (!lastmatch->next) break;
symb=findsymbol(osdedittmp, lastmatch->next);
x += maxwidth;
if (x > (osdcols - maxwidth))
{
x = 0;
OSD_Printf("\n");
if (symb && (symb != lastmatch))
OSD_Printf(" ");
}
}
if (x) OSD_Printf("\n");
OSD_Printf(OSDTEXT_RED "Press TAB again to cycle through matches\n");
} }
OSD_Printf(OSDTEXT_RED "Found %d possible completions for '%s':\n",num,osdedittmp);
maxwidth += 3;
symb = tabc;
OSD_Printf(" ");
while (symb && (symb != lastmatch))
{
tabc = lastmatch = symb;
OSD_Printf("%-*s",maxwidth,symb->name);
if (!lastmatch->next) break;
symb=findsymbol(osdedittmp, lastmatch->next);
x += maxwidth;
if (x > (osdcols - maxwidth))
{
x = 0;
OSD_Printf("\n");
if (symb && (symb != lastmatch))
OSD_Printf(" ");
}
}
if (x) OSD_Printf("\n");
OSD_Printf(OSDTEXT_RED "Press TAB again to cycle through matches\n");
} }
} }
else
{
tabc = findsymbol(osdedittmp, lastmatch->next);
if (!tabc && lastmatch)
tabc = findsymbol(osdedittmp, NULL); // wrap */
}
if (tabc)
{
for (i=osdeditcursor; i>0; i--) if (osdeditbuf[i-1] == ' ') break;
osdeditlen = i;
for (j=0; tabc->name[j] && osdeditlen <= OSD_EDITLENGTH
&& (osdeditlen < commonsize); i++,j++,osdeditlen++)
osdeditbuf[i] = tabc->name[j];
osdeditcursor = osdeditlen;
osdeditwinend = osdeditcursor;
osdeditwinstart = osdeditwinend-editlinewidth;
if (osdeditwinstart<0)
{
osdeditwinstart=0;
osdeditwinend = editlinewidth;
}
lastmatch = tabc;
}
} }
return 0; else
{
tabc = findsymbol(osdedittmp, lastmatch->next);
if (!tabc && lastmatch)
tabc = findsymbol(osdedittmp, NULL); // wrap */
}
if (tabc)
{
for (i=osdeditcursor; i>0; i--) if (osdeditbuf[i-1] == ' ') break;
osdeditlen = i;
for (j=0; tabc->name[j] && osdeditlen <= OSD_EDITLENGTH
&& (osdeditlen < commonsize); i++,j++,osdeditlen++)
osdeditbuf[i] = tabc->name[j];
osdeditcursor = osdeditlen;
osdeditwinend = osdeditcursor;
osdeditwinstart = osdeditwinend-editlinewidth;
if (osdeditwinstart<0)
{
osdeditwinstart=0;
osdeditwinend = editlinewidth;
}
lastmatch = tabc;
}
}
return 0;
case 11: // control k, delete all to end of line case 11: // control k, delete all to end of line
Bmemset(osdeditbuf+osdeditcursor,0,sizeof(osdeditbuf)-osdeditcursor); Bmemset(osdeditbuf+osdeditcursor,0,sizeof(osdeditbuf)-osdeditcursor);
return 0; return 0;
@ -1089,7 +1092,7 @@ int32_t OSD_HandleChar(char ch)
osdhistorytotal++; osdhistorytotal++;
if (osdexeccount == OSD_HISTORYDEPTH) if (osdexeccount == OSD_HISTORYDEPTH)
OSD_Printf("Command Buffer Warning: Failed queueing command " OSD_Printf("Command Buffer Warning: Failed queueing command "
"for execution. Buffer full.\n"); "for execution. Buffer full.\n");
else else
osdexeccount++; osdexeccount++;
} }
@ -1097,7 +1100,7 @@ int32_t OSD_HandleChar(char ch)
{ {
if (osdexeccount == OSD_HISTORYDEPTH) if (osdexeccount == OSD_HISTORYDEPTH)
OSD_Printf("Command Buffer Warning: Failed queueing command " OSD_Printf("Command Buffer Warning: Failed queueing command "
"for execution. Buffer full.\n"); "for execution. Buffer full.\n");
else else
osdexeccount++; osdexeccount++;
} }
@ -1478,7 +1481,7 @@ void OSD_Draw(void)
if (osdver[0]) if (osdver[0])
drawosdstr(osdcols-osdverlen,osdrowscur - (offset >= osdcols-osdverlen), drawosdstr(osdcols-osdverlen,osdrowscur - (offset >= osdcols-osdverlen),
osdver,osdverlen,(sintable[(totalclock<<4)&2047]>>11),osdverpal); osdver,osdverlen,(sintable[(totalclock<<4)&2047]>>11),osdverpal);
} }
enddrawing(); enddrawing();
@ -1505,11 +1508,6 @@ void OSD_Printf(const char *fmt, ...)
char *chp, p=osdtextpal, s=osdtextshade; char *chp, p=osdtextpal, s=osdtextshade;
va_list va; va_list va;
/*
if ((osdflags & OSD_INITIALIZED) == 0)
OSD_Init();
*/
mutex_lock(&m_osdprintf); mutex_lock(&m_osdprintf);
va_start(va, fmt); va_start(va, fmt);
@ -1518,28 +1516,30 @@ void OSD_Printf(const char *fmt, ...)
if (tmpstr[0]=='^' && tmpstr[1]=='1' && tmpstr[2]=='0' && ++OSD_errors > MAX_ERRORS) if (tmpstr[0]=='^' && tmpstr[1]=='1' && tmpstr[2]=='0' && ++OSD_errors > MAX_ERRORS)
{ {
if (OSD_errors == MAX_ERRORS+1) Bstrcpy(tmpstr,OSD_ERROR "\nToo many errors. Logging errors stopped.\n"); if (OSD_errors == MAX_ERRORS + 1)
Bstrcpy(tmpstr, OSD_ERROR "\nToo many errors. Logging errors stopped.\n");
else else
{ {
OSD_errors=MAX_ERRORS+2; OSD_errors = MAX_ERRORS + 2;
mutex_unlock(&m_osdprintf); mutex_unlock(&m_osdprintf);
return; return;
} }
} }
if (linecnt<logcutoff) if (linecnt < logcutoff)
{ {
if (osdlog&&(!logcutoff||linecnt<logcutoff)) if (osdlog && (!logcutoff || linecnt < logcutoff))
{ {
chp = Bstrdup(tmpstr); chp = Bstrdup(tmpstr);
Bfputs(OSD_StripColors(chp,tmpstr), osdlog); Bfputs(OSD_StripColors(chp, tmpstr), osdlog);
Bprintf("%s", chp);
Bfree(chp); Bfree(chp);
} }
} }
else if (linecnt==logcutoff) else if (linecnt == logcutoff)
{ {
Bfputs("\nMaximal log size reached. Logging stopped.\nSet the \"logcutoff\" console variable to a higher value if you need a longer log.\n", osdlog); Bfputs("\nMaximal log size reached. Logging stopped.\nSet the \"logcutoff\" console variable to a higher value if you need a longer log.\n", osdlog);
linecnt=logcutoff+1; linecnt = logcutoff + 1;
} }
chp = tmpstr; chp = tmpstr;
@ -1552,11 +1552,13 @@ void OSD_Printf(const char *fmt, ...)
OSD_LineFeed(); OSD_LineFeed();
continue; continue;
} }
if (*chp == '\r') if (*chp == '\r')
{ {
osdpos=0; osdpos=0;
continue; continue;
} }
if (*chp == '^') if (*chp == '^')
{ {
if (isdigit(*(chp+1))) if (isdigit(*(chp+1)))
@ -1569,12 +1571,14 @@ void OSD_Printf(const char *fmt, ...)
p = atol(smallbuf); p = atol(smallbuf);
continue; continue;
} }
smallbuf[0] = *(chp++); smallbuf[0] = *(chp++);
smallbuf[1] = *(chp); smallbuf[1] = *(chp);
smallbuf[2] = '\0'; smallbuf[2] = '\0';
p = atol(smallbuf); p = atol(smallbuf);
continue; continue;
} }
if (Btoupper(*(chp+1)) == 'S') if (Btoupper(*(chp+1)) == 'S')
{ {
chp++; chp++;
@ -1582,6 +1586,7 @@ void OSD_Printf(const char *fmt, ...)
s = *chp; s = *chp;
continue; continue;
} }
if (Btoupper(*(chp+1)) == 'O') if (Btoupper(*(chp+1)) == 'O')
{ {
chp++; chp++;
@ -1590,8 +1595,10 @@ void OSD_Printf(const char *fmt, ...)
continue; continue;
} }
} }
osdtext[osdpos] = *chp; osdtext[osdpos] = *chp;
osdfmt[osdpos++] = p+(s<<5); osdfmt[osdpos++] = p+(s<<5);
if (osdpos == osdcols) if (osdpos == osdcols)
{ {
osdpos = 0; osdpos = 0;
@ -1766,11 +1773,11 @@ int32_t OSD_Dispatch(const char *cmd)
ofp.parms = (const char **)parms; ofp.parms = (const char **)parms;
ofp.raw = cmd; ofp.raw = cmd;
switch((intptr_t)symb->func) switch ((intptr_t)symb->func)
{ {
case (intptr_t)OSD_ALIAS: case(intptr_t)OSD_ALIAS:
OSD_Dispatch(symb->help); OSD_Dispatch(symb->help);
case (intptr_t)OSD_UNALIASED: case(intptr_t)OSD_UNALIASED:
break; break;
default: default:
switch (symb->func(&ofp)) switch (symb->func(&ofp))
@ -1797,7 +1804,7 @@ int32_t OSD_Dispatch(const char *cmd)
// //
// OSD_RegisterFunction() -- Registers a new function // OSD_RegisterFunction() -- Registers a new function
// //
int32_t OSD_RegisterFunction(const char *name, const char *help, int32_t (*func)(const osdfuncparm_t*)) int32_t OSD_RegisterFunction(const char *name, const char *help, int32_t (*func)(const osdfuncparm_t *))
{ {
symbol_t *symb; symbol_t *symb;
const char *cp; const char *cp;
@ -1841,13 +1848,13 @@ int32_t OSD_RegisterFunction(const char *name, const char *help, int32_t (*func)
if (symb) // allow this now for reusing an alias name if (symb) // allow this now for reusing an alias name
{ {
/* /*
if (symb->func != OSD_ALIAS && symb->func != OSD_UNALIASED) if (symb->func != OSD_ALIAS && symb->func != OSD_UNALIASED)
{ {
OSD_Printf("OSD_RegisterFunction(): \"%s\" is already defined\n", name); OSD_Printf("OSD_RegisterFunction(): \"%s\" is already defined\n", name);
return -1; return -1;
} }
*/ */
// Bfree((char *)symb->help); // Bfree((char *)symb->help);
symb->help = help; symb->help = help;
symb->func = func; symb->func = func;
@ -1998,7 +2005,7 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm)
float val; float val;
if (showval) if (showval)
{ {
OSD_Printf("\"%s\" is \"%f\"\n%s\n",cvars[i].name,*(float*)cvars[i].var,(char*)cvars[i].helpstr); OSD_Printf("\"%s\" is \"%f\"\n%s\n",cvars[i].name,*(float *)cvars[i].var,(char *)cvars[i].helpstr);
return OSDCMD_OK; return OSDCMD_OK;
} }
@ -2009,7 +2016,7 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm)
OSD_Printf("%s value out of range\n",cvars[i].name); OSD_Printf("%s value out of range\n",cvars[i].name);
return OSDCMD_OK; return OSDCMD_OK;
} }
*(float*)cvars[i].var = val; *(float *)cvars[i].var = val;
if (!OSD_ParsingScript()) if (!OSD_ParsingScript())
OSD_Printf("%s %f",cvars[i].name,val); OSD_Printf("%s %f",cvars[i].name,val);
} }
@ -2019,7 +2026,7 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm)
double val; double val;
if (showval) if (showval)
{ {
OSD_Printf("\"%s\" is \"%f\"\n%s\n",cvars[i].name,*(double*)cvars[i].var,(char*)cvars[i].helpstr); OSD_Printf("\"%s\" is \"%f\"\n%s\n",cvars[i].name,*(double *)cvars[i].var,(char *)cvars[i].helpstr);
return OSDCMD_OK; return OSDCMD_OK;
} }
@ -2030,7 +2037,7 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm)
OSD_Printf("%s value out of range\n",cvars[i].name); OSD_Printf("%s value out of range\n",cvars[i].name);
return OSDCMD_OK; return OSDCMD_OK;
} }
*(double*)cvars[i].var = val; *(double *)cvars[i].var = val;
if (!OSD_ParsingScript()) if (!OSD_ParsingScript())
OSD_Printf("%s %f",cvars[i].name,val); OSD_Printf("%s %f",cvars[i].name,val);
} }
@ -2042,7 +2049,7 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm)
int32_t val; int32_t val;
if (showval) if (showval)
{ {
OSD_Printf("\"%s\" is \"%d\"\n%s\n",cvars[i].name,*(int32_t*)cvars[i].var,(char*)cvars[i].helpstr); OSD_Printf("\"%s\" is \"%d\"\n%s\n",cvars[i].name,*(int32_t *)cvars[i].var,(char *)cvars[i].helpstr);
return OSDCMD_OK; return OSDCMD_OK;
} }
@ -2054,7 +2061,7 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm)
OSD_Printf("%s value out of range\n",cvars[i].name); OSD_Printf("%s value out of range\n",cvars[i].name);
return OSDCMD_OK; return OSDCMD_OK;
} }
*(int32_t*)cvars[i].var = val; *(int32_t *)cvars[i].var = val;
if (!OSD_ParsingScript()) if (!OSD_ParsingScript())
OSD_Printf("%s %d",cvars[i].name,val); OSD_Printf("%s %d",cvars[i].name,val);
} }
@ -2063,14 +2070,14 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm)
{ {
if (showval) if (showval)
{ {
OSD_Printf("\"%s\" is \"%s\"\n%s\n",cvars[i].name,(char*)cvars[i].var,(char*)cvars[i].helpstr); OSD_Printf("\"%s\" is \"%s\"\n%s\n",cvars[i].name,(char *)cvars[i].var,(char *)cvars[i].helpstr);
return OSDCMD_OK; return OSDCMD_OK;
} }
Bstrncpy((char*)cvars[i].var, parm->parms[0], cvars[i].max-1); Bstrncpy((char *)cvars[i].var, parm->parms[0], cvars[i].max-1);
((char*)cvars[i].var)[cvars[i].max-1] = 0; ((char *)cvars[i].var)[cvars[i].max-1] = 0;
if (!OSD_ParsingScript()) if (!OSD_ParsingScript())
OSD_Printf("%s %s",cvars[i].name,(char*)cvars[i].var); OSD_Printf("%s %s",cvars[i].name,(char *)cvars[i].var);
} }
break; break;
default: default:
@ -2095,12 +2102,12 @@ void OSD_WriteCvars(FILE *fp)
{ {
if (!(cvars[i].type & CVAR_NOSAVE) && OSD_CvarModified(&cvars[i])) if (!(cvars[i].type & CVAR_NOSAVE) && OSD_CvarModified(&cvars[i]))
switch (cvars[i].type&(CVAR_FLOAT|CVAR_DOUBLE|CVAR_INT|CVAR_UINT|CVAR_BOOL|CVAR_STRING)) switch (cvars[i].type&(CVAR_FLOAT|CVAR_DOUBLE|CVAR_INT|CVAR_UINT|CVAR_BOOL|CVAR_STRING))
{ {
case CVAR_FLOAT: case CVAR_FLOAT:
fprintf(fp,"%s \"%f\"\n",cvars[i].name,*(float*)cvars[i].var); fprintf(fp,"%s \"%f\"\n",cvars[i].name,*(float *)cvars[i].var);
break; break;
case CVAR_DOUBLE: case CVAR_DOUBLE:
fprintf(fp,"%s \"%f\"\n",cvars[i].name,*(double*)cvars[i].var); fprintf(fp,"%s \"%f\"\n",cvars[i].name,*(double *)cvars[i].var);
break; break;
case CVAR_INT: case CVAR_INT:
case CVAR_UINT: case CVAR_UINT:
@ -2108,11 +2115,11 @@ void OSD_WriteCvars(FILE *fp)
fprintf(fp,"%s \"%d\"\n",cvars[i].name,*(int32_t *)cvars[i].var); fprintf(fp,"%s \"%d\"\n",cvars[i].name,*(int32_t *)cvars[i].var);
break; break;
case CVAR_STRING: case CVAR_STRING:
fprintf(fp,"%s \"%s\"\n",cvars[i].name,(char*)cvars[i].var); fprintf(fp,"%s \"%s\"\n",cvars[i].name,(char *)cvars[i].var);
break; break;
default: default:
break; break;
} }
} }
} }

View file

@ -300,10 +300,10 @@ pthtyp *gltexcachead[GLTEXCACHEADSIZ];
int32_t drawingskybox = 0; int32_t drawingskybox = 0;
int32_t gloadtile_art(int32_t,int32_t,int32_t,pthtyp*,int32_t); int32_t gloadtile_art(int32_t,int32_t,int32_t,pthtyp *,int32_t);
int32_t gloadtile_hi(int32_t,int32_t,int32_t,hicreplctyp*,int32_t,pthtyp*,int32_t,char); int32_t gloadtile_hi(int32_t,int32_t,int32_t,hicreplctyp *,int32_t,pthtyp *,int32_t,char);
static int32_t hicprecaching = 0; static int32_t hicprecaching = 0;
pthtyp * gltexcache(int32_t dapicnum, int32_t dapalnum, int32_t dameth) pthtyp *gltexcache(int32_t dapicnum, int32_t dapalnum, int32_t dameth)
{ {
int32_t i, j; int32_t i, j;
hicreplctyp *si; hicreplctyp *si;
@ -645,8 +645,8 @@ void polymost_glreset()
cacheptrs[ii] = NULL; cacheptrs[ii] = NULL;
} }
Bfree(cacheptrs[i]); Bfree(cacheptrs[i]);
cacheptrs[i] = NULL; cacheptrs[i] = NULL;
} }
polymost_cachesync(); polymost_cachesync();
@ -1199,7 +1199,7 @@ int32_t gloadtile_art(int32_t dapic, int32_t dapal, int32_t dameth, pthtyp *pth,
} }
} }
if (doalloc) bglGenTextures(1,(GLuint*)&pth->glpic); //# of textures (make OpenGL allocate structure) if (doalloc) bglGenTextures(1,(GLuint *)&pth->glpic); //# of textures (make OpenGL allocate structure)
bglBindTexture(GL_TEXTURE_2D,pth->glpic); bglBindTexture(GL_TEXTURE_2D,pth->glpic);
fixtransparency(pic,tsizx,tsizy,xsiz,ysiz,dameth); fixtransparency(pic,tsizx,tsizy,xsiz,ysiz,dameth);
@ -1558,7 +1558,7 @@ int32_t gloadtile_cached(int32_t fil, texcacheheader *head, int32_t *doalloc, pt
if (*doalloc&1) if (*doalloc&1)
{ {
bglGenTextures(1,(GLuint*)&pth->glpic); //# of textures (make OpenGL allocate structure) bglGenTextures(1,(GLuint *)&pth->glpic); //# of textures (make OpenGL allocate structure)
*doalloc |= 2; // prevents bglGenTextures being called again if we fail in here *doalloc |= 2; // prevents bglGenTextures being called again if we fail in here
} }
bglBindTexture(GL_TEXTURE_2D,pth->glpic); bglBindTexture(GL_TEXTURE_2D,pth->glpic);
@ -1829,7 +1829,7 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp
intexfmt = (hasalpha == 255) ? GL_COMPRESSED_RGB_ARB : GL_COMPRESSED_RGBA_ARB; intexfmt = (hasalpha == 255) ? GL_COMPRESSED_RGB_ARB : GL_COMPRESSED_RGBA_ARB;
else if (hasalpha == 255) intexfmt = GL_RGB; else if (hasalpha == 255) intexfmt = GL_RGB;
if ((doalloc&3)==1) bglGenTextures(1,(GLuint*)&pth->glpic); //# of textures (make OpenGL allocate structure) if ((doalloc&3)==1) bglGenTextures(1,(GLuint *)&pth->glpic); //# of textures (make OpenGL allocate structure)
bglBindTexture(GL_TEXTURE_2D,pth->glpic); bglBindTexture(GL_TEXTURE_2D,pth->glpic);
fixtransparency(pic,tsizx,tsizy,xsiz,ysiz,dameth); fixtransparency(pic,tsizx,tsizy,xsiz,ysiz,dameth);
@ -2897,7 +2897,7 @@ void domost(float x0, float y0, float x1, float y1)
{ {
d = (y0-y1)*dx - (x0-x1)*cv[j]; d = (y0-y1)*dx - (x0-x1)*cv[j];
n = (y0-cy[j])*dx - (x0-nx0)*cv[j]; n = (y0-cy[j])*dx - (x0-nx0)*cv[j];
if ((fabs(n) <= fabs(d)) && (d*n >= 0) && (d != 0)) if ((fabs(n) <= fabs(d)) && (d *n >= 0) && (d != 0))
{ {
t = n/d; nx = (x1-x0)*t + x0; t = n/d; nx = (x1-x0)*t + x0;
if ((nx > nx0) && (nx < nx1)) if ((nx > nx0) && (nx < nx1))
@ -4168,7 +4168,7 @@ static void polymost_scansector(int32_t sectnum)
if ((nextsectnum >= 0) && (!(wal->cstat&32)) && (!(gotsector[nextsectnum>>3]&pow2char[nextsectnum&7]))) if ((nextsectnum >= 0) && (!(wal->cstat&32)) && (!(gotsector[nextsectnum>>3]&pow2char[nextsectnum&7])))
{ {
d = (double)x1*(double)y2 - (double)x2*(double)y1; xp1 = (double)(x2-x1); yp1 = (double)(y2-y1); d = (double)x1*(double)y2 - (double)x2*(double)y1; xp1 = (double)(x2-x1); yp1 = (double)(y2-y1);
if (d*d <= (xp1*xp1 + yp1*yp1)*(SCISDIST*SCISDIST*260.0)) if (d *d <= (xp1*xp1 + yp1*yp1)*(SCISDIST*SCISDIST*260.0))
sectorborder[sectorbordercnt++] = nextsectnum; sectorborder[sectorbordercnt++] = nextsectnum;
} }
@ -4380,7 +4380,7 @@ void polymost_drawrooms()
hitallsprites = 1; hitallsprites = 1;
hitscan((const vec3_t *)&vect,globalcursectnum, //Start position hitscan((const vec3_t *)&vect,globalcursectnum, //Start position
vx>>10,vy>>10,vz>>6,&hitinfo,0xffff0030); vx>>10,vy>>10,vz>>6,&hitinfo,0xffff0030);
if (hitinfo.hitsect != -1) // if hitsect is -1, hitscan overflowed somewhere if (hitinfo.hitsect != -1) // if hitsect is -1, hitscan overflowed somewhere
{ {
@ -5305,13 +5305,16 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
if (dastat&4) { x1 = -x1; y1 = -y1; } if (dastat&4) { x1 = -x1; y1 = -y1; }
// In Polymost, we don't care if the model is very big // In Polymost, we don't care if the model is very big
if (rendmode < 4) { if (rendmode < 4)
{
tspr.xrepeat = tspr.yrepeat = 32; tspr.xrepeat = tspr.yrepeat = 32;
tspr.x = (int32_t)(((double)gcosang*z1 - (double)gsinang*x1)*16384.0 + globalposx); tspr.x = (int32_t)(((double)gcosang*z1 - (double)gsinang*x1)*16384.0 + globalposx);
tspr.y = (int32_t)(((double)gsinang*z1 + (double)gcosang*x1)*16384.0 + globalposy); tspr.y = (int32_t)(((double)gsinang*z1 + (double)gcosang*x1)*16384.0 + globalposy);
tspr.z = (int32_t)(globalposz + y1*16384.0*0.8); tspr.z = (int32_t)(globalposz + y1*16384.0*0.8);
} else { }
else
{
float x, y, z; float x, y, z;
tspr.xrepeat = tspr.yrepeat = 5; tspr.xrepeat = tspr.yrepeat = 5;
@ -5373,7 +5376,8 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
if (!nofog) bglDisable(GL_FOG); if (!nofog) bglDisable(GL_FOG);
if (rendmode < 4) if (rendmode < 4)
mddraw(&tspr); mddraw(&tspr);
else { else
{
tspriteptr[MAXSPRITESONSCREEN] = &tspr; tspriteptr[MAXSPRITESONSCREEN] = &tspr;
bglEnable(GL_ALPHA_TEST); bglEnable(GL_ALPHA_TEST);
@ -5652,9 +5656,9 @@ static void tessectrap(float *px, float *py, int32_t *point2, int32_t numpoints)
if (numpoints+16 > allocpoints) //16 for safety if (numpoints+16 > allocpoints) //16 for safety
{ {
allocpoints = numpoints+16; allocpoints = numpoints+16;
rst = (raster*)Brealloc(rst,allocpoints*sizeof(raster)); rst = (raster *)Brealloc(rst,allocpoints*sizeof(raster));
slist = (int32_t*)Brealloc(slist,allocpoints*sizeof(int32_t)); slist = (int32_t *)Brealloc(slist,allocpoints*sizeof(int32_t));
npoint2 = (int32_t*)Brealloc(npoint2,allocpoints*sizeof(int32_t)); npoint2 = (int32_t *)Brealloc(npoint2,allocpoints*sizeof(int32_t));
} }
//Remove unnecessary collinear points: //Remove unnecessary collinear points:
@ -5949,7 +5953,7 @@ int32_t polymost_printext256(int32_t xpos, int32_t ypos, int16_t col, int16_t ba
} }
Bmemset(tbuf, 0, 256*128); Bmemset(tbuf, 0, 256*128);
cptr = (char*)textfont; cptr = (char *)textfont;
for (h=0; h<256; h++) for (h=0; h<256; h++)
{ {
tptr = tbuf + (h%32)*8 + (h/32)*256*8; tptr = tbuf + (h%32)*8 + (h/32)*256*8;
@ -5963,7 +5967,7 @@ int32_t polymost_printext256(int32_t xpos, int32_t ypos, int16_t col, int16_t ba
} }
} }
cptr = (char*)smalltextfont; cptr = (char *)smalltextfont;
for (h=0; h<256; h++) for (h=0; h<256; h++)
{ {
tptr = tbuf + 256*64 + (h%32)*8 + (h/32)*256*8; tptr = tbuf + 256*64 + (h%32)*8 + (h/32)*256*8;
@ -5978,7 +5982,7 @@ int32_t polymost_printext256(int32_t xpos, int32_t ypos, int16_t col, int16_t ba
} }
bglBindTexture(GL_TEXTURE_2D, polymosttext); bglBindTexture(GL_TEXTURE_2D, polymosttext);
bglTexImage2D(GL_TEXTURE_2D,0,GL_ALPHA,256,128,0,GL_ALPHA,GL_UNSIGNED_BYTE,(GLvoid*)tbuf); bglTexImage2D(GL_TEXTURE_2D,0,GL_ALPHA,256,128,0,GL_ALPHA,GL_UNSIGNED_BYTE,(GLvoid *)tbuf);
bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
Bfree(tbuf); Bfree(tbuf);
@ -6160,73 +6164,73 @@ void polymost_initosdfuncs(void)
cvar_t cvars_polymost[] = cvar_t cvars_polymost[] =
{ {
#ifdef USE_OPENGL #ifdef USE_OPENGL
{ "r_animsmoothing","r_animsmoothing: enable/disable model animation smoothing",(void *)&r_animsmoothing, CVAR_BOOL, 0, 1 }, { "r_animsmoothing","r_animsmoothing: enable/disable model animation smoothing",(void *) &r_animsmoothing, CVAR_BOOL, 0, 1 },
{ "r_modelocclusionchecking","r_modelocclusionchecking: enable/disable hack to cull \"obstructed\" models",(void *)&r_modelocclusionchecking, CVAR_INT, 0, 2 }, { "r_modelocclusionchecking","r_modelocclusionchecking: enable/disable hack to cull \"obstructed\" models",(void *) &r_modelocclusionchecking, CVAR_INT, 0, 2 },
{ "r_detailmapping","r_detailmapping: enable/disable detail mapping",(void *)&r_detailmapping, CVAR_BOOL, 0, 1 }, { "r_detailmapping","r_detailmapping: enable/disable detail mapping",(void *) &r_detailmapping, CVAR_BOOL, 0, 1 },
{ "r_downsize","r_downsize: controls downsizing factor for hires textures",(void *)&r_downsize, CVAR_INT|CVAR_FUNCPTR, 0, 5 }, { "r_downsize","r_downsize: controls downsizing factor for hires textures",(void *) &r_downsize, CVAR_INT|CVAR_FUNCPTR, 0, 5 },
{ "r_fullbrights","r_fullbrights: enable/disable fullbright textures",(void *)&r_fullbrights, CVAR_BOOL, 0, 1 }, { "r_fullbrights","r_fullbrights: enable/disable fullbright textures",(void *) &r_fullbrights, CVAR_BOOL, 0, 1 },
{ "r_glowmapping","r_glowmapping: enable/disable glow mapping",(void *)&r_glowmapping, CVAR_BOOL, 0, 1 }, { "r_glowmapping","r_glowmapping: enable/disable glow mapping",(void *) &r_glowmapping, CVAR_BOOL, 0, 1 },
/* /*
{ "r_multisample","r_multisample: sets the number of samples used for antialiasing (0 = off)",(void *)&r_glowmapping, CVAR_BOOL, 0, 1 } { "r_multisample","r_multisample: sets the number of samples used for antialiasing (0 = off)",(void *)&r_glowmapping, CVAR_BOOL, 0, 1 }
{ "r_nvmultisamplehint","r_nvmultisamplehint: enable/disable Nvidia multisampling hinting",(void *)&glnvmultisamplehint, CVAR_BOOL, 0, 1 } { "r_nvmultisamplehint","r_nvmultisamplehint: enable/disable Nvidia multisampling hinting",(void *)&glnvmultisamplehint, CVAR_BOOL, 0, 1 }
*/ */
{ {
"r_parallaxskyclamping","r_parallaxskyclamping: enable/disable parallaxed floor/ceiling sky texture clamping", "r_parallaxskyclamping","r_parallaxskyclamping: enable/disable parallaxed floor/ceiling sky texture clamping",
(void *)&r_parallaxskyclamping, CVAR_BOOL, 0, 1 (void *) &r_parallaxskyclamping, CVAR_BOOL, 0, 1
}, },
{ {
"r_parallaxskypanning","r_parallaxskypanning: enable/disable parallaxed floor/ceiling panning when drawing a parallaxed sky", "r_parallaxskypanning","r_parallaxskypanning: enable/disable parallaxed floor/ceiling panning when drawing a parallaxed sky",
(void *)&r_parallaxskypanning, CVAR_BOOL, 0, 1 (void *) &r_parallaxskypanning, CVAR_BOOL, 0, 1
}, },
{ "r_polygonmode","r_polygonmode: debugging feature",(void *)&glpolygonmode, CVAR_INT | CVAR_NOSAVE, 0, 3 }, { "r_polygonmode","r_polygonmode: debugging feature",(void *) &glpolygonmode, CVAR_INT | CVAR_NOSAVE, 0, 3 },
{ "r_redbluemode","r_redbluemode: enable/disable experimental OpenGL red-blue glasses mode",(void *)&glredbluemode, CVAR_BOOL, 0, 1 }, { "r_redbluemode","r_redbluemode: enable/disable experimental OpenGL red-blue glasses mode",(void *) &glredbluemode, CVAR_BOOL, 0, 1 },
{ "r_shadescale","r_shadescale: multiplier for lighting",(void *)&shadescale, CVAR_FLOAT, 0, 10 }, { "r_shadescale","r_shadescale: multiplier for lighting",(void *) &shadescale, CVAR_FLOAT, 0, 10 },
{ "r_swapinterval","r_swapinterval: sets the GL swap interval (VSync)",(void *)&vsync, CVAR_BOOL|CVAR_FUNCPTR, 0, 1 }, { "r_swapinterval","r_swapinterval: sets the GL swap interval (VSync)",(void *) &vsync, CVAR_BOOL|CVAR_FUNCPTR, 0, 1 },
{ "r_texcache","r_texcache: enable/disable OpenGL compressed texture cache",(void *)&glusetexcache, CVAR_INT, 0, 2 }, { "r_texcache","r_texcache: enable/disable OpenGL compressed texture cache",(void *) &glusetexcache, CVAR_INT, 0, 2 },
{ "r_texcompr","r_texcompr: enable/disable OpenGL texture compression",(void *)&glusetexcompr, CVAR_BOOL, 0, 1 }, { "r_texcompr","r_texcompr: enable/disable OpenGL texture compression",(void *) &glusetexcompr, CVAR_BOOL, 0, 1 },
{ "r_textureanisotropy", "r_textureanisotropy: changes the OpenGL texture anisotropy setting", (void *)&glanisotropy, CVAR_INT|CVAR_FUNCPTR, 0, 16 }, { "r_textureanisotropy", "r_textureanisotropy: changes the OpenGL texture anisotropy setting", (void *) &glanisotropy, CVAR_INT|CVAR_FUNCPTR, 0, 16 },
{ "r_texturemaxsize","r_texturemaxsize: changes the maximum OpenGL texture size limit",(void *)&gltexmaxsize, CVAR_INT | CVAR_NOSAVE, 0, 4096 }, { "r_texturemaxsize","r_texturemaxsize: changes the maximum OpenGL texture size limit",(void *) &gltexmaxsize, CVAR_INT | CVAR_NOSAVE, 0, 4096 },
{ "r_texturemiplevel","r_texturemiplevel: changes the highest OpenGL mipmap level used",(void *)&gltexmiplevel, CVAR_INT, 0, 6 }, { "r_texturemiplevel","r_texturemiplevel: changes the highest OpenGL mipmap level used",(void *) &gltexmiplevel, CVAR_INT, 0, 6 },
{ "r_texturemode", "r_texturemode: changes the texture filtering settings", (void *)&gltexfiltermode, CVAR_INT|CVAR_FUNCPTR, 0, 5 }, { "r_texturemode", "r_texturemode: changes the texture filtering settings", (void *) &gltexfiltermode, CVAR_INT|CVAR_FUNCPTR, 0, 5 },
{ "r_vbocount","r_vbocount: sets the number of Vertex Buffer Objects to use when drawing models",(void *)&r_vbocount, CVAR_INT, 1, 256 }, { "r_vbocount","r_vbocount: sets the number of Vertex Buffer Objects to use when drawing models",(void *) &r_vbocount, CVAR_INT, 1, 256 },
{ "r_vbos","r_vbos: enable/disable using Vertex Buffer Objects when drawing models",(void *)&r_vbos, CVAR_BOOL, 0, 1 }, { "r_vbos","r_vbos: enable/disable using Vertex Buffer Objects when drawing models",(void *) &r_vbos, CVAR_BOOL, 0, 1 },
{ "r_vertexarrays","r_vertexarrays: enable/disable using vertex arrays when drawing models",(void *)&r_vertexarrays, CVAR_BOOL, 0, 1 }, { "r_vertexarrays","r_vertexarrays: enable/disable using vertex arrays when drawing models",(void *) &r_vertexarrays, CVAR_BOOL, 0, 1 },
{ "r_anamorphic", "r_anamorphic: enable/disable widescreen mode", (void*)&glwidescreen, CVAR_BOOL, 0, 1 }, { "r_anamorphic", "r_anamorphic: enable/disable widescreen mode", (void *) &glwidescreen, CVAR_BOOL, 0, 1 },
{ "r_projectionhack", "r_projectionhack: enable/disable projection hack", (void*)&glprojectionhacks, CVAR_INT, 0, 2 }, { "r_projectionhack", "r_projectionhack: enable/disable projection hack", (void *) &glprojectionhacks, CVAR_INT, 0, 2 },
#ifdef POLYMER #ifdef POLYMER
// polymer cvars // polymer cvars
{ "r_pr_lighting", "r_pr_lighting: enable/disable dynamic lights", (void*)&pr_lighting, CVAR_BOOL, 0, 1 }, { "r_pr_lighting", "r_pr_lighting: enable/disable dynamic lights", (void *) &pr_lighting, CVAR_BOOL, 0, 1 },
{ "r_pr_normalmapping", "r_pr_normalmapping: enable/disable virtual displacement mapping", (void*)&pr_normalmapping, CVAR_BOOL, 0, 1 }, { "r_pr_normalmapping", "r_pr_normalmapping: enable/disable virtual displacement mapping", (void *) &pr_normalmapping, CVAR_BOOL, 0, 1 },
{ "r_pr_specularmapping", "r_pr_specularmapping: enable/disable specular mapping", (void*)&pr_specularmapping, CVAR_BOOL, 0, 1 }, { "r_pr_specularmapping", "r_pr_specularmapping: enable/disable specular mapping", (void *) &pr_specularmapping, CVAR_BOOL, 0, 1 },
{ "r_pr_shadows", "r_pr_shadows: enable/disable dynamic shadows", (void*)&pr_shadows, CVAR_BOOL, 0, 1 }, { "r_pr_shadows", "r_pr_shadows: enable/disable dynamic shadows", (void *) &pr_shadows, CVAR_BOOL, 0, 1 },
{ "r_pr_shadowcount", "r_pr_shadowcount: maximal amount of shadow emitting lights on screen - you need to restart the renderer for it to take effect", (void*)&pr_shadowcount, CVAR_INT, 0, 64 }, { "r_pr_shadowcount", "r_pr_shadowcount: maximal amount of shadow emitting lights on screen - you need to restart the renderer for it to take effect", (void *) &pr_shadowcount, CVAR_INT, 0, 64 },
{ "r_pr_shadowdetail", "r_pr_shadowdetail: sets the shadow map resolution - you need to restart the renderer for it to take effect", (void*)&pr_shadowdetail, CVAR_INT, 0, 5 }, { "r_pr_shadowdetail", "r_pr_shadowdetail: sets the shadow map resolution - you need to restart the renderer for it to take effect", (void *) &pr_shadowdetail, CVAR_INT, 0, 5 },
{ "r_pr_shadowfiltering", "r_pr_shadowfiltering: enable/disable shadow edges filtering - you need to restart the renderer for it to take effect", (void*)&pr_shadowfiltering, CVAR_BOOL, 0, 1 }, { "r_pr_shadowfiltering", "r_pr_shadowfiltering: enable/disable shadow edges filtering - you need to restart the renderer for it to take effect", (void *) &pr_shadowfiltering, CVAR_BOOL, 0, 1 },
{ "r_pr_maxlightpasses", "r_pr_maxlightpasses: the maximal amount of lights a single object can by affected by", (void*)&r_pr_maxlightpasses, CVAR_INT|CVAR_FUNCPTR, 0, PR_MAXLIGHTS }, { "r_pr_maxlightpasses", "r_pr_maxlightpasses: the maximal amount of lights a single object can by affected by", (void *) &r_pr_maxlightpasses, CVAR_INT|CVAR_FUNCPTR, 0, PR_MAXLIGHTS },
{ "r_pr_maxlightpriority", "r_pr_maxlightpriority: lowering that value removes less meaningful lights from the scene", (void*)&pr_maxlightpriority, CVAR_INT, 0, PR_MAXLIGHTPRIORITY }, { "r_pr_maxlightpriority", "r_pr_maxlightpriority: lowering that value removes less meaningful lights from the scene", (void *) &pr_maxlightpriority, CVAR_INT, 0, PR_MAXLIGHTPRIORITY },
{ "r_pr_fov", "r_pr_fov: sets the field of vision in build angle", (void*)&pr_fov, CVAR_INT, 0, 1023}, { "r_pr_fov", "r_pr_fov: sets the field of vision in build angle", (void *) &pr_fov, CVAR_INT, 0, 1023},
{ "r_pr_customaspect", "r_pr_customaspect: if non-zero, forces the 3D view aspect ratio", (void*)&pr_customaspect, CVAR_FLOAT, 0, 3 }, { "r_pr_customaspect", "r_pr_customaspect: if non-zero, forces the 3D view aspect ratio", (void *) &pr_customaspect, CVAR_FLOAT, 0, 3 },
{ "r_pr_billboardingmode", "r_pr_billboardingmode: face sprite display method. 0: classic mode; 1: polymost mode", (void*)&pr_billboardingmode, CVAR_INT, 0, 1 }, { "r_pr_billboardingmode", "r_pr_billboardingmode: face sprite display method. 0: classic mode; 1: polymost mode", (void *) &pr_billboardingmode, CVAR_INT, 0, 1 },
{ "r_pr_verbosity", "r_pr_verbosity: verbosity level of the polymer renderer", (void*)&pr_verbosity, CVAR_INT, 0, 3 }, { "r_pr_verbosity", "r_pr_verbosity: verbosity level of the polymer renderer", (void *) &pr_verbosity, CVAR_INT, 0, 3 },
{ "r_pr_wireframe", "r_pr_wireframe: toggles wireframe mode", (void*)&pr_wireframe, CVAR_INT | CVAR_NOSAVE, 0, 1 }, { "r_pr_wireframe", "r_pr_wireframe: toggles wireframe mode", (void *) &pr_wireframe, CVAR_INT | CVAR_NOSAVE, 0, 1 },
{ "r_pr_vbos", "r_pr_vbos: contols Vertex Buffer Object usage. 0: no VBOs. 1: VBOs for map data. 2: VBOs for model data.", (void*)&pr_vbos, CVAR_INT, 0, 2 }, { "r_pr_vbos", "r_pr_vbos: contols Vertex Buffer Object usage. 0: no VBOs. 1: VBOs for map data. 2: VBOs for model data.", (void *) &pr_vbos, CVAR_INT, 0, 2 },
{ "r_pr_gpusmoothing", "r_pr_gpusmoothing: toggles model animation interpolation", (void*)&pr_gpusmoothing, CVAR_INT, 0, 1 }, { "r_pr_gpusmoothing", "r_pr_gpusmoothing: toggles model animation interpolation", (void *) &pr_gpusmoothing, CVAR_INT, 0, 1 },
{ "r_pr_overrideparallax", "r_pr_overrideparallax: overrides parallax mapping scale and bias values with values from the pr_parallaxscale and pr_parallaxbias cvars; use it to fine-tune DEF tokens", (void*)&pr_overrideparallax, CVAR_BOOL | CVAR_NOSAVE, 0, 1 }, { "r_pr_overrideparallax", "r_pr_overrideparallax: overrides parallax mapping scale and bias values with values from the pr_parallaxscale and pr_parallaxbias cvars; use it to fine-tune DEF tokens", (void *) &pr_overrideparallax, CVAR_BOOL | CVAR_NOSAVE, 0, 1 },
{ "r_pr_parallaxscale", "r_pr_parallaxscale: overriden parallax mapping offset scale", (void*)&pr_parallaxscale, CVAR_FLOAT | CVAR_NOSAVE, -10, 10 }, { "r_pr_parallaxscale", "r_pr_parallaxscale: overriden parallax mapping offset scale", (void *) &pr_parallaxscale, CVAR_FLOAT | CVAR_NOSAVE, -10, 10 },
{ "r_pr_parallaxbias", "r_pr_parallaxbias: overriden parallax mapping offset bias", (void*)&pr_parallaxbias, CVAR_FLOAT | CVAR_NOSAVE, -10, 10 }, { "r_pr_parallaxbias", "r_pr_parallaxbias: overriden parallax mapping offset bias", (void *) &pr_parallaxbias, CVAR_FLOAT | CVAR_NOSAVE, -10, 10 },
{ "r_pr_overridespecular", "r_pr_overridespecular: overrides specular material power and factor values with values from the pr_specularpower and pr_specularfactor cvars; use it to fine-tune DEF tokens", (void*)&pr_overridespecular, CVAR_BOOL | CVAR_NOSAVE, 0, 1 }, { "r_pr_overridespecular", "r_pr_overridespecular: overrides specular material power and factor values with values from the pr_specularpower and pr_specularfactor cvars; use it to fine-tune DEF tokens", (void *) &pr_overridespecular, CVAR_BOOL | CVAR_NOSAVE, 0, 1 },
{ "r_pr_specularpower", "r_pr_specularpower: overriden specular material power", (void*)&pr_specularpower, CVAR_FLOAT | CVAR_NOSAVE, -10, 1000 }, { "r_pr_specularpower", "r_pr_specularpower: overriden specular material power", (void *) &pr_specularpower, CVAR_FLOAT | CVAR_NOSAVE, -10, 1000 },
{ "r_pr_specularfactor", "r_pr_specularfactor: overriden specular material factor", (void*)&pr_specularfactor, CVAR_FLOAT | CVAR_NOSAVE, -10, 1000 }, { "r_pr_specularfactor", "r_pr_specularfactor: overriden specular material factor", (void *) &pr_specularfactor, CVAR_FLOAT | CVAR_NOSAVE, -10, 1000 },
{ "r_pr_highpalookups", "r_pr_highpalookups: enable/disable highpalookups", (void*)&pr_highpalookups, CVAR_BOOL, 0, 1 }, { "r_pr_highpalookups", "r_pr_highpalookups: enable/disable highpalookups", (void *) &pr_highpalookups, CVAR_BOOL, 0, 1 },
{ "r_pr_ati_fboworkaround", "r_pr_ati_fboworkaround: enable this to workaround an ATI driver bug that causes sprite shadows to be square - you need to restart the renderer for it to take effect", (void*)&pr_ati_fboworkaround, CVAR_BOOL | CVAR_NOSAVE, 0, 1 }, { "r_pr_ati_fboworkaround", "r_pr_ati_fboworkaround: enable this to workaround an ATI driver bug that causes sprite shadows to be square - you need to restart the renderer for it to take effect", (void *) &pr_ati_fboworkaround, CVAR_BOOL | CVAR_NOSAVE, 0, 1 },
{ "r_pr_ati_nodepthoffset", "r_pr_ati_nodepthoffset: enable this to workaround an ATI driver bug that causes sprite drawing to freeze the game on Radeon X1x00 hardware - you need to restart the renderer for it to take effect", (void*)&pr_ati_nodepthoffset, CVAR_BOOL | CVAR_NOSAVE, 0, 1 }, { "r_pr_ati_nodepthoffset", "r_pr_ati_nodepthoffset: enable this to workaround an ATI driver bug that causes sprite drawing to freeze the game on Radeon X1x00 hardware - you need to restart the renderer for it to take effect", (void *) &pr_ati_nodepthoffset, CVAR_BOOL | CVAR_NOSAVE, 0, 1 },
#endif #endif
{ "r_models","r_models: enable/disable model rendering",(void *)&usemodels, CVAR_BOOL, 0, 1 }, { "r_models","r_models: enable/disable model rendering",(void *) &usemodels, CVAR_BOOL, 0, 1 },
{ "r_hightile","r_hightile: enable/disable hightile texture rendering",(void *)&usehightile, CVAR_BOOL, 0, 1 }, { "r_hightile","r_hightile: enable/disable hightile texture rendering",(void *) &usehightile, CVAR_BOOL, 0, 1 },
{ "r_preview_mouseaim", "r_preview_mouseaim: toggles mouse aiming preview, use this to calibrate yxaspect in Polymost Mapster32", (void *)&preview_mouseaim, CVAR_BOOL, 0, 1 }, { "r_preview_mouseaim", "r_preview_mouseaim: toggles mouse aiming preview, use this to calibrate yxaspect in Polymost Mapster32", (void *) &preview_mouseaim, CVAR_BOOL, 0, 1 },
#endif #endif
}; };
@ -6273,7 +6277,7 @@ void polymost_precache(int32_t dapicnum, int32_t dapalnum, int32_t datype)
for (i=0; i<=j; i++) for (i=0; i<=j; i++)
{ {
mdloadskin((md2model_t*)models[mid], 0, dapalnum, i); mdloadskin((md2model_t *)models[mid], 0, dapalnum, i);
} }
} }
#endif #endif
@ -6343,9 +6347,9 @@ int32_t dxtfilter(int32_t fil, texcachepicture *pict, char *pic, void *midbuf, c
char *cptr; char *cptr;
if ((pict->format == B_LITTLE32(GL_COMPRESSED_RGB_S3TC_DXT1_EXT)) || if ((pict->format == B_LITTLE32(GL_COMPRESSED_RGB_S3TC_DXT1_EXT)) ||
(pict->format == B_LITTLE32(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT))) { offs = 0; stride = 8; } (pict->format == B_LITTLE32(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT))) { offs = 0; stride = 8; }
else if ((pict->format == B_LITTLE32(GL_COMPRESSED_RGBA_S3TC_DXT3_EXT)) || else if ((pict->format == B_LITTLE32(GL_COMPRESSED_RGBA_S3TC_DXT3_EXT)) ||
(pict->format == B_LITTLE32(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT))) { offs = 8; stride = 16; } (pict->format == B_LITTLE32(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT))) { offs = 8; stride = 16; }
else { offs = 0; stride = 8; } else { offs = 0; stride = 8; }
if (stride == 16) //If DXT3... if (stride == 16) //If DXT3...
@ -6380,58 +6384,58 @@ int32_t dxtfilter(int32_t fil, texcachepicture *pict, char *pic, void *midbuf, c
cptr = midbuf; cptr = midbuf;
for (k=0; k<=2; k+=2) for (k=0; k<=2; k+=2)
for (j=0; (unsigned)j<miplen; j+=stride) for (j=0; (unsigned)j<miplen; j+=stride)
{ *(int16_t *)cptr = hicosub(*(int16_t *)(&pic[offs+j+k])); cptr += 2; } { *(int16_t *)cptr = hicosub(*(int16_t *)(&pic[offs+j+k])); cptr += 2; }
if (glusetexcache == 2) if (glusetexcache == 2)
{
j = (miplen/stride)<<2;
cleng = qlz_compress(midbuf,packbuf,j,state_compress);
if (cleng == 0 || cleng > j-1)
{ {
j = (miplen/stride)<<2; cleng = j;
cleng = qlz_compress(midbuf,packbuf,j,state_compress);
if (cleng == 0 || cleng > j-1)
{
cleng = j;
writebuf = midbuf;
}
else writebuf = packbuf;
}
else
{
cleng = (miplen/stride)<<2;
writebuf = midbuf; writebuf = midbuf;
} }
j = B_LITTLE32(cleng); else writebuf = packbuf;
Bwrite(fil,&j,sizeof(j)); }
Bwrite(fil,writebuf,cleng); else
{
cleng = (miplen/stride)<<2;
writebuf = midbuf;
}
j = B_LITTLE32(cleng);
Bwrite(fil,&j,sizeof(j));
Bwrite(fil,writebuf,cleng);
//index_4x4 //index_4x4
cptr = midbuf; cptr = midbuf;
for (j=0; (unsigned)j<miplen; j+=stride) for (j=0; (unsigned)j<miplen; j+=stride)
{
char *c2 = &pic[j+offs+4];
cptr[0] = ((c2[0]>>0)&3) + (((c2[1]>>0)&3)<<2) + (((c2[2]>>0)&3)<<4) + (((c2[3]>>0)&3)<<6);
cptr[1] = ((c2[0]>>2)&3) + (((c2[1]>>2)&3)<<2) + (((c2[2]>>2)&3)<<4) + (((c2[3]>>2)&3)<<6);
cptr[2] = ((c2[0]>>4)&3) + (((c2[1]>>4)&3)<<2) + (((c2[2]>>4)&3)<<4) + (((c2[3]>>4)&3)<<6);
cptr[3] = ((c2[0]>>6)&3) + (((c2[1]>>6)&3)<<2) + (((c2[2]>>6)&3)<<4) + (((c2[3]>>6)&3)<<6);
cptr += 4;
}
if (glusetexcache == 2)
{
j = (miplen/stride)<<2;
cleng = qlz_compress(midbuf,packbuf,j,state_compress);
if (cleng == 0 || cleng > j-1)
{ {
char *c2 = &pic[j+offs+4]; cleng = j;
cptr[0] = ((c2[0]>>0)&3) + (((c2[1]>>0)&3)<<2) + (((c2[2]>>0)&3)<<4) + (((c2[3]>>0)&3)<<6);
cptr[1] = ((c2[0]>>2)&3) + (((c2[1]>>2)&3)<<2) + (((c2[2]>>2)&3)<<4) + (((c2[3]>>2)&3)<<6);
cptr[2] = ((c2[0]>>4)&3) + (((c2[1]>>4)&3)<<2) + (((c2[2]>>4)&3)<<4) + (((c2[3]>>4)&3)<<6);
cptr[3] = ((c2[0]>>6)&3) + (((c2[1]>>6)&3)<<2) + (((c2[2]>>6)&3)<<4) + (((c2[3]>>6)&3)<<6);
cptr += 4;
}
if (glusetexcache == 2)
{
j = (miplen/stride)<<2;
cleng = qlz_compress(midbuf,packbuf,j,state_compress);
if (cleng == 0 || cleng > j-1)
{
cleng = j;
writebuf = midbuf;
}
else writebuf = packbuf;
}
else
{
cleng = (miplen/stride)<<2;
writebuf = midbuf; writebuf = midbuf;
} }
j = B_LITTLE32(cleng); else writebuf = packbuf;
Bwrite(fil,&j,sizeof(j)); }
Bwrite(fil,writebuf,cleng); else
return 0; {
cleng = (miplen/stride)<<2;
writebuf = midbuf;
}
j = B_LITTLE32(cleng);
Bwrite(fil,&j,sizeof(j));
Bwrite(fil,writebuf,cleng);
return 0;
} }
int32_t dedxtfilter(int32_t fil, texcachepicture *pict, char *pic, void *midbuf, char *packbuf, int32_t ispacked) int32_t dedxtfilter(int32_t fil, texcachepicture *pict, char *pic, void *midbuf, char *packbuf, int32_t ispacked)

View file

@ -40,9 +40,9 @@ int32_t boundmulscale(int32_t a, int32_t b, int32_t c)
"xorl $0x7fffffff, %%eax\n\t" // xor eax, 0x7fffffff "xorl $0x7fffffff, %%eax\n\t" // xor eax, 0x7fffffff
"1:" // skipboundit: "1:" // skipboundit:
: "+a"(a), "+b"(b), "+c"(c) // input eax ebx ecx : "+a"(a), "+b"(b), "+c"(c) // input eax ebx ecx
: :
: "edx", "cc" : "edx", "cc"
); );
return a; return a;
} }
@ -84,8 +84,8 @@ void clearbufbyte(void *D, int32_t c, int32_t a)
"stosb\n\t" "stosb\n\t"
"5:" // endit "5:" // endit
: "+D"(D), "+c"(c), "+a"(a) : : "+D"(D), "+c"(c), "+a"(a) :
: "ebx", "memory", "cc" : "ebx", "memory", "cc"
); );
} }
void copybufbyte(void *S, void *D, int32_t c) void copybufbyte(void *S, void *D, int32_t c)
@ -125,8 +125,8 @@ void copybufbyte(void *S, void *D, int32_t c)
"movsb\n\t" "movsb\n\t"
"5:" // endit: "5:" // endit:
: "+c"(c), "+S"(S), "+D"(D) : : "+c"(c), "+S"(S), "+D"(D) :
: "ebx", "memory", "cc" : "ebx", "memory", "cc"
); );
} }
void copybufreverse(void *S, void *D, int32_t c) void copybufreverse(void *S, void *D, int32_t c)
@ -159,8 +159,8 @@ void copybufreverse(void *S, void *D, int32_t c)
"jnz 2b\n\t" // jnz begloop "jnz 2b\n\t" // jnz begloop
"3:" "3:"
: "+S"(S), "+D"(D), "+c"(c) : : "+S"(S), "+D"(D), "+c"(c) :
: "eax", "memory", "cc" : "eax", "memory", "cc"
); );
} }
#elif defined(_MSC_VER) && !defined(NOASM) // __GNUC__ && __i386__ #elif defined(_MSC_VER) && !defined(NOASM) // __GNUC__ && __i386__
@ -191,19 +191,19 @@ void qinterpolatedown16short(intptr_t bufptr, int32_t num, int32_t val, int32_t
void clearbuf(void *d, int32_t c, int32_t a) void clearbuf(void *d, int32_t c, int32_t a)
{ {
int32_t *p = (int32_t*)d; int32_t *p = (int32_t *)d;
while ((c--) > 0) *(p++) = a; while ((c--) > 0) *(p++) = a;
} }
void copybuf(void *s, void *d, int32_t c) void copybuf(void *s, void *d, int32_t c)
{ {
int32_t *p = (int32_t*)s, *q = (int32_t*)d; int32_t *p = (int32_t *)s, *q = (int32_t *)d;
while ((c--) > 0) *(q++) = *(p++); while ((c--) > 0) *(q++) = *(p++);
} }
void swapbuf4(void *a, void *b, int32_t c) void swapbuf4(void *a, void *b, int32_t c)
{ {
int32_t *p = (int32_t*)a, *q = (int32_t*)b; int32_t *p = (int32_t *)a, *q = (int32_t *)b;
int32_t x, y; int32_t x, y;
while ((c--) > 0) while ((c--) > 0)
{ {
@ -217,7 +217,7 @@ void swapbuf4(void *a, void *b, int32_t c)
void clearbufbyte(void *D, int32_t c, int32_t a) void clearbufbyte(void *D, int32_t c, int32_t a)
{ {
// Cringe City // Cringe City
char *p = (char*)D; char *p = (char *)D;
int32_t m[4] = { 0xffl,0xff00l,0xff0000l,0xff000000l }; int32_t m[4] = { 0xffl,0xff00l,0xff0000l,0xff000000l };
int32_t n[4] = { 0,8,16,24 }; int32_t n[4] = { 0,8,16,24 };
int32_t z=0; int32_t z=0;
@ -230,13 +230,13 @@ void clearbufbyte(void *D, int32_t c, int32_t a)
void copybufbyte(void *S, void *D, int32_t c) void copybufbyte(void *S, void *D, int32_t c)
{ {
char *p = (char*)S, *q = (char*)D; char *p = (char *)S, *q = (char *)D;
while ((c--) > 0) *(q++) = *(p++); while ((c--) > 0) *(q++) = *(p++);
} }
void copybufreverse(void *S, void *D, int32_t c) void copybufreverse(void *S, void *D, int32_t c)
{ {
char *p = (char*)S, *q = (char*)D; char *p = (char *)S, *q = (char *)D;
while ((c--) > 0) *(q++) = *(p--); while ((c--) > 0) *(q++) = *(p--);
} }

File diff suppressed because it is too large Load diff

View file

@ -18,10 +18,10 @@ extern void SetKey(int32_t key, int32_t state);
#define MASK_UP (MASK_DOWN<<1) #define MASK_UP (MASK_DOWN<<1)
#define MouseWheelFakePressTime 50 #define MouseWheelFakePressTime 50
#ifndef GET_RAWINPUT_CODE_WPARAM #ifndef GET_RAWINPUT_CODE_WPARAM
#define GET_RAWINPUT_CODE_WPARAM(wParam) ((wParam) & 0xff) #define GET_RAWINPUT_CODE_WPARAM(wParam) ((wParam) & 0xff)
#endif #endif
static inline void RI_ProcessMouse(const RAWMOUSE* rmouse) static inline void RI_ProcessMouse(const RAWMOUSE *rmouse)
{ {
int32_t i, mask; int32_t i, mask;
@ -77,7 +77,7 @@ static inline void RI_ProcessMouse(const RAWMOUSE* rmouse)
} }
} }
static inline void RI_ProcessKeyboard(const RAWKEYBOARD* rkbd) static inline void RI_ProcessKeyboard(const RAWKEYBOARD *rkbd)
{ {
uint8_t key = rkbd->MakeCode, VKey = rkbd->VKey; uint8_t key = rkbd->MakeCode, VKey = rkbd->VKey;

View file

@ -279,7 +279,7 @@ scriptfile *scriptfile_fromfile(const char *fn)
return NULL; return NULL;
} }
sf = (scriptfile*) Bmalloc(sizeof(scriptfile)); sf = (scriptfile *) Bmalloc(sizeof(scriptfile));
if (!sf) if (!sf)
{ {
kclose(fp); kclose(fp);
@ -311,7 +311,7 @@ scriptfile *scriptfile_fromstring(const char *string)
tx = (char *) Bmalloc(flen + 2); tx = (char *) Bmalloc(flen + 2);
if (!tx) return NULL; if (!tx) return NULL;
sf = (scriptfile*) Bmalloc(sizeof(scriptfile)); sf = (scriptfile *) Bmalloc(sizeof(scriptfile));
if (!sf) if (!sf)
{ {
Bfree(tx); Bfree(tx);
@ -349,7 +349,7 @@ int32_t scriptfile_eof(scriptfile *sf)
static int32_t symbtablength=0, symbtaballoclength=0; static int32_t symbtablength=0, symbtaballoclength=0;
static char *symbtab = NULL; static char *symbtab = NULL;
static char * getsymbtabspace(int32_t reqd) static char *getsymbtabspace(int32_t reqd)
{ {
char *pos,*np; char *pos,*np;
int32_t i; int32_t i;
@ -375,7 +375,7 @@ int32_t scriptfile_getsymbolvalue(char *name, int32_t *val)
{ {
if (!Bstrcasecmp(name, scanner)) if (!Bstrcasecmp(name, scanner))
{ {
*val = *(int32_t*)(scanner + strlen(scanner) + 1); *val = *(int32_t *)(scanner + strlen(scanner) + 1);
return 1; return 1;
} }
@ -397,7 +397,7 @@ int32_t scriptfile_addsymbolvalue(char *name, int32_t val)
{ {
if (!Bstrcasecmp(name, scanner)) if (!Bstrcasecmp(name, scanner))
{ {
*(int32_t*)(scanner + strlen(scanner) + 1) = val; *(int32_t *)(scanner + strlen(scanner) + 1) = val;
return 1; return 1;
} }
@ -409,7 +409,7 @@ int32_t scriptfile_addsymbolvalue(char *name, int32_t val)
if (!sp) return 0; if (!sp) return 0;
strcpy(sp, name); strcpy(sp, name);
sp += strlen(name)+1; sp += strlen(name)+1;
*(int32_t*)sp = val; *(int32_t *)sp = val;
return 1; // added return 1; // added
} }

View file

@ -54,7 +54,7 @@ int32_t _buildargc = 1;
const char **_buildargv = NULL; const char **_buildargv = NULL;
extern int32_t app_main(int32_t argc, const char *argv[]); extern int32_t app_main(int32_t argc, const char *argv[]);
char quitevent=0, appactive=1; char quitevent=0, appactive=1, novideo=0;
// video // video
static SDL_Surface *sdl_surface; static SDL_Surface *sdl_surface;
@ -81,8 +81,8 @@ static char keytranslation[SDL_NUM_SCANCODES];
static int32_t buildkeytranslationtable(void); static int32_t buildkeytranslationtable(void);
//static SDL_Surface * loadtarga(const char *fn); // for loading the icon //static SDL_Surface * loadtarga(const char *fn); // for loading the icon
static SDL_Surface * appicon = NULL; static SDL_Surface *appicon = NULL;
static SDL_Surface * loadappicon(void); static SDL_Surface *loadappicon(void);
static mutex_t m_initprintf; static mutex_t m_initprintf;
@ -183,7 +183,7 @@ int32_t main(int32_t argc, char *argv[])
startwin_open(); startwin_open();
_buildargc = argc; _buildargc = argc;
_buildargv = (const char**)argv; _buildargv = (const char **)argv;
// pipe standard outputs to files // pipe standard outputs to files
if ((argp = Bgetenv("BUILD_LOGSTDOUT")) != NULL) if ((argp = Bgetenv("BUILD_LOGSTDOUT")) != NULL)
@ -228,7 +228,7 @@ void setvsync(int32_t sync)
} }
#endif #endif
static void attach_debugger_here(void){} static void attach_debugger_here(void) {}
#ifdef __GNUC__ #ifdef __GNUC__
# define PRINTSTACKONSEGV 1 # define PRINTSTACKONSEGV 1
@ -295,8 +295,15 @@ int32_t initsystem(void)
#endif #endif
)) ))
{ {
initprintf("Initialization failed! (%s)\n", SDL_GetError()); initprintf("Initialization failed! (%s)\nNon-interactive mode enabled\n", SDL_GetError());
return -1; /* if (SDL_Init(0))
{
initprintf("Initialization failed! (%s)\n", SDL_GetError());
return -1;
}
else
*/
novideo = nogl = 1;
} }
signal(SIGSEGV, sighandler); signal(SIGSEGV, sighandler);
@ -309,7 +316,7 @@ int32_t initsystem(void)
lockcount = 0; lockcount = 0;
#ifdef USE_OPENGL #ifdef USE_OPENGL
if (loadgldriver(getenv("BUILD_GLDRV"))) if (!novideo && loadgldriver(getenv("BUILD_GLDRV")))
{ {
initprintf("Failed loading OpenGL driver. GL modes will be unavailable.\n"); initprintf("Failed loading OpenGL driver. GL modes will be unavailable.\n");
nogl = 1; nogl = 1;
@ -319,13 +326,18 @@ int32_t initsystem(void)
#ifndef __APPLE__ #ifndef __APPLE__
//icon = loadtarga("icon.tga"); //icon = loadtarga("icon.tga");
appicon = loadappicon();
if (appicon) if (!novideo)
SDL_WM_SetIcon(appicon, 0); {
appicon = loadappicon();
if (appicon)
SDL_WM_SetIcon(appicon, 0);
}
#endif #endif
if (SDL_VideoDriverName(drvname, 32)) if (!novideo)
initprintf("Using \"%s\" video driver\n", drvname); if (SDL_VideoDriverName(drvname, 32))
initprintf("Using \"%s\" video driver\n", drvname);
/* /*
// dump a quick summary of the graphics hardware // dump a quick summary of the graphics hardware
@ -384,8 +396,8 @@ void initprintf(const char *f, ...)
Bvsnprintf(buf, sizeof(buf), f, va); Bvsnprintf(buf, sizeof(buf), f, va);
va_end(va); va_end(va);
OSD_Printf(buf); OSD_Printf("%s", buf);
Bprintf("%s", buf); // Bprintf("%s", buf);
mutex_lock(&m_initprintf); mutex_lock(&m_initprintf);
if (Bstrlen(dabuf) + Bstrlen(buf) > 1022) if (Bstrlen(dabuf) + Bstrlen(buf) > 1022)
@ -495,7 +507,7 @@ int32_t initinput(void)
joyhat = (int32_t *)Bcalloc(joynumhats, sizeof(int32_t)); joyhat = (int32_t *)Bcalloc(joynumhats, sizeof(int32_t));
for (i = 0; i < joynumhats; i++) for (i = 0; i < joynumhats; i++)
joyhat[i] = -1; // centre joyhat[i] = -1; // centre
joydead = (uint16_t *)Bcalloc(joynumaxes, sizeof(uint16_t)); joydead = (uint16_t *)Bcalloc(joynumaxes, sizeof(uint16_t));
joysatur = (uint16_t *)Bcalloc(joynumaxes, sizeof(uint16_t)); joysatur = (uint16_t *)Bcalloc(joynumaxes, sizeof(uint16_t));
@ -793,7 +805,7 @@ void getvalidmodes(void)
#endif #endif
int32_t i, j, maxx=0, maxy=0; int32_t i, j, maxx=0, maxy=0;
if (modeschecked) return; if (modeschecked || novideo) return;
validmodecnt=0; validmodecnt=0;
// initprintf("Detecting video modes:\n"); // initprintf("Detecting video modes:\n");
@ -879,7 +891,7 @@ void getvalidmodes(void)
#undef CHECK #undef CHECK
#undef ADDMODE #undef ADDMODE
qsort((void*)validmode, validmodecnt, sizeof(struct validmode_t), (int32_t(*)(const void*,const void*))sortmodes); qsort((void *)validmode, validmodecnt, sizeof(struct validmode_t), (int32_t( *)(const void *,const void *))sortmodes);
modeschecked=1; modeschecked=1;
} }
@ -1131,28 +1143,33 @@ int32_t setvideomode(int32_t x, int32_t y, int32_t c, int32_t fs)
glinfo.extensions = (const char *)bglGetString(GL_EXTENSIONS); glinfo.extensions = (const char *)bglGetString(GL_EXTENSIONS);
#ifdef POLYMER #ifdef POLYMER
if (!Bstrcmp(glinfo.vendor,"ATI Technologies Inc.")) { if (!Bstrcmp(glinfo.vendor,"ATI Technologies Inc."))
{
pr_ati_fboworkaround = 1; pr_ati_fboworkaround = 1;
initprintf("Enabling ATI FBO color attachment workaround.\n"); initprintf("Enabling ATI FBO color attachment workaround.\n");
if (!Bstrncmp(glinfo.renderer,"Radeon X1", 9)) { if (Bstrstr(glinfo.renderer,"Radeon X1"))
{
pr_ati_nodepthoffset = 1; pr_ati_nodepthoffset = 1;
initprintf("Enabling ATI R520 polygon offset workaround.\n"); initprintf("Enabling ATI R520 polygon offset workaround.\n");
} else }
else
pr_ati_nodepthoffset = 0; pr_ati_nodepthoffset = 0;
#ifdef __APPLE__ #ifdef __APPLE__
//See bug description at http://lists.apple.com/archives/mac-opengl/2005/Oct/msg00169.html //See bug description at http://lists.apple.com/archives/mac-opengl/2005/Oct/msg00169.html
if (!Bstrncmp(glinfo.renderer,"ATI Radeon 9600", 15)) { if (!Bstrncmp(glinfo.renderer,"ATI Radeon 9600", 15))
{
pr_ati_textureformat_one = 1; pr_ati_textureformat_one = 1;
initprintf("Enabling ATI Radeon 9600 texture format workaround.\n"); initprintf("Enabling ATI Radeon 9600 texture format workaround.\n");
} else }
else
pr_ati_textureformat_one = 0; pr_ati_textureformat_one = 0;
#endif #endif
} else }
else
pr_ati_fboworkaround = 0; pr_ati_fboworkaround = 0;
#endif #endif
glinfo.maxanisotropy = 1.0; glinfo.maxanisotropy = 1.0;
glinfo.bgra = 0; glinfo.bgra = 0;
glinfo.texcompr = 0; glinfo.texcompr = 0;
@ -1160,7 +1177,7 @@ int32_t setvideomode(int32_t x, int32_t y, int32_t c, int32_t fs)
// process the extensions string and flag stuff we recognize // process the extensions string and flag stuff we recognize
p = Bstrdup(glinfo.extensions); p = Bstrdup(glinfo.extensions);
p3 = p; p3 = p;
while ((p2 = Bstrtoken(p3==p?p:NULL, " ", (char**)&p3, 1)) != NULL) while ((p2 = Bstrtoken(p3==p?p:NULL, " ", (char **)&p3, 1)) != NULL)
{ {
if (!Bstrcmp(p2, "GL_EXT_texture_filter_anisotropic")) if (!Bstrcmp(p2, "GL_EXT_texture_filter_anisotropic"))
{ {
@ -1487,6 +1504,8 @@ int32_t setgamma(void)
double invgamma = 1 / gamma; double invgamma = 1 / gamma;
double norm = pow(255., invgamma - 1); double norm = pow(255., invgamma - 1);
if (novideo) return 0;
// This formula is taken from Doomsday // This formula is taken from Doomsday
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
@ -1502,11 +1521,11 @@ int32_t setgamma(void)
#ifndef __APPLE__ #ifndef __APPLE__
extern struct sdlappicon sdlappicon; extern struct sdlappicon sdlappicon;
static SDL_Surface * loadappicon(void) static SDL_Surface *loadappicon(void)
{ {
SDL_Surface *surf; SDL_Surface *surf;
surf = SDL_CreateRGBSurfaceFrom((void*)sdlappicon.pixels, surf = SDL_CreateRGBSurfaceFrom((void *)sdlappicon.pixels,
sdlappicon.width, sdlappicon.height, 32, sdlappicon.width*4, sdlappicon.width, sdlappicon.height, 32, sdlappicon.width*4,
0xffl,0xff00l,0xff0000l,0xff000000l); 0xffl,0xff00l,0xff0000l,0xff000000l);
@ -1750,15 +1769,15 @@ int32_t handleevents(void)
{ {
joyaxis[ev.jaxis.axis] = ev.jaxis.value * 10000 / 32767; joyaxis[ev.jaxis.axis] = ev.jaxis.value * 10000 / 32767;
if ((joyaxis[ev.jaxis.axis] < joydead[ev.jaxis.axis]) if ((joyaxis[ev.jaxis.axis] < joydead[ev.jaxis.axis])
&& (joyaxis[ev.jaxis.axis] > -joydead[ev.jaxis.axis])) && (joyaxis[ev.jaxis.axis] > -joydead[ev.jaxis.axis]))
joyaxis[ev.jaxis.axis] = 0; joyaxis[ev.jaxis.axis] = 0;
else if (joyaxis[ev.jaxis.axis] >= joysatur[ev.jaxis.axis]) else if (joyaxis[ev.jaxis.axis] >= joysatur[ev.jaxis.axis])
joyaxis[ev.jaxis.axis] = 10000; joyaxis[ev.jaxis.axis] = 10000;
else if (joyaxis[ev.jaxis.axis] <= -joysatur[ev.jaxis.axis]) else if (joyaxis[ev.jaxis.axis] <= -joysatur[ev.jaxis.axis])
joyaxis[ev.jaxis.axis] = -10000; joyaxis[ev.jaxis.axis] = -10000;
else else
joyaxis[ev.jaxis.axis] = joyaxis[ev.jaxis.axis] * joyaxis[ev.jaxis.axis] = joyaxis[ev.jaxis.axis] *
10000 / joysatur[ev.jaxis.axis]; 10000 / joysatur[ev.jaxis.axis];
} }
break; break;
@ -1850,26 +1869,30 @@ inline void idle_waitevent(void)
#if (SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION < 3) // SDL 1.2 #if (SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION < 3) // SDL 1.2
// from SDL HG, modified // from SDL HG, modified
static int32_t SDL_WaitEventTimeout(SDL_Event * event, int32_t timeout) static int32_t SDL_WaitEventTimeout(SDL_Event *event, int32_t timeout)
{ {
uint32_t expiration = 0; uint32_t expiration = 0;
if (timeout > 0) if (timeout > 0)
expiration = SDL_GetTicks() + timeout; expiration = SDL_GetTicks() + timeout;
for (;;) { for (;;)
{
SDL_PumpEvents(); SDL_PumpEvents();
switch (SDL_PeepEvents(event, 1, SDL_GETEVENT, ~0)) { //SDL_FIRSTEVENT, SDL_LASTEVENT)) { switch (SDL_PeepEvents(event, 1, SDL_GETEVENT, ~0)) //SDL_FIRSTEVENT, SDL_LASTEVENT)) {
{
case -1: case -1:
return 0; return 0;
case 1: case 1:
return 1; return 1;
case 0: case 0:
if (timeout == 0) { if (timeout == 0)
{
/* Polling and no events, just return */ /* Polling and no events, just return */
return 0; return 0;
} }
if (timeout > 0 && ((int32_t) (SDL_GetTicks() - expiration) >= 0)) { if (timeout > 0 && ((int32_t)(SDL_GetTicks() - expiration) >= 0))
{
/* Timeout expired and no events */ /* Timeout expired and no events */
return 0; return 0;
} }

View file

@ -1,17 +1,18 @@
#if defined(LINKED_GTK) #if defined(LINKED_GTK)
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gdk-pixbuf/gdk-pixdata.h> #include <gdk-pixbuf/gdk-pixdata.h>
#else #else
#include "dynamicgtk.h" #include "dynamicgtk.h"
#endif #endif
#include "build.h" #include "build.h"
#include "editor.h" #include "editor.h"
#include "baselayer.h" #include "baselayer.h"
enum { enum
TAB_CONFIG, {
TAB_MESSAGES, TAB_CONFIG,
TAB_MESSAGES,
}; };
static struct static struct
@ -145,8 +146,8 @@ static void SetPage(int32_t n)
if (n == TAB_CONFIG) n = TRUE; else n = FALSE; if (n == TAB_CONFIG) n = TRUE; else n = FALSE;
gtk_widget_set_sensitive(stwidgets.startbutton, n); gtk_widget_set_sensitive(stwidgets.startbutton, n);
gtk_container_foreach(GTK_CONTAINER(stwidgets.configtlayout), gtk_container_foreach(GTK_CONTAINER(stwidgets.configtlayout),
(GtkCallback)gtk_widget_set_sensitive, (GtkCallback)gtk_widget_set_sensitive,
(gpointer)&n); (gpointer)&n);
} }
static void PopulateForm(void) static void PopulateForm(void)
@ -246,13 +247,13 @@ static GtkWidget *create_window(void)
gtk_container_set_border_width(GTK_CONTAINER(stwidgets.tabs), 4); gtk_container_set_border_width(GTK_CONTAINER(stwidgets.tabs), 4);
// layout table of config page // layout table of config page
stwidgets.configtlayout = gtk_table_new(4, 3, FALSE); stwidgets.configtlayout = gtk_table_new(4, 3, FALSE);
gtk_container_add(GTK_CONTAINER(stwidgets.tabs), stwidgets.configtlayout); gtk_container_add(GTK_CONTAINER(stwidgets.tabs), stwidgets.configtlayout);
// 2D video mode label // 2D video mode label
stwidgets.vmode2dlabel = gtk_label_new_with_mnemonic("_2D Video mode:"); stwidgets.vmode2dlabel = gtk_label_new_with_mnemonic("_2D Video mode:");
gtk_misc_set_alignment (GTK_MISC(stwidgets.vmode2dlabel), 0.3, 0); gtk_misc_set_alignment(GTK_MISC(stwidgets.vmode2dlabel), 0.3, 0);
gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode2dlabel, 0,1, 0,1, GTK_FILL, 0, 4, 6); gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode2dlabel, 0,1, 0,1, GTK_FILL, 0, 4, 6);
// 2D video mode combo // 2D video mode combo
{ {
@ -266,22 +267,22 @@ static GtkWidget *create_window(void)
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(stwidgets.vmode2dcombo), cell, FALSE); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(stwidgets.vmode2dcombo), cell, FALSE);
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(stwidgets.vmode2dcombo), cell, "text", 0, NULL); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(stwidgets.vmode2dcombo), cell, "text", 0, NULL);
} }
gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode2dcombo, 1,2, 0,1, GTK_EXPAND | GTK_FILL, 0, 4, 6); gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode2dcombo, 1,2, 0,1, GTK_EXPAND | GTK_FILL, 0, 4, 6);
gtk_widget_add_accelerator(stwidgets.vmode2dcombo, "grab_focus", stwidgets.accel_group, gtk_widget_add_accelerator(stwidgets.vmode2dcombo, "grab_focus", stwidgets.accel_group,
GDK_2, GDK_MOD1_MASK, GDK_2, GDK_MOD1_MASK,
GTK_ACCEL_VISIBLE); GTK_ACCEL_VISIBLE);
// Fullscreen checkbox // Fullscreen checkbox
stwidgets.fullscreencheck = gtk_check_button_new_with_mnemonic("_Fullscreen"); stwidgets.fullscreencheck = gtk_check_button_new_with_mnemonic("_Fullscreen");
gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.fullscreencheck, 2,3, 0,1, GTK_FILL, 0, 4, 6); gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.fullscreencheck, 2,3, 0,1, GTK_FILL, 0, 4, 6);
gtk_widget_add_accelerator(stwidgets.fullscreencheck, "grab_focus", stwidgets.accel_group, gtk_widget_add_accelerator(stwidgets.fullscreencheck, "grab_focus", stwidgets.accel_group,
GDK_F, GDK_MOD1_MASK, GDK_F, GDK_MOD1_MASK,
GTK_ACCEL_VISIBLE); GTK_ACCEL_VISIBLE);
// 3D video mode label // 3D video mode label
stwidgets.vmode3dlabel = gtk_label_new_with_mnemonic("_3D Video mode:"); stwidgets.vmode3dlabel = gtk_label_new_with_mnemonic("_3D Video mode:");
gtk_misc_set_alignment (GTK_MISC(stwidgets.vmode3dlabel), 0.3, 0); gtk_misc_set_alignment(GTK_MISC(stwidgets.vmode3dlabel), 0.3, 0);
gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode3dlabel, 0,1, 1,2, GTK_FILL, 0, 4, 6); gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode3dlabel, 0,1, 1,2, GTK_FILL, 0, 4, 6);
// 3D video mode combo // 3D video mode combo
{ {
@ -295,17 +296,17 @@ static GtkWidget *create_window(void)
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(stwidgets.vmode3dcombo), cell, FALSE); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(stwidgets.vmode3dcombo), cell, FALSE);
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(stwidgets.vmode3dcombo), cell, "text", 0, NULL); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(stwidgets.vmode3dcombo), cell, "text", 0, NULL);
} }
gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode3dcombo, 1,2, 1,2, GTK_EXPAND | GTK_FILL, 0, 4, 0); gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode3dcombo, 1,2, 1,2, GTK_EXPAND | GTK_FILL, 0, 4, 0);
gtk_widget_add_accelerator(stwidgets.vmode3dcombo, "grab_focus", stwidgets.accel_group, gtk_widget_add_accelerator(stwidgets.vmode3dcombo, "grab_focus", stwidgets.accel_group,
GDK_3, GDK_MOD1_MASK, GDK_3, GDK_MOD1_MASK,
GTK_ACCEL_VISIBLE); GTK_ACCEL_VISIBLE);
// Empty horizontal layout // Empty horizontal layout
stwidgets.emptyhlayout = gtk_hbox_new(TRUE, 0); stwidgets.emptyhlayout = gtk_hbox_new(TRUE, 0);
gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.emptyhlayout, 0,1, 2,3, 0, GTK_EXPAND | GTK_FILL, 0, 0); gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.emptyhlayout, 0,1, 2,3, 0, GTK_EXPAND | GTK_FILL, 0, 0);
// Always show config checkbox // Always show config checkbox
stwidgets.alwaysshowcheck = gtk_check_button_new_with_mnemonic("_Always show configuration on start"); stwidgets.alwaysshowcheck = gtk_check_button_new_with_mnemonic("_Always show configuration on start");
gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.alwaysshowcheck, 0,2, 3,4, GTK_FILL, 0, 4, 6); gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.alwaysshowcheck, 0,2, 3,4, GTK_FILL, 0, 4, 6);
gtk_widget_add_accelerator(stwidgets.alwaysshowcheck, "grab_focus", stwidgets.accel_group, gtk_widget_add_accelerator(stwidgets.alwaysshowcheck, "grab_focus", stwidgets.accel_group,
GDK_A, GDK_MOD1_MASK, GDK_A, GDK_MOD1_MASK,
GTK_ACCEL_VISIBLE); GTK_ACCEL_VISIBLE);

View file

@ -434,7 +434,7 @@ int32_t startwin_settitle(const char *str)
int32_t startwin_idle(void *v) int32_t startwin_idle(void *v)
{ {
if (!startupdlg || !IsWindow(startupdlg)) return 0; if (!startupdlg || !IsWindow(startupdlg)) return 0;
if (IsDialogMessage(startupdlg, (MSG*)v)) return 1; if (IsDialogMessage(startupdlg, (MSG *)v)) return 1;
return 0; return 0;
} }

View file

@ -69,8 +69,8 @@ char forcegl=0;
#endif #endif
static LPTSTR GetWindowsErrorMsg(DWORD code); static LPTSTR GetWindowsErrorMsg(DWORD code);
static const char * GetDDrawError(HRESULT code); static const char *GetDDrawError(HRESULT code);
static const char * GetDInputError(HRESULT code); static const char *GetDInputError(HRESULT code);
static void ShowErrorBox(const char *m); static void ShowErrorBox(const char *m);
static void ShowDDrawErrorBox(const char *m, HRESULT r); static void ShowDDrawErrorBox(const char *m, HRESULT r);
static void ShowDInputErrorBox(const char *m, HRESULT r); static void ShowDInputErrorBox(const char *m, HRESULT r);
@ -441,7 +441,7 @@ int32_t WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, in
} }
*wp = 0; *wp = 0;
_buildargv = (const char**)Bmalloc(sizeof(char*)*_buildargc); _buildargv = (const char **)Bmalloc(sizeof(char *)*_buildargc);
wp = argvbuf; wp = argvbuf;
for (i=0; i<_buildargc; i++,wp++) for (i=0; i<_buildargc; i++,wp++)
{ {
@ -586,7 +586,7 @@ static void win_printversion(void)
} }
initprintf("Windows %s (build %lu.%lu.%lu) %s", ver, initprintf("Windows %s (build %lu.%lu.%lu) %s", ver,
osv.dwMajorVersion, osv.dwMinorVersion, osv.dwBuildNumber, osv.szCSDVersion); osv.dwMajorVersion, osv.dwMinorVersion, osv.dwBuildNumber, osv.szCSDVersion);
#ifdef NEDMALLOC #ifdef NEDMALLOC
initprintf("\n"); initprintf("\n");
@ -754,7 +754,7 @@ int32_t handleevents(void)
continue; continue;
} }
if (startwin_idle((void*)&msg) > 0) continue; if (startwin_idle((void *)&msg) > 0) continue;
TranslateMessage(&msg); TranslateMessage(&msg);
DispatchMessage(&msg); DispatchMessage(&msg);
@ -1010,7 +1010,7 @@ static BOOL CALLBACK InitDirectInput_enum(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRe
static BOOL CALLBACK InitDirectInput_enumobjects(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef) static BOOL CALLBACK InitDirectInput_enumobjects(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef)
{ {
int32_t *typecounts = (int32_t*)pvRef; int32_t *typecounts = (int32_t *)pvRef;
if (lpddoi->dwType & DIDFT_AXIS) if (lpddoi->dwType & DIDFT_AXIS)
{ {
@ -1183,17 +1183,17 @@ static void UninitDirectInput(void)
if (axisdefs) if (axisdefs)
{ {
for (i=joynumaxes-1; i>=0; i--) if (axisdefs[i].name) Bfree((void*)axisdefs[i].name); for (i=joynumaxes-1; i>=0; i--) if (axisdefs[i].name) Bfree((void *)axisdefs[i].name);
Bfree(axisdefs); axisdefs = NULL; Bfree(axisdefs); axisdefs = NULL;
} }
if (buttondefs) if (buttondefs)
{ {
for (i=joynumbuttons-1; i>=0; i--) if (buttondefs[i].name) Bfree((void*)buttondefs[i].name); for (i=joynumbuttons-1; i>=0; i--) if (buttondefs[i].name) Bfree((void *)buttondefs[i].name);
Bfree(buttondefs); buttondefs = NULL; Bfree(buttondefs); buttondefs = NULL;
} }
if (hatdefs) if (hatdefs)
{ {
for (i=joynumhats-1; i>=0; i--) if (hatdefs[i].name) Bfree((void*)hatdefs[i].name); for (i=joynumhats-1; i>=0; i--) if (hatdefs[i].name) Bfree((void *)hatdefs[i].name);
Bfree(hatdefs); hatdefs = NULL; Bfree(hatdefs); hatdefs = NULL;
} }
@ -1396,7 +1396,7 @@ static void ShowDInputErrorBox(const char *m, HRESULT r)
// GetDInputError() -- stinking huge list of error messages since MS didn't want to include // GetDInputError() -- stinking huge list of error messages since MS didn't want to include
// them in the DLL // them in the DLL
// //
static const char * GetDInputError(HRESULT code) static const char *GetDInputError(HRESULT code)
{ {
switch (code) switch (code)
{ {
@ -1514,14 +1514,14 @@ int32_t inittimer(int32_t tickspersecond)
// OpenWatcom seems to want us to query the value into a local variable // OpenWatcom seems to want us to query the value into a local variable
// instead of the global 'timerfreq' or else it gets pissed with an // instead of the global 'timerfreq' or else it gets pissed with an
// access violation // access violation
if (!QueryPerformanceFrequency((LARGE_INTEGER*)&t)) if (!QueryPerformanceFrequency((LARGE_INTEGER *)&t))
{ {
ShowErrorBox("Failed fetching timer frequency"); ShowErrorBox("Failed fetching timer frequency");
return -1; return -1;
} }
timerfreq = t; timerfreq = t;
timerticspersec = tickspersecond; timerticspersec = tickspersecond;
QueryPerformanceCounter((LARGE_INTEGER*)&t); QueryPerformanceCounter((LARGE_INTEGER *)&t);
timerlastsample = (int32_t)(t*timerticspersec / timerfreq); timerlastsample = (int32_t)(t*timerticspersec / timerfreq);
usertimercallback = NULL; usertimercallback = NULL;
@ -1550,7 +1550,7 @@ inline void sampletimer(void)
if (!timerfreq) return; if (!timerfreq) return;
QueryPerformanceCounter((LARGE_INTEGER*)&i); QueryPerformanceCounter((LARGE_INTEGER *)&i);
n = (int32_t)((i*timerticspersec / timerfreq) - timerlastsample); n = (int32_t)((i*timerticspersec / timerfreq) - timerlastsample);
if (n <= 0) return; if (n <= 0) return;
@ -1569,7 +1569,7 @@ uint32_t getticks(void)
{ {
int64_t i; int64_t i;
if (timerfreq == 0) return 0; if (timerfreq == 0) return 0;
QueryPerformanceCounter((LARGE_INTEGER*)&i); QueryPerformanceCounter((LARGE_INTEGER *)&i);
return (uint32_t)(i*longlong(1000)/timerfreq); return (uint32_t)(i*longlong(1000)/timerfreq);
} }
@ -1594,7 +1594,7 @@ static HMODULE hDDrawDLL = NULL;
static LPDIRECTDRAW lpDD = NULL; static LPDIRECTDRAW lpDD = NULL;
static LPDIRECTDRAWSURFACE lpDDSPrimary = NULL; static LPDIRECTDRAWSURFACE lpDDSPrimary = NULL;
static LPDIRECTDRAWSURFACE lpDDSBack = NULL; static LPDIRECTDRAWSURFACE lpDDSBack = NULL;
static char * lpOffscreen = NULL; static char *lpOffscreen = NULL;
static LPDIRECTDRAWPALETTE lpDDPalette = NULL; static LPDIRECTDRAWPALETTE lpDDPalette = NULL;
static BOOL bDDrawInited = FALSE; static BOOL bDDrawInited = FALSE;
static DWORD DDdwCaps = 0, DDdwCaps2 = 0; static DWORD DDdwCaps = 0, DDdwCaps2 = 0;
@ -1909,7 +1909,7 @@ void getvalidmodes(void)
ADDMODE(defaultres[i][0],defaultres[i][1],cdepths[j],0,-1) ADDMODE(defaultres[i][0],defaultres[i][1],cdepths[j],0,-1)
} }
qsort((void*)validmode, validmodecnt, sizeof(struct validmode_t), (int32_t(*)(const void*,const void*))sortmodes); qsort((void *)validmode, validmodecnt, sizeof(struct validmode_t), (int32_t( *)(const void *,const void *))sortmodes);
modeschecked=1; modeschecked=1;
} }
@ -2889,7 +2889,7 @@ static int32_t SetupOpenGL(int32_t width, int32_t height, int32_t bitspp)
// process the extensions string and flag stuff we recognize // process the extensions string and flag stuff we recognize
p = (GLubyte *)Bstrdup(glinfo.extensions); p = (GLubyte *)Bstrdup(glinfo.extensions);
p3 = p; p3 = p;
while ((p2 = (GLubyte *)Bstrtoken(p3==p?(char *)p:NULL, " ", (char**)&p3, 1)) != NULL) while ((p2 = (GLubyte *)Bstrtoken(p3==p?(char *)p:NULL, " ", (char **)&p3, 1)) != NULL)
{ {
if (!Bstrcmp((char *)p2, "GL_EXT_texture_filter_anisotropic")) if (!Bstrcmp((char *)p2, "GL_EXT_texture_filter_anisotropic"))
{ {
@ -3285,7 +3285,7 @@ static void ShowDDrawErrorBox(const char *m, HRESULT r)
// GetDDrawError() -- stinking huge list of error messages since MS didn't want to include // GetDDrawError() -- stinking huge list of error messages since MS didn't want to include
// them in the DLL // them in the DLL
// //
static const char * GetDDrawError(HRESULT code) static const char *GetDDrawError(HRESULT code)
{ {
switch (code) switch (code)
{ {