void set_defsystemkeys(void){ set_systemkeys(KEY_F12,KEY_F1,KEY_F4,KEY_F5,KEY_F8,KEY_F2,KEY_F3,KEY_F6); }
int parse_option(char *attr, char *val){ int t; if (!strcmp(attr,"nolimit")) { app_data.limit = !(val[0]!='0'); } else if (!strcmp(attr,"nosound")) { app_data.sound_en = !(val[0]!='0'); } else if (!strcmp(attr,"novoice")) { app_data.voice = !(val[0]!='0'); } else if (!strcmp(attr,"filter")) { app_data.filter = (val[0]!='0'); } else if (!strcmp(attr,"debug")) { app_data.debug = (val[0]!='0'); } else if ((!strcmp(attr,"s1")) || (!strcmp(attr,"s2"))) { int sn; sn = (!strcmp(attr,"s1"))? 0 : 1; if (strlen(val)<2){ t = -1; sscanf(val,"%d",&t); if ((t>=0) && (t<=3)) { if ((t==1)||(t==2)){ app_data.stick[sn] = 1; set_defjoykeys(sn,t-1); } else { app_data.stick[sn] = (t==0) ? 0 : 2; if (t==3) { app_data.sticknumber[sn] = app_data.sticknumber[0]+app_data.sticknumber[1]+1; } set_joykeys(sn,0,0,0,0,0); } } else { fprintf(stderr,"Invalid value for option %s\n",attr); return 0; } } else { char *p,*s; int i,k,code,nk,codes[5]; strupr(val); nk = 0; p = strtok(val,","); while (p) { i = code = 0; k = keybtab[i].keybcode; s = keybtab[i].keybname; while (k && (code==0)) { if (strcmp(s,p)==0) code = k; i++; k = keybtab[i].keybcode; s = keybtab[i].keybname; } if (!code) { fprintf(stderr,"Invalid value for option %s : key %s unknown\n",attr,p); return 0; } codes[nk] = code; p = strtok(NULL,","); nk++; if (nk>5) { fprintf(stderr,"Invalid value for option %s : invalid number of keys\n",attr); return 0; } } if (nk != 5) { fprintf(stderr,"Invalid value for option %s : invalid number of keys\n",attr); return 0; } app_data.stick[sn] = 1; set_joykeys(sn,codes[0],codes[1],codes[2],codes[3],codes[4]); } } else if (!strcmp(attr,"s0")) { char *p,*s; int i,k,code,nk,codes[8]; strupr(val); nk = 0; p = strtok(val,","); while (p) { i = code = 0; k = keybtab[i].keybcode; s = keybtab[i].keybname; while (k && (code==0)) { if (strcmp(s,p)==0) code = k; i++; k = keybtab[i].keybcode; s = keybtab[i].keybname; } if (!code) { fprintf(stderr,"Invalid value for option %s : key %s unknown\n",attr,p); return 0; } codes[nk] = code; p = strtok(NULL,","); nk++; if (nk>8) { fprintf(stderr,"Invalid value for option %s : invalid number of keys\n",attr); return 0; } } if (nk != 8) { fprintf(stderr,"Invalid value for option %s : invalid number of keys\n",attr); return 0; } set_systemkeys(codes[0],codes[1],codes[2],codes[3],codes[4],codes[5],codes[6],codes[7]); } else if (!strcmp(attr,"speed")) { t = -1; sscanf(val,"%d",&t); if ((t>0) && (t<=10000)) app_data.speed = t; else { fprintf(stderr,"Invalid value for option %s\n",attr); return 0; } } else if (!strcmp(attr,"svolume")) { t = -1; sscanf(val,"%d",&t); if ((t>=0) && (t<=100)) app_data.svolume = t; else { fprintf(stderr,"Invalid value for option %s\n",attr); return 0; } if (t==0) app_data.sound_en=0; } else if (!strcmp(attr,"vvolume")) { t = -1; sscanf(val,"%d",&t); if ((t>=0) && (t<=100)) app_data.vvolume = t; else { fprintf(stderr,"Invalid value for option %s\n",attr); return 0; } if (t==0) app_data.voice=0; } else if (!strcmp(attr,"wsize")) { t = -1; sscanf(val,"%d",&t); if ((t>0) && (t<5)) { app_data.wsize = t; app_data.fullscreen = 0; } else { fprintf(stderr,"Invalid value for option %s\n",attr); return 0; } } else if (!strcmp(attr,"fullscreen")) { app_data.fullscreen = (val[0]!='0'); } else if (!strcmp(attr,"scanlines")) { app_data.scanlines = (val[0]!='0'); } else if (!strcmp(attr,"scshot")) { strcpy(scshot,val); } else if (!strcmp(attr,"savefile")) { strcpy(statefile,val); } else if (!strcmp(attr,"biosdir")) { strcpy(xbios,val); } else if (!strcmp(attr,"bios")) { strcpy(bios,val); } else if (!strcmp(attr,"romdir")) { strcpy(xrom,val); } else if (!strcmp(attr,"help")) { helpflag = 1; } else if (!strcmp(attr,"euro")) { app_data.euro = (val[0]!='0'); } else if (!strcmp(attr,"exrom")) { app_data.exrom = (val[0]!='0'); } else if (!strcmp(attr,"3k")) { app_data.three_k = (val[0]!='0'); } else if (!strcmp(attr,"g7400")){ strcpy(bios,"g7400"); } else if (!strcmp(attr,"c52")) { strcpy(bios,"c52"); } else if (!strcmp(attr,"jopac")) { strcpy(bios,"jopac"); } else if (!strcmp(attr,"o2rom")) { strcpy(bios,"o2rom"); } else if (!strcmp(attr,"scorefile")) { strcpy(scorefile,val); } else if (!strcmp(attr,"scoreadr")) { t = -1; sscanf(val,"%d",&t); if ((t>=0) && (t<=255)) app_data.scoreaddress = t; else { fprintf(stderr,"Invalid value for option %s\n",attr); return 0; } } else if (!strcmp(attr,"scoretype")) { t = -1; sscanf(val,"%d",&t); if ((t>=0) && (t<=9999)) app_data.scoretype = t; else { fprintf(stderr,"Invalid value for option %s\n",attr); return 0; } } else if (!strcmp(attr,"score")) { t = -1; sscanf(val,"%d",&t); if ((t>=0) && (t<=999999)) app_data.default_highscore = t; else { fprintf(stderr,"Invalid value for option %s\n",attr); return 0; } } else { if (!helpflag){ fprintf(stderr,"Invalid option : %s\n",attr); return 0; } } return 1; }