mirror of
https://github.com/Oibaf66/fbzx-wii.git
synced 2024-11-28 11:04:15 +01:00
Added general configuration management
This commit is contained in:
parent
a93b567fda
commit
b81feb3573
@ -494,22 +494,16 @@ void load_main_game(char *nombre) {
|
||||
}
|
||||
}
|
||||
|
||||
void save_config(struct computer *object) {
|
||||
int save_config(struct computer *object, char *filename) {
|
||||
|
||||
char config_path[1024];
|
||||
int length;
|
||||
unsigned char key, joy_n;
|
||||
FILE *fconfig;
|
||||
|
||||
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,"wb");
|
||||
fconfig = fopen(filename,"wb");
|
||||
if (fconfig==NULL) {
|
||||
return;
|
||||
return -2; // can't create file
|
||||
}
|
||||
|
||||
fprintf(fconfig,"mode=%c%c",48+object->mode128k,10);
|
||||
fprintf(fconfig,"issue=%c%c",48+object->issue,10);
|
||||
fprintf(fconfig,"joystick1=%c%c",48+object->joystick[0],10);
|
||||
@ -533,6 +527,7 @@ void save_config(struct computer *object) {
|
||||
fprintf(fconfig,"joybutton_%c_%c=%.3d%c",joy_n+48,key+97, object->joybuttonkey[joy_n][key],10);
|
||||
|
||||
fclose(fconfig);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
@ -642,21 +637,13 @@ int load_config(struct computer *object, char *filename) {
|
||||
|
||||
char config_path[1024];
|
||||
char line[1024],carac,done;
|
||||
int length,pos, key_sdl=0;
|
||||
int pos, key_sdl=0;
|
||||
FILE *fconfig;
|
||||
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");
|
||||
}
|
||||
else return -2;
|
||||
|
||||
fconfig = fopen(config_path,"rb");
|
||||
if (fconfig==NULL) {
|
||||
@ -816,9 +803,11 @@ int load_config(struct computer *object, char *filename) {
|
||||
int main(int argc,char *argv[]) {
|
||||
|
||||
int bucle,tstados,argumento,fullscreen,dblbuffer,hwsurface,length;
|
||||
char gamefile[4096];
|
||||
char gamefile[4096],config_path[1024] ;
|
||||
|
||||
word PC=0;
|
||||
|
||||
|
||||
// by default, try all sound modes
|
||||
sound_type=SOUND_AUTOMATIC;
|
||||
gamefile[0]=0;
|
||||
@ -868,7 +857,14 @@ int main(int argc,char *argv[]) {
|
||||
set_volume(16);
|
||||
|
||||
// load current config
|
||||
load_config(&ordenador, NULL);
|
||||
strcpy(config_path,getenv("HOME"));
|
||||
length=strlen(config_path);
|
||||
if ((length>0)&&(config_path[length-1]!='/'))
|
||||
strcat(config_path,"/");
|
||||
strcat(config_path,"fbzx.conf");
|
||||
|
||||
load_config(&ordenador, config_path);
|
||||
|
||||
printf("Modo: %d\n",ordenador.mode128k);
|
||||
while(argumento<argc) {
|
||||
if ((0==strcmp(argv[argumento],"-h"))||(0==strcmp(argv[argumento],"--help"))) {
|
||||
|
@ -44,7 +44,7 @@ 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(struct computer *object, char *filename);
|
||||
int save_config_game(struct computer *object, char *filename, int overwrite);
|
||||
FILE *myfopen(char *filename,char *mode);
|
||||
|
||||
|
138
src/gui_sdl.c
138
src/gui_sdl.c
@ -62,9 +62,9 @@ static const char *main_menu_messages[] = {
|
||||
/*05*/ "Wiimote configuration",
|
||||
/*06*/ "^|Wiimote1|Wiimote2",
|
||||
/*07*/ "Emulation settings",
|
||||
/*08*/ "Microdrive",
|
||||
/*09*/ "Tools",
|
||||
/*10*/ "Confs files",
|
||||
/*08*/ "Confs files",
|
||||
/*09*/ "Microdrive",
|
||||
/*10*/ "Tools",
|
||||
/*11*/ "Reset",
|
||||
/*12*/ "Help",
|
||||
/*13*/ "Quit",
|
||||
@ -153,13 +153,14 @@ static const char *help_messages[] = {
|
||||
};
|
||||
|
||||
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",
|
||||
/*00*/ "General configurations",
|
||||
/*01*/ "^|Load|Save|Delete",
|
||||
/*02*/ " ",
|
||||
/*03*/ "Game configurations",
|
||||
/*04*/ "^|Load|Save|Delete",
|
||||
/*05*/ " ",
|
||||
/*06*/ "Load confs automatically",
|
||||
/*07*/ "^|on|off",
|
||||
NULL
|
||||
};
|
||||
|
||||
@ -905,7 +906,7 @@ static void save_load_snapshot(int which)
|
||||
}
|
||||
}
|
||||
|
||||
static void save_load_configurations(int which)
|
||||
static void save_load_game_configurations(int which)
|
||||
{
|
||||
const char *dir = path_confs;
|
||||
const char *tape = ordenador.last_selected_file;
|
||||
@ -914,18 +915,6 @@ static void save_load_configurations(int which)
|
||||
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:
|
||||
@ -940,7 +929,7 @@ static void save_load_configurations(int which)
|
||||
{
|
||||
if (which == 0) // Load config file
|
||||
{
|
||||
if (!load_config(&ordenador,db)) msgInfo("Configurations loaded",3000,NULL);
|
||||
if (!load_config(&ordenador,db)) msgInfo("Game confs loaded",3000,NULL);
|
||||
break;
|
||||
}
|
||||
else // Delete config file
|
||||
@ -949,18 +938,35 @@ static void save_load_configurations(int which)
|
||||
free((void*)filename);
|
||||
} break;
|
||||
case 1: // Save configuration file
|
||||
|
||||
// Name (for game config saves) - TO CHECK
|
||||
if (tape && strrchr(tape, '/'))
|
||||
strncpy(fb, strrchr(tape, '/') + 1, 80);
|
||||
else
|
||||
{
|
||||
msgInfo("No file selected",3000,NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
//remove the extension
|
||||
ptr = strrchr (fb, '.');
|
||||
|
||||
if (ptr) *ptr = 0;
|
||||
|
||||
snprintf(db, 255, "%s/%s.conf", dir, fb);
|
||||
|
||||
retorno=save_config_game(&ordenador,db,0);
|
||||
|
||||
switch(retorno)
|
||||
{
|
||||
case 0: //OK
|
||||
msgInfo("Configurations saved",3000,NULL);
|
||||
msgInfo("Game confs 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);
|
||||
msgInfo("Game confs saved",3000,NULL);
|
||||
}
|
||||
break;
|
||||
case -2:
|
||||
@ -972,31 +978,87 @@ static void save_load_configurations(int which)
|
||||
break;
|
||||
}
|
||||
}
|
||||
static void save_load_general_configurations(int which)
|
||||
{
|
||||
|
||||
int retorno;
|
||||
unsigned char old_bw,old_model;
|
||||
char config_path[1024];
|
||||
int length;
|
||||
FILE *fconfig;
|
||||
|
||||
strcpy(config_path,getenv("HOME"));
|
||||
length=strlen(config_path);
|
||||
if ((length>0)&&(config_path[length-1]!='/'))
|
||||
strcat(config_path,"/");
|
||||
strcat(config_path,"fbzx.conf");
|
||||
|
||||
switch(which)
|
||||
{
|
||||
case 2:
|
||||
case 0: // Load or delete file
|
||||
{
|
||||
fconfig = fopen(config_path,"r");
|
||||
if (fconfig==NULL)
|
||||
{
|
||||
msgInfo("Can not access the file",3000,NULL);
|
||||
return;
|
||||
}
|
||||
else fclose(fconfig);
|
||||
|
||||
if (which == 0) // Load config file
|
||||
{
|
||||
old_bw = ordenador.bw;
|
||||
old_model= get_machine_model();
|
||||
if (!load_config(&ordenador,config_path)) msgInfo("General confs loaded",3000,NULL);
|
||||
if (old_bw!=ordenador.bw) computer_set_palete();
|
||||
if (old_model != get_machine_model()) ResetComputer();
|
||||
break;
|
||||
}
|
||||
else // Delete config file
|
||||
if (msgYesNo("Delete the file?", 0, FULL_DISPLAY_X /2-138, FULL_DISPLAY_Y /2-48)) unlink(config_path);
|
||||
|
||||
} break;
|
||||
case 1: // Save configuration file
|
||||
retorno=save_config(&ordenador,config_path);
|
||||
|
||||
switch(retorno)
|
||||
{
|
||||
case 0: //OK
|
||||
msgInfo("General confs 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];
|
||||
int submenus[3];
|
||||
|
||||
memset(submenus, 0, sizeof(submenus));
|
||||
|
||||
submenus[1]=!ordenador.autoconf;
|
||||
submenus[2]=!ordenador.autoconf;
|
||||
|
||||
opt = menu_select_title("Configurations file menu",
|
||||
confs_messages, submenus);
|
||||
if (opt < 0)
|
||||
return;
|
||||
|
||||
ordenador.autoconf=!submenus[1];
|
||||
ordenador.autoconf=!submenus[2];
|
||||
|
||||
switch(opt)
|
||||
{
|
||||
case 0: // Save general configurations
|
||||
save_config(&ordenador);
|
||||
msgInfo("Configurations saved",3000,NULL);
|
||||
case 0: // Save, load and delete general configurations
|
||||
save_load_general_configurations(submenus[0]);
|
||||
break;
|
||||
case 2: // Save, load and delete game configurations
|
||||
save_load_configurations(submenus[0]);
|
||||
case 3: // Save, load and delete game configurations
|
||||
save_load_game_configurations(submenus[1]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -1038,13 +1100,13 @@ void main_menu()
|
||||
emulation_settings();
|
||||
break;
|
||||
case 8:
|
||||
microdrive();
|
||||
manage_configurations();
|
||||
break;
|
||||
case 9:
|
||||
tools();
|
||||
microdrive();
|
||||
break;
|
||||
case 10:
|
||||
manage_configurations();
|
||||
tools();
|
||||
break;
|
||||
case 11:
|
||||
ResetComputer ();
|
||||
@ -1064,7 +1126,7 @@ void main_menu()
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} while (opt == 5 || opt == 7 || opt == 8 || opt == 12);
|
||||
} while (opt == 5 || opt == 7 || opt == 9 || opt == 12);
|
||||
|
||||
clean_screen();
|
||||
|
||||
|
73
src/z80free/README_test.txt
Normal file
73
src/z80free/README_test.txt
Normal file
@ -0,0 +1,73 @@
|
||||
File formats
|
||||
============
|
||||
|
||||
tests.in
|
||||
--------
|
||||
|
||||
Each test has the format:
|
||||
|
||||
<arbitrary test description>
|
||||
AF BC DE HL AF' BC' DE' HL' IX IY SP PC
|
||||
I R IFF1 IFF2 IM <halted> <tstates>
|
||||
|
||||
<halted> specifies whether the Z80 is halted.
|
||||
<tstates> specifies the number of tstates to run the test for, in
|
||||
decimal; the number actually executed may be higher, as the final
|
||||
instruction is allowed to complete.
|
||||
|
||||
Then followed by lines specifying the initial memory setup. Each has
|
||||
the format:
|
||||
|
||||
<start address> <byte1> <byte2> ... -1
|
||||
|
||||
eg
|
||||
|
||||
1234 56 78 9a -1
|
||||
|
||||
says to put 0x56 at 0x1234, 0x78 at 0x1235 and 0x9a at 0x1236.
|
||||
|
||||
Finally, -1 to end the test. Blank lines may follow before the next test.
|
||||
|
||||
tests.expected
|
||||
--------------
|
||||
|
||||
Each test output starts with the test description, followed by a list
|
||||
of 'events': each has the format
|
||||
|
||||
<time> <type> <address> <data>
|
||||
|
||||
<time> is simply the time at which the event occurs.
|
||||
<type> is one of MR (memory read), MW (memory write), MC (memory
|
||||
contend), PR (port read), PW (port write) or PC (port contend).
|
||||
<address> is the address (or IO port) affected.
|
||||
<data> is the byte written or read. Missing for contentions.
|
||||
|
||||
After that, lines specifying AF, BC etc as for .in files. <tstates>
|
||||
now specifies the final time.
|
||||
|
||||
After that, lines specifying which bits of memory have changed since
|
||||
the initial setup. Same format as for .in files.
|
||||
|
||||
Why some specific tests are here
|
||||
================================
|
||||
|
||||
37_{1,2,3}: check the behaviour of SCF with respect to bits 3 and 5
|
||||
(bug fixed on 20040225).
|
||||
|
||||
cb{4,5,6,7}{7,f}_1: designed to check that bits 3 and 5 are copied to
|
||||
F only for BIT 3,<arg> and BIT 5,<arg> respectively
|
||||
(bug fixed on 20040225).
|
||||
|
||||
However, later research has revealed the bits 3
|
||||
and 5 are copied on all BIT instructions, so these
|
||||
tests are now essentially redundant.
|
||||
|
||||
d{3,b}_{1,2,3}: check for correct port contention on IO in the four
|
||||
relevant states (port high byte in 0x40 to 0x7f or not,
|
||||
port low bit set or reset).
|
||||
|
||||
dd00.in, ddfd00.in: test timings of "extended NOP" opcodes DD 00 and
|
||||
DD FD 00; the extra 00 at the end is to check the
|
||||
next opcode executes at the right time (bug fixed
|
||||
on 20060722).
|
||||
|
Loading…
Reference in New Issue
Block a user