    The tutorial procedure for colour printing at the graphic screen 640x256x16.

                 This procedure was used in the Flex Navigator v1.xx.
                       Written for Estex v1.xx or high.

Files description:
	main.z80  - initial(main) file
	print.z80 - printing procedure

Font format description:
  In the font used 256 symbols with height 8 points and various width.

  +000 [256] - width of a symbol on X (for each symbol) (in bytes)
  +256 [256] - low byte of symbol image offset (for each symbol)
  +512 [256] - high byte of symbol image offset (for each symbol)
  +768 ...   - images of symbols (from 0 to 255 symbol)
	       images stored as vertical lines, 8 bytes per line, 4 bits per point.
	       number of lines (in bytes) calculate from size of X
               background colour = 0x00
	       foreground colour = 0x0F

	       for instance, image of "A" symbol:
		width of symbol on X = 4 (bytes)
	        00 00 00 00
	        00 FF FF 00
	        0F 00 00 F0
	        0F 00 00 F0
	        0F FF FF F0
	        0F 00 00 F0
	        0F 00 00 F0
	        00 00 00 00

		In the image of symbol it will stored as:

		00 00 0F 0F 0F 0F 0F 00  00 FF 00 00 FF 00 00 00  00 FF 00 00 FF 00 00 00  00 00 F0 F0 F0 F0 F0 00
		
Algorithm description:
  The main problem for the colour printing was fast transformation each point (background/foregraunf) to the necessary colour.
Here, I will showed, how I could solve this a "hard" problem. ;) If somebody will think up faster variant, I will be glad to see it. :)

  The printing on the screen realized by vertical lines with the help of accelerator at once till 8 bytes.
We require 2 buffers, size in 8 bytes for the colors mixing (background and foreground). Because, to get mixed up we shall be at once till 1 vertical line. These buffers are initialized at each change of colour by function PreparePrintColors (It's made automatically and you don't need about it to care!).

Using print by function TextOut.

	operation | - Logical Inclusive OR (in Z80 CPU instruction OR)
	operation ^ - Logical Exclusive OR (in Z80 CPU instruction XOR)

Function PreparePrintColors:

	1. initialize ForegroundBuffer
		ForegroundBuffer = Foreground colour ^ 0xFF
	2. initialize BackgroundBuffer
		BackgroundBuffer = Background colour ^ ForegroundBuffer

Function TextOut (input parameters see in the source):
	actually, a image printing:
	Screen = (line_of_image | BackgroundBuffer) ^ ForegroundBuffer

Let's look at a point level:
	assume the colors for printing Background = 0, Foreground = 1

	then ForegroundBuffer = 1 ^ 0xFF and result 0xFE
	also BackgroundBuffer = 0 ^ 0xFE and result 0xFE

	for the background colour from a image (=0x00)
	Screen = (0x00 | 0xFE) ^ 0xFE result 0x00

	for the foreground colour from a image (=0xFF)
	Screen = (0xFF | 0xFE) ^ 0xFE result 0x01

It's possible to do for any of colours...

This algorithm works slower when are printed of very small strings. It occurs because a lot of initialization are required. Also when made often change of colour (Though, I hadn't changing it in the Flex Navigator so often, only for necessary). ;)

27 june 2002
Anton Enin (C) Copyright 2002 R-lab
If you have the questions email me: r-lab@mail.ru or ask in the Sprinter's forum.

