implementation of mmio 1024..2047

This commit is contained in:
minjaesong
2021-04-20 14:49:58 +09:00
parent 95c33f7d5e
commit d85b1a99dc
3 changed files with 40 additions and 3 deletions

View File

@@ -9,7 +9,6 @@ let DEBUG_PRINT = true;
let errorlevel = 0;
const termWidth = con.getmaxyx()[1];
const termHeight = con.getmaxyx()[0];
const welcome_text = (termWidth > 40) ? "TSVM Disk Operating System, version " + _TVDOS.VERSION
@@ -17,6 +16,14 @@ const welcome_text = (termWidth > 40) ? "TSVM Disk Operating System, version " +
const greetLeftPad = (termWidth - welcome_text.length - 6) >> 1;
const greetRightPad = termWidth - greetLeftPad - welcome_text.length - 6;
function makeHash() {
let e = "YBNDRFG8EJKMCPQXOTLVWIS2A345H769";
let m = e.length;
return e[Math.floor(Math.random()*m)] + e[Math.floor(Math.random()*m)] + e[Math.floor(Math.random()*m)] + e[Math.floor(Math.random()*m)] + e[Math.floor(Math.random()*m)]
}
const shellID = makeHash();
function print_prompt_text() {
if (goFancy) {
con.color_pair(239,161);
@@ -59,6 +66,12 @@ function greet() {
println(welcome_text);
}
function sendLcdMsg(s) {
for (let i = 1024; i < 1048; i++) {
sys.poke(-i-1, (s === undefined) ? 0 : s.charCodeAt(i - 1024)|0);
}
}
function trimStartRevSlash(s) {
var cnt = 0;
while (cnt < s.length) {
@@ -362,7 +375,18 @@ shell.execute = function(line) {
});
}
else {
return execApp(programCode, tokens)|0; // return value of undefined will cast into 0
if (_G.shellProgramTitles === undefined) _G.shellProgramTitles = [];
_G.shellProgramTitles.push(cmd.toUpperCase())
sendLcdMsg(_G.shellProgramTitles[_G.shellProgramTitles.length - 1]);
serial.println(_G.shellProgramTitles);
let ret = execApp(programCode, tokens)|0; // return value of undefined will cast into 0
_G.shellProgramTitles.pop();
sendLcdMsg(_G.shellProgramTitles[_G.shellProgramTitles.length - 1]);
serial.println(_G.shellProgramTitles);
return ret;
}
}
}
@@ -370,7 +394,6 @@ shell.execute = function(line) {
Object.freeze(shell);
_G.shell = shell;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (exec_args[1] !== undefined) {

View File

@@ -41,6 +41,7 @@ class CharacterLCDdisplay(vm: VM) : GraphicsAdapter(vm, AdapterConfig(
val batPerc = "89"
val batVolt = "5.1"
val batText = " $batPerc% ${batVolt}V"
val msg = (1024L until 1048L).map { vm.getIO().mmio_read(it)!!.toInt().and(255) }
vm.poke(-69,2)
val time_t = currentTimeInMills()
val min = (time_t / 60000) % 60
@@ -58,6 +59,10 @@ class CharacterLCDdisplay(vm: VM) : GraphicsAdapter(vm, AdapterConfig(
val ccode = clock[x].toInt()
batch.draw(lcdFont.get(ccode % 16, ccode / 16), xoff+74 + x * lcdFont.tileW, y)
}
for (x in msg.indices) {
val ccode = msg[x]
batch.draw(lcdFont.get(ccode % 16, ccode / 16), xoff+74 + (x + 6) * lcdFont.tileW, y)
}
for (x in batText.indices) {
val ccode = batText[x].toInt()
batch.draw(lcdFont.get(ccode % 16, ccode / 16), xoff+74 + (config.textCols - batText.length + x) * lcdFont.tileW, y)

View File

@@ -37,6 +37,8 @@ class IOSpace(val vm: VM) : PeriBase, InputProcessor {
)
/*private*/ val blockTransferPorts = Array(4) { BlockTransferPort(vm, it) }
private val peripheralFast = UnsafeHelper.allocate(1024)
private val keyEventBuffers = ByteArray(8)
init {
@@ -45,6 +47,8 @@ class IOSpace(val vm: VM) : PeriBase, InputProcessor {
//blockTransferPorts[0].attachDevice(TestDiskDrive(vm, 0, File("assets/disk0")))
// for testers: use EmulInstance
peripheralFast.fillWith(0)
}
private fun composeBlockTransferStatus(portno: Int): Int {
@@ -99,6 +103,8 @@ class IOSpace(val vm: VM) : PeriBase, InputProcessor {
88L -> vm.romMapping.toByte()
in 1024..2047 -> peripheralFast[addr - 1024]
4076L -> blockTransferPorts[0].statusCode.toByte()
4077L -> blockTransferPorts[1].statusCode.toByte()
4078L -> blockTransferPorts[2].statusCode.toByte()
@@ -157,6 +163,8 @@ class IOSpace(val vm: VM) : PeriBase, InputProcessor {
88L -> vm.romMapping = bi
in 1024..2047 -> peripheralFast[addr - 1024] = byte
4076L -> blockTransferPorts[0].statusCode = bi
4077L -> blockTransferPorts[1].statusCode = bi
4078L -> blockTransferPorts[2].statusCode = bi
@@ -203,6 +211,7 @@ class IOSpace(val vm: VM) : PeriBase, InputProcessor {
override fun dispose() {
blockTransferRx.forEach { it.destroy() }
blockTransferTx.forEach { it.destroy() }
peripheralFast.destroy()
}
private var mouseX: Short = 0