Código:
...
const char *lxcolor[] = {"0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%", NULL};
const char *lxbright[] = {"0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%", NULL};
const char *lxcontrast[] = {"0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%", NULL};
...
...
static char config[24][256];
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, border=0, xcolor=0, xbright=0, xcontrast=0;
int red1=0, red2=0, red3=0, red4=0, green1=0, green2=0, green3=0, green4=0, blue1=0, blue2=0, blue3=0, blue4=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");
border = rc_getint("border");
xcolor = rc_getint("xcolor");
xbright = rc_getint("xbright");
xcontrast = rc_getint("xcontrast");
#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("Saturation",lxcolor,&xcolor); /* 3 */
dialog_option("Brightness",lxbright,&xbright); /* 4 */
dialog_option("Contrast",lxcontrast,&xcontrast); /* 5 */
dialog_option("Upscaler",lupscaler,&upscale); /* 6 */
dialog_option("Frameskip",lframeskip,&skip); /* 7 */
dialog_option("Show FPS",lsdl_showfps,&sfps); /* 8 */
dialog_option("Show Border", lborder, &border); /* 9 */
#if defined(WIZ) || defined(DINGOO_NATIVE)
dialog_option("Clock Speed",lclockspeeds,&speed); /* 10 */
#else
dialog_text("Clock Speed","Default",0); /* 10 */
#endif
dialog_text("Rom Path",romdir,FIELD_SELECTABLE); /* 11 */
#ifdef GNUBOY_HARDWARE_VOLUME
dialog_option("Volume", volume_levels, &volume_hardware); /* 12 *//* this is not the OSD volume.. */
#else
dialog_text("Volume", "Default", 0); /* 12 */ /* this is not the OSD volume.. */
#endif /* GNBOY_HARDWARE_VOLUME */
dialog_text(NULL,NULL,0); /* 13 */
dialog_text("Apply",NULL,FIELD_SELECTABLE); /* 14 */
dialog_text("Apply & Save",NULL,FIELD_SELECTABLE); /* 15 */
dialog_text("Cancel",NULL,FIELD_SELECTABLE); /* 16 */
switch(ret=dialog_end()){
case 11: /* "Rom Path" romdir */
tmp = menu_requestdir("Select Rom Directory",romdir);
if(tmp){
free(romdir);
romdir = tmp;
}
goto start;
case 16: /* Cancel */
return ret;
break;
case 14: /* Apply */
case 15: /* 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;
}
red1 = ((85 + (xcolor * 17)) * (xbright * 0.1));
red2 = ((85 - (xcolor * 8.5)) * (xbright * 0.1));
red3 = ((85 - (xcolor * 8.5)) * (xbright * 0.1));
red4 = (255 - (xcontrast * 25.5));
green1 = ((85 - (xcolor * 8.5)) * (xbright * 0.1));
green2 = ((85 + (xcolor * 17)) * (xbright * 0.1));
green3 = ((85 - (xcolor * 8.5)) * (xbright * 0.1));
green4 = (255 - (xcontrast * 25.5));
blue1 = ((85 - (xcolor * 8.5)) * (xbright * 0.1));
blue2 = ((85 - (xcolor * 8.5)) * (xbright * 0.1));
blue3 = ((85 + (xcolor * 17)) * (xbright * 0.1));
blue4 = (255 - (xcontrast * 25.5));
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 border %i", border);
sprintf(config[10],"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[11], "set romdir \"%s\"", tmp_path);
}
#else
sprintf(config[11],"set romdir \"%s\"",romdir);
#endif /* DINGOO_NATIVE */
sprintf(config[12],"set xcolor %i", xcolor);
sprintf(config[13],"set xbright %i", xbright);
sprintf(config[14],"set xcontrast %i", xcontrast);
sprintf(config[15],"set red %i %i %i %i", red1, red2, red3, red4);
sprintf(config[16],"set green %i %i %i %i", green1, green2, green3, green4);
sprintf(config[17],"set blue %i %i %i %i", blue1, blue2, blue3, blue4);
for(i=0; i<18; i++)
rc_command(config[i]);
pal_dirty();
if (ret == 15){ /* Apply & Save */
file = fopen("ohboy.rc","w");
for(i=0; i<18; i++){
fputs(config[i],file);
fputs("\n",file);
}
fclose(file);
}
vid_init();
scaler_init(0);
break;
}
free(romdir);
return ret;
}
Marcadores