From a56e347a88066fa8da5a6f0cd647167d7ac71d86 Mon Sep 17 00:00:00 2001 From: Jeff Parsons Date: Tue, 23 Feb 2016 10:48:22 -0800 Subject: [PATCH] Fixed a couple of new DiskDump bugs --- _developer.yml | 1 + disks/README.md | 4 ++-- disks/pc/README.md | 4 ++-- docs/pcjs/README.md | 22 ++++++++++++---------- modules/diskdump/lib/diskdump.js | 4 ++-- 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/_developer.yml b/_developer.yml index 367fd759b..d2e2ee732 100644 --- a/_developer.yml +++ b/_developer.yml @@ -1,4 +1,5 @@ developer: true +url: "http://localhost:4000" pcjs: compiled: false diff --git a/disks/README.md b/disks/README.md index 28d00a608..129602fe0 100644 --- a/disks/README.md +++ b/disks/README.md @@ -13,10 +13,10 @@ Browse [IBM PC](pc/) and [Challenger 1P](c1p/) disk archives. PCjs works best with disk images in a **JSON** format, to save conversion time, so that's the only disk image format you'll find on the PCjs website. -To convert any of our **JSON** disk images back into an **IMG** file, you can use the DiskDump API +To convert any of our **JSON** disk images back into an **IMG** file, you can use the [DiskDump API](/api/v1/dump) with the *format* parameter set to `img` instead of `json`. For example: - http://localhost:8088/api/v1/dump?disk=/disks/pc/dos/ibm/2.00/PCDOS200-DISK1.json&format=img + {{ site.url }}/api/v1/dump?disk=/disks/pc/dos/ibm/2.00/PCDOS200-DISK1.json&format=img In fact, when browsing the disk archives, the PCjs web server automatically provides "onclick" handlers for links to JSON-encoded disk images, which will invoke the API for you. diff --git a/disks/pc/README.md b/disks/pc/README.md index 336e09154..bad95c864 100644 --- a/disks/pc/README.md +++ b/disks/pc/README.md @@ -211,9 +211,9 @@ or with the "--path" option, which specifies either a single file or a set files node diskdump --path="./apps/pc/1981/visicalc/bin/vc.com;../readme.md" --format=json --output=./apps/pc/1981/visicalc/disk.json -or via the PCjs server's DiskDump API: +or via the PCjs server's [DiskDump API](/api/v1/dump): - http://www.pcjs.org/api/v1/dump?path=/apps/pc/1981/visicalc/bin/vc.com&format=json + {{ site.url }}/api/v1/dump?path=/apps/pc/1981/visicalc/bin/vc.com&format=json Learn more about PCjs disk image formats [here](/disks/). diff --git a/docs/pcjs/README.md b/docs/pcjs/README.md index 099204dc1..890c8ff31 100644 --- a/docs/pcjs/README.md +++ b/docs/pcjs/README.md @@ -158,25 +158,27 @@ All of the examples described above are available for [download](examples/). ### Creating PCjs-Compatible Disk Images -If you have (or find) an IMG disk image file on a server, the PCjs web server provides a **DiskDump API** via endpoint -"/api/v1/dump" that creates PCjs-compatible disks in JSON: +If you have (or find) an IMG disk image file on a server, the PCjs web server provides a +[DiskDump API](/api/v1/dump) via endpoint "/api/v1/dump" that creates PCjs-compatible disks in JSON: - http://localhost:8088/api/v1/dump?disk=(file|url)&format=json + {{ site.url }}/api/v1/dump?disk=(file|url)&format=json -For example, let's say you found a disk image online: +For example, let's say you found a disk image online, such as: http://archive.pcjs.org/disks/pc/dos/ibm/1.00/PCDOS100.img -To convert it to a PCjs-compatible JSON format, use the following command: +To convert it to a PCjs-compatible JSON format, issue the following +[request](/api/v1/dump?disk=http://archive.pcjs.org/disks/pc/dos/ibm/1.00/PCDOS100.img&format=json), +save the resulting JSON file to a folder on your server, and then update your machine XML file(s) to use that file. - http://localhost:8088/api/v1/dump?disk=http://archive.pcjs.org/disks/pc/dos/ibm/1.00/PCDOS100.img&format=json + {{ site.url }}/api/v1/dump?disk=http://archive.pcjs.org/disks/pc/dos/ibm/1.00/PCDOS100.img&format=json -Save the resulting JSON file to a folder on your server, and then update your machine XML file(s) to use that file. -If necessary, you can also reverse the process, converting a JSON disk image back into an IMG file: +If necessary, you can also reverse the process and convert a JSON disk image back into an IMG file, with the +this [request](/api/v1/dump?disk=http://www.pcjs.org/disks/pc/dos/ibm/1.00/PCDOS100.json&format=img): - http://localhost:8088/api/v1/dump?disk=http://www.pcjs.org/disks/pc/dos/ibm/1.00/PCDOS100.json&format=img + {{ site.url }}/api/v1/dump?disk={{ site.url }}/disks/pc/dos/ibm/1.00/PCDOS100.json&format=img -Although PCjs will accept IMG disk image files, it must call the **DiskDump API** to convert the image +Although PCjs will accept IMG disk image files, it must call the [DiskDump API](/api/v1/dump) to convert the image every time it's loaded, so it's *much* faster and more efficient to use pre-converted JSON-encoded disk images. Remember that PC and PC XT machines supported only 160Kb diskettes (on any version of PC-DOS), diff --git a/modules/diskdump/lib/diskdump.js b/modules/diskdump/lib/diskdump.js index 4d44dce0a..fad4c11ec 100644 --- a/modules/diskdump/lib/diskdump.js +++ b/modules/diskdump/lib/diskdump.js @@ -155,7 +155,7 @@ BufferPF.prototype.fill = function(b) if (NODE) { this.buf.fill(b); } else { - for (var off = 0; off < this.ab.length; off++) { + for (var off = 0; off < this.length; off++) { this.dv.setUint8(off, b); } } @@ -175,7 +175,7 @@ BufferPF.prototype.write = function(s, off, len) this.buf.write(s, off, len); } else { var i = 0; - while (off < init.length) { + while (off < this.length) { this.dv.setUint8(off, s.charCodeAt(i++)); off++; }