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 > Distinguish between hardware and emulator at runtime

#171006 - pladux - Wed Oct 28, 2009 11:33 am

Hey guys,

i'm working on a little app that is able fetch some data from a website.

Since there is no emulator with wifi support all calls to Wifi_InitDefault leads to a blank window. On the DS everything just works fine, so i'd like to find a way to feed my app with 'fake data' when it runs on an emulator.

I want something like
Code:

if(runningOnNDS()) {
    retrieveDataFromInternet()
} else {
    retrieveDataFromLocalFile()
}


I do not want
Code:

#ifdef NDS
    retrieveDataFromInternet()
#else
    retrieveDataFromLocalFile()
#endif

since this would need an other build target.

It would be nice if someone could give me a hint.

#171007 - a128 - Wed Oct 28, 2009 12:25 pm

use the libfat (FAT) ....Luke :-)
Code:


   if(fatInitDefault()) {
      imfat=true;
      printf("Success...gues I have the hardware with DLDI\n");
   } else {
      imfat=false;
      printf("Failed... (normal for some emulators. Dont worry, yet :p)\n");
   }


as seen in NitroFS
_________________
"Hey! It compiles! Ship it!"

#171008 - pladux - Wed Oct 28, 2009 12:35 pm

thank you

#171023 - Exophase - Wed Oct 28, 2009 8:37 pm

Why not just test if the WiFi is actually working? That way if an emulator does implement WiFi your code will work on it the proper way, and if the emulator is too genuine/accurate for your check to work then it won't unexpectedly fail.

#171028 - hacker013 - Wed Oct 28, 2009 10:20 pm

libfat read and writes are supported in ideas with a special plugin ;)
_________________
Website / Blog

Let the nds be with you.

#171037 - TwentySeven - Wed Oct 28, 2009 11:40 pm

Yeah I just check the wifi.

Wifi_AutoConnect(); // request connect
while(1)
{
i=Wifi_AssocStatus(); // check status
if(i==ASSOCSTATUS_ASSOCIATED)
{
Debugout("Connected successfully!");
break;
}
if(i==ASSOCSTATUS_CANNOTCONNECT)
{
Debugout("Could not connect!");
return -1; //probably in an emulator
}

#171049 - a128 - Thu Oct 29, 2009 9:34 am

Ideas also have a WiFi plugin

But who uses Ideas...?! My apps never runs on Ideas! Which is sad because I think it has some great debugging features.
_________________
"Hey! It compiles! Ship it!"