Video Macros&Constants

Summary
Video Macros&Constants
Macros and Constants
cpct_memPage6Macro that encodes a video memory page in the 6 Least Significant bits (LSb) of a byte, required as parameter for cpct_setVideoMemoryPage
Video Memory PagesUseful constants defining some typical Video Memory Pages to be used as parameters for cpct_setVideoMemoryPage
cpct_setBorderChanges the colour of the screen border.
cpct_clearScreenMacro to simplify clearing the screen.
cpct_clearScreen_f8Macro to simplify clearing the screen: fast version (in chuncks of 8 bytes)
cpct_clearScreen_f64Does exactly the same as cpct_clearScreen_f8 but calling cpct_memset_f64 instead of cpct_memset_f8.

Macros and Constants

cpct_memPage6

Macro that encodes a video memory page in the 6 Least Significant bits (LSb) of a byte, required as parameter for cpct_setVideoMemoryPage

C Definition

#define cpct_memPage6 (PAGE)

Parameters (1 byte)

(1B) PAGEVideo memory page wanted

Returns

u8Video Memory Page encoded in the 6 LSb of the byte.

Details

This is just a macro that shifts PAGE 2 bits to the right, to leave it with just 6 significant bits.  For more information, check functions cpct_setVideoMemoryPage and cpct_setVideoMemoryOffset.

Video Memory Pages

Useful constants defining some typical Video Memory Pages to be used as parameters for cpct_setVideoMemoryPage

cpct_pageCOVideo Memory Page 0xC0 (0xC0··)
cpct_page8OVideo Memory Page 0x80 (0x80··)
cpct_page4OVideo Memory Page 0x40 (0x40··)
cpct_page0OVideo Memory Page 0x00 (0x00··)

cpct_setBorder

Changes the colour of the screen border.

C Definition

#define cpct_setBorder (HWC) cpct_setPALColour (16, (HWC))

Input Parameters (1 Byte)

(1B) HWCHardware colour value for the screen border.

More information

This is not a real function, but a C macro.  Beware of using it along with complex expressions or calculations, as it may expand in non-desired ways.

For more information, check the real function cpct_setPALColour, which is called when using cpct_setBorderColour (It is called using 16 as pen argument, which identifies the border).

cpct_clearScreen

Macro to simplify clearing the screen.

C Definition

#define cpct_clearScreen (COL)

Parameters (1 byte)

(1B) COLColour pattern to be used for screen clearing.  Typically, a 0x00 is used to fill up all the screen with 0’s (firmware colour 0).  However, you may use it in combination with cpct_px2byteM0, cpct_px2byteM1 or a manually created colour pattern.

Details

Fills up all the standard screen (range [0xC000-0xFFFF]) with COL byte, the colour pattern given.  It uses <cpc_memset> to do the task, just filling up 16K bytes out of COL value, starting at 0xC000.

Measures

This function takes 98331 microseconds to fill the screen.  This is 4.924 VSYNCs on a 50Hz display.

cpct_clearScreen_f8

Macro to simplify clearing the screen: fast version (in chuncks of 8 bytes)

C Definition

#define cpct_clearScreen_f8 (COL)

Parameters (2 bytes)

(2B) COLColour pattern to be used for screen clearing.  Typically, a 0x0000 is used to fill up all the screen with 0’s (firmware colour 0).  However, you may use it in combination with cpct_px2byteM0, cpct_px2byteM1 or a manually created colour pattern.  Take into account that CPC’s memory access is little-endian: this means that using 0x1122 as colour pattern will fill up memory with the sequence 0x22, 0x11, 0x22, 0x11...

Details

Fills up all the standard screen (range [0xC000-0xFFFF]) with COL pair of bytes, the colour pattern given.  It uses <cpc_memset_f8> to do the task, just filling up 16K bytes out of COL value, starting at 0xC000.

Warning

<cpc_memset_f8> disables interrupts and moves SP while operating.  It also sets interrupts to enabled at its end, without taking into account its previous status.  Take it into account when using this macro.

Measures

This function takes 41036 microseconds to fill the screen.  This is 2.086 VSYNCs on a 50Hz display.

cpct_clearScreen_f64

Does exactly the same as cpct_clearScreen_f8 but calling cpct_memset_f64 instead of cpct_memset_f8.  Therefore, it works in chuncks of 64 bytes, being a 33% faster.

C Definition

#define cpct_clearScreen_f64 (COL)

Parameters (2 bytes)

(2B) COLColour pattern to be used for screen clearing.  Typically, a 0x0000 is used to fill up all the screen with 0’s (firmware colour 0).  However, you may use it in combination with cpct_px2byteM0, cpct_px2byteM1 or a manually created colour pattern.  Take into account that CPC’s memory access is little-endian: this means that using 0x1122 as colour pattern will fill up memory with the sequence 0x22, 0x11, 0x22, 0x11...

Details

Fills up all the standard screen (range [0xC000-0xFFFF]) with COL pair of bytes, the colour pattern given.  It uses <cpc_memset_f64> to do the task, just filling up 16K bytes out of COL value, starting at 0xC000.

Warning

<cpc_memset_f64> disables interrupts and moves SP while operating.  It also sets interrupts to enabled at its end, without taking into account its previous status.  Take it into account when using this macro.

Measures

This function takes 33843 microseconds to fill the screen.  This is 1.721 VSYNCs on a 50Hz display.

Sets the 6 most significant bits (the page) of the memory address where video memory starts.
Macro to simplify clearing the screen: fast version (in chuncks of 8 bytes)
Fills up a complete array in memory setting bytes 2-by-2, in chuncks of 64 bytes.
Fills up a complete array in memory setting bytes 2-by-2, in chuncks of 8 bytes.
Macro that encodes a video memory page in the 6 Least Significant bits (LSb) of a byte, required as parameter for cpct_setVideoMemoryPage
Sets the 8 Least Significant bits (the offset) of the memory address where video memory starts.
Changes the colour of the screen border.
Changes one colour value of the Palette, similarly to BASIC’s INK instruction.
Macro to simplify clearing the screen.
Transforms 2 pixel colour values [0-15] into a byte value in the video memory pixel format for Mode 0.
Transforms 4 pixel colour values [0-3] into a byte value in the video memory pixel format for Mode 1.
Does exactly the same as cpct_clearScreen_f8 but calling cpct_memset_f64 instead of cpct_memset_f8.
Close