mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-01-06 16:32:23 +00:00
Documented and cleaned up verlib.h and veralib.c
This commit is contained in:
parent
f60c94a374
commit
ce8e0ab26a
@ -35,6 +35,12 @@ byte* vera_layer_hscroll_h[2] = {VERA_L0_HSCROLL_H, VERA_L1_HSCROLL_H};
|
||||
byte vera_layer_textcolor[2] = {WHITE, WHITE};
|
||||
byte vera_layer_backcolor[2] = {BLUE, BLUE};
|
||||
|
||||
// --- VERA addressing ---
|
||||
|
||||
void vera_vram_bank_offset(byte bank, word offset, byte incr);
|
||||
void vera_vram_address0(dword bankaddr, byte incr);
|
||||
void vera_vram_address1(dword bankaddr, byte incr);
|
||||
|
||||
// --- VERA active display management ---
|
||||
|
||||
void vera_display_set_scale_none();
|
||||
@ -42,6 +48,8 @@ void vera_display_set_scale_double();
|
||||
void vera_display_set_scale_triple();
|
||||
byte vera_display_get_hscale();
|
||||
byte vera_display_get_vscale();
|
||||
word vera_display_get_height();
|
||||
word vera_display_get_width();
|
||||
|
||||
// --- VERA LAYERS ---
|
||||
|
||||
@ -50,11 +58,26 @@ byte vera_display_get_vscale();
|
||||
// - config: Specifies the modes which are specified using T256C / 'Bitmap Mode' / 'Color Depth'.
|
||||
void vera_layer_set_config(byte layer, byte config);
|
||||
|
||||
// Set the configuration of the layer.
|
||||
|
||||
// Get the configuration of the layer.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - config: Specifies the modes which are specified using T256C / 'Bitmap Mode' / 'Color Depth'.
|
||||
// - return: Specifies the modes which are specified using T256C / 'Bitmap Mode' / 'Color Depth'.
|
||||
byte vera_layer_get_config(byte layer);
|
||||
|
||||
|
||||
// Set the configuration of the layer text color mode.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - color_mode: Specifies the color mode to be VERA_LAYER_CONFIG_16 or VERA_LAYER_CONFIG_256 for text mode.
|
||||
void vera_layer_set_text_color_mode( byte layer, byte color_mode );
|
||||
|
||||
// Set the configuration of the layer to bitmap mode.
|
||||
// - layer: Value of 0 or 1.
|
||||
void vera_layer_set_bitmap_mode( byte layer );
|
||||
|
||||
// Set the configuration of the layer to tilemap mode.
|
||||
// - layer: Value of 0 or 1.
|
||||
void vera_layer_set_tilemap_mode( byte layer );
|
||||
|
||||
// Set the map width or height of the layer.
|
||||
// - layer: Value of 0 or 1.
|
||||
inline void vera_layer_set_width_32(byte layer);
|
||||
@ -66,41 +89,72 @@ inline void vera_layer_set_height_64(byte layer);
|
||||
inline void vera_layer_set_height_128(byte layer);
|
||||
inline void vera_layer_set_height_256(byte layer);
|
||||
|
||||
// Get the map width of the layer.
|
||||
// - layer: Value of 0 or 1.
|
||||
word vera_layer_get_width(byte layer);
|
||||
|
||||
// Get the map height of the layer.
|
||||
// - layer: Value of 0 or 1.
|
||||
word vera_layer_get_height(byte layer);
|
||||
|
||||
|
||||
// Set the color depth of the layer in bit per pixel (BPP) to 1.
|
||||
// - layer: Value of 0 or 1.
|
||||
inline void vera_layer_set_color_depth_1BPP(byte layer);
|
||||
|
||||
// Set the color depth of the layer in bit per pixel (BPP) to 1.
|
||||
// - layer: Value of 0 or 1.
|
||||
inline void vera_layer_set_color_depth_2BPP(byte layer);
|
||||
|
||||
// Set the color depth of the layer in bit per pixel (BPP) to 1.
|
||||
// - layer: Value of 0 or 1.
|
||||
inline void vera_layer_set_color_depth_4BPP(byte layer);
|
||||
|
||||
// Set the color depth of the layer in bit per pixel (BPP) to 1.
|
||||
// - layer: Value of 0 or 1.
|
||||
inline void vera_layer_set_color_depth_8BPP(byte layer);
|
||||
|
||||
// Get the color depth of the layer.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - return: 0 = 1 color, 1 = 2 colors, 2 = 4 colors or 3 = 8 colors.
|
||||
inline byte vera_layer_get_color_depth(byte layer);
|
||||
|
||||
// Enable the layer to be displayed on the screen.
|
||||
// - layer: 0 or 1.
|
||||
void vera_layer_show(byte layer);
|
||||
inline void vera_layer_show(byte layer);
|
||||
|
||||
// Disable the layer to be displayed on the screen.
|
||||
// - layer: 0 or 1.
|
||||
void vera_layer_hide(byte layer);
|
||||
inline void vera_layer_hide(byte layer);
|
||||
|
||||
// Is the layer shown on the screen?
|
||||
// - returns: 1 if layer is displayed on the screen, 0 if not.
|
||||
byte vera_layer_is_visible(byte layer);
|
||||
inline byte vera_layer_is_visible(byte layer);
|
||||
|
||||
// Set the base of the map for the layer with which the conio will interact.
|
||||
|
||||
// Set the base of the map layer with which the conio will interact.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - mapbase: Specifies the base address of the tile map.
|
||||
// Note that the register only specifies bits 16:9 of the address,
|
||||
// so the resulting address in the VERA VRAM is always aligned to a multiple of 512 bytes.
|
||||
void vera_layer_set_mapbase(byte layer, byte mapbase);
|
||||
|
||||
// Get the base of the map for the layer with which the conio will interact.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - return: Returns the base address of the tile map.
|
||||
// Note that the register is a byte, specifying only bits 16:9 of the address,
|
||||
// so the resulting address in the VERA VRAM is always aligned to a multiple of 512 bytes!
|
||||
byte vera_layer_get_mapbase(byte layer);
|
||||
|
||||
// Set the base of the map layer with which the conio will interact.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - mapbase_address: A dword typed address (4 bytes), that specifies the full address of the map base.
|
||||
// - mapbase_address: a dword typed address (4 bytes), that specifies the full address of the map base.
|
||||
// The function does the translation from the dword that contains the 17 bit address,
|
||||
// to the respective mapbase vera register.
|
||||
// Note that the register only specifies bits 16:9 of the address,
|
||||
// so the resulting address in the VERA VRAM is always aligned to a multiple of 512 bytes.
|
||||
void vera_layer_set_mapbase_address(byte layer, dword mapbase_address);
|
||||
|
||||
// Get the base of the map layer with which the conio will interact.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - return: Returns the base address of the tile map.
|
||||
// Note that the register is a byte, specifying only bits 16:9 of the address,
|
||||
// so the resulting address in the VERA VRAM is always aligned to a multiple of 512 bytes.
|
||||
byte vera_layer_get_mapbase(byte layer);
|
||||
|
||||
// Get the map base address of the tiles for the layer.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - return: Specifies the map base address of the layer, which is returned as a dword.
|
||||
@ -108,6 +162,20 @@ void vera_layer_set_mapbase_address(byte layer, dword mapbase_address);
|
||||
// so the resulting address in the VERA VRAM is always aligned to a multiple of 512 bytes!
|
||||
dword vera_layer_get_mapbase_address(byte layer);
|
||||
|
||||
// Get the map base bank of the tiles for the layer.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - return: Bank in vera vram.
|
||||
byte vera_layer_get_mapbase_bank(byte layer);
|
||||
|
||||
// Get the map base lower 16-bit address (offset) of the tiles for the layer.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - return: Offset in vera vram of the specified bank.
|
||||
word vera_layer_get_mapbase_offset(byte layer);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Set the base of the tiles for the layer with which the conio will interact.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - tilebase: Specifies the base address of the tile map.
|
||||
@ -115,9 +183,9 @@ dword vera_layer_get_mapbase_address(byte layer);
|
||||
// so the resulting address in the VERA VRAM is always aligned to a multiple of 2048 bytes!
|
||||
void vera_layer_set_tilebase(byte layer, byte tilebase);
|
||||
|
||||
// Set the base of the tiles for the layer with which the conio will interact.
|
||||
// Set the base address of the tiles for the layer with which the conio will interact.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - tilebase_address: A dword typed address (4 bytes), that specifies the base address of the tile map.
|
||||
// - tilebase_address: a dword typed address (4 bytes), that specifies the base address of the tile map.
|
||||
// The function does the translation from the dword that contains the 17 bit address,
|
||||
// to the respective tilebase vera register.
|
||||
// Note that the resulting vera register holds only specifies bits 16:11 of the address,
|
||||
@ -131,11 +199,19 @@ void vera_layer_set_tilebase_address(byte layer, dword tilebase_address);
|
||||
// so the resulting address in the VERA VRAM is always aligned to a multiple of 2048 bytes!
|
||||
byte vera_layer_get_tilebase(byte layer);
|
||||
|
||||
// Get the tile base address of the tiles for the layer.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - return: Specifies the base address of the tile map, which is calculated as an unsigned long int.
|
||||
// Note that the register only specifies bits 16:11 of the address,
|
||||
// so the resulting address in the VERA VRAM is always aligned to a multiple of 2048 bytes!
|
||||
dword vera_layer_get_tilebase_address(byte layer);
|
||||
|
||||
// --- VERA layer color management ---
|
||||
|
||||
// Set the front color for text output. The old front text color setting is returned.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - color: a 4 bit value ( decimal between 0 and 15).
|
||||
// This will only work when the VERA is in 16 color mode!
|
||||
// - color: a 4 bit value ( decimal between 0 and 15) when the VERA works in 16x16 color text mode.
|
||||
// An 8 bit value (decimal between 0 and 255) when the VERA works in 256 text mode.
|
||||
// Note that on the VERA, the transparent color has value 0.
|
||||
byte vera_layer_set_textcolor(byte layer, byte color);
|
||||
|
||||
@ -177,6 +253,19 @@ inline void vera_layer_set_horizontal_scroll(byte layer, word scroll);
|
||||
// - scroll: A value between 0 and 4096.
|
||||
inline void vera_layer_set_vertical_scroll(byte layer, word scroll);
|
||||
|
||||
// --- VERA layer technical functions to quickly shift rows.
|
||||
|
||||
// Get the bit shift value required to skip a whole line fast.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - return: Rowshift value to calculate fast from a y value to line offset in tile mode.
|
||||
byte vera_layer_get_rowshift(byte layer);
|
||||
|
||||
// Get the value required to skip a whole line fast.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - return: Skip value to calculate fast from a y value to line offset in tile mode.
|
||||
word vera_layer_get_rowskip(byte layer);
|
||||
|
||||
|
||||
// Set a vera layer in tile mode and configure the:
|
||||
// - layer: Value of 0 or 1.
|
||||
// - mapbase_address: A dword typed address (4 bytes), that specifies the full address of the map base.
|
||||
@ -196,3 +285,42 @@ inline void vera_layer_set_vertical_scroll(byte layer, word scroll);
|
||||
// - color_depth: The color depth in bits per pixel (BPP), which can be 1, 2, 4 or 8.
|
||||
void vera_layer_mode_tile(byte layer, dword mapbase_address, dword tilebase_address, word mapwidth, word mapheight, byte tilewidth, byte tileheight, byte color_depth );
|
||||
|
||||
|
||||
// Set a vera layer in text mode and configure the:
|
||||
// - layer: Value of 0 or 1.
|
||||
// - mapbase_address: A dword typed address (4 bytes), that specifies the full address of the map base.
|
||||
// The function does the translation from the dword that contains the 17 bit address,
|
||||
// to the respective mapbase vera register.
|
||||
// Note that the register only specifies bits 16:9 of the address,
|
||||
// so the resulting address in the VERA VRAM is always aligned to a multiple of 512 bytes.
|
||||
// - tilebase_address: A dword typed address (4 bytes), that specifies the base address of the tile map.
|
||||
// The function does the translation from the dword that contains the 17 bit address,
|
||||
// to the respective tilebase vera register.
|
||||
// Note that the resulting vera register holds only specifies bits 16:11 of the address,
|
||||
// so the resulting address in the VERA VRAM is always aligned to a multiple of 2048 bytes!
|
||||
// - mapwidth: The width of the map in number of tiles.
|
||||
// - mapheight: The height of the map in number of tiles.
|
||||
// - tilewidth: The width of a tile, which can be 8 or 16 pixels.
|
||||
// - tileheight: The height of a tile, which can be 8 or 16 pixels.
|
||||
// - color_mode: The color mode, which can be 16 or 256.
|
||||
void vera_layer_mode_text(byte layer, dword mapbase_address, dword tilebase_address, word mapwidth, word mapheight, byte tilewidth, byte tileheight, word color_mode );
|
||||
|
||||
// Set a vera layer in bitmap mode and configure the:
|
||||
// - layer: Value of 0 or 1.
|
||||
// - mapbase_address: A dword typed address (4 bytes), that specifies the full address of the map base.
|
||||
// The function does the translation from the dword that contains the 17 bit address,
|
||||
// to the respective mapbase vera register.
|
||||
// Note that the register only specifies bits 16:9 of the address,
|
||||
// so the resulting address in the VERA VRAM is always aligned to a multiple of 512 bytes.
|
||||
// - tilebase_address: A dword typed address (4 bytes), that specifies the base address of the tile map.
|
||||
// The function does the translation from the dword that contains the 17 bit address,
|
||||
// to the respective tilebase vera register.
|
||||
// Note that the resulting vera register holds only specifies bits 16:11 of the address,
|
||||
// so the resulting address in the VERA VRAM is always aligned to a multiple of 2048 bytes!
|
||||
// - mapwidth: The width of the map in number of tiles.
|
||||
// - mapheight: The height of the map in number of tiles.
|
||||
// - tilewidth: The width of a tile, which can be 8 or 16 pixels.
|
||||
// - tileheight: The height of a tile, which can be 8 or 16 pixels.
|
||||
// - color_mode: The color mode, which can be 16 or 256.
|
||||
void vera_layer_mode_bitmap(byte layer, dword bitmap_address, word mapwidth, word color_depth );
|
||||
|
||||
|
@ -127,15 +127,14 @@ void vera_layer_set_config(byte layer, byte config) {
|
||||
*addr = config;
|
||||
}
|
||||
|
||||
// Set the configuration of the layer.
|
||||
// Get the configuration of the layer.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - config: Specifies the modes which are specified using T256C / 'Bitmap Mode' / 'Color Depth'.
|
||||
// - return: Specifies the modes which are specified using T256C / 'Bitmap Mode' / 'Color Depth'.
|
||||
byte vera_layer_get_config(byte layer) {
|
||||
byte* config = vera_layer_config[layer];
|
||||
return *config;
|
||||
}
|
||||
|
||||
// Set the configuration of the layer.
|
||||
// Set the configuration of the layer text color mode.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - color_mode: Specifies the color mode to be VERA_LAYER_CONFIG_16 or VERA_LAYER_CONFIG_256 for text mode.
|
||||
void vera_layer_set_text_color_mode( byte layer, byte color_mode ) {
|
||||
@ -204,7 +203,7 @@ inline void vera_layer_set_height_256(byte layer) {
|
||||
*addr |= VERA_LAYER_HEIGHT_256;
|
||||
}
|
||||
|
||||
// Get the map width or height of the layer.
|
||||
// Get the map width of the layer.
|
||||
// - layer: Value of 0 or 1.
|
||||
word vera_layer_get_width(byte layer) {
|
||||
byte* config = vera_layer_config[layer];
|
||||
@ -212,29 +211,40 @@ word vera_layer_get_width(byte layer) {
|
||||
return VERA_LAYER_WIDTH[ (*config & mask) >> 4];
|
||||
}
|
||||
|
||||
// Get the map height of the layer.
|
||||
// - layer: Value of 0 or 1.
|
||||
word vera_layer_get_height(byte layer) {
|
||||
byte* config = vera_layer_config[layer];
|
||||
byte mask = VERA_LAYER_HEIGHT_MASK;
|
||||
return VERA_LAYER_HEIGHT[ (*config & mask) >> 6];
|
||||
}
|
||||
|
||||
// Set the color depth of the layer in terms of bit per pixel (BPP) of the tile base.
|
||||
// Set the color depth of the layer in bit per pixel (BPP) to 1.
|
||||
// - layer: Value of 0 or 1.
|
||||
inline void vera_layer_set_color_depth_1BPP(byte layer) {
|
||||
byte* addr = vera_layer_config[layer];
|
||||
*addr &= ~VERA_LAYER_COLOR_DEPTH_MASK;
|
||||
*addr |= VERA_LAYER_COLOR_DEPTH_1BPP;
|
||||
}
|
||||
|
||||
// Set the color depth of the layer in bit per pixel (BPP) to 1.
|
||||
// - layer: Value of 0 or 1.
|
||||
inline void vera_layer_set_color_depth_2BPP(byte layer) {
|
||||
byte* addr = vera_layer_config[layer];
|
||||
*addr &= ~VERA_LAYER_COLOR_DEPTH_MASK;
|
||||
*addr |= VERA_LAYER_COLOR_DEPTH_2BPP;
|
||||
}
|
||||
|
||||
// Set the color depth of the layer in bit per pixel (BPP) to 1.
|
||||
// - layer: Value of 0 or 1.
|
||||
inline void vera_layer_set_color_depth_4BPP(byte layer) {
|
||||
byte* addr = vera_layer_config[layer];
|
||||
*addr &= ~VERA_LAYER_COLOR_DEPTH_MASK;
|
||||
*addr |= VERA_LAYER_COLOR_DEPTH_4BPP;
|
||||
}
|
||||
|
||||
// Set the color depth of the layer in bit per pixel (BPP) to 1.
|
||||
// - layer: Value of 0 or 1.
|
||||
inline void vera_layer_set_color_depth_8BPP(byte layer) {
|
||||
byte* addr = vera_layer_config[layer];
|
||||
*addr &= ~VERA_LAYER_COLOR_DEPTH_MASK;
|
||||
@ -244,10 +254,9 @@ inline void vera_layer_set_color_depth_8BPP(byte layer) {
|
||||
// Get the color depth of the layer.
|
||||
// - layer: Value of 0 or 1.
|
||||
// - return: 0 = 1 color, 1 = 2 colors, 2 = 4 colors or 3 = 8 colors.
|
||||
byte vera_layer_get_color_depth(byte layer) {
|
||||
inline byte vera_layer_get_color_depth(byte layer) {
|
||||
byte* config = vera_layer_config[layer];
|
||||
byte mask = (byte)VERA_LAYER_COLOR_DEPTH_MASK;
|
||||
return *config & mask;
|
||||
return (*config & VERA_LAYER_COLOR_DEPTH_MASK);
|
||||
}
|
||||
|
||||
// Enable the layer to be displayed on the screen.
|
||||
@ -263,7 +272,6 @@ inline void vera_layer_hide(byte layer) {
|
||||
*VERA_DC_VIDEO &= ~vera_layer_enable[layer];
|
||||
}
|
||||
|
||||
|
||||
// Is the layer shown on the screen?
|
||||
// - returns: 1 if layer is displayed on the screen, 0 if not.
|
||||
inline byte vera_layer_is_visible(byte layer) {
|
||||
|
Loading…
Reference in New Issue
Block a user