Jump to content

Photo

convert ca65 -> stella/dasm symbol file


4 replies to this topic

#1 gauauu ONLINE  

gauauu

    Moonsweeper

  • 390 posts
  • Location:Illinois

Posted Mon May 14, 2018 7:57 AM

Has anybody written a converter to generate DASM/Stella compatible symbol files from the debug map output of ca65? 

 

I'm planning to write one later today, should be relatively straightforward, but thought I'd ask and see if anyone's already done so before I waste time reinventing things.

 

(Although it's so simple, I guess I probably could have written one in the amount of time I spent googling, searching, and then asking this question. Ah well, the work we go through to avoid work....)

 

 



#2 stephena OFFLINE  

stephena

    River Patroller

  • 3,257 posts
  • Stella maintainer
  • Location:Newfoundland, Canada

Posted Mon May 14, 2018 10:23 AM

There has been talk over the years about revamping the disassembly support in Stella, and making more direct use of the files that DASM produces (lst, sym, etc).  And to that end, also adding support for ca65 directly.

 

We haven't yet found the time to work on any of this, but I keep it on the TODO list, and in the back of my mind, since I want to come back to it at some point.  That being said, if you do get a converter written and don't mind releasing it under GPLv2, please consider donating it.  We may make use of it in Stella at some point.



#3 gauauu ONLINE  

gauauu

    Moonsweeper

  • Topic Starter
  • 390 posts
  • Location:Illinois

Posted Mon May 14, 2018 2:07 PM

We haven't yet found the time to work on any of this, but I keep it on the TODO list, and in the back of my mind, since I want to come back to it at some point.  That being said, if you do get a converter written and don't mind releasing it under GPLv2, please consider donating it.  We may make use of it in Stella at some point.

 

I'd be happy to donate it.  Are there other considerations (language/features/etc?) that would be important to you? I was originally going to the write the simplest thing possible in python, but if there's value in making something more general or robust, I'm happy to spend a little more time.

 

Alternatively, I'm willing to at least look at the Stella code that reads the list/symbol file, and see how hard it would be to bake in support for ca65 files. But I'm not sure that's worth the effort if you're planning to completely revamp how that all works? 



#4 stephena OFFLINE  

stephena

    River Patroller

  • 3,257 posts
  • Stella maintainer
  • Location:Newfoundland, Canada

Posted Wed May 16, 2018 4:58 AM

We are planning to add this to Stella at some point, but it may not even be this year.  So don't feel you have to wait.  Go ahead and write this in whatever language you were going to use.  We can still use your ideas/research, even if we don't use the actual code (most of the time, the research is the most important part anyway).



#5 gauauu ONLINE  

gauauu

    Moonsweeper

  • Topic Starter
  • 390 posts
  • Location:Illinois

Posted Wed May 16, 2018 8:30 AM

Here's my first pass, which is a super-simple python script that converts ca65 list files to dasm sym format. It could almost be done as just a sed regex instead, but anyway, here you go. You mentioned licenses, so I grant anyone a license to use this under any OSI-approved license of your choosing :-)
 

Usage -- link with the -L flag, then call debugMap.py

ld65 -L $(CC65_PATH)/share/cc65/lib -m map.txt -Ln labels.txt --dbgfile $(title).dbg -C foo.cfg blah blah blah
python debugMap.py labels.txt mygame.sym

 
 
 
debugMap.py:

#!/usr/bin/python3
import sys

def convert_maps(labels_filename, sym_filename):
    labels_file = open(labels_filename, "r")
    label_lines = labels_file.readlines()

    labels = {}
    
    for line in label_lines:
        parts = line.split()
        label = parts[2][1:]
        addr = parts[1][2:].lower()
        labels[label] = addr


    sym_file = open(sym_filename, "w")
    for label, addr in labels.items():
        sym_file.write(label + "        " + addr + "        (R )\n")


if __name__ == "__main__":
    convert_maps(sys.argv[1], sys.argv[2])

I might also take a look modifying stella directly to read them, but we'll see. It depends on how motivated I feel.






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users