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 > MD2 loading

#108196 - Xgame - Mon Nov 06, 2006 4:39 pm

Hi, I need a mode for load md2, but I can't find it!I looked anywere but all the animated loader for md2 have expired in their host. I just need it, or same suggestion for do my own loader

#108231 - Payk - Mon Nov 06, 2006 10:21 pm

U can have my code or better code a own one...u can leanr much from it ;)

http://tfc.duke.free.fr/coding/md2-specs-en.html
^^this site is great for it.
if you load the mesh and its totaly fucked up dont be shoked!
the float there is much bigger then on nds (and fixedpoint too...which i recommand) just do /128 for each vertex and it will look right.
But thats to slow for rendering....i recommand you scale down and take the vertices and convert to fixed point.

If you have wrong textures just toggle S and T...while T needs to be changed like: T=texturewidth -T (pseudo code)

If its an milkshape md2, u dont need to do that...
contact me if its to much for you...but i recommand you to try on your own first...

#108292 - Xgame - Tue Nov 07, 2006 3:52 pm

just a question:
in libnds which is a function like "fopen", fclose", "fread" and "fseek"?

#108296 - tepples - Tue Nov 07, 2006 4:12 pm

Xgame wrote:
just a question:
in libnds which is a function like "fopen", fclose", "fread" and "fseek"?

Those functions are present in libfat, provided that your code mounts the drive first. But conspicuous by its absence are findfirst() and opendir().
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#108299 - Xgame - Tue Nov 07, 2006 4:31 pm

no way to include file?

#108302 - Payk - Tue Nov 07, 2006 5:17 pm

Sure.
Best way is romdiskfs portet/modded by GPF.
It uses gba-rom space (means it only works on ez-deluxe,supercard, m3...generally all devices which support gba)

fopen will then be KOS_fopen.
same for the rest. writing isnt possible.
root wil be "/rd/"...it support folder structure and every read command like stdio/stdlib...its cool

http://gpf.dcemu.co.uk/ndsromdisk.shtml
Its faster then fat and nobody can change content of your game (that easily)...

Strangely its just a hand full of coders using it. that mac VM from lazyone, all portet things from GPF, and my game are using that as well. I just can recommand it.

But it doesnt work on following devices:
DS-Xtreme,DS-LINK,NINJDS,MK2/3,GBAMP,SC RUMBLEPACK...
all things which dont go trough gba slot and dont have the 32MB built in ram to hold roms....but most devices have that. And i am working on a mox between fat/kos...just wait some weeks (got other things todo too).
Till then u could use KOS or FAT. As you prefer...

#108306 - Xgame - Tue Nov 07, 2006 5:49 pm

rally cool! thank you, i'll try now
EDIT
how can I use just "#include"model.md2""? It whold be easier.


Last edited by Xgame on Tue Nov 07, 2006 6:48 pm; edited 1 time in total

#108309 - Lazy1 - Tue Nov 07, 2006 6:10 pm

I thought someone had a way of appending the romdisk to the arm9 binary or something. That was supposed to work with non-ram cards.

#108318 - Payk - Tue Nov 07, 2006 8:11 pm

Lazy1: Yes? You got more infos?
XGame: It wouldnt be easier...no stdio functions.
And it would mean that the model is stored in 4MB main ram till the entiry game...not a whise choice

#108331 - tepples - Tue Nov 07, 2006 9:10 pm

Lazy1 wrote:
I thought someone had a way of appending the romdisk to the arm9 binary or something. That was supposed to work with non-ram cards.

You can try using the 'bin2o' macro that comes with the libnds project template to convert the romdisk to an object file for linking into your project.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#108349 - Payk - Tue Nov 07, 2006 11:15 pm

Hmh yeah its nice for smaller projects...but it costs mainram of course...

#108392 - Lazy1 - Wed Nov 08, 2006 1:13 pm

I have started working on getting romfs working with the standard I/O functions and it seems to be going pretty well so far.
Calling romfsInitDefault() sets everything up so files can be read with extreme ease.

There is a big problem though, I cannot find a whole lot of documentation on how devoptab works. I've been taking quick looks at libfat here and there but it's not enough.

Even still, it does read files quite nicely and prints "Hello World!" as expected.
Code:

int main( void ) {
   static char helloBuffer[ 512 ];
   FILE* helloFile = NULL;

   powerON( POWER_ALL_2D | POWER_SWAP_LCDS );
   
   irqInit( );
   irqEnable( IRQ_VBLANK );
   
   consoleDemoInit( );
   romfsInitDefault( );

   if ( ( helloFile = fopen( "hello.txt", "rt" ) ) != NULL ) {
      fread( helloBuffer, 1, 512, helloFile );
      fclose( helloFile );

      iprintf( "%s\n", helloBuffer );
   } else {
      iprintf( "File open failed\n" );
   }
   
   while ( 1 ) {
      swiWaitForVBlank( );
   }
      
   return 0;
}

#108395 - Xgame - Wed Nov 08, 2006 1:59 pm

for me isn't working. what Have I to do for get it work?

#108426 - Lazy1 - Wed Nov 08, 2006 6:24 pm

What are you trying to get to work?
Having problems with libfat or romfs?