CHGame 0.3.0
Libraries for the CHGame handheld
Loading...
Searching...
No Matches
Row operations

Scrolling and stamping whole framebuffer rows at word speed. More...

Functions

void gfx_scroll (int y, int h, int dx, int dy, int fill=-1)
 Moves a band of rows by (dx, dy) pixels inside the band.
 
void gfx_copyRow (int y, const uint8_t *src, int x0, int x1)
 Copies pixels [x0, x1) of a full-width row buffer into framebuffer row y, clipped.
 

Detailed Description

Scrolling and stamping whole framebuffer rows at word speed.

Word copies in SRAM. newlib-nano's memmove/memcpy are byte loops in flash here: a screen shake built on memmove cost ~10 ms a frame.

Function Documentation

◆ gfx_scroll()

void gfx_scroll ( int  y,
int  h,
int  dx,
int  dy,
int  fill = -1 
)

Moves a band of rows by (dx, dy) pixels inside the band.

Moves the band of rows y..y+h-1 by dx pixels right and dy rows down (negative = left/up). Odd dx is fine (nibble shifts). It works on whole rows and ignores the clip rectangle - it is a post-process: shake, scrolling backgrounds.

Parameters
yFirst row of the band.
hRows in the band (clipped to the screen).
dxPixels to move right; negative moves left.
dyRows to move down; negative moves up.
fillPalette index for the pixels uncovered by the move, or -1 (the default) to leave them as they were.

◆ gfx_copyRow()

void gfx_copyRow ( int  y,
const uint8_t *  src,
int  x0,
int  x1 
)

Copies pixels [x0, x1) of a full-width row buffer into framebuffer row y, clipped.

Build a pattern row once, stamp it into many rows at word speed: tiled floors, checkerboards, gradients.

Parameters
yFramebuffer row.
srcA row of GFX_FB_STRIDE bytes, packed like the framebuffer.
x0First pixel copied.
x1One past the last pixel copied.