Skip to content

Commit

Permalink
Merge branch 'master' into gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffpar committed Aug 24, 2023
2 parents b95364d + 8108e74 commit cef2ac8
Show file tree
Hide file tree
Showing 77 changed files with 192,450 additions and 1,411 deletions.
94 changes: 60 additions & 34 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -466,9 +466,10 @@
"request": "launch",
"program": "${workspaceFolder}/tools/pc/pc.js",
"args": [
"chkdsk c:,quit"
"--sys:pcdos:7",
"--halt"
],
"cwd": "${workspaceFolder}/tools/pc/disks/MSDOS330",
"cwd": "${workspaceFolder}/tools/pc/disks/TEST/SRC/MBR",
"stopOnEntry": false,
"console": "integratedTerminal",
"outFiles": [
Expand Down Expand Up @@ -553,10 +554,11 @@
"program": "${workspaceFolder}/tools/pc/pc.js",
"args": [
"ibm5170",
"MBR",
"dir"
"--disk=MBR.json",
"--nofloppy",
"--halt"
],
"cwd": "${workspaceFolder}/tools/pc/disks/MSDOS330/SRC",
"cwd": "${workspaceFolder}/tools/pc/disks",
"stopOnEntry": false,
"console": "integratedTerminal",
"outFiles": [
Expand Down Expand Up @@ -621,12 +623,34 @@
"request": "launch",
"program": "${workspaceFolder}/tools/pc/pc.js",
"args": [
"disks/MSDOS320",
"--drivetype=3",
"--debug",
"dir"
"--sys=compaq",
"--ver=3.31",
"--drivesize=40"
],
"cwd": "${workspaceFolder}/tools/pc",
"cwd": "${workspaceFolder}/tools/pc/disks/MSDOS330/SRC/MBR",
"stopOnEntry": false,
"console": "integratedTerminal",
"outFiles": [
"${workspaceFolder}/none/**/*.js"
],
"presentation": {
"hidden": false,
"group": "machines",
"order": 15
}
},
{
"name": "pc.js compaq386 MBR331",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/tools/pc/pc.js",
"args": [
"compaq386",
"--disk=MBR331.img",
"--nofloppy",
"--halt"
],
"cwd": "${workspaceFolder}/tools/pc/disks",
"stopOnEntry": false,
"console": "integratedTerminal",
"outFiles": [
Expand Down Expand Up @@ -700,13 +724,13 @@
}
},
{
"name": "pc.js dir --system=compaq --version=3.31",
"name": "pc.js dir --sys=compaq --ver=3.31",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/tools/pc/pc.js",
"args": [
"--system=compaq",
"--version=3.31",
"--sys=compaq",
"--ver=3.31",
"disks/MSDOS320",
"dir"
],
Expand All @@ -723,13 +747,13 @@
}
},
{
"name": "pc.js dir --system=pcdos --version=2.00",
"name": "pc.js dir --sys=pcdos --ver=2.00",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/tools/pc/pc.js",
"args": [
"--system=pcdos",
"--version=2.00",
"--sys=pcdos",
"--ver=2.00",
"disks/MSDOS320",
"dir"
],
Expand All @@ -746,13 +770,13 @@
}
},
{
"name": "pc.js dir --system=pcdos --version=2.00 --drivesize=20mb",
"name": "pc.js dir --sys=pcdos --ver=2.00 --drivesize=20mb",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/tools/pc/pc.js",
"args": [
"--system=pcdos",
"--version=2.00",
"--sys=pcdos",
"--ver=2.00",
"--drivesize=20mb",
"disks/MSDOS320",
"dir"
Expand All @@ -770,13 +794,13 @@
}
},
{
"name": "pc.js dir --system=pcdos --version=3.10",
"name": "pc.js dir --sys=pcdos --ver=3.10",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/tools/pc/pc.js",
"args": [
"--system=pcdos",
"--version=3.10",
"--sys=pcdos",
"--ver=3.10",
"disks/MSDOS320",
"dir"
],
Expand All @@ -793,13 +817,13 @@
}
},
{
"name": "pc.js dir --system=pcdos --version=3.10 --drivesize=20mb",
"name": "pc.js dir --sys=pcdos --ver=3.10 --drivesize=20mb",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/tools/pc/pc.js",
"args": [
"--system=pcdos",
"--version=3.10",
"--sys=pcdos",
"--ver=3.10",
"--drivesize=20mb",
"ibm5170",
"disks/MSDOS320",
Expand Down Expand Up @@ -840,15 +864,15 @@
}
},
{
"name": "pc.js dir --drivetype=80:2:18 --system=compaq --version=3.31",
"name": "pc.js dir --drivetype=80:2:18 --sys=compaq --ver=3.31",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/tools/pc/pc.js",
"args": [
"dir",
"--drivetype=80:2:18",
"--system=compaq",
"--version=3.31"
"--sys=compaq",
"--ver=3.31"
],
"cwd": "${workspaceFolder}/tools/pc/disks/MSDOS330/SRC/MBR",
"stopOnEntry": false,
Expand Down Expand Up @@ -1474,9 +1498,10 @@
"program": "${workspaceFolder}/tools/diskimage/diskimage.js",
"args": [
"MBR/",
"mbr.img",
"MBR.img",
"--drivetype=305:4:17:1024",
"--overwrite",
"--drivetype=40:2:5:1024"
"--partitioned=false"
],
"cwd": "${workspaceFolder}/tools/pc/disks/MSDOS330/SRC",
"stopOnEntry": false,
Expand Down Expand Up @@ -1544,12 +1569,13 @@
"request": "launch",
"program": "${workspaceFolder}/tools/diskimage/diskimage.js",
"args": [
"--dir=DISK0001",
"--dir=MBR/",
"--normalize",
"--output=TEST0001.img",
"--output=MBR.img",
"--target=10M",
"--overwrite"
],
"cwd": "${workspaceFolder}/disks/tmp",
"cwd": "${workspaceFolder}/tools/pc/disks/MSDOS330/SRC",
"stopOnEntry": false,
"console": "integratedTerminal",
"outFiles": [
Expand Down Expand Up @@ -1793,7 +1819,7 @@
"request": "launch",
"program": "${workspaceFolder}/tools/diskimage/diskimage.js",
"args": [
"--collection=miscdisks/pcx86/lang/borland/pascal/6.00/TURBO-PASCAL-600-DISK4",
"--collection=miscdisks/pcx86/app/other/visicalc/1981",
"--checkdisk",
"--rebuild"
],
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
"ARCTEMP",
"arcusq",
"AREG",
"Argh",
"arounds",
"ARPL",
"Arrr",
Expand Down Expand Up @@ -871,6 +872,7 @@
"IOPM",
"IORD",
"ioregs",
"IOSYS",
"IOTABLE",
"ipad",
"IREG",
Expand Down Expand Up @@ -1401,6 +1403,7 @@
"Realia",
"RECAL",
"Recalc",
"Recalcs",
"Recompiles",
"REDIR",
"redirector",
Expand Down
27 changes: 13 additions & 14 deletions blog/_posts/2023/2023-08-10-building-dos-compatible-hard-disks.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,18 @@ Next, let's look at [pc.json](/tools/pc/pc.json), the configuration file for `pc
{
"defaults": {
"type": "pcx86",
"system": "msdos",
"version": "3.30",
"drivesize": "10mb",
"sys": "msdos",
"ver": "3.30",
"size": "10mb",
"maxfiles": 1024,
"directory": ".",
"machine": "compaq386.json",
"state": "state386.json"
},
"apps": {
"cp": {},
"ls": {},
"vi": {},
"edit": {
".edit": {
"exec": "vi $*"
}
},
Expand Down Expand Up @@ -110,9 +109,9 @@ You may have noticed the `defaults` section in the [pc.json](/tools/pc/pc.json)
```
"defaults": {
"type": "pcx86",
"system": "msdos",
"version": "3.30",
"drivesize": "10mb",
"sys": "msdos",
"ver": "3.30",
"size": "10mb",
"maxfiles": 1024,
"directory": ".",
"machine": "compaq386.json",
Expand All @@ -125,27 +124,27 @@ These settings control what happens whenever `pc.js` builds (or rebuilds) a hard
To change those defaults, you can either edit `pc.json` or pass command-line overrides; for example:

$ cd MSDOS330-C400
$ pc.js ibm5170 --drivesize=20 --fat=12 --maxfiles=2048 dir
$ pc.js ibm5170 --size=20 --fat=12 --maxfiles=2048 dir

This changes the default machine from a `compaq386` to an `ibm5170`, sets the drive size to 20Mb, forces the default FAT size to 12-bit (which would otherwise be 16-bit for a 20Mb disk), and allows up to 2048 local files to be included in the disk image.

You can also use `--driveclass` and `--drivetype` for even more control of the virtual hard disk image, but make sure the values you specify are valid for the machine being used. By default, `pc.js` loads a [compaq386](/tools/pc/compaq386.json) machine, which also uses a saved machine state (`state386.json`) that bypasses the system startup tests and floppy drive checks, so that it can start booting from the virtual hard disk immediately. But the COMPAQ DeskPro 386 has a drive type table in ROM that differs significantly from the drive types defined by the IBM PC AT, so if you're using an AT-specific drive type (eg, `--drivetype=6`), then you should also specify an IBM 5170 machine configuration. An [ibm5170.xml](/tools/pc/ibm5170.xml) file is included in the `pc.js` folder to make this easier:
You can also use `--ctrl` and `--type` for even more control of the virtual hard disk image, but make sure the values you specify are valid for the machine being used. By default, `pc.js` loads a [compaq386](/tools/pc/compaq386.json) machine, which also uses a saved machine state (`state386.json`) that bypasses the system startup tests and floppy drive checks, so that it can start booting from the virtual hard disk immediately. But the COMPAQ DeskPro 386 has a drive type table in ROM that differs significantly from the drive types defined by the IBM PC AT, so if you're using an AT-specific drive type (eg, `--type=6`), then you should also specify an IBM 5170 machine configuration. An [ibm5170.xml](/tools/pc/ibm5170.xml) file is included in the `pc.js` folder to make this easier:

$ pc.js ibm5170 --drivetype=6 MSDOS330-C400 dir
$ pc.js ibm5170 --type=6 MSDOS330-C400 dir

### Some Caveats Regarding Disk Formats

With great disk-creating power comes great responsibility -- or at least some basic knowledge of the limitations of various versions of DOS. For example, if you want to build a disk that uses a 16-bit FAT (perhaps because you want a smaller cluster size), then you must *also* build it with PC DOS or MS-DOS 3.0 or higher, since version 2.x only understood disks using a 12-bit FAT.

You can override the `system` and `version` defaults with command-line options `--system` and `--version`; eg:
You can override the `sys` and `ver` defaults with command-line options `--sys` and `--ver`; eg:

$ pc.js --system=pcdos --version=3.00 dir
$ pc.js --sys=pcdos --ver=3.00 dir

Stick with DOS versions 2.x or 3.x for now. Support for other versions hasn't been tested yet.

`pc.js` also tries to detect and fix certain broken combinations. For example, when I first tried to construct a 10Mb disk image with a 16-bit FAT running MS-DOS 3.30:

$ pc.js --drivesize=10 --fat=16 dir
$ pc.js --size=10 --fat=16 dir

it failed to boot for several reasons.

Expand Down
22 changes: 14 additions & 8 deletions machines/arcade/invaders/releases/3.00/invaders-uncompiled.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ const MESSAGE = {
ALL: 0xffffffffffff,
NONE: 0x000000000000,
DEFAULT: 0x000000000000,
HALT: 0x000008000000,
INFO: 0x000010000000,
WARN: 0x000020000000,
ERROR: 0x000040000000,
DEBUG: 0x000080000000,
BUFFER: 0x800000000000,
};

Expand Down Expand Up @@ -2607,6 +2612,12 @@ class WebIO extends StdIO {
format = args.shift();
}
if (this.isMessageOn(messages)) {
if (this.testBits(messages, WebIO.MESSAGE.ERROR)) {
format = "error: " + format;
}
if (this.testBits(messages, WebIO.MESSAGE.WARN)) {
format = "warning: " + format;
}
return super.printf(format, ...args);
}
return 0;
Expand Down Expand Up @@ -3694,11 +3705,6 @@ Device.MESSAGE.INPUT = 0x000000200000;
Device.MESSAGE.KEY = 0x000000400000;
Device.MESSAGE.MOUSE = 0x000000800000;
Device.MESSAGE.TOUCH = 0x000001000000;
Device.MESSAGE.INFO = 0x000002000000;
Device.MESSAGE.WARN = 0x000004000000;
Device.MESSAGE.ERROR = 0x000008000000;
Device.MESSAGE.DEBUG = 0x000010000000;
Device.MESSAGE.HALT = 0x000020000000;
Device.MESSAGE.CUSTOM = 0x000100000000; // all custom device messages must start here

Device.MESSAGE_NAMES["addr"] = Device.MESSAGE.ADDR;
Expand Down Expand Up @@ -3726,10 +3732,10 @@ Device.MESSAGE_NAMES["input"] = Device.MESSAGE.INPUT;
Device.MESSAGE_NAMES["key"] = Device.MESSAGE.KEY;
Device.MESSAGE_NAMES["mouse"] = Device.MESSAGE.MOUSE;
Device.MESSAGE_NAMES["touch"] = Device.MESSAGE.TOUCH;
Device.MESSAGE_NAMES["halt"] = Device.MESSAGE.HALT;
Device.MESSAGE_NAMES["info"] = Device.MESSAGE.INFO;
Device.MESSAGE_NAMES["warn"] = Device.MESSAGE.WARN;
Device.MESSAGE_NAMES["error"] = Device.MESSAGE.ERROR;
Device.MESSAGE_NAMES["halt"] = Device.MESSAGE.HALT;

Device.CLASSES["Device"] = Device;

Expand Down Expand Up @@ -7014,7 +7020,7 @@ class Time extends Device {
* reach 90% of our original target and revert back to the base multiplier.
*/
this.nTargetMultiplier >>= 1;
this.printf(Device.MESSAGE.WARN, "warning: frame time (%5.3fms) exceeded maximum (%5.3fms), target multiplier now %d\n", msFrame, this.msFrameDefault, this.nTargetMultiplier);
this.printf(Device.MESSAGE.WARN, "frame time (%5.3fms) exceeded maximum (%5.3fms), target multiplier now %d\n", msFrame, this.msFrameDefault, this.nTargetMultiplier);
}
/**
* If we (potentially) took too long on this last run, we pass that time back as an adjustment,
Expand Down Expand Up @@ -7509,7 +7515,7 @@ class Time extends Device {
let msDeltaRun = msStartThisRun - this.msStartThisRun - this.msFrameDefault;
if (msDeltaRun > this.msFrameDefault) {
this.msStartRun += msDeltaRun;
this.printf(Device.MESSAGE.WARN, "warning: browser throttling detected, compensating by %5.3fms\n", msDeltaRun);
this.printf(Device.MESSAGE.WARN, "browser throttling detected, compensating by %5.3fms\n", msDeltaRun);
}
}
this.msStartThisRun = msStartThisRun;
Expand Down
Loading

0 comments on commit cef2ac8

Please sign in to comment.