Support multiple devices on the Smartport card
This commit is contained in:
parent
718f0b60b3
commit
9f36507fa5
|
@ -20,7 +20,7 @@ See:
|
||||||
// CardSmartPort represents a SmartPort card
|
// CardSmartPort represents a SmartPort card
|
||||||
type CardSmartPort struct {
|
type CardSmartPort struct {
|
||||||
cardBase
|
cardBase
|
||||||
device smartPortDevice
|
devices []smartPortDevice
|
||||||
hardDiskBlocks uint32
|
hardDiskBlocks uint32
|
||||||
|
|
||||||
mliParams uint16
|
mliParams uint16
|
||||||
|
@ -46,7 +46,7 @@ func (c *CardSmartPort) LoadImage(filename string, trace bool) error {
|
||||||
device, err := NewSmartPortHardDisk(c, filename)
|
device, err := NewSmartPortHardDisk(c, filename)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
device.trace = trace
|
device.trace = trace
|
||||||
c.device = device
|
c.devices = append(c.devices, device)
|
||||||
c.hardDiskBlocks = device.disk.GetSizeInBlocks() // Needed for the PRODOS status
|
c.hardDiskBlocks = device.disk.GetSizeInBlocks() // Needed for the PRODOS status
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
@ -54,7 +54,7 @@ func (c *CardSmartPort) LoadImage(filename string, trace bool) error {
|
||||||
|
|
||||||
// LoadImage loads a disk image
|
// LoadImage loads a disk image
|
||||||
func (c *CardSmartPort) AddDevice(unt uint8, device smartPortDevice) {
|
func (c *CardSmartPort) AddDevice(unt uint8, device smartPortDevice) {
|
||||||
c.device = device
|
c.devices = append(c.devices, device)
|
||||||
c.hardDiskBlocks = 0 // Needed for the PRODOS status
|
c.hardDiskBlocks = 0 // Needed for the PRODOS status
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,22 +119,25 @@ func (c *CardSmartPort) assign(a *Apple2, slot int) {
|
||||||
|
|
||||||
func (c *CardSmartPort) exec(call *smartPortCall) uint8 {
|
func (c *CardSmartPort) exec(call *smartPortCall) uint8 {
|
||||||
var result uint8
|
var result uint8
|
||||||
|
unit := int(call.unit())
|
||||||
|
|
||||||
if call.command == proDosDeviceCommandStatus &&
|
if call.command == proDosDeviceCommandStatus &&
|
||||||
// Call to the host
|
// Call to the host
|
||||||
call.statusCode() == prodosDeviceStatusCodeDevice {
|
call.statusCode() == prodosDeviceStatusCodeDevice {
|
||||||
|
|
||||||
result = c.hostStatus(call)
|
result = c.hostStatus(call)
|
||||||
} else if call.unit() > 1 {
|
} else if unit > len(c.devices) {
|
||||||
result = proDosDeviceErrorNoDevice
|
result = proDosDeviceErrorNoDevice
|
||||||
} else {
|
} else {
|
||||||
// TODO: select the device, 0(host) is sent to 1
|
if unit == 0 {
|
||||||
result = c.device.exec(call)
|
unit = 1 // For unit 0(host) use the first device
|
||||||
|
}
|
||||||
|
result = c.devices[unit-1].exec(call)
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.trace {
|
if c.trace {
|
||||||
fmt.Printf("[CardSmartPort] Command %v on slot %v => result %s.\n",
|
fmt.Printf("[CardSmartPort] Command %v on slot %v, unit %v => result %s.\n",
|
||||||
call, c.slot, smartPortErrorMessage(result))
|
call, c.slot, call.unit(), smartPortErrorMessage(result))
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue