dangiu / PicoMemcard

Emulating PSX Memory Card (or controller) using a Raspberry Pi Pico
GNU General Public License v3.0
529 stars 38 forks source link

FreePSXBoot autoboot, file API and executable launcher #8

Open spicyjpeg opened 2 years ago

spicyjpeg commented 2 years ago

I have been thinking about a few possible enhancements for this project, none of which would be particularly hard to implement.

As controllers sit on the same shared SPI bus as memory cards, it should be possible for the RP2040 to emulate a controller for a few seconds after bootup and send the keypresses required to enter the memory card manager; this would fully automate the process of launching FreePSXBoot. It should also be possible to sniff communications between the console and the controllers (which are polled at 50-60 Hz by the kernel) and detect specific key combos to e.g. change the card image.

Moreover, the RP2040 could implement a custom command set to allow homebrew apps to access files on the flash or SD card, potentially making it possible to write a launcher (booted through FreePSXBoot) for executables on the card. This wouldn't be useful for retail games as they are hardcoded to access the CD drive, however it would make debugging homebrew on real hardware easier (currently the most common way to test on a PS1 is to build a serial port adapter, which is far slower and requires cutting up hard-to-find link cables or soldering to the motherboard).

I'm probably going to try adding these features in a few weeks once I have some free time, as the PS1 homebrew scene desperately needs a lower barrier to entry on the hardware side of things (and on the software side as well, but I'm already tackling that with my contributions to PSn00bSDK).

dangiu commented 2 years ago

All great ideas! Regarding simulating a controller is definitely possible and also quite easy. To be honest when I was testing the Pico bus sniffing/injection capabilities one of the first test was to emulate a controller repeatedly alternating left and right on the dpad. In the proof of concept folder (poc_examples) I still have some of the code I used so implementing this should be pretty straight forward. Listening for a specific set of button presses to change memory card image is also nice, I believe that some third party card were doing something like this.

Regarding the other features, they would probably require lot of development also on the PSX side of things... I'm definitely no expert on that but I'd be very happy to accept any help/contribution!

realJoshByrnes commented 1 year ago

Can we detect when a PlayStation has booted and is ready for input? It seems that the controller starts communication before the BIOS is ready for input, which would mean we need to add a timer, which may vary by bios/unit, and may do the wrong thing coupled with user input.