#162779 - hacker013 - Fri Sep 12, 2008 7:40 pm
Hey everybody,
I've have some problems with my code to load a bmp and to draw it. (it is modifyd version of mighty maxs bmp load code for his os.
I get when is use hax_draw_bmp a black screen. Can you see the problem?
gr,
hacker013
_________________
Website / Blog
Let the nds be with you.
I've have some problems with my code to load a bmp and to draw it. (it is modifyd version of mighty maxs bmp load code for his os.
Code: |
#include <hax_fat.h> #include <hax_bmp.h> #include <malloc.h> #include <string.h> /*----------------------------------------------------------------------------------------------------------- hax_load_bmp const char* name = filename bool custom = custom memory adres unsigned long adress = if custom is true, custom memory adress, else 0 -----------------------------------------------------------------------------------------------------------*/ unsigned short *hax_load_bmp(const char* name,bool custom,unsigned long adress) { FILE *bmp = fopen(name,"rb") ; if (!bmp) return NULL; unsigned short *screen = NULL; if (custom==true) { screen = (unsigned short *)adress ; } else { screen = (unsigned short *)malloc(flength(bmp)); } fseek(bmp,54,SEEK_SET) ; int x,y ; for (y=191;y>=0;y--) { for (x=0;x<256;x++) { unsigned char color[3] ; fread(&color[0],1,3,bmp) ; color[0]/=8 ; color[1]/=8 ; color[2]/=8 ; screen[y*256+x] = 0x8000 | (color[0] & 0x1F) | ((color[1] & 0x1F) << 5) | ((color[2] & 0x1F) << 10) ; } ; } ; fclose(bmp) ; return screen; } void hax_draw_bmp(bool screen,int x, int y, int w, int h, unsigned long adress) { unsigned short *scr = NULL; if (screen==0) { scr = (u16 *)0x06008000; } else { scr = (u16 *)0x06208000; } unsigned short *mem = (unsigned short *)adress ; for (y=y;h>=y;h--) { for (x=x;x<w;x++) { scr[h*256+x] = *mem; mem++; } ; } ; } void hax_remove_bmp(unsigned long adress) { free((unsigned short *)adress); } |
I get when is use hax_draw_bmp a black screen. Can you see the problem?
gr,
hacker013
_________________
Website / Blog
Let the nds be with you.