mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-09 22:54:03 +09:00
gzip now works after some TVDOS kernel fixes
This commit is contained in:
@@ -1,3 +1,11 @@
|
|||||||
|
let _fromCharCode = b => String.fromCharCode((b >= 0) ? b : 256 + b)
|
||||||
|
function btostr(bytes) {
|
||||||
|
let s = ""
|
||||||
|
for (let i = 0; i < bytes.length; i++) {
|
||||||
|
s += _fromCharCode(bytes[i])
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
}
|
||||||
// define exceptions
|
// define exceptions
|
||||||
function InterruptedException(m) {
|
function InterruptedException(m) {
|
||||||
this.message = m;
|
this.message = m;
|
||||||
@@ -180,7 +188,7 @@ class TVDOSFileDescriptor {
|
|||||||
|
|
||||||
this._driverID = driverID
|
this._driverID = driverID
|
||||||
this._driver = _TVDOS.DRV.FS[driverID]
|
this._driver = _TVDOS.DRV.FS[driverID]
|
||||||
serial.println(`TVDOSFileDescriptor input path: ${path0}, p = ${p}, driveLetter = ${this._driveLetter}, path = ${this._path}, driver = ${driverID}`)
|
// serial.println(`TVDOSFileDescriptor input path: ${path0}, p = ${p}, driveLetter = ${this._driveLetter}, path = ${this._path}, driver = ${driverID}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -430,7 +438,7 @@ _TVDOS.DRV.FS.SERIAL.swrite = (fd, string) => {
|
|||||||
_TVDOS.DRV.FS.SERIAL._flush(port[0]);_TVDOS.DRV.FS.SERIAL._close(port[0])
|
_TVDOS.DRV.FS.SERIAL._flush(port[0]);_TVDOS.DRV.FS.SERIAL._close(port[0])
|
||||||
}
|
}
|
||||||
_TVDOS.DRV.FS.SERIAL.bwrite = (fd, bytes) => { // pwrite replaces DMA.ramToCom
|
_TVDOS.DRV.FS.SERIAL.bwrite = (fd, bytes) => { // pwrite replaces DMA.ramToCom
|
||||||
let string = String.fromCharCode.apply(null, bytes) // no spreading: has length limit
|
let string = btostr(bytes) // no spreading: has length limit
|
||||||
_TVDOS.DRV.FS.SERIAL.swrite(fd, string)
|
_TVDOS.DRV.FS.SERIAL.swrite(fd, string)
|
||||||
}
|
}
|
||||||
_TVDOS.DRV.FS.SERIAL.pappend = (fd, ptr, count) => {
|
_TVDOS.DRV.FS.SERIAL.pappend = (fd, ptr, count) => {
|
||||||
@@ -440,7 +448,7 @@ _TVDOS.DRV.FS.SERIAL.pappend = (fd, ptr, count) => {
|
|||||||
dma.ramToCom(ptr, port[0], count)
|
dma.ramToCom(ptr, port[0], count)
|
||||||
}
|
}
|
||||||
_TVDOS.DRV.FS.SERIAL.bappend = (fd, bytes) => { // pwrite replaces DMA.ramToCom
|
_TVDOS.DRV.FS.SERIAL.bappend = (fd, bytes) => { // pwrite replaces DMA.ramToCom
|
||||||
let string = String.fromCharCode.apply(null, bytes) // no spreading: has length limit
|
let string = btostr(bytes) // no spreading: has length limit
|
||||||
_TVDOS.DRV.FS.SERIAL.sappend(fd, string)
|
_TVDOS.DRV.FS.SERIAL.sappend(fd, string)
|
||||||
}
|
}
|
||||||
_TVDOS.DRV.FS.SERIAL.sappend = (fd, string) => {
|
_TVDOS.DRV.FS.SERIAL.sappend = (fd, string) => {
|
||||||
@@ -686,7 +694,7 @@ _TVDOS.DRV.FS.DEVCON.sread = (fd) => {
|
|||||||
|
|
||||||
_TVDOS.DRV.FS.DEVCON.pwrite = (fd, ptr, count, offset) => {}
|
_TVDOS.DRV.FS.DEVCON.pwrite = (fd, ptr, count, offset) => {}
|
||||||
_TVDOS.DRV.FS.DEVCON.bwrite = (fd, bytes) => {
|
_TVDOS.DRV.FS.DEVCON.bwrite = (fd, bytes) => {
|
||||||
let string = String.fromCharCode.apply(null, bytes) // no spreading: has length limit
|
let string = btostr(bytes) // no spreading: has length limit
|
||||||
_TVDOS.DRV.FS.DEVZERO.swrite(fd, string)
|
_TVDOS.DRV.FS.DEVZERO.swrite(fd, string)
|
||||||
}
|
}
|
||||||
_TVDOS.DRV.FS.DEVCON.swrite = (fd, string) => {
|
_TVDOS.DRV.FS.DEVCON.swrite = (fd, string) => {
|
||||||
@@ -941,7 +949,7 @@ filesystem.write = (driveLetter, string) => {
|
|||||||
filesystem._flush(port[0]); filesystem._close(port[0]);
|
filesystem._flush(port[0]); filesystem._close(port[0]);
|
||||||
};
|
};
|
||||||
filesystem.writeBytes = (driveLetter, bytes) => {
|
filesystem.writeBytes = (driveLetter, bytes) => {
|
||||||
var string = String.fromCharCode.apply(null, bytes); // no spreading: has length limit
|
var string = btostr(bytes); // no spreading: has length limit
|
||||||
filesystem.write(driveLetter, string);
|
filesystem.write(driveLetter, string);
|
||||||
};
|
};
|
||||||
filesystem.isDirectory = (driveLetter) => {
|
filesystem.isDirectory = (driveLetter) => {
|
||||||
@@ -1004,8 +1012,6 @@ files.reservedNames = ["AUX", // unused
|
|||||||
|
|
||||||
/** This function only creates a file descriptor; will not actually interact with the drives yet. */
|
/** This function only creates a file descriptor; will not actually interact with the drives yet. */
|
||||||
files.open = (fullPath) => {
|
files.open = (fullPath) => {
|
||||||
// FIXME nonexisting file must NOT return undefined (try: 'cd Q:\' on command.js)
|
|
||||||
|
|
||||||
if (files.reservedNames.includes(fullPath.toUpperCase())) {
|
if (files.reservedNames.includes(fullPath.toUpperCase())) {
|
||||||
return new TVDOSFileDescriptor(fullPath.toUpperCase())
|
return new TVDOSFileDescriptor(fullPath.toUpperCase())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ const toStdout = (options.indexOf("-C") >= 0)
|
|||||||
|
|
||||||
|
|
||||||
const file = files.open(_G.shell.resolvePathInput(filePath).full)
|
const file = files.open(_G.shell.resolvePathInput(filePath).full)
|
||||||
const file2 = files.open(_G.shell.resolvePathInput(filePath).full + ".gz")
|
//const file2 = files.open(_G.shell.resolvePathInput(filePath).full + ".gz")
|
||||||
|
|
||||||
// returns Java byte[]
|
// returns Java byte[]
|
||||||
const actionfun = (decompMode) ?
|
const actionfun = (decompMode) ?
|
||||||
@@ -39,15 +39,11 @@ const actionfun = (decompMode) ?
|
|||||||
|
|
||||||
|
|
||||||
const writefun = (toStdout) ?
|
const writefun = (toStdout) ?
|
||||||
(bytes) => print(String.fromCharCode.apply(null, bytes))
|
(bytes) => print(btostr(bytes))
|
||||||
:
|
:
|
||||||
(bytes) => file2.swrite(String.fromCharCode.apply(null, bytes))
|
(bytes) => file.swrite(btostr(bytes))
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
|
|
||||||
writefun(actionfun(file.bread()))
|
writefun(actionfun(file.bread()))
|
||||||
//file2.swrite(file.sread())
|
|
||||||
|
|
||||||
|
|
||||||
// FIXME compression seems to work fine but this program writes lots of ?????s
|
|
||||||
|
|||||||
@@ -36,14 +36,14 @@ const COL_HL_EXT = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const EXEC_FUNS = {
|
const EXEC_FUNS = {
|
||||||
"wav": (f) => _G.shell.execute(`playwav ${f} /i`),
|
"wav": (f) => _G.shell.execute(`playwav ${f} -i`),
|
||||||
"adpcm": (f) => _G.shell.execute(`playwav ${f} /i`),
|
"adpcm": (f) => _G.shell.execute(`playwav ${f} -i`),
|
||||||
"mp3": (f) => _G.shell.execute(`playmp3 ${f} /i`),
|
"mp3": (f) => _G.shell.execute(`playmp3 ${f} -i`),
|
||||||
"mp2": (f) => _G.shell.execute(`playmp2 ${f} /i`),
|
"mp2": (f) => _G.shell.execute(`playmp2 ${f} -i`),
|
||||||
"mov": (f) => _G.shell.execute(`playmov ${f} /i`),
|
"mov": (f) => _G.shell.execute(`playmov ${f} -i`),
|
||||||
"pcm": (f) => _G.shell.execute(`playpcm ${f} /i`),
|
"pcm": (f) => _G.shell.execute(`playpcm ${f} -i`),
|
||||||
"ipf1": (f) => _G.shell.execute(`decodeipf ${f} /i`),
|
"ipf1": (f) => _G.shell.execute(`decodeipf ${f} -i`),
|
||||||
"ipf2": (f) => _G.shell.execute(`decodeipf ${f} /i`),
|
"ipf2": (f) => _G.shell.execute(`decodeipf ${f} -i`),
|
||||||
"bas": (f) => _G.shell.execute(`basic ${f}`)
|
"bas": (f) => _G.shell.execute(`basic ${f}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user