diff --git a/Makefile b/Makefile index 52c0100..35729c2 100644 --- a/Makefile +++ b/Makefile @@ -118,6 +118,7 @@ dist: $(BUILD) mkdir -p $@/fbzx-wii/snapshots mkdir -p $@/fbzx-wii/microdrives mkdir -p $@/fbzx-wii/scr + mkdir -p $@/fbzx-wii/configurations mkdir -p $@/apps/fbzx-wii/doc cp fbzx.dol $@/apps/fbzx-wii/boot.dol cp meta.xml $@/apps/fbzx-wii/meta.xml @@ -132,6 +133,7 @@ dist: $(BUILD) touch $@/fbzx-wii/snapshots/dummy touch $@/fbzx-wii/microdrives/dummy touch $@/fbzx-wii/scr/dummy + touch $@/fbzx-wii/configurations/dummy cd $@ && tar -czf ../fbzx-wii-vx-bin.tar.gz * distsource: diff --git a/src/computer.c b/src/computer.c index 25237a7..032ceba 100644 --- a/src/computer.c +++ b/src/computer.c @@ -143,7 +143,7 @@ void computer_init () { strcpy (ordenador.SmbPwd, "Password"); strcpy (ordenador.SmbShare, "Share"); strcpy (ordenador.SmbIp, "192.168.0.1"); - + ordenador.autoconf=0; } void computer_set_palete() { diff --git a/src/computer.h b/src/computer.h index 30de42c..9e56afe 100644 --- a/src/computer.h +++ b/src/computer.h @@ -213,7 +213,7 @@ struct computer { unsigned char SmbPwd[32]; unsigned char SmbShare[32]; unsigned char SmbIp[32]; - + unsigned char autoconf; }; void computer_init(); diff --git a/src/emulator.c b/src/emulator.c index 6780347..0a3dd96 100644 --- a/src/emulator.c +++ b/src/emulator.c @@ -67,6 +67,7 @@ char path_snaps[2049]; char path_taps[2049]; char path_mdrs[2049]; char path_scr[2049]; +char path_confs[2049]; unsigned int colors[80]; unsigned int jump_frames,curr_frames; char *filenames[5]; @@ -527,6 +528,7 @@ void save_config(struct computer *object) { fprintf(fconfig,"rumble1=%c%c",48+object->rumble[0],10); fprintf(fconfig,"rumble2=%c%c",48+object->rumble[1],10); fprintf(fconfig,"port=%c%c",48+object->port,10); + fprintf(fconfig,"autoconf=%c%c",48+object->autoconf,10); for (joy_n=0; joy_n<2; joy_n++) @@ -537,6 +539,39 @@ void save_config(struct computer *object) { } +int save_config_game(struct computer *object, char *filename, int overwrite) { + + unsigned char key, joy_n; + FILE *fconfig; + + fconfig=fopen(filename,"r"); + if((fconfig!=NULL)&&(!overwrite)) { + fclose(fconfig); + return -1; // file already exists + } + + fconfig = fopen(filename,"wb"); + if (fconfig==NULL) { + return -2; // can't create file + } + + fprintf(fconfig,"joystick1=%c%c",48+object->joystick[0],10); + fprintf(fconfig,"joystick2=%c%c",48+object->joystick[1],10); + fprintf(fconfig,"ay_sound=%c%c",48+object->ay_emul,10); + fprintf(fconfig,"joypad1=%c%c",48+object->joypad_as_joystick[0],10); + fprintf(fconfig,"joypad2=%c%c",48+object->joypad_as_joystick[1],10); + fprintf(fconfig,"rumble1=%c%c",48+object->rumble[0],10); + fprintf(fconfig,"rumble2=%c%c",48+object->rumble[1],10); + + for (joy_n=0; joy_n<2; joy_n++) + for (key=0; key<22; key++) + fprintf(fconfig,"joybutton_%c_%c=%.3d%c",joy_n+48,key+97, object->joybuttonkey[joy_n][key],10); + + fclose(fconfig); + return 0; + +} + void load_config_smb(struct computer *object) { char line[1024],carac,done; @@ -606,23 +641,29 @@ void load_config_smb(struct computer *object) { fclose(fconfig); } -void load_config(struct computer *object) { +int load_config(struct computer *object, char *filename) { char config_path[1024]; char line[1024],carac,done; int length,pos, key_sdl=0; FILE *fconfig; - unsigned char volume=16,mode128k=255,issue=255,joystick1=255,joystick2=255,ay_emul=255,mdr_active=255, - dblscan=255,bw=255, tap_fast=0, joypad1=0, joypad2=0, rumble1=0, rumble2=0, joy_n=0, key_n=0, port=0; + unsigned char volume=255,mode128k=255,issue=255,joystick1=255,joystick2=255,ay_emul=255,mdr_active=255, + dblscan=255,bw=255, tap_fast=255, joypad1=255, joypad2=255, rumble1=255, rumble2=255, joy_n=255, key_n=255, port=255, autoconf=255; + if (filename) strcpy(config_path,filename); + + else + { strcpy(config_path,getenv("HOME")); length=strlen(config_path); if ((length>0)&&(config_path[length-1]!='/')) strcat(config_path,"/"); strcat(config_path,"fbzx_conf"); + } + fconfig = fopen(config_path,"rb"); if (fconfig==NULL) { - return; + return -1; } done=1; @@ -709,6 +750,10 @@ void load_config(struct computer *object) { port=line[5]-'0'; continue; } + if (!strncmp(line,"autoconf=",9)) { + autoconf=line[9]-'0'; + continue; + } if (!strncmp(line,"joybutton_",10)) { sscanf(line, "joybutton_%c_%c=%3d",&joy_n ,&key_n, &key_sdl); if ((joy_n<50) && (joy_n>47) && (key_n<119) && (key_n>96)) @@ -763,8 +808,12 @@ void load_config(struct computer *object) { if (port<3) { object->port=port; } + if (autoconf<2) { + object->autoconf=autoconf; + } fclose(fconfig); + return 0; } int main(int argc,char *argv[]) { @@ -822,7 +871,7 @@ int main(int argc,char *argv[]) { set_volume(16); // load current config - load_config(&ordenador); + load_config(&ordenador, NULL); printf("Modo: %d\n",ordenador.mode128k); while(argumentod_name);