2 // This file is part of the PicoDrive Megadrive Emulator
\r
4 // Copyright (c) 2011 FinalDave (emudave (at) gmail.com)
\r
6 // This code is licensed under the GNU General Public License version 2.0 and the MAME License.
\r
7 // You can choose the license that has the most advantages for you.
\r
9 // SVN repository can be found at http://code.google.com/p/cyclone68000/
\r
13 static char *ConfigName="\\PicoConfig.txt";
\r
14 struct Config Config;
\r
18 memset(&Config,0,sizeof(Config));
\r
20 Config.key[0]=VK_UP;
\r
21 Config.key[1]=VK_DOWN;
\r
22 Config.key[2]=VK_LEFT;
\r
23 Config.key[3]=VK_RIGHT;
\r
24 Config.key[4]=GXKey.vkC; // A
\r
25 Config.key[5]=GXKey.vkA; // B
\r
26 Config.key[6]=GXKey.vkB; // C
\r
27 Config.key[7]=GXKey.vkStart;
\r
37 // Open config file:
\r
38 f=fopen(ConfigName,"wt"); if (f==NULL) return 1;
\r
40 fprintf(f,"// PicoDrive Config File\n\n");
\r
42 fprintf(f,"// Keys: Up Down Left Right\n");
\r
43 fprintf(f,"// A B C Start\n\n");
\r
45 max=sizeof(Config.key)/sizeof(Config.key[0]);
\r
48 fprintf(f,"key,%d,0x%.2x\n",i,Config.key[i]);
\r
62 memset(line,0,sizeof(line));
\r
64 // Open config file:
\r
65 f=fopen(ConfigName,"rt"); if (f==NULL) return 1;
\r
67 // Read through each line of the config file
\r
70 char *tok[3]={"","",""};
\r
71 if (fgets(line,sizeof(line)-1,f)==NULL) break;
\r
73 // Split line into tokens:
\r
76 tok[i]=strtok(i<1?line:NULL, ",\r\n");
\r
77 if (tok[i]==NULL) { tok[i]=""; break; }
\r
80 if (_stricmp(tok[0],"key")==0)
\r
85 ta=strtol(tok[1],NULL,0);
\r
86 tb=strtol(tok[2],NULL,0);
\r
88 Config.key[ta&7]=tb;
\r