Skip to content

Commit

Permalink
Debugger: Added support for WLA-DX symbol files for SMS
Browse files Browse the repository at this point in the history
+ Added support for WLA-DX's "nocash" symbol output format
  • Loading branch information
SourMesen committed Jan 12, 2024
1 parent 5c2a115 commit e3076c6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
17 changes: 16 additions & 1 deletion UI/Debugger/Integration/WlaDxImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,12 @@ public void Import(string path, bool showResult)
int errorCount = 0;
bool isAsar = false;

//When [labels] tag isn't found, the symbols were output using the "nocash" symbol format (-s vs -S command line option)
bool labelsOnly = !lines.Contains("[labels]");

for(int i = 0; i < lines.Length; i++) {
string str = lines[i].Trim();
if(str == "[labels]") {
if(labelsOnly || str == "[labels]") {
for(; i < lines.Length; i++) {
if(lines[i].Length > 0) {
Match m = _labelRegex.Match(lines[i]);
Expand Down Expand Up @@ -303,3 +306,15 @@ protected override AddressInfo GetLabelAddress(int bank, int addr)
return new AddressInfo() { Address = bank * 0x2000 + (addr & 0x1FFF), Type = MemoryType.PcePrgRom };
}
}

public class SmsWlaDxImporter : WlaDxImporter
{
protected override AddressInfo GetLabelAddress(int bank, int addr)
{
if(addr >= 0xC000) {
return new AddressInfo() { Address = addr - 0xC000, Type = MemoryType.SmsWorkRam };
} else {
return new AddressInfo() { Address = bank * 0x4000 + (addr & 0x3FFF), Type = MemoryType.SmsPrgRom };
}
}
}
3 changes: 2 additions & 1 deletion UI/Debugger/Utilities/DebugWorkspaceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public static void LoadSymFile(string path, bool showResult)
{
if(File.Exists(path) && Path.GetExtension(path).ToLower() == "." + FileDialogHelper.SymFileExt) {
string symContent = File.ReadAllText(path);
if(symContent.Contains("[labels]")) {
if(symContent.Contains("[labels]") || symContent.Contains("this file was created with wlalink")) {
//Assume WLA-DX symbol files
WlaDxImporter? importer = null;
switch(_romInfo.ConsoleType) {
Expand All @@ -110,6 +110,7 @@ public static void LoadSymFile(string path, bool showResult)

case ConsoleType.Gameboy: importer = new GbWlaDxImporter(); break;
case ConsoleType.PcEngine: importer = new PceWlaDxImporter(); break;
case ConsoleType.Sms: importer = new SmsWlaDxImporter(); break;
}

if(importer != null) {
Expand Down

0 comments on commit e3076c6

Please sign in to comment.