getting rid of old filesystem functions

This commit is contained in:
minjaesong
2022-09-06 20:30:46 +09:00
parent 8232053695
commit 0d1e33f7e6
14 changed files with 102 additions and 47 deletions

View File

@@ -439,6 +439,9 @@ con.move = function(y, x) {
con.addch = function(c) {
graphics.putSymbol(c|0);
};
con.prnch = function(c) {
print("\x84"+c+"u");
};
con.mvaddch = function(y, x, c) {
con.move(y, x); con.addch(c);
};

View File

@@ -570,6 +570,7 @@ Object.freeze(_TVDOS.DRV.FS.DEVFBIPF)
// Legacy Serial filesystem, !!pending for removal!!
/*
const filesystem = {};
filesystem._toPorts = (driveLetter) => {
@@ -692,6 +693,7 @@ filesystem.remove = (driveLetter) => {
return (response === 0);
};
Object.freeze(filesystem);
*/
///////////////////////////////////////////////////////////////////////////////

View File

@@ -39,9 +39,10 @@ let bulletinShown = false;
let cursoringCol = 0;
// load existing file if it's there
let editingExistingFile = (0 == filesystem.open(driveLetter, filePath, "R"));
let file = files.open(`${driveLetter}:/${filePath}`)
let editingExistingFile = file.exists
if (editingExistingFile) {
textbuffer = filesystem.readAll(driveLetter).split("\n");
textbuffer = file.sread().split("\n")
}
let windowWidth = 0;
@@ -197,8 +198,7 @@ function gotoText() {
// FUNCTIONING FUNCTIONS (LOL) //
function writeout() {
filesystem.open(driveLetter, filePath, "W");
filesystem.write(driveLetter, textbuffer.join('\n'));
file.swrite(textbuffer.join("\n"))
}
// KEYBOARDING FUNCTIONS //

View File

@@ -21,9 +21,11 @@ _fsh.brandLogoTexSmall = new GL.Texture(24, 14, gzip.decomp(base64.atob(
_fsh.scrlayout = ["com.fsh.clock","com.fsh.calendar","com.fsh.todo_list", "com.fsh.quick_access"];
_fsh.drawWallpaper = function() {
filesystem.open("A", "/tvdos/wall.bytes", "R")
let wp = files.open("A:/tvdos/wall.bytes")
// filesystem.open("A", "/tvdos/wall.bytes", "R")
let b = sys.malloc(250880)
dma.comToRam(0, 0, b, 250880)
// dma.comToRam(0, 0, b, 250880)
wp.pread(b, 250880, 0)
dma.ramToFrame(b, 0, 250880)
sys.free(b)
};

View File

@@ -3,18 +3,30 @@ if (exec_args[1] === undefined) {
return 1;
}
let fileOpenedStatus = filesystem.open(_G.shell.getCurrentDrive(), _G.shell.resolvePathInput(exec_args[1]).string, "R");
if (fileOpenedStatus != 0) {
let file = files.open(`${_G.shell.getCurrentDrive()}:/${_G.shell.resolvePathInput(exec_args[1]).string}`)
if (!file.exists) {
printerrln(_G.shell.resolvePathInput(exec_args[1]).string+": cannot open");
return fileOpenedStatus;
return 1;
}
let fileContent = filesystem.readAll(_G.shell.getCurrentDrive());
let visible = "";
let fileContent = file.sread()
for (let k = 0; k < fileContent.length; k++) {
if (k > 0 && k % 16 == 0) visible += "\n";
visible += `${fileContent.charCodeAt(k).toString(16).toUpperCase().padStart(2, '0')} `;
for (let k = 0; k < fileContent.length; k += 16) {
for (let i = 0; i < 16; i++) {
let charCode = fileContent.charCodeAt(k+i)
if (!isNaN(charCode))
print(`${charCode.toString(16).toUpperCase().padStart(2, '0')} `)
else
print(` `)
}
print('| ')
for (let i = 0; i < 16; i++) {
let charCode = fileContent.charCodeAt(k+i)
if (!isNaN(charCode))
con.prnch(charCode)
else
con.prnch(0)
}
println()
}
println(visible);
return 0;

View File

@@ -38,13 +38,13 @@ else {
return 0;
}
let fileOpened = filesystem.open(_G.shell.getCurrentDrive(), _G.shell.resolvePathInput(filename).string, "R");
if (fileOpened != 0) {
let file = files.open(`${_G.shell.getCurrentDrive()}:/${_G.shell.resolvePathInput(filename).string}`)
if (!file.exists) {
printerrln(_G.shell.resolvePathInput(filename).string+": cannot open");
return 1;
}
fileContent = filesystem.readAll(_G.shell.getCurrentDrive());
fileContent = file.sread()
}
// initialise some helper variables

View File

@@ -11,20 +11,20 @@ if (exec_args[1] === undefined) {
let path = _G.shell.resolvePathInput(exec_args[2] || exec_args[1]).string;
let driveLetter = _G.shell.getCurrentDrive();
let noNewFile = (exec_args[1] == "/c" || exec_args[1] == "/C");
let fileOpenedStatus = filesystem.open(driveLetter, path, "W");
if (fileOpenedStatus != 0) {
printerrln("TOUCH: Can't open "+driveLetter+":\\"+path+" due to IO error");
return fileOpenedStatus;
}
if (!noNewFile) {
filesystem.mkFile(driveLetter);
}
let touched = filesystem.touch(driveLetter);
if (!touched) {
printerrln("TOUCH: Can't touch "+driveLetter+":\\"+path+" due to IO error");
let file = files.open(`${driveLetter}:/${path}`)
if (!file.exists) {
printerrln("TOUCH: Can't open "+file.fullPath+" due to IO error");
return 1;
}
if (!noNewFile) {
file.mkFile()
}
let touched = file.touch()
if (!touched) {
printerrln("TOUCH: Can't touch "+file.fullPath+" due to IO error");
return 2;
}
return 0;

View File

@@ -2,26 +2,28 @@ let status = 0
let workarea = sys.malloc(1920)
// install LOCHRROM
status = filesystem.open("A", "/tvdos/i18n/hang_lo.chr", "R")
if (status != 0) {
let hangulRomL = files.open("A:/tvdos/i18n/hang_lo.chr")
if (!hangulRomL.exists) {
printerrln("hang_lo.chr not found")
sys.free(workarea)
return status
}
dma.comToRam(filesystem._toPorts("A")[0], 0, workarea, 1920)
//dma.comToRam(filesystem._toPorts("A")[0], 0, workarea, 1920)
hangulRomL.pread(workarea, 1920, 0)
for (let i = 0; i < 1920; i++) sys.poke(-1300607 - i, sys.peek(workarea + i))
sys.poke(-1299460, 18)
// install HICHRROM
status = filesystem.open("A", "/tvdos/i18n/hang_hi.chr", "R")
if (status != 0) {
let hangulRomH = files.open("A:/tvdos/i18n/hang_hi.chr")
if (!hangulRomH.exists) {
printerrln("hang_hi.chr not found")
sys.free(workarea)
sys.poke(-1299460, 20) // clean up the crap
return status
}
dma.comToRam(filesystem._toPorts("A")[0], 0, workarea, 1920)
//dma.comToRam(filesystem._toPorts("A")[0], 0, workarea, 1920)
hangulRomH.pread(workarea, 1920, 0)
for (let i = 0; i < 1920; i++) sys.poke(-1300607 - i, sys.peek(workarea + i))
sys.poke(-1299460, 19)