dos kernel wip

This commit is contained in:
minjaesong
2020-10-29 11:52:31 +09:00
parent 5167bf1034
commit 219bc641cf
10 changed files with 105 additions and 79 deletions

View File

@@ -80,7 +80,6 @@ object SerialHelper {
fun getDeviceStatus(vm: VM, portNo: Int): DeviceStatus {
val msgStr = sendMessageGetBytes(vm, portNo, "DEVSTU$END_OF_SEND_BLOCK".toByteArray(VM.CHARSET))
return DeviceStatus(
msgStr[0] == 0x06.toByte(),
msgStr[1].toUint(),
msgStr.sliceArray(3 until msgStr.size - 1).toString(VM.CHARSET)
)
@@ -130,7 +129,7 @@ object SerialHelper {
private fun Boolean.toInt() = if (this) 1 else 0
data class DeviceStatus(val isError: Boolean, val code: Int, val message: String)
data class DeviceStatus(val code: Int, val message: String)
}
class SerialHelperDelegate(val vm: VM) {
@@ -138,7 +137,8 @@ class SerialHelperDelegate(val vm: VM) {
fun pullMessage(portNo: Int) = SerialHelper.pullMessage(vm, portNo).toString(VM.CHARSET)
fun sendMessageGetBytes(portNo: Int, message: String) = SerialHelper.sendMessageGetBytes(vm, portNo, message.toByteArray(VM.CHARSET)).toString(VM.CHARSET)
fun fetchResponse(portNo: Int) = SerialHelper.fetchResponse(vm, portNo).toString(VM.CHARSET)
fun getDeviceStatus(portNo: Int) = SerialHelper.getDeviceStatus(vm, portNo)
fun waitUntilReady(portNo: Int) = SerialHelper.waitUntilReady(vm, portNo)
fun getStatusCode(portNo: Int) = SerialHelper.getStatusCode(vm, portNo)
/** @return Object where { code: <Int>, message: <String> } */
fun getDeviceStatus(portNo: Int) = SerialHelper.getDeviceStatus(vm, portNo)
}

View File

@@ -65,6 +65,10 @@ class VMGUI(val appConfig: LwjglApplicationConfiguration) : ApplicationAdapter()
val tvgl = fr2.readText()
fr2.close()
val fr3 = FileReader("./assets/tvdos/TVDOS.SYS")
val tvknl = fr3.readText()
fr3.close()
//val fr = FileReader("./assets/tvdos/command.js")
//val fr = FileReader("./assets/zippytest.js")
@@ -77,7 +81,7 @@ class VMGUI(val appConfig: LwjglApplicationConfiguration) : ApplicationAdapter()
vmRunner = VMRunnerFactory(vm, "js")
coroutineJob = GlobalScope.launch {
vmRunner.evalGlobal(bios + "\n" + tvgl)
vmRunner.evalGlobal("$bios\n$tvknl\n$tvgl")
vmRunner.executeCommand(prg)
}
}

View File

@@ -38,8 +38,8 @@ class IOSpace(val vm: VM) : PeriBase, InputProcessor {
private val keyEventBuffers = ByteArray(8)
init {
blockTransferPorts[0].attachDevice(TestFunctionGenerator())
blockTransferPorts[1].attachDevice(TestDiskDrive(0))
//blockTransferPorts[0].attachDevice(TestFunctionGenerator())
blockTransferPorts[0].attachDevice(TestDiskDrive(0))
}
private fun composeBlockTransferStatus(portno: Int): Int {

View File

@@ -31,19 +31,6 @@ class TestDiskDrive(private val driveNum: Int) : BlockTransferInterface(false, t
fun composePositiveAns(vararg msg: String): ByteArray {
val sb = ArrayList<Byte>()
sb.add(GOOD_NEWS)
sb.addAll(msg[0].toByteArray().toTypedArray())
for (k in 1 until msg.size) {
sb.add(UNIT_SEP)
sb.addAll(msg[k].toByteArray().toTypedArray())
}
sb.add(END_OF_SEND_BLOCK)
return sb.toByteArray()
}
fun composeNegativeAns(vararg msg: String): ByteArray {
val sb = ArrayList<Byte>()
sb.add(BAD_NEWS)
sb.addAll(msg[0].toByteArray().toTypedArray())
for (k in 1 until msg.size) {
sb.add(UNIT_SEP)
@@ -130,14 +117,8 @@ class TestDiskDrive(private val driveNum: Int) : BlockTransferInterface(false, t
writeMode = false
writeModeLength = -1
}
else if (inputString.startsWith("DEVSTU\u0017")) {
if (statusCode < 128) {
recipient?.writeout(composePositiveAns("${statusCode.toChar()}", errorMsgs[statusCode]))
}
else {
recipient?.writeout(composeNegativeAns("${statusCode.toChar()}", errorMsgs[statusCode]))
}
}
else if (inputString.startsWith("DEVSTU\u0017"))
recipient?.writeout(composePositiveAns("${statusCode.toChar()}", errorMsgs[statusCode]))
else if (inputString.startsWith("DEVTYP\u0017"))
recipient?.writeout(composePositiveAns("STOR"))
else if (inputString.startsWith("DEVNAM\u0017"))

View File

@@ -90,7 +90,6 @@ Nunc mollis nibh vitae sapien consequat, ut vestibulum sem pharetra. Aliquam iac
fun composeSerialAns(vararg msg: String): ByteArray {
val sb = ArrayList<Byte>()
sb.add(0x06) // always positive ans
sb.addAll(msg[0].toByteArray().toTypedArray())
for (k in 1 until msg.lastIndex) {
sb.add(0x1F)