mirror of
https://github.com/copy/v86.git
synced 2025-12-31 04:23:15 +00:00
changed CPU.devices.cdrom and .hda to point to their IDEInterface objects
- changed cdrom and hda to point to the drive's IDEInterface instead of its parent IDEChannel - added boolean method IDEInterface.has_disk() to query whether a Compact Disk is inserted or not - the IDEController object and the CD-ROM device are now created unconditionally
This commit is contained in:
parent
b1e45723df
commit
0dff08dfa6
4 changed files with 25 additions and 25 deletions
|
|
@ -2398,7 +2398,7 @@ function init_ui(profile, settings, emulator)
|
|||
$("change_cdrom_image").value = settings.cdrom ? "Eject CD image" : "Insert CD image";
|
||||
$("change_cdrom_image").onclick = function()
|
||||
{
|
||||
if(emulator.v86.cpu.devices.cdrom.master.buffer)
|
||||
if(emulator.v86.cpu.devices.cdrom.has_disk())
|
||||
{
|
||||
emulator.eject_cdrom();
|
||||
$("change_cdrom_image").value = "Insert CD image";
|
||||
|
|
|
|||
|
|
@ -995,7 +995,7 @@ V86.prototype.set_cdrom = async function(file)
|
|||
load_file(file.url, {
|
||||
done: result =>
|
||||
{
|
||||
this.v86.cpu.devices.cdrom.master.set_cdrom(new SyncBuffer(result));
|
||||
this.v86.cpu.devices.cdrom.set_cdrom(new SyncBuffer(result));
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
@ -1004,7 +1004,7 @@ V86.prototype.set_cdrom = async function(file)
|
|||
const image = buffer_from_object(file, this.zstd_decompress_worker.bind(this));
|
||||
image.onload = () =>
|
||||
{
|
||||
this.v86.cpu.devices.cdrom.master.set_cdrom(image);
|
||||
this.v86.cpu.devices.cdrom.set_cdrom(image);
|
||||
};
|
||||
await image.load();
|
||||
}
|
||||
|
|
@ -1015,7 +1015,7 @@ V86.prototype.set_cdrom = async function(file)
|
|||
*/
|
||||
V86.prototype.eject_cdrom = function()
|
||||
{
|
||||
this.v86.cpu.devices.cdrom.master.eject();
|
||||
this.v86.cpu.devices.cdrom.eject();
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
37
src/cpu.js
37
src/cpu.js
|
|
@ -537,8 +537,8 @@ CPU.prototype.get_state = function()
|
|||
state[53] = this.devices.ps2;
|
||||
state[54] = this.devices.uart0;
|
||||
state[55] = this.devices.fdc;
|
||||
state[56] = this.devices.cdrom;
|
||||
state[57] = this.devices.hda;
|
||||
state[56] = this.devices.cdrom.channel;
|
||||
state[57] = this.devices.hda? this.devices.hda.channel : undefined;
|
||||
state[58] = this.devices.pit;
|
||||
state[59] = this.devices.net;
|
||||
state[60] = this.get_state_pic();
|
||||
|
|
@ -692,8 +692,8 @@ CPU.prototype.set_state = function(state)
|
|||
this.devices.ps2 && this.devices.ps2.set_state(state[53]);
|
||||
this.devices.uart0 && this.devices.uart0.set_state(state[54]);
|
||||
this.devices.fdc && this.devices.fdc.set_state(state[55]);
|
||||
this.devices.cdrom && this.devices.cdrom.set_state(state[56]);
|
||||
this.devices.hda && this.devices.hda.set_state(state[57]);
|
||||
this.devices.cdrom && this.devices.cdrom.channel.set_state(state[56]);
|
||||
this.devices.hda && this.devices.hda.channel.set_state(state[57]);
|
||||
this.devices.pit && this.devices.pit.set_state(state[58]);
|
||||
this.devices.net && this.devices.net.set_state(state[59]);
|
||||
this.set_state_pic(state[60]);
|
||||
|
|
@ -1105,24 +1105,19 @@ CPU.prototype.init = function(settings, device_bus)
|
|||
|
||||
this.devices.fdc = new FloppyController(this, settings.fda, settings.fdb);
|
||||
|
||||
if(settings.hda || settings.cdrom) {
|
||||
let cdrom_channel = 0;
|
||||
const ide_config = [[undefined, undefined], [undefined, undefined]];
|
||||
if(settings.hda) {
|
||||
ide_config[0][0] = {buffer: settings.hda};
|
||||
ide_config[0][1] = {buffer: settings.hdb};
|
||||
cdrom_channel++;
|
||||
}
|
||||
ide_config[cdrom_channel][0] = {is_cdrom: true, buffer: settings.cdrom};
|
||||
|
||||
this.devices.ide = new IDEController(this, device_bus, ide_config);
|
||||
|
||||
if(settings.hda) {
|
||||
this.devices.hda = this.devices.ide.channels[0];
|
||||
// this.devices.hdb = ? // TODO: this.devices.hda/hdb/cdrom should point to IDEInterface, not IDEDevice objects?!
|
||||
}
|
||||
this.devices.cdrom = this.devices.ide.channels[cdrom_channel];
|
||||
let cdrom_channel = 0;
|
||||
const ide_config = [[undefined, undefined], [undefined, undefined]];
|
||||
if(settings.hda) {
|
||||
ide_config[0][0] = {buffer: settings.hda};
|
||||
ide_config[0][1] = {buffer: settings.hdb};
|
||||
cdrom_channel++;
|
||||
}
|
||||
ide_config[cdrom_channel][0] = {is_cdrom: true, buffer: settings.cdrom};
|
||||
this.devices.ide = new IDEController(this, device_bus, ide_config);
|
||||
if(settings.hda) {
|
||||
this.devices.hda = this.devices.ide.primary.master;
|
||||
}
|
||||
this.devices.cdrom = this.devices.ide.channels[cdrom_channel].master;
|
||||
|
||||
this.devices.pit = new PIT(this, device_bus);
|
||||
|
||||
|
|
|
|||
|
|
@ -886,6 +886,11 @@ IDEInterface.prototype.init_interface = function()
|
|||
}
|
||||
};
|
||||
|
||||
IDEInterface.prototype.has_disk = function()
|
||||
{
|
||||
return this.buffer;
|
||||
};
|
||||
|
||||
IDEInterface.prototype.eject = function()
|
||||
{
|
||||
if(this.is_atapi && this.buffer)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue