Exemple #1
0
static void gba_init(void)
{
	//default values
	cpuSaveType = 0;
	flashSize = 0x10000;
	enableRtc = false;
	mirroringEnable = false;

	LoadImagePreferences();

	utilUpdateSystemColorMaps();

	if(flashSize == 0x10000 || flashSize == 0x20000)
		flashSetSize(flashSize);

	if(rtcEnable)
		rtcEnable(enableRtc);
	doMirroring(mirroringEnable);

	soundInit();
	soundSetSampleRate(32000);

	CPUInit(0, false);
	CPUReset();

	soundReset();
	soundResume();

	uint8_t *state_buf = new uint8_t[2000000];
	serialize_size = CPUWriteState_libgba(state_buf, 2000000);
	delete[] state_buf;
}
Exemple #2
0
void initUI(void)
{
    bool optionsLoaded;
    bool mouseInitialized;
    
    initMachine();
    
    optionsLoaded = loadOptions();
    
    initGameEngine(&gCallbacks);
    mouseInitialized = initMouse(&gMouseCallbacks);
    
    // If we couldn't initialize a mouse and it was enabled on the options, then disable it.
    if ((!mouseInitialized) &&
        (gGameOptions.enableMouse)) {
        gGameOptions.enableMouse = false;
        gGameOptions.optionsSaved = false;
        
        // If there were no options loaded, then let's turn on the joystick instead.
        if (!optionsLoaded) {
            gGameOptions.enableJoystick = true;
        }
    }
    
    initJoystick(&gJoyCallbacks);
    
    if (gGameOptions.enableSound) {
        soundInit(gGameOptions.mockingBoardSlot, gGameOptions.enableSpeechChip);
    }
    
    if (!gGameOptions.optionsSaved) {
        saveOptions();
    }
}
Exemple #3
0
static void applyNewOptions(tGameOptions *newOptions)
{
    bool oldEnableMouse = gGameOptions.enableMouse;
    
    // If there is no change in game options, then nothing to do.
    if (memcmp(newOptions, &gGameOptions, sizeof(gGameOptions)) == 0) {
        return;
    }
    
    if ((gGameOptions.enableSound != newOptions->enableSound) ||
        (gGameOptions.mockingBoardSlot != newOptions->mockingBoardSlot) ||
        (gGameOptions.enableSpeechChip != gGameOptions.enableSpeechChip)) {
        // If the sound parameters have changed, then re-init or shutdown sounds
        if (newOptions->enableSound) {
            soundInit(newOptions->mockingBoardSlot, newOptions->enableSpeechChip);
        } else {
            soundShutdown();
        }
    }
    
    memcpy(&gGameOptions, newOptions, sizeof(gGameOptions));
    gGameOptions.optionsSaved = false;
    if (oldEnableMouse != gGameOptions.enableMouse) {
        if (gGameOptions.enableMouse) {
            gGameOptions.enableMouse = initMouse(&gMouseCallbacks);
        }
    }
    saveOptions();
}
Exemple #4
0
void MyModuleInit(RTC::Manager* manager)
{
  soundInit(manager);
  RTC::RtcBase* comp;

  // Create a component
  comp = manager->createComponent("sound");

  if (comp==NULL)
  {
    std::cerr << "Component create failed." << std::endl;
    abort();
  }

  // Example
  // The following procedure is examples how handle RT-Components.
  // These should not be in this function.

  // Get the component's object reference
//  RTC::RTObject_var rtobj;
//  rtobj = RTC::RTObject::_narrow(manager->getPOA()->servant_to_reference(comp));

  // Get the port list of the component
//  PortServiceList* portlist;
//  portlist = rtobj->get_ports();

  // getting port profiles
//  std::cout << "Number of Ports: ";
//  std::cout << portlist->length() << std::endl << std::endl; 
//  for (CORBA::ULong i(0), n(portlist->length()); i < n; ++i)
//  {
//    PortService_ptr port;
//    port = (*portlist)[i];
//    std::cout << "Port" << i << " (name): ";
//    std::cout << port->get_port_profile()->name << std::endl;
//    
//    RTC::PortInterfaceProfileList iflist;
//    iflist = port->get_port_profile()->interfaces;
//    std::cout << "---interfaces---" << std::endl;
//    for (CORBA::ULong i(0), n(iflist.length()); i < n; ++i)
//    {
//      std::cout << "I/F name: ";
//      std::cout << iflist[i].instance_name << std::endl;
//      std::cout << "I/F type: ";
//      std::cout << iflist[i].type_name << std::endl;
//      const char* pol;
//      pol = iflist[i].polarity == 0 ? "PROVIDED" : "REQUIRED";
//      std::cout << "Polarity: " << pol << std::endl;
//    }
//    std::cout << "---properties---" << std::endl;
//    NVUtil::dump(port->get_port_profile()->properties);
//    std::cout << "----------------" << std::endl << std::endl;
//  }

  return;
}
void init() {

    soundInit();

    sleepval.tv_sec = 0;
    sleepval.tv_nsec = 500000000;

    dpy = XOpenDisplay(NULL);
    screen = DefaultScreen(dpy);
    root = RootWindow(dpy, screen);

}
static void gba_init(void)
{
   cpuSaveType = 0;
   flashSize = 0x10000;
   enableRtc = false;
   mirroringEnable = false;
#ifdef FRONTEND_SUPPORTS_RGB565
   systemColorDepth = 16;
   systemRedShift = 11;
   systemGreenShift = 6;
   systemBlueShift = 0;
#else
   systemColorDepth = 32;
   systemRedShift = 19;
   systemGreenShift = 11;
   systemBlueShift = 3;
#endif


   utilUpdateSystemColorMaps(false);
   
   if (cpuSaveType == 0)
      utilGBAFindSave(size);
   else
      saveType = cpuSaveType;

   load_image_preferences();

   if(flashSize == 0x10000 || flashSize == 0x20000)
      flashSetSize(flashSize);

   if(enableRtc)
      rtcEnable(enableRtc);

   doMirroring(mirroringEnable);

   soundInit();
   soundSetSampleRate(32000);

   CPUInit(0, false);
   CPUReset();

   soundReset();

   uint8_t * state_buf = (uint8_t*)malloc(2000000);
   serialize_size = CPUWriteState(state_buf, 2000000);
   free(state_buf);

   emulating = 1;
}
void Window::vInitSystem()
{
    systemColorDepth = 32;
    systemVerbose = 0;
    systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
    systemFrameSkip = 2;

    emulating = 0;

    gbFrameSkip = 0;

    m_iFrameCount = 0;

    soundInit();
}
Exemple #8
0
//-------------------------------------------------------------------------------------------
void xenDemoInit(){ 

	//Init My Application
	swDispManagerSetCullRegion(0,0,1024,768);
	swDispManagerSetLayerCount(10);
	camID=swGraphicsCreateCam();

	//Manager Init
	resourceInit();
	physInit();
	soundInit();
	moleculerDecomposeInit();
	explosionInit();
	objParticleInit();
	clawWeaponInit();
	enemyWeaponInit();
	dslInit();
	

	//Entitiy Init
	laserGateInit();
	//clawCreate();




	if(xenDemoIsSupportPostProcessing() && graphicsCardIsNvidia()){
		rendTargID=swGraphicsCreateRenderingTarget(1024,512,3); //Define New RenderingTarget 
		fullScreenImgID=swGraphicsRenderingTargetGetImgID(rendTargID); //Get ImgID  
		swGraphicsActiveGLSLShader(SW_DISABLED_SHADER_ID);
	}
		

	bgMusicSourceID=swAudioCreateSource();
	swAudioBindSourceAndBuffer(bgMusicSourceID,bgMusicBufferID);
	swAudioSetSourceGain(bgMusicSourceID,5.0);

	
	#ifdef DEBUG	
	//sceneGenerate();
	scnMngrSetMode(SCENE_MAINGUI_MAINPAGE);
	#else
	//scnMngrSetMode(SCENE_MAINGUI_MAINPAGE);
	introInit();
	#endif
	gameLoopTimerID=swTimerCreate(0.016,NULL,xenDemoLoop);
}
bool MainWnd::FileRun()
{
  // save battery file before we change the filename...
  if(rom != NULL || gbRom != NULL) {
    if(theApp.autoSaveLoadCheatList)
      winSaveCheatListDefault();
    writeBatteryFile();
    cheatSearchCleanup(&cheatSearchData);
    theApp.emuCleanUp();
    remoteCleanUp(); 
    emulating = false;   
  }
  char tempName[2048];
  char file[2048];
  
  utilGetBaseName(theApp.szFile, tempName);
  
  _fullpath(file, tempName, 1024);
  theApp.filename = file;

  int index = theApp.filename.ReverseFind('.');
  if(index != -1)
    theApp.filename = theApp.filename.Left(index);

  CString ipsname;
  ipsname.Format("%s.ips", theApp.filename);  

  if(!theApp.dir.GetLength()) {
    int index = theApp.filename.ReverseFind('\\');
    if(index != -1) {
      theApp.dir = theApp.filename.Left(index-1);
    }
  }

  IMAGE_TYPE type = utilFindType(theApp.szFile);

  if(type == IMAGE_UNKNOWN) {
    systemMessage(IDS_UNSUPPORTED_FILE_TYPE,
                  "Unsupported file type: %s", theApp.szFile);
    return false;
  }

  theApp.cartridgeType = (int)type;
  if(type == IMAGE_GB) {
    if(!gbLoadRom(theApp.szFile))
      return false;
    theApp.emuWriteState = gbWriteSaveState;
    theApp.emuWriteMemState = gbWriteMemSaveState;
    theApp.emuReadState = gbReadSaveState;
    theApp.emuReadMemState = gbReadMemSaveState;
    theApp.emuWriteBattery = gbWriteBatteryFile;
    theApp.emuReadBattery = gbReadBatteryFile;
    theApp.emuReset = gbReset;
    theApp.emuCleanUp = gbCleanUp;
    theApp.emuWritePNG = gbWritePNGFile;
    theApp.emuWriteBMP = gbWriteBMPFile;
    theApp.emuMain = gbEmulate;
#ifdef FINAL_VERSION
    theApp.emuCount = 70000/4;
#else
    theApp.emuCount = 1000;
#endif
    gbBorderOn = theApp.winGbBorderOn;
    if(theApp.autoIPS) {
      int size = gbRomSize;
      utilApplyIPS(ipsname, &gbRom, &size);
      if(size != gbRomSize) {
        extern bool gbUpdateSizes();
        gbUpdateSizes();
        gbReset();
      }
    }
  } else {
    int size = CPULoadRom(theApp.szFile);
    if(!size)
      return false;
    
    flashSetSize(theApp.winFlashSize);
    rtcEnable(theApp.winRtcEnable);
    cpuSaveType = theApp.winSaveType;

    //    if(cpuEnhancedDetection && winSaveType == 0) {
    //      utilGBAFindSave(rom, size);
    //    }
    GetModuleFileName(NULL, tempName, 2048);

    char *p = strrchr(tempName, '\\');
    if(p)
      *p = 0;
    
    char buffer[5];
    strncpy(buffer, (const char *)&rom[0xac], 4);
    buffer[4] = 0;

    strcat(tempName, "\\vba-over.ini");
    
    UINT i = GetPrivateProfileInt(buffer,
                                  "rtcEnabled",
                                  -1,
                                  tempName);
    if(i != (UINT)-1)
      rtcEnable(i == 0 ? false : true);

    i = GetPrivateProfileInt(buffer,
                             "flashSize",
                             -1,
                             tempName);
    if(i != (UINT)-1 && (i == 0x10000 || i == 0x20000))
      flashSetSize((int)i);

    i = GetPrivateProfileInt(buffer,
                             "saveType",
                             -1,
                             tempName);
    if(i != (UINT)-1 && (i <= 5))
      cpuSaveType = (int)i;

    theApp.emuWriteState = CPUWriteState;
    theApp.emuWriteMemState = CPUWriteMemState;
    theApp.emuReadState = CPUReadState;
    theApp.emuReadMemState = CPUReadMemState;
    theApp.emuWriteBattery = CPUWriteBatteryFile;
    theApp.emuReadBattery = CPUReadBatteryFile;
    theApp.emuReset = CPUReset;
    theApp.emuCleanUp = CPUCleanUp;
    theApp.emuWritePNG = CPUWritePNGFile;
    theApp.emuWriteBMP = CPUWriteBMPFile;
    theApp.emuMain = CPULoop;
#ifdef FINAL_VERSION
    theApp.emuCount = 250000;
#else
    theApp.emuCount = 5000;
#endif
    if(theApp.removeIntros && rom != NULL) {
      *((u32 *)rom)= 0xea00002e;
    }
    
    if(theApp.autoIPS) {
      int size = 0x2000000;
      utilApplyIPS(ipsname, &rom, &size);
      if(size != 0x2000000) {
        CPUReset();
      }
    }
  }
    
  if(theApp.soundInitialized) {
    if(theApp.cartridgeType == 1)
      gbSoundReset();
    else
      soundReset();
  } else {
    if(!soundOffFlag)
      soundInit();
    theApp.soundInitialized = true;
  }

  if(type == IMAGE_GBA) {
    skipBios = theApp.skipBiosFile ? true : false;
    CPUInit((char *)(LPCTSTR)theApp.biosFileName, theApp.useBiosFile ? true : false);
    CPUReset();
  }
  
  readBatteryFile();

  if(theApp.autoSaveLoadCheatList)
    winLoadCheatListDefault();
  
  theApp.addRecentFile(theApp.szFile);

  theApp.updateWindowSize(theApp.videoOption);

  theApp.updateFrameSkip();

  if(theApp.autoHideMenu && theApp.videoOption > VIDEO_4X && theApp.menuToggle)
    OnFileTogglemenu();
 
  emulating = true;

  if(theApp.autoLoadMostRecent)
    OnFileLoadgameMostrecent();

  theApp.frameskipadjust = 0;
  theApp.renderedFrames = 0;
  theApp.autoFrameSkipLastTime = theApp.throttleLastTime = systemGetClock();

  theApp.rewindCount = 0;
  theApp.rewindCounter = 0;
  theApp.rewindSaveNeeded = false;
  
  theApp.disablePowerManagement();
  
  return true;
}
void systemTask(void *arg)
{
  bool pass = true;

  ledInit();
  ledSet(CHG_LED, 1);

#ifdef DEBUG_QUEUE_MONITOR
  queueMonitorInit();
#endif

#ifdef ENABLE_UART1
  uart1Init();
#endif
#ifdef ENABLE_UART2
  uart2Init();
#endif

  //Init the high-levels modules
  systemInit();
  commInit();
  commanderInit();

  StateEstimatorType estimator = anyEstimator;
  deckInit();
  estimator = deckGetRequiredEstimator();
  stabilizerInit(estimator);
  if (deckGetRequiredLowInterferenceRadioMode())
  {
    platformSetLowInterferenceRadioMode();
  }
  soundInit();
  memInit();

#ifdef PROXIMITY_ENABLED
  proximityInit();
#endif

  //Test the modules
  pass &= systemTest();
  pass &= configblockTest();
  pass &= commTest();
  pass &= commanderTest();
  pass &= stabilizerTest();
  pass &= deckTest();
  pass &= soundTest();
  pass &= memTest();
  pass &= watchdogNormalStartTest();

  //Start the firmware
  if(pass)
  {
    selftestPassed = 1;
    systemStart();
    soundSetEffect(SND_STARTUP);
    ledseqRun(SYS_LED, seq_alive);
    ledseqRun(LINK_LED, seq_testPassed);
  }
  else
  {
    selftestPassed = 0;
    if (systemTest())
    {
      while(1)
      {
        ledseqRun(SYS_LED, seq_testPassed); //Red passed == not passed!
        vTaskDelay(M2T(2000));
        // System can be forced to start by setting the param to 1 from the cfclient
        if (selftestPassed)
        {
	        DEBUG_PRINT("Start forced.\n");
          systemStart();
          break;
        }
      }
    }
    else
    {
      ledInit();
      ledSet(SYS_LED, true);
    }
  }
  DEBUG_PRINT("Free heap: %d bytes\n", xPortGetFreeHeapSize());

  workerLoop();

  //Should never reach this point!
  while(1)
    vTaskDelay(portMAX_DELAY);
}
Exemple #11
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;
}
initialiseModule(void) {
	return soundInit();
}
Exemple #13
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;
}
initialiseModule(void)
{
	// SoundPlugin>>#initialiseModule
	return soundInit();
}
void systemTask(void *arg)
{
  bool pass = true;

  ledInit();
  ledSet(CHG_LED, 1);

#ifdef DEBUG_QUEUE_MONITOR
  queueMonitorInit();
#endif

  uartInit();
#ifdef ENABLE_UART1
  uart1Init();
#endif
#ifdef ENABLE_UART2
  uart2Init();
#endif

  //Init the high-levels modules
  systemInit();

#ifndef USE_RADIOLINK_CRTP
#ifdef UART_OUTPUT_TRACE_DATA
  //debugInitTrace();
#endif
#ifdef ENABLE_UART
//  uartInit();
#endif
#endif //ndef USE_RADIOLINK_CRTP

  commInit();
  commanderAdvancedInit();
  stabilizerInit();
#ifdef PLATFORM_CF2
  deckInit();
  #endif
  soundInit();
  memInit();

#ifdef PROXIMITY_ENABLED
  proximityInit();
#endif

  //Test the modules
  pass &= systemTest();
  pass &= configblockTest();
  pass &= commTest();
  pass &= commanderAdvancedTest();
  pass &= stabilizerTest();
#ifdef PLATFORM_CF2
  pass &= deckTest();
  #endif
  pass &= soundTest();
  pass &= memTest();
  pass &= watchdogNormalStartTest();

  //Start the firmware
  if(pass)
  {
    selftestPassed = 1;
    systemStart();
    soundSetEffect(SND_STARTUP);
    ledseqRun(SYS_LED, seq_alive);
    ledseqRun(LINK_LED, seq_testPassed);
  }
  else
  {
    selftestPassed = 0;
    if (systemTest())
    {
      while(1)
      {
        ledseqRun(SYS_LED, seq_testPassed); //Red passed == not passed!
        vTaskDelay(M2T(2000));
        // System can be forced to start by setting the param to 1 from the cfclient
        if (selftestPassed)
        {
	        DEBUG_PRINT("Start forced.\n");
          systemStart();
          break;
        }
      }
    }
    else
    {
      ledInit();
      ledSet(SYS_LED, true);
    }
  }
  DEBUG_PRINT("Free heap: %d bytes\n", xPortGetFreeHeapSize());

  workerLoop();

  //Should never reach this point!
  while(1)
    vTaskDelay(portMAX_DELAY);
}
Exemple #16
0
EXPORT(sqInt) initialiseModule(void) {
	return soundInit();
}
Exemple #17
0
bool MainWnd::FileRun()
{
  // save battery file before we change the filename...
  if(rom != NULL || gbRom != NULL) {
    if(theApp.autoSaveLoadCheatList)
      winSaveCheatListDefault();
    writeBatteryFile();
    cheatSearchCleanup(&cheatSearchData);
    theApp.emulator.emuCleanUp();
    remoteCleanUp();
    emulating = false;
#ifdef APU_LOGGER_H
    end_apu_log();
#endif
  }
  char tempName[2048];
  char file[2048];
  CString oldFile = theApp.filename;

  utilStripDoubleExtension(theApp.szFile, tempName);

  _fullpath(file, tempName, 2048);
  theApp.filename = file;

  int index = theApp.filename.ReverseFind('.');
  if(index != -1)
    theApp.filename = theApp.filename.Left(index);

  if( theApp.filename != oldFile ) {
	  // clear cheat list when another game is loaded
	  cheatsDeleteAll( false );
	  gbCheatRemoveAll();
  }

  CString patchName;
  patchName.Format("%s.ips", theApp.filename);
  if( !fileExists( patchName ) ) {
	  patchName.Format("%s.ups", theApp.filename);
	  if( !fileExists( patchName ) ) {
		  patchName.Format("%s.ppf", theApp.filename);
		  if( !fileExists( patchName ) ) {
			  // don't use any patches
			  patchName.Empty();
		  }
	  }
  }


  if(!theApp.dir.GetLength()) {
    int index = theApp.filename.ReverseFind('\\');
    if(index != -1) {
      theApp.dir = theApp.filename.Left(index-1);
    }
  }

  IMAGE_TYPE type = utilFindType(theApp.szFile);

  if(type == IMAGE_UNKNOWN) {
    systemMessage(IDS_UNSUPPORTED_FILE_TYPE,
                  "Unsupported file type: %s", theApp.szFile);
    return false;
  }
  systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
  theApp.cartridgeType = type;
  if(type == IMAGE_GB) {
    if(!gbLoadRom(theApp.szFile))
      return false;

    gbGetHardwareType();

    // used for the handling of the gb Boot Rom
    if (gbHardware & 5)
    {
      skipBios = theApp.skipBiosFile;
	  gbCPUInit(theApp.biosFileNameGB, theApp.useBiosFileGB);
    }



    gbReset();
    theApp.emulator = GBSystem;
    gbBorderOn = theApp.winGbBorderOn;
    theApp.romSize = gbRomSize;


    if(theApp.autoPatch && !patchName.IsEmpty()) {
      int size = gbRomSize;
      applyPatch(patchName, &gbRom, &size);
      if(size != gbRomSize) {
        extern bool gbUpdateSizes();
        gbUpdateSizes();
        gbReset();
        theApp.romSize = size;
      }
    }
  } else {
    int size = CPULoadRom(theApp.szFile);
    if(!size)
      return false;

    theApp.romSize = size;

    flashSetSize(theApp.winFlashSize);
    rtcEnable(theApp.winRtcEnable);
    cpuSaveType = theApp.winSaveType;

    GetModuleFileName(NULL, tempName, 2048);

    char *p = strrchr(tempName, '\\');
    if(p)
      *p = 0;

    char buffer[5];
    strncpy(buffer, (const char *)&rom[0xac], 4);
    buffer[4] = 0;

    strcat(tempName, "\\vba-over.ini");

    UINT i = GetPrivateProfileInt(buffer,
					                "rtcEnabled",
                                  -1,
                                  tempName);
    if(i != (UINT)-1)
      rtcEnable(i == 0 ? false : true);

    i = GetPrivateProfileInt(buffer,
                             "flashSize",
                             -1,
                             tempName);
    if(i != (UINT)-1 && (i == 0x10000 || i == 0x20000))
      flashSetSize((int)i);

    i = GetPrivateProfileInt(buffer,
                             "saveType",
                             -1,
                             tempName);
    if(i != (UINT)-1 && (i <= 5))
      cpuSaveType = (int)i;
    i = GetPrivateProfileInt(buffer,
                             "mirroringEnabled",
                             -1,
                             tempName);
    if(i != (UINT)-1)
      doMirroring (i == 0 ? false : true);

    theApp.emulator = GBASystem;
    /* disabled due to problems
    if(theApp.removeIntros && rom != NULL) {
      *((u32 *)rom)= 0xea00002e;
    }
    */

    if(theApp.autoPatch && !patchName.IsEmpty()) {
      int size = 0x2000000;
      applyPatch(patchName, &rom, &size);
      if(size != 0x2000000) {
        CPUReset();
      }
    }
  }

  if(theApp.soundInitialized) {
    if(theApp.cartridgeType == 1)
      gbSoundReset();
    else
      soundReset();
  } else {
	  soundInit();
    theApp.soundInitialized = true;
  }

#ifdef APU_LOGGER_H
  begin_apu_log("apu_log.txt");
#endif

  if(type == IMAGE_GBA) {
    skipBios = theApp.skipBiosFile;
    CPUInit(theApp.biosFileNameGBA.GetString(), theApp.useBiosFileGBA);
    CPUReset();
  }

  readBatteryFile();

  if(theApp.autoSaveLoadCheatList)
    winLoadCheatListDefault();

  theApp.addRecentFile(theApp.szFile);

  theApp.updateWindowSize(theApp.videoOption);

  theApp.updateFrameSkip();

  emulating = true;

  if(theApp.autoLoadMostRecent)
    OnFileLoadgameMostrecent();

  theApp.frameskipadjust = 0;
  theApp.renderedFrames = 0;
  theApp.autoFrameSkipLastTime = systemGetClock();

  theApp.rewindCount = 0;
  theApp.rewindCounter = 0;
  theApp.rewindSaveNeeded = false;

  toolsClearLog();

  return true;
}