- Useful Prizm Routines
- 17 Apr 2011 11:18:10 am
- Last edited by KermMartian on 13 May 2011 03:32:56 pm; edited 2 times in total
I'll start us off.
XORSprite and CopySprite
The former XORs a sprite of specified width and height to the screen. Do it twice, and the screen will return to its original state. The latter routine overwrites the data on the screen, but is (potentially) faster because it memcpys each row. Note that these routines expect the sort of data that SourceCoder outputs.
Code:
XORSprite and CopySprite
The former XORs a sprite of specified width and height to the screen. Do it twice, and the screen will return to its original state. The latter routine overwrites the data on the screen, but is (potentially) faster because it memcpys each row. Note that these routines expect the sort of data that SourceCoder outputs.
Code:
#define LCD_WIDTH_PX 384
#define LCD_HEIGHT_PX 216
void XORSprite(char* data, int x, int y, int width, int height) {
char* VRAM = (char*)0xA8000000;
VRAM += 2*(LCD_WIDTH_PX*y + x);
for(int j=y; j<y+height; j++) {
for(int i=x; i<x+width; i++) {
*(VRAM++) ^= *(data++);
*(VRAM++) ^= *(data++);
}
VRAM += 2*(LCD_WIDTH_PX-width);
}
}
void CopySprite(char* data, int x, int y, int width, int height) {
char* VRAM = (char*)0xA8000000;
VRAM += 2*(LCD_WIDTH_PX*y + x);
for(int j=y; j<y+height; j++) {
memcpy(VRAM,data,2*width);
VRAM += 2*LCD_WIDTH_PX;
data += 2*width;
}
}