mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 19:51:51 +09:00
lfs -x impl
This commit is contained in:
@@ -6,7 +6,7 @@ To collect a directory into myarchive.lfs:
|
||||
To extract an archive to path\\to\\my\\files:
|
||||
lfs -x myarchive.lfs \\path\\to\\my\\files
|
||||
To list the collected files:
|
||||
lfs -t`)
|
||||
lfs -t myarchive.lfs`)
|
||||
}
|
||||
|
||||
let option = exec_args[1]
|
||||
@@ -33,11 +33,14 @@ function recurseDir(file, action) {
|
||||
}
|
||||
|
||||
}
|
||||
function mkDirs(fd) {
|
||||
let parent = files.open(`${fd.driveLetter}:${fd.parentPath}\\`)
|
||||
if (parent.exists) fd.mkDir()
|
||||
else mkDirs(parent)
|
||||
}
|
||||
|
||||
const lfsFile = files.open(_G.shell.resolvePathInput(lfsPath).full)
|
||||
const rootDir = files.open(_G.shell.resolvePathInput(dirPath).full)
|
||||
|
||||
const rootDirPathLen = rootDir.fullPath.length
|
||||
const rootDir = ("-T" == option) ? undefined : files.open(_G.shell.resolvePathInput(dirPath).full)
|
||||
|
||||
if ("-C" == option) {
|
||||
if (!rootDir.exists) {
|
||||
@@ -46,6 +49,7 @@ if ("-C" == option) {
|
||||
}
|
||||
|
||||
let out = "TVDOSLFS\x01\x00\x00\x00\x00\x00\x00\x00"
|
||||
const rootDirPathLen = rootDir.fullPath.length
|
||||
|
||||
recurseDir(rootDir, file=>{
|
||||
let f = files.open(file.fullPath)
|
||||
@@ -72,15 +76,46 @@ if ("-C" == option) {
|
||||
|
||||
lfsFile.swrite(out)
|
||||
}
|
||||
else if ("T" == option || "-X" == option) {
|
||||
else if ("-T" == option || "-X" == option) {
|
||||
if (!lfsFile.exists) {
|
||||
printerrln(`No such file: ${lfsFile.fullPath}`)
|
||||
return 1
|
||||
}
|
||||
|
||||
const bytes = lfsFile.sread()
|
||||
if (bytes.substring(0, 9) != "TVDOSLFS\x01") {
|
||||
printerrln("File is not LFS")
|
||||
return 2
|
||||
}
|
||||
|
||||
TODO()
|
||||
if ("-X" == option && !rootDir.exists) {
|
||||
rootDir.mkDir()
|
||||
}
|
||||
|
||||
let curs = 16
|
||||
while (curs < bytes.length) {
|
||||
let fileType = bytes.charCodeAt(curs)
|
||||
let pathlen = (bytes.charCodeAt(curs+1) << 8) | bytes.charCodeAt(curs+2)
|
||||
curs += 3
|
||||
let path = bytes.substring(curs, curs + pathlen)
|
||||
curs += pathlen
|
||||
let filelen = (bytes.charCodeAt(curs) << 24) | (bytes.charCodeAt(curs+1) << 16) | (bytes.charCodeAt(curs+2) << 8) | bytes.charCodeAt(curs+3)
|
||||
curs += 4
|
||||
|
||||
if ("-X" == option) {
|
||||
let filebytes = bytes.substring(curs, curs + filelen)
|
||||
let outfile = files.open(`${rootDir.fullPath}\\${path}`)
|
||||
|
||||
mkDirs(files.open(`${rootDir.driveLetter}:${files.open(`${rootDir.fullPath}\\${path}`).parentPath}`))
|
||||
outfile.mkFile()
|
||||
outfile.swrite(filebytes)
|
||||
}
|
||||
else if ("-T" == option) {
|
||||
println(`${filelen}\t${path}`)
|
||||
}
|
||||
|
||||
curs += filelen
|
||||
}
|
||||
}
|
||||
else {
|
||||
printerrln("Unknown option: " + option)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package net.torvald.tsvm
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.Input
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.tsvm.VMEmuExecutableWrapper.Companion.FONT
|
||||
@@ -15,16 +17,52 @@ class ConfigMenu(parent: VMEmuExecutable, x: Int, y: Int, w: Int, h: Int) : EmuM
|
||||
override fun hide() {
|
||||
}
|
||||
|
||||
|
||||
private var guiClickLatched = arrayOf(false, false, false, false, false, false, false, false)
|
||||
|
||||
override fun update() {
|
||||
|
||||
if (Gdx.input.isButtonPressed(Input.Buttons.LEFT)) {
|
||||
if (!guiClickLatched[Input.Buttons.LEFT]) {
|
||||
val mx = Gdx.input.x - x
|
||||
val my = Gdx.input.y - y
|
||||
|
||||
// make com/card/ram buttons work
|
||||
if (mx in 26 until 76) {
|
||||
// com
|
||||
if (my in 37 until 37 + FONT.H*4) {
|
||||
selectedPort = "com${1+((my-37) / FONT.H)}"
|
||||
}
|
||||
// card
|
||||
else if (my in 102 until 102 + FONT.H*7) {
|
||||
selectedPort = "card${1+((my-102) / FONT.H)}"
|
||||
}
|
||||
|
||||
|
||||
//ram
|
||||
if (my in 206 until 206 + FONT.H*10) {
|
||||
selectedRAM = "ram${ramsize[(my-206) / FONT.H]}k"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
guiClickLatched[Input.Buttons.LEFT] = true
|
||||
}
|
||||
}
|
||||
else {
|
||||
guiClickLatched[Input.Buttons.LEFT] = false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private val STR_COM = "\u00D6\u00D7\u00D8\u00D9"
|
||||
private val STR_CARD = "\u00DA\u00DB\u00DC\u00DD"
|
||||
|
||||
private val selectedPort = "" // com1-4, card1-7, ram16k..ram8192k
|
||||
private var selectedPort = "" // com1-4, card1-7
|
||||
private var selectedRAM = ""// ram16k..ram8192k
|
||||
private val ramsize = listOf(16,32,64,128,256,512,1024,2048,4096,8192)
|
||||
|
||||
|
||||
@@ -77,11 +115,22 @@ class ConfigMenu(parent: VMEmuExecutable, x: Int, y: Int, w: Int, h: Int) : EmuM
|
||||
|
||||
for (i in 0..9) {
|
||||
val ramnum = ramsize[i]
|
||||
batch.setColourBy { selectedPort == "ram${ramnum}k" }
|
||||
batch.setColourBy { selectedRAM == "ram${ramnum}k" }
|
||||
FONT.draw(batch, "${ramnum}K", 36f + (if (ramnum < 100) 7f else if (ramnum < 1000) 4f else 0f), 206f + FONT.H * i)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// test print
|
||||
val text = if (selectedPort.startsWith("com"))
|
||||
vm.getIO().blockTransferPorts[selectedPort[3].code - 0x31].recipient?.javaClass?.simpleName
|
||||
else if (selectedPort.startsWith("card"))
|
||||
vm.peripheralTable[selectedPort[4].code - 0x30].peripheral?.javaClass?.simpleName
|
||||
else
|
||||
""
|
||||
|
||||
batch.color = Color.WHITE
|
||||
FONT.draw(batch, text ?: "Nothing", 96f, 37f)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user