Author Topic: Systems programming/reverse engineering  (Read 2773 times)

Schala Zeal

  • Radical Dreamer (+2000)
  • *
  • Posts: 2127
  • 7th Elemental Innate, and vtuber
    • View Profile
Systems programming/reverse engineering
« on: January 21, 2023, 10:23:39 pm »
So I've been enthralled with the Rust programming language lately, which rides developers' asses to make properly working code.

Recently, I've made a proof of concept 6502 CPU emulator and accompanying disassembler in it. The NES uses the 6502 CPU and the SNES uses a CPU that builds on that. One of the features I want to add that should be easy to code is feeding in a text file that maps labels with ROM addresses. I could, with Mario Bros 1, type up a ROM map that I can then feed into my disassembler and it will label things such as the sound loading function or the cheep-cheep sprite location.

Eventually, I want to take the NES emulator and extend it into a 65C16/Ricoh 5A22 emulator that will carry the same disassembler features. Using that, I've been inspired by Geiger's Snes9X debugger and want to make something modern and more robust.

I believe the Compendium has documented the Chrono Trigger ROM locations, along with Temporal Flux. Once done, I hope to have my emulator be able to set debug breakpoints in the ROM, step through, step over, etc., complete with labels for data and functions, so the user can see exactly what assembly is being executed.

Eventual future plans may include a decompiler to C, to make it even easier.

Right now the only foreseen difficulties are the graphics. I plan to use WebGPU for the graphics
« Last Edit: January 21, 2023, 11:33:26 pm by Schala Zeal »

pseudonymous_traveller

  • Iokan (+1)
  • *
  • Posts: 8
  • In the realm of the past, I am King & you will bow
    • View Profile
Re: Systems programming/reverse engineering
« Reply #1 on: January 27, 2023, 06:53:09 pm »
Okay, that actually sounds pretty cool. What resources are you using to learn emulation concepts?

On a somewhat different note, has anyone had success using Ghidra to reverse engineer some of the Chrono Trigger code? Speaking from experience using Ida Pro (very similar), it makes our lives a whole lot easier.

Otherwise, very ambitious yet cool project idea. I wish I could stay focused long enough to complete something like that  :roll:.

Also the emulator in link related (https://ce-programming.github.io/CEmu/) may provide some inspiration, despite it being ez80 rather than 6502-based.
« Last Edit: January 27, 2023, 06:55:43 pm by pseudonymous_traveller »

Mauron

  • Guru of Reason Emeritus
  • Errare Explorer (+1500)
  • *
  • Posts: 1764
  • Nu-chan
    • View Profile
    • Maurtopia
Re: Systems programming/reverse engineering
« Reply #2 on: February 25, 2023, 03:09:15 am »
On a somewhat different note, has anyone had success using Ghidra to reverse engineer some of the Chrono Trigger code? Speaking from experience using Ida Pro (very similar), it makes our lives a whole lot easier.

I've been playing with it a little lately. I made my own fork of the current SNES Loader to support HiROM mapping and the latest version of Ghidra. At the moment the loader/language files still need work. It gives errors occasionally, trips up over function calls, and the decompiled C gets... weird... sometimes.

It's definitely helping with organizing my data. I'm seeing more patterns in RAM data, and I've still got a lot of notes to convert.

alberteinstein

  • Iokan (+1)
  • *
  • Posts: 1
    • View Profile
Re: Systems programming/reverse engineering
« Reply #3 on: January 14, 2024, 11:23:16 pm »
So I've been enthralled with the Rust programming language lately, which rides developers' asses to make properly working code.

Recently, I've made a proof of concept 6502 CPU emulator and accompanying disassembler in it. The NES uses the 6502 CPU and the SNES uses a CPU that builds on that. One of the features I want to add that should be easy to code is feeding in a text file that maps labels with ROM addresses. I could, with Mario Bros 1, type up a ROM map that I can then feed into my disassembler and it will label things such as the sound loading function or the cheep-cheep sprite location.

Eventually, I want to take iq test the NES emulator and extend it into a 65C16/Ricoh 5A22 emulator that will carry the same disassembler features. Using that, I've been inspired by Geiger's Snes9X debugger and want to make something modern and more robust.

I believe the Compendium has documented the Chrono Trigger ROM locations, along with Temporal Flux. Once done, I hope to have my emulator be able to set debug breakpoints in the ROM, step through, step over, etc., complete with labels for data and functions, so the user can see exactly what assembly is being executed.

Eventual future plans may include a decompiler to C, to make it even easier.

Right now the only foreseen difficulties are the graphics. I plan to use WebGPU for the graphics
Working with the 6502 CPU and extending the emulator to support the 65C16/Ricoh 5A22 CPU is a fascinating endeavor. The idea of incorporating a ROM map to label specific locations within the ROM is a great feature that will make the disassembler more user-friendly.

Adding debugging features like breakpoints, stepping through code, and displaying labels for data and functions will definitely enhance the user experience and make the emulator more powerful. The potential future addition of a decompiler to C is also an interesting idea.

As for the graphics, using WebGPU for rendering is a modern and promising choice, and it will be interesting to see how you integrate it into your emulator.