remove some outdated code, tidy up

This commit is contained in:
nhmall
2023-01-12 09:42:02 -05:00
parent e2457754a6
commit 99a9f8600e
+4 -33
View File
@@ -120,23 +120,13 @@ typedef struct tagRGBQ {
#define BI_RLE4 2L #define BI_RLE4 2L
#define BI_BITFIELDS 3L #define BI_BITFIELDS 3L
#endif /* __GNUC__ */ #endif /* __GNUC__ */
#define RGBQUAD_COUNT 256
#pragma pack(1) #pragma pack(1)
struct tagBMP { struct tagBMP {
BITMAPFILEHEADER bmfh; BITMAPFILEHEADER bmfh;
BITMAPINFOHEADER bmih; BITMAPINFOHEADER bmih;
#if BITCOUNT == 4
#define RGBQUAD_COUNT 16
RGBQUAD bmaColors[RGBQUAD_COUNT]; RGBQUAD bmaColors[RGBQUAD_COUNT];
#else
#if (TILE_X == 32)
#define RGBQUAD_COUNT 256
#else
/*#define RGBQUAD_COUNT 16 */
#define RGBQUAD_COUNT 256
#endif
RGBQUAD bmaColors[RGBQUAD_COUNT];
#endif
uchar packtile; /* start */ uchar packtile; /* start */
} PACK bmp, *newbmp; } PACK bmp, *newbmp;
#pragma pack() #pragma pack()
@@ -208,12 +198,13 @@ main(int argc, char *argv[])
max_x = 16 * 40; max_x = 16 * 40;
max_y = ((16 * magictileno) / 40) + 16; max_y = ((16 * magictileno) / 40) + 16;
bmpsize = (sizeof bmp - sizeof bmp.packtile) + (max_y * (max_x * sizeof(uchar))); bmpsize = (sizeof bmp - sizeof bmp.packtile)
+ (max_y * (max_x * sizeof(uchar)));
newbmp = malloc(bmpsize); newbmp = malloc(bmpsize);
if (!newbmp) { if (!newbmp) {
printf("memory allocation failure, %d %d, aborting.\n", printf("memory allocation failure, %d %d, aborting.\n",
bmpsize, magictileno); bmpsize, magictileno);
exit(1); exit(EXIT_FAILURE);
} }
tilecount = 0; tilecount = 0;
xoffset = yoffset = 0; xoffset = yoffset = 0;
@@ -266,11 +257,7 @@ main(int argc, char *argv[])
} }
build_bmptile(tilepixels); build_bmptile(tilepixels);
tilecount++; tilecount++;
#if BITCOUNT == 4
xoffset += (TILE_X / 2);
#else
xoffset += TILE_X; xoffset += TILE_X;
#endif
if (xoffset >= max_x) { if (xoffset >= max_x) {
yoffset += TILE_Y; yoffset += TILE_Y;
xoffset = 0; xoffset = 0;
@@ -307,20 +294,11 @@ build_bmih(UNALIGNED_POINTER BITMAPINFOHEADER* pbmih)
WORD cClrBits; WORD cClrBits;
int w, h; int w, h;
pbmih->biSize = lelong(sizeof(bmp.bmih)); pbmih->biSize = lelong(sizeof(bmp.bmih));
#if BITCOUNT == 4
pbmih->biWidth = lelong(w = max_x * 2);
#else
pbmih->biWidth = lelong(w = max_x); pbmih->biWidth = lelong(w = max_x);
#endif
pbmih->biHeight = lelong(h = max_y); pbmih->biHeight = lelong(h = max_y);
pbmih->biPlanes = leshort(1); pbmih->biPlanes = leshort(1);
#if BITCOUNT == 4
pbmih->biBitCount = leshort(4);
cClrBits = 4;
#else
pbmih->biBitCount = leshort(8); pbmih->biBitCount = leshort(8);
cClrBits = 8; cClrBits = 8;
#endif
if (cClrBits == 1) if (cClrBits == 1)
cClrBits = 1; cClrBits = 1;
else if (cClrBits <= 4) else if (cClrBits <= 4)
@@ -372,16 +350,9 @@ build_bmptile(pixel(*pixels)[TILE_X])
tilecount); tilecount);
y = (max_y - 1) - (cur_y + yoffset); y = (max_y - 1) - (cur_y + yoffset);
apply_color = cur_color; apply_color = cur_color;
#if BITCOUNT == 4
x = (cur_x / 2) + xoffset;
newbmp.packtile[y][x] = (cur_x % 2 != 0)
? (uchar) (bmp.packtile[y][x] | cur_color)
: (uchar) (cur_color << 4);
#else
x = cur_x + xoffset; x = cur_x + xoffset;
c = &newbmp->packtile + ((y * max_x) + x); c = &newbmp->packtile + ((y * max_x) + x);
*c = (uchar) apply_color; *c = (uchar) apply_color;
#endif
} }
} }
} }