#167713 - Tommmie - Mon Mar 23, 2009 7:25 am
ok so i started with converting a 1024x1024 bg with grit to the bin format. i load the bin's from fat but my ds AND ideas do nothing, my code:
ok so i have a new piece of code without that malloc part(it's even smaller now:)), but could someone please say me why that was wrong?
Code: |
#include <nds.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <dirent.h> #include <fat.h> #include <nitrofs.h> #include "kakariko.h" #include "background.h" int x; int y; u8 speed; int nx, ny; int rx, ry; unsigned short sourcemap[16384]; unsigned short * buffer; //--------------------------------------------------------------------------------- int main(void) { //--------------------------------------------------------------------------------- videoSetMode(MODE_5_2D | DISPLAY_BG0_ACTIVE); vramSetBankA(VRAM_A_MAIN_BG); fatInitDefault(); nitroFSInit("/test.nds"); int bg1 = bgInit(0, BgType_Text8bpp, BgSize_T_512x256, 0, 1); FILE * pfile; pfile = fopen("map.bin", "rb"); fread(&sourcemap, kakarikoMapLen, 1, pfile); fclose (pfile); pfile = fopen("/tiles.bin", "rb"); buffer = (unsigned short*) malloc (kakarikoTilesLen); fread(&buffer, kakarikoTilesLen, 1, pfile); fclose (pfile); dmaCopy(buffer, bgGetGfxPtr(bg1), sizeof(kakarikoTiles)); free(buffer); pfile = fopen("/pal.bin", "rb"); buffer = (unsigned short*) malloc (kakarikoPalLen); fread(&buffer, kakarikoPalLen, 1, pfile); fclose (pfile); dmaCopy(buffer, BG_PALETTE, sizeof(kakarikoPal)); free (buffer); |
ok so i have a new piece of code without that malloc part(it's even smaller now:)), but could someone please say me why that was wrong?