mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-10 15:04:03 +09:00
basic:SAVE function, filesystem:write
This commit is contained in:
21
assets/bios/basicbios.js
Normal file
21
assets/bios/basicbios.js
Normal file
@@ -0,0 +1,21 @@
|
||||
println("Main RAM:"+(system.maxmem() >> 10)+" KBytes");
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// probe bootable device
|
||||
|
||||
var _BIOS = {};
|
||||
|
||||
// Syntax: [Port, Drive-number]
|
||||
// Port #0-3: Serial port 1-4
|
||||
// #4+ : Left for future extension
|
||||
// Drive-number always starts at 1
|
||||
_BIOS.FIRST_BOOTABLE_PORT = [0,1]; // ah screw it
|
||||
|
||||
Object.freeze(_BIOS);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// load a BASIC rom
|
||||
sys.mapRom(1);
|
||||
eval("let _appStub=function(exec_args){"+sys.romReadAll()+"};_appStub;")();
|
||||
3
assets/rmaze.bas
Normal file
3
assets/rmaze.bas
Normal file
@@ -0,0 +1,3 @@
|
||||
1 rem RANDOM MAZE
|
||||
10 print(chr$(47+round(rnd(1))*45);)
|
||||
20 goto 10
|
||||
File diff suppressed because it is too large
Load Diff
@@ -70,11 +70,23 @@ filesystem.readAll = function(driveLetter) {
|
||||
throw Error("File not opened");
|
||||
}
|
||||
if (response < 0 || response >= 128) {
|
||||
let status = com.getDeviceStatus(port[0]);
|
||||
throw Error("Reading a file failed with "+response+": "+status.message);
|
||||
throw Error("Reading a file failed with "+response);
|
||||
}
|
||||
return com.pullMessage(port[0]);
|
||||
};
|
||||
filesystem.write = function(driveLetter, string) {
|
||||
let port = filesystem._toPorts(driveLetter);
|
||||
com.sendMessage(port[0], "WRITE"+string.length);
|
||||
let response = com.getStatusCode(port[0]);
|
||||
if (135 == response) {
|
||||
throw Error("File not opened");
|
||||
}
|
||||
if (response < 0 || response >= 128) {
|
||||
throw Error("Writing a file failed with "+response);
|
||||
}
|
||||
com.sendMessage(port[0], string);
|
||||
filesystem._flush(port[0]); filesystem._close(port[0]);
|
||||
};
|
||||
filesystem.isDirectory = function(driveLetter) {
|
||||
let port = filesystem._toPorts(driveLetter);
|
||||
com.sendMessage(port[0], "LISTFILES");
|
||||
|
||||
Reference in New Issue
Block a user