void retro_run(void)
{
   uint32_t x, y;
   const uint8_t *buffer;
   uint32_t *surface, pitch;

   update_input();

   prosystem_ExecuteFrame(keyboard_data); // wants input

   videoWidth  = Rect_GetLength(&maria_visibleArea);
   videoHeight = Rect_GetHeight(&maria_visibleArea);
   buffer      = maria_surface + ((maria_visibleArea.top - maria_displayArea.top) * Rect_GetLength(&maria_visibleArea));
   surface     = (uint32_t*)videoBuffer;
   pitch       = 320;

   for(y = 0; y < videoHeight; y++)
   {
      for(x = 0; x < videoWidth; x += 4)
      {
         surface[x + 0] = display_palette32[buffer[x + 0]];
         surface[x + 1] = display_palette32[buffer[x + 1]];
         surface[x + 2] = display_palette32[buffer[x + 2]];
         surface[x + 3] = display_palette32[buffer[x + 3]];
      }
      surface += pitch;
      buffer  += videoWidth;
   }

   video_cb(videoBuffer, videoWidth, videoHeight, videoWidth << 2);

   sound_Store();
}
Beispiel #2
0
/*
 * Runs the main Atari emulator loop
 *
 * testframes   The number of testframes to run (for loading saves)
 */
void wii_atari_main_loop( int testframes )
{
  WII_SetRenderCallback( &wii_render_callback );

  WII_ChangeSquare( wii_screen_x, wii_screen_y, 0, 0 );

  // Track the first fire of the lightgun (so that the catridge can properly
  // detect joystick versus lightgun.)
  lightgun_first_fire = true;

  // Only enable lightgun if the cartridge supports it and we are displaying
  // at 2x.
  lightgun_enabled = 
    ( cartridge_controller[0] & CARTRIDGE_CONTROLLER_LIGHTGUN );

  float fps_counter;
  u32 timerCount = 0;
  u32 start_time = SDL_GetTicks();

  timer_Reset();

  while( !prosystem_paused ) 
  {
    if( testframes < 0 )
    {
      wii_atari_update_keys( keyboard_data );
      wii_testframe = false;
    }
    else
    {
      wii_testframe = true;
    }

    if( prosystem_active && !prosystem_paused ) 
    {       
      prosystem_ExecuteFrame( keyboard_data );

      while( !timer_IsTime() );

      fps_counter = (((float)timerCount++/(SDL_GetTicks()-start_time))*1000.0);
      wii_atari_refresh_screen( true, testframes );

      if( testframes < 0 )
      {
        sound_Store();
      }

      wii_fps_counter = fps_counter;

      if( testframes > 0 )
      { 
        --testframes;
      }
      else if( testframes == 0 )
      {
        return;
      }
    }        
  }

  // Save the high score SRAM
  cartridge_SaveHighScoreSram();
}