Added hardfile and VFS support in the GUI, removed 2 warnings

This commit is contained in:
fabio.olimpieri 2014-02-08 11:37:04 +00:00
parent 5f1a96e343
commit a00f4ef0b4
9 changed files with 459 additions and 35 deletions

View File

@ -187,13 +187,13 @@ dist:uae.dol
install -d $@/uae
install -d $@/uae/roms
install -d $@/uae/floppies
install -d $@/uae/harddisks
install -d $@/uae/HD
install -d $@/uae/harddir
install -d $@/uae/saves
install -d $@/uae/wave
echo "dummy" > $@/uae/roms/put-your-kick-dot-rom-here
echo "dummy" > $@/uae/floppies/dummy
echo "dummy" > $@/uae/harddisks/dummy
echo "dummy" > $@/uae/HD/dummy
echo "dummy" > $@/uae/harddir/dummy
echo "dummy" > $@/uae/saves/dummy
cp $< $@/apps/uae/boot.dol

View File

@ -37,6 +37,8 @@
//#define DEBUG_AUDIO
#define DEBUG_CHANNEL_MASK 15
extern int is_vsync (void);
int audio_channel_mask = 15;
static int debugchannel (unsigned int ch)

View File

@ -2461,10 +2461,12 @@ void default_prefs (struct uae_prefs *p, int type)
prefs_set_attr ("rom_path", strdup_path_expand (TARGET_ROM_PATH));
#ifdef GEKKO
prefs_set_attr ("floppy_path", strdup(TARGET_FLOPPY_PATH)); //We don't want / at the end of path
prefs_set_attr ("hardfile_path", strdup(TARGET_HARDFILE_PATH));
#else
prefs_set_attr ("floppy_path", strdup_path_expand (TARGET_FLOPPY_PATH));
prefs_set_attr ("hardfile_path", strdup_path_expand (TARGET_HARDFILE_PATH));
#endif
prefs_set_attr ("hardfile_path", strdup_path_expand (TARGET_HARDFILE_PATH));
#ifdef SAVESTATE
prefs_set_attr ("savestate_path", strdup_path_expand (TARGET_SAVESTATE_PATH));
#endif

View File

@ -21,6 +21,7 @@
#include "VirtualKeyboard.h"
#include "sounddep/sound.h"
#include "inputdevice.h"
#include "filesys.h"
#define ID_BUTTON_OFFSET 0
#define ID_AXIS_OFFSET 32
@ -51,10 +52,11 @@ static const char *main_menu_messages[] = {
/*08*/ "Emulation options",
/*09*/ "Audio options",
/*10*/ "Other options",
/*11*/ "Save confs",
/*12*/ "Load confs",
/*13*/ "Reset UAE",
/*14*/ "Quit",
/*11*/ "HD emulation",
/*12*/ "Save confs",
/*13*/ "Load confs",
/*14*/ "Reset UAE",
/*15*/ "Quit",
NULL
};
@ -220,6 +222,79 @@ static const char *load_conf_messages[] = {
NULL
};
static const char *hd_emulation_messages[] = {
/*00*/ "Mount virtual filesystem",
/*01*/ " ",
/*02*/ "Mount RDB hard disk",
/*03*/ " ",
/*04*/ "Mount hard drive partition",
/*05*/ " ",
/*06*/ "Unmount device",
/*07*/ " ",
/*08*/ "Make hardfile",
/*09*/ " ",
/*10*/ "Delete hardfile",
NULL
};
static const char *VFS_configuration_messages[] = {
/*00*/ "Device Name",
/*01*/ "^|DH0|DH1|DH2|DH3|DH4|DH5",
/*02*/ "Volume name",
/*03*/ "^|VFS0|VFS1|VFS2|VFS3|VFS4",
/*04*/ "Access",
/*05*/ "^| RW | RO ",
/*06*/ "Boot priority",
/*07*/ "^| 0 | 1 | 2 | 3 |127|-128",
NULL
};
static const char *partition_configuration_messages[] = {
/*00*/ "Device Name",
/*01*/ "^|DH0|DH1|DH2|DH3|DH4|DH5",
/*02*/ "Access",
/*03*/ "^| RW | RO ",
/*04*/ "Sectors per track",
/*05*/ "^|32|64|128|256",
/*06*/ "Surfaces/heads",
/*07*/ "^| 1 | 2 | 4 | 8 | 16 ",
/*08*/ "Reserved blocks",
/*09*/ "^| 0 | 1 | 2 | 3 | 4 ",
/*10*/ "Block size",
/*11*/ "^|512|1024|2048|4096",
/*12*/ "Boot priority",
/*13*/ "^| 0 | 1 | 2 | 3 |127|-128",
NULL
};
static const char *make_hdf_messages[] = {
/*00*/ "Name",
/*01*/ "^|HDF0|HDF1|HDF2|HDF3|HDF4|HDF5",
/*01*/ "Size",
/*02*/ "^|10M|20M|50M|100M|200M|500M",
/*03*/ "Sectors per track",
/*04*/ "^|32|64|128|256",
/*05*/ "Surfaces/heads",
/*06*/ "^| 1 | 2 | 4 | 8 | 16 ",
/*07*/ "Block size",
/*08*/ "^|512|1024|2048|4096",
NULL
};
static const char *RDB_configuration_messages[] = {
/*04*/ "Access",
/*05*/ "^| RW | RO ",
NULL
};
static const char *device_table[] = {"DH0","DH1","DH2","DH3","DH4","DH5"};
static const char *volume_table[] = {"VFS0","VFS1","VFS2","VFS3","VFS4"};
static const char *hdf_name_table[] = {"HDF0","HDF1","HDF2","HDF3","HDF4","HDF5"};
static const int sector_table[] = {32, 64, 128, 256};
static const int surface_table[] = {1, 2, 4, 8, 16};
static const int blocksize_table[] = {512, 1024, 2048, 4096};
static const int boot_priority_table[] = {0, 1, 2, 3, 127, -128};
static const int hdf_size_table[] = {10*1024*1024,20*1024*1024,50*1024*1024,100*1024*1024,10*1024*1024, 200*1024*1024,500*1024*1024 };
static const int correct_aspect_table[] = {0,100,95,93,90};
static const int cpu_to_chipset_table[] = {0,-1,512*2,512*4, 512*8, 512*12, 512*16, 512*20};
static const int floppy_table[] = {100, 0, 400, 800};
@ -395,6 +470,17 @@ void fix_options_menu_sdl (int printmsg)
#endif
}
int file_exists (const char *name)
{
FILE *f;
f = fopen(name,"rb");
if (!f)
return 0;
fclose (f);
return 1;
}
static int find_index_by_val(int val, const int vec[], int vec_size, int default_val)
{
int i;
@ -553,6 +639,192 @@ static void insert_rom(void)
}
}
static void mount_harddisk(void)
{
#ifdef FILESYS
int submenus[1], opt, access;
submenus[0] = 0; //RW
opt = menu_select_title("RDB configuration menu",
RDB_configuration_messages, submenus);
if (opt < 0)
return;
access = submenus[0];
char *name, *err_msg;
char *ptr_file_name;
char dir[255];
strncpy(dir,prefs_get_attr("hardfile_path"),255);
name = (char *) menu_select_file(dir, NULL, 0);
if (name != NULL)
{
ptr_file_name = strrchr(name,'/');
if (ptr_file_name) ptr_file_name++; else ptr_file_name = name;
if (strcmp(ptr_file_name, "None") == 0)
return;
err_msg= (char *) add_filesys_unit (currprefs.mountinfo, NULL,NULL , name, access, 0, 0, 0, 0, 0,NULL, 0);
if (err_msg) msgInfo(err_msg, 3000, NULL);
free((void*)name);
}
#endif
}
void mount_partition(void)
{
#ifdef FILESYS
int submenus[7], opt;
int access, sector, surfaces, reserved, blocksize, priority;
const char *device;
submenus[0] = 0; //device
submenus[1] = 0; //access
submenus[2] = 0; //sector
submenus[3] = 0; //surfacces
submenus[4] = 2; //reserved
submenus[5] = 0; //blocksize
submenus[6] = 0; //priority
opt = menu_select_title("HD partition configuration menu",
partition_configuration_messages, submenus);
if (opt < 0)
return;
device = device_table[submenus[0]];
access = submenus[1];
sector = sector_table[submenus[2]];
surfaces = surface_table[submenus[3]];
reserved = submenus[4];
blocksize = blocksize_table[submenus[5]];
priority = boot_priority_table[submenus[6]];
char *name, *err_msg;
char *ptr_file_name;
char dir[255];
strncpy(dir,prefs_get_attr("hardfile_path"),255);
name = (char *) menu_select_file(dir, NULL, 0);
if (name != NULL)
{
ptr_file_name = strrchr(name,'/');
if (ptr_file_name) ptr_file_name++; else ptr_file_name = name;
if (strcmp(ptr_file_name, "None") == 0)
return;
err_msg= (char *) add_filesys_unit (currprefs.mountinfo, device ,NULL , name, access, sector, surfaces, reserved, blocksize, priority,NULL, 0);
if (err_msg) msgInfo(err_msg, 3000, NULL);
free((void*)name);
}
#endif
}
static void mount_virtual_file_system(void)
{
#ifdef FILESYS
int submenus[4], opt;
int access, priority;
const char *device, *volume;
submenus[0] = 0; //device
submenus[1] = 0; //volume
submenus[2] = 0; //access
submenus[3] = 5; //priority
opt = menu_select_title("VFS configuration menu",
VFS_configuration_messages, submenus);
if (opt < 0)
return;
device = device_table[submenus[0]];
volume = volume_table[submenus[1]];
access = submenus[2];
priority = boot_priority_table[submenus[3]];
char *err_msg;
err_msg= (char *) add_filesys_unit (currprefs.mountinfo, device,volume , "/uae/harddir", 0, 0, 0, 0, 0, priority, NULL, 0);
if (err_msg) msgInfo(err_msg, 3000, NULL);
#endif
}
static void unmount_device()
{
#ifdef FILESYS
int dev_to_unmount=menu_select_devices();
if (dev_to_unmount==-1) return;
if (kill_filesys_unit (currprefs.mountinfo, dev_to_unmount) == -1)
msgInfo("Volume does not exist", 3000, NULL);
#endif
}
extern int make_hdf(int size, const char *hdf_path, int blocks_per_track, int surfaces, int block_size);
void make_hardfile(void)
{
#ifdef FILESYS
int submenus[5], opt;
int sector, surfaces, blocksize, size;
const char *device, *hdf_name;
submenus[0] = 0; //name
submenus[1] = 0; //size
submenus[2] = 0; //sector
submenus[3] = 0; //surfacces
submenus[4] = 0; //blocksize
opt = menu_select_title("Make hardfile menu",
make_hdf_messages, submenus);
if (opt < 0)
return;
hdf_name = hdf_name_table[submenus[0]];
size = hdf_size_table[submenus[1]];
sector = sector_table[submenus[2]];
surfaces = surface_table[submenus[3]];
blocksize = blocksize_table[submenus[4]];
const char *dir = prefs_get_attr("hardfile_path");
char hdf_path[256];
snprintf(hdf_path, 255, "%s/%s.hdf", dir, hdf_name);
if (file_exists(hdf_path))
{
if (msgYesNo("Overwrite the existing file?", 0, FULL_DISPLAY_X /2-180, FULL_DISPLAY_Y /2-48))
unlink (hdf_path); else return;
}
msgInfo("Creating file",1,NULL);
if (!make_hdf(size, hdf_path, sector, surfaces, blocksize))
msgInfo("Hardfile created",4000,NULL);
else
msgInfo("Failed to create hardfile",4000,NULL);
#endif
}
void delete_hardfile(void)
{
char *name;
char dir[255];
strncpy(dir,prefs_get_attr("hardfile_path"),255);
name = (char *) menu_select_file(dir, NULL, 0);
if (name && msgYesNo("Are you sure to delete the hardfile?", 0, FULL_DISPLAY_X /2-200, FULL_DISPLAY_Y /2-48))
{unlink (name); msgInfo("Hardfile deleted",3000,NULL);}
}
static void cpu_chipset_options(void)
{
int submenus[3], opt;
@ -1300,6 +1572,42 @@ static void help(void)
help_messages, NULL);
}
*/
void hd_emulation()
{
int opt;
opt = menu_select_title("HD emulation menu",
hd_emulation_messages, NULL);
if (opt < 0)
return;
switch(opt)
{
case 0:
mount_virtual_file_system();
break;
case 2:
mount_harddisk();
break;
case 4:
mount_partition();
break;
case 6:
unmount_device();
break;
case 8:
make_hardfile();
break;
case 10:
delete_hardfile();
break;
default:
break;
}
}
void gui_init (int argc, char **argv)
{
}
@ -1415,24 +1723,27 @@ void gui_display(int shortcut)
break;
case 10:
other_options();
break;
case 11:
save_conf_file_menu();
break;
case 11:
hd_emulation();
break;
case 12:
save_conf_file_menu();
break;
case 13:
load_conf_file_menu();
break;
case 13:
case 14:
uae_reset(1);
break;
case 14:
case 15:
if (msgYesNo("Are you sure to quit?", 0, FULL_DISPLAY_X /2-138, FULL_DISPLAY_Y /2-48))
{currprefs.rumble=0; uae_quit();}
break;
default:
break;
}
} while (opt == 0 || opt == 5 || opt == 8 || opt == 9 || opt == 10);flip_screen();}
} while (opt == 0 || opt == 5 || opt == 8 || opt == 9 || opt == 10 || opt == 11);flip_screen();}
if (shortcut==6) {virtual_keyboard(); notice_screen_contents_lost ();}//Enter Virtual Keyboard

View File

@ -1,9 +1,10 @@
/*********************************************************************
*
* Copyright (C) 2004,2008, Simon Kagstrom
* Copyright (C) 2010,2014, Fabio Olimpieri
*
* Filename: menu.c
* Author: Simon Kagstrom <simon.kagstrom@gmail.com>
* Author: Simon Kagstrom <simon.kagstrom@gmail.com>, Fabio Olimpieri
* Description: Code for menus (originally for Mophun)
*
* $Id$
@ -17,10 +18,16 @@
#include <unistd.h>
#include <string.h>
#include "sysconfig.h"
#include "menu.h"
#include "VirtualKeyboard.h"
#include "sysconfig.h"
#include "sysdeps.h"
#include "options.h"
#include "filesys.h"
struct joyinfo {
SDL_Joystick *joy;
unsigned int axles;
@ -55,6 +62,22 @@ typedef struct
int n_entries;
} menu_t;
enum hdlist_cols {
HDLIST_DEVICE,
HDLIST_VOLUME,
HDLIST_PATH,
HDLIST_READONLY,
HDLIST_HEADS,
HDLIST_CYLS,
HDLIST_SECS,
HDLIST_RSRVD,
HDLIST_SIZE,
HDLIST_BLKSIZE,
HDLIST_BOOTPRI,
HDLIST_MAX_COLS
};
static SDL_Surface *real_screen;
#define IS_SUBMENU(p_msg) ( (p_msg)[0] == '^' )
@ -283,7 +306,7 @@ static const char **get_file_list(const char *base_dir)
char buf[255];
//ipf files are not enabled in UAE Wii
const char *exts[] = {".adf", ".ADF", ".adz", ".ADZ", ".zip",".ZIP",".dms", ".DMS",
".sav", ".SAV", ".uss", ".USS", ".rom", ".ROM", NULL};
".sav", ".SAV", ".uss", ".USS", ".rom", ".ROM", ".hdf", ".HDF", NULL};
struct stat st;
snprintf(buf, 255, "%s/%s", base_dir, de->d_name);
@ -322,6 +345,89 @@ static const char **get_file_list(const char *base_dir)
return file_list;
}
const char **get_file_list_devices()
{
char **device_list_menu;
device_list_menu = (char**)malloc((MAX_DEVICE_ITEM+1) * sizeof(char*));
device_list_menu[0] = NULL;
#ifdef FILESYS
int i, nr;
char texts[HDLIST_MAX_COLS][64];
nr = nr_units(currprefs.mountinfo);
if (!nr) return NULL;
for (i=0; i<HDLIST_MAX_COLS; i++)
strcpy (texts[i], " ");
device_list_menu[0]=malloc(80);
sprintf(device_list_menu[0], "#1NR %-6s %-6s %s %s %s %s %s %s %s",
"Device", "Volume","Acc","Sec", "Sur","Res","Blk","Prio", "Path");
for (i = 0; i < nr; i++) {
int secspertrack, surfaces, reserved, blocksize, bootpri;
uae_u64 size;
int cylinders, readonly, flags;
char *devname, *volname, *rootdir, *filesysdir;
const char *failure;
device_list_menu[i+1]=malloc(80);
/* We always use currprefs.mountinfo for the GUI. The filesystem
code makes a private copy which is updated every reset. */
failure = get_filesys_unit (currprefs.mountinfo, i,
&devname, &volname, &rootdir, &readonly,
&secspertrack, &surfaces, &reserved,
&cylinders, &size, &blocksize, &bootpri,
&filesysdir, &flags);
if (is_hardfile (currprefs.mountinfo, i)) {
if (secspertrack == 0)
strcpy (texts[HDLIST_DEVICE], "N/A" );
else //Partitionable hard disk or partition
strncpy (texts[HDLIST_DEVICE], devname, 6);
texts[HDLIST_DEVICE][6]='\0';
sprintf (texts[HDLIST_VOLUME], "N/A" );
sprintf (texts[HDLIST_HEADS], "%.3d", surfaces);
//sprintf (texts[HDLIST_CYLS], "%.3d", cylinders);
sprintf (texts[HDLIST_SECS], "%.3d", secspertrack);
sprintf (texts[HDLIST_RSRVD], "%.3d", reserved);
//sprintf (texts[HDLIST_SIZE], "%.3d", size);
sprintf (texts[HDLIST_BLKSIZE], "%.3d", blocksize);
} else { //Virtual filesystem
strncpy (texts[HDLIST_DEVICE], devname, 6);
texts[HDLIST_DEVICE][6]='\0';
strncpy (texts[HDLIST_VOLUME], volname, 6);
texts[HDLIST_VOLUME][6]='\0';
strcpy (texts[HDLIST_HEADS], "N/A");
//strcpy (texts[HDLIST_CYLS], "N/A");
strcpy (texts[HDLIST_SECS], "N/A");
strcpy (texts[HDLIST_RSRVD], "N/A");
//strcpy (texts[HDLIST_SIZE], "N/A");
strcpy (texts[HDLIST_BLKSIZE], "N/A");
}
strncpy (texts[HDLIST_PATH], rootdir ,24);
texts[HDLIST_PATH][24]='\0';
strcpy (texts[HDLIST_READONLY], readonly ? "RO " : "RW ");
sprintf (texts[HDLIST_BOOTPRI], "%4d", bootpri);
sprintf(device_list_menu[i+1], "%.2d %-6s %-6s %s %s %s %s %s %s %-24s",
i,texts[HDLIST_DEVICE],texts[HDLIST_VOLUME],texts[HDLIST_READONLY], texts[HDLIST_SECS],
texts[HDLIST_HEADS],texts[HDLIST_RSRVD], texts[HDLIST_BLKSIZE] ,texts[HDLIST_BOOTPRI], texts[HDLIST_PATH]);
}
device_list_menu[i+1]=NULL;
#endif
return (const char **) device_list_menu;
}
static submenu_t *find_submenu(menu_t *p_menu, int index)
{
@ -914,7 +1020,7 @@ int menu_select(const char **msgs, int *submenus)
static const char *menu_select_file_internal(const char *dir_path,
int x, int y, int x2, int y2, const char *selected_file, int which)
{
const char **file_list = get_file_list(dir_path);
const char **file_list;
char *sel;
char *out;
const char *ptr_selected_file;
@ -923,6 +1029,9 @@ static const char *menu_select_file_internal(const char *dir_path,
int i;
char buf[64];
if (!strcmp(dir_path,"devices")) file_list = get_file_list_devices();
else file_list = get_file_list(dir_path);
if (file_list == NULL)
return NULL;
@ -989,18 +1098,6 @@ static const char *menu_select_file_internal(const char *dir_path,
return out;
}
/*
const char *menu_select_file_start(const char *dir_path, const char **d64_name)
{
const char *file = menu_select_file_internal(dir_path,
32, 32, FULL_DISPLAY_X, FULL_DISPLAY_Y - 32);
if (!file)
return NULL;
return file;
}
*/
const char *menu_select_file(const char *dir_path,const char *selected_file, int which)
{
if (dir_path == NULL)
@ -1009,6 +1106,14 @@ const char *menu_select_file(const char *dir_path,const char *selected_file, int
0, 20, FULL_DISPLAY_X, FULL_DISPLAY_Y - 20, selected_file, which);
}
int menu_select_devices()
{
const char *selected_device;
selected_device= menu_select_file_internal("devices",
0, 20, FULL_DISPLAY_X, FULL_DISPLAY_Y - 20, NULL, 0);
if (!selected_device) return -1; else return (atoi(selected_device));
}
static TTF_Font *read_font(const char *path, int font_size)
{
TTF_Font *out;

View File

@ -1,9 +1,10 @@
/*********************************************************************
*
* Copyright (C) 2004, 2008, Simon Kagstrom
* Copyright (C) 2010,2014, Fabio Olimpieri
*
* Filename: menu.h
* Author: Simon Kagstrom <simon.kagstrom@gmail.com>
* Author: Simon Kagstrom <simon.kagstrom@gmail.com>, Fabio Olimpieri
* Description:
*
* $Id$
@ -31,6 +32,7 @@ extern "C" {
#define KEY_HELP 256
#define FULL_DISPLAY_X 640
#define FULL_DISPLAY_Y 480
#define MAX_DEVICE_ITEM 32
void menu_print_font(SDL_Surface *screen, int r, int g, int b, int x, int y, const char *msg, int font_size);
@ -57,6 +59,8 @@ int ext_matches(const char *name, const char *ext);
void flip_screen (void);
int menu_select_devices(void);
#if defined(__cplusplus)
}
#endif

View File

@ -369,7 +369,7 @@
/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
# define _ALL_SOURCE 1
//# define _ALL_SOURCE 1
#endif
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE

View File

@ -10,7 +10,7 @@
#define TARGET_ROM_PATH "/uae/roms"
#define TARGET_FLOPPY_PATH "/uae/floppies"
#define TARGET_HARDFILE_PATH "/uae/harddisks"
#define TARGET_HARDFILE_PATH "/uae/HD"
#define TARGET_SAVESTATE_PATH "/uae/saves"
#define TARGET_SD_PATH "sd:/"
#define TARGET_USB_PATH "usb:/"

View File

@ -4,13 +4,13 @@ kickstart_key_file=$(FILE_PATH)/rom.key
floppy0=/uae/floppies/
#Examples of hardfile (hard drive partition)
#hardfile2=rw,DH0:/uae/harddisks/hardfile.hdf,32,1,2,512,0,
#hardfile2=rw,DH0:/uae/HD/hardfile.hdf,32,1,2,512,0,
#Examples of hardfile (full partitionable hard disk /RDB)
#hardfile2=rw,:/uae/harddisks/hardfile.hdf,0,0,0,0,0,
#hardfile2=rw,:/uae/HD/hardfile.hdf,0,0,0,0,0,
#You can also use hardfile from a real usb harddisk
#hardfile2=rw,DH0:usb:/harddisks/hardfile.hdf,32,1,2,512,0,
#hardfile2=rw,DH0:usb:/HD/hardfile.hdf,32,1,2,512,0,
#You can also use hardfile from wifi connection with SMB
#hardfile2=rw,DH0:smb:/hardfile.hdf,32,1,2,512,0,