VICKY

From C256 Foenix Wiki
Revision as of 22:48, 7 May 2019 by Stef (talk | contribs) (VICKY - the graphics engine)
Jump to navigation Jump to search

VICKY - the graphics engine

"Vicky" is the name of the graphics engine of the C256 Foenix. It supports:

  • 640x480@60FPS Max Resolution @ 256 Colors (1 Byte per pixel)
  • 32 Sprites with a resolution of 32x32 pixels
  • 4 layers of tiles with a resolution of 16x16 pixels for each tile
  • Text Mode

During the video layer composition, Vicky has to read 1 line of bitmap (640 pixels), 1 line of tiles for each layer (4x 640 pixels) and all the lines that are part of the 32 Sprites (worst case scenario 32 lines of 32 pixels), that are displayed on that line. Then a composition and priority encoding is done. In order to establish a priority, in other words, to know which pixel will be in front, Vicky needs to store 10 lines of 640 pixels then scan the lot and determine which one will be displayed.

640 + 640 + 640 + 640 + 640 + (32 * 32) = 4224 Pixels are to be read during a single line interval. The pixel rate is 200Mbytes/sec, 5ns, so the overall operation takes 21.12us, without calculating the overhead in the FPGA to go from one process to the other.

The pixel index value $00 is always transparent, regardless if it's bitmap, tile or sprite. The respective values of the first 4 bytes represented in the LUT are thus always ignored.

Despite the fact that there is an ALPHA value in the LUT, it is not supported/used at all.

Vicky Gloabl Memory Map:

Start Address Stop Address Register Description Additional Info
$AF:0000 $AF:0000 MASTER_CTRL_REG_L Vicky Master Control Registers
$AF:0001 $AF:0001 MASTER_CTRL_REG_H
$AF:0002 $AF:0002 VKY_RESERVED_00
$AF:0003 $AF:0003 VKY_RESERVED_01
$AF:0004 $AF:0004 BORDER_CTRL_REG Border Control Registers
$AF:0005 $AF:0005 BORDER_COLOR_B
$AF:0006 $AF:0006 BORDER_COLOR_G
$AF:0007 $AF:0007 BORDER_COLOR_R
$AF:0008 $AF:0008 BACKGROUND_COLOR_B Background Control Registers
$AF:0009 $AF:0009 BACKGROUND_COLOR_G
$AF:000A $AF:000A BACKGROUND_COLOR_R
$AF:000B $AF:000F UNDEFINED - RESERVED
$AF:0010 $AF:0010 VKY_TXT_CURSOR_CTRL_REG Cursor Control Registers
$AF:0011 $AF:0011 VKY_TXT_RESERVED
$AF:0012 $AF:0012 VKY_TXT_CURSOR_CHAR_REG Char used as the Cursor
$AF:0013 $AF:0013 VKY_TXT_CURSOR_COLR_REG Color Choice for the Cursor
$AF:0014 $AF:0014 VKY_TXT_CURSOR_X_REG_L Cursor Position X
$AF:0015 $AF:0015 VKY_TXT_CURSOR_X_REG_H
$AF:0016 $AF:0016 VKY_TXT_CURSOR_Y_REG_L Cursor Position Y
$AF:0017 $AF:0017 VKY_TXT_CURSOR_Y_REG_H
$AF:0018 $AF:001B UNDEFINED - RESERVED
$AF:001C $AF:001C VKY_INFO_CHIP_NUM_L Vicky Chip Part Number
$AF:001D $AF:001D VKY_INFO_CHIP_NUM_H
$AF:001E $AF:001E VKY_INFO_CHIP_VER_L Vicky Chip Version
$AF:001F $AF:001F VKY_INFO_CHIP_VER_H
$AF:0020 $AF:00FF UNDEFINED - RESERVED
$AF:0100 $AF:0100 TL0_CONTROL_REG Tile 0 Register Set
$AF:0101 $AF:0101 TL0_START_ADDY_L Start Address Within the Video Memory
$AF:0102 $AF:0102 TL0_START_ADDY_M
$AF:0103 $AF:0103 TL0_START_ADDY_H
$AF:0104 $AF:0104 TL0_SCROLL_X
$AF:0105 $AF:0105 TL0_SCROLL_Y
$AF:0106 $AF:0107 UNDEFINED - RESERVED
$AF:0108 $AF:0108 TL1_CONTROL_REG Tile 1 Register Set
$AF:0109 $AF:0109 TL1_START_ADDY_L Start Address Within the Video Memory
$AF:010A $AF:010A TL1_START_ADDY_M
$AF:010B $AF:010B TL1_START_ADDY_H
$AF:010C $AF:010C TL1_SCROLL_X
$AF:010D $AF:010D TL1_SCROLL_Y
$AF:010E $AF:010F UNDEFINED - RESERVED
$AF:0110 $AF:0110 TL2_CONTROL_REG Tile 2 Register Set
$AF:0111 $AF:0111 TL2_START_ADDY_L Start Address Within the Video Memory
$AF:0112 $AF:0112 TL2_START_ADDY_M
$AF:0113 $AF:0113 TL2_START_ADDY_H
$AF:0114 $AF:0114 TL2_SCROLL_X
$AF:0115 $AF:0115 TL2_SCROLL_Y
$AF:0116 $AF:0117 UNDEFINED - RESERVED
$AF:0118 $AF:0118 TL3_CONTROL_REG Tile 3 Register Set
$AF:0119 $AF:0119 TL3_START_ADDY_L Start Address Within the Video Memory
$AF:011A $AF:011A TL3_START_ADDY_M
$AF:011B $AF:011B TL3_START_ADDY_H
$AF:011C $AF:011C TL3_SCROLL_X
$AF:011D $AF:011D TL3_SCROLL_Y
$AF:011E $AF:011F UNDEFINED - RESERVED
$AF:0120 $AF:013F UNDEFINED - RESERVED
$AF:0140 $AF:0140 BM_CONTROL_REG Bitmap Registers Set
$AF:0141 $AF:0141 BM_START_ADDY_L Start Address Within the Video Memory
$AF:0142 $AF:0142 BM_START_ADDY_M
$AF:0143 $AF:0143 BM_START_ADDY_H
$AF:0144 $AF:0144 BM_X_SIZE_L Needs to be set to 640
$AF:0145 $AF:0145 BM_X_SIZE_H
$AF:0146 $AF:0146 BM_Y_SIZE_L Needs to be set to 480
$AF:0147 $AF:0147 BM_Y_SIZE_H
$AF:0148 $AF:014F BM_RESERVED
$AF:0150 $AF:01FF UNDEFINED - RESERVED
$AF:0200 $AF:0200 SP00_CONTROL_REG Sprite 0 (Highest Priority)
$AF:0201 $AF:0201 SP00_ADDY_PTR_L Start Address Within the Video Memory
$AF:0202 $AF:0202 SP00_ADDY_PTR_M
$AF:0203 $AF:0203 SP00_ADDY_PTR_H
$AF:0204 $AF:0204 SP00_X_POS_L
$AF:0205 $AF:0205 SP00_X_POS_H
$AF:0206 $AF:0206 SP00_Y_POS_L
$AF:0207 $AF:0207 SP00_Y_POS_H
$AF:0208 $AF:020F SP01 - Sprite 1
$AF:0210 $AF:0217 SP02 - Sprite 2
$AF:0218 $AF:021F SP03 - Sprite 3
$AF:0220 $AF:0227 SP04 - Sprite 4
$AF:0228 $AF:022F SP05 - Sprite 5
$AF:0230 $AF:0237 SP06 - Sprite 6
$AF:0238 $AF:023F SP07 - Sprite 7
$AF:0208 $AF:020F SP01 - Sprite 1
$AF:0208 $AF:020F SP01 - Sprite 1
$AF:0208 $AF:020F SP01 - Sprite 1
$AF:0208 $AF:020F SP01 - Sprite 1
$AF:0208 $AF:020F SP01 - Sprite 1
$AF:0208 $AF:020F SP01 - Sprite 1
$AF:0208 $AF:020F SP01 - Sprite 1
$AF:0208 $AF:020F SP01 - Sprite 1
$AF:0208 $AF:020F SP01 - Sprite 1
$AF:0208 $AF:020F SP01 - Sprite 1
$AF:0208 $AF:020F SP01 - Sprite 1
$AF:0208 $AF:020F SP01 - Sprite 1
$AF:0208 $AF:020F SP01 - Sprite 1
$AF:0208 $AF:020F SP01 - Sprite 1
$AF:0208 $AF:020F SP01 - Sprite 1
$AF:0208 $AF:020F SP01 - Sprite 1
$AF:0208 $AF:020F SP01 - Sprite 1
$AF:0208 $AF:020F SP01 - Sprite 1
$AF:0208 $AF:020F SP01 - Sprite 1
$AF:0208 $AF:020F SP01 - Sprite 1
$AF:0208 $AF:020F SP01 - Sprite 1
$AF:0208 $AF:020F SP01 - Sprite 1
$AF:0208 $AF:020F SP01 - Sprite 1
$AF:0208 $AF:020F SP01 - Sprite 1
$AF:0208 $AF:020F SP01 - Sprite 1

Modes

Modes are enabled and disabled via the Vicky Master Control Register at $AF0000 via the control bits:

Mstr_Ctrl_Text_Mode_En = $01 Enable the Text Mode
Mstr_Ctrl_Text_Overlay = $02 Enable the Overlay of the text mode on top of Graphic Mode (the Background Color is ignored)
Mstr_Ctrl_Graph_Mode_En = $04 Enable the Graphic Mode
Mstr_Ctrl_Bitmap_En = $08 Enable the Bitmap Module In Vicky
Mstr_Ctrl_TileMap_En = $10 Enable the Tile Module in Vicky
Mstr_Ctrl_Sprite_En = $20 Enable the Sprite Module in Vicky
Mstr_Ctrl_GAMMA_En = $40 Enable the GAMMA correction - The Analog and DVI have different color values, the GAMMA is great to correct the difference
Mstr_Ctrl_Disable_Vid = $80 This will disable the Scanning of the Video information in the 4Meg of VideoRAM hence giving 100% bandwidth to the CPU

Bitmap Layer

The bitmap is stored anywhere in $B0 bank memory. If the bitmap is supposed to start at $B0:0000, the BM_START_ADDY has to be set to $00:0000.

  • BM_CONTROL_REG = $AF0140
    • Bit 0 = disable/enable
    • Bit 1-3 = Target LUT address located at AF:2000 and up.
  • BM_START_ADDY_L = $AF0141
  • BM_START_ADDY_M = $AF0142
  • BM_START_ADDY_H = $AF0143

LUT

A LUT, namely a Look-Up-Table, stores a selection of colors. 256 colors are supported in the video composition, which are selectable out of 16.777.216 colors in the 24 Bit RGB color scheme. The LUT also contains an 8 Bit alpha channel, though it isn't supported. In summary, the LUT has $400 (1024) bytes - and the order for composing it is B -> G -> R -> A.

As an example, if you would want to compose a LUT of 16 base colors, it would look like this:

Address Hex Values (BGRA) Decimal RGB Value
$AF:2000 -- ignored -- -- ignored --
$AF:2004 00 00 00 00 0, 0, 0
$AF:2008 FF FF FF 00 255, 255, 255
$AF:200C 00 00 88 00 0, 0, 136
$AF:2010 EE FF AA 00 238, 255, 170
$AF:2014 CC 44 CC 00 204, 68, 204
$AF:2018 55 CC 00 00 85, 204, 0
$AF:201C AA 00 00 00 170, 0, 0
$AF:2020 77 EE EE 00 119, 238, 238
$AF:2024 55 88 DD 00 85, 136, 221
$AF:2028 00 44 66 00 0, 68, 102
$AF:202C 77 77 FF 00 119, 119, 255
$AF:2030 33 33 33 00 51, 51, 51
$AF:2034 77 77 77 00 119, 119, 119
$AF:2038 66 FF AA 00 102, 255, 170
$AF:203C FF 88 00 00 255, 136, 0
$AF:2040 BB BB BB 00 187, 187, 187

Adressing anything in the LUT is achieved by simply dividing the lower 10 bits of target color address by 4.