Blah
Wanna Be Programmer
gp_uncompressZDA returns 8bit data, but gp_drawSprite needs 16bit data. What I'm doing is trying to draw a sprite from a .bin file inside a ZDA which has been converted to an .h included in the file h34r: It all works except for the gp_drawSprite which gives a "incompatible pointer type" error. I can read a text file out of it though because gp_drawString takes chars. So thats not the problem.
Here's my code. Actually its a hacked up zdaread.c
Here's my code. Actually its a hacked up zdaread.c
Code:
#include "gp32.h"
#include "zda.h"
#include "data.h"
unsigned short gp_colorRGB24to16( unsigned char R, unsigned char G, unsigned char B )
{
return ((R >> 3) << 11) | ((G >> 3) << 6) | ((B >> 3) << 1);
}
int main() {
//DIR dir_struct;
//int dir_entrys;
int x,err;
unsigned short *framebuffer1;
framebuffer1 = (unsigned short*) FRAMEBUFFER1;
gp_setCpuspeed(133);
gp_initFramebuffer(framebuffer1,16,85);
gp_clearFramebuffer16(framebuffer1,0xFFFF);
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// USING NEW ZDA FORMAT WITH HEADER
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//
// I compressed 3 files to the datah.zda file
// Makefile, README.TXT, zda_compressor.c
// You no longer need to know size or offset position
{ char header_12bytes[12]; // The ZDA header is always 12 Bytes big
char *full_header; // The full headersize depend on content
char *compressed;
char *uncompressed;
int real_headersize;
int usize,csize,offset,err;
memcpy(header_12bytes,data,12);
real_headersize=gp_zda_headersize(header_12bytes); // calculate the real headersize
full_header = (char*) malloc(real_headersize); // malloc space for full header
memcpy(full_header,data,real_headersize);
csize = gp_zda_csize (full_header, "1.bin"); // get compressed size of file README.TXT
usize = gp_zda_usize (full_header, "1.bin"); // get uncompressed size of file README.TXT
offset = gp_zda_offset(full_header, "1.bin"); // get the offset for file README.TXT, counting from file beginning
compressed = (char*) malloc(csize); // temp buffer for compressed file
uncompressed = (char*) malloc(usize); // buffer for uncompressed data
memcpy(compressed,data+offset,csize);
gp_drawString(10,100,26,"Uncompressing file ... ",0xF800,framebuffer1);
err = gp_uncompressZDA((u8*)uncompressed, &usize, (u8*)compressed, csize ); // uncompress
unsigned short color;
color = gp_colorRGB24to16(97,68,43);
gp_drawSpriteHT (uncompressed,0,0,framebuffer1,color);
// free all memory
free (full_header);
free (compressed);
free (uncompressed);
}
while (1) { if ( gp_getButton()&BUTTON_A) gp_Reset(); }
}