diff --git a/src/ide/ui.ts b/src/ide/ui.ts index d2a78d59..12b403fa 100644 --- a/src/ide/ui.ts +++ b/src/ide/ui.ts @@ -1141,6 +1141,39 @@ 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`; + }); + + var prefix = getFilenamePrefix(getCurrentMainFilename()); + var blob = new Blob([text], {type:"text/plain;charset=utf-8"}); + saveAs(blob, prefix + ".mlb", {autoBom:false}); + +} + + async function _downloadAllFilesZipFile(e) { var zip = await newJSZip(); var keys = await store.keys(); @@ -1907,6 +1940,7 @@ function setupDebugControls() { $("#item_download_rom").click(_downloadROMImage); $("#item_download_file").click(_downloadSourceFile); $("#item_download_zip").click(_downloadProjectZipFile); + $("#item_download_sym").click(_downloadSymFile); $("#item_download_allzip").click(_downloadAllFilesZipFile); $("#item_record_video").click(_recordVideo); if (platform_id.startsWith('apple2') || platform_id.startsWith('vcs')) // TODO: look for function