www.pudn.com > sn068s.zip > MAIN.CPP


//#define NO_GUI 
/* 
 
 SNEeSe 
 
*/ 
 
#include  
#include  
#include  
 
#include  
 
#include "platform.h" 
#include "romload.h" 
#include "helper.h" 
#include "guicore.h" 
#include "emugui.h" 
#include "debug.h" 
#include "snes.h" 
#include "timers.h" 
 
#include "scrmode.h" 
#include "types.h" 
 
/* NTSC */ 
/**/ 
unsigned long SPC_CPU_cycle_divisor = 118125, SPC_CPU_cycle_multiplicand = 5632*2; 
/**/ 
/* PAL */ 
/* 
unsigned long SPC_CPU_cycle_divisor = 2128137, SPC_CPU_cycle_multiplicand = 102400*2; 
 */ 
 
void no_adjust(void){} 
 
SCREEN screenmodes[9]={ 
 { 8,320,200,320,200,GFX_VGA   ,no_adjust  },  // 320x200x256 VGA 
 { 8,320,200,320,200,GFX_VGA   ,no_adjust  },  // 320x200x256 VGA FIT (SQUASH) 
 { 8,320,240,320,240,GFX_MODEX ,no_adjust  },  // 320x240x256 MODE-X 
 { 8,256,256,256,239,GFX_VGA   ,Set256x239 },  // 256x239*256 VGA 
 {16,320,200,320,200,GFX_VESA2L,no_adjust  },  // 320x200x16b SVGA 
 {16,320,240,320,240,GFX_VESA2L,no_adjust  },  // 320x240x16b SVGA 
 {16,640,480,640,480,GFX_VESA2L,no_adjust  },  // 640x480x16b SVGA 
 {16,640,480,640,480,GFX_VESA2L,no_adjust  },  // 640x480x16b SVGA FIT (STRETCH) 
 { 8,320,240,320,240,GFX_VESA2L,no_adjust  }   // 320x240x256 VESA2L 
}; 
 
int main(int argc, char **argv) 
{ 
 
 cout << "SNEeSe, version " << SNEESE_VERSION_STR 
      << " (" << RELEASE_DATE << ")" << endl 
      << allegro_id << endl << endl; 
 cout.flush(); 
 
 // Perform platform-specific initialization 
 if (platform_init(argc, argv)) return 1; 
 
 // Load saved configuration, using defaults for missing settings 
 if (LoadConfig()) return 1; 
 
 char *name = NULL; 
 if (parse_args(argc, argv, &name, 1)) return 1; 
 
 snes_init(); 
 
 if (name != NULL) 
 { 
  cout << "Attempting to load " << name << endl; 
 
  if (!open_rom(name)) 
  { 
   cout << "Failed to load cartridge ROM: " << name << endl; 
   return 1; 
  } 
 
  cout << endl << "Press any key to continue..."; 
  cout.flush(); 
 
  while (!keypressed()); 
  readkey(); 
 } 
 
#ifndef NO_GUI 
 const char *errormsg = (const char *)0; 
 if (GUI_ENABLED) 
 { 
  errormsg = GUI_init(); 
  if (errormsg) 
  { 
   cout << errormsg; 
   return 1; 
  } 
 } 
#endif 
 
 if (!SetGUIScreen(SCREEN_MODE)) return 1; 
 
#ifndef NO_GUI 
 GUI_ERROR GUI_error = GUI_EXIT; 
#endif 
 for (;;) 
 { 
  if (snes_rom_loaded) 
  { 
   snes_exec(); 
  } 
 
#ifndef NO_GUI 
  if (!GUI_ENABLED) break; 
/* 
  if (!SetGUIScreen(SCREEN_MODE))       // SCREEN_MODE set by config file 
  { 
   cout << "Failure creating GUI bitmap!\n"; 
   return 1; 
  } 
*/ 
  GUI_error = GUI(); 
  if (GUI_error != GUI_CONTINUE) break; 
#else 
 break; 
#endif 
 } 
 
 if (snes_rom_loaded) 
  SaveSRAM(SRAM_filename);  // Save the Save RAM to file 
 
 SaveConfig(); 
 
 set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); 
 remove_keyboard(); 
 
#ifdef DEBUG 
 if (snes_rom_loaded) 
 { 
  DisplayStatus(); 
 } 
 
// cout << "\nThanks for testing SNEeSe - look out for future releases.\n"; 
 cout << "\nThanks for using SNEeSe - look out for future releases.\n"; 
#else 
 cout << "\nThanks for using SNEeSe - look out for future releases.\n"; 
#endif 
 
 cout << "Displayed frames: " << Frames << endl; 
 
#ifndef NO_GUI 
 if (GUI_ENABLED) 
 { 
  if (GUI_error != GUI_EXIT) 
  { 
   cout << "GUI: " << GUI_error_table[GUI_error] << endl; 
  } 
 } 
#endif 
 
 save_debug_dumps(); 
 cout.flush(); 
 
 return 0; 
}