Ejemplo n.º 1
0
void Config_LoadConfig(void)
{
   FILE *f;
   char line[4096];

   // default configuration
   Config_SetDefault();

   // __LIBRETRO__: Get screen size
   config.screen.width = screen_width;
   config.screen.height = screen_height;


   // read configuration
   const char *filename = ConfigGetSharedDataFilepath("gles2n64.conf");
   f = fopen(filename, "r");
   if (!f)
   {
      if (log_cb)
      {
         log_cb(RETRO_LOG_WARN, "[gles2N64]: Couldn't open config file '%s' for reading: %s\n", filename, strerror( errno ) );
         log_cb(RETRO_LOG_WARN, "[gles2N64]: Attempting to write new Config \n");
      }
      Config_WriteConfig(filename);
   }
   else
   {
      if (log_cb)
         log_cb(RETRO_LOG_INFO, "[gles2n64]: Loading Config from %s \n", filename);

      while (!feof( f ))
      {
         char *val;
         fgets( line, 4096, f );

         if (line[0] == '#' || line[0] == '\n')
            continue;

         val = strchr( line, '=' );
         if (!val) continue;

         *val++ = '\0';

         Config_SetOption(line,val);
      }

      if (config.version < CONFIG_VERSION)
      {
         if (log_cb)
            log_cb(RETRO_LOG_WARN, "[gles2N64]: Wrong config version, rewriting config with defaults\n");
         Config_SetDefault();
         Config_WriteConfig(filename);
      }

      fclose(f);
   }
}
Ejemplo n.º 2
0
void Config_LoadConfig()
{
    FILE *f;
    char line[4096];

    // default configuration
    Config_SetDefault();

    // read configuration
    char filename[PATH_MAX];
    snprintf(filename, PATH_MAX, "%s/gles2n64.conf", GetPluginDir());
    f = fopen(filename, "r");
    if (!f)
    {
        LOG(LOG_MINIMAL, "[gles2N64]: Couldn't open config file '%s' for reading: %s\n", filename, strerror( errno ) );
        LOG(LOG_MINIMAL, "[gles2N64]: Attempting to write new Config \n");
        Config_WriteConfig(filename);
    }
    else
    {
        LOG(LOG_MINIMAL, "[gles2n64]: Loading Config from %s \n", filename);

        while (!feof( f ))
        {
            char *val;
            fgets( line, 4096, f );

            if (line[0] == '#' || line[0] == '\n')
                continue;

            val = strchr( line, '=' );
            if (!val) continue;

            *val++ = '\0';

             Config_SetOption(line,val);
        }

        if (config.version < CONFIG_VERSION)
        {
            LOG(LOG_WARNING, "[gles2N64]: Wrong config version, rewriting config with defaults\n");
            Config_SetDefault();
            Config_WriteConfig(filename);
        }

        fclose(f);
    }
}
Ejemplo n.º 3
0
void Config_LoadRomConfig(unsigned char* header)
{
   char line[4096];
   int i;

   // get the name of the ROM
   for (i = 0; i < 20; i++)
      config.romName[i] = header[0x20+i];
   config.romName[20] = '\0';
   while (config.romName[strlen(config.romName)-1] == ' ')
   {
      config.romName[strlen(config.romName)-1] = '\0';
   }

   switch(header[0x3e])
   {
      // PAL codes
      case 0x44:
      case 0x46:
      case 0x49:
      case 0x50:
      case 0x53:
      case 0x55:
      case 0x58:
      case 0x59:
         config.romPAL = true;
         break;

         // NTSC codes
      case 0x37:
      case 0x41:
      case 0x45:
      case 0x4a:
         config.romPAL = false;
         break;

         // Fallback for unknown codes
      default:
         config.romPAL = false;
   }

   if (log_cb)
      log_cb(RETRO_LOG_INFO, "Rom is %s\n", config.romPAL ? "PAL" : "NTSC");

   const char *filename = ConfigGetSharedDataFilepath("gles2n64rom.conf");
   FILE *f = fopen(filename,"r");
   if (!f)
   {
      if (log_cb)
         log_cb(RETRO_LOG_INFO, "Could not find %s Rom settings file, using global.\n", filename);
      return;
   }
   else
   {
      if (log_cb)
         log_cb(RETRO_LOG_INFO, "[gles2N64]: Searching %s Database for \"%s\" ROM\n", filename, config.romName);
      bool isRom = false;
      while (!feof(f))
      {
         fgets(line, 4096, f);
         if (line[0] == '\n') continue;

         if (strncmp(line,"rom name=", 9) == 0)
         {
            //Depending on the editor, end lines could be terminated by "LF" or "CRLF"
            char* lf = strchr(line, '\n'); //Line Feed
            char* cr = strchr(line, '\r'); //Carriage Return
            if (lf) *lf='\0';
            if (cr) *cr='\0';
            isRom = (strcasecmp(config.romName, line+9) == 0);
         }
         else
         {
            if (isRom)
            {
               char* val = strchr(line, '=');
               if (!val) continue;
               *val++ = '\0';
               Config_SetOption(line,val);
               if (log_cb)
                  log_cb(RETRO_LOG_INFO, "%s = %s", line, val);
            }
         }
      }
   }

   fclose(f);
}
Ejemplo n.º 4
0
void Config_LoadRomConfig(unsigned char* header)
{
    char line[4096];

    // get the name of the ROM
    for (int i=0; i<20; i++) config.romName[i] = header[0x20+i];
    config.romName[20] = '\0';
    while (config.romName[strlen(config.romName)-1] == ' ')
    {
        config.romName[strlen(config.romName)-1] = '\0';
    }

    switch(header[0x3e])
    {
        // PAL codes
        case 0x44:
        case 0x46:
        case 0x49:
        case 0x50:
        case 0x53:
        case 0x55:
        case 0x58:
        case 0x59:
            config.romPAL = true;
            break;

        // NTSC codes
        case 0x37:
        case 0x41:
        case 0x45:
        case 0x4a:
            config.romPAL = false;
            break;

        // Fallback for unknown codes
        default:
            config.romPAL = false;
    }

    LOG(LOG_MINIMAL, "Rom is %s\n", config.romPAL ? "PAL" : "NTSC");

    const char *filename = ConfigGetSharedDataFilepath("gles2n64rom.conf");
    FILE *f = fopen(filename,"r");
    if (!f)
    {
        LOG(LOG_MINIMAL, "Could not find %s Rom settings file, using global.\n", filename);
        return;
    }
    else
    {
        LOG(LOG_MINIMAL, "[gles2N64]: Searching %s Database for \"%s\" ROM\n", filename, config.romName);
        bool isRom = false;
        while (!feof(f))
        {
            fgets(line, 4096, f);
            if (line[0] == '\n') continue;

            if (strncmp(line,"rom name=", 9) == 0)
            {
                char* v = strchr(line, '\n');
                if (v) *v='\0';
                isRom = (strcasecmp(config.romName, line+9) == 0);
            }
            else
            {
                if (isRom)
                {
                    char* val = strchr(line, '=');
                    if (!val) continue;
                    *val++ = '\0';
                    Config_SetOption(line,val);
                }
            }
        }
    }
	
    fclose(f);
}
Ejemplo n.º 5
0
void Config_LoadRomConfig(unsigned char* header)
{
    char line[4096];
    char filename[PATH_MAX];

    // get the name of the ROM
    for (int i=0; i<20; i++) config.romName[i] = header[0x20+i];
    config.romName[20] = '\0';
    while (config.romName[strlen(config.romName)-1] == ' ')
    {
        config.romName[strlen(config.romName)-1] = '\0';
    }

    switch(header[0x3e])
    {
        case 0x44: //Germany ('D')
            config.romPAL = true;
            break;
        case 0x45: //USA ('E')
            config.romPAL = false;
            break;
        case 0x4A: //= Japan ('J')
            config.romPAL = false;
            break;
        case 0x50: //= Europe ('P')
            config.romPAL = true;
            break;
        case 0x55: //= Australia ('U')
            config.romPAL = true;
            break;
        default:
            config.romPAL = false;
            break;
    }

    LOG(LOG_MINIMAL, "Rom is %s\n", config.romPAL ? "PAL" : "NTSC");

    snprintf(filename, PATH_MAX, "%s/gles2n64rom.conf", GetPluginDir());
    FILE *f = fopen(filename,"r");
    if (!f)
    {
        LOG(LOG_MINIMAL, "Could not find %s Rom settings file, using global.\n", filename);
        return;
    }
    else
    {
        LOG(LOG_MINIMAL, "[gles2N64]: Searching %s Database for \"%s\" ROM\n", filename, config.romName);
        bool isRom = false;
        while (!feof(f))
        {
            fgets(line, 4096, f);
            if (line[0] == '\n') continue;

            if (strncmp(line,"rom name=", 9) == 0)
            {
                char* v = strchr(line, '\n');
                if (v) *v='\0';
                isRom = (strcasecmp(config.romName, line+9) == 0);
            }
            else
            {
                if (isRom)
                {
                    char* val = strchr(line, '=');
                    if (!val) continue;
                    *val++ = '\0';
                    Config_SetOption(line,val);
                }
            }
        }
    }
}