- changed parameter type for floppy status (inserted/ejected) to bx_param_bool_c

This commit is contained in:
Volker Ruppert 2009-03-25 18:33:43 +00:00
parent 1c0f788d3f
commit 1dee09c468
8 changed files with 59 additions and 66 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: config.cc,v 1.170 2009-03-24 16:28:02 vruppert Exp $
// $Id: config.cc,v 1.171 2009-03-25 18:33:30 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -115,12 +115,12 @@ static Bit64s bx_param_handler(bx_param_c *param, int set, Bit64s val)
}
} else if (!strcmp(pname, BXPN_FLOPPYA_STATUS)) {
if ((set) && (SIM->get_init_done())) {
DEV_floppy_set_media_status(0, val == BX_INSERTED);
DEV_floppy_set_media_status(0, val);
bx_gui->update_drive_status_buttons();
}
} else if (!strcmp(pname, BXPN_FLOPPYB_STATUS)) {
if ((set) && (SIM->get_init_done())) {
DEV_floppy_set_media_status(1, val == BX_INSERTED);
DEV_floppy_set_media_status(1, val);
bx_gui->update_drive_status_buttons();
}
} else if (!strcmp(pname, BXPN_MOUSE_ENABLED)) {
@ -204,14 +204,14 @@ const char *bx_param_string_handler(bx_param_string_c *param, int set,
}
}
if ((DEV_floppy_present()) &&
(SIM->get_param_enum("status", base)->get() == BX_INSERTED)) {
(SIM->get_param_bool("status", base)->get() == 1)) {
// tell the device model that we removed, then inserted the disk
DEV_floppy_set_media_status(device, 0);
DEV_floppy_set_media_status(device, 1);
}
} else {
SIM->get_param_enum("type", base)->set_enabled(!empty);
SIM->get_param_enum("status", base)->set_enabled(!empty);
SIM->get_param_bool("status", base)->set_enabled(!empty);
}
}
#if BX_PLUGINS
@ -243,7 +243,7 @@ static int bx_param_enable_handler(bx_param_c *param, int val)
sparam = (bx_param_string_c*)param;
empty = (strlen(sparam->getptr()) < 1) || !strcmp(sparam->getptr(), "none");
SIM->get_param_enum("type", base)->set_enabled(val && !empty);
SIM->get_param_enum("status", base)->set_enabled(val && !empty);
SIM->get_param_bool("status", base)->set_enabled(val && !empty);
} else {
BX_PANIC(("bx_param_enable_handler called with unknown parameter '%s'", pname));
}
@ -256,8 +256,8 @@ void bx_init_options()
bx_list_c *menu;
bx_list_c *deplist;
bx_param_num_c *ioaddr, *ioaddr2, *irq;
bx_param_bool_c *enabled, *inserted;
bx_param_enum_c *mode, *status, *type, *ethmod;
bx_param_bool_c *enabled, *status;
bx_param_enum_c *mode, *type, *ethmod;
bx_param_string_c *macaddr, *ethdev;
bx_param_filename_c *path;
char name[BX_PATHNAME_LEN], descr[512], group[16], label[512];
@ -898,14 +898,12 @@ void bx_init_options()
type->set_ask_format("What type of floppy media? (auto=detect) [%s] ");
type->set_runtime_param(1);
status = new bx_param_enum_c(floppya,
status = new bx_param_bool_c(floppya,
"status",
"Media status",
"Inserted or ejected",
floppy_status_names,
BX_EJECTED,
BX_EJECTED);
status->set_ask_format("Is the floppy inserted or ejected? [%s] ");
"Inserted",
"Floppy media status (inserted / ejected)",
0);
status->set_ask_format("Is media inserted in drive? [%s] ");
status->set_runtime_param(1);
deplist = new bx_list_c(NULL, 1);
@ -947,14 +945,12 @@ void bx_init_options()
type->set_ask_format("What type of floppy media? (auto=detect) [%s] ");
type->set_runtime_param(1);
status = new bx_param_enum_c(floppyb,
status = new bx_param_bool_c(floppyb,
"status",
"Media status",
"Inserted or ejected",
floppy_status_names,
BX_EJECTED,
BX_EJECTED);
status->set_ask_format("Is the floppy inserted or ejected? [%s] ");
"Inserted",
"Floppy media status (inserted / ejected)",
0);
status->set_ask_format("Is media inserted in drive? [%s] ");
status->set_runtime_param(1);
deplist = new bx_list_c(NULL, 1);
@ -1097,12 +1093,12 @@ void bx_init_options()
BX_ATA_MODE_FLAT);
mode->set_ask_format("Enter mode of ATA device, (flat, concat, etc.): [%s] ");
inserted = new bx_param_bool_c(menu,
status = new bx_param_bool_c(menu,
"status",
"Inserted",
"CD-ROM media status (inserted / ejected)",
0);
inserted->set_ask_format("Is media inserted in drive? [%s] ");
status->set_ask_format("Is media inserted in drive? [%s] ");
bx_param_filename_c *journal = new bx_param_filename_c(menu,
"journal",
@ -1178,7 +1174,7 @@ void bx_init_options()
// some items depend on the drive type
bx_param_c *type_deplist[] = {
mode,
inserted,
status,
cylinders,
heads,
spt,
@ -1191,7 +1187,7 @@ void bx_init_options()
type->set_dependent_bitmap(BX_ATA_DEVICE_CDROM, 0x02);
type->set_handler(bx_param_handler);
inserted->set_handler(bx_param_handler);
status->set_handler(bx_param_handler);
path->set_handler(bx_param_string_handler);
}
@ -2210,8 +2206,11 @@ static int parse_line_formatted(const char *context, int num_params, char *param
PARSE_ERR(("%s: %s image size doesn't match one of the supported types.",
context, params[0]));
}
else if (!strncmp(params[i], "status=", 7)) {
SIM->get_param_enum("status", base)->set_by_name(&params[i][7]);
else if (!strcmp(params[i], "status=inserted")) {
SIM->get_param_bool("status", base)->set(1);
}
else if (!strcmp(params[i], "status=ejected")) {
SIM->get_param_bool("status", base)->set(0);
}
else {
PARSE_ERR(("%s: %s attribute '%s' not understood.", context, params[0],
@ -3244,7 +3243,7 @@ int bx_write_floppy_options(FILE *fp, int drive)
fprintf(fp, ", %s=\"%s\", status=%s",
fdtypes[SIM->get_param_enum(type)->get() - BX_FLOPPY_NONE],
SIM->get_param_string(path)->getptr(),
SIM->get_param_enum(status)->get_selected());
SIM->get_param_bool(status)->get() ? "inserted":"ejected");
}
fprintf(fp, "\n");
return 0;

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: gui.cc,v 1.110 2009-03-23 19:05:15 vruppert Exp $
// $Id: gui.cc,v 1.111 2009-03-25 18:33:38 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -247,9 +247,9 @@ void bx_gui_c::cleanup(void)
void bx_gui_c::update_drive_status_buttons(void)
{
BX_GUI_THIS floppyA_status = DEV_floppy_get_media_status(0)
&& (SIM->get_param_enum(BXPN_FLOPPYA_STATUS)->get() == BX_INSERTED);
&& (SIM->get_param_bool(BXPN_FLOPPYA_STATUS)->get());
BX_GUI_THIS floppyB_status = DEV_floppy_get_media_status(1)
&& (SIM->get_param_enum(BXPN_FLOPPYB_STATUS)->get() == BX_INSERTED);
&& (SIM->get_param_bool(BXPN_FLOPPYB_STATUS)->get());
Bit32u handle = DEV_hd_get_first_cd_handle();
BX_GUI_THIS cdromD_status = DEV_hd_get_cd_media_status(handle);
if (BX_GUI_THIS floppyA_status)

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: siminterface.cc,v 1.202 2009-03-23 19:05:16 vruppert Exp $
// $Id: siminterface.cc,v 1.203 2009-03-25 18:33:38 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2009 The Bochs Project
@ -467,7 +467,6 @@ const char *bochs_start_names[] = { "quick", "load", "edit", "run" };
const char *floppy_devtype_names[] = { "none", "5.25\" 360K", "5.25\" 1.2M", "3.5\" 720K", "3.5\" 1.44M", "3.5\" 2.88M", NULL };
const char *floppy_type_names[] = { "none", "1.2M", "1.44M", "2.88M", "720K", "360K", "160K", "180K", "320K", "auto", NULL };
int floppy_type_n_sectors[] = { -1, 80*2*15, 80*2*18, 80*2*36, 80*2*9, 40*2*9, 40*1*8, 40*1*9, 40*2*8, -1 };
const char *floppy_status_names[] = { "ejected", "inserted", NULL };
const char *bochs_bootdisk_names[] = { "none", "floppy", "disk","cdrom", "network", NULL };
const char *loader_os_names[] = { "none", "linux", "nullkernel", NULL };

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: siminterface.h,v 1.236 2009-03-23 19:05:16 vruppert Exp $
// $Id: siminterface.h,v 1.237 2009-03-25 18:33:39 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2009 The Bochs Project
@ -302,10 +302,6 @@ typedef enum {
#define BX_RESET_SOFTWARE 10
#define BX_RESET_HARDWARE 11
// floppy
#define BX_EJECTED 10
#define BX_INSERTED 11
// boot devices (using the same values as the rombios)
#define BX_BOOT_NONE 0
#define BX_BOOT_FLOPPYA 1
@ -1097,7 +1093,6 @@ BOCHSAPI extern const char *bochs_start_names[];
BOCHSAPI extern const char *floppy_devtype_names[];
BOCHSAPI extern const char *floppy_type_names[];
BOCHSAPI extern int floppy_type_n_sectors[];
BOCHSAPI extern const char *floppy_status_names[];
BOCHSAPI extern const char *bochs_bootdisk_names[];
BOCHSAPI extern const char *loader_os_names[];
BOCHSAPI extern const char *keyboard_type_names[];

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: textconfig.cc,v 1.79 2009-03-24 16:28:02 vruppert Exp $
// $Id: textconfig.cc,v 1.80 2009-03-25 18:33:40 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2009 The Bochs Project
@ -343,7 +343,7 @@ void build_runtime_options_prompt(const char *format, char *buf, int size)
else {
sprintf(buffer[i], "%s, size=%s, %s", SIM->get_param_string("path", floppyop)->getptr(),
SIM->get_param_enum("type", floppyop)->get_selected(),
SIM->get_param_enum("status", floppyop)->get_selected());
SIM->get_param_bool("status", floppyop)->get() ? "inserted":"ejected");
if (!SIM->get_param_string("path", floppyop)->getptr()[0]) strcpy(buffer[i], "none");
}
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: win32dialog.cc,v 1.82 2009-03-24 16:28:03 vruppert Exp $
// $Id: win32dialog.cc,v 1.83 2009-03-25 18:33:41 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2009 The Bochs Project
@ -202,7 +202,7 @@ static BOOL CALLBACK StringParamProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM
static BOOL CALLBACK FloppyDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
static bx_param_filename_c *param;
static bx_param_enum_c *status;
static bx_param_bool_c *status;
static bx_param_enum_c *devtype;
static bx_param_enum_c *mediatype;
static char origpath[MAX_PATH];
@ -217,11 +217,11 @@ static BOOL CALLBACK FloppyDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP
param = (bx_param_filename_c *)lParam;
param->get_param_path(pname, 80);
if (!strcmp(pname, BXPN_FLOPPYA_PATH)) {
status = SIM->get_param_enum(BXPN_FLOPPYA_STATUS);
status = SIM->get_param_bool(BXPN_FLOPPYA_STATUS);
devtype = SIM->get_param_enum(BXPN_FLOPPYA_DEVTYPE);
mediatype = SIM->get_param_enum(BXPN_FLOPPYA_TYPE);
} else {
status = SIM->get_param_enum(BXPN_FLOPPYB_STATUS);
status = SIM->get_param_bool(BXPN_FLOPPYB_STATUS);
devtype = SIM->get_param_enum(BXPN_FLOPPYB_DEVTYPE);
mediatype = SIM->get_param_enum(BXPN_FLOPPYB_TYPE);
}
@ -235,7 +235,7 @@ static BOOL CALLBACK FloppyDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP
}
cap = mediatype->get() - (int)mediatype->get_min();
SendMessage(GetDlgItem(hDlg, IDMEDIATYPE), CB_SETCURSEL, cap, 0);
if (status->get() == BX_INSERTED) {
if (status->get()) {
SendMessage(GetDlgItem(hDlg, IDSTATUS), BM_SETCHECK, BST_CHECKED, 0);
}
lstrcpy(origpath, param->getptr());
@ -269,7 +269,7 @@ static BOOL CALLBACK FloppyDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP
return TRUE;
break;
case IDOK:
status->set(BX_EJECTED);
status->set(0);
if (SendMessage(GetDlgItem(hDlg, IDSTATUS), BM_GETCHECK, 0, 0) == BST_CHECKED) {
GetDlgItemText(hDlg, IDPATH, path, MAX_PATH);
if (lstrlen(path) == 0) {
@ -283,7 +283,7 @@ static BOOL CALLBACK FloppyDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP
cap = SendMessage(GetDlgItem(hDlg, IDMEDIATYPE), CB_GETITEMDATA, i, 0);
mediatype->set(cap);
if (lstrcmp(path, "none")) {
status->set(BX_INSERTED);
status->set(1);
}
EndDialog(hDlg, 1);
return TRUE;

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////
// $Id: wxmain.cc,v 1.160 2009-03-23 19:05:16 vruppert Exp $
// $Id: wxmain.cc,v 1.161 2009-03-25 18:33:42 vruppert Exp $
/////////////////////////////////////////////////////////////////
//
// wxmain.cc implements the wxWidgets frame, toolbar, menus, and dialogs.
@ -1295,10 +1295,10 @@ void MyFrame::editFloppyConfig(int drive)
if (!list) { wxLogError(wxT("floppy object param is null")); return; }
bx_param_filename_c *fname = (bx_param_filename_c*) list->get_by_name("path");
bx_param_enum_c *disktype = (bx_param_enum_c *) list->get_by_name("type");
bx_param_enum_c *status = (bx_param_enum_c *) list->get_by_name("status");
bx_param_bool_c *status = (bx_param_bool_c *) list->get_by_name("status");
if (fname->get_type() != BXT_PARAM_STRING
|| disktype->get_type() != BXT_PARAM_ENUM
|| status->get_type() != BXT_PARAM_ENUM) {
|| status->get_type() != BXT_PARAM_BOOL) {
wxLogError(wxT("floppy params have wrong type"));
return;
}
@ -1320,7 +1320,7 @@ void MyFrame::editFloppyConfig(int drive)
dlg.SetValidateFunc(editFloppyValidate);
if (disktype->get() == BX_FLOPPY_NONE) {
dlg.SetRadio(0);
} else if ((status->get() == BX_EJECTED) || (!strcmp("none", fname->getptr()))) {
} else if ((status->get() == 0) || (!strcmp("none", fname->getptr()))) {
dlg.SetRadio((sim_thread == NULL)?1:0);
} else {
// otherwise the SetFilename() should have done the right thing.
@ -1338,7 +1338,7 @@ void MyFrame::editFloppyConfig(int drive)
}
} else {
if (dlg.GetRadio() > 0) {
status->set(BX_INSERTED);
status->set(1);
}
}
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: floppy.cc,v 1.118 2009-03-23 19:05:16 vruppert Exp $
// $Id: floppy.cc,v 1.119 2009-03-25 18:33:43 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -141,7 +141,7 @@ void bx_floppy_ctrl_c::init(void)
{
Bit8u i, devtype, cmos_value;
BX_DEBUG(("Init $Id: floppy.cc,v 1.118 2009-03-23 19:05:16 vruppert Exp $"));
BX_DEBUG(("Init $Id: floppy.cc,v 1.119 2009-03-25 18:33:43 vruppert Exp $"));
DEV_dma_register_8bit_channel(2, dma_read, dma_write, "Floppy Drive");
DEV_register_irq(6, "Floppy Drive");
for (unsigned addr=0x03F2; addr<=0x03F7; addr++) {
@ -180,7 +180,7 @@ void bx_floppy_ctrl_c::init(void)
}
if (SIM->get_param_enum(BXPN_FLOPPYA_TYPE)->get() != BX_FLOPPY_NONE) {
if (SIM->get_param_enum(BXPN_FLOPPYA_STATUS)->get() == BX_INSERTED) {
if (SIM->get_param_bool(BXPN_FLOPPYA_STATUS)->get()) {
if (evaluate_media(BX_FD_THIS s.device_type[0], SIM->get_param_enum(BXPN_FLOPPYA_TYPE)->get(),
SIM->get_param_string(BXPN_FLOPPYA_PATH)->getptr(), & BX_FD_THIS s.media[0])) {
BX_FD_THIS s.media_present[0] = 1;
@ -190,7 +190,7 @@ void bx_floppy_ctrl_c::init(void)
MED.write_protected, MED.heads, MED.tracks, MED.sectors_per_track));
#undef MED
} else {
SIM->get_param_enum(BXPN_FLOPPYA_STATUS)->set(BX_EJECTED);
SIM->get_param_bool(BXPN_FLOPPYA_STATUS)->set(0);
}
}
}
@ -210,7 +210,7 @@ void bx_floppy_ctrl_c::init(void)
}
if (SIM->get_param_enum(BXPN_FLOPPYB_TYPE)->get() != BX_FLOPPY_NONE) {
if (SIM->get_param_enum(BXPN_FLOPPYB_STATUS)->get() == BX_INSERTED) {
if (SIM->get_param_bool(BXPN_FLOPPYB_STATUS)->get()) {
if (evaluate_media(BX_FD_THIS s.device_type[1], SIM->get_param_enum(BXPN_FLOPPYB_TYPE)->get(),
SIM->get_param_string(BXPN_FLOPPYB_PATH)->getptr(), & BX_FD_THIS s.media[1])) {
BX_FD_THIS s.media_present[1] = 1;
@ -220,7 +220,7 @@ void bx_floppy_ctrl_c::init(void)
MED.write_protected, MED.heads, MED.tracks, MED.sectors_per_track));
#undef MED
} else {
SIM->get_param_enum(BXPN_FLOPPYB_STATUS)->set(BX_EJECTED);
SIM->get_param_bool(BXPN_FLOPPYB_STATUS)->set(0);
}
}
}
@ -1431,9 +1431,9 @@ unsigned bx_floppy_ctrl_c::set_media_status(unsigned drive, unsigned status)
}
BX_FD_THIS s.media_present[drive] = 0;
if (drive == 0) {
SIM->get_param_enum(BXPN_FLOPPYA_STATUS)->set(BX_EJECTED);
SIM->get_param_bool(BXPN_FLOPPYA_STATUS)->set(0);
} else {
SIM->get_param_enum(BXPN_FLOPPYB_STATUS)->set(BX_EJECTED);
SIM->get_param_bool(BXPN_FLOPPYB_STATUS)->set(0);
}
BX_FD_THIS s.DIR[drive] |= 0x80; // disk changed line
return(0);
@ -1453,22 +1453,22 @@ unsigned bx_floppy_ctrl_c::set_media_status(unsigned drive, unsigned status)
BX_INFO(("fd0: '%s' ro=%d, h=%d,t=%d,spt=%d", SIM->get_param_string(BXPN_FLOPPYA_PATH)->getptr(),
MED.write_protected, MED.heads, MED.tracks, MED.sectors_per_track));
#undef MED
SIM->get_param_enum(BXPN_FLOPPYA_STATUS)->set(BX_INSERTED);
SIM->get_param_bool(BXPN_FLOPPYA_STATUS)->set(1);
} else {
#define MED (BX_FD_THIS s.media[1])
BX_INFO(("fd1: '%s' ro=%d, h=%d,t=%d,spt=%d", SIM->get_param_string(BXPN_FLOPPYB_PATH)->getptr(),
MED.write_protected, MED.heads, MED.tracks, MED.sectors_per_track));
#undef MED
SIM->get_param_enum(BXPN_FLOPPYB_STATUS)->set(BX_INSERTED);
SIM->get_param_bool(BXPN_FLOPPYB_STATUS)->set(1);
}
return(1);
} else {
BX_FD_THIS s.media_present[drive] = 0;
if (drive == 0) {
SIM->get_param_enum(BXPN_FLOPPYA_STATUS)->set(BX_EJECTED);
SIM->get_param_bool(BXPN_FLOPPYA_STATUS)->set(0);
SIM->get_param_enum(BXPN_FLOPPYA_TYPE)->set(BX_FLOPPY_NONE);
} else {
SIM->get_param_enum(BXPN_FLOPPYB_STATUS)->set(BX_EJECTED);
SIM->get_param_bool(BXPN_FLOPPYB_STATUS)->set(0);
SIM->get_param_enum(BXPN_FLOPPYB_TYPE)->set(BX_FLOPPY_NONE);
}
return(0);