diff --git a/assets/bios/quick.js b/assets/bios/quick.js new file mode 100644 index 0000000..22055e7 --- /dev/null +++ b/assets/bios/quick.js @@ -0,0 +1,32 @@ + +// probe bootable device + +var _BIOS = {}; + +// Syntax: [Port, Drive-number] +// Port #0-3: Serial port 1-4 +// #4+ : Left for future extension +// Drive-number always starts at 1 +_BIOS.FIRST_BOOTABLE_PORT = [0,1]; // ah screw it + +Object.freeze(_BIOS); + +/////////////////////////////////////////////////////////////////////////////// + +// load a bootsector using 'LOADBOOT' +let portNumber = 0; +let driveStatus = 0; +while (portNumber < 4) { + if (com.areYouThere(portNumber)) { + com.sendMessage(portNumber, "LOADBOOT"); + driveStatus = com.getStatusCode(portNumber); + if (driveStatus == 0) break; + } + portNumber += 1; +} +if (portNumber < 4) { + eval(com.fetchResponse(portNumber).trimNull()); +} +else { + printerrln("No bootable medium found."); +} \ No newline at end of file diff --git a/assets/disk0/tvdos/bin/command.js b/assets/disk0/tvdos/bin/command.js index c0ba157..0c29f8a 100644 --- a/assets/disk0/tvdos/bin/command.js +++ b/assets/disk0/tvdos/bin/command.js @@ -50,7 +50,7 @@ function greet() { con.color_pair(0,253); print(" ".repeat(greetLeftPad)+welcome_text+" ".repeat(greetRightPad)); con.color_pair(253,255); - con.addch(16); + con.addch(16);print(' '); con.move(3,1); } else @@ -434,7 +434,7 @@ if (goInteractive) { if (isNaN(errorlevel)) errorlevel = 2; } catch (e) { - printerrln("\n"+e); + printerrln("\n"+(e.stack || e)); if (errorlevel === 0 || isNaN(errorlevel)) { errorlevel = 1; // generic failure } diff --git a/assets/disk0/tvdos/tuidev/demo.js b/assets/disk0/tvdos/tuidev/demo.js new file mode 100644 index 0000000..b5cdc48 --- /dev/null +++ b/assets/disk0/tvdos/tuidev/demo.js @@ -0,0 +1,76 @@ +/* +Screen: +=================== +Titlebar +=================== + +C A N V A S + +=================== + +there are usually two separate canvases: main-screen and menu-screen +*/ + +class SimpleScreen { + + constructor(title) { + this.title = title; + this.termWidth = con.getmaxyx()[1]; + this.termHeight = con.getmaxyx()[0]; + } + + drawTitlebar() { + + let titleLeftPad = (this.termWidth - this.title.length - 6) >> 1; + let titleRightPad = this.termWidth - titleLeftPad - this.title.length - 6; + + con.move(1,1); + con.color_pair(253,255); + print(' ');con.addch(17); + con.color_pair(0,253); + print(" ".repeat(titleLeftPad)+this.title+" ".repeat(titleRightPad)); + con.color_pair(253,255); + con.addch(16);print(' '); + } + redraw() { + con.color_pair(239,255); + con.clear(); + this.drawTitlebar(); + if (this.canvas !== undefined) this.canvas.redraw(); + } + update() { + if (this.canvas !== undefined) this.canvas.update(); + } +} + +class Canvas { + constructor(identifier) { + this.id = identifier; + } + redraw() {} + update() {} +} + +class Demo extends SimpleScreen { + constructor(title) { + super(title); + let mainCanvas = new Canvas("main"); + mainCanvas.redraw = () => { + + } + mainCanvas.update = () => { + con.move(2 + (Math.random()*(this.termHeight - 1)), 1 + (Math.random()*this.termWidth)); + con.addch(0xB3 + (Math.random()*39)); + } + + this.mainCanvas = mainCanvas + this.canvas = this.mainCanvas; + } +} + +let s = new Demo("Ctrl-C to exit"); +s.redraw(); +while (!con.hitterminate()) { + s.update(); +} +con.clear(); \ No newline at end of file diff --git a/src/net/torvald/tsvm/AppLoader.java b/src/net/torvald/tsvm/AppLoader.java index 5b84786..0e71662 100644 --- a/src/net/torvald/tsvm/AppLoader.java +++ b/src/net/torvald/tsvm/AppLoader.java @@ -30,7 +30,7 @@ public class AppLoader { //VM vm = new VM(64 << 10, new TheRealWorld(), new VMProgramRom[]{BasicBios.INSTANCE, BasicRom.INSTANCE}); //VM vm = new VM(64 << 10, new TheRealWorld(), new VMProgramRom[]{OEMBios.INSTANCE, BasicRom.INSTANCE}); - VM vm = new VM(64 << 10, new TheRealWorld(), new VMProgramRom[]{GenericBios.INSTANCE}); + VM vm = new VM(64 << 10, new TheRealWorld(), new VMProgramRom[]{QuickBios.INSTANCE}); //VM vm = new VM(64 << 10, new TheRealWorld(), new VMProgramRom[]{TBASRelBios.INSTANCE}); new LwjglApplication(new VMGUI(vm, appConfig), appConfig); } diff --git a/src/net/torvald/tsvm/peripheral/GraphicsAdapter.kt b/src/net/torvald/tsvm/peripheral/GraphicsAdapter.kt index 5421cee..57b0fe5 100644 --- a/src/net/torvald/tsvm/peripheral/GraphicsAdapter.kt +++ b/src/net/torvald/tsvm/peripheral/GraphicsAdapter.kt @@ -123,7 +123,7 @@ open class GraphicsAdapter(val vm: VM, val config: AdapterConfig, val sgr: Super var newx = x var newy = y - if (newx >= TEXT_COLS) { + if (newx > TEXT_COLS) { newx = 0 newy += 1 } diff --git a/src/net/torvald/tsvm/peripheral/TTY.kt b/src/net/torvald/tsvm/peripheral/TTY.kt index 036fc9a..958c2ee 100644 --- a/src/net/torvald/tsvm/peripheral/TTY.kt +++ b/src/net/torvald/tsvm/peripheral/TTY.kt @@ -39,7 +39,7 @@ class TTY(val vm: VM) : GlassTty(TEXT_ROWS, TEXT_COLS), PeriBase { var newx = x var newy = y - if (newx >= TEXT_COLS) { + if (newx > TEXT_COLS) { newx = 0 newy += 1 } diff --git a/src/net/torvald/tsvm/peripheral/VMProgramRom.kt b/src/net/torvald/tsvm/peripheral/VMProgramRom.kt index 40c5f93..bb03f2d 100644 --- a/src/net/torvald/tsvm/peripheral/VMProgramRom.kt +++ b/src/net/torvald/tsvm/peripheral/VMProgramRom.kt @@ -30,6 +30,25 @@ object GenericBios : VMProgramRom { override fun get(addr: Int): Byte = contents[addr] } +object QuickBios : VMProgramRom { + private val contents: ByteArray + + init { + val bytes = File("./assets/bios/quick.js").readBytes() + contents = bytes.sliceArray(0 until minOf(65536, bytes.size)) + } + + override fun readAll(): String { + // check if bios is compressed in gzip + return if (contents.startsWith(GZIP_HEADER)) + CompressorDelegate.decomp(contents).toString(VM.CHARSET) + else + contents.toString(VM.CHARSET) + } + + override fun get(addr: Int): Byte = contents[addr] +} + object BasicBios : VMProgramRom { private val contents: ByteArray