Building a Human68k BMP converter for the X68000
The Sharp X68000 was designed around a graphical environment that feels wonderfully direct by modern standards. Images are stored in formats suited to its video hardware, colours are handled through palette registers, and screen memory is mapped in ways that reward careful programming. A BMP-to-X68000 converter therefore needs to do more than open a Windows bitmap and copy pixels. It must translate between two different assumptions about colour, layout and memory.
A practical Human68k tool can make that translation repeatable. Instead of manually converting artwork on a modern computer, transferring files, testing them on real hardware and correcting palette problems, an enthusiast can run one command and produce an image ready for an X68000 graphics program or game-development workflow. The same utility can support preservation work, homebrew projects and demonstrations on period-correct displays.
The most useful design is a small command-line program with a predictable input format, clear output options and conservative defaults. BMP files may contain indexed colours, 24-bit RGB data or 32-bit pixels with unused alpha bytes. X68000 software may expect packed pixels, planar bitplanes, a fixed palette or a particular screen mode. Keeping these stages separate makes the converter easier to test and extend.
This is also a good project for the broader retrocomputing community. Australian owners often wait for imported hardware from Japan, pay close attention to postage and GST, and may test equipment through a SCART-to-component setup or a period monitor found in Melbourne, Sydney or Brisbane. A dependable image tool reduces the number of physical variables involved when diagnosing whether a problem belongs to the artwork, the cable, the monitor or the computer.
Defining the target screen format
The first decision is to identify exactly which X68000 screen format the program will create. “X68000 image” is too broad because the platform supports several resolutions, colour depths and memory arrangements. A converter aimed at a 16-colour screen has different constraints from one producing a 256-colour image, and a tool for a graphics library may need a different file layout from a tool for a game engine.
A useful command line might accept options such as -mode 256x256x16, -mode 512x512x16 or -mode 256x256x256, depending on the formats supported by the target software. It should reject unsupported combinations rather than silently resizing or reducing the image. The output specification should document width, height, number of colours, palette order, pixel packing and byte order in plain language.
Screen memory deserves particular care. Depending on the graphics mode, pixels may be stored as separate bitplanes rather than consecutive colour indices. In a four-plane image, one bit from each plane contributes to the final pixel value. A converter that writes ordinary chunky pixels into a file expected to contain bitplanes will produce an image that looks like random noise, even though the source and destination dimensions appear correct.
It is sensible to implement an intermediate representation based on palette indices. The loader produces RGB pixels, the quantiser maps them to indices, and the encoder transforms those indices into the required X68000 memory or file layout. That separation allows the same colour-reduction code to feed several output formats and makes debugging far easier.
Reading BMP files safely
BMP is deceptively simple. The file begins with a bitmap file header followed by a DIB header, optional palette data and pixel storage. Header sizes vary, fields are little-endian, and rows are padded to four-byte boundaries. A robust Human68k utility should read fields using explicit byte operations rather than assuming the host compiler will lay out a C structure identically to the file format.
The converter should support the BMP variants that are genuinely useful and reject the rest with a helpful message. Indexed 1-bit, 4-bit and 8-bit files are valuable because they already contain a palette. Twenty-four-bit BMPs are common for artwork exported from modern applications, while 32-bit files may contain an alpha channel that the X68000 destination cannot represent. Top-down BMPs, identified by a negative height in some DIB formats, also need deliberate handling.
Rows in a conventional BMP are stored from the bottom upwards. The loader can normalise this immediately into a top-to-bottom image buffer, then let the rest of the program work in normal screen coordinates. It must also account for row padding: an 8-bit image that is 257 pixels wide does not occupy 257 bytes per row on disk. The stored stride is rounded up to a multiple of four.
Input validation matters on an older platform. Check that offsets remain inside the file, multiplication cannot overflow the chosen integer type, the compression mode is supported and the declared dimensions are reasonable. A damaged download or incomplete floppy transfer should result in an error such as “pixel data ends before row 120”, rather than a crash or a corrupt output file.
Reducing colours for X68000 hardware
The hardest visual problem is usually colour quantisation. A 24-bit BMP may contain thousands of subtly different colours, while an X68000 screen mode may provide only 16 or 256 palette entries. Selecting the first colours encountered will technically produce an image, but gradients, skin tones and shadows will often break into distracting patches.
For a compact utility, median-cut quantisation is a practical starting point. The algorithm divides the colour population into boxes, repeatedly splitting the box with the greatest colour range until the desired number of palette entries is reached. The average or weighted average of each box becomes a palette colour. It is straightforward to implement, reasonably fast on Human68k and much better than simple truncation.
A more advanced version could offer uniform quantisation, popularity-based selection and an optional error-diffusion dither. Floyd–Steinberg dithering can make photographs and shaded illustrations appear smoother by distributing quantisation error to neighbouring pixels. It can also create speckle and unwanted patterns on pixel art, so dithering should be disabled by default or selected with an explicit option.
Pixel art needs a different priority from photographic material. Nearest-colour mapping preserves crisp blocks and intentional outlines, while dithering can destroy a carefully chosen two-tone shadow. The converter could provide --dither none, --dither ordered and --dither floyd, allowing the user to select a method for each source image. A fixed palette file is even more useful for a game project that needs consistent colours across multiple screens.
The palette should be written in the exact order expected by the target program. If the X68000 format uses a restricted number of bits per red, green and blue component, the converter should round values to those limits before generating the final palette. It should also report the resulting colours, perhaps through a text palette dump, so an artist can see why a bright Australian sky became a muted blue on a real monitor.
Encoding pixels and palette data
Once every source pixel has a destination index, encoding becomes a mechanical but important process. For packed indexed output, the program writes one or more indices into each byte according to the selected colour depth. For planar output, it loops through each bitplane and writes the corresponding bit for every pixel in the required order. The implementation should describe whether bytes advance across a row, down a column or through a block arrangement.
A test image is more useful than a complicated photograph during development. Generate a checkerboard, numbered colour bars, diagonal lines and a one-pixel border. Each pattern exposes a different class of error: reversed bit order, wrong stride, swapped planes, incorrect row direction or a mistaken palette index. Keep these fixtures in the source repository and compare the generated files against known-good binary output.
Human68k programs also need to be conscious of memory and execution time. A 512-by-512 true-colour working buffer may be unnecessary when the final screen has only 16 colours. The desktop build can use a comfortable buffer for development, but the X68000 version should avoid wasteful duplicate copies. Processing one row at a time is possible for some quantisation methods, while others require the full image to calculate a useful palette.
For documentation and preservation, consider producing two output files: the screen data and a small palette file. This makes it easier to inspect each component independently and to reuse the palette in a sprite or tile converter. A header option can include width, height, format identifier and palette count, while a raw option can remain available for software that expects an exact memory dump.
Designing a useful Human68k command line
A command-line interface should be friendly to both local users and scripts. A basic invocation might look like BMP2X68 image.bmp image.pi -mode 256x256x16, with optional arguments for resizing, cropping, palette selection, dithering and output format. Keep the default behaviour conservative: preserve the source aspect ratio, refuse unexpected cropping and warn when an image exceeds the selected screen dimensions.
Human68k users may run the program from a floppy disk, hard-disk image, CompactFlash adapter or network share. Short option names are convenient on a Japanese keyboard, but long names make batch files self-explanatory. Filenames should be accepted with mixed case, and errors should identify the input file and the specific stage that failed. A message such as “unsupported BMP compression: RLE8” is far more useful than “bad file”.
Cross-compiling from a modern Linux or Windows system can speed development, but the final binary should be tested on an actual X68000 or a reliable emulator. Tools such as make, a cross-compiler and an emulator allow rapid iteration, while hardware confirms assumptions about alignment, stack size and system calls. This split workflow is especially useful in Australia, where an owner in Perth or regional New South Wales may prefer to validate most builds before waiting for a replacement disk or imported SCSI accessory.
Batch conversion is another worthwhile feature. A project can contain dozens of title screens, tilesets and background images, all needing the same palette and output format. A response file or shell-friendly command line allows the converter to process a directory while preserving predictable names. Include a verbose mode that prints source dimensions, selected palette size, output bytes and any crop or resize decisions.
Testing on real displays and in preservation workflows
A converter is finished only when its output has been viewed through the intended X68000 software and display chain. Emulator screenshots are valuable, but they may hide analogue colour behaviour, sync issues or palette-register assumptions. Test with a simple viewer that can display the generated format without additional game-engine processing, then compare the result with the original BMP on a calibrated modern screen.
Australian power and video conditions add practical details. The local mains supply is nominally 230 volts at 50 Hz, and imported Japanese equipment may require a suitable transformer or a correctly repaired power supply rather than an improvised adaptor. PAL-era televisions and modern converters can interpret RGB signals differently, so a colour mismatch should not immediately be blamed on the quantiser. Keep a known-good test image and cable available before changing the software.
Hardware maintenance can affect testing just as much as image encoding. A marginal floppy drive, ageing capacitors or an unstable expansion board may corrupt the transferred file. Notes on floppy drive calibration show why disciplined measurement matters when a physical device appears unreliable. Verify checksums on files copied between machines, especially when using old disks or long serial transfers.
The finished utility should be documented alongside its source, sample BMP files and expected outputs. Publishing the project through a personal preservation site such as X68K.NET gives other owners a practical reference and keeps the tool connected to hardware notes, repair knowledge and related software. A short licence, build recipe and format description will help the next enthusiast maintain it when the original development environment becomes difficult to obtain.
A small project page can also explain where to find suitable hardware and media without pretending that every Australian buyer has the same options. Japanese auction services, local retrocomputing groups, Gumtree listings and specialist importers each have different costs and risks. A Sydney collector may find a monitor locally, while someone in Adelaide may rely on postage and need to budget for protective packing. Clear technical documentation is often more valuable than a polished download button because it lets users diagnose their own setup.
For broader visibility, a well-written release note can point readers towards retro computing resources while keeping the converter’s purpose clear. Include screenshots, a sample command, supported BMP types and a binary checksum. Avoid promising perfect conversion: state the colour limits, resizing rules and known incompatibilities so users can make informed decisions before transferring files to their machines.
Download the source, create a set of test patterns and implement the BMP loader before adding advanced dithering. Then verify each stage separately: decoded pixels, palette selection, indexed image data and final X68000 encoding. Share reproducible results with the enthusiast community, record which screen modes have been tested, and keep the tool small enough that another Human68k developer can inspect and improve it years from now.
Nereid-X Expansion Board
A personally-produced LAN+USB+Memory expansion board for Sharp X68000 series computers. Multiple production runs were offered, including a final batch and a later revival reproduction run.
Power Supply Repair
X68 power supply repair and modification services were offered by the site owner, with documentation shared through diary entries spanning 2001–2006.
Server & Networking
Notes on FreeBSD administration, ISP changes, server migration, and networking topics. The site itself ran on FreeBSD with the hns diary system and Namazu search integration.
Get in touch
X68K.NET connects Sharp X68000 enthusiasts through community links and shared projects. Reach out with questions about the Nereid project or X68 resources.