From 0189cf6064b5af27c7c02674569fd9deeef2b91c Mon Sep 17 00:00:00 2001 From: qbix79 Date: Fri, 23 May 2008 10:00:43 +0000 Subject: [PATCH] Most functions in kplib.c now use a intptr_t for (da)frameplace kzopen and kzipopen now retrun a intptr_t as this actually a FILE* General 64 bit fixss to cache1d.c. Some cast correction for polymost hrp works now in 64 bit if you make md3load return NULL. git-svn-id: https://svn.eduke32.com/eduke32@737 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/build/include/kplib.h | 4 +- polymer/build/src/cache1d.c | 9 ++-- polymer/build/src/kplib.c | 77 +++++++++++++++++++---------------- polymer/build/src/polymost.c | 2 +- 4 files changed, 50 insertions(+), 42 deletions(-) diff --git a/polymer/build/include/kplib.h b/polymer/build/include/kplib.h index 850253a3c..63f9660db 100644 --- a/polymer/build/include/kplib.h +++ b/polymer/build/include/kplib.h @@ -1,8 +1,8 @@ //High-level (easy) picture loading function: -extern void kpzload (const char *, int *, int *, int *, int *); +extern void kpzload (const char *, int *, intptr_t *, int *, int *); //Low-level PNG/JPG functions: extern void kpgetdim (const char *, int, int *, int *); -extern int kprender (const char *, int, int, int, int, int, int, int); +extern int kprender (const char *, int, intptr_t, int, int, int, int, int); //ZIP functions: extern int kzaddstack (const char *); diff --git a/polymer/build/src/cache1d.c b/polymer/build/src/cache1d.c index 2a1d42408..ef5d9d89d 100644 --- a/polymer/build/src/cache1d.c +++ b/polymer/build/src/cache1d.c @@ -17,7 +17,7 @@ //Insert '|' in front of filename //Doing this tells kzopen to load the file only if inside a .ZIP file -static int kzipopen(char *filnam) +static intptr_t kzipopen(char *filnam) { unsigned int i; char newst[BMAX_PATH+4]; @@ -193,7 +193,7 @@ void suckcache(intptr_t *suckptr) //Can't exit early, because invalid pointer might be same even though lock = 0 for (i=0;ixr1;p+=ixstp,x--) *(int *)p = palcol[olinbuf[x]]; } @@ -815,7 +817,8 @@ static inline void pal8hlineasm(int x, int xr1, int p, int ixstp) static int filter1st, filterest; static void putbuf(const unsigned char *buf, int leng) { - int i, x, p; + int i, x; + intptr_t p; if (filt < 0) { @@ -978,7 +981,7 @@ static void initpngtables() } static int kpngrend(const char *kfilebuf, int kfilength, - int daframeplace, int dabytesperline, int daxres, int dayres, + intptr_t daframeplace, int dabytesperline, int daxres, int dayres, int daglobxoffs, int daglobyoffs) { int i, j, k, bfinal, btype, hlit, hdist, leng; @@ -1447,7 +1450,8 @@ static void invdct8x8(int *dc, unsigned char dcflag) static void yrbrend(int x, int y) { - int i, j, ox, oy, xx, yy, xxx, yyy, xxxend, yyyend, yv, cr, cb, p, pp, *odc, *dc, *dc2; + int i, j, ox, oy, xx, yy, xxx, yyy, xxxend, yyyend, yv, cr, cb, *odc, *dc, *dc2; + intptr_t p,pp; odc = dct[0]; dc2 = dct[10]; for (yy=0;yy<(lcompvsamp[0]<<3);yy+=8) @@ -1535,7 +1539,7 @@ static void yrbrend(int x, int y) } static int kpegrend(const char *kfilebuf, int kfilength, - int daframeplace, int dabytesperline, int daxres, int dayres, + intptr_t daframeplace, int dabytesperline, int daxres, int dayres, int daglobxoffs, int daglobyoffs) { int i, j, v, leng, xdim = 0, ydim = 0, index, prec, restartcnt, restartinterval; @@ -1565,7 +1569,7 @@ static int kpegrend(const char *kfilebuf, int kfilength, while (marker == 255); if (marker != 0xd9) //Don't read past end of buffer { - leng = ((int)kfileptr[0]<<8)+(int)kfileptr[1]-2; + leng = ((intptr_t)kfileptr[0]<<8)+(intptr_t)kfileptr[1]-2; kfileptr += 2; } //printf("fileoffs=%08x, marker=%02x,leng=%d",((int)kfileptr)-((int)kfilebuf)-2,marker,leng); @@ -1949,14 +1953,14 @@ static unsigned char suffix[4100], filbuffer[768], tempstack[4096]; static int prefix[4100]; static int kgifrend(const char *kfilebuf, int kfilelength, - int daframeplace, int dabytesperline, int daxres, int dayres, + intptr_t daframeplace, int dabytesperline, int daxres, int dayres, int daglobxoffs, int daglobyoffs) { int i, x, y, xsiz, ysiz, yinc, xend, xspan, yspan, currstr, numbitgoal; - int lzcols, dat, blocklen, bitcnt, xoff, yoff, transcol, backcol, *lptr; + int lzcols, dat, blocklen, bitcnt, xoff, transcol, backcol, *lptr; char numbits, startnumbits, chunkind, ilacefirst; const unsigned char *ptr, *cptr = 0; - +intptr_t yoff; UNREFERENCED_PARAMETER(kfilelength); coltype = 3; bitdepth = 8; //For PNGOUT @@ -2009,14 +2013,14 @@ static int kgifrend(const char *kfilebuf, int kfilelength, xx[3] = min(daglobxoffs+xsiz ,daxres); yy[3] = min(daglobyoffs+ysiz ,dayres); lptr = (int *)(yy[0]*dabytesperline+daframeplace); - for (y=yy[0];y>8)&0xf8); g[0] = ((c0>>3)&0xfc); b[0] = ((c0<<3)&0xfc); a[0] = 255; c1 = SSWAPIB(*(unsigned short *)&uptr[2]); @@ -2593,17 +2600,17 @@ void kpgetdim(const char *buf, int leng, int *xsiz, int *ysiz) lptr = (int *)buf; if ((lptr[0] != LSWAPIB(0x474e5089)) || (lptr[1] != LSWAPIB(0x0a1a0a0d))) return; lptr = &lptr[2]; - while (((unsigned int)lptr-(unsigned int)buf) < (unsigned int)(leng-16)) + while (((uintptr_t)lptr-(uintptr_t)buf) < (uintptr_t)(leng-16)) { if (lptr[1] == LSWAPIB(0x52444849)) //IHDR {(*xsiz) = LSWAPIL(lptr[2]); (*ysiz) = LSWAPIL(lptr[3]); break; } - lptr = (int *)((int)lptr + LSWAPIL(lptr[0]) + 12); + lptr = (int *)((intptr_t)lptr + LSWAPIL(lptr[0]) + 12); } } else if ((ubuf[0] == 0xff) && (ubuf[1] == 0xd8)) //.JPG { cptr = (unsigned char *)&buf[2]; - while (((unsigned int)cptr-(unsigned int)buf) < (unsigned int)(leng-8)) + while (((uintptr_t)cptr-(uintptr_t)buf) < (uintptr_t)(leng-8)) { if (cptr[0] != 255) { cptr = &cptr[1]; continue; } if ((unsigned int)(cptr[1]-0xc0) < 3) @@ -2664,7 +2671,7 @@ void kpgetdim(const char *buf, int leng, int *xsiz, int *ysiz) } } -int kprender(const char *buf, int leng, int frameptr, int bpl, +int kprender(const char *buf, int leng, intptr_t frameptr, int bpl, int xdim, int ydim, int xoff, int yoff) { unsigned char *ubuf = (unsigned char *)buf; @@ -2886,7 +2893,7 @@ int kzaddstack(const char *zipnam) return(0); } -int kzopen(const char *filnam) +intptr_t kzopen(const char *filnam) { FILE *fil; int zipseek; @@ -2903,7 +2910,7 @@ int kzopen(const char *filnam) kzfs.leng = filelength(_fileno(kzfs.fil)); kzfs.pos = 0; kzfs.i = 0; - return((int)kzfs.fil); + return((intptr_t)kzfs.fil); } } if (kzcheckhash(filnam,&zipnam,&zipseek)) @@ -2922,7 +2929,7 @@ int kzopen(const char *filnam) switch (kzfs.comptyp) //Compression method { case 0: - kzfs.i = 0; return((int)kzfs.fil); + kzfs.i = 0; return((intptr_t)kzfs.fil); case 8: if (!pnginited) { pnginited = 1; initpngtables(); } kzfs.comptell = 0; @@ -2931,7 +2938,7 @@ int kzopen(const char *filnam) //WARNING: No file in ZIP can be > 2GB-32K bytes gslidew = 0x7fffffff; //Force reload at beginning - return((int)kzfs.fil); + return((intptr_t)kzfs.fil); default: fclose(kzfs.fil); kzfs.fil = 0; return(0); } @@ -3359,7 +3366,7 @@ void kzclose() //====================== ZIP decompression code ends ========================= //===================== HANDY PICTURE function begins ======================== -void kpzload(const char *filnam, int *pic, int *bpl, int *xsiz, int *ysiz) +void kpzload(const char *filnam, intptr_t *pic, int *bpl, int *xsiz, int *ysiz) { char *buf; int leng; @@ -3373,7 +3380,7 @@ void kpzload(const char *filnam, int *pic, int *bpl, int *xsiz, int *ysiz) kpgetdim(buf,leng,xsiz,ysiz); (*bpl) = ((*xsiz)<<2); - (*pic) = (int)malloc((*ysiz)*(*bpl)); if (!(*pic)) { free(buf); return; } + (*pic) = (intptr_t)malloc((*ysiz)*(*bpl)); if (!(*pic)) { free(buf); return; } if (kprender(buf,leng,*pic,*bpl,*xsiz,*ysiz,0,0) < 0) { free(buf); free((void *)*pic); (*pic) = 0; return; } free(buf); } diff --git a/polymer/build/src/polymost.c b/polymer/build/src/polymost.c index b305ee207..ab5ae248d 100644 --- a/polymer/build/src/polymost.c +++ b/polymer/build/src/polymost.c @@ -1548,7 +1548,7 @@ int gloadtile_hi(int dapic,int dapalnum, int facen, hicreplctyp *hicr, int damet } pic = (coltype *)calloc(xsiz,ysiz*sizeof(coltype)); if (!pic) { free(picfil); return 1; } - if (kprender(picfil,picfillen,(int)pic,xsiz*sizeof(coltype),xsiz,ysiz,0,0)) { free(picfil); free(pic); return -2; } + if (kprender(picfil,picfillen,(intptr_t)pic,xsiz*sizeof(coltype),xsiz,ysiz,0,0)) { free(picfil); free(pic); return -2; } applypalmapsT((char *)pic,tsizx,tsizy,dapic,dapalnum,dameth); r=(glinfo.bgra)?hictinting[dapalnum].r:hictinting[dapalnum].b;