cpct_setPALColour

Changes one colour value of the Palette, similarly to BASIC’s INK instruction.

C Definition

void cpct_setPALColour (u8 pen, u8 hw_ink)

Input Parameters (2 Bytes)

(1B L) pen[0-16] Index of the palette colour to change.  Similar to PEN Number in BASIC.
(1B H) hw_ink[0-31] New hardware colour value for the given palette index.

Assembly call (Input parameters on registers)

call cpct_setPALColour_asm

Parameter Restrictions

  • pen must be <= 16.  Values [0-15] are normal palette colours, while index 16 refers to the Screen Border.  Giving pen > 16 may yield unexpected behaviour.
  • hw_ink must be <= 31.

Requirements

This function requires the CPC firmware to be DISABLED.  Otherwise, it may not work, as firmware tends to restore palette colour values to its own selection.

Details

This function modifies changes one concrete palette registers to set the hardware value of one of the available colours.  This process is similar to the one that does the BASIC’s INK command.  However, this function does it giving a direct command to the PAL chip (which is inside the Gate Array).  The PAL chip contains the 17 registers that hold the colour values for the 16 available colours of the Amstrad CPC (PENs), and the screen border colour.

Gate Array (GA) is accessed through the port 0x7F.  PENR and INKR commands are used to select the register that will be modified and then sending the new hardware colour value to set.  It is important to remember that this commands are processed by the PAL chip and it requires hardware colour values for INKR, which are different from firmware colour values (which are used by BASIC’s INK command).

Destroyed Register values

F, BC, HL

Required memory

C-bindings12 bytes
ASM-bindings10 bytes

Time Measures

   Case     | microSecs (us) | CPU Cycles
------------------------------------------
    Any     |      25        |    100
------------------------------------------
 ASM-Saving |      -9        |    -36
------------------------------------------

Credits

This function has been constructed with great help from the documentation at Grimware about the Gate Array.

http://www.grimware.org/doku.php/documentations/devices/gatearray

Changes one colour value of the Palette, similarly to BASIC’s INK instruction.
unsigned char (u8 = unsigned 8-bits, 1 byte )
Close