diff --git a/polymer/build/include/a.h b/polymer/build/include/a.h index baad0cef2..af593062d 100644 --- a/polymer/build/include/a.h +++ b/polymer/build/include/a.h @@ -8,89 +8,89 @@ #if defined(__WATCOMC__) && !defined(NOASM) -extern long mmxoverlay(); +extern int mmxoverlay(); #pragma aux mmxoverlay modify [eax ebx ecx edx]; -extern long sethlinesizes(long,long,long); +extern int sethlinesizes(int,int,int); #pragma aux sethlinesizes parm [eax][ebx][ecx]; -extern long setpalookupaddress(char *); +extern int setpalookupaddress(char *); #pragma aux setpalookupaddress parm [eax]; -extern long setuphlineasm4(long,long); +extern int setuphlineasm4(int,int); #pragma aux setuphlineasm4 parm [eax][ebx]; -extern long hlineasm4(long,long,long,long,long,long); +extern int hlineasm4(int,int,int,int,int,int); #pragma aux hlineasm4 parm [eax][ebx][ecx][edx][esi][edi]; -extern long setuprhlineasm4(long,long,long,long,long,long); +extern int setuprhlineasm4(int,int,int,int,int,int); #pragma aux setuprhlineasm4 parm [eax][ebx][ecx][edx][esi][edi]; -extern long rhlineasm4(long,long,long,long,long,long); +extern int rhlineasm4(int,int,int,int,int,int); #pragma aux rhlineasm4 parm [eax][ebx][ecx][edx][esi][edi]; -extern long setuprmhlineasm4(long,long,long,long,long,long); +extern int setuprmhlineasm4(int,int,int,int,int,int); #pragma aux setuprmhlineasm4 parm [eax][ebx][ecx][edx][esi][edi]; -extern long rmhlineasm4(long,long,long,long,long,long); +extern int rmhlineasm4(int,int,int,int,int,int); #pragma aux rmhlineasm4 parm [eax][ebx][ecx][edx][esi][edi]; -extern long setupqrhlineasm4(long,long,long,long,long,long); +extern int setupqrhlineasm4(int,int,int,int,int,int); #pragma aux setupqrhlineasm4 parm [eax][ebx][ecx][edx][esi][edi]; -extern long qrhlineasm4(long,long,long,long,long,long); +extern int qrhlineasm4(int,int,int,int,int,int); #pragma aux qrhlineasm4 parm [eax][ebx][ecx][edx][esi][edi]; -extern long setvlinebpl(long); +extern int setvlinebpl(int); #pragma aux setvlinebpl parm [eax]; -extern long fixtransluscence(long); +extern int fixtransluscence(int); #pragma aux fixtransluscence parm [eax]; -extern long prevlineasm1(long,long,long,long,long,long); +extern int prevlineasm1(int,int,int,int,int,int); #pragma aux prevlineasm1 parm [eax][ebx][ecx][edx][esi][edi]; -extern long vlineasm1(long,long,long,long,long,long); +extern int vlineasm1(int,int,int,int,int,int); #pragma aux vlineasm1 parm [eax][ebx][ecx][edx][esi][edi]; -extern long setuptvlineasm(long); +extern int setuptvlineasm(int); #pragma aux setuptvlineasm parm [eax]; -extern long tvlineasm1(long,long,long,long,long,long); +extern int tvlineasm1(int,int,int,int,int,int); #pragma aux tvlineasm1 parm [eax][ebx][ecx][edx][esi][edi]; -extern long setuptvlineasm2(long,long,long); +extern int setuptvlineasm2(int,int,int); #pragma aux setuptvlineasm2 parm [eax][ebx][ecx]; -extern long tvlineasm2(long,long,long,long,long,long); +extern int tvlineasm2(int,int,int,int,int,int); #pragma aux tvlineasm2 parm [eax][ebx][ecx][edx][esi][edi]; -extern long mvlineasm1(long,long,long,long,long,long); +extern int mvlineasm1(int,int,int,int,int,int); #pragma aux mvlineasm1 parm [eax][ebx][ecx][edx][esi][edi]; -extern long setupvlineasm(long); +extern int setupvlineasm(int); #pragma aux setupvlineasm parm [eax]; -extern long vlineasm4(long,long); +extern int vlineasm4(int,int); #pragma aux vlineasm4 parm [ecx][edi] modify [eax ebx ecx edx esi edi]; -extern long setupmvlineasm(long); +extern int setupmvlineasm(int); #pragma aux setupmvlineasm parm [eax]; -extern long mvlineasm4(long,long); +extern int mvlineasm4(int,int); #pragma aux mvlineasm4 parm [ecx][edi] modify [eax ebx ecx edx esi edi]; -extern void setupspritevline(long,long,long,long,long,long); +extern void setupspritevline(int,int,int,int,int,int); #pragma aux setupspritevline parm [eax][ebx][ecx][edx][esi][edi]; -extern void spritevline(long,long,long,long,long,long); +extern void spritevline(int,int,int,int,int,int); #pragma aux spritevline parm [eax][ebx][ecx][edx][esi][edi]; -extern void msetupspritevline(long,long,long,long,long,long); +extern void msetupspritevline(int,int,int,int,int,int); #pragma aux msetupspritevline parm [eax][ebx][ecx][edx][esi][edi]; -extern void mspritevline(long,long,long,long,long,long); +extern void mspritevline(int,int,int,int,int,int); #pragma aux mspritevline parm [eax][ebx][ecx][edx][esi][edi]; -extern void tsetupspritevline(long,long,long,long,long,long); +extern void tsetupspritevline(int,int,int,int,int,int); #pragma aux tsetupspritevline parm [eax][ebx][ecx][edx][esi][edi]; -extern void tspritevline(long,long,long,long,long,long); +extern void tspritevline(int,int,int,int,int,int); #pragma aux tspritevline parm [eax][ebx][ecx][edx][esi][edi]; -extern long mhline(long,long,long,long,long,long); +extern int mhline(int,int,int,int,int,int); #pragma aux mhline parm [eax][ebx][ecx][edx][esi][edi]; -extern long mhlineskipmodify(long,long,long,long,long,long); +extern int mhlineskipmodify(int,int,int,int,int,int); #pragma aux mhlineskipmodify parm [eax][ebx][ecx][edx][esi][edi]; -extern long msethlineshift(long,long); +extern int msethlineshift(int,int); #pragma aux msethlineshift parm [eax][ebx]; -extern long thline(long,long,long,long,long,long); +extern int thline(int,int,int,int,int,int); #pragma aux thline parm [eax][ebx][ecx][edx][esi][edi]; -extern long thlineskipmodify(long,long,long,long,long,long); +extern int thlineskipmodify(int,int,int,int,int,int); #pragma aux thlineskipmodify parm [eax][ebx][ecx][edx][esi][edi]; -extern long tsethlineshift(long,long); +extern int tsethlineshift(int,int); #pragma aux tsethlineshift parm [eax][ebx]; -extern long setupslopevlin(long,long,long); +extern int setupslopevlin(int,int,int); #pragma aux setupslopevlin parm [eax][ebx][ecx] modify [edx]; -extern long slopevlin(long,long,long,long,long,long); +extern int slopevlin(int,int,int,int,int,int); #pragma aux slopevlin parm [eax][ebx][ecx][edx][esi][edi]; -extern long settransnormal(); +extern int settransnormal(); #pragma aux settransnormal parm; -extern long settransreverse(); +extern int settransreverse(); #pragma aux settransreverse parm; -extern long setupdrawslab(long,long); +extern int setupdrawslab(int,int); #pragma aux setupdrawslab parm [eax][ebx]; -extern long drawslab(long,long,long,long,long,long); +extern int drawslab(int,int,int,int,int,int); #pragma aux drawslab parm [eax][ebx][ecx][edx][esi][edi]; #elif defined(__GNUC__) && defined(__i386__) && !defined(NOASM) // __WATCOMC__ @@ -99,140 +99,140 @@ extern long drawslab(long,long,long,long,long,long); #define __cdecl #endif -extern long __cdecl mmxoverlay(); -extern long __cdecl sethlinesizes(long,long,long); -extern long __cdecl setpalookupaddress(char *); -extern long __cdecl setuphlineasm4(long,long); -extern long __cdecl hlineasm4(long,long,long,long,long,long); -extern long __cdecl setuprhlineasm4(long,long,long,long,long,long); -extern long __cdecl rhlineasm4(long,long,long,long,long,long); -extern long __cdecl setuprmhlineasm4(long,long,long,long,long,long); -extern long __cdecl rmhlineasm4(long,long,long,long,long,long); -extern long __cdecl setupqrhlineasm4(long,long,long,long,long,long); -extern long __cdecl qrhlineasm4(long,long,long,long,long,long); -extern long __cdecl setvlinebpl(long); -extern long __cdecl fixtransluscence(long); -extern long __cdecl prevlineasm1(long,long,long,long,long,long); -extern long __cdecl vlineasm1(long,long,long,long,long,long); -extern long __cdecl setuptvlineasm(long); -extern long __cdecl tvlineasm1(long,long,long,long,long,long); -extern long __cdecl setuptvlineasm2(long,long,long); -extern long __cdecl tvlineasm2(long,long,long,long,long,long); -extern long __cdecl mvlineasm1(long,long,long,long,long,long); -extern long __cdecl setupvlineasm(long); -extern long __cdecl vlineasm4(long,long); -extern long __cdecl setupmvlineasm(long); -extern long __cdecl mvlineasm4(long,long); -extern long __cdecl setupspritevline(long,long,long,long,long,long); -extern long __cdecl spritevline(long,long,long,long,long,long); -extern long __cdecl msetupspritevline(long,long,long,long,long,long); -extern long __cdecl mspritevline(long,long,long,long,long,long); -extern long __cdecl tsetupspritevline(long,long,long,long,long,long); -extern long __cdecl tspritevline(long,long,long,long,long,long); -extern long __cdecl mhline(long,long,long,long,long,long); -extern long __cdecl mhlineskipmodify(long,long,long,long,long,long); -extern long __cdecl msethlineshift(long,long); -extern long __cdecl thline(long,long,long,long,long,long); -extern long __cdecl thlineskipmodify(long,long,long,long,long,long); -extern long __cdecl tsethlineshift(long,long); -extern long __cdecl setupslopevlin(long,long,long); -extern long __cdecl slopevlin(long,long,long,long,long,long); -extern long __cdecl settransnormal(); -extern long __cdecl settransreverse(); -extern long __cdecl setupdrawslab(long,long); -extern long __cdecl drawslab(long,long,long,long,long,long); -extern void __cdecl stretchhline(long,long,long,long,long,long); +extern int __cdecl mmxoverlay(); +extern int __cdecl sethlinesizes(int,int,int); +extern int __cdecl setpalookupaddress(char *); +extern int __cdecl setuphlineasm4(int,int); +extern int __cdecl hlineasm4(int,int,int,int,int,int); +extern int __cdecl setuprhlineasm4(int,int,int,int,int,int); +extern int __cdecl rhlineasm4(int,int,int,int,int,int); +extern int __cdecl setuprmhlineasm4(int,int,int,int,int,int); +extern int __cdecl rmhlineasm4(int,int,int,int,int,int); +extern int __cdecl setupqrhlineasm4(int,int,int,int,int,int); +extern int __cdecl qrhlineasm4(int,int,int,int,int,int); +extern int __cdecl setvlinebpl(int); +extern int __cdecl fixtransluscence(int); +extern int __cdecl prevlineasm1(int,int,int,int,int,int); +extern int __cdecl vlineasm1(int,int,int,int,int,int); +extern int __cdecl setuptvlineasm(int); +extern int __cdecl tvlineasm1(int,int,int,int,int,int); +extern int __cdecl setuptvlineasm2(int,int,int); +extern int __cdecl tvlineasm2(int,int,int,int,int,int); +extern int __cdecl mvlineasm1(int,int,int,int,int,int); +extern int __cdecl setupvlineasm(int); +extern int __cdecl vlineasm4(int,int); +extern int __cdecl setupmvlineasm(int); +extern int __cdecl mvlineasm4(int,int); +extern int __cdecl setupspritevline(int,int,int,int,int,int); +extern int __cdecl spritevline(int,int,int,int,int,int); +extern int __cdecl msetupspritevline(int,int,int,int,int,int); +extern int __cdecl mspritevline(int,int,int,int,int,int); +extern int __cdecl tsetupspritevline(int,int,int,int,int,int); +extern int __cdecl tspritevline(int,int,int,int,int,int); +extern int __cdecl mhline(int,int,int,int,int,int); +extern int __cdecl mhlineskipmodify(int,int,int,int,int,int); +extern int __cdecl msethlineshift(int,int); +extern int __cdecl thline(int,int,int,int,int,int); +extern int __cdecl thlineskipmodify(int,int,int,int,int,int); +extern int __cdecl tsethlineshift(int,int); +extern int __cdecl setupslopevlin(int,int,int); +extern int __cdecl slopevlin(int,int,int,int,int,int); +extern int __cdecl settransnormal(); +extern int __cdecl settransreverse(); +extern int __cdecl setupdrawslab(int,int); +extern int __cdecl drawslab(int,int,int,int,int,int); +extern void __cdecl stretchhline(int,int,int,int,int,int); #elif defined(_MSC_VER) && !defined(NOASM) // __GNUC__ && __i386__ -extern long _cdecl mmxoverlay(); -extern long _cdecl sethlinesizes(long,long,long); -extern long _cdecl setpalookupaddress(char *); -extern long _cdecl setuphlineasm4(long,long); -extern long _cdecl hlineasm4(long,long,long,long,long,long); -extern long _cdecl setuprhlineasm4(long,long,long,long,long,long); -extern long _cdecl rhlineasm4(long,long,long,long,long,long); -extern long _cdecl setuprmhlineasm4(long,long,long,long,long,long); -extern long _cdecl rmhlineasm4(long,long,long,long,long,long); -extern long _cdecl setupqrhlineasm4(long,long,long,long,long,long); -extern long _cdecl qrhlineasm4(long,long,long,long,long,long); -extern long _cdecl setvlinebpl(long); -extern long _cdecl fixtransluscence(long); -extern long _cdecl prevlineasm1(long,long,long,long,long,long); -extern long _cdecl vlineasm1(long,long,long,long,long,long); -extern long _cdecl setuptvlineasm(long); -extern long _cdecl tvlineasm1(long,long,long,long,long,long); -extern long _cdecl setuptvlineasm2(long,long,long); -extern long _cdecl tvlineasm2(long,long,long,long,long,long); -extern long _cdecl mvlineasm1(long,long,long,long,long,long); -extern long _cdecl setupvlineasm(long); -extern long _cdecl vlineasm4(long,long); -extern long _cdecl setupmvlineasm(long); -extern long _cdecl mvlineasm4(long,long); -extern long _cdecl setupspritevline(long,long,long,long,long,long); -extern long _cdecl spritevline(long,long,long,long,long,long); -extern long _cdecl msetupspritevline(long,long,long,long,long,long); -extern long _cdecl mspritevline(long,long,long,long,long,long); -extern long _cdecl tsetupspritevline(long,long,long,long,long,long); -extern long _cdecl tspritevline(long,long,long,long,long,long); -extern long _cdecl mhline(long,long,long,long,long,long); -extern long _cdecl mhlineskipmodify(long,long,long,long,long,long); -extern long _cdecl msethlineshift(long,long); -extern long _cdecl thline(long,long,long,long,long,long); -extern long _cdecl thlineskipmodify(long,long,long,long,long,long); -extern long _cdecl tsethlineshift(long,long); -extern long _cdecl setupslopevlin(long,long,long); -extern long _cdecl slopevlin(long,long,long,long,long,long); -extern long _cdecl settransnormal(); -extern long _cdecl settransreverse(); -extern long _cdecl setupdrawslab(long,long); -extern long _cdecl drawslab(long,long,long,long,long,long); -extern void _cdecl stretchhline(long,long,long,long,long,long); +extern int _cdecl mmxoverlay(); +extern int _cdecl sethlinesizes(int,int,int); +extern int _cdecl setpalookupaddress(char *); +extern int _cdecl setuphlineasm4(int,int); +extern int _cdecl hlineasm4(int,int,int,int,int,int); +extern int _cdecl setuprhlineasm4(int,int,int,int,int,int); +extern int _cdecl rhlineasm4(int,int,int,int,int,int); +extern int _cdecl setuprmhlineasm4(int,int,int,int,int,int); +extern int _cdecl rmhlineasm4(int,int,int,int,int,int); +extern int _cdecl setupqrhlineasm4(int,int,int,int,int,int); +extern int _cdecl qrhlineasm4(int,int,int,int,int,int); +extern int _cdecl setvlinebpl(int); +extern int _cdecl fixtransluscence(int); +extern int _cdecl prevlineasm1(int,int,int,int,int,int); +extern int _cdecl vlineasm1(int,int,int,int,int,int); +extern int _cdecl setuptvlineasm(int); +extern int _cdecl tvlineasm1(int,int,int,int,int,int); +extern int _cdecl setuptvlineasm2(int,int,int); +extern int _cdecl tvlineasm2(int,int,int,int,int,int); +extern int _cdecl mvlineasm1(int,int,int,int,int,int); +extern int _cdecl setupvlineasm(int); +extern int _cdecl vlineasm4(int,int); +extern int _cdecl setupmvlineasm(int); +extern int _cdecl mvlineasm4(int,int); +extern int _cdecl setupspritevline(int,int,int,int,int,int); +extern int _cdecl spritevline(int,int,int,int,int,int); +extern int _cdecl msetupspritevline(int,int,int,int,int,int); +extern int _cdecl mspritevline(int,int,int,int,int,int); +extern int _cdecl tsetupspritevline(int,int,int,int,int,int); +extern int _cdecl tspritevline(int,int,int,int,int,int); +extern int _cdecl mhline(int,int,int,int,int,int); +extern int _cdecl mhlineskipmodify(int,int,int,int,int,int); +extern int _cdecl msethlineshift(int,int); +extern int _cdecl thline(int,int,int,int,int,int); +extern int _cdecl thlineskipmodify(int,int,int,int,int,int); +extern int _cdecl tsethlineshift(int,int); +extern int _cdecl setupslopevlin(int,int,int); +extern int _cdecl slopevlin(int,int,int,int,int,int); +extern int _cdecl settransnormal(); +extern int _cdecl settransreverse(); +extern int _cdecl setupdrawslab(int,int); +extern int _cdecl drawslab(int,int,int,int,int,int); +extern void _cdecl stretchhline(int,int,int,int,int,int); #else // _MSC_VER #define ENGINE_USING_A_C -void setvlinebpl(long dabpl); -void fixtransluscence(long datransoff); +void setvlinebpl(int dabpl); +void fixtransluscence(int datransoff); void settransnormal(void); void settransreverse(void); -void sethlinesizes(long logx, long logy, long bufplc); +void sethlinesizes(int logx, int logy, int bufplc); void setpalookupaddress(char *paladdr); -void setuphlineasm4(long bxinc, long byinc); -void hlineasm4(long cnt, long skiploadincs, long paloffs, unsigned long by, unsigned long bx, long p); +void setuphlineasm4(int bxinc, int byinc); +void hlineasm4(int cnt, int skiploadincs, int paloffs, unsigned int by, unsigned int bx, int p); -void setupslopevlin(long logylogx, long bufplc, long pinc); -void slopevlin(long p, long i, long slopaloffs, long cnt, long bx, long by); +void setupslopevlin(int logylogx, int bufplc, int pinc); +void slopevlin(int p, int i, int slopaloffs, int cnt, int bx, int by); -void setupvlineasm(long neglogy); -void vlineasm1(long vinc, long paloffs, long cnt, unsigned long vplc, long bufplc, long p); +void setupvlineasm(int neglogy); +void vlineasm1(int vinc, int paloffs, int cnt, unsigned int vplc, int bufplc, int p); -void setupmvlineasm(long neglogy); -void mvlineasm1(long vinc, long paloffs, long cnt, unsigned long vplc, long bufplc, long p); +void setupmvlineasm(int neglogy); +void mvlineasm1(int vinc, int paloffs, int cnt, unsigned int vplc, int bufplc, int p); -void setuptvlineasm(long neglogy); -void tvlineasm1(long vinc, long paloffs, long cnt, unsigned long vplc, long bufplc, long p); +void setuptvlineasm(int neglogy); +void tvlineasm1(int vinc, int paloffs, int cnt, unsigned int vplc, int bufplc, int p); -void msethlineshift(long logx, long logy); -void mhline(long bufplc, unsigned long bx, long cntup16, long junk, unsigned long by, long p); +void msethlineshift(int logx, int logy); +void mhline(int bufplc, unsigned int bx, int cntup16, int junk, unsigned int by, int p); -void tsethlineshift(long logx, long logy); -void thline(long bufplc, unsigned long bx, long cntup16, long junk, unsigned long by, long p); +void tsethlineshift(int logx, int logy); +void thline(int bufplc, unsigned int bx, int cntup16, int junk, unsigned int by, int p); -void setupspritevline(long paloffs, long bxinc, long byinc, long ysiz); -void spritevline(long bx, long by, long cnt, long bufplc, long p); +void setupspritevline(int paloffs, int bxinc, int byinc, int ysiz); +void spritevline(int bx, int by, int cnt, int bufplc, int p); -void msetupspritevline(long paloffs, long bxinc, long byinc, long ysiz); -void mspritevline(long bx, long by, long cnt, long bufplc, long p); +void msetupspritevline(int paloffs, int bxinc, int byinc, int ysiz); +void mspritevline(int bx, int by, int cnt, int bufplc, int p); -void tsetupspritevline(long paloffs, long bxinc, long byinc, long ysiz); -void tspritevline(long bx, long by, long cnt, long bufplc, long p); +void tsetupspritevline(int paloffs, int bxinc, int byinc, int ysiz); +void tspritevline(int bx, int by, int cnt, int bufplc, int p); -void setupdrawslab (long dabpl, long pal); -void drawslab (long dx, long v, long dy, long vi, long vptr, long p); -void stretchhline (long p0, long u, long cnt, long uinc, long rptr, long p); +void setupdrawslab (int dabpl, int pal); +void drawslab (int dx, int v, int dy, int vi, int vptr, int p); +void stretchhline (int p0, int u, int cnt, int uinc, int rptr, int p); void mmxoverlay(); diff --git a/polymer/build/include/baselayer.h b/polymer/build/include/baselayer.h index ddef088cf..058cfc906 100644 --- a/polymer/build/include/baselayer.h +++ b/polymer/build/include/baselayer.h @@ -22,7 +22,7 @@ extern int startwin_settitle(const char *); extern int startwin_idle(void *); // video -extern long xres, yres, bpp, fullscreen, bytesperline, imageSize, frameplace; +extern int xres, yres, bpp, fullscreen, bytesperline, imageSize, frameplace; extern char offscreenrendering; extern void (*baselayer_onvideomodechange)(int); @@ -61,12 +61,12 @@ extern char keystatus[256], keyfifo[KEYFIFOSIZ], keyfifoplc, keyfifoend; extern unsigned char keyasciififo[KEYFIFOSIZ], keyasciififoplc, keyasciififoend; // mouse -extern long mousex, mousey, mouseb; +extern int mousex, mousey, mouseb; // joystick -extern long *joyaxis, *joyhat, joyb; +extern int *joyaxis, *joyhat, joyb; extern char joyisgamepad, joynumaxes, joynumbuttons, joynumhats; -extern long joyaxespresent; +extern int joyaxespresent; @@ -79,15 +79,15 @@ void debugprintf(const char *,...); int handleevents(void); extern inline void idle(void); -typedef void (*KeyPressCallback)(long,long); -typedef void (*MousePressCallback)(long,long); -typedef void (*JoyPressCallback)(long,long); +typedef void (*KeyPressCallback)(int,int); +typedef void (*MousePressCallback)(int,int); +typedef void (*JoyPressCallback)(int,int); int initinput(void); void uninitinput(void); void releaseallbuttons(void); -void setkeypresscallback(void (*callback)(long,long)); -void setmousepresscallback(void (*callback)(long,long)); -void setjoypresscallback(void (*callback)(long,long)); +void setkeypresscallback(void (*callback)(int,int)); +void setmousepresscallback(void (*callback)(int,int)); +void setjoypresscallback(void (*callback)(int,int)); const unsigned char *getkeyname(int num); const unsigned char *getjoyname(int what, int num); // what: 0=axis, 1=button, 2=hat @@ -98,15 +98,15 @@ void bflushchars(void); int initmouse(void); void uninitmouse(void); void grabmouse(char a); -void readmousexy(long *x, long *y); -void readmousebstatus(long *b); +void readmousexy(int *x, int *y); +void readmousebstatus(int *b); void setjoydeadzone(int axis, unsigned short dead, unsigned short satur); void getjoydeadzone(int axis, unsigned short *dead, unsigned short *satur); int inittimer(int); void uninittimer(void); void sampletimer(void); -unsigned long getticks(void); +unsigned int getticks(void); int gettimerfreq(void); void (*installusertimercallback(void (*callback)(void)))(void); diff --git a/polymer/build/include/build.h b/polymer/build/include/build.h index eae628125..fde5f2500 100644 --- a/polymer/build/include/build.h +++ b/polymer/build/include/build.h @@ -85,7 +85,7 @@ extern "C" { typedef struct BPACK { short wallptr, wallnum; - long ceilingz, floorz; + int ceilingz, floorz; short ceilingstat, floorstat; short ceilingpicnum, ceilingheinum; signed char ceilingshade; @@ -113,7 +113,7 @@ typedef struct BPACK //32 bytes typedef struct BPACK { - long x, y; + int x, y; short point2, nextwall, nextsector, cstat; short picnum, overpicnum; signed char shade; @@ -139,7 +139,7 @@ typedef struct BPACK //44 bytes typedef struct BPACK { - long x, y, z; + int x, y, z; short cstat, picnum; signed char shade; char pal, clipdist, filler; @@ -151,11 +151,11 @@ typedef struct BPACK } spritetype; typedef struct BPACK { - unsigned long mdanimtims; + unsigned int mdanimtims; short mdanimcur; short angoff; short pitch, roll; - long xoff, yoff, zoff; + int xoff, yoff, zoff; unsigned char flags; char filler[3]; } spriteexttype; @@ -170,41 +170,41 @@ typedef struct BPACK { #define SPREXT_NOMDANIM 2 EXTERN spriteexttype *spriteext; EXTERN spritesmoothtype *spritesmooth; -EXTERN long guniqhudid; +EXTERN int guniqhudid; EXTERN sectortype *sector; EXTERN walltype *wall; EXTERN spritetype *sprite; -EXTERN long spritesortcnt; +EXTERN int spritesortcnt; EXTERN spritetype *tsprite; -EXTERN long xdim, ydim, ylookup[MAXYDIM+1], numpages; -EXTERN long yxaspect, viewingrange; +EXTERN int xdim, ydim, ylookup[MAXYDIM+1], numpages; +EXTERN int yxaspect, viewingrange; #define MAXVALIDMODES 256 -EXTERN long validmodecnt; +EXTERN int validmodecnt; struct validmode_t { - long xdim,ydim; + int xdim,ydim; char bpp; char fs; // bit 0 = fullscreen flag char filler[2]; - long extra; // internal use + int extra; // internal use }; EXTERN struct validmode_t validmode[MAXVALIDMODES]; EXTERN short numsectors, numwalls; -EXTERN /*volatile*/ long totalclock; -EXTERN long numframes, randomseed; +EXTERN /*volatile*/ int totalclock; +EXTERN int numframes, randomseed; EXTERN short sintable[2048]; EXTERN char palette[768]; EXTERN short numpalookups; EXTERN char *palookup[MAXPALOOKUPS]; EXTERN char parallaxtype, showinvisibility; -EXTERN long parallaxyoffs, parallaxyscale; -EXTERN long visibility, parallaxvisibility; +EXTERN int parallaxyoffs, parallaxyscale; +EXTERN int visibility, parallaxvisibility; -EXTERN long windowx1, windowy1, windowx2, windowy2; +EXTERN int windowx1, windowy1, windowx2, windowy2; EXTERN short startumost[MAXXDIM], startdmost[MAXXDIM]; EXTERN short pskyoff[MAXPSKYTILES], pskybits; @@ -216,8 +216,8 @@ EXTERN short nextspritesect[MAXSPRITES], nextspritestat[MAXSPRITES]; EXTERN short tilesizx[MAXTILES], tilesizy[MAXTILES]; EXTERN char picsiz[MAXTILES]; EXTERN char walock[MAXTILES]; -EXTERN long pow2long[32]; -EXTERN long numtiles, picanm[MAXTILES], waloff[MAXTILES]; +EXTERN int pow2long[32]; +EXTERN int numtiles, picanm[MAXTILES], waloff[MAXTILES]; EXTERN int windowpos, windowx, windowy; @@ -245,7 +245,7 @@ EXTERN char gotsector[(MAXSECTORS+7)>>3]; EXTERN char captureformat; extern char vgapalette[5*256]; -extern unsigned long drawlinepat; +extern unsigned int drawlinepat; extern void faketimerhandler(void); @@ -256,14 +256,14 @@ typedef struct { extern palette_t curpalette[256], curpalettefaded[256], palfadergb; extern char palfadedelta; -extern long dommxoverlay, novoxmips; +extern int dommxoverlay, novoxmips; #ifdef SUPERBUILD -extern long tiletovox[MAXTILES]; -extern long usevoxels, voxscale[MAXVOXELS]; +extern int tiletovox[MAXTILES]; +extern int usevoxels, voxscale[MAXVOXELS]; #endif #ifdef POLYMOST -extern long usemodels, usehightile; +extern int usemodels, usehightile; #endif extern char *engineerrstr; @@ -375,79 +375,79 @@ int preinitengine(void); // a partial setup of the engine used for launch win int initengine(void); void uninitengine(void); void initspritelists(void); -long loadboard(char *filename, char fromwhere, long *daposx, long *daposy, long *daposz, short *daang, short *dacursectnum); -long loadmaphack(char *filename); -long saveboard(char *filename, long *daposx, long *daposy, long *daposz, short *daang, short *dacursectnum); -long loadpics(char *filename, long askedsize); +int loadboard(char *filename, char fromwhere, int *daposx, int *daposy, int *daposz, short *daang, short *dacursectnum); +int loadmaphack(char *filename); +int saveboard(char *filename, int *daposx, int *daposy, int *daposz, short *daang, short *dacursectnum); +int loadpics(char *filename, int askedsize); void loadtile(short tilenume); -long qloadkvx(long voxindex, char *filename); -long allocatepermanenttile(short tilenume, long xsiz, long ysiz); -void copytilepiece(long tilenume1, long sx1, long sy1, long xsiz, long ysiz, long tilenume2, long sx2, long sy2); -void makepalookup(long palnum, char *remapbuf, signed char r, signed char g, signed char b, char dastat); +int qloadkvx(int voxindex, char *filename); +int allocatepermanenttile(short tilenume, int xsiz, int ysiz); +void copytilepiece(int tilenume1, int sx1, int sy1, int xsiz, int ysiz, int tilenume2, int sx2, int sy2); +void makepalookup(int palnum, char *remapbuf, signed char r, signed char g, signed char b, char dastat); void setvgapalette(void); void setbrightness(char dabrightness, char *dapal, char noapply); void setpalettefade(char r, char g, char b, char offset); void squarerotatetile(short tilenume); -long setgamemode(char davidoption, long daxdim, long daydim, long dabpp); +int setgamemode(char davidoption, int daxdim, int daydim, int dabpp); void nextpage(void); -void setview(long x1, long y1, long x2, long y2); -void setaspect(long daxrange, long daaspect); +void setview(int x1, int y1, int x2, int y2); +void setaspect(int daxrange, int daaspect); void flushperms(void); -void plotpixel(long x, long y, char col); -char getpixel(long x, long y); -void setviewtotile(short tilenume, long xsiz, long ysiz); +void plotpixel(int x, int y, char col); +char getpixel(int x, int y); +void setviewtotile(short tilenume, int xsiz, int ysiz); void setviewback(void); -void preparemirror(long dax, long day, long daz, short daang, long dahoriz, short dawall, short dasector, long *tposx, long *tposy, short *tang); +void preparemirror(int dax, int day, int daz, short daang, int dahoriz, short dawall, short dasector, int *tposx, int *tposy, short *tang); void completemirror(void); -void drawrooms(long daposx, long daposy, long daposz, short daang, long dahoriz, short dacursectnum); +void drawrooms(int daposx, int daposy, int daposz, short daang, int dahoriz, short dacursectnum); void drawmasks(void); -void clearview(long dacol); -void clearallviews(long dacol); -void drawmapview(long dax, long day, long zoome, short ang); -void rotatesprite(long sx, long sy, long z, short a, short picnum, signed char dashade, char dapalnum, char dastat, long cx1, long cy1, long cx2, long cy2); -void drawline256(long x1, long y1, long x2, long y2, char col); -void printext16(long xpos, long ypos, short col, short backcol, char *name, char fontsize); -void printext256(long xpos, long ypos, short col, short backcol, char *name, char fontsize); +void clearview(int dacol); +void clearallviews(int dacol); +void drawmapview(int dax, int day, int zoome, short ang); +void rotatesprite(int sx, int sy, int z, short a, short picnum, signed char dashade, char dapalnum, char dastat, int cx1, int cy1, int cx2, int cy2); +void drawline256(int x1, int y1, int x2, int y2, char col); +void printext16(int xpos, int ypos, short col, short backcol, char *name, char fontsize); +void printext256(int xpos, int ypos, short col, short backcol, char *name, char fontsize); -long clipmove(long *x, long *y, long *z, short *sectnum, long xvect, long yvect, long walldist, long ceildist, long flordist, unsigned long cliptype); -long clipinsidebox(long x, long y, short wallnum, long walldist); -long clipinsideboxline(long x, long y, long x1, long y1, long x2, long y2, long walldist); -long pushmove(long *x, long *y, long *z, short *sectnum, long walldist, long ceildist, long flordist, unsigned long cliptype); -void getzrange(long x, long y, long z, short sectnum, long *ceilz, long *ceilhit, long *florz, long *florhit, long walldist, unsigned long cliptype); -long hitscan(long xs, long ys, long zs, short sectnum, long vx, long vy, long vz, short *hitsect, short *hitwall, short *hitsprite, long *hitx, long *hity, long *hitz, unsigned long cliptype); -long neartag(long xs, long ys, long zs, short sectnum, short ange, short *neartagsector, short *neartagwall, short *neartagsprite, long *neartaghitdist, long neartagrange, char tagsearch); -long cansee(long x1, long y1, long z1, short sect1, long x2, long y2, long z2, short sect2); -void updatesector(long x, long y, short *sectnum); -void updatesectorz(long x, long y, long z, short *sectnum); -long inside(long x, long y, short sectnum); -void dragpoint(short pointhighlight, long dax, long day); +int clipmove(int *x, int *y, int *z, short *sectnum, int xvect, int yvect, int walldist, int ceildist, int flordist, unsigned int cliptype); +int clipinsidebox(int x, int y, short wallnum, int walldist); +int clipinsideboxline(int x, int y, int x1, int y1, int x2, int y2, int walldist); +int pushmove(int *x, int *y, int *z, short *sectnum, int walldist, int ceildist, int flordist, unsigned int cliptype); +void getzrange(int x, int y, int z, short sectnum, int *ceilz, int *ceilhit, int *florz, int *florhit, int walldist, unsigned int cliptype); +int hitscan(int xs, int ys, int zs, short sectnum, int vx, int vy, int vz, short *hitsect, short *hitwall, short *hitsprite, int *hitx, int *hity, int *hitz, unsigned int cliptype); +int neartag(int xs, int ys, int zs, short sectnum, short ange, short *neartagsector, short *neartagwall, short *neartagsprite, int *neartaghitdist, int neartagrange, char tagsearch); +int cansee(int x1, int y1, int z1, short sect1, int x2, int y2, int z2, short sect2); +void updatesector(int x, int y, short *sectnum); +void updatesectorz(int x, int y, int z, short *sectnum); +int inside(int x, int y, short sectnum); +void dragpoint(short pointhighlight, int dax, int day); void setfirstwall(short sectnum, short newfirstwall); -void getmousevalues(long *mousx, long *mousy, long *bstatus); -long krand(void); -long ksqrt(long num); -long getangle(long xvect, long yvect); -void rotatepoint(long xpivot, long ypivot, long x, long y, short daang, long *x2, long *y2); -long lastwall(short point); -long nextsectorneighborz(short sectnum, long thez, short topbottom, short direction); -long getceilzofslope(short sectnum, long dax, long day); -long getflorzofslope(short sectnum, long dax, long day); -void getzsofslope(short sectnum, long dax, long day, long *ceilz, long *florz); -void alignceilslope(short dasect, long x, long y, long z); -void alignflorslope(short dasect, long x, long y, long z); -long sectorofwall(short theline); -long loopnumofsector(short sectnum, short wallnum); +void getmousevalues(int *mousx, int *mousy, int *bstatus); +int krand(void); +int ksqrt(int num); +int getangle(int xvect, int yvect); +void rotatepoint(int xpivot, int ypivot, int x, int y, short daang, int *x2, int *y2); +int lastwall(short point); +int nextsectorneighborz(short sectnum, int thez, short topbottom, short direction); +int getceilzofslope(short sectnum, int dax, int day); +int getflorzofslope(short sectnum, int dax, int day); +void getzsofslope(short sectnum, int dax, int day, int *ceilz, int *florz); +void alignceilslope(short dasect, int x, int y, int z); +void alignflorslope(short dasect, int x, int y, int z); +int sectorofwall(short theline); +int loopnumofsector(short sectnum, short wallnum); -long insertsprite(short sectnum, short statnum); -long deletesprite(short spritenum); -long changespritesect(short spritenum, short newsectnum); -long changespritestat(short spritenum, short newstatnum); -long setsprite(short spritenum, long newx, long newy, long newz); +int insertsprite(short sectnum, short statnum); +int deletesprite(short spritenum); +int changespritesect(short spritenum, short newsectnum); +int changespritestat(short spritenum, short newstatnum); +int setsprite(short spritenum, int newx, int newy, int newz); -long screencapture(char *filename, char inverseit); +int screencapture(char *filename, char inverseit); // PLAG: line utility functions typedef struct s_equation { @@ -456,24 +456,24 @@ typedef struct s_equation { typedef struct s_point2d { float x, y; } _point2d; -_equation equation(long x1, long y1, long x2, long y2); +_equation equation(int x1, int y1, int x2, int y2); int sameside(_equation* eq, _point2d* p1, _point2d* p2); int wallvisible(short wallnum); #define STATUS2DSIZ 144 void qsetmode640350(void); void qsetmode640480(void); -void qsetmodeany(long,long); +void qsetmodeany(int,int); void clear2dscreen(void); -void draw2dgrid(long posxe, long posye, short ange, long zoome, short gride); -void draw2dscreen(long posxe, long posye, short ange, long zoome, short gride); -void drawline16(long x1, long y1, long x2, long y2, char col); -void drawcircle16(long x1, long y1, long r, char col); +void draw2dgrid(int posxe, int posye, short ange, int zoome, short gride); +void draw2dscreen(int posxe, int posye, short ange, int zoome, short gride); +void drawline16(int x1, int y1, int x2, int y2, char col); +void drawcircle16(int x1, int y1, int r, char col); int setrendermode(int renderer); int getrendermode(void); -void setrollangle(long rolla); +void setrollangle(int rolla); // pal: pass -1 to invalidate all palettes for the tile, or >=0 for a particular palette // how: pass -1 to invalidate all instances of the tile in texture memory, or a bitfield @@ -486,42 +486,42 @@ void setrollangle(long rolla); // bit 6: 33% translucence, using clamping // bit 7: 67% translucence, using clamping // clamping is for sprites, repeating is for walls -void invalidatetile(short tilenume, long pal, long how); +void invalidatetile(short tilenume, int pal, int how); -long animateoffs(short tilenum, short fakevar); +int animateoffs(short tilenum, short fakevar); void setpolymost2dview(void); // sets up GL for 2D drawing -long polymost_drawtilescreen(long tilex, long tiley, long wallnum, long dimen, int tilezoom); +int polymost_drawtilescreen(int tilex, int tiley, int wallnum, int dimen, int tilezoom); void polymost_glreset(void); -void polymost_precache(long dapicnum, long dapalnum, long datype); +void polymost_precache(int dapicnum, int dapalnum, int datype); #if defined(POLYMOST) && defined(USE_OPENGL) -extern long glanisotropy; -extern long glusetexcompr; -extern long gltexfiltermode; -extern long glredbluemode; -extern long glusetexcache, glusetexcachecompression; -extern long glmultisample, glnvmultisamplehint; -extern long glwidescreen, glprojectionhacks; +extern int glanisotropy; +extern int glusetexcompr; +extern int gltexfiltermode; +extern int glredbluemode; +extern int glusetexcache, glusetexcachecompression; +extern int glmultisample, glnvmultisamplehint; +extern int glwidescreen, glprojectionhacks; void gltexapplyprops (void); -extern long r_depthpeeling, r_peelscount; -extern long r_detailmapping; -extern long r_glowmapping; -extern long r_vertexarrays; -extern long r_vbos; -extern long r_vbocount; -extern long r_animsmoothing; +extern int r_depthpeeling, r_peelscount; +extern int r_detailmapping; +extern int r_glowmapping; +extern int r_vertexarrays; +extern int r_vbos; +extern int r_vbocount; +extern int r_animsmoothing; #endif void hicinit(void); // effect bitset: 1 = greyscale, 2 = invert -void hicsetpalettetint(long palnum, unsigned char r, unsigned char g, unsigned char b, unsigned char effect); +void hicsetpalettetint(int palnum, unsigned char r, unsigned char g, unsigned char b, unsigned char effect); // flags bitset: 1 = don't compress -int hicsetsubsttex(long picnum, long palnum, char *filen, float alphacut, float xscale, float yscale, char flags); -int hicsetskybox(long picnum, long palnum, char *faces[6]); -int hicclearsubst(long picnum, long palnum); +int hicsetsubsttex(int picnum, int palnum, char *filen, float alphacut, float xscale, float yscale, char flags); +int hicsetskybox(int picnum, int palnum, char *faces[6]); +int hicclearsubst(int picnum, int palnum); int md_loadmodel(const char *fn); int md_setmisc(int modelid, float scale, int shadeoff, float zadd); @@ -535,8 +535,8 @@ int md_undefinemodel(int modelid); int loaddefinitionsfile(char *fn); -extern long mapversion; // if loadboard() fails with -2 return, try loadoldboard(). if it fails with -2, board is dodgy -long loadoldboard(char *filename, char fromwhere, long *daposx, long *daposy, long *daposz, short *daang, short *dacursectnum); +extern int mapversion; // if loadboard() fails with -2 return, try loadoldboard(). if it fails with -2, board is dodgy +int loadoldboard(char *filename, char fromwhere, int *daposx, int *daposy, int *daposz, short *daang, short *dacursectnum); #ifdef _MSC_VER #pragma pack() diff --git a/polymer/build/include/cache1d.h b/polymer/build/include/cache1d.h index 03c2e3f70..8b440ac06 100644 --- a/polymer/build/include/cache1d.h +++ b/polymer/build/include/cache1d.h @@ -7,9 +7,9 @@ extern "C" { #endif -void initcache(long dacachestart, long dacachesize); -void allocache(long *newhandle, long newbytes, char *newlockptr); -void suckcache(long *suckptr); +void initcache(int dacachestart, int dacachesize); +void allocache(int *newhandle, int newbytes, char *newlockptr); +void suckcache(int *suckptr); void agecache(void); extern int pathsearchmode; // 0 = gamefs mode (default), 1 = localfs mode (editor's mode) @@ -18,15 +18,15 @@ int findfrompath(const char *fn, char **where); int openfrompath(const char *fn, int flags, int mode); BFILE *fopenfrompath(const char *fn, const char *mode); -long initgroupfile(char *filename); -void uninitsinglegroupfile(long grphandle); +int initgroupfile(char *filename); +void uninitsinglegroupfile(int grphandle); void uninitgroupfile(void); -long kopen4load(char *filename, char searchfirst); // searchfirst: 0 = anywhere, 1 = first group, 2 = any group -long kread(long handle, void *buffer, long leng); -long klseek(long handle, long offset, long whence); -long kfilelength(long handle); -long ktell(long handle); -void kclose(long handle); +int kopen4load(char *filename, char searchfirst); // searchfirst: 0 = anywhere, 1 = first group, 2 = any group +int kread(int handle, void *buffer, int leng); +int klseek(int handle, int offset, int whence); +int kfilelength(int handle); +int ktell(int handle); +void kclose(int handle); enum { CACHE1D_FIND_FILE = 1, @@ -50,9 +50,9 @@ typedef struct _CACHE1D_FIND_REC { void klistfree(CACHE1D_FIND_REC *rec); CACHE1D_FIND_REC *klistpath(const char *path, const char *mask, int type); -int kdfread(void *buffer, bsize_t dasizeof, bsize_t count, long fil); +int kdfread(void *buffer, bsize_t dasizeof, bsize_t count, int fil); int dfread(void *buffer, bsize_t dasizeof, bsize_t count, BFILE *fil); -void kdfwrite(void *buffer, bsize_t dasizeof, bsize_t count, long fil); +void kdfwrite(void *buffer, bsize_t dasizeof, bsize_t count, int fil); void dfwrite(void *buffer, bsize_t dasizeof, bsize_t count, BFILE *fil); #ifdef __cplusplus diff --git a/polymer/build/include/compat.h b/polymer/build/include/compat.h index 3c8f54078..4d87d327d 100644 --- a/polymer/build/include/compat.h +++ b/polymer/build/include/compat.h @@ -73,7 +73,7 @@ # define longlong(x) x##i64 #else # define longlong(x) x##ll -typedef long long int64; +typedef long long int int64; typedef unsigned long long uint64; #endif @@ -178,7 +178,7 @@ extern "C" { # endif #elif defined B_ENDIAN_C_INLINE static inline unsigned short B_SWAP16(unsigned short s) { return (s>>8)|(s<<8); } -static inline unsigned long B_SWAP32(unsigned long l) { return ((l>>8)&0xff00)|((l&0xff00)<<8)|(l<<24)|(l>>24); } +static inline unsigned int B_SWAP32(unsigned int l) { return ((l>>8)&0xff00)|((l&0xff00)<<8)|(l<<24)|(l>>24); } static inline uint64 B_SWAP64(uint64 l) { return (l>>56)|((l>>40)&0xff00)|((l>>24)&0xff0000)|((l>>8)&0xff000000)|((l&255)<<56)|((l&0xff00)<<40)|((l&0xff0000)<<24)|((l&0xff000000)<<8); } #endif @@ -298,8 +298,8 @@ int Bclosedir(BDIR *dir); # define bssize_t ssize_t #else typedef void BFILE; - typedef unsigned long bsize_t; - typedef signed long bssize_t; + typedef unsigned int bsize_t; + typedef signed int bssize_t; #endif @@ -415,9 +415,9 @@ bsize_t Bstrlen(const char *s); char *Bstrchr(const char *s, int c); char *Bstrrchr(const char *s, int c); int Batoi(const char *nptr); -long Batol(const char *nptr); -long int Bstrtol(const char *nptr, char **endptr, int base); -unsigned long int Bstrtoul(const char *nptr, char **endptr, int base); +int Batol(const char *nptr); +int int Bstrtol(const char *nptr, char **endptr, int base); +unsigned int int Bstrtoul(const char *nptr, char **endptr, int base); void *Bmemcpy(void *dest, const void *src, bsize_t n); void *Bmemmove(void *dest, const void *src, bsize_t n); void *Bmemchr(const void *s, int c, bsize_t n); @@ -437,9 +437,9 @@ unsigned int Bgetsysmemsize(void); int Bcorrectfilename(char *filename, int removefn); int Bcanonicalisefilename(char *filename, int removefn); char *Bgetsystemdrives(void); -long Bfilelength(int fd); +int Bfilelength(int fd); char *Bstrtoken(char *s, char *delim, char **ptrptr, int chop); -long Bwildmatch (const char *i, const char *j); +int Bwildmatch (const char *i, const char *j); #if !defined(_WIN32) char *Bstrlwr(char *); diff --git a/polymer/build/include/crc32.h b/polymer/build/include/crc32.h index 5f0984175..36ceb9430 100644 --- a/polymer/build/include/crc32.h +++ b/polymer/build/include/crc32.h @@ -7,11 +7,11 @@ extern "C" { void initcrc32table(void); -unsigned long crc32once(unsigned char *blk, unsigned long len); +unsigned int crc32once(unsigned char *blk, unsigned int len); -void crc32init(unsigned long *crcvar); -void crc32block(unsigned long *crcvar, unsigned char *blk, unsigned long len); -unsigned long crc32finish(unsigned long *crcvar); +void crc32init(unsigned int *crcvar); +void crc32block(unsigned int *crcvar, unsigned char *blk, unsigned int len); +unsigned int crc32finish(unsigned int *crcvar); #ifdef __cplusplus } diff --git a/polymer/build/include/editor.h b/polymer/build/include/editor.h index bb5126228..79e80bc75 100644 --- a/polymer/build/include/editor.h +++ b/polymer/build/include/editor.h @@ -11,9 +11,9 @@ extern "C" { #define NUMBUILDKEYS 20 -extern long qsetmode; +extern int qsetmode; extern short searchsector, searchwall, searchstat; -extern long zmode, kensplayerheight; +extern int zmode, kensplayerheight; extern short defaultspritecstat; extern short temppicnum, tempcstat, templotag, temphitag, tempextra; @@ -22,7 +22,7 @@ extern unsigned char somethingintab; extern unsigned char buildkeys[NUMBUILDKEYS]; -extern long ydim16, xdimgame, ydimgame, bppgame, xdim2d, ydim2d, forcesetup; +extern int ydim16, xdimgame, ydimgame, bppgame, xdim2d, ydim2d, forcesetup; extern int ExtInit(void); @@ -55,13 +55,13 @@ int writesetup(const char *fn); // from config.c void editinput(void); void clearmidstatbar16(void); -long getnumber256(char namestart[80], long num, long maxnumber, char sign); -long getnumber16(char namestart[80], long num, long maxnumber, char sign); +int getnumber256(char namestart[80], int num, int maxnumber, char sign); +int getnumber16(char namestart[80], int num, int maxnumber, char sign); void printmessage256(char name[82]); void printmessage16(char name[82]); -void getpoint(long searchxe, long searchye, long *x, long *y); -long getpointhighlight(long xplc, long yplc); +void getpoint(int searchxe, int searchye, int *x, int *y); +int getpointhighlight(int xplc, int yplc); #ifdef __cplusplus } diff --git a/polymer/build/include/kplib.h b/polymer/build/include/kplib.h index 32f063ec8..850253a3c 100644 --- a/polymer/build/include/kplib.h +++ b/polymer/build/include/kplib.h @@ -1,21 +1,21 @@ //High-level (easy) picture loading function: -extern void kpzload (const char *, long *, long *, long *, long *); +extern void kpzload (const char *, int *, int *, int *, int *); //Low-level PNG/JPG functions: -extern void kpgetdim (const char *, long, long *, long *); -extern long kprender (const char *, long, long, long, long, long, long, long); +extern void kpgetdim (const char *, int, int *, int *); +extern int kprender (const char *, int, int, int, int, int, int, int); //ZIP functions: -extern long kzaddstack (const char *); +extern int kzaddstack (const char *); extern void kzuninit (); -extern long kzopen (const char *); -extern long kzread (void *, long); -extern long kzfilelength (); -extern long kzseek (long, long); -extern long kztell (); -extern long kzgetc (); -extern long kzeof (); +extern int kzopen (const char *); +extern int kzread (void *, int); +extern int kzfilelength (); +extern int kzseek (int, int); +extern int kztell (); +extern int kzgetc (); +extern int kzeof (); extern void kzclose (); extern void kzfindfilestart (const char *); //pass wildcard string -extern long kzfindfile (char *); //you alloc buf, returns 1:found,0:~found +extern int kzfindfile (char *); //you alloc buf, returns 1:found,0:~found diff --git a/polymer/build/include/lzwnew.h b/polymer/build/include/lzwnew.h index 6606bb3a5..b25c70965 100644 --- a/polymer/build/include/lzwnew.h +++ b/polymer/build/include/lzwnew.h @@ -1,2 +1,2 @@ -long lzwcompress (unsigned char *ucompbuf, long ucompleng, unsigned char *compbuf); -long lzwuncompress (unsigned char *compbuf, long compleng, unsigned char *ucompbuf, long ucompleng); +int lzwcompress (unsigned char *ucompbuf, int ucompleng, unsigned char *compbuf); +int lzwuncompress (unsigned char *compbuf, int compleng, unsigned char *ucompbuf, int ucompleng); diff --git a/polymer/build/include/md4.h b/polymer/build/include/md4.h index 27c2e3611..fdb23b4f7 100644 --- a/polymer/build/include/md4.h +++ b/polymer/build/include/md4.h @@ -27,8 +27,8 @@ /* MD4 context. */ typedef struct { - unsigned long state[4]; /* state (ABCD) */ - unsigned long count[2]; /* number of bits, modulo 2^64 (lsb first) */ + unsigned int state[4]; /* state (ABCD) */ + unsigned int count[2]; /* number of bits, modulo 2^64 (lsb first) */ unsigned char buffer[64]; /* input buffer */ } MD4_CTX; diff --git a/polymer/build/include/mmulti.h b/polymer/build/include/mmulti.h index 5d5698631..6886a62f4 100644 --- a/polymer/build/include/mmulti.h +++ b/polymer/build/include/mmulti.h @@ -5,30 +5,30 @@ #define MAXMULTIPLAYERS 16 -extern long myconnectindex, numplayers; -extern long connecthead, connectpoint2[MAXMULTIPLAYERS]; +extern int myconnectindex, numplayers; +extern int connecthead, connectpoint2[MAXMULTIPLAYERS]; extern char syncstate; extern int natfree; //Addfaz NatFree -long initmultiplayersparms(long argc, char **argv); -long initmultiplayerscycle(void); +int initmultiplayersparms(int argc, char **argv); +int initmultiplayerscycle(void); -void initmultiplayers(long argc, char **argv, char damultioption, char dacomrateoption, char dapriority); -void setpackettimeout(long datimeoutcount, long daresendagaincount); +void initmultiplayers(int argc, char **argv, char damultioption, char dacomrateoption, char dapriority); +void setpackettimeout(int datimeoutcount, int daresendagaincount); void uninitmultiplayers(void); void sendlogon(void); void sendlogoff(void); -long getoutputcirclesize(void); +int getoutputcirclesize(void); void setsocket(short newsocket); -void sendpacket(long other, char *bufptr, long messleng); -long getpacket(long *other, char *bufptr); +void sendpacket(int other, char *bufptr, int messleng); +int getpacket(int *other, char *bufptr); void flushpackets(void); -void genericmultifunction(long other, char *bufptr, long messleng, long command); -long isvalidipaddress(char *st); +void genericmultifunction(int other, char *bufptr, int messleng, int command); +int isvalidipaddress(char *st); void nfIncCP(void); //Addfaz NatFree -int nfCheckHF (long other); //Addfaz NatFree -int nfCheckCP(long other); //Addfaz NatFree +int nfCheckHF (int other); //Addfaz NatFree +int nfCheckCP(int other); //Addfaz NatFree #endif // __mmulti_h__ diff --git a/polymer/build/include/polymer.h b/polymer/build/include/polymer.h index b043ec88e..9d06b7352 100644 --- a/polymer/build/include/polymer.h +++ b/polymer/build/include/polymer.h @@ -88,10 +88,10 @@ extern int updatesectors; int polymer_init(void); void polymer_glinit(void); void polymer_loadboard(void); -void polymer_drawrooms(long daposx, long daposy, long daposz, short daang, long dahoriz, short dacursectnum, int root); -void polymer_rotatesprite(long sx, long sy, long z, short a, short picnum, signed char dashade, char dapalnum, char dastat, long cx1, long cy1, long cx2, long cy2); -void polymer_drawmaskwall(long damaskwallcnt); -void polymer_drawsprite(long snum); +void polymer_drawrooms(int daposx, int daposy, int daposz, short daang, int dahoriz, short dacursectnum, int root); +void polymer_rotatesprite(int sx, int sy, int z, short a, short picnum, signed char dashade, char dapalnum, char dastat, int cx1, int cy1, int cx2, int cy2); +void polymer_drawmaskwall(int damaskwallcnt); +void polymer_drawsprite(int snum); // SECTORS int polymer_initsector(short sectnum); int polymer_updatesector(short sectnum); diff --git a/polymer/build/include/polymost.h b/polymer/build/include/polymost.h index e6b049aa7..9adbec154 100644 --- a/polymer/build/include/polymost.h +++ b/polymer/build/include/polymost.h @@ -4,7 +4,7 @@ # include "glbuild.h" struct hicskybox_t { - long ignore; + int ignore; char *face[6]; }; @@ -32,7 +32,7 @@ typedef struct pthtyp_t struct pthtyp_t *ofb; // only fullbright } pthtyp; -pthtyp * gltexcache (long dapicnum, long dapalnum, long dameth); +pthtyp * gltexcache (int dapicnum, int dapalnum, int dameth); extern palette_t hictinting[MAXPALOOKUPS]; extern float gtang; diff --git a/polymer/build/include/pragmas.h b/polymer/build/include/pragmas.h index df0684af3..7f2c42040 100644 --- a/polymer/build/include/pragmas.h +++ b/polymer/build/include/pragmas.h @@ -9,7 +9,7 @@ extern "C" { #endif -extern long dmval; +extern int dmval; #if defined(__GNUC__) && defined(__i386__) && !defined(NOASM) @@ -27,15 +27,15 @@ extern long dmval; // maybe one day I'll make these into macros -long boundmulscale(long a, long b, long c); -void clearbufbyte(void *D, long c, long a); -void copybufbyte(void *S, void *D, long c); -void copybufreverse(void *S, void *D, long c); +int boundmulscale(int a, int b, int c); +void clearbufbyte(void *D, int c, int a); +void copybufbyte(void *S, void *D, int c); +void copybufreverse(void *S, void *D, int c); #ifdef NO_GCC_BUILTINS #define sqr(a) \ - ({ long __a=(a); \ + ({ int __a=(a); \ __asm__ __volatile__ ("imull %0, %0" \ : "=q" (__a) \ : "0" (__a) \ @@ -46,437 +46,437 @@ void copybufreverse(void *S, void *D, long c); #endif #define scale(a,d,c) \ - ({ long __a=(a), __d=(d), __c=(c); \ + ({ int __a=(a), __d=(d), __c=(c); \ __asm__ __volatile__ ("imull %%edx; idivl %%ecx" \ : "=a" (__a), "=d" (__d) \ : "0" (__a), "1" (__d), "c" (__c) : "cc"); \ __a; }) #define mulscale(a,d,c) \ - ({ long __a=(a), __d=(d), __c=(c); \ + ({ int __a=(a), __d=(d), __c=(c); \ __asm__ __volatile__ ("imull %%edx; shrdl %%cl, %%edx, %%eax" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d), "c" (__c) : "cc"); \ __a; }) #define mulscale1(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx; shrdl $1, %%edx, %%eax" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d) : "cc"); \ __a; }) #define mulscale2(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx; shrdl $2, %%edx, %%eax" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d) : "cc"); \ __a; }) #define mulscale3(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx; shrdl $3, %%edx, %%eax" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d) : "cc"); \ __a; }) #define mulscale4(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx; shrdl $4, %%edx, %%eax" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d) : "cc"); \ __a; }) #define mulscale5(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx; shrdl $5, %%edx, %%eax" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d) : "cc"); \ __a; }) #define mulscale6(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx; shrdl $6, %%edx, %%eax" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d) : "cc"); \ __a; }) #define mulscale7(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx; shrdl $7, %%edx, %%eax" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d) : "cc"); \ __a; }) #define mulscale8(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx; shrdl $8, %%edx, %%eax" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d) : "cc"); \ __a; }) #define mulscale9(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx; shrdl $9, %%edx, %%eax" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d) : "cc"); \ __a; }) #define mulscale10(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx; shrdl $10, %%edx, %%eax" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d) : "cc"); \ __a; }) #define mulscale11(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx; shrdl $11, %%edx, %%eax" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d) : "cc"); \ __a; }) #define mulscale12(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx; shrdl $12, %%edx, %%eax" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d) : "cc"); \ __a; }) #define mulscale13(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx; shrdl $13, %%edx, %%eax" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d) : "cc"); \ __a; }) #define mulscale14(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx; shrdl $14, %%edx, %%eax" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d) : "cc"); \ __a; }) #define mulscale15(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx; shrdl $15, %%edx, %%eax" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d) : "cc"); \ __a; }) #define mulscale16(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx; shrdl $16, %%edx, %%eax" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d) : "cc"); \ __a; }) #define mulscale17(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx; shrdl $17, %%edx, %%eax" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d) : "cc"); \ __a; }) #define mulscale18(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx; shrdl $18, %%edx, %%eax" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d) : "cc"); \ __a; }) #define mulscale19(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx; shrdl $19, %%edx, %%eax" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d) : "cc"); \ __a; }) #define mulscale20(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx; shrdl $20, %%edx, %%eax" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d) : "cc"); \ __a; }) #define mulscale21(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx; shrdl $21, %%edx, %%eax" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d) : "cc"); \ __a; }) #define mulscale22(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx; shrdl $22, %%edx, %%eax" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d) : "cc"); \ __a; }) #define mulscale23(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx; shrdl $23, %%edx, %%eax" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d) : "cc"); \ __a; }) #define mulscale24(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx; shrdl $24, %%edx, %%eax" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d) : "cc"); \ __a; }) #define mulscale25(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx; shrdl $25, %%edx, %%eax" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d) : "cc"); \ __a; }) #define mulscale26(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx; shrdl $26, %%edx, %%eax" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d) : "cc"); \ __a; }) #define mulscale27(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx; shrdl $27, %%edx, %%eax" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d) : "cc"); \ __a; }) #define mulscale28(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx; shrdl $28, %%edx, %%eax" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d) : "cc"); \ __a; }) #define mulscale29(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx; shrdl $29, %%edx, %%eax" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d) : "cc"); \ __a; }) #define mulscale30(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx; shrdl $30, %%edx, %%eax" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d) : "cc"); \ __a; }) #define mulscale31(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx; shrdl $31, %%edx, %%eax" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d) : "cc"); \ __a; }) #define mulscale32(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx" \ : "=a" (__a), "=d" (__d) \ : "a" (__a), "d" (__d) : "cc"); \ __d; }) #define dmulscale(a,d,S,D,c) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D), __c=(c); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D), __c=(c); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl %%cl, %%edx, %%eax" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ : "a" (__a), "d" (__d), "S" (__S), "D" (__D), "c" (__c) : "ebx", "cc"); \ __a; }) #define dmulscale1(a,d,S,D) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $1, %%edx, %%eax" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ __a; }) #define dmulscale2(a,d,S,D) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $2, %%edx, %%eax" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ __a; }) #define dmulscale3(a,d,S,D) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $3, %%edx, %%eax" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ __a; }) #define dmulscale4(a,d,S,D) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $4, %%edx, %%eax" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ __a; }) #define dmulscale5(a,d,S,D) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $5, %%edx, %%eax" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ __a; }) #define dmulscale6(a,d,S,D) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $6, %%edx, %%eax" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ __a; }) #define dmulscale7(a,d,S,D) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $7, %%edx, %%eax" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ __a; }) #define dmulscale8(a,d,S,D) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $8, %%edx, %%eax" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ __a; }) #define dmulscale9(a,d,S,D) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $9, %%edx, %%eax" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ __a; }) #define dmulscale10(a,d,S,D) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $10, %%edx, %%eax" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ __a; }) #define dmulscale11(a,d,S,D) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $11, %%edx, %%eax" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ __a; }) #define dmulscale12(a,d,S,D) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $12, %%edx, %%eax" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ __a; }) #define dmulscale13(a,d,S,D) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $13, %%edx, %%eax" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ __a; }) #define dmulscale14(a,d,S,D) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $14, %%edx, %%eax" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ __a; }) #define dmulscale15(a,d,S,D) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $15, %%edx, %%eax" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ __a; }) #define dmulscale16(a,d,S,D) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $16, %%edx, %%eax" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ __a; }) #define dmulscale17(a,d,S,D) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $17, %%edx, %%eax" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ __a; }) #define dmulscale18(a,d,S,D) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $18, %%edx, %%eax" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ __a; }) #define dmulscale19(a,d,S,D) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $19, %%edx, %%eax" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ __a; }) #define dmulscale20(a,d,S,D) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $20, %%edx, %%eax" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ __a; }) #define dmulscale21(a,d,S,D) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $21, %%edx, %%eax" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ __a; }) #define dmulscale22(a,d,S,D) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $22, %%edx, %%eax" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ __a; }) #define dmulscale23(a,d,S,D) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $23, %%edx, %%eax" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ __a; }) #define dmulscale24(a,d,S,D) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $24, %%edx, %%eax" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ __a; }) #define dmulscale25(a,d,S,D) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $25, %%edx, %%eax" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ __a; }) #define dmulscale26(a,d,S,D) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $26, %%edx, %%eax" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ __a; }) #define dmulscale27(a,d,S,D) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $27, %%edx, %%eax" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ __a; }) #define dmulscale28(a,d,S,D) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $28, %%edx, %%eax" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ __a; }) #define dmulscale29(a,d,S,D) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $29, %%edx, %%eax" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ __a; }) #define dmulscale30(a,d,S,D) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $30, %%edx, %%eax" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ __a; }) #define dmulscale31(a,d,S,D) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $31, %%edx, %%eax" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ __a; }) #define dmulscale32(a,d,S,D) \ - ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx" \ : "=a" (__a), "=d" (__d), "=S" (__S) \ @@ -484,7 +484,7 @@ void copybufreverse(void *S, void *D, long c); __d; }) #define tmulscale1(a,d,b,c,S,D) \ - ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $1, %%edx, %%eax" \ @@ -492,7 +492,7 @@ void copybufreverse(void *S, void *D, long c); : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ __a; }) #define tmulscale2(a,d,b,c,S,D) \ - ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $2, %%edx, %%eax" \ @@ -500,7 +500,7 @@ void copybufreverse(void *S, void *D, long c); : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ __a; }) #define tmulscale3(a,d,b,c,S,D) \ - ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $3, %%edx, %%eax" \ @@ -508,7 +508,7 @@ void copybufreverse(void *S, void *D, long c); : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ __a; }) #define tmulscale4(a,d,b,c,S,D) \ - ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $4, %%edx, %%eax" \ @@ -516,7 +516,7 @@ void copybufreverse(void *S, void *D, long c); : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ __a; }) #define tmulscale5(a,d,b,c,S,D) \ - ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $5, %%edx, %%eax" \ @@ -524,7 +524,7 @@ void copybufreverse(void *S, void *D, long c); : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ __a; }) #define tmulscale6(a,d,b,c,S,D) \ - ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $6, %%edx, %%eax" \ @@ -532,7 +532,7 @@ void copybufreverse(void *S, void *D, long c); : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ __a; }) #define tmulscale7(a,d,b,c,S,D) \ - ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $7, %%edx, %%eax" \ @@ -540,7 +540,7 @@ void copybufreverse(void *S, void *D, long c); : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ __a; }) #define tmulscale8(a,d,b,c,S,D) \ - ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $8, %%edx, %%eax" \ @@ -548,7 +548,7 @@ void copybufreverse(void *S, void *D, long c); : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ __a; }) #define tmulscale9(a,d,b,c,S,D) \ - ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $9, %%edx, %%eax" \ @@ -556,7 +556,7 @@ void copybufreverse(void *S, void *D, long c); : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ __a; }) #define tmulscale10(a,d,b,c,S,D) \ - ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $10, %%edx, %%eax" \ @@ -564,7 +564,7 @@ void copybufreverse(void *S, void *D, long c); : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ __a; }) #define tmulscale11(a,d,b,c,S,D) \ - ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $11, %%edx, %%eax" \ @@ -572,7 +572,7 @@ void copybufreverse(void *S, void *D, long c); : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ __a; }) #define tmulscale12(a,d,b,c,S,D) \ - ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $12, %%edx, %%eax" \ @@ -580,7 +580,7 @@ void copybufreverse(void *S, void *D, long c); : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ __a; }) #define tmulscale13(a,d,b,c,S,D) \ - ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $13, %%edx, %%eax" \ @@ -588,7 +588,7 @@ void copybufreverse(void *S, void *D, long c); : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ __a; }) #define tmulscale14(a,d,b,c,S,D) \ - ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $14, %%edx, %%eax" \ @@ -596,7 +596,7 @@ void copybufreverse(void *S, void *D, long c); : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ __a; }) #define tmulscale15(a,d,b,c,S,D) \ - ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $15, %%edx, %%eax" \ @@ -604,7 +604,7 @@ void copybufreverse(void *S, void *D, long c); : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ __a; }) #define tmulscale16(a,d,b,c,S,D) \ - ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $16, %%edx, %%eax" \ @@ -612,7 +612,7 @@ void copybufreverse(void *S, void *D, long c); : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ __a; }) #define tmulscale17(a,d,b,c,S,D) \ - ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $17, %%edx, %%eax" \ @@ -620,7 +620,7 @@ void copybufreverse(void *S, void *D, long c); : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ __a; }) #define tmulscale18(a,d,b,c,S,D) \ - ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $18, %%edx, %%eax" \ @@ -628,7 +628,7 @@ void copybufreverse(void *S, void *D, long c); : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ __a; }) #define tmulscale19(a,d,b,c,S,D) \ - ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $19, %%edx, %%eax" \ @@ -636,7 +636,7 @@ void copybufreverse(void *S, void *D, long c); : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ __a; }) #define tmulscale20(a,d,b,c,S,D) \ - ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $20, %%edx, %%eax" \ @@ -644,7 +644,7 @@ void copybufreverse(void *S, void *D, long c); : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ __a; }) #define tmulscale21(a,d,b,c,S,D) \ - ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $21, %%edx, %%eax" \ @@ -652,7 +652,7 @@ void copybufreverse(void *S, void *D, long c); : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ __a; }) #define tmulscale22(a,d,b,c,S,D) \ - ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $22, %%edx, %%eax" \ @@ -660,7 +660,7 @@ void copybufreverse(void *S, void *D, long c); : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ __a; }) #define tmulscale23(a,d,b,c,S,D) \ - ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $23, %%edx, %%eax" \ @@ -668,7 +668,7 @@ void copybufreverse(void *S, void *D, long c); : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ __a; }) #define tmulscale24(a,d,b,c,S,D) \ - ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $24, %%edx, %%eax" \ @@ -676,7 +676,7 @@ void copybufreverse(void *S, void *D, long c); : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ __a; }) #define tmulscale25(a,d,b,c,S,D) \ - ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $25, %%edx, %%eax" \ @@ -684,7 +684,7 @@ void copybufreverse(void *S, void *D, long c); : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ __a; }) #define tmulscale26(a,d,b,c,S,D) \ - ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $26, %%edx, %%eax" \ @@ -692,7 +692,7 @@ void copybufreverse(void *S, void *D, long c); : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ __a; }) #define tmulscale27(a,d,b,c,S,D) \ - ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $27, %%edx, %%eax" \ @@ -700,7 +700,7 @@ void copybufreverse(void *S, void *D, long c); : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ __a; }) #define tmulscale28(a,d,b,c,S,D) \ - ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $28, %%edx, %%eax" \ @@ -708,7 +708,7 @@ void copybufreverse(void *S, void *D, long c); : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ __a; }) #define tmulscale29(a,d,b,c,S,D) \ - ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $29, %%edx, %%eax" \ @@ -716,7 +716,7 @@ void copybufreverse(void *S, void *D, long c); : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ __a; }) #define tmulscale30(a,d,b,c,S,D) \ - ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $30, %%edx, %%eax" \ @@ -724,7 +724,7 @@ void copybufreverse(void *S, void *D, long c); : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ __a; }) #define tmulscale31(a,d,b,c,S,D) \ - ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $31, %%edx, %%eax" \ @@ -732,7 +732,7 @@ void copybufreverse(void *S, void *D, long c); : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ __a; }) #define tmulscale32(a,d,b,c,S,D) \ - ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + ({ int __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx" \ @@ -741,260 +741,260 @@ void copybufreverse(void *S, void *D, long c); __d; }) #define divscale(a,b,c) \ - ({ long __a=(a), __b=(b), __c=(c); \ + ({ int __a=(a), __b=(b), __c=(c); \ __asm__ __volatile__ ("movl %%eax, %%edx; shll %%cl, %%eax; negb %%cl; sarl %%cl, %%edx; idivl %%ebx" \ : "=a" (__a) : "a" (__a), "c" (__c), "b" (__b) : "edx", "cc"); \ __a; }) #define divscale1(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("addl %%eax, %%eax; sbbl %%edx, %%edx; idivl %%ebx" \ : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ __a; }) #define divscale2(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("movl %%eax, %%edx; sarl $30, %%edx; leal (,%%eax,4), %%eax; idivl %%ebx" \ : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ __a; }) #define divscale3(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("movl %%eax, %%edx; sarl $29, %%edx; leal (,%%eax,8), %%eax; idivl %%ebx" \ : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ __a; }) #define divscale4(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("movl %%eax, %%edx; sarl $28, %%edx; shll $4, %%eax; idivl %%ebx" \ : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ __a; }) #define divscale5(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("movl %%eax, %%edx; sarl $27, %%edx; shll $5, %%eax; idivl %%ebx" \ : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ __a; }) #define divscale6(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("movl %%eax, %%edx; sarl $26, %%edx; shll $6, %%eax; idivl %%ebx" \ : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ __a; }) #define divscale7(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("movl %%eax, %%edx; sarl $25, %%edx; shll $7, %%eax; idivl %%ebx" \ : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ __a; }) #define divscale8(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("movl %%eax, %%edx; sarl $24, %%edx; shll $8, %%eax; idivl %%ebx" \ : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ __a; }) #define divscale9(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("movl %%eax, %%edx; sarl $23, %%edx; shll $9, %%eax; idivl %%ebx" \ : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ __a; }) #define divscale10(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("movl %%eax, %%edx; sarl $22, %%edx; shll $10, %%eax; idivl %%ebx" \ : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ __a; }) #define divscale11(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("movl %%eax, %%edx; sarl $21, %%edx; shll $11, %%eax; idivl %%ebx" \ : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ __a; }) #define divscale12(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("movl %%eax, %%edx; sarl $20, %%edx; shll $12, %%eax; idivl %%ebx" \ : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ __a; }) #define divscale13(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("movl %%eax, %%edx; sarl $19, %%edx; shll $13, %%eax; idivl %%ebx" \ : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ __a; }) #define divscale14(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("movl %%eax, %%edx; sarl $18, %%edx; shll $14, %%eax; idivl %%ebx" \ : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ __a; }) #define divscale15(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("movl %%eax, %%edx; sarl $17, %%edx; shll $15, %%eax; idivl %%ebx" \ : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ __a; }) #define divscale16(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("movl %%eax, %%edx; sarl $16, %%edx; shll $16, %%eax; idivl %%ebx" \ : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ __a; }) #define divscale17(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("movl %%eax, %%edx; sarl $15, %%edx; shll $17, %%eax; idivl %%ebx" \ : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ __a; }) #define divscale18(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("movl %%eax, %%edx; sarl $14, %%edx; shll $18, %%eax; idivl %%ebx" \ : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ __a; }) #define divscale19(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("movl %%eax, %%edx; sarl $13, %%edx; shll $19, %%eax; idivl %%ebx" \ : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ __a; }) #define divscale20(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("movl %%eax, %%edx; sarl $12, %%edx; shll $20, %%eax; idivl %%ebx" \ : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ __a; }) #define divscale21(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("movl %%eax, %%edx; sarl $11, %%edx; shll $21, %%eax; idivl %%ebx" \ : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ __a; }) #define divscale22(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("movl %%eax, %%edx; sarl $10, %%edx; shll $22, %%eax; idivl %%ebx" \ : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ __a; }) #define divscale23(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("movl %%eax, %%edx; sarl $9, %%edx; shll $23, %%eax; idivl %%ebx" \ : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ __a; }) #define divscale24(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("movl %%eax, %%edx; sarl $8, %%edx; shll $24, %%eax; idivl %%ebx" \ : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ __a; }) #define divscale25(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("movl %%eax, %%edx; sarl $7, %%edx; shll $25, %%eax; idivl %%ebx" \ : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ __a; }) #define divscale26(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("movl %%eax, %%edx; sarl $6, %%edx; shll $26, %%eax; idivl %%ebx" \ : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ __a; }) #define divscale27(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("movl %%eax, %%edx; sarl $5, %%edx; shll $27, %%eax; idivl %%ebx" \ : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ __a; }) #define divscale28(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("movl %%eax, %%edx; sarl $4, %%edx; shll $28, %%eax; idivl %%ebx" \ : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ __a; }) #define divscale29(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("movl %%eax, %%edx; sarl $3, %%edx; shll $29, %%eax; idivl %%ebx" \ : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ __a; }) #define divscale30(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("movl %%eax, %%edx; sarl $2, %%edx; shll $30, %%eax; idivl %%ebx" \ : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ __a; }) #define divscale31(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("movl %%eax, %%edx; sarl $1, %%edx; shll $31, %%eax; idivl %%ebx" \ : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ __a; }) #define divscale32(d,b) \ - ({ long __d=(d), __b=(b), __r; \ + ({ int __d=(d), __b=(b), __r; \ __asm__ __volatile__ ("xorl %%eax, %%eax; idivl %%ebx" \ : "=a" (__r), "=d" (__d) : "d" (__d), "b" (__b) : "cc"); \ __r; }) #define readpixel(D) \ - ({ void *__D=(D); long __a; \ + ({ void *__D=(D); int __a; \ __asm__ __volatile__ ("movb (%%edi), %%al" \ : "=a" (__a): "D" (__D) : "cc"); \ __a; }) #define drawpixel(D,a) \ - ({ void *__D=(D); long __a=(a); \ + ({ void *__D=(D); int __a=(a); \ __asm__ __volatile__ ("movb %%al, (%%edi)" \ : : "D" (__D), "a" (__a) : "memory", "cc"); \ 0; }) #define drawpixels(D,a) \ - ({ void *__D=(D); long __a=(a); \ + ({ void *__D=(D); int __a=(a); \ __asm__ __volatile__ ("movw %%ax, (%%edi)" \ : : "D" (__D), "a" (__a) : "memory", "cc"); \ 0; }) #define drawpixelses(D,a) \ - ({ void *__D=(D); long __a=(a); \ + ({ void *__D=(D); int __a=(a); \ __asm__ __volatile__ ("movl %%eax, (%%edi)" \ : : "D" (__D), "a" (__a) : "memory", "cc"); \ 0; }) #define clearbuf(D,c,a) \ - ({ void *__D=(D); long __c=(c), __a=(a); \ + ({ void *__D=(D); int __c=(c), __a=(a); \ __asm__ __volatile__ ("rep; stosl" \ : "=&D" (__D), "=&c" (__c) : "0" (__D), "1" (__c), "a" (__a) : "memory", "cc"); \ 0; }) #define copybuf(S,D,c) \ - ({ void *__S=(S), *__D=(D); long __c=(c); \ + ({ void *__S=(S), *__D=(D); int __c=(c); \ __asm__ __volatile__ ("rep; movsl" \ : "=&S" (__S), "=&D" (__D), "=&c" (__c) : "0" (__S), "1" (__D), "2" (__c) : "memory", "cc"); \ 0; }) #define mul3(a) \ - ({ long __a=(a), __r; \ + ({ int __a=(a), __r; \ __asm__ __volatile__ ("lea (%1,%1,2), %0" \ : "=r" (__r) : "0" (__a) : "cc"); \ __r; }) #define mul5(a) \ - ({ long __a=(a), __r; \ + ({ int __a=(a), __r; \ __asm__ __volatile__ ("lea (%1,%1,4), %0" \ : "=r" (__r) : "0" (__a) : "cc"); \ __r; }) #define mul9(a) \ - ({ long __a=(a), __r; \ + ({ int __a=(a), __r; \ __asm__ __volatile__ ("lea (%1,%1,8), %0" \ : "=r" (__r) : "0" (__a) : "cc"); \ __r; }) //returns eax/ebx, dmval = eax%edx; #define divmod(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("xorl %%edx, %%edx; divl %%ebx; movl %%edx, "_DMVAL \ : "+a" (__a) : "b" (__b) : "edx", "memory", "cc"); \ __a; }) //returns eax%ebx, dmval = eax/edx; #define moddiv(a,b) \ - ({ long __a=(a), __b=(b), __d; \ + ({ int __a=(a), __b=(b), __d; \ __asm__ __volatile__ ("xorl %%edx, %%edx; divl %%ebx; movl %%eax, "_DMVAL \ : "=d" (__d) : "a" (__a), "b" (__b) : "eax", "memory", "cc"); \ __d; }) #define klabs(a) \ - ({ long __a=(a); \ + ({ int __a=(a); \ __asm__ __volatile__ ("testl %%eax, %%eax; jns 0f; negl %%eax; 0:" \ : "=a" (__a) : "a" (__a) : "cc"); \ __a; }) #define ksgn(b) \ - ({ long __b=(b), __r; \ + ({ int __b=(b), __r; \ __asm__ __volatile__ ("addl %%ebx, %%ebx; sbbl %%eax, %%eax; cmpl %%ebx, %%eax; adcb $0, %%al" \ : "=a" (__r) : "b" (__b) : "cc"); \ __r; }) #define umin(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("subl %%ebx, %%eax; sbbl %%ecx, %%ecx; andl %%ecx, %%eax; addl %%ebx, %%eax" \ : "=a" (__a) : "a" (__a), "b" (__b) : "ecx", "cc"); \ __a; }) #define umax(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("subl %%ebx, %%eax; sbbl %%ecx, %%ecx; xorl $0xffffffff, %%ecx; andl %%ecx, %%eax; addl %%ebx, %%eax" \ : "=a" (__a) : "a" (__a), "b" (__b) : "ecx", "cc"); \ __a; }) #define kmin(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("cmpl %%ebx, %%eax; jl 0f; movl %%ebx, %%eax; 0:" \ : "=a" (__a) : "a" (__a), "b" (__b) : "cc"); \ __a; }) #define kmax(a,b) \ - ({ long __a=(a), __b=(b); \ + ({ int __a=(a), __b=(b); \ __asm__ __volatile__ ("cmpl %%ebx, %%eax; jg 0f; movl %%ebx, %%eax; 0:" \ : "=a" (__a) : "a" (__a), "b" (__b) : "cc"); \ __a; }) @@ -1015,7 +1015,7 @@ void copybufreverse(void *S, void *D, long c); : : "a" (__a), "b" (__b) : "ecx", "edx", "memory", "cc"); \ 0; }) #define swapbuf4(a,b,c) \ - ({ void *__a=(a), *__b=(b); long __c=(c); \ + ({ void *__a=(a), *__b=(b); int __c=(c); \ __asm__ __volatile__ ("0: movl (%%eax), %%esi; movl (%%ebx), %%edi; movl %%esi, (%%ebx); " \ "movl %%edi, (%%eax); addl $4, %%eax; addl $4, %%ebx; decl %%ecx; jnz 0b" \ : : "a" (__a), "b" (__b), "c" (__c) : "esi", "edi", "memory", "cc"); \ @@ -1031,7 +1031,7 @@ void copybufreverse(void *S, void *D, long c); //swapchar2(ptr1,ptr2,xsiz); is the same as: //swapchar(ptr1,ptr2); swapchar(ptr1+1,ptr2+xsiz); #define swapchar2(a,b,S) \ - ({ void *__a=(a), *__b=(b); long __S=(S); \ + ({ void *__a=(a), *__b=(b); int __S=(S); \ __asm__ __volatile__ ("addl %%ebx, %%esi; movw (%%eax), %%cx; movb (%%ebx), %%dl; " \ "movb %%cl, (%%ebx); movb (%%esi), %%dh; movb %%ch, (%%esi); " \ "movw %%dx, (%%eax)" \ @@ -1040,7 +1040,7 @@ void copybufreverse(void *S, void *D, long c); #define qinterpolatedown16(a,c,d,S) \ - ({ void *__a=(void*)(a); long __c=(c), __d=(d), __S=(S); \ + ({ void *__a=(void*)(a); int __c=(c), __d=(d), __S=(S); \ __asm__ __volatile__ ("movl %%ecx, %%ebx; shrl $1, %%ecx; jz 1f; " \ "0: leal (%%edx,%%esi,), %%edi; sarl $16, %%edx; movl %%edx, (%%eax); " \ "leal (%%edi,%%esi,), %%edx; sarl $16, %%edi; movl %%edi, 4(%%eax); " \ @@ -1051,7 +1051,7 @@ void copybufreverse(void *S, void *D, long c); 0; }) #define qinterpolatedown16short(a,c,d,S) \ - ({ void *__a=(void*)(a); long __c=(c), __d=(d), __S=(S); \ + ({ void *__a=(void*)(a); int __c=(c), __d=(d), __S=(S); \ __asm__ __volatile__ ("testl %%ecx, %%ecx; jz 3f; testb $2, %%al; jz 0f; movl %%edx, %%ebx; " \ "sarl $16, %%ebx; movw %%bx, (%%eax); addl %%esi, %%edx; addl $2, %%eax; " \ "decl %%ecx; jz 3f; " \ @@ -1075,252 +1075,252 @@ void copybufreverse(void *S, void *D, long c); // //{{{ -long sqr(long); +int sqr(int); #pragma aux sqr =\ "imul eax, eax",\ parm nomemory [eax]\ modify exact [eax]\ value [eax] -long scale(long,long,long); +int scale(int,int,int); #pragma aux scale =\ "imul edx",\ "idiv ecx",\ parm nomemory [eax][edx][ecx]\ modify exact [eax edx] -long mulscale(long,long,long); +int mulscale(int,int,int); #pragma aux mulscale =\ "imul edx",\ "shrd eax, edx, cl",\ parm nomemory [eax][edx][ecx]\ modify exact [eax edx] -long mulscale1(long,long); +int mulscale1(int,int); #pragma aux mulscale1 =\ "imul edx",\ "shrd eax, edx, 1",\ parm nomemory [eax][edx]\ modify exact [eax edx] -long mulscale2(long,long); +int mulscale2(int,int); #pragma aux mulscale2 =\ "imul edx",\ "shrd eax, edx, 2",\ parm nomemory [eax][edx]\ modify exact [eax edx] -long mulscale3(long,long); +int mulscale3(int,int); #pragma aux mulscale3 =\ "imul edx",\ "shrd eax, edx, 3",\ parm nomemory [eax][edx]\ modify exact [eax edx] -long mulscale4(long,long); +int mulscale4(int,int); #pragma aux mulscale4 =\ "imul edx",\ "shrd eax, edx, 4",\ parm nomemory [eax][edx]\ modify exact [eax edx] -long mulscale5(long,long); +int mulscale5(int,int); #pragma aux mulscale5 =\ "imul edx",\ "shrd eax, edx, 5",\ parm nomemory [eax][edx]\ modify exact [eax edx] -long mulscale6(long,long); +int mulscale6(int,int); #pragma aux mulscale6 =\ "imul edx",\ "shrd eax, edx, 6",\ parm nomemory [eax][edx]\ modify exact [eax edx] -long mulscale7(long,long); +int mulscale7(int,int); #pragma aux mulscale7 =\ "imul edx",\ "shrd eax, edx, 7",\ parm nomemory [eax][edx]\ modify exact [eax edx] -long mulscale8(long,long); +int mulscale8(int,int); #pragma aux mulscale8 =\ "imul edx",\ "shrd eax, edx, 8",\ parm nomemory [eax][edx]\ modify exact [eax edx] -long mulscale9(long,long); +int mulscale9(int,int); #pragma aux mulscale9 =\ "imul edx",\ "shrd eax, edx, 9",\ parm nomemory [eax][edx]\ modify exact [eax edx] -long mulscale10(long,long); +int mulscale10(int,int); #pragma aux mulscale10 =\ "imul edx",\ "shrd eax, edx, 10",\ parm nomemory [eax][edx]\ modify exact [eax edx] -long mulscale11(long,long); +int mulscale11(int,int); #pragma aux mulscale11 =\ "imul edx",\ "shrd eax, edx, 11",\ parm nomemory [eax][edx]\ modify exact [eax edx] -long mulscale12(long,long); +int mulscale12(int,int); #pragma aux mulscale12 =\ "imul edx",\ "shrd eax, edx, 12",\ parm nomemory [eax][edx]\ modify exact [eax edx] -long mulscale13(long,long); +int mulscale13(int,int); #pragma aux mulscale13 =\ "imul edx",\ "shrd eax, edx, 13",\ parm nomemory [eax][edx]\ modify exact [eax edx] -long mulscale14(long,long); +int mulscale14(int,int); #pragma aux mulscale14 =\ "imul edx",\ "shrd eax, edx, 14",\ parm nomemory [eax][edx]\ modify exact [eax edx] -long mulscale15(long,long); +int mulscale15(int,int); #pragma aux mulscale15 =\ "imul edx",\ "shrd eax, edx, 15",\ parm nomemory [eax][edx]\ modify exact [eax edx] -long mulscale16(long,long); +int mulscale16(int,int); #pragma aux mulscale16 =\ "imul edx",\ "shrd eax, edx, 16",\ parm nomemory [eax][edx]\ modify exact [eax edx] -long mulscale17(long,long); +int mulscale17(int,int); #pragma aux mulscale17 =\ "imul edx",\ "shrd eax, edx, 17",\ parm nomemory [eax][edx]\ modify exact [eax edx] -long mulscale18(long,long); +int mulscale18(int,int); #pragma aux mulscale18 =\ "imul edx",\ "shrd eax, edx, 18",\ parm nomemory [eax][edx]\ modify exact [eax edx] -long mulscale19(long,long); +int mulscale19(int,int); #pragma aux mulscale19 =\ "imul edx",\ "shrd eax, edx, 19",\ parm nomemory [eax][edx]\ modify exact [eax edx] -long mulscale20(long,long); +int mulscale20(int,int); #pragma aux mulscale20 =\ "imul edx",\ "shrd eax, edx, 20",\ parm nomemory [eax][edx]\ modify exact [eax edx] -long mulscale21(long,long); +int mulscale21(int,int); #pragma aux mulscale21 =\ "imul edx",\ "shrd eax, edx, 21",\ parm nomemory [eax][edx]\ modify exact [eax edx] -long mulscale22(long,long); +int mulscale22(int,int); #pragma aux mulscale22 =\ "imul edx",\ "shrd eax, edx, 22",\ parm nomemory [eax][edx]\ modify exact [eax edx] -long mulscale23(long,long); +int mulscale23(int,int); #pragma aux mulscale23 =\ "imul edx",\ "shrd eax, edx, 23",\ parm nomemory [eax][edx]\ modify exact [eax edx] -long mulscale24(long,long); +int mulscale24(int,int); #pragma aux mulscale24 =\ "imul edx",\ "shrd eax, edx, 24",\ parm nomemory [eax][edx]\ modify exact [eax edx] -long mulscale25(long,long); +int mulscale25(int,int); #pragma aux mulscale25 =\ "imul edx",\ "shrd eax, edx, 25",\ parm nomemory [eax][edx]\ modify exact [eax edx] -long mulscale26(long,long); +int mulscale26(int,int); #pragma aux mulscale26 =\ "imul edx",\ "shrd eax, edx, 26",\ parm nomemory [eax][edx]\ modify exact [eax edx] -long mulscale27(long,long); +int mulscale27(int,int); #pragma aux mulscale27 =\ "imul edx",\ "shrd eax, edx, 27",\ parm nomemory [eax][edx]\ modify exact [eax edx] -long mulscale28(long,long); +int mulscale28(int,int); #pragma aux mulscale28 =\ "imul edx",\ "shrd eax, edx, 28",\ parm nomemory [eax][edx]\ modify exact [eax edx] -long mulscale29(long,long); +int mulscale29(int,int); #pragma aux mulscale29 =\ "imul edx",\ "shrd eax, edx, 29",\ parm nomemory [eax][edx]\ modify exact [eax edx] -long mulscale30(long,long); +int mulscale30(int,int); #pragma aux mulscale30 =\ "imul edx",\ "shrd eax, edx, 30",\ parm nomemory [eax][edx]\ modify exact [eax edx] -long mulscale31(long,long); +int mulscale31(int,int); #pragma aux mulscale31 =\ "imul edx",\ "shrd eax, edx, 31",\ parm nomemory [eax][edx]\ modify exact [eax edx] -long mulscale32(long,long); +int mulscale32(int,int); #pragma aux mulscale32 =\ "imul edx",\ parm nomemory [eax][edx]\ modify exact [eax edx]\ value [edx] -long dmulscale(long,long,long,long,long); +int dmulscale(int,int,int,int,int); #pragma aux dmulscale =\ "imul edx",\ "mov ebx, eax",\ @@ -1333,7 +1333,7 @@ long dmulscale(long,long,long,long,long); parm nomemory [eax][edx][esi][edi][ecx]\ modify exact [eax ebx edx esi] -long dmulscale1(long,long,long,long); +int dmulscale1(int,int,int,int); #pragma aux dmulscale1 =\ "imul edx",\ "mov ebx, eax",\ @@ -1346,7 +1346,7 @@ long dmulscale1(long,long,long,long); parm nomemory [eax][edx][esi][edi]\ modify exact [eax ebx edx esi] -long dmulscale2(long,long,long,long); +int dmulscale2(int,int,int,int); #pragma aux dmulscale2 =\ "imul edx",\ "mov ebx, eax",\ @@ -1359,7 +1359,7 @@ long dmulscale2(long,long,long,long); parm nomemory [eax][edx][esi][edi]\ modify exact [eax ebx edx esi] -long dmulscale3(long,long,long,long); +int dmulscale3(int,int,int,int); #pragma aux dmulscale3 =\ "imul edx",\ "mov ebx, eax",\ @@ -1372,7 +1372,7 @@ long dmulscale3(long,long,long,long); parm nomemory [eax][edx][esi][edi]\ modify exact [eax ebx edx esi] -long dmulscale4(long,long,long,long); +int dmulscale4(int,int,int,int); #pragma aux dmulscale4 =\ "imul edx",\ "mov ebx, eax",\ @@ -1385,7 +1385,7 @@ long dmulscale4(long,long,long,long); parm nomemory [eax][edx][esi][edi]\ modify exact [eax ebx edx esi] -long dmulscale5(long,long,long,long); +int dmulscale5(int,int,int,int); #pragma aux dmulscale5 =\ "imul edx",\ "mov ebx, eax",\ @@ -1398,7 +1398,7 @@ long dmulscale5(long,long,long,long); parm nomemory [eax][edx][esi][edi]\ modify exact [eax ebx edx esi] -long dmulscale6(long,long,long,long); +int dmulscale6(int,int,int,int); #pragma aux dmulscale6 =\ "imul edx",\ "mov ebx, eax",\ @@ -1411,7 +1411,7 @@ long dmulscale6(long,long,long,long); parm nomemory [eax][edx][esi][edi]\ modify exact [eax ebx edx esi] -long dmulscale7(long,long,long,long); +int dmulscale7(int,int,int,int); #pragma aux dmulscale7 =\ "imul edx",\ "mov ebx, eax",\ @@ -1424,7 +1424,7 @@ long dmulscale7(long,long,long,long); parm nomemory [eax][edx][esi][edi]\ modify exact [eax ebx edx esi] -long dmulscale8(long,long,long,long); +int dmulscale8(int,int,int,int); #pragma aux dmulscale8 =\ "imul edx",\ "mov ebx, eax",\ @@ -1437,7 +1437,7 @@ long dmulscale8(long,long,long,long); parm nomemory [eax][edx][esi][edi]\ modify exact [eax ebx edx esi] -long dmulscale9(long,long,long,long); +int dmulscale9(int,int,int,int); #pragma aux dmulscale9 =\ "imul edx",\ "mov ebx, eax",\ @@ -1450,7 +1450,7 @@ long dmulscale9(long,long,long,long); parm nomemory [eax][edx][esi][edi]\ modify exact [eax ebx edx esi] -long dmulscale10(long,long,long,long); +int dmulscale10(int,int,int,int); #pragma aux dmulscale10 =\ "imul edx",\ "mov ebx, eax",\ @@ -1463,7 +1463,7 @@ long dmulscale10(long,long,long,long); parm nomemory [eax][edx][esi][edi]\ modify exact [eax ebx edx esi] -long dmulscale11(long,long,long,long); +int dmulscale11(int,int,int,int); #pragma aux dmulscale11 =\ "imul edx",\ "mov ebx, eax",\ @@ -1476,7 +1476,7 @@ long dmulscale11(long,long,long,long); parm nomemory [eax][edx][esi][edi]\ modify exact [eax ebx edx esi] -long dmulscale12(long,long,long,long); +int dmulscale12(int,int,int,int); #pragma aux dmulscale12 =\ "imul edx",\ "mov ebx, eax",\ @@ -1489,7 +1489,7 @@ long dmulscale12(long,long,long,long); parm nomemory [eax][edx][esi][edi]\ modify exact [eax ebx edx esi] -long dmulscale13(long,long,long,long); +int dmulscale13(int,int,int,int); #pragma aux dmulscale13 =\ "imul edx",\ "mov ebx, eax",\ @@ -1502,7 +1502,7 @@ long dmulscale13(long,long,long,long); parm nomemory [eax][edx][esi][edi]\ modify exact [eax ebx edx esi] -long dmulscale14(long,long,long,long); +int dmulscale14(int,int,int,int); #pragma aux dmulscale14 =\ "imul edx",\ "mov ebx, eax",\ @@ -1515,7 +1515,7 @@ long dmulscale14(long,long,long,long); parm nomemory [eax][edx][esi][edi]\ modify exact [eax ebx edx esi] -long dmulscale15(long,long,long,long); +int dmulscale15(int,int,int,int); #pragma aux dmulscale15 =\ "imul edx",\ "mov ebx, eax",\ @@ -1528,7 +1528,7 @@ long dmulscale15(long,long,long,long); parm nomemory [eax][edx][esi][edi]\ modify exact [eax ebx edx esi] -long dmulscale16(long,long,long,long); +int dmulscale16(int,int,int,int); #pragma aux dmulscale16 =\ "imul edx",\ "mov ebx, eax",\ @@ -1541,7 +1541,7 @@ long dmulscale16(long,long,long,long); parm nomemory [eax][edx][esi][edi]\ modify exact [eax ebx edx esi] -long dmulscale17(long,long,long,long); +int dmulscale17(int,int,int,int); #pragma aux dmulscale17 =\ "imul edx",\ "mov ebx, eax",\ @@ -1554,7 +1554,7 @@ long dmulscale17(long,long,long,long); parm nomemory [eax][edx][esi][edi]\ modify exact [eax ebx edx esi] -long dmulscale18(long,long,long,long); +int dmulscale18(int,int,int,int); #pragma aux dmulscale18 =\ "imul edx",\ "mov ebx, eax",\ @@ -1567,7 +1567,7 @@ long dmulscale18(long,long,long,long); parm nomemory [eax][edx][esi][edi]\ modify exact [eax ebx edx esi] -long dmulscale19(long,long,long,long); +int dmulscale19(int,int,int,int); #pragma aux dmulscale19 =\ "imul edx",\ "mov ebx, eax",\ @@ -1580,7 +1580,7 @@ long dmulscale19(long,long,long,long); parm nomemory [eax][edx][esi][edi]\ modify exact [eax ebx edx esi] -long dmulscale20(long,long,long,long); +int dmulscale20(int,int,int,int); #pragma aux dmulscale20 =\ "imul edx",\ "mov ebx, eax",\ @@ -1593,7 +1593,7 @@ long dmulscale20(long,long,long,long); parm nomemory [eax][edx][esi][edi]\ modify exact [eax ebx edx esi] -long dmulscale21(long,long,long,long); +int dmulscale21(int,int,int,int); #pragma aux dmulscale21 =\ "imul edx",\ "mov ebx, eax",\ @@ -1606,7 +1606,7 @@ long dmulscale21(long,long,long,long); parm nomemory [eax][edx][esi][edi]\ modify exact [eax ebx edx esi] -long dmulscale22(long,long,long,long); +int dmulscale22(int,int,int,int); #pragma aux dmulscale22 =\ "imul edx",\ "mov ebx, eax",\ @@ -1619,7 +1619,7 @@ long dmulscale22(long,long,long,long); parm nomemory [eax][edx][esi][edi]\ modify exact [eax ebx edx esi] -long dmulscale23(long,long,long,long); +int dmulscale23(int,int,int,int); #pragma aux dmulscale23 =\ "imul edx",\ "mov ebx, eax",\ @@ -1632,7 +1632,7 @@ long dmulscale23(long,long,long,long); parm nomemory [eax][edx][esi][edi]\ modify exact [eax ebx edx esi] -long dmulscale24(long,long,long,long); +int dmulscale24(int,int,int,int); #pragma aux dmulscale24 =\ "imul edx",\ "mov ebx, eax",\ @@ -1645,7 +1645,7 @@ long dmulscale24(long,long,long,long); parm nomemory [eax][edx][esi][edi]\ modify exact [eax ebx edx esi] -long dmulscale25(long,long,long,long); +int dmulscale25(int,int,int,int); #pragma aux dmulscale25 =\ "imul edx",\ "mov ebx, eax",\ @@ -1658,7 +1658,7 @@ long dmulscale25(long,long,long,long); parm nomemory [eax][edx][esi][edi]\ modify exact [eax ebx edx esi] -long dmulscale26(long,long,long,long); +int dmulscale26(int,int,int,int); #pragma aux dmulscale26 =\ "imul edx",\ "mov ebx, eax",\ @@ -1671,7 +1671,7 @@ long dmulscale26(long,long,long,long); parm nomemory [eax][edx][esi][edi]\ modify exact [eax ebx edx esi] -long dmulscale27(long,long,long,long); +int dmulscale27(int,int,int,int); #pragma aux dmulscale27 =\ "imul edx",\ "mov ebx, eax",\ @@ -1684,7 +1684,7 @@ long dmulscale27(long,long,long,long); parm nomemory [eax][edx][esi][edi]\ modify exact [eax ebx edx esi] -long dmulscale28(long,long,long,long); +int dmulscale28(int,int,int,int); #pragma aux dmulscale28 =\ "imul edx",\ "mov ebx, eax",\ @@ -1697,7 +1697,7 @@ long dmulscale28(long,long,long,long); parm nomemory [eax][edx][esi][edi]\ modify exact [eax ebx edx esi] -long dmulscale29(long,long,long,long); +int dmulscale29(int,int,int,int); #pragma aux dmulscale29 =\ "imul edx",\ "mov ebx, eax",\ @@ -1710,7 +1710,7 @@ long dmulscale29(long,long,long,long); parm nomemory [eax][edx][esi][edi]\ modify exact [eax ebx edx esi] -long dmulscale30(long,long,long,long); +int dmulscale30(int,int,int,int); #pragma aux dmulscale30 =\ "imul edx",\ "mov ebx, eax",\ @@ -1723,7 +1723,7 @@ long dmulscale30(long,long,long,long); parm nomemory [eax][edx][esi][edi]\ modify exact [eax ebx edx esi] -long dmulscale31(long,long,long,long); +int dmulscale31(int,int,int,int); #pragma aux dmulscale31 =\ "imul edx",\ "mov ebx, eax",\ @@ -1736,7 +1736,7 @@ long dmulscale31(long,long,long,long); parm nomemory [eax][edx][esi][edi]\ modify exact [eax ebx edx esi] -long dmulscale32(long,long,long,long); +int dmulscale32(int,int,int,int); #pragma aux dmulscale32 =\ "imul edx",\ "mov ebx, eax",\ @@ -1749,7 +1749,7 @@ long dmulscale32(long,long,long,long); modify exact [eax ebx edx esi]\ value [edx] -long tmulscale1(long,long,long,long,long,long); +int tmulscale1(int,int,int,int,int,int); #pragma aux tmulscale1 =\ "imul edx",\ "xchg eax, ebx",\ @@ -1765,7 +1765,7 @@ long tmulscale1(long,long,long,long,long,long); parm nomemory [eax][edx][ebx][ecx][esi][edi]\ modify exact [eax ebx ecx edx] -long tmulscale2(long,long,long,long,long,long); +int tmulscale2(int,int,int,int,int,int); #pragma aux tmulscale2 =\ "imul edx",\ "xchg eax, ebx",\ @@ -1781,7 +1781,7 @@ long tmulscale2(long,long,long,long,long,long); parm nomemory [eax][edx][ebx][ecx][esi][edi]\ modify exact [eax ebx ecx edx] -long tmulscale3(long,long,long,long,long,long); +int tmulscale3(int,int,int,int,int,int); #pragma aux tmulscale3 =\ "imul edx",\ "xchg eax, ebx",\ @@ -1797,7 +1797,7 @@ long tmulscale3(long,long,long,long,long,long); parm nomemory [eax][edx][ebx][ecx][esi][edi]\ modify exact [eax ebx ecx edx] -long tmulscale4(long,long,long,long,long,long); +int tmulscale4(int,int,int,int,int,int); #pragma aux tmulscale4 =\ "imul edx",\ "xchg eax, ebx",\ @@ -1813,7 +1813,7 @@ long tmulscale4(long,long,long,long,long,long); parm nomemory [eax][edx][ebx][ecx][esi][edi]\ modify exact [eax ebx ecx edx] -long tmulscale5(long,long,long,long,long,long); +int tmulscale5(int,int,int,int,int,int); #pragma aux tmulscale5 =\ "imul edx",\ "xchg eax, ebx",\ @@ -1829,7 +1829,7 @@ long tmulscale5(long,long,long,long,long,long); parm nomemory [eax][edx][ebx][ecx][esi][edi]\ modify exact [eax ebx ecx edx] -long tmulscale6(long,long,long,long,long,long); +int tmulscale6(int,int,int,int,int,int); #pragma aux tmulscale6 =\ "imul edx",\ "xchg eax, ebx",\ @@ -1845,7 +1845,7 @@ long tmulscale6(long,long,long,long,long,long); parm nomemory [eax][edx][ebx][ecx][esi][edi]\ modify exact [eax ebx ecx edx] -long tmulscale7(long,long,long,long,long,long); +int tmulscale7(int,int,int,int,int,int); #pragma aux tmulscale7 =\ "imul edx",\ "xchg eax, ebx",\ @@ -1861,7 +1861,7 @@ long tmulscale7(long,long,long,long,long,long); parm nomemory [eax][edx][ebx][ecx][esi][edi]\ modify exact [eax ebx ecx edx] -long tmulscale8(long,long,long,long,long,long); +int tmulscale8(int,int,int,int,int,int); #pragma aux tmulscale8 =\ "imul edx",\ "xchg eax, ebx",\ @@ -1877,7 +1877,7 @@ long tmulscale8(long,long,long,long,long,long); parm nomemory [eax][edx][ebx][ecx][esi][edi]\ modify exact [eax ebx ecx edx] -long tmulscale9(long,long,long,long,long,long); +int tmulscale9(int,int,int,int,int,int); #pragma aux tmulscale9 =\ "imul edx",\ "xchg eax, ebx",\ @@ -1893,7 +1893,7 @@ long tmulscale9(long,long,long,long,long,long); parm nomemory [eax][edx][ebx][ecx][esi][edi]\ modify exact [eax ebx ecx edx] -long tmulscale10(long,long,long,long,long,long); +int tmulscale10(int,int,int,int,int,int); #pragma aux tmulscale10 =\ "imul edx",\ "xchg eax, ebx",\ @@ -1909,7 +1909,7 @@ long tmulscale10(long,long,long,long,long,long); parm nomemory [eax][edx][ebx][ecx][esi][edi]\ modify exact [eax ebx ecx edx] -long tmulscale11(long,long,long,long,long,long); +int tmulscale11(int,int,int,int,int,int); #pragma aux tmulscale11 =\ "imul edx",\ "xchg eax, ebx",\ @@ -1925,7 +1925,7 @@ long tmulscale11(long,long,long,long,long,long); parm nomemory [eax][edx][ebx][ecx][esi][edi]\ modify exact [eax ebx ecx edx] -long tmulscale12(long,long,long,long,long,long); +int tmulscale12(int,int,int,int,int,int); #pragma aux tmulscale12 =\ "imul edx",\ "xchg eax, ebx",\ @@ -1941,7 +1941,7 @@ long tmulscale12(long,long,long,long,long,long); parm nomemory [eax][edx][ebx][ecx][esi][edi]\ modify exact [eax ebx ecx edx] -long tmulscale13(long,long,long,long,long,long); +int tmulscale13(int,int,int,int,int,int); #pragma aux tmulscale13 =\ "imul edx",\ "xchg eax, ebx",\ @@ -1957,7 +1957,7 @@ long tmulscale13(long,long,long,long,long,long); parm nomemory [eax][edx][ebx][ecx][esi][edi]\ modify exact [eax ebx ecx edx] -long tmulscale14(long,long,long,long,long,long); +int tmulscale14(int,int,int,int,int,int); #pragma aux tmulscale14 =\ "imul edx",\ "xchg eax, ebx",\ @@ -1973,7 +1973,7 @@ long tmulscale14(long,long,long,long,long,long); parm nomemory [eax][edx][ebx][ecx][esi][edi]\ modify exact [eax ebx ecx edx] -long tmulscale15(long,long,long,long,long,long); +int tmulscale15(int,int,int,int,int,int); #pragma aux tmulscale15 =\ "imul edx",\ "xchg eax, ebx",\ @@ -1989,7 +1989,7 @@ long tmulscale15(long,long,long,long,long,long); parm nomemory [eax][edx][ebx][ecx][esi][edi]\ modify exact [eax ebx ecx edx] -long tmulscale16(long,long,long,long,long,long); +int tmulscale16(int,int,int,int,int,int); #pragma aux tmulscale16 =\ "imul edx",\ "xchg eax, ebx",\ @@ -2005,7 +2005,7 @@ long tmulscale16(long,long,long,long,long,long); parm nomemory [eax][edx][ebx][ecx][esi][edi]\ modify exact [eax ebx ecx edx] -long tmulscale17(long,long,long,long,long,long); +int tmulscale17(int,int,int,int,int,int); #pragma aux tmulscale17 =\ "imul edx",\ "xchg eax, ebx",\ @@ -2021,7 +2021,7 @@ long tmulscale17(long,long,long,long,long,long); parm nomemory [eax][edx][ebx][ecx][esi][edi]\ modify exact [eax ebx ecx edx] -long tmulscale18(long,long,long,long,long,long); +int tmulscale18(int,int,int,int,int,int); #pragma aux tmulscale18 =\ "imul edx",\ "xchg eax, ebx",\ @@ -2037,7 +2037,7 @@ long tmulscale18(long,long,long,long,long,long); parm nomemory [eax][edx][ebx][ecx][esi][edi]\ modify exact [eax ebx ecx edx] -long tmulscale19(long,long,long,long,long,long); +int tmulscale19(int,int,int,int,int,int); #pragma aux tmulscale19 =\ "imul edx",\ "xchg eax, ebx",\ @@ -2053,7 +2053,7 @@ long tmulscale19(long,long,long,long,long,long); parm nomemory [eax][edx][ebx][ecx][esi][edi]\ modify exact [eax ebx ecx edx] -long tmulscale20(long,long,long,long,long,long); +int tmulscale20(int,int,int,int,int,int); #pragma aux tmulscale20 =\ "imul edx",\ "xchg eax, ebx",\ @@ -2069,7 +2069,7 @@ long tmulscale20(long,long,long,long,long,long); parm nomemory [eax][edx][ebx][ecx][esi][edi]\ modify exact [eax ebx ecx edx] -long tmulscale21(long,long,long,long,long,long); +int tmulscale21(int,int,int,int,int,int); #pragma aux tmulscale21 =\ "imul edx",\ "xchg eax, ebx",\ @@ -2085,7 +2085,7 @@ long tmulscale21(long,long,long,long,long,long); parm nomemory [eax][edx][ebx][ecx][esi][edi]\ modify exact [eax ebx ecx edx] -long tmulscale22(long,long,long,long,long,long); +int tmulscale22(int,int,int,int,int,int); #pragma aux tmulscale22 =\ "imul edx",\ "xchg eax, ebx",\ @@ -2101,7 +2101,7 @@ long tmulscale22(long,long,long,long,long,long); parm nomemory [eax][edx][ebx][ecx][esi][edi]\ modify exact [eax ebx ecx edx] -long tmulscale23(long,long,long,long,long,long); +int tmulscale23(int,int,int,int,int,int); #pragma aux tmulscale23 =\ "imul edx",\ "xchg eax, ebx",\ @@ -2117,7 +2117,7 @@ long tmulscale23(long,long,long,long,long,long); parm nomemory [eax][edx][ebx][ecx][esi][edi]\ modify exact [eax ebx ecx edx] -long tmulscale24(long,long,long,long,long,long); +int tmulscale24(int,int,int,int,int,int); #pragma aux tmulscale24 =\ "imul edx",\ "xchg eax, ebx",\ @@ -2133,7 +2133,7 @@ long tmulscale24(long,long,long,long,long,long); parm nomemory [eax][edx][ebx][ecx][esi][edi]\ modify exact [eax ebx ecx edx] -long tmulscale25(long,long,long,long,long,long); +int tmulscale25(int,int,int,int,int,int); #pragma aux tmulscale25 =\ "imul edx",\ "xchg eax, ebx",\ @@ -2149,7 +2149,7 @@ long tmulscale25(long,long,long,long,long,long); parm nomemory [eax][edx][ebx][ecx][esi][edi]\ modify exact [eax ebx ecx edx] -long tmulscale26(long,long,long,long,long,long); +int tmulscale26(int,int,int,int,int,int); #pragma aux tmulscale26 =\ "imul edx",\ "xchg eax, ebx",\ @@ -2165,7 +2165,7 @@ long tmulscale26(long,long,long,long,long,long); parm nomemory [eax][edx][ebx][ecx][esi][edi]\ modify exact [eax ebx ecx edx] -long tmulscale27(long,long,long,long,long,long); +int tmulscale27(int,int,int,int,int,int); #pragma aux tmulscale27 =\ "imul edx",\ "xchg eax, ebx",\ @@ -2181,7 +2181,7 @@ long tmulscale27(long,long,long,long,long,long); parm nomemory [eax][edx][ebx][ecx][esi][edi]\ modify exact [eax ebx ecx edx] -long tmulscale28(long,long,long,long,long,long); +int tmulscale28(int,int,int,int,int,int); #pragma aux tmulscale28 =\ "imul edx",\ "xchg eax, ebx",\ @@ -2197,7 +2197,7 @@ long tmulscale28(long,long,long,long,long,long); parm nomemory [eax][edx][ebx][ecx][esi][edi]\ modify exact [eax ebx ecx edx] -long tmulscale29(long,long,long,long,long,long); +int tmulscale29(int,int,int,int,int,int); #pragma aux tmulscale29 =\ "imul edx",\ "xchg eax, ebx",\ @@ -2213,7 +2213,7 @@ long tmulscale29(long,long,long,long,long,long); parm nomemory [eax][edx][ebx][ecx][esi][edi]\ modify exact [eax ebx ecx edx] -long tmulscale30(long,long,long,long,long,long); +int tmulscale30(int,int,int,int,int,int); #pragma aux tmulscale30 =\ "imul edx",\ "xchg eax, ebx",\ @@ -2229,7 +2229,7 @@ long tmulscale30(long,long,long,long,long,long); parm nomemory [eax][edx][ebx][ecx][esi][edi]\ modify exact [eax ebx ecx edx] -long tmulscale31(long,long,long,long,long,long); +int tmulscale31(int,int,int,int,int,int); #pragma aux tmulscale31 =\ "imul edx",\ "xchg eax, ebx",\ @@ -2245,7 +2245,7 @@ long tmulscale31(long,long,long,long,long,long); parm nomemory [eax][edx][ebx][ecx][esi][edi]\ modify exact [eax ebx ecx edx] -long tmulscale32(long,long,long,long,long,long); +int tmulscale32(int,int,int,int,int,int); #pragma aux tmulscale32 =\ "imul edx",\ "xchg eax, ebx",\ @@ -2261,7 +2261,7 @@ long tmulscale32(long,long,long,long,long,long); modify exact [eax ebx ecx edx]\ value [edx] -long boundmulscale(long,long,long); +int boundmulscale(int,int,int); #pragma aux boundmulscale =\ "imul ebx",\ "mov ebx, edx",\ @@ -2281,7 +2281,7 @@ long boundmulscale(long,long,long); parm nomemory [eax][ebx][ecx]\ modify exact [eax ebx edx] -long divscale(long,long,long); +int divscale(int,int,int); #pragma aux divscale =\ "mov edx, eax",\ "shl eax, cl",\ @@ -2291,7 +2291,7 @@ long divscale(long,long,long); parm nomemory [eax][ebx][ecx]\ modify exact [eax ecx edx] -long divscale1(long,long); +int divscale1(int,int); #pragma aux divscale1 =\ "add eax, eax",\ "sbb edx, edx",\ @@ -2299,7 +2299,7 @@ long divscale1(long,long); parm nomemory [eax][ebx]\ modify exact [eax edx] -long divscale2(long,long); +int divscale2(int,int); #pragma aux divscale2 =\ "mov edx, eax",\ "sar edx, 30",\ @@ -2308,7 +2308,7 @@ long divscale2(long,long); parm nomemory [eax][ebx]\ modify exact [eax edx] -long divscale3(long,long); +int divscale3(int,int); #pragma aux divscale3 =\ "mov edx, eax",\ "sar edx, 29",\ @@ -2317,7 +2317,7 @@ long divscale3(long,long); parm nomemory [eax][ebx]\ modify exact [eax edx] -long divscale4(long,long); +int divscale4(int,int); #pragma aux divscale4 =\ "mov edx, eax",\ "sar edx, 28",\ @@ -2326,7 +2326,7 @@ long divscale4(long,long); parm nomemory [eax][ebx]\ modify exact [eax edx] -long divscale5(long,long); +int divscale5(int,int); #pragma aux divscale5 =\ "mov edx, eax",\ "sar edx, 27",\ @@ -2335,7 +2335,7 @@ long divscale5(long,long); parm nomemory [eax][ebx]\ modify exact [eax edx] -long divscale6(long,long); +int divscale6(int,int); #pragma aux divscale6 =\ "mov edx, eax",\ "sar edx, 26",\ @@ -2344,7 +2344,7 @@ long divscale6(long,long); parm nomemory [eax][ebx]\ modify exact [eax edx] -long divscale7(long,long); +int divscale7(int,int); #pragma aux divscale7 =\ "mov edx, eax",\ "sar edx, 25",\ @@ -2353,7 +2353,7 @@ long divscale7(long,long); parm nomemory [eax][ebx]\ modify exact [eax edx] -long divscale8(long,long); +int divscale8(int,int); #pragma aux divscale8 =\ "mov edx, eax",\ "sar edx, 24",\ @@ -2362,7 +2362,7 @@ long divscale8(long,long); parm nomemory [eax][ebx]\ modify exact [eax edx] -long divscale9(long,long); +int divscale9(int,int); #pragma aux divscale9 =\ "mov edx, eax",\ "sar edx, 23",\ @@ -2371,7 +2371,7 @@ long divscale9(long,long); parm nomemory [eax][ebx]\ modify exact [eax edx] -long divscale10(long,long); +int divscale10(int,int); #pragma aux divscale10 =\ "mov edx, eax",\ "sar edx, 22",\ @@ -2380,7 +2380,7 @@ long divscale10(long,long); parm nomemory [eax][ebx]\ modify exact [eax edx] -long divscale11(long,long); +int divscale11(int,int); #pragma aux divscale11 =\ "mov edx, eax",\ "sar edx, 21",\ @@ -2389,7 +2389,7 @@ long divscale11(long,long); parm nomemory [eax][ebx]\ modify exact [eax edx] -long divscale12(long,long); +int divscale12(int,int); #pragma aux divscale12 =\ "mov edx, eax",\ "sar edx, 20",\ @@ -2398,7 +2398,7 @@ long divscale12(long,long); parm nomemory [eax][ebx]\ modify exact [eax edx] -long divscale13(long,long); +int divscale13(int,int); #pragma aux divscale13 =\ "mov edx, eax",\ "sar edx, 19",\ @@ -2407,7 +2407,7 @@ long divscale13(long,long); parm nomemory [eax][ebx]\ modify exact [eax edx] -long divscale14(long,long); +int divscale14(int,int); #pragma aux divscale14 =\ "mov edx, eax",\ "sar edx, 18",\ @@ -2416,7 +2416,7 @@ long divscale14(long,long); parm nomemory [eax][ebx]\ modify exact [eax edx] -long divscale15(long,long); +int divscale15(int,int); #pragma aux divscale15 =\ "mov edx, eax",\ "sar edx, 17",\ @@ -2425,7 +2425,7 @@ long divscale15(long,long); parm nomemory [eax][ebx]\ modify exact [eax edx] -long divscale16(long,long); +int divscale16(int,int); #pragma aux divscale16 =\ "mov edx, eax",\ "sar edx, 16",\ @@ -2434,7 +2434,7 @@ long divscale16(long,long); parm nomemory [eax][ebx]\ modify exact [eax edx] -long divscale17(long,long); +int divscale17(int,int); #pragma aux divscale17 =\ "mov edx, eax",\ "sar edx, 15",\ @@ -2443,7 +2443,7 @@ long divscale17(long,long); parm nomemory [eax][ebx]\ modify exact [eax edx] -long divscale18(long,long); +int divscale18(int,int); #pragma aux divscale18 =\ "mov edx, eax",\ "sar edx, 14",\ @@ -2452,7 +2452,7 @@ long divscale18(long,long); parm nomemory [eax][ebx]\ modify exact [eax edx] -long divscale19(long,long); +int divscale19(int,int); #pragma aux divscale19 =\ "mov edx, eax",\ "sar edx, 13",\ @@ -2461,7 +2461,7 @@ long divscale19(long,long); parm nomemory [eax][ebx]\ modify exact [eax edx] -long divscale20(long,long); +int divscale20(int,int); #pragma aux divscale20 =\ "mov edx, eax",\ "sar edx, 12",\ @@ -2470,7 +2470,7 @@ long divscale20(long,long); parm nomemory [eax][ebx]\ modify exact [eax edx] -long divscale21(long,long); +int divscale21(int,int); #pragma aux divscale21 =\ "mov edx, eax",\ "sar edx, 11",\ @@ -2479,7 +2479,7 @@ long divscale21(long,long); parm nomemory [eax][ebx]\ modify exact [eax edx] -long divscale22(long,long); +int divscale22(int,int); #pragma aux divscale22 =\ "mov edx, eax",\ "sar edx, 10",\ @@ -2488,7 +2488,7 @@ long divscale22(long,long); parm nomemory [eax][ebx]\ modify exact [eax edx] -long divscale23(long,long); +int divscale23(int,int); #pragma aux divscale23 =\ "mov edx, eax",\ "sar edx, 9",\ @@ -2497,7 +2497,7 @@ long divscale23(long,long); parm nomemory [eax][ebx]\ modify exact [eax edx] -long divscale24(long,long); +int divscale24(int,int); #pragma aux divscale24 =\ "mov edx, eax",\ "sar edx, 8",\ @@ -2506,7 +2506,7 @@ long divscale24(long,long); parm nomemory [eax][ebx]\ modify exact [eax edx] -long divscale25(long,long); +int divscale25(int,int); #pragma aux divscale25 =\ "mov edx, eax",\ "sar edx, 7",\ @@ -2515,7 +2515,7 @@ long divscale25(long,long); parm nomemory [eax][ebx]\ modify exact [eax edx] -long divscale26(long,long); +int divscale26(int,int); #pragma aux divscale26 =\ "mov edx, eax",\ "sar edx, 6",\ @@ -2524,7 +2524,7 @@ long divscale26(long,long); parm nomemory [eax][ebx]\ modify exact [eax edx] -long divscale27(long,long); +int divscale27(int,int); #pragma aux divscale27 =\ "mov edx, eax",\ "sar edx, 5",\ @@ -2533,7 +2533,7 @@ long divscale27(long,long); parm nomemory [eax][ebx]\ modify exact [eax edx] -long divscale28(long,long); +int divscale28(int,int); #pragma aux divscale28 =\ "mov edx, eax",\ "sar edx, 4",\ @@ -2542,7 +2542,7 @@ long divscale28(long,long); parm nomemory [eax][ebx]\ modify exact [eax edx] -long divscale29(long,long); +int divscale29(int,int); #pragma aux divscale29 =\ "mov edx, eax",\ "sar edx, 3",\ @@ -2551,7 +2551,7 @@ long divscale29(long,long); parm nomemory [eax][ebx]\ modify exact [eax edx] -long divscale30(long,long); +int divscale30(int,int); #pragma aux divscale30 =\ "mov edx, eax",\ "sar edx, 2",\ @@ -2560,7 +2560,7 @@ long divscale30(long,long); parm nomemory [eax][ebx]\ modify exact [eax edx] -long divscale31(long,long); +int divscale31(int,int); #pragma aux divscale31 =\ "mov edx, eax",\ "sar edx, 1",\ @@ -2569,44 +2569,44 @@ long divscale31(long,long); parm nomemory [eax][ebx]\ modify exact [eax edx] -long divscale32(long,long); +int divscale32(int,int); #pragma aux divscale32 =\ "xor eax, eax",\ "idiv ebx",\ parm nomemory [edx][ebx]\ modify exact [eax edx] -long readpixel(void*); +int readpixel(void*); #pragma aux readpixel =\ "mov al, byte ptr [edi]",\ parm nomemory [edi]\ modify exact [eax] -long drawpixel(void*,long); +int drawpixel(void*,int); #pragma aux drawpixel =\ "mov byte ptr [edi], al",\ parm [edi][eax]\ modify exact -long drawpixels(void*,long); +int drawpixels(void*,int); #pragma aux drawpixels =\ "mov word ptr [edi], ax",\ parm [edi][eax]\ modify exact -long drawpixelses(void*,long); +int drawpixelses(void*,int); #pragma aux drawpixelses =\ "mov dword ptr [edi], eax",\ parm [edi][eax]\ modify exact -long clearbuf(void*,long,long); +int clearbuf(void*,int,int); #pragma aux clearbuf =\ "rep stosd",\ parm [edi][ecx][eax]\ modify exact [edi ecx] -long clearbufbyte(void*,long,long); +int clearbufbyte(void*,int,int); #pragma aux clearbufbyte =\ "cmp ecx, 4",\ "jae longcopy",\ @@ -2637,13 +2637,13 @@ long clearbufbyte(void*,long,long); parm [edi][ecx][eax]\ modify [ebx] -long copybuf(void*,void*,long); +int copybuf(void*,void*,int); #pragma aux copybuf =\ "rep movsd",\ parm [esi][edi][ecx]\ modify exact [ecx esi edi] -long copybufbyte(void*,void*,long); +int copybufbyte(void*,void*,int); #pragma aux copybufbyte =\ "cmp ecx, 4",\ "jae longcopy",\ @@ -2674,7 +2674,7 @@ long copybufbyte(void*,void*,long); parm [esi][edi][ecx]\ modify [ebx] -long copybufreverse(void*,void*,long); +int copybufreverse(void*,void*,int); #pragma aux copybufreverse =\ "shr ecx, 1",\ "jnc skipit1",\ @@ -2701,7 +2701,7 @@ long copybufreverse(void*,void*,long); "endloop:",\ parm [esi][edi][ecx] -long qinterpolatedown16(long,long,long,long); +int qinterpolatedown16(int,int,int,int); #pragma aux qinterpolatedown16 =\ "mov ebx, ecx",\ "shr ecx, 1",\ @@ -2723,7 +2723,7 @@ long qinterpolatedown16(long,long,long,long); parm [eax][ecx][edx][esi]\ modify exact [eax ebx ecx edx edi] -long qinterpolatedown16short(long,long,long,long); +int qinterpolatedown16short(int,int,int,int); #pragma aux qinterpolatedown16short =\ "test ecx, ecx",\ "jz endit",\ @@ -2758,23 +2758,23 @@ long qinterpolatedown16short(long,long,long,long); parm [eax][ecx][edx][esi]\ modify exact [eax ebx ecx edx edi] -long mul3(long); +int mul3(int); #pragma aux mul3 =\ "lea eax, [eax+eax*2]",\ parm nomemory [eax] -long mul5(long); +int mul5(int); #pragma aux mul5 =\ "lea eax, [eax+eax*4]",\ parm nomemory [eax] -long mul9(long); +int mul9(int); #pragma aux mul9 =\ "lea eax, [eax+eax*8]",\ parm nomemory [eax] //returns eax/ebx, dmval = eax%edx; -long divmod(long,long); +int divmod(int,int); #pragma aux divmod =\ "xor edx, edx",\ "div ebx",\ @@ -2784,7 +2784,7 @@ long divmod(long,long); value [eax] //returns eax%ebx, dmval = eax/edx; -long moddiv(long,long); +int moddiv(int,int); #pragma aux moddiv =\ "xor edx, edx",\ "div ebx",\ @@ -2793,7 +2793,7 @@ long moddiv(long,long); modify exact [eax edx]\ value [edx] -long klabs(long); +int klabs(int); #pragma aux klabs =\ "test eax, eax",\ "jns skipnegate",\ @@ -2801,7 +2801,7 @@ long klabs(long); "skipnegate:",\ parm nomemory [eax] -long ksgn(long); +int ksgn(int); #pragma aux ksgn =\ "add ebx, ebx",\ "sbb eax, eax",\ @@ -2811,7 +2811,7 @@ long ksgn(long); modify exact [eax ebx] //eax = (unsigned min)umin(eax,ebx) -long umin(long,long); +int umin(int,int); #pragma aux umin =\ "sub eax, ebx",\ "sbb ecx, ecx",\ @@ -2821,7 +2821,7 @@ long umin(long,long); modify exact [eax ecx] //eax = (unsigned max)umax(eax,ebx) -long umax(long,long); +int umax(int,int); #pragma aux umax =\ "sub eax, ebx",\ "sbb ecx, ecx",\ @@ -2831,7 +2831,7 @@ long umax(long,long); parm nomemory [eax][ebx]\ modify exact [eax ecx] -long kmin(long,long); +int kmin(int,int); #pragma aux kmin =\ "cmp eax, ebx",\ "jl skipit",\ @@ -2840,7 +2840,7 @@ long kmin(long,long); parm nomemory [eax][ebx]\ modify exact [eax] -long kmax(long,long); +int kmax(int,int); #pragma aux kmax =\ "cmp eax, ebx",\ "jg skipit",\ @@ -2849,7 +2849,7 @@ long kmax(long,long); parm nomemory [eax][ebx]\ modify exact [eax] -long swapchar(void*,void*); +int swapchar(void*,void*); #pragma aux swapchar =\ "mov cl, [eax]",\ "mov ch, [ebx]",\ @@ -2858,7 +2858,7 @@ long swapchar(void*,void*); parm [eax][ebx]\ modify exact [ecx] -long swapshort(void*,void*); +int swapshort(void*,void*); #pragma aux swapshort =\ "mov cx, [eax]",\ "mov dx, [ebx]",\ @@ -2867,7 +2867,7 @@ long swapshort(void*,void*); parm [eax][ebx]\ modify exact [ecx edx] -long swaplong(void*,void*); +int swaplong(void*,void*); #pragma aux swaplong =\ "mov ecx, [eax]",\ "mov edx, [ebx]",\ @@ -2876,7 +2876,7 @@ long swaplong(void*,void*); parm [eax][ebx]\ modify exact [ecx edx] -long swapbuf4(void*,void*,long); +int swapbuf4(void*,void*,int); #pragma aux swapbuf4 =\ "begswap:",\ "mov esi, [eax]",\ @@ -2890,7 +2890,7 @@ long swapbuf4(void*,void*,long); parm [eax][ebx][ecx]\ modify exact [eax ebx ecx esi edi] -long swap64bit(void*,void*); +int swap64bit(void*,void*); #pragma aux swap64bit =\ "mov ecx, [eax]",\ "mov edx, [ebx]",\ @@ -2905,7 +2905,7 @@ long swap64bit(void*,void*); //swapchar2(ptr1,ptr2,xsiz); is the same as: //swapchar(ptr1,ptr2); swapchar(ptr1+1,ptr2+xsiz); -long swapchar2(void*,void*,long); +int swapchar2(void*,void*,int); #pragma aux swapchar2 =\ "add esi, ebx",\ "mov cx, [eax]",\ @@ -2925,7 +2925,7 @@ long swapchar2(void*,void*,long); // //{{{ -static __inline long sqr(long a) +static __inline int sqr(int a) { _asm { mov eax, a @@ -2933,7 +2933,7 @@ static __inline long sqr(long a) } } -static __inline long scale(long a, long d, long c) +static __inline int scale(int a, int d, int c) { _asm { mov eax, a @@ -2942,7 +2942,7 @@ static __inline long scale(long a, long d, long c) } } -static __inline long mulscale(long a, long d, long c) +static __inline int mulscale(int a, int d, int c) { _asm { mov ecx, c @@ -2953,7 +2953,7 @@ static __inline long mulscale(long a, long d, long c) } #define MULSCALE(x) \ -static __inline long mulscale##x (long a, long d) \ +static __inline int mulscale##x (int a, int d) \ { \ _asm mov eax, a \ _asm imul d \ @@ -2969,7 +2969,7 @@ MULSCALE(21) MULSCALE(22) MULSCALE(23) MULSCALE(24) MULSCALE(25) MULSCALE(26) MULSCALE(27) MULSCALE(28) MULSCALE(29) MULSCALE(30) MULSCALE(31) #undef MULSCALE -static __inline long mulscale32(long a, long d) +static __inline int mulscale32(int a, int d) { _asm { mov eax, a @@ -2978,7 +2978,7 @@ static __inline long mulscale32(long a, long d) } } -static __inline long dmulscale(long a, long d, long S, long D, long c) +static __inline int dmulscale(int a, int d, int S, int D, int c) { _asm { mov ecx, c @@ -2995,7 +2995,7 @@ static __inline long dmulscale(long a, long d, long S, long D, long c) } #define DMULSCALE(x) \ -static __inline long dmulscale##x (long a, long d, long S, long D) \ +static __inline int dmulscale##x (int a, int d, int S, int D) \ { \ _asm mov eax, a \ _asm imul d \ @@ -3017,7 +3017,7 @@ DMULSCALE(21) DMULSCALE(22) DMULSCALE(23) DMULSCALE(24) DMULSCALE(25) DMULSCALE(26) DMULSCALE(27) DMULSCALE(28) DMULSCALE(29) DMULSCALE(30) DMULSCALE(31) #undef DMULSCALE -static __inline long dmulscale32(long a, long d, long S, long D) +static __inline int dmulscale32(int a, int d, int S, int D) { _asm { mov eax, a @@ -3033,7 +3033,7 @@ static __inline long dmulscale32(long a, long d, long S, long D) } #define TMULSCALE(x) \ -static __inline long tmulscale##x (long a, long d, long b, long c, long S, long D) \ +static __inline int tmulscale##x (int a, int d, int b, int c, int S, int D) \ { \ _asm mov eax, a \ _asm mov ebx, b \ @@ -3060,7 +3060,7 @@ TMULSCALE(21) TMULSCALE(22) TMULSCALE(23) TMULSCALE(24) TMULSCALE(25) TMULSCALE(26) TMULSCALE(27) TMULSCALE(28) TMULSCALE(29) TMULSCALE(30) TMULSCALE(31) #undef TMULSCALE -static __inline long tmulscale32(long a, long d, long b, long c, long S, long D) +static __inline int tmulscale32(int a, int d, int b, int c, int S, int D) { _asm { mov eax, a @@ -3080,7 +3080,7 @@ static __inline long tmulscale32(long a, long d, long b, long c, long S, long D) } } -static __inline long boundmulscale(long a, long b, long c) +static __inline int boundmulscale(int a, int b, int c) { _asm { mov eax, a @@ -3103,7 +3103,7 @@ static __inline long boundmulscale(long a, long b, long c) } } -static __inline long divscale(long a, long b, long c) +static __inline int divscale(int a, int b, int c) { _asm { mov eax, a @@ -3116,7 +3116,7 @@ static __inline long divscale(long a, long b, long c) } } -static __inline long divscale1(long a, long b) +static __inline int divscale1(int a, int b) { _asm { mov eax, a @@ -3126,7 +3126,7 @@ static __inline long divscale1(long a, long b) } } -static __inline long divscale2(long a, long b) +static __inline int divscale2(int a, int b) { _asm { mov eax, a @@ -3137,7 +3137,7 @@ static __inline long divscale2(long a, long b) } } -static __inline long divscale3(long a, long b) +static __inline int divscale3(int a, int b) { _asm { mov eax, a @@ -3149,7 +3149,7 @@ static __inline long divscale3(long a, long b) } #define DIVSCALE(x,y) \ -static __inline long divscale##y(long a, long b) \ +static __inline int divscale##y(int a, int b) \ { \ _asm mov eax, a \ _asm mov edx, eax \ @@ -3166,7 +3166,7 @@ DIVSCALE(12,20) DIVSCALE(11,21) DIVSCALE(10,22) DIVSCALE(9,23) DIVSCALE(8,24) DIVSCALE(7,25) DIVSCALE(6,26) DIVSCALE(5,27) DIVSCALE(4,28) DIVSCALE(3,29) DIVSCALE(2,30) DIVSCALE(1,31) -static __inline long divscale32(long d, long b) +static __inline int divscale32(int d, int b) { _asm { mov edx, d @@ -3201,7 +3201,7 @@ static __inline void drawpixels(void *d, short a) } } -static __inline void drawpixelses(void *d, long a) +static __inline void drawpixelses(void *d, int a) { _asm { mov edx, d @@ -3210,7 +3210,7 @@ static __inline void drawpixelses(void *d, long a) } } -static __inline void clearbuf(void *d, long c, long a) +static __inline void clearbuf(void *d, int c, int a) { _asm { mov edi, d @@ -3220,7 +3220,7 @@ static __inline void clearbuf(void *d, long c, long a) } } -static __inline void clearbufbyte(void *d, long c, long a) +static __inline void clearbufbyte(void *d, int c, int a) { _asm { mov edi, d @@ -3260,7 +3260,7 @@ static __inline void clearbufbyte(void *d, long c, long a) } } -static __inline void copybuf(void *s, void *d, long c) +static __inline void copybuf(void *s, void *d, int c) { _asm { mov esi, s @@ -3270,7 +3270,7 @@ static __inline void copybuf(void *s, void *d, long c) } } -static __inline void copybufbyte(void *s, void *d, long c) +static __inline void copybufbyte(void *s, void *d, int c) { _asm { mov esi, s @@ -3310,7 +3310,7 @@ static __inline void copybufbyte(void *s, void *d, long c) } } -static __inline void copybufreverse(void *s, void *d, long c) +static __inline void copybufreverse(void *s, void *d, int c) { _asm { mov esi, s @@ -3345,7 +3345,7 @@ static __inline void copybufreverse(void *s, void *d, long c) } } -static __inline void qinterpolatedown16(long a, long c, long d, long s) +static __inline void qinterpolatedown16(int a, int c, int d, int s) { _asm { mov eax, a @@ -3374,7 +3374,7 @@ static __inline void qinterpolatedown16(long a, long c, long d, long s) } } -static __inline void qinterpolatedown16short(long a, long c, long d, long s) +static __inline void qinterpolatedown16short(int a, int c, int d, int s) { _asm { mov eax, a @@ -3417,7 +3417,7 @@ static __inline void qinterpolatedown16short(long a, long c, long d, long s) } } -static __inline long mul3(long a) +static __inline int mul3(int a) { _asm { mov eax, a @@ -3425,7 +3425,7 @@ static __inline long mul3(long a) } } -static __inline long mul5(long a) +static __inline int mul5(int a) { _asm { mov eax, a @@ -3433,7 +3433,7 @@ static __inline long mul5(long a) } } -static __inline long mul9(long a) +static __inline int mul9(int a) { _asm { mov eax, a @@ -3442,7 +3442,7 @@ static __inline long mul9(long a) } //returns eax/ebx, dmval = eax%edx; -static __inline long divmod(long a, long b) +static __inline int divmod(int a, int b) { _asm { mov eax, a @@ -3453,7 +3453,7 @@ static __inline long divmod(long a, long b) } //returns eax%ebx, dmval = eax/edx; -static __inline long moddiv(long a, long b) +static __inline int moddiv(int a, int b) { _asm { mov eax, a @@ -3464,7 +3464,7 @@ static __inline long moddiv(long a, long b) } } -static __inline long klabs(long a) +static __inline int klabs(int a) { _asm { mov eax, a @@ -3475,7 +3475,7 @@ static __inline long klabs(long a) } } -static __inline long ksgn(long b) +static __inline int ksgn(int b) { _asm { mov ebx, b @@ -3487,7 +3487,7 @@ static __inline long ksgn(long b) } //eax = (unsigned min)umin(eax,ebx) -static __inline long umin(long a, long b) +static __inline int umin(int a, int b) { _asm { mov eax, a @@ -3499,7 +3499,7 @@ static __inline long umin(long a, long b) } //eax = (unsigned max)umax(eax,ebx) -static __inline long umax(long a, long b) +static __inline int umax(int a, int b) { _asm { mov eax, a @@ -3511,7 +3511,7 @@ static __inline long umax(long a, long b) } } -static __inline long kmin(long a, long b) +static __inline int kmin(int a, int b) { _asm { mov eax, a @@ -3523,7 +3523,7 @@ static __inline long kmin(long a, long b) } } -static __inline long kmax(long a, long b) +static __inline int kmax(int a, int b) { _asm { mov eax, a @@ -3571,7 +3571,7 @@ static __inline void swaplong(void *a, void *b) } } -static __inline void swapbuf4(void *a, void *b, long c) +static __inline void swapbuf4(void *a, void *b, int c) { _asm { mov eax, a @@ -3607,7 +3607,7 @@ static __inline void swap64bit(void *a, void *b) //swapchar2(ptr1,ptr2,xsiz); is the same as: //swapchar(ptr1,ptr2); swapchar(ptr1+1,ptr2+xsiz); -static __inline void swapchar2(void *a, void *b, long s) +static __inline void swapchar2(void *a, void *b, int s) { _asm { mov eax, a @@ -3631,27 +3631,27 @@ static __inline void swapchar2(void *a, void *b, long s) // #define qw(x) ((int64)(x)) // quadword cast -#define dw(x) ((long)(x)) // doubleword cast +#define dw(x) ((int)(x)) // doubleword cast #define wo(x) ((short)(x)) // word cast #define by(x) ((char)(x)) // byte cast #define _scaler(a) \ -static inline long mulscale##a(long eax, long edx) \ +static inline int mulscale##a(int eax, int edx) \ { \ return dw((qw(eax) * qw(edx)) >> a); \ } \ \ -static inline long divscale##a(long eax, long ebx) \ +static inline int divscale##a(int eax, int ebx) \ { \ return dw((qw(eax) << a) / qw(ebx)); \ } \ \ -static inline long dmulscale##a(long eax, long edx, long esi, long edi) \ +static inline int dmulscale##a(int eax, int edx, int esi, int edi) \ { \ return dw(((qw(eax) * qw(edx)) + (qw(esi) * qw(edi))) >> a); \ } \ \ -static inline long tmulscale##a(long eax, long edx, long ebx, long ecx, long esi, long edi) \ +static inline int tmulscale##a(int eax, int edx, int ebx, int ecx, int esi, int edi) \ { \ return dw(((qw(eax) * qw(edx)) + (qw(ebx) * qw(ecx)) + (qw(esi) * qw(edi))) >> a); \ } \ @@ -3666,44 +3666,44 @@ _scaler(25) _scaler(26) _scaler(27) _scaler(28) _scaler(29) _scaler(30) _scaler(31) _scaler(32) static inline void swapchar(void* a, void* b) { char t = *((char*)b); *((char*)b) = *((char*)a); *((char*)a) = t; } -static inline void swapchar2(void* a, void* b, long s) { swapchar(a,b); swapchar((char*)a+1,(char*)b+s); } +static inline void swapchar2(void* a, void* b, int s) { swapchar(a,b); swapchar((char*)a+1,(char*)b+s); } static inline void swapshort(void* a, void* b) { short t = *((short*)b); *((short*)b) = *((short*)a); *((short*)a) = t; } -static inline void swaplong(void* a, void* b) { long t = *((long*)b); *((long*)b) = *((long*)a); *((long*)a) = t; } +static inline void swaplong(void* a, void* b) { int t = *((int*)b); *((int*)b) = *((int*)a); *((int*)a) = t; } static inline void swap64bit(void* a, void* b) { int64 t = *((int64*)b); *((int64*)b) = *((int64*)a); *((int64*)a) = t; } static inline char readpixel(void* s) { return (*((char*)(s))); } static inline void drawpixel(void* s, char a) { *((char*)(s)) = a; } static inline void drawpixels(void* s, short a) { *((short*)(s)) = a; } -static inline void drawpixelses(void* s, long a) { *((long*)(s)) = a; } +static inline void drawpixelses(void* s, int a) { *((int*)(s)) = a; } -static inline long mul3(long a) { return (a<<1)+a; } -static inline long mul5(long a) { return (a<<2)+a; } -static inline long mul9(long a) { return (a<<3)+a; } +static inline int mul3(int a) { return (a<<1)+a; } +static inline int mul5(int a) { return (a<<2)+a; } +static inline int mul9(int a) { return (a<<3)+a; } -static inline long divmod(long a, long b) { unsigned long _a=(unsigned long)a, _b=(unsigned long)b; dmval = _a%_b; return _a/_b; } -static inline long moddiv(long a, long b) { unsigned long _a=(unsigned long)a, _b=(unsigned long)b; dmval = _a/_b; return _a%_b; } +static inline int divmod(int a, int b) { unsigned int _a=(unsigned int)a, _b=(unsigned int)b; dmval = _a%_b; return _a/_b; } +static inline int moddiv(int a, int b) { unsigned int _a=(unsigned int)a, _b=(unsigned int)b; dmval = _a/_b; return _a%_b; } -static inline long klabs(long a) { if (a < 0) return -a; return a; } -static inline long ksgn(long a) { if (a > 0) return 1; if (a < 0) return -1; return 0; } +static inline int klabs(int a) { if (a < 0) return -a; return a; } +static inline int ksgn(int a) { if (a > 0) return 1; if (a < 0) return -1; return 0; } -static inline long umin(long a, long b) { if ((unsigned long)a < (unsigned long)b) return a; return b; } -static inline long umax(long a, long b) { if ((unsigned long)a < (unsigned long)b) return b; return a; } -static inline long kmin(long a, long b) { if ((signed long)a < (signed long)b) return a; return b; } -static inline long kmax(long a, long b) { if ((signed long)a < (signed long)b) return b; return a; } +static inline int umin(int a, int b) { if ((unsigned int)a < (unsigned int)b) return a; return b; } +static inline int umax(int a, int b) { if ((unsigned int)a < (unsigned int)b) return b; return a; } +static inline int kmin(int a, int b) { if ((signed int)a < (signed int)b) return a; return b; } +static inline int kmax(int a, int b) { if ((signed int)a < (signed int)b) return b; return a; } -static inline long sqr(long eax) { return (eax) * (eax); } -static inline long scale(long eax, long edx, long ecx) { return dw((qw(eax) * qw(edx)) / qw(ecx)); } -static inline long mulscale(long eax, long edx, long ecx) { return dw((qw(eax) * qw(edx)) >> by(ecx)); } -static inline long divscale(long eax, long ebx, long ecx) { return dw((qw(eax) << by(ecx)) / qw(ebx)); } -static inline long dmulscale(long eax, long edx, long esi, long edi, long ecx) { return dw(((qw(eax) * qw(edx)) + (qw(esi) * qw(edi))) >> by(ecx)); } +static inline int sqr(int eax) { return (eax) * (eax); } +static inline int scale(int eax, int edx, int ecx) { return dw((qw(eax) * qw(edx)) / qw(ecx)); } +static inline int mulscale(int eax, int edx, int ecx) { return dw((qw(eax) * qw(edx)) >> by(ecx)); } +static inline int divscale(int eax, int ebx, int ecx) { return dw((qw(eax) << by(ecx)) / qw(ebx)); } +static inline int dmulscale(int eax, int edx, int esi, int edi, int ecx) { return dw(((qw(eax) * qw(edx)) + (qw(esi) * qw(edi))) >> by(ecx)); } -static inline long boundmulscale(long a, long d, long c) +static inline int boundmulscale(int a, int d, int c) { // courtesy of Ken int64 p; p = (((int64)a)*((int64)d))>>c; if (p >= longlong(2147483647)) p = longlong(2147483647); if (p < longlong(-2147483648)) p = longlong(-2147483648); - return((long)p); + return((int)p); } #undef qw @@ -3712,16 +3712,16 @@ static inline long boundmulscale(long a, long d, long c) #undef by #undef _scaler -void qinterpolatedown16 (long bufptr, long num, long val, long add); -void qinterpolatedown16short (long bufptr, long num, long val, long add); +void qinterpolatedown16 (int bufptr, int num, int val, int add); +void qinterpolatedown16short (int bufptr, int num, int val, int add); -void clearbuf(void* d, long c, long a); -void copybuf(void* s, void* d, long c); -void swapbuf4(void* a, void* b, long c); +void clearbuf(void* d, int c, int a); +void copybuf(void* s, void* d, int c); +void swapbuf4(void* a, void* b, int c); -void clearbufbyte(void *D, long c, long a); -void copybufbyte(void *S, void *D, long c); -void copybufreverse(void *S, void *D, long c); +void clearbufbyte(void *D, int c, int a); +void copybufbyte(void *S, void *D, int c); +void copybufreverse(void *S, void *D, int c); #endif diff --git a/polymer/build/include/scriptfile.h b/polymer/build/include/scriptfile.h index 5027a1bc7..9c77aa8b1 100644 --- a/polymer/build/include/scriptfile.h +++ b/polymer/build/include/scriptfile.h @@ -6,7 +6,7 @@ typedef struct { char *eof; char *filename; int linenum; - long *lineoffs; + int *lineoffs; } scriptfile; char *scriptfile_gettoken(scriptfile *sf); diff --git a/polymer/build/include/tmp/buildsound.h b/polymer/build/include/tmp/buildsound.h index c85922bc4..bce038ac1 100644 --- a/polymer/build/include/tmp/buildsound.h +++ b/polymer/build/include/tmp/buildsound.h @@ -1,10 +1,10 @@ typedef struct { - unsigned long samplerate; // sample rate of the sound + unsigned int samplerate; // sample rate of the sound unsigned short channels; // number of channels unsigned short bitspersample; // bits per sample unsigned short format; // 0 = pcm - unsigned long soundlength; // bytes required for sound storage + unsigned int soundlength; // bytes required for sound storage } SoundInfo; diff --git a/polymer/build/include/tmp/pragmas-functions.h b/polymer/build/include/tmp/pragmas-functions.h index 185c60dfe..29fe8c60f 100644 --- a/polymer/build/include/tmp/pragmas-functions.h +++ b/polymer/build/include/tmp/pragmas-functions.h @@ -1,159 +1,159 @@ #ifdef USE_C_FUNCTION_PRAGMAS -long sqr(long a); -long scale(long a, long d, long c); -long mulscale(long a, long d, long c); -long mulscale1(long a, long d); -long mulscale2(long a, long d); -long mulscale3(long a, long d); -long mulscale4(long a, long d); -long mulscale5(long a, long d); -long mulscale6(long a, long d); -long mulscale7(long a, long d); -long mulscale8(long a, long d); -long mulscale9(long a, long d); -long mulscale10(long a, long d); -long mulscale11(long a, long d); -long mulscale12(long a, long d); -long mulscale13(long a, long d); -long mulscale14(long a, long d); -long mulscale15(long a, long d); -long mulscale16(long a, long d); -long mulscale17(long a, long d); -long mulscale18(long a, long d); -long mulscale19(long a, long d); -long mulscale20(long a, long d); -long mulscale21(long a, long d); -long mulscale22(long a, long d); -long mulscale23(long a, long d); -long mulscale24(long a, long d); -long mulscale25(long a, long d); -long mulscale26(long a, long d); -long mulscale27(long a, long d); -long mulscale28(long a, long d); -long mulscale29(long a, long d); -long mulscale30(long a, long d); -long mulscale31(long a, long d); -long mulscale32(long a, long d); -long dmulscale(long a, long d, long S, long D, long c); -long dmulscale1(long a, long d, long S, long D); -long dmulscale2(long a, long d, long S, long D); -long dmulscale3(long a, long d, long S, long D); -long dmulscale4(long a, long d, long S, long D); -long dmulscale5(long a, long d, long S, long D); -long dmulscale6(long a, long d, long S, long D); -long dmulscale7(long a, long d, long S, long D); -long dmulscale8(long a, long d, long S, long D); -long dmulscale9(long a, long d, long S, long D); -long dmulscale10(long a, long d, long S, long D); -long dmulscale11(long a, long d, long S, long D); -long dmulscale12(long a, long d, long S, long D); -long dmulscale13(long a, long d, long S, long D); -long dmulscale14(long a, long d, long S, long D); -long dmulscale15(long a, long d, long S, long D); -long dmulscale16(long a, long d, long S, long D); -long dmulscale17(long a, long d, long S, long D); -long dmulscale18(long a, long d, long S, long D); -long dmulscale19(long a, long d, long S, long D); -long dmulscale20(long a, long d, long S, long D); -long dmulscale21(long a, long d, long S, long D); -long dmulscale22(long a, long d, long S, long D); -long dmulscale23(long a, long d, long S, long D); -long dmulscale24(long a, long d, long S, long D); -long dmulscale25(long a, long d, long S, long D); -long dmulscale26(long a, long d, long S, long D); -long dmulscale27(long a, long d, long S, long D); -long dmulscale28(long a, long d, long S, long D); -long dmulscale29(long a, long d, long S, long D); -long dmulscale30(long a, long d, long S, long D); -long dmulscale31(long a, long d, long S, long D); -long dmulscale32(long a, long d, long S, long D); -long tmulscale1(long a, long d, long b, long c, long S, long D); -long tmulscale2(long a, long d, long b, long c, long S, long D); -long tmulscale3(long a, long d, long b, long c, long S, long D); -long tmulscale4(long a, long d, long b, long c, long S, long D); -long tmulscale5(long a, long d, long b, long c, long S, long D); -long tmulscale6(long a, long d, long b, long c, long S, long D); -long tmulscale7(long a, long d, long b, long c, long S, long D); -long tmulscale8(long a, long d, long b, long c, long S, long D); -long tmulscale9(long a, long d, long b, long c, long S, long D); -long tmulscale10(long a, long d, long b, long c, long S, long D); -long tmulscale11(long a, long d, long b, long c, long S, long D); -long tmulscale12(long a, long d, long b, long c, long S, long D); -long tmulscale13(long a, long d, long b, long c, long S, long D); -long tmulscale14(long a, long d, long b, long c, long S, long D); -long tmulscale15(long a, long d, long b, long c, long S, long D); -long tmulscale16(long a, long d, long b, long c, long S, long D); -long tmulscale17(long a, long d, long b, long c, long S, long D); -long tmulscale18(long a, long d, long b, long c, long S, long D); -long tmulscale19(long a, long d, long b, long c, long S, long D); -long tmulscale20(long a, long d, long b, long c, long S, long D); -long tmulscale21(long a, long d, long b, long c, long S, long D); -long tmulscale22(long a, long d, long b, long c, long S, long D); -long tmulscale23(long a, long d, long b, long c, long S, long D); -long tmulscale24(long a, long d, long b, long c, long S, long D); -long tmulscale25(long a, long d, long b, long c, long S, long D); -long tmulscale26(long a, long d, long b, long c, long S, long D); -long tmulscale27(long a, long d, long b, long c, long S, long D); -long tmulscale28(long a, long d, long b, long c, long S, long D); -long tmulscale29(long a, long d, long b, long c, long S, long D); -long tmulscale30(long a, long d, long b, long c, long S, long D); -long tmulscale31(long a, long d, long b, long c, long S, long D); -long tmulscale32(long a, long d, long b, long c, long S, long D); -long divscale(long a, long b, long c); -long divscale1(long a, long b); -long divscale2(long a, long b); -long divscale3(long a, long b); -long divscale4(long a, long b); -long divscale5(long a, long b); -long divscale6(long a, long b); -long divscale7(long a, long b); -long divscale8(long a, long b); -long divscale9(long a, long b); -long divscale10(long a, long b); -long divscale11(long a, long b); -long divscale12(long a, long b); -long divscale13(long a, long b); -long divscale14(long a, long b); -long divscale15(long a, long b); -long divscale16(long a, long b); -long divscale17(long a, long b); -long divscale18(long a, long b); -long divscale19(long a, long b); -long divscale20(long a, long b); -long divscale21(long a, long b); -long divscale22(long a, long b); -long divscale23(long a, long b); -long divscale24(long a, long b); -long divscale25(long a, long b); -long divscale26(long a, long b); -long divscale27(long a, long b); -long divscale28(long a, long b); -long divscale29(long a, long b); -long divscale30(long a, long b); -long divscale31(long a, long b); -long divscale32(long d, long b); -long readpixel(void *D); -void drawpixel(void *D, long a); -void drawpixels(void *D, long a); -void drawpixelses(void *D, long a); -void clearbuf(void* D, long c, long a); -void copybuf(void *S, void *D, long c); -long mul3(long a); -long mul5(long a); -long mul9(long a); -long divmod(long a, long b); -long moddiv(long a, long b); -long klabs(long a); -long ksgn(long b); -long umin(long a, long b); -long umax(long a, long b); -long kmin(long a, long b); -long kmax(long a, long b); +int sqr(int a); +int scale(int a, int d, int c); +int mulscale(int a, int d, int c); +int mulscale1(int a, int d); +int mulscale2(int a, int d); +int mulscale3(int a, int d); +int mulscale4(int a, int d); +int mulscale5(int a, int d); +int mulscale6(int a, int d); +int mulscale7(int a, int d); +int mulscale8(int a, int d); +int mulscale9(int a, int d); +int mulscale10(int a, int d); +int mulscale11(int a, int d); +int mulscale12(int a, int d); +int mulscale13(int a, int d); +int mulscale14(int a, int d); +int mulscale15(int a, int d); +int mulscale16(int a, int d); +int mulscale17(int a, int d); +int mulscale18(int a, int d); +int mulscale19(int a, int d); +int mulscale20(int a, int d); +int mulscale21(int a, int d); +int mulscale22(int a, int d); +int mulscale23(int a, int d); +int mulscale24(int a, int d); +int mulscale25(int a, int d); +int mulscale26(int a, int d); +int mulscale27(int a, int d); +int mulscale28(int a, int d); +int mulscale29(int a, int d); +int mulscale30(int a, int d); +int mulscale31(int a, int d); +int mulscale32(int a, int d); +int dmulscale(int a, int d, int S, int D, int c); +int dmulscale1(int a, int d, int S, int D); +int dmulscale2(int a, int d, int S, int D); +int dmulscale3(int a, int d, int S, int D); +int dmulscale4(int a, int d, int S, int D); +int dmulscale5(int a, int d, int S, int D); +int dmulscale6(int a, int d, int S, int D); +int dmulscale7(int a, int d, int S, int D); +int dmulscale8(int a, int d, int S, int D); +int dmulscale9(int a, int d, int S, int D); +int dmulscale10(int a, int d, int S, int D); +int dmulscale11(int a, int d, int S, int D); +int dmulscale12(int a, int d, int S, int D); +int dmulscale13(int a, int d, int S, int D); +int dmulscale14(int a, int d, int S, int D); +int dmulscale15(int a, int d, int S, int D); +int dmulscale16(int a, int d, int S, int D); +int dmulscale17(int a, int d, int S, int D); +int dmulscale18(int a, int d, int S, int D); +int dmulscale19(int a, int d, int S, int D); +int dmulscale20(int a, int d, int S, int D); +int dmulscale21(int a, int d, int S, int D); +int dmulscale22(int a, int d, int S, int D); +int dmulscale23(int a, int d, int S, int D); +int dmulscale24(int a, int d, int S, int D); +int dmulscale25(int a, int d, int S, int D); +int dmulscale26(int a, int d, int S, int D); +int dmulscale27(int a, int d, int S, int D); +int dmulscale28(int a, int d, int S, int D); +int dmulscale29(int a, int d, int S, int D); +int dmulscale30(int a, int d, int S, int D); +int dmulscale31(int a, int d, int S, int D); +int dmulscale32(int a, int d, int S, int D); +int tmulscale1(int a, int d, int b, int c, int S, int D); +int tmulscale2(int a, int d, int b, int c, int S, int D); +int tmulscale3(int a, int d, int b, int c, int S, int D); +int tmulscale4(int a, int d, int b, int c, int S, int D); +int tmulscale5(int a, int d, int b, int c, int S, int D); +int tmulscale6(int a, int d, int b, int c, int S, int D); +int tmulscale7(int a, int d, int b, int c, int S, int D); +int tmulscale8(int a, int d, int b, int c, int S, int D); +int tmulscale9(int a, int d, int b, int c, int S, int D); +int tmulscale10(int a, int d, int b, int c, int S, int D); +int tmulscale11(int a, int d, int b, int c, int S, int D); +int tmulscale12(int a, int d, int b, int c, int S, int D); +int tmulscale13(int a, int d, int b, int c, int S, int D); +int tmulscale14(int a, int d, int b, int c, int S, int D); +int tmulscale15(int a, int d, int b, int c, int S, int D); +int tmulscale16(int a, int d, int b, int c, int S, int D); +int tmulscale17(int a, int d, int b, int c, int S, int D); +int tmulscale18(int a, int d, int b, int c, int S, int D); +int tmulscale19(int a, int d, int b, int c, int S, int D); +int tmulscale20(int a, int d, int b, int c, int S, int D); +int tmulscale21(int a, int d, int b, int c, int S, int D); +int tmulscale22(int a, int d, int b, int c, int S, int D); +int tmulscale23(int a, int d, int b, int c, int S, int D); +int tmulscale24(int a, int d, int b, int c, int S, int D); +int tmulscale25(int a, int d, int b, int c, int S, int D); +int tmulscale26(int a, int d, int b, int c, int S, int D); +int tmulscale27(int a, int d, int b, int c, int S, int D); +int tmulscale28(int a, int d, int b, int c, int S, int D); +int tmulscale29(int a, int d, int b, int c, int S, int D); +int tmulscale30(int a, int d, int b, int c, int S, int D); +int tmulscale31(int a, int d, int b, int c, int S, int D); +int tmulscale32(int a, int d, int b, int c, int S, int D); +int divscale(int a, int b, int c); +int divscale1(int a, int b); +int divscale2(int a, int b); +int divscale3(int a, int b); +int divscale4(int a, int b); +int divscale5(int a, int b); +int divscale6(int a, int b); +int divscale7(int a, int b); +int divscale8(int a, int b); +int divscale9(int a, int b); +int divscale10(int a, int b); +int divscale11(int a, int b); +int divscale12(int a, int b); +int divscale13(int a, int b); +int divscale14(int a, int b); +int divscale15(int a, int b); +int divscale16(int a, int b); +int divscale17(int a, int b); +int divscale18(int a, int b); +int divscale19(int a, int b); +int divscale20(int a, int b); +int divscale21(int a, int b); +int divscale22(int a, int b); +int divscale23(int a, int b); +int divscale24(int a, int b); +int divscale25(int a, int b); +int divscale26(int a, int b); +int divscale27(int a, int b); +int divscale28(int a, int b); +int divscale29(int a, int b); +int divscale30(int a, int b); +int divscale31(int a, int b); +int divscale32(int d, int b); +int readpixel(void *D); +void drawpixel(void *D, int a); +void drawpixels(void *D, int a); +void drawpixelses(void *D, int a); +void clearbuf(void* D, int c, int a); +void copybuf(void *S, void *D, int c); +int mul3(int a); +int mul5(int a); +int mul9(int a); +int divmod(int a, int b); +int moddiv(int a, int b); +int klabs(int a); +int ksgn(int b); +int umin(int a, int b); +int umax(int a, int b); +int kmin(int a, int b); +int kmax(int a, int b); void swapchar(void *a, void *b); void swapshort(void *a, void *b); void swaplong(void *a, void *b); -void swapbuf4(void *a, void *b, long c); +void swapbuf4(void *a, void *b, int c); void swap64bit(void *a, void *b); -void swapchar2(void *a, void *b, long S); +void swapchar2(void *a, void *b, int S); #endif diff --git a/polymer/build/include/winlayer.h b/polymer/build/include/winlayer.h index a25bde625..ad5ae3b29 100644 --- a/polymer/build/include/winlayer.h +++ b/polymer/build/include/winlayer.h @@ -10,8 +10,8 @@ extern unsigned maxrefreshfreq; extern int glusecds; -long win_gethwnd(void); -long win_gethinstance(void); +int win_gethwnd(void); +int win_gethinstance(void); void win_allowtaskswitching(int onf); int win_checkinstance(void); diff --git a/polymer/build/src/a-c.c b/polymer/build/src/a-c.c index 8596a87c0..ad4576b2f 100644 --- a/polymer/build/src/a-c.c +++ b/polymer/build/src/a-c.c @@ -10,31 +10,31 @@ #ifdef ENGINE_USING_A_C -long krecip(long num); // from engine.c +int krecip(int num); // from engine.c #define BITSOFPRECISION 3 #define BITSOFPRECISIONPOW 8 -extern long asm1, asm2, asm3, asm4, fpuasm, globalx3, globaly3; +extern int asm1, asm2, asm3, asm4, fpuasm, globalx3, globaly3; extern void *reciptable; -static long bpl, transmode = 0; -static long glogx, glogy, gbxinc, gbyinc, gpinc; +static int bpl, transmode = 0; +static int glogx, glogy, gbxinc, gbyinc, gpinc; static char *gbuf, *gpal, *ghlinepal, *gtrans; //Global variable functions -void setvlinebpl(long dabpl) { bpl = dabpl; } -void fixtransluscence(long datransoff) { gtrans = (char *)datransoff; } +void setvlinebpl(int dabpl) { bpl = dabpl; } +void fixtransluscence(int datransoff) { gtrans = (char *)datransoff; } void settransnormal(void) { transmode = 0; } void settransreverse(void) { transmode = 1; } //Ceiling/floor horizontal line functions -void sethlinesizes(long logx, long logy, long bufplc) +void sethlinesizes(int logx, int logy, int bufplc) { glogx = logx; glogy = logy; gbuf = (char *)bufplc; } void setpalookupaddress(char *paladdr) { ghlinepal = paladdr; } -void setuphlineasm4(long bxinc, long byinc) { gbxinc = bxinc; gbyinc = byinc; } -void hlineasm4(long cnt, long skiploadincs, long paloffs, unsigned long by, unsigned long bx, long p) +void setuphlineasm4(int bxinc, int byinc) { gbxinc = bxinc; gbyinc = byinc; } +void hlineasm4(int cnt, int skiploadincs, int paloffs, unsigned int by, unsigned int bx, int p) { char *palptr; @@ -51,18 +51,18 @@ void hlineasm4(long cnt, long skiploadincs, long paloffs, unsigned long by, unsi //Sloped ceiling/floor vertical line functions -void setupslopevlin(long logylogx, long bufplc, long pinc) +void setupslopevlin(int logylogx, int bufplc, int pinc) { glogx = (logylogx&255); glogy = (logylogx>>8); gbuf = (char *)bufplc; gpinc = pinc; } -void slopevlin(long p, long i, long slopaloffs, long cnt, long bx, long by) +void slopevlin(int p, int i, int slopaloffs, int cnt, int bx, int by) { - long *slopalptr, bz, bzinc; - unsigned long u, v; + int *slopalptr, bz, bzinc; + unsigned int u, v; bz = asm3; bzinc = (asm1>>3); - slopalptr = (long *)slopaloffs; + slopalptr = (int *)slopaloffs; for (;cnt>0;cnt--) { i = krecip(bz>>6); bz += bzinc; @@ -76,8 +76,8 @@ void slopevlin(long p, long i, long slopaloffs, long cnt, long bx, long by) //Wall,face sprite/wall sprite vertical line functions -void setupvlineasm(long neglogy) { glogy = neglogy; } -void vlineasm1(long vinc, long paloffs, long cnt, unsigned long vplc, long bufplc, long p) +void setupvlineasm(int neglogy) { glogy = neglogy; } +void vlineasm1(int vinc, int paloffs, int cnt, unsigned int vplc, int bufplc, int p) { gbuf = (char *)bufplc; gpal = (char *)paloffs; @@ -89,8 +89,8 @@ void vlineasm1(long vinc, long paloffs, long cnt, unsigned long vplc, long bufpl } } -void setupmvlineasm(long neglogy) { glogy = neglogy; } -void mvlineasm1(long vinc, long paloffs, long cnt, unsigned long vplc, long bufplc, long p) +void setupmvlineasm(int neglogy) { glogy = neglogy; } +void mvlineasm1(int vinc, int paloffs, int cnt, unsigned int vplc, int bufplc, int p) { char ch; @@ -104,8 +104,8 @@ void mvlineasm1(long vinc, long paloffs, long cnt, unsigned long vplc, long bufp } } -void setuptvlineasm(long neglogy) { glogy = neglogy; } -void tvlineasm1(long vinc, long paloffs, long cnt, unsigned long vplc, long bufplc, long p) +void setuptvlineasm(int neglogy) { glogy = neglogy; } +void tvlineasm1(int vinc, int paloffs, int cnt, unsigned int vplc, int bufplc, int p) { char ch; @@ -134,8 +134,8 @@ void tvlineasm1(long vinc, long paloffs, long cnt, unsigned long vplc, long bufp } //Floor sprite horizontal line functions -void msethlineshift(long logx, long logy) { glogx = logx; glogy = logy; } -void mhline(long bufplc, unsigned long bx, long cntup16, long junk, unsigned long by, long p) +void msethlineshift(int logx, int logy) { glogx = logx; glogy = logy; } +void mhline(int bufplc, unsigned int bx, int cntup16, int junk, unsigned int by, int p) { char ch; @@ -151,8 +151,8 @@ void mhline(long bufplc, unsigned long bx, long cntup16, long junk, unsigned lon } } -void tsethlineshift(long logx, long logy) { glogx = logx; glogy = logy; } -void thline(long bufplc, unsigned long bx, long cntup16, long junk, unsigned long by, long p) +void tsethlineshift(int logx, int logy) { glogx = logx; glogy = logy; } +void thline(int bufplc, unsigned int bx, int cntup16, int junk, unsigned int by, int p) { char ch; @@ -184,14 +184,14 @@ void thline(long bufplc, unsigned long bx, long cntup16, long junk, unsigned lon //Rotatesprite vertical line functions -void setupspritevline(long paloffs, long bxinc, long byinc, long ysiz) +void setupspritevline(int paloffs, int bxinc, int byinc, int ysiz) { gpal = (char *)paloffs; gbxinc = bxinc; gbyinc = byinc; glogy = ysiz; } -void spritevline(long bx, long by, long cnt, long bufplc, long p) +void spritevline(int bx, int by, int cnt, int bufplc, int p) { gbuf = (char *)bufplc; for (;cnt>1;cnt--) @@ -204,14 +204,14 @@ void spritevline(long bx, long by, long cnt, long bufplc, long p) } //Rotatesprite vertical line functions -void msetupspritevline(long paloffs, long bxinc, long byinc, long ysiz) +void msetupspritevline(int paloffs, int bxinc, int byinc, int ysiz) { gpal = (char *)paloffs; gbxinc = bxinc; gbyinc = byinc; glogy = ysiz; } -void mspritevline(long bx, long by, long cnt, long bufplc, long p) +void mspritevline(int bx, int by, int cnt, int bufplc, int p) { char ch; @@ -219,21 +219,21 @@ void mspritevline(long bx, long by, long cnt, long bufplc, long p) for (;cnt>1;cnt--) { ch = gbuf[(bx>>16)*glogy+(by>>16)]; - if (ch != 255) (*(char *)p) = gpal[ch]; + if (ch != 255)(*(char *)p) = gpal[ch]; bx += gbxinc; by += gbyinc; p += bpl; } } -void tsetupspritevline(long paloffs, long bxinc, long byinc, long ysiz) +void tsetupspritevline(int paloffs, int bxinc, int byinc, int ysiz) { gpal = (char *)paloffs; gbxinc = bxinc; gbyinc = byinc; glogy = ysiz; } -void tspritevline(long bx, long by, long cnt, long bufplc, long p) +void tspritevline(int bx, int by, int cnt, int bufplc, int p) { char ch; @@ -262,28 +262,29 @@ void tspritevline(long bx, long by, long cnt, long bufplc, long p) } } -void setupdrawslab (long dabpl, long pal) +void setupdrawslab(int dabpl, int pal) { bpl = dabpl; gpal = (char *)pal; } -void drawslab (long dx, long v, long dy, long vi, long vptr, long p) +void drawslab(int dx, int v, int dy, int vi, int vptr, int p) { - long x; + int x; while (dy > 0) { - for (x=0;x>16)+vptr))]; + for (x=0;x>16)+vptr))]; p += bpl; v += vi; dy--; } } -void stretchhline (long p0, long u, long cnt, long uinc, long rptr, long p) +void stretchhline(int p0, int u, int cnt, int uinc, int rptr, int p) { p0 = p-(cnt<<2); do { p--; *(char *)p = *(char *)((u>>16)+rptr); u -= uinc; - } while (p > p0); + } + while (p > p0); } diff --git a/polymer/build/src/baselayer.c b/polymer/build/src/baselayer.c index cef10ece1..703b89a52 100644 --- a/polymer/build/src/baselayer.c +++ b/polymer/build/src/baselayer.c @@ -8,28 +8,29 @@ #endif #ifdef USE_OPENGL -struct glinfo glinfo = { - "Unknown", // vendor - "Unknown", // renderer - "0.0.0", // version - "", // extensions +struct glinfo glinfo = +{ + "Unknown", // vendor + "Unknown", // renderer + "0.0.0", // version + "", // extensions - 1.0, // max anisotropy - 0, // brga texture format - 0, // clamp-to-edge support - 0, // texture compression - 0, // non-power-of-two textures - 0, // multisampling - 0, // nvidia multisampling hint - 0, // ARBfp - 0, // depth textures - 0, // shadow comparison - 0, // Frame Buffer Objects - 0, // rectangle textures - 0, // multitexturing - 0, // env_combine - 0, // Vertex Buffer Objects - }; + 1.0, // max anisotropy + 0, // brga texture format + 0, // clamp-to-edge support + 0, // texture compression + 0, // non-power-of-two textures + 0, // multisampling + 0, // nvidia multisampling hint + 0, // ARBfp + 0, // depth textures + 0, // shadow comparison + 0, // Frame Buffer Objects + 0, // rectangle textures + 0, // multitexturing + 0, // env_combine + 0, // Vertex Buffer Objects +}; #endif static void onvideomodechange(int newmode) { } @@ -40,10 +41,11 @@ static int osdfunc_setrendermode(const osdfuncparm_t *parm) int m; char *p; - char *modestrs[] = { - "classic software", "polygonal flat-shaded software", - "polygonal textured software", "polygonal OpenGL", "great justice" - }; + char *modestrs[] = + { + "classic software", "polygonal flat-shaded software", + "polygonal textured software", "polygonal OpenGL", "great justice" + }; if (parm->numparms != 1) return OSDCMD_SHOWHELP; m = Bstrtol(parm->parms[0], &p, 10); @@ -51,7 +53,7 @@ static int osdfunc_setrendermode(const osdfuncparm_t *parm) if (m < 0 || m > 4) return OSDCMD_SHOWHELP; setrendermode(m); - OSD_Printf("Rendering method changed to %s\n", modestrs[ getrendermode() ] ); + OSD_Printf("Rendering method changed to %s\n", modestrs[ getrendermode()]); return OSDCMD_OK; } @@ -60,7 +62,7 @@ static int osdfunc_setrendermode(const osdfuncparm_t *parm) #ifdef DEBUGGINGAIDS static int osdcmd_hicsetpalettetint(const osdfuncparm_t *parm) { - long pal, cols[3], eff; + int pal, cols[3], eff; char *p; if (parm->numparms != 5) return OSDCMD_SHOWHELP; @@ -81,7 +83,8 @@ static int osdcmd_glinfo(const osdfuncparm_t *parm) { char *s,*t,*u,i; - if (bpp == 8) { + if (bpp == 8) + { OSD_Printf("glinfo: Not in OpenGL mode.\n"); return OSDCMD_OK; } @@ -128,11 +131,15 @@ static int osdcmd_glinfo(const osdfuncparm_t *parm) s = Bstrdup(glinfo.extensions); if (!s) OSD_Printf(glinfo.extensions); - else { + else + { i = 0; t = u = s; - while (*t) { - if (*t == ' ') { - if (i&1) { + while (*t) + { + if (*t == ' ') + { + if (i&1) + { *t = 0; OSD_Printf(" %s\n",u); u = t+1; @@ -153,24 +160,28 @@ static int osdcmd_vars(const osdfuncparm_t *parm) { int showval = (parm->numparms < 1); - if (!Bstrcasecmp(parm->name, "screencaptureformat")) { + if (!Bstrcasecmp(parm->name, "screencaptureformat")) + { const char *fmts[] = {"TGA", "PCX"}; if (showval) { OSD_Printf("captureformat is %s\n", fmts[captureformat]); } - else { + else + { int j; for (j=0; j<2; j++) - if (!Bstrcasecmp(parm->parms[0], fmts[j])) break; + if (!Bstrcasecmp(parm->parms[0], fmts[j])) break; if (j == 2) return OSDCMD_SHOWHELP; captureformat = j; } return OSDCMD_OK; } #ifdef SUPERBUILD - else if (!Bstrcasecmp(parm->name, "novoxmips")) { + else if (!Bstrcasecmp(parm->name, "novoxmips")) + { if (showval) { OSD_Printf("novoxmips is %d\n", novoxmips); } else { novoxmips = (atoi(parm->parms[0]) != 0); } } - else if (!Bstrcasecmp(parm->name, "usevoxels")) { + else if (!Bstrcasecmp(parm->name, "usevoxels")) + { if (showval) { OSD_Printf("usevoxels is %d\n", usevoxels); } else { usevoxels = (atoi(parm->parms[0]) != 0); } } diff --git a/polymer/build/src/build.c b/polymer/build/src/build.c index fe7a9a9a1..8c700a07f 100644 --- a/polymer/build/src/build.c +++ b/polymer/build/src/build.c @@ -23,7 +23,7 @@ #define TIMERINTSPERSECOND 120 #define updatecrc16(crc,dat) (crc = (((crc<<8)&65535)^crctable[((((unsigned short)crc)>>8)&65535)^dat])) -static long crctable[256]; +static int crctable[256]; static char kensig[32]; extern int ExtInit(void); @@ -54,40 +54,40 @@ char noclip=0; void _printmessage16(char name[82]); -long vel, svel, angvel; +int vel, svel, angvel; unsigned char buildkeys[NUMBUILDKEYS] = - { - 0xc8,0xd0,0xcb,0xcd,0x2a,0x9d,0x1d,0x39, - 0x1e,0x2c,0xd1,0xc9,0x33,0x34, - 0x9c,0x1c,0xd,0xc,0xf,0x29 - }; +{ + 0xc8,0xd0,0xcb,0xcd,0x2a,0x9d,0x1d,0x39, + 0x1e,0x2c,0xd1,0xc9,0x33,0x34, + 0x9c,0x1c,0xd,0xc,0xf,0x29 +}; -long posx, posy, posz, horiz = 100; -long mousexsurp = 0, mouseysurp = 0; +int posx, posy, posz, horiz = 100; +int mousexsurp = 0, mouseysurp = 0; short ang, cursectnum; -long hvel; +int hvel; -long grponlymode = 0; -extern long editorgridextent; // in engine.c +int grponlymode = 0; +extern int editorgridextent; // in engine.c extern double msens; -long synctics = 0, lockclock = 0; +int synctics = 0, lockclock = 0; extern char vgacompatible; extern char picsiz[MAXTILES]; -extern long startposx, startposy, startposz; +extern int startposx, startposy, startposz; extern short startang, startsectnum; -extern long frameplace, ydim16, halfxdim16, midydim16; -long xdim2d = 640, ydim2d = 480, xdimgame = 640, ydimgame = 480, bppgame = 8; -long forcesetup = 1; +extern int frameplace, ydim16, halfxdim16, midydim16; +int xdim2d = 640, ydim2d = 480, xdimgame = 640, ydimgame = 480, bppgame = 8; +int forcesetup = 1; -extern long cachesize, artsize; +extern int cachesize, artsize; static short oldmousebstatus = 0; short brightness = 0; -long zlock = 0x7fffffff, zmode = 0, whitecol, kensplayerheight = 32; +int zlock = 0x7fffffff, zmode = 0, whitecol, kensplayerheight = 32; short defaultspritecstat = 0; short localartfreq[MAXTILES]; @@ -99,17 +99,17 @@ char names[MAXTILES][25]; short asksave = 0; extern short editstatus, searchit; -extern long searchx, searchy; //search input +extern int searchx, searchy; //search input extern short searchsector, searchwall, searchstat; //search output -long osearchx, osearchy; //old search input +int osearchx, osearchy; //old search input extern short pointhighlight, linehighlight, highlightcnt; short grid = 3, gridlock = 1, showtags = 1; -long zoom = 768, gettilezoom = 1; -long lastpm16time; +int zoom = 768, gettilezoom = 1; +int lastpm16time; -long numsprites; -extern long mapversion; +int numsprites; +extern int mapversion; short highlight[MAXWALLS]; short highlightsector[MAXSECTORS], highlightsectorcnt = -1; @@ -129,77 +129,77 @@ static CACHE1D_FIND_REC *finddirs=NULL, *findfiles=NULL, *finddirshigh=NULL, *fi static int numdirs=0, numfiles=0; static int currentlist=0; -static long repeatcountx, repeatcounty; +static int repeatcountx, repeatcounty; -static long fillist[640]; +static int fillist[640]; -long mousx, mousy; +int mousx, mousy; static char scantoasc[128] = - { - 0,0,'1','2','3','4','5','6','7','8','9','0','-','=',0,0, - 'q','w','e','r','t','y','u','i','o','p','[',']',0,0,'a','s', - 'd','f','g','h','j','k','l',';',39,'`',0,92,'z','x','c','v', - 'b','n','m',',','.','/',0,'*',0,32,0,0,0,0,0,0, - 0,0,0,0,0,0,0,'7','8','9','-','4','5','6','+','1', - '2','3','0','.',0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - }; +{ + 0,0,'1','2','3','4','5','6','7','8','9','0','-','=',0,0, + 'q','w','e','r','t','y','u','i','o','p','[',']',0,0,'a','s', + 'd','f','g','h','j','k','l',';',39,'`',0,92,'z','x','c','v', + 'b','n','m',',','.','/',0,'*',0,32,0,0,0,0,0,0, + 0,0,0,0,0,0,0,'7','8','9','-','4','5','6','+','1', + '2','3','0','.',0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +}; static char scantoascwithshift[128] = - { - 0,0,'!','@','#','$','%','^','&','*','(',')','_','+',0,0, - 'Q','W','E','R','T','Y','U','I','O','P','{','}',0,0,'A','S', - 'D','F','G','H','J','K','L',':',34,'~',0,'|','Z','X','C','V', - 'B','N','M','<','>','?',0,'*',0,32,0,0,0,0,0,0, - 0,0,0,0,0,0,0,'7','8','9','-','4','5','6','+','1', - '2','3','0','.',0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - }; +{ + 0,0,'!','@','#','$','%','^','&','*','(',')','_','+',0,0, + 'Q','W','E','R','T','Y','U','I','O','P','{','}',0,0,'A','S', + 'D','F','G','H','J','K','L',':',34,'~',0,'|','Z','X','C','V', + 'B','N','M','<','>','?',0,'*',0,32,0,0,0,0,0,0, + 0,0,0,0,0,0,0,'7','8','9','-','4','5','6','+','1', + '2','3','0','.',0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +}; -char changechar(char dachar, long dadir, char smooshyalign, char boundcheck); -long adjustmark(long *xplc, long *yplc, short danumwalls); -long checkautoinsert(long dax, long day, short danumwalls); +char changechar(char dachar, int dadir, char smooshyalign, char boundcheck); +int adjustmark(int *xplc, int *yplc, short danumwalls); +int checkautoinsert(int dax, int day, short danumwalls); void keytimerstuff(void); -long clockdir(short wallstart); +int clockdir(short wallstart); void flipwalls(short numwalls, short newnumwalls); -void insertpoint(short linehighlight, long dax, long day); +void insertpoint(short linehighlight, int dax, int day); void deletepoint(short point); -long deletesector(short sucksect); -long checksectorpointer(short i, short sectnum); +int deletesector(short sucksect); +int checksectorpointer(short i, short sectnum); void fixrepeats(short i); -short loopinside(long x, long y, short startwall); -long fillsector(short sectnum, char fillcolor); +short loopinside(int x, int y, short startwall); +int fillsector(short sectnum, char fillcolor); short whitelinescan(short dalinehighlight); -void printcoords16(long posxe, long posye, short ange); +void printcoords16(int posxe, int posye, short ange); void copysector(short soursector, short destsector, short deststartwall, char copystat); void showsectordata(short sectnum); void showwalldata(short wallnum); void showspritedata(short spritenum); -long drawtilescreen(long pictopleft, long picbox); +int drawtilescreen(int pictopleft, int picbox); void overheadeditor(void); -long getlinehighlight(long xplc, long yplc); +int getlinehighlight(int xplc, int yplc); void fixspritesectors(void); -long movewalls(long start, long offs); -long loadnames(void); +int movewalls(int start, int offs); +int loadnames(void); void updatenumsprites(void); -void getclosestpointonwall(long x, long y, long dawall, long *nx, long *ny); +void getclosestpointonwall(int x, int y, int dawall, int *nx, int *ny); void initcrc(void); -void AutoAlignWalls(long nWall0, long ply); -long gettile(long tilenum); +void AutoAlignWalls(int nWall0, int ply); +int gettile(int tilenum); -long menuselect(void); -long getfilenames(char *path, char *kind); +int menuselect(void); +int getfilenames(char *path, char *kind); void clearfilenames(void); void clearkeys(void) { memset(keystatus,0,sizeof(keystatus)); } static int osdcmd_restartvid(const osdfuncparm_t *parm) { - extern long qsetmode; + extern int qsetmode; if (qsetmode != 200) return OSDCMD_OK; @@ -212,12 +212,13 @@ static int osdcmd_restartvid(const osdfuncparm_t *parm) static int osdcmd_vidmode(const osdfuncparm_t *parm) { - long newx = xdim, newy = ydim, newbpp = bpp, newfullscreen = fullscreen; - extern long qsetmode; + int newx = xdim, newy = ydim, newbpp = bpp, newfullscreen = fullscreen; + extern int qsetmode; if (qsetmode != 200) return OSDCMD_OK; - switch (parm->numparms) { + switch (parm->numparms) + { case 1: // bpp switch newbpp = Batol(parm->parms[0]); break; @@ -246,7 +247,7 @@ extern char *defsfilename; // set in bstub.c int app_main(int argc, const char **argv) { char ch, quitflag, cmdsetup = 0; - long i, j, k; + int i, j, k; pathsearchmode = 1; // unrestrict findfrompath so that full access to the filesystem can be had @@ -265,10 +266,13 @@ int app_main(int argc, const char **argv) editstatus = 1; boardfilename[0] = 0; - for (i=1; i k) { k = j; whitecol = i; } } @@ -372,9 +381,9 @@ int app_main(int argc, const char **argv) startsectnum = cursectnum; // TX 20050225: moved to loadboard totalclock = 0; - + updatesector(posx,posy,&cursectnum); - + if (cursectnum == -1) { setbrightness(0,palette,0); @@ -385,13 +394,15 @@ CANCEL: quitflag = 0; while (quitflag == 0) { - if (handleevents()) { - if (quitevent) { + if (handleevents()) + { + if (quitevent) + { keystatus[1] = 1; quitevent = 0; } } - + OSD_DispatchQueued(); ExtPreCheckKeys(); @@ -421,15 +432,18 @@ CANCEL: while ((keystatus[1]|keystatus[0x1c]|keystatus[0x39]|keystatus[0x31]) == 0) { - if (handleevents()) { - if (quitevent) { + if (handleevents()) + { + if (quitevent) + { quitflag = 1; break; } } idle(); - if (keystatus[0x15] != 0) { + if (keystatus[0x15] != 0) + { keystatus[0x15] = 0; quitflag = 1; break; } @@ -453,8 +467,9 @@ CANCEL: { if (handleevents()) { if (quitevent) break; } // like saying no idle(); - - if (keystatus[0x15] != 0) { + + if (keystatus[0x15] != 0) + { keystatus[0x15] = 0; fixspritesectors(); updatesector(startposx,startposy,&startsectnum); @@ -478,7 +493,7 @@ CANCEL: ExtUnInit(); uninitengine(); - Bprintf("Memory status: %ld(%ld) bytes\n",cachesize,artsize); + Bprintf("Memory status: %d(%d) bytes\n",cachesize,artsize); Bprintf("%s\n",kensig); return(0); } @@ -500,11 +515,11 @@ void editinput(void) { char smooshyalign, repeatpanalign, *ptr, buffer[80]; short sectnum, nextsectnum, startwall, endwall, dasector, daang; - long mousz, bstatus; - long i, j, k, cnt, templong=0, doubvel, changedir, wallfind[2], daz[2]; - long dashade[2], goalz, xvect, yvect, hiz, loz; + int mousz, bstatus; + int i, j, k, cnt, tempint=0, doubvel, changedir, wallfind[2], daz[2]; + int dashade[2], goalz, xvect, yvect, hiz, loz; short hitsect, hitwall, hitsprite; - long hitx, hity, hitz, dax, day, hihit, lohit; + int hitx, hity, hitz, dax, day, hihit, lohit; if (keystatus[0x57] > 0) //F11 - brightness { @@ -525,8 +540,8 @@ void editinput(void) mousy = (mousy<<16)+mouseysurp; { ldiv_t ld; - ld = ldiv((long)(mousx), (1<<16)); mousx = ld.quot; mousexsurp = ld.rem; - ld = ldiv((long)(mousy), (1<<16)); mousy = ld.quot; mouseysurp = ld.rem; + ld = ldiv((int)(mousx), (1<<16)); mousx = ld.quot; mousexsurp = ld.rem; + ld = ldiv((int)(mousy), (1<<16)); mousy = ld.quot; mouseysurp = ld.rem; } if (mlook) @@ -546,7 +561,7 @@ void editinput(void) { searchx = xdim>>1; searchy = ydim>>1; - } + } osearchx = searchx-mousx; osearchy = searchy-mousy; } @@ -572,7 +587,8 @@ void editinput(void) if (keystatus[0x44] > 0) ang++; if (angvel != 0) //ang += angvel * constant - { //ENGINE calculates angvel for you + { + //ENGINE calculates angvel for you doubvel = synctics; if (keystatus[buildkeys[4]] > 0) //Lt. shift makes turn velocity 50% faster doubvel += (synctics>>1); @@ -587,13 +603,13 @@ void editinput(void) xvect = 0, yvect = 0; if (vel != 0) { - xvect += ((vel*doubvel*(long)sintable[(ang+2560)&2047])>>3); - yvect += ((vel*doubvel*(long)sintable[(ang+2048)&2047])>>3); + xvect += ((vel*doubvel*(int)sintable[(ang+2560)&2047])>>3); + yvect += ((vel*doubvel*(int)sintable[(ang+2048)&2047])>>3); } if (svel != 0) { - xvect += ((svel*doubvel*(long)sintable[(ang+2048)&2047])>>3); - yvect += ((svel*doubvel*(long)sintable[(ang+1536)&2047])>>3); + xvect += ((svel*doubvel*(int)sintable[(ang+2048)&2047])>>3); + yvect += ((svel*doubvel*(int)sintable[(ang+1536)&2047])>>3); } if (noclip) { @@ -657,9 +673,12 @@ void editinput(void) goalz = posz; if (keystatus[buildkeys[8]] > 0) //A { - if (keystatus[0x1d] > 0) { + if (keystatus[0x1d] > 0) + { horiz = max(-100,horiz-((keystatus[buildkeys[4]]+1)*synctics*2)); - } else { + } + else + { if (zmode != 1) goalz -= (8<<8); else @@ -671,9 +690,12 @@ void editinput(void) } if (keystatus[buildkeys[9]] > 0) //Z (stand low) { - if (keystatus[0x1d] > 0) { + if (keystatus[0x1d] > 0) + { horiz = min(300,horiz+((keystatus[buildkeys[4]]+1)*synctics*2)); - } else { + } + else + { if (zmode != 1) goalz += (8<<8); else if (zlock > 0) @@ -903,10 +925,10 @@ void editinput(void) i = headspritesect[searchsector]; while (i != -1) { - templong = getceilzofslope(searchsector,sprite[i].x,sprite[i].y); - templong += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<2); - if (sprite[i].cstat&128) templong += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); - if (sprite[i].z == templong) + tempint = getceilzofslope(searchsector,sprite[i].x,sprite[i].y); + tempint += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<2); + if (sprite[i].cstat&128) tempint += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); + if (sprite[i].z == tempint) sprite[i].z -= 1024 << ((keystatus[0x1d]|keystatus[0x9d])<<1); // JBF 20031128 i = nextspritesect[i]; } @@ -919,10 +941,10 @@ void editinput(void) i = headspritesect[highlightsector[j]]; while (i != -1) { - templong = getceilzofslope(highlightsector[j],sprite[i].x,sprite[i].y); - templong += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<2); - if (sprite[i].cstat&128) templong += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); - if (sprite[i].z == templong) + tempint = getceilzofslope(highlightsector[j],sprite[i].x,sprite[i].y); + tempint += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<2); + if (sprite[i].cstat&128) tempint += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); + if (sprite[i].z == tempint) sprite[i].z -= 1024 << ((keystatus[0x1d]|keystatus[0x9d])<<1); // JBF 20031128 i = nextspritesect[i]; } @@ -937,9 +959,9 @@ void editinput(void) i = headspritesect[searchsector]; while (i != -1) { - templong = getflorzofslope(searchsector,sprite[i].x,sprite[i].y); - if (sprite[i].cstat&128) templong += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); - if (sprite[i].z == templong) + tempint = getflorzofslope(searchsector,sprite[i].x,sprite[i].y); + if (sprite[i].cstat&128) tempint += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); + if (sprite[i].z == tempint) sprite[i].z -= 1024 << ((keystatus[0x1d]|keystatus[0x9d])<<1); // JBF 20031128 i = nextspritesect[i]; } @@ -952,9 +974,9 @@ void editinput(void) i = headspritesect[highlightsector[j]]; while (i != -1) { - templong = getflorzofslope(highlightsector[j],sprite[i].x,sprite[i].y); - if (sprite[i].cstat&128) templong += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); - if (sprite[i].z == templong) + tempint = getflorzofslope(highlightsector[j],sprite[i].x,sprite[i].y); + if (sprite[i].cstat&128) tempint += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); + if (sprite[i].z == tempint) sprite[i].z -= 1024 << ((keystatus[0x1d]|keystatus[0x9d])<<1); // JBF 20031128 i = nextspritesect[i]; } @@ -1017,10 +1039,10 @@ void editinput(void) i = headspritesect[searchsector]; while (i != -1) { - templong = getceilzofslope(searchsector,sprite[i].x,sprite[i].y); - if (sprite[i].cstat&128) templong += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); - templong += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<2); - if (sprite[i].z == templong) + tempint = getceilzofslope(searchsector,sprite[i].x,sprite[i].y); + if (sprite[i].cstat&128) tempint += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); + tempint += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<2); + if (sprite[i].z == tempint) sprite[i].z += 1024 << ((keystatus[0x1d]|keystatus[0x9d])<<1); // JBF 20031128 i = nextspritesect[i]; } @@ -1033,10 +1055,10 @@ void editinput(void) i = headspritesect[highlightsector[j]]; while (i != -1) { - templong = getceilzofslope(highlightsector[j],sprite[i].x,sprite[i].y); - if (sprite[i].cstat&128) templong += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); - templong += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<2); - if (sprite[i].z == templong) + tempint = getceilzofslope(highlightsector[j],sprite[i].x,sprite[i].y); + if (sprite[i].cstat&128) tempint += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); + tempint += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<2); + if (sprite[i].z == tempint) sprite[i].z += 1024 << ((keystatus[0x1d]|keystatus[0x9d])<<1); // JBF 20031128 i = nextspritesect[i]; } @@ -1051,9 +1073,9 @@ void editinput(void) i = headspritesect[searchsector]; while (i != -1) { - templong = getflorzofslope(searchsector,sprite[i].x,sprite[i].y); - if (sprite[i].cstat&128) templong += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); - if (sprite[i].z == templong) + tempint = getflorzofslope(searchsector,sprite[i].x,sprite[i].y); + if (sprite[i].cstat&128) tempint += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); + if (sprite[i].z == tempint) sprite[i].z += 1024 << ((keystatus[0x1d]|keystatus[0x9d])<<1); // JBF 20031128 i = nextspritesect[i]; } @@ -1066,9 +1088,9 @@ void editinput(void) i = headspritesect[highlightsector[j]]; while (i != -1) { - templong = getflorzofslope(highlightsector[j],sprite[i].x,sprite[i].y); - if (sprite[i].cstat&128) templong += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); - if (sprite[i].z == templong) + tempint = getflorzofslope(highlightsector[j],sprite[i].x,sprite[i].y); + if (sprite[i].cstat&128) tempint += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); + if (sprite[i].z == tempint) sprite[i].z += 1024 << ((keystatus[0x1d]|keystatus[0x9d])<<1); // JBF 20031128 i = nextspritesect[i]; } @@ -1187,8 +1209,8 @@ void editinput(void) i = searchwall; do { - if ((long)wall[i].shade < dashade[0]) dashade[0] = wall[i].shade; - if ((long)wall[i].shade > dashade[1]) dashade[1] = wall[i].shade; + if ((int)wall[i].shade < dashade[0]) dashade[0] = wall[i].shade; + if ((int)wall[i].shade > dashade[1]) dashade[1] = wall[i].shade; i = wall[i].point2; } @@ -1248,7 +1270,7 @@ void editinput(void) } else if (((searchstat == 1) || (searchstat == 2)) && ((keystatus[0x1d]|keystatus[0x9d]) > 0) && (somethingintab < 255)) //Either ctrl key { - clearbuf(&pskysearch[0],(long)((numsectors+3)>>2),0L); + clearbuf(&pskysearch[0],(int)((numsectors+3)>>2),0L); if (searchstat == 1) { i = searchsector; @@ -1470,21 +1492,21 @@ void editinput(void) # if 0 if (keystatus[0x2f] > 0) //V { - if (searchstat == 0) templong = wall[searchwall].picnum; - if (searchstat == 1) templong = sector[searchsector].ceilingpicnum; - if (searchstat == 2) templong = sector[searchsector].floorpicnum; - if (searchstat == 3) templong = sprite[searchwall].picnum; - if (searchstat == 4) templong = wall[searchwall].overpicnum; - templong = gettile(templong); - if (searchstat == 0) wall[searchwall].picnum = templong; - if (searchstat == 1) sector[searchsector].ceilingpicnum = templong; - if (searchstat == 2) sector[searchsector].floorpicnum = templong; - if (searchstat == 3) sprite[searchwall].picnum = templong; + if (searchstat == 0) tempint = wall[searchwall].picnum; + if (searchstat == 1) tempint = sector[searchsector].ceilingpicnum; + if (searchstat == 2) tempint = sector[searchsector].floorpicnum; + if (searchstat == 3) tempint = sprite[searchwall].picnum; + if (searchstat == 4) tempint = wall[searchwall].overpicnum; + tempint = gettile(tempint); + if (searchstat == 0) wall[searchwall].picnum = tempint; + if (searchstat == 1) sector[searchsector].ceilingpicnum = tempint; + if (searchstat == 2) sector[searchsector].floorpicnum = tempint; + if (searchstat == 3) sprite[searchwall].picnum = tempint; if (searchstat == 4) { - wall[searchwall].overpicnum = templong; + wall[searchwall].overpicnum = tempint; if (wall[searchwall].nextwall >= 0) - wall[wall[searchwall].nextwall].overpicnum = templong; + wall[wall[searchwall].nextwall].overpicnum = tempint; } asksave = 1; keystatus[0x2f] = 0; @@ -1685,7 +1707,7 @@ void editinput(void) { if ((searchstat == 0) || (searchstat == 4)) { - AutoAlignWalls((long)searchwall,0L); + AutoAlignWalls((int)searchwall,0L); /*wallfind[0] = searchwall; cnt = 4096; @@ -2029,14 +2051,14 @@ void editinput(void) if (searchstat != 3) { i = wall[searchwall].nextwall; - templong = (keystatus[0x2a]|keystatus[0x36]); + tempint = (keystatus[0x2a]|keystatus[0x36]); if (i >= 0) { wall[searchwall].cstat ^= 16; if ((wall[searchwall].cstat&16) > 0) { wall[searchwall].cstat &= ~8; - if (templong == 0) + if (tempint == 0) { wall[i].cstat |= 8; //auto other-side flip wall[i].cstat |= 16; @@ -2046,14 +2068,14 @@ void editinput(void) else { wall[searchwall].cstat &= ~8; - if (templong == 0) + if (tempint == 0) { wall[i].cstat &= ~8; //auto other-side unflip wall[i].cstat &= ~16; } } wall[searchwall].cstat &= ~32; - if (templong == 0) wall[i].cstat &= ~32; + if (tempint == 0) wall[i].cstat &= ~32; asksave = 1; } } @@ -2393,7 +2415,7 @@ void editinput(void) } } -char changechar(char dachar, long dadir, char smooshyalign, char boundcheck) +char changechar(char dachar, int dadir, char smooshyalign, char boundcheck) { if (dadir < 0) { @@ -2419,11 +2441,11 @@ char changechar(char dachar, long dadir, char smooshyalign, char boundcheck) return(dachar); } #if 0 -long gettile(long tilenum) +int gettile(int tilenum) { char snotbuf[80], ch; - long i, j, k, otilenum, topleft, gap, temp, templong; - long xtiles, ytiles, tottiles; + int i, j, k, otilenum, topleft, gap, temp, tempint; + int xtiles, ytiles, tottiles; if (tilenum < 0) tilenum = 0; @@ -2460,12 +2482,12 @@ long gettile(long tilenum) temp = i; while ((localartfreq[temp] < localartfreq[temp+gap]) && (temp >= 0)) { - templong = localartfreq[temp]; + tempint = localartfreq[temp]; localartfreq[temp] = localartfreq[temp+gap]; - localartfreq[temp+gap] = templong; - templong = localartlookup[temp]; + localartfreq[temp+gap] = tempint; + tempint = localartlookup[temp]; localartlookup[temp] = localartlookup[temp+gap]; - localartlookup[temp+gap] = templong; + localartlookup[temp+gap] = tempint; if (tilenum == temp) tilenum = temp+gap; @@ -2497,7 +2519,8 @@ long gettile(long tilenum) { drawtilescreen(topleft,tilenum); - if (handleevents()) { + if (handleevents()) + { if (quitevent) quitevent = 0; } idle(); @@ -2568,7 +2591,8 @@ long gettile(long tilenum) j = tilenum; while (keystatus[1] == 0) { - if (handleevents()) { + if (handleevents()) + { if (quitevent) quitevent = 0; } idle(); @@ -2576,16 +2600,21 @@ long gettile(long tilenum) ch = bgetchar(); //drawtilescreen(topleft,tilenum); - Bsprintf(snotbuf,"Goto tile: %ld_ ",j); + Bsprintf(snotbuf,"Goto tile: %d_ ",j); printext256(0,0,whitecol,0,snotbuf,0); showframe(1); - if (ch >= '0' && ch <= '9') { + if (ch >= '0' && ch <= '9') + { i = (j*10)+(ch-'0'); if (i < MAXTILES) j = i; - } else if (ch == 8) { + } + else if (ch == 8) + { j /= 10; - } else if (ch == 13) { + } + else if (ch == 13) + { tilenum = j; break; } @@ -2618,10 +2647,10 @@ long gettile(long tilenum) return(tilenum); } -long drawtilescreen(long pictopleft, long picbox) +int drawtilescreen(int pictopleft, int picbox) { - long i, j, vidpos, vidpos2, dat, wallnum, xdime, ydime, cnt, pinc; - long dax, day, scaledown, xtiles, ytiles, tottiles; + int i, j, vidpos, vidpos2, dat, wallnum, xdime, ydime, cnt, pinc; + int dax, day, scaledown, xtiles, ytiles, tottiles; char *picptr, snotbuf[80]; xtiles = (xdim>>6); ytiles = (ydim>>6); tottiles = xtiles*ytiles; @@ -2647,7 +2676,8 @@ long drawtilescreen(long pictopleft, long picbox) dax = ((cnt%(xtiles<>gettilezoom, 0)) { + if (polymost_drawtilescreen(dax, day, wallnum, 64>>gettilezoom, 0)) + { vidpos = ylookup[day]+dax+frameplace; if ((xdime <= (64>>gettilezoom)) && (ydime <= (64>>gettilezoom))) { @@ -2707,7 +2737,7 @@ long drawtilescreen(long pictopleft, long picbox) } i = localartlookup[picbox]; - Bsprintf(snotbuf,"%ld",i); + Bsprintf(snotbuf,"%d",i); printext256(0L,ydim-8,whitecol,-1,snotbuf,0); printext256(xdim-(Bstrlen(names[i])<<3),ydim-8,whitecol,-1,names[i],0); @@ -2724,20 +2754,20 @@ long drawtilescreen(long pictopleft, long picbox) void overheadeditor(void) { char buffer[80], *dabuffer, ch; - long i, j, k, m=0, mousxplc, mousyplc, firstx=0, firsty=0, oposz, col; - long templong, templong1, templong2, doubvel; - long startwall=0, endwall, dax, day, daz, x1, y1, x2, y2, x3, y3, x4, y4; - long highlightx1, highlighty1, highlightx2, highlighty2, xvect, yvect; + int i, j, k, m=0, mousxplc, mousyplc, firstx=0, firsty=0, oposz, col; + int tempint, tempint1, tempint2, doubvel; + int startwall=0, endwall, dax, day, daz, x1, y1, x2, y2, x3, y3, x4, y4; + int highlightx1, highlighty1, highlightx2, highlighty2, xvect, yvect; short pag, suckwall=0, sucksect, newnumwalls, newnumsectors, split=0, bad; short splitsect=0, danumwalls, secondstartwall, joinsector[2], joinsectnum; short splitstartwall=0, splitendwall, loopnum; - long mousx, mousy, bstatus; - long centerx, centery, circlerad; + int mousx, mousy, bstatus; + int centerx, centery, circlerad; short circlewall, circlepoints, circleang1, circleang2, circleangdir; - long sectorhighlightx=0, sectorhighlighty=0; + int sectorhighlightx=0, sectorhighlighty=0; short cursectorhighlight, sectorhighlightstat; short hitsect, hitwall, hitsprite; - long hitx, hity, hitz; + int hitx, hity, hitz; walltype *wal; //qsetmode640480(); @@ -2815,13 +2845,15 @@ void overheadeditor(void) keystatus[buildkeys[14]] = 0; while ((keystatus[buildkeys[14]]>>1) == 0) { - if (handleevents()) { - if (quitevent) { + if (handleevents()) + { + if (quitevent) + { keystatus[1] = 1; quitevent = 0; } } - + idle(); OSD_DispatchQueued(); @@ -2831,8 +2863,8 @@ void overheadeditor(void) mousy = (mousy<<16)+mouseysurp; { ldiv_t ld; - ld = ldiv((long)(mousx), (1<<16)); mousx = ld.quot; mousexsurp = ld.rem; - ld = ldiv((long)(mousy), (1<<16)); mousy = ld.quot; mouseysurp = ld.rem; + ld = ldiv((int)(mousx), (1<<16)); mousx = ld.quot; mousexsurp = ld.rem; + ld = ldiv((int)(mousy), (1<<16)); mousy = ld.quot; mouseysurp = ld.rem; } searchx += mousx*msens; searchy += mousy*msens; @@ -2848,7 +2880,8 @@ void overheadeditor(void) if (keystatus[0x43] > 0) ang--, keystatus[0x43] = 0; if (keystatus[0x44] > 0) ang++, keystatus[0x44] = 0; */ if (angvel != 0) //ang += angvel * constant - { //ENGINE calculates angvel for you + { + //ENGINE calculates angvel for you doubvel = synctics; if (keystatus[buildkeys[4]] > 0) //Lt. shift makes turn velocity 50% faster doubvel += (synctics>>1); @@ -2863,13 +2896,13 @@ void overheadeditor(void) xvect = 0, yvect = 0; if (vel != 0) { - xvect += ((vel*doubvel*(long)sintable[(ang+2560)&2047])>>3); - yvect += ((vel*doubvel*(long)sintable[(ang+2048)&2047])>>3); + xvect += ((vel*doubvel*(int)sintable[(ang+2560)&2047])>>3); + yvect += ((vel*doubvel*(int)sintable[(ang+2048)&2047])>>3); } if (svel != 0) { - xvect += ((svel*doubvel*(long)sintable[(ang+2048)&2047])>>3); - yvect += ((svel*doubvel*(long)sintable[(ang+1536)&2047])>>3); + xvect += ((svel*doubvel*(int)sintable[(ang+2048)&2047])>>3); + yvect += ((svel*doubvel*(int)sintable[(ang+1536)&2047])>>3); } if (noclip) { @@ -2894,9 +2927,9 @@ void overheadeditor(void) ydim16 = ydim - STATUS2DSIZ; - templong = numwalls; + tempint = numwalls; numwalls = newnumwalls; - if (numwalls < 0) numwalls = templong; + if (numwalls < 0) numwalls = tempint; clear2dscreen(); draw2dgrid(posx,posy,ang,zoom,grid); @@ -3023,19 +3056,20 @@ void overheadeditor(void) printcoords16(posx,posy,ang); - numwalls = templong; + numwalls = tempint; if (highlightsectorcnt > 0) for (i=0;i= 0) @@ -3109,10 +3143,10 @@ void overheadeditor(void) for (i=0;i= 16384) { i = pointhighlight-16384; - Bsprintf(buffer,"Sprite (%ld) Lo-tag: ",i); + Bsprintf(buffer,"Sprite (%d) Lo-tag: ",i); sprite[i].lotag = getnumber16(buffer,sprite[i].lotag,65536L,0); clearmidstatbar16(); showspritedata((short)i); @@ -3698,7 +3732,7 @@ void overheadeditor(void) else if (linehighlight >= 0) { i = linehighlight; - Bsprintf(buffer,"Wall (%ld) Lo-tag: ",i); + Bsprintf(buffer,"Wall (%d) Lo-tag: ",i); wall[i].lotag = getnumber16(buffer,wall[i].lotag,65536L,0); clearmidstatbar16(); showwalldata((short)i); @@ -3710,7 +3744,7 @@ void overheadeditor(void) for (i=0;i= 16384) { i = pointhighlight-16384; - Bsprintf(buffer,"Sprite (%ld) Hi-tag: ",i); + Bsprintf(buffer,"Sprite (%d) Hi-tag: ",i); sprite[i].hitag = getnumber16(buffer,sprite[i].hitag,65536L,0); clearmidstatbar16(); showspritedata((short)i); @@ -3756,7 +3790,7 @@ void overheadeditor(void) else if (linehighlight >= 0) { i = linehighlight; - Bsprintf(buffer,"Wall (%ld) Hi-tag: ",i); + Bsprintf(buffer,"Wall (%d) Hi-tag: ",i); wall[i].hitag = getnumber16(buffer,wall[i].hitag,65536L,0); clearmidstatbar16(); showwalldata((short)i); @@ -3767,7 +3801,7 @@ void overheadeditor(void) for (i=0;i= 16384) { i = pointhighlight-16384; - Bsprintf(buffer,"Sprite (%ld) Status list: ",i); + Bsprintf(buffer,"Sprite (%d) Status list: ",i); changespritestat(i,getnumber16(buffer,sprite[i].statnum,65536L,0)); clearmidstatbar16(); showspritedata((short)i); @@ -3872,11 +3906,11 @@ void overheadeditor(void) getpoint(highlightx2,highlighty2,&highlightx2,&highlighty2); if (highlightx1 > highlightx2) { - templong = highlightx1; highlightx1 = highlightx2; highlightx2 = templong; + tempint = highlightx1; highlightx1 = highlightx2; highlightx2 = tempint; } if (highlighty1 > highlighty2) { - templong = highlighty1; highlighty1 = highlighty2; highlighty2 = templong; + tempint = highlighty1; highlighty1 = highlighty2; highlighty2 = tempint; } if ((keystatus[0x1d]|keystatus[0x9d]) > 0) @@ -3970,11 +4004,11 @@ void overheadeditor(void) getpoint(highlightx2,highlighty2,&highlightx2,&highlighty2); if (highlightx1 > highlightx2) { - templong = highlightx1; highlightx1 = highlightx2; highlightx2 = templong; + tempint = highlightx1; highlightx1 = highlightx2; highlightx2 = tempint; } if (highlighty1 > highlighty2) { - templong = highlighty1; highlighty1 = highlighty2; highlighty2 = templong; + tempint = highlighty1; highlighty1 = highlighty2; highlighty2 = tempint; } for (i=0;i=0;j=nextspritesect[j]) - { sprite[j].x += dax; sprite[j].y += day; } + { sprite[j].x += dax; sprite[j].y += day; } } //for(i=0;i 0) for (i=0;i 0) || (bstatus&32)) && (zoom > 8)) { zoom -= synctics*(zoom>>4); @@ -4615,12 +4649,12 @@ void overheadeditor(void) x3 = mousxplc; y3 = mousyplc; adjustmark(&x3,&y3,newnumwalls); - templong1 = dmulscale4(x3-x2,x1-x3,y1-y3,y3-y2); - templong2 = dmulscale4(y1-y2,x1-x3,y1-y3,x2-x1); - if (templong2 != 0) + tempint1 = dmulscale4(x3-x2,x1-x3,y1-y3,y3-y2); + tempint2 = dmulscale4(y1-y2,x1-x3,y1-y3,x2-x1); + if (tempint2 != 0) { - centerx = (((x1+x2) + scale(y1-y2,templong1,templong2))>>1); - centery = (((y1+y2) + scale(x2-x1,templong1,templong2))>>1); + centerx = (((x1+x2) + scale(y1-y2,tempint1,tempint2))>>1); + centery = (((y1+y2) + scale(x2-x1,tempint1,tempint2))>>1); dax = mulscale14(centerx-posx,zoom); day = mulscale14(centery-posy,zoom); @@ -4713,7 +4747,8 @@ void overheadeditor(void) newnumwalls++; } else - { //if not back to first point + { + //if not back to first point if ((firstx != mousxplc) || (firsty != mousyplc)) //nextpoint { j = 0; @@ -4729,7 +4764,8 @@ void overheadeditor(void) day = ((wall[numwalls].y+mousyplc)>>1); for (i=0;inumwalls;j--) @@ -5159,7 +5197,8 @@ void overheadeditor(void) wall[danumwalls].point2 = danumwalls+1; danumwalls++; m = wall[m].point2; - } while (m != splitstartwall); + } + while (m != splitstartwall); wall[danumwalls-1].point2 = numwalls; //Add other loops to sector @@ -5178,7 +5217,8 @@ void overheadeditor(void) wall[danumwalls].point2 = danumwalls+1; danumwalls++; m = wall[m].point2; - } while (m != j); + } + while (m != j); wall[danumwalls-1].point2 = k; } } @@ -5298,7 +5338,8 @@ void overheadeditor(void) } if ((keystatus[0xd3] > 0) && (keystatus[0x9d] > 0) && (numwalls >= 0)) - { //sector delete + { + //sector delete keystatus[0xd3] = 0; sucksect = -1; @@ -5400,7 +5441,7 @@ void overheadeditor(void) } else if (linehighlight >= 0) { - getclosestpointonwall(mousxplc,mousyplc,(long)linehighlight,&dax,&day); + getclosestpointonwall(mousxplc,mousyplc,(int)linehighlight,&dax,&day); adjustmark(&dax,&day,newnumwalls); insertpoint(linehighlight,dax,day); printmessage16("Point inserted."); @@ -5476,8 +5517,10 @@ CANCEL: bad = 1; while (bad == 1) { - if (handleevents()) { - if (quitevent) { + if (handleevents()) + { + if (quitevent) + { quitevent = 0; } } @@ -5499,8 +5542,10 @@ CANCEL: bflushchars(); ch = 0; while (keystatus[1] == 0) { - if (handleevents()) { - if (quitevent) { + if (handleevents()) + { + if (quitevent) + { quitevent = 0; } } @@ -5539,7 +5584,9 @@ CANCEL: initspritelists(); Bstrcpy(boardfilename,"newboard.map"); break; - } else if (ch == 'N' || ch == 'n' || ch == 13 || ch == ' ') { + } + else if (ch == 'N' || ch == 'n' || ch == 13 || ch == ' ') + { break; } } @@ -5727,7 +5774,8 @@ CANCEL: printmessage16(buffer); showframe(1); - if (handleevents()) { + if (handleevents()) + { if (quitevent) quitevent = 0; } idle(); @@ -5736,8 +5784,10 @@ CANCEL: if (keystatus[1] > 0) bad = 1; else if (ch == 13) bad = 2; - else if (ch > 0) { - if (i > 0 && (ch == 8 || ch == 127)) { + else if (ch > 0) + { + if (i > 0 && (ch == 8 || ch == 127)) + { i--; boardfilename[i] = 0; } @@ -5771,7 +5821,8 @@ CANCEL: else Bstrcpy(selectedboardfilename, boardfilename); if (pathsearchmode) f = selectedboardfilename; - else { + else + { // virtual filesystem mode can't save to directories so drop the file into // the current directory f = strrchr(selectedboardfilename, '/'); @@ -5800,7 +5851,8 @@ CANCEL: fixspritesectors(); //Do this before saving! updatesector(startposx,startposy,&startsectnum); if (pathsearchmode) f = boardfilename; - else { + else + { // virtual filesystem mode can't save to directories so drop the file into // the current directory f = strrchr(boardfilename, '/'); @@ -5820,7 +5872,8 @@ CANCEL: bflushchars(); while ((keystatus[1]|keystatus[0x2e]) == 0) { - if (handleevents()) { + if (handleevents()) + { if (quitevent) quitevent = 0; } idle(); @@ -5835,7 +5888,8 @@ CANCEL: showframe(1); while ((keystatus[1]|keystatus[0x2e]) == 0) { - if (handleevents()) { + if (handleevents()) + { if (quitevent) break; // like saying no } idle(); @@ -5849,7 +5903,8 @@ CANCEL: updatesector(startposx,startposy,&startsectnum); ExtPreSaveMap(); if (pathsearchmode) f = boardfilename; - else { + else + { // virtual filesystem mode can't save to directories so drop the file into // the current directory f = strrchr(boardfilename, '/'); @@ -5858,7 +5913,9 @@ CANCEL: saveboard(f,&startposx,&startposy,&startposz,&startang,&startsectnum); ExtSaveMap(f); break; - } else if (ch == 'n' || ch == 'N' || ch == 13 || ch == ' ') { + } + else if (ch == 'n' || ch == 'N' || ch == 13 || ch == ' ') + { break; } } @@ -5876,10 +5933,12 @@ CANCEL: uninitinput(); ExtUnInit(); uninitengine(); - printf("Memory status: %ld(%ld) bytes\n",cachesize,artsize); + printf("Memory status: %d(%d) bytes\n",cachesize,artsize); printf("%s\n",kensig); exit(0); - } else if (ch == 'n' || ch == 'N' || ch == 13 || ch == ' ') { + } + else if (ch == 'n' || ch == 'N' || ch == 13 || ch == ' ') + { break; } } @@ -5914,7 +5973,7 @@ CANCEL: uninittimer(); uninitsystem(); clearfilenames(); - printf("%ld * %ld not supported in this graphics mode\n",xdim,ydim); + printf("%d * %d not supported in this graphics mode\n",xdim,ydim); exit(0); } @@ -5925,7 +5984,7 @@ CANCEL: searchy = scale(searchy,ydimgame,ydim2d-STATUS2DSIZ); } -void getpoint(long searchxe, long searchye, long *x, long *y) +void getpoint(int searchxe, int searchye, int *x, int *y) { if (posx <= -editorgridextent) posx = -editorgridextent; if (posx >= editorgridextent) posx = editorgridextent; @@ -5941,9 +6000,9 @@ void getpoint(long searchxe, long searchye, long *x, long *y) if (*y >= editorgridextent) *y = editorgridextent; } -long getlinehighlight(long xplc, long yplc) +int getlinehighlight(int xplc, int yplc) { - long i, dst, dist, closest, x1, y1, x2, y2, nx, ny; + int i, dst, dist, closest, x1, y1, x2, y2, nx, ny; if (numwalls == 0) return(-1); @@ -5961,7 +6020,8 @@ long getlinehighlight(long xplc, long yplc) } if (wall[closest].nextwall >= 0) - { //if red line, allow highlighting of both sides + { + //if red line, allow highlighting of both sides x1 = wall[closest].x; y1 = wall[closest].y; x2 = wall[wall[closest].point2].x; @@ -5973,9 +6033,9 @@ long getlinehighlight(long xplc, long yplc) return(closest); } -long getpointhighlight(long xplc, long yplc) +int getpointhighlight(int xplc, int yplc) { - long i, dst, dist = 512, closest = -1; + int i, dst, dist = 512, closest = -1; if (numwalls == 0) return(-1); @@ -6000,9 +6060,9 @@ long getpointhighlight(long xplc, long yplc) return(closest); } -long adjustmark(long *xplc, long *yplc, short danumwalls) +int adjustmark(int *xplc, int *yplc, short danumwalls) { - long i, dst, dist, dax, day, pointlockdist; + int i, dst, dist, dax, day, pointlockdist; if (danumwalls < 0) danumwalls = numwalls; @@ -6036,9 +6096,9 @@ long adjustmark(long *xplc, long *yplc, short danumwalls) return(0); } -long checkautoinsert(long dax, long day, short danumwalls) +int checkautoinsert(int dax, int day, short danumwalls) { - long i, x1, y1, x2, y2; + int i, x1, y1, x2, y2; if (danumwalls < 0) danumwalls = numwalls; @@ -6059,10 +6119,10 @@ long checkautoinsert(long dax, long day, short danumwalls) return(0); } -long clockdir(short wallstart) //Returns: 0 is CW, 1 is CCW +int clockdir(short wallstart) //Returns: 0 is CW, 1 is CCW { short i, themin; - long minx, templong, x0, x1, x2, y0, y1, y2; + int minx, tempint, x0, x1, x2, y0, y1, y2; minx = 0x7fffffff; themin = -1; @@ -6088,8 +6148,8 @@ long clockdir(short wallstart) //Returns: 0 is CW, 1 is CCW if ((y1 >= y2) && (y1 <= y0)) return(0); if ((y1 >= y0) && (y1 <= y2)) return(1); - templong = (x0-x1)*(y2-y1) - (x2-x1)*(y0-y1); - if (templong < 0) + tempint = (x0-x1)*(y2-y1) - (x2-x1)*(y0-y1); + if (tempint < 0) return(0); else return(1); @@ -6097,22 +6157,22 @@ long clockdir(short wallstart) //Returns: 0 is CW, 1 is CCW void flipwalls(short numwalls, short newnumwalls) { - long i, j, nume, templong; + int i, j, nume, tempint; nume = newnumwalls-numwalls; for (i=numwalls;i>1);i++) { j = numwalls+newnumwalls-i-1; - templong = wall[i].x; wall[i].x = wall[j].x; wall[j].x = templong; - templong = wall[i].y; wall[i].y = wall[j].y; wall[j].y = templong; + tempint = wall[i].x; wall[i].x = wall[j].x; wall[j].x = tempint; + tempint = wall[i].y; wall[i].y = wall[j].y; wall[j].y = tempint; } } -void insertpoint(short linehighlight, long dax, long day) +void insertpoint(short linehighlight, int dax, int day) { short sucksect; - long i, j, k; + int i, j, k; j = linehighlight; sucksect = sectorofwall((short)j); @@ -6121,7 +6181,7 @@ void insertpoint(short linehighlight, long dax, long day) for (i=sucksect+1;i= 0) deletesprite(headspritesect[sucksect]); @@ -6229,7 +6289,7 @@ long deletesector(short sucksect) void fixspritesectors(void) { - long i, j, dax, day, daz; + int i, j, dax, day, daz; for (i=numsectors-1;i>=0;i--) if ((sector[i].wallnum <= 0) || (sector[i].wallptr >= numwalls)) @@ -6256,9 +6316,9 @@ void fixspritesectors(void) } } -long movewalls(long start, long offs) +int movewalls(int start, int offs) { - long i; + int i; if (offs < 0) //Delete { @@ -6279,9 +6339,9 @@ long movewalls(long start, long offs) return(0); } -long checksectorpointer(short i, short sectnum) +int checksectorpointer(short i, short sectnum) { - long j, k, startwall, endwall, x1, y1, x2, y2; + int j, k, startwall, endwall, x1, y1, x2, y2; x1 = wall[i].x; y1 = wall[i].y; @@ -6320,7 +6380,7 @@ long checksectorpointer(short i, short sectnum) void fixrepeats(short i) { - long dax, day, dist; + int dax, day, dist; dax = wall[wall[i].point2].x-wall[i].x; day = wall[wall[i].point2].y-wall[i].y; @@ -6341,9 +6401,9 @@ void clearmidstatbar16(void) enddrawing(); } -short loopinside(long x, long y, short startwall) +short loopinside(int x, int y, short startwall) { - long x1, y1, x2, y2, templong; + int x1, y1, x2, y2, tempint; short i, cnt; cnt = clockdir(startwall); @@ -6356,8 +6416,8 @@ short loopinside(long x, long y, short startwall) y1 = wall[i].y; y2 = wall[wall[i].point2].y; if (y1 > y2) { - templong = x1, x1 = x2, x2 = templong; - templong = y1, y1 = y2, y2 = templong; + tempint = x1, x1 = x2, x2 = tempint; + tempint = y1, y1 = y2, y2 = tempint; } if ((y1 <= y) && (y2 > y)) if (x1*(y-y2)+x2*(y1-y) <= x*(y1-y2)) @@ -6369,9 +6429,9 @@ short loopinside(long x, long y, short startwall) return(cnt); } -long numloopsofsector(short sectnum) +int numloopsofsector(short sectnum) { - long i, numloops, startwall, endwall; + int i, numloops, startwall, endwall; numloops = 0; startwall = sector[sectnum].wallptr; @@ -6381,28 +6441,30 @@ long numloopsofsector(short sectnum) return(numloops); } -long getnumber16(char namestart[80], long num, long maxnumber, char sign) +int getnumber16(char namestart[80], int num, int maxnumber, char sign) { char buffer[80], ch; - long j, k, n, danum, oldnum; + int j, k, n, danum, oldnum; - danum = (long)num; + danum = (int)num; oldnum = danum; bflushchars(); while (keystatus[0x1] == 0) { - if (handleevents()) { + if (handleevents()) + { if (quitevent) quitevent = 0; } idle(); ch = bgetchar(); - Bsprintf(buffer,"%s%ld_ ",namestart,danum); + Bsprintf(buffer,"%s%d_ ",namestart,danum); printmessage16(buffer); showframe(1); - if (ch >= '0' && ch <= '9') { + if (ch >= '0' && ch <= '9') + { if (danum >= 0) { n = (danum*10)+(ch-'0'); @@ -6413,13 +6475,19 @@ long getnumber16(char namestart[80], long num, long maxnumber, char sign) n = (danum*10)-(ch-'0'); if (n >= -maxnumber) danum = n; } - } else if (ch == 8 || ch == 127) { // backspace + } + else if (ch == 8 || ch == 127) // backspace + { danum /= 10; - } else if (ch == 13) { + } + else if (ch == 13) + { oldnum = danum; asksave = 1; break; - } else if (ch == '-' && sign) { // negate + } + else if (ch == '-' && sign) // negate + { danum = -danum; } } @@ -6427,17 +6495,18 @@ long getnumber16(char namestart[80], long num, long maxnumber, char sign) return(oldnum); } -long getnumber256(char namestart[80], long num, long maxnumber, char sign) +int getnumber256(char namestart[80], int num, int maxnumber, char sign) { char buffer[80], ch; - long j, k, n, danum, oldnum; + int j, k, n, danum, oldnum; danum = num; oldnum = danum; bflushchars(); while (keystatus[0x1] == 0) { - if (handleevents()) { + if (handleevents()) + { if (quitevent) quitevent = 0; } @@ -6449,11 +6518,12 @@ long getnumber256(char namestart[80], long num, long maxnumber, char sign) ch = bgetchar(); - Bsprintf(buffer,"%s%ld_ ",namestart,danum); + Bsprintf(buffer,"%s%d_ ",namestart,danum); printmessage256(buffer); showframe(1); - if (ch >= '0' && ch <= '9') { + if (ch >= '0' && ch <= '9') + { if (danum >= 0) { n = (danum*10)+(ch-'0'); @@ -6464,13 +6534,19 @@ long getnumber256(char namestart[80], long num, long maxnumber, char sign) n = (danum*10)-(ch-'0'); if (n >= -maxnumber) danum = n; } - } else if (ch == 8 || ch == 127) { // backspace + } + else if (ch == 8 || ch == 127) // backspace + { danum /= 10; - } else if (ch == 13) { + } + else if (ch == 13) + { oldnum = danum; asksave = 1; break; - } else if (ch == '-' && sign) { // negate + } + else if (ch == '-' && sign) // negate + { danum = -danum; } } @@ -6489,7 +6565,7 @@ void clearfilenames(void) numfiles = numdirs = 0; } -long getfilenames(char *path, char *kind) +int getfilenames(char *path, char *kind) { CACHE1D_FIND_REC *r; @@ -6507,10 +6583,10 @@ long getfilenames(char *path, char *kind) return(0); } -long menuselect(void) +int menuselect(void) { int listsize; - long i, j, topplc; + int i, j, topplc; char ch, buffer[78], *sb; static char oldpath[BMAX_PATH]; CACHE1D_FIND_REC *dir; @@ -6531,13 +6607,17 @@ long menuselect(void) printmessage16("Select map file with arrow keys and enter."); enddrawing(); - do { + do + { begindrawing(); clearbuf((char *)frameplace, (bytesperline*ydim16) >> 2, 0l); - if (pathsearchmode) { + if (pathsearchmode) + { strcpy(buffer,"Local filesystem mode; press F for game filesystem."); - } else { + } + else + { sprintf(buffer,"Game filesystem %smode; press F for local filesystem or G for %s.", grponlymode?"GRP-only ":"", grponlymode?"all files":"GRP contents only"); } @@ -6547,32 +6627,42 @@ long menuselect(void) buffer[sizeof(buffer)-1] = 0; printext16(1,ydim16-8-1,8,0,buffer,0); - if (finddirshigh) { + if (finddirshigh) + { dir = finddirshigh; for (i=listsize/2-1; i>=0; i--) if (!dir->prev) break; else dir=dir->prev; - for (i=0; inext) { + for (i=0; inext) + { int c = dir->type == CACHE1D_FIND_DIR ? 4 : 3; memset(buffer,0,sizeof(buffer)); strncpy(buffer,dir->name,25); if (strlen(buffer) == 25) buffer[21] = buffer[22] = buffer[23] = '.', buffer[24] = 0; - if (dir == finddirshigh) { + if (dir == finddirshigh) + { if (currentlist == 0) printext16(8,16+8*i,c|8,0,"->",0); printext16(32,16+8*i,c|8,0,buffer,0); - } else { + } + else + { printext16(32,16+8*i,c,0,buffer,0); } } } - if (findfileshigh) { + if (findfileshigh) + { dir = findfileshigh; for (i=listsize/2-1; i>=0; i--) if (!dir->prev) break; else dir=dir->prev; - for (i=0; inext) { - if (dir == findfileshigh) { + for (i=0; inext) + { + if (dir == findfileshigh) + { if (currentlist == 1) printext16(240,16+8*i,7|8,0,"->",0); printext16(240+24,16+8*i,7|8,0,dir->name,0); - } else { + } + else + { printext16(240+24,16+8*i,7,0,dir->name,0); } } @@ -6590,21 +6680,25 @@ long menuselect(void) ch = 0; //Interesting fakery of ch = getch() while (ch == 0) { - if (handleevents()) { - if (quitevent) { + if (handleevents()) + { + if (quitevent) + { keystatus[1] = 1; quitevent = 0; } } idle(); ch = bgetchar(); - { // JBF 20040208: seek to first name matching pressed character + { + // JBF 20040208: seek to first name matching pressed character CACHE1D_FIND_REC *seeker = currentlist ? findfiles : finddirs; if ((keystatus[0xc7]|keystatus[0xcf]) > 0) // home/end { while (keystatus[0xcf]?seeker->next:seeker->prev) seeker = keystatus[0xcf]?seeker->next:seeker->prev; - if (seeker) { + if (seeker) + { if (currentlist) findfileshigh = seeker; else finddirshigh = seeker; } @@ -6615,12 +6709,14 @@ long menuselect(void) { seeker = currentlist?findfileshigh:finddirshigh; i = (ydim2d-STATUS2DSIZ-48)>>3; - while (i>0) { + while (i>0) + { if (keystatus[0xd1]?seeker->next:seeker->prev) seeker = keystatus[0xd1]?seeker->next:seeker->prev; i--; } - if (seeker) { + if (seeker) + { if (currentlist) findfileshigh = seeker; else finddirshigh = seeker; } @@ -6630,15 +6726,18 @@ long menuselect(void) else { char ch2; - if (ch > 0 && ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9'))) { + if (ch > 0 && ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9'))) + { if (ch >= 'a') ch -= ('a'-'A'); - while (seeker) { + while (seeker) + { ch2 = seeker->name[0]; if (ch2 >= 'a' && ch2 <= 'z') ch2 -= ('a'-'A'); if (ch2 == ch) break; seeker = seeker->next; } - if (seeker) { + if (seeker) + { if (currentlist) findfileshigh = seeker; else finddirshigh = seeker; continue; @@ -6651,40 +6750,63 @@ long menuselect(void) if (keystatus[0xc8] > 0) ch = 72; // up arr if (keystatus[0xd0] > 0) ch = 80; // down arr } - if (ch == 'f' || ch == 'F') { + if (ch == 'f' || ch == 'F') + { currentlist = 0; pathsearchmode = 1-pathsearchmode; - if (pathsearchmode) { + if (pathsearchmode) + { strcpy(selectedboardfilename, ""); Bcanonicalisefilename(selectedboardfilename, 0); - } else strcpy(selectedboardfilename, "/"); + } + else strcpy(selectedboardfilename, "/"); getfilenames(selectedboardfilename, "*.map"); Bstrcpy(oldpath,selectedboardfilename); - } else if (ch == 'g' || ch == 'G') { - if (!pathsearchmode) { + } + else if (ch == 'g' || ch == 'G') + { + if (!pathsearchmode) + { grponlymode = 1-grponlymode; getfilenames(selectedboardfilename, "*.map"); Bstrcpy(oldpath,selectedboardfilename); } - } else if (ch == 9) { + } + else if (ch == 9) + { if ((currentlist == 0 && findfiles) || (currentlist == 1 && finddirs)) currentlist = 1-currentlist; - } else if ((ch == 75) || (ch == 72)) { - if (currentlist == 0) { + } + else if ((ch == 75) || (ch == 72)) + { + if (currentlist == 0) + { if (finddirshigh && finddirshigh->prev) finddirshigh = finddirshigh->prev; - } else { + } + else + { if (findfileshigh && findfileshigh->prev) findfileshigh = findfileshigh->prev; } - } else if ((ch == 77) || (ch == 80)) { - if (currentlist == 0) { + } + else if ((ch == 77) || (ch == 80)) + { + if (currentlist == 0) + { if (finddirshigh && finddirshigh->next) finddirshigh = finddirshigh->next; - } else { + } + else + { if (findfileshigh && findfileshigh->next) findfileshigh = findfileshigh->next; } - } else if ((ch == 13) && (currentlist == 0)) { - if (finddirshigh->type == CACHE1D_FIND_DRIVE) { + } + else if ((ch == 13) && (currentlist == 0)) + { + if (finddirshigh->type == CACHE1D_FIND_DRIVE) + { strcpy(selectedboardfilename, finddirshigh->name); - } else { + } + else + { strcat(selectedboardfilename, finddirshigh->name); } strcat(selectedboardfilename, "/"); @@ -6718,10 +6840,10 @@ long menuselect(void) return(-1); } -long fillsector(short sectnum, char fillcolor) +int fillsector(short sectnum, char fillcolor) { - long x1, x2, y1, y2, sy, y, templong; - long lborder, rborder, uborder, dborder, miny, maxy, dax; + int x1, x2, y1, y2, sy, y, tempint; + int lborder, rborder, uborder, dborder, miny, maxy, dax; short z, zz, startwall, endwall, fillcnt; lborder = 0; rborder = xdim; @@ -6756,8 +6878,8 @@ long fillsector(short sectnum, char fillcolor) y1 = wall[z].y; y2 = wall[wall[z].point2].y; if (y1 > y2) { - templong = x1; x1 = x2; x2 = templong; - templong = y1; y1 = y2; y2 = templong; + tempint = x1; x1 = x2; x2 = tempint; + tempint = y1; y1 = y2; y2 = tempint; } if ((y1 <= y) && (y2 > y)) //if (x1*(y-y2) + x2*(y1-y) <= 0) @@ -6774,7 +6896,7 @@ long fillsector(short sectnum, char fillcolor) for (zz=0;zz= 1) { + if (a >= 1) + { if (a > 1) if (buffer[a-2] == '\r') buffer[a-2] = 0; if (buffer[a-1] == '\n') buffer[a-1] = 0; @@ -6925,26 +7051,31 @@ long loadnames(void) while (*p == 32) p++; if (*p == 0) continue; // blank line - if (*p == '#') { + if (*p == '#') + { p++; while (*p == 32) p++; if (*p == 0) continue; // null directive - if (!Bstrncmp(p, "define ", 7)) { + if (!Bstrncmp(p, "define ", 7)) + { // #define_... p += 7; while (*p == 32) p++; - if (*p == 0) { + if (*p == 0) + { printf("Error: Malformed #define at line %d\n", line-1); continue; } name = p; while (*p != 32 && *p != 0) p++; - if (*p == 32) { + if (*p == 32) + { *(p++) = 0; while (*p == 32) p++; - if (*p == 0) { // #define_NAME with no number + if (*p == 0) // #define_NAME with no number + { printf("Error: No number given for name \"%s\" (line %d)\n", name, line-1); continue; } @@ -6955,12 +7086,14 @@ long loadnames(void) // add to list num = Bstrtol(number, &endptr, 10); - if (*endptr != 0) { + if (*endptr != 0) + { p = endptr; goto badline; } //printf("Grokked \"%s\" -> \"%d\"\n", name, num); - if (num < 0 || num >= MAXTILES) { + if (num < 0 || num >= MAXTILES) + { printf("Error: Constant %d for name \"%s\" out of range (line %d)\n", num, name, line-1); continue; } @@ -6975,12 +7108,17 @@ long loadnames(void) continue; - } else { // #define_NAME with no number + } + else // #define_NAME with no number + { printf("Error: No number given for name \"%s\" (line %d)\n", name, line-1); continue; } - } else goto badline; - } else if (*p == '/') { + } + else goto badline; + } + else if (*p == '/') + { if (*(p+1) == '/') continue; // comment } badline: @@ -6992,12 +7130,12 @@ badline: return 0; } -void printcoords16(long posxe, long posye, short ange) +void printcoords16(int posxe, int posye, short ange) { char snotbuf[80]; - long i,m; + int i,m; - Bsprintf(snotbuf,"x=%ld y=%ld ang=%d",posxe,posye,ange); + Bsprintf(snotbuf,"x=%d y=%d ang=%d",posxe,posye,ange); i = 0; while ((snotbuf[i] != 0) && (i < 30)) i++; @@ -7012,7 +7150,7 @@ void printcoords16(long posxe, long posye, short ange) printext16(8, ydim-STATUS2DSIZ+128+2, 9, 0, snotbuf,0); - Bsprintf(snotbuf,"%d/%d sect. %d/%d walls %ld/%d spri.", + Bsprintf(snotbuf,"%d/%d sect. %d/%d walls %d/%d spri.", numsectors,m?MAXSECTORSV8:MAXSECTORSV7, numwalls,m?MAXWALLSV8:MAXWALLSV7, numsprites,m?MAXSPRITESV8:MAXSPRITESV7); @@ -7031,7 +7169,7 @@ void printcoords16(long posxe, long posye, short ange) void updatenumsprites(void) { - long i; + int i; numsprites = 0; for (i=0;i>8); + Bsprintf(snotbuf,"Pixel height: %d",(sector[sectnum].floorz-sector[sectnum].ceilingz)>>8); printext16(8,ydim-STATUS2DSIZ+104,11,-1,snotbuf,0); printext16(200,ydim-STATUS2DSIZ+32,11,-1,"CEILINGS:",0); @@ -7123,7 +7261,7 @@ void showsectordata(short sectnum) printext16(200,ydim-STATUS2DSIZ+56,11,-1,snotbuf,0); Bsprintf(snotbuf,"Shade byte: %d",sector[sectnum].ceilingshade); printext16(200,ydim-STATUS2DSIZ+64,11,-1,snotbuf,0); - Bsprintf(snotbuf,"Z-coordinate: %ld",sector[sectnum].ceilingz); + Bsprintf(snotbuf,"Z-coordinate: %d",sector[sectnum].ceilingz); printext16(200,ydim-STATUS2DSIZ+72,11,-1,snotbuf,0); Bsprintf(snotbuf,"Tile number: %d",sector[sectnum].ceilingpicnum); printext16(200,ydim-STATUS2DSIZ+80,11,-1,snotbuf,0); @@ -7139,7 +7277,7 @@ void showsectordata(short sectnum) printext16(400,ydim-STATUS2DSIZ+56,11,-1,snotbuf,0); Bsprintf(snotbuf,"Shade byte: %d",sector[sectnum].floorshade); printext16(400,ydim-STATUS2DSIZ+64,11,-1,snotbuf,0); - Bsprintf(snotbuf,"Z-coordinate: %ld",sector[sectnum].floorz); + Bsprintf(snotbuf,"Z-coordinate: %d",sector[sectnum].floorz); printext16(400,ydim-STATUS2DSIZ+72,11,-1,snotbuf,0); Bsprintf(snotbuf,"Tile number: %d",sector[sectnum].floorpicnum); printext16(400,ydim-STATUS2DSIZ+80,11,-1,snotbuf,0); @@ -7151,18 +7289,18 @@ void showsectordata(short sectnum) void showwalldata(short wallnum) { - long dax, day, dist; + int dax, day, dist; char snotbuf[80]; Bsprintf(snotbuf,"Wall %d",wallnum); printext16(8,ydim-STATUS2DSIZ+32,11,-1,snotbuf,0); - Bsprintf(snotbuf,"X-coordinate: %ld",wall[wallnum].x); + Bsprintf(snotbuf,"X-coordinate: %d",wall[wallnum].x); printext16(8,ydim-STATUS2DSIZ+48,11,-1,snotbuf,0); - Bsprintf(snotbuf,"Y-coordinate: %ld",wall[wallnum].y); + Bsprintf(snotbuf,"Y-coordinate: %d",wall[wallnum].y); printext16(8,ydim-STATUS2DSIZ+56,11,-1,snotbuf,0); Bsprintf(snotbuf,"Point2: %d",wall[wallnum].point2); printext16(8,ydim-STATUS2DSIZ+64,11,-1,snotbuf,0); - Bsprintf(snotbuf,"Sector: %ld",sectorofwall(wallnum)); + Bsprintf(snotbuf,"Sector: %d",sectorofwall(wallnum)); printext16(8,ydim-STATUS2DSIZ+72,11,-1,snotbuf,0); Bsprintf(snotbuf,"Tags: %d, %d",wall[wallnum].hitag,wall[wallnum].lotag); @@ -7200,11 +7338,11 @@ void showwalldata(short wallnum) // TX 20050102 I'm not sure what unit dist<<4 is supposed to be, but dist itself is correct in terms of game coordinates as one would expect - Bsprintf(snotbuf,"Wall length: %ld",dist); + Bsprintf(snotbuf,"Wall length: %d",dist); printext16(400,ydim-STATUS2DSIZ+96,11,-1,snotbuf,0); - dax = (long)sectorofwall(wallnum); - Bsprintf(snotbuf,"Pixel height: %ld",(sector[dax].floorz-sector[dax].ceilingz)>>8); + dax = (int)sectorofwall(wallnum); + Bsprintf(snotbuf,"Pixel height: %d",(sector[dax].floorz-sector[dax].ceilingz)>>8); printext16(400,ydim-STATUS2DSIZ+104,11,-1,snotbuf,0); } @@ -7214,11 +7352,11 @@ void showspritedata(short spritenum) Bsprintf(snotbuf,"Sprite %d",spritenum); printext16(8,ydim-STATUS2DSIZ+32,11,-1,snotbuf,0); - Bsprintf(snotbuf,"X-coordinate: %ld",sprite[spritenum].x); + Bsprintf(snotbuf,"X-coordinate: %d",sprite[spritenum].x); printext16(8,ydim-STATUS2DSIZ+48,11,-1,snotbuf,0); - Bsprintf(snotbuf,"Y-coordinate: %ld",sprite[spritenum].y); + Bsprintf(snotbuf,"Y-coordinate: %d",sprite[spritenum].y); printext16(8,ydim-STATUS2DSIZ+56,11,-1,snotbuf,0); - Bsprintf(snotbuf,"Z-coordinate: %ld",sprite[spritenum].z); + Bsprintf(snotbuf,"Z-coordinate: %d",sprite[spritenum].z); printext16(8,ydim-STATUS2DSIZ+64,11,-1,snotbuf,0); Bsprintf(snotbuf,"Sectnum: %d",sprite[spritenum].sectnum); @@ -7263,7 +7401,7 @@ void showspritedata(short spritenum) void keytimerstuff(void) { - static long ltotalclock=0; + static int ltotalclock=0; int i; if (totalclock == ltotalclock) return; ltotalclock=totalclock; @@ -7296,7 +7434,7 @@ void keytimerstuff(void) void _printmessage16(char name[82]) { char snotbuf[60]; - long i; + int i; i = 0; while ((name[i] != 0) && (i < 54)) @@ -7325,7 +7463,7 @@ void printmessage16(char name[82]) void printmessage256(char name[82]) { char snotbuf[40]; - long i; + int i; i = 0; while ((name[i] != 0) && (i < 38)) @@ -7344,10 +7482,10 @@ void printmessage256(char name[82]) } //Find closest point (*dax, *day) on wall (dawall) to (x, y) -void getclosestpointonwall(long x, long y, long dawall, long *nx, long *ny) +void getclosestpointonwall(int x, int y, int dawall, int *nx, int *ny) { walltype *wal; - long i, j, dx, dy; + int i, j, dx, dy; wal = &wall[dawall]; dx = wall[wal->point2].x-wal->x; @@ -7363,7 +7501,7 @@ void getclosestpointonwall(long x, long y, long dawall, long *nx, long *ny) void initcrc(void) { - long i, j, k, a; + int i, j, k, a; for (j=0;j<256;j++) //Calculate CRC table { @@ -7382,9 +7520,9 @@ void initcrc(void) static char visited[MAXWALLS]; -long GetWallZPeg(long nWall) +int GetWallZPeg(int nWall) { - long z=0, nSector, nNextSector; + int z=0, nSector, nNextSector; nSector = sectorofwall((short)nWall); nNextSector = wall[nWall].nextsector; @@ -7410,9 +7548,9 @@ long GetWallZPeg(long nWall) return(z); } -void AlignWalls(long nWall0, long z0, long nWall1, long z1, long nTile) +void AlignWalls(int nWall0, int z0, int nWall1, int z1, int nTile) { - long n; + int n; //do the x alignment wall[nWall1].cstat &= ~0x0108; //Set to non-flip @@ -7426,9 +7564,9 @@ void AlignWalls(long nWall0, long z0, long nWall1, long z1, long nTile) wall[nWall1].ypanning = (char)(wall[nWall0].ypanning+(((z1-z0)*wall[nWall0].yrepeat)>>(n+3))); } -void AutoAlignWalls(long nWall0, long ply) +void AutoAlignWalls(int nWall0, int ply) { - long z0, z1, nTile, nWall1, branch, visible, nNextSector, nSector; + int z0, z1, nTile, nWall1, branch, visible, nNextSector, nSector; nTile = wall[nWall0].picnum; branch = 0; diff --git a/polymer/build/src/cache1d.c b/polymer/build/src/cache1d.c index 29132d097..5d10732ee 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 long kzipopen(char *filnam) +static int kzipopen(char *filnam) { unsigned int i; char newst[BMAX_PATH+4]; @@ -35,12 +35,12 @@ static long kzipopen(char *filnam) // To use this module, here's all you need to do: // // Step 1: Allocate a nice BIG buffer, like from 1MB-4MB and -// Call initcache(long cachestart, long cachesize) where +// Call initcache(int cachestart, int cachesize) where // -// cachestart = (long)(pointer to start of BIG buffer) +// cachestart = (int)(pointer to start of BIG buffer) // cachesize = length of BIG buffer // -// Step 2: Call allocache(long *bufptr, long bufsiz, char *lockptr) +// Step 2: Call allocache(int *bufptr, int bufsiz, char *lockptr) // whenever you need to allocate a buffer, where: // // *bufptr = pointer to 4-byte pointer to buffer @@ -61,13 +61,13 @@ static long kzipopen(char *filnam) #define MAXCACHEOBJECTS 9216 -static long cachesize = 0; -long cachecount = 0; +static int cachesize = 0; +int cachecount = 0; char zerochar = 0; -long cachestart = 0, cacnum = 0, agecount = 0; -typedef struct { long *hand, leng; char *lock ; } cactype; +int cachestart = 0, cacnum = 0, agecount = 0; +typedef struct { int *hand, leng; char *lock ; } cactype; cactype cac[MAXCACHEOBJECTS]; -static long lockrecip[200]; +static int lockrecip[200]; static char toupperlookup[256]; @@ -79,9 +79,9 @@ static void reportandexit(char *errormessage); extern char pow2char[8]; -void initcache(long dacachestart, long dacachesize) +void initcache(int dacachestart, int dacachesize) { - long i; + int i; for (i=1;i<200;i++) lockrecip[i] = (1<<28)/(200-i); @@ -95,16 +95,16 @@ void initcache(long dacachestart, long dacachesize) initprintf("initcache(): Initialised with %d bytes\n", dacachesize); } -void allocache(long *newhandle, long newbytes, char *newlockptr) +void allocache(int *newhandle, int newbytes, char *newlockptr) { - long i, /*j,*/ z, zz, bestz=0, daval, bestval, besto=0, o1, o2, sucklen, suckz; + int i, /*j,*/ z, zz, bestz=0, daval, bestval, besto=0, o1, o2, sucklen, suckz; newbytes = ((newbytes+15)&0xfffffff0); if ((unsigned)newbytes > (unsigned)cachesize) { - Bprintf("Cachesize: %ld\n",cachesize); - Bprintf("*Newhandle: 0x%lx, Newbytes: %ld, *Newlock: %d\n",(long)newhandle,newbytes,*newlockptr); + Bprintf("Cachesize: %d\n",cachesize); + Bprintf("*Newhandle: 0x%x, Newbytes: %d, *Newlock: %d\n",(int)newhandle,newbytes,*newlockptr); reportandexit("BUFFER TOO BIG TO FIT IN CACHE!"); } @@ -124,7 +124,7 @@ void allocache(long *newhandle, long newbytes, char *newlockptr) for (i=o1,zz=z;i= 200) { daval = 0x7fffffff; break; } + if (*cac[zz].lock >= 200) { daval = 0x7fffffff; break; } daval += mulscale32(cac[zz].leng+65536,lockrecip[*cac[zz].lock]); if (daval >= bestval) break; } @@ -135,7 +135,7 @@ void allocache(long *newhandle, long newbytes, char *newlockptr) } } - //printf("%ld %ld %ld\n",besto,newbytes,*newlockptr); + //printf("%d %d %d\n",besto,newbytes,*newlockptr); if (bestval == 0x7fffffff) reportandexit("CACHE SPACE ALL LOCKED UP!"); @@ -164,7 +164,7 @@ void allocache(long *newhandle, long newbytes, char *newlockptr) return; } -if (*cac[bestz].lock == 0) { cac[bestz].leng += sucklen; return; } + if (*cac[bestz].lock == 0) { cac[bestz].leng += sucklen; return; } cacnum++; if (cacnum > MAXCACHEOBJECTS) reportandexit("Too many objects in cache! (cacnum > MAXCACHEOBJECTS)"); for (z=cacnum-1;z>bestz;z--) cac[z] = cac[z-1]; @@ -172,13 +172,13 @@ if (*cac[bestz].lock == 0) { cac[bestz].leng += sucklen; return; } cac[bestz].lock = &zerochar; } -void suckcache(long *suckptr) +void suckcache(int *suckptr) { - long i; + int i; //Can't exit early, because invalid pointer might be same even though lock = 0 for (i=0;i= cacnum) agecount = cacnum-1; @@ -217,30 +217,31 @@ void agecache(void) static void reportandexit(char *errormessage) { - long i, j; + int i, j; //setvmode(0x3); j = 0; for (i=0;i -typedef struct _searchpath { +typedef struct _searchpath +{ struct _searchpath *next; char *path; size_t pathlen; // to save repeated calls to strlen() @@ -256,7 +257,8 @@ int addsearchpath(const char *p) searchpath_t *srch; int i; - if (Bstat(p, &st) < 0) { + if (Bstat(p, &st) < 0) + { if (errno == ENOENT) return -2; return -1; } @@ -268,7 +270,8 @@ int addsearchpath(const char *p) srch->next = searchpathhead; srch->pathlen = strlen(p)+1; srch->path = (char*)malloc(srch->pathlen + 1); - if (!srch->path) { + if (!srch->path) + { free(srch); return -1; } @@ -277,9 +280,9 @@ int addsearchpath(const char *p) searchpathhead = srch; if (srch->pathlen > maxsearchpathlen) maxsearchpathlen = srch->pathlen; - + Bcorrectfilename(srch->path,0); - + initprintf("addsearchpath(): Added %s\n", srch->path); return 0; @@ -294,9 +297,11 @@ int findfrompath(const char *fn, char **where) // pathsearchmode == 0: tests current dir and then the dirs of the path stack // pathsearchmode == 1: tests fn without modification, then like for pathsearchmode == 0 - if (pathsearchmode) { + if (pathsearchmode) + { // test unmolested filename first - if (access(fn, F_OK) >= 0) { + if (access(fn, F_OK) >= 0) + { *where = strdup(fn); return 0; } @@ -312,21 +317,24 @@ int findfrompath(const char *fn, char **where) allocsiz += 1; // a nul pfn = (char *)malloc(allocsiz); -if (!pfn) { free(ffn); return -1; } + if (!pfn) { free(ffn); return -1; } strcpy(pfn, "./"); strcat(pfn, ffn); - if (access(pfn, F_OK) >= 0) { + if (access(pfn, F_OK) >= 0) + { *where = pfn; free(ffn); return 0; } - for (sp = searchpathhead; sp; sp = sp->next) { + for (sp = searchpathhead; sp; sp = sp->next) + { strcpy(pfn, sp->path); strcat(pfn, ffn); //initprintf("Trying %s\n", pfn); - if (access(pfn, F_OK) >= 0) { + if (access(pfn, F_OK) >= 0) + { *where = pfn; free(ffn); return 0; @@ -355,7 +363,8 @@ BFILE* fopenfrompath(const char *fn, const char *mode) int bmode = 0, smode = 0; const char *c; - for (c=mode; c[0]; ) { + for (c=mode; c[0];) + { if (c[0] == 'r' && c[1] == '+') { bmode = BO_RDWR; smode = BS_IREAD|BS_IWRITE; c+=2; } else if (c[0] == 'r') { bmode = BO_RDONLY; smode = BS_IREAD; c+=1; } else if (c[0] == 'w' && c[1] == '+') { bmode = BO_RDWR|BO_CREAT|BO_TRUNC; smode = BS_IREAD|BS_IWRITE; c+=2; } @@ -380,50 +389,50 @@ BFILE* fopenfrompath(const char *fn, const char *mode) #define MAXOPENFILES 64 //Warning: Fix filehan if this is changed static char toupperlookup[256] = - { - 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f, - 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f, - 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, - 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f, - 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f, - 0x60,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f, - 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x7b,0x7c,0x7d,0x7e,0x7f, - 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f, - 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f, - 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf, - 0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0xbe,0xbf, - 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf, - 0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xdb,0xdc,0xdd,0xde,0xdf, - 0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xeb,0xec,0xed,0xee,0xef, - 0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff - }; +{ + 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, + 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f, + 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f, + 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, + 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f, + 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f, + 0x60,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f, + 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x7b,0x7c,0x7d,0x7e,0x7f, + 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f, + 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f, + 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf, + 0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0xbe,0xbf, + 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf, + 0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xdb,0xdc,0xdd,0xde,0xdf, + 0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xeb,0xec,0xed,0xee,0xef, + 0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff +}; -static long numgroupfiles = 0; -static long gnumfiles[MAXGROUPFILES]; -static long groupfil[MAXGROUPFILES] = {-1,-1,-1,-1}; -static long groupfilpos[MAXGROUPFILES]; +static int numgroupfiles = 0; +static int gnumfiles[MAXGROUPFILES]; +static int groupfil[MAXGROUPFILES] = {-1,-1,-1,-1}; +static int groupfilpos[MAXGROUPFILES]; static char *gfilelist[MAXGROUPFILES]; -static long *gfileoffs[MAXGROUPFILES]; +static int *gfileoffs[MAXGROUPFILES]; static char filegrp[MAXOPENFILES]; -static long filepos[MAXOPENFILES]; -static long filehan[MAXOPENFILES] = - { - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 - }; +static int filepos[MAXOPENFILES]; +static int filehan[MAXOPENFILES] = +{ + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 +}; #ifdef WITHKPLIB static char filenamsav[MAXOPENFILES][260]; -static long kzcurhand = -1; +static int kzcurhand = -1; #endif -long initgroupfile(char *filename) +int initgroupfile(char *filename) { char buf[16]; - long i, j, k; + int i, j, k; #ifdef WITHKPLIB char *zfn; searchpath_t *sp = NULL; @@ -439,10 +448,11 @@ long initgroupfile(char *filename) // check to see if the file passed is a ZIP and pass it on to kplib if it is i = Bopen(zfn,BO_BINARY|BO_RDONLY,BS_IREAD); -if (i < 0) { free(zfn); return -1; } + if (i < 0) { free(zfn); return -1; } Bread(i, buf, 4); - if (buf[0] == 0x50 && buf[1] == 0x4B && buf[2] == 0x03 && buf[3] == 0x04) { + if (buf[0] == 0x50 && buf[1] == 0x4B && buf[2] == 0x03 && buf[3] == 0x04) + { Bclose(i); j = kzaddstack(zfn); free(zfn); @@ -470,19 +480,19 @@ if (i < 0) { free(zfn); return -1; } groupfil[numgroupfiles] = -1; return(-1); } - gnumfiles[numgroupfiles] = B_LITTLE32(*((long *)&buf[12])); + gnumfiles[numgroupfiles] = B_LITTLE32(*((int *)&buf[12])); if ((gfilelist[numgroupfiles] = (char *)kmalloc(gnumfiles[numgroupfiles]<<4)) == 0) - { Bprintf("Not enough memory for file grouping system\n"); exit(0); } - if ((gfileoffs[numgroupfiles] = (long *)kmalloc((gnumfiles[numgroupfiles]+1)<<2)) == 0) - { Bprintf("Not enough memory for file grouping system\n"); exit(0); } + { Bprintf("Not enough memory for file grouping system\n"); exit(0); } + if ((gfileoffs[numgroupfiles] = (int *)kmalloc((gnumfiles[numgroupfiles]+1)<<2)) == 0) + { Bprintf("Not enough memory for file grouping system\n"); exit(0); } Bread(groupfil[numgroupfiles],gfilelist[numgroupfiles],gnumfiles[numgroupfiles]<<4); j = 0; for (i=0;i=0;i--) if (groupfil[i] != -1 && groupfil[i] == grphandle) @@ -515,7 +525,8 @@ void uninitsinglegroupfile(long grphandle) // move any group files following this one back for (i=grpnum+1; i= 254) // external file (255) or ZIPped file (254) continue; else if (filegrp[i] == grpnum) // close file in group we closed @@ -537,7 +549,7 @@ void uninitsinglegroupfile(long grphandle) void uninitgroupfile(void) { - long i; + int i; for (i=numgroupfiles-1;i>=0;i--) if (groupfil[i] != -1) @@ -550,15 +562,16 @@ void uninitgroupfile(void) numgroupfiles = 0; // JBF 20040111: "close" any files open in groups - for (i=0;i= 0) filepos[kzcurhand] = kztell(); kzclose(); } - if (searchfirst != 1 && (i = kzipopen(filename)) != 0) { + if (searchfirst != 1 && (i = kzipopen(filename)) != 0) + { kzcurhand = newhandle; filegrp[newhandle] = 254; filehan[newhandle] = i; @@ -613,11 +627,11 @@ long kopen4load(char *filename, char searchfirst) { if (!filename[j]) break; if (toupperlookup[filename[j]] != toupperlookup[gfileptr[j]]) - { bad = 1; break; } + { bad = 1; break; } } if (bad) continue; if (j<13 && gfileptr[j]) continue; // JBF: because e1l1.map might exist before e1l1 - if (j==13 && filename[j]) continue; // JBF: long file name + if (j==13 && filename[j]) continue; // JBF: int file name filegrp[newhandle] = k; filehan[newhandle] = i; @@ -629,9 +643,9 @@ long kopen4load(char *filename, char searchfirst) return(-1); } -long kread(long handle, void *buffer, long leng) +int kread(int handle, void *buffer, int leng) { - long i, filenum, groupnum; + int i, filenum, groupnum; filenum = filehan[handle]; groupnum = filegrp[handle]; @@ -668,9 +682,9 @@ long kread(long handle, void *buffer, long leng) return(0); } -long klseek(long handle, long offset, long whence) +int klseek(int handle, int offset, int whence) { - long i, groupnum; + int i, groupnum; groupnum = filegrp[handle]; @@ -707,12 +721,13 @@ long klseek(long handle, long offset, long whence) return(-1); } -long kfilelength(long handle) +int kfilelength(int handle) { - long i, groupnum; + int i, groupnum; groupnum = filegrp[handle]; - if (groupnum == 255) { + if (groupnum == 255) + { // return(filelength(filehan[handle])) return Bfilelength(filehan[handle]); } @@ -733,9 +748,9 @@ long kfilelength(long handle) return(gfileoffs[groupnum][i+1]-gfileoffs[groupnum][i]); } -long ktell(long handle) +int ktell(int handle) { - long i, groupnum; + int i, groupnum; groupnum = filegrp[handle]; @@ -758,7 +773,7 @@ long ktell(long handle) return(-1); } -void kclose(long handle) +void kclose(int handle) { if (handle < 0) return; if (filegrp[handle] == 255) Bclose(filehan[handle]); @@ -776,11 +791,13 @@ static int klistaddentry(CACHE1D_FIND_REC **rec, char *name, int type, int sourc { CACHE1D_FIND_REC *r = NULL, *attach = NULL; - if (*rec) { + if (*rec) + { int insensitive, v; CACHE1D_FIND_REC *last = NULL; - for (attach = *rec; attach; last = attach, attach = attach->next) { + for (attach = *rec; attach; last = attach, attach = attach->next) + { if (type == CACHE1D_FIND_DRIVE) continue; // we just want to get to the end for drives #ifdef _WIN32 insensitive = 1; @@ -798,7 +815,8 @@ static int klistaddentry(CACHE1D_FIND_REC **rec, char *name, int type, int sourc // sorted list if (v > 0) continue; // item to add is bigger than the current one // so look for something bigger than us - if (v < 0) { // item to add is smaller than the current one + if (v < 0) // item to add is smaller than the current one + { attach = NULL; // so wedge it between the current item and the one before break; } @@ -813,7 +831,8 @@ static int klistaddentry(CACHE1D_FIND_REC **rec, char *name, int type, int sourc if (!attach) attach = last; } - if (r) { + if (r) + { r->type = type; r->source = source; return 0; @@ -826,12 +845,15 @@ static int klistaddentry(CACHE1D_FIND_REC **rec, char *name, int type, int sourc r->source = source; r->usera = r->userb = NULL; - if (!attach) { // we are the first item + if (!attach) // we are the first item + { r->prev = NULL; r->next = *rec; - if (*rec) (*rec)->prev = r; + if (*rec)(*rec)->prev = r; *rec = r; - } else { + } + else + { r->prev = attach; r->next = attach->next; if (attach->next) attach->next->prev = r; @@ -845,7 +867,8 @@ void klistfree(CACHE1D_FIND_REC *rec) { CACHE1D_FIND_REC *n; - while (rec) { + while (rec) + { n = rec->next; free(rec); rec = n; @@ -866,18 +889,20 @@ CACHE1D_FIND_REC *klistpath(const char *_path, const char *mask, int type) // we don't need any leading dots and slashes or trailing slashes either { int i,j; - for (i=0; path[i] == '.' || toupperlookup[path[i]] == '/'; ) i++; + for (i=0; path[i] == '.' || toupperlookup[path[i]] == '/';) i++; for (j=0; (path[j] = path[i]); j++,i++) ; while (j>0 && toupperlookup[path[j-1]] == '/') j--; path[j] = 0; //initprintf("Cleaned up path = \"%s\"\n",path); } - if (*path && (type & CACHE1D_FIND_DIR)) { + if (*path && (type & CACHE1D_FIND_DIR)) + { if (klistaddentry(&rec, "..", CACHE1D_FIND_DIR, CACHE1D_SOURCE_CURDIR) < 0) goto failure; } - if (!(type & CACHE1D_OPT_NOSTACK)) { // current directory and paths in the search stack + if (!(type & CACHE1D_OPT_NOSTACK)) // current directory and paths in the search stack + { searchpath_t *search = NULL; BDIR *dir; struct Bdirent *dirent; @@ -887,15 +912,20 @@ CACHE1D_FIND_REC *klistpath(const char *_path, const char *mask, int type) if (pathsearchmode) d = _path; - do { - if (!pathsearchmode) { + do + { + if (!pathsearchmode) + { strcpy(buf, path); if (*path) strcat(buf, "/"); strcat(buf, d); - } else strcpy(buf, d); + } + else strcpy(buf, d); dir = Bopendir(buf); - if (dir) { - while ((dirent = Breaddir(dir))) { + if (dir) + { + while ((dirent = Breaddir(dir))) + { if ((dirent->name[0] == '.' && dirent->name[1] == 0) || (dirent->name[0] == '.' && dirent->name[1] == '.' && dirent->name[2] == 0)) continue; @@ -904,7 +934,8 @@ CACHE1D_FIND_REC *klistpath(const char *_path, const char *mask, int type) if (!Bwildmatch(dirent->name, mask)) continue; switch (klistaddentry(&rec, dirent->name, (dirent->mode & BS_IFDIR) ? CACHE1D_FIND_DIR : CACHE1D_FIND_FILE, - stackdepth)) { + stackdepth)) + { case -1: goto failure; //case 1: initprintf("%s:%s dropped for lower priority\n", d,dirent->name); break; //case 0: initprintf("%s:%s accepted\n", d,dirent->name); break; @@ -917,24 +948,30 @@ CACHE1D_FIND_REC *klistpath(const char *_path, const char *mask, int type) if (pathsearchmode) break; - if (!search) { + if (!search) + { search = searchpathhead; stackdepth = CACHE1D_SOURCE_PATH; - } else { + } + else + { search = search->next; stackdepth++; } if (search) d = search->path; - } while (search); + } + while (search); } - if (!pathsearchmode) { // next, zip files + if (!pathsearchmode) // next, zip files + { char buf[BMAX_PATH], *p; int i, j, ftype; strcpy(buf,path); if (*path) strcat(buf,"/"); strcat(buf,mask); - for (kzfindfilestart(buf); kzfindfile(buf); ) { + for (kzfindfilestart(buf); kzfindfile(buf);) + { if (buf[0] != '|') continue; // local files we don't need // scan for the end of the string and shift @@ -942,18 +979,20 @@ CACHE1D_FIND_REC *klistpath(const char *_path, const char *mask, int type) for (i=1; (buf[i-1]=buf[i]); i++) ; i-=2; // if there's a slash at the end, this is a directory entry - if (toupperlookup[buf[i]] == '/') { ftype = CACHE1D_FIND_DIR; buf[i] = 0; } + if (toupperlookup[buf[i]] == '/') { ftype = CACHE1D_FIND_DIR; buf[i] = 0; } else ftype = CACHE1D_FIND_FILE; // skip over the common characters at the beginning of the base path and the zip entry - for (j=0; buf[j] && path[j]; j++) { + for (j=0; buf[j] && path[j]; j++) + { if (toupperlookup[ path[j] ] == toupperlookup[ buf[j] ]) continue; break; } // we've now hopefully skipped the common path component at the beginning. // if that's true, we should be staring at a null byte in path and either any character in buf // if j==0, or a slash if j>0 - if ((!path[0] && buf[j]) || (!path[j] && toupperlookup[ buf[j] ] == '/')) { + if ((!path[0] && buf[j]) || (!path[j] && toupperlookup[ buf[j] ] == '/')) + { if (j>0) j++; // yep, so now we shift what follows back to the start of buf and while we do that, @@ -961,7 +1000,9 @@ CACHE1D_FIND_REC *klistpath(const char *_path, const char *mask, int type) // and is useless to us. for (i = 0; (buf[i] = buf[j]) && toupperlookup[buf[j]] != '/'; i++,j++) ; if (toupperlookup[buf[j]] == '/') continue; // damn, try next entry - } else { + } + else + { // if we're here it means we have a situation where: // path = foo // buf = foobar... @@ -976,7 +1017,8 @@ CACHE1D_FIND_REC *klistpath(const char *_path, const char *mask, int type) if ((type & CACHE1D_FIND_FILE) && ftype != CACHE1D_FIND_FILE) continue; // the entry is in the clear - switch (klistaddentry(&rec, buf, ftype, CACHE1D_SOURCE_ZIP)) { + switch (klistaddentry(&rec, buf, ftype, CACHE1D_SOURCE_ZIP)) + { case -1: goto failure; //case 1: initprintf(":%s dropped for lower priority\n", buf); break; @@ -988,17 +1030,20 @@ CACHE1D_FIND_REC *klistpath(const char *_path, const char *mask, int type) } // then, grp files - if (!pathsearchmode && !*path && (type & CACHE1D_FIND_FILE)) { + if (!pathsearchmode && !*path && (type & CACHE1D_FIND_FILE)) + { char buf[13]; int i,j; buf[12] = 0; - for (i=0;i=0;j--) { Bmemcpy(buf,&gfilelist[i][j<<4],12); if (!Bwildmatch(buf,mask)) continue; - switch (klistaddentry(&rec, buf, CACHE1D_FIND_FILE, CACHE1D_SOURCE_GRP)) { + switch (klistaddentry(&rec, buf, CACHE1D_FIND_FILE, CACHE1D_SOURCE_GRP)) + { case -1: goto failure; //case 1: initprintf(":%s dropped for lower priority\n", workspace); break; @@ -1010,12 +1055,16 @@ CACHE1D_FIND_REC *klistpath(const char *_path, const char *mask, int type) } } - if (pathsearchmode && (type & CACHE1D_FIND_DRIVE)) { + if (pathsearchmode && (type & CACHE1D_FIND_DRIVE)) + { char *drives, *drp; drives = Bgetsystemdrives(); - if (drives) { - for (drp=drives; *drp; drp+=strlen(drp)+1) { - if (klistaddentry(&rec, drp, CACHE1D_FIND_DRIVE, CACHE1D_SOURCE_DRIVE) < 0) { + if (drives) + { + for (drp=drives; *drp; drp+=strlen(drp)+1) + { + if (klistaddentry(&rec, drp, CACHE1D_FIND_DRIVE, CACHE1D_SOURCE_DRIVE) < 0) + { free(drives); goto failure; } @@ -1037,39 +1086,39 @@ failure: static char *lzwbuf1, *lzwbuf4, *lzwbuf5, lzwbuflock[5]; static short *lzwbuf2, *lzwbuf3; -static long lzwcompress(char *lzwinbuf, long uncompleng, char *lzwoutbuf); -static long lzwuncompress(char *lzwinbuf, long compleng, char *lzwoutbuf); +static int lzwcompress(char *lzwinbuf, int uncompleng, char *lzwoutbuf); +static int lzwuncompress(char *lzwinbuf, int compleng, char *lzwoutbuf); -int kdfread(void *buffer, bsize_t dasizeof, bsize_t count, long fil) +int kdfread(void *buffer, bsize_t dasizeof, bsize_t count, int fil) { - unsigned long i, j, k, kgoal; + unsigned int i, j, k, kgoal; short leng; char *ptr; lzwbuflock[0] = lzwbuflock[1] = lzwbuflock[2] = lzwbuflock[3] = lzwbuflock[4] = 200; - if (lzwbuf1 == NULL) allocache((long *)&lzwbuf1,LZWSIZE+(LZWSIZE>>4),&lzwbuflock[0]); - if (lzwbuf2 == NULL) allocache((long *)&lzwbuf2,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[1]); - if (lzwbuf3 == NULL) allocache((long *)&lzwbuf3,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[2]); - if (lzwbuf4 == NULL) allocache((long *)&lzwbuf4,LZWSIZE,&lzwbuflock[3]); - if (lzwbuf5 == NULL) allocache((long *)&lzwbuf5,LZWSIZE+(LZWSIZE>>4),&lzwbuflock[4]); + if (lzwbuf1 == NULL) allocache((int *)&lzwbuf1,LZWSIZE+(LZWSIZE>>4),&lzwbuflock[0]); + if (lzwbuf2 == NULL) allocache((int *)&lzwbuf2,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[1]); + if (lzwbuf3 == NULL) allocache((int *)&lzwbuf3,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[2]); + if (lzwbuf4 == NULL) allocache((int *)&lzwbuf4,LZWSIZE,&lzwbuflock[3]); + if (lzwbuf5 == NULL) allocache((int *)&lzwbuf5,LZWSIZE+(LZWSIZE>>4),&lzwbuflock[4]); -if (dasizeof > LZWSIZE) { count *= dasizeof; dasizeof = 1; } + if (dasizeof > LZWSIZE) { count *= dasizeof; dasizeof = 1; } ptr = (char *)buffer; if (kread(fil,&leng,2) != 2) return -1; leng = B_LITTLE16(leng); - if (kread(fil,lzwbuf5,(long)leng) != leng) return -1; - k = 0; kgoal = lzwuncompress(lzwbuf5,(long)leng,lzwbuf4); + if (kread(fil,lzwbuf5,(int)leng) != leng) return -1; + k = 0; kgoal = lzwuncompress(lzwbuf5,(int)leng,lzwbuf4); - copybufbyte(lzwbuf4,ptr,(long)dasizeof); - k += (long)dasizeof; + copybufbyte(lzwbuf4,ptr,(int)dasizeof); + k += (int)dasizeof; for (i=1;i= kgoal) { if (kread(fil,&leng,2) != 2) return -1; leng = B_LITTLE16(leng); - if (kread(fil,lzwbuf5,(long)leng) != leng) return -1; - k = 0; kgoal = lzwuncompress(lzwbuf5,(long)leng,lzwbuf4); + if (kread(fil,lzwbuf5,(int)leng) != leng) return -1; + k = 0; kgoal = lzwuncompress(lzwbuf5,(int)leng,lzwbuf4); } for (j=0;j LZWSIZE) { count *= dasizeof; dasizeof = 1; } int dfread(void *buffer, bsize_t dasizeof, bsize_t count, BFILE *fil) { - unsigned long i, j, k, kgoal; + unsigned int i, j, k, kgoal; short leng; char *ptr; lzwbuflock[0] = lzwbuflock[1] = lzwbuflock[2] = lzwbuflock[3] = lzwbuflock[4] = 200; - if (lzwbuf1 == NULL) allocache((long *)&lzwbuf1,LZWSIZE+(LZWSIZE>>4),&lzwbuflock[0]); - if (lzwbuf2 == NULL) allocache((long *)&lzwbuf2,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[1]); - if (lzwbuf3 == NULL) allocache((long *)&lzwbuf3,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[2]); - if (lzwbuf4 == NULL) allocache((long *)&lzwbuf4,LZWSIZE,&lzwbuflock[3]); - if (lzwbuf5 == NULL) allocache((long *)&lzwbuf5,LZWSIZE+(LZWSIZE>>4),&lzwbuflock[4]); + if (lzwbuf1 == NULL) allocache((int *)&lzwbuf1,LZWSIZE+(LZWSIZE>>4),&lzwbuflock[0]); + if (lzwbuf2 == NULL) allocache((int *)&lzwbuf2,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[1]); + if (lzwbuf3 == NULL) allocache((int *)&lzwbuf3,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[2]); + if (lzwbuf4 == NULL) allocache((int *)&lzwbuf4,LZWSIZE,&lzwbuflock[3]); + if (lzwbuf5 == NULL) allocache((int *)&lzwbuf5,LZWSIZE+(LZWSIZE>>4),&lzwbuflock[4]); -if (dasizeof > LZWSIZE) { count *= dasizeof; dasizeof = 1; } + if (dasizeof > LZWSIZE) { count *= dasizeof; dasizeof = 1; } ptr = (char *)buffer; if (Bfread(&leng,2,1,fil) != 1) return -1; leng = B_LITTLE16(leng); - if (Bfread(lzwbuf5,(long)leng,1,fil) != 1) return -1; - k = 0; kgoal = lzwuncompress(lzwbuf5,(long)leng,lzwbuf4); + if (Bfread(lzwbuf5,(int)leng,1,fil) != 1) return -1; + k = 0; kgoal = lzwuncompress(lzwbuf5,(int)leng,lzwbuf4); - copybufbyte(lzwbuf4,ptr,(long)dasizeof); - k += (long)dasizeof; + copybufbyte(lzwbuf4,ptr,(int)dasizeof); + k += (int)dasizeof; for (i=1;i= kgoal) { if (Bfread(&leng,2,1,fil) != 1) return -1; leng = B_LITTLE16(leng); - if (Bfread(lzwbuf5,(long)leng,1,fil) != 1) return -1; - k = 0; kgoal = lzwuncompress(lzwbuf5,(long)leng,lzwbuf4); + if (Bfread(lzwbuf5,(int)leng,1,fil) != 1) return -1; + k = 0; kgoal = lzwuncompress(lzwbuf5,(int)leng,lzwbuf4); } for (j=0;j LZWSIZE) { count *= dasizeof; dasizeof = 1; } return count; } -void kdfwrite(void *buffer, bsize_t dasizeof, bsize_t count, long fil) +void kdfwrite(void *buffer, bsize_t dasizeof, bsize_t count, int fil) { - unsigned long i, j, k; + unsigned int i, j, k; short leng, swleng; char *ptr; lzwbuflock[0] = lzwbuflock[1] = lzwbuflock[2] = lzwbuflock[3] = lzwbuflock[4] = 200; - if (lzwbuf1 == NULL) allocache((long *)&lzwbuf1,LZWSIZE+(LZWSIZE>>4),&lzwbuflock[0]); - if (lzwbuf2 == NULL) allocache((long *)&lzwbuf2,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[1]); - if (lzwbuf3 == NULL) allocache((long *)&lzwbuf3,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[2]); - if (lzwbuf4 == NULL) allocache((long *)&lzwbuf4,LZWSIZE,&lzwbuflock[3]); - if (lzwbuf5 == NULL) allocache((long *)&lzwbuf5,LZWSIZE+(LZWSIZE>>4),&lzwbuflock[4]); + if (lzwbuf1 == NULL) allocache((int *)&lzwbuf1,LZWSIZE+(LZWSIZE>>4),&lzwbuflock[0]); + if (lzwbuf2 == NULL) allocache((int *)&lzwbuf2,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[1]); + if (lzwbuf3 == NULL) allocache((int *)&lzwbuf3,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[2]); + if (lzwbuf4 == NULL) allocache((int *)&lzwbuf4,LZWSIZE,&lzwbuflock[3]); + if (lzwbuf5 == NULL) allocache((int *)&lzwbuf5,LZWSIZE+(LZWSIZE>>4),&lzwbuflock[4]); -if (dasizeof > LZWSIZE) { count *= dasizeof; dasizeof = 1; } + if (dasizeof > LZWSIZE) { count *= dasizeof; dasizeof = 1; } ptr = (char *)buffer; - copybufbyte(ptr,lzwbuf4,(long)dasizeof); + copybufbyte(ptr,lzwbuf4,(int)dasizeof); k = dasizeof; if (k > LZWSIZE-dasizeof) { leng = (short)lzwcompress(lzwbuf4,k,lzwbuf5); k = 0; swleng = B_LITTLE16(leng); - Bwrite(fil,&swleng,2); Bwrite(fil,lzwbuf5,(long)leng); + Bwrite(fil,&swleng,2); Bwrite(fil,lzwbuf5,(int)leng); } for (i=1;i LZWSIZE) { count *= dasizeof; dasizeof = 1; } if (k > LZWSIZE-dasizeof) { leng = (short)lzwcompress(lzwbuf4,k,lzwbuf5); k = 0; swleng = B_LITTLE16(leng); - Bwrite(fil,&swleng,2); Bwrite(fil,lzwbuf5,(long)leng); + Bwrite(fil,&swleng,2); Bwrite(fil,lzwbuf5,(int)leng); } ptr += dasizeof; } if (k > 0) { leng = (short)lzwcompress(lzwbuf4,k,lzwbuf5); swleng = B_LITTLE16(leng); - Bwrite(fil,&swleng,2); Bwrite(fil,lzwbuf5,(long)leng); + Bwrite(fil,&swleng,2); Bwrite(fil,lzwbuf5,(int)leng); } lzwbuflock[0] = lzwbuflock[1] = lzwbuflock[2] = lzwbuflock[3] = lzwbuflock[4] = 1; } void dfwrite(void *buffer, bsize_t dasizeof, bsize_t count, BFILE *fil) { - unsigned long i, j, k; + unsigned int i, j, k; short leng, swleng; char *ptr; lzwbuflock[0] = lzwbuflock[1] = lzwbuflock[2] = lzwbuflock[3] = lzwbuflock[4] = 200; - if (lzwbuf1 == NULL) allocache((long *)&lzwbuf1,LZWSIZE+(LZWSIZE>>4),&lzwbuflock[0]); - if (lzwbuf2 == NULL) allocache((long *)&lzwbuf2,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[1]); - if (lzwbuf3 == NULL) allocache((long *)&lzwbuf3,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[2]); - if (lzwbuf4 == NULL) allocache((long *)&lzwbuf4,LZWSIZE,&lzwbuflock[3]); - if (lzwbuf5 == NULL) allocache((long *)&lzwbuf5,LZWSIZE+(LZWSIZE>>4),&lzwbuflock[4]); + if (lzwbuf1 == NULL) allocache((int *)&lzwbuf1,LZWSIZE+(LZWSIZE>>4),&lzwbuflock[0]); + if (lzwbuf2 == NULL) allocache((int *)&lzwbuf2,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[1]); + if (lzwbuf3 == NULL) allocache((int *)&lzwbuf3,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[2]); + if (lzwbuf4 == NULL) allocache((int *)&lzwbuf4,LZWSIZE,&lzwbuflock[3]); + if (lzwbuf5 == NULL) allocache((int *)&lzwbuf5,LZWSIZE+(LZWSIZE>>4),&lzwbuflock[4]); -if (dasizeof > LZWSIZE) { count *= dasizeof; dasizeof = 1; } + if (dasizeof > LZWSIZE) { count *= dasizeof; dasizeof = 1; } ptr = (char *)buffer; - copybufbyte(ptr,lzwbuf4,(long)dasizeof); + copybufbyte(ptr,lzwbuf4,(int)dasizeof); k = dasizeof; if (k > LZWSIZE-dasizeof) { leng = (short)lzwcompress(lzwbuf4,k,lzwbuf5); k = 0; swleng = B_LITTLE16(leng); - Bfwrite(&swleng,2,1,fil); Bfwrite(lzwbuf5,(long)leng,1,fil); + Bfwrite(&swleng,2,1,fil); Bfwrite(lzwbuf5,(int)leng,1,fil); } for (i=1;i LZWSIZE) { count *= dasizeof; dasizeof = 1; } if (k > LZWSIZE-dasizeof) { leng = (short)lzwcompress(lzwbuf4,k,lzwbuf5); k = 0; swleng = B_LITTLE16(leng); - Bfwrite(&swleng,2,1,fil); Bfwrite(lzwbuf5,(long)leng,1,fil); + Bfwrite(&swleng,2,1,fil); Bfwrite(lzwbuf5,(int)leng,1,fil); } ptr += dasizeof; } if (k > 0) { leng = (short)lzwcompress(lzwbuf4,k,lzwbuf5); swleng = B_LITTLE16(leng); - Bfwrite(&swleng,2,1,fil); Bfwrite(lzwbuf5,(long)leng,1,fil); + Bfwrite(&swleng,2,1,fil); Bfwrite(lzwbuf5,(int)leng,1,fil); } lzwbuflock[0] = lzwbuflock[1] = lzwbuflock[2] = lzwbuflock[3] = lzwbuflock[4] = 1; } -static long lzwcompress(char *lzwinbuf, long uncompleng, char *lzwoutbuf) +static int lzwcompress(char *lzwinbuf, int uncompleng, char *lzwoutbuf) { - long i, addr, newaddr, addrcnt, zx, *intptr; - long bytecnt1, bitcnt, numbits, oneupnumbits; + int i, addr, newaddr, addrcnt, zx, *intptr; + int bytecnt1, bitcnt, numbits, oneupnumbits; short *shortptr; for (i=255;i>=0;i--) { lzwbuf1[i] = i; lzwbuf3[i] = (i+1)&255; } @@ -1225,7 +1274,7 @@ static long lzwcompress(char *lzwinbuf, long uncompleng, char *lzwoutbuf) { bytecnt1++; if (bytecnt1 == uncompleng) break; - if (lzwbuf2[addr] < 0) {lzwbuf2[addr] = addrcnt; break;} + if (lzwbuf2[addr] < 0) {lzwbuf2[addr] = addrcnt; break;} newaddr = lzwbuf2[addr]; while (lzwbuf1[newaddr] != lzwinbuf[bytecnt1]) { @@ -1235,22 +1284,24 @@ static long lzwcompress(char *lzwinbuf, long uncompleng, char *lzwoutbuf) } if (lzwbuf3[newaddr] == addrcnt) break; addr = newaddr; - } while (addr >= 0); + } + while (addr >= 0); lzwbuf1[addrcnt] = lzwinbuf[bytecnt1]; lzwbuf2[addrcnt] = -1; lzwbuf3[addrcnt] = -1; - intptr = (long *)&lzwoutbuf[bitcnt>>3]; + intptr = (int *)&lzwoutbuf[bitcnt>>3]; intptr[0] |= B_LITTLE32(addr<<(bitcnt&7)); bitcnt += numbits; if ((addr&((oneupnumbits>>1)-1)) > ((addrcnt-1)&((oneupnumbits>>1)-1))) bitcnt--; addrcnt++; - if (addrcnt > oneupnumbits) { numbits++; oneupnumbits <<= 1; } - } while ((bytecnt1 < uncompleng) && (bitcnt < (uncompleng<<3))); + if (addrcnt > oneupnumbits) { numbits++; oneupnumbits <<= 1; } + } + while ((bytecnt1 < uncompleng) && (bitcnt < (uncompleng<<3))); - intptr = (long *)&lzwoutbuf[bitcnt>>3]; + intptr = (int *)&lzwoutbuf[bitcnt>>3]; intptr[0] |= B_LITTLE32(addr<<(bitcnt&7)); bitcnt += numbits; if ((addr&((oneupnumbits>>1)-1)) > ((addrcnt-1)&((oneupnumbits>>1)-1))) @@ -1268,29 +1319,29 @@ static long lzwcompress(char *lzwinbuf, long uncompleng, char *lzwoutbuf) return(uncompleng+4); } -static long lzwuncompress(char *lzwinbuf, long compleng, char *lzwoutbuf) +static int lzwuncompress(char *lzwinbuf, int compleng, char *lzwoutbuf) { - long strtot, currstr, numbits, oneupnumbits; - long i, dat, leng, bitcnt, outbytecnt, *intptr; + int strtot, currstr, numbits, oneupnumbits; + int i, dat, leng, bitcnt, outbytecnt, *intptr; short *shortptr; shortptr = (short *)lzwinbuf; - strtot = (long)B_LITTLE16(shortptr[1]); + strtot = (int)B_LITTLE16(shortptr[1]); if (strtot == 0) { copybuf(lzwinbuf+4,lzwoutbuf,((compleng-4)+3)>>2); - return((long)B_LITTLE16(shortptr[0])); //uncompleng + return((int)B_LITTLE16(shortptr[0])); //uncompleng } for (i=255;i>=0;i--) { lzwbuf2[i] = i; lzwbuf3[i] = i; } currstr = 256; bitcnt = (4<<3); outbytecnt = 0; numbits = 8; oneupnumbits = (1<<8); do { - intptr = (long *)&lzwinbuf[bitcnt>>3]; + intptr = (int *)&lzwinbuf[bitcnt>>3]; dat = ((B_LITTLE32(intptr[0])>>(bitcnt&7)) & (oneupnumbits-1)); bitcnt += numbits; if ((dat&((oneupnumbits>>1)-1)) > ((currstr-1)&((oneupnumbits>>1)-1))) - { dat &= ((oneupnumbits>>1)-1); bitcnt--; } + { dat &= ((oneupnumbits>>1)-1); bitcnt--; } lzwbuf3[currstr] = dat; @@ -1302,9 +1353,10 @@ static long lzwuncompress(char *lzwinbuf, long compleng, char *lzwoutbuf) lzwbuf2[currstr-1] = dat; lzwbuf2[currstr] = dat; currstr++; - if (currstr > oneupnumbits) { numbits++; oneupnumbits <<= 1; } - } while (currstr < strtot); - return((long)B_LITTLE16(shortptr[0])); //uncompleng + if (currstr > oneupnumbits) { numbits++; oneupnumbits <<= 1; } + } + while (currstr < strtot); + return((int)B_LITTLE16(shortptr[0])); //uncompleng } /* diff --git a/polymer/build/src/compat.c b/polymer/build/src/compat.c index 3695b8d97..ffaf8efe3 100644 --- a/polymer/build/src/compat.c +++ b/polymer/build/src/compat.c @@ -95,7 +95,8 @@ bssize_t Bread(int fd, void *buf, bsize_t count) int Blseek(int fildes, int offset, int whence) { - switch (whence) { + switch (whence) + { case BSEEK_SET: whence=SEEK_SET; break; case BSEEK_CUR: @@ -225,17 +226,17 @@ int Batoi(const char *nptr) return atoi(nptr); } -long Batol(const char *nptr) +int Batol(const char *nptr) { return atol(nptr); } -long int Bstrtol(const char *nptr, char **endptr, int base) +int int Bstrtol(const char *nptr, char **endptr, int base) { return strtol(nptr,endptr,base); } -unsigned long int Bstrtoul(const char *nptr, char **endptr, int base) +unsigned int int Bstrtoul(const char *nptr, char **endptr, int base) { return strtoul(nptr,endptr,base); } @@ -396,7 +397,8 @@ int Bcorrectfilename(char *filename, int removefn) fn = strdup(filename); if (!fn) return -1; - for (first=fn; *first; first++) { + for (first=fn; *first; first++) + { #ifdef _WIN32 if (*first == '\\') *first = '/'; #endif @@ -405,7 +407,8 @@ int Bcorrectfilename(char *filename, int removefn) trailslash = (first>fn && first[-1] == '/'); first = fn; - do { + do + { token = Bstrtoken(first, "/", &next, 1); first = NULL; if (!token) break; @@ -413,14 +416,16 @@ int Bcorrectfilename(char *filename, int removefn) else if (token[0] == '.' && token[1] == 0) continue; else if (token[0] == '.' && token[1] == '.' && token[2] == 0) ntok = max(0,ntok-1); else tokarr[ntok++] = token; - } while (1); + } + while (1); -if (!trailslash && removefn) { ntok = max(0,ntok-1); trailslash = 1; } + if (!trailslash && removefn) { ntok = max(0,ntok-1); trailslash = 1; } if (ntok == 0 && trailslash && leadslash) trailslash = 0; first = filename; if (leadslash) *(first++) = '/'; - for (i=0; i0) *(first++) = '/'; for (token=tokarr[i]; *token; token++) *(first++) = *token; @@ -442,7 +447,8 @@ int Bcanonicalisefilename(char *filename, int removefn) #ifdef _WIN32 { - if (filename[0] && filename[1] == ':') { + if (filename[0] && filename[1] == ':') + { // filename is prefixed with a drive drv = toupper(filename[0])-'A' + 1; fnp += 2; @@ -460,11 +466,14 @@ int Bcanonicalisefilename(char *filename, int removefn) for (p=fn; *p; p++) if (*p == '\\') *p = '/'; #endif - if (fn[0] != '/') { + if (fn[0] != '/') + { // we are dealing with a path relative to the current directory strcpy(filename, cwd); strcat(filename, fn); - } else { + } + else + { #ifdef _WIN32 filename[0] = cwd[0]; filename[1] = ':'; @@ -492,7 +501,8 @@ char *Bgetsystemdrives(void) drv = GetLogicalDrives(); if (drv == 0) return NULL; - for (mask=1; mask<0x8000000l; mask<<=1) { + for (mask=1; mask<0x8000000l; mask<<=1) + { if ((drv&mask) == 0) continue; number++; } @@ -501,7 +511,8 @@ char *Bgetsystemdrives(void) if (!str) return NULL; number = 0; - for (mask=1; mask<0x8000000l; mask<<=1, number++) { + for (mask=1; mask<0x8000000l; mask<<=1, number++) + { if ((drv&mask) == 0) continue; *(p++) = 'A' + number; *(p++) = ':'; @@ -517,17 +528,18 @@ char *Bgetsystemdrives(void) } -long Bfilelength(int fd) +int Bfilelength(int fd) { struct stat st; if (fstat(fd, &st) < 0) return -1; - return(long)(st.st_size); + return(int)(st.st_size); } -typedef struct { +typedef struct +{ #ifdef _MSC_VER - long dir; + int dir; struct _finddata_t fid; #else DIR *dir; @@ -547,7 +559,8 @@ BDIR* Bopendir(const char *name) #endif dirr = (BDIR_real*)malloc(sizeof(BDIR_real) + strlen(name)); - if (!dirr) { + if (!dirr) + { #ifdef _MSC_VER free(t); #endif @@ -566,13 +579,15 @@ BDIR* Bopendir(const char *name) dirr->dir = _findfirst(t,&dirr->fid); free(t); - if (dirr->dir == -1) { + if (dirr->dir == -1) + { free(dirr); return NULL; } #else dirr->dir = opendir(name); - if (dirr->dir == NULL) { + if (dirr->dir == NULL) + { free(dirr); return NULL; } @@ -592,8 +607,10 @@ struct Bdirent* Breaddir(BDIR *dir) char *fn; #ifdef _MSC_VER - if (dirr->status > 0) { - if (_findnext(dirr->dir,&dirr->fid) != 0) { + if (dirr->status > 0) + { + if (_findnext(dirr->dir,&dirr->fid) != 0) + { dirr->status = -1; return NULL; } @@ -603,10 +620,13 @@ struct Bdirent* Breaddir(BDIR *dir) dirr->status++; #else de = readdir(dirr->dir); - if (de == NULL) { + if (de == NULL) + { dirr->status = -1; return NULL; - } else { + } + else + { dirr->status++; } //# if defined(__WATCOMC__) || defined(__linux) || defined(__BEOS__) || defined(__QNX__) || defined(SKYOS) @@ -621,9 +641,11 @@ struct Bdirent* Breaddir(BDIR *dir) dirr->info.mtime = 0; fn = (char *)malloc(strlen(dirr->name) + 1 + dirr->info.namlen + 1); - if (fn) { + if (fn) + { sprintf(fn,"%s/%s",dirr->name,dirr->info.name); - if (!stat(fn, &st)) { + if (!stat(fn, &st)) + { dirr->info.mode = st.st_mode; dirr->info.size = st.st_size; dirr->info.mtime = st.st_mtime; @@ -661,14 +683,16 @@ char *Bstrtoken(char *s, char *delim, char **ptrptr, int chop) if (!p) return NULL; while (*p != 0 && strchr(delim, *p)) p++; - if (*p == 0) { + if (*p == 0) + { *ptrptr = NULL; return NULL; } start = p; while (*p != 0 && !strchr(delim, *p)) p++; if (*p == 0) *ptrptr = NULL; - else { + else + { if (chop) *(p++) = 0; *ptrptr = p; } @@ -680,7 +704,7 @@ char *Bstrtoken(char *s, char *delim, char **ptrptr, int chop) //Brute-force case-insensitive, slash-insensitive, * and ? wildcard matcher //Given: string i and string j. string j can have wildcards //Returns: 1:matches, 0:doesn't match -long Bwildmatch (const char *i, const char *j) +int Bwildmatch(const char *i, const char *j) { const char *k; char c0, c1; @@ -694,7 +718,7 @@ long Bwildmatch (const char *i, const char *j) continue; } if (!*i) return(0); - if (*j == '?') { i++; j++; continue; } + if (*j == '?') { i++; j++; continue; } c0 = *i; if ((c0 >= 'a') && (c0 <= 'z')) c0 -= 32; c1 = *j; if ((c1 >= 'a') && (c1 <= 'z')) c1 -= 32; #ifdef _WIN32 @@ -703,7 +727,8 @@ long Bwildmatch (const char *i, const char *j) #endif if (c0 != c1) return(0); i++; j++; - } while (*j); + } + while (*j); return(!*i); } @@ -712,7 +737,7 @@ char *Bstrlwr(char *s) { char *t = s; if (!s) return s; -while (*t) { *t = Btolower(*t); t++; } + while (*t) { *t = Btolower(*t); t++; } return s; } @@ -720,7 +745,7 @@ char *Bstrupr(char *s) { char *t = s; if (!s) return s; -while (*t) { *t = Btoupper(*t); t++; } + while (*t) { *t = Btoupper(*t); t++; } return s; } #endif @@ -737,7 +762,7 @@ unsigned int Bgetsysmemsize(void) return (unsigned int)memst.dwTotalPhys; #elif (defined(_SC_PAGE_SIZE) || defined(_SC_PAGESIZE)) && defined(_SC_PHYS_PAGES) unsigned int siz = 0x7fffffff; - long scpagesiz, scphyspages; + int scpagesiz, scphyspages; #ifdef _SC_PAGE_SIZE scpagesiz = sysconf(_SC_PAGE_SIZE); diff --git a/polymer/build/src/config.c b/polymer/build/src/config.c index 735457861..a4acc40ee 100644 --- a/polymer/build/src/config.c +++ b/polymer/build/src/config.c @@ -11,10 +11,10 @@ #endif #include "baselayer.h" -static long vesares[13][2] = {{320,200},{360,200},{320,240},{360,240},{320,400}, - {360,400},{640,350},{640,400},{640,480},{800,600}, - {1024,768},{1280,1024},{1600,1200} - }; +static int vesares[13][2] = {{320,200},{360,200},{320,240},{360,240},{320,400}, + {360,400},{640,350},{640,400},{640,480},{800,600}, + {1024,768},{1280,1024},{1600,1200} +}; static int readconfig(BFILE *fp, const char *key, char *value, unsigned len) { @@ -25,7 +25,8 @@ static int readconfig(BFILE *fp, const char *key, char *value, unsigned len) Brewind(fp); - while (1) { + while (1) + { if (!Bfgets(buf, 1000, fp)) return 0; if (buf[0] == ';') continue; @@ -55,11 +56,11 @@ static int readconfig(BFILE *fp, const char *key, char *value, unsigned len) } extern short brightness; -extern long fullscreen; +extern int fullscreen; extern char option[8]; extern char keys[NUMBUILDKEYS]; extern double msens; -extern long editorgridextent; +extern int editorgridextent; /* * SETUP.DAT @@ -108,13 +109,15 @@ int loadsetup(const char *fn) if ((fp = Bfopen(fn, "rt")) == NULL) return -1; -if (readconfig(fp, "forcesetup", val, VL) > 0) { if (Batoi(val) != 0) forcesetup = 1; else forcesetup = 0; } -if (readconfig(fp, "fullscreen", val, VL) > 0) { if (Batoi(val) != 0) fullscreen = 1; else fullscreen = 0; } - if (readconfig(fp, "resolution", val, VL) > 0) { + if (readconfig(fp, "forcesetup", val, VL) > 0) { if (Batoi(val) != 0) forcesetup = 1; else forcesetup = 0; } + if (readconfig(fp, "fullscreen", val, VL) > 0) { if (Batoi(val) != 0) fullscreen = 1; else fullscreen = 0; } + if (readconfig(fp, "resolution", val, VL) > 0) + { i = Batoi(val) & 0x0f; if ((unsigned)i<13) { xdimgame = xdim2d = vesares[i][0]; ydimgame = ydim2d = vesares[i][1]; } } - if (readconfig(fp, "2dresolution", val, VL) > 0) { + if (readconfig(fp, "2dresolution", val, VL) > 0) + { i = Batoi(val) & 0x0f; if ((unsigned)i<13) { xdim2d = vesares[i][0]; ydim2d = vesares[i][1]; } } @@ -123,11 +126,11 @@ if (readconfig(fp, "fullscreen", val, VL) > 0) { if (Batoi(val) != 0) fullscreen if (readconfig(fp, "xdim3d", val, VL) > 0) xdimgame = Batoi(val); if (readconfig(fp, "ydim3d", val, VL) > 0) ydimgame = Batoi(val); if (readconfig(fp, "samplerate", val, VL) > 0) option[7] = (Batoi(val) & 0x0f) << 4; -if (readconfig(fp, "music", val, VL) > 0) { if (Batoi(val) != 0) option[2] = 1; else option[2] = 0; } -if (readconfig(fp, "mouse", val, VL) > 0) { if (Batoi(val) != 0) option[3] = 1; else option[3] = 0; } + if (readconfig(fp, "music", val, VL) > 0) { if (Batoi(val) != 0) option[2] = 1; else option[2] = 0; } + if (readconfig(fp, "mouse", val, VL) > 0) { if (Batoi(val) != 0) option[3] = 1; else option[3] = 0; } if (readconfig(fp, "bpp", val, VL) > 0) bppgame = Batoi(val); if (readconfig(fp, "editorgridextent", val, VL) > 0) editorgridextent = max(min(524288,Batoi(val)),65536); -if (readconfig(fp, "renderer", val, VL) > 0) { i = Batoi(val); setrendermode(i); } + if (readconfig(fp, "renderer", val, VL) > 0) { i = Batoi(val); setrendermode(i); } if (readconfig(fp, "brightness", val, VL) > 0) brightness = min(max(Batoi(val),0),15); #ifdef RENDERTYPEWIN @@ -135,18 +138,22 @@ if (readconfig(fp, "renderer", val, VL) > 0) { i = Batoi(val); setrendermode(i); #endif #if defined(POLYMOST) && defined(USE_OPENGL) glusetexcache = glusetexcachecompression = -1; - if (readconfig(fp, "glusetexcache", val, VL) > 0) { + if (readconfig(fp, "glusetexcache", val, VL) > 0) + { if (Batoi(val) != 0) glusetexcache = 1; else glusetexcache = 0; } - if (readconfig(fp, "glusetexcachecompression", val, VL) > 0) { + if (readconfig(fp, "glusetexcachecompression", val, VL) > 0) + { if (Batoi(val) != 0) glusetexcachecompression = 1; else glusetexcachecompression = 0; } - if (readconfig(fp, "gltexfiltermode", val, VL) > 0) { + if (readconfig(fp, "gltexfiltermode", val, VL) > 0) + { gltexfiltermode = Batoi(val); } - if (readconfig(fp, "glanisotropy", val, VL) > 0) { + if (readconfig(fp, "glanisotropy", val, VL) > 0) + { glanisotropy = Batoi(val); } #endif @@ -184,9 +191,9 @@ if (readconfig(fp, "renderer", val, VL) > 0) { i = Batoi(val); setrendermode(i); if (readconfig(fp, "windowposx", val, VL) > 0) windowx = Batoi(val); windowy = -1; if (readconfig(fp, "windowposy", val, VL) > 0) windowy = Batoi(val); -#endif +#endif -if (readconfig(fp, "keyconsole", val, VL) > 0) { keys[19] = Bstrtol(val, NULL, 16); OSD_CaptureKey(keys[19]); } + if (readconfig(fp, "keyconsole", val, VL) > 0) { keys[19] = Bstrtol(val, NULL, 16); OSD_CaptureKey(keys[19]); } if (readconfig(fp, "mousesensitivity", val, VL) > 0) msens = Bstrtod(val, NULL); Bfclose(fp); @@ -205,31 +212,31 @@ int writesetup(const char *fn) "; Always show configuration options on startup\n" "; 0 - No\n" "; 1 - Yes\n" - "forcesetup = %ld\n" + "forcesetup = %d\n" "\n" "; Video mode selection\n" "; 0 - Windowed\n" "; 1 - Fullscreen\n" - "fullscreen = %ld\n" + "fullscreen = %d\n" "\n" "; Video resolution\n" - "xdim2d = %ld\n" - "ydim2d = %ld\n" - "xdim3d = %ld\n" - "ydim3d = %ld\n" + "xdim2d = %d\n" + "ydim2d = %d\n" + "xdim3d = %d\n" + "ydim3d = %d\n" "\n" "; 3D-mode colour depth\n" - "bpp = %ld\n" + "bpp = %d\n" "\n" "; Grid limits\n" - "editorgridextent = %ld\n" + "editorgridextent = %d\n" "\n" #if defined(POLYMOST) && defined(USE_OPENGL) "; OpenGL mode options\n" - "glusetexcache = %ld\n" - "glusetexcachecompression = %ld\n" - "gltexfiltermode = %ld\n" - "glanisotropy = %ld\n" + "glusetexcache = %d\n" + "glusetexcachecompression = %d\n" + "gltexfiltermode = %d\n" + "glanisotropy = %d\n" "\n" #endif @@ -248,7 +255,7 @@ int writesetup(const char *fn) "; 15 - highest\n" "brightness = %d\n" "\n" -#if 0 +#if 0 "; Sound sample frequency\n" "; 0 - 6 KHz\n" "; 1 - 8 KHz\n" @@ -264,7 +271,7 @@ int writesetup(const char *fn) "; 1 - On\n" "music = %d\n" "\n" -#endif +#endif "; Enable mouse\n" "; 0 - No\n" "; 1 - Yes\n" @@ -273,7 +280,7 @@ int writesetup(const char *fn) "; Mouse sensitivity\n" "mousesensitivity = %g\n" "\n" -#if 1 +#if 1 "; Key Settings\n" "; Here's a map of all the keyboard scan codes: NOTE: values are listed in hex!\n" "; +---------------------------------------------------------------------------------------------+\n" @@ -328,17 +335,17 @@ int writesetup(const char *fn) #ifdef RENDERTYPEWIN maxrefreshfreq, windowpos, windowx, windowy, #endif - brightness, + brightness, #if 0 option[7]>>4, option[2], -#endif +#endif option[3], msens, -#if 1 +#if 1 keys[0], keys[1], keys[2], keys[3], keys[4], keys[5], keys[6], keys[7], keys[8], keys[9], keys[10], keys[11], keys[12], keys[13], keys[14], keys[15], keys[16], keys[17], keys[18], -#endif +#endif keys[19] ); diff --git a/polymer/build/src/crc32.c b/polymer/build/src/crc32.c index 85221d194..947535450 100644 --- a/polymer/build/src/crc32.c +++ b/polymer/build/src/crc32.c @@ -2,7 +2,7 @@ /* // this table of numbers is borrowed from the InfoZip source. -static unsigned long crc32table[256] = { +static unsigned int crc32table[256] = { 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, @@ -58,45 +58,46 @@ static unsigned long crc32table[256] = { }; */ -static unsigned long crc32table[256]; +static unsigned int crc32table[256]; void initcrc32table(void) { - unsigned long i,j,k; + unsigned int i,j,k; // algorithm and polynomial same as that used by infozip's zip - for (i=0; i<256; i++) { + for (i=0; i<256; i++) + { j = i; for (k=8; k; k--) - j = (j&1) ? (0xedb88320L ^ (j>>1)) : (j>>1); + j = (j&1) ? (0xedb88320L ^(j>>1)) : (j>>1); crc32table[i] = j; } } -unsigned long crc32once(unsigned char *blk, unsigned long len) +unsigned int crc32once(unsigned char *blk, unsigned int len) { - unsigned long crc; + unsigned int crc; crc32init(&crc); crc32block(&crc, blk, len); return crc32finish(&crc); } -void crc32init(unsigned long *crcvar) +void crc32init(unsigned int *crcvar) { if (!crcvar) return; *crcvar = 0xffffffffl; } -void crc32block(unsigned long *crcvar, unsigned char *blk, unsigned long len) +void crc32block(unsigned int *crcvar, unsigned char *blk, unsigned int len) { - unsigned long crc = *crcvar; - while (len--) crc = crc32table[(crc ^ *(blk++)) & 0xffl] ^ (crc >> 8); + unsigned int crc = *crcvar; + while (len--) crc = crc32table[(crc ^ *(blk++)) & 0xffl] ^(crc >> 8); *crcvar = crc; } -unsigned long crc32finish(unsigned long *crcvar) +unsigned int crc32finish(unsigned int *crcvar) { *crcvar = *crcvar ^ 0xffffffffl; return *crcvar; diff --git a/polymer/build/src/defs.c b/polymer/build/src/defs.c index 7002bb2d0..61b487091 100644 --- a/polymer/build/src/defs.c +++ b/polymer/build/src/defs.c @@ -12,7 +12,8 @@ #include "cache1d.h" #include "kplib.h" -enum { +enum +{ T_EOF = -2, T_ERROR = -1, T_INCLUDE = 0, @@ -72,140 +73,150 @@ enum { typedef struct { char *text; int tokenid; } tokenlist; static tokenlist basetokens[] = - { - { "include", T_INCLUDE }, - { "#include", T_INCLUDE }, - { "define", T_DEFINE }, - { "#define", T_DEFINE }, +{ + { "include", T_INCLUDE }, + { "#include", T_INCLUDE }, + { "define", T_DEFINE }, + { "#define", T_DEFINE }, - // deprecated style - { "definetexture", T_DEFINETEXTURE }, - { "defineskybox", T_DEFINESKYBOX }, - { "definetint", T_DEFINETINT }, - { "definemodel", T_DEFINEMODEL }, - { "definemodelframe",T_DEFINEMODELFRAME }, - { "definemodelanim", T_DEFINEMODELANIM }, - { "definemodelskin", T_DEFINEMODELSKIN }, - { "selectmodelskin", T_SELECTMODELSKIN }, - { "definevoxel", T_DEFINEVOXEL }, - { "definevoxeltiles",T_DEFINEVOXELTILES }, + // deprecated style + { "definetexture", T_DEFINETEXTURE }, + { "defineskybox", T_DEFINESKYBOX }, + { "definetint", T_DEFINETINT }, + { "definemodel", T_DEFINEMODEL }, + { "definemodelframe",T_DEFINEMODELFRAME }, + { "definemodelanim", T_DEFINEMODELANIM }, + { "definemodelskin", T_DEFINEMODELSKIN }, + { "selectmodelskin", T_SELECTMODELSKIN }, + { "definevoxel", T_DEFINEVOXEL }, + { "definevoxeltiles",T_DEFINEVOXELTILES }, - // new style + // new style - { "model", T_MODEL }, - { "voxel", T_VOXEL }, - { "skybox", T_SKYBOX }, - { "tint", T_TINT }, - { "texture", T_TEXTURE }, - { "tile", T_TEXTURE }, + { "model", T_MODEL }, + { "voxel", T_VOXEL }, + { "skybox", T_SKYBOX }, + { "tint", T_TINT }, + { "texture", T_TEXTURE }, + { "tile", T_TEXTURE }, - // other stuff - { "undefmodel", T_UNDEFMODEL }, - { "undefmodelrange", T_UNDEFMODELRANGE }, - { "undefmodelof", T_UNDEFMODELOF }, - { "undeftexture", T_UNDEFTEXTURE }, - { "undeftexturerange", T_UNDEFTEXTURERANGE }, - { "alphahack", T_ALPHAHACK }, - { "alphahackrange", T_ALPHAHACKRANGE }, - { "spritecol", T_SPRITECOL }, - { "2dcol", T_2DCOL }, - { "fogpal", T_FOGPAL }, - { "loadgrp", T_LOADGRP }, - { "dummytile", T_DUMMYTILE }, - { "dummytilerange", T_DUMMYTILERANGE }, - { "cachesize", T_CACHESIZE }, - }; + // other stuff + { "undefmodel", T_UNDEFMODEL }, + { "undefmodelrange", T_UNDEFMODELRANGE }, + { "undefmodelof", T_UNDEFMODELOF }, + { "undeftexture", T_UNDEFTEXTURE }, + { "undeftexturerange", T_UNDEFTEXTURERANGE }, + { "alphahack", T_ALPHAHACK }, + { "alphahackrange", T_ALPHAHACKRANGE }, + { "spritecol", T_SPRITECOL }, + { "2dcol", T_2DCOL }, + { "fogpal", T_FOGPAL }, + { "loadgrp", T_LOADGRP }, + { "dummytile", T_DUMMYTILE }, + { "dummytilerange", T_DUMMYTILERANGE }, + { "cachesize", T_CACHESIZE }, +}; -static tokenlist modeltokens[] = { - { "scale", T_SCALE }, - { "shade", T_SHADE }, - { "zadd", T_ZADD }, - { "frame", T_FRAME }, - { "anim", T_ANIM }, - { "skin", T_SKIN }, - { "glow", T_GLOW }, - { "detail", T_DETAIL }, - { "hud", T_HUD }, - }; +static tokenlist modeltokens[] = +{ + { "scale", T_SCALE }, + { "shade", T_SHADE }, + { "zadd", T_ZADD }, + { "frame", T_FRAME }, + { "anim", T_ANIM }, + { "skin", T_SKIN }, + { "glow", T_GLOW }, + { "detail", T_DETAIL }, + { "hud", T_HUD }, +}; -static tokenlist modelframetokens[] = { - { "frame", T_FRAME }, - { "name", T_FRAME }, - { "tile", T_TILE }, - { "tile0", T_TILE0 }, - { "tile1", T_TILE1 }, - { "smoothduration", T_SMOOTHDURATION }, - }; +static tokenlist modelframetokens[] = +{ + { "frame", T_FRAME }, + { "name", T_FRAME }, + { "tile", T_TILE }, + { "tile0", T_TILE0 }, + { "tile1", T_TILE1 }, + { "smoothduration", T_SMOOTHDURATION }, +}; -static tokenlist modelanimtokens[] = { - { "frame0", T_FRAME0 }, - { "frame1", T_FRAME1 }, - { "fps", T_FPS }, - { "flags", T_FLAGS }, - }; +static tokenlist modelanimtokens[] = +{ + { "frame0", T_FRAME0 }, + { "frame1", T_FRAME1 }, + { "fps", T_FPS }, + { "flags", T_FLAGS }, +}; -static tokenlist modelskintokens[] = { - { "pal", T_PAL }, - { "file", T_FILE }, - { "surf", T_SURF }, - { "surface", T_SURF }, - { "intensity", T_PARAM }, - { "scale", T_PARAM }, - { "detailscale", T_PARAM }, - }; +static tokenlist modelskintokens[] = +{ + { "pal", T_PAL }, + { "file", T_FILE }, + { "surf", T_SURF }, + { "surface", T_SURF }, + { "intensity", T_PARAM }, + { "scale", T_PARAM }, + { "detailscale", T_PARAM }, +}; -static tokenlist modelhudtokens[] = { - { "tile", T_TILE }, - { "tile0", T_TILE0 }, - { "tile1", T_TILE1 }, - { "xadd", T_XADD }, - { "yadd", T_YADD }, - { "zadd", T_ZADD }, - { "angadd", T_ANGADD }, - { "hide", T_HIDE }, - { "nobob", T_NOBOB }, - { "flipped",T_FLIPPED}, - { "nodepth",T_NODEPTH}, - }; +static tokenlist modelhudtokens[] = +{ + { "tile", T_TILE }, + { "tile0", T_TILE0 }, + { "tile1", T_TILE1 }, + { "xadd", T_XADD }, + { "yadd", T_YADD }, + { "zadd", T_ZADD }, + { "angadd", T_ANGADD }, + { "hide", T_HIDE }, + { "nobob", T_NOBOB }, + { "flipped",T_FLIPPED}, + { "nodepth",T_NODEPTH}, +}; -static tokenlist voxeltokens[] = { - { "tile", T_TILE }, - { "tile0", T_TILE0 }, - { "tile1", T_TILE1 }, - { "scale", T_SCALE }, - }; +static tokenlist voxeltokens[] = +{ + { "tile", T_TILE }, + { "tile0", T_TILE0 }, + { "tile1", T_TILE1 }, + { "scale", T_SCALE }, +}; -static tokenlist skyboxtokens[] = { - { "tile" ,T_TILE }, - { "pal" ,T_PAL }, - { "ft" ,T_FRONT },{ "front" ,T_FRONT },{ "forward",T_FRONT }, - { "rt" ,T_RIGHT },{ "right" ,T_RIGHT }, - { "bk" ,T_BACK },{ "back" ,T_BACK }, - { "lf" ,T_LEFT },{ "left" ,T_LEFT },{ "lt" ,T_LEFT }, - { "up" ,T_TOP },{ "top" ,T_TOP },{ "ceiling",T_TOP },{ "ceil" ,T_TOP }, - { "dn" ,T_BOTTOM },{ "bottom" ,T_BOTTOM },{ "floor" ,T_BOTTOM },{ "down" ,T_BOTTOM } - }; +static tokenlist skyboxtokens[] = +{ + { "tile" ,T_TILE }, + { "pal" ,T_PAL }, + { "ft" ,T_FRONT },{ "front" ,T_FRONT },{ "forward",T_FRONT }, + { "rt" ,T_RIGHT },{ "right" ,T_RIGHT }, + { "bk" ,T_BACK },{ "back" ,T_BACK }, + { "lf" ,T_LEFT },{ "left" ,T_LEFT },{ "lt" ,T_LEFT }, + { "up" ,T_TOP },{ "top" ,T_TOP },{ "ceiling",T_TOP },{ "ceil" ,T_TOP }, + { "dn" ,T_BOTTOM },{ "bottom" ,T_BOTTOM },{ "floor" ,T_BOTTOM },{ "down" ,T_BOTTOM } +}; -static tokenlist tinttokens[] = { - { "pal", T_PAL }, - { "red", T_RED },{ "r", T_RED }, - { "green", T_GREEN },{ "g", T_GREEN }, - { "blue", T_BLUE },{ "b", T_BLUE }, - { "flags", T_FLAGS } - }; +static tokenlist tinttokens[] = +{ + { "pal", T_PAL }, + { "red", T_RED },{ "r", T_RED }, + { "green", T_GREEN },{ "g", T_GREEN }, + { "blue", T_BLUE },{ "b", T_BLUE }, + { "flags", T_FLAGS } +}; -static tokenlist texturetokens[] = { - { "pal", T_PAL }, - { "detail", T_DETAIL }, - { "glow", T_GLOW }, - }; -static tokenlist texturetokens_pal[] = { - { "file", T_FILE },{ "name", T_FILE }, - { "alphacut", T_ALPHACUT }, - { "detailscale", T_XSCALE }, { "scale", T_XSCALE }, { "xscale", T_XSCALE }, { "intensity", T_XSCALE }, - { "yscale", T_YSCALE }, - { "nocompress", T_NOCOMPRESS }, - }; +static tokenlist texturetokens[] = +{ + { "pal", T_PAL }, + { "detail", T_DETAIL }, + { "glow", T_GLOW }, +}; +static tokenlist texturetokens_pal[] = +{ + { "file", T_FILE },{ "name", T_FILE }, + { "alphacut", T_ALPHACUT }, + { "detailscale", T_XSCALE }, { "scale", T_XSCALE }, { "xscale", T_XSCALE }, { "intensity", T_XSCALE }, + { "yscale", T_YSCALE }, + { "nocompress", T_NOCOMPRESS }, +}; static int getatoken(scriptfile *sf, tokenlist *tl, int ntokens) { @@ -216,7 +227,8 @@ static int getatoken(scriptfile *sf, tokenlist *tl, int ntokens) tok = scriptfile_gettoken(sf); if (!tok) return T_EOF; - for (i=0;iltextptr; - switch (tokn) { + switch (tokn) + { case T_ERROR: initprintf("Error on line %s:%d.\n", script->filename,scriptfile_getlinum(script,cmdtokptr)); break; @@ -254,14 +269,18 @@ static int defsparser(scriptfile *script) case T_INCLUDE: { char *fn; - if (!scriptfile_getstring(script,&fn)) { + if (!scriptfile_getstring(script,&fn)) + { scriptfile *included; included = scriptfile_fromfile(fn); - if (!included) { + if (!included) + { initprintf("Warning: Failed including %s on line %s:%d\n", fn, script->filename,scriptfile_getlinum(script,cmdtokptr)); - } else { + } + else + { defsparser(included); scriptfile_close(included); } @@ -298,16 +317,19 @@ static int defsparser(scriptfile *script) i = pathsearchmode; pathsearchmode = 1; - if (findfrompath(fn,&tfn) < 0) { + if (findfrompath(fn,&tfn) < 0) + { char buf[BMAX_PATH]; Bstrcpy(buf,fn); kzfindfilestart(buf); - if (!kzfindfile(buf)) { + if (!kzfindfile(buf)) + { initprintf("Error: file '%s' does not exist\n",fn); break; - } - } else Bfree(tfn); + } + } + else Bfree(tfn); pathsearchmode = i; hicsetsubsttex(tile,pal,fn,-1.0,1.0,1.0,0); @@ -321,20 +343,24 @@ static int defsparser(scriptfile *script) if (scriptfile_getsymbol(script,&tile)) break; if (scriptfile_getsymbol(script,&pal)) break; if (scriptfile_getsymbol(script,&i)) break; //future expansion - for (i=0;i<6;i++) { + for (i=0;i<6;i++) + { if (scriptfile_getstring(script,&fn[i])) break; //grab the 6 faces ii = pathsearchmode; pathsearchmode = 1; - if (findfrompath(fn[i],&tfn) < 0) { + if (findfrompath(fn[i],&tfn) < 0) + { char buf[BMAX_PATH]; Bstrcpy(buf,fn[i]); kzfindfilestart(buf); - if (!kzfindfile(buf)) { + if (!kzfindfile(buf)) + { initprintf("Error: file '%s' does not exist\n",fn[i]); happy = 0; - } - } else Bfree(tfn); + } + } + else Bfree(tfn); pathsearchmode = ii; } if (i < 6 || !happy) break; @@ -361,7 +387,7 @@ static int defsparser(scriptfile *script) if (scriptfile_getsymbol(script,&tile)) break; if (scriptfile_getdouble(script,&alpha)) break; #if defined(POLYMOST) && defined(USE_OPENGL) - if ((unsigned long)tile < MAXTILES) alphahackarray[tile] = alpha; + if ((unsigned int)tile < MAXTILES) alphahackarray[tile] = alpha; #endif } break; @@ -373,7 +399,8 @@ static int defsparser(scriptfile *script) if (scriptfile_getsymbol(script,&tilenume1)) break; if (scriptfile_getsymbol(script,&tilenume2)) break; if (scriptfile_getdouble(script,&alpha)) break; - if (tilenume2 < tilenume1) { + if (tilenume2 < tilenume1) + { initprintf("Warning: backwards tile range on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); i = tilenume2; tilenume2 = tilenume1; @@ -384,7 +411,7 @@ static int defsparser(scriptfile *script) { for (i=tilenume1;i<=tilenume2;i++) { - if ((unsigned long)i < MAXTILES) + if ((unsigned int)i < MAXTILES) alphahackarray[i] = alpha; } } @@ -398,7 +425,7 @@ static int defsparser(scriptfile *script) if (scriptfile_getsymbol(script,&tile)) break; if (scriptfile_getnumber(script,&col)) break; if (scriptfile_getnumber(script,&col2)) break; - if ((unsigned long)tile < MAXTILES) + if ((unsigned int)tile < MAXTILES) { spritecol2d[tile][0] = col; spritecol2d[tile][1] = col2; @@ -414,7 +441,8 @@ static int defsparser(scriptfile *script) if (scriptfile_getnumber(script,&g)) break; if (scriptfile_getnumber(script,&b)) break; - if (col < 256) { + if (col < 256) + { vgapal16[col*4+0] = b; // blue vgapal16[col*4+1] = g; // green vgapal16[col*4+2] = r; // red @@ -445,7 +473,7 @@ static int defsparser(scriptfile *script) case T_CACHESIZE: { int j; - + if (scriptfile_getnumber(script,&j)) break; } break; @@ -482,7 +510,8 @@ static int defsparser(scriptfile *script) if (scriptfile_getnumber(script,&tile2)) break; if (scriptfile_getnumber(script,&xsiz)) break; if (scriptfile_getnumber(script,&ysiz)) break; - if (tile2 < tile1) { + if (tile2 < tile1) + { initprintf("Warning: backwards tile range on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); i = tile2; tile2 = tile1; @@ -492,7 +521,7 @@ static int defsparser(scriptfile *script) { for (i=tile1;i<=tile2;i++) { - if ((unsigned long)i < MAXTILES) + if ((unsigned int)i < MAXTILES) { if (xsiz > 0 && ysiz > 0) { @@ -524,7 +553,8 @@ static int defsparser(scriptfile *script) #if defined(POLYMOST) && defined(USE_OPENGL) lastmodelid = md_loadmodel(modelfn); - if (lastmodelid < 0) { + if (lastmodelid < 0) + { initprintf("Failure loading MD2/MD3 model \"%s\"\n", modelfn); break; } @@ -542,20 +572,24 @@ static int defsparser(scriptfile *script) if (scriptfile_getstring(script,&framename)) break; if (scriptfile_getnumber(script,&ftilenume)) break; //first tile number if (scriptfile_getnumber(script,<ilenume)) break; //last tile number (inclusive) - if (ltilenume < ftilenume) { + if (ltilenume < ftilenume) + { initprintf("Warning: backwards tile range on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); tilex = ftilenume; ftilenume = ltilenume; ltilenume = tilex; } - if (lastmodelid < 0) { + if (lastmodelid < 0) + { initprintf("Warning: Ignoring frame definition.\n"); break; } #if defined(POLYMOST) && defined(USE_OPENGL) - for (tilex = ftilenume; tilex <= ltilenume && happy; tilex++) { - switch (md_defineframe(lastmodelid, framename, tilex, max(0,modelskin), 0.0f)) { + for (tilex = ftilenume; tilex <= ltilenume && happy; tilex++) + { + switch (md_defineframe(lastmodelid, framename, tilex, max(0,modelskin), 0.0f)) + { case 0: break; case -1: @@ -587,12 +621,14 @@ static int defsparser(scriptfile *script) if (scriptfile_getdouble(script,&dfps)) break; //animation frame rate if (scriptfile_getnumber(script,&flags)) break; - if (lastmodelid < 0) { + if (lastmodelid < 0) + { initprintf("Warning: Ignoring animation definition.\n"); break; } #if defined(POLYMOST) && defined(USE_OPENGL) - switch (md_defineanimation(lastmodelid, startframe, endframe, (int)(dfps*(65536.0*.001)), flags)) { + switch (md_defineanimation(lastmodelid, startframe, endframe, (int)(dfps*(65536.0*.001)), flags)) + { case 0: break; case -1: @@ -633,11 +669,12 @@ static int defsparser(scriptfile *script) // definemodelframe "foo2" 1003 1004 // these use skin 1 // selectmodelskin 0 // resets to skin 0 // definemodelframe "foo3" 1005 1006 // these use skin 0 - if (seenframe) { modelskin = ++lastmodelskin; } + if (seenframe) { modelskin = ++lastmodelskin; } seenframe = 0; #if defined(POLYMOST) && defined(USE_OPENGL) - switch (md_defineskin(lastmodelid, skinfn, palnum, max(0,modelskin), 0, 0.0f)) { + switch (md_defineskin(lastmodelid, skinfn, palnum, max(0,modelskin), 0, 0.0f)) + { case 0: break; case -1: @@ -669,13 +706,15 @@ static int defsparser(scriptfile *script) if (scriptfile_getstring(script,&fn)) break; //voxel filename - if (nextvoxid == MAXVOXELS) { + if (nextvoxid == MAXVOXELS) + { initprintf("Maximum number of voxels already defined.\n"); break; } #ifdef SUPERBUILD - if (qloadkvx(nextvoxid, fn)) { + if (qloadkvx(nextvoxid, fn)) + { initprintf("Failure loading voxel file \"%s\"\n",fn); break; } @@ -691,25 +730,29 @@ static int defsparser(scriptfile *script) if (scriptfile_getnumber(script,&ftilenume)) break; //1st tile # if (scriptfile_getnumber(script,<ilenume)) break; //last tile # - if (ltilenume < ftilenume) { + if (ltilenume < ftilenume) + { initprintf("Warning: backwards tile range on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); tilex = ftilenume; ftilenume = ltilenume; ltilenume = tilex; } - if (ltilenume < 0 || ftilenume >= MAXTILES) { + if (ltilenume < 0 || ftilenume >= MAXTILES) + { initprintf("Invalid tile range on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); break; } - if (lastvoxid < 0) { + if (lastvoxid < 0) + { initprintf("Warning: Ignoring voxel tiles definition.\n"); break; } #ifdef SUPERBUILD - for (tilex = ftilenume; tilex <= ltilenume; tilex++) { + for (tilex = ftilenume; tilex <= ltilenume; tilex++) + { tiletovox[tilex] = lastvoxid; } #endif @@ -730,15 +773,18 @@ static int defsparser(scriptfile *script) #if defined(POLYMOST) && defined(USE_OPENGL) lastmodelid = md_loadmodel(modelfn); - if (lastmodelid < 0) { + if (lastmodelid < 0) + { initprintf("Failure loading MD2/MD3 model \"%s\"\n", modelfn); break; } #endif if (scriptfile_getbraces(script,&modelend)) break; - while (script->textptr < modelend) { + while (script->textptr < modelend) + { int token = getatoken(script,modeltokens,sizeof(modeltokens)/sizeof(tokenlist)); - switch (token) { + switch (token) + { //case T_ERROR: initprintf("Error on line %s:%d in model tokens\n", script->filename,script->linenum); break; case T_SCALE: scriptfile_getdouble(script,&scale); break; @@ -754,8 +800,10 @@ static int defsparser(scriptfile *script) double smoothduration = 0.0f; if (scriptfile_getbraces(script,&frameend)) break; - while (script->textptr < frameend) { - switch (getatoken(script,modelframetokens,sizeof(modelframetokens)/sizeof(tokenlist))) { + while (script->textptr < frameend) + { + switch (getatoken(script,modelframetokens,sizeof(modelframetokens)/sizeof(tokenlist))) + { case T_FRAME: scriptfile_getstring(script,&framename); break; case T_TILE: @@ -773,20 +821,24 @@ static int defsparser(scriptfile *script) if (ltilenume < 0) initprintf("Error: missing 'last tile number' for frame definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,frametokptr)), happy = 0; if (!happy) break; - if (ltilenume < ftilenume) { + if (ltilenume < ftilenume) + { initprintf("Warning: backwards tile range on line %s:%d\n", script->filename, scriptfile_getlinum(script,frametokptr)); tilex = ftilenume; ftilenume = ltilenume; ltilenume = tilex; } - if (lastmodelid < 0) { + if (lastmodelid < 0) + { initprintf("Warning: Ignoring frame definition.\n"); break; } #if defined(POLYMOST) && defined(USE_OPENGL) - for (tilex = ftilenume; tilex <= ltilenume && happy; tilex++) { - switch (md_defineframe(lastmodelid, framename, tilex, max(0,modelskin), smoothduration)) { + for (tilex = ftilenume; tilex <= ltilenume && happy; tilex++) + { + switch (md_defineframe(lastmodelid, framename, tilex, max(0,modelskin), smoothduration)) + { case 0: break; case -1: @@ -815,8 +867,10 @@ static int defsparser(scriptfile *script) double dfps = 1.0; if (scriptfile_getbraces(script,&animend)) break; - while (script->textptr < animend) { - switch (getatoken(script,modelanimtokens,sizeof(modelanimtokens)/sizeof(tokenlist))) { + while (script->textptr < animend) + { + switch (getatoken(script,modelanimtokens,sizeof(modelanimtokens)/sizeof(tokenlist))) + { case T_FRAME0: scriptfile_getstring(script,&startframe); break; case T_FRAME1: @@ -832,12 +886,14 @@ static int defsparser(scriptfile *script) if (!endframe) initprintf("Error: missing 'end frame' for anim definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,animtokptr)), happy = 0; if (!happy) break; - if (lastmodelid < 0) { + if (lastmodelid < 0) + { initprintf("Warning: Ignoring animation definition.\n"); break; } #if defined(POLYMOST) && defined(USE_OPENGL) - switch (md_defineanimation(lastmodelid, startframe, endframe, (int)(dfps*(65536.0*.001)), flags)) { + switch (md_defineanimation(lastmodelid, startframe, endframe, (int)(dfps*(65536.0*.001)), flags)) + { case 0: break; case -1: @@ -856,8 +912,9 @@ static int defsparser(scriptfile *script) break; } #endif - } break; - case T_SKIN: case T_DETAIL: case T_GLOW: + } + break; + case T_SKIN: case T_DETAIL: case T_GLOW: { char *skintokptr = script->ltextptr; char *skinend, *skinfn = 0; @@ -865,8 +922,10 @@ static int defsparser(scriptfile *script) double param = 1.0; if (scriptfile_getbraces(script,&skinend)) break; - while (script->textptr < skinend) { - switch (getatoken(script,modelskintokens,sizeof(modelskintokens)/sizeof(tokenlist))) { + while (script->textptr < skinend) + { + switch (getatoken(script,modelskintokens,sizeof(modelskintokens)/sizeof(tokenlist))) + { case T_PAL: scriptfile_getsymbol(script,&palnum); break; case T_PARAM: @@ -878,7 +937,8 @@ static int defsparser(scriptfile *script) } } - if (!skinfn) { + if (!skinfn) + { initprintf("Error: missing 'skin filename' for skin definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,skintokptr)); break; } @@ -895,7 +955,8 @@ static int defsparser(scriptfile *script) palnum = GLOWPAL; #if defined(POLYMOST) && defined(USE_OPENGL) - switch (md_defineskin(lastmodelid, skinfn, palnum, max(0,modelskin), surfnum, param)) { + switch (md_defineskin(lastmodelid, skinfn, palnum, max(0,modelskin), surfnum, param)) + { case 0: break; case -1: @@ -914,7 +975,8 @@ static int defsparser(scriptfile *script) break; } #endif - } break; + } + break; case T_HUD: { char *hudtokptr = script->ltextptr; @@ -923,8 +985,10 @@ static int defsparser(scriptfile *script) double xadd = 0.0, yadd = 0.0, zadd = 0.0, angadd = 0.0; if (scriptfile_getbraces(script,&frameend)) break; - while (script->textptr < frameend) { - switch (getatoken(script,modelhudtokens,sizeof(modelhudtokens)/sizeof(tokenlist))) { + while (script->textptr < frameend) + { + switch (getatoken(script,modelhudtokens,sizeof(modelhudtokens)/sizeof(tokenlist))) + { case T_TILE: scriptfile_getsymbol(script,&ftilenume); ltilenume = ftilenume; break; case T_TILE0: @@ -954,20 +1018,24 @@ static int defsparser(scriptfile *script) if (ltilenume < 0) initprintf("Error: missing 'last tile number' for hud definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,hudtokptr)), happy = 0; if (!happy) break; - if (ltilenume < ftilenume) { + if (ltilenume < ftilenume) + { initprintf("Warning: backwards tile range on line %s:%d\n", script->filename, scriptfile_getlinum(script,hudtokptr)); tilex = ftilenume; ftilenume = ltilenume; ltilenume = tilex; } - if (lastmodelid < 0) { + if (lastmodelid < 0) + { initprintf("Warning: Ignoring frame definition.\n"); break; } #if defined(POLYMOST) && defined(USE_OPENGL) - for (tilex = ftilenume; tilex <= ltilenume && happy; tilex++) { - switch (md_definehud(lastmodelid, tilex, xadd, yadd, zadd, angadd, flags)) { + for (tilex = ftilenume; tilex <= ltilenume && happy; tilex++) + { + switch (md_definehud(lastmodelid, tilex, xadd, yadd, zadd, angadd, flags)) + { case 0: break; case -1: @@ -985,7 +1053,8 @@ static int defsparser(scriptfile *script) } } #endif - } break; + } + break; } } @@ -1005,20 +1074,22 @@ static int defsparser(scriptfile *script) int tile0 = MAXTILES, tile1 = -1, tilex = -1; if (scriptfile_getstring(script,&fn)) break; //voxel filename - if (nextvoxid == MAXVOXELS) { initprintf("Maximum number of voxels already defined.\n"); break; } + if (nextvoxid == MAXVOXELS) { initprintf("Maximum number of voxels already defined.\n"); break; } #ifdef SUPERBUILD if (qloadkvx(nextvoxid, fn)) { initprintf("Failure loading voxel file \"%s\"\n",fn); break; } lastvoxid = nextvoxid++; #endif if (scriptfile_getbraces(script,&modelend)) break; - while (script->textptr < modelend) { - switch (getatoken(script,voxeltokens,sizeof(voxeltokens)/sizeof(tokenlist))) { + while (script->textptr < modelend) + { + switch (getatoken(script,voxeltokens,sizeof(voxeltokens)/sizeof(tokenlist))) + { //case T_ERROR: initprintf("Error on line %s:%d in voxel tokens\n", script->filename,linenum); break; case T_TILE: scriptfile_getsymbol(script,&tilex); #ifdef SUPERBUILD - if ((unsigned long)tilex < MAXTILES) tiletovox[tilex] = lastvoxid; + if ((unsigned int)tilex < MAXTILES) tiletovox[tilex] = lastvoxid; else initprintf("Invalid tile number on line %s:%d\n",script->filename, scriptfile_getlinum(script,voxeltokptr)); #endif break; @@ -1032,12 +1103,13 @@ static int defsparser(scriptfile *script) tilex = tile0; tile0 = tile1; tile1 = tilex; } if ((tile1 < 0) || (tile0 >= MAXTILES)) - { initprintf("Invalid tile range on line %s:%d\n",script->filename, scriptfile_getlinum(script,voxeltokptr)); break; } + { initprintf("Invalid tile range on line %s:%d\n",script->filename, scriptfile_getlinum(script,voxeltokptr)); break; } #ifdef SUPERBUILD for (tilex=tile0;tilex<=tile1;tilex++) tiletovox[tilex] = lastvoxid; #endif break; //last tile number (inclusive) - case T_SCALE: { + case T_SCALE: + { double scale=1.0; scriptfile_getdouble(script,&scale); #ifdef SUPERBUILD @@ -1057,13 +1129,15 @@ static int defsparser(scriptfile *script) int i, tile = -1, pal = 0,j,ii; if (scriptfile_getbraces(script,&modelend)) break; - while (script->textptr < modelend) { - switch (getatoken(script,skyboxtokens,sizeof(skyboxtokens)/sizeof(tokenlist))) { + while (script->textptr < modelend) + { + switch (getatoken(script,skyboxtokens,sizeof(skyboxtokens)/sizeof(tokenlist))) + { //case T_ERROR: initprintf("Error on line %s:%d in skybox tokens\n",script->filename,linenum); break; case T_TILE: - scriptfile_getsymbol(script,&tile ); break; + scriptfile_getsymbol(script,&tile); break; case T_PAL: - scriptfile_getsymbol(script,&pal ); break; + scriptfile_getsymbol(script,&pal); break; case T_FRONT: scriptfile_getstring(script,&fn[0]); break; case T_RIGHT: @@ -1080,20 +1154,24 @@ static int defsparser(scriptfile *script) } if (tile < 0) initprintf("Error: missing 'tile number' for skybox definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,skyboxtokptr)), happy=0; - for (i=0;i<6;i++) { + for (i=0;i<6;i++) + { if (!fn[i]) initprintf("Error: missing '%s filename' for skybox definition near line %s:%d\n", skyfaces[i], script->filename, scriptfile_getlinum(script,skyboxtokptr)), happy = 0; ii = pathsearchmode; pathsearchmode = 1; - if (findfrompath(fn[i],&tfn) < 0) { + if (findfrompath(fn[i],&tfn) < 0) + { char buf[BMAX_PATH]; Bstrcpy(buf,fn[i]); kzfindfilestart(buf); - if (!kzfindfile(buf)) { + if (!kzfindfile(buf)) + { initprintf("Error: file '%s' does not exist\n",fn[i]); happy = 0; - } - } else Bfree(tfn); + } + } + else Bfree(tfn); pathsearchmode = ii; } if (!happy) break; @@ -1108,8 +1186,10 @@ static int defsparser(scriptfile *script) char *tintend; if (scriptfile_getbraces(script,&tintend)) break; - while (script->textptr < tintend) { - switch (getatoken(script,tinttokens,sizeof(tinttokens)/sizeof(tokenlist))) { + while (script->textptr < tintend) + { + switch (getatoken(script,tinttokens,sizeof(tinttokens)/sizeof(tokenlist))) + { case T_PAL: scriptfile_getsymbol(script,&pal); break; case T_RED: @@ -1123,7 +1203,8 @@ static int defsparser(scriptfile *script) } } - if (pal < 0) { + if (pal < 0) + { initprintf("Error: missing 'palette number' for tint definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr)); break; } @@ -1138,10 +1219,13 @@ static int defsparser(scriptfile *script) if (scriptfile_getsymbol(script,&tile)) break; if (scriptfile_getbraces(script,&textureend)) break; - while (script->textptr < textureend) { + while (script->textptr < textureend) + { token = getatoken(script,texturetokens,sizeof(texturetokens)/sizeof(tokenlist)); - switch (token) { - case T_PAL: { + switch (token) + { + case T_PAL: + { char *paltokptr = script->ltextptr, *palend; int pal=-1, i; char *fn = NULL, *tfn = NULL; @@ -1150,8 +1234,10 @@ static int defsparser(scriptfile *script) if (scriptfile_getsymbol(script,&pal)) break; if (scriptfile_getbraces(script,&palend)) break; - while (script->textptr < palend) { - switch (getatoken(script,texturetokens_pal,sizeof(texturetokens_pal)/sizeof(tokenlist))) { + while (script->textptr < palend) + { + switch (getatoken(script,texturetokens_pal,sizeof(texturetokens_pal)/sizeof(tokenlist))) + { case T_FILE: scriptfile_getstring(script,&fn); break; case T_ALPHACUT: @@ -1168,12 +1254,14 @@ static int defsparser(scriptfile *script) } if ((unsigned)tile > (unsigned)MAXTILES) break; // message is printed later - if ((unsigned)pal >= ((unsigned)MAXPALOOKUPS - RESERVEDPALS)) { + if ((unsigned)pal >= ((unsigned)MAXPALOOKUPS - RESERVEDPALS)) + { initprintf("Error: missing or invalid 'palette number' for texture definition near " "line %s:%d\n", script->filename, scriptfile_getlinum(script,paltokptr)); break; } - if (!fn) { + if (!fn) + { initprintf("Error: missing 'file name' for texture definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,paltokptr)); break; @@ -1181,23 +1269,28 @@ static int defsparser(scriptfile *script) i = pathsearchmode; pathsearchmode = 1; - if (findfrompath(fn,&tfn) < 0) { + if (findfrompath(fn,&tfn) < 0) + { char buf[BMAX_PATH]; Bstrcpy(buf,fn); kzfindfilestart(buf); - if (!kzfindfile(buf)) { + if (!kzfindfile(buf)) + { initprintf("Error: file '%s' does not exist\n",fn); break; } - } else Bfree(tfn); + } + else Bfree(tfn); pathsearchmode = i; xscale = 1.0f / xscale; yscale = 1.0f / yscale; hicsetsubsttex(tile,pal,fn,alphacut,xscale,yscale,flags); - } break; - case T_DETAIL: case T_GLOW: { + } + break; + case T_DETAIL: case T_GLOW: + { char *detailtokptr = script->ltextptr, *detailend; int pal = 0, i; char *fn = NULL, *tfn = NULL; @@ -1205,8 +1298,10 @@ static int defsparser(scriptfile *script) char flags = 0; if (scriptfile_getbraces(script,&detailend)) break; - while (script->textptr < detailend) { - switch (getatoken(script,texturetokens_pal,sizeof(texturetokens_pal)/sizeof(tokenlist))) { + while (script->textptr < detailend) + { + switch (getatoken(script,texturetokens_pal,sizeof(texturetokens_pal)/sizeof(tokenlist))) + { case T_FILE: scriptfile_getstring(script,&fn); break; case T_XSCALE: @@ -1221,7 +1316,8 @@ static int defsparser(scriptfile *script) } if ((unsigned)tile > (unsigned)MAXTILES) break; // message is printed later - if (!fn) { + if (!fn) + { initprintf("Error: missing 'file name' for texture definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,detailtokptr)); break; @@ -1229,16 +1325,19 @@ static int defsparser(scriptfile *script) i = pathsearchmode; pathsearchmode = 1; - if (findfrompath(fn,&tfn) < 0) { + if (findfrompath(fn,&tfn) < 0) + { char buf[BMAX_PATH]; Bstrcpy(buf,fn); kzfindfilestart(buf); - if (!kzfindfile(buf)) { + if (!kzfindfile(buf)) + { initprintf("Error: file '%s' does not exist\n",fn); break; - } - } else Bfree(tfn); + } + } + else Bfree(tfn); pathsearchmode = i; if (token == T_DETAIL) @@ -1251,13 +1350,15 @@ static int defsparser(scriptfile *script) pal = GLOWPAL; hicsetsubsttex(tile,pal,fn,-1.0,xscale,yscale,flags); - } break; + } + break; default: break; } } - if ((unsigned)tile >= (unsigned)MAXTILES) { + if ((unsigned)tile >= (unsigned)MAXTILES) + { initprintf("Error: missing or invalid 'tile number' for texture definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,texturetokptr)); break; @@ -1271,21 +1372,27 @@ static int defsparser(scriptfile *script) int r0,r1; if (scriptfile_getsymbol(script,&r0)) break; - if (tokn == T_UNDEFMODELRANGE) { + if (tokn == T_UNDEFMODELRANGE) + { if (scriptfile_getsymbol(script,&r1)) break; - if (r1 < r0) { + if (r1 < r0) + { int t = r1; r1 = r0; r0 = t; initprintf("Warning: backwards tile range on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); } - if (r0 < 0 || r1 >= MAXTILES) { + if (r0 < 0 || r1 >= MAXTILES) + { initprintf("Error: invalid tile range on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); break; } - } else { + } + else + { r1 = r0; - if ((unsigned)r0 >= (unsigned)MAXTILES) { + if ((unsigned)r0 >= (unsigned)MAXTILES) + { initprintf("Error: invalid tile number on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); break; } @@ -1301,7 +1408,8 @@ static int defsparser(scriptfile *script) int mid,r0; if (scriptfile_getsymbol(script,&r0)) break; - if ((unsigned)r0 >= (unsigned)MAXTILES) { + if ((unsigned)r0 >= (unsigned)MAXTILES) + { initprintf("Error: invalid tile number on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); break; } @@ -1321,21 +1429,27 @@ static int defsparser(scriptfile *script) int r0,r1,i; if (scriptfile_getsymbol(script,&r0)) break; - if (tokn == T_UNDEFTEXTURERANGE) { + if (tokn == T_UNDEFTEXTURERANGE) + { if (scriptfile_getsymbol(script,&r1)) break; - if (r1 < r0) { + if (r1 < r0) + { int t = r1; r1 = r0; r0 = t; initprintf("Warning: backwards tile range on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); } - if (r0 < 0 || r1 >= MAXTILES) { + if (r0 < 0 || r1 >= MAXTILES) + { initprintf("Error: invalid tile range on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); break; } - } else { + } + else + { r1 = r0; - if ((unsigned)r0 >= (unsigned)MAXTILES) { + if ((unsigned)r0 >= (unsigned)MAXTILES) + { initprintf("Error: invalid tile number on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); break; } diff --git a/polymer/build/src/dynamicgtk.c b/polymer/build/src/dynamicgtk.c index 5cca99c3a..597cb29b5 100755 --- a/polymer/build/src/dynamicgtk.c +++ b/polymer/build/src/dynamicgtk.c @@ -25,7 +25,8 @@ int dynamicgtk_init(void) memset(&dynamicgtksyms, 0, sizeof(dynamicgtksyms)); - do { + do + { GETDLSYM(g_free) GETDLSYM(g_object_get_data) GETDLSYM(g_object_set_data) @@ -146,9 +147,11 @@ int dynamicgtk_init(void) GETDLSYM(gtk_window_set_title) GETDLSYM(gtk_window_set_type_hint) GETDLSYM(g_utf8_collate) - } while (0); + } + while (0); - if (err) { + if (err) + { //printf("Failed fetching symbol %s from GTK lib\n", failsym); dlclose(handle); handle = NULL; diff --git a/polymer/build/src/engine.c b/polymer/build/src/engine.c index d4c2ea923..6291f8087 100644 --- a/polymer/build/src/engine.c +++ b/polymer/build/src/engine.c @@ -49,34 +49,34 @@ void kfree(void *buffer) { Bfree(buffer); } #define kkfree kfree #ifdef SUPERBUILD -void loadvoxel(long voxindex) { voxindex=0; } -long tiletovox[MAXTILES]; -long usevoxels = 1; +void loadvoxel(int voxindex) { voxindex=0; } +int tiletovox[MAXTILES]; +int usevoxels = 1; #define kloadvoxel loadvoxel -long novoxmips = 0; -long editorgridextent = 131072; +int novoxmips = 0; +int editorgridextent = 131072; //These variables need to be copied into BUILD #define MAXXSIZ 256 #define MAXYSIZ 256 #define MAXZSIZ 255 #define MAXVOXMIPS 5 -long voxoff[MAXVOXELS][MAXVOXMIPS]; char voxlock[MAXVOXELS][MAXVOXMIPS]; -long voxscale[MAXVOXELS]; +int voxoff[MAXVOXELS][MAXVOXMIPS]; char voxlock[MAXVOXELS][MAXVOXMIPS]; +int voxscale[MAXVOXELS]; -static long ggxinc[MAXXSIZ+1], ggyinc[MAXXSIZ+1]; -static long lowrecip[1024], nytooclose, nytoofar; -static unsigned long distrecip[65536]; +static int ggxinc[MAXXSIZ+1], ggyinc[MAXXSIZ+1]; +static int lowrecip[1024], nytooclose, nytoofar; +static unsigned int distrecip[65536]; #endif -static long *lookups = NULL; +static int *lookups = NULL; static char lookupsalloctype = 255; -long dommxoverlay = 1, beforedrawrooms = 1, indrawroomsandmasks = 0; +int dommxoverlay = 1, beforedrawrooms = 1, indrawroomsandmasks = 0; -static long oxdimen = -1, oviewingrange = -1, oxyaspect = -1; +static int oxdimen = -1, oviewingrange = -1, oxyaspect = -1; -long curbrightness = 0, gammabrightness = 0; +int curbrightness = 0, gammabrightness = 0; //Textured Map variables static char globalpolytype; @@ -84,36 +84,36 @@ static short *dotp1[MAXYDIM], *dotp2[MAXYDIM]; static unsigned char tempbuf[MAXWALLS]; -long ebpbak, espbak; -long slopalookup[16384]; // was 2048 +int ebpbak, espbak; +int slopalookup[16384]; // was 2048 #if defined(USE_OPENGL) static palette_t palookupfog[MAXPALOOKUPS]; #endif static char permanentlock = 255; -long artversion, mapversion=7L; // JBF 20040211: default mapversion to 7 +int artversion, mapversion=7L; // JBF 20040211: default mapversion to 7 void *pic = NULL; char picsiz[MAXTILES], tilefilenum[MAXTILES]; -long lastageclock; -long tilefileoffs[MAXTILES]; +int lastageclock; +int tilefileoffs[MAXTILES]; -long artsize = 0, cachesize = 0; +int artsize = 0, cachesize = 0; static short radarang[1280], radarang2[MAXXDIM]; static unsigned short sqrtable[4096], shlookup[4096+256]; char pow2char[8] = {1,2,4,8,16,32,64,128}; -long pow2long[32] = - { - 1L,2L,4L,8L, - 16L,32L,64L,128L, - 256L,512L,1024L,2048L, - 4096L,8192L,16384L,32768L, - 65536L,131072L,262144L,524288L, - 1048576L,2097152L,4194304L,8388608L, - 16777216L,33554432L,67108864L,134217728L, - 268435456L,536870912L,1073741824L,2147483647L - }; -long reciptable[2048], fpuasm; +int pow2long[32] = +{ + 1L,2L,4L,8L, + 16L,32L,64L,128L, + 256L,512L,1024L,2048L, + 4096L,8192L,16384L,32768L, + 65536L,131072L,262144L,524288L, + 1048576L,2097152L,4194304L,8388608L, + 16777216L,33554432L,67108864L,134217728L, + 268435456L,536870912L,1073741824L,2147483647L +}; +int reciptable[2048], fpuasm; char britable[16][256]; // JBF 20040207: full 8bit precision //char textfont[1024], smalltextfont[1024]; @@ -145,7 +145,7 @@ char *engineerrstr = "No error"; "shr eax, cl",\ parm nomemory [eax]\ modify exact [eax ebx ecx] -unsigned long nsqrtasm(unsigned long); +unsigned int nsqrtasm(unsigned int); #pragma aux msqrtasm =\ "mov eax, 0x40000000",\ @@ -163,7 +163,7 @@ unsigned long nsqrtasm(unsigned long); "shr eax, 1",\ parm nomemory [ecx]\ modify exact [eax ebx ecx] -long msqrtasm(unsigned long); +int msqrtasm(unsigned int); //0x007ff000 is (11<<13), 0x3f800000 is (127<<23) #pragma aux krecipasm =\ @@ -183,7 +183,7 @@ long msqrtasm(unsigned long); "xor eax, ebx",\ parm [eax]\ modify exact [eax ebx ecx] -long krecipasm(long); +int krecipasm(int); #pragma aux setgotpic =\ "mov ebx, eax",\ @@ -198,7 +198,7 @@ long krecipasm(long); "mov byte ptr gotpic[eax], dl",\ parm [eax]\ modify exact [eax ebx ecx edx] -void setgotpic(long); +void setgotpic(int); #pragma aux getclipmask =\ "sar eax, 31",\ @@ -214,7 +214,7 @@ void setgotpic(long); "xor eax, ebx",\ parm [eax][ebx][ecx][edx]\ modify exact [eax ebx ecx edx] -long getclipmask(long,long,long,long); +int getclipmask(int,int,int,int); #pragma aux getkensmessagecrc =\ "xor eax, eax",\ @@ -226,7 +226,7 @@ long getclipmask(long,long,long,long); "loop short beg",\ parm [ebx]\ modify exact [eax ebx ecx edx] -long getkensmessagecrc(long); +int getkensmessagecrc(int); #elif defined(_MSC_VER) && !defined(NOASM) // __WATCOMC__ @@ -234,9 +234,10 @@ long getkensmessagecrc(long); // Microsoft C Inline Assembly Routines // -static inline long nsqrtasm(long a) +static inline int nsqrtasm(int a) { - _asm { + _asm + { push ebx mov eax, a test eax, 0xff000000 @@ -245,10 +246,10 @@ static inline long nsqrtasm(long a) shr ebx, 12 mov cx, word ptr shlookup[ebx*2] jmp short under24 - over24: +over24: shr ebx, 24 mov cx, word ptr shlookup[ebx*2+8192] - under24: +under24: shr eax, cl mov cl, ch mov ax, word ptr sqrtable[eax*2] @@ -257,19 +258,20 @@ static inline long nsqrtasm(long a) } } -static inline long msqrtasm(long c) +static inline int msqrtasm(int c) { - _asm { + _asm + { push ebx mov ecx, c mov eax, 0x40000000 mov ebx, 0x20000000 - begit: +begit: cmp ecx, eax jl skip sub ecx, eax lea eax, [eax+ebx*4] - skip: +skip: sub eax, ebx shr eax, 1 shr ebx, 2 @@ -282,39 +284,41 @@ static inline long msqrtasm(long c) } //0x007ff000 is (11<<13), 0x3f800000 is (127<<23) -static inline long krecipasm(long a) +static inline int krecipasm(int a) { - _asm { + _asm + { push ebx mov eax, a mov fpuasm, eax fild dword ptr fpuasm add eax, eax - fstp dword ptr fpuasm - sbb ebx, ebx - mov eax, fpuasm - mov ecx, eax - and eax, 0x007ff000 - shr eax, 10 - sub ecx, 0x3f800000 - shr ecx, 23 - mov eax, dword ptr reciptable[eax] - sar eax, cl - xor eax, ebx - pop ebx - } + fstp dword ptr fpuasm + sbb ebx, ebx + mov eax, fpuasm + mov ecx, eax + and eax, 0x007ff000 + shr eax, 10 + sub ecx, 0x3f800000 + shr ecx, 23 + mov eax, dword ptr reciptable[eax] + sar eax, cl + xor eax, ebx + pop ebx } +} -static inline void setgotpic(long a) +static inline void setgotpic(int a) { - _asm { + _asm + { push ebx mov eax, a mov ebx, eax cmp byte ptr walock[eax], 200 jae skipit mov byte ptr walock[eax], 199 - skipit: +skipit: shr eax, 3 and ebx, 7 mov dl, byte ptr gotpic[eax] @@ -325,9 +329,10 @@ static inline void setgotpic(long a) } } -static inline long getclipmask(long a, long b, long c, long d) +static inline int getclipmask(int a, int b, int c, int d) { - _asm { + _asm + { push ebx mov eax, a mov ebx, b @@ -335,27 +340,28 @@ static inline long getclipmask(long a, long b, long c, long d) mov edx, d sar eax, 31 add ebx, ebx - adc eax, eax - add ecx, ecx - adc eax, eax - add edx, edx - adc eax, eax - mov ebx, eax - shl ebx, 4 - or al, 0xf0 - xor eax, ebx - pop ebx - } - } + adc eax, eax + add ecx, ecx + adc eax, eax + add edx, edx + adc eax, eax + mov ebx, eax + shl ebx, 4 + or al, 0xf0 + xor eax, ebx + pop ebx + } +} -static inline long getkensmessagecrc(void *b) +static inline int getkensmessagecrc(void *b) { - _asm { + _asm + { push ebx mov ebx, b xor eax, eax mov ecx, 32 - beg: +beg: mov edx, dword ptr [ebx+ecx*4-4] ror edx, cl adc eax, edx @@ -372,7 +378,7 @@ static inline long getkensmessagecrc(void *b) // #define nsqrtasm(a) \ - ({ long __r, __a=(a); \ + ({ int __r, __a=(a); \ __asm__ __volatile__ ( \ "testl $0xff000000, %%eax\n\t" \ "movl %%eax, %%ebx\n\t" \ @@ -393,7 +399,7 @@ static inline long getkensmessagecrc(void *b) // edx is blown by this code somehow?! #define msqrtasm(c) \ - ({ long __r, __c=(c); \ + ({ int __r, __c=(c); \ __asm__ __volatile__ ( \ "movl $0x40000000, %%eax\n\t" \ "movl $0x20000000, %%ebx\n\t" \ @@ -414,7 +420,7 @@ static inline long getkensmessagecrc(void *b) __r; }) #define setgotpic(a) \ - ({ long __a=(a); \ + ({ int __a=(a); \ __asm__ __volatile__ ( \ "movl %%eax, %%ebx\n\t" \ "cmpb $200, "ASMSYM("walock")"(%%eax)\n\t" \ @@ -432,7 +438,7 @@ static inline long getkensmessagecrc(void *b) __a; }) #define krecipasm(a) \ - ({ long __a=(a); \ + ({ int __a=(a); \ __asm__ __volatile__ ( \ "movl %%eax, ("ASMSYM("fpuasm")"); fildl ("ASMSYM("fpuasm")"); " \ "addl %%eax, %%eax; fstps ("ASMSYM("fpuasm")"); sbbl %%ebx, %%ebx; " \ @@ -444,7 +450,7 @@ static inline long getkensmessagecrc(void *b) __a; }) #define getclipmask(a,b,c,d) \ - ({ long __a=(a), __b=(b), __c=(c), __d=(d); \ + ({ int __a=(a), __b=(b), __c=(c), __d=(d); \ __asm__ __volatile__ ("sarl $31, %%eax; addl %%ebx, %%ebx; adcl %%eax, %%eax; " \ "addl %%ecx, %%ecx; adcl %%eax, %%eax; addl %%edx, %%edx; " \ "adcl %%eax, %%eax; movl %%eax, %%ebx; shl $4, %%ebx; " \ @@ -455,7 +461,7 @@ static inline long getkensmessagecrc(void *b) #define getkensmessagecrc(b) \ - ({ long __a, __b=(b); \ + ({ int __a, __b=(b); \ __asm__ __volatile__ ( \ "xorl %%eax, %%eax\n\t" \ "movl $32, %%ecx\n\t" \ @@ -470,16 +476,20 @@ static inline long getkensmessagecrc(void *b) #else // __GNUC__ && __i386__ -static inline unsigned long nsqrtasm(unsigned long a) -{ // JBF 20030901: This was a damn lot simpler to reverse engineer than +static inline unsigned int nsqrtasm(unsigned int a) +{ + // JBF 20030901: This was a damn lot simpler to reverse engineer than // msqrtasm was. Really, it was just like simplifying an algebra equation. unsigned short c; - if (a & 0xff000000) { // test eax, 0xff000000 / jnz short over24 + if (a & 0xff000000) // test eax, 0xff000000 / jnz short over24 + { c = shlookup[(a >> 24) + 4096]; // mov ebx, eax // over24: shr ebx, 24 // mov cx, word ptr shlookup[ebx*2+8192] - } else { + } + else + { c = shlookup[a >> 12]; // mov ebx, eax // shr ebx, 12 // mov cx, word ptr shlookup[ebx*2] @@ -492,47 +502,52 @@ static inline unsigned long nsqrtasm(unsigned long a) return a; } -static inline long msqrtasm(unsigned long c) +static inline int msqrtasm(unsigned int c) { - unsigned long a,b; + unsigned int a,b; a = 0x40000000l; // mov eax, 0x40000000 b = 0x20000000l; // mov ebx, 0x20000000 - do { // begit: - if (c >= a) { // cmp ecx, eax / jl skip + do // begit: + { + if (c >= a) // cmp ecx, eax / jl skip + { c -= a; // sub ecx, eax a += b*4; // lea eax, [eax+ebx*4] } // skip: a -= b; // sub eax, ebx a >>= 1; // shr eax, 1 b >>= 2; // shr ebx, 2 - } while (b); // jnz begit + } + while (b); // jnz begit if (c >= a) // cmp ecx, eax a++; // sbb eax, -1 a >>= 1; // shr eax, 1 return a; } -static inline void setgotpic(long tilenume) +static inline void setgotpic(int tilenume) { if (walock[tilenume] < 200) walock[tilenume] = 199; gotpic[tilenume>>3] |= pow2char[tilenume&7]; } -static inline long krecipasm(long i) -{ // Ken did this - float f = (float)i; i = *(long *)&f; +static inline int krecipasm(int i) +{ + // Ken did this + float f = (float)i; i = *(int *)&f; return((reciptable[(i>>12)&2047]>>(((i-0x3f800000)>>23)&31))^(i>>31)); } -static inline long getclipmask(long a, long b, long c, long d) -{ // Ken did this +static inline int getclipmask(int a, int b, int c, int d) +{ + // Ken did this d = ((a<0)*8) + ((b<0)*4) + ((c<0)*2) + (d<0); return(((d<<4)^0xf0)|d); } -inline long getkensmessagecrc(long b) +inline int getkensmessagecrc(int b) { return 0x56c764d4l; b=b; @@ -541,8 +556,8 @@ inline long getkensmessagecrc(long b) #endif -static long xb1[MAXWALLSB], yb1[MAXWALLSB], xb2[MAXWALLSB], yb2[MAXWALLSB]; -static long rx1[MAXWALLSB], ry1[MAXWALLSB], rx2[MAXWALLSB], ry2[MAXWALLSB]; +static int xb1[MAXWALLSB], yb1[MAXWALLSB], xb2[MAXWALLSB], yb2[MAXWALLSB]; +static int rx1[MAXWALLSB], ry1[MAXWALLSB], rx2[MAXWALLSB], ry2[MAXWALLSB]; static short p2[MAXWALLSB], thesector[MAXWALLSB], thewall[MAXWALLSB]; static short bunchfirst[MAXWALLSB], bunchlast[MAXWALLSB]; @@ -550,123 +565,123 @@ static short bunchfirst[MAXWALLSB], bunchlast[MAXWALLSB]; static short smost[MAXYSAVES], smostcnt; static short smoststart[MAXWALLSB]; static char smostwalltype[MAXWALLSB]; -static long smostwall[MAXWALLSB], smostwallcnt = -1L; +static int smostwall[MAXWALLSB], smostwallcnt = -1L; static short maskwall[MAXWALLSB], maskwallcnt; -static long spritesx[MAXSPRITESONSCREEN]; -static long spritesy[MAXSPRITESONSCREEN+1]; -static long spritesz[MAXSPRITESONSCREEN]; +static int spritesx[MAXSPRITESONSCREEN]; +static int spritesy[MAXSPRITESONSCREEN+1]; +static int spritesz[MAXSPRITESONSCREEN]; static spritetype *tspriteptr[MAXSPRITESONSCREEN]; short umost[MAXXDIM], dmost[MAXXDIM]; static short bakumost[MAXXDIM], bakdmost[MAXXDIM]; short uplc[MAXXDIM], dplc[MAXXDIM]; static short uwall[MAXXDIM], dwall[MAXXDIM]; -static long swplc[MAXXDIM], lplc[MAXXDIM]; -static long swall[MAXXDIM], lwall[MAXXDIM+4]; -long xdimen = -1, xdimenrecip, halfxdimen, xdimenscale, xdimscale; -long wx1, wy1, wx2, wy2, ydimen; -long /*viewoffset,*/ frameoffset; +static int swplc[MAXXDIM], lplc[MAXXDIM]; +static int swall[MAXXDIM], lwall[MAXXDIM+4]; +int xdimen = -1, xdimenrecip, halfxdimen, xdimenscale, xdimscale; +int wx1, wy1, wx2, wy2, ydimen; +int /*viewoffset,*/ frameoffset; -static long nrx1[8], nry1[8], nrx2[8], nry2[8]; // JBF 20031206: Thanks Ken +static int nrx1[8], nry1[8], nrx2[8], nry2[8]; // JBF 20031206: Thanks Ken -static long rxi[8], ryi[8], rzi[8], rxi2[8], ryi2[8], rzi2[8]; -static long xsi[8], ysi[8], *horizlookup=0, *horizlookup2=0, horizycent; +static int rxi[8], ryi[8], rzi[8], rxi2[8], ryi2[8], rzi2[8]; +static int xsi[8], ysi[8], *horizlookup=0, *horizlookup2=0, horizycent; -long globalposx, globalposy, globalposz, globalhoriz; +int globalposx, globalposy, globalposz, globalhoriz; short globalang, globalcursectnum; -long globalpal, cosglobalang, singlobalang; -long cosviewingrangeglobalang, sinviewingrangeglobalang; +int globalpal, cosglobalang, singlobalang; +int cosviewingrangeglobalang, sinviewingrangeglobalang; char *globalpalwritten; -long globaluclip, globaldclip, globvis; -long globalvisibility, globalhisibility, globalpisibility, globalcisibility; +int globaluclip, globaldclip, globvis; +int globalvisibility, globalhisibility, globalpisibility, globalcisibility; char globparaceilclip, globparaflorclip; -long xyaspect, viewingrangerecip; +int xyaspect, viewingrangerecip; -long asm1, asm2, asm3, asm4; -long vplce[4], vince[4], palookupoffse[4], bufplce[4]; +int asm1, asm2, asm3, asm4; +int vplce[4], vince[4], palookupoffse[4], bufplce[4]; char globalxshift, globalyshift; -long globalxpanning, globalypanning, globalshade; +int globalxpanning, globalypanning, globalshade; short globalpicnum, globalshiftval; -long globalzd, globalbufplc, globalyscale, globalorientation; -long globalx1, globaly1, globalx2, globaly2, globalx3, globaly3, globalzx; -long globalx, globaly, globalz; +int globalzd, globalbufplc, globalyscale, globalorientation; +int globalx1, globaly1, globalx2, globaly2, globalx3, globaly3, globalzx; +int globalx, globaly, globalz; static short sectorborder[256], sectorbordercnt; static char tablesloaded = 0; -long pageoffset, ydim16, qsetmode = 0; -long startposx, startposy, startposz; +int pageoffset, ydim16, qsetmode = 0; +int startposx, startposy, startposz; short startang, startsectnum; short pointhighlight, linehighlight, highlightcnt; -static long lastx[MAXYDIM]; +static int lastx[MAXYDIM]; char *transluc = NULL, paletteloaded = 0; -long halfxdim16, midydim16; +int halfxdim16, midydim16; #define FASTPALGRIDSIZ 8 -static long rdist[129], gdist[129], bdist[129]; +static int rdist[129], gdist[129], bdist[129]; static char colhere[((FASTPALGRIDSIZ+2)*(FASTPALGRIDSIZ+2)*(FASTPALGRIDSIZ+2))>>3]; static char colhead[(FASTPALGRIDSIZ+2)*(FASTPALGRIDSIZ+2)*(FASTPALGRIDSIZ+2)]; -static long colnext[256]; +static int colnext[256]; static char coldist[8] = {0,1,2,3,4,3,2,1}; -static long colscan[27]; +static int colscan[27]; static short clipnum, hitwalls[4]; -long hitscangoalx = (1<<29)-1, hitscangoaly = (1<<29)-1; +int hitscangoalx = (1<<29)-1, hitscangoaly = (1<<29)-1; #ifdef POLYMOST -static long hitallsprites = 0; +static int hitallsprites = 0; #endif -typedef struct { long x1, y1, x2, y2; } linetype; +typedef struct { int x1, y1, x2, y2; } linetype; static linetype clipit[MAXCLIPNUM]; static short clipsectorlist[MAXCLIPNUM], clipsectnum; static short clipobjectval[MAXCLIPNUM]; typedef struct { - long sx, sy, z; + int sx, sy, z; short a, picnum; signed char dashade; char dapalnum, dastat, pagesleft; - long cx1, cy1, cx2, cy2; - long uniqid; //JF extension + int cx1, cy1, cx2, cy2; + int uniqid; //JF extension } permfifotype; static permfifotype permfifo[MAXPERMS]; -static long permhead = 0, permtail = 0; +static int permhead = 0, permtail = 0; short numscans, numhits, numbunches; static short posfil, capturecount = 0, hitcnt; char vgapal16[4*256] = - { - 00,00,00,00, 42,00,00,00, 00,42,00,00, 42,42,00,00, 00,00,42,00, - 42,00,42,00, 00,21,42,00, 42,42,42,00, 21,21,21,00, 63,21,21,00, - 21,63,21,00, 63,63,21,00, 21,21,63,00, 63,21,63,00, 21,63,63,00, - 63,63,63,00 - }; +{ + 00,00,00,00, 42,00,00,00, 00,42,00,00, 42,42,00,00, 00,00,42,00, + 42,00,42,00, 00,21,42,00, 42,42,42,00, 21,21,21,00, 63,21,21,00, + 21,63,21,00, 63,63,21,00, 21,21,63,00, 63,21,63,00, 21,63,63,00, + 63,63,63,00 +}; short editstatus = 0; short searchit; -long searchx = -1, searchy; //search input +int searchx = -1, searchy; //search input short searchsector, searchwall, searchstat; //search output double msens = 1.0; static char artfilename[20]; -static long numtilefiles, artfil = -1, artfilnum, artfilplc; +static int numtilefiles, artfil = -1, artfilnum, artfilplc; static char inpreparemirror = 0; -static long mirrorsx1, mirrorsy1, mirrorsx2, mirrorsy2; +static int mirrorsx1, mirrorsy1, mirrorsx2, mirrorsy2; -static long setviewcnt = 0; // interface layers use this now -static long bakframeplace[4], bakxsiz[4], bakysiz[4]; -static long bakwindowx1[4], bakwindowy1[4]; -static long bakwindowx2[4], bakwindowy2[4]; +static int setviewcnt = 0; // interface layers use this now +static int bakframeplace[4], bakxsiz[4], bakysiz[4]; +static int bakwindowx1[4], bakwindowy1[4]; +static int bakwindowx2[4], bakwindowy2[4]; #ifdef POLYMOST -static long bakrendmode,baktile; +static int bakrendmode,baktile; #endif -long totalclocklock; +int totalclocklock; char apptitle[256] = "Build Engine"; palette_t curpalette[256]; // the current palette, unadjusted for brightness or tint @@ -679,7 +694,7 @@ char palfadedelta = 0; // // Internal Engine Functions // -//long cacheresets = 0,cacheinvalidates = 0; +//int cacheresets = 0,cacheinvalidates = 0; //============================================================================= //POLYMOST BEGINS @@ -689,18 +704,18 @@ static void scansector(short sectnum); #include "hightile.c" #include "polymost.c" #else -void hicsetpalettetint(long palnum, unsigned char r, unsigned char g, unsigned char b, unsigned char effect) { } -int hicsetsubsttex(long picnum, long palnum, char *filen, float alphacut, float xscale, float yscale, char flags) { return 0; } -int hicsetskybox(long picnum, long palnum, char *faces[6]) { return 0; } -int hicclearsubst(long picnum, long palnum) { return 0; } -long polymost_drawtilescreen (long tilex, long tiley, long wallnum, long dimen, int tilezoom) { return -1; } +void hicsetpalettetint(int palnum, unsigned char r, unsigned char g, unsigned char b, unsigned char effect) { } +int hicsetsubsttex(int picnum, int palnum, char *filen, float alphacut, float xscale, float yscale, char flags) { return 0; } +int hicsetskybox(int picnum, int palnum, char *faces[6]) { return 0; } +int hicclearsubst(int picnum, int palnum) { return 0; } +int polymost_drawtilescreen(int tilex, int tiley, int wallnum, int dimen, int tilezoom) { return -1; } #endif //============================================================================= //POLYMOST ENDS // // getpalookup (internal) // -static inline long getpalookup(long davis, long dashade) +static inline int getpalookup(int davis, int dashade) { return(min(max(dashade+(davis>>8),0),numpalookups-1)); } @@ -713,7 +728,7 @@ static void scansector(short sectnum) { walltype *wal, *wal2; spritetype *spr; - long xs, ys, x1, y1, x2, y2, xp1, yp1, xp2=0, yp2=0, templong; + int xs, ys, x1, y1, x2, y2, xp1, yp1, xp2=0, yp2=0, tempint; short z, zz, startwall, endwall, numscansbefore, scanfirst, bunchfrst; short nextsectnum; @@ -761,9 +776,9 @@ static void scansector(short sectnum) if ((nextsectnum >= 0) && ((wal->cstat&32) == 0)) if ((gotsector[nextsectnum>>3]&pow2char[nextsectnum&7]) == 0) { - templong = x1*y2-x2*y1; - if (((unsigned)templong+262144) < 524288) - if (mulscale5(templong,templong) <= (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)) + tempint = x1*y2-x2*y1; + if (((unsigned)tempint+262144) < 524288) + if (mulscale5(tempint,tempint) <= (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)) sectorborder[sectorbordercnt++] = nextsectnum; } @@ -796,9 +811,9 @@ static void scansector(short sectnum) { if (xp2 < -yp2) goto skipitaddwall; xb1[numscans] = 0; - templong = yp1-yp2+xp1-xp2; - if (templong == 0) goto skipitaddwall; - yb1[numscans] = yp1 + scale(yp2-yp1,xp1+yp1,templong); + tempint = yp1-yp2+xp1-xp2; + if (tempint == 0) goto skipitaddwall; + yb1[numscans] = yp1 + scale(yp2-yp1,xp1+yp1,tempint); } if (yb1[numscans] < 256) goto skipitaddwall; @@ -814,9 +829,9 @@ static void scansector(short sectnum) { if (xp1 > yp1) goto skipitaddwall; xb2[numscans] = xdimen-1; - templong = xp2-xp1+yp1-yp2; - if (templong == 0) goto skipitaddwall; - yb2[numscans] = yp1 + scale(yp2-yp1,yp1-xp1,templong); + tempint = xp2-xp1+yp1-yp2; + if (tempint == 0) goto skipitaddwall; + yb2[numscans] = yp1 + scale(yp2-yp1,yp1-xp1,tempint); } if ((yb2[numscans] < 256) || (xb1[numscans] > xb2[numscans])) goto skipitaddwall; @@ -841,17 +856,18 @@ skipitaddwall: for (zz=bunchfirst[z];p2[zz]>=0;zz=p2[zz]); bunchlast[z] = zz; } - } while (sectorbordercnt > 0); + } + while (sectorbordercnt > 0); } // // maskwallscan (internal) // -static void maskwallscan(long x1, long x2, short *uwal, short *dwal, long *swal, long *lwal) +static void maskwallscan(int x1, int x2, short *uwal, short *dwal, int *swal, int *lwal) { - long i, x, startx, xnice, ynice, fpalookup; - long y1ve[4], y2ve[4], u4, d4, dax, z, p, tsizx, tsizy; + int i, x, startx, xnice, ynice, fpalookup; + int y1ve[4], y2ve[4], u4, d4, dax, z, p, tsizx, tsizy; char bad; tsizx = tilesizx[globalpicnum]; @@ -890,10 +906,10 @@ static void maskwallscan(long x1, long x2, short *uwal, short *dwal, long *swal, y2ve[0] = min(dwal[x],startdmost[x+windowx1]-windowy1); if (y2ve[0] <= y1ve[0]) continue; - palookupoffse[0] = fpalookup+(getpalookup((long)mulscale16(swal[x],globvis),globalshade)<<8); + palookupoffse[0] = fpalookup+(getpalookup((int)mulscale16(swal[x],globvis),globalshade)<<8); bufplce[0] = lwal[x] + globalxpanning; - if (bufplce[0] >= tsizx) { if (xnice == 0) bufplce[0] %= tsizx; else bufplce[0] &= tsizx; } + if (bufplce[0] >= tsizx) { if (xnice == 0) bufplce[0] %= tsizx; else bufplce[0] &= tsizx; } if (ynice == 0) bufplce[0] *= tsizy; else bufplce[0] <<= tsizy; vince[0] = swal[x]*globalyscale; @@ -920,8 +936,8 @@ static void maskwallscan(long x1, long x2, short *uwal, short *dwal, long *swal, } if (bad == 15) continue; - palookupoffse[0] = fpalookup+(getpalookup((long)mulscale16(swal[x],globvis),globalshade)<<8); - palookupoffse[3] = fpalookup+(getpalookup((long)mulscale16(swal[x+3],globvis),globalshade)<<8); + palookupoffse[0] = fpalookup+(getpalookup((int)mulscale16(swal[x],globvis),globalshade)<<8); + palookupoffse[3] = fpalookup+(getpalookup((int)mulscale16(swal[x+3],globvis),globalshade)<<8); if ((palookupoffse[0] == palookupoffse[3]) && ((bad&0x9) == 0)) { @@ -930,8 +946,8 @@ static void maskwallscan(long x1, long x2, short *uwal, short *dwal, long *swal, } else { - palookupoffse[1] = fpalookup+(getpalookup((long)mulscale16(swal[x+1],globvis),globalshade)<<8); - palookupoffse[2] = fpalookup+(getpalookup((long)mulscale16(swal[x+2],globvis),globalshade)<<8); + palookupoffse[1] = fpalookup+(getpalookup((int)mulscale16(swal[x+1],globvis),globalshade)<<8); + palookupoffse[2] = fpalookup+(getpalookup((int)mulscale16(swal[x+2],globvis),globalshade)<<8); } u4 = max(max(y1ve[0],y1ve[1]),max(y1ve[2],y1ve[3])); @@ -965,10 +981,10 @@ static void maskwallscan(long x1, long x2, short *uwal, short *dwal, long *swal, y2ve[0] = min(dwal[x],startdmost[x+windowx1]-windowy1); if (y2ve[0] <= y1ve[0]) continue; - palookupoffse[0] = fpalookup+(getpalookup((long)mulscale16(swal[x],globvis),globalshade)<<8); + palookupoffse[0] = fpalookup+(getpalookup((int)mulscale16(swal[x],globvis),globalshade)<<8); bufplce[0] = lwal[x] + globalxpanning; - if (bufplce[0] >= tsizx) { if (xnice == 0) bufplce[0] %= tsizx; else bufplce[0] &= tsizx; } + if (bufplce[0] >= tsizx) { if (xnice == 0) bufplce[0] %= tsizx; else bufplce[0] &= tsizx; } if (ynice == 0) bufplce[0] *= tsizy; else bufplce[0] <<= tsizy; vince[0] = swal[x]*globalyscale; @@ -986,10 +1002,10 @@ static void maskwallscan(long x1, long x2, short *uwal, short *dwal, long *swal, y2ve[0] = min(dwal[x],startdmost[x+windowx1]-windowy1); if (y2ve[0] <= y1ve[0]) continue; - palookupoffse[0] = fpalookup+(getpalookup((long)mulscale16(swal[x],globvis),globalshade)<<8); + palookupoffse[0] = fpalookup+(getpalookup((int)mulscale16(swal[x],globvis),globalshade)<<8); bufplce[0] = lwal[x] + globalxpanning; - if (bufplce[0] >= tsizx) { if (xnice == 0) bufplce[0] %= tsizx; else bufplce[0] &= tsizx; } + if (bufplce[0] >= tsizx) { if (xnice == 0) bufplce[0] %= tsizx; else bufplce[0] &= tsizx; } if (ynice == 0) bufplce[0] *= tsizy; else bufplce[0] <<= tsizy; vince[0] = swal[x]*globalyscale; @@ -1007,10 +1023,10 @@ static void maskwallscan(long x1, long x2, short *uwal, short *dwal, long *swal, // // wallfront (internal) // -static long wallfront(long l1, long l2) +static int wallfront(int l1, int l2) { walltype *wal; - long x11, y11, x21, y21, x12, y12, x22, y22, dx, dy, t1, t2; + int x11, y11, x21, y21, x12, y12, x22, y22, dx, dy, t1, t2; wal = &wall[thewall[l1]]; x11 = wal->x; y11 = wal->y; wal = &wall[wal->point2]; x21 = wal->x; y21 = wal->y; @@ -1045,10 +1061,10 @@ static long wallfront(long l1, long l2) // // spritewallfront (internal) // -static long spritewallfront(spritetype *s, long w) +static int spritewallfront(spritetype *s, int w) { walltype *wal; - long x1, y1; + int x1, y1; wal = &wall[w]; x1 = wal->x; y1 = wal->y; wal = &wall[wal->point2]; @@ -1058,12 +1074,12 @@ static long spritewallfront(spritetype *s, long w) // // spritebehindwall(internal) // -static long spriteobstructswall(spritetype *s, long w) +static int spriteobstructswall(spritetype *s, int w) { walltype *wal; - long x, y; - long x1, y1; - long x2, y2; + int x, y; + int x1, y1; + int x2, y2; double a1, b1, c1; double a2, b2, c2; double d1, d2; @@ -1109,9 +1125,9 @@ static long spriteobstructswall(spritetype *s, long w) // // bunchfront (internal) // -static long bunchfront(long b1, long b2) +static int bunchfront(int b1, int b2) { - long x1b1, x2b1, x1b2, x2b2, b1f, b2f, i; + int x1b1, x2b1, x1b2, x2b2, b1f, b2f, i; b1f = bunchfirst[b1]; x1b1 = xb1[b1f]; x2b2 = xb2[bunchlast[b2]]+1; if (x1b1 >= x2b2) return(-1); @@ -1131,15 +1147,15 @@ static long bunchfront(long b1, long b2) // // hline (internal) // -static void hline(long xr, long yp) +static void hline(int xr, int yp) { - long xl, r, s; + int xl, r, s; xl = lastx[yp]; if (xl > xr) return; r = horizlookup2[yp-globalhoriz+horizycent]; asm1 = globalx1*r; asm2 = globaly2*r; - s = ((long)getpalookup((long)mulscale16(r,globvis),globalshade)<<8); + s = ((int)getpalookup((int)mulscale16(r,globvis),globalshade)<<8); hlineasm4(xr-xl,0L,s,globalx2*r+globalypanning,globaly1*r+globalxpanning, ylookup[yp]+xr+frameoffset); @@ -1149,16 +1165,16 @@ static void hline(long xr, long yp) // // slowhline (internal) // -static void slowhline(long xr, long yp) +static void slowhline(int xr, int yp) { - long xl, r; + int xl, r; xl = lastx[yp]; if (xl > xr) return; r = horizlookup2[yp-globalhoriz+horizycent]; asm1 = globalx1*r; asm2 = globaly2*r; - asm3 = (long)globalpalwritten + ((long)getpalookup((long)mulscale16(r,globvis),globalshade)<<8); + asm3 = (int)globalpalwritten + ((int)getpalookup((int)mulscale16(r,globvis),globalshade)<<8); if (!(globalorientation&256)) { mhline(globalbufplc,globaly1*r+globalxpanning-asm1*(xr-xl),(xr-xl)<<16,0L, @@ -1173,9 +1189,9 @@ static void slowhline(long xr, long yp) // // prepwall (internal) // -static void prepwall(long z, walltype *wal) +static void prepwall(int z, walltype *wal) { - long i, l=0, ol=0, splc, sinc, x, topinc, top, botinc, bot, walxrepeat; + int i, l=0, ol=0, splc, sinc, x, topinc, top, botinc, bot, walxrepeat; walxrepeat = (wal->xrepeat<<3); @@ -1254,9 +1270,9 @@ static void prepwall(long z, walltype *wal) // // animateoffs (internal) // -long animateoffs(short tilenum, short fakevar) +int animateoffs(short tilenum, short fakevar) { - long i, k, offs; + int i, k, offs; offs = 0; i = (totalclocklock>>((picanm[tilenum]>>24)&15)); @@ -1285,11 +1301,11 @@ long animateoffs(short tilenum, short fakevar) // // owallmost (internal) // -static long owallmost(short *mostbuf, long w, long z) +static int owallmost(short *mostbuf, int w, int z) { - long bad, inty, xcross, y, yinc; - long s1, s2, s3, s4, ix1, ix2, iy1, iy2, t; - long i; + int bad, inty, xcross, y, yinc; + int s1, s2, s3, s4, ix1, ix2, iy1, iy2, t; + int i; z <<= 7; s1 = mulscale20(globaluclip,yb1[w]); s2 = mulscale20(globaluclip,yb2[w]); @@ -1355,7 +1371,7 @@ static long owallmost(short *mostbuf, long w, long z) y = (scale(z,xdimenscale,iy1)<<4); yinc = ((scale(z,xdimenscale,iy2)<<4)-y) / (ix2-ix1+1); - qinterpolatedown16short((long)&mostbuf[ix1],ix2-ix1+1,y+(globalhoriz<<16),yinc); + qinterpolatedown16short((int)&mostbuf[ix1],ix2-ix1+1,y+(globalhoriz<<16),yinc); if (mostbuf[ix1] < 0) mostbuf[ix1] = 0; if (mostbuf[ix1] > ydimen) mostbuf[ix1] = ydimen; @@ -1369,11 +1385,11 @@ static long owallmost(short *mostbuf, long w, long z) // // wallmost (internal) // -static long wallmost(short *mostbuf, long w, long sectnum, char dastat) +static int wallmost(short *mostbuf, int w, int sectnum, char dastat) { - long bad, i, j, t, y, z, inty, intz, xcross, yinc, fw; - long x1, y1, z1, x2, y2, z2, xv, yv, dx, dy, dasqr, oz1, oz2; - long s1, s2, s3, s4, ix1, ix2, iy1, iy2; + int bad, i, j, t, y, z, inty, intz, xcross, yinc, fw; + int x1, y1, z1, x2, y2, z2, xv, yv, dx, dy, dasqr, oz1, oz2; + int s1, s2, s3, s4, ix1, ix2, iy1, iy2; //char datempbuf[256]; if (dastat == 0) @@ -1398,9 +1414,9 @@ static long wallmost(short *mostbuf, long w, long sectnum, char dastat) dasqr = krecipasm(nsqrtasm(dx*dx+dy*dy)); if (xb1[w] == 0) - { xv = cosglobalang+sinviewingrangeglobalang; yv = singlobalang-cosviewingrangeglobalang; } + { xv = cosglobalang+sinviewingrangeglobalang; yv = singlobalang-cosviewingrangeglobalang; } else - { xv = x1-globalposx; yv = y1-globalposy; } + { xv = x1-globalposx; yv = y1-globalposy; } i = xv*(y1-globalposy)-yv*(x1-globalposx); j = yv*x2-xv*y2; if (klabs(j) > klabs(i>>3)) i = divscale28(i,j); if (dastat == 0) @@ -1418,9 +1434,9 @@ static long wallmost(short *mostbuf, long w, long sectnum, char dastat) if (xb2[w] == xdimen-1) - { xv = cosglobalang-sinviewingrangeglobalang; yv = singlobalang+cosviewingrangeglobalang; } + { xv = cosglobalang-sinviewingrangeglobalang; yv = singlobalang+cosviewingrangeglobalang; } else - { xv = (x2+x1)-globalposx; yv = (y2+y1)-globalposy; } + { xv = (x2+x1)-globalposx; yv = (y2+y1)-globalposy; } i = xv*(y1-globalposy)-yv*(x1-globalposx); j = yv*x2-xv*y2; if (klabs(j) > klabs(i>>3)) i = divscale28(i,j); if (dastat == 0) @@ -1513,7 +1529,7 @@ static long wallmost(short *mostbuf, long w, long sectnum, char dastat) y = (scale(z1,xdimenscale,iy1)<<4); yinc = ((scale(z2,xdimenscale,iy2)<<4)-y) / (ix2-ix1+1); - qinterpolatedown16short((long)&mostbuf[ix1],ix2-ix1+1,y+(globalhoriz<<16),yinc); + qinterpolatedown16short((int)&mostbuf[ix1],ix2-ix1+1,y+(globalhoriz<<16),yinc); if (mostbuf[ix1] < 0) mostbuf[ix1] = 0; if (mostbuf[ix1] > ydimen) mostbuf[ix1] = ydimen; @@ -1527,9 +1543,9 @@ static long wallmost(short *mostbuf, long w, long sectnum, char dastat) // // ceilscan (internal) // -static void ceilscan(long x1, long x2, long sectnum) +static void ceilscan(int x1, int x2, int sectnum) { - long i, j, ox, oy, x, y1, y2, twall, bwall; + int i, j, ox, oy, x, y1, y2, twall, bwall; sectortype *sec; sec = §or[sectnum]; @@ -1551,10 +1567,10 @@ static void ceilscan(long x1, long x2, long sectnum) if (waloff[globalpicnum] == 0) loadtile(globalpicnum); globalbufplc = waloff[globalpicnum]; - globalshade = (long)sec->ceilingshade; + globalshade = (int)sec->ceilingshade; globvis = globalcisibility; - if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16))); - globalorientation = (long)sec->ceilingstat; + if (sec->visibility != 0) globvis = mulscale4(globvis,(int)((unsigned char)(sec->visibility+16))); + globalorientation = (int)sec->ceilingstat; if ((globalorientation&64) == 0) @@ -1586,7 +1602,7 @@ static void ceilscan(long x1, long x2, long sectnum) globaly1 = mulscale16(globaly1,viewingrangerecip); globalxshift = (8-(picsiz[globalpicnum]&15)); globalyshift = (8-(picsiz[globalpicnum]>>4)); -if (globalorientation&8) { globalxshift++; globalyshift++; } + if (globalorientation&8) { globalxshift++; globalyshift++; } if ((globalorientation&0x4) > 0) { @@ -1599,8 +1615,8 @@ if (globalorientation&8) { globalxshift++; globalyshift++; } globalx1 <<= globalxshift; globaly1 <<= globalxshift; globalx2 <<= globalyshift; globaly2 <<= globalyshift; globalxpanning <<= globalxshift; globalypanning <<= globalyshift; - globalxpanning += (((long)sec->ceilingxpanning)<<24); - globalypanning += (((long)sec->ceilingypanning)<<24); + globalxpanning += (((int)sec->ceilingxpanning)<<24); + globalypanning += (((int)sec->ceilingypanning)<<24); globaly1 = (-globalx1-globaly1)*halfxdimen; globalx2 = (globalx2-globaly2)*halfxdimen; @@ -1638,7 +1654,7 @@ if (globalorientation&8) { globalxshift++; globalyshift++; } else { while (y1 < y2-1) hline(x-1,++y1); - if (x == x2) { globalx2 += globaly2; globaly1 += globalx1; break; } + if (x == x2) { globalx2 += globaly2; globaly1 += globalx1; break; } y1 = umost[x+1]; y2 = y1; } globalx2 += globaly2; globaly1 += globalx1; @@ -1685,7 +1701,7 @@ if (globalorientation&8) { globalxshift++; globalyshift++; } else { while (y1 < y2-1) slowhline(x-1,++y1); - if (x == x2) { globalx2 += globaly2; globaly1 += globalx1; break; } + if (x == x2) { globalx2 += globaly2; globaly1 += globalx1; break; } y1 = umost[x+1]; y2 = y1; } globalx2 += globaly2; globaly1 += globalx1; @@ -1698,9 +1714,9 @@ if (globalorientation&8) { globalxshift++; globalyshift++; } // // florscan (internal) // -static void florscan(long x1, long x2, long sectnum) +static void florscan(int x1, int x2, int sectnum) { - long i, j, ox, oy, x, y1, y2, twall, bwall; + int i, j, ox, oy, x, y1, y2, twall, bwall; sectortype *sec; sec = §or[sectnum]; @@ -1722,10 +1738,10 @@ static void florscan(long x1, long x2, long sectnum) if (waloff[globalpicnum] == 0) loadtile(globalpicnum); globalbufplc = waloff[globalpicnum]; - globalshade = (long)sec->floorshade; + globalshade = (int)sec->floorshade; globvis = globalcisibility; - if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16))); - globalorientation = (long)sec->floorstat; + if (sec->visibility != 0) globvis = mulscale4(globvis,(int)((unsigned char)(sec->visibility+16))); + globalorientation = (int)sec->floorstat; if ((globalorientation&64) == 0) @@ -1757,7 +1773,7 @@ static void florscan(long x1, long x2, long sectnum) globaly1 = mulscale16(globaly1,viewingrangerecip); globalxshift = (8-(picsiz[globalpicnum]&15)); globalyshift = (8-(picsiz[globalpicnum]>>4)); -if (globalorientation&8) { globalxshift++; globalyshift++; } + if (globalorientation&8) { globalxshift++; globalyshift++; } if ((globalorientation&0x4) > 0) { @@ -1770,8 +1786,8 @@ if (globalorientation&8) { globalxshift++; globalyshift++; } globalx1 <<= globalxshift; globaly1 <<= globalxshift; globalx2 <<= globalyshift; globaly2 <<= globalyshift; globalxpanning <<= globalxshift; globalypanning <<= globalyshift; - globalxpanning += (((long)sec->floorxpanning)<<24); - globalypanning += (((long)sec->floorypanning)<<24); + globalxpanning += (((int)sec->floorxpanning)<<24); + globalypanning += (((int)sec->floorypanning)<<24); globaly1 = (-globalx1-globaly1)*halfxdimen; globalx2 = (globalx2-globaly2)*halfxdimen; @@ -1809,7 +1825,7 @@ if (globalorientation&8) { globalxshift++; globalyshift++; } else { while (y1 < y2-1) hline(x-1,++y1); - if (x == x2) { globalx2 += globaly2; globaly1 += globalx1; break; } + if (x == x2) { globalx2 += globaly2; globaly1 += globalx1; break; } y1 = max(dplc[x+1],umost[x+1]); y2 = y1; } globalx2 += globaly2; globaly1 += globalx1; @@ -1856,7 +1872,7 @@ if (globalorientation&8) { globalxshift++; globalyshift++; } else { while (y1 < y2-1) slowhline(x-1,++y1); - if (x == x2) { globalx2 += globaly2; globaly1 += globalx1; break; } + if (x == x2) { globalx2 += globaly2; globaly1 += globalx1; break; } y1 = max(dplc[x+1],umost[x+1]); y2 = y1; } globalx2 += globaly2; globaly1 += globalx1; @@ -1869,10 +1885,10 @@ if (globalorientation&8) { globalxshift++; globalyshift++; } // // wallscan (internal) // -static void wallscan(long x1, long x2, short *uwal, short *dwal, long *swal, long *lwal) +static void wallscan(int x1, int x2, short *uwal, short *dwal, int *swal, int *lwal) { - long i, x, xnice, ynice, fpalookup; - long y1ve[4], y2ve[4], u4, d4, z, tsizx, tsizy; + int i, x, xnice, ynice, fpalookup; + int y1ve[4], y2ve[4], u4, d4, z, tsizx, tsizy; char bad; if (x2 >= xdim) x2 = xdim-1; @@ -1906,10 +1922,10 @@ static void wallscan(long x1, long x2, short *uwal, short *dwal, long *swal, lon y2ve[0] = min(dwal[x],dmost[x]); if (y2ve[0] <= y1ve[0]) continue; - palookupoffse[0] = fpalookup+(getpalookup((long)mulscale16(swal[x],globvis),globalshade)<<8); + palookupoffse[0] = fpalookup+(getpalookup((int)mulscale16(swal[x],globvis),globalshade)<<8); bufplce[0] = lwal[x] + globalxpanning; - if (bufplce[0] >= tsizx) { if (xnice == 0) bufplce[0] %= tsizx; else bufplce[0] &= tsizx; } + if (bufplce[0] >= tsizx) { if (xnice == 0) bufplce[0] %= tsizx; else bufplce[0] &= tsizx; } if (ynice == 0) bufplce[0] *= tsizy; else bufplce[0] <<= tsizy; vince[0] = swal[x]*globalyscale; @@ -1936,8 +1952,8 @@ static void wallscan(long x1, long x2, short *uwal, short *dwal, long *swal, lon } if (bad == 15) continue; - palookupoffse[0] = fpalookup+(getpalookup((long)mulscale16(swal[x],globvis),globalshade)<<8); - palookupoffse[3] = fpalookup+(getpalookup((long)mulscale16(swal[x+3],globvis),globalshade)<<8); + palookupoffse[0] = fpalookup+(getpalookup((int)mulscale16(swal[x],globvis),globalshade)<<8); + palookupoffse[3] = fpalookup+(getpalookup((int)mulscale16(swal[x+3],globvis),globalshade)<<8); if ((palookupoffse[0] == palookupoffse[3]) && ((bad&0x9) == 0)) { @@ -1946,8 +1962,8 @@ static void wallscan(long x1, long x2, short *uwal, short *dwal, long *swal, lon } else { - palookupoffse[1] = fpalookup+(getpalookup((long)mulscale16(swal[x+1],globvis),globalshade)<<8); - palookupoffse[2] = fpalookup+(getpalookup((long)mulscale16(swal[x+2],globvis),globalshade)<<8); + palookupoffse[1] = fpalookup+(getpalookup((int)mulscale16(swal[x+1],globvis),globalshade)<<8); + palookupoffse[2] = fpalookup+(getpalookup((int)mulscale16(swal[x+2],globvis),globalshade)<<8); } u4 = max(max(y1ve[0],y1ve[1]),max(y1ve[2],y1ve[3])); @@ -1981,10 +1997,10 @@ static void wallscan(long x1, long x2, short *uwal, short *dwal, long *swal, lon y2ve[0] = min(dwal[x],dmost[x]); if (y2ve[0] <= y1ve[0]) continue; - palookupoffse[0] = fpalookup+(getpalookup((long)mulscale16(swal[x],globvis),globalshade)<<8); + palookupoffse[0] = fpalookup+(getpalookup((int)mulscale16(swal[x],globvis),globalshade)<<8); bufplce[0] = lwal[x] + globalxpanning; - if (bufplce[0] >= tsizx) { if (xnice == 0) bufplce[0] %= tsizx; else bufplce[0] &= tsizx; } + if (bufplce[0] >= tsizx) { if (xnice == 0) bufplce[0] %= tsizx; else bufplce[0] &= tsizx; } if (ynice == 0) bufplce[0] *= tsizy; else bufplce[0] <<= tsizy; vince[0] = swal[x]*globalyscale; @@ -2001,10 +2017,10 @@ static void wallscan(long x1, long x2, short *uwal, short *dwal, long *swal, lon y2ve[0] = min(dwal[x],dmost[x]); if (y2ve[0] <= y1ve[0]) continue; - palookupoffse[0] = fpalookup+(getpalookup((long)mulscale16(swal[x],globvis),globalshade)<<8); + palookupoffse[0] = fpalookup+(getpalookup((int)mulscale16(swal[x],globvis),globalshade)<<8); bufplce[0] = lwal[x] + globalxpanning; - if (bufplce[0] >= tsizx) { if (xnice == 0) bufplce[0] %= tsizx; else bufplce[0] &= tsizx; } + if (bufplce[0] >= tsizx) { if (xnice == 0) bufplce[0] %= tsizx; else bufplce[0] &= tsizx; } if (ynice == 0) bufplce[0] *= tsizy; else bufplce[0] <<= tsizy; vince[0] = swal[x]*globalyscale; @@ -2022,9 +2038,9 @@ static void wallscan(long x1, long x2, short *uwal, short *dwal, long *swal, lon // // transmaskvline (internal) // -static void transmaskvline(long x) +static void transmaskvline(int x) { - long vplc, vinc, p, i, palookupoffs, bufplc; + int vplc, vinc, p, i, palookupoffs, bufplc; short y1v, y2v; if ((x < 0) || (x >= xdimen)) return; @@ -2034,7 +2050,7 @@ static void transmaskvline(long x) y2v--; if (y2v < y1v) return; - palookupoffs = FP_OFF(palookup[globalpal]) + (getpalookup((long)mulscale16(swall[x],globvis),globalshade)<<8); + palookupoffs = FP_OFF(palookup[globalpal]) + (getpalookup((int)mulscale16(swall[x],globvis),globalshade)<<8); vinc = swall[x]*globalyscale; vplc = globalzd + vinc*(y1v-globalhoriz+1); @@ -2053,13 +2069,13 @@ static void transmaskvline(long x) // transmaskvline2 (internal) // #ifndef ENGINE_USING_A_C -static void transmaskvline2(long x) +static void transmaskvline2(int x) { - long i, y1, y2, x2; + int i, y1, y2, x2; short y1ve[2], y2ve[2]; if ((x < 0) || (x >= xdimen)) return; -if (x == xdimen-1) { transmaskvline(x); return; } + if (x == xdimen-1) { transmaskvline(x); return; } x2 = x+1; @@ -2070,8 +2086,8 @@ if (x == xdimen-1) { transmaskvline(x); return; } y2ve[1] = min(dwall[x2],startdmost[x2+windowx1]-windowy1)-1; if (y2ve[1] < y1ve[1]) { transmaskvline(x); return; } - palookupoffse[0] = FP_OFF(palookup[globalpal]) + (getpalookup((long)mulscale16(swall[x],globvis),globalshade)<<8); - palookupoffse[1] = FP_OFF(palookup[globalpal]) + (getpalookup((long)mulscale16(swall[x2],globvis),globalshade)<<8); + palookupoffse[0] = FP_OFF(palookup[globalpal]) + (getpalookup((int)mulscale16(swall[x],globvis),globalshade)<<8); + palookupoffse[1] = FP_OFF(palookup[globalpal]) + (getpalookup((int)mulscale16(swall[x2],globvis),globalshade)<<8); setuptvlineasm2(globalshiftval,palookupoffse[0],palookupoffse[1]); @@ -2125,9 +2141,9 @@ if (x == xdimen-1) { transmaskvline(x); return; } // // transmaskwallscan (internal) // -static void transmaskwallscan(long x1, long x2) +static void transmaskwallscan(int x1, int x2) { - long x; + int x; setgotpic(globalpicnum); if ((tilesizx[globalpicnum] <= 0) || (tilesizy[globalpicnum] <= 0)) return; @@ -2150,9 +2166,9 @@ static void transmaskwallscan(long x1, long x2) // // ceilspritehline (internal) // -static void ceilspritehline(long x2, long y) +static void ceilspritehline(int x2, int y) { - long x1, v, bx, by; + int x1, v, bx, by; //x = x1 + (x2-x1)t + (y1-y2)u ~ x = 160v //y = y1 + (y2-y1)t + (x2-x1)u ~ y = (scrx-160)v @@ -2166,7 +2182,7 @@ static void ceilspritehline(long x2, long y) asm1 = mulscale14(globalx2,v); asm2 = mulscale14(globaly2,v); - asm3 = FP_OFF(palookup[globalpal]) + (getpalookup((long)mulscale28(klabs(v),globvis),globalshade)<<8); + asm3 = FP_OFF(palookup[globalpal]) + (getpalookup((int)mulscale28(klabs(v),globvis),globalshade)<<8); if ((globalorientation&2) == 0) mhline(globalbufplc,bx,(x2-x1)<<16,0L,by,ylookup[y]+x1+frameoffset); @@ -2180,9 +2196,9 @@ static void ceilspritehline(long x2, long y) // // ceilspritescan (internal) // -static void ceilspritescan(long x1, long x2) +static void ceilspritescan(int x1, int x2) { - long x, y1, y2, twall, bwall; + int x, y1, y2, twall, bwall; y1 = uwall[x1]; y2 = y1; for (x=x1;x<=x2;x++) @@ -2219,11 +2235,11 @@ static void ceilspritescan(long x1, long x2) // grouscan (internal) // #define BITSOFPRECISION 3 //Don't forget to change this in A.ASM also! -static void grouscan(long dax1, long dax2, long sectnum, char dastat) +static void grouscan(int dax1, int dax2, int sectnum, char dastat) { - long i, j, l, x, y, dx, dy, wx, wy, y1, y2, daz; - long daslope, dasqr; - long shoffs, shinc, m1, m2, *mptr1, *mptr2, *nptr1, *nptr2; + int i, j, l, x, y, dx, dy, wx, wy, y1, y2, daz; + int daslope, dasqr; + int shoffs, shinc, m1, m2, *mptr1, *mptr2, *nptr1, *nptr2; walltype *wal; sectortype *sec; @@ -2314,24 +2330,24 @@ static void grouscan(long dax1, long dax2, long sectnum, char dastat) if (dastat == 0) { - globalx1 += (((long)sec->ceilingxpanning)<<24); - globaly1 += (((long)sec->ceilingypanning)<<24); + globalx1 += (((int)sec->ceilingxpanning)<<24); + globaly1 += (((int)sec->ceilingypanning)<<24); } else { - globalx1 += (((long)sec->floorxpanning)<<24); - globaly1 += (((long)sec->floorypanning)<<24); + globalx1 += (((int)sec->floorxpanning)<<24); + globaly1 += (((int)sec->floorypanning)<<24); } asm1 = -(globalzd>>(16-BITSOFPRECISION)); globvis = globalvisibility; - if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16))); + if (sec->visibility != 0) globvis = mulscale4(globvis,(int)((unsigned char)(sec->visibility+16))); globvis = mulscale13(globvis,daz); globvis = mulscale16(globvis,xdimscale); j = FP_OFF(palookup[globalpal]); - setupslopevlin(((long)(picsiz[globalpicnum]&15))+(((long)(picsiz[globalpicnum]>>4))<<8),waloff[globalpicnum],-ylookup[1]); + setupslopevlin(((int)(picsiz[globalpicnum]&15))+(((int)(picsiz[globalpicnum]>>4))<<8),waloff[globalpicnum],-ylookup[1]); l = (globalzd>>16); @@ -2342,7 +2358,7 @@ static void grouscan(long dax1, long dax2, long sectnum, char dastat) //Avoid visibility overflow by crossing horizon if (globalzd > 0) m1 += (globalzd>>16); else m1 -= (globalzd>>16); m2 = m1+l; - mptr1 = (long *)&slopalookup[y1+(shoffs>>15)]; mptr2 = mptr1+1; + mptr1 = (int *)&slopalookup[y1+(shoffs>>15)]; mptr2 = mptr1+1; for (x=dax1;x<=dax2;x++) { @@ -2350,23 +2366,23 @@ static void grouscan(long dax1, long dax2, long sectnum, char dastat) else { y1 = max(umost[x],dplc[x]); y2 = dmost[x]-1; } if (y1 <= y2) { - nptr1 = (long *)&slopalookup[y1+(shoffs>>15)]; - nptr2 = (long *)&slopalookup[y2+(shoffs>>15)]; + nptr1 = (int *)&slopalookup[y1+(shoffs>>15)]; + nptr2 = (int *)&slopalookup[y2+(shoffs>>15)]; while (nptr1 <= mptr1) { - *mptr1-- = j + (getpalookup((long)mulscale24(krecipasm(m1),globvis),globalshade)<<8); + *mptr1-- = j + (getpalookup((int)mulscale24(krecipasm(m1),globvis),globalshade)<<8); m1 -= l; } while (nptr2 >= mptr2) { - *mptr2++ = j + (getpalookup((long)mulscale24(krecipasm(m2),globvis),globalshade)<<8); + *mptr2++ = j + (getpalookup((int)mulscale24(krecipasm(m2),globvis),globalshade)<<8); m2 += l; } globalx3 = (globalx2>>10); globaly3 = (globaly2>>10); asm3 = mulscale16(y2,globalzd) + (globalzx>>6); - slopevlin(ylookup[y2]+x+frameoffset,krecipasm(asm3>>3),(long)nptr2,y2-y1+1,globalx1,globaly1); + slopevlin(ylookup[y2]+x+frameoffset,krecipasm(asm3>>3),(int)nptr2,y2-y1+1,globalx1,globaly1); if ((x&15) == 0) faketimerhandler(); } @@ -2381,10 +2397,10 @@ static void grouscan(long dax1, long dax2, long sectnum, char dastat) // // parascan (internal) // -static void parascan(long dax1, long dax2, long sectnum, char dastat, long bunch) +static void parascan(int dax1, int dax2, int sectnum, char dastat, int bunch) { sectortype *sec; - long j, k, l, m, n, x, z, wallnum, nextsectnum, globalhorizbak; + int j, k, l, m, n, x, z, wallnum, nextsectnum, globalhorizbak; short *topptr, *botptr; sectnum = thesector[bunchfirst[bunch]]; sec = §or[sectnum]; @@ -2394,15 +2410,15 @@ static void parascan(long dax1, long dax2, long sectnum, char dastat, long bunch globalhoriz = mulscale16(globalhoriz-(ydimen>>1),parallaxyscale) + (ydimen>>1); globvis = globalpisibility; //globalorientation = 0L; - if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16))); + if (sec->visibility != 0) globvis = mulscale4(globvis,(int)((unsigned char)(sec->visibility+16))); if (dastat == 0) { globalpal = sec->ceilingpal; globalpicnum = sec->ceilingpicnum; - globalshade = (long)sec->ceilingshade; - globalxpanning = (long)sec->ceilingxpanning; - globalypanning = (long)sec->ceilingypanning; + globalshade = (int)sec->ceilingshade; + globalxpanning = (int)sec->ceilingxpanning; + globalypanning = (int)sec->ceilingypanning; topptr = umost; botptr = uplc; } @@ -2410,9 +2426,9 @@ static void parascan(long dax1, long dax2, long sectnum, char dastat, long bunch { globalpal = sec->floorpal; globalpicnum = sec->floorpicnum; - globalshade = (long)sec->floorshade; - globalxpanning = (long)sec->floorxpanning; - globalypanning = (long)sec->floorypanning; + globalshade = (int)sec->floorshade; + globalxpanning = (int)sec->floorxpanning; + globalypanning = (int)sec->floorypanning; topptr = dplc; botptr = dmost; } @@ -2449,13 +2465,13 @@ static void parascan(long dax1, long dax2, long sectnum, char dastat, long bunch else { for (j=xb1[z];j<=xb2[z];j++) - lplc[j] = ((((long)radarang2[j]+globalang)&2047)>>k); + lplc[j] = ((((int)radarang2[j]+globalang)&2047)>>k); } if (parallaxtype == 2) { n = mulscale16(xdimscale,viewingrange); for (j=xb1[z];j<=xb2[z];j++) - swplc[j] = mulscale14(sintable[((long)radarang2[j]+512)&2047],n); + swplc[j] = mulscale14(sintable[((int)radarang2[j]+512)&2047],n); } else clearbuf(&swplc[xb1[z]],xb2[z]-xb1[z]+1,mulscale16(xdimscale,viewingrange)); @@ -2523,13 +2539,13 @@ static void parascan(long dax1, long dax2, long sectnum, char dastat, long bunch // // drawalls (internal) // -static void drawalls(long bunch) +static void drawalls(int bunch) { sectortype *sec, *nextsec; walltype *wal; - long i, x, x1, x2, cz[5], fz[5]; - long z, wallnum, sectnum, nextsectnum; - long startsmostwallcnt, startsmostcnt, gotswall; + int i, x, x1, x2, cz[5], fz[5]; + int z, wallnum, sectnum, nextsectnum; + int startsmostwallcnt, startsmostcnt, gotswall; char andwstat1, andwstat2; z = bunchfirst[bunch]; @@ -2636,19 +2652,19 @@ static void drawalls(long bunch) searchstat = 0; searchit = 1; } - globalorientation = (long)wal->cstat; + globalorientation = (int)wal->cstat; globalpicnum = wal->picnum; if ((unsigned)globalpicnum >= (unsigned)MAXTILES) globalpicnum = 0; - globalxpanning = (long)wal->xpanning; - globalypanning = (long)wal->ypanning; + globalxpanning = (int)wal->xpanning; + globalypanning = (int)wal->ypanning; globalshiftval = (picsiz[globalpicnum]>>4); if (pow2long[globalshiftval] != tilesizy[globalpicnum]) globalshiftval++; globalshiftval = 32-globalshiftval; if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,(short)wallnum+16384); - globalshade = (long)wal->shade; + globalshade = (int)wal->shade; globvis = globalvisibility; - if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16))); - globalpal = (long)wal->pal; + if (sec->visibility != 0) globvis = mulscale4(globvis,(int)((unsigned char)(sec->visibility+16))); + globalpal = (int)wal->pal; if (palookup[globalpal] == NULL) globalpal = 0; // JBF: fixes crash globalyscale = (wal->yrepeat<<(globalshiftval-19)); if ((globalorientation&4) == 0) @@ -2658,7 +2674,7 @@ static void drawalls(long bunch) globalzd += (globalypanning<<24); if (globalorientation&256) globalyscale = -globalyscale, globalzd = -globalzd; - if (gotswall == 0) { gotswall = 1; prepwall(z,wal); } + if (gotswall == 0) { gotswall = 1; prepwall(z,wal); } wallscan(x1,x2,uplc,dwall,swall,lwall); if ((cz[2] >= cz[0]) && (cz[3] >= cz[1])) @@ -2729,30 +2745,30 @@ static void drawalls(long bunch) if ((wal->cstat&2) > 0) { wallnum = wal->nextwall; wal = &wall[wallnum]; - globalorientation = (long)wal->cstat; + globalorientation = (int)wal->cstat; globalpicnum = wal->picnum; if ((unsigned)globalpicnum >= (unsigned)MAXTILES) globalpicnum = 0; - globalxpanning = (long)wal->xpanning; - globalypanning = (long)wal->ypanning; + globalxpanning = (int)wal->xpanning; + globalypanning = (int)wal->ypanning; if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,(short)wallnum+16384); - globalshade = (long)wal->shade; - globalpal = (long)wal->pal; + globalshade = (int)wal->shade; + globalpal = (int)wal->pal; wallnum = thewall[z]; wal = &wall[wallnum]; } else { - globalorientation = (long)wal->cstat; + globalorientation = (int)wal->cstat; globalpicnum = wal->picnum; if ((unsigned)globalpicnum >= (unsigned)MAXTILES) globalpicnum = 0; - globalxpanning = (long)wal->xpanning; - globalypanning = (long)wal->ypanning; + globalxpanning = (int)wal->xpanning; + globalypanning = (int)wal->ypanning; if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,(short)wallnum+16384); - globalshade = (long)wal->shade; - globalpal = (long)wal->pal; + globalshade = (int)wal->shade; + globalpal = (int)wal->pal; } if (palookup[globalpal] == NULL) globalpal = 0; // JBF: fixes crash globvis = globalvisibility; - if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16))); + if (sec->visibility != 0) globvis = mulscale4(globvis,(int)((unsigned char)(sec->visibility+16))); globalshiftval = (picsiz[globalpicnum]>>4); if (pow2long[globalshiftval] != tilesizy[globalpicnum]) globalshiftval++; globalshiftval = 32-globalshiftval; @@ -2764,7 +2780,7 @@ static void drawalls(long bunch) globalzd += (globalypanning<<24); if (globalorientation&256) globalyscale = -globalyscale, globalzd = -globalzd; - if (gotswall == 0) { gotswall = 1; prepwall(z,wal); } + if (gotswall == 0) { gotswall = 1; prepwall(z,wal); } wallscan(x1,x2,uwall,dplc,swall,lwall); if ((fz[2] <= fz[0]) && (fz[3] <= fz[1])) @@ -2814,7 +2830,7 @@ static void drawalls(long bunch) { for (x=x1;xcstat&32)) //White/1-way wall { - globalorientation = (long)wal->cstat; + globalorientation = (int)wal->cstat; if (nextsectnum < 0) globalpicnum = wal->picnum; else globalpicnum = wal->overpicnum; if ((unsigned)globalpicnum >= (unsigned)MAXTILES) globalpicnum = 0; - globalxpanning = (long)wal->xpanning; - globalypanning = (long)wal->ypanning; + globalxpanning = (int)wal->xpanning; + globalypanning = (int)wal->ypanning; if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,(short)wallnum+16384); - globalshade = (long)wal->shade; + globalshade = (int)wal->shade; globvis = globalvisibility; - if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16))); - globalpal = (long)wal->pal; + if (sec->visibility != 0) globvis = mulscale4(globvis,(int)((unsigned char)(sec->visibility+16))); + globalpal = (int)wal->pal; if (palookup[globalpal] == NULL) globalpal = 0; // JBF: fixes crash globalshiftval = (picsiz[globalpicnum]>>4); if (pow2long[globalshiftval] != tilesizy[globalpicnum]) globalshiftval++; @@ -2860,12 +2876,12 @@ static void drawalls(long bunch) globalzd = ((globalzd*globalyscale)<<8) + (globalypanning<<24); if (globalorientation&256) globalyscale = -globalyscale, globalzd = -globalzd; - if (gotswall == 0) { gotswall = 1; prepwall(z,wal); } + if (gotswall == 0) { gotswall = 1; prepwall(z,wal); } wallscan(x1,x2,uplc,dplc,swall,lwall); for (x=x1;x<=x2;x++) if (umost[x] <= dmost[x]) - { umost[x] = 1; dmost[x] = 0; numhits--; } + { umost[x] = 1; dmost[x] = 0; numhits--; } smostwall[smostwallcnt] = z; smostwalltype[smostwallcnt] = 0; smostwallcnt++; @@ -2884,17 +2900,17 @@ static void drawalls(long bunch) // drawvox // #ifdef SUPERBUILD -static void drawvox(long dasprx, long daspry, long dasprz, long dasprang, - long daxscale, long dayscale, char daindex, - signed char dashade, char dapal, long *daumost, long *dadmost) +static void drawvox(int dasprx, int daspry, int dasprz, int dasprang, + int daxscale, int dayscale, char daindex, + signed char dashade, char dapal, int *daumost, int *dadmost) { - long i, j, k, x, y, syoff, ggxstart, ggystart, nxoff; - long cosang, sinang, sprcosang, sprsinang, backx, backy, gxinc, gyinc; - long daxsiz, daysiz, dazsiz, daxpivot, daypivot, dazpivot; - long daxscalerecip, dayscalerecip, cnt, gxstart, gystart, odayscale; - long l1, l2, slabxoffs, xyvoxoffs, *longptr; - long lx, rx, nx, ny, x1=0, y1=0, z1, x2=0, y2=0, z2, yplc, yinc=0; - long yoff, xs=0, ys=0, xe, ye, xi=0, yi=0, cbackx, cbacky, dagxinc, dagyinc; + int i, j, k, x, y, syoff, ggxstart, ggystart, nxoff; + int cosang, sinang, sprcosang, sprsinang, backx, backy, gxinc, gyinc; + int daxsiz, daysiz, dazsiz, daxpivot, daypivot, dazpivot; + int daxscalerecip, dayscalerecip, cnt, gxstart, gystart, odayscale; + int l1, l2, slabxoffs, xyvoxoffs, *longptr; + int lx, rx, nx, ny, x1=0, y1=0, z1, x2=0, y2=0, z2, yplc, yinc=0; + int yoff, xs=0, ys=0, xe, ye, xi=0, yi=0, cbackx, cbacky, dagxinc, dagyinc; short *shortptr; char *voxptr, *voxend, *davoxptr, oand, oand16, oand32; @@ -2904,7 +2920,7 @@ static void drawvox(long dasprx, long daspry, long dasprz, long dasprang, sprsinang = sintable[dasprang&2047]; i = klabs(dmulscale6(dasprx-globalposx,cosang,daspry-globalposy,sinang)); - j = (long)(getpalookup((long)mulscale21(globvis,i),(long)dashade)<<8); + j = (int)(getpalookup((int)mulscale21(globvis,i),(int)dashade)<<8); setupdrawslab(ylookup[1],FP_OFF(palookup[dapal])+j); j = 1310720; j *= min(daxscale,dayscale); j >>= 6; //New hacks (for sized-down voxels) @@ -2917,11 +2933,11 @@ static void drawvox(long dasprx, long daspry, long dasprz, long dasprang, if (novoxmips) i = 0; davoxptr = (char *)voxoff[daindex][i]; -if (!davoxptr && i > 0) { davoxptr = (char *)voxoff[daindex][0]; i = 0; } + if (!davoxptr && i > 0) { davoxptr = (char *)voxoff[daindex][0]; i = 0; } if (!davoxptr) return; if (voxscale[daindex] == 65536) - { daxscale <<= (i+8); dayscale <<= (i+8); } + { daxscale <<= (i+8); dayscale <<= (i+8); } else { daxscale = mulscale8(daxscale< 0) { davoxptr = (char *)voxoff[daindex][0]; i = 0; } daxscalerecip = (1<<30)/daxscale; dayscalerecip = (1<<30)/dayscale; - longptr = (long *)davoxptr; + longptr = (int *)davoxptr; daxsiz = B_LITTLE32(longptr[0]); daysiz = B_LITTLE32(longptr[1]); dazsiz = B_LITTLE32(longptr[2]); daxpivot = B_LITTLE32(longptr[3]); daypivot = B_LITTLE32(longptr[4]); dazpivot = B_LITTLE32(longptr[5]); davoxptr += (6<<2); @@ -2972,7 +2988,7 @@ if (!davoxptr && i > 0) { davoxptr = (char *)voxoff[daindex][0]; i = 0; } if ((klabs(globalposz-dasprz)>>10) >= klabs(odayscale)) return; syoff = divscale21(globalposz-dasprz,odayscale) + (dazpivot<<7); yoff = ((klabs(gxinc)+klabs(gyinc))>>1); - longptr = (long *)davoxptr; + longptr = (int *)davoxptr; xyvoxoffs = ((daxsiz+1)<<2); begindrawing(); //{{{ @@ -3050,7 +3066,7 @@ if (!davoxptr && i > 0) { davoxptr = (char *)voxoff[daindex][0]; i = 0; } oand16 = oand+16; oand32 = oand+32; - if (yi > 0) { dagxinc = gxinc; dagyinc = mulscale16(gyinc,viewingrangerecip); } + if (yi > 0) { dagxinc = gxinc; dagyinc = mulscale16(gyinc,viewingrangerecip); } else { dagxinc = -gxinc; dagyinc = -mulscale16(gyinc,viewingrangerecip); } //Fix for non 90 degree viewing ranges @@ -3062,7 +3078,7 @@ if (!davoxptr && i > 0) { davoxptr = (char *)voxoff[daindex][0]; i = 0; } for (x=xs;x!=xe;x+=xi) { - slabxoffs = (long)&davoxptr[B_LITTLE32(longptr[x])]; + slabxoffs = (int)&davoxptr[B_LITTLE32(longptr[x])]; shortptr = (short *)&davoxptr[((x*(daysiz+1))<<1)+xyvoxoffs]; nx = mulscale16(ggxstart+ggxinc[x],viewingrangerecip)+x1; @@ -3117,12 +3133,13 @@ if (!davoxptr && i > 0) { davoxptr = (char *)voxoff[daindex][0]; i = 0; } { if (z2-z1 >= 1024) yinc = divscale16(voxptr[1],z2-z1); else if (z2 > z1) yinc = (lowrecip[z2-z1]*voxptr[1]>>8); - if (z1 < daumost[lx]) { yplc = yinc*(daumost[lx]-z1); z1 = daumost[lx]; } else yplc = 0; + if (z1 < daumost[lx]) { yplc = yinc*(daumost[lx]-z1); z1 = daumost[lx]; } + else yplc = 0; } if (z2 > dadmost[lx]) z2 = dadmost[lx]; z2 -= z1; if (z2 <= 0) continue; - drawslab(rx,yplc,z2,yinc,(long)&voxptr[3],ylookup[z1]+lx+frameoffset); + drawslab(rx,yplc,z2,yinc,(int)&voxptr[3],ylookup[z1]+lx+frameoffset); } } } @@ -3135,23 +3152,24 @@ if (!davoxptr && i > 0) { davoxptr = (char *)voxoff[daindex][0]; i = 0; } // // drawsprite (internal) // -static void drawsprite(long snum) +static void drawsprite(int snum) { spritetype *tspr; sectortype *sec; - long startum, startdm, sectnum, xb, yp, cstat; - long siz, xsiz, ysiz, xoff, yoff, xspan, yspan; - long x1, y1, x2, y2, lx, rx, dalx2, darx2, i, j, k, x, linum, linuminc; - long yinc, z, z1, z2, xp1, yp1, xp2, yp2; - long xv, yv, top, topinc, bot, botinc, hplc, hinc; - long cosang, sinang, dax, day, lpoint, lmax, rpoint, rmax, dax1, dax2, y; - long npoints, npoints2, zz, t, zsgn, zzsgn, *longptr; - long tilenum, vtilenum = 0, spritenum; + int startum, startdm, sectnum, xb, yp, cstat; + int siz, xsiz, ysiz, xoff, yoff, xspan, yspan; + int x1, y1, x2, y2, lx, rx, dalx2, darx2, i, j, k, x, linum, linuminc; + int yinc, z, z1, z2, xp1, yp1, xp2, yp2; + int xv, yv, top, topinc, bot, botinc, hplc, hinc; + int cosang, sinang, dax, day, lpoint, lmax, rpoint, rmax, dax1, dax2, y; + int npoints, npoints2, zz, t, zsgn, zzsgn, *longptr; + int tilenum, vtilenum = 0, spritenum; char swapped, daclip; //============================================================================= //POLYMOST BEGINS #ifdef POLYMOST - if (rendmode == 3) { + if (rendmode == 3) + { polymost_drawsprite(snum); # ifdef USE_OPENGL bglDisable(GL_POLYGON_OFFSET_FILL); @@ -3176,7 +3194,8 @@ static void drawsprite(long snum) #if defined(POLYMOST) && defined(USE_OPENGL) && (!(spriteext[tspr->owner].flags&SPREXT_NOTMD)) #endif - ) { + ) + { vtilenum = tiletovox[tilenum]; cstat |= 48; } @@ -3199,8 +3218,8 @@ static void drawsprite(long snum) if (cstat&512) settransreverse(); else settransnormal(); } - xoff = (long)((signed char)((picanm[tilenum]>>8)&255))+((long)tspr->xoffset); - yoff = (long)((signed char)((picanm[tilenum]>>16)&255))+((long)tspr->yoffset); + xoff = (int)((signed char)((picanm[tilenum]>>8)&255))+((int)tspr->xoffset); + yoff = (int)((signed char)((picanm[tilenum]>>16)&255))+((int)tspr->yoffset); if ((cstat&48) == 0) { @@ -3208,7 +3227,7 @@ static void drawsprite(long snum) siz = divscale19(xdimenscale,yp); - xv = mulscale16(((long)tspr->xrepeat)<<16,xyaspect); + xv = mulscale16(((int)tspr->xrepeat)<<16,xyaspect); xspan = tilesizx[tilenum]; yspan = tilesizy[tilenum]; @@ -3285,7 +3304,7 @@ static void drawsprite(long snum) j = smostwall[i]; if ((xb1[j] > rx) || (xb2[j] < lx)) continue; if ((yp <= yb1[j]) && (yp <= yb2[j])) continue; - if (spritewallfront(tspr,(long)thewall[j]) && ((yp <= yb1[j]) || (yp <= yb2[j]))) continue; + if (spritewallfront(tspr,(int)thewall[j]) && ((yp <= yb1[j]) || (yp <= yb2[j]))) continue; dalx2 = max(xb1[j],lx); darx2 = min(xb2[j],rx); @@ -3343,7 +3362,7 @@ static void drawsprite(long snum) globalxpanning = 0L; globalypanning = 0L; globvis = globalvisibility; - if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16))); + if (sec->visibility != 0) globvis = mulscale4(globvis,(int)((unsigned char)(sec->visibility+16))); globalshiftval = (picsiz[globalpicnum]>>4); if (pow2long[globalshiftval] != tilesizy[globalpicnum]) globalshiftval++; globalshiftval = 32-globalshiftval; @@ -3355,7 +3374,7 @@ static void drawsprite(long snum) globalzd = (((globalposz-z2)*globalyscale)<<8); } - qinterpolatedown16((long)&lwall[lx],rx-lx+1,linum,linuminc); + qinterpolatedown16((int)&lwall[lx],rx-lx+1,linum,linuminc); clearbuf(&swall[lx],rx-lx+1,mulscale19(yp,xdimscale)); if ((cstat&2) == 0) @@ -3486,7 +3505,7 @@ static void drawsprite(long snum) globalxpanning = 0L; globalypanning = 0L; globvis = globalvisibility; - if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16))); + if (sec->visibility != 0) globvis = mulscale4(globvis,(int)((unsigned char)(sec->visibility+16))); globalshiftval = (picsiz[globalpicnum]>>4); if (pow2long[globalshiftval] != tilesizy[globalpicnum]) globalshiftval++; globalshiftval = 32-globalshiftval; @@ -3503,10 +3522,10 @@ static void drawsprite(long snum) if (((sec->floorstat&1) == 0) && (z2 > sec->floorz)) z2 = sec->floorz; - owallmost(uwall,(long)(MAXWALLSB-1),z1-globalposz); - owallmost(dwall,(long)(MAXWALLSB-1),z2-globalposz); + owallmost(uwall,(int)(MAXWALLSB-1),z1-globalposz); + owallmost(dwall,(int)(MAXWALLSB-1),z2-globalposz); for (i=xb1[MAXWALLSB-1];i<=xb2[MAXWALLSB-1];i++) - { swall[i] = (krecipasm(hplc)<<2); hplc += hinc; } + { swall[i] = (krecipasm(hplc)<<2); hplc += hinc; } for (i=smostwallcnt-1;i>=0;i--) { @@ -3547,7 +3566,8 @@ static void drawsprite(long snum) x = 0x7fffffff; } else - { //INTERSECTION! + { + //INTERSECTION! x = (xp1-globalposx) + scale(xp2-xp1,z1,z1-z2); y = (yp1-globalposy) + scale(yp2-yp1,z1,z1-z2); @@ -3560,9 +3580,9 @@ static void drawsprite(long snum) if (xp1 >= 0) x++; //Fix for SIGNED divide if (z1 < 0) - { if (dalx2 < x) dalx2 = x; } + { if (dalx2 < x) dalx2 = x; } else - { if (darx2 > x) darx2 = x; } + { if (darx2 > x) darx2 = x; } x = 0x80000001; } else @@ -3608,9 +3628,12 @@ static void drawsprite(long snum) searchstat = 3; searchit = 1; } - if ((cstat&2) == 0) { + if ((cstat&2) == 0) + { maskwallscan(xb1[MAXWALLSB-1],xb2[MAXWALLSB-1],uwall,dwall,swall,lwall); - } else { + } + else + { transmaskwallscan(xb1[MAXWALLSB-1],xb2[MAXWALLSB-1]); } } @@ -3655,9 +3678,9 @@ static void drawsprite(long snum) ryi[1] = ryi[2] = ryi[3] = ryi[0]; if ((cstat&4) == 0) - { z = 0; z1 = 1; z2 = 3; } + { z = 0; z1 = 1; z2 = 3; } else - { z = 1; z1 = 0; z2 = 2; } + { z = 1; z1 = 0; z2 = 2; } dax = rzi[z1]-rzi[z]; day = rxi[z1]-rxi[z]; bot = dmulscale8(dax,dax,day,day); @@ -3796,8 +3819,8 @@ static void drawsprite(long snum) ysi[z] = scale(ryi[z],xdimen<<15,rzi[z]) + (globalhoriz<<16); if (xsi[z] < 0) xsi[z] = 0; if (xsi[z] > (xdimen<<16)) xsi[z] = (xdimen<<16); - if (ysi[z] < ((long)0<<16)) ysi[z] = ((long)0<<16); - if (ysi[z] > ((long)ydimen<<16)) ysi[z] = ((long)ydimen<<16); + if (ysi[z] < ((int)0<<16)) ysi[z] = ((int)0<<16); + if (ysi[z] > ((int)ydimen<<16)) ysi[z] = ((int)ydimen<<16); if (xsi[z] < lmax) lmax = xsi[z], lpoint = z; if (xsi[z] > rmax) rmax = xsi[z], rpoint = z; } @@ -3813,7 +3836,7 @@ static void drawsprite(long snum) { yinc = divscale16(ysi[zz]-ysi[z],xsi[zz]-xsi[z]); y = ysi[z] + mulscale16((dax1<<16)-xsi[z],yinc); - qinterpolatedown16short((long)(&uwall[dax1]),dax2-dax1,y,yinc); + qinterpolatedown16short((int)(&uwall[dax1]),dax2-dax1,y,yinc); } } @@ -3828,7 +3851,7 @@ static void drawsprite(long snum) { yinc = divscale16(ysi[zz]-ysi[z],xsi[zz]-xsi[z]); y = ysi[zz] + mulscale16((dax1<<16)-xsi[zz],yinc); - qinterpolatedown16short((long)(&dwall[dax1]),dax2-dax1,y,yinc); + qinterpolatedown16short((int)(&dwall[dax1]),dax2-dax1,y,yinc); } } @@ -3898,7 +3921,7 @@ static void drawsprite(long snum) globalbufplc = waloff[globalpicnum]; globvis = mulscale16(globalhisibility,viewingrange); - if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16))); + if (sec->visibility != 0) globvis = mulscale4(globvis,(int)((unsigned char)(sec->visibility+16))); x = picsiz[globalpicnum]; y = ((x>>4)&15); x &= 15; if (pow2long[x] != xspan) @@ -3930,20 +3953,20 @@ static void drawsprite(long snum) #ifdef SUPERBUILD else if ((cstat&48) == 48) { - long nxrepeat, nyrepeat; + int nxrepeat, nyrepeat; lx = 0; rx = xdim-1; for (x=lx;x<=rx;x++) { - lwall[x] = (long)startumost[x+windowx1]-windowy1; - swall[x] = (long)startdmost[x+windowx1]-windowy1; + lwall[x] = (int)startumost[x+windowx1]-windowy1; + swall[x] = (int)startdmost[x+windowx1]-windowy1; } for (i=smostwallcnt-1;i>=0;i--) { j = smostwall[i]; if ((xb1[j] > rx) || (xb2[j] < lx)) continue; if ((yp <= yb1[j]) && (yp <= yb2[j])) continue; - if (spritewallfront(tspr,(long)thewall[j]) && ((yp <= yb1[j]) || (yp <= yb2[j]))) continue; + if (spritewallfront(tspr,(int)thewall[j]) && ((yp <= yb1[j]) || (yp <= yb2[j]))) continue; dalx2 = max(xb1[j],lx); darx2 = min(xb2[j],rx); @@ -3984,25 +4007,25 @@ static void drawsprite(long snum) break; } - longptr = (long *)voxoff[vtilenum][0]; + longptr = (int *)voxoff[vtilenum][0]; if (voxscale[vtilenum] == 65536) { - nxrepeat = (((long)tspr->xrepeat)<<16); - nyrepeat = (((long)tspr->yrepeat)<<16); + nxrepeat = (((int)tspr->xrepeat)<<16); + nyrepeat = (((int)tspr->yrepeat)<<16); } else { - nxrepeat = ((long)tspr->xrepeat)*voxscale[vtilenum]; - nyrepeat = ((long)tspr->yrepeat)*voxscale[vtilenum]; + nxrepeat = ((int)tspr->xrepeat)*voxscale[vtilenum]; + nyrepeat = ((int)tspr->yrepeat)*voxscale[vtilenum]; } if (!(cstat&128)) tspr->z -= mulscale22(B_LITTLE32(longptr[5]),nyrepeat); - yoff = (long)((signed char)((picanm[sprite[tspr->owner].picnum]>>16)&255))+((long)tspr->yoffset); + yoff = (int)((signed char)((picanm[sprite[tspr->owner].picnum]>>16)&255))+((int)tspr->yoffset); tspr->z -= mulscale14(yoff,nyrepeat); globvis = globalvisibility; - if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16))); + if (sec->visibility != 0) globvis = mulscale4(globvis,(int)((unsigned char)(sec->visibility+16))); if ((searchit >= 1) && (yp > (4<<8)) && (searchy >= lwall[searchx]) && (searchy < swall[searchx])) { @@ -4052,11 +4075,11 @@ static void drawsprite(long snum) } } - i = (long)tspr->ang+1536; + i = (int)tspr->ang+1536; #if defined(POLYMOST) && defined(USE_OPENGL) i += spriteext[tspr->owner].angoff; #endif - drawvox(tspr->x,tspr->y,tspr->z,i,(long)tspr->xrepeat,(long)tspr->yrepeat,vtilenum,tspr->shade,tspr->pal,lwall,swall); + drawvox(tspr->x,tspr->y,tspr->z,i,(int)tspr->xrepeat,(int)tspr->yrepeat,vtilenum,tspr->shade,tspr->pal,lwall,swall); } #endif if (automapping == 1) show2dsprite[spritenum>>3] |= pow2char[spritenum&7]; @@ -4068,7 +4091,7 @@ static void drawsprite(long snum) // static void drawmaskwall(short damaskwallcnt) { - long i, j, k, x, z, sectnum, z1, z2, lx, rx; + int i, j, k, x, z, sectnum, z1, z2, lx, rx; sectortype *sec, *nsec; walltype *wal; @@ -4087,23 +4110,23 @@ static void drawmaskwall(short damaskwallcnt) z2 = min(nsec->floorz,sec->floorz); wallmost(uwall,z,sectnum,(char)0); - wallmost(uplc,z,(long)wal->nextsector,(char)0); + wallmost(uplc,z,(int)wal->nextsector,(char)0); for (x=xb1[z];x<=xb2[z];x++) if (uplc[x] > uwall[x]) uwall[x] = uplc[x]; wallmost(dwall,z,sectnum,(char)1); - wallmost(dplc,z,(long)wal->nextsector,(char)1); + wallmost(dplc,z,(int)wal->nextsector,(char)1); for (x=xb1[z];x<=xb2[z];x++) if (dplc[x] < dwall[x]) dwall[x] = dplc[x]; prepwall(z,wal); - globalorientation = (long)wal->cstat; + globalorientation = (int)wal->cstat; globalpicnum = wal->overpicnum; if ((unsigned)globalpicnum >= (unsigned)MAXTILES) globalpicnum = 0; - globalxpanning = (long)wal->xpanning; - globalypanning = (long)wal->ypanning; + globalxpanning = (int)wal->xpanning; + globalypanning = (int)wal->ypanning; if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,(short)thewall[z]+16384); - globalshade = (long)wal->shade; + globalshade = (int)wal->shade; globvis = globalvisibility; - if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16))); - globalpal = (long)wal->pal; + if (sec->visibility != 0) globvis = mulscale4(globvis,(int)((unsigned char)(sec->visibility+16))); + globalpal = (int)wal->pal; globalshiftval = (picsiz[globalpicnum]>>4); if (pow2long[globalshiftval] != tilesizy[globalpicnum]) globalshiftval++; globalshiftval = 32-globalshiftval; @@ -4170,10 +4193,10 @@ static void drawmaskwall(short damaskwallcnt) // // fillpolygon (internal) // -static void fillpolygon(long npoints) +static void fillpolygon(int npoints) { - long z, zz, x1, y1, x2, y2, miny, maxy, y, xinc, cnt; - long ox, oy, bx, by, p, day1, day2; + int z, zz, x1, y1, x2, y2, miny, maxy, y, xinc, cnt; + int ox, oy, bx, by, p, day1, day2; short *ptr, *ptr2; #if defined POLYMOST && defined USE_OPENGL @@ -4182,7 +4205,7 @@ static void fillpolygon(long npoints) miny = 0x7fffffff; maxy = 0x80000000; for (z=npoints-1;z>=0;z--) - { y = ry1[z]; miny = min(miny,y); maxy = max(maxy,y); } + { y = ry1[z]; miny = min(miny,y); maxy = max(maxy,y); } miny = (miny>>12); maxy = (maxy>>12); if (miny < 0) miny = 0; if (maxy >= ydim) maxy = ydim-1; @@ -4277,10 +4300,10 @@ static void fillpolygon(long npoints) // // clippoly (internal) // -static long clippoly(long npoints, long clipstat) +static int clippoly(int npoints, int clipstat) { - long z, zz, s1, s2, t, npoints2, start2, z1, z2, z3, z4, splitcnt; - long cx1, cy1, cx2, cy2; + int z, zz, s1, s2, t, npoints2, start2, z1, z2, z3, z4, splitcnt; + int cx1, cy1, cx2, cy2; cx1 = windowx1; cy1 = windowy1; @@ -4312,7 +4335,8 @@ static long clippoly(long npoints, long clipstat) npoints2++; } z = zz; - } while (xb1[z] >= 0); + } + while (xb1[z] >= 0); if (npoints2 >= start2+3) xb2[npoints2-1] = start2, start2 = npoints2; @@ -4321,7 +4345,8 @@ static long clippoly(long npoints, long clipstat) z = 1; while ((z < npoints) && (xb1[z] < 0)) z++; - } while (z < npoints); + } + while (z < npoints); if (npoints2 <= 2) return(0); for (z=1;z= 0); + } + while (xb2[z] >= 0); if (npoints >= start2+3) xb1[npoints-1] = start2, start2 = npoints; @@ -4368,7 +4394,8 @@ static long clippoly(long npoints, long clipstat) z = 1; while ((z < npoints2) && (xb2[z] < 0)) z++; - } while (z < npoints2); + } + while (z < npoints2); if (npoints <= 2) return(0); for (z=1;z= 0); + } + while (xb1[z] >= 0); if (npoints2 >= start2+3) xb2[npoints2-1] = start2, start2 = npoints2; @@ -4416,7 +4444,8 @@ static long clippoly(long npoints, long clipstat) z = 1; while ((z < npoints) && (xb1[z] < 0)) z++; - } while (z < npoints); + } + while (z < npoints); if (npoints2 <= 2) return(0); for (z=1;z= 0); + } + while (xb2[z] >= 0); if (npoints >= start2+3) xb1[npoints-1] = start2, start2 = npoints; @@ -4463,7 +4493,8 @@ static long clippoly(long npoints, long clipstat) z = 1; while ((z < npoints2) && (xb2[z] < 0)) z++; - } while (z < npoints2); + } + while (z < npoints2); if (npoints <= 2) return(0); for (z=1;z yres-1) cy2 = yres-1; xsiz = tilesizx[picnum]; ysiz = tilesizy[picnum]; -if (dastat&16) { xoff = 0; yoff = 0; } + if (dastat&16) { xoff = 0; yoff = 0; } else { - xoff = (long)((signed char)((picanm[picnum]>>8)&255))+(xsiz>>1); - yoff = (long)((signed char)((picanm[picnum]>>16)&255))+(ysiz>>1); + xoff = (int)((signed char)((picanm[picnum]>>8)&255))+(xsiz>>1); + yoff = (int)((signed char)((picanm[picnum]>>16)&255))+(ysiz>>1); } if (dastat&4) yoff = ysiz-yoff; @@ -4640,12 +4673,12 @@ if (dastat&16) { xoff = 0; yoff = 0; } if (dax2 > dax1) { yplc = y1 + mulscale16((dax1<<16)+65535-x1,yinc); - qinterpolatedown16short((long)(&uplc[dax1]),dax2-dax1,yplc,yinc); + qinterpolatedown16short((int)(&uplc[dax1]),dax2-dax1,yplc,yinc); } else { yplc = y2 + mulscale16((dax2<<16)+65535-x2,yinc); - qinterpolatedown16short((long)(&dplc[dax2]),dax1-dax2,yplc,yinc); + qinterpolatedown16short((int)(&dplc[dax2]),dax1-dax2,yplc,yinc); } } nextv = v; @@ -4656,7 +4689,7 @@ if (dastat&16) { xoff = 0; yoff = 0; } bufplc = waloff[picnum]; if (palookup[dapalnum] == NULL) dapalnum = 0; - palookupoffs = FP_OFF(palookup[dapalnum]) + (getpalookup(0L,(long)dashade)<<8); + palookupoffs = FP_OFF(palookup[dapalnum]) + (getpalookup(0L,(int)dashade)<<8); i = divscale32(1L,z); xv = mulscale14(sinang,i); @@ -4825,10 +4858,12 @@ if (dastat&16) { xoff = 0; yoff = 0; } //x,y1 bx += xv*(y1-oy); by += yv*(y1-oy); oy = y1; - if (dastat&64) { + if (dastat&64) + { if (qlinemode) qrhlineasm4(x-lastx[y1],(bx>>16)*ysiz+(by>>16)+bufplc,0L,0L ,by<<16,ylookup[y1]+x+frameplace); else rhlineasm4(x-lastx[y1],(bx>>16)*ysiz+(by>>16)+bufplc,0L,bx<<16,by<<16,ylookup[y1]+x+frameplace); - } else rmhlineasm4(x-lastx[y1],(bx>>16)*ysiz+(by>>16)+bufplc,0L,bx<<16,by<<16,ylookup[y1]+x+frameplace); + } + else rmhlineasm4(x-lastx[y1],(bx>>16)*ysiz+(by>>16)+bufplc,0L,bx<<16,by<<16,ylookup[y1]+x+frameplace); } y1 = ny1; } @@ -4840,10 +4875,12 @@ if (dastat&16) { xoff = 0; yoff = 0; } //x,y1 bx += xv*(y1-oy); by += yv*(y1-oy); oy = y1; - if (dastat&64) { + if (dastat&64) + { if (qlinemode) qrhlineasm4(x-lastx[y1],(bx>>16)*ysiz+(by>>16)+bufplc,0L,0L ,by<<16,ylookup[y1]+x+frameplace); else rhlineasm4(x-lastx[y1],(bx>>16)*ysiz+(by>>16)+bufplc,0L,bx<<16,by<<16,ylookup[y1]+x+frameplace); - } else rmhlineasm4(x-lastx[y1],(bx>>16)*ysiz+(by>>16)+bufplc,0L,bx<<16,by<<16,ylookup[y1]+x+frameplace); + } + else rmhlineasm4(x-lastx[y1],(bx>>16)*ysiz+(by>>16)+bufplc,0L,bx<<16,by<<16,ylookup[y1]+x+frameplace); } while (y1 > ny1) lastx[y1--] = x; } @@ -4853,10 +4890,12 @@ if (dastat&16) { xoff = 0; yoff = 0; } //x,y2 bx += xv*(y2-oy); by += yv*(y2-oy); oy = y2; - if (dastat&64) { + if (dastat&64) + { if (qlinemode) qrhlineasm4(x-lastx[y2],(bx>>16)*ysiz+(by>>16)+bufplc,0L,0L ,by<<16,ylookup[y2]+x+frameplace); else rhlineasm4(x-lastx[y2],(bx>>16)*ysiz+(by>>16)+bufplc,0L,bx<<16,by<<16,ylookup[y2]+x+frameplace); - } else rmhlineasm4(x-lastx[y2],(bx>>16)*ysiz+(by>>16)+bufplc,0L,bx<<16,by<<16,ylookup[y2]+x+frameplace); + } + else rmhlineasm4(x-lastx[y2],(bx>>16)*ysiz+(by>>16)+bufplc,0L,bx<<16,by<<16,ylookup[y2]+x+frameplace); } while (y2 < ny2) lastx[y2++] = x; } @@ -4868,12 +4907,14 @@ if (dastat&16) { xoff = 0; yoff = 0; } //x,y1 bx += xv*(y1-oy); by += yv*(y1-oy); oy = y1; - if (dastat&64) { + if (dastat&64) + { if (qlinemode) qrhlineasm4(x-lastx[y1],(bx>>16)*ysiz+(by>>16)+bufplc,0L,0L ,by<<16,ylookup[y1]+x+frameplace); else rhlineasm4(x-lastx[y1],(bx>>16)*ysiz+(by>>16)+bufplc,0L,bx<<16,by<<16,ylookup[y1]+x+frameplace); - } else rmhlineasm4(x-lastx[y1],(bx>>16)*ysiz+(by>>16)+bufplc,0L,bx<<16,by<<16,ylookup[y1]+x+frameplace); + } + else rmhlineasm4(x-lastx[y1],(bx>>16)*ysiz+(by>>16)+bufplc,0L,bx<<16,by<<16,ylookup[y1]+x+frameplace); } - if (x == x2-1) { bx += xv2; by += yv2; break; } + if (x == x2-1) { bx += xv2; by += yv2; break; } y1 = uplc[x+1]; if (((dastat&8) == 0) && (startumost[x+1] > y1)) y1 = startumost[x+1]; y2 = y1; @@ -4886,10 +4927,12 @@ if (dastat&16) { xoff = 0; yoff = 0; } //x2,y1 bx += xv*(y1-oy); by += yv*(y1-oy); oy = y1; - if (dastat&64) { + if (dastat&64) + { if (qlinemode) qrhlineasm4(x2-lastx[y1],(bx>>16)*ysiz+(by>>16)+bufplc,0L,0L,by<<16,ylookup[y1]+x2+frameplace); else rhlineasm4(x2-lastx[y1],(bx>>16)*ysiz+(by>>16)+bufplc,0L,bx<<16,by<<16,ylookup[y1]+x2+frameplace); - } else rmhlineasm4(x2-lastx[y1],(bx>>16)*ysiz+(by>>16)+bufplc,0L,bx<<16,by<<16,ylookup[y1]+x2+frameplace); + } + else rmhlineasm4(x2-lastx[y1],(bx>>16)*ysiz+(by>>16)+bufplc,0L,bx<<16,by<<16,ylookup[y1]+x2+frameplace); } } } @@ -5018,7 +5061,7 @@ if (dastat&16) { xoff = 0; yoff = 0; } // static void initksqrt(void) { - long i, j, k; + int i, j, k; j = 1; k = 0; for (i=0;i<4096;i++) @@ -5036,7 +5079,7 @@ static void initksqrt(void) // static void dosetaspect(void) { - long i, j, k, x, xinc,a; + int i, j, k, x, xinc,a; if (xyaspect != oxyaspect) { @@ -5059,8 +5102,8 @@ static void dosetaspect(void) for (i=0;i>16); x += xinc; - if (j != 0) j = mulscale16((long)radarang[k+1]-(long)radarang[k],j); - radarang2[i] = (short)(((long)radarang[k]+j)>>6); + if (j != 0) j = mulscale16((int)radarang[k+1]-(int)radarang[k],j); + radarang2[i] = (short)(((int)radarang[k]+j)>>6); } #ifdef SUPERBUILD for (i=1;i<65536;i++) distrecip[i] = divscale20(xdimen,i); @@ -5078,7 +5121,8 @@ static void calcbritable(void) { int i,j; double a,b; - for (i=0;i<16;i++) { + for (i=0;i<16;i++) + { a = (double)8 / ((double)i+8); b = (double)255 / pow((double)255,a); for (j=0;j<256;j++) // JBF 20040207: full 8bit precision @@ -5088,7 +5132,7 @@ static void calcbritable(void) static int loadtables(void) { - long i, fil; + int i, fil; if (tablesloaded == 0) { @@ -5107,7 +5151,9 @@ static int loadtables(void) calcbritable(); kclose(fil); - } else { + } + else + { engineerrstr = "Failed to load TABLES.DAT!"; initprintf("ERROR: %s\n", engineerrstr); return 1; @@ -5122,9 +5168,9 @@ static int loadtables(void) // // initfastcolorlookup (internal) // -static void initfastcolorlookup(long rscale, long gscale, long bscale) +static void initfastcolorlookup(int rscale, int gscale, int bscale) { - long i, j, x, y, z; + int i, j, x, y, z; char *pal1; j = 0; @@ -5165,7 +5211,7 @@ static void initfastcolorlookup(long rscale, long gscale, long bscale) // static void loadpalette(void) { - long fil,i; + int fil,i; if (paletteloaded != 0) return; if ((fil = kopen4load("palette.dat",0)) == -1) return; @@ -5174,9 +5220,9 @@ static void loadpalette(void) kread(fil,&numpalookups,2); numpalookups = B_LITTLE16(numpalookups); if ((palookup[0] = (char *)kkmalloc(numpalookups<<8)) == NULL) - allocache((long*)&palookup[0],numpalookups<<8,&permanentlock); + allocache((int*)&palookup[0],numpalookups<<8,&permanentlock); if ((transluc = (char *)kkmalloc(65536L)) == NULL) - allocache((long*)&transluc,65536,&permanentlock); + allocache((int*)&transluc,65536,&permanentlock); globalpalwritten = palookup[0]; globalpal = 0; setpalookupaddress(globalpalwritten); @@ -5196,9 +5242,9 @@ static void loadpalette(void) // // getclosestcol (internal) // -static long getclosestcol(long r, long g, long b) +static int getclosestcol(int r, int g, int b) { - long i, j, k, dist, mindist, retcol; + int i, j, k, dist, mindist, retcol; char *pal1; j = (r>>3)*FASTPALGRIDSIZ*FASTPALGRIDSIZ+(g>>3)*FASTPALGRIDSIZ+(b>>3)+FASTPALGRIDSIZ*FASTPALGRIDSIZ+FASTPALGRIDSIZ+1; @@ -5227,7 +5273,8 @@ static long getclosestcol(long r, long g, long b) } } i = colnext[i]; - } while (i >= 0); + } + while (i >= 0); } if (retcol >= 0) return(retcol); @@ -5247,7 +5294,7 @@ static long getclosestcol(long r, long g, long b) // // insertspritesect (internal) // -static long insertspritesect(short sectnum) +static int insertspritesect(short sectnum) { short blanktouse; @@ -5275,7 +5322,7 @@ static long insertspritesect(short sectnum) // // insertspritestat (internal) // -static long insertspritestat(short statnum) +static int insertspritestat(short statnum) { short blanktouse; @@ -5303,7 +5350,7 @@ static long insertspritestat(short statnum) // // deletespritesect (internal) // -static long deletespritesect(short deleteme) +static int deletespritesect(short deleteme) { if (sprite[deleteme].sectnum == MAXSECTORS) return(-1); @@ -5327,7 +5374,7 @@ static long deletespritesect(short deleteme) // // deletespritestat (internal) // -static long deletespritestat(short deleteme) +static int deletespritestat(short deleteme) { if (sprite[deleteme].statnum == MAXSTATUS) return(-1); @@ -5351,10 +5398,11 @@ static long deletespritestat(short deleteme) // // lintersect (internal) // -static long lintersect(long x1, long y1, long z1, long x2, long y2, long z2, long x3, - long y3, long x4, long y4, long *intx, long *inty, long *intz) -{ //p1 to p2 is a line segment - long x21, y21, x34, y34, x31, y31, bot, topt, topu, t; +static int lintersect(int x1, int y1, int z1, int x2, int y2, int z2, int x3, + int y3, int x4, int y4, int *intx, int *inty, int *intz) +{ + //p1 to p2 is a line segment + int x21, y21, x34, y34, x31, y31, bot, topt, topu, t; x21 = x2-x1; x34 = x3-x4; y21 = y2-y1; y34 = y3-y4; @@ -5383,10 +5431,11 @@ static long lintersect(long x1, long y1, long z1, long x2, long y2, long z2, lon // // rintersect (internal) // -static long rintersect(long x1, long y1, long z1, long vx, long vy, long vz, long x3, - long y3, long x4, long y4, long *intx, long *inty, long *intz) -{ //p1 towards p2 is a ray - long x34, y34, x31, y31, bot, topt, topu, t; +static int rintersect(int x1, int y1, int z1, int vx, int vy, int vz, int x3, + int y3, int x4, int y4, int *intx, int *inty, int *intz) +{ + //p1 towards p2 is a ray + int x34, y34, x31, y31, bot, topt, topu, t; x34 = x3-x4; y34 = y3-y4; bot = vx*y34 - vy*x34; @@ -5414,9 +5463,9 @@ static long rintersect(long x1, long y1, long z1, long vx, long vy, long vz, lon // // keepaway (internal) // -static void keepaway (long *x, long *y, long w) +static void keepaway(int *x, int *y, int w) { - long dx, dy, ox, oy, x1, y1; + int dx, dy, ox, oy, x1, y1; char first; x1 = clipit[w].x1; dx = clipit[w].x2-x1; @@ -5435,10 +5484,10 @@ static void keepaway (long *x, long *y, long w) // // raytrace (internal) // -static long raytrace(long x3, long y3, long *x4, long *y4) +static int raytrace(int x3, int y3, int *x4, int *y4) { - long x1, y1, x2, y2, bot, topu, nintx, ninty, cnt, z, hitwall; - long x21, y21, x43, y43; + int x1, y1, x2, y2, bot, topu, nintx, ninty, cnt, z, hitwall; + int x21, y21, x43, y43; hitwall = -1; for (z=clipnum-1;z>=0;z--) @@ -5460,10 +5509,11 @@ static long raytrace(long x3, long y3, long *x4, long *y4) nintx = x3 + scale(x43,topu,bot); ninty = y3 + scale(y43,topu,bot); topu--; - } while (x21*(ninty-y1) <= (nintx-x1)*y21); + } + while (x21*(ninty-y1) <= (nintx-x1)*y21); if (klabs(x3-nintx)+klabs(y3-ninty) < klabs(x3-*x4)+klabs(y3-*y4)) - { *x4 = nintx; *y4 = ninty; hitwall = z; } + { *x4 = nintx; *y4 = ninty; hitwall = z; } } return(hitwall); } @@ -5479,9 +5529,11 @@ static long raytrace(long x3, long y3, long *x4, long *y4) static void sighandler(int sig, const siginfo_t *info, void *ctx) { const char *s; - switch (sig) { + switch (sig) + { case SIGFPE: - switch (info->si_code) { + switch (info->si_code) + { case FPE_INTDIV: s = "FPE_INTDIV (integer divide by zero)"; break; case FPE_INTOVF: @@ -5534,7 +5586,8 @@ int preinitengine(void) return 1; if ((e = Bgetenv("BUILD_NOP6")) != NULL) - if (!Bstrcasecmp(e, "TRUE")) { + if (!Bstrcasecmp(e, "TRUE")) + { Bprintf("Disabling P6 optimizations.\n"); dommxoverlay = 0; } @@ -5555,7 +5608,7 @@ int preinitengine(void) // int initengine(void) { - long i, j; + int i, j; #if !defined _WIN32 && defined DEBUGGINGAIDS struct sigaction sigact, oldact; @@ -5565,7 +5618,8 @@ int initengine(void) sigaction(SIGFPE, &sigact, &oldact); #endif - if (!preinitcalled) { + if (!preinitcalled) + { i = preinitengine(); if (i) return i; } @@ -5602,11 +5656,11 @@ int initengine(void) for (i=0;i>5),0L); - clearbuf(&show2dsprite[0],(long)((MAXSPRITES+3)>>5),0L); - clearbuf(&show2dwall[0],(long)((MAXWALLS+3)>>5),0L); + clearbuf(&show2dsector[0],(int)((MAXSECTORS+3)>>5),0L); + clearbuf(&show2dsprite[0],(int)((MAXSPRITES+3)>>5),0L); + clearbuf(&show2dwall[0],(int)((MAXWALLS+3)>>5),0L); automapping = 0; pointhighlight = -1; @@ -5634,7 +5688,7 @@ int initengine(void) // void uninitengine(void) { - long i; + int i; //OSD_Printf("cacheresets = %d, cacheinvalidates = %d\n", cacheresets, cacheinvalidates); @@ -5647,7 +5701,7 @@ void uninitengine(void) uninitsystem(); if (artfil != -1) kclose(artfil); -if (transluc != NULL) { kkfree(transluc); transluc = NULL; } + if (transluc != NULL) { kkfree(transluc); transluc = NULL; } if (pic != NULL) { kkfree(pic); pic = NULL; } if (lookups != NULL) { @@ -5656,7 +5710,7 @@ if (transluc != NULL) { kkfree(transluc); transluc = NULL; } lookups = NULL; } for (i=0;i>3),0L); - Bmemset(&gotsector[0],0,(long)((numsectors+7)>>3)); + //clearbufbyte(&gotsector[0],(int)((numsectors+7)>>3),0L); + Bmemset(&gotsector[0],0,(int)((numsectors+7)>>3)); shortptr1 = (short *)&startumost[windowx1]; shortptr2 = (short *)&startdmost[windowx1]; @@ -5755,7 +5809,8 @@ void drawrooms(long daposx, long daposy, long daposz, umost[i] = shortptr1[i]-windowy1; dmost[i] = shortptr2[i]-windowy1; i--; - } while (i != 0); + } + while (i != 0); umost[0] = shortptr1[0]-windowy1; dmost[0] = shortptr2[0]-windowy1; @@ -5770,7 +5825,7 @@ void drawrooms(long daposx, long daposy, long daposz, //============================================================================= //POLYMOST BEGINS polymost_drawrooms(); - if (rendmode) + if (rendmode) return; #endif //============================================================================= //POLYMOST ENDS @@ -5817,10 +5872,10 @@ void drawrooms(long daposx, long daposy, long daposz, for (i=0;i 0) && (numhits > 0)) { - clearbuf(&tempbuf[0],(long)((numbunches+3)>>2),0L); + clearbuf(&tempbuf[0],(int)((numbunches+3)>>2),0L); tempbuf[0] = 1; closest = 0; //Almost works, but not quite :( @@ -5868,8 +5923,9 @@ void drawrooms(long daposx, long daposy, long daposz, } // UTILITY TYPES AND FUNCTIONS FOR DRAWMASKS OCCLUSION TREE -typedef struct s_maskleaf { - long index; +typedef struct s_maskleaf +{ + int index; _point2d p1, p2; _equation maskeq, p1eq, p2eq; struct s_maskleaf* branch[MAXWALLSB]; @@ -5879,7 +5935,7 @@ typedef struct s_maskleaf { _maskleaf maskleaves[MAXWALLSB]; // returns equation of a line given two points -_equation equation(long x1, long y1, long x2, long y2) +_equation equation(int x1, int y1, int x2, int y2) { _equation ret; @@ -5900,8 +5956,9 @@ _equation equation(long x1, long y1, long x2, long y2) } int wallvisible(short wallnum) -{ // 1 if wall is in front of player 0 otherwise - long a1, a2; +{ + // 1 if wall is in front of player 0 otherwise + int a1, a2; walltype *w1, *w2; w1 = &wall[wallnum]; @@ -6024,7 +6081,7 @@ void drawpeel(int peel) // void drawmasks(void) { - long i, j, k, l, m, gap, xs, ys, xp, yp, yoff, yspan; + int i, j, k, l, m, gap, xs, ys, xp, yp, yoff, yspan; // PLAG: sorting stuff _equation maskeq, p1eq, p2eq; _point2d dot, dot2, middle, pos, spr; @@ -6056,64 +6113,64 @@ killsprite: } #ifdef USE_OPENGL -if ((!r_depthpeeling) || (rendmode < 3)) + if ((!r_depthpeeling) || (rendmode < 3)) #endif -{ - - gap = 1; while (gap < spritesortcnt) gap = (gap<<1)+1; - for (gap>>=1;gap>0;gap>>=1) //Sort sprite list - for (i=0;i=0;l-=gap) - { - if (spritesy[l] <= spritesy[l+gap]) break; - swaplong(&tspriteptr[l],&tspriteptr[l+gap]); - swaplong(&spritesx[l],&spritesx[l+gap]); - swaplong(&spritesy[l],&spritesy[l+gap]); - } - - if (spritesortcnt > 0) - spritesy[spritesortcnt] = (spritesy[spritesortcnt-1]^1); - - ys = spritesy[0]; i = 0; - for (j=1;j<=spritesortcnt;j++) { - if (spritesy[j] == ys) continue; - ys = spritesy[j]; - if (j > i+1) - { - for (k=i;kz; - if ((tspriteptr[k]->cstat&48) != 32) + + gap = 1; while (gap < spritesortcnt) gap = (gap<<1)+1; + for (gap>>=1;gap>0;gap>>=1) //Sort sprite list + for (i=0;i=0;l-=gap) { - yoff = (long)((signed char)((picanm[tspriteptr[k]->picnum]>>16)&255))+((long)tspriteptr[k]->yoffset); - spritesz[k] -= ((yoff*tspriteptr[k]->yrepeat)<<2); - yspan = (tilesizy[tspriteptr[k]->picnum]*tspriteptr[k]->yrepeat<<2); - if (!(tspriteptr[k]->cstat&128)) spritesz[k] -= (yspan>>1); - if (klabs(spritesz[k]-globalposz) < (yspan>>1)) spritesz[k] = globalposz; + if (spritesy[l] <= spritesy[l+gap]) break; + swaplong(&tspriteptr[l],&tspriteptr[l+gap]); + swaplong(&spritesx[l],&spritesx[l+gap]); + swaplong(&spritesy[l],&spritesy[l+gap]); } + + if (spritesortcnt > 0) + spritesy[spritesortcnt] = (spritesy[spritesortcnt-1]^1); + + ys = spritesy[0]; i = 0; + for (j=1;j<=spritesortcnt;j++) + { + if (spritesy[j] == ys) continue; + ys = spritesy[j]; + if (j > i+1) + { + for (k=i;kz; + if ((tspriteptr[k]->cstat&48) != 32) + { + yoff = (int)((signed char)((picanm[tspriteptr[k]->picnum]>>16)&255))+((int)tspriteptr[k]->yoffset); + spritesz[k] -= ((yoff*tspriteptr[k]->yrepeat)<<2); + yspan = (tilesizy[tspriteptr[k]->picnum]*tspriteptr[k]->yrepeat<<2); + if (!(tspriteptr[k]->cstat&128)) spritesz[k] -= (yspan>>1); + if (klabs(spritesz[k]-globalposz) < (yspan>>1)) spritesz[k] = globalposz; + } + } + for (k=i+1;kstatnum < tspriteptr[l]->statnum) + { + swaplong(&tspriteptr[k],&tspriteptr[l]); + swaplong(&spritesx[k],&spritesx[l]); + swaplong(&spritesy[k],&spritesy[l]); + } } - for (k=i+1;kstatnum < tspriteptr[l]->statnum) - { - swaplong(&tspriteptr[k],&tspriteptr[l]); - swaplong(&spritesx[k],&spritesx[l]); - swaplong(&spritesy[k],&spritesy[l]); - } + i = j; } - i = j; } -} begindrawing(); //{{{ @@ -6135,68 +6192,68 @@ if ((!r_depthpeeling) || (rendmode < 3)) }*/ #if defined(USE_OPENGL) && defined(POLYMOST) -if ((!r_depthpeeling) || (rendmode < 3)) + if ((!r_depthpeeling) || (rendmode < 3)) #endif -{ -#if defined(USE_OPENGL) && defined(POLYMOST) - curpolygonoffset = 0; -#endif - pos.x = globalposx; - pos.y = globalposy; - - while (maskwallcnt) { - maskwallcnt--; +#if defined(USE_OPENGL) && defined(POLYMOST) + curpolygonoffset = 0; +#endif + pos.x = globalposx; + pos.y = globalposy; - dot.x = wall[thewall[maskwall[maskwallcnt]]].x; - dot.y = wall[thewall[maskwall[maskwallcnt]]].y; - dot2.x = wall[wall[thewall[maskwall[maskwallcnt]]].point2].x; - dot2.y = wall[wall[thewall[maskwall[maskwallcnt]]].point2].y; - - maskeq = equation(dot.x, dot.y, dot2.x, dot2.y); - p1eq = equation(pos.x, pos.y, dot.x, dot.y); - p2eq = equation(pos.x, pos.y, dot2.x, dot2.y); - - middle.x = (dot.x + dot2.x) / 2; - middle.y = (dot.y + dot2.y) / 2; - - i = spritesortcnt; - while (i) + while (maskwallcnt) { - i--; - if (tspriteptr[i] != NULL) - { - spr.x = tspriteptr[i]->x; - spr.y = tspriteptr[i]->y; + maskwallcnt--; - if ((sameside(&maskeq, &spr, &pos) == 0) && sameside(&p1eq, &middle, &spr) && sameside(&p2eq, &middle, &spr)) + dot.x = wall[thewall[maskwall[maskwallcnt]]].x; + dot.y = wall[thewall[maskwall[maskwallcnt]]].y; + dot2.x = wall[wall[thewall[maskwall[maskwallcnt]]].point2].x; + dot2.y = wall[wall[thewall[maskwall[maskwallcnt]]].point2].y; + + maskeq = equation(dot.x, dot.y, dot2.x, dot2.y); + p1eq = equation(pos.x, pos.y, dot.x, dot.y); + p2eq = equation(pos.x, pos.y, dot2.x, dot2.y); + + middle.x = (dot.x + dot2.x) / 2; + middle.y = (dot.y + dot2.y) / 2; + + i = spritesortcnt; + while (i) + { + i--; + if (tspriteptr[i] != NULL) { - drawsprite(i); - tspriteptr[i] = NULL; + spr.x = tspriteptr[i]->x; + spr.y = tspriteptr[i]->y; + + if ((sameside(&maskeq, &spr, &pos) == 0) && sameside(&p1eq, &middle, &spr) && sameside(&p2eq, &middle, &spr)) + { + drawsprite(i); + tspriteptr[i] = NULL; + } } } + drawmaskwall(maskwallcnt); } - drawmaskwall(maskwallcnt); - } - while (spritesortcnt) - { - spritesortcnt--; - if (tspriteptr[spritesortcnt] != NULL) - drawsprite(spritesortcnt); - } + while (spritesortcnt) + { + spritesortcnt--; + if (tspriteptr[spritesortcnt] != NULL) + drawsprite(spritesortcnt); + } -} /* depthpeeling */ + } /* depthpeeling */ #if defined(USE_OPENGL) && defined(POLYMOST) -else -{ - curpolygonoffset = 0; - j = spritesortcnt; - k = maskwallcnt; + else + { + curpolygonoffset = 0; + j = spritesortcnt; + k = maskwallcnt; - while (j > 0) drawsprite(--j); - while (k > 0) drawmaskwall(--k); -} + while (j > 0) drawsprite(--j); + while (k > 0) drawmaskwall(--k); + } #endif #if defined(USE_OPENGL) && defined(POLYMOST) @@ -6309,20 +6366,20 @@ else // // drawmapview // -void drawmapview(long dax, long day, long zoome, short ang) +void drawmapview(int dax, int day, int zoome, short ang) { walltype *wal; sectortype *sec; spritetype *spr; - long tilenum, xoff, yoff, i, j, k, l, cosang, sinang, xspan, yspan; - long xrepeat, yrepeat, x, y, x1, y1, x2, y2, x3, y3, x4, y4, bakx1, baky1; - long s, w, ox, oy, startwall, cx1, cy1, cx2, cy2; - long bakgxvect, bakgyvect, sortnum, gap, npoints; - long xvect, yvect, xvect2, yvect2, daslope; + int tilenum, xoff, yoff, i, j, k, l, cosang, sinang, xspan, yspan; + int xrepeat, yrepeat, x, y, x1, y1, x2, y2, x3, y3, x4, y4, bakx1, baky1; + int s, w, ox, oy, startwall, cx1, cy1, cx2, cy2; + int bakgxvect, bakgyvect, sortnum, gap, npoints; + int xvect, yvect, xvect2, yvect2, daslope; beforedrawrooms = 0; - clearbuf(&gotsector[0],(long)((numsectors+31)>>5),0L); + clearbuf(&gotsector[0],(int)((numsectors+31)>>5),0L); cx1 = (windowx1<<12); cy1 = (windowy1<<12); cx2 = ((windowx2+1)<<12)-1; cy2 = ((windowy2+1)<<12)-1; @@ -6393,7 +6450,7 @@ void drawmapview(long dax, long day, long zoome, short ang) gotsector[s>>3] |= pow2char[s&7]; - globalorientation = (long)sec->floorstat; + globalorientation = (int)sec->floorstat; if ((globalorientation&1) != 0) continue; globalpal = sec->floorpal; @@ -6413,7 +6470,7 @@ void drawmapview(long dax, long day, long zoome, short ang) globalbufplc = waloff[globalpicnum]; globalshade = max(min(sec->floorshade,numpalookups-1),0); globvis = globalhisibility; - if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16))); + if (sec->visibility != 0) globvis = mulscale4(globvis,(int)((unsigned char)(sec->visibility+16))); globalpolytype = 0; if ((globalorientation&64) == 0) { @@ -6442,7 +6499,7 @@ void drawmapview(long dax, long day, long zoome, short ang) } globalxshift = (8-(picsiz[globalpicnum]&15)); globalyshift = (8-(picsiz[globalpicnum]>>4)); - if (globalorientation&8) {globalxshift++; globalyshift++; } + if (globalorientation&8) {globalxshift++; globalyshift++; } sethlinesizes(picsiz[globalpicnum]&15,picsiz[globalpicnum]>>4,globalbufplc); @@ -6458,8 +6515,8 @@ void drawmapview(long dax, long day, long zoome, short ang) asm2 = (globalx2<floorxpanning)<<24); - globalposy = (globalposy<<(20+globalyshift))-(((long)sec->floorypanning)<<24); + globalposx = (globalposx<<(20+globalxshift))+(((int)sec->floorxpanning)<<24); + globalposy = (globalposy<<(20+globalyshift))-(((int)sec->floorypanning)<<24); fillpolygon(npoints); } @@ -6482,8 +6539,8 @@ void drawmapview(long dax, long day, long zoome, short ang) npoints = 0; tilenum = spr->picnum; - xoff = (long)((signed char)((picanm[tilenum]>>8)&255))+((long)spr->xoffset); - yoff = (long)((signed char)((picanm[tilenum]>>16)&255))+((long)spr->yoffset); + xoff = (int)((signed char)((picanm[tilenum]>>8)&255))+((int)spr->xoffset); + yoff = (int)((signed char)((picanm[tilenum]>>16)&255))+((int)spr->yoffset); if ((spr->cstat&4) > 0) xoff = -xoff; if ((spr->cstat&8) > 0) yoff = -yoff; @@ -6546,13 +6603,13 @@ void drawmapview(long dax, long day, long zoome, short ang) if (waloff[globalpicnum] == 0) loadtile(globalpicnum); globalbufplc = waloff[globalpicnum]; if ((sector[spr->sectnum].ceilingstat&1) > 0) - globalshade = ((long)sector[spr->sectnum].ceilingshade); + globalshade = ((int)sector[spr->sectnum].ceilingshade); else - globalshade = ((long)sector[spr->sectnum].floorshade); + globalshade = ((int)sector[spr->sectnum].floorshade); globalshade = max(min(globalshade+spr->shade+6,numpalookups-1),0); asm3 = FP_OFF(palookup[spr->pal]+(globalshade<<8)); globvis = globalhisibility; - if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16))); + if (sec->visibility != 0) globvis = mulscale4(globvis,(int)((unsigned char)(sec->visibility+16))); globalpolytype = ((spr->cstat&2)>>1)+1; //relative alignment stuff @@ -6579,7 +6636,8 @@ void drawmapview(long dax, long day, long zoome, short ang) if ((spr->cstat&2) == 0) msethlineshift(ox,oy); - else { + else + { if (spr->cstat&512) settransreverse(); else settransnormal(); tsethlineshift(ox,oy); } @@ -6600,15 +6658,15 @@ void drawmapview(long dax, long day, long zoome, short ang) // // loadboard // -long loadboard(char *filename, char fromwhere, long *daposx, long *daposy, long *daposz, - short *daang, short *dacursectnum) +int loadboard(char *filename, char fromwhere, int *daposx, int *daposy, int *daposz, + short *daang, short *dacursectnum) { short fil, i, numsprites; i = strlen(filename)-1; if (filename[i] == 255) { filename[i] = 0; fromwhere = 1; } // JBF 20040119: "compatibility" if ((fil = kopen4load(filename,fromwhere)) == -1) - { mapversion = 7L; return(-1); } + { mapversion = 7L; return(-1); } kread(fil,&mapversion,4); mapversion = B_LITTLE32(mapversion); if (mapversion != 7L && mapversion != 8L) { kclose(fil); return(-2); } @@ -6626,9 +6684,9 @@ long loadboard(char *filename, char fromwhere, long *daposx, long *daposy, long #define MYMAXWALLS (mapversion==7l?MAXWALLSV7:MAXWALLSV8) #define MYMAXSPRITES (mapversion==7l?MAXSPRITESV7:MAXSPRITESV8) - clearbuf(&show2dsector[0],(long)((MYMAXSECTORS+3)>>5),0L); - clearbuf(&show2dsprite[0],(long)((MYMAXSPRITES+3)>>5),0L); - clearbuf(&show2dwall[0],(long)((MYMAXWALLS+3)>>5),0L); + clearbuf(&show2dsector[0],(int)((MYMAXSECTORS+3)>>5),0L); + clearbuf(&show2dsprite[0],(int)((MYMAXSPRITES+3)>>5),0L); + clearbuf(&show2dwall[0],(int)((MYMAXWALLS+3)>>5),0L); kread(fil,daposx,4); *daposx = B_LITTLE32(*daposx); kread(fil,daposy,4); *daposy = B_LITTLE32(*daposy); @@ -6639,7 +6697,8 @@ long loadboard(char *filename, char fromwhere, long *daposx, long *daposy, long kread(fil,&numsectors,2); numsectors = B_LITTLE16(numsectors); if (numsectors > MYMAXSECTORS) { kclose(fil); return(-1); } kread(fil,§or[0],sizeof(sectortype)*numsectors); - for (i=numsectors-1; i>=0; i--) { + for (i=numsectors-1; i>=0; i--) + { sector[i].wallptr = B_LITTLE16(sector[i].wallptr); sector[i].wallnum = B_LITTLE16(sector[i].wallnum); sector[i].ceilingz = B_LITTLE32(sector[i].ceilingz); @@ -6658,7 +6717,8 @@ long loadboard(char *filename, char fromwhere, long *daposx, long *daposy, long kread(fil,&numwalls,2); numwalls = B_LITTLE16(numwalls); if (numwalls > MYMAXWALLS) { kclose(fil); return(-1); } kread(fil,&wall[0],sizeof(walltype)*numwalls); - for (i=numwalls-1; i>=0; i--) { + for (i=numwalls-1; i>=0; i--) + { wall[i].x = B_LITTLE32(wall[i].x); wall[i].y = B_LITTLE32(wall[i].y); wall[i].point2 = B_LITTLE16(wall[i].point2); @@ -6675,7 +6735,8 @@ long loadboard(char *filename, char fromwhere, long *daposx, long *daposy, long kread(fil,&numsprites,2); numsprites = B_LITTLE16(numsprites); if (numsprites > MYMAXSPRITES) { kclose(fil); return(-1); } kread(fil,&sprite[0],sizeof(spritetype)*numsprites); - for (i=numsprites-1; i>=0; i--) { + for (i=numsprites-1; i>=0; i--) + { sprite[i].x = B_LITTLE32(sprite[i].x); sprite[i].y = B_LITTLE32(sprite[i].y); sprite[i].z = B_LITTLE32(sprite[i].z); @@ -6693,7 +6754,8 @@ long loadboard(char *filename, char fromwhere, long *daposx, long *daposy, long sprite[i].extra = B_LITTLE16(sprite[i].extra); } - for (i=0;iextra = from->extra; } -static void convertv5wallv6(struct walltypev5 *from, struct walltypev6 *to, long i) +static void convertv5wallv6(struct walltypev5 *from, struct walltypev6 *to, int i) { to->x = from->x; to->y = from->y; @@ -6929,14 +6991,14 @@ static void convertv6sectv7(struct sectortypev6 *from, sectortype *to) to->wallptr = from->wallptr; to->wallnum = from->wallnum; to->ceilingpicnum = from->ceilingpicnum; - to->ceilingheinum = max(min(((long)from->ceilingheinum)<<5,32767),-32768); + to->ceilingheinum = max(min(((int)from->ceilingheinum)<<5,32767),-32768); if ((from->ceilingstat&2) == 0) to->ceilingheinum = 0; to->ceilingshade = from->ceilingshade; to->ceilingpal = from->ceilingpal; to->ceilingxpanning = from->ceilingxpanning; to->ceilingypanning = from->ceilingypanning; to->floorpicnum = from->floorpicnum; - to->floorheinum = max(min(((long)from->floorheinum)<<5,32767),-32768); + to->floorheinum = max(min(((int)from->floorheinum)<<5,32767),-32768); if ((from->floorstat&2) == 0) to->floorheinum = 0; to->floorshade = from->floorshade; to->floorpal = from->floorpal; @@ -7001,8 +7063,8 @@ static void convertv6sprv7(struct spritetypev6 *from, spritetype *to) // Powerslave uses v6 // Witchaven 1 and TekWar use v5 -long loadoldboard(char *filename, char fromwhere, long *daposx, long *daposy, long *daposz, - short *daang, short *dacursectnum) +int loadoldboard(char *filename, char fromwhere, int *daposx, int *daposy, int *daposz, + short *daang, short *dacursectnum) { short fil, i, numsprites; struct sectortypev5 v5sect; @@ -7015,16 +7077,16 @@ long loadoldboard(char *filename, char fromwhere, long *daposx, long *daposy, lo i = strlen(filename)-1; if (filename[i] == 255) { filename[i] = 0; fromwhere = 1; } // JBF 20040119: "compatibility" if ((fil = kopen4load(filename,fromwhere)) == -1) - { mapversion = 5L; return(-1); } + { mapversion = 5L; return(-1); } kread(fil,&mapversion,4); mapversion = B_LITTLE32(mapversion); if (mapversion != 5L && mapversion != 6L) { kclose(fil); return(-2); } initspritelists(); - clearbuf(&show2dsector[0],(long)((MAXSECTORS+3)>>5),0L); - clearbuf(&show2dsprite[0],(long)((MAXSPRITES+3)>>5),0L); - clearbuf(&show2dwall[0],(long)((MAXWALLS+3)>>5),0L); + clearbuf(&show2dsector[0],(int)((MAXSECTORS+3)>>5),0L); + clearbuf(&show2dsprite[0],(int)((MAXSPRITES+3)>>5),0L); + clearbuf(&show2dwall[0],(int)((MAXWALLS+3)>>5),0L); kread(fil,daposx,4); *daposx = B_LITTLE32(*daposx); kread(fil,daposy,4); *daposy = B_LITTLE32(*daposy); @@ -7034,8 +7096,10 @@ long loadoldboard(char *filename, char fromwhere, long *daposx, long *daposy, lo kread(fil,&numsectors,2); numsectors = B_LITTLE16(numsectors); if (numsectors > MAXSECTORS) { kclose(fil); return(-1); } - for (i=0; i MAXWALLS) { kclose(fil); return(-1); } - for (i=0; i MAXWALLS) { kclose(fil); return(-1); } + for (i=0; i MAXWALLS) { kclose(fil); return(-1); } v6wall.extra = B_LITTLE16(v6wall.extra); break; } - switch (mapversion) { + switch (mapversion) + { case 5: convertv5wallv6(&v5wall,&v6wall,i); case 6: @@ -7117,9 +7185,11 @@ if (numwalls > MAXWALLS) { kclose(fil); return(-1); } } kread(fil,&numsprites,2); numsprites = B_LITTLE16(numsprites); -if (numsprites > MAXSPRITES) { kclose(fil); return(-1); } - for (i=0; i MAXSPRITES) { kclose(fil); return(-1); } + for (i=0; i MAXSPRITES) { kclose(fil); return(-1); } v6spr.extra = B_LITTLE16(v6spr.extra); break; } - switch (mapversion) { + switch (mapversion) + { case 5: convertv5sprv6(&v5spr,&v6spr); case 6: @@ -7164,7 +7235,8 @@ if (numsprites > MAXSPRITES) { kclose(fil); return(-1); } } } - for (i=0;i MAXSPRITES) { kclose(fil); return(-1); } // #if defined(POLYMOST) && defined(USE_OPENGL) #include "scriptfile.h" -long loadmaphack(char *filename) +int loadmaphack(char *filename) { enum { @@ -7206,23 +7278,24 @@ long loadmaphack(char *filename) T_MDZOFF }; - static struct { char *text; int tokenid; } legaltokens[] = { - { "sprite", T_SPRITE }, - { "angleoff", T_ANGOFF }, - { "angoff", T_ANGOFF }, - { "notmd2", T_NOMODEL }, - { "notmd3", T_NOMODEL }, - { "notmd", T_NOMODEL }, - { "nomd2anim", T_NOANIM }, - { "nomd3anim", T_NOANIM }, - { "nomdanim", T_NOANIM }, - { "pitch", T_PITCH }, - { "roll", T_ROLL }, - { "mdxoff", T_MDXOFF }, - { "mdyoff", T_MDYOFF }, - { "mdzoff", T_MDZOFF }, - { NULL, -1 } - }; + static struct { char *text; int tokenid; } legaltokens[] = + { + { "sprite", T_SPRITE }, + { "angleoff", T_ANGOFF }, + { "angoff", T_ANGOFF }, + { "notmd2", T_NOMODEL }, + { "notmd3", T_NOMODEL }, + { "notmd", T_NOMODEL }, + { "nomd2anim", T_NOANIM }, + { "nomd3anim", T_NOANIM }, + { "nomdanim", T_NOANIM }, + { "pitch", T_PITCH }, + { "roll", T_ROLL }, + { "mdxoff", T_MDXOFF }, + { "mdyoff", T_MDYOFF }, + { "mdzoff", T_MDZOFF }, + { NULL, -1 } + }; scriptfile *script; char *tok, *cmdtokptr; @@ -7235,16 +7308,19 @@ long loadmaphack(char *filename) memset(spriteext, 0, sizeof(spriteexttype) * MAXSPRITES); memset(spritesmooth, 0, sizeof(spritesmooth)); - while (1) { + while (1) + { tok = scriptfile_gettoken(script); if (!tok) break; for (i=0;legaltokens[i].text;i++) if (!Bstrcasecmp(tok,legaltokens[i].text)) break; cmdtokptr = script->ltextptr; - switch (legaltokens[i].tokenid) { + switch (legaltokens[i].tokenid) + { case T_SPRITE: // sprite if (scriptfile_getnumber(script, &whichsprite)) break; - if ((unsigned)whichsprite >= (unsigned)MAXSPRITES) { + if ((unsigned)whichsprite >= (unsigned)MAXSPRITES) + { // sprite number out of range initprintf("Sprite number out of range 0-%d on line %s:%d\n", MAXSPRITES-1,script->filename, scriptfile_getlinum(script,cmdtokptr)); @@ -7258,7 +7334,8 @@ long loadmaphack(char *filename) int 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)); @@ -7268,7 +7345,8 @@ long loadmaphack(char *filename) } break; case T_NOMODEL: // notmd - if (whichsprite < 0) { + 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)); @@ -7277,7 +7355,8 @@ long loadmaphack(char *filename) spriteext[whichsprite].flags |= SPREXT_NOTMD; break; case T_NOANIM: // nomdanim - if (whichsprite < 0) { + 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)); @@ -7290,7 +7369,8 @@ long loadmaphack(char *filename) int 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)); @@ -7303,7 +7383,8 @@ long loadmaphack(char *filename) int 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)); @@ -7316,7 +7397,8 @@ long loadmaphack(char *filename) int 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)); @@ -7329,7 +7411,8 @@ long loadmaphack(char *filename) int 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)); @@ -7342,7 +7425,8 @@ long loadmaphack(char *filename) int 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)); @@ -7363,18 +7447,18 @@ long loadmaphack(char *filename) return 0; } #else -long loadmaphack(char *filename) { return -1; } +int loadmaphack(char *filename) { return -1; } #endif // // saveboard // -long saveboard(char *filename, long *daposx, long *daposy, long *daposz, - short *daang, short *dacursectnum) +int saveboard(char *filename, int *daposx, int *daposy, int *daposz, + short *daang, short *dacursectnum) { short fil, i, j, numsprites, ts; - long tl; + int tl; sectortype *tsect = NULL; walltype *twall = NULL; spritetype *tspri = NULL; @@ -7419,7 +7503,8 @@ long saveboard(char *filename, long *daposx, long *daposy, long *daposz, Bmemcpy(&tsect[0], §or[0], sizeof(sectortype) * numsectors); - for (i=0; iwallptr = B_LITTLE16(sec->wallptr); sec->wallnum = B_LITTLE16(sec->wallnum); @@ -7448,7 +7533,8 @@ long saveboard(char *filename, long *daposx, long *daposy, long *daposz, Bmemcpy(&twall[0], &wall[0], sizeof(walltype) * numwalls); - for (i=0; ix = B_LITTLE32(wal->x); wal->y = B_LITTLE32(wal->y); @@ -7525,9 +7611,9 @@ long saveboard(char *filename, long *daposx, long *daposy, long *daposz, // // JBF: davidoption now functions as a windowed-mode flag (0 == windowed, 1 == fullscreen) extern char videomodereset; -long setgamemode(char davidoption, long daxdim, long daydim, long dabpp) +int setgamemode(char davidoption, int daxdim, int daydim, int dabpp) { - long i, j; + int i, j; if ((qsetmode == 200) && (videomodereset == 0) && (davidoption == fullscreen) && (xdim == daxdim) && (ydim == daydim) && (bpp == dabpp)) @@ -7550,23 +7636,23 @@ long setgamemode(char davidoption, long daxdim, long daydim, long dabpp) xdim = daxdim; ydim = daydim; - j = ydim*4*sizeof(long); //Leave room for horizlookup&horizlookup2 + j = ydim*4*sizeof(int); //Leave room for horizlookup&horizlookup2 if (lookups != NULL) { if (lookupsalloctype == 0) kkfree((void *)lookups); - if (lookupsalloctype == 1) suckcache((long *)lookups); + if (lookupsalloctype == 1) suckcache((int *)lookups); lookups = NULL; } lookupsalloctype = 0; - if ((lookups = (long *)kkmalloc(j<<1)) == NULL) + if ((lookups = (int *)kkmalloc(j<<1)) == NULL) { - allocache((long *)&lookups,j<<1,&permanentlock); + allocache((int *)&lookups,j<<1,&permanentlock); lookupsalloctype = 1; } - horizlookup = (long *)(lookups); - horizlookup2 = (long *)(FP_OFF(lookups)+j); + horizlookup = (int *)(lookups); + horizlookup2 = (int *)(FP_OFF(lookups)+j); horizycent = ((ydim*4)>>1); //Force drawrooms to call dosetaspect & recalculate stuff @@ -7580,7 +7666,7 @@ long setgamemode(char davidoption, long daxdim, long daydim, long dabpp) clearallviews(0L); setbrightness(curbrightness,&palette[0],0); -if (searchx < 0) { searchx = halfxdimen; searchy = (ydimen>>1); } + if (searchx < 0) { searchx = halfxdimen; searchy = (ydimen>>1); } #if defined(POLYMOST) && defined(USE_OPENGL) if (rendmode == 3) @@ -7601,7 +7687,7 @@ if (searchx < 0) { searchx = halfxdimen; searchy = (ydimen>>1); } // void nextpage(void) { - long i; + int i; permfifotype *per; //char snotbuf[32]; @@ -7609,12 +7695,12 @@ void nextpage(void) //for(i=0;i<4096;i++) // if (waloff[i] != 0) // { - // sprintf(snotbuf,"%ld-%ld",i,tilesizx[i]*tilesizy[i]); + // sprintf(snotbuf,"%d-%d",i,tilesizx[i]*tilesizy[i]); // printext256((j>>5)*40+32,(j&31)*6,walock[i]>>3,-1,snotbuf,1); // k += tilesizx[i]*tilesizy[i]; // j++; // } - //sprintf(snotbuf,"Total: %ld",k); + //sprintf(snotbuf,"Total: %d",k); //printext256((j>>5)*40+32,(j&31)*6,31,-1,snotbuf,1); switch (qsetmode) @@ -7657,11 +7743,11 @@ void nextpage(void) faketimerhandler(); if ((totalclock >= lastageclock+8) || (totalclock < lastageclock)) - { lastageclock = totalclock; agecache(); } + { lastageclock = totalclock; agecache(); } #ifdef USE_OPENGL omdtims = mdtims; mdtims = getticks(); - if (((unsigned long)(mdtims-omdtims)) > 10000) omdtims = mdtims; + if (((unsigned int)(mdtims-omdtims)) > 10000) omdtims = mdtims; #endif beforedrawrooms = 1; @@ -7672,9 +7758,9 @@ void nextpage(void) // // loadpics // -long loadpics(char *filename, long askedsize) +int loadpics(char *filename, int askedsize) { - long offscount, localtilestart, localtileend, dasiz; + int offscount, localtilestart, localtileend, dasiz; short fil, i, j, k; Bstrcpy(artfilename,filename); @@ -7699,7 +7785,8 @@ long loadpics(char *filename, long askedsize) if ((fil = kopen4load(artfilename,0)) != -1) { kread(fil,&artversion,4); artversion = B_LITTLE32(artversion); - if (artversion != 1) { + if (artversion != 1) + { Bprintf("loadpics(): Invalid art file version in %s\n", artfilename); return(-1); } @@ -7709,7 +7796,8 @@ long loadpics(char *filename, long askedsize) kread(fil,&tilesizx[localtilestart],(localtileend-localtilestart+1)<<1); kread(fil,&tilesizy[localtilestart],(localtileend-localtilestart+1)<<1); kread(fil,&picanm[localtilestart],(localtileend-localtilestart+1)<<2); - for (i=localtilestart; i<=localtileend; i++) { + for (i=localtilestart; i<=localtileend; i++) + { tilesizx[i] = B_LITTLE16(tilesizx[i]); tilesizy[i] = B_LITTLE16(tilesizy[i]); picanm[i] = B_LITTLE32(picanm[i]); @@ -7720,7 +7808,7 @@ long loadpics(char *filename, long askedsize) { tilefilenum[i] = k; tilefileoffs[i] = offscount; - dasiz = (long)(tilesizx[i]*tilesizy[i]); + dasiz = (int)(tilesizx[i]*tilesizy[i]); offscount += dasiz; artsize += ((dasiz+15)&0xfffffff0); } @@ -7731,12 +7819,12 @@ long loadpics(char *filename, long askedsize) } while (k != numtilefiles); - clearbuf(&gotpic[0],(long)((MAXTILES+31)>>5),0L); + clearbuf(&gotpic[0],(int)((MAXTILES+31)>>5),0L); //try dpmi_DETERMINEMAXREALALLOC! - //cachesize = min((long)((Bgetsysmemsize()/100)*60),max(artsize,askedsize)); - if (Bgetsysmemsize() <= (unsigned long)askedsize) + //cachesize = min((int)((Bgetsysmemsize()/100)*60),max(artsize,askedsize)); + if (Bgetsysmemsize() <= (unsigned int)askedsize) cachesize = (Bgetsysmemsize()/100)*60; else cachesize = askedsize; @@ -7774,7 +7862,7 @@ char faketile[MAXTILES]; void loadtile(short tilenume) { char *ptr; - long i, dasiz; + int i, dasiz; if ((unsigned)tilenume >= (unsigned)MAXTILES) return; dasiz = tilesizx[tilenume]*tilesizy[tilenume]; @@ -7813,7 +7901,8 @@ void loadtile(short tilenume) kread(artfil,ptr,dasiz); faketimerhandler(); artfilplc = tilefileoffs[tilenume]+dasiz; - } else { Bmemset((char *)waloff[tilenume],0,dasiz); faketimerhandler(); } + } + else { Bmemset((char *)waloff[tilenume],0,dasiz); faketimerhandler(); } } void checktile(short tilenume) @@ -7825,9 +7914,9 @@ void checktile(short tilenume) // // allocatepermanenttile // -long allocatepermanenttile(short tilenume, long xsiz, long ysiz) +int allocatepermanenttile(short tilenume, int xsiz, int ysiz) { - long j, dasiz; + int j, dasiz; if ((xsiz <= 0) || (ysiz <= 0) || ((unsigned)tilenume >= (unsigned)MAXTILES)) return(0); @@ -7853,11 +7942,11 @@ long allocatepermanenttile(short tilenume, long xsiz, long ysiz) // // copytilepiece // -void copytilepiece(long tilenume1, long sx1, long sy1, long xsiz, long ysiz, - long tilenume2, long sx2, long sy2) +void copytilepiece(int tilenume1, int sx1, int sy1, int xsiz, int ysiz, + int tilenume2, int sx2, int sy2) { char *ptr1, *ptr2, dat; - long xsiz1, ysiz1, xsiz2, ysiz2, i, j, x1, y1, x2, y2; + int xsiz1, ysiz1, xsiz2, ysiz2, i, j, x1, y1, x2, y2; xsiz1 = tilesizx[tilenume1]; ysiz1 = tilesizy[tilenume1]; xsiz2 = tilesizx[tilenume2]; ysiz2 = tilesizy[tilenume2]; @@ -7895,9 +7984,9 @@ void copytilepiece(long tilenume1, long sx1, long sy1, long xsiz, long ysiz, // qloadkvx // #ifdef SUPERBUILD -long qloadkvx(long voxindex, char *filename) +int qloadkvx(int voxindex, char *filename) { - long i, fil, dasiz, lengcnt, lengtot; + int i, fil, dasiz, lengcnt, lengtot; char *ptr; if ((fil = kopen4load(filename,0)) == -1) return -1; @@ -7920,7 +8009,8 @@ long qloadkvx(long voxindex, char *filename) kclose(fil); #if defined POLYMOST && defined USE_OPENGL - if (voxmodels[voxindex]) { + if (voxmodels[voxindex]) + { voxfree(voxmodels[voxindex]); voxmodels[voxindex] = NULL; } @@ -7934,10 +8024,10 @@ long qloadkvx(long voxindex, char *filename) // // clipinsidebox // -long clipinsidebox(long x, long y, short wallnum, long walldist) +int clipinsidebox(int x, int y, short wallnum, int walldist) { walltype *wal; - long x1, y1, x2, y2, r; + int x1, y1, x2, y2, r; r = (walldist<<1); wal = &wall[wallnum]; x1 = wal->x+walldist-x; y1 = wal->y+walldist-y; @@ -7964,9 +8054,9 @@ long clipinsidebox(long x, long y, short wallnum, long walldist) // // clipinsideboxline // -long clipinsideboxline(long x, long y, long x1, long y1, long x2, long y2, long walldist) +int clipinsideboxline(int x, int y, int x1, int y1, int x2, int y2, int walldist) { - long r; + int r; r = (walldist<<1); @@ -7994,11 +8084,11 @@ long clipinsideboxline(long x, long y, long x1, long y1, long x2, long y2, long // // inside // -long inside(long x, long y, short sectnum) +int inside(int x, int y, short sectnum) { walltype *wal; - long i, x1, y1, x2, y2; - unsigned long cnt; + int i, x1, y1, x2, y2; + unsigned int cnt; if ((sectnum < 0) || (sectnum >= numsectors)) return(-1); @@ -8014,7 +8104,8 @@ long inside(long x, long y, short sectnum) if ((x1^x2) >= 0) cnt ^= x1; else cnt ^= (x1*y2-x2*y1)^y2; } wal++; i--; - } while (i); + } + while (i); return(cnt>>31); } @@ -8022,7 +8113,7 @@ long inside(long x, long y, short sectnum) // // getangle // -long getangle(long xvect, long yvect) +int getangle(int xvect, int yvect) { if ((xvect|yvect) == 0) return(0); if (xvect == 0) return(512+((yvect<0)<<10)); @@ -8038,7 +8129,7 @@ long getangle(long xvect, long yvect) // // ksqrt // -long ksqrt(long num) +int ksqrt(int num) { return(nsqrtasm(num)); } @@ -8047,7 +8138,7 @@ long ksqrt(long num) // // krecip // -long krecip(long num) +int krecip(int num) { return(krecipasm(num)); } @@ -8055,7 +8146,7 @@ long krecip(long num) // // setsprite // -long setsprite(short spritenum, long newx, long newy, long newz) +int setsprite(short spritenum, int newx, int newy, int newz) { short tempsectnum; @@ -8074,7 +8165,7 @@ long setsprite(short spritenum, long newx, long newy, long newz) return(0); } -long setspritez(short spritenum, long newx, long newy, long newz) +int setspritez(short spritenum, int newx, int newy, int newz) { short tempsectnum; @@ -8096,7 +8187,7 @@ long setspritez(short spritenum, long newx, long newy, long newz) // // insertsprite // -long insertsprite(short sectnum, short statnum) +int insertsprite(short sectnum, short statnum) { insertspritestat(statnum); return(insertspritesect(sectnum)); @@ -8106,7 +8197,7 @@ long insertsprite(short sectnum, short statnum) // // deletesprite // -long deletesprite(short spritenum) +int deletesprite(short spritenum) { deletespritestat(spritenum); return(deletespritesect(spritenum)); @@ -8116,7 +8207,7 @@ long deletesprite(short spritenum) // // changespritesect // -long changespritesect(short spritenum, short newsectnum) +int changespritesect(short spritenum, short newsectnum) { if ((newsectnum < 0) || (newsectnum > MAXSECTORS)) return(-1); if (sprite[spritenum].sectnum == newsectnum) return(0); @@ -8130,7 +8221,7 @@ long changespritesect(short spritenum, short newsectnum) // // changespritestat // -long changespritestat(short spritenum, short newstatnum) +int changespritestat(short spritenum, short newstatnum) { if ((newstatnum < 0) || (newstatnum > MAXSTATUS)) return(-1); if (sprite[spritenum].statnum == newstatnum) return(0); @@ -8144,10 +8235,10 @@ long changespritestat(short spritenum, short newstatnum) // // nextsectorneighborz // -long nextsectorneighborz(short sectnum, long thez, short topbottom, short direction) +int nextsectorneighborz(short sectnum, int thez, short topbottom, short direction) { walltype *wal; - long i, testz, nextz; + int i, testz, nextz; short sectortouse; if (direction == 1) nextz = 0x7fffffff; else nextz = 0x80000000; @@ -8203,7 +8294,8 @@ long nextsectorneighborz(short sectnum, long thez, short topbottom, short direct } wal++; i--; - } while (i != 0); + } + while (i != 0); return(sectortouse); } @@ -8212,12 +8304,12 @@ long nextsectorneighborz(short sectnum, long thez, short topbottom, short direct // // cansee // -long cansee(long x1, long y1, long z1, short sect1, long x2, long y2, long z2, short sect2) +int cansee(int x1, int y1, int z1, short sect1, int x2, int y2, int z2, short sect2) { sectortype *sec; walltype *wal, *wal2; - long i, cnt, nexts, x, y, z, cz, fz, dasectnum, dacnt, danum; - long x21, y21, z21, x31, y31, x34, y34, bot, t; + int i, cnt, nexts, x, y, z, cz, fz, dasectnum, dacnt, danum; + int x21, y21, z21, x31, y31, x34, y34, bot, t; if ((x1 == x2) && (y1 == y2)) return(sect1 == sect2); @@ -8262,18 +8354,18 @@ long cansee(long x1, long y1, long z1, short sect1, long x2, long y2, long z2, s // // hitscan // -long hitscan(long xs, long ys, long zs, short sectnum, long vx, long vy, long vz, - short *hitsect, short *hitwall, short *hitsprite, - long *hitx, long *hity, long *hitz, unsigned long cliptype) +int hitscan(int xs, int ys, int zs, short sectnum, int vx, int vy, int vz, + short *hitsect, short *hitwall, short *hitsprite, + int *hitx, int *hity, int *hitz, unsigned int cliptype) { sectortype *sec; walltype *wal, *wal2; spritetype *spr; - long z, zz, x1, y1=0, z1=0, x2, y2, x3, y3, x4, y4, intx, inty, intz; - long topt, topu, bot, dist, offx, offy, cstat; - long i, j, k, l, tilenum, xoff, yoff, dax, day, daz, daz2; - long ang, cosang, sinang, xspan, yspan, xrepeat, yrepeat; - long dawalclipmask, dasprclipmask; + int z, zz, x1, y1=0, z1=0, x2, y2, x3, y3, x4, y4, intx, inty, intz; + int topt, topu, bot, dist, offx, offy, cstat; + int i, j, k, l, tilenum, xoff, yoff, dax, day, daz, daz2; + int ang, cosang, sinang, xspan, yspan, xrepeat, yrepeat; + int dawalclipmask, dasprclipmask; short tempshortcnt, tempshortnum, dasector, startwall, endwall; short nextsector; char clipyou; @@ -8421,7 +8513,7 @@ long hitscan(long xs, long ys, long zs, short sectnum, long vx, long vy, long vz i = (tilesizy[spr->picnum]*spr->yrepeat<<2); if (cstat&128) z1 += (i>>1); - if (picanm[spr->picnum]&0x00ff0000) z1 -= ((long)((signed char)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); + if (picanm[spr->picnum]&0x00ff0000) z1 -= ((int)((signed char)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); if ((intz > z1) || (intz < z1-i)) continue; topu = vx*(y1-ys) - vy*(x1-xs); @@ -8442,7 +8534,7 @@ long hitscan(long xs, long ys, long zs, short sectnum, long vx, long vy, long vz //These lines get the 2 points of the rotated sprite //Given: (x1, y1) starts out as the center point tilenum = spr->picnum; - xoff = (long)((signed char)((picanm[tilenum]>>8)&255))+((long)spr->xoffset); + xoff = (int)((signed char)((picanm[tilenum]>>8)&255))+((int)spr->xoffset); if ((cstat&4) > 0) xoff = -xoff; k = spr->ang; l = spr->xrepeat; dax = sintable[k&2047]*l; day = sintable[(k+1536)&2047]*l; @@ -8459,7 +8551,7 @@ long hitscan(long xs, long ys, long zs, short sectnum, long vx, long vy, long vz 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 -= ((long)((signed char)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); + if (picanm[spr->picnum]&0x00ff0000) daz -= ((int)((signed char)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); if ((intz < daz) && (intz > daz-k)) { *hitsect = dasector; *hitwall = -1; *hitsprite = z; @@ -8474,9 +8566,9 @@ long hitscan(long xs, long ys, long zs, short sectnum, long vx, long vy, long vz if ((zs > intz) == ((cstat&8)==0)) continue; #if 1 // Abyss crash prevention code ((intz-zs)*zx overflowing a 8-bit word) - zz=(long)((intz-zs)*vx); + zz=(int)((intz-zs)*vx); intx = xs+scale(zz,1,vz); - zz=(long)((intz-zs)*vy); + zz=(int)((intz-zs)*vy); inty = ys+scale(zz,1,vz); #else intx = xs+scale(intz-zs,vx,vz); @@ -8486,8 +8578,8 @@ long hitscan(long xs, long ys, long zs, short sectnum, long vx, long vy, long vz if (klabs(intx-xs)+klabs(inty-ys) > klabs((*hitx)-xs)+klabs((*hity)-ys)) continue; tilenum = spr->picnum; - xoff = (long)((signed char)((picanm[tilenum]>>8)&255))+((long)spr->xoffset); - yoff = (long)((signed char)((picanm[tilenum]>>16)&255))+((long)spr->yoffset); + xoff = (int)((signed char)((picanm[tilenum]>>8)&255))+((int)spr->xoffset); + yoff = (int)((signed char)((picanm[tilenum]>>16)&255))+((int)spr->yoffset); if ((cstat&4) > 0) xoff = -xoff; if ((cstat&8) > 0) yoff = -yoff; @@ -8537,7 +8629,8 @@ long hitscan(long xs, long ys, long zs, short sectnum, long vx, long vy, long vz } } tempshortcnt++; - } while (tempshortcnt < tempshortnum); + } + while (tempshortcnt < tempshortnum); return(0); } @@ -8545,12 +8638,12 @@ long hitscan(long xs, long ys, long zs, short sectnum, long vx, long vy, long vz // // neartag // -long neartag(long xs, long ys, long zs, short sectnum, short ange, short *neartagsector, short *neartagwall, short *neartagsprite, long *neartaghitdist, long neartagrange, char tagsearch) +int neartag(int xs, int ys, int zs, short sectnum, short ange, short *neartagsector, short *neartagwall, short *neartagsprite, int *neartaghitdist, int neartagrange, char tagsearch) { walltype *wal, *wal2; spritetype *spr; - long i, z, zz, xe, ye, ze, x1, y1, z1, x2, y2, intx, inty, intz; - long topt, topu, bot, dist, offx, offy, vx, vy, vz; + int i, z, zz, xe, ye, ze, x1, y1, z1, x2, y2, intx, inty, intz; + int topt, topu, bot, dist, offx, offy, vx, vy, vz; short tempshortcnt, tempshortnum, dasector, startwall, endwall; short nextsector, good; @@ -8630,7 +8723,7 @@ long neartag(long xs, long ys, long zs, short sectnum, short ange, short *nearta intz = zs+scale(vz,topt,bot); i = tilesizy[spr->picnum]*spr->yrepeat; if (spr->cstat&128) z1 += (i<<1); - if (picanm[spr->picnum]&0x00ff0000) z1 -= ((long)((signed char)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); + if (picanm[spr->picnum]&0x00ff0000) z1 -= ((int)((signed char)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); if ((intz <= z1) && (intz >= z1-(i<<2))) { topu = vx*(y1-ys) - vy*(x1-xs); @@ -8659,7 +8752,8 @@ long neartag(long xs, long ys, long zs, short sectnum, short ange, short *nearta } tempshortcnt++; - } while (tempshortcnt < tempshortnum); + } + while (tempshortcnt < tempshortnum); return(0); } @@ -8667,7 +8761,7 @@ long neartag(long xs, long ys, long zs, short sectnum, short ange, short *nearta // // dragpoint // -void dragpoint(short pointhighlight, long dax, long day) +void dragpoint(short pointhighlight, int dax, int day) { short cnt, tempshort; @@ -8713,9 +8807,9 @@ void dragpoint(short pointhighlight, long dax, long day) // // lastwall // -long lastwall(short point) +int lastwall(short point) { - long i, j, cnt; + int i, j, cnt; if ((point > 0) && (wall[point-1].point2 == point)) return(point-1); i = point; @@ -8726,7 +8820,8 @@ long lastwall(short point) if (j == point) return(i); i = j; cnt--; - } while (cnt > 0); + } + while (cnt > 0); return(point); } @@ -8741,26 +8836,26 @@ long lastwall(short point) clipnum++; \ } \ } \ - -long clipmoveboxtracenum = 3; + +int clipmoveboxtracenum = 3; // // clipmove // -long clipmove (long *x, long *y, long *z, short *sectnum, - long xvect, long yvect, - long walldist, long ceildist, long flordist, unsigned long cliptype) +int clipmove(int *x, int *y, int *z, short *sectnum, + int xvect, int yvect, + int walldist, int ceildist, int flordist, unsigned int cliptype) { walltype *wal, *wal2; spritetype *spr; sectortype *sec, *sec2; - long i, j, templong1, templong2; - long oxvect, oyvect, goalx, goaly, intx, inty, lx, ly, retval; - long k, l, clipsectcnt, startwall, endwall, cstat, dasect; - long x1, y1, x2, y2, cx, cy, rad, xmin, ymin, xmax, ymax, daz, daz2; - long bsz, dax, day, xoff, yoff, xspan, yspan, cosang, sinang, tilenum; - long xrepeat, yrepeat, gx, gy, dx, dy, dasprclipmask, dawalclipmask; - long hitwall, cnt, clipyou; + int i, j, tempint1, tempint2; + int oxvect, oyvect, goalx, goaly, intx, inty, lx, ly, retval; + int k, l, clipsectcnt, startwall, endwall, cstat, dasect; + int x1, y1, x2, y2, cx, cy, rad, xmin, ymin, xmax, ymax, daz, daz2; + int bsz, dax, day, xoff, yoff, xspan, yspan, cosang, sinang, tilenum; + int xrepeat, yrepeat, gx, gy, dx, dy, dasprclipmask, dawalclipmask; + int hitwall, cnt, clipyou; if (((xvect|yvect) == 0) || (*sectnum < 0)) return(0); retval = 0; @@ -8867,7 +8962,7 @@ long clipmove (long *x, long *y, long *z, short *sectnum, { 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 -= ((long)((signed char)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); + if (picanm[spr->picnum]&0x00ff0000) daz -= ((int)((signed char)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); if (((*z) < daz+ceildist) && ((*z) > daz-k-flordist)) { bsz = (spr->clipdist<<2)+walldist; if (gx < 0) bsz = -bsz; @@ -8880,7 +8975,7 @@ long clipmove (long *x, long *y, long *z, short *sectnum, case 16: 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 -= ((long)((signed char)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); + if (picanm[spr->picnum]&0x00ff0000) daz -= ((int)((signed char)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); daz2 = daz-k; daz += ceildist; daz2 -= flordist; if (((*z) < daz) && ((*z) > daz2)) @@ -8888,7 +8983,7 @@ long clipmove (long *x, long *y, long *z, short *sectnum, //These lines get the 2 points of the rotated sprite //Given: (x1, y1) starts out as the center point tilenum = spr->picnum; - xoff = (long)((signed char)((picanm[tilenum]>>8)&255))+((long)spr->xoffset); + xoff = (int)((signed char)((picanm[tilenum]>>8)&255))+((int)spr->xoffset); if ((cstat&4) > 0) xoff = -xoff; k = spr->ang; l = spr->xrepeat; dax = sintable[k&2047]*l; day = sintable[(k+1536)&2047]*l; @@ -8912,9 +9007,9 @@ long clipmove (long *x, long *y, long *z, short *sectnum, //Side blocker if ((x2-x1)*((*x)-x1) + (y2-y1)*((*y)-y1) < 0) - { addclipline(x1-day,y1+dax,x1+dax,y1+day,(short)j+49152); } + { addclipline(x1-day,y1+dax,x1+dax,y1+day,(short)j+49152); } else if ((x1-x2)*((*x)-x2) + (y1-y2)*((*y)-y2) < 0) - { addclipline(x2+day,y2-dax,x2-dax,y2-day,(short)j+49152); } + { addclipline(x2+day,y2-dax,x2-dax,y2-day,(short)j+49152); } } } break; @@ -8927,8 +9022,8 @@ long clipmove (long *x, long *y, long *z, short *sectnum, if (((*z) > spr->z) == ((cstat&8)==0)) continue; tilenum = spr->picnum; - xoff = (long)((signed char)((picanm[tilenum]>>8)&255))+((long)spr->xoffset); - yoff = (long)((signed char)((picanm[tilenum]>>16)&255))+((long)spr->yoffset); + xoff = (int)((signed char)((picanm[tilenum]>>8)&255))+((int)spr->xoffset); + yoff = (int)((signed char)((picanm[tilenum]>>16)&255))+((int)spr->yoffset); if ((cstat&4) > 0) xoff = -xoff; if ((cstat&8) > 0) yoff = -yoff; @@ -8975,7 +9070,8 @@ long clipmove (long *x, long *y, long *z, short *sectnum, break; } } - } while (clipsectcnt < clipsectnum); + } + while (clipsectcnt < clipsectnum); hitwall = 0; @@ -8987,25 +9083,25 @@ long clipmove (long *x, long *y, long *z, short *sectnum, { lx = clipit[hitwall].x2-clipit[hitwall].x1; ly = clipit[hitwall].y2-clipit[hitwall].y1; - templong2 = lx*lx + ly*ly; - if (templong2 > 0) + tempint2 = lx*lx + ly*ly; + if (tempint2 > 0) { - templong1 = (goalx-intx)*lx + (goaly-inty)*ly; + tempint1 = (goalx-intx)*lx + (goaly-inty)*ly; - if ((klabs(templong1)>>11) < templong2) - i = divscale20(templong1,templong2); + if ((klabs(tempint1)>>11) < tempint2) + i = divscale20(tempint1,tempint2); else i = 0; goalx = mulscale20(lx,i)+intx; goaly = mulscale20(ly,i)+inty; } - templong1 = dmulscale6(lx,oxvect,ly,oyvect); + tempint1 = dmulscale6(lx,oxvect,ly,oyvect); for (i=cnt+1;i<=clipmoveboxtracenum;i++) { j = hitwalls[i]; - templong2 = dmulscale6(clipit[j].x2-clipit[j].x1,oxvect,clipit[j].y2-clipit[j].y1,oyvect); - if ((templong1^templong2) < 0) + tempint2 = dmulscale6(clipit[j].x2-clipit[j].x1,oxvect,clipit[j].y2-clipit[j].y1,oyvect); + if ((tempint1^tempint2) < 0) { updatesector(*x,*y,sectnum); return(retval); @@ -9023,7 +9119,8 @@ long clipmove (long *x, long *y, long *z, short *sectnum, *x = intx; *y = inty; - } while (((xvect|yvect) != 0) && (hitwall >= 0) && (cnt > 0)); + } + while (((xvect|yvect) != 0) && (hitwall >= 0) && (cnt > 0)); for (j=0;j=0;j--) if (inside(*x,*y,j) == 1) { if (sector[j].ceilingstat&2) - templong2 = (getceilzofslope((short)j,*x,*y)-(*z)); + tempint2 = (getceilzofslope((short)j,*x,*y)-(*z)); else - templong2 = (sector[j].ceilingz-(*z)); + tempint2 = (sector[j].ceilingz-(*z)); - if (templong2 > 0) + if (tempint2 > 0) { - if (templong2 < templong1) - { *sectnum = j; templong1 = templong2; } + if (tempint2 < tempint1) + { *sectnum = j; tempint1 = tempint2; } } else { if (sector[j].floorstat&2) - templong2 = ((*z)-getflorzofslope((short)j,*x,*y)); + tempint2 = ((*z)-getflorzofslope((short)j,*x,*y)); else - templong2 = ((*z)-sector[j].floorz); + tempint2 = ((*z)-sector[j].floorz); - if (templong2 <= 0) + if (tempint2 <= 0) { *sectnum = j; return(retval); } - if (templong2 < templong1) - { *sectnum = j; templong1 = templong2; } + if (tempint2 < tempint1) + { *sectnum = j; tempint1 = tempint2; } } } @@ -9070,14 +9167,14 @@ long clipmove (long *x, long *y, long *z, short *sectnum, // // pushmove // -long pushmove (long *x, long *y, long *z, short *sectnum, - long walldist, long ceildist, long flordist, unsigned long cliptype) +int pushmove(int *x, int *y, int *z, short *sectnum, + int walldist, int ceildist, int flordist, unsigned int cliptype) { sectortype *sec, *sec2; walltype *wal, *wal2; spritetype *spr; - long i, j, k, t, dx, dy, dax, day, daz, daz2, bad, dir; - long dasprclipmask, dawalclipmask; + int i, j, k, t, dx, dy, dax, day, daz, daz2, bad, dir; + int dasprclipmask, dawalclipmask; short startwall, endwall, clipsectcnt; char bad2; @@ -9109,7 +9206,7 @@ long pushmove (long *x, long *y, long *z, short *sectnum, { t = ((tilesizy[spr->picnum]*spr->yrepeat)<<2); if (spr->cstat&128) daz = spr->z+(t>>1); else daz = spr->z; - if (picanm[spr->picnum]&0x00ff0000) daz -= ((long)((signed char)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); + if (picanm[spr->picnum]&0x00ff0000) daz -= ((int)((signed char)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); if (((*z) < daz+ceildist) && ((*z) > daz-t-flordist)) { t = (spr->clipdist<<2)+walldist; @@ -9182,7 +9279,8 @@ long pushmove (long *x, long *y, long *z, short *sectnum, { *x = (*x) + dx; *y = (*y) + dy; bad2--; if (bad2 == 0) break; - } while (clipinsidebox(*x,*y,i,walldist-4) != 0); + } + while (clipinsidebox(*x,*y,i,walldist-4) != 0); bad = -1; k--; if (k <= 0) return(bad); updatesector(*x,*y,sectnum); @@ -9196,9 +9294,11 @@ long pushmove (long *x, long *y, long *z, short *sectnum, } clipsectcnt++; - } while (clipsectcnt < clipsectnum); + } + while (clipsectcnt < clipsectnum); dir = -dir; - } while (bad != 0); + } + while (bad != 0); return(bad); } @@ -9207,10 +9307,10 @@ long pushmove (long *x, long *y, long *z, short *sectnum, // // updatesector[z] // -void updatesector(long x, long y, short *sectnum) +void updatesector(int x, int y, short *sectnum) { walltype *wal; - long i, j; + int i, j; if (inside(x,y,*sectnum) == 1) return; @@ -9229,7 +9329,8 @@ void updatesector(long x, long y, short *sectnum) } wal++; j--; - } while (j != 0); + } + while (j != 0); } for (i=numsectors-1;i>=0;i--) @@ -9242,10 +9343,10 @@ void updatesector(long x, long y, short *sectnum) *sectnum = -1; } -void updatesectorz(long x, long y, long z, short *sectnum) +void updatesectorz(int x, int y, int z, short *sectnum) { walltype *wal; - long i, j, cz, fz; + int i, j, cz, fz; getzsofslope(*sectnum, x, y, &cz, &fz); if ((z >= cz) && (z <= fz)) @@ -9263,10 +9364,11 @@ void updatesectorz(long x, long y, long z, short *sectnum) getzsofslope(i, x, y, &cz, &fz); if ((z >= cz) && (z <= fz)) if (inside(x,y,(short)i) == 1) - { *sectnum = i; return; } + { *sectnum = i; return; } } wal++; j--; - } while (j != 0); + } + while (j != 0); } for (i=numsectors-1;i>=0;i--) @@ -9274,7 +9376,7 @@ void updatesectorz(long x, long y, long z, short *sectnum) getzsofslope(i, x, y, &cz, &fz); if ((z >= cz) && (z <= fz)) if (inside(x,y,(short)i) == 1) - { *sectnum = i; return; } + { *sectnum = i; return; } } *sectnum = -1; @@ -9284,9 +9386,9 @@ void updatesectorz(long x, long y, long z, short *sectnum) // // rotatepoint // -void rotatepoint(long xpivot, long ypivot, long x, long y, short daang, long *x2, long *y2) +void rotatepoint(int xpivot, int ypivot, int x, int y, short daang, int *x2, int *y2) { - long dacos, dasin; + int dacos, dasin; dacos = sintable[(daang+2560)&2047]; dasin = sintable[(daang+2048)&2047]; @@ -9301,7 +9403,7 @@ void rotatepoint(long xpivot, long ypivot, long x, long y, short daang, long *x2 // getmousevalues // -void getmousevalues(long *mousx, long *mousy, long *bstatus) +void getmousevalues(int *mousx, int *mousy, int *bstatus) { readmousexy(mousx,mousy); readmousebstatus(bstatus); @@ -9311,27 +9413,27 @@ void getmousevalues(long *mousx, long *mousy, long *bstatus) // // krand // -long krand(void) +int krand(void) { randomseed = (randomseed*27584621)+1; - return(((unsigned long)randomseed)>>16); + return(((unsigned int)randomseed)>>16); } // // getzrange // -void getzrange(long x, long y, long z, short sectnum, - long *ceilz, long *ceilhit, long *florz, long *florhit, - long walldist, unsigned long cliptype) +void getzrange(int x, int y, int z, short sectnum, + int *ceilz, int *ceilhit, int *florz, int *florhit, + int walldist, unsigned int cliptype) { sectortype *sec; walltype *wal, *wal2; spritetype *spr; - long clipsectcnt, startwall, endwall, tilenum, xoff, yoff, dax, day; - long xmin, ymin, xmax, ymax, i, j, k, l, daz, daz2, dx, dy; - long x1, y1, x2, y2, x3, y3, x4, y4, ang, cosang, sinang; - long xspan, yspan, xrepeat, yrepeat, dasprclipmask, dawalclipmask; + int clipsectcnt, startwall, endwall, tilenum, xoff, yoff, dax, day; + int xmin, ymin, xmax, ymax, i, j, k, l, daz, daz2, dx, dy; + int x1, y1, x2, y2, x3, y3, x4, y4, ang, cosang, sinang; + int xspan, yspan, xrepeat, yrepeat, dasprclipmask, dawalclipmask; short cstat; char clipyou; @@ -9400,12 +9502,13 @@ void getzrange(long x, long y, long z, short sectnum, //It actually got here, through all the continue's!!! getzsofslope((short)k,x,y,&daz,&daz2); - if (daz > *ceilz) { *ceilz = daz; *ceilhit = k+16384; } + if (daz > *ceilz) { *ceilz = daz; *ceilhit = k+16384; } if (daz2 < *florz) { *florz = daz2; *florhit = k+16384; } } } clipsectcnt++; - } while (clipsectcnt < clipsectnum); + } + while (clipsectcnt < clipsectnum); for (i=0;iz; k = ((tilesizy[spr->picnum]*spr->yrepeat)<<1); if (cstat&128) daz += k; - if (picanm[spr->picnum]&0x00ff0000) daz -= ((long)((signed char)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); + if (picanm[spr->picnum]&0x00ff0000) daz -= ((int)((signed char)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); daz2 = daz - (k<<1); clipyou = 1; } break; case 16: tilenum = spr->picnum; - xoff = (long)((signed char)((picanm[tilenum]>>8)&255))+((long)spr->xoffset); + xoff = (int)((signed char)((picanm[tilenum]>>8)&255))+((int)spr->xoffset); if ((cstat&4) > 0) xoff = -xoff; k = spr->ang; l = spr->xrepeat; dax = sintable[k&2047]*l; day = sintable[(k+1536)&2047]*l; @@ -9445,7 +9548,7 @@ void getzrange(long x, long y, long z, short sectnum, { daz = spr->z; k = ((tilesizy[spr->picnum]*spr->yrepeat)<<1); if (cstat&128) daz += k; - if (picanm[spr->picnum]&0x00ff0000) daz -= ((long)((signed char)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); + if (picanm[spr->picnum]&0x00ff0000) daz -= ((int)((signed char)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); daz2 = daz-(k<<1); clipyou = 1; } @@ -9457,8 +9560,8 @@ void getzrange(long x, long y, long z, short sectnum, if ((z > daz) == ((cstat&8)==0)) continue; tilenum = spr->picnum; - xoff = (long)((signed char)((picanm[tilenum]>>8)&255))+((long)spr->xoffset); - yoff = (long)((signed char)((picanm[tilenum]>>16)&255))+((long)spr->yoffset); + xoff = (int)((signed char)((picanm[tilenum]>>8)&255))+((int)spr->xoffset); + yoff = (int)((signed char)((picanm[tilenum]>>16)&255))+((int)spr->yoffset); if ((cstat&4) > 0) xoff = -xoff; if ((cstat&8) > 0) yoff = -yoff; @@ -9519,9 +9622,9 @@ void getzrange(long x, long y, long z, short sectnum, // // setview // -void setview(long x1, long y1, long x2, long y2) +void setview(int x1, int y1, int x2, int y2) { - long i; + int i; windowx1 = x1; wx1 = (x1<<12); windowy1 = y1; wy1 = (y1<<12); @@ -9532,11 +9635,11 @@ void setview(long x1, long y1, long x2, long y2) xdimenrecip = divscale32(1L,xdimen); ydimen = (y2-y1)+1; - setaspect(65536L,(long)divscale16(ydim*320L,xdim*200L)); + setaspect(65536L,(int)divscale16(ydim*320L,xdim*200L)); for (i=0;i cx2) || (cy1 > cy2)) return; @@ -9584,7 +9687,8 @@ void rotatesprite(long sx, long sy, long z, short a, short picnum, signed char d if (picanm[picnum]&192) picnum += animateoffs(picnum,(short)0xc000); if ((tilesizx[picnum] <= 0) || (tilesizy[picnum] <= 0)) return; - if (((dastat&128) == 0) || (numpages < 2) || (beforedrawrooms != 0)) { + if (((dastat&128) == 0) || (numpages < 2) || (beforedrawrooms != 0)) + { begindrawing(); //{{{ dorotatesprite(sx,sy,z,a,picnum,dashade,dapalnum,dastat,cx1,cy1,cx2,cy2,guniqhudid); enddrawing(); //}}} @@ -9652,9 +9756,9 @@ void rotatesprite(long sx, long sy, long z, short a, short picnum, signed char d // // makepalookup // -void makepalookup(long palnum, char *remapbuf, signed char r, signed char g, signed char b, char dastat) +void makepalookup(int palnum, char *remapbuf, signed char r, signed char g, signed char b, char dastat) { - long i, j, palscale; + int i, j, palscale; char *ptr, *ptr2; if (paletteloaded == 0) return; @@ -9663,7 +9767,7 @@ void makepalookup(long palnum, char *remapbuf, signed char r, signed char g, sig { //Allocate palookup buffer if ((palookup[palnum] = (char *)kkmalloc(numpalookups<<8)) == NULL) - allocache((long*)&palookup[palnum],numpalookups<<8,&permanentlock); + allocache((int*)&palookup[palnum],numpalookups<<8,&permanentlock); } if (dastat == 0) return; @@ -9676,7 +9780,7 @@ void makepalookup(long palnum, char *remapbuf, signed char r, signed char g, sig ptr = (char *)(FP_OFF(palookup[0])+remapbuf[i]); ptr2 = (char *)(FP_OFF(palookup[palnum])+i); for (j=0;j= 3) { + if (rendmode >= 3) + { newpalettesum = crc32once((unsigned char *)curpalettefaded, sizeof(curpalettefaded)); // only reset the textures if the preserve flag (bit 1 of noapply) is clear and @@ -9787,9 +9893,11 @@ void setpalettefade(char r, char g, char b, char offset) palfadedelta = min(63,offset) << 2; k = 0; - for (i=0;i<256;i++) { + for (i=0;i<256;i++) + { if (gammabrightness) p = curpalette[i]; - else { + else + { p.b = britable[curbrightness][ curpalette[i].b ]; p.g = britable[curbrightness][ curpalette[i].g ]; p.r = britable[curbrightness][ curpalette[i].r ]; @@ -9797,13 +9905,13 @@ void setpalettefade(char r, char g, char b, char offset) tempbuf[k++] = (curpalettefaded[i].b = - p.b + ( ( ( (long)palfadergb.b - (long)p.b ) * (long)offset ) >> 6 ) ) >> 2; + p.b + ((((int)palfadergb.b - (int)p.b) * (int)offset) >> 6)) >> 2; tempbuf[k++] = (curpalettefaded[i].g = - p.g + ( ( ( (long)palfadergb.g - (long)p.g ) * (long)offset ) >> 6 ) ) >> 2; + p.g + ((((int)palfadergb.g - (int)p.g) * (int)offset) >> 6)) >> 2; tempbuf[k++] = (curpalettefaded[i].r = - p.r + ( ( ( (long)palfadergb.r - (long)p.r ) * (long)offset ) >> 6 ) ) >> 2; + p.r + ((((int)palfadergb.r - (int)p.r) * (int)offset) >> 6)) >> 2; tempbuf[k++] = curpalettefaded[i].f = 0; } @@ -9814,17 +9922,19 @@ void setpalettefade(char r, char g, char b, char offset) // // clearview // -void clearview(long dacol) +void clearview(int dacol) { - long p, y, dx; + int p, y, dx; if (qsetmode != 200) return; #if defined(POLYMOST) && defined(USE_OPENGL) - if (rendmode >= 3) { + if (rendmode >= 3) + { palette_t p; if (gammabrightness) p = curpalette[dacol]; - else { + else + { p.r = britable[curbrightness][ curpalette[dacol].r ]; p.g = britable[curbrightness][ curpalette[dacol].g ]; p.b = britable[curbrightness][ curpalette[dacol].b ]; @@ -9842,7 +9952,8 @@ void clearview(long dacol) dx = windowx2-windowx1+1; //dacol += (dacol<<8); dacol += (dacol<<16); p = frameplace+ylookup[windowy1]+windowx1; - for (y=windowy1;y<=windowy2;y++) { + for (y=windowy1;y<=windowy2;y++) + { //clearbufbyte((void*)p,dx,dacol); Bmemset((void*)p,dacol,dx); p += ylookup[1]; @@ -9856,16 +9967,18 @@ void clearview(long dacol) // // clearallviews // -void clearallviews(long dacol) +void clearallviews(int dacol) { if (qsetmode != 200) return; //dacol += (dacol<<8); dacol += (dacol<<16); #if defined(POLYMOST) && defined(USE_OPENGL) - if (rendmode >= 3) { + if (rendmode >= 3) + { palette_t p; if (gammabrightness) p = curpalette[dacol]; - else { + else + { p.r = britable[curbrightness][ curpalette[dacol].r ]; p.g = britable[curbrightness][ curpalette[dacol].g ]; p.b = britable[curbrightness][ curpalette[dacol].b ]; @@ -9893,13 +10006,15 @@ void clearallviews(long dacol) // // plotpixel // -void plotpixel(long x, long y, char col) +void plotpixel(int x, int y, char col) { #if defined(POLYMOST) && defined(USE_OPENGL) - if (rendmode >= 3 && qsetmode == 200) { + if (rendmode >= 3 && qsetmode == 200) + { palette_t p; if (gammabrightness) p = curpalette[col]; - else { + else + { p.r = britable[curbrightness][ curpalette[col].r ]; p.g = britable[curbrightness][ curpalette[col].g ]; p.b = britable[curbrightness][ curpalette[col].b ]; @@ -9917,7 +10032,7 @@ void plotpixel(long x, long y, char col) #endif begindrawing(); //{{{ - drawpixel((void*)(ylookup[y]+x+frameplace),(long)col); + drawpixel((void*)(ylookup[y]+x+frameplace),(int)col); enddrawing(); //}}} } @@ -9925,7 +10040,7 @@ void plotpixel(long x, long y, char col) // // getpixel // -char getpixel(long x, long y) +char getpixel(int x, int y) { char r; @@ -9945,9 +10060,9 @@ char getpixel(long x, long y) // // setviewtotile // -void setviewtotile(short tilenume, long xsiz, long ysiz) +void setviewtotile(short tilenume, int xsiz, int ysiz) { - long i, j; + int i, j; //DRAWROOMS TO TILE BACKUP&SET CODE tilesizx[tilenume] = xsiz; tilesizy[tilenume] = ysiz; @@ -9956,7 +10071,8 @@ void setviewtotile(short tilenume, long xsiz, long ysiz) bakwindowx1[setviewcnt] = windowx1; bakwindowy1[setviewcnt] = windowy1; bakwindowx2[setviewcnt] = windowx2; bakwindowy2[setviewcnt] = windowy2; #ifdef POLYMOST - if (setviewcnt == 0) { + if (setviewcnt == 0) + { bakrendmode = rendmode; baktile = tilenume; } @@ -9980,14 +10096,15 @@ void setviewtotile(short tilenume, long xsiz, long ysiz) extern char modechange; void setviewback(void) { - long i, j, k; + int i, j, k; if (setviewcnt <= 0) return; setviewcnt--; offscreenrendering = (setviewcnt>0); #ifdef POLYMOST - if (setviewcnt == 0) { + if (setviewcnt == 0) + { rendmode = bakrendmode; invalidatetile(baktile,-1,-1); } @@ -10013,7 +10130,7 @@ void setviewback(void) // void squarerotatetile(short tilenume) { - long i, j, k, xsiz, ysiz; + int i, j, k, xsiz, ysiz; char *ptr1, *ptr2; xsiz = tilesizx[tilenume]; ysiz = tilesizy[tilenume]; @@ -10027,7 +10144,7 @@ void squarerotatetile(short tilenume) ptr1 = (char *)(waloff[tilenume]+i*(xsiz+1)); ptr2 = ptr1; if ((i&1) != 0) { ptr1--; ptr2 -= xsiz; swapchar(ptr1,ptr2); } for (j=(i>>1)-1;j>=0;j--) - { ptr1 -= 2; ptr2 -= k; swapchar2(ptr1,ptr2,xsiz); } + { ptr1 -= 2; ptr2 -= k; swapchar2(ptr1,ptr2,xsiz); } } } } @@ -10036,9 +10153,9 @@ void squarerotatetile(short tilenume) // // preparemirror // -void preparemirror(long dax, long day, long daz, short daang, long dahoriz, short dawall, short dasector, long *tposx, long *tposy, short *tang) +void preparemirror(int dax, int day, int daz, short daang, int dahoriz, short dawall, short dasector, int *tposx, int *tposy, short *tang) { - long i, j, x, y, dx, dy; + int i, j, x, y, dx, dy; x = wall[dawall].x; dx = wall[wall[dawall].point2].x-x; y = wall[dawall].y; dy = wall[wall[dawall].point2].y-y; @@ -10057,14 +10174,14 @@ void preparemirror(long dax, long day, long daz, short daang, long dahoriz, shor // void completemirror(void) { - long i, dy, p; + int i, dy, p; #ifdef POLYMOST if (rendmode) return; #endif //Can't reverse with uninitialized data -if (inpreparemirror) { inpreparemirror = 0; return; } + if (inpreparemirror) { inpreparemirror = 0; return; } if (mirrorsx1 > 0) mirrorsx1--; if (mirrorsx2 < windowx2-windowx1-1) mirrorsx2++; if (mirrorsx2 < mirrorsx1) return; @@ -10087,9 +10204,9 @@ if (inpreparemirror) { inpreparemirror = 0; return; } // // sectorofwall // -long sectorofwall(short theline) +int sectorofwall(short theline) { - long i, gap; + int i, gap; if ((theline < 0) || (theline >= numwalls)) return(-1); i = wall[theline].nextwall; if (i >= 0) return(wall[i].nextsector); @@ -10109,9 +10226,9 @@ long sectorofwall(short theline) // // getceilzofslope // -long getceilzofslope(short sectnum, long dax, long day) +int getceilzofslope(short sectnum, int dax, int day) { - long dx, dy, i, j; + int dx, dy, i, j; walltype *wal; if (!(sector[sectnum].ceilingstat&2)) return(sector[sectnum].ceilingz); @@ -10126,9 +10243,9 @@ long getceilzofslope(short sectnum, long dax, long day) // // getflorzofslope // -long getflorzofslope(short sectnum, long dax, long day) +int getflorzofslope(short sectnum, int dax, int day) { - long dx, dy, i, j; + int dx, dy, i, j; walltype *wal; if (!(sector[sectnum].floorstat&2)) return(sector[sectnum].floorz); @@ -10143,9 +10260,9 @@ long getflorzofslope(short sectnum, long dax, long day) // // getzsofslope // -void getzsofslope(short sectnum, long dax, long day, long *ceilz, long *florz) +void getzsofslope(short sectnum, int dax, int day, int *ceilz, int *florz) { - long dx, dy, i, j; + int dx, dy, i, j; walltype *wal, *wal2; sectortype *sec; @@ -10166,9 +10283,9 @@ void getzsofslope(short sectnum, long dax, long day, long *ceilz, long *florz) // // alignceilslope // -void alignceilslope(short dasect, long x, long y, long z) +void alignceilslope(short dasect, int x, int y, int z) { - long i, dax, day; + int i, dax, day; walltype *wal; wal = &wall[sector[dasect].wallptr]; @@ -10187,9 +10304,9 @@ void alignceilslope(short dasect, long x, long y, long z) // // alignflorslope // -void alignflorslope(short dasect, long x, long y, long z) +void alignflorslope(short dasect, int x, int y, int z) { - long i, dax, day; + int i, dax, day; walltype *wal; wal = &wall[sector[dasect].wallptr]; @@ -10208,9 +10325,9 @@ void alignflorslope(short dasect, long x, long y, long z) // // loopnumofsector // -long loopnumofsector(short sectnum, short wallnum) +int loopnumofsector(short sectnum, short wallnum) { - long i, numloops, startwall, endwall; + int i, numloops, startwall, endwall; numloops = 0; startwall = sector[sectnum].wallptr; @@ -10229,8 +10346,8 @@ long loopnumofsector(short sectnum, short wallnum) // void setfirstwall(short sectnum, short newfirstwall) { - long i, j, k, numwallsofloop; - long startwall, endwall, danumwalls, dagoalloop; + int i, j, k, numwallsofloop; + int startwall, endwall, danumwalls, dagoalloop; startwall = sector[sectnum].wallptr; danumwalls = sector[sectnum].wallnum; @@ -10245,7 +10362,8 @@ void setfirstwall(short sectnum, short newfirstwall) { numwallsofloop++; i = wall[i].point2; - } while (i != newfirstwall); + } + while (i != newfirstwall); //Put correct loop at beginning dagoalloop = loopnumofsector(sectnum,newfirstwall); @@ -10289,9 +10407,9 @@ void setfirstwall(short sectnum, short newfirstwall) // // drawline256 // -void drawline256(long x1, long y1, long x2, long y2, char col) +void drawline256(int x1, int y1, int x2, int y2, char col) { - long dx, dy, i, j, p, inc, plc, daend; + int dx, dy, i, j, p, inc, plc, daend; col = palookup[0][col]; @@ -10300,7 +10418,8 @@ void drawline256(long x1, long y1, long x2, long y2, char col) { palette_t p; if (gammabrightness) p = curpalette[col]; - else { + else + { p.r = britable[curbrightness][ curpalette[col].r ]; p.g = britable[curbrightness][ curpalette[col].g ]; p.b = britable[curbrightness][ curpalette[col].b ]; @@ -10399,37 +10518,37 @@ void drawline256(long x1, long y1, long x2, long y2, char col) // // JBF: Had to add extra tests to make sure x-coordinates weren't winding up -'ve // after clipping or crashes would ensue -unsigned long drawlinepat = 0xffffffff; +unsigned int drawlinepat = 0xffffffff; -void drawline16(long x1, long y1, long x2, long y2, char col) +void drawline16(int x1, int y1, int x2, int y2, char col) { - long i, dx, dy, p, pinc, d; - unsigned long patc=0; + int i, dx, dy, p, pinc, d; + unsigned int patc=0; dx = x2-x1; dy = y2-y1; if (dx >= 0) { if ((x1 >= xres) || (x2 < 0)) return; - if (x1 < 0) { if (dy) y1 += scale(0-x1,dy,dx); x1 = 0; } - if (x2 >= xres) { if (dy) y2 += scale(xres-1-x2,dy,dx); x2 = xres-1; } + if (x1 < 0) { if (dy) y1 += scale(0-x1,dy,dx); x1 = 0; } + if (x2 >= xres) { if (dy) y2 += scale(xres-1-x2,dy,dx); x2 = xres-1; } } else { if ((x2 >= xres) || (x1 < 0)) return; - if (x2 < 0) { if (dy) y2 += scale(0-x2,dy,dx); x2 = 0; } - if (x1 >= xres) { if (dy) y1 += scale(xres-1-x1,dy,dx); x1 = xres-1; } + if (x2 < 0) { if (dy) y2 += scale(0-x2,dy,dx); x2 = 0; } + if (x1 >= xres) { if (dy) y1 += scale(xres-1-x1,dy,dx); x1 = xres-1; } } if (dy >= 0) { if ((y1 >= ydim16) || (y2 < 0)) return; - if (y1 < 0) { if (dx) x1 += scale(0-y1,dx,dy); y1 = 0; if (x1 < 0) x1 = 0; } - if (y2 >= ydim16) { if (dx) x2 += scale(ydim16-1-y2,dx,dy); y2 = ydim16-1; if (x2 < 0) x2 = 0; } + if (y1 < 0) { if (dx) x1 += scale(0-y1,dx,dy); y1 = 0; if (x1 < 0) x1 = 0; } + if (y2 >= ydim16) { if (dx) x2 += scale(ydim16-1-y2,dx,dy); y2 = ydim16-1; if (x2 < 0) x2 = 0; } } else { if ((y2 >= ydim16) || (y1 < 0)) return; - if (y2 < 0) { if (dx) x2 += scale(0-y2,dx,dy); y2 = 0; if (x2 < 0) x2 = 0; } - if (y1 >= ydim16) { if (dx) x1 += scale(ydim16-1-y1,dx,dy); y1 = ydim16-1; if (x1 < 0) x1 = 0; } + if (y2 < 0) { if (dx) x2 += scale(0-y2,dx,dy); y2 = 0; if (x2 < 0) x2 = 0; } + if (y1 >= ydim16) { if (dx) x1 += scale(ydim16-1-y1,dx,dy); y1 = ydim16-1; if (x1 < 0) x1 = 0; } } dx = klabs(x2-x1)+1; dy = klabs(y2-y1)+1; @@ -10445,16 +10564,18 @@ void drawline16(long x1, long y1, long x2, long y2, char col) begindrawing(); //{{{ p = (y1*bytesperline)+x1+frameplace; - if (dy == 0 && drawlinepat == 0xffffffff) { - i = ((long)col<<24)|((long)col<<16)|((long)col<<8)|col; + if (dy == 0 && drawlinepat == 0xffffffff) + { + i = ((int)col<<24)|((int)col<<16)|((int)col<<8)|col; clearbufbyte((void *)p, dx, i); - } else + } + else for (i=dx;i>0;i--) { if (drawlinepat & pow2long[(patc++)&31]) drawpixel((char *)p, col); d += dy; - if (d >= dx) { d -= dx; p += pinc; } + if (d >= dx) { d -= dx; p += pinc; } p++; } enddrawing(); //}}} @@ -10476,16 +10597,16 @@ void drawline16(long x1, long y1, long x2, long y2, char col) if (drawlinepat & pow2long[(patc++)&31]) drawpixel((char *)p, col); d += dx; - if (d >= dy) { d -= dy; p += pinc; } + if (d >= dy) { d -= dy; p += pinc; } p += bytesperline; } enddrawing(); //}}} } -void drawcircle16(long x1, long y1, long r, char col) +void drawcircle16(int x1, int y1, int r, char col) { #if 1 - long p, xp, yp, xpbpl, ypbpl, d, de, dse, patc=0; + int p, xp, yp, xpbpl, ypbpl, d, de, dse, patc=0; if (r < 0) r = -r; if (x1+r < 0 || x1-r >= xres) return; @@ -10512,24 +10633,29 @@ void drawcircle16(long x1, long y1, long r, char col) begindrawing(); p = (y1*bytesperline)+x1+frameplace; - if (drawlinepat & pow2long[(patc++)&31]) { - if ((unsigned long)y1 < (unsigned long)ydim16 && (unsigned long)(x1+r) < (unsigned long)xres ) + if (drawlinepat & pow2long[(patc++)&31]) + { + if ((unsigned int)y1 < (unsigned int)ydim16 && (unsigned int)(x1+r) < (unsigned int)xres) drawpixel((char *)(p+r), col); // a - if ((unsigned long)x1 < (unsigned long)xres && (unsigned long)(y1+r) < (unsigned long)ydim16) + if ((unsigned int)x1 < (unsigned int)xres && (unsigned int)(y1+r) < (unsigned int)ydim16) drawpixel((char *)(p+(r*bytesperline)), col); // b - if ((unsigned long)y1 < (unsigned long)ydim16 && (unsigned long)(x1-r) < (unsigned long)xres ) + if ((unsigned int)y1 < (unsigned int)ydim16 && (unsigned int)(x1-r) < (unsigned int)xres) drawpixel((char *)(p-r), col); // c - if ((unsigned long)x1 < (unsigned long)xres && (unsigned long)(y1-r) < (unsigned long)ydim16) + if ((unsigned int)x1 < (unsigned int)xres && (unsigned int)(y1-r) < (unsigned int)ydim16) drawpixel((char *)(p-(r*bytesperline)), col); // d } - while (yp > xp) { - if (d < 0) { + while (yp > xp) + { + if (d < 0) + { d += de; de += 2; dse += 2; xp++; - } else { + } + else + { d += dse; de += 2; dse += 4; @@ -10539,34 +10665,36 @@ void drawcircle16(long x1, long y1, long r, char col) ypbpl = yp*bytesperline; xpbpl = xp*bytesperline; - if (drawlinepat & pow2long[(patc++)&31]) { - if ((unsigned long)(x1+yp) < (unsigned long)xres && (unsigned long)(y1+xp) < (unsigned long)ydim16) + if (drawlinepat & pow2long[(patc++)&31]) + { + if ((unsigned int)(x1+yp) < (unsigned int)xres && (unsigned int)(y1+xp) < (unsigned int)ydim16) drawpixel((char *)(p+yp+xpbpl), col); // 1 - if ((unsigned long)(x1+xp) < (unsigned long)xres && (unsigned long)(y1+yp) < (unsigned long)ydim16) + if ((unsigned int)(x1+xp) < (unsigned int)xres && (unsigned int)(y1+yp) < (unsigned int)ydim16) drawpixel((char *)(p+xp+ypbpl), col); // 2 - if ((unsigned long)(x1-xp) < (unsigned long)xres && (unsigned long)(y1+yp) < (unsigned long)ydim16) + if ((unsigned int)(x1-xp) < (unsigned int)xres && (unsigned int)(y1+yp) < (unsigned int)ydim16) drawpixel((char *)(p-xp+ypbpl), col); // 3 - if ((unsigned long)(x1-yp) < (unsigned long)xres && (unsigned long)(y1+xp) < (unsigned long)ydim16) + if ((unsigned int)(x1-yp) < (unsigned int)xres && (unsigned int)(y1+xp) < (unsigned int)ydim16) drawpixel((char *)(p-yp+xpbpl), col); // 4 - if ((unsigned long)(x1-yp) < (unsigned long)xres && (unsigned long)(y1-xp) < (unsigned long)ydim16) + if ((unsigned int)(x1-yp) < (unsigned int)xres && (unsigned int)(y1-xp) < (unsigned int)ydim16) drawpixel((char *)(p-yp-xpbpl), col); // 5 - if ((unsigned long)(x1-xp) < (unsigned long)xres && (unsigned long)(y1-yp) < (unsigned long)ydim16) + if ((unsigned int)(x1-xp) < (unsigned int)xres && (unsigned int)(y1-yp) < (unsigned int)ydim16) drawpixel((char *)(p-xp-ypbpl), col); // 6 - if ((unsigned long)(x1+xp) < (unsigned long)xres && (unsigned long)(y1-yp) < (unsigned long)ydim16) + if ((unsigned int)(x1+xp) < (unsigned int)xres && (unsigned int)(y1-yp) < (unsigned int)ydim16) drawpixel((char *)(p+xp-ypbpl), col); // 7 - if ((unsigned long)(x1+yp) < (unsigned long)xres && (unsigned long)(y1-xp) < (unsigned long)ydim16) + if ((unsigned int)(x1+yp) < (unsigned int)xres && (unsigned int)(y1-xp) < (unsigned int)ydim16) drawpixel((char *)(p+yp-xpbpl), col); // 8 } } enddrawing(); #else // JonoF's rough approximation of a circle - long l,spx,spy,lpx,lpy,px,py; + int l,spx,spy,lpx,lpy,px,py; spx = lpx = x1+mulscale14(r,sintable[0]); spy = lpy = y1+mulscale14(r,sintable[512]); - for (l=64;l<2048;l+=64) { + for (l=64;l<2048;l+=64) + { px = x1+mulscale14(r,sintable[l]); py = y1+mulscale14(r,sintable[(l+512)&2047]); @@ -10588,7 +10716,8 @@ void qsetmode640350(void) { if (qsetmode != 350) { - if (setvideomode(640, 350, 8, fullscreen) < 0) { + if (setvideomode(640, 350, 8, fullscreen) < 0) + { //fprintf(stderr, "Couldn't set 640x350 video mode for some reason.\n"); return; } @@ -10618,7 +10747,8 @@ void qsetmode640480(void) { if (qsetmode != 480) { - if (setvideomode(640, 480, 8, fullscreen) < 0) { + if (setvideomode(640, 480, 8, fullscreen) < 0) + { //fprintf(stderr, "Couldn't set 640x480 video mode for some reason.\n"); return; } @@ -10645,12 +10775,13 @@ void qsetmode640480(void) // // qsetmodeany // -void qsetmodeany(long daxdim, long daydim) +void qsetmodeany(int daxdim, int daydim) { if (daxdim < 640) daxdim = 640; if (daydim < 480) daydim = 480; - if (qsetmode != ((daxdim<<16)|(daydim&0xffff))) { + if (qsetmode != ((daxdim<<16)|(daydim&0xffff))) + { if (setvideomode(daxdim, daydim, 8, fullscreen) < 0) return; @@ -10682,7 +10813,8 @@ void clear2dscreen(void) begindrawing(); //{{{ if (qsetmode == 350) clearsz = 350; - else { + else + { if (ydim16 <= yres-STATUS2DSIZ) clearsz = yres - STATUS2DSIZ; else clearsz = yres; } @@ -10694,9 +10826,9 @@ void clear2dscreen(void) // // draw2dgrid // -void draw2dgrid(long posxe, long posye, short ange, long zoome, short gride) +void draw2dgrid(int posxe, int posye, short ange, int zoome, short gride) { - long i, xp1, yp1, xp2=0, yp2, tempy; + int i, xp1, yp1, xp2=0, yp2, tempy; if (gride > 0) { @@ -10756,10 +10888,10 @@ void draw2dgrid(long posxe, long posye, short ange, long zoome, short gride) char spritecol2d[MAXTILES][2]; -void draw2dscreen(long posxe, long posye, short ange, long zoome, short gride) +void draw2dscreen(int posxe, int posye, short ange, int zoome, short gride) { walltype *wal; - long i, j, k, xp1, yp1, xp2, yp2, tempy, templong; + int i, j, k, xp1, yp1, xp2, yp2, tempy, tempint; char col, mask; if (qsetmode == 200) return; @@ -10850,7 +10982,7 @@ void draw2dscreen(long posxe, long posye, short ange, long zoome, short gride) } } - templong = ((midydim16+yp1)*bytesperline)+(halfxdim16+xp1)+frameplace; + tempint = ((midydim16+yp1)*bytesperline)+(halfxdim16+xp1)+frameplace; drawline16(halfxdim16+xp1-pointsize,midydim16+yp1+pointsize,halfxdim16+xp1+pointsize,midydim16+yp1+pointsize,col); drawline16(halfxdim16+xp1+pointsize,midydim16+yp1+pointsize,halfxdim16+xp1+pointsize,midydim16+yp1-pointsize,col); @@ -10877,7 +11009,8 @@ void draw2dscreen(long posxe, long posye, short ange, long zoome, short gride) } if (editstatus == 1) { - if ((pointhighlight-16384) > 0 && (j+16384 == pointhighlight || ((sprite[j].x == sprite[pointhighlight-16384].x) && (sprite[j].y == sprite[pointhighlight-16384].y)))) { + if ((pointhighlight-16384) > 0 && (j+16384 == pointhighlight || ((sprite[j].x == sprite[pointhighlight-16384].x) && (sprite[j].y == sprite[pointhighlight-16384].y)))) + { if (totalclock & 32) col += (2<<2); } else if ((highlightcnt > 0) && (editstatus == 1)) @@ -10892,29 +11025,29 @@ void draw2dscreen(long posxe, long posye, short ange, long zoome, short gride) if (((halfxdim16+xp1) >= 4) && ((halfxdim16+xp1) <= xdim-6)) if (((midydim16+yp1) >= 4) && ((midydim16+yp1) <= ydim16-6)) { - long temp; - templong = ((midydim16+yp1)*bytesperline)+(halfxdim16+xp1)+frameplace; + int temp; + tempint = ((midydim16+yp1)*bytesperline)+(halfxdim16+xp1)+frameplace; for (temp=0;temp<2;temp++) { - drawpixel((char *)(templong+3+(bytesperline*temp)), col); - drawpixel((char *)(templong-3-(bytesperline*temp)), col); - drawpixel((char *)(templong-3+(bytesperline*temp)), col); - drawpixel((char *)(templong+3-(bytesperline*temp)), col); + drawpixel((char *)(tempint+3+(bytesperline*temp)), col); + drawpixel((char *)(tempint-3-(bytesperline*temp)), col); + drawpixel((char *)(tempint-3+(bytesperline*temp)), col); + drawpixel((char *)(tempint+3-(bytesperline*temp)), col); } - drawpixel((char *)(templong+2+(bytesperline*2)), col); - drawpixel((char *)(templong-2-(bytesperline*2)), col); - drawpixel((char *)(templong-2+(bytesperline*2)), col); - drawpixel((char *)(templong+2-(bytesperline*2)), col); + drawpixel((char *)(tempint+2+(bytesperline*2)), col); + drawpixel((char *)(tempint-2-(bytesperline*2)), col); + drawpixel((char *)(tempint-2+(bytesperline*2)), col); + drawpixel((char *)(tempint+2-(bytesperline*2)), col); for (temp=0;temp<2;temp++) { - drawpixel((char *)(templong+temp+(bytesperline*3)), col); - drawpixel((char *)(templong-temp-(bytesperline*3)), col); - drawpixel((char *)(templong-temp+(bytesperline*3)), col); - drawpixel((char *)(templong+temp-(bytesperline*3)), col); + drawpixel((char *)(tempint+temp+(bytesperline*3)), col); + drawpixel((char *)(tempint-temp-(bytesperline*3)), col); + drawpixel((char *)(tempint-temp+(bytesperline*3)), col); + drawpixel((char *)(tempint+temp-(bytesperline*3)), col); } @@ -10942,13 +11075,14 @@ void draw2dscreen(long posxe, long posye, short ange, long zoome, short gride) } - if ((sprite[j].cstat&32) > 0) { - long fx = mulscale6(tilesizx[sprite[j].picnum], sprite[j].xrepeat); - long fy = mulscale6(tilesizy[sprite[j].picnum], sprite[j].yrepeat); - long co[4][2], ii; - long sinang = sintable[(sprite[j].ang+512+1024)&2047]; - long cosang = sintable[(sprite[j].ang+1024)&2047]; - long r,s; + if ((sprite[j].cstat&32) > 0) + { + int fx = mulscale6(tilesizx[sprite[j].picnum], sprite[j].xrepeat); + int fy = mulscale6(tilesizy[sprite[j].picnum], sprite[j].yrepeat); + int co[4][2], ii; + int sinang = sintable[(sprite[j].ang+512+1024)&2047]; + int cosang = sintable[(sprite[j].ang+1024)&2047]; + int r,s; fx = mulscale10(fx,zoome) >> 1; fy = mulscale10(fy,zoome) >> 1; @@ -10962,7 +11096,8 @@ void draw2dscreen(long posxe, long posye, short ange, long zoome, short gride) co[3][0] = -fx; co[3][1] = fy; - for (ii=0;ii<4;ii++) { + for (ii=0;ii<4;ii++) + { r = mulscale14(cosang,co[ii][0]) - mulscale14(sinang,co[ii][1]); s = mulscale14(sinang,co[ii][0]) + mulscale14(cosang,co[ii][1]); co[ii][0] = r; @@ -10995,7 +11130,7 @@ void draw2dscreen(long posxe, long posye, short ange, long zoome, short gride) else if ((sprite[j].cstat&16) > 0) { - long fx = mulscale6(tilesizx[sprite[j].picnum], sprite[j].xrepeat); + int fx = mulscale6(tilesizx[sprite[j].picnum], sprite[j].xrepeat); xp2 = mulscale11(sintable[(sprite[j].ang+2560)&2047],zoome) / 6144; yp2 = mulscale11(sintable[(sprite[j].ang+2048)&2047],zoome) / 6144; @@ -11060,7 +11195,7 @@ void draw2dscreen(long posxe, long posye, short ange, long zoome, short gride) else if ((sprite[j].cstat&16) > 0) { - long fx = mulscale6(tilesizx[sprite[j].picnum], sprite[j].xrepeat); + int fx = mulscale6(tilesizx[sprite[j].picnum], sprite[j].xrepeat); xp2 = mulscale11(sintable[(sprite[j].ang+2560)&2047],zoome) / 6144; yp2 = mulscale11(sintable[(sprite[j].ang+2048)&2047],zoome) / 6144; @@ -11079,12 +11214,12 @@ void draw2dscreen(long posxe, long posye, short ange, long zoome, short gride) else if ((sprite[j].cstat&32) > 0) { - long fx = mulscale6(tilesizx[sprite[j].picnum], sprite[j].xrepeat); - long fy = mulscale6(tilesizy[sprite[j].picnum], sprite[j].yrepeat); - long co[4][2], ii; - long sinang = sintable[(sprite[j].ang+512+1024)&2047]; - long cosang = sintable[(sprite[j].ang+1024)&2047]; - long r,s; + int fx = mulscale6(tilesizx[sprite[j].picnum], sprite[j].xrepeat); + int fy = mulscale6(tilesizy[sprite[j].picnum], sprite[j].yrepeat); + int co[4][2], ii; + int sinang = sintable[(sprite[j].ang+512+1024)&2047]; + int cosang = sintable[(sprite[j].ang+1024)&2047]; + int r,s; fx = mulscale10(fx,zoome) >> 1; fy = mulscale10(fy,zoome) >> 1; @@ -11098,7 +11233,8 @@ void draw2dscreen(long posxe, long posye, short ange, long zoome, short gride) co[3][0] = -fx; co[3][1] = fy; - for (ii=0;ii<4;ii++) { + for (ii=0;ii<4;ii++) + { r = mulscale14(cosang,co[ii][0]) - mulscale14(sinang,co[ii][1]); s = mulscale14(sinang,co[ii][0]) + mulscale14(cosang,co[ii][1]); co[ii][0] = r; @@ -11106,7 +11242,8 @@ void draw2dscreen(long posxe, long posye, short ange, long zoome, short gride) } drawlinepat = 0xcfcfcfcf; - for (ii=0;ii<4;ii++) { + for (ii=0;ii<4;ii++) + { drawline16(halfxdim16 + xp1 + co[ii][0], midydim16 + yp1 - co[ii][1], halfxdim16 + xp1 + co[(ii+1)&3][0], midydim16 + yp1 - co[(ii+1)&3][1], col); @@ -11134,9 +11271,9 @@ void draw2dscreen(long posxe, long posye, short ange, long zoome, short gride) // // printext16 // -void printext16(long xpos, long ypos, short col, short backcol, char *name, char fontsize) +void printext16(int xpos, int ypos, short col, short backcol, char *name, char fontsize) { - long stx, i, x, y, charxsiz; + int stx, i, x, y, charxsiz; char *fontptr, *letptr, *ptr; stx = xpos; @@ -11169,9 +11306,9 @@ void printext16(long xpos, long ypos, short col, short backcol, char *name, char // // printext256 // -void printext256(long xpos, long ypos, short col, short backcol, char *name, char fontsize) +void printext256(int xpos, int ypos, short col, short backcol, char *name, char fontsize) { - long stx, i, x, y, charxsiz; + int stx, i, x, y, charxsiz; char *fontptr, *letptr, *ptr; stx = xpos; @@ -11182,15 +11319,19 @@ void printext256(long xpos, long ypos, short col, short backcol, char *name, cha #if defined(POLYMOST) && defined(USE_OPENGL) if (!polymost_printext256(xpos,ypos,col,backcol,name,fontsize)) return; - if (rendmode >= 3 && qsetmode == 200) { - long xx, yy; + if (rendmode >= 3 && qsetmode == 200) + { + int xx, yy; int lc=-1; palette_t p,b; - if (gammabrightness) { + if (gammabrightness) + { p = curpalette[col]; b = curpalette[backcol]; - } else { + } + else + { p.r = britable[curbrightness][ curpalette[col].r ]; p.g = britable[curbrightness][ curpalette[col].g ]; p.b = britable[curbrightness][ curpalette[col].b ]; @@ -11205,18 +11346,24 @@ void printext256(long xpos, long ypos, short col, short backcol, char *name, cha bglBegin(GL_POINTS); - for (i=0;name[i];i++) { + for (i=0;name[i];i++) + { letptr = &fontptr[name[i]<<3]; xx = stx-fontsize; yy = ypos+7 + 2; //+1 is hack! - for (y=7;y>=0;y--) { - for (x=charxsiz-1;x>=0;x--) { - if (letptr[y]&pow2char[7-fontsize-x]) { + for (y=7;y>=0;y--) + { + for (x=charxsiz-1;x>=0;x--) + { + if (letptr[y]&pow2char[7-fontsize-x]) + { if (lc!=col) bglColor4ub(p.r,p.g,p.b,255); lc = col; bglVertex2i(xx+x,yy); - } else if (backcol >= 0) { + } + else if (backcol >= 0) + { if (lc!=backcol) bglColor4ub(b.r,b.g,b.b,255); lc = backcol; @@ -11260,15 +11407,16 @@ void printext256(long xpos, long ypos, short col, short backcol, char *name, cha // // screencapture // -long screencapture_tga(char *filename, char inverseit) +int screencapture_tga(char *filename, char inverseit) { - long i,j; + int i,j; char *ptr, head[18] = { 0,1,1,0,0,0,1,24,0,0,0,0,0/*wlo*/,0/*whi*/,0/*hlo*/,0/*hhi*/,8,0 }; //char palette[4*256]; char *fn = Bstrdup(filename), *inversebuf, c; BFILE *fil; - do { // JBF 2004022: So we don't overwrite existing screenshots + do // JBF 2004022: So we don't overwrite existing screenshots + { if (capturecount > 9999) return -1; i = Bstrrchr(fn,'.')-fn-4; @@ -11284,15 +11432,18 @@ long screencapture_tga(char *filename, char inverseit) if ((fil = Bfopen(fn,"rb")) == NULL) break; Bfclose(fil); capturecount++; - } while (1); + } + while (1); fil = Bfopen(fn,"wb"); - if (fil == NULL) { + if (fil == NULL) + { Bfree(fn); return -1; } #if defined(POLYMOST) && defined(USE_OPENGL) - if (rendmode >= 3 && qsetmode == 200) { + if (rendmode >= 3 && qsetmode == 200) + { head[1] = 0; // no colourmap head[2] = 2; // uncompressed truecolour head[3] = 0; // (low) first colourmap index @@ -11316,10 +11467,12 @@ long screencapture_tga(char *filename, char inverseit) // palette first #if defined(POLYMOST) && defined(USE_OPENGL) - if (rendmode < 3 || (rendmode >= 3 && qsetmode != 200)) { + if (rendmode < 3 || (rendmode >= 3 && qsetmode != 200)) + { #endif //getpalette(0,256,palette); - for (i=0; i<256; i++) { + for (i=0; i<256; i++) + { Bfputc(curpalettefaded[i].b, fil); // b Bfputc(curpalettefaded[i].g, fil); // g Bfputc(curpalettefaded[i].r, fil); // r @@ -11329,25 +11482,33 @@ long screencapture_tga(char *filename, char inverseit) #endif // targa renders bottom to top, from left to right - if (inverseit && qsetmode != 200) { + if (inverseit && qsetmode != 200) + { inversebuf = (char *)kmalloc(bytesperline); - if (inversebuf) { - for (i=ydim-1; i>=0; i--) { + if (inversebuf) + { + for (i=ydim-1; i>=0; i--) + { copybuf(ptr+i*bytesperline, inversebuf, xdim >> 2); - for (j=0; j < (bytesperline>>2); j++) ((long *)inversebuf)[j] ^= 0x0f0f0f0fL; + for (j=0; j < (bytesperline>>2); j++)((int *)inversebuf)[j] ^= 0x0f0f0f0fL; Bfwrite(inversebuf, xdim, 1, fil); } kfree(inversebuf); } - } else { + } + else + { #if defined(POLYMOST) && defined(USE_OPENGL) - if (rendmode >= 3 && qsetmode == 200) { + if (rendmode >= 3 && qsetmode == 200) + { // 24bit inversebuf = (char *)kmalloc(xdim*ydim*3); - if (inversebuf) { + if (inversebuf) + { bglReadPixels(0,0,xdim,ydim,GL_RGB,GL_UNSIGNED_BYTE,inversebuf); j = xdim*ydim*3; - for (i=0; i=0; i--) Bfwrite(ptr+i*bytesperline, xdim, 1, fil); @@ -11377,17 +11540,20 @@ long screencapture_tga(char *filename, char inverseit) static int writepcxbyte(char colour, unsigned char count, BFILE *fp) { if (!count) return 0; - if (count == 1 && (colour & 0xc0) != 0xc0) { + if (count == 1 && (colour & 0xc0) != 0xc0) + { Bfputc(colour, fp); return 1; - } else { + } + else + { Bfputc(0xc0 | count, fp); Bfputc(colour, fp); return 2; } } -static void writepcxline(char *buf, long bytes, long step, BFILE *fp) +static void writepcxline(char *buf, int bytes, int step, BFILE *fp) { char ths, last; int srcIndex, i; @@ -11396,16 +11562,21 @@ static void writepcxline(char *buf, long bytes, long step, BFILE *fp) runCount = 1; last = *buf; - for (srcIndex=1; srcIndex 9999) return -1; i = Bstrrchr(fn,'.')-fn-4; @@ -11441,9 +11613,11 @@ long screencapture_pcx(char *filename, char inverseit) if ((fil = Bfopen(fn,"rb")) == NULL) break; Bfclose(fil); capturecount++; - } while (1); + } + while (1); fil = Bfopen(fn,"wb"); - if (fil == NULL) { + if (fil == NULL) + { Bfree(fn); return -1; } @@ -11459,7 +11633,8 @@ long screencapture_pcx(char *filename, char inverseit) head[68] = 1; #if defined(POLYMOST) && defined(USE_OPENGL) - if (rendmode >= 3 && qsetmode == 200) { + if (rendmode >= 3 && qsetmode == 200) + { head[65] = 3; // 24-bit } #endif @@ -11480,31 +11655,41 @@ long screencapture_pcx(char *filename, char inverseit) ptr = (char *)frameplace; // targa renders bottom to top, from left to right - if (inverseit && qsetmode != 200) { + if (inverseit && qsetmode != 200) + { inversebuf = (char *)kmalloc(bytesperline); - if (inversebuf) { - for (i=0; i> 2); - for (j=0; j < (bytesperline>>2); j++) ((long *)inversebuf)[j] ^= 0x0f0f0f0fL; + for (j=0; j < (bytesperline>>2); j++)((int *)inversebuf)[j] ^= 0x0f0f0f0fL; writepcxline(inversebuf, xdim, 1, fil); } kfree(inversebuf); } - } else { + } + else + { #if defined(POLYMOST) && defined(USE_OPENGL) - if (rendmode >= 3 && qsetmode == 200) { + if (rendmode >= 3 && qsetmode == 200) + { // 24bit inversebuf = (char *)kmalloc(xdim*ydim*3); - if (inversebuf) { + if (inversebuf) + { bglReadPixels(0,0,xdim,ydim,GL_RGB,GL_UNSIGNED_BYTE,inversebuf); - for (i=ydim-1; i>=0; i--) { + for (i=ydim-1; i>=0; i--) + { writepcxline(inversebuf+i*xdim*3, xdim, 3, fil); writepcxline(inversebuf+i*xdim*3+1, xdim, 3, fil); writepcxline(inversebuf+i*xdim*3+2, xdim, 3, fil); } kfree(inversebuf); } - } else { + } + else + { #endif for (i=0; i= 3 && qsetmode != 200)) { + if (rendmode < 3 || (rendmode >= 3 && qsetmode != 200)) + { #endif //getpalette(0,256,palette); Bfputc(12,fil); - for (i=0; i<256; i++) { + for (i=0; i<256; i++) + { Bfputc(curpalettefaded[i].r, fil); // b Bfputc(curpalettefaded[i].g, fil); // g Bfputc(curpalettefaded[i].b, fil); // r @@ -11537,7 +11724,7 @@ long screencapture_pcx(char *filename, char inverseit) return(0); } -long screencapture(char *filename, char inverseit) +int screencapture(char *filename, char inverseit) { if (captureformat == 0) return screencapture_tga(filename,inverseit); else return screencapture_pcx(filename,inverseit); @@ -11553,10 +11740,13 @@ int setrendermode(int renderer) #ifdef POLYMOST int method; - if (bpp == 8) { + if (bpp == 8) + { if (renderer < 0) renderer = 0; else if (renderer > 2) renderer = 2; - } else { + } + else + { if (renderer < 3) renderer = 3; else if (renderer > 4) renderer = 4; } @@ -11586,7 +11776,7 @@ int getrendermode(void) // // setrollangle // -void setrollangle(long rolla) +void setrollangle(int rolla) { #ifdef POLYMOST if (rolla == 0) gtang = 0.0; @@ -11609,7 +11799,7 @@ void setrollangle(long rolla) // bit 7: ignored (67% translucence, using clamping) // clamping is for sprites, repeating is for walls // -void invalidatetile(short tilenume, long pal, long how) +void invalidatetile(short tilenume, int pal, int how) { #if defined(POLYMOST) && defined(USE_OPENGL) int numpal, firstpal, np; @@ -11617,18 +11807,23 @@ void invalidatetile(short tilenume, long pal, long how) if (rendmode < 3) return; - if (pal < 0) { + if (pal < 0) + { numpal = MAXPALOOKUPS; firstpal = 0; - } else { + } + else + { numpal = 1; firstpal = pal % MAXPALOOKUPS; } - for (hp = 0; hp < 8; hp+=4) { + for (hp = 0; hp < 8; hp+=4) + { if (!(how & pow2long[hp])) continue; - for (np = firstpal; np < firstpal+numpal; np++) { + for (np = firstpal; np < firstpal+numpal; np++) + { gltexinvalidate(tilenume, np, hp); } } @@ -11645,7 +11840,8 @@ void setpolymost2dview(void) #if defined(POLYMOST) && defined(USE_OPENGL) if (rendmode < 3) return; - if (gloy1 != -1) { + if (gloy1 != -1) + { bglViewport(0,0,xres,yres); bglMatrixMode(GL_PROJECTION); bglLoadIdentity(); diff --git a/polymer/build/src/glbuild.c b/polymer/build/src/glbuild.c index 732f2fd43..b8d3a5722 100644 --- a/polymer/build/src/glbuild.c +++ b/polymer/build/src/glbuild.c @@ -15,90 +15,90 @@ #endif #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 * 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); // 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 * 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 * 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); // Lighting -void (APIENTRY * bglShadeModel)( GLenum mode ); +void (APIENTRY * bglShadeModel)(GLenum mode); // Raster funcs -void (APIENTRY * bglReadPixels)( GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels ); +void (APIENTRY * bglReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); // 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 * 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 * 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 * 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); @@ -128,46 +128,46 @@ 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 * 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); - -// 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 * bglMapBufferARB)(GLenum target, GLenum access); -GLboolean (APIENTRY * bglUnmapBufferARB)(GLenum target); +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 * bglMapBufferARB)(GLenum target, GLenum access); +GLboolean(APIENTRY * bglUnmapBufferARB)(GLenum target); // 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 * bgluProject)(GLdouble objX, GLdouble objY, GLdouble objZ, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble* winX, GLdouble* winY, GLdouble* winZ); #ifdef RENDERTYPEWIN // Windows -HGLRC (WINAPI * bwglCreateContext)(HDC); +HGLRC(WINAPI * bwglCreateContext)(HDC); BOOL (WINAPI * bwglDeleteContext)(HGLRC); -PROC (WINAPI * bwglGetProcAddress)(LPCSTR); +PROC(WINAPI * bwglGetProcAddress)(LPCSTR); BOOL (WINAPI * bwglMakeCurrent)(HDC,HGLRC); BOOL (WINAPI * bwglSwapBuffers)(HDC); @@ -196,7 +196,8 @@ static void * getproc_(const char *s, int *err, int fatal, int extension) #else #error Need a dynamic loader for this platform... #endif - if (!t && fatal) { + if (!t && fatal) + { initprintf("Failed to find %s in %s\n", s, gldriver); *err = 1; } @@ -216,7 +217,8 @@ int loadgldriver(const char *driver) if (hGLDLL) return 0; #endif - if (!driver) { + if (!driver) + { #ifdef _WIN32 driver = "OPENGL32.DLL"; #elif defined __APPLE__ @@ -268,9 +270,9 @@ int loadgldriver(const char *driver) bglGetError = GETPROC("glGetError"); bglGetString = GETPROC("glGetString"); bglHint = GETPROC("glHint"); - bglDrawBuffer = GETPROC("glDrawBuffer"); - bglReadBuffer = GETPROC("glDrawBuffer"); - bglScissor = GETPROC("glScissor"); + bglDrawBuffer = GETPROC("glDrawBuffer"); + bglReadBuffer = GETPROC("glDrawBuffer"); + bglScissor = GETPROC("glScissor"); // Depth bglDepthFunc = GETPROC("glDepthFunc"); @@ -350,7 +352,7 @@ int loadgldriver(const char *driver) bglClearStencil = GETPROC("glClearStencil"); bglStencilOp = GETPROC("glStencilOp"); bglStencilFunc = GETPROC("glStencilFunc"); - + loadglextensions(); loadglulibrary(getenv("BUILD_GLULIB")); @@ -382,26 +384,26 @@ int loadglextensions(void) // Frame Buffer Objects bglGenFramebuffersEXT = GETPROCEXTSOFT("glGenFramebuffersEXT"); - bglBindFramebufferEXT = GETPROCEXTSOFT("glBindFramebufferEXT"); - bglFramebufferTexture2DEXT = GETPROCEXTSOFT("glFramebufferTexture2DEXT"); - bglCheckFramebufferStatusEXT = GETPROCEXTSOFT("glCheckFramebufferStatusEXT"); - bglDeleteFramebuffersEXT = GETPROCEXTSOFT("glDeleteFramebuffersEXT"); - - // Vertex Buffer Objects - bglGenBuffersARB = GETPROCEXTSOFT("glGenBuffersARB"); - bglBindBufferARB = GETPROCEXTSOFT("glBindBufferARB"); - bglDeleteBuffersARB = GETPROCEXTSOFT("glDeleteBuffersARB"); + bglBindFramebufferEXT = GETPROCEXTSOFT("glBindFramebufferEXT"); + bglFramebufferTexture2DEXT = GETPROCEXTSOFT("glFramebufferTexture2DEXT"); + bglCheckFramebufferStatusEXT = GETPROCEXTSOFT("glCheckFramebufferStatusEXT"); + bglDeleteFramebuffersEXT = GETPROCEXTSOFT("glDeleteFramebuffersEXT"); + + // Vertex Buffer Objects + bglGenBuffersARB = GETPROCEXTSOFT("glGenBuffersARB"); + bglBindBufferARB = GETPROCEXTSOFT("glBindBufferARB"); + bglDeleteBuffersARB = GETPROCEXTSOFT("glDeleteBuffersARB"); bglBufferDataARB = GETPROCEXTSOFT("glBufferDataARB"); bglMapBufferARB = GETPROCEXTSOFT("glMapBufferARB"); bglUnmapBufferARB = GETPROCEXTSOFT("glUnmapBufferARB"); - + return err; } int unloadgldriver(void) { unloadglulibrary(); - + #ifdef RENDERTYPEWIN if (!hGLDLL) return 0; #endif @@ -433,9 +435,9 @@ int unloadgldriver(void) bglGetError = NULL; bglGetString = NULL; bglHint = NULL; - bglDrawBuffer = NULL; - bglReadBuffer = NULL; - bglScissor = NULL; + bglDrawBuffer = NULL; + bglReadBuffer = NULL; + bglScissor = NULL; // Depth bglDepthFunc = NULL; @@ -529,15 +531,15 @@ int unloadgldriver(void) // Frame Buffer Objects bglGenFramebuffersEXT = NULL; - bglBindFramebufferEXT = NULL; - bglFramebufferTexture2DEXT = NULL; - bglCheckFramebufferStatusEXT = NULL; - bglDeleteFramebuffersEXT = NULL; - - // Vertex Buffer Objects - bglGenBuffersARB = NULL; - bglBindBufferARB = NULL; - bglDeleteBuffersARB = NULL; + bglBindFramebufferEXT = NULL; + bglFramebufferTexture2DEXT = NULL; + bglCheckFramebufferStatusEXT = NULL; + bglDeleteFramebuffersEXT = NULL; + + // Vertex Buffer Objects + bglGenBuffersARB = NULL; + bglBindBufferARB = NULL; + bglDeleteBuffersARB = NULL; bglBufferDataARB = NULL; bglMapBufferARB = NULL; bglUnmapBufferARB = NULL; @@ -566,7 +568,8 @@ static void * glugetproc_(const char *s, int *err, int fatal) #else t = (void*)dlsym(gluhandle,s); #endif - if (!t && fatal) { + if (!t && fatal) + { initprintf("Failed to find %s in %s\n", s, glulibrary); *err = 1; } @@ -584,7 +587,8 @@ int loadglulibrary(const char *driver) if (hGLUDLL) return 0; #endif - if (!driver) { + if (!driver) + { #ifdef _WIN32 driver = "GLU32.DLL"; #elif defined __APPLE__ @@ -657,7 +661,7 @@ int unloadglulibrary(void) bgluErrorString = NULL; bgluProject = NULL; - + return 0; } #endif diff --git a/polymer/build/src/gtkbits.c b/polymer/build/src/gtkbits.c index ec06612d6..4dd89390c 100644 --- a/polymer/build/src/gtkbits.c +++ b/polymer/build/src/gtkbits.c @@ -67,7 +67,8 @@ void gtkbuild_init(int *argc, char ***argv) { #ifndef LINKED_GTK gtkenabled = dynamicgtk_init(); - if (gtkenabled < 0) { + if (gtkenabled < 0) + { gtkenabled = 0; return; } @@ -84,7 +85,8 @@ void gtkbuild_init(int *argc, char ***argv) void gtkbuild_exit(int r) { - if (gtkenabled) { + if (gtkenabled) + { if (appicon) g_object_unref((gpointer)appicon); } #ifndef LINKED_GTK diff --git a/polymer/build/src/hightile.c b/polymer/build/src/hightile.c index 2757a4689..d6a4fa27c 100644 --- a/polymer/build/src/hightile.c +++ b/polymer/build/src/hightile.c @@ -11,7 +11,7 @@ palette_t hictinting[MAXPALOOKUPS]; //moved into polymost.h /*struct hicskybox_t { - long ignore; + int ignore; char *face[6]; }; @@ -28,19 +28,25 @@ static char hicfirstinit = 0; // // find the index into hicreplc[] which contains the replacement tile particulars // -static hicreplctyp * hicfindsubst(long picnum, long palnum, long skybox) +static hicreplctyp * hicfindsubst(int picnum, int palnum, int skybox) { hicreplctyp *hr; if (!hicfirstinit) return NULL; - if ((unsigned long)picnum >= (unsigned long)MAXTILES) return NULL; + if ((unsigned int)picnum >= (unsigned int)MAXTILES) return NULL; - do { - for (hr = hicreplc[picnum]; hr; hr = hr->next) { - if (hr->palnum == palnum) { - if (skybox) { + do + { + for (hr = hicreplc[picnum]; hr; hr = hr->next) + { + if (hr->palnum == palnum) + { + if (skybox) + { if (hr->skybox && !hr->skybox->ignore) return hr; - } else { + } + else + { if (!hr->ignore) return hr; } } @@ -48,7 +54,8 @@ static hicreplctyp * hicfindsubst(long picnum, long palnum, long skybox) if (!palnum || palnum >= (MAXPALOOKUPS - RESERVEDPALS)) break; palnum = 0; - } while (1); + } + while (1); return NULL; // no replacement found } @@ -60,22 +67,28 @@ static hicreplctyp * hicfindsubst(long picnum, long palnum, long skybox) // void hicinit(void) { - long i,j; + int i,j; hicreplctyp *hr, *next; - for (i=0;i=0;i--) { - for (hr=hicreplc[i]; hr; ) { + for (i=MAXTILES-1;i>=0;i--) + { + for (hr=hicreplc[i]; hr;) + { next = hr->next; - if (hr->skybox) { - for (j=5;j>=0;j--) { - if (hr->skybox->face[j]) { + if (hr->skybox) + { + for (j=5;j>=0;j--) + { + if (hr->skybox->face[j]) + { free(hr->skybox->face[j]); } } @@ -99,9 +112,9 @@ void hicinit(void) // palette shifts on true-colour textures and only true-colour textures. // effect bitset: 1 = greyscale, 2 = invert // -void hicsetpalettetint(long palnum, unsigned char r, unsigned char g, unsigned char b, unsigned char effect) +void hicsetpalettetint(int palnum, unsigned char r, unsigned char g, unsigned char b, unsigned char effect) { - if ((unsigned long)palnum >= (unsigned long)MAXPALOOKUPS) return; + if ((unsigned int)palnum >= (unsigned int)MAXPALOOKUPS) return; if (!hicfirstinit) hicinit(); hictinting[palnum].r = r; @@ -115,31 +128,35 @@ void hicsetpalettetint(long palnum, unsigned char r, unsigned char g, unsigned c // hicsetsubsttex(picnum,pal,filen,alphacut) // Specifies a replacement graphic file for an ART tile. // -int hicsetsubsttex(long picnum, long palnum, char *filen, float alphacut, float xscale, float yscale, char flags) +int hicsetsubsttex(int picnum, int palnum, char *filen, float alphacut, float xscale, float yscale, char flags) { hicreplctyp *hr, *hrn; - if ((unsigned long)picnum >= (unsigned long)MAXTILES) return -1; - if ((unsigned long)palnum >= (unsigned long)MAXPALOOKUPS) return -1; + if ((unsigned int)picnum >= (unsigned int)MAXTILES) return -1; + if ((unsigned int)palnum >= (unsigned int)MAXPALOOKUPS) return -1; if (!hicfirstinit) hicinit(); - for (hr = hicreplc[picnum]; hr; hr = hr->next) { + for (hr = hicreplc[picnum]; hr; hr = hr->next) + { if (hr->palnum == palnum) break; } - if (!hr) { + if (!hr) + { // no replacement yet defined hrn = (hicreplctyp *)calloc(1,sizeof(hicreplctyp)); if (!hrn) return -1; hrn->palnum = palnum; - } else hrn = hr; + } + else hrn = hr; // store into hicreplc the details for this replacement if (hrn->filename) free(hrn->filename); hrn->filename = strdup(filen); - if (!hrn->filename) { + if (!hrn->filename) + { if (hrn->skybox) return -1; // don't free the base structure if there's a skybox defined if (hr == NULL) free(hrn); // not yet a link in the chain return -1; @@ -149,7 +166,8 @@ int hicsetsubsttex(long picnum, long palnum, char *filen, float alphacut, float hrn->xscale = xscale; hrn->yscale = yscale; hrn->flags = flags; - if (hr == NULL) { + if (hr == NULL) + { hrn->next = hicreplc[picnum]; hicreplc[picnum] = hrn; } @@ -164,46 +182,56 @@ int hicsetsubsttex(long picnum, long palnum, char *filen, float alphacut, float // hicsetskybox(picnum,pal,faces[6]) // Specifies a graphic files making up a skybox. // -int hicsetskybox(long picnum, long palnum, char *faces[6]) +int hicsetskybox(int picnum, int palnum, char *faces[6]) { hicreplctyp *hr, *hrn; - long j; + int j; - if ((unsigned long)picnum >= (unsigned long)MAXTILES) return -1; - if ((unsigned long)palnum >= (unsigned long)MAXPALOOKUPS) return -1; + if ((unsigned int)picnum >= (unsigned int)MAXTILES) return -1; + if ((unsigned int)palnum >= (unsigned int)MAXPALOOKUPS) return -1; for (j=5;j>=0;j--) if (!faces[j]) return -1; if (!hicfirstinit) hicinit(); - for (hr = hicreplc[picnum]; hr; hr = hr->next) { + for (hr = hicreplc[picnum]; hr; hr = hr->next) + { if (hr->palnum == palnum) break; } - if (!hr) { + if (!hr) + { // no replacement yet defined hrn = (hicreplctyp *)calloc(1,sizeof(hicreplctyp)); if (!hrn) return -1; hrn->palnum = palnum; - } else hrn = hr; + } + else hrn = hr; - if (!hrn->skybox) { + if (!hrn->skybox) + { hrn->skybox = (struct hicskybox_t *)calloc(1,sizeof(struct hicskybox_t)); - if (!hrn->skybox) { + if (!hrn->skybox) + { if (hr == NULL) free(hrn); // not yet a link in the chain return -1; } - } else { - for (j=5;j>=0;j--) { + } + else + { + for (j=5;j>=0;j--) + { if (hrn->skybox->face[j]) free(hrn->skybox->face[j]); } } // store each face's filename - for (j=0;j<6;j++) { + for (j=0;j<6;j++) + { hrn->skybox->face[j] = strdup(faces[j]); - if (!hrn->skybox->face[j]) { + if (!hrn->skybox->face[j]) + { for (--j; j>=0; --j) // free any previous faces free(hrn->skybox->face[j]); free(hrn->skybox); @@ -213,7 +241,8 @@ int hicsetskybox(long picnum, long palnum, char *faces[6]) } } hrn->skybox->ignore = 0; - if (hr == NULL) { + if (hr == NULL) + { hrn->next = hicreplc[picnum]; hicreplc[picnum] = hrn; } @@ -226,15 +255,16 @@ int hicsetskybox(long picnum, long palnum, char *faces[6]) // hicclearsubst(picnum,pal) // Clears a replacement for an ART tile, including skybox faces. // -int hicclearsubst(long picnum, long palnum) +int hicclearsubst(int picnum, int palnum) { hicreplctyp *hr, *hrn = NULL; - if ((unsigned long)picnum >= (unsigned long)MAXTILES) return -1; - if ((unsigned long)palnum >= (unsigned long)MAXPALOOKUPS) return -1; + if ((unsigned int)picnum >= (unsigned int)MAXTILES) return -1; + if ((unsigned int)palnum >= (unsigned int)MAXPALOOKUPS) return -1; if (!hicfirstinit) return 0; - for (hr = hicreplc[picnum]; hr; hrn = hr, hr = hr->next) { + for (hr = hicreplc[picnum]; hr; hrn = hr, hr = hr->next) + { if (hr->palnum == palnum) break; } @@ -242,7 +272,8 @@ int hicclearsubst(long picnum, long palnum) if (!hr) return 0; if (hr->filename) free(hr->filename); - if (hr->skybox) { + if (hr->skybox) + { int i; for (i=5;i>=0;i--) if (hr->skybox->face[i]) diff --git a/polymer/build/src/kplib.c b/polymer/build/src/kplib.c index 038889a19..1363aaa90 100644 --- a/polymer/build/src/kplib.c +++ b/polymer/build/src/kplib.c @@ -42,24 +42,24 @@ credits. #endif #ifdef BIGENDIAN -static unsigned long LSWAPIB (unsigned long a) { return(((a>>8)&0xff00)+((a&0xff00)<<8)+(a<<24)+(a>>24)); } -static unsigned short SSWAPIB (unsigned short a) { return((a>>8)+(a<<8)); } +static unsigned int LSWAPIB(unsigned int a) { return(((a>>8)&0xff00)+((a&0xff00)<<8)+(a<<24)+(a>>24)); } +static unsigned short SSWAPIB(unsigned short a) { return((a>>8)+(a<<8)); } #define LSWAPIL(a) (a) #define SSWAPIL(a) (a) #else #define LSWAPIB(a) (a) #define SSWAPIB(a) (a) -static unsigned long LSWAPIL (unsigned long a) { return(((a>>8)&0xff00)+((a&0xff00)<<8)+(a<<24)+(a>>24)); } -static unsigned short SSWAPIL (unsigned short a) { return((a>>8)+(a<<8)); } +static unsigned int LSWAPIL(unsigned int a) { return(((a>>8)&0xff00)+((a&0xff00)<<8)+(a<<24)+(a>>24)); } +static unsigned short SSWAPIL(unsigned short a) { return((a>>8)+(a<<8)); } #endif #if !defined(_WIN32) && !defined(__DOS__) #include #include typedef long long __int64; -static __inline long _lrotl (long i, int sh) +static __inline int _lrotl(int i, int sh) { return((i>>(-sh))|(i<>8) + ((a&0xff00)<<8) + (a<<24) + (a>>24)); } -static inline long bitrev (long b, long c) +static inline int bitrev(int b, int c) { - long i, j; + int i, j; for (i=1,j=0,c=(1< 0x8000000) + if (((unsigned int)cpb[0]) > 0x8000000) { cpuid(0x80000001,cpb); i |= (cpb[3]&(1<<31)); @@ -383,23 +383,24 @@ static long getcputype () } static unsigned char fakebuf[8], *nfilptr; -static long nbitpos; -static void suckbitsnextblock () +static int nbitpos; +static void suckbitsnextblock() { - long n; + int n; if (!zipfilmode) { if (!nfilptr) - { //|===|===|crc|lng|typ|===|===| + { + //|===|===|crc|lng|typ|===|===| // \ fakebuf: / // |===|===| //----x O---x O-------- - nbitpos = LSWAPIL(*(long *)&filptr[8]); + nbitpos = LSWAPIL(*(int *)&filptr[8]); nfilptr = (unsigned char *)&filptr[nbitpos+12]; - *(long *)&fakebuf[0] = *(long *)&filptr[0]; //Copy last dword of IDAT chunk - if (*(long *)&filptr[12] == LSWAPIB(0x54414449)) //Copy 1st dword of next IDAT chunk - *(long *)&fakebuf[4] = *(long *)&filptr[16]; + *(int *)&fakebuf[0] = *(int *)&filptr[0]; //Copy last dword of IDAT chunk + if (*(int *)&filptr[12] == LSWAPIB(0x54414449)) //Copy 1st dword of next IDAT chunk + *(int *)&fakebuf[4] = *(int *)&filptr[16]; filptr = &fakebuf[4]; bitpos -= 32; } else @@ -412,7 +413,7 @@ static void suckbitsnextblock () else { //NOTE: should only read bytes inside compsize, not 64K!!! :/ - *(long *)&olinbuf[0] = *(long *)&olinbuf[sizeof(olinbuf)-4]; + *(int *)&olinbuf[0] = *(int *)&olinbuf[sizeof(olinbuf)-4]; n = min((unsigned)(kzfs.compleng-kzfs.comptell),sizeof(olinbuf)-4); fread(&olinbuf[4],n,1,kzfs.fil); kzfs.comptell += n; @@ -420,32 +421,33 @@ static void suckbitsnextblock () } } -static _inline long peekbits (long n) { return((LSWAPIB(*(long *)&filptr[bitpos>>3])>>(bitpos&7))&pow2mask[n]); } -static _inline void suckbits (long n) { bitpos += n; if (bitpos >= 0) suckbitsnextblock(); } -static _inline long getbits (long n) { long i = peekbits(n); suckbits(n); return(i); } +static _inline int peekbits(int n) { return((LSWAPIB(*(int *)&filptr[bitpos>>3])>>(bitpos&7))&pow2mask[n]); } +static _inline void suckbits(int n) { bitpos += n; if (bitpos >= 0) suckbitsnextblock(); } +static _inline int getbits(int n) { int i = peekbits(n); suckbits(n); return(i); } -static long hufgetsym (long *hitab, long *hbmax) +static int hufgetsym(int *hitab, int *hbmax) { - long v, n; + int v, n; v = n = 0; - do { v = (v<<1)+getbits(1)+hbmax[n]-hbmax[n+1]; n++; } while (v >= 0); + do { v = (v<<1)+getbits(1)+hbmax[n]-hbmax[n+1]; n++; } + while (v >= 0); return(hitab[hbmax[n]+v]); } //This did not result in a speed-up on P4-3.6Ghz (02/22/2005) -//static long hufgetsym_skipb (long *hitab, long *hbmax, long n, long addit) +//static int hufgetsym_skipb (int *hitab, int *hbmax, int n, int addit) //{ -// long v; +// int v; // // v = bitrev(getbits(n),n)+addit; // do { v = (v<<1)+getbits(1)+hbmax[n]-hbmax[n+1]; n++; } while (v >= 0); // return(hitab[hbmax[n]+v]); //} -static void qhufgencode (long *hitab, long *hbmax, long *qhval, unsigned char *qhbit, long numbits) +static void qhufgencode(int *hitab, int *hbmax, int *qhval, unsigned char *qhbit, int numbits) { - long i, j, k, n, r; + int i, j, k, n, r; //r is the bit reverse of i. Ex: if: i = 1011100111, r = 1110011101 i = r = 0; @@ -490,9 +492,9 @@ static void qhufgencode (long *hitab, long *hbmax, long *qhval, unsigned char *q //inum : Number of indices //hitab[inum] : Indices from size-ordered list to original symbol //hbmax[0-31] : Highest index (+1) of n-bit symbol -static void hufgencode (long *inbuf, long inum, long *hitab, long *hbmax) +static void hufgencode(int *inbuf, int inum, int *hitab, int *hbmax) { - long i, tbuf[31]; + int i, tbuf[31]; for (i=30;i;i--) tbuf[i] = 0; for (i=inum-1;i>=0;i--) tbuf[inbuf[i]]++; @@ -501,9 +503,9 @@ static void hufgencode (long *inbuf, long inum, long *hitab, long *hbmax) for (i=0;i>i)&15); iyoff = ((0x00402010>>i)&15); if (((ixoff >= xsiz) || (iyoff >= ysiz)) && (intlac >= 2)) { i = -1; intlac--; } - } while (i < 0); + } + while (i < 0); j = ((0x33221100>>i)&15); ixstp = (1<>i)&15); iystp = (1<=0))|(ixstp-1))&i); @@ -550,7 +553,7 @@ static long initpass () //Interlaced images have 7 "passes", non-interlaced have xr0 = ixsiz-xr0; xr1 = ixsiz-xr1; -if (coltype == 4) { xr0 = xr0*2; xr1 = xr1*2; } + if (coltype == 4) { xr0 = xr0*2; xr1 = xr1*2; } else if (coltype == 2) { xr0 = xr0*3-2; xr1 = xr1*3-2; } else if (coltype == 6) { xr0 = xr0*4-2; xr1 = xr1*4-2; } else @@ -572,9 +575,9 @@ if (coltype == 4) { xr0 = xr0*2; xr1 = xr1*2; } return(0); } -static long Paeth (long a, long b, long c) +static int Paeth(int a, int b, int c) { - long pa, pb, pc; + int pa, pb, pc; pa = b-c; pb = a-c; pc = labs(pa+pb); pa = labs(pa); pb = labs(pb); if ((pa <= pb) && (pa <= pc)) return(a); @@ -584,7 +587,7 @@ static long Paeth (long a, long b, long c) #if defined(__WATCOMC__) && !defined(NOASM) //NOTE: cmov now has correctly ordered registers (thx to bug fix in 11.0c!) -long Paeth686 (long, long, long); +int Paeth686(int, int, int); #pragma aux Paeth686 =\ ".686"\ "mov edx, ecx"\ @@ -603,7 +606,7 @@ long Paeth686 (long, long, long); value [ecx] //Note: "cmove eax,?" may be faster than "jne ?:and eax,?" but who cares -void rgbhlineasm (long, long, long, long); +void rgbhlineasm(int, int, int, int); #pragma aux rgbhlineasm =\ "sub ecx, edx"\ "jle short endit"\ @@ -631,7 +634,7 @@ void rgbhlineasm (long, long, long, long); modify exact [eax ecx edi]\ value -void pal8hlineasm (long, long, long, long); +void pal8hlineasm(int, int, int, int); #pragma aux pal8hlineasm =\ "sub ecx, edx"\ "jle short endit"\ @@ -649,7 +652,7 @@ void pal8hlineasm (long, long, long, long); #elif defined(_MSC_VER) && !defined(NOASM) -static _inline long Paeth686 (long a, long b, long c) +static _inline int Paeth686(int a, int b, int c) { _asm { @@ -670,7 +673,7 @@ static _inline long Paeth686 (long a, long b, long c) } } -static _inline void rgbhlineasm (long c, long d, long t, long b) +static _inline void rgbhlineasm(int c, int d, int t, int b) { _asm { @@ -681,32 +684,32 @@ static _inline void rgbhlineasm (long c, long d, long t, long b) sub ecx, edx jle short endit add edx, offset olinbuf - cmp dword ptr trnsrgb, 0 - jz short begit2 - begit: - mov eax, dword ptr [ecx+edx] - or eax, 0xff000000 - cmp eax, dword ptr trnsrgb - jne short skipit - and eax, 0xffffff - skipit: - sub ecx, 3 - mov [edi], eax - lea edi, [edi+ebx] - jnz short begit - jmp short endit - begit2: - mov eax, dword ptr [ecx+edx] - or eax, 0xff000000 - sub ecx, 3 - mov [edi], eax - lea edi, [edi+ebx] - jnz short begit2 - endit: - } + cmp dword ptr trnsrgb, 0 + jz short begit2 +begit: + mov eax, dword ptr [ecx+edx] + or eax, 0xff000000 + cmp eax, dword ptr trnsrgb + jne short skipit + and eax, 0xffffff +skipit: + sub ecx, 3 + mov [edi], eax + lea edi, [edi+ebx] + jnz short begit + jmp short endit +begit2: + mov eax, dword ptr [ecx+edx] + or eax, 0xff000000 + sub ecx, 3 + mov [edi], eax + lea edi, [edi+ebx] + jnz short begit2 +endit: } +} -static _inline void pal8hlineasm (long c, long d, long t, long b) +static _inline void pal8hlineasm(int c, int d, int t, int b) { _asm { @@ -717,36 +720,36 @@ static _inline void pal8hlineasm (long c, long d, long t, long b) sub ecx, edx jle short endit add edx, offset olinbuf - begit: - movzx eax, byte ptr [ecx+edx] - mov eax, dword ptr palcol[eax*4] - sub ecx, 1 - mov [edi], eax - lea edi, [edi+ebx] - jnz short begit - endit: - } +begit: + movzx eax, byte ptr [ecx+edx] + mov eax, dword ptr palcol[eax*4] + sub ecx, 1 + mov [edi], eax + lea edi, [edi+ebx] + jnz short begit +endit: } +} #elif defined(__GNUC__) && defined(__i386__) && !defined(NOASM) -static inline long Paeth686 (long a, long b, long c) +static inline int Paeth686(int a, int b, int c) { - __asm__ __volatile__ ( + __asm__ __volatile__( "movl %%ecx, %%edx\n\tsubl %%eax, %%edx\n\tsubl %%ebx, %%edx\n\t" "leal (abstab10+2048)(,%%edx,4), %%edx\n\t" "movl (%%edx,%%ebx,4), %%esi\n\tmovl (%%edx,%%ecx,4), %%edi\n\t" "cmpl %%esi, %%edi\n\tcmovgel %%esi, %%edi\n\tcmovgel %%ebx, %%ecx\n\t" "cmpl (%%edx,%%eax,4), %%edi\n\tcmovgel %%eax, %%ecx" - : "+c" (c) : "a" (a), "b" (b) : "esi","edi","memory","cc" + : "+c"(c) : "a"(a), "b"(b) : "esi","edi","memory","cc" ); return c; } //Note: "cmove eax,?" may be faster than "jne ?:and eax,?" but who cares -static inline void rgbhlineasm (long c, long d, long t, long b) +static inline void rgbhlineasm(int c, int d, int t, int b) { - __asm__ __volatile__ ( + __asm__ __volatile__( "subl %%edx, %%ecx\n\tjle 3f\n\taddl $olinbuf, %%edx\n\t" "cmpl $0, trnsrgb(,1)\n\tjz 2f\n\t" "0: movl (%%ecx,%%edx,1), %%eax\n\torl $0xff000000, %%eax\n\tcmpl trnsrgb(,1), %%eax\n\t" @@ -756,47 +759,47 @@ static inline void rgbhlineasm (long c, long d, long t, long b) "2: movl (%%ecx,%%edx,1), %%eax\n\torl $0xff000000, %%eax\n\tsubl $3, %%ecx\n\t" "movl %%eax, (%%edi)\n\tleal (%%edi,%%ebx,1), %%edi\n\tjnz 2b\n\t" "3:" - : "+c" (c), "+D" (t) : "d" (d), "b" (b) : "eax","memory","cc" + : "+c"(c), "+D"(t) : "d"(d), "b"(b) : "eax","memory","cc" ); } -static inline void pal8hlineasm (long c, long d, long t, long b) +static inline void pal8hlineasm(int c, int d, int t, int b) { - __asm__ __volatile__ ( + __asm__ __volatile__( "subl %%edx, %%ecx\n\tjle 1f\n\taddl $olinbuf, %%edx\n\t" "0: movzbl (%%ecx,%%edx,1), %%eax\n\tmovl palcol(,%%eax,4), %%eax\n\t" "subl $1, %%ecx\n\tmovl %%eax, (%%edi)\n\tleal (%%edi,%%ebx,1), %%edi\n\tjnz 0b\n\t" "1:" - : "+c" (c), "+D" (t) : "d" (d), "b" (b) : "eax","memory","cc" + : "+c"(c), "+D"(t) : "d"(d), "b"(b) : "eax","memory","cc" ); } #else -static inline long Paeth686 (long a, long b, long c) +static inline int Paeth686(int a, int b, int c) { return(Paeth(a,b,c)); } -static inline void rgbhlineasm (long x, long xr1, long p, long ixstp) +static inline void rgbhlineasm(int x, int xr1, int p, int ixstp) { - long i; + int i; if (!trnsrgb) { - for (;x>xr1;p+=ixstp,x-=3) *(long *)p = (*(long *)&olinbuf[x])|LSWAPIB(0xff000000); + for (;x>xr1;p+=ixstp,x-=3) *(int *)p = (*(int *)&olinbuf[x])|LSWAPIB(0xff000000); return; } for (;x>xr1;p+=ixstp,x-=3) { - i = (*(long *)&olinbuf[x])|LSWAPIB(0xff000000); + i = (*(int *)&olinbuf[x])|LSWAPIB(0xff000000); if (i == trnsrgb) i &= LSWAPIB(0xffffff); - *(long *)p = i; + *(int *)p = i; } } -static inline void pal8hlineasm (long x, long xr1, long p, long ixstp) +static inline void pal8hlineasm(int x, int xr1, int p, int ixstp) { - for (;x>xr1;p+=ixstp,x--) *(long *)p = palcol[olinbuf[x]]; + for (;x>xr1;p+=ixstp,x--) *(int *)p = palcol[olinbuf[x]]; } #endif @@ -809,10 +812,10 @@ static inline void pal8hlineasm (long x, long xr1, long p, long ixstp) // /f3: 3333333... // /f4: 4444444... // /f5: 0142321... -static long filter1st, filterest; -static void putbuf (const unsigned char *buf, long leng) +static int filter1st, filterest; +static void putbuf(const unsigned char *buf, int leng) { - long i, x, p; + int i, x, p; if (filt < 0) { @@ -821,7 +824,8 @@ static void putbuf (const unsigned char *buf, long leng) if (filter1st < 0) filter1st = filt; else filterest |= (1< 0) return; //Draw line! - if ((unsigned long)yplc < (unsigned long)yres) + if ((unsigned int)yplc < (unsigned int)yres) { x = xr0; p = nfplace; switch (coltype) @@ -884,13 +888,13 @@ static void putbuf (const unsigned char *buf, long leng) { #if (PROCESSALPHAHERE == 1) //Enable this code to process alpha right here! - if (olinbuf[x-1] == 255) { *(long *)p = palcol[olinbuf[x]]; continue; } - if (!olinbuf[x-1]) { *(long *)p = bakcol; continue; } + if (olinbuf[x-1] == 255) { *(int *)p = palcol[olinbuf[x]]; continue; } + if (!olinbuf[x-1]) { *(int *)p = bakcol; continue; } //I do >>8, but theoretically should be: /255 *(char *)(p) = *(char *)(p+1) = *(char *)(p+2) = *(char *)(p+3) = - (((((long)olinbuf[x])-bakr)*(long)olinbuf[x-1])>>8) + bakr; + (((((int)olinbuf[x])-bakr)*(int)olinbuf[x-1])>>8) + bakr; #else - *(long *)p = (palcol[olinbuf[x]]&LSWAPIB(0xffffff))|LSWAPIL((long)olinbuf[x-1]); + *(int *)p = (palcol[olinbuf[x]]&LSWAPIB(0xffffff))|LSWAPIL((int)olinbuf[x-1]); #endif } break; @@ -899,14 +903,14 @@ static void putbuf (const unsigned char *buf, long leng) { #if (PROCESSALPHAHERE == 1) //Enable this code to process alpha right here! - if (olinbuf[x-1] == 255) { *(long *)p = *(long *)&olinbuf[x]; continue; } - if (!olinbuf[x-1]) { *(long *)p = bakcol; continue; } + if (olinbuf[x-1] == 255) { *(int *)p = *(int *)&olinbuf[x]; continue; } + if (!olinbuf[x-1]) { *(int *)p = bakcol; continue; } //I do >>8, but theoretically should be: /255 - *(char *)(p ) = (((((long)olinbuf[x ])-bakr)*(long)olinbuf[x-1])>>8) + bakr; - *(char *)(p+1) = (((((long)olinbuf[x+1])-bakg)*(long)olinbuf[x-1])>>8) + bakg; - *(char *)(p+2) = (((((long)olinbuf[x+2])-bakb)*(long)olinbuf[x-1])>>8) + bakb; + *(char *)(p) = (((((int)olinbuf[x ])-bakr)*(int)olinbuf[x-1])>>8) + bakr; + *(char *)(p+1) = (((((int)olinbuf[x+1])-bakg)*(int)olinbuf[x-1])>>8) + bakg; + *(char *)(p+2) = (((((int)olinbuf[x+2])-bakb)*(int)olinbuf[x-1])>>8) + bakb; #else - *(char *)(p ) = olinbuf[x ]; //R + *(char *)(p) = olinbuf[x ]; //R *(char *)(p+1) = olinbuf[x+1]; //G *(char *)(p+2) = olinbuf[x+2]; //B *(char *)(p+3) = olinbuf[x-1]; //A @@ -917,34 +921,35 @@ static void putbuf (const unsigned char *buf, long leng) switch (bitdepth) { case 1: - for (;x>xr1;p+=ixstp,x-- ) *(long *)p = palcol[olinbuf[x>>3]>>(x&7)]; break; + for (;x>xr1;p+=ixstp,x--) *(int *)p = palcol[olinbuf[x>>3]>>(x&7)]; break; case 2: - for (;x>xr1;p+=ixstp,x-=2) *(long *)p = palcol[olinbuf[x>>3]>>(x&6)]; break; + for (;x>xr1;p+=ixstp,x-=2) *(int *)p = palcol[olinbuf[x>>3]>>(x&6)]; break; case 4: - for (;x>xr1;p+=ixstp,x-=4) *(long *)p = palcol[olinbuf[x>>3]>>(x&4)]; break; + for (;x>xr1;p+=ixstp,x-=4) *(int *)p = palcol[olinbuf[x>>3]>>(x&4)]; break; case 8: - pal8hlineasm(x,xr1,p,ixstp); break; //for(;x>xr1;p+=ixstp,x--) *(long *)p = palcol[olinbuf[x]]; break; + pal8hlineasm(x,xr1,p,ixstp); break; //for(;x>xr1;p+=ixstp,x--) *(int *)p = palcol[olinbuf[x]]; break; } break; } nfplace += nbpl; } - *(long *)&opixbuf0[0] = *(long *)&opixbuf1[0] = 0; + *(int *)&opixbuf0[0] = *(int *)&opixbuf1[0] = 0; xplc = xsizbpl; yplc += iystp; - if ((intlac) && (yplc >= globyoffs+ysiz)) { intlac--; initpass(); } + if ((intlac) && (yplc >= globyoffs+ysiz)) { intlac--; initpass(); } if (i < leng) { filt = buf[i++]; if (filter1st < 0) filter1st = filt; else filterest |= (1<=0;i--) palcol[i] = LSWAPIB((LSWAPIL(*(long *)&filptr[i*3])>>8)|0xff000000); + for (i=paleng-1;i>=0;i--) palcol[i] = LSWAPIB((LSWAPIL(*(int *)&filptr[i*3])>>8)|0xff000000); } else if (i == LSWAPIB(0x44474b62)) //bKGD (must be after PLTE and before IDAT) { @@ -1023,16 +1028,16 @@ static long kpngrend (const char *kfilebuf, long kfilength, { case 0: case 4: - bakcol = (((long)filptr[0]<<8)+(long)filptr[1])*255/((1<=0;i--) - palcol[i] &= LSWAPIB((((long)filptr[i])<<24)|0xffffff); + palcol[i] &= LSWAPIB((((int)filptr[i])<<24)|0xffffff); break; default: ; } } - else if (i == LSWAPIB(0x54414449)) { break; } //IDAT + else if (i == LSWAPIB(0x54414449)) { break; } //IDAT - filptr = &filptr[leng+4]; //crc = LSWAPIL(*(long *)&filptr[-4]); + filptr = &filptr[leng+4]; //crc = LSWAPIL(*(int *)&filptr[-4]); } //Initialize this for the getbits() function @@ -1171,7 +1176,7 @@ static long kpngrend (const char *kfilebuf, long kfilength, i = hufgetsym(ibuf0,nbuf0); if (i < 16) { clen[j++] = i; continue; } if (i == 16) - { for (i=getbits(2)+3;i;i--) { clen[j] = clen[j-1]; j++; } } + { for (i=getbits(2)+3;i;i--) { clen[j] = clen[j-1]; j++; } } else { if (i == 17) i = getbits(3)+3; else i = getbits(7)+11; @@ -1197,21 +1202,25 @@ static long kpngrend (const char *kfilebuf, long kfilength, } k = peekbits(LOGQHUFSIZ0); - if (qhufbit0[k]) { i = qhufval0[k]; suckbits((long)qhufbit0[k]); } else i = hufgetsym(ibuf0,nbuf0); + if (qhufbit0[k]) { i = qhufval0[k]; suckbits((int)qhufbit0[k]); } + else i = hufgetsym(ibuf0,nbuf0); //else i = hufgetsym_skipb(ibuf0,nbuf0,LOGQHUFSIZ0,qhuf0v); //hufgetsym_skipb related code - if (i < 256) { slidebuf[(slidew++)&32767] = (char)i; continue; } + if (i < 256) { slidebuf[(slidew++)&32767] = (char)i; continue; } if (i == 256) break; i = getbits(hxbit[i+30-257][0]) + hxbit[i+30-257][1]; k = peekbits(LOGQHUFSIZ1); - if (qhufbit1[k]) { j = qhufval1[k]; suckbits((long)qhufbit1[k]); } else j = hufgetsym(ibuf1,nbuf1); + if (qhufbit1[k]) { j = qhufval1[k]; suckbits((int)qhufbit1[k]); } + else j = hufgetsym(ibuf1,nbuf1); //else j = hufgetsym_skipb(ibuf1,nbuf1,LOGQHUFSIZ1,qhuf1v); //hufgetsym_skipb related code j = getbits(hxbit[j][0]) + hxbit[j][1]; - i += slidew; do { slidebuf[slidew&32767] = slidebuf[(slidew-j)&32767]; slidew++; } while (slidew < i); + i += slidew; do { slidebuf[slidew&32767] = slidebuf[(slidew-j)&32767]; slidew++; } + while (slidew < i); } - } while (!bfinal); + } + while (!bfinal); slider -= 16384; if (!((slider^slidew)&32768)) @@ -1238,30 +1247,30 @@ kpngrend_goodret: // All non 32-bit color drawing was removed // "Motion" JPG code was removed // A lot of parameters were added to kpeg() for library usage -static long kpeginited = 0; -static long clipxdim, clipydim; +static int kpeginited = 0; +static int clipxdim, clipydim; -static long hufmaxatbit[8][20], hufvalatbit[8][20], hufcnt[8]; +static int hufmaxatbit[8][20], hufvalatbit[8][20], hufcnt[8]; static unsigned char hufnumatbit[8][20], huftable[8][256]; -static long hufquickval[8][1024], hufquickbits[8][1024], hufquickcnt[8]; -static long quantab[4][64], dct[12][64], lastdc[4], unzig[64], zigit[64]; //dct:10=MAX (says spec);+2 for hacks +static int hufquickval[8][1024], hufquickbits[8][1024], hufquickcnt[8]; +static int quantab[4][64], dct[12][64], lastdc[4], unzig[64], zigit[64]; //dct:10=MAX (says spec);+2 for hacks static unsigned char gnumcomponents, dcflagor[64]; -static long gcompid[4], gcomphsamp[4], gcompvsamp[4], gcompquantab[4], gcomphsampshift[4], gcompvsampshift[4]; -static long lnumcomponents, lcompid[4], lcompdc[4], lcompac[4], lcomphsamp[4], lcompvsamp[4], lcompquantab[4]; -static long lcomphvsamp0, lcomphsampshift0, lcompvsampshift0; -static long colclip[1024], colclipup8[1024], colclipup16[1024]; +static int gcompid[4], gcomphsamp[4], gcompvsamp[4], gcompquantab[4], gcomphsampshift[4], gcompvsampshift[4]; +static int lnumcomponents, lcompid[4], lcompdc[4], lcompac[4], lcomphsamp[4], lcompvsamp[4], lcompquantab[4]; +static int lcomphvsamp0, lcomphsampshift0, lcompvsampshift0; +static int colclip[1024], colclipup8[1024], colclipup16[1024]; static unsigned char pow2char[8] = {1,2,4,8,16,32,64,128}; #if defined(__WATCOMC__) && !defined(NOASM) -long mulshr24 (long, long); +int mulshr24(int, int); #pragma aux mulshr24 =\ "imul edx"\ "shrd eax, edx, 24"\ parm nomemory [eax][edx]\ modify exact [eax edx] -long mulshr32 (long, long); +int mulshr32(int, int); #pragma aux mulshr32 =\ "imul edx"\ parm nomemory [eax][edx]\ @@ -1270,7 +1279,7 @@ long mulshr32 (long, long); #elif defined(_MSC_VER) && !defined(NOASM) -static _inline long mulshr24 (long a, long d) +static _inline int mulshr24(int a, int d) { _asm { @@ -1280,7 +1289,7 @@ static _inline long mulshr24 (long a, long d) } } -static _inline long mulshr32 (long a, long d) +static _inline int mulshr32(int a, int d) { _asm { @@ -1293,38 +1302,38 @@ static _inline long mulshr32 (long a, long d) #elif defined(__GNUC__) && defined(__i386__) && !defined(NOASM) #define mulshr24(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx; shrdl $24, %%edx, %%eax" \ : "+a" (__a), "+d" (__d) : : "cc"); \ __a; }) #define mulshr32(a,d) \ - ({ long __a=(a), __d=(d); \ + ({ int __a=(a), __d=(d); \ __asm__ __volatile__ ("imull %%edx" \ : "+a" (__a), "+d" (__d) : : "cc"); \ __d; }) #else -static inline long mulshr24 (long a, long b) +static inline int mulshr24(int a, int b) { - return((long)((((__int64)a)*((__int64)b))>>24)); + return((int)((((__int64)a)*((__int64)b))>>24)); } -static inline long mulshr32 (long a, long b) +static inline int mulshr32(int a, int b) { - return((long)((((__int64)a)*((__int64)b))>>32)); + return((int)((((__int64)a)*((__int64)b))>>32)); } #endif -static long cosqr16[8] = //cosqr16[i] = ((cos(PI*i/16)*sqrt(2))<<24); +static int cosqr16[8] = //cosqr16[i] = ((cos(PI*i/16)*sqrt(2))<<24); {23726566,23270667,21920489,19727919,16777216,13181774,9079764,4628823}; -static long crmul[4096], cbmul[4096]; +static int crmul[4096], cbmul[4096]; -static void initkpeg () +static void initkpeg() { - long i, x, y; + int i, x, y; x = 0; //Back & forth diagonal pattern (aligning bytes for best compression) for (i=0;i<16;i+=2) @@ -1366,9 +1375,9 @@ static void initkpeg () memset((void *)&dct[10][0],0,64*2*sizeof(dct[0][0])); } -static void huffgetval (long index, long curbits, long num, long *daval, long *dabits) +static void huffgetval(int index, int curbits, int num, int *daval, int *dabits) { - long b, v, pow2, *hmax; + int b, v, pow2, *hmax; hmax = &hufmaxatbit[index][0]; pow2 = pow2long[curbits-1]; @@ -1387,13 +1396,13 @@ static void huffgetval (long index, long curbits, long num, long *daval, long *d *dabits = 16; *daval = 0; } -static void invdct8x8 (long *dc, unsigned char dcflag) +static void invdct8x8(int *dc, unsigned char dcflag) { #define SQRT2 23726566 //(sqrt(2))<<24 #define C182 31000253 //(cos(PI/8)*2)<<24 #define C18S22 43840978 //(cos(PI/8)*sqrt(2)*2)<<24 #define C38S22 18159528 //(cos(PI*3/8)*sqrt(2)*2)<<24 - long *edc, t0, t1, t2, t3, t4, t5, t6, t7; + int *edc, t0, t1, t2, t3, t4, t5, t6, t7; edc = dc+64; do @@ -1413,7 +1422,8 @@ static void invdct8x8 (long *dc, unsigned char dcflag) dc[2] = t2+t5; dc[5] = t2-t5; dc[4] = t3+t4; dc[3] = t3-t4; } dc += 8; dcflag >>= 1; - } while (dc < edc); + } + while (dc < edc); dc -= 32; edc -= 24; do { @@ -1429,12 +1439,13 @@ static void invdct8x8 (long *dc, unsigned char dcflag) dc[0*8-32] = t0+t7; dc[7*8-32] = t0-t7; dc[1*8-32] = t1+t6; dc[6*8-32] = t1-t6; dc[2*8-32] = t2+t5; dc[5*8-32] = t2-t5; dc[4*8-32] = t3+t4; dc[3*8-32] = t3-t4; dc++; - } while (dc < edc); + } + while (dc < edc); } -static void yrbrend (long x, long y) +static void yrbrend(int x, int y) { - long 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, p, pp, *odc, *dc, *dc2; odc = dct[0]; dc2 = dct[10]; for (yy=0;yy<(lcompvsamp[0]<<3);yy+=8) @@ -1458,9 +1469,9 @@ static void yrbrend (long x, long y) yv = dc[xxx]; cr = (dc2[xxx+64]>>13)&~1; cb = (dc2[xxx ]>>13)&~1; - ((long *)p)[xxx] = colclipup16[(unsigned)(yv+crmul[cr+2048] )>>22]+ - colclipup8[(unsigned)(yv+crmul[cr+2049]+cbmul[cb+2048])>>22]+ - colclip[(unsigned)(yv+cbmul[cb+2049] )>>22]; + ((int *)p)[xxx] = colclipup16[(unsigned)(yv+crmul[cr+2048])>>22]+ + colclipup8[(unsigned)(yv+crmul[cr+2049]+cbmul[cb+2048])>>22]+ + colclip[(unsigned)(yv+cbmul[cb+2049])>>22]; } p += bytesperline; dc += 8; @@ -1475,17 +1486,17 @@ static void yrbrend (long x, long y) { yv = dc[xxx]; cr = (dc2[(xxx>>1)+64]>>13)&~1; - cb = (dc2[(xxx>>1) ]>>13)&~1; + cb = (dc2[(xxx>>1)]>>13)&~1; i = crmul[cr+2049]+cbmul[cb+2048]; cr = crmul[cr+2048]; cb = cbmul[cb+2049]; - ((long *)p)[xxx] = colclipup16[(unsigned)(yv+cr)>>22]+ - colclipup8[(unsigned)(yv+ i)>>22]+ - colclip[(unsigned)(yv+cb)>>22]; + ((int *)p)[xxx] = colclipup16[(unsigned)(yv+cr)>>22]+ + colclipup8[(unsigned)(yv+ i)>>22]+ + colclip[(unsigned)(yv+cb)>>22]; yv = dc[xxx+1]; - ((long *)p)[xxx+1] = colclipup16[(unsigned)(yv+cr)>>22]+ - colclipup8[(unsigned)(yv+ i)>>22]+ - colclip[(unsigned)(yv+cb)>>22]; + ((int *)p)[xxx+1] = colclipup16[(unsigned)(yv+cr)>>22]+ + colclipup8[(unsigned)(yv+ i)>>22]+ + colclip[(unsigned)(yv+cb)>>22]; } p += bytesperline; dc += 8; @@ -1508,9 +1519,9 @@ static void yrbrend (long x, long y) cb = (dc2[i ]>>13)&~1; i++; } - ((long *)p)[xxx] = colclipup16[(unsigned)(yv+crmul[cr+2048] )>>22]+ - colclipup8[(unsigned)(yv+crmul[cr+2049]+cbmul[cb+2048])>>22]+ - colclip[(unsigned)(yv+cbmul[cb+2049] )>>22]; + ((int *)p)[xxx] = colclipup16[(unsigned)(yv+crmul[cr+2048])>>22]+ + colclipup8[(unsigned)(yv+crmul[cr+2049]+cbmul[cb+2048])>>22]+ + colclip[(unsigned)(yv+cbmul[cb+2049])>>22]; } p += bytesperline; dc += 8; @@ -1521,14 +1532,14 @@ static void yrbrend (long x, long y) } } -static long kpegrend (const char *kfilebuf, long kfilength, - long daframeplace, long dabytesperline, long daxres, long dayres, - long daglobxoffs, long daglobyoffs) +static int kpegrend(const char *kfilebuf, int kfilength, + int daframeplace, int dabytesperline, int daxres, int dayres, + int daglobxoffs, int daglobyoffs) { - long i, j, p, v, leng, xdim = 0, ydim = 0, index, prec, restartcnt, restartinterval; - long x, y, z, xx, yy, zz, *dc = 0, *dc2, num, curbits, c, daval, dabits, *hqval, *hqbits, hqcnt, *quanptr = 0; - long passcnt = 0, ghsampmax = 0, gvsampmax = 0, glhsampmax = 0, glvsampmax = 0, glhstep, glvstep; - long eobrun, Ss, Se, Ah, Al, Alut[2], dctx[12], dcty[12], ldctx[12], ldcty[12], lshx[4], lshy[4]; + int i, j, p, v, leng, xdim = 0, ydim = 0, index, prec, restartcnt, restartinterval; + int x, y, z, xx, yy, zz, *dc = 0, *dc2, num, curbits, c, daval, dabits, *hqval, *hqbits, hqcnt, *quanptr = 0; + int passcnt = 0, ghsampmax = 0, gvsampmax = 0, glhsampmax = 0, glvsampmax = 0, glhstep, glvstep; + int eobrun, Ss, Se, Ah, Al, Alut[2], dctx[12], dcty[12], ldctx[12], ldcty[12], lshx[4], lshy[4]; short *dctbuf = 0, *dctptr[12], *ldctptr[12], *dcs = 0; unsigned char ch, marker, dcflag; const unsigned char *kfileptr; @@ -1548,13 +1559,14 @@ static long kpegrend (const char *kfilebuf, long kfilength, do { ch = *kfileptr++; if (ch != 255) continue; - do { marker = *kfileptr++; } while (marker == 255); + do { marker = *kfileptr++; } + while (marker == 255); if (marker != 0xd9) //Don't read past end of buffer { - leng = ((long)kfileptr[0]<<8)+(long)kfileptr[1]-2; + leng = ((int)kfileptr[0]<<8)+(int)kfileptr[1]-2; kfileptr += 2; } - //printf("fileoffs=%08x, marker=%02x,leng=%d",((long)kfileptr)-((long)kfilebuf)-2,marker,leng); + //printf("fileoffs=%08x, marker=%02x,leng=%d",((int)kfileptr)-((int)kfilebuf)-2,marker,leng); switch (marker) { case 0xc0: @@ -1565,7 +1577,7 @@ static long kpegrend (const char *kfilebuf, long kfilength, ydim = SSWAPIL(*(unsigned short *)&kfileptr[0]); xdim = SSWAPIL(*(unsigned short *)&kfileptr[2]); - //printf("%s: %ld / %ld = %ld\n",filename,xdim*ydim*3,kfilength,(xdim*ydim*3)/kfilength); + //printf("%s: %d / %d = %d\n",filename,xdim*ydim*3,kfilength,(xdim*ydim*3)/kfilength); frameplace = daframeplace; bytesperline = dabytesperline; @@ -1606,7 +1618,7 @@ static long kpegrend (const char *kfilebuf, long kfilength, { hufmaxatbit[index][i] = v+hufnumatbit[index][i]; hufvalatbit[index][i] = hufcnt[index]-v; - memcpy((void *)&huftable[index][hufcnt[index]],(void *)kfileptr,(long)hufnumatbit[index][i]); + memcpy((void *)&huftable[index][hufcnt[index]],(void *)kfileptr,(int)hufnumatbit[index][i]); if (i <= 10) for (c=0;c0;j--) @@ -1621,7 +1633,8 @@ static long kpegrend (const char *kfilebuf, long kfilength, v = ((v+hufnumatbit[index][i])<<1); } - } while (leng > 0); + } + while (leng > 0); break; case 0xdb: do @@ -1631,26 +1644,27 @@ static long kpegrend (const char *kfilebuf, long kfilength, prec = (ch>>4); for (z=0;z<64;z++) { - v = (long)(*kfileptr++); - if (prec) v = (v<<8)+((long)(*kfileptr++)); + v = (int)(*kfileptr++); + if (prec) v = (v<<8)+((int)(*kfileptr++)); v <<= 19; - if (unzig[z]&7 ) v = mulshr24(v,cosqr16[unzig[z]&7 ]); + if (unzig[z]&7) v = mulshr24(v,cosqr16[unzig[z]&7 ]); if (unzig[z]>>3) v = mulshr24(v,cosqr16[unzig[z]>>3]); if (index) v >>= 6; quantab[index][unzig[z]] = v; } leng -= 64; if (prec) leng -= 64; - } while (leng > 0); + } + while (leng > 0); break; case 0xdd: restartinterval = SSWAPIL(*(unsigned short *)&kfileptr[0]); kfileptr += leng; break; case 0xda: - if ((xdim <= 0) || (ydim <= 0)) { if (dctbuf) free(dctbuf); return(-1); } + if ((xdim <= 0) || (ydim <= 0)) { if (dctbuf) free(dctbuf); return(-1); } - lnumcomponents = (long)(*kfileptr++); if (!lnumcomponents) { if (dctbuf) free(dctbuf); return(-1); } + lnumcomponents = (int)(*kfileptr++); if (!lnumcomponents) { if (dctbuf) free(dctbuf); return(-1); } if (lnumcomponents > 1) coltype = 2; for (z=0;z= xres) || (min(globxoffs+xdim,xres) <= 0) || (max(globyoffs,0) >= yres) || (min(globyoffs+ydim,yres) <= 0)) - { if (dctbuf) free(dctbuf); return(0); } + { if (dctbuf) free(dctbuf); return(0); } Alut[0] = (1<>lshy[c])*ldctx[c] + ((x+xx)>>lshx[c]))<<6]; @@ -1741,14 +1756,14 @@ static long kpegrend (const char *kfilebuf, long kfilength, while (curbits < 24) //Getbits { ch = *kfileptr++; if (ch == 255) kfileptr++; - num = (num<<8)+((long)ch); curbits += 8; + num = (num<<8)+((int)ch); curbits += 8; } if (!Ah) { i = ((num>>(curbits-10))&1023); if (i < hufquickcnt[lcompdc[c]]) - { daval = hufquickval[lcompdc[c]][i]; curbits -= hufquickbits[lcompdc[c]][i]; } + { daval = hufquickval[lcompdc[c]][i]; curbits -= hufquickbits[lcompdc[c]][i]; } else { huffgetval(lcompdc[c],curbits,num,&daval,&dabits); curbits -= dabits; } if (daval) @@ -1756,7 +1771,7 @@ static long kpegrend (const char *kfilebuf, long kfilength, while (curbits < 24) //Getbits { ch = *kfileptr++; if (ch == 255) kfileptr++; - num = (num<<8)+((long)ch); curbits += 8; + num = (num<<8)+((int)ch); curbits += 8; } curbits -= daval; v = ((unsigned)num >> curbits) & pow2mask[daval]; @@ -1778,11 +1793,11 @@ static long kpegrend (const char *kfilebuf, long kfilength, while (curbits < 24) //Getbits { ch = *kfileptr++; if (ch == 255) kfileptr++; - num = (num<<8)+((long)ch); curbits += 8; + num = (num<<8)+((int)ch); curbits += 8; } i = ((num>>(curbits-10))&1023); if (i < hqcnt) - { daval = hqval[i]; curbits -= hqbits[i]; } + { daval = hqval[i]; curbits -= hqbits[i]; } else { huffgetval(lcompac[c]+4,curbits,num,&daval,&dabits); curbits -= dabits; } zz = (daval>>4); daval &= 15; @@ -1802,7 +1817,7 @@ static long kpegrend (const char *kfilebuf, long kfilength, while (curbits < 24) //Getbits { ch = *kfileptr++; if (ch == 255) kfileptr++; - num = (num<<8)+((long)ch); curbits += 8; + num = (num<<8)+((int)ch); curbits += 8; } curbits -= zz; eobrun += ((unsigned)num >> curbits) & pow2mask[zz]; } @@ -1818,12 +1833,14 @@ static long kpegrend (const char *kfilebuf, long kfilength, while (curbits < 24) //Getbits { ch = *kfileptr++; if (ch == 255) kfileptr++; - num = (num<<8)+((long)ch); curbits += 8; + num = (num<<8)+((int)ch); curbits += 8; } if (num&(pow2long[--curbits])) dcs[z] += ((short)Alut[dcs[z] < 0]); - } else if (--zz < 0) break; + } + else if (--zz < 0) break; z++; - } while (z <= Se); + } + while (z <= Se); if (daval) dcs[z] = daval; } else @@ -1833,7 +1850,7 @@ static long kpegrend (const char *kfilebuf, long kfilength, while (curbits < 24) //Getbits { ch = *kfileptr++; if (ch == 255) kfileptr++; - num = (num<<8)+((long)ch); curbits += 8; + num = (num<<8)+((int)ch); curbits += 8; } curbits -= daval; v = ((unsigned)num >> curbits) & pow2mask[daval]; if (v <= pow2mask[daval-1]) v -= pow2mask[daval]; @@ -1841,7 +1858,8 @@ static long kpegrend (const char *kfilebuf, long kfilength, if (!dctbuf) dc[unzig[z]] = v; else dcs[z] = (short)(v< 0)) { eobrun--; @@ -1851,7 +1869,7 @@ static long kpegrend (const char *kfilebuf, long kfilength, while (curbits < 24) //Getbits { ch = *kfileptr++; if (ch == 255) kfileptr++; - num = (num<<8)+((long)ch); curbits += 8; + num = (num<<8)+((int)ch); curbits += 8; } if (num&(pow2long[--curbits])) dcs[z] += ((short)Alut[dcs[z] < 0]); } @@ -1887,7 +1905,8 @@ kpegrend_break2: default: kfileptr += leng; break; } - } while (kfileptr-(unsigned char *)kfilebuf < kfilength); + } + while (kfileptr-(unsigned char *)kfilebuf < kfilength); if (!dctbuf) return(0); @@ -1912,7 +1931,7 @@ kpegrend_break2: { dcs = &dctptr[c][(((y+yy)>>lshy[c])*dctx[c] + ((x+xx)>>lshx[c]))<<6]; quanptr = &quantab[gcompquantab[c]][0]; - for (z=0;z<64;z++) dc[z] = ((long)dcs[zigit[z]])*quanptr[z]; + for (z=0;z<64;z++) dc[z] = ((int)dcs[zigit[z]])*quanptr[z]; invdct8x8(dc,-1); } yrbrend(x,y); @@ -1925,14 +1944,14 @@ kpegrend_break2: //================================ GIF begins ================================ static unsigned char suffix[4100], filbuffer[768], tempstack[4096]; -static long prefix[4100]; +static int prefix[4100]; -static long kgifrend (const char *kfilebuf, long kfilelength, - long daframeplace, long dabytesperline, long daxres, long dayres, - long daglobxoffs, long daglobyoffs) +static int kgifrend(const char *kfilebuf, int kfilelength, + int daframeplace, int dabytesperline, int daxres, int dayres, + int daglobxoffs, int daglobyoffs) { - long i, x, y, xsiz, ysiz, yinc, xend, xspan, yspan, currstr, numbitgoal; - long lzcols, dat, blocklen, bitcnt, xoff, yoff, transcol, backcol, *lptr; + int i, x, y, xsiz, ysiz, yinc, xend, xspan, yspan, currstr, numbitgoal; + int lzcols, dat, blocklen, bitcnt, xoff, yoff, transcol, backcol, *lptr; char numbits, startnumbits, chunkind, ilacefirst; const unsigned char *ptr, *cptr = 0; @@ -1942,13 +1961,15 @@ static long kgifrend (const char *kfilebuf, long kfilelength, (kfilebuf[2] != 'F') || (kfilebuf[12])) return(-1); paleng = (1<<((kfilebuf[10]&7)+1)); ptr = (unsigned char *)&kfilebuf[13]; -if (kfilebuf[10]&128) { cptr = ptr; ptr += paleng*3; } + if (kfilebuf[10]&128) { cptr = ptr; ptr += paleng*3; } transcol = -1; while ((chunkind = *ptr++) == '!') - { //! 0xf9 leng flags ?? ?? transcol - if (ptr[0] == 0xf9) { if (ptr[2]&1) transcol = (long)(((unsigned char)ptr[5])); } + { + //! 0xf9 leng flags ?? ?? transcol + if (ptr[0] == 0xf9) { if (ptr[2]&1) transcol = (int)(((unsigned char)ptr[5])); } ptr++; - do { i = *ptr++; ptr += i; } while (i); + do { i = *ptr++; ptr += i; } + while (i); } if (chunkind != ',') return(-1); @@ -1956,7 +1977,7 @@ if (kfilebuf[10]&128) { cptr = ptr; ptr += paleng*3; } yoff = SSWAPIB(*(unsigned short *)&ptr[2]); xspan = SSWAPIB(*(unsigned short *)&ptr[4]); yspan = SSWAPIB(*(unsigned short *)&ptr[6]); ptr += 9; -if (ptr[-1]&64) { yinc = 8; ilacefirst = 1; } + if (ptr[-1]&64) { yinc = 8; ilacefirst = 1; } else { yinc = 1; ilacefirst = 0; } if (ptr[-1]&128) { @@ -1965,7 +1986,7 @@ if (ptr[-1]&64) { yinc = 8; ilacefirst = 1; } } for (i=0;i= 0) palcol[transcol] &= LSWAPIB(~0xff000000); @@ -1974,7 +1995,7 @@ if (ptr[-1]&64) { yinc = 8; ilacefirst = 1; } ysiz = SSWAPIB(*(unsigned short *)&kfilebuf[8]); if ((xoff != 0) || (yoff != 0) || (xsiz != xspan) || (ysiz != yspan)) { - long xx[4], yy[4]; + int xx[4], yy[4]; if (kfilebuf[10]&128) backcol = palcol[(unsigned char)kfilebuf[11]]; else backcol = 0; //Fill border to backcol @@ -1983,14 +2004,15 @@ if (ptr[-1]&64) { yinc = 8; ilacefirst = 1; } xx[2] = max(daglobxoffs+xoff+xspan, 0); yy[2] = min(daglobyoffs+yoff+yspan,dayres); xx[3] = min(daglobxoffs+xsiz ,daxres); yy[3] = min(daglobyoffs+ysiz ,dayres); - lptr = (long *)(yy[0]*dabytesperline+daframeplace); - for (y=yy[0];y=0;i--) { suffix[i] = (char)(prefix[i] = i); } @@ -2013,13 +2035,13 @@ if (ptr[-1]&64) { yinc = 8; ilacefirst = 1; } bitcnt = 0; while (1) { - dat = (LSWAPIB(*(long *)&filbuffer[bitcnt>>3])>>(bitcnt&7)) & (numbitgoal-1); + dat = (LSWAPIB(*(int *)&filbuffer[bitcnt>>3])>>(bitcnt&7)) & (numbitgoal-1); bitcnt += numbits; if ((bitcnt>>3) > blocklen-3) { *(short *)filbuffer = *(short *)&filbuffer[bitcnt>>3]; i = blocklen-(bitcnt>>3); - blocklen = (long)*ptr++; + blocklen = (int)*ptr++; memcpy(&filbuffer[i],ptr,blocklen); ptr += blocklen; bitcnt &= 7; blocklen += i; } @@ -2029,7 +2051,7 @@ if (ptr[-1]&64) { yinc = 8; ilacefirst = 1; } continue; } if ((currstr == numbitgoal) && (numbits < 12)) - { numbits++; numbitgoal <<= 1; } + { numbits++; numbitgoal <<= 1; } prefix[currstr] = dat; for (i=0;dat>=lzcols;dat=prefix[dat]) tempstack[i++] = suffix[dat]; @@ -2038,8 +2060,8 @@ if (ptr[-1]&64) { yinc = 8; ilacefirst = 1; } for (;i>=0;i--) { - if ((unsigned long)x < (unsigned long)daxres) - *(long *)(yoff+(x<<2)) = palcol[(long)tempstack[i]]; + if ((unsigned int)x < (unsigned int)daxres) + *(int *)(yoff+(x<<2)) = palcol[(int)tempstack[i]]; x++; if (x == xend) { @@ -2048,7 +2070,7 @@ if (ptr[-1]&64) { yinc = 8; ilacefirst = 1; } switch (yinc) { case 8: - if (!ilacefirst) { y = daglobyoffs+2; yinc = 4; break; } + if (!ilacefirst) { y = daglobyoffs+2; yinc = 4; break; } ilacefirst = 0; y = daglobyoffs+4; yinc = 8; break; case 4: y = daglobyoffs+1; yinc = 2; break; @@ -2056,10 +2078,10 @@ if (ptr[-1]&64) { yinc = 8; ilacefirst = 1; } case 1: return(0); } - if ((unsigned long)y < (unsigned long)dayres) - { yoff = y*dabytesperline+daframeplace; x = daglobxoffs; xend = xspan; } + if ((unsigned int)y < (unsigned int)dayres) + { yoff = y*dabytesperline+daframeplace; x = daglobxoffs; xend = xspan; } else - { x = daglobxoffs+0x80000000; xend = xspan+0x80000000; } + { x = daglobxoffs+0x80000000; xend = xspan+0x80000000; } } } currstr++; @@ -2071,13 +2093,13 @@ if (ptr[-1]&64) { yinc = 8; ilacefirst = 1; } // //old .CEL format: //short id = 0x9119, xdim, ydim, xoff, yoff, id = 0x0008; -//long imagebytes, filler[4]; +//int imagebytes, filler[4]; //char pal6bit[256][3], image[ydim][xdim]; -static long kcelrend (const char *buf, long fleng, - long daframeplace, long dabytesperline, long daxres, long dayres, - long daglobxoffs, long daglobyoffs) +static int kcelrend(const char *buf, int fleng, + int daframeplace, int dabytesperline, int daxres, int dayres, + int daglobxoffs, int daglobyoffs) { - long i, x, y, x0, x1, y0, y1, xsiz, ysiz; + int i, x, y, x0, x1, y0, y1, xsiz, ysiz; const char *cptr; if ((buf[0] != 0x19) || (buf[1] != 0x91) || @@ -2085,15 +2107,15 @@ static long kcelrend (const char *buf, long fleng, coltype = 3; bitdepth = 8; paleng = 256; //For PNGOUT - xsiz = (long)SSWAPIB(*(unsigned short *)&buf[2]); if (xsiz <= 0) return(-1); - ysiz = (long)SSWAPIB(*(unsigned short *)&buf[4]); if (ysiz <= 0) return(-1); + xsiz = (int)SSWAPIB(*(unsigned short *)&buf[2]); if (xsiz <= 0) return(-1); + ysiz = (int)SSWAPIB(*(unsigned short *)&buf[4]); if (ysiz <= 0) return(-1); cptr = &buf[32]; for (i=0;i<256;i++) { - palcol[i] = (((long)cptr[0])<<18) + - (((long)cptr[1])<<10) + - (((long)cptr[2])<< 2) + LSWAPIB(0xff000000); + palcol[i] = (((int)cptr[0])<<18) + + (((int)cptr[1])<<10) + + (((int)cptr[2])<< 2) + LSWAPIB(0xff000000); cptr += 3; } @@ -2102,8 +2124,8 @@ static long kcelrend (const char *buf, long fleng, for (y=y0;y>3); + xsiz = (int)SSWAPIB(*(unsigned short *)&header[12]); if (xsiz <= 0) return(-1); + ysiz = (int)SSWAPIB(*(unsigned short *)&header[14]); if (ysiz <= 0) return(-1); + colbyte = ((((int)header[16])+7)>>3); if (header[1] == 1) { - pixbyte = ((((long)header[7])+7)>>3); + pixbyte = ((((int)header[7])+7)>>3); cptr = &fptr[-SSWAPIB(*(unsigned short *)&header[3])*pixbyte]; fptr += SSWAPIB(*(unsigned short *)&header[5])*pixbyte; - } else pixbyte = colbyte; + } + else pixbyte = colbyte; switch (pixbyte) //For PNGOUT { @@ -2149,7 +2172,7 @@ static long ktgarend (const char *header, long fleng, coltype = 6; break; } -if (!(header[17]&16)) { x0 = 0; x1 = xsiz; xi = 1; } + if (!(header[17]&16)) { x0 = 0; x1 = xsiz; xi = 1; } else { x0 = xsiz-1; x1 = -1; xi =-1; } if (header[17]&32) { y0 = 0; y1 = ysiz; yi = 1; pi = dabytesperline; } else { y0 = ysiz-1; y1 = -1; yi =-1; pi =-dabytesperline; } @@ -2163,33 +2186,34 @@ if (!(header[17]&16)) { x0 = 0; x1 = xsiz; xi = 1; } { if (rlestat < 128) { - if ((rlestat&127) == 127) { rlestat = (long)fptr[0]; fptr++; } + if ((rlestat&127) == 127) { rlestat = (int)fptr[0]; fptr++; } if (header[1] == 1) { if (colbyte == 1) i = fptr[0]; - else i = (long)SSWAPIB(*(unsigned short *)&fptr[0]); + else i = (int)SSWAPIB(*(unsigned short *)&fptr[0]); nptr = &cptr[i*pixbyte]; - } else nptr = fptr; + } + else nptr = fptr; switch (pixbyte) { case 1: - i = palcol[(long)nptr[0]]; break; + i = palcol[(int)nptr[0]]; break; case 2: - i = (long)SSWAPIB(*(unsigned short *)&nptr[0]); + i = (int)SSWAPIB(*(unsigned short *)&nptr[0]); i = LSWAPIB(((i&0x7c00)<<9) + ((i&0x03e0)<<6) + ((i&0x001f)<<3) + 0xff000000); break; case 3: - i = (*(long *)&nptr[0]) | LSWAPIB(0xff000000); break; + i = (*(int *)&nptr[0]) | LSWAPIB(0xff000000); break; case 4: - i = (*(long *)&nptr[0]); break; + i = (*(int *)&nptr[0]); break; } fptr += colbyte; } if (rlestat >= 0) rlestat--; - if (((unsigned long)x < (unsigned long)daxres) && ((unsigned long)y < (unsigned long)dayres)) - *(long *)(x*4+p) = i; + if (((unsigned int)x < (unsigned int)daxres) && ((unsigned int)y < (unsigned int)dayres)) + *(int *)(x*4+p) = i; } return(0); } @@ -2214,43 +2238,43 @@ if (!(header[17]&16)) { x0 = 0; x1 = xsiz; xi = 1; } //ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ // ³ rastoff(?): bitmap data ³ // ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ -static long kbmprend (const char *buf, long fleng, - long daframeplace, long dabytesperline, long daxres, long dayres, - long daglobxoffs, long daglobyoffs) +static int kbmprend(const char *buf, int fleng, + int daframeplace, int dabytesperline, int daxres, int dayres, + int daglobxoffs, int daglobyoffs) { - long i, j, x, y, x0, x1, y0, y1, rastoff, headsiz, xsiz, ysiz, cdim, comp, cptrinc, *lptr; + int i, j, x, y, x0, x1, y0, y1, rastoff, headsiz, xsiz, ysiz, cdim, comp, cptrinc, *lptr; const char *cptr; - headsiz = *(long *)&buf[14]; + headsiz = *(int *)&buf[14]; if (headsiz == LSWAPIB(12)) //OS/2 1.x (old format) { if (*(short *)(&buf[22]) != SSWAPIB(1)) return(-1); - xsiz = (long)SSWAPIB(*(unsigned short *)&buf[18]); - ysiz = (long)SSWAPIB(*(unsigned short *)&buf[20]); - cdim = (long)SSWAPIB(*(unsigned short *)&buf[24]); + xsiz = (int)SSWAPIB(*(unsigned short *)&buf[18]); + ysiz = (int)SSWAPIB(*(unsigned short *)&buf[20]); + cdim = (int)SSWAPIB(*(unsigned short *)&buf[24]); comp = 0; } else //All newer formats... { if (*(short *)(&buf[26]) != SSWAPIB(1)) return(-1); - xsiz = LSWAPIB(*(long *)&buf[18]); - ysiz = LSWAPIB(*(long *)&buf[22]); - cdim = (long)SSWAPIB(*(unsigned short *)&buf[28]); - comp = LSWAPIB(*(long *)&buf[30]); + xsiz = LSWAPIB(*(int *)&buf[18]); + ysiz = LSWAPIB(*(int *)&buf[22]); + cdim = (int)SSWAPIB(*(unsigned short *)&buf[28]); + comp = LSWAPIB(*(int *)&buf[30]); } if ((xsiz <= 0) || (!ysiz)) return(-1); //cdim must be: (1,4,8,16,24,32) - if (((unsigned long)(cdim-1) >= (unsigned long)32) || (!((1<= (unsigned int)32) || (!((1<>1); + j = (((unsigned int)j)>>1); } for (palcol[i+3]=0;palcol[i+3]<32;palcol[i+3]++) { if (!(j&1)) break; - j = (((unsigned long)j)>>1); + j = (((unsigned int)j)>>1); } } } @@ -2285,11 +2309,12 @@ static long kbmprend (const char *buf, long fleng, palcol[2] = 8-(palcol[2]+palcol[5]); palcol[3] = ((-1<<(24-palcol[3]))&0x00ff0000); palcol[4] = ((-1<<(16-palcol[4]))&0x0000ff00); - palcol[5] = ((-1<<( 8-palcol[5]))&0x000000ff); + palcol[5] = ((-1<<(8-palcol[5]))&0x000000ff); } cptrinc = (((xsiz*cdim+31)>>3)&~3); cptr = &buf[rastoff]; -if (ysiz < 0) { ysiz = -ysiz; } else { cptr = &cptr[(ysiz-1)*cptrinc]; cptrinc = -cptrinc; } + if (ysiz < 0) { ysiz = -ysiz; } + else { cptr = &cptr[(ysiz-1)*cptrinc]; cptrinc = -cptrinc; } x0 = daglobxoffs; x1 = xsiz+daglobxoffs; y0 = daglobyoffs; y1 = ysiz+daglobyoffs; @@ -2298,34 +2323,36 @@ if (ysiz < 0) { ysiz = -ysiz; } else { cptr = &cptr[(ysiz-1)*cptrinc]; cptrinc = if (x1 > daxres) x1 = daxres; for (y=y0;y= (unsigned long)dayres) continue; - lptr = (long *)(y*dabytesperline-(daglobyoffs<<2)+daframeplace); + if ((unsigned int)y >= (unsigned int)dayres) continue; + lptr = (int *)(y*dabytesperline-(daglobyoffs<<2)+daframeplace); switch (cdim) { case 1: - for (x=x0;x>3]>>((x&7)^7))&1)]; break; + for (x=x0;x>3]>>((x&7)^7))&1)]; break; case 4: - for (x=x0;x>1]>>(((x&1)^1)<<2))&15)]; break; + for (x=x0;x>1]>>(((x&1)^1)<<2))&15)]; break; case 8: - for (x=x0;x= x1) { x = x0; y++; p += dabytesperline; } + if ((unsigned int)y < (unsigned int)dayres) + if ((unsigned int)x < (unsigned int)daxres) *(int *)(x+p) = j; + x += 4; if (x >= x1) { x = x0; y++; p += dabytesperline; } } - } while (y < y1); + } + while (y < y1); } else if (nplanes == 3) //24-bit PCX { @@ -2402,11 +2430,12 @@ static long kpcxrend (const char *buf, long fleng, c = *cptr++; if (c < 192) i = 1; else { i = (c&63); c = *cptr++; } for (;i;i--) { - if ((unsigned long)y < (unsigned long)dayres) - if ((unsigned long)x < (unsigned long)daxres) *(char *)(x+p) = c; - x += 4; if (x >= x1) { j--; if (j < 0) { j = 3-1; y++; p += dabytesperline; } x = x0+j; } + if ((unsigned int)y < (unsigned int)dayres) + if ((unsigned int)x < (unsigned int)daxres) *(char *)(x+p) = c; + x += 4; if (x >= x1) { j--; if (j < 0) { j = 3-1; y++; p += dabytesperline; } x = x0+j; } } - } while (y < y1); + } + while (y < y1); } return(0); @@ -2416,35 +2445,35 @@ static long kpcxrend (const char *buf, long fleng, //============================== DDS begins ================================= //Note:currently supports: DXT1,DXT2,DXT3,DXT4,DXT5,A8R8G8B8 -static long kddsrend (const char *buf, long leng, - long frameptr, long bpl, long xdim, long ydim, long xoff, long yoff) +static int kddsrend(const char *buf, int leng, + int frameptr, int bpl, int xdim, int ydim, int xoff, int yoff) { - long x = 0, y = 0, z = 0, xx, yy, xsiz, ysiz, dxt, al[2], ai, j, k, v, c0, c1, stride; - unsigned long lut[256], r[4], g[4], b[4], a[8], rr, gg, bb; + int x = 0, y = 0, z = 0, xx, yy, xsiz, ysiz, dxt, al[2], ai, j, k, v, c0, c1, stride; + unsigned int lut[256], r[4], g[4], b[4], a[8], rr, gg, bb; unsigned char *uptr, *wptr; - xsiz = LSWAPIB(*(long *)&buf[16]); - ysiz = LSWAPIB(*(long *)&buf[12]); - if ((*(long *)&buf[80])&LSWAPIB(64)) //Uncompressed supports only A8R8G8B8 for now + xsiz = LSWAPIB(*(int *)&buf[16]); + ysiz = LSWAPIB(*(int *)&buf[12]); + if ((*(int *)&buf[80])&LSWAPIB(64)) //Uncompressed supports only A8R8G8B8 for now { - if ((*(long *)&buf[88]) != (signed)LSWAPIB(32)) return(-1); - if ((*(long *)&buf[92]) != (signed)LSWAPIB(0x00ff0000)) return(-1); - if ((*(long *)&buf[96]) != (signed)LSWAPIB(0x0000ff00)) return(-1); - if ((*(long *)&buf[100]) != (signed)LSWAPIB(0x000000ff)) return(-1); - if ((*(long *)&buf[104]) != (signed)LSWAPIB(0xff000000)) return(-1); + if ((*(int *)&buf[88]) != (signed)LSWAPIB(32)) return(-1); + if ((*(int *)&buf[92]) != (signed)LSWAPIB(0x00ff0000)) return(-1); + if ((*(int *)&buf[96]) != (signed)LSWAPIB(0x0000ff00)) return(-1); + if ((*(int *)&buf[100]) != (signed)LSWAPIB(0x000000ff)) return(-1); + if ((*(int *)&buf[104]) != (signed)LSWAPIB(0xff000000)) return(-1); buf += 128; j = yoff*bpl + (xoff<<2) + frameptr; xx = (xsiz<<2); - if (xoff < 0) { j -= (xoff<<2); buf -= (xoff<<2); xsiz += xoff; } + if (xoff < 0) { j -= (xoff<<2); buf -= (xoff<<2); xsiz += xoff; } xsiz = (min(xsiz,xdim-xoff)<<2); ysiz = min(ysiz,ydim); for (y=0;y= (unsigned long)ydim) continue; + if ((unsigned int)(y+yoff) >= (unsigned int)ydim) continue; memcpy((void *)j,(void *)buf,xsiz); } return(0); } - if (!((*(long *)&buf[80])&LSWAPIB(4))) return(-1); //FOURCC invalid + if (!((*(int *)&buf[80])&LSWAPIB(4))) return(-1); //FOURCC invalid dxt = buf[87]-'0'; if ((buf[84] != 'D') || (buf[85] != 'X') || (buf[86] != 'T') || (dxt < 1) || (dxt > 5)) return(-1); buf += 128; @@ -2459,8 +2488,8 @@ static long kddsrend (const char *buf, long leng, for (y=0;y>8)&0xf8); g[0] = ((c0>>3)&0xfc); b[0] = ((c0<<3)&0xfc); a[0] = 255; c1 = SSWAPIB(*(unsigned short *)&uptr[2]); @@ -2481,7 +2510,7 @@ static long kddsrend (const char *buf, long leng, b[2] = (b[0] + b[1])>>1; a[2] = 255; r[3] = g[3] = b[3] = a[3] = 0; //Transparent } - v = LSWAPIB(*(long *)&uptr[4]); + v = LSWAPIB(*(int *)&uptr[4]); if (dxt >= 4) { a[0] = uptr[-8]; a[1] = uptr[-7]; k = a[1]-a[0]; @@ -2496,17 +2525,17 @@ static long kddsrend (const char *buf, long leng, for (j=2;j<6;j++) { a[j] = ((z*(65536/5))>>16); z += k; } a[6] = 0; a[7] = 255; } - al[0] = LSWAPIB(*(long *)&uptr[-6]); - al[1] = LSWAPIB(*(long *)&uptr[-3]); + al[0] = LSWAPIB(*(int *)&uptr[-6]); + al[1] = LSWAPIB(*(int *)&uptr[-3]); } wptr = (unsigned char *)((y+yoff)*bpl + ((x+xoff)<<2) + frameptr); ai = 0; for (yy=0;yy<4;yy++,wptr+=bpl) { - if ((unsigned long)(y+yy+yoff) >= (unsigned long)ydim) { ai += 4; continue; } + if ((unsigned int)(y+yy+yoff) >= (unsigned int)ydim) { ai += 4; continue; } for (xx=0;xx<4;xx++,ai++) { - if ((unsigned long)(x+xx+xoff) >= (unsigned long)xdim) continue; + if ((unsigned int)(x+xx+xoff) >= (unsigned int)xdim) continue; j = ((v>>(ai<<1))&3); switch (dxt) @@ -2515,10 +2544,10 @@ static long kddsrend (const char *buf, long leng, z = a[j]; break; case 2: case 3: - z = (( uptr[(ai>>1)-8] >> ((xx&1)<<2) )&15)*17; break; + z = ((uptr[(ai>>1)-8] >> ((xx&1)<<2))&15)*17; break; case 4: case 5: - z = a[( al[yy>>1] >> ((ai&7)*3) )&7]; break; + z = a[(al[yy>>1] >> ((ai&7)*3))&7]; break; } rr = r[j]; gg = g[j]; bb = b[j]; if (!(dxt&1)) @@ -2540,32 +2569,32 @@ static long kddsrend (const char *buf, long leng, //=============================== DDS ends ================================== //=================== External picture interface begins ====================== -void kpgetdim (const char *buf, long leng, long *xsiz, long *ysiz) +void kpgetdim(const char *buf, int leng, int *xsiz, int *ysiz) { - long *lptr; + int *lptr; const unsigned char *cptr; unsigned char *ubuf = (unsigned char *)buf; (*xsiz) = (*ysiz) = 0; if (leng < 16) return; if ((ubuf[0] == 0x89) && (ubuf[1] == 0x50)) //.PNG { - lptr = (long *)buf; + lptr = (int *)buf; if ((lptr[0] != LSWAPIB(0x474e5089)) || (lptr[1] != LSWAPIB(0x0a1a0a0d))) return; lptr = &lptr[2]; - while (((unsigned long)lptr-(unsigned long)buf) < (unsigned long)(leng-16)) + while (((unsigned int)lptr-(unsigned int)buf) < (unsigned int)(leng-16)) { if (lptr[1] == LSWAPIB(0x52444849)) //IHDR - { (*xsiz) = LSWAPIL(lptr[2]); (*ysiz) = LSWAPIL(lptr[3]); break; } - lptr = (long *)((long)lptr + LSWAPIL(lptr[0]) + 12); + {(*xsiz) = LSWAPIL(lptr[2]); (*ysiz) = LSWAPIL(lptr[3]); break; } + lptr = (int *)((int)lptr + LSWAPIL(lptr[0]) + 12); } } else if ((ubuf[0] == 0xff) && (ubuf[1] == 0xd8)) //.JPG { cptr = (unsigned char *)&buf[2]; - while (((unsigned long)cptr-(unsigned long)buf) < (unsigned long)(leng-8)) + while (((unsigned int)cptr-(unsigned int)buf) < (unsigned int)(leng-8)) { if (cptr[0] != 255) { cptr = &cptr[1]; continue; } - if ((unsigned long)(cptr[1]-0xc0) < 3) + if ((unsigned int)(cptr[1]-0xc0) < 3) { (*ysiz) = SSWAPIL(*(unsigned short *)&cptr[5]); (*xsiz) = SSWAPIL(*(unsigned short *)&cptr[7]); @@ -2576,54 +2605,55 @@ void kpgetdim (const char *buf, long leng, long *xsiz, long *ysiz) } else if ((ubuf[0] == 'G') && (ubuf[1] == 'I') && (ubuf[2] == 'F') && (ubuf[12] == 0)) //.GIF { - (*xsiz) = (long)SSWAPIB(*(unsigned short *)&buf[6]); - (*ysiz) = (long)SSWAPIB(*(unsigned short *)&buf[8]); + (*xsiz) = (int)SSWAPIB(*(unsigned short *)&buf[6]); + (*ysiz) = (int)SSWAPIB(*(unsigned short *)&buf[8]); } else if ((ubuf[0] == 0x19) && (ubuf[1] == 0x91) && (ubuf[10] == 8) && (ubuf[11] == 0)) //old .CEL/.PIC { - (*xsiz) = (long)SSWAPIB(*(unsigned short *)&buf[2]); - (*ysiz) = (long)SSWAPIB(*(unsigned short *)&buf[4]); + (*xsiz) = (int)SSWAPIB(*(unsigned short *)&buf[2]); + (*ysiz) = (int)SSWAPIB(*(unsigned short *)&buf[4]); } else if ((ubuf[0] == 'B') && (ubuf[1] == 'M')) //.BMP { - if (*(long *)(&buf[14]) == LSWAPIB(12)) //OS/2 1.x (old format) + if (*(int *)(&buf[14]) == LSWAPIB(12)) //OS/2 1.x (old format) { if (*(short *)(&buf[22]) != SSWAPIB(1)) return; - (*xsiz) = (long)SSWAPIB(*(unsigned short *)&buf[18]); - (*ysiz) = (long)SSWAPIB(*(unsigned short *)&buf[20]); + (*xsiz) = (int)SSWAPIB(*(unsigned short *)&buf[18]); + (*ysiz) = (int)SSWAPIB(*(unsigned short *)&buf[20]); } else //All newer formats... { if (*(short *)(&buf[26]) != SSWAPIB(1)) return; - (*xsiz) = LSWAPIB(*(long *)&buf[18]); - (*ysiz) = LSWAPIB(*(long *)&buf[22]); + (*xsiz) = LSWAPIB(*(int *)&buf[18]); + (*ysiz) = LSWAPIB(*(int *)&buf[22]); } } - else if (*(long *)ubuf == LSWAPIB(0x0801050a)) //.PCX + else if (*(int *)ubuf == LSWAPIB(0x0801050a)) //.PCX { (*xsiz) = SSWAPIB(*(short *)&buf[ 8])-SSWAPIB(*(short *)&buf[4])+1; (*ysiz) = SSWAPIB(*(short *)&buf[10])-SSWAPIB(*(short *)&buf[6])+1; } - else if ((*(long *)ubuf == LSWAPIB(0x20534444)) && (*(long *)&ubuf[4] == LSWAPIB(124))) //.DDS + else if ((*(int *)ubuf == LSWAPIB(0x20534444)) && (*(int *)&ubuf[4] == LSWAPIB(124))) //.DDS { - (*xsiz) = LSWAPIB(*(long *)&buf[16]); - (*ysiz) = LSWAPIB(*(long *)&buf[12]); + (*xsiz) = LSWAPIB(*(int *)&buf[16]); + (*ysiz) = LSWAPIB(*(int *)&buf[12]); } else - { //Unreliable .TGA identification - this MUST be final case! + { + //Unreliable .TGA identification - this MUST be final case! if ((leng >= 20) && (!(ubuf[1]&0xfe))) if ((ubuf[2] < 12) && ((1<= 'a') && (c0 <= 'z')) c0 -= 32; c1 = *j; if ((c1 >= 'a') && (c1 <= 'z')) c1 -= 32; if (c0 == '/') c0 = '\\'; if (c1 == '/') c1 = '\\'; if (c0 != c1) return(0); i++; j++; - } while (*j); + } + while (*j); return(!*i); } //Same as: stricmp(st0,st1) except: '/' == '\' -static long filnamcmp (const char *st0, const char *st1) +static int filnamcmp(const char *st0, const char *st1) { - long i; + int i; char ch0, ch1; for (i=0;st0[i];i++) @@ -2721,11 +2752,11 @@ static long filnamcmp (const char *st0, const char *st1) //... #define KZHASHINITSIZE 8192 static char *kzhashbuf = 0; -static long kzhashead[256], kzhashpos, kzlastfnam, kzhashsiz; +static int kzhashead[256], kzhashpos, kzlastfnam, kzhashsiz; -static long kzcheckhashsiz (long siz) +static int kzcheckhashsiz(int siz) { - long i; + int i; if (!kzhashbuf) //Initialize hash table on first call { @@ -2735,16 +2766,17 @@ static long kzcheckhashsiz (long siz) } if (kzhashpos+siz > kzhashsiz) //Make sure string fits in kzhashbuf { - i = kzhashsiz; do { i <<= 1; } while (kzhashpos+siz > i); + i = kzhashsiz; do { i <<= 1; } + while (kzhashpos+siz > i); kzhashbuf = (char *)realloc(kzhashbuf,i); if (!kzhashbuf) return(0); kzhashsiz = i; } return(1); } -static long kzcalchash (const char *st) +static int kzcalchash(const char *st) { - long i, hashind; + int i, hashind; char ch; for (i=0,hashind=0;st[i];i++) @@ -2757,48 +2789,48 @@ static long kzcalchash (const char *st) return(hashind%(sizeof(kzhashead)/sizeof(kzhashead[0]))); } -static long kzcheckhash (const char *filnam, char **zipnam, long *zipseek) +static int kzcheckhash(const char *filnam, char **zipnam, int *zipseek) { - long i; + int i; if (!kzhashbuf) return(0); if (filnam[0] == '|') filnam++; - for (i=kzhashead[kzcalchash(filnam)];i>=0;i=(*(long *)&kzhashbuf[i])) + for (i=kzhashead[kzcalchash(filnam)];i>=0;i=(*(int *)&kzhashbuf[i])) if (!filnamcmp(filnam,&kzhashbuf[i+16])) { - (*zipnam) = &kzhashbuf[*(long *)&kzhashbuf[i+8]]; - (*zipseek) = *(long *)&kzhashbuf[i+12]; + (*zipnam) = &kzhashbuf[*(int *)&kzhashbuf[i+8]]; + (*zipseek) = *(int *)&kzhashbuf[i+12]; return(1); } return(0); } -void kzuninit () +void kzuninit() { if (kzhashbuf) { free(kzhashbuf); kzhashbuf = 0; } kzhashpos = kzhashsiz = 0; } //Load ZIP directory into memory (hash) to allow fast access later -long kzaddstack (const char *zipnam) +int kzaddstack(const char *zipnam) { FILE *fil; - long i, j, hashind, zipnamoffs, numfiles; + int i, j, hashind, zipnamoffs, numfiles; char tempbuf[260+46]; fil = fopen(zipnam,"rb"); if (!fil) return(-1); //Write ZIP filename to hash -i = strlen(zipnam)+1; if (!kzcheckhashsiz(i)) { fclose(fil); return(-1); } + i = strlen(zipnam)+1; if (!kzcheckhashsiz(i)) { fclose(fil); return(-1); } strcpy(&kzhashbuf[kzhashpos],zipnam); zipnamoffs = kzhashpos; kzhashpos += i; fseek(fil,-22,SEEK_END); fread(tempbuf,22,1,fil); - if (*(long *)&tempbuf[0] == LSWAPIB(0x06054b50)) //Fast way of finding dir info + if (*(int *)&tempbuf[0] == LSWAPIB(0x06054b50)) //Fast way of finding dir info { numfiles = SSWAPIB(*(short *)&tempbuf[10]); - fseek(fil,LSWAPIB(*(long *)&tempbuf[16]),SEEK_SET); + fseek(fil,LSWAPIB(*(int *)&tempbuf[16]),SEEK_SET); } else //Slow way of finding dir info (used when ZIP has junk at end) { @@ -2807,9 +2839,9 @@ i = strlen(zipnam)+1; if (!kzcheckhashsiz(i)) { fclose(fil); return(-1); } { if (!fread(&j,4,1,fil)) { numfiles = -1; break; } if (j == LSWAPIB(0x02014b50)) break; //Found central file header :) - if (j != LSWAPIB(0x04034b50)) { numfiles = -1; break; } + if (j != LSWAPIB(0x04034b50)) { numfiles = -1; break; } fread(tempbuf,26,1,fil); - fseek(fil,LSWAPIB(*(long *)&tempbuf[14]) + SSWAPIB(*(short *)&tempbuf[24]) + SSWAPIB(*(short *)&tempbuf[22]),SEEK_CUR); + fseek(fil,LSWAPIB(*(int *)&tempbuf[14]) + SSWAPIB(*(short *)&tempbuf[24]) + SSWAPIB(*(short *)&tempbuf[22]),SEEK_CUR); numfiles++; } if (numfiles < 0) { fclose(fil); return(-1); } @@ -2818,7 +2850,7 @@ i = strlen(zipnam)+1; if (!kzcheckhashsiz(i)) { fclose(fil); return(-1); } for (i=0;i 2GB-32K bytes gslidew = 0x7fffffff; //Force reload at beginning - return((long)kzfs.fil); + return((int)kzfs.fil); default: fclose(kzfs.fil); kzfs.fil = 0; return(0); } @@ -2897,7 +2929,7 @@ long kzopen (const char *filnam) // -------------------------------------------------------------------------- -static long srchstat = -1, wildstpathleng; +static int srchstat = -1, wildstpathleng; #if defined(__DOS__) static char wildst[260] = ""; @@ -2912,12 +2944,12 @@ static DIR *hfind = NULL; static struct dirent *findata = NULL; #endif -void kzfindfilestart (const char *st) +void kzfindfilestart(const char *st) { #if defined(__DOS__) #elif defined(_WIN32) if (hfind != INVALID_HANDLE_VALUE) - { FindClose(hfind); hfind = INVALID_HANDLE_VALUE; } + { FindClose(hfind); hfind = INVALID_HANDLE_VALUE; } #else if (hfind) { closedir(hfind); hfind = NULL; } #endif @@ -2925,9 +2957,9 @@ void kzfindfilestart (const char *st) srchstat = -3; } -long kzfindfile (char *filnam) +int kzfindfile(char *filnam) { - long i; + int i; filnam[0] = 0; if (srchstat == -3) @@ -2947,7 +2979,7 @@ long kzfindfile (char *filnam) #if defined(__DOS__) if (_dos_findfirst(wildst,_A_SUBDIR,&findata)) - { if (!kzhashbuf) return(0); srchstat = kzlastfnam; continue; } + { if (!kzhashbuf) return(0); srchstat = kzlastfnam; continue; } i = wildstpathleng; if (findata.attrib&16) if ((findata.name[0] == '.') && (!findata.name[1])) continue; @@ -2956,7 +2988,7 @@ long kzfindfile (char *filnam) #elif defined(_WIN32) hfind = FindFirstFile(wildst,&findata); if (hfind == INVALID_HANDLE_VALUE) - { if (!kzhashbuf) return(0); srchstat = kzlastfnam; continue; } + { if (!kzhashbuf) return(0); srchstat = kzlastfnam; continue; } if (findata.dwFileAttributes&FILE_ATTRIBUTE_HIDDEN) continue; i = wildstpathleng; if (findata.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) @@ -2967,7 +2999,8 @@ long kzfindfile (char *filnam) if (!hfind) { char *s = "."; - if (wildstpathleng > 0) { + if (wildstpathleng > 0) + { filnam[wildstpathleng] = 0; s = filnam; } @@ -2977,7 +3010,8 @@ long kzfindfile (char *filnam) break; // process srchstat == -2 #endif return(1); - } while (0); + } + while (0); } if (srchstat == -2) while (1) @@ -2985,7 +3019,7 @@ long kzfindfile (char *filnam) memcpy(filnam,wildst,wildstpathleng); #if defined(__DOS__) if (_dos_findnext(&findata)) - { if (!kzhashbuf) return(0); srchstat = kzlastfnam; break; } + { if (!kzhashbuf) return(0); srchstat = kzlastfnam; break; } i = wildstpathleng; if (findata.attrib&16) if ((findata.name[0] == '.') && (!findata.name[1])) continue; @@ -2993,7 +3027,7 @@ long kzfindfile (char *filnam) if (findata.attrib&16) strcat(&filnam[i],"\\"); #elif defined(_WIN32) if (!FindNextFile(hfind,&findata)) - { FindClose(hfind); hfind = INVALID_HANDLE_VALUE; if (!kzhashbuf) return(0); /* srchstat = kzlastfnam; */ break; } + { FindClose(hfind); hfind = INVALID_HANDLE_VALUE; if (!kzhashbuf) return(0); /* srchstat = kzlastfnam; */ break; } if (findata.dwFileAttributes&FILE_ATTRIBUTE_HIDDEN) continue; i = wildstpathleng; if (findata.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) @@ -3002,12 +3036,12 @@ long kzfindfile (char *filnam) if (findata.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) strcat(&filnam[i],"\\"); #else if ((findata = readdir(hfind)) == NULL) - { closedir(hfind); hfind = NULL; if (!kzhashbuf) return 0; srchstat = kzlastfnam; break; } + { closedir(hfind); hfind = NULL; if (!kzhashbuf) return 0; srchstat = kzlastfnam; break; } i = wildstpathleng; if (findata->d_type == DT_DIR) - { if (findata->d_name[0] == '.' && !findata->d_name[1]) continue; } //skip . + { if (findata->d_name[0] == '.' && !findata->d_name[1]) continue; } //skip . else if ((findata->d_type == DT_REG) || (findata->d_type == DT_LNK)) - { if (findata->d_name[0] == '.') continue; } //skip hidden (dot) files + { if (findata->d_name[0] == '.') continue; } //skip hidden (dot) files else continue; //skip devices and fifos and such if (!wildmatch(findata->d_name,&wildst[wildstpathleng])) continue; strcpy(&filnam[i],findata->d_name); @@ -3021,10 +3055,10 @@ long kzfindfile (char *filnam) { //strcpy(filnam,&kzhashbuf[srchstat+16]); filnam[0] = '|'; strcpy(&filnam[1],&kzhashbuf[srchstat+16]); - srchstat = *(long *)&kzhashbuf[srchstat+4]; + srchstat = *(int *)&kzhashbuf[srchstat+4]; return(1); } - srchstat = *(long *)&kzhashbuf[srchstat+4]; + srchstat = *(int *)&kzhashbuf[srchstat+4]; } return(0); } @@ -3040,9 +3074,9 @@ long kzfindfile (char *filnam) // -------------------------------------------------------------------------- static char *gzbufptr; -static void putbuf4zip (const unsigned char *buf, long uncomp0, long uncomp1) +static void putbuf4zip(const unsigned char *buf, int uncomp0, int uncomp1) { - long i0, i1; + int i0, i1; // uncomp0 ... uncomp1 // &gzbufptr[kzfs.pos] ... &gzbufptr[kzfs.endpos]; i0 = max(uncomp0,kzfs.pos); @@ -3051,9 +3085,9 @@ static void putbuf4zip (const unsigned char *buf, long uncomp0, long uncomp1) } //returns number of bytes copied -long kzread (void *buffer, long leng) +int kzread(void *buffer, int leng) { - long i, j, k, bfinal, btype, hlit, hdist; + int i, j, k, bfinal, btype, hlit, hdist; if ((!kzfs.fil) || (leng <= 0)) return(0); @@ -3085,7 +3119,7 @@ long kzread (void *buffer, long leng) kzfs.comptell = min((unsigned)kzfs.compleng,sizeof(olinbuf)); fread(&olinbuf[0],kzfs.comptell,1,kzfs.fil); //Make it re-load when there are < 32 bits left in FIFO - bitpos = -(((long)sizeof(olinbuf)-4)<<3); + bitpos = -(((int)sizeof(olinbuf)-4)<<3); //Identity: filptr + (bitpos>>3) = &olinbuf[0] filptr = &olinbuf[-(bitpos>>3)]; } @@ -3131,11 +3165,11 @@ kzreadplc0: #if 0 //Display Huffman block offsets&lengths of input file - for debugging only! { - static long ouncomppos = 0, ocomppos = 0; + static int ouncomppos = 0, ocomppos = 0; if (kzfs.comptell == sizeof(olinbuf)) i = 0; else if (kzfs.comptell < kzfs.compleng) i = kzfs.comptell-(sizeof(olinbuf)-4); else i = kzfs.comptell-(kzfs.comptell%(sizeof(olinbuf)-4)); - i += ((long)&filptr[bitpos>>3])-((long)(&olinbuf[0])); + i += ((int)&filptr[bitpos>>3])-((int)(&olinbuf[0])); i = (i<<3)+(bitpos&7)-3; if (gslidew) printf(" ULng:0x%08x CLng:0x%08x.%x",gslidew-ouncomppos,(i-ocomppos)>>3,((i-ocomppos)&7)<<1); printf("\ntype:%d, Uoff:0x%08x Coff:0x%08x.%x",btype,gslidew,i>>3,(i&7)<<1); @@ -3195,7 +3229,7 @@ kzreadplc1: i = hufgetsym(ibuf0,nbuf0); if (i < 16) { clen[j++] = i; continue; } if (i == 16) - { for (i=getbits(2)+3;i;i--) { clen[j] = clen[j-1]; j++; } } + { for (i=getbits(2)+3;i;i--) { clen[j] = clen[j-1]; j++; } } else { if (i == 17) i = getbits(3)+3; else i = getbits(7)+11; @@ -3224,21 +3258,22 @@ kzreadplc2: } k = peekbits(LOGQHUFSIZ0); - if (qhufbit0[k]) { i = qhufval0[k]; suckbits((long)qhufbit0[k]); } + if (qhufbit0[k]) { i = qhufval0[k]; suckbits((int)qhufbit0[k]); } else i = hufgetsym(ibuf0,nbuf0); - if (i < 256) { slidebuf[(gslidew++)&32767] = (char)i; continue; } + if (i < 256) { slidebuf[(gslidew++)&32767] = (char)i; continue; } if (i == 256) break; i = getbits(hxbit[i+30-257][0]) + hxbit[i+30-257][1]; k = peekbits(LOGQHUFSIZ1); - if (qhufbit1[k]) { j = qhufval1[k]; suckbits((long)qhufbit1[k]); } + if (qhufbit1[k]) { j = qhufval1[k]; suckbits((int)qhufbit1[k]); } else j = hufgetsym(ibuf1,nbuf1); j = getbits(hxbit[j][0]) + hxbit[j][1]; for (;i;i--,gslidew++) slidebuf[gslidew&32767] = slidebuf[(gslidew-j)&32767]; } - } while (!bfinal); + } + while (!bfinal); gslider -= 16384; if (!((gslider^gslidew)&32768)) @@ -3259,7 +3294,7 @@ retkzread: return(kzfs.pos-i); } -long kzfilelength () +int kzfilelength() { if (!kzfs.fil) return(0); return(kzfs.leng); @@ -3267,7 +3302,7 @@ long kzfilelength () //WARNING: kzseek(<-32768,SEEK_CUR); or: // kzseek(0,SEEK_END); can make next kzread very slow!!! -long kzseek (long offset, long whence) +int kzseek(int offset, int whence) { if (!kzfs.fil) return(-1); switch (whence) @@ -3285,26 +3320,26 @@ long kzseek (long offset, long whence) return(kzfs.pos); } -long kztell () +int kztell() { if (!kzfs.fil) return(-1); return(kzfs.pos); } -long kzgetc () +int kzgetc() { char ch; if (!kzread(&ch,1)) return(-1); - return((long)ch); + return((int)ch); } -long kzeof () +int kzeof() { if (!kzfs.fil) return(-1); return(kzfs.pos >= kzfs.leng); } -void kzclose () +void kzclose() { if (kzfs.fil) { fclose(kzfs.fil); kzfs.fil = 0; } } @@ -3312,10 +3347,10 @@ void kzclose () //====================== ZIP decompression code ends ========================= //===================== HANDY PICTURE function begins ======================== -void kpzload (const char *filnam, long *pic, long *bpl, long *xsiz, long *ysiz) +void kpzload(const char *filnam, int *pic, int *bpl, int *xsiz, int *ysiz) { char *buf; - long leng; + int leng; (*pic) = 0; if (!kzopen(filnam)) return; @@ -3326,7 +3361,7 @@ void kpzload (const char *filnam, long *pic, long *bpl, long *xsiz, long *ysiz) kpgetdim(buf,leng,xsiz,ysiz); (*bpl) = ((*xsiz)<<2); -(*pic) = (long)malloc((*ysiz)*(*bpl)); if (!(*pic)) { free(buf); return; } + (*pic) = (int)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/lzf_c.c b/polymer/build/src/lzf_c.c index 6e1a047d3..3dcda790c 100644 --- a/polymer/build/src/lzf_c.c +++ b/polymer/build/src/lzf_c.c @@ -81,12 +81,12 @@ */ unsigned int -lzf_compress (const void *const in_data, unsigned int in_len, - void *out_data, unsigned int out_len +lzf_compress(const void *const in_data, unsigned int in_len, + void *out_data, unsigned int out_len #if LZF_STATE_ARG - , LZF_STATE *htab + , LZF_STATE *htab #endif - ) + ) { #if !LZF_STATE_ARG LZF_STATE htab; @@ -98,13 +98,13 @@ lzf_compress (const void *const in_data, unsigned int in_len, u8 *out_end = op + out_len; const u8 *ref; - unsigned int hval = FRST (ip); - unsigned long off; + unsigned int hval = FRST(ip); + unsigned int off; int lit = 0; #if INIT_HTAB # if USE_MEMCPY - memset (htab, 0, sizeof (htab)); + memset(htab, 0, sizeof(htab)); # else for (hslot = htab; hslot < htab + HSIZE; hslot++) *hslot++ = ip; @@ -115,8 +115,8 @@ lzf_compress (const void *const in_data, unsigned int in_len, { if (ip < in_end - 2) { - hval = NEXT (hval, ip); - hslot = htab + IDX (hval); + hval = NEXT(hval, ip); + hslot = htab + IDX(hval); ref = *hslot; *hslot = ip; if (1 @@ -166,7 +166,7 @@ lzf_compress (const void *const in_data, unsigned int in_len, } else { - *op++ = (off >> 8) + ( 7 << 5); + *op++ = (off >> 8) + (7 << 5); *op++ = len - 7; } @@ -177,22 +177,22 @@ lzf_compress (const void *const in_data, unsigned int in_len, #if VERY_FAST && !ULTRA_FAST --ip; #endif - hval = FRST (ip); + hval = FRST(ip); - hval = NEXT (hval, ip); - htab[IDX (hval)] = ip; + hval = NEXT(hval, ip); + htab[IDX(hval)] = ip; ip++; #if VERY_FAST && !ULTRA_FAST - hval = NEXT (hval, ip); - htab[IDX (hval)] = ip; + hval = NEXT(hval, ip); + htab[IDX(hval)] = ip; ip++; #endif #else do { - hval = NEXT (hval, ip); - htab[IDX (hval)] = ip; + hval = NEXT(hval, ip); + htab[IDX(hval)] = ip; ip++; } while (len--); @@ -214,7 +214,7 @@ lzf_compress (const void *const in_data, unsigned int in_len, *op++ = MAX_LIT - 1; #if USE_MEMCPY - memcpy (op, ip - MAX_LIT, MAX_LIT); + memcpy(op, ip - MAX_LIT, MAX_LIT); op += MAX_LIT; lit = 0; #else diff --git a/polymer/build/src/lzf_d.c b/polymer/build/src/lzf_d.c index e99055eb5..d2ddb8b7a 100644 --- a/polymer/build/src/lzf_d.c +++ b/polymer/build/src/lzf_d.c @@ -46,8 +46,8 @@ #endif unsigned int -lzf_decompress (const void *const in_data, unsigned int in_len, - void *out_data, unsigned int out_len) +lzf_decompress(const void *const in_data, unsigned int in_len, + void *out_data, unsigned int out_len) { u8 const *ip = (const u8 *)in_data; u8 *op = (u8 *)out_data; @@ -64,12 +64,12 @@ lzf_decompress (const void *const in_data, unsigned int in_len, if (op + ctrl > out_end) { - SET_ERRNO (E2BIG); + SET_ERRNO(E2BIG); return 0; } #if USE_MEMCPY - memcpy (op, ip, ctrl); + memcpy(op, ip, ctrl); op += ctrl; ip += ctrl; #else @@ -91,13 +91,13 @@ lzf_decompress (const void *const in_data, unsigned int in_len, if (op + len + 2 > out_end) { - SET_ERRNO (E2BIG); + SET_ERRNO(E2BIG); return 0; } if (ref < (u8 *)out_data) { - SET_ERRNO (EINVAL); + SET_ERRNO(EINVAL); return 0; } diff --git a/polymer/build/src/lzwnew.c b/polymer/build/src/lzwnew.c index 257b7bd19..a9a4c11ad 100644 --- a/polymer/build/src/lzwnew.c +++ b/polymer/build/src/lzwnew.c @@ -1,27 +1,27 @@ //-------------------------------------------------------------------------------------------------- #if defined(__POWERPC__) -static unsigned long LSWAPIB (unsigned long a) { return(((a>>8)&0xff00)+((a&0xff00)<<8)+(a<<24)+(a>>24)); } -static unsigned short SSWAPIB (unsigned short a) { return((a>>8)+(a<<8)); } +static unsigned int LSWAPIB(unsigned int a) { return(((a>>8)&0xff00)+((a&0xff00)<<8)+(a<<24)+(a>>24)); } +static unsigned short SSWAPIB(unsigned short a) { return((a>>8)+(a<<8)); } #else #define LSWAPIB(a) (a) #define SSWAPIB(a) (a) #endif #define USENEW 1 -long lzwcompress (unsigned char *ucompbuf, long ucompleng, unsigned char *compbuf) +int lzwcompress(unsigned char *ucompbuf, int ucompleng, unsigned char *compbuf) { - long i, j, numnodes, *lptr, bitcnt, nbits, oneupnbits, hmask, *child; - long *sibly; + int i, j, numnodes, *lptr, bitcnt, nbits, oneupnbits, hmask, *child; + int *sibly; #if USENEW - long *sibry; + int *sibry; #endif unsigned char *nodev, *cptr, *eptr; nodev = (unsigned char *)malloc((ucompleng+256)*sizeof(char)); if (!nodev) return(0); -child = (long *)malloc((ucompleng+256)*sizeof(long)); if (!child) { free(nodev); return(0); } - sibly = (long *)malloc((ucompleng+256)*sizeof(long)); if (!sibly) { free(child); free(nodev); return(0); } + child = (int *)malloc((ucompleng+256)*sizeof(int)); if (!child) { free(nodev); return(0); } + sibly = (int *)malloc((ucompleng+256)*sizeof(int)); if (!sibly) { free(child); free(nodev); return(0); } #if USENEW - sibry = (long *)malloc((ucompleng+256)*sizeof(long)); if (!sibry) { free(sibly); free(child); free(nodev); return(0); } + sibry = (int *)malloc((ucompleng+256)*sizeof(int)); if (!sibry) { free(sibly); free(child); free(nodev); return(0); } #endif for (i=255;i>=0;i--) { nodev[i] = i; child[i] = -1; } @@ -35,18 +35,18 @@ child = (long *)malloc((ucompleng+256)*sizeof(long)); if (!child) { free(nodev); for (i=cptr[0];i>=0;i=j) { cptr++; if (cptr >= eptr) goto lzwcompbreak2b; - j = child[i]; if (j < 0) { child[i] = numnodes; break; } + j = child[i]; if (j < 0) { child[i] = numnodes; break; } #if USENEW //This is about 2x faster when ucompbuf is more random, 5% slower when very compressible while (cptr[0] != nodev[j]) { if (cptr[0] < nodev[j]) - { if (sibly[j] < 0) { sibly[j] = numnodes; goto lzwcompbreak2a; } j = sibly[j]; } + { if (sibly[j] < 0) { sibly[j] = numnodes; goto lzwcompbreak2a; } j = sibly[j]; } else { if (sibry[j] < 0) { sibry[j] = numnodes; goto lzwcompbreak2a; } j = sibry[j]; } } #else for (;nodev[j]!=cptr[0];j=sibly[j]) - if (sibly[j] < 0) { sibly[j] = numnodes; goto lzwcompbreak2a; } + if (sibly[j] < 0) { sibly[j] = numnodes; goto lzwcompbreak2a; } #endif } lzwcompbreak2a: @@ -57,11 +57,12 @@ lzwcompbreak2b: sibry[numnodes] = -1; #endif - lptr = (long *)&compbuf[bitcnt>>3]; lptr[0] |= LSWAPIB(i<<(bitcnt&7)); + lptr = (int *)&compbuf[bitcnt>>3]; lptr[0] |= LSWAPIB(i<<(bitcnt&7)); bitcnt += nbits; if ((i&hmask) > ((numnodes-1)&hmask)) bitcnt--; - numnodes++; if (numnodes > oneupnbits) { nbits++; oneupnbits <<= 1; hmask = ((oneupnbits>>1)-1); } - } while ((cptr < eptr) && (bitcnt < (ucompleng<<3))); + numnodes++; if (numnodes > oneupnbits) { nbits++; oneupnbits <<= 1; hmask = ((oneupnbits>>1)-1); } + } + while ((cptr < eptr) && (bitcnt < (ucompleng<<3))); #if USENEW free(sibry); @@ -69,50 +70,52 @@ lzwcompbreak2b: free(sibly); free(child); free(nodev); - lptr = (long *)compbuf; -if (((bitcnt+7)>>3) < ucompleng) { lptr[0] = LSWAPIB(numnodes); return((bitcnt+7)>>3); } + lptr = (int *)compbuf; + if (((bitcnt+7)>>3) < ucompleng) { lptr[0] = LSWAPIB(numnodes); return((bitcnt+7)>>3); } memcpy(compbuf,ucompbuf,ucompleng); return(ucompleng); } -long lzwuncompress (unsigned char *compbuf, long compleng, unsigned char *ucompbuf, long ucompleng) +int lzwuncompress(unsigned char *compbuf, int compleng, unsigned char *ucompbuf, int ucompleng) { - long i, dat, leng, bitcnt, *lptr, numnodes, totnodes, nbits, oneupnbits, hmask, *prefix; + int i, dat, leng, bitcnt, *lptr, numnodes, totnodes, nbits, oneupnbits, hmask, *prefix; unsigned char ch, *ucptr, *suffix; - long ucomp = (long)ucompbuf; + int ucomp = (int)ucompbuf; if (compleng >= ucompleng) { memcpy(ucompbuf,compbuf,ucompleng); return ucompleng; } - totnodes = LSWAPIB(((long *)compbuf)[0]); if (totnodes <= 0 || totnodes >= ucompleng+256) return 0; + totnodes = LSWAPIB(((int *)compbuf)[0]); if (totnodes <= 0 || totnodes >= ucompleng+256) return 0; - prefix = (long *)malloc(totnodes*sizeof(long)); if (!prefix) return 0; -suffix = (unsigned char *)malloc(totnodes*sizeof(char)); if (!suffix) { free(prefix); return 0; } + prefix = (int *)malloc(totnodes*sizeof(int)); if (!prefix) return 0; + suffix = (unsigned char *)malloc(totnodes*sizeof(char)); if (!suffix) { free(prefix); return 0; } numnodes = 256; bitcnt = (4<<3); nbits = 8; oneupnbits = (1<<8); hmask = ((oneupnbits>>1)-1); do { - lptr = (long *)&compbuf[bitcnt>>3]; dat = ((LSWAPIB(lptr[0])>>(bitcnt&7))&(oneupnbits-1)); + lptr = (int *)&compbuf[bitcnt>>3]; dat = ((LSWAPIB(lptr[0])>>(bitcnt&7))&(oneupnbits-1)); bitcnt += nbits; if ((dat&hmask) > ((numnodes-1)&hmask)) { dat &= hmask; bitcnt--; } prefix[numnodes] = dat; ucompbuf++; - for (leng=0;dat>=256;dat=prefix[dat]) { - if ((long)ucompbuf+leng-ucomp > ucompleng) goto bail; + for (leng=0;dat>=256;dat=prefix[dat]) + { + if ((int)ucompbuf+leng-ucomp > ucompleng) goto bail; ucompbuf[leng++] = suffix[dat]; } ucptr = &ucompbuf[leng-1]; - for (i=(leng>>1)-1;i>=0;i--) { ch = ucompbuf[i]; ucompbuf[i] = ucptr[-i]; ucptr[-i] = ch; } + for (i=(leng>>1)-1;i>=0;i--) { ch = ucompbuf[i]; ucompbuf[i] = ucptr[-i]; ucptr[-i] = ch; } ucompbuf[-1] = dat; ucompbuf += leng; suffix[numnodes-1] = suffix[numnodes] = dat; numnodes++; if (numnodes > oneupnbits) { nbits++; oneupnbits <<= 1; hmask = ((oneupnbits>>1)-1); } - } while (numnodes < totnodes); + } + while (numnodes < totnodes); bail: free(suffix); free(prefix); - return (long)ucompbuf-ucomp; + return (int)ucompbuf-ucomp; } //-------------------------------------------------------------------------------------------------- diff --git a/polymer/build/src/md4.c b/polymer/build/src/md4.c index 1aab9dfba..1b2e03237 100644 --- a/polymer/build/src/md4.c +++ b/polymer/build/src/md4.c @@ -26,7 +26,7 @@ typedef unsigned char * POINTER; typedef unsigned short UINT2; -typedef unsigned long UINT4; +typedef unsigned int UINT4; #include "md4.h" #include "compat.h" @@ -46,17 +46,18 @@ typedef unsigned long UINT4; #define S33 11 #define S34 15 -static void MD4Transform (UINT4 [4], unsigned char [64]); -static void Encode (unsigned char *, UINT4 *, unsigned int); -static void Decode (UINT4 *, unsigned char *, unsigned int); +static void MD4Transform(UINT4 [4], unsigned char [64]); +static void Encode(unsigned char *, UINT4 *, unsigned int); +static void Decode(UINT4 *, unsigned char *, unsigned int); #define MD4_memcpy memcpy #define MD4_memset memset -static unsigned char PADDING[64] = { - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; +static unsigned char PADDING[64] = +{ + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; /* F, G and H are basic MD4 functions. */ @@ -94,7 +95,7 @@ void md4once(unsigned char *block, unsigned int len, unsigned char digest[16]) /* MD4 initialization. Begins an MD4 operation, writing a new context. */ -void md4init (MD4_CTX *context) +void md4init(MD4_CTX *context) { context->count[0] = context->count[1] = 0; @@ -110,7 +111,7 @@ void md4init (MD4_CTX *context) operation, processing another message block, and updating the context. */ -void md4block (MD4_CTX *context, unsigned char *input, unsigned int inputLen) +void md4block(MD4_CTX *context, unsigned char *input, unsigned int inputLen) { unsigned int i, index, partLen; @@ -126,13 +127,14 @@ void md4block (MD4_CTX *context, unsigned char *input, unsigned int inputLen) /* Transform as many times as possible. */ - if (inputLen >= partLen) { + if (inputLen >= partLen) + { MD4_memcpy ((POINTER)&context->buffer[index], (POINTER)input, partLen); - MD4Transform (context->state, context->buffer); + MD4Transform(context->state, context->buffer); for (i = partLen; i + 63 < inputLen; i += 64) - MD4Transform (context->state, &input[i]); + MD4Transform(context->state, &input[i]); index = 0; } @@ -148,91 +150,91 @@ void md4block (MD4_CTX *context, unsigned char *input, unsigned int inputLen) /* MD4 finalization. Ends an MD4 message-digest operation, writing the the message digest and zeroizing the context. */ -void md4finish (unsigned char digest[16], MD4_CTX *context) +void md4finish(unsigned char digest[16], MD4_CTX *context) { unsigned char bits[8]; unsigned int index, padLen; /* Save number of bits */ - Encode (bits, context->count, 8); + Encode(bits, context->count, 8); /* Pad out to 56 mod 64. */ index = (unsigned int)((context->count[0] >> 3) & 0x3f); padLen = (index < 56) ? (56 - index) : (120 - index); - md4block (context, PADDING, padLen); + md4block(context, PADDING, padLen); /* Append length (before padding) */ - md4block (context, bits, 8); + md4block(context, bits, 8); /* Store state in digest */ - Encode (digest, context->state, 16); + Encode(digest, context->state, 16); /* Zeroize sensitive information. */ - MD4_memset ((POINTER)context, 0, sizeof (*context)); + MD4_memset((POINTER)context, 0, sizeof(*context)); } /* MD4 basic transformation. Transforms state based on block. */ -static void MD4Transform (UINT4 state[4], unsigned char block[64]) +static void MD4Transform(UINT4 state[4], unsigned char block[64]) { UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; - Decode (x, block, 64); + Decode(x, block, 64); /* Round 1 */ - FF (a, b, c, d, x[ 0], S11); /* 1 */ - FF (d, a, b, c, x[ 1], S12); /* 2 */ - FF (c, d, a, b, x[ 2], S13); /* 3 */ - FF (b, c, d, a, x[ 3], S14); /* 4 */ - FF (a, b, c, d, x[ 4], S11); /* 5 */ - FF (d, a, b, c, x[ 5], S12); /* 6 */ - FF (c, d, a, b, x[ 6], S13); /* 7 */ - FF (b, c, d, a, x[ 7], S14); /* 8 */ - FF (a, b, c, d, x[ 8], S11); /* 9 */ - FF (d, a, b, c, x[ 9], S12); /* 10 */ - FF (c, d, a, b, x[10], S13); /* 11 */ - FF (b, c, d, a, x[11], S14); /* 12 */ - FF (a, b, c, d, x[12], S11); /* 13 */ - FF (d, a, b, c, x[13], S12); /* 14 */ - FF (c, d, a, b, x[14], S13); /* 15 */ - FF (b, c, d, a, x[15], S14); /* 16 */ + FF(a, b, c, d, x[ 0], S11); /* 1 */ + FF(d, a, b, c, x[ 1], S12); /* 2 */ + FF(c, d, a, b, x[ 2], S13); /* 3 */ + FF(b, c, d, a, x[ 3], S14); /* 4 */ + FF(a, b, c, d, x[ 4], S11); /* 5 */ + FF(d, a, b, c, x[ 5], S12); /* 6 */ + FF(c, d, a, b, x[ 6], S13); /* 7 */ + FF(b, c, d, a, x[ 7], S14); /* 8 */ + FF(a, b, c, d, x[ 8], S11); /* 9 */ + FF(d, a, b, c, x[ 9], S12); /* 10 */ + FF(c, d, a, b, x[10], S13); /* 11 */ + FF(b, c, d, a, x[11], S14); /* 12 */ + FF(a, b, c, d, x[12], S11); /* 13 */ + FF(d, a, b, c, x[13], S12); /* 14 */ + FF(c, d, a, b, x[14], S13); /* 15 */ + FF(b, c, d, a, x[15], S14); /* 16 */ /* Round 2 */ - GG (a, b, c, d, x[ 0], S21); /* 17 */ - GG (d, a, b, c, x[ 4], S22); /* 18 */ - GG (c, d, a, b, x[ 8], S23); /* 19 */ - GG (b, c, d, a, x[12], S24); /* 20 */ - GG (a, b, c, d, x[ 1], S21); /* 21 */ - GG (d, a, b, c, x[ 5], S22); /* 22 */ - GG (c, d, a, b, x[ 9], S23); /* 23 */ - GG (b, c, d, a, x[13], S24); /* 24 */ - GG (a, b, c, d, x[ 2], S21); /* 25 */ - GG (d, a, b, c, x[ 6], S22); /* 26 */ - GG (c, d, a, b, x[10], S23); /* 27 */ - GG (b, c, d, a, x[14], S24); /* 28 */ - GG (a, b, c, d, x[ 3], S21); /* 29 */ - GG (d, a, b, c, x[ 7], S22); /* 30 */ - GG (c, d, a, b, x[11], S23); /* 31 */ - GG (b, c, d, a, x[15], S24); /* 32 */ + GG(a, b, c, d, x[ 0], S21); /* 17 */ + GG(d, a, b, c, x[ 4], S22); /* 18 */ + GG(c, d, a, b, x[ 8], S23); /* 19 */ + GG(b, c, d, a, x[12], S24); /* 20 */ + GG(a, b, c, d, x[ 1], S21); /* 21 */ + GG(d, a, b, c, x[ 5], S22); /* 22 */ + GG(c, d, a, b, x[ 9], S23); /* 23 */ + GG(b, c, d, a, x[13], S24); /* 24 */ + GG(a, b, c, d, x[ 2], S21); /* 25 */ + GG(d, a, b, c, x[ 6], S22); /* 26 */ + GG(c, d, a, b, x[10], S23); /* 27 */ + GG(b, c, d, a, x[14], S24); /* 28 */ + GG(a, b, c, d, x[ 3], S21); /* 29 */ + GG(d, a, b, c, x[ 7], S22); /* 30 */ + GG(c, d, a, b, x[11], S23); /* 31 */ + GG(b, c, d, a, x[15], S24); /* 32 */ /* Round 3 */ - HH (a, b, c, d, x[ 0], S31); /* 33 */ - HH (d, a, b, c, x[ 8], S32); /* 34 */ - HH (c, d, a, b, x[ 4], S33); /* 35 */ - HH (b, c, d, a, x[12], S34); /* 36 */ - HH (a, b, c, d, x[ 2], S31); /* 37 */ - HH (d, a, b, c, x[10], S32); /* 38 */ - HH (c, d, a, b, x[ 6], S33); /* 39 */ - HH (b, c, d, a, x[14], S34); /* 40 */ - HH (a, b, c, d, x[ 1], S31); /* 41 */ - HH (d, a, b, c, x[ 9], S32); /* 42 */ - HH (c, d, a, b, x[ 5], S33); /* 43 */ - HH (b, c, d, a, x[13], S34); /* 44 */ - HH (a, b, c, d, x[ 3], S31); /* 45 */ - HH (d, a, b, c, x[11], S32); /* 46 */ - HH (c, d, a, b, x[ 7], S33); /* 47 */ - HH (b, c, d, a, x[15], S34); /* 48 */ + HH(a, b, c, d, x[ 0], S31); /* 33 */ + HH(d, a, b, c, x[ 8], S32); /* 34 */ + HH(c, d, a, b, x[ 4], S33); /* 35 */ + HH(b, c, d, a, x[12], S34); /* 36 */ + HH(a, b, c, d, x[ 2], S31); /* 37 */ + HH(d, a, b, c, x[10], S32); /* 38 */ + HH(c, d, a, b, x[ 6], S33); /* 39 */ + HH(b, c, d, a, x[14], S34); /* 40 */ + HH(a, b, c, d, x[ 1], S31); /* 41 */ + HH(d, a, b, c, x[ 9], S32); /* 42 */ + HH(c, d, a, b, x[ 5], S33); /* 43 */ + HH(b, c, d, a, x[13], S34); /* 44 */ + HH(a, b, c, d, x[ 3], S31); /* 45 */ + HH(d, a, b, c, x[11], S32); /* 46 */ + HH(c, d, a, b, x[ 7], S33); /* 47 */ + HH(b, c, d, a, x[15], S34); /* 48 */ state[0] += a; state[1] += b; @@ -241,17 +243,18 @@ static void MD4Transform (UINT4 state[4], unsigned char block[64]) /* Zeroize sensitive information. */ - MD4_memset ((POINTER)x, 0, sizeof (x)); + MD4_memset((POINTER)x, 0, sizeof(x)); } /* Encodes input (UINT4) into output (unsigned char). Assumes len is a multiple of 4. */ -static void Encode (unsigned char *output, UINT4 *input, unsigned int len) +static void Encode(unsigned char *output, UINT4 *input, unsigned int len) { unsigned int i, j; - for (i = 0, j = 0; j < len; i++, j += 4) { + for (i = 0, j = 0; j < len; i++, j += 4) + { output[j] = (unsigned char)(input[i] & 0xff); output[j+1] = (unsigned char)((input[i] >> 8) & 0xff); output[j+2] = (unsigned char)((input[i] >> 16) & 0xff); @@ -262,7 +265,7 @@ static void Encode (unsigned char *output, UINT4 *input, unsigned int len) /* Decodes input (unsigned char) into output (UINT4). Assumes len is a multiple of 4. */ -static void Decode (UINT4 *output, unsigned char *input, unsigned int len) +static void Decode(UINT4 *output, unsigned char *input, unsigned int len) { unsigned int i, j; diff --git a/polymer/build/src/mdsprite.c b/polymer/build/src/mdsprite.c index 8f867199b..b30a3e5be 100644 --- a/polymer/build/src/mdsprite.c +++ b/polymer/build/src/mdsprite.c @@ -8,8 +8,8 @@ typedef struct { - long mdnum; //VOX=1, MD2=2, MD3=3. NOTE: must be first in structure! - long shadeoff; + int mdnum; //VOX=1, MD2=2, MD3=3. NOTE: must be first in structure! + int shadeoff; float scale, bscale, zadd; GLuint *texid; // skins } mdmodel; @@ -43,9 +43,9 @@ typedef struct { float x, y, z; } point3d; typedef struct { - long id, vers, skinxsiz, skinysiz, framebytes; //id:"IPD2", vers:8 - long numskins, numverts, numuv, numtris, numglcmds, numframes; - long ofsskins, ofsuv, ofstris, ofsframes, ofsglcmds, ofseof; //ofsskins: skin names (64 bytes each) + int id, vers, skinxsiz, skinysiz, framebytes; //id:"IPD2", vers:8 + int numskins, numverts, numuv, numtris, numglcmds, numframes; + int ofsskins, ofsuv, ofstris, ofsframes, ofsglcmds, ofseof; //ofsskins: skin names (64 bytes each) } md2head_t; typedef struct { unsigned char v[3], ni; } md2vert_t; //compressed vertex coords (x,y,z) @@ -66,19 +66,19 @@ typedef struct typedef struct { //WARNING: This top block is a union between md2model&md3model: Make sure it matches! - long mdnum; //VOX=1, MD2=2, MD3=3. NOTE: must be first in structure! - long shadeoff; + int mdnum; //VOX=1, MD2=2, MD3=3. NOTE: must be first in structure! + int shadeoff; float scale, bscale, zadd; GLuint *texid; // texture ids for base skin if no mappings defined - long numframes, cframe, nframe, fpssc, usesalpha; + int numframes, cframe, nframe, fpssc, usesalpha; float oldtime, curtime, interpol; mdanim_t *animations; mdskinmap_t *skinmap; - long numskins, skinloaded; // set to 1+numofskin when a skin is loaded and the tex coords are modified, + int numskins, skinloaded; // set to 1+numofskin when a skin is loaded and the tex coords are modified, //MD2 specific stuff: - long numverts, numglcmds, framebytes, *glcmds; + int numverts, numglcmds, framebytes, *glcmds; char *frames; char *basepath; // pointer to string of base path char *skinfn; // pointer to first of numskins 64-char strings @@ -87,8 +87,8 @@ typedef struct } md2model; -typedef struct { char nam[64]; long i; } md3shader_t; //ascz path of shader, shader index -typedef struct { long i[3]; } md3tri_t; //indices of tri +typedef struct { char nam[64]; int i; } md3shader_t; //ascz path of shader, shader index +typedef struct { int i[3]; } md3tri_t; //indices of tri typedef struct { float u, v; } md3uv_t; typedef struct { signed short x, y, z; unsigned char nlat, nlng; } md3xyzn_t; //xyz are [10:6] ints @@ -107,42 +107,42 @@ typedef struct typedef struct { - long id; //IDP3(0x33806873) + int id; //IDP3(0x33806873) char nam[64]; //ascz surface name - long flags; //? - long numframes, numshaders, numverts, numtris; //numframes same as md3head,max shade=~256,vert=~4096,tri=~8192 + int flags; //? + int numframes, numshaders, numverts, numtris; //numframes same as md3head,max shade=~256,vert=~4096,tri=~8192 md3tri_t *tris; //file format: rel offs from md3surf md3shader_t *shaders; //file format: rel offs from md3surf md3uv_t *uv; //file format: rel offs from md3surf md3xyzn_t *xyzn; //file format: rel offs from md3surf - long ofsend; + int ofsend; } md3surf_t; typedef struct { - long id, vers; //id=IDP3(0x33806873), vers=15 + int id, vers; //id=IDP3(0x33806873), vers=15 char nam[64]; //ascz path in PK3 - long flags; //? - long numframes, numtags, numsurfs, numskins; //max=~1024,~16,~32,numskins=artifact of MD2; use shader field instead + int flags; //? + int numframes, numtags, numsurfs, numskins; //max=~1024,~16,~32,numskins=artifact of MD2; use shader field instead md3frame_t *frames; //file format: abs offs md3tag_t *tags; //file format: abs offs md3surf_t *surfs; //file format: abs offs - long eof; //file format: abs offs + int eof; //file format: abs offs } md3head_t; typedef struct { //WARNING: This top block is a union between md2model&md3model: Make sure it matches! - long mdnum; //VOX=1, MD2=2, MD3=3. NOTE: must be first in structure! - long shadeoff; + int mdnum; //VOX=1, MD2=2, MD3=3. NOTE: must be first in structure! + int shadeoff; float scale, bscale, zadd; unsigned int *texid; // texture ids for base skin if no mappings defined - long numframes, cframe, nframe, fpssc, usesalpha; + int numframes, cframe, nframe, fpssc, usesalpha; float oldtime, curtime, interpol; mdanim_t *animations; mdskinmap_t *skinmap; - long numskins, skinloaded; // set to 1+numofskin when a skin is loaded and the tex coords are modified, + int numskins, skinloaded; // set to 1+numofskin when a skin is loaded and the tex coords are modified, //MD3 specific md3head_t head; @@ -164,22 +164,23 @@ typedef struct { vert_t v[4]; } voxrect_t; typedef struct { //WARNING: This top block is a union of md2model,md3model,voxmodel: Make sure it matches! - long mdnum; //VOX=1, MD2=2, MD3=3. NOTE: must be first in structure! - long shadeoff; + int mdnum; //VOX=1, MD2=2, MD3=3. NOTE: must be first in structure! + int shadeoff; float scale, bscale, zadd; unsigned int *texid; // skins for palettes //VOX specific stuff: - voxrect_t *quad; long qcnt, qfacind[7]; - long *mytex, mytexx, mytexy; - long xsiz, ysiz, zsiz; + voxrect_t *quad; int qcnt, qfacind[7]; + int *mytex, mytexx, mytexy; + int xsiz, ysiz, zsiz; float xpiv, ypiv, zpiv; - long is8bit; + int is8bit; } voxmodel; static voxmodel *voxmodels[MAXVOXELS]; typedef struct -{ // maps build tiles to particular animation frames of a model +{ + // maps build tiles to particular animation frames of a model int modelid; int skinnum; int framenum; // calculate the number from the name when declaring @@ -194,24 +195,24 @@ hudtyp hudmem[2][MAXTILES]; //~320KB ... ok for now ... could replace with dynam static char mdinited=0; #define MODELALLOCGROUP 256 -static long nummodelsalloced = 0, nextmodelid = 0; +static int nummodelsalloced = 0, nextmodelid = 0; static mdmodel **models = NULL; -static long maxmodelverts = 0, allocmodelverts = 0; -static long maxmodeltris = 0, allocmodeltris = 0; +static int maxmodelverts = 0, allocmodelverts = 0; +static int maxmodeltris = 0, allocmodeltris = 0; static point3d *vertlist = NULL; //temp array to store interpolated vertices for drawing -static long allocvbos = 0, curvbo = 0; +static int allocvbos = 0, curvbo = 0; static GLuint* vertvbos = NULL; static GLuint* indexvbos = NULL; -mdmodel *mdload (const char *); -int mddraw (spritetype *); -void mdfree (mdmodel *); +mdmodel *mdload(const char *); +int mddraw(spritetype *); +void mdfree(mdmodel *); extern int timerticspersec; -static void freeallmodels () +static void freeallmodels() { int i; @@ -243,7 +244,7 @@ static void freeallmodels () } } -static void clearskins () +static void clearskins() { mdmodel *m; int i, j; @@ -251,13 +252,17 @@ static void clearskins () for (i=0;imdnum == 1) { + if (m->mdnum == 1) + { voxmodel *v = (voxmodel*)m; - for (j=0;jtexid[j]) bglDeleteTextures(1,(GLuint*)&v->texid[j]); v->texid[j] = 0; } - } else if (m->mdnum == 2 || m->mdnum == 3) { + } + else if (m->mdnum == 2 || m->mdnum == 3) + { md2model *m2 = (md2model*)m; mdskinmap_t *sk; for (j=0;jnumskins*(HICEFFECTMASK+1);j++) @@ -278,21 +283,22 @@ static void clearskins () for (i=0;itexid[j]) bglDeleteTextures(1,(GLuint*)&v->texid[j]); v->texid[j] = 0; } } } -static void mdinit () +static void mdinit() { memset(hudmem,0,sizeof(hudmem)); freeallmodels(); mdinited = 1; } -int md_loadmodel (const char *fn) +int md_loadmodel(const char *fn) { mdmodel *vm, **ml; @@ -309,13 +315,13 @@ int md_loadmodel (const char *fn) return(nextmodelid-1); } -int md_setmisc (int modelid, float scale, int shadeoff, float zadd) +int md_setmisc(int modelid, float scale, int shadeoff, float zadd) { mdmodel *m; if (!mdinited) mdinit(); - if ((unsigned long)modelid >= (unsigned long)nextmodelid) return -1; + if ((unsigned int)modelid >= (unsigned int)nextmodelid) return -1; m = models[modelid]; m->bscale = scale; m->shadeoff = shadeoff; @@ -324,13 +330,13 @@ int md_setmisc (int modelid, float scale, int shadeoff, float zadd) return 0; } -int md_tilehasmodel (int tilenume) +int md_tilehasmodel(int tilenume) { if (!mdinited) return -1; return tile2model[tilenume].modelid; } -static long framename2index (mdmodel *vm, const char *nam) +static int framename2index(mdmodel *vm, const char *nam) { int i = 0; @@ -358,7 +364,7 @@ static long framename2index (mdmodel *vm, const char *nam) return(i); } -int md_defineframe (int modelid, const char *framename, int tilenume, int skinnum, float smoothduration) +int md_defineframe(int modelid, const char *framename, int tilenume, int skinnum, float smoothduration) { void *vm; md2model *m; @@ -366,12 +372,13 @@ int md_defineframe (int modelid, const char *framename, int tilenume, int skinnu if (!mdinited) mdinit(); - if ((unsigned long)modelid >= (unsigned long)nextmodelid) return(-1); - if ((unsigned long)tilenume >= (unsigned long)MAXTILES) return(-2); + if ((unsigned int)modelid >= (unsigned int)nextmodelid) return(-1); + if ((unsigned int)tilenume >= (unsigned int)MAXTILES) return(-2); if (!framename) return(-3); m = (md2model *)models[modelid]; - if (m->mdnum == 1) { + if (m->mdnum == 1) + { tile2model[tilenume].modelid = modelid; tile2model[tilenume].framenum = tile2model[tilenume].skinnum = 0; return 0; @@ -388,7 +395,7 @@ int md_defineframe (int modelid, const char *framename, int tilenume, int skinnu return 0; } -int md_defineanimation (int modelid, const char *framestart, const char *frameend, int fpssc, int flags) +int md_defineanimation(int modelid, const char *framestart, const char *frameend, int fpssc, int flags) { md2model *m; mdanim_t ma, *map; @@ -396,7 +403,7 @@ int md_defineanimation (int modelid, const char *framestart, const char *frameen if (!mdinited) mdinit(); - if ((unsigned long)modelid >= (unsigned long)nextmodelid) return(-1); + if ((unsigned int)modelid >= (unsigned int)nextmodelid) return(-1); memset(&ma, 0, sizeof(ma)); m = (md2model *)models[modelid]; @@ -425,14 +432,14 @@ int md_defineanimation (int modelid, const char *framestart, const char *frameen return(0); } -int md_defineskin (int modelid, const char *skinfn, int palnum, int skinnum, int surfnum, float param) +int md_defineskin(int modelid, const char *skinfn, int palnum, int skinnum, int surfnum, float param) { mdskinmap_t *sk, *skl; md2model *m; if (!mdinited) mdinit(); - if ((unsigned long)modelid >= (unsigned long)nextmodelid) return -1; + if ((unsigned int)modelid >= (unsigned int)nextmodelid) return -1; if (!skinfn) return -2; if ((unsigned)palnum >= (unsigned)MAXPALOOKUPS) return -3; @@ -443,13 +450,15 @@ int md_defineskin (int modelid, const char *skinfn, int palnum, int skinnum, int skl = NULL; for (sk = m->skinmap; sk; skl = sk, sk = sk->next) if (sk->palette == (unsigned char)palnum && skinnum == sk->skinnum && surfnum == sk->surfnum) break; - if (!sk) { + if (!sk) + { sk = (mdskinmap_t *)calloc(1,sizeof(mdskinmap_t)); if (!sk) return -4; if (!skl) m->skinmap = sk; else skl->next = sk; - } else if (sk->fn) free(sk->fn); + } + else if (sk->fn) free(sk->fn); sk->palette = (unsigned char)palnum; sk->skinnum = skinnum; @@ -462,12 +471,12 @@ int md_defineskin (int modelid, const char *skinfn, int palnum, int skinnum, int return 0; } -int md_definehud (int modelid, int tilex, double xadd, double yadd, double zadd, double angadd, int flags) +int md_definehud(int modelid, int tilex, double xadd, double yadd, double zadd, double angadd, int flags) { if (!mdinited) mdinit(); - if ((unsigned long)modelid >= (unsigned long)nextmodelid) return -1; - if ((unsigned long)tilex >= (unsigned long)MAXTILES) return -2; + if ((unsigned int)modelid >= (unsigned int)nextmodelid) return -1; + if ((unsigned int)tilex >= (unsigned int)MAXTILES) return -2; hudmem[(flags>>2)&1][tilex].xadd = xadd; hudmem[(flags>>2)&1][tilex].yadd = yadd; @@ -491,13 +500,14 @@ int md_undefinemodel(int modelid) { int i; if (!mdinited) return 0; - if ((unsigned long)modelid >= (unsigned long)nextmodelid) return -1; + if ((unsigned int)modelid >= (unsigned int)nextmodelid) return -1; for (i=MAXTILES-1; i>=0; i--) if (tile2model[i].modelid == modelid) tile2model[i].modelid = -1; - if (models) { + if (models) + { mdfree(models[modelid]); models[modelid] = NULL; } @@ -505,12 +515,12 @@ int md_undefinemodel(int modelid) return 0; } -static int daskinloader (long filh, long *fptr, long *bpl, long *sizx, long *sizy, long *osizx, long *osizy, char *hasalpha, char effect) +static int daskinloader(int filh, int *fptr, int *bpl, int *sizx, int *sizy, int *osizx, int *osizy, char *hasalpha, char effect) { - long picfillen, j,y,x; + int picfillen, j,y,x; char *picfil,*cptr,al=255; coltype *pic; - long xsiz, ysiz, tsizx, tsizy; + int xsiz, ysiz, tsizx, tsizy; picfillen = kfilelength(filh); picfil = (char *)malloc(picfillen); if (!picfil) { return -1; } @@ -522,10 +532,13 @@ static int daskinloader (long filh, long *fptr, long *bpl, long *sizx, long *siz kpgetdim(picfil,picfillen,&tsizx,&tsizy); if (tsizx == 0 || tsizy == 0) { free(picfil); return -1; } - if (!glinfo.texnpot) { + if (!glinfo.texnpot) + { for (xsiz=1;xsiz=0;j--) { + if (!glinfo.bgra) + { + for (j=xsiz*ysiz-1;j>=0;j--) + { swapchar(&pic[j].r, &pic[j].b); } } @@ -576,20 +593,21 @@ static int daskinloader (long filh, long *fptr, long *bpl, long *sizx, long *siz *sizx = xsiz; *sizy = ysiz; *bpl = xsiz; - *fptr = (long)pic; + *fptr = (int)pic; *hasalpha = (al != 255); return 0; } // JONOF'S COMPRESSED TEXTURE CACHE STUFF --------------------------------------------------- -long mdloadskin_trytexcache(char *fn, long len, char effect, texcacheheader *head) +int mdloadskin_trytexcache(char *fn, int len, char effect, texcacheheader *head) { - long fil, fp; + int fil, fp; char cachefn[BMAX_PATH], *cp; unsigned char mdsum[16]; if (!glinfo.texcompr || !glusetexcompr || !glusetexcache) return -1; - if (!bglCompressedTexImage2DARB || !bglGetCompressedTexImageARB) { + if (!bglCompressedTexImage2DARB || !bglGetCompressedTexImageARB) + { // lacking the necessary extensions to do this initprintf("Warning: the GL driver lacks necessary functions to use caching\n"); glusetexcache = 0; @@ -600,7 +618,7 @@ long mdloadskin_trytexcache(char *fn, long len, char effect, texcacheheader *hea for (cp = cachefn, fp = 0; (*cp = TEXCACHEDIR[fp]); cp++,fp++); *(cp++) = '/'; for (fp = 0; fp < 16; phex(mdsum[fp++], cp), cp+=2); - sprintf(cp, "-%lx-0%x", len, effect); + sprintf(cp, "-%x-0%x", len, effect); fil = kopen4load(cachefn, 0); if (fil < 0) return -1; @@ -622,15 +640,16 @@ failure: return -1; } -static long mdloadskin_cached(long fil, texcacheheader *head, long *doalloc, GLuint *glpic, long *xsiz, long *ysiz) +static int mdloadskin_cached(int fil, texcacheheader *head, int *doalloc, GLuint *glpic, int *xsiz, int *ysiz) { int level, r; texcachepicture pict; void *pic = NULL, *packbuf = NULL; void *midbuf = NULL; - long alloclen=0; + int alloclen=0; - if (*doalloc&1) { + if (*doalloc&1) + { bglGenTextures(1,glpic); //# of textures (make OpenGL allocate structure) *doalloc |= 2; // prevents bglGenTextures being called again if we fail in here } @@ -639,7 +658,8 @@ static long mdloadskin_cached(long fil, texcacheheader *head, long *doalloc, GLu bglGetError(); // load the mipmaps - for (level = 0; level==0 || (pict.xdim > 1 || pict.ydim > 1); level++) { + for (level = 0; level==0 || (pict.xdim > 1 || pict.ydim > 1); level++) + { r = kread(fil, &pict, sizeof(texcachepicture)); if (r < (int)sizeof(texcachepicture)) goto failure; @@ -650,9 +670,10 @@ static long mdloadskin_cached(long fil, texcacheheader *head, long *doalloc, GLu pict.border = B_LITTLE32(pict.border); pict.depth = B_LITTLE32(pict.depth); - if (level == 0) { *xsiz = pict.xdim; *ysiz = pict.ydim; } + if (level == 0) { *xsiz = pict.xdim; *ysiz = pict.ydim; } - if (alloclen < pict.size) { + if (alloclen < pict.size) + { void *picc = realloc(pic, pict.size); if (!picc) goto failure; else pic = picc; alloclen = pict.size; @@ -684,15 +705,15 @@ failure: // --------------------------------------------------- JONOF'S COMPRESSED TEXTURE CACHE STUFF //Note: even though it says md2model, it works for both md2model&md3model -static long mdloadskin (md2model *m, int number, int pal, int surf) +static int mdloadskin(md2model *m, int number, int pal, int surf) { - long i,j, fptr=0, bpl, xsiz=0, ysiz=0, osizx, osizy, texfmt = GL_RGBA, intexfmt = GL_RGBA; + int i,j, fptr=0, bpl, xsiz=0, ysiz=0, osizx, osizy, texfmt = GL_RGBA, intexfmt = GL_RGBA; char *skinfile, hasalpha, fn[BMAX_PATH+65]; GLuint *texidx = NULL; mdskinmap_t *sk, *skzero = NULL; - long doalloc = 1, filh; + int doalloc = 1, filh; - long cachefil = -1, picfillen; + int cachefil = -1, picfillen; texcacheheader cachead; if (m->mdnum == 2) surf = 0; @@ -753,7 +774,8 @@ static long mdloadskin (md2model *m, int number, int pal, int surf) *texidx = 0; - if ((filh = kopen4load(fn, 0)) < 0) { + if ((filh = kopen4load(fn, 0)) < 0) + { initprintf("Skin %s not found.\n",fn); skinfile[0] = 0; return 0; @@ -763,14 +785,17 @@ static long mdloadskin (md2model *m, int number, int pal, int surf) kclose(filh); // FIXME: shouldn't have to do this. bug in cache1d.c cachefil = mdloadskin_trytexcache(fn, picfillen, hictinting[pal].f, &cachead); - if (cachefil >= 0 && !mdloadskin_cached(cachefil, &cachead, &doalloc, texidx, &xsiz, &ysiz)) { + if (cachefil >= 0 && !mdloadskin_cached(cachefil, &cachead, &doalloc, texidx, &xsiz, &ysiz)) + { osizx = cachead.xdim; osizy = cachead.ydim; m->usesalpha = hasalpha = (cachead.flags & 2) ? 1 : 0; kclose(cachefil); //kclose(filh); // FIXME: uncomment when cache1d.c is fixed // cachefil >= 0, so it won't be rewritten - } else { + } + else + { if (cachefil >= 0) kclose(cachefil); cachefil = -1; // the compressed version will be saved to disk @@ -781,7 +806,8 @@ static long mdloadskin (md2model *m, int number, int pal, int surf) initprintf("Failed loading skin file \"%s\"\n", fn); skinfile[0] = 0; return(0); - } else kclose(filh); + } + else kclose(filh); m->usesalpha = hasalpha; if ((doalloc&3)==1) bglGenTextures(1,(GLuint*)texidx); @@ -804,7 +830,7 @@ static long mdloadskin (md2model *m, int number, int pal, int surf) fy = ((float)osizy)/((float)ysiz); if (m->mdnum == 2) { - long *lptr; + int *lptr; for (lptr=m->glcmds;(i=*lptr++);) for (i=labs(i);i>0;i--,lptr+=3) { @@ -816,7 +842,7 @@ static long mdloadskin (md2model *m, int number, int pal, int surf) { md3model *m3 = (md3model *)m; md3surf_t *s; - long surfi; + int surfi; for (surfi=0;surfihead.numsurfs;surfi++) { s = &m3->head.surfs[surfi]; @@ -838,12 +864,14 @@ static long mdloadskin (md2model *m, int number, int pal, int surf) bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT); bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT); - if (cachefil < 0) { + if (cachefil < 0) + { // save off the compressed version cachead.xdim = osizx; cachead.ydim = osizy; i = 0; - for (j=0;j<31;j++) { + for (j=0;j<31;j++) + { if (xsiz == pow2long[j]) { i |= 1; } if (ysiz == pow2long[j]) { i |= 2; } } @@ -857,10 +885,10 @@ static long mdloadskin (md2model *m, int number, int pal, int surf) int mdpause; //Note: even though it says md2model, it works for both md2model&md3model -static void updateanimation (md2model *m, spritetype *tspr) +static void updateanimation(md2model *m, spritetype *tspr) { mdanim_t *anim; - long i, j, k; + int i, j, k; int fps; if (mdpause) @@ -877,7 +905,8 @@ static void updateanimation (md2model *m, spritetype *tspr) for (anim = m->animations; anim && anim->startframe != m->cframe; anim = anim->next) ; - if (!anim) { + if (!anim) + { if (r_animsmoothing && (tile2model[tspr->picnum].smoothduration != 0) && (spritesmooth[tspr->owner].mdoldframe != m->cframe)) { if (spritesmooth[tspr->owner].mdsmooth == 0) @@ -911,7 +940,7 @@ static void updateanimation (md2model *m, spritetype *tspr) } } - if (anim && (((long)spriteext[tspr->owner].mdanimcur) != anim->startframe || (spriteext[tspr->owner].flags & SPREXT_NOMDANIM))) + if (anim && (((int)spriteext[tspr->owner].mdanimcur) != anim->startframe || (spriteext[tspr->owner].flags & SPREXT_NOMDANIM))) { //if (spriteext[tspr->owner].flags & SPREXT_NOMDANIM) OSD_Printf("SPREXT_NOMDANIM\n"); //OSD_Printf("smooth launched ! oldanim %i new anim %i\n", spriteext[tspr->owner].mdanimcur, anim->startframe); @@ -940,7 +969,7 @@ static void updateanimation (md2model *m, spritetype *tspr) j = 65536; else j = ((anim->endframe+1-anim->startframe)<<16); - //Just in case you play the game for a VERY long time... + //Just in case you play the game for a VERY int time... if (i < 0) { i = 0; spriteext[tspr->owner].mdanimtims = mdtims; } //compare with j*2 instead of j to ensure i stays > j-65536 for MDANIM_ONESHOT if ((anim) && (i >= j+j) && (fps)) //Keep mdanimtims close to mdtims to avoid the use of MOD @@ -949,8 +978,8 @@ static void updateanimation (md2model *m, spritetype *tspr) k = i; if (anim && (anim->flags&MDANIM_ONESHOT)) - { if (i > j-65536) i = j-65536; } -else { if (i >= j) { i -= j; if (i >= j) i %= j; } } + { if (i > j-65536) i = j-65536; } + else { if (i >= j) { i -= j; if (i >= j) i %= j; } } if (r_animsmoothing && spritesmooth[tspr->owner].mdsmooth) { @@ -980,7 +1009,7 @@ else { if (i >= j) { i -= j; if (i >= j) i %= j; } } } // VBO generation and allocation -static void mdloadvbos (md3model *m) +static void mdloadvbos(md3model *m) { int i; @@ -998,9 +1027,9 @@ static void mdloadvbos (md3model *m) } //--------------------------------------- MD2 LIBRARY BEGINS --------------------------------------- -static long long memoryusage = 0; +static int memoryusage = 0; -static md2model *md2load (int fil, const char *filnam) +static md2model *md2load(int fil, const char *filnam) { md2model *m; md3model *m3; @@ -1008,7 +1037,7 @@ static md2model *md2load (int fil, const char *filnam) md2frame_t *f; md2head_t head; char *buf, st[BMAX_PATH]; - long i, j, k; + int i, j, k; m = (md2model *)calloc(1,sizeof(md2model)); if (!m) return(0); m->mdnum = 2; m->scale = .01; @@ -1024,7 +1053,7 @@ static md2model *md2load (int fil, const char *filnam) head.ofsframes = B_LITTLE32(head.ofsframes); head.ofsglcmds = B_LITTLE32(head.ofsglcmds); head.ofseof = B_LITTLE32(head.ofseof); -if ((head.id != 0x32504449) || (head.vers != 8)) { free(m); return(0); } //"IDP2" + if ((head.id != 0x32504449) || (head.vers != 8)) { free(m); return(0); } //"IDP2" m->numskins = head.numskins; m->numframes = head.numframes; @@ -1033,40 +1062,42 @@ if ((head.id != 0x32504449) || (head.vers != 8)) { free(m); return(0); } //"IDP2 m->framebytes = head.framebytes; m->frames = (char *)calloc(m->numframes,m->framebytes); if (!m->frames) { free(m); return(0); } - m->glcmds = (long *)calloc(m->numglcmds,sizeof(long)); if (!m->glcmds) { free(m->frames); free(m); return(0); } + m->glcmds = (int *)calloc(m->numglcmds,sizeof(int)); if (!m->glcmds) { free(m->frames); free(m); return(0); } m->tris = (md2tri_t *)calloc(head.numtris, sizeof(md2tri_t)); if (!m->tris) { free(m->glcmds); free(m->frames); free(m); return(0); } m->uv = (md2uv_t *)calloc(head.numuv, sizeof(md2uv_t)); if (!m->uv) { free(m->tris); free(m->glcmds); free(m->frames); free(m); return(0); } klseek(fil,head.ofsframes,SEEK_SET); if (kread(fil,(char *)m->frames,m->numframes*m->framebytes) != m->numframes*m->framebytes) - { free(m->uv); free(m->tris); free(m->glcmds); free(m->frames); free(m); return(0); } + { free(m->uv); free(m->tris); free(m->glcmds); free(m->frames); free(m); return(0); } klseek(fil,head.ofsglcmds,SEEK_SET); - if (kread(fil,(char *)m->glcmds,m->numglcmds*sizeof(long)) != (long)(m->numglcmds*sizeof(long))) - { free(m->uv); free(m->tris); free(m->glcmds); free(m->frames); free(m); return(0); } + if (kread(fil,(char *)m->glcmds,m->numglcmds*sizeof(int)) != (int)(m->numglcmds*sizeof(int))) + { free(m->uv); free(m->tris); free(m->glcmds); free(m->frames); free(m); return(0); } klseek(fil,head.ofstris,SEEK_SET); - if (kread(fil,(char *)m->tris,head.numtris*sizeof(md2tri_t)) != (long)(head.numtris*sizeof(md2tri_t))) - { free(m->uv); free(m->tris); free(m->glcmds); free(m->frames); free(m); return(0); } + if (kread(fil,(char *)m->tris,head.numtris*sizeof(md2tri_t)) != (int)(head.numtris*sizeof(md2tri_t))) + { free(m->uv); free(m->tris); free(m->glcmds); free(m->frames); free(m); return(0); } klseek(fil,head.ofsuv,SEEK_SET); - if (kread(fil,(char *)m->uv,head.numuv*sizeof(md2uv_t)) != (long)(head.numuv*sizeof(md2uv_t))) - { free(m->uv); free(m->tris); free(m->glcmds); free(m->frames); free(m); return(0); } + if (kread(fil,(char *)m->uv,head.numuv*sizeof(md2uv_t)) != (int)(head.numuv*sizeof(md2uv_t))) + { free(m->uv); free(m->tris); free(m->glcmds); free(m->frames); free(m); return(0); } #if B_BIG_ENDIAN != 0 { char *f = (char *)m->frames; - long *l,j; + int *l,j; md2frame_t *fr; - for (i = m->numframes-1; i>=0; i--) { + for (i = m->numframes-1; i>=0; i--) + { fr = (md2frame_t *)f; - l = (long *)&fr->mul; + l = (int *)&fr->mul; for (j=5;j>=0;j--) l[j] = B_LITTLE32(l[j]); f += m->framebytes; } - for (i = m->numglcmds-1; i>=0; i--) { + for (i = m->numglcmds-1; i>=0; i--) + { m->glcmds[i] = B_LITTLE32(m->glcmds[i]); } } @@ -1074,16 +1105,16 @@ if ((head.id != 0x32504449) || (head.vers != 8)) { free(m); return(0); } //"IDP2 strcpy(st,filnam); for (i=strlen(st)-1;i>0;i--) - if ((st[i] == '/') || (st[i] == '\\')) { i++; break; } + if ((st[i] == '/') || (st[i] == '\\')) { i++; break; } if (i<0) i=0; st[i] = 0; -m->basepath = (char *)malloc(i+1); if (!m->basepath) { free(m->uv); free(m->tris); free(m->glcmds); free(m->frames); free(m); return(0); } + m->basepath = (char *)malloc(i+1); if (!m->basepath) { free(m->uv); free(m->tris); free(m->glcmds); free(m->frames); free(m); return(0); } strcpy(m->basepath, st); m->skinfn = (char *)calloc(m->numskins,64); if (!m->skinfn) { free(m->basepath); free(m->uv); free(m->tris); free(m->glcmds); free(m->frames); free(m); return(0); } klseek(fil,head.ofsskins,SEEK_SET); if (kread(fil,m->skinfn,64*m->numskins) != 64*m->numskins) - { free(m->glcmds); free(m->frames); free(m); return(0); } + { free(m->glcmds); free(m->frames); free(m); return(0); } m->texid = (GLuint *)calloc(m->numskins, sizeof(GLuint) * (HICEFFECTMASK+1)); if (!m->texid) { free(m->skinfn); free(m->basepath); free(m->uv); free(m->tris); free(m->glcmds); free(m->frames); free(m); return(0); } @@ -1195,8 +1226,8 @@ m->basepath = (char *)malloc(i+1); if (!m->basepath) { free(m->uv); free(m->tris sk->skinnum = 0; sk->surfnum = 0; - if(m->numskins > 0) - { + if (m->numskins > 0) + { sk->fn = (char *)malloc(strlen(m->basepath)+strlen(m->skinfn)+1); strcpy(sk->fn, m->basepath); strcat(sk->fn, m->skinfn); @@ -1218,7 +1249,8 @@ m->basepath = (char *)malloc(i+1); if (!m->basepath) { free(m->uv); free(m->tris //---------------------------------------- MD2 LIBRARY ENDS ---------------------------------------- // DICHOTOMIC RECURSIVE SORTING - USED BY MD3DRAW - MAY PUT IT IN ITS OWN SOURCE FILE LATER -int partition(unsigned short *indexes, float *depths, int f, int l) { +int partition(unsigned short *indexes, float *depths, int f, int l) +{ int up,down,temp; float tempf; unsigned short tempus; @@ -1226,12 +1258,13 @@ int partition(unsigned short *indexes, float *depths, int f, int l) { unsigned short piv2 = indexes[f]; up = f; down = l; - do { + do + { while ((depths[up] <= piv) && (up < l)) up++; while ((depths[down] > piv) && (down > f)) down--; - if (up < down ) + if (up < down) { tempf = depths[up]; depths[up] = depths[down]; @@ -1240,7 +1273,8 @@ int partition(unsigned short *indexes, float *depths, int f, int l) { indexes[up] = indexes[down]; indexes[down] = tempus; } - } while (down > up); + } + while (down > up); depths[f] = depths[down]; depths[down] = piv; indexes[f] = indexes[down]; @@ -1248,9 +1282,11 @@ int partition(unsigned short *indexes, float *depths, int f, int l) { return down; } -void quicksort(unsigned short *indexes, float *depths, int first, int last) { +void quicksort(unsigned short *indexes, float *depths, int first, int last) +{ int pivIndex = 0; - if (first < last) { + if (first < last) + { pivIndex = partition(indexes,depths,first, last); quicksort(indexes,depths,first,(pivIndex-1)); quicksort(indexes,depths,(pivIndex+1),last); @@ -1260,11 +1296,11 @@ void quicksort(unsigned short *indexes, float *depths, int first, int last) { //--------------------------------------- MD3 LIBRARY BEGINS --------------------------------------- -static md3model *md3load (int fil) +static md3model *md3load(int fil) { char *buf, st[BMAX_PATH+2], bst[BMAX_PATH+2]; - long i, j, surfi, ofsurf, bsc, offs[4], leng[4]; - long maxtrispersurf; + int i, j, surfi, ofsurf, bsc, offs[4], leng[4]; + int maxtrispersurf; md3model *m; md3surf_t *s; @@ -1277,42 +1313,45 @@ static md3model *md3load (int fil) m->head.id = B_LITTLE32(m->head.id); m->head.vers = B_LITTLE32(m->head.vers); m->head.flags = B_LITTLE32(m->head.flags); m->head.numframes = B_LITTLE32(m->head.numframes); m->head.numtags = B_LITTLE32(m->head.numtags); m->head.numsurfs = B_LITTLE32(m->head.numsurfs); - m->head.numskins = B_LITTLE32(m->head.numskins); m->head.frames = (md3frame_t*)B_LITTLE32((long)m->head.frames); - m->head.tags = (md3tag_t*)B_LITTLE32((long)m->head.tags); m->head.surfs = (md3surf_t*)B_LITTLE32((long)m->head.surfs); + m->head.numskins = B_LITTLE32(m->head.numskins); m->head.frames = (md3frame_t*)B_LITTLE32((int)m->head.frames); + m->head.tags = (md3tag_t*)B_LITTLE32((int)m->head.tags); m->head.surfs = (md3surf_t*)B_LITTLE32((int)m->head.surfs); m->head.eof = B_LITTLE32(m->head.eof); -if ((m->head.id != 0x33504449) && (m->head.vers != 15)) { free(m); return(0); } //"IDP3" + if ((m->head.id != 0x33504449) && (m->head.vers != 15)) { free(m); return(0); } //"IDP3" m->numskins = m->head.numskins; //<- dead code? m->numframes = m->head.numframes; - ofsurf = (long)m->head.surfs; + ofsurf = (int)m->head.surfs; - klseek(fil,(long)m->head.frames,SEEK_SET); i = m->head.numframes*sizeof(md3frame_t); + klseek(fil,(int)m->head.frames,SEEK_SET); i = m->head.numframes*sizeof(md3frame_t); m->head.frames = (md3frame_t *)malloc(i); if (!m->head.frames) { free(m); return(0); } kread(fil,m->head.frames,i); if (m->head.numtags == 0) m->head.tags = NULL; - else { - klseek(fil,(long)m->head.tags,SEEK_SET); i = m->head.numtags*sizeof(md3tag_t); + else + { + klseek(fil,(int)m->head.tags,SEEK_SET); i = m->head.numtags*sizeof(md3tag_t); m->head.tags = (md3tag_t *)malloc(i); if (!m->head.tags) { free(m->head.frames); free(m); return(0); } kread(fil,m->head.tags,i); } - klseek(fil,(long)m->head.surfs,SEEK_SET); i = m->head.numsurfs*sizeof(md3surf_t); + klseek(fil,(int)m->head.surfs,SEEK_SET); i = m->head.numsurfs*sizeof(md3surf_t); m->head.surfs = (md3surf_t *)malloc(i); if (!m->head.surfs) { if (m->head.tags) free(m->head.tags); free(m->head.frames); free(m); return(0); } #if B_BIG_ENDIAN != 0 { - long *l; + int *l; - for (i = m->head.numframes-1; i>=0; i--) { - l = (long *)&m->head.frames[i].min; + for (i = m->head.numframes-1; i>=0; i--) + { + l = (int *)&m->head.frames[i].min; for (j=3+3+3+1-1;j>=0;j--) l[j] = B_LITTLE32(l[j]); } - for (i = m->head.numtags-1; i>=0; i--) { - l = (long *)&m->head.tags[i].p; + for (i = m->head.numtags-1; i>=0; i--) + { + l = (int *)&m->head.tags[i].p; for (j=3+3+3+3-1;j>=0;j--) l[j] = B_LITTLE32(l[j]); } } @@ -1327,17 +1366,17 @@ if ((m->head.id != 0x33504449) && (m->head.vers != 15)) { free(m); return(0); } #if B_BIG_ENDIAN != 0 { - long *l; + int *l; s->id = B_LITTLE32(s->id); - l = (long *)&s->flags; + l = (int *)&s->flags; for (j=1+1+1+1+1+1+1+1+1+1-1;j>=0;j--) l[j] = B_LITTLE32(l[j]); } #endif - offs[0] = ofsurf+((long)(s->tris )); leng[0] = s->numtris*sizeof(md3tri_t); - offs[1] = ofsurf+((long)(s->shaders)); leng[1] = s->numshaders*sizeof(md3shader_t); - offs[2] = ofsurf+((long)(s->uv )); leng[2] = s->numverts*sizeof(md3uv_t); - offs[3] = ofsurf+((long)(s->xyzn )); leng[3] = s->numframes*s->numverts*sizeof(md3xyzn_t); + offs[0] = ofsurf+((int)(s->tris)); leng[0] = s->numtris*sizeof(md3tri_t); + offs[1] = ofsurf+((int)(s->shaders)); leng[1] = s->numshaders*sizeof(md3shader_t); + offs[2] = ofsurf+((int)(s->uv)); leng[2] = s->numverts*sizeof(md3uv_t); + offs[3] = ofsurf+((int)(s->xyzn)); leng[3] = s->numframes*s->numverts*sizeof(md3xyzn_t); //memoryusage += (s->numverts * s->numframes * sizeof(md3xyzn_t)); //OSD_Printf("Current model geometry memory usage : %i.\n", memoryusage); @@ -1348,9 +1387,9 @@ if ((m->head.id != 0x33504449) && (m->head.vers != 15)) { free(m); return(0); } for (surfi--;surfi>=0;surfi--) free(m->head.surfs[surfi].tris); if (m->head.tags) free(m->head.tags); free(m->head.frames); free(m); return(0); } - s->shaders = (md3shader_t *)(((long)s->tris )+leng[0]); - s->uv = (md3uv_t *)(((long)s->shaders)+leng[1]); - s->xyzn = (md3xyzn_t *)(((long)s->uv )+leng[2]); + s->shaders = (md3shader_t *)(((int)s->tris)+leng[0]); + s->uv = (md3uv_t *)(((int)s->shaders)+leng[1]); + s->xyzn = (md3xyzn_t *)(((int)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]); @@ -1359,20 +1398,24 @@ if ((m->head.id != 0x33504449) && (m->head.vers != 15)) { free(m); return(0); } #if B_BIG_ENDIAN != 0 { - long *l; + int *l; - for (i=s->numtris-1;i>=0;i--) { + for (i=s->numtris-1;i>=0;i--) + { for (j=2;j>=0;j--) s->tris[i].i[j] = B_LITTLE32(s->tris[i].i[j]); } - for (i=s->numshaders-1;i>=0;i--) { + for (i=s->numshaders-1;i>=0;i--) + { s->shaders[i].i = B_LITTLE32(s->shaders[i].i); } - for (i=s->numverts-1;i>=0;i--) { - l = (long*)&s->uv[i].u; + for (i=s->numverts-1;i>=0;i--) + { + l = (int*)&s->uv[i].u; l[0] = B_LITTLE32(l[0]); l[1] = B_LITTLE32(l[1]); } - for (i=s->numframes*s->numverts-1;i>=0;i--) { + for (i=s->numframes*s->numverts-1;i>=0;i--) + { s->xyzn[i].x = (signed short)B_LITTLE16((unsigned short)s->xyzn[i].x); s->xyzn[i].y = (signed short)B_LITTLE16((unsigned short)s->xyzn[i].y); s->xyzn[i].z = (signed short)B_LITTLE16((unsigned short)s->xyzn[i].z); @@ -1400,7 +1443,7 @@ if ((m->head.id != 0x33504449) && (m->head.vers != 15)) { free(m); return(0); } (!stricmp(&st[j],"CEL"))) { for (i=0;st[i];i++) if (st[i] != filnam[i]) break; - if (i > bsc) { bsc = i; strcpy(bst,st); } + if (i > bsc) { bsc = i; strcpy(bst,st); } } } if (!mdloadskin(&m->texid,&m->usesalpha,bst)) ;//bad! @@ -1415,11 +1458,11 @@ if ((m->head.id != 0x33504449) && (m->head.vers != 15)) { free(m); return(0); } return(m); } -static int md3draw (md3model *m, spritetype *tspr) +static int md3draw(md3model *m, spritetype *tspr) { point3d fp, fp1, fp2, m0, m1, a0, a1; md3xyzn_t *v0, *v1; - long i, j, k, l, surfi, *lptr; + int i, j, k, l, surfi, *lptr; float f, g, k0, k1, k2, k3, k4, k5, k6, k7, mat[16], pc[4], mult; md3surf_t *s; int texunits = GL_TEXTURE0_ARB; @@ -1442,7 +1485,8 @@ static int md3draw (md3model *m, spritetype *tspr) f = m->interpol; g = 1-f; if (m->head.flags == 1337) - { // md2 + { + // md2 m0.x = m->scale * g; m1.x = m->scale *f; m0.y = m->scale * g; m1.y = m->scale *f; m0.z = m->scale * g; m1.z = m->scale *f; @@ -1530,7 +1574,7 @@ static int md3draw (md3model *m, spritetype *tspr) bglDepthRange(0.0,0.9999); } bglPushAttrib(GL_POLYGON_BIT); - if ((grhalfxdown10x >= 0) ^ ((globalorientation&8) != 0) ^ ((globalorientation&4) != 0)) bglFrontFace(GL_CW); else bglFrontFace(GL_CCW); + if ((grhalfxdown10x >= 0) ^((globalorientation&8) != 0) ^((globalorientation&4) != 0)) bglFrontFace(GL_CW); else bglFrontFace(GL_CCW); bglEnable(GL_CULL_FACE); bglCullFace(GL_BACK); @@ -1547,7 +1591,8 @@ static int md3draw (md3model *m, spritetype *tspr) pc[2] *= (float)hictinting[MAXPALOOKUPS-1].b / 255.0; } -if (tspr->cstat&2) { if (!(tspr->cstat&512)) pc[3] = 0.66; else pc[3] = 0.33; } else pc[3] = 1.0; + if (tspr->cstat&2) { if (!(tspr->cstat&512)) pc[3] = 0.66; else pc[3] = 0.33; } + else pc[3] = 1.0; if (m->usesalpha) //Sprites with alpha in texture { // bglEnable(GL_BLEND);// bglBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); @@ -1678,7 +1723,7 @@ if (tspr->cstat&2) { if (!(tspr->cstat&512)) pc[3] = 0.66; else pc[3] = 0.33; } bglTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE); bglTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR); - + bglTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE); bglTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS_ARB); bglTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA); @@ -1838,56 +1883,56 @@ if (tspr->cstat&2) { if (!(tspr->cstat&512)) pc[3] = 0.66; else pc[3] = 0.33; } if (r_vertexarrays) { + if (r_vbos) + bglBindBufferARB(GL_ARRAY_BUFFER_ARB, m->vbos[surfi]); + l = GL_TEXTURE0_ARB; + while (l <= texunits) + { + bglClientActiveTextureARB(l++); + bglEnableClientState(GL_TEXTURE_COORD_ARRAY); if (r_vbos) - bglBindBufferARB(GL_ARRAY_BUFFER_ARB, m->vbos[surfi]); - l = GL_TEXTURE0_ARB; - while (l <= texunits) - { - bglClientActiveTextureARB(l++); - bglEnableClientState(GL_TEXTURE_COORD_ARRAY); - if (r_vbos) - bglTexCoordPointer(2, GL_FLOAT, 0, 0); - else - bglTexCoordPointer(2, GL_FLOAT, 0, &(s->uv[0].u)); - } - - if (r_vbos) - { - bglBindBufferARB(GL_ARRAY_BUFFER_ARB, vertvbos[curvbo]); - bglVertexPointer(3, GL_FLOAT, 0, 0); - } + bglTexCoordPointer(2, GL_FLOAT, 0, 0); else - bglVertexPointer(3, GL_FLOAT, 0, &(vertlist[0].x)); + bglTexCoordPointer(2, GL_FLOAT, 0, &(s->uv[0].u)); + } - if (r_vbos) - { - bglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, indexvbos[curvbo]); - bglDrawElements(GL_TRIANGLES, s->numtris * 3, GL_UNSIGNED_SHORT, 0); - } - else - bglDrawElements(GL_TRIANGLES, s->numtris * 3, GL_UNSIGNED_SHORT, m->vindexes); + if (r_vbos) + { + bglBindBufferARB(GL_ARRAY_BUFFER_ARB, vertvbos[curvbo]); + bglVertexPointer(3, GL_FLOAT, 0, 0); + } + else + bglVertexPointer(3, GL_FLOAT, 0, &(vertlist[0].x)); - if (r_vbos) - { - bglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); - bglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); - } + if (r_vbos) + { + bglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, indexvbos[curvbo]); + bglDrawElements(GL_TRIANGLES, s->numtris * 3, GL_UNSIGNED_SHORT, 0); + } + else + bglDrawElements(GL_TRIANGLES, s->numtris * 3, GL_UNSIGNED_SHORT, m->vindexes); + + if (r_vbos) + { + bglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); + bglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); + } } - while (texunits > GL_TEXTURE0_ARB) + while (texunits > GL_TEXTURE0_ARB) + { + bglMatrixMode(GL_TEXTURE); + bglLoadIdentity(); + bglMatrixMode(GL_MODELVIEW); + bglTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1.0f); + bglDisable(GL_TEXTURE_2D); + if (r_vertexarrays) { - bglMatrixMode(GL_TEXTURE); - bglLoadIdentity(); - bglMatrixMode(GL_MODELVIEW); - bglTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1.0f); - bglDisable(GL_TEXTURE_2D); - if (r_vertexarrays) - { - bglDisableClientState(GL_TEXTURE_COORD_ARRAY); - bglClientActiveTextureARB(texunits - 1); - } - bglActiveTextureARB(--texunits); + bglDisableClientState(GL_TEXTURE_COORD_ARRAY); + bglClientActiveTextureARB(texunits - 1); } + bglActiveTextureARB(--texunits); + } } //------------ @@ -1904,12 +1949,12 @@ if (tspr->cstat&2) { if (!(tspr->cstat&512)) pc[3] = 0.66; else pc[3] = 0.33; } return 1; } -static void md3free (md3model *m) +static void md3free(md3model *m) { mdanim_t *anim, *nanim = NULL; mdskinmap_t *sk, *nsk = NULL; md3surf_t *s; - long surfi; + int surfi; if (!m) return; @@ -1964,27 +2009,27 @@ static void md3free (md3model *m) //--------------------------------------- VOX LIBRARY BEGINS --------------------------------------- //For loading/conversion only -static long xsiz, ysiz, zsiz, yzsiz, *vbit = 0; //vbit: 1 bit per voxel: 0=air,1=solid +static int xsiz, ysiz, zsiz, yzsiz, *vbit = 0; //vbit: 1 bit per voxel: 0=air,1=solid static float xpiv, ypiv, zpiv; //Might want to use more complex/unique names! -static long *vcolhashead = 0, vcolhashsizm1; -typedef struct { long p, c, n; } voxcol_t; -static voxcol_t *vcol = 0; long vnum = 0, vmax = 0; +static int *vcolhashead = 0, vcolhashsizm1; +typedef struct { int p, c, n; } voxcol_t; +static voxcol_t *vcol = 0; int vnum = 0, vmax = 0; typedef struct { short x, y; } spoint2d; static spoint2d *shp; -static long *shcntmal, *shcnt = 0, shcntp; -static long mytexo5, *zbit, gmaxx, gmaxy, garea, pow2m1[33]; +static int *shcntmal, *shcnt = 0, shcntp; +static int mytexo5, *zbit, gmaxx, gmaxy, garea, pow2m1[33]; static voxmodel *gvox; //pitch must equal xsiz*4 -unsigned gloadtex (long *picbuf, long xsiz, long ysiz, long is8bit, long dapal) +unsigned gloadtex(int *picbuf, int xsiz, int ysiz, int is8bit, int dapal) { unsigned rtexid; coltype *pic, *pic2; unsigned char *cptr; - long i; + int i; pic = (coltype *)picbuf; //Correct for GL's RGB order; also apply gamma here.. - pic2 = (coltype *)malloc(xsiz*ysiz*sizeof(long)); if (!pic2) return((unsigned)-1); + pic2 = (coltype *)malloc(xsiz*ysiz*sizeof(int)); if (!pic2) return((unsigned)-1); cptr = (unsigned char*)&britable[gammabrightness ? 0 : curbrightness][0]; if (!is8bit) { @@ -2001,9 +2046,9 @@ unsigned gloadtex (long *picbuf, long xsiz, long ysiz, long is8bit, long dapal) if (palookup[dapal] == NULL) dapal = 0; for (i=xsiz*ysiz-1;i>=0;i--) { - pic2[i].b = cptr[palette[(long)palookup[dapal][pic[i].a]*3+2]*4]; - pic2[i].g = cptr[palette[(long)palookup[dapal][pic[i].a]*3+1]*4]; - pic2[i].r = cptr[palette[(long)palookup[dapal][pic[i].a]*3+0]*4]; + pic2[i].b = cptr[palette[(int)palookup[dapal][pic[i].a]*3+2]*4]; + pic2[i].g = cptr[palette[(int)palookup[dapal][pic[i].a]*3+1]*4]; + pic2[i].r = cptr[palette[(int)palookup[dapal][pic[i].a]*3+0]*4]; pic2[i].a = 255; } } @@ -2017,7 +2062,7 @@ unsigned gloadtex (long *picbuf, long xsiz, long ysiz, long is8bit, long dapal) return(rtexid); } -static long getvox (long x, long y, long z) +static int getvox(int x, int y, int z) { z += x*yzsiz + y*zsiz; for (x=vcolhashead[(z*214013)&vcolhashsizm1];x>=0;x=vcol[x].n) @@ -2025,7 +2070,7 @@ static long getvox (long x, long y, long z) return(0x808080); } -static void putvox (long x, long y, long z, long col) +static void putvox(int x, int y, int z, int col) { if (vnum >= vmax) { vmax = max(vmax<<1,4096); vcol = (voxcol_t *)realloc(vcol,vmax*sizeof(voxcol_t)); } @@ -2036,9 +2081,9 @@ static void putvox (long x, long y, long z, long col) } //Set all bits in vbit from (x,y,z0) to (x,y,z1-1) to 0's -static void setzrange0 (long *lptr, long z0, long z1) +static void setzrange0(int *lptr, int z0, int z1) { - long z, ze; + int z, ze; if (!((z0^z1)&~31)) { lptr[z0>>5] &= ((~(-1<>5); ze = (z1>>5); lptr[z] &=~(-1<>5] |= ((~(-1<>5); ze = (z1>>5); lptr[z] |= (-1<mytexx + x0; for (dy=0;dy;dy--,i+=gvox->mytexx) - for (x=0;x>5]&(1<>5]&(1<>5); dx += x0-1; c = (dx>>5) - (x0>>5); m = ~pow2m1[x0&31]; m1 = pow2m1[(dx&31)+1]; if (!c) { for (m&=m1;dy;dy--,i+=mytexo5) if (zbit[i]&m) return(0); } else - { for (;dy;dy--,i+=mytexo5) + { + for (;dy;dy--,i+=mytexo5) { if (zbit[i]&m) return(0); for (x=1;xmytexx + x0; for (y=0;ymytexx) - for (x=0;x>5] |= (1<>5] |= (1<>5); dx += x0-1; c = (dx>>5) - (x0>>5); m = ~pow2m1[x0&31]; m1 = pow2m1[(dx&31)+1]; if (!c) { for (m&=m1;dy;dy--,i+=mytexo5) zbit[i] |= m; } else - { for (;dy;dy--,i+=mytexo5) + { + for (;dy;dy--,i+=mytexo5) { zbit[i] |= m; for (x=1;x gmaxx) gmaxx = x; if (y > gmaxy) gmaxy = y; @@ -2118,14 +2165,16 @@ if (x < y) { z = x; x = y; y = z; } gvox->qcnt++; } -static void addquad (long x0, long y0, long z0, long x1, long y1, long z1, long x2, long y2, long z2, long face) +static void addquad(int x0, int y0, int z0, int x1, int y1, int z1, int x2, int y2, int z2, int face) { - long i, j, x, y, z, xx, yy, nx = 0, ny = 0, nz = 0, *lptr; + int i, j, x, y, z, xx, yy, nx = 0, ny = 0, nz = 0, *lptr; voxrect_t *qptr; x = labs(x2-x0); y = labs(y2-y0); z = labs(z2-z0); - if (!x) { x = y; y = z; i = 0; } else if (!y) { y = z; i = 1; } else i = 2; -if (x < y) { z = x; x = y; y = z; i += 3; } + if (!x) { x = y; y = z; i = 0; } + else if (!y) { y = z; i = 1; } + else i = 2; + if (x < y) { z = x; x = y; y = z; i += 3; } z = shcnt[y*shcntp+x]++; lptr = &gvox->mytex[(shp[z].y+VOXBORDWIDTH)*gvox->mytexx+(shp[z].x+VOXBORDWIDTH)]; switch (face) @@ -2149,23 +2198,29 @@ if (x < y) { z = x; x = y; y = z; i += 3; } switch (face) { case 0: - if (i < 3) { nx = x1+x-1-xx; nz = z1+yy; } //back - else { nx = x1+y-1-yy; nz = z1+xx; } break; + if (i < 3) { nx = x1+x-1-xx; nz = z1+yy; } //back + else { nx = x1+y-1-yy; nz = z1+xx; } + break; case 1: - if (i < 3) { nx = x0+xx; nz = z0+yy; } //front - else { nx = x0+yy; nz = z0+xx; } break; + if (i < 3) { nx = x0+xx; nz = z0+yy; } //front + else { nx = x0+yy; nz = z0+xx; } + break; case 2: - if (i < 3) { nx = x1-x+xx; ny = y1-1-yy; } //bot - else { nx = x1-1-yy; ny = y1-1-xx; } break; + if (i < 3) { nx = x1-x+xx; ny = y1-1-yy; } //bot + else { nx = x1-1-yy; ny = y1-1-xx; } + break; case 3: - if (i < 3) { nx = x0+xx; ny = y0+yy; } //top - else { nx = x0+yy; ny = y0+xx; } break; + if (i < 3) { nx = x0+xx; ny = y0+yy; } //top + else { nx = x0+yy; ny = y0+xx; } + break; case 4: - if (i < 3) { ny = y1+x-1-xx; nz = z1+yy; } //right - else { ny = y1+y-1-yy; nz = z1+xx; } break; + if (i < 3) { ny = y1+x-1-xx; nz = z1+yy; } //right + else { ny = y1+y-1-yy; nz = z1+xx; } + break; case 5: - if (i < 3) { ny = y0+xx; nz = z0+yy; } //left - else { ny = y0+yy; nz = z0+xx; } break; + if (i < 3) { ny = y0+xx; nz = z0+yy; } //left + else { ny = y0+yy; nz = z0+xx; } + break; } lptr[xx] = getvox(nx,ny,nz); } @@ -2206,18 +2261,18 @@ if (x < y) { z = x; x = y; y = z; i += 3; } } -static long isolid (long x, long y, long z) +static int isolid(int x, int y, int z) { - if ((unsigned long)x >= (unsigned long)xsiz) return(0); - if ((unsigned long)y >= (unsigned long)ysiz) return(0); - if ((unsigned long)z >= (unsigned long)zsiz) return(0); + if ((unsigned int)x >= (unsigned int)xsiz) return(0); + if ((unsigned int)y >= (unsigned int)ysiz) return(0); + if ((unsigned int)z >= (unsigned int)zsiz) return(0); z += x*yzsiz + y*zsiz; return(vbit[z>>5]&(1<qfacind[i] = -1; i = ((max(ysiz,zsiz)+1)<<2); -bx0 = (long *)malloc(i<<1); if (!bx0) { free(gvox); return(0); } - by0 = (long *)(((long)bx0)+i); + bx0 = (int *)malloc(i<<1); if (!bx0) { free(gvox); return(0); } + by0 = (int *)(((int)bx0)+i); for (cnt=0;cnt<2;cnt++) { @@ -2255,7 +2310,7 @@ bx0 = (long *)malloc(i<<1); if (!bx0) { free(gvox); return(0); } { ov = v; v = (isolid(x,y,z) && (!isolid(x,y+i,z))); if ((by0[z] >= 0) && ((by0[z] != oz) || (v >= ov))) - { daquad(bx0[z],y,by0[z],x,y,by0[z],x,y,z,i>=0); by0[z] = -1; } + { daquad(bx0[z],y,by0[z],x,y,by0[z],x,y,z,i>=0); by0[z] = -1; } if (v > ov) oz = z; else if ((v < ov) && (by0[z] != oz)) { bx0[z] = x; by0[z] = oz; } } @@ -2266,7 +2321,7 @@ bx0 = (long *)malloc(i<<1); if (!bx0) { free(gvox); return(0); } { ov = v; v = (isolid(x,y,z) && (!isolid(x,y,z-i))); if ((by0[y] >= 0) && ((by0[y] != oz) || (v >= ov))) - { daquad(bx0[y],by0[y],z,x,by0[y],z,x,y,z,(i>=0)+2); by0[y] = -1; } + { daquad(bx0[y],by0[y],z,x,by0[y],z,x,y,z,(i>=0)+2); by0[y] = -1; } if (v > ov) oz = y; else if ((v < ov) && (by0[y] != oz)) { bx0[y] = x; by0[y] = oz; } } @@ -2277,7 +2332,7 @@ bx0 = (long *)malloc(i<<1); if (!bx0) { free(gvox); return(0); } { ov = v; v = (isolid(x,y,z) && (!isolid(x-i,y,z))); if ((by0[z] >= 0) && ((by0[z] != oz) || (v >= ov))) - { daquad(x,bx0[z],by0[z],x,y,by0[z],x,y,z,(i>=0)+4); by0[z] = -1; } + { daquad(x,bx0[z],by0[z],x,y,by0[z],x,y,z,(i>=0)+4); by0[z] = -1; } if (v > ov) oz = z; else if ((v < ov) && (by0[z] != oz)) { bx0[z] = y; by0[z] = oz; } } @@ -2305,7 +2360,7 @@ skindidntfit: mytexo5 = (gvox->mytexx>>5); i = (((gvox->mytexx*gvox->mytexy+31)>>5)<<2); - zbit = (long *)malloc(i); if (!zbit) { free(bx0); free(gvox); free(shp); return(0); } + zbit = (int *)malloc(i); if (!zbit) { free(bx0); free(gvox); free(shp); return(0); } memset(zbit,0,i); v = gvox->mytexx*gvox->mytexy; @@ -2339,7 +2394,8 @@ skindidntfit: goto skindidntfit; } - } while (!isrectfree(x0,y0,dx,dy)); + } + while (!isrectfree(x0,y0,dx,dy)); while ((y0) && (isrectfree(x0,y0-1,dx,1))) y0--; while ((x0) && (isrectfree(x0-1,y0,1,dy))) x0--; setrect(x0,y0,dx,dy); @@ -2347,9 +2403,9 @@ skindidntfit: } gvox->quad = (voxrect_t *)malloc(gvox->qcnt*sizeof(voxrect_t)); - if (!gvox->quad) { free(zbit); free(shp); free(bx0); free(gvox); return(0); } + if (!gvox->quad) { free(zbit); free(shp); free(bx0); free(gvox); return(0); } - gvox->mytex = (long *)malloc(gvox->mytexx*gvox->mytexy*sizeof(long)); + gvox->mytex = (int *)malloc(gvox->mytexx*gvox->mytexy*sizeof(int)); if (!gvox->mytex) { free(gvox->quad); free(zbit); free(shp); free(bx0); free(gvox); return(0); } } } @@ -2357,9 +2413,9 @@ skindidntfit: return(gvox); } -static long loadvox (const char *filnam) +static int loadvox(const char *filnam) { - long i, j, k, x, y, z, pal[256], fil; + int i, j, k, x, y, z, pal[256], fil; unsigned char c[3], *tbuf; fil = kopen4load((char *)filnam,0); if (fil < 0) return(-1); @@ -2372,15 +2428,15 @@ static long loadvox (const char *filnam) klseek(fil,-768,SEEK_END); for (i=0;i<256;i++) - { kread(fil,c,3); pal[i] = (((long)c[0])<<18)+(((long)c[1])<<10)+(((long)c[2])<<2)+(i<<24); } + { kread(fil,c,3); pal[i] = (((int)c[0])<<18)+(((int)c[1])<<10)+(((int)c[2])<<2)+(i<<24); } pal[255] = -1; vcolhashsizm1 = 8192-1; - vcolhashead = (long *)malloc((vcolhashsizm1+1)*sizeof(long)); if (!vcolhashead) { kclose(fil); return(-1); } - memset(vcolhashead,-1,(vcolhashsizm1+1)*sizeof(long)); + vcolhashead = (int *)malloc((vcolhashsizm1+1)*sizeof(int)); if (!vcolhashead) { kclose(fil); return(-1); } + memset(vcolhashead,-1,(vcolhashsizm1+1)*sizeof(int)); yzsiz = ysiz*zsiz; i = ((xsiz*yzsiz+31)>>3); - vbit = (long *)malloc(i); if (!vbit) { kclose(fil); return(-1); } + vbit = (int *)malloc(i); if (!vbit) { kclose(fil); return(-1); } memset(vbit,0,i); tbuf = (unsigned char *)malloc(zsiz*sizeof(char)); if (!tbuf) { kclose(fil); return(-1); } @@ -2391,7 +2447,7 @@ static long loadvox (const char *filnam) { kread(fil,tbuf,zsiz); for (z=zsiz-1;z>=0;z--) - { if (tbuf[z] != 255) { i = j+z; vbit[i>>5] |= (1<>5] |= (1<>5]&(1<>5]&(1<>5]&(1<>5]&(1<>5]&(1<=0; i--) xyoffs[i] = B_LITTLE16(xyoffs[i]); klseek(fil,-768,SEEK_END); for (i=0;i<256;i++) - { kread(fil,c,3); pal[i] = B_LITTLE32((((long)c[0])<<18)+(((long)c[1])<<10)+(((long)c[2])<<2)+(i<<24)); } + { kread(fil,c,3); pal[i] = B_LITTLE32((((int)c[0])<<18)+(((int)c[1])<<10)+(((int)c[2])<<2)+(i<<24)); } yzsiz = ysiz*zsiz; i = ((xsiz*yzsiz+31)>>3); - vbit = (long *)malloc(i); if (!vbit) { free(xyoffs); kclose(fil); return(-1); } + vbit = (int *)malloc(i); if (!vbit) { free(xyoffs); kclose(fil); return(-1); } memset(vbit,0,i); for (vcolhashsizm1=4096;vcolhashsizm1<(mip1leng>>1);vcolhashsizm1<<=1); vcolhashsizm1--; //approx to numvoxs! -vcolhashead = (long *)malloc((vcolhashsizm1+1)*sizeof(long)); if (!vcolhashead) { free(xyoffs); kclose(fil); return(-1); } - memset(vcolhashead,-1,(vcolhashsizm1+1)*sizeof(long)); + vcolhashead = (int *)malloc((vcolhashsizm1+1)*sizeof(int)); if (!vcolhashead) { free(xyoffs); kclose(fil); return(-1); } + memset(vcolhashead,-1,(vcolhashsizm1+1)*sizeof(int)); klseek(fil,28+((xsiz+1)<<2)+((ysizp1*xsiz)<<1),SEEK_SET); @@ -2464,7 +2520,7 @@ vcolhashead = (long *)malloc((vcolhashsizm1+1)*sizeof(long)); if (!vcolhashead) z1 = 0; while (i) { - z0 = (long)cptr[0]; k = (long)cptr[1]; cptr += 3; + z0 = (int)cptr[0]; k = (int)cptr[1]; cptr += 3; if (!(cptr[-1]&16)) setzrange1(vbit,j+z1,j+z0); i -= k+3; z1 = z0+k; setzrange1(vbit,j+z0,j+z1); @@ -2475,14 +2531,14 @@ vcolhashead = (long *)malloc((vcolhashsizm1+1)*sizeof(long)); if (!vcolhashead) free(tbuf); free(xyoffs); return(0); } -static long loadkv6 (const char *filnam) +static int loadkv6(const char *filnam) { - long i, j, x, y, z, numvoxs, z0, z1, fil; + int i, j, x, y, z, numvoxs, z0, z1, fil; unsigned short *ylen; unsigned char c[8]; fil = kopen4load((char *)filnam,0); if (fil < 0) return(-1); -kread(fil,&i,4); if (B_LITTLE32(i) != 0x6c78764b) { kclose(fil); return(-1); } //Kvxl + kread(fil,&i,4); if (B_LITTLE32(i) != 0x6c78764b) { kclose(fil); return(-1); } //Kvxl kread(fil,&xsiz,4); xsiz = B_LITTLE32(xsiz); kread(fil,&ysiz,4); ysiz = B_LITTLE32(ysiz); kread(fil,&zsiz,4); zsiz = B_LITTLE32(zsiz); @@ -2499,12 +2555,12 @@ kread(fil,&i,4); if (B_LITTLE32(i) != 0x6c78764b) { kclose(fil); return(-1); } / klseek(fil,32,SEEK_SET); yzsiz = ysiz*zsiz; i = ((xsiz*yzsiz+31)>>3); -vbit = (long *)malloc(i); if (!vbit) { free(ylen); kclose(fil); return(-1); } + vbit = (int *)malloc(i); if (!vbit) { free(ylen); kclose(fil); return(-1); } memset(vbit,0,i); for (vcolhashsizm1=4096;vcolhashsizm1>5] |= (1<>3); - vbit = (long *)malloc(i); if (!vbit) { kclose(fil); return(-1); } + vbit = (int *)malloc(i); if (!vbit) { kclose(fil); return(-1); } memset(vbit,-1,i); vcolhashsizm1 = 1048576-1; - vcolhashead = (long *)malloc((vcolhashsizm1+1)*sizeof(long)); if (!vcolhashead) { kclose(fil); return(-1); } - memset(vcolhashead,-1,(vcolhashsizm1+1)*sizeof(long)); + vcolhashead = (int *)malloc((vcolhashsizm1+1)*sizeof(int)); if (!vcolhashead) { kclose(fil); return(-1); } + memset(vcolhashead,-1,(vcolhashsizm1+1)*sizeof(int)); //Allocate huge buffer and load rest of file into it... i = kfilelength(fil)-ktell(fil); @@ -2563,17 +2619,17 @@ if ((i != 0x09072000) || (xsiz != 1024) || (ysiz != 1024)) { kclose(fil); return while (1) { setzrange0(vbit,j+z,j+v[1]); - for (z=v[1];z<=v[2];z++) putvox(x,y,z,(*(long *)&v[(z-v[1]+1)<<2])&0xffffff); + for (z=v[1];z<=v[2];z++) putvox(x,y,z,(*(int *)&v[(z-v[1]+1)<<2])&0xffffff); if (!v[0]) break; z = v[2]-v[1]-v[0]+2; v += v[0]*4; - for (z+=v[3];zmytex) free(m->mytex); @@ -2582,13 +2638,13 @@ static void voxfree (voxmodel *m) free(m); } -static voxmodel *voxload (const char *filnam) +static voxmodel *voxload(const char *filnam) { - long i, is8bit, ret; + int i, is8bit, ret; voxmodel *vm; i = strlen(filnam)-4; if (i < 0) return(0); -if (!Bstrcasecmp(&filnam[i],".vox")) { ret = loadvox(filnam); is8bit = 1; } + if (!Bstrcasecmp(&filnam[i],".vox")) { ret = loadvox(filnam); is8bit = 1; } else if (!Bstrcasecmp(&filnam[i],".kvx")) { ret = loadkvx(filnam); is8bit = 1; } else if (!Bstrcasecmp(&filnam[i],".kv6")) { ret = loadkv6(filnam); is8bit = 0; } //else if (!Bstrcasecmp(&filnam[i],".vxl")) { ret = loadvxl(filnam); is8bit = 0; } @@ -2613,10 +2669,10 @@ if (!Bstrcasecmp(&filnam[i],".vox")) { ret = loadvox(filnam); is8bit = 1; } } //Draw voxel model as perfect cubes -static int voxdraw (voxmodel *m, spritetype *tspr) +static int voxdraw(voxmodel *m, spritetype *tspr) { point3d fp, m0, a0; - long i, j, k, fi, *lptr, xx, yy, zz; + int i, j, k, fi, *lptr, xx, yy, zz; float ru, rv, uhack[2], vhack[2], phack[2], clut[6] = {1,1,1,1,1,1}; //1.02,1.02,0.94,1.06,0.98,0.98}; float f, g, k0, k1, k2, k3, k4, k5, k6, k7, mat[16], omat[16], pc[4]; vert_t *vptr; @@ -2675,7 +2731,7 @@ static int voxdraw (voxmodel *m, spritetype *tspr) mat[14] += a0.y*mat[2] + a0.z*mat[6] + a0.x*mat[10]; //Mirrors -if (grhalfxdown10x < 0) { mat[0] = -mat[0]; mat[4] = -mat[4]; mat[8] = -mat[8]; mat[12] = -mat[12]; } + if (grhalfxdown10x < 0) { mat[0] = -mat[0]; mat[4] = -mat[4]; mat[8] = -mat[8]; mat[12] = -mat[12]; } //------------ //bit 10 is an ugly hack in game.c\animatesprites telling MD2SPRITE @@ -2696,7 +2752,8 @@ if (grhalfxdown10x < 0) { mat[0] = -mat[0]; mat[4] = -mat[4]; mat[8] = -mat[8]; pc[0] *= (float)hictinting[globalpal].r / 255.0; pc[1] *= (float)hictinting[globalpal].g / 255.0; pc[2] *= (float)hictinting[globalpal].b / 255.0; -if (tspr->cstat&2) { if (!(tspr->cstat&512)) pc[3] = 0.66; else pc[3] = 0.33; } else pc[3] = 1.0; + if (tspr->cstat&2) { if (!(tspr->cstat&512)) pc[3] = 0.66; else pc[3] = 0.33; } + else pc[3] = 1.0; if (tspr->cstat&2 && (!peelcompiling)) bglEnable(GL_BLEND); //else bglDisable(GL_BLEND); //------------ @@ -2765,11 +2822,11 @@ if (tspr->cstat&2) { if (!(tspr->cstat&512)) pc[3] = 0.66; else pc[3] = 0.33; } //---------------------------------------- VOX LIBRARY ENDS ---------------------------------------- //--------------------------------------- MD LIBRARY BEGINS --------------------------------------- -mdmodel *mdload (const char *filnam) +mdmodel *mdload(const char *filnam) { mdmodel *vm; int fil; - long i; + int i; vm = (mdmodel*)voxload(filnam); if (vm) return(vm); @@ -2789,7 +2846,7 @@ mdmodel *mdload (const char *filnam) return(vm); } -int mddraw (spritetype *tspr) +int mddraw(spritetype *tspr) { mdanim_t *anim; mdmodel *vm; @@ -2833,7 +2890,7 @@ int mddraw (spritetype *tspr) return 0; } -void mdfree (mdmodel *vm) +void mdfree(mdmodel *vm) { if (vm->mdnum == 1) { voxfree((voxmodel *)vm); return; } if (vm->mdnum == 3) { md3free((md3model *)vm); return; } diff --git a/polymer/build/src/mmulti.c b/polymer/build/src/mmulti.c index 59a0b3970..7b35d96a7 100644 --- a/polymer/build/src/mmulti.c +++ b/polymer/build/src/mmulti.c @@ -29,10 +29,10 @@ #include "compat.h" #include -static long GetTickCount(void) +static int GetTickCount(void) { struct timeval tv; - long ti; + int ti; if (gettimeofday(&tv,NULL) < 0) return 0; // tv is sec.usec, GTC gives msec ti = tv.tv_sec * 1000; @@ -59,27 +59,27 @@ static long GetTickCount(void) int packetrate = PAKRATE; #define SIMMIS 0 //Release:0 Test:100 Packets per 256 missed. #define SIMLAG 0 //Release:0 Test: 10 Packets to delay receipt -static long simlagcnt[MAXPLAYERS]; +static int simlagcnt[MAXPLAYERS]; static char simlagfif[MAXPLAYERS][SIMLAG+1][MAXPAKSIZ+2]; #if ((SIMMIS != 0) || (SIMLAG != 0)) #pragma message("\n\nWARNING! INTENTIONAL PACKET LOSS SIMULATION IS ENABLED!\nREMEMBER TO CHANGE SIMMIS&SIMLAG to 0 before RELEASE!\n\n") #endif -long myconnectindex, numplayers; -long connecthead, connectpoint2[MAXPLAYERS]; +int myconnectindex, numplayers; +int connecthead, connectpoint2[MAXPLAYERS]; -static long tims, lastsendtims[MAXPLAYERS]; +static int tims, lastsendtims[MAXPLAYERS]; static char pakbuf[MAXPAKSIZ]; #define FIFSIZ 512 //16384/40 = 6min:49sec -static long ipak[MAXPLAYERS][FIFSIZ], icnt0[MAXPLAYERS]; -static long opak[MAXPLAYERS][FIFSIZ], ocnt0[MAXPLAYERS], ocnt1[MAXPLAYERS]; -static char pakmem[4194304]; static long pakmemi = 1; +static int ipak[MAXPLAYERS][FIFSIZ], icnt0[MAXPLAYERS]; +static int opak[MAXPLAYERS][FIFSIZ], ocnt0[MAXPLAYERS], ocnt1[MAXPLAYERS]; +static char pakmem[4194304]; static int pakmemi = 1; #define NETPORT 0x5bd9 static SOCKET mysock; -static long myip, myport = NETPORT, otherip[MAXPLAYERS], otherport[MAXPLAYERS]; -static long snatchip = 0, snatchport = 0, danetmode = 255, netready = 0; +static int myip, myport = NETPORT, otherip[MAXPLAYERS], otherport[MAXPLAYERS]; +static int snatchip = 0, snatchport = 0, danetmode = 255, netready = 0; #ifdef _WIN32 int wsainitialized = 0; @@ -92,7 +92,7 @@ int nfFinished = 0; //Flag that determines NatFree has found all players and set int HeardFrom[MAXPLAYERS]; //For connecthead int HeardFrom2[MAXPLAYERS]; //For others -int nfCheckCP (long other) //Check if target player is our current NatFree Player +int nfCheckCP(int other) //Check if target player is our current NatFree Player { if (!natfree || nfFinished) return 1; @@ -102,7 +102,7 @@ int nfCheckCP (long other) //Check if target player is our current NatFree Playe return 0; } -int nfCheckHF (long other) //function to check if we've heard from a player +int nfCheckHF(int other) //function to check if we've heard from a player { if (HeardFrom[other] == 1) return 1; @@ -110,7 +110,7 @@ int nfCheckHF (long other) //function to check if we've heard from a player return 0; } -void nfIncCP () //function to handle currentplayer increment +void nfIncCP() //function to handle currentplayer increment { if (natfree && !nfFinished) { @@ -126,7 +126,7 @@ void nfIncCP () //function to handle currentplayer increment } /*Addfaz NatFree End*/ -void netuninit () +void netuninit() { if (mysock != (SOCKET)INVALID_HANDLE_VALUE) closesocket(mysock); #ifdef _WIN32 @@ -135,41 +135,41 @@ void netuninit () #endif } -static int set_socket_blockmode(SOCKET socket, int onOrOff) +static int set_socket_blockmode(SOCKET socket, int onOrOff) { -#ifdef _WIN32 - unsigned long flags; +#ifdef _WIN32 + unsigned int flags; #else - signed long flags; -#endif - int rc = 0; - - /* set socket to be (non-)blocking. */ - -#ifdef _WIN32 - flags = (onOrOff) ? 0 : 1; - rc = (ioctlsocket(socket, FIONBIO, &flags) == 0); -#else - flags = fcntl(socket, F_GETFL, 0); - if (flags != -1) - { - if (onOrOff) - flags &= ~O_NONBLOCK; - else - flags |= O_NONBLOCK; - rc = (fcntl(socket, F_SETFL, flags) == 0); - } -#endif - - return(rc); -} + signed int flags; +#endif + int rc = 0; -long netinit (long portnum) + /* set socket to be (non-)blocking. */ + +#ifdef _WIN32 + flags = (onOrOff) ? 0 : 1; + rc = (ioctlsocket(socket, FIONBIO, &flags) == 0); +#else + flags = fcntl(socket, F_GETFL, 0); + if (flags != -1) + { + if (onOrOff) + flags &= ~O_NONBLOCK; + else + flags |= O_NONBLOCK; + rc = (fcntl(socket, F_SETFL, flags) == 0); + } +#endif + + return(rc); +} + +int netinit(int portnum) { LPHOSTENT lpHostEnt; char hostnam[256]; struct sockaddr_in ip; - long i; + int i; #ifdef _WIN32 if (wsainitialized == 0) @@ -185,7 +185,7 @@ long netinit (long portnum) #ifdef __BEOS__ i = 1; if (setsockopt(mysock,SOL_SOCKET,SO_NONBLOCK,&i,sizeof(i)) < 0) return(0); #else -// i = 1; if (ioctlsocket(mysock,FIONBIO,(unsigned long *)&i) == SOCKET_ERROR) return(0); +// i = 1; if (ioctlsocket(mysock,FIONBIO,(unsigned int *)&i) == SOCKET_ERROR) return(0); if (!set_socket_blockmode(mysock,0)) return(0); #endif @@ -198,7 +198,7 @@ long netinit (long portnum) if (gethostname(hostnam,sizeof(hostnam)) != SOCKET_ERROR) if ((lpHostEnt = gethostbyname(hostnam))) { - myip = ip.sin_addr.s_addr = *(long *)lpHostEnt->h_addr; + myip = ip.sin_addr.s_addr = *(int *)lpHostEnt->h_addr; printf("mmulti: This machine's IP is %s\n", inet_ntoa(ip.sin_addr)); } return(1); @@ -206,7 +206,7 @@ long netinit (long portnum) return(0); } -long netsend (long other, char *dabuf, long bufsiz) //0:buffer full... can't send +int netsend(int other, char *dabuf, int bufsiz) //0:buffer full... can't send { struct sockaddr_in ip; @@ -234,10 +234,10 @@ long netsend (long other, char *dabuf, long bufsiz) //0:buffer full... can't sen return(sendto(mysock,dabuf,bufsiz,0,(struct sockaddr *)&ip,sizeof(struct sockaddr_in)) != SOCKET_ERROR); } -long netread (long *other, char *dabuf, long bufsiz) //0:no packets in buffer +int netread(int *other, char *dabuf, int bufsiz) //0:no packets in buffer { struct sockaddr_in ip; - long i; + int i; i = sizeof(ip); @@ -246,12 +246,12 @@ long netread (long *other, char *dabuf, long bufsiz) //0:no packets in buffer if ((rand()&255) < SIMMIS) return(0); #endif - snatchip = (long)ip.sin_addr.s_addr; snatchport = (long)ip.sin_port; + snatchip = (int)ip.sin_addr.s_addr; snatchport = (int)ip.sin_port; (*other) = myconnectindex; for (i=0;i= '0') && (st[i] <= '9')) - { num = num*10+st[i]-'0'; if (num >= 65536) return(0); } + { num = num*10+st[i]-'0'; if (num >= 65536) return(0); } else return(0); } return(1); } if ((st[i] >= '0') && (st[i] <= '9')) - { num = num*10+st[i]-'0'; if (num >= 256) return(0); } + { num = num*10+st[i]-'0'; if (num >= 256) return(0); } } return(bcnt == 3); @@ -323,19 +323,19 @@ long isvalidipaddress (char *st) //---------------------------------- Obsolete variables&functions ---------------------------------- char syncstate = 0; -void setpackettimeout (long datimeoutcount, long daresendagaincount) {} -void genericmultifunction (long other, char *bufptr, long messleng, long command) {} -long getoutputcirclesize () { return(0); } -void setsocket (long newsocket) { } -void flushpackets () {} -void sendlogon () {} -void sendlogoff () {} +void setpackettimeout(int datimeoutcount, int daresendagaincount) {} +void genericmultifunction(int other, char *bufptr, int messleng, int command) {} +int getoutputcirclesize() { return(0); } +void setsocket(int newsocket) { } +void flushpackets() {} +void sendlogon() {} +void sendlogoff() {} //-------------------------------------------------------------------------------------------------- -static long crctab16[256]; -static void initcrc16 () +static int crctab16[256]; +static void initcrc16() { - long i, j, k, a; + int i, j, k, a; for (j=0;j<256;j++) { for (i=7,k=(j<<8),a=0;i>=0;i--,k=((k<<1)&65535)) @@ -347,21 +347,21 @@ static void initcrc16 () } } #define updatecrc16(crc,dat) crc = (((crc<<8)&65535)^crctab16[((((unsigned short)crc)>>8)&65535)^dat]) -static unsigned short getcrc16 (char *buffer, long bufleng) +static unsigned short getcrc16(char *buffer, int bufleng) { - long i, j; + int i, j; j = 0; for (i=bufleng-1;i>=0;i--) updatecrc16(j,buffer[i]); return((unsigned short)(j&65535)); } -void uninitmultiplayers () { netuninit(); } +void uninitmultiplayers() { netuninit(); } -long getpacket(long *, char *); +int getpacket(int *, char *); static void initmultiplayers_reset(void) { - long i; + int i; initcrc16(); memset(icnt0,0,sizeof(icnt0)); @@ -393,23 +393,25 @@ static void initmultiplayers_reset(void) // 192.168.1.2 game /n1 192.168.1.100 game /n1 192.168.1.100 192.168.1.4 // 192.168.1.100 game 192.168.1.2 /n1 game 192.168.1.2 /n1 192.168.1.4 // 192.168.1.4 game 192.168.1.2 192.168.1.100 /n1 -long initmultiplayersparms(long argc, char **argv) +int initmultiplayersparms(int argc, char **argv) { - long i, j, daindex, portnum = NETPORT; + int i, j, daindex, portnum = NETPORT; char *st; initmultiplayers_reset(); danetmode = 255; daindex = 0; // go looking for the port, if specified - for (i=0;i 1024 && j<65535) portnum = j; - printf("mmulti: Using port %ld\n", portnum); + printf("mmulti: Using port %d\n", portnum); } } @@ -425,7 +427,8 @@ long initmultiplayersparms(long argc, char **argv) // { foundnet = 1; continue; } //if (!foundnet) continue; - if ((argv[i][0] == '-') || (argv[i][0] == '/')) { + if ((argv[i][0] == '-') || (argv[i][0] == '/')) + { if ((argv[i][1] == 'N') || (argv[i][1] == 'n') || (argv[i][1] == 'I') || (argv[i][1] == 'i')) { numplayers = 2; @@ -436,7 +439,7 @@ long initmultiplayersparms(long argc, char **argv) { numplayers = (argv[i][4]-'0'); if ((argv[i][5] >= '0') && (argv[i][5] <= '9')) numplayers = numplayers*10+(argv[i][5]-'0'); - printf("mmulti: %ld-player game\n", numplayers); + printf("mmulti: %d-player game\n", numplayers); } printf("mmulti: Master-slave mode\n"); } @@ -455,12 +458,13 @@ long initmultiplayersparms(long argc, char **argv) if (isvalidipaddress(st)) { if ((danetmode == 1) && (daindex == myconnectindex)) daindex++; - for (j=0;st[j];j++) { + for (j=0;st[j];j++) + { if (st[j] == ':') - { otherport[daindex] = htons((unsigned short)atol(&st[j+1])); st[j] = 0; break; } + { otherport[daindex] = htons((unsigned short)atol(&st[j+1])); st[j] = 0; break; } } otherip[daindex] = inet_addr(st); - printf("mmulti: Player %ld at %s:%d\n",daindex,st,ntohs(otherport[daindex])); + printf("mmulti: Player %d at %s:%d\n",daindex,st,ntohs(otherport[daindex])); daindex++; } else @@ -470,25 +474,26 @@ long initmultiplayersparms(long argc, char **argv) for (j=0;st[j];j++) if (st[j] == ':') - { pt = htons((unsigned short)atol(&st[j+1])); st[j] = 0; break; } + { pt = htons((unsigned short)atol(&st[j+1])); st[j] = 0; break; } if ((lph = gethostbyname(st))) { if ((danetmode == 1) && (daindex == myconnectindex)) daindex++; - otherip[daindex] = *(long *)lph->h_addr; + otherip[daindex] = *(int *)lph->h_addr; otherport[daindex] = pt; - printf("mmulti: Player %ld at %s:%d (%s)\n",daindex, + printf("mmulti: Player %d at %s:%d (%s)\n",daindex, inet_ntoa(*(struct in_addr *)lph->h_addr),ntohs(pt),argv[i]); daindex++; - } else printf("mmulti: Failed resolving %s\n",argv[i]); + } + else printf("mmulti: Failed resolving %s\n",argv[i]); } free(st); } -if ((danetmode == 255) && (daindex)) { numplayers = 2; danetmode = 0; } //an IP w/o /n# defaults to /n0 + if ((danetmode == 255) && (daindex)) { numplayers = 2; danetmode = 0; } //an IP w/o /n# defaults to /n0 if ((numplayers >= 2) && (daindex) && (!danetmode)) myconnectindex = 1; if (daindex > numplayers) numplayers = daindex; //for(i=0;i>8)&255,(otherip[i]>>16)&255,((unsigned long)otherip[i])>>24,ntohs(otherport[i])); + // printf("Player %d: %d.%d.%d.%d:%d\n",i,otherip[i]&255,(otherip[i]>>8)&255,(otherip[i]>>16)&255,((unsigned int)otherip[i])>>24,ntohs(otherport[i])); connecthead = 0; for (i=0;i= 2); } -long initmultiplayerscycle(void) +int initmultiplayerscycle(void) { - long i, k; - extern long totalclock; + int i, k; + extern int totalclock; idle(); - + getpacket(&i,0); tims = GetTickCount(); @@ -512,7 +517,8 @@ long initmultiplayerscycle(void) { for (i=numplayers-1;i>0;i--) if (!otherip[i]) break; - if (!i) { + if (!i) + { nfIncCP(); //Addfaz NatFree netready = 1; //Player 0 is ready return 0; @@ -527,11 +533,11 @@ long initmultiplayerscycle(void) lastsendtims[connecthead] = tims; // short crc16ofs; //offset of crc16 - // long icnt0; //-1 (special packet for MMULTI.C's player collection) + // int icnt0; //-1 (special packet for MMULTI.C's player collection) // ... // unsigned short crc16; //CRC16 of everything except crc16 k = 2; - *(long *)&pakbuf[k] = -1; k += 4; + *(int *)&pakbuf[k] = -1; k += 4; pakbuf[k++] = 0xaa; *(unsigned short *)&pakbuf[0] = (unsigned short)k; *(unsigned short *)&pakbuf[k] = getcrc16(pakbuf,k); k += 2; @@ -542,9 +548,9 @@ long initmultiplayerscycle(void) return 1; } -void initmultiplayers (long argc, char **argv, char damultioption, char dacomrateoption, char dapriority) +void initmultiplayers(int argc, char **argv, char damultioption, char dacomrateoption, char dapriority) { - long i, j, k, otims; + int i, j, k, otims; if (initmultiplayersparms(argc,argv)) { @@ -552,7 +558,7 @@ void initmultiplayers (long argc, char **argv, char damultioption, char dacomrat //Console code seems to crash Win98 upon quitting game //it's not necessary and it's not portable anyway char tbuf[1024]; - unsigned long u; + unsigned int u; HANDLE hconsout; AllocConsole(); SetConsoleTitle("Multiplayer status..."); @@ -570,7 +576,7 @@ void initmultiplayers (long argc, char **argv, char damultioption, char dacomrat { if (i == myconnectindex) { strcat(tbuf," "); continue; } if (!otherip[i]) { strcat(tbuf,"?.?.?.?:? "); continue; } - sprintf(&tbuf[strlen(tbuf)],"%d.%d.%d.%d:%04x ",otherip[i]&255,(otherip[i]>>8)&255,(otherip[i]>>16)&255,(((unsigned long)otherip[i])>>24),otherport[i]); + sprintf(&tbuf[strlen(tbuf)],"%d.%d.%d.%d:%04x ",otherip[i]&255,(otherip[i]>>8)&255,(otherip[i]>>16)&255,(((unsigned int)otherip[i])>>24),otherport[i]); } WriteConsole(hconsout,tbuf,strlen(tbuf),&u,0); } @@ -583,19 +589,19 @@ void initmultiplayers (long argc, char **argv, char damultioption, char dacomrat netready = 1; } -void dosendpackets (long other) //Host to send intially, client to send to others once heard from host. +void dosendpackets(int other) //Host to send intially, client to send to others once heard from host. { - long i, j, k; + int i, j, k; if (!otherip[other]) return; //Packet format: // short crc16ofs; //offset of crc16 - // long icnt0; //earliest unacked packet + // int icnt0; //earliest unacked packet // char ibits[32]; //ack status of packets icnt0<=i (long)sizeof(pakbuf)) break; + if (k+6+j+4 > (int)sizeof(pakbuf)) break; *(unsigned short *)&pakbuf[k] = (unsigned short)j; k += 2; - *(long *)&pakbuf[k] = i; k += 4; + *(int *)&pakbuf[k] = i; k += 4; memcpy(&pakbuf[k],&pakmem[opak[other][i&(FIFSIZ-1)]+2],j); k += j; } *(unsigned short *)&pakbuf[k] = 0; k += 2; @@ -636,13 +642,13 @@ void dosendpackets (long other) //Host to send intially, client to send to other /*Addfaz NatFree End*/ } -void sendpacket (long other, char *bufptr, long messleng) +void sendpacket(int other, char *bufptr, int messleng) { - long i, j; + int i, j; if (numplayers < 2) return; - if (pakmemi+messleng+2 > (long)sizeof(pakmem)) pakmemi = 1; + if (pakmemi+messleng+2 > (int)sizeof(pakmem)) pakmemi = 1; opak[other][ocnt1[other]&(FIFSIZ-1)] = pakmemi; *(short *)&pakmem[pakmemi] = messleng; memcpy(&pakmem[pakmemi+2],bufptr,messleng); pakmemi += messleng+2; @@ -655,9 +661,9 @@ void sendpacket (long other, char *bufptr, long messleng) //passing bufptr == 0 enables receive&sending raw packets but does not return any received packets //(used as hack for player collection) -long getpacket (long *retother, char *bufptr) +int getpacket(int *retother, char *bufptr) { - long i, j, k, ic0, crc16ofs, messleng, other; + int i, j, k, ic0, crc16ofs, messleng, other; if (numplayers < 2) return(0); @@ -674,22 +680,22 @@ long getpacket (long *retother, char *bufptr) { //Packet format: // short crc16ofs; //offset of crc16 - // long icnt0; //earliest unacked packet + // int icnt0; //earliest unacked packet // char ibits[32]; //ack status of packets icnt0<=i= icnt0[other]) && (!ipak[other][j&(FIFSIZ-1)])) { - if (pakmemi+messleng+2 > (long)sizeof(pakmem)) pakmemi = 1; + if (pakmemi+messleng+2 > (int)sizeof(pakmem)) pakmemi = 1; ipak[other][j&(FIFSIZ-1)] = pakmemi; *(short *)&pakmem[pakmemi] = messleng; memcpy(&pakmem[pakmemi+2],&pakbuf[k],messleng); pakmemi += messleng+2; } k += messleng; - messleng = (long)(*(unsigned short *)&pakbuf[k]); k += 2; + messleng = (int)(*(unsigned short *)&pakbuf[k]); k += 2; } } } @@ -829,7 +835,8 @@ int getexternaladdress(char *buffer) { WSADATA ws; - if (WSAStartup(0x101,&ws) == SOCKET_ERROR) { + if (WSAStartup(0x101,&ws) == SOCKET_ERROR) + { initprintf("mmulti: Winsock error in getexternaladdress() (%d)\n",errno); return(0); } @@ -837,7 +844,8 @@ int getexternaladdress(char *buffer) } #endif - if ((h=gethostbyname(host)) == NULL) { + if ((h=gethostbyname(host)) == NULL) + { initprintf("mmulti: gethostbyname() error in getexternaladdress() (%d)\n",h_errno); return(0); } @@ -850,19 +858,22 @@ int getexternaladdress(char *buffer) mysock = socket(PF_INET, SOCK_STREAM, 0); - - if (mysock == INVALID_SOCKET) { + + if (mysock == INVALID_SOCKET) + { initprintf("mmulti: socket() error in getexternaladdress() (%d)\n",errno); return(0); } - if (connect(mysock, (struct sockaddr *)&dest_addr, sizeof(struct sockaddr)) == SOCKET_ERROR) { + if (connect(mysock, (struct sockaddr *)&dest_addr, sizeof(struct sockaddr)) == SOCKET_ERROR) + { initprintf("mmulti: connect() error in getexternaladdress() (%d)\n",errno); return(0); } bytes_sent = send(mysock, req, strlen(req), 0); - if (bytes_sent == SOCKET_ERROR) { + if (bytes_sent == SOCKET_ERROR) + { initprintf("mmulti: send() error in getexternaladdress() (%d)\n",errno); return(0); } @@ -903,7 +914,8 @@ int getversionfromwebsite(char *buffer) // FIXME: this probably belongs in game { WSADATA ws; - if (WSAStartup(0x101,&ws) == SOCKET_ERROR) { + if (WSAStartup(0x101,&ws) == SOCKET_ERROR) + { initprintf("update: Winsock error in getversionfromwebsite() (%d)\n",errno); return(0); } @@ -911,7 +923,8 @@ int getversionfromwebsite(char *buffer) // FIXME: this probably belongs in game } #endif - if ((h=gethostbyname(host)) == NULL) { + if ((h=gethostbyname(host)) == NULL) + { initprintf("update: gethostbyname() error in getversionfromwebsite() (%d)\n",h_errno); return(0); } @@ -924,19 +937,22 @@ int getversionfromwebsite(char *buffer) // FIXME: this probably belongs in game mysock = socket(PF_INET, SOCK_STREAM, 0); - - if (mysock == INVALID_SOCKET) { + + if (mysock == INVALID_SOCKET) + { initprintf("update: socket() error in getversionfromwebsite() (%d)\n",errno); return(0); } - if (connect(mysock, (struct sockaddr *)&dest_addr, sizeof(struct sockaddr)) == SOCKET_ERROR) { + if (connect(mysock, (struct sockaddr *)&dest_addr, sizeof(struct sockaddr)) == SOCKET_ERROR) + { initprintf("update: connect() error in getversionfromwebsite() (%d)\n",errno); return(0); } bytes_sent = send(mysock, req, strlen(req), 0); - if (bytes_sent == SOCKET_ERROR) { + if (bytes_sent == SOCKET_ERROR) + { initprintf("update: send() error in getversionfromwebsite() (%d)\n",errno); return(0); } @@ -944,14 +960,15 @@ int getversionfromwebsite(char *buffer) // FIXME: this probably belongs in game // initprintf("sent %d bytes\n",bytes_sent); recv(mysock, (char *)&tempbuf, sizeof(tempbuf), 0); closesocket(mysock); - + memcpy(&otherbuf,&tempbuf,sizeof(otherbuf)); - + strtok(otherbuf," "); if (atol(strtok(NULL," ")) == 200) - { + { for (i=0;(unsigned)i 4) if (tempbuf[i-1] == '\n' && tempbuf[i-2] == '\r' && tempbuf[i-3] == '\n' && tempbuf[i-4] == '\r') { @@ -960,11 +977,11 @@ int getversionfromwebsite(char *buffer) // FIXME: this probably belongs in game ver[j] = tempbuf[i]; i++, j++; } - ver[j] = '\0'; + ver[j] = '\0'; break; } } - + if (j) { strcpy(buffer,ver); diff --git a/polymer/build/src/mmulti_null.c b/polymer/build/src/mmulti_null.c index 71a115b1e..d7e25996d 100644 --- a/polymer/build/src/mmulti_null.c +++ b/polymer/build/src/mmulti_null.c @@ -9,32 +9,32 @@ #include "mmulti.h" -long myconnectindex, numplayers; -long connecthead, connectpoint2[MAXMULTIPLAYERS]; +int myconnectindex, numplayers; +int connecthead, connectpoint2[MAXMULTIPLAYERS]; char syncstate = 0; -long isvalidipaddress (char *st) +int isvalidipaddress(char *st) { return 0; } -long initmultiplayersparms(long argc, char **argv) +int initmultiplayersparms(int argc, char **argv) { return 0; } -long initmultiplayerscycle(void) +int initmultiplayerscycle(void) { return 0; } -void initmultiplayers(long argc, char **argv, char damultioption, char dacomrateoption, char dapriority) +void initmultiplayers(int argc, char **argv, char damultioption, char dacomrateoption, char dapriority) { numplayers = 1; myconnectindex = 0; connecthead = 0; connectpoint2[0] = -1; } -void setpackettimeout(long datimeoutcount, long daresendagaincount) +void setpackettimeout(int datimeoutcount, int daresendagaincount) { } @@ -50,7 +50,7 @@ void sendlogoff(void) { } -long getoutputcirclesize(void) +int getoutputcirclesize(void) { return 0; } @@ -59,11 +59,11 @@ void setsocket(short newsocket) { } -void sendpacket(long other, char *bufptr, long messleng) +void sendpacket(int other, char *bufptr, int messleng) { } -long getpacket (long *other, char *bufptr) +int getpacket(int *other, char *bufptr) { return 0; } @@ -72,7 +72,7 @@ void flushpackets(void) { } -void genericmultifunction(long other, char *bufptr, long messleng, long command) +void genericmultifunction(int other, char *bufptr, int messleng, int command) { } diff --git a/polymer/build/src/osd.c b/polymer/build/src/osd.c index 2f319f216..7bbfa0a22 100644 --- a/polymer/build/src/osd.c +++ b/polymer/build/src/osd.c @@ -8,7 +8,8 @@ #include "baselayer.h" -typedef struct _symbol { +typedef struct _symbol +{ const char *name; struct _symbol *next; @@ -61,7 +62,7 @@ static BFILE *osdlog=NULL; // log filehandle static char osdinited=0; // text buffer initialised? static int osdkey=0x29; // tilde shows the osd static int keytime=0; -static long osdscrtime = 0; +static int osdscrtime = 0; // command prompt editing #define EDITLENGTH 512 @@ -114,7 +115,8 @@ static void _internal_drawosdchar(int x, int y, char ch, int shade, int pal) st[0] = ch; - if (white<0) { + if (white<0) + { // find the palette index closest to white k=0; for (i=0;i<256;i++) @@ -136,7 +138,8 @@ static void _internal_drawosdstr(int x, int y, char *ch, int len, int shade, int memcpy(st,ch,len); st[len]=0; - if (white<0) { + if (white<0) + { // find the palette index closest to white k=0; for (i=0;i<256;i++) @@ -156,7 +159,8 @@ static void _internal_drawosdcursor(int x, int y, int type, int lastkeypress) if (type) st[0] = '#'; - if (white<0) { + if (white<0) + { // find the palette index closest to white k=0; for (i=0;i<256;i++) @@ -198,9 +202,11 @@ static int _internal_osdfunc_vars(const osdfuncparm_t *parm) { int showval = (parm->numparms < 1); - if (!Bstrcasecmp(parm->name, "osdrows")) { + if (!Bstrcasecmp(parm->name, "osdrows")) + { if (showval) { OSD_Printf("osdrows is %d\n", osdrows); return OSDCMD_OK; } - else { + else + { osdrows = atoi(parm->parms[0]); if (osdrows < 1) osdrows = 1; else if (osdrows > osdmaxrows) osdrows = osdmaxrows; @@ -228,9 +234,12 @@ static int _internal_osdfunc_help(const osdfuncparm_t *parm) if (parm->numparms != 1) return OSDCMD_SHOWHELP; symb = findexactsymbol(parm->parms[0]); - if (!symb) { + if (!symb) + { OSD_Printf("Help Error: \"%s\" is not a defined variable or function\n", parm->parms[0]); - } else { + } + else + { OSD_Printf("%s\n", symb->help); } @@ -254,7 +263,8 @@ void OSD_Cleanup(void) { symbol_t *s; - for (; symbols; symbols=s) { + for (; symbols; symbols=s) + { s=symbols->next; Bfree(symbols); } @@ -372,23 +382,28 @@ int OSD_HandleKey(int sc, int press) if (!osdinited) return sc; - if (sc == osdkey) { - if (press) { + if (sc == osdkey) + { + if (press) + { osdscroll = -osdscroll; if (osdrowscur == -1) osdscroll = 1; else if (osdrowscur == osdrows) osdscroll = -1; - osdrowscur += osdscroll; + osdrowscur += osdscroll; OSD_CaptureInput(osdscroll == 1); osdscrtime = getticks(); } return 0;//sc; - } else if (!osdinput) { + } + else if (!osdinput) + { return sc; } - if (!press) { + if (!press) + { if (sc == 42 || sc == 54) // shift osdeditshift = 0; if (sc == 29 || sc == 157) // control @@ -400,22 +415,36 @@ int OSD_HandleKey(int sc, int press) if (sc != 15) lastmatch = NULL; // tab - while ( (ch = bgetchar()) ) { - if (ch == 1) { // control a. jump to beginning of line - } else if (ch == 2) { // control b, move one character left - } else if (ch == 5) { // control e, jump to end of line - } else if (ch == 6) { // control f, move one character right - } else if (ch == 8 || ch == 127) { // control h, backspace + while ((ch = bgetchar())) + { + if (ch == 1) // control a. jump to beginning of line + { + } + else if (ch == 2) // control b, move one character left + { + } + else if (ch == 5) // control e, jump to end of line + { + } + else if (ch == 6) // control f, move one character right + { + } + else if (ch == 8 || ch == 127) // control h, backspace + { if (!osdeditcursor || !osdeditlen) return 0; - if (!osdovertype) { + if (!osdovertype) + { if (osdeditcursor < osdeditlen) Bmemmove(osdeditbuf+osdeditcursor-1, osdeditbuf+osdeditcursor, osdeditlen-osdeditcursor); osdeditlen--; } osdeditcursor--; if (osdeditcursor0;i--) if (osdeditbuf[i-1] == ' ') break; for (j=0;osdeditbuf[i] != ' ' && i < osdeditlen;j++,i++) osdedittmp[j] = osdeditbuf[i]; @@ -424,7 +453,7 @@ int OSD_HandleKey(int sc, int press) if (j > 0) { tabc = findsymbol(osdedittmp, NULL); - + if (tabc) { if (tabc->next) @@ -438,19 +467,22 @@ int OSD_HandleKey(int sc, int press) { OSD_Printf(" %s\n", symb->name); lastmatch = symb; - symb=findsymbol(osdedittmp, lastmatch->next); + symb=findsymbol(osdedittmp, lastmatch->next); } } } } } - } else { + } + else + { tabc = findsymbol(osdedittmp, lastmatch->next); if (!tabc && lastmatch) tabc = findsymbol(osdedittmp, NULL); // wrap } - if (tabc) { + if (tabc) + { for (i=osdeditcursor;i>0;i--) if (osdeditbuf[i-1] == ' ') break; osdeditlen = i; for (j=0;tabc->name[j] && osdeditlen <= EDITLENGTH;i++,j++,osdeditlen++) @@ -458,19 +490,27 @@ int OSD_HandleKey(int sc, int press) osdeditcursor = osdeditlen; osdeditwinend = osdeditcursor; osdeditwinstart = osdeditwinend-editlinewidth; - if (osdeditwinstart<0) { + if (osdeditwinstart<0) + { osdeditwinstart=0; osdeditwinend = editlinewidth; } lastmatch = tabc; } - } else if (ch == 11) { // control k, delete all to end of line - } else if (ch == 12) { // control l, clear screen + } + else if (ch == 11) // control k, delete all to end of line + { + } + else if (ch == 12) // control l, clear screen + { Bmemset(osdtext,0,sizeof(osdtext)); osdlines = 1; - } else if (ch == 13) { // control m, enter - if (osdeditlen>0) { + } + else if (ch == 13) // control m, enter + { + if (osdeditlen>0) + { osdeditbuf[osdeditlen] = 0; Bmemmove(osdhistorybuf[1], osdhistorybuf[0], HISTORYDEPTH*(EDITLENGTH+1)); Bmemmove(osdhistorybuf[0], osdeditbuf, EDITLENGTH+1); @@ -487,10 +527,17 @@ int OSD_HandleKey(int sc, int press) osdeditcursor=0; osdeditwinstart=0; osdeditwinend=editlinewidth; - } else if (ch == 16) { // control p, previous (ie. up arrow) - } else if (ch == 20) { // control t, swap previous two chars - } else if (ch == 21) { // control u, delete all to beginning - if (osdeditcursor>0 && osdeditlen) { + } + else if (ch == 16) // control p, previous (ie. up arrow) + { + } + else if (ch == 20) // control t, swap previous two chars + { + } + else if (ch == 21) // control u, delete all to beginning + { + if (osdeditcursor>0 && osdeditlen) + { if (osdeditcursor0 && osdeditlen>0) { + } + else if (ch == 23) // control w, delete one word back + { + if (osdeditcursor>0 && osdeditlen>0) + { i=osdeditcursor; while (i>0 && osdeditbuf[i-1]==32) i--; while (i>0 && osdeditbuf[i-1]!=32) i--; @@ -507,20 +557,26 @@ int OSD_HandleKey(int sc, int press) Bmemmove(osdeditbuf+i, osdeditbuf+osdeditcursor, osdeditlen-osdeditcursor); osdeditlen -= (osdeditcursor-i); osdeditcursor = i; - if (osdeditcursor < osdeditwinstart) { + if (osdeditcursor < osdeditwinstart) + { osdeditwinstart=osdeditcursor; osdeditwinend=osdeditwinstart+editlinewidth; } } - } else if (ch >= 32) { // text char + } + else if (ch >= 32) // text char + { if (!osdovertype && osdeditlen == EDITLENGTH) // buffer full, can't insert another char return 0; - if (!osdovertype) { + if (!osdovertype) + { if (osdeditcursor < osdeditlen) Bmemmove(osdeditbuf+osdeditcursor+1, osdeditbuf+osdeditcursor, osdeditlen-osdeditcursor); osdeditlen++; - } else { + } + else + { if (osdeditcursor == osdeditlen) osdeditlen++; } @@ -530,124 +586,183 @@ int OSD_HandleKey(int sc, int press) } } - if (sc == 15) { // tab - } else if (sc == 1) { // escape -// OSD_ShowDisplay(0); - osdscroll = -1; - osdrowscur += osdscroll; - OSD_CaptureInput(0); - osdscrtime = getticks(); - } else if (sc == 201) { // page up + if (sc == 15) // tab + { + } + else if (sc == 1) // escape +{ + // OSD_ShowDisplay(0); + osdscroll = -1; + osdrowscur += osdscroll; + OSD_CaptureInput(0); + osdscrtime = getticks(); + } + else if (sc == 201) // page up + { if (osdhead < osdlines-1) osdhead++; - } else if (sc == 209) { // page down + } + else if (sc == 209) // page down + { if (osdhead > 0) osdhead--; - } else if (sc == 199) { // home - if (osdeditcontrol) { + } + else if (sc == 199) // home + { + if (osdeditcontrol) + { osdhead = osdlines-1; - } else { + } + else + { osdeditcursor = 0; osdeditwinstart = osdeditcursor; osdeditwinend = osdeditwinstart+editlinewidth; } - } else if (sc == 207) { // end - if (osdeditcontrol) { + } + else if (sc == 207) // end + { + if (osdeditcontrol) + { osdhead = 0; - } else { + } + else + { osdeditcursor = osdeditlen; osdeditwinend = osdeditcursor; osdeditwinstart = osdeditwinend-editlinewidth; - if (osdeditwinstart<0) { + if (osdeditwinstart<0) + { osdeditwinstart=0; osdeditwinend = editlinewidth; } } - } else if (sc == 210) { // insert + } + else if (sc == 210) // insert + { osdovertype ^= 1; - } else if (sc == 203) { // left - if (osdeditcursor>0) { - if (osdeditcontrol) { - while (osdeditcursor>0) { + } + else if (sc == 203) // left + { + if (osdeditcursor>0) + { + if (osdeditcontrol) + { + while (osdeditcursor>0) + { if (osdeditbuf[osdeditcursor-1] != 32) break; osdeditcursor--; } - while (osdeditcursor>0) { + while (osdeditcursor>0) + { if (osdeditbuf[osdeditcursor-1] == 32) break; osdeditcursor--; } - } else osdeditcursor--; + } + else osdeditcursor--; } if (osdeditcursor=osdeditwinend) osdeditwinstart+=(osdeditcursor-osdeditwinend), osdeditwinend+=(osdeditcursor-osdeditwinend); - } else if (sc == 200) { // up - if (osdhistorypos < osdhistorysize-1) { + } + else if (sc == 200) // up + { + if (osdhistorypos < osdhistorysize-1) + { osdhistorypos++; memcpy(osdeditbuf, osdhistorybuf[osdhistorypos], EDITLENGTH+1); osdeditlen = osdeditcursor = 0; while (osdeditbuf[osdeditcursor]) osdeditlen++, osdeditcursor++; - if (osdeditcursor=osdeditwinend) + } + else if (osdeditcursor>=osdeditwinend) osdeditwinstart+=(osdeditcursor-osdeditwinend), osdeditwinend+=(osdeditcursor-osdeditwinend); } - } else if (sc == 208) { // down - if (osdhistorypos >= 0) { - if (osdhistorypos == 0) { + } + else if (sc == 208) // down + { + if (osdhistorypos >= 0) + { + if (osdhistorypos == 0) + { osdeditlen=0; osdeditcursor=0; osdeditwinstart=0; osdeditwinend=editlinewidth; osdhistorypos = -1; - } else { + } + else + { osdhistorypos--; memcpy(osdeditbuf, osdhistorybuf[osdhistorypos], EDITLENGTH+1); osdeditlen = osdeditcursor = 0; while (osdeditbuf[osdeditcursor]) osdeditlen++, osdeditcursor++; - if (osdeditcursor=osdeditwinend) + } + else if (osdeditcursor>=osdeditwinend) osdeditwinstart+=(osdeditcursor-osdeditwinend), osdeditwinend+=(osdeditcursor-osdeditwinend); } } - } else if (sc == 42 || sc == 54) { // shift + } + else if (sc == 42 || sc == 54) // shift + { osdeditshift = 1; - } else if (sc == 29 || sc == 157) { // control + } + else if (sc == 29 || sc == 157) // control + { osdeditcontrol = 1; - } else if (sc == 58) { // capslock + } + else if (sc == 58) // capslock + { osdeditcaps ^= 1; - } else if (sc == 28 || sc == 156) { // enter - } else if (sc == 14) { // backspace - } else if (sc == 211) { // delete + } + else if (sc == 28 || sc == 156) // enter + { + } + else if (sc == 14) // backspace + { + } + else if (sc == 211) // delete + { if (osdeditcursor == osdeditlen || !osdeditlen) return 0; if (osdeditcursor <= osdeditlen-1) Bmemmove(osdeditbuf+osdeditcursor, osdeditbuf+osdeditcursor+1, osdeditlen-osdeditcursor-1); osdeditlen--; @@ -675,7 +790,8 @@ void OSD_ResizeDisplay(int w, int h) k = min(newcols, osdcols); memset(newtext, 32, TEXTSIZE); - for (i=0;i0; lines--, row--) { + + for (; lines>0; lines--, row--) + { drawosdstr(0,row,osdtext+topoffs,osdcols,osdtextshade,osdtextpal); topoffs+=osdcols; } @@ -791,7 +908,7 @@ void OSD_Draw(void) drawosdchar(3+x,osdrowscur,osdeditbuf[osdeditwinstart+x],osdeditshade,osdeditpal); drawosdcursor(3+osdeditcursor-osdeditwinstart,osdrowscur,osdovertype,keytime); - + enddrawing(); } @@ -822,14 +939,19 @@ void OSD_Printf(const char *fmt, ...) if (osdlog) Bfputs(tmpstr, osdlog); - for (chp = tmpstr; *chp; chp++) { + for (chp = tmpstr; *chp; chp++) + { if (*chp == '\r') osdpos=0; - else if (*chp == '\n') { + else if (*chp == '\n') + { osdpos=0; linefeed(); - } else { + } + else + { osdtext[osdpos++] = *chp; - if (osdpos == osdcols) { + if (osdpos == osdcols) + { osdpos = 0; linefeed(); } @@ -850,7 +972,8 @@ void OSD_DispatchQueued(void) cmd=osdexeccount-1; osdexeccount=0; - for (; cmd>=0; cmd--) { + for (; cmd>=0; cmd--) + { OSD_Dispatch((const char *)osdhistorybuf[cmd]); } } @@ -879,27 +1002,35 @@ static char *strtoken(char *s, char **ptrptr, int *restart) // a semicolon is an end of statement delimiter like a \0 is, so we signal // the caller to 'restart' for the rest of the string pointed at by *ptrptr - if (*p == ';') { + if (*p == ';') + { *restart = 1; *ptrptr = p+1; return NULL; } // or if we hit the end of the input, signal all done by nulling *ptrptr - else if (*p == 0) { + else if (*p == 0) + { *ptrptr = NULL; return NULL; } - if (*p == '\"') { + if (*p == '\"') + { // quoted string start = ++p; p2 = p; - while (*p != 0) { - if (*p == '\"') { + while (*p != 0) + { + if (*p == '\"') + { p++; break; - } else if (*p == '\\') { - switch (*(++p)) { + } + else if (*p == '\\') + { + switch (*(++p)) + { case 'n': *p2 = '\n'; break; case 'r': @@ -907,30 +1038,37 @@ static char *strtoken(char *s, char **ptrptr, int *restart) default: *p2 = *p; break; } - } else { + } + else + { *p2 = *p; } p2++, p++; } *p2 = 0; - } else { + } + else + { start = p; while (*p != 0 && *p != ';' && *p != ' ') p++; } // if we hit the end of input, signal all done by nulling *ptrptr - if (*p == 0) { + if (*p == 0) + { *ptrptr = NULL; } // or if we came upon a semicolon, signal caller to restart with the // string at *ptrptr - else if (*p == ';') { + else if (*p == ';') + { *p = 0; *ptrptr = p+1; *restart = 1; } // otherwise, clip off the token and carry on - else { + else + { *(p++) = 0; *ptrptr = p; } @@ -951,31 +1089,36 @@ int OSD_Dispatch(const char *cmd) workbuf = state = Bstrdup(cmd); if (!workbuf) return -1; - do { + do + { numparms = 0; Bmemset(parms, 0, sizeof(parms)); wp = strtoken(state, &wtp, &restart); - if (!wp) { + if (!wp) + { state = wtp; continue; } symb = findexactsymbol(wp); - if (!symb) { + if (!symb) + { OSD_Printf("Error: \"%s\" is not defined\n", wp); free(workbuf); return -1; } ofp.name = wp; - while (wtp && !restart) { + while (wtp && !restart) + { wp = strtoken(NULL, &wtp, &restart); if (wp && numparms < MAXPARMS) parms[numparms++] = wp; } ofp.numparms = numparms; ofp.parms = (const char **)parms; ofp.raw = cmd; - switch (symb->func(&ofp)) { + switch (symb->func(&ofp)) + { case OSDCMD_OK: break; case OSDCMD_SHOWHELP: @@ -983,7 +1126,8 @@ int OSD_Dispatch(const char *cmd) } state = wtp; - } while (wtp && restart); + } + while (wtp && restart); free(workbuf); @@ -1001,44 +1145,52 @@ int OSD_RegisterFunction(const char *name, const char *help, int (*func)(const o if (!osdinited) OSD_Init(); - if (!name) { + if (!name) + { Bprintf("OSD_RegisterFunction(): may not register a function with a null name\n"); return -1; } - if (!name[0]) { + if (!name[0]) + { Bprintf("OSD_RegisterFunction(): may not register a function with no name\n"); return -1; } // check for illegal characters in name - for (cp = name; *cp; cp++) { - if ((cp == name) && (*cp >= '0') && (*cp <= '9')) { + for (cp = name; *cp; cp++) + { + if ((cp == name) && (*cp >= '0') && (*cp <= '9')) + { Bprintf("OSD_RegisterFunction(): first character of function name \"%s\" must not be a numeral\n", name); return -1; } if ((*cp < '0') || (*cp > '9' && *cp < 'A') || (*cp > 'Z' && *cp < 'a' && *cp != '_') || - (*cp > 'z')) { + (*cp > 'z')) + { Bprintf("OSD_RegisterFunction(): illegal character in function name \"%s\"\n", name); return -1; } } if (!help) help = "(no description for this function)"; - if (!func) { + if (!func) + { Bprintf("OSD_RegisterFunction(): may not register a null function\n"); return -1; } symb = findexactsymbol(name); - if (symb) { + if (symb) + { Bprintf("OSD_RegisterFunction(): \"%s\" is already defined\n", name); return -1; } symb = addnewsymbol(name); - if (!symb) { + if (!symb) + { Bprintf("OSD_RegisterFunction(): Failed registering function \"%s\"\n", name); return -1; } @@ -1076,16 +1228,23 @@ static symbol_t *addnewsymbol(const char *name) Bmemset(newsymb, 0, sizeof(symbol_t)); // link it to the main chain - if (!symbols) { + if (!symbols) + { symbols = newsymb; - } else { - if (Bstrcasecmp(name, symbols->name) <= 0) { + } + else + { + if (Bstrcasecmp(name, symbols->name) <= 0) + { t = symbols; symbols = newsymb; symbols->next = t; - } else { + } + else + { s = symbols; - while (s->next) { + while (s->next) + { if (Bstrcasecmp(s->next->name, name) > 0) break; s=s->next; } diff --git a/polymer/build/src/polymer.c b/polymer/build/src/polymer.c index 4a52b9453..631e90250 100644 --- a/polymer/build/src/polymer.c +++ b/polymer/build/src/polymer.c @@ -148,7 +148,7 @@ void polymer_loadboard(void) if (pr_verbosity >= 1) OSD_Printf("PR : Board loaded.\n"); } -void polymer_drawrooms(long daposx, long daposy, long daposz, short daang, long dahoriz, short dacursectnum, int root) +void polymer_drawrooms(int daposx, int daposy, int daposz, short daang, int dahoriz, short dacursectnum, int root) { int i, j; float ang, horizang, tiltang; @@ -253,16 +253,16 @@ void polymer_drawrooms(long daposx, long daposy, long daposz, sho if (pr_verbosity >= 3) OSD_Printf("PR : Rooms drawn.\n"); } -void polymer_rotatesprite(long sx, long sy, long z, short a, short picnum, signed char dashade, char dapalnum, char dastat, long cx1, long cy1, long cx2, long cy2) +void polymer_rotatesprite(int sx, int sy, int z, short a, short picnum, signed char dashade, char dapalnum, char dastat, int cx1, int cy1, int cx2, int cy2) { } -void polymer_drawmaskwall(long damaskwallcnt) +void polymer_drawmaskwall(int damaskwallcnt) { OSD_Printf("PR : Masked wall %i...\n", damaskwallcnt); } -void polymer_drawsprite(long snum) +void polymer_drawsprite(int snum) { OSD_Printf("PR : Sprite %i...\n", snum); } @@ -310,10 +310,10 @@ int polymer_updatesector(short sectnum) sectortype *sec; walltype *wal; int i, j; - long ceilz, florz; - long tex, tey; + int ceilz, florz; + int tex, tey; float secangcos, secangsin, scalecoef; - long ang; + int ang; short curstat, curpicnum; char curxpanning, curypanning; GLfloat* curbuffer; @@ -431,7 +431,8 @@ int polymer_updatesector(short sectnum) pth = gltexcache(curpicnum,curxpanning,0); - if (pth && (pth->flags & 2) && (pth->palnum != curxpanning)) { + if (pth && (pth->flags & 2) && (pth->palnum != curxpanning)) + { curbuffer[0] *= (float)hictinting[curxpanning].r / 255.0; curbuffer[1] *= (float)hictinting[curxpanning].g / 255.0; curbuffer[2] *= (float)hictinting[curxpanning].b / 255.0; @@ -464,7 +465,8 @@ int polymer_updatesector(short sectnum) void PR_CALLBACK polymer_tesscombine(GLdouble v[3], GLdouble *data[4], GLfloat weight[4], GLdouble **out) -{ // This callback is called by the tesselator when it detects an intersection between contours (HELLO ROTATING SPOTLIGHT IN E1L1). +{ + // This callback is called by the tesselator when it detects an intersection between contours (HELLO ROTATING SPOTLIGHT IN E1L1). GLdouble* ptr; tempvertice[0] = v[0]; @@ -479,13 +481,15 @@ void PR_CALLBACK polymer_tesscombine(GLdouble v[3], GLdouble *data[4], GLfloa void PR_CALLBACK polymer_tesserror(GLenum error) -{ // This callback is called by the tesselator whenever it raises an error. +{ + // This callback is called by the tesselator whenever it raises an error. if (pr_verbosity >= 1) OSD_Printf("PR : Tesselation error number %i reported : %s.\n", error, bgluErrorString(errno)); } void PR_CALLBACK polymer_tessedgeflag(GLenum error) -{ // Passing an edgeflag callback forces the tesselator to output a triangle list +{ + // Passing an edgeflag callback forces the tesselator to output a triangle list return; } @@ -506,7 +510,8 @@ void PR_CALLBACK polymer_tessvertex(void* vertex, void* sector) s->curindice++; } int polymer_buildfloor(short sectnum) -{ // This function tesselates the floor/ceiling of a sector and stores the triangles in a display list. +{ + // This function tesselates the floor/ceiling of a sector and stores the triangles in a display list. _prsector* s; sectortype *sec; int i; @@ -571,7 +576,7 @@ void polymer_drawsector(short sectnum) walltype *wal; _prsector* s; int i; - long zdiff; + int zdiff; if (pr_verbosity >= 3) OSD_Printf("PR : Drawing sector %i...\n", sectnum); @@ -655,7 +660,7 @@ void polymer_updatewall(short wallnum) _prwall *w; _prsector *s, *ns; pthtyp* pth; - long xref, yref, xdif, ydif; + int xref, yref, xdif, ydif; float ypancoef, dist; int i; @@ -699,7 +704,8 @@ void polymer_updatewall(short wallnum) else w->wallfbglpic = 0; - if (pth && (pth->flags & 2) && (pth->palnum != wal->pal)) { + if (pth && (pth->flags & 2) && (pth->palnum != wal->pal)) + { w->wallcolor[0] *= (float)hictinting[wal->pal].r / 255.0; w->wallcolor[1] *= (float)hictinting[wal->pal].g / 255.0; w->wallcolor[2] *= (float)hictinting[wal->pal].b / 255.0; @@ -780,7 +786,8 @@ void polymer_updatewall(short wallnum) else w->wallfbglpic = 0; - if (pth && (pth->flags & 2) && (pth->palnum != wal->pal)) { + if (pth && (pth->flags & 2) && (pth->palnum != wal->pal)) + { w->wallcolor[0] *= (float)hictinting[wal->pal].r / 255.0; w->wallcolor[1] *= (float)hictinting[wal->pal].g / 255.0; w->wallcolor[2] *= (float)hictinting[wal->pal].b / 255.0; @@ -853,7 +860,8 @@ void polymer_updatewall(short wallnum) memcpy(w->overcolor, w->wallcolor, sizeof(GLfloat) * 4); - if (pth && (pth->flags & 2) && (pth->palnum != wal->pal)) { + if (pth && (pth->flags & 2) && (pth->palnum != wal->pal)) + { w->overcolor[0] *= (float)hictinting[wal->pal].r / 255.0; w->overcolor[1] *= (float)hictinting[wal->pal].g / 255.0; w->overcolor[2] *= (float)hictinting[wal->pal].b / 255.0; @@ -972,7 +980,8 @@ void polymer_extractfrustum(GLdouble* modelview, GLdouble* projec } i = 0; while (i < 5) - { // frustum plane norms + { + // frustum plane norms frustumnorms[i] = sqrt((frustum[(i * 4) + 0] * frustum[(i * 4) + 0]) + (frustum[(i * 4) + 1] * frustum[(i * 4) + 1]) + (frustum[(i * 4) + 2] * frustum[(i * 4) + 2])); @@ -1030,7 +1039,8 @@ void polymer_drawroom(short sectnum) } int polymer_checkportal(short wallnum) -{ // Returns 1 if the wall is in the current portal and sets the current portal to the wall, returns 0 otherwise +{ + // Returns 1 if the wall is in the current portal and sets the current portal to the wall, returns 0 otherwise GLint wallportal[4], newportal[4]; int mask, portalpointcount; @@ -1041,7 +1051,8 @@ int polymer_checkportal(short wallnum) if (mask == 0) return (0); // not visible if (mask > 1) - { // only some points visible, clip the polygon to the viewport + { + // only some points visible, clip the polygon to the viewport portalpointcount = polymer_cliptofrustum(wallnum, mask); polymer_getportal(portalpoints, portalpointcount, wallportal); } @@ -1052,10 +1063,10 @@ int polymer_checkportal(short wallnum) return (0); // the wall is totally outside the current portal // we need to find the intersection of the current portal and the wall portal - newportal[0] = portal[0] + (klabs(wallportal[0] - portal[0]) + (wallportal[0] - portal[0])) / 2; + newportal[0] = portal[0] + (klabs(wallportal[0] - portal[0]) + (wallportal[0] - portal[0])) / 2; newportal[1] = portal[1] + (klabs(wallportal[1] - portal[1]) + (wallportal[1] - portal[1])) / 2; - newportal[2] = portal[2] + ((wallportal[2] - portal[2]) - klabs(wallportal[2] - portal[2])) / 2; - newportal[3] = portal[3] + ((wallportal[3] - portal[3]) - klabs(wallportal[3] - portal[3])) / 2; + newportal[2] = portal[2] + ((wallportal[2] - portal[2]) - klabs(wallportal[2] - portal[2])) / 2; + newportal[3] = portal[3] + ((wallportal[3] - portal[3]) - klabs(wallportal[3] - portal[3])) / 2; // update the view portal if (pr_verbosity >= 3) OSD_Printf("PR : Updating portal...\n"); @@ -1128,12 +1139,14 @@ void polymer_lineplaneintersection(GLfloat *point1, GLfloat *poin } int polymer_cliptofrustum(short wallnum, int mask) -{ // sutherland-hofnman polygon clipping algorithm against all planes of the frustum +{ + // sutherland-hofnman polygon clipping algorithm against all planes of the frustum GLfloat intersect[3]; int i, j, k, l, m, result, exitpoint; if (portalpoints == NULL) - { // one-time initialization + { + // one-time initialization portalpoints = calloc(4, sizeof(GLfloat) * 3); distances = calloc(4, sizeof(float)); maxportalpointcount = 4; @@ -1143,7 +1156,8 @@ int polymer_cliptofrustum(short wallnum, int mask) memcpy(portalpoints, prwalls[wallnum]->portal, sizeof(GLfloat) * 3 * 4); i = 0; while (i < 4) - { // frustum planes + { + // frustum planes j = k = 0; m = -1; while (j < result) @@ -1157,7 +1171,8 @@ int polymer_cliptofrustum(short wallnum, int mask) } if ((k) && (m != -1)) - { // divide and conquer while we may + { + // divide and conquer while we may j = m; while ((j != m) || (k)) { @@ -1166,21 +1181,24 @@ int polymer_cliptofrustum(short wallnum, int mask) k = 0; if (pr_verbosity >= 3) OSD_Printf("PR : Clipping against frustum plane %d starting with point %d...\n", i, m); } - + l = j + 1; // L is next point if (l == result) l = 0; - + if ((distances[j] >= 0) && (distances[l] < 0)) - { // case 1 : line exits the plane -> compute intersection + { + // case 1 : line exits the plane -> compute intersection polymer_lineplaneintersection(&portalpoints[j * 3], &portalpoints[l * 3], distances[j], distances[l], intersect); exitpoint = l; if (pr_verbosity >= 3) OSD_Printf("PR : %d: EXIT\n", j); } else if ((distances[j] < 0) && (distances[l] < 0)) - { // case 2 : line is totally outside the plane + { + // case 2 : line is totally outside the plane if (j != exitpoint) - { // if we didn't just exit we need to delete this point forever + { + // if we didn't just exit we need to delete this point forever result--; if (j != result) { @@ -1190,7 +1208,7 @@ int polymer_cliptofrustum(short wallnum, int mask) { m--; } - l--; + l--; } if (l == result) l = 0; @@ -1200,9 +1218,11 @@ int polymer_cliptofrustum(short wallnum, int mask) if (pr_verbosity >= 3) OSD_Printf("PR : %d: IN\n", j); } else if ((distances[j] < 0) && (distances[l] >= 0)) - { // case 3 : we're going back into the plane -> replace current point with intersection + { + // case 3 : we're going back into the plane -> replace current point with intersection if (j == exitpoint) - { // if we just exited a point is created + { + // if we just exited a point is created if (result == maxportalpointcount) { portalpoints = realloc(portalpoints, sizeof(GLfloat) * 3 * (maxportalpointcount + 1)); @@ -1232,7 +1252,7 @@ int polymer_cliptofrustum(short wallnum, int mask) j = l; // L } } - + if (pr_verbosity >= 3) OSD_Printf("PR : Plane %d finished, result : %d.\n", i, result); i++; diff --git a/polymer/build/src/polymost.c b/polymer/build/src/polymost.c index 90f18a0ed..d0a32567a 100644 --- a/polymer/build/src/polymost.c +++ b/polymer/build/src/polymost.c @@ -65,15 +65,15 @@ Low priority: **************************************************************************************************/ -long animateoffs(short tilenum, short fakevar); -long rendmode = 0; -long usemodels=1, usehightile=1; +int animateoffs(short tilenum, short fakevar); +int rendmode = 0; +int usemodels=1, usehightile=1; #include //<-important! -typedef struct { float x, cy[2], fy[2]; long n, p, tag, ctag, ftag; } vsptyp; +typedef struct { float x, cy[2], fy[2]; int n, p, tag, ctag, ftag; } vsptyp; #define VSPMAX 4096 //<- careful! static vsptyp vsp[VSPMAX]; -static long vcnt, gtag; +static int vcnt, gtag; static double dxb1[MAXWALLSB], dxb2[MAXWALLSB]; @@ -95,53 +95,55 @@ double gvo, gvx, gvy; double gdo, gdx, gdy; #if (USEZBUFFER != 0) -long zbufmem = 0, zbufysiz = 0, zbufbpl = 0, *zbufoff = 0; +int zbufmem = 0, zbufysiz = 0, zbufbpl = 0, *zbufoff = 0; #endif #ifdef USE_OPENGL -long glredbluemode = 0; -static long lastglredbluemode = 0, redblueclearcnt = 0; +int glredbluemode = 0; +static int lastglredbluemode = 0, redblueclearcnt = 0; -static struct glfiltermodes { +static struct glfiltermodes +{ char *name; - long min,mag; -} glfiltermodes[] = { - {"GL_NEAREST",GL_NEAREST,GL_NEAREST}, - {"GL_LINEAR",GL_LINEAR,GL_LINEAR}, - {"GL_NEAREST_MIPMAP_NEAREST",GL_NEAREST_MIPMAP_NEAREST,GL_NEAREST}, - {"GL_LINEAR_MIPMAP_NEAREST",GL_LINEAR_MIPMAP_NEAREST,GL_LINEAR}, - {"GL_NEAREST_MIPMAP_LINEAR",GL_NEAREST_MIPMAP_LINEAR,GL_NEAREST}, - {"GL_LINEAR_MIPMAP_LINEAR",GL_LINEAR_MIPMAP_LINEAR,GL_LINEAR} - }; + int min,mag; +} glfiltermodes[] = +{ + {"GL_NEAREST",GL_NEAREST,GL_NEAREST}, + {"GL_LINEAR",GL_LINEAR,GL_LINEAR}, + {"GL_NEAREST_MIPMAP_NEAREST",GL_NEAREST_MIPMAP_NEAREST,GL_NEAREST}, + {"GL_LINEAR_MIPMAP_NEAREST",GL_LINEAR_MIPMAP_NEAREST,GL_LINEAR}, + {"GL_NEAREST_MIPMAP_LINEAR",GL_NEAREST_MIPMAP_LINEAR,GL_NEAREST}, + {"GL_LINEAR_MIPMAP_LINEAR",GL_LINEAR_MIPMAP_LINEAR,GL_LINEAR} +}; #define numglfiltermodes (sizeof(glfiltermodes)/sizeof(glfiltermodes[0])) -long glanisotropy = 1; // 0 = maximum supported by card -long glusetexcompr = 1; -long gltexfiltermode = 2; // GL_NEAREST_MIPMAP_NEAREST -long glusetexcache = 0; -long glusetexcachecompression = 1; -long glmultisample = 0, glnvmultisamplehint = 0; -long gltexmaxsize = 0; // 0 means autodetection on first run -long gltexmiplevel = 0; // discards this many mipmap levels -static long lastglpolygonmode = 0; //FUK -long glpolygonmode = 0; // 0:GL_FILL,1:GL_LINE,2:GL_POINT //FUK -long glwidescreen = 0; -long glprojectionhacks = 1; +int glanisotropy = 1; // 0 = maximum supported by card +int glusetexcompr = 1; +int gltexfiltermode = 2; // GL_NEAREST_MIPMAP_NEAREST +int glusetexcache = 0; +int glusetexcachecompression = 1; +int glmultisample = 0, glnvmultisamplehint = 0; +int gltexmaxsize = 0; // 0 means autodetection on first run +int gltexmiplevel = 0; // discards this many mipmap levels +static int lastglpolygonmode = 0; //FUK +int glpolygonmode = 0; // 0:GL_FILL,1:GL_LINE,2:GL_POINT //FUK +int glwidescreen = 0; +int glprojectionhacks = 1; static GLuint polymosttext = 0; extern char nofog; // Those THREE globals control the drawing of fullbright tiles -static long fullbrightloadingpass = 0; -static long fullbrightdrawingpass = 0; -static long shadeforfullbrightpass; +static int fullbrightloadingpass = 0; +static int fullbrightdrawingpass = 0; +static int shadeforfullbrightpass; // Depth peeling control -long r_depthpeeling = 0; // cvar toggling general depth peeling usage -long r_peelscount = 5; // cvar controlling the number of peeling layers -long r_curpeel = -1; // cvar controlling the display of independant peeling layers +int r_depthpeeling = 0; // cvar toggling general depth peeling usage +int r_peelscount = 5; // cvar controlling the number of peeling layers +int r_curpeel = -1; // cvar controlling the display of independant peeling layers static float curpolygonoffset; // internal polygon offset stack for drawing flat sprites to avoid depth fighting -static long peelcompiling = 0; // internal control var to disable blending when compiling the peeling display list -static long newpeelscount = 0; // temporary var for peels count changing during the game +static int peelcompiling = 0; // internal control var to disable blending when compiling the peeling display list +static int newpeelscount = 0; // temporary var for peels count changing during the game // Depth peeling data static GLuint ztexture[3]; // secondary Z-buffers identifier @@ -150,31 +152,31 @@ static GLuint *peelfbos; // peels FBOs identifiers static GLuint peelprogram[2]; // ARBfp peeling fragment program // Detail mapping cvar -long r_detailmapping = 1; +int r_detailmapping = 1; // Glow mapping cvar -long r_glowmapping = 1; +int r_glowmapping = 1; // Vertex Array model drawing cvar -long r_vertexarrays = 1; +int r_vertexarrays = 1; // Vertex Buffer Objects model drawing cvars -long r_vbos = 0; -long r_vbocount = 64; +int r_vbos = 0; +int r_vbocount = 64; // model animation smoothing cvar -long r_animsmoothing = 1; +int r_animsmoothing = 1; static float fogresult, ofogresult, fogcol[4]; -static void fogcalc (signed char shade, char vis, char pal) +static void fogcalc(signed char shade, char vis, char pal) { if (vis < 240) fogresult = (float)gvisibility*(vis+16+(shade<0?(-(shade)*(shade))/8.f:((shade)*(shade))/8.f)); else fogresult = (float)gvisibility*((vis-240+(shade<0?(-(shade)*(shade))/8.f:((shade)*(shade))/8.f))/(klabs(vis-256))); if (fogresult < 0.010) fogresult = 0.010; else if (fogresult > 10.000) fogresult = 10.000; - + fogcol[0] = (float)palookupfog[pal].r / 63.f; fogcol[1] = (float)palookupfog[pal].g / 63.f; fogcol[2] = (float)palookupfog[pal].b / 63.f; @@ -183,7 +185,7 @@ static void fogcalc (signed char shade, char vis, char pal) #endif #if defined(USE_MSC_PRAGMAS) -static inline void ftol (float f, long *a) +static inline void ftol(float f, int *a) { _asm { @@ -193,7 +195,7 @@ static inline void ftol (float f, long *a) } } -static inline void dtol (double d, long *a) +static inline void dtol(double d, int *a) { _asm { @@ -213,89 +215,89 @@ static inline void dtol (double d, long *a) #elif defined(USE_GCC_PRAGMAS) -static inline void ftol (float f, long *a) +static inline void ftol(float f, int *a) { - __asm__ __volatile__ ( + __asm__ __volatile__( #if 0 //(__GNUC__ >= 3) "flds %1; fistpl %0;" #else "flds %1; fistpl (%0);" #endif - : "=r" (a) : "m" (f) : "memory","cc"); + : "=r"(a) : "m"(f) : "memory","cc"); } -static inline void dtol (double d, long *a) +static inline void dtol(double d, int *a) { - __asm__ __volatile__ ( + __asm__ __volatile__( #if 0 //(__GNUC__ >= 3) "fldl %1; fistpl %0;" #else "fldl %1; fistpl (%0);" #endif - : "=r" (a) : "m" (d) : "memory","cc"); + : "=r"(a) : "m"(d) : "memory","cc"); } #else -static inline void ftol (float f, long *a) +static inline void ftol(float f, int *a) { - *a = (long)f; + *a = (int)f; } -static inline void dtol (double d, long *a) +static inline void dtol(double d, int *a) { - *a = (long)d; + *a = (int)d; } #endif -static inline long imod (long a, long b) +static inline int imod(int a, int b) { if (a >= 0) return(a%b); return(((a+1)%b)+b-1); } -void drawline2d (float x0, float y0, float x1, float y1, char col) +void drawline2d(float x0, float y0, float x1, float y1, char col) { float f, dx, dy, fxres, fyres; - long e, inc, x, y; - unsigned long up16; + int e, inc, x, y; + unsigned int up16; dx = x1-x0; dy = y1-y0; if ((dx == 0) && (dy == 0)) return; fxres = (float)xdimen; fyres = (float)ydimen; -if (x0 >= fxres) { if (x1 >= fxres) return; y0 += (fxres-x0)*dy/dx; x0 = fxres; } -else if (x0 < 0) { if (x1 < 0) return; y0 += ( 0-x0)*dy/dx; x0 = 0; } -if (x1 >= fxres) { y1 += (fxres-x1)*dy/dx; x1 = fxres; } - else if (x1 < 0) { y1 += ( 0-x1)*dy/dx; x1 = 0; } + if (x0 >= fxres) { if (x1 >= fxres) return; y0 += (fxres-x0)*dy/dx; x0 = fxres; } + else if (x0 < 0) { if (x1 < 0) return; y0 += (0-x0)*dy/dx; x0 = 0; } + if (x1 >= fxres) { y1 += (fxres-x1)*dy/dx; x1 = fxres; } + else if (x1 < 0) { y1 += (0-x1)*dy/dx; x1 = 0; } if (y0 >= fyres) { if (y1 >= fyres) return; x0 += (fyres-y0)*dx/dy; y0 = fyres; } -else if (y0 < 0) { if (y1 < 0) return; x0 += ( 0-y0)*dx/dy; y0 = 0; } -if (y1 >= fyres) { x1 += (fyres-y1)*dx/dy; y1 = fyres; } - else if (y1 < 0) { x1 += ( 0-y1)*dx/dy; y1 = 0; } + else if (y0 < 0) { if (y1 < 0) return; x0 += (0-y0)*dx/dy; y0 = 0; } + if (y1 >= fyres) { x1 += (fyres-y1)*dx/dy; y1 = fyres; } + else if (y1 < 0) { x1 += (0-y1)*dx/dy; y1 = 0; } if (fabs(dx) > fabs(dy)) { if (x0 > x1) { f = x0; x0 = x1; x1 = f; f = y0; y0 = y1; y1 = f; } - y = (long)(y0*65536.f)+32768; - inc = (long)(dy/dx*65536.f+.5f); - x = (long)(x0+.5); if (x < 0) { y -= inc*x; x = 0; } //if for safety - e = (long)(x1+.5); if (e > xdimen) e = xdimen; //if for safety + y = (int)(y0*65536.f)+32768; + inc = (int)(dy/dx*65536.f+.5f); + x = (int)(x0+.5); if (x < 0) { y -= inc*x; x = 0; } //if for safety + e = (int)(x1+.5); if (e > xdimen) e = xdimen; //if for safety up16 = (ydimen<<16); - for (;x>16]+x+frameoffset) = col; + for (;x>16]+x+frameoffset) = col; } else { if (y0 > y1) { f = x0; x0 = x1; x1 = f; f = y0; y0 = y1; y1 = f; } - x = (long)(x0*65536.f)+32768; - inc = (long)(dx/dy*65536.f+.5f); - y = (long)(y0+.5); if (y < 0) { x -= inc*y; y = 0; } //if for safety - e = (long)(y1+.5); if (e > ydimen) e = ydimen; //if for safety + x = (int)(x0*65536.f)+32768; + inc = (int)(dx/dy*65536.f+.5f); + y = (int)(y0+.5); if (y < 0) { x -= inc*y; y = 0; } //if for safety + e = (int)(y1+.5); if (e > ydimen) e = ydimen; //if for safety up16 = (xdimen<<16); - for (;y>16)+frameoffset) = col; + for (;y>16)+frameoffset) = col; } } #ifdef USE_OPENGL typedef struct { unsigned char r, g, b, a; } coltype; -static void uploadtexture(long doalloc, long xsiz, long ysiz, long intexfmt, long texfmt, coltype *pic, long tsizx, long tsizy, long dameth); +static void uploadtexture(int doalloc, int xsiz, int ysiz, int intexfmt, int texfmt, coltype *pic, int tsizx, int tsizy, int dameth); #include "md4.h" @@ -309,25 +311,27 @@ static void uploadtexture(long doalloc, long xsiz, long ysiz, long intexfmt, lon #endif static char TEXCACHEDIR[] = "texcache"; -typedef struct { +typedef struct +{ char magic[8]; // 'Polymost' - long xdim, ydim; // of image, unpadded - long flags; // 1 = !2^x, 2 = has alpha, 4 = lzw compressed + int xdim, ydim; // of image, unpadded + int flags; // 1 = !2^x, 2 = has alpha, 4 = lzw compressed } texcacheheader; -typedef struct { - long size; - long format; - long xdim, ydim; // of mipmap (possibly padded) - long border, depth; +typedef struct +{ + int size; + int format; + int xdim, ydim; // of mipmap (possibly padded) + int border, depth; } texcachepicture; -int dxtfilter(int fil, texcachepicture *pict, char *pic, void *midbuf, char *packbuf, unsigned long miplen); +int dxtfilter(int fil, texcachepicture *pict, char *pic, void *midbuf, char *packbuf, unsigned int miplen); int dedxtfilter(int fil, texcachepicture *pict, char *pic, void *midbuf, char *packbuf, int ispacked); static inline void phex(unsigned char v, char *s); -void writexcache(char *fn, long len, long dameth, char effect, texcacheheader *head); +void writexcache(char *fn, int len, int dameth, char effect, texcacheheader *head); -static long mdtims, omdtims; +static int mdtims, omdtims; float alphahackarray[MAXTILES]; #include "mdsprite.c" @@ -358,14 +362,14 @@ float alphahackarray[MAXTILES]; #define GLTEXCACHEADSIZ 8192 static pthtyp *gltexcachead[GLTEXCACHEADSIZ]; -static long drawingskybox = 0; +static int drawingskybox = 0; -int gloadtile_art(long,long,long,pthtyp*,long); -int gloadtile_hi(long,long,hicreplctyp*,long,pthtyp*,long,char); +int gloadtile_art(int,int,int,pthtyp*,int); +int gloadtile_hi(int,int,hicreplctyp*,int,pthtyp*,int,char); static int hicprecaching = 0; -pthtyp * gltexcache (long dapicnum, long dapalnum, long dameth) +pthtyp * gltexcache(int dapicnum, int dapalnum, int dameth) { - long i, j; + int i, j; hicreplctyp *si; pthtyp *pth, *pth2; @@ -373,7 +377,8 @@ pthtyp * gltexcache (long dapicnum, long dapalnum, long dameth) if (usehightile) si = hicfindsubst(dapicnum,dapalnum,drawingskybox); else si = NULL; - if (!si) { + if (!si) + { if (drawingskybox) return NULL; goto tryart; } @@ -385,7 +390,8 @@ pthtyp * gltexcache (long dapicnum, long dapalnum, long dameth) */ // load a replacement - for (pth=gltexcachead[j]; pth; pth=pth->next) { + for (pth=gltexcachead[j]; pth; pth=pth->next) + { if (pth->picnum == dapicnum && pth->palnum == si->palnum && (si->palnum>0 ? 1 : (pth->effects == hictinting[dapalnum].f)) && @@ -397,7 +403,8 @@ pthtyp * gltexcache (long dapicnum, long dapalnum, long dameth) { pth->flags &= ~128; if (gloadtile_hi(dapicnum,drawingskybox,si,dameth,pth,0, - (si->palnum>0) ? 0 : hictinting[dapalnum].f)) { // reload tile + (si->palnum>0) ? 0 : hictinting[dapalnum].f)) // reload tile + { if (drawingskybox) return NULL; goto tryart; // failed, so try for ART } @@ -413,7 +420,8 @@ pthtyp * gltexcache (long dapicnum, long dapalnum, long dameth) // possibly fetch an already loaded multitexture :_) if (dapalnum >= (MAXPALOOKUPS - RESERVEDPALS)) for (i = (GLTEXCACHEADSIZ - 1); i >= 0; i--) - for (pth2=gltexcachead[i]; pth2; pth2=pth2->next) { + for (pth2=gltexcachead[i]; pth2; pth2=pth2->next) + { if ((pth2->hicr) && (pth2->hicr->filename) && (Bstrcasecmp(pth2->hicr->filename, si->filename) == 0)) { memcpy(pth, pth2, sizeof(pthtyp)); @@ -427,7 +435,8 @@ pthtyp * gltexcache (long dapicnum, long dapalnum, long dameth) } } - if (gloadtile_hi(dapicnum,drawingskybox,si,dameth,pth,1, (si->palnum>0) ? 0 : hictinting[dapalnum].f)) { + if (gloadtile_hi(dapicnum,drawingskybox,si,dameth,pth,1, (si->palnum>0) ? 0 : hictinting[dapalnum].f)) + { free(pth); if (drawingskybox) return NULL; goto tryart; // failed, so try for ART @@ -458,7 +467,8 @@ tryart: pth = (pthtyp *)calloc(1,sizeof(pthtyp)); if (!pth) return NULL; - if (gloadtile_art(dapicnum,dapalnum,dameth,pth,1)) { + if (gloadtile_art(dapicnum,dapalnum,dameth,pth,1)) + { free(pth); return NULL; } @@ -468,9 +478,9 @@ tryart: return(pth); } -long gltexmayhavealpha (long dapicnum, long dapalnum) +int gltexmayhavealpha(int dapicnum, int dapalnum) { - long j = (dapicnum&(GLTEXCACHEADSIZ-1)); + int j = (dapicnum&(GLTEXCACHEADSIZ-1)); pthtyp *pth; for (pth=gltexcachead[j]; pth; pth=pth->next) @@ -479,14 +489,14 @@ long gltexmayhavealpha (long dapicnum, long dapalnum) return(1); } -void gltexinvalidate (long dapicnum, long dapalnum, long dameth) +void gltexinvalidate(int dapicnum, int dapalnum, int dameth) { - long i, j; + int i, j; pthtyp *pth; j = (dapicnum&(GLTEXCACHEADSIZ-1)); for (pth=gltexcachead[j]; pth; pth=pth->next) - if (pth->picnum == dapicnum && pth->palnum == dapalnum && (pth->flags & 1) == ((dameth&4)>>2) ) + if (pth->picnum == dapicnum && pth->palnum == dapalnum && (pth->flags & 1) == ((dameth&4)>>2)) { pth->flags |= 128; if (pth->flags & 16) @@ -497,9 +507,9 @@ void gltexinvalidate (long dapicnum, long dapalnum, long dameth) //Make all textures "dirty" so they reload, but not re-allocate //This should be much faster than polymost_glreset() //Use this for palette effects ... but not ones that change every frame! -void gltexinvalidateall () +void gltexinvalidateall() { - long j; + int j; pthtyp *pth; for (j=GLTEXCACHEADSIZ-1;j>=0;j--) @@ -515,9 +525,9 @@ void gltexinvalidateall () #endif } -void gltexinvalidate8 () +void gltexinvalidate8() { - long j; + int j; pthtyp *pth; for (j=GLTEXCACHEADSIZ-1;j>=0;j--) @@ -535,20 +545,22 @@ void gltexinvalidate8 () #endif } -void gltexapplyprops (void) +void gltexapplyprops(void) { - long i; + int i; pthtyp *pth; if (glinfo.maxanisotropy > 1.0) { - if (glanisotropy <= 0 || glanisotropy > glinfo.maxanisotropy) glanisotropy = (long)glinfo.maxanisotropy; + if (glanisotropy <= 0 || glanisotropy > glinfo.maxanisotropy) glanisotropy = (int)glinfo.maxanisotropy; } if (gltexfiltermode < 0) gltexfiltermode = 0; - else if (gltexfiltermode >= (long)numglfiltermodes) gltexfiltermode = numglfiltermodes-1; - for (i=GLTEXCACHEADSIZ-1;i>=0;i--) { - for (pth=gltexcachead[i];pth;pth=pth->next) { + else if (gltexfiltermode >= (int)numglfiltermodes) gltexfiltermode = numglfiltermodes-1; + for (i=GLTEXCACHEADSIZ-1;i>=0;i--) + { + for (pth=gltexcachead[i];pth;pth=pth->next) + { bglBindTexture(GL_TEXTURE_2D,pth->glpic); bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,glfiltermodes[gltexfiltermode].mag); bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,glfiltermodes[gltexfiltermode].min); @@ -604,9 +616,9 @@ static float glox1, gloy1, glox2, gloy2; //Use this for both initialization and uninitialization of OpenGL. static int gltexcacnum = -1; -void polymost_glreset () +void polymost_glreset() { - long i; + int i; pthtyp *pth, *next; //Reset if this is -1 (meaning 1st texture call ever), or > 0 (textures in memory) if (gltexcacnum < 0) @@ -619,8 +631,10 @@ void polymost_glreset () } else { - for (i=GLTEXCACHEADSIZ-1; i>=0; i--) { - for (pth=gltexcachead[i]; pth;) { + for (i=GLTEXCACHEADSIZ-1; i>=0; i--) + { + for (pth=gltexcachead[i]; pth;) + { next = pth->next; if (pth->flags & 16) // fullbright textures { @@ -661,33 +675,33 @@ void polymost_glinit() { GLfloat col[4]; int i; - char notpeeledprogramstring[] = - "!!ARBfp1.0\n" - "OPTION ARB_fog_exp2;\n" - "OPTION ARB_fragment_program_shadow;\n" - "TEMP texsample;\n" - "TEMP depthresult;\n" - "TEX depthresult, fragment.position, texture[1], SHADOWRECT;\n" - "ADD depthresult.a, depthresult.a, -0.5;\n" - "KIL depthresult.a;\n" - "TEX texsample, fragment.texcoord[0], texture[0], 2D;\n" - "MUL result.color, fragment.color, texsample;\n" - "END\n"; - char peeledprogramstring[] = - "!!ARBfp1.0\n" - "OPTION ARB_fog_exp2;\n" - "OPTION ARB_fragment_program_shadow;\n" - "TEMP texsample;\n" - "TEMP depthresult;\n" - "TEX depthresult, fragment.position, texture[2], SHADOWRECT;\n" - "ADD depthresult.a, depthresult.a, -0.5;\n" - "KIL depthresult.a;\n" - "TEX depthresult, fragment.position, texture[1], SHADOWRECT;\n" - "ADD depthresult.a, depthresult.a, -0.5;\n" - "KIL depthresult.a;\n" - "TEX texsample, fragment.texcoord[0], texture[0], 2D;\n" - "MUL result.color, fragment.color, texsample;\n" - "END\n"; + char notpeeledprogramstring[] = + "!!ARBfp1.0\n" + "OPTION ARB_fog_exp2;\n" + "OPTION ARB_fragment_program_shadow;\n" + "TEMP texsample;\n" + "TEMP depthresult;\n" + "TEX depthresult, fragment.position, texture[1], SHADOWRECT;\n" + "ADD depthresult.a, depthresult.a, -0.5;\n" + "KIL depthresult.a;\n" + "TEX texsample, fragment.texcoord[0], texture[0], 2D;\n" + "MUL result.color, fragment.color, texsample;\n" + "END\n"; + char peeledprogramstring[] = + "!!ARBfp1.0\n" + "OPTION ARB_fog_exp2;\n" + "OPTION ARB_fragment_program_shadow;\n" + "TEMP texsample;\n" + "TEMP depthresult;\n" + "TEX depthresult, fragment.position, texture[2], SHADOWRECT;\n" + "ADD depthresult.a, depthresult.a, -0.5;\n" + "KIL depthresult.a;\n" + "TEX depthresult, fragment.position, texture[1], SHADOWRECT;\n" + "ADD depthresult.a, depthresult.a, -0.5;\n" + "KIL depthresult.a;\n" + "TEX texsample, fragment.texcoord[0], texture[0], 2D;\n" + "MUL result.color, fragment.color, texsample;\n" + "END\n"; #if 1 if (!Bstrcmp(glinfo.vendor, "ATI Technologies Inc.")) @@ -702,11 +716,11 @@ void polymost_glinit() #else bglHint(GL_FOG_HINT,GL_DONT_CARE); #endif - + bglFogi(GL_FOG_MODE,GL_EXP2); bglFogf(GL_FOG_DENSITY,1.0); //must be > 0, default is 1 -/* bglFogf(GL_FOG_START,0.0); //default is 0 - bglFogf(GL_FOG_END,1.0); //default is 1 */ + /* bglFogf(GL_FOG_START,0.0); //default is 0 + bglFogf(GL_FOG_END,1.0); //default is 1 */ col[0] = 0; col[1] = 0; col[2] = 0; col[3] = 0; //range:0 to 1 bglFogfv(GL_FOG_COLOR,col); //default is 0,0,0,0 @@ -715,7 +729,8 @@ void polymost_glinit() //bglHint(GL_LINE_SMOOTH_HINT, GL_NICEST); //bglEnable(GL_LINE_SMOOTH); - if (glmultisample > 0 && glinfo.multisample) { + if (glmultisample > 0 && glinfo.multisample) + { if (glinfo.nvmultisamplehint) bglHint(GL_MULTISAMPLE_FILTER_HINT_NV, glnvmultisamplehint ? GL_NICEST:GL_FASTEST); bglEnable(GL_MULTISAMPLE_ARB); @@ -821,15 +836,18 @@ void polymost_glinit() bglEnableClientState(GL_TEXTURE_COORD_ARRAY); } -void resizeglcheck () +void resizeglcheck() { float m[4][4]; int fovcorrect; - if (glredbluemode < lastglredbluemode) { + if (glredbluemode < lastglredbluemode) + { glox1 = -1; bglColorMask(1,1,1,1); - } else if (glredbluemode != lastglredbluemode) { + } + else if (glredbluemode != lastglredbluemode) + { redblueclearcnt = 0; } lastglredbluemode = glredbluemode; @@ -883,10 +901,10 @@ void resizeglcheck () } } -void fixtransparency (coltype *dapic, long daxsiz, long daysiz, long daxsiz2, long daysiz2, long dameth) +void fixtransparency(coltype *dapic, int daxsiz, int daysiz, int daxsiz2, int daysiz2, int dameth) { coltype *wpptr; - long j, x, y, r, g, b, dox, doy, naxsiz2; + int j, x, y, r, g, b, dox, doy, naxsiz2; dox = daxsiz2-1; doy = daysiz2-1; if (dameth&4) { dox = min(dox,daxsiz); doy = min(doy,daysiz); } @@ -903,10 +921,10 @@ void fixtransparency (coltype *dapic, long daxsiz, long daysiz, long daxsiz2, lo { if (wpptr->a) continue; r = g = b = j = 0; - if ((x> 0) && (wpptr[ -1].a)) { r += (long)wpptr[ -1].r; g += (long)wpptr[ -1].g; b += (long)wpptr[ -1].b; j++; } - if ((x 0) && (wpptr[naxsiz2].a)) { r += (long)wpptr[naxsiz2].r; g += (long)wpptr[naxsiz2].g; b += (long)wpptr[naxsiz2].b; j++; } - if ((y 0) && (wpptr[ -1].a)) { r += (int)wpptr[ -1].r; g += (int)wpptr[ -1].g; b += (int)wpptr[ -1].b; j++; } + if ((x 0) && (wpptr[naxsiz2].a)) { r += (int)wpptr[naxsiz2].r; g += (int)wpptr[naxsiz2].g; b += (int)wpptr[naxsiz2].b; j++; } + if ((y1; i>>=1) gltexmaxsize++; } @@ -955,7 +975,8 @@ static void uploadtexture(long doalloc, long xsiz, long ysiz, long intexfmt, lon intexfmt==GL_COMPRESSED_RGB_ARB?"GL_COMPRESSED_RGB_ARB":"other")); */ - if (js == 0) { + if (js == 0) + { if (doalloc&1) bglTexImage2D(GL_TEXTURE_2D,0,intexfmt,xsiz,ysiz,0,texfmt,GL_UNSIGNED_BYTE,pic); //loading 1st time else @@ -976,12 +997,12 @@ static void uploadtexture(long doalloc, long xsiz, long ysiz, long intexfmt, lon for (x=0;x= 0) fixtransparency(pic,(tsizx+(1<>j,(tsizy+(1<>j,x3,y3,dameth); - if (j >= js) { + if (j >= js) + { if (doalloc&1) bglTexImage2D(GL_TEXTURE_2D,j-js,intexfmt,x3,y3,0,texfmt,GL_UNSIGNED_BYTE,pic); //loading 1st time else @@ -1012,21 +1034,27 @@ static void uploadtexture(long doalloc, long xsiz, long ysiz, long intexfmt, lon #endif } -int gloadtile_art (long dapic, long dapal, long dameth, pthtyp *pth, long doalloc) +int gloadtile_art(int dapic, int dapal, int dameth, pthtyp *pth, int doalloc) { coltype *pic, *wpptr; - long j, x, y, x2, y2, xsiz, ysiz, dacol, tsizx, tsizy; + int j, x, y, x2, y2, xsiz, ysiz, dacol, tsizx, tsizy; char hasalpha = 0, hasfullbright = 0; tsizx = tilesizx[dapic]; tsizy = tilesizy[dapic]; - if (!glinfo.texnpot) { + if (!glinfo.texnpot) + { for (xsiz=1;xsiz= tsizx) || (y >= tsizy))) //Clamp texture - { wpptr->r = wpptr->g = wpptr->b = wpptr->a = 0; continue; } + { wpptr->r = wpptr->g = wpptr->b = wpptr->a = 0; continue; } if (x < tsizx) x2 = x; else x2 = x-tsizx; - dacol = (long)(*(unsigned char *)(waloff[dapic]+x2*tsizy+y2)); + dacol = (int)(*(unsigned char *)(waloff[dapic]+x2*tsizy+y2)); if (!fullbrightloadingpass) - { // regular texture + { + // regular texture if ((dacol > 239) && (dacol != 255)) hasfullbright = 1; wpptr->a = 255; } else if (fullbrightloadingpass == 1) - { // texture with only fullbright areas - if (dacol < 240) { // regular colors + { + // texture with only fullbright areas + if (dacol < 240) // regular colors + { wpptr->a = 0; hasalpha = 1; - } else { // fullbright + } + else // fullbright + { wpptr->a = 255; } } if (dacol != 255) - dacol = (long)((unsigned char)palookup[dapal][dacol]); - else { + dacol = (int)((unsigned char)palookup[dapal][dacol]); + else + { wpptr->a = 0; hasalpha = 1; } - if (gammabrightness) { + if (gammabrightness) + { wpptr->r = curpalette[dacol].r; wpptr->g = curpalette[dacol].g; wpptr->b = curpalette[dacol].b; - } else { + } + else + { wpptr->r = britable[curbrightness][ curpalette[dacol].r ]; wpptr->g = britable[curbrightness][ curpalette[dacol].g ]; wpptr->b = britable[curbrightness][ curpalette[dacol].b ]; @@ -1093,13 +1130,13 @@ int gloadtile_art (long dapic, long dapal, long dameth, pthtyp *pth, long doallo uploadtexture(doalloc,xsiz,ysiz,hasalpha?GL_RGBA:GL_RGB,GL_RGBA,pic,tsizx,tsizy,dameth); if (gltexfiltermode < 0) gltexfiltermode = 0; - else if (gltexfiltermode >= (long)numglfiltermodes) gltexfiltermode = numglfiltermodes-1; + else if (gltexfiltermode >= (int)numglfiltermodes) gltexfiltermode = numglfiltermodes-1; bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,glfiltermodes[gltexfiltermode].mag); bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,glfiltermodes[gltexfiltermode].min); if (glinfo.maxanisotropy > 1.0) { - if (glanisotropy <= 0 || glanisotropy > glinfo.maxanisotropy) glanisotropy = (long)glinfo.maxanisotropy; + if (glanisotropy <= 0 || glanisotropy > glinfo.maxanisotropy) glanisotropy = (int)glinfo.maxanisotropy; bglTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAX_ANISOTROPY_EXT,glanisotropy); } @@ -1109,7 +1146,8 @@ int gloadtile_art (long dapic, long dapal, long dameth, pthtyp *pth, long doallo bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT); } else - { //For sprite textures, clamping looks better than wrapping + { + //For sprite textures, clamping looks better than wrapping bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP); bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP); } @@ -1145,14 +1183,15 @@ static inline void phex(unsigned char v, char *s) s[1] = x<10 ? (x+'0') : (x-10+'a'); } -long trytexcache(char *fn, long len, long dameth, char effect, texcacheheader *head) +int trytexcache(char *fn, int len, int dameth, char effect, texcacheheader *head) { - long fil, fp; + int fil, fp; char cachefn[BMAX_PATH], *cp; unsigned char mdsum[16]; if (!glinfo.texcompr || !glusetexcompr || !glusetexcache) return -1; - if (!bglCompressedTexImage2DARB || !bglGetCompressedTexImageARB) { + if (!bglCompressedTexImage2DARB || !bglGetCompressedTexImageARB) + { // lacking the necessary extensions to do this initprintf("Warning: the GL driver lacks necessary functions to use caching\n"); glusetexcache = 0; @@ -1163,7 +1202,7 @@ long trytexcache(char *fn, long len, long dameth, char effect, texcacheheader *h for (cp = cachefn, fp = 0; (*cp = TEXCACHEDIR[fp]); cp++,fp++); *(cp++) = '/'; for (fp = 0; fp < 16; phex(mdsum[fp++], cp), cp+=2); - sprintf(cp, "-%lx-%lx%x", len, dameth, effect); + sprintf(cp, "-%x-%x%x", len, dameth, effect); fil = kopen4load(cachefn, 0); if (fil < 0) return -1; @@ -1185,21 +1224,22 @@ failure: return -1; } -void writexcache(char *fn, long len, long dameth, char effect, texcacheheader *head) +void writexcache(char *fn, int len, int dameth, char effect, texcacheheader *head) { - long fil=-1, fp; + int fil=-1, fp; char cachefn[BMAX_PATH], *cp; unsigned char mdsum[16]; texcachepicture pict; char *pic = NULL, *packbuf = NULL; void *midbuf = NULL; - unsigned long alloclen=0, level, miplen; - unsigned long padx=0, pady=0; + unsigned int alloclen=0, level, miplen; + unsigned int padx=0, pady=0; GLuint gi; - long j, k; + int j, k; if (!glinfo.texcompr || !glusetexcompr || !glusetexcache) return; - if (!bglCompressedTexImage2DARB || !bglGetCompressedTexImageARB) { + if (!bglCompressedTexImage2DARB || !bglGetCompressedTexImageARB) + { // lacking the necessary extensions to do this initprintf("Warning: the GL driver lacks necessary functions to use caching\n"); glusetexcache = 0; @@ -1208,20 +1248,28 @@ void writexcache(char *fn, long len, long dameth, char effect, texcacheheader *h { struct stat st; - if (stat(TEXCACHEDIR, &st) < 0) { - if (errno == ENOENT) { // path doesn't exist + if (stat(TEXCACHEDIR, &st) < 0) + { + if (errno == ENOENT) // path doesn't exist + { // try to create the cache directory - if (Bmkdir(TEXCACHEDIR, S_IRWXU) < 0) { + if (Bmkdir(TEXCACHEDIR, S_IRWXU) < 0) + { initprintf("Failed to create texture cache directory %s\n", TEXCACHEDIR); glusetexcache = 0; return; - } else initprintf("Created texture cache directory %s\n", TEXCACHEDIR); - } else { + } + else initprintf("Created texture cache directory %s\n", TEXCACHEDIR); + } + else + { // another type of failure glusetexcache = 0; return; } - } else if ((st.st_mode & S_IFDIR) != S_IFDIR) { + } + else if ((st.st_mode & S_IFDIR) != S_IFDIR) + { // cache directory isn't a directory glusetexcache = 0; return; @@ -1236,7 +1284,7 @@ void writexcache(char *fn, long len, long dameth, char effect, texcacheheader *h for (cp = cachefn, fp = 0; (*cp = TEXCACHEDIR[fp]); cp++,fp++); *(cp++) = '/'; for (fp = 0; fp < 16; phex(mdsum[fp++], cp), cp+=2); - sprintf(cp, "-%lx-%lx%x", len, dameth, effect); + sprintf(cp, "-%x-%x%x", len, dameth, effect); initprintf("Writing cached tex: %s\n", cachefn); @@ -1254,7 +1302,8 @@ void writexcache(char *fn, long len, long dameth, char effect, texcacheheader *h if (Bwrite(fil, head, sizeof(texcacheheader)) != sizeof(texcacheheader)) goto failure; bglGetError(); - for (level = 0; level==0 || (padx > 1 || pady > 1); level++) { + for (level = 0; level==0 || (padx > 1 || pady > 1); level++) + { bglGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_COMPRESSED_ARB, (GLint *)&gi); if (bglGetError() != GL_NO_ERROR) goto failure; if (gi != GL_TRUE) goto failure; // an uncompressed mipmap @@ -1275,9 +1324,10 @@ void writexcache(char *fn, long len, long dameth, char effect, texcacheheader *h pict.depth = B_LITTLE32(gi); bglGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB, (GLint *)&gi); if (bglGetError() != GL_NO_ERROR) goto failure; - miplen = (long)gi; pict.size = B_LITTLE32(gi); + miplen = (int)gi; pict.size = B_LITTLE32(gi); - if (alloclen < miplen) { + if (alloclen < miplen) + { void *picc = realloc(pic, miplen); if (!picc) goto failure; else pic = picc; alloclen = miplen; @@ -1303,15 +1353,16 @@ failure: if (packbuf) free(packbuf); } -int gloadtile_cached(long fil, texcacheheader *head, long *doalloc, pthtyp *pth) +int gloadtile_cached(int fil, texcacheheader *head, int *doalloc, pthtyp *pth) { int level, r; texcachepicture pict; char *pic = NULL, *packbuf = NULL; void *midbuf = NULL; - long alloclen=0; + int alloclen=0; - if (*doalloc&1) { + if (*doalloc&1) + { bglGenTextures(1,(GLuint*)&pth->glpic); //# of textures (make OpenGL allocate structure) *doalloc |= 2; // prevents bglGenTextures being called again if we fail in here } @@ -1323,7 +1374,8 @@ int gloadtile_cached(long fil, texcacheheader *head, long *doalloc, pthtyp *pth) bglGetError(); // load the mipmaps - for (level = 0; level==0 || (pict.xdim > 1 || pict.ydim > 1); level++) { + for (level = 0; level==0 || (pict.xdim > 1 || pict.ydim > 1); level++) + { r = kread(fil, &pict, sizeof(texcachepicture)); if (r < (int)sizeof(texcachepicture)) goto failure; @@ -1334,7 +1386,8 @@ int gloadtile_cached(long fil, texcacheheader *head, long *doalloc, pthtyp *pth) pict.border = B_LITTLE32(pict.border); pict.depth = B_LITTLE32(pict.depth); - if (alloclen < pict.size) { + if (alloclen < pict.size) + { void *picc = realloc(pic, pict.size); if (!picc) goto failure; else pic = picc; alloclen = pict.size; @@ -1365,29 +1418,33 @@ failure: } // --------------------------------------------------- JONOF'S COMPRESSED TEXTURE CACHE STUFF -int gloadtile_hi(long dapic, long facen, hicreplctyp *hicr, long dameth, pthtyp *pth, long doalloc, char effect) +int gloadtile_hi(int dapic, int facen, hicreplctyp *hicr, int dameth, pthtyp *pth, int doalloc, char effect) { coltype *pic = NULL, *rpptr; - long j, x, y, x2, y2, xsiz=0, ysiz=0, tsizx, tsizy; + int j, x, y, x2, y2, xsiz=0, ysiz=0, tsizx, tsizy; char *picfil = NULL, *fn, hasalpha = 255; - long picfillen, texfmt = GL_RGBA, intexfmt = GL_RGBA, filh; + int picfillen, texfmt = GL_RGBA, intexfmt = GL_RGBA, filh; - long cachefil = -1; + int cachefil = -1; texcacheheader cachead; if (!hicr) return -1; - if (facen > 0) { + if (facen > 0) + { if (!hicr->skybox) return -1; if (facen > 6) return -1; if (!hicr->skybox->face[facen-1]) return -1; fn = hicr->skybox->face[facen-1]; - } else { + } + else + { if (!hicr->filename) return -1; fn = hicr->filename; } - if ((filh = kopen4load(fn, 0)) < 0) { + if ((filh = kopen4load(fn, 0)) < 0) + { initprintf("hightile: %s (pic %d) not found\n", fn, dapic); if (facen > 0) hicr->skybox->ignore = 1; @@ -1400,20 +1457,23 @@ int gloadtile_hi(long dapic, long facen, hicreplctyp *hicr, long dameth, pthtyp kclose(filh); // FIXME: shouldn't have to do this. bug in cache1d.c cachefil = trytexcache(fn, picfillen, dameth, effect, &cachead); - if (cachefil >= 0 && !gloadtile_cached(cachefil, &cachead, &doalloc, pth)) { + if (cachefil >= 0 && !gloadtile_cached(cachefil, &cachead, &doalloc, pth)) + { tsizx = cachead.xdim; tsizy = cachead.ydim; hasalpha = (cachead.flags & 2) ? 0 : 255; kclose(cachefil); //kclose(filh); // FIXME: uncomment when cache1d.c is fixed // cachefil >= 0, so it won't be rewritten - } else { + } + else + { if (cachefil >= 0) kclose(cachefil); cachefil = -1; // the compressed version will be saved to disk if ((filh = kopen4load(fn, 0)) < 0) return -1; - picfil = (char *)malloc(picfillen); if (!picfil) { kclose(filh); return 1; } + picfil = (char *)malloc(picfillen); if (!picfil) { kclose(filh); return 1; } kread(filh, picfil, picfillen); kclose(filh); @@ -1425,16 +1485,19 @@ int gloadtile_hi(long dapic, long facen, hicreplctyp *hicr, long dameth, pthtyp pth->sizx = tsizx; pth->sizy = tsizy; - if (!glinfo.texnpot) { + if (!glinfo.texnpot) + { for (xsiz=1;xsiz tsizx) //Copy left to right { - long *lptr = (long *)pic; + int *lptr = (int *)pic; for (y=0;y tsizy) //Copy top to bottom memcpy(&pic[xsiz*tsizy],pic,(ysiz-tsizy)*xsiz<<2); } - if (!glinfo.bgra) { - for (j=xsiz*ysiz-1;j>=0;j--) { + if (!glinfo.bgra) + { + for (j=xsiz*ysiz-1;j>=0;j--) + { swapchar(&pic[j].r, &pic[j].b); } - } else texfmt = GL_BGRA; + } + else texfmt = GL_BGRA; free(picfil); picfil = 0; if (glinfo.texcompr && glusetexcompr && !(hicr->flags & 1)) @@ -1496,22 +1564,25 @@ int gloadtile_hi(long dapic, long facen, hicreplctyp *hicr, long dameth, pthtyp } // precalculate scaling parameters for replacement - if (facen > 0) { + if (facen > 0) + { pth->scalex = ((float)tsizx) / 64.0; pth->scaley = ((float)tsizy) / 64.0; - } else { + } + else + { pth->scalex = ((float)tsizx) / ((float)tilesizx[dapic]); pth->scaley = ((float)tsizy) / ((float)tilesizy[dapic]); } if (gltexfiltermode < 0) gltexfiltermode = 0; - else if (gltexfiltermode >= (long)numglfiltermodes) gltexfiltermode = numglfiltermodes-1; + else if (gltexfiltermode >= (int)numglfiltermodes) gltexfiltermode = numglfiltermodes-1; bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,glfiltermodes[gltexfiltermode].mag); bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,glfiltermodes[gltexfiltermode].min); if (glinfo.maxanisotropy > 1.0) { - if (glanisotropy <= 0 || glanisotropy > glinfo.maxanisotropy) glanisotropy = (long)glinfo.maxanisotropy; + if (glanisotropy <= 0 || glanisotropy > glinfo.maxanisotropy) glanisotropy = (int)glinfo.maxanisotropy; bglTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAX_ANISOTROPY_EXT,glanisotropy); } @@ -1521,7 +1592,8 @@ int gloadtile_hi(long dapic, long facen, hicreplctyp *hicr, long dameth, pthtyp bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT); } else - { //For sprite textures, clamping looks better than wrapping + { + //For sprite textures, clamping looks better than wrapping bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP); bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP); } @@ -1534,12 +1606,14 @@ int gloadtile_hi(long dapic, long facen, hicreplctyp *hicr, long dameth, pthtyp pth->skyface = facen; pth->hicr = hicr; - if (cachefil < 0) { + if (cachefil < 0) + { // save off the compressed version cachead.xdim = tsizx; cachead.ydim = tsizy; x = 0; - for (j=0;j<31;j++) { + for (j=0;j<31;j++) + { if (xsiz == pow2long[j]) { x |= 1; } if (ysiz == pow2long[j]) { x |= 2; } } @@ -1556,24 +1630,24 @@ int gloadtile_hi(long dapic, long facen, hicreplctyp *hicr, long dameth, pthtyp // n must be <= 8 (assume clipping can double number of vertices) //method: 0:solid, 1:masked(255 is transparent), 2:transluscent #1, 3:transluscent #2 // +4 means it's a sprite, so wraparound isn't needed -static long pow2xsplit = 0, skyclamphack = 0; +static int pow2xsplit = 0, skyclamphack = 0; -void drawpoly (double *dpx, double *dpy, long n, long method) +void drawpoly(double *dpx, double *dpy, int n, int method) { #define PI 3.14159265358979323 double ngdx = 0.0, ngdy = 0.0, ngdo = 0.0, ngux = 0.0, nguy = 0.0, nguo = 0.0; double ngvx = 0.0, ngvy = 0.0, ngvo = 0.0, dp, up, vp, rdp, du0 = 0.0, du1 = 0.0, dui, duj; double ngdx2, ngux2, ngvx2; double f, r, ox, oy, oz, ox2, oy2, oz2, dd[16], uu[16], vv[16], px[16], py[16], uoffs; - long i, j, k, x, y, z, nn, ix0, ix1, mini, maxi, tsizx, tsizy, tsizxm1 = 0, tsizym1 = 0, ltsizy = 0; - long xx, yy, xi, d0, u0, v0, d1, u1, v1, xmodnice = 0, ymulnice = 0, dorot; + int i, j, k, x, y, z, nn, ix0, ix1, mini, maxi, tsizx, tsizy, tsizxm1 = 0, tsizym1 = 0, ltsizy = 0; + int xx, yy, xi, d0, u0, v0, d1, u1, v1, xmodnice = 0, ymulnice = 0, dorot; char dacol = 0, *walptr, *palptr = NULL, *vidp, *vide; #ifdef USE_OPENGL pthtyp *pth, *detailpth, *glowpth; int texunits = GL_TEXTURE0_ARB; #endif // backup of the n for possible redrawing of fullbright - long n_ = n, method_ = method; + int n_ = n, method_ = method; if (method == -1) return; @@ -1589,7 +1663,7 @@ void drawpoly (double *dpx, double *dpy, long n, long method) } //Load texture (globalpicnum) - if ((unsigned long)globalpicnum >= MAXTILES) globalpicnum = 0; + if ((unsigned int)globalpicnum >= MAXTILES) globalpicnum = 0; setgotpic(globalpicnum); tsizx = tilesizx[globalpicnum]; tsizy = tilesizy[globalpicnum]; @@ -1682,7 +1756,7 @@ void drawpoly (double *dpx, double *dpy, long n, long method) // detail texture detailpth = NULL; if (r_detailmapping && usehightile && !r_depthpeeling && !drawingskybox && - hicfindsubst(globalpicnum, DETAILPAL, 0)) + hicfindsubst(globalpicnum, DETAILPAL, 0)) detailpth = gltexcache(globalpicnum, DETAILPAL, method&(~3)); if (detailpth && (detailpth->hicr->palnum == DETAILPAL)) @@ -1700,7 +1774,7 @@ void drawpoly (double *dpx, double *dpy, long n, long method) bglTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE); bglTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR); - + bglTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE); bglTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS_ARB); bglTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA); @@ -1728,7 +1802,7 @@ void drawpoly (double *dpx, double *dpy, long n, long method) // glow texture glowpth = NULL; if (r_glowmapping && usehightile && !r_depthpeeling && !drawingskybox && - hicfindsubst(globalpicnum, GLOWPAL, 0)) + hicfindsubst(globalpicnum, GLOWPAL, 0)) glowpth = gltexcache(globalpicnum, GLOWPAL, method&(~3)); if (glowpth && (glowpth->hicr->palnum == GLOWPAL)) @@ -1767,19 +1841,25 @@ void drawpoly (double *dpx, double *dpy, long n, long method) } else { hackscx = 1.0; hackscy = 1.0; } - if (!glinfo.texnpot) { + if (!glinfo.texnpot) + { for (xx=1;xxhicr && pth->hicr->alphacut >= 0.0) al = pth->hicr->alphacut; if (alphahackarray[globalpicnum]) @@ -1883,11 +1963,11 @@ void drawpoly (double *dpx, double *dpy, long n, long method) } f = 1.0/(double)tsizx; - ix0 = (long)floor(du0*f); - ix1 = (long)floor(du1*f); + ix0 = (int)floor(du0*f); + ix1 = (int)floor(du1*f); for (;ix0<=ix1;ix0++) { - du0 = (double)((ix0 )*tsizx); // + uoffs; + du0 = (double)((ix0)*tsizx); // + uoffs; du1 = (double)((ix0+1)*tsizx); // + uoffs; i = 0; nn = 0; @@ -1898,7 +1978,7 @@ void drawpoly (double *dpx, double *dpy, long n, long method) dui = duj; duj = (px[j]*ngux + py[j]*nguy + nguo) / (px[j]*ngdx + py[j]*ngdy + ngdo); - if ((du0 <= dui) && (dui <= du1)) { uu[nn] = px[i]; vv[nn] = py[i]; nn++; } + if ((du0 <= dui) && (dui <= du1)) { uu[nn] = px[i]; vv[nn] = py[i]; nn++; } if (duj <= dui) { if ((du1 < duj) != (du1 < dui)) @@ -1911,14 +1991,14 @@ void drawpoly (double *dpx, double *dpy, long n, long method) //((px[j]-px[i])*f + px[i])*(ngux-ngdx*du1) + //((py[j]-py[i])*f + py[i])*(nguy-ngdy*du1) + (nguo-ngdo*du1) = 0 - f = -( px[i] *(ngux-ngdx*du1) + py[i] *(nguy-ngdy*du1) + (nguo-ngdo*du1)) / + f = -(px[i] *(ngux-ngdx*du1) + py[i] *(nguy-ngdy*du1) + (nguo-ngdo*du1)) / ((px[j]-px[i])*(ngux-ngdx*du1) + (py[j]-py[i])*(nguy-ngdy*du1)); uu[nn] = (px[j]-px[i])*f + px[i]; vv[nn] = (py[j]-py[i])*f + py[i]; nn++; } if ((du0 < duj) != (du0 < dui)) { - f = -( px[i] *(ngux-ngdx*du0) + py[i] *(nguy-ngdy*du0) + (nguo-ngdo*du0)) / + f = -(px[i] *(ngux-ngdx*du0) + py[i] *(nguy-ngdy*du0) + (nguo-ngdo*du0)) / ((px[j]-px[i])*(ngux-ngdx*du0) + (py[j]-py[i])*(nguy-ngdy*du0)); uu[nn] = (px[j]-px[i])*f + px[i]; vv[nn] = (py[j]-py[i])*f + py[i]; nn++; @@ -1928,21 +2008,22 @@ void drawpoly (double *dpx, double *dpy, long n, long method) { if ((du0 < duj) != (du0 < dui)) { - f = -( px[i] *(ngux-ngdx*du0) + py[i] *(nguy-ngdy*du0) + (nguo-ngdo*du0)) / + f = -(px[i] *(ngux-ngdx*du0) + py[i] *(nguy-ngdy*du0) + (nguo-ngdo*du0)) / ((px[j]-px[i])*(ngux-ngdx*du0) + (py[j]-py[i])*(nguy-ngdy*du0)); uu[nn] = (px[j]-px[i])*f + px[i]; vv[nn] = (py[j]-py[i])*f + py[i]; nn++; } if ((du1 < duj) != (du1 < dui)) { - f = -( px[i] *(ngux-ngdx*du1) + py[i] *(nguy-ngdy*du1) + (nguo-ngdo*du1)) / + f = -(px[i] *(ngux-ngdx*du1) + py[i] *(nguy-ngdy*du1) + (nguo-ngdo*du1)) / ((px[j]-px[i])*(ngux-ngdx*du1) + (py[j]-py[i])*(nguy-ngdy*du1)); uu[nn] = (px[j]-px[i])*f + px[i]; vv[nn] = (py[j]-py[i])*f + py[i]; nn++; } } i = j; - } while (i); + } + while (i); if (nn < 3) continue; bglBegin(GL_TRIANGLE_FAN); @@ -2023,9 +2104,9 @@ void drawpoly (double *dpx, double *dpy, long n, long method) { zbufbpl = bytesperline; zbufysiz = ydim; - zbufmem = (long)realloc((void *)zbufmem,zbufbpl*zbufysiz*4); + zbufmem = (int)realloc((void *)zbufmem,zbufbpl*zbufysiz*4); } - zbufoff = (long *)(zbufmem-(frameplace<<2)); + zbufoff = (int *)(zbufmem-(frameplace<<2)); #endif if ((!transluc)) method = (method&~3)+1; //In case translucent table doesn't exist @@ -2072,13 +2153,13 @@ void drawpoly (double *dpx, double *dpy, long n, long method) tsizxm1 = tsizx-1; xmodnice = (!(tsizxm1&tsizx)); tsizym1 = tsizy-1; ymulnice = (!(tsizym1&tsizy)); if ((method&4) && (!xmodnice)) //Sprites don't need a mod on texture coordinates - { xmodnice = 1; for (tsizxm1=1;tsizxm1>4); } else { - dacol = palookup[0][(long)(*(char *)(waloff[globalpicnum]))+(min(max(globalshade,0),numpalookups-1)<<8)]; + dacol = palookup[0][(int)(*(char *)(waloff[globalpicnum]))+(min(max(globalshade,0),numpalookups-1)<<8)]; } if (grhalfxdown10x < 0) //Hack for mirrors @@ -2116,7 +2197,8 @@ void drawpoly (double *dpx, double *dpy, long n, long method) for (;yy>y;yy--,x-=xi) lastx[yy-1] = (x>>14); } i = j; - } while (i != mini); + } + while (i != mini); do { j = i+1; if (j == n) j = 0; @@ -2140,7 +2222,7 @@ void drawpoly (double *dpx, double *dpy, long n, long method) up = ngux*(double)ix0 + nguy*(double)y + nguo; vp = ngvx*(double)ix0 + ngvy*(double)y + ngvo; rdp = 65536.0/dp; dp += ngdx2; - dtol( rdp,&d0); + dtol(rdp,&d0); dtol(up*rdp,&u0); up += ngux2; dtol(vp*rdp,&v0); vp += ngvx2; rdp = 65536.0/dp; @@ -2152,7 +2234,7 @@ void drawpoly (double *dpx, double *dpy, long n, long method) { for (xx=ix0;xx>LINTERPSIZ); + dtol(rdp,&d1); dp += ngdx2; d1 = ((d1-d0)>>LINTERPSIZ); dtol(up*rdp,&u1); up += ngux2; u1 = ((u1-u0)>>LINTERPSIZ); dtol(vp*rdp,&v1); vp += ngvx2; v1 = ((v1-v0)>>LINTERPSIZ); rdp = 65536.0/dp; vide = &vidp[min(ix1-xx,1<>16)&tsizxm1)<>16)&tsizym1)]]; //+((d0>>13)&0x3f00)]; #else @@ -2174,7 +2256,7 @@ void drawpoly (double *dpx, double *dpy, long n, long method) { for (xx=ix0;xx>LINTERPSIZ); + dtol(rdp,&d1); dp += ngdx2; d1 = ((d1-d0)>>LINTERPSIZ); dtol(up*rdp,&u1); up += ngux2; u1 = ((u1-u0)>>LINTERPSIZ); dtol(vp*rdp,&v1); vp += ngvx2; v1 = ((v1-v0)>>LINTERPSIZ); rdp = 65536.0/dp; vide = &vidp[min(ix1-xx,1<>16,tsizx)*tsizy + ((v0>>16)&tsizym1)]]; //+((d0>>13)&0x3f00)]; #else @@ -2198,7 +2280,7 @@ void drawpoly (double *dpx, double *dpy, long n, long method) { for (xx=ix0;xx>LINTERPSIZ); + dtol(rdp,&d1); dp += ngdx2; d1 = ((d1-d0)>>LINTERPSIZ); dtol(up*rdp,&u1); up += ngux2; u1 = ((u1-u0)>>LINTERPSIZ); dtol(vp*rdp,&v1); vp += ngvx2; v1 = ((v1-v0)>>LINTERPSIZ); rdp = 65536.0/dp; vide = &vidp[min(ix1-xx,1<>16)&tsizxm1)*tsizy) + ((v0>>16)&tsizym1)]; #if (DEPTHDEBUG == 0) #if (USEZBUFFER != 0) - if ((dacol != 255) && (d0 <= zbufoff[(long)vidp])) + if ((dacol != 255) && (d0 <= zbufoff[(int)vidp])) { - zbufoff[(long)vidp] = d0; - vidp[0] = palptr[((long)dacol)]; //+((d0>>13)&0x3f00)]; + zbufoff[(int)vidp] = d0; + vidp[0] = palptr[((int)dacol)]; //+((d0>>13)&0x3f00)]; } #else - if (dacol != 255) vidp[0] = palptr[((long)dacol)]; //+((d0>>13)&0x3f00)]; + if (dacol != 255) vidp[0] = palptr[((int)dacol)]; //+((d0>>13)&0x3f00)]; #endif #else if ((dacol != 255) && (vidp[0] > (d0>>16))) vidp[0] = ((d0>>16)&255); @@ -2226,7 +2308,7 @@ void drawpoly (double *dpx, double *dpy, long n, long method) { for (xx=ix0;xx>LINTERPSIZ); + dtol(rdp,&d1); dp += ngdx2; d1 = ((d1-d0)>>LINTERPSIZ); dtol(up*rdp,&u1); up += ngux2; u1 = ((u1-u0)>>LINTERPSIZ); dtol(vp*rdp,&v1); vp += ngvx2; v1 = ((v1-v0)>>LINTERPSIZ); rdp = 65536.0/dp; vide = &vidp[min(ix1-xx,1<>16,tsizx)*tsizy + ((v0>>16)&tsizym1)]; #if (DEPTHDEBUG == 0) #if (USEZBUFFER != 0) - if ((dacol != 255) && (d0 <= zbufoff[(long)vidp])) + if ((dacol != 255) && (d0 <= zbufoff[(int)vidp])) { - zbufoff[(long)vidp] = d0; - vidp[0] = palptr[((long)dacol)]; //+((d0>>13)&0x3f00)]; + zbufoff[(int)vidp] = d0; + vidp[0] = palptr[((int)dacol)]; //+((d0>>13)&0x3f00)]; } #else - if (dacol != 255) vidp[0] = palptr[((long)dacol)]; //+((d0>>13)&0x3f00)]; + if (dacol != 255) vidp[0] = palptr[((int)dacol)]; //+((d0>>13)&0x3f00)]; #endif #else if ((dacol != 255) && (vidp[0] > (d0>>16))) vidp[0] = ((d0>>16)&255); @@ -2254,7 +2336,7 @@ void drawpoly (double *dpx, double *dpy, long n, long method) case 2: //Transluscence #1 for (xx=ix0;xx>LINTERPSIZ); + dtol(rdp,&d1); dp += ngdx2; d1 = ((d1-d0)>>LINTERPSIZ); dtol(up*rdp,&u1); up += ngux2; u1 = ((u1-u0)>>LINTERPSIZ); dtol(vp*rdp,&v1); vp += ngvx2; v1 = ((v1-v0)>>LINTERPSIZ); rdp = 65536.0/dp; vide = &vidp[min(ix1-xx,1<>16)&tsizxm1)<>16)&tsizym1)]; #if (DEPTHDEBUG == 0) #if (USEZBUFFER != 0) - if ((dacol != 255) && (d0 <= zbufoff[(long)vidp])) + if ((dacol != 255) && (d0 <= zbufoff[(int)vidp])) { - zbufoff[(long)vidp] = d0; - vidp[0] = transluc[(((long)vidp[0])<<8)+((long)palptr[((long)dacol)])]; //+((d0>>13)&0x3f00)])]; + zbufoff[(int)vidp] = d0; + vidp[0] = transluc[(((int)vidp[0])<<8)+((int)palptr[((int)dacol)])]; //+((d0>>13)&0x3f00)])]; } #else if (dacol != 255) - vidp[0] = transluc[(((long)vidp[0])<<8)+((long)palptr[((long)dacol)])]; //+((d0>>13)&0x3f00)])]; + vidp[0] = transluc[(((int)vidp[0])<<8)+((int)palptr[((int)dacol)])]; //+((d0>>13)&0x3f00)])]; #endif #else if ((dacol != 255) && (vidp[0] > (d0>>16))) vidp[0] = ((d0>>16)&255); @@ -2283,7 +2365,7 @@ void drawpoly (double *dpx, double *dpy, long n, long method) case 3: //Transluscence #2 for (xx=ix0;xx>LINTERPSIZ); + dtol(rdp,&d1); dp += ngdx2; d1 = ((d1-d0)>>LINTERPSIZ); dtol(up*rdp,&u1); up += ngux2; u1 = ((u1-u0)>>LINTERPSIZ); dtol(vp*rdp,&v1); vp += ngvx2; v1 = ((v1-v0)>>LINTERPSIZ); rdp = 65536.0/dp; vide = &vidp[min(ix1-xx,1<>16)&tsizxm1)<>16)&tsizym1)]; #if (DEPTHDEBUG == 0) #if (USEZBUFFER != 0) - if ((dacol != 255) && (d0 <= zbufoff[(long)vidp])) + if ((dacol != 255) && (d0 <= zbufoff[(int)vidp])) { - zbufoff[(long)vidp] = d0; - vidp[0] = transluc[((long)vidp[0])+(((long)palptr[((long)dacol)/*+((d0>>13)&0x3f00)*/])<<8)]; + zbufoff[(int)vidp] = d0; + vidp[0] = transluc[((int)vidp[0])+(((int)palptr[((int)dacol)/*+((d0>>13)&0x3f00)*/])<<8)]; } #else if (dacol != 255) - vidp[0] = transluc[((long)vidp[0])+(((long)palptr[((long)dacol)/*+((d0>>13)&0x3f00)*/])<<8)]; + vidp[0] = transluc[((int)vidp[0])+(((int)palptr[((int)dacol)/*+((d0>>13)&0x3f00)*/])<<8)]; #endif #else if ((dacol != 255) && (vidp[0] > (d0>>16))) vidp[0] = ((d0>>16)&255); @@ -2315,7 +2397,8 @@ void drawpoly (double *dpx, double *dpy, long n, long method) } } i = j; - } while (i != maxi); + } + while (i != maxi); if (rendmode == 1) { @@ -2337,9 +2420,9 @@ void drawpoly (double *dpx, double *dpy, long n, long method) // / \ // (px[3],py[3]).--------------.(px[2],py[2]) */ -void initmosts (double *px, double *py, long n) +void initmosts(double *px, double *py, int n) { - long i, j, k, imin; + int i, j, k, imin; vcnt = 1; //0 is dummy solid node @@ -2391,7 +2474,8 @@ void initmosts (double *px, double *py, long n) i++; if (i >= n) i = 0; if (i == j) break; j--; if (j < 0) j = n-1; } - } while (i != j); + } + while (i != j); if (px[i] > vsp[vcnt-1].x) { vsp[vcnt].x = px[i]; @@ -2414,9 +2498,9 @@ void initmosts (double *px, double *py, long n) vsp[VSPMAX-1].n = vcnt; vsp[vcnt].p = VSPMAX-1; } -void vsdel (long i) +void vsdel(int i) { - long pi, ni; + int pi, ni; //Delete i pi = vsp[i].p; ni = vsp[i].n; @@ -2430,9 +2514,9 @@ void vsdel (long i) vsp[VSPMAX-1].n = i; } -long vsinsaft (long i) +int vsinsaft(int i) { - long r; + int r; //i = next element from empty list r = vsp[VSPMAX-1].n; vsp[vsp[r].n].p = VSPMAX-1; @@ -2447,9 +2531,9 @@ long vsinsaft (long i) return(r); } -long testvisiblemost (float x0, float x1) +int testvisiblemost(float x0, float x1) { - long i, newi; + int i, newi; for (i=vsp[0].n;i;i=newi) { @@ -2459,14 +2543,14 @@ long testvisiblemost (float x0, float x1) return(0); } -static long domostpolymethod = 0; +static int domostpolymethod = 0; -void domost (float x0, float y0, float x1, float y1) +void domost(float x0, float y0, float x1, float y1) { double dpx[4], dpy[4]; float d, f, n, t, slop, dx, dx0, dx1, nx, nx0, ny0, nx1, ny1; float spx[4], spy[4], cy[2], cv[2]; - long i, j, k, z, ni, vcnt = 0, scnt, newi, dir, spt[4]; + int i, j, k, z, ni, vcnt = 0, scnt, newi, dir, spt[4]; if (x0 < x1) { @@ -2498,7 +2582,7 @@ void domost (float x0, float y0, float x1, float y1) { t = (x0-nx0)*cv[dir] - (y0-cy[dir])*dx; if (((!dir) && (t < 0)) || ((dir) && (t > 0))) - { spx[scnt] = x0; spy[scnt] = y0; spt[scnt] = -1; scnt++; } + { spx[scnt] = x0; spy[scnt] = y0; spt[scnt] = -1; scnt++; } } //Test for intersection on umost (j == 0) and dmost (j == 1) @@ -2530,7 +2614,7 @@ void domost (float x0, float y0, float x1, float y1) { t = (x1-nx0)*cv[dir] - (y1-cy[dir])*dx; if (((!dir) && (t < 0)) || ((dir) && (t > 0))) - { spx[scnt] = x1; spy[scnt] = y1; spt[scnt] = -1; scnt++; } + { spx[scnt] = x1; spy[scnt] = y1; spt[scnt] = -1; scnt++; } } vsp[i].tag = vsp[newi].tag = -1; @@ -2654,14 +2738,14 @@ void domost (float x0, float y0, float x1, float y1) ni = vsp[i].n; if ((vsp[i].cy[0] >= vsp[i].fy[0]) && (vsp[i].cy[1] >= vsp[i].fy[1])) { vsp[i].ctag = vsp[i].ftag = -1; } if ((vsp[i].ctag == vsp[ni].ctag) && (vsp[i].ftag == vsp[ni].ftag)) - { vsp[i].cy[1] = vsp[ni].cy[1]; vsp[i].fy[1] = vsp[ni].fy[1]; vsdel(ni); } + { vsp[i].cy[1] = vsp[ni].cy[1]; vsp[i].fy[1] = vsp[ni].fy[1]; vsdel(ni); } else i = ni; } } -static void polymost_scansector (long sectnum); +static void polymost_scansector(int sectnum); -static void polymost_drawalls (long bunch) +static void polymost_drawalls(int bunch) { sectortype *sec, *nextsec; walltype *wal, *wal2, *nwal; @@ -2669,13 +2753,15 @@ static void polymost_drawalls (long bunch) double fx, fy, x0, x1, y0, y1, cy0, cy1, fy0, fy1, xp0, yp0, xp1, yp1, ryp0, ryp1, nx0, ny0, nx1, ny1; double t, r, t0, t1, ocy0, ocy1, ofy0, ofy1, oxp0, oyp0, ft[4]; double oguo, ogux, oguy; - long i, x, y, z, cz, fz, wallnum, sectnum, nextsectnum; + int i, x, y, z, cz, fz, wallnum, sectnum, nextsectnum; sectnum = thesector[bunchfirst[bunch]]; sec = §or[sectnum]; #if 0 // USE_OPENGL - if (!nofog) { - if (rendmode >= 3) { + if (!nofog) + { + if (rendmode >= 3) + { float col[4]; col[0] = (float)palookupfog[sec->floorpal].r / 63.f; col[1] = (float)palookupfog[sec->floorpal].g / 63.f; @@ -2713,7 +2799,7 @@ static void polymost_drawalls (long bunch) nx0 = (wal2->x-wal->x)*t0+wal->x; ny0 = (wal2->y-wal->y)*t0+wal->y; } - else { t0 = 0.f; nx0 = wal->x; ny0 = wal->y; } + else { t0 = 0.f; nx0 = wal->x; ny0 = wal->y; } if (yp1 < SCISDIST) { t1 = (SCISDIST-oyp0)/(yp1-oyp0); xp1 = (xp1-oxp0)*t1+oxp0; yp1 = SCISDIST; @@ -2731,15 +2817,15 @@ static void polymost_drawalls (long bunch) ryp0 *= gyxscale; ryp1 *= gyxscale; - getzsofslope(sectnum,(long)nx0,(long)ny0,&cz,&fz); + getzsofslope(sectnum,(int)nx0,(int)ny0,&cz,&fz); cy0 = ((float)(cz-globalposz))*ryp0 + ghoriz; fy0 = ((float)(fz-globalposz))*ryp0 + ghoriz; - getzsofslope(sectnum,(long)nx1,(long)ny1,&cz,&fz); + getzsofslope(sectnum,(int)nx1,(int)ny1,&cz,&fz); cy1 = ((float)(cz-globalposz))*ryp1 + ghoriz; fy1 = ((float)(fz-globalposz))*ryp1 + ghoriz; - globalpicnum = sec->floorpicnum; globalshade = sec->floorshade; globalpal = (long)((unsigned char)sec->floorpal); + globalpicnum = sec->floorpicnum; globalshade = sec->floorshade; globalpal = (int)((unsigned char)sec->floorpal); globalorientation = sec->floorstat; if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,sectnum); if (!(globalorientation&1)) @@ -2748,7 +2834,7 @@ static void polymost_drawalls (long bunch) //(cosglobalang/ 16384*(sx-ghalfx) + 0*(sy-ghoriz) + (sinviewingrangeglobalang/16384)*ghalfx)*d + globalposy = v*16 //( 0*(sx-ghalfx) + 1*(sy-ghoriz) + ( 0)*ghalfx)*d + globalposz/16 = (sec->floorz/16) if (!(globalorientation&64)) - { ft[0] = globalposx; ft[1] = globalposy; ft[2] = cosglobalang; ft[3] = singlobalang; } + { ft[0] = globalposx; ft[1] = globalposy; ft[2] = cosglobalang; ft[3] = singlobalang; } else { //relative alignment @@ -2764,7 +2850,7 @@ static void polymost_drawalls (long bunch) gdx = 0; gdy = gxyaspect; if (!(globalorientation&2)) gdy /= (double)(sec->floorz-globalposz); gdo = -ghoriz*gdy; - if (globalorientation&8) { ft[0] /= 8; ft[1] /= -8; ft[2] /= 2097152; ft[3] /= 2097152; } + if (globalorientation&8) { ft[0] /= 8; ft[1] /= -8; ft[2] /= 2097152; ft[3] /= 2097152; } else { ft[0] /= 16; ft[1] /= -16; ft[2] /= 4194304; ft[3] /= 4194304; } gux = (double)ft[3]*((double)viewingrange)/-65536.0; gvx = (double)ft[2]*((double)viewingrange)/-65536.0; @@ -2817,7 +2903,7 @@ static void polymost_drawalls (long bunch) py[0] = fy0; py[1] = fy1; - py[2] = (getflorzofslope(sectnum,(long)ox,(long)oy)-globalposz)*oy2 + ghoriz; + py[2] = (getflorzofslope(sectnum,(int)ox,(int)oy)-globalposz)*oy2 + ghoriz; ox = py[1]-py[2]; oy = py[2]-py[0]; oz = py[0]-py[1]; r = 1.0 / (ox*px[0] + oy*px[1] + oz*px[2]); @@ -2847,7 +2933,7 @@ static void polymost_drawalls (long bunch) { fogcalc(sec->floorshade,sec->visibility,sec->floorpal); bglFogf(GL_FOG_DENSITY,fogresult); - bglFogfv(GL_FOG_COLOR,fogcol); + bglFogfv(GL_FOG_COLOR,fogcol); } #endif pow2xsplit = 0; domost(x0,fy0,x1,fy1); //flor @@ -2870,13 +2956,13 @@ static void polymost_drawalls (long bunch) { fogcalc(sec->floorshade,sec->visibility,sec->floorpal); bglFogf(GL_FOG_DENSITY,fogresult * 0.005); - bglFogfv(GL_FOG_COLOR,fogcol); + bglFogfv(GL_FOG_COLOR,fogcol); } //Use clamping for tiled sky textures for (i=(1<0;i--) if (pskyoff[i] != pskyoff[i-1]) - { skyclamphack = 1; break; } + { skyclamphack = 1; break; } } #endif if (bpp == 8 || !usehightile || !hicfindsubst(globalpicnum,globalpal,1)) @@ -2896,7 +2982,8 @@ static void polymost_drawalls (long bunch) oy = (((double)tilesizy[globalpicnum])*dd[0]-vv[0])/vv[1]; if ((oy > fy0) && (oy > fy1)) domost(x0,oy,x1,oy); else if ((oy > fy0) != (oy > fy1)) - { // fy0 fy1 + { + // fy0 fy1 // \ / //oy---------- oy---------- // \ / @@ -2904,7 +2991,8 @@ static void polymost_drawalls (long bunch) ox = (oy-fy0)*(x1-x0)/(fy1-fy0) + x0; if (oy > fy0) { domost(x0,oy,ox,oy); domost(ox,oy,x1,fy1); } else { domost(x0,fy0,ox,oy); domost(ox,oy,x1,oy); } - } else domost(x0,fy0,x1,fy1); + } + else domost(x0,fy0,x1,fy1); gdx = 0; gdy = 0; gdo = dd[0]; @@ -2915,7 +3003,7 @@ static void polymost_drawalls (long bunch) i = globalpicnum; r = (fy1-fy0)/(x1-x0); //slope of line oy = ((double)viewingrange)/(ghalfx*256.0); oz = 1/oy; - y = ((((long)((x0-ghalfx)*oy))+globalang)>>(11-pskybits)); + y = ((((int)((x0-ghalfx)*oy))+globalang)>>(11-pskybits)); fx = x0; do { @@ -2926,15 +3014,17 @@ static void polymost_drawalls (long bunch) if (fx > x1) { fx = x1; i = -1; } pow2xsplit = 0; domost(ox,(ox-x0)*r+fy0,fx,(fx-x0)*r+fy0); //flor - } while (i >= 0); + } + while (i >= 0); } else //NOTE: code copied from ceiling code... lots of duplicated stuff :/ - { //Skybox code for parallax ceiling! + { + //Skybox code for parallax ceiling! double _xp0, _yp0, _xp1, _yp1, _oxp0, _oyp0, _t0, _t1, _nx0, _ny0, _nx1, _ny1; double _ryp0, _ryp1, _x0, _x1, _cy0, _fy0, _cy1, _fy1, _ox0, _ox1; double nfy0, nfy1; - long skywalx[4] = {-512,512,512,-512}, skywaly[4] = {-512,-512,512,512}; + int skywalx[4] = {-512,512,512,-512}, skywaly[4] = {-512,-512,512,512}; pow2xsplit = 0; skyclamphack = 1; @@ -2958,7 +3048,7 @@ static void polymost_drawalls (long bunch) _nx0 = (skywalx[(i+1)&3]-skywalx[i&3])*_t0+skywalx[i&3]; _ny0 = (skywaly[(i+1)&3]-skywaly[i&3])*_t0+skywaly[i&3]; } - else { _t0 = 0.f; _nx0 = skywalx[i&3]; _ny0 = skywaly[i&3]; } + else { _t0 = 0.f; _nx0 = skywalx[i&3]; _ny0 = skywaly[i&3]; } if (_yp1 < SCISDIST) { _t1 = (SCISDIST-_oyp0)/(_yp1-_oyp0); _xp1 = (_xp1-_oxp0)*_t1+_oxp0; _yp1 = SCISDIST; @@ -3040,7 +3130,8 @@ static void polymost_drawalls (long bunch) oy = _fy0 + (_fy1-_fy0)*t; if (nfy0 > _fy0) { domost(_x0,nfy0,ox,oy); domost(ox,oy,_x1,_fy1); } else { domost(_x0,_fy0,ox,oy); domost(ox,oy,_x1,nfy1); } - } else domost(_x0,nfy0,_x1,nfy1); + } + else domost(_x0,nfy0,_x1,nfy1); //wall of skybox #ifdef USE_OPENGL @@ -3071,7 +3162,8 @@ static void polymost_drawalls (long bunch) oy = _cy0 + (_cy1-_cy0)*t; if (nfy0 > _cy0) { domost(_x0,nfy0,ox,oy); domost(ox,oy,_x1,_cy1); } else { domost(_x0,_cy0,ox,oy); domost(ox,oy,_x1,nfy1); } - } else domost(_x0,nfy0,_x1,nfy1); + } + else domost(_x0,nfy0,_x1,nfy1); } //Floor of skybox @@ -3101,7 +3193,8 @@ static void polymost_drawalls (long bunch) if (rendmode >= 3) { skyclamphack = 0; - if (!nofog) { + if (!nofog) + { bglEnable(GL_FOG); //bglFogf(GL_FOG_DENSITY,gvisibility*((float)((unsigned char)(sec->visibility<240?sec->visibility+16:sec->visibility-239)))); } @@ -3109,13 +3202,13 @@ static void polymost_drawalls (long bunch) #endif } - globalpicnum = sec->ceilingpicnum; globalshade = sec->ceilingshade; globalpal = (long)((unsigned char)sec->ceilingpal); + globalpicnum = sec->ceilingpicnum; globalshade = sec->ceilingshade; globalpal = (int)((unsigned char)sec->ceilingpal); globalorientation = sec->ceilingstat; if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,sectnum); if (!(globalorientation&1)) { if (!(globalorientation&64)) - { ft[0] = globalposx; ft[1] = globalposy; ft[2] = cosglobalang; ft[3] = singlobalang; } + { ft[0] = globalposx; ft[1] = globalposy; ft[2] = cosglobalang; ft[3] = singlobalang; } else { //relative alignment @@ -3132,7 +3225,7 @@ static void polymost_drawalls (long bunch) gdy = gxyaspect; if (!(globalorientation&2)) gdy /= (double)(sec->ceilingz-globalposz); gdo = -ghoriz*gdy; - if (globalorientation&8) { ft[0] /= 8; ft[1] /= -8; ft[2] /= 2097152; ft[3] /= 2097152; } + if (globalorientation&8) { ft[0] /= 8; ft[1] /= -8; ft[2] /= 2097152; ft[3] /= 2097152; } else { ft[0] /= 16; ft[1] /= -16; ft[2] /= 4194304; ft[3] /= 4194304; } gux = (double)ft[3]*((double)viewingrange)/-65536.0; gvx = (double)ft[2]*((double)viewingrange)/-65536.0; @@ -3185,7 +3278,7 @@ static void polymost_drawalls (long bunch) py[0] = cy0; py[1] = cy1; - py[2] = (getceilzofslope(sectnum,(long)ox,(long)oy)-globalposz)*oy2 + ghoriz; + py[2] = (getceilzofslope(sectnum,(int)ox,(int)oy)-globalposz)*oy2 + ghoriz; ox = py[1]-py[2]; oy = py[2]-py[0]; oz = py[0]-py[1]; r = 1.0 / (ox*px[0] + oy*px[1] + oz*px[2]); @@ -3215,7 +3308,7 @@ static void polymost_drawalls (long bunch) { fogcalc(sec->ceilingshade,sec->visibility,sec->floorpal); bglFogf(GL_FOG_DENSITY,fogresult); - bglFogfv(GL_FOG_COLOR,fogcol); + bglFogfv(GL_FOG_COLOR,fogcol); } #endif pow2xsplit = 0; domost(x1,cy1,x0,cy0); //ceil @@ -3237,12 +3330,12 @@ static void polymost_drawalls (long bunch) { fogcalc(sec->ceilingshade,sec->visibility,sec->floorpal); bglFogf(GL_FOG_DENSITY,fogresult * 0.005); - bglFogfv(GL_FOG_COLOR,fogcol); + bglFogfv(GL_FOG_COLOR,fogcol); } //Use clamping for tiled sky textures for (i=(1<0;i--) if (pskyoff[i] != pskyoff[i-1]) - { skyclamphack = 1; break; } + { skyclamphack = 1; break; } } #endif //Parallaxing sky... @@ -3272,7 +3365,8 @@ static void polymost_drawalls (long bunch) ox = (oy-cy0)*(x1-x0)/(cy1-cy0) + x0; if (oy < cy0) { domost(ox,oy,x0,oy); domost(x1,cy1,ox,oy); } else { domost(ox,oy,x0,cy0); domost(x1,oy,ox,oy); } - } else domost(x1,cy1,x0,cy0); + } + else domost(x1,cy1,x0,cy0); gdx = 0; gdy = 0; gdo = dd[0]; gux = gdo*(t*((double)xdimscale)*((double)yxaspect)*((double)viewingrange))/(16384.0*65536.0*65536.0*5.0*1024.0); @@ -3282,7 +3376,7 @@ static void polymost_drawalls (long bunch) i = globalpicnum; r = (cy1-cy0)/(x1-x0); //slope of line oy = ((double)viewingrange)/(ghalfx*256.0); oz = 1/oy; - y = ((((long)((x0-ghalfx)*oy))+globalang)>>(11-pskybits)); + y = ((((int)((x0-ghalfx)*oy))+globalang)>>(11-pskybits)); fx = x0; do { @@ -3292,14 +3386,16 @@ static void polymost_drawalls (long bunch) ox = fx; fx = ((double)((y<<(11-pskybits))-globalang))*oz+ghalfx; if (fx > x1) { fx = x1; i = -1; } pow2xsplit = 0; domost(fx,(fx-x0)*r+cy0,ox,(ox-x0)*r+cy0); //ceil - } while (i >= 0); + } + while (i >= 0); } else - { //Skybox code for parallax ceiling! + { + //Skybox code for parallax ceiling! double _xp0, _yp0, _xp1, _yp1, _oxp0, _oyp0, _t0, _t1, _nx0, _ny0, _nx1, _ny1; double _ryp0, _ryp1, _x0, _x1, _cy0, _fy0, _cy1, _fy1, _ox0, _ox1; double ncy0, ncy1; - long skywalx[4] = {-512,512,512,-512}, skywaly[4] = {-512,-512,512,512}; + int skywalx[4] = {-512,512,512,-512}, skywaly[4] = {-512,-512,512,512}; pow2xsplit = 0; skyclamphack = 1; @@ -3323,7 +3419,7 @@ static void polymost_drawalls (long bunch) _nx0 = (skywalx[(i+1)&3]-skywalx[i&3])*_t0+skywalx[i&3]; _ny0 = (skywaly[(i+1)&3]-skywaly[i&3])*_t0+skywaly[i&3]; } - else { _t0 = 0.f; _nx0 = skywalx[i&3]; _ny0 = skywaly[i&3]; } + else { _t0 = 0.f; _nx0 = skywalx[i&3]; _ny0 = skywaly[i&3]; } if (_yp1 < SCISDIST) { _t1 = (SCISDIST-_oyp0)/(_yp1-_oyp0); _xp1 = (_xp1-_oxp0)*_t1+_oxp0; _yp1 = SCISDIST; @@ -3404,7 +3500,8 @@ static void polymost_drawalls (long bunch) oy = _cy0 + (_cy1-_cy0)*t; if (ncy0 < _cy0) { domost(ox,oy,_x0,ncy0); domost(_x1,_cy1,ox,oy); } else { domost(ox,oy,_x0,_cy0); domost(_x1,ncy1,ox,oy); } - } else domost(_x1,ncy1,_x0,ncy0); + } + else domost(_x1,ncy1,_x0,ncy0); //wall of skybox #ifdef USE_OPENGL @@ -3435,7 +3532,8 @@ static void polymost_drawalls (long bunch) oy = _fy0 + (_fy1-_fy0)*t; if (ncy0 < _fy0) { domost(ox,oy,_x0,ncy0); domost(_x1,_fy1,ox,oy); } else { domost(ox,oy,_x0,_fy0); domost(_x1,ncy1,ox,oy); } - } else domost(_x1,ncy1,_x0,ncy0); + } + else domost(_x1,ncy1,_x0,ncy0); } //Floor of skybox @@ -3466,7 +3564,8 @@ static void polymost_drawalls (long bunch) if (rendmode >= 3) { skyclamphack = 0; - if (!nofog) { + if (!nofog) + { bglEnable(GL_FOG); //bglFogf(GL_FOG_DENSITY,gvisibility*((float)((unsigned char)(sec->visibility<240?sec->visibility+16:sec->visibility-239)))); } @@ -3516,10 +3615,10 @@ static void polymost_drawalls (long bunch) if (nextsectnum >= 0) { - getzsofslope(nextsectnum,(long)nx0,(long)ny0,&cz,&fz); + getzsofslope(nextsectnum,(int)nx0,(int)ny0,&cz,&fz); ocy0 = ((float)(cz-globalposz))*ryp0 + ghoriz; ofy0 = ((float)(fz-globalposz))*ryp0 + ghoriz; - getzsofslope(nextsectnum,(long)nx1,(long)ny1,&cz,&fz); + getzsofslope(nextsectnum,(int)nx1,(int)ny1,&cz,&fz); ocy1 = ((float)(cz-globalposz))*ryp1 + ghoriz; ofy1 = ((float)(fz-globalposz))*ryp1 + ghoriz; @@ -3527,7 +3626,7 @@ static void polymost_drawalls (long bunch) if (((cy0 < ocy0) || (cy1 < ocy1)) && (!((sec->ceilingstat§or[nextsectnum].ceilingstat)&1))) { - globalpicnum = wal->picnum; globalshade = wal->shade; globalpal = (long)((unsigned char)wal->pal); + globalpicnum = wal->picnum; globalshade = wal->shade; globalpal = (int)((unsigned char)wal->pal); if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,wallnum+16384); if (!(wal->cstat&4)) i = sector[nextsectnum].ceilingz; else i = sec->ceilingz; @@ -3557,7 +3656,7 @@ static void polymost_drawalls (long bunch) } #endif pow2xsplit = 1; domost(x1,ocy1,x0,ocy0); - if (wal->cstat&8) { gux = ogux; guy = oguy; guo = oguo; } + if (wal->cstat&8) { gux = ogux; guy = oguy; guo = oguo; } } if (((ofy0 < fy0) || (ofy1 < fy1)) && (!((sec->floorstat§or[nextsectnum].floorstat)&1))) { @@ -3569,7 +3668,7 @@ static void polymost_drawalls (long bunch) gux += (float)(nwal->xpanning-wal->xpanning)*gdx; guy += (float)(nwal->xpanning-wal->xpanning)*gdy; } - globalpicnum = nwal->picnum; globalshade = nwal->shade; globalpal = (long)((unsigned char)nwal->pal); + globalpicnum = nwal->picnum; globalshade = nwal->shade; globalpal = (int)((unsigned char)nwal->pal); if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,wallnum+16384); if (!(nwal->cstat&4)) i = sector[nextsectnum].floorz; else i = sec->ceilingz; @@ -3599,18 +3698,18 @@ static void polymost_drawalls (long bunch) } #endif pow2xsplit = 1; domost(x0,ofy0,x1,ofy1); - if (wal->cstat&(2+8)) { guo = oguo; gux = ogux; guy = oguy; } + if (wal->cstat&(2+8)) { guo = oguo; gux = ogux; guy = oguy; } } } if ((nextsectnum < 0) || (wal->cstat&32)) //White/1-way wall { if (nextsectnum < 0) globalpicnum = wal->picnum; else globalpicnum = wal->overpicnum; - globalshade = wal->shade; globalpal = (long)((unsigned char)wal->pal); + globalshade = wal->shade; globalpal = (int)((unsigned char)wal->pal); if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,wallnum+16384); - if (nextsectnum >= 0) { if (!(wal->cstat&4)) i = nextsec->ceilingz; else i = sec->ceilingz; } - else { if (!(wal->cstat&4)) i = sec->ceilingz; else i = sec->floorz; } + if (nextsectnum >= 0) { if (!(wal->cstat&4)) i = nextsec->ceilingz; else i = sec->ceilingz; } + else { if (!(wal->cstat&4)) i = sec->ceilingz; else i = sec->floorz; } t0 = ((float)(i-globalposz))*ryp0 + ghoriz; t1 = ((float)(i-globalposz))*ryp1 + ghoriz; t = ((gdx*x0 + gdo) * (float)wal->yrepeat) / ((x1-x0) * ryp0 * 2048.f); @@ -3645,11 +3744,11 @@ static void polymost_drawalls (long bunch) } } -static long wallfront(long, long); -static long polymost_bunchfront (long b1, long b2) +static int wallfront(int, int); +static int polymost_bunchfront(int b1, int b2) { double x1b1, x1b2, x2b1, x2b2; - long b1f, b2f, i; + int b1f, b2f, i; b1f = bunchfirst[b1]; x1b1 = dxb1[b1f]; x2b2 = dxb2[bunchlast[b2]]; if (x1b1 >= x2b2) return(-1); b2f = bunchfirst[b2]; x1b2 = dxb1[b2f]; x2b1 = dxb2[bunchlast[b1]]; if (x1b2 >= x2b1) return(-1); @@ -3663,13 +3762,13 @@ static long polymost_bunchfront (long b1, long b2) return(wallfront(i,b2f)); } -static void polymost_scansector (long sectnum) +static void polymost_scansector(int sectnum) { double d, xp1, yp1, xp2, yp2; walltype *wal, *wal2; spritetype *spr; - long z, zz, startwall, endwall, numscansbefore, scanfirst, bunchfrst, nextsectnum; - long xs, ys, x1, y1, x2, y2; + int z, zz, startwall, endwall, numscansbefore, scanfirst, bunchfrst, nextsectnum; + int xs, ys, x1, y1, x2, y2; if (sectnum < 0) return; if (automapping) show2dsector[sectnum>>3] |= pow2char[sectnum&7]; @@ -3719,11 +3818,11 @@ static void polymost_scansector (long sectnum) if ((z == startwall) || (wall[z-1].point2 != z)) { - xp1 = ((double)y1*(double)cosglobalang - (double)x1*(double)singlobalang )/64.0; + xp1 = ((double)y1*(double)cosglobalang - (double)x1*(double)singlobalang)/64.0; yp1 = ((double)x1*(double)cosviewingrangeglobalang + (double)y1*(double)sinviewingrangeglobalang)/64.0; } else { xp1 = xp2; yp1 = yp2; } - xp2 = ((double)y2*(double)cosglobalang - (double)x2*(double)singlobalang )/64.0; + xp2 = ((double)y2*(double)cosglobalang - (double)x2*(double)singlobalang)/64.0; yp2 = ((double)x2*(double)cosviewingrangeglobalang + (double)y2*(double)sinviewingrangeglobalang)/64.0; if ((yp1 >= SCISDIST) || (yp2 >= SCISDIST)) if ((double)xp1*(double)yp2 < (double)xp2*(double)yp1) //if wall is facing you... @@ -3737,28 +3836,29 @@ static void polymost_scansector (long sectnum) else dxb2[numscans] = 1e32; if (dxb1[numscans] < dxb2[numscans]) - { thesector[numscans] = sectnum; thewall[numscans] = z; p2[numscans] = numscans+1; numscans++; } + { thesector[numscans] = sectnum; thewall[numscans] = z; p2[numscans] = numscans+1; numscans++; } } if ((wall[z].point2 < z) && (scanfirst < numscans)) - { p2[numscans-1] = scanfirst; scanfirst = numscans; } + { p2[numscans-1] = scanfirst; scanfirst = numscans; } } for (z=numscansbefore;z dxb1[p2[z]])) - { bunchfirst[numbunches++] = p2[z]; p2[z] = -1; } + { bunchfirst[numbunches++] = p2[z]; p2[z] = -1; } for (z=bunchfrst;z=0;zz=p2[zz]); bunchlast[z] = zz; } - } while (sectorbordercnt > 0); + } + while (sectorbordercnt > 0); } -void polymost_drawrooms () +void polymost_drawrooms() { - long i, j, k, n, n2, closest; + int i, j, k, n, n2, closest; double ox, oy, oz, ox2, oy2, oz2, r, px[6], py[6], pz[6], px2[6], py2[6], pz2[6], sx[6], sy[6]; if (!rendmode) return; @@ -3836,7 +3936,7 @@ void polymost_drawrooms () gctang = cos(gtang); gstang = sin(gtang); if (fabs(gstang) < .001) //This hack avoids nasty precision bugs in domost() - { gstang = 0; if (gctang > 0) gctang = 1.0; else gctang = -1.0; } + { gstang = 0; if (gctang > 0) gctang = 1.0; else gctang = -1.0; } if (inpreparemirror) gstang = -gstang; @@ -3864,7 +3964,7 @@ void polymost_drawrooms () for (i=0;i= n) j = 0; - if (pz[i] >= SCISDIST) { px2[n2] = px[i]; py2[n2] = py[i]; pz2[n2] = pz[i]; n2++; } + if (pz[i] >= SCISDIST) { px2[n2] = px[i]; py2[n2] = py[i]; pz2[n2] = pz[i]; n2++; } if ((pz[i] >= SCISDIST) != (pz[j] >= SCISDIST)) { r = (SCISDIST-pz[i])/(pz[j]-pz[i]); @@ -3885,7 +3985,7 @@ void polymost_drawrooms () if (searchit == 2) { short hitsect, hitwall, hitsprite; - long vx, vy, vz, hitx, hity, hitz; + int vx, vy, vz, hitx, hity, hitz; ox2 = (searchx-ghalfx)/1.2; oy2 = (searchy-ghoriz)/ 1.2; oz2 = ghalfx; @@ -3900,9 +4000,9 @@ void polymost_drawrooms () oz2 = oy*gchang + oz*gshang; //Standard Left/right rotation - vx = (long)(ox2*((float)cosglobalang) - oy2*((float)singlobalang)); - vy = (long)(ox2*((float)singlobalang) + oy2*((float)cosglobalang)); - vz = (long)(oz2*16384.0); + vx = (int)(ox2*((float)cosglobalang) - oy2*((float)singlobalang)); + vy = (int)(ox2*((float)singlobalang) + oy2*((float)cosglobalang)); + vz = (int)(oz2*16384.0); hitallsprites = 1; hitscan(globalposx,globalposy,globalposz,globalcursectnum, //Start position @@ -3915,7 +4015,7 @@ void polymost_drawrooms () searchwall = hitwall; searchstat = 0; if (wall[hitwall].nextwall >= 0) { - long cz, fz; + int cz, fz; getzsofslope(wall[hitwall].nextsector,hitx,hity,&cz,&fz); if (hitz > fz) { @@ -3926,10 +4026,10 @@ void polymost_drawrooms () searchstat = 4; } } - else if (hitsprite >= 0) { searchwall = hitsprite; searchstat = 3; } + else if (hitsprite >= 0) { searchwall = hitsprite; searchstat = 3; } else { - long cz, fz; + int cz, fz; getzsofslope(hitsect,hitx,hity,&cz,&fz); if ((hitz<<1) < cz+fz) searchstat = 1; else searchstat = 2; //if (vz < 0) searchstat = 1; else searchstat = 2; //Won't work for slopes :/ @@ -3971,14 +4071,14 @@ void polymost_drawrooms () { j = polymost_bunchfront(i,closest); if (j < 0) continue; tempbuf[i] = 1; - if (!j) { tempbuf[closest] = 1; closest = i; } + if (!j) { tempbuf[closest] = 1; closest = i; } } for (i=0;iceilingz,sec->ceilingz); z2 = min(nsec->floorz,sec->floorz); - globalpicnum = wal->overpicnum; if ((unsigned long)globalpicnum >= MAXTILES) globalpicnum = 0; + globalpicnum = wal->overpicnum; if ((unsigned int)globalpicnum >= MAXTILES) globalpicnum = 0; if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,(short)thewall[z]+16384); - globalshade = (long)wal->shade; - globalpal = (long)((unsigned char)wal->pal); - globalorientation = (long)wal->cstat; + globalshade = (int)wal->shade; + globalpal = (int)((unsigned char)wal->pal); + globalorientation = (int)wal->cstat; #ifdef USE_OPENGL if (r_depthpeeling) @@ -4042,15 +4142,15 @@ void polymost_drawmaskwall (long damaskwallcnt) //Clip to close parallel-screen plane oxp0 = xp0; oyp0 = yp0; -if (yp0 < SCISDIST) { t0 = (SCISDIST-yp0)/(yp1-yp0); xp0 = (xp1-xp0)*t0+xp0; yp0 = SCISDIST; } + if (yp0 < SCISDIST) { t0 = (SCISDIST-yp0)/(yp1-yp0); xp0 = (xp1-xp0)*t0+xp0; yp0 = SCISDIST; } else t0 = 0.f; -if (yp1 < SCISDIST) { t1 = (SCISDIST-oyp0)/(yp1-oyp0); xp1 = (xp1-oxp0)*t1+oxp0; yp1 = SCISDIST; } + if (yp1 < SCISDIST) { t1 = (SCISDIST-oyp0)/(yp1-oyp0); xp1 = (xp1-oxp0)*t1+oxp0; yp1 = SCISDIST; } else { t1 = 1.f; } - getzsofslope(sectnum,(long)((wal2->x-wal->x)*t0+wal->x),(long)((wal2->y-wal->y)*t0+wal->y),&cz[0],&fz[0]); - getzsofslope(wal->nextsector,(long)((wal2->x-wal->x)*t0+wal->x),(long)((wal2->y-wal->y)*t0+wal->y),&cz[1],&fz[1]); - getzsofslope(sectnum,(long)((wal2->x-wal->x)*t1+wal->x),(long)((wal2->y-wal->y)*t1+wal->y),&cz[2],&fz[2]); - getzsofslope(wal->nextsector,(long)((wal2->x-wal->x)*t1+wal->x),(long)((wal2->y-wal->y)*t1+wal->y),&cz[3],&fz[3]); + getzsofslope(sectnum,(int)((wal2->x-wal->x)*t0+wal->x),(int)((wal2->y-wal->y)*t0+wal->y),&cz[0],&fz[0]); + getzsofslope(wal->nextsector,(int)((wal2->x-wal->x)*t0+wal->x),(int)((wal2->y-wal->y)*t0+wal->y),&cz[1],&fz[1]); + getzsofslope(sectnum,(int)((wal2->x-wal->x)*t1+wal->x),(int)((wal2->y-wal->y)*t1+wal->y),&cz[2],&fz[2]); + getzsofslope(wal->nextsector,(int)((wal2->x-wal->x)*t1+wal->x),(int)((wal2->y-wal->y)*t1+wal->y),&cz[3],&fz[3]); ryp0 = 1.f/yp0; ryp1 = 1.f/yp1; @@ -4097,11 +4197,13 @@ if (yp1 < SCISDIST) { t1 = (SCISDIST-oyp0)/(yp1-oyp0); xp1 = (xp1-oxp0)*t1+oxp0; if (wal->cstat&128) { if (!(wal->cstat&512)) method = 2; else method = 3; } #ifdef USE_OPENGL - if (!nofog) { - if (rendmode >= 3) { + if (!nofog) + { + if (rendmode >= 3) + { fogcalc(wal->shade,sec->visibility,sec->floorpal); bglFogf(GL_FOG_DENSITY,fogresult); - bglFogfv(GL_FOG_COLOR,fogcol); + bglFogfv(GL_FOG_COLOR,fogcol); } } #endif @@ -4141,7 +4243,7 @@ if (yp1 < SCISDIST) { t1 = (SCISDIST-oyp0)/(yp1-oyp0); xp1 = (xp1-oxp0)*t1+oxp0; j = i+1; if (j >= n) j = 0; t0 = t1; t1 = -((dpx[j]-x0)*(csy[2]-csy[0]) - (dpy[j]-csy[0])*(x1-x0)); - if (t0 >= 0) { dpx2[n2] = dpx[i]; dpy2[n2] = dpy[i]; n2++; } + if (t0 >= 0) { dpx2[n2] = dpx[i]; dpy2[n2] = dpy[i]; n2++; } if ((t0 >= 0) != (t1 >= 0)) { r = t0/(t0-t1); @@ -4159,7 +4261,7 @@ if (yp1 < SCISDIST) { t1 = (SCISDIST-oyp0)/(yp1-oyp0); xp1 = (xp1-oxp0)*t1+oxp0; j = i+1; if (j >= n2) j = 0; t0 = t1; t1 = -((dpx2[j]-x1)*(fsy[0]-fsy[2]) - (dpy2[j]-fsy[2])*(x0-x1)); - if (t0 >= 0) { dpx[n] = dpx2[i]; dpy[n] = dpy2[i]; n++; } + if (t0 >= 0) { dpx[n] = dpx2[i]; dpy[n] = dpy2[i]; n++; } if ((t0 >= 0) != (t1 >= 0)) { r = t0/(t0-t1); @@ -4173,12 +4275,12 @@ if (yp1 < SCISDIST) { t1 = (SCISDIST-oyp0)/(yp1-oyp0); xp1 = (xp1-oxp0)*t1+oxp0; drawpoly(dpx,dpy,n,method); } -void polymost_drawsprite (long snum) +void polymost_drawsprite(int snum) { double px[6], py[6]; float f, r, c, s, fx, fy, sx0, sy0, sx1, sy1, xp0, yp0, xp1, yp1, oxp0, oyp0, ryp0, ryp1, ft[4]; float x0, y0, x1, y1, sc0, sf0, sc1, sf1, px2[6], py2[6], xv, yv, t0, t1; - long i, j, spritenum, xoff=0, yoff=0, method, npoints; + int i, j, spritenum, xoff=0, yoff=0, method, npoints; spritetype *tspr; tspr = tspriteptr[snum]; @@ -4190,15 +4292,16 @@ void polymost_drawsprite (long snum) globalorientation = tspr->cstat; spritenum = tspr->owner; - if ((globalorientation&48) != 48) { // only non-voxel sprites should do this + if ((globalorientation&48) != 48) // only non-voxel sprites should do this + { if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,spritenum+32768); - xoff = (long)((signed char)((picanm[globalpicnum]>>8)&255))+((long)tspr->xoffset); - yoff = (long)((signed char)((picanm[globalpicnum]>>16)&255))+((long)tspr->yoffset); + xoff = (int)((signed char)((picanm[globalpicnum]>>8)&255))+((int)tspr->xoffset); + yoff = (int)((signed char)((picanm[globalpicnum]>>16)&255))+((int)tspr->yoffset); } method = 1+4; -if (tspr->cstat&2) { if (!(tspr->cstat&512)) method = 2+4; else method = 3+4; } + if (tspr->cstat&2) { if (!(tspr->cstat&512)) method = 2+4; else method = 3+4; } #ifdef USE_OPENGL @@ -4209,33 +4312,38 @@ if (tspr->cstat&2) { if (!(tspr->cstat&512)) method = 2+4; else method = 3+4; } if (!(((tspr->cstat&2) || (gltexmayhavealpha(globalpicnum,tspr->pal)))) && peelcompiling) return; // discard opaque sprite when composing the depth peels } - if (!nofog && rendmode >= 3) { + if (!nofog && rendmode >= 3) + { fogcalc(globalshade,sector[tspr->sectnum].visibility,sector[tspr->sectnum].floorpal); bglFogf(GL_FOG_DENSITY,fogresult); - bglFogfv(GL_FOG_COLOR,fogcol); + bglFogfv(GL_FOG_COLOR,fogcol); } - while (rendmode >= 3 && !(spriteext[tspr->owner].flags&SPREXT_NOTMD)) { - if (usemodels && tile2model[tspr->picnum].modelid >= 0 && tile2model[tspr->picnum].framenum >= 0) { + while (rendmode >= 3 && !(spriteext[tspr->owner].flags&SPREXT_NOTMD)) + { + if (usemodels && tile2model[tspr->picnum].modelid >= 0 && tile2model[tspr->picnum].framenum >= 0) + { if (mddraw(tspr)) return; break; // else, render as flat sprite } - if (usevoxels && (tspr->cstat&48)!=48 && tiletovox[tspr->picnum] >= 0 && voxmodels[ tiletovox[tspr->picnum] ]) { + if (usevoxels && (tspr->cstat&48)!=48 && tiletovox[tspr->picnum] >= 0 && voxmodels[ tiletovox[tspr->picnum] ]) + { if (voxdraw(voxmodels[ tiletovox[tspr->picnum] ], tspr)) return; break; // else, render as flat sprite } - if ((tspr->cstat&48)==48 && voxmodels[ tspr->picnum ]) { + if ((tspr->cstat&48)==48 && voxmodels[ tspr->picnum ]) + { voxdraw(voxmodels[ tspr->picnum ], tspr); return; } break; } if (((tspr->cstat&2) || (gltexmayhavealpha(tspr->picnum,tspr->pal)))) - { - curpolygonoffset += 0.01f; - bglEnable(GL_POLYGON_OFFSET_FILL); - bglPolygonOffset(-curpolygonoffset, -curpolygonoffset); - } + { + curpolygonoffset += 0.01f; + bglEnable(GL_POLYGON_OFFSET_FILL); + bglPolygonOffset(-curpolygonoffset, -curpolygonoffset); + } #endif switch ((globalorientation>>4)&3) @@ -4260,15 +4368,15 @@ if (tspr->cstat&2) { if (!(tspr->cstat&512)) method = 2+4; else method = 3+4; } fy *= ((float)tilesizy[globalpicnum]); px[0] = px[3] = sx0-fx*.5; px[1] = px[2] = sx0+fx*.5; - if (!(globalorientation&128)) { py[0] = py[1] = sy0-fy; py[2] = py[3] = sy0; } + if (!(globalorientation&128)) { py[0] = py[1] = sy0-fy; py[2] = py[3] = sy0; } else { py[0] = py[1] = sy0-fy*.5; py[2] = py[3] = sy0+fy*.5; } gdx = gdy = guy = gvx = 0; gdo = ryp0*gviewxrange; if (!(globalorientation&4)) - { gux = (float)tilesizx[globalpicnum]*gdo/(px[1]-px[0]+.002); guo = -gux*(px[0]-.001); } + { gux = (float)tilesizx[globalpicnum]*gdo/(px[1]-px[0]+.002); guo = -gux*(px[0]-.001); } else { gux = (float)tilesizx[globalpicnum]*gdo/(px[0]-px[1]-.002); guo = -gux*(px[1]+.001); } if (!(globalorientation&8)) - { gvy = (float)tilesizy[globalpicnum]*gdo/(py[3]-py[0]+.002); gvo = -gvy*(py[0]-.001); } + { gvy = (float)tilesizy[globalpicnum]*gdo/(py[3]-py[0]+.002); gvo = -gvy*(py[0]-.001); } else { gvy = (float)tilesizy[globalpicnum]*gdo/(py[0]-py[3]-.002); gvo = -gvy*(py[3]+.001); } //Clip sprites to ceilings/floors when no parallaxing and not sloped @@ -4291,7 +4399,7 @@ if (tspr->cstat&2) { if (!(tspr->cstat&512)) method = 2+4; else method = 3+4; } if (globalorientation&4) xoff = -xoff; if (globalorientation&8) yoff = -yoff; - xv = (float)tspr->xrepeat * (float)sintable[(tspr->ang )&2047] / 65536.0; + xv = (float)tspr->xrepeat * (float)sintable[(tspr->ang)&2047] / 65536.0; yv = (float)tspr->xrepeat * (float)sintable[(tspr->ang+1536)&2047] / 65536.0; f = (float)(tilesizx[globalpicnum]>>1) + (float)xoff; x0 = (float)(tspr->x-globalposx) - xv*f; x1 = xv*(float)tilesizx[globalpicnum] + x0; @@ -4305,7 +4413,7 @@ if (tspr->cstat&2) { if (!(tspr->cstat&512)) method = 2+4; else method = 3+4; } //Clip to close parallel-screen plane oxp0 = xp0; oyp0 = yp0; - if (yp0 < SCISDIST) { t0 = (SCISDIST-yp0)/(yp1-yp0); xp0 = (xp1-xp0)*t0+xp0; yp0 = SCISDIST; } + if (yp0 < SCISDIST) { t0 = (SCISDIST-yp0)/(yp1-yp0); xp0 = (xp1-xp0)*t0+xp0; yp0 = SCISDIST; } else { t0 = 0.f; } if (yp1 < SCISDIST) { t1 = (SCISDIST-oyp0)/(yp1-oyp0); xp1 = (xp1-oxp0)*t1+oxp0; yp1 = SCISDIST; } else { t1 = 1.f; } @@ -4346,7 +4454,7 @@ if (tspr->cstat&2) { if (!(tspr->cstat&512)) method = 2+4; else method = 3+4; } //gux*sx0 + guo = t0*tilesizx[globalpicnum]*yp0 //gux*sx1 + guo = t1*tilesizx[globalpicnum]*yp1 - if (globalorientation&4) { t0 = 1.f-t0; t1 = 1.f-t1; } + if (globalorientation&4) { t0 = 1.f-t0; t1 = 1.f-t1; } gux = (t0*ryp0 - t1*ryp1)*gxyaspect*(float)tilesizx[globalpicnum] / (sx0-sx1); guy = 0; guo = t0*ryp0*gxyaspect*(float)tilesizx[globalpicnum] - gux*sx0; @@ -4422,8 +4530,10 @@ if (tspr->cstat&2) { if (!(tspr->cstat&512)) method = 2+4; else method = 3+4; } { sx0 = (float)(tspr->x-globalposx); sy0 = (float)(tspr->y-globalposy); - if ((j+0)&2) { sy0 -= s*y0; sx0 -= c*y0; } else { sy0 += s*y1; sx0 += c*y1; } - if ((j+1)&2) { sx0 -= s*x0; sy0 += c*x0; } else { sx0 += s*x1; sy0 -= c*x1; } + if ((j+0)&2) { sy0 -= s*y0; sx0 -= c*y0; } + else { sy0 += s*y1; sx0 += c*y1; } + if ((j+1)&2) { sx0 -= s*x0; sy0 += c*x0; } + else { sx0 += s*x1; sy0 -= c*x1; } px[j] = sy0*gcosang - sx0*gsinang; py[j] = sx0*gcosang2 + sy0*gsinang2; } @@ -4507,12 +4617,12 @@ if (tspr->cstat&2) { if (!(tspr->cstat&512)) method = 2+4; else method = 3+4; } //dastat&64 1:non-masked, 0:masked //dastat&128 1:draw all pages (permanent) //cx1,... clip window (actual screen coords) -void polymost_dorotatesprite (long sx, long sy, long z, short a, short picnum, - signed char dashade, char dapalnum, char dastat, long cx1, long cy1, long cx2, long cy2, long uniqid) +void polymost_dorotatesprite(int sx, int sy, int z, short a, short picnum, + signed char dashade, char dapalnum, char dastat, int cx1, int cy1, int cx2, int cy2, int uniqid) { - static long onumframes = 0; - long i, n, nn, x, zz, xoff, yoff, xsiz, ysiz, method; - long ogpicnum, ogshade, ogpal, ofoffset, oxdimen, oydimen, oldviewingrange; + static int onumframes = 0; + int i, n, nn, x, zz, xoff, yoff, xsiz, ysiz, method; + int ogpicnum, ogshade, ogpal, ofoffset, oxdimen, oydimen, oldviewingrange; double ogxyaspect; double ogchang, ogshang, ogctang, ogstang, oghalfx, oghoriz, fx, fy, x1, y1, z1, x2, y2; double ogrhalfxdown10, ogrhalfxdown10x; @@ -4535,7 +4645,7 @@ void polymost_dorotatesprite (long sx, long sy, long z, short a, short picnum, ogctang = gctang; gctang = (double)sintable[(a+512)&2047]*d; ogstang = gstang; gstang = (double)sintable[a&2047]*d; ogshade = globalshade; globalshade = dashade; - ogpal = globalpal; globalpal = (long)((unsigned char)dapalnum); + ogpal = globalpal; globalpal = (int)((unsigned char)dapalnum); ogxyaspect = gxyaspect; gxyaspect = 1.0; oldviewingrange = viewingrange; viewingrange = 65536; @@ -4550,14 +4660,14 @@ void polymost_dorotatesprite (long sx, long sy, long z, short a, short picnum, if (dastat&16) { xsiz = tilesizx[picnum]; ysiz = tilesizy[picnum]; - xoff = (long)((signed char)((picanm[picnum]>>8)&255))+(xsiz>>1); - yoff = (long)((signed char)((picanm[picnum]>>16)&255))+(ysiz>>1); + xoff = (int)((signed char)((picanm[picnum]>>8)&255))+(xsiz>>1); + yoff = (int)((signed char)((picanm[picnum]>>16)&255))+(ysiz>>1); d = (double)z/(65536.0*16384.0); cosang2 = cosang = (double)sintable[(a+512)&2047]*d; sinang2 = sinang = (double)sintable[a&2047]*d; if ((dastat&2) || (!(dastat&8))) //Don't aspect unscaled perms - { d = (double)xyaspect/65536.0; cosang2 *= d; sinang2 *= d; } + { d = (double)xyaspect/65536.0; cosang2 *= d; sinang2 *= d; } fx += -(double)xoff*cosang2+ (double)yoff*sinang2; fy += -(double)xoff*sinang - (double)yoff*cosang; } @@ -4577,9 +4687,9 @@ void polymost_dorotatesprite (long sx, long sy, long z, short a, short picnum, tspr.xrepeat = tspr.yrepeat = 32; if (dastat&4) { x1 = -x1; y1 = -y1; } - tspr.x = (long)(((double)gcosang*z1 - (double)gsinang*x1)*16384.0 + globalposx); - tspr.y = (long)(((double)gsinang*z1 + (double)gcosang*x1)*16384.0 + globalposy); - tspr.z = (long)(globalposz + y1*16384.0*0.8); + tspr.x = (int)(((double)gcosang*z1 - (double)gsinang*x1)*16384.0 + globalposx); + tspr.y = (int)(((double)gsinang*z1 + (double)gcosang*x1)*16384.0 + globalposy); + tspr.z = (int)(globalposz + y1*16384.0*0.8); tspr.picnum = picnum; tspr.shade = dashade; tspr.pal = dapalnum; @@ -4626,8 +4736,8 @@ void polymost_dorotatesprite (long sx, long sy, long z, short a, short picnum, { i = klabs(tspr.shade); bglFogf(GL_FOG_DENSITY,fogcalc(tspr.shade,sector[tspr.sectnum].visibility); - } - mddraw(&tspr); + } + mddraw(&tspr); #else if (!nofog) bglDisable(GL_FOG); mddraw(&tspr); @@ -4648,7 +4758,7 @@ void polymost_dorotatesprite (long sx, long sy, long z, short a, short picnum, ogpicnum = globalpicnum; globalpicnum = picnum; ogshade = globalshade; globalshade = dashade; - ogpal = globalpal; globalpal = (long)((unsigned char)dapalnum); + ogpal = globalpal; globalpal = (int)((unsigned char)dapalnum); oghalfx = ghalfx; ghalfx = (double)(xdim>>1); ogrhalfxdown10 = grhalfxdown10; grhalfxdown10 = 1.0/(((double)ghalfx)*1024); ogrhalfxdown10x = grhalfxdown10x; grhalfxdown10x = grhalfxdown10; @@ -4687,11 +4797,11 @@ void polymost_dorotatesprite (long sx, long sy, long z, short a, short picnum, method |= 4; //Use OpenGL clamping - dorotatesprite never repeats xsiz = tilesizx[globalpicnum]; ysiz = tilesizy[globalpicnum]; -if (dastat&16) { xoff = 0; yoff = 0; } + if (dastat&16) { xoff = 0; yoff = 0; } else { - xoff = (long)((signed char)((picanm[globalpicnum]>>8)&255))+(xsiz>>1); - yoff = (long)((signed char)((picanm[globalpicnum]>>16)&255))+(ysiz>>1); + xoff = (int)((signed char)((picanm[globalpicnum]>>8)&255))+(xsiz>>1); + yoff = (int)((signed char)((picanm[globalpicnum]>>16)&255))+(ysiz>>1); } if (dastat&4) yoff = ysiz-yoff; @@ -4718,7 +4828,7 @@ if (dastat&16) { xoff = 0; yoff = 0; } cosang2 = cosang = (double)sintable[(a+512)&2047]*d; sinang2 = sinang = (double)sintable[a&2047]*d; if ((dastat&2) || (!(dastat&8))) //Don't aspect unscaled perms - { d = (double)xyaspect/65536.0; cosang2 *= d; sinang2 *= d; } + { d = (double)xyaspect/65536.0; cosang2 *= d; sinang2 *= d; } px[0] = (double)sx/65536.0 - (double)xoff*cosang2+ (double)yoff*sinang2; py[0] = (double)sy/65536.0 - (double)xoff*sinang - (double)yoff*cosang; px[1] = px[0] + (double)xsiz*cosang2; @@ -4739,7 +4849,8 @@ if (dastat&16) { xoff = 0; yoff = 0; } guo = 0 - px[0]*gux - py[0]*guy; if (!(dastat&4)) - { //px[0]*gvx + py[0]*gvy + gvo = 0 + { + //px[0]*gvx + py[0]*gvy + gvo = 0 //px[1]*gvx + py[1]*gvy + gvo = 0 //px[3]*gvx + py[3]*gvy + gvo = ysiz-.0001 gvx = (py[0]-py[1])*((double)ysiz-.0001)*d; @@ -4747,7 +4858,8 @@ if (dastat&16) { xoff = 0; yoff = 0; } gvo = 0 - px[0]*gvx - py[0]*gvy; } else - { //px[0]*gvx + py[0]*gvy + gvo = ysiz-.0001 + { + //px[0]*gvx + py[0]*gvy + gvo = ysiz-.0001 //px[1]*gvx + py[1]*gvy + gvo = ysiz-.0001 //px[3]*gvx + py[3]*gvy + gvo = 0 gvx = (py[1]-py[0])*((double)ysiz-.0001)*d; @@ -4756,38 +4868,41 @@ if (dastat&16) { xoff = 0; yoff = 0; } } cx2++; cy2++; - //Clippoly4 (converted from long to double) + //Clippoly4 (converted from int to double) nn = z = 0; do { zz = z+1; if (zz == n) zz = 0; - x1 = px[z]; x2 = px[zz]-x1; if ((cx1 <= x1) && (x1 <= cx2)) { px2[nn] = x1; py2[nn] = py[z]; nn++; } + x1 = px[z]; x2 = px[zz]-x1; if ((cx1 <= x1) && (x1 <= cx2)) { px2[nn] = x1; py2[nn] = py[z]; nn++; } if (x2 <= 0) fx = cx2; else fx = cx1; d = fx-x1; - if ((d < x2) != (d < 0)) { px2[nn] = fx; py2[nn] = (py[zz]-py[z])*d/x2 + py[z]; nn++; } + if ((d < x2) != (d < 0)) { px2[nn] = fx; py2[nn] = (py[zz]-py[z])*d/x2 + py[z]; nn++; } if (x2 <= 0) fx = cx1; else fx = cx2; d = fx-x1; - if ((d < x2) != (d < 0)) { px2[nn] = fx; py2[nn] = (py[zz]-py[z])*d/x2 + py[z]; nn++; } + if ((d < x2) != (d < 0)) { px2[nn] = fx; py2[nn] = (py[zz]-py[z])*d/x2 + py[z]; nn++; } z = zz; - } while (z); + } + while (z); if (nn >= 3) { n = z = 0; do { zz = z+1; if (zz == nn) zz = 0; - y1 = py2[z]; y2 = py2[zz]-y1; if ((cy1 <= y1) && (y1 <= cy2)) { py[n] = y1; px[n] = px2[z]; n++; } + y1 = py2[z]; y2 = py2[zz]-y1; if ((cy1 <= y1) && (y1 <= cy2)) { py[n] = y1; px[n] = px2[z]; n++; } if (y2 <= 0) fy = cy2; else fy = cy1; d = fy-y1; - if ((d < y2) != (d < 0)) { py[n] = fy; px[n] = (px2[zz]-px2[z])*d/y2 + px2[z]; n++; } + if ((d < y2) != (d < 0)) { py[n] = fy; px[n] = (px2[zz]-px2[z])*d/y2 + px2[z]; n++; } if (y2 <= 0) fy = cy1; else fy = cy2; d = fy-y1; - if ((d < y2) != (d < 0)) { py[n] = fy; px[n] = (px2[zz]-px2[z])*d/y2 + px2[z]; n++; } + if ((d < y2) != (d < 0)) { py[n] = fy; px[n] = (px2[zz]-px2[z])*d/y2 + px2[z]; n++; } z = zz; - } while (z); + } + while (z); if (!nofog) bglDisable(GL_FOG); pow2xsplit = 0; drawpoly(px,py,n,method); if (!nofog) bglEnable(GL_FOG); } #ifdef USE_OPENGL - if (rendmode >= 3) { + if (rendmode >= 3) + { bglMatrixMode(GL_PROJECTION); bglPopMatrix(); } #endif @@ -4810,14 +4925,14 @@ if (dastat&16) { xoff = 0; yoff = 0; } #ifdef USE_OPENGL static float trapextx[2]; -static void drawtrap (float x0, float x1, float y0, float x2, float x3, float y1) +static void drawtrap(float x0, float x1, float y0, float x2, float x3, float y1) { float px[4], py[4]; - long i, n; + int i, n; if (y0 == y1) return; px[0] = x0; py[0] = y0; py[2] = y1; -if (x0 == x1) { px[1] = x3; py[1] = y1; px[2] = x2; n = 3; } + if (x0 == x1) { px[1] = x3; py[1] = y1; px[2] = x2; n = 3; } else if (x2 == x3) { px[1] = x1; py[1] = y0; px[2] = x3; n = 3; } else { px[1] = x1; py[1] = y0; px[2] = x3; px[3] = x2; py[3] = y1; n = 4; } @@ -4832,20 +4947,20 @@ if (x0 == x1) { px[1] = x3; py[1] = y1; px[2] = x2; n = 3; } bglEnd(); } -static void tessectrap (float *px, float *py, long *point2, long numpoints) +static void tessectrap(float *px, float *py, int *point2, int numpoints) { float x0, x1, m0, m1; - long i, j, k, z, i0, i1, i2, i3, npoints, gap, numrst; + int i, j, k, z, i0, i1, i2, i3, npoints, gap, numrst; - static long allocpoints = 0, *slist = 0, *npoint2 = 0; - typedef struct { float x, y, xi; long i; } raster; + static int allocpoints = 0, *slist = 0, *npoint2 = 0; + typedef struct { float x, y, xi; int i; } raster; static raster *rst = 0; if (numpoints+16 > allocpoints) //16 for safety { allocpoints = numpoints+16; rst = (raster*)realloc(rst,allocpoints*sizeof(raster)); - slist = (long*)realloc(slist,allocpoints*sizeof(long)); - npoint2 = (long*)realloc(npoint2,allocpoints*sizeof(long)); + slist = (int*)realloc(slist,allocpoints*sizeof(int)); + npoint2 = (int*)realloc(npoint2,allocpoints*sizeof(int)); } //Remove unnecessary collinear points: @@ -4858,7 +4973,7 @@ static void tessectrap (float *px, float *py, long *point2, long numpoints) k = npoint2[j]; m0 = (px[j]-px[i])*(py[k]-py[j]); m1 = (py[j]-py[i])*(px[k]-px[j]); - if (m0 < m1) { z |= 1; continue; } + if (m0 < m1) { z |= 1; continue; } if (m0 > m1) { z |= 2; continue; } npoint2[i] = k; npoint2[j] = -1; npoints--; i--; //collinear } @@ -4899,7 +5014,7 @@ static void tessectrap (float *px, float *py, long *point2, long numpoints) { i0 = slist[z]; i1 = npoint2[i0]; if (py[i0] == py[i1]) continue; i2 = i1; i3 = npoint2[i1]; - if (py[i1] == py[i3]) { i2 = i3; i3 = npoint2[i3]; } + if (py[i1] == py[i3]) { i2 = i3; i3 = npoint2[i3]; } //i0 i3 // \ / @@ -4935,9 +5050,10 @@ static void tessectrap (float *px, float *py, long *point2, long numpoints) rst[k].i = i3; rst[k].xi = m1; rst[k].x = px[i2]; rst[k].y = py[i2]; } else - { //NOTE:don't count backwards! + { + //NOTE:don't count backwards! if (i1 == i2) { for (i=0;i py[i0]) && (py[i2] > py[i3])) //Delete raster @@ -4968,11 +5084,11 @@ static void tessectrap (float *px, float *py, long *point2, long numpoints) } } -void polymost_fillpolygon (long npoints) +void polymost_fillpolygon(int npoints) { pthtyp *pth; float f,a=0.0; - long i, j, k; + int i, j, k; globalx1 = mulscale16(globalx1,xyaspect); globaly2 = mulscale16(globaly2,xyaspect); @@ -4983,7 +5099,7 @@ void polymost_fillpolygon (long npoints) guo = (((double)xdim)*gux + ((double)ydim)*guy)*-.5 + ((double)globalposx)*(1.0/4294967296.0); gvo = (((double)xdim)*gvx + ((double)ydim)*gvy)*-.5 - ((double)globalposy)*(1.0/4294967296.0); - //Convert long to float (in-place) + //Convert int to float (in-place) for (i=npoints-1;i>=0;i--) { ((float *)rx1)[i] = ((float)rx1[i])/4096.0; @@ -4997,7 +5113,8 @@ void polymost_fillpolygon (long npoints) bglBindTexture(GL_TEXTURE_2D, pth ? pth->glpic : 0); f = ((float)(numpalookups-min(max(globalshade * shadescale,0),numpalookups)))/((float)numpalookups); - switch ((globalorientation>>7)&3) { + switch ((globalorientation>>7)&3) + { case 0: case 1: a = 1.0; bglDisable(GL_BLEND); break; @@ -5012,19 +5129,22 @@ void polymost_fillpolygon (long npoints) } #endif -long polymost_drawtilescreen (long tilex, long tiley, long wallnum, long dimen, int tilezoom) +int polymost_drawtilescreen(int tilex, int tiley, int wallnum, int dimen, int tilezoom) { #ifdef USE_OPENGL float xdime, ydime, xdimepad, ydimepad, scx, scy, ratio = 1.0; - long i; + int i; pthtyp *pth; if ((rendmode < 3) || (qsetmode != 200)) return(-1); - if (!glinfo.texnpot) { + if (!glinfo.texnpot) + { i = (1<<(picsiz[wallnum]&15)); if (i < tilesizx[wallnum]) i += i; xdimepad = (float)i; i = (1<<(picsiz[wallnum]>>4)); if (i < tilesizy[wallnum]) i += i; ydimepad = (float)i; - } else { + } + else + { xdimepad = (float)tilesizx[wallnum]; ydimepad = (float)tilesizy[wallnum]; } @@ -5054,7 +5174,8 @@ long polymost_drawtilescreen (long tilex, long tiley, long wallnum, long dimen, else ratio = dimen/scy; } - if (!pth || (pth->flags & 8)) { + if (!pth || (pth->flags & 8)) + { bglDisable(GL_TEXTURE_2D); bglBegin(GL_TRIANGLE_FAN); if (gammabrightness) @@ -5067,8 +5188,8 @@ long polymost_drawtilescreen (long tilex, long tiley, long wallnum, long dimen, (float)britable[curbrightness][ curpalette[255].g ] / 255.0, (float)britable[curbrightness][ curpalette[255].b ] / 255.0, 1); - bglVertex2f((float)tilex ,(float)tiley ); - bglVertex2f((float)tilex+(scx*ratio),(float)tiley ); + bglVertex2f((float)tilex ,(float)tiley); + bglVertex2f((float)tilex+(scx*ratio),(float)tiley); bglVertex2f((float)tilex+(scx*ratio),(float)tiley+(scy*ratio)); bglVertex2f((float)tilex ,(float)tiley+(scy*ratio)); bglEnd(); @@ -5078,10 +5199,10 @@ long polymost_drawtilescreen (long tilex, long tiley, long wallnum, long dimen, bglEnable(GL_TEXTURE_2D); bglEnable(GL_BLEND); bglBegin(GL_TRIANGLE_FAN); - bglTexCoord2f( 0, 0); bglVertex2f((float)tilex ,(float)tiley ); - bglTexCoord2f(xdimepad, 0); bglVertex2f((float)tilex+(scx*ratio),(float)tiley ); + bglTexCoord2f(0, 0); bglVertex2f((float)tilex ,(float)tiley); + bglTexCoord2f(xdimepad, 0); bglVertex2f((float)tilex+(scx*ratio),(float)tiley); bglTexCoord2f(xdimepad,ydimepad); bglVertex2f((float)tilex+(scx*ratio),(float)tiley+(scy*ratio)); - bglTexCoord2f( 0,ydimepad); bglVertex2f((float)tilex ,(float)tiley+(scy*ratio)); + bglTexCoord2f(0,ydimepad); bglVertex2f((float)tilex ,(float)tiley+(scy*ratio)); bglEnd(); return(0); @@ -5090,7 +5211,7 @@ long polymost_drawtilescreen (long tilex, long tiley, long wallnum, long dimen, #endif } -long polymost_printext256(long xpos, long ypos, short col, short backcol, char *name, char fontsize) +int polymost_printext256(int xpos, int ypos, short col, short backcol, char *name, char fontsize) { #ifndef USE_OPENGL return -1; @@ -5099,10 +5220,13 @@ long polymost_printext256(long xpos, long ypos, short col, short backcol, char * int c; palette_t p,b; - if (gammabrightness) { + if (gammabrightness) + { p = curpalette[col]; b = curpalette[backcol]; - } else { + } + else + { p.r = britable[curbrightness][ curpalette[col].r ]; p.g = britable[curbrightness][ curpalette[col].g ]; p.b = britable[curbrightness][ curpalette[col].b ]; @@ -5113,7 +5237,8 @@ long polymost_printext256(long xpos, long ypos, short col, short backcol, char * if ((rendmode < 3) || (qsetmode != 200)) return(-1); - if (!polymosttext) { + if (!polymosttext) + { // construct a 256x128 8-bit alpha-only texture for the font glyph matrix unsigned char *tbuf, *cptr, *tptr; int h,i,j,l; @@ -5122,7 +5247,8 @@ long polymost_printext256(long xpos, long ypos, short col, short backcol, char * if (!polymosttext) return -1; tbuf = (unsigned char *)Bmalloc(256*128); - if (!tbuf) { + if (!tbuf) + { bglDeleteTextures(1,&polymosttext); polymosttext = 0; return -1; @@ -5130,10 +5256,13 @@ long polymost_printext256(long xpos, long ypos, short col, short backcol, char * Bmemset(tbuf, 0, 256*128); cptr = (unsigned char*)textfont; - for (h=0;h<256;h++) { + for (h=0;h<256;h++) + { tptr = tbuf + (h%32)*8 + (h/32)*256*8; - for (i=0;i<8;i++) { - for (j=0;j<8;j++) { + for (i=0;i<8;i++) + { + for (j=0;j<8;j++) + { if (cptr[h*8+i] & pow2char[7-j]) tptr[j] = 255; } tptr += 256; @@ -5141,10 +5270,13 @@ long polymost_printext256(long xpos, long ypos, short col, short backcol, char * } cptr = (unsigned char*)smalltextfont; - for (h=0;h<256;h++) { + for (h=0;h<256;h++) + { tptr = tbuf + 256*64 + (h%32)*8 + (h/32)*256*8; - for (i=1;i<7;i++) { - for (j=2;j<6;j++) { + for (i=1;i<7;i++) + { + for (j=2;j<6;j++) + { if (cptr[h*8+i] & pow2char[7-j]) tptr[j-2] = 255; } tptr += 256; @@ -5163,7 +5295,8 @@ long polymost_printext256(long xpos, long ypos, short col, short backcol, char * bglDisable(GL_ALPHA_TEST); bglDepthMask(GL_FALSE); // disable writing to the z-buffer - if (backcol >= 0) { + if (backcol >= 0) + { bglColor4ub(b.r,b.g,b.b,255); c = Bstrlen(name); @@ -5181,7 +5314,8 @@ long polymost_printext256(long xpos, long ypos, short col, short backcol, char * txc = fontsize ? (4.0/256.0) : (8.0/256.0); tyc = fontsize ? (6.0/128.0) : (8.0/128.0); bglBegin(GL_QUADS); - for (c=0; name[c]; c++) { + for (c=0; name[c]; c++) + { tx = (float)(name[c]%32)/32.0; ty = (float)((name[c]/32) + (fontsize*8))/16.0; @@ -5207,7 +5341,8 @@ static int gltexturemode(const osdfuncparm_t *parm) int m; const char *p; - if (parm->numparms != 1) { + if (parm->numparms != 1) + { OSD_Printf("Current texturing mode is %s\n", glfiltermodes[gltexfiltermode].name); OSD_Printf(" Vaild modes are:\n"); for (m = 0; m < (int)numglfiltermodes; m++) @@ -5217,48 +5352,55 @@ static int gltexturemode(const osdfuncparm_t *parm) } m = Bstrtoul(parm->parms[0], (char **)&p, 10); - if (p == parm->parms[0]) { + if (p == parm->parms[0]) + { // string - for (m = 0; m < (int)numglfiltermodes; m++) { + for (m = 0; m < (int)numglfiltermodes; m++) + { if (!Bstrcasecmp(parm->parms[0], glfiltermodes[m].name)) break; } if (m == numglfiltermodes) m = gltexfiltermode; // no change - } else { + } + else + { if (m < 0) m = 0; else if (m >= (int)numglfiltermodes) m = numglfiltermodes - 1; } - if (m != gltexfiltermode) { + if (m != gltexfiltermode) + { gltexfiltermode = m; gltexapplyprops(); } - OSD_Printf("Texture filtering mode changed to %s\n", glfiltermodes[gltexfiltermode].name ); + OSD_Printf("Texture filtering mode changed to %s\n", glfiltermodes[gltexfiltermode].name); return OSDCMD_OK; } static int gltextureanisotropy(const osdfuncparm_t *parm) { - long l; + int l; const char *p; - if (parm->numparms != 1) { + if (parm->numparms != 1) + { OSD_Printf("Current texture anisotropy is %d\n", glanisotropy); - OSD_Printf(" Maximum is %d\n", (long)glinfo.maxanisotropy); + OSD_Printf(" Maximum is %d\n", (int)glinfo.maxanisotropy); return OSDCMD_OK; } l = Bstrtoul(parm->parms[0], (char **)&p, 10); - if (l < 0 || l > (long)glinfo.maxanisotropy) l = 0; + if (l < 0 || l > (int)glinfo.maxanisotropy) l = 0; - if (l != gltexfiltermode) { + if (l != gltexfiltermode) + { glanisotropy = l; gltexapplyprops(); } - OSD_Printf("Texture anisotropy changed to %d\n", glanisotropy ); + OSD_Printf("Texture anisotropy changed to %d\n", glanisotropy); return OSDCMD_OK; } @@ -5269,40 +5411,48 @@ static int osdcmd_polymostvars(const osdfuncparm_t *parm) int showval = (parm->numparms < 1), val = 0; if (!showval) val = atoi(parm->parms[0]); - if (!Bstrcasecmp(parm->name, "usemodels")) { + if (!Bstrcasecmp(parm->name, "usemodels")) + { if (showval) { OSD_Printf("usemodels is %d\n", usemodels); } else usemodels = (val != 0); return OSDCMD_OK; } - else if (!Bstrcasecmp(parm->name, "usehightile")) { + else if (!Bstrcasecmp(parm->name, "usehightile")) + { if (showval) { OSD_Printf("usehightile is %d\n", usehightile); } else usehightile = (val != 0); return OSDCMD_OK; } #ifdef USE_OPENGL - else if (!Bstrcasecmp(parm->name, "glusetexcompr")) { + else if (!Bstrcasecmp(parm->name, "glusetexcompr")) + { if (showval) { OSD_Printf("glusetexcompr is %d\n", glusetexcompr); } else glusetexcompr = (val != 0); return OSDCMD_OK; } - else if (!Bstrcasecmp(parm->name, "glredbluemode")) { + else if (!Bstrcasecmp(parm->name, "glredbluemode")) + { if (showval) { OSD_Printf("glredbluemode is %d\n", glredbluemode); } else glredbluemode = (val != 0); return OSDCMD_OK; } - else if (!Bstrcasecmp(parm->name, "gltexturemaxsize")) { + else if (!Bstrcasecmp(parm->name, "gltexturemaxsize")) + { if (showval) { OSD_Printf("gltexturemaxsize is %d\n", gltexmaxsize); } else gltexmaxsize = val; return OSDCMD_OK; } - else if (!Bstrcasecmp(parm->name, "gltexturemiplevel")) { + else if (!Bstrcasecmp(parm->name, "gltexturemiplevel")) + { if (showval) { OSD_Printf("gltexturemiplevel is %d\n", gltexmiplevel); } else gltexmiplevel = val; return OSDCMD_OK; } - else if (!Bstrcasecmp(parm->name, "r_depthpeeling")) { + else if (!Bstrcasecmp(parm->name, "r_depthpeeling")) + { if (showval) { OSD_Printf("r_depthpeeling is %d\n", r_depthpeeling); } - else { + else + { if (!glinfo.arbfp || !glinfo.depthtex || !glinfo.shadow || !glinfo.fbos || !glinfo.rect) { OSD_Printf("r_depthpeeling: Your OpenGL implementation doesn't support depth peeling.\n"); @@ -5316,10 +5466,12 @@ static int osdcmd_polymostvars(const osdfuncparm_t *parm) } return OSDCMD_OK; } - else if (!Bstrcasecmp(parm->name, "r_peelscount")) { + else if (!Bstrcasecmp(parm->name, "r_peelscount")) + { if (showval) { OSD_Printf("r_peelscount is %d\n", r_peelscount); } else if (val < 1) { OSD_Printf("Value out of range.\n"); } - else { + else + { newpeelscount = val; resetvideomode(); if (setgamemode(fullscreen,xdim,ydim,bpp)) @@ -5327,15 +5479,18 @@ static int osdcmd_polymostvars(const osdfuncparm_t *parm) } return OSDCMD_OK; } - else if (!Bstrcasecmp(parm->name, "r_curpeel")) { + else if (!Bstrcasecmp(parm->name, "r_curpeel")) + { if (showval) { OSD_Printf("r_curpeel is %d\n", r_curpeel); } else if ((val < -1) || (val >= r_peelscount)) { OSD_Printf("Value out of range.\n"); } else r_curpeel = val; return OSDCMD_OK; } - else if (!Bstrcasecmp(parm->name, "r_detailmapping")) { + else if (!Bstrcasecmp(parm->name, "r_detailmapping")) + { if (showval) { OSD_Printf("r_detailmapping is %d\n", r_detailmapping); } - else { + else + { if (!glinfo.multitex || !glinfo.envcombine) { OSD_Printf("Your OpenGL implementation doesn't support detail mapping.\n"); @@ -5346,9 +5501,11 @@ static int osdcmd_polymostvars(const osdfuncparm_t *parm) } return OSDCMD_OK; } - else if (!Bstrcasecmp(parm->name, "r_glowmapping")) { + else if (!Bstrcasecmp(parm->name, "r_glowmapping")) + { if (showval) { OSD_Printf("r_glowmapping is %d\n", r_glowmapping); } - else { + else + { if (!glinfo.multitex || !glinfo.envcombine) { OSD_Printf("Your OpenGL implementation doesn't support glow mapping.\n"); @@ -5359,14 +5516,17 @@ static int osdcmd_polymostvars(const osdfuncparm_t *parm) } return OSDCMD_OK; } - else if (!Bstrcasecmp(parm->name, "r_vertexarrays")) { + else if (!Bstrcasecmp(parm->name, "r_vertexarrays")) + { if (showval) { OSD_Printf("r_vertexarrays is %d\n", r_vertexarrays); } else r_vertexarrays = (val != 0); return OSDCMD_OK; } - else if (!Bstrcasecmp(parm->name, "r_vbos")) { + else if (!Bstrcasecmp(parm->name, "r_vbos")) + { if (showval) { OSD_Printf("r_vbos is %d\n", r_vbos); } - else { + else + { if (!glinfo.vbos) { OSD_Printf("Your OpenGL implementation doesn't support Vertex Buffer Objects.\n"); @@ -5377,45 +5537,53 @@ static int osdcmd_polymostvars(const osdfuncparm_t *parm) } return OSDCMD_OK; } - else if (!Bstrcasecmp(parm->name, "r_vbocount")) { + else if (!Bstrcasecmp(parm->name, "r_vbocount")) + { if (showval) { OSD_Printf("r_vbocount is %d\n", r_vbocount); } else if (val < 1) { OSD_Printf("Value out of range.\n"); } else r_vbocount = val; return OSDCMD_OK; } - else if (!Bstrcasecmp(parm->name, "r_animsmoothing")) { + else if (!Bstrcasecmp(parm->name, "r_animsmoothing")) + { if (showval) { OSD_Printf("r_animsmoothing is %d\n", r_animsmoothing); } else r_animsmoothing = (val != 0); return OSDCMD_OK; } - else if (!Bstrcasecmp(parm->name, "glpolygonmode")) { + else if (!Bstrcasecmp(parm->name, "glpolygonmode")) + { if (showval) { OSD_Printf("glpolygonmode is %d\n", glpolygonmode); } else glpolygonmode = val; return OSDCMD_OK; } - else if (!Bstrcasecmp(parm->name, "glusetexcache")) { + else if (!Bstrcasecmp(parm->name, "glusetexcache")) + { if (showval) { OSD_Printf("glusetexcache is %d\n", glusetexcache); } else glusetexcache = (val != 0); return OSDCMD_OK; } - else if (!Bstrcasecmp(parm->name, "glusetexcachecompression")) { + else if (!Bstrcasecmp(parm->name, "glusetexcachecompression")) + { if (showval) { OSD_Printf("glusetexcachecompression is %d\n", glusetexcachecompression); } else glusetexcachecompression = (val != 0); return OSDCMD_OK; } - else if (!Bstrcasecmp(parm->name, "glmultisample")) { + else if (!Bstrcasecmp(parm->name, "glmultisample")) + { if (showval) { OSD_Printf("glmultisample is %d\n", glmultisample); } else glmultisample = max(0,val); return OSDCMD_OK; } - else if (!Bstrcasecmp(parm->name, "glnvmultisamplehint")) { + else if (!Bstrcasecmp(parm->name, "glnvmultisamplehint")) + { if (showval) { OSD_Printf("glnvmultisamplehint is %d\n", glnvmultisamplehint); } else glnvmultisamplehint = (val != 0); return OSDCMD_OK; } - else if (!Bstrcasecmp(parm->name, "r_shadescale")) { + else if (!Bstrcasecmp(parm->name, "r_shadescale")) + { if (showval) { OSD_Printf("r_shadescale is %g\n", shadescale); } - else + else { float fval = atof(parm->parms[0]); shadescale = fval; @@ -5436,11 +5604,13 @@ static int dumptexturedefs(const osdfuncparm_t *parm) if (!hicfirstinit) return OSDCMD_OK; initprintf("// Begin Texture Dump\n"); - for (i=0;inext) { + for (; hr; hr = hr->next) + { if (!hr->filename) continue; initprintf(" pal %d { name \"%s\" ", hr->palnum, hr->filename); if (hr->alphacut >= 0.0) initprintf("alphacut %g ", hr->alphacut); @@ -5484,7 +5654,7 @@ void polymost_initosdfuncs(void) //OSD_RegisterFunction("dumptexturedefs","dumptexturedefs: dumps all texture definitions in the new style",dumptexturedefs); } -void polymost_precache(long dapicnum, long dapalnum, long datype) +void polymost_precache(int dapicnum, int dapalnum, int datype) { #ifdef USE_OPENGL // dapicnum and dapalnum are like you'd expect @@ -5519,18 +5689,18 @@ void polymost_precache(long dapicnum, long dapalnum, long datype) #endif } -static unsigned short hicosub (unsigned short c) +static unsigned short hicosub(unsigned short c) { - long r, g, b; + int r, g, b; g = ((c>> 5)&63); r = ((c>>11)-(g>>1))&31; b = ((c>> 0)-(g>>1))&31; return((r<<11)+(g<<5)+b); } -static unsigned short hicoadd (unsigned short c) +static unsigned short hicoadd(unsigned short c) { - long r, g, b; + int r, g, b; g = ((c>> 5)&63); r = ((c>>11)+(g>>1))&31; b = ((c>> 0)+(g>>1))&31; @@ -5544,7 +5714,7 @@ Description of Ken's filter to improve LZW compression of DXT1 format by ~15%: ( Here are the 3 DXT fields: 1. __int64 alpha_4x4; //DXT3 only (16 byte structure size when included) 2. short rgb0, rgb1; - 3. long index_4x4; + 3. int index_4x4; Each field is then stored with its own specialized algorithm. 1. I haven't done much testing with this field - I just copy it raw without any transform for now. @@ -5576,38 +5746,43 @@ Description of Ken's filter to improve LZW compression of DXT1 format by ~15%: ( */ #if defined(POLYMOST) && defined(USE_OPENGL) -int dxtfilter(int fil, texcachepicture *pict, char *pic, void *midbuf, char *packbuf, unsigned long miplen) +int dxtfilter(int fil, texcachepicture *pict, char *pic, void *midbuf, char *packbuf, unsigned int miplen) { void *writebuf; #if (USEKENFILTER == 0) - unsigned long cleng,j; - if (glusetexcachecompression) { + unsigned int cleng,j; + if (glusetexcachecompression) + { #ifdef USELZF cleng = lzf_compress(pic, miplen, packbuf, miplen-1); - if (cleng == 0) { + if (cleng == 0) + { // failed to compress cleng = miplen; writebuf = pic; - } else writebuf = packbuf; + } + else writebuf = packbuf; #else cleng = lzwcompress(pic,miplen,packbuf); writebuf = packbuf; #endif - } else { + } + else + { cleng = miplen; writebuf = pic; } if (cleng < 0) return -1; j = B_LITTLE32(cleng); - if (Bwrite(fil, &j, sizeof(unsigned long)) != sizeof(unsigned long)) return -1; + if (Bwrite(fil, &j, sizeof(unsigned int)) != sizeof(unsigned int)) return -1; if (Bwrite(fil, writebuf, cleng) != cleng) return -1; #else - unsigned long j, k, offs, stride, cleng; + unsigned int j, k, offs, stride, cleng; 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... @@ -5617,19 +5792,24 @@ int dxtfilter(int fil, texcachepicture *pict, char *pic, void *midbuf, char *pac for (k=0;k<8;k++) *cptr++ = pic[k]; for (j=stride;(unsigned)j>6)&3) + (((c2[1]>>6)&3)<<2) + (((c2[2]>>6)&3)<<4) + (((c2[3]>>6)&3)<<6); cptr += 4; } - if (glusetexcachecompression) { + if (glusetexcachecompression) + { #ifdef USELZF j = (miplen/stride)*4; cleng = lzf_compress(midbuf,j,packbuf,j-1); - if (cleng == 0) { + if (cleng == 0) + { cleng = j; writebuf = midbuf; - } else writebuf = packbuf; + } + else writebuf = packbuf; #else cleng = lzwcompress(midbuf,(miplen/stride)*4,packbuf); writebuf = packbuf; #endif - } else { + } + else + { cleng = (miplen/stride)*4; writebuf = midbuf; } @@ -5701,8 +5891,8 @@ int dedxtfilter(int fil, texcachepicture *pict, char *pic, void *midbuf, char *p { void *inbuf; #if (USEKENFILTER == 0) - unsigned long cleng; - if (kread(fil, &cleng, sizeof(unsigned long)) != sizeof(unsigned long)) return -1; cleng = B_LITTLE32(cleng); + unsigned int cleng; + if (kread(fil, &cleng, sizeof(unsigned int)) != sizeof(unsigned int)) return -1; cleng = B_LITTLE32(cleng); #ifdef USELZF if (ispacked && cleng < pict->size) inbuf = packbuf; else inbuf = pic; if (kread(fil, inbuf, cleng) != cleng) return -1; @@ -5714,15 +5904,15 @@ int dedxtfilter(int fil, texcachepicture *pict, char *pic, void *midbuf, char *p if (ispacked && lzwuncompress(packbuf, cleng, pic, pict->size) != pict->size) return -1; #endif #else - long j, k, offs, stride, cleng; + int j, k, offs, stride, cleng; char *cptr; if (ispacked) inbuf = packbuf; else inbuf = midbuf; if ((pict->format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT) || - (pict->format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT)) { offs = 0; stride = 8; } + (pict->format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT)) { offs = 0; stride = 8; } else if ((pict->format == GL_COMPRESSED_RGBA_S3TC_DXT3_EXT) || - (pict->format == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT)) { offs = 8; stride = 16; } + (pict->format == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT)) { offs = 8; stride = 16; } else { offs = 0; stride = 8; } if (stride == 16) //If DXT3... diff --git a/polymer/build/src/pragmas.c b/polymer/build/src/pragmas.c index c287d7959..824c82c6b 100644 --- a/polymer/build/src/pragmas.c +++ b/polymer/build/src/pragmas.c @@ -10,7 +10,7 @@ //#include "pragmas.h" #include "compat.h" -long dmval; +int dmval; #if defined(__GNUC__) && defined(__i386__) && !defined(NOASM) // NOASM @@ -21,9 +21,9 @@ long dmval; #define ASM __asm__ __volatile__ -long boundmulscale(long a, long b, long c) +int boundmulscale(int a, int b, int c) { - ASM ( + ASM( "imull %%ebx\n\t" "movl %%edx, %%ebx\n\t" // mov ebx, edx "shrdl %%cl, %%edx, %%eax\n\t" // mov eax, edx, cl @@ -39,7 +39,7 @@ long boundmulscale(long a, long b, long c) "sarl $31, %%eax\n\t" // sar eax, 31 "xorl $0x7fffffff, %%eax\n\t" // xor eax, 0x7fffffff "1:" // skipboundit: - : "+a" (a), "+b" (b), "+c" (c) // input eax ebx ecx + : "+a"(a), "+b"(b), "+c"(c) // input eax ebx ecx : : "edx", "cc" ); @@ -47,9 +47,9 @@ long boundmulscale(long a, long b, long c) } -void clearbufbyte(void *D, long c, long a) +void clearbufbyte(void *D, int c, int a) { - ASM ( + ASM( "cmpl $4, %%ecx\n\t" "jae 1f\n\t" "testb $1, %%cl\n\t" @@ -83,14 +83,14 @@ void clearbufbyte(void *D, long c, long a) "jz 5f\n\t" // jz endit "stosb\n\t" "5:" // endit - : "+D" (D), "+c" (c), "+a" (a) : + : "+D"(D), "+c"(c), "+a"(a) : : "ebx", "memory", "cc" ); } -void copybufbyte(void *S, void *D, long c) +void copybufbyte(void *S, void *D, int c) { - ASM ( + ASM( "cmpl $4, %%ecx\n\t" // cmp ecx, 4 "jae 1f\n\t" "testb $1, %%cl\n\t" // test cl, 1 @@ -124,14 +124,14 @@ void copybufbyte(void *S, void *D, long c) "jz 5f\n\t" "movsb\n\t" "5:" // endit: - : "+c" (c), "+S" (S), "+D" (D) : + : "+c"(c), "+S"(S), "+D"(D) : : "ebx", "memory", "cc" ); } -void copybufreverse(void *S, void *D, long c) +void copybufreverse(void *S, void *D, int c) { - ASM ( + ASM( "shrl $1, %%ecx\n\t" "jnc 0f\n\t" // jnc skipit1 "movb (%%esi), %%al\n\t" @@ -158,7 +158,7 @@ void copybufreverse(void *S, void *D, long c) "decl %%ecx\n\t" "jnz 2b\n\t" // jnz begloop "3:" - : "+S" (S), "+D" (D), "+c" (c) : + : "+S"(S), "+D"(D), "+c"(c) : : "eax", "memory", "cc" ); } @@ -181,35 +181,38 @@ void copybufreverse(void *S, void *D, long c) // Generic C version // -void qinterpolatedown16(long bufptr, long num, long val, long add) -{ // gee, I wonder who could have provided this... - long i, *lptr = (long *)bufptr; +void qinterpolatedown16(int bufptr, int num, int val, int add) +{ + // gee, I wonder who could have provided this... + int i, *lptr = (int *)bufptr; for (i=0;i>16); val += add; } } -void qinterpolatedown16short(long bufptr, long num, long val, long add) -{ // ...maybe the same person who provided this too? - long i; short *sptr = (short *)bufptr; +void qinterpolatedown16short(int bufptr, int num, int val, int add) +{ + // ...maybe the same person who provided this too? + int i; short *sptr = (short *)bufptr; for (i=0;i>16); val += add; } } -void clearbuf(void *d, long c, long a) +void clearbuf(void *d, int c, int a) { - long *p = (long*)d; + int *p = (int*)d; while ((c--) > 0) *(p++) = a; } -void copybuf(void *s, void *d, long c) +void copybuf(void *s, void *d, int c) { - long *p = (long*)s, *q = (long*)d; + int *p = (int*)s, *q = (int*)d; while ((c--) > 0) *(q++) = *(p++); } -void swapbuf4(void *a, void *b, long c) +void swapbuf4(void *a, void *b, int c) { - long *p = (long*)a, *q = (long*)b; - long x, y; - while ((c--) > 0) { + int *p = (int*)a, *q = (int*)b; + int x, y; + while ((c--) > 0) + { x = *q; y = *p; *(q++) = y; @@ -217,25 +220,27 @@ void swapbuf4(void *a, void *b, long c) } } -void clearbufbyte(void *D, long c, long a) -{ // Cringe City +void clearbufbyte(void *D, int c, int a) +{ + // Cringe City char *p = (char*)D; - long m[4] = { 0xffl,0xff00l,0xff0000l,0xff000000l }; - long n[4] = { 0,8,16,24 }; - long z=0; - while ((c--) > 0) { + int m[4] = { 0xffl,0xff00l,0xff0000l,0xff000000l }; + int n[4] = { 0,8,16,24 }; + int z=0; + while ((c--) > 0) + { *(p++) = (char)((a & m[z])>>n[z]); z=(z+1)&3; } } -void copybufbyte(void *S, void *D, long c) +void copybufbyte(void *S, void *D, int c) { char *p = (char*)S, *q = (char*)D; while ((c--) > 0) *(q++) = *(p++); } -void copybufreverse(void *S, void *D, long c) +void copybufreverse(void *S, void *D, int c) { char *p = (char*)S, *q = (char*)D; while ((c--) > 0) *(q++) = *(p--); diff --git a/polymer/build/src/scriptfile.c b/polymer/build/src/scriptfile.c index 556a763b4..f45ab41ac 100644 --- a/polymer/build/src/scriptfile.c +++ b/polymer/build/src/scriptfile.c @@ -5,7 +5,7 @@ * See the included license file "BUILDLIC.TXT" for license info. */ -#include "compat.h" +#include "compat.h" #include "scriptfile.h" #include "baselayer.h" #include "compat.h" @@ -54,7 +54,8 @@ int scriptfile_getnumber(scriptfile *sf, int *num) sf->ltextptr = sf->textptr; (*num) = strtol((const char *)sf->textptr,&sf->textptr,0); - if (!ISWS(*sf->textptr) && *sf->textptr) { + if (!ISWS(*sf->textptr) && *sf->textptr) + { char *p = sf->textptr; skipovertoken(sf); initprintf("Error on line %s:%d: expecting int, got \"%s\"\n",sf->filename,scriptfile_getlinum(sf,sf->ltextptr),p); @@ -73,23 +74,31 @@ static double parsedouble(char *ptr, char **end) p = ptr; if (*p == '-') negative = 1, p++; else if (*p == '+') p++; - for (;; p++) { - if (*p >= '0' && *p <= '9') { + for (;; p++) + { + if (*p >= '0' && *p <= '9') + { dig = *p - '0'; if (beforedecimal) num = num * 10.0 + dig; else if (exposgn) expo = expo*10 + dig; - else { + else + { num += (double)dig * decpl; decpl /= 10.0; } - } else if (*p == '.') { + } + else if (*p == '.') + { if (beforedecimal) beforedecimal = 0; else break; - } else if ((*p == 'E') || (*p == 'e')) { + } + else if ((*p == 'E') || (*p == 'e')) + { exposgn = 1; if (p[1] == '-') { exposgn = -1; p++; } else if (p[1] == '+') p++; - } else break; + } + else break; } if (end) *end = p; @@ -112,7 +121,8 @@ int scriptfile_getdouble(scriptfile *sf, double *num) //(*num) = strtod((const char *)sf->textptr,&sf->textptr); (*num) = parsedouble(sf->textptr, &sf->textptr); - if (!ISWS(*sf->textptr) && *sf->textptr) { + if (!ISWS(*sf->textptr) && *sf->textptr) + { char *p = sf->textptr; skipovertoken(sf); initprintf("Error on line %s:%d: expecting float, got \"%s\"\n",sf->filename,scriptfile_getlinum(sf,sf->ltextptr),p); @@ -130,7 +140,8 @@ int scriptfile_getsymbol(scriptfile *sf, int *num) if (!t) return -1; v = Bstrtol(t, &e, 10); - if (*e) { + if (*e) + { // looks like a string, so find it in the symbol table if (scriptfile_getsymbolvalue(t, num)) return 0; initprintf("Error on line %s:%d: expecting symbol, got \"%s\"\n",sf->filename,scriptfile_getlinum(sf,sf->ltextptr),t); @@ -153,7 +164,8 @@ int scriptfile_getbraces(scriptfile *sf, char **braceend) return -1; } - if (sf->textptr[0] != '{') { + if (sf->textptr[0] != '{') + { initprintf("Error on line %s:%d: expecting '{'\n",sf->filename,scriptfile_getlinum(sf,sf->textptr)); return -1; } @@ -162,7 +174,7 @@ int scriptfile_getbraces(scriptfile *sf, char **braceend) { if (sf->textptr >= sf->eof) return(0); if (sf->textptr[0] == '{') bracecnt++; - if (sf->textptr[0] == '}') { bracecnt--; if (!bracecnt) break; } + if (sf->textptr[0] == '}') { bracecnt--; if (!bracecnt) break; } sf->textptr++; } (*braceend) = sf->textptr; @@ -171,13 +183,13 @@ int scriptfile_getbraces(scriptfile *sf, char **braceend) } -int scriptfile_getlinum (scriptfile *sf, char *ptr) +int scriptfile_getlinum(scriptfile *sf, char *ptr) { int i, stp, ind; //for(i=0;ilinenum;i++) if (sf->lineoffs[i] >= ind) return(i+1); //brute force algo - ind = ((long)ptr) - ((long)sf->textbuf); + ind = ((int)ptr) - ((int)sf->textbuf); for (stp=1;stp+stplinenum;stp+=stp); //stp = highest power of 2 less than sf->linenum for (i=0;stp;stp>>=1) @@ -185,9 +197,9 @@ int scriptfile_getlinum (scriptfile *sf, char *ptr) return(i+1); //i = index to highest lineoffs which is less than ind; convert to 1-based line numbers } -void scriptfile_preparse (scriptfile *sf, char *tx, long flen) +void scriptfile_preparse(scriptfile *sf, char *tx, int flen) { - long i, cr, numcr, nflen, ws, cs, inquote; + int i, cr, numcr, nflen, ws, cs, inquote; //Count number of lines numcr = 1; @@ -200,7 +212,7 @@ void scriptfile_preparse (scriptfile *sf, char *tx, long flen) } sf->linenum = numcr; - sf->lineoffs = (long *)malloc(sf->linenum*sizeof(long)); + sf->lineoffs = (int *)malloc(sf->linenum*sizeof(int)); //Preprocess file for comments (// and /*...*/, and convert all whitespace to single spaces) nflen = 0; ws = 0; cs = 0; numcr = 0; inquote = 0; @@ -218,13 +230,13 @@ void scriptfile_preparse (scriptfile *sf, char *tx, long flen) ws = 1; continue; //strip CR/LF } - if ((!inquote) && ((tx[i] == ' ') || (tx[i] == '\t'))) { ws = 1; continue; } //strip Space/Tab + if ((!inquote) && ((tx[i] == ' ') || (tx[i] == '\t'))) { ws = 1; continue; } //strip Space/Tab if ((tx[i] == '/') && (tx[i+1] == '/') && (!cs)) cs = 1; - if ((tx[i] == '/') && (tx[i+1] == '*') && (!cs)) { ws = 1; cs = 2; } + if ((tx[i] == '/') && (tx[i+1] == '*') && (!cs)) { ws = 1; cs = 2; } if ((tx[i] == '*') && (tx[i+1] == '/') && (cs == 2)) { cs = 0; i++; continue; } if (cs) continue; - if (ws) { tx[nflen++] = 0; ws = 0; } + if (ws) { tx[nflen++] = 0; ws = 0; } //quotes inside strings: \" if ((tx[i] == '\\') && (tx[i+1] == '\"')) { i++; tx[nflen++] = '\"'; continue; } @@ -260,13 +272,15 @@ scriptfile *scriptfile_fromfile(char *fn) flen = kfilelength(fp); tx = (char *) malloc(flen + 2); - if (!tx) { + if (!tx) + { kclose(fp); return NULL; } sf = (scriptfile*) malloc(sizeof(scriptfile)); - if (!sf) { + if (!sf) + { kclose(fp); free(tx); return NULL; @@ -297,7 +311,8 @@ scriptfile *scriptfile_fromstring(char *string) if (!tx) return NULL; sf = (scriptfile*) malloc(sizeof(scriptfile)); - if (!sf) { + if (!sf) + { free(tx); return NULL; } @@ -355,8 +370,10 @@ int scriptfile_getsymbolvalue(char *name, int *val) char *scanner = symbtab; if (!symbtab) return 0; - while (scanner - symbtab < symbtablength) { - if (!Bstrcasecmp(name, scanner)) { + while (scanner - symbtab < symbtablength) + { + if (!Bstrcasecmp(name, scanner)) + { *val = *(int*)(scanner + strlen(scanner) + 1); return 1; } @@ -373,10 +390,13 @@ int scriptfile_addsymbolvalue(char *name, int val) char *sp; // if (scriptfile_getsymbolvalue(name, &x)) return -1; // already exists - if (symbtab) { + if (symbtab) + { char *scanner = symbtab; - while (scanner - symbtab < symbtablength) { - if (!Bstrcasecmp(name, scanner)) { + while (scanner - symbtab < symbtablength) + { + if (!Bstrcasecmp(name, scanner)) + { *(int*)(scanner + strlen(scanner) + 1) = val; return 1; } diff --git a/polymer/build/src/sdlayer.c b/polymer/build/src/sdlayer.c index 08e518ce0..4f6c91307 100644 --- a/polymer/build/src/sdlayer.c +++ b/polymer/build/src/sdlayer.c @@ -41,24 +41,24 @@ int startwin_settitle(const char *s) { s=s; return 0; } // fix for mousewheel #define MWHEELTICKS 10 -static unsigned long mwheelup, mwheeldown; +static unsigned int mwheelup, mwheeldown; int _buildargc = 1; const char **_buildargv = NULL; -extern long app_main(long argc, const char *argv[]); +extern int app_main(int argc, const char *argv[]); char quitevent=0, appactive=1; // video static SDL_Surface *sdl_surface; -long xres=-1, yres=-1, bpp=0, fullscreen=0, bytesperline, imageSize; -long frameplace=0, lockcount=0; +int xres=-1, yres=-1, bpp=0, fullscreen=0, bytesperline, imageSize; +int frameplace=0, lockcount=0; char modechange=1; char offscreenrendering=0; char videomodereset = 0; char nofog=0; static unsigned short sysgamma[3][256]; -extern long curbrightness, gammabrightness; +extern int curbrightness, gammabrightness; #ifdef USE_OPENGL // OpenGL stuff @@ -70,15 +70,15 @@ char inputdevices=0; char keystatus[256], keyfifo[KEYFIFOSIZ], keyfifoplc, keyfifoend; unsigned char keyasciififo[KEYFIFOSIZ], keyasciififoplc, keyasciififoend; static unsigned char keynames[256][24]; -long mousex=0,mousey=0,mouseb=0; -long *joyaxis = NULL, joyb=0, *joyhat = NULL; +int mousex=0,mousey=0,mouseb=0; +int *joyaxis = NULL, joyb=0, *joyhat = NULL; char joyisgamepad=0, joynumaxes=0, joynumbuttons=0, joynumhats=0; -long joyaxespresent=0; +int joyaxespresent=0; -void(*keypresscallback)(long,long) = 0; -void(*mousepresscallback)(long,long) = 0; -void(*joypresscallback)(long,long) = 0; +void(*keypresscallback)(int,int) = 0; +void(*mousepresscallback)(int,int) = 0; +void(*joypresscallback)(int,int) = 0; static unsigned char keytranslation[SDLK_LAST]; static int buildkeytranslationtable(void); @@ -321,7 +321,7 @@ void debugprintf(const char *f, ...) // static char mouseacquired=0,moustat=0; -static long joyblast=0; +static int joyblast=0; static SDL_Joystick *joydev = NULL; // @@ -366,8 +366,8 @@ int initinput(void) initprintf("Joystick 1 has %d axes, %d buttons, and %d hat(s).\n", joynumaxes,joynumbuttons,joynumhats); - joyaxis = (long *)Bcalloc(joynumaxes, sizeof(long)); - joyhat = (long *)Bcalloc(joynumhats, sizeof(long)); + joyaxis = (int *)Bcalloc(joynumaxes, sizeof(int)); + joyhat = (int *)Bcalloc(joynumhats, sizeof(int)); } } @@ -446,9 +446,9 @@ void bflushchars(void) // // set{key|mouse|joy}presscallback() -- sets a callback which gets notified when keys are pressed // -void setkeypresscallback(void(*callback)(long, long)) { keypresscallback = callback; } -void setmousepresscallback(void(*callback)(long, long)) { mousepresscallback = callback; } -void setjoypresscallback(void(*callback)(long, long)) { joypresscallback = callback; } +void setkeypresscallback(void(*callback)(int, int)) { keypresscallback = callback; } +void setmousepresscallback(void(*callback)(int, int)) { mousepresscallback = callback; } +void setjoypresscallback(void(*callback)(int, int)) { joypresscallback = callback; } // // initmouse() -- init mouse input @@ -503,7 +503,7 @@ void grabmouse(char a) // // readmousexy() -- return mouse motion information // -void readmousexy(long *x, long *y) +void readmousexy(int *x, int *y) { if (!mouseacquired || !appactive || !moustat) { *x = *y = 0; return; } *x = mousex; @@ -514,7 +514,7 @@ void readmousexy(long *x, long *y) // // readmousebstatus() -- return mouse button information // -void readmousebstatus(long *b) +void readmousebstatus(int *b) { if (!mouseacquired || !appactive || !moustat) *b = 0; else *b = mouseb; @@ -593,12 +593,12 @@ void uninittimer(void) void sampletimer(void) { Uint32 i; - long n; + int n; if (!timerfreq) return; i = SDL_GetTicks(); - n = (long)(i * timerticspersec / timerfreq) - timerlastsample; + n = (int)(i * timerticspersec / timerfreq) - timerlastsample; if (n>0) { totalclock += n; @@ -611,9 +611,9 @@ void sampletimer(void) // // getticks() -- returns the sdl ticks count // -unsigned long getticks(void) +unsigned int getticks(void) { - return (unsigned long)SDL_GetTicks(); + return (unsigned int)SDL_GetTicks(); } @@ -670,19 +670,19 @@ static char modeschecked=0; void getvalidmodes(void) { static int cdepths[] = - { - 8, + { + 8, #ifdef USE_OPENGL - 16,24,32, + 16,24,32, #endif - 0 - }; + 0 + }; static int defaultres[][2] = - { - {1280,1024} - ,{1280,960},{1152,864},{1024,768},{800,600},{640,480}, - {640,400},{512,384},{480,360},{400,300},{320,240},{320,200},{0,0} - }; + { + {1280,1024} + ,{1280,960},{1152,864},{1024,768},{800,600},{640,480}, + {640,400},{512,384},{480,360},{400,300},{320,240},{320,200},{0,0} + }; SDL_Rect **modes; SDL_PixelFormat pf = { NULL, 8, 1, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0 }; int i, j, maxx=0, maxy=0; @@ -804,7 +804,8 @@ int checkvideomode(int *x, int *y, int c, int fs, int forced) dx = klabs(validmode[i].xdim - *x); dy = klabs(validmode[i].ydim - *y); if (!(dx | dy)) - { // perfect match + { + // perfect match nearest = i; break; } @@ -880,24 +881,25 @@ int setvideomode(int x, int y, int c, int fs) SDL_GLattr attr; int value; } - attributes[] = { + attributes[] = + { #if 0 - { SDL_GL_RED_SIZE, 8 }, - { SDL_GL_GREEN_SIZE, 8 }, - { SDL_GL_BLUE_SIZE, 8 }, - { SDL_GL_ALPHA_SIZE, 8 }, - { SDL_GL_BUFFER_SIZE, c }, - { SDL_GL_STENCIL_SIZE, 0 }, - { SDL_GL_ACCUM_RED_SIZE, 0 }, - { SDL_GL_ACCUM_GREEN_SIZE, 0 }, - { SDL_GL_ACCUM_BLUE_SIZE, 0 }, - { SDL_GL_ACCUM_ALPHA_SIZE, 0 }, - { SDL_GL_DEPTH_SIZE, 24 }, + { SDL_GL_RED_SIZE, 8 }, + { SDL_GL_GREEN_SIZE, 8 }, + { SDL_GL_BLUE_SIZE, 8 }, + { SDL_GL_ALPHA_SIZE, 8 }, + { SDL_GL_BUFFER_SIZE, c }, + { SDL_GL_STENCIL_SIZE, 0 }, + { SDL_GL_ACCUM_RED_SIZE, 0 }, + { SDL_GL_ACCUM_GREEN_SIZE, 0 }, + { SDL_GL_ACCUM_BLUE_SIZE, 0 }, + { SDL_GL_ACCUM_ALPHA_SIZE, 0 }, + { SDL_GL_DEPTH_SIZE, 24 }, #endif - { SDL_GL_DOUBLEBUFFER, 1 }, - { SDL_GL_MULTISAMPLEBUFFERS, glmultisample > 0 }, - { SDL_GL_MULTISAMPLESAMPLES, glmultisample }, - }; + { SDL_GL_DOUBLEBUFFER, 1 }, + { SDL_GL_MULTISAMPLEBUFFERS, glmultisample > 0 }, + { SDL_GL_MULTISAMPLESAMPLES, glmultisample }, + }; if (nogl) return -1; @@ -1138,7 +1140,7 @@ void resetvideomode(void) // void begindrawing(void) { - long i,j; + int i,j; if (bpp > 8) { @@ -1157,7 +1159,7 @@ void begindrawing(void) if (offscreenrendering) return; if (SDL_MUSTLOCK(sdl_surface)) SDL_LockSurface(sdl_surface); - frameplace = (long)sdl_surface->pixels; + frameplace = (int)sdl_surface->pixels; if (sdl_surface->pitch != bytesperline || modechange) { @@ -1184,7 +1186,7 @@ void enddrawing(void) } if (!frameplace) return; -if (lockcount > 1) { lockcount--; return; } + if (lockcount > 1) { lockcount--; return; } if (!offscreenrendering) frameplace = 0; if (lockcount == 0) return; lockcount = 0; @@ -1200,7 +1202,7 @@ if (lockcount > 1) { lockcount--; return; } // void showframe(int w) { - long i,j; + int i,j; #ifdef USE_OPENGL if (bpp > 8) @@ -1243,7 +1245,7 @@ void showframe(int w) if (lockcount) { - printf("Frame still locked %ld times when showframe() called.\n", lockcount); + printf("Frame still locked %d times when showframe() called.\n", lockcount); while (lockcount) enddrawing(); } @@ -1451,8 +1453,8 @@ int handleevents(void) case SDL_MOUSEMOTION: if (appactive) { - mousex += ev.motion.xrel; - mousey += ev.motion.yrel; + mousex += ev.motion.xrel; + mousey += ev.motion.yrel; } break; @@ -1463,24 +1465,25 @@ int handleevents(void) case SDL_JOYHATMOTION: { - int hatvals[16] = { - -1, // centre - 0, // up 1 - 9000, // right 2 - 4500, // up+right 3 - 18000, // down 4 - -1, // down+up!! 5 - 13500, // down+right 6 - -1, // down+right+up!! 7 - 27000, // left 8 - 27500, // left+up 9 - -1, // left+right!! 10 - -1, // left+right+up!! 11 - 22500, // left+down 12 - -1, // left+down+up!! 13 - -1, // left+down+right!! 14 - -1, // left+down+right+up!! 15 - }; + int hatvals[16] = + { + -1, // centre + 0, // up 1 + 9000, // right 2 + 4500, // up+right 3 + 18000, // down 4 + -1, // down+up!! 5 + 13500, // down+right 6 + -1, // down+right+up!! 7 + 27000, // left 8 + 27500, // left+up 9 + -1, // left+right!! 10 + -1, // left+right+up!! 11 + 22500, // left+down 12 + -1, // left+down+up!! 13 + -1, // left+down+right!! 14 + -1, // left+down+right+up!! 15 + }; if (appactive && ev.jhat.hat < joynumhats) joyhat[ ev.jhat.hat ] = hatvals[ ev.jhat.value & 15 ]; break; @@ -1680,26 +1683,29 @@ static int buildkeytranslationtable(void) void makeasmwriteable(void) { #ifndef ENGINE_USING_A_C - extern int dep_begin, dep_end; + extern int dep_begin, dep_end; # if defined _WIN32 - DWORD oldprot; - if (!VirtualProtect((LPVOID)&dep_begin, (SIZE_T)&dep_end - (SIZE_T)&dep_begin, PAGE_EXECUTE_READWRITE, &oldprot)) { - initprint("Error making code writeable\n"); - return; - } + DWORD oldprot; + if (!VirtualProtect((LPVOID)&dep_begin, (SIZE_T)&dep_end - (SIZE_T)&dep_begin, PAGE_EXECUTE_READWRITE, &oldprot)) + { + initprint("Error making code writeable\n"); + return; + } # elif defined __linux || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ - int pagesize; - size_t dep_begin_page; - pagesize = sysconf(_SC_PAGE_SIZE); - if (pagesize == -1) { - initprintf("Error getting system page size\n"); - return; - } - dep_begin_page = ((size_t)&dep_begin) & ~(pagesize-1); - if (mprotect((const void *)dep_begin_page, (size_t)&dep_end - dep_begin_page, PROT_READ|PROT_WRITE) < 0) { - initprintf("Error making code writeable (errno=%d)\n", errno); - return; - } + int pagesize; + size_t dep_begin_page; + pagesize = sysconf(_SC_PAGE_SIZE); + if (pagesize == -1) + { + initprintf("Error getting system page size\n"); + return; + } + dep_begin_page = ((size_t)&dep_begin) & ~(pagesize-1); + if (mprotect((const void *)dep_begin_page, (size_t)&dep_end - dep_begin_page, PROT_READ|PROT_WRITE) < 0) + { + initprintf("Error making code writeable (errno=%d)\n", errno); + return; + } # else # error Don't know how to unprotect the self-modifying assembly on this platform! # endif diff --git a/polymer/build/src/smalltextfont.c b/polymer/build/src/smalltextfont.c index 212c1f712..60d2d4d6a 100644 --- a/polymer/build/src/smalltextfont.c +++ b/polymer/build/src/smalltextfont.c @@ -3,177 +3,178 @@ // Font created by Ken Silverman // Generated by BIN2C.EXE by Jonathon Fowler -char smalltextfont[2048] = { - // 2048 bytes - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3C, 0x24, - 0x3C, 0x18, 0x00, 0x00, 0x00, 0x18, 0x24, 0x3C, 0x24, 0x18, 0x00, 0x00, - 0x00, 0x28, 0x3C, 0x3C, 0x38, 0x10, 0x00, 0x00, 0x00, 0x10, 0x38, 0x3C, - 0x38, 0x10, 0x00, 0x00, 0x00, 0x18, 0x3C, 0x3C, 0x18, 0x3C, 0x00, 0x00, - 0x00, 0x18, 0x18, 0x3C, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x38, 0x28, 0x38, 0x38, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x1C, 0x14, 0x14, 0x30, 0x00, 0x00, - 0x00, 0x24, 0x18, 0x3C, 0x18, 0x24, 0x00, 0x00, 0x00, 0x20, 0x30, 0x38, - 0x30, 0x20, 0x00, 0x00, 0x00, 0x08, 0x18, 0x38, 0x18, 0x08, 0x00, 0x00, - 0x00, 0x10, 0x38, 0x10, 0x38, 0x10, 0x00, 0x00, 0x00, 0x28, 0x28, 0x28, - 0x00, 0x28, 0x00, 0x00, 0x00, 0x1C, 0x34, 0x34, 0x14, 0x14, 0x00, 0x00, - 0x00, 0x1C, 0x30, 0x28, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x38, 0x38, 0x00, 0x00, 0x00, 0x10, 0x38, 0x10, 0x38, 0x38, 0x00, 0x00, - 0x00, 0x10, 0x38, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, - 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3C, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x10, 0x3C, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x10, 0x10, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x28, 0x28, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x3C, 0x28, 0x3C, 0x28, 0x00, 0x00, - 0x00, 0x18, 0x30, 0x10, 0x18, 0x30, 0x00, 0x00, 0x00, 0x28, 0x08, 0x10, - 0x20, 0x28, 0x00, 0x00, 0x00, 0x10, 0x28, 0x10, 0x30, 0x38, 0x00, 0x00, - 0x00, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x20, 0x20, - 0x20, 0x10, 0x00, 0x00, 0x00, 0x10, 0x08, 0x08, 0x08, 0x10, 0x00, 0x00, - 0x00, 0x00, 0x28, 0x10, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, - 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x10, 0x00, - 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x10, 0x00, 0x00, 0x00, 0x08, 0x08, 0x10, 0x10, 0x20, 0x00, 0x00, - 0x00, 0x38, 0x28, 0x28, 0x28, 0x38, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, - 0x10, 0x10, 0x00, 0x00, 0x00, 0x38, 0x08, 0x38, 0x20, 0x38, 0x00, 0x00, - 0x00, 0x38, 0x08, 0x38, 0x08, 0x38, 0x00, 0x00, 0x00, 0x28, 0x28, 0x38, - 0x08, 0x08, 0x00, 0x00, 0x00, 0x38, 0x20, 0x38, 0x08, 0x38, 0x00, 0x00, - 0x00, 0x38, 0x20, 0x38, 0x28, 0x38, 0x00, 0x00, 0x00, 0x38, 0x08, 0x08, - 0x08, 0x08, 0x00, 0x00, 0x00, 0x38, 0x28, 0x38, 0x28, 0x38, 0x00, 0x00, - 0x00, 0x38, 0x28, 0x38, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, - 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x10, 0x20, 0x00, 0x00, - 0x00, 0x08, 0x10, 0x20, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, - 0x38, 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x08, 0x10, 0x20, 0x00, 0x00, - 0x00, 0x30, 0x08, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x38, 0x28, 0x38, - 0x30, 0x38, 0x00, 0x00, 0x00, 0x10, 0x28, 0x38, 0x28, 0x28, 0x00, 0x00, - 0x00, 0x30, 0x28, 0x30, 0x28, 0x30, 0x00, 0x00, 0x00, 0x18, 0x20, 0x20, - 0x20, 0x18, 0x00, 0x00, 0x00, 0x30, 0x28, 0x28, 0x28, 0x30, 0x00, 0x00, - 0x00, 0x38, 0x20, 0x30, 0x20, 0x38, 0x00, 0x00, 0x00, 0x38, 0x20, 0x30, - 0x20, 0x20, 0x00, 0x00, 0x00, 0x38, 0x20, 0x28, 0x28, 0x38, 0x00, 0x00, - 0x00, 0x28, 0x28, 0x38, 0x28, 0x28, 0x00, 0x00, 0x00, 0x38, 0x10, 0x10, - 0x10, 0x38, 0x00, 0x00, 0x00, 0x38, 0x08, 0x08, 0x28, 0x18, 0x00, 0x00, - 0x00, 0x28, 0x28, 0x30, 0x28, 0x28, 0x00, 0x00, 0x00, 0x20, 0x20, 0x20, - 0x20, 0x38, 0x00, 0x00, 0x00, 0x28, 0x38, 0x38, 0x28, 0x28, 0x00, 0x00, - 0x00, 0x28, 0x38, 0x38, 0x38, 0x28, 0x00, 0x00, 0x00, 0x38, 0x28, 0x28, - 0x28, 0x38, 0x00, 0x00, 0x00, 0x38, 0x28, 0x38, 0x20, 0x20, 0x00, 0x00, - 0x00, 0x38, 0x28, 0x28, 0x38, 0x18, 0x00, 0x00, 0x00, 0x38, 0x28, 0x30, - 0x28, 0x28, 0x00, 0x00, 0x00, 0x38, 0x20, 0x38, 0x08, 0x38, 0x00, 0x00, - 0x00, 0x38, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x28, 0x28, 0x28, - 0x28, 0x38, 0x00, 0x00, 0x00, 0x28, 0x28, 0x28, 0x10, 0x10, 0x00, 0x00, - 0x00, 0x28, 0x28, 0x38, 0x38, 0x28, 0x00, 0x00, 0x00, 0x28, 0x28, 0x10, - 0x28, 0x28, 0x00, 0x00, 0x00, 0x28, 0x28, 0x38, 0x10, 0x10, 0x00, 0x00, - 0x00, 0x38, 0x08, 0x10, 0x20, 0x38, 0x00, 0x00, 0x00, 0x30, 0x20, 0x20, - 0x20, 0x30, 0x00, 0x00, 0x00, 0x20, 0x10, 0x10, 0x08, 0x08, 0x00, 0x00, - 0x00, 0x18, 0x08, 0x08, 0x08, 0x18, 0x00, 0x00, 0x00, 0x10, 0x28, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, - 0x00, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, - 0x28, 0x18, 0x00, 0x00, 0x00, 0x20, 0x20, 0x38, 0x28, 0x38, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x38, 0x20, 0x38, 0x00, 0x00, 0x00, 0x08, 0x08, 0x38, - 0x28, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x38, 0x18, 0x00, 0x00, - 0x00, 0x08, 0x10, 0x38, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x18, 0x28, - 0x18, 0x08, 0x30, 0x00, 0x00, 0x20, 0x20, 0x38, 0x28, 0x28, 0x00, 0x00, - 0x00, 0x00, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, - 0x10, 0x10, 0x20, 0x00, 0x00, 0x20, 0x20, 0x28, 0x30, 0x28, 0x00, 0x00, - 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x20, 0x38, - 0x38, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x28, 0x28, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x38, 0x28, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, - 0x28, 0x38, 0x20, 0x00, 0x00, 0x00, 0x00, 0x38, 0x28, 0x38, 0x08, 0x00, - 0x00, 0x00, 0x00, 0x38, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, - 0x10, 0x30, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x10, 0x10, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x28, 0x28, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, - 0x28, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x38, 0x38, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x28, 0x10, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, - 0x28, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x10, 0x18, 0x00, 0x00, - 0x00, 0x18, 0x10, 0x20, 0x10, 0x18, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, - 0x10, 0x10, 0x00, 0x00, 0x00, 0x30, 0x10, 0x08, 0x10, 0x30, 0x00, 0x00, - 0x00, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x28, - 0x38, 0x00, 0x00, 0x00, 0x00, 0x18, 0x20, 0x20, 0x20, 0x18, 0x30, 0x00, - 0x00, 0x28, 0x00, 0x28, 0x28, 0x18, 0x00, 0x00, 0x00, 0x18, 0x00, 0x18, - 0x38, 0x18, 0x00, 0x00, 0x00, 0x38, 0x00, 0x18, 0x28, 0x18, 0x00, 0x00, - 0x00, 0x28, 0x00, 0x18, 0x28, 0x18, 0x00, 0x00, 0x00, 0x30, 0x00, 0x18, - 0x28, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10, 0x18, 0x28, 0x18, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x38, 0x20, 0x38, 0x10, 0x00, 0x00, 0x38, 0x00, 0x18, - 0x38, 0x18, 0x00, 0x00, 0x00, 0x28, 0x00, 0x18, 0x38, 0x18, 0x00, 0x00, - 0x00, 0x30, 0x00, 0x18, 0x38, 0x18, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, - 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x10, 0x10, 0x00, 0x00, - 0x00, 0x00, 0x30, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x28, 0x10, 0x28, - 0x38, 0x28, 0x00, 0x00, 0x00, 0x10, 0x00, 0x10, 0x38, 0x28, 0x00, 0x00, - 0x00, 0x18, 0x00, 0x38, 0x30, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, - 0x28, 0x1C, 0x00, 0x00, 0x00, 0x1C, 0x28, 0x3C, 0x28, 0x2C, 0x00, 0x00, - 0x00, 0x38, 0x00, 0x38, 0x28, 0x38, 0x00, 0x00, 0x00, 0x28, 0x00, 0x38, - 0x28, 0x38, 0x00, 0x00, 0x00, 0x30, 0x00, 0x38, 0x28, 0x38, 0x00, 0x00, - 0x00, 0x38, 0x00, 0x28, 0x28, 0x18, 0x00, 0x00, 0x00, 0x30, 0x00, 0x28, - 0x28, 0x18, 0x00, 0x00, 0x00, 0x28, 0x00, 0x28, 0x28, 0x18, 0x30, 0x00, - 0x00, 0x28, 0x00, 0x38, 0x28, 0x38, 0x00, 0x00, 0x00, 0x28, 0x00, 0x28, - 0x28, 0x38, 0x00, 0x00, 0x00, 0x10, 0x38, 0x20, 0x38, 0x10, 0x00, 0x00, - 0x00, 0x18, 0x14, 0x30, 0x10, 0x3C, 0x00, 0x00, 0x00, 0x28, 0x10, 0x38, - 0x38, 0x10, 0x00, 0x00, 0x00, 0x30, 0x28, 0x3C, 0x28, 0x2C, 0x00, 0x00, - 0x00, 0x18, 0x10, 0x38, 0x10, 0x30, 0x00, 0x00, 0x00, 0x18, 0x00, 0x18, - 0x28, 0x18, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x10, 0x10, 0x00, 0x00, - 0x00, 0x18, 0x00, 0x38, 0x28, 0x38, 0x00, 0x00, 0x00, 0x18, 0x00, 0x28, - 0x28, 0x18, 0x00, 0x00, 0x00, 0x30, 0x00, 0x30, 0x28, 0x28, 0x00, 0x00, - 0x00, 0x38, 0x00, 0x28, 0x38, 0x28, 0x00, 0x00, 0x00, 0x18, 0x28, 0x18, - 0x00, 0x38, 0x00, 0x00, 0x00, 0x38, 0x28, 0x38, 0x00, 0x38, 0x00, 0x00, - 0x00, 0x10, 0x00, 0x10, 0x20, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, - 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x10, 0x00, 0x00, 0x00, - 0x00, 0x20, 0x28, 0x10, 0x38, 0x18, 0x00, 0x00, 0x00, 0x20, 0x28, 0x18, - 0x38, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x10, 0x10, 0x10, 0x00, 0x00, - 0x00, 0x00, 0x14, 0x28, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x14, - 0x28, 0x00, 0x00, 0x00, 0x00, 0x08, 0x20, 0x08, 0x20, 0x08, 0x20, 0x00, - 0x00, 0x14, 0x28, 0x14, 0x28, 0x14, 0x28, 0x00, 0x00, 0x34, 0x1C, 0x34, - 0x1C, 0x34, 0x1C, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, - 0x00, 0x10, 0x10, 0x30, 0x10, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x30, - 0x30, 0x10, 0x10, 0x00, 0x00, 0x18, 0x18, 0x38, 0x18, 0x18, 0x18, 0x00, - 0x00, 0x00, 0x00, 0x38, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x30, - 0x30, 0x10, 0x10, 0x00, 0x00, 0x18, 0x18, 0x38, 0x38, 0x18, 0x18, 0x00, - 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x38, - 0x38, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x38, 0x38, 0x00, 0x00, 0x00, - 0x00, 0x18, 0x18, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x30, - 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x10, 0x10, 0x10, 0x00, - 0x00, 0x10, 0x10, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x3C, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x10, 0x10, 0x10, 0x00, - 0x00, 0x10, 0x10, 0x1C, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x3C, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x3C, 0x10, 0x10, 0x10, 0x00, - 0x00, 0x10, 0x10, 0x1C, 0x1C, 0x10, 0x10, 0x00, 0x00, 0x18, 0x18, 0x1C, - 0x18, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x1C, 0x1C, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x1C, 0x1C, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x3C, - 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x3C, 0x18, 0x18, 0x00, - 0x00, 0x18, 0x18, 0x1C, 0x1C, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x3C, - 0x3C, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, - 0x00, 0x10, 0x10, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x3C, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x3C, 0x10, 0x10, 0x00, - 0x00, 0x00, 0x00, 0x3C, 0x18, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x1C, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x1C, 0x1C, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x1C, 0x1C, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x1C, - 0x18, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x3C, 0x18, 0x18, 0x18, 0x00, - 0x00, 0x10, 0x10, 0x3C, 0x3C, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x30, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x10, 0x10, 0x10, 0x00, - 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x3C, 0x3C, 0x3C, 0x00, 0x00, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, - 0x00, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x00, 0x00, 0x3C, 0x3C, 0x3C, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x28, 0x34, 0x00, 0x00, - 0x00, 0x30, 0x28, 0x30, 0x28, 0x30, 0x20, 0x00, 0x00, 0x38, 0x28, 0x20, - 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x38, 0x20, 0x10, 0x20, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, - 0x28, 0x10, 0x00, 0x00, 0x00, 0x00, 0x28, 0x28, 0x30, 0x20, 0x00, 0x00, - 0x00, 0x00, 0x14, 0x28, 0x08, 0x08, 0x00, 0x00, 0x00, 0x38, 0x10, 0x28, - 0x10, 0x38, 0x00, 0x00, 0x00, 0x10, 0x28, 0x38, 0x28, 0x10, 0x00, 0x00, - 0x00, 0x18, 0x24, 0x24, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x18, 0x10, 0x18, - 0x28, 0x38, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3C, 0x18, 0x00, 0x00, 0x00, - 0x00, 0x04, 0x18, 0x3C, 0x18, 0x20, 0x00, 0x00, 0x00, 0x18, 0x20, 0x30, - 0x20, 0x18, 0x00, 0x00, 0x00, 0x10, 0x28, 0x28, 0x28, 0x28, 0x00, 0x00, - 0x00, 0x38, 0x00, 0x38, 0x00, 0x38, 0x00, 0x00, 0x00, 0x10, 0x38, 0x10, - 0x00, 0x38, 0x00, 0x00, 0x00, 0x10, 0x08, 0x10, 0x00, 0x38, 0x00, 0x00, - 0x00, 0x10, 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x00, 0x10, 0x28, 0x20, - 0x20, 0x20, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x28, 0x10, 0x00, 0x00, - 0x00, 0x10, 0x00, 0x38, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x18, 0x38, - 0x30, 0x00, 0x00, 0x00, 0x00, 0x38, 0x28, 0x38, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x10, 0x10, 0x30, 0x10, 0x00, 0x00, - 0x00, 0x30, 0x28, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x10, 0x38, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x38, 0x38, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; +char smalltextfont[2048] = +{ + // 2048 bytes + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3C, 0x24, + 0x3C, 0x18, 0x00, 0x00, 0x00, 0x18, 0x24, 0x3C, 0x24, 0x18, 0x00, 0x00, + 0x00, 0x28, 0x3C, 0x3C, 0x38, 0x10, 0x00, 0x00, 0x00, 0x10, 0x38, 0x3C, + 0x38, 0x10, 0x00, 0x00, 0x00, 0x18, 0x3C, 0x3C, 0x18, 0x3C, 0x00, 0x00, + 0x00, 0x18, 0x18, 0x3C, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x38, 0x28, 0x38, 0x38, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x1C, 0x14, 0x14, 0x30, 0x00, 0x00, + 0x00, 0x24, 0x18, 0x3C, 0x18, 0x24, 0x00, 0x00, 0x00, 0x20, 0x30, 0x38, + 0x30, 0x20, 0x00, 0x00, 0x00, 0x08, 0x18, 0x38, 0x18, 0x08, 0x00, 0x00, + 0x00, 0x10, 0x38, 0x10, 0x38, 0x10, 0x00, 0x00, 0x00, 0x28, 0x28, 0x28, + 0x00, 0x28, 0x00, 0x00, 0x00, 0x1C, 0x34, 0x34, 0x14, 0x14, 0x00, 0x00, + 0x00, 0x1C, 0x30, 0x28, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x38, 0x38, 0x00, 0x00, 0x00, 0x10, 0x38, 0x10, 0x38, 0x38, 0x00, 0x00, + 0x00, 0x10, 0x38, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, + 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3C, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x10, 0x3C, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x10, 0x10, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x28, 0x28, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x3C, 0x28, 0x3C, 0x28, 0x00, 0x00, + 0x00, 0x18, 0x30, 0x10, 0x18, 0x30, 0x00, 0x00, 0x00, 0x28, 0x08, 0x10, + 0x20, 0x28, 0x00, 0x00, 0x00, 0x10, 0x28, 0x10, 0x30, 0x38, 0x00, 0x00, + 0x00, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x20, 0x20, + 0x20, 0x10, 0x00, 0x00, 0x00, 0x10, 0x08, 0x08, 0x08, 0x10, 0x00, 0x00, + 0x00, 0x00, 0x28, 0x10, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x10, 0x00, 0x00, 0x00, 0x08, 0x08, 0x10, 0x10, 0x20, 0x00, 0x00, + 0x00, 0x38, 0x28, 0x28, 0x28, 0x38, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x00, 0x00, 0x00, 0x38, 0x08, 0x38, 0x20, 0x38, 0x00, 0x00, + 0x00, 0x38, 0x08, 0x38, 0x08, 0x38, 0x00, 0x00, 0x00, 0x28, 0x28, 0x38, + 0x08, 0x08, 0x00, 0x00, 0x00, 0x38, 0x20, 0x38, 0x08, 0x38, 0x00, 0x00, + 0x00, 0x38, 0x20, 0x38, 0x28, 0x38, 0x00, 0x00, 0x00, 0x38, 0x08, 0x08, + 0x08, 0x08, 0x00, 0x00, 0x00, 0x38, 0x28, 0x38, 0x28, 0x38, 0x00, 0x00, + 0x00, 0x38, 0x28, 0x38, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x10, 0x20, 0x00, 0x00, + 0x00, 0x08, 0x10, 0x20, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, + 0x38, 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x08, 0x10, 0x20, 0x00, 0x00, + 0x00, 0x30, 0x08, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x38, 0x28, 0x38, + 0x30, 0x38, 0x00, 0x00, 0x00, 0x10, 0x28, 0x38, 0x28, 0x28, 0x00, 0x00, + 0x00, 0x30, 0x28, 0x30, 0x28, 0x30, 0x00, 0x00, 0x00, 0x18, 0x20, 0x20, + 0x20, 0x18, 0x00, 0x00, 0x00, 0x30, 0x28, 0x28, 0x28, 0x30, 0x00, 0x00, + 0x00, 0x38, 0x20, 0x30, 0x20, 0x38, 0x00, 0x00, 0x00, 0x38, 0x20, 0x30, + 0x20, 0x20, 0x00, 0x00, 0x00, 0x38, 0x20, 0x28, 0x28, 0x38, 0x00, 0x00, + 0x00, 0x28, 0x28, 0x38, 0x28, 0x28, 0x00, 0x00, 0x00, 0x38, 0x10, 0x10, + 0x10, 0x38, 0x00, 0x00, 0x00, 0x38, 0x08, 0x08, 0x28, 0x18, 0x00, 0x00, + 0x00, 0x28, 0x28, 0x30, 0x28, 0x28, 0x00, 0x00, 0x00, 0x20, 0x20, 0x20, + 0x20, 0x38, 0x00, 0x00, 0x00, 0x28, 0x38, 0x38, 0x28, 0x28, 0x00, 0x00, + 0x00, 0x28, 0x38, 0x38, 0x38, 0x28, 0x00, 0x00, 0x00, 0x38, 0x28, 0x28, + 0x28, 0x38, 0x00, 0x00, 0x00, 0x38, 0x28, 0x38, 0x20, 0x20, 0x00, 0x00, + 0x00, 0x38, 0x28, 0x28, 0x38, 0x18, 0x00, 0x00, 0x00, 0x38, 0x28, 0x30, + 0x28, 0x28, 0x00, 0x00, 0x00, 0x38, 0x20, 0x38, 0x08, 0x38, 0x00, 0x00, + 0x00, 0x38, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x28, 0x28, 0x28, + 0x28, 0x38, 0x00, 0x00, 0x00, 0x28, 0x28, 0x28, 0x10, 0x10, 0x00, 0x00, + 0x00, 0x28, 0x28, 0x38, 0x38, 0x28, 0x00, 0x00, 0x00, 0x28, 0x28, 0x10, + 0x28, 0x28, 0x00, 0x00, 0x00, 0x28, 0x28, 0x38, 0x10, 0x10, 0x00, 0x00, + 0x00, 0x38, 0x08, 0x10, 0x20, 0x38, 0x00, 0x00, 0x00, 0x30, 0x20, 0x20, + 0x20, 0x30, 0x00, 0x00, 0x00, 0x20, 0x10, 0x10, 0x08, 0x08, 0x00, 0x00, + 0x00, 0x18, 0x08, 0x08, 0x08, 0x18, 0x00, 0x00, 0x00, 0x10, 0x28, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, + 0x00, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, + 0x28, 0x18, 0x00, 0x00, 0x00, 0x20, 0x20, 0x38, 0x28, 0x38, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x38, 0x20, 0x38, 0x00, 0x00, 0x00, 0x08, 0x08, 0x38, + 0x28, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x38, 0x18, 0x00, 0x00, + 0x00, 0x08, 0x10, 0x38, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x18, 0x28, + 0x18, 0x08, 0x30, 0x00, 0x00, 0x20, 0x20, 0x38, 0x28, 0x28, 0x00, 0x00, + 0x00, 0x00, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, + 0x10, 0x10, 0x20, 0x00, 0x00, 0x20, 0x20, 0x28, 0x30, 0x28, 0x00, 0x00, + 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x20, 0x38, + 0x38, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x28, 0x28, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x38, 0x28, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, + 0x28, 0x38, 0x20, 0x00, 0x00, 0x00, 0x00, 0x38, 0x28, 0x38, 0x08, 0x00, + 0x00, 0x00, 0x00, 0x38, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, + 0x10, 0x30, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x10, 0x10, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x28, 0x28, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, + 0x28, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x38, 0x38, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x28, 0x10, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, + 0x28, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x10, 0x18, 0x00, 0x00, + 0x00, 0x18, 0x10, 0x20, 0x10, 0x18, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, + 0x10, 0x10, 0x00, 0x00, 0x00, 0x30, 0x10, 0x08, 0x10, 0x30, 0x00, 0x00, + 0x00, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x28, + 0x38, 0x00, 0x00, 0x00, 0x00, 0x18, 0x20, 0x20, 0x20, 0x18, 0x30, 0x00, + 0x00, 0x28, 0x00, 0x28, 0x28, 0x18, 0x00, 0x00, 0x00, 0x18, 0x00, 0x18, + 0x38, 0x18, 0x00, 0x00, 0x00, 0x38, 0x00, 0x18, 0x28, 0x18, 0x00, 0x00, + 0x00, 0x28, 0x00, 0x18, 0x28, 0x18, 0x00, 0x00, 0x00, 0x30, 0x00, 0x18, + 0x28, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10, 0x18, 0x28, 0x18, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x38, 0x20, 0x38, 0x10, 0x00, 0x00, 0x38, 0x00, 0x18, + 0x38, 0x18, 0x00, 0x00, 0x00, 0x28, 0x00, 0x18, 0x38, 0x18, 0x00, 0x00, + 0x00, 0x30, 0x00, 0x18, 0x38, 0x18, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, + 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x10, 0x10, 0x00, 0x00, + 0x00, 0x00, 0x30, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x28, 0x10, 0x28, + 0x38, 0x28, 0x00, 0x00, 0x00, 0x10, 0x00, 0x10, 0x38, 0x28, 0x00, 0x00, + 0x00, 0x18, 0x00, 0x38, 0x30, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, + 0x28, 0x1C, 0x00, 0x00, 0x00, 0x1C, 0x28, 0x3C, 0x28, 0x2C, 0x00, 0x00, + 0x00, 0x38, 0x00, 0x38, 0x28, 0x38, 0x00, 0x00, 0x00, 0x28, 0x00, 0x38, + 0x28, 0x38, 0x00, 0x00, 0x00, 0x30, 0x00, 0x38, 0x28, 0x38, 0x00, 0x00, + 0x00, 0x38, 0x00, 0x28, 0x28, 0x18, 0x00, 0x00, 0x00, 0x30, 0x00, 0x28, + 0x28, 0x18, 0x00, 0x00, 0x00, 0x28, 0x00, 0x28, 0x28, 0x18, 0x30, 0x00, + 0x00, 0x28, 0x00, 0x38, 0x28, 0x38, 0x00, 0x00, 0x00, 0x28, 0x00, 0x28, + 0x28, 0x38, 0x00, 0x00, 0x00, 0x10, 0x38, 0x20, 0x38, 0x10, 0x00, 0x00, + 0x00, 0x18, 0x14, 0x30, 0x10, 0x3C, 0x00, 0x00, 0x00, 0x28, 0x10, 0x38, + 0x38, 0x10, 0x00, 0x00, 0x00, 0x30, 0x28, 0x3C, 0x28, 0x2C, 0x00, 0x00, + 0x00, 0x18, 0x10, 0x38, 0x10, 0x30, 0x00, 0x00, 0x00, 0x18, 0x00, 0x18, + 0x28, 0x18, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x10, 0x10, 0x00, 0x00, + 0x00, 0x18, 0x00, 0x38, 0x28, 0x38, 0x00, 0x00, 0x00, 0x18, 0x00, 0x28, + 0x28, 0x18, 0x00, 0x00, 0x00, 0x30, 0x00, 0x30, 0x28, 0x28, 0x00, 0x00, + 0x00, 0x38, 0x00, 0x28, 0x38, 0x28, 0x00, 0x00, 0x00, 0x18, 0x28, 0x18, + 0x00, 0x38, 0x00, 0x00, 0x00, 0x38, 0x28, 0x38, 0x00, 0x38, 0x00, 0x00, + 0x00, 0x10, 0x00, 0x10, 0x20, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x20, 0x28, 0x10, 0x38, 0x18, 0x00, 0x00, 0x00, 0x20, 0x28, 0x18, + 0x38, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x10, 0x10, 0x10, 0x00, 0x00, + 0x00, 0x00, 0x14, 0x28, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x14, + 0x28, 0x00, 0x00, 0x00, 0x00, 0x08, 0x20, 0x08, 0x20, 0x08, 0x20, 0x00, + 0x00, 0x14, 0x28, 0x14, 0x28, 0x14, 0x28, 0x00, 0x00, 0x34, 0x1C, 0x34, + 0x1C, 0x34, 0x1C, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, + 0x00, 0x10, 0x10, 0x30, 0x10, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x30, + 0x30, 0x10, 0x10, 0x00, 0x00, 0x18, 0x18, 0x38, 0x18, 0x18, 0x18, 0x00, + 0x00, 0x00, 0x00, 0x38, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x30, + 0x30, 0x10, 0x10, 0x00, 0x00, 0x18, 0x18, 0x38, 0x38, 0x18, 0x18, 0x00, + 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x38, + 0x38, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x38, 0x38, 0x00, 0x00, 0x00, + 0x00, 0x18, 0x18, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x30, + 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x10, 0x10, 0x10, 0x00, + 0x00, 0x10, 0x10, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x3C, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x10, 0x10, 0x10, 0x00, + 0x00, 0x10, 0x10, 0x1C, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x3C, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x3C, 0x10, 0x10, 0x10, 0x00, + 0x00, 0x10, 0x10, 0x1C, 0x1C, 0x10, 0x10, 0x00, 0x00, 0x18, 0x18, 0x1C, + 0x18, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x1C, 0x1C, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x1C, 0x1C, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x3C, + 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x3C, 0x18, 0x18, 0x00, + 0x00, 0x18, 0x18, 0x1C, 0x1C, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x3C, + 0x3C, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, + 0x00, 0x10, 0x10, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x3C, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x3C, 0x10, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x3C, 0x18, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x1C, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x1C, 0x1C, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x1C, 0x1C, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x1C, + 0x18, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x3C, 0x18, 0x18, 0x18, 0x00, + 0x00, 0x10, 0x10, 0x3C, 0x3C, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x30, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x10, 0x10, 0x10, 0x00, + 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3C, 0x3C, 0x3C, 0x00, 0x00, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, + 0x00, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x00, 0x00, 0x3C, 0x3C, 0x3C, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x28, 0x34, 0x00, 0x00, + 0x00, 0x30, 0x28, 0x30, 0x28, 0x30, 0x20, 0x00, 0x00, 0x38, 0x28, 0x20, + 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x18, 0x18, 0x00, 0x00, + 0x00, 0x38, 0x20, 0x10, 0x20, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, + 0x28, 0x10, 0x00, 0x00, 0x00, 0x00, 0x28, 0x28, 0x30, 0x20, 0x00, 0x00, + 0x00, 0x00, 0x14, 0x28, 0x08, 0x08, 0x00, 0x00, 0x00, 0x38, 0x10, 0x28, + 0x10, 0x38, 0x00, 0x00, 0x00, 0x10, 0x28, 0x38, 0x28, 0x10, 0x00, 0x00, + 0x00, 0x18, 0x24, 0x24, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x18, 0x10, 0x18, + 0x28, 0x38, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3C, 0x18, 0x00, 0x00, 0x00, + 0x00, 0x04, 0x18, 0x3C, 0x18, 0x20, 0x00, 0x00, 0x00, 0x18, 0x20, 0x30, + 0x20, 0x18, 0x00, 0x00, 0x00, 0x10, 0x28, 0x28, 0x28, 0x28, 0x00, 0x00, + 0x00, 0x38, 0x00, 0x38, 0x00, 0x38, 0x00, 0x00, 0x00, 0x10, 0x38, 0x10, + 0x00, 0x38, 0x00, 0x00, 0x00, 0x10, 0x08, 0x10, 0x00, 0x38, 0x00, 0x00, + 0x00, 0x10, 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x00, 0x10, 0x28, 0x20, + 0x20, 0x20, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x28, 0x10, 0x00, 0x00, + 0x00, 0x10, 0x00, 0x38, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x18, 0x38, + 0x30, 0x00, 0x00, 0x00, 0x00, 0x38, 0x28, 0x38, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x10, 0x10, 0x30, 0x10, 0x00, 0x00, + 0x00, 0x30, 0x28, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x10, 0x38, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x38, 0x38, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; diff --git a/polymer/build/src/sound.c b/polymer/build/src/sound.c index 50ae03eae..a43fe2b9a 100644 --- a/polymer/build/src/sound.c +++ b/polymer/build/src/sound.c @@ -61,7 +61,7 @@ static int F_CALLBACKAPI f_tell(unsigned int handle) } -void initsb(char dadigistat, char damusistat, long dasamplerate, char danumspeakers, char dabytespersample, char daintspersec, char daquality) +void initsb(char dadigistat, char damusistat, int dasamplerate, char danumspeakers, char dabytespersample, char daintspersec, char daquality) { char *s; int i,j; @@ -78,7 +78,8 @@ void initsb(char dadigistat, char damusistat, long dasamplerate, char danumspeak printOSD(" Linked version: %.02f\n", FMOD_VERSION); printOSD(" DLL version: %.02f\n", FSOUND_GetVersion()); - if (FSOUND_GetVersion() < FMOD_VERSION) { + if (FSOUND_GetVersion() < FMOD_VERSION) + { printOSD(" ... Failure: FMOD DLL too old! Sound disabled.\n"); return; } @@ -87,14 +88,18 @@ void initsb(char dadigistat, char damusistat, long dasamplerate, char danumspeak //FSOUND_SetOutput(FSOUND_OUTPUT_ASIO); - if (FSOUND_Init(dasamplerate, NUMCHANNELS, 0)) { + if (FSOUND_Init(dasamplerate, NUMCHANNELS, 0)) + { printOSD(" ... Success\n"); fmod_inited = 1; - } else { + } + else + { printOSD(" ... Failure: %s\n", FMOD_ErrorString(FSOUND_GetError())); } - switch (FSOUND_GetOutput()) { + switch (FSOUND_GetOutput()) + { case FSOUND_OUTPUT_NOSOUND: s = "No Sound"; break; case FSOUND_OUTPUT_WINMM: @@ -129,19 +134,20 @@ void initsb(char dadigistat, char damusistat, long dasamplerate, char danumspeak void uninitsb(void) { - if (fmod_inited) { + if (fmod_inited) + { FSOUND_Close(); fmod_inited = 0; } } -void setears(long daposx, long daposy, long daxvect, long dayvect) +void setears(int daposx, int daposy, int daxvect, int dayvect) { } -void wsayfollow(char *dafilename, long dafreq, long davol, long *daxplc, long *dayplc, char followstat) +void wsayfollow(char *dafilename, int dafreq, int davol, int *daxplc, int *dayplc, char followstat) { /* dafilename: @@ -164,13 +170,14 @@ void wsayfollow(char *dafilename, long dafreq, long davol, long *daxplc, long *d 1 = position follows an object */ unsigned char ch1, ch2; - long i, wavnum, bad, oldest=0, free=-1, ox, oy, x, y, vo; + int i, wavnum, bad, oldest=0, free=-1, ox, oy, x, y, vo; unsigned int oldestpos=0; int chan; if (fmod_inited == 0) return; - for (wavnum=numwaves-1;wavnum>=0;wavnum--) { + for (wavnum=numwaves-1;wavnum>=0;wavnum--) + { bad = 0; i = 0; @@ -178,25 +185,29 @@ void wsayfollow(char *dafilename, long dafreq, long davol, long *daxplc, long *d { ch1 = dafilename[i]; if ((ch1 >= 97) && (ch1 <= 123)) ch1 -= 32; ch2 = instname[wavnum][i]; if ((ch2 >= 97) && (ch2 <= 123)) ch2 -= 32; - if (ch1 != ch2) {bad = 1; break;} + if (ch1 != ch2) {bad = 1; break;} i++; } if (bad != 0) continue; - for (i=0; i oldestpos) { + if (FSOUND_GetCurrentPosition(channels[i]) > oldestpos) + { oldest = i; oldestpos = FSOUND_GetCurrentPosition(channels[i]); } } - if (free < 0) { + if (free < 0) + { FSOUND_StopSound(channels[oldest]); free = oldest; } @@ -214,10 +225,10 @@ void wsayfollow(char *dafilename, long dafreq, long davol, long *daxplc, long *d } -void wsay(char *dafilename, long dafreq, long volume1, long volume2) +void wsay(char *dafilename, int dafreq, int volume1, int volume2) { unsigned char ch1, ch2; - long i, j, bad, free=-1, oldest=0; + int i, j, bad, free=-1, oldest=0; unsigned int oldestpos=0; int chan; @@ -233,25 +244,29 @@ void wsay(char *dafilename, long dafreq, long volume1, long volume2) { ch1 = dafilename[j]; if ((ch1 >= 97) && (ch1 <= 123)) ch1 -= 32; ch2 = instname[i][j]; if ((ch2 >= 97) && (ch2 <= 123)) ch2 -= 32; - if (ch1 != ch2) {bad = 1; break;} + if (ch1 != ch2) {bad = 1; break;} j++; } if (bad == 0) { - for (j=0; j oldestpos) { + if (FSOUND_GetCurrentPosition(channels[j]) > oldestpos) + { oldest = j; oldestpos = FSOUND_GetCurrentPosition(channels[j]); } } - if (free < 0) { + if (free < 0) + { FSOUND_StopSound(channels[oldest]); free = oldest; } @@ -269,36 +284,42 @@ void wsay(char *dafilename, long dafreq, long volume1, long volume2) } i--; - } while (i >= 0); + } + while (i >= 0); } void loadwaves(void) { - long fil, dawaversionum, i, tmp; - long wavleng[MAXWAVES], repstart[MAXWAVES], repleng[MAXWAVES], finetune[MAXWAVES]; + int fil, dawaversionum, i, tmp; + int wavleng[MAXWAVES], repstart[MAXWAVES], repleng[MAXWAVES], finetune[MAXWAVES]; char *p; fil = kopen4load("WAVES.KWV", 0); - if (fil != -1) { + if (fil != -1) + { kread(fil, &dawaversionum, 4); dawaversionum = B_LITTLE32(dawaversionum); if (dawaversionum != 0) { kclose(fil); return; } kread(fil, &numwaves, 4); numwaves = B_LITTLE32(numwaves); - for (i=0; i= settings.bpp3d) i++; else break; } - for ( ; cd[i]; i++) { + for (i=0; cd[i];) { if (cd[i] >= settings.bpp3d) i++; else break; } + for (; cd[i]; i++) + { mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, cd[i], settings.fullscreen, 1); if (mode3d < 0) continue; settings.bpp3d = cd[i]; @@ -104,14 +107,16 @@ static void PopulateForm(void) gtk_list_store_clear(modes2d); gtk_list_store_clear(modes3d); - for (i=0; i aptr) gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)-1); @@ -566,7 +575,7 @@ int startwin_settitle(const char *title) { if (!gtkenabled) return 0; if (!startwin) return 1; - gtk_window_set_title (GTK_WINDOW (startwin), title); + gtk_window_set_title(GTK_WINDOW(startwin), title); return 0; } @@ -574,7 +583,7 @@ int startwin_idle(void *s) { if (!gtkenabled) return 0; //if (!startwin) return 1; - gtk_main_iteration_do (FALSE); + gtk_main_iteration_do(FALSE); return 0; } @@ -597,7 +606,8 @@ int startwin_run(void) gtk_main(); SetPage(TAB_MESSAGES); - if (retval) { + if (retval) + { fullscreen = settings.fullscreen; xdim2d = settings.xdim2d; ydim2d = settings.ydim2d; diff --git a/polymer/build/src/startwin.editor.c b/polymer/build/src/startwin.editor.c index f3e437f8b..4db284e75 100755 --- a/polymer/build/src/startwin.editor.c +++ b/polymer/build/src/startwin.editor.c @@ -19,7 +19,8 @@ #define TAB_CONFIG 0 #define TAB_MESSAGES 1 -static struct { +static struct +{ int fullscreen; int xdim2d, ydim2d; int xdim3d, ydim3d, bpp3d; @@ -43,10 +44,12 @@ static void PopulateForm(void) mode2d = checkvideomode(&settings.xdim2d, &settings.ydim2d, 8, settings.fullscreen, 1); mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, settings.bpp3d, settings.fullscreen, 1); if (mode2d < 0) mode2d = 0; - if (mode3d < 0) { + if (mode3d < 0) + { int cd[] = { 32, 24, 16, 15, 8, 0 }; - for (i=0; cd[i]; ) { if (cd[i] >= settings.bpp3d) i++; else break; } - for ( ; cd[i]; i++) { + for (i=0; cd[i];) { if (cd[i] >= settings.bpp3d) i++; else break; } + for (; cd[i]; i++) + { mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, cd[i], settings.fullscreen, 1); if (mode3d < 0) continue; settings.bpp3d = cd[i]; @@ -59,18 +62,19 @@ static void PopulateForm(void) ComboBox_ResetContent(hwnd2d); ComboBox_ResetContent(hwnd3d); - for (i=0; iidFrom != WIN_STARTWIN_TABCTL) break; cur = (int)SendMessage(nmhdr->hwndFrom, TCM_GETCURSEL,0,0); - switch (nmhdr->code) { - case TCN_SELCHANGING: { + switch (nmhdr->code) + { + case TCN_SELCHANGING: + { if (cur < 0 || !pages[cur]) break; ShowWindow(pages[cur],SW_HIDE); return TRUE; } - case TCN_SELCHANGE: { + case TCN_SELCHANGE: + { if (cur < 0 || !pages[cur]) break; ShowWindow(pages[cur],SW_SHOW); return TRUE; @@ -279,12 +295,14 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, return TRUE; case WM_DESTROY: - if (hbmp) { + if (hbmp) + { DeleteObject(hbmp); hbmp = NULL; } - if (pages[TAB_CONFIG]) { + if (pages[TAB_CONFIG]) + { DestroyWindow(pages[TAB_CONFIG]); pages[TAB_CONFIG] = NULL; } @@ -293,7 +311,8 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, return TRUE; case WM_COMMAND: - switch (LOWORD(wParam)) { + switch (LOWORD(wParam)) + { case WIN_STARTWIN_CANCEL: if (mode == TAB_CONFIG) done = 0; else quitevent++; @@ -324,7 +343,8 @@ int startwin_open(void) icc.dwICC = ICC_TAB_CLASSES; InitCommonControlsEx(&icc); startupdlg = CreateDialog((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(WIN_STARTWIN), NULL, startup_dlgproc); - if (startupdlg) { + if (startupdlg) + { SetPage(TAB_MESSAGES); EnableConfig(0); return 0; @@ -361,25 +381,33 @@ int startwin_puts(const char *buf) SendMessage(edctl, EM_SETSEL, (WPARAM)curlen, (LPARAM)curlen); linesbefore = SendMessage(edctl, EM_GETLINECOUNT, 0,0); p = buf; - while (*p) { - if (newline) { + while (*p) + { + if (newline) + { SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)"\r\n"); newline = 0; } q = p; while (*q && *q != '\n') q++; memcpy(workbuf, p, q-p); - if (*q == '\n') { - if (!q[1]) { + if (*q == '\n') + { + if (!q[1]) + { newline = 1; workbuf[q-p] = 0; - } else { + } + else + { workbuf[q-p] = '\r'; workbuf[q-p+1] = '\n'; workbuf[q-p+2] = 0; } p = q+1; - } else { + } + else + { workbuf[q-p] = 0; p = q; } @@ -424,8 +452,10 @@ int startwin_run(void) settings.forcesetup = forcesetup; PopulateForm(); - while (done < 0) { - switch (GetMessage(&msg, NULL, 0,0)) { + while (done < 0) + { + switch (GetMessage(&msg, NULL, 0,0)) + { case 0: done = 1; break; case -1: @@ -440,7 +470,8 @@ int startwin_run(void) SetPage(TAB_MESSAGES); EnableConfig(0); - if (done) { + if (done) + { fullscreen = settings.fullscreen; xdim2d = settings.xdim2d; ydim2d = settings.ydim2d; diff --git a/polymer/build/src/textfont.c b/polymer/build/src/textfont.c index 452b23475..bcab15eff 100644 --- a/polymer/build/src/textfont.c +++ b/polymer/build/src/textfont.c @@ -3,177 +3,178 @@ // Extracted from a Matrox Millenium // Generated by BIN2C.EXE by Jonathon Fowler -char textfont[2048] = { - // 2048 bytes - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x81, 0xA5, 0x81, - 0xBD, 0x99, 0x81, 0x7E, 0x7E, 0xFF, 0xDB, 0xFF, 0xC3, 0xE7, 0xFF, 0x7E, - 0x6C, 0xFE, 0xFE, 0xFE, 0x7C, 0x38, 0x10, 0x00, 0x10, 0x38, 0x7C, 0xFE, - 0x7C, 0x38, 0x10, 0x00, 0x38, 0x7C, 0x38, 0xFE, 0xFE, 0x7C, 0x38, 0x7C, - 0x10, 0x10, 0x38, 0x7C, 0xFE, 0x7C, 0x38, 0x7C, 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, 0x0F, 0x7D, 0xCC, 0xCC, 0xCC, 0x78, - 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x7E, 0x18, 0x3F, 0x33, 0x3F, 0x30, - 0x30, 0x70, 0xF0, 0xE0, 0x7F, 0x63, 0x7F, 0x63, 0x63, 0x67, 0xE6, 0xC0, - 0x99, 0x5A, 0x3C, 0xE7, 0xE7, 0x3C, 0x5A, 0x99, 0x80, 0xE0, 0xF8, 0xFE, - 0xF8, 0xE0, 0x80, 0x00, 0x02, 0x0E, 0x3E, 0xFE, 0x3E, 0x0E, 0x02, 0x00, - 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x7E, 0x3C, 0x18, 0x66, 0x66, 0x66, 0x66, - 0x66, 0x00, 0x66, 0x00, 0x7F, 0xDB, 0xDB, 0x7B, 0x1B, 0x1B, 0x1B, 0x00, - 0x3E, 0x63, 0x38, 0x6C, 0x6C, 0x38, 0xCC, 0x78, 0x00, 0x00, 0x00, 0x00, - 0x7E, 0x7E, 0x7E, 0x00, 0x18, 0x3C, 0x7E, 0x18, 0x7E, 0x3C, 0x18, 0xFF, - 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, - 0x7E, 0x3C, 0x18, 0x00, 0x00, 0x18, 0x0C, 0xFE, 0x0C, 0x18, 0x00, 0x00, - 0x00, 0x30, 0x60, 0xFE, 0x60, 0x30, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, - 0xC0, 0xFE, 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, - 0x30, 0x78, 0x78, 0x30, 0x30, 0x00, 0x30, 0x00, 0x6C, 0x6C, 0x6C, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x6C, 0x6C, 0xFE, 0x6C, 0xFE, 0x6C, 0x6C, 0x00, - 0x30, 0x7C, 0xC0, 0x78, 0x0C, 0xF8, 0x30, 0x00, 0x00, 0xC6, 0xCC, 0x18, - 0x30, 0x66, 0xC6, 0x00, 0x38, 0x6C, 0x38, 0x76, 0xDC, 0xCC, 0x76, 0x00, - 0x60, 0x60, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x30, 0x60, 0x60, - 0x60, 0x30, 0x18, 0x00, 0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0x60, 0x00, - 0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00, 0x00, 0x30, 0x30, 0xFC, - 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x60, - 0x00, 0x00, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x30, 0x30, 0x00, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0x80, 0x00, - 0x7C, 0xC6, 0xCE, 0xDE, 0xF6, 0xE6, 0x7C, 0x00, 0x30, 0x70, 0x30, 0x30, - 0x30, 0x30, 0xFC, 0x00, 0x78, 0xCC, 0x0C, 0x38, 0x60, 0xCC, 0xFC, 0x00, - 0x78, 0xCC, 0x0C, 0x38, 0x0C, 0xCC, 0x78, 0x00, 0x1C, 0x3C, 0x6C, 0xCC, - 0xFE, 0x0C, 0x1E, 0x00, 0xFC, 0xC0, 0xF8, 0x0C, 0x0C, 0xCC, 0x78, 0x00, - 0x38, 0x60, 0xC0, 0xF8, 0xCC, 0xCC, 0x78, 0x00, 0xFC, 0xCC, 0x0C, 0x18, - 0x30, 0x30, 0x30, 0x00, 0x78, 0xCC, 0xCC, 0x78, 0xCC, 0xCC, 0x78, 0x00, - 0x78, 0xCC, 0xCC, 0x7C, 0x0C, 0x18, 0x70, 0x00, 0x00, 0x30, 0x30, 0x00, - 0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x30, 0x60, - 0x18, 0x30, 0x60, 0xC0, 0x60, 0x30, 0x18, 0x00, 0x00, 0x00, 0xFC, 0x00, - 0x00, 0xFC, 0x00, 0x00, 0x60, 0x30, 0x18, 0x0C, 0x18, 0x30, 0x60, 0x00, - 0x78, 0xCC, 0x0C, 0x18, 0x30, 0x00, 0x30, 0x00, 0x7C, 0xC6, 0xDE, 0xDE, - 0xDE, 0xC0, 0x78, 0x00, 0x30, 0x78, 0xCC, 0xCC, 0xFC, 0xCC, 0xCC, 0x00, - 0xFC, 0x66, 0x66, 0x7C, 0x66, 0x66, 0xFC, 0x00, 0x3C, 0x66, 0xC0, 0xC0, - 0xC0, 0x66, 0x3C, 0x00, 0xF8, 0x6C, 0x66, 0x66, 0x66, 0x6C, 0xF8, 0x00, - 0xFE, 0x62, 0x68, 0x78, 0x68, 0x62, 0xFE, 0x00, 0xFE, 0x62, 0x68, 0x78, - 0x68, 0x60, 0xF0, 0x00, 0x3C, 0x66, 0xC0, 0xC0, 0xCE, 0x66, 0x3E, 0x00, - 0xCC, 0xCC, 0xCC, 0xFC, 0xCC, 0xCC, 0xCC, 0x00, 0x78, 0x30, 0x30, 0x30, - 0x30, 0x30, 0x78, 0x00, 0x1E, 0x0C, 0x0C, 0x0C, 0xCC, 0xCC, 0x78, 0x00, - 0xE6, 0x66, 0x6C, 0x78, 0x6C, 0x66, 0xE6, 0x00, 0xF0, 0x60, 0x60, 0x60, - 0x62, 0x66, 0xFE, 0x00, 0xC6, 0xEE, 0xFE, 0xFE, 0xD6, 0xC6, 0xC6, 0x00, - 0xC6, 0xE6, 0xF6, 0xDE, 0xCE, 0xC6, 0xC6, 0x00, 0x38, 0x6C, 0xC6, 0xC6, - 0xC6, 0x6C, 0x38, 0x00, 0xFC, 0x66, 0x66, 0x7C, 0x60, 0x60, 0xF0, 0x00, - 0x78, 0xCC, 0xCC, 0xCC, 0xDC, 0x78, 0x1C, 0x00, 0xFC, 0x66, 0x66, 0x7C, - 0x6C, 0x66, 0xE6, 0x00, 0x78, 0xCC, 0xE0, 0x70, 0x1C, 0xCC, 0x78, 0x00, - 0xFC, 0xB4, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, - 0xCC, 0xCC, 0xFC, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x00, - 0xC6, 0xC6, 0xC6, 0xD6, 0xFE, 0xEE, 0xC6, 0x00, 0xC6, 0xC6, 0x6C, 0x38, - 0x38, 0x6C, 0xC6, 0x00, 0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x30, 0x78, 0x00, - 0xFE, 0xC6, 0x8C, 0x18, 0x32, 0x66, 0xFE, 0x00, 0x78, 0x60, 0x60, 0x60, - 0x60, 0x60, 0x78, 0x00, 0xC0, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x02, 0x00, - 0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, 0x00, 0x10, 0x38, 0x6C, 0xC6, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, - 0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0C, - 0x7C, 0xCC, 0x76, 0x00, 0xE0, 0x60, 0x60, 0x7C, 0x66, 0x66, 0xDC, 0x00, - 0x00, 0x00, 0x78, 0xCC, 0xC0, 0xCC, 0x78, 0x00, 0x1C, 0x0C, 0x0C, 0x7C, - 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00, - 0x38, 0x6C, 0x60, 0xF0, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x76, 0xCC, - 0xCC, 0x7C, 0x0C, 0xF8, 0xE0, 0x60, 0x6C, 0x76, 0x66, 0x66, 0xE6, 0x00, - 0x30, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00, 0x0C, 0x00, 0x0C, 0x0C, - 0x0C, 0xCC, 0xCC, 0x78, 0xE0, 0x60, 0x66, 0x6C, 0x78, 0x6C, 0xE6, 0x00, - 0x70, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, 0x00, 0x00, 0xCC, 0xFE, - 0xFE, 0xD6, 0xC6, 0x00, 0x00, 0x00, 0xF8, 0xCC, 0xCC, 0xCC, 0xCC, 0x00, - 0x00, 0x00, 0x78, 0xCC, 0xCC, 0xCC, 0x78, 0x00, 0x00, 0x00, 0xDC, 0x66, - 0x66, 0x7C, 0x60, 0xF0, 0x00, 0x00, 0x76, 0xCC, 0xCC, 0x7C, 0x0C, 0x1E, - 0x00, 0x00, 0xDC, 0x76, 0x66, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x7C, 0xC0, - 0x78, 0x0C, 0xF8, 0x00, 0x10, 0x30, 0x7C, 0x30, 0x30, 0x34, 0x18, 0x00, - 0x00, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0xCC, 0xCC, - 0xCC, 0x78, 0x30, 0x00, 0x00, 0x00, 0xC6, 0xD6, 0xFE, 0xFE, 0x6C, 0x00, - 0x00, 0x00, 0xC6, 0x6C, 0x38, 0x6C, 0xC6, 0x00, 0x00, 0x00, 0xCC, 0xCC, - 0xCC, 0x7C, 0x0C, 0xF8, 0x00, 0x00, 0xFC, 0x98, 0x30, 0x64, 0xFC, 0x00, - 0x1C, 0x30, 0x30, 0xE0, 0x30, 0x30, 0x1C, 0x00, 0x18, 0x18, 0x18, 0x00, - 0x18, 0x18, 0x18, 0x00, 0xE0, 0x30, 0x30, 0x1C, 0x30, 0x30, 0xE0, 0x00, - 0x76, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6C, - 0xC6, 0xC6, 0xFE, 0x00, 0x78, 0xCC, 0xC0, 0xCC, 0x78, 0x18, 0x0C, 0x78, - 0x00, 0xCC, 0x00, 0xCC, 0xCC, 0xCC, 0x7E, 0x00, 0x1C, 0x00, 0x78, 0xCC, - 0xFC, 0xC0, 0x78, 0x00, 0x7E, 0xC3, 0x3C, 0x06, 0x3E, 0x66, 0x3F, 0x00, - 0xCC, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x7E, 0x00, 0xE0, 0x00, 0x78, 0x0C, - 0x7C, 0xCC, 0x7E, 0x00, 0x30, 0x30, 0x78, 0x0C, 0x7C, 0xCC, 0x7E, 0x00, - 0x00, 0x00, 0x78, 0xC0, 0xC0, 0x78, 0x0C, 0x38, 0x7E, 0xC3, 0x3C, 0x66, - 0x7E, 0x60, 0x3C, 0x00, 0xCC, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00, - 0xE0, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00, 0xCC, 0x00, 0x70, 0x30, - 0x30, 0x30, 0x78, 0x00, 0x7C, 0xC6, 0x38, 0x18, 0x18, 0x18, 0x3C, 0x00, - 0xE0, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00, 0xC6, 0x38, 0x6C, 0xC6, - 0xFE, 0xC6, 0xC6, 0x00, 0x30, 0x30, 0x00, 0x78, 0xCC, 0xFC, 0xCC, 0x00, - 0x1C, 0x00, 0xFC, 0x60, 0x78, 0x60, 0xFC, 0x00, 0x00, 0x00, 0x7F, 0x0C, - 0x7F, 0xCC, 0x7F, 0x00, 0x3E, 0x6C, 0xCC, 0xFE, 0xCC, 0xCC, 0xCE, 0x00, - 0x78, 0xCC, 0x00, 0x78, 0xCC, 0xCC, 0x78, 0x00, 0x00, 0xCC, 0x00, 0x78, - 0xCC, 0xCC, 0x78, 0x00, 0x00, 0xE0, 0x00, 0x78, 0xCC, 0xCC, 0x78, 0x00, - 0x78, 0xCC, 0x00, 0xCC, 0xCC, 0xCC, 0x7E, 0x00, 0x00, 0xE0, 0x00, 0xCC, - 0xCC, 0xCC, 0x7E, 0x00, 0x00, 0xCC, 0x00, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8, - 0xC3, 0x18, 0x3C, 0x66, 0x66, 0x3C, 0x18, 0x00, 0xCC, 0x00, 0xCC, 0xCC, - 0xCC, 0xCC, 0x78, 0x00, 0x18, 0x18, 0x7E, 0xC0, 0xC0, 0x7E, 0x18, 0x18, - 0x38, 0x6C, 0x64, 0xF0, 0x60, 0xE6, 0xFC, 0x00, 0xCC, 0xCC, 0x78, 0xFC, - 0x30, 0xFC, 0x30, 0x30, 0xF8, 0xCC, 0xCC, 0xFA, 0xC6, 0xCF, 0xC6, 0xC7, - 0x0E, 0x1B, 0x18, 0x3C, 0x18, 0x18, 0xD8, 0x70, 0x1C, 0x00, 0x78, 0x0C, - 0x7C, 0xCC, 0x7E, 0x00, 0x38, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00, - 0x00, 0x1C, 0x00, 0x78, 0xCC, 0xCC, 0x78, 0x00, 0x00, 0x1C, 0x00, 0xCC, - 0xCC, 0xCC, 0x7E, 0x00, 0x00, 0xF8, 0x00, 0xF8, 0xCC, 0xCC, 0xCC, 0x00, - 0xFC, 0x00, 0xCC, 0xEC, 0xFC, 0xDC, 0xCC, 0x00, 0x3C, 0x6C, 0x6C, 0x3E, - 0x00, 0x7E, 0x00, 0x00, 0x38, 0x6C, 0x6C, 0x38, 0x00, 0x7C, 0x00, 0x00, - 0x30, 0x00, 0x30, 0x60, 0xC0, 0xCC, 0x78, 0x00, 0x00, 0x00, 0x00, 0xFC, - 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x0C, 0x0C, 0x00, 0x00, - 0xC3, 0xC6, 0xCC, 0xDE, 0x33, 0x66, 0xCC, 0x0F, 0xC3, 0xC6, 0xCC, 0xDB, - 0x37, 0x6F, 0xCF, 0x03, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00, - 0x00, 0x33, 0x66, 0xCC, 0x66, 0x33, 0x00, 0x00, 0x00, 0xCC, 0x66, 0x33, - 0x66, 0xCC, 0x00, 0x00, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, - 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0xDB, 0x77, 0xDB, 0xEE, - 0xDB, 0x77, 0xDB, 0xEE, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x18, 0xF8, 0x18, 0x18, 0x18, 0x18, 0x18, 0xF8, 0x18, - 0xF8, 0x18, 0x18, 0x18, 0x36, 0x36, 0x36, 0x36, 0xF6, 0x36, 0x36, 0x36, - 0x00, 0x00, 0x00, 0x00, 0xFE, 0x36, 0x36, 0x36, 0x00, 0x00, 0xF8, 0x18, - 0xF8, 0x18, 0x18, 0x18, 0x36, 0x36, 0xF6, 0x06, 0xF6, 0x36, 0x36, 0x36, - 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0xFE, 0x06, - 0xF6, 0x36, 0x36, 0x36, 0x36, 0x36, 0xF6, 0x06, 0xFE, 0x00, 0x00, 0x00, - 0x36, 0x36, 0x36, 0x36, 0xFE, 0x00, 0x00, 0x00, 0x18, 0x18, 0xF8, 0x18, - 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x18, 0x1F, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, - 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x18, 0x1F, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0xFF, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x1F, 0x18, 0x1F, 0x18, 0x18, 0x18, 0x36, 0x36, 0x36, 0x36, - 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x3F, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x3F, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0xF7, 0x00, - 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xF7, 0x36, 0x36, 0x36, - 0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36, 0x00, 0x00, 0xFF, 0x00, - 0xFF, 0x00, 0x00, 0x00, 0x36, 0x36, 0xF7, 0x00, 0xF7, 0x36, 0x36, 0x36, - 0x18, 0x18, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x36, 0x36, 0x36, 0x36, - 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x18, 0x18, 0x18, - 0x00, 0x00, 0x00, 0x00, 0xFF, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, - 0x3F, 0x00, 0x00, 0x00, 0x18, 0x18, 0x1F, 0x18, 0x1F, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x1F, 0x18, 0x1F, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, - 0x3F, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xFF, 0x36, 0x36, 0x36, - 0x18, 0x18, 0xFF, 0x18, 0xFF, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x18, 0x18, 0x18, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 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, 0xDC, 0xC8, 0xDC, 0x76, 0x00, - 0x00, 0x78, 0xCC, 0xF8, 0xCC, 0xF8, 0xC0, 0xC0, 0x00, 0xFC, 0xCC, 0xC0, - 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0xFE, 0x6C, 0x6C, 0x6C, 0x6C, 0x6C, 0x00, - 0xFC, 0xCC, 0x60, 0x30, 0x60, 0xCC, 0xFC, 0x00, 0x00, 0x00, 0x7E, 0xD8, - 0xD8, 0xD8, 0x70, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x7C, 0x60, 0xC0, - 0x00, 0x76, 0xDC, 0x18, 0x18, 0x18, 0x18, 0x00, 0xFC, 0x30, 0x78, 0xCC, - 0xCC, 0x78, 0x30, 0xFC, 0x38, 0x6C, 0xC6, 0xFE, 0xC6, 0x6C, 0x38, 0x00, - 0x38, 0x6C, 0xC6, 0xC6, 0x6C, 0x6C, 0xEE, 0x00, 0x1C, 0x30, 0x18, 0x7C, - 0xCC, 0xCC, 0x78, 0x00, 0x00, 0x00, 0x7E, 0xDB, 0xDB, 0x7E, 0x00, 0x00, - 0x06, 0x0C, 0x7E, 0xDB, 0xDB, 0x7E, 0x60, 0xC0, 0x38, 0x60, 0xC0, 0xF8, - 0xC0, 0x60, 0x38, 0x00, 0x78, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x00, - 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0x00, 0x30, 0x30, 0xFC, 0x30, - 0x30, 0x00, 0xFC, 0x00, 0x60, 0x30, 0x18, 0x30, 0x60, 0x00, 0xFC, 0x00, - 0x18, 0x30, 0x60, 0x30, 0x18, 0x00, 0xFC, 0x00, 0x0E, 0x1B, 0x1B, 0x18, - 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xD8, 0xD8, 0x70, - 0x30, 0x30, 0x00, 0xFC, 0x00, 0x30, 0x30, 0x00, 0x00, 0x76, 0xDC, 0x00, - 0x76, 0xDC, 0x00, 0x00, 0x38, 0x6C, 0x6C, 0x38, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x18, 0x00, 0x00, 0x00, 0x0F, 0x0C, 0x0C, 0x0C, 0xEC, 0x6C, 0x3C, 0x1C, - 0x78, 0x6C, 0x6C, 0x6C, 0x6C, 0x00, 0x00, 0x00, 0x70, 0x18, 0x30, 0x60, - 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; +char textfont[2048] = +{ + // 2048 bytes + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x81, 0xA5, 0x81, + 0xBD, 0x99, 0x81, 0x7E, 0x7E, 0xFF, 0xDB, 0xFF, 0xC3, 0xE7, 0xFF, 0x7E, + 0x6C, 0xFE, 0xFE, 0xFE, 0x7C, 0x38, 0x10, 0x00, 0x10, 0x38, 0x7C, 0xFE, + 0x7C, 0x38, 0x10, 0x00, 0x38, 0x7C, 0x38, 0xFE, 0xFE, 0x7C, 0x38, 0x7C, + 0x10, 0x10, 0x38, 0x7C, 0xFE, 0x7C, 0x38, 0x7C, 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, 0x0F, 0x7D, 0xCC, 0xCC, 0xCC, 0x78, + 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x7E, 0x18, 0x3F, 0x33, 0x3F, 0x30, + 0x30, 0x70, 0xF0, 0xE0, 0x7F, 0x63, 0x7F, 0x63, 0x63, 0x67, 0xE6, 0xC0, + 0x99, 0x5A, 0x3C, 0xE7, 0xE7, 0x3C, 0x5A, 0x99, 0x80, 0xE0, 0xF8, 0xFE, + 0xF8, 0xE0, 0x80, 0x00, 0x02, 0x0E, 0x3E, 0xFE, 0x3E, 0x0E, 0x02, 0x00, + 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x7E, 0x3C, 0x18, 0x66, 0x66, 0x66, 0x66, + 0x66, 0x00, 0x66, 0x00, 0x7F, 0xDB, 0xDB, 0x7B, 0x1B, 0x1B, 0x1B, 0x00, + 0x3E, 0x63, 0x38, 0x6C, 0x6C, 0x38, 0xCC, 0x78, 0x00, 0x00, 0x00, 0x00, + 0x7E, 0x7E, 0x7E, 0x00, 0x18, 0x3C, 0x7E, 0x18, 0x7E, 0x3C, 0x18, 0xFF, + 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, + 0x7E, 0x3C, 0x18, 0x00, 0x00, 0x18, 0x0C, 0xFE, 0x0C, 0x18, 0x00, 0x00, + 0x00, 0x30, 0x60, 0xFE, 0x60, 0x30, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, + 0xC0, 0xFE, 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, + 0x30, 0x78, 0x78, 0x30, 0x30, 0x00, 0x30, 0x00, 0x6C, 0x6C, 0x6C, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x6C, 0x6C, 0xFE, 0x6C, 0xFE, 0x6C, 0x6C, 0x00, + 0x30, 0x7C, 0xC0, 0x78, 0x0C, 0xF8, 0x30, 0x00, 0x00, 0xC6, 0xCC, 0x18, + 0x30, 0x66, 0xC6, 0x00, 0x38, 0x6C, 0x38, 0x76, 0xDC, 0xCC, 0x76, 0x00, + 0x60, 0x60, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x30, 0x60, 0x60, + 0x60, 0x30, 0x18, 0x00, 0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0x60, 0x00, + 0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00, 0x00, 0x30, 0x30, 0xFC, + 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x60, + 0x00, 0x00, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x30, 0x30, 0x00, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0x80, 0x00, + 0x7C, 0xC6, 0xCE, 0xDE, 0xF6, 0xE6, 0x7C, 0x00, 0x30, 0x70, 0x30, 0x30, + 0x30, 0x30, 0xFC, 0x00, 0x78, 0xCC, 0x0C, 0x38, 0x60, 0xCC, 0xFC, 0x00, + 0x78, 0xCC, 0x0C, 0x38, 0x0C, 0xCC, 0x78, 0x00, 0x1C, 0x3C, 0x6C, 0xCC, + 0xFE, 0x0C, 0x1E, 0x00, 0xFC, 0xC0, 0xF8, 0x0C, 0x0C, 0xCC, 0x78, 0x00, + 0x38, 0x60, 0xC0, 0xF8, 0xCC, 0xCC, 0x78, 0x00, 0xFC, 0xCC, 0x0C, 0x18, + 0x30, 0x30, 0x30, 0x00, 0x78, 0xCC, 0xCC, 0x78, 0xCC, 0xCC, 0x78, 0x00, + 0x78, 0xCC, 0xCC, 0x7C, 0x0C, 0x18, 0x70, 0x00, 0x00, 0x30, 0x30, 0x00, + 0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x30, 0x60, + 0x18, 0x30, 0x60, 0xC0, 0x60, 0x30, 0x18, 0x00, 0x00, 0x00, 0xFC, 0x00, + 0x00, 0xFC, 0x00, 0x00, 0x60, 0x30, 0x18, 0x0C, 0x18, 0x30, 0x60, 0x00, + 0x78, 0xCC, 0x0C, 0x18, 0x30, 0x00, 0x30, 0x00, 0x7C, 0xC6, 0xDE, 0xDE, + 0xDE, 0xC0, 0x78, 0x00, 0x30, 0x78, 0xCC, 0xCC, 0xFC, 0xCC, 0xCC, 0x00, + 0xFC, 0x66, 0x66, 0x7C, 0x66, 0x66, 0xFC, 0x00, 0x3C, 0x66, 0xC0, 0xC0, + 0xC0, 0x66, 0x3C, 0x00, 0xF8, 0x6C, 0x66, 0x66, 0x66, 0x6C, 0xF8, 0x00, + 0xFE, 0x62, 0x68, 0x78, 0x68, 0x62, 0xFE, 0x00, 0xFE, 0x62, 0x68, 0x78, + 0x68, 0x60, 0xF0, 0x00, 0x3C, 0x66, 0xC0, 0xC0, 0xCE, 0x66, 0x3E, 0x00, + 0xCC, 0xCC, 0xCC, 0xFC, 0xCC, 0xCC, 0xCC, 0x00, 0x78, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x78, 0x00, 0x1E, 0x0C, 0x0C, 0x0C, 0xCC, 0xCC, 0x78, 0x00, + 0xE6, 0x66, 0x6C, 0x78, 0x6C, 0x66, 0xE6, 0x00, 0xF0, 0x60, 0x60, 0x60, + 0x62, 0x66, 0xFE, 0x00, 0xC6, 0xEE, 0xFE, 0xFE, 0xD6, 0xC6, 0xC6, 0x00, + 0xC6, 0xE6, 0xF6, 0xDE, 0xCE, 0xC6, 0xC6, 0x00, 0x38, 0x6C, 0xC6, 0xC6, + 0xC6, 0x6C, 0x38, 0x00, 0xFC, 0x66, 0x66, 0x7C, 0x60, 0x60, 0xF0, 0x00, + 0x78, 0xCC, 0xCC, 0xCC, 0xDC, 0x78, 0x1C, 0x00, 0xFC, 0x66, 0x66, 0x7C, + 0x6C, 0x66, 0xE6, 0x00, 0x78, 0xCC, 0xE0, 0x70, 0x1C, 0xCC, 0x78, 0x00, + 0xFC, 0xB4, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, + 0xCC, 0xCC, 0xFC, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x00, + 0xC6, 0xC6, 0xC6, 0xD6, 0xFE, 0xEE, 0xC6, 0x00, 0xC6, 0xC6, 0x6C, 0x38, + 0x38, 0x6C, 0xC6, 0x00, 0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x30, 0x78, 0x00, + 0xFE, 0xC6, 0x8C, 0x18, 0x32, 0x66, 0xFE, 0x00, 0x78, 0x60, 0x60, 0x60, + 0x60, 0x60, 0x78, 0x00, 0xC0, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x02, 0x00, + 0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, 0x00, 0x10, 0x38, 0x6C, 0xC6, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, + 0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0C, + 0x7C, 0xCC, 0x76, 0x00, 0xE0, 0x60, 0x60, 0x7C, 0x66, 0x66, 0xDC, 0x00, + 0x00, 0x00, 0x78, 0xCC, 0xC0, 0xCC, 0x78, 0x00, 0x1C, 0x0C, 0x0C, 0x7C, + 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00, + 0x38, 0x6C, 0x60, 0xF0, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x76, 0xCC, + 0xCC, 0x7C, 0x0C, 0xF8, 0xE0, 0x60, 0x6C, 0x76, 0x66, 0x66, 0xE6, 0x00, + 0x30, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00, 0x0C, 0x00, 0x0C, 0x0C, + 0x0C, 0xCC, 0xCC, 0x78, 0xE0, 0x60, 0x66, 0x6C, 0x78, 0x6C, 0xE6, 0x00, + 0x70, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, 0x00, 0x00, 0xCC, 0xFE, + 0xFE, 0xD6, 0xC6, 0x00, 0x00, 0x00, 0xF8, 0xCC, 0xCC, 0xCC, 0xCC, 0x00, + 0x00, 0x00, 0x78, 0xCC, 0xCC, 0xCC, 0x78, 0x00, 0x00, 0x00, 0xDC, 0x66, + 0x66, 0x7C, 0x60, 0xF0, 0x00, 0x00, 0x76, 0xCC, 0xCC, 0x7C, 0x0C, 0x1E, + 0x00, 0x00, 0xDC, 0x76, 0x66, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x7C, 0xC0, + 0x78, 0x0C, 0xF8, 0x00, 0x10, 0x30, 0x7C, 0x30, 0x30, 0x34, 0x18, 0x00, + 0x00, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0xCC, 0xCC, + 0xCC, 0x78, 0x30, 0x00, 0x00, 0x00, 0xC6, 0xD6, 0xFE, 0xFE, 0x6C, 0x00, + 0x00, 0x00, 0xC6, 0x6C, 0x38, 0x6C, 0xC6, 0x00, 0x00, 0x00, 0xCC, 0xCC, + 0xCC, 0x7C, 0x0C, 0xF8, 0x00, 0x00, 0xFC, 0x98, 0x30, 0x64, 0xFC, 0x00, + 0x1C, 0x30, 0x30, 0xE0, 0x30, 0x30, 0x1C, 0x00, 0x18, 0x18, 0x18, 0x00, + 0x18, 0x18, 0x18, 0x00, 0xE0, 0x30, 0x30, 0x1C, 0x30, 0x30, 0xE0, 0x00, + 0x76, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6C, + 0xC6, 0xC6, 0xFE, 0x00, 0x78, 0xCC, 0xC0, 0xCC, 0x78, 0x18, 0x0C, 0x78, + 0x00, 0xCC, 0x00, 0xCC, 0xCC, 0xCC, 0x7E, 0x00, 0x1C, 0x00, 0x78, 0xCC, + 0xFC, 0xC0, 0x78, 0x00, 0x7E, 0xC3, 0x3C, 0x06, 0x3E, 0x66, 0x3F, 0x00, + 0xCC, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x7E, 0x00, 0xE0, 0x00, 0x78, 0x0C, + 0x7C, 0xCC, 0x7E, 0x00, 0x30, 0x30, 0x78, 0x0C, 0x7C, 0xCC, 0x7E, 0x00, + 0x00, 0x00, 0x78, 0xC0, 0xC0, 0x78, 0x0C, 0x38, 0x7E, 0xC3, 0x3C, 0x66, + 0x7E, 0x60, 0x3C, 0x00, 0xCC, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00, + 0xE0, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00, 0xCC, 0x00, 0x70, 0x30, + 0x30, 0x30, 0x78, 0x00, 0x7C, 0xC6, 0x38, 0x18, 0x18, 0x18, 0x3C, 0x00, + 0xE0, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00, 0xC6, 0x38, 0x6C, 0xC6, + 0xFE, 0xC6, 0xC6, 0x00, 0x30, 0x30, 0x00, 0x78, 0xCC, 0xFC, 0xCC, 0x00, + 0x1C, 0x00, 0xFC, 0x60, 0x78, 0x60, 0xFC, 0x00, 0x00, 0x00, 0x7F, 0x0C, + 0x7F, 0xCC, 0x7F, 0x00, 0x3E, 0x6C, 0xCC, 0xFE, 0xCC, 0xCC, 0xCE, 0x00, + 0x78, 0xCC, 0x00, 0x78, 0xCC, 0xCC, 0x78, 0x00, 0x00, 0xCC, 0x00, 0x78, + 0xCC, 0xCC, 0x78, 0x00, 0x00, 0xE0, 0x00, 0x78, 0xCC, 0xCC, 0x78, 0x00, + 0x78, 0xCC, 0x00, 0xCC, 0xCC, 0xCC, 0x7E, 0x00, 0x00, 0xE0, 0x00, 0xCC, + 0xCC, 0xCC, 0x7E, 0x00, 0x00, 0xCC, 0x00, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8, + 0xC3, 0x18, 0x3C, 0x66, 0x66, 0x3C, 0x18, 0x00, 0xCC, 0x00, 0xCC, 0xCC, + 0xCC, 0xCC, 0x78, 0x00, 0x18, 0x18, 0x7E, 0xC0, 0xC0, 0x7E, 0x18, 0x18, + 0x38, 0x6C, 0x64, 0xF0, 0x60, 0xE6, 0xFC, 0x00, 0xCC, 0xCC, 0x78, 0xFC, + 0x30, 0xFC, 0x30, 0x30, 0xF8, 0xCC, 0xCC, 0xFA, 0xC6, 0xCF, 0xC6, 0xC7, + 0x0E, 0x1B, 0x18, 0x3C, 0x18, 0x18, 0xD8, 0x70, 0x1C, 0x00, 0x78, 0x0C, + 0x7C, 0xCC, 0x7E, 0x00, 0x38, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00, + 0x00, 0x1C, 0x00, 0x78, 0xCC, 0xCC, 0x78, 0x00, 0x00, 0x1C, 0x00, 0xCC, + 0xCC, 0xCC, 0x7E, 0x00, 0x00, 0xF8, 0x00, 0xF8, 0xCC, 0xCC, 0xCC, 0x00, + 0xFC, 0x00, 0xCC, 0xEC, 0xFC, 0xDC, 0xCC, 0x00, 0x3C, 0x6C, 0x6C, 0x3E, + 0x00, 0x7E, 0x00, 0x00, 0x38, 0x6C, 0x6C, 0x38, 0x00, 0x7C, 0x00, 0x00, + 0x30, 0x00, 0x30, 0x60, 0xC0, 0xCC, 0x78, 0x00, 0x00, 0x00, 0x00, 0xFC, + 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x0C, 0x0C, 0x00, 0x00, + 0xC3, 0xC6, 0xCC, 0xDE, 0x33, 0x66, 0xCC, 0x0F, 0xC3, 0xC6, 0xCC, 0xDB, + 0x37, 0x6F, 0xCF, 0x03, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00, + 0x00, 0x33, 0x66, 0xCC, 0x66, 0x33, 0x00, 0x00, 0x00, 0xCC, 0x66, 0x33, + 0x66, 0xCC, 0x00, 0x00, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, + 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0xDB, 0x77, 0xDB, 0xEE, + 0xDB, 0x77, 0xDB, 0xEE, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0xF8, 0x18, 0x18, 0x18, 0x18, 0x18, 0xF8, 0x18, + 0xF8, 0x18, 0x18, 0x18, 0x36, 0x36, 0x36, 0x36, 0xF6, 0x36, 0x36, 0x36, + 0x00, 0x00, 0x00, 0x00, 0xFE, 0x36, 0x36, 0x36, 0x00, 0x00, 0xF8, 0x18, + 0xF8, 0x18, 0x18, 0x18, 0x36, 0x36, 0xF6, 0x06, 0xF6, 0x36, 0x36, 0x36, + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0xFE, 0x06, + 0xF6, 0x36, 0x36, 0x36, 0x36, 0x36, 0xF6, 0x06, 0xFE, 0x00, 0x00, 0x00, + 0x36, 0x36, 0x36, 0x36, 0xFE, 0x00, 0x00, 0x00, 0x18, 0x18, 0xF8, 0x18, + 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x1F, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, + 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x1F, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, + 0xFF, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0xFF, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x1F, 0x18, 0x1F, 0x18, 0x18, 0x18, 0x36, 0x36, 0x36, 0x36, + 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x3F, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3F, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0xF7, 0x00, + 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xF7, 0x36, 0x36, 0x36, + 0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36, 0x00, 0x00, 0xFF, 0x00, + 0xFF, 0x00, 0x00, 0x00, 0x36, 0x36, 0xF7, 0x00, 0xF7, 0x36, 0x36, 0x36, + 0x18, 0x18, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x36, 0x36, 0x36, 0x36, + 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x18, 0x18, 0x18, + 0x00, 0x00, 0x00, 0x00, 0xFF, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, + 0x3F, 0x00, 0x00, 0x00, 0x18, 0x18, 0x1F, 0x18, 0x1F, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x1F, 0x18, 0x1F, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, + 0x3F, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xFF, 0x36, 0x36, 0x36, + 0x18, 0x18, 0xFF, 0x18, 0xFF, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x18, 0x18, 0x18, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 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, 0xDC, 0xC8, 0xDC, 0x76, 0x00, + 0x00, 0x78, 0xCC, 0xF8, 0xCC, 0xF8, 0xC0, 0xC0, 0x00, 0xFC, 0xCC, 0xC0, + 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0xFE, 0x6C, 0x6C, 0x6C, 0x6C, 0x6C, 0x00, + 0xFC, 0xCC, 0x60, 0x30, 0x60, 0xCC, 0xFC, 0x00, 0x00, 0x00, 0x7E, 0xD8, + 0xD8, 0xD8, 0x70, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x7C, 0x60, 0xC0, + 0x00, 0x76, 0xDC, 0x18, 0x18, 0x18, 0x18, 0x00, 0xFC, 0x30, 0x78, 0xCC, + 0xCC, 0x78, 0x30, 0xFC, 0x38, 0x6C, 0xC6, 0xFE, 0xC6, 0x6C, 0x38, 0x00, + 0x38, 0x6C, 0xC6, 0xC6, 0x6C, 0x6C, 0xEE, 0x00, 0x1C, 0x30, 0x18, 0x7C, + 0xCC, 0xCC, 0x78, 0x00, 0x00, 0x00, 0x7E, 0xDB, 0xDB, 0x7E, 0x00, 0x00, + 0x06, 0x0C, 0x7E, 0xDB, 0xDB, 0x7E, 0x60, 0xC0, 0x38, 0x60, 0xC0, 0xF8, + 0xC0, 0x60, 0x38, 0x00, 0x78, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x00, + 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0x00, 0x30, 0x30, 0xFC, 0x30, + 0x30, 0x00, 0xFC, 0x00, 0x60, 0x30, 0x18, 0x30, 0x60, 0x00, 0xFC, 0x00, + 0x18, 0x30, 0x60, 0x30, 0x18, 0x00, 0xFC, 0x00, 0x0E, 0x1B, 0x1B, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xD8, 0xD8, 0x70, + 0x30, 0x30, 0x00, 0xFC, 0x00, 0x30, 0x30, 0x00, 0x00, 0x76, 0xDC, 0x00, + 0x76, 0xDC, 0x00, 0x00, 0x38, 0x6C, 0x6C, 0x38, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x00, 0x00, 0x00, 0x0F, 0x0C, 0x0C, 0x0C, 0xEC, 0x6C, 0x3C, 0x1C, + 0x78, 0x6C, 0x6C, 0x6C, 0x6C, 0x00, 0x00, 0x00, 0x70, 0x18, 0x30, 0x60, + 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; diff --git a/polymer/build/src/util/bin2c.cpp b/polymer/build/src/util/bin2c.cpp index 7777bb0cd..7a02f8f6d 100644 --- a/polymer/build/src/util/bin2c.cpp +++ b/polymer/build/src/util/bin2c.cpp @@ -41,7 +41,7 @@ void main(int argc, char *argv[]) FILE *in, *out; char datab1, datab2; int across=0, maxacross; - long length, written=0; + int length, written=0; // get the source file diff --git a/polymer/build/src/util/cacheinfo.c b/polymer/build/src/util/cacheinfo.c index 07b5f68ff..251cbe1b1 100644 --- a/polymer/build/src/util/cacheinfo.c +++ b/polymer/build/src/util/cacheinfo.c @@ -11,14 +11,14 @@ typedef struct { char magic[8]; // 'Polymost' - long xdim, ydim; // of image, unpadded - long flags; // 1 = !2^x, 2 = has alpha, 4 = lzw compressed + int xdim, ydim; // of image, unpadded + int flags; // 1 = !2^x, 2 = has alpha, 4 = lzw compressed } texcacheheader; typedef struct { - long size; - long format; - long xdim, ydim; // of mipmap (possibly padded) - long border, depth; + int size; + int format; + int xdim, ydim; // of mipmap (possibly padded) + int border, depth; } texcachepicture; int main(int argc, char **argv) diff --git a/polymer/build/src/util/generateicon.c b/polymer/build/src/util/generateicon.c index c9d2341ea..dce95d047 100644 --- a/polymer/build/src/util/generateicon.c +++ b/polymer/build/src/util/generateicon.c @@ -50,8 +50,8 @@ int writeicon(FILE *fp, struct icon *ico) int main(int argc, char **argv) { struct icon icon; - long bpl, xsiz, ysiz; - long i,j,k,c; + int bpl, xsiz, ysiz; + int i,j,k,c; unsigned char *mask, *maskp, bm, *pp; if (argc<2) { @@ -61,7 +61,7 @@ int main(int argc, char **argv) memset(&icon, 0, sizeof(icon)); - kpzload(argv[1], (long*)&icon.pixels, &bpl, (long*)&icon.width, (long*)&icon.height); + kpzload(argv[1], (int*)&icon.pixels, &bpl, (int*)&icon.width, (int*)&icon.height); if (!icon.pixels) { fprintf(stderr, "Failure loading %s\n", argv[1]); return 1; diff --git a/polymer/build/src/util/kextract.c b/polymer/build/src/util/kextract.c index 5558fd823..af45e82ad 100644 --- a/polymer/build/src/util/kextract.c +++ b/polymer/build/src/util/kextract.c @@ -11,10 +11,10 @@ static char buf[65536]; -static long numfiles, anyfiles4extraction; +static int numfiles, anyfiles4extraction; static char marked4extraction[MAXFILES]; static char filelist[MAXFILES][16]; -static long fileoffs[MAXFILES+1], fileleng[MAXFILES]; +static int fileoffs[MAXFILES+1], fileleng[MAXFILES]; void findfiles(const char *dafilespec) { @@ -35,7 +35,7 @@ void findfiles(const char *dafilespec) int main(int argc, char **argv) { - long i, j, k, l, fil, fil2; + int i, j, k, l, fil, fil2; if (argc < 3) { @@ -63,14 +63,14 @@ int main(int argc, char **argv) printf("Error: %s not a valid group file\n",argv[1]); return(0); } - numfiles = *((long*)&buf[12]); numfiles = B_LITTLE32(numfiles); + numfiles = *((int*)&buf[12]); numfiles = B_LITTLE32(numfiles); Bread(fil,filelist,numfiles<<4); j = 0; for(i=0;iname, matchstr); } -long filesize(const char *path, const char *name) +int filesize(const char *path, const char *name) { char p[BMAX_PATH]; struct stat st; @@ -44,7 +44,7 @@ long filesize(const char *path, const char *name) void findfiles(const char *dafilespec) { struct Bdirent *name; - long daspeclen; + int daspeclen; char daspec[128], *dir; BDIR *di; @@ -91,7 +91,7 @@ void findfiles(const char *dafilespec) int main(int argc, char **argv) { - long i, j, k, l, fil, fil2; + int i, j, k, l, fil, fil2; if (argc < 3) { diff --git a/polymer/build/src/util/kmd2tool.c b/polymer/build/src/util/kmd2tool.c index 1da37fe4f..658d9e0e3 100644 --- a/polymer/build/src/util/kmd2tool.c +++ b/polymer/build/src/util/kmd2tool.c @@ -11,9 +11,9 @@ kmd2tool.exe: kmd2tool.c; cl kmd2tool.c /Ox /G6fy /MD /link /opt:nowin98 typedef struct { float x, y, z; } point3d; typedef struct -{ long id, vers, skinxsiz, skinysiz, framebytes; //id:"IPD2", vers:8 - long numskins, numverts, numuv, numtris, numglcmds, numframes; - long ofsskins, ofsuv, ofstris, ofsframes, ofsglcmds, ofseof; //ofsskins: skin names (64 bytes each) +{ int id, vers, skinxsiz, skinysiz, framebytes; //id:"IPD2", vers:8 + int numskins, numverts, numuv, numtris, numglcmds, numframes; + int ofsskins, ofsuv, ofstris, ofsframes, ofsglcmds, ofseof; //ofsskins: skin names (64 bytes each) } md2typ; typedef struct { point3d mul, add; } frametyp; @@ -21,7 +21,7 @@ typedef struct { point3d mul, add; } frametyp; int main (int argc, char **argv) { FILE *fil; - long i, leng; + int i, leng; char *fbuf; md2typ *head; frametyp *fptr; diff --git a/polymer/build/src/util/transpal.c b/polymer/build/src/util/transpal.c index f2e5218a6..616813fe9 100644 --- a/polymer/build/src/util/transpal.c +++ b/polymer/build/src/util/transpal.c @@ -10,25 +10,25 @@ #define MAXPALOOKUPS 256 -static long numpalookups, transratio; +static int numpalookups, transratio; static char palettefilename[13], origpalookup[MAXPALOOKUPS<<8]; static char palette[768], palookup[MAXPALOOKUPS<<8], transluc[65536]; static char closestcol[64][64][64]; #define FASTPALGRIDSIZ 8 -static long rdist[129], gdist[129], bdist[129]; +static int rdist[129], gdist[129], bdist[129]; static char colhere[((FASTPALGRIDSIZ+2)*(FASTPALGRIDSIZ+2)*(FASTPALGRIDSIZ+2))>>3]; static char colhead[(FASTPALGRIDSIZ+2)*(FASTPALGRIDSIZ+2)*(FASTPALGRIDSIZ+2)]; -static long colnext[256]; +static int colnext[256]; static char coldist[8] = {0,1,2,3,4,3,2,1}; -static long colscan[27]; +static int colscan[27]; -char getclosestcol(long r, long g, long b) +char getclosestcol(int r, int g, int b) { - long i, j, k, dist, mindist, retcol; - long *rlookup, *glookup, *blookup; + int i, j, k, dist, mindist, retcol; + int *rlookup, *glookup, *blookup; char *ptr; if (closestcol[r][g][b] != 255) return(closestcol[r][g][b]); @@ -38,9 +38,9 @@ char getclosestcol(long r, long g, long b) mindist = min(mindist,bdist[coldist[b&7]+64+8]); mindist++; - rlookup = (long *)&rdist[64-r]; - glookup = (long *)&gdist[64-g]; - blookup = (long *)&bdist[64-b]; + rlookup = (int *)&rdist[64-r]; + glookup = (int *)&gdist[64-g]; + blookup = (int *)&bdist[64-b]; retcol = -1; for(k=26;k>=0;k--) @@ -86,7 +86,7 @@ char getclosestcol(long r, long g, long b) char getpalookup(char dashade, char dacol) { - long r, g, b, t; + int r, g, b, t; char *ptr; ptr = (char *)&palette[dacol*3]; @@ -97,9 +97,9 @@ char getpalookup(char dashade, char dacol) return(getclosestcol(r,g,b)); } -char gettrans(char dat1, char dat2, long datransratio) +char gettrans(char dat1, char dat2, int datransratio) { - long r, g, b; + int r, g, b; char *ptr, *ptr2; ptr = (char *)&palette[dat1*3]; @@ -110,9 +110,9 @@ char gettrans(char dat1, char dat2, long datransratio) return(getclosestcol(r,g,b)); } -void initfastcolorlookup(long rscale, long gscale, long bscale) +void initfastcolorlookup(int rscale, int gscale, int bscale) { - long i, j, x, y, z; + int i, j, x, y, z; char *ptr; j = 0; @@ -149,7 +149,7 @@ int main(int argc, char **argv) { char col, ch; short orignumpalookups; - long fil, i, j, rscale, gscale, bscale; + int fil, i, j, rscale, gscale, bscale; char buf[65536]; ch = 13; @@ -203,7 +203,7 @@ int main(int argc, char **argv) Bread(fil,palette,768); Bread(fil,&orignumpalookups,2); orignumpalookups = B_LITTLE16(orignumpalookups); orignumpalookups = min(max(orignumpalookups,1),256); - Bread(fil,origpalookup,(long)orignumpalookups<<8); + Bread(fil,origpalookup,(int)orignumpalookups<<8); Bclose(fil); clearbuf(buf,65536>>2,0L); @@ -217,8 +217,8 @@ int main(int argc, char **argv) col = getpalookup((char)i,(char)j); palookup[(i<<8)+j] = col; - drawpixel(((((i<<1)+0)*320+(j+8))>>2)+buf,(long)col); - drawpixel(((((i<<1)+1)*320+(j+8))>>2)+buf,(long)col); + drawpixel(((((i<<1)+0)*320+(j+8))>>2)+buf,(int)col); + drawpixel(((((i<<1)+1)*320+(j+8))>>2)+buf,(int)col); } for(i=0;i<256;i++) @@ -235,7 +235,7 @@ int main(int argc, char **argv) col = gettrans((char)i,(char)j,transratio); transluc[(i<<8)+j] = col; - drawpixel((((j+132+8)*320+(i+8))>>2)+buf,(long)col); + drawpixel((((j+132+8)*320+(i+8))>>2)+buf,(int)col); } if (ch == 13) @@ -257,7 +257,7 @@ int main(int argc, char **argv) { printf("Couldn't save file %s",palettefilename); return(0); } Bwrite(fil,palette,768); s = B_LITTLE16(orignumpalookups); Bwrite(fil,&s,2); - Bwrite(fil,origpalookup,(long)orignumpalookups<<8); + Bwrite(fil,origpalookup,(int)orignumpalookups<<8); Bwrite(fil,transluc,65536); Bclose(fil); printf("Transluscent table updated\n"); diff --git a/polymer/build/src/util/wad2art.c b/polymer/build/src/util/wad2art.c index fd318011e..4de10dc76 100644 --- a/polymer/build/src/util/wad2art.c +++ b/polymer/build/src/util/wad2art.c @@ -10,11 +10,11 @@ #define MAXWADS 4096 -static long artversion, localtilestart, localtileend; -static long fil1, fil2; +static int artversion, localtilestart, localtileend; +static int fil1, fil2; static char wadata[MAXWADS][8]; -static long wadplc[MAXWADS], wadlen[MAXWADS], numwads; -static long xoffses[1024], ylookup[256], picanm[MAXWADS]; +static int wadplc[MAXWADS], wadlen[MAXWADS], numwads; +static int xoffses[1024], ylookup[256], picanm[MAXWADS]; static short tilesizx[MAXWADS], tilesizy[MAXWADS]; static char pal[768], palookup[8192]; static char screen[65536], tempbuf[131072]; @@ -22,19 +22,19 @@ static char screen[65536], tempbuf[131072]; void loadwadheader(void) { - long i, j; + int i, j; Bread(fil1,&tempbuf[0],12); - numwads = ((long)tempbuf[4])+(((long)tempbuf[5])<<8)+(((long)tempbuf[6])<<16)+(((long)tempbuf[7])<<24); - i = ((long)tempbuf[8])+(((long)tempbuf[9])<<8)+(((long)tempbuf[10])<<16)+(((long)tempbuf[11])<<24); + numwads = ((int)tempbuf[4])+(((int)tempbuf[5])<<8)+(((int)tempbuf[6])<<16)+(((int)tempbuf[7])<<24); + i = ((int)tempbuf[8])+(((int)tempbuf[9])<<8)+(((int)tempbuf[10])<<16)+(((int)tempbuf[11])<<24); Blseek(fil1,i,BSEEK_SET); Bread(fil1,&tempbuf[0],numwads*16); j = 0; for(i=0;i 320) || (ysiz > 200)) goto skipit; i = 8; for(zx=0;zx= fileng) return(-1); if ((filpos&16383) == 0) Bread(filhandle,filebuf,16384); filpos++; - return((long)filebuf[(filpos-1)&16383]); + return((int)filebuf[(filpos-1)&16383]); } -long readline(void) +int readline(void) { - long i, ch; + int i, ch; do { @@ -296,8 +296,8 @@ long readline(void) void parsescript(void) { - long i, j, k, l, lasti, breakout, tstart, tend, textnum, frontbackstat; - long spritenumstat, slen; + int i, j, k, l, lasti, breakout, tstart, tend, textnum, frontbackstat; + int spritenumstat, slen; char ch; clearbufbyte(FP_OFF(sectspri),MAXSECTS*8*sizeof(short),0xffffffff); @@ -730,37 +730,37 @@ void parsescript(void) close(filhandle); } -long getspritefield(long i, long fieldnum) +int getspritefield(int i, int fieldnum) { switch(fieldnum) { - case 0: return((long)sprite[i].x); - case 1: return((long)sprite[i].y); - case 2: return((long)sprite[i].z); - case 3: return((long)sprite[i].cstat); - case 4: return((long)sprite[i].shade); - case 5: return((long)sprite[i].pal); - case 6: return((long)sprite[i].clipdist); - case 7: return((long)sprite[i].xrepeat); - case 8: return((long)sprite[i].yrepeat); - case 9: return((long)sprite[i].xoffset); - case 10: return((long)sprite[i].yoffset); - case 11: return((long)sprite[i].picnum); - case 12: return((long)sprite[i].ang); - case 13: return((long)sprite[i].xvel); - case 14: return((long)sprite[i].yvel); - case 15: return((long)sprite[i].zvel); - case 16: return((long)sprite[i].owner); - case 17: return((long)sprite[i].sectnum); - case 18: return((long)sprite[i].statnum); - case 19: return((long)sprite[i].lotag); - case 20: return((long)sprite[i].hitag); - case 21: return((long)sprite[i].extra); + case 0: return((int)sprite[i].x); + case 1: return((int)sprite[i].y); + case 2: return((int)sprite[i].z); + case 3: return((int)sprite[i].cstat); + case 4: return((int)sprite[i].shade); + case 5: return((int)sprite[i].pal); + case 6: return((int)sprite[i].clipdist); + case 7: return((int)sprite[i].xrepeat); + case 8: return((int)sprite[i].yrepeat); + case 9: return((int)sprite[i].xoffset); + case 10: return((int)sprite[i].yoffset); + case 11: return((int)sprite[i].picnum); + case 12: return((int)sprite[i].ang); + case 13: return((int)sprite[i].xvel); + case 14: return((int)sprite[i].yvel); + case 15: return((int)sprite[i].zvel); + case 16: return((int)sprite[i].owner); + case 17: return((int)sprite[i].sectnum); + case 18: return((int)sprite[i].statnum); + case 19: return((int)sprite[i].lotag); + case 20: return((int)sprite[i].hitag); + case 21: return((int)sprite[i].extra); } return(0); } -void setspritefield(long i, long fieldnum, long newval) +void setspritefield(int i, int fieldnum, int newval) { switch(fieldnum) { @@ -789,32 +789,32 @@ void setspritefield(long i, long fieldnum, long newval) } } -long getwallfield(long i, long fieldnum) +int getwallfield(int i, int fieldnum) { switch(fieldnum) { - case 64: return((long)wall[i].x); - case 65: return((long)wall[i].y); - case 66: return((long)wall[i].point2); - case 67: return((long)wall[i].nextsector); - case 68: return((long)wall[i].nextwall); - case 69: return((long)wall[i].picnum); - case 70: return((long)wall[i].overpicnum); - case 71: return((long)wall[i].shade); - case 72: return((long)wall[i].pal); - case 73: return((long)wall[i].cstat); - case 74: return((long)wall[i].xrepeat); - case 75: return((long)wall[i].yrepeat); - case 76: return((long)wall[i].xpanning); - case 77: return((long)wall[i].ypanning); - case 78: return((long)wall[i].lotag); - case 79: return((long)wall[i].hitag); - case 80: return((long)wall[i].extra); + case 64: return((int)wall[i].x); + case 65: return((int)wall[i].y); + case 66: return((int)wall[i].point2); + case 67: return((int)wall[i].nextsector); + case 68: return((int)wall[i].nextwall); + case 69: return((int)wall[i].picnum); + case 70: return((int)wall[i].overpicnum); + case 71: return((int)wall[i].shade); + case 72: return((int)wall[i].pal); + case 73: return((int)wall[i].cstat); + case 74: return((int)wall[i].xrepeat); + case 75: return((int)wall[i].yrepeat); + case 76: return((int)wall[i].xpanning); + case 77: return((int)wall[i].ypanning); + case 78: return((int)wall[i].lotag); + case 79: return((int)wall[i].hitag); + case 80: return((int)wall[i].extra); } return(0); } -void setwallfield(long i, long fieldnum, long newval) +void setwallfield(int i, int fieldnum, int newval) { switch(fieldnum) { @@ -838,37 +838,37 @@ void setwallfield(long i, long fieldnum, long newval) } } -long getsectorfield(long i, long fieldnum) +int getsectorfield(int i, int fieldnum) { switch(fieldnum) { - case 32: return((long)sector[i].wallptr); - case 33: return((long)sector[i].wallnum); - case 34: return((long)sector[i].ceilingpicnum); - case 35: return((long)sector[i].floorpicnum); - case 36: return((long)sector[i].ceilingheinum); - case 37: return((long)sector[i].floorheinum); - case 38: return((long)sector[i].ceilingz); - case 39: return((long)sector[i].floorz); - case 40: return((long)sector[i].ceilingshade); - case 41: return((long)sector[i].floorshade); - case 42: return((long)sector[i].ceilingxpanning); - case 43: return((long)sector[i].floorxpanning); - case 44: return((long)sector[i].ceilingypanning); - case 45: return((long)sector[i].floorypanning); - case 46: return((long)sector[i].ceilingstat); - case 47: return((long)sector[i].floorstat); - case 48: return((long)sector[i].ceilingpal); - case 49: return((long)sector[i].floorpal); - case 50: return((long)sector[i].visibility); - case 51: return((long)sector[i].lotag); - case 52: return((long)sector[i].hitag); - case 53: return((long)sector[i].extra); + case 32: return((int)sector[i].wallptr); + case 33: return((int)sector[i].wallnum); + case 34: return((int)sector[i].ceilingpicnum); + case 35: return((int)sector[i].floorpicnum); + case 36: return((int)sector[i].ceilingheinum); + case 37: return((int)sector[i].floorheinum); + case 38: return((int)sector[i].ceilingz); + case 39: return((int)sector[i].floorz); + case 40: return((int)sector[i].ceilingshade); + case 41: return((int)sector[i].floorshade); + case 42: return((int)sector[i].ceilingxpanning); + case 43: return((int)sector[i].floorxpanning); + case 44: return((int)sector[i].ceilingypanning); + case 45: return((int)sector[i].floorypanning); + case 46: return((int)sector[i].ceilingstat); + case 47: return((int)sector[i].floorstat); + case 48: return((int)sector[i].ceilingpal); + case 49: return((int)sector[i].floorpal); + case 50: return((int)sector[i].visibility); + case 51: return((int)sector[i].lotag); + case 52: return((int)sector[i].hitag); + case 53: return((int)sector[i].extra); } return(0); } -void setsectorfield(long i, long fieldnum, long newval) +void setsectorfield(int i, int fieldnum, int newval) { switch(fieldnum) { @@ -897,9 +897,9 @@ void setsectorfield(long i, long fieldnum, long newval) } } -long getwadindex(char *nam) +int getwadindex(char *nam) { - long i, j; + int i, j; i = 0; for(j=2048;j>0;j>>=1) @@ -913,13 +913,13 @@ int main(int argc, char **argv) { char argstring[5][80]; char iwadfil[80], pwadfil[80], doommap[16], buildmap[16], picstr[16]; - long w, numwads, numtexts, startnumtexts, danumtexts, numpnames; - long x, y, z, zz, zzz, zzx, zx, cx, cy, gap, p, pp, i, j, k, l, offs; - long dnumpoints, dnumlines, dnumsides, dnumsectors, dnumthings, good; - long minx, maxx, miny, maxy, numsectors, numwalls, wadtype; - long startnumwalls, l1, l2, startpoint2, dapoint2, area; - long fil, ifil, pfil, x1, y1, x2, y2, startwall, endwall; - long mapversion, posx, posy, posz, templong, cnt, boardwadindex; + int w, numwads, numtexts, startnumtexts, danumtexts, numpnames; + int x, y, z, zz, zzz, zzx, zx, cx, cy, gap, p, pp, i, j, k, l, offs; + int dnumpoints, dnumlines, dnumsides, dnumsectors, dnumthings, good; + int minx, maxx, miny, maxy, numsectors, numwalls, wadtype; + int startnumwalls, l1, l2, startpoint2, dapoint2, area; + int fil, ifil, pfil, x1, y1, x2, y2, startwall, endwall; + int mapversion, posx, posy, posz, tempint, cnt, boardwadindex; short ang, cursectnum; printf("Wad2Map! Copyright 1995 by Ken Silverman\n"); @@ -991,9 +991,9 @@ int main(int argc, char **argv) { if ((z&1023) == 0) Bread(ifil,tempbuf,16384); zz = ((z&1023)<<4); - iwadplc[z] = ((long)tempbuf[zz]) + (((long)tempbuf[zz+1])<<8) + (((long)tempbuf[zz+2])<<16) + (((long)tempbuf[zz+3])<<24); + iwadplc[z] = ((int)tempbuf[zz]) + (((int)tempbuf[zz+1])<<8) + (((int)tempbuf[zz+2])<<16) + (((int)tempbuf[zz+3])<<24); zz += 4; - iwadlen[z] = ((long)tempbuf[zz]) + (((long)tempbuf[zz+1])<<8) + (((long)tempbuf[zz+2])<<16) + (((long)tempbuf[zz+3])<<24); + iwadlen[z] = ((int)tempbuf[zz]) + (((int)tempbuf[zz+1])<<8) + (((int)tempbuf[zz+2])<<16) + (((int)tempbuf[zz+3])<<24); zz += 4; iwadata[z][0] = tempbuf[zz+0]; iwadata[z][1] = tempbuf[zz+1]; iwadata[z][2] = tempbuf[zz+2]; iwadata[z][3] = tempbuf[zz+3]; @@ -1023,9 +1023,9 @@ int main(int argc, char **argv) { if ((z&1023) == 0) Bread(ifil,tempbuf,16384); zz = ((z&1023)<<4); - pwadplc[z] = ((long)tempbuf[zz]) + (((long)tempbuf[zz+1])<<8) + (((long)tempbuf[zz+2])<<16) + (((long)tempbuf[zz+3])<<24); + pwadplc[z] = ((int)tempbuf[zz]) + (((int)tempbuf[zz+1])<<8) + (((int)tempbuf[zz+2])<<16) + (((int)tempbuf[zz+3])<<24); zz += 4; - pwadlen[z] = ((long)tempbuf[zz]) + (((long)tempbuf[zz+1])<<8) + (((long)tempbuf[zz+2])<<16) + (((long)tempbuf[zz+3])<<24); + pwadlen[z] = ((int)tempbuf[zz]) + (((int)tempbuf[zz+1])<<8) + (((int)tempbuf[zz+2])<<16) + (((int)tempbuf[zz+3])<<24); zz += 4; pwadata[z][0] = tempbuf[zz+0]; pwadata[z][1] = tempbuf[zz+1]; pwadata[z][2] = tempbuf[zz+2]; pwadata[z][3] = tempbuf[zz+3]; @@ -1061,7 +1061,7 @@ int main(int argc, char **argv) { printf("TEXTURE1 not found!\n"); exit(0); } Blseek(ifil,iwadplc[w],BSEEK_SET); Bread(ifil,&numtexts,4); - Bread(ifil,textoffs,numtexts*sizeof(long)); + Bread(ifil,textoffs,numtexts*sizeof(int)); for(z=0;z= 0) @@ -1079,7 +1079,7 @@ int main(int argc, char **argv) Blseek(ifil,iwadplc[w],BSEEK_SET); startnumtexts = numtexts; Bread(ifil,&danumtexts,4); numtexts += danumtexts; - Bread(ifil,&textoffs[startnumtexts],(numtexts-startnumtexts)*sizeof(long)); + Bread(ifil,&textoffs[startnumtexts],(numtexts-startnumtexts)*sizeof(int)); for(z=startnumtexts;znumparms == 0) { + if (parm->numparms == 0) + { if (maxrefreshfreq == 0) OSD_Printf("\"maxrefreshfreq\" is \"No maximum\"\n"); else @@ -398,7 +429,8 @@ static int set_maxrefreshfreq(const osdfuncparm_t *parm) static int set_windowpos(const osdfuncparm_t *parm) { - if (parm->numparms == 0) { + if (parm->numparms == 0) + { OSD_Printf("\"r_windowpositioning\" is \"%d\"\n",windowpos); return OSDCMD_OK; } @@ -436,17 +468,17 @@ static void print_os_version(void) break; case 1: ver = "XP"; - break; + break; case 2: ver = "Server 2003"; break; } - break; + break; } if (osv.dwMajorVersion == 6 && osv.dwMinorVersion == 0) ver = "Vista"; break; - + case VER_PLATFORM_WIN32_WINDOWS: awful_windows_9x = 1; if (osv.dwMinorVersion < 10) @@ -501,7 +533,8 @@ int initsystem(void) print_os_version(); #if defined(USE_OPENGL) && defined(POLYMOST) - if (loadgldriver(getenv("BUILD_GLDRV"))) { + if (loadgldriver(getenv("BUILD_GLDRV"))) + { initprintf("Failed loading OpenGL driver. GL modes will be unavailable.\n"); nogl = 1; } @@ -585,7 +618,8 @@ int handleevents(void) //if (frameplace && fullscreen) printf("Offscreen buffer is locked!\n"); - while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { + while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) + { if (msg.message == WM_QUIT) quitevent = 1; @@ -629,52 +663,60 @@ static GUID guidDevs[NUM_INPUTS]; static char devacquired[NUM_INPUTS] = { 0,0,0 }; static HANDLE inputevt[NUM_INPUTS] = {0,0,0}; -static long joyblast=0; +static int joyblast=0; static char moustat = 0, mousegrab = 0; -static struct { +static struct +{ char *name; LPDIRECTINPUTDEVICE2A *did; const DIDATAFORMAT *df; -} devicedef[NUM_INPUTS] = { - { "keyboard", &lpDID[KEYBOARD], &c_dfDIKeyboard }, - { "mouse", &lpDID[MOUSE], &c_dfDIMouse }, - { "joystick", &lpDID[JOYSTICK], &c_dfDIJoystick } - }; -static struct _joydef { +} devicedef[NUM_INPUTS] = +{ + { "keyboard", &lpDID[KEYBOARD], &c_dfDIKeyboard }, + { "mouse", &lpDID[MOUSE], &c_dfDIMouse }, + { "joystick", &lpDID[JOYSTICK], &c_dfDIJoystick } +}; +static struct _joydef +{ const char *name; unsigned ofs; // directinput 'dwOfs' value } *axisdefs = NULL, *buttondefs = NULL, *hatdefs = NULL; -struct _joydevicefeature { +struct _joydevicefeature +{ unsigned int ofs; const char *name; }; -struct _joydevicedefn { - unsigned long devid; // is the value of DIDEVICEINSTANCE.guidProduct.Data1 +struct _joydevicedefn +{ + unsigned int devid; // is the value of DIDEVICEINSTANCE.guidProduct.Data1 int nfeatures; struct _joydevicefeature *features; }; // This is to give more realistic names to the buttons, axes, etc on a controller than // those the driver reports. Curse inconsistency. -struct _joydevicefeature joyfeatures_C20A046D[] = { // Logitech WingMan RumblePad USB - { 0, "Left Stick X" }, { 4, "Left Stick Y" }, { 8, "Right Stick X" }, - { 20, "Right Stick Y" }, { 24, "Throttle" }, - }; -struct _joydevicefeature joyfeatures_C218046D[] = { // Logitech RumblePad 2 USB - { 0, "Left Stick X" }, { 4, "Left Stick Y" }, { 8, "Right Stick X" }, - { 20, "Right Stick Y" }, { 32, "D-Pad" }, { 48, "Button 1" }, - { 49, "Button 2" }, { 50, "Button 3" }, { 51, "Button 4" }, - { 52, "Button 5" }, { 53, "Button 6" }, { 54, "Button 7" }, - { 55, "Button 8" }, { 56, "Button 9" }, { 57, "Button 10" }, - { 58, "Left Stick Press" }, { 59, "Right Stick Press" }, - }; +struct _joydevicefeature joyfeatures_C20A046D[] = // Logitech WingMan RumblePad USB +{ + { 0, "Left Stick X" }, { 4, "Left Stick Y" }, { 8, "Right Stick X" }, + { 20, "Right Stick Y" }, { 24, "Throttle" }, +}; +struct _joydevicefeature joyfeatures_C218046D[] = // Logitech RumblePad 2 USB +{ + { 0, "Left Stick X" }, { 4, "Left Stick Y" }, { 8, "Right Stick X" }, + { 20, "Right Stick Y" }, { 32, "D-Pad" }, { 48, "Button 1" }, + { 49, "Button 2" }, { 50, "Button 3" }, { 51, "Button 4" }, + { 52, "Button 5" }, { 53, "Button 6" }, { 54, "Button 7" }, + { 55, "Button 8" }, { 56, "Button 9" }, { 57, "Button 10" }, + { 58, "Left Stick Press" }, { 59, "Right Stick Press" }, +}; #define featurecount(x) (sizeof(x)/sizeof(struct _joydevicefeature)) -static struct _joydevicedefn *thisjoydef = NULL, joyfeatures[] = { - { 0xC20A046D, featurecount(joyfeatures_C20A046D), joyfeatures_C20A046D }, // Logitech WingMan RumblePad USB - { 0xC218046D, featurecount(joyfeatures_C218046D), joyfeatures_C218046D }, // Logitech RumblePad 2 USB - }; +static struct _joydevicedefn *thisjoydef = NULL, joyfeatures[] = +{ + { 0xC20A046D, featurecount(joyfeatures_C20A046D), joyfeatures_C20A046D }, // Logitech WingMan RumblePad USB + { 0xC218046D, featurecount(joyfeatures_C218046D), joyfeatures_C218046D }, // Logitech RumblePad 2 USB +}; #undef featurecount // I don't see any pressing need to store the key-up events yet @@ -745,9 +787,9 @@ void bflushchars(void) // // set{key|mouse|joy}presscallback() -- sets a callback which gets notified when keys are pressed // -void setkeypresscallback(void (*callback)(long, long)) { keypresscallback = callback; } -void setmousepresscallback(void (*callback)(long, long)) { mousepresscallback = callback; } -void setjoypresscallback(void (*callback)(long, long)) { joypresscallback = callback; } +void setkeypresscallback(void (*callback)(int, int)) { keypresscallback = callback; } +void setmousepresscallback(void (*callback)(int, int)) { mousepresscallback = callback; } +void setjoypresscallback(void (*callback)(int, int)) { joypresscallback = callback; } // @@ -798,7 +840,7 @@ void grabmouse(char a) // // readmousexy() -- return mouse motion information // -void readmousexy(long *x, long *y) +void readmousexy(int *x, int *y) { if (!moustat || !devacquired[MOUSE] || !mousegrab) { *x = *y = 0; return; } *x = mousex; @@ -811,7 +853,7 @@ void readmousexy(long *x, long *y) // // readmousebstatus() -- return mouse button information // -void readmousebstatus(long *b) +void readmousebstatus(int *b) { if (!moustat || !devacquired[MOUSE] || !mousegrab) *b = 0; else *b = mouseb; @@ -836,17 +878,21 @@ void setjoydeadzone(int axis, unsigned short dead, unsigned short satur) memset(&dipdw, 0, sizeof(dipdw)); dipdw.diph.dwSize = sizeof(DIPROPDWORD); dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); - if (axis < 0) { + if (axis < 0) + { dipdw.diph.dwObj = 0; dipdw.diph.dwHow = DIPH_DEVICE; - } else { + } + else + { dipdw.diph.dwObj = axisdefs[axis].ofs; dipdw.diph.dwHow = DIPH_BYOFFSET; } dipdw.dwData = dead; result = IDirectInputDevice2_SetProperty(lpDID[JOYSTICK], DIPROP_DEADZONE, &dipdw.diph); - if FAILED(result) { + if FAILED(result) + { //ShowDInputErrorBox("Failed setting joystick dead zone", result); initprintf("Failed setting joystick dead zone: %s\n", GetDInputError(result)); return; @@ -855,7 +901,8 @@ void setjoydeadzone(int axis, unsigned short dead, unsigned short satur) dipdw.dwData = satur; result = IDirectInputDevice2_SetProperty(lpDID[JOYSTICK], DIPROP_SATURATION, &dipdw.diph); - if FAILED(result) { + if FAILED(result) + { //ShowDInputErrorBox("Failed setting joystick saturation point", result); initprintf("Failed setting joystick saturation point: %s\n", GetDInputError(result)); return; @@ -872,22 +919,26 @@ void getjoydeadzone(int axis, unsigned short *dead, unsigned short *satur) HRESULT result; if (!dead || !satur) return; -if (!lpDID[JOYSTICK]) { *dead = *satur = 0; return; } + if (!lpDID[JOYSTICK]) { *dead = *satur = 0; return; } if (axis >= joynumaxes) { *dead = *satur = 0; return; } memset(&dipdw, 0, sizeof(dipdw)); dipdw.diph.dwSize = sizeof(DIPROPDWORD); dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); - if (axis < 0) { + if (axis < 0) + { dipdw.diph.dwObj = 0; dipdw.diph.dwHow = DIPH_DEVICE; - } else { + } + else + { dipdw.diph.dwObj = axisdefs[axis].ofs; dipdw.diph.dwHow = DIPH_BYOFFSET; } result = IDirectInputDevice2_GetProperty(lpDID[JOYSTICK], DIPROP_DEADZONE, &dipdw.diph); - if FAILED(result) { + if FAILED(result) + { //ShowDInputErrorBox("Failed getting joystick dead zone", result); initprintf("Failed getting joystick dead zone: %s\n", GetDInputError(result)); return; @@ -896,7 +947,8 @@ if (!lpDID[JOYSTICK]) { *dead = *satur = 0; return; } *dead = dipdw.dwData; result = IDirectInputDevice2_GetProperty(lpDID[JOYSTICK], DIPROP_SATURATION, &dipdw.diph); - if FAILED(result) { + if FAILED(result) + { //ShowDInputErrorBox("Failed getting joystick saturation point", result); initprintf("Failed getting joystick saturation point: %s\n", GetDInputError(result)); return; @@ -910,7 +962,8 @@ void releaseallbuttons(void) { int i; - if (mousepresscallback) { + if (mousepresscallback) + { if (mouseb & 1) mousepresscallback(1, 0); if (mouseb & 2) mousepresscallback(2, 0); if (mouseb & 4) mousepresscallback(3, 0); @@ -921,13 +974,15 @@ void releaseallbuttons(void) mousewheel[0]=mousewheel[1]=0; mouseb = 0; - if (joypresscallback) { + if (joypresscallback) + { for (i=0;i<32;i++) if (joyb & (1<dwDevType&0xff) { + switch (lpddi->dwDevType&0xff) + { case DIDEVTYPE_KEYBOARD: inputdevices |= (1<guidInstance); thisjoydef = NULL; - for (i=0; i<(int)(sizeof(joyfeatures)/sizeof(joyfeatures[0])); i++) { - if (lpddi->guidProduct.Data1 == joyfeatures[i].devid) { + for (i=0; i<(int)(sizeof(joyfeatures)/sizeof(joyfeatures[0])); i++) + { + if (lpddi->guidProduct.Data1 == joyfeatures[i].devid) + { thisjoydef = &joyfeatures[i]; break; } @@ -1001,7 +1059,8 @@ static const char *joyfindnameforofs(int ofs) { int i; if (!thisjoydef) return NULL; - for (i=0;infeatures;i++) { + for (i=0;infeatures;i++) + { if (ofs == (int)thisjoydef->features[i].ofs) return Bstrdup(thisjoydef->features[i].name); } @@ -1011,9 +1070,10 @@ static const char *joyfindnameforofs(int ofs) static BOOL CALLBACK InitDirectInput_enumobjects(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef) { unsigned i; - long *typecounts = (long*)pvRef; + int *typecounts = (int*)pvRef; - if (lpddoi->dwType & DIDFT_AXIS) { + if (lpddoi->dwType & DIDFT_AXIS) + { //initprintf(" Axis: %s (dwOfs=%d)\n", lpddoi->tszName, lpddoi->dwOfs); axisdefs[ typecounts[0] ].name = joyfindnameforofs(lpddoi->dwOfs); @@ -1022,7 +1082,9 @@ static BOOL CALLBACK InitDirectInput_enumobjects(LPCDIDEVICEOBJECTINSTANCE lpddo axisdefs[ typecounts[0] ].ofs = lpddoi->dwOfs; typecounts[0]++; - } else if (lpddoi->dwType & DIDFT_BUTTON) { + } + else if (lpddoi->dwType & DIDFT_BUTTON) + { //initprintf(" Button: %s (dwOfs=%d)\n", lpddoi->tszName, lpddoi->dwOfs); buttondefs[ typecounts[1] ].name = joyfindnameforofs(lpddoi->dwOfs); @@ -1031,7 +1093,9 @@ static BOOL CALLBACK InitDirectInput_enumobjects(LPCDIDEVICEOBJECTINSTANCE lpddo buttondefs[ typecounts[1] ].ofs = lpddoi->dwOfs; typecounts[1]++; - } else if (lpddoi->dwType & DIDFT_POV) { + } + else if (lpddoi->dwType & DIDFT_POV) + { //initprintf(" POV: %s (dwOfs=%d)\n", lpddoi->tszName, lpddoi->dwOfs); hatdefs[ typecounts[2] ].name = joyfindnameforofs(lpddoi->dwOfs); @@ -1053,7 +1117,7 @@ static BOOL CALLBACK InitDirectInput_enumobjects(LPCDIDEVICEOBJECTINSTANCE lpddo static BOOL InitDirectInput(void) { HRESULT result; - HRESULT (WINAPI *aDirectInputCreateA)(HINSTANCE, DWORD, LPDIRECTINPUTA *, LPUNKNOWN); + HRESULT(WINAPI *aDirectInputCreateA)(HINSTANCE, DWORD, LPDIRECTINPUTA *, LPUNKNOWN); DIPROPDWORD dipdw; LPDIRECTINPUTDEVICEA dev; LPDIRECTINPUTDEVICE2A dev2; @@ -1066,10 +1130,12 @@ static BOOL InitDirectInput(void) initprintf("Initialising DirectInput...\n"); // load up the DirectInput DLL - if (!hDInputDLL) { + if (!hDInputDLL) + { initprintf(" - Loading DINPUT.DLL\n"); hDInputDLL = LoadLibrary("DINPUT.DLL"); - if (!hDInputDLL) { + if (!hDInputDLL) + { ShowErrorBox("Error loading DINPUT.DLL"); return TRUE; } @@ -1082,16 +1148,17 @@ static BOOL InitDirectInput(void) // create a new DirectInput object initprintf(" - Creating DirectInput object\n"); result = aDirectInputCreateA(hInstance, DIRECTINPUT_VERSION, &lpDI, NULL); -if FAILED(result) { HorribleDInputDeath("DirectInputCreateA() failed", result); } + if FAILED(result) { HorribleDInputDeath("DirectInputCreateA() failed", result); } else if (result != DI_OK) initprintf(" Created DirectInput object with warning: %s\n",GetDInputError(result)); // enumerate devices to make us look fancy initprintf(" - Enumerating attached input devices\n"); inputdevices = 0; result = IDirectInput_EnumDevices(lpDI, 0, InitDirectInput_enum, NULL, DIEDFL_ATTACHEDONLY); -if FAILED(result) { HorribleDInputDeath("Failed enumerating attached input devices", result); } + if FAILED(result) { HorribleDInputDeath("Failed enumerating attached input devices", result); } else if (result != DI_OK) initprintf(" Enumerated input devices with warning: %s\n",GetDInputError(result)); - if (!(inputdevices & (1<=0; i--) if (axisdefs[i].name) free((void*)axisdefs[i].name); free(axisdefs); axisdefs = NULL; } - if (buttondefs) { + if (buttondefs) + { for (i=joynumbuttons-1; i>=0; i--) if (buttondefs[i].name) free((void*)buttondefs[i].name); free(buttondefs); buttondefs = NULL; } - if (hatdefs) { + if (hatdefs) + { for (i=joynumhats-1; i>=0; i--) if (hatdefs[i].name) free((void*)hatdefs[i].name); free(hatdefs); hatdefs = NULL; } - for (devn = 0; devn < NUM_INPUTS; devn++) { - if (*devicedef[devn].did) { + for (devn = 0; devn < NUM_INPUTS; devn++) + { + if (*devicedef[devn].did) + { initprintf(" - Releasing %s device\n", devicedef[devn].name); if (devn != JOYSTICK) IDirectInputDevice2_SetEventNotification(*devicedef[devn].did, NULL); @@ -1215,19 +1290,22 @@ static void UninitDirectInput(void) IDirectInputDevice2_Release(*devicedef[devn].did); *devicedef[devn].did = NULL; } - if (inputevt[devn]) { + if (inputevt[devn]) + { CloseHandle(inputevt[devn]); inputevt[devn] = NULL; } } - if (lpDI) { + if (lpDI) + { initprintf(" - Releasing DirectInput object\n"); IDirectInput_Release(lpDI); lpDI = NULL; } - if (hDInputDLL) { + if (hDInputDLL) + { initprintf(" - Unloading DINPUT.DLL\n"); FreeLibrary(hDInputDLL); hDInputDLL = NULL; @@ -1248,7 +1326,8 @@ static void GetKeyNames(void) char tbuf[MAX_PATH]; memset(keynames,0,sizeof(keynames)); - for (i=0;i<256;i++) { + for (i=0;i<256;i++) + { ZeroMemory(&key,sizeof(key)); key.dwSize = sizeof(DIDEVICEOBJECTINSTANCE); @@ -1268,7 +1347,8 @@ const unsigned char *getkeyname(int num) const unsigned char *getjoyname(int what, int num) { - switch (what) { + switch (what) + { case 0: // axis if ((unsigned)num > (unsigned)joynumaxes) return NULL; return (unsigned char *)axisdefs[num].name; @@ -1298,9 +1378,11 @@ static void AcquireInputDevices(char acquire, signed char device) if (!bDInputInited) return; if (!hWindow) return; - if (acquire) { + if (acquire) + { if (!appactive) return; // why acquire when inactive? - for (i=0; i 0 && t - mousewheel[0] > MouseWheelFakePressTime) { + if (mousegrab) + { + if (mousewheel[0] > 0 && t - mousewheel[0] > MouseWheelFakePressTime) + { if (mousepresscallback) mousepresscallback(5,0); mousewheel[0] = 0; mouseb &= ~16; } - if (mousewheel[1] > 0 && t - mousewheel[1] > MouseWheelFakePressTime) { + if (mousewheel[1] > 0 && t - mousewheel[1] > MouseWheelFakePressTime) + { if (mousepresscallback) mousepresscallback(6,0); mousewheel[1] = 0; mouseb &= ~32; } @@ -1394,20 +1489,24 @@ static void ProcessInputDevices(void) // use event objects so that we can quickly get indication of when data is ready // to be read and input events processed ev = MsgWaitForMultipleObjects(numdevs, waithnds, FALSE, 0, 0); - if (/*(ev >= WAIT_OBJECT_0) &&*/ (ev < (WAIT_OBJECT_0+numdevs))) { - switch (idevnums[ev - WAIT_OBJECT_0]) { + if (/*(ev >= WAIT_OBJECT_0) &&*/ (ev < (WAIT_OBJECT_0+numdevs))) + { + switch (idevnums[ev - WAIT_OBJECT_0]) + { case KEYBOARD: // keyboard if (!lpDID[KEYBOARD]) break; result = IDirectInputDevice2_GetDeviceData(lpDID[KEYBOARD], sizeof(DIDEVICEOBJECTDATA), (LPDIDEVICEOBJECTDATA)&didod, &dwElements, 0); - if (result == DI_OK) { + if (result == DI_OK) + { DWORD k, numlockon = FALSE; static DWORD shiftkey = 0, shiftkeycount = 0; numlockon = (GetKeyState(VK_NUMLOCK) & 1); // process the key events - for (i=0; i 0) { // wheel up + if ((int)didod[i].dwData > 0) // wheel up + { if (mousewheel[0] > 0 && mousepresscallback) mousepresscallback(5,0); mousewheel[0] = t; mouseb |= 16; if (mousepresscallback) mousepresscallback(5, 1); } - else if ((int)didod[i].dwData < 0) { // wheel down + else if ((int)didod[i].dwData < 0) // wheel down + { if (mousewheel[1] > 0 && mousepresscallback) mousepresscallback(6,0); mousewheel[1] = t; mouseb |= 32; if (mousepresscallback) mousepresscallback(6, 1); @@ -1493,12 +1599,15 @@ static void ProcessInputDevices(void) if (!lpDID[JOYSTICK]) break; result = IDirectInputDevice2_GetDeviceData(lpDID[JOYSTICK], sizeof(DIDEVICEOBJECTDATA), (LPDIDEVICEOBJECTDATA)&didod, &dwElements, 0); - if (result == DI_OK) { + if (result == DI_OK) + { int j; - for (i=0; i 0) { + if (lastKeyDown > 0) + { u = (1000 + t - lastKeyTime)%1000; - if ((u >= 250) && !(lastKeyDown&0x80000000l)) { + if ((u >= 250) && !(lastKeyDown&0x80000000l)) + { if (OSD_HandleKey(lastKeyDown, 1) != 0) SetKey(lastKeyDown, 1); lastKeyDown |= 0x80000000l; lastKeyTime = t; - } else if ((u >= 30) && (lastKeyDown&0x80000000l)) { + } + else if ((u >= 30) && (lastKeyDown&0x80000000l)) + { if (OSD_HandleKey(lastKeyDown&(0x7fffffffl), 1) != 0) SetKey(lastKeyDown&(0x7fffffffl), 1); lastKeyTime = t; @@ -1572,7 +1687,8 @@ static void ShowDInputErrorBox(const char *m, HRESULT r) // static const char * GetDInputError(HRESULT code) { - switch (code) { + switch (code) + { case DI_OK: return "DI_OK"; case DI_BUFFEROVERFLOW: @@ -1653,7 +1769,7 @@ static const char * GetDInputError(HRESULT code) //================================================================================================= static int64 timerfreq=0; -static long timerlastsample=0; +static int timerlastsample=0; int timerticspersec=0; static void (*usertimercallback)(void) = NULL; @@ -1687,14 +1803,15 @@ int inittimer(int 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); - timerlastsample = (long)(t*timerticspersec / timerfreq); + timerlastsample = (int)(t*timerticspersec / timerfreq); usertimercallback = NULL; @@ -1718,13 +1835,14 @@ void uninittimer(void) void sampletimer(void) { int64 i; - long n; + int n; if (!timerfreq) return; QueryPerformanceCounter((LARGE_INTEGER*)&i); - n = (long)(i*timerticspersec / timerfreq) - timerlastsample; - if (n>0) { + n = (int)(i*timerticspersec / timerfreq) - timerlastsample; + if (n>0) + { totalclock += n; timerlastsample += n; } @@ -1736,12 +1854,12 @@ void sampletimer(void) // // getticks() -- returns the windows ticks count // -unsigned long getticks(void) +unsigned int getticks(void) { int64 i; if (timerfreq == 0) return 0; QueryPerformanceCounter((LARGE_INTEGER*)&i); - return (unsigned long)(i*longlong(1000)/timerfreq); + return (unsigned int)(i*longlong(1000)/timerfreq); } @@ -1778,33 +1896,34 @@ static HPALETTE hPalette = NULL; static VOID *lpPixels = NULL; #define NUM_SYS_COLOURS 25 -static int syscolouridx[NUM_SYS_COLOURS] = { - COLOR_SCROLLBAR, // 1 - COLOR_BACKGROUND, - COLOR_ACTIVECAPTION, - COLOR_INACTIVECAPTION, - COLOR_MENU, - COLOR_WINDOW, - COLOR_WINDOWFRAME, - COLOR_MENUTEXT, - COLOR_WINDOWTEXT, - COLOR_CAPTIONTEXT, // 10 - COLOR_ACTIVEBORDER, - COLOR_INACTIVEBORDER, - COLOR_APPWORKSPACE, - COLOR_HIGHLIGHT, - COLOR_HIGHLIGHTTEXT, - COLOR_BTNFACE, - COLOR_BTNSHADOW, - COLOR_GRAYTEXT, - COLOR_BTNTEXT, - COLOR_INACTIVECAPTIONTEXT, // 20 - COLOR_BTNHIGHLIGHT, - COLOR_3DDKSHADOW, - COLOR_3DLIGHT, - COLOR_INFOTEXT, - COLOR_INFOBK // 25 - }; +static int syscolouridx[NUM_SYS_COLOURS] = +{ + COLOR_SCROLLBAR, // 1 + COLOR_BACKGROUND, + COLOR_ACTIVECAPTION, + COLOR_INACTIVECAPTION, + COLOR_MENU, + COLOR_WINDOW, + COLOR_WINDOWFRAME, + COLOR_MENUTEXT, + COLOR_WINDOWTEXT, + COLOR_CAPTIONTEXT, // 10 + COLOR_ACTIVEBORDER, + COLOR_INACTIVEBORDER, + COLOR_APPWORKSPACE, + COLOR_HIGHLIGHT, + COLOR_HIGHLIGHTTEXT, + COLOR_BTNFACE, + COLOR_BTNSHADOW, + COLOR_GRAYTEXT, + COLOR_BTNTEXT, + COLOR_INACTIVECAPTIONTEXT, // 20 + COLOR_BTNHIGHLIGHT, + COLOR_3DDKSHADOW, + COLOR_3DLIGHT, + COLOR_INFOTEXT, + COLOR_INFOBK // 25 +}; static DWORD syscolours[NUM_SYS_COLOURS]; static char system_colours_saved = 0, bw_colours_set = 0; @@ -1828,23 +1947,27 @@ int checkvideomode(int *x, int *y, int c, int fs, int forced) if (*y > MAXYDIM) *y = MAXYDIM; *x &= 0xfffffff8l; - for (i=0; i= 0) gammabrightness = 1; if (gammabrightness && setgamma(f,f,f) < 0) gammabrightness = 0; @@ -1944,9 +2072,12 @@ static void cdsenummodes(void) ZeroMemory(&dm,sizeof(DEVMODE)); dm.dmSize = sizeof(DEVMODE); - while (EnumDisplaySettings(NULL, j, &dm)) { - if (dm.dmBitsPerPel > 8) { - for (i=0;i 8) + { + for (i=0;i modes[i].freq && maxrefreshfreq > 0) || - (dm.dmDisplayFrequency > modes[i].freq && maxrefreshfreq == 0)) { + (dm.dmDisplayFrequency > modes[i].freq && maxrefreshfreq == 0)) + { if (i==nmodes) nmodes++; modes[i].x = dm.dmPelsWidth; @@ -1969,7 +2101,8 @@ static void cdsenummodes(void) dm.dmSize = sizeof(DEVMODE); } - for (i=0;iddpfPixelFormat.dwRGBBitCount == 8) { + if (ddsd->ddpfPixelFormat.dwRGBBitCount == 8) + { CHECK(ddsd->dwWidth, ddsd->dwHeight) ADDMODE(ddsd->dwWidth, ddsd->dwHeight, ddsd->ddpfPixelFormat.dwRGBBitCount, 1,-1); } @@ -2002,10 +2136,11 @@ static int sortmodes(const struct validmode_t *a, const struct validmode_t *b) } void getvalidmodes(void) { - static int defaultres[][2] = { - {1280,1024},{1280,960},{1152,864},{1024,768},{800,600},{640,480}, - {640,400},{512,384},{480,360},{400,300},{320,240},{320,200},{0,0} - }; + static int defaultres[][2] = + { + {1280,1024},{1280,960},{1152,864},{1024,768},{800,600},{640,480}, + {640,400},{512,384},{480,360},{400,300},{320,240},{320,200},{0,0} + }; int cdepths[2] = { 8, 0 }; int i, j, maxx=0, maxy=0; HRESULT result; @@ -2019,13 +2154,16 @@ void getvalidmodes(void) validmodecnt=0; initprintf("Detecting video modes:\n"); - if (bDDrawInited) { + if (bDDrawInited) + { // if DirectDraw initialisation didn't fail enumerate fullscreen modes result = IDirectDraw_EnumDisplayModes(lpDD, 0, NULL, 0, getvalidmodes_enum); - if (result != DD_OK) { + if (result != DD_OK) + { initprintf("Unable to enumerate fullscreen modes. Using default list.\n"); - for (j=0; j < 2; j++) { + for (j=0; j < 2; j++) + { if (cdepths[j] == 0) continue; for (i=0; defaultres[i][0]; i++) ADDMODE(defaultres[i][0],defaultres[i][1],cdepths[j],1,-1) @@ -2041,7 +2179,8 @@ void getvalidmodes(void) maxy = desktopydim-1; // add windowed modes next - for (j=0; j < 2; j++) { + for (j=0; j < 2; j++) + { if (cdepths[j] == 0) continue; for (i=0; defaultres[i][0]; i++) CHECK(defaultres[i][0],defaultres[i][1]) @@ -2072,9 +2211,10 @@ void resetvideomode(void) // void begindrawing(void) { - long i,j; + int i,j; - if (bpp > 8) { + if (bpp > 8) + { if (offscreenrendering) return; frameplace = 0; bytesperline = 0; @@ -2088,17 +2228,23 @@ void begindrawing(void) if (offscreenrendering) return; - if (!fullscreen) { - frameplace = (long)lpPixels; - } else { - frameplace = (long)lpOffscreen; + if (!fullscreen) + { + frameplace = (int)lpPixels; + } + else + { + frameplace = (int)lpOffscreen; } if (!modechange) return; - if (!fullscreen) { + if (!fullscreen) + { bytesperline = xres|4; - } else { + } + else + { bytesperline = xres|1; } @@ -2116,13 +2262,14 @@ void begindrawing(void) // void enddrawing(void) { - if (bpp > 8) { + if (bpp > 8) + { if (!offscreenrendering) frameplace = 0; return; } if (!frameplace) return; -if (lockcount > 1) { lockcount--; return; } + if (lockcount > 1) { lockcount--; return; } if (!offscreenrendering) frameplace = 0; lockcount = 0; } @@ -2139,8 +2286,10 @@ void showframe(int w) int i,j; #if defined(USE_OPENGL) && defined(POLYMOST) - if (bpp > 8) { - if (palfadedelta) { + if (bpp > 8) + { + if (palfadedelta) + { bglMatrixMode(GL_PROJECTION); bglPushMatrix(); bglLoadIdentity(); @@ -2177,15 +2326,20 @@ void showframe(int w) if (offscreenrendering) return; - if (lockcount) { - initprintf("Frame still locked %ld times when showframe() called.\n", lockcount); + if (lockcount) + { + initprintf("Frame still locked %d times when showframe() called.\n", lockcount); while (lockcount) enddrawing(); } - if (!fullscreen) { + if (!fullscreen) + { BitBlt(hDC, 0, 0, xres, yres, hDCSection, 0, 0, SRCCOPY); - } else { - if (!w) { + } + else + { + if (!w) + { if ((result = IDirectDrawSurface_GetBltStatus(lpDDSBack, DDGBS_CANBLT)) == DDERR_WASSTILLDRAWING) return; @@ -2198,14 +2352,16 @@ void showframe(int w) ddsd.dwSize = sizeof(ddsd); result = IDirectDrawSurface_Lock(lpDDSBack, NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_NOSYSLOCK | DDLOCK_WAIT, NULL); - if (result == DDERR_SURFACELOST) { + if (result == DDERR_SURFACELOST) + { if (!appactive) return; // not in a position to restore display anyway IDirectDrawSurface_Restore(lpDDSPrimary); result = IDirectDrawSurface_Lock(lpDDSBack, NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_NOSYSLOCK | DDLOCK_WAIT, NULL); } - if (result != DD_OK) { + if (result != DD_OK) + { if (result != DDERR_WASSTILLDRAWING) initprintf("Failed locking back-buffer surface: %s\n", GetDDrawError(result)); return; @@ -2221,20 +2377,23 @@ void showframe(int w) // unlock the backbuffer surface result = IDirectDrawSurface_Unlock(lpDDSBack, NULL); - if (result != DD_OK) { + if (result != DD_OK) + { initprintf("Failed unlocking back-buffer surface: %s\n", GetDDrawError(result)); return; } // flip the chain result = IDirectDrawSurface_Flip(lpDDSPrimary, NULL, w?DDFLIP_WAIT:0); - if (result == DDERR_SURFACELOST) { + if (result == DDERR_SURFACELOST) + { if (!appactive) return; // not in a position to restore display anyway IDirectDrawSurface_Restore(lpDDSPrimary); result = IDirectDrawSurface_Flip(lpDDSPrimary, NULL, w?DDFLIP_WAIT:0); } - if (result != DD_OK) { + if (result != DD_OK) + { if (result != DDERR_WASSTILLDRAWING) initprintf("IDirectDrawSurface_Flip(): %s\n", GetDDrawError(result)); } @@ -2254,7 +2413,8 @@ int setpalette(int start, int num, char *dapal) RGBQUAD *rgb; //HPALETTE hPalPrev; - struct logpal { + struct logpal + { WORD palVersion; WORD palNumEntries; PALETTEENTRY palPalEntry[256]; @@ -2262,7 +2422,8 @@ int setpalette(int start, int num, char *dapal) copybuf(curpalettefaded, lpal.palPalEntry, 256); - for (i=start, n=num; n>0; i++, n--) { + for (i=start, n=num; n>0; i++, n--) + { /* lpal.palPalEntry[i].peBlue = dapal[0] << 2; lpal.palPalEntry[i].peGreen = dapal[1] << 2; @@ -2275,10 +2436,13 @@ int setpalette(int start, int num, char *dapal) if (bpp > 8) return 0; // no palette in opengl - if (!fullscreen) { - if (num > 0) { + if (!fullscreen) + { + if (num > 0) + { rgb = (RGBQUAD *)Bmalloc(sizeof(RGBQUAD)*num); - for (i=start, n=0; n 8) { + if (!fullscreen || bpp > 8) + { // GL and windowed mode use DIB method int i; HDC hDC = GetDC(hWindow); i = SetDeviceGammaRamp(hDC, gt) ? 0 : -1; ReleaseDC(hWindow, hDC); return i; - } else { + } + else + { // fullscreen uses DirectX LPDIRECTDRAWGAMMACONTROL gam; HRESULT hr; @@ -2382,13 +2559,15 @@ static int setgammaramp(WORD gt[3][256]) if (!(DDdwCaps2 & DDCAPS2_PRIMARYGAMMA)) return -1; hr = IDirectDrawSurface_QueryInterface(lpDDSPrimary, &IID_IDirectDrawGammaControl, (LPVOID)&gam); - if (hr != DD_OK) { + if (hr != DD_OK) + { ShowDDrawErrorBox("Error querying gamma control", hr); return -1; } hr = IDirectDrawGammaControl_SetGammaRamp(gam, 0, (LPDDGAMMARAMP)gt); - if (hr != DD_OK) { + if (hr != DD_OK) + { IDirectDrawGammaControl_Release(gam); ShowDDrawErrorBox("Error setting gamma ramp", hr); return -1; @@ -2407,7 +2586,8 @@ int setgamma(float ro, float go, float bo) if (!hWindow) return -1; ro = 1.0 / ro; go = 1.0 / go; bo = 1.0 / bo; - for (i=0;i<256;i++) { + for (i=0;i<256;i++) + { gt[0][i] = (WORD)min(65535, max(0, (int)(pow((double)i / 256.0, ro) * 65535.0 + 0.5))); gt[1][i] = (WORD)min(65535, max(0, (int)(pow((double)i / 256.0, go) * 65535.0 + 0.5))); gt[2][i] = (WORD)min(65535, max(0, (int)(pow((double)i / 256.0, go) * 65535.0 + 0.5))); @@ -2419,26 +2599,31 @@ int setgamma(float ro, float go, float bo) static int getgammaramp(WORD gt[3][256]) { if (!hWindow) return -1; - if (!fullscreen || bpp > 8) { + if (!fullscreen || bpp > 8) + { int i; HDC hDC = GetDC(hWindow); i = GetDeviceGammaRamp(hDC, gt) ? 0 : -1; ReleaseDC(hWindow, hDC); return i; - } else { + } + else + { LPDIRECTDRAWGAMMACONTROL gam; HRESULT hr; if (!(DDdwCaps2 & DDCAPS2_PRIMARYGAMMA)) return -1; hr = IDirectDrawSurface_QueryInterface(lpDDSPrimary, &IID_IDirectDrawGammaControl, (LPVOID)&gam); - if (hr != DD_OK) { + if (hr != DD_OK) + { ShowDDrawErrorBox("Error querying gamma control", hr); return -1; } hr = IDirectDrawGammaControl_GetGammaRamp(gam, 0, (LPDDGAMMARAMP)gt); - if (hr != DD_OK) { + if (hr != DD_OK) + { IDirectDrawGammaControl_Release(gam); ShowDDrawErrorBox("Error getting gamma ramp", hr); return -1; @@ -2464,8 +2649,8 @@ static BOOL WINAPI InitDirectDraw_enum(GUID *lpGUID, LPSTR lpDesc, LPSTR lpName, static BOOL InitDirectDraw(void) { HRESULT result; - HRESULT (WINAPI *aDirectDrawCreate)(GUID *, LPDIRECTDRAW *, IUnknown *); - HRESULT (WINAPI *aDirectDrawEnumerate)(LPDDENUMCALLBACK, LPVOID); + HRESULT(WINAPI *aDirectDrawCreate)(GUID *, LPDIRECTDRAW *, IUnknown *); + HRESULT(WINAPI *aDirectDrawEnumerate)(LPDDENUMCALLBACK, LPVOID); DDCAPS ddcaps; if (bDDrawInited) return FALSE; @@ -2473,10 +2658,12 @@ static BOOL InitDirectDraw(void) initprintf("Initialising DirectDraw...\n"); // load up the DirectDraw DLL - if (!hDDrawDLL) { + if (!hDDrawDLL) + { initprintf(" - Loading DDRAW.DLL\n"); hDDrawDLL = LoadLibrary("DDRAW.DLL"); - if (!hDDrawDLL) { + if (!hDDrawDLL) + { ShowErrorBox("Error loading DDRAW.DLL"); return TRUE; } @@ -2484,7 +2671,8 @@ static BOOL InitDirectDraw(void) // get the pointer to DirectDrawEnumerate aDirectDrawEnumerate = (void *)GetProcAddress(hDDrawDLL, "DirectDrawEnumerateA"); - if (!aDirectDrawEnumerate) { + if (!aDirectDrawEnumerate) + { ShowErrorBox("Error fetching DirectDrawEnumerate()"); UninitDirectDraw(); return TRUE; @@ -2496,7 +2684,8 @@ static BOOL InitDirectDraw(void) // get the pointer to DirectDrawCreate aDirectDrawCreate = (void *)GetProcAddress(hDDrawDLL, "DirectDrawCreate"); - if (!aDirectDrawCreate) { + if (!aDirectDrawCreate) + { ShowErrorBox("Error fetching DirectDrawCreate()"); UninitDirectDraw(); return TRUE; @@ -2505,7 +2694,8 @@ static BOOL InitDirectDraw(void) // create a new DirectDraw object initprintf(" - Creating DirectDraw object\n"); result = aDirectDrawCreate(NULL, &lpDD, NULL); - if (result != DD_OK) { + if (result != DD_OK) + { ShowDDrawErrorBox("DirectDrawCreate() failed", result); UninitDirectDraw(); return TRUE; @@ -2515,9 +2705,12 @@ static BOOL InitDirectDraw(void) initprintf(" - Checking capabilities\n"); ddcaps.dwSize = sizeof(DDCAPS); result = IDirectDraw_GetCaps(lpDD, &ddcaps, NULL); - if (result != DD_OK) { + if (result != DD_OK) + { initprintf(" Unable to get capabilities.\n"); - } else { + } + else + { DDdwCaps = ddcaps.dwCaps; DDdwCaps2 = ddcaps.dwCaps2; } @@ -2539,13 +2732,15 @@ static void UninitDirectDraw(void) RestoreDirectDrawMode(); - if (lpDD) { + if (lpDD) + { initprintf(" - Releasing DirectDraw object\n"); IDirectDraw_Release(lpDD); lpDD = NULL; } - if (hDDrawDLL) { + if (hDDrawDLL) + { initprintf(" - Unloading DDRAW.DLL\n"); FreeLibrary(hDDrawDLL); hDDrawDLL = NULL; @@ -2565,17 +2760,20 @@ static int RestoreDirectDrawMode(void) if (fullscreen == 0 || /*bpp > 8 ||*/ !bDDrawInited) return FALSE; if (modesetusing == 1) ChangeDisplaySettings(NULL,0); - else if (modesetusing == 0) { + else if (modesetusing == 0) + { // restore previous display mode and set to normal cooperative level result = IDirectDraw_RestoreDisplayMode(lpDD); - if (result != DD_OK) { + if (result != DD_OK) + { ShowDDrawErrorBox("Error restoring display mode", result); UninitDirectDraw(); return TRUE; } result = IDirectDraw_SetCooperativeLevel(lpDD, hWindow, DDSCL_NORMAL); - if (result != DD_OK) { + if (result != DD_OK) + { ShowDDrawErrorBox("Error setting cooperative level", result); UninitDirectDraw(); return TRUE; @@ -2592,25 +2790,29 @@ static int RestoreDirectDrawMode(void) // static void ReleaseDirectDrawSurfaces(void) { - if (lpDDPalette) { + if (lpDDPalette) + { initprintf(" - Releasing palette\n"); IDirectDrawPalette_Release(lpDDPalette); lpDDPalette = NULL; } - if (lpDDSBack) { + if (lpDDSBack) + { initprintf(" - Releasing back-buffer surface\n"); IDirectDrawSurface_Release(lpDDSBack); lpDDSBack = NULL; } - if (lpDDSPrimary) { + if (lpDDSPrimary) + { initprintf(" - Releasing primary surface\n"); IDirectDrawSurface_Release(lpDDSPrimary); lpDDSPrimary = NULL; } - if (lpOffscreen) { + if (lpOffscreen) + { initprintf(" - Freeing offscreen buffer\n"); free(lpOffscreen); lpOffscreen = NULL; @@ -2635,7 +2837,8 @@ static int SetupDirectDraw(int width, int height) initprintf(" - Creating primary surface\n"); result = IDirectDraw_CreateSurface(lpDD, &ddsd, &lpDDSPrimary, NULL); - if (result != DD_OK) { + if (result != DD_OK) + { ShowDDrawErrorBox("Failure creating primary surface", result); UninitDirectDraw(); return TRUE; @@ -2647,7 +2850,8 @@ static int SetupDirectDraw(int width, int height) initprintf(" - Getting back buffer\n"); result = IDirectDrawSurface_GetAttachedSurface(lpDDSPrimary, &ddsd.ddsCaps, &lpDDSBack); - if (result != DD_OK) { + if (result != DD_OK) + { ShowDDrawErrorBox("Failure fetching back-buffer surface", result); UninitDirectDraw(); return TRUE; @@ -2655,7 +2859,8 @@ static int SetupDirectDraw(int width, int height) initprintf(" - Allocating offscreen buffer\n"); lpOffscreen = (char *)malloc((width|1)*height); - if (!lpOffscreen) { + if (!lpOffscreen) + { ShowErrorBox("Failure allocating offscreen buffer"); UninitDirectDraw(); return TRUE; @@ -2664,14 +2869,16 @@ static int SetupDirectDraw(int width, int height) // attach a palette to the primary surface initprintf(" - Creating palette\n"); result = IDirectDraw_CreatePalette(lpDD, DDPCAPS_8BIT | DDPCAPS_ALLOW256, (PALETTEENTRY*)curpalette, &lpDDPalette, NULL); - if (result != DD_OK) { + if (result != DD_OK) + { ShowDDrawErrorBox("Failure creating palette", result); UninitDirectDraw(); return TRUE; } result = IDirectDrawSurface_SetPalette(lpDDSPrimary, lpDDPalette); - if (result != DD_OK) { + if (result != DD_OK) + { ShowDDrawErrorBox("Failure setting palette", result); UninitDirectDraw(); return TRUE; @@ -2689,22 +2896,26 @@ static void UninitDIB(void) if (desktopbpp <= 8) RestoreSystemColours(); - if (hPalette) { + if (hPalette) + { DeleteObject(hPalette); hPalette = NULL; } - if (hDCSection) { + if (hDCSection) + { DeleteDC(hDCSection); hDCSection = NULL; } - if (hDIBSection) { + if (hDIBSection) + { DeleteObject(hDIBSection); hDIBSection = NULL; } - if (hDC) { + if (hDC) + { ReleaseDC(hWindow, hDC); hDC = NULL; } @@ -2716,27 +2927,32 @@ static void UninitDIB(void) // static int SetupDIB(int width, int height) { - struct binfo { + struct binfo + { BITMAPINFOHEADER header; RGBQUAD colours[256]; } dibsect; int i; - if (!hDC) { + if (!hDC) + { hDC = GetDC(hWindow); - if (!hDC) { + if (!hDC) + { ShowErrorBox("Error getting device context"); return TRUE; } } - if (hDCSection) { + if (hDCSection) + { DeleteDC(hDCSection); hDCSection = NULL; } // destroy the previous DIB section if it existed - if (hDIBSection) { + if (hDIBSection) + { DeleteObject(hDIBSection); hDIBSection = NULL; } @@ -2752,14 +2968,16 @@ static int SetupDIB(int width, int height) dibsect.header.biCompression = BI_RGB; dibsect.header.biClrUsed = 256; dibsect.header.biClrImportant = 256; - for (i=0; i<256; i++) { + for (i=0; i<256; i++) + { dibsect.colours[i].rgbBlue = curpalette[i].b; dibsect.colours[i].rgbGreen = curpalette[i].g; dibsect.colours[i].rgbRed = curpalette[i].r; } hDIBSection = CreateDIBSection(hDC, (BITMAPINFO *)&dibsect, DIB_RGB_COLORS, &lpPixels, NULL, 0); - if (!hDIBSection) { + if (!hDIBSection) + { ReleaseDC(hWindow, hDC); hDC = NULL; @@ -2771,7 +2989,8 @@ static int SetupDIB(int width, int height) // create a compatible memory DC hDCSection = CreateCompatibleDC(hDC); - if (!hDCSection) { + if (!hDCSection) + { ReleaseDC(hWindow, hDC); hDC = NULL; @@ -2780,7 +2999,8 @@ static int SetupDIB(int width, int height) } // select the DIB section into the memory DC - if (!SelectObject(hDCSection, hDIBSection)) { + if (!SelectObject(hDCSection, hDIBSection)) + { ReleaseDC(hWindow, hDC); hDC = NULL; DeleteDC(hDCSection); @@ -2802,14 +3022,17 @@ static HWND hGLWindow = NULL; static void ReleaseOpenGL(void) { - if (hGLRC) { + if (hGLRC) + { polymost_glreset(); if (!bwglMakeCurrent(0,0)) { } if (!bwglDeleteContext(hGLRC)) { } hGLRC = NULL; } - if (hGLWindow) { - if (hDC) { + if (hGLWindow) + { + if (hDC) + { ReleaseDC(hGLWindow, hDC); hDC = NULL; } @@ -2834,24 +3057,25 @@ static void UninitOpenGL(void) // static int SetupOpenGL(int width, int height, int bitspp) { - PIXELFORMATDESCRIPTOR pfd = { - sizeof(PIXELFORMATDESCRIPTOR), - 1, //Version Number - PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER, //Must Support these - PFD_TYPE_RGBA, //Request An RGBA Format - 0, //Select Our Color Depth - 0,0,0,0,0,0, //Color Bits Ignored - 0, //No Alpha Buffer - 0, //Shift Bit Ignored - 0, //No Accumulation Buffer - 0,0,0,0, //Accumulation Bits Ignored - 32, //16/24/32 Z-Buffer depth - 1, //No Stencil Buffer - 0, //No Auxiliary Buffer - PFD_MAIN_PLANE, //Main Drawing Layer - 0, //Reserved - 0,0,0 //Layer Masks Ignored - }; + PIXELFORMATDESCRIPTOR pfd = + { + sizeof(PIXELFORMATDESCRIPTOR), + 1, //Version Number + PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER, //Must Support these + PFD_TYPE_RGBA, //Request An RGBA Format + 0, //Select Our Color Depth + 0,0,0,0,0,0, //Color Bits Ignored + 0, //No Alpha Buffer + 0, //Shift Bit Ignored + 0, //No Accumulation Buffer + 0,0,0,0, //Accumulation Bits Ignored + 32, //16/24/32 Z-Buffer depth + 1, //No Stencil Buffer + 0, //No Auxiliary Buffer + PFD_MAIN_PLANE, //Main Drawing Layer + 0, //Reserved + 0,0,0 //Layer Masks Ignored + }; GLuint PixelFormat; int minidriver; int err; @@ -2868,13 +3092,15 @@ static int SetupOpenGL(int width, int height, int bitspp) (HMENU)0, hInstance, NULL); - if (!hGLWindow) { + if (!hGLWindow) + { ShowErrorBox("Error creating OpenGL child window."); return TRUE; } hDC = GetDC(hGLWindow); - if (!hDC) { + if (!hDC) + { ReleaseOpenGL(); ShowErrorBox("Error getting device context"); return TRUE; @@ -2884,7 +3110,8 @@ static int SetupOpenGL(int width, int height, int bitspp) if (minidriver) PixelFormat = bwglChoosePixelFormat(hDC,&pfd); else PixelFormat = ChoosePixelFormat(hDC,&pfd); - if (!PixelFormat) { + if (!PixelFormat) + { ReleaseOpenGL(); ShowErrorBox("Can't choose pixel format"); return TRUE; @@ -2892,20 +3119,23 @@ static int SetupOpenGL(int width, int height, int bitspp) if (minidriver) err = bwglSetPixelFormat(hDC, PixelFormat, &pfd); else err = SetPixelFormat(hDC, PixelFormat, &pfd); - if (!err) { + if (!err) + { ReleaseOpenGL(); ShowErrorBox("Can't set pixel format"); return TRUE; } hGLRC = bwglCreateContext(hDC); - if (!hGLRC) { + if (!hGLRC) + { ReleaseOpenGL(); ShowErrorBox("Can't create GL RC"); return TRUE; } - if (!bwglMakeCurrent(hDC, hGLRC)) { + if (!bwglMakeCurrent(hDC, hGLRC)) + { ReleaseOpenGL(); ShowErrorBox("Can't activate GL RC"); return TRUE; @@ -2937,38 +3167,60 @@ static int SetupOpenGL(int width, int height, int bitspp) // process the extensions string and flag stuff we recognize p = (unsigned char *)Bstrdup(glinfo.extensions); p3 = p; - while ((p2 = (unsigned char *)Bstrtoken(p3==p?(char *)p:NULL, " ", (char**)&p3, 1)) != NULL) { - if (!Bstrcmp((char *)p2, "GL_EXT_texture_filter_anisotropic")) { + while ((p2 = (unsigned char *)Bstrtoken(p3==p?(char *)p:NULL, " ", (char**)&p3, 1)) != NULL) + { + if (!Bstrcmp((char *)p2, "GL_EXT_texture_filter_anisotropic")) + { // supports anisotropy. get the maximum anisotropy level bglGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &glinfo.maxanisotropy); - } else if (!Bstrcmp((char *)p2, "GL_EXT_texture_edge_clamp") || - !Bstrcmp((char *)p2, "GL_SGIS_texture_edge_clamp")) { + } + else if (!Bstrcmp((char *)p2, "GL_EXT_texture_edge_clamp") || + !Bstrcmp((char *)p2, "GL_SGIS_texture_edge_clamp")) + { // supports GL_CLAMP_TO_EDGE or GL_CLAMP_TO_EDGE_SGIS glinfo.clamptoedge = 1; - } else if (!Bstrcmp((char *)p2, "GL_EXT_bgra")) { + } + else if (!Bstrcmp((char *)p2, "GL_EXT_bgra")) + { // support bgra textures glinfo.bgra = 1; - } else if (!Bstrcmp((char *)p2, "GL_ARB_texture_compression")) { + } + else if (!Bstrcmp((char *)p2, "GL_ARB_texture_compression")) + { // support texture compression glinfo.texcompr = 1; - } else if (!Bstrcmp((char *)p2, "GL_ARB_texture_non_power_of_two")) { + } + else if (!Bstrcmp((char *)p2, "GL_ARB_texture_non_power_of_two")) + { // support non-power-of-two texture sizes glinfo.texnpot = 1; - } else if (!Bstrcmp((char *)p2, "WGL_3DFX_gamma_control")) { + } + else if (!Bstrcmp((char *)p2, "WGL_3DFX_gamma_control")) + { // 3dfx cards have issues with fog nofog = 1; if (!(warnonce&1)) initprintf("3dfx card detected: OpenGL fog disabled\n"); warnonce |= 1; - } else if (!Bstrcmp((char *)p2, "GL_ARB_fragment_program")) { + } + else if (!Bstrcmp((char *)p2, "GL_ARB_fragment_program")) + { glinfo.arbfp = 1; - } else if (!Bstrcmp((char *)p2, "GL_ARB_depth_texture")) { + } + else if (!Bstrcmp((char *)p2, "GL_ARB_depth_texture")) + { glinfo.depthtex = 1; - } else if (!Bstrcmp((char *)p2, "GL_ARB_shadow")) { + } + else if (!Bstrcmp((char *)p2, "GL_ARB_shadow")) + { glinfo.shadow = 1; - } else if (!Bstrcmp((char *)p2, "GL_EXT_framebuffer_object")) { + } + else if (!Bstrcmp((char *)p2, "GL_EXT_framebuffer_object")) + { glinfo.fbos = 1; - } else if (!Bstrcmp((char *)p2, "GL_NV_texture_rectangle") || - !Bstrcmp((char *)p2, "GL_EXT_texture_rectangle")) { + } + else if (!Bstrcmp((char *)p2, "GL_NV_texture_rectangle") || + !Bstrcmp((char *)p2, "GL_EXT_texture_rectangle")) + { glinfo.rect = 1; } else if (!Bstrcmp((char *)p2, "GL_ARB_multitexture")) @@ -3003,12 +3255,15 @@ static BOOL CreateAppWindow(int modenum) HRESULT result; - if (modenum == 0x7fffffff) { + if (modenum == 0x7fffffff) + { width = customxdim; height = customydim; fs = customfs; bitspp = custombpp; - } else { + } + else + { width = validmode[modenum].xdim; height = validmode[modenum].ydim; fs = validmode[modenum].fs; @@ -3017,20 +3272,27 @@ static BOOL CreateAppWindow(int modenum) if (width == xres && height == yres && fs == fullscreen && bitspp == bpp && !videomodereset) return FALSE; - if (hWindow) { - if (bpp > 8) { + if (hWindow) + { + if (bpp > 8) + { #if defined(USE_OPENGL) && defined(POLYMOST) ReleaseOpenGL(); // release opengl #endif - } else { + } + else + { ReleaseDirectDrawSurfaces(); // releases directdraw surfaces } - if (!fs && fullscreen) { + if (!fs && fullscreen) + { // restore previous display mode and set to normal cooperative level RestoreDirectDrawMode(); #if defined(USE_OPENGL) && defined(POLYMOST) - } else if (fs && fullscreen) { + } + else if (fs && fullscreen) + { // using CDS for GL modes, so restore from DirectDraw if (bpp != bitspp) RestoreDirectDrawMode(); #endif @@ -3040,15 +3302,19 @@ static BOOL CreateAppWindow(int modenum) ShowWindow(hWindow, SW_HIDE); // so Windows redraws what's behind if the window shrinks } - if (fs) { + if (fs) + { stylebitsex = WS_EX_TOPMOST; stylebits = WS_POPUP; - } else { + } + else + { stylebitsex = 0; stylebits = WINDOW_STYLE; } - if (!hWindow) { + if (!hWindow) + { hWindow = CreateWindowEx( stylebitsex, "buildapp", @@ -3062,19 +3328,23 @@ static BOOL CreateAppWindow(int modenum) NULL, hInstance, 0); - if (!hWindow) { + if (!hWindow) + { ShowErrorBox("Unable to create window"); return TRUE; } startwin_close(); - } else { + } + else + { SetWindowLong(hWindow,GWL_EXSTYLE,stylebitsex); SetWindowLong(hWindow,GWL_STYLE,stylebits); } // resize the window - if (!fs) { + if (!fs) + { rect.left = 0; rect.top = 0; rect.right = width-1; @@ -3085,7 +3355,9 @@ static BOOL CreateAppWindow(int modenum) h = (rect.bottom - rect.top); x = (desktopxdim - w) / 2; y = (desktopydim - h) / 2; - } else { + } + else + { x=y=0; w=width; h=height; @@ -3105,37 +3377,47 @@ static BOOL CreateAppWindow(int modenum) SetWindowPos(hWindow, HWND_TOP, windowpos?windowx:x, windowpos?windowy:y, w, h, 0); // fullscreen? - if (!fs) { - if (bitspp > 8) { + if (!fs) + { + if (bitspp > 8) + { #if defined(USE_OPENGL) && defined(POLYMOST) // yes, start up opengl - if (SetupOpenGL(width,height,bitspp)) { + if (SetupOpenGL(width,height,bitspp)) + { return TRUE; } #endif - } else { + } + else + { // no, use DIB section - if (SetupDIB(width,height)) { + if (SetupDIB(width,height)) + { return TRUE; } } modesetusing = -1; - } else { + } + else + { // yes, set up DirectDraw // clean up after the DIB renderer if it was being used UninitDIB(); - if (!bDDrawInited) { + if (!bDDrawInited) + { DestroyWindow(hWindow); hWindow = NULL; return TRUE; } #if defined(USE_OPENGL) && defined(POLYMOST) - if (bitspp > 8) { + if (bitspp > 8) + { DEVMODE dmScreenSettings; ZeroMemory(&dmScreenSettings, sizeof(DEVMODE)); @@ -3144,12 +3426,14 @@ static BOOL CreateAppWindow(int modenum) dmScreenSettings.dmPelsHeight = height; dmScreenSettings.dmBitsPerPel = bitspp; dmScreenSettings.dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT; - if (modenum != 0x7fffffff) { + if (modenum != 0x7fffffff) + { dmScreenSettings.dmDisplayFrequency = validmode[modenum].extra; dmScreenSettings.dmFields |= DM_DISPLAYFREQUENCY; } - if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) { + if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) + { ShowErrorBox("Video mode not supported"); return TRUE; } @@ -3159,19 +3443,22 @@ static BOOL CreateAppWindow(int modenum) SetFocus(hWindow); modesetusing = 1; - } else + } + else #endif { // set exclusive cooperative level result = IDirectDraw_SetCooperativeLevel(lpDD, hWindow, DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN); - if (result != DD_OK) { + if (result != DD_OK) + { ShowDDrawErrorBox("Error setting cooperative level", result); UninitDirectDraw(); return TRUE; } result = IDirectDraw_SetDisplayMode(lpDD, width, height, bitspp); - if (result != DD_OK) { + if (result != DD_OK) + { ShowDDrawErrorBox("Error setting display mode", result); UninitDirectDraw(); return TRUE; @@ -3180,16 +3467,21 @@ static BOOL CreateAppWindow(int modenum) modesetusing = 0; } - if (bitspp > 8) { + if (bitspp > 8) + { #if defined(USE_OPENGL) && defined(POLYMOST) // we want an opengl mode - if (SetupOpenGL(width,height,bitspp)) { + if (SetupOpenGL(width,height,bitspp)) + { return TRUE; } #endif - } else { + } + else + { // we want software - if (SetupDirectDraw(width,height)) { + if (SetupDirectDraw(width,height)) + { return TRUE; } } @@ -3226,7 +3518,8 @@ static BOOL CreateAppWindow(int modenum) // static void DestroyAppWindow(void) { - if (hWindow && gammabrightness) { + if (hWindow && gammabrightness) + { setgammaramp(sysgamma); gammabrightness = 0; } @@ -3237,7 +3530,8 @@ static void DestroyAppWindow(void) UninitDirectDraw(); UninitDIB(); - if (hWindow) { + if (hWindow) + { DestroyWindow(hWindow); hWindow = NULL; } @@ -3267,11 +3561,12 @@ static void SetBWSystemColours(void) { #define WHI RGB(255,255,255) #define BLA RGB(0,0,0) - static COLORREF syscoloursbw[NUM_SYS_COLOURS] = { - WHI, BLA, BLA, WHI, WHI, WHI, WHI, BLA, BLA, WHI, - WHI, WHI, WHI, BLA, WHI, WHI, BLA, BLA, BLA, BLA, - BLA, BLA, WHI, BLA, WHI - }; + static COLORREF syscoloursbw[NUM_SYS_COLOURS] = + { + WHI, BLA, BLA, WHI, WHI, WHI, WHI, BLA, BLA, WHI, + WHI, WHI, WHI, BLA, WHI, WHI, BLA, BLA, BLA, BLA, + BLA, BLA, WHI, BLA, WHI + }; #undef WHI #undef BLA if (!system_colours_saved || bw_colours_set) return; @@ -3312,7 +3607,8 @@ static void ShowDDrawErrorBox(const char *m, HRESULT r) // static const char * GetDDrawError(HRESULT code) { - switch (code) { + switch (code) + { case DD_OK: return "DD_OK"; case DDERR_ALREADYINITIALIZED: @@ -3600,7 +3896,8 @@ static LRESULT CALLBACK WndProcCallback(HWND hWnd, UINT uMsg, WPARAM wParam, LPA if (hWnd == hGLWindow) return DefWindowProc(hWnd,uMsg,wParam,lParam); #endif - switch (uMsg) { + switch (uMsg) + { case WM_SYSCOMMAND: // don't let the monitor fall asleep or let the screensaver activate if (wParam == SC_SCREENSAVE || wParam == SC_MONITORPOWER) return 0; @@ -3624,7 +3921,7 @@ static LRESULT CALLBACK WndProcCallback(HWND hWnd, UINT uMsg, WPARAM wParam, LPA ShowWindow(hWindow, SW_MINIMIZE); } else if (appactive && realfs) - { + { ShowWindow(hWindow, SW_SHOWNORMAL); SetForegroundWindow(hWindow); SetFocus(hWindow); @@ -3634,17 +3931,21 @@ static LRESULT CALLBACK WndProcCallback(HWND hWnd, UINT uMsg, WPARAM wParam, LPA } #endif if (backgroundidle) - SetPriorityClass( GetCurrentProcess(), - appactive ? NORMAL_PRIORITY_CLASS : IDLE_PRIORITY_CLASS ); + SetPriorityClass(GetCurrentProcess(), + appactive ? NORMAL_PRIORITY_CLASS : IDLE_PRIORITY_CLASS); break; } case WM_ACTIVATE: - if (desktopbpp <= 8) { - if (appactive) { + if (desktopbpp <= 8) + { + if (appactive) + { setpalette(0,0,0); SetBWSystemColours(); // initprintf("Resetting palette.\n"); - } else { + } + else + { RestoreSystemColours(); // initprintf("Resetting system colours.\n"); } @@ -3705,7 +4006,8 @@ static LRESULT CALLBACK WndProcCallback(HWND hWnd, UINT uMsg, WPARAM wParam, LPA case WM_KEYUP: // pause sucks. I read that apparently it doesn't work the same everwhere // with DirectInput but it does with Windows messages. Oh well. - if (wParam == VK_PAUSE && (lParam & 0x80000000l)) { + if (wParam == VK_PAUSE && (lParam & 0x80000000l)) + { SetKey(0x59, 1); if (keypresscallback) @@ -3776,7 +4078,8 @@ static BOOL RegisterWindowClass(void) wcx.lpszClassName = WindowClass; wcx.hIconSm = LoadImage(hInstance, MAKEINTRESOURCE(100), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR); - if (!RegisterClassEx(&wcx)) { + if (!RegisterClassEx(&wcx)) + { ShowErrorBox("Failed to register window class"); return TRUE; } @@ -3802,17 +4105,18 @@ static LPTSTR GetWindowsErrorMsg(DWORD code) return lpMsgBuf; } -// -// makeasmwriteable() -- removes write protection from the self-modifying assembly code -// -void makeasmwriteable(void) -{ -#ifndef ENGINE_USING_A_C - extern int dep_begin, dep_end; - DWORD oldprot; - - if (!VirtualProtect((LPVOID)&dep_begin, (SIZE_T)&dep_end - (SIZE_T)&dep_begin, PAGE_EXECUTE_READWRITE, &oldprot)) { - ShowErrorBox("Problem making code writeable"); - } -#endif +// +// makeasmwriteable() -- removes write protection from the self-modifying assembly code +// +void makeasmwriteable(void) +{ +#ifndef ENGINE_USING_A_C + extern int dep_begin, dep_end; + DWORD oldprot; + + if (!VirtualProtect((LPVOID)&dep_begin, (SIZE_T)&dep_end - (SIZE_T)&dep_begin, PAGE_EXECUTE_READWRITE, &oldprot)) + { + ShowErrorBox("Problem making code writeable"); + } +#endif } \ No newline at end of file diff --git a/polymer/eduke32/source/actors.c b/polymer/eduke32/source/actors.c index 54a5591f0..9242d314a 100644 --- a/polymer/eduke32/source/actors.c +++ b/polymer/eduke32/source/actors.c @@ -23,19 +23,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. //------------------------------------------------------------------------- #include "duke3d.h" -extern long numenvsnds; +extern int numenvsnds; extern int actor_tog; void updateinterpolations() //Stick at beginning of domovethings { - long i=numinterpolations-1; + int i=numinterpolations-1; for (;i>=0;i--) oldipos[i] = *curipos[i]; } -void setinterpolation(long *posptr) +void setinterpolation(int *posptr) { - long i; + int i; if (numinterpolations >= MAXINTERPOLATIONS) return; for (i=numinterpolations-1;i>=0;i--) @@ -45,9 +45,9 @@ void setinterpolation(long *posptr) numinterpolations++; } -void stopinterpolation(long *posptr) +void stopinterpolation(int *posptr) { - long i; + int i; for (i=numinterpolations-1;i>=startofdynamicinterpolations;i--) if (curipos[i] == posptr) @@ -59,9 +59,9 @@ void stopinterpolation(long *posptr) } } -void dointerpolations(long smoothratio) //Stick at beginning of drawscreen +void dointerpolations(int smoothratio) //Stick at beginning of drawscreen { - long i=numinterpolations-1, j = 0, odelta, ndelta = 0; + int i=numinterpolations-1, j = 0, odelta, ndelta = 0; for (;i>=0;i--) { @@ -75,19 +75,19 @@ void dointerpolations(long smoothratio) //Stick at beginning of drawscreen void restoreinterpolations() //Stick at end of drawscreen { - long i=numinterpolations-1; + int i=numinterpolations-1; for (;i>=0;i--) *curipos[i] = bakipos[i]; } -long ceilingspace(int sectnum) +int ceilingspace(int sectnum) { if ((sector[sectnum].ceilingstat&1) && sector[sectnum].ceilingpal == 0 && (sector[sectnum].ceilingpicnum==MOONSKY1 || sector[sectnum].ceilingpicnum==BIGORBIT1)) return 1; return 0; } -long floorspace(int sectnum) +int floorspace(int sectnum) { if ((sector[sectnum].floorstat&1) && sector[sectnum].ceilingpal == 0) { @@ -276,12 +276,12 @@ void checkavailweapon(player_struct *p) else p->weapon_pos = -1; } -void hitradius(int i, long r, long hp1, long hp2, long hp3, long hp4) +void hitradius(int i, int r, int hp1, int hp2, int hp3, int hp4) { spritetype *s=&sprite[i],*sj; walltype *wal; - long d, q, x1, y1; - long sectcnt, sectend, dasect, startwall, endwall, nextsect; + int d, q, x1, y1; + int sectcnt, sectend, dasect, startwall, endwall, nextsect; int j,k,p,x,nextj; short sect=-1; char statlist[] = {0,1,6,10,12,2,5}; @@ -458,9 +458,9 @@ BOLT: } } -int movesprite(int spritenum, long xchange, long ychange, long zchange, unsigned long cliptype) +int movesprite(int spritenum, int xchange, int ychange, int zchange, unsigned int cliptype) { - long daz, oldx, oldy; + int daz, oldx, oldy; int retval; short dasectnum, cd; int bg = badguy(&sprite[spritenum]); @@ -525,7 +525,7 @@ int movesprite(int spritenum, long xchange, long ychange, long zchange, unsigned clipmove(&sprite[spritenum].x,&sprite[spritenum].y,&daz,&dasectnum,((xchange*TICSPERFRAME)<<11),((ychange*TICSPERFRAME)<<11),8L,(4<<8),(4<<8),cliptype); else retval = - clipmove(&sprite[spritenum].x,&sprite[spritenum].y,&daz,&dasectnum,((xchange*TICSPERFRAME)<<11),((ychange*TICSPERFRAME)<<11),(long)(sprite[spritenum].clipdist<<2),(4<<8),(4<<8),cliptype); + clipmove(&sprite[spritenum].x,&sprite[spritenum].y,&daz,&dasectnum,((xchange*TICSPERFRAME)<<11),((ychange*TICSPERFRAME)<<11),(int)(sprite[spritenum].clipdist<<2),(4<<8),(4<<8),cliptype); } if (dasectnum >= 0) @@ -541,10 +541,10 @@ int movesprite(int spritenum, long xchange, long ychange, long zchange, unsigned return(retval); } -int ssp(int i,unsigned long cliptype) //The set sprite function +int ssp(int i,unsigned int cliptype) //The set sprite function { spritetype *s= &sprite[i]; - long movetype; + int movetype; movetype = movesprite(i, (s->xvel*(sintable[(s->ang+512)&2047]))>>14, @@ -605,7 +605,7 @@ void lotsofpaper(int sp, int n) void guts(int sp, int gtype, int n, int p) { - long gutz,floorz; + int gutz,floorz; int i,a,j,sx,sy,pal; spritetype *s = &sprite[sp]; @@ -642,7 +642,7 @@ void guts(int sp, int gtype, int n, int p) void gutsdir(int sp, int gtype, int n, int p) { - long gutz,floorz; + int gutz,floorz; int i,a,j,sx,sy; spritetype *s = &sprite[sp]; @@ -706,9 +706,9 @@ static void ms(int i) { //T1,T2 and T3 are used for all the sector moving stuff!!! - long tx,ty; + int tx,ty; spritetype *s = &sprite[i]; - long j = T2, k = T3; + int j = T2, k = T3; s->x += (s->xvel*(sintable[(s->ang+512)&2047]))>>14; s->y += (s->xvel*(sintable[s->ang&2047]))>>14; @@ -728,7 +728,7 @@ static void ms(int i) static void movefta(void) { - long x, px, py, sx, sy; + int x, px, py, sx, sy; int i = headspritestat[2], j, p, nexti; short psect, ssect; spritetype *s; @@ -1019,7 +1019,7 @@ int otherp; static void moveplayers(void) //Players { int i = headspritestat[10], nexti; - long otherx; + int otherx; spritetype *s; player_struct *p; @@ -1154,7 +1154,7 @@ BOLT: static void movefx(void) { int i = headspritestat[11], j, nexti, p; - long x, ht; + int x, ht; spritetype *s; while (i >= 0) @@ -1254,7 +1254,7 @@ static void movefallers(void) { int i = headspritestat[12], nexti, sect, j; spritetype *s; - long x; + int x; while (i >= 0) { @@ -1350,7 +1350,7 @@ BOLT: static void movestandables(void) { int i = headspritestat[6], j, k, nexti, nextj, p=0, sect, switchpicnum; - long l=0, x, *t; + int l=0, x, *t; spritetype *s; short m; @@ -1617,7 +1617,7 @@ static void movestandables(void) if (s->picnum == TRIPBOMB) { - // long lTripBombControl=GetGameVar("TRIPBOMB_CONTROL", TRIPBOMB_TRIPWIRE, -1, -1); + // int lTripBombControl=GetGameVar("TRIPBOMB_CONTROL", TRIPBOMB_TRIPWIRE, -1, -1); // if(lTripBombControl & TRIPBOMB_TIMER) if (hittype[i].temp_data[6] == 1) { @@ -2294,11 +2294,11 @@ BOLT: static void bounce(int i) { - long daang, dax, day, daz, xvect, yvect, zvect; + int daang, dax, day, daz, xvect, yvect, zvect; spritetype *s = &sprite[i]; int hitsect = s->sectnum; - long k = sector[hitsect].wallptr; - long l = wall[k].point2; + int k = sector[hitsect].wallptr; + int l = wall[k].point2; xvect = mulscale10(s->xvel,sintable[(s->ang+512)&2047]); yvect = mulscale10(s->xvel,sintable[s->ang&2047]); @@ -2333,8 +2333,8 @@ static void bounce(int i) static void moveweapons(void) { int i = headspritestat[4], j=0, k, f, nexti, p, q; - long dax,day,daz, x, ll; - unsigned long qq; + int dax,day,daz, x, ll; + unsigned int qq; spritetype *s; while (i >= 0) @@ -3117,7 +3117,7 @@ static void movetransports(void) { int warpspriteto; int i = headspritestat[9], j, k, l, p, sect, sectlotag, nexti, nextj; - long ll,onfloorz,q; + int ll,onfloorz,q; while (i >= 0) { @@ -3459,7 +3459,7 @@ static short LocateTheLocator(int n,int sn) static void moveactors(void) { - long x, m, l, *t; + int x, m, l, *t; int a, j, nexti, nextj, sect, p, switchpicnum, k; spritetype *s; int i = headspritestat[1]; @@ -4434,7 +4434,7 @@ static void moveactors(void) s->xvel >>= 1; } - // long lPipeBombControl=GetGameVar("PIPEBOMB_CONTROL", PIPEBOMB_REMOTE, -1, -1); + // int lPipeBombControl=GetGameVar("PIPEBOMB_CONTROL", PIPEBOMB_REMOTE, -1, -1); DETONATEB: @@ -4786,7 +4786,7 @@ BOLT: static void moveexplosions(void) // STATNUM 5 { short i, j, nexti, sect, p; - long l, x, *t; + int l, x, *t; spritetype *s; int switchpicnum; @@ -5349,7 +5349,7 @@ BOLT: static void moveeffectors(void) //STATNUM 3 { - long q=0, l, m, x, st, j, *t; + int q=0, l, m, x, st, j, *t; int i = headspritestat[3], nexti, nextk, p, sh, nextj; short k; spritetype *s; @@ -5373,7 +5373,7 @@ static void moveeffectors(void) //STATNUM 3 { case 0: { - long zchange = 0; + int zchange = 0; zchange = 0; @@ -5588,7 +5588,7 @@ static void moveeffectors(void) //STATNUM 3 if (s->owner == -1) { - Bsprintf(tempbuf,"Could not find any locators for SE# 6 and 14 with a hitag of %ld.\n",t[3]); + Bsprintf(tempbuf,"Could not find any locators for SE# 6 and 14 with a hitag of %d.\n",t[3]); gameexit(tempbuf); } @@ -6901,23 +6901,23 @@ static void moveeffectors(void) //STATNUM 3 if (t[0] == 0) break; if (s->ang == 1536) - l = (long) &sc->ceilingz; + l = (int) &sc->ceilingz; else - l = (long) &sc->floorz; + l = (int) &sc->floorz; if (t[0] == 1) //Decide if the s->sectnum should go up or down { - s->zvel = ksgn(s->z-*(long *)l) * (SP<<4); + s->zvel = ksgn(s->z-*(int *)l) * (SP<<4); t[0]++; } if (sc->extra == 0) { - *(long *)l += s->zvel; + *(int *)l += s->zvel; - if (klabs(*(long *)l-s->z) < 1024) + if (klabs(*(int *)l-s->z) < 1024) { - *(long *)l = s->z; + *(int *)l = s->z; KILLIT(i); //All done } } @@ -7150,7 +7150,7 @@ static void moveeffectors(void) //STATNUM 3 { if (cansee(s->x,s->y,s->z,SECT,g_player[p].ps->posx,g_player[p].ps->posy,g_player[p].ps->posz,g_player[p].ps->cursectnum)) { - if (x < (long)((unsigned)sh)) + if (x < (int)((unsigned)sh)) { ud.camerasprite = i; t[0] = 999; @@ -7270,7 +7270,7 @@ static void moveeffectors(void) //STATNUM 3 break; case 29: s->hitag += 64; - l = mulscale12((long)s->yvel,sintable[s->hitag&2047]); + l = mulscale12((int)s->yvel,sintable[s->hitag&2047]); sc->floorz = s->z + l; break; case 31: // True Drop Floor @@ -7596,7 +7596,7 @@ void moveobjects(void) while (i >= 0) { int p, j = nextspritestat[i]; - OnEvent(EVENT_GAME,i, findplayer(&sprite[i],(long *)&p), p); + OnEvent(EVENT_GAME,i, findplayer(&sprite[i],(int *)&p), p); i = j; } } diff --git a/polymer/eduke32/source/anim.c b/polymer/eduke32/source/anim.c index d73d84e3e..1596357cb 100644 --- a/polymer/eduke32/source/anim.c +++ b/polymer/eduke32/source/anim.c @@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "animlib.h" #include "mouse.h" -void endanimsounds(long fr) +void endanimsounds(int fr) { switch (ud.volume_number) { @@ -91,7 +91,7 @@ void endanimsounds(long fr) } } -void logoanimsounds(long fr) +void logoanimsounds(int fr) { switch (fr) { @@ -104,7 +104,7 @@ void logoanimsounds(long fr) } } -void intro4animsounds(long fr) +void intro4animsounds(int fr) { switch (fr) { @@ -121,7 +121,7 @@ void intro4animsounds(long fr) } } -void first4animsounds(long fr) +void first4animsounds(int fr) { switch (fr) { @@ -140,7 +140,7 @@ void first4animsounds(long fr) } } -void intro42animsounds(long fr) +void intro42animsounds(int fr) { switch (fr) { @@ -150,7 +150,7 @@ void intro42animsounds(long fr) } } -void endanimvol41(long fr) +void endanimvol41(int fr) { switch (fr) { @@ -163,7 +163,7 @@ void endanimvol41(long fr) } } -void endanimvol42(long fr) +void endanimvol42(int fr) { switch (fr) { @@ -182,7 +182,7 @@ void endanimvol42(long fr) } } -void endanimvol43(long fr) +void endanimvol43(int fr) { switch (fr) { @@ -203,7 +203,7 @@ void playanm(const char *fn,char t) { char *animbuf; unsigned char *palptr; - long i, j, length=0, numframes=0; + int i, j, length=0, numframes=0; #if defined(POLYMOST) && defined(USE_OPENGL) int ogltexfiltermode=gltexfiltermode; #endif @@ -226,7 +226,7 @@ void playanm(const char *fn,char t) walock[TILE_ANIM] = 219+t; - allocache((long *)&animbuf,length,&walock[TILE_ANIM]); + allocache((int *)&animbuf,length,&walock[TILE_ANIM]); tilesizx[TILE_ANIM] = 200; tilesizy[TILE_ANIM] = 320; diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index cc093c36b..63c296914 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -181,8 +181,8 @@ static int getfilenames(const char *path, char kind[]) void ExtLoadMap(const char *mapname) { - long i; - long sky=0; + int i; + int sky=0; int j; // PreCache Wall Tiles /* @@ -607,7 +607,7 @@ const char *ExtGetSpriteCaption(short spritenum) } //end //printext16 parameters: -//printext16(long xpos, long ypos, short col, short backcol, +//printext16(int xpos, int ypos, short col, short backcol, // char name[82], char fontsize) // xpos 0-639 (top left) // ypos 0-479 (top left) @@ -617,7 +617,7 @@ const char *ExtGetSpriteCaption(short spritenum) // fontsize 0=8*8, 1=3*5 //drawline16 parameters: -// drawline16(long x1, long y1, long x2, long y2, char col) +// drawline16(int x1, int y1, int x2, int y2, char col) // x1, x2 0-639 // y1, y2 0-143 (status bar is 144 high, origin is top-left of STATUS BAR) // col 0-15 @@ -1238,14 +1238,14 @@ static void ResetFOFSize() if (fofsizey != -1) tilesizy[FOF] = fofsizey; } -static void ExtSE40Draw(int spnum,long x,long y,long z,short a,short h) +static void ExtSE40Draw(int spnum,int x,int y,int z,short a,short h) { - static long tempsectorz[MAXSECTORS]; - static long tempsectorpicnum[MAXSECTORS]; + static int tempsectorz[MAXSECTORS]; + static int tempsectorpicnum[MAXSECTORS]; int i=0,j=0,k=0; int floor1=0,floor2=0,ok=0,fofmode=0,draw_both=0; - long offx,offy,offz; + int offx,offy,offz; if (sprite[spnum].ang!=512) return; @@ -1393,7 +1393,7 @@ static void ExtSE40Draw(int spnum,long x,long y,long z,short a,short h) } // end SE40 -static void SE40Code(long x,long y,long z,long a,long h) +static void SE40Code(int x,int y,int z,int a,int h) { int i; @@ -1576,7 +1576,7 @@ static void message(char message[162]) static char lockbyte4094; -static long lastupdate, mousecol, mouseadd = 1, bstatus; +static int lastupdate, mousecol, mouseadd = 1, bstatus; static void m32_showmouse(void) { @@ -1678,9 +1678,9 @@ static int AskIfSure(void) return(retval); } -static long IsValidTile(const long idTile) +static int IsValidTile(const int idTile) { - long bValid = 0; + int bValid = 0; if ((idTile >= 0) && (idTile < MAXTILES)) { @@ -1693,9 +1693,9 @@ static long IsValidTile(const long idTile) return bValid; } -static long SelectAllTiles(long iCurrentTile) +static int SelectAllTiles(int iCurrentTile) { - long i; + int i; if (iCurrentTile < localartlookupnum) { @@ -1717,22 +1717,22 @@ static long SelectAllTiles(long iCurrentTile) return iCurrentTile; } -static long OnGotoTile(long iTile); -static long OnSelectTile(long iTile); -static long s_Zoom = INITIAL_ZOOM; -static long s_TileZoom = 1; +static int OnGotoTile(int iTile); +static int OnSelectTile(int iTile); +static int s_Zoom = INITIAL_ZOOM; +static int s_TileZoom = 1; -static long DrawTiles(long iTopLeft, long iSelected, long nXTiles, long nYTiles, long TileDim); +static int DrawTiles(int iTopLeft, int iSelected, int nXTiles, int nYTiles, int TileDim); -static long m32gettile(long idInitialTile) +static int m32gettile(int idInitialTile) { - long gap, temp; - long nXTiles, nYTiles, nDisplayedTiles; - long i; - long iTile, iTopLeftTile; - long idSelectedTile; - long j; + int gap, temp; + int nXTiles, nYTiles, nDisplayedTiles; + int i; + int iTile, iTopLeftTile; + int idSelectedTile; + int j; char ch, szTemp[128]; @@ -1829,15 +1829,15 @@ static long m32gettile(long idInitialTile) while ((localartfreq[temp] < localartfreq[temp+gap]) && (temp >= 0)) { - long templong; + int tempint; - templong = localartfreq[temp]; + tempint = localartfreq[temp]; localartfreq[temp] = localartfreq[temp+gap]; - localartfreq[temp+gap] = templong; + localartfreq[temp+gap] = tempint; - templong = localartlookup[temp]; + tempint = localartlookup[temp]; localartlookup[temp] = localartlookup[temp+gap]; - localartlookup[temp+gap] = templong; + localartlookup[temp+gap] = tempint; if (iTile == temp) { @@ -2133,13 +2133,13 @@ static long m32gettile(long idInitialTile) } // Dir = 0 (zoom out) or 1 (zoom in) -//void OnZoomInOut( long *pZoom, long Dir /*0*/ ) +//void OnZoomInOut( int *pZoom, int Dir /*0*/ ) //{ //} -static long OnGotoTile(long iTile) +static int OnGotoTile(int iTile) { - long iTemp, iNewTile; + int iTemp, iNewTile; char ch; char szTemp[128]; @@ -2160,7 +2160,7 @@ static long OnGotoTile(long iTile) ch = bgetchar(); - Bsprintf(szTemp, "Goto tile: %ld_ ", iNewTile); + Bsprintf(szTemp, "Goto tile: %d_ ", iNewTile); printext256(0, 0, whitecol, 0, szTemp, 0); showframe(1); @@ -2188,10 +2188,10 @@ static long OnGotoTile(long iTile) return iTile; } -static long LoadTileSet(const long idCurrentTile, const long *pIds, const long nIds) +static int LoadTileSet(const int idCurrentTile, const int *pIds, const int nIds) { - long iNewTile = 0; - long i; + int iNewTile = 0; + int i; localartlookupnum = nIds; @@ -2212,10 +2212,10 @@ static long LoadTileSet(const long idCurrentTile, const long *pIds, const long n } -static long OnSelectTile(long iTile) +static int OnSelectTile(int iTile) { - long bDone = 0; - long i, j; + int bDone = 0; + int i, j; char ch; for (i = 0; (unsigned)i < tile_groups; i++) @@ -2285,7 +2285,7 @@ static long OnSelectTile(long iTile) return iTile; } -const char * GetTilePixels(const long idTile) +const char * GetTilePixels(const int idTile) { char *pPixelData = 0; @@ -2307,17 +2307,17 @@ const char * GetTilePixels(const long idTile) #define PIXELS_PER_DISPLAY_LINE ylookup[1] -static long DrawTiles(long iTopLeft, long iSelected, long nXTiles, long nYTiles, long TileDim) +static int DrawTiles(int iTopLeft, int iSelected, int nXTiles, int nYTiles, int TileDim) { - long XTile, YTile; - long iTile, idTile; - long XBox, YBox; - long XPos, YPos; - long XOffset, YOffset; - long i; + int XTile, YTile; + int iTile, idTile; + int XBox, YBox; + int XPos, YPos; + int XOffset, YOffset; + int i; const char * pRawPixels; - long TileSizeX, TileSizeY; - long DivInc,MulInc; + int TileSizeX, TileSizeY; + int DivInc,MulInc; char *pScreen; char szT[128]; @@ -2410,7 +2410,7 @@ static long DrawTiles(long iTopLeft, long iSelected, long nXTiles, long nYTiles, idTile = localartlookup[ iSelected ]; - Bsprintf(szT, "%ld" , idTile); + Bsprintf(szT, "%d" , idTile); printext256(0L, ydim-8, whitecol, -1, szT, 0); printext256(xdim-(Bstrlen(names[idTile])<<3),ydim-8,whitecol,-1,names[idTile],0); @@ -2426,10 +2426,10 @@ static long DrawTiles(long iTopLeft, long iSelected, long nXTiles, long nYTiles, static void Keys3d(void) { - long i,count,rate,nexti; - long j, k, templong = 0, changedir, hiz, loz; - long hitx, hity, hitz, hihit, lohit; - long repeatcountx=0,repeatcounty=0; + int i,count,rate,nexti; + int j, k, tempint = 0, changedir, hiz, loz; + int hitx, hity, hitz, hihit, lohit; + int repeatcountx=0,repeatcounty=0; char smooshyalign=0, repeatpanalign=0, buffer[80]; short startwall, endwall, dasector, hitsect, hitwall, hitsprite, statnum=0; @@ -2519,11 +2519,11 @@ static void Keys3d(void) case 0: case 4: { - long dax, day, dist; + int dax, day, dist; dax = wall[searchwall].x-wall[wall[searchwall].point2].x; day = wall[searchwall].y-wall[wall[searchwall].point2].y; dist = ksqrt(dax*dax+day*day); - Bsprintf(msgbuf,"Wall %d: length:%ld lo:%d hi:%d ex:%d",searchwall,dist,wall[searchwall].lotag,wall[searchwall].hitag,wall[searchwall].extra); + Bsprintf(msgbuf,"Wall %d: length:%d lo:%d hi:%d ex:%d",searchwall,dist,wall[searchwall].lotag,wall[searchwall].hitag,wall[searchwall].extra); _message(msgbuf); break; } @@ -2589,21 +2589,21 @@ static void Keys3d(void) if (keystatus[KEYSC_V] > 0) //V { - if (searchstat == 0) templong = wall[searchwall].picnum; - if (searchstat == 1) templong = sector[searchsector].ceilingpicnum; - if (searchstat == 2) templong = sector[searchsector].floorpicnum; - if (searchstat == 3) templong = sprite[searchwall].picnum; - if (searchstat == 4) templong = wall[searchwall].overpicnum; - templong = m32gettile(templong); - if (searchstat == 0) wall[searchwall].picnum = templong; - if (searchstat == 1) sector[searchsector].ceilingpicnum = templong; - if (searchstat == 2) sector[searchsector].floorpicnum = templong; - if (searchstat == 3) sprite[searchwall].picnum = templong; + if (searchstat == 0) tempint = wall[searchwall].picnum; + if (searchstat == 1) tempint = sector[searchsector].ceilingpicnum; + if (searchstat == 2) tempint = sector[searchsector].floorpicnum; + if (searchstat == 3) tempint = sprite[searchwall].picnum; + if (searchstat == 4) tempint = wall[searchwall].overpicnum; + tempint = m32gettile(tempint); + if (searchstat == 0) wall[searchwall].picnum = tempint; + if (searchstat == 1) sector[searchsector].ceilingpicnum = tempint; + if (searchstat == 2) sector[searchsector].floorpicnum = tempint; + if (searchstat == 3) sprite[searchwall].picnum = tempint; if (searchstat == 4) { - wall[searchwall].overpicnum = templong; + wall[searchwall].overpicnum = tempint; if (wall[searchwall].nextwall >= 0) - wall[wall[searchwall].nextwall].overpicnum = templong; + wall[wall[searchwall].nextwall].overpicnum = tempint; } asksave = 1; keystatus[0x2f] = 0; @@ -2783,7 +2783,7 @@ static void Keys3d(void) sprite[i].ang = ((sprite[i].ang+2048-128)&2047); keystatus[0x33] = 0; } - Bsprintf(tempbuf,"Sprite %ld angle: %d",i,sprite[i].ang); + Bsprintf(tempbuf,"Sprite %d angle: %d",i,sprite[i].ang); message(tempbuf); } } @@ -2791,7 +2791,7 @@ static void Keys3d(void) { if ((searchstat == 0) || (searchstat == 4)) { - AutoAlignWalls((long)searchwall,0L); + AutoAlignWalls((int)searchwall,0L); keystatus[0x34] = 0; } if (searchstat == 3) @@ -2804,7 +2804,7 @@ static void Keys3d(void) sprite[i].ang = ((sprite[i].ang+2048+128)&2047); keystatus[0x34] = 0; } - Bsprintf(tempbuf,"Sprite %ld angle: %d",i,sprite[i].ang); + Bsprintf(tempbuf,"Sprite %d angle: %d",i,sprite[i].ang); message(tempbuf); } } @@ -2874,19 +2874,19 @@ static void Keys3d(void) case 0: case 4: strcpy(buffer,"Wall extra: "); - wall[searchwall].extra = getnumber256(buffer,(long)wall[searchwall].extra,65536L,1); + wall[searchwall].extra = getnumber256(buffer,(int)wall[searchwall].extra,65536L,1); break; case 1: strcpy(buffer,"Sector extra: "); - sector[searchsector].extra = getnumber256(buffer,(long)sector[searchsector].extra,65536L,1); + sector[searchsector].extra = getnumber256(buffer,(int)sector[searchsector].extra,65536L,1); break; case 2: strcpy(buffer,"Sector extra: "); - sector[searchsector].extra = getnumber256(buffer,(long)sector[searchsector].extra,65536L,1); + sector[searchsector].extra = getnumber256(buffer,(int)sector[searchsector].extra,65536L,1); break; case 3: strcpy(buffer,"Sprite extra: "); - sprite[searchwall].extra = getnumber256(buffer,(long)sprite[searchwall].extra,65536L,1); + sprite[searchwall].extra = getnumber256(buffer,(int)sprite[searchwall].extra,65536L,1); break; } asksave = 1; @@ -2971,7 +2971,7 @@ static void Keys3d(void) if (searchstat != 3) { i = wall[searchwall].nextwall; - templong = (keystatus[0x2a]|keystatus[0x36]); + tempint = (keystatus[0x2a]|keystatus[0x36]); if (i >= 0) { wall[searchwall].cstat ^= 16; @@ -2980,7 +2980,7 @@ static void Keys3d(void) if ((wall[searchwall].cstat&16) > 0) { wall[searchwall].cstat &= ~8; - if (templong == 0) + if (tempint == 0) { wall[i].cstat |= 8; //auto other-side flip wall[i].cstat |= 16; @@ -2990,14 +2990,14 @@ static void Keys3d(void) else { wall[searchwall].cstat &= ~8; - if (templong == 0) + if (tempint == 0) { wall[i].cstat &= ~8; //auto other-side unflip wall[i].cstat &= ~16; } } wall[searchwall].cstat &= ~32; - if (templong == 0) wall[i].cstat &= ~32; + if (tempint == 0) wall[i].cstat &= ~32; asksave = 1; } } @@ -3013,19 +3013,19 @@ static void Keys3d(void) case 0: case 4: strcpy(buffer,"Wall hitag: "); - wall[searchwall].hitag = getnumber256(buffer,(long)wall[searchwall].hitag,65536L,0); + wall[searchwall].hitag = getnumber256(buffer,(int)wall[searchwall].hitag,65536L,0); break; case 1: strcpy(buffer,"Sector hitag: "); - sector[searchsector].hitag = getnumber256(buffer,(long)sector[searchsector].hitag,65536L,0); + sector[searchsector].hitag = getnumber256(buffer,(int)sector[searchsector].hitag,65536L,0); break; case 2: strcpy(buffer,"Sector hitag: "); - sector[searchsector].hitag = getnumber256(buffer,(long)sector[searchsector].hitag,65536L,0); + sector[searchsector].hitag = getnumber256(buffer,(int)sector[searchsector].hitag,65536L,0); break; case 3: strcpy(buffer,"Sprite hitag: "); - sprite[searchwall].hitag = getnumber256(buffer,(long)sprite[searchwall].hitag,65536L,0); + sprite[searchwall].hitag = getnumber256(buffer,(int)sprite[searchwall].hitag,65536L,0); break; } } @@ -3542,15 +3542,15 @@ static void Keys3d(void) i = headspritesect[searchsector]; while (i != -1) { - templong = getceilzofslope(searchsector,sprite[i].x,sprite[i].y); - templong += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<2); - if (sprite[i].cstat&128) templong += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); - if (sprite[i].z == templong) + tempint = getceilzofslope(searchsector,sprite[i].x,sprite[i].y); + tempint += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<2); + if (sprite[i].cstat&128) tempint += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); + if (sprite[i].z == tempint) sprite[i].z -= updownunits << ((keystatus[0x1d]|keystatus[0x9d])<<1); // JBF 20031128 i = nextspritesect[i]; } sector[searchsector].ceilingz -= updownunits << ((keystatus[0x1d]|keystatus[0x9d])<<1); // JBF 20031128 - sprintf(getmessage,"Sector %d ceilingz = %ld",searchsector,sector[searchsector].ceilingz); + sprintf(getmessage,"Sector %d ceilingz = %d",searchsector,sector[searchsector].ceilingz); message(getmessage); } @@ -3561,15 +3561,15 @@ static void Keys3d(void) i = headspritesect[highlightsector[j]]; while (i != -1) { - templong = getceilzofslope(highlightsector[j],sprite[i].x,sprite[i].y); - templong += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<2); - if (sprite[i].cstat&128) templong += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); - if (sprite[i].z == templong) + tempint = getceilzofslope(highlightsector[j],sprite[i].x,sprite[i].y); + tempint += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<2); + if (sprite[i].cstat&128) tempint += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); + if (sprite[i].z == tempint) sprite[i].z -= updownunits << ((keystatus[0x1d]|keystatus[0x9d])<<1); // JBF 20031128 i = nextspritesect[i]; } sector[highlightsector[j]].ceilingz -= updownunits << ((keystatus[0x1d]|keystatus[0x9d])<<1); // JBF 20031128 - sprintf(getmessage,"Sector %d ceilingz = %ld",*highlightsector,sector[highlightsector[j]].ceilingz); + sprintf(getmessage,"Sector %d ceilingz = %d",*highlightsector,sector[highlightsector[j]].ceilingz); message(getmessage); } @@ -3582,14 +3582,14 @@ static void Keys3d(void) i = headspritesect[searchsector]; while (i != -1) { - templong = getflorzofslope(searchsector,sprite[i].x,sprite[i].y); - if (sprite[i].cstat&128) templong += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); - if (sprite[i].z == templong) + tempint = getflorzofslope(searchsector,sprite[i].x,sprite[i].y); + if (sprite[i].cstat&128) tempint += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); + if (sprite[i].z == tempint) sprite[i].z -= updownunits << ((keystatus[0x1d]|keystatus[0x9d])<<1); // JBF 20031128 i = nextspritesect[i]; } sector[searchsector].floorz -= updownunits << ((keystatus[0x1d]|keystatus[0x9d])<<1); // JBF 20031128 - sprintf(getmessage,"Sector %d floorz = %ld",searchsector,sector[searchsector].floorz); + sprintf(getmessage,"Sector %d floorz = %d",searchsector,sector[searchsector].floorz); message(getmessage); } @@ -3600,14 +3600,14 @@ static void Keys3d(void) i = headspritesect[highlightsector[j]]; while (i != -1) { - templong = getflorzofslope(highlightsector[j],sprite[i].x,sprite[i].y); - if (sprite[i].cstat&128) templong += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); - if (sprite[i].z == templong) + tempint = getflorzofslope(highlightsector[j],sprite[i].x,sprite[i].y); + if (sprite[i].cstat&128) tempint += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); + if (sprite[i].z == tempint) sprite[i].z -= updownunits << ((keystatus[0x1d]|keystatus[0x9d])<<1); // JBF 20031128 i = nextspritesect[i]; } sector[highlightsector[j]].floorz -= updownunits << ((keystatus[0x1d]|keystatus[0x9d])<<1); // JBF 20031128 - sprintf(getmessage,"Sector %d floorz = %ld",*highlightsector,sector[highlightsector[j]].floorz); + sprintf(getmessage,"Sector %d floorz = %d",*highlightsector,sector[highlightsector[j]].floorz); message(getmessage); } @@ -3639,7 +3639,7 @@ static void Keys3d(void) if (k == 0) { sprite[searchwall].z -= updownunits; - sprintf(getmessage,"Sprite %d z = %ld",searchwall,sprite[searchwall].z); + sprintf(getmessage,"Sprite %d z = %d",searchwall,sprite[searchwall].z); message(getmessage); } @@ -3648,7 +3648,7 @@ static void Keys3d(void) for (i=0;i 9) p += 8; if (rate > 99) p += 8; if (rate > 999) p += 8; @@ -4257,19 +4257,19 @@ static void Keys3d(void) case 0: case 4: strcpy(buffer,"Wall lotag: "); - wall[searchwall].lotag = getnumber256(buffer,(long)wall[searchwall].lotag,65536L,0); + wall[searchwall].lotag = getnumber256(buffer,(int)wall[searchwall].lotag,65536L,0); break; case 1: strcpy(buffer,"Sector lotag: "); - sector[searchsector].lotag = getnumber256(buffer,(long)sector[searchsector].lotag,65536L,0); + sector[searchsector].lotag = getnumber256(buffer,(int)sector[searchsector].lotag,65536L,0); break; case 2: strcpy(buffer,"Sector lotag: "); - sector[searchsector].lotag = getnumber256(buffer,(long)sector[searchsector].lotag,65536L,0); + sector[searchsector].lotag = getnumber256(buffer,(int)sector[searchsector].lotag,65536L,0); break; case 3: strcpy(buffer,"Sprite lotag: "); - sprite[searchwall].lotag = getnumber256(buffer,(long)sprite[searchwall].lotag,65536L,0); + sprite[searchwall].lotag = getnumber256(buffer,(int)sprite[searchwall].lotag,65536L,0); break; } } @@ -4339,13 +4339,13 @@ static void Keys2d(void) { short temp=0; int i=0, j,k; - long radius, xp1, yp1; + int radius, xp1, yp1; char col; - long repeatcountx=0,repeatcounty=0,smooshyalign,changedir; + int repeatcountx=0,repeatcounty=0,smooshyalign,changedir; /* for(i=0;i<0x50;i++) - {if(keystatus[i]==1) {Bsprintf(tempbuf,"key %ld",i); printmessage16(tempbuf); + {if(keystatus[i]==1) {Bsprintf(tempbuf,"key %d",i); printmessage16(tempbuf); }} */ @@ -4371,11 +4371,11 @@ static void Keys2d(void) } else if ((linehighlight >= 0) && (sectorofwall(linehighlight) == cursectornum)) { - long dax, day, dist; + int dax, day, dist; dax = wall[linehighlight].x-wall[wall[linehighlight].point2].x; day = wall[linehighlight].y-wall[wall[linehighlight].point2].y; dist = ksqrt(dax*dax+day*day); - Bsprintf(tempbuf,"Wall %d: length:%ld lo:%d hi:%d ex:%d",linehighlight,dist,wall[linehighlight].lotag,wall[linehighlight].hitag,wall[linehighlight].extra); + Bsprintf(tempbuf,"Wall %d: length:%d lo:%d hi:%d ex:%d",linehighlight,dist,wall[linehighlight].lotag,wall[linehighlight].hitag,wall[linehighlight].extra); _printmessage16(tempbuf); } else if (cursectornum >= 0) @@ -4845,7 +4845,7 @@ static void Keys2d(void) { posx=getnumber16("X-coordinate: ",posx,131072L,1); posy=getnumber16("Y-coordinate: ",posy,131072L,1); - Bsprintf(tempbuf,"Current pos now (%ld, %ld)",posx,posy); + Bsprintf(tempbuf,"Current pos now (%d, %d)",posx,posy); printmessage16(tempbuf); keystatus[0x24]=0; } @@ -5235,7 +5235,7 @@ static int osdcmd_editorgridextent(const osdfuncparm_t *parm) if (parm->numparms == 0) { - OSD_Printf("\"editorgridextent\" is \"%ld\"\n", editorgridextent); + OSD_Printf("\"editorgridextent\" is \"%d\"\n", editorgridextent); return OSDCMD_SHOWHELP; } else if (parm->numparms != 1) return OSDCMD_SHOWHELP; @@ -5245,7 +5245,7 @@ static int osdcmd_editorgridextent(const osdfuncparm_t *parm) if (i >= 65536 && i <= 524288) { editorgridextent = i; - OSD_Printf("editorgridextent %ld\n", editorgridextent); + OSD_Printf("editorgridextent %d\n", editorgridextent); } else OSD_Printf("editorgridextent: value out of range\n"); return OSDCMD_OK; @@ -5288,7 +5288,7 @@ static int osdcmd_echo(const osdfuncparm_t *parm) static int osdcmd_fileinfo(const osdfuncparm_t *parm) { - unsigned long crc, length; + unsigned int crc, length; int i,j; char buf[256]; @@ -5442,7 +5442,7 @@ void GAME_drawosdstr(int x, int y, char *ch, int len, int shade, int pal) } } -static long GetTime(void) +static int GetTime(void) { return totalclock; } @@ -5479,8 +5479,8 @@ int GAME_getrowheight(int w) #define PALETTE 4 void GAME_clearbackground(int c, int r) { - long x, y, xsiz, ysiz, tx2, ty2; - long daydim, bits; + int x, y, xsiz, ysiz, tx2, ty2; + int daydim, bits; #ifdef _WIN32 if (qsetmode != 200) @@ -5721,7 +5721,7 @@ int parsetilegroups(scriptfile *script) if (scriptfile_getstring(script,&name)) break; if (scriptfile_getbraces(script,&end)) break; - s_TileGroups[tile_groups].pIds = Bcalloc(MAX_TILE_GROUP_ENTRIES,sizeof(long)); + s_TileGroups[tile_groups].pIds = Bcalloc(MAX_TILE_GROUP_ENTRIES,sizeof(int)); s_TileGroups[tile_groups].szText = Bstrdup(name); while (script->textptr < end) @@ -5784,7 +5784,7 @@ int parsetilegroups(scriptfile *script) } } } - s_TileGroups[tile_groups].pIds = Brealloc(s_TileGroups[tile_groups].pIds,s_TileGroups[tile_groups].nIds*sizeof(long)); + s_TileGroups[tile_groups].pIds = Brealloc(s_TileGroups[tile_groups].pIds,s_TileGroups[tile_groups].nIds*sizeof(int)); tile_groups++; break; } @@ -5821,7 +5821,7 @@ int loadtilegroups(char *fn) int ExtInit(void) { - long rv = 0; + int rv = 0; int i; char cwd[BMAX_PATH]; @@ -6046,7 +6046,7 @@ void ExtPreCheckKeys(void) // just before drawrooms void ExtAnalyzeSprites(void) { - long i, k; + int i, k; spritetype *tspr; int frames=0, l; @@ -6311,8 +6311,8 @@ void ExtCheckKeys(void) void faketimerhandler(void) { - long i, dist; - long hiz, hihit, loz, lohit, oposx, oposy; + int i, dist; + int hiz, hihit, loz, lohit, oposx, oposy; short hitwall, daang; counter++; @@ -6345,8 +6345,8 @@ void faketimerhandler(void) if (yvel > 0) yvel--; i = 4-keystatus[buildkeys[4]]; - xvel += mulscale(vel,(long)sintable[(ang+512)&2047],i); - yvel += mulscale(vel,(long)sintable[ang&2047],i); + xvel += mulscale(vel,(int)sintable[(ang+512)&2047],i); + yvel += mulscale(vel,(int)sintable[ang&2047],i); if (((daang-ang)&2047) < 1024) ang = ((ang+((((daang-ang)&2047)+24)>>4))&2047); @@ -6418,7 +6418,7 @@ static void SetGAMEPalette() static void kensetpalette(char *vgapal) { - long i; + int i; char vesapal[1024]; for (i=0;i<256;i++) @@ -6433,7 +6433,7 @@ static void kensetpalette(char *vgapal) static void SearchSectorsForward() { - long ii=0; + int ii=0; if (cursector_lotag!=0) { if (cursectornum0) cursectornum--; @@ -6483,7 +6483,7 @@ static void EditSectorData(short sectnum) char disptext[80]; char edittext[80]; int col=1, row=0, rowmax = 6, dispwidth = 24, editval = 0, i = -1; - long xpos = 200, ypos = ydim-STATUS2DSIZ+48; + int xpos = 200, ypos = ydim-STATUS2DSIZ+48; disptext[dispwidth] = 0; clearmidstatbar16(); @@ -6560,7 +6560,7 @@ static void EditSectorData(short sectnum) if (editval) { printmessage16(edittext); - sector[sectnum].ceilingstat = (short)getnumber16(edittext,(long)sector[sectnum].ceilingstat,65536L,0); + sector[sectnum].ceilingstat = (short)getnumber16(edittext,(int)sector[sectnum].ceilingstat,65536L,0); } break; case 1: @@ -6569,10 +6569,10 @@ static void EditSectorData(short sectnum) { Bsprintf(edittext,"Sector %d Ceiling X Pan: ",sectnum); printmessage16(edittext); - sector[sectnum].ceilingxpanning = (char)getnumber16(edittext,(long)sector[sectnum].ceilingxpanning,256L,0); + sector[sectnum].ceilingxpanning = (char)getnumber16(edittext,(int)sector[sectnum].ceilingxpanning,256L,0); Bsprintf(edittext,"Sector %d Ceiling Y Pan: ",sectnum); printmessage16(edittext); - sector[sectnum].ceilingypanning = (char)getnumber16(edittext,(long)sector[sectnum].ceilingypanning,256L,0); + sector[sectnum].ceilingypanning = (char)getnumber16(edittext,(int)sector[sectnum].ceilingypanning,256L,0); } break; case 2: @@ -6581,12 +6581,12 @@ static void EditSectorData(short sectnum) if (editval) { printmessage16(edittext); - sector[sectnum].ceilingshade = (char)getnumber16(edittext,(long)sector[sectnum].ceilingshade,128L,1); + sector[sectnum].ceilingshade = (char)getnumber16(edittext,(int)sector[sectnum].ceilingshade,128L,1); } break; case 3: - for (i=Bsprintf(disptext,"Z-coordinate: %ld",sector[sectnum].ceilingz); i < dispwidth; i++) disptext[i] = ' '; + for (i=Bsprintf(disptext,"Z-coordinate: %d",sector[sectnum].ceilingz); i < dispwidth; i++) disptext[i] = ' '; Bsprintf(edittext,"Sector %d Ceiling Z-coordinate: ",sectnum); if (editval) { @@ -6601,7 +6601,7 @@ static void EditSectorData(short sectnum) if (editval) { printmessage16(edittext); - sector[sectnum].ceilingpicnum = (short)getnumber16(edittext,(long)sector[sectnum].ceilingpicnum,MAXTILES,0); + sector[sectnum].ceilingpicnum = (short)getnumber16(edittext,(int)sector[sectnum].ceilingpicnum,MAXTILES,0); } break; @@ -6611,7 +6611,7 @@ static void EditSectorData(short sectnum) if (editval) { printmessage16(edittext); - sector[sectnum].ceilingheinum = (short)getnumber16(edittext,(long)sector[sectnum].ceilingheinum,65536L,1); + sector[sectnum].ceilingheinum = (short)getnumber16(edittext,(int)sector[sectnum].ceilingheinum,65536L,1); } break; @@ -6621,7 +6621,7 @@ static void EditSectorData(short sectnum) if (editval) { printmessage16(edittext); - sector[sectnum].ceilingpal = (char)getnumber16(edittext,(long)sector[sectnum].ceilingpal,MAXPALOOKUPS,0); + sector[sectnum].ceilingpal = (char)getnumber16(edittext,(int)sector[sectnum].ceilingpal,MAXPALOOKUPS,0); } break; } @@ -6636,7 +6636,7 @@ static void EditSectorData(short sectnum) if (editval) { printmessage16(edittext); - sector[sectnum].floorstat = (short)getnumber16(edittext,(long)sector[sectnum].floorstat,65536L,0); + sector[sectnum].floorstat = (short)getnumber16(edittext,(int)sector[sectnum].floorstat,65536L,0); } break; @@ -6646,10 +6646,10 @@ static void EditSectorData(short sectnum) { Bsprintf(edittext,"Sector %d Floor X Pan: ",sectnum); printmessage16(edittext); - sector[sectnum].floorxpanning = (char)getnumber16(edittext,(long)sector[sectnum].floorxpanning,256L,0); + sector[sectnum].floorxpanning = (char)getnumber16(edittext,(int)sector[sectnum].floorxpanning,256L,0); Bsprintf(edittext,"Sector %d Floor Y Pan: ",sectnum); printmessage16(edittext); - sector[sectnum].floorypanning = (char)getnumber16(edittext,(long)sector[sectnum].floorypanning,256L,0); + sector[sectnum].floorypanning = (char)getnumber16(edittext,(int)sector[sectnum].floorypanning,256L,0); } break; @@ -6659,12 +6659,12 @@ static void EditSectorData(short sectnum) if (editval) { printmessage16(edittext); - sector[sectnum].floorshade = (char)getnumber16(edittext,(long)sector[sectnum].floorshade,128L,1L); + sector[sectnum].floorshade = (char)getnumber16(edittext,(int)sector[sectnum].floorshade,128L,1L); } break; case 3: - for (i=Bsprintf(disptext,"Z-coordinate: %ld",sector[sectnum].floorz); i < dispwidth; i++) disptext[i] = ' '; + for (i=Bsprintf(disptext,"Z-coordinate: %d",sector[sectnum].floorz); i < dispwidth; i++) disptext[i] = ' '; Bsprintf(edittext,"Sector %d Floor Z-coordinate: ",sectnum); if (editval) { @@ -6679,7 +6679,7 @@ static void EditSectorData(short sectnum) if (editval) { printmessage16(edittext); - sector[sectnum].floorpicnum = (short)getnumber16(edittext,(long)sector[sectnum].floorpicnum,MAXTILES,0); + sector[sectnum].floorpicnum = (short)getnumber16(edittext,(int)sector[sectnum].floorpicnum,MAXTILES,0); } break; case 5: @@ -6688,7 +6688,7 @@ static void EditSectorData(short sectnum) if (editval) { printmessage16(edittext); - sector[sectnum].floorheinum = (short)getnumber16(edittext,(long)sector[sectnum].floorheinum,65536L,1); + sector[sectnum].floorheinum = (short)getnumber16(edittext,(int)sector[sectnum].floorheinum,65536L,1); } break; case 6: @@ -6697,7 +6697,7 @@ static void EditSectorData(short sectnum) if (editval) { printmessage16(edittext); - sector[sectnum].floorpal = (char)getnumber16(edittext,(long)sector[sectnum].floorpal,MAXPALOOKUPS,0); + sector[sectnum].floorpal = (char)getnumber16(edittext,(int)sector[sectnum].floorpal,MAXPALOOKUPS,0); } break; } @@ -6721,7 +6721,7 @@ static void EditWallData(short wallnum) char disptext[80]; char edittext[80]; int row=0, dispwidth = 24, editval = 0, i = -1; - long xpos = 200, ypos = ydim-STATUS2DSIZ+48; + int xpos = 200, ypos = ydim-STATUS2DSIZ+48; disptext[dispwidth] = 0; clearmidstatbar16(); @@ -6766,7 +6766,7 @@ static void EditWallData(short wallnum) if (editval) { printmessage16(edittext); - wall[wallnum].cstat = (short)getnumber16(edittext,(long)wall[wallnum].cstat,65536L,0); + wall[wallnum].cstat = (short)getnumber16(edittext,(int)wall[wallnum].cstat,65536L,0); } break; case 1: @@ -6775,7 +6775,7 @@ static void EditWallData(short wallnum) if (editval) { printmessage16(edittext); - wall[wallnum].shade = (char)getnumber16(edittext,(long)wall[wallnum].shade,128,1); + wall[wallnum].shade = (char)getnumber16(edittext,(int)wall[wallnum].shade,128,1); } break; case 2: @@ -6784,7 +6784,7 @@ static void EditWallData(short wallnum) if (editval) { printmessage16(edittext); - wall[wallnum].pal = (char)getnumber16(edittext,(long)wall[wallnum].pal,MAXPALOOKUPS,0); + wall[wallnum].pal = (char)getnumber16(edittext,(int)wall[wallnum].pal,MAXPALOOKUPS,0); } break; case 3: @@ -6793,10 +6793,10 @@ static void EditWallData(short wallnum) { Bsprintf(edittext,"Wall %d X Repeat: ",wallnum); printmessage16(edittext); - wall[wallnum].xrepeat = (char)getnumber16(edittext,(long)wall[wallnum].xrepeat,256L,0); + wall[wallnum].xrepeat = (char)getnumber16(edittext,(int)wall[wallnum].xrepeat,256L,0); Bsprintf(edittext,"Wall %d Y Repeat: ",wallnum); printmessage16(edittext); - wall[wallnum].yrepeat = (char)getnumber16(edittext,(long)wall[wallnum].yrepeat,256L,0); + wall[wallnum].yrepeat = (char)getnumber16(edittext,(int)wall[wallnum].yrepeat,256L,0); } break; case 4: @@ -6805,10 +6805,10 @@ static void EditWallData(short wallnum) { Bsprintf(edittext,"Wall %d X Pan: ",wallnum); printmessage16(edittext); - wall[wallnum].xpanning = (char)getnumber16(edittext,(long)wall[wallnum].xpanning,256L,0); + wall[wallnum].xpanning = (char)getnumber16(edittext,(int)wall[wallnum].xpanning,256L,0); Bsprintf(edittext,"Wall %d Y Pan: ",wallnum); printmessage16(edittext); - wall[wallnum].ypanning = (char)getnumber16(edittext,(long)wall[wallnum].ypanning,256L,0); + wall[wallnum].ypanning = (char)getnumber16(edittext,(int)wall[wallnum].ypanning,256L,0); } break; case 5: @@ -6817,7 +6817,7 @@ static void EditWallData(short wallnum) if (editval) { printmessage16(edittext); - wall[wallnum].picnum = (short)getnumber16(edittext,(long)wall[wallnum].picnum,MAXTILES,0); + wall[wallnum].picnum = (short)getnumber16(edittext,(int)wall[wallnum].picnum,MAXTILES,0); } break; @@ -6827,7 +6827,7 @@ static void EditWallData(short wallnum) if (editval) { printmessage16(edittext); - wall[wallnum].overpicnum = (short)getnumber16(edittext,(long)wall[wallnum].overpicnum,MAXTILES,0); + wall[wallnum].overpicnum = (short)getnumber16(edittext,(int)wall[wallnum].overpicnum,MAXTILES,0); } break; } @@ -6854,7 +6854,7 @@ static void EditSpriteData(short spritenum) char disptext[80]; char edittext[80]; int col=0, row=0, rowmax=4, dispwidth = 24, editval = 0, i = -1; - long xpos = 8, ypos = ydim-STATUS2DSIZ+48; + int xpos = 8, ypos = ydim-STATUS2DSIZ+48; disptext[dispwidth] = 0; clearmidstatbar16(); @@ -6958,7 +6958,7 @@ static void EditSpriteData(short spritenum) { case 0: { - for (i=Bsprintf(disptext,"X-coordinate: %ld",sprite[spritenum].x); i < dispwidth; i++) disptext[i] = ' '; + for (i=Bsprintf(disptext,"X-coordinate: %d",sprite[spritenum].x); i < dispwidth; i++) disptext[i] = ' '; Bsprintf(edittext,"Sprite %d X-coordinate: ",spritenum); if (editval) { @@ -6969,7 +6969,7 @@ static void EditSpriteData(short spritenum) break; case 1: { - for (i=Bsprintf(disptext,"Y-coordinate: %ld",sprite[spritenum].y); i < dispwidth; i++) disptext[i] = ' '; + for (i=Bsprintf(disptext,"Y-coordinate: %d",sprite[spritenum].y); i < dispwidth; i++) disptext[i] = ' '; Bsprintf(edittext,"Sprite %d Y-coordinate: ",spritenum); if (editval) { @@ -6980,7 +6980,7 @@ static void EditSpriteData(short spritenum) break; case 2: { - for (i=Bsprintf(disptext,"Z-coordinate: %ld",sprite[spritenum].z); i < dispwidth; i++) disptext[i] = ' '; + for (i=Bsprintf(disptext,"Z-coordinate: %d",sprite[spritenum].z); i < dispwidth; i++) disptext[i] = ' '; Bsprintf(edittext,"Sprite %d Z-coordinate: ",spritenum); if (editval) { @@ -7029,7 +7029,7 @@ static void EditSpriteData(short spritenum) if (editval) { printmessage16(edittext); - sprite[spritenum].cstat = (short)getnumber16(edittext,(long)sprite[spritenum].cstat,65536L,0); + sprite[spritenum].cstat = (short)getnumber16(edittext,(int)sprite[spritenum].cstat,65536L,0); } } break; @@ -7040,7 +7040,7 @@ static void EditSpriteData(short spritenum) if (editval) { printmessage16(edittext); - sprite[spritenum].shade = (char)getnumber16(edittext,(long)sprite[spritenum].shade,128,1); + sprite[spritenum].shade = (char)getnumber16(edittext,(int)sprite[spritenum].shade,128,1); } } break; @@ -7051,7 +7051,7 @@ static void EditSpriteData(short spritenum) if (editval) { printmessage16(edittext); - sprite[spritenum].pal = (char)getnumber16(edittext,(long)sprite[spritenum].pal,MAXPALOOKUPS,0); + sprite[spritenum].pal = (char)getnumber16(edittext,(int)sprite[spritenum].pal,MAXPALOOKUPS,0); } } break; @@ -7062,10 +7062,10 @@ static void EditSpriteData(short spritenum) { Bsprintf(edittext,"Sprite %d X Repeat: ",spritenum); printmessage16(edittext); - sprite[spritenum].xrepeat = (char)getnumber16(edittext,(long)sprite[spritenum].xrepeat,256L,0); + sprite[spritenum].xrepeat = (char)getnumber16(edittext,(int)sprite[spritenum].xrepeat,256L,0); Bsprintf(edittext,"Sprite %d Y Repeat: ",spritenum); printmessage16(edittext); - sprite[spritenum].yrepeat = (char)getnumber16(edittext,(long)sprite[spritenum].yrepeat,256L,0); + sprite[spritenum].yrepeat = (char)getnumber16(edittext,(int)sprite[spritenum].yrepeat,256L,0); } } break; @@ -7076,10 +7076,10 @@ static void EditSpriteData(short spritenum) { Bsprintf(edittext,"Sprite %d X Offset: ",spritenum); printmessage16(edittext); - sprite[spritenum].xoffset = (char)getnumber16(edittext,(long)sprite[spritenum].xoffset,128L,1); + sprite[spritenum].xoffset = (char)getnumber16(edittext,(int)sprite[spritenum].xoffset,128L,1); Bsprintf(edittext,"Sprite %d Y Offset: ",spritenum); printmessage16(edittext); - sprite[spritenum].yoffset = (char)getnumber16(edittext,(long)sprite[spritenum].yoffset,128L,1); + sprite[spritenum].yoffset = (char)getnumber16(edittext,(int)sprite[spritenum].yoffset,128L,1); } } break; @@ -7090,7 +7090,7 @@ static void EditSpriteData(short spritenum) if (editval) { printmessage16(edittext); - sprite[spritenum].picnum = (short)getnumber16(edittext,(long)sprite[spritenum].picnum,MAXTILES,0); + sprite[spritenum].picnum = (short)getnumber16(edittext,(int)sprite[spritenum].picnum,MAXTILES,0); } } break; @@ -7108,7 +7108,7 @@ static void EditSpriteData(short spritenum) if (editval) { printmessage16(edittext); - sprite[spritenum].ang = (short)getnumber16(edittext,(long)sprite[spritenum].ang,2048L,0); + sprite[spritenum].ang = (short)getnumber16(edittext,(int)sprite[spritenum].ang,2048L,0); } } break; @@ -7119,7 +7119,7 @@ static void EditSpriteData(short spritenum) if (editval) { printmessage16(edittext); - sprite[spritenum].xvel = getnumber16(edittext,(long)sprite[spritenum].xvel,65536,1); + sprite[spritenum].xvel = getnumber16(edittext,(int)sprite[spritenum].xvel,65536,1); } } break; @@ -7130,7 +7130,7 @@ static void EditSpriteData(short spritenum) if (editval) { printmessage16(edittext); - sprite[spritenum].yvel = getnumber16(edittext,(long)sprite[spritenum].yvel,65536,1); + sprite[spritenum].yvel = getnumber16(edittext,(int)sprite[spritenum].yvel,65536,1); } } break; @@ -7141,7 +7141,7 @@ static void EditSpriteData(short spritenum) if (editval) { printmessage16(edittext); - sprite[spritenum].zvel = getnumber16(edittext,(long)sprite[spritenum].zvel,65536,1); + sprite[spritenum].zvel = getnumber16(edittext,(int)sprite[spritenum].zvel,65536,1); } } break; @@ -7152,7 +7152,7 @@ static void EditSpriteData(short spritenum) if (editval) { printmessage16(edittext); - sprite[spritenum].owner = getnumber16(edittext,(long)sprite[spritenum].owner,MAXSPRITES,0); + sprite[spritenum].owner = getnumber16(edittext,(int)sprite[spritenum].owner,MAXSPRITES,0); } } break; @@ -7163,7 +7163,7 @@ static void EditSpriteData(short spritenum) if (editval) { printmessage16(edittext); - sprite[spritenum].clipdist = (char)getnumber16(edittext,(long)sprite[spritenum].clipdist,256,0); + sprite[spritenum].clipdist = (char)getnumber16(edittext,(int)sprite[spritenum].clipdist,256,0); } } break; @@ -7174,7 +7174,7 @@ static void EditSpriteData(short spritenum) if (editval) { printmessage16(edittext); - sprite[spritenum].extra = getnumber16(edittext,(long)sprite[spritenum].extra,65536,1); + sprite[spritenum].extra = getnumber16(edittext,(int)sprite[spritenum].extra,65536,1); } } break; @@ -7264,7 +7264,7 @@ static void FuncMenu(void) { char disptext[80]; int col=0, row=0, rowmax=7, dispwidth = 24, editval = 0, i = -1, j; - long xpos = 8, ypos = ydim-STATUS2DSIZ+48; + int xpos = 8, ypos = ydim-STATUS2DSIZ+48; disptext[dispwidth] = 0; clearmidstatbar16(); diff --git a/polymer/eduke32/source/config.c b/polymer/eduke32/source/config.c index f73839657..f8e50254f 100644 --- a/polymer/eduke32/source/config.c +++ b/polymer/eduke32/source/config.c @@ -389,13 +389,13 @@ void CONFIG_SetupMouse(void) for (i=0;i= 0) g_player[0].wchoice[i] = dummy; @@ -746,7 +746,7 @@ void CONFIG_WriteSetup(void) if (ud.config.scripthandle < 0) ud.config.scripthandle = SCRIPT_Init(setupfilename); - SCRIPT_PutNumber(ud.config.scripthandle, "Controls","AimingFlag",(long) myaimmode,false,false); + SCRIPT_PutNumber(ud.config.scripthandle, "Controls","AimingFlag",(int) myaimmode,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Controls","AutoAim",ud.config.AutoAim,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Controls","MouseAimingFlipped",ud.mouseflip,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Controls","MouseAiming",ud.mouseaiming,false,false); @@ -855,32 +855,32 @@ void CONFIG_WriteSetup(void) for (dummy=0;dummy<10;dummy++) { - Bsprintf(buf,"WeaponChoice%ld",dummy); + Bsprintf(buf,"WeaponChoice%d",dummy); SCRIPT_PutNumber(ud.config.scripthandle, "Misc",buf,g_player[myconnectindex].wchoice[dummy],false,false); } for (dummy=0;dummy= (MAXMOUSEBUTTONS-2)) continue; - Bsprintf(buf,"MouseButtonClicked%ld",dummy); + Bsprintf(buf,"MouseButtonClicked%d",dummy); SCRIPT_PutString(ud.config.scripthandle,"Controls", buf, CONFIG_FunctionNumToName(ud.config.MouseFunctions[dummy][1])); } for (dummy=0;dummy= 3) #define IFISSOFTMODE if (getrendermode() < 3) @@ -805,12 +805,12 @@ enum gamevarflags { }; typedef struct { - long lValue; + int lValue; char *szLabel; - unsigned long dwFlags; + unsigned int dwFlags; - long *plValues; // array of values when 'per-player', or 'per-actor' - long lDefault; + int *plValues; // array of values when 'per-player', or 'per-actor' + int lDefault; char bReset; } gamevar_t; @@ -848,23 +848,23 @@ extern char g_szBuf[1024]; #define NAM_GRENADE_LIFETIME 120 #define NAM_GRENADE_LIFETIME_VAR 30 -extern long *aplWeaponClip[MAX_WEAPONS]; // number of items in clip -extern long *aplWeaponReload[MAX_WEAPONS]; // delay to reload (include fire) -extern long *aplWeaponFireDelay[MAX_WEAPONS]; // delay to fire -extern long *aplWeaponHoldDelay[MAX_WEAPONS]; // delay after release fire button to fire (0 for none) -extern long *aplWeaponTotalTime[MAX_WEAPONS]; // The total time the weapon is cycling before next fire. -extern long *aplWeaponFlags[MAX_WEAPONS]; // Flags for weapon -extern long *aplWeaponShoots[MAX_WEAPONS]; // what the weapon shoots -extern long *aplWeaponSpawnTime[MAX_WEAPONS]; // the frame at which to spawn an item -extern long *aplWeaponSpawn[MAX_WEAPONS]; // the item to spawn -extern long *aplWeaponShotsPerBurst[MAX_WEAPONS]; // number of shots per 'burst' (one ammo per 'burst' -extern long *aplWeaponWorksLike[MAX_WEAPONS]; // What original the weapon works like -extern long *aplWeaponInitialSound[MAX_WEAPONS]; // Sound made when initialy firing. zero for no sound -extern long *aplWeaponFireSound[MAX_WEAPONS]; // Sound made when firing (each time for automatic) -extern long *aplWeaponSound2Time[MAX_WEAPONS]; // Alternate sound time -extern long *aplWeaponSound2Sound[MAX_WEAPONS]; // Alternate sound sound ID -extern long *aplWeaponReloadSound1[MAX_WEAPONS]; // Sound of magazine being removed -extern long *aplWeaponReloadSound2[MAX_WEAPONS]; // Sound of magazine being inserted +extern int *aplWeaponClip[MAX_WEAPONS]; // number of items in clip +extern int *aplWeaponReload[MAX_WEAPONS]; // delay to reload (include fire) +extern int *aplWeaponFireDelay[MAX_WEAPONS]; // delay to fire +extern int *aplWeaponHoldDelay[MAX_WEAPONS]; // delay after release fire button to fire (0 for none) +extern int *aplWeaponTotalTime[MAX_WEAPONS]; // The total time the weapon is cycling before next fire. +extern int *aplWeaponFlags[MAX_WEAPONS]; // Flags for weapon +extern int *aplWeaponShoots[MAX_WEAPONS]; // what the weapon shoots +extern int *aplWeaponSpawnTime[MAX_WEAPONS]; // the frame at which to spawn an item +extern int *aplWeaponSpawn[MAX_WEAPONS]; // the item to spawn +extern int *aplWeaponShotsPerBurst[MAX_WEAPONS]; // number of shots per 'burst' (one ammo per 'burst' +extern int *aplWeaponWorksLike[MAX_WEAPONS]; // What original the weapon works like +extern int *aplWeaponInitialSound[MAX_WEAPONS]; // Sound made when initialy firing. zero for no sound +extern int *aplWeaponFireSound[MAX_WEAPONS]; // Sound made when firing (each time for automatic) +extern int *aplWeaponSound2Time[MAX_WEAPONS]; // Alternate sound time +extern int *aplWeaponSound2Sound[MAX_WEAPONS]; // Alternate sound sound ID +extern int *aplWeaponReloadSound1[MAX_WEAPONS]; // Sound of magazine being removed +extern int *aplWeaponReloadSound2[MAX_WEAPONS]; // Sound of magazine being inserted extern short timer; @@ -952,7 +952,7 @@ extern char setupfilename[BMAX_PATH]; typedef struct { char *name, *filename, *musicfn; - long partime, designertime; + int partime, designertime; } map_t; extern map_t map[MAXVOLUMES*MAXLEVELS]; @@ -961,14 +961,14 @@ typedef struct { player_struct *ps; input *sync; - long movefifoend; - long syncvalhead; - long myminlag; + int movefifoend; + int syncvalhead; + int myminlag; int frags[MAXPLAYERS]; - int32 pcolor; - int32 pteam; - int32 wchoice[MAX_WEAPONS]; + int pcolor; + int pteam; + int wchoice[MAX_WEAPONS]; char syncval[MOVEFIFOSIZ]; char user_name[32]; diff --git a/polymer/eduke32/source/funct.h b/polymer/eduke32/source/funct.h index b4c9e080e..a595ccb8a 100644 --- a/polymer/eduke32/source/funct.h +++ b/polymer/eduke32/source/funct.h @@ -33,13 +33,13 @@ extern void MusicShutdown(void); extern void intomenusounds(void); extern void playmusic(const char *fn); extern int loadsound(unsigned num); -extern int xyzsound(int num,int i,long x,long y,long z); +extern int xyzsound(int num,int i,int x,int y,int z); extern void sound(int num); extern int spritesound(unsigned int num,int i); extern void stopsound(int num); extern void stopenvsound(int num,int i); extern void pan3dsound(void); -extern void testcallback(unsigned long num); +extern void testcallback(unsigned int num); extern void clearsoundlocks(void); extern int callsound(int sn,int whatsprite); extern int check_activator_motion(int lotag); @@ -47,13 +47,13 @@ extern int isadoorwall(int dapic); extern int isanunderoperator(int lotag); extern int isanearoperator(int lotag); extern int checkcursectnums(int sect); -extern long ldist(spritetype *s1,spritetype *s2); -extern long dist(spritetype *s1,spritetype *s2); -extern int findplayer(spritetype *s,long *d); -extern int findotherplayer(int p,long *d); +extern int ldist(spritetype *s1,spritetype *s2); +extern int dist(spritetype *s1,spritetype *s2); +extern int findplayer(spritetype *s,int *d); +extern int findotherplayer(int p,int *d); extern void doanimations(void); -extern int getanimationgoal(long *animptr); -extern int setanimation(int animsect,long *animptr,long thegoal,long thevel); +extern int getanimationgoal(int *animptr); +extern int setanimation(int animsect,int *animptr,int thegoal,int thevel); extern void animatecamsprite(void); extern void animatewalls(void); extern int activatewarpelevators(int s,int d); @@ -62,9 +62,9 @@ extern void operaterespawns(int low); extern void operateactivators(int low,int snum); extern void operatemasterswitches(int low); extern void operateforcefields(int s,int low); -extern int checkhitswitch(int snum,long w,int switchtype); +extern int checkhitswitch(int snum,int w,int switchtype); extern void activatebysector(int sect,int j); -extern void checkhitwall(int spr,int dawallnum,long x,long y,long z,int atwith); +extern void checkhitwall(int spr,int dawallnum,int x,int y,int z,int atwith); extern void checkplayerhurt(player_struct *p,int j); extern int checkhitceiling(int sn); extern void checkhitsprite(int i,int sn); @@ -94,8 +94,8 @@ extern int enterlevel(int g); extern void backtomenu(void); extern void setpal(player_struct *p); extern void quickkill(player_struct *p); -extern long hits(int i); -extern long hitasprite(int i,short *hitsp); +extern int hits(int i); +extern int hitasprite(int i,short *hitsp); extern int shoot(int i,int atwith); extern void displaymasks(int snum); extern void displayweapon(int snum); @@ -103,45 +103,45 @@ extern void getinput(int snum); extern void checkweapons(player_struct *p); extern void processinput(int snum); extern void cmenu(int cm); -extern void savetemp(const char *fn,long daptr,long dasiz); +extern void savetemp(const char *fn,int daptr,int dasiz); // extern int loadpheader(char spot,int32 *vn,int32 *ln,int32 *psk,int32 *numplr); extern int loadplayer(int spot); extern int saveplayer(int spot); extern inline int menutext(int x,int y,int s,int p,const char *t); extern void menus(void); -extern void palto(int r,int g,int b,long e); +extern void palto(int r,int g,int b,int e); extern void playanm(const char *fn,char); extern int getincangle(int a,int na); extern void getglobalz(int iActor); extern void makeitfall(int iActor); extern void loadefs(const char *fn); extern int furthestangle(int iActor,int angs); -extern void execute(int iActor,int iPlayer,long lDist); -extern void overwritesprite(long thex,long they,int tilenum,int shade,int stat,int dapalnum); +extern void execute(int iActor,int iPlayer,int lDist); +extern void overwritesprite(int thex,int they,int tilenum,int shade,int stat,int dapalnum); extern inline int gametext(int x,int y,const char *t,int s,int dabits); extern inline int gametextpal(int x,int y,const char *t,int s,int p); extern inline int minitext(int x,int y,const char *t,int p,int sb); -extern void gamenumber(long x,long y,long n,int s); +extern void gamenumber(int x,int y,int n,int s); extern void Shutdown(void); extern void getpackets(void); extern void check_fta_sounds(int i); extern inline int inventory(spritetype *s); extern inline int badguy(spritetype *s); extern int badguypic(int pn); -extern void myos(long x,long y,int tilenum,int shade,int orientation); -extern void myospal(long x,long y,int tilenum,int shade,int orientation,int p); +extern void myos(int x,int y,int tilenum,int shade,int orientation); +extern void myospal(int x,int y,int tilenum,int shade,int orientation,int p); extern void displayfragbar(void); extern void FTA(int q,player_struct *p); extern void gameexit(const char *t); extern inline int strget(int x,int y,char *t,int dalen,int c); -extern void displayrest(long smoothratio); -extern void updatesectorz(long x,long y,long z,short *sectnum); +extern void displayrest(int smoothratio); +extern void updatesectorz(int x,int y,int z,short *sectnum); extern void drawbackground(void); -extern void displayrooms(int snum,long smoothratio); -extern int EGS(int whatsect,long s_x,long s_y,long s_z,int s_pn,int s_s,int s_xr,int s_yr,int s_a,int s_ve,long s_zv,int s_ow,int s_ss); +extern void displayrooms(int snum,int smoothratio); +extern int EGS(int whatsect,int s_x,int s_y,int s_z,int s_pn,int s_s,int s_xr,int s_yr,int s_a,int s_ve,int s_zv,int s_ow,int s_ss); extern int wallswitchcheck(int i); extern int spawn(int j,int pn); -extern void animatesprites(long x,long y,int a,long smoothratio); +extern void animatesprites(int x,int y,int a,int smoothratio); extern int main(int argc,char **argv); extern void opendemowrite(void); extern void closedemowrite(void); @@ -150,7 +150,7 @@ extern void lotsofglass(int i,int wallnum,int n); extern void spriteglass(int i,int n); extern void ceilingglass(int i,int sectnum,int n); extern void lotsofcolourglass(int i,int wallnum,int n); -extern long GetTime(void); +extern int GetTime(void); extern void CONFIG_GetSetupFilename(void); extern int32 CONFIG_FunctionNameToNum(char *func); extern char *CONFIG_FunctionNumToName(int32 func); @@ -162,20 +162,20 @@ extern void readsavenames(void); extern int32 CONFIG_ReadSetup(void); extern void CONFIG_WriteSetup(void); extern void updateinterpolations(void); -extern void setinterpolation(long *posptr); -extern void stopinterpolation(long *posptr); -extern void dointerpolations(long smoothratio); +extern void setinterpolation(int *posptr); +extern void stopinterpolation(int *posptr); +extern void dointerpolations(int smoothratio); extern void restoreinterpolations(void); -extern long ceilingspace(int sectnum); -extern long floorspace(int sectnum); +extern int ceilingspace(int sectnum); +extern int floorspace(int sectnum); extern void addammo(int weapon,player_struct *p,int amount); extern void addweaponnoswitch(player_struct *p,int weapon); extern void addweapon(player_struct *p,int weapon); extern void checkavailinven(player_struct *p); extern void checkavailweapon(player_struct *p); -extern void hitradius(int i,long r,long hp1,long hp2,long hp3,long hp4); -extern int movesprite(int spritenum,long xchange,long ychange,long zchange,unsigned long cliptype); -extern int ssp(int i,unsigned long cliptype); +extern void hitradius(int i,int r,int hp1,int hp2,int hp3,int hp4); +extern int movesprite(int spritenum,int xchange,int ychange,int zchange,unsigned int cliptype); +extern int ssp(int i,unsigned int cliptype); extern void insertspriteq(int i); extern void lotsofmoney(int sp,int n); extern void lotsofmail(int sp, int n); @@ -190,25 +190,25 @@ extern void movecyclers(void); extern void movedummyplayers(void); // game.c -extern inline void setstatusbarscale(long sc); +extern inline void setstatusbarscale(int sc); extern void setgamepalette(player_struct *player, char *pal, int set); extern void fadepal(int r, int g, int b, int start, int end, int step); extern inline int minitextshade(int x,int y,const char *t,int s,int p,int sb); -extern inline int gametext_(int small, int starttile, int x,int y,const char *t,int s,int p,int orientation,long x1, long y1, long x2, long y2); -extern void txdigitalnumber(int starttile, long x,long y,long n,int s,int pal,int cs,long x1, long y1, long x2, long y2); -extern void myosx(long x,long y,int tilenum,int shade,int orientation); -extern void myospalx(long x,long y,int tilenum,int shade,int orientation,int p); +extern inline int gametext_(int small, int starttile, int x,int y,const char *t,int s,int p,int orientation,int x1, int y1, int x2, int y2); +extern void txdigitalnumber(int starttile, int x,int y,int n,int s,int pal,int cs,int x1, int y1, int x2, int y2); +extern void myosx(int x,int y,int tilenum,int shade,int orientation); +extern void myospalx(int x,int y,int tilenum,int shade,int orientation,int p); extern void ResetGameVars(void); extern void ResetActorGameVars(int iActor); extern void setupdynamictostatic(); -extern void processnames(const char *szLabel, long lValue); +extern void processnames(const char *szLabel, int lValue); -extern void LoadActor(long sActor); +extern void LoadActor(int sActor); -extern long GetGameVar(const char *szGameLabel, long lDefault, int iActor, int iPlayer); +extern int GetGameVar(const char *szGameLabel, int lDefault, int iActor, int iPlayer); extern void DumpGameVars(FILE *fp); // extern void AddLog(const char *psz, ...); @@ -216,16 +216,16 @@ extern void ResetSystemDefaults(void); extern void InitGameVarPointers(void); extern void InitGameVars(void); extern void SaveGameVars(FILE *fil); -extern int ReadGameVars(long fil); +extern int ReadGameVars(int fil); -extern long GetGameVarID(int id, int iActor, int iPlayer); -extern void SetGameVarID(int id, long lValue, int iActor, int iPlayer); -extern int AddGameVar(const char *pszLabel, long lValue, unsigned long dwFlags); +extern int GetGameVarID(int id, int iActor, int iPlayer); +extern void SetGameVarID(int id, int lValue, int iActor, int iPlayer); +extern int AddGameVar(const char *pszLabel, int lValue, unsigned int dwFlags); extern void ReportError(int iError); extern void onvideomodechange(int newmode); -extern void OnEvent(int iEventID, int sActor, int sPlayer, long lDist); +extern void OnEvent(int iEventID, int sActor, int sPlayer, int lDist); extern int isspritemakingsound(int i, int num); extern int issoundplaying(int i, int num); @@ -243,6 +243,6 @@ extern inline int checkspriteflagsp(int iPicnum, int iType); extern int getteampal(int team); -extern void se40code(long x,long y,long z,long a,long h, long smoothratio); +extern void se40code(int x,int y,int z,int a,int h, int smoothratio); #endif // __funct_h__ diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 9773d1d63..14fe7e6c3 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -61,20 +61,20 @@ extern int getversionfromwebsite(char *buffer); #define TIMERUPDATESIZ 32 -long cameradist = 0, cameraclock = 0; +int cameradist = 0, cameraclock = 0; static int playerswhenstarted; static int qe,cp,usecwd = 0; -static int32 g_CommandSetup = 0; -static int32 g_NoSetup = 0; -static int32 g_NoAutoLoad = 0; -static int32 g_NoSound = 0; -static int32 g_NoMusic = 0; +static int g_CommandSetup = 0; +static int g_NoSetup = 0; +static int g_NoAutoLoad = 0; +static int g_NoSound = 0; +static int g_NoMusic = 0; static char *CommandMap = NULL; static char *CommandName = NULL; static char *CommandNet = NULL; static int g_KeepAddr = 0; -int32 CommandWeaponChoice = 0; +int CommandWeaponChoice = 0; static struct strllist { struct strllist *next; @@ -99,7 +99,7 @@ int debug_on = 0,actor_tog = 0; static char *rtsptr; extern char syncstate; -extern int32 numlumps; +extern int numlumps; static FILE *frecfilep = (FILE *)NULL; @@ -114,13 +114,13 @@ static char defaultconfilename[BMAX_PATH] = {"EDUKE.CON"}; static char *confilename = defaultconfilename; static char *duke3ddef = "duke3d.def"; -extern long lastvisinc; +extern int lastvisinc; int g_Shareware = 0; int g_GameType = 0; #define MAXUSERQUOTES 4 -static long quotebot, quotebotgoal; +static int quotebot, quotebotgoal; static int user_quote_time[MAXUSERQUOTES]; static char user_quote[MAXUSERQUOTES][178]; // char typebuflen,typebuf[41]; @@ -131,9 +131,9 @@ static int MAXCACHE1DSIZE = (16*1048576); static int MAXCACHE1DSIZE = (32*1048576); #endif -long tempwallptr; +int tempwallptr; -static long nonsharedtimer; +static int nonsharedtimer; static void cameratext(short i); static int moveloop(void); @@ -141,11 +141,11 @@ static void doorders(void); static void fakedomovethings(void); static void fakedomovethingscorrect(void); static int domovethings(void); -static long playback(void); +static int playback(void); static char recbuf[180]; -extern void computergetinput(long snum, input *syn); +extern void computergetinput(int snum, input *syn); enum { @@ -183,32 +183,32 @@ static int getatoken(scriptfile *sf, tokenlist *tl, int ntokens) return T_ERROR; } -inline void setstatusbarscale(long sc) +inline void setstatusbarscale(int sc) { ud.statusbarscale = min(100,max(10,sc)); vscrn(); } -static inline long sbarx(long x) +static inline int sbarx(int x) { if (ud.screen_size == 4 /*|| ud.statusbarmode == 1*/) return scale(x<<16,ud.statusbarscale,100); return (((320l<<16) - scale(320l<<16,ud.statusbarscale,100)) >> 1) + scale(x<<16,ud.statusbarscale,100); } -static inline long sbary(long y) +static inline int sbary(int y) { return ((200l<<16) - scale(200l<<16,ud.statusbarscale,100) + scale(y<<16,ud.statusbarscale,100)); } -static inline long sbarsc(long sc) +static inline int sbarsc(int sc) { return scale(sc,ud.statusbarscale,100); } -static void patchstatusbar(long x1, long y1, long x2, long y2) +static void patchstatusbar(int x1, int y1, int x2, int y2) { - long scl, tx, ty; - long clx1,cly1,clx2,cly2,clofx,clofy; + int scl, tx, ty; + int clx1,cly1,clx2,cly2,clofx,clofy; scl = sbarsc(65536); tx = sbarx(0); @@ -289,7 +289,7 @@ const char *stripcolorcodes(const char *t) return(colstrip); } -int gametext_(int small, int starttile, int x,int y,const char *t,int s,int p,int orientation,long x1, long y1, long x2, long y2) +int gametext_(int small, int starttile, int x,int y,const char *t,int s,int p,int orientation,int x1, int y1, int x2, int y2) { int ac,newx,oldx=x; char centre, *oldt; @@ -430,18 +430,18 @@ inline int minitext(int x,int y,const char *t,int p,int sb) } #if 0 -static void gamenumber(long x,long y,long n,char s) +static void gamenumber(int x,int y,int n,char s) { char b[10]; //ltoa(n,b,10); - Bsnprintf(b,10,"%ld",n); + Bsnprintf(b,10,"%d",n); gametext(x,y,b,s,2+8+16); } #endif static void allowtimetocorrecterrorswhenquitting(void) { - long i, j, oldtotalclock; + int i, j, oldtotalclock; ready2send = 0; @@ -467,7 +467,7 @@ static void allowtimetocorrecterrorswhenquitting(void) void adduserquote(const char *daquote) { - long i; + int i; for (i=MAXUSERQUOTES-1;i>0;i--) { @@ -481,12 +481,12 @@ void adduserquote(const char *daquote) pub = NUMPAGES; } -long lastpackettime = 0; +int lastpackettime = 0; void getpackets(void) { - long i, j, k, l; - long other, packbufleng; + int i, j, k, l; + int other, packbufleng; input *osyn, *nsyn; sampletimer(); @@ -542,7 +542,7 @@ void getpackets(void) { if (g_player[i].playerquitflag == 0) continue; if (i == myconnectindex) - otherminlag = (long)((signed char)packbuf[j]); + otherminlag = (int)((signed char)packbuf[j]); j++; } @@ -557,7 +557,7 @@ void getpackets(void) if (g_player[i].playerquitflag == 0) continue; l = packbuf[k++]; - l += (long)(packbuf[k++]<<8); + l += (int)(packbuf[k++]<<8); if (i == myconnectindex) { @@ -569,15 +569,15 @@ void getpackets(void) if (l&1) nsyn[i].fvel = packbuf[j]+((short)packbuf[j+1]<<8), j += 2; if (l&2) nsyn[i].svel = packbuf[j]+((short)packbuf[j+1]<<8), j += 2; if (l&4) nsyn[i].avel = (signed char)packbuf[j++]; - if (l&8) nsyn[i].bits = ((nsyn[i].bits&0xffffff00)|((long)packbuf[j++])); - if (l&16) nsyn[i].bits = ((nsyn[i].bits&0xffff00ff)|((long)packbuf[j++])<<8); - if (l&32) nsyn[i].bits = ((nsyn[i].bits&0xff00ffff)|((long)packbuf[j++])<<16); - if (l&64) nsyn[i].bits = ((nsyn[i].bits&0x00ffffff)|((long)packbuf[j++])<<24); + if (l&8) nsyn[i].bits = ((nsyn[i].bits&0xffffff00)|((int)packbuf[j++])); + if (l&16) nsyn[i].bits = ((nsyn[i].bits&0xffff00ff)|((int)packbuf[j++])<<8); + if (l&32) nsyn[i].bits = ((nsyn[i].bits&0xff00ffff)|((int)packbuf[j++])<<16); + if (l&64) nsyn[i].bits = ((nsyn[i].bits&0x00ffffff)|((int)packbuf[j++])<<24); if (l&128) nsyn[i].horz = (signed char)packbuf[j++]; - if (l&256) nsyn[i].extbits = ((nsyn[i].extbits&0xffffff00)|((long)packbuf[j++])); - if (l&512) nsyn[i].extbits = ((nsyn[i].extbits&0xffff00ff)|((long)packbuf[j++])<<8); - if (l&1024) nsyn[i].extbits = ((nsyn[i].extbits&0xff00ffff)|((long)packbuf[j++])<<16); - if (l&2048) nsyn[i].extbits = ((nsyn[i].extbits&0x00ffffff)|((long)packbuf[j++])<<24); + if (l&256) nsyn[i].extbits = ((nsyn[i].extbits&0xffffff00)|((int)packbuf[j++])); + if (l&512) nsyn[i].extbits = ((nsyn[i].extbits&0xffff00ff)|((int)packbuf[j++])<<8); + if (l&1024) nsyn[i].extbits = ((nsyn[i].extbits&0xff00ffff)|((int)packbuf[j++])<<16); + if (l&2048) nsyn[i].extbits = ((nsyn[i].extbits&0x00ffffff)|((int)packbuf[j++])<<24); if (nsyn[i].bits&(1<<26)) g_player[i].playerquitflag = 0; g_player[i].movefifoend++; @@ -607,7 +607,7 @@ void getpackets(void) break; case 1: //[1] (receive slave sync buffer) j = 3; - k = packbuf[1] + (long)(packbuf[2]<<8); + k = packbuf[1] + (int)(packbuf[2]<<8); osyn = (input *)&inputfifo[(g_player[other].movefifoend-1)&(MOVEFIFOSIZ-1)][0]; nsyn = (input *)&inputfifo[(g_player[other].movefifoend)&(MOVEFIFOSIZ-1)][0]; @@ -616,15 +616,15 @@ void getpackets(void) if (k&1) nsyn[other].fvel = packbuf[j]+((short)packbuf[j+1]<<8), j += 2; if (k&2) nsyn[other].svel = packbuf[j]+((short)packbuf[j+1]<<8), j += 2; if (k&4) nsyn[other].avel = (signed char)packbuf[j++]; - if (k&8) nsyn[other].bits = ((nsyn[other].bits&0xffffff00)|((long)packbuf[j++])); - if (k&16) nsyn[other].bits = ((nsyn[other].bits&0xffff00ff)|((long)packbuf[j++])<<8); - if (k&32) nsyn[other].bits = ((nsyn[other].bits&0xff00ffff)|((long)packbuf[j++])<<16); - if (k&64) nsyn[other].bits = ((nsyn[other].bits&0x00ffffff)|((long)packbuf[j++])<<24); + if (k&8) nsyn[other].bits = ((nsyn[other].bits&0xffffff00)|((int)packbuf[j++])); + if (k&16) nsyn[other].bits = ((nsyn[other].bits&0xffff00ff)|((int)packbuf[j++])<<8); + if (k&32) nsyn[other].bits = ((nsyn[other].bits&0xff00ffff)|((int)packbuf[j++])<<16); + if (k&64) nsyn[other].bits = ((nsyn[other].bits&0x00ffffff)|((int)packbuf[j++])<<24); if (k&128) nsyn[other].horz = (signed char)packbuf[j++]; - if (k&256) nsyn[other].extbits = ((nsyn[other].extbits&0xffffff00)|((long)packbuf[j++])); - if (k&512) nsyn[other].extbits = ((nsyn[other].extbits&0xffff00ff)|((long)packbuf[j++])<<8); - if (k&1024) nsyn[other].extbits = ((nsyn[other].extbits&0xff00ffff)|((long)packbuf[j++])<<16); - if (k&2048) nsyn[other].extbits = ((nsyn[other].extbits&0x00ffffff)|((long)packbuf[j++])<<24); + if (k&256) nsyn[other].extbits = ((nsyn[other].extbits&0xffffff00)|((int)packbuf[j++])); + if (k&512) nsyn[other].extbits = ((nsyn[other].extbits&0xffff00ff)|((int)packbuf[j++])<<8); + if (k&1024) nsyn[other].extbits = ((nsyn[other].extbits&0xff00ffff)|((int)packbuf[j++])<<16); + if (k&2048) nsyn[other].extbits = ((nsyn[other].extbits&0x00ffffff)|((int)packbuf[j++])<<24); g_player[other].movefifoend++; while (j != packbufleng) @@ -652,7 +652,7 @@ void getpackets(void) for (i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) { if (i == myconnectindex) - otherminlag = (long)((signed char)packbuf[j]); + otherminlag = (int)((signed char)packbuf[j]); j++; } @@ -661,20 +661,20 @@ void getpackets(void) copybufbyte(&osyn[other],&nsyn[other],sizeof(input)); k = packbuf[j++]; - k += (long)(packbuf[j++]<<8); + k += (int)(packbuf[j++]<<8); if (k&1) nsyn[other].fvel = packbuf[j]+((short)packbuf[j+1]<<8), j += 2; if (k&2) nsyn[other].svel = packbuf[j]+((short)packbuf[j+1]<<8), j += 2; if (k&4) nsyn[other].avel = (signed char)packbuf[j++]; - if (k&8) nsyn[other].bits = ((nsyn[other].bits&0xffffff00)|((long)packbuf[j++])); - if (k&16) nsyn[other].bits = ((nsyn[other].bits&0xffff00ff)|((long)packbuf[j++])<<8); - if (k&32) nsyn[other].bits = ((nsyn[other].bits&0xff00ffff)|((long)packbuf[j++])<<16); - if (k&64) nsyn[other].bits = ((nsyn[other].bits&0x00ffffff)|((long)packbuf[j++])<<24); + if (k&8) nsyn[other].bits = ((nsyn[other].bits&0xffffff00)|((int)packbuf[j++])); + if (k&16) nsyn[other].bits = ((nsyn[other].bits&0xffff00ff)|((int)packbuf[j++])<<8); + if (k&32) nsyn[other].bits = ((nsyn[other].bits&0xff00ffff)|((int)packbuf[j++])<<16); + if (k&64) nsyn[other].bits = ((nsyn[other].bits&0x00ffffff)|((int)packbuf[j++])<<24); if (k&128) nsyn[other].horz = (signed char)packbuf[j++]; - if (k&256) nsyn[other].extbits = ((nsyn[other].extbits&0xffffff00)|((long)packbuf[j++])); - if (k&512) nsyn[other].extbits = ((nsyn[other].extbits&0xffff00ff)|((long)packbuf[j++])<<8); - if (k&1024) nsyn[other].extbits = ((nsyn[other].extbits&0xff00ffff)|((long)packbuf[j++])<<16); - if (k&2048) nsyn[other].extbits = ((nsyn[other].extbits&0x00ffffff)|((long)packbuf[j++])<<24); + if (k&256) nsyn[other].extbits = ((nsyn[other].extbits&0xffffff00)|((int)packbuf[j++])); + if (k&512) nsyn[other].extbits = ((nsyn[other].extbits&0xffff00ff)|((int)packbuf[j++])<<8); + if (k&1024) nsyn[other].extbits = ((nsyn[other].extbits&0xff00ffff)|((int)packbuf[j++])<<16); + if (k&2048) nsyn[other].extbits = ((nsyn[other].extbits&0x00ffffff)|((int)packbuf[j++])<<24); g_player[other].movefifoend++; for (i=1;i packbufleng) - initprintf("INVALID GAME PACKET!!! (packet %d, %ld too many bytes (%ld %ld))\n",packbuf[0],j-packbufleng,packbufleng,k); + initprintf("INVALID GAME PACKET!!! (packet %d, %d too many bytes (%d %d))\n",packbuf[0],j-packbufleng,packbufleng,k); while (j < packbufleng) { @@ -698,7 +698,7 @@ void getpackets(void) case 250: if (g_player[other].playerreadyflag == 0) - initprintf("Player %ld is ready\n", other); + initprintf("Player %d is ready\n", other); g_player[other].playerreadyflag++; break; case 255: @@ -718,10 +718,10 @@ void getpackets(void) if (i != other) sendpacket(i,packbuf,packbufleng); } - else if (((long)packbuf[1]) != myconnectindex) + else if (((int)packbuf[1]) != myconnectindex) { //Master re-transmits message not intended for master - sendpacket((long)packbuf[1],packbuf,packbufleng); + sendpacket((int)packbuf[1],packbuf,packbufleng); break; } } @@ -981,7 +981,7 @@ void getpackets(void) void faketimerhandler(void) { - long i, j, k; + int i, j, k; // short who; input *osyn, *nsyn; @@ -1302,10 +1302,10 @@ void faketimerhandler(void) } } -extern long cacnum; +extern int cacnum; typedef struct { - long *hand, leng; + int *hand, leng; char *lock ; } cactype; @@ -1319,7 +1319,7 @@ static void caches(void) for (i=0;i= 200) { - Bsprintf(tempbuf,"Locked- %d: Leng:%ld, Lock:%d",i,cac[i].leng,*cac[i].lock); + Bsprintf(tempbuf,"Locked- %d: Leng:%d, Lock:%d",i,cac[i].leng,*cac[i].lock); printext256(0L,k,31,-1,tempbuf,1); k += 6; } @@ -1337,7 +1337,7 @@ static void caches(void) static void checksync(void) { - long i; + int i; for (i=connecthead;i>=0;i=connectpoint2[i]) if (g_player[i].syncvalhead == syncvaltottail) break; @@ -1524,7 +1524,7 @@ inline int badguy(spritetype *s) return(badguypic(s->picnum)); } -void myos(long x, long y, int tilenum, int shade, int orientation) +void myos(int x, int y, int tilenum, int shade, int orientation) { int p = sector[g_player[screenpeek].ps->cursectnum].floorpal, a = 0; @@ -1534,7 +1534,7 @@ void myos(long x, long y, int tilenum, int shade, int orientation) rotatesprite(x<<16,y<<16,65536L,a,tilenum,shade,p,2|orientation,windowx1,windowy1,windowx2,windowy2); } -void myospal(long x, long y, int tilenum, int shade, int orientation, int p) +void myospal(int x, int y, int tilenum, int shade, int orientation, int p) { int a = 0; @@ -1544,7 +1544,7 @@ void myospal(long x, long y, int tilenum, int shade, int orientation, int p) rotatesprite(x<<16,y<<16,65536L,a,tilenum,shade,p,2|orientation,windowx1,windowy1,windowx2,windowy2); } -void myosx(long x, long y, int tilenum, int shade, int orientation) +void myosx(int x, int y, int tilenum, int shade, int orientation) { int p = sector[g_player[screenpeek].ps->cursectnum].floorpal, a = 0; @@ -1554,7 +1554,7 @@ void myosx(long x, long y, int tilenum, int shade, int orientation) rotatesprite(x<<16,y<<16,32768L,a,tilenum,shade,p,2|orientation,windowx1,windowy1,windowx2,windowy2); } -void myospalx(long x, long y, int tilenum, int shade, int orientation, int p) +void myospalx(int x, int y, int tilenum, int shade, int orientation, int p) { int a = 0; @@ -1564,7 +1564,7 @@ void myospalx(long x, long y, int tilenum, int shade, int orientation, int p) rotatesprite(x<<16,y<<16,32768L,a,tilenum,shade,p,2|orientation,windowx1,windowy1,windowx2,windowy2); } -static void invennum(long x,long y,char num1,char ha,char sbits) +static void invennum(int x,int y,char num1,char ha,char sbits) { char dabuf[80] = {0}; Bsprintf(dabuf,"%d",num1); @@ -1584,7 +1584,7 @@ static void invennum(long x,long y,char num1,char ha,char sbits) rotatesprite(sbarx(x+4),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[0]-'0',ha,0,sbits,0,0,xdim-1,ydim-1); } -static void weaponnum(short ind,long x,long y,long num1, long num2,char ha) +static void weaponnum(short ind,int x,int y,int num1, int num2,char ha) { char dabuf[80] = {0}; @@ -1602,7 +1602,7 @@ static void weaponnum(short ind,long x,long y,long num1, long num2,char ha) if (num1 > 99) num1 = 99; if (num2 > 99) num2 = 99; - Bsprintf(dabuf,"%ld",num1); + Bsprintf(dabuf,"%d",num1); if (num1 > 9) { rotatesprite(sbarx(x),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[0]-'0',ha,0,10,0,0,xdim-1,ydim-1); @@ -1610,7 +1610,7 @@ static void weaponnum(short ind,long x,long y,long num1, long num2,char ha) } else rotatesprite(sbarx(x+4),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[0]-'0',ha,0,10,0,0,xdim-1,ydim-1); - Bsprintf(dabuf,"%ld",num2); + Bsprintf(dabuf,"%d",num2); if (num2 > 9) { rotatesprite(sbarx(x+13),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[0]-'0',ha,0,10,0,0,xdim-1,ydim-1); @@ -1620,7 +1620,7 @@ static void weaponnum(short ind,long x,long y,long num1, long num2,char ha) rotatesprite(sbarx(x+13),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[0]-'0',ha,0,10,0,0,xdim-1,ydim-1); } -static void weaponnum999(char ind,long x,long y,long num1, long num2,char ha) +static void weaponnum999(char ind,int x,int y,int num1, int num2,char ha) { char dabuf[80] = {0}; @@ -1628,7 +1628,7 @@ static void weaponnum999(char ind,long x,long y,long num1, long num2,char ha) rotatesprite(sbarx(x-4),sbary(y),sbarsc(65536L),0,THREEBYFIVE+10,ha,0,10,0,0,xdim-1,ydim-1); rotatesprite(sbarx(x+13),sbary(y),sbarsc(65536L),0,THREEBYFIVE+11,ha,0,10,0,0,xdim-1,ydim-1); - Bsprintf(dabuf,"%ld",num1); + Bsprintf(dabuf,"%d",num1); if (num1 > 99) { rotatesprite(sbarx(x),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[0]-'0',ha,0,10,0,0,xdim-1,ydim-1); @@ -1642,7 +1642,7 @@ static void weaponnum999(char ind,long x,long y,long num1, long num2,char ha) } else rotatesprite(sbarx(x+8),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[0]-'0',ha,0,10,0,0,xdim-1,ydim-1); - Bsprintf(dabuf,"%ld",num2); + Bsprintf(dabuf,"%d",num2); if (num2 > 99) { rotatesprite(sbarx(x+17),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[0]-'0',ha,0,10,0,0,xdim-1,ydim-1); @@ -1658,7 +1658,7 @@ static void weaponnum999(char ind,long x,long y,long num1, long num2,char ha) rotatesprite(sbarx(x+25),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[0]-'0',ha,0,10,0,0,xdim-1,ydim-1); } -static void weapon_amounts(player_struct *p,long x,long y,long u) +static void weapon_amounts(player_struct *p,int x,int y,int u) { int cw = p->curr_weapon; @@ -1746,12 +1746,12 @@ static void weapon_amounts(player_struct *p,long x,long y,long u) } } -static void digitalnumber(long x,long y,long n,char s,char cs) +static void digitalnumber(int x,int y,int n,char s,char cs) { int i, j = 0, k, p, c; char b[10]; - Bsnprintf(b,10,"%ld",n); + Bsnprintf(b,10,"%d",n); i = Bstrlen(b); for (k=0;k 0) minitext(288-30-o,180,"ON",0,10+16+permbit + 256); - else if ((unsigned long)j != 0x80000000) minitext(284-30-o,180,"OFF",2,10+16+permbit + 256); + else if ((unsigned int)j != 0x80000000) minitext(284-30-o,180,"OFF",2,10+16+permbit + 256); if (p->inven_icon >= 6) minitext(284-35-o,180,"AUTO",2,10+16+permbit + 256); } return; @@ -2040,7 +2040,7 @@ static void coolgaugetext(int snum) } { - long lAmount=GetGameVar("PLR_MORALE",-1, p->i, snum); + int lAmount=GetGameVar("PLR_MORALE",-1, p->i, snum); if (lAmount == -1) { if (sbar.shield_amount != p->shield_amount) @@ -2195,7 +2195,7 @@ static void coolgaugetext(int snum) } if (u&2) { - long lAmount=GetGameVar("PLR_MORALE",-1, p->i, snum); + int lAmount=GetGameVar("PLR_MORALE",-1, p->i, snum); if (u != -1) patchstatusbar(52,SBY+17,75,SBY+17+11); if (lAmount == -1) digitalnumber(64,SBY+17,p->shield_amount,-16,10+16); @@ -2280,7 +2280,7 @@ static void coolgaugetext(int snum) j = 0x80000000; } if (j > 0) minitext(288-30-o,SBY+14,"ON",0,10+16+permbit + 256); - else if ((unsigned long)j != 0x80000000) minitext(284-30-o,SBY+14,"OFF",2,10+16+permbit + 256); + else if ((unsigned int)j != 0x80000000) minitext(284-30-o,SBY+14,"OFF",2,10+16+permbit + 256); } if (u&8192) { @@ -2315,11 +2315,11 @@ static void coolgaugetext(int snum) } #define AVERAGEFRAMES 16 -static long frameval[AVERAGEFRAMES], framecnt = 0; +static int frameval[AVERAGEFRAMES], framecnt = 0; static void tics(void) { - long i = totalclock,j; + int i = totalclock,j; char b[10]; if (i != frameval[framecnt]) @@ -2329,7 +2329,7 @@ static void tics(void) { int ii, k = 0, p = 8; - Bsprintf(b,"%ld",max(j,0)); + Bsprintf(b,"%d",max(j,0)); // minitext(scale(windowx1,320,xdim)+1,scale(windowy1,200,ydim)+1,b,(timer*AVERAGEFRAMES)/(i-frameval[framecnt]) < 40?2:0,26); ii = scale(k,ydim,200)+windowy1; @@ -2367,17 +2367,17 @@ static void coords(int snum) else if (ud.multimode > 1) y = 16; } - sprintf(tempbuf,"X= %ld",g_player[snum].ps->posx); + sprintf(tempbuf,"X= %d",g_player[snum].ps->posx); printext256(250L,y,31,-1,tempbuf,0); - sprintf(tempbuf,"Y= %ld",g_player[snum].ps->posy); + sprintf(tempbuf,"Y= %d",g_player[snum].ps->posy); printext256(250L,y+9L,31,-1,tempbuf,0); - Bsprintf(tempbuf,"Z= %ld",g_player[snum].ps->posz); + Bsprintf(tempbuf,"Z= %d",g_player[snum].ps->posz); printext256(250L,y+18L,31,-1,tempbuf,0); Bsprintf(tempbuf,"A= %d",g_player[snum].ps->ang); printext256(250L,y+27L,31,-1,tempbuf,0); - Bsprintf(tempbuf,"H= %ld",g_player[snum].ps->horiz); + Bsprintf(tempbuf,"H= %d",g_player[snum].ps->horiz); printext256(250L,y+36L,31,-1,tempbuf,0); - Bsprintf(tempbuf,"ZV= %ld",g_player[snum].ps->poszv); + Bsprintf(tempbuf,"ZV= %d",g_player[snum].ps->poszv); printext256(250L,y+45L,31,-1,tempbuf,0); Bsprintf(tempbuf,"OG= %d",g_player[snum].ps->on_ground); printext256(250L,y+54L,31,-1,tempbuf,0); @@ -2387,7 +2387,7 @@ static void coords(int snum) printext256(250L,y+72L,31,-1,tempbuf,0); Bsprintf(tempbuf,"SECTL= %d",sector[g_player[snum].ps->cursectnum].lotag); printext256(250L,y+81L,31,-1,tempbuf,0); - Bsprintf(tempbuf,"SEED= %ld",randomseed); + Bsprintf(tempbuf,"SEED= %d",randomseed); printext256(250L,y+90L,31,-1,tempbuf,0); Bsprintf(tempbuf,"THOLD= %d",g_player[snum].ps->transporter_hold); printext256(250L,y+99L+7,31,-1,tempbuf,0); @@ -2395,7 +2395,7 @@ static void coords(int snum) static void operatefta(void) { - long i, j = 200-45, k, l; + int i, j = 200-45, k, l; if (ud.screen_size < 1) j = 200-8; @@ -2564,7 +2564,7 @@ static void showtwoscreens(void) } } -extern long qsetmode; +extern int qsetmode; void gameexit(const char *t) { @@ -2880,12 +2880,12 @@ static void moveclouds(void) } } -static void drawoverheadmap(long cposx, long cposy, long czoom, short cang) +static void drawoverheadmap(int cposx, int cposy, int czoom, short cang) { - long i, j, k, l, x1, y1, x2=0, y2=0, x3, y3, x4, y4, ox, oy, xoff, yoff; - long dax, day, cosang, sinang, xspan, yspan, sprx, spry; - long xrepeat, yrepeat, z1, z2, startwall, endwall, tilenum, daang; - long xvect, yvect, xvect2, yvect2; + int i, j, k, l, x1, y1, x2=0, y2=0, x3, y3, x4, y4, ox, oy, xoff, yoff; + int dax, day, cosang, sinang, xspan, yspan, sprx, spry; + int xrepeat, yrepeat, z1, z2, startwall, endwall, tilenum, daang; + int xvect, yvect, xvect2, yvect2; short p; char col; walltype *wal, *wal2; @@ -2991,7 +2991,7 @@ static void drawoverheadmap(long cposx, long cposy, long czoom, short cang) x1 = sprx; y1 = spry; tilenum = spr->picnum; - xoff = (long)((signed char)((picanm[tilenum]>>8)&255))+((long)spr->xoffset); + xoff = (int)((signed char)((picanm[tilenum]>>8)&255))+((int)spr->xoffset); if ((spr->cstat&4) > 0) xoff = -xoff; k = spr->ang; l = spr->xrepeat; @@ -3023,8 +3023,8 @@ static void drawoverheadmap(long cposx, long cposy, long czoom, short cang) case 32: tilenum = spr->picnum; - xoff = (long)((signed char)((picanm[tilenum]>>8)&255))+((long)spr->xoffset); - yoff = (long)((signed char)((picanm[tilenum]>>16)&255))+((long)spr->yoffset); + xoff = (int)((signed char)((picanm[tilenum]>>8)&255))+((int)spr->xoffset); + yoff = (int)((signed char)((picanm[tilenum]>>16)&255))+((int)spr->yoffset); if ((spr->cstat&4) > 0) xoff = -xoff; if ((spr->cstat&8) > 0) yoff = -yoff; @@ -3166,18 +3166,18 @@ static void drawoverheadmap(long cposx, long cposy, long czoom, short cang) } } -void palto(int r,int g,int b,long e) +void palto(int r,int g,int b,int e) { - long tc; + int tc; /* for(i=0;i<768;i+=3) { temparray[i ] = - g_player[myconnectindex].ps->palette[i+0]+((((long)r-(long)g_player[myconnectindex].ps->palette[i+0])*(long)(e&127))>>6); + g_player[myconnectindex].ps->palette[i+0]+((((int)r-(int)g_player[myconnectindex].ps->palette[i+0])*(int)(e&127))>>6); temparray[i+1] = - g_player[myconnectindex].ps->palette[i+1]+((((long)g-(long)g_player[myconnectindex].ps->palette[i+1])*(long)(e&127))>>6); + g_player[myconnectindex].ps->palette[i+1]+((((int)g-(int)g_player[myconnectindex].ps->palette[i+1])*(int)(e&127))>>6); temparray[i+2] = - g_player[myconnectindex].ps->palette[i+2]+((((long)b-(long)g_player[myconnectindex].ps->palette[i+2])*(long)(e&127))>>6); + g_player[myconnectindex].ps->palette[i+2]+((((int)b-(int)g_player[myconnectindex].ps->palette[i+2])*(int)(e&127))>>6); } */ @@ -3191,14 +3191,14 @@ void palto(int r,int g,int b,long e) } } -void displayrest(long smoothratio) +void displayrest(int smoothratio) { - long a, i, j; + int a, i, j; char fader=0,fadeg=0,fadeb=0,fadef=0,tintr=0,tintg=0,tintb=0,tintf=0,dotint=0; player_struct *pp = g_player[screenpeek].ps; walltype *wal; - long cposx,cposy,cang; + int cposx,cposy,cang; #if defined(USE_OPENGL) && defined(POLYMOST) // this takes care of fullscreen tint for OpenGL @@ -3340,15 +3340,15 @@ void displayrest(long smoothratio) { if (screenpeek == myconnectindex && numplayers > 1) { - cposx = omyx+mulscale16((long)(myx-omyx),smoothratio); - cposy = omyy+mulscale16((long)(myy-omyy),smoothratio); - cang = omyang+mulscale16((long)(((myang+1024-omyang)&2047)-1024),smoothratio); + cposx = omyx+mulscale16((int)(myx-omyx),smoothratio); + cposy = omyy+mulscale16((int)(myy-omyy),smoothratio); + cang = omyang+mulscale16((int)(((myang+1024-omyang)&2047)-1024),smoothratio); } else { - cposx = pp->oposx+mulscale16((long)(pp->posx-pp->oposx),smoothratio); - cposy = pp->oposy+mulscale16((long)(pp->posy-pp->oposy),smoothratio); - cang = pp->oang+mulscale16((long)(((pp->ang+1024-pp->oang)&2047)-1024),smoothratio); + cposx = pp->oposx+mulscale16((int)(pp->posx-pp->oposx),smoothratio); + cposy = pp->oposy+mulscale16((int)(pp->posy-pp->oposy),smoothratio); + cang = pp->oang+mulscale16((int)(((pp->ang+1024-pp->oang)&2047)-1024),smoothratio); } } else @@ -3489,32 +3489,32 @@ void displayrest(long smoothratio) { i = (ud.screen_size <= 4)?0:scale(tilesizy[BOTTOMSTATUSBAR],ud.statusbarscale,100); - Bsprintf(tempbuf,"Time: %ld:%02ld", + Bsprintf(tempbuf,"Time: %d:%02d", (g_player[myconnectindex].ps->player_par/(26*60)), (g_player[myconnectindex].ps->player_par/26)%60); minitext(320-5*12,200-i-6-6-6,tempbuf,0,26); if (ud.player_skill > 3 || (ud.multimode > 1 && !GTFLAGS(GAMETYPE_FLAG_PLAYERSFRIENDLY))) - Bsprintf(tempbuf,"Kills: %ld",(ud.multimode>1 &&!GTFLAGS(GAMETYPE_FLAG_PLAYERSFRIENDLY))?g_player[i].ps->frag-g_player[i].ps->fraggedself:g_player[myconnectindex].ps->actors_killed); + Bsprintf(tempbuf,"Kills: %d",(ud.multimode>1 &&!GTFLAGS(GAMETYPE_FLAG_PLAYERSFRIENDLY))?g_player[i].ps->frag-g_player[i].ps->fraggedself:g_player[myconnectindex].ps->actors_killed); else - Bsprintf(tempbuf,"Kills: %ld/%ld",g_player[myconnectindex].ps->actors_killed, + Bsprintf(tempbuf,"Kills: %d/%d",g_player[myconnectindex].ps->actors_killed, g_player[myconnectindex].ps->max_actors_killed>g_player[myconnectindex].ps->actors_killed? g_player[myconnectindex].ps->max_actors_killed:g_player[myconnectindex].ps->actors_killed); minitext(320-5*12,200-i-6-6,tempbuf,0,26); - Bsprintf(tempbuf,"Secrets: %ld/%ld", g_player[myconnectindex].ps->secret_rooms,g_player[myconnectindex].ps->max_secret_rooms); + Bsprintf(tempbuf,"Secrets: %d/%d", g_player[myconnectindex].ps->secret_rooms,g_player[myconnectindex].ps->max_secret_rooms); minitext(320-5*12,200-i-6,tempbuf,0,26); } if (tintf > 0 || dotint) palto(tintr,tintg,tintb,tintf|128); } -static void view(player_struct *pp, long *vx, long *vy,long *vz,short *vsectnum, int ang, int horiz) +static void view(player_struct *pp, int *vx, int *vy,int *vz,short *vsectnum, int ang, int horiz) { spritetype *sp = &sprite[pp->i]; - long i, hx, hy, hitx, hity, hitz; - long nx = (sintable[(ang+1536)&2047]>>4); - long ny = (sintable[(ang+1024)&2047]>>4); - long nz = (horiz-100)*128; + int i, hx, hy, hitx, hity, hitz; + int nx = (sintable[(ang+1536)&2047]>>4); + int ny = (sintable[(ang+1024)&2047]>>4); + int nz = (horiz-100)*128; short hitsect, hitwall, hitsprite, daang; short bakcstat = sp->cstat; @@ -3568,7 +3568,7 @@ static void view(player_struct *pp, long *vx, long *vy,long *vz,short *vsectnum, void drawbackground(void) { short dapicnum; - long x,y,x1,y1,x2,y2,rx; + int x,y,x1,y1,x2,y2,rx; flushperms(); @@ -3704,14 +3704,14 @@ void drawbackground(void) // If standing in sector with SE43 or SE45 // then draw viewing to SE40 and lower all =hi SE42 floors. -static void SE40_Draw(int spnum,long x,long y,long z,int a,int h,long smoothratio) +static void SE40_Draw(int spnum,int x,int y,int z,int a,int h,int smoothratio) { - static long tempsectorz[MAXSECTORS]; - static long tempsectorpicnum[MAXSECTORS]; + static int tempsectorz[MAXSECTORS]; + static int tempsectorpicnum[MAXSECTORS]; int i=0,j=0,k=0; int floor1=0,floor2=0,ok=0,fofmode=0,draw_both=0; - long offx,offy,offz; + int offx,offy,offz; if (sprite[spnum].ang!=512) return; @@ -3848,7 +3848,7 @@ static void SE40_Draw(int spnum,long x,long y,long z,int a,int h,long smoothrati } } // end SE40 -void se40code(long x,long y,long z,long a,long h, long smoothratio) +void se40code(int x,int y,int z,int a,int h, int smoothratio) { int i= headspritestat[15]; @@ -3874,18 +3874,18 @@ void se40code(long x,long y,long z,long a,long h, long smoothratio) } #endif -static long oyrepeat=-1; +static int oyrepeat=-1; -void displayrooms(int snum,long smoothratio) +void displayrooms(int snum,int smoothratio) { - long dst,j,fz,cz; - long tposx,tposy,i; + int dst,j,fz,cz; + int tposx,tposy,i; short k; player_struct *p = g_player[snum].ps; short tang; - long tiltcx,tiltcy,tiltcs=0; // JBF 20030807 + int tiltcx,tiltcy,tiltcs=0; // JBF 20030807 #ifdef POLYMOST - extern long rendmode; + extern int rendmode; #endif if (pub > 0 || getrendermode() >= 3) // JBF 20040101: redraw background always @@ -3925,7 +3925,7 @@ void displayrooms(int snum,long smoothratio) if (s->yvel < 0) s->yvel = -100; else if (s->yvel > 199) s->yvel = 300; - ud.cameraang = hittype[ud.camerasprite].tempang+mulscale16((long)(((s->ang+1024-hittype[ud.camerasprite].tempang)&2047)-1024),smoothratio); + ud.cameraang = hittype[ud.camerasprite].tempang+mulscale16((int)(((s->ang+1024-hittype[ud.camerasprite].tempang)&2047)-1024),smoothratio); #ifdef SE40 se40code(s->x,s->y,s->z,ud.cameraang,s->yvel,smoothratio); #endif @@ -3946,7 +3946,7 @@ void displayrooms(int snum,long smoothratio) { walock[TILE_SAVESHOT] = 199; if (waloff[TILE_SAVESHOT] == 0) - allocache((long *)&waloff[TILE_SAVESHOT],200*320,&walock[TILE_SAVESHOT]); + allocache((int *)&waloff[TILE_SAVESHOT],200*320,&walock[TILE_SAVESHOT]); setviewtotile(TILE_SAVESHOT,200L,320L); } else if (getrendermode() == 0 && ((ud.screen_tilting && p->rotscrnang) || ud.detail==0)) @@ -4001,20 +4001,20 @@ void displayrooms(int snum,long smoothratio) if ((snum == myconnectindex) && (numplayers > 1)) { - ud.camerax = omyx+mulscale16((long)(myx-omyx),smoothratio); - ud.cameray = omyy+mulscale16((long)(myy-omyy),smoothratio); - ud.cameraz = omyz+mulscale16((long)(myz-omyz),smoothratio); - ud.cameraang = omyang+mulscale16((long)(((myang+1024-omyang)&2047)-1024),smoothratio); - ud.camerahoriz = omyhoriz+omyhorizoff+mulscale16((long)(myhoriz+myhorizoff-omyhoriz-omyhorizoff),smoothratio); + ud.camerax = omyx+mulscale16((int)(myx-omyx),smoothratio); + ud.cameray = omyy+mulscale16((int)(myy-omyy),smoothratio); + ud.cameraz = omyz+mulscale16((int)(myz-omyz),smoothratio); + ud.cameraang = omyang+mulscale16((int)(((myang+1024-omyang)&2047)-1024),smoothratio); + ud.camerahoriz = omyhoriz+omyhorizoff+mulscale16((int)(myhoriz+myhorizoff-omyhoriz-omyhorizoff),smoothratio); ud.camerasect = mycursectnum; } else { - ud.camerax = p->oposx+mulscale16((long)(p->posx-p->oposx),smoothratio); - ud.cameray = p->oposy+mulscale16((long)(p->posy-p->oposy),smoothratio); - ud.cameraz = p->oposz+mulscale16((long)(p->posz-p->oposz),smoothratio); - ud.cameraang = p->oang+mulscale16((long)(((p->ang+1024-p->oang)&2047)-1024),smoothratio); - ud.camerahoriz = p->ohoriz+p->ohorizoff+mulscale16((long)(p->horiz+p->horizoff-p->ohoriz-p->ohorizoff),smoothratio); + ud.camerax = p->oposx+mulscale16((int)(p->posx-p->oposx),smoothratio); + ud.cameray = p->oposy+mulscale16((int)(p->posy-p->oposy),smoothratio); + ud.cameraz = p->oposz+mulscale16((int)(p->posz-p->oposz),smoothratio); + ud.cameraang = p->oang+mulscale16((int)(((p->ang+1024-p->oang)&2047)-1024),smoothratio); + ud.camerahoriz = p->ohoriz+p->ohorizoff+mulscale16((int)(p->horiz+p->horizoff-p->ohoriz-p->ohorizoff),smoothratio); } ud.cameraang += p->look_ang; @@ -4032,7 +4032,7 @@ void displayrooms(int snum,long smoothratio) else if (p->over_shoulder_on == 0) { if (ud.viewbob) - ud.cameraz += p->opyoff+mulscale16((long)(p->pyoff-p->opyoff),smoothratio); + ud.cameraz += p->opyoff+mulscale16((int)(p->pyoff-p->opyoff),smoothratio); } else view(p,&ud.camerax,&ud.cameray,&ud.cameraz,&ud.camerasect,ud.cameraang,ud.camerahoriz); @@ -4150,23 +4150,23 @@ static void dumpdebugdata(void) for (j=0;j= 0) { - fprintf(fp,"Sprite %d (%ld,%ld,%ld) (picnum: %d)\n",j,sprite[j].x,sprite[j].y,sprite[j].z,sprite[j].picnum); + fprintf(fp,"Sprite %d (%d,%d,%d) (picnum: %d)\n",j,sprite[j].x,sprite[j].y,sprite[j].z,sprite[j].picnum); for (i=0;iposx,&g_player[myconnectindex].ps->posy,&g_player[myconnectindex].ps->posz,&g_player[myconnectindex].ps->ang,&g_player[myconnectindex].ps->cursectnum); } -int EGS(int whatsect,long s_x,long s_y,long s_z,int s_pn,int s_s,int s_xr,int s_yr,int s_a,int s_ve,long s_zv,int s_ow,int s_ss) +int EGS(int whatsect,int s_x,int s_y,int s_z,int s_pn,int s_s,int s_xr,int s_yr,int s_a,int s_ve,int s_zv,int s_ow,int s_ss) { int i = insertsprite(whatsect,s_ss); - long p; + int p; spritetype *s = &sprite[i]; if (i < 0) { dumpdebugdata(); - OSD_Printf("Failed spawning sprite with tile %ld from sprite %ld (%ld) at x:%ld,y:%ld,z:%ld,sector:%ld\n",s_pn,s_ow,sprite[s_ow].picnum,s_x,s_y,s_z,whatsect); + OSD_Printf("Failed spawning sprite with tile %d from sprite %d (%d) at x:%d,y:%d,z:%d,sector:%d\n",s_pn,s_ow,sprite[s_ow].picnum,s_x,s_y,s_z,whatsect); gameexit("Too many sprites spawned."); } @@ -4359,7 +4359,7 @@ int wallswitchcheck(int i) int spawn(int j, int pn) { int i, s, startwall, endwall, sect, clostest=0; - long x, y, d, p; + int x, y, d, p; spritetype *sp; if (j >= 0) @@ -5835,7 +5835,7 @@ int spawn(int j, int pn) case 20: { - long q; + int q; startwall = sector[sect].wallptr; endwall = startwall+sector[sect].wallnum; @@ -6008,7 +6008,7 @@ int spawn(int j, int pn) } if (j == MAXSPRITES) { - Bsprintf(tempbuf,"Found lonely Sector Effector (lotag 0) at (%ld,%ld)\n",sp->x,sp->y); + Bsprintf(tempbuf,"Found lonely Sector Effector (lotag 0) at (%d,%d)\n",sp->x,sp->y); gameexit(tempbuf); } sp->owner = j; @@ -6025,7 +6025,7 @@ int spawn(int j, int pn) tempwallptr++; if (tempwallptr > 2047) { - Bsprintf(tempbuf,"Too many moving sectors at (%ld,%ld).\n",wall[s].x,wall[s].y); + Bsprintf(tempbuf,"Too many moving sectors at (%d,%d).\n",wall[s].x,wall[s].y); gameexit(tempbuf); } } @@ -6057,7 +6057,7 @@ int spawn(int j, int pn) if (j == 0) { - Bsprintf(tempbuf,"Subway found no zero'd sectors with locators\nat (%ld,%ld).\n",sp->x,sp->y); + Bsprintf(tempbuf,"Subway found no zero'd sectors with locators\nat (%d,%d).\n",sp->x,sp->y); gameexit(tempbuf); } @@ -6231,10 +6231,10 @@ int spawn(int j, int pn) //#pragma auto_inline(off) #pragma optimize("g",off) #endif -void animatesprites(long x,long y,int a,long smoothratio) +void animatesprites(int x,int y,int a,int smoothratio) { int i, j, k, p, sect; - long l, t1,t3,t4; + int l, t1,t3,t4; spritetype *s,*t; int switchpic; @@ -6600,10 +6600,10 @@ void animatesprites(long x,long y,int a,long smoothratio) t->cstat |= 2; if (screenpeek == myconnectindex && numplayers >= 2) { - t->x = omyx+mulscale16((long)(myx-omyx),smoothratio); - t->y = omyy+mulscale16((long)(myy-omyy),smoothratio); - t->z = omyz+mulscale16((long)(myz-omyz),smoothratio)+(40<<8); - t->ang = omyang+mulscale16((long)(((myang+1024-omyang)&2047)-1024),smoothratio); + t->x = omyx+mulscale16((int)(myx-omyx),smoothratio); + t->y = omyy+mulscale16((int)(myy-omyy),smoothratio); + t->z = omyz+mulscale16((int)(myz-omyz),smoothratio)+(40<<8); + t->ang = omyang+mulscale16((int)(((myang+1024-omyang)&2047)-1024),smoothratio); t->sectnum = mycursectnum; } } @@ -6781,14 +6781,14 @@ PALONLY: if (ud.angleinterpolation) { if (sprpos[i].ang != sprpos[i].oldang) - t->ang = (sprpos[i].oldang + (mulscale16((long)(sprpos[i].angdif),smoothratio) * sprpos[i].angdir)) & 2047; + t->ang = (sprpos[i].oldang + (mulscale16((int)(sprpos[i].angdif),smoothratio) * sprpos[i].angdir)) & 2047; else t->ang = sprpos[i].ang; } if (t4) { - l = *(long *)(t4+8); + l = *(int *)(t4+8); #if defined(POLYMOST) && defined(USE_OPENGL) if (bpp > 8 && usemodels && md_tilehasmodel(s->picnum) >= 0) { @@ -6843,7 +6843,7 @@ PALONLY: break; } - t->picnum += k + (*(long *)t4) + l * t3; + t->picnum += k + (*(int *)t4) + l * t3; if (l > 0) while (tilesizx[t->picnum] == 0 && t->picnum > 0) t->picnum -= l; //Hack, for actors @@ -6872,7 +6872,7 @@ PALONLY: } else if (ud.shadows && spritesortcnt < (MAXSPRITESONSCREEN-2)) { - long daz,xrep,yrep; + int daz,xrep,yrep; if ((sector[sect].lotag&0xff) > 2 || s->statnum == 4 || s->statnum == 5 || s->picnum == DRONE || s->picnum == COMMANDER) daz = sector[sect].floorz; @@ -7661,7 +7661,7 @@ FOUNDCHEAT: static void nonsharedkeys(void) { int i,ch; - long j; + int j; if (ud.recstat == 2) { @@ -9061,7 +9061,7 @@ static void checkcommandline(int argc,const char **argv) static void Logo(void) { int soundanm = 0; - long logoflags=GetGameVar("LOGO_FLAGS",255, -1, -1); + int logoflags=GetGameVar("LOGO_FLAGS",255, -1, -1); ready2send = 0; @@ -9248,7 +9248,7 @@ static void Logo(void) static void loadtmb(void) { unsigned char tmb[8000]; - long fil, l; + int fil, l; fil = kopen4load("d3dtimbr.tmb",0); if (fil == -1) return; @@ -9342,8 +9342,8 @@ static void compilecons(void) { int i; label = (char *)&sprite[0]; // V8: 16384*44/64 = 11264 V7: 4096*44/64 = 2816 - labelcode = (long *)§or[0]; // V8: 4096*40/4 = 40960 V7: 1024*40/4 = 10240 - labeltype = (long *)&wall[0]; // V8: 16384*32/4 = 131072 V7: 8192*32/4 = 65536 + labelcode = (int *)§or[0]; // V8: 4096*40/4 = 40960 V7: 1024*40/4 = 10240 + labeltype = (int *)&wall[0]; // V8: 16384*32/4 = 131072 V7: 8192*32/4 = 65536 // if we compile for a V7 engine wall[] should be used for label names since it's bigger if (userconfiles == 0) @@ -9370,15 +9370,15 @@ static void compilecons(void) loadefs(confilename); } - if ((unsigned long)labelcnt > MAXSPRITES*sizeof(spritetype)/64) // see the arithmetic above for why + if ((unsigned int)labelcnt > MAXSPRITES*sizeof(spritetype)/64) // see the arithmetic above for why gameexit("Error: too many labels defined!"); else { char *newlabel; - long *newlabelcode; + int *newlabelcode; newlabel = (char *)malloc(labelcnt<<6); - newlabelcode = (long *)malloc(labelcnt*sizeof(long)); + newlabelcode = (int *)malloc(labelcnt*sizeof(int)); if (!newlabel || !newlabelcode) { @@ -9386,7 +9386,7 @@ static void compilecons(void) } copybuf(label, newlabel, (labelcnt*64)/4); - copybuf(labelcode, newlabelcode, (labelcnt*sizeof(long))/4); + copybuf(labelcode, newlabelcode, (labelcnt*sizeof(int))/4); label = newlabel; labelcode = newlabelcode; @@ -9414,7 +9414,7 @@ static void sanitizegametype() static void genspriteremaps(void) { - long j,fp; + int j,fp; signed char look_pos; char *lookfn = "lookup.dat"; @@ -9428,7 +9428,7 @@ static void genspriteremaps(void) { kread(fp,(signed char *)&look_pos,1); kread(fp,tempbuf,256); - makepalookup((long)look_pos,tempbuf,0,0,0,1); + makepalookup((int)look_pos,tempbuf,0,0,0,1); } for (j = 0; j < 256; j++) @@ -9455,7 +9455,7 @@ static void genspriteremaps(void) extern int startwin_run(void); static void SetupGameButtons(void); -static void Startup(long argc, const char **argv) +static void Startup(int argc, const char **argv) { int i; @@ -9531,7 +9531,7 @@ static void Startup(long argc, const char **argv) if (VOLUMEONE) { - initprintf("*** You have run Duke Nukem 3D %ld times. ***\n\n",ud.executions); + initprintf("*** You have run Duke Nukem 3D %d times. ***\n\n",ud.executions); if (ud.executions >= 50) initprintf("IT IS NOW TIME TO UPGRADE TO THE COMPLETE VERSION!!!\n"); } @@ -9762,20 +9762,20 @@ void updateplayer(void) } #if 0 -void writestring(long a1,long a2,long a3,short a4,long vx,long vy,long vz) +void writestring(int a1,int a2,int a3,short a4,int vx,int vy,int vz) { FILE *fp; fp = (FILE *)fopen("debug.txt","rt+"); - fprintf(fp,"%ld %ld %ld %d %ld %ld %ld\n",a1,a2,a3,a4,vx,vy,vz); + fprintf(fp,"%d %d %d %d %d %d %d\n",a1,a2,a3,a4,vx,vy,vz); fclose(fp); } #endif #if 0 -char testcd(char *fn, long testsiz); +char testcd(char *fn, int testsiz); // JBF: various hacks here static void copyprotect(void) @@ -10471,7 +10471,7 @@ static int opendemoread(int which_demo) // 0 = mine { char d[13]; char ver; - int32 i; + int i; Bstrcpy(d, "demo_.dmo"); @@ -10489,7 +10489,7 @@ static int opendemoread(int which_demo) // 0 = mine else if ((recfilep = kopen4load(d,loadfromgrouponly)) == -1) return(0); - if (kread(recfilep,&ud.reccnt,sizeof(long)) != sizeof(long)) goto corrupt; + if (kread(recfilep,&ud.reccnt,sizeof(int)) != sizeof(int)) goto corrupt; if (kread(recfilep,&ver,sizeof(char)) != sizeof(char)) goto corrupt; if (ver != BYTEVERSION /*&& ver != 116 && ver != 117*/) @@ -10524,15 +10524,15 @@ static int opendemoread(int which_demo) // 0 = mine OSD_Printf("ud.multimode: %d\n",ud.multimode); if (kread(recfilep,(short *)&ud.m_monsters_off,sizeof(short)) != sizeof(short)) goto corrupt; OSD_Printf("ud.m_monsters_off: %d\n",ud.m_monsters_off); - if (kread(recfilep,(int32 *)&ud.m_respawn_monsters,sizeof(int32)) != sizeof(int32)) goto corrupt; + if (kread(recfilep,(int *)&ud.m_respawn_monsters,sizeof(int)) != sizeof(int)) goto corrupt; OSD_Printf("ud.m_respawn_monsters: %d\n",ud.m_respawn_monsters); - if (kread(recfilep,(int32 *)&ud.m_respawn_items,sizeof(int32)) != sizeof(int32)) goto corrupt; + if (kread(recfilep,(int *)&ud.m_respawn_items,sizeof(int)) != sizeof(int)) goto corrupt; OSD_Printf("ud.m_respawn_items: %d\n",ud.m_respawn_items); - if (kread(recfilep,(int32 *)&ud.m_respawn_inventory,sizeof(int32)) != sizeof(int32)) goto corrupt; + if (kread(recfilep,(int *)&ud.m_respawn_inventory,sizeof(int)) != sizeof(int)) goto corrupt; OSD_Printf("ud.m_respawn_inventory: %d\n",ud.m_respawn_inventory); - if (kread(recfilep,(int32 *)&ud.playerai,sizeof(int32)) != sizeof(int32)) goto corrupt; + if (kread(recfilep,(int *)&ud.playerai,sizeof(int)) != sizeof(int)) goto corrupt; OSD_Printf("ud.playerai: %d\n",ud.playerai); - if (kread(recfilep,(int32 *)&i,sizeof(int32)) != sizeof(int32)) goto corrupt; + if (kread(recfilep,(int *)&i,sizeof(int)) != sizeof(int)) goto corrupt; if (kread(recfilep,(char *)boardfilename,sizeof(boardfilename)) != sizeof(boardfilename)) goto corrupt; @@ -10542,23 +10542,23 @@ static int opendemoread(int which_demo) // 0 = mine ud.m_volume_number = 0; } - if (kread(recfilep,(int32 *)&ud.m_noexits,sizeof(int32)) != sizeof(int32)) goto corrupt; + if (kread(recfilep,(int *)&ud.m_noexits,sizeof(int)) != sizeof(int)) goto corrupt; for (i=0;iaim_mode,sizeof(int32)) != sizeof(int32)) goto corrupt; - if (kread(recfilep,(int32 *)&g_player[i].ps->auto_aim,sizeof(int32)) != sizeof(int32)) goto corrupt; // JBF 20031126 - if (kread(recfilep,(int32 *)&g_player[i].ps->weaponswitch,sizeof(int32)) != sizeof(int32)) goto corrupt; - if (kread(recfilep,(int32 *)&g_player[i].pcolor,sizeof(int32)) != sizeof(int32)) goto corrupt; + if (kread(recfilep,(int *)&g_player[i].ps->aim_mode,sizeof(int)) != sizeof(int)) goto corrupt; + if (kread(recfilep,(int *)&g_player[i].ps->auto_aim,sizeof(int)) != sizeof(int)) goto corrupt; // JBF 20031126 + if (kread(recfilep,(int *)&g_player[i].ps->weaponswitch,sizeof(int)) != sizeof(int)) goto corrupt; + if (kread(recfilep,(int *)&g_player[i].pcolor,sizeof(int)) != sizeof(int)) goto corrupt; g_player[i].ps->palookup = g_player[i].pcolor; - if (kread(recfilep,(int32 *)&g_player[i].pteam,sizeof(int32)) != sizeof(int32)) goto corrupt; + if (kread(recfilep,(int *)&g_player[i].pteam,sizeof(int)) != sizeof(int)) goto corrupt; g_player[i].ps->team = g_player[i].pteam; } @@ -10577,7 +10577,7 @@ corrupt: void opendemowrite(void) { char *d = "demo1.dmo"; - long dummylong = 0; + int dummylong = 0; char ver; short i; @@ -10595,22 +10595,22 @@ void opendemowrite(void) fwrite((char *)&ud.m_ffire,sizeof(char),1,frecfilep); fwrite((short *)&ud.multimode,sizeof(short),1,frecfilep); fwrite((short *)&ud.m_monsters_off,sizeof(short),1,frecfilep); - fwrite((int32 *)&ud.m_respawn_monsters,sizeof(int32),1,frecfilep); - fwrite((int32 *)&ud.m_respawn_items,sizeof(int32),1,frecfilep); - fwrite((int32 *)&ud.m_respawn_inventory,sizeof(int32),1,frecfilep); - fwrite((int32 *)&ud.playerai,sizeof(int32),1,frecfilep); - fwrite((int32 *)&ud.auto_run,sizeof(int32),1,frecfilep); + fwrite((int *)&ud.m_respawn_monsters,sizeof(int),1,frecfilep); + fwrite((int *)&ud.m_respawn_items,sizeof(int),1,frecfilep); + fwrite((int *)&ud.m_respawn_inventory,sizeof(int),1,frecfilep); + fwrite((int *)&ud.playerai,sizeof(int),1,frecfilep); + fwrite((int *)&ud.auto_run,sizeof(int),1,frecfilep); fwrite((char *)boardfilename,sizeof(boardfilename),1,frecfilep); - fwrite((int32 *)&ud.m_noexits,sizeof(int32),1,frecfilep); + fwrite((int *)&ud.m_noexits,sizeof(int),1,frecfilep); for (i=0;iaim_mode,sizeof(int32),1,frecfilep); - fwrite((int32 *)&g_player[i].ps->auto_aim,sizeof(int32),1,frecfilep); // JBF 20031126 - fwrite(&g_player[i].ps->weaponswitch,sizeof(int32),1,frecfilep); - fwrite(&g_player[i].pcolor,sizeof(int32),1,frecfilep); - fwrite(&g_player[i].pteam,sizeof(int32),1,frecfilep); + fwrite((int *)&g_player[i].ps->aim_mode,sizeof(int),1,frecfilep); + fwrite((int *)&g_player[i].ps->auto_aim,sizeof(int),1,frecfilep); // JBF 20031126 + fwrite(&g_player[i].ps->weaponswitch,sizeof(int),1,frecfilep); + fwrite(&g_player[i].pcolor,sizeof(int),1,frecfilep); + fwrite(&g_player[i].pteam,sizeof(int),1,frecfilep); } totalreccnt = 0; @@ -10643,7 +10643,7 @@ void closedemowrite(void) dfwrite(recsync,sizeof(input)*ud.multimode,ud.reccnt/ud.multimode,frecfilep); fseek(frecfilep,SEEK_SET,0L); - fwrite(&totalreccnt,sizeof(long),1,frecfilep); + fwrite(&totalreccnt,sizeof(int),1,frecfilep); ud.recstat = ud.m_recstat = 0; } fclose(frecfilep); @@ -10653,10 +10653,10 @@ void closedemowrite(void) static int which_demo = 1; static int in_menu = 0; -// extern long syncs[]; -static long playback(void) +// extern int syncs[]; +static int playback(void) { - long i,j,k,l; + int i,j,k,l; int foundemo = 0; if (ready2send) return 0; @@ -10823,7 +10823,7 @@ RECHECK: #if 0 { - unsigned long crcv; + unsigned int crcv; // sync checker + initcrc32table(); crc32init(&crcv); @@ -10861,7 +10861,7 @@ static int moveloop() static void fakedomovethingscorrect(void) { - long i; + int i; player_struct *p; if (numplayers < 2) return; @@ -10903,8 +10903,8 @@ static void fakedomovethings(void) { input *syn; player_struct *p; - long i, j, k, doubvel, fz, cz, hz, lz, x, y; - unsigned long sb_snum; + int i, j, k, doubvel, fz, cz, hz, lz, x, y; + unsigned int sb_snum; short psect, psectlotag, tempsect, backcstat; char shrunk, spritebridge; @@ -11210,7 +11210,7 @@ static void fakedomovethings(void) else if (syn->avel) //p->ang += syncangvel * constant { //ENGINE calculates angvel for you - long tempang = syn->avel<<1; + int tempang = syn->avel<<1; if (psectlotag == 2) myang += (tempang-(tempang>>3))*ksgn(doubvel); @@ -11407,7 +11407,7 @@ static int domovethings(void) if (ud.idplayers && ud.multimode > 1) { - long sx,sy,sz; + int sx,sy,sz; short sect,hw,hs; for (i=0;iplayer_par/(26*60)), (g_player[myconnectindex].ps->player_par/26)%60); gametext((320>>2)+71,yy+9,tempbuf,0,2+8+16); @@ -12213,7 +12213,7 @@ FRAGBONUS: if (!(ud.volume_number == 0 && ud.last_level-1 == 7)) { - Bsprintf(tempbuf,"%0*ld:%02ld",clockpad, + Bsprintf(tempbuf,"%0*d:%02d",clockpad, (map[ud.volume_number*MAXLEVELS+ud.last_level-1].partime/(26*60)), (map[ud.volume_number*MAXLEVELS+ud.last_level-1].partime/26)%60); gametext((320>>2)+71,yy+9,tempbuf,0,2+8+16); @@ -12221,7 +12221,7 @@ FRAGBONUS: if (!NAM) { - Bsprintf(tempbuf,"%0*ld:%02ld",clockpad, + Bsprintf(tempbuf,"%0*d:%02d",clockpad, (map[ud.volume_number*MAXLEVELS+ud.last_level-1].designertime/(26*60)), (map[ud.volume_number*MAXLEVELS+ud.last_level-1].designertime/26)%60); gametext((320>>2)+71,yy+9,tempbuf,0,2+8+16); @@ -12231,7 +12231,7 @@ FRAGBONUS: if (playerbest > 0) { - sprintf(tempbuf,"%0*ld:%02ld",clockpad, + sprintf(tempbuf,"%0*d:%02d",clockpad, (playerbest/(26*60)), (playerbest/26)%60); gametext((320>>2)+71,yy+9,tempbuf,0,2+8+16); @@ -12263,7 +12263,7 @@ FRAGBONUS: bonuscnt++; sound(PIPEBOMB_EXPLODE); } - sprintf(tempbuf,"%-3ld",g_player[myconnectindex].ps->actors_killed); + sprintf(tempbuf,"%-3d",g_player[myconnectindex].ps->actors_killed); gametext((320>>2)+70,yy+9,tempbuf,0,2+8+16); yy += 10; if (ud.player_skill > 3) @@ -12276,7 +12276,7 @@ FRAGBONUS: { if ((g_player[myconnectindex].ps->max_actors_killed-g_player[myconnectindex].ps->actors_killed) < 0) sprintf(tempbuf,"%-3d",0); - else sprintf(tempbuf,"%-3ld",g_player[myconnectindex].ps->max_actors_killed-g_player[myconnectindex].ps->actors_killed); + else sprintf(tempbuf,"%-3d",g_player[myconnectindex].ps->max_actors_killed-g_player[myconnectindex].ps->actors_killed); gametext((320>>2)+70,yy+9,tempbuf,0,2+8+16); yy += 10; } @@ -12300,12 +12300,12 @@ FRAGBONUS: bonuscnt++; sound(PIPEBOMB_EXPLODE); } - sprintf(tempbuf,"%-3ld",g_player[myconnectindex].ps->secret_rooms); + sprintf(tempbuf,"%-3d",g_player[myconnectindex].ps->secret_rooms); gametext((320>>2)+70,yy+9,tempbuf,0,2+8+16); yy += 10; if (g_player[myconnectindex].ps->secret_rooms > 0) - sprintf(tempbuf,"%-3ld%%",(100*g_player[myconnectindex].ps->secret_rooms/g_player[myconnectindex].ps->max_secret_rooms)); - sprintf(tempbuf,"%-3ld",g_player[myconnectindex].ps->max_secret_rooms-g_player[myconnectindex].ps->secret_rooms); + sprintf(tempbuf,"%-3d%%",(100*g_player[myconnectindex].ps->secret_rooms/g_player[myconnectindex].ps->max_secret_rooms)); + sprintf(tempbuf,"%-3d",g_player[myconnectindex].ps->max_secret_rooms-g_player[myconnectindex].ps->secret_rooms); gametext((320>>2)+70,yy+9,tempbuf,0,2+8+16); yy += 10; } @@ -12334,7 +12334,7 @@ FRAGBONUS: static void cameratext(short i) { char flipbits; - long x , y; + int x , y; if (!T1) { @@ -12355,9 +12355,9 @@ static void cameratext(short i) } #if 0 -void vglass(long x,long y,short a,short wn,short n) +void vglass(int x,int y,short a,short wn,short n) { - long z, zincs; + int z, zincs; short sect; sect = wall[wn].nextsector; @@ -12371,7 +12371,7 @@ void vglass(long x,long y,short a,short wn,short n) void lotsofglass(int i,int wallnum,int n) { - long j, xv, yv, z, x1, y1; + int j, xv, yv, z, x1, y1; short sect; int a; @@ -12420,7 +12420,7 @@ void lotsofglass(int i,int wallnum,int n) void spriteglass(int i,int n) { - long j, k, a, z; + int j, k, a, z; for (j=n;j>0;j--) { @@ -12433,7 +12433,7 @@ void spriteglass(int i,int n) void ceilingglass(int i,int sectnum,int n) { - long j, xv, yv, z, x1, y1; + int j, xv, yv, z, x1, y1; int a,s, startwall,endwall; startwall = sector[sectnum].wallptr; @@ -12460,7 +12460,7 @@ void ceilingglass(int i,int sectnum,int n) void lotsofcolourglass(int i,int wallnum,int n) { - long j, xv, yv, z, x1, y1; + int j, xv, yv, z, x1, y1; short sect = -1; int a, k; @@ -12561,7 +12561,7 @@ static void SetupGameButtons(void) =================== */ -long GetTime(void) +int GetTime(void) { return totalclock; } diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index 3c0127995..b0d94506c 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -36,7 +36,7 @@ int total_lines,line_number; static int checking_ifelse,parsing_state; char g_szBuf[1024]; -long *casescriptptr=NULL; // the pointer to the start of the case table in a switch statement +int *casescriptptr=NULL; // the pointer to the start of the case table in a switch statement // first entry is 'default' code. static int casecount = 0; static int checking_switch = 0, current_event = -1; @@ -45,23 +45,23 @@ static int num_braces = 0; // init to some sensible defaults int redefined_quote_count = 0; -long *aplWeaponClip[MAX_WEAPONS]; // number of items in magazine -long *aplWeaponReload[MAX_WEAPONS]; // delay to reload (include fire) -long *aplWeaponFireDelay[MAX_WEAPONS]; // delay to fire -long *aplWeaponHoldDelay[MAX_WEAPONS]; // delay after release fire button to fire (0 for none) -long *aplWeaponTotalTime[MAX_WEAPONS]; // The total time the weapon is cycling before next fire. -long *aplWeaponFlags[MAX_WEAPONS]; // Flags for weapon -long *aplWeaponShoots[MAX_WEAPONS]; // what the weapon shoots -long *aplWeaponSpawnTime[MAX_WEAPONS]; // the frame at which to spawn an item -long *aplWeaponSpawn[MAX_WEAPONS]; // the item to spawn -long *aplWeaponShotsPerBurst[MAX_WEAPONS]; // number of shots per 'burst' (one ammo per 'burst' -long *aplWeaponWorksLike[MAX_WEAPONS]; // What original the weapon works like -long *aplWeaponInitialSound[MAX_WEAPONS]; // Sound made when initialy firing. zero for no sound -long *aplWeaponFireSound[MAX_WEAPONS]; // Sound made when firing (each time for automatic) -long *aplWeaponSound2Time[MAX_WEAPONS]; // Alternate sound time -long *aplWeaponSound2Sound[MAX_WEAPONS]; // Alternate sound sound ID -long *aplWeaponReloadSound1[MAX_WEAPONS]; // Sound of magazine being removed -long *aplWeaponReloadSound2[MAX_WEAPONS]; // Sound of magazine being inserted +int *aplWeaponClip[MAX_WEAPONS]; // number of items in magazine +int *aplWeaponReload[MAX_WEAPONS]; // delay to reload (include fire) +int *aplWeaponFireDelay[MAX_WEAPONS]; // delay to fire +int *aplWeaponHoldDelay[MAX_WEAPONS]; // delay after release fire button to fire (0 for none) +int *aplWeaponTotalTime[MAX_WEAPONS]; // The total time the weapon is cycling before next fire. +int *aplWeaponFlags[MAX_WEAPONS]; // Flags for weapon +int *aplWeaponShoots[MAX_WEAPONS]; // what the weapon shoots +int *aplWeaponSpawnTime[MAX_WEAPONS]; // the frame at which to spawn an item +int *aplWeaponSpawn[MAX_WEAPONS]; // the item to spawn +int *aplWeaponShotsPerBurst[MAX_WEAPONS]; // number of shots per 'burst' (one ammo per 'burst' +int *aplWeaponWorksLike[MAX_WEAPONS]; // What original the weapon works like +int *aplWeaponInitialSound[MAX_WEAPONS]; // Sound made when initialy firing. zero for no sound +int *aplWeaponFireSound[MAX_WEAPONS]; // Sound made when firing (each time for automatic) +int *aplWeaponSound2Time[MAX_WEAPONS]; // Alternate sound time +int *aplWeaponSound2Sound[MAX_WEAPONS]; // Alternate sound sound ID +int *aplWeaponReloadSound1[MAX_WEAPONS]; // Sound of magazine being removed +int *aplWeaponReloadSound2[MAX_WEAPONS]; // Sound of magazine being inserted int g_iReturnVarID=-1; // var ID of "RETURN" int g_iWeaponVarID=-1; // var ID of "WEAPON" @@ -74,15 +74,15 @@ int g_iHiTagID=-1; // var ID of "HITAG" int g_iTextureID=-1; // var ID of "TEXTURE" int g_iThisActorID=-1; // var ID of "THISACTOR" -long *actorLoadEventScrptr[MAXTILES]; +int *actorLoadEventScrptr[MAXTILES]; -long *apScriptGameEvent[MAXGAMEEVENTS]; -long *parsing_event=NULL; +int *apScriptGameEvent[MAXGAMEEVENTS]; +int *parsing_event=NULL; gamevar_t aGameVars[MAXGAMEVARS]; int iGameVarCount=0; -extern long qsetmode; +extern int qsetmode; char *textptr; int error,warning; @@ -108,7 +108,7 @@ static const char *labeltypenames[] = "move" }; -static const char *translatelabeltype(long type) +static const char *translatelabeltype(int type) { int i; char x[64]; @@ -857,14 +857,14 @@ static int skipcomments(void) else if (c == '/' && textptr[1] == '/') { if (!(error || warning) && g_ScriptDebug > 1) - initprintf("%s:%ld: debug: got comment.\n",compilefile,line_number); + initprintf("%s:%d: debug: got comment.\n",compilefile,line_number); while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; } else if (c == '/' && textptr[1] == '*') { if (!(error || warning) && g_ScriptDebug > 1) - initprintf("%s:%ld: debug: got start of comment block.\n",compilefile,line_number); + initprintf("%s:%d: debug: got start of comment block.\n",compilefile,line_number); while (*textptr && !(textptr[0] == '*' && textptr[1] == '/')) { if (*textptr == '\n') @@ -872,13 +872,13 @@ static int skipcomments(void) textptr++; } if ((!(error || warning) && g_ScriptDebug > 1) && (textptr[0] == '*' && textptr[1] == '/')) - initprintf("%s:%ld: debug: got end of comment block.\n",compilefile,line_number); + initprintf("%s:%d: debug: got end of comment block.\n",compilefile,line_number); if (!*textptr) { if (!(error || warning) && g_ScriptDebug) - initprintf("%s:%ld: debug: EOF in comment!\n",compilefile,line_number); + initprintf("%s:%d: debug: EOF in comment!\n",compilefile,line_number); ReportError(-1); - initprintf("%s:%ld: error: found `/*' with no `*/'.\n",compilefile,line_number); + initprintf("%s:%d: error: found `/*' with no `*/'.\n",compilefile,line_number); parsing_state = num_braces = 0; parsing_actor = 0; error++; @@ -891,29 +891,29 @@ static int skipcomments(void) if ((unsigned)(scriptptr-script) > (unsigned)(g_ScriptSize-32)) { - long oscriptptr = (unsigned)(scriptptr-script); - long ocasescriptptr = (unsigned)(casescriptptr-script); - long oparsing_event = (unsigned)(parsing_event-script); - long oparsing_actor = (unsigned)(parsing_actor-script); + int oscriptptr = (unsigned)(scriptptr-script); + int ocasescriptptr = (unsigned)(casescriptptr-script); + int oparsing_event = (unsigned)(parsing_event-script); + int oparsing_actor = (unsigned)(parsing_actor-script); char *scriptptrs; - long *newscript; + int *newscript; for (i=0;i= (long)(&script[0]) && (long)script[i] < (long)(&script[g_ScriptSize])) +// initprintf("%d\n",i); + if ((int)script[i] >= (int)(&script[0]) && (int)script[i] < (int)(&script[g_ScriptSize])) { scriptptrs[i] = 1; - j = (long)script[i] - (long)&script[0]; + j = (int)script[i] - (int)&script[0]; script[i] = j; } else scriptptrs[i] = 0; @@ -922,81 +922,81 @@ static int skipcomments(void) for (i=0;i=0 ; i++) @@ -1234,7 +1234,7 @@ static long getlabelid(LABELS *pLabel, const char *psz) return l; } -static long getlabeloffset(LABELS *pLabel, const char *psz) +static int getlabeloffset(LABELS *pLabel, const char *psz) { // find the label psz in the table pLabel. // returns the offset in the array for the label, or -1 @@ -1253,7 +1253,7 @@ static long getlabeloffset(LABELS *pLabel, const char *psz) static void getlabel(void) { - long i; + int i; skipcomments(); @@ -1271,12 +1271,12 @@ static void getlabel(void) label[(labelcnt<<6)+i] = 0; if (!(error || warning) && g_ScriptDebug > 1) - initprintf("%s:%ld: debug: got label `%s'.\n",compilefile,line_number,label+(labelcnt<<6)); + initprintf("%s:%d: debug: got label `%s'.\n",compilefile,line_number,label+(labelcnt<<6)); } -static long keyword(void) +static int keyword(void) { - long i; + int i; char *temptextptr; skipcomments(); @@ -1304,9 +1304,9 @@ static long keyword(void) return -1; } -static long transword(void) //Returns its code # +static int transword(void) //Returns its code # { - long i, l; + int i, l; skipcomments(); @@ -1339,7 +1339,7 @@ static long transword(void) //Returns its code # textptr += l; scriptptr++; if (!(error || warning) && g_ScriptDebug) - initprintf("%s:%ld: debug: translating keyword `%s'.\n",compilefile,line_number,keyw[i]); + initprintf("%s:%d: debug: translating keyword `%s'.\n",compilefile,line_number,keyw[i]); return i; } } @@ -1349,12 +1349,12 @@ static long transword(void) //Returns its code # if (tempbuf[0] == '{' && tempbuf[1] != 0) { ReportError(-1); - initprintf("%s:%ld: error: expected a SPACE or CR between `{' and `%s'.\n",compilefile,line_number,tempbuf+1); + initprintf("%s:%d: error: expected a SPACE or CR between `{' and `%s'.\n",compilefile,line_number,tempbuf+1); } else if (tempbuf[0] == '}' && tempbuf[1] != 0) { ReportError(-1); - initprintf("%s:%ld: error: expected a SPACE or CR between `}' and `%s'.\n",compilefile,line_number,tempbuf+1); + initprintf("%s:%d: error: expected a SPACE or CR between `}' and `%s'.\n",compilefile,line_number,tempbuf+1); } else ReportError(ERROR_EXPECTEDKEYWORD); error++; @@ -1369,7 +1369,7 @@ static void transvartype(int type) if (!type && !labelsonly && (isdigit(*textptr) || ((*textptr == '-') && (isdigit(*(textptr+1)))))) { if (!(error || warning) && g_ScriptDebug) - initprintf("%s:%ld: debug: accepted constant %ld in place of gamevar.\n",compilefile,line_number,atol(textptr)); + initprintf("%s:%d: debug: accepted constant %d in place of gamevar.\n",compilefile,line_number,atol(textptr)); *scriptptr++=MAXGAMEVARS; *scriptptr++=atol(textptr); getlabel(); @@ -1380,7 +1380,7 @@ static void transvartype(int type) if (!type) { if (!(error || warning) && g_ScriptDebug) - initprintf("%s:%ld: debug: flagging gamevar as negative.\n",compilefile,line_number,atol(textptr)); + initprintf("%s:%d: debug: flagging gamevar as negative.\n",compilefile,line_number,atol(textptr)); f = (MAXGAMEVARS<<1); } else @@ -1411,7 +1411,7 @@ static void transvartype(int type) if (Bstrcmp(tempbuf,label+(i<<6)) == 0 && (labeltype[i] & LABEL_DEFINE)) { if (!(error || warning) && g_ScriptDebug) - initprintf("%s:%ld: debug: accepted defined label `%s' instead of gamevar.\n",compilefile,line_number,label+(i<<6)); + initprintf("%s:%d: debug: accepted defined label `%s' instead of gamevar.\n",compilefile,line_number,label+(i<<6)); *scriptptr++=MAXGAMEVARS; *scriptptr++=labelcode[i]; textptr++; @@ -1443,10 +1443,10 @@ static void transvartype(int type) if ((aGameVars[i].dwFlags & GAMEVAR_FLAG_SYNCCHECK) && parsing_actor && CheckEventSync(current_event)) { ReportError(-1); - initprintf("%s:%ld: warning: found local gamevar `%s' used within %s; expect multiplayer synchronization issues.\n",compilefile,line_number,label+(labelcnt<<6),parsing_event?"a synced event":"an actor"); + initprintf("%s:%d: warning: found local gamevar `%s' used within %s; expect multiplayer synchronization issues.\n",compilefile,line_number,label+(labelcnt<<6),parsing_event?"a synced event":"an actor"); } if (!(error || warning) && g_ScriptDebug > 1) - initprintf("%s:%ld: debug: accepted gamevar `%s'.\n",compilefile,line_number,label+(labelcnt<<6)); + initprintf("%s:%d: debug: accepted gamevar `%s'.\n",compilefile,line_number,label+(labelcnt<<6)); i |= f; *scriptptr++=i; } @@ -1468,9 +1468,9 @@ static inline void transmultvars(int num) transmultvarstype(0,num); } -static long transnum(long type) +static int transnum(int type) { - long i, l; + int i, l; skipcomments(); @@ -1510,7 +1510,7 @@ static long transnum(long type) if (!(error || warning) && g_ScriptDebug > 1) { gl = (char *)translatelabeltype(labeltype[i]); - initprintf("%s:%ld: debug: accepted %s label `%s'.\n",compilefile,line_number,gl,label+(i<<6)); + initprintf("%s:%d: debug: accepted %s label `%s'.\n",compilefile,line_number,gl,label+(i<<6)); Bfree(gl); } *(scriptptr++) = labelcode[i]; @@ -1522,7 +1522,7 @@ static long transnum(long type) el = (char *)translatelabeltype(type); gl = (char *)translatelabeltype(labeltype[i]); ReportError(-1); - initprintf("%s:%ld: warning: expected a %s, found a %s.\n",compilefile,line_number,el,gl); + initprintf("%s:%d: warning: expected a %s, found a %s.\n",compilefile,line_number,el,gl); Bfree(el); Bfree(gl); return -1; // valid label name, but wrong type @@ -1543,7 +1543,7 @@ static long transnum(long type) // warning++; } if (!(error || warning) && g_ScriptDebug > 1) - initprintf("%s:%ld: debug: accepted constant %ld.\n",compilefile,line_number,atol(textptr)); + initprintf("%s:%d: debug: accepted constant %d.\n",compilefile,line_number,atol(textptr)); *scriptptr = atol(textptr); scriptptr++; @@ -1554,13 +1554,13 @@ static long transnum(long type) static int parsecommand(void); -static long CountCaseStatements() +static int CountCaseStatements() { - long lCount; + int lCount; char *temptextptr = textptr; int temp_line_number = line_number; - long scriptoffset = (unsigned)(scriptptr-script); - long caseoffset = (unsigned)(casescriptptr-script); + int scriptoffset = (unsigned)(scriptptr-script); + int caseoffset = (unsigned)(casescriptptr-script); int i; casecount=0; @@ -1577,22 +1577,22 @@ static long CountCaseStatements() checking_switch++; textptr=temptextptr; - scriptptr = (long *)(script+scriptoffset); + scriptptr = (int *)(script+scriptoffset); line_number = temp_line_number; lCount=casecount; casecount=0; - casescriptptr = (long *)(script+caseoffset); + casescriptptr = (int *)(script+caseoffset); casecount = 0; return lCount; } static int parsecommand(void) { - long i, j=0, k=0, done, tw; + int i, j=0, k=0, done, tw; char *temptextptr; - long *tempscrptr; + int *tempscrptr; if (quitevent) { @@ -1628,7 +1628,7 @@ static int parsecommand(void) { getlabel(); scriptptr--; - labelcode[labelcnt] = (long) scriptptr; + labelcode[labelcnt] = (int) scriptptr; labeltype[labelcnt] = LABEL_STATE; parsing_state = 1; @@ -1653,7 +1653,7 @@ static int parsecommand(void) if (labeltype[j] & LABEL_STATE) { if (!(error || warning) && g_ScriptDebug > 1) - initprintf("%s:%ld: debug: accepted state label `%s'.\n",compilefile,line_number,label+(j<<6)); + initprintf("%s:%d: debug: accepted state label `%s'.\n",compilefile,line_number,label+(j<<6)); *scriptptr = labelcode[j]; break; } @@ -1662,7 +1662,7 @@ static int parsecommand(void) char *gl; gl = (char *)translatelabeltype(labeltype[j]); ReportError(-1); - initprintf("%s:%ld: warning: expected a state, found a %s.\n",compilefile,line_number,gl); + initprintf("%s:%d: warning: expected a state, found a %s.\n",compilefile,line_number,gl); Bfree(gl); *(scriptptr-1) = CON_NULLOP; // get rid of the state, leaving a nullop to satisfy if conditions return 0; // valid label name, but wrong type @@ -1672,7 +1672,7 @@ static int parsecommand(void) if (j==labelcnt) { ReportError(-1); - initprintf("%s:%ld: error: state `%s' not found.\n",compilefile,line_number,label+(labelcnt<<6)); + initprintf("%s:%d: error: state `%s' not found.\n",compilefile,line_number,label+(labelcnt<<6)); error++; } scriptptr++; @@ -1682,7 +1682,7 @@ static int parsecommand(void) if (parsing_state == 0) { ReportError(-1); - initprintf("%s:%ld: error: found `ends' without open `state'.\n",compilefile,line_number); + initprintf("%s:%d: error: found `ends' without open `state'.\n",compilefile,line_number); error++; } // else @@ -1717,7 +1717,7 @@ static int parsecommand(void) case CON_GETTHISPROJECTILE: case CON_GETPROJECTILE: { - long lLabelID; + int lLabelID; // syntax getwall[].x // gets the value of wall[].xxx into @@ -1757,7 +1757,7 @@ static int parsecommand(void) //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); lLabelID=getlabeloffset(projectilelabels,label+(labelcnt<<6)); - //printf("LabelID is %ld\n",lLabelID); + //printf("LabelID is %d\n",lLabelID); if (lLabelID == -1) { error++; @@ -1822,7 +1822,7 @@ static int parsecommand(void) if (Bstrcmp(label+(labelcnt<<6),aGameVars[i].szLabel) == 0) { warning++; - initprintf(" * WARNING.(L%ld) duplicate Game definition `%s' ignored.\n",line_number,label+(labelcnt<<6)); + initprintf(" * WARNING.(L%d) duplicate Game definition `%s' ignored.\n",line_number,label+(labelcnt<<6)); break; } } @@ -1915,7 +1915,7 @@ static int parsecommand(void) { ReportError(-1); *(scriptptr-1) = 0; - initprintf("%s:%ld: warning: expected a move, found a constant.\n",compilefile,line_number); + initprintf("%s:%d: warning: expected a move, found a constant.\n",compilefile,line_number); } j = 0; @@ -1947,13 +1947,13 @@ static int parsecommand(void) if (Bstrcmp(label+(labelcnt<<6),label+(i<<6)) == 0 /* && (labeltype[i] & LABEL_MOVE) */) { warning++; - initprintf("%s:%ld: warning: duplicate move `%s' ignored.\n",compilefile,line_number,label+(labelcnt<<6)); + initprintf("%s:%d: warning: duplicate move `%s' ignored.\n",compilefile,line_number,label+(labelcnt<<6)); break; } if (i == labelcnt) { labeltype[labelcnt] = LABEL_MOVE; - labelcode[labelcnt++] = (long) scriptptr; + labelcode[labelcnt++] = (int) scriptptr; } for (j=0;j<2;j++) { @@ -2068,7 +2068,7 @@ static int parsecommand(void) if (fp < 0) { error++; - initprintf("%s:%ld: error: could not find file `%s'.\n",compilefile,line_number,tempbuf); + initprintf("%s:%d: error: could not find file `%s'.\n",compilefile,line_number,tempbuf); return 0; } @@ -2079,12 +2079,12 @@ static int parsecommand(void) { kclose(fp); error++; - initprintf("%s:%ld: error: could not allocate %ld bytes to include `%s'.\n", + initprintf("%s:%d: error: could not allocate %d bytes to include `%s'.\n", line_number,compilefile,j,tempbuf); return 0; } - initprintf("Including: %s (%ld bytes)\n",tempbuf, j); + initprintf("Including: %s (%d bytes)\n",tempbuf, j); kread(fp, mptr, j); kclose(fp); mptr[j] = 0; @@ -2139,14 +2139,14 @@ static int parsecommand(void) if (Bstrcmp(label+(labelcnt<<6),label+(i<<6)) == 0 /* && (labeltype[i] & LABEL_AI) */) { warning++; - initprintf("%s:%ld: warning: duplicate ai `%s' ignored.\n",compilefile,line_number,label+(labelcnt<<6)); + initprintf("%s:%d: warning: duplicate ai `%s' ignored.\n",compilefile,line_number,label+(labelcnt<<6)); break; } if (i == labelcnt) { labeltype[labelcnt] = LABEL_AI; - labelcode[labelcnt++] = (long) scriptptr; + labelcode[labelcnt++] = (int) scriptptr; } for (j=0;j<3;j++) @@ -2160,7 +2160,7 @@ static int parsecommand(void) { ReportError(-1); *(scriptptr-1) = 0; - initprintf("%s:%ld: warning: expected a move, found a constant.\n",compilefile,line_number); + initprintf("%s:%d: warning: expected a move, found a constant.\n",compilefile,line_number); } k = 0; while (keyword() == -1) @@ -2206,14 +2206,14 @@ static int parsecommand(void) if (Bstrcmp(label+(labelcnt<<6),label+(i<<6)) == 0 /* && (labeltype[i] & LABEL_ACTION) */) { warning++; - initprintf("%s:%ld: warning: duplicate action `%s' ignored.\n",compilefile,line_number,label+(labelcnt<<6)); + initprintf("%s:%d: warning: duplicate action `%s' ignored.\n",compilefile,line_number,label+(labelcnt<<6)); break; } if (i == labelcnt) { labeltype[labelcnt] = LABEL_ACTION; - labelcode[labelcnt] = (long) scriptptr; + labelcode[labelcnt] = (int) scriptptr; labelcnt++; } @@ -2290,7 +2290,7 @@ static int parsecommand(void) { ReportError(-1); *(scriptptr-1) = 0; - initprintf("%s:%ld: warning: expected a move, found a constant.\n",compilefile,line_number); + initprintf("%s:%d: warning: expected a move, found a constant.\n",compilefile,line_number); } break; } @@ -2330,7 +2330,7 @@ static int parsecommand(void) //AddLog(g_szBuf); if (j > MAXGAMEEVENTS-1 || j < 0) { - initprintf("%s:%ld: error: invalid event ID.\n",compilefile,line_number); + initprintf("%s:%d: error: invalid event ID.\n",compilefile,line_number); error++; return 0; } @@ -2341,7 +2341,7 @@ static int parsecommand(void) parsing_event = parsing_actor = 0; ReportError(-1); parsing_event = parsing_actor = tempscrptr; - initprintf("%s:%ld: warning: duplicate event `%s'.\n",compilefile,line_number,parsing_item_name); + initprintf("%s:%d: warning: duplicate event `%s'.\n",compilefile,line_number,parsing_item_name); } else apScriptGameEvent[j]=parsing_event; @@ -2403,7 +2403,7 @@ static int parsecommand(void) if (j > 2) { ReportError(-1); - initprintf("%s:%ld: warning: invalid useractor type.\n",compilefile,line_number); + initprintf("%s:%d: warning: invalid useractor type.\n",compilefile,line_number); j = 0; } @@ -2448,7 +2448,7 @@ static int parsecommand(void) { ReportError(-1); *(scriptptr-1) = 0; - initprintf("%s:%ld: warning: expected a move, found a constant.\n",compilefile,line_number); + initprintf("%s:%d: warning: expected a move, found a constant.\n",compilefile,line_number); } break; } @@ -2520,14 +2520,14 @@ static int parsecommand(void) { *(scriptptr-1) = 32768; ReportError(-1); - initprintf("%s:%ld: warning: tried to set cstat 32767, using 32768 instead.\n",compilefile,line_number); + initprintf("%s:%d: warning: tried to set cstat 32767, using 32768 instead.\n",compilefile,line_number); } else if ((*(scriptptr-1) & 32) && (*(scriptptr-1) & 16)) { i = *(scriptptr-1); *(scriptptr-1) ^= 48; ReportError(-1); - initprintf("%s:%ld: warning: tried to set cstat %ld, using %ld instead.\n",compilefile,line_number,i,*(scriptptr-1)); + initprintf("%s:%d: warning: tried to set cstat %d, using %d instead.\n",compilefile,line_number,i,*(scriptptr-1)); } } return 0; @@ -2552,21 +2552,21 @@ static int parsecommand(void) case CON_ELSE: if (checking_ifelse) { - long offset; + int offset; checking_ifelse--; tempscrptr = scriptptr; offset = (unsigned)(tempscrptr-script); scriptptr++; //Leave a spot for the fail location parsecommand(); - tempscrptr = (long *)script+offset; - *tempscrptr = (long) scriptptr; + tempscrptr = (int *)script+offset; + *tempscrptr = (int) scriptptr; } else { scriptptr--; error++; ReportError(-1); - initprintf("%s:%ld: error: found `else' with no `if'.\n",compilefile,line_number); + initprintf("%s:%d: error: found `else' with no `if'.\n",compilefile,line_number); } return 0; @@ -2575,7 +2575,7 @@ static int parsecommand(void) ReportError(WARNING_EVENTSYNC); case CON_GETSECTOR: { - long lLabelID; + int lLabelID; // syntax getsector[].x // gets the value of sector[].xxx into @@ -2706,7 +2706,7 @@ static int parsecommand(void) ReportError(WARNING_EVENTSYNC); case CON_GETWALL: { - long lLabelID; + int lLabelID; // syntax getwall[].x // gets the value of wall[].xxx into @@ -2769,7 +2769,7 @@ static int parsecommand(void) ReportError(WARNING_EVENTSYNC); case CON_GETPLAYER: { - long lLabelID; + int lLabelID; // syntax getwall[].x // gets the value of wall[].xxx into @@ -2808,7 +2808,7 @@ static int parsecommand(void) //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); lLabelID=getlabeloffset(playerlabels,label+(labelcnt<<6)); - //printf("LabelID is %ld\n",lLabelID); + //printf("LabelID is %d\n",lLabelID); if (lLabelID == -1) { error++; @@ -2846,7 +2846,7 @@ static int parsecommand(void) ReportError(WARNING_EVENTSYNC); case CON_GETINPUT: { - long lLabelID; + int lLabelID; // syntax getwall[].x // gets the value of wall[].xxx into @@ -2885,7 +2885,7 @@ static int parsecommand(void) //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); lLabelID=getlabeloffset(inputlabels,label+(labelcnt<<6)); - //printf("LabelID is %ld\n",lLabelID); + //printf("LabelID is %d\n",lLabelID); if (lLabelID == -1) { error++; @@ -2908,7 +2908,7 @@ static int parsecommand(void) case CON_SETUSERDEF: case CON_GETUSERDEF: { - long lLabelID; + int lLabelID; // syntax [gs]etuserdef.x // gets the value of ud.xxx into @@ -3033,7 +3033,7 @@ static int parsecommand(void) { error++; ReportError(-1); - initprintf("%s:%ld: error: variable `%s' is not per-actor.\n",compilefile,line_number,label+(labelcnt<<6)); + initprintf("%s:%d: error: variable `%s' is not per-actor.\n",compilefile,line_number,label+(labelcnt<<6)); return 0; } @@ -3045,7 +3045,7 @@ static int parsecommand(void) { error++; ReportError(-1); - initprintf("%s:%ld: error: variable `%s' is not per-player.\n",compilefile,line_number,label+(labelcnt<<6)); + initprintf("%s:%d: error: variable `%s' is not per-player.\n",compilefile,line_number,label+(labelcnt<<6)); return 0; } @@ -3073,7 +3073,7 @@ static int parsecommand(void) ReportError(WARNING_EVENTSYNC); case CON_GETACTOR: { - long lLabelID; + int lLabelID; // syntax getwall[].x // gets the value of wall[].xxx into @@ -3112,7 +3112,7 @@ static int parsecommand(void) //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); lLabelID=getlabeloffset(actorlabels,label+(labelcnt<<6)); - //printf("LabelID is %ld\n",lLabelID); + //printf("LabelID is %d\n",lLabelID); if (lLabelID == -1) { error++; @@ -3188,7 +3188,7 @@ static int parsecommand(void) if (*scriptptr > BYTEVERSION_JF) { warning++; - initprintf("%s:%ld: warning: need build %ld, found build %ld\n",compilefile,line_number,k,BYTEVERSION_JF); + initprintf("%s:%d: warning: need build %d, found build %d\n",compilefile,line_number,k,BYTEVERSION_JF); } break; } @@ -3222,7 +3222,7 @@ static int parsecommand(void) // syntax: [rand|add|set]var // sets var1 to const1 // adds const1 to var1 (const1 can be negative...) - //printf("Found [add|set]var at line= %ld\n",line_number); + //printf("Found [add|set]var at line= %d\n",line_number); // get the ID of the DEF if (tw != CON_ZSHOOT && tw != CON_EZSHOOT) @@ -3315,7 +3315,7 @@ static int parsecommand(void) case CON_DEFINEPROJECTILE: { int y; - signed long z; + signed int z; if (parsing_state || parsing_actor) { @@ -3437,7 +3437,7 @@ static int parsecommand(void) case CON_IFVARVARAND: case CON_WHILEVARVARN: { - long offset; + int offset; transmultvars(2); tempscrptr = scriptptr; @@ -3447,8 +3447,8 @@ static int parsecommand(void) j = keyword(); parsecommand(); - tempscrptr = (long *)script+offset; - *tempscrptr = (long) scriptptr; + tempscrptr = (int *)script+offset; + *tempscrptr = (int) scriptptr; if (tw != CON_WHILEVARVARN) checking_ifelse++; return 0; @@ -3475,7 +3475,7 @@ static int parsecommand(void) case CON_IFVARAND: case CON_WHILEVARN: { - long offset; + int offset; // get the ID of the DEF transvar(); @@ -3488,8 +3488,8 @@ static int parsecommand(void) j = keyword(); parsecommand(); - tempscrptr = (long *)script+offset; - *tempscrptr = (long) scriptptr; + tempscrptr = (int *)script+offset; + *tempscrptr = (int) scriptptr; if (tw != CON_WHILEVARN) checking_ifelse++; return 0; @@ -3514,7 +3514,7 @@ static int parsecommand(void) } // syntax: - // long x, long y, long z, short a, short tilenum, signed char shade, char orientation, x1, y1, x2, y2 + // int x, int y, int z, short a, short tilenum, signed char shade, char orientation, x1, y1, x2, y2 // myospal adds char pal // get the ID of the DEFs @@ -3613,7 +3613,7 @@ static int parsecommand(void) } // syntax: - // long x, long y, short tilenum, signed char shade, char orientation + // int x, int y, short tilenum, signed char shade, char orientation // myospal adds char pal transmultvars(5); @@ -3639,7 +3639,7 @@ static int parsecommand(void) case CON_SWITCH: { - long tempoffset; + int tempoffset; //AddLog("Got Switch statement"); if (checking_switch) @@ -3667,7 +3667,7 @@ static int parsecommand(void) j=CountCaseStatements(); // initprintf("Done Counting Case Statements for switch %d: found %d.\n", checking_switch,j); - tempscrptr = (long *)(script+tempoffset); + tempscrptr = (int *)(script+tempoffset); //AddLog(g_szBuf); if (checking_switch>1) @@ -3681,7 +3681,7 @@ static int parsecommand(void) } if (tempscrptr) { - tempscrptr[1]=(long)j; // save count of cases + tempscrptr[1]=(int)j; // save count of cases } else { @@ -3717,7 +3717,7 @@ static int parsecommand(void) casecount=0; if (tempscrptr) { - tempscrptr[0]= (long)scriptptr - (long)&script[0]; // save 'end' location + tempscrptr[0]= (int)scriptptr - (int)&script[0]; // save 'end' location } else { @@ -3739,7 +3739,7 @@ static int parsecommand(void) case CON_CASE: { - long tempoffset; + int tempoffset; //AddLog("Found Case"); repeatcase: scriptptr--; // don't save in code @@ -3747,7 +3747,7 @@ repeatcase: { error++; ReportError(-1); - initprintf("%s:%ld: error: found `case' statement when not in switch\n",compilefile,line_number); + initprintf("%s:%d: error: found `case' statement when not in switch\n",compilefile,line_number); return 1; } casecount++; @@ -3760,13 +3760,13 @@ repeatcase: //AddLog(g_szBuf); j=*(--scriptptr); // get value - //Bsprintf(g_szBuf,"case: Value of case %ld is %ld",(long)casecount,(long)j); + //Bsprintf(g_szBuf,"case: Value of case %d is %d",(int)casecount,(int)j); //AddLog(g_szBuf); if (casescriptptr) { //AddLog("Adding value to script"); casescriptptr[casecount++]=j; // save value - casescriptptr[casecount]=(long)((long*)scriptptr-&script[0]); // save offset + casescriptptr[casecount]=(int)((int*)scriptptr-&script[0]); // save offset } // j = keyword(); //Bsprintf(g_szBuf,"case3: %.12s",textptr); @@ -3791,11 +3791,11 @@ repeatcase: { //AddLog("Found Repeat Case"); transword(); // eat 'case' - tempscrptr = (long *)(script+tempoffset); + tempscrptr = (int *)(script+tempoffset); goto repeatcase; } } - tempscrptr = (long *)(script+tempoffset); + tempscrptr = (int *)(script+tempoffset); //AddLog("End Case"); return 0; // break; @@ -3806,7 +3806,7 @@ repeatcase: { error++; ReportError(-1); - initprintf("%s:%ld: error: found `default' statement when not in switch\n",compilefile,line_number); + initprintf("%s:%d: error: found `default' statement when not in switch\n",compilefile,line_number); return 1; } if (casescriptptr && casescriptptr[0]!=0) @@ -3814,11 +3814,11 @@ repeatcase: // duplicate default statement error++; ReportError(-1); - initprintf("%s:%ld: error: multiple `default' statements found in switch\n",compilefile,line_number); + initprintf("%s:%d: error: multiple `default' statements found in switch\n",compilefile,line_number); } if (casescriptptr) { - casescriptptr[0]=(long)(scriptptr-&script[0]); // save offset + casescriptptr[0]=(int)(scriptptr-&script[0]); // save offset } //Bsprintf(g_szBuf,"default: '%.22s'",textptr); //AddLog(g_szBuf); @@ -3837,7 +3837,7 @@ repeatcase: { error++; ReportError(-1); - initprintf("%s:%ld: error: found `endswitch' without matching `switch'\n",compilefile,line_number); + initprintf("%s:%d: error: found `endswitch' without matching `switch'\n",compilefile,line_number); } return 1; // end of block break; @@ -3919,7 +3919,7 @@ repeatcase: { ReportError(-1); *(scriptptr-1) = 0; - initprintf("%s:%ld: warning: expected a move, found a constant.\n",compilefile,line_number); + initprintf("%s:%d: warning: expected a move, found a constant.\n",compilefile,line_number); } break; case CON_IFPINVENTORY: @@ -3952,7 +3952,7 @@ repeatcase: case CON_IFCANSEETARGET: case CON_IFNOSOUNDS: { - long offset; + int offset; if (tw == CON_IFP) { j = 0; @@ -3974,8 +3974,8 @@ repeatcase: j = keyword(); parsecommand(); - tempscrptr = (long *)script+offset; - *tempscrptr = (long) scriptptr; + tempscrptr = (int *)script+offset; + *tempscrptr = (int) scriptptr; checking_ifelse++; return 0; @@ -4002,7 +4002,7 @@ repeatcase: } ReportError(-1); - initprintf("%s:%ld: error: found more `}' than `{'.\n",compilefile,line_number); + initprintf("%s:%d: error: found more `}' than `{'.\n",compilefile,line_number); error++; } return 1; @@ -4023,7 +4023,7 @@ repeatcase: if (j < 0 || j > MAXVOLUMES-1) { - initprintf("%s:%ld: error: volume number exceeds maximum volume count.\n",compilefile,line_number); + initprintf("%s:%d: error: volume number exceeds maximum volume count.\n",compilefile,line_number); error++; while (*textptr != 0x0a && *textptr != 0) textptr++; break; @@ -4037,7 +4037,7 @@ repeatcase: textptr++,i++; if (i >= (signed)sizeof(volume_names[j])-1) { - initprintf("%s:%ld: error: volume name exceeds limit of %ld characters.\n",compilefile,line_number,sizeof(volume_names[j])-1); + initprintf("%s:%d: error: volume name exceeds limit of %d characters.\n",compilefile,line_number,sizeof(volume_names[j])-1); error++; while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; break; @@ -4056,7 +4056,7 @@ repeatcase: if (j < 0 || j > NUMGAMEFUNCTIONS-1) { - initprintf("%s:%ld: error: function number exceeds number of game functions.\n",compilefile,line_number); + initprintf("%s:%d: error: function number exceeds number of game functions.\n",compilefile,line_number); error++; while (*textptr != 0x0a && *textptr != 0) textptr++; break; @@ -4071,7 +4071,7 @@ repeatcase: textptr++,i++; if (i >= MAXGAMEFUNCLEN-1) { - initprintf("%s:%ld: error: function name exceeds limit of %ld characters.\n",compilefile,line_number,MAXGAMEFUNCLEN); + initprintf("%s:%d: error: function name exceeds limit of %d characters.\n",compilefile,line_number,MAXGAMEFUNCLEN); error++; while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; break; @@ -4090,7 +4090,7 @@ repeatcase: if (j < 0 || j > 4) { - initprintf("%s:%ld: error: skill number exceeds maximum skill count.\n",compilefile,line_number); + initprintf("%s:%d: error: skill number exceeds maximum skill count.\n",compilefile,line_number); error++; while (*textptr != 0x0a && *textptr != 0) textptr++; break; @@ -4104,7 +4104,7 @@ repeatcase: textptr++,i++; if (i >= (signed)sizeof(skill_names[j])-1) { - initprintf("%s:%ld: error: skill name exceeds limit of %ld characters.\n",compilefile,line_number,sizeof(skill_names[j])-1); + initprintf("%s:%d: error: skill name exceeds limit of %d characters.\n",compilefile,line_number,sizeof(skill_names[j])-1); error++; while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; break; @@ -4127,7 +4127,7 @@ repeatcase: if (j < 0 || j > MAXGAMETYPES-1) { - initprintf("%s:%ld: error: gametype number exceeds maximum gametype count.\n",compilefile,line_number); + initprintf("%s:%d: error: gametype number exceeds maximum gametype count.\n",compilefile,line_number); error++; while (*textptr != 0x0a && *textptr != 0) textptr++; break; @@ -4142,7 +4142,7 @@ repeatcase: textptr++,i++; if (i >= (signed)sizeof(gametype_names[j])-1) { - initprintf("%s:%ld: error: gametype name exceeds limit of %ld characters.\n",compilefile,line_number,sizeof(gametype_names[j])-1); + initprintf("%s:%d: error: gametype name exceeds limit of %d characters.\n",compilefile,line_number,sizeof(gametype_names[j])-1); error++; while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; break; @@ -4163,14 +4163,14 @@ repeatcase: if (j < 0 || j > MAXVOLUMES-1) { - initprintf("%s:%ld: error: volume number exceeds maximum volume count.\n",compilefile,line_number); + initprintf("%s:%d: error: volume number exceeds maximum volume count.\n",compilefile,line_number); error++; while (*textptr != 0x0a && *textptr != 0) textptr++; break; } if (k < 0 || k > MAXLEVELS-1) { - initprintf("%s:%ld: error: level number exceeds maximum number of levels per episode.\n",compilefile,line_number); + initprintf("%s:%d: error: level number exceeds maximum number of levels per episode.\n",compilefile,line_number); error++; while (*textptr != 0x0a && *textptr != 0) textptr++; break; @@ -4186,7 +4186,7 @@ repeatcase: textptr++,i++; if (i >= BMAX_PATH) { - initprintf("%s:%ld: error: level file name exceeds limit of %d characters.\n",compilefile,line_number,BMAX_PATH); + initprintf("%s:%d: error: level file name exceeds limit of %d characters.\n",compilefile,line_number,BMAX_PATH); error++; while (*textptr != ' ' && *textptr != '\t') textptr++; break; @@ -4201,7 +4201,7 @@ repeatcase: else if ((Bstrlen(tempbuf)+1) > sizeof(map[j*MAXLEVELS+k].filename)) map[j*MAXLEVELS+k].filename = Brealloc(map[j*MAXLEVELS+k].filename,(Bstrlen(tempbuf)+1)); - /* initprintf("level file name string len: %ld\n",Bstrlen(tempbuf)); */ + /* initprintf("level file name string len: %d\n",Bstrlen(tempbuf)); */ Bstrcpy(map[j*MAXLEVELS+k].filename,tempbuf); @@ -4229,7 +4229,7 @@ repeatcase: textptr++,i++; if (i >= 32) { - initprintf("%s:%ld: error: level name exceeds limit of %ld characters.\n",compilefile,line_number,32); + initprintf("%s:%d: error: level name exceeds limit of %d characters.\n",compilefile,line_number,32); error++; while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; break; @@ -4243,7 +4243,7 @@ repeatcase: else if ((Bstrlen(tempbuf)+1) > sizeof(map[j*MAXLEVELS+k].name)) map[j*MAXLEVELS+k].name = Brealloc(map[j*MAXLEVELS+k].name,(Bstrlen(tempbuf)+1)); - /* initprintf("level name string len: %ld\n",Bstrlen(tempbuf)); */ + /* initprintf("level name string len: %d\n",Bstrlen(tempbuf)); */ Bstrcpy(map[j*MAXLEVELS+k].name,tempbuf); @@ -4260,7 +4260,7 @@ repeatcase: if (k >= MAXQUOTES) { - initprintf("%s:%ld: error: quote number exceeds limit of %ld.\n",compilefile,line_number,MAXQUOTES); + initprintf("%s:%d: error: quote number exceeds limit of %d.\n",compilefile,line_number,MAXQUOTES); error++; } @@ -4297,7 +4297,7 @@ repeatcase: { if (*textptr == '%' && *(textptr+1) == 's') { - initprintf("%s:%ld: error: quote text contains string identifier.\n",compilefile,line_number); + initprintf("%s:%d: error: quote text contains string identifier.\n",compilefile,line_number); error++; while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; break; @@ -4309,7 +4309,7 @@ repeatcase: textptr++,i++; if (i >= MAXQUOTELEN-1) { - initprintf("%s:%ld: error: quote text exceeds limit of %ld characters.\n",compilefile,line_number,MAXQUOTELEN-1); + initprintf("%s:%d: error: quote text exceeds limit of %d characters.\n",compilefile,line_number,MAXQUOTELEN-1); error++; while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; break; @@ -4340,7 +4340,7 @@ repeatcase: if (k > 25) { - initprintf("%s:%ld: error: cheat redefinition attempts to redefine nonexistant cheat.\n",compilefile,line_number); + initprintf("%s:%d: error: cheat redefinition attempts to redefine nonexistant cheat.\n",compilefile,line_number); error++; while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; break; @@ -4355,7 +4355,7 @@ repeatcase: textptr++,i++; if (i >= (signed)sizeof(cheatquotes[k])-1) { - initprintf("%s:%ld: error: cheat exceeds limit of %ld characters.\n",compilefile,line_number,MAXCHEATLEN,sizeof(cheatquotes[k])-1); + initprintf("%s:%d: error: cheat exceeds limit of %d characters.\n",compilefile,line_number,MAXCHEATLEN,sizeof(cheatquotes[k])-1); error++; while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0 && *textptr != ' ') textptr++; break; @@ -4391,7 +4391,7 @@ repeatcase: textptr++,i++; if (i >= BMAX_PATH) { - initprintf("%s:%ld: error: sound filename exceeds limit of %d characters.\n",compilefile,line_number,BMAX_PATH); + initprintf("%s:%d: error: sound filename exceeds limit of %d characters.\n",compilefile,line_number,BMAX_PATH); error++; skipcomments(); break; @@ -4421,7 +4421,7 @@ repeatcase: if (parsing_event == 0) { ReportError(-1); - initprintf("%s:%ld: error: found `endevent' without open `onevent'.\n",compilefile,line_number); + initprintf("%s:%d: error: found `endevent' without open `onevent'.\n",compilefile,line_number); error++; } if (num_braces > 0) @@ -4444,7 +4444,7 @@ repeatcase: if (parsing_actor == 0) { ReportError(-1); - initprintf("%s:%ld: error: found `enda' without open `actor'.\n",compilefile,line_number); + initprintf("%s:%d: error: found `enda' without open `actor'.\n",compilefile,line_number); error++; } if (num_braces > 0) @@ -4464,7 +4464,7 @@ repeatcase: case CON_BREAK: if (checking_switch) { - //Bsprintf(g_szBuf," * (L%ld) case Break statement.\n",line_number); + //Bsprintf(g_szBuf," * (L%d) case Break statement.\n",line_number); //AddLog(g_szBuf); return 1; } @@ -4492,7 +4492,7 @@ repeatcase: return 0; case CON_GAMESTARTUP: { - long params[30]; + int params[30]; scriptptr--; for (j = 0; j < 30; j++) @@ -4623,7 +4623,7 @@ static const char *defaultcons[NUM_DEFAULT_CONS] = void copydefaultcons(void) { - long i, fs, fpi; + int i, fs, fpi; FILE *fpo; for (i=0;i= MAXWALLS) @@ -2190,7 +2190,7 @@ static void DoWall(int iSet, int lVar1, int lLabelID, int lVar2) static void DoSector(int iSet, int lVar1, int lLabelID, int lVar2) { - long lValue; + int lValue; int iSector=sprite[g_i].sectnum; if (lVar1 != g_iThisActorID) @@ -2376,8 +2376,8 @@ static void DoSector(int iSet, int lVar1, int lLabelID, int lVar2) static void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) { - long lValue; - long lTemp; + int lValue; + int lTemp; int iActor=g_i; if (lVar1 != g_iThisActorID) @@ -2740,7 +2740,7 @@ static void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) static void DoProjectile(int iSet, int lVar1, int lLabelID, int lVar2) { - long lValue; + int lValue; if (lVar1 < 0 || lVar1 >= MAXTILES) { @@ -2958,7 +2958,7 @@ static void DoProjectile(int iSet, int lVar1, int lLabelID, int lVar2) static int parse(void); -void OnEvent(int iEventID, int iActor, int iPlayer, long lDist) +void OnEvent(int iEventID, int iActor, int iPlayer, int lDist) { if (iEventID >= MAXGAMEEVENTS) { @@ -2975,7 +2975,7 @@ void OnEvent(int iEventID, int iActor, int iPlayer, long lDist) { int og_i=g_i, og_p=g_p, okillit_flag=killit_flag; - long og_x=g_x, *og_t=g_t, *oinsptr=insptr; + int og_x=g_x, *og_t=g_t, *oinsptr=insptr; spritetype *og_sp=g_sp; g_i = iActor; // current sprite ID @@ -3063,10 +3063,10 @@ static void forceplayerangle(player_struct *p) static char dodge(spritetype *s) { - long bx,by,bxvect,byvect,d,i; - long mx = s->x, my = s->y; - long mxvect = sintable[(s->ang+512)&2047]; - long myvect = sintable[s->ang&2047]; + int bx,by,bxvect,byvect,d,i; + int mx = s->x, my = s->y; + int mxvect = sintable[(s->ang+512)&2047]; + int myvect = sintable[s->ang&2047]; for (i=headspritestat[4];i>=0;i=nextspritestat[i]) //weapons list { @@ -3095,9 +3095,9 @@ static char dodge(spritetype *s) int furthestangle(int iActor,int angs) { short hitsect,hitwall,hitspr,furthest_angle=0; - long hx, hy, hz, d; + int hx, hy, hz, d; spritetype *s = &sprite[iActor]; - long greatestd = -(1<<30); + int greatestd = -(1<<30); int angincs = 2048/angs,j; if (s->picnum != APLAYER) @@ -3121,10 +3121,10 @@ int furthestangle(int iActor,int angs) return (furthest_angle&2047); } -int furthestcanseepoint(int iActor,spritetype *ts,long *dax,long *day) +int furthestcanseepoint(int iActor,spritetype *ts,int *dax,int *day) { short hitsect,hitwall,hitspr, angincs; - long hx, hy, hz, d, da;//, d, cd, ca,tempx,tempy,cx,cy; + int hx, hy, hz, d, da;//, d, cd, ca,tempx,tempy,cx,cy; int j; spritetype *s = &sprite[iActor]; @@ -3161,7 +3161,7 @@ void getglobalz(int iActor) if (s->statnum == 10 || s->statnum == 6 || s->statnum == 2 || s->statnum == 1 || s->statnum == 4) { - long hz,lz,zr = 127L; + int hz,lz,zr = 127L; if (s->statnum == 4) zr = 4L; @@ -3204,7 +3204,7 @@ void getglobalz(int iActor) void makeitfall(int iActor) { spritetype *s = &sprite[iActor]; - long hz,lz,c = gc; + int hz,lz,c = gc; if (floorspace(s->sectnum)) c = 0; @@ -3261,7 +3261,7 @@ int getincangle(int a,int na) static void alterang(int a) { int aang = g_sp->ang, angdif, goalang; - long ticselapsed = (g_t[0])&31, *moveptr = (long *)g_t[1]; + int ticselapsed = (g_t[0])&31, *moveptr = (int *)g_t[1]; int j = g_player[g_p].ps->holoduke_on; g_sp->xvel += (*moveptr-g_sp->xvel)/5; @@ -3323,9 +3323,9 @@ static void alterang(int a) static void move(void) { - long l, *moveptr; + int l, *moveptr; int a = g_sp->hitag, goalang, angdif; - long daxvel; + int daxvel; if (a == -1) a = 0; @@ -3364,8 +3364,8 @@ static void move(void) if (a&face_player_smart) { - long newx = g_player[g_p].ps->posx+(g_player[g_p].ps->posxv/768); - long newy = g_player[g_p].ps->posy+(g_player[g_p].ps->posyv/768); + int newx = g_player[g_p].ps->posx+(g_player[g_p].ps->posxv/768); + int newy = g_player[g_p].ps->posy+(g_player[g_p].ps->posyv/768); goalang = getangle(newx-g_sp->x,newy-g_sp->y); angdif = getincangle(g_sp->ang,goalang)>>2; @@ -3385,7 +3385,7 @@ static void move(void) return; } - moveptr = (long *)g_t[1]; + moveptr = (int *)g_t[1]; if (a&geth) g_sp->xvel += (*moveptr-g_sp->xvel)>>1; if (a&getv) g_sp->zvel += ((*(moveptr+1)<<4)-g_sp->zvel)>>1; @@ -3513,7 +3513,7 @@ static void move(void) } } -static void parseifelse(long condition) +static void parseifelse(int condition) { if (condition) { @@ -3523,7 +3523,7 @@ static void parseifelse(long condition) } else { - insptr = (long *) *(insptr+1); + insptr = (int *) *(insptr+1); if (*insptr == 10) { // else... @@ -3534,11 +3534,11 @@ static void parseifelse(long condition) } } -// long *it = 0x00589a04; +// int *it = 0x00589a04; static int parse(void) { - long j, l, s, tw; + int j, l, s, tw; if (killit_flag) return 1; @@ -3726,9 +3726,9 @@ static int parse(void) case CON_AI: insptr++; g_t[5] = *insptr++; // Ai - g_t[4] = *(long *)(g_t[5]); // Action - g_t[1] = *(long *)(g_t[5]+4); // move - g_sp->hitag = *(long *)(g_t[5]+8); // move flags + g_t[4] = *(int *)(g_t[5]); // Action + g_t[1] = *(int *)(g_t[5]+4); // move + g_sp->hitag = *(int *)(g_t[5]+8); // move flags g_t[0] = g_t[2] = g_t[3] = 0; // count, actioncount... g_t[3] = ??? if (g_sp->hitag&random_angle) g_sp->ang = TRAND&2047; @@ -3756,7 +3756,7 @@ static int parse(void) break; case CON_ELSE: - insptr = (long *) *(insptr+1); + insptr = (int *) *(insptr+1); break; case CON_ADDSTRENGTH: @@ -4059,7 +4059,7 @@ static int parse(void) case CON_DEBUG: insptr++; - initprintf("%ld\n",*insptr++); + initprintf("%d\n",*insptr++); break; case CON_ENDOFGAME: @@ -4137,9 +4137,9 @@ static int parse(void) case CON_STATE: { - long *tempscrptr=insptr+2; + int *tempscrptr=insptr+2; - insptr = (long *) *(insptr+1); + insptr = (int *) *(insptr+1); while (1) if (parse()) break; insptr = tempscrptr; } @@ -4385,17 +4385,17 @@ static int parse(void) break; } - case CON_GETKEYNAME: - insptr++; - { - int i = GetGameVarID(*insptr++, g_i, g_p), f=GetGameVarID(*insptr++, g_i, g_p); - - j=GetGameVarID(*insptr++, g_i, g_p); - - if (fta_quotes[i] != NULL && f < NUMGAMEFUNCTIONS && j < 2) - Bstrcpy(fta_quotes[i], KB_ScanCodeToString(ud.config.KeyboardKeys[f][j])); - - break; + case CON_GETKEYNAME: + insptr++; + { + int i = GetGameVarID(*insptr++, g_i, g_p), f=GetGameVarID(*insptr++, g_i, g_p); + + j=GetGameVarID(*insptr++, g_i, g_p); + + if (fta_quotes[i] != NULL && f < NUMGAMEFUNCTIONS && j < 2) + Bstrcpy(fta_quotes[i], KB_ScanCodeToString(ud.config.KeyboardKeys[f][j])); + + break; } case CON_MYOSX: @@ -4441,29 +4441,29 @@ static int parse(void) // script offset to default case (null if none) // For each case: value, ptr to code //AddLog("Processing Switch..."); - long lValue=GetGameVarID(*insptr++, g_i, g_p), lEnd=*insptr++, lCases=*insptr++; - long *lpDefault=insptr++, *lpCases=insptr, bMatched=0, *lTempInsPtr, lCheckCase; + int lValue=GetGameVarID(*insptr++, g_i, g_p), lEnd=*insptr++, lCases=*insptr++; + int *lpDefault=insptr++, *lpCases=insptr, bMatched=0, *lTempInsPtr, lCheckCase; insptr+=lCases*2; lTempInsPtr=insptr; - //Bsprintf(g_szBuf,"lEnd= %ld *lpDefault=%ld",lEnd,*lpDefault); + //Bsprintf(g_szBuf,"lEnd= %d *lpDefault=%d",lEnd,*lpDefault); //AddLog(g_szBuf); - //Bsprintf(g_szBuf,"Checking %ld cases for %ld",lCases, lValue); + //Bsprintf(g_szBuf,"Checking %d cases for %d",lCases, lValue); //AddLog(g_szBuf); for (lCheckCase=0; lCheckCase x2) swaplong(&x1,&x2); if (y1 > y2) swaplong(&y1,&y2); @@ -4775,7 +4776,7 @@ static int parse(void) if ((gotpic[MIRROR>>3]&(1<<(MIRROR&7))) > 0) { - long j, i = 0, k, dst = 0x7fffffff; + int j, i = 0, k, dst = 0x7fffffff; for (k=0;k= iGameVarCount) || lVarID < 0) { @@ -5531,11 +5532,11 @@ static int parse(void) { // invalid varID insptr++; - OSD_Printf("CONLOGVAR: L=%ld INVALID VARIABLE\n",l); + OSD_Printf("CONLOGVAR: L=%d INVALID VARIABLE\n",l); break; // out of switch } } - Bsprintf(szBuf,"CONLOGVAR: L=%ld %s ",l, aGameVars[lVarID].szLabel); + Bsprintf(szBuf,"CONLOGVAR: L=%d %s ",l, aGameVars[lVarID].szLabel); strcpy(g_szBuf,szBuf); if (aGameVars[lVarID].dwFlags & GAMEVAR_FLAG_READONLY) @@ -5556,7 +5557,7 @@ static int parse(void) Bsprintf(szBuf," (Global)"); } Bstrcat(g_szBuf,szBuf); - Bsprintf(szBuf," =%ld\n", GetGameVarID(lVarID, g_i, g_p)*m); + Bsprintf(szBuf," =%d\n", GetGameVarID(lVarID, g_i, g_p)*m); Bstrcat(g_szBuf,szBuf); OSD_Printf(g_szBuf); insptr++; @@ -5755,7 +5756,7 @@ static int parse(void) // that is of into // -1 for none found // - long var1 = *insptr++, d; + int var1 = *insptr++, d; if (tw == CON_FINDPLAYER) j=findplayer(&sprite[g_i],&d); else if (tw == CON_FINDOTHERPLAYER) j=findotherplayer(g_i,&d); @@ -6214,7 +6215,7 @@ static int parse(void) case CON_WHILEVARN: { int i; - long *savedinsptr=insptr; + int *savedinsptr=insptr; j=1; while (j) { @@ -6233,7 +6234,7 @@ static int parse(void) case CON_WHILEVARVARN: { int i,k; - long *savedinsptr=insptr; + int *savedinsptr=insptr; j=1; while (j) { @@ -6456,24 +6457,24 @@ static int parse(void) case CON_GETCURRADDRESS: insptr++; j=*insptr++; - SetGameVarID(j, (long)insptr, g_i, g_p); + SetGameVarID(j, (int)insptr, g_i, g_p); break; case CON_JUMP: insptr++; j = GetGameVarID(*insptr++, g_i, g_p); - insptr = (long *)j; + insptr = (int *)j; break; default: - OSD_Printf("fatal error: default processing: prev inst: %ld, curr inst: %ld, next inst: %ld\ncurrent actor: %d (%d)\n",*(insptr-1),*insptr,*(insptr+1),g_i,g_sp->picnum); + OSD_Printf("fatal error: default processing: prev inst: %d, curr inst: %d, next inst: %d\ncurrent actor: %d (%d)\n",*(insptr-1),*insptr,*(insptr+1),g_i,g_sp->picnum); gameexit("An error has occurred in the EDuke32 CON executor.\n\nPlease mail all of your CON files along with the file eduke32.log\nto terminx@gmail.com.\n\nThank you."); break; } return 0; } -void LoadActor(long iActor) +void LoadActor(int iActor) { g_i = iActor; // Sprite ID g_p = -1; // iPlayer; // Player ID @@ -6509,7 +6510,7 @@ void LoadActor(long iActor) } } -void execute(int iActor,int iPlayer,long lDist) +void execute(int iActor,int iPlayer,int lDist) { short temp, temp2; @@ -6537,14 +6538,14 @@ void execute(int iActor,int iPlayer,long lDist) { g_sp->lotag += TICSPERFRAME; - if (g_sp->lotag > *(long *)(g_t[4]+16)) + if (g_sp->lotag > *(int *)(g_t[4]+16)) { g_t[2]++; g_sp->lotag = 0; - g_t[3] += *(long *)(g_t[4]+12); + g_t[3] += *(int *)(g_t[4]+12); } - if (klabs(g_t[3]) >= klabs(*(long *)(g_t[4]+4) * *(long *)(g_t[4]+12))) + if (klabs(g_t[3]) >= klabs(*(int *)(g_t[4]+4) * *(int *)(g_t[4]+12))) g_t[3] = 0; } diff --git a/polymer/eduke32/source/gamevars.c b/polymer/eduke32/source/gamevars.c index 57d39795d..98dfffac1 100755 --- a/polymer/eduke32/source/gamevars.c +++ b/polymer/eduke32/source/gamevars.c @@ -39,7 +39,7 @@ static void FreeGameVars(void) { // aGameVars[i].lValue=0; // if (aGameVars[i].szLabel) - //Bfree(aGameVars[i].szLabel); + //Bfree(aGameVars[i].szLabel); // aGameVars[i].szLabel=NULL; // aGameVars[i].dwFlags=0; @@ -76,10 +76,10 @@ static void ClearGameVars(void) return; } -int ReadGameVars(long fil) +int ReadGameVars(int fil) { int i; - long l; + int l; // AddLog("Reading gamevars from savegame"); @@ -99,9 +99,9 @@ int ReadGameVars(long fil) for (i=0;i= 0 && iPlayer < MAXPLAYERS) { - //Bsprintf(g_szBuf,"GetGameVarID(%d, %d, %d) returns %ld\n",id,iActor,iPlayer, aGameVars[id].plValues[iPlayer]); + //Bsprintf(g_szBuf,"GetGameVarID(%d, %d, %d) returns %d\n",id,iActor,iPlayer, aGameVars[id].plValues[iPlayer]); //AddLog(g_szBuf); if (inv) return(-aGameVars[id].plValues[iPlayer]); return (aGameVars[id].plValues[iPlayer]); @@ -472,8 +472,8 @@ long GetGameVarID(int id, int iActor, int iPlayer) if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PLONG) { - if (inv) return(-(*((long*)aGameVars[id].lValue))); - return(*((long*)aGameVars[id].lValue)); + if (inv) return(-(*((int*)aGameVars[id].lValue))); + return(*((int*)aGameVars[id].lValue)); } if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PSHORT) @@ -492,14 +492,14 @@ long GetGameVarID(int id, int iActor, int iPlayer) return (aGameVars[id].lValue); } -void SetGameVarID(int id, long lValue, int iActor, int iPlayer) +void SetGameVarID(int id, int lValue, int iActor, int iPlayer) { if (id<0 || id >= iGameVarCount) { OSD_Printf("SetGameVarID(): tried to set invalid gamevar ID (%d) from sprite %d (%d), player %d\n",id,g_i,sprite[g_i].picnum,g_p); return; } - //Bsprintf(g_szBuf,"SGVI: %d ('%s') to %ld for %d %d",id,aGameVars[id].szLabel,lValue,iActor,iPlayer); + //Bsprintf(g_szBuf,"SGVI: %d ('%s') to %d for %d %d",id,aGameVars[id].szLabel,lValue,iActor,iPlayer); //AddLog(g_szBuf); if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PERPLAYER) { @@ -528,7 +528,7 @@ void SetGameVarID(int id, long lValue, int iActor, int iPlayer) if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PLONG) { // set the value at pointer - *((long*)aGameVars[id].lValue)=lValue; + *((int*)aGameVars[id].lValue)=lValue; return; } @@ -550,7 +550,7 @@ void SetGameVarID(int id, long lValue, int iActor, int iPlayer) aGameVars[id].lValue=lValue; } -long GetGameVar(const char *szGameLabel, long lDefault, int iActor, int iPlayer) +int GetGameVar(const char *szGameLabel, int lDefault, int iActor, int iPlayer) { int i=0; for (;iname); - crc32init((unsigned long *)&crcval); + crc32init((unsigned int *)&crcval); do { b = read(fh, buf, sizeof(buf)); - if (b > 0) crc32block((unsigned long *)&crcval, (unsigned char *)buf, b); + if (b > 0) crc32block((unsigned int *)&crcval, (unsigned char *)buf, b); } while (b == sizeof(buf)); - crc32finish((unsigned long *)&crcval); + crc32finish((unsigned int *)&crcval); close(fh); initprintf(" Done\n"); diff --git a/polymer/eduke32/source/jaudiolib/_midi.h b/polymer/eduke32/source/jaudiolib/_midi.h index b28edd216..03aec2fb4 100644 --- a/polymer/eduke32/source/jaudiolib/_midi.h +++ b/polymer/eduke32/source/jaudiolib/_midi.h @@ -114,14 +114,14 @@ typedef struct short loopcount; short RunningStatus; unsigned time; - long FPSecondsPerTick; + int FPSecondsPerTick; short tick; short beat; short measure; short BeatsPerMeasure; short TicksPerBeat; short TimeBase; - long delay; + int delay; short active; } songcontext; @@ -130,7 +130,7 @@ typedef struct unsigned char *start; unsigned char *pos; - long delay; + int delay; short active; short RunningStatus; @@ -142,8 +142,8 @@ typedef struct char EMIDI_VolumeChange; } track; -static long _MIDI_ReadNumber( void *from, size_t size ); -static long _MIDI_ReadDelta( track *ptr ); +static int _MIDI_ReadNumber( void *from, size_t size ); +static int _MIDI_ReadDelta( track *ptr ); static void _MIDI_ResetTracks( void ); static void _MIDI_AdvanceTick( void ); static void _MIDI_MetaEvent( track *Track ); diff --git a/polymer/eduke32/source/jaudiolib/_multivc.h b/polymer/eduke32/source/jaudiolib/_multivc.h index a0adf3808..f1b4d57ae 100644 --- a/polymer/eduke32/source/jaudiolib/_multivc.h +++ b/polymer/eduke32/source/jaudiolib/_multivc.h @@ -103,35 +103,35 @@ typedef struct VoiceNode playbackstatus ( *GetSound )( struct VoiceNode *voice ); - void ( *mix )( unsigned long position, unsigned long rate, - char *start, unsigned long length ); + void ( *mix )( unsigned int position, unsigned int rate, + char *start, unsigned int length ); char *NextBlock; char *LoopStart; char *LoopEnd; unsigned LoopCount; - unsigned long LoopSize; - unsigned long BlockLength; + unsigned int LoopSize; + unsigned int BlockLength; - unsigned long PitchScale; - unsigned long FixedPointBufferSize; + unsigned int PitchScale; + unsigned int FixedPointBufferSize; char *sound; - unsigned long length; - unsigned long SamplingRate; - unsigned long RateScale; - unsigned long position; + unsigned int length; + unsigned int SamplingRate; + unsigned int RateScale; + unsigned int position; int Playing; int handle; int priority; - void ( *DemandFeed )( char **ptr, unsigned long *length ); + void ( *DemandFeed )( char **ptr, unsigned int *length ); short *LeftVolume; short *RightVolume; - unsigned long callbackval; + unsigned int callbackval; } VoiceNode; @@ -175,18 +175,18 @@ typedef struct typedef struct { char RIFF[ 4 ]; - unsigned long file_size; + unsigned int file_size; char WAVE[ 4 ]; char fmt[ 4 ]; - unsigned long format_size; + unsigned int format_size; } riff_header; typedef struct { unsigned short wFormatTag; unsigned short nChannels; - unsigned long nSamplesPerSec; - unsigned long nAvgBytesPerSec; + unsigned int nSamplesPerSec; + unsigned int nAvgBytesPerSec; unsigned short nBlockAlign; unsigned short nBitsPerSample; } format_header; @@ -194,7 +194,7 @@ typedef struct typedef struct { unsigned char DATA[ 4 ]; - unsigned long size; + unsigned int size; } data_header; typedef MONO8 VOLUME8[ 256 ]; @@ -222,13 +222,13 @@ static short *MV_GetVolumeTable( int vol ); static void MV_SetVoiceMixMode( VoiceNode *voice ); -static void MV_SetVoicePitch( VoiceNode *voice, unsigned long rate, int pitchoffset ); +static void MV_SetVoicePitch( VoiceNode *voice, unsigned int rate, int pitchoffset ); static void MV_CalcVolume( int MaxLevel ); static void MV_CalcPanTable( void ); -void ClearBuffer_DW(void *ptr, long data, long length) +void ClearBuffer_DW(void *ptr, int data, int length) { - long *pptr = ptr; + int *pptr = ptr; for (; length>0; length--) *(pptr++) = data; } @@ -283,29 +283,29 @@ parm [ edi ] [ eax ] [ ecx ] modify exact [ ecx edi ]; #endif -void CDEC MV_Mix8BitMono( unsigned long position, unsigned long rate, - char *start, unsigned long length ); +void CDEC MV_Mix8BitMono( unsigned int position, unsigned int rate, + char *start, unsigned int length ); -void CDEC MV_Mix8BitStereo( unsigned long position, - unsigned long rate, char *start, unsigned long length ); +void CDEC MV_Mix8BitStereo( unsigned int position, + unsigned int rate, char *start, unsigned int length ); -void CDEC MV_Mix16BitMono( unsigned long position, - unsigned long rate, char *start, unsigned long length ); +void CDEC MV_Mix16BitMono( unsigned int position, + unsigned int rate, char *start, unsigned int length ); -void CDEC MV_Mix16BitStereo( unsigned long position, - unsigned long rate, char *start, unsigned long length ); +void CDEC MV_Mix16BitStereo( unsigned int position, + unsigned int rate, char *start, unsigned int length ); -void CDEC MV_Mix16BitMono16( unsigned long position, - unsigned long rate, char *start, unsigned long length ); +void CDEC MV_Mix16BitMono16( unsigned int position, + unsigned int rate, char *start, unsigned int length ); -void CDEC MV_Mix8BitMono16( unsigned long position, unsigned long rate, - char *start, unsigned long length ); +void CDEC MV_Mix8BitMono16( unsigned int position, unsigned int rate, + char *start, unsigned int length ); -void CDEC MV_Mix8BitStereo16( unsigned long position, - unsigned long rate, char *start, unsigned long length ); +void CDEC MV_Mix8BitStereo16( unsigned int position, + unsigned int rate, char *start, unsigned int length ); -void CDEC MV_Mix16BitStereo16( unsigned long position, - unsigned long rate, char *start, unsigned long length ); +void CDEC MV_Mix16BitStereo16( unsigned int position, + unsigned int rate, char *start, unsigned int length ); void CDEC MV_16BitReverb( char *src, char *dest, VOLUME16 *volume, int count ); void CDEC MV_8BitReverb( signed char *src, signed char *dest, VOLUME16 *volume, int count ); diff --git a/polymer/eduke32/source/jaudiolib/audiolib_fx_fmod.c b/polymer/eduke32/source/jaudiolib/audiolib_fx_fmod.c index 7698d9cd3..2d6b695cd 100644 --- a/polymer/eduke32/source/jaudiolib/audiolib_fx_fmod.c +++ b/polymer/eduke32/source/jaudiolib/audiolib_fx_fmod.c @@ -34,11 +34,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define dprintOSD(...) #ifdef WINDOWS -extern long hWindow; +extern int hWindow; #endif -void(*FX_CallBackFunc)(unsigned long) = NULL; +void(*FX_CallBackFunc)(unsigned int) = NULL; int FX_ErrorCode = FX_Ok; #define FX_SetErrorCode( status ) \ @@ -49,9 +49,9 @@ FSOUND_SAMPLE * FX_Samples[MAXSOUNDS + 11]; // 11 remote ridicules int FX_NumVoices = 0; static char chtoggle=0; static char *chstates=NULL, *chstatesa, *chstatesb; -static long *chcallvals=NULL; +static int *chcallvals=NULL; -int FX_ReadVOCInfo(char *data, long size, int *samplerate, int *channels, int *samplesize, long *datalen); +int FX_ReadVOCInfo(char *data, int size, int *samplerate, int *channels, int *samplesize, int *datalen); int FX_ReadVOCData(char *data, char *buf, int bufferlen, char eightbit); int FX_SimulateCallbacks(void); @@ -146,10 +146,10 @@ int FX_Init(int SoundCard, int numvoices, int numchannels, int samplebits, unsig chtoggle=0; if (chstates) free(chstates); - chstates = (char*)malloc(numvoices*2 + sizeof(long)*numvoices); - memset(chstates,0,numvoices*2 + sizeof(long)*numvoices); + chstates = (char*)malloc(numvoices*2 + sizeof(int)*numvoices); + memset(chstates,0,numvoices*2 + sizeof(int)*numvoices); - chcallvals = (long*)(chstates + numvoices*2); + chcallvals = (int*)(chstates + numvoices*2); chstatesa = chstates; chstatesb = chstates + numvoices; @@ -192,7 +192,7 @@ int FX_Shutdown(void) Sets the function to call when a voice is done. ---------------------------------------------------------------------*/ -int FX_SetCallBack(void(*function)(unsigned long)) +int FX_SetCallBack(void(*function)(unsigned int)) { FX_CallBackFunc = function; FX_SetErrorCode(FX_Ok); @@ -281,14 +281,14 @@ int FX_VoiceAvailable(int priority) int FX_PlayLoopedVOC ( char *ptr, - long loopstart, - long loopend, + int loopstart, + int loopend, int pitchoffset, int vol, int left, int right, int priority, - unsigned long callbackval + unsigned int callbackval ) { return FX_PlayLoopedSound(pitchoffset, vol, callbackval); @@ -304,14 +304,14 @@ int FX_PlayLoopedVOC int FX_PlayLoopedWAV ( char *ptr, - long loopstart, - long loopend, + int loopstart, + int loopend, int pitchoffset, int vol, int left, int right, int priority, - unsigned long callbackval + unsigned int callbackval ) { return FX_PlayLoopedSound(pitchoffset, vol, callbackval); @@ -332,7 +332,7 @@ int FX_PlayVOC3D int angle, int distance, int priority, - unsigned long callbackval + unsigned int callbackval ) { return FX_PlayPositionedSound(pitchoffset, angle, distance, callbackval); @@ -353,7 +353,7 @@ int FX_PlayWAV3D int angle, int distance, int priority, - unsigned long callbackval + unsigned int callbackval ) { return FX_PlayPositionedSound(pitchoffset, angle, distance, callbackval); @@ -424,7 +424,7 @@ int FX_StopAllSounds(void) int FX_PlayLoopedSound( int pitchoffset, int vol, - unsigned long num + unsigned int num ) { int chan; @@ -460,7 +460,7 @@ int FX_PlayPositionedSound( int pitchoffset, int angle, int distance, - unsigned long num + unsigned int num ) { int chan; @@ -491,12 +491,12 @@ int FX_PlayPositionedSound( } -int FX_LoadSample(char *ptr, long size, unsigned long number, int priority) +int FX_LoadSample(char *ptr, int size, unsigned int number, int priority) { FSOUND_SAMPLE *samp = NULL; int samplerate=0, channels=0, samplesize=0; int flags=0; - long datalen=0; + int datalen=0; void *ptr1,*ptr2; int ptr1len,ptr2len; @@ -532,7 +532,7 @@ int FX_LoadSample(char *ptr, long size, unsigned long number, int priority) } -int FX_SampleLoaded(unsigned long number) +int FX_SampleLoaded(unsigned int number) { return (FX_Samples[number] != NULL); } @@ -541,7 +541,7 @@ int FX_SampleLoaded(unsigned long number) #define REGRESSTC(tc) (256000000/(65536-(tc))) #define REGRESSSR(sr) (1000000/(256-(sr))) -int FX_ReadVOCInfo(char *data, long size, int *samplerate, int *channels, int *samplesize, long *datalen) +int FX_ReadVOCInfo(char *data, int size, int *samplerate, int *channels, int *samplesize, int *datalen) { short version,version2; char blocktype=0; @@ -646,7 +646,7 @@ int FX_ReadVOCInfo(char *data, long size, int *samplerate, int *channels, int *s break; case 9: /* sound data format 3 */ - *samplerate = *((long*)(ptr)); + *samplerate = *((int*)(ptr)); *samplesize = ptr[4]; *channels = ptr[5]; if ((ptr[6] | (ptr[7] << 8)) != 0 && diff --git a/polymer/eduke32/source/jaudiolib/audiolib_fxstub.c b/polymer/eduke32/source/jaudiolib/audiolib_fxstub.c index d44bad716..b723f51f0 100644 --- a/polymer/eduke32/source/jaudiolib/audiolib_fxstub.c +++ b/polymer/eduke32/source/jaudiolib/audiolib_fxstub.c @@ -122,7 +122,7 @@ int FX_Shutdown int FX_SetCallBack ( - void(*function)(unsigned long) + void(*function)(unsigned int) ) { @@ -227,14 +227,14 @@ int FX_VoiceAvailable int FX_PlayLoopedVOC ( char *ptr, - long loopstart, - long loopend, + int loopstart, + int loopend, int pitchoffset, int vol, int left, int right, int priority, - unsigned long callbackval + unsigned int callbackval ) { @@ -251,14 +251,14 @@ int FX_PlayLoopedVOC int FX_PlayLoopedWAV ( char *ptr, - long loopstart, - long loopend, + int loopstart, + int loopend, int pitchoffset, int vol, int left, int right, int priority, - unsigned long callbackval + unsigned int callbackval ) { @@ -280,7 +280,7 @@ int FX_PlayVOC3D int angle, int distance, int priority, - unsigned long callbackval + unsigned int callbackval ) { @@ -302,7 +302,7 @@ int FX_PlayWAV3D int angle, int distance, int priority, - unsigned long callbackval + unsigned int callbackval ) { diff --git a/polymer/eduke32/source/jaudiolib/audiolib_musicstub.c b/polymer/eduke32/source/jaudiolib/audiolib_musicstub.c index 60a81f395..5c3649139 100644 --- a/polymer/eduke32/source/jaudiolib/audiolib_musicstub.c +++ b/polymer/eduke32/source/jaudiolib/audiolib_musicstub.c @@ -341,7 +341,7 @@ int MUSIC_GetContext void MUSIC_SetSongTick ( - unsigned long PositionInTicks + unsigned int PositionInTicks ) {} @@ -355,7 +355,7 @@ void MUSIC_SetSongTick void MUSIC_SetSongTime ( - unsigned long milliseconds + unsigned int milliseconds ) {} diff --git a/polymer/eduke32/source/jaudiolib/debugio.h b/polymer/eduke32/source/jaudiolib/debugio.h index a6510ba19..04d355553 100755 --- a/polymer/eduke32/source/jaudiolib/debugio.h +++ b/polymer/eduke32/source/jaudiolib/debugio.h @@ -24,7 +24,7 @@ void DB_SetXY( int x, int y ); void DB_PutChar( char ch ); int DB_PrintString( char *string ); int DB_PrintNum( int number ); -int DB_PrintUnsigned( unsigned long number, int radix ); +int DB_PrintUnsigned( unsigned int number, int radix ); int DB_printf( char *fmt, ... ); #endif diff --git a/polymer/eduke32/source/jaudiolib/dsoundout.c b/polymer/eduke32/source/jaudiolib/dsoundout.c index 3b8ce6c38..5b55b6738 100644 --- a/polymer/eduke32/source/jaudiolib/dsoundout.c +++ b/polymer/eduke32/source/jaudiolib/dsoundout.c @@ -449,7 +449,7 @@ static DWORD WINAPI isr(LPVOID parm) { /* #define copybuf(S,D,c) \ - ({ void *__S=(S), *__D=(D); long __c=(c); \ + ({ void *__S=(S), *__D=(D); int __c=(c); \ __asm__ __volatile__ ("rep; movsl" \ : "+S" (__S), "+D" (__D), "+c" (__c) : : "memory", "cc"); \ 0; }) diff --git a/polymer/eduke32/source/jaudiolib/fx_man.c b/polymer/eduke32/source/jaudiolib/fx_man.c index b92ff5379..fddb422c0 100644 --- a/polymer/eduke32/source/jaudiolib/fx_man.c +++ b/polymer/eduke32/source/jaudiolib/fx_man.c @@ -323,7 +323,7 @@ int FX_Shutdown int FX_SetCallBack ( - void(*function)(unsigned long) + void(*function)(unsigned int) ) { @@ -612,7 +612,7 @@ int FX_PlayVOC int left, int right, int priority, - unsigned long callbackval + unsigned int callbackval ) { @@ -639,14 +639,14 @@ int FX_PlayVOC int FX_PlayLoopedVOC ( char *ptr, - long loopstart, - long loopend, + int loopstart, + int loopend, int pitchoffset, int vol, int left, int right, int priority, - unsigned long callbackval + unsigned int callbackval ) { @@ -678,7 +678,7 @@ int FX_PlayWAV int left, int right, int priority, - unsigned long callbackval + unsigned int callbackval ) { @@ -705,14 +705,14 @@ int FX_PlayWAV int FX_PlayLoopedWAV ( char *ptr, - long loopstart, - long loopend, + int loopstart, + int loopend, int pitchoffset, int vol, int left, int right, int priority, - unsigned long callbackval + unsigned int callbackval ) { @@ -744,7 +744,7 @@ int FX_PlayVOC3D int angle, int distance, int priority, - unsigned long callbackval + unsigned int callbackval ) { @@ -776,7 +776,7 @@ int FX_PlayWAV3D int angle, int distance, int priority, - unsigned long callbackval + unsigned int callbackval ) { @@ -803,14 +803,14 @@ int FX_PlayWAV3D int FX_PlayRaw ( char *ptr, - unsigned long length, + unsigned int length, unsigned rate, int pitchoffset, int vol, int left, int right, int priority, - unsigned long callbackval + unsigned int callbackval ) { @@ -837,7 +837,7 @@ int FX_PlayRaw int FX_PlayLoopedRaw ( char *ptr, - unsigned long length, + unsigned int length, char *loopstart, char *loopend, unsigned rate, @@ -846,7 +846,7 @@ int FX_PlayLoopedRaw int left, int right, int priority, - unsigned long callbackval + unsigned int callbackval ) { @@ -982,14 +982,14 @@ int FX_StopAllSounds int FX_StartDemandFeedPlayback ( - void(*function)(char **ptr, unsigned long *length), + void(*function)(char **ptr, unsigned int *length), int rate, int pitchoffset, int vol, int left, int right, int priority, - unsigned long callbackval + unsigned int callbackval ) { diff --git a/polymer/eduke32/source/jaudiolib/fx_man.h b/polymer/eduke32/source/jaudiolib/fx_man.h index f2fa2429d..943081b8b 100644 --- a/polymer/eduke32/source/jaudiolib/fx_man.h +++ b/polymer/eduke32/source/jaudiolib/fx_man.h @@ -44,13 +44,13 @@ typedef struct typedef struct { - unsigned long Address; - unsigned long Type; - unsigned long Interrupt; - unsigned long Dma8; - unsigned long Dma16; - unsigned long Midi; - unsigned long Emu; + unsigned int Address; + unsigned int Type; + unsigned int Interrupt; + unsigned int Dma8; + unsigned int Dma16; + unsigned int Midi; + unsigned int Emu; } fx_blaster_config; enum FX_ERRORS @@ -83,7 +83,7 @@ char *FX_ErrorString( int ErrorNumber ); //int FX_SetupSoundBlaster( fx_blaster_config blaster, int *MaxVoices, int *MaxSampleBits, int *MaxChannels ); int FX_Init( int SoundCard, int numvoices, int numchannels, int samplebits, unsigned mixrate ); int FX_Shutdown( void ); -int FX_SetCallBack( void ( *function )( unsigned long ) ); +int FX_SetCallBack( void ( *function )( unsigned int ) ); void FX_SetVolume( int volume ); int FX_GetVolume( void ); @@ -102,33 +102,33 @@ int FX_SetPitch( int handle, int pitchoffset ); int FX_SetFrequency( int handle, int frequency ); int FX_PlayVOC( char *ptr, int pitchoffset, int vol, int left, int right, - int priority, unsigned long callbackval ); -int FX_PlayLoopedVOC( char *ptr, long loopstart, long loopend, + int priority, unsigned int callbackval ); +int FX_PlayLoopedVOC( char *ptr, int loopstart, int loopend, int pitchoffset, int vol, int left, int right, int priority, - unsigned long callbackval ); + unsigned int callbackval ); int FX_PlayWAV( char *ptr, int pitchoffset, int vol, int left, int right, - int priority, unsigned long callbackval ); -int FX_PlayLoopedWAV( char *ptr, long loopstart, long loopend, + int priority, unsigned int callbackval ); +int FX_PlayLoopedWAV( char *ptr, int loopstart, int loopend, int pitchoffset, int vol, int left, int right, int priority, - unsigned long callbackval ); + unsigned int callbackval ); int FX_PlayVOC3D( char *ptr, int pitchoffset, int angle, int distance, - int priority, unsigned long callbackval ); + int priority, unsigned int callbackval ); int FX_PlayWAV3D( char *ptr, int pitchoffset, int angle, int distance, - int priority, unsigned long callbackval ); -int FX_PlayRaw( char *ptr, unsigned long length, unsigned rate, + int priority, unsigned int callbackval ); +int FX_PlayRaw( char *ptr, unsigned int length, unsigned rate, int pitchoffset, int vol, int left, int right, int priority, - unsigned long callbackval ); -int FX_PlayLoopedRaw( char *ptr, unsigned long length, char *loopstart, + unsigned int callbackval ); +int FX_PlayLoopedRaw( char *ptr, unsigned int length, char *loopstart, char *loopend, unsigned rate, int pitchoffset, int vol, int left, - int right, int priority, unsigned long callbackval ); + int right, int priority, unsigned int callbackval ); int FX_Pan3D( int handle, int angle, int distance ); int FX_SoundActive( int handle ); int FX_SoundsPlaying( void ); int FX_StopSound( int handle ); int FX_StopAllSounds( void ); -int FX_StartDemandFeedPlayback( void ( *function )( char **ptr, unsigned long *length ), +int FX_StartDemandFeedPlayback( void ( *function )( char **ptr, unsigned int *length ), int rate, int pitchoffset, int vol, int left, int right, - int priority, unsigned long callbackval ); + int priority, unsigned int callbackval ); int FX_StartRecording( int MixRate, void ( *function )( char *ptr, int length ) ); void FX_StopRecord( void ); diff --git a/polymer/eduke32/source/jaudiolib/fx_man_fmod.h b/polymer/eduke32/source/jaudiolib/fx_man_fmod.h index e1b92ae3a..388bfa191 100644 --- a/polymer/eduke32/source/jaudiolib/fx_man_fmod.h +++ b/polymer/eduke32/source/jaudiolib/fx_man_fmod.h @@ -42,7 +42,7 @@ enum FX_ERRORS char *FX_ErrorString( int ErrorNumber ); int FX_Init( int SoundCard, int numvoices, int numchannels, int samplebits, unsigned mixrate ); int FX_Shutdown( void ); -int FX_SetCallBack( void ( *function )( unsigned long ) ); +int FX_SetCallBack( void ( *function )( unsigned int ) ); void FX_SetVolume( int volume ); void FX_SetReverseStereo( int setting ); @@ -52,26 +52,26 @@ void FX_SetReverbDelay( int delay ); int FX_VoiceAvailable( int priority ); -int FX_PlayLoopedVOC( char *ptr, long loopstart, long loopend, +int FX_PlayLoopedVOC( char *ptr, int loopstart, int loopend, int pitchoffset, int vol, int left, int right, int priority, - unsigned long callbackval ); -int FX_PlayLoopedWAV( char *ptr, long loopstart, long loopend, + unsigned int callbackval ); +int FX_PlayLoopedWAV( char *ptr, int loopstart, int loopend, int pitchoffset, int vol, int left, int right, int priority, - unsigned long callbackval ); + unsigned int callbackval ); int FX_PlayVOC3D( char *ptr, int pitchoffset, int angle, int distance, - int priority, unsigned long callbackval ); + int priority, unsigned int callbackval ); int FX_PlayWAV3D( char *ptr, int pitchoffset, int angle, int distance, - int priority, unsigned long callbackval ); + int priority, unsigned int callbackval ); int FX_Pan3D( int handle, int angle, int distance ); int FX_StopSound( int handle ); int FX_StopAllSounds( void ); -int FX_LoadSample(char *ptr, long size, unsigned long number, int priority); -int FX_SampleLoaded(unsigned long number); +int FX_LoadSample(char *ptr, int size, unsigned int number, int priority); +int FX_SampleLoaded(unsigned int number); -int FX_PlayLoopedSound(int,int,unsigned long); -int FX_PlayPositionedSound(int,int,int,unsigned long); +int FX_PlayLoopedSound(int,int,unsigned int); +int FX_PlayPositionedSound(int,int,int,unsigned int); int FX_SimulateCallbacks(void); diff --git a/polymer/eduke32/source/jaudiolib/interrup.h b/polymer/eduke32/source/jaudiolib/interrup.h index e8d78b90b..05b101534 100755 --- a/polymer/eduke32/source/jaudiolib/interrup.h +++ b/polymer/eduke32/source/jaudiolib/interrup.h @@ -31,8 +31,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef __INTERRUPT_H #define __INTERRUPT_H -unsigned long DisableInterrupts( void ); -void RestoreInterrupts( unsigned long flags ); +unsigned int DisableInterrupts( void ); +void RestoreInterrupts( unsigned int flags ); #ifdef PLAT_DOS #pragma aux DisableInterrupts = \ diff --git a/polymer/eduke32/source/jaudiolib/midi.c b/polymer/eduke32/source/jaudiolib/midi.c index 122df9502..06e66685d 100644 --- a/polymer/eduke32/source/jaudiolib/midi.c +++ b/polymer/eduke32/source/jaudiolib/midi.c @@ -75,14 +75,14 @@ static unsigned _MIDI_Time; static int _MIDI_BeatsPerMeasure; static int _MIDI_TicksPerBeat; static int _MIDI_TimeBase; -static long _MIDI_FPSecondsPerTick; +static int _MIDI_FPSecondsPerTick; static unsigned _MIDI_TotalTime; static int _MIDI_TotalTicks; static int _MIDI_TotalBeats; static int _MIDI_TotalMeasures; -unsigned long _MIDI_PositionInTicks; -unsigned long _MIDI_GlobalPositionInTicks; +unsigned int _MIDI_PositionInTicks; +unsigned int _MIDI_GlobalPositionInTicks; static int _MIDI_Context; @@ -118,7 +118,7 @@ char MIDI_PatchMap[ 128 ]; Reads a variable length number from a MIDI track. ---------------------------------------------------------------------*/ -static long _MIDI_ReadNumber +static int _MIDI_ReadNumber ( void *from, size_t size @@ -126,7 +126,7 @@ static long _MIDI_ReadNumber { unsigned char *FromPtr; - long value; + int value; if (size > 4) { @@ -152,13 +152,13 @@ static long _MIDI_ReadNumber Reads a variable length encoded delta delay time from the MIDI data. ---------------------------------------------------------------------*/ -static long _MIDI_ReadDelta +static int _MIDI_ReadDelta ( track *ptr ) { - long value; + int value; unsigned char c; GET_NEXT_EVENT(ptr, value); @@ -290,7 +290,7 @@ static void _MIDI_MetaEvent int command; int length; int denominator; - long tempo; + int tempo; GET_NEXT_EVENT(Track, command); GET_NEXT_EVENT(Track, length); @@ -1200,8 +1200,8 @@ int MIDI_PlaySong { int numtracks; int format; - long headersize; - long tracklength; + int headersize; + int tracklength; track *CurrentTrack; unsigned char *ptr; int status; @@ -1220,7 +1220,7 @@ int MIDI_PlaySong return(MIDI_NullMidiModule); } - if (*(unsigned long *)song != MIDI_HEADER_SIGNATURE) + if (*(unsigned int *)song != MIDI_HEADER_SIGNATURE) { return(MIDI_InvalidMidiFile); } @@ -1261,7 +1261,7 @@ int MIDI_PlaySong numtracks = _MIDI_NumTracks; while (numtracks--) { - if (*(unsigned long *)ptr != MIDI_TRACK_SIGNATURE) + if (*(unsigned int *)ptr != MIDI_TRACK_SIGNATURE) { USRHOOKS_FreeMem(_MIDI_TrackPtr); @@ -1324,7 +1324,7 @@ void MIDI_SetTempo ) { - long tickspersecond; + int tickspersecond; MIDI_Tempo = tempo; tickspersecond = ((tempo) * _MIDI_Division) / 60; @@ -1512,7 +1512,7 @@ static int _MIDI_ProcessNextTick void MIDI_SetSongTick ( - unsigned long PositionInTicks + unsigned int PositionInTicks ) { @@ -1559,13 +1559,13 @@ void MIDI_SetSongTick void MIDI_SetSongTime ( - unsigned long milliseconds + unsigned int milliseconds ) { - unsigned long mil; - unsigned long sec; - unsigned long newtime; + unsigned int mil; + unsigned int sec; + unsigned int newtime; if (!_MIDI_SongLoaded) { @@ -1620,7 +1620,7 @@ void MIDI_SetSongPosition ) { - unsigned long pos; + unsigned int pos; if (!_MIDI_SongLoaded) { @@ -1631,13 +1631,13 @@ void MIDI_SetSongPosition pos = RELATIVE_BEAT(measure, beat, tick); - if (pos < (unsigned long)RELATIVE_BEAT(_MIDI_Measure, _MIDI_Beat, _MIDI_Tick)) + if (pos < (unsigned int)RELATIVE_BEAT(_MIDI_Measure, _MIDI_Beat, _MIDI_Tick)) { _MIDI_ResetTracks(); MIDI_Reset(); } - while ((unsigned long)RELATIVE_BEAT(_MIDI_Measure, _MIDI_Beat, _MIDI_Tick) < pos) + while ((unsigned int)RELATIVE_BEAT(_MIDI_Measure, _MIDI_Beat, _MIDI_Tick) < pos) { if (_MIDI_ProcessNextTick()) { @@ -1671,8 +1671,8 @@ void MIDI_GetSongPosition ) { - unsigned long mil; - unsigned long sec; + unsigned int mil; + unsigned int sec; mil = (_MIDI_Time & ((1 << TIME_PRECISION) - 1)) * 1000; sec = _MIDI_Time >> TIME_PRECISION; @@ -1696,8 +1696,8 @@ void MIDI_GetSongLength ) { - unsigned long mil; - unsigned long sec; + unsigned int mil; + unsigned int sec; mil = (_MIDI_TotalTime & ((1 << TIME_PRECISION) - 1)) * 1000; sec = _MIDI_TotalTime >> TIME_PRECISION; diff --git a/polymer/eduke32/source/jaudiolib/midi.h b/polymer/eduke32/source/jaudiolib/midi.h index 343d99536..429e4284f 100644 --- a/polymer/eduke32/source/jaudiolib/midi.h +++ b/polymer/eduke32/source/jaudiolib/midi.h @@ -88,8 +88,8 @@ void MIDI_StopSong( void ); int MIDI_PlaySong( unsigned char *song, int loopflag ); void MIDI_SetTempo( int tempo ); int MIDI_GetTempo( void ); -void MIDI_SetSongTick( unsigned long PositionInTicks ); -void MIDI_SetSongTime( unsigned long milliseconds ); +void MIDI_SetSongTick( unsigned int PositionInTicks ); +void MIDI_SetSongTime( unsigned int milliseconds ); void MIDI_SetSongPosition( int measure, int beat, int tick ); void MIDI_GetSongPosition( songposition *pos ); void MIDI_GetSongLength( songposition *pos ); diff --git a/polymer/eduke32/source/jaudiolib/mpu401.c b/polymer/eduke32/source/jaudiolib/mpu401.c index 0dab155cd..3b2e112f9 100644 --- a/polymer/eduke32/source/jaudiolib/mpu401.c +++ b/polymer/eduke32/source/jaudiolib/mpu401.c @@ -42,9 +42,9 @@ static DWORD mididevice = -1; typedef struct { - long time; - long stream; - long event; + int time; + int stream; + int event; } MIDIEVENTHEAD; #define PAD(x) ((((x)+3)&(~3))) @@ -57,8 +57,8 @@ static MIDIHDR bufferheaders[NUMBUFFERS]; int _MPU_CurrentBuffer = 0; int _MPU_BuffersWaiting = 0; -extern unsigned long _MIDI_GlobalPositionInTicks; -unsigned long _MPU_LastEvent=0; +extern unsigned int _MIDI_GlobalPositionInTicks; +unsigned int _MPU_LastEvent=0; #define MIDI_NOTE_OFF 0x80 #define MIDI_NOTE_ON 0x90 @@ -120,7 +120,7 @@ void CALLBACK MPU_MIDICallback(HMIDIOUT handle, UINT uMsg, DWORD dwInstance, DWO midiOutUnprepareHeader((HMIDIOUT)handle, (MIDIHDR*)dwParam1, sizeof(MIDIHDR)); for (i=0;i0; count--, padded--, eventcnt[_MPU_CurrentBuffer]++) *(p++) = *(data++); @@ -220,7 +220,7 @@ void MPU_SendMidiImmediate(char *data, int count) static int masks[3] = { 0x00ffffffl, 0x0000ffffl, 0x000000ffl }; if (!count) return; - if (count<=3) midiOutShortMsg((HMIDIOUT)hmido, (*((long*)data)) & masks[count-1]); + if (count<=3) midiOutShortMsg((HMIDIOUT)hmido, (*((int*)data)) & masks[count-1]); else { ZeroMemory(&mhdr, sizeof(mhdr)); @@ -450,7 +450,7 @@ void MPU_SetVolume(int volume) { /* HMIXER hmixer; - long mixerid; + int mixerid; MIXERCONTROLDETAILS mxcd; MIXERCONTROLDETAILS_UNSIGNED mxcdu; MMRESULT mme; diff --git a/polymer/eduke32/source/jaudiolib/multivoc.c b/polymer/eduke32/source/jaudiolib/multivoc.c index 5de4cc184..bbe316464 100644 --- a/polymer/eduke32/source/jaudiolib/multivoc.c +++ b/polymer/eduke32/source/jaudiolib/multivoc.c @@ -105,7 +105,7 @@ static VoiceNode VoicePool; int MV_MixPage = 0; static int MV_VoiceHandle = MV_MinVoiceHandle; -static void(*MV_CallBackFunc)(unsigned long) = NULL; +static void(*MV_CallBackFunc)(unsigned int) = NULL; static void(*MV_RecordFunc)(char *ptr, int length) = NULL; static void(*MV_MixFunction)(VoiceNode *voice, int buffer); @@ -118,7 +118,7 @@ short *MV_RightVolume; int MV_SampleSize = 1; int MV_RightChannelOffset; -unsigned long MV_MixPosition; +unsigned int MV_MixPosition; int MV_ErrorCode = MV_Ok; @@ -255,10 +255,10 @@ static void MV_Mix(VoiceNode *voice, int buffer) { char *start; int length; - long voclength; - unsigned long position; - unsigned long rate; - unsigned long FixedPointBufferSize; + int voclength; + unsigned int position; + unsigned int rate; + unsigned int FixedPointBufferSize; if ((voice->length == 0) && (voice->GetSound(voice) != KeepPlaying)) { @@ -504,8 +504,8 @@ playbackstatus MV_GetNextVOCBlock(VoiceNode *voice) unsigned char *ptr; int blocktype; int lastblocktype; - unsigned long blocklength = 0; - unsigned long samplespeed = 0; + unsigned int blocklength = 0; + unsigned int samplespeed = 0; unsigned int tc = 0; int packtype; int voicemode; @@ -559,14 +559,14 @@ playbackstatus MV_GetNextVOCBlock(VoiceNode *voice) } blocktype = (int)*ptr; - blocklength = (*(unsigned long *)(ptr + 1)) & 0x00ffffff; + blocklength = (*(unsigned int *)(ptr + 1)) & 0x00ffffff; ptr += 4; switch (blocktype) { case 0 : // End of data - if ((voice->LoopStart == NULL) || ((unsigned long *)voice->LoopStart >= (unsigned long *)(ptr - 4))) + if ((voice->LoopStart == NULL) || ((unsigned int *)voice->LoopStart >= (unsigned int *)(ptr - 4))) { voice->Playing = FALSE; done = TRUE; @@ -678,7 +678,7 @@ playbackstatus MV_GetNextVOCBlock(VoiceNode *voice) case 9 : // New sound data block - samplespeed = *(unsigned long *)ptr; + samplespeed = *(unsigned int *)ptr; BitsPerSample = (unsigned)*(ptr + 4); Channels = (unsigned)*(ptr + 5); Format = (unsigned)*(unsigned short *)(ptr + 6); @@ -727,17 +727,17 @@ playbackstatus MV_GetNextVOCBlock(VoiceNode *voice) if (voice->LoopEnd != NULL) { - if (blocklength > (unsigned long)voice->LoopEnd) + if (blocklength > (unsigned int)voice->LoopEnd) { - blocklength = (unsigned long)voice->LoopEnd; + blocklength = (unsigned int)voice->LoopEnd; } else { voice->LoopEnd = (char *)blocklength; } - voice->LoopStart = voice->sound + (unsigned long)voice->LoopStart; - voice->LoopEnd = voice->sound + (unsigned long)voice->LoopEnd; + voice->LoopStart = voice->sound + (unsigned int)voice->LoopStart; + voice->LoopEnd = voice->sound + (unsigned int)voice->LoopEnd; voice->LoopSize = voice->LoopEnd - voice->LoopStart; } @@ -989,7 +989,7 @@ int MV_Kill(int handle) { VoiceNode *voice; unsigned flags; - unsigned long callbackval; + unsigned int callbackval; if (!MV_Installed) { @@ -1168,7 +1168,7 @@ int MV_VoiceAvailable(int priority) Sets the pitch for the specified voice. ---------------------------------------------------------------------*/ -void MV_SetVoicePitch(VoiceNode *voice, unsigned long rate, int pitchoffset) +void MV_SetVoicePitch(VoiceNode *voice, unsigned int rate, int pitchoffset) { voice->SamplingRate = rate; voice->PitchScale = PITCH_GetScale(pitchoffset); @@ -1824,7 +1824,7 @@ void MV_StopRecord(void) Plays a digitized sound from a user controlled buffering system. ---------------------------------------------------------------------*/ -int MV_StartDemandFeedPlayback(void(*function)(char **ptr, unsigned long *length), int rate, int pitchoffset, int vol, int left, int right, int priority, unsigned long callbackval) +int MV_StartDemandFeedPlayback(void(*function)(char **ptr, unsigned int *length), int rate, int pitchoffset, int vol, int left, int right, int priority, unsigned int callbackval) { VoiceNode *voice; @@ -1875,7 +1875,7 @@ int MV_StartDemandFeedPlayback(void(*function)(char **ptr, unsigned long *length priority. ---------------------------------------------------------------------*/ -int MV_PlayRaw(char *ptr, unsigned long length, unsigned rate, int pitchoffset, int vol, int left, int right, int priority, unsigned long callbackval) +int MV_PlayRaw(char *ptr, unsigned int length, unsigned rate, int pitchoffset, int vol, int left, int right, int priority, unsigned int callbackval) { int status; @@ -1892,7 +1892,7 @@ int MV_PlayRaw(char *ptr, unsigned long length, unsigned rate, int pitchoffset, priority. ---------------------------------------------------------------------*/ -int MV_PlayLoopedRaw(char *ptr, long length, char *loopstart, char *loopend, unsigned rate, int pitchoffset, int vol, int left, int right, int priority, unsigned long callbackval) +int MV_PlayLoopedRaw(char *ptr, int length, char *loopstart, char *loopend, unsigned rate, int pitchoffset, int vol, int left, int right, int priority, unsigned int callbackval) { VoiceNode *voice; @@ -1941,7 +1941,7 @@ int MV_PlayLoopedRaw(char *ptr, long length, char *loopstart, char *loopend, uns priority. ---------------------------------------------------------------------*/ -int MV_PlayWAV(char *ptr, int pitchoffset, int vol, int left, int right, int priority, unsigned long callbackval) +int MV_PlayWAV(char *ptr, int pitchoffset, int vol, int left, int right, int priority, unsigned int callbackval) { int status; @@ -1958,7 +1958,7 @@ int MV_PlayWAV(char *ptr, int pitchoffset, int vol, int left, int right, int pri from listener. ---------------------------------------------------------------------*/ -int MV_PlayWAV3D(char *ptr, int pitchoffset, int angle, int distance, int priority, unsigned long callbackval) +int MV_PlayWAV3D(char *ptr, int pitchoffset, int angle, int distance, int priority, unsigned int callbackval) { int left; int right; @@ -2000,7 +2000,7 @@ int MV_PlayWAV3D(char *ptr, int pitchoffset, int angle, int distance, int priori priority. ---------------------------------------------------------------------*/ -int MV_PlayLoopedWAV(char *ptr, long loopstart, long loopend, int pitchoffset, int vol, int left, int right, int priority, unsigned long callbackval) +int MV_PlayLoopedWAV(char *ptr, int loopstart, int loopend, int pitchoffset, int vol, int left, int right, int priority, unsigned int callbackval) { riff_header *riff; format_header *format; @@ -2116,7 +2116,7 @@ int MV_PlayLoopedWAV(char *ptr, long loopstart, long loopend, int pitchoffset, i from listener. ---------------------------------------------------------------------*/ -int MV_PlayVOC3D(char *ptr, int pitchoffset, int angle, int distance, int priority, unsigned long callbackval) +int MV_PlayVOC3D(char *ptr, int pitchoffset, int angle, int distance, int priority, unsigned int callbackval) { int left; int right; @@ -2158,7 +2158,7 @@ int MV_PlayVOC3D(char *ptr, int pitchoffset, int angle, int distance, int priori priority. ---------------------------------------------------------------------*/ -int MV_PlayVOC(char *ptr, int pitchoffset, int vol, int left, int right, int priority, unsigned long callbackval) +int MV_PlayVOC(char *ptr, int pitchoffset, int vol, int left, int right, int priority, unsigned int callbackval) { int status; @@ -2175,7 +2175,7 @@ int MV_PlayVOC(char *ptr, int pitchoffset, int vol, int left, int right, int pri priority. ---------------------------------------------------------------------*/ -int MV_PlayLoopedVOC(char *ptr, long loopstart, long loopend, int pitchoffset, int vol, int left, int right, int priority, unsigned long callbackval) +int MV_PlayLoopedVOC(char *ptr, int loopstart, int loopend, int pitchoffset, int vol, int left, int right, int priority, unsigned int callbackval) { VoiceNode *voice; int status; @@ -2375,7 +2375,7 @@ int MV_GetVolume(void) Set the function to call when a voice stops. ---------------------------------------------------------------------*/ -void MV_SetCallBack(void(*function)(unsigned long)) +void MV_SetCallBack(void(*function)(unsigned int)) { MV_CallBackFunc = function; } @@ -2414,7 +2414,7 @@ int MV_GetReverseStereo(void) int MV_TestPlayback(void) { unsigned flags; - long time; + int time; int start; int status; int pos; @@ -2474,7 +2474,7 @@ int MV_TestPlayback(void) } #endif -int USRHOOKS_GetMem(void **ptr, unsigned long size) +int USRHOOKS_GetMem(void **ptr, unsigned int size) { *ptr = malloc(size); diff --git a/polymer/eduke32/source/jaudiolib/multivoc.h b/polymer/eduke32/source/jaudiolib/multivoc.h index 19af4479e..25b277c69 100644 --- a/polymer/eduke32/source/jaudiolib/multivoc.h +++ b/polymer/eduke32/source/jaudiolib/multivoc.h @@ -78,34 +78,34 @@ int MV_StartPlayback( void ); void MV_StopPlayback( void ); int MV_StartRecording( int MixRate, void ( *function )( char *ptr, int length ) ); void MV_StopRecord( void ); -int MV_StartDemandFeedPlayback( void ( *function )( char **ptr, unsigned long *length ), +int MV_StartDemandFeedPlayback( void ( *function )( char **ptr, unsigned int *length ), int rate, int pitchoffset, int vol, int left, int right, - int priority, unsigned long callbackval ); -int MV_PlayRaw( char *ptr, unsigned long length, + int priority, unsigned int callbackval ); +int MV_PlayRaw( char *ptr, unsigned int length, unsigned rate, int pitchoffset, int vol, int left, - int right, int priority, unsigned long callbackval ); -int MV_PlayLoopedRaw( char *ptr, long length, + int right, int priority, unsigned int callbackval ); +int MV_PlayLoopedRaw( char *ptr, int length, char *loopstart, char *loopend, unsigned rate, int pitchoffset, int vol, int left, int right, int priority, - unsigned long callbackval ); + unsigned int callbackval ); int MV_PlayWAV( char *ptr, int pitchoffset, int vol, int left, - int right, int priority, unsigned long callbackval ); + int right, int priority, unsigned int callbackval ); int MV_PlayWAV3D( char *ptr, int pitchoffset, int angle, int distance, - int priority, unsigned long callbackval ); -int MV_PlayLoopedWAV( char *ptr, long loopstart, long loopend, + int priority, unsigned int callbackval ); +int MV_PlayLoopedWAV( char *ptr, int loopstart, int loopend, int pitchoffset, int vol, int left, int right, int priority, - unsigned long callbackval ); + unsigned int callbackval ); int MV_PlayVOC3D( char *ptr, int pitchoffset, int angle, int distance, - int priority, unsigned long callbackval ); + int priority, unsigned int callbackval ); int MV_PlayVOC( char *ptr, int pitchoffset, int vol, int left, int right, - int priority, unsigned long callbackval ); -int MV_PlayLoopedVOC( char *ptr, long loopstart, long loopend, + int priority, unsigned int callbackval ); +int MV_PlayLoopedVOC( char *ptr, int loopstart, int loopend, int pitchoffset, int vol, int left, int right, int priority, - unsigned long callbackval ); + unsigned int callbackval ); void MV_CreateVolumeTable( int index, int volume, int MaxVolume ); void MV_SetVolume( int volume ); int MV_GetVolume( void ); -void MV_SetCallBack( void ( *function )( unsigned long ) ); +void MV_SetCallBack( void ( *function )( unsigned int ) ); void MV_SetReverseStereo( int setting ); int MV_GetReverseStereo( void ); int MV_Init( int soundcard, int MixRate, int Voices, int numchannels, diff --git a/polymer/eduke32/source/jaudiolib/music.c b/polymer/eduke32/source/jaudiolib/music.c index 9edc03041..ac72a22ba 100644 --- a/polymer/eduke32/source/jaudiolib/music.c +++ b/polymer/eduke32/source/jaudiolib/music.c @@ -395,7 +395,7 @@ int MUSIC_GetContext void MUSIC_SetSongTick ( - unsigned long PositionInTicks + unsigned int PositionInTicks ) { @@ -411,7 +411,7 @@ void MUSIC_SetSongTick void MUSIC_SetSongTime ( - unsigned long milliseconds + unsigned int milliseconds ) { diff --git a/polymer/eduke32/source/jaudiolib/music.h b/polymer/eduke32/source/jaudiolib/music.h index 028790d92..ff76e60c2 100644 --- a/polymer/eduke32/source/jaudiolib/music.h +++ b/polymer/eduke32/source/jaudiolib/music.h @@ -50,8 +50,8 @@ enum MUSIC_ERRORS typedef struct { - unsigned long tickposition; - unsigned long milliseconds; + unsigned int tickposition; + unsigned int milliseconds; unsigned int measure; unsigned int beat; unsigned int tick; @@ -75,8 +75,8 @@ int MUSIC_StopSong( void ); int MUSIC_PlaySong( unsigned char *song, int loopflag ); void MUSIC_SetContext( int context ); int MUSIC_GetContext( void ); -void MUSIC_SetSongTick( unsigned long PositionInTicks ); -void MUSIC_SetSongTime( unsigned long milliseconds ); +void MUSIC_SetSongTick( unsigned int PositionInTicks ); +void MUSIC_SetSongTime( unsigned int milliseconds ); void MUSIC_SetSongPosition( int measure, int beat, int tick ); void MUSIC_GetSongPosition( songposition *pos ); void MUSIC_GetSongLength( songposition *pos ); diff --git a/polymer/eduke32/source/jaudiolib/pitch.c b/polymer/eduke32/source/jaudiolib/pitch.c index be87a3628..4d5c20915 100644 --- a/polymer/eduke32/source/jaudiolib/pitch.c +++ b/polymer/eduke32/source/jaudiolib/pitch.c @@ -36,7 +36,7 @@ Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) #define MAXDETUNE 25 -static unsigned long PitchTable[ 12 ][ MAXDETUNE ] = +static unsigned int PitchTable[ 12 ][ MAXDETUNE ] = { { 0x10000, 0x10097, 0x1012f, 0x101c7, 0x10260, 0x102f9, 0x10392, 0x1042c, @@ -138,13 +138,13 @@ void PITCH_Init Returns a fixed-point value to scale number the specified amount. ---------------------------------------------------------------------*/ -unsigned long PITCH_GetScale +unsigned int PITCH_GetScale ( int pitchoffset ) { - unsigned long scale; + unsigned int scale; int octaveshift; int noteshift; int note; diff --git a/polymer/eduke32/source/jaudiolib/pitch.h b/polymer/eduke32/source/jaudiolib/pitch.h index b054507a7..af8f10992 100644 --- a/polymer/eduke32/source/jaudiolib/pitch.h +++ b/polymer/eduke32/source/jaudiolib/pitch.h @@ -40,5 +40,5 @@ enum PITCH_ERRORS }; //void PITCH_Init( void ); -unsigned long PITCH_GetScale( int pitchoffset ); +unsigned int PITCH_GetScale( int pitchoffset ); #endif diff --git a/polymer/eduke32/source/jaudiolib/sdlmusic.c b/polymer/eduke32/source/jaudiolib/sdlmusic.c index 12857f781..1f011d3cb 100755 --- a/polymer/eduke32/source/jaudiolib/sdlmusic.c +++ b/polymer/eduke32/source/jaudiolib/sdlmusic.c @@ -187,7 +187,7 @@ void SafeWrite(int32 handle, void *buffer, int32 count) { iocount = count > 0x8000 ? 0x8000 : count; if (write(handle,buffer,iocount) != (int)iocount) - Error("File write failure writing %ld bytes",count); + Error("File write failure writing %d bytes",count); buffer = (void *)((byte *)buffer + iocount); count -= iocount; } @@ -470,10 +470,10 @@ void PlayMusic(char *_filename) //FixFilePath(filename); char filename[BMAX_PATH]; - long handle; - long size; + int handle; + int size; void *song; - long rc; + int rc; MUSIC_StopSong(); @@ -550,13 +550,13 @@ int MUSIC_GetContext(void) } // MUSIC_GetContext -void MUSIC_SetSongTick(unsigned long PositionInTicks) +void MUSIC_SetSongTick(unsigned int PositionInTicks) { musdebug("STUB ... MUSIC_SetSongTick().\n"); } // MUSIC_SetSongTick -void MUSIC_SetSongTime(unsigned long milliseconds) +void MUSIC_SetSongTime(unsigned int milliseconds) { musdebug("STUB ... MUSIC_SetSongTime().\n"); }// MUSIC_SetSongTime diff --git a/polymer/eduke32/source/jaudiolib/sdlout.c b/polymer/eduke32/source/jaudiolib/sdlout.c index 6aabba4a6..33f01e7d3 100644 --- a/polymer/eduke32/source/jaudiolib/sdlout.c +++ b/polymer/eduke32/source/jaudiolib/sdlout.c @@ -185,7 +185,7 @@ static void isr(void *userdata, unsigned char *stream, int len) { /* #define copybuf(S,D,c) \ - ({ void *__S=(S), *__D=(D); long __c=(c); \ + ({ void *__S=(S), *__D=(D); int __c=(c); \ __asm__ __volatile__ ("rep; movsl" \ : "+S" (__S), "+D" (__D), "+c" (__c) : : "memory", "cc"); \ 0; }) diff --git a/polymer/eduke32/source/jaudiolib/usrhooks.h b/polymer/eduke32/source/jaudiolib/usrhooks.h index 25e3fcf10..e28a62344 100644 --- a/polymer/eduke32/source/jaudiolib/usrhooks.h +++ b/polymer/eduke32/source/jaudiolib/usrhooks.h @@ -50,7 +50,7 @@ enum USRHOOKS_Errors Function Prototypes ---------------------------------------------------------------------*/ -int USRHOOKS_GetMem( void **ptr, unsigned long size ); +int USRHOOKS_GetMem( void **ptr, unsigned int size ); int USRHOOKS_FreeMem( void *ptr ); #endif diff --git a/polymer/eduke32/source/jmact/control.c b/polymer/eduke32/source/jmact/control.c index c3f9e85b9..b835e7442 100644 --- a/polymer/eduke32/source/jmact/control.c +++ b/polymer/eduke32/source/jmact/control.c @@ -233,7 +233,7 @@ void CONTROL_PrintKeyMap(void) void CONTROL_PrintControlFlag(int32 which) { - initprintf("function %2ld active=%d used=%d toggle=%d buttonheld=%d cleared=%ld\n", + initprintf("function %2ld active=%d used=%d toggle=%d buttonheld=%d cleared=%d\n", which, CONTROL_Flags[which].active, CONTROL_Flags[which].used, CONTROL_Flags[which].toggle, CONTROL_Flags[which].buttonheld, CONTROL_Flags[which].cleared); @@ -243,16 +243,16 @@ void CONTROL_PrintAxes(void) { int32 i; - initprintf("nummouseaxes=%ld\n", CONTROL_NumMouseAxes); + initprintf("nummouseaxes=%d\n", CONTROL_NumMouseAxes); for (i=0;i 8) { - long x,y,y1=0,y2=ydim; + int x,y,y1=0,y2=ydim; for (y=y1;y>1,512,TILE_LOADSHOT,-32,0,4+10+64,0,0,xdim-1,ydim-1); - sprintf(tempbuf,"PLAYERS: %-2ld ",ud.multimode); + sprintf(tempbuf,"PLAYERS: %-2d ",ud.multimode); gametext(160,156,tempbuf,0,2+8+16); - sprintf(tempbuf,"EPISODE: %-2ld / LEVEL: %-2ld / SKILL: %-2ld",1+ud.volume_number,1+ud.level_number,ud.player_skill); + sprintf(tempbuf,"EPISODE: %-2d / LEVEL: %-2d / SKILL: %-2d",1+ud.volume_number,1+ud.level_number,ud.player_skill); gametext(160,168,tempbuf,0,2+8+16); if (ud.volume_number == 0 && ud.level_number == 7) @@ -2488,7 +2488,7 @@ cheat_for_port_credits: gltexapplyprops(); } if (glanisotropy == 1) strcpy(tempbuf,"NONE"); - else sprintf(tempbuf,"%ldx",glanisotropy); + else sprintf(tempbuf,"%dx",glanisotropy); gametextpal(d,yy, tempbuf, MENUHIGHLIGHT(io), 0); break; @@ -2914,9 +2914,9 @@ cheat_for_port_credits: else vidsets[dax++] = 0x20000|validmode[day].bpp|((validmode[day].fs&1)<<16); } - for (dax = 0; dax < (long)(sizeof(vidsets)/sizeof(vidsets[1])) && vidsets[dax] != -1; dax++) + for (dax = 0; dax < (int)(sizeof(vidsets)/sizeof(vidsets[1])) && vidsets[dax] != -1; dax++) if (vidsets[dax] == (((getrendermode()>=2)<<17)|(fullscreen<<16)|bpp)) break; - if (dax < (long)(sizeof(vidsets)/sizeof(vidsets[1]))) newvidset = dax; + if (dax < (int)(sizeof(vidsets)/sizeof(vidsets[1]))) newvidset = dax; curvidset = newvidset; cmenu(203); @@ -3137,8 +3137,8 @@ cheat_for_port_credits: case 3: if (!changesmade) break; { - long pxdim, pydim, pfs, pbpp, prend; - long nxdim, nydim, nfs, nbpp, nrend; + int pxdim, pydim, pfs, pbpp, prend; + int nxdim, nydim, nfs, nbpp, nrend; pxdim = xdim; pydim = ydim; @@ -3215,7 +3215,7 @@ cheat_for_port_credits: } menutext(c,50,MENUHIGHLIGHT(0),0,"RESOLUTION"); - sprintf(tempbuf,"%ld x %ld", + sprintf(tempbuf,"%d x %d", (newvidmode==validmodecnt)?xdim:validmode[newvidmode].xdim, (newvidmode==validmodecnt)?ydim:validmode[newvidmode].ydim); gametext(c+154,50-8,tempbuf,MENUHIGHLIGHT(0),2+8+16); @@ -4342,9 +4342,9 @@ cheat_for_port_credits: if (current_menu >= 360 && current_menu <= 369) { - sprintf(tempbuf,"PLAYERS: %-2ld ",ud.multimode); + sprintf(tempbuf,"PLAYERS: %-2d ",ud.multimode); gametext(160,156,tempbuf,0,2+8+16); - sprintf(tempbuf,"EPISODE: %-2ld / LEVEL: %-2ld / SKILL: %-2ld",1+ud.volume_number,1+ud.level_number,ud.player_skill); + sprintf(tempbuf,"EPISODE: %-2d / LEVEL: %-2d / SKILL: %-2d",1+ud.volume_number,1+ud.level_number,ud.player_skill); gametext(160,168,tempbuf,0,2+8+16); if (ud.volume_number == 0 && ud.level_number == 7) gametext(160,180,boardfilename,0,2+8+16); @@ -4409,9 +4409,9 @@ cheat_for_port_credits: } rotatesprite(101<<16,97<<16,65536L>>1,512,TILE_LOADSHOT,-32,0,4+10+64,0,0,xdim-1,ydim-1); - sprintf(tempbuf,"PLAYERS: %-2ld ",savehead.numplr); + sprintf(tempbuf,"PLAYERS: %-2d ",savehead.numplr); gametext(160,156,tempbuf,0,2+8+16); - sprintf(tempbuf,"EPISODE: %-2ld / LEVEL: %-2ld / SKILL: %-2ld",1+savehead.volnum,1+savehead.levnum,savehead.plrskl); + sprintf(tempbuf,"EPISODE: %-2d / LEVEL: %-2d / SKILL: %-2d",1+savehead.volnum,1+savehead.levnum,savehead.plrskl); gametext(160,168,tempbuf,0,2+8+16); if (savehead.volnum == 0 && savehead.levnum == 7) gametext(160,180,savehead.boardfn,0,2+8+16); @@ -4428,9 +4428,9 @@ cheat_for_port_credits: rotatesprite(101<<16,97<<16,65536L>>1,512,TILE_LOADSHOT,-32,0,4+10+64,0,0,xdim-1,ydim-1); } else menutext(69,70,0,0,"EMPTY"); - sprintf(tempbuf,"PLAYERS: %-2ld ",ud.multimode); + sprintf(tempbuf,"PLAYERS: %-2d ",ud.multimode); gametext(160,156,tempbuf,0,2+8+16); - sprintf(tempbuf,"EPISODE: %-2ld / LEVEL: %-2ld / SKILL: %-2ld",1+ud.volume_number,1+ud.level_number,ud.player_skill); + sprintf(tempbuf,"EPISODE: %-2d / LEVEL: %-2d / SKILL: %-2d",1+ud.volume_number,1+ud.level_number,ud.player_skill); gametext(160,168,tempbuf,0,2+8+16); if (ud.volume_number == 0 && ud.level_number == 7) gametext(160,180,boardfilename,0,2+8+16); @@ -4992,16 +4992,16 @@ VOLUME_ALL_40x: if (VOLUMEONE) { - sprintf(tempbuf,"EPISODE %ld",ud.m_volume_number+1); + sprintf(tempbuf,"EPISODE %d",ud.m_volume_number+1); menutext(c,57+16-9,MENUHIGHLIGHT(1),1,tempbuf); } else { - sprintf(tempbuf,"EPISODE %ld",ud.m_volume_number+1); + sprintf(tempbuf,"EPISODE %d",ud.m_volume_number+1); menutext(c,57+16-9,MENUHIGHLIGHT(1),PHX(-3),tempbuf); } - sprintf(tempbuf,"LEVEL %ld",ud.m_level_number+1); + sprintf(tempbuf,"LEVEL %d",ud.m_level_number+1); menutext(c,57+16+16-9,MENUHIGHLIGHT(2),PHX(-4),tempbuf); menutext(c,57+16+16+16-9,MENUHIGHLIGHT(3),PHX(-5),"MONSTERS"); diff --git a/polymer/eduke32/source/namesdyn.c b/polymer/eduke32/source/namesdyn.c index e6f40b97c..4ecc9d775 100644 --- a/polymer/eduke32/source/namesdyn.c +++ b/polymer/eduke32/source/namesdyn.c @@ -768,7 +768,7 @@ unsigned short RESERVEDSLOT12 = 6143; unsigned short dynamictostatic[MAXTILES]; -void processnames(const char *szLabel, long lValue) +void processnames(const char *szLabel, int lValue) { switch (szLabel[0]) { diff --git a/polymer/eduke32/source/osdcmds.c b/polymer/eduke32/source/osdcmds.c index 56e50b6ad..ced03cad5 100644 --- a/polymer/eduke32/source/osdcmds.c +++ b/polymer/eduke32/source/osdcmds.c @@ -81,7 +81,7 @@ static int osdcmd_changelevel(const osdfuncparm_t *parm) { if (volume > num_volumes) { - OSD_Printf("changelevel: invalid volume number (range 1-%ld)\n",num_volumes); + OSD_Printf("changelevel: invalid volume number (range 1-%d)\n",num_volumes); return OSDCMD_OK; } } @@ -289,7 +289,7 @@ static int osdcmd_noclip(const osdfuncparm_t *parm) static int osdcmd_fileinfo(const osdfuncparm_t *parm) { - unsigned long crc, length; + unsigned int crc, length; int i,j; char buf[256]; @@ -437,7 +437,7 @@ static int osdcmd_setstatusbarscale(const osdfuncparm_t *parm) static int osdcmd_spawn(const osdfuncparm_t *parm) { - long x=0,y=0,z=0; + int x=0,y=0,z=0; unsigned short cstat=0,picnum=0; unsigned char pal=0; short ang=0; diff --git a/polymer/eduke32/source/osdfuncs.c b/polymer/eduke32/source/osdfuncs.c index 5e6908a8f..751509216 100644 --- a/polymer/eduke32/source/osdfuncs.c +++ b/polymer/eduke32/source/osdfuncs.c @@ -73,8 +73,8 @@ void GAME_onshowosd(int shown) #define PALETTE 4 void GAME_clearbackground(int c, int r) { - long x, y, xsiz, ysiz, tx2, ty2; - long daydim, bits; + int x, y, xsiz, ysiz, tx2, ty2; + int daydim, bits; if (getrendermode() < 3) bits = BITS; else bits = BITSTL; diff --git a/polymer/eduke32/source/player.c b/polymer/eduke32/source/player.c index 1c3a481cf..4b9939892 100644 --- a/polymer/eduke32/source/player.c +++ b/polymer/eduke32/source/player.c @@ -27,14 +27,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "duke3d.h" #include "osd.h" -long g_currentweapon; -long g_gun_pos; -long g_looking_arc; -long g_weapon_offset; -long g_gs; -long g_kb; -long g_looking_angSR1; -long g_weapon_xoffset; +int g_currentweapon; +int g_gun_pos; +int g_looking_arc; +int g_weapon_offset; +int g_gs; +int g_kb; +int g_looking_angSR1; +int g_weapon_xoffset; int32 turnheldtime; //MED int32 lastcontroltime; //MED @@ -57,7 +57,7 @@ void setpal(player_struct *p) static void incur_damage(player_struct *p) { - long damage = 0L, shield_damage = 0L; + int damage = 0L, shield_damage = 0L; SetGameVarID(g_iReturnVarID,0,p->i,sprite[p->i].yvel); OnEvent(EVENT_INCURDAMAGE, p->i, sprite[p->i].yvel, -1); @@ -107,9 +107,9 @@ void quickkill(player_struct *p) return; } -static void tracers(long x1,long y1,long z1,long x2,long y2,long z2,long n) +static void tracers(int x1,int y1,int z1,int x2,int y2,int z2,int n) { - long i, xv, yv, zv; + int i, xv, yv, zv; short sect = -1; i = n+1; @@ -136,9 +136,9 @@ static void tracers(long x1,long y1,long z1,long x2,long y2,long z2,long n) } } -static void hitscantrail(long x1, long y1, long z1, long x2, long y2, long z2, int ang, int atwith) +static void hitscantrail(int x1, int y1, int z1, int x2, int y2, int z2, int ang, int atwith) { - long xv, yv, zv, n, j, i; + int xv, yv, zv, n, j, i; short sect = -1; x1 += (sintable[(348+ang+512)&2047]/projectile[atwith].offset); @@ -174,11 +174,11 @@ static void hitscantrail(long x1, long y1, long z1, long x2, long y2, long z2, i } } -long hits(int i) +int hits(int i) { - long sx,sy,sz; + int sx,sy,sz; short sect,hw,hs; - long zoff; + int zoff; if (PN == APLAYER) zoff = (40<<8); else zoff = 0; @@ -196,8 +196,8 @@ static int aim(spritetype *s,int aang,int atwith) int gotshrinker,gotfreezer; int i, j, a, k, cans; int aimstats[] = {10,13,1,2}; - long dx1, dy1, dx2, dy2, dx3, dy3, smax, sdist; - long xv, yv; + int dx1, dy1, dx2, dy2, dx3, dy3, smax, sdist; + int xv, yv; if (s->picnum == APLAYER) { @@ -304,7 +304,7 @@ static int aim(spritetype *s,int aang,int atwith) int shoot(int i,int atwith) { short hitsect, hitspr, hitwall, l, sa, p, j, k=-1, wh, scount; - long sx, sy, sz, vel, zvel = 0, hitx, hity, hitz, x, oldzvel, dal; + int sx, sy, sz, vel, zvel = 0, hitx, hity, hitz, x, oldzvel, dal; unsigned char sizx,sizy; spritetype *s = &sprite[i]; short sect = s->sectnum; @@ -1664,12 +1664,12 @@ SKIPBULLETHOLE: if (j == 1) { - long lTripBombControl=GetGameVar("TRIPBOMB_CONTROL", TRIPBOMB_TRIPWIRE, g_player[p].ps->i, p); + int lTripBombControl=GetGameVar("TRIPBOMB_CONTROL", TRIPBOMB_TRIPWIRE, g_player[p].ps->i, p); k = EGS(hitsect,hitx,hity,hitz,TRIPBOMB,-16,4,5,sa,0,0,i,6); if (lTripBombControl & TRIPBOMB_TIMER) { - long lLifetime=GetGameVar("STICKYBOMB_LIFETIME", NAM_GRENADE_LIFETIME, g_player[p].ps->i, p); - long lLifetimeVar=GetGameVar("STICKYBOMB_LIFETIME_VAR", NAM_GRENADE_LIFETIME_VAR, g_player[p].ps->i, p); + int lLifetime=GetGameVar("STICKYBOMB_LIFETIME", NAM_GRENADE_LIFETIME, g_player[p].ps->i, p); + int lLifetimeVar=GetGameVar("STICKYBOMB_LIFETIME_VAR", NAM_GRENADE_LIFETIME_VAR, g_player[p].ps->i, p); // set timer. blows up when at zero.... hittype[k].temp_data[7]=lLifetime + mulscale(krand(),lLifetimeVar, 14) @@ -1847,7 +1847,7 @@ SKIPBULLETHOLE: static void displayloogie(int snum) { - long i, a, x, y, z; + int i, a, x, y, z; if (g_player[snum].ps->loogcnt == 0) return; @@ -1867,7 +1867,7 @@ static void displayloogie(int snum) static int animatefist(int gs,int snum) { int looking_arc,fisti,fistpal; - long fistzoom, fistz; + int fistzoom, fistz; fisti = g_player[snum].ps->fist_incs; if (fisti > 32) fisti = 32; @@ -1941,7 +1941,7 @@ static int animateknuckles(int gs,int snum) return 1; } -long lastvisinc; +int lastvisinc; void DoFire(player_struct *p) { @@ -2085,7 +2085,7 @@ static int animateaccess(int gs,int snum) return 1; } -static void myospalw(long x, long y, int tilenum, int shade, int orientation, int p) +static void myospalw(int x, int y, int tilenum, int shade, int orientation, int p) { if (!ud.drawweapon) return; @@ -2116,8 +2116,8 @@ static int fistsign, last_quick_kick[MAXPLAYERS]; void displayweapon(int snum) { - long gun_pos, looking_arc, cw; - long weapon_xoffset, i, j; + int gun_pos, looking_arc, cw; + int weapon_xoffset, i, j; int o = 0,pal; player_struct *p = g_player[snum].ps; short *kb = &p->kickback_pic; @@ -2702,7 +2702,7 @@ void displayweapon(int snum) #define MAXANGVEL 127 #define MAXHORIZ 127 -long myaimmode = 0, myaimstat = 0, omyaimstat = 0; +int myaimmode = 0, myaimstat = 0, omyaimstat = 0; int32 mouseyaxismode = -1; static ControlInfo lastinfo = { 0,0,0,0,0,0 }; int jump_input = 0; @@ -2727,7 +2727,7 @@ void getinput(int snum) loc.svel = svel = 0; loc.avel = angvel = 0; loc.horz = horiz = 0; - loc.bits = (((long)gamequit)<<26); + loc.bits = (((int)gamequit)<<26); loc.extbits = (g_player[snum].pteam != g_player[snum].ps->team)<<6; loc.extbits |= (1<<7); return; @@ -2867,7 +2867,7 @@ void getinput(int snum) loc.bits |= myaimmode<<23; loc.bits |= BUTTON(gamefunc_Holo_Duke)<<24; loc.bits |= BUTTON(gamefunc_Jetpack)<<25; - loc.bits |= (((long)gamequit)<<26); + loc.bits |= (((int)gamequit)<<26); loc.bits |= BUTTON(gamefunc_Inventory_Right)<<27; loc.bits |= BUTTON(gamefunc_TurnAround)<<28; loc.bits |= BUTTON(gamefunc_Open)<<29; @@ -3249,9 +3249,9 @@ void checkweapons(player_struct *p) void processinput(int snum) { - long j, i, k, doubvel, fz, cz, hz, lz, truefdist, x, y; + int j, i, k, doubvel, fz, cz, hz, lz, truefdist, x, y; int shrunk; - unsigned long sb_snum; + unsigned int sb_snum; int psect, psectlotag; short *kb, tempsect; player_struct *p = g_player[snum].ps; @@ -4179,7 +4179,7 @@ void processinput(int snum) else if (g_player[snum].sync->avel) //p->ang += syncangvel * constant { //ENGINE calculates angvel for you - long tempang = g_player[snum].sync->avel<<1; + int tempang = g_player[snum].sync->avel<<1; if (psectlotag == 2) p->angvel =(tempang-(tempang>>3))*ksgn(doubvel); else p->angvel = tempang*ksgn(doubvel); @@ -4743,7 +4743,7 @@ SHOOTINCODE: case TRIPBOMB_WEAPON: if (p->ammo_amount[p->curr_weapon] > 0) { - long sx,sy,sz; + int sx,sy,sz; short sect,hw,hitsp; hitscan(p->posx, p->posy, p->posz, @@ -4842,7 +4842,7 @@ SHOOTINCODE: (*kb)++; if ((*kb)==aplWeaponHoldDelay[p->curr_weapon][snum]) { - long lPipeBombControl; + int lPipeBombControl; p->ammo_amount[p->curr_weapon]--; @@ -4867,8 +4867,8 @@ SHOOTINCODE: if (lPipeBombControl & PIPEBOMB_TIMER) { - long lGrenadeLifetime=GetGameVar("GRENADE_LIFETIME", NAM_GRENADE_LIFETIME, -1, snum); - long lGrenadeLifetimeVar=GetGameVar("GRENADE_LIFETIME_VAR", NAM_GRENADE_LIFETIME_VAR, -1, snum); + int lGrenadeLifetime=GetGameVar("GRENADE_LIFETIME", NAM_GRENADE_LIFETIME, -1, snum); + int lGrenadeLifetimeVar=GetGameVar("GRENADE_LIFETIME_VAR", NAM_GRENADE_LIFETIME_VAR, -1, snum); hittype[j].temp_data[7]=lGrenadeLifetime + mulscale(krand(),lGrenadeLifetimeVar, 14) - lGrenadeLifetimeVar; @@ -4898,7 +4898,7 @@ SHOOTINCODE: } else if ((*kb) > aplWeaponTotalTime[p->curr_weapon][snum]) { - long lPipeBombControl=GetGameVar("PIPEBOMB_CONTROL", PIPEBOMB_REMOTE, -1, snum); + int lPipeBombControl=GetGameVar("PIPEBOMB_CONTROL", PIPEBOMB_REMOTE, -1, snum); (*kb) = 0; @@ -4937,7 +4937,7 @@ SHOOTINCODE: if ((*kb) >= aplWeaponTotalTime[p->curr_weapon][snum]) { - long lPipeBombControl=GetGameVar("PIPEBOMB_CONTROL", PIPEBOMB_REMOTE, -1, snum); + int lPipeBombControl=GetGameVar("PIPEBOMB_CONTROL", PIPEBOMB_REMOTE, -1, snum); (*kb) = 0; if ((p->ammo_amount[HANDBOMB_WEAPON] > 0) && lPipeBombControl == PIPEBOMB_REMOTE) addweapon(p,HANDBOMB_WEAPON); @@ -5099,7 +5099,7 @@ SHOOTINCODE: } //UPDATE THIS FILE OVER THE OLD GETSPRITESCORE/COMPUTERGETINPUT FUNCTIONS -int getspritescore(long snum, long dapicnum) +int getspritescore(int snum, int dapicnum) { switch (dynamictostatic[dapicnum]) { @@ -5188,7 +5188,7 @@ int getspritescore(long snum, long dapicnum) return(0); } -static long fdmatrix[12][12] = +static int fdmatrix[12][12] = { //KNEE PIST SHOT CHAIN RPG PIPE SHRI DEVI WALL FREE HAND EXPA { 128, -1, -1, -1, 128, -1, -1, -1, 128, -1, 128, -1 }, //KNEE @@ -5205,16 +5205,16 @@ static long fdmatrix[12][12] = { 128, 128, 128, 128,2560, 128,2560,2560, 128, 128, 128, 128 } //EXPA }; -static long goalx[MAXPLAYERS], goaly[MAXPLAYERS], goalz[MAXPLAYERS]; -static long goalsect[MAXPLAYERS], goalwall[MAXPLAYERS], goalsprite[MAXPLAYERS], goalspritescore[MAXPLAYERS]; -static long goalplayer[MAXPLAYERS], clipmovecount[MAXPLAYERS]; +static int goalx[MAXPLAYERS], goaly[MAXPLAYERS], goalz[MAXPLAYERS]; +static int goalsect[MAXPLAYERS], goalwall[MAXPLAYERS], goalsprite[MAXPLAYERS], goalspritescore[MAXPLAYERS]; +static int goalplayer[MAXPLAYERS], clipmovecount[MAXPLAYERS]; short searchsect[MAXSECTORS], searchparent[MAXSECTORS]; char dashow2dsector[(MAXSECTORS+7)>>3]; -void computergetinput(long snum, input *syn) +void computergetinput(int snum, input *syn) { - long i, j, k, l, x1, y1, z1, x2, y2, z2, x3, y3, z3, dx, dy; - long dist, daang, zang, fightdist, damyang, damysect; - long startsect, endsect, splc, send, startwall, endwall; + int i, j, k, l, x1, y1, z1, x2, y2, z2, x3, y3, z3, dx, dy; + int dist, daang, zang, fightdist, damyang, damysect; + int startsect, endsect, splc, send, startwall, endwall; short dasect, dawall, daspr; player_struct *p = g_player[snum].ps; walltype *wal; @@ -5328,7 +5328,7 @@ void computergetinput(long snum, input *syn) hitscan(sprite[j].x,sprite[j].y,sprite[j].z,sprite[j].sectnum, mulscale14(sprite[j].xvel,sintable[(sprite[j].ang+512)&2047]), mulscale14(sprite[j].xvel,sintable[sprite[j].ang&2047]), - (long)sprite[j].zvel, + (int)sprite[j].zvel, &dasect,&dawall,&daspr,&x3,&y3,&z3,CLIPMASK1); } } diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index c4a12f057..69cf0fdd8 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -273,7 +273,7 @@ static void cachegoodsprites(void) static int getsound(unsigned int num) { short fp; - long l; + int l; if (num >= MAXSOUNDS || ud.config.SoundToggle == 0) return 0; if (ud.config.FXDevice < 0) return 0; @@ -289,7 +289,7 @@ static int getsound(unsigned int num) (l < 12288)) { g_sounds[num].lock = 199; - allocache((long *)&g_sounds[num].ptr,l,(char *)&g_sounds[num].lock); + allocache((int *)&g_sounds[num].ptr,l,(char *)&g_sounds[num].lock); if (g_sounds[num].ptr != NULL) kread(fp, g_sounds[num].ptr , l); } @@ -319,7 +319,7 @@ static void precachenecessarysounds(void) static void dofrontscreens(char *statustext) { - long i=0,j; + int i=0,j; if (ud.recstat != 2) { @@ -393,9 +393,9 @@ static void dofrontscreens(char *statustext) void cacheit(void) { - long i,j,k, pc=0; - long tc; - unsigned long starttime, endtime; + int i,j,k, pc=0; + int tc; + unsigned int starttime, endtime; if (ud.recstat == 2) return; @@ -474,7 +474,7 @@ void cacheit(void) } if (totalclock - tc > TICRATE/4) { - sprintf(tempbuf,"Loading resources... %ld%%\n",min(100,100*pc/precachecount)); + sprintf(tempbuf,"Loading resources... %d%%\n",min(100,100*pc/precachecount)); dofrontscreens(tempbuf); tc = totalclock; } @@ -504,7 +504,7 @@ void xyzmirror(int i,int wn) void vscrn(void) { - long i, j, ss, x1, x2, y1, y2; + int i, j, ss, x1, x2, y1, y2; if (ud.screen_size < 0) ud.screen_size = 0; if (ud.screen_size > 64) ud.screen_size = 64; @@ -545,7 +545,7 @@ void pickrandomspot(int snum) { player_struct *p = g_player[snum].ps; int i=snum,j,k; - unsigned long dist,pdist = -1; + unsigned int dist,pdist = -1; if (ud.multimode > 1 && !(gametype_flags[ud.coop] & GAMETYPE_FLAG_FIXEDRESPAWN)) { @@ -1275,7 +1275,7 @@ int getteampal(int team) static void resetpspritevars(char g) { short i, j, nexti,circ; - long firstx,firsty; + int firstx,firsty; spritetype *s; char aimmode[MAXPLAYERS],autoaim[MAXPLAYERS],weaponswitch[MAXPLAYERS]; STATUSBARTYPE tsbar[MAXPLAYERS]; @@ -1466,7 +1466,7 @@ void resettimevars(void) void waitforeverybody() { - long i; + int i; if (numplayers < 2) return; packbuf[0] = 250; @@ -1634,7 +1634,7 @@ int enterlevel(int g) } else { - initprintf("Map E%ldL%ld not defined!\n",ud.volume_number+1,ud.level_number+1); + initprintf("Map E%dL%d not defined!\n",ud.volume_number+1,ud.level_number+1); return 1; } } @@ -1837,6 +1837,6 @@ int enterlevel(int g) // variables are set by pointer... OnEvent(EVENT_ENTERLEVEL, -1, -1, -1); - initprintf("E%ldL%ld: %s\n",ud.volume_number+1,ud.level_number+1,map[(ud.volume_number*MAXLEVELS)+ud.level_number].name); + initprintf("E%dL%d: %s\n",ud.volume_number+1,ud.level_number+1,map[(ud.volume_number*MAXLEVELS)+ud.level_number].name); return 0; } diff --git a/polymer/eduke32/source/rts.c b/polymer/eduke32/source/rts.c index 97b7c802b..bd79eecb4 100644 --- a/polymer/eduke32/source/rts.c +++ b/polymer/eduke32/source/rts.c @@ -246,7 +246,7 @@ void *RTS_GetSound(int32 lump) if (lumpcache[lump] == NULL) { lumplockbyte[lump] = 200; - allocache((long *)&lumpcache[lump],(long)RTS_SoundLength(lump-1),&lumplockbyte[lump]); // JBF 20030910: char * => long * + allocache((int *)&lumpcache[lump],(int)RTS_SoundLength(lump-1),&lumplockbyte[lump]); // JBF 20030910: char * => int * RTS_ReadLump(lump, lumpcache[lump]); } else diff --git a/polymer/eduke32/source/savegame.c b/polymer/eduke32/source/savegame.c index d7e3e32d8..46a8729e3 100644 --- a/polymer/eduke32/source/savegame.c +++ b/polymer/eduke32/source/savegame.c @@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void readsavenames(void) { - long dummy,j; + int dummy,j; int i; char fn[13]; BFILE *fil; @@ -37,7 +37,7 @@ void readsavenames(void) { fn[4] = i+'0'; if ((fil = Bfopen(fn,"rb")) == NULL) continue; - if (dfread(&j,sizeof(long),1,fil) != 1) + if (dfread(&j,sizeof(int),1,fil) != 1) { Bfclose(fil); continue; @@ -73,8 +73,8 @@ void readsavenames(void) int loadpheader(char spot,struct savehead *saveh) { char fn[13]; - long fil; - long bv; + int fil; + int bv; strcpy(fn, "egam0.sav"); fn[4] = spot+'0'; @@ -124,7 +124,7 @@ int loadplayer(int spot) char fn[13]; char mpfn[13]; char *fnptr, *scriptptrs; - long fil, bv, i, j, x; + int fil, bv, i, j, x; int32 nump; strcpy(fn, "egam0.sav"); @@ -247,8 +247,8 @@ int loadplayer(int spot) if (kdfread(&g_PlayerSpawnPoints,sizeof(g_PlayerSpawnPoints),1,fil) != 1) goto corrupt; if (kdfread(&numanimwalls,sizeof(numanimwalls),1,fil) != 1) goto corrupt; if (kdfread(&animwall,sizeof(animwall),1,fil) != 1) goto corrupt; - if (kdfread(&msx[0],sizeof(long),sizeof(msx)/sizeof(long),fil) != sizeof(msx)/sizeof(long)) goto corrupt; - if (kdfread(&msy[0],sizeof(long),sizeof(msy)/sizeof(long),fil) != sizeof(msy)/sizeof(long)) goto corrupt; + if (kdfread(&msx[0],sizeof(int),sizeof(msx)/sizeof(int),fil) != sizeof(msx)/sizeof(int)) goto corrupt; + if (kdfread(&msy[0],sizeof(int),sizeof(msy)/sizeof(int),fil) != sizeof(msy)/sizeof(int)) goto corrupt; if (kdfread((short *)&spriteqloc,sizeof(short),1,fil) != 1) goto corrupt; if (kdfread((short *)&spriteqamount,sizeof(short),1,fil) != 1) goto corrupt; if (kdfread((short *)&spriteq[0],sizeof(short),spriteqamount,fil) != spriteqamount) goto corrupt; @@ -268,12 +268,12 @@ int loadplayer(int spot) if (kdfread(&scriptptrs[0],sizeof(scriptptrs),g_ScriptSize,fil) != g_ScriptSize) goto corrupt; if (script != NULL) Bfree(script); - script = Bcalloc(1,g_ScriptSize * sizeof(long)); + script = Bcalloc(1,g_ScriptSize * sizeof(int)); if (kdfread(&script[0],sizeof(script),g_ScriptSize,fil) != g_ScriptSize) goto corrupt; for (i=0;i=0;i--) animateptr[i] = (long *)((long)animateptr[i]+(long)(§or[0])); + for (i = animatecnt-1;i>=0;i--) animateptr[i] = (int *)((int)animateptr[i]+(int)(§or[0])); if (kdfread(&animategoal[0],4,MAXANIMATES,fil) != MAXANIMATES) goto corrupt; if (kdfread(&animatevel[0],4,MAXANIMATES,fil) != MAXANIMATES) goto corrupt; @@ -357,7 +357,7 @@ int loadplayer(int spot) if (kdfread(&spritecache[0],sizeof(spritecache[0]),MAXTILES,fil) != MAXTILES) goto corrupt; - if (kdfread(&i,sizeof(long),1,fil) != 1) goto corrupt; + if (kdfread(&i,sizeof(int),1,fil) != 1) goto corrupt; while (i != MAXQUOTES) { @@ -367,7 +367,7 @@ int loadplayer(int spot) fta_quotes[i] = Bcalloc(MAXQUOTELEN,sizeof(char)); if (kdfread((char *)fta_quotes[i],MAXQUOTELEN,1,fil) != 1) goto corrupt; - if (kdfread(&i,sizeof(long),1,fil) != 1) goto corrupt; + if (kdfread(&i,sizeof(int),1,fil) != 1) goto corrupt; } if (kdfread(&redefined_quote_count,sizeof(redefined_quote_count),1,fil) != 1) goto corrupt; @@ -515,12 +515,12 @@ corrupt: int saveplayer(int spot) { - long i, j; + int i, j; char fn[13]; char mpfn[13]; char *fnptr, *scriptptrs; FILE *fil; - long bv = BYTEVERSION; + int bv = BYTEVERSION; strcpy(fn, "egam0.sav"); strcpy(mpfn, "egamA_00.sav"); @@ -573,7 +573,7 @@ int saveplayer(int spot) if (!waloff[TILE_SAVESHOT]) { walock[TILE_SAVESHOT] = 254; - allocache((long *)&waloff[TILE_SAVESHOT],200*320,&walock[TILE_SAVESHOT]); + allocache((int *)&waloff[TILE_SAVESHOT],200*320,&walock[TILE_SAVESHOT]); clearbuf((void*)waloff[TILE_SAVESHOT],(200*320)/4,0); walock[TILE_SAVESHOT] = 1; } @@ -598,8 +598,8 @@ int saveplayer(int spot) dfwrite(&g_PlayerSpawnPoints,sizeof(g_PlayerSpawnPoints),1,fil); dfwrite(&numanimwalls,sizeof(numanimwalls),1,fil); dfwrite(&animwall,sizeof(animwall),1,fil); - dfwrite(&msx[0],sizeof(long),sizeof(msx)/sizeof(long),fil); - dfwrite(&msy[0],sizeof(long),sizeof(msy)/sizeof(long),fil); + dfwrite(&msx[0],sizeof(int),sizeof(msx)/sizeof(int),fil); + dfwrite(&msy[0],sizeof(int),sizeof(msy)/sizeof(int),fil); dfwrite(&spriteqloc,sizeof(short),1,fil); dfwrite(&spriteqamount,sizeof(short),1,fil); dfwrite(&spriteq[0],sizeof(short),spriteqamount,fil); @@ -618,10 +618,10 @@ int saveplayer(int spot) scriptptrs = Bcalloc(1, g_ScriptSize * sizeof(scriptptrs)); for (i=0;i= (long)(&script[0]) && (long)script[i] < (long)(&script[g_ScriptSize])) + if ((int)script[i] >= (int)(&script[0]) && (int)script[i] < (int)(&script[g_ScriptSize])) { scriptptrs[i] = 1; - j = (long)script[i] - (long)&script[0]; + j = (int)script[i] - (int)&script[0]; script[i] = j; } else scriptptrs[i] = 0; @@ -633,36 +633,36 @@ int saveplayer(int spot) for (i=0;i= j && T2 < (long)(&script[g_ScriptSize])) + if (T2 >= j && T2 < (int)(&script[g_ScriptSize])) { scriptptrs[i] |= 1; T2 -= j; } - if (T5 >= j && T5 < (long)(&script[g_ScriptSize])) + if (T5 >= j && T5 < (int)(&script[g_ScriptSize])) { scriptptrs[i] |= 2; T5 -= j; } - if (T6 >= j && T6 < (long)(&script[g_ScriptSize])) + if (T6 >= j && T6 < (int)(&script[g_ScriptSize])) { scriptptrs[i] |= 4; T6 -= j; @@ -697,7 +697,7 @@ int saveplayer(int spot) for (i=0;i=0;i--) animateptr[i] = (long *)((long)animateptr[i]-(long)(§or[0])); + for (i = animatecnt-1;i>=0;i--) animateptr[i] = (int *)((int)animateptr[i]-(int)(§or[0])); dfwrite(&animateptr[0],4,MAXANIMATES,fil); - for (i = animatecnt-1;i>=0;i--) animateptr[i] = (long *)((long)animateptr[i]+(long)(§or[0])); + for (i = animatecnt-1;i>=0;i--) animateptr[i] = (int *)((int)animateptr[i]+(int)(§or[0])); dfwrite(&animategoal[0],4,MAXANIMATES,fil); dfwrite(&animatevel[0],4,MAXANIMATES,fil); @@ -755,11 +755,11 @@ int saveplayer(int spot) { if (fta_quotes[i] != NULL) { - dfwrite(&i,sizeof(long),1,fil); + dfwrite(&i,sizeof(int),1,fil); dfwrite(fta_quotes[i],MAXQUOTELEN, 1, fil); } } - dfwrite(&i,sizeof(long),1,fil); + dfwrite(&i,sizeof(int),1,fil); dfwrite(&redefined_quote_count,sizeof(redefined_quote_count),1,fil); for (i=0;ix - s2->x; vy = s1->y - s2->y; ret = FindDistance2D(vx,vy); return(ret?ret:1); } -long dist(spritetype *s1,spritetype *s2) +int dist(spritetype *s1,spritetype *s2) { - long vx,vy,vz; + int vx,vy,vz; vx = s1->x - s2->x; vy = s1->y - s2->y; vz = s1->z - s2->z; return(FindDistance3D(vx,vy,vz>>4)); } -int findplayer(spritetype *s,long *d) +int findplayer(spritetype *s,int *d) { int j, closest_player; - long x, closest; + int x, closest; if (ud.multimode < 2) { @@ -242,10 +242,10 @@ int findplayer(spritetype *s,long *d) return closest_player; } -int findotherplayer(int p,long *d) +int findotherplayer(int p,int *d) { int j, closest_player; - long x, closest; + int x, closest; closest = 0x7fffffff; closest_player = p; @@ -268,7 +268,7 @@ int findotherplayer(int p,long *d) void doanimations(void) { - long i, j, a, p, v, dasect; + int i, j, a, p, v, dasect; for (i=animatecnt-1;i>=0;i--) { @@ -334,13 +334,13 @@ void doanimations(void) } } -int getanimationgoal(long *animptr) +int getanimationgoal(int *animptr) { - long i, j; + int i, j; j = -1; for (i=animatecnt-1;i>=0;i--) - if (animptr == (long *)animateptr[i]) + if (animptr == (int *)animateptr[i]) { j = i; break; @@ -348,9 +348,9 @@ int getanimationgoal(long *animptr) return(j); } -int setanimation(int animsect,long *animptr, long thegoal, long thevel) +int setanimation(int animsect,int *animptr, int thegoal, int thevel) { - long i, j; + int i, j; if (animatecnt >= MAXANIMATES-1) return(-1); @@ -406,7 +406,7 @@ void animatecamsprite(void) void animatewalls(void) { - long i, j, p, t; + int i, j, p, t; for (p=0;p < numanimwalls ;p++) // for(p=numanimwalls-1;p>=0;p--) @@ -538,7 +538,7 @@ int activatewarpelevators(int s,int d) //Parm = sectoreffectornum void operatesectors(int sn,int ii) { - long j=0, l, q, startwall, endwall; + int j=0, l, q, startwall, endwall; int i; sectortype *sptr = §or[sn]; @@ -582,8 +582,8 @@ void operatesectors(int sn,int ii) case 9: { - long dax,day,dax2,day2,sp; - long wallfind[2]; + int dax,day,dax2,day2,sp; + int wallfind[2]; startwall = sptr->wallptr; endwall = startwall+sptr->wallnum-1; @@ -1131,11 +1131,11 @@ void operateforcefields(int s, int low) } } -int checkhitswitch(int snum,long w,int switchtype) +int checkhitswitch(int snum,int w,int switchtype) { int switchpal, switchpicnum; int i, x, lotag,hitag,picnum,correctdips,numdips; - long sx,sy; + int sx,sy; if (w < 0) return 0; correctdips = 1; @@ -1615,7 +1615,7 @@ static void breakwall(int newpn,int spr,int dawallnum) lotsofglass(spr,dawallnum,10); } -void checkhitwall(int spr,int dawallnum,long x,long y,long z,int atwith) +void checkhitwall(int spr,int dawallnum,int x,int y,int z,int atwith) { short sn = -1; int j, i, darkestwall; @@ -2518,7 +2518,7 @@ void allignwarpelevators(void) void sharedkeys(int snum) { int i, k, dainv; - unsigned long sb_snum = g_player[snum].sync->bits, j; + unsigned int sb_snum = g_player[snum].sync->bits, j; player_struct *p = g_player[snum].ps; if (p->cheat_phase == 1) return; @@ -2815,8 +2815,8 @@ CHECKINV1: break; } - if ((unsigned long) GetGameVarID(g_iReturnVarID,p->i,snum) != j) - j = (unsigned long) GetGameVarID(g_iReturnVarID,p->i,snum); + if ((unsigned int) GetGameVarID(g_iReturnVarID,p->i,snum) != j) + j = (unsigned int) GetGameVarID(g_iReturnVarID,p->i,snum); if (p->reloading == 1) j = -1; @@ -2839,7 +2839,7 @@ CHECKINV1: { if (k == GROW_WEAPON) // JBF: this is handling next/previous with the grower selected { - if (j == (unsigned long)-1) + if (j == (unsigned int)-1) k = 5; else k = 7; @@ -2942,7 +2942,7 @@ CHECKINV1: sb_snum |= 1<<19; p->weapon_pos = -9; } - else if ((long)j >= 0 && p->gotweapon[j] && (unsigned long)p->curr_weapon != j) + else if ((int)j >= 0 && p->gotweapon[j] && (unsigned int)p->curr_weapon != j) switch (j) { case KNEE_WEAPON: @@ -3101,7 +3101,7 @@ CHECKINV1: { j = p->max_player_health-sprite[p->i].extra; - if ((unsigned long)p->firstaid_amount > j) + if ((unsigned int)p->firstaid_amount > j) { p->firstaid_amount -= j; sprite[p->i].extra = p->max_player_health; @@ -3167,9 +3167,9 @@ CHECKINV1: } } -long hitasprite(int i,short *hitsp) +int hitasprite(int i,short *hitsp) { - long sx,sy,sz,zoff; + int sx,sy,sz,zoff; short sect,hw; if (badguy(&sprite[i])) @@ -3188,9 +3188,9 @@ long hitasprite(int i,short *hitsp) return (FindDistance2D(sx-SX,sy-SY)); } -static long hitawall(player_struct *p,short *hitw) +static int hitawall(player_struct *p,short *hitw) { - long sx,sy,sz; + int sx,sy,sz; short sect,hs; hitscan(p->posx,p->posy,p->posz,p->cursectnum, @@ -3204,7 +3204,7 @@ static long hitawall(player_struct *p,short *hitw) void checksectors(int snum) { - long i = -1,oldz; + int i = -1,oldz; player_struct *p = g_player[snum].ps; short j,hitscanwall; diff --git a/polymer/eduke32/source/sounds.c b/polymer/eduke32/source/sounds.c index e750cdbcf..04d59e2f5 100644 --- a/polymer/eduke32/source/sounds.c +++ b/polymer/eduke32/source/sounds.c @@ -34,7 +34,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define LOUDESTVOLUME 150 -long backflag,numenvsnds; +int backflag,numenvsnds; /* =================== @@ -46,7 +46,7 @@ long backflag,numenvsnds; void SoundStartup(void) { - int32 status; + int status; // if they chose None lets return if (ud.config.FXDevice < 0) return; @@ -79,7 +79,7 @@ void SoundStartup(void) void SoundShutdown(void) { - int32 status; + int status; // if they chose None lets return if (ud.config.FXDevice < 0) @@ -103,7 +103,7 @@ void SoundShutdown(void) void MusicStartup(void) { - int32 status; + int status; // if they chose None lets return if (ud.config.MusicDevice < 0) @@ -141,7 +141,7 @@ void MusicStartup(void) void MusicShutdown(void) { - int32 status; + int status; // if they chose None lets return if (ud.config.MusicDevice < 0) @@ -191,7 +191,7 @@ void playmusic(const char *fn) { #if defined(_WIN32) short fp; - long l; + int l; if (fn == NULL) return; @@ -203,7 +203,7 @@ void playmusic(const char *fn) if (fp == -1) return; l = kfilelength(fp); - if (l >= (signed long)sizeof(MusicPtr)) + if (l >= (signed int)sizeof(MusicPtr)) { kclose(fp); return; @@ -228,7 +228,7 @@ void playmusic(const char *fn) int loadsound(unsigned int num) { - long fp, l; + int fp, l; if (num >= MAXSOUNDS || ud.config.SoundToggle == 0) return 0; if (ud.config.FXDevice < 0) return 0; @@ -247,15 +247,15 @@ int loadsound(unsigned int num) g_sounds[num].lock = 200; - allocache((long *)&g_sounds[num].ptr,l,(char *)&g_sounds[num].lock); + allocache((int *)&g_sounds[num].ptr,l,(char *)&g_sounds[num].lock); kread(fp, g_sounds[num].ptr , l); kclose(fp); return 1; } -int xyzsound(int num,int i,long x,long y,long z) +int xyzsound(int num,int i,int x,int y,int z) { - long sndist, cx, cy, cz, j,k; + int sndist, cx, cy, cz, j,k; int pitche,pitchs,cs; int voice, sndang, ca, pitch; @@ -407,7 +407,7 @@ void sound(int num) { int pitch,pitche,pitchs,cx; int voice; - long start; + int start; if (ud.config.FXDevice < 0) return; if (ud.config.SoundToggle==0) return; @@ -447,13 +447,13 @@ void sound(int num) { if (*g_sounds[num].ptr == 'C') { - start = (long)*(unsigned short *)(g_sounds[num].ptr + 0x14); + start = (int)*(unsigned short *)(g_sounds[num].ptr + 0x14); voice = FX_PlayLoopedVOC(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz, pitch,LOUDESTVOLUME,LOUDESTVOLUME,LOUDESTVOLUME,g_sounds[num].pr,num); } else { - start = (long)*(unsigned short *)(g_sounds[num].ptr + 0x14); + start = (int)*(unsigned short *)(g_sounds[num].ptr + 0x14); voice = FX_PlayLoopedWAV(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz, pitch,LOUDESTVOLUME,LOUDESTVOLUME,LOUDESTVOLUME,g_sounds[num].pr,num); } @@ -508,7 +508,7 @@ void stopenvsound(int num,int i) void pan3dsound(void) { - long sndist, sx, sy, sz, cx, cy, cz; + int sndist, sx, sy, sz, cx, cy, cz; int sndang,ca,j,k,i,cs; numenvsnds = 0; @@ -586,11 +586,11 @@ void pan3dsound(void) } } -void testcallback(unsigned long num) +void testcallback(unsigned int num) { int tempi,tempj,tempk; - if ((long)num < 0) + if ((int)num < 0) { if (lumplockbyte[-num] >= 200) lumplockbyte[-num]--; @@ -626,7 +626,7 @@ void testcallback(unsigned long num) void clearsoundlocks(void) { - long i; + int i; for (i=0;i= 200) diff --git a/polymer/eduke32/source/startgtk.game.c b/polymer/eduke32/source/startgtk.game.c index 2d1a3679d..c639cb708 100755 --- a/polymer/eduke32/source/startgtk.game.c +++ b/polymer/eduke32/source/startgtk.game.c @@ -114,7 +114,7 @@ static void PopulateForm(int pgs) if (validmode[i].fs != settings.fullscreen) continue; // all modes get added to the 3D mode list - Bsprintf(buf, "%ld x %ld %dbpp", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp); + Bsprintf(buf, "%d x %d %dbpp", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp); gtk_list_store_append(modes3d, &iter); gtk_list_store_set(modes3d, &iter, 0,buf, 1,i, -1); if (i == mode3d) diff --git a/polymer/eduke32/source/startwin.game.c b/polymer/eduke32/source/startwin.game.c index c7086b976..d8cdafaf8 100755 --- a/polymer/eduke32/source/startwin.game.c +++ b/polymer/eduke32/source/startwin.game.c @@ -85,7 +85,7 @@ static void PopulateForm(int pgs) if (validmode[i].fs != settings.fullscreen) continue; // all modes get added to the 3D mode list - Bsprintf(buf, "%ld x %ld %dbpp", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp); + Bsprintf(buf, "%d x %d %dbpp", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp); j = ComboBox_AddString(hwnd, buf); ComboBox_SetItemData(hwnd, j, i); if (i == mode) ComboBox_SetCurSel(hwnd, j); diff --git a/polymer/eduke32/source/testcd.c b/polymer/eduke32/source/testcd.c index 5bca4fc00..cef440b66 100644 --- a/polymer/eduke32/source/testcd.c +++ b/polymer/eduke32/source/testcd.c @@ -36,7 +36,7 @@ Replacement cd-auth routine by Jonathon Fowler. * of it all. Because it's amusing. Who cares? */ -char testcd(char *fn, long testsiz) +char testcd(char *fn, int testsiz) { DWORD driveletters; int i, fil, dalen;