コード例 #1
0
ファイル: ncpl_conn.c プロジェクト: edgar-pek/PerspicuOS
/*
 * read rc file as follows:
 * 1. read [server] section
 * 2. override with [server:user] section
 * Since abcence of rcfile is not a bug, silently ignore that fact.
 * rcfile never closed to reduce number of open/close operations.
 */
int
ncp_li_readrc(struct ncp_conn_loginfo *li) {
	int i, val, error;
	char uname[NCP_BINDERY_NAME_LEN*2+1];
	char *sect = NULL, *p;

	/*
	 * if info from cmd line incomplete, try to find existing
	 * connection and fill server/user from it.
	 */
	if (li->server[0] == 0 || li->user == NULL) {
		int connHandle;
		struct ncp_conn_stat cs;
		
		if ((error = ncp_conn_scan(li, &connHandle)) != 0) {
			ncp_error("no default connection found", errno);
			return error;
		}
		ncp_conn_getinfo(connHandle, &cs);
		ncp_li_setserver(li, cs.li.server);
		ncp_li_setuser(li, cs.user);
		ncp_li_setpassword(li, "");
		ncp_disconnect(connHandle);
	}
	if (ncp_open_rcfile()) 	return 0;
	
	for (i = 0; i < 2; i++) {
		switch (i) {
		    case 0:
			sect = li->server;
			break;
		    case 1:
			strcat(strcat(strcpy(uname,li->server),":"),li->user ? li->user : "******");
			sect = uname;
			break;
		}
		rc_getstringptr(ncp_rc, sect, "password", &p);
		if (p)
			ncp_li_setpassword(li, p);
		rc_getint(ncp_rc,sect, "timeout", &li->timeout);
		rc_getint(ncp_rc,sect, "retry_count", &li->retry_count);
		rc_getint(ncp_rc,sect, "sig_level", &li->sig_level);
		if (rc_getint(ncp_rc,sect,"access_mode",&val) == 0)
			li->access_mode = val;
		if(rc_getbool(ncp_rc,sect,"bindery",&val) == 0 && val) {
			li->opt |= NCP_OPT_BIND;
		}
	}
	return 0;
}
コード例 #2
0
ファイル: video.c プロジェクト: brijohn/gnuboy-ex
void vid_init()
{
	int scale = rc_getint("scale");

	vid_set_window_size(scale);

	fb.pelsize = 2;
	fb.yuv = 0;
	fb.indexed = 0;
	fb.enabled = 1;
	fb.dirty = 0;
	fb.w = 160 * scale;
	fb.h = 144 * scale;
	fb.pitch = fb.w * fb.pelsize;
	fb.ptr = (byte *)0xAC202800;
	fb.cc[0].r = 3;  /* 8-5 (wasted bits on red) */
	fb.cc[0].l = 11; /* this is the offset to the R bits (16-5) */
	fb.cc[1].r = 2;  /* 8-6 (wasted bits on green) */
	fb.cc[1].l = 5;  /* This is the offset to the G bits (16-5-6) */
	fb.cc[2].r = 3;  /* 8-5 (wasted bits on red) */
	fb.cc[2].l = 0;  /* This is the offset to the B bits (16-5-6-5) */

	set_pen(create_rgb16(0, 0, 0));
	draw_rect(0, 0, fb.w, fb.h);
	lcdc_copy_vram();
}
コード例 #3
0
ファイル: nandsim_cfgparse.c プロジェクト: Alkzndr/freebsd
/*
 *  Function tries to get appropriate value for given key, convert it to
 *  int of certain length.
 */
static int
get_argument_int(const char *sect_name, int sectno, struct nandsim_key *key,
    struct rcfile *f)
{
	int getres;
	uint32_t val;

	getres = rc_getint(f, sect_name, sectno, key->keyname, &val);
	if (getres != 0) {

		if (key->mandatory != 0) {
			error(MSG_MANDATORYKEYMISSING, key->keyname,
			    sect_name);

			return (EINVAL);
		} else
			/* Non-mandatory key, not present -- skip */
			return (0);
	}
	if (SIZE(key->valuetype) == SIZE_8)
		*(uint8_t *)(key->field) = (uint8_t)val;
	else if (SIZE(key->valuetype) == SIZE_16)
		*(uint16_t *)(key->field) = (uint16_t)val;
	else
		*(uint32_t *)(key->field) = (uint32_t)val;
	return (0);
}
コード例 #4
0
ファイル: sdl.c プロジェクト: Garrant3/gameboy4iphone
void vid_init()
{
	int flags;

	if (!vmode[0] || !vmode[1])
	{
		int scale = rc_getint("scale");
		if (scale < 1) scale = 1;
		vmode[0] = 160 * scale;
		vmode[1] = 144 * scale;
	}
	
	flags = SDL_ANYFORMAT | SDL_HWPALETTE | SDL_HWSURFACE;

	if (fullscreen)
		flags |= SDL_FULLSCREEN;

	if (SDL_Init(SDL_INIT_VIDEO))
		die("SDL: Couldn't initialize SDL: %s\n", SDL_GetError());

	if (!(screen = SDL_SetVideoMode(vmode[0], vmode[1], vmode[2], flags)))
		die("SDL: can't set video mode: %s\n", SDL_GetError());

	SDL_ShowCursor(0);

	joy_init();

	overlay_init();
	
	if (fb.yuv) return;
	
	SDL_LockSurface(screen);
	
	fb.w = screen->w;
	fb.h = screen->h;
	fb.pelsize = screen->format->BytesPerPixel;
	fb.pitch = screen->pitch;
	fb.indexed = fb.pelsize == 1;
	fb.ptr = screen->pixels;
	fb.cc[0].r = screen->format->Rloss;
	fb.cc[0].l = screen->format->Rshift;
	fb.cc[1].r = screen->format->Gloss;
	fb.cc[1].l = screen->format->Gshift;
	fb.cc[2].r = screen->format->Bloss;
	fb.cc[2].l = screen->format->Bshift;

	SDL_UnlockSurface(screen);

	fb.enabled = 1;
	fb.dirty = 0;
	
}
コード例 #5
0
ファイル: ctx.c プロジェクト: AhmadTux/DragonFlyBSD
/*
 * level values:
 * 0 - default
 * 1 - server
 * 2 - server:user
 * 3 - server:user:share
 */
static int
smb_ctx_readrcsection(struct smb_ctx *ctx, const char *sname, int level)
{
	char *p;
	int error;

	if (level >= 0) {
		rc_getstringptr(smb_rc, sname, "charsets", &p);
		if (p) {
			error = smb_ctx_setcharset(ctx, p);
			if (error)
				smb_error("charset specification in the section '%s' ignored", error, sname);
		}
	}
	if (level <= 1) {
		rc_getint(smb_rc, sname, "timeout", &ctx->ct_ssn.ioc_timeout);
		rc_getint(smb_rc, sname, "retry_count", &ctx->ct_ssn.ioc_retrycount);
	}
	if (level == 1) {
		rc_getstringptr(smb_rc, sname, "addr", &p);
		if (p) {
			error = smb_ctx_setsrvaddr(ctx, p);
			if (error) {
				smb_error("invalid address specified in the section %s", 0, sname);
				return error;
			}
		}
	}
	if (level >= 2) {
		rc_getstringptr(smb_rc, sname, "password", &p);
		if (p)
			smb_ctx_setpassword(ctx, p);
	}
	rc_getstringptr(smb_rc, sname, "workgroup", &p);
	if (p)
		smb_ctx_setworkgroup(ctx, p);
	return 0;
}
コード例 #6
0
ファイル: nandsim_cfgparse.c プロジェクト: Alkzndr/freebsd
static int
configure_sim(const char *devfname, struct rcfile *f)
{
	struct sim_param sim_conf;
	char buf[255];
	int err, tmpv, fd;

	err = rc_getint(f, "sim", 0, "log_level", &tmpv);

	if (tmpv < 0 || tmpv > 255 || err) {
		error("Bad log level specified (%d)\n", tmpv);
		return (ENOTSUP);
	} else
		sim_conf.log_level = tmpv;

	rc_getstring(f, "sim", 0, "log_output", 255, (char *)&buf);

	tmpv = -1;
	err = logoutputtoint((char *)&buf, &tmpv);
	if (err) {
		error("Log output specified in config file does not seem to "
		    "be valid (%s)!", (char *)&buf);
		return (ENOTSUP);
	}

	sim_conf.log_output = tmpv;

	fd = open(devfname, O_RDWR);
	if (fd == -1) {
		error("could not open simulator device file (%s)!",
		    devfname);
		return (EX_OSFILE);
	}

	err = ioctl(fd, NANDSIM_SIM_PARAM, &sim_conf);
	if (err) {
		error("simulator parameters could not be modified: %s",
		    strerror(errno));
		close(fd);
		return (ENXIO);
	}

	close(fd);
	return (EX_OK);
}
コード例 #7
0
ファイル: rcfile.c プロジェクト: coyizumi/cs111
/*
 * Unified command line/rc file parser
 */
int
opt_args_parse(struct rcfile *rcp, struct opt_args *ap, const char *sect,
	opt_callback_t *callback)
{
	int len, error;

	for (; ap->opt; ap++) {
		switch (ap->type) {
		    case OPTARG_STR:
			if (rc_getstringptr(rcp, sect, ap->name, &ap->str) != 0)
				break;
			len = strlen(ap->str);
			if (len > ap->ival) {
				warnx("rc: argument for option '%c' (%s) too long\n", ap->opt, ap->name);
				return EINVAL;
			}
			callback(ap);
			break;
		    case OPTARG_BOOL:
			error = rc_getbool(rcp, sect, ap->name, &ap->ival);
			if (error == ENOENT)
				break;
			if (error)
				return EINVAL;
			callback(ap);
			break;
		    case OPTARG_INT:
			if (rc_getint(rcp, sect, ap->name, &ap->ival) != 0)
				break;
			if (((ap->flag & OPTFL_HAVEMIN) && ap->ival < ap->min) || 
			    ((ap->flag & OPTFL_HAVEMAX) && ap->ival > ap->max)) {
				warnx("rc: argument for option '%c' (%s) should be in [%d-%d] range\n",
				    ap->opt, ap->name, ap->min, ap->max);
				return EINVAL;
			}
			callback(ap);
			break;
		    default:
			break;
		}
	}
	return 0;
}
コード例 #8
0
ファイル: ncpl_subr.c プロジェクト: AhmadTux/DragonFlyBSD
/*
 * misc options parsing routines
 */
int
ncp_args_parserc(struct ncp_args *na, char *sect, ncp_setopt_t *set_callback) {
	int len, error;

	for (; na->opt; na++) {
		switch (na->at) {
		    case NCA_STR:
			if (rc_getstringptr(ncp_rc,sect,na->name,&na->str) == 0) {
				len = strlen(na->str);
				if (len > na->ival) {
					fprintf(stderr,"rc: Argument for option '%c' (%s) too long\n",na->opt,na->name);
					return EINVAL;
				}
				set_callback(na);
			}
			break;
		    case NCA_BOOL:
			error = rc_getbool(ncp_rc,sect,na->name,&na->ival);
			if (error == ENOENT) break;
			if (error) return EINVAL;
			set_callback(na);
			break;
		    case NCA_INT:
			if (rc_getint(ncp_rc,sect,na->name,&na->ival) == 0) {
				if (((na->flag & NAFL_HAVEMIN) && 
				     (na->ival < na->min)) || 
				    ((na->flag & NAFL_HAVEMAX) && 
				     (na->ival > na->max))) {
					fprintf(stderr,"rc: Argument for option '%c' (%s) should be in [%d-%d] range\n",na->opt,na->name,na->min,na->max);
					return EINVAL;
				}
				set_callback(na);
			};
			break;
		    default:
			break;
		}
	}
	return 0;
}
コード例 #9
0
ファイル: nb.c プロジェクト: ajinkya93/netbsd-src
/*
 * used level values:
 * 0 - default
 * 1 - server
 */
int
nb_ctx_readrcsection(struct rcfile *rcfile, struct nb_ctx *ctx,
	const char *sname, int level)
{
	char *p;
	int error;

	if (level > 1)
		return EINVAL;
	rc_getint(rcfile, sname, "nbtimeout", &ctx->nb_timo);
	rc_getstringptr(rcfile, sname, "nbns", &p);
	if (p) {
		error = nb_ctx_setns(ctx, p);
		if (error) {
			smb_error("invalid address specified in the section %s", 0, sname);
			return error;
		}
	}
	rc_getstringptr(rcfile, sname, "nbscope", &p);
	if (p)
		nb_ctx_setscope(ctx, p);
	return 0;
}
コード例 #10
0
ファイル: video.c プロジェクト: brijohn/gnuboy-ex
void vid_begin()
{
	vid_set_window_size(rc_getint("scale"));
	if (frameskip >= 0)
                fb.enabled = framecounter==0;
}
コード例 #11
0
ファイル: menu.c プロジェクト: ionbladez/ohboy-zipit
int menu_controls(){

	int ret=0, i=0, btna=2, btnb=1, btnx=2, btny=1, btnl=3, btnr=4;

	FILE *file;

	btna = rc_getint("button_a");
	btnb = rc_getint("button_b");
	btnx = rc_getint("button_x");
	btny = rc_getint("button_y");
	btnl = rc_getint("button_l");
	btnr = rc_getint("button_r");

	start:

	dialog_begin("Controls",NULL);

	#if defined(CAANOO)
	dialog_text("Caanoo","Gameboy",0);                       /* 1 */
	#endif
	#if defined(WIZ)
	dialog_text("Wiz","Gameboy",0);                          /* 1 */
	#endif
	#if defined(DINGOO_NATIVE)
	dialog_text("Dingoo","Gameboy",0);                       /* 1 */
	#endif
	#if defined(GP2X_ONLY)
	dialog_text("GP2X","Gameboy",0);                         /* 1 */
	#endif
	dialog_text(NULL,NULL,0);                                /* 2 */
	dialog_option("Button A",lbutton_a,&btna);               /* 3 */
	dialog_option("Button B",lbutton_b,&btnb);               /* 4 */
	dialog_option("Button X",lbutton_x,&btnx);               /* 5 */
	dialog_option("Button Y",lbutton_y,&btny);               /* 6 */
	dialog_option("Button L",lbutton_l,&btnl);               /* 7 */
	dialog_option("Button R",lbutton_r,&btnr);               /* 8 */
	dialog_text(NULL,NULL,0);                                /* 9 */
	dialog_text("Apply",NULL,FIELD_SELECTABLE);              /* 10 */
	dialog_text("Apply & Save",NULL,FIELD_SELECTABLE);       /* 11 */
	dialog_text("Cancel",NULL,FIELD_SELECTABLE);             /* 12 */

	switch(ret=dialog_end()){
		case 12: /* Cancel */
			return ret;
			break;
		case 10: /* Apply */
		case 11: /* Apply & Save */
		    sprintf(config[0],"#KEY BINDINGS#");
			sprintf(config[1],"set button_a %i",btna);
			sprintf(config[2],"set button_b %i",btnb);
			sprintf(config[3],"set button_x %i",btnx);
			sprintf(config[4],"set button_y %i",btny);
			sprintf(config[5],"set button_l %i",btnl);
			sprintf(config[6],"set button_r %i",btnr);
			#if defined(CAANOO)
			    if (btna == 0) {sprintf(config[7],"unbind joy0");}
			    if (btnb == 0) {sprintf(config[8],"unbind joy2");}
			    if (btnx == 0) {sprintf(config[9],"unbind joy1");}
			    if (btny == 0) {sprintf(config[10],"unbind joy3");}
			    if (btnl == 0) {sprintf(config[11],"unbind joy4");}
			    if (btnr == 0) {sprintf(config[12],"unbind joy5");}

			    if (btna == 1) {sprintf(config[7],"bind joy0 +a");}
			    if (btnb == 1) {sprintf(config[8],"bind joy2 +a");}
			    if (btnx == 1) {sprintf(config[9],"bind joy1 +a");}
			    if (btny == 1) {sprintf(config[10],"bind joy3 +a");}
			    if (btnl == 1) {sprintf(config[11],"bind joy4 +a");}
			    if (btnr == 1) {sprintf(config[12],"bind joy5 +a");}

			    if (btna == 2) {sprintf(config[7],"bind joy0 +b");}
			    if (btnb == 2) {sprintf(config[8],"bind joy2 +b");}
			    if (btnx == 2) {sprintf(config[9],"bind joy1 +b");}
			    if (btny == 2) {sprintf(config[10],"bind joy3 +b");}
			    if (btnl == 2) {sprintf(config[11],"bind joy4 +b");}
			    if (btnr == 2) {sprintf(config[12],"bind joy5 +b");}

			    if (btna == 3) {sprintf(config[7],"bind joy0 +select");}
			    if (btnb == 3) {sprintf(config[8],"bind joy2 +select");}
			    if (btnx == 3) {sprintf(config[9],"bind joy1 +select");}
			    if (btny == 3) {sprintf(config[10],"bind joy3 +select");}
			    if (btnl == 3) {sprintf(config[11],"bind joy4 +select");}
			    if (btnr == 3) {sprintf(config[12],"bind joy5 +select");}

			    if (btna == 4) {sprintf(config[7],"bind joy0 +start");}
			    if (btnb == 4) {sprintf(config[8],"bind joy2 +start");}
			    if (btnx == 4) {sprintf(config[9],"bind joy1 +start");}
			    if (btny == 4) {sprintf(config[10],"bind joy3 +start");}
			    if (btnl == 4) {sprintf(config[11],"bind joy4 +start");}
			    if (btnr == 4) {sprintf(config[12],"bind joy5 +start");}

			    if (btna == 5) {sprintf(config[7],"bind joy0 reset");}
			    if (btnb == 5) {sprintf(config[8],"bind joy2 reset");}
			    if (btnx == 5) {sprintf(config[9],"bind joy1 reset");}
			    if (btny == 5) {sprintf(config[10],"bind joy3 reset");}
			    if (btnl == 5) {sprintf(config[11],"bind joy4 reset");}
			    if (btnr == 5) {sprintf(config[12],"bind joy5 reset");}

			    if (btna == 6) {sprintf(config[7],"bind joy0 quit");}
			    if (btnb == 6) {sprintf(config[8],"bind joy2 quit");}
			    if (btnx == 6) {sprintf(config[9],"bind joy1 quit");}
			    if (btny == 6) {sprintf(config[10],"bind joy3 quit");}
			    if (btnl == 6) {sprintf(config[11],"bind joy4 quit");}
			    if (btnr == 6) {sprintf(config[12],"bind joy5 quit");}
			#endif
			#if defined(DINGOO_NATIVE)
			    if (btna == 0) {sprintf(config[7],"unbind ctrl");}
			    if (btnb == 0) {sprintf(config[8],"unbind alt");}
			    if (btnx == 0) {sprintf(config[9],"unbind space");}
			    if (btny == 0) {sprintf(config[10],"unbind shift");}
			    if (btnl == 0) {sprintf(config[11],"unbind tab");}
			    if (btnr == 0) {sprintf(config[12],"unbind backspace");}

			    if (btna == 1) {sprintf(config[7],"bind ctrl +a");}
			    if (btnb == 1) {sprintf(config[8],"bind alt +a");}
			    if (btnx == 1) {sprintf(config[9],"bind space +a");}
			    if (btny == 1) {sprintf(config[10],"bind shift +a");}
			    if (btnl == 1) {sprintf(config[11],"bind tab +a");}
			    if (btnr == 1) {sprintf(config[12],"bind backspace +a");}

			    if (btna == 2) {sprintf(config[7],"bind ctrl +b");}
			    if (btnb == 2) {sprintf(config[8],"bind alt +b");}
			    if (btnx == 2) {sprintf(config[9],"bind space +b");}
			    if (btny == 2) {sprintf(config[10],"bind shift +b");}
			    if (btnl == 2) {sprintf(config[11],"bind tab +b");}
			    if (btnr == 2) {sprintf(config[12],"bind backspace +b");}

			    if (btna == 3) {sprintf(config[7],"bind ctrl +select");}
			    if (btnb == 3) {sprintf(config[8],"bind alt +select");}
			    if (btnx == 3) {sprintf(config[9],"bind space +select");}
			    if (btny == 3) {sprintf(config[10],"bind shift +select");}
			    if (btnl == 3) {sprintf(config[11],"bind tab +select");}
			    if (btnr == 3) {sprintf(config[12],"bind backspace +select");}

			    if (btna == 4) {sprintf(config[7],"bind ctrl +start");}
			    if (btnb == 4) {sprintf(config[8],"bind alt +start");}
			    if (btnx == 4) {sprintf(config[9],"bind space +start");}
			    if (btny == 4) {sprintf(config[10],"bind shift +start");}
			    if (btnl == 4) {sprintf(config[11],"bind tab +start");}
			    if (btnr == 4) {sprintf(config[12],"bind backspace +start");}

			    if (btna == 5) {sprintf(config[7],"bind ctrl reset");}
			    if (btnb == 5) {sprintf(config[8],"bind alt reset");}
			    if (btnx == 5) {sprintf(config[9],"bind space reset");}
			    if (btny == 5) {sprintf(config[10],"bind shift reset");}
			    if (btnl == 5) {sprintf(config[11],"bind tab reset");}
			    if (btnr == 5) {sprintf(config[12],"bind backspace reset");}

			    if (btna == 6) {sprintf(config[7],"bind ctrl quit");}
			    if (btnb == 6) {sprintf(config[8],"bind alt quit");}
			    if (btnx == 6) {sprintf(config[9],"bind space quit");}
			    if (btny == 6) {sprintf(config[10],"bind shift quit");}
			    if (btnl == 6) {sprintf(config[11],"bind tab quit");}
			    if (btnr == 6) {sprintf(config[12],"bind backspace quit");}
			#endif
			#if defined(WIZ) || defined(GP2X_ONLY)
			    if (btna == 0) {sprintf(config[7],"unbind joy12");}
			    if (btnb == 0) {sprintf(config[8],"unbind joy13");}
			    if (btnx == 0) {sprintf(config[9],"unbind joy14");}
			    if (btny == 0) {sprintf(config[10],"unbind joy15");}
			    if (btnl == 0) {sprintf(config[11],"unbind joy10");}
			    if (btnr == 0) {sprintf(config[12],"unbind joy11");}

			    if (btna == 1) {sprintf(config[7],"bind joy12 +a");}
			    if (btnb == 1) {sprintf(config[8],"bind joy13 +a");}
			    if (btnx == 1) {sprintf(config[9],"bind joy14 +a");}
			    if (btny == 1) {sprintf(config[10],"bind joy15 +a");}
			    if (btnl == 1) {sprintf(config[11],"bind joy10 +a");}
			    if (btnr == 1) {sprintf(config[12],"bind joy11 +a");}

			    if (btna == 2) {sprintf(config[7],"bind joy12 +b");}
			    if (btnb == 2) {sprintf(config[8],"bind joy13 +b");}
			    if (btnx == 2) {sprintf(config[9],"bind joy14 +b");}
			    if (btny == 2) {sprintf(config[10],"bind joy15 +b");}
			    if (btnl == 2) {sprintf(config[11],"bind joy10 +b");}
			    if (btnr == 2) {sprintf(config[12],"bind joy11 +b");}

			    if (btna == 3) {sprintf(config[7],"bind joy12 +select");}
			    if (btnb == 3) {sprintf(config[8],"bind joy13 +select");}
			    if (btnx == 3) {sprintf(config[9],"bind joy14 +select");}
			    if (btny == 3) {sprintf(config[10],"bind joy15 +select");}
			    if (btnl == 3) {sprintf(config[11],"bind joy10 +select");}
			    if (btnr == 3) {sprintf(config[12],"bind joy11 +select");}

			    if (btna == 4) {sprintf(config[7],"bind joy12 +start");}
			    if (btnb == 4) {sprintf(config[8],"bind joy13 +start");}
			    if (btnx == 4) {sprintf(config[9],"bind joy14 +start");}
			    if (btny == 4) {sprintf(config[10],"bind joy15 +start");}
			    if (btnl == 4) {sprintf(config[11],"bind joy10 +start");}
			    if (btnr == 4) {sprintf(config[12],"bind joy11 +start");}

			    if (btna == 5) {sprintf(config[7],"bind joy12 reset");}
			    if (btnb == 5) {sprintf(config[8],"bind joy13 reset");}
			    if (btnx == 5) {sprintf(config[9],"bind joy14 reset");}
			    if (btny == 5) {sprintf(config[10],"bind joy15 reset");}
			    if (btnl == 5) {sprintf(config[11],"bind joy10 reset");}
			    if (btnr == 5) {sprintf(config[12],"bind joy11 reset");}

			    if (btna == 6) {sprintf(config[7],"bind joy12 quit");}
			    if (btnb == 6) {sprintf(config[8],"bind joy13 quit");}
			    if (btnx == 6) {sprintf(config[9],"bind joy14 quit");}
			    if (btny == 6) {sprintf(config[10],"bind joy15 quit");}
			    if (btnl == 6) {sprintf(config[11],"bind joy10 quit");}
			    if (btnr == 6) {sprintf(config[12],"bind joy11 quit");}
			#endif
			for(i=0; i<13; i++)
				rc_command(config[i]);

			pal_dirty();

			if (ret == 11){ /* Apply & Save */
				file = fopen("bindings.rc","w");
				for(i=0; i<13; i++){
					fputs(config[i],file);
					fputs("\n",file);
				}
				fclose(file);
			}
		break;
	}
	return ret;
}
コード例 #12
0
ファイル: menu.c プロジェクト: ionbladez/ohboy-zipit
int menu_options(){

	struct pal_s *palp=0;
	int pal=0, skip=0, ret=0, cfilter=0, sfps=0, upscale=0, speed=0, i=0;
	char *tmp=0, *romdir=0;

	FILE *file;
#ifdef DINGOO_NATIVE
    /*
    **  100Mhz once caused Dingoo A320 MIPS to hang,
    **  when 100Mhz worked BW GB (Adjustris) game was running at 32 fps (versus 60 at 200Mhz).
    **  150Mhz has never worked on my Dingoo A320.
    */
    uintptr_t dingoo_clock_speeds[] = { 200000000, 250000000, 300000000, 336000000, 360000000, 400000000 /* , 430000000 Should not be needed */ };
    /*
    ** under-under clock option is for GB games.
    ** GB games can often be ran under the already
    ** underclocked Dingoo speed of 336Mhz
    */

    bool dingoo_clock_change_result;
	uintptr_t tempCore=336000000; /* default Dingoo A320 clock speed */
	uintptr_t tempMemory=112000000; /* default Dingoo A320 memory speed */
	cpu_clock_get(&tempCore, &tempMemory);
#endif /* DINGOO_NATIVE */

	pal = findpal();
	cfilter = rc_getint("colorfilter");
	if(cfilter && !rc_getint("filterdmg")) cfilter = 2;
	upscale = rc_getint("upscaler");
	skip = rc_getint("frameskip")+1;
	sfps = rc_getint("showfps");
#ifdef DINGOO_NATIVE
	speed = 0;
#else
	speed = rc_getint("cpuspeed")/50 - 4;
#endif /* DINGOO_NATIVE */
	if(speed<0) speed = 0;
	if(speed>11) speed = 11;

	romdir = rc_getstr("romdir");
	romdir = romdir ? strdup(romdir) : strdup(".");

	start:

	dialog_begin("Options",NULL);

	dialog_option("Mono Palette",lpalettes,&pal);               /* 1 */
	dialog_option("Color Filter",lcolorfilter,&cfilter);        /* 2 */
	dialog_option("Upscaler",lupscaler,&upscale);               /* 3 */
	dialog_option("Frameskip",lframeskip,&skip);                /* 4 */
	dialog_option("Show FPS",lsdl_showfps,&sfps);               /* 5 */
#if defined(WIZ) || defined(DINGOO_NATIVE)
	dialog_option("Clock Speed",lclockspeeds,&speed);           /* 6 */
#else
	dialog_text("Clock Speed","Default",0);                     /* 6 */
#endif
	dialog_text("Rom Path",romdir,FIELD_SELECTABLE);            /* 7 */
	#ifdef GNUBOY_HARDWARE_VOLUME
	dialog_option("Volume", volume_levels, &volume_hardware);   /* 8 */ /* this is not the OSD volume.. */
	#else
	dialog_text("Volume", "Default", 0);                        /* 8 */ /* this is not the OSD volume.. */
	#endif /* GNBOY_HARDWARE_VOLUME */
	dialog_text(NULL,NULL,0);                                   /* 9 */
	dialog_text("Apply",NULL,FIELD_SELECTABLE);                 /* 10 */
	dialog_text("Apply & Save",NULL,FIELD_SELECTABLE);          /* 11 */
	dialog_text("Cancel",NULL,FIELD_SELECTABLE);                /* 12 */

	switch(ret=dialog_end()){
		case 7: /* "Rom Path" romdir */
			tmp = menu_requestdir("Select Rom Directory",romdir);
			if(tmp){
				free(romdir);
				romdir = tmp;
			}
			goto start;
		case 12: /* Cancel */
			return ret;
			break;
		case 10: /* Apply */
		case 11: /* Apply & Save */
			#ifdef GNUBOY_HARDWARE_VOLUME
			pcm_volume(volume_hardware * 10);
			#endif /* GNBOY_HARDWARE_VOLUME */
			palp = &gbpal[pal];
			if(speed)
			{
#ifdef DINGOO_NATIVE
                /*
                ** For now do NOT plug in into settings system, current
                ** (Wiz) speed system is focused on multiples of 50Mhz.
                ** Dingoo default clock speed is 336Mhz (CPU certified for
                ** 360, 433MHz is supposed to be possible).
                ** Only set clock speed if changed in options each and
                ** everytime - do not use config file
                */
                --speed;
                /* check menu response is withing the preset array range/size */
                if (speed > (sizeof(dingoo_clock_speeds)/sizeof(uintptr_t) - 1) )
                    speed = 0;
                
                tempCore = dingoo_clock_speeds[speed];
                dingoo_clock_change_result = cpu_clock_set(tempCore);
                
                tempCore=tempMemory=0;
                cpu_clock_get(&tempCore, &tempMemory); /* currently unused */
                /* TODO display clock speed next to on screen FPS indicator */
#endif /* DINGOO_NATIVE */
    
				speed = speed*50 + 200;
			}
			sprintf(config[0],"set dmg_bgp 0x%.6x 0x%.6x 0x%.6x 0x%.6x", palp->dmg_bgp[0], palp->dmg_bgp[1], palp->dmg_bgp[2], palp->dmg_bgp[3]);
			sprintf(config[1],"set dmg_wndp 0x%.6x 0x%.6x 0x%.6x 0x%.6x",palp->dmg_wndp[0],palp->dmg_wndp[1],palp->dmg_wndp[2],palp->dmg_wndp[3]);
			sprintf(config[2],"set dmg_obp0 0x%.6x 0x%.6x 0x%.6x 0x%.6x",palp->dmg_obp0[0],palp->dmg_obp0[1],palp->dmg_obp0[2],palp->dmg_obp0[3]);
			sprintf(config[3],"set dmg_obp1 0x%.6x 0x%.6x 0x%.6x 0x%.6x",palp->dmg_obp1[0],palp->dmg_obp1[1],palp->dmg_obp1[2],palp->dmg_obp1[3]);
			sprintf(config[4],"set colorfilter %i",cfilter!=0);
			sprintf(config[5],"set filterdmg %i",cfilter==1);
			sprintf(config[6],"set upscaler %i",upscale);
			sprintf(config[7],"set frameskip %i",skip-1);
			sprintf(config[8],"set showfps %i",sfps);
			sprintf(config[9],"set cpuspeed %i",speed);
			#ifdef DINGOO_NATIVE /* FIXME Windows too..... if (DIRSEP_CHAR == '\\').... */
			{
				char tmp_path[PATH_MAX];
				char *dest, *src;
				dest = &tmp_path[0];
				src = romdir;
				
				/* escape the path seperator (should escape other things too.) */
				while(*dest = *src++)
				{
					if (*dest == DIRSEP_CHAR)
					{
						dest++;
						*dest = DIRSEP_CHAR;
					}
					dest++;
				}
			
				sprintf(config[10], "set romdir \"%s\"", tmp_path);
				scaler_init(0);
			}
			#else
			sprintf(config[10],"set romdir \"%s\"",romdir);
			scaler_init(0);
			#endif /* DINGOO_NATIVE */

			for(i=0; i<11; i++)
				rc_command(config[i]);

			pal_dirty();

			if (ret == 11){ /* Apply & Save */
				file = fopen("ohboy.rc","w");
				for(i=0; i<11; i++){
					fputs(config[i],file);
					fputs("\n",file);
				}
				fclose(file);
			}

		break;
	}

	free(romdir);

	return ret;
}
コード例 #13
0
ファイル: menu.c プロジェクト: ionbladez/ohboy-zipit
int menu(){

	char *dir;
	int mexit=0;
	static char *loadrom;
	int old_upscale = 0, new_upscale = 0;

	old_upscale = rc_getint("upscaler");
	gui_begin();
	while(!mexit){
		dialog_begin(rom.name,"ohBoy");

		dialog_text("Back to Game",NULL,FIELD_SELECTABLE);
		dialog_text("Load State",NULL,FIELD_SELECTABLE);
		dialog_text("Save State",NULL,FIELD_SELECTABLE);
		dialog_text("Reset Game",NULL,FIELD_SELECTABLE);
		dialog_text(NULL,NULL,0);
		dialog_text("Load ROM",NULL,FIELD_SELECTABLE);
		dialog_text("Options",NULL,FIELD_SELECTABLE);
		dialog_text("Controls",NULL,FIELD_SELECTABLE);
		dialog_text("About",NULL,FIELD_SELECTABLE);
		dialog_text("Quit","",FIELD_SELECTABLE);
		
#ifdef DINGOO_NATIVE
		dialog_text(NULL, NULL, 0); /* blank line */
		dialog_text("Menu:", NULL, 0);
		dialog_text(" Slide Power", NULL, 0);
#endif /* DINGOO_NATIVE */

		switch(dialog_end()){
			case 2:
				if(menu_state(0)) mexit=1;
				break;
			case 3:
				if(menu_state(1)) mexit=1;
				break;
			case 4:
				rc_command("reset");
				mexit=1;
				break;
			case 6:
				dir = rc_getstr("romdir");
				if(loadrom = menu_requestfile(NULL,"Select Rom",dir,"gb;gbc;zip")) {
					loader_unload();
					ohb_loadrom(loadrom);
					mexit=1;
				}
				break;
			case 7:
				if(menu_options()) mexit=1;
				break;
			case 8:
				if(menu_controls()) mexit=1;
				break;
			case 9:
				if(menu_about()) mexit=0;
				break;
			case 10:
				exit(0);
				break;
			default:
				mexit=1;
				break;
		}
	}
	new_upscale = rc_getint("upscaler");
	if (old_upscale != new_upscale)
		scaler_init(new_upscale);
	gui_end();

	return 0;
}