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 > My first DS demo!

#39483 - FeaRog - Sat Apr 09, 2005 4:21 pm

Hi all,
I've been working like a madman since I got my PassMe (about 28 hours ago now), reasonably steep learning curve, but here's what I've come up with. I'll release the source once I've tidied it up a bit - its not terribly readable at the moment.

I think I'm running out of texture memory, you notice it on the later models. Theres a few bugs on the texturing of the 3rd model.

This sort of works on the IdeaS emulator, but not very well. It has z-buffer issues, texture changing doesn't work properly, and the SELECT button doesn't seem to work at all. For full effect, run it on real hardware with the PassMe :)

Controls:
Touchscreen/D-pad = rotate
A/B = zoom in/out
Select = change model

You can get it here:
http://www.geocities.com/codefiend.geo/viewer.zip

I'm pretty stoked with what I've done so far :D

Enjoy!

FeaRog

#39493 - Lino - Sat Apr 09, 2005 7:04 pm

This is the image with my version of iDeaS...


http://ideasemu.altervista.org

#39494 - FeaRog - Sat Apr 09, 2005 7:14 pm

Yep - try rotating the player around and you notice that you can see his gun through his body, among other artefacts.

Note that this doesn't run on any of the other emulators.

#39501 - ecurtz - Sat Apr 09, 2005 7:40 pm

Looks great.

I just got 256 color textures working for my version of a md2 converter this morning. PM me for details of the fixes I had to make if you're interested, it might help with your texture issues. (Or just wait for them to get into ndsLib, I already sent the details to dovoto, and he's pretty on the ball about making fixes.)

#39524 - dovoto - Sun Apr 10, 2005 12:27 am

That looks great! 256 color textures should make a big difference in memory usage. I updated the CVS with the fix (although it will only work for a single palette and even that is untested).

Also you may want to call:
void glResetTextures(void);

in between each model and reload the textures. This should reset texture memory. My texture stuff is very untested so any feedback is definitly welcome. I also uploaded the fix to the bugs you noticed ecurtz. They are in CVS (takes a few hours to propigate).
_________________
www.drunkencoders.com

#39538 - Lynx - Sun Apr 10, 2005 2:23 am

Very nice! Looks good on hardware to me!

#39552 - zazery - Sun Apr 10, 2005 6:03 am

Looks really cool on the hardware. The screens are reversed on my DS if the iDeas screenshot is supposed to be how it looks. The model is on the top screen and the text on the bottom.

#39553 - FeaRog - Sun Apr 10, 2005 6:36 am

Thanks for the positive feedback guys :)

Dovoto - I've just updated my ndslib, and started to play with display lists.

I've found that I had to replace the following macros in videoGL.h:
Code:
#define FIFO_*            REG2ID(GFX_*)

with
Code:
#define FIFO_*            REG2ID(&GFX_*)

for it to operate.

I also haven't been able to get the glCallList() function to work; I have played with the DMA control flags for it and can't seem to get anything to happen. Instead I'm using:

Code:

void glCallList2(uint32* list)
{
   uint32 wordcount = *(list++);
   while( wordcount-- )
      GFX_FIFO = *(list++);
}

Which works fine on hardware, but not in iDeaS.

Another thing I discovered: the console printing commands have a problem that they don't print any zeros in a number until the last one. Eg
Code:
consolePrintf("0x%x", 0x4000400);
prints 0x440. Heres my fixed version of printx for reference - they all seem to need fixing like this:

Code:

void printx(int w, unsigned int d)
{
   int loop = 0;
   int i = 0;
   
   char buf[20] = {0};

   while(d > 0)
   {
      buf[loop++] =  d & 0xF;
      d = d>>4;
   }
   
   int started = 0;
   for (i = 7; i >= 0; i--)
   {
      if (buf[i])
         started = 1;

      if(started)
      {
         if(buf[i] < 10)
            consolePrintChar(buf[i] + '0');
         else
            consolePrintChar(buf[i] + 'a' - 10);
      }
      else if(i < w)
         consolePrintChar('0');
   }
}


And yet another thing! I hadn't done a clean rebuild of ndslib prior to fixing that console bug, and now that I've done one I find that my viewer doesn't run in iDeaS at all, and neither does the 3D example. They still work fine in hardware. Unfortunately I don't know precisely when it stopped working so I can't revert.

ecurtz - what format is the palette in on the 256 colour textures? 5551 like the RGBA format?

#39558 - FeaRog - Sun Apr 10, 2005 7:03 am

Model on the top screen is how it is meant to appear zazery - I'm guessing that Lino has reversed them in his version of the emulator.

#39559 - ecurtz - Sun Apr 10, 2005 7:10 am

Palette is the same format as a regular 555 pixel. It seems to ignore the alpha bit.

#39561 - LOUD NOISES - Sun Apr 10, 2005 7:22 am

How exactly are you guys getting this to run on iDeaS? All I get is a black screen, although the textured cube demo seemed to work...

#39562 - FeaRog - Sun Apr 10, 2005 7:37 am

It won't run off the .nds file in iDeaS (not in the version I have anyway), and I don't have an emulator friendly arm9.bin for you, as it doesn't seem to work with the latest version of ndslib... Lino has all the source and he's working on the compatibility issues, so you might be able to try it in the emu in a few days (fingers crossed) :)

I'm still planning on releasing the source code, but maybe once I've got display lists and paletted textures happening... too busy messing around to clean things up at the moment :D This is one fun little doodad!

#39564 - garlic - Sun Apr 10, 2005 7:40 am

iDeaS seems to reverse the screens on the code i've tried as well.

#39610 - dovoto - Sun Apr 10, 2005 7:08 pm

Fixed the fifo display list comands. Fixed console functions. Added a few fifo comands. Display lists seem to have issues with DMA. Works fine on longer lists but not realy on short display lists...for now i will leave the code as a while loop for compatibility and try to figure out the limitations on DMA as that is were the real power will come from.
_________________
www.drunkencoders.com

#39655 - FeaRog - Mon Apr 11, 2005 2:34 am

Based on my tests I'd say that the FIFO can handle a maximum list length of 16k - a 15k list (Quake ogre) worked fine, but 19k (Quake player) did not. I haven't exhaustively tested the minimum size yet, but I intend to. I'll probably generate a bunch of lists with different numbers of triangles and test them one by one. My best guess at this stage is that there is some sort of buffer between the DMA and the FIFO, and that the data doesn't reach the FIFO until that buffer is filled.
Once we know more about the size limits (if there is one, ie if we're not missing something) we could add a check to glCallList:

Code:
void glCallList(uint32* list)
{
    if (size < minSize)
        glCallListLoop(list);
    else
        glCallListDMA(list);
}

#39683 - mike260 - Mon Apr 11, 2005 1:03 pm

Hmm...it's been a while, but I think Metroid's DMA->FIFO code splits DMAs into chunks of around 512 bytes or less. IIRC, the code is in the ITCM section, which is right at the end of the ARM9 bin.