mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-10 23:04:04 +09:00
virtual terminal wip
This commit is contained in:
@@ -723,11 +723,24 @@ Object.freeze(_TVDOS.DRV.FS.DEVCON)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
let mkvtcontext = (index, VMEM) => {
|
||||
return { // VT0 is reserved for symlink to physical terminal
|
||||
isActive: (index === 0 || index === "0"),
|
||||
buffer: (index === 0 || index === "0") ? undefined : VMEM
|
||||
// TODO: getCursorYX, setCursorYX, setCursorX, setCursorY, getTextForeBack, setTextFore, setTextBack
|
||||
// all read/write form the VMEM
|
||||
}
|
||||
}
|
||||
|
||||
// byte-to-byte copy of the 512 KB of VRAM
|
||||
function mkdevvt(index) {
|
||||
|
||||
// VT0 is reserved for symlink to the physical terminal
|
||||
if (isNaN(index)) return false // check for non-numerics and undefined
|
||||
if (index !== index || index <= 0) return false // check for NaN, 0 and negative values
|
||||
|
||||
// check if the device already exists
|
||||
if (_TVDOS.DRV.FS['DEV'+index] != undefined) return false
|
||||
if (_TVDOS.DRV.FS['DEVVT'+index] != undefined) return false
|
||||
|
||||
let VDEV = {}
|
||||
let VMEM = new Int8Array(512 * 1024)
|
||||
@@ -782,6 +795,7 @@ VDEV.mkFile = () => {}
|
||||
VDEV.remove = () => {}
|
||||
VDEV.exists = () => true
|
||||
|
||||
_TVDOS.VT_CONTEXTS[index] = mkvtcontext(index, VMEM)
|
||||
_TVDOS.DRV.FS['DEVVT'+index] = VDEV
|
||||
|
||||
Object.freeze(_TVDOS.DRV.FS['DEVVT'+index])
|
||||
@@ -846,6 +860,9 @@ _TVDOS.DRV.FS.DEVPT.mkDir = () => {}
|
||||
_TVDOS.DRV.FS.DEVPT.mkFile = () => {}
|
||||
_TVDOS.DRV.FS.DEVPT.remove = () => {}
|
||||
_TVDOS.DRV.FS.DEVPT.exists = () => true
|
||||
|
||||
mkvtcontext(0)
|
||||
|
||||
Object.freeze(_TVDOS.DRV.FS.DEVPT)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -56,11 +56,33 @@ let runner = undefined
|
||||
|
||||
function startNewInstance() {
|
||||
runner = parallel.attachProgram("TVDOS", parallel.spawnNewContext(), bios)
|
||||
|
||||
serial.println("Starting new instance "+runner)
|
||||
|
||||
parallel.launch(runner)
|
||||
sys.sleep(1000)
|
||||
}
|
||||
|
||||
function startNewInstanceOnVT(vtIndex) {
|
||||
if (isNaN(index) || index !== index) throw Error("VT index must be a numeric value")
|
||||
if (index <= 0) throw Error(`VT index cannot be zero or negative (${vtIndex})`)
|
||||
|
||||
// Ensure VT exists
|
||||
if (!_TVDOS.VT_CONTEXTS[vtIndex]) {
|
||||
mkdevvt(vtIndex)
|
||||
}
|
||||
|
||||
// Create context with VT binding
|
||||
let contextInit = `_TVDOS.CURRENT_VT = ${vtIndex};${bios}`
|
||||
|
||||
runner = parallel.attachProgram(`TVDOS-VT${vtIndex}`, parallel.spawnNewContext(), contextInit)
|
||||
|
||||
serial.println(`Starting new instance ${runner} on VT${vtIndex}`)
|
||||
|
||||
parallel.launch(runner)
|
||||
sys.sleep(50)
|
||||
}
|
||||
|
||||
const randomkeypusher = `
|
||||
while (1) {
|
||||
sys.poke(-38, 65 + (Math.random()*26)|0)
|
||||
|
||||
Reference in New Issue
Block a user