gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > N00b needs help with accessing assets

#67194 - HyperHacker - Mon Jan 16, 2006 4:30 am

Next question... with ndstool I can include binary files in the .nds, but how do I access them from code? I can see them in the .nds in a hex editor, but I scanned the main RAM for the file's content and didn't find anything, and fopen() doesn't do it. GBFS functions don't find it either.

#67219 - tepples - Mon Jan 16, 2006 7:09 am

Binary files in the .nds are mainly intended for use with DS Game Cards by licensed developers (or for Pocket Heaven purposes), not for use in GBA ROM. To use GBFS in GBA ROM in a ds.gba program, use 'padbin 256 rom.nds' followed by 'copy /b ndsloader.bin+rom.nds+data.gbfs rom.ds.gba'.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#67222 - HyperHacker - Mon Jan 16, 2006 7:29 am

Does it have to be .ds.gba? I'm using WMB to run it, which has worked fine with .nds and no loader so far.

#67226 - crossraleigh - Mon Jan 16, 2006 7:41 am

Then use the bin2o makefile macro. If you insist on using GBFS, you can bin2o the .gbfs file: there is a libnds example that demonstrates this technique.

#67308 - HyperHacker - Mon Jan 16, 2006 10:18 pm

Eh, I don't use makefiles. I use a batch file.
Code:
@echo off

IF NOT DEFINED devkitarm_path GOTO noenv
IF NOT DEFINED ndslib_path GOTO noenv
IF NOT DEFINED nds_wmb_path GOTO noenv
goto start

:noenv
echo The required environment variables have not been defined.
goto end

:start
echo Compiling ARM7...
%devkitarm_path%\arm-elf-g++ -g -mcpu=arm7tdmi -mtune=arm7tdmi -mthumb-interwork -I%ndslib_path%\include -DARM7 -fomit-frame-pointer -ffast-math -o%devkitarm_path%\arm7.o -c arm7.c
IF NOT EXIST %devkitarm_path%\arm7.o GOTO done
%devkitarm_path%\arm-elf-g++ -g -mthumb-interwork -mno-fpu -specs=ds_arm7.specs %devkitarm_path%\arm7.o -L%ndslib_path%\lib -lnds7 -o%devkitarm_path%\arm7.elf
IF NOT EXIST %devkitarm_path%\arm7.elf GOTO done
%devkitarm_path%\arm-elf-objcopy -O binary %devkitarm_path%\arm7.elf %devkitarm_path%\arm7.bin
IF NOT EXIST %devkitarm_path%\arm7.bin GOTO done

echo Compiling ARM9...
%devkitarm_path%\arm-elf-g++ -g -mcpu=arm9tdmi -mtune=arm9tdmi -mthumb-interwork -I%ndslib_path%\include -DARM9 -fomit-frame-pointer -ffast-math -o%devkitarm_path%\arm9.o -c arm9.c
IF NOT EXIST %devkitarm_path%\arm9.o GOTO done
%devkitarm_path%\arm-elf-g++ -g -mthumb-interwork -mno-fpu -specs=ds_arm9.specs %devkitarm_path%\arm9.o -L%ndslib_path%\lib -lnds9 -o%devkitarm_path%\arm9.elf
IF NOT EXIST %devkitarm_path%\arm9.elf GOTO done
%devkitarm_path%\arm-elf-objcopy -O binary %devkitarm_path%\arm9.elf %devkitarm_path%\arm9.bin
IF NOT EXIST %devkitarm_path%\arm9.bin GOTO done

:link
echo Linking...
%devkitarm_path%\ndstool -c %devkitarm_path%\test3.nds -7 %devkitarm_path%\arm7.bin -9 %devkitarm_path%\arm9.bin -o %devkitarm_path%\logos\nds.bmp -d data

:run
echo Running...
%nds_wmb_path%\wmb -data %devkitarm_path%\test3.nds -player Banana

:done
echo Cleaning...
del %devkitarm_path%\arm7.o > NUL
del %devkitarm_path%\arm9.o > NUL
del %devkitarm_path%\arm7.elf > NUL
del %devkitarm_path%\arm9.elf > NUL
del %devkitarm_path%\arm7.bin > NUL
del %devkitarm_path%\arm9.bin > NUL
echo Done.
echo ????????????????????????????????????????????????????????????????????????????????
popd
:end

It compiles ARM7 and ARM9 sources separately, merges them with ndstool, starts a WMB broadcast if the compile succeeded, and deletes the temporary files. :-)