mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00:46 +00:00
Build tools: Whitespace cleanup and tab stop replacement.
git-svn-id: https://svn.eduke32.com/eduke32@2473 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
a9fc470258
commit
67f946bdd8
14 changed files with 2662 additions and 2662 deletions
|
@ -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 <filename> 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 <filename> 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<argc; i++) {
|
||||
if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "-?") || !strcmp(argv[i], "--help")) {
|
||||
usage();
|
||||
return 0;
|
||||
} else if (!strcmp(argv[i], "-o")) {
|
||||
outputfile = argv[++i];
|
||||
}
|
||||
}
|
||||
for (i=1; i<argc; i++) {
|
||||
if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "-?") || !strcmp(argv[i], "--help")) {
|
||||
usage();
|
||||
return 0;
|
||||
} else if (!strcmp(argv[i], "-o")) {
|
||||
outputfile = argv[++i];
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcmp(outputfile, "-")) {
|
||||
output = fdopen(1, "wt");
|
||||
outputfile = NULL;
|
||||
} else {
|
||||
output = fopen(outputfile, "wt");
|
||||
if (!output) {
|
||||
fprintf(stderr, "enumdisplay: failed to open %s for output\n", outputfile);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (!strcmp(outputfile, "-")) {
|
||||
output = fdopen(1, "wt");
|
||||
outputfile = NULL;
|
||||
} else {
|
||||
output = fopen(outputfile, "wt");
|
||||
if (!output) {
|
||||
fprintf(stderr, "enumdisplay: failed to open %s for output\n", outputfile);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(output,
|
||||
"enumdisplay results\n"
|
||||
"\n"
|
||||
"Display settings:\n"
|
||||
);
|
||||
ZeroMemory(&devmode, sizeof(devmode));
|
||||
devmode.dmSize = sizeof(DEVMODE);
|
||||
if (!EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devmode)) {
|
||||
fprintf(output, "\tEnumDisplaySettings() FAILED!\n");
|
||||
} else {
|
||||
dumpdevmode(&devmode);
|
||||
}
|
||||
fprintf(output,
|
||||
"enumdisplay results\n"
|
||||
"\n"
|
||||
"Display settings:\n"
|
||||
);
|
||||
ZeroMemory(&devmode, sizeof(devmode));
|
||||
devmode.dmSize = sizeof(DEVMODE);
|
||||
if (!EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devmode)) {
|
||||
fprintf(output, "\tEnumDisplaySettings() FAILED!\n");
|
||||
} else {
|
||||
dumpdevmode(&devmode);
|
||||
}
|
||||
|
||||
fprintf(output,
|
||||
"\n"
|
||||
"All modes from EnumDisplaySettings:\n"
|
||||
);
|
||||
ZeroMemory(&devmode, sizeof(devmode));
|
||||
devmode.dmSize = sizeof(DEVMODE);
|
||||
i = 0;
|
||||
while (EnumDisplaySettings(NULL, i, &devmode)) {
|
||||
dumpdevmode(&devmode);
|
||||
fprintf(output, "\n");
|
||||
ZeroMemory(&devmode, sizeof(devmode));
|
||||
devmode.dmSize = sizeof(DEVMODE);
|
||||
i++;
|
||||
}
|
||||
fprintf(output,
|
||||
"\n"
|
||||
"All modes from EnumDisplaySettings:\n"
|
||||
);
|
||||
ZeroMemory(&devmode, sizeof(devmode));
|
||||
devmode.dmSize = sizeof(DEVMODE);
|
||||
i = 0;
|
||||
while (EnumDisplaySettings(NULL, i, &devmode)) {
|
||||
dumpdevmode(&devmode);
|
||||
fprintf(output, "\n");
|
||||
ZeroMemory(&devmode, sizeof(devmode));
|
||||
devmode.dmSize = sizeof(DEVMODE);
|
||||
i++;
|
||||
}
|
||||
|
||||
if (!InitDirectDraw()) {
|
||||
fprintf(output,
|
||||
"\n"
|
||||
"All modes from IDirectDraw::EnumDisplayModes:\n"
|
||||
);
|
||||
hresult = IDirectDraw_EnumDisplayModes(lpDD, 0, NULL, (LPVOID)0, ddenum);
|
||||
if (hresult != DD_OK) {
|
||||
fprintf(output, "\tIDirectDraw::EnumDisplayModes() FAILED! (%d)\n", hresult);
|
||||
}
|
||||
}
|
||||
UninitDirectDraw();
|
||||
if (!InitDirectDraw()) {
|
||||
fprintf(output,
|
||||
"\n"
|
||||
"All modes from IDirectDraw::EnumDisplayModes:\n"
|
||||
);
|
||||
hresult = IDirectDraw_EnumDisplayModes(lpDD, 0, NULL, (LPVOID)0, ddenum);
|
||||
if (hresult != DD_OK) {
|
||||
fprintf(output, "\tIDirectDraw::EnumDisplayModes() FAILED! (%d)\n", hresult);
|
||||
}
|
||||
}
|
||||
UninitDirectDraw();
|
||||
|
||||
if (outputfile) fclose(output);
|
||||
if (outputfile) fclose(output);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,129 +1,129 @@
|
|||
// compile with:
|
||||
// gcc -o getdxdidf.exe src\getdxdidf.c -Ic:\mingw32\dx6\include -Lc:\mingw32\dx6\lib -ldxguid -ldinput -mwindows
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define INITGUID
|
||||
#include <windows.h>
|
||||
#include <dinput.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
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<c_dfDIKeyboard.dwNumObjs; i++) {
|
||||
fprintf(fp,
|
||||
"\t{ %s, %d, 0x%08X, 0x%08X },\n",
|
||||
WhatGUID(c_dfDIKeyboard.rgodf[i].pguid),
|
||||
c_dfDIKeyboard.rgodf[i].dwOfs,
|
||||
c_dfDIKeyboard.rgodf[i].dwType,
|
||||
c_dfDIKeyboard.rgodf[i].dwFlags
|
||||
);
|
||||
}
|
||||
fprintf(fp,
|
||||
"};\n"
|
||||
"\n"
|
||||
"const DIDATAFORMAT c_dfDIKeyboard = { %d, %d, 0x%08X, %d, %d, c_dfDIKeyboard_odf };\n\n",
|
||||
c_dfDIKeyboard.dwSize,
|
||||
c_dfDIKeyboard.dwObjSize,
|
||||
c_dfDIKeyboard.dwFlags,
|
||||
c_dfDIKeyboard.dwDataSize,
|
||||
c_dfDIKeyboard.dwNumObjs
|
||||
);
|
||||
|
||||
|
||||
|
||||
fprintf(fp,
|
||||
"// Mouse\n"
|
||||
"\n"
|
||||
"static DIOBJECTDATAFORMAT c_dfDIMouse_odf[] = {\n"
|
||||
);
|
||||
|
||||
for (i=0; i<c_dfDIMouse.dwNumObjs; i++) {
|
||||
fprintf(fp,
|
||||
"\t{ %s, %d, 0x%08X, 0x%08X },\n",
|
||||
WhatGUID(c_dfDIMouse.rgodf[i].pguid),
|
||||
c_dfDIMouse.rgodf[i].dwOfs,
|
||||
c_dfDIMouse.rgodf[i].dwType,
|
||||
c_dfDIMouse.rgodf[i].dwFlags
|
||||
);
|
||||
}
|
||||
fprintf(fp,
|
||||
"};\n"
|
||||
"\n"
|
||||
"const DIDATAFORMAT c_dfDIMouse = { %d, %d, 0x%08X, %d, %d, c_dfDIMouse_odf };\n\n",
|
||||
c_dfDIMouse.dwSize,
|
||||
c_dfDIMouse.dwObjSize,
|
||||
c_dfDIMouse.dwFlags,
|
||||
c_dfDIMouse.dwDataSize,
|
||||
c_dfDIMouse.dwNumObjs
|
||||
);
|
||||
|
||||
|
||||
|
||||
fprintf(fp,
|
||||
"// Joystick\n"
|
||||
"\n"
|
||||
"static DIOBJECTDATAFORMAT c_dfDIJoystick_odf[] = {\n"
|
||||
);
|
||||
|
||||
for (i=0; i<c_dfDIJoystick.dwNumObjs; i++) {
|
||||
fprintf(fp,
|
||||
"\t{ %s, %d, 0x%08X, 0x%08X },\n",
|
||||
WhatGUID(c_dfDIJoystick.rgodf[i].pguid),
|
||||
c_dfDIJoystick.rgodf[i].dwOfs,
|
||||
c_dfDIJoystick.rgodf[i].dwType,
|
||||
c_dfDIJoystick.rgodf[i].dwFlags
|
||||
);
|
||||
}
|
||||
fprintf(fp,
|
||||
"};\n"
|
||||
"\n"
|
||||
"const DIDATAFORMAT c_dfDIJoystick = { %d, %d, 0x%08X, %d, %d, c_dfDIJoystick_odf };\n\n",
|
||||
c_dfDIJoystick.dwSize,
|
||||
c_dfDIJoystick.dwObjSize,
|
||||
c_dfDIJoystick.dwFlags,
|
||||
c_dfDIJoystick.dwDataSize,
|
||||
c_dfDIJoystick.dwNumObjs
|
||||
);
|
||||
|
||||
|
||||
fclose(fp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
// compile with:
|
||||
// gcc -o getdxdidf.exe src\getdxdidf.c -Ic:\mingw32\dx6\include -Lc:\mingw32\dx6\lib -ldxguid -ldinput -mwindows
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define INITGUID
|
||||
#include <windows.h>
|
||||
#include <dinput.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
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<c_dfDIKeyboard.dwNumObjs; i++) {
|
||||
fprintf(fp,
|
||||
"\t{ %s, %d, 0x%08X, 0x%08X },\n",
|
||||
WhatGUID(c_dfDIKeyboard.rgodf[i].pguid),
|
||||
c_dfDIKeyboard.rgodf[i].dwOfs,
|
||||
c_dfDIKeyboard.rgodf[i].dwType,
|
||||
c_dfDIKeyboard.rgodf[i].dwFlags
|
||||
);
|
||||
}
|
||||
fprintf(fp,
|
||||
"};\n"
|
||||
"\n"
|
||||
"const DIDATAFORMAT c_dfDIKeyboard = { %d, %d, 0x%08X, %d, %d, c_dfDIKeyboard_odf };\n\n",
|
||||
c_dfDIKeyboard.dwSize,
|
||||
c_dfDIKeyboard.dwObjSize,
|
||||
c_dfDIKeyboard.dwFlags,
|
||||
c_dfDIKeyboard.dwDataSize,
|
||||
c_dfDIKeyboard.dwNumObjs
|
||||
);
|
||||
|
||||
|
||||
|
||||
fprintf(fp,
|
||||
"// Mouse\n"
|
||||
"\n"
|
||||
"static DIOBJECTDATAFORMAT c_dfDIMouse_odf[] = {\n"
|
||||
);
|
||||
|
||||
for (i=0; i<c_dfDIMouse.dwNumObjs; i++) {
|
||||
fprintf(fp,
|
||||
"\t{ %s, %d, 0x%08X, 0x%08X },\n",
|
||||
WhatGUID(c_dfDIMouse.rgodf[i].pguid),
|
||||
c_dfDIMouse.rgodf[i].dwOfs,
|
||||
c_dfDIMouse.rgodf[i].dwType,
|
||||
c_dfDIMouse.rgodf[i].dwFlags
|
||||
);
|
||||
}
|
||||
fprintf(fp,
|
||||
"};\n"
|
||||
"\n"
|
||||
"const DIDATAFORMAT c_dfDIMouse = { %d, %d, 0x%08X, %d, %d, c_dfDIMouse_odf };\n\n",
|
||||
c_dfDIMouse.dwSize,
|
||||
c_dfDIMouse.dwObjSize,
|
||||
c_dfDIMouse.dwFlags,
|
||||
c_dfDIMouse.dwDataSize,
|
||||
c_dfDIMouse.dwNumObjs
|
||||
);
|
||||
|
||||
|
||||
|
||||
fprintf(fp,
|
||||
"// Joystick\n"
|
||||
"\n"
|
||||
"static DIOBJECTDATAFORMAT c_dfDIJoystick_odf[] = {\n"
|
||||
);
|
||||
|
||||
for (i=0; i<c_dfDIJoystick.dwNumObjs; i++) {
|
||||
fprintf(fp,
|
||||
"\t{ %s, %d, 0x%08X, 0x%08X },\n",
|
||||
WhatGUID(c_dfDIJoystick.rgodf[i].pguid),
|
||||
c_dfDIJoystick.rgodf[i].dwOfs,
|
||||
c_dfDIJoystick.rgodf[i].dwType,
|
||||
c_dfDIJoystick.rgodf[i].dwFlags
|
||||
);
|
||||
}
|
||||
fprintf(fp,
|
||||
"};\n"
|
||||
"\n"
|
||||
"const DIDATAFORMAT c_dfDIJoystick = { %d, %d, 0x%08X, %d, %d, c_dfDIJoystick_odf };\n\n",
|
||||
c_dfDIJoystick.dwSize,
|
||||
c_dfDIJoystick.dwObjSize,
|
||||
c_dfDIJoystick.dwFlags,
|
||||
c_dfDIJoystick.dwDataSize,
|
||||
c_dfDIJoystick.dwNumObjs
|
||||
);
|
||||
|
||||
|
||||
fclose(fp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,163 +1,163 @@
|
|||
// gcc b.c -Lc:/mingw32/lib -lmingw32 -lSDLmain -lSDL
|
||||
|
||||
#include <stdio.h>
|
||||
#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;i<SDLK_LAST;i++) {
|
||||
if (i>0) printf(", ");
|
||||
if (i%8 == 7) printf("\n");
|
||||
printf("%d",keytranslation[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// gcc b.c -Lc:/mingw32/lib -lmingw32 -lSDLmain -lSDL
|
||||
|
||||
#include <stdio.h>
|
||||
#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;i<SDLK_LAST;i++) {
|
||||
if (i>0) printf(", ");
|
||||
if (i%8 == 7) printf("\n");
|
||||
printf("%d",keytranslation[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -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; written<length; written++) {
|
||||
if (across == maxacross)
|
||||
{
|
||||
fprintf(out, "\n ");
|
||||
across = 0;
|
||||
}
|
||||
// convert the data
|
||||
for (written=0; written<length; written++) {
|
||||
if (across == maxacross)
|
||||
{
|
||||
fprintf(out, "\n ");
|
||||
across = 0;
|
||||
}
|
||||
|
||||
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');
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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;i<ico->width*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;i<ico->width*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 <picture file>\n");
|
||||
return 1;
|
||||
}
|
||||
if (argc<2) {
|
||||
fprintf(stderr, "generateicon <picture file>\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<icon.height*icon.width; i++) {
|
||||
if (bm == 0) {
|
||||
bm = 1;
|
||||
maskp++;
|
||||
}
|
||||
maskp = icon.mask;
|
||||
bm = 1;
|
||||
pp = (unsigned char *)icon.pixels;
|
||||
for (i=0; i<icon.height*icon.width; i++) {
|
||||
if (bm == 0) {
|
||||
bm = 1;
|
||||
maskp++;
|
||||
}
|
||||
|
||||
{
|
||||
unsigned char c = pp[0];
|
||||
pp[0] = pp[2];
|
||||
pp[2] = c;
|
||||
}
|
||||
if (pp[3] > 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 <groupfile.grp> [@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 <groupfile.grp> [@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;i<numfiles;i++)
|
||||
{
|
||||
k = *((int*)&filelist[i][12]); k = B_LITTLE32(k);
|
||||
filelist[i][12] = 0;
|
||||
fileoffs[i] = j;
|
||||
j += k;
|
||||
}
|
||||
fileoffs[numfiles] = j;
|
||||
j = 0;
|
||||
for(i=0;i<numfiles;i++)
|
||||
{
|
||||
k = *((int*)&filelist[i][12]); k = B_LITTLE32(k);
|
||||
filelist[i][12] = 0;
|
||||
fileoffs[i] = j;
|
||||
j += k;
|
||||
}
|
||||
fileoffs[numfiles] = j;
|
||||
|
||||
if (onlylist)
|
||||
{
|
||||
|
@ -89,72 +89,72 @@ int main(int argc, char **argv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
for(i=0;i<numfiles;i++) marked4extraction[i] = 0;
|
||||
for(i=0;i<numfiles;i++) marked4extraction[i] = 0;
|
||||
|
||||
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++;
|
||||
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;i<numfiles;i++)
|
||||
{
|
||||
if (marked4extraction[i] == 0) continue;
|
||||
for(i=0;i<numfiles;i++)
|
||||
{
|
||||
if (marked4extraction[i] == 0) continue;
|
||||
|
||||
fileleng[i] = fileoffs[i+1]-fileoffs[i];
|
||||
fileleng[i] = fileoffs[i+1]-fileoffs[i];
|
||||
|
||||
if ((fil2 = Bopen(filelist[i],BO_BINARY|BO_TRUNC|BO_CREAT|BO_WRONLY,BS_IREAD|BS_IWRITE)) == -1)
|
||||
{
|
||||
printf("Error: Could not write to %s\n",filelist[i]);
|
||||
continue;
|
||||
}
|
||||
printf("Extracting %s...\n",filelist[i]);
|
||||
Blseek(fil,fileoffs[i]+((numfiles+1)<<4),SEEK_SET);
|
||||
for(j=0;j<fileleng[i];j+=65536)
|
||||
{
|
||||
k = min(fileleng[i]-j,65536);
|
||||
Bread(fil,buf,k);
|
||||
if (Bwrite(fil2,buf,k) < k)
|
||||
{
|
||||
printf("Write error (drive full?)\n");
|
||||
Bclose(fil2);
|
||||
Bclose(fil);
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
Bclose(fil2);
|
||||
}
|
||||
Bclose(fil);
|
||||
if ((fil2 = Bopen(filelist[i],BO_BINARY|BO_TRUNC|BO_CREAT|BO_WRONLY,BS_IREAD|BS_IWRITE)) == -1)
|
||||
{
|
||||
printf("Error: Could not write to %s\n",filelist[i]);
|
||||
continue;
|
||||
}
|
||||
printf("Extracting %s...\n",filelist[i]);
|
||||
Blseek(fil,fileoffs[i]+((numfiles+1)<<4),SEEK_SET);
|
||||
for(j=0;j<fileleng[i];j+=65536)
|
||||
{
|
||||
k = min(fileleng[i]-j,65536);
|
||||
Bread(fil,buf,k);
|
||||
if (Bwrite(fil2,buf,k) < k)
|
||||
{
|
||||
printf("Write error (drive full?)\n");
|
||||
Bclose(fil2);
|
||||
Bclose(fil);
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
Bclose(fil2);
|
||||
}
|
||||
Bclose(fil);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ static void jstrupr(char *s) { while (*s) { *s = Btoupper(*s); s++; } }
|
|||
|
||||
#define MAXFILES 4096
|
||||
|
||||
static char buf[65536]; // These limits should be abolished one day
|
||||
static char buf[65536]; // These limits should be abolished one day
|
||||
|
||||
static int numfiles;
|
||||
static char filespec[MAXFILES][128], filelist[MAXFILES][16];
|
||||
|
@ -23,149 +23,149 @@ static int fileleng[MAXFILES];
|
|||
static char *matchstr = "*.*";
|
||||
int checkmatch(const struct Bdirent *a)
|
||||
{
|
||||
if (a->mode & 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;i<numfiles;i++)
|
||||
{
|
||||
printf("Adding %s...\n",filespec[i]);
|
||||
if ((fil2 = Bopen(filespec[i],BO_BINARY|BO_RDONLY,BS_IREAD)) == -1)
|
||||
{
|
||||
printf("Error: %s not found\n",filespec[i]);
|
||||
Bclose(fil);
|
||||
return(0);
|
||||
}
|
||||
for(j=0;j<fileleng[i];j+=65536)
|
||||
{
|
||||
k = min(fileleng[i]-j,65536);
|
||||
Bread(fil2,buf,k);
|
||||
if (Bwrite(fil,buf,k) < k)
|
||||
{
|
||||
Bclose(fil2);
|
||||
Bclose(fil);
|
||||
printf("OUT OF HD SPACE!\n");
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
Bclose(fil2);
|
||||
}
|
||||
Bclose(fil);
|
||||
printf("Saved to %s.\n",argv[1]);
|
||||
for(i=0;i<numfiles;i++)
|
||||
{
|
||||
printf("Adding %s...\n",filespec[i]);
|
||||
if ((fil2 = Bopen(filespec[i],BO_BINARY|BO_RDONLY,BS_IREAD)) == -1)
|
||||
{
|
||||
printf("Error: %s not found\n",filespec[i]);
|
||||
Bclose(fil);
|
||||
return(0);
|
||||
}
|
||||
for(j=0;j<fileleng[i];j+=65536)
|
||||
{
|
||||
k = min(fileleng[i]-j,65536);
|
||||
Bread(fil2,buf,k);
|
||||
if (Bwrite(fil,buf,k) < k)
|
||||
{
|
||||
Bclose(fil2);
|
||||
Bclose(fil);
|
||||
printf("OUT OF HD SPACE!\n");
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
Bclose(fil2);
|
||||
}
|
||||
Bclose(fil);
|
||||
printf("Saved to %s.\n",argv[1]);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#if 0
|
||||
kmd2tool.exe: kmd2tool.c; cl kmd2tool.c /Ox /G6fy /MD /link /opt:nowin98
|
||||
del kmd2tool.obj
|
||||
del kmd2tool.obj
|
||||
!if 0
|
||||
#endif
|
||||
|
||||
|
@ -12,45 +12,45 @@ typedef struct { float x, y, z; } point3d;
|
|||
|
||||
typedef struct
|
||||
{ int id, vers, skinxsiz, skinysiz, framebytes; //id:"IPD2", vers:8
|
||||
int numskins, numverts, numuv, numtris, numglcmds, numframes;
|
||||
int ofsskins, ofsuv, ofstris, ofsframes, ofsglcmds, ofseof; //ofsskins: skin names (64 bytes each)
|
||||
int numskins, numverts, numuv, numtris, numglcmds, numframes;
|
||||
int ofsskins, ofsuv, ofstris, ofsframes, ofsglcmds, ofseof; //ofsskins: skin names (64 bytes each)
|
||||
} md2typ;
|
||||
|
||||
typedef struct { point3d mul, add; } frametyp;
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
FILE *fil;
|
||||
int i, leng;
|
||||
char *fbuf;
|
||||
md2typ *head;
|
||||
frametyp *fptr;
|
||||
FILE *fil;
|
||||
int i, leng;
|
||||
char *fbuf;
|
||||
md2typ *head;
|
||||
frametyp *fptr;
|
||||
|
||||
if (argc != 4) { puts("KMD2TOOL [MD2 in file] [MD2 out file] [z offset] by Ken Silverman"); return(0); }
|
||||
if (!stricmp(argv[1],argv[2])) { puts("input&output filenames can't be same"); return(0); }
|
||||
if (argc != 4) { puts("KMD2TOOL [MD2 in file] [MD2 out file] [z offset] by Ken Silverman"); return(0); }
|
||||
if (!stricmp(argv[1],argv[2])) { puts("input&output filenames can't be same"); return(0); }
|
||||
|
||||
fil = fopen(argv[1],"rb"); if (!fil) { puts("error"); return(0); }
|
||||
leng = filelength(_fileno(fil));
|
||||
fbuf = (char *)malloc(leng); if (!fbuf) { puts("error"); return(0); }
|
||||
fread(fbuf,leng,1,fil);
|
||||
fclose(fil);
|
||||
fil = fopen(argv[1],"rb"); if (!fil) { puts("error"); return(0); }
|
||||
leng = filelength(_fileno(fil));
|
||||
fbuf = (char *)malloc(leng); if (!fbuf) { puts("error"); return(0); }
|
||||
fread(fbuf,leng,1,fil);
|
||||
fclose(fil);
|
||||
|
||||
head = (md2typ *)fbuf;
|
||||
if ((head->id != 0x32504449) && (head->vers != 8)) { free(fbuf); puts("error"); return(0); } //"IDP2"
|
||||
for(i=0;i<head->numframes;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;i<head->numframes;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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<numpalookups;i++)
|
||||
for(j=0;j<256;j++)
|
||||
{
|
||||
col = getpalookup((char)i,(char)j);
|
||||
palookup[(i<<8)+j] = col;
|
||||
for(i=0;i<numpalookups;i++)
|
||||
for(j=0;j<256;j++)
|
||||
{
|
||||
col = getpalookup((char)i,(char)j);
|
||||
palookup[(i<<8)+j] = col;
|
||||
|
||||
drawpixel(((((i<<1)+0)*320+(j+8))>>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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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<numwads;i++)
|
||||
{
|
||||
wadplc[i] = ((int)tempbuf[j])+(((int)tempbuf[j+1])<<8)+(((int)tempbuf[j+2])<<16)+(((int)tempbuf[j+3])<<24);
|
||||
j += 4;
|
||||
wadlen[i] = ((int)tempbuf[j])+(((int)tempbuf[j+1])<<8)+(((int)tempbuf[j+2])<<16)+(((int)tempbuf[j+3])<<24);
|
||||
j += 4;
|
||||
wadata[i][0] = tempbuf[j+0]; wadata[i][1] = tempbuf[j+1];
|
||||
wadata[i][2] = tempbuf[j+2]; wadata[i][3] = tempbuf[j+3];
|
||||
wadata[i][4] = tempbuf[j+4]; wadata[i][5] = tempbuf[j+5];
|
||||
wadata[i][6] = tempbuf[j+6]; wadata[i][7] = tempbuf[j+7];
|
||||
j += 8;
|
||||
}
|
||||
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<numwads;i++)
|
||||
{
|
||||
wadplc[i] = ((int)tempbuf[j])+(((int)tempbuf[j+1])<<8)+(((int)tempbuf[j+2])<<16)+(((int)tempbuf[j+3])<<24);
|
||||
j += 4;
|
||||
wadlen[i] = ((int)tempbuf[j])+(((int)tempbuf[j+1])<<8)+(((int)tempbuf[j+2])<<16)+(((int)tempbuf[j+3])<<24);
|
||||
j += 4;
|
||||
wadata[i][0] = tempbuf[j+0]; wadata[i][1] = tempbuf[j+1];
|
||||
wadata[i][2] = tempbuf[j+2]; wadata[i][3] = tempbuf[j+3];
|
||||
wadata[i][4] = tempbuf[j+4]; wadata[i][5] = tempbuf[j+5];
|
||||
wadata[i][6] = tempbuf[j+6]; wadata[i][7] = tempbuf[j+7];
|
||||
j += 8;
|
||||
}
|
||||
}
|
||||
|
||||
void convpalette(void)
|
||||
{
|
||||
int i, fil3;
|
||||
short danumshades;
|
||||
int i, fil3;
|
||||
short danumshades;
|
||||
|
||||
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],"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<xlen;x++)
|
||||
for(p=x;p<pend;p+=320)
|
||||
tempbuf[i++] = screen[p];
|
||||
if (Bwrite(fil2,&tempbuf[0],i) < 0)
|
||||
{
|
||||
printf("NOT ENOUGH DISK SPACE!\n");
|
||||
exit(0);
|
||||
}
|
||||
tilesizx[tilenum] = xlen;
|
||||
tilesizy[tilenum] = ylen;
|
||||
i = 0;
|
||||
for(x=0;x<xlen;x++)
|
||||
for(p=x;p<pend;p+=320)
|
||||
tempbuf[i++] = screen[p];
|
||||
if (Bwrite(fil2,&tempbuf[0],i) < 0)
|
||||
{
|
||||
printf("NOT ENOUGH DISK SPACE!\n");
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
void savenames(void)
|
||||
{
|
||||
BFILE * fil3;
|
||||
BFILE * fil3;
|
||||
int i;
|
||||
|
||||
fil3 = Bfopen("names.h","w");
|
||||
fil3 = Bfopen("names.h","w");
|
||||
|
||||
if (fil3 != NULL)
|
||||
{
|
||||
|
@ -109,159 +109,159 @@ void savenames(void)
|
|||
|
||||
void showart (char *part)
|
||||
{
|
||||
char yoff;
|
||||
short xsiz, ysiz;
|
||||
int i, z, zx, x, p, pend, curplc;
|
||||
char yoff;
|
||||
short xsiz, ysiz;
|
||||
int i, z, zx, x, p, pend, curplc;
|
||||
|
||||
curplc = -1;
|
||||
if ((Bstrncasecmp(part,"L_START",7) == 0) || (Bstrncasecmp(part,"S_START",7) == 0) || (Bstrncasecmp(part,"P_START",7) == 0))
|
||||
{
|
||||
if (Bstrncasecmp(part,"L_START",7) == 0)
|
||||
z = 462;
|
||||
else
|
||||
{
|
||||
z = 0;
|
||||
while (Bstrncasecmp(wadata[z],part,7) != 0) z++;
|
||||
z++;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if (Bstrncasecmp(wadata[z],"P1_START",8) == 0) z++;
|
||||
if (Bstrncasecmp(wadata[z],"P1_END",6) == 0) z++;
|
||||
if (Bstrncasecmp(wadata[z],"P2_START",8) == 0) z++;
|
||||
if (Bstrncasecmp(wadata[z],"S_START",7) == 0) break;
|
||||
if (Bstrncasecmp(wadata[z],"S_END",5) == 0) break;
|
||||
if (Bstrncasecmp(wadata[z],"P_END",5) == 0) break;
|
||||
|
||||
if (curplc != wadplc[z]) Blseek(fil1,wadplc[z],BSEEK_SET);
|
||||
read(fil1,&tempbuf[0],wadlen[z]);
|
||||
curplc = wadplc[z]+wadlen[z];
|
||||
curplc = -1;
|
||||
if ((Bstrncasecmp(part,"L_START",7) == 0) || (Bstrncasecmp(part,"S_START",7) == 0) || (Bstrncasecmp(part,"P_START",7) == 0))
|
||||
{
|
||||
if (Bstrncasecmp(part,"L_START",7) == 0)
|
||||
z = 462;
|
||||
else
|
||||
{
|
||||
z = 0;
|
||||
while (Bstrncasecmp(wadata[z],part,7) != 0) z++;
|
||||
z++;
|
||||
}
|
||||
|
||||
xsiz = (int)tempbuf[0]+(((int)tempbuf[1])<<8);
|
||||
ysiz = (int)tempbuf[2]+(((int)tempbuf[3])<<8);
|
||||
if ((xsiz <= 0) || (ysiz <= 0) || (xsiz > 320) || (ysiz > 200)) goto skipit;
|
||||
i = 8;
|
||||
for(zx=0;zx<xsiz;zx++)
|
||||
{
|
||||
xoffses[zx] = ((int)tempbuf[i])+(((int)tempbuf[i+1])<<8)+(((int)tempbuf[i+2])<<16)+(((int)tempbuf[i+3])<<24);
|
||||
i += 4;
|
||||
}
|
||||
do
|
||||
{
|
||||
if (Bstrncasecmp(wadata[z],"P1_START",8) == 0) z++;
|
||||
if (Bstrncasecmp(wadata[z],"P1_END",6) == 0) z++;
|
||||
if (Bstrncasecmp(wadata[z],"P2_START",8) == 0) z++;
|
||||
if (Bstrncasecmp(wadata[z],"S_START",7) == 0) break;
|
||||
if (Bstrncasecmp(wadata[z],"S_END",5) == 0) break;
|
||||
if (Bstrncasecmp(wadata[z],"P_END",5) == 0) break;
|
||||
|
||||
clearbuf(screen,ylookup[ysiz]>>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<xsiz;x++)
|
||||
{
|
||||
i = xoffses[x];
|
||||
yoff = tempbuf[i++];
|
||||
while (yoff != 255)
|
||||
{
|
||||
p = ylookup[yoff]+x;
|
||||
pend = p+ylookup[tempbuf[i]];
|
||||
i += 2;
|
||||
for(;p<pend;p+=320)
|
||||
screen[p] = tempbuf[i++];
|
||||
i++;
|
||||
yoff = tempbuf[i++];
|
||||
}
|
||||
}
|
||||
xsiz = (int)tempbuf[0]+(((int)tempbuf[1])<<8);
|
||||
ysiz = (int)tempbuf[2]+(((int)tempbuf[3])<<8);
|
||||
if ((xsiz <= 0) || (ysiz <= 0) || (xsiz > 320) || (ysiz > 200)) goto skipit;
|
||||
i = 8;
|
||||
for(zx=0;zx<xsiz;zx++)
|
||||
{
|
||||
xoffses[zx] = ((int)tempbuf[i])+(((int)tempbuf[i+1])<<8)+(((int)tempbuf[i+2])<<16)+(((int)tempbuf[i+3])<<24);
|
||||
i += 4;
|
||||
}
|
||||
|
||||
saveart(z,xsiz,ysiz);
|
||||
clearbuf(screen,ylookup[ysiz]>>2,0xffffffff);
|
||||
|
||||
for(x=0;x<xsiz;x++)
|
||||
{
|
||||
i = xoffses[x];
|
||||
yoff = tempbuf[i++];
|
||||
while (yoff != 255)
|
||||
{
|
||||
p = ylookup[yoff]+x;
|
||||
pend = p+ylookup[tempbuf[i]];
|
||||
i += 2;
|
||||
for(;p<pend;p+=320)
|
||||
screen[p] = tempbuf[i++];
|
||||
i++;
|
||||
yoff = tempbuf[i++];
|
||||
}
|
||||
}
|
||||
|
||||
saveart(z,xsiz,ysiz);
|
||||
skipit:
|
||||
z++;
|
||||
} while (z < numwads);
|
||||
}
|
||||
else
|
||||
{
|
||||
z = 0;
|
||||
while (Bstrncasecmp(wadata[z],part,7) != 0) z++;
|
||||
z++;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (Bstrncasecmp(wadata[z],"F1_START",8) == 0) z++;
|
||||
if (Bstrncasecmp(wadata[z],"F1_END",6) == 0) z++;
|
||||
if (Bstrncasecmp(wadata[z],"F_END",5) == 0) break;
|
||||
z++;
|
||||
} while (z < numwads);
|
||||
}
|
||||
else
|
||||
{
|
||||
z = 0;
|
||||
while (Bstrncasecmp(wadata[z],part,7) != 0) z++;
|
||||
z++;
|
||||
|
||||
if (wadlen[z] == 4096)
|
||||
{
|
||||
if (curplc != wadplc[z]) Blseek(fil1,wadplc[z],BSEEK_SET);
|
||||
Bread(fil1,&tempbuf[0],4096);
|
||||
curplc = wadplc[z]+4096;
|
||||
i = 0;
|
||||
for(x=0;x<64;x++)
|
||||
for(p=x;p<320*64;p+=320)
|
||||
screen[p] = tempbuf[i++];
|
||||
while (1)
|
||||
{
|
||||
if (Bstrncasecmp(wadata[z],"F1_START",8) == 0) z++;
|
||||
if (Bstrncasecmp(wadata[z],"F1_END",6) == 0) z++;
|
||||
if (Bstrncasecmp(wadata[z],"F_END",5) == 0) break;
|
||||
|
||||
saveart(z,64,64);
|
||||
}
|
||||
if (wadlen[z] == 4096)
|
||||
{
|
||||
if (curplc != wadplc[z]) Blseek(fil1,wadplc[z],BSEEK_SET);
|
||||
Bread(fil1,&tempbuf[0],4096);
|
||||
curplc = wadplc[z]+4096;
|
||||
i = 0;
|
||||
for(x=0;x<64;x++)
|
||||
for(p=x;p<320*64;p+=320)
|
||||
screen[p] = tempbuf[i++];
|
||||
|
||||
z++;
|
||||
}
|
||||
}
|
||||
saveart(z,64,64);
|
||||
}
|
||||
|
||||
z++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i, j, endoffile;
|
||||
char wadfile[80];
|
||||
int i, j, endoffile;
|
||||
char wadfile[80];
|
||||
|
||||
printf("Wad2Art! Copyright 1995 by Ken Silverman\n");
|
||||
printf("Wad2Art! Copyright 1995 by Ken Silverman\n");
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
printf("Command line parameters: Wad2Art [Doom IWAD file]\n");
|
||||
printf(" Creates TILES000.ART, PALETTE.DAT, and NAMES.H in current directory.\n");
|
||||
printf(" Ex: wad2art c:\\doom\\doom.wad\n");
|
||||
exit(0);
|
||||
}
|
||||
if (argc != 2)
|
||||
{
|
||||
printf("Command line parameters: Wad2Art [Doom IWAD file]\n");
|
||||
printf(" Creates TILES000.ART, PALETTE.DAT, and NAMES.H in current directory.\n");
|
||||
printf(" Ex: wad2art c:\\doom\\doom.wad\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
strcpy(wadfile,argv[1]);
|
||||
if (strchr(wadfile,'.') == 0) strcat(wadfile,".wad");
|
||||
if ((fil1 = Bopen(wadfile,BO_BINARY|BO_RDONLY,BS_IREAD)) == -1)
|
||||
{ printf("Wad not found\n"); exit(0); }
|
||||
if ((fil2 = Bopen("tiles000.art",BO_BINARY|BO_TRUNC|BO_CREAT|BO_WRONLY,BS_IREAD|BS_IWRITE)) == -1)
|
||||
{ printf("Can't open art file\n"); exit(0); }
|
||||
strcpy(wadfile,argv[1]);
|
||||
if (strchr(wadfile,'.') == 0) strcat(wadfile,".wad");
|
||||
if ((fil1 = Bopen(wadfile,BO_BINARY|BO_RDONLY,BS_IREAD)) == -1)
|
||||
{ printf("Wad not found\n"); exit(0); }
|
||||
if ((fil2 = Bopen("tiles000.art",BO_BINARY|BO_TRUNC|BO_CREAT|BO_WRONLY,BS_IREAD|BS_IWRITE)) == -1)
|
||||
{ printf("Can't open art file\n"); exit(0); }
|
||||
|
||||
j = 0;
|
||||
for(i=0;i<256;i++) { ylookup[i] = j; j += 320; }
|
||||
j = 0;
|
||||
for(i=0;i<256;i++) { ylookup[i] = j; j += 320; }
|
||||
|
||||
printf("Loading wad header...\n");
|
||||
loadwadheader();
|
||||
Blseek(fil2,16+(numwads<<3),SEEK_SET);
|
||||
for(i=0;i<numwads;i++)
|
||||
{ tilesizx[i] = 0; tilesizy[i] = 0; picanm[i] = 0L; }
|
||||
printf("Loading wad header...\n");
|
||||
loadwadheader();
|
||||
Blseek(fil2,16+(numwads<<3),SEEK_SET);
|
||||
for(i=0;i<numwads;i++)
|
||||
{ tilesizx[i] = 0; tilesizy[i] = 0; picanm[i] = 0L; }
|
||||
|
||||
printf("Saving names.h\n");
|
||||
savenames();
|
||||
printf("Converting palette\n");
|
||||
convpalette();
|
||||
printf("Saving names.h\n");
|
||||
savenames();
|
||||
printf("Converting palette\n");
|
||||
convpalette();
|
||||
|
||||
printf("Saving tiles000.art\n");
|
||||
showart("L_START");
|
||||
showart("S_START");
|
||||
showart("P_START");
|
||||
showart("F_START");
|
||||
printf("Saving tiles000.art\n");
|
||||
showart("L_START");
|
||||
showart("S_START");
|
||||
showart("P_START");
|
||||
showart("F_START");
|
||||
|
||||
printf("Saving tiles000.art header\n");
|
||||
artversion = 1; localtilestart = 0; localtileend = numwads-1;
|
||||
printf("Saving tiles000.art header\n");
|
||||
artversion = 1; localtilestart = 0; localtileend = numwads-1;
|
||||
|
||||
endoffile = Btell(fil2);
|
||||
Blseek(fil2,0,BSEEK_SET);
|
||||
Bwrite(fil2,&artversion,4);
|
||||
Bwrite(fil2,&numwads,4);
|
||||
Bwrite(fil2,&localtilestart,4);
|
||||
Bwrite(fil2,&localtileend,4);
|
||||
Bwrite(fil2,&tilesizx[0],numwads<<1);
|
||||
Bwrite(fil2,&tilesizy[0],numwads<<1);
|
||||
Bwrite(fil2,&picanm[0],numwads<<2);
|
||||
Blseek(fil2,endoffile,BSEEK_SET);
|
||||
endoffile = Btell(fil2);
|
||||
Blseek(fil2,0,BSEEK_SET);
|
||||
Bwrite(fil2,&artversion,4);
|
||||
Bwrite(fil2,&numwads,4);
|
||||
Bwrite(fil2,&localtilestart,4);
|
||||
Bwrite(fil2,&localtileend,4);
|
||||
Bwrite(fil2,&tilesizx[0],numwads<<1);
|
||||
Bwrite(fil2,&tilesizy[0],numwads<<1);
|
||||
Bwrite(fil2,&picanm[0],numwads<<2);
|
||||
Blseek(fil2,endoffile,BSEEK_SET);
|
||||
|
||||
Bclose(fil2);
|
||||
Bclose(fil1);
|
||||
Bclose(fil2);
|
||||
Bclose(fil1);
|
||||
|
||||
printf("Congratulations! Your disk actually had enough space this time!\n");
|
||||
printf("Congratulations! Your disk actually had enough space this time!\n");
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue