4bpp tiled surfaces, row major
[Surface functions]
Functions | |
u32 | schr4r_get_pixel (const TSurface *src, int x, int y) |
Get the pixel value of src at (x, y). | |
void | schr4r_plot (const TSurface *dst, int x, int y, u32 clr) |
Plot a single pixel on a 4bpp tiled surface. | |
void | schr4r_hline (const TSurface *dst, int x1, int y, int x2, u32 clr) |
Draw a horizontal line on a 4bpp tiled surface. | |
void | schr4r_vline (const TSurface *dst, int x, int y1, int y2, u32 clr) |
Draw a vertical line on a 4bpp tiled surface. | |
void | schr4r_line (const TSurface *dst, int x1, int y1, int x2, int y2, u32 clr) |
Draw a line on a 4bpp tiled surface. | |
void | schr4r_rect (const TSurface *dst, int left, int top, int right, int bottom, u32 clr) |
Render a rectangle on a tiled canvas. | |
void | schr4r_frame (const TSurface *dst, int left, int top, int right, int bottom, u32 clr) |
Draw a rectangle on a 4bpp tiled surface. | |
void | schr4r_prep_map (const TSurface *srf, u16 *map, u16 se0) |
Prepare a screen-entry map for use with chr4. | |
u32 * | schr4r_get_ptr (const TSurface *srf, int x, int y) |
Special pointer getter for chr4: start of in-tile line. | |
INLINE void | _schr4r_plot (const TSurface *dst, int x, int y, u32 clr) |
Plot a single pixel on a 4bpp tiled,row-major surface; inline version. | |
INLINE u32 | _schr4r_get_pixel (const TSurface *src, int x, int y) |
Get the pixel value of src at (x, y); inline version. |
Detailed Description
A (4bpp) tiled surface is formed when each tilemap entry references a unique tile (this is done by schr4r_prep_map()). The pixels on the tiles will then uniquely map onto pixels on the screen.There are two ways of map-layout here: row-major indexing and column-major indexing. The difference if is that tile 1 is to the right of tile 0 in the former, but under it in the latter.
30x20t screen: Row-major: 0 1 2 3 ... 30 31 32 33 ... 60 61 62 63 ...
Column-major: 0 20 40 60 ... 1 21 41 61 ... 2 22 41 62 ...
With 4bpp tiles, the column-major version makes the y coordinate match up nicely with successive words. For this reason, column-major is preferred over row-major.
Function Documentation
void schr4r_frame | ( | const TSurface * | dst, | |
int | left, | |||
int | top, | |||
int | right, | |||
int | bottom, | |||
u32 | clr | |||
) |
Draw a rectangle on a 4bpp tiled surface.
- Parameters:
-
dst Destination surface. left Left side of rectangle; top Top side of rectangle. right Right side of rectangle. bottom Bottom side of rectangle. clr Color.
- Note:
- Does normalization, but not bounds checks.
PONDER: RB in- or exclusive?
u32 schr4r_get_pixel | ( | const TSurface * | src, | |
int | x, | |||
int | y | |||
) |
Get the pixel value of src at (x, y).
void schr4r_hline | ( | const TSurface * | dst, | |
int | x1, | |||
int | y, | |||
int | x2, | |||
u32 | clr | |||
) |
Draw a horizontal line on a 4bpp tiled surface.
- Parameters:
-
dst Destination surface. x1 First X-coord. y Y-coord. x2 Second X-coord. clr Color.
- Note:
- Does normalization, but not bounds checks.
void schr4r_line | ( | const TSurface * | dst, | |
int | x1, | |||
int | y1, | |||
int | x2, | |||
int | y2, | |||
u32 | clr | |||
) |
Draw a line on a 4bpp tiled surface.
- Parameters:
-
dst Destination surface. x1 First X-coord. y1 First Y-coord. x2 Second X-coord. y2 Second Y-coord. clr Color.
- Note:
- Does normalization, but not bounds checks.
void schr4r_plot | ( | const TSurface * | dst, | |
int | x, | |||
int | y, | |||
u32 | clr | |||
) |
Plot a single pixel on a 4bpp tiled surface.
- Parameters:
-
dst Destination surface. x X-coord. y Y-coord. clr Color.
- Note:
- Slow as fuck. Inline plotting functionality if possible.
void schr4r_prep_map | ( | const TSurface * | srf, | |
u16 * | map, | |||
u16 | se0 | |||
) |
Prepare a screen-entry map for use with chr4.
- Parameters:
-
srf Surface with size information. map Screen-blocked map to initialize. se0 Additive base screen-entry.
void schr4r_rect | ( | const TSurface * | dst, | |
int | left, | |||
int | top, | |||
int | right, | |||
int | bottom, | |||
u32 | clr | |||
) |
Render a rectangle on a tiled canvas.
- Parameters:
-
dst Destination surface. left Left side of rectangle; top Top side of rectangle. right Right side of rectangle. bottom Bottom side of rectangle. clr Color-index. Octupled if > 16.
- Note:
- For a routine like this you can strive for programmer sanity or speed. This is for speed. Except for very small rects, this is between 5x and 300x faster than the trivial version. Here's how it works: | c | +---+ a | d | b +---+ | e |
- If unaligned left : draw A [left,8), update dstD/width
- If unaligned right: draw B [right&~7,right), Adjust dstD/width
- If width>0
- if unaligned top : draw C in ix/iy loop. Adjust dstD/height
- If height>8 : draw D in memset32 blocks, adjust height
- Final sets : draw E in ix/iy loop
void schr4r_vline | ( | const TSurface * | dst, | |
int | x, | |||
int | y1, | |||
int | y2, | |||
u32 | clr | |||
) |
Draw a vertical line on a 4bpp tiled surface.
- Parameters:
-
dst Destination surface. x X-coord. y1 First Y-coord. y2 Second Y-coord. clr Color.
- Note:
- Does normalization, but not bounds checks.
Generated on Mon Aug 25 17:03:57 2008 for libtonc by
