system control on sbin

This commit is contained in:
minjaesong
2023-01-31 15:00:45 +09:00
parent 5be05e8eec
commit 7990bcb987
4 changed files with 60 additions and 3 deletions

View File

@@ -12,6 +12,8 @@ const fullFilePath = _G.shell.resolvePathInput(exec_args[1])
const FILE_LENGTH = files.open(fullFilePath.full).size
con.clear();con.curs_set(0)
graphics.clearPixels(255)
graphics.clearPixels2(240)
let seqread = require("seqread")

View File

@@ -2,7 +2,7 @@ const SND_BASE_ADDR = audio.getBaseAddr()
if (!SND_BASE_ADDR) return 10
const MP2_BITRATES = ["VBR", 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384]
const MP2_BITRATES = ["???", 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384]
const MP2_CHANNELMODES = ["Stereo", "Joint", "Dual", "Mono"]
const pcm = require("pcm")
const interactive = exec_args[2] && exec_args[2].toLowerCase() == "/i"

View File

@@ -0,0 +1,54 @@
// synopsis: sysctl {reset|...} target
const verbs = {
"reset": ["Reset", "Resetting"]
}
const actions = {
"reset": {
"mmu": ()=>{
for (let k = 0; k < sys.maxmem(); k += 64) {
try {
sys.free(k)
}
catch (e) {}
}
},
"graphics": ()=>{
graphics.resetPalette()
con.reset_graphics()
graphics.clearPixels(255)
graphics.clearPixels2(240)
graphics.setGraphicsMode(0)
graphics.setBackground(34,51,68)
sys.poke(-1299460, 20)
sys.poke(-1299460, 21)
}
"audio": ()=>{
for (let k = 0; k < 4; k++) {
audio.stop(k)
audio.purgeQueue(k)
audio.resetParams(k)
}
}
}
}
const verb = exec_args[1]
const target = exec_args[2]
if (verb && !target) {
println(`sysctl: no target specified for ${verbs[verb][1]}`)
return 1
}
if (!verb) {
println("Usage: sysctl {reset|...} target")
return 10
}
let actionfun = actions[verb][target]
if (actionfun) actionfun()
else {
printerrln(`sysctl: unknown target ${target}`)
return 1
}