mirror of
https://github.com/Oibaf66/fbzx-wii.git
synced 2024-10-31 22:35:06 +01:00
Added game configurations
This commit is contained in:
parent
eaaffd9492
commit
e5dda6bb45
2
Makefile
2
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:
|
||||
|
@ -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() {
|
||||
|
@ -213,7 +213,7 @@ struct computer {
|
||||
unsigned char SmbPwd[32];
|
||||
unsigned char SmbShare[32];
|
||||
unsigned char SmbIp[32];
|
||||
|
||||
unsigned char autoconf;
|
||||
};
|
||||
|
||||
void computer_init();
|
||||
|
@ -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(argumento<argc) {
|
||||
if ((0==strcmp(argv[argumento],"-h"))||(0==strcmp(argv[argumento],"--help"))) {
|
||||
@ -977,10 +1026,12 @@ int main(int argc,char *argv[]) {
|
||||
strcpy(path_taps,path_snaps);
|
||||
strcpy(path_mdrs,path_snaps);
|
||||
strcpy(path_scr,path_snaps);
|
||||
strcpy(path_confs,path_snaps);
|
||||
strcat(path_snaps,"snapshots");
|
||||
strcat(path_taps,"tapes");
|
||||
strcat(path_mdrs,"microdrives");
|
||||
strcat(path_scr,"scr");
|
||||
strcat(path_confs,"configurations");
|
||||
|
||||
#ifdef GEKKO
|
||||
if ((ordenador.port==1)&&usbismount) {
|
||||
|
@ -36,13 +36,16 @@ extern char path_snaps[2049];
|
||||
extern char path_taps[2049];
|
||||
extern char path_mdrs[2049];
|
||||
extern char path_scr[2049];
|
||||
extern char path_confs[2049];
|
||||
extern unsigned int colors[80];
|
||||
extern unsigned int jump_frames,curr_frames;
|
||||
|
||||
void SDL_Fullscreen_Switch(void);
|
||||
void load_rom(char);
|
||||
void load_main_game(char *nombre);
|
||||
int load_config(struct computer *object, char *filename);
|
||||
void save_config(struct computer *object);
|
||||
int save_config_game(struct computer *object, char *filename, int overwrite);
|
||||
FILE *myfopen(char *filename,char *mode);
|
||||
|
||||
#endif
|
||||
|
140
src/gui_sdl.c
140
src/gui_sdl.c
@ -64,7 +64,7 @@ static const char *main_menu_messages[] = {
|
||||
/*07*/ "Emulation settings",
|
||||
/*08*/ "Microdrive",
|
||||
/*09*/ "Tools",
|
||||
/*10*/ "Save confs",
|
||||
/*10*/ "Confs files",
|
||||
/*11*/ "Reset",
|
||||
/*12*/ "Help",
|
||||
/*13*/ "Quit",
|
||||
@ -152,6 +152,40 @@ static const char *help_messages[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const char *confs_messages[] = {
|
||||
/*00*/ "Save general configs",
|
||||
/*01*/ " ",
|
||||
/*02*/ "Game configurations",
|
||||
/*03*/ "^|Load|Save|Delete",
|
||||
/*04*/ " ",
|
||||
/*05*/ "Load confs automatically",
|
||||
/*06*/ "^|on|off",
|
||||
NULL
|
||||
};
|
||||
|
||||
void maybe_load_conf(const char *filename)
|
||||
{
|
||||
const char *dir = path_confs;
|
||||
char *ptr;
|
||||
char db[256];
|
||||
char fb[81];
|
||||
|
||||
if (filename==NULL) return;
|
||||
|
||||
if (strrchr(filename, '/'))
|
||||
strncpy(fb, strrchr(filename, '/') + 1, 80);
|
||||
else
|
||||
strncpy(fb, filename, 80);
|
||||
|
||||
//remove the extension
|
||||
ptr = strrchr (fb, '.');
|
||||
if (ptr) *ptr = 0;
|
||||
|
||||
snprintf(db, 255, "%s/%s.conf", dir, fb);
|
||||
if (!load_config(&ordenador,db)) msgInfo("Configurations loaded",2000,NULL) ;
|
||||
|
||||
}
|
||||
|
||||
static void insert_tape()
|
||||
{
|
||||
unsigned char char_id[11];
|
||||
@ -198,6 +232,7 @@ static void insert_tape()
|
||||
case 0: // all right
|
||||
strcpy(ordenador.current_tap,filename);
|
||||
strcpy(ordenador.last_selected_file,filename);
|
||||
if (ordenador.autoconf) maybe_load_conf(filename);
|
||||
break;
|
||||
case -1:
|
||||
msgInfo("Error: Can't load that file",3000,NULL);
|
||||
@ -819,6 +854,7 @@ static void save_load_snapshot(int which)
|
||||
switch(retorno) {
|
||||
case 0: // all right
|
||||
strcpy(ordenador.last_selected_file,filename);
|
||||
if (ordenador.autoconf) maybe_load_conf(filename);
|
||||
break;
|
||||
case -1:
|
||||
msgInfo("Error: Can't load that file",3000,NULL);
|
||||
@ -858,6 +894,105 @@ static void save_load_snapshot(int which)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void save_load_configurations(int which)
|
||||
{
|
||||
const char *dir = path_confs;
|
||||
const char *tape = ordenador.last_selected_file;
|
||||
char *ptr;
|
||||
char db[256];
|
||||
char fb[81];
|
||||
int retorno;
|
||||
|
||||
// Name (for saves) - TO CHECK
|
||||
if (tape && strrchr(tape, '/'))
|
||||
strncpy(fb, strrchr(tape, '/') + 1, 80);
|
||||
else
|
||||
strcpy(fb, "unknown");
|
||||
|
||||
//remove the extension
|
||||
ptr = strrchr (fb, '.');
|
||||
if (ptr) *ptr = 0;
|
||||
|
||||
snprintf(db, 255, "%s/%s.conf", dir, fb);
|
||||
|
||||
switch(which)
|
||||
{
|
||||
case 2:
|
||||
case 0: // Load or delete file
|
||||
{
|
||||
const char *filename = menu_select_file(dir, NULL,-1);
|
||||
|
||||
if (!filename)
|
||||
return;
|
||||
|
||||
if (ext_matches(filename, ".conf")|ext_matches(filename, ".CONF"))
|
||||
{
|
||||
if (which == 0) // Load config file
|
||||
{
|
||||
if (!load_config(&ordenador,db)) msgInfo("Configurations loaded",3000,NULL);
|
||||
break;
|
||||
}
|
||||
else // Delete config file
|
||||
if (msgYesNo("Delete the file?", 0, FULL_DISPLAY_X /2-138, FULL_DISPLAY_Y /2-48)) unlink(filename);
|
||||
}
|
||||
free((void*)filename);
|
||||
} break;
|
||||
case 1: // Save configuration file
|
||||
retorno=save_config_game(&ordenador,db,0);
|
||||
|
||||
switch(retorno)
|
||||
{
|
||||
case 0: //OK
|
||||
msgInfo("Configurations saved",3000,NULL);
|
||||
break;
|
||||
case -1:
|
||||
if (msgYesNo("Overwrite the exiting file?", 0, FULL_DISPLAY_X /2-160, FULL_DISPLAY_Y /2-48))
|
||||
{
|
||||
save_config_game(&ordenador,db,1); //force overwrite
|
||||
msgInfo("Configurations saved",3000,NULL);
|
||||
}
|
||||
break;
|
||||
case -2:
|
||||
msgInfo("Can't create file",3000,NULL);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void manage_configurations()
|
||||
{
|
||||
int opt ;
|
||||
int submenus[2];
|
||||
|
||||
memset(submenus, 0, sizeof(submenus));
|
||||
|
||||
submenus[1]=!ordenador.autoconf;
|
||||
|
||||
opt = menu_select_title("Configurations file menu",
|
||||
confs_messages, submenus);
|
||||
if (opt < 0)
|
||||
return;
|
||||
|
||||
ordenador.autoconf=!submenus[1];
|
||||
|
||||
switch(opt)
|
||||
{
|
||||
case 0: // Save general configurations
|
||||
save_config(&ordenador);
|
||||
msgInfo("Configurations saved",3000,NULL);
|
||||
break;
|
||||
case 2: // Save, load and delete game configurations
|
||||
save_load_configurations(submenus[0]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void help(void)
|
||||
{
|
||||
@ -899,8 +1034,7 @@ void main_menu()
|
||||
tools();
|
||||
break;
|
||||
case 10:
|
||||
save_config(&ordenador);
|
||||
msgInfo("Configurations saved",3000,NULL);
|
||||
manage_configurations();
|
||||
break;
|
||||
case 11:
|
||||
ResetComputer ();
|
||||
|
@ -281,7 +281,7 @@ static const char **get_file_list(const char *base_dir)
|
||||
{
|
||||
char buf[255];
|
||||
const char *exts[] = {".tap", ".TAP", ".tzx", ".TZX", ".z80",".Z80",".sna", ".SNA",
|
||||
".mdr", ".MDR", ".scr", ".SCR", NULL};
|
||||
".mdr", ".MDR", ".scr", ".SCR", ".conf", ".CONF",NULL};
|
||||
struct stat st;
|
||||
|
||||
snprintf(buf, 255, "%s/%s", base_dir, de->d_name);
|
||||
|
Loading…
Reference in New Issue
Block a user