device file for physical and virtual terminals

This commit is contained in:
minjaesong
2025-07-23 11:43:53 +09:00
parent e3aa143c5b
commit 923137d459
2 changed files with 129 additions and 0 deletions

View File

@@ -723,6 +723,133 @@ Object.freeze(_TVDOS.DRV.FS.DEVCON)
///////////////////////////////////////////////////////////////////////////////
// byte-to-byte copy of the 512 KB of VRAM
function mkdevvt(index) {
// check if the device already exists
if (_TVDOS.DRV.FS['DEV'+index] != undefined) return false
let VDEV = {}
let VMEM = new Int8Array(512 * 1024)
VDEV.pread = (fd, ptr, count, offset) => {
for (let i = 0; i < (count || 0); i++) {
sys.poke(ptr + i, VMEM[i + (offset || 0)])
}
}
VDEV.bread = (fd) => {
return VMEM.slice()
}
VDEV.sread = (fd) => {
let r = ''
for (let i = 0; i < VMEM.length; i++) {
let c = VMEM[i]
r += String.fromCharCode((c < 0) ? 256 + c : c)
}
return r
}
VDEV.pwrite = (fd, ptr, count, offset) => {
for (let i = 0; i < (count || 0); i++) {
VMEM[i + (offset || 0)] = sys.peek(ptr + i)
}
}
VDEV.bwrite = (fd, bytes) {
if (bytes.length == VMEM.length && bytes instanceof Int8Array) {
VMEM = bytes.slice()
}
else {
for (let i = 0; i < bytes.length; i++) {
VMEM[i] = bytes[i]
}
}
}
VDEV.swrite = (fd, string) => {
for (let i = 0; i < string.length; i++) {
VMEM[i] = string.charCodeAt(i)
}
}
VDEV.flush = () => {}
VDEV.close = () => {}
VDEV.isDirectory = () => false
VDEV.listFiles = () => undefined
VDEV.touch = () => {}
VDEV.mkDir = () => {}
VDEV.mkFile = () => {}
VDEV.remove = () => {}
VDEV.exists = () => true
_TVDOS.DRV.FS['DEVVT'+index] = VDEV
Object.freeze(_TVDOS.DRV.FS['DEVVT'+index])
return true
}
///////////////////////////////////////////////////////////////////////////////
// physical video terminal
_TVDOS.DRV.FS.DEVPT = {}
_TVDOS.DRV.FS.DEVPT.pread = (fd, ptr, count, offset) => {
let mem = graphics.getGpuMemBase()
for (let i = 0; i < (count || 0); i++) {
sys.poke(ptr + i, sys.peek(mem - i))
}
}
_TVDOS.DRV.FS.DEVPT.bread = (fd) => {
let mem = graphics.getGpuMemBase()
let r = new Int8Array(512 * 1024)
for (let i = 0; i < r.length; i++) {
r[i] = sys.peek(mem - i)
}
}
_TVDOS.DRV.FS.DEVPT.sread = (fd) => {
let mem = graphics.getGpuMemBase()
let r = ''
for (let i = 0; i < 512 * 1024; i++) {
let c = sys.peek(mem - i)
r[i] = String.fromCharCode((c < 0) ? 256 + c : c)
}
}
_TVDOS.DRV.FS.DEVPT.pwrite = (fd, ptr, count, offset) => {
let mem = graphics.getGpuMemBase()
for (let i = 0; i < (count || 0); i++) {
sys.poke(mem - i, sys.peek(ptr + i))
}
}
_TVDOS.DRV.FS.DEVPT.bwrite = (fd, bytes) {
let mem = graphics.getGpuMemBase()
for (let i = 0; i < bytes.length; i++) {
sys.poke(mem - i, bytes[i])
}
}
_TVDOS.DRV.FS.DEVPT.swrite = (fd, string) => {
let mem = graphics.getGpuMemBase()
for (let i = 0; i < string.length; i++) {
sys.poke(mem - i, string.charCodeAt(i))
}
}
_TVDOS.DRV.FS.DEVPT.flush = () => {}
_TVDOS.DRV.FS.DEVPT.close = () => {}
_TVDOS.DRV.FS.DEVPT.isDirectory = () => false
_TVDOS.DRV.FS.DEVPT.listFiles = () => undefined
_TVDOS.DRV.FS.DEVPT.touch = () => {}
_TVDOS.DRV.FS.DEVPT.mkDir = () => {}
_TVDOS.DRV.FS.DEVPT.mkFile = () => {}
_TVDOS.DRV.FS.DEVPT.remove = () => {}
_TVDOS.DRV.FS.DEVPT.exists = () => true
Object.freeze(_TVDOS.DRV.FS.DEVPT)
///////////////////////////////////////////////////////////////////////////////
_TVDOS.DRV.FS.DEVFBIPF = {}
_TVDOS.DRV.FS.DEVFBIPF.pwrite = (fd, infilePtr, count, _2) => {

View File

@@ -893,6 +893,7 @@ NOTE: Sequential I/O will clobber the peripheral memory space.
0x01 - Skip (arg 1) bytes
0x02 - Read (arg 1) bytes and store to core memory pointer (arg 2)
0x03 - Write (arg 1) bytes using data from the core memory from pointer (arg 2)
0xF0 - Rewind the file to the starting point
0xFF - Terminate sequential I/O session and free up the memory space
259..261 RW: Argument #1
262..264 RW: Argument #2
@@ -903,3 +904,4 @@ NOTE: Sequential I/O will clobber the peripheral memory space.
Memory Space
0..1048575 RW: Buffer for the block transfer lane
note: length of a command cannot exceed 4096 bytes