Homebrew DeSmuME source code query [Programming]

  • Thread starter Deleted User
  • Start date
  • Views 1,666
  • Replies 4
D

Deleted User

Guest
OP
Hey Guys.

So, looking at the DeSmuMe source I see this:

Code:
//only dump this from ogl renderer. for now, softrasterizer creates things in an incompatible pixel format
//#define DEBUG_DUMP_TEXTURE

Now its commented out, but there is a texture dumper in there, further down it has this:
I did uncomment it of course, thinking it'd be that simple.
Code:
#if defined (DEBUG_DUMP_TEXTURE) && defined (WIN32)
#define DO_DEBUG_DUMP_TEXTURE
static void DebugDumpTexture(TexCacheItem* item)
{
    static int ctr=0;
    char fname[100];
    sprintf(fname,"c:\\dump\\%d.bmp", ctr);
    ctr++;
 
    NDS_WriteBMP_32bppBuffer(item->sizeX,item->sizeY,item->decoded,fname);
}
#endif

My thoughts on this are that theres a built in texture dumper in DeSmuMe, which isn't much of a surprise, but simply enabling it doesn't seem to do anything.

Thats all in texcache.cpp, nothing edited there, all default.

My question is, thats the only reference to DEBUG_TEXTURE_DUMP in the whole project, how am I supposed to dump the textures then? Theres no key, or shortcut or anything, nor do they get dumped as they load into memory.

Note:
I am aware there are various other methods to ripping textures from NDS games, and those work great, I'm mostly interested in understanding how this code works, and when its supposed to initiate.

I'm not much of a coder so chances are I'm just overlooking something stupidly simple here.
 

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,798
Trophies
3
XP
28,285
Country
United Kingdom
I am not sure about this particular issue but a lot of the debugging side of things with desmume is more placeholder than anything else, 3d being especially troubled by this situation.
 
  • Like
Reactions: Deleted User
D

Deleted User

Guest
OP
Was really hoping somebody might be able to chip in with some advice, I'm still stumped even now.
 
D

Deleted User

Guest
OP
At the top of texcache.cpp, look for the line that says "//#define DEBUG_DUMP_TEXTURE". Uncomment that line (make it just say "#define DEBUG_DUMP_TEXTURE", without the "//" before it). Start Desmume with the OpenGL renderer settings. It should automatically dump the textures to the C:\dump\ folder. If that folder doesn't exist then you'll need to make it yourself. That's all that should need to be done, judging from the code I looked at.

I figured it out. What you said is what I thought, and it was also correct, it wasn't dumping (and still isn't) to the c:\dump folder, its actually dumping to the folder the exe is in (or in the previous case it was dumping to the save state folder). So I was being stupid, but also I'd left it as \\ instead of \, plus the c was lower case (might mean nothing, but its uppercase now and it works so I'm using that as a thumbs up.

Awesome, so with that figured out, now I need to figure out where to place the snippets of this code to dump the 3d models. (hopefully it won't dump hundreds for every movement like the texture dump does).

Code:
//texcache.cpp
 
//only dump this from ogl renderer. for now, softrasterizer creates things in an incompatible pixel format
 
//#define DEBUG_DUMP_TEXTURE//szfzafa
 
 
 
 
 
//gfx3d.h
 
//szfzafa
 
extern unsigned char szfzafadumpmodelmark;
 
void gfx3d_szfzafadumpmodels();
 
 
 
//gfx3d.cpp
 
unsigned char szfzafadumpmodelmark=0;//szfzafa
 
static void gfx3d_doFlush()
 
{
 
    //szfzafa
 
        if(szfzafadumpmodelmark)
 
        gfx3d_szfzafadumpmodels();
 
    //szfzafa
 
        gfx3d.frameCtr++;
 
……
 
 
 
//szfzafa:dump models!
 
//-------------savestate
 
 
 
void gfx3d_szfzafadumpmodels()
 
{
 
    if(gfx3d.vertlist->count>4&&gfx3d.polylist->count>1)
 
        szfzafadumpmodelmark=0;
 
    else
 
        {
 
                  printf("szfzafa ripping failed~\n");
 
        return;
 
    }
 
 
 
    FILE *file;
 
    if ((file = fopen("c:\\dump\\szfzafa.obj","wb")) == NULL)
 
        return;
 
    //dump the render lists
 
        printf("szfzafa ripping %d verts %d polys~\n",gfx3d.vertlist->count,gfx3d.polylist->count);
 
    for(int i=0;i<gfx3d.vertlist->count;i++)
 
    {
 
          //fprintf(file,"v\t%f\t%f\t%f\t%f\n",gfx3d.vertlist->list[i].x,gfx3d.vertlist->list[i].y,gfx3d.vertlist->list[i].z,gfx3d.vertlist->list[i].w);
 
                  fprintf(file,"v\t%f\t%f\t%f\t%f\n",
 
              gfx3d.vertlist->list[i].y*3.0/-32.0,
 
              gfx3d.vertlist->list[i].x/8.0,
 
              gfx3d.vertlist->list[i].z/-2.0,
 
              gfx3d.vertlist->list[i].w);
 
        //fprintf(file,"vt\t%f\t%f\n",gfx3d.vertlist->list[i].u,gfx3d.vertlist->list[i].v);
 
                  fprintf(file,"vt\t%f\t%f\n",gfx3d.vertlist->list[i].u,-gfx3d.vertlist->list[i].v);
 
    }
 
 
 
    //char szfzafatex[32];
 
        u32 szfzafapa1=gfx3d.polylist->list[0].polyAttr;
 
    u32 szfzafapa2=gfx3d.polylist->list[0].texPalette;
 
    u32 szfzafapa3=gfx3d.polylist->list[0].texParam;
 
    fprintf(file,"g\t%x_%x_%x\n",szfzafapa1,szfzafapa2,szfzafapa3);
 
    //printf("usemtl\t%x\n",szfzafapa);
 
        for(int i=0;i<gfx3d.polylist->count;i++)
 
    {
 
        if(szfzafapa1!=gfx3d.polylist->list[i].polyAttr||
 
              szfzafapa2!=gfx3d.polylist->list[i].texPalette||
 
              szfzafapa3!=gfx3d.polylist->list[i].texParam)
 
        {
 
              szfzafapa1=gfx3d.polylist->list[i].polyAttr;
 
              szfzafapa2=gfx3d.polylist->list[i].texPalette;
 
              szfzafapa3=gfx3d.polylist->list[i].texParam;
 
              fprintf(file,"g\t%x_%x_%x\n",szfzafapa1,szfzafapa2,szfzafapa3);
 
        }
 
        switch(gfx3d.polylist->list[i].type)
 
        {
 
        case 4:  fprintf(file,"f\t%d/%d\t%d/%d\t%d/%d\t%d/%d\n",
 
                      1+gfx3d.polylist->list[i].vertIndexes[0],1+gfx3d.polylist->list[i].vertIndexes[0],
 
                      1+gfx3d.polylist->list[i].vertIndexes[1],1+gfx3d.polylist->list[i].vertIndexes[1],
 
                      1+gfx3d.polylist->list[i].vertIndexes[2],1+gfx3d.polylist->list[i].vertIndexes[2],
 
                      1+gfx3d.polylist->list[i].vertIndexes[3],1+gfx3d.polylist->list[i].vertIndexes[3]);
 
              break;
 
        case 3:  fprintf(file,"f\t%d/%d\t%d/%d\t%d/%d\n",
 
                      1+gfx3d.polylist->list[i].vertIndexes[0],1+gfx3d.polylist->list[i].vertIndexes[0],
 
                      1+gfx3d.polylist->list[i].vertIndexes[1],1+gfx3d.polylist->list[i].vertIndexes[1],
 
                      1+gfx3d.polylist->list[i].vertIndexes[2],1+gfx3d.polylist->list[i].vertIndexes[2]);
 
              break;
 
        default:;
 
        }
 
    }
 
    fclose(file);
 
}

I know where it says the section, sort of, and It makes it clear what cpp or .h file to past the code in, the downside is, it doesn't say much where, or even how to activate it at all.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
  • ZeroT21 @ ZeroT21:
    generic soldering irons were never made to last
    +1
  • SylverReZ @ SylverReZ:
    @ZeroT21, Exactly. They're only good if you're willing to practice soldering, not for the long run.
  • ZeroT21 @ ZeroT21:
    i only use 'em to fix my own home appliances or personal projects/mods
    +1
  • SylverReZ @ SylverReZ:
    Home appliances would be a soldering gun, including plumbing. Normal soldering irons are for hobbyist projects/modchip installs.
  • ZeroT21 @ ZeroT21:
    though i've heard plenty of people getting wrecked trying to ''fix'' their microwave
  • SylverReZ @ SylverReZ:
    @ZeroT21, Did somebody tell them to put something metal in there?
  • ZeroT21 @ ZeroT21:
    I'm wondering what's so hard about it
  • SylverReZ @ SylverReZ:
    🍆 <== This?
  • ZeroT21 @ ZeroT21:
    having bigger nuts than brains is genetic probably
    +1
  • SylverReZ @ SylverReZ:
    That's what they tried to tell you.
  • SylverReZ @ SylverReZ:
    Hypothetically.
  • ZeroT21 @ ZeroT21:
    People won't believe me anyways untill shit happens. Youtube teaches everything they say... so ima just sit back and enjoy the mayhem
    +1
  • SylverReZ @ SylverReZ:
    If brain small, does that mean bigger balls? :unsure:
  • ZeroT21 @ ZeroT21:
    no ,they have bigger balls
    +1
  • ZeroT21 @ ZeroT21:
    we can't possibly insinuate they have small brains, be modest and just tell 'em they have big balls so they feel better bout 'emselfs
    +1
  • SylverReZ @ SylverReZ:
    @ZeroT21, True lol.
  • BakerMan @ BakerMan:
    chat is this real?
  • K3Nv2 @ K3Nv2:
    Chat is Ai
  • ZeroT21 @ ZeroT21:
    big balls are REAL
  • ZeroT21 @ ZeroT21:
    AI has balls too

    :rofl2:
    ZeroT21 @ ZeroT21: AI has balls too :rofl2: