Ejemplo n.º 1
0
/****************************************************
**
**  Save last position and size of main help window.
**
****************************************************/
void __far __pascal WriteLastMainWndPos( WINDOWPLACEMENT __far * WndPlacePtr )
{ 
  char szNumber[ 8 ];
  char szString[ MAX_WNDPOS_STRING ];
  char szINIFilePath[ _MAX_PATH ];
  
  /* Get path to the INI file. */
  GetINIPath( szINIFilePath );
  

  /* If maximized. */
  if( WndPlacePtr->showCmd == SW_SHOWMAXIMIZED )
  {
    /* Save window state. */
    itoa( TRUE, szNumber, 10 );
    _fstrcpy( szString, szNumber );
  }
  
  /* If not maximized. */
  else
  {
    /* Save window state. */
    itoa( FALSE, szNumber, 10 );
    _fstrcpy( szString, szNumber );
    _fstrcat( szString, INI_WNDPOS_TOKEN );

    /* Process x position. */
    itoa( WndPlacePtr->rcNormalPosition.left, szNumber, 10 );
    _fstrcat( szString, szNumber );
    _fstrcat( szString, INI_WNDPOS_TOKEN );
    
    /* Process y position. */
    itoa( WndPlacePtr->rcNormalPosition.top, szNumber, 10 );
    _fstrcat( szString, szNumber );
    _fstrcat( szString, INI_WNDPOS_TOKEN );
    
    /* Process width position. */
    itoa( WndPlacePtr->rcNormalPosition.right, szNumber, 10 );
    _fstrcat( szString, szNumber );
    _fstrcat( szString, INI_WNDPOS_TOKEN );
    
    /* Process height position. */
    itoa( WndPlacePtr->rcNormalPosition.bottom, szNumber, 10 );
    _fstrcat( szString, szNumber );
  }

  /* Write entry "LastPos" */
  WritePrivateProfileString( INI_GENERAL_SECTION, INI_WNDPOS_ENTRY, 
                             szString, szINIFilePath );
}
Ejemplo n.º 2
0
void  ReadConfig(void)
{
	FILE *fp;
    int i;

    GetINIPath(IniName,MAX_PATH);

    i=GetPrivateProfileInt("Keys","Key_A",31, IniName);
    KEY_A = i;
    
    i=GetPrivateProfileInt("Keys","Key_B",11, IniName);
    KEY_B = i;
    
    i=GetPrivateProfileInt("Keys","Key_SELECT",36, IniName);
    KEY_SELECT = i;
    
    i=GetPrivateProfileInt("Keys","Key_START",13, IniName);
    if(i==13)
    KEY_START = 47;
    else
    KEY_START = i;
        
    i=GetPrivateProfileInt("Keys","Key_RIGHT",40, IniName);
    KEY_RIGHT = i;
    
    i=GetPrivateProfileInt("Keys","Key_LEFT",39, IniName);
    KEY_LEFT = i;
    
    i=GetPrivateProfileInt("Keys","Key_UP",37, IniName);
    KEY_UP = i;
    
    i=GetPrivateProfileInt("Keys","Key_DOWN",38, IniName);
    KEY_DOWN = i;  
    
    i=GetPrivateProfileInt("Keys","Key_R",23, IniName);
    KEY_R = i;
    
    i=GetPrivateProfileInt("Keys","Key_L",12, IniName);
    KEY_L = i;
    
    i=GetPrivateProfileInt("Keys","Key_X",16, IniName);
    KEY_X = i;
    
    i=GetPrivateProfileInt("Keys","Key_Y",17, IniName);
    KEY_Y = i;

    /*i=GetPrivateProfileInt("Keys","Key_DEBUG",13, IniName);
    KEY_DEBUG = i;*/
}
Ejemplo n.º 3
0
/****************************************************
**
**  Read maximum number of history entries from INI file.
**
****************************************************/
void __far __pascal ReadINIMaxHistory( WORD __far * wMaxHistory )
{
  char szINIFilePath[ _MAX_PATH ];

  /* Get path to the INI file. */
  GetINIPath( szINIFilePath );
  
  /* No history. */
  *wMaxHistory = 0;
  
  /* Entry "MaxHistory" */
  *wMaxHistory = GetPrivateProfileInt( INI_HISTORY_SECTION, INI_MAXHISTORY_ENTRY, 
                                       DEFAULT_MAXHISTORY, szINIFilePath );
   
  /* Entry was there but it wasn't an integer. */
  if( *wMaxHistory == 0 ) *wMaxHistory = DEFAULT_MAXHISTORY;
} 
Ejemplo n.º 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;
}
Ejemplo n.º 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;
}
Ejemplo n.º 6
0
/****************************************************
**
**  Read last position and size of main help window.
**
****************************************************/
BOOL __far __pascal ReadLastMainWndPos( WINDOWPLACEMENT __far * WndPlacePtr )
{ 
  BOOL bMaxmized;
  
  char __far * TokenPtr; 
  char szString[ MAX_WNDPOS_STRING ];
  char szINIFilePath[ _MAX_PATH ];

  short int nBytesRead;

  
  /* Get path to the INI file. */
  GetINIPath( szINIFilePath );
  
  /* Read entry "LastPos" */
  nBytesRead = GetPrivateProfileString( INI_GENERAL_SECTION, INI_WNDPOS_ENTRY, 
                           INI_ENTRY_NOT_FOUND, szString, MAX_WNDPOS_STRING, 
                           szINIFilePath );            
                           
  /* No bytes read or entry not there. */
  if( nBytesRead == 0 || _fstrcmp( szString, INI_ENTRY_NOT_FOUND ) == 0 )
  {
    /* Set to default. */
    WndPlacePtr->showCmd = SW_SHOWNORMAL;
    WndPlacePtr->rcNormalPosition.left   = CW_USEDEFAULT;
    WndPlacePtr->rcNormalPosition.top    = CW_USEDEFAULT;
    WndPlacePtr->rcNormalPosition.right  = CW_USEDEFAULT;
    WndPlacePtr->rcNormalPosition.bottom = CW_USEDEFAULT;
  
    /* Setting not found. */
    return( FALSE );
  }
                                                                
  /* 
  ** Parse entry. 
  */

  /* Get maximize state. */
  TokenPtr = _fstrtok( szString, INI_WNDPOS_TOKEN );
  if( TokenPtr != NULL )
  { 
    bMaxmized = (BOOL) atoi( TokenPtr ); 
  }
  
  /* If maximized. */
  if( bMaxmized )
  {
    WndPlacePtr->showCmd = SW_SHOWMAXIMIZED;
    WndPlacePtr->rcNormalPosition.left   = CW_USEDEFAULT;
    WndPlacePtr->rcNormalPosition.top    = CW_USEDEFAULT;
    WndPlacePtr->rcNormalPosition.right  = CW_USEDEFAULT;
    WndPlacePtr->rcNormalPosition.bottom = CW_USEDEFAULT;

    /* Setting found. */
    return( TRUE );
  }

  /* Not maximized. */
  WndPlacePtr->showCmd = SW_SHOWNORMAL;
    
  /* Get x position. */
  TokenPtr = _fstrtok( NULL, INI_WNDPOS_TOKEN );
  if( TokenPtr != NULL )
  { 
    WndPlacePtr->rcNormalPosition.left = atoi( TokenPtr ); 
  }
  
  /* Get y position. */
  TokenPtr = _fstrtok( NULL, INI_WNDPOS_TOKEN );
  if( TokenPtr != NULL )
  { 
    WndPlacePtr->rcNormalPosition.top = atoi( TokenPtr ); 
  }
  
  /* Get width. */
  TokenPtr = _fstrtok( NULL, INI_WNDPOS_TOKEN );
  if( TokenPtr != NULL )
  { 
    WndPlacePtr->rcNormalPosition.right = atoi( TokenPtr ); 
  }

  /* Get height. */
  TokenPtr = _fstrtok( NULL, INI_WNDPOS_TOKEN );
  if( TokenPtr != NULL )
  { 
    WndPlacePtr->rcNormalPosition.bottom = atoi( TokenPtr ); 
  }

  /* Setting found. */
  return( TRUE );
}