#99486 - dannyboy - Tue Aug 22, 2006 1:06 am
Hi all, I started messing around with 2D stuff on the DS and a couple of issues have come up.
1) I had some code to load a 2D background working nicely as so:
However I decided to start using a filesystem, namely gbfs. I changed the code to the following:
The problem is, it works, but the new code is a lot slower. Where the first code seemed instantaneous the new code takes a short while, even on hardware. Is there a way to speed it up? Oh, and what about 8 bit backgrounds. What's the best way to load those?
2) I am having problems with the colours for my sprites. In this example, I load 3 sprites. I use the palette of the second sprite which shows perfectly. However the other 2 show with distorted colouring. Is there a way to synchronise the palettes?
1) I had some code to load a 2D background working nicely as so:
Code: |
for(int i = 0; i < 256*192; i++) {
BG_GFX_SUB[i] = ((u16*)ColourField_bin)[i] | BIT(15); } |
However I decided to start using a filesystem, namely gbfs. I changed the code to the following:
Code: |
for(int i = 0; i < 256*192; i++) {
BG_GFX_SUB[i] = ((u16*)gbfs_get_obj(&data_gbfs, "ColourField.bin", NULL)) [i] | BIT(15); } |
The problem is, it works, but the new code is a lot slower. Where the first code seemed instantaneous the new code takes a short while, even on hardware. Is there a way to speed it up? Oh, and what about 8 bit backgrounds. What's the best way to load those?
2) I am having problems with the colours for my sprites. In this example, I load 3 sprites. I use the palette of the second sprite which shows perfectly. However the other 2 show with distorted colouring. Is there a way to synchronise the palettes?
Code: |
sImage Image;
void CSprite::LoadPalette() { for(int i = 0; i < 256; i++) { SPRITE_PALETTE_SUB[i] = Image.palette[i]; } } void CSprite::LoadImage(unsigned char* pcxFile, int i) // Load simage into the given memory location { int offset = i*32*16; // offset in memory for multiple sprites loadPCX(pcxFile, &Image); // load our pcx file into an image imageTileData(&Image); // tile it so it is useful as sprite data for(int i = 0; i < 32*16; i++) { SPRITE_GFX_SUB[offset + i] = Image.data16[i]; } } LoadImage((u8*)gbfs_get_obj(&data_gbfs, "one.pcx", NULL), 1); LoadImage((u8*)gbfs_get_obj(&data_gbfs, "two.pcx", NULL), 2); for(int i = 0; i < 256; i++) { SPRITE_PALETTE_SUB[i] = Image.palette[i]; LoadImage((u8*)gbfs_get_obj(&data_gbfs, "three.pcx", NULL), 3); } |