Tutorial 6 – Multicolor Images

This will be a short one.

Start Turbo Rascal SE and click the “images” tab. Select a new image of type “multicolor”, and press “import”.

In the import section, open an image of your own choosing. For that special effect, I decided on a nice image of a moose during sunset. Probably because I live in Norway. Play around with parameters in order to create a perfect atmospheric image of a moose.

Here’s a screenshot of the editor

When you are done with the image, export as binary to your .RAS project folder.

Now here’s the nice part: the code is absolutely short.

program Tutorial6;
	image_color: IncBin("images/moose_color.bin", "$5000");
	image_data: IncBin("images/moose_data.bin", "$6000");

	poke(VIC_DATA_LOC, 0,$18);
	copyimagecolordata(image_color,1); // bank 1



Some handy explanations:

  • The binary part of the image is split into two parts: _data and _color. The _data file contains the 8×8 character information for this bitmap, while the color binary contains the color information.
  • Notice that the color and data are stored in the VIC bank #1, with memory addresses between $4000-$8000. This is done because we’ll have tons of space for code on lower memory addresses
  • The function “setmulticolormode” sets the VIC multi color mode, while the setbitmapmode enables bitmap displaying (and disables character text etc)
  • The technical part: We need to poke the VIC_DATA_LOC in order to tell the VIC that
    • The screen memory will be placed at $400, which is specified by the high bit of $18: $1 * $400 = 400
    • The bitmap data is stored at $400*8 = $2000, but locally on bank #1 at $4000 means that the actual position is $2000 +$4000 = $6000
  • We then set BANK 1 to be enabled, using memory addresses $4000-$8000 for the current display
  • Finally, we copy the color information from the variable image_color to the actual screen memory, using bank 1 (specified by the final parameter)
  • In the end, loop and enjoy!

Here’s the code running on VICE.<