Personal Log »

Processing data in the assembler

I got the inspiration from the fantastic rasm –a Z80 assembler–. rasm supports a number of formats for input and output, and the input goes way beyond the “include” we can find in some assemblers.

As part of my TR8 fantasy console I have implemented .incpng "file.png", that does the following –from the docs–:

.incpng “filename”
Read the PNG image and add the content to the output at current position. The image colors will be matched with the TR8 palette and any non-matching color will be considered transparent and the index 128 will be used.

So it is like a “include binary”, but it understand and reads a PNG file, including the pixel data in the assembled output.

It converts the image to red, green and blue triplets –RGB values– and maps them to the EGA default palette –which is the palette I’m currently using–. If a RGB value doesn’t match the EGA palette, the tool uses 128. That value is used with the blitter if transparent is enabled to treat it as transparent –otherwise it will be black–.

Example game (WIP)

The menu of the example game uses 'incpng' for the title

It is so convenient to use! But obviously, this is only because I’m writing the assembler myself –and it has many limitations, currently–. Using other compilers, very often the options are very limited, and that is when my conversion tools written in Python save the day.

Would you like to discuss the post? You can send me an email!