Floppy disk write protection

This commit is contained in:
dingusdev 2022-02-24 07:33:30 -07:00
parent edd3979647
commit 80a4864a92
5 changed files with 21 additions and 5 deletions

View File

@ -131,7 +131,7 @@ uint8_t MacSuperDrive::status(uint8_t addr)
}
}
int MacSuperDrive::insert_disk(std::string& img_path)
int MacSuperDrive::insert_disk(std::string& img_path, bool write_flag = 0)
{
if (this->has_disk) {
LOG_F(ERROR, "Superdrive: drive is not empty!");
@ -150,7 +150,7 @@ int MacSuperDrive::insert_disk(std::string& img_path)
this->img_conv->get_raw_disk_data(this->disk_data.get());
// disk is write-enabled by default
this->wr_protect = 0;
this->wr_protect = write_flag;
// everything is set up, let's say we got a disk
this->has_disk = 1;

View File

@ -86,7 +86,7 @@ public:
void command(uint8_t addr, uint8_t value);
uint8_t status(uint8_t addr);
int insert_disk(std::string& img_path);
int insert_disk(std::string& img_path, bool write_flag);
double get_current_track_delay();
double get_sector_delay();
void init_track_search(int pos);

View File

@ -80,6 +80,8 @@ static const PropMap GossamerSettings = {
new StrProperty("")},
{"fdd_img",
new StrProperty("")},
{"fdd_wr_prot",
new StrProperty("")},
};
/** Monitors supported by the PDM on-board video. */
@ -99,6 +101,8 @@ static const PropMap PDMSettings = {
new StrProperty("HiRes12-14in", PDMBuiltinMonitorIDs)},
{"fdd_img",
new StrProperty("")},
{"fdd_wr_prot",
new StrProperty("")},
};
static const map<string, string> PropHelp = {
@ -107,6 +111,7 @@ static const map<string, string> PropHelp = {
{"rambank3_size", "specifies RAM bank 3 size in MB"},
{"gfxmem_size", "specifies video memory size in MB"},
{"fdd_img", "specifies path to floppy disk image"},
{"fdd_wr_prot", "toggles floppy disks write protection"},
{"mon_id", "specifies which monitor to emulate"},
};

View File

@ -110,7 +110,8 @@ int create_gossamer(std::string& id) {
}
/* check for a floppy image to be inserted into the virtual superdrive */
std::string fdd_path = GET_STR_PROP("fdd_img");
std::string fdd_path = GET_STR_PROP("fdd_img");
std::string fd_write_prot = GET_STR_PROP("fdd_wr_prot");
if (!fdd_path.empty()) {
open_floppy_image(fdd_path);
}

View File

@ -99,12 +99,22 @@ int create_pdm(std::string& id) {
// if a floppy image was given "insert" it into the virtual superdrive
std::string fd_image_path = GET_STR_PROP("fdd_img");
std::string fd_write_prot = GET_STR_PROP("fdd_wr_prot");
if (!fd_image_path.empty()) {
using namespace MacSuperdrive;
MacSuperDrive* fdd = dynamic_cast<MacSuperDrive*>
(gMachineObj->get_comp_by_name("Superdrive"));
fdd->insert_disk(fd_image_path);
bool write_flag = false;
if (!fd_write_prot.empty()) {
if (fd_write_prot.compare("on") == 0) {
write_flag = true;
}
}
fdd->insert_disk(fd_image_path, write_flag);
}
LOG_F(INFO, "Initialization completed.\n");