Skip to content

Commit

Permalink
UI for floppy insertion/ejection
Browse files Browse the repository at this point in the history
  • Loading branch information
copy committed Aug 26, 2023
1 parent d6f3ffc commit 8c04489
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 23 deletions.
11 changes: 1 addition & 10 deletions debug.html
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ <h4>Debugger</h4>
<input type="button" value="Get hard disk image" id="get_hda_image">
<input type="button" value="Get second hard disk image" id="get_hdb_image">
<input type="button" value="Get cdrom image" id="get_cdrom_image">
<input type="button" value="Insert floppy image" id="change_fda_image">
<input type="button" value="Save State" id="save_state">
<input type="button" value="Load State" id="load_state"> <input type="file" style="display: none" id="load_state_input">
<input type="button" value="Memory Dump" id="memory_dump">
Expand All @@ -278,16 +279,6 @@ <h4>Debugger</h4>
</label>

<br>
<label id="change_fda" style="display: none">
Change floppy:
<input type="file">
</label>

<label id="change_cdrom" style="display: none">
Change CD:
<input type="file">
</label>

</div>

<pre style="margin: 0" id="log_levels"></pre>
Expand Down
13 changes: 1 addition & 12 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ <h4>Setup</h4>
<input type="button" value="Get hard disk image" id="get_hda_image">
<input type="button" value="Get second hard disk image" id="get_hdb_image">
<input type="button" value="Get cdrom image" id="get_cdrom_image">
<input type="button" value="Insert floppy image" id="change_fda_image">
<input type="button" value="Save State" id="save_state">
<input type="button" value="Load State" id="load_state"> <input type="file" style="display: none" id="load_state_input">
<input type="button" value="Memory Dump" id="memory_dump">
Expand All @@ -201,18 +202,6 @@ <h4>Setup</h4>
</label>

<br>
<label id="change_fda" style="display: none">
Change floppy:
<input type="file">
</label>

<label id="change_cdrom" style="display: none">
Change CD:
<input type="file">
</label>

<br>

</div>
<pre style="display: none" id="loading"></pre>
</div>
Expand Down
26 changes: 26 additions & 0 deletions src/browser/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1704,6 +1704,32 @@
};
}

$("change_fda_image").value = settings.fda ? "Eject floppy image" : "Insert floppy image";
$("change_fda_image").onclick = function()
{
if(emulator.v86.cpu.devices.fdc.fda_image)
{
emulator.eject_fda();
$("change_fda_image").value = "Insert floppy image";
}
else
{
const file_input = document.createElement("input");
file_input.type = "file";
file_input.onchange = async function(e)
{
const file = file_input.files[0];
if(file)
{
await emulator.set_fda({ buffer: file });
$("change_fda_image").value = "Eject floppy image";
}
};
file_input.click();
}
$("change_fda_image").blur();
};

$("memory_dump").onclick = function()
{
const mem8 = emulator.v86.cpu.mem8;
Expand Down
2 changes: 1 addition & 1 deletion src/browser/starter.js
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@ V86Starter.prototype.set_fda = async function(file)
{
this.v86.cpu.devices.fdc.set_fda(image);
};
image.load();
await image.load();
}
};

Expand Down

0 comments on commit 8c04489

Please sign in to comment.