This repo plays with the idea of parsing DM src code and converting it into different formats If I don't give up on this or can pull this off, I want to transpile DM to a different language.
After taking a look at what Somnium13 did, I believe that it may be a better idea to lex and parse DM code instead of converting generated byte code. I will also be relying on a hinting system. In some areas of the DM code, there will be comments that pass extra information to the new DM compiler.
https://github.com/Somnium13/SS13
in the somnium13_src folder is the source code for Somnium13 transpiler, that takes DM bytecode and turns it into C# I got this by emailing the author & he still had the source code from 2016!
For more information on the tools in somnium13_src, here is an email I got from him that contains useful info.
Okay, sorry for the delay. I've found it. I was worried I might have lost it. I'm attaching a document that explains BYOND's bytecode, which I found after I had reverse engineered it myself. I think I got from Tobba's github, but I honestly can't remember for sure. In any case it should be a better reference than my awful code.
As for the decompiler itself, I'll try to explain its workings so you're not totally lost in a pile of shitcode:
It's designed to target version 509. I have no idea what's changed since that version.
There are a number of different components, most of which dump intermediate information so I wouldn't have to run the entire pipeline each time I wanted to test a change.
somstruct.js is the entry point, and it drives everything else. It's also the back-end code generator, and is responsible for spitting out the C# files after all the other stages run.
somdump.cpp compiles to an executable that decrypts the dmb and dumps its data structures in JSON format.
rscdump.cpp opens the resource file and builds an index mapping resource IDs back to their corresponding file names.
sompipe.js is probably what you'd be most interested in. It converts the byte arrays from the JSON dump into somewhat human readable, but still pretty disgusting JSON pseudo-assembly code.
somname.js is a fairly straightforward module that's used to rename classes/methods/variables. It also contains the meat of the type inference methods. Type inference never worked well, which led to a lot of disgusting generated code and abuse of the "dynamic" keyword. I'd suggest trying to figure types out better than I did, especially if you're compiling to native code. There's a chance that I'm incredibly dumb and the DMB includes more type information than I thought.
somdecomp.js is the mess that's responsible for trying to map DM semantics onto C#. It converts the pseudo-assembly to a C# AST. I doubt this part is worth trying to salvage for anything.
som.map.html is a really rudimentary map viewer, which I think I made just to make sure I was decoding the maps correctly.
Feel free to reuse/open source anything you want, but I suspect you'll probably want to rewrite most of it.
I did find this project when I was trying to figure out where I got the DMB info. Is this what you're working on, or something unrelated? In any case, what you're doing is the kind of project I'd love to help out with if I had the time, but I'm already pretty busy. I'm probably going to put my efforts toward SS3D if I do anything SS13 related. Wishing you the best of luck though, and I'm excited to hear what you come up with.