From 0304ded9917388f6d3a5bc581985e1214d44c386 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Sat, 24 Sep 2022 16:46:44 +0900 Subject: [PATCH] device files are mounted under the drive letter of dollarsign --- assets/disk0/devcontest.js | 2 +- assets/disk0/devipftest.js | 2 +- assets/disk0/devrandomtest.js | 2 +- assets/disk0/tvdos/TVDOS.SYS | 20 ++++++++++++++------ assets/disk0/tvdos/bin/decodeipf.js | 2 +- doc/tsvmman.idx | 12 ++++++------ doc/tsvmman.ind | 12 ++++++------ doc/tvdos.tex | 12 ++++++++---- 8 files changed, 38 insertions(+), 26 deletions(-) diff --git a/assets/disk0/devcontest.js b/assets/disk0/devcontest.js index 614a78c..b82ac75 100644 --- a/assets/disk0/devcontest.js +++ b/assets/disk0/devcontest.js @@ -1,3 +1,3 @@ -let f = files.open("CON") +let f = files.open("$:/CON") f.swrite("Hello, world! I'm just writing to a file named 'CON'\n") f.close() diff --git a/assets/disk0/devipftest.js b/assets/disk0/devipftest.js index 64f4d3a..14ad4a6 100644 --- a/assets/disk0/devipftest.js +++ b/assets/disk0/devipftest.js @@ -1,4 +1,4 @@ -let fout = files.open("FBIPF") +let fout = files.open("$:/FBIPF") let fin = files.open(_G.shell.resolvePathInput(exec_args[1]).full) let ipfRead = fin.bread() diff --git a/assets/disk0/devrandomtest.js b/assets/disk0/devrandomtest.js index 3bf84dc..6ed265f 100644 --- a/assets/disk0/devrandomtest.js +++ b/assets/disk0/devrandomtest.js @@ -1,4 +1,4 @@ -let f = files.open("RND") +let f = files.open("$:/RND") let mlen = 512 let m = sys.malloc(mlen) diff --git a/assets/disk0/tvdos/TVDOS.SYS b/assets/disk0/tvdos/TVDOS.SYS index cc94db5..45a3e82 100644 --- a/assets/disk0/tvdos/TVDOS.SYS +++ b/assets/disk0/tvdos/TVDOS.SYS @@ -94,15 +94,17 @@ _TVDOS.DRV.FS = {} class TVDOSFileDescriptor { constructor(path0, driverID) { - if (driverID === undefined) { - if (!files.reservedNames.includes(path0)) { - throw Error(`${path0} is not a valid device file`) + if (path0.startsWith("$")) { + let devName = path0.substring(3) + + if (!files.reservedNames.includes(devName)) { + throw Error(`${devName} is not a valid device file`) } this._driveLetter = undefined this._path = path0 - this._driverID = `DEV${path0}` - this._driver = _TVDOS.DRV.FS[`DEV${path0}`] // can't just put `driverID` here + this._driverID = `DEV${devName}` + this._driver = _TVDOS.DRV.FS[`DEV${devName}`] // can't just put `driverID` here } else { let p = path0.replaceAll("/", "\\") @@ -111,7 +113,7 @@ class TVDOSFileDescriptor { p = p.substring(0, p.length - 1) } this._driveLetter = p[0] - this._path = p.substring(2) // detaches A: + this._path = p.substring(2) // detaches $: this._driverID = driverID this._driver = _TVDOS.DRV.FS[driverID] serial.println(`TVDOSFileDescriptor input path: ${path0}, p = ${p}, driveLetter = ${this._driveLetter}, path = ${this._path}`) @@ -810,6 +812,12 @@ files.open = (fullPath) => { if (fullPath[2] != '/' && fullPath[2] != '\\') throw Error("Expected full path with drive letter, got " + fullPath) let driveLetter = fullPath[0].toUpperCase() let driver = _TVDOS.DRIVEFS[driveLetter] + + // special device files ($:\NUL, $:\CON, etc) + if ("$" == driveLetter) { + return new TVDOSFileDescriptor(fullPath.toUpperCase()) + } + return new TVDOSFileDescriptor(fullPath, driver) } diff --git a/assets/disk0/tvdos/bin/decodeipf.js b/assets/disk0/tvdos/bin/decodeipf.js index d24b531..129fa93 100644 --- a/assets/disk0/tvdos/bin/decodeipf.js +++ b/assets/disk0/tvdos/bin/decodeipf.js @@ -26,7 +26,7 @@ if (!magicMatching) { } // decode input image -let ipfFile = files.open("FBIPF") +let ipfFile = files.open("$:/FBIPF") graphics.clearText(); graphics.clearPixels(0); graphics.clearPixels2(0) ipfFile.pwrite(infilePtr, infile.size, 0) sys.free(infilePtr) diff --git a/doc/tsvmman.idx b/doc/tsvmman.idx index 0526528..9d7bc4c 100644 --- a/doc/tsvmman.idx +++ b/doc/tsvmman.idx @@ -20,9 +20,9 @@ \indexentry{boot process|hyperpage}{29} \indexentry{coreutils (DOS)|hyperpage}{30} \indexentry{applications (DOS)|hyperpage}{31} -\indexentry{pipe (DOS)|hyperpage}{33} -\indexentry{filesystem (DOS)|hyperpage}{35} -\indexentry{file descriptor (DOS)|hyperpage}{35} -\indexentry{device file|hyperpage}{37} -\indexentry{input (DOS)|hyperpage}{39} -\indexentry{gl (DOS)|hyperpage}{40} +\indexentry{pipe (DOS)|hyperpage}{34} +\indexentry{filesystem (DOS)|hyperpage}{36} +\indexentry{file descriptor (DOS)|hyperpage}{36} +\indexentry{device file|hyperpage}{38} +\indexentry{input (DOS)|hyperpage}{40} +\indexentry{gl (DOS)|hyperpage}{41} diff --git a/doc/tsvmman.ind b/doc/tsvmman.ind index e700d6f..b8724bb 100644 --- a/doc/tsvmman.ind +++ b/doc/tsvmman.ind @@ -19,22 +19,22 @@ \indexspace - \item device file, \hyperpage{37} + \item device file, \hyperpage{38} \indexspace - \item file descriptor (DOS), \hyperpage{35} - \item filesystem (DOS), \hyperpage{35} + \item file descriptor (DOS), \hyperpage{36} + \item filesystem (DOS), \hyperpage{36} \indexspace - \item gl (DOS), \hyperpage{40} + \item gl (DOS), \hyperpage{41} \item graphics (library), \hyperpage{26} \item gzip (library), \hyperpage{12} \indexspace - \item input (DOS), \hyperpage{39} + \item input (DOS), \hyperpage{40} \indexspace @@ -51,7 +51,7 @@ \indexspace - \item pipe (DOS), \hyperpage{33} + \item pipe (DOS), \hyperpage{34} \indexspace diff --git a/doc/tvdos.tex b/doc/tvdos.tex index 4bb27db..08d3725 100644 --- a/doc/tvdos.tex +++ b/doc/tvdos.tex @@ -4,7 +4,7 @@ All \thedos-related features requires the DOS to be fully loaded. - +On this documentation, what would be a reverse solidus (e.g. directory separators) are typesetted using a slash; while they \emph{are} interchangeable, using the reverse solidus are recommended for path input. \chapter{Bootstrapping} @@ -59,10 +59,14 @@ Variables can be set or changed using \textbf{SET} commands. This chapter will only briefly list and describe the applications. \begin{outline} -\1\dossynopsis{basica}{Invokens a BASIC interpreter stored in the ROM. If no BASIC rom is present, nothing will be done.} +\1\dossynopsis{basica}{Invokes a BASIC interpreter stored in the ROM. If no BASIC rom is present, nothing will be done.} +\1\dossynopsis{basic}{If your system is bundled with a software-based BASIC, this command will invoke the BASIC interpreter stored in the disk.} \1\dossynopsis{color}{Changes the background and the foreground of the active session.} \1\dossynopsis{command}{The default text-based DOS shell. Call with \code{command /fancy} for more \ae sthetically pleasing looks.} +\1\dossynopsis{decodeipf}{file}{Decodes the IPF-formatted image to the framebuffer using the graphics processor.} +\1\dossynopsis{drives}{Shows the list of the connected and mounted disk drives.} \1\dossynopsis{edit}{path}{The interactive full-screen text editor.} +\1\dossynopsis{encodeipf}{1/2 imagefile ipffile}{Encodes the given image file (.jpg, .png, .bmp, .tga) to the IPF format using the graphics hardware.} \1\dossynopsis{false}{Returns errorlevel 1 upon execution.} \1\dossynopsis{hexdump}{path}{Prints out the contents of a file in hexadecimal view. Supports pipe.} \1\dossynopsis{less}{path}{Allows user to read the long text, even if they are wider and/or taller than the screen. Supports pipe.} @@ -168,7 +172,7 @@ Functions: \section{The Device Files} -\index{device file}Some devices are also virtualised through the file descriptor, and they are given a special path. (their fullPath does not contain a drive letter) +\index{device file}Some devices are also virtualised through the file descriptor, and they are given a special drive letter of \code{\$}. (e.g. \code{\$:/RND}) \begin{outline} \1\inlinesynopsis{RND}{returns random bytes upon reading} @@ -186,7 +190,7 @@ Functions: \2\argsynopsis{pwrite}{writes the bytes from the given pointer.} \2\argsynopsis{bwrite}{identical to \code{print()} except the given byte array will be casted to string.} \2\argsynopsis{swrite}{identical to \code{print()}.} -\1\inlinesynopsis{FBIPF}{decodes IPF-formatted image to the framebuffer. Use the \emph{Graphics} library for the encoding.} +\1\inlinesynopsis{FBIPF}{decodes IPF-formatted image to the framebuffer. Use the bundled \code{encodeipf.js} for the encoding.} \2\argsynopsis{pwrite, bwrite}{decodes the given IPF binary data. Offsets and counts for \code{pwrite} are ignored.} \end{outline}