Not too long ago, Johnny D worked for a large worldwide electronics company that designed controllers and devices for all sorts of industries. Like many global corporations, Johnny had the usual problems dealing with international leadership and being such a small part of a large machine.

One request that came down the pipeline was that, since a new line of display units came out, Johnny would need to port some old controller code to the new platform. Of course, because the code had been transferred to and from different groups over the years, the specific compiler used to compile the code was long lost and forgotten, leaving Johnny with a whole host of problems and errors during compilation. In fact, he wasn't even sure how it passed any compiler, as there were no makefiles and over warnings and errors.

But as Johnny soon learned, that was just the tip of the iceberg. For some unknown reason, the original developer decided that the best way to deal with bitmap images was to convert them to C-files and header-files. That probably doesn't make a whole lot of sense, so I'll let the code explain.

First, the header (trs_sensor_calibration_bmp.h):

#ifndef __TRS_SENSOR_CALIBRATION_BMP_H__
#define __TRS_SENSOR_CALIBRATION_BMP_H__

#ifdef __cplusplus
extern "C"
{
#endif

#include "typedefs.h"

#define TRS_SENSOR_CALIBRATION_BMP_PALETTE_COUNT 2

extern _huge const struct bitmap_header_def TRS_SENSOR_CALIBRATION_BMP_HEADER;
extern _huge const u8 TRS_SENSOR_CALIBRATION_BMP_PALETTE[];
extern _huge const u8 TRS_SENSOR_CALIBRATION_BMP_DATA[];

#ifdef __cplusplus
};
#endif

#endif// __TRS_SENSOR_CALIBRATION_BMP_H__

While that might not seem too off, this is what trs_sensor_calibration_bmp.c looked like.

#include "typedefs.h"
#include "piclib.h"
...
#include "directives.h"


_huge const struct bitmap_header_def TRS_SENSOR_CALIBRATION_BMP_HEADER =
{
	0x0000009E,	// File size
	0x00000000,	// Reserved
	0x0000003E,	// Data offset
	0x00000028,	// Size
	0x0000001A,	// Width
	0x00000018,	// Height
	0x0001,		// Planes
	0x0001,		// Bitcount
	0x00000000,	// Compression
	0x00000060,	// Image size
	0x00000EC4,	// X pixels per meter
	0x00000EC4,	//Y pixels per meter
	0x00000002,	//Colors used
	0x00000000,	//Colors important
};

_huge const u8 TRS_SENSOR_CALIBRATION_BMP_PALETTE[] =
{
	0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 
};

_huge const u8 TRS_SENSOR_CALIBRATION_BMP_DATA[] =
{
	0xF7,0xFF,0xFF,0xFF,
	0xE7,0xFF,0xFF,0xFF,
	0xC0,0x7F,0xFF,0xFF,
	0xC0,0x70,0x3F,0xFF,
	0xE7,0xE0,0x1F,0xFF,
	0xF7,0xE7,0x9F,0xFF,
	0xFC,0x07,0x9F,0xFF,
	0xF8,0x0E,0x0F,0xFF,
	0xF9,0xFC,0x07,0xFF,
	0xF8,0x78,0xE3,0xFF,
	0xF0,0x01,0xF3,0xFF,
	0xF3,0x01,0xF3,0xFF,
	0xF3,0x18,0xE3,0xFF,
	0xF0,0x3C,0x07,0xFF,
	0xF8,0x7E,0x0F,0xFF,
	0xFF,0xFB,0xFF,0xFF,
	0xFF,0xEE,0xFF,0xFF,
	0xFF,0xF1,0xFF,0xFF,
	0xFF,0xDF,0x7F,0xFF,
	0xFF,0xE0,0xFF,0xFF,
	0xFF,0x7F,0xBF,0xFF,
	0xFF,0x80,0x7F,0xFF,
	0xFF,0xFF,0xFF,0xFF,
	0xFF,0xFF,0xFF,0xFF,
};

While clever, Johnny could never quite figure out how the "c-bitmap" is a good idea. But clearly, the original developer did: there were a total of 274 such "bitmaps" in the project.