mirror of
https://github.com/ivanizag/izapple2.git
synced 2025-02-12 01:31:11 +00:00
Rename SmartPort constants
This commit is contained in:
parent
33ea1f6e7a
commit
39e0c9ef7a
@ -68,14 +68,14 @@ func (c *CardSmartPort) assign(a *Apple2, slot int) {
|
||||
|
||||
// Generate Smarport compatible params
|
||||
var call *smartPortCall
|
||||
if command == proDosDeviceCommandStatus {
|
||||
if command == smartPortCommandStatus {
|
||||
call = newSmartPortCallSynthetic(c, command, []uint8{
|
||||
3, // 3 args
|
||||
unit,
|
||||
a.mmu.Peek(0x44), a.mmu.Peek(0x45), // data address
|
||||
0,
|
||||
})
|
||||
} else if command == proDosDeviceCommandReadBlock || command == proDosDeviceCommandWriteBlock {
|
||||
} else if command == smartPortCommandReadBlock || command == smartPortCommandWriteBlock {
|
||||
call = newSmartPortCallSynthetic(c, command, []uint8{
|
||||
3, // 3args
|
||||
unit,
|
||||
@ -83,7 +83,7 @@ func (c *CardSmartPort) assign(a *Apple2, slot int) {
|
||||
a.mmu.Peek(0x46), a.mmu.Peek(0x47), 0, // block number
|
||||
})
|
||||
} else {
|
||||
return proDosDeviceBadCommand
|
||||
return smartPortBadCommand
|
||||
}
|
||||
|
||||
return c.exec(call)
|
||||
@ -121,13 +121,13 @@ func (c *CardSmartPort) exec(call *smartPortCall) uint8 {
|
||||
var result uint8
|
||||
unit := int(call.unit())
|
||||
|
||||
if call.command == proDosDeviceCommandStatus &&
|
||||
if call.command == smartPortCommandStatus &&
|
||||
// Call to the host
|
||||
call.statusCode() == prodosDeviceStatusCodeDevice {
|
||||
call.statusCode() == smartPortStatusCodeDevice {
|
||||
|
||||
result = c.hostStatus(call)
|
||||
} else if unit > len(c.devices) {
|
||||
result = proDosDeviceErrorNoDevice
|
||||
result = smartPortErrorNoDevice
|
||||
} else {
|
||||
if unit == 0 {
|
||||
unit = 1 // For unit 0(host) use the first device
|
||||
@ -158,7 +158,7 @@ func (c *CardSmartPort) hostStatus(call *smartPortCall) uint8 {
|
||||
c.a.mmu.Poke(dest+6, 0x00)
|
||||
c.a.mmu.Poke(dest+7, 0x00) // Reserved
|
||||
|
||||
return proDosDeviceNoError
|
||||
return smartPortNoError
|
||||
}
|
||||
|
||||
func buildHardDiskRom(slot int) []uint8 {
|
||||
|
@ -43,7 +43,7 @@ func (js *FnJson) Query(query []uint8) {
|
||||
queryString = strings.TrimSuffix(queryString, "/")
|
||||
path := strings.Split(queryString, "/")
|
||||
|
||||
js.Result = nil
|
||||
js.Result = getJsonValue(nil)
|
||||
current := js.data
|
||||
for i := 0; i < len(path); i++ {
|
||||
switch v := current.(type) {
|
||||
|
@ -122,7 +122,6 @@ func TestQueryArray(t *testing.T) {
|
||||
{"/1/account/display_name", "NULL"},
|
||||
{"/-1/account/display_name", "NULL"},
|
||||
{"/zz/account/display_name", "NULL"},
|
||||
{"/0/media_attachments/0/meta/original", "width213height181size213x181aspect1.1767955801"},
|
||||
}
|
||||
testQuerys(t, testArrayMessage, testCases)
|
||||
}
|
||||
|
@ -11,42 +11,42 @@ type smartPortDevice interface {
|
||||
}
|
||||
|
||||
const (
|
||||
proDosDeviceCommandStatus = 0
|
||||
proDosDeviceCommandReadBlock = 1
|
||||
proDosDeviceCommandWriteBlock = 2
|
||||
proDosDeviceCommandFormat = 3
|
||||
proDosDeviceCommandControl = 4
|
||||
proDosDeviceCommandInit = 5
|
||||
proDosDeviceCommandOpen = 6
|
||||
proDosDeviceCommandClose = 7
|
||||
proDosDeviceCommandRead = 8
|
||||
proDosDeviceCommandWrite = 9
|
||||
smartPortCommandStatus = 0
|
||||
smartPortCommandReadBlock = 1
|
||||
smartPortCommandWriteBlock = 2
|
||||
smartPortCommandFormat = 3
|
||||
smartPortCommandControl = 4
|
||||
smartPortCommandInit = 5
|
||||
smartPortCommandOpen = 6
|
||||
smartPortCommandClose = 7
|
||||
smartPortCommandRead = 8
|
||||
smartPortCommandWrite = 9
|
||||
)
|
||||
|
||||
const (
|
||||
prodosDeviceStatusCodeDevice = 0
|
||||
prodosDeviceStatusCodeDeviceControlBlock = 1
|
||||
prodosDeviceStatusCodeNewline = 2
|
||||
prodosDeviceStatusCodeDeviceInfo = 3
|
||||
smartPortStatusCodeDevice = 0
|
||||
smartPortStatusCodeDeviceControlBlock = 1
|
||||
smartPortStatusCodeNewline = 2
|
||||
smartPortStatusCodeDeviceInfo = 3
|
||||
)
|
||||
|
||||
const (
|
||||
prodosDeviceStatusCodeTypeBlock = uint8(1) << 7
|
||||
prodosDeviceStatusCodeTypeWrite = uint8(1) << 6
|
||||
prodosDeviceStatusCodeTypeRead = uint8(1) << 5
|
||||
prodosDeviceStatusCodeTypeOnline = uint8(1) << 4
|
||||
prodosDeviceStatusCodeTypeFormat = uint8(1) << 3
|
||||
prodosDeviceStatusCodeTypeProtected = uint8(1) << 2
|
||||
prodosDeviceStatusCodeTypeInterruping = uint8(1) << 1
|
||||
prodosDeviceStatusCodeTypeOpen = uint8(1) << 0
|
||||
smartPortStatusCodeTypeBlock = uint8(1) << 7
|
||||
smartPortStatusCodeTypeWrite = uint8(1) << 6
|
||||
smartPortStatusCodeTypeRead = uint8(1) << 5
|
||||
smartPortStatusCodeTypeOnline = uint8(1) << 4
|
||||
smartPortStatusCodeTypeFormat = uint8(1) << 3
|
||||
smartPortStatusCodeTypeProtected = uint8(1) << 2
|
||||
smartPortStatusCodeTypeInterruping = uint8(1) << 1
|
||||
smartPortStatusCodeTypeOpen = uint8(1) << 0
|
||||
)
|
||||
|
||||
const (
|
||||
proDosDeviceNoError = uint8(0)
|
||||
proDosDeviceBadCommand = uint8(1)
|
||||
proDosDeviceErrorIO = uint8(0x27)
|
||||
proDosDeviceErrorNoDevice = uint8(0x28)
|
||||
proDosDeviceErrorWriteProtected = uint8(0x2b)
|
||||
smartPortNoError = uint8(0)
|
||||
smartPortBadCommand = uint8(1)
|
||||
smartPortErrorIO = uint8(0x27)
|
||||
smartPortErrorNoDevice = uint8(0x28)
|
||||
smartPortErrorWriteProtected = uint8(0x2b)
|
||||
)
|
||||
|
||||
type smartPortCall struct {
|
||||
@ -80,8 +80,8 @@ func (spc *smartPortCall) unit() uint8 {
|
||||
}
|
||||
|
||||
func (spc *smartPortCall) statusCode() uint8 {
|
||||
if spc.command != proDosDeviceCommandStatus {
|
||||
panic("Status code paremeter requeted for a non status smartport call")
|
||||
if spc.command != smartPortCommandStatus {
|
||||
panic("Status code paremeter requeted for a non status smartPort call")
|
||||
}
|
||||
return spc.param8(4)
|
||||
}
|
||||
@ -125,37 +125,37 @@ func (spc *smartPortCall) paramData(offset uint8) []uint8 {
|
||||
|
||||
func (spc *smartPortCall) String() string {
|
||||
switch spc.command {
|
||||
case proDosDeviceCommandStatus:
|
||||
case smartPortCommandStatus:
|
||||
return fmt.Sprintf("STATUS(%v, unit=%v, code=%v)",
|
||||
spc.command, spc.unit(),
|
||||
spc.statusCode())
|
||||
case proDosDeviceCommandReadBlock:
|
||||
case smartPortCommandReadBlock:
|
||||
return fmt.Sprintf("READBLOCK(%v, unit=%v, block=%v)",
|
||||
spc.command, spc.unit(),
|
||||
spc.param24(4))
|
||||
case proDosDeviceCommandWriteBlock:
|
||||
case smartPortCommandWriteBlock:
|
||||
return fmt.Sprintf("WRITEBLOCK(%v, unit=%v, block=%v)",
|
||||
spc.command, spc.unit(),
|
||||
spc.param24(4))
|
||||
case proDosDeviceCommandControl:
|
||||
case smartPortCommandControl:
|
||||
return fmt.Sprintf("CONTROL(%v, unit=%v, code=%v)",
|
||||
spc.command, spc.unit(),
|
||||
spc.param8(4))
|
||||
case proDosDeviceCommandInit:
|
||||
case smartPortCommandInit:
|
||||
return fmt.Sprintf("INIT(%v, unit=%v)",
|
||||
spc.command, spc.unit())
|
||||
case proDosDeviceCommandOpen:
|
||||
case smartPortCommandOpen:
|
||||
return fmt.Sprintf("OPEN(%v, unit=%v)",
|
||||
spc.command, spc.unit())
|
||||
case proDosDeviceCommandClose:
|
||||
case smartPortCommandClose:
|
||||
return fmt.Sprintf("CLOSE(%v, unit=%v)",
|
||||
spc.command, spc.unit())
|
||||
case proDosDeviceCommandRead:
|
||||
case smartPortCommandRead:
|
||||
return fmt.Sprintf("READ(%v, unit=%v, pos=%v, len=%v)",
|
||||
spc.command, spc.unit(),
|
||||
spc.param24(6),
|
||||
spc.param16(4))
|
||||
case proDosDeviceCommandWrite:
|
||||
case smartPortCommandWrite:
|
||||
return fmt.Sprintf("WRITE(%v, unit=%v, pos=%v, len=%v)",
|
||||
spc.command, spc.unit(),
|
||||
spc.param24(6),
|
||||
@ -169,15 +169,15 @@ func (spc *smartPortCall) String() string {
|
||||
|
||||
func smartPortErrorMessage(code uint8) string {
|
||||
switch code {
|
||||
case proDosDeviceNoError:
|
||||
case smartPortNoError:
|
||||
return "SUCCESS"
|
||||
case proDosDeviceBadCommand:
|
||||
case smartPortBadCommand:
|
||||
return "BAD_COMMAND"
|
||||
case proDosDeviceErrorIO:
|
||||
case smartPortErrorIO:
|
||||
return "ERROR_IO"
|
||||
case proDosDeviceErrorNoDevice:
|
||||
case smartPortErrorNoDevice:
|
||||
return "NO_DEVICE"
|
||||
case proDosDeviceErrorWriteProtected:
|
||||
case smartPortErrorWriteProtected:
|
||||
return "WRITE_PROTECT_ERROR"
|
||||
default:
|
||||
return string(code)
|
||||
|
@ -46,22 +46,22 @@ func (d *SmartPortFujinet) exec(call *smartPortCall) uint8 {
|
||||
|
||||
switch call.command {
|
||||
|
||||
case proDosDeviceCommandOpen:
|
||||
result = proDosDeviceNoError
|
||||
case smartPortCommandOpen:
|
||||
result = smartPortNoError
|
||||
|
||||
case proDosDeviceCommandClose:
|
||||
result = proDosDeviceNoError
|
||||
case smartPortCommandClose:
|
||||
result = smartPortNoError
|
||||
|
||||
case proDosDeviceCommandStatus:
|
||||
case smartPortCommandStatus:
|
||||
address := call.param16(2)
|
||||
result = d.status(call.statusCode(), address)
|
||||
|
||||
case proDosDeviceCommandControl:
|
||||
case smartPortCommandControl:
|
||||
data := call.paramData(2)
|
||||
controlCode := call.param8(4)
|
||||
result = d.control(data, controlCode)
|
||||
|
||||
case proDosDeviceCommandRead:
|
||||
case smartPortCommandRead:
|
||||
address := call.param16(2)
|
||||
len := call.param16(4)
|
||||
pos := call.param24(6)
|
||||
@ -69,7 +69,7 @@ func (d *SmartPortFujinet) exec(call *smartPortCall) uint8 {
|
||||
|
||||
default:
|
||||
// Prodos device command not supported
|
||||
result = proDosDeviceErrorIO
|
||||
result = smartPortErrorIO
|
||||
}
|
||||
|
||||
if d.trace {
|
||||
@ -91,7 +91,7 @@ func (d *SmartPortFujinet) read(pos uint32, length uint16, dest uint16) uint8 {
|
||||
d.host.a.mmu.Poke(dest+i, d.data[i])
|
||||
}
|
||||
|
||||
return proDosDeviceNoError
|
||||
return smartPortNoError
|
||||
}
|
||||
|
||||
func (d *SmartPortFujinet) control(data []uint8, code uint8) uint8 {
|
||||
@ -118,7 +118,7 @@ func (d *SmartPortFujinet) control(data []uint8, code uint8) uint8 {
|
||||
d.controlChannelMode(mode)
|
||||
}
|
||||
|
||||
return proDosDeviceNoError
|
||||
return smartPortNoError
|
||||
}
|
||||
|
||||
func (d *SmartPortFujinet) controlJsonParse() {
|
||||
@ -196,17 +196,17 @@ func (d *SmartPortFujinet) controlOpen(method uint8, translation uint8, rawUrl s
|
||||
func (d *SmartPortFujinet) status(code uint8, dest uint16) uint8 {
|
||||
|
||||
switch code {
|
||||
case prodosDeviceStatusCodeDevice:
|
||||
case smartPortStatusCodeDevice:
|
||||
// See iwmNetwork::encode_status_reply_packet()
|
||||
d.host.a.mmu.pokeRange(dest, []uint8{
|
||||
prodosDeviceStatusCodeTypeRead & prodosDeviceStatusCodeTypeOnline,
|
||||
smartPortStatusCodeTypeRead & smartPortStatusCodeTypeOnline,
|
||||
0, 0, 0, // Block size is 0
|
||||
})
|
||||
|
||||
case prodosDeviceStatusCodeDeviceInfo:
|
||||
case smartPortStatusCodeDeviceInfo:
|
||||
// See iwmNetwork::encode_status_reply_packet()
|
||||
d.host.a.mmu.pokeRange(dest, []uint8{
|
||||
prodosDeviceStatusCodeTypeRead & prodosDeviceStatusCodeTypeOnline,
|
||||
smartPortStatusCodeTypeRead & smartPortStatusCodeTypeOnline,
|
||||
0, 0, 0, // Block size is 0
|
||||
7, 'N', 'E', 'T', 'W', 'O', 'R', 'K', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
|
||||
0x02, // Type hard disk
|
||||
@ -243,5 +243,5 @@ func (d *SmartPortFujinet) status(code uint8, dest uint16) uint8 {
|
||||
}
|
||||
}
|
||||
|
||||
return proDosDeviceNoError // The return code is always success
|
||||
return smartPortNoError // The return code is always success
|
||||
}
|
||||
|
@ -42,27 +42,27 @@ func (d *SmartPortHardDisk) exec(call *smartPortCall) uint8 {
|
||||
var result uint8
|
||||
|
||||
switch call.command {
|
||||
case proDosDeviceCommandStatus:
|
||||
case smartPortCommandStatus:
|
||||
address := call.param16(2)
|
||||
result = d.status(address)
|
||||
|
||||
case proDosDeviceCommandReadBlock:
|
||||
case smartPortCommandReadBlock:
|
||||
address := call.param16(2)
|
||||
block := call.param24(4)
|
||||
result = d.readBlock(block, address)
|
||||
|
||||
case proDosDeviceCommandWriteBlock:
|
||||
case smartPortCommandWriteBlock:
|
||||
address := call.param16(2)
|
||||
block := call.param24(4)
|
||||
result = d.writeBlock(block, address)
|
||||
|
||||
default:
|
||||
// Prodos device command not supported
|
||||
result = proDosDeviceErrorIO
|
||||
result = smartPortErrorIO
|
||||
}
|
||||
|
||||
if d.trace {
|
||||
fmt.Printf("[SmartPortFujinet] Command %v, return %s \n",
|
||||
fmt.Printf("[SmartPortHardDisk] Command %v, return %s \n",
|
||||
call, smartPortErrorMessage(result))
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ func (d *SmartPortHardDisk) readBlock(block uint32, dest uint16) uint8 {
|
||||
|
||||
data, err := d.disk.Read(block)
|
||||
if err != nil {
|
||||
return proDosDeviceErrorIO
|
||||
return smartPortErrorIO
|
||||
}
|
||||
|
||||
// Byte by byte transfer to memory using the full Poke code path
|
||||
@ -84,7 +84,7 @@ func (d *SmartPortHardDisk) readBlock(block uint32, dest uint16) uint8 {
|
||||
d.host.a.mmu.Poke(dest+i, data[i])
|
||||
}
|
||||
|
||||
return proDosDeviceNoError
|
||||
return smartPortNoError
|
||||
}
|
||||
|
||||
func (d *SmartPortHardDisk) writeBlock(block uint32, source uint16) uint8 {
|
||||
@ -93,7 +93,7 @@ func (d *SmartPortHardDisk) writeBlock(block uint32, source uint16) uint8 {
|
||||
}
|
||||
|
||||
if d.disk.IsReadOnly() {
|
||||
return proDosDeviceErrorWriteProtected
|
||||
return smartPortErrorWriteProtected
|
||||
}
|
||||
|
||||
// Byte by byte transfer from memory using the full Peek code path
|
||||
@ -104,10 +104,10 @@ func (d *SmartPortHardDisk) writeBlock(block uint32, source uint16) uint8 {
|
||||
|
||||
err := d.disk.Write(block, buf)
|
||||
if err != nil {
|
||||
return proDosDeviceErrorIO
|
||||
return smartPortErrorIO
|
||||
}
|
||||
|
||||
return proDosDeviceNoError
|
||||
return smartPortNoError
|
||||
}
|
||||
|
||||
func (d *SmartPortHardDisk) status(dest uint16) uint8 {
|
||||
@ -125,5 +125,5 @@ func (d *SmartPortHardDisk) status(dest uint16) uint8 {
|
||||
d.host.a.mmu.Poke(dest+6, 0x00)
|
||||
d.host.a.mmu.Poke(dest+7, 0x00) // Reserved
|
||||
|
||||
return proDosDeviceNoError
|
||||
return smartPortNoError
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user