Example #1
0
/*
 * Loads the specified ROM
 *
 * filename     The filename of the ROM
 * loadbios     Whether or not to load the Atari BIOS
 *
 * return   Whether the load was successful
 */
bool wii_atari_load_rom( char *filename, bool loadbios ) 
{
  std::string std_filename( filename );
  if( !cartridge_Load(std_filename) ) return false;

  database_Load( cartridge_digest );

  bios_enabled = false;
  if( loadbios )
  {
    if( bios_Load( 
      ( cartridge_region == REGION_PAL ? 
        WII_ROOT_BOOT_ROM_PAL : WII_ROOT_BOOT_ROM_NTSC  ) ) ) 
    {
      bios_enabled = true;
    }
    else
    {
      bios_enabled = false;
    }
  }

  wii_reset_keyboard_data();
  wii_atari_init_palette8();   
  prosystem_Reset();

  wii_atari_pause( false );

  return true;
}
bool retro_load_game(const struct retro_game_info *info)
{
    enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_XRGB8888;
    if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt))
    {
        if (log_cb)
            log_cb(RETRO_LOG_INFO, "[ProSystem]: XRGB8888 is not supported.\n");
        return false;
    }

    struct retro_input_descriptor desc[] = {
       { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT,  "Left" },
       { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP,    "Up" },
       { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN,  "Down" },
       { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "Right" },
       { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B,     "1" },
       { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A,     "2" },
       { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X,     "Console Reset" },
       { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Console Select" },
       { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Console Pause" },
       { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "Left Difficulty" },
       { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "Right Difficulty" },

       { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT,  "Left" },
       { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP,    "Up" },
       { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN,  "Down" },
       { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B,     "1" },
       { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A,     "2" },

       { 0 },
    };

   environ_cb(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, desc);

    memset(keyboard_data, 0, sizeof(keyboard_data));

    // Difficulty switches: Left position = (B)eginner, Right position = (A)dvanced
    // Left difficulty switch defaults to left position, "(B)eginner"
    keyboard_data[15] = 1;

    // Right difficulty switch defaults to right position, "(A)dvanced", which fixes Tower Toppler
    keyboard_data[16] = 0;

    const char *system_directory_c = NULL;

    if (cartridge_Load((const uint8_t*)info->data, info->size))
    {
       environ_cb(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &system_directory_c);
       if (!system_directory_c)
       {
          if (log_cb)
             log_cb(RETRO_LOG_WARN, "[ProSystem]: no system directory defined, unable to look for ProSystem.dat\n");
          database_enabled = false;
       }
       else
       {
          std::string system_directory(system_directory_c);
          std::string database_file_path = system_directory + "/ProSystem.dat";
          std::ifstream database_file(database_file_path.c_str());
          if (!database_file.is_open())
          {
             if (log_cb)
                log_cb(RETRO_LOG_WARN, "[ProSystem]: ProSystem.dat not found, cannot load internal ROM database\n");
             database_enabled = false;
          }
          else
          {
             database_filename = database_file_path;
             database_enabled = true;
          }
       }

       // BIOS is optional
       std::string system_directory(system_directory_c);
       std::string bios_file_path = system_directory + "/7800 BIOS (U).rom";
       if (bios_Load(bios_file_path.c_str()))
          bios_enabled = true;

       database_Load(cartridge_digest);
       prosystem_Reset();

       display_ResetPalette32();

       return true;
    }

   return false;
}