
Contributing
This webpage cannot succeed without volunteer effort. Your help in improving existing or adding new apps is very welcome. Simply contact via e-mail any apps you think we should add.
Learning from Open Source
This webpage cannot succeed without volunteer effort. Your help in improving existing or adding new apps is very welcome. Simply contact via e-mail any apps you think we should add.
Copy an N-bit (for N=8, 2, or 1) sprite/image to the VRAM buffer.
const unsigned char* data:
Sprite drawn to VRAM
#include <fxcg/display.h>
void CopySpriteNbit(const unsigned char* data, int x, int y, int width, int height, color_t* palette, unsigned int bitwidth) {
color_t* VRAM = (color_t*) GetVRAMAddress();
VRAM += (LCD_WIDTH_PX*y + x);
int offset = 0;
unsigned char buf;
for(int j=y; j<y+height; j++) {
int availbits = 0;
for(int i=x; i<x+width; i++) {
if (!availbits) {
buf = data[offset++];
availbits = 8;
}
color_t this = ((color_t)buf>>(8-bitwidth));
*VRAM = palette[(color_t)this];
VRAM++;
buf<<=bitwidth;
availbits-=bitwidth;
}
VRAM += (LCD_WIDTH_PX-width);
}
}