development:csdk:2.0:headers:draw_direct
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
development:csdk:2.0:headers:draw_direct [2024/11/22 08:52] – clyde | development:csdk:2.0:headers:draw_direct [2024/11/22 09:07] (current) – clyde | ||
---|---|---|---|
Line 2: | Line 2: | ||
draw_direct.h provides macros and functions to support setting up draw operations by direct manipulation of blitter registers. The functions and macros are largely convenience functions for setting up the control registers for common operations, like drawing sprites or colored boxes. | draw_direct.h provides macros and functions to support setting up draw operations by direct manipulation of blitter registers. The functions and macros are largely convenience functions for setting up the control registers for common operations, like drawing sprites or colored boxes. | ||
+ | |||
+ | In general the flow of Direct Drawing is: | ||
+ | |||
+ | - Set up either sprite or box mode with '' | ||
+ | - Set values for the blitter parameters using the '' | ||
+ | - Start the blitter with '' | ||
+ | - Before modifying parameters to prepare the next drawing, ensure that the last drawing is finished with '' | ||
===== Drawing Semantics ===== | ===== Drawing Semantics ===== | ||
- | ==== By indexing the hardware registers === | ||
- | These are actually defined in gametank.h but are used for direct drawing | ||
- | <code C> | ||
<code C> | <code C> | ||
#define DIRECT_SET_DEST_X(x) vram[VX] = (x); | #define DIRECT_SET_DEST_X(x) vram[VX] = (x); | ||
Line 15: | Line 19: | ||
#define DIRECT_SET_HEIGHT(h) vram[HEIGHT] = (h); | #define DIRECT_SET_HEIGHT(h) vram[HEIGHT] = (h); | ||
#define DIRECT_SET_COLOR(c) vram[COLOR] = ~(c); | #define DIRECT_SET_COLOR(c) vram[COLOR] = ~(c); | ||
- | </ | ||
</ | </ | ||
`vram` points to the memory range that is alternately used for the Frame Buffer, the Sprite RAM, and the Blitter Control Registers. If the blitter is enabled (as done by calling one of the direct_prepare_ functions below) the first eight addresses in the VRAM range will map to the Blitter Control Registers. | `vram` points to the memory range that is alternately used for the Frame Buffer, the Sprite RAM, and the Blitter Control Registers. If the blitter is enabled (as done by calling one of the direct_prepare_ functions below) the first eight addresses in the VRAM range will map to the Blitter Control Registers. | ||
Line 29: | Line 32: | ||
* COLOR sets the color for solid colored box mode, bitwise inverted | * COLOR sets the color for solid colored box mode, bitwise inverted | ||
+ | Before using these, you'll need to call either '' | ||
===== Functions ===== | ===== Functions ===== | ||
==== direct_prepare_sprite_mode ==== | ==== direct_prepare_sprite_mode ==== | ||
Line 70: | Line 74: | ||
Draws a packed sprite as exported from Aseprite with a given X,Y position and frame number. A SpriteSlot is a handle given by allocate_sprite in sprites.h | Draws a packed sprite as exported from Aseprite with a given X,Y position and frame number. A SpriteSlot is a handle given by allocate_sprite in sprites.h | ||
===== Macros ===== | ===== Macros ===== | ||
+ | |||
+ | ==== DIRECT_SET_DEST_X==== | ||
+ | <code C> | ||
+ | DIRECT_SET_DEST_X(x) | ||
+ | </ | ||
+ | Sets the X position of the blitter' | ||
+ | |||
+ | ==== DIRECT_SET_DEST_Y==== | ||
+ | <code C> | ||
+ | DIRECT_SET_DEST_Y(y) | ||
+ | </ | ||
+ | Sets the Y position of the blitter' | ||
+ | |||
+ | ==== DIRECT_SET_SOURCE_X==== | ||
+ | <code C> | ||
+ | DIRECT_SET_SOURCE_X(x) | ||
+ | </ | ||
+ | Sets the X position of the blitter' | ||
+ | |||
+ | This macro also factors in the X offset bit, which is set or cleared by '' | ||
+ | |||
+ | ==== DIRECT_SET_SOURCE_Y==== | ||
+ | <code C> | ||
+ | DIRECT_SET_SOURCE_Y(y) | ||
+ | </ | ||
+ | Sets the Y position of the blitter' | ||
+ | |||
+ | This macro also factors in the Y offset bit, which is set or cleared by '' | ||
+ | |||
+ | ==== DIRECT_SET_WIDTH==== | ||
+ | <code C> | ||
+ | DIRECT_SET_WIDTH(w) | ||
+ | </ | ||
+ | Sets the width of the next blitter operation. | ||
+ | |||
+ | ==== DIRECT_SET_HEIGHT==== | ||
+ | <code C> | ||
+ | DIRECT_SET_HEIGHT(h) | ||
+ | </ | ||
+ | Sets the height of the next blitter operation. Safe to modify during blits. | ||
+ | |||
+ | ==== DIRECT_SET_COLOR==== | ||
+ | <code C> | ||
+ | DIRECT_SET_COLOR(c) | ||
+ | </ | ||
+ | Sets the color that will be used if the blitter is in solid color mode, as set by '' | ||
+ | |||
==== DIRECT_DRAW_START ==== | ==== DIRECT_DRAW_START ==== | ||
<code C> | <code C> |
development/csdk/2.0/headers/draw_direct.1732265537.txt.gz · Last modified: 2024/11/22 08:52 by clyde