- now the memory options menu, interface menu, and disk menu in the
control panel are all implemented as bx_list_c, and look much like they did before. - removed many hardcoded UI functions from control.cc, since the much more general "text_ask" methods have replaced them. - add range checking on integer parameter values. This exposed several cases where my initial value for an integer parameter was not in range. - cleaned up behavior of get/set methods. The get/set methods allow the handler to override the value that is returned/set, or perform side effects. - the title parameter of a bx_list_c now defaults to the name. - now bx_param_c fields that used to be private are protected instead - removed references to bx_any - moved definition of set_handler from siminterface.h to siminterface.cc. I was considering with doing a "set" of the old value when the handler is first installed, but that remains commented out. - BX_BOOT_DISKA and BX_BOOT_DISKC are now 0,1 so that they can correspond with the values of a bx_param_enum_c. For a while they were 0x00 and 0x80 corresponding to the numbering convention of the bios, but it didn't really matter.
This commit is contained in:
parent
c47c6837c9
commit
93f5f8e06b
@ -629,7 +629,7 @@ typedef struct {
|
||||
} bx_sb16_options;
|
||||
|
||||
#define BX_BOOT_FLOPPYA 0
|
||||
#define BX_BOOT_DISKC 0x80
|
||||
#define BX_BOOT_DISKC 1
|
||||
|
||||
typedef struct {
|
||||
bx_floppy_options floppya;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* gui/control.cc
|
||||
* $Id: control.cc,v 1.24 2001-06-20 14:01:39 bdenney Exp $
|
||||
* $Id: control.cc,v 1.25 2001-06-21 14:37:55 bdenney Exp $
|
||||
*
|
||||
* This is code for a text-mode control panel. Note that this file
|
||||
* does NOT include bochs.h. Instead, it does all of its contact with
|
||||
@ -73,19 +73,9 @@ extern "C" {
|
||||
|
||||
/* functions for changing particular options */
|
||||
void bx_control_panel_init ();
|
||||
void bx_edit_floppy (int drive);
|
||||
void bx_edit_hard_disk (int drive);
|
||||
void bx_edit_cdrom ();
|
||||
void bx_newhd_support ();
|
||||
void bx_private_colormap ();
|
||||
void bx_boot_from ();
|
||||
void bx_ips_change ();
|
||||
int bx_read_rc (char *rc);
|
||||
int bx_write_rc (char *rc);
|
||||
void bx_log_file ();
|
||||
void bx_log_options (int individual);
|
||||
void bx_vga_update_interval ();
|
||||
void bx_mouse_enable ();
|
||||
|
||||
/******************************************************************/
|
||||
/* lots of code stolen from bximage.c */
|
||||
@ -286,45 +276,6 @@ static char *startup_options_prompt =
|
||||
"\n"
|
||||
"Please choose one: [0] ";
|
||||
|
||||
static char *startup_mem_options_prompt =
|
||||
"--------------------\n"
|
||||
"Bochs Memory Options\n"
|
||||
"--------------------\n"
|
||||
"0. Return to previous menu\n"
|
||||
"1. Memory in Megabytes: %d\n"
|
||||
"2. VGA ROM image: %s\n"
|
||||
"3. ROM image: %s\n"
|
||||
"4. ROM address: 0x%05x\n"
|
||||
"\n"
|
||||
"Please choose one: [0] ";
|
||||
|
||||
static char *startup_interface_options =
|
||||
"------------------\n"
|
||||
"Bochs Interface Options\n"
|
||||
"------------------\n"
|
||||
"0. Return to previous menu\n"
|
||||
"1. VGA Update Interval: %d\n"
|
||||
"2. Mouse: %s\n"
|
||||
"3. Emulated instructions per second (IPS): %u\n"
|
||||
"4. Private Colormap: %s\n"
|
||||
"\n"
|
||||
"Please choose one: [0] ";
|
||||
|
||||
static char *startup_disk_options_prompt =
|
||||
"------------------\n"
|
||||
"Bochs Disk Options\n"
|
||||
"------------------\n"
|
||||
"0. Return to previous menu\n"
|
||||
"1. Floppy disk 0: %s\n"
|
||||
"2. Floppy disk 1: %s\n"
|
||||
"3. Hard disk 0: %s\n"
|
||||
"4. Hard disk 1: %s\n"
|
||||
"5. CDROM: %s\n"
|
||||
"6. New Hard Drive Support: %s\n"
|
||||
"7. Boot from: %s\n"
|
||||
"%s\n"
|
||||
"Please choose one: [0] ";
|
||||
|
||||
static char *startup_sound_options_prompt =
|
||||
"------------------\n"
|
||||
"Bochs Sound Options\n"
|
||||
@ -373,9 +324,9 @@ char *menu_prompt_list[BX_CPANEL_N_MENUS] = {
|
||||
ask_about_control_panel,
|
||||
startup_menu_prompt,
|
||||
startup_options_prompt,
|
||||
startup_mem_options_prompt,
|
||||
startup_interface_options,
|
||||
startup_disk_options_prompt,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
startup_sound_options_prompt,
|
||||
startup_misc_options_prompt,
|
||||
runtime_menu_prompt
|
||||
@ -388,41 +339,6 @@ char *menu_prompt_list[BX_CPANEL_N_MENUS] = {
|
||||
do {fprintf (stderr, "ERROR: control panel menu %d has no choice %d\n", menu, choice); \
|
||||
assert (0); } while (0)
|
||||
|
||||
char *fdsize_choices[] = { "0.72","1.2","1.44","2.88" };
|
||||
int fdsize_n_choices = 4;
|
||||
|
||||
void build_disk_options_prompt (char *format, char *buf, int size)
|
||||
{
|
||||
bx_floppy_options floppyop;
|
||||
bx_disk_options diskop;
|
||||
bx_cdrom_options cdromop;
|
||||
char buffer[7][128];
|
||||
for (int i=0; i<2; i++) {
|
||||
SIM->get_floppy_options (i, &floppyop);
|
||||
sprintf (buffer[i], "%s, size=%s, %s", floppyop.Opath->getptr (),
|
||||
SIM->get_floppy_type_name (floppyop.Otype->get ()),
|
||||
floppyop.Oinitial_status->get () ? "inserted" : "ejected");
|
||||
if (!floppyop.Opath->getptr()[0]) strcpy (buffer[i], "none");
|
||||
SIM->get_disk_options (i, &diskop);
|
||||
sprintf (buffer[2+i], "%s, %d cylinders, %d heads, %d sectors/track",
|
||||
diskop.Opath->getptr (), diskop.Ocylinders->get (),
|
||||
diskop.Oheads->get (), diskop.Ospt->get ());
|
||||
if (!diskop.Opresent->get ()) strcpy (buffer[2+i], "none");
|
||||
}
|
||||
SIM->get_cdrom_options (0, &cdromop);
|
||||
sprintf (buffer[4], "%s, %spresent, %s",
|
||||
cdromop.Opath->getptr (), cdromop.Opresent->get ()?"":"not ",
|
||||
cdromop.Oinserted?"inserted":"ejected");
|
||||
if (!cdromop.Opath->getptr()[0]) strcpy (buffer[4], "none");
|
||||
sprintf (buffer[5], "%s", SIM->get_newhd_support () ? "yes":"no");
|
||||
sprintf (buffer[6], "%s", SIM->get_boot_hard_disk () ? "hard drive":"floppy drive");
|
||||
// check if diskd and cdromd are on at once
|
||||
SIM->get_disk_options (1, &diskop);
|
||||
int conflict = (diskop.Opresent->get () && cdromop.Opresent->get ());
|
||||
char *diskd_cdromd_conflict_msg = "\nERROR:\nThis configuration has both a cdrom and a hard disk enabled.\nYou cannot have both!";
|
||||
snprintf (buf, size, format, buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5], buffer[6], conflict? diskd_cdromd_conflict_msg : "");
|
||||
}
|
||||
|
||||
void build_runtime_options_prompt (char *format, char *buf, int size)
|
||||
{
|
||||
bx_floppy_options floppyop;
|
||||
@ -446,8 +362,8 @@ void build_runtime_options_prompt (char *format, char *buf, int size)
|
||||
SIM->get_param_num (BXP_MOUSE_ENABLED)->get () ? "enabled" : "disabled");
|
||||
}
|
||||
|
||||
int do_mem_options_menu () {
|
||||
bx_list_c *menu = (bx_list_c *)SIM->get_param (BXP_MEMORY_OPTIONS_MENU);
|
||||
int do_menu (bx_id id) {
|
||||
bx_list_c *menu = (bx_list_c *)SIM->get_param (id);
|
||||
while (1) {
|
||||
menu->get_choice()->set (0);
|
||||
int status = menu->text_ask (stdin, stderr);
|
||||
@ -464,6 +380,12 @@ int do_mem_options_menu () {
|
||||
}
|
||||
}
|
||||
|
||||
void askparam (bx_id id)
|
||||
{
|
||||
bx_param_c *param = SIM->get_param (id);
|
||||
param->text_ask (stdin, stderr);
|
||||
}
|
||||
|
||||
// return value of bx_control_panel:
|
||||
// -1: error while reading, like if stdin closed
|
||||
// 0: no error
|
||||
@ -508,11 +430,11 @@ int bx_control_panel (int menu)
|
||||
if (ask_uint (prompt, 0, 8, 0, &choice, 10) < 0) return -1;
|
||||
switch (choice) {
|
||||
case 0: return 0;
|
||||
case 1: bx_log_file (); break;
|
||||
case 1: askparam (BXP_LOG_FILENAME); break;
|
||||
case 2: bx_log_options (0); break;
|
||||
case 3: bx_log_options (1); break;
|
||||
case 4: bx_control_panel (BX_CPANEL_START_OPTS_MEM); break;
|
||||
case 5: bx_control_panel (BX_CPANEL_START_OPTS_INTERFACE); break;
|
||||
case 4: bx_control_panel (BXP_MENU_MEMORY); break;
|
||||
case 5: bx_control_panel (BXP_MENU_INTERFACE); break;
|
||||
case 6: bx_control_panel (BX_CPANEL_START_OPTS_DISK); break;
|
||||
case 7: bx_control_panel (BX_CPANEL_START_OPTS_SOUND); break;
|
||||
case 8: bx_control_panel (BX_CPANEL_START_OPTS_MISC); break;
|
||||
@ -520,60 +442,25 @@ int bx_control_panel (int menu)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BX_CPANEL_START_OPTS_MEM:
|
||||
return do_mem_options_menu ();
|
||||
case BX_CPANEL_START_OPTS_INTERFACE:
|
||||
{
|
||||
char prompt[1024];
|
||||
int interval = SIM->get_param_num (BXP_VGA_UPDATE_INTERVAL)->get ();
|
||||
bx_param_num_c *ips = SIM->get_param_num (BXP_IPS);
|
||||
sprintf (prompt, startup_interface_options,
|
||||
interval,
|
||||
SIM->get_param_num (BXP_MOUSE_ENABLED)->get () ? "enabled" : "disabled",
|
||||
ips->get (),
|
||||
SIM->get_private_colormap () ? "enabled" : "disabled");
|
||||
if (ask_uint (prompt, 0, 4, 0, &choice, 10) < 0) return -1;
|
||||
switch (choice) {
|
||||
case 0: return 0;
|
||||
case 1: bx_vga_update_interval (); break;
|
||||
case 2: bx_mouse_enable (); break;
|
||||
case 3: bx_ips_change (); break;
|
||||
case 4: bx_private_colormap (); break;
|
||||
default: BAD_OPTION(menu, choice);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BXP_MENU_MEMORY:
|
||||
return do_menu (BXP_MENU_MEMORY);
|
||||
case BXP_MENU_INTERFACE:
|
||||
return do_menu (BXP_MENU_INTERFACE);
|
||||
case BX_CPANEL_START_OPTS_DISK:
|
||||
{
|
||||
char prompt[1024];
|
||||
build_disk_options_prompt (startup_disk_options_prompt, prompt, 1024);
|
||||
if (ask_uint (prompt, 0, 7, 0, &choice, 10) < 0) return -1;
|
||||
switch (choice) {
|
||||
case 0: return 0;
|
||||
case 1: bx_edit_floppy (0); break;
|
||||
case 2: bx_edit_floppy (1); break;
|
||||
case 3: bx_edit_hard_disk (0); break;
|
||||
case 4: bx_edit_hard_disk (1); break;
|
||||
case 5: bx_edit_cdrom (); break;
|
||||
case 6: bx_newhd_support (); break;
|
||||
case 7: bx_boot_from (); break;
|
||||
default: BAD_OPTION(menu, choice);
|
||||
}
|
||||
}
|
||||
break;
|
||||
return do_menu (BXP_MENU_DISK);
|
||||
case BX_CPANEL_RUNTIME:
|
||||
char prompt[1024];
|
||||
build_runtime_options_prompt (runtime_menu_prompt, prompt, 1024);
|
||||
if (ask_uint (prompt, 1, 11, 10, &choice, 10) < 0) return -1;
|
||||
switch (choice) {
|
||||
case 1: bx_edit_floppy (0); break;
|
||||
case 2: bx_edit_floppy (1); break;
|
||||
case 3: bx_edit_cdrom (); break;
|
||||
case 4: bx_ips_change (); break;
|
||||
case 1: do_menu (BXP_FLOPPYA); break;
|
||||
case 2: do_menu (BXP_FLOPPYB); break;
|
||||
case 3: do_menu (BXP_CDROMD); break;
|
||||
case 4: askparam (BXP_IPS); break;
|
||||
case 5: bx_log_options (0); break;
|
||||
case 6: bx_log_options (1); break;
|
||||
case 7: bx_vga_update_interval (); break;
|
||||
case 8: bx_mouse_enable (); break;
|
||||
case 7: askparam (BXP_VGA_UPDATE_INTERVAL); break;
|
||||
case 8: askparam (BXP_MOUSE_ENABLED); break;
|
||||
case 9: NOT_IMPLEMENTED (choice); break;
|
||||
case 10: fprintf (stderr, "Continuing simulation\n"); return 0;
|
||||
case 11:
|
||||
@ -593,122 +480,6 @@ int bx_control_panel (int menu)
|
||||
}
|
||||
}
|
||||
|
||||
void bx_edit_floppy (int drive)
|
||||
{
|
||||
bx_floppy_options opt, newopt;
|
||||
assert (SIM->get_floppy_options (drive, &opt) >= 0);
|
||||
newopt = opt;
|
||||
fprintf (stderr, "Changing options for floppy drive %d\n", drive);
|
||||
char the_default[512];
|
||||
opt.Opath->get (the_default, sizeof(the_default));
|
||||
if (ask_string ("Enter new pathname: [%s] ", the_default, newopt.Opath->getptr ()) < 0)
|
||||
return;
|
||||
int newtype, oldtype = opt.Otype->get () - BX_FLOPPY_NONE;
|
||||
if (ask_menu ("What is the floppy disk size?\nChoices are 720K, 1.2M, 1.44M, 2.88M. [%s] ", n_floppy_type_names, floppy_type_names, oldtype, &newtype) < 0) return;
|
||||
newopt.Otype->set (newtype + BX_FLOPPY_NONE);
|
||||
if (SIM->set_floppy_options (drive, &newopt) < 0) {
|
||||
fprintf (stderr, "The disk image %s could not be opened.\n", newopt.Opath->getptr ());
|
||||
}
|
||||
}
|
||||
|
||||
void bx_edit_hard_disk (int drive)
|
||||
{
|
||||
bx_disk_options opt, newopt;
|
||||
assert (SIM->get_disk_options (drive, &opt) >= 0);
|
||||
newopt = opt;
|
||||
fprintf (stderr, "Changing options for hard drive %d\n", drive);
|
||||
char buf[512];
|
||||
opt.Opath->get (buf, sizeof (buf));
|
||||
if (ask_string ("Enter new pathname, or type 'none' for no disk: [%s] ", buf, newopt.Opath->getptr ()) < 0)
|
||||
return;
|
||||
newopt.Opresent->set (strcmp (newopt.Opath->getptr (), "none") != 0);
|
||||
if (newopt.Opresent->get ()) { // skip if "none" is the path.
|
||||
// ask cyl, head, sec.
|
||||
Bit32u n;
|
||||
if (ask_uint ("How many cylinders? [%d] ", 1, 65535, opt.Ocylinders->get (), &n, 10) < 0)
|
||||
return;
|
||||
newopt.Ocylinders->set (n);
|
||||
if (ask_uint ("How many heads? [%d] ", 1, 256, opt.Oheads->get (), &n, 10) < 0)
|
||||
return;
|
||||
newopt.Oheads->set (n);
|
||||
if (ask_uint ("How many sectors per track? [%d] ", 1, 255, opt.Ospt->get (), &n, 10) < 0)
|
||||
return;
|
||||
newopt.Ospt->set (n);
|
||||
}
|
||||
if (SIM->set_disk_options (drive, &newopt) < 0) {
|
||||
fprintf (stderr, "The disk image %s could not be opened.\n", newopt.Opath->getptr ());
|
||||
}
|
||||
}
|
||||
|
||||
void bx_edit_cdrom ()
|
||||
{
|
||||
bx_cdrom_options opt, newopt;
|
||||
assert (SIM->get_cdrom_options (0, &opt) >= 0);
|
||||
newopt = opt;
|
||||
newopt.Opresent->set (1);
|
||||
char buf[512];
|
||||
opt.Opath->get (buf, sizeof (buf));
|
||||
if (ask_string ("Enter pathname of the cdrom device, or 'none' for no cdrom: [%s] ", buf, newopt.Opath->getptr ()) < 0)
|
||||
return;
|
||||
if (!strcmp (newopt.Opath->getptr (), "none")) {
|
||||
newopt.Opath->getptr ()[0] = 0;
|
||||
newopt.Opresent->set (0);
|
||||
}
|
||||
if (SIM->set_cdrom_options (0, &newopt) < 0) {
|
||||
fprintf (stderr, "The device at %s could not be opened.\n", newopt.Opath->getptr ());
|
||||
}
|
||||
}
|
||||
|
||||
void bx_newhd_support ()
|
||||
{
|
||||
Bit32u newval, oldval = SIM->get_newhd_support ();
|
||||
if (ask_yn ("Use new hard disk support (recommended)? [%s] ", oldval, &newval) < 0) return;
|
||||
if (newval == oldval) return;
|
||||
SIM->set_newhd_support (newval);
|
||||
}
|
||||
|
||||
void bx_private_colormap ()
|
||||
{
|
||||
Bit32u newval, oldval = SIM->get_private_colormap ();
|
||||
if (ask_yn ("Use private colormap? [%s] ", oldval, &newval) < 0) return;
|
||||
if (newval == oldval) return;
|
||||
SIM->set_private_colormap (newval);
|
||||
}
|
||||
|
||||
|
||||
void bx_boot_from ()
|
||||
{
|
||||
int newval, oldval = SIM->get_boot_hard_disk ();
|
||||
char *choices[] = {"fd","hd"};
|
||||
if (ask_menu ("Boot floppy disk or hard disk? Type hd or fd. [%s] ",
|
||||
2, choices, oldval, &newval) < 0) return;
|
||||
SIM->set_boot_hard_disk (newval);
|
||||
}
|
||||
|
||||
void bx_ips_change ()
|
||||
{
|
||||
char prompt[1024];
|
||||
bx_param_num_c *ips = SIM->get_param_num (BXP_IPS);
|
||||
Bit32u oldips = ips->get ();
|
||||
sprintf (prompt, "Type a new value for ips: [%d] ", oldips);
|
||||
Bit32u newips;
|
||||
if (ask_uint (prompt, 1, 1<<30, oldips, &newips, 10) < 0)
|
||||
return;
|
||||
ips->set (newips);
|
||||
}
|
||||
|
||||
void bx_vga_update_interval ()
|
||||
{
|
||||
char prompt[1024];
|
||||
bx_param_num_c *pinterval = SIM->get_param_num (BXP_VGA_UPDATE_INTERVAL);
|
||||
Bit32u old = pinterval->get ();
|
||||
sprintf (prompt, "Type a new value for VGA update interval: [%d] ", old);
|
||||
Bit32u newinterval;
|
||||
if (ask_uint (prompt, 1, 1<<30, old, &newinterval, 10) < 0)
|
||||
return;
|
||||
pinterval->set (newinterval);
|
||||
}
|
||||
|
||||
static void bx_print_log_action_table ()
|
||||
{
|
||||
// just try to print all the prefixes first.
|
||||
@ -770,15 +541,6 @@ void bx_log_options (int individual)
|
||||
}
|
||||
}
|
||||
|
||||
void bx_mouse_enable ()
|
||||
{
|
||||
bx_param_num_c *mouse_en = SIM->get_param_num (BXP_MOUSE_ENABLED);
|
||||
Bit32u newval, oldval = mouse_en->get ();
|
||||
if (ask_yn ("Enable the mouse? [%s] ", oldval, &newval) < 0) return;
|
||||
if (newval == oldval) return;
|
||||
mouse_en->set (newval);
|
||||
}
|
||||
|
||||
int bx_read_rc (char *rc)
|
||||
{
|
||||
if (rc && SIM->read_rc (rc) >= 0) return 0;
|
||||
@ -830,14 +592,6 @@ int bx_write_rc (char *rc)
|
||||
}
|
||||
}
|
||||
|
||||
void bx_log_file ()
|
||||
{
|
||||
char oldpath[CPANEL_PATH_LEN], newpath[CPANEL_PATH_LEN];
|
||||
assert (SIM->get_log_file (oldpath, CPANEL_PATH_LEN) >= 0);
|
||||
if (ask_string ("Enter log file name: [%s] ", oldpath, newpath) < 0) return;
|
||||
SIM->set_log_file (newpath);
|
||||
}
|
||||
|
||||
/*
|
||||
A panic has occurred. Do you want to:
|
||||
cont - continue execution
|
||||
@ -896,9 +650,8 @@ bx_param_num_c::text_print (FILE *fp)
|
||||
//fprintf (fp, "value=%u\n", get ());
|
||||
if (get_format ()) {
|
||||
fprintf (fp, get_format (), get ());
|
||||
fprintf (fp, "\n");
|
||||
} else {
|
||||
char *format = "%s: %d\n";
|
||||
char *format = "%s: %d";
|
||||
assert (base==10 || base==16);
|
||||
if (base==16) format = "%s: 0x%x\n";
|
||||
fprintf (fp, format, get_name (), get ());
|
||||
@ -909,10 +662,23 @@ void
|
||||
bx_param_bool_c::text_print (FILE *fp)
|
||||
{
|
||||
if (get_format ()) {
|
||||
fprintf (fp, get_format (), get ());
|
||||
fprintf (fp, "\n");
|
||||
fprintf (fp, get_format (), get () ? "yes" : "no");
|
||||
} else {
|
||||
char *format = "%s: %s\n";
|
||||
char *format = "%s: %s";
|
||||
fprintf (fp, format, get_name (), get () ? "yes" : "no");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
bx_param_enum_c::text_print (FILE *fp)
|
||||
{
|
||||
int n = get ();
|
||||
assert (n >= min && n <= max);
|
||||
char *choice = choices[n - min];
|
||||
if (get_format ()) {
|
||||
fprintf (fp, get_format (), choice);
|
||||
} else {
|
||||
char *format = "%s: %s";
|
||||
fprintf (fp, format, get_name (), get () ? "yes" : "no");
|
||||
}
|
||||
}
|
||||
@ -924,25 +690,31 @@ bx_param_string_c::text_print (FILE *fp)
|
||||
//fprintf (fp, "value=%s\n", getptr ());
|
||||
if (get_format ()) {
|
||||
fprintf (fp, get_format (), getptr ());
|
||||
fprintf (fp, "\n");
|
||||
} else {
|
||||
fprintf (fp, "%s: %s\n", get_name (), getptr ());
|
||||
fprintf (fp, "%s: %s", get_name (), getptr ());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
bx_list_c::text_print (FILE *fp)
|
||||
{
|
||||
fprintf (fp, "This is a list.\n");
|
||||
fprintf (fp, "title=%s\n", title->getptr ());
|
||||
//fprintf (fp, "This is a list.\n");
|
||||
//fprintf (fp, "title=%s\n", title->getptr ());
|
||||
fprintf (fp, "%s: ", get_name ());
|
||||
/*
|
||||
fprintf (fp, "options=%s%s%s\n",
|
||||
(options->get () == 0) ? "none" : "",
|
||||
(options->get () & BX_SHOW_PARENT) ? "SHOW_PARENT " : "",
|
||||
(options->get () & BX_SERIES_ASK) ? "SERIES_ASK " : "");
|
||||
*/
|
||||
for (int i=0; i<size; i++) {
|
||||
fprintf (fp, "param[%d] = %p\n", i, list[i]);
|
||||
if (list[i])
|
||||
//fprintf (fp, "param[%d] = %p\n", i, list[i]);
|
||||
assert (list[i] != NULL);
|
||||
if (list[i]->get_enabled ()) {
|
||||
list[i]->text_print (fp);
|
||||
if (!options->get () & BX_SERIES_ASK)
|
||||
fprintf (fp, "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -955,6 +727,7 @@ bx_param_num_c::text_ask (FILE *fpin, FILE *fpout)
|
||||
if (prompt == NULL) {
|
||||
// default prompt, if they didn't set an ask format string
|
||||
text_print (fpout);
|
||||
fprintf (fpout, "\n");
|
||||
prompt = "Enter new value: [%d] ";
|
||||
if (base==16)
|
||||
prompt = "Enter new value in hex: [%x] ";
|
||||
@ -974,7 +747,9 @@ bx_param_bool_c::text_ask (FILE *fpin, FILE *fpout)
|
||||
char *prompt = get_ask_format ();
|
||||
if (prompt == NULL) {
|
||||
// default prompt, if they didn't set an ask format string
|
||||
prompt = "Set %s to: [%s] ";
|
||||
char buffer[512];
|
||||
sprintf (buffer, "%s? [%%s] ", get_name ());
|
||||
prompt = buffer;
|
||||
}
|
||||
Bit32u n = get ();
|
||||
status = ask_yn (prompt, n, &n);
|
||||
@ -983,6 +758,26 @@ bx_param_bool_c::text_ask (FILE *fpin, FILE *fpout)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
bx_param_enum_c::text_ask (FILE *fpin, FILE *fpout)
|
||||
{
|
||||
fprintf (fpout, "\n");
|
||||
char *prompt = get_ask_format ();
|
||||
if (prompt == NULL) {
|
||||
// default prompt, if they didn't set an ask format string
|
||||
char buffer[512];
|
||||
fprintf (fpout, "%s = ", get_name ());
|
||||
text_print (fpout);
|
||||
fprintf (fpout, "\n");
|
||||
prompt = "Enter new value: [%s] ";
|
||||
}
|
||||
Bit32s n = get () - min;
|
||||
int status = ask_menu (prompt, (max-min+1), choices, n, &n);
|
||||
if (status < 0) return status;
|
||||
n += min;
|
||||
set (n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
bx_param_string_c::text_ask (FILE *fpin, FILE *fpout)
|
||||
@ -993,6 +788,7 @@ bx_param_string_c::text_ask (FILE *fpin, FILE *fpout)
|
||||
if (prompt == NULL) {
|
||||
// default prompt, if they didn't set an ask format string
|
||||
text_print (fpout);
|
||||
fprintf (fpout, "\n");
|
||||
prompt = "Enter a new value, or press return for no change.\n";
|
||||
}
|
||||
//FIXME
|
||||
@ -1006,27 +802,38 @@ bx_param_string_c::text_ask (FILE *fpin, FILE *fpout)
|
||||
int
|
||||
bx_list_c::text_ask (FILE *fpin, FILE *fpout)
|
||||
{
|
||||
char *my_title = title->getptr ();
|
||||
fprintf (fpout, "\n");
|
||||
int i, imax = strlen (title->getptr ());
|
||||
int i, imax = strlen (my_title);
|
||||
for (i=0; i<imax; i++) fprintf (fpout, "-");
|
||||
fprintf (fpout, "\n%s\n", title->getptr ());
|
||||
fprintf (fpout, "\n%s\n", my_title);
|
||||
for (i=0; i<imax; i++) fprintf (fpout, "-");
|
||||
fprintf (fpout, "\n");
|
||||
//fprintf (fp, "options=%s\n", options->get ());
|
||||
if (options->get () & BX_SHOW_PARENT)
|
||||
fprintf (fpout, "0. Return to previous menu\n");
|
||||
for (int i=0; i<size; i++) {
|
||||
assert (list[i] != NULL);
|
||||
fprintf (fpout, "%d. ", i+1);
|
||||
list[i]->text_print (fpout);
|
||||
}
|
||||
fprintf (fpout, "\n"); //fprintf (fp, "options=%s\n", options->get ());
|
||||
if (options->get () & BX_SERIES_ASK) {
|
||||
for (int i=0; i<size; i++) {
|
||||
if (list[i]->get_enabled ())
|
||||
list[i]->text_ask (fpin, fpout);
|
||||
}
|
||||
} else {
|
||||
if (options->get () & BX_SHOW_PARENT)
|
||||
fprintf (fpout, "0. Return to previous menu\n");
|
||||
for (int i=0; i<size; i++) {
|
||||
assert (list[i] != NULL);
|
||||
fprintf (fpout, "%d. ", i+1);
|
||||
if (list[i]->get_enabled ()) {
|
||||
list[i]->text_print (fpout);
|
||||
fprintf (fpout, "\n");
|
||||
} else
|
||||
fprintf (fpout, "(disabled)\n");
|
||||
}
|
||||
fprintf (fpout, "\n");
|
||||
Bit32u n = choice->get ();
|
||||
int min = (options->get () & BX_SHOW_PARENT) ? 0 : 1;
|
||||
int max = size;
|
||||
int status = ask_uint ("Please choose one: [%d] ", min, max, n, &n, 10);
|
||||
if (status < 0) return status;
|
||||
choice->set (n);
|
||||
Bit32u n = choice->get ();
|
||||
int min = (options->get () & BX_SHOW_PARENT) ? 0 : 1;
|
||||
int max = size;
|
||||
int status = ask_uint ("Please choose one: [%d] ", min, max, n, &n, 10);
|
||||
if (status < 0) return status;
|
||||
choice->set (n);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* gui/siminterface.cc
|
||||
* $Id: siminterface.cc,v 1.24 2001-06-20 14:01:39 bdenney Exp $
|
||||
* $Id: siminterface.cc,v 1.25 2001-06-21 14:37:55 bdenney Exp $
|
||||
*
|
||||
* Defines the actual link between bx_simulator_interface_c methods
|
||||
* and the simulator. This file includes bochs.h because it needs
|
||||
@ -87,7 +87,7 @@ bx_real_sim_c::get_param_num (bx_id id) {
|
||||
return NULL;
|
||||
}
|
||||
int type = generic->get_type ();
|
||||
if (type == BXT_PARAM_NUM || type == BXT_PARAM_BOOL)
|
||||
if (type == BXT_PARAM_NUM || type == BXT_PARAM_BOOL || type == BXT_PARAM_ENUM)
|
||||
return (bx_param_num_c *)generic;
|
||||
BX_PANIC (("get_param_num %u could not find an integer parameter with that id", id));
|
||||
return NULL;
|
||||
@ -308,6 +308,8 @@ char *floppy_type_names[] = { "none", "1.2M", "1.44M", "2.88M", "720K", NULL };
|
||||
int n_floppy_type_names = 5;
|
||||
char *floppy_status_names[] = { "ejected", "inserted", NULL };
|
||||
int n_floppy_status_names = 2;
|
||||
char *floppy_bootdisk_names[] = { "floppy", "hard", NULL };
|
||||
int n_floppy_bootdisk_names = 2;
|
||||
|
||||
char *
|
||||
bx_real_sim_c::get_floppy_type_name (int type)
|
||||
@ -437,6 +439,7 @@ bx_param_c::bx_param_c (bx_id id, char *name, char *description)
|
||||
this->text_format = NULL;
|
||||
this->ask_format = NULL;
|
||||
this->runtime_param = 0;
|
||||
this->enabled = 1;
|
||||
SIM->register_param (id, this);
|
||||
}
|
||||
|
||||
@ -453,6 +456,7 @@ bx_param_num_c::bx_param_num_c (bx_id id,
|
||||
this->val = initial_val;
|
||||
this->handler = NULL;
|
||||
this->base = 10;
|
||||
set (initial_val);
|
||||
}
|
||||
|
||||
void
|
||||
@ -461,6 +465,14 @@ bx_param_num_c::reset ()
|
||||
this->val = initial_val;
|
||||
}
|
||||
|
||||
void
|
||||
bx_param_num_c::set_handler (param_event_handler handler)
|
||||
{
|
||||
this->handler = handler;
|
||||
// now that there's a handler, call set once to run the handler immediately
|
||||
//set (get ());
|
||||
}
|
||||
|
||||
Bit32s
|
||||
bx_param_num_c::get ()
|
||||
{
|
||||
@ -483,6 +495,8 @@ bx_param_num_c::set (Bit32s newval)
|
||||
// just set the value. This code does not check max/min.
|
||||
val = newval;
|
||||
}
|
||||
if (val < min || val > max)
|
||||
BX_PANIC (("numerical parameter %s was set to %d, which is out of range %d to %d", get_name (), val, min, max));
|
||||
}
|
||||
|
||||
bx_param_bool_c::bx_param_bool_c (bx_id id,
|
||||
@ -492,6 +506,7 @@ bx_param_bool_c::bx_param_bool_c (bx_id id,
|
||||
: bx_param_num_c (id, name, description, 0, 1, initial_val)
|
||||
{
|
||||
set_type (BXT_PARAM_BOOL);
|
||||
set (initial_val);
|
||||
}
|
||||
|
||||
bx_param_enum_c::bx_param_enum_c (bx_id id,
|
||||
@ -502,12 +517,16 @@ bx_param_enum_c::bx_param_enum_c (bx_id id,
|
||||
Bit32s value_base)
|
||||
: bx_param_num_c (id, name, description, value_base, BX_MAX_INT, initial_val)
|
||||
{
|
||||
set_type (BXT_PARAM_ENUM);
|
||||
this->choices = choices;
|
||||
this->value_base = value_base;
|
||||
// count number of choices, set max
|
||||
char **p = choices;
|
||||
while (*p != NULL) p++;
|
||||
this->min = value_base;
|
||||
// now that the max is known, replace the BX_MAX_INT sent to the parent
|
||||
// class constructor with the real max.
|
||||
this->max = value_base + (p - choices - 1);
|
||||
set (initial_val);
|
||||
}
|
||||
|
||||
bx_param_string_c::bx_param_string_c (bx_id id,
|
||||
@ -526,6 +545,7 @@ bx_param_string_c::bx_param_string_c (bx_id id,
|
||||
this->maxsize = maxsize;
|
||||
strncpy (this->val, initial_val, maxsize);
|
||||
strncpy (this->initial_val, initial_val, maxsize);
|
||||
set (initial_val);
|
||||
}
|
||||
|
||||
void
|
||||
@ -533,25 +553,37 @@ bx_param_string_c::reset () {
|
||||
strncpy (this->val, this->initial_val, maxsize);
|
||||
}
|
||||
|
||||
void
|
||||
bx_param_string_c::set_handler (param_string_event_handler handler)
|
||||
{
|
||||
this->handler = handler;
|
||||
// now that there's a handler, call set once to run the handler immediately
|
||||
//set (getptr ());
|
||||
}
|
||||
|
||||
Bit32s
|
||||
bx_param_string_c::get (char *buf, int len)
|
||||
{
|
||||
if (handler)
|
||||
strncpy (buf, val, len);
|
||||
if (handler) {
|
||||
// the handler can choose to replace the value in val/len. Also its
|
||||
// return value is passed back as the return value of get.
|
||||
(*handler)(this, 0, buf, len);
|
||||
else
|
||||
strncpy (buf, val, len);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
bx_param_string_c::set (char *buf)
|
||||
{
|
||||
if (handler)
|
||||
(*handler)(this, 1, buf, -1);
|
||||
else
|
||||
strncpy (val, buf, maxsize);
|
||||
if (handler) {
|
||||
// the handler can return a different char* to be copied into the value
|
||||
buf = (*handler)(this, 1, buf, -1);
|
||||
}
|
||||
strncpy (val, buf, maxsize);
|
||||
}
|
||||
|
||||
#if 0
|
||||
bx_list_c::bx_list_c (bx_id id, int maxsize)
|
||||
: bx_param_c (id, "list", "")
|
||||
{
|
||||
@ -561,9 +593,10 @@ bx_list_c::bx_list_c (bx_id id, int maxsize)
|
||||
this->list = new bx_param_c* [maxsize];
|
||||
init ();
|
||||
}
|
||||
#endif
|
||||
|
||||
bx_list_c::bx_list_c (bx_id id, bx_param_c **init_list)
|
||||
: bx_param_c (id, "list", "")
|
||||
bx_list_c::bx_list_c (bx_id id, char *name, char *description, bx_param_c **init_list)
|
||||
: bx_param_c (id, name, description)
|
||||
{
|
||||
set_type (BXT_LIST);
|
||||
this->size = 0;
|
||||
@ -579,15 +612,16 @@ bx_list_c::bx_list_c (bx_id id, bx_param_c **init_list)
|
||||
void
|
||||
bx_list_c::init ()
|
||||
{
|
||||
this->title = new bx_param_string_c (BXP_LIST_TITLE,
|
||||
"list_title",
|
||||
"title of the bx_list",
|
||||
"list", 80);
|
||||
this->options = new bx_param_num_c (BXP_LIST_OPTIONS,
|
||||
"list_option", "", 0, 1<<31,
|
||||
// the title defaults to the name
|
||||
this->title = new bx_param_string_c (BXP_NULL,
|
||||
"title of list",
|
||||
"",
|
||||
get_name (), 80);
|
||||
this->options = new bx_param_num_c (BXP_NULL,
|
||||
"list_option", "", 0, BX_MAX_INT,
|
||||
0);
|
||||
this->choice = new bx_param_num_c (BXP_LIST_CHOICE,
|
||||
"list_choice", "", 0, 1<<31,
|
||||
this->choice = new bx_param_num_c (BXP_NULL,
|
||||
"list_choice", "", 0, BX_MAX_INT,
|
||||
1);
|
||||
this->parent = NULL;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* gui/siminterface.h
|
||||
* $Id: siminterface.h,v 1.14 2001-06-20 14:01:39 bdenney Exp $
|
||||
* $Id: siminterface.h,v 1.15 2001-06-21 14:37:55 bdenney Exp $
|
||||
*
|
||||
* Interface to the simulator, currently only used by control.cc.
|
||||
* The base class bx_simulator_interface_c, contains only virtual functions
|
||||
@ -27,31 +27,32 @@ typedef enum {
|
||||
BXP_ROM_PATH,
|
||||
BXP_ROM_ADDRESS,
|
||||
BXP_VGA_ROM_PATH,
|
||||
BXP_LIST_TITLE, //title field in any bx_list
|
||||
BXP_LIST_OPTIONS, //options field in any bx_list
|
||||
BXP_LIST_CHOICE, //choice field in any bx_list
|
||||
BXP_MEMORY_OPTIONS_MENU,
|
||||
BXP_KBD_SERIAL_DELAY,
|
||||
BXP_FLOPPY_CMD_DELAY,
|
||||
BXP_FLOPPYA_PATH,
|
||||
BXP_FLOPPYA_TYPE,
|
||||
BXP_FLOPPYA_STATUS,
|
||||
BXP_FLOPPYA,
|
||||
BXP_FLOPPYB_PATH,
|
||||
BXP_FLOPPYB_TYPE,
|
||||
BXP_FLOPPYB_STATUS,
|
||||
BXP_FLOPPYB,
|
||||
BXP_DISKC_PRESENT,
|
||||
BXP_DISKC_PATH,
|
||||
BXP_DISKC_CYLINDERS,
|
||||
BXP_DISKC_HEADS,
|
||||
BXP_DISKC_SPT,
|
||||
BXP_DISKC,
|
||||
BXP_DISKD_PRESENT,
|
||||
BXP_DISKD_PATH,
|
||||
BXP_DISKD_CYLINDERS,
|
||||
BXP_DISKD_HEADS,
|
||||
BXP_DISKD_SPT,
|
||||
BXP_DISKD,
|
||||
BXP_CDROM_PRESENT,
|
||||
BXP_CDROM_PATH,
|
||||
BXP_CDROM_INSERTED,
|
||||
BXP_CDROMD,
|
||||
BXP_PRIVATE_COLORMAP,
|
||||
BXP_I440FX_SUPPORT,
|
||||
BXP_NEWHARDDRIVESUPPORT,
|
||||
@ -64,6 +65,13 @@ typedef enum {
|
||||
BXP_LOAD32BITOS_IOLOG,
|
||||
BXP_LOAD32BITOS_INITRD,
|
||||
BXP_BOOTDRIVE,
|
||||
BXP_MENU_MAIN,
|
||||
BXP_MENU_MEMORY,
|
||||
BXP_MENU_INTERFACE,
|
||||
BXP_MENU_DISK,
|
||||
BXP_MENU_SOUND,
|
||||
BXP_MENU_MISC,
|
||||
BXP_MENU_RUNTIME,
|
||||
BXP_THIS_IS_THE_LAST // used to determine length of list
|
||||
} bx_id;
|
||||
|
||||
@ -78,26 +86,6 @@ typedef enum {
|
||||
BXT_LIST
|
||||
} bx_objtype;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Abstract type. I haven't actually found a great use for this bx_any.
|
||||
|
||||
struct bx_any {
|
||||
Bit32u type;
|
||||
union s {
|
||||
int integer;
|
||||
int boolean;
|
||||
struct string {
|
||||
char *val;
|
||||
int alloc_len;
|
||||
};
|
||||
struct list {
|
||||
Bit32u size;
|
||||
bx_any *array;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class bx_object_c {
|
||||
private:
|
||||
@ -112,12 +100,13 @@ public:
|
||||
};
|
||||
|
||||
class bx_param_c : public bx_object_c {
|
||||
private:
|
||||
protected:
|
||||
char *name;
|
||||
char *description;
|
||||
char *text_format; // printf format string. %d for ints, %s for strings, etc.
|
||||
char *ask_format; // format string for asking for a new value
|
||||
int runtime_param;
|
||||
int enabled;
|
||||
public:
|
||||
bx_param_c (bx_id id,
|
||||
char *name,
|
||||
@ -129,6 +118,8 @@ public:
|
||||
void set_runtime_param (int val) { runtime_param = val; }
|
||||
char *get_name () { return name; }
|
||||
char *get_description () { return description; }
|
||||
int get_enabled () { return enabled; }
|
||||
void set_enabled (int enabled) { this->enabled = enabled; }
|
||||
void reset () {}
|
||||
int getint () {return -1;}
|
||||
#if BX_UI_TEXT
|
||||
@ -137,26 +128,6 @@ public:
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef Bit32s (*param_any_event_handler)(class bx_param_any_c *, int set, bx_any val);
|
||||
|
||||
class bx_param_any_c : public bx_param_c {
|
||||
bx_any min, max, val, initial_val;
|
||||
param_any_event_handler handler;
|
||||
public:
|
||||
bx_param_any_c (bx_id id,
|
||||
char *name,
|
||||
char *description,
|
||||
bx_any min, bx_any max, bx_any initial_val);
|
||||
bx_param_any_c (bx_id id,
|
||||
char *name,
|
||||
char *description,
|
||||
bx_any initial_val);
|
||||
void reset ();
|
||||
void set_handler (param_any_event_handler handler) { this->handler = handler; }
|
||||
bx_any get ();
|
||||
void set (bx_any val);
|
||||
};
|
||||
|
||||
typedef Bit32s (*param_event_handler)(class bx_param_c *, int set, Bit32s val);
|
||||
|
||||
class bx_param_num_c : public bx_param_c {
|
||||
@ -170,7 +141,7 @@ public:
|
||||
char *description,
|
||||
Bit32s min, Bit32s max, Bit32s initial_val);
|
||||
void reset ();
|
||||
void set_handler (param_event_handler handler) { this->handler = handler; }
|
||||
void set_handler (param_event_handler handler);
|
||||
Bit32s get ();
|
||||
void set (Bit32s val);
|
||||
void set_base (int base) { this->base = base; }
|
||||
@ -193,7 +164,6 @@ public:
|
||||
};
|
||||
|
||||
class bx_param_enum_c : public bx_param_num_c {
|
||||
Bit32s value_base;
|
||||
char **choices;
|
||||
public:
|
||||
bx_param_enum_c (bx_id id,
|
||||
@ -203,12 +173,12 @@ public:
|
||||
Bit32s initial_val,
|
||||
Bit32s value_base = 0);
|
||||
#if BX_UI_TEXT
|
||||
//virtual void text_print (FILE *fp);
|
||||
//virtual int text_ask (FILE *fpin, FILE *fpout);
|
||||
virtual void text_print (FILE *fp);
|
||||
virtual int text_ask (FILE *fpin, FILE *fpout);
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef Bit32s (*param_string_event_handler)(class bx_param_string_c *, int set, char *val, int maxlen);
|
||||
typedef char* (*param_string_event_handler)(class bx_param_string_c *, int set, char *val, int maxlen);
|
||||
|
||||
class bx_param_string_c : public bx_param_c {
|
||||
int maxsize;
|
||||
@ -221,7 +191,7 @@ public:
|
||||
char *initial_val,
|
||||
int maxsize=-1);
|
||||
void reset ();
|
||||
void set_handler (param_string_event_handler handler) { this->handler = handler; }
|
||||
void set_handler (param_string_event_handler handler);
|
||||
Bit32s get (char *buf, int len);
|
||||
char *getptr () {return val; }
|
||||
void set (char *buf);
|
||||
@ -231,17 +201,6 @@ public:
|
||||
#endif
|
||||
};
|
||||
|
||||
// the BX_LISTOPT_* values define the bits in bx_list_c, that controls
|
||||
// the behavior of the bx_list_c.
|
||||
// When a bx_list_c is displayed as a menu, SHOW_PARENT controls whether
|
||||
// or not the menu shows "0. Return to previous menu" or not.
|
||||
#define BX_LISTOPT_SHOW_PARENT (1<<0)
|
||||
// Some lists are best displayed shown as menus, others as a series of related
|
||||
// questions. Options is a bx_param so that if necessary the bx_list could
|
||||
// install a handler to cause get/set of options to have side effects.
|
||||
#define BX_LISTOPT_SERIES_ASK (1<<1)
|
||||
|
||||
|
||||
class bx_list_c : public bx_param_c {
|
||||
private:
|
||||
// just a list of bx_param_c objects. size tells current number of
|
||||
@ -272,8 +231,8 @@ public:
|
||||
// related questions.
|
||||
BX_SERIES_ASK = (1<<1)
|
||||
} bx_listopt_bits;
|
||||
bx_list_c (bx_id id, int maxsize);
|
||||
bx_list_c (bx_id id, bx_param_c **init_list);
|
||||
//bx_list_c (bx_id id, int maxsize);
|
||||
bx_list_c (bx_id id, char *name, char *description, bx_param_c **init_list);
|
||||
void add (bx_param_c *param);
|
||||
bx_param_c *get (int index);
|
||||
bx_param_num_c *get_options () { return options; }
|
||||
@ -301,6 +260,8 @@ extern char *floppy_type_names[];
|
||||
extern int n_floppy_type_names;
|
||||
extern char *floppy_status_names[];
|
||||
extern int n_floppy_status_names;
|
||||
extern char *floppy_bootdisk_names[];
|
||||
extern int n_floppy_bootdisk_names;
|
||||
|
||||
typedef struct {
|
||||
bx_param_string_c *Opath;
|
||||
@ -320,7 +281,7 @@ struct bx_cdrom_options
|
||||
{
|
||||
bx_param_bool_c *Opresent;
|
||||
bx_param_string_c *Opath;
|
||||
bx_param_bool_c *Oinserted;
|
||||
bx_param_enum_c *Oinserted;
|
||||
};
|
||||
|
||||
|
||||
|
270
bochs/main.cc
270
bochs/main.cc
@ -113,40 +113,124 @@ bx_param_handler (bx_param_c *param, int set, Bit32s val)
|
||||
return val;
|
||||
}
|
||||
|
||||
char *bx_param_string_handler (bx_param_string_c *param, int set, char *val, int maxlen)
|
||||
{
|
||||
int empty = 0;
|
||||
if ((strlen(val) < 1) || !strcmp ("none", val)) {
|
||||
empty = 1;
|
||||
val = "none";
|
||||
}
|
||||
switch (param->get_id ()) {
|
||||
case BXP_FLOPPYA_PATH:
|
||||
if (set==1) {
|
||||
SIM->get_param_num(BXP_FLOPPYA_TYPE)->set_enabled (!empty);
|
||||
SIM->get_param_num(BXP_FLOPPYA_STATUS)->set_enabled (!empty);
|
||||
}
|
||||
break;
|
||||
case BXP_FLOPPYB_PATH:
|
||||
if (set==1) {
|
||||
SIM->get_param_num(BXP_FLOPPYB_TYPE)->set_enabled (!empty);
|
||||
SIM->get_param_num(BXP_FLOPPYB_STATUS)->set_enabled (!empty);
|
||||
}
|
||||
break;
|
||||
case BXP_DISKC_PATH:
|
||||
if (set==1) {
|
||||
SIM->get_param_num(BXP_DISKC_PRESENT)->set (!empty);
|
||||
SIM->get_param_num(BXP_DISKC_CYLINDERS)->set_enabled (!empty);
|
||||
SIM->get_param_num(BXP_DISKC_HEADS)->set_enabled (!empty);
|
||||
SIM->get_param_num(BXP_DISKC_SPT)->set_enabled (!empty);
|
||||
}
|
||||
break;
|
||||
case BXP_DISKD_PATH:
|
||||
if (set==1) {
|
||||
SIM->get_param_num(BXP_DISKD_PRESENT)->set (!empty);
|
||||
SIM->get_param_num(BXP_DISKD_CYLINDERS)->set_enabled (!empty);
|
||||
SIM->get_param_num(BXP_DISKD_HEADS)->set_enabled (!empty);
|
||||
SIM->get_param_num(BXP_DISKD_SPT)->set_enabled (!empty);
|
||||
}
|
||||
break;
|
||||
case BXP_CDROM_PATH:
|
||||
if (set==1) {
|
||||
SIM->get_param_num(BXP_CDROM_PRESENT)->set (!empty);
|
||||
SIM->get_param_num(BXP_CDROM_INSERTED)->set_enabled (!empty);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
void bx_init_options ()
|
||||
{
|
||||
bx_list_c *menu;
|
||||
|
||||
// floppya
|
||||
bx_options.floppya.Opath = new bx_param_string_c (BXP_FLOPPYA_PATH,
|
||||
"floppya:path",
|
||||
"Floppy A image",
|
||||
"Pathname of first floppy image file or device. If you're booting from floppy, this should be a bootable floppy.",
|
||||
"", BX_PATHNAME_LEN);
|
||||
bx_options.floppya.Opath->set_ask_format ("Enter new filename, or 'none' for no disk: [%s] ");
|
||||
bx_options.floppya.Otype = new bx_param_enum_c (BXP_FLOPPYA_TYPE,
|
||||
"floppya:type",
|
||||
"Type of floppy disk",
|
||||
floppy_status_names,
|
||||
floppy_type_names,
|
||||
BX_FLOPPY_NONE,
|
||||
BX_FLOPPY_NONE);
|
||||
bx_options.floppya.Otype->set_ask_format ("What type of floppy disk? [%s] ");
|
||||
bx_options.floppya.Oinitial_status = new bx_param_enum_c (BXP_FLOPPYA_STATUS,
|
||||
"floppya:status",
|
||||
"Is floppya inserted",
|
||||
"Inserted or ejected",
|
||||
floppy_type_names,
|
||||
BX_EJECTED,
|
||||
floppy_status_names,
|
||||
BX_INSERTED,
|
||||
BX_EJECTED);
|
||||
bx_options.floppya.Oinitial_status->set_ask_format ("Is the floppy inserted or ejected? [%s] ");
|
||||
bx_options.floppya.Opath->set_format ("%s");
|
||||
bx_options.floppya.Otype->set_format (", size=%s, ");
|
||||
bx_options.floppya.Oinitial_status->set_format ("%s");
|
||||
bx_param_c *floppya_init_list[] = {
|
||||
bx_options.floppya.Opath,
|
||||
bx_options.floppya.Otype,
|
||||
bx_options.floppya.Oinitial_status,
|
||||
NULL
|
||||
};
|
||||
menu = new bx_list_c (BXP_FLOPPYA, "Floppy Disk 0", "All options for first floppy disk", floppya_init_list);
|
||||
menu->get_options ()->set (menu->BX_SERIES_ASK);
|
||||
bx_options.floppya.Opath->set_handler (bx_param_string_handler);
|
||||
bx_options.floppya.Opath->set ("none");
|
||||
|
||||
bx_options.floppyb.Opath = new bx_param_string_c (BXP_FLOPPYB_PATH,
|
||||
"floppyb:path",
|
||||
"Pathname of second floppy image file or device.",
|
||||
"", BX_PATHNAME_LEN);
|
||||
bx_options.floppyb.Opath->set_ask_format ("Enter new filename, or 'none' for no disk: [%s] ");
|
||||
bx_options.floppyb.Otype = new bx_param_enum_c (BXP_FLOPPYB_TYPE,
|
||||
"floppyb:type",
|
||||
"Type of floppy disk",
|
||||
floppy_type_names,
|
||||
BX_FLOPPY_NONE,
|
||||
BX_FLOPPY_NONE);
|
||||
bx_options.floppyb.Oinitial_status = new bx_param_enum_c (BXP_FLOPPYA_STATUS,
|
||||
"floppyb:status",
|
||||
bx_options.floppyb.Otype->set_ask_format ("What type of floppy disk? [%s] ");
|
||||
bx_options.floppyb.Oinitial_status = new bx_param_enum_c (BXP_FLOPPYB_STATUS,
|
||||
"Is floppyb inserted",
|
||||
"Inserted or ejected",
|
||||
floppy_type_names,
|
||||
BX_EJECTED,
|
||||
floppy_status_names,
|
||||
BX_INSERTED,
|
||||
BX_EJECTED);
|
||||
bx_options.floppyb.Oinitial_status->set_ask_format ("Is the floppy inserted or ejected? [%s] ");
|
||||
bx_options.floppyb.Oinitial_status->set_format ("%s");
|
||||
bx_options.floppyb.Opath->set_format ("%s");
|
||||
bx_options.floppyb.Otype->set_format (", size=%s, ");
|
||||
bx_options.floppyb.Oinitial_status->set_format ("%s");
|
||||
bx_param_c *floppyb_init_list[] = {
|
||||
bx_options.floppyb.Opath,
|
||||
bx_options.floppyb.Otype,
|
||||
bx_options.floppyb.Oinitial_status,
|
||||
NULL
|
||||
};
|
||||
menu = new bx_list_c (BXP_FLOPPYB, "Floppy Disk 1", "All options for second floppy disk", floppyb_init_list);
|
||||
menu->get_options ()->set (menu->BX_SERIES_ASK);
|
||||
bx_options.floppyb.Opath->set_handler (bx_param_string_handler);
|
||||
bx_options.floppyb.Opath->set ("none");
|
||||
|
||||
// diskc options
|
||||
bx_options.diskc.Opresent = new bx_param_bool_c (BXP_DISKC_PRESENT,
|
||||
@ -154,24 +238,45 @@ void bx_init_options ()
|
||||
"Controls whether diskc is installed or not",
|
||||
0);
|
||||
bx_options.diskc.Opath = new bx_param_string_c (BXP_DISKC_PATH,
|
||||
"diskc:path",
|
||||
"",
|
||||
"Pathname of the hard drive image",
|
||||
"", BX_PATHNAME_LEN);
|
||||
bx_options.diskc.Ocylinders = new bx_param_num_c (BXP_DISKC_CYLINDERS,
|
||||
"diskc:cylinders",
|
||||
"Number of cylinders",
|
||||
1, 65535,
|
||||
0);
|
||||
1);
|
||||
bx_options.diskc.Oheads = new bx_param_num_c (BXP_DISKC_HEADS,
|
||||
"diskc:heads",
|
||||
"Number of heads",
|
||||
1, 65535,
|
||||
0);
|
||||
1);
|
||||
bx_options.diskc.Ospt = new bx_param_num_c (BXP_DISKC_SPT,
|
||||
"diskc:spt",
|
||||
"Number of sectors per track",
|
||||
1, 65535,
|
||||
0);
|
||||
1);
|
||||
bx_options.diskc.Opath->set_ask_format ("Enter new filename, or 'none' for no disk: [%s] ");
|
||||
bx_options.diskc.Ocylinders->set_ask_format ("Enter number of cylinders: [%d] ");
|
||||
bx_options.diskc.Oheads->set_ask_format ("Enter number of heads: [%d] ");
|
||||
bx_options.diskc.Ospt->set_ask_format ("Enter number of sectors per track: [%d] ");
|
||||
bx_options.diskc.Opath->set_format ("%s");
|
||||
bx_options.diskc.Ocylinders->set_format (", %d cylinders, ");
|
||||
bx_options.diskc.Oheads->set_format ("%d heads, ");
|
||||
bx_options.diskc.Ospt->set_format ("%d sectors/track");
|
||||
bx_param_c *diskc_init_list[] = {
|
||||
bx_options.diskc.Opath,
|
||||
bx_options.diskc.Ocylinders,
|
||||
bx_options.diskc.Oheads,
|
||||
bx_options.diskc.Ospt,
|
||||
NULL
|
||||
};
|
||||
menu = new bx_list_c (BXP_DISKC, "Hard disk 0", "All options for hard disk 0", diskc_init_list);
|
||||
menu->get_options ()->set (menu->BX_SERIES_ASK);
|
||||
// if path is the word "none", then do not ask the other options and
|
||||
// set present=0.
|
||||
bx_options.diskc.Opath->set_handler (bx_param_string_handler);
|
||||
bx_options.diskc.Opath->set ("none");
|
||||
|
||||
// diskd options
|
||||
bx_options.diskd.Opresent = new bx_param_bool_c (BXP_DISKD_PRESENT,
|
||||
@ -186,31 +291,92 @@ void bx_init_options ()
|
||||
"diskd:cylinders",
|
||||
"Number of cylinders",
|
||||
1, 65535,
|
||||
0);
|
||||
1);
|
||||
bx_options.diskd.Oheads = new bx_param_num_c (BXP_DISKD_HEADS,
|
||||
"diskd:heads",
|
||||
"Number of heads",
|
||||
1, 65535,
|
||||
0);
|
||||
1);
|
||||
bx_options.diskd.Ospt = new bx_param_num_c (BXP_DISKD_SPT,
|
||||
"diskd:spt",
|
||||
"Number of sectors per track",
|
||||
1, 65535,
|
||||
0);
|
||||
1);
|
||||
bx_options.diskd.Opath->set_ask_format ("Enter new filename, or none for no disk: [%s] ");
|
||||
bx_options.diskd.Ocylinders->set_ask_format ("Enter number of cylinders: [%d] ");
|
||||
bx_options.diskd.Oheads->set_ask_format ("Enter number of heads: [%d] ");
|
||||
bx_options.diskd.Ospt->set_ask_format ("Enter number of sectors per track: [%d] ");
|
||||
bx_options.diskd.Opath->set_format ("%s");
|
||||
bx_options.diskd.Ocylinders->set_format (", %d cylinders, ");
|
||||
bx_options.diskd.Oheads->set_format ("%d heads, ");
|
||||
bx_options.diskd.Ospt->set_format ("%d sectors/track");
|
||||
bx_param_c *diskd_init_list[] = {
|
||||
bx_options.diskd.Opath,
|
||||
bx_options.diskd.Ocylinders,
|
||||
bx_options.diskd.Oheads,
|
||||
bx_options.diskd.Ospt,
|
||||
NULL
|
||||
};
|
||||
menu = new bx_list_c (BXP_DISKD, "Hard disk 1", "All options for hard disk 1", diskd_init_list);
|
||||
menu->get_options ()->set (menu->BX_SERIES_ASK);
|
||||
bx_options.diskd.Opath->set_handler (bx_param_string_handler);
|
||||
bx_options.diskd.Opath->set ("none");
|
||||
|
||||
// cdrom options
|
||||
bx_options.cdromd.Opresent = new bx_param_bool_c (BXP_CDROM_PRESENT,
|
||||
"cdrom:present",
|
||||
"CDROM is present",
|
||||
"Controls whether cdromd is installed or not",
|
||||
0);
|
||||
bx_options.cdromd.Opath = new bx_param_string_c (BXP_CDROM_PATH,
|
||||
"cdrom:path",
|
||||
"CDROM image filename",
|
||||
"Pathname of the cdrom device or image",
|
||||
"", BX_PATHNAME_LEN);
|
||||
bx_options.cdromd.Oinserted = new bx_param_bool_c (BXP_CDROM_PRESENT,
|
||||
"cdrom:present",
|
||||
"Controls whether cdromd is installed or not",
|
||||
0);
|
||||
bx_options.cdromd.Opath->set_format ("%s");
|
||||
bx_options.cdromd.Opath->set_ask_format ("Enter new filename, or 'none' for no CDROM: [%s] ");
|
||||
bx_options.cdromd.Oinserted = new bx_param_enum_c (BXP_CDROM_INSERTED,
|
||||
"Is the CDROM inserted or ejected",
|
||||
"Inserted or ejected",
|
||||
floppy_status_names,
|
||||
BX_INSERTED,
|
||||
BX_EJECTED);
|
||||
bx_options.cdromd.Oinserted->set_format (", %s");
|
||||
bx_options.cdromd.Oinserted->set_ask_format ("Is the CDROM inserted or ejected? [%s] ");
|
||||
bx_param_c *cdromd_init_list[] = {
|
||||
bx_options.cdromd.Opath,
|
||||
bx_options.cdromd.Oinserted,
|
||||
NULL
|
||||
};
|
||||
menu = new bx_list_c (BXP_CDROMD, "CDROM", "Options for the CDROM", cdromd_init_list);
|
||||
menu->get_options ()->set (menu->BX_SERIES_ASK);
|
||||
bx_options.cdromd.Opath->set_handler (bx_param_string_handler);
|
||||
bx_options.cdromd.Opath->set ("none");
|
||||
|
||||
bx_options.OnewHardDriveSupport = new bx_param_bool_c (BXP_NEWHARDDRIVESUPPORT,
|
||||
"New Hard Drive Support",
|
||||
"Enables new features found on newer hard drives.",
|
||||
1);
|
||||
|
||||
bx_options.Obootdrive = new bx_param_enum_c (BXP_BOOTDRIVE,
|
||||
"bootdrive",
|
||||
"Boot A or C",
|
||||
floppy_bootdisk_names,
|
||||
BX_BOOT_FLOPPYA,
|
||||
BX_BOOT_FLOPPYA);
|
||||
bx_options.Obootdrive->set_format ("Boot from: %s drive");
|
||||
bx_options.Obootdrive->set_ask_format ("Boot from floppy drive or hard drive? [%s] ");
|
||||
// disk menu
|
||||
bx_param_c *disk_menu_init_list[] = {
|
||||
SIM->get_param (BXP_FLOPPYA),
|
||||
SIM->get_param (BXP_FLOPPYB),
|
||||
SIM->get_param (BXP_DISKC),
|
||||
SIM->get_param (BXP_DISKD),
|
||||
SIM->get_param (BXP_CDROMD),
|
||||
SIM->get_param (BXP_NEWHARDDRIVESUPPORT),
|
||||
SIM->get_param (BXP_BOOTDRIVE),
|
||||
NULL
|
||||
};
|
||||
menu = new bx_list_c (BXP_MENU_DISK, "Bochs Disk Options", "diskmenu", disk_menu_init_list);
|
||||
menu->get_options ()->set (menu->BX_SHOW_PARENT);
|
||||
|
||||
// memory options menu
|
||||
bx_options.memory.Osize = new bx_param_num_c (BXP_MEM_SIZE,
|
||||
@ -237,30 +403,47 @@ void bx_init_options ()
|
||||
"Pathname of VGA ROM image to load",
|
||||
"", BX_PATHNAME_LEN);
|
||||
bx_options.vgarom.Opath->set_format ("Name of VGA BIOS image: %s");
|
||||
bx_param_c *init_list[] = {
|
||||
bx_param_c *memory_init_list[] = {
|
||||
bx_options.memory.Osize,
|
||||
bx_options.vgarom.Opath,
|
||||
bx_options.rom.Opath,
|
||||
bx_options.rom.Oaddress,
|
||||
NULL
|
||||
};
|
||||
bx_list_c *menu = new bx_list_c (BXP_MEMORY_OPTIONS_MENU, init_list);
|
||||
menu->get_title ()->set ("Bochs Memory Options");
|
||||
menu = new bx_list_c (BXP_MENU_MEMORY, "Bochs Memory Options", "memmenu", memory_init_list);
|
||||
menu->get_options ()->set (menu->BX_SHOW_PARENT);
|
||||
|
||||
|
||||
|
||||
bx_options.Oips = new bx_param_num_c (BXP_IPS,
|
||||
"ips",
|
||||
"Emulated instructions per second, used to calibrate bochs emulated\ntime with wall clock time.",
|
||||
1, BX_MAX_INT,
|
||||
500000);
|
||||
bx_options.Ovga_update_interval = new bx_param_num_c (BXP_VGA_UPDATE_INTERVAL,
|
||||
"vga_update_interval",
|
||||
"VGA Update Interval",
|
||||
"Number of microseconds between VGA updates",
|
||||
1, BX_MAX_INT,
|
||||
30000);
|
||||
bx_options.Ovga_update_interval->set_handler (bx_param_handler);
|
||||
bx_options.Ovga_update_interval->set_ask_format ("Type a new value for VGA update interval: [%d] ");
|
||||
bx_options.Omouse_enabled = new bx_param_bool_c (BXP_MOUSE_ENABLED,
|
||||
"Enable the mouse",
|
||||
"Controls whether the mouse sends events to bochs",
|
||||
0);
|
||||
bx_options.Omouse_enabled->set_handler (bx_param_handler);
|
||||
bx_options.Oips = new bx_param_num_c (BXP_IPS,
|
||||
"Emulated instructions per second (IPS)",
|
||||
"Emulated instructions per second, used to calibrate bochs emulated\ntime with wall clock time.",
|
||||
1, BX_MAX_INT,
|
||||
500000);
|
||||
bx_options.Oprivate_colormap = new bx_param_bool_c (BXP_PRIVATE_COLORMAP,
|
||||
"Use a private colormap",
|
||||
"Request that the GUI create and use it's own non-shared colormap. This colormap will be used when in the bochs window. If not enabled, a shared colormap scheme may be used. Not implemented on all GUI's.",
|
||||
0);
|
||||
bx_param_c *interface_init_list[] = {
|
||||
bx_options.Ovga_update_interval,
|
||||
bx_options.Omouse_enabled,
|
||||
bx_options.Oips,
|
||||
bx_options.Oprivate_colormap,
|
||||
NULL
|
||||
};
|
||||
menu = new bx_list_c (BXP_MENU_INTERFACE, "Bochs Interface Menu", "intfmenu", interface_init_list);
|
||||
menu->get_options ()->set (menu->BX_SHOW_PARENT);
|
||||
|
||||
bx_options.Okeyboard_serial_delay = new bx_param_num_c (BXP_KBD_SERIAL_DELAY,
|
||||
"keyboard_serial_delay",
|
||||
"Approximate time in microseconds that it takes one character to be transfered from the keyboard to controller over the serial path.",
|
||||
@ -271,27 +454,15 @@ void bx_init_options ()
|
||||
"Time in microseconds to wait before completing some floppy commands such as read/write/seek/etc, which normally have a delay associated. This used to be hardwired to 50,000 before.",
|
||||
1, BX_MAX_INT,
|
||||
50000);
|
||||
bx_options.Omouse_enabled = new bx_param_bool_c (BXP_MOUSE_ENABLED,
|
||||
"mouse_enabled",
|
||||
"Controls whether the mouse sends events to bochs",
|
||||
0);
|
||||
bx_options.Omouse_enabled->set_handler (bx_param_handler);
|
||||
bx_options.Oprivate_colormap = new bx_param_bool_c (BXP_PRIVATE_COLORMAP,
|
||||
"private_colormap",
|
||||
"Request that the GUI create and use it's own non-shared colormap. This colormap will be used when in the bochs window. If not enabled, a shared colormap scheme may be used. Not implemented on all GUI's.",
|
||||
0);
|
||||
bx_options.Oi440FXSupport = new bx_param_bool_c (BXP_I440FX_SUPPORT,
|
||||
"i440FXSupport",
|
||||
"Controls whether to emulate PCI I440FX",
|
||||
0);
|
||||
bx_options.OnewHardDriveSupport = new bx_param_bool_c (BXP_NEWHARDDRIVESUPPORT,
|
||||
"newharddrivesupport",
|
||||
"Enables new features found on newer hard drives.",
|
||||
1);
|
||||
bx_options.log.Ofilename = new bx_param_string_c (BXP_LOG_FILENAME,
|
||||
"log:filename",
|
||||
"Pathname of bochs log file",
|
||||
"-", BX_PATHNAME_LEN);
|
||||
bx_options.log.Ofilename->set_ask_format ("Enter log filename: [%s] ");
|
||||
bx_options.cmos.Opath = new bx_param_string_c (BXP_CMOS_PATH,
|
||||
"cmos:path",
|
||||
"Pathname of CMOS image",
|
||||
@ -303,7 +474,7 @@ void bx_init_options ()
|
||||
bx_options.cmos.Otime0 = new bx_param_num_c (BXP_CMOS_TIME0,
|
||||
"cmos:time0",
|
||||
"Start time for Bochs CMOS clock, used if you really want two runs to be identical (cosimulation)",
|
||||
1, BX_MAX_INT,
|
||||
0, BX_MAX_INT,
|
||||
0);
|
||||
bx_options.load32bitOSImage.OwhichOS = new bx_param_num_c (BXP_LOAD32BITOS_WHICH,
|
||||
"load32bitOS:which",
|
||||
@ -322,11 +493,6 @@ void bx_init_options ()
|
||||
"load32bitOS:initrd",
|
||||
"Initrd",
|
||||
"", BX_PATHNAME_LEN);
|
||||
bx_options.Obootdrive = new bx_param_num_c (BXP_BOOTDRIVE,
|
||||
"bootdrive",
|
||||
"Boot A or C",
|
||||
BX_BOOT_FLOPPYA, BX_BOOT_DISKC,
|
||||
BX_BOOT_FLOPPYA);
|
||||
}
|
||||
|
||||
void bx_print_header(void);
|
||||
|
Loading…
Reference in New Issue
Block a user