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 05:16] – 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 ===== | ||
- | These are actually defined in gametank.h but are used for direct drawing | ||
<code C> | <code C> | ||
- | # | + | # |
- | + | # | |
- | #define VX 0 | + | # |
- | #define VY 1 | + | # |
- | #define GX 2 | + | # |
- | #define GY 3 | + | # |
- | #define WIDTH 4 | + | # |
- | #define HEIGHT | + | |
- | #define START 6 | + | |
- | #define COLOR 7 | + | |
</ | </ | ||
`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. | ||
- | * VX and VY, as in " | + | * VX and VY, as in " |
- | * GX and GX, as in " | + | * GX and GX, as in " |
- | * WIDTH and HEIGHT set the width and height of a drawing operation. Range 0-127 supported, the high bit is used for reversing the direction of blitting (sprite flipping) | + | * WIDTH and HEIGHT set the width and height of a drawing operation. Range 0-127 supported, the high bit is used for reversing the direction of blitting (sprite flipping). |
* START is a location that will start a blit if you write a 1 to it, but you should use the DIRECT_DRAW_START so that the draw_busy flag will be set. | * START is a location that will start a blit if you write a 1 to it, but you should use the DIRECT_DRAW_START so that the draw_busy flag will be set. | ||
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> | ||
Line 107: | Line 158: | ||
SpriteSlot map_tile_gfx; | SpriteSlot map_tile_gfx; | ||
- | |||
- | static char offset_gx; | ||
- | static char offset_gy; | ||
void load_tile_graphics() { | void load_tile_graphics() { | ||
map_tile_gfx = allocate_sprite(& | map_tile_gfx = allocate_sprite(& | ||
- | //Depending on other allocations the graphic may be offset to another quadrant | ||
- | //This is not needed for the queued functions which handle this internally | ||
- | offset_gx = SPRITE_OFFSET_X(map_tile_gfx); | ||
- | offset_gy = SPRITE_OFFSET_Y(map_tile_gfx); | ||
} | } | ||
Line 130: | Line 174: | ||
y = 0; | y = 0; | ||
i = 0; | i = 0; | ||
- | | + | |
- | | + | |
- | | + | |
while(i < 64) { | while(i < 64) { | ||
t = ASSET__gfx__test1_bin_ptr[i]; | t = ASSET__gfx__test1_bin_ptr[i]; | ||
await_drawing(); | await_drawing(); | ||
- | | + | |
- | | + | |
- | | + | |
DIRECT_DRAW_START(); | DIRECT_DRAW_START(); | ||
++i; | ++i; | ||
Line 145: | Line 189: | ||
x = 0; | x = 0; | ||
y += 16; | y += 16; | ||
- | | + | |
} | } | ||
} | } |
development/csdk/2.0/headers/draw_direct.1732252578.txt.gz · Last modified: 2024/11/22 05:16 by clyde