Fix style and hide extra COM ports behind options

This commit is contained in:
copy 2019-05-11 19:05:16 -05:00
parent 0bce005cc0
commit e237b218c9
3 changed files with 41 additions and 26 deletions

View file

@ -121,6 +121,9 @@ function V86Starter(options)
settings.fastboot = options["fastboot"] || false;
settings.fda = undefined;
settings.fdb = undefined;
settings.uart1 = options["uart1"] || false;
settings.uart2 = options["uart2"] || false;
settings.uart3 = options["uart3"] || false;
if(options["network_relay_url"])
{

View file

@ -333,7 +333,7 @@ CPU.prototype.get_state = function()
state[51] = this.devices.hpet;
state[52] = this.devices.vga;
state[53] = this.devices.ps2;
state[54] = this.devices.uart;
state[54] = this.devices.uart0;
state[55] = this.devices.fdc;
state[56] = this.devices.cdrom;
state[57] = this.devices.hda;
@ -413,7 +413,7 @@ CPU.prototype.set_state = function(state)
this.devices.hpet = state[51];
this.devices.vga = state[52];
this.devices.ps2 = state[53];
this.devices.uart = state[54];
this.devices.uart0 = state[54];
this.devices.fdc = state[55];
this.devices.cdrom = state[56];
this.devices.hda = state[57];
@ -740,10 +740,20 @@ CPU.prototype.init = function(settings, device_bus)
this.devices.ps2 = new PS2(this, device_bus);
this.devices.uart = new UART(this, 0x3F8, device_bus);
this.devices.uart1 = new UART(this, 0x2F8, device_bus);
this.devices.uart2 = new UART(this, 0x3E8, device_bus);
this.devices.uart3 = new UART(this, 0x2E8, device_bus);
this.devices.uart0 = new UART(this, 0x3F8, device_bus);
if(settings.uart1)
{
this.devices.uart1 = new UART(this, 0x2F8, device_bus);
}
if(settings.uart2)
{
this.devices.uart2 = new UART(this, 0x3E8, device_bus);
}
if(settings.uart3)
{
this.devices.uart3 = new UART(this, 0x3E8, device_bus);
}
this.devices.fdc = new FloppyController(this, settings.fda, settings.fdb);

View file

@ -69,26 +69,28 @@ function UART(cpu, port, bus)
this.current_line = [];
switch(port) {
case 0x3F8:
this.com = 0;
this.irq = 4;
break;
case 0x2F8:
this.com = 1;
this.irq = 3;
break;
case 0x3E8:
this.com = 2;
this.irq = 4;
break;
case 0x2E8:
this.com = 3;
this.irq = 3;
break;
default:
dbg_log("Invalid port: " + h(port), LOG_SERIAL);
return;
switch(port)
{
case 0x3F8:
this.com = 0;
this.irq = 4;
break;
case 0x2F8:
this.com = 1;
this.irq = 3;
break;
case 0x3E8:
this.com = 2;
this.irq = 4;
break;
case 0x2E8:
this.com = 3;
this.irq = 3;
break;
default:
dbg_log("Invalid serial port: " + h(port), LOG_SERIAL);
this.com = 0;
this.irq = 4;
}
this.bus.register("serial" + this.com + "-input", function(data)