mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-09-27 08:54:48 +00:00
nes: download Mesen symbol file (contrib from NotExactlySiev)
This commit is contained in:
parent
d511034428
commit
a173597bda
@ -89,7 +89,7 @@ if (window.location.host.endsWith('8bitworkshop.com')) {
|
|||||||
<li><a class="dropdown-item" href="#" id="item_download_rom">Download ROM Image</a></li>
|
<li><a class="dropdown-item" href="#" id="item_download_rom">Download ROM Image</a></li>
|
||||||
<li><a class="dropdown-item" href="#" id="item_download_zip">Download Project as ZIP</a></li>
|
<li><a class="dropdown-item" href="#" id="item_download_zip">Download Project as ZIP</a></li>
|
||||||
<li><a class="dropdown-item" href="#" id="item_download_allzip">Download All Changes as ZIP</a></li>
|
<li><a class="dropdown-item" href="#" id="item_download_allzip">Download All Changes as ZIP</a></li>
|
||||||
<li><a class="dropdown-item" href="#" id="item_download_sym">Download Debug Symbols (.mlb)</a></li>
|
<li><a class="dropdown-item" href="#" id="item_download_sym">Download Debug Symbols</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li class="dropdown dropdown-submenu">
|
<li class="dropdown dropdown-submenu">
|
||||||
|
@ -151,6 +151,7 @@ export interface Platform {
|
|||||||
sourceFileFetch?: (path:string) => FileData;
|
sourceFileFetch?: (path:string) => FileData;
|
||||||
|
|
||||||
getDownloadFile?() : {extension:string, blob:Blob};
|
getDownloadFile?() : {extension:string, blob:Blob};
|
||||||
|
getDebugSymbolFile?() : {extension:string, blob:Blob};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Preset {
|
export interface Preset {
|
||||||
|
@ -1142,38 +1142,15 @@ async function _downloadProjectZipFile(e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _downloadSymFile(e) {
|
function _downloadSymFile(e) {
|
||||||
var sym = platform.debugSymbols.addr2symbol;
|
let symfile = platform.getDebugSymbolFile && platform.getDebugSymbolFile();
|
||||||
var text = "";
|
if (!symfile) {
|
||||||
$.each(sym, function(k, v) {
|
alertError("This project does not have debug information.");
|
||||||
let symType;
|
return;
|
||||||
if (k < 0x2000) {
|
}
|
||||||
k = k % 0x800;
|
|
||||||
symType = "R";
|
|
||||||
} else if (k < 0x6000) symType = "G";
|
|
||||||
else if (k < 0x8000) {
|
|
||||||
k = k - 0x6000;
|
|
||||||
symType = "S";
|
|
||||||
} else {
|
|
||||||
k = k - 0x8000;
|
|
||||||
symType = "P";
|
|
||||||
}
|
|
||||||
let addr = Number(k).toString(16).padStart(4, '0').toUpperCase();
|
|
||||||
// Mesen doesn't allow lables to start with digits
|
|
||||||
if (v[0] >= '0' && v[0] <= '9') {
|
|
||||||
v = "L" + v;
|
|
||||||
}
|
|
||||||
// nor does it allow dots
|
|
||||||
v = v.replaceAll('.', '_');
|
|
||||||
text += `${symType}:${addr}:${v}\n`;
|
|
||||||
});
|
|
||||||
|
|
||||||
var prefix = getFilenamePrefix(getCurrentMainFilename());
|
var prefix = getFilenamePrefix(getCurrentMainFilename());
|
||||||
var blob = new Blob([text], {type:"text/plain;charset=utf-8"});
|
saveAs(symfile.blob, prefix + symfile.extension, {autoBom:false});
|
||||||
saveAs(blob, prefix + ".mlb", {autoBom:false});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async function _downloadAllFilesZipFile(e) {
|
async function _downloadAllFilesZipFile(e) {
|
||||||
var zip = await newJSZip();
|
var zip = await newJSZip();
|
||||||
var keys = await store.keys();
|
var keys = await store.keys();
|
||||||
|
@ -486,6 +486,37 @@ class JSNESPlatform extends Base6502Platform implements Platform, Probeable {
|
|||||||
showHelp(tool:string, ident:string) {
|
showHelp(tool:string, ident:string) {
|
||||||
window.open("https://8bitworkshop.com/docs/platforms/nes/", "_help"); // TODO
|
window.open("https://8bitworkshop.com/docs/platforms/nes/", "_help"); // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getDebugSymbolFile() {
|
||||||
|
var sym = this.debugSymbols.addr2symbol;
|
||||||
|
var text = "";
|
||||||
|
$.each(sym, function(k, v) {
|
||||||
|
let symType;
|
||||||
|
if (k < 0x2000) {
|
||||||
|
k = k % 0x800;
|
||||||
|
symType = "R";
|
||||||
|
} else if (k < 0x6000) symType = "G";
|
||||||
|
else if (k < 0x8000) {
|
||||||
|
k = k - 0x6000;
|
||||||
|
symType = "S";
|
||||||
|
} else {
|
||||||
|
k = k - 0x8000;
|
||||||
|
symType = "P";
|
||||||
|
}
|
||||||
|
let addr = Number(k).toString(16).padStart(4, '0').toUpperCase();
|
||||||
|
// Mesen doesn't allow lables to start with digits
|
||||||
|
if (v[0] >= '0' && v[0] <= '9') {
|
||||||
|
v = "L" + v;
|
||||||
|
}
|
||||||
|
// nor does it allow dots
|
||||||
|
v = (v as any).replaceAll('.', '_');
|
||||||
|
text += `${symType}:${addr}:${v}\n`;
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
extension:".mlb",
|
||||||
|
blob: new Blob([text], {type:"text/plain"})
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// MAME support
|
/// MAME support
|
||||||
@ -522,6 +553,7 @@ class NESMAMEPlatform extends BaseMAME6502Platform implements Platform {
|
|||||||
getToolForFilename = getToolForFilename_6502;
|
getToolForFilename = getToolForFilename_6502;
|
||||||
getOpcodeMetadata = getOpcodeMetadata_6502;
|
getOpcodeMetadata = getOpcodeMetadata_6502;
|
||||||
getDefaultExtension() { return ".c"; };
|
getDefaultExtension() { return ".c"; };
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user