HiResColour PRINT Driver by Lanex, 2021
===============================================================

This program helps you to utilise the new HiResColour (HRC)
graphics mode in BASIC programs on your ZX Spectrum.

---------------------------------------------------------------
 The HRC consist of 512*192 pixels. Moreover, every block of
 8*4 pixels has its own attributes. This makes a screen with
 64*24 chars and 64*48 attributes for standard (8 pixel wide
 and high) characters. The attribute format is common, the
 same as with 32*24 screen characters.

 A HRC screen takes 12288 bytes (bitmap) plus 3072 bytes for
 attributes. A storage method of a HRC bitmap is linear, thus
 dealing with pixels is simple and more programming techniques
 and new tricks are possible (incl. Z80-DMA RAM-to-RAM
 transfers). Two HRC memory areas are available, starting at
 16384 or 49152 (screen memory banks no. 5 and 7 on ram-paging
 models). Both areas can be used together in GigaScreen and
 KeyLayer (with a transparent colour) modes.

 The HRC is currently implemented in the MB03+ Ultimate
 interface and in the eLeMeNt ZX computer, available through
 their digital video outputs. However, it was designed to be
 included easily into any modern ULA replacement and is
 compatible with the ULA+, besides the old Timex HiRes graphic.

----------------------------------------------------------------
1. Description

The HRC PRINT Driver makes BASIC LPRINT command to print
characters onto the HiRes screen.

The extended attributes area of 64*48 cells allows to
- colour a space of one character with four colors
- print characters at positions of half rows 
- make colour gradients in one character 

----------------------------------------------------------------
2. Syntax

LPRINT uses these parameters:

   AT half-row,column     to set a position        
                              half-row is <0,47>
                              column is <0,63>
   PAPER atrribute-value  to set colours for a whole character
   INK atrribute-value    to set colours for a lower char-half

e.g. LPRINT AT 12,6; PAPER 71; INK 2;"Hello!"

A colour attribute is a number between 0 and 255 consisting of

    bit  7       Flash on/off
    bit  6       Bright on/off
    bits 5,4,3   Paper colour
    bit  2,1,0   Ink colour

Colours are

    0   000   Black 		 4   100   Green 		
    1   001   Blue 		     5   101   Cyan 		
    2   010   Red 		     6   110   Yellow 		
    3   011   Magenta 	     7   111   White    
    
e.g.  7+8*1    = 15   white chars and blue background
      2+8*0+64 = 66   bright red chars and black background

HRC PRINT Driver example:
    LPRINT PAPER 66; INK 2 makes red characters on black paper,
    with its upper half brighter and its lower part darker

An attached demo (files for the esxDOS and also in TAPs) will
show and list more examples.

----------------------------------------------------------------
3. Important calls and internals

The whole machine code is small, only 390 bytes long. Two memory
versions are available. The first starts at 48680, the second at
32768. The current version of the driver cannot be relocated. 

Run the driver via RANDOMIZE USR 48643 (or 32771). You can also
call this again when needed to clear HRC screen.

When stopping the program that is using a HRC screen, before a
return to the BASIC editor, you have to call 48640 (or 32768).

The HRC Driver should work on any speed of the real Z80-CPUs
(was tested on 7, 14 and 20 MHz settings of the eLeMeNt ZX
computer, in all Pentagon modes).

----------------------------------------------------------------
4. Change of charset

The system variable CHARS (of 2 bytes, at address 23606 dec.) is
used by the HRC PRINT Driver to trace character data from a
standard ZX Spectrum system font. 

The CHARS variable normally aims to ROM. Its value is an address
of a character set, lowered by 256. You can set up your own
address in RAM and make CHARS point to it. A font file should be
always 768 bytes long and start with space (CHR$ 32) and carry
on to the copyright symbol (CHR$ 127).

    LOAD *"charset" CODE addr    
	POKE 23606,addr-256*INT (addr/256) 
	POKE 23607,INT (addr/256) 
                               Note: LOAD* is the esxDOS syntax.

If you use alternative ROMs that can handle hexadecimal numbers,
then a switch to a new font is easier. While the value 23606 is
mostly the zero by default, you usually only need, for example,
to enter

    LOAD *"charset" CODE &fc00
    POKE 23607,&fb
                        Why a number &fb?  &fb00 = &fc00 - &100
                                           64256 = 64512 - 256

Note: This works in the ZXDIR ROM. Use the "%" sign instead of
      the "&" for the BSROM.

Since the HiResColour PRINT Driver does not peek&poke the
attribute area in the original zx-screen (which is 32 * 24,
ie 768 bytes), we can also use its initial address (22528) for
an alternative font.

    LOAD *"charset" CODE &5800
    POKE 23607,&57 

================================================================ 
                                    https://www.ilnx.cz/kontakt/
