(c) Copyright 2009-2025 Óscar Toledo Gutiérrez https://nanochess.org/
Converts a BMP/PNG image to TMS9928 bitmap/color format, Sega Master System format, or NES/Famicom format.
tmscolor.c TMSColor C language source code.
vdp_colors.bmp A reference of VDP TMS9928 colors to use in your images.
LICENSE Source code license.
README.md This file.
tmscolor [options] image.bmp image.asm [label]
tmscolor [options] image.png image.asm [label]
-sms Generates Sega Master System format.
-nes Generates NES/Famicom format.
-b Generates CVBasic source code (use always for NES/Famicom)
-n Removes CVBasic stub code for displaying.
-s Process tiles in chunks of 16 pixels high (sprites).
-sb Same as above but generates readable bitmap statements (CVBasic mode)
-t Generates minimum of tiles required.
-t1 Same but starting at tile 1 (0-255).
-e45d2 Replaces color 4 with 5 and d with 2 before processing.
-fx Flip image along the X-coordinate (mirror)
-fy Flip image along the Y-coordinate
-i Generates BITMAP statements instead of DATA
-i2 Generates BITMAP statements using X and .
-m Generates magic sprites for areas with more than 2 colors
-p1 Searches best color combination for photo (slow)
-p2 Searches best color combination for photo (2x2 dither) (slow)
-o result.bmp
Outputs the final image, plus highlight of errors (if any).
By default it converts the image to assembler code (use option -b for CVBasic code). The label argument is for the label name used in the code.
Best photo conversion is generated by this command line:
tmscolor -p2 photo.bmp photo.asm
Or for CVBasic:
tmscolor -b -p2 photo.bmp photo.bas
Photos will look better if the contrast is good. Magic sprites will work only with an image of 256x192 pixels, and only for TMS9928.
For Sega Master System you should use the standard VDP colors, and you can provide your palette inside your game or program (for example, using the PALETTE LOAD sentence of CVBasic). It is way easier than trying to calculate a palette inside TMSColor.
For NES/Famicom you should use the standard TMS9928 VDP colors, the lower two bits of the color are used for the NES bitmap, and you can provide your palette inside your game or program (also using the PALETTE LOAD sentence). If you have black areas (RGB #000000), use the option -e10 to translate the standard black color (1) into the zero (0) used for NES/Famicom backgrounds, or use the RGB color #404040.
Also for NES/Famicom both -p1 and -p2 will translate the image into grayscale and generate a four tone image.
The current official version is v3.2
CVBasic is available from https://github.com/nanochess/CVBasic
If you find TMSColor useful, please show your appreciation making a donation via Paypal ($9 USD suggested) to b-i+y-u+b-i (at) gmail.com
If you find a bug, please report to same email and I'll try to look into it. Because lack of time I cannot guarantee it will be corrected.