News: 11 March 2016 - Forum Rules

Author Topic: BZK 6502 Disassembler  (Read 4363 times)

Cyneprepou4uk

  • Hero Member
  • *****
  • Posts: 734
  • I am the baldest romhacker
    • View Profile
BZK 6502 Disassembler
« on: December 03, 2020, 01:29:15 pm »
Let's create a quick disassembly of your game!  :)

This disassembler is a CDL-based Lua script. Mostly targeted on romhackers who just want to have a better view at the game code with little effort. By editing the config file you can properly disassemble any game on any mapper.

Disassembler features:
- Separate code from data using a CDL file
- Display all 6 CDL flags, ROM File and NES Memory address
- Use several table files to display symbols
- Auto adding labels to RAM addresses
- Additional info about each CPU address

Notepad++ scripts features:
- Convert .byte to instructions
- Convert .byte to .word/.dbyt + labels
- Auto adding labels to Branches, Tables and JMP/JSR instructions
- Other manipulations with bytes

Final output files are compatible with ca65 assembler (after deleting "garbage" text using a single regex). Assembles files into a 1:1 copy of the original ROM.

Spoiler:


If you wanna try it, read the manual. Let me know if you have any questions.
« Last Edit: December 13, 2020, 06:44:12 pm by Cyneprepou4uk »

Vanya

  • Hero Member
  • *****
  • Posts: 1932
    • View Profile
Re: BZK 6502 Disassembler
« Reply #1 on: December 03, 2020, 07:28:12 pm »
Oh! That's pretty neat, and seems super useful, nice!

PolishedTurd

  • Full Member
  • ***
  • Posts: 219
    • View Profile
Re: BZK 6502 Disassembler
« Reply #2 on: December 06, 2020, 09:51:15 am »
This looks really cool! Can't wait to try it out on a couple games.

Thank you!

Cyneprepou4uk

  • Hero Member
  • *****
  • Posts: 734
  • I am the baldest romhacker
    • View Profile
Re: BZK 6502 Disassembler
« Reply #3 on: December 06, 2020, 03:59:33 pm »
Good, you might unlock "the 1st tester" achievement  :cookie:

shadow501

  • Full Member
  • ***
  • Posts: 225
  • Modder
    • View Profile
Re: BZK 6502 Disassembler
« Reply #4 on: December 07, 2020, 01:37:07 am »
Let's create a quick disassembly of your game!  :)

This disassembler is a CDL-based Lua script (CDL is a file created by Code/Data Logger). It's an updated version of my own disassembler which I was using to create a CT2 disassembly, taken into account all my previous experience with 3 (successful) attempts to manually create a disassembly for other games from scratch without any scripts.

It produces assembly files with additional information like CDL flags, ROM File and NES Memory addresses. Also you can use several advanced table files to look for the text bytes. Then you polish your assembly files with my Notepad++ LuaScript plugin scripts.

Spoiler:


The disassembler is mostly targeted on romhackers who want to have a better view at the game code with little effort. At the same time output files can easily be made compatible with ca65 assembler, including some other features.

If you wanna try it, read the manual. Let me know if you have any questions.

Hope to see Captain Tsubasa 1 NES translation  :)

Cyneprepou4uk

  • Hero Member
  • *****
  • Posts: 734
  • I am the baldest romhacker
    • View Profile
Re: BZK 6502 Disassembler
« Reply #5 on: December 07, 2020, 03:16:34 am »
I don't like CT1, but I'll be hoping so too, maybe it will help   :D

Cyneprepou4uk

  • Hero Member
  • *****
  • Posts: 734
  • I am the baldest romhacker
    • View Profile
Re: BZK 6502 Disassembler
« Reply #6 on: December 31, 2020, 10:54:17 am »
Version 1.6.0 is available. Since last time I've fixed a couple of bugs and improved some scripts.

Trax

  • RHDN Patreon Supporter!
  • Hero Member
  • *****
  • Posts: 609
    • View Profile
    • Trax ROM Hacking
Re: BZK 6502 Disassembler
« Reply #7 on: January 04, 2021, 12:33:44 am »
How does the disassembler differentiate between code and other data?

Cyneprepou4uk

  • Hero Member
  • *****
  • Posts: 734
  • I am the baldest romhacker
    • View Profile
Re: BZK 6502 Disassembler
« Reply #8 on: January 04, 2021, 01:02:41 am »
By looking at CDL file.

Cyneprepou4uk

  • Hero Member
  • *****
  • Posts: 734
  • I am the baldest romhacker
    • View Profile
Re: BZK 6502 Disassembler
« Reply #9 on: January 30, 2021, 04:06:53 pm »
Version 1.6.1 is available with a small bugfix (not really important one).

I've recorded an example of disassembling Mappy game using this disassembler.
https://youtu.be/Abrv2Rpo80Y

Fox Cunning

  • Jr. Member
  • **
  • Posts: 81
  • Barrel-roller
    • View Profile
Re: BZK 6502 Disassembler
« Reply #10 on: February 10, 2021, 02:46:12 am »
That's one great little utility! I primarily use Mesen, which can also export CDL files. I'll let you know if it works with those too.

Cyneprepou4uk

  • Hero Member
  • *****
  • Posts: 734
  • I am the baldest romhacker
    • View Profile
Re: BZK 6502 Disassembler
« Reply #11 on: February 10, 2021, 07:54:07 am »
 :thumbsup:

February 10, 2021, 12:09:08 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
I assume that both FCEUX and Mesen produce the same cdl format.
https://github.com/SourMesen/Mesen/issues/561

However I'm not sure about bit7. At some point FCEUX reserved this bit as "code being executed at $6000-$7FFF" flag. My disassembler marks this case as "D 4" in output files (didn't test it though).

But Mesen might be using bit7 for other purpose.
https://forums.nesdev.com/viewtopic.php?f=3&t=13844&start=855#p256461

If that post is correct, and my untested function works, then output files will have a little more useful info when using cdl from Mesen.
« Last Edit: February 10, 2021, 12:09:08 pm by Cyneprepou4uk »

Cyneprepou4uk

  • Hero Member
  • *****
  • Posts: 734
  • I am the baldest romhacker
    • View Profile
Re: BZK 6502 Disassembler
« Reply #12 on: October 13, 2021, 01:34:19 pm »
A big update is coming soon  :)

You know that Trace Logger tool in FCEUX emulator, right? You know how laggy the emulator gets while using it? You know those enormous output files it produces?

That's all in the past now. I've hacked the emulator to output only the most important data that I need, while doing it as fast as my C++ skills (which are at the beginning level) can afford.

Despite being a noob, I still did a pretty good job. Right now I'm running my Double Dragon 2 walkthrough movie file at turbo speed while tracing, and still get 100+ FPS.

I've also found and hacked a tool called Remove Duplicate Lines, in order to work with all the files in a folder, not manually selecting a file after another. This reduces total 27,7 GB output files from a 45 min movie to 1,7 GB.

When I accumulate all that data and produce a 15,7 MB dump with my script, I get:
- all A, X and Y values, presented at the moment when the instruction was about to be executed
- if it was a JSR, absolute JMP or indirect JMP, I have info about all ROM and RAM addresses they've jumped to, not NES addresses
- all ROM and RAM addresses to which RTS was leading to
- all ROM and RAM addresses, calculated via instructions like LDA (addr),Y and LDA (addr,X)

If you know a thing or two about NES romhacking, and also about making disassemblies, I think you understand the value of this dump. And when I pass it to my disassembler, a true magic will happen  >:D

The whole collecting data thing took me about 80 min in this case.

I think that I probably won't be needed a CDL file for my disassembler anymore. By having info about X and Y values I can determine which bytes were read via absolute indexed instructions, so what else can I ask for? The only thing that I can think of is being able to see DPCM samples with a CDL.

Other not so important things that I wanted to log are the state of status flags register, and also banks id for 8000, A000, C000 and E000 NES addresses. But the emulator started to get a bit laggy, and that info isn't very useful comparing to other, which is sufficient.

If you have any other ideas, I'm all ears.