N64 assembly editor
Users browsing this thread: 1 Guest(s)

Hi guys. I've been working on this assembly editor for n64. My aim with this one was to have an easy interface. As in easy, I mean as to eliminate the small repetitive tasks (such as navigating the assembly, calculating addresses or moving/NOPing a section of assembly).

I don't think it's finished yet as I am slowly finding small updates to add, but it is currently usable. Any feedback for bugs or features it should have is welcome!

It's current features are:
  • ​Game offset mode: Jumps/branches/addresses and navigation will be treated with the appropriate memory region offset
  • ​Memory region calculation: Main and Boot regions automatically calculated and supports additional memory regions
  • ​Hex/Binary mode
  • ​Assembly search engine: Search particular phrases to locate some code
  • ​Highlighting for jumps/branches and selected register
  • ​Text boxes containing original assembly, hacked assembly and comments/notes which are constantly aligned
  • ​Easy address translation from memory editor to emulator
  • ​Checksum calculation (should work for most games)
  • ​CRC bypass (works for some games)
  • ​Jump/branch mapping which allows highlighting of "branch/jump targets" and "jumps to function" lookup
  • ​Changeable colour scheme
  • ​Hacking notes are always output to a negotiable text document in order of address they are aligned with
  • ​Generate a script from a script template to apply to a batch of addresses for use in other programs
  • ​Float/Double <--> Hex translation

It's currently functional spaghetti source code. If you would like to give it a whirl and you're on linux or mac, you will need a Python 3.5 or 3.6 interpreter, also need to install Python's tkinter module. If you're on Windows, there is a download link to a snapshot of my Python environment and also the disassembler and a batch file to run it.

If you haven't dabbled in python before, you likely won't have the interpreter on your machine. I'd suggest Anaconda (a Python virtual environment manager) as when you make an environment, you can specify "Anaconda" at the end of the command when creating a virtual environment in the command prompt, and it will create the python installation with a whole heap of commonly used modules, including tkinter. Anaconda might chew up to 1gb of data to install, as a forewarning.

Anaconda for OSX: https://conda.io/docs/user-guide/install/macos.html
Anaconda for Linux: https://conda.io/docs/user-guide/install/linux.html
**Don't choose miniconda, from what I understand, you can get stuck in "dependency hell" while trying to obtain tkinter, which is not a place you want to be in

​Source on Git: https://github.com/mitchasdf/N64-Rom-Disassembler
Download for Windows** (includes python and tkinter): https://drive.google.com/open?id=1lqW6q5WkfurMnpScZ-QOvbcM4oap0gpS

**You may need to disable any ad or popup blockers or add the page to the blocker's exclusion list. If you don't, you will get "failed to start action" and http errors when attempting to download. The download button is located at the top-right of the page.

Usage

In the main window, there are 4 tall text boxes. Respectively, they represent: Addresses, base file, hack file, hacking notes/comments.

When you open a rom initially, you can choose "start new" in the file menu to select the base file and then the name and location for the hack file. If you already have a hack file you wish to open, you can "open existing" and then associate it with the base file in the 2nd file navigation window.

They might feel like normal text boxes, but they have heavily modified behaviour so as to keep the code and comments aligned. You can copy/paste or backspace multiple lines of code or comments and it will be safe.

The text boxes are bound with a few hotkeys which make life a bit easier. I'll list them all here:
  • ​Return: Move to end of next line
  • ​Shift+Return: Move to end of previous line
  • ​Shift+Backspace or Shift+Delete: Remove line of code
  • ​Ctrl+B: Insert branch template (BEQ R0, R0, $)
  • ​Ctrl+R: Restore line of code, or selection of lines of code
  • ​Ctrl+F: Follow jump or branch
  • ​Ctrl+G: Find all J or JAL which target any address inside the current function
  • ​Ctrl+Comma (< key): Undo
  • ​Ctrl+Fullstop (> key): Redo

The rest of the hotkeys which don't affect the text boxes can be found scattered in the Menu.

Extra text box behaviours:
  • ​NOP will be automatically removed when typing on that line
  • ​Blank lines will be replaced with and treated as NOP
  • ​Multi-line selections will be extended to the bounds of the start and end lines you select when you attempt to action the selection
  • ​Hack text box will always input as upper case letters


For address translation from memory editor RAM to emulator RAM, you may use an option to set the memory editor offset for the current game, and from there you can either type in addresses manually, or, if you leave the input text box blank and just click the translate button, it will try to convert your clipboard contents instead.

The comments navigator has a "filter" option to search for comments with particular phrases. It will filter out any comment that doesn't contain each word you type in, separated by spaces. You can see an example of that in the comments navigator image below.

If you group your addresses by adding hashtags (#group name) to the end of their comments, you can then add those groups to the batch with the click of a button in the script generator window.

To use additional memory region offsets, its as simple as setting the parameters using the option in the options menu, then all jumps to that region will appear with the offset applied. All additional jumps made to that region will be encoded accordingly. Setting memory regions has no affect on the layout or placement of the code, only how it appears. The addresses list on the left side of the main window (and addresses in all other windows) will also have the offset applied during game offset mode.
Every navigation task which shifts your view will only have the region offset applied to your input during game offset mode.


Screenshots

​Main window
[Image: Main_win.png]

​Comments navigator
[Image: updated_comments_win.png]

​Jumps navigator
[Image: jumps_win.png]

​Script generator
[Image: script_generation.png]
[Image: test_script_generation.png]

​Assembly search
[Image: assembly_search.png]

​All newer versions will be compatible with old config files

​*** I have moved a few menu items around so that Tools isn't so crowded any more. Some buttons which cause time-consuming work to begin were too easy to accidentally click, so they have been moved and encased in separators

​Latest update: 12/02/2018
(This post was last modified: 02-03-2018, 09:05 AM by mitchasdf.)

Hey mitchasdf,

Excellent tool! I'm usually not a big fan of python, but your code is actually quite elegant and the interface is very clean.

I had a chance to run it and the interface is a little confusing at first, but makes sense once you get going with it. Probably the initial confusion is the open dialog immediately followed by the save dialog. This is a good idea in general, as it will save people from accidentally overwriting good ROMs.

I have a couple issues/suggestions for improvement.
1. the "translate address" input box uses a font that is too large to fit an entire address in the box on my machine, so it spans multiple lines.
[Image: Gw5NE2A.png]
2. allowing for multiple memory regions to be specified. ROMs always have multiple regions which get loaded into different RAM addresses (e.g., SM64 has 4: boot, main, engine, and menu).

If you prefer I add them to the issue tracker on Github, just let me know.

This looks like a very useful tool, but I have just one request: Could you make it usable on Linux please?  See, I run Linux, but when I try to run your program I get :

Code:
​Traceback (most recent call last):
 File "/home/user/misc/Other/Other/N64-Rom-Disassembler/main.py", line 7, in <module>
   from disassembler import Disassembler, REGISTERS_ENCODE, BRANCH_INTS, JUMP_INTS, CIC
 File "/home/user/misc/Other/Other/N64-Rom-Disassembler/disassembler.py", line 7, in <module>
   from decoder import PyDecoder
ImportError: No module named 'decoder'

The problem is the with the .pyd file.  I'm not sure, but I think that the pyd format is Windows specific, and Linux Python, for whatever reason, can't import a Python DLL (Which is what pyd file is, I think).  So if there's any way to use a plain Python module rather than a compiled Python DLL, would you do that please? Smile  

Thank you in advance!  From your screenshots, this looks like a great tool, and I'd be really glad if I could run it under Linux!   Smile   Excellent job, and keep up the good work!  Big Grin

Spoiler :
​By the way, if you ever want some help redesigning the interface or something, let me know!  I have some experience in using Tkinter, and I'd be glad to help!  Wink
Quote:A word fitly spoken is like apples of gold in pictures of silver.
  --Proverbs 25:11


Cheers for the feedback queueRAM.

I'll look into adding the custom memory regions tomorrow morning.

For now, I've set the font sizes for those text boxes so the text no longer wraps. I'd forgotten about that and it was running off system default. There's also a fail-safe in place for overwriting a file that exists.


Hi J_128. Sorry, I made a more optimised algorithm in C++ literally hours ago and compiled that with Cython. I was unaware it was not going to work for linux. But I fixed it so it will revert to the python version of the algorithm if you cannot load PyDecoder Tongue
(This post was last modified: 06-12-2017, 05:36 PM by mitchasdf.)

The new version of the disassembler is now up (30/01/2018)

New features:
  • ​Memory region stuff (shoutouts to queueRAM!)
  • ​Assembly search
  • ​ Float <-> Hex translator
  • ​Minor tweaks to jump mapping (use re-map jumps in tools to "apply" this change to your current jumps.data)
    * it should be noted that you do not need to use re-map jumps after changing your memory regions
(This post was last modified: 30-01-2018, 09:31 AM by mitchasdf.)

I have made some small changes and fixed a few bugs since the 25/01/2018 update.

I'm starting study so I might not be working on adding new features the disassembler as frequently in the coming months. But if anyone leaves feedback for bugs I will fix them asap Smile

Apologies to anybody who has tried to use the download link for windows and the file is missing. nofile.io keeps deleting my uploads after an unknown amount of time, so I've hosted it on google drive instead.

N64 assembly editor
Users browsing this thread: 1 Guest(s)