rust-console / cargo-n64

Make Nintendo 64 games in Rust! 🦀
MIT License
158 stars 10 forks source link

Open source IPL3 alternative #42

Open parasyte opened 3 years ago

parasyte commented 3 years ago

cargo-n64 does not ship with an IPL ROM for copyright reasons, even though this code is required to cold boot a Nintendo 64. We should add a default open source IPL3, preferably one with MIT license (or equivalent).

I know of two open source IPL3s:

  1. https://github.com/PeterLemon/N64/tree/master/BOOTCODE It is unlicensed and looks like a direct copy of 6102.bin with some minor adjustments.
  2. https://github.com/pseudophpt/pseultra/blob/master/n64/boot/src/boot.sx Minimal implementation. Appears to be incomplete.

The biggest challenge is that IPL2 authenticates IPL3 with the PIF. Exact details of PIF authentication are out of scope for cargo-n64, but there is more on the topic in the links below:

This means that the easiest way to workaround the IPL2 checksum is including a custom CIC implementation with the IPL3 code that sends the appropriate precomputed checksum to the PIF.

Note that the IPL2 checksum is not a problem on emulators or on carts like 64Drive and EverDrive64. These carts include an UltraCIC implementation and boot into a menu (using CIC-NUS-6102).

The 64Drive has a special "USB mode" that makes the cart act like a bare N64 cart with a selectable CIC when powered on with a USB cable plugged in. When running a ROM created with a custom IPL3 in USB mode, it is necessary to reprogram the CIC emulation on the 64drive with the appropriate precomputed checksum. Unfortunately, this is not currently supported by 64drive.

moparisthebest commented 2 years ago

Does https://github.com/hcs64/boot_stub meet the need? It doesn't have a license, but the comment says it's dedicated to the public domain.

parasyte commented 2 years ago

Unfortunately, that uses the RDRAM and cache init code from the official IPL3. But it's another one to add to the list. Thanks for the heads up.