diff --git a/polymer/eduke32/build/src/misc/enumdisplay.c b/polymer/eduke32/build/src/misc/enumdisplay.c index 1274bf14a..6fb98bda7 100644 --- a/polymer/eduke32/build/src/misc/enumdisplay.c +++ b/polymer/eduke32/build/src/misc/enumdisplay.c @@ -12,145 +12,145 @@ FILE *output = NULL; void usage(void) { - printf( - "enumdisplay by Jonathon Fowler (jf@jonof.id.au)\n" - "Options:\n" - " -h, -?, --help This message\n" - " -o Use different output file (default: " - DEFAULT_OUTPUT_FILE ", use - for stdout)\n" - ); + printf( + "enumdisplay by Jonathon Fowler (jf@jonof.id.au)\n" + "Options:\n" + " -h, -?, --help This message\n" + " -o Use different output file (default: " + DEFAULT_OUTPUT_FILE ", use - for stdout)\n" + ); } void dumpdevmode(DEVMODE *devmode) { - fprintf(output, "\tdmFields has"); - if (devmode->dmFields & DM_PELSWIDTH) fprintf(output, " DM_PELSWIDTH"); - if (devmode->dmFields & DM_PELSHEIGHT) fprintf(output, " DM_PELSHEIGHT"); - if (devmode->dmFields & DM_BITSPERPEL) fprintf(output, " DM_BITSPERPEL"); - fprintf(output, "\n\tdmPelsWidth = %d\n", devmode->dmPelsWidth); - fprintf(output, "\tdmPelsHeight = %d\n", devmode->dmPelsHeight); - fprintf(output, "\tdmBitsPerPel = %d\n", devmode->dmBitsPerPel); + fprintf(output, "\tdmFields has"); + if (devmode->dmFields & DM_PELSWIDTH) fprintf(output, " DM_PELSWIDTH"); + if (devmode->dmFields & DM_PELSHEIGHT) fprintf(output, " DM_PELSHEIGHT"); + if (devmode->dmFields & DM_BITSPERPEL) fprintf(output, " DM_BITSPERPEL"); + fprintf(output, "\n\tdmPelsWidth = %d\n", devmode->dmPelsWidth); + fprintf(output, "\tdmPelsHeight = %d\n", devmode->dmPelsHeight); + fprintf(output, "\tdmBitsPerPel = %d\n", devmode->dmBitsPerPel); } HRESULT WINAPI ddenum(DDSURFACEDESC *ddsd, VOID *udata) { - fprintf(output, "\tdwFlags has"); - if (ddsd->dwFlags & DDSD_WIDTH) fprintf(output, " DDSD_WIDTH"); - if (ddsd->dwFlags & DDSD_HEIGHT) fprintf(output, " DDSD_HEIGHT"); - if (ddsd->dwFlags & DDSD_PIXELFORMAT) fprintf(output, " DDSD_PIXELFORMAT"); - fprintf(output, "\n\tdwWidth = %d\n", ddsd->dwWidth); - fprintf(output, "\tdwHeight = %d\n", ddsd->dwHeight); - fprintf(output, "\tddpfPixelFormat.dwFlags has"); - if (ddsd->ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED1) fprintf(output, " DDPF_PALETTEINDEXED1"); - if (ddsd->ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED2) fprintf(output, " DDPF_PALETTEINDEXED2"); - if (ddsd->ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED4) fprintf(output, " DDPF_PALETTEINDEXED4"); - if (ddsd->ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED8) fprintf(output, " DDPF_PALETTEINDEXED8"); - if (ddsd->ddpfPixelFormat.dwFlags & DDPF_RGB) fprintf(output, " DDPF_RGB"); - fprintf(output, "\n\tddpfPixelFormat.dwRGBBitCount = %d\n", ddsd->ddpfPixelFormat.dwRGBBitCount); - fprintf(output, "\n"); + fprintf(output, "\tdwFlags has"); + if (ddsd->dwFlags & DDSD_WIDTH) fprintf(output, " DDSD_WIDTH"); + if (ddsd->dwFlags & DDSD_HEIGHT) fprintf(output, " DDSD_HEIGHT"); + if (ddsd->dwFlags & DDSD_PIXELFORMAT) fprintf(output, " DDSD_PIXELFORMAT"); + fprintf(output, "\n\tdwWidth = %d\n", ddsd->dwWidth); + fprintf(output, "\tdwHeight = %d\n", ddsd->dwHeight); + fprintf(output, "\tddpfPixelFormat.dwFlags has"); + if (ddsd->ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED1) fprintf(output, " DDPF_PALETTEINDEXED1"); + if (ddsd->ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED2) fprintf(output, " DDPF_PALETTEINDEXED2"); + if (ddsd->ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED4) fprintf(output, " DDPF_PALETTEINDEXED4"); + if (ddsd->ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED8) fprintf(output, " DDPF_PALETTEINDEXED8"); + if (ddsd->ddpfPixelFormat.dwFlags & DDPF_RGB) fprintf(output, " DDPF_RGB"); + fprintf(output, "\n\tddpfPixelFormat.dwRGBBitCount = %d\n", ddsd->ddpfPixelFormat.dwRGBBitCount); + fprintf(output, "\n"); - return(DDENUMRET_OK); + return(DDENUMRET_OK); } int InitDirectDraw(void) { - HRESULT result; - HRESULT (WINAPI *aDirectDrawCreate)(GUID *, LPDIRECTDRAW *, IUnknown *); - HRESULT (WINAPI *aDirectDrawEnumerate)(LPDDENUMCALLBACK, LPVOID); - DDCAPS ddcaps; + HRESULT result; + HRESULT (WINAPI *aDirectDrawCreate)(GUID *, LPDIRECTDRAW *, IUnknown *); + HRESULT (WINAPI *aDirectDrawEnumerate)(LPDDENUMCALLBACK, LPVOID); + DDCAPS ddcaps; - hDDrawDLL = LoadLibrary("DDRAW.DLL"); - if (!hDDrawDLL) { fprintf(output, "Failed loading DDRAW.DLL\n"); return -1; } + hDDrawDLL = LoadLibrary("DDRAW.DLL"); + if (!hDDrawDLL) { fprintf(output, "Failed loading DDRAW.DLL\n"); return -1; } - aDirectDrawEnumerate = (void *)GetProcAddress(hDDrawDLL, "DirectDrawEnumerateA"); - if (!aDirectDrawEnumerate) { fprintf(output, "Error fetching DirectDrawEnumerate\n"); return -1; } + aDirectDrawEnumerate = (void *)GetProcAddress(hDDrawDLL, "DirectDrawEnumerateA"); + if (!aDirectDrawEnumerate) { fprintf(output, "Error fetching DirectDrawEnumerate\n"); return -1; } - aDirectDrawCreate = (void *)GetProcAddress(hDDrawDLL, "DirectDrawCreate"); - if (!aDirectDrawCreate) { fprintf(output, "Error fetching DirectDrawCreate\n"); return -1; } + aDirectDrawCreate = (void *)GetProcAddress(hDDrawDLL, "DirectDrawCreate"); + if (!aDirectDrawCreate) { fprintf(output, "Error fetching DirectDrawCreate\n"); return -1; } - result = aDirectDrawCreate(NULL, &lpDD, NULL); - if (result != DD_OK) { fprintf(output, "DirectDrawCreate() failed (%d)\n", result); return -1; } + result = aDirectDrawCreate(NULL, &lpDD, NULL); + if (result != DD_OK) { fprintf(output, "DirectDrawCreate() failed (%d)\n", result); return -1; } - return 0; + return 0; } void UninitDirectDraw(void) { - if (lpDD) IDirectDraw_Release(lpDD); - lpDD = NULL; - if (hDDrawDLL) FreeLibrary(hDDrawDLL); - hDDrawDLL = NULL; + if (lpDD) IDirectDraw_Release(lpDD); + lpDD = NULL; + if (hDDrawDLL) FreeLibrary(hDDrawDLL); + hDDrawDLL = NULL; } int main(int argc, char **argv) { - int i; + int i; - DEVMODE devmode; - HRESULT hresult; + DEVMODE devmode; + HRESULT hresult; - for (i=1; i -#include -#include - - -char *WhatGUID(const GUID *guid) -{ - if (guid == &GUID_XAxis) return "&GUID_XAxis"; - if (guid == &GUID_YAxis) return "&GUID_YAxis"; - if (guid == &GUID_ZAxis) return "&GUID_ZAxis"; - if (guid == &GUID_RxAxis) return "&GUID_RxAxis"; - if (guid == &GUID_RyAxis) return "&GUID_RyAxis"; - if (guid == &GUID_RzAxis) return "&GUID_RzAxis"; - if (guid == &GUID_Slider) return "&GUID_Slider"; - - if (guid == &GUID_Button) return "&GUID_Button"; - if (guid == &GUID_Key) return "&GUID_Key"; - - if (guid == &GUID_POV) return "&GUID_POV"; - - if (guid == &GUID_Unknown) return "&GUID_Unknown"; - - return "NULL"; -} - - - -int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) -{ - FILE *fp; - DWORD i; - - fp = fopen("didf.txt", "w"); - if (!fp) return -1; - setvbuf(fp, NULL, _IONBF, 0); - - - fprintf(fp, - "// Keyboard\n" - "\n" - "static DIOBJECTDATAFORMAT c_dfDIKeyboard_odf[] = {\n" - ); - - for (i=0; i +#include +#include + + +char *WhatGUID(const GUID *guid) +{ + if (guid == &GUID_XAxis) return "&GUID_XAxis"; + if (guid == &GUID_YAxis) return "&GUID_YAxis"; + if (guid == &GUID_ZAxis) return "&GUID_ZAxis"; + if (guid == &GUID_RxAxis) return "&GUID_RxAxis"; + if (guid == &GUID_RyAxis) return "&GUID_RyAxis"; + if (guid == &GUID_RzAxis) return "&GUID_RzAxis"; + if (guid == &GUID_Slider) return "&GUID_Slider"; + + if (guid == &GUID_Button) return "&GUID_Button"; + if (guid == &GUID_Key) return "&GUID_Key"; + + if (guid == &GUID_POV) return "&GUID_POV"; + + if (guid == &GUID_Unknown) return "&GUID_Unknown"; + + return "NULL"; +} + + + +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) +{ + FILE *fp; + DWORD i; + + fp = fopen("didf.txt", "w"); + if (!fp) return -1; + setvbuf(fp, NULL, _IONBF, 0); + + + fprintf(fp, + "// Keyboard\n" + "\n" + "static DIOBJECTDATAFORMAT c_dfDIKeyboard_odf[] = {\n" + ); + + for (i=0; i -#include "SDL/SDL.h" - -int keytranslation[SDLK_LAST]; -char *keysyms[SDLK_LAST]; - -static int buildkeytranslationtable(void) -{ - memset(keytranslation,0,sizeof(keytranslation)); - memset(keysyms,0,sizeof(keysyms)); - -#define MAP(x,y) { \ - keytranslation[x] = y; \ - keysyms[x] = #x ; \ -} - MAP(SDLK_BACKSPACE, 0xe); - MAP(SDLK_TAB, 0xf); - MAP(SDLK_RETURN, 0x1c); - MAP(SDLK_PAUSE, 0x59); // 0x1d + 0x45 + 0x9d + 0xc5 - MAP(SDLK_ESCAPE, 0x1); - MAP(SDLK_SPACE, 0x39); - MAP(SDLK_EXCLAIM, 0x2); // '1' - MAP(SDLK_QUOTEDBL, 0x28); // ''' - MAP(SDLK_HASH, 0x4); // '3' - MAP(SDLK_DOLLAR, 0x5); // '4' - MAP(37, 0x6); // '5' <-- where's the keysym SDL guys? - MAP(SDLK_AMPERSAND, 0x8); // '7' - MAP(SDLK_QUOTE, 0x28); // ''' - MAP(SDLK_LEFTPAREN, 0xa); // '9' - MAP(SDLK_RIGHTPAREN, 0xb); // '0' - MAP(SDLK_ASTERISK, 0x9); // '8' - MAP(SDLK_PLUS, 0xd); // '=' - MAP(SDLK_COMMA, 0x33); - MAP(SDLK_MINUS, 0xc); - MAP(SDLK_PERIOD, 0x34); - MAP(SDLK_SLASH, 0x35); - MAP(SDLK_0, 0xb); - MAP(SDLK_1, 0x2); - MAP(SDLK_2, 0x3); - MAP(SDLK_3, 0x4); - MAP(SDLK_4, 0x5); - MAP(SDLK_5, 0x6); - MAP(SDLK_6, 0x7); - MAP(SDLK_7, 0x8); - MAP(SDLK_8, 0x9); - MAP(SDLK_9, 0xa); - MAP(SDLK_COLON, 0x27); - MAP(SDLK_SEMICOLON, 0x27); - MAP(SDLK_LESS, 0x33); - MAP(SDLK_EQUALS, 0xd); - MAP(SDLK_GREATER, 0x34); - MAP(SDLK_QUESTION, 0x35); - MAP(SDLK_AT, 0x3); // '2' - MAP(SDLK_LEFTBRACKET, 0x1a); - MAP(SDLK_BACKSLASH, 0x2b); - MAP(SDLK_RIGHTBRACKET, 0x1b); - MAP(SDLK_CARET, 0x7); // '7' - MAP(SDLK_UNDERSCORE, 0xc); - MAP(SDLK_BACKQUOTE, 0x29); - MAP(SDLK_a, 0x1e); - MAP(SDLK_b, 0x30); - MAP(SDLK_c, 0x2e); - MAP(SDLK_d, 0x20); - MAP(SDLK_e, 0x12); - MAP(SDLK_f, 0x21); - MAP(SDLK_g, 0x22); - MAP(SDLK_h, 0x23); - MAP(SDLK_i, 0x17); - MAP(SDLK_j, 0x24); - MAP(SDLK_k, 0x25); - MAP(SDLK_l, 0x26); - MAP(SDLK_m, 0x32); - MAP(SDLK_n, 0x31); - MAP(SDLK_o, 0x18); - MAP(SDLK_p, 0x19); - MAP(SDLK_q, 0x10); - MAP(SDLK_r, 0x13); - MAP(SDLK_s, 0x1f); - MAP(SDLK_t, 0x14); - MAP(SDLK_u, 0x16); - MAP(SDLK_v, 0x2f); - MAP(SDLK_w, 0x11); - MAP(SDLK_x, 0x2d); - MAP(SDLK_y, 0x15); - MAP(SDLK_z, 0x2c); - MAP(SDLK_DELETE, 0xd3); - MAP(SDLK_KP0, 0x52); - MAP(SDLK_KP1, 0x4f); - MAP(SDLK_KP2, 0x50); - MAP(SDLK_KP3, 0x51); - MAP(SDLK_KP4, 0x4b); - MAP(SDLK_KP5, 0x4c); - MAP(SDLK_KP6, 0x4d); - MAP(SDLK_KP7, 0x47); - MAP(SDLK_KP8, 0x48); - MAP(SDLK_KP9, 0x49); - MAP(SDLK_KP_PERIOD, 0x53); - MAP(SDLK_KP_DIVIDE, 0xb5); - MAP(SDLK_KP_MULTIPLY, 0x37); - MAP(SDLK_KP_MINUS, 0x4a); - MAP(SDLK_KP_PLUS, 0x4e); - MAP(SDLK_KP_ENTER, 0x9c); - //MAP(SDLK_KP_EQUALS, ); - MAP(SDLK_UP, 0xc8); - MAP(SDLK_DOWN, 0xd0); - MAP(SDLK_RIGHT, 0xcd); - MAP(SDLK_LEFT, 0xcb); - MAP(SDLK_INSERT, 0xd2); - MAP(SDLK_HOME, 0xc7); - MAP(SDLK_END, 0xcf); - MAP(SDLK_PAGEUP, 0xc9); - MAP(SDLK_PAGEDOWN, 0xd1); - MAP(SDLK_F1, 0x3b); - MAP(SDLK_F2, 0x3c); - MAP(SDLK_F3, 0x3d); - MAP(SDLK_F4, 0x3e); - MAP(SDLK_F5, 0x3f); - MAP(SDLK_F6, 0x40); - MAP(SDLK_F7, 0x41); - MAP(SDLK_F8, 0x42); - MAP(SDLK_F9, 0x43); - MAP(SDLK_F10, 0x44); - MAP(SDLK_F11, 0x57); - MAP(SDLK_F12, 0x58); - MAP(SDLK_NUMLOCK, 0x45); - MAP(SDLK_CAPSLOCK, 0x3a); - MAP(SDLK_SCROLLOCK, 0x46); - MAP(SDLK_RSHIFT, 0x36); - MAP(SDLK_LSHIFT, 0x2a); - MAP(SDLK_RCTRL, 0x9d); - MAP(SDLK_LCTRL, 0x1d); - MAP(SDLK_RALT, 0xb8); - MAP(SDLK_LALT, 0x38); - MAP(SDLK_LSUPER, 0xdb); // win l - MAP(SDLK_RSUPER, 0xdc); // win r - MAP(SDLK_PRINT, -2); // 0xaa + 0xb7 - MAP(SDLK_SYSREQ, 0x54); // alt+printscr - MAP(SDLK_BREAK, 0xb7); // ctrl+pause - MAP(SDLK_MENU, 0xdd); // win menu? -#undef MAP - - return 0; -} - -#undef main - -int main(int argc, char **argv) -{ - int i; - - buildkeytranslationtable(); - - for (i=0;i0) printf(", "); - if (i%8 == 7) printf("\n"); - printf("%d",keytranslation[i]); - } - - return 0; -} - +// gcc b.c -Lc:/mingw32/lib -lmingw32 -lSDLmain -lSDL + +#include +#include "SDL/SDL.h" + +int keytranslation[SDLK_LAST]; +char *keysyms[SDLK_LAST]; + +static int buildkeytranslationtable(void) +{ + memset(keytranslation,0,sizeof(keytranslation)); + memset(keysyms,0,sizeof(keysyms)); + +#define MAP(x,y) { \ + keytranslation[x] = y; \ + keysyms[x] = #x ; \ +} + MAP(SDLK_BACKSPACE, 0xe); + MAP(SDLK_TAB, 0xf); + MAP(SDLK_RETURN, 0x1c); + MAP(SDLK_PAUSE, 0x59); // 0x1d + 0x45 + 0x9d + 0xc5 + MAP(SDLK_ESCAPE, 0x1); + MAP(SDLK_SPACE, 0x39); + MAP(SDLK_EXCLAIM, 0x2); // '1' + MAP(SDLK_QUOTEDBL, 0x28); // ''' + MAP(SDLK_HASH, 0x4); // '3' + MAP(SDLK_DOLLAR, 0x5); // '4' + MAP(37, 0x6); // '5' <-- where's the keysym SDL guys? + MAP(SDLK_AMPERSAND, 0x8); // '7' + MAP(SDLK_QUOTE, 0x28); // ''' + MAP(SDLK_LEFTPAREN, 0xa); // '9' + MAP(SDLK_RIGHTPAREN, 0xb); // '0' + MAP(SDLK_ASTERISK, 0x9); // '8' + MAP(SDLK_PLUS, 0xd); // '=' + MAP(SDLK_COMMA, 0x33); + MAP(SDLK_MINUS, 0xc); + MAP(SDLK_PERIOD, 0x34); + MAP(SDLK_SLASH, 0x35); + MAP(SDLK_0, 0xb); + MAP(SDLK_1, 0x2); + MAP(SDLK_2, 0x3); + MAP(SDLK_3, 0x4); + MAP(SDLK_4, 0x5); + MAP(SDLK_5, 0x6); + MAP(SDLK_6, 0x7); + MAP(SDLK_7, 0x8); + MAP(SDLK_8, 0x9); + MAP(SDLK_9, 0xa); + MAP(SDLK_COLON, 0x27); + MAP(SDLK_SEMICOLON, 0x27); + MAP(SDLK_LESS, 0x33); + MAP(SDLK_EQUALS, 0xd); + MAP(SDLK_GREATER, 0x34); + MAP(SDLK_QUESTION, 0x35); + MAP(SDLK_AT, 0x3); // '2' + MAP(SDLK_LEFTBRACKET, 0x1a); + MAP(SDLK_BACKSLASH, 0x2b); + MAP(SDLK_RIGHTBRACKET, 0x1b); + MAP(SDLK_CARET, 0x7); // '7' + MAP(SDLK_UNDERSCORE, 0xc); + MAP(SDLK_BACKQUOTE, 0x29); + MAP(SDLK_a, 0x1e); + MAP(SDLK_b, 0x30); + MAP(SDLK_c, 0x2e); + MAP(SDLK_d, 0x20); + MAP(SDLK_e, 0x12); + MAP(SDLK_f, 0x21); + MAP(SDLK_g, 0x22); + MAP(SDLK_h, 0x23); + MAP(SDLK_i, 0x17); + MAP(SDLK_j, 0x24); + MAP(SDLK_k, 0x25); + MAP(SDLK_l, 0x26); + MAP(SDLK_m, 0x32); + MAP(SDLK_n, 0x31); + MAP(SDLK_o, 0x18); + MAP(SDLK_p, 0x19); + MAP(SDLK_q, 0x10); + MAP(SDLK_r, 0x13); + MAP(SDLK_s, 0x1f); + MAP(SDLK_t, 0x14); + MAP(SDLK_u, 0x16); + MAP(SDLK_v, 0x2f); + MAP(SDLK_w, 0x11); + MAP(SDLK_x, 0x2d); + MAP(SDLK_y, 0x15); + MAP(SDLK_z, 0x2c); + MAP(SDLK_DELETE, 0xd3); + MAP(SDLK_KP0, 0x52); + MAP(SDLK_KP1, 0x4f); + MAP(SDLK_KP2, 0x50); + MAP(SDLK_KP3, 0x51); + MAP(SDLK_KP4, 0x4b); + MAP(SDLK_KP5, 0x4c); + MAP(SDLK_KP6, 0x4d); + MAP(SDLK_KP7, 0x47); + MAP(SDLK_KP8, 0x48); + MAP(SDLK_KP9, 0x49); + MAP(SDLK_KP_PERIOD, 0x53); + MAP(SDLK_KP_DIVIDE, 0xb5); + MAP(SDLK_KP_MULTIPLY, 0x37); + MAP(SDLK_KP_MINUS, 0x4a); + MAP(SDLK_KP_PLUS, 0x4e); + MAP(SDLK_KP_ENTER, 0x9c); + //MAP(SDLK_KP_EQUALS, ); + MAP(SDLK_UP, 0xc8); + MAP(SDLK_DOWN, 0xd0); + MAP(SDLK_RIGHT, 0xcd); + MAP(SDLK_LEFT, 0xcb); + MAP(SDLK_INSERT, 0xd2); + MAP(SDLK_HOME, 0xc7); + MAP(SDLK_END, 0xcf); + MAP(SDLK_PAGEUP, 0xc9); + MAP(SDLK_PAGEDOWN, 0xd1); + MAP(SDLK_F1, 0x3b); + MAP(SDLK_F2, 0x3c); + MAP(SDLK_F3, 0x3d); + MAP(SDLK_F4, 0x3e); + MAP(SDLK_F5, 0x3f); + MAP(SDLK_F6, 0x40); + MAP(SDLK_F7, 0x41); + MAP(SDLK_F8, 0x42); + MAP(SDLK_F9, 0x43); + MAP(SDLK_F10, 0x44); + MAP(SDLK_F11, 0x57); + MAP(SDLK_F12, 0x58); + MAP(SDLK_NUMLOCK, 0x45); + MAP(SDLK_CAPSLOCK, 0x3a); + MAP(SDLK_SCROLLOCK, 0x46); + MAP(SDLK_RSHIFT, 0x36); + MAP(SDLK_LSHIFT, 0x2a); + MAP(SDLK_RCTRL, 0x9d); + MAP(SDLK_LCTRL, 0x1d); + MAP(SDLK_RALT, 0xb8); + MAP(SDLK_LALT, 0x38); + MAP(SDLK_LSUPER, 0xdb); // win l + MAP(SDLK_RSUPER, 0xdc); // win r + MAP(SDLK_PRINT, -2); // 0xaa + 0xb7 + MAP(SDLK_SYSREQ, 0x54); // alt+printscr + MAP(SDLK_BREAK, 0xb7); // ctrl+pause + MAP(SDLK_MENU, 0xdd); // win menu? +#undef MAP + + return 0; +} + +#undef main + +int main(int argc, char **argv) +{ + int i; + + buildkeytranslationtable(); + + for (i=0;i0) printf(", "); + if (i%8 == 7) printf("\n"); + printf("%d",keytranslation[i]); + } + + return 0; +} + diff --git a/polymer/eduke32/build/src/util/bin2c.cpp b/polymer/eduke32/build/src/util/bin2c.cpp index e0f5fe4ea..98741b232 100644 --- a/polymer/eduke32/build/src/util/bin2c.cpp +++ b/polymer/eduke32/build/src/util/bin2c.cpp @@ -24,115 +24,115 @@ int PathAddExt(char *path, char *ext); int main(int argc, char *argv[]) { - printf("BIN2C - Binary to C data converter\n" - "Copyright (c) 1999 Jonathon Fowler\n\n"); + printf("BIN2C - Binary to C data converter\n" + "Copyright (c) 1999 Jonathon Fowler\n\n"); - if (argc < 4) - { - printf("Usage:\n" - " BIN2C source<.DAT> output<.C> b|w\n\n" - " source<.DAT> Binary source file\n" - " output<.C> Output C code file\n" - " b|w Byte or word-sized data\n\n"); - exit(0); - } + if (argc < 4) + { + printf("Usage:\n" + " BIN2C source<.DAT> output<.C> b|w\n\n" + " source<.DAT> Binary source file\n" + " output<.C> Output C code file\n" + " b|w Byte or word-sized data\n\n"); + exit(0); + } - int arg; - FILE *in, *out; - char datab1, datab2; - int across=0, maxacross; - int length, written=0; + int arg; + FILE *in, *out; + char datab1, datab2; + int across=0, maxacross; + int length, written=0; - // get the source file - strcpy(source, argv[1]); - strupr(source); - PathAddExt(source, defsrcext); - printf("þ Source file: %s\n", source); + // get the source file + strcpy(source, argv[1]); + strupr(source); + PathAddExt(source, defsrcext); + printf("þ Source file: %s\n", source); - // get the output file - strcpy(output, argv[2]); - strupr(output); - PathAddExt(output, defoutext); - printf("þ Output file: %s\n", output); + // get the output file + strcpy(output, argv[2]); + strupr(output); + PathAddExt(output, defoutext); + printf("þ Output file: %s\n", output); - // get byte/word data - switch (tolower(argv[3][0])) - { - case 'b': - printf("þ Byte data.\n"); - bytesize=1; - break; + // get byte/word data + switch (tolower(argv[3][0])) + { + case 'b': + printf("þ Byte data.\n"); + bytesize=1; + break; - case 'w': - printf("þ Word data.\n"); - bytesize=0; - break; + case 'w': + printf("þ Word data.\n"); + bytesize=0; + break; - default: - printf("þ Unknown data size specified. Defaulting to byte.\n"); - bytesize=1; - break; - } + default: + printf("þ Unknown data size specified. Defaulting to byte.\n"); + bytesize=1; + break; + } - // open the input file - in = fopen(source, "rb"); - if (!in) - { - printf("Error opening %s\n", source); - exit(1); - } + // open the input file + in = fopen(source, "rb"); + if (!in) + { + printf("Error opening %s\n", source); + exit(1); + } - // open the output file - out = fopen(output, "w+t"); - if (!out) - { - printf("Error creating %s\n", output); - exit(1); - } + // open the output file + out = fopen(output, "w+t"); + if (!out) + { + printf("Error creating %s\n", output); + exit(1); + } - length = filelength(fileno(in)); + length = filelength(fileno(in)); - // write a header out to the output file - fprintf(out, "// %s\n\n// Generated by BIN2C.EXE\n// By Jonathon Fowler\n\n", output); + // write a header out to the output file + fprintf(out, "// %s\n\n// Generated by BIN2C.EXE\n// By Jonathon Fowler\n\n", output); - // start a data block - fprintf(out, "%s datablock[] = {\n // %ld bytes", (bytesize) ? "char" : "unsigned", length); + // start a data block + fprintf(out, "%s datablock[] = {\n // %ld bytes", (bytesize) ? "char" : "unsigned", length); - if (bytesize) - maxacross = 12; - else - maxacross = 9; - across = maxacross; + if (bytesize) + maxacross = 12; + else + maxacross = 9; + across = maxacross; - // convert the data - for (written=0; written1) ? ',' : '\n'); - } else { - datab1 = fgetc(in); - datab2 = fgetc(in); - fprintf(out, " 0x%02X%02X%c", datab2, datab1, ((length-written)>2) ? ',' : '\n'); - } + if (bytesize) + { + datab1 = fgetc(in); + fprintf(out, " 0x%02X%c", datab1, ((length-written)>1) ? ',' : '\n'); + } else { + datab1 = fgetc(in); + datab2 = fgetc(in); + fprintf(out, " 0x%02X%02X%c", datab2, datab1, ((length-written)>2) ? ',' : '\n'); + } - across++; + across++; - if (!bytesize) written++; - } + if (!bytesize) written++; + } - fprintf(out, " };"); + fprintf(out, " };"); - fclose(out); - fclose(in); + fclose(out); + fclose(in); return 0; } @@ -141,13 +141,13 @@ int main(int argc, char *argv[]) // Add an extention to a path if one doesn't exist int PathAddExt(char *path, char *ext) { - char drive[MAXDRIVE], dir[MAXDIR], name[MAXFILE], extn[MAXEXT]; - int flags; + char drive[MAXDRIVE], dir[MAXDIR], name[MAXFILE], extn[MAXEXT]; + int flags; - flags = fnsplit(path, drive, dir, name, extn); + flags = fnsplit(path, drive, dir, name, extn); - if (!(flags & EXTENSION)) // tack on an extension - strcat(path, ext); + if (!(flags & EXTENSION)) // tack on an extension + strcat(path, ext); - return ((flags & EXTENSION) == 0); + return ((flags & EXTENSION) == 0); } diff --git a/polymer/eduke32/build/src/util/cacheinfo.c b/polymer/eduke32/build/src/util/cacheinfo.c index cc658719b..893ad3fcc 100644 --- a/polymer/eduke32/build/src/util/cacheinfo.c +++ b/polymer/eduke32/build/src/util/cacheinfo.c @@ -10,81 +10,81 @@ #define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 typedef struct { - char magic[8]; // 'Polymost' - int xdim, ydim; // of image, unpadded - int flags; // 1 = !2^x, 2 = has alpha, 4 = lzw compressed + char magic[8]; // 'Polymost' + int xdim, ydim; // of image, unpadded + int flags; // 1 = !2^x, 2 = has alpha, 4 = lzw compressed } texcacheheader; typedef struct { - int size; - int format; - int xdim, ydim; // of mipmap (possibly padded) - int border, depth; + int size; + int format; + int xdim, ydim; // of mipmap (possibly padded) + int border, depth; } texcachepicture; int main(void) { - DIR *dir; - struct dirent *dirent; - struct stat st; - FILE *fp; - texcacheheader head; - texcachepicture mip; - - dir = opendir("."); - while ((dirent = readdir(dir))) { - if (stat(dirent->d_name, &st)) { - printf("%s: failed to stat\n", dirent->d_name); - continue; - } - if (!(st.st_mode&S_IFREG)) { - printf("%s: not a regular file\n", dirent->d_name); - continue; - } - - fp = fopen(dirent->d_name,"rb"); - if (!fp) { - printf("%s: failed to open\n", dirent->d_name); - continue; - } - - if (fread(&head, sizeof(head), 1, fp) != 1) { - fclose(fp); - printf("%s: failed to read header\n", dirent->d_name); - continue; - } - head.xdim = B_LITTLE32(head.xdim); - head.ydim = B_LITTLE32(head.ydim); - head.flags = B_LITTLE32(head.flags); - if (fread(&mip, sizeof(mip), 1, fp) != 1) { - fclose(fp); - printf("%s: failed to read mipmap header\n", dirent->d_name); - continue; - } - mip.format = B_LITTLE32(mip.format); - fclose(fp); - if (memcmp(head.magic, "Polymost", 8)) { - printf("%s: bad signature\n", dirent->d_name); - continue; - } - else { - char *format; - char flags[4] = "", flagsc = 0; - switch (mip.format) { - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: format = "RGB DXT1"; break; - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: format = "RGBA DXT1"; break; - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: format = "RGBA DXT3"; break; - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: format = "RGBA DXT5"; break; - default: format = "Unknown"; break; - } - if (head.flags&1) flags[flagsc++] = '2'; - if (head.flags&2) flags[flagsc++] = 'A'; - if (head.flags&4) flags[flagsc++] = 'L'; - flags[flagsc++] = 0; - - printf("%s: flags=%s format=%s\n", dirent->d_name, flags, format); - } - } - closedir(dir); - - return 0; -} \ No newline at end of file + DIR *dir; + struct dirent *dirent; + struct stat st; + FILE *fp; + texcacheheader head; + texcachepicture mip; + + dir = opendir("."); + while ((dirent = readdir(dir))) { + if (stat(dirent->d_name, &st)) { + printf("%s: failed to stat\n", dirent->d_name); + continue; + } + if (!(st.st_mode&S_IFREG)) { + printf("%s: not a regular file\n", dirent->d_name); + continue; + } + + fp = fopen(dirent->d_name,"rb"); + if (!fp) { + printf("%s: failed to open\n", dirent->d_name); + continue; + } + + if (fread(&head, sizeof(head), 1, fp) != 1) { + fclose(fp); + printf("%s: failed to read header\n", dirent->d_name); + continue; + } + head.xdim = B_LITTLE32(head.xdim); + head.ydim = B_LITTLE32(head.ydim); + head.flags = B_LITTLE32(head.flags); + if (fread(&mip, sizeof(mip), 1, fp) != 1) { + fclose(fp); + printf("%s: failed to read mipmap header\n", dirent->d_name); + continue; + } + mip.format = B_LITTLE32(mip.format); + fclose(fp); + if (memcmp(head.magic, "Polymost", 8)) { + printf("%s: bad signature\n", dirent->d_name); + continue; + } + else { + char *format; + char flags[4] = "", flagsc = 0; + switch (mip.format) { + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: format = "RGB DXT1"; break; + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: format = "RGBA DXT1"; break; + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: format = "RGBA DXT3"; break; + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: format = "RGBA DXT5"; break; + default: format = "Unknown"; break; + } + if (head.flags&1) flags[flagsc++] = '2'; + if (head.flags&2) flags[flagsc++] = 'A'; + if (head.flags&4) flags[flagsc++] = 'L'; + flags[flagsc++] = 0; + + printf("%s: flags=%s format=%s\n", dirent->d_name, flags, format); + } + } + closedir(dir); + + return 0; +} diff --git a/polymer/eduke32/build/src/util/generateicon.c b/polymer/eduke32/build/src/util/generateicon.c index db5860a28..9b8386854 100644 --- a/polymer/eduke32/build/src/util/generateicon.c +++ b/polymer/eduke32/build/src/util/generateicon.c @@ -3,109 +3,109 @@ #include "compat.h" struct icon { - int width,height; - unsigned int *pixels; - unsigned char *mask; + int width,height; + unsigned int *pixels; + unsigned char *mask; }; int writeicon(FILE *fp, struct icon *ico) { - int i; - - fprintf(fp, - "#include \"sdlayer.h\"\n" - "\n" - ); - fprintf(fp,"static unsigned int sdlappicon_pixels[] = {\n"); - for (i=0;iwidth*ico->height;i++) { - if ((i%6) == 0) fprintf(fp,"\t"); - else fprintf(fp," "); - fprintf(fp, "0x%08x,", B_LITTLE32(ico->pixels[i])); - if ((i%6) == 5) fprintf(fp,"\n"); - } - if ((i%16) > 0) fprintf(fp, "\n"); - fprintf(fp, "};\n\n"); - - fprintf(fp,"static unsigned char sdlappicon_mask[] = {\n"); - for (i=0;i<((ico->width+7)/8)*ico->height;i++) { - if ((i%14) == 0) fprintf(fp,"\t"); - else fprintf(fp," "); - fprintf(fp, "%3d,", ico->mask[i]); - if ((i%14) == 13) fprintf(fp,"\n"); - } - if ((i%16) > 0) fprintf(fp, "\n"); - fprintf(fp, "};\n\n"); + int i; - fprintf(fp, - "struct sdlappicon sdlappicon = {\n" - " %d,%d, // width,height\n" - " sdlappicon_pixels,\n" - " sdlappicon_mask\n" - "};\n", - ico->width, ico->height - ); + fprintf(fp, + "#include \"sdlayer.h\"\n" + "\n" + ); + fprintf(fp,"static unsigned int sdlappicon_pixels[] = {\n"); + for (i=0;iwidth*ico->height;i++) { + if ((i%6) == 0) fprintf(fp,"\t"); + else fprintf(fp," "); + fprintf(fp, "0x%08x,", B_LITTLE32(ico->pixels[i])); + if ((i%6) == 5) fprintf(fp,"\n"); + } + if ((i%16) > 0) fprintf(fp, "\n"); + fprintf(fp, "};\n\n"); - return 0; + fprintf(fp,"static unsigned char sdlappicon_mask[] = {\n"); + for (i=0;i<((ico->width+7)/8)*ico->height;i++) { + if ((i%14) == 0) fprintf(fp,"\t"); + else fprintf(fp," "); + fprintf(fp, "%3d,", ico->mask[i]); + if ((i%14) == 13) fprintf(fp,"\n"); + } + if ((i%16) > 0) fprintf(fp, "\n"); + fprintf(fp, "};\n\n"); + + fprintf(fp, + "struct sdlappicon sdlappicon = {\n" + " %d,%d, // width,height\n" + " sdlappicon_pixels,\n" + " sdlappicon_mask\n" + "};\n", + ico->width, ico->height + ); + + return 0; } int main(int argc, char **argv) { - struct icon icon; - int bpl; - int i; - unsigned char *maskp, bm, *pp; + struct icon icon; + int bpl; + int i; + unsigned char *maskp, bm, *pp; - if (argc<2) { - fprintf(stderr, "generateicon \n"); - return 1; - } + if (argc<2) { + fprintf(stderr, "generateicon \n"); + return 1; + } - memset(&icon, 0, sizeof(icon)); + memset(&icon, 0, sizeof(icon)); - 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; - } + 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; + } - if (bpl != icon.width * 4) { - fprintf(stderr, "bpl != icon.width * 4\n"); - free(icon.pixels); - return 1; - } + if (bpl != icon.width * 4) { + fprintf(stderr, "bpl != icon.width * 4\n"); + free(icon.pixels); + return 1; + } - icon.mask = (unsigned char *)calloc(icon.height, (icon.width+7)/8); - if (!icon.mask) { - fprintf(stderr, "Out of memory\n"); - free(icon.pixels); - return 1; - } + icon.mask = (unsigned char *)calloc(icon.height, (icon.width+7)/8); + if (!icon.mask) { + fprintf(stderr, "Out of memory\n"); + free(icon.pixels); + return 1; + } - maskp = icon.mask; - bm = 1; - pp = (unsigned char *)icon.pixels; - for (i=0; i 0) *maskp |= bm; + { + unsigned char c = pp[0]; + pp[0] = pp[2]; + pp[2] = c; + } + if (pp[3] > 0) *maskp |= bm; - bm <<= 1; - pp += 4; - } + bm <<= 1; + pp += 4; + } - writeicon(stdout, &icon); - - free(icon.pixels); - free(icon.mask); + writeicon(stdout, &icon); - return 0; + free(icon.pixels); + free(icon.mask); + + return 0; } diff --git a/polymer/eduke32/build/src/util/kextract.c b/polymer/eduke32/build/src/util/kextract.c index ce2a158f3..c631270ff 100644 --- a/polymer/eduke32/build/src/util/kextract.c +++ b/polymer/eduke32/build/src/util/kextract.c @@ -18,68 +18,68 @@ static int fileoffs[MAXFILES+1], fileleng[MAXFILES]; void findfiles(const char *dafilespec) { - char t[13]; - int i; + char t[13]; + int i; - for(i=numfiles-1;i>=0;i--) - { - memcpy(t,filelist[i],12); - t[12] = 0; - - if (Bwildmatch(t,dafilespec)) { - marked4extraction[i] = 1; - anyfiles4extraction = 1; - } - } + for(i=numfiles-1;i>=0;i--) + { + memcpy(t,filelist[i],12); + t[12] = 0; + + if (Bwildmatch(t,dafilespec)) { + marked4extraction[i] = 1; + anyfiles4extraction = 1; + } + } } int main(int argc, char **argv) { - int i, j, k, l, fil, fil2; + int i, j, k, l, fil, fil2; - int onlylist = (argc==2); + int onlylist = (argc==2); - if (argc < 2) - { - printf("KEXTRACT [@file or filespec...] by Kenneth Silverman\n"); - printf(" This program extracts files from a previously grouped group file.\n"); - printf(" You can extract files using the ? and * wildcards.\n"); - printf(" Ex: kextract stuff.dat tiles000.art nukeland.map palette.dat\n"); - printf(" (stuff.dat is the group file, the rest are the files to extract)\n"); - printf(" kextract stuff.grp\n"); + if (argc < 2) + { + printf("KEXTRACT [@file or filespec...] by Kenneth Silverman\n"); + printf(" This program extracts files from a previously grouped group file.\n"); + printf(" You can extract files using the ? and * wildcards.\n"); + printf(" Ex: kextract stuff.dat tiles000.art nukeland.map palette.dat\n"); + printf(" (stuff.dat is the group file, the rest are the files to extract)\n"); + printf(" kextract stuff.grp\n"); printf(" (simply lists the contents of stuff.grp)\n"); - return(0); - } + return(0); + } - if ((fil = Bopen(argv[1],BO_BINARY|BO_RDONLY,BS_IREAD)) == -1) - { - printf("Error: %s could not be opened\n",argv[1]); - return(0); - } + if ((fil = Bopen(argv[1],BO_BINARY|BO_RDONLY,BS_IREAD)) == -1) + { + printf("Error: %s could not be opened\n",argv[1]); + return(0); + } - Bread(fil,buf,16); - if ((buf[0] != 'K') || (buf[1] != 'e') || (buf[2] != 'n') || - (buf[3] != 'S') || (buf[4] != 'i') || (buf[5] != 'l') || - (buf[6] != 'v') || (buf[7] != 'e') || (buf[8] != 'r') || - (buf[9] != 'm') || (buf[10] != 'a') || (buf[11] != 'n')) - { - Bclose(fil); - printf("Error: %s not a valid group file\n",argv[1]); - return(0); - } - numfiles = *((int*)&buf[12]); numfiles = B_LITTLE32(numfiles); + Bread(fil,buf,16); + if ((buf[0] != 'K') || (buf[1] != 'e') || (buf[2] != 'n') || + (buf[3] != 'S') || (buf[4] != 'i') || (buf[5] != 'l') || + (buf[6] != 'v') || (buf[7] != 'e') || (buf[8] != 'r') || + (buf[9] != 'm') || (buf[10] != 'a') || (buf[11] != 'n')) + { + Bclose(fil); + printf("Error: %s not a valid group file\n",argv[1]); + return(0); + } + numfiles = *((int*)&buf[12]); numfiles = B_LITTLE32(numfiles); - Bread(fil,filelist,numfiles<<4); + Bread(fil,filelist,numfiles<<4); - j = 0; - for(i=0;i1;i--) - { - if (argv[i][0] == '@') - { - if ((fil2 = Bopen(&argv[i][1],BO_BINARY|BO_RDONLY,BS_IREAD)) != -1) - { - l = Bread(fil2,buf,65536); - j = 0; - while ((j < l) && (buf[j] <= 32)) j++; - while (j < l) - { - k = j; - while ((k < l) && (buf[k] > 32)) k++; + anyfiles4extraction = 0; + for(i=argc-1;i>1;i--) + { + if (argv[i][0] == '@') + { + if ((fil2 = Bopen(&argv[i][1],BO_BINARY|BO_RDONLY,BS_IREAD)) != -1) + { + l = Bread(fil2,buf,65536); + j = 0; + while ((j < l) && (buf[j] <= 32)) j++; + while (j < l) + { + k = j; + while ((k < l) && (buf[k] > 32)) k++; - buf[k] = 0; - findfiles(&buf[j]); - j = k+1; + buf[k] = 0; + findfiles(&buf[j]); + j = k+1; - while ((j < l) && (buf[j] <= 32)) j++; - } - Bclose(fil2); - } - } - else - findfiles(argv[i]); - } + while ((j < l) && (buf[j] <= 32)) j++; + } + Bclose(fil2); + } + } + else + findfiles(argv[i]); + } - if (anyfiles4extraction == 0) - { - Bclose(fil); - printf("No files found in group file with those names\n"); - return(0); - } + if (anyfiles4extraction == 0) + { + Bclose(fil); + printf("No files found in group file with those names\n"); + return(0); + } - for(i=0;imode & BS_IFDIR) return 0; // is a directory - if (a->namlen > 12) return 0; // name too long - return Bwildmatch(a->name, matchstr); + if (a->mode & BS_IFDIR) return 0; // is a directory + if (a->namlen > 12) return 0; // name too long + return Bwildmatch(a->name, matchstr); } int filesize(const char *path, const char *name) { - char p[BMAX_PATH]; - struct stat st; + char p[BMAX_PATH]; + struct stat st; - strcpy(p, path); - strcat(p, "/"); - strcat(p, name); + strcpy(p, path); + strcat(p, "/"); + strcat(p, name); - if (!stat(p, &st)) return st.st_size; - return 0; + if (!stat(p, &st)) return st.st_size; + return 0; } void findfiles(const char *dafilespec) { - struct Bdirent *name; - int daspeclen; - char daspec[128], *dir; - BDIR *di; + struct Bdirent *name; + int daspeclen; + char daspec[128], *dir; + BDIR *di; - strcpy(daspec,dafilespec); - daspeclen=strlen(daspec); - while ((daspec[daspeclen] != '\\') && (daspec[daspeclen] != '/') && (daspeclen > 0)) daspeclen--; - if (daspeclen > 0) { - daspec[daspeclen]=0; - dir = daspec; - matchstr = &daspec[daspeclen+1]; - } else { - dir = "."; - matchstr = daspec; - } + strcpy(daspec,dafilespec); + daspeclen=strlen(daspec); + while ((daspec[daspeclen] != '\\') && (daspec[daspeclen] != '/') && (daspeclen > 0)) daspeclen--; + if (daspeclen > 0) { + daspec[daspeclen]=0; + dir = daspec; + matchstr = &daspec[daspeclen+1]; + } else { + dir = "."; + matchstr = daspec; + } - di = Bopendir(dir); - if (!di) return; + di = Bopendir(dir); + if (!di) return; - while ((name = Breaddir(di))) { - if (!checkmatch(name)) continue; + while ((name = Breaddir(di))) { + if (!checkmatch(name)) continue; - strcpy(&filelist[numfiles][0],name->name); - jstrupr(&filelist[numfiles][0]); - fileleng[numfiles] = name->size; - filelist[numfiles][12] = (char)(fileleng[numfiles]&255); - filelist[numfiles][13] = (char)((fileleng[numfiles]>>8)&255); - filelist[numfiles][14] = (char)((fileleng[numfiles]>>16)&255); - filelist[numfiles][15] = (char)((fileleng[numfiles]>>24)&255); + strcpy(&filelist[numfiles][0],name->name); + jstrupr(&filelist[numfiles][0]); + fileleng[numfiles] = name->size; + filelist[numfiles][12] = (char)(fileleng[numfiles]&255); + filelist[numfiles][13] = (char)((fileleng[numfiles]>>8)&255); + filelist[numfiles][14] = (char)((fileleng[numfiles]>>16)&255); + filelist[numfiles][15] = (char)((fileleng[numfiles]>>24)&255); - strcpy(filespec[numfiles],dir); - strcat(filespec[numfiles], "/"); - strcat(filespec[numfiles],name->name); + strcpy(filespec[numfiles],dir); + strcat(filespec[numfiles], "/"); + strcat(filespec[numfiles],name->name); - numfiles++; - if (numfiles > MAXFILES) - { - printf("FATAL ERROR: TOO MANY FILES SELECTED! (MAX is 4096)\n"); - exit(0); - } - } + numfiles++; + if (numfiles > MAXFILES) + { + printf("FATAL ERROR: TOO MANY FILES SELECTED! (MAX is 4096)\n"); + exit(0); + } + } - Bclosedir(di); + Bclosedir(di); } int main(int argc, char **argv) { - int i, j, k, l, fil, fil2; + int i, j, k, l, fil, fil2; - if (argc < 3) - { - printf("KGROUP [grouped file][@file or filespec...] by Kenneth Silverman\n"); - printf(" This program collects many files into 1 big uncompressed file called a\n"); - printf(" group file\n"); - printf(" Ex: kgroup stuff.dat *.art *.map *.k?? palette.dat tables.dat\n"); - printf(" (stuff.dat is the group file, the rest are the files to add)\n"); - exit(0); - } + if (argc < 3) + { + printf("KGROUP [grouped file][@file or filespec...] by Kenneth Silverman\n"); + printf(" This program collects many files into 1 big uncompressed file called a\n"); + printf(" group file\n"); + printf(" Ex: kgroup stuff.dat *.art *.map *.k?? palette.dat tables.dat\n"); + printf(" (stuff.dat is the group file, the rest are the files to add)\n"); + exit(0); + } - numfiles = 0; - for(i=argc-1;i>1;i--) - { - if (argv[i][0] == '@') - { - if ((fil = Bopen(&argv[i][1],BO_BINARY|BO_RDONLY,BS_IREAD)) != -1) - { - l = Bread(fil,buf,65536); - j = 0; - while ((j < l) && (buf[j] <= 32)) j++; - while (j < l) - { - k = j; - while ((k < l) && (buf[k] > 32)) k++; + numfiles = 0; + for(i=argc-1;i>1;i--) + { + if (argv[i][0] == '@') + { + if ((fil = Bopen(&argv[i][1],BO_BINARY|BO_RDONLY,BS_IREAD)) != -1) + { + l = Bread(fil,buf,65536); + j = 0; + while ((j < l) && (buf[j] <= 32)) j++; + while (j < l) + { + k = j; + while ((k < l) && (buf[k] > 32)) k++; - buf[k] = 0; - findfiles(&buf[j]); - j = k+1; + buf[k] = 0; + findfiles(&buf[j]); + j = k+1; - while ((j < l) && (buf[j] <= 32)) j++; - } - Bclose(fil); - } - } - else - findfiles(argv[i]); - } + while ((j < l) && (buf[j] <= 32)) j++; + } + Bclose(fil); + } + } + else + findfiles(argv[i]); + } - if ((fil = Bopen(argv[1],BO_BINARY|BO_TRUNC|BO_CREAT|BO_WRONLY,BS_IREAD|BS_IWRITE)) == -1) - { - printf("Error: %s could not be opened\n",argv[1]); - exit(0); - } - Bwrite(fil,"KenSilverman",12); - Bwrite(fil,&numfiles,4); - Bwrite(fil,filelist,numfiles<<4); + if ((fil = Bopen(argv[1],BO_BINARY|BO_TRUNC|BO_CREAT|BO_WRONLY,BS_IREAD|BS_IWRITE)) == -1) + { + printf("Error: %s could not be opened\n",argv[1]); + exit(0); + } + Bwrite(fil,"KenSilverman",12); + Bwrite(fil,&numfiles,4); + Bwrite(fil,filelist,numfiles<<4); - for(i=0;iid != 0x32504449) && (head->vers != 8)) { free(fbuf); puts("error"); return(0); } //"IDP2" - for(i=0;inumframes;i++) - { - fptr = (frametyp *)&fbuf[head->ofsframes+head->framebytes*i]; - printf("frame %2d scale:%f,%f,%f offs:%f,%f,%f\n",i,fptr->mul.x,fptr->mul.y,fptr->mul.z,fptr->add.x,fptr->add.y,fptr->add.z); - fptr->add.z += atof(argv[3]); - } + head = (md2typ *)fbuf; + if ((head->id != 0x32504449) && (head->vers != 8)) { free(fbuf); puts("error"); return(0); } //"IDP2" + for(i=0;inumframes;i++) + { + fptr = (frametyp *)&fbuf[head->ofsframes+head->framebytes*i]; + printf("frame %2d scale:%f,%f,%f offs:%f,%f,%f\n",i,fptr->mul.x,fptr->mul.y,fptr->mul.z,fptr->add.x,fptr->add.y,fptr->add.z); + fptr->add.z += atof(argv[3]); + } - fil = fopen(argv[2],"wb"); if (!fil) { puts("error"); return(0); } - fwrite(fbuf,leng,1,fil); - fclose(fil); + fil = fopen(argv[2],"wb"); if (!fil) { puts("error"); return(0); } + fwrite(fbuf,leng,1,fil); + fclose(fil); - free(fbuf); + free(fbuf); - return(0); + return(0); } #if 0 diff --git a/polymer/eduke32/build/src/util/md2tool.c b/polymer/eduke32/build/src/util/md2tool.c index 31ee05cd2..d9bf2b6e6 100644 --- a/polymer/eduke32/build/src/util/md2tool.c +++ b/polymer/eduke32/build/src/util/md2tool.c @@ -135,7 +135,7 @@ int main(int argc, char **argv) uint8_t maxv[3]={0,0,0}; uint8_t minv[3]={255,255,255}; - md2frame_t *fr; + md2frame_t *fr; uint8_t *vp; md2model_t *m; diff --git a/polymer/eduke32/build/src/util/transpal.c b/polymer/eduke32/build/src/util/transpal.c index 23ffdf06b..a2d7fa91f 100644 --- a/polymer/eduke32/build/src/util/transpal.c +++ b/polymer/eduke32/build/src/util/transpal.c @@ -27,244 +27,244 @@ static int colscan[27]; char getclosestcol(int r, int g, int b) { - int i, j, k, dist, mindist, retcol; - int *rlookup, *glookup, *blookup; - char *ptr; + int i, j, k, dist, mindist, retcol; + int *rlookup, *glookup, *blookup; + char *ptr; - if (closestcol[r][g][b] != 255) return(closestcol[r][g][b]); + if (closestcol[r][g][b] != 255) return(closestcol[r][g][b]); - j = (r>>3)*FASTPALGRIDSIZ*FASTPALGRIDSIZ+(g>>3)*FASTPALGRIDSIZ+(b>>3)+FASTPALGRIDSIZ*FASTPALGRIDSIZ+FASTPALGRIDSIZ+1; - mindist = min(rdist[coldist[r&7]+64+8],gdist[coldist[g&7]+64+8]); - mindist = min(mindist,bdist[coldist[b&7]+64+8]); - mindist++; + j = (r>>3)*FASTPALGRIDSIZ*FASTPALGRIDSIZ+(g>>3)*FASTPALGRIDSIZ+(b>>3)+FASTPALGRIDSIZ*FASTPALGRIDSIZ+FASTPALGRIDSIZ+1; + mindist = min(rdist[coldist[r&7]+64+8],gdist[coldist[g&7]+64+8]); + mindist = min(mindist,bdist[coldist[b&7]+64+8]); + mindist++; - rlookup = (int *)&rdist[64-r]; - glookup = (int *)&gdist[64-g]; - blookup = (int *)&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--) - { - i = colscan[k]+j; if ((colhere[i>>3]&(1<<(i&7))) == 0) continue; - for(i=colhead[i];i>=0;i=colnext[i]) - { - ptr = (char *)&palette[i*3]; - dist = glookup[ptr[1]]; if (dist >= mindist) continue; - dist += rlookup[ptr[0]]; if (dist >= mindist) continue; - dist += blookup[ptr[2]]; if (dist >= mindist) continue; - mindist = dist; retcol = i; - } - } - if (retcol < 0) - { - mindist = 0x7fffffff; - ptr = (char *)&palette[768-3]; - for(i=255;i>=0;i--,ptr-=3) - { - dist = glookup[ptr[1]]; if (dist >= mindist) continue; - dist += rlookup[ptr[0]]; if (dist >= mindist) continue; - dist += blookup[ptr[2]]; if (dist >= mindist) continue; - mindist = dist; retcol = i; - } - } - ptr = (char *)&closestcol[r][g][b]; - *ptr = retcol; - if ((r >= 4) && (ptr[(-2)<<12] == retcol)) ptr[(-3)<<12] = retcol, ptr[(-2)<<12] = retcol, ptr[(-1)<<12] = retcol; - if ((g >= 4) && (ptr[(-2)<<6] == retcol)) ptr[(-3)<<6] = retcol, ptr[(-2)<<6] = retcol, ptr[(-1)<<6] = retcol; - if ((b >= 4) && (ptr[(-2)] == retcol)) ptr[(-3)] = retcol, ptr[(-2)] = retcol, ptr[(-1)] = retcol; - if ((r < 64-4) && (ptr[(2)<<12] == retcol)) ptr[(3)<<12] = retcol, ptr[(2)<<12] = retcol, ptr[(1)<<12] = retcol; - if ((g < 64-4) && (ptr[(2)<<6] == retcol)) ptr[(3)<<6] = retcol, ptr[(2)<<6] = retcol, ptr[(1)<<6] = retcol; - if ((b < 64-4) && (ptr[(2)] == retcol)) ptr[(3)] = retcol, ptr[(2)] = retcol, ptr[(1)] = retcol; - if ((r >= 2) && (ptr[(-1)<<12] == retcol)) ptr[(-1)<<12] = retcol; - if ((g >= 2) && (ptr[(-1)<<6] == retcol)) ptr[(-1)<<6] = retcol; - if ((b >= 2) && (ptr[(-1)] == retcol)) ptr[(-1)] = retcol; - if ((r < 64-2) && (ptr[(1)<<12] == retcol)) ptr[(1)<<12] = retcol; - if ((g < 64-2) && (ptr[(1)<<6] == retcol)) ptr[(1)<<6] = retcol; - if ((b < 64-2) && (ptr[(1)] == retcol)) ptr[(1)] = retcol; - return(retcol); + retcol = -1; + for(k=26;k>=0;k--) + { + i = colscan[k]+j; if ((colhere[i>>3]&(1<<(i&7))) == 0) continue; + for(i=colhead[i];i>=0;i=colnext[i]) + { + ptr = (char *)&palette[i*3]; + dist = glookup[ptr[1]]; if (dist >= mindist) continue; + dist += rlookup[ptr[0]]; if (dist >= mindist) continue; + dist += blookup[ptr[2]]; if (dist >= mindist) continue; + mindist = dist; retcol = i; + } + } + if (retcol < 0) + { + mindist = 0x7fffffff; + ptr = (char *)&palette[768-3]; + for(i=255;i>=0;i--,ptr-=3) + { + dist = glookup[ptr[1]]; if (dist >= mindist) continue; + dist += rlookup[ptr[0]]; if (dist >= mindist) continue; + dist += blookup[ptr[2]]; if (dist >= mindist) continue; + mindist = dist; retcol = i; + } + } + ptr = (char *)&closestcol[r][g][b]; + *ptr = retcol; + if ((r >= 4) && (ptr[(-2)<<12] == retcol)) ptr[(-3)<<12] = retcol, ptr[(-2)<<12] = retcol, ptr[(-1)<<12] = retcol; + if ((g >= 4) && (ptr[(-2)<<6] == retcol)) ptr[(-3)<<6] = retcol, ptr[(-2)<<6] = retcol, ptr[(-1)<<6] = retcol; + if ((b >= 4) && (ptr[(-2)] == retcol)) ptr[(-3)] = retcol, ptr[(-2)] = retcol, ptr[(-1)] = retcol; + if ((r < 64-4) && (ptr[(2)<<12] == retcol)) ptr[(3)<<12] = retcol, ptr[(2)<<12] = retcol, ptr[(1)<<12] = retcol; + if ((g < 64-4) && (ptr[(2)<<6] == retcol)) ptr[(3)<<6] = retcol, ptr[(2)<<6] = retcol, ptr[(1)<<6] = retcol; + if ((b < 64-4) && (ptr[(2)] == retcol)) ptr[(3)] = retcol, ptr[(2)] = retcol, ptr[(1)] = retcol; + if ((r >= 2) && (ptr[(-1)<<12] == retcol)) ptr[(-1)<<12] = retcol; + if ((g >= 2) && (ptr[(-1)<<6] == retcol)) ptr[(-1)<<6] = retcol; + if ((b >= 2) && (ptr[(-1)] == retcol)) ptr[(-1)] = retcol; + if ((r < 64-2) && (ptr[(1)<<12] == retcol)) ptr[(1)<<12] = retcol; + if ((g < 64-2) && (ptr[(1)<<6] == retcol)) ptr[(1)<<6] = retcol; + if ((b < 64-2) && (ptr[(1)] == retcol)) ptr[(1)] = retcol; + return(retcol); } char getpalookup(char dashade, char dacol) { - int r, g, b, t; - char *ptr; + int r, g, b, t; + char *ptr; - ptr = (char *)&palette[dacol*3]; - t = divscale16(numpalookups-dashade,numpalookups); - r = ((ptr[0]*t+32768)>>16); - g = ((ptr[1]*t+32768)>>16); - b = ((ptr[2]*t+32768)>>16); - return(getclosestcol(r,g,b)); + ptr = (char *)&palette[dacol*3]; + t = divscale16(numpalookups-dashade,numpalookups); + r = ((ptr[0]*t+32768)>>16); + g = ((ptr[1]*t+32768)>>16); + b = ((ptr[2]*t+32768)>>16); + return(getclosestcol(r,g,b)); } char gettrans(char dat1, char dat2, int datransratio) { - int r, g, b; - char *ptr, *ptr2; + int r, g, b; + char *ptr, *ptr2; - ptr = (char *)&palette[dat1*3]; - ptr2 = (char *)&palette[dat2*3]; - r = ptr[0]; r += (((ptr2[0]-r)*datransratio+128)>>8); - g = ptr[1]; g += (((ptr2[1]-g)*datransratio+128)>>8); - b = ptr[2]; b += (((ptr2[2]-b)*datransratio+128)>>8); - return(getclosestcol(r,g,b)); + ptr = (char *)&palette[dat1*3]; + ptr2 = (char *)&palette[dat2*3]; + r = ptr[0]; r += (((ptr2[0]-r)*datransratio+128)>>8); + g = ptr[1]; g += (((ptr2[1]-g)*datransratio+128)>>8); + b = ptr[2]; b += (((ptr2[2]-b)*datransratio+128)>>8); + return(getclosestcol(r,g,b)); } void initfastcolorlookup(int rscale, int gscale, int bscale) { - int i, j, x, y, z; - char *ptr; + int i, j, x, y, z; + char *ptr; - j = 0; - for(i=64;i>=0;i--) - { - //j = (i-64)*(i-64); - rdist[i] = rdist[128-i] = j*rscale; - gdist[i] = gdist[128-i] = j*gscale; - bdist[i] = bdist[128-i] = j*bscale; - j += 129-(i<<1); - } + j = 0; + for(i=64;i>=0;i--) + { + //j = (i-64)*(i-64); + rdist[i] = rdist[128-i] = j*rscale; + gdist[i] = gdist[128-i] = j*gscale; + bdist[i] = bdist[128-i] = j*bscale; + j += 129-(i<<1); + } Bmemset(colhere, 0, sizeof(colhere)); Bmemset(colhead, 0, sizeof(colhead)); - ptr = (char *)&palette[768-3]; - for(i=255;i>=0;i--,ptr-=3) - { - j = (ptr[0]>>3)*FASTPALGRIDSIZ*FASTPALGRIDSIZ+(ptr[1]>>3)*FASTPALGRIDSIZ+(ptr[2]>>3)+FASTPALGRIDSIZ*FASTPALGRIDSIZ+FASTPALGRIDSIZ+1; - if (colhere[j>>3]&(1<<(j&7))) colnext[i] = colhead[j]; else colnext[i] = -1; - colhead[j] = i; - colhere[j>>3] |= (1<<(j&7)); - } + ptr = (char *)&palette[768-3]; + for(i=255;i>=0;i--,ptr-=3) + { + j = (ptr[0]>>3)*FASTPALGRIDSIZ*FASTPALGRIDSIZ+(ptr[1]>>3)*FASTPALGRIDSIZ+(ptr[2]>>3)+FASTPALGRIDSIZ*FASTPALGRIDSIZ+FASTPALGRIDSIZ+1; + if (colhere[j>>3]&(1<<(j&7))) colnext[i] = colhead[j]; else colnext[i] = -1; + colhead[j] = i; + colhere[j>>3] |= (1<<(j&7)); + } - i = 0; - for(x=-FASTPALGRIDSIZ*FASTPALGRIDSIZ;x<=FASTPALGRIDSIZ*FASTPALGRIDSIZ;x+=FASTPALGRIDSIZ*FASTPALGRIDSIZ) - for(y=-FASTPALGRIDSIZ;y<=FASTPALGRIDSIZ;y+=FASTPALGRIDSIZ) - for(z=-1;z<=1;z++) - colscan[i++] = x+y+z; - i = colscan[13]; colscan[13] = colscan[26]; colscan[26] = i; + i = 0; + for(x=-FASTPALGRIDSIZ*FASTPALGRIDSIZ;x<=FASTPALGRIDSIZ*FASTPALGRIDSIZ;x+=FASTPALGRIDSIZ*FASTPALGRIDSIZ) + for(y=-FASTPALGRIDSIZ;y<=FASTPALGRIDSIZ;y+=FASTPALGRIDSIZ) + for(z=-1;z<=1;z++) + colscan[i++] = x+y+z; + i = colscan[13]; colscan[13] = colscan[26]; colscan[26] = i; } int main(int argc, char **argv) { - char col, ch; - short orignumpalookups; - int fil, i, j, rscale, gscale, bscale; - char buf[65536]; + char col, ch; + short orignumpalookups; + int fil, i, j, rscale, gscale, bscale; + char buf[65536]; - ch = 13; - if (argc>1) { - if (argv[1][0] == '-') { - if (argv[1][1] == 't') { ch = 32; puts("Updating translucency table ONLY"); } - argc--; - argv++; - } - } + ch = 13; + if (argc>1) { + if (argv[1][0] == '-') { + if (argv[1][1] == 't') { ch = 32; puts("Updating translucency table ONLY"); } + argc--; + argv++; + } + } - if ((argc != 3) && (argc != 6)) - { - printf("TRANSPAL [-t] [numshades][trans#(0-inv,256-opa)][r][g][b] by Kenneth Silverman\n"); - printf(" Ex #1: transpal 32 170 30 59 11 (I use these values in my BUILD demo)\n"); - printf(" ÀÄÄÁÄÄÁÄÄÄ The RGB scales are optional\n"); - printf(" Ex #2: transpal 64 160\n\n"); - printf("Once tables are generated, the optional -t switch determines what to save:\n"); - printf(" Exclude -t to update both the shade table and transluscent table\n"); - printf(" Include -t to update the transluscent table ONLY\n"); - exit(0); - } + if ((argc != 3) && (argc != 6)) + { + printf("TRANSPAL [-t] [numshades][trans#(0-inv,256-opa)][r][g][b] by Kenneth Silverman\n"); + printf(" Ex #1: transpal 32 170 30 59 11 (I use these values in my BUILD demo)\n"); + printf(" ÀÄÄÁÄÄÁÄÄÄ The RGB scales are optional\n"); + printf(" Ex #2: transpal 64 160\n\n"); + printf("Once tables are generated, the optional -t switch determines what to save:\n"); + printf(" Exclude -t to update both the shade table and transluscent table\n"); + printf(" Include -t to update the transluscent table ONLY\n"); + exit(0); + } - strcpy(palettefilename,"palette.dat"); - numpalookups = atol(argv[1]); - transratio = atol(argv[2]); + strcpy(palettefilename,"palette.dat"); + numpalookups = atol(argv[1]); + transratio = atol(argv[2]); - if (argc == 6) - { - rscale = atol(argv[3]); - gscale = atol(argv[4]); - bscale = atol(argv[5]); - } - else - { - rscale = 30; - gscale = 59; - bscale = 11; - } + if (argc == 6) + { + rscale = atol(argv[3]); + gscale = atol(argv[4]); + bscale = atol(argv[5]); + } + else + { + rscale = 30; + gscale = 59; + bscale = 11; + } - if ((numpalookups < 1) || (numpalookups > 256)) - { printf("Invalid number of shades\n"); exit(0); } - if ((transratio < 0) || (transratio > 256)) - { printf("Invalid transluscent ratio\n"); exit(0); } + if ((numpalookups < 1) || (numpalookups > 256)) + { printf("Invalid number of shades\n"); exit(0); } + if ((transratio < 0) || (transratio > 256)) + { printf("Invalid transluscent ratio\n"); exit(0); } - if ((fil = Bopen(palettefilename,BO_BINARY|BO_RDONLY,BS_IREAD)) == -1) - { - printf("%s not found",palettefilename); - return(0); - } - Bread(fil,palette,768); - Bread(fil,&orignumpalookups,2); orignumpalookups = B_LITTLE16(orignumpalookups); - orignumpalookups = min(max(orignumpalookups,1),256); - Bread(fil,origpalookup,(int)orignumpalookups<<8); - Bclose(fil); + if ((fil = Bopen(palettefilename,BO_BINARY|BO_RDONLY,BS_IREAD)) == -1) + { + printf("%s not found",palettefilename); + return(0); + } + Bread(fil,palette,768); + Bread(fil,&orignumpalookups,2); orignumpalookups = B_LITTLE16(orignumpalookups); + orignumpalookups = min(max(orignumpalookups,1),256); + Bread(fil,origpalookup,(int)orignumpalookups<<8); + Bclose(fil); - clearbuf(buf,65536>>2,0L); + clearbuf(buf,65536>>2,0L); - initfastcolorlookup(rscale,gscale,bscale); - clearbuf(closestcol,262144>>2,0xffffffff); + initfastcolorlookup(rscale,gscale,bscale); + clearbuf(closestcol,262144>>2,0xffffffff); - for(i=0;i>2)+buf,(int)col); - drawpixel(((((i<<1)+1)*320+(j+8))>>2)+buf,(int)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++) - for(j=0;j<6;j++) - { - drawpixel((((j+132+0)*320+(i+8))>>2)+buf,i); + for(i=0;i<256;i++) + for(j=0;j<6;j++) + { + drawpixel((((j+132+0)*320+(i+8))>>2)+buf,i); - drawpixel((((i+132+8)*320+(j+0))>>2)+buf,i); - } + drawpixel((((i+132+8)*320+(j+0))>>2)+buf,i); + } - for(i=0;i<256;i++) - for(j=0;j<256;j++) - { - col = gettrans((char)i,(char)j,transratio); - transluc[(i<<8)+j] = col; + for(i=0;i<256;i++) + for(j=0;j<256;j++) + { + col = gettrans((char)i,(char)j,transratio); + transluc[(i<<8)+j] = col; - drawpixel((((j+132+8)*320+(i+8))>>2)+buf,(int)col); - } + drawpixel((((j+132+8)*320+(i+8))>>2)+buf,(int)col); + } - if (ch == 13) - { - short s; - if ((fil = Bopen(palettefilename,BO_BINARY|BO_TRUNC|BO_CREAT|BO_WRONLY,BS_IREAD|BS_IWRITE)) == -1) - { printf("Couldn't save file %s",palettefilename); return(0); } - Bwrite(fil,palette,768); - s = B_LITTLE16(numpalookups); Bwrite(fil,&s,2); - Bwrite(fil,palookup,numpalookups<<8); - Bwrite(fil,transluc,65536); - Bclose(fil); - printf("Shade table AND transluscent table updated\n"); - } - else if (ch == 32) - { - short s; - if ((fil = Bopen(palettefilename,BO_BINARY|BO_TRUNC|BO_CREAT|BO_WRONLY,BS_IREAD|BS_IWRITE)) == -1) - { printf("Couldn't save file %s",palettefilename); return(0); } - Bwrite(fil,palette,768); - s = B_LITTLE16(orignumpalookups); Bwrite(fil,&s,2); - Bwrite(fil,origpalookup,(int)orignumpalookups<<8); - Bwrite(fil,transluc,65536); - Bclose(fil); - printf("Transluscent table updated\n"); - } - else - printf("Palette file wasn't touched\n"); + if (ch == 13) + { + short s; + if ((fil = Bopen(palettefilename,BO_BINARY|BO_TRUNC|BO_CREAT|BO_WRONLY,BS_IREAD|BS_IWRITE)) == -1) + { printf("Couldn't save file %s",palettefilename); return(0); } + Bwrite(fil,palette,768); + s = B_LITTLE16(numpalookups); Bwrite(fil,&s,2); + Bwrite(fil,palookup,numpalookups<<8); + Bwrite(fil,transluc,65536); + Bclose(fil); + printf("Shade table AND transluscent table updated\n"); + } + else if (ch == 32) + { + short s; + if ((fil = Bopen(palettefilename,BO_BINARY|BO_TRUNC|BO_CREAT|BO_WRONLY,BS_IREAD|BS_IWRITE)) == -1) + { printf("Couldn't save file %s",palettefilename); return(0); } + Bwrite(fil,palette,768); + s = B_LITTLE16(orignumpalookups); Bwrite(fil,&s,2); + Bwrite(fil,origpalookup,(int)orignumpalookups<<8); + Bwrite(fil,transluc,65536); + Bclose(fil); + printf("Transluscent table updated\n"); + } + else + printf("Palette file wasn't touched\n"); - return 0; + return 0; } diff --git a/polymer/eduke32/build/src/util/vgafont.cpp b/polymer/eduke32/build/src/util/vgafont.cpp index a674f9ac7..ccca01c51 100644 --- a/polymer/eduke32/build/src/util/vgafont.cpp +++ b/polymer/eduke32/build/src/util/vgafont.cpp @@ -8,133 +8,133 @@ int main(void) { - int font, width, height, numchars; - struct REGPACK r; - FILE *fp; + int font, width, height, numchars; + struct REGPACK r; + FILE *fp; - printf("VGA Font Grabber\n" - "Copyright (c) 1997 Jonathon Fowler\n"); + printf("VGA Font Grabber\n" + "Copyright (c) 1997 Jonathon Fowler\n"); - do { - printf("\nSelect which font to grab:\n" - " 1. 8-by-8 ROM\n" - " 2. 8-by-14 ROM\n" - " 3. 8-by-16 ROM\n" - " 4. 9-by-16 ROM\n" - " 5. 9-by-14 ROM\n" - " 6. Quit\n" - " > "); - scanf("%d",&font); + do { + printf("\nSelect which font to grab:\n" + " 1. 8-by-8 ROM\n" + " 2. 8-by-14 ROM\n" + " 3. 8-by-16 ROM\n" + " 4. 9-by-16 ROM\n" + " 5. 9-by-14 ROM\n" + " 6. Quit\n" + " > "); + scanf("%d",&font); - switch (font) { - case 1: - printf("Getting 8-by-8 ROM font..."); + switch (font) { + case 1: + printf("Getting 8-by-8 ROM font..."); - if ((fp = fopen("88vga.dat", "wb")) != NULL) { - width = 8; - height = 8; - numchars = 256; + if ((fp = fopen("88vga.dat", "wb")) != NULL) { + width = 8; + height = 8; + numchars = 256; - r.r_ax = 0x1130; // locate the font (1st half) - r.r_bx = 0x0300; - intr(0x10, &r); + r.r_ax = 0x1130; // locate the font (1st half) + r.r_bx = 0x0300; + intr(0x10, &r); - fwrite(MK_FP(r.r_es, r.r_bp), 1, (8 * 128), fp); + fwrite(MK_FP(r.r_es, r.r_bp), 1, (8 * 128), fp); - r.r_ax = 0x1130; // locate the font (2nd half) - r.r_bx = 0x0400; - intr(0x10, &r); + r.r_ax = 0x1130; // locate the font (2nd half) + r.r_bx = 0x0400; + intr(0x10, &r); - fwrite(MK_FP(r.r_es, r.r_bp), 1, (8 * 128), fp); + fwrite(MK_FP(r.r_es, r.r_bp), 1, (8 * 128), fp); - fclose(fp); - } + fclose(fp); + } - printf("Done\n"); - break; - case 2: - printf("Getting 8-by-14 ROM font..."); + printf("Done\n"); + break; + case 2: + printf("Getting 8-by-14 ROM font..."); - if ((fp = fopen("814vga.dat", "wb")) != NULL) { - width = 8; - height = 14; - numchars = 256; + if ((fp = fopen("814vga.dat", "wb")) != NULL) { + width = 8; + height = 14; + numchars = 256; - r.r_ax = 0x1130; // locate the font - r.r_bx = 0x0200; - intr(0x10, &r); + r.r_ax = 0x1130; // locate the font + r.r_bx = 0x0200; + intr(0x10, &r); - fwrite(MK_FP(r.r_es, r.r_bp), 1, (14 * 256), fp); + fwrite(MK_FP(r.r_es, r.r_bp), 1, (14 * 256), fp); - fclose(fp); - } + fclose(fp); + } - printf("Done\n"); - break; - case 3: - printf("Getting 8-by-16 ROM font..."); + printf("Done\n"); + break; + case 3: + printf("Getting 8-by-16 ROM font..."); - if ((fp = fopen("816vga.dat", "wb")) != NULL) { - width = 8; - height = 16; - numchars = 256; + if ((fp = fopen("816vga.dat", "wb")) != NULL) { + width = 8; + height = 16; + numchars = 256; - r.r_ax = 0x1130; // locate the font - r.r_bx = 0x0600; - intr(0x10, &r); + r.r_ax = 0x1130; // locate the font + r.r_bx = 0x0600; + intr(0x10, &r); - fwrite(MK_FP(r.r_es, r.r_bp), 1, (16 * 256), fp); + fwrite(MK_FP(r.r_es, r.r_bp), 1, (16 * 256), fp); - fclose(fp); - } + fclose(fp); + } - printf("Done\n"); - break; - case 4: - printf("Getting 9-by-16 ROM font..."); + printf("Done\n"); + break; + case 4: + printf("Getting 9-by-16 ROM font..."); - if ((fp = fopen("916vga.dat", "wb")) != NULL) { - width = 9; - height = 16; - numchars = 256; + if ((fp = fopen("916vga.dat", "wb")) != NULL) { + width = 9; + height = 16; + numchars = 256; - r.r_ax = 0x1130; // locate the font - r.r_bx = 0x0700; - intr(0x10, &r); + r.r_ax = 0x1130; // locate the font + r.r_bx = 0x0700; + intr(0x10, &r); - fwrite(MK_FP(r.r_es, r.r_bp), 1, (16 * 256) *2, fp); + fwrite(MK_FP(r.r_es, r.r_bp), 1, (16 * 256) *2, fp); - fclose(fp); - } + fclose(fp); + } - printf("Done\n"); - break; - case 5: - printf("Getting 9-by-14 ROM font..."); + printf("Done\n"); + break; + case 5: + printf("Getting 9-by-14 ROM font..."); - if ((fp = fopen("914vga.dat", "wb")) != NULL) { - width = 9; - height = 16; - numchars = 256; + if ((fp = fopen("914vga.dat", "wb")) != NULL) { + width = 9; + height = 16; + numchars = 256; - r.r_ax = 0x1130; // locate the font - r.r_bx = 0x0500; - intr(0x10, &r); + r.r_ax = 0x1130; // locate the font + r.r_bx = 0x0500; + intr(0x10, &r); - fwrite(MK_FP(r.r_es, r.r_bp), 1, (14 * 256)* 2, fp); + fwrite(MK_FP(r.r_es, r.r_bp), 1, (14 * 256)* 2, fp); - fclose(fp); - } + fclose(fp); + } - printf("Done\n"); - break; - case 6: - break; - default: - printf("Please try again\n"); - break; - } - } while (font != 6); + printf("Done\n"); + break; + case 6: + break; + default: + printf("Please try again\n"); + break; + } + } while (font != 6); return 0; } diff --git a/polymer/eduke32/build/src/util/wad2art.c b/polymer/eduke32/build/src/util/wad2art.c index 8cb7746fd..3db1df891 100644 --- a/polymer/eduke32/build/src/util/wad2art.c +++ b/polymer/eduke32/build/src/util/wad2art.c @@ -22,78 +22,78 @@ static char screen[65536], tempbuf[131072]; void loadwadheader(void) { - int i, j; + int i, j; - Bread(fil1,&tempbuf[0],12); - 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>= 2; + i = 0; + while (Bstrncasecmp(wadata[i],"PLAYPAL",7) != 0) i++; + Blseek(fil1,wadplc[i],BSEEK_SET); + Bread(fil1,pal,768); + for(i=0;i<768;i++) pal[i] >>= 2; - i = 0; - while (Bstrncasecmp(wadata[i],"COLORMAP",8) != 0) i++; - Blseek(fil1,wadplc[i],BSEEK_SET); - Bread(fil1,palookup,8192); + i = 0; + while (Bstrncasecmp(wadata[i],"COLORMAP",8) != 0) i++; + Blseek(fil1,wadplc[i],BSEEK_SET); + Bread(fil1,palookup,8192); - if ((fil3 = Bopen("palette.dat",BO_BINARY|BO_TRUNC|BO_CREAT|BO_WRONLY,BS_IREAD|BS_IWRITE)) == -1) - { printf("Cannot save palette.dat\n"); exit(0); } - Bwrite(fil3,pal,768); - danumshades = 32; - Bwrite(fil3,&danumshades,2); - Bwrite(fil3,palookup,8192); - Bclose(fil3); + if ((fil3 = Bopen("palette.dat",BO_BINARY|BO_TRUNC|BO_CREAT|BO_WRONLY,BS_IREAD|BS_IWRITE)) == -1) + { printf("Cannot save palette.dat\n"); exit(0); } + Bwrite(fil3,pal,768); + danumshades = 32; + Bwrite(fil3,&danumshades,2); + Bwrite(fil3,palookup,8192); + Bclose(fil3); } void saveart (short tilenum, short xlen, short ylen) { - int i, x, p, pend; + int i, x, p, pend; - pend = ylookup[ylen]; + pend = ylookup[ylen]; - tilesizx[tilenum] = xlen; - tilesizy[tilenum] = ylen; - i = 0; - for(x=0;x 320) || (ysiz > 200)) goto skipit; - i = 8; - for(zx=0;zx>2,0xffffffff); + if (curplc != wadplc[z]) Blseek(fil1,wadplc[z],BSEEK_SET); + read(fil1,&tempbuf[0],wadlen[z]); + curplc = wadplc[z]+wadlen[z]; - for(x=0;x 320) || (ysiz > 200)) goto skipit; + i = 8; + for(zx=0;zx>2,0xffffffff); + + for(x=0;x> 24) + 4096]; - else c = shlookup[a >> 12]; - a >>= c&0xff; - a = (a&0xffff0000)|(sqrtable[a]); - a >>= ((c&0xff00) >> 8); + if (a & 0xff000000) c = shlookup[(a >> 24) + 4096]; + else c = shlookup[a >> 12]; + a >>= c&0xff; + a = (a&0xffff0000)|(sqrtable[a]); + a >>= ((c&0xff00) >> 8); - return a; + return a; } static inline int msqrtasm(unsigned int c) { - unsigned int a,b; + unsigned int a,b; - a = 0x40000000l; - b = 0x20000000l; - do { - if (c >= a) { - c -= a; - a += b*4; - } - a -= b; - a >>= 1; - b >>= 2; - } while (b); - if (c >= a) a++; - a >>= 1; - return a; + a = 0x40000000l; + b = 0x20000000l; + do { + if (c >= a) { + c -= a; + a += b*4; + } + a -= b; + a >>= 1; + b >>= 2; + } while (b); + if (c >= a) a++; + a >>= 1; + return a; } static void initksqrt(void) { - int i, j, k; + int i, j, k; - j = 1; k = 0; - for(i=0;i<4096;i++) - { - if (i >= j) { j <<= 2; k++; } - sqrtable[i] = (unsigned short)(msqrtasm((i<<18)+131072)<<1); - shlookup[i] = (k<<1)+((10-k)<<8); - if (i < 256) shlookup[i+4096] = ((k+6)<<1)+((10-(k+6))<<8); - } + j = 1; k = 0; + for(i=0;i<4096;i++) + { + if (i >= j) { j <<= 2; k++; } + sqrtable[i] = (unsigned short)(msqrtasm((i<<18)+131072)<<1); + shlookup[i] = (k<<1)+((10-k)<<8); + if (i < 256) shlookup[i+4096] = ((k+6)<<1)+((10-(k+6))<<8); + } } int inside(int x, int y, short sectnum) { - walltype *wal; - int i, x1, y1, x2, y2; - char cnt; + walltype *wal; + int i, x1, y1, x2, y2; + char cnt; - cnt = 0; + cnt = 0; - wal = &wall[sector[sectnum].wallptr]; - for(i=sector[sectnum].wallnum;i>0;i--) - { - y1 = wal->y-y; y2 = wall[wal->point2].y-y; - if ((y1^y2) < 0) - { - x1 = wal->x-x; x2 = wall[wal->point2].x-x; + wal = &wall[sector[sectnum].wallptr]; + for(i=sector[sectnum].wallnum;i>0;i--) + { + y1 = wal->y-y; y2 = wall[wal->point2].y-y; + if ((y1^y2) < 0) + { + x1 = wal->x-x; x2 = wall[wal->point2].x-x; - if ((x1^x2) < 0) - cnt ^= (x1*y2= 0) - cnt ^= 1; - } - wal++; - } - return(cnt); + if ((x1^x2) < 0) + cnt ^= (x1*y2= 0) + cnt ^= 1; + } + wal++; + } + return(cnt); } int readbyte(void) { - if (filpos >= fileng) return(-1); - if ((filpos&16383) == 0) Bread(filhandle,filebuf,16384); - filpos++; - return((int)filebuf[(filpos-1)&16383]); + if (filpos >= fileng) return(-1); + if ((filpos&16383) == 0) Bread(filhandle,filebuf,16384); + filpos++; + return((int)filebuf[(filpos-1)&16383]); } int readline(void) { - int i, ch; + int i, ch; - do - { - do - { - ch = readbyte(); - if (ch < 0) return(0); - } while ((ch == 13) || (ch == 10)); + do + { + do + { + ch = readbyte(); + if (ch < 0) return(0); + } while ((ch == 13) || (ch == 10)); - i = 0; tempbuf[0] = 0; - while ((ch != 13) && (ch != 10)) - { - if (ch < 0) return(0); - if (ch == ';') - { - do - { - if (ch < 0) return(0); - ch = readbyte(); - } while ((ch != 13) && (ch != 10)); - break; - } - if ((ch == 32) || (ch == 9)) ch = ','; - if ((ch != ',') || (i == 0) || (tempbuf[i-1] != ',')) - { tempbuf[i++] = ch; tempbuf[i] = 0; } - ch = readbyte(); - } - if ((i > 0) && (tempbuf[i-1] == ',')) tempbuf[i-1] = 0; - } while (i <= 0); - return(i); + i = 0; tempbuf[0] = 0; + while ((ch != 13) && (ch != 10)) + { + if (ch < 0) return(0); + if (ch == ';') + { + do + { + if (ch < 0) return(0); + ch = readbyte(); + } while ((ch != 13) && (ch != 10)); + break; + } + if ((ch == 32) || (ch == 9)) ch = ','; + if ((ch != ',') || (i == 0) || (tempbuf[i-1] != ',')) + { tempbuf[i++] = ch; tempbuf[i] = 0; } + ch = readbyte(); + } + if ((i > 0) && (tempbuf[i-1] == ',')) tempbuf[i-1] = 0; + } while (i <= 0); + return(i); } void parsescript(void) { - int i, j, k, l, lasti, breakout, tstart, tend, textnum = 0, frontbackstat; - int spritenumstat, slen; - char ch; + int i, j, k, l, lasti, breakout, tstart, tend, textnum = 0, frontbackstat; + int spritenumstat, slen; + char ch; - clearbufbyte(§spri[0], sizeof(short) * MAXSECTS * 8, 0xffffffff); + clearbufbyte(§spri[0], sizeof(short) * MAXSECTS * 8, 0xffffffff); - if (scriptname[0] == 0) - { - for(i=0;i<4096;i++) texturelookup[i] = i; - return; - } + if (scriptname[0] == 0) + { + for(i=0;i<4096;i++) texturelookup[i] = i; + return; + } - if ((filhandle = Bopen(scriptname,BO_BINARY|BO_RDONLY,BS_IREAD)) == -1) - { - printf("Could not find %s\n",scriptname); - exit(0); - } - filpos = 0; fileng = Bfilelength(filhandle); - while (readline() != 0) - { - i = 0; j = 0; lasti = 0; - while (1) - { - if ((tempbuf[i] == ',') || (tempbuf[i] == 0)) - { - if (tempbuf[i] == 0) { breakout = 1; } - else { breakout = 0, tempbuf[i] = 0; } + if ((filhandle = Bopen(scriptname,BO_BINARY|BO_RDONLY,BS_IREAD)) == -1) + { + printf("Could not find %s\n",scriptname); + exit(0); + } + filpos = 0; fileng = Bfilelength(filhandle); + while (readline() != 0) + { + i = 0; j = 0; lasti = 0; + while (1) + { + if ((tempbuf[i] == ',') || (tempbuf[i] == 0)) + { + if (tempbuf[i] == 0) { breakout = 1; } + else { breakout = 0, tempbuf[i] = 0; } - if (j == 0) - { - if (tempbuf[lasti] == '[') - { - definemode = 0; - thingtypemode = 0; - texturelookupmode = 0; - tagtypemode = 0; - sectypemode = 0; - } + if (j == 0) + { + if (tempbuf[lasti] == '[') + { + definemode = 0; + thingtypemode = 0; + texturelookupmode = 0; + tagtypemode = 0; + sectypemode = 0; + } - if (Bstrcasecmp(&tempbuf[lasti],"#define") == 0) - definemode = 1; + if (Bstrcasecmp(&tempbuf[lasti],"#define") == 0) + definemode = 1; - if (thingtypemode == 1) - { - thingoff[numthings] = thingopnum; + if (thingtypemode == 1) + { + thingoff[numthings] = thingopnum; - k = lasti; - while ((tempbuf[k] != 0) && (tempbuf[k] != '-')) k++; + k = lasti; + while ((tempbuf[k] != 0) && (tempbuf[k] != '-')) k++; - if (tempbuf[k] == '-') - { - tempbuf[k] = 0; - thingnum[numthings] = atol(&tempbuf[lasti]); - thingnum2[numthings] = atol(&tempbuf[k+1]); - } - else - { - thingnum[numthings] = atol(&tempbuf[lasti]); - thingnum2[numthings] = thingnum[numthings]; - } + if (tempbuf[k] == '-') + { + tempbuf[k] = 0; + thingnum[numthings] = atol(&tempbuf[lasti]); + thingnum2[numthings] = atol(&tempbuf[k+1]); + } + else + { + thingnum[numthings] = atol(&tempbuf[lasti]); + thingnum2[numthings] = thingnum[numthings]; + } - numthings++; - } - else if (Bstrcasecmp(&tempbuf[lasti],"[THINGTYPES]") == 0) - thingtypemode = 1; + numthings++; + } + else if (Bstrcasecmp(&tempbuf[lasti],"[THINGTYPES]") == 0) + thingtypemode = 1; - if (texturelookupmode == 1) - { - textnum = 0; - if ((tempbuf[lasti] >= 48) && (tempbuf[lasti] <= 57)) - { - k = lasti; - while ((tempbuf[k] != 0) && (tempbuf[k] != '-')) k++; + if (texturelookupmode == 1) + { + textnum = 0; + if ((tempbuf[lasti] >= 48) && (tempbuf[lasti] <= 57)) + { + k = lasti; + while ((tempbuf[k] != 0) && (tempbuf[k] != '-')) k++; - if (tempbuf[k] == '-') - { - tempbuf[k] = 0; - tstart = atol(&tempbuf[lasti]); - tend = atol(&tempbuf[k+1]); - for(k=tstart;k<=tend;k++) - tempshort[textnum++] = k; - } - else - tempshort[textnum++] = atol(&tempbuf[lasti]); - } - else - { - slen = 0; - while (tempbuf[lasti+slen] != 0) - { - ch = tempbuf[lasti+slen]; - if ((ch >= 97) && (ch <= 122)) tempbuf[lasti+slen] -= 32; - slen++; - } - if (slen > 0) - for(k=inumwads-1;k>=0;k--) - if ((iwadata[k][slen] == 0) || (iwadata[k][slen] == 32)) - if ((iwadata[k][slen-1] != 0) && (iwadata[k][slen-1] != 32)) - { - for(l=slen-1;l>=0;l--) - if (tempbuf[lasti+l] != '?') - { - ch = iwadata[k][l]; - if ((ch >= 97) && (ch <= 122)) ch -= 32; - if (tempbuf[lasti+l] != ch) break; - } - if (l < 0) tempshort[textnum++] = k; - } - } - } - else if (Bstrcasecmp(&tempbuf[lasti],"[TEXTURELOOKUPS]") == 0) - texturelookupmode = 1; + if (tempbuf[k] == '-') + { + tempbuf[k] = 0; + tstart = atol(&tempbuf[lasti]); + tend = atol(&tempbuf[k+1]); + for(k=tstart;k<=tend;k++) + tempshort[textnum++] = k; + } + else + tempshort[textnum++] = atol(&tempbuf[lasti]); + } + else + { + slen = 0; + while (tempbuf[lasti+slen] != 0) + { + ch = tempbuf[lasti+slen]; + if ((ch >= 97) && (ch <= 122)) tempbuf[lasti+slen] -= 32; + slen++; + } + if (slen > 0) + for(k=inumwads-1;k>=0;k--) + if ((iwadata[k][slen] == 0) || (iwadata[k][slen] == 32)) + if ((iwadata[k][slen-1] != 0) && (iwadata[k][slen-1] != 32)) + { + for(l=slen-1;l>=0;l--) + if (tempbuf[lasti+l] != '?') + { + ch = iwadata[k][l]; + if ((ch >= 97) && (ch <= 122)) ch -= 32; + if (tempbuf[lasti+l] != ch) break; + } + if (l < 0) tempshort[textnum++] = k; + } + } + } + else if (Bstrcasecmp(&tempbuf[lasti],"[TEXTURELOOKUPS]") == 0) + texturelookupmode = 1; - if (tagtypemode == 1) - { - tagoff[numtags] = tagopnum; + if (tagtypemode == 1) + { + tagoff[numtags] = tagopnum; - k = lasti; - while ((tempbuf[k] != 0) && (tempbuf[k] != '-')) k++; + k = lasti; + while ((tempbuf[k] != 0) && (tempbuf[k] != '-')) k++; - if (tempbuf[k] == '-') - { - tempbuf[k] = 0; - tagnum[numtags] = atol(&tempbuf[lasti]); - tagnum2[numtags] = atol(&tempbuf[k+1]); - } - else - { - tagnum[numtags] = atol(&tempbuf[lasti]); - tagnum2[numtags] = tagnum[numtags]; - } + if (tempbuf[k] == '-') + { + tempbuf[k] = 0; + tagnum[numtags] = atol(&tempbuf[lasti]); + tagnum2[numtags] = atol(&tempbuf[k+1]); + } + else + { + tagnum[numtags] = atol(&tempbuf[lasti]); + tagnum2[numtags] = tagnum[numtags]; + } - numtags++; - } - else if (Bstrcasecmp(&tempbuf[lasti],"[TAGCONVERSIONS]") == 0) - tagtypemode = 1; + numtags++; + } + else if (Bstrcasecmp(&tempbuf[lasti],"[TAGCONVERSIONS]") == 0) + tagtypemode = 1; - if (sectypemode == 1) - { - secoff[numsecs] = secopnum; + if (sectypemode == 1) + { + secoff[numsecs] = secopnum; - k = lasti; - while ((tempbuf[k] != 0) && (tempbuf[k] != '-')) k++; + k = lasti; + while ((tempbuf[k] != 0) && (tempbuf[k] != '-')) k++; - if (tempbuf[k] == '-') - { - tempbuf[k] = 0; - secnum[numsecs] = atol(&tempbuf[lasti]); - secnum2[numsecs] = atol(&tempbuf[k+1]); - } - else - { - secnum[numsecs] = atol(&tempbuf[lasti]); - secnum2[numsecs] = secnum[numsecs]; - } - numsecs++; - } - else if (Bstrcasecmp(&tempbuf[lasti],"[SECTORCONVERSIONS]") == 0) - sectypemode = 1; + if (tempbuf[k] == '-') + { + tempbuf[k] = 0; + secnum[numsecs] = atol(&tempbuf[lasti]); + secnum2[numsecs] = atol(&tempbuf[k+1]); + } + else + { + secnum[numsecs] = atol(&tempbuf[lasti]); + secnum2[numsecs] = secnum[numsecs]; + } + numsecs++; + } + else if (Bstrcasecmp(&tempbuf[lasti],"[SECTORCONVERSIONS]") == 0) + sectypemode = 1; - } - else if (j > 0) - { - if (definemode == 1) - { - defineptr[numdefines] = (char *)(&define[definecnt]); - for(k=lasti;k 0) + { + if (definemode == 1) + { + defineptr[numdefines] = (char *)(&define[definecnt]); + for(k=lasti;k= 48) && (tempbuf[k+1] <= 57)) - thingval[thingopnum] = atol(&tempbuf[k+1]); - else - { - for(l=0;l= 48) && (tempbuf[k+1] <= 57)) + thingval[thingopnum] = atol(&tempbuf[k+1]); + else + { + for(l=0;l= 48) && (tempbuf[lasti] <= 57)) - l = atol(&tempbuf[lasti]); - else - { - for(l=0;l=0;k--) texturelookup[tempshort[k]] = l; - } + if ((texturelookupmode == 1) && (j == 1)) + { + if ((tempbuf[lasti] >= 48) && (tempbuf[lasti] <= 57)) + l = atol(&tempbuf[lasti]); + else + { + for(l=0;l=0;k--) texturelookup[tempshort[k]] = l; + } - if (tagtypemode == 1) - { - for(k=lasti;k= 48) && (tempbuf[lasti] <= 57)) //1 DIGIT ONLY! - { - spritenumstat = tempbuf[lasti]-48; - lasti++; - } + spritenumstat = 0; + if ((tempbuf[lasti] >= 48) && (tempbuf[lasti] <= 57)) //1 DIGIT ONLY! + { + spritenumstat = tempbuf[lasti]-48; + lasti++; + } - if (Bstrcasecmp(&tempbuf[lasti],"sprite.x") == 0) tagfield[tagopnum] = 0; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.y") == 0) tagfield[tagopnum] = 1; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.z") == 0) tagfield[tagopnum] = 2; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.cstat") == 0) tagfield[tagopnum] = 3; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.shade") == 0) tagfield[tagopnum] = 4; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.pal") == 0) tagfield[tagopnum] = 5; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.clipdist") == 0) tagfield[tagopnum] = 6; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.xrepeat") == 0) tagfield[tagopnum] = 7; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.yrepeat") == 0) tagfield[tagopnum] = 8; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.xoffset") == 0) tagfield[tagopnum] = 9; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.yoffset") == 0) tagfield[tagopnum] = 10; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.picnum") == 0) tagfield[tagopnum] = 11; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.ang") == 0) tagfield[tagopnum] = 12; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.xvel") == 0) tagfield[tagopnum] = 13; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.yvel") == 0) tagfield[tagopnum] = 14; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.zvel") == 0) tagfield[tagopnum] = 15; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.owner") == 0) tagfield[tagopnum] = 16; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.sectnum") == 0) tagfield[tagopnum] = 17; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.statnum") == 0) tagfield[tagopnum] = 18; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.lotag") == 0) tagfield[tagopnum] = 19; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.hitag") == 0) tagfield[tagopnum] = 20; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.extra") == 0) tagfield[tagopnum] = 21; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.x") == 0) tagfield[tagopnum] = 0; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.y") == 0) tagfield[tagopnum] = 1; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.z") == 0) tagfield[tagopnum] = 2; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.cstat") == 0) tagfield[tagopnum] = 3; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.shade") == 0) tagfield[tagopnum] = 4; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.pal") == 0) tagfield[tagopnum] = 5; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.clipdist") == 0) tagfield[tagopnum] = 6; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.xrepeat") == 0) tagfield[tagopnum] = 7; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.yrepeat") == 0) tagfield[tagopnum] = 8; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.xoffset") == 0) tagfield[tagopnum] = 9; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.yoffset") == 0) tagfield[tagopnum] = 10; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.picnum") == 0) tagfield[tagopnum] = 11; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.ang") == 0) tagfield[tagopnum] = 12; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.xvel") == 0) tagfield[tagopnum] = 13; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.yvel") == 0) tagfield[tagopnum] = 14; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.zvel") == 0) tagfield[tagopnum] = 15; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.owner") == 0) tagfield[tagopnum] = 16; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.sectnum") == 0) tagfield[tagopnum] = 17; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.statnum") == 0) tagfield[tagopnum] = 18; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.lotag") == 0) tagfield[tagopnum] = 19; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.hitag") == 0) tagfield[tagopnum] = 20; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.extra") == 0) tagfield[tagopnum] = 21; - if (Bstrcasecmp(&tempbuf[lasti],"sector.wallptr") == 0) tagfield[tagopnum] = 32; - if (Bstrcasecmp(&tempbuf[lasti],"sector.wallnum") == 0) tagfield[tagopnum] = 33; - if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingpicnum") == 0) tagfield[tagopnum] = 34; - if (Bstrcasecmp(&tempbuf[lasti],"sector.floorpicnum") == 0) tagfield[tagopnum] = 35; - if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingheinum") == 0) tagfield[tagopnum] = 36; - if (Bstrcasecmp(&tempbuf[lasti],"sector.floorheinum") == 0) tagfield[tagopnum] = 37; - if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingz") == 0) tagfield[tagopnum] = 38; - if (Bstrcasecmp(&tempbuf[lasti],"sector.floorz") == 0) tagfield[tagopnum] = 39; - if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingshade") == 0) tagfield[tagopnum] = 40; - if (Bstrcasecmp(&tempbuf[lasti],"sector.floorshade") == 0) tagfield[tagopnum] = 41; - if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingxpanning") == 0) tagfield[tagopnum] = 42; - if (Bstrcasecmp(&tempbuf[lasti],"sector.floorxpanning") == 0) tagfield[tagopnum] = 43; - if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingypanning") == 0) tagfield[tagopnum] = 44; - if (Bstrcasecmp(&tempbuf[lasti],"sector.floorypanning") == 0) tagfield[tagopnum] = 45; - if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingstat") == 0) tagfield[tagopnum] = 46; - if (Bstrcasecmp(&tempbuf[lasti],"sector.floorstat") == 0) tagfield[tagopnum] = 47; - if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingpal") == 0) tagfield[tagopnum] = 48; - if (Bstrcasecmp(&tempbuf[lasti],"sector.floorpal") == 0) tagfield[tagopnum] = 49; - if (Bstrcasecmp(&tempbuf[lasti],"sector.visibility") == 0) tagfield[tagopnum] = 50; - if (Bstrcasecmp(&tempbuf[lasti],"sector.lotag") == 0) tagfield[tagopnum] = 51; - if (Bstrcasecmp(&tempbuf[lasti],"sector.hitag") == 0) tagfield[tagopnum] = 52; - if (Bstrcasecmp(&tempbuf[lasti],"sector.extra") == 0) tagfield[tagopnum] = 53; + if (Bstrcasecmp(&tempbuf[lasti],"sector.wallptr") == 0) tagfield[tagopnum] = 32; + if (Bstrcasecmp(&tempbuf[lasti],"sector.wallnum") == 0) tagfield[tagopnum] = 33; + if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingpicnum") == 0) tagfield[tagopnum] = 34; + if (Bstrcasecmp(&tempbuf[lasti],"sector.floorpicnum") == 0) tagfield[tagopnum] = 35; + if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingheinum") == 0) tagfield[tagopnum] = 36; + if (Bstrcasecmp(&tempbuf[lasti],"sector.floorheinum") == 0) tagfield[tagopnum] = 37; + if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingz") == 0) tagfield[tagopnum] = 38; + if (Bstrcasecmp(&tempbuf[lasti],"sector.floorz") == 0) tagfield[tagopnum] = 39; + if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingshade") == 0) tagfield[tagopnum] = 40; + if (Bstrcasecmp(&tempbuf[lasti],"sector.floorshade") == 0) tagfield[tagopnum] = 41; + if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingxpanning") == 0) tagfield[tagopnum] = 42; + if (Bstrcasecmp(&tempbuf[lasti],"sector.floorxpanning") == 0) tagfield[tagopnum] = 43; + if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingypanning") == 0) tagfield[tagopnum] = 44; + if (Bstrcasecmp(&tempbuf[lasti],"sector.floorypanning") == 0) tagfield[tagopnum] = 45; + if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingstat") == 0) tagfield[tagopnum] = 46; + if (Bstrcasecmp(&tempbuf[lasti],"sector.floorstat") == 0) tagfield[tagopnum] = 47; + if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingpal") == 0) tagfield[tagopnum] = 48; + if (Bstrcasecmp(&tempbuf[lasti],"sector.floorpal") == 0) tagfield[tagopnum] = 49; + if (Bstrcasecmp(&tempbuf[lasti],"sector.visibility") == 0) tagfield[tagopnum] = 50; + if (Bstrcasecmp(&tempbuf[lasti],"sector.lotag") == 0) tagfield[tagopnum] = 51; + if (Bstrcasecmp(&tempbuf[lasti],"sector.hitag") == 0) tagfield[tagopnum] = 52; + if (Bstrcasecmp(&tempbuf[lasti],"sector.extra") == 0) tagfield[tagopnum] = 53; - if (Bstrcasecmp(&tempbuf[lasti],"wall.x") == 0) tagfield[tagopnum] = 64; - if (Bstrcasecmp(&tempbuf[lasti],"wall.y") == 0) tagfield[tagopnum] = 65; - if (Bstrcasecmp(&tempbuf[lasti],"wall.point2") == 0) tagfield[tagopnum] = 66; - if (Bstrcasecmp(&tempbuf[lasti],"wall.nextsector") == 0) tagfield[tagopnum] = 67; - if (Bstrcasecmp(&tempbuf[lasti],"wall.nextwall") == 0) tagfield[tagopnum] = 68; - if (Bstrcasecmp(&tempbuf[lasti],"wall.picnum") == 0) tagfield[tagopnum] = 69; - if (Bstrcasecmp(&tempbuf[lasti],"wall.overpicnum") == 0) tagfield[tagopnum] = 70; - if (Bstrcasecmp(&tempbuf[lasti],"wall.shade") == 0) tagfield[tagopnum] = 71; - if (Bstrcasecmp(&tempbuf[lasti],"wall.pal") == 0) tagfield[tagopnum] = 72; - if (Bstrcasecmp(&tempbuf[lasti],"wall.cstat") == 0) tagfield[tagopnum] = 73; - if (Bstrcasecmp(&tempbuf[lasti],"wall.xrepeat") == 0) tagfield[tagopnum] = 74; - if (Bstrcasecmp(&tempbuf[lasti],"wall.yrepeat") == 0) tagfield[tagopnum] = 75; - if (Bstrcasecmp(&tempbuf[lasti],"wall.xpanning") == 0) tagfield[tagopnum] = 76; - if (Bstrcasecmp(&tempbuf[lasti],"wall.ypanning") == 0) tagfield[tagopnum] = 77; - if (Bstrcasecmp(&tempbuf[lasti],"wall.lotag") == 0) tagfield[tagopnum] = 78; - if (Bstrcasecmp(&tempbuf[lasti],"wall.hitag") == 0) tagfield[tagopnum] = 79; - if (Bstrcasecmp(&tempbuf[lasti],"wall.extra") == 0) tagfield[tagopnum] = 80; + if (Bstrcasecmp(&tempbuf[lasti],"wall.x") == 0) tagfield[tagopnum] = 64; + if (Bstrcasecmp(&tempbuf[lasti],"wall.y") == 0) tagfield[tagopnum] = 65; + if (Bstrcasecmp(&tempbuf[lasti],"wall.point2") == 0) tagfield[tagopnum] = 66; + if (Bstrcasecmp(&tempbuf[lasti],"wall.nextsector") == 0) tagfield[tagopnum] = 67; + if (Bstrcasecmp(&tempbuf[lasti],"wall.nextwall") == 0) tagfield[tagopnum] = 68; + if (Bstrcasecmp(&tempbuf[lasti],"wall.picnum") == 0) tagfield[tagopnum] = 69; + if (Bstrcasecmp(&tempbuf[lasti],"wall.overpicnum") == 0) tagfield[tagopnum] = 70; + if (Bstrcasecmp(&tempbuf[lasti],"wall.shade") == 0) tagfield[tagopnum] = 71; + if (Bstrcasecmp(&tempbuf[lasti],"wall.pal") == 0) tagfield[tagopnum] = 72; + if (Bstrcasecmp(&tempbuf[lasti],"wall.cstat") == 0) tagfield[tagopnum] = 73; + if (Bstrcasecmp(&tempbuf[lasti],"wall.xrepeat") == 0) tagfield[tagopnum] = 74; + if (Bstrcasecmp(&tempbuf[lasti],"wall.yrepeat") == 0) tagfield[tagopnum] = 75; + if (Bstrcasecmp(&tempbuf[lasti],"wall.xpanning") == 0) tagfield[tagopnum] = 76; + if (Bstrcasecmp(&tempbuf[lasti],"wall.ypanning") == 0) tagfield[tagopnum] = 77; + if (Bstrcasecmp(&tempbuf[lasti],"wall.lotag") == 0) tagfield[tagopnum] = 78; + if (Bstrcasecmp(&tempbuf[lasti],"wall.hitag") == 0) tagfield[tagopnum] = 79; + if (Bstrcasecmp(&tempbuf[lasti],"wall.extra") == 0) tagfield[tagopnum] = 80; - tagfield[tagopnum] += (frontbackstat<<7) + (spritenumstat<<8); + tagfield[tagopnum] += (frontbackstat<<7) + (spritenumstat<<8); - if ((tempbuf[k+1] >= 48) && (tempbuf[k+1] <= 57)) - tagval[tagopnum] = atol(&tempbuf[k+1]); - else if (Bstrcasecmp("tag",&tempbuf[k+1]) == 0) - tagval[tagopnum] = INT32_MIN; - else - { - for(l=0;l= 48) && (tempbuf[k+1] <= 57)) + tagval[tagopnum] = atol(&tempbuf[k+1]); + else if (Bstrcasecmp("tag",&tempbuf[k+1]) == 0) + tagval[tagopnum] = INT32_MIN; + else + { + for(l=0;l= 48) && (tempbuf[lasti] <= 57)) //1 DIGIT ONLY! - { - spritenumstat = tempbuf[lasti]-48; - lasti++; - } + spritenumstat = 0; + if ((tempbuf[lasti] >= 48) && (tempbuf[lasti] <= 57)) //1 DIGIT ONLY! + { + spritenumstat = tempbuf[lasti]-48; + lasti++; + } - if (Bstrcasecmp(&tempbuf[lasti],"sprite.x") == 0) secfield[secopnum] = 0; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.y") == 0) secfield[secopnum] = 1; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.z") == 0) secfield[secopnum] = 2; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.cstat") == 0) secfield[secopnum] = 3; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.shade") == 0) secfield[secopnum] = 4; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.pal") == 0) secfield[secopnum] = 5; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.clipdist") == 0) secfield[secopnum] = 6; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.xrepeat") == 0) secfield[secopnum] = 7; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.yrepeat") == 0) secfield[secopnum] = 8; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.xoffset") == 0) secfield[secopnum] = 9; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.yoffset") == 0) secfield[secopnum] = 10; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.picnum") == 0) secfield[secopnum] = 11; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.ang") == 0) secfield[secopnum] = 12; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.xvel") == 0) secfield[secopnum] = 13; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.yvel") == 0) secfield[secopnum] = 14; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.zvel") == 0) secfield[secopnum] = 15; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.owner") == 0) secfield[secopnum] = 16; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.sectnum") == 0) secfield[secopnum] = 17; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.statnum") == 0) secfield[secopnum] = 18; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.lotag") == 0) secfield[secopnum] = 19; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.hitag") == 0) secfield[secopnum] = 20; - if (Bstrcasecmp(&tempbuf[lasti],"sprite.extra") == 0) secfield[secopnum] = 21; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.x") == 0) secfield[secopnum] = 0; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.y") == 0) secfield[secopnum] = 1; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.z") == 0) secfield[secopnum] = 2; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.cstat") == 0) secfield[secopnum] = 3; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.shade") == 0) secfield[secopnum] = 4; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.pal") == 0) secfield[secopnum] = 5; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.clipdist") == 0) secfield[secopnum] = 6; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.xrepeat") == 0) secfield[secopnum] = 7; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.yrepeat") == 0) secfield[secopnum] = 8; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.xoffset") == 0) secfield[secopnum] = 9; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.yoffset") == 0) secfield[secopnum] = 10; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.picnum") == 0) secfield[secopnum] = 11; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.ang") == 0) secfield[secopnum] = 12; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.xvel") == 0) secfield[secopnum] = 13; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.yvel") == 0) secfield[secopnum] = 14; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.zvel") == 0) secfield[secopnum] = 15; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.owner") == 0) secfield[secopnum] = 16; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.sectnum") == 0) secfield[secopnum] = 17; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.statnum") == 0) secfield[secopnum] = 18; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.lotag") == 0) secfield[secopnum] = 19; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.hitag") == 0) secfield[secopnum] = 20; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.extra") == 0) secfield[secopnum] = 21; - if (Bstrcasecmp(&tempbuf[lasti],"sector.wallptr") == 0) secfield[secopnum] = 32; - if (Bstrcasecmp(&tempbuf[lasti],"sector.wallnum") == 0) secfield[secopnum] = 33; - if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingpicnum") == 0) secfield[secopnum] = 34; - if (Bstrcasecmp(&tempbuf[lasti],"sector.floorpicnum") == 0) secfield[secopnum] = 35; - if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingheinum") == 0) secfield[secopnum] = 36; - if (Bstrcasecmp(&tempbuf[lasti],"sector.floorheinum") == 0) secfield[secopnum] = 37; - if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingz") == 0) secfield[secopnum] = 38; - if (Bstrcasecmp(&tempbuf[lasti],"sector.floorz") == 0) secfield[secopnum] = 39; - if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingshade") == 0) secfield[secopnum] = 40; - if (Bstrcasecmp(&tempbuf[lasti],"sector.floorshade") == 0) secfield[secopnum] = 41; - if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingxpanning") == 0) secfield[secopnum] = 42; - if (Bstrcasecmp(&tempbuf[lasti],"sector.floorxpanning") == 0) secfield[secopnum] = 43; - if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingypanning") == 0) secfield[secopnum] = 44; - if (Bstrcasecmp(&tempbuf[lasti],"sector.floorypanning") == 0) secfield[secopnum] = 45; - if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingstat") == 0) secfield[secopnum] = 46; - if (Bstrcasecmp(&tempbuf[lasti],"sector.floorstat") == 0) secfield[secopnum] = 47; - if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingpal") == 0) secfield[secopnum] = 48; - if (Bstrcasecmp(&tempbuf[lasti],"sector.floorpal") == 0) secfield[secopnum] = 49; - if (Bstrcasecmp(&tempbuf[lasti],"sector.visibility") == 0) secfield[secopnum] = 50; - if (Bstrcasecmp(&tempbuf[lasti],"sector.lotag") == 0) secfield[secopnum] = 51; - if (Bstrcasecmp(&tempbuf[lasti],"sector.hitag") == 0) secfield[secopnum] = 52; - if (Bstrcasecmp(&tempbuf[lasti],"sector.extra") == 0) secfield[secopnum] = 53; + if (Bstrcasecmp(&tempbuf[lasti],"sector.wallptr") == 0) secfield[secopnum] = 32; + if (Bstrcasecmp(&tempbuf[lasti],"sector.wallnum") == 0) secfield[secopnum] = 33; + if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingpicnum") == 0) secfield[secopnum] = 34; + if (Bstrcasecmp(&tempbuf[lasti],"sector.floorpicnum") == 0) secfield[secopnum] = 35; + if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingheinum") == 0) secfield[secopnum] = 36; + if (Bstrcasecmp(&tempbuf[lasti],"sector.floorheinum") == 0) secfield[secopnum] = 37; + if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingz") == 0) secfield[secopnum] = 38; + if (Bstrcasecmp(&tempbuf[lasti],"sector.floorz") == 0) secfield[secopnum] = 39; + if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingshade") == 0) secfield[secopnum] = 40; + if (Bstrcasecmp(&tempbuf[lasti],"sector.floorshade") == 0) secfield[secopnum] = 41; + if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingxpanning") == 0) secfield[secopnum] = 42; + if (Bstrcasecmp(&tempbuf[lasti],"sector.floorxpanning") == 0) secfield[secopnum] = 43; + if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingypanning") == 0) secfield[secopnum] = 44; + if (Bstrcasecmp(&tempbuf[lasti],"sector.floorypanning") == 0) secfield[secopnum] = 45; + if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingstat") == 0) secfield[secopnum] = 46; + if (Bstrcasecmp(&tempbuf[lasti],"sector.floorstat") == 0) secfield[secopnum] = 47; + if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingpal") == 0) secfield[secopnum] = 48; + if (Bstrcasecmp(&tempbuf[lasti],"sector.floorpal") == 0) secfield[secopnum] = 49; + if (Bstrcasecmp(&tempbuf[lasti],"sector.visibility") == 0) secfield[secopnum] = 50; + if (Bstrcasecmp(&tempbuf[lasti],"sector.lotag") == 0) secfield[secopnum] = 51; + if (Bstrcasecmp(&tempbuf[lasti],"sector.hitag") == 0) secfield[secopnum] = 52; + if (Bstrcasecmp(&tempbuf[lasti],"sector.extra") == 0) secfield[secopnum] = 53; - secfield[secopnum] += (spritenumstat<<8); + secfield[secopnum] += (spritenumstat<<8); - if ((tempbuf[k+1] >= 48) && (tempbuf[k+1] <= 57)) - secval[secopnum] = atol(&tempbuf[k+1]); - else if (Bstrcasecmp("tag",&tempbuf[k+1]) == 0) - secval[secopnum] = INT32_MIN; - else - { - for(l=0;l= 48) && (tempbuf[k+1] <= 57)) + secval[secopnum] = atol(&tempbuf[k+1]); + else if (Bstrcasecmp("tag",&tempbuf[k+1]) == 0) + secval[secopnum] = INT32_MIN; + else + { + for(l=0;l0;j>>=1) - if (i+j < inumwads) - if (Bstrcasecmp(iwadata[slist[i+j]],nam) <= 0) i += j; - if (Bstrcasecmp(iwadata[slist[i]],nam) == 0) return(slist[i]); - return(-1); + i = 0; + for(j=2048;j>0;j>>=1) + if (i+j < inumwads) + if (Bstrcasecmp(iwadata[slist[i+j]],nam) <= 0) i += j; + if (Bstrcasecmp(iwadata[slist[i]],nam) == 0) return(slist[i]); + return(-1); } int main(int argc, char **argv) { - char argstring[5][80]; - char iwadfil[80], pwadfil[80], doommap[16], buildmap[16], picstr[16]; - int w, numtexts, startnumtexts, danumtexts, numpnames; - int x, y, z, zz, zzz, zzx, zx, cx, cy, gap, i, j, k, l, offs; - int dnumpoints = 0, dnumlines = 0, dnumsides, dnumsectors, dnumthings; - int minx, maxx, miny, maxy, numwalls, wadtype; - int startnumwalls, l1, l2, startpoint2; - int fil, ifil, pfil, x1, y1, x2, y2, startwall, endwall; - int mapversion, posx, posy, posz, boardwadindex; - short ang, cursectnum; + char argstring[5][80]; + char iwadfil[80], pwadfil[80], doommap[16], buildmap[16], picstr[16]; + int w, numtexts, startnumtexts, danumtexts, numpnames; + int x, y, z, zz, zzz, zzx, zx, cx, cy, gap, i, j, k, l, offs; + int dnumpoints = 0, dnumlines = 0, dnumsides, dnumsectors, dnumthings; + int minx, maxx, miny, maxy, numwalls, wadtype; + int startnumwalls, l1, l2, startpoint2; + int fil, ifil, pfil, x1, y1, x2, y2, startwall, endwall; + int mapversion, posx, posy, posz, boardwadindex; + short ang, cursectnum; - printf("Wad2Map! Copyright 1995 by Ken Silverman\n"); + printf("Wad2Map! Copyright 1995 by Ken Silverman\n"); - if ((argc < 3) || (argc > 5)) - { - printf("Command line parameters: Wad2Map (PWADName) IWADName MapName (ScriptName)\n"); - printf(" Ex #1: wad2map c:\\doom\\doom.wad e1m1\n"); - printf(" Ex #2: wad2map c:\\doom\\doom.wad e1m1 kenbuild.txt\n"); - printf(" Ex #3: wad2map c:\\doom\\mypwad.wad c:\\doom\\doom.wad e1m1\n"); - printf(" Ex #4: wad2map c:\\doom\\mypwad.wad c:\\doom\\doom.wad e1m1 kenbuild.txt\n"); - exit(0); - } + if ((argc < 3) || (argc > 5)) + { + printf("Command line parameters: Wad2Map (PWADName) IWADName MapName (ScriptName)\n"); + printf(" Ex #1: wad2map c:\\doom\\doom.wad e1m1\n"); + printf(" Ex #2: wad2map c:\\doom\\doom.wad e1m1 kenbuild.txt\n"); + printf(" Ex #3: wad2map c:\\doom\\mypwad.wad c:\\doom\\doom.wad e1m1\n"); + printf(" Ex #4: wad2map c:\\doom\\mypwad.wad c:\\doom\\doom.wad e1m1 kenbuild.txt\n"); + exit(0); + } - for(i=1;i>1);gap>0;gap>>=1) - for(z=0;z=0;zz-=gap) - { - if (Bstrcasecmp(iwadata[slist[zz]],iwadata[slist[zz+gap]]) <= 0) break; - i = slist[zz]; slist[zz] = slist[zz+gap]; slist[zz+gap] = i; - } + for(gap=(inumwads>>1);gap>0;gap>>=1) + for(z=0;z=0;zz-=gap) + { + if (Bstrcasecmp(iwadata[slist[zz]],iwadata[slist[zz+gap]]) <= 0) break; + i = slist[zz]; slist[zz] = slist[zz+gap]; slist[zz+gap] = i; + } - if (ifil != pfil) - { - Bread(pfil,&pnumwads,4); - Bread(pfil,&pwadstart,4); - Blseek(pfil,pwadstart,SEEK_SET); - for(z=0;z= 0) - { - Blseek(ifil,iwadplc[w],BSEEK_SET); - startnumtexts = numtexts; - Bread(ifil,&danumtexts,4); numtexts += danumtexts; - Bread(ifil,&textoffs[startnumtexts],(numtexts-startnumtexts)*sizeof(int)); - for(z=startnumtexts;z= 0) + { + Blseek(ifil,iwadplc[w],BSEEK_SET); + startnumtexts = numtexts; + Bread(ifil,&danumtexts,4); numtexts += danumtexts; + Bread(ifil,&textoffs[startnumtexts],(numtexts-startnumtexts)*sizeof(int)); + for(z=startnumtexts;z=boardwadindex;w--) - { - Blseek(pfil,pwadplc[w],BSEEK_SET); + if ((w = getwadindex(doommap)) < 0) + { printf("Board not found!\n"); exit(0); } + boardwadindex = w; + for(w=boardwadindex+10;w>=boardwadindex;w--) + { + Blseek(pfil,pwadplc[w],BSEEK_SET); - if (Bstrcasecmp(pwadata[w],"VERTEXES") == 0) - { - dnumpoints = (pwadlen[w]>>2); - Bread(pfil,tempbuf,pwadlen[w]); - offs = 0; - for(z=0;z>2); + Bread(pfil,tempbuf,pwadlen[w]); + offs = 0; + for(z=0;z maxx) maxx = x; - if (y < miny) miny = y; - if (y > maxy) maxy = y; - } - cx = (((minx+maxx)>>1)&0xffffffc0); - cy = (((miny+maxy)>>1)&0xffffffc0); + minx = 32767; maxx = -32768; + miny = 32767; maxy = -32768; + for(z=0;z maxx) maxx = x; + if (y < miny) miny = y; + if (y > maxy) maxy = y; + } + cx = (((minx+maxx)>>1)&0xffffffc0); + cy = (((miny+maxy)>>1)&0xffffffc0); - numwalls = 0; + numwalls = 0; - for(z=0;z= 0) && (z == side[line[zz].side2].sect)) - { - wx[numwalls] = px[line[zz].p2]; wy[numwalls] = py[line[zz].p2]; - wx2[numwalls] = px[line[zz].p1]; wy2[numwalls] = py[line[zz].p1]; - picindex[numwalls] = line[zz].side2; linindex[numwalls++] = zz; - } - } + for(z=0;z= 0) && (z == side[line[zz].side2].sect)) + { + wx[numwalls] = px[line[zz].p2]; wy[numwalls] = py[line[zz].p2]; + wx2[numwalls] = px[line[zz].p1]; wy2[numwalls] = py[line[zz].p1]; + picindex[numwalls] = line[zz].side2; linindex[numwalls++] = zz; + } + } - startpoint2 = startnumwalls; - for(zz=startnumwalls;zz 0)) j = 2; - else if ((wx2[zz+1]-x)*(wy2[zzz]-y) > (wy2[zz+1]-y)*(wx2[zzz]-x)) j = 2; + j = 0; + for(zzz=zz+1;zzz 0)) j = 2; + else if ((wx2[zz+1]-x)*(wy2[zzz]-y) > (wy2[zz+1]-y)*(wx2[zzz]-x)) j = 2; - if (j == 2) - { - i = wx[zz+1]; wx[zz+1] = wx[zzz]; wx[zzz] = i; - i = wy[zz+1]; wy[zz+1] = wy[zzz]; wy[zzz] = i; - i = wx2[zz+1]; wx2[zz+1] = wx2[zzz]; wx2[zzz] = i; - i = wy2[zz+1]; wy2[zz+1] = wy2[zzz]; wy2[zzz] = i; - i = picindex[zz+1]; picindex[zz+1] = picindex[zzz]; picindex[zzz] = i; - i = linindex[zz+1]; linindex[zz+1] = linindex[zzz]; linindex[zzz] = i; - } - } - point2[zz] = zz+1; - } - if (j == 0) point2[zz] = startpoint2, startpoint2 = zz+1; - } + if (j == 2) + { + i = wx[zz+1]; wx[zz+1] = wx[zzz]; wx[zzz] = i; + i = wy[zz+1]; wy[zz+1] = wy[zzz]; wy[zzz] = i; + i = wx2[zz+1]; wx2[zz+1] = wx2[zzz]; wx2[zzz] = i; + i = wy2[zz+1]; wy2[zz+1] = wy2[zzz]; wy2[zzz] = i; + i = picindex[zz+1]; picindex[zz+1] = picindex[zzz]; picindex[zzz] = i; + i = linindex[zz+1]; linindex[zz+1] = linindex[zzz]; linindex[zzz] = i; + } + } + point2[zz] = zz+1; + } + if (j == 0) point2[zz] = startpoint2, startpoint2 = zz+1; + } - sector[z].wallptr = startnumwalls; - sector[z].wallnum = numwalls-startnumwalls; - } + sector[z].wallptr = startnumwalls; + sector[z].wallnum = numwalls-startnumwalls; + } - //Collect sectors - for(z=0;z>3); - if ((sector[z].ceilingstat&1) == 0) sector[z].ceilingshade = j; - if ((sector[z].floorstat&1) == 0) sector[z].floorshade = j; - for(i=startwall;i>3); + if ((sector[z].ceilingstat&1) == 0) sector[z].ceilingshade = j; + if ((sector[z].floorstat&1) == 0) sector[z].floorshade = j; + for(i=startwall;i>1);gap>0;gap>>=1) - for(z=0;z=0;zz-=gap) - { - if (wx[slist[zz]] <= wx[slist[zz+gap]]) break; - i = slist[zz]; slist[zz] = slist[zz+gap]; slist[zz+gap] = i; - } + for(gap=(numwalls>>1);gap>0;gap>>=1) + for(z=0;z=0;zz-=gap) + { + if (wx[slist[zz]] <= wx[slist[zz+gap]]) break; + i = slist[zz]; slist[zz] = slist[zz+gap]; slist[zz+gap] = i; + } - for(z=0;z>= 1; - if ((zz+zzz < numwalls) && (wx[slist[zz+zzz]] < x2)) zz += zzz; - zzz >>= 1; - } while (zzz > 0); + zz = 0; zzz = 2048; + do + { + if ((zz+zzz < numwalls) && (wx[slist[zz+zzz]] < x2)) zz += zzz; + zzz >>= 1; + if ((zz+zzz < numwalls) && (wx[slist[zz+zzz]] < x2)) zz += zzz; + zzz >>= 1; + } while (zzz > 0); - do - { - zzx = slist[zz]; - if (wx[zzx] > x2) break; - if (wy[zzx] == y2) - if ((wx[point2[zzx]] == x1) && (wy[point2[zzx]] == y1)) - { - wall[z].nextwall = zzx; - wall[z].nextsector = sectorofwall[zzx]; - break; - } - zz++; - } while (zz < numwalls); + do + { + zzx = slist[zz]; + if (wx[zzx] > x2) break; + if (wy[zzx] == y2) + if ((wx[point2[zzx]] == x1) && (wy[point2[zzx]] == y1)) + { + wall[z].nextwall = zzx; + wall[z].nextsector = sectorofwall[zzx]; + break; + } + zz++; + } while (zz < numwalls); - if (wall[z].nextwall < 0) - { - wall[z].picnum = sidemidpic[picindex[z]]; - wall[z].overpicnum = 0; - } - else - { - wall[z].picnum = sidetoppic[picindex[z]]; - if (wall[z].picnum <= 0) wall[z].picnum = sidebotpic[picindex[z]]; - if ((wall[z].picnum <= 0) && (wall[z].nextwall >= 0)) - { - zx = picindex[wall[z].nextwall]; - wall[z].picnum = sidetoppic[zx]; - if (wall[z].picnum <= 0) wall[z].picnum = sidebotpic[zx]; - } - wall[z].overpicnum = sidemidpic[picindex[z]]; - if (wall[z].overpicnum >= 0) wall[z].cstat |= (1+4+16); - } - wall[z].xrepeat = 8; - wall[z].yrepeat = 8; - wall[z].xpanning = (char)((-side[picindex[z]].xoffset)&255); - wall[z].ypanning = (char)(((side[picindex[z]].yoffset<<1))&255); + if (wall[z].nextwall < 0) + { + wall[z].picnum = sidemidpic[picindex[z]]; + wall[z].overpicnum = 0; + } + else + { + wall[z].picnum = sidetoppic[picindex[z]]; + if (wall[z].picnum <= 0) wall[z].picnum = sidebotpic[picindex[z]]; + if ((wall[z].picnum <= 0) && (wall[z].nextwall >= 0)) + { + zx = picindex[wall[z].nextwall]; + wall[z].picnum = sidetoppic[zx]; + if (wall[z].picnum <= 0) wall[z].picnum = sidebotpic[zx]; + } + wall[z].overpicnum = sidemidpic[picindex[z]]; + if (wall[z].overpicnum >= 0) wall[z].cstat |= (1+4+16); + } + wall[z].xrepeat = 8; + wall[z].yrepeat = 8; + wall[z].xpanning = (char)((-side[picindex[z]].xoffset)&255); + wall[z].ypanning = (char)(((side[picindex[z]].yoffset<<1))&255); - if (line[linindex[z]].flags&1) wall[z].cstat |= 1; - //if (wall[z].nextwall >= 0) wall[z].cstat |= 4; - //if ((line[linindex[z]].flags&24) && (wall[z].nextwall >= 0)) - // wall[z].cstat |= 4; - } + if (line[linindex[z]].flags&1) wall[z].cstat |= 1; + //if (wall[z].nextwall >= 0) wall[z].cstat |= 4; + //if ((line[linindex[z]].flags&24) && (wall[z].nextwall >= 0)) + // wall[z].cstat |= 4; + } - for(z=0;z= thingnum[i]) && (thing[z].type <= thingnum2[i])) - for(j=thingoff[i];j= thingnum[i]) && (thing[z].type <= thingnum2[i])) + for(j=thingoff[i];j tagnum2[i])) continue; + for(zx=0;zx tagnum2[i])) continue; - for(j=tagoff[i];j= 0) - if ((tagfield[j]&128) ^ (picindex[zx] == line[z].side1)) - l = wall[zx].nextsector; + for(j=tagoff[i];j= 0) + if ((tagfield[j]&128) ^ (picindex[zx] == line[z].side1)) + l = wall[zx].nextsector; - zzz = sectspri[l][(tagfield[j]>>8)&7]; - if (zzz < 0) - { - zzz = dnumthings++; - sectspri[l][(tagfield[j]>>8)&7] = zzz; - zzx = sector[l].wallptr; x1 = wall[zzx].x; y1 = wall[zzx].y; - zzx = wall[zzx].point2; x2 = wall[zzx].x; y2 = wall[zzx].y; - sprite[zzz].x = ((x1+x2)>>1) + ksgn(y1-y2); - sprite[zzz].y = ((y1+y2)>>1) + ksgn(x2-x1); - sprite[zzz].sectnum = l; - sprite[zzz].z = sector[l].floorz; - sprite[zzz].clipdist = 32; - sprite[zzz].xrepeat = 64; - sprite[zzz].yrepeat = 64; - } + zzz = sectspri[l][(tagfield[j]>>8)&7]; + if (zzz < 0) + { + zzz = dnumthings++; + sectspri[l][(tagfield[j]>>8)&7] = zzz; + zzx = sector[l].wallptr; x1 = wall[zzx].x; y1 = wall[zzx].y; + zzx = wall[zzx].point2; x2 = wall[zzx].x; y2 = wall[zzx].y; + sprite[zzz].x = ((x1+x2)>>1) + ksgn(y1-y2); + sprite[zzz].y = ((y1+y2)>>1) + ksgn(x2-x1); + sprite[zzz].sectnum = l; + sprite[zzz].z = sector[l].floorz; + sprite[zzz].clipdist = 32; + sprite[zzz].xrepeat = 64; + sprite[zzz].yrepeat = 64; + } - switch(tagop[j]) - { - case 0: setspritefield(zzz,k,zz); break; - case 1: setspritefield(zzz,k,getspritefield(zzz,k)+zz); break; - case 2: setspritefield(zzz,k,getspritefield(zzz,k)-zz); break; - case 3: setspritefield(zzz,k,getspritefield(zzz,k)|zz); break; - case 4: setspritefield(zzz,k,getspritefield(zzz,k)&zz); break; - case 5: setspritefield(zzz,k,getspritefield(zzz,k)^zz); break; - } - } - else if (k < 64) - { - l = sectorofwall[zx]; - if (wall[zx].nextsector >= 0) - if ((tagfield[j]&128) ^ (picindex[zx] == line[z].side1)) - l = wall[zx].nextsector; + switch(tagop[j]) + { + case 0: setspritefield(zzz,k,zz); break; + case 1: setspritefield(zzz,k,getspritefield(zzz,k)+zz); break; + case 2: setspritefield(zzz,k,getspritefield(zzz,k)-zz); break; + case 3: setspritefield(zzz,k,getspritefield(zzz,k)|zz); break; + case 4: setspritefield(zzz,k,getspritefield(zzz,k)&zz); break; + case 5: setspritefield(zzz,k,getspritefield(zzz,k)^zz); break; + } + } + else if (k < 64) + { + l = sectorofwall[zx]; + if (wall[zx].nextsector >= 0) + if ((tagfield[j]&128) ^ (picindex[zx] == line[z].side1)) + l = wall[zx].nextsector; - switch(tagop[j]) - { - case 0: setsectorfield(l,k,zz); break; - case 1: setsectorfield(l,k,getsectorfield(l,k)+zz); break; - case 2: setsectorfield(l,k,getsectorfield(l,k)-zz); break; - case 3: setsectorfield(l,k,getsectorfield(l,k)|zz); break; - case 4: setsectorfield(l,k,getsectorfield(l,k)&zz); break; - case 5: setsectorfield(l,k,getsectorfield(l,k)^zz); break; - } - } - else if (k < 96) - { - l = zx; - if (wall[zx].nextwall >= 0) - if ((tagfield[j]&128) ^ (picindex[zx] == line[z].side1)) - l = wall[zx].nextwall; + switch(tagop[j]) + { + case 0: setsectorfield(l,k,zz); break; + case 1: setsectorfield(l,k,getsectorfield(l,k)+zz); break; + case 2: setsectorfield(l,k,getsectorfield(l,k)-zz); break; + case 3: setsectorfield(l,k,getsectorfield(l,k)|zz); break; + case 4: setsectorfield(l,k,getsectorfield(l,k)&zz); break; + case 5: setsectorfield(l,k,getsectorfield(l,k)^zz); break; + } + } + else if (k < 96) + { + l = zx; + if (wall[zx].nextwall >= 0) + if ((tagfield[j]&128) ^ (picindex[zx] == line[z].side1)) + l = wall[zx].nextwall; - switch(tagop[j]) - { - case 0: setwallfield(l,k,zz); break; - case 1: setwallfield(l,k,getwallfield(l,k)+zz); break; - case 2: setwallfield(l,k,getwallfield(l,k)-zz); break; - case 3: setwallfield(l,k,getwallfield(l,k)|zz); break; - case 4: setwallfield(l,k,getwallfield(l,k)&zz); break; - case 5: setwallfield(l,k,getwallfield(l,k)^zz); break; - } - } - } - } - } + switch(tagop[j]) + { + case 0: setwallfield(l,k,zz); break; + case 1: setwallfield(l,k,getwallfield(l,k)+zz); break; + case 2: setwallfield(l,k,getwallfield(l,k)-zz); break; + case 3: setwallfield(l,k,getwallfield(l,k)|zz); break; + case 4: setwallfield(l,k,getwallfield(l,k)&zz); break; + case 5: setwallfield(l,k,getwallfield(l,k)^zz); break; + } + } + } + } + } - for(l=0;l= secnum[i]) && (sect[l].type <= secnum2[i])) - { - for(j=secoff[i];j>8)&7]; - if (zzz < 0) - { - zzz = dnumthings++; - sectspri[l][(secfield[j]>>8)&7] = zzz; - zzx = sector[l].wallptr; x1 = wall[zzx].x; y1 = wall[zzx].y; - zzx = wall[zzx].point2; x2 = wall[zzx].x; y2 = wall[zzx].y; - sprite[zzz].x = ((x1+x2)>>1) + ksgn(y1-y2); - sprite[zzz].y = ((y1+y2)>>1) + ksgn(x2-x1); - sprite[zzz].sectnum = l; - sprite[zzz].z = sector[l].floorz; - sprite[zzz].clipdist = 32; - sprite[zzz].xrepeat = 64; - sprite[zzz].yrepeat = 64; - } + for(l=0;l= secnum[i]) && (sect[l].type <= secnum2[i])) + { + for(j=secoff[i];j>8)&7]; + if (zzz < 0) + { + zzz = dnumthings++; + sectspri[l][(secfield[j]>>8)&7] = zzz; + zzx = sector[l].wallptr; x1 = wall[zzx].x; y1 = wall[zzx].y; + zzx = wall[zzx].point2; x2 = wall[zzx].x; y2 = wall[zzx].y; + sprite[zzz].x = ((x1+x2)>>1) + ksgn(y1-y2); + sprite[zzz].y = ((y1+y2)>>1) + ksgn(x2-x1); + sprite[zzz].sectnum = l; + sprite[zzz].z = sector[l].floorz; + sprite[zzz].clipdist = 32; + sprite[zzz].xrepeat = 64; + sprite[zzz].yrepeat = 64; + } - switch(secop[j]) - { - case 0: setspritefield(zzz,k,zz); break; - case 1: setspritefield(zzz,k,getspritefield(zzz,k)+zz); break; - case 2: setspritefield(zzz,k,getspritefield(zzz,k)-zz); break; - case 3: setspritefield(zzz,k,getspritefield(zzz,k)|zz); break; - case 4: setspritefield(zzz,k,getspritefield(zzz,k)&zz); break; - case 5: setspritefield(zzz,k,getspritefield(zzz,k)^zz); break; - } - } - else if (k < 64) - { - switch(secop[j]) - { - case 0: setsectorfield(l,k,zz); break; - case 1: setsectorfield(l,k,getsectorfield(l,k)+zz); break; - case 2: setsectorfield(l,k,getsectorfield(l,k)-zz); break; - case 3: setsectorfield(l,k,getsectorfield(l,k)|zz); break; - case 4: setsectorfield(l,k,getsectorfield(l,k)&zz); break; - case 5: setsectorfield(l,k,getsectorfield(l,k)^zz); break; - } - } - } - } + switch(secop[j]) + { + case 0: setspritefield(zzz,k,zz); break; + case 1: setspritefield(zzz,k,getspritefield(zzz,k)+zz); break; + case 2: setspritefield(zzz,k,getspritefield(zzz,k)-zz); break; + case 3: setspritefield(zzz,k,getspritefield(zzz,k)|zz); break; + case 4: setspritefield(zzz,k,getspritefield(zzz,k)&zz); break; + case 5: setspritefield(zzz,k,getspritefield(zzz,k)^zz); break; + } + } + else if (k < 64) + { + switch(secop[j]) + { + case 0: setsectorfield(l,k,zz); break; + case 1: setsectorfield(l,k,getsectorfield(l,k)+zz); break; + case 2: setsectorfield(l,k,getsectorfield(l,k)-zz); break; + case 3: setsectorfield(l,k,getsectorfield(l,k)|zz); break; + case 4: setsectorfield(l,k,getsectorfield(l,k)&zz); break; + case 5: setsectorfield(l,k,getsectorfield(l,k)^zz); break; + } + } + } + } - for(z=0;z= 32768) || (klabs(y) >= 32768)) - wall[z].xrepeat = 255; - else - { - zx = mulscale10(ksqrtasm(x*x+y*y),wall[z].yrepeat); - wall[z].xrepeat = (char)min(max(zx,1),255); - } + for(z=0;z= 32768) || (klabs(y) >= 32768)) + wall[z].xrepeat = 255; + else + { + zx = mulscale10(ksqrtasm(x*x+y*y),wall[z].yrepeat); + wall[z].xrepeat = (char)min(max(zx,1),255); + } - wall[z].picnum = texturelookup[wall[z].picnum]; - wall[z].overpicnum = texturelookup[wall[z].overpicnum]; - } + wall[z].picnum = texturelookup[wall[z].picnum]; + wall[z].overpicnum = texturelookup[wall[z].overpicnum]; + } - mapversion = 7; posx = 0; posy = 0; posz = 0; ang = 1536; cursectnum = 0; + mapversion = 7; posx = 0; posy = 0; posz = 0; ang = 1536; cursectnum = 0; - //WATCH OUT THAT FOR DNUMTHINGS BEING HIGHER THAN NUMBER ON DOOM MAP! - for(i=0;i