mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2025-01-22 21:32:38 +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_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_sym">Download Debug Symbols (.mlb)</a></li>
|
||||
<li><a class="dropdown-item" href="#" id="item_download_sym">Download Debug Symbols</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown dropdown-submenu">
|
||||
|
@ -151,6 +151,7 @@ export interface Platform {
|
||||
sourceFileFetch?: (path:string) => FileData;
|
||||
|
||||
getDownloadFile?() : {extension:string, blob:Blob};
|
||||
getDebugSymbolFile?() : {extension:string, blob:Blob};
|
||||
}
|
||||
|
||||
export interface Preset {
|
||||
|
@ -1142,38 +1142,15 @@ async function _downloadProjectZipFile(e) {
|
||||
}
|
||||
|
||||
function _downloadSymFile(e) {
|
||||
var sym = platform.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.replaceAll('.', '_');
|
||||
text += `${symType}:${addr}:${v}\n`;
|
||||
});
|
||||
|
||||
let symfile = platform.getDebugSymbolFile && platform.getDebugSymbolFile();
|
||||
if (!symfile) {
|
||||
alertError("This project does not have debug information.");
|
||||
return;
|
||||
}
|
||||
var prefix = getFilenamePrefix(getCurrentMainFilename());
|
||||
var blob = new Blob([text], {type:"text/plain;charset=utf-8"});
|
||||
saveAs(blob, prefix + ".mlb", {autoBom:false});
|
||||
|
||||
saveAs(symfile.blob, prefix + symfile.extension, {autoBom:false});
|
||||
}
|
||||
|
||||
|
||||
async function _downloadAllFilesZipFile(e) {
|
||||
var zip = await newJSZip();
|
||||
var keys = await store.keys();
|
||||
|
@ -486,6 +486,37 @@ class JSNESPlatform extends Base6502Platform implements Platform, Probeable {
|
||||
showHelp(tool:string, ident:string) {
|
||||
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
|
||||
@ -522,6 +553,7 @@ class NESMAMEPlatform extends BaseMAME6502Platform implements Platform {
|
||||
getToolForFilename = getToolForFilename_6502;
|
||||
getOpcodeMetadata = getOpcodeMetadata_6502;
|
||||
getDefaultExtension() { return ".c"; };
|
||||
|
||||
}
|
||||
|
||||
///
|
||||
|
Loading…
x
Reference in New Issue
Block a user