News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: How can I use bisqwit's disassembly?  (Read 1777 times)

Timaeus

  • Jr. Member
  • **
  • Posts: 75
  • Noel <3
    • View Profile
How can I use bisqwit's disassembly?
« on: February 17, 2020, 05:44:49 pm »
  I tried disassembly my Megaman 1 hack all day (my goal is to edit enemies AI, and weapons maybe), and nothing. I tried alot of things but none of them worked, since all of it is just so confusing for me (I am a newcomer). Then I found out that bisqwit's disassembly can do alot of things, and the example file of Castlevania 2 (this one : https://bisqwit.iki.fi/src/clever-disasm-example/cv2u.lst) is exactly formed in a way that I think I can work with. The problem is, I got alot of files from the link of his disaseembly (lots of CC files and such) and I have no idea of where to start. Can someone explain me with details how it works and how I can end up with the same results as the example?

nesrocks

  • Hero Member
  • *****
  • Posts: 641
    • View Profile
    • nesrocks.com
Re: How can I use bisqwit's disassembly?
« Reply #1 on: February 17, 2020, 05:47:43 pm »
When I do hacks I do not disassemble the games. A lot of people do this, but it is not necessary, and I find it to be too much trouble for what it's worth. Maybe it's just me, but I prefer to edit the ROM directly using fceux's hex editor and debugger. It's fast, simple and you see the results right away. Of course, if you're doing incredibly extensive modifications that would greatly benefit from code being rearranged inside the ROM, then maybe it's worth the trouble. But I think it often isn't.

Timaeus

  • Jr. Member
  • **
  • Posts: 75
  • Noel <3
    • View Profile
Re: How can I use bisqwit's disassembly?
« Reply #2 on: February 17, 2020, 05:51:26 pm »
  Well, I heared about that option. I even tried it, but I still do not know what to do with it and how the debugger works. I never worked with something like this before. I wish I knew how to use FCEUX that way.

nesrocks

  • Hero Member
  • *****
  • Posts: 641
    • View Profile
    • nesrocks.com
Re: How can I use bisqwit's disassembly?
« Reply #3 on: February 17, 2020, 05:54:02 pm »
Read fceux's entire debugger reference page, and I do mean all of it. All of those things are important and very useful. It's what the bulk of my romhacking workflow relies on 95% of the time. http://www.fceux.com/web/help/fceux.html?Debugger.html

Disch

  • Hero Member
  • *****
  • Posts: 2787
  • NES Junkie
    • View Profile
Re: How can I use bisqwit's disassembly?
« Reply #4 on: February 17, 2020, 08:26:00 pm »
For anything more than like a small ~10 byte change, I don't recommend anyone under any circumstances manually translate assembly into raw byte code to type into a hex editor.  That is making things MUCH harder on yourself.

If you don't have a full disassembly, the next best thing is to use an injection assembler that will allow you to assemble small bits of code and shove them in an existing ROM.

This has more benefits than I can list, but here are a few:
  • Much less error prone
  • Don't have to count bytes and adjust branches every time you change something minor
  • Keep your changes in external files rather than having everything in a monolithic binary
  • VERSION CONTROL.  Throw that shit up on github
  • Can put comments in your code so you know wtf you were thinking when you come back to look at your changes 2 weeks later

The two downsides are that you'd have to reload the ROM to see your changes, and that finding a good injection assembler for NES is kind of hard.  I know some people use xkas, but I ended up making a custom assembler a while back that I never got around to releasing.  If interested I can dig it up.


nesrocks

  • Hero Member
  • *****
  • Posts: 641
    • View Profile
    • nesrocks.com
Re: How can I use bisqwit's disassembly?
« Reply #5 on: February 17, 2020, 11:23:56 pm »
Fceux has an injection assembler in the debugger, doesn't it? I never got it to work, which is why I use mesen's assembler to generate small snippets of code, then I copy the byte code and paste into the rom using fceux. I changed more than 10 bytes in my hacks using this method.

You show valid points, but in practical terms, I prefer not working on a disassembly because for rom hacking you're doing two jobs at once:
1 - reverse engineering the game.
2 - adding your changes.

Fceux is great for both. And the third advantage is that if you're learning how the NES works you can make small adjustments and see right away what happens.
Fceux's interface could be better for reverse engineering though, which is why I modified it to better fit that purpose. Since I did it in a rather sloppy manner, I've kept it to myself, but I can share to anyone who asks. https://twitter.com/bitinkstudios/status/1090646565763596288
« Last Edit: February 17, 2020, 11:44:42 pm by nesrocks »

Cyneprepou4uk

  • Sr. Member
  • ****
  • Posts: 334
  • I am the baldest romhacker
    • View Profile
Re: How can I use bisqwit's disassembly?
« Reply #6 on: February 18, 2020, 06:33:29 am »
You are both pussies, there is nothing like writting code with bytes  >:D
iromhacker.ru - NES ROM hacking tutorials for beginners. Please use Google Translate browser extension

nesrocks

  • Hero Member
  • *****
  • Posts: 641
    • View Profile
    • nesrocks.com
Re: How can I use bisqwit's disassembly?
« Reply #7 on: February 18, 2020, 11:47:28 am »
You are both pussies, there is nothing like writting code with bytes  >:D
I do that too, unless it's code with lots of branching, then an injector beats it  :laugh:

Timaeus

  • Jr. Member
  • **
  • Posts: 75
  • Noel <3
    • View Profile
Re: How can I use bisqwit's disassembly?
« Reply #8 on: February 18, 2020, 04:27:05 pm »
I honestly feel like giving up at this point. Not even hex editing with FCEUX was good enough for me. I just lose so much of my time with no results.
Gonna say FCEUX felt like a better choice though.
I tried editing with debugger, and I couldn't. Hex editing took me like two hours for a veery small and simple change. If at the very least I could edit the coding with debugger.

This is really taking out all my motivation.
« Last Edit: February 18, 2020, 04:32:16 pm by Timaeus »

Disch

  • Hero Member
  • *****
  • Posts: 2787
  • NES Junkie
    • View Profile
Re: How can I use bisqwit's disassembly?
« Reply #9 on: February 18, 2020, 04:53:57 pm »
Syntax for my assembler looks like this:

Code: [Select]
;    CPU address,    ROM file offset    maximum number of bytes to insert -- to prevent you from stepping out of your free space
#org $C400,          $3C410,            32

MyRoutine:
  LDA #0
  LDX #$0F
  .Loop:
    STA $0100, X
    DEX
    BPL .Loop
  RTS

;  You could then do another #org here to inject to a different part of the ROM

That's your asm file.  Then you'd assemble it on the command line with this:

Code: [Select]
bodoasm your_file.asm -a 6502 -o your_rom_file.nes

That's it.  Simple injection assembler.  Tell it the source file, the assembly (I have 6502/65816/spc700 support so far -- and it's extendable via Lua scripts), and the output file.

IMO it's much easier to do things this way than writing byte code in a hex editor.


I have the source code for it, but not the binary.  I'd have to rebuild it (and its dependencies) because reasons.  If you think this will help, let me know and I'll build and upload it for you.

(it's also not finished so there are some features missing, but the basics work)
« Last Edit: February 18, 2020, 05:14:06 pm by Disch »

Timaeus

  • Jr. Member
  • **
  • Posts: 75
  • Noel <3
    • View Profile
Re: How can I use bisqwit's disassembly?
« Reply #10 on: February 18, 2020, 11:08:15 pm »
I was thinking right now about trying to mix things up. With FCEUX's hex editor, I managed to find out what a few parts of certain bytes do, and with the debugger, I could save that info within the code and it appears whetever that part is used. I think I can use this to find out what certain things do and use the assembler to generate my own coding into it. I used to hack Sonic 1 and it's Motorola 68000 coding (managed to make enemies generate shots and such), and I think I can learn the commands with some research maybe. I also found out that each byte on the debugger has a permanent function on certain parts of the code. Or I could still use hex and debugger for the changes and learn the commands just like I did with Motorola 68000

I think those are my best way to understand it.


edit: It turned out hex editing with FCEUX and debugger are giving me more results for now. I managed to edit some stuff and mess up others (in this case, I changed three enemies but MM does not climb laters and jump 3 blocks high. I have ideas of where to look to fix that). I think I will have to move to learning the codes when I decide to do something bigger. Thank you all for the help so far. I am still abit confusing at certain spots but I am slowly learning them.
 
I decided to balance the MM1 weapons by changing their basic concepts (like speed and angles), damage and if the shots will use one or two energy units. My thoughs so far were Rolling cutter doing more damage to big enemies and going faster but in a little shorter range (1 unit per use), decrease Thunder Beam's damage abit and make it slower (1 unit), make Fire Storm use two units but with a bigger shield, Decrease Hyper Bomb's countdown and make it go abit further (2 units), making Super Arm kills any enemy in one hit and add more blocks on the game and make ice slasher slower and with slight diagonal arc. Any different suggestions?
« Last Edit: February 19, 2020, 10:40:32 pm by Timaeus »