Updated C1Pjs to use the FileDump API properly
This commit is contained in:
parent
866610f3df
commit
0ea5520444
3 changed files with 19 additions and 22 deletions
|
|
@ -1023,4 +1023,4 @@
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,70]
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,70]
|
||||||
,"symbols":{"VIDEO_SETUP":{"o":3},"POR_1":{"o":146},"RD_SWS":{"o":155},"F_BTS":{"o":206},"MK_ENV":{"o":243},"ENV_X":{"o":328,"c":"SET 40x25 COLOR ALPHA"}}}
|
,"symbols":{"VIDEO_SETUP":{"o":3},"POR_1":{"o":146},"RD_SWS":{"o":155},"F_BTS":{"o":206},"MK_ENV":{"o":243},"ENV_X":{"o":328,"c":"SET 40x25 COLOR ALPHA"}}}
|
||||||
|
|
@ -63,15 +63,8 @@ function C1PROM(parmsROM)
|
||||||
* in compact form (ie, minimal whitespace, no ASCII data comments, etc).
|
* in compact form (ie, minimal whitespace, no ASCII data comments, etc).
|
||||||
*/
|
*/
|
||||||
var sFileExt = str.getExtension(this.sImage);
|
var sFileExt = str.getExtension(this.sImage);
|
||||||
if (sFileExt != "json" && sFileExt != "hex") {
|
if (sFileExt != DumpAPI.FORMAT.JSON && sFileExt != DumpAPI.FORMAT.HEX) {
|
||||||
/**
|
sFileURL = web.getHost() + DumpAPI.ENDPOINT + '?' + DumpAPI.QUERY.FILE + '=' + this.sImage + '&' + DumpAPI.QUERY.FORMAT + '=' + DumpAPI.FORMAT.BYTES;
|
||||||
* TODO: This code was using a deprecated parameter (compact=1); make sure things still work.
|
|
||||||
*
|
|
||||||
* TODO: Convert this code to use the new shared File API definitions and weblib functions; eg:
|
|
||||||
*
|
|
||||||
* sFileURL = web.getHost() + DumpAPI.ENDPOINT + "?" + DumpAPI.QUERY.FILE + "=" + this.sImage;
|
|
||||||
*/
|
|
||||||
sFileURL = "http://" + window.location.host + "/api/v1/dump?file=" + this.sImage;
|
|
||||||
}
|
}
|
||||||
web.loadResource(sFileURL, true, null, this, this.convertImage);
|
web.loadResource(sFileURL, true, null, this, this.convertImage);
|
||||||
}
|
}
|
||||||
|
|
@ -156,13 +149,18 @@ C1PROM.prototype.convertImage = function(sImageName, sImageData, nErrorCode)
|
||||||
this.println("Error loading ROM \"" + sImageName + "\" (" + nErrorCode + ")");
|
this.println("Error loading ROM \"" + sImageName + "\" (" + nErrorCode + ")");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (sImageData[0] == "[") {
|
if (sImageData.charAt(0) == "[" || sImageData.charAt(0) == "{") {
|
||||||
try {
|
try {
|
||||||
/*
|
/*
|
||||||
* The most likely source of any exception will be right here, where we're parsing
|
* The most likely source of any exception will be here: parsing the JSON-encoded ROM data.
|
||||||
* the JSON-encoded ROM data.
|
|
||||||
*/
|
*/
|
||||||
this.abImage = eval("(" + sImageData + ")");
|
var rom = eval("(" + sImageData + ")");
|
||||||
|
var ab = rom['bytes'];
|
||||||
|
if (ab) {
|
||||||
|
this.abImage = ab;
|
||||||
|
} else {
|
||||||
|
this.abImage = rom;
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.println("Error processing ROM \"" + sImageName + "\": " + e.message);
|
this.println("Error processing ROM \"" + sImageName + "\": " + e.message);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -399,12 +399,14 @@ FileDump.prototype.dumpBuffer = function(sKey, buf, len, cbItem, offData)
|
||||||
FileDump.prototype.loadMap = function(sFilePath, done)
|
FileDump.prototype.loadMap = function(sFilePath, done)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* The BYTES and HEX formats don't support MAP files, because the clients expect those format requests
|
* The HEX format doesn't support MAP files, because old HEX clients expect an Array of bytes,
|
||||||
* to return an Array of bytes, not an Object. For all other (JSON) formats, we assume that the JSON
|
* not an Object. For all other (JSON) formats, we assume that the JSON is "unwrapped" at this point,
|
||||||
* is "unwrapped" at this point, and that even if loadMap() doesn't find a map file, it will still wrap
|
* and so even if loadMap() doesn't find a map file, it will still wrap the resulting JSON with braces.
|
||||||
* the resulting JSON with braces.
|
|
||||||
*/
|
*/
|
||||||
if (this.sFormat != DumpAPI.FORMAT.BYTES && this.sFormat != DumpAPI.FORMAT.HEX) {
|
if (this.sFormat != DumpAPI.FORMAT.HEX) {
|
||||||
|
if (!this.sKey) {
|
||||||
|
this.json = '"bytes":' + this.json;
|
||||||
|
}
|
||||||
var obj = this;
|
var obj = this;
|
||||||
var sMapPath = sFilePath.replace(/\.(rom|json)$/, ".map");
|
var sMapPath = sFilePath.replace(/\.(rom|json)$/, ".map");
|
||||||
if (str.endsWith(sMapPath, ".map")) {
|
if (str.endsWith(sMapPath, ".map")) {
|
||||||
|
|
@ -551,9 +553,6 @@ FileDump.prototype.loadMap = function(sFilePath, done)
|
||||||
}
|
}
|
||||||
sMapData = JSON.stringify(aSymbols);
|
sMapData = JSON.stringify(aSymbols);
|
||||||
if (sMapData) {
|
if (sMapData) {
|
||||||
if (!obj.sKey) {
|
|
||||||
obj.json = '"bytes":' + obj.json;
|
|
||||||
}
|
|
||||||
obj.json = '{' + obj.json + ',"symbols":' + sMapData + '}';
|
obj.json = '{' + obj.json + ',"symbols":' + sMapData + '}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue