simias / rustation

Playstation emulator in the Rust programing language
Other
552 stars 21 forks source link

Hex Editor, ASCII editor, cheats, memory card editor, assembler, disassembler, memory hacks, memory dumping and restoring. #22

Open ADormant opened 8 years ago

ADormant commented 8 years ago

I think these features would be very useful for cheats, translations, game hacking and memory hacks. Plugin-based PSX emulators have a plugin called PSX Emulation Cheater(PEC) for it. I believe PSX/PSXFin has built-in Hex editor.

http://ngemu.com/threads/playstation-emulator-cheater-setup-guide.101186/ http://pec.duttke.de/ http://www.aldostools.org/pecedit.html https://github.com/strobejb/HexEdit https://github.com/evanmiller/hecate http://www.zophar.net/utilities/hexutil.html http://homepage.ntlworld.com/simon.mallion/PSXMemTool/

simias commented 8 years ago

I was hoping that the current debug interface (implementing the GDB protocol over a debug socket) could be extended to implement a cheat engine. I already use it to step through the assembly and display RAM values and it works decently well.

That being said the GDB protocol might prove limiting for certain applications, or at least require a few hacks or extensions to work well. For instance I have no direct access to the video RAM at the moment.

I think I'll have to try one of the existing cheat engines to see how it looks like and what's the best way to reimplement the same features.

Memory cards should have their own issue I think, it's not directly related to the cheat/debugging interface.

ADormant commented 8 years ago

Yeah hex editor in particular would be very helpful for hacking. I doubt things like Hex editor , memory and framebuffer dumping can be done with just GDB. It'll probably need dedicated interface/GUI of some sort.

ADormant commented 8 years ago

Found this memory, ascii and hex editor https://github.com/bryanperris/Soft64-Bryan/commit/a32c8417d654ad1f1b2d5d123a25d8c7bd876be3 https://github.com/bryanperris/Soft64-Bryan/commit/cbc5900fe9003bec3f505f798a350124b1f748ba https://github.com/bryanperris/Soft64-Bryan/commit/ae12be0b95193d1188353b234fda5e8d751ba073 https://github.com/bryanperris/Soft64-Bryan/commit/317792db0a60221a7275bbd7ebadc5b5ca24d056 https://github.com/bryanperris/Soft64-Bryan/commit/30bade4a1422f81909693bdeba9f5ab8e2958845 https://github.com/bryanperris/Soft64-Bryan/commit/983a2123ca0850c139daf38343341cbc3c5cb0e2 https://github.com/bryanperris/Soft64-Bryan/commit/73cccc85990ebd942cf233ae552a71d0d9d7cf79 https://github.com/bryanperris/Soft64-Bryan/commit/547f411fbfade98796db9e273680567db7a3e30c https://github.com/bryanperris/Soft64-Bryan/commit/fc87976f1f66a0377fd75f11868c552c4495920a https://github.com/bryanperris/Soft64-Bryan/commit/ef23217f69cba4bb7b89fcd202360432070ad00b https://github.com/bryanperris/Soft64-Bryan/commit/e395d0ebe2e3fed33583c135c96cd50f04c5edf7 https://github.com/bryanperris/Soft64-Bryan/commit/26912be38688650a24e82e0307204ea17fe6171a https://github.com/bryanperris/Soft64-Bryan/commit/e6e18d683c4dbacfee362435c9ccb4a7339c9124 https://github.com/bryanperris/Soft64-Bryan/commit/c1058582e1e3cbc2cf796c0ecb17373e921b1196 https://github.com/bryanperris/Soft64-Bryan/commit/5cd103903fe40c0e9ac9e913e899ad9daa63c50b https://github.com/bryanperris/Soft64-Bryan/commit/e90bbabb2fea1622f09051b0cc130340bc6c5c3e https://github.com/bryanperris/Soft64-Bryan/commit/6f11e13cff36d551390531e797f34e4296fe956b https://github.com/bryanperris/Soft64-Bryan/commit/9dd6eff6c5f7f06c5bbf472a06f74b02098f7cc1 https://github.com/bryanperris/Soft64-Bryan/commit/fdfa10b08f34798f357a76c3444083d6a991dcb7 https://github.com/bryanperris/Soft64-Bryan/commit/0f21f4a96e33d3b382ca3c3fbe622d72f6977ab3 https://github.com/bryanperris/Soft64-Bryan/commit/96b3b6328186353e9da4944428cfffe0db54debb https://github.com/bryanperris/Soft64-Bryan/commit/824c96abd61561cea4d84e71460d1a01609150a6

simias commented 8 years ago

It's using HTML/Javascript for the UI it seems which might make it a bit painful to integrate. Do you know which emulator is considered to have the best memory editor? I suck at UI design...

ADormant commented 8 years ago

Dolphin and PPSSPP have memory editors also https://github.com/devinacker/bsnes-plus , VBA-M and FXEUX which has hex editor too. http://www.fceux.com/web/help/fceux.html?MemoryWatch.html http://www.fceux.com/web/help/fceux.html?HexEditor.html , https://sourceforge.net/projects/fceultra/ , http://www.fceux.com/web/help/fceux.html?PPUViewer.html Desmume http://wiki.desmume.org/index.php?title=DeSmuME_Manual_for_the_Windows_port#Tools_.7C_View_Memory , https://forums.dolphin-emu.org/Thread-howto-cheating-in-games https://www.youtube.com/watch?v=F_wu7Mh8v24 http://www.fceux.com/web/help/fceux.html?RAMWatch.html http://www.fceux.com/web/help/fceux.html?MemoryWatch.html http://www.fceux.com/web/help/fceux.html?NameTableViewer.html http://www.fceux.com/web/help/fceux.html?TraceLogger.html http://www.fceux.com/web/help/fceux.html?Debugger.html http://www.fceux.com/web/help/fceux.html?HexEditor.html http://www.fceux.com/web/help/fceux.html?RAMSearch.html http://www.fceux.com/web/help/fceux.html?PPUViewer.html

ADormant commented 8 years ago

Okay I found other example in C++. As for GUI what about GTK+? it has good Rust bindings. https://github.com/kud1ing/awesome-rust https://github.com/gamazeps/Useful-Rust-Projects https://github.com/gtk-rs https://github.com/kenz-gelsoft/wxRust

https://github.com/shonumi/gbe-plus/commit/5ad63d2b70d8132ad74274113744f4e4e79565ec https://github.com/shonumi/gbe-plus/commit/bb9914b0f79a77d543dc6c2ad852284a69208af2 https://github.com/shonumi/gbe-plus/commit/39f21630a0d9e473421ed236f2dc3b277a3a0381 https://github.com/shonumi/gbe-plus/commit/54514407e11e4ade977c44cd2d8d37d74711186a https://github.com/shonumi/gbe-plus/commit/1a5c93c196c8e5eda6572586cc46557017b2ff4e https://github.com/shonumi/gbe-plus/commit/52a91e2e2771514263078414fe3f77cf28faf055 https://github.com/shonumi/gbe-plus/commit/29fde5dbeb19fa838f150953d23597b06fdca18e https://github.com/shonumi/gbe-plus/commit/13eac98ddf8e56f97c0afaa3bfa5da6cfbd505b7 https://github.com/shonumi/gbe-plus/commit/8e796c425fe0dfd1fab4b3510f06d5547f64eb2e https://github.com/shonumi/gbe-plus/commit/c6b512468500b71e989579578c17057e1a60a23a https://github.com/shonumi/gbe-plus/commit/620b57a1acc87cd96094e2e0c2538416775f0a98 https://github.com/shonumi/gbe-plus/commit/d83da9d1230681d7cc257799e25424c906dc4517 https://github.com/shonumi/gbe-plus/commit/b498c479b555f7370b3f471b570f4258cc31c0b6 https://github.com/shonumi/gbe-plus/commit/7a4ebc41828d88e1812fee74a267cfcdb99b21ff https://github.com/shonumi/gbe-plus/commit/23ce9ddf0de87fab4fc36ea5ac380b410b7aee00 https://github.com/shonumi/gbe-plus/commit/39825899eba8611c495f83ec7c1cad6c1b3248bf https://github.com/shonumi/gbe-plus/commit/596a12c379f5bb800fd65eeb719334cf234eaa99

https://github.com/bryanperris/Soft64-Bryan/commit/cb1dd2c13b83e1e3758bd74ee599bda2d2b66b3a https://github.com/bryanperris/Soft64-Bryan/commit/04cedaac2b2d7c819ff35560f0864ea1d73883dc https://github.com/bryanperris/Soft64-Bryan/commit/e084ad0a1757e39ee5041443e58f9b216e383a81 https://github.com/bryanperris/Soft64-Bryan/commit/8235acdea292c414d8d0224c6dcce5117902a1b9 https://github.com/bryanperris/Soft64-Bryan/commit/a7b75add944e46814d7a32a4d94e7ca8fc906e31 https://github.com/bryanperris/Soft64-Bryan/commit/cc91f438772bc16a465cfed323372bbf1306ba5f https://github.com/benvanik/xenia/commit/41174b0e6406ce32f8e97058e8c95aee5cbbeb09 https://github.com/benvanik/xenia/commit/5d033f9cb319bcd9f4a9a9eefeafdbbdf1bd1209 https://github.com/benvanik/xenia/commit/826ea608902974be788d8de0593258ff4d4cd440 https://github.com/benvanik/xenia/commit/7419e7eb4a99128809e9f409b762f0e062aa48a3

ADormant commented 8 years ago

@simias Rust GUI resources https://github.com/kenz-gelsoft/wxRust

https://github.com/gtk-rs

https://github.com/crabtw/rust-bindgen

https://github.com/PistonDevelopers/conrod/blob/master/examples/all_widgets.rs

https://github.com/PistonDevelopers/conrod/blob/master/examples/custom_widget.rs

https://www.reddit.com/r/rust/comments/3rtvzg/what_would_be_the_best_way_to_make_a_rust_gui/

https://github.com/gtk-rs/gtk

https://github.com/gtk-rs/glib

https://github.com/gtk-rs/cairo

https://github.com/gtk-rs/sys

https://github.com/gtk-rs/pango

https://github.com/cyndis/qmlrs

https://github.com/PistonDevelopers/conrod

https://github.com/ctjhoa/rust-learning https://github.com/dschenkelman/rust-lang-resources https://github.com/kud1ing/awesome-rust https://github.com/gamazeps/Useful-Rust-Projects https://github.com/McNopper/OpenGL

ADormant commented 8 years ago

https://github.com/PistonDevelopers/conrod/blob/master/examples/custom_widget.rs

ADormant commented 8 years ago

@simias https://github.com/PCSX2/pcsx2/pull/1079/files https://github.com/PCSX2/pcsx2/pull/1070/files https://github.com/dolphin-emu/dolphin/pull/3413/files https://github.com/shonumi/gbe-plus/commit/75a6d05f7f8895243c91d95c7ed15d70194a75d9 https://github.com/shonumi/gbe-plus/commit/f129e2ae95fc238022457c406066b20dd59c20c9 https://github.com/shonumi/gbe-plus/commit/31f7888078fbd1a27d2e9d7311972a8c0e4f13c2 https://github.com/shonumi/gbe-plus/commit/32176aa58d4fc4cbaf45f38e7d0e40e8dd8e8b1d https://github.com/shonumi/gbe-plus/commit/c1fd1a8a167555c1a4ded285d88cc96199e42c79 https://github.com/shonumi/gbe-plus/commit/afc49af449631d6b17bf465229e854885ef7ed4a https://github.com/shonumi/gbe-plus/commit/32176aa58d4fc4cbaf45f38e7d0e40e8dd8e8b1d https://github.com/shonumi/gbe-plus/commit/ab0d38810e3b721c6310425d846cee8880c2f9b6 https://github.com/shonumi/gbe-plus/commit/a30eaae98e8ba01cb773849a502524b991d975a1 https://github.com/shonumi/gbe-plus/commit/ede78c5efb62d984a9eced167c094d7f6ecd0b1e https://github.com/shonumi/gbe-plus/commit/bc527d4c934c69b3b1005049fe9be49e6071b290 https://github.com/shonumi/gbe-plus/commit/2ed3aedb2c093c93ea377b6cc0f0544250e90967 https://github.com/shonumi/gbe-plus/commit/cd3ca5e46bca85651c57ffc8100e085581278e27 https://github.com/shonumi/gbe-plus/commit/f63c6b5827a00971ec75505966b1b7a7c27bd80d https://github.com/shonumi/gbe-plus/commit/596a12c379f5bb800fd65eeb719334cf234eaa99 https://github.com/shonumi/gbe-plus/commit/bb9914b0f79a77d543dc6c2ad852284a69208af2 https://github.com/shonumi/gbe-plus/commit/54514407e11e4ade977c44cd2d8d37d74711186a https://github.com/shonumi/gbe-plus/commit/52a91e2e2771514263078414fe3f77cf28faf055 https://github.com/shonumi/gbe-plus/commit/29fde5dbeb19fa838f150953d23597b06fdca18e https://github.com/bryanperris/Soft64-Bryan/commit/fb120137387e5fd998f03cdc1e931aa1200b9789 https://github.com/shonumi/gbe-plus/commit/13eac98ddf8e56f97c0afaa3bfa5da6cfbd505b7 https://github.com/PCSX2/pcsx2/commit/c80037bb2fb0ca791f8706eb004c2085a4a1e507 https://github.com/benvanik/xenia/commit/41174b0e6406ce32f8e97058e8c95aee5cbbeb09 https://github.com/benvanik/xenia/commit/5d033f9cb319bcd9f4a9a9eefeafdbbdf1bd1209 https://github.com/benvanik/xenia/commit/47f58960899ae6f40099c6daf81f39aaafe2af32 https://github.com/benvanik/xenia/commit/9ed093412337861bed6ee3c4edd80c34d0d3e3a3 https://github.com/benvanik/xenia/commit/3859b0a091495275f46a01d3e22ca7f70ffdeea9 https://github.com/benvanik/xenia/commit/7419e7eb4a99128809e9f409b762f0e062aa48a3 https://github.com/PCSX2/pcsx2/commit/bfd1bcec699012d7e7bbc7d49989d13adc8d145e https://github.com/PCSX2/pcsx2/commit/ba62ce9e933499f94a613f34a0a02361fd870fc6 https://github.com/PCSX2/pcsx2/commit/4eed4ca3a1a194268fe48aaece3e6669e5897fa3

simias commented 8 years ago

Sorry if I didn't get back to you yet, I'm shoulders deep in the libretro port and I still have some work ahead of me.

I have turned the Rustation code into a stand-alone library though so it should be possible to implement alternative frontends easily if libretro doesn't cut it for some of these things.

simias commented 8 years ago

I think I'm going to try to extend the GDB interface to implement GPU debugging. Now that I'm almost done converting the code into a libretro core I can't really implement a proper "internal" debugger since I can't really build a GUI in libretro. I'm thinking of having a separate application connect to the running emulators and fetch the necessary data for debugging.

An other possibility would be having a stand alone version of the emulator for debugging but I don't feel like implementing and supporting both at this point.

simias commented 8 years ago

So I've been thinking about how to handle memory cards. It's a bit tricky to handle right.

My current approach would be to have a game-specific memory card in slot 1 and a common memory card (always the same no matter the game you play) in slot 2. I think it's relatively straightforward and it would fit my particular needs I think. Maybe some people would prefer to have two game-specific memory cards though, if they like to make many saves for a given game.

A potential problem is that "game-specific" can be tricky to do right, especially for multi-disc games. At first I thought I could use the serial number (it's normally the main binary name in all licensed PlayStation games). Unfortunately I've discovered that multi-disc games have a different serial number per-game. For instance MGS (USA) disc 1 is SLUS-00594 while disc 2 is SLUS-00776.

Mednafen handles this by using m3u playlists, but that seems pretty user-unfriendly. Unfortunately the only other approach I can think of would be to use a database containing all PSX games and use that to catch the multi-disc scenario.

With a database we could decide to standardize on the serial number of the first disc for instance, that would give us files named like:

SLUS-00594_Metal-Gear-Solid.mcr
SCPS-10031_Crash-Bandicoot.mcr
SCES-01438_Spyro-the-Dragon.mcr

Having a DB could also avoid having to mess with m3u when changing discs, the emulator could just look for a disc image in the current directory with the correct serial number, although that might be a bit slow if you have a shitload of disc images in the directory. But that's an other problem.

Serial numbers are different between regions, but that's probably a feature since we can't be sure that the memory card format would be compatible anyway.

I'm going to try to compile such a database and see how it goes.