Exemple #1
0
int appInit(int argc, char **argv) {
    const char *opt;

    _flubAppCtx.launchedFromConsole = _appLaunchedFromConsole();

    if((opt = strrchr(argv[0], PLATFORM_PATH_SEP)) != NULL) {
        _flubAppCtx.progName = opt;
    } else {
        _flubAppCtx.progName = argv[0];
    }

    if((!logInit()) ||
            (!cmdlineInit(argc, argv)) ||
            (!flubSDLInit()) ||
            (!flubPhysfsInit(argv[0])) ||
            (!flubCfgInit()) ||
            (!videoInit()) ||
            (!texmgrInit()) ||
            (!flubFontInit()) ||
            (!gfxInit()) ||
            (!audioInit()) ||
            (!inputInit()) ||
            (!consoleInit()) ||
            (!flubGuiThemeInit())
      ) {
        return 0;
    }

    return 1;
}
Exemple #2
0
void EXPORT_THIS *d_init_partial(const char *data_dir) {
	if ((d = malloc(sizeof(DARNIT))) == NULL) {
		fprintf(stderr, "libDarnit: Error: Unable to malloc(%i)\n", (int) sizeof(DARNIT));
		return d;
	}

	tpw_init();

	d->platform.platform = 0;
	darnitSetPlatform(1);
	glColor4f(255, 255, 255, 255);
	d->video.tint_r = d->video.tint_g = d->video.tint_b = d->video.tint_a = 255;
	utilInit();

	if (inputInit() < 0);
	else if (audioInit() < 0);
	else if (socketInit() < 0);
	else {
		if (fsInit(data_dir) < 0)
			return NULL;
		return d;
	}

	free(d);
	return NULL;
}
Exemple #3
0
int main(void) {
    cpu_clock_init(); /* CPU Clock is now 104 MHz */
    ssp_clock_init();
    systickInit();

    SETUPgout(EN_VDD);
    SETUPgout(MIXER_EN);
    SETUPgout(MIC_AMP_DIS);

    SETUPgout(LED1);
    SETUPgout(LED2);
    SETUPgout(LED3);
    SETUPgout(LED4);

    inputInit();
    lcdInit();
    lcdFill(0xff);
    lcdPrintln("Flash-App");
    lcdNl();
    lcdDisplay();

    cpld_flash();
    cpu_clock_set(50);
    full_msc();

    return 0;
}
Exemple #4
0
int main(void) {
	cpuClockInit(); /* CPU Clock is now 104 MHz */
	ssp_clock_init();
	systickInit();

//	cpu_clock_set(204);

	SETUPgout(EN_VDD);
	SETUPgout(MIXER_EN);
	SETUPgout(MIC_AMP_DIS);

	SETUPgout(LED1);
	SETUPgout(LED2);
	SETUPgout(LED3);
	SETUPgout(LED4);

	inputInit();
	lcdInit();
	fsInit(); 
	lcdFill(0xff);
	readConfig();

	generated_init();

	while(1) {
        handleMenu(&menu_main);
        getInputWaitRelease();
	}
	return 0;
}
Exemple #5
0
int main(int argc, char **argv)
{
    usb_dev_handle      *handle = NULL;
    unsigned char       buffer[254];
    int                 nBytes;

    if(openAvrDoper(&handle) != 0) {
        fprintf(stderr, "Could not find USB device \"%s\" with vid=0x%x pid=0x%x or 0x%x\n", USB_PRODUCT_STRING, USBDEV_SHARED_VENDOR, USBDEV_SHARED_CDCPID, USBDEV_SHARED_HIDPID);
        exit(1);
    }
    /* We need not set a configuration and claim an interface to use endpoint 0 */
    inputInit();
    /* The following loop does busy polling with 100ms sleeps when no data was
     * received. We can't use an interrupt endpoint because the CDC device class
     * has already consumed them all.
     */
    for(;;) {
        nBytes = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, USB_VENDOR_RQ_READ, 0, 0, (char *)buffer, sizeof(buffer), 5000);
        if(nBytes < 0) {
            avrDoperReconnect(&handle);
            continue;
        }
        if(nBytes > 0) {
            normalizeAndPrintString(buffer, nBytes);
        } else {
            usleep(50000); /* 50ms */
        }
        if(inputPoll(&handle))
            break;
    }
    usb_close(handle);
    inputExit();
    return 0;
}
Exemple #6
0
/* Hardware initialization */
static void hwInit(void)
{
	extFunc = eeprom_read_byte((uint8_t*)EEPROM_EXT_FUNC);
	#if 0
	loadTempParams();
	if (extFunc == USE_DS18B20) {
		ds18x20SearchDevices();
		tempInit();							/* Init temperature control */
	}
	#endif
	I2CInit();								/* I2C bus */
	displayInit();							/* Load params and text labels before fb scan started */
	rcInit();								/* IR Remote control */
	inputInit();							/* Buttons/encoder polling */
	adcInit();								/* Analog-to-digital converter */

	sei();									/* Gloabl interrupt enable */

	//tunerInit(extFunc);						/* Tuner */

	DDR(STMU_STBY) |= STMU_STBY_LINE;		/* Standby port */
	DDR(STMU_MUTE) |= STMU_MUTE_LINE;		/* Mute port */
	sndInit(extFunc);						/* Load labels/icons/etc */

	setStbyTimer(0);

	return;
}
Exemple #7
0
void initInput(void) {
	inputInit();

  gInput.mouse1 = 0;
  gInput.mouse2 = 0;
  gInput.mousex = 0;
  gInput.mousey = 0;
}
Exemple #8
0
void input(char prompt[], char line[], uint8_t asciistart, uint8_t asciiend, uint8_t maxlength){
 	setSystemFont();
	inputInit(prompt, line, maxlength, asciistart, asciiend);
	while (!s_input.done) {
        inputDraw();
        lcdDisplay();
        inputMove();
    }
	inputClean();
	return;
}
Exemple #9
0
int main(uint32_t startloc) {
	cpu_clock_init();
	ssp_clock_init();
	systickInit();

//	cpu_clock_set(204);

	SETUPgout(EN_VDD);
	SETUPgout(MIXER_EN);
	SETUPgout(MIC_AMP_DIS);

	SETUPgout(LED1);
	SETUPgout(LED2);
	SETUPgout(LED3);
	SETUPgout(LED4);
	inputInit();
	flashInit();

	lcdInit();
	fsInit();
	lcdFill(0xff); /* Display BL Image here */

	sli=startloc;

	if (startloc != (uintptr_t)&_app_start){ /* not booted via DFU, do autoboot */ 
        char filename[FLEN];
        switch(getInputRaw()){
            case BTN_LEFT:
                getInputWaitRelease();
                doRealExec(1);
                break;
            case BTN_UP:
                doMSC();
            default:
            case BTN_NONE:
                readTextFile(BOOTCFG, filename, FLEN);
                lcdPrintln("Booting:");
                lcdPrintln(filename);
                bootFile(filename);
                break;
		};
	};
	static const struct MENU main={ "Bootloader", {
		{ "Exec Firmware", &doExec},
		{ "MSC", &doMSC},
		{ "Flash Boot Ldr", &doFlash},
		{ "Info", &doInfo},
		{NULL,NULL}
	}};
	do {
		handleMenu(&main);
	}while(1);
}
Exemple #10
0
int main(void)
{
	cpu_clock_init();
	ssp_clock_init();

	inputInit();

    lcdInit();
    lcdFill(0xff);
	OFF(MIXER_EN);

	static const struct MENU main={ "img test", {
		{ "LCD", &doLCD},
		{NULL,NULL}
	}};
	handleMenu(&main);
	return 0;
}
Exemple #11
0
int main(uint32_t startloc) {
	cpu_clock_init();
	ssp_clock_init();
	systick_set_reload(208000);
	systick_set_clocksource(0);
	systick_interrupt_enable();
	systick_counter_enable();

//	cpu_clock_pll1_max_speed();

	SETUPgout(EN_VDD);
	SETUPgout(MIXER_EN);

	SETUPgout(LED1);
	SETUPgout(LED2);
	SETUPgout(LED3);
	SETUPgout(LED4);
	inputInit();
	flashInit();

    lcdInit();
	fsInit();
    lcdFill(0xff); /* Display BL Image here */

	sli=startloc;

	if (startloc != (uintptr_t)&_app_start){ /* not booted via DFU, do autoboot */ 
		if (getInputRaw()!=BTN_LEFT){
			char filename[FLEN];
			readTextFile(BOOTCFG, filename, FLEN);
			lcdPrintln("Fname");
			lcdPrintln(filename);
			bootFile(filename,0);
		};
	};
	static const struct MENU main={ "Bootloader", {
		{ "Info", &doInfo},
		{ "Exec", &doExec},
		{ "Flash", &doFlash},
		{NULL,NULL}
	}};
	handleMenu(&main);
	return 0;
}
Exemple #12
0
void gameboyInit(Gameboy *gameboy, Cartridge *cartridge)
{
	CPU *cpu = malloc(sizeof(CPU));
	cpuInit(cpu);

	MMU *mmu = malloc(sizeof(MMU));
	mmuInit(mmu, cartridge);

	Timer *timer = malloc(sizeof(Timer));
	timerInit(timer);

	Display *display = malloc(sizeof(Display));
	displayInit(display);

	Joypad *joypad = malloc(sizeof(Joypad));
	inputInit(joypad);

	gameboy->cpu = cpu;
	gameboy->mmu = mmu;
	gameboy->timer = timer;
	gameboy->display = display;
	gameboy->joypad = joypad;
}
Exemple #13
0
int main(void) {
	cpu_clock_init_();
	ssp_clock_init();

	systickInit();

//	cpu_clock_pll1_max_speed();

	SETUPgout(EN_VDD);
	SETUPgout(MIXER_EN);

	SETUPgout(LED1);
	SETUPgout(LED2);
	SETUPgout(LED3);
	SETUPgout(LED4);

	inputInit();
	feldInit();

    lcdInit();
	fsInit(); 
    lcdFill(0xff);

	static const struct MENU main={ "main 1", {
		{ "FS", &doFS},
		{ "MSC", &doMSC},
		{ "flash", &doFlash},
		{ "LCD", &doLCD},
		{ "speed", &doSpeed},
		{ "ADC", &doADC},
		{ "feld", &doFeld},
		{ "chrg", &doChrg},
		{NULL,NULL}
	}};
	handleMenu(&main);
	return 0;
}
Exemple #14
0
	int main(int _argc, char** _argv)
	{
		//DBG(BX_COMPILER_NAME " / " BX_CPU_NAME " / " BX_ARCH_NAME " / " BX_PLATFORM_NAME);

#if BX_CONFIG_CRT_FILE_READER_WRITER
		s_fileReader = new bx::CrtFileReader;
		s_fileWriter = new bx::CrtFileWriter;
#endif // BX_CONFIG_CRT_FILE_READER_WRITER

		cmdInit();
		cmdAdd("mouselock", cmdMouseLock);
		cmdAdd("graphics",  cmdGraphics );
		cmdAdd("exit",      cmdExit     );

		inputInit();
		inputAddBindings("bindings", s_bindings);

		entry::WindowHandle defaultWindow = { 0 };
		entry::setWindowTitle(defaultWindow, bx::baseName(_argv[0]));

		int32_t result = ::_main_(_argc, _argv);

		inputRemoveBindings("bindings");
		inputShutdown();

		cmdShutdown();

#if BX_CONFIG_CRT_FILE_READER_WRITER
		delete s_fileReader;
		s_fileReader = NULL;

		delete s_fileWriter;
		s_fileWriter = NULL;
#endif // BX_CONFIG_CRT_FILE_READER_WRITER

		return result;
	}
Exemple #15
0
static UINT32
sysInit(
	void
)
{
	/* board dependent modules */
	rtcInit();
	wdtInit();

	inputInit();

	audioInit();
	fmInit();
	lineBufferInit();
	graphicInit();
	scalarInit();
	if (strcmp(SYSCONFIG_PRODUCT, "gplus.microwindowsUI__gplus.evm32900b") != 0) {
		aesInit();
	}
	sdmaInit();
#ifdef SYSCONFIG_ARCH_SPMP8050
	rotatorInit();
#endif
#ifdef SYSCONFIG_ARCH_SPMP8050
	cevaInit();
#endif
	if( gp_ver.major == MACH_GPL32900 )
	{
		cevaInit();
	}
	
	storageInit();

	if (strcmp(SYSCONFIG_MAINSTORAGE, "gp_usb_disk")) {
		usbInit();
	}

	usbWifiInit();
    touchpanelInit();
#ifdef SYSCONFIG_SDIO
	system("modprobe cfg80211");
	system("modprobe mac80211");
	system("modprobe sunrpc");
#endif
	sensorInit();
	ppuInit();
	//tvInit();

	powerInit();
	batteryInit();
	gsensorInit();
	asensorInit();
#ifdef SYSCONFIG_GP_FAST_BOOT
	gpFastBootInit();
#endif /* SYSCONFIG_GP_FAST_BOOT */
	if( gp_ver.major == MACH_GPL32900B )
	{
		On2Init();
		LBPInit();
	}

	return SP_OK;
}
void initialize(char * helpFileName, char * dataFileName,
				char * macroFileName,
				char * dataPath, char * macroPath, char * homePath,
				promptType prompt)
{
	long            i;
	Symbolhandle    symh, symh1;
	long            length, nMacroFiles = 0, nPaths = 0;
	long            nBuiltins = 0;
	char           *dataPathName = (char *) 0, *macroPathName = (char *) 0;
	char           *macroFileNames[NMACROFILES+1];
	char           *place;
	char            completePath[PATHSIZE+1];
	char           *pathName;
	double          value;
#ifdef READLINE
#if defined(INPUTRCFILE) || defined(DEFAULTINPUTRC)
	Keymap           keymap; /* current keymap */
	char            *backwardkillword = "\033\010"; /*Esc-Backspace*/
	FILE            *readlineBindings = (FILE *) 0;
	Symbolhandle     symhPath = (Symbolhandle) 0;
#endif /*defined(INPUTRCFILE) || defined(DEFAULTINPUTRC)*/
#endif /*READLINE*/
	WHERE("initialize");

	getElapsedTime((double *) 0); /* save current time */
	getElapsedTime((double *) 0); /* do it twice for good measure */


#if defined(MSDOS)
	pathName = get_dataPath();
	for (i = 0; pathName[i] != '\0'; i++)
	{ /* make sure all path separators are '\\' */
		if (pathName[i] == '/')
		{
			pathName[i] = DIRSEPARATOR[0];
		}
	} /*for (i == 0; pathName[i] != '\0'; i++)*/
#elif defined(MACINTOSH)
	/* macGetPath() returns address of completePath */
	pathName = macGetPath(completePath, HomeVolume, HomeDirectory);
#elif defined(UNIX)
	pathName = getenv("HOME");
#elif defined(VMS)
	pathName = getenv("ANOVA$HOME");
	dataPathName = 	macroPathName = pathName;
#endif

	if (pathName == (char *) 0)
	{
		completePath[0] = '\0';
	} /*if (pathName == (char *) 0)*/
	else
	{		
		if (pathName != completePath)
		{
			strncpy(completePath, pathName, PATHSIZE);
			completePath[PATHSIZE] = '\0';
		}
		length = strlen(completePath);
#ifndef NOSEPARATOR
		if (completePath[length-1] != DIRSEPARATOR[0] && length < PATHSIZE)
		{
			strcat(completePath, DIRSEPARATOR);
		}
#endif /*NOSEPARATOR*/
	} /*if (pathName == (char *) 0){}else{}*/

	homePath = (homePath != (char *) 0) ? homePath : completePath ;

#if !defined(UNIX) && !defined(VMS)
	if (completePath[0] != '\0')
	{
		dataPathName = (dataPath != (char *) 0) ? dataPath : completePath;
		macroPathName = (macroPath != (char *) 0) ? macroPath : completePath;
	}
	else
#endif /*UNIX*/
/* use defined values on Unix which should have trailing '/' */
	{
		dataPathName = (dataPath != (char *) 0) ? dataPath : DATAPATHNAME;
		macroPathName = (macroPath != (char *) 0) ? macroPath : MACROPATHNAME;
	}
	
/*  initialized math constants */
	MV_E    = exp(1);
	MV_PI_4 = atan(1.0);
	MV_PI_2 = 2.0*MV_PI_4;
	MV_PI   = 4.0*MV_PI_4;

#ifdef M_E
	MV_LOG2E    =       M_LOG2E;
	MV_LOG10E   =      M_LOG10E;
	MV_LN2      =         M_LN2;
	MV_LN10     =        M_LN10;
	MV_1_PI     =        M_1_PI;
	MV_2_PI     =        M_2_PI;
	MV_2_SQRTPI =    M_2_SQRTPI;
	MV_SQRT2    =       M_SQRT2;
#ifdef M_SQRT1_2
	MV_SQRT1_2  =     M_SQRT1_2;
#else /*M_SQRT1_2*/
	MV_SQRT1_2  =      M_SQRT_2; /*Borland math.h name of constant */
#endif /*M_SQRT1_2*/
#else /*M_E*/
	MV_LOG2E    =  1.4426950408889634074;
	MV_LOG10E   = 0.43429448190325182765;
	MV_LN2      = 0.69314718055994530942;
	MV_LN10     = 2.30258509299404568402;
	MV_1_PI     = 0.31830988618379067154;
	MV_2_PI     = 0.63661977236758134308;
	MV_2_SQRTPI = 1.12837916709551257390;
	MV_SQRT2    = 1.41421356237309504880;
	MV_SQRT1_2  = 0.70710678118654752440;
#endif /*M_E*/

	if (!inputInit())
	{ /* allocate space for INPUTSTRINGS and ISTRCHARS*/
		goto fatalError;
	}

	/*
	  Allocate space for globals, BATCHECHO, INPUTFILE, INPUTFILENAMES,
	  LASTINPUTWASCR, PROMPTS
	  */
	if (!batchInit())
	{
		goto fatalError;
	}
	
	if(!Symbolinit())
	{ /* create size TABLESIZE symbol table and zero it out*/
		goto fatalError;
	}

	if(!glmInit())
	{ /* allocate glm related globals */
		goto fatalError;
	}

	/* create fake handles for function symbols */
	for (nBuiltins = 0; builtins[nBuiltins].name; nBuiltins++)
	{ /* count builtins */
		;
	}
	FunctionPointers = (Symbol **) mygetpointer(nBuiltins * sizeof(Symbol *));
	FunctionSymbols = (FunctionSymbol *) mygetpointer(nBuiltins*
													  sizeof(FunctionSymbol));
	if(FunctionPointers == (Symbol **) 0 ||
	   FunctionSymbols == (FunctionSymbol *) 0)
	{
		goto fatalError;
	}

	for (i = 0;i<nBuiltins; i++)
	{ /* make fake Symbolhandle for each builtin function */
		symh = FunctionPointers + i;
		*symh = (Symbol *) (FunctionSymbols+i);
		setTYPE(symh, BLTIN);
		markFakeSymbol(symh); /* indicates it's fake if we ever need to know */
		setNDIMS(symh, 1);
		setDIM(symh, 1, 1);
		setPREV(symh, (Symbolhandle) 0);
		setNEXT(symh, (Symbolhandle) 0);
		setFPTR(symh, builtins[i].function);
		setNAME(symh, builtins[i].name);
		Addsymbol(symh);
	} /*for (i = 0;i<nBuiltins; i++)*/

	/* now install pre-defined constants */
	for (i = 0; constants[i].name; i++)
	{
		symh = RInstall(constants[i].name, 1L);
		if(symh == (Symbolhandle) 0)
		{
			goto fatalError;
		}
		if(strcmp(NAME(symh),"PI") == 0)
		{
			value = MV_PI;
		}
		else if(strcmp(NAME(symh),"E") == 0)
		{
			value = MV_E;
		}
		else if(strcmp(NAME(symh),"DEGPERRAD") == 0)
		{
			value = 45.0/MV_PI_4;
		}
		else
		{
			value = constants[i].value;
		}
		DATAVALUE(symh,0) = value;
	} /*for (i = 0; constants[i].name; i++)*/

	/*
	  Create NULLSYMBOL (value returned by print(), etc.
	  Note that it is *not* installed in the symbol table
	*/
	NULLSYMBOL = Makesymbol(NULLSYM);
	if(NULLSYMBOL == (Symbolhandle) 0)
	{
		goto fatalError;
	}
	setNAME(NULLSYMBOL, "NULLSYMBOL");

	 /* initialize special symbol CLIPBOARD */
	if (!iniClipboard(CLIPBOARDNAME))
	{
		goto fatalError;
	}

#ifdef HASSELECTION
	 /* initialize special symbol SELECTION */
	if (!iniClipboard(SELECTIONNAME))
	{
		goto fatalError;
	}
#endif /*HASSELECTION*/
	/* install pre-defined macros */
	if (!iniMacros())
	{
		goto fatalError;
	}
	
	/* install pre-defined string variables (they must all be scalar) */

	for (i = 0; stringvars[i].name; i++)
	{
		
		symh = CInstall(stringvars[i].name, strlen(stringvars[i].string) + 1);
		if(symh == (Symbolhandle) 0)
		{
			goto fatalError;
		}
		strcpy(STRINGPTR(symh), stringvars[i].string);
		cleanString(STRINGPTR(symh));
	} /*for (i = 0; stringvars[i].name; i++)*/

	/*
	   set value for MISSING and infinities
	*/

#if LONGSPERDOUBLE == 2
	setBdouble(Missing, HIMISSING, LOWMISSING);
#ifdef HASINFINITY
	setBdouble(PlusInfinity, HIPLUSINFINITY, LOWPLUSINFINITY);
	setBdouble(MinusInfinity, HIMINUSINFINITY, LOWMINUSINFINITY);
#endif /*HASINFINITY*/
#else /*LONGSPERDOUBLE == 2*/
	MISSING = MISSINGVALUE; /* may have to do something fancier than this */
#ifdef HASINFINITY
	PLUSINFINITY = 1.0/0.0;
	MINUSINFINITY = -1.0/0.0;
#endif /*HASINFINITY*/
#endif /*LONGSPERDOUBLE == 2*/

/*
  TOOBIGVALUE should be HUGE_VAL which may be infinite
*/
#ifndef NOSTRTOD
	TOOBIGVALUE = mystrtod(TOOBIGVALUESTRING,(char **) 0);
#else /*NOSTRTOD*/
#ifdef HUGE_VAL
	TOOBIGVALUE = HUGE_VAL;
#else /*HUGE_VAL*/
	TOOBIGVALUE = exp(1e200);
#endif /*HUGE_VAL*/
#endif /*NOSTRTOD*/

	OLDMISSING = OLDMISSINGVALUE;  /* -99999.9999 */
	
	setDefaultOptions(); /* set default options */
	if (prompt[0] != '\0')
	{
		strcpy((char *) DEFAULTPROMPTS[0], (char *) prompt);
	}
	strcpy((char *) PROMPTS[0], (char *) DEFAULTPROMPTS[0]);
	
#ifdef VERSION
	sprintf(OUTSTR,"MacAnova %s ",VERSION);
#ifdef TODAY
	strcat(OUTSTR,TODAY);
#endif /*TODAY*/
	symh = CInstall("VERSION", strlen(OUTSTR) + 1);
	if(symh == (Symbolhandle) 0)
	{
		goto fatalError;
	}
	strcpy(STRINGPTR(symh),OUTSTR);
	*OUTSTR = '\0';
	VERSION_ID = myduphandle(STRING(symh));
	if(VERSION_ID == (char **) 0)
	{
		goto fatalError;
	}
#endif /*VERSION*/

	/* Create global HELPFILENAME*/
	if(helpFileName == (char *) 0)
	{
		helpFileName = HELPNAME;
#ifdef UNIX
		pathName = HELPPATHNAME;
#elif	defined(VMS)
		pathName = getenv("ANOVA$HOME");
#else /*UNIX*/
		pathName = completePath;
#endif /*UNIX*/
	}
	else
	{
		pathName = NullString;
	}
	length = strlen(pathName) + strlen(helpFileName);
	
	HELPFILENAME = mygethandle(length + 1);
	if(HELPFILENAME == (char **) 0)
	{
		goto fatalError;
	}
	strcpy(*HELPFILENAME,pathName);
	strcat(*HELPFILENAME,helpFileName);

/*   Install CHARACTER scalar DATAPATH containing dataPathName */
	length = strlen(dataPathName);
#ifndef NOSEPARATOR
	if (dataPathName[length-1] != DIRSEPARATOR[0])
	{
		length++;
	}
#endif /*NOSEPARATOR*/
	symh = CInstall("DATAPATH",length + 1);
	if (symh == (Symbolhandle) 0)
	{
		goto fatalError;
	}
	strcpy(STRINGPTR(symh),dataPathName);
#ifndef NOSEPARATOR
	STRINGVALUE(symh, length-1) = DIRSEPARATOR[0];
	STRINGVALUE(symh, length) = '\0';
#endif /*NOSEPARATOR*/
/* 
   Install CHARACTER vector DATAPATHS containing dataPathName and
   macroPathName.  If they are the same, they are not duplicated
*/
	nPaths = 1;
	if (strcmp(macroPathName, dataPathName) != 0 &&
		strcmp(macroPathName, STRINGPTR(symh)) != 0)
	{
		long      length2 = strlen(macroPathName);
		
		length++; /* account for trailing null of dataPathName */
		nPaths = 2;
#ifndef NOSEPARATOR
		if (macroPathName[length2-1] != DIRSEPARATOR[0])
		{
			length2++;
		}
#endif /*NOSEPARATOR*/
		length += length2;
	}
	
	symh1 = CInstall("DATAPATHS",length + 1);
	if (symh1 == (Symbolhandle) 0)
	{
		goto fatalError;
	}
	strcpy(STRINGPTR(symh1),STRINGPTR(symh));
	if (nPaths > 1)
	{
		strcpy(skipStrings(STRINGPTR(symh1), 1), macroPathName);
#ifndef NOSEPARATOR
		STRINGVALUE(symh1,length-1) = DIRSEPARATOR[0];
		STRINGVALUE(symh1,length) = '\0';
#endif /*NOSEPARATOR*/
	}
	setDIM(symh1, 1, nPaths);
	
	/* pre-install CHARACTER scalar HOME */
	length = strlen(homePath);

	if(length > 0)
	{
#ifndef NOSEPARATOR
		if (homePath[length-1] != DIRSEPARATOR[0])
		{ /* make room for terminating separator */
			length++;
		}
#endif /*NOSEPARATOR*/
		symh = CInstall("HOME",length + 1);
		if (symh == (Symbolhandle) 0)
		{
			goto fatalError;
		}
		strcpy(STRINGPTR(symh),homePath);
#ifndef NOSEPARATOR
		/* make sure HOME terminates with DIRSEPARATOR[0]*/
		STRINGVALUE(symh, length-1) = DIRSEPARATOR[0];
		STRINGVALUE(symh, length) = '\0';
#endif /*NOSEPARATOR*/
#ifdef MSDOS
		{
			char       *pc;
		
			for (pc = STRINGPTR(symh); *pc != '\0'; pc++)
			{ /* ensure all separators are standard backslashes*/
				if (*pc == '/')
				{
					*pc = DIRSEPARATOR[0];
				}
			} /*for (pc = STRINGPTR(symh); *pc != '\0'; pc++)*/
		}
#endif /*MSDOS*/
	} /*if(length > 0)*/

	/* install CHARACTER scalar DATAFILE */
	if(dataFileName == (char *) 0)
	{
		dataFileName = DATAFILENAME;
	}
	
	length = strlen(dataFileName);

	symh = CInstall("DATAFILE", length + 1);
	if (symh == (Symbolhandle) 0)
	{
		goto fatalError;
	}

	strcpy(STRINGPTR(symh), dataFileName);

	/* Install CHARACTER scalar MACROFILE and CHARACTER vector MACROFILES*/
	for (i = 0; i < NMACROFILES + 1; i++)
	{
		macroFileNames[i] = NullString;
	}
	if (macroFileName != (char *) 0)
	{
		macroFileNames[nMacroFiles++] = macroFileName;
	}
	macroFileNames[nMacroFiles++] = MACROFILENAME;
	macroFileNames[nMacroFiles++] = TSMACROFILENAME;
	macroFileNames[nMacroFiles++] = DESIGNMACROFILENAME;
	macroFileNames[nMacroFiles++] = ARIMAMACROFILENAME;

	length = strlen(macroFileNames[0]) + 1;

	symh = CInstall("MACROFILE",length);
	if(symh == (Symbolhandle) 0)
	{
		goto fatalError;
	}
	strcpy(STRINGPTR(symh), macroFileNames[0]);
	
	length = 0;
	for (i = 0; i < nMacroFiles; i++)
	{
		length += strlen(macroFileNames[i]) + 1;
	}
	symh = CInstall("MACROFILES", length);
	if (symh == (Symbolhandle) 0)
	{
		goto fatalError;
	}
	setDIM(symh, 1, nMacroFiles);
	place = STRINGPTR(symh);
	for (i = 0; i < nMacroFiles; i++)
	{
		place = copyStrings(macroFileNames[i], place, 1);
	}
	
#ifdef READLINE
	/* Initialize line editing and history */
#if defined(INPUTRCFILE) || defined(DEFAULTINPUTRC)
	using_history(); /*added 980108*/
	rl_initialize(); /*added 980106 */
	rl_initialize_funmap();
	keymap = rl_get_keymap();
	if (keymap != (Keymap) 0)
	{ /* this binding is standard but not the default in readline 1.1 */
		rl_set_key (backwardkillword, rl_backward_kill_word, keymap);
	} /*if (keymap != (Keymap) 0)*/
#ifndef INPUTRCFILE
	pathName = OUTSTR;
	strcpy(pathName, dataPathName);
	strcat(pathName, DEFAULTINPUTRC);
#else /*INPUTRCFILE*/
	pathName = INPUTRCFILE;
#endif /*INPUTRCFILE*/
	if (pathName[0] != '\0')
	{
		readlineBindings = fmyopen(pathName, TEXTREADMODE);
		if (readlineBindings != (FILE *) 0)
		{
			fclose(readlineBindings);
			rl_read_init_file(pathName);
		} /*if (readlineBindings != (FILE *) 0)*/
	} /*if (pathName[0] != '\0')*/
#endif /*defined(INPUTRCFILE) || defined(DEFAULTINPUTRC)*/
#endif /*READLINE*/

/*
   initialize or clear virtually everything in sight
*/
	*OUTSTR = '\0';
	for (i = 0;i < MAXWDEPTH;i++)
	{
		WHILELIMITS[i] = MAXWHILE;
		FORVECTORS[i] = (double **) 0;
	}
	clearGlobals();

	INPUTFILE[0] = STDIN;
	INPUTFILENAMES[0] = &StdinName;

	for (i=1;i<MAXBDEPTH;i++)
	{
		INPUTFILE[i] = (FILE *) 0;
		INPUTFILENAMES[i] = (char **) 0;
	}

	TMPHANDLE = mygethandle(sizeof(double)); /*warehouseable length*/
	if(TMPHANDLE == (char **) 0)
	{
		goto fatalError;
	}
	INPUTSTRING = ThisInputstring = (unsigned char **) TMPHANDLE;
	(*INPUTSTRING)[0] = '\0';

	GUBED = 0; /* this is here to make it easy to change for debugging */

#ifdef DJGPP
	INTERRUPT = INTSET;
	(void) interrupted(0); /* to get DJGPP started */
	INTERRUPT = INTNOTSET;
#endif /*DJGPP*/
#if defined(BCPP) || defined (wx_msw)
	(void) _control87(EM_OVERFLOW,EM_OVERFLOW);
#endif /*BCPP||wxmsw*/

#ifdef wx_motif
#if (0) /* inititalization now done in base frame initializer */
	initializePSPrinter();
#endif
#endif /*wx_motif*/
	return ;

  fatalError:
	FatalError = 1;
	
} /*initialize()*/
Exemple #17
0
	int main(int _argc, char** _argv)
	{
		//DBG(BX_COMPILER_NAME " / " BX_CPU_NAME " / " BX_ARCH_NAME " / " BX_PLATFORM_NAME);

		if (BX_ENABLED(ENTRY_CONFIG_PROFILER) )
		{
			rmtSettings* settings = rmt_Settings();
			BX_WARN(NULL != settings, "Remotery is not enabled.");
			if (NULL != settings)
			{
				settings->malloc  = rmtMalloc;
				settings->realloc = rmtRealloc;
				settings->free    = rmtFree;

				rmtError err = rmt_CreateGlobalInstance(&s_rmt);
				BX_WARN(RMT_ERROR_NONE != err, "Remotery failed to create global instance.");
				if (RMT_ERROR_NONE == err)
				{
					rmt_SetCurrentThreadName("Main");
				}
				else
				{
					s_rmt = NULL;
				}
			}
		}

#if BX_CONFIG_CRT_FILE_READER_WRITER
		s_fileReader = new bx::CrtFileReader;
		s_fileWriter = new bx::CrtFileWriter;
#endif // BX_CONFIG_CRT_FILE_READER_WRITER

		cmdInit();
		cmdAdd("mouselock", cmdMouseLock);
		cmdAdd("graphics",  cmdGraphics );
		cmdAdd("exit",      cmdExit     );

		inputInit();
		inputAddBindings("bindings", s_bindings);

		entry::WindowHandle defaultWindow = { 0 };
		entry::setWindowTitle(defaultWindow, bx::baseName(_argv[0]) );
		setWindowSize(defaultWindow, ENTRY_DEFAULT_WIDTH, ENTRY_DEFAULT_HEIGHT);

		int32_t result = ::_main_(_argc, _argv);

		inputRemoveBindings("bindings");
		inputShutdown();

		cmdShutdown();

#if BX_CONFIG_CRT_FILE_READER_WRITER
		delete s_fileReader;
		s_fileReader = NULL;

		delete s_fileWriter;
		s_fileWriter = NULL;
#endif // BX_CONFIG_CRT_FILE_READER_WRITER

		if (BX_ENABLED(ENTRY_CONFIG_PROFILER)
		&&  NULL != s_rmt)
		{
			rmt_DestroyGlobalInstance(s_rmt);
		}

		return result;
	}
Exemple #18
0
int main(void)
{
	cpu_clock_init_();
//	cpu_clock_pll1_max_speed();
	scu_pinmux(RF_EN_PIN,SCU_GPIO_NOPULL|RF_EN_FUNC);
	GPIO_DIR(RF_EN_GPORT) |= RF_EN_GPIN;
	gpio_clear(RF_EN_GPORT, RF_EN_GPIN); /* RF off */

    // Config LED as out
	scu_pinmux(LED1_PIN,SCU_GPIO_NOPULL|LED1_FUNC);
	GPIO_DIR(LED1_GPORT) |= LED1_GPIN;

	inputInit();

    lcdInit();
    lcdFill(0xff);
	setSystemFont();
	char tu=0,td=0,tl=0,tr=0,tm=0;
	char led=0;
	lcdPrintln("Sec-Test v2");
	lcdPrintln("");

	int ctr=0;
	int k=0;
	/* Blink LED1 on the board. */
	while (1) 
	{
		lcdSetCrsr(0,16);
		lcdPrint(IntToStr(tu,2,F_HEX)); lcdPrintln(" Up");
		lcdPrint(IntToStr(td,2,F_HEX)); lcdPrintln(" Down");
		lcdPrint(IntToStr(tl,2,F_HEX)); lcdPrintln(" Left");
		lcdPrint(IntToStr(tr,2,F_HEX)); lcdPrintln(" Right");
		lcdPrint(IntToStr(tm,2,F_HEX)); lcdPrintln(" Enter");
		lcdDisplay(); 
		switch(getInput()){
			case BTN_UP:
				tu=1-tu;
				if (tu){
				}else{
				};
				break;
			case BTN_DOWN:
				td=1-td;
				if (td){
				}else{
				};
				break;
			case BTN_LEFT:
				tl=1-tl;
				if (tl){
				}else{
				};
				break;
			case BTN_RIGHT:
				tr=1-tr;
				if (tr){
				}else{
				};
				break;
			case BTN_ENTER:
				tm=1-tm;
				if (tm){
				}else{
				};
				break;
		};

		led=1-led;
		if (led){
			gpio_set(LED1_GPORT, LED1_GPIN); /* LED on */
		}else{
			gpio_clear(LED1_GPORT, LED1_GPIN); /* LED off */
//			delayNop(200000);
		};

		ctr++;
		lcdNl();
		lcdPrint(IntToStrX(ctr,4));
	}

	return 0;
}
Exemple #19
0
int main(int argc, char *argv[])
{
	if (argc < 2)
	{
		fprintf(stderr, "[gwmserver] no launcher specified\n");
		return 1;
	};
	
	char dispdev[1024];
	uint64_t requestRes;
	char linebuf[1024];
	
	if (geteuid() != 0)
	{
		fprintf(stderr, "[gwmserver] you need to be root to start the window manager\n");
		return 1;
	};

	int sockfd = socket(AF_UNIX, SOCK_SEQPACKET, 0);
	if (sockfd == -1)
	{
		fprintf(stderr, "[gwmserver] cannot create socket: %s\n", strerror(errno));
		return 1;
	};
	
	struct sockaddr_un srvaddr;
	srvaddr.sun_family = AF_UNIX;
	strcpy(srvaddr.sun_path, "/run/gwmserver");
	
	if (bind(sockfd, (struct sockaddr*) &srvaddr, sizeof(struct sockaddr_un)) != 0)
	{
		fprintf(stderr, "[gwmserver] cannot bind to /run/gwmserver: %s\n", strerror(errno));
		return 1;
	};
	
	if (listen(sockfd, 5) != 0)
	{
		fprintf(stderr, "[gwmserver] cannot listen: %s\n", strerror(errno));
		return 1;
	};
	
	// make sure the clipboard and shared surface directories actually exist
	mkdir("/run/clipboard", 0777);
	mkdir("/run/shsurf", 01777);
	mkdir("/run/gwmserver-wd", 0777);
	mkdir("/var", 0755);
	mkdir("/var/log", 0755);
	
	chdir("/run/gwmserver-wd");
	
	FILE *fp = fopen("/etc/gwm.conf", "r");
	if (fp == NULL)
	{
		fprintf(stderr, "could not open /etc/gwm.conf: %s\n", strerror(errno));
		return 1;
	};
	
	requestRes = DDI_RES_AUTO;
	dispdev[0] = 0;
	
	char *line;
	int lineno = 0;
	char logdest[PATH_MAX];
	strcpy(logdest, "/var/log/gwmserver.log");
	while ((line = fgets(linebuf, 1024, fp)) != NULL)
	{
		lineno++;
		
		char *endline = strchr(line, '\n');
		if (endline != NULL)
		{
			*endline = 0;
		};
		
		if (strlen(line) >= 1023)
		{
			fprintf(stderr, "/etc/gwm.conf:%d: buffer overflow\n", lineno);
			return 1;
		};
		
		if ((line[0] == 0) || (line[0] == '#'))
		{
			continue;
		}
		else
		{
			char *cmd = strtok(line, " \t");
			if (cmd == NULL)
			{
				continue;
			};
			
			if (strcmp(cmd, "display") == 0)
			{
				char *name = strtok(NULL, " \t");
				if (name == NULL)
				{
					fprintf(stderr, "/etc/gwm.conf:%d: 'display' needs a parameter\n", lineno);
					return 1;
				};
				
				strcpy(dispdev, name);
			}
			else if (strcmp(cmd, "resolution") == 0)
			{
				char *res = strtok(NULL, " \t");
				if (res == NULL)
				{
					fprintf(stderr, "/etc/gwm.conf:%d: 'resolution' needs a parameter\n", lineno);
					return 1;
				};
				
				uint64_t reqWidth, reqHeight;
				if (strcmp(res, "auto") == 0)
				{
					requestRes = DDI_RES_AUTO;
				}
				else if (strcmp(res, "safe") == 0)
				{
					requestRes = DDI_RES_SAFE;
				}
				else if (sscanf(res, "%lux%lu", &reqWidth, &reqHeight) == 2)
				{
					requestRes = DDI_RES_SPECIFIC(reqWidth, reqHeight);
				}
				else
				{
					fprintf(stderr, "/etc/gwm.conf:%d: invalid resolution: %s\n", lineno, res);
					return 1;
				};
			}
			else if (strcmp(cmd, "log") == 0)
			{
				char *path = strtok(NULL, " \t");
				if (path == NULL)
				{
					fprintf(stderr, "/etc/gwm.conf:%d: 'log' needs a parameter\n", lineno);
					return 1;
				};
				
				if (strlen(path) >= PATH_MAX)
				{
					fprintf(stderr, "/etc/gwm.conf:%d: log path too long\n", lineno);
					return 1;
				};
				
				strcpy(logdest, path);
			}
			else
			{
				fprintf(stderr, "/etc/gwm.conf:%d: invalid directive: %s\n", lineno, cmd);
				return 1;
			};
		};
	};
	fclose(fp);
	
	int logfd = open(logdest, O_WRONLY | O_CREAT | O_APPEND, 0644);
	if (logfd == -1)
	{
		fprintf(stderr, "[gwmserver] could not open log file %s: %s\n", logdest, strerror(errno));
		return 1;
	};
	
	dup2(logfd, 1);
	dup2(logfd, 2);
	close(logfd);
	
	if (dispdev[0] == 0)
	{
		fprintf(stderr, "/etc/gwm.conf: no display device specified!\n");
		return 1;
	};

	if (ddiInit(dispdev, O_RDWR) != 0)
	{
		fprintf(stderr, "ddiInit: %s: %s\n", dispdev, strerror(errno));
		return 1;
	};
	
	if (symlink(dispdev, "/run/gwmdisp") != 0)
	{
		fprintf(stderr, "symlink /run/gwmdisp: %s\n", strerror(errno));
		return 1;
	};

	frontBuffer = ddiSetVideoMode(requestRes);
	screen = ddiCreateSurface(&frontBuffer->format, frontBuffer->width, frontBuffer->height, NULL, 0);
	
	// GWM information
	int fd = open("/run/gwminfo", O_RDWR | O_CREAT | O_TRUNC, 0644);
	if (fd == -1)
	{
		fprintf(stderr, "Failed to open /run/gwminfo! %s\n", strerror(errno));
		return 1;
	};

	DDIColor backgroundColor = {0, 0, 0x77, 0xFF};
	desktopBackground = ddiCreateSurface(&screen->format, screen->width, screen->height, NULL, DDI_SHARED);
	ddiFillRect(desktopBackground, 0, 0, screen->width, screen->height, &backgroundColor);
	ddiFillRect(screen, 0, 0, screen->width, screen->height, &backgroundColor);
	ddiFillRect(frontBuffer, 0, 0, screen->width, screen->height, &backgroundColor);
	
	ftruncate(fd, sizeof(GWMInfo));
	gwminfo = (GWMInfo*) mmap(NULL, sizeof(GWMInfo), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
	gwminfo->backgroundID = desktopBackground->id;

	printf("[gwmserver] initialize theme info\n");
	gwmGlobalThemeInit(&frontBuffer->format);
	
	imgWincap = ddiOpenSurface(gwminfo->imgWinCap);
	imgWinbut = ddiOpenSurface(gwminfo->imgWinButtons);
	
	if (fork() == 0)
	{
		execv(argv[1], &argv[1]);
		perror("exec launcher");
		_exit(1);
	};
	
	// now that we won't be starting any processes, we can set core dumps
	signal(SIGSEGV, SIG_CORE);
	signal(SIGILL, SIG_CORE);
	signal(SIGBUS, SIG_CORE);
	signal(SIGABRT, SIG_CORE);
	signal(SIGALRM, SIG_CORE);
	
	kblSet("/usr/share/kblayout/en_US/int", stderr);
	wndInit();
	ptrInit();
	inputInit();
	runServer(sockfd);
	return 0;
};
Exemple #20
0
int main(int argc, char **argv)
{
	char nom_du_fichier[300] = "No_File_Loaded";
	if (argc > 1)
	{
		strcpy_s(nom_du_fichier, argv[1]);
	}
	char temp[20] = "";
	SDL_Window *window = nullptr;
	SDL_Renderer *render = nullptr;
	Input INPUT; inputInit(&INPUT);
	SDL_Color WHITE = { 255, 255 , 255 };
	int volume = 70;
	initVid(&window, &render, w_window, h_window);
	SDL_SetWindowTitle(window, "ColdJuke");

	TTF_Init();
	Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, MIX_DEFAULT_CHANNELS, 1024);

	Mix_Music *music = nullptr;
	music = Mix_LoadMUS(nom_du_fichier);
	Mix_PlayMusic(music, -1);
	Mix_VolumeMusic(static_cast<double>(128 / 100)*volume);
	clearWithColor(render, 80, 40, 100, 255);
	SDL_Texture *gui = imgToTex((baseProgramPath + "gui.png").c_str(), render);
	
	sprintf_s(temp, "%d%%", volume);
	SDL_Texture *tex_volume = txtToTex(temp, render, WHITE, 14);
	SDL_Texture *texte = txtToTex(nom_du_fichier, render, WHITE, 14);
	afficherGui(gui, texte, tex_volume, render);

	SDL_RenderPresent(render);
	int FPS(60), TICKS(1000 / FPS);
	long start(SDL_GetTicks()), actual(SDL_GetTicks());
	INPUT.filedrop = "";
	while (!INPUT.quit && !INPUT.key[SDL_SCANCODE_ESCAPE] && !(INPUT.leftclic && INPUT.leftclic_position_x > w_window-32 && INPUT.leftclic_position_y < 32))
	{
		inputReturn(&INPUT);

		actual = SDL_GetTicks();
		if (actual - start > TICKS)
		{
			if (INPUT.key[SDL_SCANCODE_SPACE] || (INPUT.leftclic && INPUT.leftclic_position_x < 64 && INPUT.leftclic_position_y > 64)) // Pause Play
			{
				if (Mix_PausedMusic())
				{
					Mix_ResumeMusic();
					texToRenderPart(gui, render, 100, 0, 64, 64, 64, 32, 0, 64, 64);
					SDL_RenderPresent(render);

				}
				else
				{
					Mix_PauseMusic();
					texToRenderPart(gui, render, 100, 0, 64, 64, 64, 32, 64, 64, 64);
					SDL_RenderPresent(render);

				}
				SDL_Delay(250);
			}
			if (INPUT.wheelup)
			{
				volume += 2;
				if (volume > 100)
					volume = 100;
				Mix_VolumeMusic(static_cast<double>(128 / 100)*volume);
				// Volume 
				texToRenderPart(gui, render, 100, w_window - 64, 64, 64, 64, 96, 0, 64, 64);
				sprintf_s(temp, "%d%%", volume);
				SDL_DestroyTexture(tex_volume);
				tex_volume = txtToTex(temp, render, WHITE, 14);
				// Volume Number
				texToRender(tex_volume, render, 100, w_window - 40, 85);
				SDL_RenderPresent(render);


			}
			if (INPUT.wheeldown)
			{
				volume -= 2;
				if (volume < 0)
					volume = 0;
				Mix_VolumeMusic(static_cast<double>(128 / 100)*volume);
				// Volume 
				texToRenderPart(gui, render, 100, w_window - 64, 64, 64, 64, 96, 0, 64, 64);
				sprintf_s(temp, "%d%%", volume);
				SDL_DestroyTexture(tex_volume);
				tex_volume = txtToTex(temp, render, WHITE, 14);
				// Volume Number
				texToRender(tex_volume, render, 100, w_window - 40, 85);
				SDL_RenderPresent(render);

			}
			if (INPUT.rightclic)
			{
				int x_mouse_screen; int y_mouse_screen;
				SDL_GetGlobalMouseState(&x_mouse_screen,&y_mouse_screen);
				SDL_SetWindowPosition(window, x_mouse_screen-INPUT.rightclic_position_x, y_mouse_screen-INPUT.rightclic_position_y);
				inputReturn(&INPUT);
			}
			if (INPUT.filedrop != "")
			{
				Mix_PauseMusic();
				music = Mix_LoadMUS(INPUT.filedrop);
				strcpy_s(nom_du_fichier, INPUT.filedrop);
				Mix_PlayMusic(music, -1);
				sprintf_s(temp, "%d%%", volume);
				SDL_DestroyTexture(texte);
				texte = txtToTex(nom_du_fichier, render, WHITE, 14);
				afficherGui(gui, texte, tex_volume, render);
				SDL_RenderPresent(render);

			}
			start = actual;
			INPUT.filedrop = "";
			INPUT.wheeldown = 0;
			INPUT.wheelup = 0;
		}
		else
		{
			SDL_Delay(TICKS - (actual - start));
		}
	}

	Mix_CloseAudio();
	TTF_Quit();
	SDL_Quit();
	return 0;
}