- implemented dependent list support for enum parameters. Each enum value has a
Bit64u value with the "enable bitmap" (e. g. bit #0 is the enable value for the first item of the dependent list). TODO: use this feature in win32 and wx dialogs - ata drive type and loader hack parameters now using the enum dependent list - avoid multiple dependencies in the SB16 config menu
This commit is contained in:
parent
8c605c029d
commit
d987b68127
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: config.cc,v 1.162 2009-03-15 21:16:16 vruppert Exp $
|
||||
// $Id: config.cc,v 1.163 2009-03-16 21:07:44 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2002 MandrakeSoft S.A.
|
||||
@ -92,34 +92,13 @@ static Bit64s bx_param_handler(bx_param_c *param, int set, Bit64s val)
|
||||
if (set) {
|
||||
switch (val) {
|
||||
case BX_ATA_DEVICE_DISK:
|
||||
SIM->get_param_num("present", base)->set(1);
|
||||
SIM->get_param("mode", base)->set_enabled(1);
|
||||
SIM->get_param("path", base)->set_enabled(1);
|
||||
((bx_param_filename_c*)SIM->get_param("path", base))->set_extension("img");
|
||||
//SIM->get_param("journal", base)->set_enabled(1);
|
||||
SIM->get_param("cylinders", base)->set_enabled(1);
|
||||
SIM->get_param("heads", base)->set_enabled(1);
|
||||
SIM->get_param("spt", base)->set_enabled(1);
|
||||
SIM->get_param("status", base)->set_enabled(0);
|
||||
SIM->get_param("model", base)->set_enabled(1);
|
||||
SIM->get_param("biosdetect", base)->set_enabled(1);
|
||||
SIM->get_param("translation", base)->set_enabled(1);
|
||||
SIM->get_param("path", base)->set_runtime_param(0);
|
||||
SIM->get_param("status", base)->set_runtime_param(0);
|
||||
break;
|
||||
case BX_ATA_DEVICE_CDROM:
|
||||
SIM->get_param_num("present", base)->set(1);
|
||||
SIM->get_param("mode", base)->set_enabled(0);
|
||||
SIM->get_param("path", base)->set_enabled(1);
|
||||
((bx_param_filename_c*)SIM->get_param("path", base))->set_extension("iso");
|
||||
SIM->get_param("journal", base)->set_enabled(0);
|
||||
SIM->get_param("cylinders", base)->set_enabled(0);
|
||||
SIM->get_param("heads", base)->set_enabled(0);
|
||||
SIM->get_param("spt", base)->set_enabled(0);
|
||||
SIM->get_param("status", base)->set_enabled(1);
|
||||
SIM->get_param("model", base)->set_enabled(1);
|
||||
SIM->get_param("biosdetect", base)->set_enabled(1);
|
||||
SIM->get_param("translation", base)->set_enabled(0);
|
||||
SIM->get_param("path", base)->set_runtime_param(1);
|
||||
SIM->get_param("status", base)->set_runtime_param(1);
|
||||
break;
|
||||
@ -128,14 +107,7 @@ static Bit64s bx_param_handler(bx_param_c *param, int set, Bit64s val)
|
||||
}
|
||||
} else {
|
||||
param->get_param_path(pname, BX_PATHNAME_LEN);
|
||||
if (!strcmp(pname, BXPN_LOAD32BITOS_WHICH)) {
|
||||
if (set) {
|
||||
int enable = (val != Load32bitOSNone);
|
||||
SIM->get_param(BXPN_LOAD32BITOS_PATH)->set_enabled(enable);
|
||||
SIM->get_param(BXPN_LOAD32BITOS_IOLOG)->set_enabled(enable);
|
||||
SIM->get_param(BXPN_LOAD32BITOS_INITRD)->set_enabled(enable);
|
||||
}
|
||||
} else if (!strcmp(pname, BXPN_FLOPPYA_TYPE)) {
|
||||
if (!strcmp(pname, BXPN_FLOPPYA_TYPE)) {
|
||||
if (set) {
|
||||
if (val == BX_FLOPPY_AUTO) {
|
||||
val = get_floppy_type_from_image(SIM->get_param_string(BXPN_FLOPPYA_PATH)->getptr());
|
||||
@ -965,7 +937,8 @@ void bx_init_options()
|
||||
iolog->set_ask_format("Enter pathname of I/O log: [%s] ");
|
||||
initrd->set_ask_format("Enter pathname of initrd: [%s] ");
|
||||
load32bitos->set_options(menu->SERIES_ASK);
|
||||
whichOS->set_handler(bx_param_handler);
|
||||
whichOS->set_dependent_list(load32bitos->clone());
|
||||
whichOS->set_dependent_bitmap(Load32bitOSNone, 0);
|
||||
whichOS->set(Load32bitOSNone);
|
||||
boot_params->set_options(menu->SHOW_PARENT);
|
||||
|
||||
@ -1262,6 +1235,21 @@ void bx_init_options()
|
||||
// the master/slave menu depends on the ATA channel's enabled flag
|
||||
enabled->get_dependent_list()->add(menu);
|
||||
|
||||
// some items depend on the drive type
|
||||
bx_param_c *type_deplist[] = {
|
||||
mode,
|
||||
status,
|
||||
cylinders,
|
||||
heads,
|
||||
spt,
|
||||
translation,
|
||||
NULL
|
||||
};
|
||||
deplist = new bx_list_c(NULL, "deplist", "", type_deplist);
|
||||
type->set_dependent_list(deplist);
|
||||
type->set_dependent_bitmap(BX_ATA_DEVICE_DISK, 0x3d);
|
||||
type->set_dependent_bitmap(BX_ATA_DEVICE_CDROM, 0x02);
|
||||
|
||||
type->set_handler(bx_param_handler);
|
||||
mode->set_handler(bx_param_handler);
|
||||
status->set_handler(bx_param_handler);
|
||||
@ -1627,7 +1615,11 @@ void bx_init_options()
|
||||
loglevel->set_options(loglevel->USE_SPIN_CONTROL);
|
||||
loglevel->set_group("SB16");
|
||||
dmatimer->set_group("SB16");
|
||||
enabled->set_dependent_list(menu->clone());
|
||||
deplist = new bx_list_c(NULL, 3);
|
||||
deplist->add(midimode);
|
||||
deplist->add(wavemode);
|
||||
deplist->add(loglevel);
|
||||
enabled->set_dependent_list(deplist);
|
||||
deplist = new bx_list_c(NULL, 1);
|
||||
deplist->add(midifile);
|
||||
midimode->set_dependent_list(deplist);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: siminterface.cc,v 1.198 2009-03-15 21:16:16 vruppert Exp $
|
||||
// $Id: siminterface.cc,v 1.199 2009-03-16 21:07:44 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2009 The Bochs Project
|
||||
@ -1474,7 +1474,7 @@ void bx_param_num_c::update_dependents()
|
||||
for (int i=0; i<dependent_list->get_size(); i++) {
|
||||
bx_param_c *param = dependent_list->get(i);
|
||||
if (param != this)
|
||||
param->set_enabled(en);
|
||||
param->set_enabled(en);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1776,9 +1776,24 @@ bx_param_enum_c::bx_param_enum_c(bx_param_c *parent,
|
||||
// now that the max is known, replace the BX_MAX_BIT64S sent to the parent
|
||||
// class constructor with the real max.
|
||||
this->max = value_base + (p - choices - 1);
|
||||
this->deps_bitmap = NULL;
|
||||
set(initial_val);
|
||||
}
|
||||
|
||||
bx_param_enum_c::~bx_param_enum_c()
|
||||
{
|
||||
if (deps_bitmap != NULL) {
|
||||
free(deps_bitmap);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void bx_param_enum_c::set(Bit64s val)
|
||||
{
|
||||
bx_param_num_c::set(val);
|
||||
update_dependents();
|
||||
}
|
||||
|
||||
int bx_param_enum_c::find_by_name(const char *string)
|
||||
{
|
||||
const char **p;
|
||||
@ -1797,6 +1812,46 @@ bx_bool bx_param_enum_c::set_by_name(const char *string)
|
||||
return 1;
|
||||
}
|
||||
|
||||
void bx_param_enum_c::set_dependent_list(bx_list_c *l)
|
||||
{
|
||||
dependent_list = l;
|
||||
deps_bitmap = (Bit64u*)malloc(sizeof(Bit64u) * (max - min + 1));
|
||||
for (int i=0; i<(max-min+1); i++) {
|
||||
deps_bitmap[i] = (1 << (l->get_size())) - 1;
|
||||
}
|
||||
update_dependents();
|
||||
}
|
||||
|
||||
void bx_param_enum_c::set_dependent_bitmap(Bit64s value, Bit64u bitmap)
|
||||
{
|
||||
if (deps_bitmap != NULL) {
|
||||
deps_bitmap[value - min] = bitmap;
|
||||
}
|
||||
}
|
||||
|
||||
Bit64u bx_param_enum_c::get_dependent_bitmap(Bit64s value)
|
||||
{
|
||||
if (deps_bitmap != NULL) {
|
||||
return deps_bitmap[value - min];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bx_param_enum_c::update_dependents()
|
||||
{
|
||||
if ((dependent_list != NULL) && (deps_bitmap != NULL)) {
|
||||
Bit64u en_bmap = deps_bitmap[val.number - min];
|
||||
Bit64u mask = 0x1;
|
||||
for (int i=0; i<dependent_list->get_size(); i++) {
|
||||
int en = (en_bmap & mask) && enabled;
|
||||
bx_param_c *param = dependent_list->get(i);
|
||||
if (param != this)
|
||||
param->set_enabled(en);
|
||||
mask <<= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bx_param_string_c::bx_param_string_c(bx_param_c *parent,
|
||||
const char *name,
|
||||
const char *label,
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: siminterface.h,v 1.232 2009-03-15 21:16:16 vruppert Exp $
|
||||
// $Id: siminterface.h,v 1.233 2009-03-16 21:07:44 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2009 The Bochs Project
|
||||
@ -844,6 +844,9 @@ public:
|
||||
|
||||
class BOCHSAPI bx_param_enum_c : public bx_param_num_c {
|
||||
const char **choices;
|
||||
bx_list_c *dependent_list;
|
||||
Bit64u *deps_bitmap;
|
||||
void update_dependents();
|
||||
public:
|
||||
bx_param_enum_c(bx_param_c *parent,
|
||||
const char *name,
|
||||
@ -852,10 +855,15 @@ public:
|
||||
const char **choices,
|
||||
Bit64s initial_val,
|
||||
Bit64s value_base = 0);
|
||||
virtual ~bx_param_enum_c();
|
||||
const char *get_choice(int n) { return choices[n]; }
|
||||
const char *get_selected() { return choices[val.number - min]; }
|
||||
int find_by_name(const char *string);
|
||||
virtual void set(Bit64s val);
|
||||
bx_bool set_by_name(const char *string);
|
||||
void set_dependent_list(bx_list_c *l);
|
||||
void set_dependent_bitmap(Bit64s value, Bit64u bitmap);
|
||||
Bit64u get_dependent_bitmap(Bit64s value);
|
||||
#if BX_USE_TEXTCONFIG
|
||||
virtual void text_print(FILE *fp);
|
||||
virtual int text_ask(FILE *fpin, FILE *fpout);
|
||||
|
Loading…
Reference in New Issue
Block a user