Example #1
0
int main(int argc,char *argv[])
{
  char *t;

  if(timeBeginPeriod(1)!=TIMERR_NOERROR)
  {
   AddLogText("Error setting timer granularity to 1ms.",1);
  }

  if(!FCEUI_Initialize())
   goto doexito;

  srand(GetTickCount());        // rand() is used for some GUI sillyness.

  fceu_hInstance=GetModuleHandle(0);

  GetBaseDirectory();

  sprintf(TempArray,"%s\\fceu98.cfg",BaseDirectory);
  LoadConfig(TempArray);

  t=ParseArgies(argc,argv);
  /* Bleh, need to find a better place for this. */
  {
        palyo&=1;
        FCEUI_SetVidSystem(palyo);
        genie&=1;
        FCEUI_SetGameGenie(genie);
        fullscreen&=1;
        soundo&=1;
        FCEUI_SetSoundVolume(soundvolume);
        FCEUI_SetSoundQuality(soundquality);

  }
  ParseGIInput(NULL);      /* Since a game doesn't have to be
                     loaded before the GUI can be used, make
                     sure the temporary input type variables
                     are set.
                  */

  CreateDirs();
  SetDirs();

  DoVideoConfigFix();
  DoTimingConfigFix();

  if(eoptions&EO_CPALETTE)
   FCEUI_SetPaletteArray(cpalette);

  if(!t) fullscreen=0;

  CreateMainWindow();

  if(!InitDInput())
   goto doexito;

  if(!DriverInitialize())
   goto doexito;

  InitSpeedThrottle();
  UpdateMenu();

  if(t)
   ALoad(t);
  else if(eoptions&EO_FOAFTERSTART)
   LoadNewGamey(hAppWnd, 0);

  doloopy:
  UpdateFCEUWindow();
  if(GI)
  {
   while(GI)
   {
         uint8 *gfx;
         int32 *sound;
         int32 ssize;

         FCEUI_Emulate(&gfx, &sound, &ssize, 0);
         xbsave = gfx;
         FCEUD_Update(gfx, sound, ssize);
   }
   xbsave = NULL;
   RedrawWindow(hAppWnd,0,0,RDW_ERASE|RDW_INVALIDATE);
   StopSound();
  }
  Sleep(50);
  if(!exiting)
   goto doloopy;

  doexito:
  DriverKill();
  timeEndPeriod(1);
  FCEUI_Kill();
  return(0);
}
Example #2
0
void EMU_init()
{
	//oglrender_init = android_opengl_init;
	
	path.ReadPathSettings();
	if (video.layout > 2)
	{
		video.layout = video.layout_old = 0;
	}
	
	EMU_loadSettings();
    
	Desmume_InitOnce();
	//gpu_SetRotateScreen(video.rotation);
	NDS_FillDefaultFirmwareConfigData(&fw_config);
	//Hud.reset();
	
	INFO("Init NDS");
	/*
	switch (slot1_device_type)
	{
		case NDS_SLOT1_NONE:
		case NDS_SLOT1_RETAIL:
		case NDS_SLOT1_R4:
		case NDS_SLOT1_RETAIL_NAND:
			break;
		default:
			slot1_device_type = NDS_SLOT1_RETAIL;
			break;
	}
	*/
	switch (addon_type)
	{
        case NDS_ADDON_NONE:
            break;
        case NDS_ADDON_CFLASH:
            break;
        case NDS_ADDON_RUMBLEPAK:
            break;
        case NDS_ADDON_GBAGAME:
            if (!strlen(GBAgameName))
            {
                addon_type = NDS_ADDON_NONE;
                break;
            }
            // TODO: check for file exist
            break;
        case NDS_ADDON_GUITARGRIP:
            break;
        case NDS_ADDON_EXPMEMORY:
            break;
        case NDS_ADDON_PIANO:
            break;
        case NDS_ADDON_PADDLE:
            break;
        default:
            addon_type = NDS_ADDON_NONE;
            break;
	}
    
	//!slot1Change((NDS_SLOT1_TYPE)slot1_device_type);
	addonsChangePak(addon_type);
    
	NDS_Init();
	
	//osd->singleScreen = true;
	cur3DCore = 1;
	NDS_3D_ChangeCore(cur3DCore); //OpenGL
	
	LOG("Init sound core\n");
	SPU_ChangeSoundCore(SNDCORE_COREAUDIO, DESMUME_SAMPLE_RATE*8/60);
	
	static const char* nickname = "emozilla";
	fw_config.nickname_len = strlen(nickname);
	for(int i = 0 ; i < fw_config.nickname_len ; ++i)
		fw_config.nickname[i] = nickname[i];
    
	static const char* message = "nds4ios makes you happy!";
	fw_config.message_len = strlen(message);
	for(int i = 0 ; i < fw_config.message_len ; ++i)
		fw_config.message[i] = message[i];
	
	fw_config.language = 1;
    
	video.setfilter(video.NONE);
	
	NDS_CreateDummyFirmware(&fw_config);
	
	InitSpeedThrottle();
	
	mainLoopData.freq = 1000;
	mainLoopData.lastticks = GetTickCount();
}
Example #3
0
File: emu.cpp Project: DD4ve/iNDS
void EMU_init(int lang)
{
	//oglrender_init = android_opengl_init;
	
	path.ReadPathSettings();
	if (video.layout > 2)
	{
		video.layout = video.layout_old = 0;
	}
	
	EMU_loadSettings();
    
	Desmume_InitOnce();
	//gpu_SetRotateScreen(video.rotation);
	NDS_FillDefaultFirmwareConfigData(&fw_config);
	//Hud.reset();
	
	INFO("Init NDS");
	/*
	switch (slot1_device_type)
	{
		case NDS_SLOT1_NONE:
		case NDS_SLOT1_RETAIL:
		case NDS_SLOT1_R4:
		case NDS_SLOT1_RETAIL_NAND:
			break;
		default:
			slot1_device_type = NDS_SLOT1_RETAIL;
			break;
	}
	*/
	switch (addon_type)
	{
        case NDS_ADDON_NONE:
            break;
        case NDS_ADDON_CFLASH:
            break;
        case NDS_ADDON_RUMBLEPAK:
            break;
        case NDS_ADDON_GBAGAME:
            if (!strlen(GBAgameName))
            {
                addon_type = NDS_ADDON_NONE;
                break;
            }
            // TODO: check for file exist
            break;
        case NDS_ADDON_GUITARGRIP:
            break;
        case NDS_ADDON_EXPMEMORY:
            break;
        case NDS_ADDON_PIANO:
            break;
        case NDS_ADDON_PADDLE:
            break;
        default:
            addon_type = NDS_ADDON_NONE;
            break;
	}
    
	//!slot1Change((NDS_SLOT1_TYPE)slot1_device_type);
	addonsChangePak(addon_type);
    
	NDS_Init();
	
	//osd->singleScreen = true;
	cur3DCore = 1;
	NDS_3D_ChangeCore(cur3DCore); //OpenGL
	
	LOG("Init sound core\n");
	SPU_ChangeSoundCore(SNDCORE_COREAUDIO, DESMUME_SAMPLE_RATE*8/60);
	
	static const char* nickname = "iNDS"; //TODO: Add firmware cfg in settings
	fw_config.nickname_len = strlen(nickname);
	for(int i = 0 ; i < fw_config.nickname_len ; ++i)
		fw_config.nickname[i] = nickname[i];
    
	static const char* message = "iNDS is the best!";
	fw_config.message_len = strlen(message);
	for(int i = 0 ; i < fw_config.message_len ; ++i)
		fw_config.message[i] = message[i];
	
	fw_config.language = lang < 0 ? NDS_FW_LANG_ENG : lang;
	fw_config.fav_colour = 15;
	fw_config.birth_month = 2;
	fw_config.birth_day = 17;
	fw_config.ds_type = NDS_CONSOLE_TYPE_LITE;
    
	video.setfilter(video.NONE); //figure out why this doesn't seem to work (also add to cfg)
	
	NDS_CreateDummyFirmware(&fw_config);
	
	InitSpeedThrottle();
	
	mainLoopData.freq = 1000;
	mainLoopData.lastticks = GetTickCount();
}
Example #4
0
int WINAPI WinMain( HINSTANCE hInstance,
				   HINSTANCE hPrevInstance,
				   LPSTR lpCmdLine,
				   int nCmdShow )
{
	MSG uMsg;

	memset(&uMsg,0,sizeof(uMsg));

	winClass.lpszClassName = "MY_WINDOWS_CLASS";
	winClass.cbSize = sizeof(WNDCLASSEX);
	winClass.style = CS_HREDRAW | CS_VREDRAW;
	winClass.lpfnWndProc = WndProc;
	winClass.hInstance = hInstance;
	winClass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
	winClass.hIconSm = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
	winClass.hCursor = LoadCursor(NULL, IDC_ARROW);
	winClass.lpszMenuName = MAKEINTRESOURCE(IDC_CV);
	winClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
	winClass.cbClsExtra = 0;
	winClass.cbWndExtra = 0;

	OpenConsole();

	

	if( !RegisterClassEx(&winClass) )
		return E_FAIL;

	GetINIPath();
	LoadSettings();

	pcejin.aspectRatio = GetPrivateProfileInt("Video", "aspectratio", 0, IniName);
	pcejin.windowSize = GetPrivateProfileInt("Video", "pcejin.windowSize", 1, IniName);
	
	WndX = GetPrivateProfileInt("Main", "WndX", 0, IniName);
	WndY = GetPrivateProfileInt("Main", "WndY", 0, IniName);
	
	g_hWnd = CreateWindowEx( NULL, "MY_WINDOWS_CLASS",
		pcejin.versionName.c_str(),
		WS_OVERLAPPEDWINDOW | WS_VISIBLE,
		WndX, WndY, 256, 232, NULL, NULL, hInstance, NULL );

	if( g_hWnd == NULL )
		return E_FAIL;

	ScaleScreen(pcejin.windowSize);

	soundInit();

	LoadIniSettings();
	InitSpeedThrottle();

	RecentROMs.SetGUI_hWnd(g_hWnd);
	RecentROMs.SetID(RECENTROM_START);
	RecentROMs.SetMenuID(ID_FILE_RECENTROM);
	RecentROMs.SetType("ROM");
	RecentROMs.MakeRecentMenu(hInstance);
	RecentROMs.GetRecentItemsFromIni(IniName, "General");

	RecentMovies.SetGUI_hWnd(g_hWnd);
	RecentMovies.SetID(RECENTMOVIE_START);
	RecentMovies.SetMenuID(ID_MOVIE_RECENT);
	RecentMovies.SetType("Movie");
	RecentMovies.MakeRecentMenu(hInstance);
	RecentMovies.GetRecentItemsFromIni(IniName, "General");

	RecentLua.SetGUI_hWnd(g_hWnd);
	RecentLua.SetID(RECENTLUA_START);
	RecentLua.SetMenuID(ID_LUA_RECENT);
	RecentLua.SetType("Lua");
	RecentLua.MakeRecentMenu(hInstance);
	RecentLua.GetRecentItemsFromIni(IniName, "General");

	DirectDrawInit();

	InitCustomControls();
	InitCustomKeys(&CustomKeys);
	LoadHotkeyConfig();
	LoadInputConfig();

	DragAcceptFiles(g_hWnd, true);

	extern void Agg_init();
	Agg_init();

	if (osd)  {delete osd; osd =NULL; }
	osd  = new OSDCLASS(-1);

	di_init();

	DWORD wmTimerRes;
	TIMECAPS tc;
	if (timeGetDevCaps(&tc, sizeof(TIMECAPS))== TIMERR_NOERROR)
	{
		wmTimerRes = std::min(std::max(tc.wPeriodMin, (UINT)1), tc.wPeriodMax);
		timeBeginPeriod (wmTimerRes);
	}
	else
	{
		wmTimerRes = 5;
		timeBeginPeriod (wmTimerRes);
	}

	if (KeyInDelayMSec == 0) {
		DWORD dwKeyboardDelay;
		SystemParametersInfo(SPI_GETKEYBOARDDELAY, 0, &dwKeyboardDelay, 0);
		KeyInDelayMSec = 250 * (dwKeyboardDelay + 1);
	}
	if (KeyInRepeatMSec == 0) {
		DWORD dwKeyboardSpeed;
		SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &dwKeyboardSpeed, 0);
		KeyInRepeatMSec = (int)(1000.0/(((30.0-2.5)/31.0)*dwKeyboardSpeed+2.5));
	}
	if (KeyInRepeatMSec < (int)wmTimerRes)
		KeyInRepeatMSec = (int)wmTimerRes;
	if (KeyInDelayMSec < KeyInRepeatMSec)
		KeyInDelayMSec = KeyInRepeatMSec;

	hKeyInputTimer = timeSetEvent (KeyInRepeatMSec, 0, KeyInputTimer, 0, TIME_PERIODIC);

	ShowWindow( g_hWnd, nCmdShow );
	UpdateWindow( g_hWnd );

	initialize();
	
	if (lpCmdLine[0])ParseCmdLine(lpCmdLine, g_hWnd);

	if (RecentROMs.GetAutoLoad() && (!skipAutoLoadROM))
	{
		ALoad(RecentROMs.GetRecentItem(0).c_str());
	
	}
	
	//Intentionally does not prompt for a game if no game specified, user should be forced to autoload roms as well, for this to work properly
	if (RecentMovies.GetAutoLoad() && (!skipAutoLoadMovie))
	{	
		LoadMovie(RecentMovies.GetRecentItem(0).c_str(), 1, false, false);
	}

	if (RecentLua.GetAutoLoad() && (!skipAutoLoadLua))
	{
		char temp [1024];
		strcpy(temp, RecentLua.GetRecentItem(0).c_str());
		HWND hDlg = CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_LUA), g_hWnd, (DLGPROC) LuaScriptProc);
		SendDlgItemMessage(hDlg,IDC_EDIT_LUAPATH,WM_SETTEXT,0,(LPARAM)temp);
		
	}

	while( uMsg.message != WM_QUIT )
	{
		if( PeekMessage( &uMsg, NULL, 0, 0, PM_REMOVE ) )
		{
			TranslateMessage( &uMsg );
			DispatchMessage( &uMsg );
		}
		else {
			emulate();
			render();	
		}
		if(!pcejin.started)
			Sleep(1);
	}

	// shutDown();

	timeEndPeriod (wmTimerRes);

	CloseAllToolWindows();

	UnregisterClass( "MY_WINDOWS_CLASS", winClass.hInstance );
	
	return uMsg.wParam;
}
Example #5
0
int WINAPI WinMain( HINSTANCE hInstance,
				   HINSTANCE hPrevInstance,
				   LPSTR lpCmdLine,
				   int nCmdShow )
{
	MSG uMsg;

	memset(&uMsg,0,sizeof(uMsg));

	winClass.lpszClassName = "MY_WINDOWS_CLASS";
	winClass.cbSize = sizeof(WNDCLASSEX);
	winClass.style = CS_HREDRAW | CS_VREDRAW;
	winClass.lpfnWndProc = WndProc;
	winClass.hInstance = hInstance;
	winClass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
	winClass.hIconSm = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
	winClass.hCursor = LoadCursor(NULL, IDC_ARROW);
	winClass.lpszMenuName = MAKEINTRESOURCE(IDC_CV);
	winClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
	winClass.cbClsExtra = 0;
	winClass.cbWndExtra = 0;

	if( !RegisterClassEx(&winClass) )
		return E_FAIL;

	GetINIPath();

	OpenConsoleWindow = GetPrivateProfileBool("Display", "OpenConsoleWindow", true, IniName);

	if (OpenConsoleWindow)
		OpenConsole();

	pcejin.aspectRatio = GetPrivateProfileBool("Video", "aspectratio", false, IniName);
	pcejin.windowSize = GetPrivateProfileInt("Video", "pcejin.windowSize", 1, IniName);
	
	WndX = GetPrivateProfileInt("Main", "WndX", 0, IniName);
	WndY = GetPrivateProfileInt("Main", "WndY", 0, IniName);
	
	g_hWnd = CreateWindowEx( NULL, "MY_WINDOWS_CLASS",
		pcejin.versionName.c_str(),
		WS_OVERLAPPEDWINDOW | WS_VISIBLE,
		WndX, WndY, 348, 224, NULL, NULL, hInstance, NULL );

	if( g_hWnd == NULL )
		return E_FAIL;

	ScaleScreen((float)pcejin.windowSize);

	soundInit();

	LoadIniSettings();
	InitSpeedThrottle();

	DirectDrawInit();

	InitCustomControls();
	InitCustomKeys(&CustomKeys);
	LoadHotkeyConfig();
	LoadInputConfig();

	DragAcceptFiles(g_hWnd, true);

	extern void Agg_init();
	Agg_init();

	if (osd)  {delete osd; osd =NULL; }
	osd  = new OSDCLASS(-1);

	di_init();

	DWORD wmTimerRes;
	TIMECAPS tc;
	if (timeGetDevCaps(&tc, sizeof(TIMECAPS))== TIMERR_NOERROR)
	{
		wmTimerRes = std::min(std::max(tc.wPeriodMin, (UINT)1), tc.wPeriodMax);
		timeBeginPeriod (wmTimerRes);
	}
	else
	{
		wmTimerRes = 5;
		timeBeginPeriod (wmTimerRes);
	}

	if (KeyInDelayMSec == 0) {
		DWORD dwKeyboardDelay;
		SystemParametersInfo(SPI_GETKEYBOARDDELAY, 0, &dwKeyboardDelay, 0);
		KeyInDelayMSec = 250 * (dwKeyboardDelay + 1);
	}
	if (KeyInRepeatMSec == 0) {
		DWORD dwKeyboardSpeed;
		SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &dwKeyboardSpeed, 0);
		KeyInRepeatMSec = (int)(1000.0/(((30.0-2.5)/31.0)*dwKeyboardSpeed+2.5));
	}
	if (KeyInRepeatMSec < (int)wmTimerRes)
		KeyInRepeatMSec = (int)wmTimerRes;
	if (KeyInDelayMSec < KeyInRepeatMSec)
		KeyInDelayMSec = KeyInRepeatMSec;

	hKeyInputTimer = timeSetEvent (KeyInRepeatMSec, 0, KeyInputTimer, 0, TIME_PERIODIC);

	ShowWindow( g_hWnd, nCmdShow );
	UpdateWindow( g_hWnd );

	initialize();
	
	if (lpCmdLine[0])ParseCmdLine(lpCmdLine, g_hWnd);

	while( uMsg.message != WM_QUIT )
	{
		if( PeekMessage( &uMsg, NULL, 0, 0, PM_REMOVE ) )
		{
			TranslateMessage( &uMsg );
			DispatchMessage( &uMsg );
		}
		else {
			emulate();
			render();	
		}
		if(!pcejin.started)
			Sleep(1);
	}

	// shutDown();

	timeEndPeriod (wmTimerRes);

	CloseAllToolWindows();

	UnregisterClass( "MY_WINDOWS_CLASS", winClass.hInstance );
	
	return uMsg.wParam;
}