Client-side support for the original DiskDump API is finally limping along

This commit is contained in:
Jeff Parsons 2016-02-22 17:38:57 -08:00
commit 3dd7512f4f
33 changed files with 1334 additions and 1054 deletions

View file

@ -5,18 +5,23 @@ permalink: /api/v1/dump/
scripts: # the following list of scripts should mirror what /modules/diskdump/lib/diskdump.js requires
- /modules/shared/lib/defines.js
- /modules/shared/lib/netlib.js
- /modules/shared/lib/strlib.js
- /modules/shared/lib/weblib.js
- /modules/shared/lib/diskapi.js
- /modules/shared/lib/dumpapi.js
- /modules/shared/lib/component.js
- /modules/pcjs/lib/x86.js
- /modules/diskdump/lib/diskdump.js
---
PCjs DiskDump and FileDump API
===
The PCjs [DiskDump](/modules/diskdump/) and [FileDump](/modules/filedump/) API are not supported by the current
PCjs web server. When **pcjs.org** switched from a Node.js web server running on Amazon Web Services to GitHub Pages,
the server-side API had to be abandoned.
The PCjs [DiskDump](/modules/diskdump/) and [FileDump](/modules/filedump/) API are not fully supported
by the current PCjs web server.
When **pcjs.org** switched from a Node.js web server running on
[Amazon Web Services](https://aws.amazon.com/elasticbeanstalk/) to
[GitHub Pages](https://pages.github.com/), the original server-side API had to be abandoned.
However, we're working on a client-side replacement of the API that will run
entirely in your browser, so hopefully portions of the original API will be available in the near future.

View file

@ -7,8 +7,11 @@ permalink: /api/v1/report/
PCjs Reporting API
===
The PCjs Reporting API is not supported by the current PCjs web server. When **pcjs.org** switched from a Node.js
web server running on Amazon Web Services to GitHub Pages, the server-side API had to be abandoned.
The PCjs Reporting API is not supported by the current PCjs web server.
When **pcjs.org** switched from a Node.js web server running on
[Amazon Web Services](https://aws.amazon.com/elasticbeanstalk/) to
[GitHub Pages](https://pages.github.com/), the original server-side API had to be abandoned.
However, if you're encountering a serious problem with any of the machines on **pcjs.org**, feel free to
[send us a note](mailto:Jeff@pcjs.org) about the problem, along with a link to the machine. Thanks.
[send a note](mailto:Jeff@pcjs.org) about the problem, along with a link to the machine. However, there is
no PCjs Customer Service Department, so we may or may not be able to help.

19
api/v1/user/README.md Normal file
View file

@ -0,0 +1,19 @@
---
layout: page
title: PCjs User API
permalink: /api/v1/user/
---
PCjs User API
===
The PCjs User API is not supported by the current PCjs web server.
When **pcjs.org** switched from a Node.js web server running on
[Amazon Web Services](https://aws.amazon.com/elasticbeanstalk/) to
[GitHub Pages](https://pages.github.com/), the original server-side API had to be abandoned.
Support for PCjs user accounts, including remote disk storage, is still partially supported by the
Node.js server implementation, so if you really want to try it, you'll have to check out the
[Developer Notes](https://github.com/jeffpar/pcjs#user-content-developer-notes) section of the
[PCjs Project](https://github.com/jeffpar/pcjs) for instructions on running your own local copy of Node.js and the
PCjs web server.

View file

@ -5,7 +5,7 @@
<computer id="xt-ega-256k" name="IBM PC XT"/>
<cpu id="cpu8088" model="8088"/>
<ram id="ramLow" addr="0x00000" test="false"/>
<rom id="romEGA" addr="0xc0000" size="0x4000" file="/devices/pc/video/ibm/ega/ibm-ega.json" notify="videoEGA"/>
<rom id="romEGA" addr="0xc0000" size="0x4000" file="/devices/pc/video/ibm/ega/1984-09-13/ibm-ega.json" notify="videoEGA"/>
<rom id="romHDC" addr="0xc8000" size="0x2000" file="/devices/pc/hdc/ibm-xebec-1982.json"/>
<rom id="romBASIC" addr="0xf6000" size="0x8000" file="/devices/pc/rom/5160/basic/BASIC110.json"/>
<rom id="romBIOS" addr="0xfe000" size="0x2000" file="/devices/pc/rom/5160/bios/1982-11-08/XTBIOS-REV1.json"/>

View file

@ -4,7 +4,7 @@
<name pos="center">IBM PC XT, 128K EGA, 640K RAM, 10Mb Hard Drive</name>
<computer id="xt-ega-640k" name="IBM PC XT" state="/devices/pc/machine/5160/ega/640kb/win101/state.json"/>
<ram id="ramLow" addr="0x00000" test="false" size="0xa0000" comment="0xa0000 (640Kb) size overrides SW1|ROM BIOS memory test has been disabled"/>
<rom id="romEGA" addr="0xc0000" size="0x4000" file="/devices/pc/video/ibm/ega/ibm-ega.json" notify="videoEGA"/>
<rom id="romEGA" addr="0xc0000" size="0x4000" file="/devices/pc/video/ibm/ega/1984-09-13/ibm-ega.json" notify="videoEGA"/>
<rom id="romHDC" addr="0xc8000" size="0x2000" file="/devices/pc/hdc/ibm-xebec-1982.json"/>
<rom id="romBASIC" addr="0xf6000" size="0x8000" file="/devices/pc/rom/5160/basic/BASIC110.json"/>
<rom id="romBIOS" addr="0xfe000" size="0x2000" file="/devices/pc/rom/5160/bios/1982-11-08/XTBIOS-REV1.json"/>

View file

@ -5,7 +5,7 @@
<computer id="xt-ega-640k" name="IBM PC XT"/>
<cpu id="cpu8088" model="8088"/>
<ram id="ramLow" addr="0x00000" test="false" size="0xa0000" comment="0xa0000 (640Kb) size overrides SW1|ROM BIOS memory test has been disabled"/>
<rom id="romEGA" addr="0xc0000" size="0x4000" file="/devices/pc/video/ibm/ega/ibm-ega.json" notify="videoEGA"/>
<rom id="romEGA" addr="0xc0000" size="0x4000" file="/devices/pc/video/ibm/ega/1984-09-13/ibm-ega.json" notify="videoEGA"/>
<rom id="romHDC" addr="0xc8000" size="0x2000" file="/devices/pc/hdc/ibm-xebec-1982.json"/>
<rom id="romBASIC" addr="0xf6000" size="0x8000" file="/devices/pc/rom/5160/basic/BASIC110.json"/>
<rom id="romBIOS" addr="0xfe000" size="0x2000" file="/devices/pc/rom/5160/bios/1982-11-08/XTBIOS-REV1.json"/>

View file

@ -5,7 +5,7 @@
<computer id="xt-ega-640k" name="IBM PC XT"/>
<cpu id="cpu8088" model="8088"/>
<ram id="ramLow" addr="0x00000" test="false" size="0xa0000" comment="0xa0000 (640Kb) size overrides SW1|ROM BIOS memory test has been disabled"/>
<rom id="romEGA" addr="0xc0000" size="0x4000" file="/devices/pc/video/ibm/ega/ibm-ega.json" notify="videoEGA"/>
<rom id="romEGA" addr="0xc0000" size="0x4000" file="/devices/pc/video/ibm/ega/1984-09-13/ibm-ega.json" notify="videoEGA"/>
<rom id="romHDC" addr="0xc8000" size="0x2000" file="/devices/pc/hdc/ibm-xebec-1982.json"/>
<rom id="romBASIC" addr="0xf6000" size="0x8000" file="/devices/pc/rom/5160/basic/BASIC110.json"/>
<rom id="romBIOS" addr="0xfe000" size="0x2000" file="/devices/pc/rom/5160/bios/1982-11-08/XTBIOS-REV1.json"/>

View file

@ -5,7 +5,7 @@
<computer id="xt-ega-640k" name="IBM PC XT" state="/devices/pc/machine/5160/ega/640kb/win101/state.json"/>
<cpu id="cpu8088" model="8088"/>
<ram id="ramLow" addr="0x00000" test="false" size="0xa0000" comment="0xa0000 (640Kb) size overrides SW1|ROM BIOS memory test has been disabled"/>
<rom id="romEGA" addr="0xc0000" size="0x4000" file="/devices/pc/video/ibm/ega/ibm-ega.json" notify="videoEGA"/>
<rom id="romEGA" addr="0xc0000" size="0x4000" file="/devices/pc/video/ibm/ega/1984-09-13/ibm-ega.json" notify="videoEGA"/>
<rom id="romHDC" addr="0xc8000" size="0x2000" file="/devices/pc/hdc/ibm-xebec-1982.json"/>
<rom id="romBASIC" addr="0xf6000" size="0x8000" file="/devices/pc/rom/5160/basic/BASIC110.json"/>
<rom id="romBIOS" addr="0xfe000" size="0x2000" file="/devices/pc/rom/5160/bios/1982-11-08/XTBIOS-REV1.json"/>

View file

@ -4,7 +4,7 @@
<name pos="center">IBM PC XT, 128K EGA, 640K RAM, 10Mb Hard Drive</name>
<computer id="xt-ega-640k" name="IBM PC XT" state="/devices/pc/machine/5160/ega/640kb/win101/state.json"/>
<ram id="ramLow" addr="0x00000" test="false" size="0xa0000" comment="0xa0000 (640Kb) size overrides SW1|ROM BIOS memory test has been disabled"/>
<rom id="romEGA" addr="0xc0000" size="0x4000" file="/devices/pc/video/ibm/ega/ibm-ega.json" notify="videoEGA"/>
<rom id="romEGA" addr="0xc0000" size="0x4000" file="/devices/pc/video/ibm/ega/1984-09-13/ibm-ega.json" notify="videoEGA"/>
<rom id="romHDC" addr="0xc8000" size="0x2000" file="/devices/pc/hdc/ibm-xebec-1982.json"/>
<rom id="romBASIC" addr="0xf6000" size="0x8000" file="/devices/pc/rom/5160/basic/BASIC110.json"/>
<rom id="romBIOS" addr="0xfe000" size="0x2000" file="/devices/pc/rom/5160/bios/1982-11-08/XTBIOS-REV1.json"/>

View file

@ -6,7 +6,7 @@
<cpu id="cpu286" model="80286"/>
<ram id="ramLow" addr="0x00000" test="false" size="0xa0000" comment="ROM BIOS memory test has been disabled"/>
<ram id="ramExt" addr="0x100000" size="0x80000" comment=""/>
<rom id="romEGA" addr="0xc0000" size="0x4000" file="/devices/pc/video/ibm/ega/ibm-ega.json" notify="videoEGA"/>
<rom id="romEGA" addr="0xc0000" size="0x4000" file="/devices/pc/video/ibm/ega/1984-09-13/ibm-ega.json" notify="videoEGA"/>
<rom id="romBIOS" addr="0xf0000" size="0x10000" alias="0xff0000" file="/devices/pc/rom/5170/bios/1984-01-10/ATBIOS-REV1.json"/>
<video ref="/devices/pc/video/ibm/ega/ibm-ega-128kb-autolockfs.xml"/>
<keyboard ref="/devices/pc/keyboard/keyboard-minimal-functions.xml"/>

View file

@ -6,7 +6,7 @@
<cpu id="cpu286" model="80286" cycles="8000000"/>
<ram id="ramLow" addr="0x00000" test="true" size="0xa0000" comment="ROM BIOS memory test has been disabled"/>
<ram id="ramExt" addr="0x100000" size="0x80000" comment=""/>
<rom id="romEGA" addr="0xc0000" size="0x4000" file="/devices/pc/video/ibm/ega/ibm-ega.json" notify="videoEGA"/>
<rom id="romEGA" addr="0xc0000" size="0x4000" file="/devices/pc/video/ibm/ega/1984-09-13/ibm-ega.json" notify="videoEGA"/>
<rom id="romBIOS" addr="0xf0000" size="0x10000" alias="0xff0000" file="/devices/pc/rom/5170/bios/1985-11-15/ATBIOS-REV3.json"/>
<video ref="/devices/pc/video/ibm/ega/ibm-ega-128kb-autolockfs.xml"/>
<keyboard ref="/devices/pc/keyboard/keyboard-minimal-functions.xml"/>

View file

@ -6,7 +6,7 @@
<cpu id="cpu286" model="80286" cycles="8000000"/>
<ram id="ramLow" addr="0x00000" test="false" size="0xa0000" comment="ROM BIOS memory test has been disabled"/>
<ram id="ramExt" addr="0x100000" size="0x80000" comment=""/>
<rom id="romEGA" addr="0xc0000" size="0x4000" file="/devices/pc/video/ibm/ega/ibm-ega.json" notify="videoEGA"/>
<rom id="romEGA" addr="0xc0000" size="0x4000" file="/devices/pc/video/ibm/ega/1984-09-13/ibm-ega.json" notify="videoEGA"/>
<rom id="romBIOS" addr="0xf0000" size="0x10000" alias="0xff0000" file="/devices/pc/rom/5170/bios/1985-11-15/ATBIOS-REV3.json"/>
<video ref="/devices/pc/video/ibm/ega/ibm-ega-128kb-autolockfs.xml"/>
<keyboard ref="/devices/pc/keyboard/keyboard-minimal-arrows.xml"/>

View file

@ -5,7 +5,7 @@
<computer id="at-ega-640k" name="IBM PC AT" buswidth="24"/>
<cpu id="cpu286" model="80286"/>
<ram id="ramLow" addr="0x00000" size="0xa0000"/>
<rom id="romEGA" addr="0xc0000" size="0x4000" file="/devices/pc/video/ibm/ega/ibm-ega.json" notify="videoEGA"/>
<rom id="romEGA" addr="0xc0000" size="0x4000" file="/devices/pc/video/ibm/ega/1984-09-13/ibm-ega.json" notify="videoEGA"/>
<rom id="romBIOS" addr="0xf0000" size="0x10000" alias="0xff0000" file="/devices/pc/rom/5170/bios/1984-01-10/ATBIOS-REV1.json"/>
<video ref="/devices/pc/video/ibm/ega/ibm-ega-128kb-autolockfs.xml"/>
<keyboard ref="/devices/pc/keyboard/keyboard-minimal-functions.xml"/>

View file

@ -5,7 +5,7 @@
<computer id="at-ega-640k" name="IBM PC AT" buswidth="24"/>
<cpu id="cpu286" model="80286"/>
<ram id="ramLow" addr="0x00000" size="0xa0000"/>
<rom id="romEGA" addr="0xc0000" size="0x4000" file="/devices/pc/video/ibm/ega/ibm-ega.json" notify="videoEGA"/>
<rom id="romEGA" addr="0xc0000" size="0x4000" file="/devices/pc/video/ibm/ega/1984-09-13/ibm-ega.json" notify="videoEGA"/>
<rom id="romBIOS" addr="0xf0000" size="0x10000" alias="0xff0000" file="/devices/pc/rom/5170/bios/1984-01-10/ATBIOS-REV1.json"/>
<video ref="/devices/pc/video/ibm/ega/ibm-ega-128kb-autolockfs.xml"/>
<keyboard ref="/devices/pc/keyboard/keyboard-minimal.xml"/>

View file

@ -7,7 +7,7 @@
<ram id="ramLow" addr="0x00000" test="false" size="0xa0000" comment="ROM BIOS memory test has been disabled"/>
<ram id="ramCPQ" addr="0xfa0000" size="0x60000" comment="Compaq memory at 0xFA0000"/>
<ram id="ramExt" addr="0x100000" size="0x100000" comment="Extended memory at 0x100000"/>
<rom id="romEGA" addr="0xc0000" size="0x4000" file="/devices/pc/video/ibm/ega/ibm-ega.json" notify="videoEGA"/>
<rom id="romEGA" addr="0xc0000" size="0x4000" file="/devices/pc/video/ibm/ega/1984-09-13/ibm-ega.json" notify="videoEGA"/>
<rom id="romBIOS" addr="0xf8000" size="0x8000" alias="[0xf0000,0xffff0000,0xffff8000]" file="/devices/pc/rom/compaq/bios/deskpro386/1988-01-28/1988-01-28.json"/>
<video ref="/devices/pc/video/ibm/ega/ibm-ega-128kb-autolockfs.xml"/>
<keyboard ref="/devices/pc/keyboard/keyboard-minimal-arrows.xml"/>

View file

@ -7,7 +7,7 @@
<ram id="ramLow" addr="0x00000" test="false" size="0xa0000" comment="ROM BIOS memory test has been disabled"/>
<ram id="ramCPQ" addr="0xfa0000" size="0x60000" comment="Compaq memory at 0xFA0000"/>
<ram id="ramExt" addr="0x100000" size="0x300000" comment="Extended memory at 0x100000"/>
<rom id="romEGA" addr="0xc0000" size="0x4000" file="/devices/pc/video/ibm/ega/ibm-ega.json" notify="videoEGA"/>
<rom id="romEGA" addr="0xc0000" size="0x4000" file="/devices/pc/video/ibm/ega/1984-09-13/ibm-ega.json" notify="videoEGA"/>
<rom id="romBIOS" addr="0xf8000" size="0x8000" alias="[0xf0000,0xffff0000,0xffff8000]" file="/devices/pc/rom/compaq/bios/deskpro386/1988-01-28/1988-01-28.json"/>
<video ref="/devices/pc/video/ibm/ega/ibm-ega-256kb-autolockfs.xml"/>
<keyboard ref="/devices/pc/keyboard/keyboard-minimal-arrows.xml"/>

View file

@ -7,7 +7,7 @@
<ram id="ramLow" addr="0x00000" test="true" size="0xa0000" comment="ROM BIOS memory test has NOT been disabled"/>
<ram id="ramCPQ" addr="0xfa0000" size="0x60000" comment="Compaq memory at 0xFA0000"/>
<ram id="ramExt" addr="0x100000" size="0x100000" comment="Extended memory at 0x100000"/>
<rom id="romVGA" addr="0xc0000" size="0x6000" file="/devices/pc/video/ibm/vga/ibm-vga.json" notify="videoVGA[0x378d,0x3f8d]"/>
<rom id="romVGA" addr="0xc0000" size="0x6000" file="/devices/pc/video/ibm/vga/1986-10-27/ibm-vga.json" notify="videoVGA[0x378d,0x3f8d]"/>
<rom id="romBIOS" addr="0xf8000" size="0x8000" alias="[0xf0000,0xffff0000,0xffff8000]" file="/devices/pc/rom/compaq/bios/deskpro386/1988-01-28/1988-01-28.json"/>
<video ref="/devices/pc/video/ibm/vga/ibm-vga-autolockfs.xml"/>
<keyboard ref="/devices/pc/keyboard/keyboard-minimal-functions.xml"/>

View file

@ -7,7 +7,7 @@
<ram id="ramLow" addr="0x00000" test="false" size="0xa0000" comment="ROM BIOS memory test has been disabled"/>
<ram id="ramCPQ" addr="0xfa0000" size="0x60000" comment="Compaq memory at 0xFA0000"/>
<ram id="ramExt" addr="0x100000" size="0x300000" comment="Extended memory at 0x100000"/>
<rom id="romVGA" addr="0xc0000" size="0x6000" file="/devices/pc/video/ibm/vga/ibm-vga.json" notify="videoVGA[0x378d,0x3f8d]"/>
<rom id="romVGA" addr="0xc0000" size="0x6000" file="/devices/pc/video/ibm/vga/1986-10-27/ibm-vga.json" notify="videoVGA[0x378d,0x3f8d]"/>
<rom id="romBIOS" addr="0xf8000" size="0x8000" alias="[0xf0000,0xffff0000,0xffff8000]" file="/devices/pc/rom/compaq/bios/deskpro386/1988-01-28/1988-01-28.json"/>
<video ref="/devices/pc/video/ibm/vga/ibm-vga-lockfs.xml"/>
<keyboard id="keyboard"/>

View file

@ -19,11 +19,11 @@ Each ROM chip apparently contains 32Kb of data, but only the upper 16Kb of each
and merge them into a single 64Kb file, using the PCjs [FileDump](/modules/filedump/lib/) utility:
filedump --file=VGA_Wonder_V3-1.02_EVEN.BIN --merge=VGA_Wonder_V3-1.02_ODD.BIN --format=rom --output=VGA_Wonder_V3-1.02.rom
filedump --file=1988-11-11/archive/VGA_Wonder_V3-1.02_EVEN.BIN --merge=1988-11-11/archive/VGA_Wonder_V3-1.02_ODD.BIN --format=rom --output=1988-11-11/archive/VGA_Wonder_V3-1.02.rom
Then, within the resulting 64Kb file, we extract the ROM code+data from the upper 32Kb:
filedump --file=VGA_Wonder_V3-1.02.rom --offset=32768 --format=json --output=VGA_Wonder_V3-1.02.json
filedump --file=1988-11-11/archive/VGA_Wonder_V3-1.02.rom --offset=32768 --format=json --output=1988-11-11/VGA_Wonder_V3-1.02.json
And now we have a JSON-encoded ROM image that PCjs machines can load.
@ -31,7 +31,7 @@ And now we have a JSON-encoded ROM image that PCjs machines can load.
To create a human-readable dump, you can use the following command:
filedump --file=VGA_Wonder_V3-1.02.json --format=bytes --comments
filedump --file=1988-11-11/VGA_Wonder_V3-1.02.json --format=bytes --comments
Here are the first 12 lines from that dump:
@ -47,4 +47,3 @@ Here are the first 12 lines from that dump:
0x72,0x20,0x42,0x69,0x6F,0x73,0x2C,0x20,0x56,0x65,0x72,0x73,0x69,0x6F,0x6E,0x20, // 0x00000090 r Bios, Version
0x56,0x33,0x2D,0x31,0x2E,0x30,0x32,0x20,0x0D,0x0A,0x00,0x1E,0x06,0x57,0x56,0x55, // 0x000000A0 V3-1.02 .....WVU
0x52,0x51,0x53,0x50,0xBA,0xE8,0x46,0xB0,0x16,0xEE,0xBA,0x02,0x01,0xB0,0x01,0xEE, // 0x000000B0 RQSP..F.........

View file

@ -1,4 +1,4 @@
;
Aa;
; ROM BIOS for IBM VGA Adapter (aka IBM PS/2 Display Adapter)
; (C)COPYRIGHT IBM Corp. 1984, 1986 10/27/86
;

View file

@ -6,7 +6,7 @@
<cpu id="cpu286" model="80286" cycles="8000000" autostart="true"/>
<ram id="ramLow" addr="0x00000" test="false" size="0xa0000" comment="ROM BIOS memory test has been disabled"/>
<ram id="ramExt" addr="0x100000" size="0x160000" comment=""/>
<rom id="romEGA" addr="0xc0000" size="0x4000" file="/devices/pc/video/ibm/ega/ibm-ega.json" notify="videoEGA"/>
<rom id="romEGA" addr="0xc0000" size="0x4000" file="/devices/pc/video/ibm/ega/1984-09-13/ibm-ega.json" notify="videoEGA"/>
<rom id="romBIOS" addr="0xf0000" size="0x10000" alias="0xff0000" file="/devices/pc/rom/5170/bios/1985-11-15/ATBIOS-REV3.json"/>
<video ref="/devices/pc/video/ibm/ega/ibm-ega-128kb-lockfs.xml"/>
<keyboard ref="/devices/pc/keyboard/keyboard-minimal-arrows.xml"/>

View file

@ -36,7 +36,7 @@
"use strict";
if (NODE) {
if (typeof module != "undefined") { // we can't simply test for NODE, since defines.js hasn't been loaded yet
var fs = require("fs");
var path = require("path");
var http = require("http");
@ -83,6 +83,231 @@ var logFile = null;
*/
var fNormalize = true;
/**
* BufferPF(init, start, end)
*
* BufferPF is our browser polyfill (hence the PF) for Node's Buffer class. It's basically a wrapper object
* containing a real Buffer in Node and a simulated buffer in a browser.
*
* This is NOT a general-purpose polyfill. It supports only those Buffer constructor calls and methods that the
* DiskDump module actually requires.
*
* The constructor supports initialization with: 1) a number specifying the buffer length in bytes, 2) a string,
* 3) an array of byte-sized numbers (aka octets), or 4) another BufferPF, but only when ALSO specifying start and end
* parameters; this final variation is used to support the slice() method.
*
* Finally, under Node, if an API gives us a real Buffer, we need a way to create a BufferPF from it, so that's handled
* as a special NODE case.
*
* @constructor
* @param {number|string|Array|BufferPF|Buffer} [init]
* @param {number} [start]
* @param {number} [end]
*/
function BufferPF(init, start, end)
{
if (NODE) {
if (start === undefined) {
if (typeof init == "object" && init instanceof Buffer) {
this.buf = init;
} else {
this.buf = new Buffer(init);
}
} else {
this.buf = init.buf.slice(start, end);
}
this.length = this.buf.length;
}
else if (typeof init == "number") {
this.ab = new ArrayBuffer(init);
this.dv = new DataView(this.ab, 0, init);
this.length = init;
}
else if (start === undefined) {
var off;
this.ab = new ArrayBuffer(init.length);
this.dv = new DataView(this.ab, 0, init.length);
if (typeof init != "string") {
for (off = 0; off < init.length; off++) {
this.dv.setUint8(off, init[off]);
}
} else {
for (off = 0; off < init.length; off++) {
this.dv.setUint8(off, init.charCodeAt(off));
}
}
this.length = init.length;
} else {
this.ab = init.ab;
if (end === undefined) end = this.ab.length;
this.dv = new DataView(this.ab, start, this.length = end - start);
}
}
/**
* fill(b)
*
* @this {BufferPF}
* @param {number} b
*/
BufferPF.prototype.fill = function(b)
{
if (NODE) {
this.buf.fill(b);
} else {
for (var off = 0; off < this.ab.length; off++) {
this.dv.setUint8(off, b);
}
}
};
/**
* write(s, off, len)
*
* @this {BufferPF}
* @param {string} s
* @param {number} off
* @param {number} len
*/
BufferPF.prototype.write = function(s, off, len)
{
if (NODE) {
this.buf.write(s, off, len);
} else {
var i = 0;
while (off < init.length) {
this.dv.setUint8(off, s.charCodeAt(i++));
off++;
}
}
};
/**
* readUInt8(b)
*
* @this {BufferPF}
* @param {number} off
* @return {number}
*/
BufferPF.prototype.readUInt8 = function(off)
{
return (NODE? this.buf.readUInt8(off) : this.dv.getUint8(off));
};
/**
* writeUInt8(b, off)
*
* @this {BufferPF}
* @param {number} b
* @param {number} off
*/
BufferPF.prototype.writeUInt8 = function(b, off)
{
if (NODE) {
this.buf.writeUInt8(b, off);
} else {
this.dv.setUint8(off, b);
}
};
/**
* readUInt16BE(off)
*
* @this {BufferPF}
* @param {number} off
* @return {number}
*/
BufferPF.prototype.readUInt16BE = function(off)
{
return (NODE? this.buf.readUInt16BE(off) : this.dv.getUint16(off));
};
/**
* readUInt16LE(off)
*
* @this {BufferPF}
* @param {number} off
* @return {number}
*/
BufferPF.prototype.readUInt16LE = function(off)
{
return (NODE? this.buf.readUInt16LE(off) : this.dv.getUint16(off, true));
};
/**
* readUInt32LE(off)
*
* @this {BufferPF}
* @param {number} off
* @return {number}
*/
BufferPF.prototype.readUInt32LE = function(off)
{
return (NODE? this.buf.readUInt32LE(off) : this.dv.getUint32(off, true));
};
/**
* readInt32LE(off)
*
* @this {BufferPF}
* @param {number} off
* @return {number}
*/
BufferPF.prototype.readInt32LE = function(off)
{
return (NODE? this.buf.readInt32LE(off) : this.dv.getInt32(off, true));
};
/**
* writeInt32LE(dw, off)
*
* @this {BufferPF}
* @param {number} dw
* @param {number} off
*/
BufferPF.prototype.writeInt32LE = function(dw, off)
{
if (NODE) {
this.buf.writeInt32LE(dw, off);
} else {
this.dv.setInt32(off, dw, true);
}
};
/**
* copy(bufTarget, offTarget)
*
* @this {BufferPF}
* @param {BufferPF} bufTarget
* @param {number} offTarget
*/
BufferPF.prototype.copy = function(bufTarget, offTarget)
{
if (NODE) {
this.buf.copy(bufTarget.buf, offTarget);
} else {
var offMax = this.length;
var cbMax = bufTarget.length - offTarget;
if (offMax > cbMax) offMax = cbMax;
for (var off = 0; off < offMax; off++) {
bufTarget.writeUInt8(this.readUInt8(off), offTarget + off);
}
}
};
/**
* slice(start, end)
*
* @this {BufferPF}
* @param {number} [start]
* @param {number} [end]
* @return {BufferPF}
*/
BufferPF.prototype.slice = function(start, end)
{
return new BufferPF(this, start || 0, end);
};
/**
* DiskDump()
*
@ -738,7 +963,8 @@ DiskDump.logError = function(err)
{
var sError = "";
if (err) {
sError = "diskdump error: " + err.message;
sError = "DiskDump error: " + err.message;
if (!NODE) web.alertUser(sError);
DiskDump.logConsole(sError);
}
return sError;
@ -787,6 +1013,7 @@ DiskDump.getStat = function(sPath, done)
*/
DiskDump.readFile = function(sPath, sEncoding, done)
{
if (NODE) {
if (net.isRemote(sPath)) {
/*
* Just a quick verification that the getStat() function works...
@ -807,6 +1034,20 @@ DiskDump.readFile = function(sPath, sEncoding, done)
done(err, buf);
});
}
} else {
/*
* This is the browser code path (ie, you've loaded diskdump.js in your browser rather than in Node)
*/
web.getResource(sPath, "bytes", true, function doneReadFileBrowser(sURL, sResource, nErrorCode) {
var buf = sResource;
if (!nErrorCode) {
if (str.endsWith(sURL, ".img")) {
buf = new BufferPF(sResource);
}
}
done(nErrorCode? new Error(sURL + " (" + nErrorCode + ")") : null, buf);
});
}
};
/*
@ -1166,7 +1407,7 @@ DiskDump.prototype.validateTime = function(dateTime)
* @this {DiskDump}
* @param {number} cb
* @param {Array.<number>} [abInit]
* @return {Array.<number>} of bytes zero-initialized
* @return {Array.<number>} of bytes, initialized with abInit (or with zero when abInit is empty or exhausted)
*/
DiskDump.prototype.buildData = function(cb, abInit)
{
@ -1187,7 +1428,7 @@ DiskDump.prototype.buildData = function(cb, abInit)
*/
DiskDump.prototype.copyData = function(offDisk, ab)
{
var buf = new Buffer(ab);
var buf = new BufferPF(ab);
buf.copy(this.bufDisk, offDisk);
return ab.length;
};
@ -1793,14 +2034,14 @@ DiskDump.prototype.buildClusters = function(aFiles, offDisk, cbCluster, iParentC
}(aFiles[iFile], cbData, offDisk)); // jshint ignore:line
} else {
cbData = sData.length;
bufData = new Buffer(sData);
bufData = new BufferPF(sData);
if (this.sManifestFile) aFiles[iFile].FILE_MD5 = crypto.createHash('md5').update(bufData).digest('hex');
}
}
else if (cbData < 0) {
var abData = [];
cbData = this.buildDir(abData, aFiles[iFile].FILE_DATA, aFiles[iFile].FILE_TIME, aFiles[iFile].FILE_CLUS, iParentCluster) * 32;
bufData = new Buffer(this.buildData(cbData, abData));
bufData = new BufferPF(this.buildData(cbData, abData));
cSubDirs++;
}
if (bufData) {
@ -2049,7 +2290,7 @@ DiskDump.prototype.buildImageFromFiles = function(aFiles, done)
* functions that prefer not passing around temporary buffers. In the meantime, perhaps any catastrophic
* failures should set bufDisk back to null?
*/
this.bufDisk = new Buffer(cbDisk);
this.bufDisk = new BufferPF(cbDisk);
/*
* WARNING: Buffers are NOT zero-initialized, so we need explicitly fill bufDisk with zeros (this seems
@ -2707,7 +2948,7 @@ DiskDump.prototype.convertToIMG = function()
var cbDisk = nCylinders * nHeads * nSectorsPerTrack * 512;
var off = 0;
buf = new Buffer(cbDisk);
buf = new BufferPF(cbDisk);
/*
* WARNING: Buffers are NOT zero-initialized, so we need explicitly fill it with zeros (this seems to

View file

@ -199,7 +199,7 @@ FileDump.logError = function(err)
{
var sError = "";
if (err) {
sError = "filedump error: " + err.message;
sError = "FileDump error: " + err.message;
console.log(sError);
}
return sError;

View file

@ -290,12 +290,14 @@ Component.log = function(s, type)
{
if (DEBUG) {
if (s) {
var msElapsed, sMsg = (type? (type + ": ") : "") + s;
var sElapsed = "", sMsg = (type? (type + ": ") : "") + s;
if (typeof usr != "undefined") {
if (Component.msStart === undefined) {
Component.msStart = usr.getTime();
}
msElapsed = usr.getTime() - Component.msStart;
if (window && window.console) console.log(msElapsed + "ms: " + sMsg.replace(/\n/g, " "));
sElapsed = (usr.getTime() - Component.msStart) + "ms: ";
}
if (window && window.console) console.log(sElapsed + sMsg.replace(/\n/g, " "));
}
}
};
@ -749,6 +751,7 @@ Component.prototype = {
*
* TODO: Add a task to the build process that "asserts" there are no instances of "assertion failure" in RELEASE builds.
*
* @this {Component}
* @param {boolean} f is the expression we are asserting to be true
* @param {string} [s] is description of the assertion on failure
*/

View file

@ -175,8 +175,16 @@ web.notice = function(s, fPrintOnly, id)
*
* Request the specified resource (sURL), and once the request is complete, notify done().
*
* Also, if dataPost is set to a string, that string can be used to control the response format;
* by default, the response format is plain text, but you can specify "bytes" to request arbitrary
* binary data, which should come back as a string of bytes.
*
* TODO: The "bytes" option works by calling overrideMimeType(), which was never a best practice.
* Instead, we should implement supported response types ("text" and "arraybuffer", at a minimum)
* by setting xmlHTTP.responseType to one of those values before calling xmlHTTP.send().
*
* @param {string} sURL
* @param {Object|null} [dataPost] for a POST request (default is a GET request)
* @param {string|Object|null} [dataPost] for a POST request (default is a GET request)
* @param {boolean} [fAsync] is true for an asynchronous request
* @param {function(string,string,number)} [done]
* @return {Array|null} Array containing [sResource, nErrorCode], or null if no response yet
@ -231,7 +239,7 @@ web.getResource = function(sURL, dataPost, fAsync, done)
};
}
if (dataPost) {
if (typeof dataPost == "object") {
var sDataPost = "";
for (var p in dataPost) {
if (!dataPost.hasOwnProperty(p)) continue;
@ -246,6 +254,9 @@ web.getResource = function(sURL, dataPost, fAsync, done)
} else {
if (MAXDEBUG) web.log("web.getResource(GET " + sURL + ")");
xmlHTTP.open("GET", sURL, !!fAsync); // ensure that fAsync is a valid boolean (Internet Explorer xmlHTTP functions insist on it)
if (dataPost == "bytes") {
xmlHTTP.overrideMimeType("text/plain; charset=x-user-defined");
}
xmlHTTP.send();
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long