diff --git a/polymer/eduke32/build/src/a-c.c b/polymer/eduke32/build/src/a-c.c index 7e37ed836..505088bf3 100644 --- a/polymer/eduke32/build/src/a-c.c +++ b/polymer/eduke32/build/src/a-c.c @@ -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) { - intptr_t* slopalptr; + intptr_t *slopalptr; int32_t bz, bzinc; uint32_t u, v; bz = asm3; bzinc = (asm1>>3); - slopalptr = (intptr_t*)slopaloffs; + slopalptr = (intptr_t *)slopaloffs; for (; cnt>0; cnt--) { i = krecip(bz>>6); bz += bzinc; diff --git a/polymer/eduke32/build/src/baselayer.c b/polymer/eduke32/build/src/baselayer.c index b0b95685e..fa258c1c0 100644 --- a/polymer/eduke32/build/src/baselayer.c +++ b/polymer/eduke32/build/src/baselayer.c @@ -51,7 +51,7 @@ void SetKey(int32_t key, int32_t state) { keystatus[remap[key]] = state; - if (state) + if (state) { keyfifo[keyfifoend] = remap[key]; keyfifo[(keyfifoend+1)&(KEYFIFOSIZ-1)] = state; @@ -279,22 +279,22 @@ static int32_t osdcmd_cvar_set_baselayer(const osdfuncparm_t *parm) if (r != OSDCMD_OK) return r; -/* - if (!Bstrcasecmp(parm->name, "r_scrcaptureformat")) - { - const char *fmts[] = {"TGA", "PCX"}; - if (showval) { OSD_Printf("r_scrcaptureformat is %s\n", fmts[captureformat]); } - else + /* + if (!Bstrcasecmp(parm->name, "r_scrcaptureformat")) { - 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; + const char *fmts[] = {"TGA", "PCX"}; + if (showval) { OSD_Printf("r_scrcaptureformat is %s\n", fmts[captureformat]); } + else + { + 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")) { @@ -313,17 +313,17 @@ int32_t baselayer_init(void) cvar_t cvars_engine[] = { #ifdef SUPERBUILD - { "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_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_scrcaptureformat","r_scrcaptureformat: sets the output format for screenshots (TGA or PCX)",osdcmd_vars, CVAR_FUNCPTR, 0, 0 },*/ - { "vid_gamma","vid_gamma : adjusts gamma ramp",(void *)&vid_gamma, CVAR_DOUBLE|CVAR_FUNCPTR, 0, 10 }, - { "vid_contrast","vid_contrast : adjusts gamma ramp",(void *)&vid_contrast, CVAR_DOUBLE|CVAR_FUNCPTR, 0, 10 }, - { "vid_brightness","vid_brightness : adjusts gamma ramp",(void *)&vid_brightness, CVAR_DOUBLE|CVAR_FUNCPTR, 0, 10 }, + { "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_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_scrcaptureformat","r_scrcaptureformat: sets the output format for screenshots (TGA or PCX)",osdcmd_vars, CVAR_FUNCPTR, 0, 0 },*/ + { "vid_gamma","vid_gamma : adjusts gamma ramp",(void *) &vid_gamma, CVAR_DOUBLE|CVAR_FUNCPTR, 0, 10 }, + { "vid_contrast","vid_contrast : adjusts gamma ramp",(void *) &vid_contrast, CVAR_DOUBLE|CVAR_FUNCPTR, 0, 10 }, + { "vid_brightness","vid_brightness : adjusts gamma ramp",(void *) &vid_brightness, CVAR_DOUBLE|CVAR_FUNCPTR, 0, 10 }, #endif - { "debug1","debug counter",(void *)&debug1, CVAR_FLOAT, -100000, 100000 }, - { "debug2","debug counter",(void *)&debug2, CVAR_FLOAT, -100000, 100000 }, + { "debug1","debug counter",(void *) &debug1, CVAR_FLOAT, -100000, 100000 }, + { "debug2","debug counter",(void *) &debug2, CVAR_FLOAT, -100000, 100000 }, }; for (i=0; i640?0:1); for (i=0; inumsectors>MAXSECTORS || numwalls+mapinfo->numwalls>MAXWALLS - || numsprites+mapinfo->numsprites>MAXSPRITES) + || numsprites+mapinfo->numsprites>MAXSPRITES) { mapinfofull_free(mapinfo); return -1; @@ -1735,9 +1735,9 @@ void overheadeditor(void) while ((keystatus[buildkeys[BK_MODE2D_3D]]>>1) == 0) { 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] - || keystatus[0x48] || keystatus[0x4b] || keystatus[0x4d] || keystatus[0x50] // keypad keys - || bstatus || OSD_IsMoving())) + || DOWN_BK(MOVEUP) || DOWN_BK(MOVEDOWN) || keystatus[0x10] || keystatus[0x11] + || keystatus[0x48] || keystatus[0x4b] || keystatus[0x4d] || keystatus[0x50] // keypad keys + || bstatus || OSD_IsMoving())) { if (totalclock > waitdelay) { @@ -1855,8 +1855,8 @@ void overheadeditor(void) if (numwalls < 0) numwalls = tempint; if ((getticks() - lastdraw) >= 5 || (vel|angvel|svel) || DOWN_BK(MOVEUP) || DOWN_BK(MOVEDOWN) - || mousx || mousy || bstatus || keystatus[0x10] || keystatus[0x11] - || newnumwalls>=0 || OSD_IsMoving()) + || mousx || mousy || bstatus || keystatus[0x10] || keystatus[0x11] + || newnumwalls>=0 || OSD_IsMoving()) { lastdraw = getticks(); @@ -2186,8 +2186,8 @@ void overheadeditor(void) if (gridlock && grid > 0) locktogrid(&dax, &day); - // dax = ((dax+(GRIDMAX>>grid))&(0xffffffff-(GRIDMAX>>(grid-1))+1)); - // day = ((day+(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)); for (i=0; i= highlightx1 && wall[i].x <= highlightx2 && - wall[i].y >= highlighty1 && wall[i].y <= highlighty2) + wall[i].y >= highlighty1 && wall[i].y <= highlighty2) { if (!sub) show2dwall[i>>3] |= (1<<(i&7)); @@ -2719,8 +2719,8 @@ void overheadeditor(void) for (i=0; i= highlightx1 && sprite[i].x <= highlightx2 && - sprite[i].y >= highlighty1 && sprite[i].y <= highlighty2) + sprite[i].x >= highlightx1 && sprite[i].x <= highlightx2 && + sprite[i].y >= highlighty1 && sprite[i].y <= highlighty2) { if (!sub) { @@ -2834,7 +2834,8 @@ void overheadeditor(void) // visitedwall[j>>3] |= (1<<(j&7)); n--; } - } while (j!=refwall && n>0); + } + while (j!=refwall && n>0); if (j!=refwall) { message("internal error while trying to trace outer loop: j!=refwall"); @@ -3051,7 +3052,7 @@ outtathis: for (i=0; i=0) 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= getceilzofslope(i,dax,day)) - if (sprite[daspr].z-daz <= getflorzofslope(i,dax,day)) - { - sprite[daspr].x = dax; - sprite[daspr].y = day; - if (sprite[daspr].sectnum != i) - changespritesect(daspr,(int16_t)i); - break; - } -*/ + for (i=0; i= getceilzofslope(i,dax,day)) + if (sprite[daspr].z-daz <= getflorzofslope(i,dax,day)) + { + sprite[daspr].x = dax; + sprite[daspr].y = day; + if (sprite[daspr].sectnum != i) + changespritesect(daspr,(int16_t)i); + break; + } + */ } } asksave = 1; @@ -3873,7 +3874,7 @@ SKIP: if ((split == 0) && (firstx == mousxplc) && (firsty == mousyplc) && (newnumwalls >= numwalls+3)) { if (suckwall == -1) //if no connections to other sectors - { /* No problem... */ } + { /* No problem... */ } else { if (newnumwalls>=MAXWALLS) // still too optimistic since we can have more than one new red wall @@ -4529,7 +4530,7 @@ SKIP: printmessage16("2D mode textures %s", (graphicsmode == 2)?"enabled w/ animation":graphicsmode?"enabled":"disabled"); } - + } if (keystatus[0xd3] && eitherCTRL && (numwalls >= 0)) //sector delete @@ -4595,7 +4596,7 @@ SKIP: } if (keystatus[0xd2] || keystatus[0x17]) //InsertPoint - { + { if (highlightsectorcnt >= 0) duplicate_selected_sectors(); else if (highlightcnt >= 0) @@ -5052,7 +5053,7 @@ CANCEL: } setbrightness(GAMMA_CALC,palette,0); - + pos.z = oposz; searchx = clamp(scale(searchx,xdimgame,xdim2d), 8, xdimgame-8-1); @@ -5863,7 +5864,7 @@ int32_t _getnumber256(const char *namestart, int32_t num, int32_t maxnumber, cha // defaultstr: can be NULL // NO overflow checks are done when copying them! // 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]; int32_t ei=0, qrylen=0; @@ -5936,7 +5937,7 @@ const char* getstring_simple(const char *querystr, const char *defaultstr, int32 buf[ei+1] = 0; } } - else + else { if (isalnum(ch) || ch==' ') buf[ei] = Btoupper(ch); @@ -6664,7 +6665,7 @@ static void copysector(int16_t soursector, int16_t destsector, int16_t deststart else if (highlightsector[i]==soursector) { message("internal error in copysector(): highlightsector[i]==soursector"); - goto nonextsector; + goto nonextsector; } wall[newnumwalls].nextwall = numwalls + m + (wall[j].nextwall-sector[k].wallptr); } @@ -6905,7 +6906,7 @@ int32_t snfillprintf(char *outbuf, size_t bufsiz, int32_t fill, const char *fmt, ofs = min(nwritten, (signed)bufsiz-1); Bmemset(outbuf, fill, bufsiz-ofs); - + return ofs; } #endif diff --git a/polymer/eduke32/build/src/cache1d.c b/polymer/eduke32/build/src/cache1d.c index f8d366942..7d68973dd 100644 --- a/polymer/eduke32/build/src/cache1d.c +++ b/polymer/eduke32/build/src/cache1d.c @@ -274,12 +274,12 @@ int32_t addsearchpath(const char *p) } 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; srch->next = searchpathhead; srch->pathlen = strlen(p)+1; - srch->path = (char*)Bmalloc(srch->pathlen + 1); + srch->path = (char *)Bmalloc(srch->pathlen + 1); if (!srch->path) { 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); if (!ffn) return -1; Bcorrectfilename(ffn,0); // compress relative paths @@ -415,7 +415,7 @@ int32_t openfrompath(const char *fn, int32_t flags, int32_t mode) return h; } -BFILE* fopenfrompath(const char *fn, const char *mode) +BFILE *fopenfrompath(const char *fn, const char *mode) { int32_t fh; 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); 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->source = source; r->usera = r->userb = NULL; diff --git a/polymer/eduke32/build/src/compat.c b/polymer/eduke32/build/src/compat.c index 1a6eed7b7..ed1123e8d 100644 --- a/polymer/eduke32/build/src/compat.c +++ b/polymer/eduke32/build/src/compat.c @@ -119,47 +119,47 @@ int32_t Blseek(int32_t fildes, int32_t offset, int32_t whence) BFILE *Bfopen(const char *path, const char *mode) { - return (BFILE*)fopen(path,mode); + return (BFILE *)fopen(path,mode); } int32_t Bfclose(BFILE *stream) { - return fclose((FILE*)stream); + return fclose((FILE *)stream); } void Brewind(BFILE *stream) { - rewind((FILE*)stream); + rewind((FILE *)stream); } int32_t Bfgetc(BFILE *stream) { - return fgetc((FILE*)stream); + return fgetc((FILE *)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) { - return fputc(c,(FILE*)stream); + return fputc(c,(FILE *)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) { - 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) { - 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); CFRelease(base); if (!str) return NULL; - s = (char*)CFStringGetCStringPtr(str,CFStringGetSystemEncoding()); + s = (char *)CFStringGetCStringPtr(str,CFStringGetSystemEncoding()); if (s) s = Bstrdup(s); CFRelease(str); return s; @@ -417,7 +417,7 @@ char *Bgetsupportdir(int32_t global) str = CFURLCopyFileSystemPath(base, kCFURLPOSIXPathStyle); CFRelease(base); if (!str) return NULL; - s = (char*)CFStringGetCStringPtr(str,CFStringGetSystemEncoding()); + s = (char *)CFStringGetCStringPtr(str,CFStringGetSystemEncoding()); if (s) s = Bstrdup(s); CFRelease(str); return s; @@ -585,16 +585,16 @@ typedef struct char name[1]; } BDIR_real; -BDIR* Bopendir(const char *name) +BDIR *Bopendir(const char *name) { BDIR_real *dirr; #ifdef _MSC_VER char *t,*tt; - t = (char*)Bmalloc(strlen(name)+1+4); + t = (char *)Bmalloc(strlen(name)+1+4); if (!t) return NULL; #endif - dirr = (BDIR_real*)Bmalloc(sizeof(BDIR_real) + strlen(name)); + dirr = (BDIR_real *)Bmalloc(sizeof(BDIR_real) + strlen(name)); if (!dirr) { #ifdef _MSC_VER @@ -632,12 +632,12 @@ BDIR* Bopendir(const char *name) dirr->status = 0; 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 stat st; char *fn; @@ -694,7 +694,7 @@ struct Bdirent* Breaddir(BDIR *dir) int32_t Bclosedir(BDIR *dir) { - BDIR_real *dirr = (BDIR_real*)dir; + BDIR_real *dirr = (BDIR_real *)dir; #ifdef _MSC_VER _findclose(dirr->dir); @@ -790,57 +790,57 @@ char *Bstrupr(char *s) // // Bgetsysmemsize() -- gets the amount of system memory in the machine // -uint32_t Bgetsysmemsize(void) -{ -#ifdef _WIN32 - uint32_t siz = UINT_MAX; - HMODULE lib = LoadLibrary("KERNEL32.DLL"); - - if (lib) - { - BOOL (WINAPI *aGlobalMemoryStatusEx)(LPMEMORYSTATUSEX) = - (void *)GetProcAddress(lib, "GlobalMemoryStatusEx"); - - if (aGlobalMemoryStatusEx) - { - //WinNT - MEMORYSTATUSEX memst; - memst.dwLength = sizeof(MEMORYSTATUSEX); - if (aGlobalMemoryStatusEx(&memst)) - siz = (uint32_t)min(UINT_MAX, memst.ullTotalPhys); - } - else - { - // Yeah, there's enough Win9x hatred here that a perfectly good workaround - // has been replaced by an error message. Oh well, we don't support 9x anyway. - initprintf("Bgetsysmemsize(): error determining system memory size!\n"); - } - - FreeLibrary(lib); - } - - return siz; -#elif (defined(_SC_PAGE_SIZE) || defined(_SC_PAGESIZE)) && defined(_SC_PHYS_PAGES) - uint32_t siz = UINT_MAX; - int64_t scpagesiz, scphyspages; - -#ifdef _SC_PAGE_SIZE - scpagesiz = sysconf(_SC_PAGE_SIZE); -#else - scpagesiz = sysconf(_SC_PAGESIZE); -#endif - scphyspages = sysconf(_SC_PHYS_PAGES); - if (scpagesiz >= 0 && scphyspages >= 0) - siz = (uint32_t)min(UINT_MAX, (int64_t)scpagesiz * (int64_t)scphyspages); - - //initprintf("Bgetsysmemsize(): %d pages of %d bytes, %d bytes of system memory\n", - // scphyspages, scpagesiz, siz); - - return siz; -#else - return UINT_MAX; -#endif -} +uint32_t Bgetsysmemsize(void) +{ +#ifdef _WIN32 + uint32_t siz = UINT_MAX; + HMODULE lib = LoadLibrary("KERNEL32.DLL"); + + if (lib) + { + BOOL (WINAPI *aGlobalMemoryStatusEx)(LPMEMORYSTATUSEX) = + (void *)GetProcAddress(lib, "GlobalMemoryStatusEx"); + + if (aGlobalMemoryStatusEx) + { + //WinNT + MEMORYSTATUSEX memst; + memst.dwLength = sizeof(MEMORYSTATUSEX); + if (aGlobalMemoryStatusEx(&memst)) + siz = (uint32_t)min(UINT_MAX, memst.ullTotalPhys); + } + else + { + // Yeah, there's enough Win9x hatred here that a perfectly good workaround + // has been replaced by an error message. Oh well, we don't support 9x anyway. + initprintf("Bgetsysmemsize(): error determining system memory size!\n"); + } + + FreeLibrary(lib); + } + + return siz; +#elif (defined(_SC_PAGE_SIZE) || defined(_SC_PAGESIZE)) && defined(_SC_PHYS_PAGES) + uint32_t siz = UINT_MAX; + int64_t scpagesiz, scphyspages; + +#ifdef _SC_PAGE_SIZE + scpagesiz = sysconf(_SC_PAGE_SIZE); +#else + scpagesiz = sysconf(_SC_PAGESIZE); +#endif + scphyspages = sysconf(_SC_PHYS_PAGES); + if (scpagesiz >= 0 && scphyspages >= 0) + siz = (uint32_t)min(UINT_MAX, (int64_t)scpagesiz * (int64_t)scphyspages); + + //initprintf("Bgetsysmemsize(): %d pages of %d bytes, %d bytes of system memory\n", + // scphyspages, scpagesiz, siz); + + return siz; +#else + return UINT_MAX; +#endif +} diff --git a/polymer/eduke32/build/src/defs.c b/polymer/eduke32/build/src/defs.c index 901f6471e..5cd9c4076 100644 --- a/polymer/eduke32/build/src/defs.c +++ b/polymer/eduke32/build/src/defs.c @@ -1467,7 +1467,7 @@ static int32_t defsparser(scriptfile *script) script->filename, scriptfile_getlinum(script,highpaltokptr)); break; } - + oldpathsearchmode = pathsearchmode; pathsearchmode = 1; if (findfrompath(fn,&tfn) < 0) @@ -1502,12 +1502,12 @@ static int32_t defsparser(scriptfile *script) klseek(fd, 0, SEEK_SET); 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); 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", 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); Bfree(filebuf); 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); diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 174d87c34..22d2b9a29 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -46,7 +46,7 @@ float debug1, debug2; -static void drawpixel_safe(void* s, char a) +static void drawpixel_safe(void *s, char a) { #if defined __GNUC__ if (__builtin_expect((intptr_t)s >= frameplace && (intptr_t)s < frameplace+bytesperline*ydim, 1)) @@ -58,15 +58,15 @@ static void drawpixel_safe(void* s, char a) else { static const char *const c = &editorcolors[15]; - drawpixel((intptr_t*)frameplace, *c); - drawpixel((intptr_t*)frameplace+1, *c); - drawpixel((intptr_t*)frameplace+2, *c); - drawpixel((intptr_t*)frameplace+bytesperline, *c); - drawpixel((intptr_t*)frameplace+bytesperline+1, *c); - drawpixel((intptr_t*)frameplace+bytesperline+2, *c); - drawpixel((intptr_t*)frameplace+2*bytesperline, *c); - drawpixel((intptr_t*)frameplace+2*bytesperline+1, *c); - drawpixel((intptr_t*)frameplace+2*bytesperline+2, *c); + drawpixel((intptr_t *)frameplace, *c); + drawpixel((intptr_t *)frameplace+1, *c); + drawpixel((intptr_t *)frameplace+2, *c); + drawpixel((intptr_t *)frameplace+bytesperline, *c); + drawpixel((intptr_t *)frameplace+bytesperline+1, *c); + drawpixel((intptr_t *)frameplace+bytesperline+2, *c); + drawpixel((intptr_t *)frameplace+2*bytesperline, *c); + drawpixel((intptr_t *)frameplace+2*bytesperline+1, *c); + drawpixel((intptr_t *)frameplace+2*bytesperline+2, *c); } #endif } @@ -295,7 +295,7 @@ int32_t clipmapinfo_load(const char *filename) int32_t i,k,w, px,py,pz; int16_t ang,cs; - char fn[BMAX_PATH], loadedwhich[32]={0}, *lwcp=loadedwhich; + char fn[BMAX_PATH], loadedwhich[32]= {0}, *lwcp=loadedwhich; int32_t slen, fi, fisec[10], fispr[10]; int32_t ournumsectors=0, ournumwalls=0, ournumsprites=0, numsprites; @@ -333,8 +333,8 @@ int32_t clipmapinfo_load(const char *filename) break; if (ournumsectors+numsectors>MAXSECTORS || - ournumwalls+numwalls>MAXWALLS || - ournumsprites+numsprites>MAXSPRITES) + ournumwalls+numwalls>MAXWALLS || + ournumsprites+numsprites>MAXSPRITES) { initprintf("clip map: warning: exceeded limits when loading %s, aborting.\n", fn); break; @@ -538,7 +538,8 @@ int32_t clipmapinfo_load(const char *filename) } } } - } while (++scnt < numclipsects); + } + while (++scnt < numclipsects); if (outersect==-1) { @@ -622,7 +623,7 @@ int32_t clipmapinfo_load(const char *filename) else { if (wall[w].hitag>4); + msethlineshift(picsiz[globalpicnum]&15,picsiz[globalpicnum]>>4); break; case 256: - settransnormal(); + settransnormal(); tsethlineshift(picsiz[globalpicnum]&15,picsiz[globalpicnum]>>4); break; case 384: - settransreverse(); + settransreverse(); tsethlineshift(picsiz[globalpicnum]&15,picsiz[globalpicnum]>>4); break; } @@ -2339,14 +2340,14 @@ static void florscan(int32_t x1, int32_t x2, int32_t sectnum) switch (globalorientation&0x180) { case 128: - msethlineshift(picsiz[globalpicnum]&15,picsiz[globalpicnum]>>4); + msethlineshift(picsiz[globalpicnum]&15,picsiz[globalpicnum]>>4); break; case 256: - settransnormal(); + settransnormal(); tsethlineshift(picsiz[globalpicnum]&15,picsiz[globalpicnum]>>4); break; case 384: - settransreverse(); + settransreverse(); tsethlineshift(picsiz[globalpicnum]&15,picsiz[globalpicnum]>>4); break; } @@ -3513,21 +3514,21 @@ static void drawvox(int32_t dasprx, int32_t daspry, int32_t dasprz, int32_t dasp switch (cnt) { case 0: - xs = 0; ys = 0; xi = 1; yi = 1; break; + xs = 0; ys = 0; xi = 1; yi = 1; break; case 1: - xs = daxsiz-1; ys = 0; xi = -1; yi = 1; break; + xs = daxsiz-1; ys = 0; xi = -1; yi = 1; break; case 2: - xs = 0; ys = daysiz-1; xi = 1; yi = -1; break; + xs = 0; ys = daysiz-1; xi = 1; yi = -1; break; case 3: - xs = daxsiz-1; ys = daysiz-1; xi = -1; yi = -1; break; + xs = daxsiz-1; ys = daysiz-1; xi = -1; yi = -1; break; case 4: - xs = 0; ys = cbacky; xi = 1; yi = 2; break; + xs = 0; ys = cbacky; xi = 1; yi = 2; break; case 5: - xs = daxsiz-1; ys = cbacky; xi = -1; yi = 2; break; + xs = daxsiz-1; ys = cbacky; xi = -1; yi = 2; break; case 6: - xs = cbackx; ys = 0; xi = 2; yi = 1; break; + xs = cbackx; ys = 0; xi = 2; yi = 1; break; case 7: - xs = cbackx; ys = daysiz-1; xi = 2; yi = -1; break; + xs = cbackx; ys = daysiz-1; xi = 2; yi = -1; break; } xe = cbackx; ye = cbacky; if (cnt < 4) @@ -3550,32 +3551,32 @@ static void drawvox(int32_t dasprx, int32_t daspry, int32_t dasprz, int32_t dasp switch (i) { case 6: - case 7: - x1 = 0; y1 = 0; break; + case 7: + x1 = 0; y1 = 0; break; case 8: - case 5: - x1 = gxinc; y1 = gyinc; break; + case 5: + x1 = gxinc; y1 = gyinc; break; case 0: - case 3: - x1 = gyinc; y1 = -gxinc; break; + case 3: + x1 = gyinc; y1 = -gxinc; break; case 2: - case 1: - x1 = gxinc+gyinc; y1 = gyinc-gxinc; break; + case 1: + x1 = gxinc+gyinc; y1 = gyinc-gxinc; break; } switch (i) { case 2: - case 5: - x2 = 0; y2 = 0; break; + case 5: + x2 = 0; y2 = 0; break; case 0: - case 1: - x2 = gxinc; y2 = gyinc; break; + case 1: + x2 = gxinc; y2 = gyinc; break; case 8: - case 7: - x2 = gyinc; y2 = -gxinc; break; + case 7: + x2 = gyinc; y2 = -gxinc; break; case 6: - case 3: - x2 = gxinc+gyinc; y2 = gyinc-gxinc; break; + case 3: + x2 = gxinc+gyinc; y2 = gyinc-gxinc; break; } oand = pow2char[(xs uwall[x]) uwall[x] = smost[k+x]; if ((dalx2 == lx) && (darx2 == rx)) daclip |= 1; break; case 2: - k = smoststart[i] - xb1[j]; + k = smoststart[i] - xb1[j]; for (x=dalx2; x<=darx2; x++) if (smost[k+x] < dwall[x]) dwall[x] = smost[k+x]; if ((dalx2 == lx) && (darx2 == rx)) daclip |= 2; @@ -4127,20 +4128,20 @@ static void drawsprite(int32_t snum) switch (smostwalltype[i]) { case 0: - if (dalx2 <= darx2) - { - if ((dalx2 == xb1[MAXWALLSB-1]) && (darx2 == xb2[MAXWALLSB-1])) return; - //clearbufbyte(&dwall[dalx2],(darx2-dalx2+1)*sizeof(dwall[0]),0L); - for (k=dalx2; k<=darx2; k++) dwall[k] = 0; - } + if (dalx2 <= darx2) + { + if ((dalx2 == xb1[MAXWALLSB-1]) && (darx2 == xb2[MAXWALLSB-1])) return; + //clearbufbyte(&dwall[dalx2],(darx2-dalx2+1)*sizeof(dwall[0]),0L); + for (k=dalx2; k<=darx2; k++) dwall[k] = 0; + } break; case 1: - k = smoststart[i] - xb1[j]; + k = smoststart[i] - xb1[j]; for (x=dalx2; x<=darx2; x++) if (smost[k+x] > uwall[x]) uwall[x] = smost[k+x]; break; case 2: - k = smoststart[i] - xb1[j]; + k = smoststart[i] - xb1[j]; for (x=dalx2; x<=darx2; x++) if (smost[k+x] < dwall[x]) dwall[x] = smost[k+x]; break; @@ -4412,20 +4413,20 @@ static void drawsprite(int32_t snum) switch (smostwalltype[i]) { case 0: - if (dalx2 <= darx2) - { - if ((dalx2 == lx) && (darx2 == rx)) return; - //clearbufbyte(&dwall[dalx2],(darx2-dalx2+1)*sizeof(dwall[0]),0L); - for (x=dalx2; x<=darx2; x++) dwall[x] = 0; - } + if (dalx2 <= darx2) + { + if ((dalx2 == lx) && (darx2 == rx)) return; + //clearbufbyte(&dwall[dalx2],(darx2-dalx2+1)*sizeof(dwall[0]),0L); + for (x=dalx2; x<=darx2; x++) dwall[x] = 0; + } break; case 1: - k = smoststart[i] - xb1[j]; + k = smoststart[i] - xb1[j]; for (x=dalx2; x<=darx2; x++) if (smost[k+x] > uwall[x]) uwall[x] = smost[k+x]; break; case 2: - k = smoststart[i] - xb1[j]; + k = smoststart[i] - xb1[j]; for (x=dalx2; x<=darx2; x++) if (smost[k+x] < dwall[x]) dwall[x] = smost[k+x]; break; @@ -4502,20 +4503,20 @@ static void drawsprite(int32_t snum) switch (smostwalltype[i]) { case 0: - if (dalx2 <= darx2) - { - if ((dalx2 == lx) && (darx2 == rx)) return; - //clearbufbyte(&swall[dalx2],(darx2-dalx2+1)*sizeof(swall[0]),0L); - for (x=dalx2; x<=darx2; x++) swall[x] = 0; - } + if (dalx2 <= darx2) + { + if ((dalx2 == lx) && (darx2 == rx)) return; + //clearbufbyte(&swall[dalx2],(darx2-dalx2+1)*sizeof(swall[0]),0L); + for (x=dalx2; x<=darx2; x++) swall[x] = 0; + } break; case 1: - k = smoststart[i] - xb1[j]; + k = smoststart[i] - xb1[j]; for (x=dalx2; x<=darx2; x++) if (smost[k+x] > lwall[x]) lwall[x] = smost[k+x]; break; case 2: - k = smoststart[i] - xb1[j]; + k = smoststart[i] - xb1[j]; for (x=dalx2; x<=darx2; x++) if (smost[k+x] < swall[x]) swall[x] = smost[k+x]; break; @@ -4691,20 +4692,20 @@ static void drawmaskwall(int16_t damaskwallcnt) switch (smostwalltype[i]) { case 0: - if (lx <= rx) - { - if ((lx == xb1[z]) && (rx == xb2[z])) return; - //clearbufbyte(&dwall[lx],(rx-lx+1)*sizeof(dwall[0]),0L); - for (x=lx; x<=rx; x++) dwall[x] = 0; - } + if (lx <= rx) + { + if ((lx == xb1[z]) && (rx == xb2[z])) return; + //clearbufbyte(&dwall[lx],(rx-lx+1)*sizeof(dwall[0]),0L); + for (x=lx; x<=rx; x++) dwall[x] = 0; + } break; case 1: - k = smoststart[i] - xb1[j]; + k = smoststart[i] - xb1[j]; for (x=lx; x<=rx; x++) if (smost[k+x] > uwall[x]) uwall[x] = smost[k+x]; break; case 2: - k = smoststart[i] - xb1[j]; + k = smoststart[i] - xb1[j]; for (x=lx; x<=rx; x++) if (smost[k+x] < dwall[x]) dwall[x] = smost[k+x]; break; @@ -5120,7 +5121,7 @@ static int32_t clippoly4(int32_t cx1, int32_t cy1, int32_t cx2, int32_t cy2) // //JBF 20031206: Thanks to Ken's hunting, s/(rx1|ry1|rx2|ry2)/n\1/ in this function static void dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum, int8_t dashade, - char dapalnum, int32_t dastat, int32_t cx1, int32_t cy1, int32_t cx2, int32_t cy2, int32_t uniqid) + char dapalnum, int32_t dastat, int32_t cx1, int32_t cy1, int32_t cx2, int32_t cy2, int32_t uniqid) { int32_t cosang, sinang, v, nextv, dax1, dax2, oy, bx, by; int32_t i, x, y, x1, y1, x2, y2, gx1, gy1 ; @@ -5517,13 +5518,13 @@ static void dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t switch (y1-oy) { case -1: - bx -= xv; by -= yv; oy = y1; break; + bx -= xv; by -= yv; oy = y1; break; case 0: - break; + break; case 1: - bx += xv; by += yv; oy = y1; break; + bx += xv; by += yv; oy = y1; break; default: - bx += xv*(y1-oy); by += yv*(y1-oy); oy = y1; break; + bx += xv*(y1-oy); by += yv*(y1-oy); oy = y1; break; } p = ylookup[y1]+x+frameplace; @@ -5572,13 +5573,13 @@ static void dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t switch (y1-oy) { case -1: - bx -= xv; by -= yv; oy = y1; break; + bx -= xv; by -= yv; oy = y1; break; case 0: - break; + break; case 1: - bx += xv; by += yv; oy = y1; break; + bx += xv; by += yv; oy = y1; break; default: - bx += xv*(y1-oy); by += yv*(y1-oy); oy = y1; break; + bx += xv*(y1-oy); by += yv*(y1-oy); oy = y1; break; } p = ylookup[y1]+x+frameplace; @@ -5772,9 +5773,9 @@ static void loadpalette(void) kread(fil,&numpalookups,2); numpalookups = B_LITTLE16(numpalookups); if ((palookup[0] = (char *)Bmalloc(numpalookups<<8)) == NULL) - allocache((intptr_t*)&palookup[0],numpalookups<<8,&permanentlock); + allocache((intptr_t *)&palookup[0],numpalookups<<8,&permanentlock); if ((transluc = (char *)Bmalloc(65536L)) == NULL) - allocache((intptr_t*)&transluc,65536,&permanentlock); + allocache((intptr_t *)&transluc,65536,&permanentlock); globalpalwritten = palookup[0]; globalpal = 0; setpalookupaddress(globalpalwritten); @@ -6105,31 +6106,31 @@ static void sighandler(int32_t sig, const siginfo_t *info, void *ctx) switch (sig) { case SIGFPE: - switch (info->si_code) - { - case FPE_INTDIV: - s = "FPE_INTDIV (integer divide by zero)"; break; - case FPE_INTOVF: - s = "FPE_INTOVF (integer overflow)"; break; - case FPE_FLTDIV: - s = "FPE_FLTDIV (floating-point divide by zero)"; break; - case FPE_FLTOVF: - s = "FPE_FLTOVF (floating-point overflow)"; break; - case FPE_FLTUND: - s = "FPE_FLTUND (floating-point underflow)"; break; - case FPE_FLTRES: - s = "FPE_FLTRES (floating-point inexact result)"; break; - case FPE_FLTINV: - s = "FPE_FLTINV (floating-point invalid operation)"; break; - case FPE_FLTSUB: - s = "FPE_FLTSUB (floating-point subscript out of range)"; break; - default: - s = "?! (unknown)"; break; - } + switch (info->si_code) + { + case FPE_INTDIV: + s = "FPE_INTDIV (integer divide by zero)"; break; + case FPE_INTOVF: + s = "FPE_INTOVF (integer overflow)"; break; + case FPE_FLTDIV: + s = "FPE_FLTDIV (floating-point divide by zero)"; break; + case FPE_FLTOVF: + s = "FPE_FLTOVF (floating-point overflow)"; break; + case FPE_FLTUND: + s = "FPE_FLTUND (floating-point underflow)"; break; + case FPE_FLTRES: + s = "FPE_FLTRES (floating-point inexact result)"; break; + case FPE_FLTINV: + s = "FPE_FLTINV (floating-point invalid operation)"; break; + case FPE_FLTSUB: + s = "FPE_FLTSUB (floating-point subscript out of range)"; break; + default: + s = "?! (unknown)"; break; + } fprintf(stderr, "Caught SIGFPE at address %p, code %s. Aborting.\n", info->si_addr, s); break; default: - break; + break; } abort(); } @@ -6173,25 +6174,25 @@ int32_t preinitengine(void) } dynarray[] = { - { (void **)§or, sizeof(sectortype) * MAXSECTORS }, - { (void **)&wall, sizeof(walltype) * (MAXWALLS+4) }, // +4: editor quirks - { (void **)&sprite, sizeof(spritetype) * MAXSPRITES }, - { (void **)&tsprite, sizeof(spritetype) * MAXSPRITESONSCREEN }, - { (void **)&spriteext, sizeof(spriteext_t) * (MAXSPRITES+MAXUNIQHUDID) }, - { (void **)&spritesmooth, sizeof(spritesmooth_t) * (MAXSPRITES+MAXUNIQHUDID) }, - { (void **)&state_compress, sizeof(qlz_state_compress) }, - { (void **)&state_decompress, sizeof(qlz_state_decompress) } + { (void **) §or, sizeof(sectortype) *MAXSECTORS }, + { (void **) &wall, sizeof(walltype) *(MAXWALLS+4) }, // +4: editor quirks + { (void **) &sprite, sizeof(spritetype) *MAXSPRITES }, + { (void **) &tsprite, sizeof(spritetype) *MAXSPRITESONSCREEN }, + { (void **) &spriteext, sizeof(spriteext_t) *(MAXSPRITES+MAXUNIQHUDID) }, + { (void **) &spritesmooth, sizeof(spritesmooth_t) *(MAXSPRITES+MAXUNIQHUDID) }, + { (void **) &state_compress, sizeof(qlz_state_compress) }, + { (void **) &state_decompress, sizeof(qlz_state_decompress) } }; - for (i=0;i<(signed)(sizeof(dynarray)/sizeof(dynarray[0])); i++) + for (i=0; i<(signed)(sizeof(dynarray)/sizeof(dynarray[0])); i++) size += dynarray[i].size; - + if ((blockptr = Bcalloc(1, size)) == NULL) return 1; size = 0; - for (i=0;i<(signed)(sizeof(dynarray)/sizeof(dynarray[0])); i++) + for (i=0; i<(signed)(sizeof(dynarray)/sizeof(dynarray[0])); i++) { *dynarray[i].ptr = (int8_t *)blockptr + size; size += dynarray[i].size; @@ -6206,7 +6207,7 @@ int32_t preinitengine(void) spriteext = spriteext_s; spritesmooth = spritesmooth_s; state_compress = (qlz_state_compress *) Bmalloc(sizeof(qlz_state_compress) + sizeof(qlz_state_decompress)); - state_decompress = (qlz_state_decompress *) ((int8_t *)(state_compress) + sizeof(qlz_state_compress)); + state_decompress = (qlz_state_decompress *)((int8_t *)(state_compress) + sizeof(qlz_state_compress)); #endif if ((e = Bgetenv("BUILD_NOP6")) != NULL) @@ -6332,7 +6333,7 @@ void uninitengine(void) i=(sizeof(artptrs)/sizeof(intptr_t))-1; // this leaves a bunch of invalid pointers in waloff... fixme? - for(; i>=0; i--) + for (; i>=0; i--) { if (artptrs[i]) { @@ -6682,7 +6683,7 @@ static inline void drawmaskleaf(_maskleaf* wall) } */ -static inline int32_t sameside(_equation* eq, _point2d* p1, _point2d* p2) +static inline int32_t sameside(_equation *eq, _point2d *p1, _point2d *p2) { float sign1, sign2; @@ -6731,7 +6732,7 @@ void drawmasks(void) } else if ((tspriteptr[i]->cstat&48) == 0) { -killsprite: + killsprite: spritesortcnt--; //Delete face sprite if on wrong side! if (i == spritesortcnt) continue; tspriteptr[i] = tspriteptr[spritesortcnt]; @@ -7319,47 +7320,47 @@ int32_t loadboard(char *filename, char flags, int32_t *daposx, int32_t *daposy, for (i=0; i= 0; ii--) - { - for (jj=32; jj >= 0; jj--) + if (sect == -1) { - updatesector(sprite[k].x+ii-16, sprite[k].y+jj-16, §); - if (sect != -1) break; + int32_t ii, jj; + + for (ii=32; ii >= 0; ii--) + { + for (jj=32; jj >= 0; jj--) + { + updatesector(sprite[k].x+ii-16, sprite[k].y+jj-16, §); + if (sect != -1) break; + } + if (sect != -1) break; + } + + / * fuck it, the sprite is clearly not legitimately in any sector at this point + so let's queue it up for deletion * / + if (sect == -1) + dq[dnum++] = k; } - if (sect != -1) break; - } + */ + } - / * fuck it, the sprite is clearly not legitimately in any sector at this point - so let's queue it up for deletion * / - if (sect == -1) - dq[dnum++] = k; + /* + while (dnum--) + { + initprintf(OSD_ERROR "Map error: removing sprite #%d(%d,%d) in null space. Map is corrupt!\n",dq[dnum],sprite[dq[dnum]].x,sprite[dq[dnum]].y); + deletesprite(dq[dnum]); } -*/ - } - -/* - while (dnum--) - { - initprintf(OSD_ERROR "Map error: removing sprite #%d(%d,%d) in null space. Map is corrupt!\n",dq[dnum],sprite[dq[dnum]].x,sprite[dq[dnum]].y); - deletesprite(dq[dnum]); - } -*/ + */ //Must be after loading sectors, etc! updatesector(*daposx,*daposy,dacursectnum); @@ -7693,7 +7694,7 @@ int32_t loadoldboard(char *filename, char fromwhere, int32_t *daposx, int32_t *d switch (mapversion) { case 5: - kread(fil,&v5sect,sizeof(struct sectortypev5)); + kread(fil,&v5sect,sizeof(struct sectortypev5)); v5sect.wallptr = B_LITTLE16(v5sect.wallptr); v5sect.wallnum = B_LITTLE16(v5sect.wallnum); v5sect.ceilingpicnum = B_LITTLE16(v5sect.ceilingpicnum); @@ -7707,7 +7708,7 @@ int32_t loadoldboard(char *filename, char fromwhere, int32_t *daposx, int32_t *d v5sect.extra = B_LITTLE16(v5sect.extra); break; case 6: - kread(fil,&v6sect,sizeof(struct sectortypev6)); + kread(fil,&v6sect,sizeof(struct sectortypev6)); v6sect.wallptr = B_LITTLE16(v6sect.wallptr); v6sect.wallnum = B_LITTLE16(v6sect.wallnum); v6sect.ceilingpicnum = B_LITTLE16(v6sect.ceilingpicnum); @@ -7724,9 +7725,9 @@ int32_t loadoldboard(char *filename, char fromwhere, int32_t *daposx, int32_t *d switch (mapversion) { case 5: - convertv5sectv6(&v5sect,&v6sect); + convertv5sectv6(&v5sect,&v6sect); case 6: - convertv6sectv7(&v6sect,§or[i]); + convertv6sectv7(&v6sect,§or[i]); } } @@ -7737,7 +7738,7 @@ int32_t loadoldboard(char *filename, char fromwhere, int32_t *daposx, int32_t *d switch (mapversion) { case 5: - kread(fil,&v5wall,sizeof(struct walltypev5)); + kread(fil,&v5wall,sizeof(struct walltypev5)); v5wall.x = B_LITTLE32(v5wall.x); v5wall.y = B_LITTLE32(v5wall.y); v5wall.point2 = B_LITTLE16(v5wall.point2); @@ -7753,7 +7754,7 @@ int32_t loadoldboard(char *filename, char fromwhere, int32_t *daposx, int32_t *d v5wall.extra = B_LITTLE16(v5wall.extra); break; case 6: - kread(fil,&v6wall,sizeof(struct walltypev6)); + kread(fil,&v6wall,sizeof(struct walltypev6)); v6wall.x = B_LITTLE32(v6wall.x); v6wall.y = B_LITTLE32(v6wall.y); v6wall.point2 = B_LITTLE16(v6wall.point2); @@ -7770,9 +7771,9 @@ int32_t loadoldboard(char *filename, char fromwhere, int32_t *daposx, int32_t *d switch (mapversion) { case 5: - convertv5wallv6(&v5wall,&v6wall,i); + convertv5wallv6(&v5wall,&v6wall,i); case 6: - convertv6wallv7(&v6wall,&wall[i]); + convertv6wallv7(&v6wall,&wall[i]); } } @@ -7783,7 +7784,7 @@ int32_t loadoldboard(char *filename, char fromwhere, int32_t *daposx, int32_t *d switch (mapversion) { case 5: - kread(fil,&v5spr,sizeof(struct spritetypev5)); + kread(fil,&v5spr,sizeof(struct spritetypev5)); v5spr.x = B_LITTLE32(v5spr.x); v5spr.y = B_LITTLE32(v5spr.y); v5spr.z = B_LITTLE32(v5spr.z); @@ -7800,7 +7801,7 @@ int32_t loadoldboard(char *filename, char fromwhere, int32_t *daposx, int32_t *d v5spr.extra = B_LITTLE16(v5spr.extra); break; case 6: - kread(fil,&v6spr,sizeof(struct spritetypev6)); + kread(fil,&v6spr,sizeof(struct spritetypev6)); v6spr.x = B_LITTLE32(v6spr.x); v6spr.y = B_LITTLE32(v6spr.y); v6spr.z = B_LITTLE32(v6spr.z); @@ -7821,9 +7822,9 @@ int32_t loadoldboard(char *filename, char fromwhere, int32_t *daposx, int32_t *d switch (mapversion) { case 5: - convertv5sprv6(&v5spr,&v6spr); + convertv5sprv6(&v5spr,&v6spr); case 6: - convertv6sprv7(&v6spr,&sprite[i]); + convertv6sprv7(&v6spr,&sprite[i]); } } @@ -7947,7 +7948,7 @@ int32_t loadmaphack(const char *filename) switch (legaltokens[i].tokenid) { case T_SPRITE: // sprite - if (scriptfile_getnumber(script, &whichsprite)) break; + if (scriptfile_getnumber(script, &whichsprite)) break; if ((unsigned)whichsprite >= (unsigned)MAXSPRITES) { @@ -7960,190 +7961,190 @@ int32_t loadmaphack(const char *filename) break; case T_ANGOFF: // angoff - { - int32_t ang; - if (scriptfile_getnumber(script, &ang)) break; + { + int32_t ang; + if (scriptfile_getnumber(script, &ang)) break; - if (whichsprite < 0) + if (whichsprite < 0) { // no sprite directive preceeding initprintf("Ignoring angle offset directive because of absent/invalid sprite number on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); - break; - } - spriteext[whichsprite].angoff = (int16_t)ang; + break; + } + spriteext[whichsprite].angoff = (int16_t)ang; } break; case T_NOMODEL: // notmd - if (whichsprite < 0) - { - // no sprite directive preceeding - initprintf("Ignoring not-MD2/MD3 directive because of absent/invalid sprite number on line %s:%d\n", - script->filename, scriptfile_getlinum(script,cmdtokptr)); - break; - } + if (whichsprite < 0) + { + // no sprite directive preceeding + initprintf("Ignoring not-MD2/MD3 directive because of absent/invalid sprite number on line %s:%d\n", + script->filename, scriptfile_getlinum(script,cmdtokptr)); + break; + } spriteext[whichsprite].flags |= SPREXT_NOTMD; break; case T_NOANIM: // nomdanim - if (whichsprite < 0) - { - // no sprite directive preceeding - initprintf("Ignoring no-MD2/MD3-anim directive because of absent/invalid sprite number on line %s:%d\n", - script->filename, scriptfile_getlinum(script,cmdtokptr)); - break; - } + if (whichsprite < 0) + { + // no sprite directive preceeding + initprintf("Ignoring no-MD2/MD3-anim directive because of absent/invalid sprite number on line %s:%d\n", + script->filename, scriptfile_getlinum(script,cmdtokptr)); + break; + } spriteext[whichsprite].flags |= SPREXT_NOMDANIM; break; case T_PITCH: // pitch - { - int32_t pitch; - if (scriptfile_getnumber(script, &pitch)) break; + { + int32_t pitch; + if (scriptfile_getnumber(script, &pitch)) break; - if (whichsprite < 0) + if (whichsprite < 0) { // no sprite directive preceeding initprintf("Ignoring pitch directive because of absent/invalid sprite number on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); - break; - } - spriteext[whichsprite].pitch = (int16_t)pitch; + break; + } + spriteext[whichsprite].pitch = (int16_t)pitch; } break; case T_ROLL: // roll - { - int32_t roll; - if (scriptfile_getnumber(script, &roll)) break; + { + int32_t roll; + if (scriptfile_getnumber(script, &roll)) break; - if (whichsprite < 0) + if (whichsprite < 0) { // no sprite directive preceeding initprintf("Ignoring roll directive because of absent/invalid sprite number on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); - break; - } - spriteext[whichsprite].roll = (int16_t)roll; + break; + } + spriteext[whichsprite].roll = (int16_t)roll; } break; case T_MDXOFF: // mdxoff - { - int32_t i; - if (scriptfile_getnumber(script, &i)) break; + { + int32_t i; + if (scriptfile_getnumber(script, &i)) break; - if (whichsprite < 0) + if (whichsprite < 0) { // no sprite directive preceeding initprintf("Ignoring mdxoff directive because of absent/invalid sprite number on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); - break; - } - spriteext[whichsprite].xoff = i; + break; + } + spriteext[whichsprite].xoff = i; } break; case T_MDYOFF: // mdyoff - { - int32_t i; - if (scriptfile_getnumber(script, &i)) break; + { + int32_t i; + if (scriptfile_getnumber(script, &i)) break; - if (whichsprite < 0) + if (whichsprite < 0) { // no sprite directive preceeding initprintf("Ignoring mdyoff directive because of absent/invalid sprite number on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); - break; - } - spriteext[whichsprite].yoff = i; + break; + } + spriteext[whichsprite].yoff = i; } break; case T_MDZOFF: // mdzoff - { - int32_t i; - if (scriptfile_getnumber(script, &i)) break; + { + int32_t i; + if (scriptfile_getnumber(script, &i)) break; - if (whichsprite < 0) + if (whichsprite < 0) { // no sprite directive preceeding initprintf("Ignoring mdzoff directive because of absent/invalid sprite number on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); - break; - } - spriteext[whichsprite].zoff = i; + break; + } + spriteext[whichsprite].zoff = i; } break; case T_AWAY1: // away1 - if (whichsprite < 0) - { - // no sprite directive preceeding - initprintf("Ignoring moving away directive because of absent/invalid sprite number on line %s:%d\n", - script->filename, scriptfile_getlinum(script,cmdtokptr)); - break; - } + if (whichsprite < 0) + { + // no sprite directive preceeding + initprintf("Ignoring moving away directive because of absent/invalid sprite number on line %s:%d\n", + script->filename, scriptfile_getlinum(script,cmdtokptr)); + break; + } spriteext[whichsprite].flags |= SPREXT_AWAY1; break; case T_AWAY2: // away2 - if (whichsprite < 0) - { - // no sprite directive preceeding - initprintf("Ignoring moving away directive because of absent/invalid sprite number on line %s:%d\n", - script->filename, scriptfile_getlinum(script,cmdtokptr)); - break; - } + if (whichsprite < 0) + { + // no sprite directive preceeding + initprintf("Ignoring moving away directive because of absent/invalid sprite number on line %s:%d\n", + script->filename, scriptfile_getlinum(script,cmdtokptr)); + break; + } spriteext[whichsprite].flags |= SPREXT_AWAY2; break; #ifdef POLYMER case T_LIGHT: // light sector x y z range r g b radius faderadius angle horiz minshade maxshade priority tilenum - { - int32_t value; - int16_t lightid; -#pragma pack(push,1) - _prlight light; -#pragma pack(pop) - scriptfile_getnumber(script, &value); - light.sector = value; - scriptfile_getnumber(script, &value); - light.x = value; - scriptfile_getnumber(script, &value); - light.y = value; - scriptfile_getnumber(script, &value); - light.z = value; - scriptfile_getnumber(script, &value); - light.range = value; - scriptfile_getnumber(script, &value); - light.color[0] = value; - scriptfile_getnumber(script, &value); - light.color[1] = value; - scriptfile_getnumber(script, &value); - light.color[2] = value; - scriptfile_getnumber(script, &value); - light.radius = value; - scriptfile_getnumber(script, &value); - light.faderadius = value; - scriptfile_getnumber(script, &value); - light.angle = value; - scriptfile_getnumber(script, &value); - light.horiz = value; - scriptfile_getnumber(script, &value); - light.minshade = value; - scriptfile_getnumber(script, &value); - light.maxshade = value; - scriptfile_getnumber(script, &value); - light.priority = value; - scriptfile_getnumber(script, &value); - light.tilenum = value; - - if (rendmode == 4) { - lightid = polymer_addlight(&light); + int32_t value; + int16_t lightid; +#pragma pack(push,1) + _prlight light; +#pragma pack(pop) + scriptfile_getnumber(script, &value); + light.sector = value; + scriptfile_getnumber(script, &value); + light.x = value; + scriptfile_getnumber(script, &value); + light.y = value; + scriptfile_getnumber(script, &value); + light.z = value; + scriptfile_getnumber(script, &value); + light.range = value; + scriptfile_getnumber(script, &value); + light.color[0] = value; + scriptfile_getnumber(script, &value); + light.color[1] = value; + scriptfile_getnumber(script, &value); + light.color[2] = value; + scriptfile_getnumber(script, &value); + light.radius = value; + scriptfile_getnumber(script, &value); + light.faderadius = value; + scriptfile_getnumber(script, &value); + light.angle = value; + scriptfile_getnumber(script, &value); + light.horiz = value; + scriptfile_getnumber(script, &value); + light.minshade = value; + scriptfile_getnumber(script, &value); + light.maxshade = value; + scriptfile_getnumber(script, &value); + light.priority = value; + scriptfile_getnumber(script, &value); + light.tilenum = value; + + if (rendmode == 4) + { + lightid = polymer_addlight(&light); if (lightid>=0) maphacklight[maphacklightcnt++] = lightid; } - break; + break; } #endif // POLYMER default: - // unrecognised token - break; + // unrecognised token + break; } } @@ -8346,11 +8347,11 @@ int32_t setgamemode(char davidoption, int32_t daxdim, int32_t daydim, int32_t da #endif if ((qsetmode == 200) && (videomodereset == 0) && (davidoption == fullscreen) && (xdim == daxdim) && (ydim == daydim) && (bpp == dabpp) -/* -#ifdef POLYMER - && glrendmode != 4 -#endif // POLYMER -*/ + /* + #ifdef POLYMER + && glrendmode != 4 + #endif // POLYMER + */ ) return(0); @@ -8365,7 +8366,7 @@ int32_t setgamemode(char davidoption, int32_t daxdim, int32_t daydim, int32_t da j = bpp; if (setvideomode(daxdim,daydim,dabpp,davidoption) < 0) return(-1); - + // Workaround possible bugs in the GL driver makeasmwriteable(); @@ -8451,7 +8452,7 @@ void nextpage(void) switch (qsetmode) { case 200: - begindrawing(); //{{{ + begindrawing(); //{{{ for (i=permtail; i!=permhead; i=((i+1)&(MAXPERMS-1))) { per = &permfifo[i]; @@ -8460,7 +8461,7 @@ void nextpage(void) per->dashade,per->dapalnum,per->dastat, per->cx1,per->cy1,per->cx2,per->cy2,per->uniqid); } - enddrawing(); //}}} + enddrawing(); //}}} OSD_Draw(); showframe(0); @@ -8482,8 +8483,8 @@ void nextpage(void) break; case 350: - case 480: - break; + case 480: + break; } faketimerhandler(); @@ -9116,7 +9117,7 @@ static int32_t hitscan_trysector(const vec3_t *sv, const sectortype *sec, hitdat } } } - else if ((how*vz > 0) && (how*sv->z <= how*z)) + else if ((how*vz > 0) && (how *sv->z <= how*z)) { z1 = z; i = z1-sv->z; if ((klabs(i)>>1) < vz*how) @@ -9149,7 +9150,7 @@ static int32_t hitscan_trysector(const vec3_t *sv, const sectortype *sec, hitdat { hitinfo->hitsect = curspr->sectnum; hitinfo->hitwall = -1; hitinfo->hitsprite = curspr-sprite; hitinfo->pos.x = x1; hitinfo->pos.y = y1; hitinfo->pos.z = z1; - } + } } else { @@ -9341,7 +9342,7 @@ int32_t hitscan(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int32 switch (cstat&48) { case 0: - topt = vx*(x1-sv->x) + vy*(y1-sv->y); if (topt <= 0) continue; + topt = vx*(x1-sv->x) + vy*(y1-sv->y); if (topt <= 0) continue; bot = vx*vx + vy*vy; if (bot == 0) continue; intz = sv->z+scale(vz,topt,bot); @@ -9366,9 +9367,9 @@ int32_t hitscan(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int32 hitinfo->pos.x = intx; hitinfo->pos.y = inty; hitinfo->pos.z = intz; break; case 16: - //These lines get the 2 points of the rotated sprite - //Given: (x1, y1) starts out as the center point - tilenum = spr->picnum; + //These lines get the 2 points of the rotated sprite + //Given: (x1, y1) starts out as the center point + tilenum = spr->picnum; xoff = (int32_t)((int8_t)((picanm[tilenum]>>8)&255))+((int32_t)spr->xoffset); if ((cstat&4) > 0) xoff = -xoff; k = spr->ang; l = spr->xrepeat; @@ -9394,7 +9395,7 @@ int32_t hitscan(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int32 } break; case 32: - if (vz == 0) continue; + if (vz == 0) continue; intz = z1; if (((intz-sv->z)^vz) < 0) continue; if ((cstat&64) != 0) @@ -9804,7 +9805,7 @@ static int32_t clipsprite_initindex(int32_t curidx, spritetype *curspr, int32_t clipnum++; \ } else if (!warned) { initprintf("!!clipnum\n"); warned=1; } \ } \ - + int32_t clipmoveboxtracenum = 3; // @@ -9931,8 +9932,8 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum, sec2 = §or[wal->nextsector]; if ((sec2->floorstat&1) == 0) // if (dasect==sectq[clipinfo[curidx].qend] || daz2 < daz-(1<<8)) - if (daz2-(flordist-1) <= vect->z && vect->z <= basez+(flordist-1)) - clipyou = 1; + if (daz2-(flordist-1) <= vect->z && vect->z <= basez+(flordist-1)) + clipyou = 1; if (clipyou == 0) { daz = getceilzofslope((int16_t)dasect,dax,day); @@ -10012,22 +10013,22 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum, switch (cstat&48) { case 0: - if ((x1 >= xmin) && (x1 <= xmax) && (y1 >= ymin) && (y1 <= ymax)) - { - k = ((tilesizy[spr->picnum]*spr->yrepeat)<<2); - if (cstat&128) daz = spr->z+(k>>1); else daz = spr->z; - if (picanm[spr->picnum]&0x00ff0000) daz -= ((int32_t)((int8_t)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); - if (((vect->z) < daz+ceildist) && ((vect->z) > daz-k-flordist)) + if ((x1 >= xmin) && (x1 <= xmax) && (y1 >= ymin) && (y1 <= ymax)) { - bsz = (spr->clipdist<<2)+walldist; if (gx < 0) bsz = -bsz; - addclipline(x1-bsz,y1-bsz,x1-bsz,y1+bsz,(int16_t)j+49152); - bsz = (spr->clipdist<<2)+walldist; if (gy < 0) bsz = -bsz; - addclipline(x1+bsz,y1-bsz,x1-bsz,y1-bsz,(int16_t)j+49152); + k = ((tilesizy[spr->picnum]*spr->yrepeat)<<2); + if (cstat&128) daz = spr->z+(k>>1); else daz = spr->z; + if (picanm[spr->picnum]&0x00ff0000) daz -= ((int32_t)((int8_t)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); + if (((vect->z) < daz+ceildist) && ((vect->z) > daz-k-flordist)) + { + bsz = (spr->clipdist<<2)+walldist; if (gx < 0) bsz = -bsz; + addclipline(x1-bsz,y1-bsz,x1-bsz,y1+bsz,(int16_t)j+49152); + bsz = (spr->clipdist<<2)+walldist; if (gy < 0) bsz = -bsz; + addclipline(x1+bsz,y1-bsz,x1-bsz,y1-bsz,(int16_t)j+49152); + } } - } break; case 16: - k = ((tilesizy[spr->picnum]*spr->yrepeat)<<2); + k = ((tilesizy[spr->picnum]*spr->yrepeat)<<2); if (cstat&128) daz = spr->z+(k>>1); else daz = spr->z; if (picanm[spr->picnum]&0x00ff0000) daz -= ((int32_t)((int8_t)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); daz2 = daz-k; @@ -10068,7 +10069,7 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum, } break; case 32: - daz = spr->z+ceildist; + daz = spr->z+ceildist; daz2 = spr->z-flordist; if (((vect->z) < daz) && ((vect->z) > daz2)) { @@ -10625,7 +10626,7 @@ void getzrange(const vec3_t *vect, int16_t sectnum, if (0) { -beginagain: + beginagain: // replace sector and wall with clip map mapinfo_set(&origmapinfo, &clipmapinfo); clipsectcnt = clipsectnum; // should be a nop, "safety"... @@ -10779,7 +10780,7 @@ beginagain: switch (cstat&48) { case 0: - k = walldist+(spr->clipdist<<2)+1; + k = walldist+(spr->clipdist<<2)+1; if ((klabs(x1-vect->x) <= k) && (klabs(y1-vect->y) <= k)) { daz = spr->z; @@ -10791,7 +10792,7 @@ beginagain: } break; case 16: - tilenum = spr->picnum; + tilenum = spr->picnum; xoff = (int32_t)((int8_t)((picanm[tilenum]>>8)&255))+((int32_t)spr->xoffset); if ((cstat&4) > 0) xoff = -xoff; k = spr->ang; l = spr->xrepeat; @@ -10809,7 +10810,7 @@ beginagain: } break; case 32: - daz = spr->z; daz2 = daz; + daz = spr->z; daz2 = daz; if ((cstat&64) != 0) if ((vect->z > daz) == ((cstat&8)==0)) continue; @@ -11052,7 +11053,7 @@ void makepalookup(int32_t palnum, char *remapbuf, int8_t r, int8_t g, int8_t b, { //Allocate palookup buffer if ((palookup[palnum] = (char *)Bmalloc(numpalookups<<8)) == NULL) - allocache((intptr_t*)&palookup[palnum],numpalookups<<8,&permanentlock); + allocache((intptr_t *)&palookup[palnum],numpalookups<<8,&permanentlock); } if (dastat == 0) return; @@ -11242,7 +11243,7 @@ void clearview(int32_t dacol) for (y=windowy1; y<=windowy2; y++) { //clearbufbyte((void*)p,dx,dacol); - Bmemset((void*)p,dacol,dx); + Bmemset((void *)p,dacol,dx); p += ylookup[1]; } enddrawing(); //}}} @@ -11276,7 +11277,7 @@ void clearallviews(int32_t dacol) begindrawing(); //{{{ //clearbufbyte((void*)frameplace,imageSize,0L); - Bmemset((void*)frameplace,dacol,imageSize); + Bmemset((void *)frameplace,dacol,imageSize); enddrawing(); //}}} //nextpage(); @@ -11308,7 +11309,7 @@ void plotpixel(int32_t x, int32_t y, char col) #endif begindrawing(); //{{{ - drawpixel_safe((void*)(ylookup[y]+x+frameplace),(int32_t)col); + drawpixel_safe((void *)(ylookup[y]+x+frameplace),(int32_t)col); enddrawing(); //}}} } @@ -11356,7 +11357,7 @@ char getpixel(int32_t x, int32_t y) #endif begindrawing(); //{{{ - r = readpixel((void*)(ylookup[y]+x+frameplace)); + r = readpixel((void *)(ylookup[y]+x+frameplace)); enddrawing(); //}}} return(r); } @@ -11500,9 +11501,9 @@ void completemirror(void) i = windowx2-windowx1-mirrorsx2-mirrorsx1; mirrorsx2 -= mirrorsx1; for (dy=mirrorsy2-mirrorsy1-1; dy>=0; dy--) { - copybufbyte((void*)(p+1),tempbuf,mirrorsx2+1); + copybufbyte((void *)(p+1),tempbuf,mirrorsx2+1); tempbuf[mirrorsx2] = tempbuf[mirrorsx2-1]; - copybufreverse(&tempbuf[mirrorsx2],(void*)(p+i),mirrorsx2+1); + copybufreverse(&tempbuf[mirrorsx2],(void *)(p+i),mirrorsx2+1); p += ylookup[1]; faketimerhandler(); } @@ -11812,7 +11813,7 @@ void drawline256(int32_t x1, int32_t y1, int32_t x2, int32_t y2, char col) { j = (plc>>12); if ((j >= startumost[i]) && (j < startdmost[i])) - drawpixel_safe((void*)(frameplace+ylookup[j]+i),col); + drawpixel_safe((void *)(frameplace+ylookup[j]+i),col); plc += inc; } enddrawing(); //}}} @@ -11835,7 +11836,7 @@ void drawline256(int32_t x1, int32_t y1, int32_t x2, int32_t y2, char col) { j = (plc>>12); if ((i >= startumost[j]) && (i < startdmost[j])) - drawpixel_safe((void*)(j+p),col); + drawpixel_safe((void *)(j+p),col); plc += inc; p += ylookup[1]; } enddrawing(); //}}} @@ -12348,7 +12349,7 @@ void draw2dgrid(int32_t posxe, int32_t posye, int32_t posze, int16_t cursectnum, // yofs = getscreenvdisp((yinc-posze)&((yinc<<4)-1), zoome); if (cursectnum<0 || cursectnum>=numsectors) yofs = getscreenvdisp(-posze, zoome); - else + else yofs = getscreenvdisp(getflorzofslope(cursectnum, posxe,posye)-posze, zoome); while (scalescreeny(mulscale14(yinc, zoome))==0 && gride>2) @@ -12380,7 +12381,7 @@ void draw2dgrid(int32_t posxe, int32_t posye, int32_t posze, int16_t cursectnum, { screencoords(&sx2,&sy2, xp2-posxe, editorgridextent-posye, zoome); dx = sx2-sx1; - dy = sy2-sy1; + dy = sy2-sy1; } xp2 += xinc; } @@ -12519,7 +12520,7 @@ static void drawscreen_drawwall(int32_t i, int32_t posxe, int32_t posye, int32_t if (totalclock & 16) col -= (2<<2); } else if (showfirstwall && searchsector>=0 && (sector[searchsector].wallptr == i || - sector[searchsector].wallptr == wall[i].nextwall)) + sector[searchsector].wallptr == wall[i].nextwall)) { col = 14; if (i == linehighlight) if (totalclock & 16) col -= (2<<2); @@ -12615,11 +12616,11 @@ static void drawscreen_drawwall(int32_t i, int32_t posxe, int32_t posye, int32_t if (zoome >= 256 && editstatus == 1) if ((halfxdim16+x1 >= 2) && (halfxdim16+x1 <= xdim-3) && - (midydim16+y1 >= 2) && (midydim16+y1 <= ydim16-3)) + (midydim16+y1 >= 2) && (midydim16+y1 <= ydim16-3)) { int32_t pointsize = 2; - if (i == pointhighlight || ((pointhighlight < MAXWALLS) && (pointhighlight >= 0) && + if (i == pointhighlight || ((pointhighlight < MAXWALLS) && (pointhighlight >= 0) && (wall[i].x == wall[pointhighlight].x) && (wall[i].y == wall[pointhighlight].y))) { if (totalclock & 16) @@ -12683,8 +12684,8 @@ static void drawscreen_drawsprite(int32_t j, int32_t posxe, int32_t posye, int32 if (editstatus == 1) { if ((pointhighlight) >= 16384 && (j+16384 == pointhighlight || - (!m32_sideview && ((sprite[j].x == sprite[pointhighlight-16384].x) && - (sprite[j].y == sprite[pointhighlight-16384].y))))) + (!m32_sideview && ((sprite[j].x == sprite[pointhighlight-16384].x) && + (sprite[j].y == sprite[pointhighlight-16384].y))))) { if (totalclock & 32) col += 8; } @@ -12702,7 +12703,7 @@ static void drawscreen_drawsprite(int32_t j, int32_t posxe, int32_t posye, int32 y1 += getscreenvdisp(sprite[j].z-posze,zoome); if ((halfxdim16+x1 >= 0) && (halfxdim16+x1 < xdim) && - (midydim16+y1 >= 0) && (midydim16+y1 < ydim16)) + (midydim16+y1 >= 0) && (midydim16+y1 < ydim16)) { drawcircle16(halfxdim16+x1, midydim16+y1, 4, 16384, editorcolors[col]); @@ -12861,14 +12862,14 @@ void draw2dscreen(const vec3_t *pos, int16_t cursectnum, int16_t ange, int32_t z m32_wallsprite[m32_swcnt++] = j; sideview_getdist(j, i); } -/* - // j = sector[numsectors-1].wallptr + sector[numsectors-1].wallnum - for (; jitems[hash_getcode(s) % t->size]) == NULL) return -1; - + do if (Bstrcmp(s,cur->string) == 0) return cur->key; diff --git a/polymer/eduke32/build/src/glbuild.c b/polymer/eduke32/build/src/glbuild.c index 451f5417d..fd5644f4d 100644 --- a/polymer/eduke32/build/src/glbuild.c +++ b/polymer/eduke32/build/src/glbuild.c @@ -11,277 +11,277 @@ #include "sdl_inc.h" #endif -void (APIENTRY * bglClearColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -void (APIENTRY * bglClear)(GLbitfield mask); -void (APIENTRY * bglColorMask)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -void (APIENTRY * bglAlphaFunc)(GLenum func, GLclampf ref); -void (APIENTRY * bglBlendFunc)(GLenum sfactor, GLenum dfactor); -void (APIENTRY * bglCullFace)(GLenum mode); -void (APIENTRY * bglFrontFace)(GLenum mode); -void (APIENTRY * bglPolygonOffset)(GLfloat factor, GLfloat units); -void (APIENTRY * bglPolygonMode)(GLenum face, GLenum mode); -void (APIENTRY * bglEnable)(GLenum cap); -void (APIENTRY * bglDisable)(GLenum cap); -void (APIENTRY * bglGetDoublev)(GLenum pname, GLdouble *params); -void (APIENTRY * bglGetFloatv)(GLenum pname, GLfloat *params); -void (APIENTRY * bglGetIntegerv)(GLenum pname, GLint *params); -void (APIENTRY * bglPushAttrib)(GLbitfield mask); -void (APIENTRY * bglPopAttrib)(void); -GLenum(APIENTRY * bglGetError)(void); -const GLubyte*(APIENTRY * bglGetString)(GLenum name); -void (APIENTRY * bglHint)(GLenum target, GLenum mode); -void (APIENTRY * bglDrawBuffer)(GLenum mode); -void (APIENTRY * bglReadBuffer)(GLenum mode); -void (APIENTRY * bglScissor)(GLint x, GLint y, GLsizei width, GLsizei height); -void (APIENTRY * bglClipPlane)(GLenum plane, const GLdouble *equation); +void (APIENTRY *bglClearColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +void (APIENTRY *bglClear)(GLbitfield mask); +void (APIENTRY *bglColorMask)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +void (APIENTRY *bglAlphaFunc)(GLenum func, GLclampf ref); +void (APIENTRY *bglBlendFunc)(GLenum sfactor, GLenum dfactor); +void (APIENTRY *bglCullFace)(GLenum mode); +void (APIENTRY *bglFrontFace)(GLenum mode); +void (APIENTRY *bglPolygonOffset)(GLfloat factor, GLfloat units); +void (APIENTRY *bglPolygonMode)(GLenum face, GLenum mode); +void (APIENTRY *bglEnable)(GLenum cap); +void (APIENTRY *bglDisable)(GLenum cap); +void (APIENTRY *bglGetDoublev)(GLenum pname, GLdouble *params); +void (APIENTRY *bglGetFloatv)(GLenum pname, GLfloat *params); +void (APIENTRY *bglGetIntegerv)(GLenum pname, GLint *params); +void (APIENTRY *bglPushAttrib)(GLbitfield mask); +void (APIENTRY *bglPopAttrib)(void); +GLenum(APIENTRY *bglGetError)(void); +const GLubyte *(APIENTRY *bglGetString)(GLenum name); +void (APIENTRY *bglHint)(GLenum target, GLenum mode); +void (APIENTRY *bglDrawBuffer)(GLenum mode); +void (APIENTRY *bglReadBuffer)(GLenum mode); +void (APIENTRY *bglScissor)(GLint x, GLint y, GLsizei width, GLsizei height); +void (APIENTRY *bglClipPlane)(GLenum plane, const GLdouble *equation); // Depth -void (APIENTRY * bglDepthFunc)(GLenum func); -void (APIENTRY * bglDepthMask)(GLboolean flag); -void (APIENTRY * bglDepthRange)(GLclampd near_val, GLclampd far_val); +void (APIENTRY *bglDepthFunc)(GLenum func); +void (APIENTRY *bglDepthMask)(GLboolean flag); +void (APIENTRY *bglDepthRange)(GLclampd near_val, GLclampd far_val); // Matrix -void (APIENTRY * bglMatrixMode)(GLenum mode); -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 * bglViewport)(GLint x, GLint y, GLsizei width, GLsizei height); -void (APIENTRY * bglPushMatrix)(void); -void (APIENTRY * bglPopMatrix)(void); -void (APIENTRY * bglLoadIdentity)(void); -void (APIENTRY * bglLoadMatrixf)(const GLfloat *m); -void (APIENTRY * bglLoadMatrixd)(const GLdouble *m); -void (APIENTRY * bglMultMatrixf)(const GLfloat *m); -void (APIENTRY * bglMultMatrixd)(const GLdouble *m); -void (APIENTRY * bglRotatef)(GLfloat angle, 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 *bglMatrixMode)(GLenum mode); +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 *bglViewport)(GLint x, GLint y, GLsizei width, GLsizei height); +void (APIENTRY *bglPushMatrix)(void); +void (APIENTRY *bglPopMatrix)(void); +void (APIENTRY *bglLoadIdentity)(void); +void (APIENTRY *bglLoadMatrixf)(const GLfloat *m); +void (APIENTRY *bglLoadMatrixd)(const GLdouble *m); +void (APIENTRY *bglMultMatrixf)(const GLfloat *m); +void (APIENTRY *bglMultMatrixd)(const GLdouble *m); +void (APIENTRY *bglRotatef)(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +void (APIENTRY *bglScalef)(GLfloat x, GLfloat y, GLfloat z); +void (APIENTRY *bglTranslatef)(GLfloat x, GLfloat y, GLfloat z); // Drawing -void (APIENTRY * bglBegin)(GLenum mode); -void (APIENTRY * bglEnd)(void); -void (APIENTRY * bglVertex2f)(GLfloat x, GLfloat y); -void (APIENTRY * bglVertex2i)(GLint x, GLint y); -void (APIENTRY * bglVertex3f)(GLfloat x, GLfloat y, GLfloat z); -void (APIENTRY * bglVertex3d)(GLdouble x, GLdouble y, GLdouble z); -void (APIENTRY * bglVertex3fv)(const GLfloat *v); -void (APIENTRY * bglVertex3dv)(const GLdouble *v); -void (APIENTRY * bglColor4f)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -void (APIENTRY * bglColor4ub)(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); -void (APIENTRY * bglTexCoord2d)(GLdouble s, GLdouble t); -void (APIENTRY * bglTexCoord2f)(GLfloat s, GLfloat t); -void (APIENTRY * bglTexCoord2i)(GLint s, GLint t); -void (APIENTRY * bglNormal3f)(GLfloat x, GLfloat y, GLfloat z); +void (APIENTRY *bglBegin)(GLenum mode); +void (APIENTRY *bglEnd)(void); +void (APIENTRY *bglVertex2f)(GLfloat x, GLfloat y); +void (APIENTRY *bglVertex2i)(GLint x, GLint y); +void (APIENTRY *bglVertex3f)(GLfloat x, GLfloat y, GLfloat z); +void (APIENTRY *bglVertex3d)(GLdouble x, GLdouble y, GLdouble z); +void (APIENTRY *bglVertex3fv)(const GLfloat *v); +void (APIENTRY *bglVertex3dv)(const GLdouble *v); +void (APIENTRY *bglColor4f)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +void (APIENTRY *bglColor4ub)(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); +void (APIENTRY *bglTexCoord2d)(GLdouble s, GLdouble t); +void (APIENTRY *bglTexCoord2f)(GLfloat s, GLfloat t); +void (APIENTRY *bglTexCoord2i)(GLint s, GLint t); +void (APIENTRY *bglNormal3f)(GLfloat x, GLfloat y, GLfloat z); // Lighting -void (APIENTRY * bglShadeModel)(GLenum mode); -void (APIENTRY * bglLightfv)(GLenum light, GLenum pname, const GLfloat * params); +void (APIENTRY *bglShadeModel)(GLenum mode); +void (APIENTRY *bglLightfv)(GLenum light, GLenum pname, const GLfloat *params); // Raster funcs -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 * bglDrawPixels)(GLsizei width, GLsizei height, GLenum format, GLenum type, const 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 *bglDrawPixels)(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); // Texture mapping -void (APIENTRY * bglTexEnvf)(GLenum target, GLenum pname, GLfloat param); -void (APIENTRY * bglGenTextures)(GLsizei n, 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 * 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 * 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 * 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 * bglTexParameteri)(GLenum target, GLenum pname, GLint param); -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 * bglGetCompressedTexImageARB)(GLenum, GLint, GLvoid *); -void (APIENTRY * bglTexGenfv)(GLenum coord, GLenum pname, const GLfloat *params); +void (APIENTRY *bglTexEnvf)(GLenum target, GLenum pname, GLfloat param); +void (APIENTRY *bglGenTextures)(GLsizei n, 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 *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 *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 *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 *bglTexParameteri)(GLenum target, GLenum pname, GLint param); +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 *bglGetCompressedTexImageARB)(GLenum, GLint, GLvoid *); +void (APIENTRY *bglTexGenfv)(GLenum coord, GLenum pname, const GLfloat *params); // Fog -void (APIENTRY * bglFogf)(GLenum pname, GLfloat param); -void (APIENTRY * bglFogi)(GLenum pname, GLint param); -void (APIENTRY * bglFogfv)(GLenum pname, const GLfloat *params); +void (APIENTRY *bglFogf)(GLenum pname, GLfloat param); +void (APIENTRY *bglFogi)(GLenum pname, GLint param); +void (APIENTRY *bglFogfv)(GLenum pname, const GLfloat *params); // Display Lists -void (APIENTRY * bglNewList)(GLuint list, GLenum mode); -void (APIENTRY * bglEndList)(void); -void (APIENTRY * bglCallList)(GLuint list); -void (APIENTRY * bglDeleteLists)(GLuint list, GLsizei range); +void (APIENTRY *bglNewList)(GLuint list, GLenum mode); +void (APIENTRY *bglEndList)(void); +void (APIENTRY *bglCallList)(GLuint list); +void (APIENTRY *bglDeleteLists)(GLuint list, GLsizei range); // Vertex Arrays -void (APIENTRY * bglEnableClientState)(GLenum cap); -void (APIENTRY * bglDisableClientState)(GLenum cap); -void (APIENTRY * bglVertexPointer)(GLint size, 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 * bglDrawArrays)(GLenum mode, GLint first, GLsizei count); -void (APIENTRY * bglDrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); +void (APIENTRY *bglEnableClientState)(GLenum cap); +void (APIENTRY *bglDisableClientState)(GLenum cap); +void (APIENTRY *bglVertexPointer)(GLint size, 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 *bglDrawArrays)(GLenum mode, GLint first, GLsizei count); +void (APIENTRY *bglDrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); // Stencil Buffer -void (APIENTRY * bglClearStencil)(GLint s); -void (APIENTRY * bglStencilOp)(GLenum fail, GLenum zfail, GLenum zpass); -void (APIENTRY * bglStencilFunc)(GLenum func, GLint ref, GLuint mask); +void (APIENTRY *bglClearStencil)(GLint s); +void (APIENTRY *bglStencilOp)(GLenum fail, GLenum zfail, GLenum zpass); +void (APIENTRY *bglStencilFunc)(GLenum func, GLint ref, GLuint mask); // GPU Programs -void (APIENTRY * bglGenProgramsARB)(GLsizei, GLuint *); -void (APIENTRY * bglBindProgramARB)(GLenum, GLuint); -void (APIENTRY * bglProgramStringARB)(GLenum, GLenum, GLsizei, const GLvoid *); -void (APIENTRY * bglDeleteProgramsARB)(GLsizei n, const GLuint *programs); +void (APIENTRY *bglGenProgramsARB)(GLsizei, GLuint *); +void (APIENTRY *bglBindProgramARB)(GLenum, GLuint); +void (APIENTRY *bglProgramStringARB)(GLenum, GLenum, GLsizei, const GLvoid *); +void (APIENTRY *bglDeleteProgramsARB)(GLsizei n, const GLuint *programs); // Multitexturing -void (APIENTRY * bglActiveTextureARB)(GLenum texture); -void (APIENTRY * bglClientActiveTextureARB)(GLenum texture); -void (APIENTRY * bglMultiTexCoord2dARB)(GLenum target, GLdouble s, GLdouble t); -void (APIENTRY * bglMultiTexCoord2fARB)(GLenum target, GLfloat s, GLfloat t); +void (APIENTRY *bglActiveTextureARB)(GLenum texture); +void (APIENTRY *bglClientActiveTextureARB)(GLenum texture); +void (APIENTRY *bglMultiTexCoord2dARB)(GLenum target, GLdouble s, GLdouble t); +void (APIENTRY *bglMultiTexCoord2fARB)(GLenum target, GLfloat s, GLfloat t); // Frame Buffer Objects -void (APIENTRY * bglGenFramebuffersEXT)(GLsizei n, GLuint *framebuffers); -void (APIENTRY * bglBindFramebufferEXT)(GLenum target, GLuint framebuffer); -void (APIENTRY * bglFramebufferTexture2DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLenum(APIENTRY * bglCheckFramebufferStatusEXT)(GLenum target); -void (APIENTRY * bglDeleteFramebuffersEXT)(GLsizei n, const GLuint *framebuffers); +void (APIENTRY *bglGenFramebuffersEXT)(GLsizei n, GLuint *framebuffers); +void (APIENTRY *bglBindFramebufferEXT)(GLenum target, GLuint framebuffer); +void (APIENTRY *bglFramebufferTexture2DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLenum(APIENTRY *bglCheckFramebufferStatusEXT)(GLenum target); +void (APIENTRY *bglDeleteFramebuffersEXT)(GLsizei n, const GLuint *framebuffers); // Vertex Buffer Objects -void (APIENTRY * bglGenBuffersARB)(GLsizei n, GLuint * buffers); -void (APIENTRY * bglBindBufferARB)(GLenum target, GLuint buffer); -void (APIENTRY * bglDeleteBuffersARB)(GLsizei n, const GLuint * buffers); -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 * bglMapBufferARB)(GLenum target, GLenum access); -GLboolean(APIENTRY * bglUnmapBufferARB)(GLenum target); +void (APIENTRY *bglGenBuffersARB)(GLsizei n, GLuint *buffers); +void (APIENTRY *bglBindBufferARB)(GLenum target, GLuint buffer); +void (APIENTRY *bglDeleteBuffersARB)(GLsizei n, const GLuint *buffers); +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 *bglMapBufferARB)(GLenum target, GLenum access); +GLboolean(APIENTRY *bglUnmapBufferARB)(GLenum target); // Occlusion queries -void (APIENTRY * bglGenQueriesARB)(GLsizei n, GLuint *ids); -void (APIENTRY * bglDeleteQueriesARB)(GLsizei n, const GLuint *ids); -GLboolean(APIENTRY * bglIsQueryARB)(GLuint id); -void (APIENTRY * bglBeginQueryARB)(GLenum target, GLuint id); -void (APIENTRY * bglEndQueryARB)(GLenum target); -void (APIENTRY * bglGetQueryivARB)(GLenum target, GLenum pname, GLint *params); -void (APIENTRY * bglGetQueryObjectivARB)(GLuint id, GLenum pname, GLint *params); -void (APIENTRY * bglGetQueryObjectuivARB)(GLuint id, GLenum pname, GLuint *params); +void (APIENTRY *bglGenQueriesARB)(GLsizei n, GLuint *ids); +void (APIENTRY *bglDeleteQueriesARB)(GLsizei n, const GLuint *ids); +GLboolean(APIENTRY *bglIsQueryARB)(GLuint id); +void (APIENTRY *bglBeginQueryARB)(GLenum target, GLuint id); +void (APIENTRY *bglEndQueryARB)(GLenum target); +void (APIENTRY *bglGetQueryivARB)(GLenum target, GLenum pname, GLint *params); +void (APIENTRY *bglGetQueryObjectivARB)(GLuint id, GLenum pname, GLint *params); +void (APIENTRY *bglGetQueryObjectuivARB)(GLuint id, GLenum pname, GLuint *params); // Shader Objects -void (APIENTRY * bglDeleteObjectARB)(GLhandleARB); -GLhandleARB(APIENTRY * bglGetHandleARB)(GLenum); -void (APIENTRY * bglDetachObjectARB)(GLhandleARB, GLhandleARB); -GLhandleARB(APIENTRY * bglCreateShaderObjectARB)(GLenum); -void (APIENTRY * bglShaderSourceARB)(GLhandleARB, GLsizei, const GLcharARB* *, const GLint *); -void (APIENTRY * bglCompileShaderARB)(GLhandleARB); -GLhandleARB(APIENTRY * bglCreateProgramObjectARB)(void); -void (APIENTRY * bglAttachObjectARB)(GLhandleARB, GLhandleARB); -void (APIENTRY * bglLinkProgramARB)(GLhandleARB); -void (APIENTRY * bglUseProgramObjectARB)(GLhandleARB); -void (APIENTRY * bglValidateProgramARB)(GLhandleARB); -void (APIENTRY * bglUniform1fARB)(GLint, GLfloat); -void (APIENTRY * bglUniform2fARB)(GLint, GLfloat, GLfloat); -void (APIENTRY * bglUniform3fARB)(GLint, GLfloat, GLfloat, GLfloat); -void (APIENTRY * bglUniform4fARB)(GLint, GLfloat, GLfloat, GLfloat, GLfloat); -void (APIENTRY * bglUniform1iARB)(GLint, GLint); -void (APIENTRY * bglUniform2iARB)(GLint, GLint, GLint); -void (APIENTRY * bglUniform3iARB)(GLint, GLint, GLint, GLint); -void (APIENTRY * bglUniform4iARB)(GLint, GLint, GLint, GLint, GLint); -void (APIENTRY * bglUniform1fvARB)(GLint, GLsizei, const GLfloat *); -void (APIENTRY * bglUniform2fvARB)(GLint, GLsizei, const GLfloat *); -void (APIENTRY * bglUniform3fvARB)(GLint, GLsizei, const GLfloat *); -void (APIENTRY * bglUniform4fvARB)(GLint, GLsizei, const GLfloat *); -void (APIENTRY * bglUniform1ivARB)(GLint, GLsizei, const GLint *); -void (APIENTRY * bglUniform2ivARB)(GLint, GLsizei, const GLint *); -void (APIENTRY * bglUniform3ivARB)(GLint, GLsizei, const GLint *); -void (APIENTRY * bglUniform4ivARB)(GLint, GLsizei, const GLint *); -void (APIENTRY * bglUniformMatrix2fvARB)(GLint, GLsizei, GLboolean, const GLfloat *); -void (APIENTRY * bglUniformMatrix3fvARB)(GLint, GLsizei, GLboolean, const GLfloat *); -void (APIENTRY * bglUniformMatrix4fvARB)(GLint, GLsizei, GLboolean, const GLfloat *); -void (APIENTRY * bglGetObjectParameterfvARB)(GLhandleARB, GLenum, GLfloat *); -void (APIENTRY * bglGetObjectParameterivARB)(GLhandleARB, GLenum, GLint *); -void (APIENTRY * bglGetInfoLogARB)(GLhandleARB, GLsizei, GLsizei *, GLcharARB *); -void (APIENTRY * bglGetAttachedObjectsARB)(GLhandleARB, GLsizei, GLsizei *, GLhandleARB *); -GLint(APIENTRY * bglGetUniformLocationARB)(GLhandleARB, const GLcharARB *); -void (APIENTRY * bglGetActiveUniformARB)(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); -void (APIENTRY * bglGetUniformfvARB)(GLhandleARB, GLint, GLfloat *); -void (APIENTRY * bglGetUniformivARB)(GLhandleARB, GLint, GLint *); -void (APIENTRY * bglGetShaderSourceARB)(GLhandleARB, GLsizei, GLsizei *, GLcharARB *); +void (APIENTRY *bglDeleteObjectARB)(GLhandleARB); +GLhandleARB(APIENTRY *bglGetHandleARB)(GLenum); +void (APIENTRY *bglDetachObjectARB)(GLhandleARB, GLhandleARB); +GLhandleARB(APIENTRY *bglCreateShaderObjectARB)(GLenum); +void (APIENTRY *bglShaderSourceARB)(GLhandleARB, GLsizei, const GLcharARB* *, const GLint *); +void (APIENTRY *bglCompileShaderARB)(GLhandleARB); +GLhandleARB(APIENTRY *bglCreateProgramObjectARB)(void); +void (APIENTRY *bglAttachObjectARB)(GLhandleARB, GLhandleARB); +void (APIENTRY *bglLinkProgramARB)(GLhandleARB); +void (APIENTRY *bglUseProgramObjectARB)(GLhandleARB); +void (APIENTRY *bglValidateProgramARB)(GLhandleARB); +void (APIENTRY *bglUniform1fARB)(GLint, GLfloat); +void (APIENTRY *bglUniform2fARB)(GLint, GLfloat, GLfloat); +void (APIENTRY *bglUniform3fARB)(GLint, GLfloat, GLfloat, GLfloat); +void (APIENTRY *bglUniform4fARB)(GLint, GLfloat, GLfloat, GLfloat, GLfloat); +void (APIENTRY *bglUniform1iARB)(GLint, GLint); +void (APIENTRY *bglUniform2iARB)(GLint, GLint, GLint); +void (APIENTRY *bglUniform3iARB)(GLint, GLint, GLint, GLint); +void (APIENTRY *bglUniform4iARB)(GLint, GLint, GLint, GLint, GLint); +void (APIENTRY *bglUniform1fvARB)(GLint, GLsizei, const GLfloat *); +void (APIENTRY *bglUniform2fvARB)(GLint, GLsizei, const GLfloat *); +void (APIENTRY *bglUniform3fvARB)(GLint, GLsizei, const GLfloat *); +void (APIENTRY *bglUniform4fvARB)(GLint, GLsizei, const GLfloat *); +void (APIENTRY *bglUniform1ivARB)(GLint, GLsizei, const GLint *); +void (APIENTRY *bglUniform2ivARB)(GLint, GLsizei, const GLint *); +void (APIENTRY *bglUniform3ivARB)(GLint, GLsizei, const GLint *); +void (APIENTRY *bglUniform4ivARB)(GLint, GLsizei, const GLint *); +void (APIENTRY *bglUniformMatrix2fvARB)(GLint, GLsizei, GLboolean, const GLfloat *); +void (APIENTRY *bglUniformMatrix3fvARB)(GLint, GLsizei, GLboolean, const GLfloat *); +void (APIENTRY *bglUniformMatrix4fvARB)(GLint, GLsizei, GLboolean, const GLfloat *); +void (APIENTRY *bglGetObjectParameterfvARB)(GLhandleARB, GLenum, GLfloat *); +void (APIENTRY *bglGetObjectParameterivARB)(GLhandleARB, GLenum, GLint *); +void (APIENTRY *bglGetInfoLogARB)(GLhandleARB, GLsizei, GLsizei *, GLcharARB *); +void (APIENTRY *bglGetAttachedObjectsARB)(GLhandleARB, GLsizei, GLsizei *, GLhandleARB *); +GLint(APIENTRY *bglGetUniformLocationARB)(GLhandleARB, const GLcharARB *); +void (APIENTRY *bglGetActiveUniformARB)(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); +void (APIENTRY *bglGetUniformfvARB)(GLhandleARB, GLint, GLfloat *); +void (APIENTRY *bglGetUniformivARB)(GLhandleARB, GLint, GLint *); +void (APIENTRY *bglGetShaderSourceARB)(GLhandleARB, GLsizei, GLsizei *, GLcharARB *); // Vertex Shaders -void (APIENTRY * bglVertexAttrib1dARB)(GLuint, GLdouble); -void (APIENTRY * bglVertexAttrib1dvARB)(GLuint, const GLdouble *); -void (APIENTRY * bglVertexAttrib1fARB)(GLuint, GLfloat); -void (APIENTRY * bglVertexAttrib1fvARB)(GLuint, const GLfloat *); -void (APIENTRY * bglVertexAttrib1sARB)(GLuint, GLshort); -void (APIENTRY * bglVertexAttrib1svARB)(GLuint, const GLshort *); -void (APIENTRY * bglVertexAttrib2dARB)(GLuint, GLdouble, GLdouble); -void (APIENTRY * bglVertexAttrib2dvARB)(GLuint, const GLdouble *); -void (APIENTRY * bglVertexAttrib2fARB)(GLuint, GLfloat, GLfloat); -void (APIENTRY * bglVertexAttrib2fvARB)(GLuint, const GLfloat *); -void (APIENTRY * bglVertexAttrib2sARB)(GLuint, GLshort, GLshort); -void (APIENTRY * bglVertexAttrib2svARB)(GLuint, const GLshort *); -void (APIENTRY * bglVertexAttrib3dARB)(GLuint, GLdouble, GLdouble, GLdouble); -void (APIENTRY * bglVertexAttrib3dvARB)(GLuint, const GLdouble *); -void (APIENTRY * bglVertexAttrib3fARB)(GLuint, GLfloat, GLfloat, GLfloat); -void (APIENTRY * bglVertexAttrib3fvARB)(GLuint, const GLfloat *); -void (APIENTRY * bglVertexAttrib3sARB)(GLuint, GLshort, GLshort, GLshort); -void (APIENTRY * bglVertexAttrib3svARB)(GLuint, const GLshort *); -void (APIENTRY * bglVertexAttrib4NbvARB)(GLuint, const GLbyte *); -void (APIENTRY * bglVertexAttrib4NivARB)(GLuint, const GLint *); -void (APIENTRY * bglVertexAttrib4NsvARB)(GLuint, const GLshort *); -void (APIENTRY * bglVertexAttrib4NubARB)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte); -void (APIENTRY * bglVertexAttrib4NubvARB)(GLuint, const GLubyte *); -void (APIENTRY * bglVertexAttrib4NuivARB)(GLuint, const GLuint *); -void (APIENTRY * bglVertexAttrib4NusvARB)(GLuint, const GLushort *); -void (APIENTRY * bglVertexAttrib4bvARB)(GLuint, const GLbyte *); -void (APIENTRY * bglVertexAttrib4dARB)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -void (APIENTRY * bglVertexAttrib4dvARB)(GLuint, const GLdouble *); -void (APIENTRY * bglVertexAttrib4fARB)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -void (APIENTRY * bglVertexAttrib4fvARB)(GLuint, const GLfloat *); -void (APIENTRY * bglVertexAttrib4ivARB)(GLuint, const GLint *); -void (APIENTRY * bglVertexAttrib4sARB)(GLuint, GLshort, GLshort, GLshort, GLshort); -void (APIENTRY * bglVertexAttrib4svARB)(GLuint, const GLshort *); -void (APIENTRY * bglVertexAttrib4ubvARB)(GLuint, const GLubyte *); -void (APIENTRY * bglVertexAttrib4uivARB)(GLuint, const GLuint *); -void (APIENTRY * bglVertexAttrib4usvARB)(GLuint, const GLushort *); -void (APIENTRY * bglVertexAttribPointerARB)(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); -void (APIENTRY * bglEnableVertexAttribArrayARB)(GLuint); -void (APIENTRY * bglDisableVertexAttribArrayARB)(GLuint); -void (APIENTRY * bglGetVertexAttribdvARB)(GLuint, GLenum, GLdouble *); -void (APIENTRY * bglGetVertexAttribfvARB)(GLuint, GLenum, GLfloat *); -void (APIENTRY * bglGetVertexAttribivARB)(GLuint, GLenum, GLint *); -void (APIENTRY * bglGetVertexAttribPointervARB)(GLuint, GLenum, GLvoid* *); -void (APIENTRY * bglBindAttribLocationARB)(GLhandleARB, GLuint, const GLcharARB *); -void (APIENTRY * bglGetActiveAttribARB)(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); -GLint(APIENTRY * bglGetAttribLocationARB)(GLhandleARB, const GLcharARB *); +void (APIENTRY *bglVertexAttrib1dARB)(GLuint, GLdouble); +void (APIENTRY *bglVertexAttrib1dvARB)(GLuint, const GLdouble *); +void (APIENTRY *bglVertexAttrib1fARB)(GLuint, GLfloat); +void (APIENTRY *bglVertexAttrib1fvARB)(GLuint, const GLfloat *); +void (APIENTRY *bglVertexAttrib1sARB)(GLuint, GLshort); +void (APIENTRY *bglVertexAttrib1svARB)(GLuint, const GLshort *); +void (APIENTRY *bglVertexAttrib2dARB)(GLuint, GLdouble, GLdouble); +void (APIENTRY *bglVertexAttrib2dvARB)(GLuint, const GLdouble *); +void (APIENTRY *bglVertexAttrib2fARB)(GLuint, GLfloat, GLfloat); +void (APIENTRY *bglVertexAttrib2fvARB)(GLuint, const GLfloat *); +void (APIENTRY *bglVertexAttrib2sARB)(GLuint, GLshort, GLshort); +void (APIENTRY *bglVertexAttrib2svARB)(GLuint, const GLshort *); +void (APIENTRY *bglVertexAttrib3dARB)(GLuint, GLdouble, GLdouble, GLdouble); +void (APIENTRY *bglVertexAttrib3dvARB)(GLuint, const GLdouble *); +void (APIENTRY *bglVertexAttrib3fARB)(GLuint, GLfloat, GLfloat, GLfloat); +void (APIENTRY *bglVertexAttrib3fvARB)(GLuint, const GLfloat *); +void (APIENTRY *bglVertexAttrib3sARB)(GLuint, GLshort, GLshort, GLshort); +void (APIENTRY *bglVertexAttrib3svARB)(GLuint, const GLshort *); +void (APIENTRY *bglVertexAttrib4NbvARB)(GLuint, const GLbyte *); +void (APIENTRY *bglVertexAttrib4NivARB)(GLuint, const GLint *); +void (APIENTRY *bglVertexAttrib4NsvARB)(GLuint, const GLshort *); +void (APIENTRY *bglVertexAttrib4NubARB)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +void (APIENTRY *bglVertexAttrib4NubvARB)(GLuint, const GLubyte *); +void (APIENTRY *bglVertexAttrib4NuivARB)(GLuint, const GLuint *); +void (APIENTRY *bglVertexAttrib4NusvARB)(GLuint, const GLushort *); +void (APIENTRY *bglVertexAttrib4bvARB)(GLuint, const GLbyte *); +void (APIENTRY *bglVertexAttrib4dARB)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +void (APIENTRY *bglVertexAttrib4dvARB)(GLuint, const GLdouble *); +void (APIENTRY *bglVertexAttrib4fARB)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +void (APIENTRY *bglVertexAttrib4fvARB)(GLuint, const GLfloat *); +void (APIENTRY *bglVertexAttrib4ivARB)(GLuint, const GLint *); +void (APIENTRY *bglVertexAttrib4sARB)(GLuint, GLshort, GLshort, GLshort, GLshort); +void (APIENTRY *bglVertexAttrib4svARB)(GLuint, const GLshort *); +void (APIENTRY *bglVertexAttrib4ubvARB)(GLuint, const GLubyte *); +void (APIENTRY *bglVertexAttrib4uivARB)(GLuint, const GLuint *); +void (APIENTRY *bglVertexAttrib4usvARB)(GLuint, const GLushort *); +void (APIENTRY *bglVertexAttribPointerARB)(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); +void (APIENTRY *bglEnableVertexAttribArrayARB)(GLuint); +void (APIENTRY *bglDisableVertexAttribArrayARB)(GLuint); +void (APIENTRY *bglGetVertexAttribdvARB)(GLuint, GLenum, GLdouble *); +void (APIENTRY *bglGetVertexAttribfvARB)(GLuint, GLenum, GLfloat *); +void (APIENTRY *bglGetVertexAttribivARB)(GLuint, GLenum, GLint *); +void (APIENTRY *bglGetVertexAttribPointervARB)(GLuint, GLenum, GLvoid* *); +void (APIENTRY *bglBindAttribLocationARB)(GLhandleARB, GLuint, const GLcharARB *); +void (APIENTRY *bglGetActiveAttribARB)(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); +GLint(APIENTRY *bglGetAttribLocationARB)(GLhandleARB, const GLcharARB *); // GLU -void (APIENTRY * bgluTessBeginContour)(GLUtesselator* tess); -void (APIENTRY * bgluTessBeginPolygon)(GLUtesselator* tess, GLvoid* data); -void (APIENTRY * bgluTessCallback)(GLUtesselator* tess, GLenum which, void (PR_CALLBACK CallBackFunc)()); -void (APIENTRY * bgluTessEndContour)(GLUtesselator* tess); -void (APIENTRY * bgluTessEndPolygon)(GLUtesselator* tess); -void (APIENTRY * bgluTessNormal)(GLUtesselator* tess, GLdouble valueX, GLdouble valueY, GLdouble valueZ); -void (APIENTRY * bgluTessProperty)(GLUtesselator* tess, GLenum which, GLdouble data); -void (APIENTRY * bgluTessVertex)(GLUtesselator* tess, GLdouble *location, GLvoid* data); -GLUtesselator*(APIENTRY * bgluNewTess)(void); +void (APIENTRY *bgluTessBeginContour)(GLUtesselator *tess); +void (APIENTRY *bgluTessBeginPolygon)(GLUtesselator *tess, GLvoid *data); +void (APIENTRY *bgluTessCallback)(GLUtesselator *tess, GLenum which, void (PR_CALLBACK CallBackFunc)()); +void (APIENTRY *bgluTessEndContour)(GLUtesselator *tess); +void (APIENTRY *bgluTessEndPolygon)(GLUtesselator *tess); +void (APIENTRY *bgluTessNormal)(GLUtesselator *tess, GLdouble valueX, GLdouble valueY, GLdouble valueZ); +void (APIENTRY *bgluTessProperty)(GLUtesselator *tess, GLenum which, GLdouble data); +void (APIENTRY *bgluTessVertex)(GLUtesselator *tess, GLdouble *location, GLvoid *data); +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 * bgluUnProject)(GLdouble winX, GLdouble winY, GLdouble winZ, const GLdouble * model, const GLdouble * proj, const GLint * view, GLdouble* objX, GLdouble* objY, GLdouble* objZ); +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); #ifdef RENDERTYPEWIN // Windows -HGLRC(WINAPI * bwglCreateContext)(HDC); -BOOL (WINAPI * bwglDeleteContext)(HGLRC); -PROC(WINAPI * bwglGetProcAddress)(LPCSTR); -BOOL (WINAPI * bwglMakeCurrent)(HDC,HGLRC); +HGLRC(WINAPI *bwglCreateContext)(HDC); +BOOL (WINAPI *bwglDeleteContext)(HGLRC); +PROC(WINAPI *bwglGetProcAddress)(LPCSTR); +BOOL (WINAPI *bwglMakeCurrent)(HDC,HGLRC); -BOOL (WINAPI * bwglSwapBuffers)(HDC); -int32_t (WINAPI * bwglChoosePixelFormat)(HDC,CONST PIXELFORMATDESCRIPTOR*); -int32_t (WINAPI * bwglDescribePixelFormat)(HDC,int32_t,UINT,LPPIXELFORMATDESCRIPTOR); -int32_t (WINAPI * bwglGetPixelFormat)(HDC); -BOOL (WINAPI * bwglSetPixelFormat)(HDC,int32_t,const PIXELFORMATDESCRIPTOR*); -BOOL (WINAPI * bwglSwapIntervalEXT)(int32_t); +BOOL (WINAPI *bwglSwapBuffers)(HDC); +int32_t (WINAPI *bwglChoosePixelFormat)(HDC,CONST PIXELFORMATDESCRIPTOR *); +int32_t (WINAPI *bwglDescribePixelFormat)(HDC,int32_t,UINT,LPPIXELFORMATDESCRIPTOR); +int32_t (WINAPI *bwglGetPixelFormat)(HDC); +BOOL (WINAPI *bwglSetPixelFormat)(HDC,int32_t,const PIXELFORMATDESCRIPTOR *); +BOOL (WINAPI *bwglSwapIntervalEXT)(int32_t); static HANDLE hGLDLL, hGLUDLL; #else @@ -292,15 +292,15 @@ static void *gluhandle = 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; #if defined RENDERTYPESDL UNREFERENCED_PARAMETER(extension); - t = (void*)SDL_GL_GetProcAddress(s); + t = (void *)SDL_GL_GetProcAddress(s); #elif defined _WIN32 - if (extension) t = (void*)bwglGetProcAddress(s); - else t = (void*)GetProcAddress(hGLDLL,s); + if (extension) t = (void *)bwglGetProcAddress(s); + else t = (void *)GetProcAddress(hGLDLL,s); #else #error Need a dynamic loader for this platform... #endif @@ -889,13 +889,13 @@ int32_t unloadgldriver(void) 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; #if defined _WIN32 - t = (void*)GetProcAddress(hGLUDLL,s); + t = (void *)GetProcAddress(hGLUDLL,s); #else - t = (void*)dlsym(gluhandle,s); + t = (void *)dlsym(gluhandle,s); #endif if (!t && fatal) { diff --git a/polymer/eduke32/build/src/hightile.c b/polymer/eduke32/build/src/hightile.c index 4a8d81766..b3df18ff2 100644 --- a/polymer/eduke32/build/src/hightile.c +++ b/polymer/eduke32/build/src/hightile.c @@ -20,7 +20,7 @@ char hicfirstinit = 0; // // 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; diff --git a/polymer/eduke32/build/src/kplib.c b/polymer/eduke32/build/src/kplib.c index 2f24df3f0..fc9b44125 100644 --- a/polymer/eduke32/build/src/kplib.c +++ b/polymer/eduke32/build/src/kplib.c @@ -206,7 +206,7 @@ static _inline int32_t bitrev(int32_t b, int32_t c) mov edx, b mov ecx, c xor eax, eax -beg: shr edx, 1 + beg: shr edx, 1 adc eax, eax sub ecx, 1 jnz short beg @@ -230,7 +230,7 @@ static _inline int32_t testflag(int32_t c) mov eax, 1 jne menostinx 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) { -__asm__ __volatile__("bswap %0" : "+r"(a) : : "cc"); + __asm__ __volatile__("bswap %0" : "+r"(a) : : "cc"); return a; } @@ -265,7 +265,7 @@ static inline int32_t bitrev(int32_t b, int32_t c) int32_t a = 0; __asm__ __volatile__( "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; } @@ -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" "popf\n\tpushf\n\tpopl %%eax\n\txorl %%ebx, %%eax\n\tmovl $1, %%eax\n\tjne 0f\n\t" "xorl %%eax, %%eax\n\t0:" - : "=a"(a) : "c"(c) : "ebx","cc"); + : "=a"(a) : "c"(c) : "ebx","cc"); return a; } @@ -285,7 +285,7 @@ static inline void cpuid(int32_t a, int32_t *s) __asm__ __volatile__( "cpuid\n\tmovl %%eax, (%%esi)\n\tmovl %%ebx, 4(%%esi)\n\t" "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 @@ -337,7 +337,8 @@ static void suckbitsnextblock() if (!zipfilmode) { if (!nfilptr) - { //|===|===|crc|lng|typ|===|===| + { + //|===|===|crc|lng|typ|===|===| // \ fakebuf: / // |===|===| //----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 cmp dword ptr trnsrgb, 0 jz short begit2 -begit: + begit: mov eax, dword ptr [ecx+edx] or eax, 0xff000000 cmp eax, dword ptr trnsrgb jne short skipit and eax, 0xffffff -skipit: + skipit: sub ecx, 3 mov [edi], eax lea edi, [edi+ebx] jnz short begit jmp short endit -begit2: + begit2: mov eax, dword ptr [ecx+edx] or eax, 0xff000000 sub ecx, 3 mov [edi], eax lea edi, [edi+ebx] jnz short begit2 -endit: + endit: pop edi 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 ebx, b 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] sub ecx, 1 mov [edi], eax @@ -615,7 +616,7 @@ begit:movzx eax, byte ptr [ecx+edx] jnz short begit pop edi 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" "cmpl (%%edx,%%eax,4), %%edi \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; } @@ -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" "jnz 2b \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) @@ -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" "jnz 0b \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 @@ -747,42 +748,42 @@ static void putbuf(const uint8_t *buf, int32_t leng) switch (filt) { case 0: - while (i < x) { olinbuf[xplc] = buf[i]; xplc--; i++; } + while (i < x) { olinbuf[xplc] = buf[i]; xplc--; i++; } break; case 1: - while (i < x) - { - olinbuf[xplc] = (uint8_t)(opixbuf1[xm] += buf[i]); - xm = xmn[xm]; xplc--; i++; - } + while (i < x) + { + olinbuf[xplc] = (uint8_t)(opixbuf1[xm] += buf[i]); + xm = xmn[xm]; xplc--; i++; + } break; 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; case 3: - while (i < x) - { - opixbuf1[xm] = olinbuf[xplc] = (uint8_t)(((opixbuf1[xm]+olinbuf[xplc])>>1)+buf[i]); - xm = xmn[xm]; xplc--; i++; - } + while (i < x) + { + opixbuf1[xm] = olinbuf[xplc] = (uint8_t)(((opixbuf1[xm]+olinbuf[xplc])>>1)+buf[i]); + xm = xmn[xm]; xplc--; i++; + } break; case 4: - while (i < x) - { - opixbuf1[xm] = (uint8_t)(Paeth(opixbuf1[xm],olinbuf[xplc],opixbuf0[xm])+buf[i]); - opixbuf0[xm] = olinbuf[xplc]; - olinbuf[xplc] = opixbuf1[xm]; - xm = xmn[xm]; xplc--; i++; - } + while (i < x) + { + opixbuf1[xm] = (uint8_t)(Paeth(opixbuf1[xm],olinbuf[xplc],opixbuf0[xm])+buf[i]); + opixbuf0[xm] = olinbuf[xplc]; + olinbuf[xplc] = opixbuf1[xm]; + xm = xmn[xm]; xplc--; i++; + } break; case 5: //Special hack for Paeth686 (Doesn't have to be case 5) - while (i < x) - { - opixbuf1[xm] = (uint8_t)(Paeth686(opixbuf1[xm],olinbuf[xplc],opixbuf0[xm])+buf[i]); - opixbuf0[xm] = olinbuf[xplc]; - olinbuf[xplc] = opixbuf1[xm]; - xm = xmn[xm]; xplc--; i++; - } + while (i < x) + { + opixbuf1[xm] = (uint8_t)(Paeth686(opixbuf1[xm],olinbuf[xplc],opixbuf0[xm])+buf[i]); + opixbuf0[xm] = olinbuf[xplc]; + olinbuf[xplc] = opixbuf1[xm]; + xm = xmn[xm]; xplc--; i++; + } break; } @@ -796,26 +797,26 @@ static void putbuf(const uint8_t *buf, int32_t leng) { case 2: rgbhlineasm(x,xr1,p,ixstp); break; case 4: - for (; x>xr1; p+=ixstp,x-=2) - *(int32_t *)p = (palcol[olinbuf[x]]&LSWAPIB(0xffffff))|LSWAPIL((int32_t)olinbuf[x-1]); + for (; x>xr1; p+=ixstp,x-=2) + *(int32_t *)p = (palcol[olinbuf[x]]&LSWAPIB(0xffffff))|LSWAPIL((int32_t)olinbuf[x-1]); break; case 6: - for (; x>xr1; p+=ixstp,x-=4) - { - *(char *)(p) = olinbuf[x ]; //B - *(char *)(p+1) = olinbuf[x+1]; //G - *(char *)(p+2) = olinbuf[x+2]; //R - *(char *)(p+3) = olinbuf[x-1]; //A - } + for (; x>xr1; p+=ixstp,x-=4) + { + *(char *)(p) = olinbuf[x ]; //B + *(char *)(p+1) = olinbuf[x+1]; //G + *(char *)(p+2) = olinbuf[x+2]; //R + *(char *)(p+3) = olinbuf[x-1]; //A + } break; default: - switch (bitdepth) - { - 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 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; - } + switch (bitdepth) + { + 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 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; + } break; } nfplace += nbpl; @@ -916,19 +917,19 @@ static int32_t kpngrend(const char *kfilebuf, int32_t kfilength, switch (coltype) { case 0: case 4: - bakcol = (((int32_t)filptr[0]<<8)+(int32_t)filptr[1])*255/((1<>16)&255); bakg = ((bakcol>>8)&255); @@ -940,18 +941,18 @@ static int32_t kpngrend(const char *kfilebuf, int32_t kfilength, switch (coltype) { case 0: - if (bitdepth <= 8) - palcol[(int32_t)filptr[1]] &= LSWAPIB(0xffffff); + if (bitdepth <= 8) + palcol[(int32_t)filptr[1]] &= LSWAPIB(0xffffff); //else {} // /c0 /d16 not yet supported break; case 2: - if (bitdepth == 8) - { trnsrgb = LSWAPIB((((int32_t)filptr[1])<<16)+(((int32_t)filptr[3])<<8)+((int32_t)filptr[5])+0xff000000); } + if (bitdepth == 8) + { 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 :( break; case 3: - for (i=min(leng,paleng)-1; i>=0; i--) - palcol[i] &= LSWAPIB((((int32_t)filptr[i])<<24)|0xffffff); + for (i=min(leng,paleng)-1; i>=0; i--) + palcol[i] &= LSWAPIB((((int32_t)filptr[i])<<24)|0xffffff); break; default:; } @@ -1107,7 +1108,7 @@ static int32_t kpngrend(const char *kfilebuf, int32_t kfilength, putbuf(slidebuf,slidew&32767); } -kpngrend_goodret:; + kpngrend_goodret:; if (!(filterest&~(1<= 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++) + do { - 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; c0; 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); - } + ch = *kfileptr++; leng--; + if (ch >= 16) { index = ch-12; } + else { index = ch; } + Bmemcpy((void *)&hufnumatbit[index][1],(void *)kfileptr,16); kfileptr += 16; + leng -= 16; - } - while (leng > 0); + v = 0; hufcnt[index] = 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; c0; 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; case 0xdb: - do - { - ch = *kfileptr++; leng--; - index = (ch&15); - prec = (ch>>4); - for (z=0; z<64; z++) + do { - 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; + ch = *kfileptr++; leng--; + index = (ch&15); + prec = (ch>>4); + for (z=0; z<64; z++) + { + 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; - if (prec) leng -= 64; - } - while (leng > 0); + while (leng > 0); break; case 0xdd: - restartinterval = SSWAPIL(*(uint16_t *)&kfileptr[0]); + restartinterval = SSWAPIL(*(uint16_t *)&kfileptr[0]); kfileptr += leng; break; 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); } 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]; for (yy=0; yy<(lcompvsamp[c]<<3); yy+=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]; @@ -1663,11 +1665,11 @@ static int32_t kpegrend(const char *kfilebuf, int32_t kfilength, { if (Ah) { - if (curbits < 8) //Getbits - { - ch = *kfileptr++; if (ch == 255) kfileptr++; - num = (num<<8)+((long)ch); curbits += 8; - } + if (curbits < 8) //Getbits + { + ch = *kfileptr++; if (ch == 255) kfileptr++; + num = (num<<8)+((long)ch); curbits += 8; + } 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; } } -kpegrend_break2:; + kpegrend_break2:; if (!dctbuf) return(0); passcnt++; kfileptr -= ((curbits>>3)+1); 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; } transcol = -1; 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])); } ptr++; 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>1]>>(((x&1)^1)<<2))&15)]; break; case 8: for (x=x0; x= 19) && (!(ubuf[1]&0xfe))) if ((ubuf[2] < 12) && ((1<= kzfs.endpos) { 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,gslidew&~32767,gslidew); } -kzreadplc3:; kzfs.jmpplc = 3; + kzreadplc3:; kzfs.jmpplc = 3; } -retkzread:; + retkzread:; i = kzfs.pos; kzfs.pos += leng; if (kzfs.pos > kzfs.leng) kzfs.pos = kzfs.leng; return(kzfs.pos-i); diff --git a/polymer/eduke32/build/src/md4.c b/polymer/eduke32/build/src/md4.c index d67dde584..8ef1920ed 100644 --- a/polymer/eduke32/build/src/md4.c +++ b/polymer/eduke32/build/src/md4.c @@ -24,7 +24,7 @@ documentation and/or software. */ -typedef unsigned char * POINTER; +typedef unsigned char *POINTER; typedef unsigned short UINT2; typedef unsigned int UINT4; diff --git a/polymer/eduke32/build/src/mdsprite.c b/polymer/eduke32/build/src/mdsprite.c index ca5efc734..cae7977cb 100644 --- a/polymer/eduke32/build/src/mdsprite.c +++ b/polymer/eduke32/build/src/mdsprite.c @@ -59,8 +59,8 @@ static int32_t maxmodeltris = 0, allocmodeltris = 0; static point3d *vertlist = NULL; //temp array to store interpolated vertices for drawing static int32_t allocvbos = 0, curvbo = 0; -static GLuint* vertvbos = NULL; -static GLuint* indexvbos = NULL; +static GLuint *vertvbos = NULL; +static GLuint *indexvbos = NULL; mdmodel_t *mdload(const char *); int32_t mddraw(spritetype *); @@ -118,13 +118,13 @@ void freeallmodels() } freevbos(); -/* - if (model_data_pool) - { - neddestroypool(model_data_pool); - model_data_pool = NULL; - } -*/ + /* + if (model_data_pool) + { + neddestroypool(model_data_pool); + model_data_pool = NULL; + } + */ } void clearskins() @@ -137,27 +137,27 @@ void clearskins() m = models[i]; if (m->mdnum == 1) { - voxmodel_t *v = (voxmodel_t*)m; + voxmodel_t *v = (voxmodel_t *)m; for (j=0; jtexid[j]) bglDeleteTextures(1,(GLuint*)&v->texid[j]); + if (v->texid[j]) bglDeleteTextures(1,(GLuint *)&v->texid[j]); v->texid[j] = 0; } } else if (m->mdnum == 2 || m->mdnum == 3) { - md2model_t *m2 = (md2model_t*)m; + md2model_t *m2 = (md2model_t *)m; mdskinmap_t *sk; for (j=0; jnumskins*(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; } for (sk=m2->skinmap; sk; sk=sk->next) 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; } } @@ -165,10 +165,10 @@ void clearskins() for (i=0; itexid[j]) bglDeleteTextures(1,(GLuint*)&v->texid[j]); + if (v->texid[j]) bglDeleteTextures(1,(GLuint *)&v->texid[j]); v->texid[j] = 0; } } @@ -191,7 +191,7 @@ int32_t md_loadmodel(const char *fn) 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; } @@ -272,7 +272,7 @@ int32_t md_defineframe(int32_t modelid, const char *framename, int32_t tilenume, return 0; } - i = framename2index((mdmodel_t*)m,framename); + i = framename2index((mdmodel_t *)m,framename); if (i == m->numframes) return(-3); // frame name invalid 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; //find index of start frame - i = framename2index((mdmodel_t*)m,framestart); + i = framename2index((mdmodel_t *)m,framestart); if (i == m->numframes) return -2; ma.startframe = i; //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; ma.endframe = i; ma.fpssc = fpssc; ma.flags = flags; - map = (mdanim_t*)Bcalloc(1,sizeof(mdanim_t)); + map = (mdanim_t *)Bcalloc(1,sizeof(mdanim_t)); if (!map) return(-4); Bmemcpy(map, &ma, sizeof(ma)); @@ -576,7 +576,7 @@ int32_t mdloadskin_trytexcache(char *fn, int32_t len, int32_t pal, char effect, Blseek(cachefilehandle, cachepos, BSEEK_SET); if (Bread(cachefilehandle, head, sizeof(texcacheheader)) < (int32_t)sizeof(texcacheheader)) { - cachepos += sizeof(texcacheheader); + cachepos += sizeof(texcacheheader); err = 1; goto failure; } @@ -789,15 +789,15 @@ int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf) willprint = 1; 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); //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; else if (!hasalpha) intexfmt = GL_RGB; if (glinfo.bgra) texfmt = GL_BGRA; - uploadtexture((doalloc&1), xsiz, ysiz, intexfmt, texfmt, (coltype*)fptr, xsiz, ysiz, 0|8192); - Bfree((void*)fptr); + uploadtexture((doalloc&1), xsiz, ysiz, intexfmt, texfmt, (coltype *)fptr, xsiz, ysiz, 0|8192); + Bfree((void *)fptr); } 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]); } - for (i = head.numtris-1; i>=0; i--) - { - 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[2] = B_LITTLE16(m->tris[i].v[2]); - 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[2] = B_LITTLE16(m->tris[i].u[2]); - } - for(i = head.numuv-1; i>=0; i--) - { - m->uv[i].u = B_LITTLE16(m->uv[i].u); - m->uv[i].v = B_LITTLE16(m->uv[i].v); - } + for (i = head.numtris-1; i>=0; i--) + { + 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[2] = B_LITTLE16(m->tris[i].v[2]); + 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[2] = B_LITTLE16(m->tris[i].u[2]); + } + for (i = head.numuv-1; i>=0; i--) + { + m->uv[i].u = B_LITTLE16(m->uv[i].u); + m->uv[i].v = B_LITTLE16(m->uv[i].v); + } } #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); } s->shaders = (md3shader_t *)(((intptr_t)s->tris)+leng[0]); - s->uv = (md3uv_t *)(((intptr_t)s->shaders)+leng[1]); - s->xyzn = (md3xyzn_t *)(((intptr_t)s->uv)+leng[2]); + s->uv = (md3uv_t *)(((intptr_t)s->shaders)+leng[1]); + 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[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--) { - l = (int32_t*)&s->uv[i].u; + l = (int32_t *)&s->uv[i].u; l[0] = B_LITTLE32(l[0]); l[1] = B_LITTLE32(l[1]); } @@ -1490,7 +1490,7 @@ static md3model_t *md3load(int32_t fil) return(m); } -static inline void invertmatrix(float* m, float* out) +static inline void invertmatrix(float *m, float *out) { 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]); } -static inline void normalize(float* vec) +static inline void normalize(float *vec) { double norm; @@ -1526,7 +1526,7 @@ static inline void normalize(float* vec) vec[2] *= norm; } -static void md3postload_common(md3model_t* m) +static void md3postload_common(md3model_t *m) { int framei, surfi, verti; 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 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[2] >= s->numverts || s->tris[trii].i[2] < 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) + { // corrupt model OSD_Printf("Triangle index out of bounds!\n"); return 0; @@ -1660,7 +1661,7 @@ static int md3postload_polymer_check(md3model_t *m) } #endif -int md3postload_polymer(md3model_t* m) +int md3postload_polymer(md3model_t *m) { #ifdef POLYMER 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 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[2] >= s->numverts || s->tris[trii].i[2] < 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) + { // corrupt model Bfree(numtris); OSD_Printf("Triangle index out of bounds!\n"); @@ -1724,20 +1726,20 @@ int md3postload_polymer(md3model_t* m) framei = 0; while (framei < m->head.numframes) { - vec1[0] = s->geometry[(framei * s->numverts * 15) + (s->tris[trii].i[1] * 15) + 0] - + vec1[0] = s->geometry[(framei * s->numverts * 15) + (s->tris[trii].i[1] * 15) + 0] - s->geometry[(framei * s->numverts * 15) + (s->tris[trii].i[0] * 15) + 0]; - vec1[1] = s->geometry[(framei * s->numverts * 15) + (s->tris[trii].i[1] * 15) + 1] - + vec1[1] = s->geometry[(framei * s->numverts * 15) + (s->tris[trii].i[1] * 15) + 1] - s->geometry[(framei * s->numverts * 15) + (s->tris[trii].i[0] * 15) + 1]; - vec1[2] = s->geometry[(framei * s->numverts * 15) + (s->tris[trii].i[1] * 15) + 2] - + vec1[2] = s->geometry[(framei * s->numverts * 15) + (s->tris[trii].i[1] * 15) + 2] - s->geometry[(framei * s->numverts * 15) + (s->tris[trii].i[0] * 15) + 2]; vec1[3] = s->uv[s->tris[trii].i[1]].u - s->uv[s->tris[trii].i[0]].u; vec1[4] = s->uv[s->tris[trii].i[1]].v - s->uv[s->tris[trii].i[0]].v; - vec2[0] = s->geometry[(framei * s->numverts * 15) + (s->tris[trii].i[2] * 15) + 0] - + vec2[0] = s->geometry[(framei * s->numverts * 15) + (s->tris[trii].i[2] * 15) + 0] - s->geometry[(framei * s->numverts * 15) + (s->tris[trii].i[1] * 15) + 0]; - vec2[1] = s->geometry[(framei * s->numverts * 15) + (s->tris[trii].i[2] * 15) + 1] - + vec2[1] = s->geometry[(framei * s->numverts * 15) + (s->tris[trii].i[2] * 15) + 1] - s->geometry[(framei * s->numverts * 15) + (s->tris[trii].i[1] * 15) + 1]; - vec2[2] = s->geometry[(framei * s->numverts * 15) + (s->tris[trii].i[2] * 15) + 2] - + vec2[2] = s->geometry[(framei * s->numverts * 15) + (s->tris[trii].i[2] * 15) + 2] - s->geometry[(framei * s->numverts * 15) + (s->tris[trii].i[1] * 15) + 2]; vec2[3] = s->uv[s->tris[trii].i[2]].u - s->uv[s->tris[trii].i[1]].u; vec2[4] = s->uv[s->tris[trii].i[2]].v - s->uv[s->tris[trii].i[1]].v; @@ -1816,9 +1818,9 @@ static int32_t md3draw(md3model_t *m, spritetype *tspr) int32_t texunits = GL_TEXTURE0_ARB; mdskinmap_t *sk; //PLAG : sorting stuff - void* vbotemp; - point3d* vertexhandle = NULL; - uint16_t* indexhandle; + void *vbotemp; + point3d *vertexhandle = NULL; + uint16_t *indexhandle; char lpal = (tspr->owner >= MAXSPRITES) ? tspr->pal : sprite[tspr->owner].pal; 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.. 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) { 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); bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_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 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); kread(fil,&i,4); klseek(fil,0,SEEK_SET); @@ -3217,30 +3219,30 @@ mdmodel_t *mdload(const char *filnam) { case 0x32504449: // 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 case 0x33504449: - vm = (mdmodel_t*)md3load(fil); + vm = (mdmodel_t *)md3load(fil); break; //IDP3 default: - vm = (mdmodel_t*)0; break; + vm = (mdmodel_t *)0; break; } kclose(fil); if (vm) { - md3postload_common((md3model_t*)vm); + md3postload_common((md3model_t *)vm); #ifdef POLYMER // implies defined(POLYMOST) && defined(USE_OPENGL)? if (glrendmode==4) - i = md3postload_polymer((md3model_t*)vm); + i = md3postload_polymer((md3model_t *)vm); else - i = md3postload_polymer_check((md3model_t*)vm); + i = md3postload_polymer_check((md3model_t *)vm); if (!i) { mdfree(vm); - vm = (mdmodel_t*)0; + vm = (mdmodel_t *)0; } #endif } diff --git a/polymer/eduke32/build/src/nedmalloc.c b/polymer/eduke32/build/src/nedmalloc.c index 3ab973742..aedc99222 100644 --- a/polymer/eduke32/build/src/nedmalloc.c +++ b/polymer/eduke32/build/src/nedmalloc.c @@ -49,40 +49,40 @@ DEALINGS IN THE SOFTWARE. #include "nedmalloc.h" #if defined(_WIN32) - #include +#include #endif #if defined(__linux__) || defined(__FreeBSD__) /* Sadly we can't include as it causes a redefinition error */ extern size_t malloc_usable_size(void *); #endif #if USE_ALLOCATOR==1 - #define MSPACES 1 - #define ONLY_MSPACES 1 +#define MSPACES 1 +#define ONLY_MSPACES 1 #endif #define USE_DL_PREFIX 1 #ifndef USE_LOCKS - #define USE_LOCKS 1 +#define USE_LOCKS 1 #endif #define FOOTERS 1 /* Need to enable footers so frees lock the right mspace */ #ifndef NEDMALLOC_DEBUG - #if defined(DEBUG) || defined(_DEBUG) - #define NEDMALLOC_DEBUG 1 - #else - #define NEDMALLOC_DEBUG 0 - #endif +#if defined(DEBUG) || defined(_DEBUG) +#define NEDMALLOC_DEBUG 1 +#else +#define NEDMALLOC_DEBUG 0 +#endif #endif /* We need to consistently define DEBUG=0|1, _DEBUG and NDEBUG for dlmalloc */ #undef DEBUG #undef _DEBUG #if NEDMALLOC_DEBUG - #define _DEBUG - #define DEBUG 1 +#define _DEBUG +#define DEBUG 1 #else - #define DEBUG 0 +#define DEBUG 0 #endif #ifdef NDEBUG /* Disable assert checking on release builds */ - #undef DEBUG - #undef _DEBUG +#undef DEBUG +#undef _DEBUG #endif /* The default of 64Kb means we spend too much time kernel-side */ #ifndef DEFAULT_GRANULARITY @@ -96,13 +96,13 @@ extern size_t malloc_usable_size(void *); #include "malloc.c.h" #ifdef NDEBUG /* Disable assert checking on release builds */ - #undef DEBUG +#undef DEBUG #elif !NEDMALLOC_DEBUG - #ifdef __GNUC__ - #warning DEBUG is defined so allocator will run with assert checking! Define NDEBUG to run at full speed. - #elif defined(_MSC_VER) - #pragma message(__FILE__ ": WARNING: DEBUG is defined so allocator will run with assert checking! Define NDEBUG to run at full speed.") - #endif +#ifdef __GNUC__ +#warning DEBUG is defined so allocator will run with assert checking! Define NDEBUG to run at full speed. +#elif defined(_MSC_VER) +#pragma message(__FILE__ ": WARNING: DEBUG is defined so allocator will run with assert checking! Define NDEBUG to run at full speed.") +#endif #endif /* The maximum concurrent threads in a pool possible */ @@ -117,11 +117,11 @@ extern size_t malloc_usable_size(void *); #ifndef THREADCACHEMAX #define THREADCACHEMAX 8192 #elif THREADCACHEMAX && !defined(THREADCACHEMAXBINS) - #ifdef __GNUC__ - #warning If you are changing THREADCACHEMAX, do you also need to change THREADCACHEMAXBINS=(topbitpos(THREADCACHEMAX)-4)? - #elif defined(_MSC_VER) - #pragma message(__FILE__ ": WARNING: If you are changing THREADCACHEMAX, do you also need to change THREADCACHEMAXBINS=(topbitpos(THREADCACHEMAX)-4)?") - #endif +#ifdef __GNUC__ +#warning If you are changing THREADCACHEMAX, do you also need to change THREADCACHEMAXBINS=(topbitpos(THREADCACHEMAX)-4)? +#elif defined(_MSC_VER) +#pragma message(__FILE__ ": WARNING: If you are changing THREADCACHEMAX, do you also need to change THREADCACHEMAXBINS=(topbitpos(THREADCACHEMAX)-4)?") +#endif #endif #ifndef THREADCACHEMAXBINS #ifdef FINEGRAINEDBINS @@ -140,39 +140,40 @@ extern size_t malloc_usable_size(void *); #if USE_LOCKS #ifdef WIN32 - #define TLSVAR DWORD - #define TLSALLOC(k) (*(k)=TlsAlloc(), TLS_OUT_OF_INDEXES==*(k)) - #define TLSFREE(k) (!TlsFree(k)) - #define TLSGET(k) TlsGetValue(k) - #define TLSSET(k, a) (!TlsSetValue(k, a)) - #ifdef DEBUG +#define TLSVAR DWORD +#define TLSALLOC(k) (*(k)=TlsAlloc(), TLS_OUT_OF_INDEXES==*(k)) +#define TLSFREE(k) (!TlsFree(k)) +#define TLSGET(k) TlsGetValue(k) +#define TLSSET(k, a) (!TlsSetValue(k, a)) +#ifdef DEBUG static LPVOID ChkedTlsGetValue(DWORD idx) { - LPVOID ret=TlsGetValue(idx); - assert(S_OK==GetLastError()); - return ret; + LPVOID ret=TlsGetValue(idx); + assert(S_OK==GetLastError()); + return ret; } - #undef TLSGET - #define TLSGET(k) ChkedTlsGetValue(k) - #endif +#undef TLSGET +#define TLSGET(k) ChkedTlsGetValue(k) +#endif #else - #define TLSVAR pthread_key_t - #define TLSALLOC(k) pthread_key_create(k, 0) - #define TLSFREE(k) pthread_key_delete(k) - #define TLSGET(k) pthread_getspecific(k) - #define TLSSET(k, a) pthread_setspecific(k, a) +#define TLSVAR pthread_key_t +#define TLSALLOC(k) pthread_key_create(k, 0) +#define TLSFREE(k) pthread_key_delete(k) +#define TLSGET(k) pthread_getspecific(k) +#define TLSSET(k, a) pthread_setspecific(k, a) #endif #else /* Probably if you're not using locks then you don't want ANY pthread stuff at all */ - #define TLSVAR void * - #define TLSALLOC(k) (*k=0) - #define TLSFREE(k) (k=0) - #define TLSGET(k) k - #define TLSSET(k, a) (k=a, 0) +#define TLSVAR void * +#define TLSALLOC(k) (*k=0) +#define TLSFREE(k) (k=0) +#define TLSGET(k) k +#define TLSSET(k, a) (k=a, 0) #endif #if defined(__cplusplus) #if !defined(NO_NED_NAMESPACE) -namespace nedalloc { +namespace nedalloc +{ #else extern "C" { #endif @@ -181,9 +182,9 @@ extern "C" { #if USE_ALLOCATOR==0 static void *unsupported_operation(const char *opname) THROWSPEC { - fprintf(stderr, "nedmalloc: The operation %s is not supported under this build configuration\n", opname); - abort(); - return 0; + fprintf(stderr, "nedmalloc: The operation %s is not supported under this build configuration\n", opname); + abort(); + return 0; } static size_t mspacecounter=(size_t) 0xdeadbeef; #endif @@ -204,241 +205,244 @@ void *(*sysrealloc)(void *, size_t)=realloc; void (*sysfree)(void *)=free; size_t (*sysblksize)(void *)= #ifdef WIN32 - /* This is the MSVCRT equivalent */ - _msize; + /* This is the MSVCRT equivalent */ + _msize; #elif defined(__linux__) || defined(__FreeBSD__) - /* This is the glibc/ptmalloc2/dlmalloc equivalent. */ - malloc_usable_size; + /* This is the glibc/ptmalloc2/dlmalloc equivalent. */ + malloc_usable_size; #elif defined(__APPLE__) - /* This is the BSD libc equivalent. */ - malloc_size; + /* This is the BSD libc equivalent. */ + malloc_size; #else #error Cannot tolerate the memory allocator of an unknown system! #endif static FORCEINLINE NEDMALLOCNOALIASATTR NEDMALLOCPTRATTR void *CallMalloc(void *RESTRICT mspace, size_t size, size_t alignment) THROWSPEC { - void *RESTRICT ret=0; - size_t _alignment=alignment; + void *RESTRICT ret=0; + size_t _alignment=alignment; #if USE_MAGIC_HEADERS - size_t *_ret=0; - size+=alignment+3*sizeof(size_t); - _alignment=0; + size_t *_ret=0; + size+=alignment+3*sizeof(size_t); + _alignment=0; #endif #if USE_ALLOCATOR==0 - ret=sysmalloc(size); /* magic headers takes care of alignment */ + ret=sysmalloc(size); /* magic headers takes care of alignment */ #elif USE_ALLOCATOR==1 - ret=_alignment ? mspace_memalign((mstate) mspace, _alignment, size) : mspace_malloc((mstate) mspace, size); + ret=_alignment ? mspace_memalign((mstate) mspace, _alignment, size) : mspace_malloc((mstate) mspace, size); #ifndef ENABLE_FAST_HEAP_DETECTION - if(ret) - { - size_t truesize=chunksize(mem2chunk(ret)); - if(!leastusedaddress || (void *)((mstate) mspace)->least_addrleast_addr; - if(!largestusedblock || truesize>largestusedblock) largestusedblock=(truesize+mparams.page_size) & ~(mparams.page_size-1); - } + if (ret) + { + size_t truesize=chunksize(mem2chunk(ret)); + if (!leastusedaddress || (void *)((mstate) mspace)->least_addrleast_addr; + if (!largestusedblock || truesize>largestusedblock) largestusedblock=(truesize+mparams.page_size) & ~(mparams.page_size-1); + } #endif #endif - if(!ret) return 0; + if (!ret) return 0; #if USE_MAGIC_HEADERS - _ret=(size_t *) ret; - ret=(void *)(_ret+3); - if(alignment) ret=(void *)(((size_t) ret+alignment-1)&~(alignment-1)); - for(; _ret<(size_t *)ret-2; _ret++) *_ret=*(size_t *)"NEDMALOC"; - _ret[0]=(size_t) mspace; - _ret[1]=size-3*sizeof(size_t); + _ret=(size_t *) ret; + ret=(void *)(_ret+3); + if (alignment) ret=(void *)(((size_t) ret+alignment-1)&~(alignment-1)); + for (; _ret<(size_t *)ret-2; _ret++) *_ret=*(size_t *)"NEDMALOC"; + _ret[0]=(size_t) mspace; + _ret[1]=size-3*sizeof(size_t); #endif - return ret; + return ret; } static FORCEINLINE NEDMALLOCNOALIASATTR NEDMALLOCPTRATTR void *CallCalloc(void *RESTRICT mspace, size_t size, size_t alignment) THROWSPEC { - void *RESTRICT ret=0; + void *RESTRICT ret=0; #if USE_MAGIC_HEADERS - size_t *_ret=0; - size+=alignment+3*sizeof(size_t); + size_t *_ret=0; + size+=alignment+3*sizeof(size_t); #endif #if USE_ALLOCATOR==0 - ret=syscalloc(1, size); + ret=syscalloc(1, size); #elif USE_ALLOCATOR==1 - ret=mspace_calloc((mstate) mspace, 1, size); + ret=mspace_calloc((mstate) mspace, 1, size); #ifndef ENABLE_FAST_HEAP_DETECTION - if(ret) - { - size_t truesize=chunksize(mem2chunk(ret)); - if(!leastusedaddress || (void *)((mstate) mspace)->least_addrleast_addr; - if(!largestusedblock || truesize>largestusedblock) largestusedblock=(truesize+mparams.page_size) & ~(mparams.page_size-1); - } + if (ret) + { + size_t truesize=chunksize(mem2chunk(ret)); + if (!leastusedaddress || (void *)((mstate) mspace)->least_addrleast_addr; + if (!largestusedblock || truesize>largestusedblock) largestusedblock=(truesize+mparams.page_size) & ~(mparams.page_size-1); + } #endif #endif - if(!ret) return 0; + if (!ret) return 0; #if USE_MAGIC_HEADERS - _ret=(size_t *) ret; - ret=(void *)(_ret+3); - if(alignment) ret=(void *)(((size_t) ret+alignment-1)&~(alignment-1)); - for(; _ret<(size_t *)ret-2; _ret++) *_ret=*(size_t *) "NEDMALOC"; - _ret[0]=(size_t) mspace; - _ret[1]=size-3*sizeof(size_t); + _ret=(size_t *) ret; + ret=(void *)(_ret+3); + if (alignment) ret=(void *)(((size_t) ret+alignment-1)&~(alignment-1)); + for (; _ret<(size_t *)ret-2; _ret++) *_ret=*(size_t *) "NEDMALOC"; + _ret[0]=(size_t) mspace; + _ret[1]=size-3*sizeof(size_t); #endif - return ret; + return ret; } static FORCEINLINE NEDMALLOCNOALIASATTR NEDMALLOCPTRATTR void *CallRealloc(void *RESTRICT mspace, void *RESTRICT mem, int isforeign, size_t oldsize, size_t newsize) THROWSPEC { - void *RESTRICT ret=0; + void *RESTRICT ret=0; #if USE_MAGIC_HEADERS - mstate oldmspace=0; - size_t *_ret=0, *_mem=(size_t *) mem-3; + mstate oldmspace=0; + size_t *_ret=0, *_mem=(size_t *) mem-3; #endif - if(isforeign) - { /* Transfer */ + if (isforeign) + { + /* Transfer */ #if USE_MAGIC_HEADERS - assert(_mem[0]!=*(size_t *) "NEDMALOC"); + assert(_mem[0]!=*(size_t *) "NEDMALOC"); #endif - if((ret=CallMalloc(mspace, newsize, 0))) - { + if ((ret=CallMalloc(mspace, newsize, 0))) + { #if defined(DEBUG) - printf("*** nedmalloc frees system allocated block %p\n", mem); + printf("*** nedmalloc frees system allocated block %p\n", mem); #endif - memcpy(ret, mem, oldsize=_mem[2]); - for(; *_mem==*(size_t *) "NEDMALOC"; *_mem--=*(size_t *) "nedmaloc"); - mem=(void *)(++_mem); + assert(_mem[0]==*(size_t *) "NEDMALOC"); + newsize+=3*sizeof(size_t); + oldmspace=(mstate) _mem[1]; + assert(oldsize>=_mem[2]); + for (; *_mem==*(size_t *) "NEDMALOC"; *_mem--=*(size_t *) "nedmaloc"); + mem=(void *)(++_mem); #endif #if USE_ALLOCATOR==0 - ret=sysrealloc(mem, newsize); + ret=sysrealloc(mem, newsize); #elif USE_ALLOCATOR==1 - ret=mspace_realloc((mstate) mspace, mem, newsize); + ret=mspace_realloc((mstate) mspace, mem, newsize); #ifndef ENABLE_FAST_HEAP_DETECTION - if(ret) - { - size_t truesize=chunksize(mem2chunk(ret)); - if(!largestusedblock || truesize>largestusedblock) largestusedblock=(truesize+mparams.page_size) & ~(mparams.page_size-1); - } + if (ret) + { + size_t truesize=chunksize(mem2chunk(ret)); + if (!largestusedblock || truesize>largestusedblock) largestusedblock=(truesize+mparams.page_size) & ~(mparams.page_size-1); + } #endif #endif - if(!ret) - { /* Put it back the way it was */ + if (!ret) + { + /* Put it back the way it was */ #if USE_MAGIC_HEADERS - for(; *_mem==0; *_mem++=*(size_t *) "NEDMALOC"); + for (; *_mem==0; *_mem++=*(size_t *) "NEDMALOC"); #endif - return 0; - } + return 0; + } #if USE_MAGIC_HEADERS - _ret=(size_t *) ret; - ret=(void *)(_ret+3); - for(; _ret<(size_t *)ret-2; _ret++) *_ret=*(size_t *) "NEDMALOC"; - _ret[0]=(size_t) mspace; - _ret[1]=newsize-3*sizeof(size_t); + _ret=(size_t *) ret; + ret=(void *)(_ret+3); + for (; _ret<(size_t *)ret-2; _ret++) *_ret=*(size_t *) "NEDMALOC"; + _ret[0]=(size_t) mspace; + _ret[1]=newsize-3*sizeof(size_t); #endif - return ret; + return ret; } static FORCEINLINE void CallFree(void *RESTRICT mspace, void *RESTRICT mem, int isforeign) THROWSPEC { #if USE_MAGIC_HEADERS - mstate oldmspace=0; - size_t *_mem=(size_t *) mem-3, oldsize=0; + mstate oldmspace=0; + size_t *_mem=(size_t *) mem-3, oldsize=0; #endif - if(isforeign) - { + if (isforeign) + { #if USE_MAGIC_HEADERS - assert(_mem[0]!=*(size_t *) "NEDMALOC"); + assert(_mem[0]!=*(size_t *) "NEDMALOC"); #endif #if defined(DEBUG) - printf("*** nedmalloc frees system allocated block %p\n", mem); + printf("*** nedmalloc frees system allocated block %p\n", mem); #endif - sysfree(mem); - return; - } + sysfree(mem); + return; + } #if USE_MAGIC_HEADERS - assert(_mem[0]==*(size_t *) "NEDMALOC"); - oldmspace=(mstate) _mem[1]; - oldsize=_mem[2]; - for(; *_mem==*(size_t *) "NEDMALOC"; *_mem--=*(size_t *) "nedmaloc"); - mem=(void *)(++_mem); + assert(_mem[0]==*(size_t *) "NEDMALOC"); + oldmspace=(mstate) _mem[1]; + oldsize=_mem[2]; + for (; *_mem==*(size_t *) "NEDMALOC"; *_mem--=*(size_t *) "nedmaloc"); + mem=(void *)(++_mem); #endif #if USE_ALLOCATOR==0 - sysfree(mem); + sysfree(mem); #elif USE_ALLOCATOR==1 - mspace_free((mstate) mspace, mem); + mspace_free((mstate) mspace, mem); #endif } static NEDMALLOCNOALIASATTR mstate nedblkmstate(void *RESTRICT mem) THROWSPEC { - if(mem) - { + if (mem) + { #if USE_MAGIC_HEADERS - size_t *_mem=(size_t *) mem-3; - if(_mem[0]==*(size_t *) "NEDMALOC") - { - return (mstate) _mem[1]; - } - else return 0; + size_t *_mem=(size_t *) mem-3; + if (_mem[0]==*(size_t *) "NEDMALOC") + { + return (mstate) _mem[1]; + } + else return 0; #else #if USE_ALLOCATOR==0 - /* Fail everything */ - return 0; + /* Fail everything */ + return 0; #elif USE_ALLOCATOR==1 #ifdef ENABLE_FAST_HEAP_DETECTION #ifdef WIN32 - /* On Windows for RELEASE both x86 and x64 the NT heap precedes each block with an eight byte header - which looks like: - normal: 4 bytes of size, 4 bytes of [char < 64, char < 64, char < 64 bit 0 always set, char random ] - mmaped: 4 bytes of size 4 bytes of [zero, zero, 0xb, zero ] + /* On Windows for RELEASE both x86 and x64 the NT heap precedes each block with an eight byte header + which looks like: + normal: 4 bytes of size, 4 bytes of [char < 64, char < 64, char < 64 bit 0 always set, char random ] + mmaped: 4 bytes of size 4 bytes of [zero, zero, 0xb, zero ] - On Windows for DEBUG both x86 and x64 the preceding four bytes is always 0xfdfdfdfd (no man's land). - */ + On Windows for DEBUG both x86 and x64 the preceding four bytes is always 0xfdfdfdfd (no man's land). + */ #pragma pack(push, 1) - struct _HEAP_ENTRY - { - USHORT Size; - USHORT PreviousSize; - UCHAR Cookie; /* SegmentIndex */ - UCHAR Flags; /* always bit 0 (HEAP_ENTRY_BUSY). bit 1=(HEAP_ENTRY_EXTRA_PRESENT), bit 2=normal block (HEAP_ENTRY_FILL_PATTERN), bit 3=mmap block (HEAP_ENTRY_VIRTUAL_ALLOC). Bit 4 (HEAP_ENTRY_LAST_ENTRY) could be set */ - UCHAR UnusedBytes; - UCHAR SmallTagIndex; /* fastbin index. Always one of 0x02, 0x03, 0x04 < 0x80 */ - } *RESTRICT he=((struct _HEAP_ENTRY *) mem)-1; + struct _HEAP_ENTRY + { + USHORT Size; + USHORT PreviousSize; + UCHAR Cookie; /* SegmentIndex */ + UCHAR Flags; /* always bit 0 (HEAP_ENTRY_BUSY). bit 1=(HEAP_ENTRY_EXTRA_PRESENT), bit 2=normal block (HEAP_ENTRY_FILL_PATTERN), bit 3=mmap block (HEAP_ENTRY_VIRTUAL_ALLOC). Bit 4 (HEAP_ENTRY_LAST_ENTRY) could be set */ + UCHAR UnusedBytes; + UCHAR SmallTagIndex; /* fastbin index. Always one of 0x02, 0x03, 0x04 < 0x80 */ + } *RESTRICT he=((struct _HEAP_ENTRY *) mem)-1; #pragma pack(pop) - unsigned int header=((unsigned int *)mem)[-1], mask1=0x8080E100, result1, mask2=0xFFFFFF06, result2; - result1=header & mask1; /* Positive testing for NT heap */ - result2=header & mask2; /* Positive testing for dlmalloc */ - if(result1==0x00000100 && result2!=0x00000102) - { /* This is likely a NT heap block */ - return 0; - } + unsigned int header=((unsigned int *)mem)[-1], mask1=0x8080E100, result1, mask2=0xFFFFFF06, result2; + result1=header & mask1; /* Positive testing for NT heap */ + result2=header & mask2; /* Positive testing for dlmalloc */ + if (result1==0x00000100 && result2!=0x00000102) + { + /* This is likely a NT heap block */ + return 0; + } #endif #ifdef __linux__ - /* On Linux glibc uses ptmalloc2 (really dlmalloc) just as we do, but prev_foot contains rubbish - when the preceding block is allocated because ptmalloc2 finds the local mstate by rounding the ptr - down to the nearest megabyte. It's like dlmalloc with FOOTERS disabled. */ - mchunkptr p=mem2chunk(mem); - mstate fm=get_mstate_for(p); - /* If it's a ptmalloc2 block, fm is likely to be some crazy value */ - if(!is_aligned(fm)) return 0; - if((size_t)mem-(size_t)fm>=(size_t)1<<(SIZE_T_BITSIZE-1)) return 0; - if(ok_magic(fm)) - return fm; - else - return 0; - if(1) { } + /* On Linux glibc uses ptmalloc2 (really dlmalloc) just as we do, but prev_foot contains rubbish + when the preceding block is allocated because ptmalloc2 finds the local mstate by rounding the ptr + down to the nearest megabyte. It's like dlmalloc with FOOTERS disabled. */ + mchunkptr p=mem2chunk(mem); + mstate fm=get_mstate_for(p); + /* If it's a ptmalloc2 block, fm is likely to be some crazy value */ + if (!is_aligned(fm)) return 0; + if ((size_t)mem-(size_t)fm>=(size_t)1<<(SIZE_T_BITSIZE-1)) return 0; + if (ok_magic(fm)) + return fm; + else + return 0; + if (1) { } #endif - else - { - mchunkptr p=mem2chunk(mem); - mstate fm=get_mstate_for(p); - assert(ok_magic(fm)); /* If this fails, someone tried to free a block twice */ - if(ok_magic(fm)) - return fm; - } + else + { + mchunkptr p=mem2chunk(mem); + mstate fm=get_mstate_for(p); + assert(ok_magic(fm)); /* If this fails, someone tried to free a block twice */ + if (ok_magic(fm)) + return fm; + } #else #ifdef WIN32 #ifdef _MSC_VER @@ -448,45 +452,45 @@ static NEDMALLOCNOALIASATTR mstate nedblkmstate(void *RESTRICT mem) THROWSPEC #endif #endif { - /* We try to return zero here if it isn't one of our own blocks, however - the current block annotation scheme used by dlmalloc makes it impossible - to be absolutely sure of avoiding a segfault. + /* We try to return zero here if it isn't one of our own blocks, however + the current block annotation scheme used by dlmalloc makes it impossible + to be absolutely sure of avoiding a segfault. - mchunkptr->prev_foot = mem-(2*size_t) = mstate ^ mparams.magic for PRECEDING block; - mchunkptr->head = mem-(1*size_t) = 8 multiple size of this block with bottom three bits = FLAG_BITS - FLAG_BITS = bit 0 is CINUSE (currently in use unless is mmap), bit 1 is PINUSE (previous block currently - in use unless mmap), bit 2 is UNUSED and currently is always zero. - */ - register void *RESTRICT leastusedaddress_=leastusedaddress; /* Cache these to avoid register reloading */ - register size_t largestusedblock_=largestusedblock; - if(!is_aligned(mem)) return 0; /* Would fail very rarely as all allocators return aligned blocks */ - if(memhead & FLAG4_BIT)) return 0; - /* Reduced uncertainty by 0.5^2 = 25.0% */ - /* size should never exceed largestusedblock */ - if(chunksize(p)>largestusedblock_) return 0; - /* Reduced uncertainty by a minimum of 0.5^3 = 12.5%, maximum 0.5^16 = 0.0015% */ - /* Having sanity checked prev_foot and head, check next block */ - if(!ismmapped && (!next_pinuse(p) || (next_chunk(p)->head & FLAG4_BIT))) return 0; - /* Reduced uncertainty by 0.5^5 = 3.13% or 0.5^18 = 0.00038% */ - #if 0 - /* If previous block is free, check that its next block pointer equals us */ - if(!ismmapped && !pinuse(p)) - if(next_chunk(prev_chunk(p))!=p) return 0; - /* We could start comparing prev_foot's for similarity but it starts getting slow. */ - #endif - fm = get_mstate_for(p); - if(!is_aligned(fm) || (void *)fm=(size_t)1<<(SIZE_T_BITSIZE-1)) return 0; - assert(ok_magic(fm)); /* If this fails, someone tried to free a block twice */ - if(ok_magic(fm)) - return fm; - } - } + mchunkptr->prev_foot = mem-(2*size_t) = mstate ^ mparams.magic for PRECEDING block; + mchunkptr->head = mem-(1*size_t) = 8 multiple size of this block with bottom three bits = FLAG_BITS + FLAG_BITS = bit 0 is CINUSE (currently in use unless is mmap), bit 1 is PINUSE (previous block currently + in use unless mmap), bit 2 is UNUSED and currently is always zero. + */ + register void *RESTRICT leastusedaddress_=leastusedaddress; /* Cache these to avoid register reloading */ + register size_t largestusedblock_=largestusedblock; + if (!is_aligned(mem)) return 0; /* Would fail very rarely as all allocators return aligned blocks */ + if (memhead &FLAG4_BIT)) return 0; + /* Reduced uncertainty by 0.5^2 = 25.0% */ + /* size should never exceed largestusedblock */ + if (chunksize(p)>largestusedblock_) return 0; + /* Reduced uncertainty by a minimum of 0.5^3 = 12.5%, maximum 0.5^16 = 0.0015% */ + /* Having sanity checked prev_foot and head, check next block */ + if (!ismmapped && (!next_pinuse(p) || (next_chunk(p)->head &FLAG4_BIT))) return 0; + /* Reduced uncertainty by 0.5^5 = 3.13% or 0.5^18 = 0.00038% */ +#if 0 + /* If previous block is free, check that its next block pointer equals us */ + if (!ismmapped && !pinuse(p)) + if (next_chunk(prev_chunk(p))!=p) return 0; + /* We could start comparing prev_foot's for similarity but it starts getting slow. */ +#endif + fm = get_mstate_for(p); + if (!is_aligned(fm) || (void *)fm=(size_t)1<<(SIZE_T_BITSIZE-1)) return 0; + assert(ok_magic(fm)); /* If this fails, someone tried to free a block twice */ + if (ok_magic(fm)) + return fm; + } + } #ifdef WIN32 #ifdef _MSC_VER __except(1) { } @@ -497,52 +501,52 @@ static NEDMALLOCNOALIASATTR mstate nedblkmstate(void *RESTRICT mem) THROWSPEC #endif #endif #endif - } - return 0; + } + return 0; } NEDMALLOCNOALIASATTR size_t nedblksize(int *RESTRICT isforeign, void *RESTRICT mem) THROWSPEC { - if(mem) - { - if(isforeign) *isforeign=1; + if (mem) + { + if (isforeign) *isforeign=1; #if USE_MAGIC_HEADERS - { - size_t *_mem=(size_t *) mem-3; - if(_mem[0]==*(size_t *) "NEDMALOC") - { - mstate mspace=(mstate) _mem[1]; - size_t size=_mem[2]; - if(isforeign) *isforeign=0; - return size; - } - } + { + size_t *_mem=(size_t *) mem-3; + if (_mem[0]==*(size_t *) "NEDMALOC") + { + mstate mspace=(mstate) _mem[1]; + size_t size=_mem[2]; + if (isforeign) *isforeign=0; + return size; + } + } #elif USE_ALLOCATOR==1 - if(nedblkmstate(mem)) - { - mchunkptr p=mem2chunk(mem); - if(isforeign) *isforeign=0; - return chunksize(p)-overhead_for(p); - } + if (nedblkmstate(mem)) + { + mchunkptr p=mem2chunk(mem); + if (isforeign) *isforeign=0; + return chunksize(p)-overhead_for(p); + } #ifdef DEBUG - else - { - int a=1; /* Set breakpoints here if needed */ - } + else + { + int a=1; /* Set breakpoints here if needed */ + } #endif #endif #if defined(ENABLE_TOLERANT_NEDMALLOC) || USE_ALLOCATOR==0 - return sysblksize(mem); + return sysblksize(mem); #endif - } - return 0; + } + return 0; } NEDMALLOCNOALIASATTR void nedsetvalue(void *v) THROWSPEC { nedpsetvalue((nedpool *) 0, v); } -NEDMALLOCNOALIASATTR NEDMALLOCPTRATTR void * nedmalloc(size_t size) THROWSPEC { return nedpmalloc((nedpool *) 0, size); } -NEDMALLOCNOALIASATTR NEDMALLOCPTRATTR void * nedcalloc(size_t no, size_t size) THROWSPEC { return nedpcalloc((nedpool *) 0, no, size); } -NEDMALLOCNOALIASATTR NEDMALLOCPTRATTR void * nedrealloc(void *mem, size_t size) THROWSPEC { return nedprealloc((nedpool *) 0, mem, size); } +NEDMALLOCNOALIASATTR NEDMALLOCPTRATTR void *nedmalloc(size_t size) THROWSPEC { return nedpmalloc((nedpool *) 0, size); } +NEDMALLOCNOALIASATTR NEDMALLOCPTRATTR void *nedcalloc(size_t no, size_t size) THROWSPEC { return nedpcalloc((nedpool *) 0, no, size); } +NEDMALLOCNOALIASATTR NEDMALLOCPTRATTR void *nedrealloc(void *mem, size_t size) THROWSPEC { return nedprealloc((nedpool *) 0, mem, size); } NEDMALLOCNOALIASATTR void nedfree(void *mem) THROWSPEC { nedpfree((nedpool *) 0, mem); } -NEDMALLOCNOALIASATTR NEDMALLOCPTRATTR void * nedmemalign(size_t alignment, size_t bytes) THROWSPEC { return nedpmemalign((nedpool *) 0, alignment, bytes); } +NEDMALLOCNOALIASATTR NEDMALLOCPTRATTR void *nedmemalign(size_t alignment, size_t bytes) THROWSPEC { return nedpmemalign((nedpool *) 0, alignment, bytes); } NEDMALLOCNOALIASATTR struct nedmallinfo nedmallinfo(void) THROWSPEC { return nedpmallinfo((nedpool *) 0); } NEDMALLOCNOALIASATTR int nedmallopt(int parno, int value) THROWSPEC { return nedpmallopt((nedpool *) 0, parno, value); } NEDMALLOCNOALIASATTR int nedmalloc_trim(size_t pad) THROWSPEC { return nedpmalloc_trim((nedpool *) 0, pad); } @@ -554,389 +558,393 @@ NEDMALLOCNOALIASATTR NEDMALLOCPTRATTR void **nedindependent_comalloc(size_t elem struct threadcacheblk_t; typedef struct threadcacheblk_t threadcacheblk; struct threadcacheblk_t -{ /* Keep less than 16 bytes on 32 bit systems and 32 bytes on 64 bit systems */ +{ + /* Keep less than 16 bytes on 32 bit systems and 32 bytes on 64 bit systems */ #ifdef FULLSANITYCHECKS - unsigned int magic; + unsigned int magic; #endif - unsigned int lastUsed, size; - threadcacheblk *next, *prev; + unsigned int lastUsed, size; + threadcacheblk *next, *prev; }; typedef struct threadcache_t { #ifdef FULLSANITYCHECKS - unsigned int magic1; + unsigned int magic1; #endif - int mymspace; /* Last mspace entry this thread used */ - long threadid; - unsigned int mallocs, frees, successes; - size_t freeInCache; /* How much free space is stored in this cache */ - threadcacheblk *bins[(THREADCACHEMAXBINS+1)*2]; + int mymspace; /* Last mspace entry this thread used */ + long threadid; + unsigned int mallocs, frees, successes; + size_t freeInCache; /* How much free space is stored in this cache */ + threadcacheblk *bins[(THREADCACHEMAXBINS+1)*2]; #ifdef FULLSANITYCHECKS - unsigned int magic2; + unsigned int magic2; #endif } threadcache; struct nedpool_t { #if USE_LOCKS - MLOCK_T mutex; + MLOCK_T mutex; #endif - void *uservalue; - int threads; /* Max entries in m to use */ - threadcache *caches[THREADCACHEMAXCACHES]; - TLSVAR mycache; /* Thread cache for this thread. 0 for unset, negative for use mspace-1 directly, otherwise is cache-1 */ - mstate m[MAXTHREADSINPOOL+1]; /* mspace entries for this pool */ + void *uservalue; + int threads; /* Max entries in m to use */ + threadcache *caches[THREADCACHEMAXCACHES]; + TLSVAR mycache; /* Thread cache for this thread. 0 for unset, negative for use mspace-1 directly, otherwise is cache-1 */ + mstate m[MAXTHREADSINPOOL+1]; /* mspace entries for this pool */ }; static nedpool syspool; static FORCEINLINE NEDMALLOCNOALIASATTR unsigned int size2binidx(size_t _size) THROWSPEC -{ /* 8=1000 16=10000 20=10100 24=11000 32=100000 48=110000 4096=1000000000000 */ - unsigned int topbit, size=(unsigned int)(_size>>4); - /* 16=1 20=1 24=1 32=10 48=11 64=100 96=110 128=1000 4096=100000000 */ +{ + /* 8=1000 16=10000 20=10100 24=11000 32=100000 48=110000 4096=1000000000000 */ + unsigned int topbit, size=(unsigned int)(_size>>4); + /* 16=1 20=1 24=1 32=10 48=11 64=100 96=110 128=1000 4096=100000000 */ #if defined(__GNUC__) - topbit = sizeof(size)*__CHAR_BIT__ - 1 - __builtin_clz(size); + topbit = sizeof(size)*__CHAR_BIT__ - 1 - __builtin_clz(size); #elif defined(_MSC_VER) && _MSC_VER>=1300 - { - unsigned long bsrTopBit; + { + unsigned long bsrTopBit; - _BitScanReverse(&bsrTopBit, size); + _BitScanReverse(&bsrTopBit, size); - topbit = bsrTopBit; - } + topbit = bsrTopBit; + } #else #if 0 - union { - unsigned asInt[2]; - double asDouble; - }; - int n; + union { + unsigned asInt[2]; + double asDouble; + }; + int n; - asDouble = (double)size + 0.5; - topbit = (asInt[!FOX_BIGENDIAN] >> 20) - 1023; + asDouble = (double)size + 0.5; + topbit = (asInt[!FOX_BIGENDIAN] >> 20) - 1023; #else - { - unsigned int x=size; - x = x | (x >> 1); - x = x | (x >> 2); - x = x | (x >> 4); - x = x | (x >> 8); - x = x | (x >>16); - x = ~x; - x = x - ((x >> 1) & 0x55555555); - x = (x & 0x33333333) + ((x >> 2) & 0x33333333); - x = (x + (x >> 4)) & 0x0F0F0F0F; - x = x + (x << 8); - x = x + (x << 16); - topbit=31 - (x >> 24); - } + { + unsigned int x=size; + x = x | (x >> 1); + x = x | (x >> 2); + x = x | (x >> 4); + x = x | (x >> 8); + x = x | (x >>16); + x = ~x; + x = x - ((x >> 1) & 0x55555555); + x = (x & 0x33333333) + ((x >> 2) & 0x33333333); + x = (x + (x >> 4)) & 0x0F0F0F0F; + x = x + (x << 8); + x = x + (x << 16); + topbit=31 - (x >> 24); + } #endif #endif - return topbit; + return topbit; } #ifdef FULLSANITYCHECKS static void tcsanitycheck(threadcacheblk **ptr) THROWSPEC { - assert((ptr[0] && ptr[1]) || (!ptr[0] && !ptr[1])); - if(ptr[0] && ptr[1]) - { - assert(nedblksize(ptr[0])>=sizeof(threadcacheblk)); - assert(nedblksize(ptr[1])>=sizeof(threadcacheblk)); - assert(*(unsigned int *) "NEDN"==ptr[0]->magic); - assert(*(unsigned int *) "NEDN"==ptr[1]->magic); - assert(!ptr[0]->prev); - assert(!ptr[1]->next); - if(ptr[0]==ptr[1]) - { - assert(!ptr[0]->next); - assert(!ptr[1]->prev); - } - } + assert((ptr[0] && ptr[1]) || (!ptr[0] && !ptr[1])); + if (ptr[0] && ptr[1]) + { + assert(nedblksize(ptr[0])>=sizeof(threadcacheblk)); + assert(nedblksize(ptr[1])>=sizeof(threadcacheblk)); + assert(*(unsigned int *) "NEDN"==ptr[0]->magic); + assert(*(unsigned int *) "NEDN"==ptr[1]->magic); + assert(!ptr[0]->prev); + assert(!ptr[1]->next); + if (ptr[0]==ptr[1]) + { + assert(!ptr[0]->next); + assert(!ptr[1]->prev); + } + } } static void tcfullsanitycheck(threadcache *tc) THROWSPEC { - threadcacheblk **tcbptr=tc->bins; - int n; - for(n=0; n<=THREADCACHEMAXBINS; n++, tcbptr+=2) - { - threadcacheblk *b, *ob=0; - tcsanitycheck(tcbptr); - for(b=tcbptr[0]; b; ob=b, b=b->next) - { - assert(*(unsigned int *) "NEDN"==b->magic); - assert(!ob || ob->next==b); - assert(!ob || b->prev==ob); - } - } + threadcacheblk **tcbptr=tc->bins; + int n; + for (n=0; n<=THREADCACHEMAXBINS; n++, tcbptr+=2) + { + threadcacheblk *b, *ob=0; + tcsanitycheck(tcbptr); + for (b=tcbptr[0]; b; ob=b, b=b->next) + { + assert(*(unsigned int *) "NEDN"==b->magic); + assert(!ob || ob->next==b); + assert(!ob || b->prev==ob); + } + } } #endif static NOINLINE void RemoveCacheEntries(nedpool *RESTRICT p, threadcache *RESTRICT tc, unsigned int age) THROWSPEC { #ifdef FULLSANITYCHECKS - tcfullsanitycheck(tc); + tcfullsanitycheck(tc); #endif - if(tc->freeInCache) - { - threadcacheblk **tcbptr=tc->bins; - int n; - for(n=0; n<=THREADCACHEMAXBINS; n++, tcbptr+=2) - { - threadcacheblk **tcb=tcbptr+1; /* come from oldest end of list */ - /*tcsanitycheck(tcbptr);*/ - for(; *tcb && tc->frees-(*tcb)->lastUsed>=age; ) - { - threadcacheblk *f=*tcb; - size_t blksize=f->size; /*nedblksize(f);*/ - assert(blksize<=nedblksize(0, f)); - assert(blksize); + if (tc->freeInCache) + { + threadcacheblk **tcbptr=tc->bins; + int n; + for (n=0; n<=THREADCACHEMAXBINS; n++, tcbptr+=2) + { + threadcacheblk **tcb=tcbptr+1; /* come from oldest end of list */ + /*tcsanitycheck(tcbptr);*/ + for (; *tcb && tc->frees-(*tcb)->lastUsed>=age;) + { + threadcacheblk *f=*tcb; + size_t blksize=f->size; /*nedblksize(f);*/ + assert(blksize<=nedblksize(0, f)); + assert(blksize); #ifdef FULLSANITYCHECKS - assert(*(unsigned int *) "NEDN"==(*tcb)->magic); + assert(*(unsigned int *) "NEDN"==(*tcb)->magic); #endif - *tcb=(*tcb)->prev; - if(*tcb) - (*tcb)->next=0; - else - *tcbptr=0; - tc->freeInCache-=blksize; - assert((long) tc->freeInCache>=0); - CallFree(0, f, 0); - /*tcsanitycheck(tcbptr);*/ - } - } - } + *tcb=(*tcb)->prev; + if (*tcb) + (*tcb)->next=0; + else + *tcbptr=0; + tc->freeInCache-=blksize; + assert((long) tc->freeInCache>=0); + CallFree(0, f, 0); + /*tcsanitycheck(tcbptr);*/ + } + } + } #ifdef FULLSANITYCHECKS - tcfullsanitycheck(tc); + tcfullsanitycheck(tc); #endif } static void DestroyCaches(nedpool *RESTRICT p) THROWSPEC { - if(p->caches) - { - threadcache *tc; - int n; - for(n=0; ncaches[n])) - { - tc->frees++; - RemoveCacheEntries(p, tc, 0); - assert(!tc->freeInCache); - tc->mymspace=-1; - tc->threadid=0; - CallFree(0, tc, 0); - p->caches[n]=0; - } - } - } + if (p->caches) + { + threadcache *tc; + int n; + for (n=0; ncaches[n])) + { + tc->frees++; + RemoveCacheEntries(p, tc, 0); + assert(!tc->freeInCache); + tc->mymspace=-1; + tc->threadid=0; + CallFree(0, tc, 0); + p->caches[n]=0; + } + } + } } static NOINLINE threadcache *AllocCache(nedpool *RESTRICT p) THROWSPEC { - threadcache *tc=0; - int n, end; + threadcache *tc=0; + int n, end; #if USE_LOCKS - ACQUIRE_LOCK(&p->mutex); + ACQUIRE_LOCK(&p->mutex); #endif - for(n=0; ncaches[n]; n++); - if(THREADCACHEMAXCACHES==n) - { /* List exhausted, so disable for this thread */ + for (n=0; ncaches[n]; n++); + if (THREADCACHEMAXCACHES==n) + { + /* List exhausted, so disable for this thread */ #if USE_LOCKS - RELEASE_LOCK(&p->mutex); + RELEASE_LOCK(&p->mutex); #endif - return 0; - } - tc=p->caches[n]=(threadcache *) CallCalloc(p->m[0], sizeof(threadcache), 0); - if(!tc) - { + return 0; + } + tc=p->caches[n]=(threadcache *) CallCalloc(p->m[0], sizeof(threadcache), 0); + if (!tc) + { #if USE_LOCKS - RELEASE_LOCK(&p->mutex); + RELEASE_LOCK(&p->mutex); #endif - return 0; - } + return 0; + } #ifdef FULLSANITYCHECKS - tc->magic1=*(unsigned int *)"NEDMALC1"; - tc->magic2=*(unsigned int *)"NEDMALC2"; + tc->magic1=*(unsigned int *)"NEDMALC1"; + tc->magic2=*(unsigned int *)"NEDMALC2"; #endif - tc->threadid= + tc->threadid= #if USE_LOCKS - (long)(size_t)CURRENT_THREAD; + (long)(size_t)CURRENT_THREAD; #else - 1; + 1; #endif - for(end=0; p->m[end]; end++); - tc->mymspace=abs(tc->threadid) % end; + for (end=0; p->m[end]; end++); + tc->mymspace=abs(tc->threadid) % end; #if USE_LOCKS - RELEASE_LOCK(&p->mutex); + RELEASE_LOCK(&p->mutex); #endif - if(TLSSET(p->mycache, (void *)(size_t)(n+1))) abort(); - return tc; + if (TLSSET(p->mycache, (void *)(size_t)(n+1))) abort(); + return tc; } static void *threadcache_malloc(nedpool *RESTRICT p, threadcache *RESTRICT tc, size_t *RESTRICT _size) THROWSPEC { - void *RESTRICT ret=0; - size_t size=*_size, blksize=0; - unsigned int bestsize; - unsigned int idx=size2binidx(size); - threadcacheblk *RESTRICT blk, **RESTRICT binsptr; + void *RESTRICT ret=0; + size_t size=*_size, blksize=0; + unsigned int bestsize; + unsigned int idx=size2binidx(size); + threadcacheblk *RESTRICT blk, * *RESTRICT binsptr; #ifdef FULLSANITYCHECKS - tcfullsanitycheck(tc); + tcfullsanitycheck(tc); #endif - /* Calculate best fit bin size */ - bestsize=1<<(idx+4); + /* Calculate best fit bin size */ + bestsize=1<<(idx+4); #ifdef FINEGRAINEDBINS - /* Finer grained bin fit */ - idx<<=1; - if(size>bestsize) - { - idx++; - bestsize+=bestsize>>1; - } - if(size>bestsize) - { - idx++; - bestsize=1<<(4+(idx>>1)); - } + /* Finer grained bin fit */ + idx<<=1; + if (size>bestsize) + { + idx++; + bestsize+=bestsize>>1; + } + if (size>bestsize) + { + idx++; + bestsize=1<<(4+(idx>>1)); + } #else - if(size>bestsize) - { - idx++; - bestsize<<=1; - } + if (size>bestsize) + { + idx++; + bestsize<<=1; + } #endif - assert(bestsize>=size); - if(sizebins[idx*2]; - /* Try to match close, but move up a bin if necessary */ - blk=*binsptr; - if(!blk || blk->sizesize; /*nedblksize(blk);*/ - assert(nedblksize(0, blk)>=blksize); - assert(blksize>=size); - if(blk->next) - blk->next->prev=0; - *binsptr=blk->next; - if(!*binsptr) - binsptr[1]=0; + assert(bestsize>=size); + if (sizebins[idx*2]; + /* Try to match close, but move up a bin if necessary */ + blk=*binsptr; + if (!blk || blk->sizesize; /*nedblksize(blk);*/ + assert(nedblksize(0, blk)>=blksize); + assert(blksize>=size); + if (blk->next) + blk->next->prev=0; + *binsptr=blk->next; + if (!*binsptr) + binsptr[1]=0; #ifdef FULLSANITYCHECKS - blk->magic=0; + blk->magic=0; #endif - assert(binsptr[0]!=blk && binsptr[1]!=blk); - assert(nedblksize(0, blk)>=sizeof(threadcacheblk) && nedblksize(0, blk)<=THREADCACHEMAX+CHUNK_OVERHEAD); - /*printf("malloc: %p, %p, %p, %lu\n", p, tc, blk, (long) _size);*/ - ret=(void *) blk; - } - ++tc->mallocs; - if(ret) - { - assert(blksize>=size); - ++tc->successes; - tc->freeInCache-=blksize; - assert((long) tc->freeInCache>=0); - } + assert(binsptr[0]!=blk && binsptr[1]!=blk); + assert(nedblksize(0, blk)>=sizeof(threadcacheblk) && nedblksize(0, blk)<=THREADCACHEMAX+CHUNK_OVERHEAD); + /*printf("malloc: %p, %p, %p, %lu\n", p, tc, blk, (long) _size);*/ + ret=(void *) blk; + } + ++tc->mallocs; + if (ret) + { + assert(blksize>=size); + ++tc->successes; + tc->freeInCache-=blksize; + assert((long) tc->freeInCache>=0); + } #if defined(DEBUG) && 0 - if(!(tc->mallocs & 0xfff)) - { - printf("*** threadcache=%u, mallocs=%u (%f), free=%u (%f), freeInCache=%u\n", (unsigned int) tc->threadid, tc->mallocs, - (float) tc->successes/tc->mallocs, tc->frees, (float) tc->successes/tc->frees, (unsigned int) tc->freeInCache); - } + if (!(tc->mallocs & 0xfff)) + { + printf("*** threadcache=%u, mallocs=%u (%f), free=%u (%f), freeInCache=%u\n", (unsigned int) tc->threadid, tc->mallocs, + (float) tc->successes/tc->mallocs, tc->frees, (float) tc->successes/tc->frees, (unsigned int) tc->freeInCache); + } #endif #ifdef FULLSANITYCHECKS - tcfullsanitycheck(tc); + tcfullsanitycheck(tc); #endif - *_size=size; - return ret; + *_size=size; + return ret; } static NOINLINE void ReleaseFreeInCache(nedpool *RESTRICT p, threadcache *RESTRICT tc, int mymspace) THROWSPEC { - unsigned int age=THREADCACHEMAXFREESPACE/8192; + unsigned int age=THREADCACHEMAXFREESPACE/8192; #if USE_LOCKS - /*ACQUIRE_LOCK(&p->m[mymspace]->mutex);*/ + /*ACQUIRE_LOCK(&p->m[mymspace]->mutex);*/ #endif - while(age && tc->freeInCache>=THREADCACHEMAXFREESPACE) - { - RemoveCacheEntries(p, tc, age); - /*printf("*** Removing cache entries older than %u (%u)\n", age, (unsigned int) tc->freeInCache);*/ - age>>=1; - } + while (age && tc->freeInCache>=THREADCACHEMAXFREESPACE) + { + RemoveCacheEntries(p, tc, age); + /*printf("*** Removing cache entries older than %u (%u)\n", age, (unsigned int) tc->freeInCache);*/ + age>>=1; + } #if USE_LOCKS - /*RELEASE_LOCK(&p->m[mymspace]->mutex);*/ + /*RELEASE_LOCK(&p->m[mymspace]->mutex);*/ #endif } static void threadcache_free(nedpool *RESTRICT p, threadcache *RESTRICT tc, int mymspace, void *RESTRICT mem, size_t size) THROWSPEC { - unsigned int bestsize; - unsigned int idx=size2binidx(size); - threadcacheblk **RESTRICT binsptr, *RESTRICT tck=(threadcacheblk *) mem; - assert(size>=sizeof(threadcacheblk) && size<=THREADCACHEMAX+CHUNK_OVERHEAD); + unsigned int bestsize; + unsigned int idx=size2binidx(size); + threadcacheblk **RESTRICT binsptr, *RESTRICT tck=(threadcacheblk *) mem; + assert(size>=sizeof(threadcacheblk) && size<=THREADCACHEMAX+CHUNK_OVERHEAD); #ifdef DEBUG - /* Make sure this is a valid memory block */ - assert(nedblksize(0, mem)); + /* Make sure this is a valid memory block */ + assert(nedblksize(0, mem)); #endif #ifdef FULLSANITYCHECKS - tcfullsanitycheck(tc); + tcfullsanitycheck(tc); #endif - /* Calculate best fit bin size */ - bestsize=1<<(idx+4); + /* Calculate best fit bin size */ + bestsize=1<<(idx+4); #ifdef FINEGRAINEDBINS - /* Finer grained bin fit */ - idx<<=1; - if(size>bestsize) - { - unsigned int biggerbestsize=bestsize+bestsize<<1; - if(size>=biggerbestsize) - { - idx++; - bestsize=biggerbestsize; - } - } + /* Finer grained bin fit */ + idx<<=1; + if (size>bestsize) + { + unsigned int biggerbestsize=bestsize+bestsize<<1; + if (size>=biggerbestsize) + { + idx++; + bestsize=biggerbestsize; + } + } #endif - if(bestsize!=size) /* dlmalloc can round up, so we round down to preserve indexing */ - size=bestsize; - binsptr=&tc->bins[idx*2]; - assert(idx<=THREADCACHEMAXBINS); - if(tck==*binsptr) - { - fprintf(stderr, "nedmalloc: Attempt to free already freed memory block %p - aborting!\n", tck); - abort(); - } + if (bestsize!=size) /* dlmalloc can round up, so we round down to preserve indexing */ + size=bestsize; + binsptr=&tc->bins[idx*2]; + assert(idx<=THREADCACHEMAXBINS); + if (tck==*binsptr) + { + fprintf(stderr, "nedmalloc: Attempt to free already freed memory block %p - aborting!\n", tck); + abort(); + } #ifdef FULLSANITYCHECKS - tck->magic=*(unsigned int *) "NEDN"; + tck->magic=*(unsigned int *) "NEDN"; #endif - tck->lastUsed=++tc->frees; - tck->size=(unsigned int) size; - tck->next=*binsptr; - tck->prev=0; - if(tck->next) - tck->next->prev=tck; - else - binsptr[1]=tck; - assert(!*binsptr || (*binsptr)->size==tck->size); - *binsptr=tck; - assert(tck==tc->bins[idx*2]); - assert(tc->bins[idx*2+1]==tck || binsptr[0]->next->prev==tck); - /*printf("free: %p, %p, %p, %lu\n", p, tc, mem, (long) size);*/ - tc->freeInCache+=size; + tck->lastUsed=++tc->frees; + tck->size=(unsigned int) size; + tck->next=*binsptr; + tck->prev=0; + if (tck->next) + tck->next->prev=tck; + else + binsptr[1]=tck; + assert(!*binsptr || (*binsptr)->size==tck->size); + *binsptr=tck; + assert(tck==tc->bins[idx*2]); + assert(tc->bins[idx*2+1]==tck || binsptr[0]->next->prev==tck); + /*printf("free: %p, %p, %p, %lu\n", p, tc, mem, (long) size);*/ + tc->freeInCache+=size; #ifdef FULLSANITYCHECKS - tcfullsanitycheck(tc); + tcfullsanitycheck(tc); #endif #if 1 - if(tc->freeInCache>=THREADCACHEMAXFREESPACE) - ReleaseFreeInCache(p, tc, mymspace); + if (tc->freeInCache>=THREADCACHEMAXFREESPACE) + ReleaseFreeInCache(p, tc, mymspace); #endif } @@ -944,113 +952,116 @@ static void threadcache_free(nedpool *RESTRICT p, threadcache *RESTRICT tc, int static NOINLINE int InitPool(nedpool *RESTRICT p, size_t capacity, int threads) THROWSPEC -{ /* threads is -1 for system pool */ - ensure_initialization(); - ACQUIRE_MALLOC_GLOBAL_LOCK(); - if(p->threads) goto done; +{ + /* threads is -1 for system pool */ + ensure_initialization(); + ACQUIRE_MALLOC_GLOBAL_LOCK(); + if (p->threads) goto done; #if USE_LOCKS - if(INITIAL_LOCK(&p->mutex)) goto err; + if (INITIAL_LOCK(&p->mutex)) goto err; #endif - if(TLSALLOC(&p->mycache)) goto err; + if (TLSALLOC(&p->mycache)) goto err; #if USE_ALLOCATOR==0 - p->m[0]=(mstate) mspacecounter++; + p->m[0]=(mstate) mspacecounter++; #elif USE_ALLOCATOR==1 - if(!(p->m[0]=(mstate) create_mspace(capacity, 1))) goto err; - p->m[0]->extp=p; + if (!(p->m[0]=(mstate) create_mspace(capacity, 1))) goto err; + p->m[0]->extp=p; #endif - p->threads=(threads<1 || threads>MAXTHREADSINPOOL) ? MAXTHREADSINPOOL : threads; + p->threads=(threads<1 || threads>MAXTHREADSINPOOL) ? MAXTHREADSINPOOL : threads; done: - RELEASE_MALLOC_GLOBAL_LOCK(); - return 1; + RELEASE_MALLOC_GLOBAL_LOCK(); + return 1; err: - if(threads<0) - abort(); /* If you can't allocate for system pool, we're screwed */ - DestroyCaches(p); - if(p->m[0]) - { + if (threads<0) + abort(); /* If you can't allocate for system pool, we're screwed */ + DestroyCaches(p); + if (p->m[0]) + { #if USE_ALLOCATOR==1 - destroy_mspace(p->m[0]); + destroy_mspace(p->m[0]); #endif - p->m[0]=0; - } - if(p->mycache) - { - if(TLSFREE(p->mycache)) abort(); - p->mycache=0; - } - RELEASE_MALLOC_GLOBAL_LOCK(); - return 0; + p->m[0]=0; + } + if (p->mycache) + { + if (TLSFREE(p->mycache)) abort(); + p->mycache=0; + } + RELEASE_MALLOC_GLOBAL_LOCK(); + return 0; } static NOINLINE mstate FindMSpace(nedpool *RESTRICT p, threadcache *RESTRICT tc, int *RESTRICT lastUsed, size_t size) THROWSPEC -{ /* Gets called when thread's last used mspace is in use. The strategy - is to run through the list of all available mspaces looking for an - unlocked one and if we fail, we create a new one so long as we don't - exceed p->threads */ - int n, end; - n=end=*lastUsed+1; +{ + /* Gets called when thread's last used mspace is in use. The strategy + is to run through the list of all available mspaces looking for an + unlocked one and if we fail, we create a new one so long as we don't + exceed p->threads */ + int n, end; + n=end=*lastUsed+1; #if USE_LOCKS - for(; p->m[n]; end=++n) - { - if(TRY_LOCK(&p->m[n]->mutex)) goto found; - } - for(n=0; n<*lastUsed && p->m[n]; n++) - { - if(TRY_LOCK(&p->m[n]->mutex)) goto found; - } - if(endthreads) - { - mstate temp; + for (; p->m[n]; end=++n) + { + if (TRY_LOCK(&p->m[n]->mutex)) goto found; + } + for (n=0; n<*lastUsed && p->m[n]; n++) + { + if (TRY_LOCK(&p->m[n]->mutex)) goto found; + } + if (endthreads) + { + mstate temp; #if USE_ALLOCATOR==0 - temp=(mstate) mspacecounter++; + temp=(mstate) mspacecounter++; #elif USE_ALLOCATOR==1 - if(!(temp=(mstate) create_mspace(size, 1))) - goto badexit; + if (!(temp=(mstate) create_mspace(size, 1))) + goto badexit; #endif - /* Now we're ready to modify the lists, we lock */ - ACQUIRE_LOCK(&p->mutex); - while(p->m[end] && endthreads) - end++; - if(end>=p->threads) - { /* Drat, must destroy it now */ - RELEASE_LOCK(&p->mutex); + /* Now we're ready to modify the lists, we lock */ + ACQUIRE_LOCK(&p->mutex); + while (p->m[end] && endthreads) + end++; + if (end>=p->threads) + { + /* Drat, must destroy it now */ + RELEASE_LOCK(&p->mutex); #if USE_ALLOCATOR==1 - destroy_mspace((mstate) temp); + destroy_mspace((mstate) temp); #endif - goto badexit; - } - /* We really want to make sure this goes into memory now but we - have to be careful of breaking aliasing rules, so write it twice */ - *((volatile struct malloc_state **) &p->m[end])=p->m[end]=temp; - ACQUIRE_LOCK(&p->m[end]->mutex); - /*printf("Created mspace idx %d\n", end);*/ - RELEASE_LOCK(&p->mutex); - n=end; - goto found; - } - /* Let it lock on the last one it used */ + goto badexit; + } + /* We really want to make sure this goes into memory now but we + have to be careful of breaking aliasing rules, so write it twice */ + *((volatile struct malloc_state **) &p->m[end])=p->m[end]=temp; + ACQUIRE_LOCK(&p->m[end]->mutex); + /*printf("Created mspace idx %d\n", end);*/ + RELEASE_LOCK(&p->mutex); + n=end; + goto found; + } + /* Let it lock on the last one it used */ badexit: - ACQUIRE_LOCK(&p->m[*lastUsed]->mutex); - return p->m[*lastUsed]; + ACQUIRE_LOCK(&p->m[*lastUsed]->mutex); + return p->m[*lastUsed]; #endif found: - *lastUsed=n; - if(tc) - tc->mymspace=n; - else - { - if(TLSSET(p->mycache, (void *)(size_t)(-(n+1)))) abort(); - } - return p->m[n]; + *lastUsed=n; + if (tc) + tc->mymspace=n; + else + { + if (TLSSET(p->mycache, (void *)(size_t)(-(n+1)))) abort(); + } + return p->m[n]; } typedef struct PoolList_t { - size_t size; /* Size of list */ - size_t length; /* Actual entries in list */ + size_t size; /* Size of list */ + size_t length; /* Actual entries in list */ #ifdef DEBUG - nedpool *list[1]; /* Force testing of list expansion */ + nedpool *list[1]; /* Force testing of list expansion */ #else - nedpool *list[16]; + nedpool *list[16]; #endif } PoolList; #if USE_LOCKS @@ -1059,180 +1070,182 @@ static MLOCK_T poollistlock; static PoolList *poollist; NEDMALLOCPTRATTR nedpool *nedcreatepool(size_t capacity, int threads) THROWSPEC { - nedpool *ret=0; - if(!poollist) - { - PoolList *newpoollist=0; - if(!(newpoollist=(PoolList *) nedpcalloc(0, 1, sizeof(PoolList)+sizeof(nedpool *)))) return 0; + nedpool *ret=0; + if (!poollist) + { + PoolList *newpoollist=0; + if (!(newpoollist=(PoolList *) nedpcalloc(0, 1, sizeof(PoolList)+sizeof(nedpool *)))) return 0; #if USE_LOCKS - INITIAL_LOCK(&poollistlock); - ACQUIRE_LOCK(&poollistlock); + INITIAL_LOCK(&poollistlock); + ACQUIRE_LOCK(&poollistlock); #endif - poollist=newpoollist; - poollist->size=sizeof(poollist->list)/sizeof(nedpool *); - } + poollist=newpoollist; + poollist->size=sizeof(poollist->list)/sizeof(nedpool *); + } #if USE_LOCKS - else - ACQUIRE_LOCK(&poollistlock); + else + ACQUIRE_LOCK(&poollistlock); #endif - if(poollist->length==poollist->size) - { - PoolList *newpoollist=0; - size_t newsize=0; - newsize=sizeof(PoolList)+(poollist->size+1)*sizeof(nedpool *); - if(!(newpoollist=(PoolList *) nedprealloc(0, poollist, newsize))) goto badexit; - poollist=newpoollist; - memset(&poollist->list[poollist->size], 0, newsize-((size_t)&poollist->list[poollist->size]-(size_t)&poollist->list[0])); - poollist->size=((newsize-((char *)&poollist->list[0]-(char *)poollist))/sizeof(nedpool *))-1; - assert(poollist->size>poollist->length); - } - if(!(ret=(nedpool *) nedpcalloc(0, 1, sizeof(nedpool)))) goto badexit; - if(!InitPool(ret, capacity, threads)) - { - nedpfree(0, ret); - goto badexit; - } - poollist->list[poollist->length++]=ret; + if (poollist->length==poollist->size) + { + PoolList *newpoollist=0; + size_t newsize=0; + newsize=sizeof(PoolList)+(poollist->size+1)*sizeof(nedpool *); + if (!(newpoollist=(PoolList *) nedprealloc(0, poollist, newsize))) goto badexit; + poollist=newpoollist; + memset(&poollist->list[poollist->size], 0, newsize-((size_t)&poollist->list[poollist->size]-(size_t)&poollist->list[0])); + poollist->size=((newsize-((char *)&poollist->list[0]-(char *)poollist))/sizeof(nedpool *))-1; + assert(poollist->size>poollist->length); + } + if (!(ret=(nedpool *) nedpcalloc(0, 1, sizeof(nedpool)))) goto badexit; + if (!InitPool(ret, capacity, threads)) + { + nedpfree(0, ret); + goto badexit; + } + poollist->list[poollist->length++]=ret; badexit: - { + { #if USE_LOCKS - RELEASE_LOCK(&poollistlock); + RELEASE_LOCK(&poollistlock); #endif - } - return ret; + } + return ret; } void neddestroypool(nedpool *p) THROWSPEC { - unsigned int n; + unsigned int n; #if USE_LOCKS - ACQUIRE_LOCK(&p->mutex); + ACQUIRE_LOCK(&p->mutex); #endif - DestroyCaches(p); - for(n=0; p->m[n]; n++) - { + DestroyCaches(p); + for (n=0; p->m[n]; n++) + { #if USE_ALLOCATOR==1 - destroy_mspace(p->m[n]); + destroy_mspace(p->m[n]); #endif - p->m[n]=0; - } + p->m[n]=0; + } #if USE_LOCKS - RELEASE_LOCK(&p->mutex); + RELEASE_LOCK(&p->mutex); #endif - if(TLSFREE(p->mycache)) abort(); - nedpfree(0, p); + if (TLSFREE(p->mycache)) abort(); + nedpfree(0, p); #if USE_LOCKS - ACQUIRE_LOCK(&poollistlock); + ACQUIRE_LOCK(&poollistlock); #endif - assert(poollist); - for(n=0; nlength && poollist->list[n]!=p; n++); - assert(n!=poollist->length); - memmove(&poollist->list[n], &poollist->list[n+1], (size_t)&poollist->list[poollist->length]-(size_t)&poollist->list[n]); - if(!--poollist->length) - { - assert(!poollist->list[0]); - nedpfree(0, poollist); - poollist=0; - } + assert(poollist); + for (n=0; nlength && poollist->list[n]!=p; n++); + assert(n!=poollist->length); + memmove(&poollist->list[n], &poollist->list[n+1], (size_t)&poollist->list[poollist->length]-(size_t)&poollist->list[n]); + if (!--poollist->length) + { + assert(!poollist->list[0]); + nedpfree(0, poollist); + poollist=0; + } #if USE_LOCKS - RELEASE_LOCK(&poollistlock); + RELEASE_LOCK(&poollistlock); #endif } void neddestroysyspool() THROWSPEC { - nedpool *p=&syspool; - int n; + nedpool *p=&syspool; + int n; #if USE_LOCKS - ACQUIRE_LOCK(&p->mutex); + ACQUIRE_LOCK(&p->mutex); #endif - DestroyCaches(p); - for(n=0; p->m[n]; n++) - { + DestroyCaches(p); + for (n=0; p->m[n]; n++) + { #if USE_ALLOCATOR==1 - destroy_mspace(p->m[n]); + destroy_mspace(p->m[n]); #endif - p->m[n]=0; - } - /* Render syspool unusable */ - for(n=0; ncaches[n]=(threadcache *)(size_t)(sizeof(size_t)>4 ? 0xdeadbeefdeadbeefULL : 0xdeadbeefUL); - for(n=0; nm[n]=(mstate)(size_t)(sizeof(size_t)>4 ? 0xdeadbeefdeadbeefULL : 0xdeadbeefUL); - if(TLSFREE(p->mycache)) abort(); + p->m[n]=0; + } + /* Render syspool unusable */ + for (n=0; ncaches[n]=(threadcache *)(size_t)(sizeof(size_t)>4 ? 0xdeadbeefdeadbeefULL : 0xdeadbeefUL); + for (n=0; nm[n]=(mstate)(size_t)(sizeof(size_t)>4 ? 0xdeadbeefdeadbeefULL : 0xdeadbeefUL); + if (TLSFREE(p->mycache)) abort(); #if USE_LOCKS - RELEASE_LOCK(&p->mutex); + RELEASE_LOCK(&p->mutex); #endif } nedpool **nedpoollist() THROWSPEC { - nedpool **ret=0; - if(poollist) - { + nedpool **ret=0; + if (poollist) + { #if USE_LOCKS - ACQUIRE_LOCK(&poollistlock); + ACQUIRE_LOCK(&poollistlock); #endif - if(!(ret=(nedpool **) nedmalloc((poollist->length+1)*sizeof(nedpool *)))) goto badexit; - memcpy(ret, poollist->list, (poollist->length+1)*sizeof(nedpool *)); + if (!(ret=(nedpool **) nedmalloc((poollist->length+1)*sizeof(nedpool *)))) goto badexit; + memcpy(ret, poollist->list, (poollist->length+1)*sizeof(nedpool *)); badexit: - { + { #if USE_LOCKS - RELEASE_LOCK(&poollistlock); + RELEASE_LOCK(&poollistlock); #endif - } - } - return ret; + } + } + return ret; } void nedpsetvalue(nedpool *p, void *v) THROWSPEC { - if(!p) { p=&syspool; if(!syspool.threads) InitPool(&syspool, 0, -1); } - p->uservalue=v; + if (!p) { p=&syspool; if (!syspool.threads) InitPool(&syspool, 0, -1); } + p->uservalue=v; } void *nedgetvalue(nedpool **p, void *mem) THROWSPEC { - nedpool *np=0; - mstate fm=nedblkmstate(mem); - if(!fm || !fm->extp) return 0; - np=(nedpool *) fm->extp; - if(p) *p=np; - return np->uservalue; + nedpool *np=0; + mstate fm=nedblkmstate(mem); + if (!fm || !fm->extp) return 0; + np=(nedpool *) fm->extp; + if (p) *p=np; + return np->uservalue; } void nedtrimthreadcache(nedpool *p, int disable) THROWSPEC { - int mycache; - if(!p) - { - p=&syspool; - if(!syspool.threads) InitPool(&syspool, 0, -1); - } - mycache=(int)(size_t) TLSGET(p->mycache); - if(!mycache) - { /* Set to mspace 0 */ - if(disable && TLSSET(p->mycache, (void *)(size_t)-1)) abort(); - } - else if(mycache>0) - { /* Set to last used mspace */ - threadcache *tc=p->caches[mycache-1]; + int mycache; + if (!p) + { + p=&syspool; + if (!syspool.threads) InitPool(&syspool, 0, -1); + } + mycache=(int)(size_t) TLSGET(p->mycache); + if (!mycache) + { + /* Set to mspace 0 */ + if (disable && TLSSET(p->mycache, (void *)(size_t)-1)) abort(); + } + else if (mycache>0) + { + /* Set to last used mspace */ + threadcache *tc=p->caches[mycache-1]; #if defined(DEBUG) - printf("Threadcache utilisation: %lf%% in cache with %lf%% lost to other threads\n", - 100.0*tc->successes/tc->mallocs, 100.0*((double) tc->mallocs-tc->frees)/tc->mallocs); + printf("Threadcache utilisation: %lf%% in cache with %lf%% lost to other threads\n", + 100.0*tc->successes/tc->mallocs, 100.0*((double) tc->mallocs-tc->frees)/tc->mallocs); #endif - if(disable && TLSSET(p->mycache, (void *)(size_t)(-tc->mymspace))) abort(); - tc->frees++; - RemoveCacheEntries(p, tc, 0); - assert(!tc->freeInCache); - if(disable) - { - tc->mymspace=-1; - tc->threadid=0; - CallFree(0, p->caches[mycache-1], 0); - p->caches[mycache-1]=0; - } - } + if (disable && TLSSET(p->mycache, (void *)(size_t)(-tc->mymspace))) abort(); + tc->frees++; + RemoveCacheEntries(p, tc, 0); + assert(!tc->freeInCache); + if (disable) + { + tc->mymspace=-1; + tc->threadid=0; + CallFree(0, p->caches[mycache-1], 0); + p->caches[mycache-1]=0; + } + } } void neddisablethreadcache(nedpool *p) THROWSPEC { - nedtrimthreadcache(p, 1); + nedtrimthreadcache(p, 1); } #if USE_LOCKS && USE_ALLOCATOR==1 @@ -1253,299 +1266,311 @@ void neddisablethreadcache(nedpool *p) THROWSPEC #endif static FORCEINLINE mstate GetMSpace(nedpool *RESTRICT p, threadcache *RESTRICT tc, int mymspace, size_t size) THROWSPEC -{ /* Returns a locked and ready for use mspace */ - mstate m=p->m[mymspace]; - assert(m); +{ + /* Returns a locked and ready for use mspace */ + mstate m=p->m[mymspace]; + assert(m); #if USE_LOCKS && USE_ALLOCATOR==1 - if(!TRY_LOCK(&p->m[mymspace]->mutex)) m=FindMSpace(p, tc, &mymspace, size); - /*assert(IS_LOCKED(&p->m[mymspace]->mutex));*/ + if (!TRY_LOCK(&p->m[mymspace]->mutex)) m=FindMSpace(p, tc, &mymspace, size); + /*assert(IS_LOCKED(&p->m[mymspace]->mutex));*/ #endif - return m; + return m; } static NOINLINE void GetThreadCache_cold1(nedpool *RESTRICT *RESTRICT p) THROWSPEC { - *p=&syspool; - if(!syspool.threads) InitPool(&syspool, 0, -1); + *p=&syspool; + if (!syspool.threads) InitPool(&syspool, 0, -1); } static NOINLINE void GetThreadCache_cold2(nedpool *RESTRICT *RESTRICT p, threadcache *RESTRICT *RESTRICT tc, int *RESTRICT mymspace, int mycache) THROWSPEC { - if(!mycache) - { /* Need to allocate a new cache */ - *tc=AllocCache(*p); - if(!*tc) - { /* Disable */ - if(TLSSET((*p)->mycache, (void *)(size_t)-1)) abort(); - *mymspace=0; - } - else - *mymspace=(*tc)->mymspace; - } - else - { /* Cache disabled, but we do have an assigned thread pool */ - *tc=0; - *mymspace=-mycache-1; - } + if (!mycache) + { + /* Need to allocate a new cache */ + *tc=AllocCache(*p); + if (!*tc) + { + /* Disable */ + if (TLSSET((*p)->mycache, (void *)(size_t)-1)) abort(); + *mymspace=0; + } + else + *mymspace=(*tc)->mymspace; + } + else + { /* Cache disabled, but we do have an assigned thread pool */ + *tc=0; + *mymspace=-mycache-1; + } } static FORCEINLINE void GetThreadCache(nedpool *RESTRICT *RESTRICT p, threadcache *RESTRICT *RESTRICT tc, int *RESTRICT mymspace, size_t *RESTRICT size) THROWSPEC { - int mycache; - if(size && *sizemycache); - if(mycache>0) - { /* Already have a cache */ - *tc=(*p)->caches[mycache-1]; - *mymspace=(*tc)->mymspace; - } - else GetThreadCache_cold2(p, tc, mymspace, mycache); - assert(*mymspace>=0); + int mycache; + if (size && *sizemycache); + if (mycache>0) + { + /* Already have a cache */ + *tc=(*p)->caches[mycache-1]; + *mymspace=(*tc)->mymspace; + } + else GetThreadCache_cold2(p, tc, mymspace, mycache); + assert(*mymspace>=0); #if USE_LOCKS - assert(!(*tc) || (long)(size_t)CURRENT_THREAD==(*tc)->threadid); + assert(!(*tc) || (long)(size_t)CURRENT_THREAD==(*tc)->threadid); #endif #ifdef FULLSANITYCHECKS - if(*tc) - { - if(*(unsigned int *)"NEDMALC1"!=(*tc)->magic1 || *(unsigned int *)"NEDMALC2"!=(*tc)->magic2) - { - abort(); - } - } + if (*tc) + { + if (*(unsigned int *)"NEDMALC1"!=(*tc)->magic1 || *(unsigned int *)"NEDMALC2"!=(*tc)->magic2) + { + abort(); + } + } #endif } -NEDMALLOCPTRATTR void * nedpmalloc(nedpool *p, size_t size) THROWSPEC +NEDMALLOCPTRATTR void *nedpmalloc(nedpool *p, size_t size) THROWSPEC { - void *ret=0; - threadcache *tc; - int mymspace; - GetThreadCache(&p, &tc, &mymspace, &size); + void *ret=0; + threadcache *tc; + int mymspace; + GetThreadCache(&p, &tc, &mymspace, &size); #if THREADCACHEMAX - if(tc && size<=THREADCACHEMAX) - { /* Use the thread cache */ - ret=threadcache_malloc(p, tc, &size); - } + if (tc && size<=THREADCACHEMAX) + { + /* Use the thread cache */ + ret=threadcache_malloc(p, tc, &size); + } #endif - if(!ret) - { /* Use this thread's mspace */ + if (!ret) + { + /* Use this thread's mspace */ GETMSPACE(m, p, tc, mymspace, size, - ret=CallMalloc(m, size, 0)); - } - return ret; + ret=CallMalloc(m, size, 0)); + } + return ret; } -NEDMALLOCPTRATTR void * nedpcalloc(nedpool *p, size_t no, size_t size) THROWSPEC +NEDMALLOCPTRATTR void *nedpcalloc(nedpool *p, size_t no, size_t size) THROWSPEC { - size_t rsize=size*no; - void *ret=0; - threadcache *tc; - int mymspace; - GetThreadCache(&p, &tc, &mymspace, &rsize); + size_t rsize=size*no; + void *ret=0; + threadcache *tc; + int mymspace; + GetThreadCache(&p, &tc, &mymspace, &rsize); #if THREADCACHEMAX - if(tc && rsize<=THREADCACHEMAX) - { /* Use the thread cache */ - if((ret=threadcache_malloc(p, tc, &rsize))) - memset(ret, 0, rsize); - } + if (tc && rsize<=THREADCACHEMAX) + { + /* Use the thread cache */ + if ((ret=threadcache_malloc(p, tc, &rsize))) + memset(ret, 0, rsize); + } #endif - if(!ret) - { /* Use this thread's mspace */ + if (!ret) + { + /* Use this thread's mspace */ GETMSPACE(m, p, tc, mymspace, rsize, - ret=CallCalloc(m, rsize, 0)); - } - return ret; + ret=CallCalloc(m, rsize, 0)); + } + return ret; } -NEDMALLOCPTRATTR void * nedprealloc(nedpool *p, void *mem, size_t size) THROWSPEC +NEDMALLOCPTRATTR void *nedprealloc(nedpool *p, void *mem, size_t size) THROWSPEC { - void *ret=0; - threadcache *tc; - int mymspace, isforeign=1; - size_t memsize; - if(!mem) return nedpmalloc(p, size); - memsize=nedblksize(&isforeign, mem); - assert(memsize); - if(!memsize) - { - fprintf(stderr, "nedmalloc: nedprealloc() called with a block not created by nedmalloc!\n"); - abort(); - } - else if(size<=memsize && memsize-size< + void *ret=0; + threadcache *tc; + int mymspace, isforeign=1; + size_t memsize; + if (!mem) return nedpmalloc(p, size); + memsize=nedblksize(&isforeign, mem); + assert(memsize); + if (!memsize) + { + fprintf(stderr, "nedmalloc: nedprealloc() called with a block not created by nedmalloc!\n"); + abort(); + } + else if (size<=memsize && memsize-size< #ifdef DEBUG - 32 + 32 #else - 1024 + 1024 #endif - ) /* If realloc size is within 1Kb smaller than existing, noop it */ - return mem; - GetThreadCache(&p, &tc, &mymspace, &size); + ) /* If realloc size is within 1Kb smaller than existing, noop it */ + return mem; + GetThreadCache(&p, &tc, &mymspace, &size); #if THREADCACHEMAX - if(tc && size && size<=THREADCACHEMAX) - { /* Use the thread cache */ - if((ret=threadcache_malloc(p, tc, &size))) - { - memcpy(ret, mem, memsize=sizeof(threadcacheblk) && memsize<=(THREADCACHEMAX+CHUNK_OVERHEAD)) - threadcache_free(p, tc, mymspace, mem, memsize); - else - CallFree(0, mem, isforeign); - } - } + if (tc && size && size<=THREADCACHEMAX) + { + /* Use the thread cache */ + if ((ret=threadcache_malloc(p, tc, &size))) + { + memcpy(ret, mem, memsize=sizeof(threadcacheblk) && memsize<=(THREADCACHEMAX+CHUNK_OVERHEAD)) + threadcache_free(p, tc, mymspace, mem, memsize); + else + CallFree(0, mem, isforeign); + } + } #endif - if(!ret) - { /* Reallocs always happen in the mspace they happened in, so skip - locking the preferred mspace for this thread */ - ret=CallRealloc(p->m[mymspace], mem, isforeign, memsize, size); - } - return ret; + if (!ret) + { + /* Reallocs always happen in the mspace they happened in, so skip + locking the preferred mspace for this thread */ + ret=CallRealloc(p->m[mymspace], mem, isforeign, memsize, size); + } + return ret; } void nedpfree(nedpool *p, void *mem) THROWSPEC -{ /* Frees always happen in the mspace they happened in, so skip - locking the preferred mspace for this thread */ - threadcache *tc; - int mymspace, isforeign=1; - size_t memsize; - if(!mem) - { /* If you tried this on FreeBSD you'd be sorry! */ -#ifdef DEBUG - fprintf(stderr, "nedmalloc: WARNING nedpfree() called with zero. This is not portable behaviour!\n"); -#endif - return; - } - memsize=nedblksize(&isforeign, mem); - assert(memsize); - if(!memsize) - { - fprintf(stderr, "nedmalloc: nedpfree() called with a block not created by nedmalloc!\n"); - abort(); - } - GetThreadCache(&p, &tc, &mymspace, 0); -#if THREADCACHEMAX - if(mem && tc && memsize>=sizeof(threadcacheblk) && memsize<=(THREADCACHEMAX+CHUNK_OVERHEAD)) - threadcache_free(p, tc, mymspace, mem, memsize); - else -#endif - CallFree(0, mem, isforeign); -} -NEDMALLOCPTRATTR void * nedpmemalign(nedpool *p, size_t alignment, size_t bytes) THROWSPEC { - void *ret; - threadcache *tc; - int mymspace; - GetThreadCache(&p, &tc, &mymspace, &bytes); - { /* Use this thread's mspace */ + /* Frees always happen in the mspace they happened in, so skip + locking the preferred mspace for this thread */ + threadcache *tc; + int mymspace, isforeign=1; + size_t memsize; + if (!mem) + { + /* If you tried this on FreeBSD you'd be sorry! */ +#ifdef DEBUG + fprintf(stderr, "nedmalloc: WARNING nedpfree() called with zero. This is not portable behaviour!\n"); +#endif + return; + } + memsize=nedblksize(&isforeign, mem); + assert(memsize); + if (!memsize) + { + fprintf(stderr, "nedmalloc: nedpfree() called with a block not created by nedmalloc!\n"); + abort(); + } + GetThreadCache(&p, &tc, &mymspace, 0); +#if THREADCACHEMAX + if (mem && tc && memsize>=sizeof(threadcacheblk) && memsize<=(THREADCACHEMAX+CHUNK_OVERHEAD)) + threadcache_free(p, tc, mymspace, mem, memsize); + else +#endif + CallFree(0, mem, isforeign); +} +NEDMALLOCPTRATTR void *nedpmemalign(nedpool *p, size_t alignment, size_t bytes) THROWSPEC +{ + void *ret; + threadcache *tc; + int mymspace; + GetThreadCache(&p, &tc, &mymspace, &bytes); + { /* Use this thread's mspace */ GETMSPACE(m, p, tc, mymspace, bytes, - ret=CallMalloc(m, bytes, alignment)); - } - return ret; + ret=CallMalloc(m, bytes, alignment)); + } + return ret; } struct nedmallinfo nedpmallinfo(nedpool *p) THROWSPEC { - int n; - struct nedmallinfo ret={0}; - if(!p) { p=&syspool; if(!syspool.threads) InitPool(&syspool, 0, -1); } - for(n=0; p->m[n]; n++) - { + int n; + struct nedmallinfo ret= {0}; +if (!p) { p=&syspool; if (!syspool.threads) InitPool(&syspool, 0, -1); } +for (n=0; p->m[n]; n++) +{ #if USE_ALLOCATOR==1 && !NO_MALLINFO - struct mallinfo t=mspace_mallinfo(p->m[n]); - ret.arena+=t.arena; - ret.ordblks+=t.ordblks; - ret.hblkhd+=t.hblkhd; - ret.usmblks+=t.usmblks; - ret.uordblks+=t.uordblks; - ret.fordblks+=t.fordblks; - ret.keepcost+=t.keepcost; +struct mallinfo t=mspace_mallinfo(p->m[n]); + ret.arena+=t.arena; + ret.ordblks+=t.ordblks; + ret.hblkhd+=t.hblkhd; + ret.usmblks+=t.usmblks; + ret.uordblks+=t.uordblks; + ret.fordblks+=t.fordblks; + ret.keepcost+=t.keepcost; #endif - } - return ret; +} +return ret; } int nedpmallopt(nedpool *p, int parno, int value) THROWSPEC { #if USE_ALLOCATOR==1 - return mspace_mallopt(parno, value); + return mspace_mallopt(parno, value); #else - return 0; + return 0; #endif } -NEDMALLOCNOALIASATTR void* nedmalloc_internals(size_t *granularity, size_t *magic) THROWSPEC +NEDMALLOCNOALIASATTR void *nedmalloc_internals(size_t *granularity, size_t *magic) THROWSPEC { #if USE_ALLOCATOR==1 - if(granularity) *granularity=mparams.granularity; - if(magic) *magic=mparams.magic; - return (void *) &syspool; + if (granularity) *granularity=mparams.granularity; + if (magic) *magic=mparams.magic; + return (void *) &syspool; #else - if(granularity) *granularity=0; - if(magic) *magic=0; - return 0; + if (granularity) *granularity=0; + if (magic) *magic=0; + return 0; #endif } int nedpmalloc_trim(nedpool *p, size_t pad) THROWSPEC { - int n, ret=0; - if(!p) { p=&syspool; if(!syspool.threads) InitPool(&syspool, 0, -1); } - for(n=0; p->m[n]; n++) - { + int n, ret=0; + if (!p) { p=&syspool; if (!syspool.threads) InitPool(&syspool, 0, -1); } + for (n=0; p->m[n]; n++) + { #if USE_ALLOCATOR==1 - ret+=mspace_trim(p->m[n], pad); + ret+=mspace_trim(p->m[n], pad); #endif - } - return ret; + } + return ret; } void nedpmalloc_stats(nedpool *p) THROWSPEC { - int n; - if(!p) { p=&syspool; if(!syspool.threads) InitPool(&syspool, 0, -1); } - for(n=0; p->m[n]; n++) - { + int n; + if (!p) { p=&syspool; if (!syspool.threads) InitPool(&syspool, 0, -1); } + for (n=0; p->m[n]; n++) + { #if USE_ALLOCATOR==1 - mspace_malloc_stats(p->m[n]); + mspace_malloc_stats(p->m[n]); #endif - } + } } size_t nedpmalloc_footprint(nedpool *p) THROWSPEC { - size_t ret=0; - int n; - if(!p) { p=&syspool; if(!syspool.threads) InitPool(&syspool, 0, -1); } - for(n=0; p->m[n]; n++) - { + size_t ret=0; + int n; + if (!p) { p=&syspool; if (!syspool.threads) InitPool(&syspool, 0, -1); } + for (n=0; p->m[n]; n++) + { #if USE_ALLOCATOR==1 - ret+=mspace_footprint(p->m[n]); + ret+=mspace_footprint(p->m[n]); #endif - } - return ret; + } + return ret; } NEDMALLOCPTRATTR void **nedpindependent_calloc(nedpool *p, size_t elemsno, size_t elemsize, void **chunks) THROWSPEC { - void **ret; - threadcache *tc; - int mymspace; - GetThreadCache(&p, &tc, &mymspace, &elemsize); + void **ret; + threadcache *tc; + int mymspace; + GetThreadCache(&p, &tc, &mymspace, &elemsize); #if USE_ALLOCATOR==0 - GETMSPACE(m, p, tc, mymspace, elemsno*elemsize, - ret=unsupported_operation("independent_calloc")); + GETMSPACE(m, p, tc, mymspace, elemsno *elemsize, + ret=unsupported_operation("independent_calloc")); #elif USE_ALLOCATOR==1 - GETMSPACE(m, p, tc, mymspace, elemsno*elemsize, - ret=mspace_independent_calloc(m, elemsno, elemsize, chunks)); + GETMSPACE(m, p, tc, mymspace, elemsno *elemsize, + ret=mspace_independent_calloc(m, elemsno, elemsize, chunks)); #endif - return ret; + return ret; } NEDMALLOCPTRATTR void **nedpindependent_comalloc(nedpool *p, size_t elems, size_t *sizes, void **chunks) THROWSPEC { - void **ret; - threadcache *tc; - int mymspace; - size_t i, *adjustedsizes=(size_t *) alloca(elems*sizeof(size_t)); - if(!adjustedsizes) return 0; - for(i=0; ivar; break; } - + Bmemcpy(&cvars[osdnumcvars++], cvar, sizeof(cvar_t)); return 0; @@ -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 // ^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; @@ -254,7 +254,7 @@ const char * OSD_StripColors(char *out, const char *in) int32_t OSD_Exec(const char *szScript) { - FILE* fp = fopenfrompath(szScript, "r"); + FILE *fp = fopenfrompath(szScript, "r"); if (fp != NULL) { @@ -281,19 +281,19 @@ int32_t OSD_OSDKey(void) 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) @@ -393,9 +393,9 @@ static int32_t _internal_osdfunc_fileinfo(const osdfuncparm_t *parm) kclose(i); OSD_Printf("fileinfo: %s\n" - " File size: %d\n" - " CRC-32: %08X\n", - parm->parms[0], length, crc); + " File size: %d\n" + " CRC-32: %08X\n", + parm->parms[0], length, crc); return OSDCMD_OK; } @@ -603,13 +603,9 @@ static int32_t _internal_osdfunc_help(const osdfuncparm_t *parm) if (parm->numparms != 1) return OSDCMD_SHOWHELP; symb = findexactsymbol(parm->parms[0]); if (!symb) - { - OSD_Printf("Help Error: \"%s\" is not a defined variable or function\n", parm->parms[0]); - } + OSD_Printf("Error: no help for undefined symbol \"%s\"\n", parm->parms[0]); else - { OSD_Printf("%s\n", symb->help); - } return OSDCMD_OK; } @@ -653,8 +649,11 @@ void OSD_Cleanup(void) Bfree(symbols); } - if (osdlog) Bfclose(osdlog); - osdlog = NULL; + if (osdlog) + { + Bfclose(osdlog); + osdlog = NULL; + } if (cvars) { @@ -717,15 +716,15 @@ void OSD_Init(void) uint32_t i; cvar_t cvars_osd[] = { - { "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 }, - { "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 }, - { "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 }, - { "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 }, - { "logcutoff","logcutoff: sets the maximal line count of the log file",(void *)&logcutoff, CVAR_INT, 0, 262144 }, + { "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 }, + { "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 }, + { "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 }, + { "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 }, + { "logcutoff","logcutoff: sets the maximal line count of the log file",(void *) &logcutoff, CVAR_INT, 0, 262144 }, }; mutex_init(&m_osdprintf); @@ -747,7 +746,7 @@ void OSD_Init(void) continue; 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); @@ -770,10 +769,14 @@ void OSD_Init(void) // void OSD_SetLogFile(char *fn) { - if (osdlog) Bfclose(osdlog); - osdlog = NULL; + if (osdlog) + { + Bfclose(osdlog); + osdlog = NULL; + } + 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 (*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), int32_t (*colwidth)(int32_t), int32_t (*rowheight)(int32_t), @@ -983,92 +986,92 @@ int32_t OSD_HandleChar(char ch) case 127: // handled in OSD_HandleScanCode (delete) return 0; 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; - for (j=0; osdeditbuf[i] != ' ' && i < osdeditlen; j++,i++) - osdedittmp[j] = osdeditbuf[i]; - osdedittmp[j] = 0; + tabc = findsymbol(osdedittmp, NULL); - 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; - int32_t maxwidth = 0, x = 0, num = 0, diffpt; + num++; - while (symb && symb != lastmatch) + if (lastmatch) { - num++; - - if (lastmatch) - { - 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); + diffpt = OSD_FindDiffPoint(symb->name,lastmatch->name); + if (diffpt < commonsize) + commonsize = diffpt; } - 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"); + + 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; + 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 Bmemset(osdeditbuf+osdeditcursor,0,sizeof(osdeditbuf)-osdeditcursor); return 0; @@ -1089,7 +1092,7 @@ int32_t OSD_HandleChar(char ch) osdhistorytotal++; if (osdexeccount == OSD_HISTORYDEPTH) OSD_Printf("Command Buffer Warning: Failed queueing command " - "for execution. Buffer full.\n"); + "for execution. Buffer full.\n"); else osdexeccount++; } @@ -1097,7 +1100,7 @@ int32_t OSD_HandleChar(char ch) { if (osdexeccount == OSD_HISTORYDEPTH) OSD_Printf("Command Buffer Warning: Failed queueing command " - "for execution. Buffer full.\n"); + "for execution. Buffer full.\n"); else osdexeccount++; } @@ -1478,7 +1481,7 @@ void OSD_Draw(void) if (osdver[0]) drawosdstr(osdcols-osdverlen,osdrowscur - (offset >= osdcols-osdverlen), - osdver,osdverlen,(sintable[(totalclock<<4)&2047]>>11),osdverpal); + osdver,osdverlen,(sintable[(totalclock<<4)&2047]>>11),osdverpal); } enddrawing(); @@ -1505,11 +1508,6 @@ void OSD_Printf(const char *fmt, ...) char *chp, p=osdtextpal, s=osdtextshade; va_list va; -/* - if ((osdflags & OSD_INITIALIZED) == 0) - OSD_Init(); -*/ - mutex_lock(&m_osdprintf); 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 (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 { - OSD_errors=MAX_ERRORS+2; + OSD_errors = MAX_ERRORS + 2; mutex_unlock(&m_osdprintf); return; } } - if (linecntfunc) + switch ((intptr_t)symb->func) { - case (intptr_t)OSD_ALIAS: + case(intptr_t)OSD_ALIAS: OSD_Dispatch(symb->help); - case (intptr_t)OSD_UNALIASED: + case(intptr_t)OSD_UNALIASED: break; default: switch (symb->func(&ofp)) @@ -1797,7 +1804,7 @@ int32_t OSD_Dispatch(const char *cmd) // // 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; 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->func != OSD_ALIAS && symb->func != OSD_UNALIASED) - { - OSD_Printf("OSD_RegisterFunction(): \"%s\" is already defined\n", name); - return -1; - } -*/ + /* + if (symb->func != OSD_ALIAS && symb->func != OSD_UNALIASED) + { + OSD_Printf("OSD_RegisterFunction(): \"%s\" is already defined\n", name); + return -1; + } + */ // Bfree((char *)symb->help); symb->help = help; symb->func = func; @@ -1998,7 +2005,7 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm) float val; 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; } @@ -2009,7 +2016,7 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm) OSD_Printf("%s value out of range\n",cvars[i].name); return OSDCMD_OK; } - *(float*)cvars[i].var = val; + *(float *)cvars[i].var = val; if (!OSD_ParsingScript()) OSD_Printf("%s %f",cvars[i].name,val); } @@ -2019,7 +2026,7 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm) double val; 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; } @@ -2030,7 +2037,7 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm) OSD_Printf("%s value out of range\n",cvars[i].name); return OSDCMD_OK; } - *(double*)cvars[i].var = val; + *(double *)cvars[i].var = val; if (!OSD_ParsingScript()) OSD_Printf("%s %f",cvars[i].name,val); } @@ -2042,7 +2049,7 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm) int32_t val; 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; } @@ -2054,7 +2061,7 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm) OSD_Printf("%s value out of range\n",cvars[i].name); return OSDCMD_OK; } - *(int32_t*)cvars[i].var = val; + *(int32_t *)cvars[i].var = val; if (!OSD_ParsingScript()) OSD_Printf("%s %d",cvars[i].name,val); } @@ -2063,14 +2070,14 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm) { 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; } - Bstrncpy((char*)cvars[i].var, parm->parms[0], cvars[i].max-1); - ((char*)cvars[i].var)[cvars[i].max-1] = 0; + Bstrncpy((char *)cvars[i].var, parm->parms[0], cvars[i].max-1); + ((char *)cvars[i].var)[cvars[i].max-1] = 0; 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; default: @@ -2095,12 +2102,12 @@ void OSD_WriteCvars(FILE *fp) { 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)) - { + { 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; 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; case CVAR_INT: 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); break; 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; default: break; - } + } } } diff --git a/polymer/eduke32/build/src/polymost.c b/polymer/eduke32/build/src/polymost.c index d59e94afd..3d80f853c 100644 --- a/polymer/eduke32/build/src/polymost.c +++ b/polymer/eduke32/build/src/polymost.c @@ -300,10 +300,10 @@ pthtyp *gltexcachead[GLTEXCACHEADSIZ]; int32_t drawingskybox = 0; -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_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); 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; hicreplctyp *si; @@ -645,8 +645,8 @@ void polymost_glreset() cacheptrs[ii] = NULL; } - Bfree(cacheptrs[i]); - cacheptrs[i] = NULL; + Bfree(cacheptrs[i]); + cacheptrs[i] = NULL; } 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); fixtransparency(pic,tsizx,tsizy,xsiz,ysiz,dameth); @@ -1365,7 +1365,7 @@ int32_t trytexcache(char *fn, int32_t len, int32_t dameth, char effect, texcache Blseek(cachefilehandle, cachepos, BSEEK_SET); if (Bread(cachefilehandle, head, sizeof(texcacheheader)) < (int32_t)sizeof(texcacheheader)) { - cachepos += sizeof(texcacheheader); + cachepos += sizeof(texcacheheader); err = 1; goto failure; } @@ -1558,7 +1558,7 @@ int32_t gloadtile_cached(int32_t fil, texcacheheader *head, int32_t *doalloc, pt 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 } 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; 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); 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]; 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; 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]))) { 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; } @@ -4380,7 +4380,7 @@ void polymost_drawrooms() hitallsprites = 1; 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 { @@ -5303,15 +5303,18 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16 tspr.ang = hudmem[(dastat&4)>>2][picnum].angadd+globalang; if (dastat&4) { x1 = -x1; y1 = -y1; } - + // In Polymost, we don't care if the model is very big - if (rendmode < 4) { + if (rendmode < 4) + { tspr.xrepeat = tspr.yrepeat = 32; 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.z = (int32_t)(globalposz + y1*16384.0*0.8); - } else { + } + else + { float x, y, z; tspr.xrepeat = tspr.yrepeat = 5; @@ -5319,7 +5322,7 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16 x = (float)(((double)gcosang*z1 - (double)gsinang*x1)*2560.0 + globalposx); y = (float)(((double)gsinang*z1 + (double)gcosang*x1)*2560.0 + globalposy); z = (float)(globalposz + y1*2560.0*0.8); - + memcpy(&tspr.x, &x, sizeof(float)); memcpy(&tspr.y, &y, sizeof(float)); memcpy(&tspr.z, &z, sizeof(float)); @@ -5373,12 +5376,13 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16 if (!nofog) bglDisable(GL_FOG); if (rendmode < 4) mddraw(&tspr); - else { + else + { tspriteptr[MAXSPRITESONSCREEN] = &tspr; bglEnable(GL_ALPHA_TEST); bglEnable(GL_BLEND); - + spriteext[tspr.owner].roll = a; spriteext[tspr.owner].zoff = z; @@ -5390,7 +5394,7 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16 bglDisable(GL_BLEND); bglDisable(GL_ALPHA_TEST); } - + if (!nofog) bglEnable(GL_FOG); #else mddraw(&tspr); @@ -5476,7 +5480,7 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16 sx = ((cx1+cx2+2+scale((oxdim-xdim), cx1+cx2+2, oxdim))<<15)+scale(sx-(320<<15),scale(xdimen, xdim, oxdim),320); else if (dastat & 256) sx = ((cx1+cx2+2-scale((oxdim-xdim), cx1+cx2+2, oxdim))<<15)+scale(sx-(320<<15),scale(xdimen, xdim, oxdim),320); - else + else sx = ((cx1+cx2+2)<<15)+scale(sx-(320<<15),scale(xdimen, xdim, oxdim),320); sy = ((cy1+cy2+2)<<15)+mulscale16(sy-(200<<15),x); @@ -5508,7 +5512,7 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16 ydim = (int32_t)((double)xdim * 0.75f); setaspect(65536L,(int32_t)divscale16(ydim*320L,xdim*200L)); } - + d = (double)z/(65536.0*16384.0); cosang2 = cosang = (double)sintable[(a+512)&2047]*d; sinang2 = sinang = (double)sintable[a&2047]*d; @@ -5652,9 +5656,9 @@ static void tessectrap(float *px, float *py, int32_t *point2, int32_t numpoints) if (numpoints+16 > allocpoints) //16 for safety { allocpoints = numpoints+16; - rst = (raster*)Brealloc(rst,allocpoints*sizeof(raster)); - slist = (int32_t*)Brealloc(slist,allocpoints*sizeof(int32_t)); - npoint2 = (int32_t*)Brealloc(npoint2,allocpoints*sizeof(int32_t)); + rst = (raster *)Brealloc(rst,allocpoints*sizeof(raster)); + slist = (int32_t *)Brealloc(slist,allocpoints*sizeof(int32_t)); + npoint2 = (int32_t *)Brealloc(npoint2,allocpoints*sizeof(int32_t)); } //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); - cptr = (char*)textfont; + cptr = (char *)textfont; for (h=0; h<256; h++) { 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++) { 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); - 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_MIN_FILTER,GL_NEAREST); Bfree(tbuf); @@ -6160,73 +6164,73 @@ void polymost_initosdfuncs(void) cvar_t cvars_polymost[] = { #ifdef USE_OPENGL - { "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_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_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_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_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_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_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_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", - (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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_projectionhack", "r_projectionhack: enable/disable projection hack", (void *) &glprojectionhacks, CVAR_INT, 0, 2 }, #ifdef POLYMER // polymer cvars - { "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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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 - { "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_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_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 }; @@ -6273,7 +6277,7 @@ void polymost_precache(int32_t dapicnum, int32_t dapalnum, int32_t datype) for (i=0; i<=j; i++) { - mdloadskin((md2model_t*)models[mid], 0, dapalnum, i); + mdloadskin((md2model_t *)models[mid], 0, dapalnum, i); } } #endif @@ -6343,9 +6347,9 @@ int32_t dxtfilter(int32_t fil, texcachepicture *pict, char *pic, void *midbuf, c char *cptr; 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)) || - (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; } if (stride == 16) //If DXT3... @@ -6380,58 +6384,58 @@ int32_t dxtfilter(int32_t fil, texcachepicture *pict, char *pic, void *midbuf, c cptr = midbuf; for (k=0; k<=2; k+=2) for (j=0; (unsigned)j j-1) { - 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; + cleng = j; writebuf = midbuf; } - j = B_LITTLE32(cleng); - Bwrite(fil,&j,sizeof(j)); - Bwrite(fil,writebuf,cleng); + else writebuf = packbuf; + } + else + { + cleng = (miplen/stride)<<2; + writebuf = midbuf; + } + j = B_LITTLE32(cleng); + Bwrite(fil,&j,sizeof(j)); + Bwrite(fil,writebuf,cleng); - //index_4x4 - cptr = midbuf; - for (j=0; (unsigned)j>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]; - 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; + cleng = j; writebuf = midbuf; } - j = B_LITTLE32(cleng); - Bwrite(fil,&j,sizeof(j)); - Bwrite(fil,writebuf,cleng); - return 0; + else writebuf = packbuf; + } + else + { + 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) @@ -6471,7 +6475,7 @@ int32_t dedxtfilter(int32_t fil, texcachepicture *pict, char *pic, void *midbuf, if (memcachedata && memcachesize >= (signed)(cachepos + cleng)) { if (ispacked && cleng < j) - { + { if (qlz_decompress((const char *)memcachedata + cachepos,midbuf,state_decompress) == 0) { cachepos += cleng; @@ -6519,7 +6523,7 @@ int32_t dedxtfilter(int32_t fil, texcachepicture *pict, char *pic, void *midbuf, if (memcachedata && memcachesize >= (signed)(cachepos + cleng)) { if (ispacked && cleng < j) - { + { if (qlz_decompress((const char *)memcachedata + cachepos,midbuf,state_decompress) == 0) { cachepos += cleng; @@ -6557,10 +6561,10 @@ int32_t dedxtfilter(int32_t fil, texcachepicture *pict, char *pic, void *midbuf, cachepos += sizeof(int32_t); } else - { + { Blseek(fil, cachepos, BSEEK_SET); cachepos += sizeof(int32_t); - if (Bread(fil,&cleng,sizeof(int32_t)) < (signed)sizeof(int32_t)) return -1; + if (Bread(fil,&cleng,sizeof(int32_t)) < (signed)sizeof(int32_t)) return -1; cleng = B_LITTLE32(cleng); } @@ -6570,7 +6574,7 @@ int32_t dedxtfilter(int32_t fil, texcachepicture *pict, char *pic, void *midbuf, if (memcachedata && memcachesize >= (signed)(cachepos + cleng)) { if (ispacked && cleng < j) - { + { if (qlz_decompress((const char *)memcachedata + cachepos,midbuf,state_decompress) == 0) { cachepos += cleng; diff --git a/polymer/eduke32/build/src/pragmas.c b/polymer/eduke32/build/src/pragmas.c index d54c81e88..2e5410d48 100644 --- a/polymer/eduke32/build/src/pragmas.c +++ b/polymer/eduke32/build/src/pragmas.c @@ -40,9 +40,9 @@ int32_t boundmulscale(int32_t a, int32_t b, int32_t c) "xorl $0x7fffffff, %%eax\n\t" // xor eax, 0x7fffffff "1:" // skipboundit: : "+a"(a), "+b"(b), "+c"(c) // input eax ebx ecx - : - : "edx", "cc" - ); + : + : "edx", "cc" + ); return a; } @@ -84,8 +84,8 @@ void clearbufbyte(void *D, int32_t c, int32_t a) "stosb\n\t" "5:" // endit : "+D"(D), "+c"(c), "+a"(a) : - : "ebx", "memory", "cc" - ); + : "ebx", "memory", "cc" + ); } 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" "5:" // endit: : "+c"(c), "+S"(S), "+D"(D) : - : "ebx", "memory", "cc" - ); + : "ebx", "memory", "cc" + ); } 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 "3:" : "+S"(S), "+D"(D), "+c"(c) : - : "eax", "memory", "cc" - ); + : "eax", "memory", "cc" + ); } #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) { - int32_t *p = (int32_t*)d; + int32_t *p = (int32_t *)d; while ((c--) > 0) *(p++) = a; } 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++); } 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; 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) { // Cringe City - char *p = (char*)D; + char *p = (char *)D; int32_t m[4] = { 0xffl,0xff00l,0xff0000l,0xff000000l }; int32_t n[4] = { 0,8,16,24 }; 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) { - char *p = (char*)S, *q = (char*)D; + char *p = (char *)S, *q = (char *)D; while ((c--) > 0) *(q++) = *(p++); } 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--); } diff --git a/polymer/eduke32/build/src/quicklz.c b/polymer/eduke32/build/src/quicklz.c index d98d56fbc..db6364552 100644 --- a/polymer/eduke32/build/src/quicklz.c +++ b/polymer/eduke32/build/src/quicklz.c @@ -1,854 +1,854 @@ -// Fast data compression library -// Copyright (C) 2006-2009 Lasse Mikkel Reinhold -// lar@quicklz.com -// -// QuickLZ can be used for free under the GPL-1 or GPL-2 license (where anything -// released into public must be open source) or under a commercial license if such -// has been acquired (see http://www.quicklz.com/order.html). The commercial license -// does not cover derived or ported versions created by third parties under GPL. - -// BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION -// BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION -// BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION -// BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION -// BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION - -// 1.5.0 BETA 2 - -#include "quicklz.h" - -#if QLZ_VERSION_MAJOR != 1 || QLZ_VERSION_MINOR != 5 || QLZ_VERSION_REVISION != 0 - #error quicklz.c and quicklz.h have different versions -#endif - -#if (defined(__X86__) || defined(__i386__) || defined(i386) || defined(_M_IX86) || defined(__386__) || defined(__x86_64__) || defined(_M_X64)) - #define X86X64 -#endif - -#define MINOFFSET 2 -#define UNCONDITIONAL_MATCHLEN 6 -#define UNCOMPRESSED_END 4 -#define CWORD_LEN 4 - -#if QLZ_COMPRESSION_LEVEL == 1 && defined QLZ_PTR_64 && QLZ_STREAMING_BUFFER == 0 - #define OFFSET_BASE source - #define CAST (ui32)(size_t) -#else - #define OFFSET_BASE 0 - #define CAST -#endif - -int qlz_get_setting(int setting) -{ - switch (setting) - { - case 0: return QLZ_COMPRESSION_LEVEL; - case 1: return sizeof(qlz_state_compress); - case 2: return sizeof(qlz_state_decompress); - case 3: return QLZ_STREAMING_BUFFER; -#ifdef QLZ_MEMORY_SAFE - case 6: return 1; -#else - case 6: return 0; -#endif - case 7: return QLZ_VERSION_MAJOR; - case 8: return QLZ_VERSION_MINOR; - case 9: return QLZ_VERSION_REVISION; - } - return -1; -} - -#if QLZ_COMPRESSION_LEVEL == 1 -static int same(const unsigned char *src, size_t n) -{ - while(n > 0 && *(src + n) == *src) - n--; - return n == 0 ? 1 : 0; -} -#endif - -static void reset_table_compress(qlz_state_compress *state) -{ - int i; - for(i = 0; i < QLZ_HASH_VALUES; i++) - { -#if QLZ_COMPRESSION_LEVEL == 1 - state->hash[i].offset = 0; -#else - state->hash_counter[i] = 0; -#endif - } -} - -static void reset_table_decompress(qlz_state_decompress *state) -{ - int i; - (void)state; - (void)i; -#if QLZ_COMPRESSION_LEVEL == 2 - for(i = 0; i < QLZ_HASH_VALUES; i++) - { - state->hash_counter[i] = 0; - } -#endif -} - -static __inline ui32 hash_func(ui32 i) -{ -#if QLZ_COMPRESSION_LEVEL == 2 - return ((i >> 9) ^ (i >> 13) ^ i) & (QLZ_HASH_VALUES - 1); -#else - return ((i >> 12) ^ i) & (QLZ_HASH_VALUES - 1); -#endif -} - -static __inline ui32 fast_read(void const *src, ui32 bytes) -{ -#ifndef X86X64 - unsigned char *p = (unsigned char*)src; - switch (bytes) - { - case 4: - return(*p | *(p + 1) << 8 | *(p + 2) << 16 | *(p + 3) << 24); - case 3: - return(*p | *(p + 1) << 8 | *(p + 2) << 16); - case 2: - return(*p | *(p + 1) << 8); - case 1: - return(*p); - } - return 0; -#else - if (bytes >= 1 && bytes <= 4) - return *((ui32*)src); - else - return 0; -#endif -} - -static __inline ui32 hashat(const unsigned char *src) -{ - ui32 fetch, hash; - fetch = fast_read(src, 3); - hash = hash_func(fetch); - return hash; -} - -static __inline void fast_write(ui32 f, void *dst, size_t bytes) -{ -#ifndef X86X64 - unsigned char *p = (unsigned char*)dst; - - switch (bytes) - { - case 4: - *p = (unsigned char)f; - *(p + 1) = (unsigned char)(f >> 8); - *(p + 2) = (unsigned char)(f >> 16); - *(p + 3) = (unsigned char)(f >> 24); - return; - case 3: - *p = (unsigned char)f; - *(p + 1) = (unsigned char)(f >> 8); - *(p + 2) = (unsigned char)(f >> 16); - return; - case 2: - *p = (unsigned char)f; - *(p + 1) = (unsigned char)(f >> 8); - return; - case 1: - *p = (unsigned char)f; - return; - } -#else - switch (bytes) - { - case 4: - *((ui32*)dst) = f; - return; - case 3: - *((ui32*)dst) = f; - return; - case 2: - *((ui16 *)dst) = (ui16)f; - return; - case 1: - *((unsigned char*)dst) = (unsigned char)f; - return; - } -#endif -} - - -size_t qlz_size_decompressed(const char *source) -{ - ui32 n, r; - n = (((*source) & 2) == 2) ? 4 : 1; - r = fast_read(source + 1 + n, n); - r = r & (0xffffffff >> ((4 - n)*8)); - return r; -} - -size_t qlz_size_compressed(const char *source) -{ - ui32 n, r; - n = (((*source) & 2) == 2) ? 4 : 1; - r = fast_read(source + 1, n); - r = r & (0xffffffff >> ((4 - n)*8)); - return r; -} - -size_t qlz_size_header(const char *source) -{ - size_t n = 2*((((*source) & 2) == 2) ? 4 : 1) + 1; - return n; -} - - -static __inline void memcpy_up(unsigned char *dst, const unsigned char *src, ui32 n) -{ - // Caution if modifying memcpy_up! Overlap of dst and src must be special handled. -#ifndef X86X64 - unsigned char *end = dst + n; - while(dst < end) - { - *dst = *src; - dst++; - src++; - } -#else - ui32 f = 0; - do - { - *(ui32 *)(dst + f) = *(ui32 *)(src + f); - f += MINOFFSET + 1; - } - while (f < n); -#endif -} - -static __inline void update_hash(qlz_state_decompress *state, const unsigned char *s) -{ -#if QLZ_COMPRESSION_LEVEL == 1 - ui32 hash; - hash = hashat(s); - state->hash[hash].offset = s; - state->hash_counter[hash] = 1; -#elif QLZ_COMPRESSION_LEVEL == 2 - ui32 hash; - unsigned char c; - hash = hashat(s); - c = state->hash_counter[hash]; - state->hash[hash].offset[c & (QLZ_POINTERS - 1)] = s; - c++; - state->hash_counter[hash] = c; -#endif - (void)state; - (void)s; -} - -#if QLZ_COMPRESSION_LEVEL <= 2 -static void update_hash_upto(qlz_state_decompress *state, unsigned char **lh, const unsigned char *max) -{ - while(*lh < max) - { - (*lh)++; - update_hash(state, *lh); - } -} -#endif - -static size_t qlz_compress_core(const unsigned char *source, unsigned char *destination, size_t size, qlz_state_compress *state) -{ - const unsigned char *last_byte = source + size - 1; - const unsigned char *src = source; - unsigned char *cword_ptr = destination; - unsigned char *dst = destination + CWORD_LEN; - ui32 cword_val = 1U << 31; - const unsigned char *last_matchstart = last_byte - UNCONDITIONAL_MATCHLEN - UNCOMPRESSED_END; - ui32 fetch = 0; - unsigned int lits = 0; - - (void) lits; - - if(src <= last_matchstart) - fetch = fast_read(src, 3); - - while(src <= last_matchstart) - { - if ((cword_val & 1) == 1) - { - // store uncompressed if compression ratio is too low - if (src > source + (size >> 1) && dst - destination > src - source - ((src - source) >> 5)) - return 0; - - fast_write((cword_val >> 1) | (1U << 31), cword_ptr, CWORD_LEN); - - cword_ptr = dst; - dst += CWORD_LEN; - cword_val = 1U << 31; - fetch = fast_read(src, 3); - } -#if QLZ_COMPRESSION_LEVEL == 1 - { - const unsigned char *o; - ui32 hash, cached; - - hash = hash_func(fetch); - cached = fetch ^ state->hash[hash].cache; - state->hash[hash].cache = fetch; - - o = state->hash[hash].offset + OFFSET_BASE; - state->hash[hash].offset = CAST(src - OFFSET_BASE); - -#ifdef X86X64 - if ((cached & 0xffffff) == 0 && o != OFFSET_BASE && (src - o > MINOFFSET || (src == o + 1 && lits >= 3 && src > source + 3 && same(src - 3, 6)))) - { - if(cached != 0) - { -#else - if (cached == 0 && o != OFFSET_BASE && (src - o > MINOFFSET || (src == o + 1 && lits >= 3 && src > source + 3 && same(src - 3, 6)))) - { - if (*(o + 3) != *(src + 3)) - { -#endif - hash <<= 4; - cword_val = (cword_val >> 1) | (1U << 31); - fast_write((3 - 2) | hash, dst, 2); - src += 3; - dst += 2; - } - else - { - const unsigned char *old_src = src; - size_t matchlen; - hash <<= 4; - - cword_val = (cword_val >> 1) | (1U << 31); - src += 4; - - if(*(o + (src - old_src)) == *src) - { - src++; - if(*(o + (src - old_src)) == *src) - { - size_t q = last_byte - UNCOMPRESSED_END - (src - 5) + 1; - size_t remaining = q > 255 ? 255 : q; - src++; - while(*(o + (src - old_src)) == *src && (size_t)(src - old_src) < remaining) - src++; - } - } - - matchlen = src - old_src; - if (matchlen < 18) - { - fast_write((ui32)(matchlen - 2) | hash, dst, 2); - dst += 2; - } - else - { - fast_write((ui32)(matchlen << 16) | hash, dst, 3); - dst += 3; - } - } - fetch = fast_read(src, 3); - lits = 0; - } - else - { - lits++; - *dst = *src; - src++; - dst++; - cword_val = (cword_val >> 1); -#ifdef X86X64 - fetch = fast_read(src, 3); -#else - fetch = (fetch >> 8 & 0xffff) | (*(src + 2) << 16); -#endif - } - } -#elif QLZ_COMPRESSION_LEVEL >= 2 - { - const unsigned char *o, *offset2; - ui32 hash, matchlen, k, m, best_k = 0; - unsigned char c; - size_t remaining = (last_byte - UNCOMPRESSED_END - src + 1) > 255 ? 255 : (last_byte - UNCOMPRESSED_END - src + 1); - (void)best_k; - - - //hash = hashat(src); - fetch = fast_read(src, 3); - hash = hash_func(fetch); - - c = state->hash_counter[hash]; - - offset2 = state->hash[hash].offset[0]; - if(offset2 < src - MINOFFSET && c > 0 && ((fast_read(offset2, 3) ^ fetch) & 0xffffff) == 0) - { - matchlen = 3; - if(*(offset2 + matchlen) == *(src + matchlen)) - { - matchlen = 4; - while(*(offset2 + matchlen) == *(src + matchlen) && matchlen < remaining) - matchlen++; - } - } - else - matchlen = 0; - for(k = 1; k < QLZ_POINTERS && c > k; k++) - { - o = state->hash[hash].offset[k]; -#if QLZ_COMPRESSION_LEVEL == 3 - if(((fast_read(o, 3) ^ fetch) & 0xffffff) == 0 && o < src - MINOFFSET) -#elif QLZ_COMPRESSION_LEVEL == 2 - if(*(src + matchlen) == *(o + matchlen) && ((fast_read(o, 3) ^ fetch) & 0xffffff) == 0 && o < src - MINOFFSET) -#endif - { - m = 3; - while(*(o + m) == *(src + m) && m < remaining) - m++; -#if QLZ_COMPRESSION_LEVEL == 3 - if ((m > matchlen) || (m == matchlen && o > offset2)) -#elif QLZ_COMPRESSION_LEVEL == 2 - if (m > matchlen) -#endif - { - offset2 = o; - matchlen = m; - best_k = k; - } - } - } - o = offset2; - state->hash[hash].offset[c & (QLZ_POINTERS - 1)] = src; - c++; - state->hash_counter[hash] = c; - -#if QLZ_COMPRESSION_LEVEL == 3 - if(matchlen > 2 && src - o < 131071) - { - ui32 u; - size_t offset = src - o; - - for(u = 1; u < matchlen; u++) - { - hash = hashat(src + u); - c = state->hash_counter[hash]++; - state->hash[hash].offset[c & (QLZ_POINTERS - 1)] = src + u; - } - - cword_val = (cword_val >> 1) | (1U << 31); - src += matchlen; - - if(matchlen == 3 && offset <= 63) - { - *dst = (unsigned char)(offset << 2); - dst++; - } - else if (matchlen == 3 && offset <= 16383) - { - ui32 f = (ui32)((offset << 2) | 1); - fast_write(f, dst, 2); - dst += 2; - } - else if (matchlen <= 18 && offset <= 1023) - { - ui32 f = ((matchlen - 3) << 2) | ((ui32)offset << 6) | 2; - fast_write(f, dst, 2); - dst += 2; - } - - else if(matchlen <= 33) - { - ui32 f = ((matchlen - 2) << 2) | ((ui32)offset << 7) | 3; - fast_write(f, dst, 3); - dst += 3; - } - else - { - ui32 f = ((matchlen - 3) << 7) | ((ui32)offset << 15) | 3; - fast_write(f, dst, 4); - dst += 4; - } - } - else - { - *dst = *src; - src++; - dst++; - cword_val = (cword_val >> 1); - } -#elif QLZ_COMPRESSION_LEVEL == 2 - - if(matchlen > 2) - { - cword_val = (cword_val >> 1) | (1U << 31); - src += matchlen; - - if (matchlen < 10) - { - ui32 f = best_k | ((matchlen - 2) << 2) | (hash << 5); - fast_write(f, dst, 2); - dst += 2; - } - else - { - ui32 f = best_k | (matchlen << 16) | (hash << 5); - fast_write(f, dst, 3); - dst += 3; - } - } - else - { - *dst = *src; - src++; - dst++; - cword_val = (cword_val >> 1); - } -#endif - } -#endif - } - while (src <= last_byte) - { - if ((cword_val & 1) == 1) - { - fast_write((cword_val >> 1) | (1U << 31), cword_ptr, CWORD_LEN); - cword_ptr = dst; - dst += CWORD_LEN; - cword_val = 1U << 31; - } -#if QLZ_COMPRESSION_LEVEL < 3 - if (src <= last_byte - 3) - { -#if QLZ_COMPRESSION_LEVEL == 1 - ui32 hash, fetch; - fetch = fast_read(src, 3); - hash = hash_func(fetch); - state->hash[hash].offset = CAST(src - OFFSET_BASE); - state->hash[hash].cache = fetch; -#elif QLZ_COMPRESSION_LEVEL == 2 - ui32 hash; - unsigned char c; - hash = hashat(src); - c = state->hash_counter[hash]; - state->hash[hash].offset[c & (QLZ_POINTERS - 1)] = src; - c++; - state->hash_counter[hash] = c; -#endif - } -#endif - *dst = *src; - src++; - dst++; - cword_val = (cword_val >> 1); - } - - while((cword_val & 1) != 1) - cword_val = (cword_val >> 1); - - fast_write((cword_val >> 1) | (1U << 31), cword_ptr, CWORD_LEN); - - // min. size must be 9 bytes so that the qlz_size functions can take 9 bytes as argument - return dst - destination < 9 ? 9 : dst - destination; -} - -static size_t qlz_decompress_core(const unsigned char *source, unsigned char *destination, size_t size, qlz_state_decompress *state, const unsigned char *history) -{ - const unsigned char *src = source + qlz_size_header((const char *)source); - unsigned char *dst = destination; - const unsigned char *last_destination_byte = destination + size - 1; - ui32 cword_val = 1; - const unsigned char *last_matchstart = last_destination_byte - UNCONDITIONAL_MATCHLEN - UNCOMPRESSED_END; - unsigned char *last_hashed = destination - 1; - const unsigned char *last_source_byte = source + qlz_size_compressed((const char *)source) - 1; - static const ui32 bitlut[16] = {4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0}; - - (void) last_source_byte; - (void) last_hashed; - (void) state; - (void) history; - - for(;;) - { - ui32 fetch; - - if (cword_val == 1) - { -#ifdef QLZ_MEMORY_SAFE - if(src + CWORD_LEN - 1 > last_source_byte) - return 0; -#endif - cword_val = fast_read(src, CWORD_LEN); - src += CWORD_LEN; - } - -#ifdef QLZ_MEMORY_SAFE - if(src + 4 - 1 > last_source_byte) - return 0; -#endif - - fetch = fast_read(src, 4); - - if ((cword_val & 1) == 1) - { - ui32 matchlen; - const unsigned char *offset2; - -#if QLZ_COMPRESSION_LEVEL == 1 - ui32 hash; - cword_val = cword_val >> 1; - hash = (fetch >> 4) & 0xfff; - offset2 = (const unsigned char *)(size_t)state->hash[hash].offset; - - if((fetch & 0xf) != 0) - { - matchlen = (fetch & 0xf) + 2; - src += 2; - } - else - { - matchlen = *(src + 2); - src += 3; - } - -#elif QLZ_COMPRESSION_LEVEL == 2 - ui32 hash; - unsigned char c; - cword_val = cword_val >> 1; - hash = (fetch >> 5) & 0x7ff; - c = (unsigned char)(fetch & 0x3); - offset2 = state->hash[hash].offset[c]; - - if((fetch & (28)) != 0) - { - matchlen = ((fetch >> 2) & 0x7) + 2; - src += 2; - } - else - { - matchlen = *(src + 2); - src += 3; - } - -#elif QLZ_COMPRESSION_LEVEL == 3 - ui32 offset; - cword_val = cword_val >> 1; - if ((fetch & 3) == 0) - { - offset = (fetch & 0xff) >> 2; - matchlen = 3; - src++; - } - else if ((fetch & 2) == 0) - { - offset = (fetch & 0xffff) >> 2; - matchlen = 3; - src += 2; - } - else if ((fetch & 1) == 0) - { - offset = (fetch & 0xffff) >> 6; - matchlen = ((fetch >> 2) & 15) + 3; - src += 2; - } - else if ((fetch & 127) != 3) - { - offset = (fetch >> 7) & 0x1ffff; - matchlen = ((fetch >> 2) & 0x1f) + 2; - src += 3; - } - else - { - offset = (fetch >> 15); - matchlen = ((fetch >> 7) & 255) + 3; - src += 4; - } - - offset2 = dst - offset; -#endif - -#ifdef QLZ_MEMORY_SAFE - if(offset2 < history || offset2 > dst - MINOFFSET - 1) - return 0; - - if(matchlen > (ui32)(last_destination_byte - dst - UNCOMPRESSED_END + 1)) - return 0; -#endif - - memcpy_up(dst, offset2, matchlen); - dst += matchlen; - -#if QLZ_COMPRESSION_LEVEL <= 2 - update_hash_upto(state, &last_hashed, dst - matchlen); - last_hashed = dst - 1; -#endif - } - else - { - if (dst < last_matchstart) - { - unsigned int n = bitlut[cword_val & 0xf]; -#ifdef X86X64 - *(ui32 *)dst = *(ui32 *)src; -#else - memcpy_up(dst, src, 4); -#endif - cword_val = cword_val >> n; - dst += n; - src += n; -#if QLZ_COMPRESSION_LEVEL <= 2 - update_hash_upto(state, &last_hashed, dst - 3); -#endif - } - else - { - while(dst <= last_destination_byte) - { - if (cword_val == 1) - { - src += CWORD_LEN; - cword_val = 1U << 31; - } -#ifdef QLZ_MEMORY_SAFE - if(src >= last_source_byte + 1) - return 0; -#endif - *dst = *src; - dst++; - src++; - cword_val = cword_val >> 1; - } - -#if QLZ_COMPRESSION_LEVEL <= 2 - update_hash_upto(state, &last_hashed, last_destination_byte - 3); // todo, use constant -#endif - return size; - } - - } - } -} - -size_t qlz_compress(const void *source, char *destination, size_t size, qlz_state_compress *state) -{ - size_t r; - ui32 compressed; - size_t base; - - if(size == 0 || size > 0xffffffff - 400) - return 0; - - if(size < 216) - base = 3; - else - base = 9; - -#if QLZ_STREAMING_BUFFER > 0 - if (state->stream_counter + size - 1 >= QLZ_STREAMING_BUFFER) -#endif - { - reset_table_compress(state); - r = base + qlz_compress_core((const unsigned char *)source, (unsigned char*)destination + base, size, state); -#if QLZ_STREAMING_BUFFER > 0 - reset_table_compress(state); -#endif - if(r == base) - { - memcpy(destination + base, source, size); - r = size + base; - compressed = 0; - } - else - { - compressed = 1; - } - state->stream_counter = 0; - } -#if QLZ_STREAMING_BUFFER > 0 - else - { - unsigned char *src = state->stream_buffer + state->stream_counter; - - memcpy(src, source, size); - r = base + qlz_compress_core(src, (unsigned char*)destination + base, size, state); - - if(r == base) - { - memcpy(destination + base, src, size); - r = size + base; - compressed = 0; - reset_table_compress(state); - } - else - { - compressed = 1; - } - state->stream_counter += size; - } -#endif - if(base == 3) - { - *destination = (unsigned char)(0 | compressed); - *(destination + 1) = (unsigned char)r; - *(destination + 2) = (unsigned char)size; - } - else - { - *destination = (unsigned char)(2 | compressed); - fast_write((ui32)r, destination + 1, 4); - fast_write((ui32)size, destination + 5, 4); - } - - *destination |= (QLZ_COMPRESSION_LEVEL << 2); - *destination |= (1 << 6); - *destination |= ((QLZ_STREAMING_BUFFER == 0 ? 0 : (QLZ_STREAMING_BUFFER == 100000 ? 1 : (QLZ_STREAMING_BUFFER == 1000000 ? 2 : 3))) << 4); - -// 76543210 -// 01SSLLHC - - return r; -} - -size_t qlz_decompress(const char *source, void *destination, qlz_state_decompress *state) -{ - size_t dsiz = qlz_size_decompressed(source); - -#if QLZ_STREAMING_BUFFER > 0 - if (state->stream_counter + qlz_size_decompressed(source) - 1 >= QLZ_STREAMING_BUFFER) -#endif - { - if((*source & 1) == 1) - { - reset_table_decompress(state); - dsiz = qlz_decompress_core((const unsigned char *)source, (unsigned char *)destination, dsiz, state, (const unsigned char *)destination); - } - else - { - memcpy(destination, source + qlz_size_header(source), dsiz); - } - state->stream_counter = 0; - reset_table_decompress(state); - } -#if QLZ_STREAMING_BUFFER > 0 - else - { - unsigned char *dst = state->stream_buffer + state->stream_counter; - if((*source & 1) == 1) - { - dsiz = qlz_decompress_core((const unsigned char *)source, dst, dsiz, state, (const unsigned char *)state->stream_buffer); - } - else - { - memcpy(dst, source + qlz_size_header(source), dsiz); - reset_table_decompress(state); - } - memcpy(destination, dst, dsiz); - state->stream_counter += dsiz; - } -#endif - return dsiz; -} - +// Fast data compression library +// Copyright (C) 2006-2009 Lasse Mikkel Reinhold +// lar@quicklz.com +// +// QuickLZ can be used for free under the GPL-1 or GPL-2 license (where anything +// released into public must be open source) or under a commercial license if such +// has been acquired (see http://www.quicklz.com/order.html). The commercial license +// does not cover derived or ported versions created by third parties under GPL. + +// BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION +// BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION +// BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION +// BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION +// BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION + +// 1.5.0 BETA 2 + +#include "quicklz.h" + +#if QLZ_VERSION_MAJOR != 1 || QLZ_VERSION_MINOR != 5 || QLZ_VERSION_REVISION != 0 +#error quicklz.c and quicklz.h have different versions +#endif + +#if (defined(__X86__) || defined(__i386__) || defined(i386) || defined(_M_IX86) || defined(__386__) || defined(__x86_64__) || defined(_M_X64)) +#define X86X64 +#endif + +#define MINOFFSET 2 +#define UNCONDITIONAL_MATCHLEN 6 +#define UNCOMPRESSED_END 4 +#define CWORD_LEN 4 + +#if QLZ_COMPRESSION_LEVEL == 1 && defined QLZ_PTR_64 && QLZ_STREAMING_BUFFER == 0 +#define OFFSET_BASE source +#define CAST (ui32)(size_t) +#else +#define OFFSET_BASE 0 +#define CAST +#endif + +int qlz_get_setting(int setting) +{ + switch (setting) + { + case 0: return QLZ_COMPRESSION_LEVEL; + case 1: return sizeof(qlz_state_compress); + case 2: return sizeof(qlz_state_decompress); + case 3: return QLZ_STREAMING_BUFFER; +#ifdef QLZ_MEMORY_SAFE + case 6: return 1; +#else + case 6: return 0; +#endif + case 7: return QLZ_VERSION_MAJOR; + case 8: return QLZ_VERSION_MINOR; + case 9: return QLZ_VERSION_REVISION; + } + return -1; +} + +#if QLZ_COMPRESSION_LEVEL == 1 +static int same(const unsigned char *src, size_t n) +{ + while (n > 0 && *(src + n) == *src) + n--; + return n == 0 ? 1 : 0; +} +#endif + +static void reset_table_compress(qlz_state_compress *state) +{ + int i; + for (i = 0; i < QLZ_HASH_VALUES; i++) + { +#if QLZ_COMPRESSION_LEVEL == 1 + state->hash[i].offset = 0; +#else + state->hash_counter[i] = 0; +#endif + } +} + +static void reset_table_decompress(qlz_state_decompress *state) +{ + int i; + (void)state; + (void)i; +#if QLZ_COMPRESSION_LEVEL == 2 + for (i = 0; i < QLZ_HASH_VALUES; i++) + { + state->hash_counter[i] = 0; + } +#endif +} + +static __inline ui32 hash_func(ui32 i) +{ +#if QLZ_COMPRESSION_LEVEL == 2 + return ((i >> 9) ^(i >> 13) ^ i) & (QLZ_HASH_VALUES - 1); +#else + return ((i >> 12) ^ i) & (QLZ_HASH_VALUES - 1); +#endif +} + +static __inline ui32 fast_read(void const *src, ui32 bytes) +{ +#ifndef X86X64 + unsigned char *p = (unsigned char *)src; + switch (bytes) + { + case 4: + return(*p | *(p + 1) << 8 | *(p + 2) << 16 | *(p + 3) << 24); + case 3: + return(*p | *(p + 1) << 8 | *(p + 2) << 16); + case 2: + return(*p | *(p + 1) << 8); + case 1: + return(*p); + } + return 0; +#else + if (bytes >= 1 && bytes <= 4) + return *((ui32 *)src); + else + return 0; +#endif +} + +static __inline ui32 hashat(const unsigned char *src) +{ + ui32 fetch, hash; + fetch = fast_read(src, 3); + hash = hash_func(fetch); + return hash; +} + +static __inline void fast_write(ui32 f, void *dst, size_t bytes) +{ +#ifndef X86X64 + unsigned char *p = (unsigned char *)dst; + + switch (bytes) + { + case 4: + *p = (unsigned char)f; + *(p + 1) = (unsigned char)(f >> 8); + *(p + 2) = (unsigned char)(f >> 16); + *(p + 3) = (unsigned char)(f >> 24); + return; + case 3: + *p = (unsigned char)f; + *(p + 1) = (unsigned char)(f >> 8); + *(p + 2) = (unsigned char)(f >> 16); + return; + case 2: + *p = (unsigned char)f; + *(p + 1) = (unsigned char)(f >> 8); + return; + case 1: + *p = (unsigned char)f; + return; + } +#else + switch (bytes) + { + case 4: + *((ui32 *)dst) = f; + return; + case 3: + *((ui32 *)dst) = f; + return; + case 2: + *((ui16 *)dst) = (ui16)f; + return; + case 1: + *((unsigned char *)dst) = (unsigned char)f; + return; + } +#endif +} + + +size_t qlz_size_decompressed(const char *source) +{ + ui32 n, r; + n = (((*source) & 2) == 2) ? 4 : 1; + r = fast_read(source + 1 + n, n); + r = r & (0xffffffff >> ((4 - n)*8)); + return r; +} + +size_t qlz_size_compressed(const char *source) +{ + ui32 n, r; + n = (((*source) & 2) == 2) ? 4 : 1; + r = fast_read(source + 1, n); + r = r & (0xffffffff >> ((4 - n)*8)); + return r; +} + +size_t qlz_size_header(const char *source) +{ + size_t n = 2*((((*source) & 2) == 2) ? 4 : 1) + 1; + return n; +} + + +static __inline void memcpy_up(unsigned char *dst, const unsigned char *src, ui32 n) +{ + // Caution if modifying memcpy_up! Overlap of dst and src must be special handled. +#ifndef X86X64 + unsigned char *end = dst + n; + while (dst < end) + { + *dst = *src; + dst++; + src++; + } +#else + ui32 f = 0; + do + { + *(ui32 *)(dst + f) = *(ui32 *)(src + f); + f += MINOFFSET + 1; + } + while (f < n); +#endif +} + +static __inline void update_hash(qlz_state_decompress *state, const unsigned char *s) +{ +#if QLZ_COMPRESSION_LEVEL == 1 + ui32 hash; + hash = hashat(s); + state->hash[hash].offset = s; + state->hash_counter[hash] = 1; +#elif QLZ_COMPRESSION_LEVEL == 2 + ui32 hash; + unsigned char c; + hash = hashat(s); + c = state->hash_counter[hash]; + state->hash[hash].offset[c & (QLZ_POINTERS - 1)] = s; + c++; + state->hash_counter[hash] = c; +#endif + (void)state; + (void)s; +} + +#if QLZ_COMPRESSION_LEVEL <= 2 +static void update_hash_upto(qlz_state_decompress *state, unsigned char **lh, const unsigned char *max) +{ + while (*lh < max) + { + (*lh)++; + update_hash(state, *lh); + } +} +#endif + +static size_t qlz_compress_core(const unsigned char *source, unsigned char *destination, size_t size, qlz_state_compress *state) +{ + const unsigned char *last_byte = source + size - 1; + const unsigned char *src = source; + unsigned char *cword_ptr = destination; + unsigned char *dst = destination + CWORD_LEN; + ui32 cword_val = 1U << 31; + const unsigned char *last_matchstart = last_byte - UNCONDITIONAL_MATCHLEN - UNCOMPRESSED_END; + ui32 fetch = 0; + unsigned int lits = 0; + + (void) lits; + + if (src <= last_matchstart) + fetch = fast_read(src, 3); + + while (src <= last_matchstart) + { + if ((cword_val & 1) == 1) + { + // store uncompressed if compression ratio is too low + if (src > source + (size >> 1) && dst - destination > src - source - ((src - source) >> 5)) + return 0; + + fast_write((cword_val >> 1) | (1U << 31), cword_ptr, CWORD_LEN); + + cword_ptr = dst; + dst += CWORD_LEN; + cword_val = 1U << 31; + fetch = fast_read(src, 3); + } +#if QLZ_COMPRESSION_LEVEL == 1 + { + const unsigned char *o; + ui32 hash, cached; + + hash = hash_func(fetch); + cached = fetch ^ state->hash[hash].cache; + state->hash[hash].cache = fetch; + + o = state->hash[hash].offset + OFFSET_BASE; + state->hash[hash].offset = CAST(src - OFFSET_BASE); + +#ifdef X86X64 + if ((cached & 0xffffff) == 0 && o != OFFSET_BASE && (src - o > MINOFFSET || (src == o + 1 && lits >= 3 && src > source + 3 && same(src - 3, 6)))) + { + if (cached != 0) + { +#else + if (cached == 0 && o != OFFSET_BASE && (src - o > MINOFFSET || (src == o + 1 && lits >= 3 && src > source + 3 && same(src - 3, 6)))) + { + if (*(o + 3) != *(src + 3)) + { +#endif + hash <<= 4; + cword_val = (cword_val >> 1) | (1U << 31); + fast_write((3 - 2) | hash, dst, 2); + src += 3; + dst += 2; + } + else + { + const unsigned char *old_src = src; + size_t matchlen; + hash <<= 4; + + cword_val = (cword_val >> 1) | (1U << 31); + src += 4; + + if (*(o + (src - old_src)) == *src) + { + src++; + if (*(o + (src - old_src)) == *src) + { + size_t q = last_byte - UNCOMPRESSED_END - (src - 5) + 1; + size_t remaining = q > 255 ? 255 : q; + src++; + while (*(o + (src - old_src)) == *src && (size_t)(src - old_src) < remaining) + src++; + } + } + + matchlen = src - old_src; + if (matchlen < 18) + { + fast_write((ui32)(matchlen - 2) | hash, dst, 2); + dst += 2; + } + else + { + fast_write((ui32)(matchlen << 16) | hash, dst, 3); + dst += 3; + } + } + fetch = fast_read(src, 3); + lits = 0; + } + else + { + lits++; + *dst = *src; + src++; + dst++; + cword_val = (cword_val >> 1); +#ifdef X86X64 + fetch = fast_read(src, 3); +#else + fetch = (fetch >> 8 & 0xffff) | (*(src + 2) << 16); +#endif + } + } +#elif QLZ_COMPRESSION_LEVEL >= 2 + { + const unsigned char *o, *offset2; + ui32 hash, matchlen, k, m, best_k = 0; + unsigned char c; + size_t remaining = (last_byte - UNCOMPRESSED_END - src + 1) > 255 ? 255 : (last_byte - UNCOMPRESSED_END - src + 1); + (void)best_k; + + + //hash = hashat(src); + fetch = fast_read(src, 3); + hash = hash_func(fetch); + + c = state->hash_counter[hash]; + + offset2 = state->hash[hash].offset[0]; + if (offset2 < src - MINOFFSET && c > 0 && ((fast_read(offset2, 3) ^ fetch) & 0xffffff) == 0) + { + matchlen = 3; + if (*(offset2 + matchlen) == *(src + matchlen)) + { + matchlen = 4; + while (*(offset2 + matchlen) == *(src + matchlen) && matchlen < remaining) + matchlen++; + } + } + else + matchlen = 0; + for (k = 1; k < QLZ_POINTERS && c > k; k++) + { + o = state->hash[hash].offset[k]; +#if QLZ_COMPRESSION_LEVEL == 3 + if (((fast_read(o, 3) ^ fetch) & 0xffffff) == 0 && o < src - MINOFFSET) +#elif QLZ_COMPRESSION_LEVEL == 2 + if (*(src + matchlen) == *(o + matchlen) && ((fast_read(o, 3) ^ fetch) & 0xffffff) == 0 && o < src - MINOFFSET) +#endif + { + m = 3; + while (*(o + m) == *(src + m) && m < remaining) + m++; +#if QLZ_COMPRESSION_LEVEL == 3 + if ((m > matchlen) || (m == matchlen && o > offset2)) +#elif QLZ_COMPRESSION_LEVEL == 2 + if (m > matchlen) +#endif + { + offset2 = o; + matchlen = m; + best_k = k; + } + } + } + o = offset2; + state->hash[hash].offset[c & (QLZ_POINTERS - 1)] = src; + c++; + state->hash_counter[hash] = c; + +#if QLZ_COMPRESSION_LEVEL == 3 + if (matchlen > 2 && src - o < 131071) + { + ui32 u; + size_t offset = src - o; + + for (u = 1; u < matchlen; u++) + { + hash = hashat(src + u); + c = state->hash_counter[hash]++; + state->hash[hash].offset[c & (QLZ_POINTERS - 1)] = src + u; + } + + cword_val = (cword_val >> 1) | (1U << 31); + src += matchlen; + + if (matchlen == 3 && offset <= 63) + { + *dst = (unsigned char)(offset << 2); + dst++; + } + else if (matchlen == 3 && offset <= 16383) + { + ui32 f = (ui32)((offset << 2) | 1); + fast_write(f, dst, 2); + dst += 2; + } + else if (matchlen <= 18 && offset <= 1023) + { + ui32 f = ((matchlen - 3) << 2) | ((ui32)offset << 6) | 2; + fast_write(f, dst, 2); + dst += 2; + } + + else if (matchlen <= 33) + { + ui32 f = ((matchlen - 2) << 2) | ((ui32)offset << 7) | 3; + fast_write(f, dst, 3); + dst += 3; + } + else + { + ui32 f = ((matchlen - 3) << 7) | ((ui32)offset << 15) | 3; + fast_write(f, dst, 4); + dst += 4; + } + } + else + { + *dst = *src; + src++; + dst++; + cword_val = (cword_val >> 1); + } +#elif QLZ_COMPRESSION_LEVEL == 2 + + if (matchlen > 2) + { + cword_val = (cword_val >> 1) | (1U << 31); + src += matchlen; + + if (matchlen < 10) + { + ui32 f = best_k | ((matchlen - 2) << 2) | (hash << 5); + fast_write(f, dst, 2); + dst += 2; + } + else + { + ui32 f = best_k | (matchlen << 16) | (hash << 5); + fast_write(f, dst, 3); + dst += 3; + } + } + else + { + *dst = *src; + src++; + dst++; + cword_val = (cword_val >> 1); + } +#endif + } +#endif + } + while (src <= last_byte) + { + if ((cword_val & 1) == 1) + { + fast_write((cword_val >> 1) | (1U << 31), cword_ptr, CWORD_LEN); + cword_ptr = dst; + dst += CWORD_LEN; + cword_val = 1U << 31; + } +#if QLZ_COMPRESSION_LEVEL < 3 + if (src <= last_byte - 3) + { +#if QLZ_COMPRESSION_LEVEL == 1 + ui32 hash, fetch; + fetch = fast_read(src, 3); + hash = hash_func(fetch); + state->hash[hash].offset = CAST(src - OFFSET_BASE); + state->hash[hash].cache = fetch; +#elif QLZ_COMPRESSION_LEVEL == 2 + ui32 hash; + unsigned char c; + hash = hashat(src); + c = state->hash_counter[hash]; + state->hash[hash].offset[c & (QLZ_POINTERS - 1)] = src; + c++; + state->hash_counter[hash] = c; +#endif + } +#endif + *dst = *src; + src++; + dst++; + cword_val = (cword_val >> 1); + } + + while ((cword_val & 1) != 1) + cword_val = (cword_val >> 1); + + fast_write((cword_val >> 1) | (1U << 31), cword_ptr, CWORD_LEN); + + // min. size must be 9 bytes so that the qlz_size functions can take 9 bytes as argument + return dst - destination < 9 ? 9 : dst - destination; +} + +static size_t qlz_decompress_core(const unsigned char *source, unsigned char *destination, size_t size, qlz_state_decompress *state, const unsigned char *history) +{ + const unsigned char *src = source + qlz_size_header((const char *)source); + unsigned char *dst = destination; + const unsigned char *last_destination_byte = destination + size - 1; + ui32 cword_val = 1; + const unsigned char *last_matchstart = last_destination_byte - UNCONDITIONAL_MATCHLEN - UNCOMPRESSED_END; + unsigned char *last_hashed = destination - 1; + const unsigned char *last_source_byte = source + qlz_size_compressed((const char *)source) - 1; + static const ui32 bitlut[16] = {4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0}; + + (void) last_source_byte; + (void) last_hashed; + (void) state; + (void) history; + + for (;;) + { + ui32 fetch; + + if (cword_val == 1) + { +#ifdef QLZ_MEMORY_SAFE + if (src + CWORD_LEN - 1 > last_source_byte) + return 0; +#endif + cword_val = fast_read(src, CWORD_LEN); + src += CWORD_LEN; + } + +#ifdef QLZ_MEMORY_SAFE + if (src + 4 - 1 > last_source_byte) + return 0; +#endif + + fetch = fast_read(src, 4); + + if ((cword_val & 1) == 1) + { + ui32 matchlen; + const unsigned char *offset2; + +#if QLZ_COMPRESSION_LEVEL == 1 + ui32 hash; + cword_val = cword_val >> 1; + hash = (fetch >> 4) & 0xfff; + offset2 = (const unsigned char *)(size_t)state->hash[hash].offset; + + if ((fetch & 0xf) != 0) + { + matchlen = (fetch & 0xf) + 2; + src += 2; + } + else + { + matchlen = *(src + 2); + src += 3; + } + +#elif QLZ_COMPRESSION_LEVEL == 2 + ui32 hash; + unsigned char c; + cword_val = cword_val >> 1; + hash = (fetch >> 5) & 0x7ff; + c = (unsigned char)(fetch & 0x3); + offset2 = state->hash[hash].offset[c]; + + if ((fetch & (28)) != 0) + { + matchlen = ((fetch >> 2) & 0x7) + 2; + src += 2; + } + else + { + matchlen = *(src + 2); + src += 3; + } + +#elif QLZ_COMPRESSION_LEVEL == 3 + ui32 offset; + cword_val = cword_val >> 1; + if ((fetch & 3) == 0) + { + offset = (fetch & 0xff) >> 2; + matchlen = 3; + src++; + } + else if ((fetch & 2) == 0) + { + offset = (fetch & 0xffff) >> 2; + matchlen = 3; + src += 2; + } + else if ((fetch & 1) == 0) + { + offset = (fetch & 0xffff) >> 6; + matchlen = ((fetch >> 2) & 15) + 3; + src += 2; + } + else if ((fetch & 127) != 3) + { + offset = (fetch >> 7) & 0x1ffff; + matchlen = ((fetch >> 2) & 0x1f) + 2; + src += 3; + } + else + { + offset = (fetch >> 15); + matchlen = ((fetch >> 7) & 255) + 3; + src += 4; + } + + offset2 = dst - offset; +#endif + +#ifdef QLZ_MEMORY_SAFE + if (offset2 < history || offset2 > dst - MINOFFSET - 1) + return 0; + + if (matchlen > (ui32)(last_destination_byte - dst - UNCOMPRESSED_END + 1)) + return 0; +#endif + + memcpy_up(dst, offset2, matchlen); + dst += matchlen; + +#if QLZ_COMPRESSION_LEVEL <= 2 + update_hash_upto(state, &last_hashed, dst - matchlen); + last_hashed = dst - 1; +#endif + } + else + { + if (dst < last_matchstart) + { + unsigned int n = bitlut[cword_val & 0xf]; +#ifdef X86X64 + *(ui32 *)dst = *(ui32 *)src; +#else + memcpy_up(dst, src, 4); +#endif + cword_val = cword_val >> n; + dst += n; + src += n; +#if QLZ_COMPRESSION_LEVEL <= 2 + update_hash_upto(state, &last_hashed, dst - 3); +#endif + } + else + { + while (dst <= last_destination_byte) + { + if (cword_val == 1) + { + src += CWORD_LEN; + cword_val = 1U << 31; + } +#ifdef QLZ_MEMORY_SAFE + if (src >= last_source_byte + 1) + return 0; +#endif + *dst = *src; + dst++; + src++; + cword_val = cword_val >> 1; + } + +#if QLZ_COMPRESSION_LEVEL <= 2 + update_hash_upto(state, &last_hashed, last_destination_byte - 3); // todo, use constant +#endif + return size; + } + + } + } +} + +size_t qlz_compress(const void *source, char *destination, size_t size, qlz_state_compress *state) +{ + size_t r; + ui32 compressed; + size_t base; + + if (size == 0 || size > 0xffffffff - 400) + return 0; + + if (size < 216) + base = 3; + else + base = 9; + +#if QLZ_STREAMING_BUFFER > 0 + if (state->stream_counter + size - 1 >= QLZ_STREAMING_BUFFER) +#endif + { + reset_table_compress(state); + r = base + qlz_compress_core((const unsigned char *)source, (unsigned char *)destination + base, size, state); +#if QLZ_STREAMING_BUFFER > 0 + reset_table_compress(state); +#endif + if (r == base) + { + memcpy(destination + base, source, size); + r = size + base; + compressed = 0; + } + else + { + compressed = 1; + } + state->stream_counter = 0; + } +#if QLZ_STREAMING_BUFFER > 0 + else + { + unsigned char *src = state->stream_buffer + state->stream_counter; + + memcpy(src, source, size); + r = base + qlz_compress_core(src, (unsigned char *)destination + base, size, state); + + if (r == base) + { + memcpy(destination + base, src, size); + r = size + base; + compressed = 0; + reset_table_compress(state); + } + else + { + compressed = 1; + } + state->stream_counter += size; + } +#endif + if (base == 3) + { + *destination = (unsigned char)(0 | compressed); + *(destination + 1) = (unsigned char)r; + *(destination + 2) = (unsigned char)size; + } + else + { + *destination = (unsigned char)(2 | compressed); + fast_write((ui32)r, destination + 1, 4); + fast_write((ui32)size, destination + 5, 4); + } + + *destination |= (QLZ_COMPRESSION_LEVEL << 2); + *destination |= (1 << 6); + *destination |= ((QLZ_STREAMING_BUFFER == 0 ? 0 : (QLZ_STREAMING_BUFFER == 100000 ? 1 : (QLZ_STREAMING_BUFFER == 1000000 ? 2 : 3))) << 4); + +// 76543210 +// 01SSLLHC + + return r; +} + +size_t qlz_decompress(const char *source, void *destination, qlz_state_decompress *state) +{ + size_t dsiz = qlz_size_decompressed(source); + +#if QLZ_STREAMING_BUFFER > 0 + if (state->stream_counter + qlz_size_decompressed(source) - 1 >= QLZ_STREAMING_BUFFER) +#endif + { + if ((*source & 1) == 1) + { + reset_table_decompress(state); + dsiz = qlz_decompress_core((const unsigned char *)source, (unsigned char *)destination, dsiz, state, (const unsigned char *)destination); + } + else + { + memcpy(destination, source + qlz_size_header(source), dsiz); + } + state->stream_counter = 0; + reset_table_decompress(state); + } +#if QLZ_STREAMING_BUFFER > 0 + else + { + unsigned char *dst = state->stream_buffer + state->stream_counter; + if ((*source & 1) == 1) + { + dsiz = qlz_decompress_core((const unsigned char *)source, dst, dsiz, state, (const unsigned char *)state->stream_buffer); + } + else + { + memcpy(dst, source + qlz_size_header(source), dsiz); + reset_table_decompress(state); + } + memcpy(destination, dst, dsiz); + state->stream_counter += dsiz; + } +#endif + return dsiz; +} + diff --git a/polymer/eduke32/build/src/rawinput.c b/polymer/eduke32/build/src/rawinput.c index 18f78be75..d68cedceb 100644 --- a/polymer/eduke32/build/src/rawinput.c +++ b/polymer/eduke32/build/src/rawinput.c @@ -18,10 +18,10 @@ extern void SetKey(int32_t key, int32_t state); #define MASK_UP (MASK_DOWN<<1) #define MouseWheelFakePressTime 50 #ifndef GET_RAWINPUT_CODE_WPARAM - #define GET_RAWINPUT_CODE_WPARAM(wParam) ((wParam) & 0xff) +#define GET_RAWINPUT_CODE_WPARAM(wParam) ((wParam) & 0xff) #endif -static inline void RI_ProcessMouse(const RAWMOUSE* rmouse) +static inline void RI_ProcessMouse(const RAWMOUSE *rmouse) { int32_t i, mask; @@ -77,11 +77,11 @@ 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; - // for some reason rkbd->MakeCode is wrong for these + // for some reason rkbd->MakeCode is wrong for these // even though rkbd->VKey is right... switch (VKey) @@ -110,7 +110,7 @@ static inline void RI_ProcessKeyboard(const RAWKEYBOARD* rkbd) else VKey = VK_NUMPAD6, key = sc_kpad_6; break; case VK_DIVIDE: // if (rkbd->Flags & RI_KEY_E0) key = sc_Slash; -// else +// else key = sc_kpad_Slash; break; case VK_INSERT: @@ -262,18 +262,18 @@ void grabmouse(char a) { static POINT pos; static int32_t d = 0; - + if (!moustat) return; if (!mousegrab || !d) { - GetCursorPos(&pos); - d++; - } - - ShowCursor(a == 0); - RI_CaptureInput(a, (HWND)win_gethwnd()); - SetCursorPos(pos.x, pos.y); + GetCursorPos(&pos); + d++; + } + + ShowCursor(a == 0); + RI_CaptureInput(a, (HWND)win_gethwnd()); + SetCursorPos(pos.x, pos.y); } void readmousexy(int32_t *x, int32_t *y) diff --git a/polymer/eduke32/build/src/scriptfile.c b/polymer/eduke32/build/src/scriptfile.c index 970ea1fed..446303a0e 100644 --- a/polymer/eduke32/build/src/scriptfile.c +++ b/polymer/eduke32/build/src/scriptfile.c @@ -279,7 +279,7 @@ scriptfile *scriptfile_fromfile(const char *fn) return NULL; } - sf = (scriptfile*) Bmalloc(sizeof(scriptfile)); + sf = (scriptfile *) Bmalloc(sizeof(scriptfile)); if (!sf) { kclose(fp); @@ -311,7 +311,7 @@ scriptfile *scriptfile_fromstring(const char *string) tx = (char *) Bmalloc(flen + 2); if (!tx) return NULL; - sf = (scriptfile*) Bmalloc(sizeof(scriptfile)); + sf = (scriptfile *) Bmalloc(sizeof(scriptfile)); if (!sf) { Bfree(tx); @@ -349,7 +349,7 @@ int32_t scriptfile_eof(scriptfile *sf) static int32_t symbtablength=0, symbtaballoclength=0; static char *symbtab = NULL; -static char * getsymbtabspace(int32_t reqd) +static char *getsymbtabspace(int32_t reqd) { char *pos,*np; int32_t i; @@ -375,7 +375,7 @@ int32_t scriptfile_getsymbolvalue(char *name, int32_t *val) { if (!Bstrcasecmp(name, scanner)) { - *val = *(int32_t*)(scanner + strlen(scanner) + 1); + *val = *(int32_t *)(scanner + strlen(scanner) + 1); return 1; } @@ -397,7 +397,7 @@ int32_t scriptfile_addsymbolvalue(char *name, int32_t val) { if (!Bstrcasecmp(name, scanner)) { - *(int32_t*)(scanner + strlen(scanner) + 1) = val; + *(int32_t *)(scanner + strlen(scanner) + 1) = val; return 1; } @@ -409,7 +409,7 @@ int32_t scriptfile_addsymbolvalue(char *name, int32_t val) if (!sp) return 0; strcpy(sp, name); sp += strlen(name)+1; - *(int32_t*)sp = val; + *(int32_t *)sp = val; return 1; // added } diff --git a/polymer/eduke32/build/src/sdlayer.c b/polymer/eduke32/build/src/sdlayer.c index 51e858d68..1ef417d32 100644 --- a/polymer/eduke32/build/src/sdlayer.c +++ b/polymer/eduke32/build/src/sdlayer.c @@ -54,7 +54,7 @@ int32_t _buildargc = 1; const char **_buildargv = NULL; extern int32_t app_main(int32_t argc, const char *argv[]); -char quitevent=0, appactive=1; +char quitevent=0, appactive=1, novideo=0; // video static SDL_Surface *sdl_surface; @@ -81,8 +81,8 @@ static char keytranslation[SDL_NUM_SCANCODES]; static int32_t buildkeytranslationtable(void); //static SDL_Surface * loadtarga(const char *fn); // for loading the icon -static SDL_Surface * appicon = NULL; -static SDL_Surface * loadappicon(void); +static SDL_Surface *appicon = NULL; +static SDL_Surface *loadappicon(void); static mutex_t m_initprintf; @@ -183,7 +183,7 @@ int32_t main(int32_t argc, char *argv[]) startwin_open(); _buildargc = argc; - _buildargv = (const char**)argv; + _buildargv = (const char **)argv; // pipe standard outputs to files if ((argp = Bgetenv("BUILD_LOGSTDOUT")) != NULL) @@ -228,7 +228,7 @@ void setvsync(int32_t sync) } #endif -static void attach_debugger_here(void){} +static void attach_debugger_here(void) {} #ifdef __GNUC__ # define PRINTSTACKONSEGV 1 @@ -295,8 +295,15 @@ int32_t initsystem(void) #endif )) { - initprintf("Initialization failed! (%s)\n", SDL_GetError()); - return -1; + initprintf("Initialization failed! (%s)\nNon-interactive mode enabled\n", SDL_GetError()); + /* if (SDL_Init(0)) + { + initprintf("Initialization failed! (%s)\n", SDL_GetError()); + return -1; + } + else + */ + novideo = nogl = 1; } signal(SIGSEGV, sighandler); @@ -309,7 +316,7 @@ int32_t initsystem(void) lockcount = 0; #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"); nogl = 1; @@ -317,15 +324,20 @@ int32_t initsystem(void) #endif #ifndef __APPLE__ - + //icon = loadtarga("icon.tga"); - appicon = loadappicon(); - if (appicon) - SDL_WM_SetIcon(appicon, 0); + + if (!novideo) + { + appicon = loadappicon(); + if (appicon) + SDL_WM_SetIcon(appicon, 0); + } #endif - if (SDL_VideoDriverName(drvname, 32)) - initprintf("Using \"%s\" video driver\n", drvname); + if (!novideo) + if (SDL_VideoDriverName(drvname, 32)) + initprintf("Using \"%s\" video driver\n", drvname); /* // dump a quick summary of the graphics hardware @@ -384,8 +396,8 @@ void initprintf(const char *f, ...) Bvsnprintf(buf, sizeof(buf), f, va); va_end(va); - OSD_Printf(buf); - Bprintf("%s", buf); + OSD_Printf("%s", buf); +// Bprintf("%s", buf); mutex_lock(&m_initprintf); if (Bstrlen(dabuf) + Bstrlen(buf) > 1022) @@ -495,7 +507,7 @@ int32_t initinput(void) joyhat = (int32_t *)Bcalloc(joynumhats, sizeof(int32_t)); for (i = 0; i < joynumhats; i++) - joyhat[i] = -1; // centre + joyhat[i] = -1; // centre joydead = (uint16_t *)Bcalloc(joynumaxes, sizeof(uint16_t)); joysatur = (uint16_t *)Bcalloc(joynumaxes, sizeof(uint16_t)); @@ -793,7 +805,7 @@ void getvalidmodes(void) #endif int32_t i, j, maxx=0, maxy=0; - if (modeschecked) return; + if (modeschecked || novideo) return; validmodecnt=0; // initprintf("Detecting video modes:\n"); @@ -879,7 +891,7 @@ void getvalidmodes(void) #undef CHECK #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; } @@ -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); #ifdef POLYMER - if (!Bstrcmp(glinfo.vendor,"ATI Technologies Inc.")) { + if (!Bstrcmp(glinfo.vendor,"ATI Technologies Inc.")) + { pr_ati_fboworkaround = 1; 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; initprintf("Enabling ATI R520 polygon offset workaround.\n"); - } else + } + else pr_ati_nodepthoffset = 0; #ifdef __APPLE__ //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; initprintf("Enabling ATI Radeon 9600 texture format workaround.\n"); - } else + } + else pr_ati_textureformat_one = 0; #endif - } else + } + else pr_ati_fboworkaround = 0; #endif - glinfo.maxanisotropy = 1.0; glinfo.bgra = 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 p = Bstrdup(glinfo.extensions); 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")) { @@ -1446,7 +1463,7 @@ int32_t setpalette(int32_t start, int32_t num) curpalettefaded[i].f = pal[i].unused = 0; //return SDL_SetPalette(sdl_surface, SDL_LOGPAL|SDL_PHYSPAL, pal, 0, 256); - + return sdl_surface ? SDL_SetColors(sdl_surface, pal, 0, 256) : 0; } @@ -1487,6 +1504,8 @@ int32_t setgamma(void) double invgamma = 1 / gamma; double norm = pow(255., invgamma - 1); + if (novideo) return 0; + // This formula is taken from Doomsday for (i = 0; i < 256; i++) @@ -1502,11 +1521,11 @@ int32_t setgamma(void) #ifndef __APPLE__ extern struct sdlappicon sdlappicon; -static SDL_Surface * loadappicon(void) +static SDL_Surface *loadappicon(void) { SDL_Surface *surf; - surf = SDL_CreateRGBSurfaceFrom((void*)sdlappicon.pixels, + surf = SDL_CreateRGBSurfaceFrom((void *)sdlappicon.pixels, sdlappicon.width, sdlappicon.height, 32, sdlappicon.width*4, 0xffl,0xff00l,0xff0000l,0xff000000l); @@ -1549,7 +1568,7 @@ int32_t handleevents(void) if (code != scantoasc[OSD_OSDKey()] && ((keyasciififoend+1)&(KEYFIFOSIZ-1)) != keyasciififoplc) { // printf("got char %d\n",code); - + if (OSD_HandleChar(code)) { keyasciififo[keyasciififoend] = code; @@ -1750,15 +1769,15 @@ int32_t handleevents(void) { joyaxis[ev.jaxis.axis] = ev.jaxis.value * 10000 / 32767; 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; else if (joyaxis[ev.jaxis.axis] >= joysatur[ev.jaxis.axis]) joyaxis[ev.jaxis.axis] = 10000; else if (joyaxis[ev.jaxis.axis] <= -joysatur[ev.jaxis.axis]) joyaxis[ev.jaxis.axis] = -10000; else - joyaxis[ev.jaxis.axis] = joyaxis[ev.jaxis.axis] * - 10000 / joysatur[ev.jaxis.axis]; + joyaxis[ev.jaxis.axis] = joyaxis[ev.jaxis.axis] * + 10000 / joysatur[ev.jaxis.axis]; } break; @@ -1850,26 +1869,30 @@ inline void idle_waitevent(void) #if (SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION < 3) // SDL 1.2 // 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; if (timeout > 0) expiration = SDL_GetTicks() + timeout; - for (;;) { + for (;;) + { 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: return 0; case 1: return 1; case 0: - if (timeout == 0) { + if (timeout == 0) + { /* Polling and no events, just return */ 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 */ return 0; } diff --git a/polymer/eduke32/build/src/startgtk.editor.c b/polymer/eduke32/build/src/startgtk.editor.c index f621f9269..a41880453 100644 --- a/polymer/eduke32/build/src/startgtk.editor.c +++ b/polymer/eduke32/build/src/startgtk.editor.c @@ -1,17 +1,18 @@ #if defined(LINKED_GTK) - #include - #include +#include +#include #else - #include "dynamicgtk.h" +#include "dynamicgtk.h" #endif #include "build.h" #include "editor.h" #include "baselayer.h" -enum { - TAB_CONFIG, - TAB_MESSAGES, +enum +{ + TAB_CONFIG, + TAB_MESSAGES, }; static struct @@ -46,7 +47,7 @@ static struct GtkWidget *startbuttonlabel; GtkAccelGroup *accel_group; } stwidgets; - + static struct { int32_t fullscreen; @@ -145,8 +146,8 @@ static void SetPage(int32_t n) if (n == TAB_CONFIG) n = TRUE; else n = FALSE; gtk_widget_set_sensitive(stwidgets.startbutton, n); gtk_container_foreach(GTK_CONTAINER(stwidgets.configtlayout), - (GtkCallback)gtk_widget_set_sensitive, - (gpointer)&n); + (GtkCallback)gtk_widget_set_sensitive, + (gpointer)&n); } static void PopulateForm(void) @@ -207,7 +208,7 @@ static void PopulateForm(void) g_signal_handlers_unblock_by_func(box2d, on_vmode2dcombo_changed, NULL); } } - + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stwidgets.fullscreencheck), settings.fullscreen); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stwidgets.alwaysshowcheck), settings.forcesetup); } @@ -246,14 +247,14 @@ static GtkWidget *create_window(void) gtk_container_set_border_width(GTK_CONTAINER(stwidgets.tabs), 4); // layout table of config page - stwidgets.configtlayout = gtk_table_new(4, 3, FALSE); - gtk_container_add(GTK_CONTAINER(stwidgets.tabs), stwidgets.configtlayout); + stwidgets.configtlayout = gtk_table_new(4, 3, FALSE); + gtk_container_add(GTK_CONTAINER(stwidgets.tabs), stwidgets.configtlayout); // 2D video mode label stwidgets.vmode2dlabel = gtk_label_new_with_mnemonic("_2D Video mode:"); - 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_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); + // 2D video mode combo { GtkListStore *list = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); @@ -266,22 +267,22 @@ static GtkWidget *create_window(void) 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_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, GDK_2, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); - - // Fullscreen checkbox + + // Fullscreen checkbox 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, GDK_F, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); - + // 3D video mode label stwidgets.vmode3dlabel = gtk_label_new_with_mnemonic("_3D Video mode:"); - 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_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); // 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_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, GDK_3, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); - // Empty horizontal layout - 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); - + // Empty horizontal layout + 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); + // Always show config checkbox 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, GDK_A, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); diff --git a/polymer/eduke32/build/src/startwin.editor.c b/polymer/eduke32/build/src/startwin.editor.c index 581533648..7067718a7 100644 --- a/polymer/eduke32/build/src/startwin.editor.c +++ b/polymer/eduke32/build/src/startwin.editor.c @@ -434,7 +434,7 @@ int32_t startwin_settitle(const char *str) int32_t startwin_idle(void *v) { if (!startupdlg || !IsWindow(startupdlg)) return 0; - if (IsDialogMessage(startupdlg, (MSG*)v)) return 1; + if (IsDialogMessage(startupdlg, (MSG *)v)) return 1; return 0; } diff --git a/polymer/eduke32/build/src/textfont.c b/polymer/eduke32/build/src/textfont.c index 59c6cf325..8e2027f40 100644 --- a/polymer/eduke32/build/src/textfont.c +++ b/polymer/eduke32/build/src/textfont.c @@ -4,258 +4,258 @@ char textfont[2048] = { 0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF, // . 0x7E, 0x81, 0xA5, 0x81, 0xBD, 0x81, 0x7E, 0x00, // . - 0x7E, 0xFF, 0xDB, 0xFF, 0xC3, 0xFF, 0x7E, 0x00, // . - 0x36, 0x7F, 0x7F, 0x7F, 0x3E, 0x1C, 0x08, 0x00, // . - 0x08, 0x1C, 0x3E, 0x7F, 0x3E, 0x1C, 0x08, 0x00, // . - 0x1C, 0x1C, 0x08, 0x6B, 0x7F, 0x6B, 0x08, 0x1C, // . - 0x08, 0x1C, 0x3E, 0x7F, 0x3E, 0x08, 0x1C, 0x3E, // . - 0x00, 0x00, 0x18, 0x3C, 0x3C, 0x18, 0x00, 0x00, // . - 0xFF, 0xFF, 0xE7, 0xC3, 0xC3, 0xE7, 0xFF, 0xFF, // . - 0x00, 0x3C, 0x66, 0x42, 0x42, 0x66, 0x3C, 0x00, // . - 0xFF, 0xC3, 0x99, 0xBD, 0xBD, 0x99, 0xC3, 0xFF, // . - 0x0F, 0x07, 0x0D, 0x3C, 0x66, 0x66, 0x66, 0x3C, // . - 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x7E, 0x18, // . - 0x30, 0x38, 0x3C, 0x36, 0x34, 0x70, 0xF0, 0xE0, // . - 0x7F, 0x63, 0x7F, 0x63, 0x63, 0x67, 0xE6, 0xC0, // . - 0x18, 0xDB, 0x7E, 0x66, 0x66, 0x7E, 0xDB, 0x18, // . - 0x40, 0x70, 0x7C, 0x7F, 0x7C, 0x70, 0x40, 0x00, // . - 0x01, 0x07, 0x1F, 0x7F, 0x1F, 0x07, 0x01, 0x00, // . - 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x7E, 0x3C, 0x18, // . - 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00, // . - 0x3F, 0x7A, 0x7A, 0x3A, 0x0A, 0x0A, 0x0A, 0x00, // . - 0x1E, 0x33, 0x1C, 0x36, 0x36, 0x1C, 0x66, 0x3C, // . - 0x00, 0x00, 0x00, 0x00, 0x7E, 0x7E, 0x7E, 0x00, // . - 0x18, 0x3C, 0x7E, 0x18, 0x7E, 0x3C, 0x18, 0x7E, // . - 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x00, // . - 0x18, 0x18, 0x18, 0x18, 0x7E, 0x3C, 0x18, 0x00, // . - 0x00, 0x0C, 0x0E, 0x7F, 0x0E, 0x0C, 0x00, 0x00, // . - 0x00, 0x18, 0x38, 0x7F, 0x38, 0x18, 0x00, 0x00, // . - 0x00, 0x00, 0x60, 0x60, 0x60, 0x7F, 0x00, 0x00, // . - 0x00, 0x24, 0x66, 0xFF, 0x66, 0x24, 0x00, 0x00, // . - 0x00, 0x18, 0x3C, 0x7E, 0xFF, 0xFF, 0x00, 0x00, // . - 0x00, 0xFF, 0xFF, 0x7E, 0x3C, 0x18, 0x00, 0x00, // - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ! - 0x06, 0x0E, 0x0C, 0x18, 0x10, 0x00, 0x20, 0x00, // " - 0x6C, 0x6C, 0x24, 0x48, 0x00, 0x00, 0x00, 0x00, // # - 0x6C, 0x6C, 0xFE, 0x6C, 0xFE, 0x6C, 0x6C, 0x00, // $ - 0x10, 0x7C, 0xD0, 0x7C, 0x16, 0x7C, 0x10, 0x00, // % - 0x00, 0xC6, 0xCC, 0x18, 0x30, 0x66, 0xC6, 0x00, // & - 0x38, 0x6C, 0x38, 0x76, 0xDC, 0xCC, 0x76, 0x00, // ' - 0x18, 0x18, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, // ( - 0x0C, 0x18, 0x30, 0x30, 0x30, 0x18, 0x0C, 0x00, // ) - 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x18, 0x30, 0x00, // * - 0x00, 0x6C, 0x38, 0xFE, 0x38, 0x6C, 0x00, 0x00, // + - 0x00, 0x18, 0x18, 0x7E, 0x7E, 0x18, 0x18, 0x00, // , - 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x08, 0x10, // - - 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, // . - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, // / - 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0x80, // 0 - 0x3C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00, // 1 - 0x0C, 0x1C, 0x3C, 0x0C, 0x0C, 0x0C, 0x0C, 0x00, // 2 - 0x3C, 0x66, 0x06, 0x1C, 0x30, 0x60, 0x7E, 0x00, // 3 - 0x3C, 0x66, 0x06, 0x1C, 0x06, 0x66, 0x3C, 0x00, // 4 - 0x1C, 0x3C, 0x6C, 0xCC, 0xFF, 0x0C, 0x0C, 0x00, // 5 - 0x7E, 0x60, 0x60, 0x7C, 0x06, 0x66, 0x3C, 0x00, // 6 - 0x3C, 0x60, 0x60, 0x7C, 0x66, 0x66, 0x3C, 0x00, // 7 - 0x7E, 0x06, 0x06, 0x0C, 0x18, 0x30, 0x30, 0x00, // 8 - 0x3C, 0x66, 0x66, 0x3C, 0x66, 0x66, 0x3C, 0x00, // 9 - 0x3C, 0x66, 0x66, 0x3E, 0x06, 0x06, 0x3C, 0x00, // : - 0x00, 0x30, 0x30, 0x00, 0x30, 0x30, 0x00, 0x00, // ; - 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x08, 0x10, // < - 0x0C, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0C, 0x00, // = - 0x00, 0x00, 0x7E, 0x00, 0x00, 0x7E, 0x00, 0x00, // > - 0x30, 0x18, 0x0C, 0x06, 0x0C, 0x18, 0x30, 0x00, // ? - 0x3C, 0x66, 0x06, 0x0C, 0x18, 0x00, 0x18, 0x00, // @ - 0x3C, 0x66, 0x6E, 0x6E, 0x6C, 0x60, 0x3C, 0x00, // A - 0x1C, 0x36, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x00, // B - 0x1C, 0x36, 0x66, 0x7C, 0x66, 0x66, 0x7C, 0x00, // C - 0x1C, 0x36, 0x60, 0x60, 0x60, 0x66, 0x3C, 0x00, // D - 0x78, 0x6C, 0x66, 0x66, 0x66, 0x66, 0x7C, 0x00, // E - 0x1E, 0x30, 0x60, 0x7C, 0x60, 0x60, 0x7E, 0x00, // F - 0x1E, 0x30, 0x60, 0x7C, 0x60, 0x60, 0x60, 0x00, // G - 0x1C, 0x36, 0x60, 0x6E, 0x66, 0x66, 0x3C, 0x00, // H - 0x66, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x66, 0x00, // I - 0x3C, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, // J - 0x06, 0x06, 0x06, 0x06, 0x66, 0x6C, 0x38, 0x00, // K - 0x66, 0x6C, 0x78, 0x70, 0x78, 0x6C, 0x66, 0x00, // L - 0x60, 0x60, 0x60, 0x60, 0x60, 0x62, 0x3E, 0x00, // M - 0xC6, 0xEE, 0xFE, 0xFE, 0xD6, 0xC6, 0xC6, 0x00, // N - 0x26, 0x76, 0x7E, 0x6E, 0x66, 0x66, 0x66, 0x00, // O - 0x1C, 0x36, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00, // P - 0x1C, 0x36, 0x66, 0x7C, 0x60, 0x60, 0x60, 0x00, // Q - 0x1C, 0x36, 0x66, 0x66, 0x66, 0x6E, 0x3C, 0x06, // R - 0x1C, 0x36, 0x66, 0x7C, 0x66, 0x66, 0x66, 0x00, // S - 0x3C, 0x66, 0x60, 0x3C, 0x06, 0x66, 0x3C, 0x00, // T - 0x7E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, // U - 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00, // V - 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x00, // W - 0xC6, 0xC6, 0xC6, 0xD6, 0xFE, 0xEE, 0xC6, 0x00, // X - 0x66, 0x66, 0x3C, 0x18, 0x3C, 0x66, 0x66, 0x00, // Y - 0x66, 0x66, 0x66, 0x3C, 0x18, 0x18, 0x18, 0x00, // Z - 0x7E, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x7E, 0x00, // [ - 0x3C, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3C, 0x00, // - 0x80, 0xC0, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x03, // ] - 0x3C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x3C, 0x00, // ^ - 0x18, 0x3C, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, // _ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, // ` - 0x18, 0x18, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, // a - 0x00, 0x00, 0x3C, 0x6C, 0x6C, 0x6C, 0x36, 0x00, // b - 0x30, 0x30, 0x3C, 0x36, 0x36, 0x36, 0x5C, 0x00, // c - 0x00, 0x00, 0x38, 0x64, 0x60, 0x64, 0x38, 0x00, // d - 0x0C, 0x0C, 0x3C, 0x6C, 0x6C, 0x6C, 0x36, 0x00, // e - 0x00, 0x00, 0x38, 0x64, 0x7C, 0x60, 0x38, 0x00, // f - 0x18, 0x34, 0x30, 0x7C, 0x30, 0x30, 0x30, 0x00, // g - 0x00, 0x00, 0x3C, 0x68, 0x38, 0x7C, 0x4C, 0x38, // h - 0x60, 0x60, 0x78, 0x6C, 0x6C, 0x6C, 0x6C, 0x00, // i - 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x00, // j - 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x58, 0x30, // k - 0x60, 0x60, 0x66, 0x6C, 0x78, 0x6C, 0x66, 0x00, // l - 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x18, 0x00, // m - 0x00, 0x00, 0xEC, 0xD6, 0xD6, 0xD6, 0xC6, 0x00, // n - 0x00, 0x00, 0xB8, 0x6C, 0x6C, 0x6C, 0x6C, 0x00, // o - 0x00, 0x00, 0x38, 0x6C, 0x6C, 0x6C, 0x38, 0x00, // p - 0x00, 0x00, 0x5C, 0x36, 0x36, 0x3C, 0x30, 0x30, // q - 0x00, 0x00, 0x3A, 0x6C, 0x6C, 0x3C, 0x0C, 0x0E, // r - 0x00, 0x00, 0x5C, 0x3A, 0x30, 0x30, 0x30, 0x00, // s - 0x00, 0x00, 0x38, 0x60, 0x38, 0x0C, 0x78, 0x00, // t - 0x30, 0x30, 0x7C, 0x30, 0x30, 0x34, 0x18, 0x00, // u - 0x00, 0x00, 0x6C, 0x6C, 0x6C, 0x6C, 0x36, 0x00, // v - 0x00, 0x00, 0x6C, 0x6C, 0x6C, 0x38, 0x10, 0x00, // w - 0x00, 0x00, 0xC6, 0xC6, 0xD6, 0xD6, 0x6C, 0x00, // x - 0x00, 0x00, 0x62, 0x34, 0x18, 0x1C, 0x66, 0x00, // y - 0x00, 0x00, 0x6C, 0x6C, 0x6C, 0x3E, 0x2C, 0x38, // z - 0x00, 0x00, 0x7C, 0x0C, 0x18, 0x30, 0x7C, 0x00, // { - 0x1C, 0x30, 0x30, 0x60, 0x30, 0x30, 0x1C, 0x00, // | - 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // } - 0x38, 0x0C, 0x0C, 0x06, 0x0C, 0x0C, 0x38, 0x00, // ~ - 0x76, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // . - 0x00, 0x00, 0x18, 0x3C, 0x66, 0x66, 0x7E, 0x00, // . - 0x3F, 0x61, 0x63, 0xF8, 0x60, 0xF9, 0x61, 0x3F, // . - 0x66, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3E, 0x00, // . - 0x0E, 0x00, 0x3C, 0x66, 0x7E, 0x60, 0x3C, 0x00, // . - 0x3C, 0x66, 0x3C, 0x06, 0x3E, 0x66, 0x3E, 0x00, // . - 0x66, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x3E, 0x00, // . - 0x70, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x3E, 0x00, // . - 0x1C, 0x1C, 0x3C, 0x06, 0x3E, 0x66, 0x3E, 0x00, // . - 0x00, 0x00, 0x3E, 0x60, 0x60, 0x3E, 0x18, 0x30, // . - 0x3C, 0x66, 0x3C, 0x66, 0x7E, 0x60, 0x3C, 0x00, // . - 0x66, 0x00, 0x3C, 0x66, 0x7E, 0x60, 0x3C, 0x00, // . - 0x70, 0x00, 0x3C, 0x66, 0x7E, 0x60, 0x3C, 0x00, // . - 0x66, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, // . - 0x3C, 0x66, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, // . - 0x70, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, // . - 0xC6, 0x38, 0x6C, 0xC6, 0xFE, 0xC6, 0xC6, 0x00, // . - 0x1C, 0x1C, 0x00, 0x3C, 0x66, 0x7E, 0x66, 0x00, // . - 0x0C, 0x18, 0x7C, 0x60, 0x78, 0x60, 0x7C, 0x00, // . - 0x00, 0x00, 0x7E, 0x1A, 0x7E, 0xD8, 0x7E, 0x00, // . - 0x3E, 0x78, 0xD8, 0xDE, 0xF8, 0xD8, 0xDE, 0x00, // . - 0x3C, 0x66, 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x00, // . - 0x66, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x00, // . - 0x70, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x00, // . - 0x3C, 0x66, 0x00, 0x66, 0x66, 0x66, 0x3E, 0x00, // . - 0x70, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3E, 0x00, // . - 0x66, 0x00, 0x66, 0x66, 0x66, 0x3E, 0x06, 0x3C, // . - 0x66, 0x3C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, // . - 0x66, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, // . - 0x0C, 0x0C, 0x3E, 0x60, 0x60, 0x3E, 0x0C, 0x0C, // . - 0x38, 0x6C, 0x60, 0xF0, 0x60, 0x66, 0xFC, 0x00, // . - 0x66, 0x66, 0x3C, 0x18, 0x7E, 0x18, 0x7E, 0x18, // . - 0x7C, 0x66, 0x66, 0x7C, 0x66, 0x6F, 0x66, 0x63, // . - 0x0E, 0x1B, 0x18, 0x3C, 0x18, 0x18, 0x78, 0x30, // . - 0x0E, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x3E, 0x00, // . - 0x0E, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, // . - 0x0E, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x00, // . - 0x0E, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3E, 0x00, // . - 0x3B, 0x6E, 0x00, 0x7C, 0x66, 0x66, 0x66, 0x00, // . - 0x3B, 0x6E, 0x00, 0x66, 0x76, 0x7E, 0x6E, 0x66, // . - 0x3E, 0x66, 0x66, 0x3E, 0x00, 0x7E, 0x00, 0x00, // . - 0x3C, 0x66, 0x66, 0x3C, 0x00, 0x7E, 0x00, 0x00, // . - 0x18, 0x00, 0x18, 0x30, 0x60, 0x66, 0x3C, 0x00, // . - 0x00, 0x00, 0x00, 0x7E, 0x60, 0x60, 0x00, 0x00, // . - 0x00, 0x00, 0x00, 0x7E, 0x06, 0x06, 0x00, 0x00, // . - 0xC6, 0xCC, 0xD8, 0x3E, 0x63, 0xC6, 0x0C, 0x1F, // . - 0xC6, 0xCC, 0xD8, 0x36, 0x6E, 0xD6, 0x1F, 0x06, // . - 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, // . - 0x00, 0x36, 0x6C, 0xD8, 0x6C, 0x36, 0x00, 0x00, // . - 0x00, 0xD8, 0x6C, 0x36, 0x6C, 0xD8, 0x00, 0x00, // . - 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, // . - 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, // . - 0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77, // . - 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, // . - 0x08, 0x08, 0x08, 0x08, 0xF8, 0x08, 0x08, 0x08, // . - 0x08, 0x08, 0x08, 0xF8, 0xF8, 0x08, 0x08, 0x08, // . - 0x1C, 0x1C, 0x1C, 0x1C, 0xFC, 0x1C, 0x1C, 0x1C, // . - 0x00, 0x00, 0x00, 0x00, 0xFC, 0x1C, 0x1C, 0x1C, // . - 0x00, 0x00, 0x00, 0xF8, 0xF8, 0x08, 0x08, 0x08, // . - 0x1C, 0x1C, 0x1C, 0xFC, 0xFC, 0x1C, 0x1C, 0x1C, // . - 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, // . - 0x00, 0x00, 0x00, 0xFC, 0xFC, 0x1C, 0x1C, 0x1C, // . - 0x1C, 0x1C, 0x1C, 0xFC, 0xFC, 0x00, 0x00, 0x00, // . - 0x1C, 0x1C, 0x1C, 0x1C, 0xFC, 0x00, 0x00, 0x00, // . - 0x08, 0x08, 0x08, 0xF8, 0xF8, 0x00, 0x00, 0x00, // . - 0x00, 0x00, 0x00, 0x00, 0xF8, 0x08, 0x08, 0x08, // . - 0x08, 0x08, 0x08, 0x08, 0x0F, 0x00, 0x00, 0x00, // . - 0x08, 0x08, 0x08, 0x08, 0xFF, 0x00, 0x00, 0x00, // . - 0x00, 0x00, 0x00, 0x00, 0xFF, 0x08, 0x08, 0x08, // . - 0x08, 0x08, 0x08, 0x08, 0x0F, 0x08, 0x08, 0x08, // . - 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, // . - 0x08, 0x08, 0x08, 0x08, 0xFF, 0x08, 0x08, 0x08, // . - 0x08, 0x08, 0x08, 0x0F, 0x0F, 0x08, 0x08, 0x08, // . - 0x1C, 0x1C, 0x1C, 0x1C, 0x1F, 0x1C, 0x1C, 0x1C, // . - 0x1C, 0x1C, 0x1C, 0x1F, 0x1F, 0x00, 0x00, 0x00, // . - 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x1C, 0x1C, 0x1C, // . - 0x1C, 0x1C, 0x1C, 0xFF, 0xFF, 0x00, 0x00, 0x00, // . - 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x1C, 0x1C, 0x1C, // . - 0x1C, 0x1C, 0x1C, 0x1F, 0x1F, 0x1C, 0x1C, 0x1C, // . - 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, // . - 0x1C, 0x1C, 0x1C, 0xFF, 0xFF, 0x1C, 0x1C, 0x1C, // . - 0x08, 0x08, 0x08, 0xFF, 0xFF, 0x00, 0x00, 0x00, // . - 0x1C, 0x1C, 0x1C, 0x1C, 0xFF, 0x00, 0x00, 0x00, // . - 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x08, 0x08, 0x08, // . - 0x00, 0x00, 0x00, 0x00, 0xFF, 0x1C, 0x1C, 0x1C, // . - 0x1C, 0x1C, 0x1C, 0x1C, 0x1F, 0x00, 0x00, 0x00, // . - 0x08, 0x08, 0x08, 0x0F, 0x0F, 0x00, 0x00, 0x00, // . - 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x08, 0x08, 0x08, // . - 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1C, 0x1C, 0x1C, // . - 0x1C, 0x1C, 0x1C, 0x1C, 0xFF, 0x1C, 0x1C, 0x1C, // . - 0x08, 0x08, 0x08, 0xFF, 0xFF, 0x08, 0x08, 0x08, // . - 0x08, 0x08, 0x08, 0x08, 0xF8, 0x00, 0x00, 0x00, // . - 0x00, 0x00, 0x00, 0x00, 0x0F, 0x08, 0x08, 0x08, // . - 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, // . - 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, // . - 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, // . - 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // . - 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, // . - 0x00, 0x00, 0x76, 0xCC, 0xCC, 0xCC, 0x76, 0x00, // . - 0x3C, 0x66, 0x66, 0x7C, 0x66, 0x66, 0x7C, 0x60, // . - 0x7E, 0x66, 0x60, 0x60, 0x60, 0x60, 0x60, 0x00, // . - 0x00, 0x00, 0xFE, 0x6C, 0x6C, 0x6C, 0x66, 0x00, // . - 0x7E, 0x66, 0x30, 0x18, 0x30, 0x66, 0x7E, 0x00, // . - 0x00, 0x00, 0x3E, 0x6C, 0x6C, 0x6C, 0x38, 0x00, // . - 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x7F, 0xC0, // . - 0x00, 0x00, 0x7E, 0xD8, 0x18, 0x18, 0x0C, 0x00, // . - 0x7C, 0x38, 0x7C, 0xD6, 0xD6, 0x7C, 0x38, 0x7C, // . - 0x7C, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0x7C, 0x00, // . - 0x7C, 0xC6, 0xC6, 0xC6, 0x6C, 0x6C, 0xEE, 0x00, // . - 0x1E, 0x30, 0x18, 0x3C, 0x66, 0x66, 0x3C, 0x00, // . - 0x00, 0x00, 0x7E, 0xDB, 0xDB, 0x7E, 0x00, 0x00, // . - 0x03, 0x06, 0x3E, 0x6B, 0x73, 0x3E, 0x60, 0xC0, // . - 0x1E, 0x30, 0x60, 0x7E, 0x60, 0x30, 0x1E, 0x00, // . - 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, // . - 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x00, // . - 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x7E, 0x00, // . - 0x30, 0x18, 0x0C, 0x18, 0x30, 0x00, 0x7E, 0x00, // . - 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x00, 0x7E, 0x00, // . - 0x0E, 0x1B, 0x1B, 0x18, 0x18, 0x18, 0x18, 0x18, // . - 0x18, 0x18, 0x18, 0x18, 0x18, 0xD8, 0xD8, 0x70, // . - 0x18, 0x18, 0x00, 0x7E, 0x00, 0x18, 0x18, 0x00, // . - 0x00, 0x76, 0xDC, 0x00, 0x76, 0xDC, 0x00, 0x00, // . - 0x3C, 0x66, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, // . - 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, // . - 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, // . - 0x1E, 0x18, 0x18, 0x18, 0x18, 0xD8, 0x78, 0x38, // . - 0x78, 0x6C, 0x6C, 0x6C, 0x6C, 0x00, 0x00, 0x00, // . - 0x38, 0x0C, 0x18, 0x30, 0x3C, 0x00, 0x00, 0x00, // . - 0x00, 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00, // . - 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00 -}; + 0x7E, 0xFF, 0xDB, 0xFF, 0xC3, 0xFF, 0x7E, 0x00, // . + 0x36, 0x7F, 0x7F, 0x7F, 0x3E, 0x1C, 0x08, 0x00, // . + 0x08, 0x1C, 0x3E, 0x7F, 0x3E, 0x1C, 0x08, 0x00, // . + 0x1C, 0x1C, 0x08, 0x6B, 0x7F, 0x6B, 0x08, 0x1C, // . + 0x08, 0x1C, 0x3E, 0x7F, 0x3E, 0x08, 0x1C, 0x3E, // . + 0x00, 0x00, 0x18, 0x3C, 0x3C, 0x18, 0x00, 0x00, // . + 0xFF, 0xFF, 0xE7, 0xC3, 0xC3, 0xE7, 0xFF, 0xFF, // . + 0x00, 0x3C, 0x66, 0x42, 0x42, 0x66, 0x3C, 0x00, // . + 0xFF, 0xC3, 0x99, 0xBD, 0xBD, 0x99, 0xC3, 0xFF, // . + 0x0F, 0x07, 0x0D, 0x3C, 0x66, 0x66, 0x66, 0x3C, // . + 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x7E, 0x18, // . + 0x30, 0x38, 0x3C, 0x36, 0x34, 0x70, 0xF0, 0xE0, // . + 0x7F, 0x63, 0x7F, 0x63, 0x63, 0x67, 0xE6, 0xC0, // . + 0x18, 0xDB, 0x7E, 0x66, 0x66, 0x7E, 0xDB, 0x18, // . + 0x40, 0x70, 0x7C, 0x7F, 0x7C, 0x70, 0x40, 0x00, // . + 0x01, 0x07, 0x1F, 0x7F, 0x1F, 0x07, 0x01, 0x00, // . + 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x7E, 0x3C, 0x18, // . + 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00, // . + 0x3F, 0x7A, 0x7A, 0x3A, 0x0A, 0x0A, 0x0A, 0x00, // . + 0x1E, 0x33, 0x1C, 0x36, 0x36, 0x1C, 0x66, 0x3C, // . + 0x00, 0x00, 0x00, 0x00, 0x7E, 0x7E, 0x7E, 0x00, // . + 0x18, 0x3C, 0x7E, 0x18, 0x7E, 0x3C, 0x18, 0x7E, // . + 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x00, // . + 0x18, 0x18, 0x18, 0x18, 0x7E, 0x3C, 0x18, 0x00, // . + 0x00, 0x0C, 0x0E, 0x7F, 0x0E, 0x0C, 0x00, 0x00, // . + 0x00, 0x18, 0x38, 0x7F, 0x38, 0x18, 0x00, 0x00, // . + 0x00, 0x00, 0x60, 0x60, 0x60, 0x7F, 0x00, 0x00, // . + 0x00, 0x24, 0x66, 0xFF, 0x66, 0x24, 0x00, 0x00, // . + 0x00, 0x18, 0x3C, 0x7E, 0xFF, 0xFF, 0x00, 0x00, // . + 0x00, 0xFF, 0xFF, 0x7E, 0x3C, 0x18, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ! + 0x06, 0x0E, 0x0C, 0x18, 0x10, 0x00, 0x20, 0x00, // " + 0x6C, 0x6C, 0x24, 0x48, 0x00, 0x00, 0x00, 0x00, // # + 0x6C, 0x6C, 0xFE, 0x6C, 0xFE, 0x6C, 0x6C, 0x00, // $ + 0x10, 0x7C, 0xD0, 0x7C, 0x16, 0x7C, 0x10, 0x00, // % + 0x00, 0xC6, 0xCC, 0x18, 0x30, 0x66, 0xC6, 0x00, // & + 0x38, 0x6C, 0x38, 0x76, 0xDC, 0xCC, 0x76, 0x00, // ' + 0x18, 0x18, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, // ( + 0x0C, 0x18, 0x30, 0x30, 0x30, 0x18, 0x0C, 0x00, // ) + 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x18, 0x30, 0x00, // * + 0x00, 0x6C, 0x38, 0xFE, 0x38, 0x6C, 0x00, 0x00, // + + 0x00, 0x18, 0x18, 0x7E, 0x7E, 0x18, 0x18, 0x00, // , + 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x08, 0x10, // - + 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, // . + 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, // / + 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0x80, // 0 + 0x3C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00, // 1 + 0x0C, 0x1C, 0x3C, 0x0C, 0x0C, 0x0C, 0x0C, 0x00, // 2 + 0x3C, 0x66, 0x06, 0x1C, 0x30, 0x60, 0x7E, 0x00, // 3 + 0x3C, 0x66, 0x06, 0x1C, 0x06, 0x66, 0x3C, 0x00, // 4 + 0x1C, 0x3C, 0x6C, 0xCC, 0xFF, 0x0C, 0x0C, 0x00, // 5 + 0x7E, 0x60, 0x60, 0x7C, 0x06, 0x66, 0x3C, 0x00, // 6 + 0x3C, 0x60, 0x60, 0x7C, 0x66, 0x66, 0x3C, 0x00, // 7 + 0x7E, 0x06, 0x06, 0x0C, 0x18, 0x30, 0x30, 0x00, // 8 + 0x3C, 0x66, 0x66, 0x3C, 0x66, 0x66, 0x3C, 0x00, // 9 + 0x3C, 0x66, 0x66, 0x3E, 0x06, 0x06, 0x3C, 0x00, // : + 0x00, 0x30, 0x30, 0x00, 0x30, 0x30, 0x00, 0x00, // ; + 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x08, 0x10, // < + 0x0C, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0C, 0x00, // = + 0x00, 0x00, 0x7E, 0x00, 0x00, 0x7E, 0x00, 0x00, // > + 0x30, 0x18, 0x0C, 0x06, 0x0C, 0x18, 0x30, 0x00, // ? + 0x3C, 0x66, 0x06, 0x0C, 0x18, 0x00, 0x18, 0x00, // @ + 0x3C, 0x66, 0x6E, 0x6E, 0x6C, 0x60, 0x3C, 0x00, // A + 0x1C, 0x36, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x00, // B + 0x1C, 0x36, 0x66, 0x7C, 0x66, 0x66, 0x7C, 0x00, // C + 0x1C, 0x36, 0x60, 0x60, 0x60, 0x66, 0x3C, 0x00, // D + 0x78, 0x6C, 0x66, 0x66, 0x66, 0x66, 0x7C, 0x00, // E + 0x1E, 0x30, 0x60, 0x7C, 0x60, 0x60, 0x7E, 0x00, // F + 0x1E, 0x30, 0x60, 0x7C, 0x60, 0x60, 0x60, 0x00, // G + 0x1C, 0x36, 0x60, 0x6E, 0x66, 0x66, 0x3C, 0x00, // H + 0x66, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x66, 0x00, // I + 0x3C, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, // J + 0x06, 0x06, 0x06, 0x06, 0x66, 0x6C, 0x38, 0x00, // K + 0x66, 0x6C, 0x78, 0x70, 0x78, 0x6C, 0x66, 0x00, // L + 0x60, 0x60, 0x60, 0x60, 0x60, 0x62, 0x3E, 0x00, // M + 0xC6, 0xEE, 0xFE, 0xFE, 0xD6, 0xC6, 0xC6, 0x00, // N + 0x26, 0x76, 0x7E, 0x6E, 0x66, 0x66, 0x66, 0x00, // O + 0x1C, 0x36, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00, // P + 0x1C, 0x36, 0x66, 0x7C, 0x60, 0x60, 0x60, 0x00, // Q + 0x1C, 0x36, 0x66, 0x66, 0x66, 0x6E, 0x3C, 0x06, // R + 0x1C, 0x36, 0x66, 0x7C, 0x66, 0x66, 0x66, 0x00, // S + 0x3C, 0x66, 0x60, 0x3C, 0x06, 0x66, 0x3C, 0x00, // T + 0x7E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, // U + 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00, // V + 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x00, // W + 0xC6, 0xC6, 0xC6, 0xD6, 0xFE, 0xEE, 0xC6, 0x00, // X + 0x66, 0x66, 0x3C, 0x18, 0x3C, 0x66, 0x66, 0x00, // Y + 0x66, 0x66, 0x66, 0x3C, 0x18, 0x18, 0x18, 0x00, // Z + 0x7E, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x7E, 0x00, // [ + 0x3C, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3C, 0x00, // + 0x80, 0xC0, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x03, // ] + 0x3C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x3C, 0x00, // ^ + 0x18, 0x3C, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, // _ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, // ` + 0x18, 0x18, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, // a + 0x00, 0x00, 0x3C, 0x6C, 0x6C, 0x6C, 0x36, 0x00, // b + 0x30, 0x30, 0x3C, 0x36, 0x36, 0x36, 0x5C, 0x00, // c + 0x00, 0x00, 0x38, 0x64, 0x60, 0x64, 0x38, 0x00, // d + 0x0C, 0x0C, 0x3C, 0x6C, 0x6C, 0x6C, 0x36, 0x00, // e + 0x00, 0x00, 0x38, 0x64, 0x7C, 0x60, 0x38, 0x00, // f + 0x18, 0x34, 0x30, 0x7C, 0x30, 0x30, 0x30, 0x00, // g + 0x00, 0x00, 0x3C, 0x68, 0x38, 0x7C, 0x4C, 0x38, // h + 0x60, 0x60, 0x78, 0x6C, 0x6C, 0x6C, 0x6C, 0x00, // i + 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x00, // j + 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x58, 0x30, // k + 0x60, 0x60, 0x66, 0x6C, 0x78, 0x6C, 0x66, 0x00, // l + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x18, 0x00, // m + 0x00, 0x00, 0xEC, 0xD6, 0xD6, 0xD6, 0xC6, 0x00, // n + 0x00, 0x00, 0xB8, 0x6C, 0x6C, 0x6C, 0x6C, 0x00, // o + 0x00, 0x00, 0x38, 0x6C, 0x6C, 0x6C, 0x38, 0x00, // p + 0x00, 0x00, 0x5C, 0x36, 0x36, 0x3C, 0x30, 0x30, // q + 0x00, 0x00, 0x3A, 0x6C, 0x6C, 0x3C, 0x0C, 0x0E, // r + 0x00, 0x00, 0x5C, 0x3A, 0x30, 0x30, 0x30, 0x00, // s + 0x00, 0x00, 0x38, 0x60, 0x38, 0x0C, 0x78, 0x00, // t + 0x30, 0x30, 0x7C, 0x30, 0x30, 0x34, 0x18, 0x00, // u + 0x00, 0x00, 0x6C, 0x6C, 0x6C, 0x6C, 0x36, 0x00, // v + 0x00, 0x00, 0x6C, 0x6C, 0x6C, 0x38, 0x10, 0x00, // w + 0x00, 0x00, 0xC6, 0xC6, 0xD6, 0xD6, 0x6C, 0x00, // x + 0x00, 0x00, 0x62, 0x34, 0x18, 0x1C, 0x66, 0x00, // y + 0x00, 0x00, 0x6C, 0x6C, 0x6C, 0x3E, 0x2C, 0x38, // z + 0x00, 0x00, 0x7C, 0x0C, 0x18, 0x30, 0x7C, 0x00, // { + 0x1C, 0x30, 0x30, 0x60, 0x30, 0x30, 0x1C, 0x00, // | + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // } + 0x38, 0x0C, 0x0C, 0x06, 0x0C, 0x0C, 0x38, 0x00, // ~ + 0x76, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // . + 0x00, 0x00, 0x18, 0x3C, 0x66, 0x66, 0x7E, 0x00, // . + 0x3F, 0x61, 0x63, 0xF8, 0x60, 0xF9, 0x61, 0x3F, // . + 0x66, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3E, 0x00, // . + 0x0E, 0x00, 0x3C, 0x66, 0x7E, 0x60, 0x3C, 0x00, // . + 0x3C, 0x66, 0x3C, 0x06, 0x3E, 0x66, 0x3E, 0x00, // . + 0x66, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x3E, 0x00, // . + 0x70, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x3E, 0x00, // . + 0x1C, 0x1C, 0x3C, 0x06, 0x3E, 0x66, 0x3E, 0x00, // . + 0x00, 0x00, 0x3E, 0x60, 0x60, 0x3E, 0x18, 0x30, // . + 0x3C, 0x66, 0x3C, 0x66, 0x7E, 0x60, 0x3C, 0x00, // . + 0x66, 0x00, 0x3C, 0x66, 0x7E, 0x60, 0x3C, 0x00, // . + 0x70, 0x00, 0x3C, 0x66, 0x7E, 0x60, 0x3C, 0x00, // . + 0x66, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, // . + 0x3C, 0x66, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, // . + 0x70, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, // . + 0xC6, 0x38, 0x6C, 0xC6, 0xFE, 0xC6, 0xC6, 0x00, // . + 0x1C, 0x1C, 0x00, 0x3C, 0x66, 0x7E, 0x66, 0x00, // . + 0x0C, 0x18, 0x7C, 0x60, 0x78, 0x60, 0x7C, 0x00, // . + 0x00, 0x00, 0x7E, 0x1A, 0x7E, 0xD8, 0x7E, 0x00, // . + 0x3E, 0x78, 0xD8, 0xDE, 0xF8, 0xD8, 0xDE, 0x00, // . + 0x3C, 0x66, 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x00, // . + 0x66, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x00, // . + 0x70, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x00, // . + 0x3C, 0x66, 0x00, 0x66, 0x66, 0x66, 0x3E, 0x00, // . + 0x70, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3E, 0x00, // . + 0x66, 0x00, 0x66, 0x66, 0x66, 0x3E, 0x06, 0x3C, // . + 0x66, 0x3C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, // . + 0x66, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, // . + 0x0C, 0x0C, 0x3E, 0x60, 0x60, 0x3E, 0x0C, 0x0C, // . + 0x38, 0x6C, 0x60, 0xF0, 0x60, 0x66, 0xFC, 0x00, // . + 0x66, 0x66, 0x3C, 0x18, 0x7E, 0x18, 0x7E, 0x18, // . + 0x7C, 0x66, 0x66, 0x7C, 0x66, 0x6F, 0x66, 0x63, // . + 0x0E, 0x1B, 0x18, 0x3C, 0x18, 0x18, 0x78, 0x30, // . + 0x0E, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x3E, 0x00, // . + 0x0E, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, // . + 0x0E, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x00, // . + 0x0E, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3E, 0x00, // . + 0x3B, 0x6E, 0x00, 0x7C, 0x66, 0x66, 0x66, 0x00, // . + 0x3B, 0x6E, 0x00, 0x66, 0x76, 0x7E, 0x6E, 0x66, // . + 0x3E, 0x66, 0x66, 0x3E, 0x00, 0x7E, 0x00, 0x00, // . + 0x3C, 0x66, 0x66, 0x3C, 0x00, 0x7E, 0x00, 0x00, // . + 0x18, 0x00, 0x18, 0x30, 0x60, 0x66, 0x3C, 0x00, // . + 0x00, 0x00, 0x00, 0x7E, 0x60, 0x60, 0x00, 0x00, // . + 0x00, 0x00, 0x00, 0x7E, 0x06, 0x06, 0x00, 0x00, // . + 0xC6, 0xCC, 0xD8, 0x3E, 0x63, 0xC6, 0x0C, 0x1F, // . + 0xC6, 0xCC, 0xD8, 0x36, 0x6E, 0xD6, 0x1F, 0x06, // . + 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, // . + 0x00, 0x36, 0x6C, 0xD8, 0x6C, 0x36, 0x00, 0x00, // . + 0x00, 0xD8, 0x6C, 0x36, 0x6C, 0xD8, 0x00, 0x00, // . + 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, // . + 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, // . + 0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77, // . + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, // . + 0x08, 0x08, 0x08, 0x08, 0xF8, 0x08, 0x08, 0x08, // . + 0x08, 0x08, 0x08, 0xF8, 0xF8, 0x08, 0x08, 0x08, // . + 0x1C, 0x1C, 0x1C, 0x1C, 0xFC, 0x1C, 0x1C, 0x1C, // . + 0x00, 0x00, 0x00, 0x00, 0xFC, 0x1C, 0x1C, 0x1C, // . + 0x00, 0x00, 0x00, 0xF8, 0xF8, 0x08, 0x08, 0x08, // . + 0x1C, 0x1C, 0x1C, 0xFC, 0xFC, 0x1C, 0x1C, 0x1C, // . + 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, // . + 0x00, 0x00, 0x00, 0xFC, 0xFC, 0x1C, 0x1C, 0x1C, // . + 0x1C, 0x1C, 0x1C, 0xFC, 0xFC, 0x00, 0x00, 0x00, // . + 0x1C, 0x1C, 0x1C, 0x1C, 0xFC, 0x00, 0x00, 0x00, // . + 0x08, 0x08, 0x08, 0xF8, 0xF8, 0x00, 0x00, 0x00, // . + 0x00, 0x00, 0x00, 0x00, 0xF8, 0x08, 0x08, 0x08, // . + 0x08, 0x08, 0x08, 0x08, 0x0F, 0x00, 0x00, 0x00, // . + 0x08, 0x08, 0x08, 0x08, 0xFF, 0x00, 0x00, 0x00, // . + 0x00, 0x00, 0x00, 0x00, 0xFF, 0x08, 0x08, 0x08, // . + 0x08, 0x08, 0x08, 0x08, 0x0F, 0x08, 0x08, 0x08, // . + 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, // . + 0x08, 0x08, 0x08, 0x08, 0xFF, 0x08, 0x08, 0x08, // . + 0x08, 0x08, 0x08, 0x0F, 0x0F, 0x08, 0x08, 0x08, // . + 0x1C, 0x1C, 0x1C, 0x1C, 0x1F, 0x1C, 0x1C, 0x1C, // . + 0x1C, 0x1C, 0x1C, 0x1F, 0x1F, 0x00, 0x00, 0x00, // . + 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x1C, 0x1C, 0x1C, // . + 0x1C, 0x1C, 0x1C, 0xFF, 0xFF, 0x00, 0x00, 0x00, // . + 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x1C, 0x1C, 0x1C, // . + 0x1C, 0x1C, 0x1C, 0x1F, 0x1F, 0x1C, 0x1C, 0x1C, // . + 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, // . + 0x1C, 0x1C, 0x1C, 0xFF, 0xFF, 0x1C, 0x1C, 0x1C, // . + 0x08, 0x08, 0x08, 0xFF, 0xFF, 0x00, 0x00, 0x00, // . + 0x1C, 0x1C, 0x1C, 0x1C, 0xFF, 0x00, 0x00, 0x00, // . + 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x08, 0x08, 0x08, // . + 0x00, 0x00, 0x00, 0x00, 0xFF, 0x1C, 0x1C, 0x1C, // . + 0x1C, 0x1C, 0x1C, 0x1C, 0x1F, 0x00, 0x00, 0x00, // . + 0x08, 0x08, 0x08, 0x0F, 0x0F, 0x00, 0x00, 0x00, // . + 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x08, 0x08, 0x08, // . + 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1C, 0x1C, 0x1C, // . + 0x1C, 0x1C, 0x1C, 0x1C, 0xFF, 0x1C, 0x1C, 0x1C, // . + 0x08, 0x08, 0x08, 0xFF, 0xFF, 0x08, 0x08, 0x08, // . + 0x08, 0x08, 0x08, 0x08, 0xF8, 0x00, 0x00, 0x00, // . + 0x00, 0x00, 0x00, 0x00, 0x0F, 0x08, 0x08, 0x08, // . + 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, // . + 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, // . + 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, // . + 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // . + 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, // . + 0x00, 0x00, 0x76, 0xCC, 0xCC, 0xCC, 0x76, 0x00, // . + 0x3C, 0x66, 0x66, 0x7C, 0x66, 0x66, 0x7C, 0x60, // . + 0x7E, 0x66, 0x60, 0x60, 0x60, 0x60, 0x60, 0x00, // . + 0x00, 0x00, 0xFE, 0x6C, 0x6C, 0x6C, 0x66, 0x00, // . + 0x7E, 0x66, 0x30, 0x18, 0x30, 0x66, 0x7E, 0x00, // . + 0x00, 0x00, 0x3E, 0x6C, 0x6C, 0x6C, 0x38, 0x00, // . + 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x7F, 0xC0, // . + 0x00, 0x00, 0x7E, 0xD8, 0x18, 0x18, 0x0C, 0x00, // . + 0x7C, 0x38, 0x7C, 0xD6, 0xD6, 0x7C, 0x38, 0x7C, // . + 0x7C, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0x7C, 0x00, // . + 0x7C, 0xC6, 0xC6, 0xC6, 0x6C, 0x6C, 0xEE, 0x00, // . + 0x1E, 0x30, 0x18, 0x3C, 0x66, 0x66, 0x3C, 0x00, // . + 0x00, 0x00, 0x7E, 0xDB, 0xDB, 0x7E, 0x00, 0x00, // . + 0x03, 0x06, 0x3E, 0x6B, 0x73, 0x3E, 0x60, 0xC0, // . + 0x1E, 0x30, 0x60, 0x7E, 0x60, 0x30, 0x1E, 0x00, // . + 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, // . + 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x00, // . + 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x7E, 0x00, // . + 0x30, 0x18, 0x0C, 0x18, 0x30, 0x00, 0x7E, 0x00, // . + 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x00, 0x7E, 0x00, // . + 0x0E, 0x1B, 0x1B, 0x18, 0x18, 0x18, 0x18, 0x18, // . + 0x18, 0x18, 0x18, 0x18, 0x18, 0xD8, 0xD8, 0x70, // . + 0x18, 0x18, 0x00, 0x7E, 0x00, 0x18, 0x18, 0x00, // . + 0x00, 0x76, 0xDC, 0x00, 0x76, 0xDC, 0x00, 0x00, // . + 0x3C, 0x66, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, // . + 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, // . + 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, // . + 0x1E, 0x18, 0x18, 0x18, 0x18, 0xD8, 0x78, 0x38, // . + 0x78, 0x6C, 0x6C, 0x6C, 0x6C, 0x00, 0x00, 0x00, // . + 0x38, 0x0C, 0x18, 0x30, 0x3C, 0x00, 0x00, 0x00, // . + 0x00, 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00, // . + 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00 +}; diff --git a/polymer/eduke32/build/src/winlayer.c b/polymer/eduke32/build/src/winlayer.c index 4cbae9793..27288b469 100644 --- a/polymer/eduke32/build/src/winlayer.c +++ b/polymer/eduke32/build/src/winlayer.c @@ -69,8 +69,8 @@ char forcegl=0; #endif static LPTSTR GetWindowsErrorMsg(DWORD code); -static const char * GetDDrawError(HRESULT code); -static const char * GetDInputError(HRESULT code); +static const char *GetDDrawError(HRESULT code); +static const char *GetDInputError(HRESULT code); static void ShowErrorBox(const char *m); static void ShowDDrawErrorBox(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; - _buildargv = (const char**)Bmalloc(sizeof(char*)*_buildargc); + _buildargv = (const char **)Bmalloc(sizeof(char *)*_buildargc); wp = argvbuf; 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, - osv.dwMajorVersion, osv.dwMinorVersion, osv.dwBuildNumber, osv.szCSDVersion); + osv.dwMajorVersion, osv.dwMinorVersion, osv.dwBuildNumber, osv.szCSDVersion); #ifdef NEDMALLOC initprintf("\n"); @@ -754,7 +754,7 @@ int32_t handleevents(void) continue; } - if (startwin_idle((void*)&msg) > 0) continue; + if (startwin_idle((void *)&msg) > 0) continue; TranslateMessage(&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) { - int32_t *typecounts = (int32_t*)pvRef; + int32_t *typecounts = (int32_t *)pvRef; if (lpddoi->dwType & DIDFT_AXIS) { @@ -1183,17 +1183,17 @@ static void UninitDirectInput(void) 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; } 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; } 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; } @@ -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 // them in the DLL // -static const char * GetDInputError(HRESULT code) +static const char *GetDInputError(HRESULT 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 // instead of the global 'timerfreq' or else it gets pissed with an // access violation - if (!QueryPerformanceFrequency((LARGE_INTEGER*)&t)) + if (!QueryPerformanceFrequency((LARGE_INTEGER *)&t)) { ShowErrorBox("Failed fetching timer frequency"); return -1; } timerfreq = t; timerticspersec = tickspersecond; - QueryPerformanceCounter((LARGE_INTEGER*)&t); + QueryPerformanceCounter((LARGE_INTEGER *)&t); timerlastsample = (int32_t)(t*timerticspersec / timerfreq); usertimercallback = NULL; @@ -1550,7 +1550,7 @@ inline void sampletimer(void) if (!timerfreq) return; - QueryPerformanceCounter((LARGE_INTEGER*)&i); + QueryPerformanceCounter((LARGE_INTEGER *)&i); n = (int32_t)((i*timerticspersec / timerfreq) - timerlastsample); if (n <= 0) return; @@ -1569,7 +1569,7 @@ uint32_t getticks(void) { int64_t i; if (timerfreq == 0) return 0; - QueryPerformanceCounter((LARGE_INTEGER*)&i); + QueryPerformanceCounter((LARGE_INTEGER *)&i); return (uint32_t)(i*longlong(1000)/timerfreq); } @@ -1594,7 +1594,7 @@ static HMODULE hDDrawDLL = NULL; static LPDIRECTDRAW lpDD = NULL; static LPDIRECTDRAWSURFACE lpDDSPrimary = NULL; static LPDIRECTDRAWSURFACE lpDDSBack = NULL; -static char * lpOffscreen = NULL; +static char *lpOffscreen = NULL; static LPDIRECTDRAWPALETTE lpDDPalette = NULL; static BOOL bDDrawInited = FALSE; static DWORD DDdwCaps = 0, DDdwCaps2 = 0; @@ -1909,7 +1909,7 @@ void getvalidmodes(void) 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; } @@ -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 p = (GLubyte *)Bstrdup(glinfo.extensions); 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")) { @@ -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 // them in the DLL // -static const char * GetDDrawError(HRESULT code) +static const char *GetDDrawError(HRESULT code) { switch (code) {