Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CMD FIFO - implemented in hardware as an abstraction layer between the CPU bus and the KAPE GPU.
- The CPU sends commands through the FIFO and sees it as a normal IO in address-space, and sending bytes to this address
- is then read by the GPU from the FIFO and ingested here. After a reset event - either hardware or software - the GPU needs around 100 ms
- before it can start accepting commands. This is about 6-7 frames (at 61,7 fps).
- The command list:
- 0x00 Send single character as textmode. 1 parameter. The next character is interpreted as a text character, and respects
- some special characters like enter and bs
- - 1 byte The character to draw on cursor position. The color will be set as the current draw color bg/fg
- 0x01 Set draw color for text. 1 parameter. The next character is interpreted as the draw color.
- - 1 byte 0bFFFFBBBB
- - F The 4-bit foreground color
- - B The 4-bit background color
- 0x02 Enter Terminal mode. Terminal mode is 32x24 textmode. Future communications are interpreted as characters to be output
- to the char location. Char location is incremented. Upon entering, the foreground and background color are reset to
- Light Gray, and cursor position is set to 0,0. Cursor is shown and blinking. Screen is cleared to space. While in terminal
- mode, sending an ESC(27 or 0x1b) accepts a terminal command.
- See Terminal Commands for terminal commands.
- 0x10 Set single index to character or pattern table at coordinates. 3 parameters.
- - 1 byte 0b***XXXXX
- - X The X position, from 0 - 31 (5 bits)
- - 1 byte 0b***YYYYY
- - Y The Y position, from 0 - 23 (5 bits, clamped to 23)
- - 1 byte Index to set at position X,Y
- 0x20 Set sprite data. 4 parameters
- - 1 byte 0bA*YYYXXX
- - A Active (processed and active in drawing loops, not necessary drawn)
- - Y 3 bit value for the Hotspot Y (pixel considered as the origin, ie. offset for drawing algorithms)
- - X 3 bit value for the Hotspot X
- - 1 byte X position
- - 1 byte Y position (wrapped around from 192)
- - 1 byte Tile index - uses the same tilemap as the background rendering
- 0x21 Set sprite active. 1 parameter
- - 1 byte Sprite index to activate
- 0x22 Set sprite not active. 1 parameter
- - 1 byte Sprite index to deactivate
- 0x23 Set sprite draw. 1 parameter
- - 1 byte Sprite index to activate
- 0x24 Set sprite active. 1 parameter
- - 1 byte Sprite index to activate
- 0x25 Set sprite tile index. 2 parameters
- - 1 byte Sprite index to set the tile index of
- - 1 byte Tile index to set to the sprite
- 0x26 Set sprite X. 2 parameters
- - 1 byte Sprite Index
- - 1 byte Sprite X coord
- 0x27 Set sprite Y. 2 parameters
- - 1 byte Sprite Index
- - 1 byte Sprite Y coord
- 0x30 Set sprite alpha color. 2 parameters
- - 1 byte Sprite Index
- - 1 byte 0b****AAAA
- - A The Alpha color that's not drawn
- 0x31 Set sprite X and Y coords. 3 parameters
- - 1 byte Sprite Index
- - 1 byte Sprite X coord
- - 1 byte Sprite Y coord
- 0x40 Switch to text mode (draw from chargen table)
- 0x41 Switch to graphics mode (draw from pattern table, sprites supported)
- 0x42 Switch to combined mode (draw from both, use a bitmask to select which one to use)
- 0x43 Switch to lores mode (128x96 pixelbuffer, resides in pattern table, no sprites)
- 0x4A Clear screen. 1 paramater. Fills either tilemap/text framebuffer or 128x96 bytes of pattern table, depending on the mode.
- - 1 byte Byte to set to all memory.
- 0x4B Flush frame to FB FIFO. No parameters.
- In Lores mode, the current framebuffer is sent to the FIFO only with the flush command.
- This is due to the fact that the CMDQ is only 2K in size, and thus to send a full frame to the FIFO you need a bit over 3 frames
- to do it. This way, you can use the internal buffer as a double-buffer, and only update the screen when done. Prevents screen tearing
- and provides possibility to update frames smoothly at ~25 FPS.
- 0x4C Draw a pixel. 3 parameters
- - 1 byte X position. Moduloed w/ SCR_LORES_WIDTH (128)
- - 1 byte Y position. Moduloed w/ SCR_LORES_HEIGHT (96)
- - 1 byte Color. Anded with a 0xf to prevent overflow.
- 0x4D Draw a line. 5 paramaters
- - 1 byte X1 position. Moduloed w/ SCR_LORES_WIDTH (128)
- - 1 byte Y1 position. Moduloed w/ SCR_LORES_HEIGHT (96)
- - 1 byte X2 position. Moduloed w/ SCR_LORES_WIDTH (128)
- - 1 byte Y2 position. Moduloed w/ SCR_LORES_HEIGHT (96)
- - 1 byte Color. Anded with a 0xf to prevent overflow.
- 0x50 Set combined mode bitmask for coordinate. 2 parameters.
- - 1 byte 0bB**XXXXX
- - B The bit the bitmask will be set to. 1 draw from pattern table (graphics). 0 draw from chargen (text)
- - X The X position, from 0 - 31 (5 bits)
- - 1 byte 0b***YYYYY
- - Y The Y position, from 0 - 23 (5 bits but clamped to 23)
- 0x80 Send pattern table data for single element. 1 parameter + 32 bytes of data (4 bits per pixel)
- - 1 byte The pattern table index to insert the data to
- - 32 bytes The pattern table data arranged as a sequential array of packed pixels, where one byte holds two pixels.
- 0xfe Direct Framebuffer mode. Intended for Lores mode for piping data directly to the framebuffer. NB: GPU soft reset
- can't be activated in this mode! Reset signal needs to be manually sent to GPU through the ~RESET line.
- 0xff Reset GPU. Once received, uses watchdog to simulate a hardware reset. Resets device.
- In case the last command has not finished, to properly FORCE a reset from a stuck state, we need to send
- as many + 1 reset commands as the longest fifo command queue, which is the send pattern table data at 33 bytes.
- So to do a FORCE RESET, send 34 reset commands to the CMD Fifo
- Terminal commands. In Terminal mode, send ESC and command with parameters. Terminal mode accepts some control characters, like
- 0x0A LF Line Feed. Goes row down, scrolls if too low.
- 0x0D CR Carriage Return. Cursor moved horizontally to Column 0
- 0x1B ESC Escape. The next character describes a command. See the following list.
- 0x08 BS Backspace. Delete character on the left (wrap around to higher row) and replace with space
- 0x01 Set draw color for text. 1 parameter. Binary version. High nibble is foreground color, low nibble is background color
- - 1 byte 0bFFFFBBBB
- - F Foreground color nibble
- - B Background color nibble
- 0x63 'c' Set draw color for text. 2 parameter. The next 2 chars '0-9'|'A-F' are interpreted as foreground and background colors
- - 1 byte Foreground color '0-9'|'A-F'
- - 1 byte Background color '0-9'|'A-F'
- 0x02 Set draw decoration. 1 parameter. Next character decides Bold, Italics, Underline font, Blinking
- - 1 byte 0b000SEUIB
- - B Bold
- - I Italics
- - U Underline
- - E Effect (Blinking)
- - S Strike-through
- 0x03 Set Cursor Position. 2 parameters.
- - 1 byte Cursor Column. Mod 32
- - 1 byte Cursor Row. Mod 24
- 0x04 Set Cursor Column. 1 parameter
- - 1 byte Cursor Column. Mod 32
- 0x05 Set Cursor Row. 1 paramater
- - 1 byte Cursor Row. Mod 24
- 0xff Exit out of Terminal Mode. The next character sent is interpreted as a normal GPU command.
Advertisement
Add Comment
Please, Sign In to add comment