rk86 2.0.5 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/rk86.js +11 -21
package/package.json
CHANGED
package/rk86.js
CHANGED
|
@@ -1588,6 +1588,10 @@ var init_catalog_data = __esm(() => {
|
|
|
1588
1588
|
];
|
|
1589
1589
|
});
|
|
1590
1590
|
|
|
1591
|
+
// src/lib/rk86_terminal.ts
|
|
1592
|
+
import { existsSync } from "fs";
|
|
1593
|
+
import { readFile } from "fs/promises";
|
|
1594
|
+
|
|
1591
1595
|
// src/lib/hex.ts
|
|
1592
1596
|
function hex(v, prefix) {
|
|
1593
1597
|
return v.toString(16).toUpperCase();
|
|
@@ -3701,12 +3705,12 @@ function decodeMon32() {
|
|
|
3701
3705
|
return Array.from(new Uint8Array(Uint8Array.from(atob(MON32_B64), (c) => c.charCodeAt(0))));
|
|
3702
3706
|
}
|
|
3703
3707
|
async function fetchFile(name) {
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
} catch {
|
|
3708
|
-
console.error(`\u043E\u0448\u0438\u0431\u043A\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043A\u0438 \u0444\u0430\u0439\u043B\u0430: ${name}`);
|
|
3708
|
+
if (!existsSync(name)) {
|
|
3709
|
+
console.error(`\u0444\u0430\u0439\u043B \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D: ${name}`);
|
|
3710
|
+
process.exit(1);
|
|
3709
3711
|
}
|
|
3712
|
+
const data = await readFile(name);
|
|
3713
|
+
return Array.from(data);
|
|
3710
3714
|
}
|
|
3711
3715
|
function printHelp() {
|
|
3712
3716
|
console.log(`\u042D\u043C\u0443\u043B\u044F\u0442\u043E\u0440 \u0420\u0430\u0434\u0438\u043E-86\u0420\u041A (\u0442\u0435\u0440\u043C\u0438\u043D\u0430\u043B)
|
|
@@ -3753,7 +3757,7 @@ async function main() {
|
|
|
3753
3757
|
const loadOnly = args.includes("-p");
|
|
3754
3758
|
const monitorIdx = args.indexOf("-m");
|
|
3755
3759
|
const monitorFile_ = monitorIdx >= 0 ? args[monitorIdx + 1] : undefined;
|
|
3756
|
-
const positional = args.filter((a, i) => !a.startsWith("-") && i !== monitorIdx + 1);
|
|
3760
|
+
const positional = args.filter((a, i) => !a.startsWith("-") && (monitorIdx < 0 || i !== monitorIdx + 1));
|
|
3757
3761
|
const programFile = positional[0];
|
|
3758
3762
|
const keyboard = new Keyboard;
|
|
3759
3763
|
const io = new IO;
|
|
@@ -3770,26 +3774,12 @@ async function main() {
|
|
|
3770
3774
|
machine.tape = new Tape(machine);
|
|
3771
3775
|
machine.runner = new Runner(machine);
|
|
3772
3776
|
machine.memory.update_ruslat = machine.ui.update_ruslat;
|
|
3773
|
-
|
|
3774
|
-
if (monitorFile_) {
|
|
3775
|
-
const content = await fetchFile(monitorFile_);
|
|
3776
|
-
if (!content) {
|
|
3777
|
-
console.error(`\u043C\u043E\u043D\u0438\u0442\u043E\u0440 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D: ${monitorFile_}`);
|
|
3778
|
-
process.exit(1);
|
|
3779
|
-
}
|
|
3780
|
-
monitorContent = content;
|
|
3781
|
-
} else {
|
|
3782
|
-
monitorContent = decodeMon32();
|
|
3783
|
-
}
|
|
3777
|
+
const monitorContent = monitorFile_ ? await fetchFile(monitorFile_) : decodeMon32();
|
|
3784
3778
|
const monitorFile = parse_rk86_binary(monitorFile_ || "mon32.bin", monitorContent);
|
|
3785
3779
|
machine.memory.load_file(monitorFile);
|
|
3786
3780
|
let entryPoint;
|
|
3787
3781
|
if (programFile) {
|
|
3788
3782
|
const content = await fetchFile(programFile);
|
|
3789
|
-
if (!content) {
|
|
3790
|
-
console.error(`\u0444\u0430\u0439\u043B \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D: ${programFile}`);
|
|
3791
|
-
process.exit(1);
|
|
3792
|
-
}
|
|
3793
3783
|
const file = parse_rk86_binary(programFile, content);
|
|
3794
3784
|
machine.memory.load_file(file);
|
|
3795
3785
|
entryPoint = file.entry;
|