Added some more disk configurations
This commit is contained in:
parent
16f91fec4a
commit
b730b915bf
31 changed files with 1002 additions and 963 deletions
|
|
@ -49,7 +49,7 @@ if (NODE) {
|
|||
* 6) writing data to a sector: write()
|
||||
* 7) save disk deltas: save()
|
||||
* 8) restore disk deltas: restore()
|
||||
* 9) converting disk contents: toJSON()
|
||||
* 9) converting disk contents: convertToJSON()
|
||||
*
|
||||
* More functionality may be factored out of the FDC and HDC components later and moved here, to
|
||||
* further reduce some of the duplication between them, but the above functionality is a good start.
|
||||
|
|
@ -2212,10 +2212,11 @@ class Disk extends Component {
|
|||
}
|
||||
|
||||
/**
|
||||
* toJSON()
|
||||
* convertToJSON(fFormatted)
|
||||
*
|
||||
* We perform some RegExp massaging on the JSON data to eliminate unnecessary properties
|
||||
* (eg, 'length' values of 512, 'pattern' values of 0, since those are defaults).
|
||||
* (eg, 'length' values of 512, 'pattern' values of 0, and empty 'data' arrays, since those
|
||||
* are defaults).
|
||||
*
|
||||
* In addition, we first check every sector to see if it can be "deflated". Sectors that were
|
||||
* initially "deflated" should remain that way unless/until they were modified, so technically,
|
||||
|
|
@ -2223,9 +2224,10 @@ class Disk extends Component {
|
|||
* so it doesn't hurt to check every sector.
|
||||
*
|
||||
* @this {Disk}
|
||||
* @param {boolean} [fFormatted]
|
||||
* @return {string} containing the entire disk image as JSON-encoded data
|
||||
*/
|
||||
toJSON()
|
||||
convertToJSON(fFormatted)
|
||||
{
|
||||
var s, pba = 0, sector, sectorLast;
|
||||
|
||||
|
|
@ -2245,9 +2247,9 @@ class Disk extends Component {
|
|||
});
|
||||
|
||||
/*
|
||||
* Eliminate unnecessary default properties (eg, 'length' values of 512, 'pattern' values of 0).
|
||||
* Eliminate unnecessary default properties (eg, 'length' values of 512, 'pattern' values of 0, etc).
|
||||
*/
|
||||
s = s.replace(/,"length":512/gm, "").replace(/,"pattern":0/gm, "");
|
||||
s = s.replace(/,"length":512/g, "").replace(/,"pattern":0/g, "").replace(/,"data":\[]/g, "");
|
||||
|
||||
/*
|
||||
* I don't really want to strip quotes from disk image property names, since I would have to put them
|
||||
|
|
@ -2256,19 +2258,20 @@ class Disk extends Component {
|
|||
* easily be stripped out, by virtue of their being the only quoted properties left. We then "requote"
|
||||
* all the property names that remain.
|
||||
*/
|
||||
s = s.replace(/"(sector|length|data|pattern)":/gm, "$1:");
|
||||
s = s.replace(/"(sector|length|data|pattern)":/g, "$1:");
|
||||
|
||||
/*
|
||||
* The next line will remove any other numeric or boolean properties that were added at runtime, although
|
||||
* they may have completely different ("minified") names if the code has been compiled.
|
||||
*/
|
||||
s = s.replace(/,"[^"]*":([0-9]+|true|false)/gm, "");
|
||||
s = s.replace(/(sector|length|data|pattern):/gm, "\"$1\":");
|
||||
s = s.replace(/,"[^"]*":([0-9]+|true|false)/g, "");
|
||||
s = s.replace(/(sector|length|data|pattern):/g, "\"$1\":");
|
||||
|
||||
/*
|
||||
* Last but not least, insert line breaks after every object definition, to ease the pain on text editors.
|
||||
* Last but not least, insert line breaks after every object definition, to improve human readability
|
||||
* (but only if the caller asks for it).
|
||||
*/
|
||||
s = s.replace(/([\]}]),/gm, "$1,\n");
|
||||
if (fFormatted) s = s.replace(/([\]}]),/g, "$1,\n");
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue