libtonc
4bpp tiled surfaces, column major

Functions

u32 schr4c_get_pixel (const TSurface *src, int x, int y)
 Get the pixel value of src at (x, y).
 
void schr4c_plot (const TSurface *dst, int x, int y, u32 clr)
 Plot a single pixel on a 4bpp tiled surface.
 
void schr4c_hline (const TSurface *dst, int x1, int y, int x2, u32 clr)
 Draw a horizontal line on a 4bpp tiled surface.
 
void schr4c_vline (const TSurface *dst, int x, int y1, int y2, u32 clr)
 Draw a vertical line on a 4bpp tiled surface.
 
void schr4c_line (const TSurface *dst, int x1, int y1, int x2, int y2, u32 clr)
 Draw a line on a 4bpp tiled surface.
 
void schr4c_rect (const TSurface *dst, int left, int top, int right, int bottom, u32 clr)
 Render a rectangle on a 4bpp tiled canvas.
 
void schr4c_frame (const TSurface *dst, int left, int top, int right, int bottom, u32 clr)
 Draw a rectangle on a 4bpp tiled surface.
 
void schr4c_blit (const TSurface *dst, int dstX, int dstY, uint width, uint height, const TSurface *src, int srcX, int srcY)
 Blitter for 4bpp tiled surfaces. Copies a rectangle from one surface to another.
 
void schr4c_floodfill (const TSurface *dst, int x, int y, u32 clr)
 Floodfill an area of the same color with new color clr.
 
void schr4c_prep_map (const TSurface *srf, u16 *map, u16 se0)
 Prepare a screen-entry map for use with chr4.
 
u32 * schr4c_get_ptr (const TSurface *srf, int x, int y)
 Special pointer getter for chr4: start of in-tile line.
 
INLINE void _schr4c_plot (const TSurface *dst, int x, int y, u32 clr)
 Plot a single pixel on a 4bpp tiled,col-jamor surface; inline version.
 
INLINE u32 _schr4c_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 schr4c_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

◆ schr4c_blit()

void schr4c_blit ( const TSurface *  dst,
int  dstX,
int  dstY,
uint  width,
uint  height,
const TSurface *  src,
int  srcX,
int  srcY 
)

Blitter for 4bpp tiled surfaces. Copies a rectangle from one surface to another.

Parameters
dstDestination surface.
dstXLeft coord of rectangle on dst.
dstYTop coord of rectangle on dst.
widthWidth of rectangle to blit.
heightHeight of rectangle to blit.
srcSource surface.
srcXLeft coord of rectangle on src.
srcYTop coord of rectangle on src.
Note
The rectangle will be clipped to both src and dst.

References chr4_lmask(), chr4_rmask(), memcpy32(), min(), and schr4c_get_ptr().

◆ schr4c_floodfill()

void schr4c_floodfill ( const TSurface *  dst,
int  x,
int  y,
u32  clr 
)

Floodfill an area of the same color with new color clr.

Parameters
dstDestination surface.
xX-coordinate.
yY-coordinate;
clrColor.
Note
This routines is probably very, very slow.

References _schr4c_get_pixel(), and schr4c_floodfill_internal().

◆ schr4c_frame()

void schr4c_frame ( const TSurface *  dst,
int  left,
int  top,
int  right,
int  bottom,
u32  clr 
)

Draw a rectangle on a 4bpp tiled surface.

Parameters
dstDestination surface.
leftLeft side of rectangle;
topTop side of rectangle.
rightRight side of rectangle.
bottomBottom side of rectangle.
clrColor.
Note
Does normalization, but not bounds checks.
PONDER: RB in- or exclusive?

References schr4c_hline(), and schr4c_vline().

◆ schr4c_hline()

void schr4c_hline ( const TSurface *  dst,
int  x1,
int  y,
int  x2,
u32  clr 
)

Draw a horizontal line on a 4bpp tiled surface.

Parameters
dstDestination surface.
x1First X-coord.
yY-coord.
x2Second X-coord.
clrColor.
Note
Does normalization, but not bounds checks.

References chr4_lmask(), chr4_rmask(), octup(), and schr4c_get_ptr().

Referenced by schr4c_floodfill_internal(), schr4c_frame(), and schr4c_line().

◆ schr4c_line()

void schr4c_line ( const TSurface *  dst,
int  x1,
int  y1,
int  x2,
int  y2,
u32  clr 
)

Draw a line on a 4bpp tiled surface.

Parameters
dstDestination surface.
x1First X-coord.
y1First Y-coord.
x2Second X-coord.
y2Second Y-coord.
clrColor.
Note
Does normalization, but not bounds checks.

References schr4c_hline(), schr4c_plot(), and schr4c_vline().

◆ schr4c_plot()

void schr4c_plot ( const TSurface *  dst,
int  x,
int  y,
u32  clr 
)

Plot a single pixel on a 4bpp tiled surface.

Parameters
dstDestination surface.
xX-coord.
yY-coord.
clrColor.
Note
Fairly slow. Inline plotting functionality if possible.

Referenced by schr4c_line().

◆ schr4c_prep_map()

void schr4c_prep_map ( const TSurface *  srf,
u16 *  map,
u16  se0 
)

Prepare a screen-entry map for use with chr4.

Parameters
srfSurface with size information.
mapScreen-blocked map to initialize.
se0Additive base screen-entry.

Referenced by tte_init_chr4c().

◆ schr4c_rect()

void schr4c_rect ( const TSurface *  dst,
int  left,
int  top,
int  right,
int  bottom,
u32  clr 
)

Render a rectangle on a 4bpp tiled canvas.

Parameters
dstDestination surface.
leftLeft side of rectangle;
topTop side of rectangle.
rightRight side of rectangle.
bottomBottom side of rectangle.
clrColor-index.

References chr4c_colset(), memset32(), min(), octup(), and schr4c_get_ptr().

Referenced by chr4c_erase().

◆ schr4c_vline()

void schr4c_vline ( const TSurface *  dst,
int  x,
int  y1,
int  y2,
u32  clr 
)

Draw a vertical line on a 4bpp tiled surface.

Parameters
dstDestination surface.
xX-coord.
y1First Y-coord.
y2Second Y-coord.
clrColor.
Note
Does normalization, but not bounds checks.

References schr4c_get_ptr().

Referenced by schr4c_frame(), and schr4c_line().