#48424 - jandujar - Tue Jul 19, 2005 10:46 pm
Hello,
I have a problem, i'm trying to incorporate a DAT file to my rom.
My makefile is this:
And my source file is:
my file puzzles.dat have this:
But numpuzzles alwais sais "0"
_________________
http://jandujar.homelinux.com
http://www.dsrobot.com
I have a problem, i'm trying to incorporate a DAT file to my rom.
My makefile is this:
Code: |
# Makefile for gbfs_demo1.nds # chris.double@double.co.nz NDSLIB_INCLUDE=c:/ndsdev/libnds/include NDSLIB_LIB=c:/ndsdev/libnds/lib all: gbfs_demo1.nds.gba libgbfs.o: libgbfs.c gbfs.h arm-elf-g++ -g -Wall -O2 -mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer -ffast-math -mthumb-interwork -I$(NDSLIB_INCLUDE) -DARM7 -c libgbfs.c -olibgbfs.o arm7_main.o: arm7_main.cpp arm-elf-g++ -g -Wall -O2 -mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer -ffast-math -mthumb-interwork -I$(NDSLIB_INCLUDE) -DARM7 -c arm7_main.cpp -oarm7_main.o arm7.elf: arm7_main.o arm-elf-g++ -g -mthumb-interwork -mno-fpu -specs=ds_arm7.specs arm7_main.o -L$(NDSLIB_LIB) -lnds7 -oarm7.elf arm7.bin: arm7.elf arm-elf-objcopy -O binary arm7.elf arm7.bin arm9_main.o: arm9_main.cpp arm-elf-g++ -g -Wall -O2 -mcpu=arm9tdmi -mtune=arm9tdmi -fomit-frame-pointer -ffast-math -mthumb-interwork -I$(NDSLIB_INCLUDE) -DARM9 -c arm9_main.cpp -oarm9_main.o arm9.elf: arm9_main.o libgbfs.o arm-elf-g++ -g -mthumb-interwork -mno-fpu -specs=ds_arm9.specs arm9_main.o libgbfs.o -L$(NDSLIB_LIB) -lnds9 -o arm9.elf arm9.bin: arm9.elf arm-elf-objcopy -O binary arm9.elf arm9.bin puzzles.gbfs: puzzles.dat gbfs puzzles.gbfs puzzles.dat gbfs_demo1.nds: arm7.bin arm9.bin puzzles.gbfs ndstool -c gbfs_demo1.nds -9 arm9.bin -7 arm7.bin cat gbfs_demo1.nds puzzles.gbfs >gbfs_demo1_tmp.nds mv gbfs_demo1_tmp.nds gbfs_demo1.nds gbfs_demo1.nds.gba: gbfs_demo1.nds dsbuild gbfs_demo1.nds -o gbfs_demo1.nds.gba clean: rm -f *.bin rm -f *.elf rm -f *.o rm -f *~ rm -f *.raw rm -f *.gbfs |
And my source file is:
Code: |
#include <nds.h> #include "nds/arm9/console.h" #include <stdlib.h> #include <string.h> #include <stdio.h> #include "gbfs.h" struct Fichero{ char const* filename; uint8* data; uint32 length; }; /* * Aqu? tengo el fichero con los puzzles * */ static Fichero ficheros[]={ {"puzzles.dat",0,0}, {0,0,0} }; static Fichero* current_file = 0; static void CargarDat(){ // Map Game Cartridge memory to ARM9 WAIT_CR &= ~0x80; /* Start searching from the beginning of cartridge memory */ GBFS_FILE const* gbfs_file = find_first_gbfs_file((void*)0x08000000); unsigned int max_length = 0; Fichero* file = ficheros; while(file->filename) { file->data = (uint8*)gbfs_get_obj(gbfs_file, file->filename, &file->length); if(file->length > max_length) max_length = file->length; file++; } current_file=ficheros; } static int key_prev = 0; static int key_curr = 0; int numpuzzles; static uint8* buffer = 0; #define key_poll() { key_prev=key_curr; key_curr = KEYS; } #define key_transit(key) ((key_curr^key_prev) & key) #define key_held(key) (~(key_curr|key_prev) & key) #define key_hit(key) ((~key_curr&key_prev) & key) #define key_released(key) ((key_curr&~key_prev) & key) void on_irq_vblank() { // Disable interrupts IME = 0; consoleClear(); consolePrintf("GBFS Demo Program\n\n"); consolePrintf("Press 'A' to play current file.\n"); consolePrintf("'left/right' changes file.\n"); consolePrintf("'up/down' changes channel.\n\n"); consolePrintf("File: %s (%d)\n", current_file->filename, current_file->length); consolePrintf("Channel: %d\n", 0); //sscanf((const char*)current_file->data,"%d\n",&numpuzzles); consolePrintf("Numpuzzles: %d\n",numpuzzles); // Tell the DS we handled the VBLANK interrupt IF = IF; VBLANK_INTR_WAIT_FLAGS = IF | IE; // Enable interrupts IME = 1; } int main(void) { powerON(POWER_ALL); videoSetMode(MODE_0_2D | DISPLAY_BG0_ACTIVE); vramSetBankA(VRAM_A_MAIN_BG); BG0_CR = BG_MAP_BASE(31); BG_PALETTE[255] = RGB15(31,31,31); lcdSwap(); irqInitHandler(irqDefaultHandler); irqSet(IRQ_VBLANK, on_irq_vblank); irqEnable(IRQ_VBLANK); consoleInitDefault((u16*)SCREEN_BASE_BLOCK(31), (u16*)CHAR_BASE_BLOCK(0), 16); CargarDat(); while(1) { swiWaitForVBlank(); key_poll(); if(key_hit(KEY_UP)) { } if(key_hit(KEY_DOWN)) { } if(key_hit(KEY_LEFT)) { if(--current_file < ficheros) current_file = ficheros; } if(key_hit(KEY_RIGHT)) { if((++current_file)->filename == 0) --current_file; } if(key_hit(KEY_A)) { dmaCopy(current_file->data, buffer, current_file->length); sscanf((const char*)buffer,"%d\n",&numpuzzles); } } return 0; } |
my file puzzles.dat have this:
Code: |
1 1 1 101010101010101010101010101010101010 |
But numpuzzles alwais sais "0"
_________________
http://jandujar.homelinux.com
http://www.dsrobot.com