Glitch City Laboratories Archives

Glitch City Laboratories closed on 1 September 2020 (announcement). This is an archived copy of a thread from Glitch City Laboratories Forums.

You can join Glitch City Research Institute to ask questions or discuss current developments.

You may also download the archive of this forum in .tar.gz, .sql.gz, or .sqlite.gz formats.

Programming/Scripting/Development/Web Design

Another Crystal Disassembly? - Page 1

Another Crystal Disassembly?

Posted by: Dandaman955
Date: 2016-07-21 00:51:36
Okay, so this is probably the most pointless thread, and I don't know how to make polls, so with that in mind:

I was looking through the current Pokemon Crystal disassembly by (I think?) pret, and I found a lot of it quite hard to read through. No disrespect to the work that was put through, but it was covered in equates and macros, with a lot of files split into sub-files which made following a lot of it difficult. Now in the Sonic scene, there are people who swear by two different types of disassemblies, often disagreeing on which is the best kind, with:-

- The up-to-date Git kind, where it is all macroed, equated and has code split into separate files, similar to how the Crystal disassembly is now. I think it's trying to be similar to how something like C handles it, with the includes and such?

- The one that isn't. Simple. :p

I personally believe that you can make a disassembly less cluttered by reducing the amount of equates, macros and file splits and replacing them with comments denoting what the instructions do in the grand scheme of things. Here's[1] an example of one disassembly I made (That isn't finished; Some instructions aren't commented and a lot of data isn't split into files yet, mainly the large block of data, from byte_100C to loc_6B48, with a few things otherwise. It should give an idea, though.) on the Action Replay ROM. I was thinking of making a disassembly with a similar structure to this one, but I don't think it's worth the effort if there isn't anyone who would actually find a use in it, so what I'm basically asking here is:

Would you be interested in/use a disassembly like this?

[1] - https://github.com/Dandaman955/Action-Replay-MD-Disasm/blob/master/Action%20Replay%20(Europe).asm

Re: Another Crystal Disassembly?

Posted by: Yeniaul
Date: 2016-07-21 00:57:04
In short? Fuck yes.
This'd be perfect for an upcoming project of mine. (Hint, hint. :D)

Re: Another Crystal Disassembly?

Posted by: Dandaman955
Date: 2016-07-21 01:16:28
Oh, you have to post to make the poll.

Anyways, I guess I can chalk one down for yes!

Re: Another Crystal Disassembly?

Posted by: TheZZAZZGlitch
Date: 2016-07-21 01:17:45
Definitely. A one-file disassembly is a lot easier to search through when you want to analyze a certain subroutine or check for certain behavior.
The current disasms of Pokemon games are formatted like "corporate quality code", which is good for ROM hacking, but not too good for reversing. A similar thing happened to the pokered disassembly. I circumvented the problem by getting an older version of the repository, where everything was still mostly in one file. But this old version has a lot of stuff undocumented, so later I need to search through the current version anyways.

An easy way to get a one-file disasm would be writing a quick script to expand all of the includes. Still, that wouldn't deal with macros and constants (looking through the code, minding my own business… fuck, what address is wWhichPokemon again? *scroll back to the top*)

Re: Another Crystal Disassembly?

Posted by: Stackout
Date: 2016-07-21 03:41:34
I second TheZZAZZGlitch.

Re: Another Crystal Disassembly?

Posted by: ISSOtm
Date: 2016-07-21 06:56:20
It would also be nice if the same happened for Red and Yellow ; but, one thing at a time, so I heavily say [size=18pt]YES[/size] to this one.

Re: Another Crystal Disassembly?

Posted by: Stackout
Date: 2016-07-21 08:24:36
I just realised, compiling the disassembly would produce a symbol or map file, that I know that bgb at least can read to get symbol names (so you can ctrl+g <label> and it'll jump to the address etc).

That could be used instead of having an entirely new disasm.

Re: Another Crystal Disassembly?

Posted by: ISSOtm
Date: 2016-07-21 20:11:38
I tried generating that file, but I didn't have rgbasm on my Debian system. When I tried to compile it, it required a package I didn't have.
That package didn't exist in the official repos, so I looked for an equivalent.
When running make on rbgasm, the equivalent produced seveal screens worth of synatx errors.

I uninstalled all out of discouragement.


If anyone could give me a link to such a .map file, I'd be ready to give them big, big hug. And a truck filled with Mews chocolate / candies / toffees / sweets.

Re: Another Crystal Disassembly?

Posted by: TheZZAZZGlitch
Date: 2016-07-22 01:51:55
I have a SYM file for Red/Blue, since I use it in bgb to get symbols for debugging.
But it doesn't seem to be of much help when creating a one-file disasm, using it by itself wouldn't preserve comments and differences between data and code. But I still included it as an attachment, since it's useful to have.

Instead, I randomly decided to do something stupid:

# coding: utf8
result = b''; counter = 0
with open('out.asm', 'rb') as f:
    for i in f.readlines():
        if i[0:9] == b'INCLUDE "':
            with open(i[9:-3], 'rb') as g: result += g.read()
            counter += 1
        else:
            result += i
with open('out.asm', 'wb') as f: f.write(result)
print("Eradicated includes: %i" % counter)
# run it multiple times to deal with nested includes


And the result looks surprisingly OK. https://aww.moe/u408xw.asm
It still lacks comments with function addresses (this could be done with the SYM file mentioned earlier), and has all the constants and macros (the problem of constants can be fixed by prefixing/suffixing each pointer constant with its effective address; still no idea how to approach the macros, does rgbasm have an command line option to only preprocess macros without compiling?)

Re: Another Crystal Disassembly?

Posted by: Yeniaul
Date: 2016-07-22 09:48:55

I tried generating that file, but I didn't have rgbasm on my Debian system. When I tried to compile it, it required a package I didn't have.
That package didn't exist in the official repos, so I looked for an equivalent.
When running make on rbgasm, the equivalent produced seveal screens worth of synatx errors.

I uninstalled all out of discouragement.


If anyone could give me a link to such a .map file, I'd be ready to give them big, big hug. And a truck filled with Mews chocolate / candies / toffees / sweets.

Search "rgbasm Debian" and find it on a repo. Look and see if any of the dependency names are links. Download those too, and any dependencies for those you don't have. Install the .deb files, starting with the lowest level of dependencies. (If rgbasm is the highest, and its dependencies are the next highest, what's the lowest level?)

This sounds and IS tedious, but try having to do this without ANY packages. You'd have to install EVERYTHING. If I can install GNUTools on Damn Small Linux, you can do the above process.

I hope you can figure out how to install them, considering all the documentation out there.

Re: Another Crystal Disassembly?

Posted by: Bent`
Date: 2016-07-28 02:16:38
Investing a little bit of time in learning how to effectively use tools like git grep and symfiles makes a big difference.