//==========================================================================
// The 'main' function for the booter. Called by boot0 when booting
// from a block device, or by the network booter.
//
// arguments:
//	 biosdev - Value passed from boot1/NBP to specify the device
//			   that the booter was loaded from.
//
// If biosdev is kBIOSDevNetwork, then this function will return if
// booting was unsuccessful. This allows the PXE firmware to try the
// next boot device on its list.
void common_boot(int biosdev)
{
	bool	 		quiet;
	bool	 		firstRun = true;
	bool	 		instantMenu;
	bool	 		rescanPrompt;
	char	 		*bootFile;
	int				status;
	unsigned int	allowBVFlags = kBVFlagSystemVolume | kBVFlagForeignBoot;
	unsigned int	denyBVFlags = kBVFlagEFISystem;
	unsigned long	adler32;
	
	// Set reminder to unload the PXE base code. Neglect to unload
	// the base code will result in a hang or kernel panic.
	gUnloadPXEOnExit = true;
	
	// Record the device that the booter was loaded from.
	gBIOSDev = biosdev & kBIOSDevMask;
	
	// Initialize boot info structure.
	initKernBootStruct();
	
	initBooterLog();
	
	// Setup VGA text mode.
	// Not sure if it is safe to call setVideoMode() before the
	// config table has been loaded. Call video_mode() instead.
#if DEBUG
	printf("before video_mode\n");
#endif
	video_mode( 2 );  // 80x25 mono text mode.
#if DEBUG
	printf("after video_mode\n");
#endif
	
	// Scan and record the system's hardware information.
	scan_platform();
	
	// First get info for boot volume.
	scanBootVolumes(gBIOSDev, 0);
	bvChain = getBVChainForBIOSDev(gBIOSDev);
	setBootGlobals(bvChain);
	
	// Load boot.plist config file
	status = loadChameleonConfig(&bootInfo->chameleonConfig);
	
	if (getBoolForKey(kQuietBootKey, &quiet, &bootInfo->chameleonConfig) && quiet) {
		gBootMode |= kBootModeQuiet;
	}
	
	// Override firstRun to get to the boot menu instantly by setting "Instant Menu"=y in system config
	if (getBoolForKey(kInstantMenuKey, &instantMenu, &bootInfo->chameleonConfig) && instantMenu) {
		firstRun = false;
	}
	
	// Loading preboot ramdisk if exists.
	loadPrebootRAMDisk();
	
	// Disable rescan option by default
	gEnableCDROMRescan = false;
	
	// Enable it with Rescan=y in system config
	if (getBoolForKey(kRescanKey, &gEnableCDROMRescan, &bootInfo->chameleonConfig)
		&& gEnableCDROMRescan) {
		gEnableCDROMRescan = true;
	}
	
	// Ask the user for Rescan option by setting "Rescan Prompt"=y in system config.
	rescanPrompt = false;
	if (getBoolForKey(kRescanPromptKey, &rescanPrompt , &bootInfo->chameleonConfig)
		&& rescanPrompt && biosDevIsCDROM(gBIOSDev))
	{
		gEnableCDROMRescan = promptForRescanOption();
	}
	
	// Enable touching a single BIOS device only if "Scan Single Drive"=y is set in system config.
	if (getBoolForKey(kScanSingleDriveKey, &gScanSingleDrive, &bootInfo->chameleonConfig)
		&& gScanSingleDrive) {
		gScanSingleDrive = true;
	}
	
	// Create a list of partitions on device(s).
	if (gScanSingleDrive) {
		scanBootVolumes(gBIOSDev, &bvCount);
	} else {
		scanDisks(gBIOSDev, &bvCount);
	}
	
	// Create a separated bvr chain using the specified filters.
	bvChain = newFilteredBVChain(0x80, 0xFF, allowBVFlags, denyBVFlags, &gDeviceCount);
	
	gBootVolume = selectBootVolume(bvChain);
	
	// Intialize module system 
	init_module_system();
		
#if DEBUG
	printf(" Default: %d, ->biosdev: %d, ->part_no: %d ->flags: %d\n",
			 gBootVolume, gBootVolume->biosdev, gBootVolume->part_no, gBootVolume->flags);
	printf(" bt(0,0): %d, ->biosdev: %d, ->part_no: %d ->flags: %d\n",
			 gBIOSBootVolume, gBIOSBootVolume->biosdev, gBIOSBootVolume->part_no, gBIOSBootVolume->flags);
	getchar();
#endif
	
	useGUI = true;
	// Override useGUI default
	getBoolForKey(kGUIKey, &useGUI, &bootInfo->chameleonConfig);
	if (useGUI && initGUI())
	{
		// initGUI() returned with an error, disabling GUI.
		useGUI = false;
	}
	
	setBootGlobals(bvChain);
	
	// Parse args, load and start kernel.
	while (1)
	{
		bool		tryresume, tryresumedefault, forceresume;
		bool		usecache = false;//true;
		const char	*val;
		int			len, trycache, ret = -1;
		long		flags, cachetime, kerneltime, exttime, sleeptime, time;
		void		*binary = (void *)kLoadAddr;
		
		// additional variable for testing alternate kernel image locations on boot helper partitions.
		char		bootFileSpec[512];
		
		// Initialize globals.
		sysConfigValid = false;
		gErrors		   = false;
		
		status = getBootOptions(firstRun);
		firstRun = false;
		if (status == -1) continue;
		 
		status = processBootOptions();
		// Status == 1 means to chainboot
		if ( status ==	1 ) break;
		// Status == -1 means that the config file couldn't be loaded or that gBootVolume is NULL
		if ( status == -1 )
		{
			// gBootVolume == NULL usually means the user hit escape.
			if (gBootVolume == NULL)
			{
				freeFilteredBVChain(bvChain);
				
				if (gEnableCDROMRescan)
					rescanBIOSDevice(gBIOSDev);
				
				bvChain = newFilteredBVChain(0x80, 0xFF, allowBVFlags, denyBVFlags, &gDeviceCount);
				setBootGlobals(bvChain);
				setupDeviceList(&bootInfo->themeConfig);
			}
			continue;
		}
		
		// Other status (e.g. 0) means that we should proceed with boot.
		
		// Turn off any GUI elements
		if ( bootArgs->Video.v_display == GRAPHICS_MODE )
		{
			gui.devicelist.draw = false;
			gui.bootprompt.draw = false;
			gui.menu.draw = false;
			gui.infobox.draw = false;
			gui.logo.draw = false;
			drawBackground();
			updateVRAM();
		}
		
		// Find out which version mac os we're booting.
		getOSVersion();
		
		if (platformCPUFeature(CPU_FEATURE_EM64T)) {
			archCpuType = CPU_TYPE_X86_64;
		} else {
			archCpuType = CPU_TYPE_I386;
		}
		
		if (getValueForKey(karch, &val, &len, &bootInfo->chameleonConfig)) {
			if (strncmp(val, "i386", 4) == 0) {
				archCpuType = CPU_TYPE_I386;
			}
		}
		
		if (getValueForKey(kKernelArchKey, &val, &len, &bootInfo->chameleonConfig)) {
			if (strncmp(val, "i386", 4) == 0) {
				archCpuType = CPU_TYPE_I386;
			}
		}
		
		// Notify modules that we are attempting to boot
		execute_hook("PreBoot", NULL, NULL, NULL, NULL);
		
		if (!getBoolForKey (kWake, &tryresume, &bootInfo->chameleonConfig)) {
			tryresume = true;
			tryresumedefault = true;
		} else {
			tryresumedefault = false;
		}
		
		if (!getBoolForKey (kForceWake, &forceresume, &bootInfo->chameleonConfig)) {
			forceresume = false;
		}
		
		if (forceresume) {
			tryresume = true;
			tryresumedefault = false;
		}
		
		while (tryresume) {
			const char *tmp;
			BVRef bvr;
			if (!getValueForKey(kWakeImage, &val, &len, &bootInfo->chameleonConfig))
				val = "/private/var/vm/sleepimage";
			
			// Do this first to be sure that root volume is mounted
			ret = GetFileInfo(0, val, &flags, &sleeptime);
			
			if ((bvr = getBootVolumeRef(val, &tmp)) == NULL)
				break;
			
			// Can't check if it was hibernation Wake=y is required
			if (bvr->modTime == 0 && tryresumedefault)
				break;
			
			if ((ret != 0) || ((flags & kFileTypeMask) != kFileTypeFlat))
				break;
			
			if (!forceresume && ((sleeptime+3)<bvr->modTime)) {
#if DEBUG	
				printf ("Hibernate image is too old by %d seconds. Use ForceWake=y to override\n",
						bvr->modTime-sleeptime);
#endif				  
				break;
			}
			
			HibernateBoot((char *)val);
			break;
		}
		
		getBoolForKey(kUseKernelCache, &usecache, &bootInfo->chameleonConfig);
		if (usecache) {
			if( getValueForKey(kKernelCacheKey, &val, &len, &bootInfo->chameleonConfig) || getValueForKey(kKernelCacheKey, &val, &len, &bootInfo->bootConfig) ) {
				if (val[0] == '\\')
				{
					len--;
					val++;
				}
				strlcpy(gBootKernelCacheFile, val, len + 1);
                verbose("Using kernel cache: \"%s\" \n", gBootKernelCacheFile);
                //sleep(5);
			}
			else {
				// Lion and Mountain Lion prelink kernel cache file␊
				if ((checkOSVersion("10.7")) || (checkOSVersion("10.8"))) {
					sprintf(gBootKernelCacheFile, "%skernelcache", kDefaultCachePathSnow);
				}
				// Snow Leopard
				else if (checkOSVersion("10.6")) {
					sprintf(gBootKernelCacheFile, "kernelcache_%s", (archCpuType == CPU_TYPE_I386)
							? "i386" : "x86_64");
					int lnam = sizeof(gBootKernelCacheFile) + 9; //with adler32
					
					char* name;
					long prev_time = 0;
					
					struct dirstuff* cacheDir = opendir(kDefaultCachePathSnow);
					
					while(readdir(cacheDir, (const char**)&name, &flags, &time) >= 0)
					{
						if (((flags & kFileTypeMask) != kFileTypeDirectory) && time > prev_time
							&& strstr(name, gBootKernelCacheFile) && (name[lnam] != '.'))
						{
							sprintf(gBootKernelCacheFile, "%s%s", kDefaultCachePathSnow, name);
							prev_time = time;
						}
					}
				}
				else {
					// Reset cache name.
					bzero(gCacheNameAdler + 64, sizeof(gCacheNameAdler) - 64);
					
					sprintf(gCacheNameAdler + 64, "%s,%s", gRootDevice, bootInfo->bootFile);
					
					adler32 = Adler32((unsigned char *)gCacheNameAdler, sizeof(gCacheNameAdler));
					
					sprintf(gBootKernelCacheFile, "%s.%08lX", kDefaultCachePathLeo, adler32);
				}
			}
		}
		
		// Check for cache file.
		trycache = (usecache && 
					((gBootMode & kBootModeSafe) == 0) &&
					!gOverrideKernel &&
					(gBootFileType == kBlockDeviceType) &&
					(gMKextName[0] == '\0') &&
					(gBootKernelCacheFile[0] != '\0'));
        
        verbose("trycache: %d\n", trycache);
		
		verbose("Loading Darwin %s\n", gMacOSVersion);
		
		if (trycache) do {
            verbose("bootInfo->bootFile: \"%s\" \n", bootInfo->bootFile);
			ret = GetFileInfo(NULL, bootInfo->bootFile, &flags, &kerneltime);
			if (ret != 0) kerneltime = 0;
			else if ((flags & kFileTypeMask) != kFileTypeFlat) {
				trycache = 0;
                verbose("trycache0 : 1\n");
				break;
			}
			
			ret = GetFileInfo(NULL, gBootKernelCacheFile, &flags, &cachetime);
			if ((ret != 0)) {
				trycache = 0;
                verbose("trycache0 : 2.1 \"%s\" \n", gBootKernelCacheFile);
				break;
			}
			else if ( ((flags & kFileTypeMask) != kFileTypeFlat) ) {
				trycache = 0;
                verbose("trycache0 : 2.2\n");
				break;
			}
			else if ( (cachetime < kerneltime) ) {
				trycache = 0;
                verbose("trycache0 : 2.3\n");
				break;
			}
			
			ret = GetFileInfo("/System/Library/", "Extensions", &flags, &exttime);
			if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeDirectory)
				&& (cachetime < exttime)) {
				trycache = 0;
                verbose("trycache0 : 3\n");
				break;
			}
			
			if (ret == 0 && kerneltime > exttime) {
				exttime = kerneltime;
			}
			
			if (ret == 0 && cachetime < (exttime + 1)) {
				trycache = 0;
                verbose("trycache0 : 4\n");
				break;
			}
		} while (0);

        // sleep(5);

		do {
			if (trycache) {
				bootFile = gBootKernelCacheFile;
				
				verbose("Loading kernel cache %s\n", bootFile);
				
				if ((checkOSVersion("10.7")) || (checkOSVersion("10.8"))) {
					ret = LoadThinFatFile(bootFile, &binary);
				}
				else {
					ret = LoadFile(bootFile);
					binary = (void *)kLoadAddr;
				}
				
				if (ret >= 0)
					break;
				
				verbose("Kernel cache did not load %s\n ", bootFile);
			}
			
			if ((checkOSVersion("10.7")) || (checkOSVersion("10.8"))) {
				bootFile = gBootKernelCacheFile;
			}
			else {
				sprintf(bootFile, "\%s", bootInfo->bootFile);
			}
			
			// Try to load kernel image from alternate locations on boot helper partitions.
			sprintf(bootFileSpec, "com.apple.boot.P%s", bootFile);
			ret = GetFileInfo(NULL, bootFileSpec, &flags, &time); 
			if (ret == -1)
			{
				sprintf(bootFileSpec, "com.apple.boot.R%s", bootFile);
				ret = GetFileInfo(NULL, bootFileSpec, &flags, &time); 
				if (ret == -1)
				{
					sprintf(bootFileSpec, "com.apple.boot.S%s", bootFile);
					ret = GetFileInfo(NULL, bootFileSpec, &flags, &time); 
					if (ret == -1)
					{
						// No alternate location found, using the original kernel image path.
						strcpy(bootFileSpec, bootInfo->bootFile);
					}
				}
			}
			
			if ((checkOSVersion("10.7")) || (checkOSVersion("10.8")))
			{
				//Lion, dont load kernel if haz cache
				if (!trycache) 
				{
					verbose("Loading kernel %s\n", bootFileSpec);
					ret = LoadThinFatFile(bootFileSpec, &binary);
					if (ret <= 0 && archCpuType == CPU_TYPE_X86_64) 
					{
						archCpuType = CPU_TYPE_I386;
						ret = LoadThinFatFile(bootFileSpec, &binary);				
					}
				} 
				else ret = 1;
			} 
			else 
			{
				//Snow Leopard or older
				verbose("Loading kernel %s\n", bootFileSpec);
				ret = LoadThinFatFile(bootFileSpec, &binary);
				if (ret <= 0 && archCpuType == CPU_TYPE_X86_64) 
				{
					archCpuType = CPU_TYPE_I386;
					ret = LoadThinFatFile(bootFileSpec, &binary);				
				}
			}
		} while (0);
		
		clearActivityIndicator();
		
#if DEBUG
		printf("Pausing...");
		sleep(8);
#endif
		
		if (ret <= 0) {
			printf("Can't find %s\n", bootFile);
			
			sleep(1);
			
			if (gBootFileType == kNetworkDeviceType) {
				// Return control back to PXE. Don't unload PXE base code.
				gUnloadPXEOnExit = false;
				break;
			}
		} else {
			/* Won't return if successful. */
			ret = ExecKernel(binary);
		}
	}
	
	// chainboot
	if (status == 1) {
		// if we are already in graphics-mode,
		if (getVideoMode() == GRAPHICS_MODE) {
			setVideoMode(VGA_TEXT_MODE, 0); // switch back to text mode.
		}
	}
	
	if ((gBootFileType == kNetworkDeviceType) && gUnloadPXEOnExit) {
		nbpUnloadBaseCode();
	}
}
Beispiel #2
0
void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event)
{
    // By default, load the first file into the text window.
    if (event.GetNumberOfFiles() > 0)
        LoadFile( event.GetFiles()[0] );
}
Beispiel #3
0
int GCMemROM(int size)
{
	bool biosError = false;

	ResetGameLoaded();

	CloseGame();
	GameInfo = new FCEUGI();
	memset(GameInfo, 0, sizeof(FCEUGI));

	GameInfo->filename = strdup(romFilename);
	GameInfo->archiveCount = 0;

	/*** Set some default values ***/
	GameInfo->name=0;
	GameInfo->type=GIT_CART;
	GameInfo->vidsys=(EGIV)GCSettings.timing;
	GameInfo->input[0]=GameInfo->input[1]=SI_UNSET;
	GameInfo->inputfc=SIFC_UNSET;
	GameInfo->cspecial=SIS_NONE;

	/*** Set internal sound information ***/
	SetSampleRate();
	FCEUI_SetSoundVolume(100); // 0-100
	FCEUI_SetLowPass(0);

	FCEUFILE * fceufp = new FCEUFILE();
	fceufp->size = size;
	fceufp->filename = romFilename;
	fceufp->mode = FCEUFILE::READ; // read only
	EMUFILE_MEMFILE *fceumem = new EMUFILE_MEMFILE(nesrom, size);
	fceufp->stream = fceumem;

	romLoaded = iNESLoad(romFilename, fceufp, 1);

	if(!romLoaded)
	{
		romLoaded = UNIFLoad(romFilename, fceufp);
	}

	if(!romLoaded)
	{
		romLoaded = NSFLoad(romFilename, fceufp);
	}

	if(!romLoaded)
	{
		// read FDS BIOS into FDSBIOS - should be 8192 bytes
		if (FDSBIOS[1] == 0)
		{
			size_t biosSize = 0;
			char * tmpbuffer = (char *) memalign(32, 64 * 1024);

			char filepath[1024];

			sprintf (filepath, "%s%s/disksys.rom", pathPrefix[GCSettings.LoadMethod], APPFOLDER);
			biosSize = LoadFile(tmpbuffer, filepath, 0, SILENT);
			if(biosSize == 0 && strlen(appPath) > 0)
			{
				sprintf (filepath, "%s/disksys.rom", appPath);
				biosSize = LoadFile(tmpbuffer, filepath, 0, SILENT);
			}

			if (biosSize == 8192)
			{
				memcpy(FDSBIOS, tmpbuffer, 8192);
			}
			else
			{
				biosError = true;

				if (biosSize > 0)
					ErrorPrompt("FDS BIOS file is invalid!");
				else
					ErrorPrompt("FDS BIOS file not found!");
			}
			free(tmpbuffer);
		}
		if (FDSBIOS[1] != 0)
		{
			romLoaded = FDSLoad(romFilename, fceufp);
		}
	}

	delete fceufp;

	if (romLoaded)
	{
		FCEU_ResetVidSys();

		if(GameInfo->type!=GIT_NSF)
			if(FSettings.GameGenie)
				OpenGameGenie();
		PowerNES();

		//if(GameInfo->type!=GIT_NSF)
		//	FCEU_LoadGamePalette();

		FCEU_ResetPalette();
		FCEU_ResetMessages();	// Save state, status messages, etc.
		SetupCheats();
		ResetAudio();
		return 1;
	}
	else
	{
		delete GameInfo;
		GameInfo = 0;

		if(!biosError)
			ErrorPrompt("Invalid game file!");
		romLoaded = false;
		return 0;
	}
}
Beispiel #4
0
void MYIniReadTools::SetFileName(char str[])
{
	strcpy(FileName,str);
	LoadFile();
}
Beispiel #5
0
int main_HInit(int argc, char *argv[])
{
   char *datafn, *s;
   int nSeg;
   void Initialise(void);
   void LoadFile(char *fn);
   void EstimateModel(void);
   void SaveModel(char *outfn);
   
   if(InitShell(argc,argv,hinit_version,hinit_vc_id)<SUCCESS)
      HError(2100,"HInit: InitShell failed");
   InitMem();   InitLabel();
   InitMath();  InitSigP();
   InitWave();  InitAudio();
   InitVQ();    InitModel();
   if(InitParm()<SUCCESS)  
      HError(2100,"HInit: InitParm failed");
   InitTrain(); InitUtil();

   if (!InfoPrinted() && NumArgs() == 0)
      ReportUsageHInit();
   if (NumArgs() == 0) return(0);
   SetConfParmsHInit();

   CreateHMMSet(&hset,&gstack,FALSE);
   while (NextArg() == SWITCHARG) {
      s = GetSwtArg();
      if (strlen(s)!=1) 
         HError(2119,"HInit: Bad switch %s; must be single letter",s);
      switch(s[0]){
      case 'e':
         epsilon = GetChkedFlt(0.0,1.0,s); break;
      case 'i':
         maxIter = GetChkedInt(0,100,s); break;
      case 'l':
         if (NextArg() != STRINGARG)
            HError(2119,"HInit: Segment label expected");
         segLab = GetStrArg();
         break;
      case 'm':
         minSeg = GetChkedInt(1,1000,s); break;
      case 'n':
         newModel = FALSE; break;
      case 'o':
         outfn = GetStrArg();
         break;
      case 'u':
         SetuFlags(); break;
      case 'v':
         minVar = GetChkedFlt(0.0,10.0,s); break;
      case 'w':
         mixWeightFloor = MINMIX * GetChkedFlt(0.0,10000.0,s); 
         break;
      case 'B':
         saveBinary = TRUE;
         break;
      case 'F':
         if (NextArg() != STRINGARG)
            HError(2119,"HInit: Data File format expected");
         if((dff = Str2Format(GetStrArg())) == ALIEN)
            HError(-2189,"HInit: Warning ALIEN Data file format set");
         break;
      case 'G':
         if (NextArg() != STRINGARG)
            HError(2119,"HInit: Label File format expected");
         if((lff = Str2Format(GetStrArg())) == ALIEN)
            HError(-2189,"HInit: Warning ALIEN Label file format set");
         break;
      case 'H':
         if (NextArg() != STRINGARG)
            HError(2119,"HInit: HMM macro file name expected");
         AddMMF(&hset,GetStrArg());
         break;
      case 'I':
         if (NextArg() != STRINGARG)
            HError(2119,"HInit: MLF file name expected");
         LoadMasterFile(GetStrArg());
         break;
      case 'L':
         if (NextArg()!=STRINGARG)
            HError(2119,"HInit: Label file directory expected");
         labDir = GetStrArg(); break;
      case 'M':
         if (NextArg()!=STRINGARG)
            HError(2119,"HInit: Output macro file directory expected");
         outDir = GetStrArg();
         break;
      case 'T':
         if (NextArg() != INTARG)
            HError(2119,"HInit: Trace value expected");
         trace = GetChkedInt(0,01777,s);
         break;
      case 'X':
         if (NextArg()!=STRINGARG)
            HError(2119,"HInit: Label file extension expected");
         labExt = GetStrArg(); break;
      default:
         HError(2119,"HInit: Unknown switch %s",s);
      }
   }
   if (NextArg()!=STRINGARG)
      HError(2119,"HInit: source HMM file name expected");
   hmmfn = GetStrArg();
   Initialise();
   do {
      if (NextArg()!=STRINGARG)
         HError(2119,"HInit: training data file name expected");
      datafn = GetStrArg();
      LoadFile(datafn);
   } while (NumArgs()>0);
   nSeg = NumSegs(segStore);
   if (nSeg < minSeg)
      HError(2121,"HInit: Too Few Observation Sequences [%d]",nSeg);
   if (trace&T_TOP) {
      printf("%d Observation Sequences Loaded\n",nSeg);
      fflush(stdout);
   }
   EstimateModel();
   SaveModel(outfn);
   if (trace&T_TOP)
      printf("Output written to directory %s\n",
             outDir==NULL?"current":outDir);
   return (0);          /* never reached -- make compiler happy */
}
bool C4GraphicsResource::Init()
{
	if (!RegisterGlobalGraphics())
		return false;
	// update group set
	if (!RegisterMainGroups())
	{
		LogFatal(LoadResStr("IDS_ERR_GFX_REGISTERMAIN"));
		return false;
	}

#ifndef USE_CONSOLE
	// Pre-load all shader files
	Files.PreCacheEntries(C4CFN_ShaderFiles);
	if (!pGL->InitShaders(&Files))
	{
		LogFatal(LoadResStr("IDS_ERR_GFX_INITSHADERS"));
		return false;
	}
#endif

	Game.SetInitProgress(11.0f);
	ProgressStart = 12.0f; ProgressIncrement = 0.35f; // TODO: This should be changed so that it stops at 25%, no matter how many graphics we load.
	// The progress bar is the only graphic besides the background that is
	// used during startup, so load it early
	if (!LoadFile(fctProgressBar, "GUIProgress", Files, C4FCT_Full, C4FCT_Full, false, 0)) return false;
	fctProgressBar.Set(fctProgressBar.Surface, 1,0, fctProgressBar.Wdt-2, fctProgressBar.Hgt);

	if (!InitFonts()) return false;

	// load GUI files
	if (!LoadFile(sfcCaption, "GUICaption", Files, idSfcCaption, 0)) return false;
	barCaption.SetHorizontal(sfcCaption, sfcCaption.Hgt, 32);
	if (!LoadFile(sfcButton, "GUIButton", Files, idSfcButton, 0)) return false;
	barButton.SetHorizontal(sfcButton);
	if (!LoadFile(sfcButtonD, "GUIButtonDown", Files, idSfcButtonD, 0)) return false;
	barButtonD.SetHorizontal(sfcButtonD);
	if (!LoadFile(fctButtonHighlight, "GUIButtonHighlight", Files, C4FCT_Full, C4FCT_Full, false, 0)) return false;
	if (!LoadFile(fctButtonHighlightRound, "GUIButtonHighlightRound", Files, C4FCT_Full, C4FCT_Full, false, 0)) return false;
	if (!LoadFile(fctIcons, "GUIIcons", Files, C4FCT_Full, C4FCT_Full, false, 0)) return false;
	fctIcons.Set(fctIcons.Surface,0,0,C4GUI_IconWdt,C4GUI_IconHgt);
	if (!LoadFile(fctIconsEx, "GUIIcons2", Files, C4FCT_Full, C4FCT_Full, false, 0)) return false;
	fctIconsEx.Set(fctIconsEx.Surface,0,0,C4GUI_IconExWdt,C4GUI_IconExHgt);
	if (!LoadFile(sfcScroll, "GUIScroll", Files, idSfcScroll, 0)) return false;
	sfctScroll.Set(C4Facet(&sfcScroll,0,0,32,32));
	if (!LoadFile(sfcContext, "GUIContext", Files, idSfcContext, 0)) return false;
	fctContext.Set(&sfcContext,0,0,16,16);
	if (!LoadFile(fctSubmenu, "GUISubmenu", Files, C4FCT_Full, C4FCT_Full, false, 0)) return false;
	if (!LoadFile(fctCheckbox, "GUICheckbox", Files, C4FCT_Full, C4FCT_Full, false, 0)) return false;
	fctCheckbox.Set(fctCheckbox.Surface, 0,0,fctCheckbox.Hgt,fctCheckbox.Hgt);
	if (!LoadFile(fctBigArrows, "GUIBigArrows", Files, C4FCT_Full, C4FCT_Full, false, 0)) return false;
	fctBigArrows.Set(fctBigArrows.Surface, 0,0, fctBigArrows.Wdt/4, fctBigArrows.Hgt);

	// Control
	if (!LoadFile(sfcControl, "Control", Files, idSfcControl, 0)) return false;
	fctKeyboard.Set(&sfcControl,0,0,80,36);
	fctCommand.Set(&sfcControl,0,36,32,32);
	fctKey.Set(&sfcControl,0,100,64,64);
	fctOKCancel.Set(&sfcControl,128,100,32,32);
	fctMouse.Set(&sfcControl,198,100,32,32);

	// Clonk style selection
	if (!LoadFile(sfcClonkSkins, "ClonkSkins",  Files, idSfcClonkSkins, 0)) return false;
	fctClonkSkin.Set(&sfcClonkSkins,0,0,64,64);

	// Facet bitmap resources
	if (!LoadFile(fctFire,        "Fire",         Files, C4FCT_Height, C4FCT_Full, false, 0))             return false;
	if (!LoadFile(fctBackground,  "Background",   Files, C4FCT_Full,   C4FCT_Full, false, C4SF_Tileable)) return false; // tileable
	if (!LoadFile(fctFlag,        "Flag",         Files, C4FCT_Full,   C4FCT_Full, false, 0))             return false; // (new format)
	if (!LoadFile(fctCrew,        "Crew",         Files, C4FCT_Full,   C4FCT_Full, false, 0))             return false; // (new format)
	if (!LoadFile(fctWealth,      "Wealth",       Files, C4FCT_Full,   C4FCT_Full, false, 0))             return false; // (new)
	if (!LoadFile(fctPlayer,      "Player",       Files, C4FCT_Full,   C4FCT_Full, false, 0))             return false; // (new format)
	if (!LoadFile(fctRank,        "Rank",         Files, C4FCT_Height, C4FCT_Full, false, 0))             return false;
	if (!LoadFile(fctCaptain,     "Captain",      Files, C4FCT_Full,   C4FCT_Full, false, 0))             return false;
	if (!LoadCursorGfx())                                                                                 return false;
	if (!LoadFile(fctSelectMark,  "SelectMark",   Files, C4FCT_Height, C4FCT_Full, false, 0))             return false;
	if (!LoadFile(fctMenu,        "Menu",         Files, 35,           35,         false, 0))             return false;
	if (!LoadFile(fctLogo,        "Logo",         Files, C4FCT_Full,   C4FCT_Full, false, 0))             return false;
	if (!LoadFile(fctConstruction,"Construction", Files, C4FCT_Full,   C4FCT_Full, false, 0))             return false; // (new)
	if (!LoadFile(fctEnergy,      "Energy",       Files, C4FCT_Full,   C4FCT_Full, false, 0))             return false; // (new)
	if (!LoadFile(fctOptions,     "Options",      Files, C4FCT_Height, C4FCT_Full, false, 0))             return false;
	if (!LoadFile(fctUpperBoard,  "UpperBoard",   Files, C4FCT_Full,   C4FCT_Full, false, C4SF_Tileable)) return false; // tileable
	if (!LoadFile(fctArrow,       "Arrow",        Files, C4FCT_Height, C4FCT_Full, false, 0))             return false;
	if (!LoadFile(fctExit,        "Exit",         Files, C4FCT_Full,   C4FCT_Full, false, 0))             return false;
	if (!LoadFile(fctHand,        "Hand",         Files, C4FCT_Height, C4FCT_Full, false, 0))             return false;
	if (!LoadFile(fctGamepad,     "Gamepad",      Files, 80,           C4FCT_Full, false, 0))             return false;
	if (!LoadFile(fctBuild,       "Build",        Files, C4FCT_Full,   C4FCT_Full, false, 0))             return false;

	// achievements
	if (!Achievements.Init(Files)) return false;

	// create ColorByOwner overlay surfaces
	if (fctCrew.idSourceGroup != fctCrewClr.idSourceGroup)
	{
		if (!fctCrewClr.CreateClrByOwner(fctCrew.Surface)) { LogFatal("ClrByOwner error! (1)"); return false; }
		fctCrewClr.Wdt=fctCrew.Wdt;
		fctCrewClr.Hgt=fctCrew.Hgt;
		fctCrewClr.idSourceGroup = fctCrew.idSourceGroup;
	}
	if (fctFlag.idSourceGroup != fctFlagClr.idSourceGroup)
	{
		if (!fctFlagClr.CreateClrByOwner(fctFlag.Surface)) { LogFatal("ClrByOwner error! (1)"); return false; }
		fctFlagClr.Wdt=fctFlag.Wdt;
		fctFlagClr.Hgt=fctFlag.Hgt;
		fctFlagClr.idSourceGroup = fctFlag.idSourceGroup;
	}
	if (fctPlayer.idSourceGroup != fctPlayerClr.idSourceGroup)
	{
		if (!fctPlayerClr.CreateClrByOwner(fctPlayer.Surface)) { LogFatal("ClrByOwner error! (1)"); return false; }
		fctPlayerClr.Wdt=fctPlayer.Wdt;
		fctPlayerClr.Hgt=fctPlayer.Hgt;
		fctPlayerClr.idSourceGroup = fctPlayer.idSourceGroup;
	}

	// get number of ranks
	int32_t Q; fctRank.GetPhaseNum(iNumRanks, Q);
	if (!iNumRanks) iNumRanks=1;

	// CloseFiles() must not be called now:
	// The sky still needs to be loaded from the global graphics
	// group in C4Game::InitGame -> C4Sky::Init so we need to keep the group(s) open.
	// In activated NETWORK2, the files mustn't be closed either, because there will be
	// multiple calls to this function to allow overloadings

	// mark initialized
	fInitialized = true;

	return true;
}
Beispiel #7
0
MYIniReadTools::MYIniReadTools(CString strPath)
{
	strcpy(FileName,strPath);
	LoadFile();
}
Beispiel #8
0
wxBitmap::wxBitmap(const wxString &filename, wxBitmapType type)
{
    LoadFile(filename, type);
}
void LoadSurfaceExtraFile( const char *path )
{
	char			srfPath[ 1024 ];
	surfaceExtra_t	*se;
	int				surfaceNum, size;
	byte			*buffer;
	
	
	/* dummy check */
	if( path == NULL || path[ 0 ] == '\0' )
		return;
	
	/* load the file */
	strcpy( srfPath, path );
	StripExtension( srfPath );
	strcat( srfPath, ".srf" );
	Sys_Printf( "Loading %s\n", srfPath );
	size = LoadFile( srfPath, (void**) &buffer );
	if( size <= 0 )
	{
		Sys_Printf( "WARNING: Unable to find surface file %s, using defaults.\n", srfPath );
		return;
	}
	
	/* parse the file */
	ParseFromMemory( buffer, size );
	
	/* tokenize it */
	while( 1 )
	{
		/* test for end of file */
		if( !GetToken( qtrue ) )
			break;
		
		/* default? */
		if( !Q_stricmp( token, "default" ) )
			se = &seDefault;

		/* surface number */
		else
		{
			surfaceNum = atoi( token );
			if( surfaceNum < 0 || surfaceNum > MAX_MAP_DRAW_SURFS )
				Error( "ReadSurfaceExtraFile(): %s, line %d: bogus surface num %d", srfPath, scriptline, surfaceNum );
			while( surfaceNum >= numSurfaceExtras )
				se = AllocSurfaceExtra();
			se = &surfaceExtras[ surfaceNum ];
		}
		
		/* handle { } section */
		if( !GetToken( qtrue ) || strcmp( token, "{" ) )
			Error( "ReadSurfaceExtraFile(): %s, line %d: { not found", srfPath, scriptline );
		while( 1 )
		{
			if( !GetToken( qtrue ) )
				break;
			if( !strcmp( token, "}" ) )
				break;
			
			/* shader */
			if( !Q_stricmp( token, "shader" ) )
			{
				GetToken( qfalse );
				se->si = ShaderInfoForShader( token );
			}
			
			/* parent surface number */
			else if( !Q_stricmp( token, "parent" ) )
			{
				GetToken( qfalse );
				se->parentSurfaceNum = atoi( token );
			}
			
			/* entity number */
			else if( !Q_stricmp( token, "entity" ) )
			{
				GetToken( qfalse );
				se->entityNum = atoi( token );
			}
			
			/* cast shadows */
			else if( !Q_stricmp( token, "castShadows" ) )
			{
				GetToken( qfalse );
				se->castShadows = atoi( token );
			}
			
			/* recv shadows */
			else if( !Q_stricmp( token, "receiveShadows" ) )
			{
				GetToken( qfalse );
				se->recvShadows = atoi( token );
			}
			
			/* lightmap sample size */
			else if( !Q_stricmp( token, "sampleSize" ) )
			{
				GetToken( qfalse );
				se->sampleSize = atoi( token );
			}
			
			/* longest curve */
			else if( !Q_stricmp( token, "longestCurve" ) )
			{
				GetToken( qfalse );
				se->longestCurve = atof( token );
			}
			
			/* lightmap axis vector */
			else if( !Q_stricmp( token, "lightmapAxis" ) )
				Parse1DMatrix( 3, se->lightmapAxis );
			
			/* ignore all other tokens on the line */
			while( TokenAvailable() )
				GetToken( qfalse );
		}
	}
	
	/* free the buffer */
	free( buffer );
}
Beispiel #10
0
t3DSParser::t3DSParser(const QString& filename)
: m_xFile()
, m_Header()
{
    LoadFile(filename);
}
Beispiel #11
0
sBool sTextControl::OnCommand(sU32 cmd)
{
  sInt s0,s1,len;
  sDiskItem *di;
  sChar buffer[sDI_PATHSIZE];
  sChar *t;

  s0 = sMin(SelPos,Cursor);
  s1 = sMax(SelPos,Cursor);
  len = s1-s0;

  switch(cmd)
  {
  case sTCC_CUT:
    if(SelMode && s0!=s1)
    {
      sGui->ClipboardClear();
      sGui->ClipboardAddText(Text+s0,len);
      Engine(s0,len,0);
      Post(DoneCmd);
      SelMode = 0;
      Cursor = s0;
    }
    return sTRUE;
  case sTCC_COPY:
    if(SelMode && s0!=s1)
    {
      sGui->ClipboardClear();
      sGui->ClipboardAddText(Text+s0,len);
      SelMode = 0;
    }
    return sTRUE;
  case sTCC_PASTE:
    t = sGui->ClipboardFindText();
    if(t && t[0])
    {
      Engine(Cursor,sGetStringLen(t),t);
      Cursor+=sGetStringLen(t);
      Post(DoneCmd);
    }
    return sTRUE;
  case sTCC_BLOCK:
    if(SelMode==0)
    {
      SelMode = 2;
      SelPos = Cursor;
    }
    else
    {
      SelMode = 0;
    }  
    return sTRUE;

  case 3:     // Cancel File Requester
    if(File)
    {
      File->Parent->RemChild(File);
      File = 0;
    }
    return sTRUE;
  case sTCC_OPEN:
    if(!File)
    {
      File = new sFileWindow;
      File->AddTitle("Open File");
      sGui->AddApp(File);
    }
    sGui->SetFocus(File);
    File->OkCmd = 4;
    File->CancelCmd = 3;
    File->SendTo = this;
    Modal = File;
    File->SetPath(PathName);
    return sTRUE;
  case 4:
    if(File)
    {
      File->GetPath(buffer,sizeof(buffer));
      OnCommand(3);
      if(!LoadFile(buffer))
      {
        SetText("");
        (new sDialogWindow)->InitOk(this,"Open File","Load failed",0);
      }
    }
    return sTRUE;

  case sTCC_CLEAR:
    SetText("");
    return sTRUE;      


  case sTCC_SAVEAS:
    if(!File)
    {
      File = new sFileWindow;
      File->AddTitle("Open File");
      sGui->AddApp(File);
    }
    sGui->SetFocus(File);
    File->OkCmd = 5;
    File->CancelCmd = 3;
    File->SendTo = this;
    Modal = File;
    File->SetPath(PathName);
    return sTRUE;
  case 5:
    if(File)
    {
      File->GetPath(PathName,sizeof(PathName));
      OnCommand(3);
      OnCommand(sTCC_SAVE);
    }
    return sTRUE;
  case sTCC_SAVE:
    di = sDiskRoot->Find(PathName,sDIF_CREATE);
    if(di)
    {
      len = sGetStringLen(Text);
      if(di->SetBinary(sDIA_DATA,(sU8 *)Text,len))
      {
        Post(CursorCmd);
        Changed = 0;
      }
      else
      {
        (new sDialogWindow)->InitOk(this,"Save File","Save failed",0);
      }
    }
    return sTRUE;

  default:
    return sFALSE;
  }
}
Beispiel #12
0
void boot(int biosdev)
{
    zeroBSS();
    mallocInit(0, 0, 0, mallocError);

#if MUST_ENABLE_A20
    // Enable A20 gate before accessing memory above 1 MB.
	if (fastEnableA20() != 0)
	{
		enableA20(); // Fast enable failed. Try legacy method.
	}
#endif

	bool	haveCABootPlist	= false;
    bool	quietBootMode	= true;

	void *binary = (void *)kLoadAddr;

	char bootFile[128];
	char rootUUID[37];

	char * kernelFlags = NULL;

	const char * val;

	int length	= 0;
	int kernelFlagsLength = 0;

	bootFile[0] = '\0';
	rootUUID[0] = '\0';

#if PRE_LINKED_KERNEL_SUPPORT
	bool	mayUseKernelCache	= false;

	long flags, cachetime;
#endif

	initPlatform(biosdev);	// Passing on the boot drive.

#if DEBUG_STATE_ENABLED
	// Don't switch graphics mode / show boot logo when DEBUG is set to 1.
	printf("\ngArchCPUType (CPU): %s\n", (gArchCPUType == CPU_TYPE_X86_64) ? "x86_64" : "i386");
	sleep(1); // Silent sleep.
#else
	showBootLogo();
#endif

	initPartitionChain();

	#define loadCABootPlist() loadSystemConfig(&bootInfo->bootConfig)

	// Loading: /Library/Preferences/SystemConfiguration/com.apple.Boot.plist
	// TODO: Check if everything works <i>without</i> having this plist.
	if (loadCABootPlist() == STATE_SUCCESS)
	{
		_BOOT_DEBUG_DUMP("com.apple.Boot.plist located.\n");

		// Load successful. Change state accordantly.
		haveCABootPlist = true;	// Checked <i>before</i> calling key functions.

		// Check the value of <key>Kernel Flags</key> for stuff we are interested in.
		// Note: We need to know about: arch= and the boot flags: -s, -v, -f and -x
		if (getValueForKey(kKernelFlagsKey, &val, &kernelFlagsLength, &bootInfo->bootConfig))
		{
			// Got it. Do we have anything to work with?
			if (kernelFlagsLength)
			{
				kernelFlagsLength++;

				// Yes. Allocate memory for it and copy the kernel flags into it.
				kernelFlags = malloc(kernelFlagsLength);
				strlcpy(kernelFlags, val, kernelFlagsLength);

				// Is 'arch=<i386/x86_64>' specified as kernel flag?
				if (getValueForBootKey((const char *)kernelFlags, "arch", &val, &length)) //  && len >= 4)
				{
					gArchCPUType = (strncmp(val, "x86_64", 6) == 0) ? CPU_TYPE_X86_64 : CPU_TYPE_I386;

					_BOOT_DEBUG_DUMP("gArchCPUType (c.a.B.plist): %s\n",  (gArchCPUType == CPU_TYPE_X86_64) ? "x86_64" : "i386");
				}
				
				// Check for -v (verbose) and -s (single user mode) flags.
				gVerboseMode =	getValueForBootKey((const char *)kernelFlags, kVerboseModeFlag, &val, &length) || 
								getValueForBootKey((const char *)kernelFlags, kSingleUserModeFlag, &val, &length);
				
				if (gVerboseMode)
				{
#if DEBUG_BOOT == false
					setVideoMode(VGA_TEXT_MODE);
#endif
				}

				// Check for -x (safe) and -f (flush cache) flags.
				if (getValueForBootKey((const char *)kernelFlags, kSafeModeFlag, &val, &length) || 
					getValueForBootKey((const char *)kernelFlags, kIgnoreCachesFlag, &val, &length))
				{
					gBootMode = kBootModeSafe;
				}

				// Is 'boot-uuid=<value>' specified as kernel flag?
				if (getValueForBootKey((const char *)kernelFlags, kBootUUIDKey, &val, &length) && length == 36)
				{
					// Yes. Copy its value into rootUUID.
					strlcpy(rootUUID, val, 37);
				}
			}
		}

		/* Enable touching of a single BIOS device by setting 'Scan Single Drive' to yes.
		if (getBoolForKey(kScanSingleDriveKey, &gScanSingleDrive, &bootInfo->bootConfig) && gScanSingleDrive)
		{
			gScanSingleDrive = true;
		} */
	}
	else
	{
		_BOOT_DEBUG_DUMP("No com.apple.Boot.plist found.\n");
	}
	
	// Was a target drive (per UUID) specified in com.apple.Boot.plist?
	if (rootUUID[0] == '\0')
	{
		_BOOT_DEBUG_DUMP("No UUID specified in com.apple.Boot.plist\n");

		// No, so are we booting from a System Volume?
		if (gPlatform.BootVolume->flags & kBVFlagSystemVolume)
		{
			_BOOT_DEBUG_DUMP("Booting from a System Volume, getting UUID.\n");

			// Yes, then let's get the UUID.
			if (HFSGetUUID(gPlatform.BootVolume, rootUUID) == STATE_SUCCESS)
			{
				_BOOT_DEBUG_DUMP("Success [%s]\n", rootUUID);
			}
		}
		else // Booting from USB-stick or SDboot media.
		{
			_BOOT_DEBUG_DUMP("Booting from a Non System Volume, getting UUID.\n");

			// Get target System Volume and UUID in one go.
			BVRef rootVolume = getTargetRootVolume(rootUUID);

			if (rootVolume)
			{
				_BOOT_DEBUG_DUMP("Success [%s]\n", rootUUID);

				// gPlatform.RootVolume = rootVolume;
			}
		}

		// This should never happen, but just to be sure.
		if (rootUUID[0] == '\0')
		{
			_BOOT_DEBUG_DUMP("Failed to get UUID for System Volume.\n");

			if (!gVerboseMode)
			{
				// Force verbose mode when we didn't find a UUID, so 
				// that people see what is going on in times of trouble.
				gVerboseMode = true;
			}
		}
	}

	/*
	 * At this stage we know exactly what boot mode we're in, and which disk to boot from
	 * any of which may or may not have been set/changed (in com.apple.Boot.plist) into a 
	 * non-default system setting and thus is this the place to update our EFI tree.
	 */

    updateEFITree(rootUUID);

	if (haveCABootPlist) // Check boolean before doing more time consuming tasks.
	{
		if (getBoolForKey(kQuietBootKey, &quietBootMode, &bootInfo->bootConfig) && !quietBootMode)
		{
			gBootMode = kBootModeNormal; // Reversed from: gBootMode |= kBootModeQuiet;
		}
	}

    // Parse args, load and start kernel.
    while (1)
    {
        // Initialize globals.

        sysConfigValid = 0;
        gErrors        = 0;

		int retStatus = -1;

		getAndProcessBootArguments(kernelFlags);

		// Initialize bootFile (defaults to: mach_kernel).
		strcpy(bootFile, bootInfo->bootFile);

#if PRE_LINKED_KERNEL_SUPPORT

		// Preliminary checks to prevent us from doing useless things.
        mayUseKernelCache = ((gBootMode & kBootModeSafe) == 0);
		
		/* 
		 * A pre-linked kernel, or kernelcache, requires you to have all essential kexts for your
		 * configuration, including FakeSMC.kext in: /System/Library/Extensions/ 
		 * Not in /Extra/Extensions/ because this directory will be ignored, completely when a 
		 * pre-linked kernel or kernelcache is used!
		 *
		 * Note: Not following this word of advise will render your system incapable of booting!
		 */
		
		if (mayUseKernelCache)
		{
			_BOOT_DEBUG_DUMP("Kernelcache path: %s\n", gPlatform.KernelCachePath);

			/*
			 * We might have been fired up from a USB thumbdrive (kickstart boot) and 
			 * thus we have to check the kernel cache path first (might not be there).
			 */

			if (GetFileInfo(NULL, gPlatform.KernelCachePath, &flags, &cachetime) == 0)
			{
#if ((MAKE_TARGET_OS & LION) == LION) // Also for Mountain Lion, which has bit 2 set like Lion.

				_BOOT_DEBUG_DUMP("Checking for kernelcache...\n");

				// Do we have a kernelcache to work with?
				if (GetFileInfo(gPlatform.KernelCachePath, (char *)kKernelCache, &flags, &cachetime) == 0)
				{
					/*
					 * Starting with Lion, we can take a shortcut by simply pointing 
					 * the 'bootFile' to the kernel cache and we are done.
					 */
					
					sprintf(bootFile, "%s/%s", gPlatform.KernelCachePath, kKernelCache);

					_BOOT_DEBUG_DUMP("Kernelcache found.\n");
				}

				_BOOT_DEBUG_ELSE_DUMP("Failed to locate the kernelcache. Will load: %s!\n", bootInfo->bootFile);
			}

			_BOOT_DEBUG_ELSE_DUMP("Failed to locate the cache directory!\n");
		}
#else // Not for Lion, go easy with the Snow Leopard.

				static char preLinkedKernelPath[128];
				static char adler32Key[PLATFORM_NAME_LEN + ROOT_PATH_LEN];

				unsigned long adler32 = 0;

				preLinkedKernelPath[0] = '\0';

				_BOOT_DEBUG_DUMP("Checking for pre-linked kernel...\n");

				// Zero out platform info (name and kernel root path).
				bzero(adler32Key, sizeof(adler32Key));
				
				// Construct key for the pre-linked kernel checksum (generated by adler32). 
				sprintf(adler32Key, gPlatform.ModelID);
				sprintf(adler32Key + PLATFORM_NAME_LEN, "%s", BOOT_DEVICE_PATH);
				sprintf(adler32Key + (PLATFORM_NAME_LEN + 38), "%s", bootInfo->bootFile);
				
				adler32 = Adler32((unsigned char *)adler32Key, sizeof(adler32Key));
				
				_BOOT_DEBUG_DUMP("adler32: %08X\n", adler32);
				
				// Create path to pre-linked kernel.
				sprintf(preLinkedKernelPath, "%s/%s_%s.%08lX", gPlatform.KernelCachePath, kKernelCache, 
						((gArchCPUType == CPU_TYPE_X86_64) ? "x86_64" : "i386"), adler32);

				// Check if this file exists.
				if ((GetFileInfo(NULL, preLinkedKernelPath, &flags, &cachetime) == 0) && ((flags & kFileTypeMask) == kFileTypeFlat))
				{
					_BOOT_DEBUG_DUMP("Pre-linked kernel cache located!\nLoading pre-linked kernel: %s\n", preLinkedKernelPath);
					
					// Returns -1 on error, or the actual filesize.
					if (LoadFile((const char *)preLinkedKernelPath))
					{
						retStatus = 1;
						binary = (void *)kLoadAddr;
						bootFile[0] = 0;
					}

					_BOOT_DEBUG_ELSE_DUMP("Failed to load the pre-linked kernel. Will load: %s!\n", bootInfo->bootFile);
				}

				_BOOT_DEBUG_ELSE_DUMP("Failed to locate the pre-linked kernel!\n");
			}

			_BOOT_DEBUG_ELSE_DUMP("Failed to locate the cache directory!\n");
		}
Beispiel #13
0
/** \fn     GalleryWidget::keyPressEvent(QKeyEvent *)
 *  \brief  Translates the keypresses and keys bound to the
 *          plugin to specific actions within the plugin
 *  \param  event The pressed key
 *  \return True if key was used, otherwise false
 */
bool GalleryWidget::keyPressEvent(QKeyEvent *event)
{
    if (GetFocusWidget()->keyPressEvent(event))
        return true;

    bool handled = false;
    QStringList actions;
    handled = GetMythMainWindow()->TranslateKeyPress("Images", event, actions);

    for (int i = 0; i < actions.size() && !handled; i++)
    {
        QString action = actions[i];
        handled = true;

        if (action == "LEFT")
            ShowPrevFile();
        else if (action == "RIGHT")
            ShowNextFile();
        else if (action == "INFO")
            ShowFileDetails();
        else if (action == "MENU")
            MenuMain();
        else if (action == "PLAY")
        {
            // If no slideshow is active and the user presses the play
            // button then start a normal slideshow. But if a slideshow
            // is already running then start or pause it.
            if (m_slideShowType == kNoSlideShow)
                StartNormalSlideShow();
            else
            {
                if (m_timer->isActive())
                    PauseSlideShow();
                else
                    ResumeSlideShow();
            }
        }
        else if (action == "PAUSE")
            PauseSlideShow();
        else if (action == "STOP")
            StopSlideShow();
        else if (action == "ROTRIGHT")
        {
            m_gvh->SetFileOrientation(kFileRotateCW);
            LoadFile();
        }
        else if (action == "ROTLEFT")
        {
            m_gvh->SetFileOrientation(kFileRotateCCW);
            LoadFile();
        }
        else if (action == "FLIPHORIZONTAL")
        {
            m_gvh->SetFileOrientation(kFileFlipHorizontal);
            LoadFile();
        }
        else if (action == "FLIPVERTICAL")
        {
            m_gvh->SetFileOrientation(kFileFlipVertical);
            LoadFile();
        }
        else if (action == "ZOOMIN")
        {
            m_gvh->SetFileZoom(kFileZoomIn);
            LoadFile();
        }
        else if (action == "ZOOMOUT")
        {
            m_gvh->SetFileZoom(kFileZoomOut);
            LoadFile();
        }
        else if (action == "ESCAPE")
        {
            if (m_infoVisible)
                HideFileDetails();
            else
                handled = false;
        }
    }

    if (!handled && MythScreenType::keyPressEvent(event))
        handled = true;

    return handled;
}
Beispiel #14
0
/*
============
main
============
*/
int main (int argc, char **argv)
{
	const char	*psrc;
	void		*src, *src2;
	char	filename[1024];
	int		p, c;
	unsigned short		crc;
	double	start, stop;
	FILE	*f;

	myargc = argc;
	myargv = argv;

	if (CheckParm("-?") || CheckParm("-h") || CheckParm("-help") || CheckParm("--help"))
	{
		printf(" Compiles progs.dat using progs.src in the current directory\n");
		printf(" -src <directory> : Specify source directory\n");
		printf(" -dcc : decompile the progs.dat in the current directory\n");
		printf(" -dcc -fix : fixes mangled names during decompilation\n");
		printf(" -dcc -asm <functionname> : decompile filename to the console\n");
		printf(" -dcc -dump -asm <functionname> : same as above but will show\n\t\tinstructions (opcodes and parms) as well\n");
		exit(0);
	}

	ValidateByteorder ();

	start = GetTime ();

	p = CheckParm("-src");
	if (p && p < argc-1)
	{
		strcpy(sourcedir, argv[p+1]);
		strcat(sourcedir, "/");
		printf("Source directory: %s\n", sourcedir);
	}
	else
	{
		sourcedir[0] = '\0';
	}

	InitData ();

	PR_FILE = stdout;

	p = CheckParm("-dump");
	if (p)
		pr_dumpasm = true;

	// do a crc of the file
	p = CheckParm("-crc");
	if (p)
	{
		CRC_Init (&crc);
		f = fopen ("progdefs.h", "r");
		while ((c = fgetc(f)) != EOF)
			CRC_ProcessByte (&crc, (byte)c);

		printf ("#define PROGHEADER_CRC %i %d\n", crc, (int)crc);
		fclose (f);
		exit (0);
	}

	p = CheckParm("-dcc");
	if (p)
	{
		DEC_ReadData ("progs.dat");
		//fix mangled names if asked
		p = CheckParm ("-fix");
		if (p)
			FILE_NUM_FOR_NAME = 1;

		memset(func_headers, 0, MAX_FUNCTIONS * sizeof(char *));
		memset(temp_val, 0, MAX_REGS * sizeof(char *));

		p = CheckParm("-bbb");
		if (p)
		{
		/*	i= -999;
			for (p = 0; p < numstatements; p++)
				if ((statements+p)->op > i)
					i = (statements+p)->op;
			printf("largest op %d\n", i); */
			FindBuiltinParameters(1);

			exit (0);
		}

		p = CheckParm("-ddd");
		if (p)
		{
			for (p++ ; p < argc ; p++)
			{
				if (argv[p][0] == '-')
					break;
				DccFunctionOP (atoi(argv[p]));
			}
			exit (0);
		}

		p = CheckParm("-info2");
		if (p)
		{
			printf("\n=======================\n");
			printf("fields\n");
			printf("=======================\n");
			PrintFields ();
			printf("\n=======================\n");
			printf("globals\n");
			printf("=======================\n");
			PrintGlobals ();
			exit (0);
		}

		p = CheckParm("-info");
		if (p)
		{
			printf("\n=======================\n");
			printf("strings\n");
			printf("=======================\n");
			PrintStrings ();
			printf("\n=======================\n");
			printf("functions");
			printf("\n=======================\n");
			PrintFunctions ();
			printf("\n=======================\n");
			printf("fields\n");
			printf("=======================\n");
			PrintFields ();
			printf("\n=======================\n");
			printf("globals\n");
			printf("=======================\n");
			PrintGlobals ();
			printf("\n=======================\n");
			printf("pr_globals\n");
			printf("=======================\n");
			PrintPRGlobals ();
			printf("\n=======================\n");
			printf("statements\n");
			printf("=======================\n");
			Printstatements();
			exit (0);
		}

		p = CheckParm("-asm");
		if (p)
		{
			for (p++; p < argc; p++)
			{
				if (argv[p][0] == '-')
					break;
				PR_PrintFunction(argv[p]);
			}
		}
		else
		{
			Dcc_Functions ();
			stop = GetTime ();
			printf("\n%d seconds elapsed.\n", (int)(stop-start));
		}

		exit (0);
	}

	sprintf(filename, "%sprogs.src", sourcedir);
	LoadFile(filename, &src);
	psrc = (char *) src;

	psrc = COM_Parse(psrc);
	if (!psrc)
	{
		Error("No destination filename.  HCC -help for info.\n");
	}

	strcpy(destfile, com_token);
	printf("outputfile: %s\n", destfile);

	pr_dumpasm = false;

	PR_BeginCompilation();

	// compile all the files
	do
	{
		psrc = COM_Parse(psrc);
		if (!psrc)
			break;

		sprintf (filename, "%s%s", sourcedir, com_token);
		printf ("compiling %s\n", filename);
		LoadFile (filename, &src2);

		if (!PR_CompileFile((char *)src2, filename))
			exit (1);

	} while (1);

	if (!PR_FinishCompilation())
	{
		Error ("compilation errors");
	}

	p = CheckParm("-asm");
	if (p)
	{
		for (p++; p < argc; p++)
		{
			if (argv[p][0] == '-')
			{
				break;
			}
			PrintFunction(argv[p]);
		}
	}

	// write progdefs.h
	crc = PR_WriteProgdefs("progdefs.h");
//	crc = 14046;	// FIXME: cheap hack for now!!!!!!!!!!!!!

	// write data file
	WriteData(crc);

	// write files.dat
	WriteFiles();

	stop = GetTime ();
	printf("\n%d seconds elapsed.\n", (int)(stop-start));

	exit (0);
}
void Musicplayer::LoadCurrentFile()
{
	LoadFile(CurrentFileName->c_str());
}
Beispiel #16
0
bool PSP_Init(const CoreParameter &coreParam, std::string *error_string)
{
	INFO_LOG(HLE, "PPSSPP %s", PPSSPP_GIT_VERSION);

	coreParameter = coreParam;
	currentCPU = &mipsr4k;
	numCPUs = 1;

	// Default memory settings
	// Seems to be the safest place currently..
	Memory::g_MemorySize = 0x2000000; // 32 MB of ram by default
	g_RemasterMode = false;
	g_DoubleTextureCoordinates = false;

	std::string filename = coreParam.fileToStart;
	EmuFileType type = Identify_File(filename);

	if(type == FILETYPE_PSP_ISO || type == FILETYPE_PSP_ISO_NP || type == FILETYPE_PSP_DISC_DIRECTORY)
		InitMemoryForGameISO(filename);

	Memory::Init();
	mipsr4k.Reset();
	mipsr4k.pc = 0;

	host->AttemptLoadSymbolMap();

	if (coreParameter.enableSound)
	{
		mixer = new PSPMixer();
		host->InitSound(mixer);
	}

	if (coreParameter.disableG3Dlog)
	{
		LogManager::GetInstance()->SetEnable(LogTypes::G3D, false);
	}

	CoreTiming::Init();

	// Init all the HLE modules
	HLEInit();

	// TODO: Check Game INI here for settings, patches and cheats, and modify coreParameter accordingly

	// Why did we check for CORE_POWERDOWN here?
	if (!LoadFile(filename, error_string)) { // || coreState == CORE_POWERDOWN) {
		pspFileSystem.Shutdown();
		CoreTiming::Shutdown();
		__KernelShutdown();
		HLEShutdown();
		host->ShutdownSound();
		Memory::Shutdown();
		coreParameter.fileToStart = "";
		return false;
	}

	if (coreParam.updateRecent)
		g_Config.AddRecent(filename);

	// Setup JIT here.
	if (coreParameter.startPaused)
		coreState = CORE_STEPPING;
	else
		coreState = CORE_RUNNING;
	return true;
}
Beispiel #17
0
void Model::GenerateToolPath()
{
	unsigned int numItems = m_levels.size() * NUM_DEGREE;
	Buffer outputBuffer, modelBuffer;

	modelBuffer = m_computeSystem->CreateBuffer(m_levels.data(), numItems, sizeof(float));
	outputBuffer = m_computeSystem->CreateBuffer(nullptr, numItems, sizeof(Vector4));

	m_generateToolPathShader->ClearBuffers();
	m_generateToolPathShader->AddBuffer(modelBuffer);
	m_generateToolPathShader->AddBuffer(outputBuffer);

	float levelHeight = 0.1f;
	float numDegree = NUM_DEGREE;

	m_computeSystem->SetFloatAttrib(m_generateToolPathShader, "levelHeight", &levelHeight, 1);
	m_computeSystem->SetFloatAttrib(m_generateToolPathShader, "numDegree", &numDegree, 1);

	m_generateToolPathShader->SetComputeSize(NUM_DEGREE, m_levels.size(), 1);
	m_generateToolPathShader->SetGroupSize(1, 1, 1);

	m_computeSystem->DispatchCompute(m_generateToolPathShader);	

	outputBuffer = m_generateToolPathShader->GetBuffer(1);
	Vector4* data = m_computeSystem->GetValues<Vector4>(outputBuffer);

	/*for (unsigned int i = 0; i < numItems; ++i)
	{
		Log::Info("Index[" + std::to_string(i) + "] " + std::to_string(data[i].y));
	}*/

	Buffer vertexBuffer, indexBuffer;
	unsigned int numVerts = numItems * 4;
	unsigned int numInds = numItems * 6;

	vertexBuffer = m_computeSystem->CreateBuffer(nullptr, numVerts, sizeof(Vector4));
	indexBuffer = m_computeSystem->CreateBuffer(nullptr, numInds, sizeof(unsigned int));

	m_buildToolPathVertsShader->ClearBuffers();
	m_buildToolPathVertsShader->AddBuffer(outputBuffer);
	m_buildToolPathVertsShader->AddBuffer(vertexBuffer);
	m_buildToolPathVertsShader->AddBuffer(indexBuffer);

	m_buildToolPathVertsShader->SetComputeSize(NUM_DEGREE, m_levels.size(), 1);
	m_buildToolPathVertsShader->SetGroupSize(1, 1, 1);

	m_computeSystem->DispatchCompute(m_buildToolPathVertsShader);
	
	Buffer vb = m_buildToolPathVertsShader->GetBuffer(1);
	Vector4* vd = m_computeSystem->GetValues<Vector4>(vb);

	Buffer ib = m_buildToolPathVertsShader->GetBuffer(2);
	unsigned int* id = m_computeSystem->GetValues<unsigned int>(ib);

	/*for (unsigned int i = 0; i < numVerts; ++i)
	{
	Log::Info("Index[" + std::to_string(i) + "] " + std::to_string(vd[i].x) + ", " + std::to_string(vd[i].y) + ", " + std::to_string(vd[i].z));
	}*/

	m_toolPathRO = m_renderer->CreateRenderObject(vd, numVerts, id, numInds, LoadFile(RESOURCE_PATH + "vs.vs"), LoadFile(RESOURCE_PATH + "fs.fs"));

	m_computeSystem->ReleaseBuffer(&modelBuffer);
	m_computeSystem->ReleaseBuffer(&outputBuffer);
}
Beispiel #18
0
VSTPresets::ErrorCode VSTPresets::LoadFile(FileReader &file, CVstPlugin &plugin)
//------------------------------------------------------------------------------
{
	const bool firstChunk = file.GetPosition() == 0;
	ChunkHeader header;
	if(!file.ReadConvertEndianness(header) || header.chunkMagic != cMagic)
	{
		return invalidFile;
	}
	if(header.fxID != plugin.GetUID())
	{
		return wrongPlugin;
	}

	if(header.fxMagic == fMagic || header.fxMagic == chunkPresetMagic)
	{
		// Program
		PlugParamIndex numParams = file.ReadUint32BE();

		VstPatchChunkInfo info;
		info.version = 1;
		info.pluginUniqueID = header.fxID;
		info.pluginVersion = header.fxVersion;
		info.numElements = numParams;
		MemsetZero(info.future);
		plugin.Dispatch(effBeginLoadProgram, 0, 0, &info, 0.0f);
		plugin.Dispatch(effBeginSetProgram, 0, 0, nullptr, 0.0f);

		char prgName[28];
		file.ReadString<mpt::String::maybeNullTerminated>(prgName, 28);
		plugin.Dispatch(effSetProgramName, 0, 0, prgName, 0.0f);

		if(header.fxMagic == fMagic)
		{
			if(plugin.GetNumParameters() != numParams)
			{
				return wrongParameters;
			}
			for(PlugParamIndex p = 0; p < numParams; p++)
			{
				plugin.SetParameter(p, file.ReadFloatBE());
			}
		} else
		{
			FileReader chunk = file.ReadChunk(file.ReadUint32BE());
			plugin.Dispatch(effSetChunk, 1, chunk.GetLength(), const_cast<char *>(chunk.GetRawData()), 0);
		}
		plugin.Dispatch(effEndSetProgram, 0, 0, nullptr, 0.0f);
	} else if((header.fxMagic == bankMagic || header.fxMagic == chunkBankMagic) && firstChunk)
	{
		// Bank - only read if it's the first chunk in the file, not if it's a sub chunk.
		uint32 numProgs = file.ReadUint32BE();
		uint32 currentProgram = file.ReadUint32BE();
		file.Skip(124);

		VstPatchChunkInfo info;
		info.version = 1;
		info.pluginUniqueID = header.fxID;
		info.pluginVersion = header.fxVersion;
		info.numElements = numProgs;
		MemsetZero(info.future);
		plugin.Dispatch(effBeginLoadBank, 0, 0, &info, 0.0f);

		if(header.fxMagic == bankMagic)
		{
			VstInt32 oldCurrentProgram = plugin.GetCurrentProgram();
			for(uint32 p = 0; p < numProgs; p++)
			{
				plugin.Dispatch(effBeginSetProgram, 0, 0, nullptr, 0.0f);
				plugin.Dispatch(effSetProgram, 0, 0, nullptr, 0.0f);
				ErrorCode retVal = LoadFile(file, plugin);
				if(retVal != noError)
				{
					return retVal;
				}
				plugin.Dispatch(effEndSetProgram, 0, 0, nullptr, 0.0f);
			}
			plugin.SetCurrentProgram(oldCurrentProgram);
		} else
		{
			FileReader chunk = file.ReadChunk(file.ReadUint32BE());
			plugin.Dispatch(effSetChunk, 0, chunk.GetLength(), const_cast<char *>(chunk.GetRawData()), 0);
		}
		if(header.version >= 2)
		{
			plugin.SetCurrentProgram(currentProgram);
		}
	}

	return noError;
}
Beispiel #19
0
void SampleDisplayFileContent(const char* fileName)
{
	char content[16] = { 0 };
	LoadFile(fileName, content);
	Print("Content: '%s'\n", content);
}
Beispiel #20
0
bool LoadSound(const char* filename, bool sfxr)
{
    auto it = sound_files.find(filename);
    Sound snd;

    if (it == sound_files.end())
    {
        size_t len = 0;
        uchar *buf = LoadFile(filename, &len);
        if (!buf)
            return false;

        if (sfxr)
        {
            snd.buf = buf;
            snd.len = len;
        }
        else
        {
            SDL_AudioSpec wav_spec;
            Uint32 wav_len;
            auto wav_spec_ret = SDL_LoadWAV_RW(SDL_RWFromMem(buf, (int)len), true, &wav_spec, &snd.buf, &wav_len);

            free(buf);

            if (!wav_spec_ret)
                return false;

            snd.len = wav_len;

            SDL_AudioCVT  wav_cvt;
            int ret = SDL_BuildAudioCVT(&wav_cvt,
                        wav_spec.format, wav_spec.channels, wav_spec.freq,
                        playbackspec.format, playbackspec.channels, playbackspec.freq);

            if (ret < 0)
            {
                SDL_FreeWAV(snd.buf);
                return false;
            }

            if (ret)
            {
                wav_cvt.buf = (uchar *)malloc(snd.len * wav_cvt.len_mult);
                wav_cvt.len = (int)snd.len;
                memcpy(wav_cvt.buf, snd.buf, snd.len);

                SDL_FreeWAV(snd.buf);

                SDL_ConvertAudio(&wav_cvt);

                snd.buf = wav_cvt.buf;
                // caution: len is not size of buffer anymore, but size of valid data..
                // that works ok with SDL_FreeWAV/free
                snd.len = size_t(wav_cvt.len * wav_cvt.len_ratio);
            }
        }

        snd.sfxr = sfxr;

        sound_files[filename] = snd;
    }
    else
    {
        snd = it->second;

        if (sfxr != snd.sfxr)   // wav file and sfxr file with same name? should be very rare :)
            return false;
    }

    if (sfxr)
    {
        uchar *file = snd.buf;

        int version = 0;
        fread_mem(&version, 1, sizeof(int), file);
        if(version!=102)
            return false;

        fread_mem(&wave_type, 1, sizeof(int), file);

        fread_mem(&sound_vol, 1, sizeof(float), file);

        fread_mem(&p_base_freq, 1, sizeof(float), file);
        fread_mem(&p_freq_limit, 1, sizeof(float), file);
        fread_mem(&p_freq_ramp, 1, sizeof(float), file);
        fread_mem(&p_freq_dramp, 1, sizeof(float), file);
        fread_mem(&p_duty, 1, sizeof(float), file);
        fread_mem(&p_duty_ramp, 1, sizeof(float), file);

        fread_mem(&p_vib_strength, 1, sizeof(float), file);
        fread_mem(&p_vib_speed, 1, sizeof(float), file);
        fread_mem(&p_vib_delay, 1, sizeof(float), file);

        fread_mem(&p_env_attack, 1, sizeof(float), file);
        fread_mem(&p_env_sustain, 1, sizeof(float), file);
        fread_mem(&p_env_decay, 1, sizeof(float), file);
        fread_mem(&p_env_punch, 1, sizeof(float), file);

        fread_mem(&filter_on, 1, sizeof(bool), file);
        fread_mem(&p_lpf_resonance, 1, sizeof(float), file);
        fread_mem(&p_lpf_freq, 1, sizeof(float), file);
        fread_mem(&p_lpf_ramp, 1, sizeof(float), file);
        fread_mem(&p_hpf_freq, 1, sizeof(float), file);
        fread_mem(&p_hpf_ramp, 1, sizeof(float), file);

        fread_mem(&p_pha_offset, 1, sizeof(float), file);
        fread_mem(&p_pha_ramp, 1, sizeof(float), file);
        fread_mem(&p_repeat_speed, 1, sizeof(float), file);
        fread_mem(&p_arp_speed, 1, sizeof(float), file);
        fread_mem(&p_arp_mod, 1, sizeof(float), file);
    }

    cursnd = snd;

    return true;
}
Beispiel #21
0
void MYIniReadTools::SetFileName(CString str)
{
	strcpy(FileName,str);
	LoadFile();
}
Beispiel #22
0
/****************************************************************************
 * NGCUnfreezeGame
 ***************************************************************************/
int
NGCUnfreezeGame (int method, bool8 silent)
{
	char filepath[1024];
	int offset = 0;
	int result = 0;
	char msg[80];

	bufoffset = 0;

	ShowAction ((char*) "Loading...");

    if(method == METHOD_AUTO)
		method = autoSaveMethod(); // we use 'Save' because snapshot needs R/W

    if(!MakeFilePath(filepath, FILE_SNAPSHOT, method))
        return 0;

    AllocSaveBuffer ();

    offset = LoadFile(filepath, method, silent);

	if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB) // MC in slot A or slot B
	{
		if (offset)
		{
			char * zipbuffer = (char *)malloc(SAVEBUFFERSIZE);
			memset (zipbuffer, 0, SAVEBUFFERSIZE);

			// skip the saveicon and comment
			offset = (sizeof(saveicon) + 64);
			uLongf zipsize = 0;
			uLongf decompressedsize = 0;

			memcpy (&zipsize, savebuffer+offset, 4);
			offset += 4;

			memcpy (&decompressedsize, savebuffer+offset, 4);
			offset += 4;

			uLongf DestBuffSize = SAVEBUFFERSIZE;
			int err= uncompress((Bytef*)zipbuffer, (uLongf*)&DestBuffSize, (const Bytef*)(savebuffer + offset), zipsize);

			if ( err!=Z_OK )
			{
				sprintf (msg, "Unzip error %s ",zError(err));
				WaitPrompt (msg);
			}
			else if ( DestBuffSize != decompressedsize )
			{
				WaitPrompt((char*) "Unzipped size doesn't match expected size!");
			}
			else
			{
				offset = SAVEBUFFERSIZE;
				memcpy (savebuffer, zipbuffer, SAVEBUFFERSIZE);
			}
			free(zipbuffer);
		}
    }

	if(offset > 0)
	{
		if (S9xUnfreezeGame ("AGAME") == SUCCESS)
			result = 1;
		else
			WaitPrompt((char*) "Error thawing");
	}
	else
	{
		if(!silent)
			WaitPrompt((char*) "Freeze file not found");
	}
	FreeSaveBuffer ();
	return result;
}
Beispiel #23
0
/*
================
DialogAF::ReloadFile
================
*/
void DialogAF::ReloadFile( void ) {
	LoadFile( file );
}
Beispiel #24
0
static void Load() {
  module = LoadFile("jazzcat-electric_city.ahx", MEMF_PUBLIC);
  if (AhxInitPlayer(AHX_LOAD_WAVES_FILE, AHX_FILTERS) != 0)
    exit(10);
}
Beispiel #25
0
sU8 *sSystem_::LoadFile(sChar *name)
{
    sInt dummy;
    return LoadFile(name,dummy);
}
Beispiel #26
0
static void ParseFileSaveData(HWND hwnd, BOOL changed)
{
    LV_ITEM item;
    HWND hwndLV = GetDlgItem(hwnd, IDC_FILELIST);
    int i;
    for (i = 0;; i++)
    {
        PROJECTITEM *pj = NULL;
        DWINFO *ptr = NULL;
        struct saveData *sd = NULL;
        item.iItem = i;
        item.iSubItem = 0;
        item.mask = LVIF_PARAM;
        if (!ListView_GetItem(hwndLV, &item))
            break;
        sd = (struct saveData *)item.lParam;
        if (sd->asProject)
            pj = sd->data;
        else
            ptr = sd->data;
        if (changed)
        {
            if (ListView_GetCheckState(hwndLV, i))
            {				
                if (ptr)
                {
                    LoadFile(ptr->self, ptr, TRUE);
                }		
                else if (pj->type == PJ_FILE)
                {
                    DWINFO *ptr = GetFileInfo(pj->realName);
                    if (ptr)
                        LoadFile(ptr->self, ptr, TRUE);
                }
                else
                {
                    ResReload(pj);
                }
            }
        }
        else
        {
            if (pj && !pj->resData || !pj)
            {
                if (!ptr)
                    ptr = GetFileInfo(pj->realName);
                if (ptr)
                {
                    if (ListView_GetCheckState(hwndLV, i))
                        SendMessage(ptr->self, WM_COMMAND, IDM_SAVE,
                            0);
                    else
                    {
                        TagLinesAdjust(ptr->dwName, TAGM_DISCARDFILE);
                    }
                }
            }
            else 
            {
                if (ListView_GetCheckState(hwndLV, i))
                    ResSave(pj->realName, pj->resData);
                else
                    ResFree(pj, FALSE);
            }
        }
        free(sd);
    }
}
Beispiel #27
0
/******************************************************************************
Function Name  :  UpdateTestSetup
Input(s)       :
Output         :  HRESULT
Functionality  :
Member of      :  CTestSetupEntity
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  28/04/2011
Modifications  :
Code Tag       :
******************************************************************************/
HRESULT CTestSetupEntity::UpdateTestSetup()
{
    CString omStrFile = m_omstrCurrentTSFile;
    vInitialise();
    return LoadFile(omStrFile);
}
Beispiel #28
0
GpxDocument::GpxDocument(const wxString &filename)
{
      LoadFile(filename);
      //FIXME: we should probably validate if the file is GPX DTD compliant and die if not... BUT we would need a dependency to some validating parser.
}
Beispiel #29
0
bool TiXmlDocument::LoadFile( TiXmlEncoding encoding )
{
	return LoadFile( Value(), encoding );
}
Beispiel #30
0
void CLuaHandleSynced::Init(const string& syncedFile,
                            const string& unsyncedFile,
                            const string& modes)
{
	if (L == NULL) {
		return;
	}

	if (fullCtrl) {
		// numWeaponDefs has an extra slot
		for (int w = 0; w <= weaponDefHandler->numWeaponDefs; w++) {
			watchWeapons.push_back(false);
		}
	}

	const string syncedCode   = LoadFile(syncedFile, modes);
	const string unsyncedCode = LoadFile(unsyncedFile, modes);
	if (syncedCode.empty() && unsyncedCode.empty()) {
		KillLua();
		return;
	}

	// load the standard libraries
	LUA_OPEN_LIB(L, luaopen_base);
	LUA_OPEN_LIB(L, luaopen_math);
	LUA_OPEN_LIB(L, luaopen_table);
	LUA_OPEN_LIB(L, luaopen_string);
	//LUA_OPEN_LIB(L, luaopen_io);
	//LUA_OPEN_LIB(L, luaopen_os);
	//LUA_OPEN_LIB(L, luaopen_package);
	//LUA_OPEN_LIB(L, luaopen_debug);

	// delete some dangerous functions
	lua_pushnil(L); lua_setglobal(L, "dofile");
	lua_pushnil(L); lua_setglobal(L, "loadfile");
	lua_pushnil(L); lua_setglobal(L, "loadlib");
	lua_pushnil(L); lua_setglobal(L, "loadstring"); // replaced
	lua_pushnil(L); lua_setglobal(L, "require");
	lua_pushnil(L); lua_setglobal(L, "rawequal");
	lua_pushnil(L); lua_setglobal(L, "rawget");
	lua_pushnil(L); lua_setglobal(L, "rawset");
//	lua_pushnil(L); lua_setglobal(L, "getfenv");
//	lua_pushnil(L); lua_setglobal(L, "setfenv");
	lua_pushnil(L); lua_setglobal(L, "newproxy");
	lua_pushnil(L); lua_setglobal(L, "gcinfo");
	lua_pushnil(L); lua_setglobal(L, "collectgarbage");

	// use gs->randFloat() for the synchronized code, and disable randomseed()
	// (this first copies the original functions to the registry for unsynced)
	if (!SyncifyRandomFuncs()) {
		KillLua();
		return;
	}

	CLuaHandle* origHandle = activeHandle;
	SetActiveHandle();

	synced = true;

	const bool haveSynced = SetupSynced(syncedCode, syncedFile);
	if (L == NULL) {
		SetActiveHandle(origHandle);
		return;
	}

	synced = false;

	const bool haveUnsynced = SetupUnsynced(unsyncedCode, unsyncedFile);
	if (L == NULL) {
		SetActiveHandle(origHandle);
		return;
	}

	synced = true;

	if (!haveSynced && !haveUnsynced) {
		KillLua();
		SetActiveHandle(origHandle);
		return;
	}

	// register for call-ins
	eventHandler.AddClient(this);

	SetActiveHandle(origHandle);
}