mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-14 00:14:05 +09:00
script modules and 'require()'
This commit is contained in:
@@ -594,6 +594,19 @@ shell.stdio = {
|
||||
}
|
||||
}
|
||||
Object.freeze(shell.stdio)
|
||||
// install an improved version of require that takes care of relative path
|
||||
shell.require = require
|
||||
require = function(path) {
|
||||
// absolute path?
|
||||
if (path[1] == ":") return shell.require(path)
|
||||
else {
|
||||
// if the path starts with ".", look for the current directory
|
||||
// if the path starts with [A-Za-z0-9], look for the DOSDIR/includes
|
||||
if (path[0] == '.') return shell.require(shell.resolvePathInput(path).full + ".js")
|
||||
else return shell.require(`A:${_TVDOS.variables.DOSDIR}/include/${path}.js`)
|
||||
}
|
||||
}
|
||||
|
||||
shell.execute = function(line) {
|
||||
if (0 == line.size) return
|
||||
let parsedTokens = shell.parse(line) // echo, "hai", |, less
|
||||
|
||||
@@ -188,6 +188,15 @@ while (readCount < FILE_LENGTH) {
|
||||
if (65535 == packetType) {
|
||||
frameUnit -= 1
|
||||
}
|
||||
// background colour packets
|
||||
else if (65279 == packetType) {
|
||||
let rgbx = readInt()
|
||||
graphics.setBackground(
|
||||
(rgbx & 0xFF000000) >>> 24,
|
||||
(rgbx & 0x00FF0000) >>> 16,
|
||||
(rgbx & 0x0000FF00) >>> 8
|
||||
)
|
||||
}
|
||||
// video packets
|
||||
else if (packetType < 2047) {
|
||||
// iPF
|
||||
|
||||
Reference in New Issue
Block a user