-
Notifications
You must be signed in to change notification settings - Fork 0
Customising the Filesystem
The virtual filesystem lives in prompt/javascript/fs.js as a JS array called fs. Every directory and every file is an object in that tree. No server, no database — edit the file, hard-refresh, you're done.
var fs = [{
name: 'C',
directories: [ ... ],
files: [ ... ]
}];A node is one of:
| Shape | Means |
|---|---|
{ name, directories, files } |
a directory |
{ name, link } |
a "file" that opens a URL when executed |
{ name, data } |
a "file" whose data is run as a batch script when executed |
hidden: true on a node hides it from dir (still navigable via cd).
{ name: 'GITHUB.COM', link: 'https://github.com/yourname' }Drop it into any directory's files array. The user can cd into the directory and type github.com to open it.
{ name: 'HELLO.BAT',
data: 'echo off\nsetcol 2e\necho Hello, world!\nsetcol 07\necho.' }Lines are separated by \n. Supported batch commands: anything in Commands plus any filename present in the current directory.
{ name: 'MUSIC',
directories: [],
files: [
{ name: 'BANDCAMP.COM', link: 'https://yourname.bandcamp.com' }
]
}The standard pattern for a system with several titles: a directory whose menu.bat prints a box-drawn menu, plus numbered launcher .bat files that each run a named link .bat.
{ name: 'GAMES', directories: [], files: [
{ name: 'menu.bat', data: 'echo off\ncls\necho ╔═══...╗\n...echo.\n' },
{ name: '0.bat', data: 'echo off\ncd ..\ncd ..\nmenu\n' },
{ name: '1.bat', data: 'mario\n' },
{ name: '2.bat', data: 'contra\n' },
{ name: 'mario.bat', link: '../emulators/jsnes/play.html?game=mario' },
{ name: 'contra.bat', link: '../emulators/jsnes/play.html?game=contra' },
] }The menu.bat data string would render rows like ║ 1. Super Mario Bros. (1985) MARIO ║ — title first, year column, code last is the project convention (see Menu box format below).
The user types a number → it runs the matching N.bat → which runs <key> → which resolves to <key>.bat (the link: entry) → which opens the emulator URL.
For a real example see the NES or C64 blocks in fs.js.
Standard menus use double-rule CP437 borders with a 45-char inner width.
╔═════════════════════════════════════════════╗
║ CENTERED HEADER ║ ◄── header (45 chars between ║)
╠─────────────────────────────────────────────╣
║ ║ ◄── blank spacer row
║ 1. Some Title (1985) CMDNAME ║ ◄── 4-column: # Title (Year) CODE
║ 2. Another Title (1986) CMD2 ║
║ ║
║ 11. BASIC system prompt BASIC ║ ◄── BASIC/prompt rows skip the year column
║ ║
║ 0. Back ║ ◄── always last
║ ║
╠─────────────────────────────────────────────╣
║ Type a number and press ENTER ║
╚═════════════════════════════════════════════╝
Entry row layout (45 chars between borders): 4 columns — number, title, year, code. Games sorted by year ascending, alphabetical within year.
║ N. Title field (YYYY) CMDNAME ║
├──┤├──┤├─────────────────┤├──────┤├─┤├──────┤
3 2. 21 chars 6 2 9
spc ". " title (left) year sp code (left)
- Title field 21 chars left-justified; year column 6 chars
(YYYY)or(home)-style marker; 2-char separator; code field 9 chars left-justified. - BASIC / system-prompt rows have no year — title field extends through the year + separator slot.
- Double-digit numbers shift left one space:
NN.vsN.— same 7-char prefix width. - Blank line before the last entry in a group = visual separator (e.g. games vs system prompt).
Notes:
- Apostrophes in titles must be escaped:
K.C.\'s Krazy Chase!inside a'...'JS string. - The on-screen rendering uses CP437 box-drawing glyphs (
É,═,║, etc.) via the font sprite system — the Unicode equivalents shown above are for documentation readability only.
autoexec.bat runs automatically on load. Its default data is just menu\n — which runs the root menu.bat. The root menu.bat in turn does cd emulators\nmenu\n, dropping the user straight into the EMULATOR LAUNCHER (there used to be a redundant single-option intermediate menu — gone since the project now has one launcher entry point).
To boot to a different starting place, override menu.bat (or autoexec.bat):
{ name: 'autoexec.bat', data: 'cd emulators\\console\\nes\\games\ncls\ndir/w/o\n' }To set colours at boot, prepend setcol:
{ name: 'autoexec.bat', data: 'echo off\nsetcol 02\nc:\ncls\nmenu\n' }Common combos:
| Code | bg / fg |
|---|---|
07 |
black / light grey (default) |
0f |
black / white |
17 |
dark blue / light grey |
02 |
black / dark green |
0a |
black / green |
0e |
black / yellow |
See Font System for the 16-colour palette.
- Use absolute paths (
cd\\games\\action) inside.batfiles; relativecdonly works if the target is a direct child. - Files can only be executed from the directory they live in — there is no
PATH. - For menu generation it's much easier to write a small Python helper that emits the
echolines than to hand-craft the box-drawing characters.