pokemon-speedrunning / gambatte-speedrun

Fork of https://github.com/sinamas/gambatte with Pokemon speedrunning-related changes.
GNU General Public License v2.0
94 stars 27 forks source link

MBC30 or MBC3 with 4MB support #37

Closed nephitejnf closed 4 years ago

nephitejnf commented 4 years ago

This is a notable feature solely to JP Crystal, but doesn't work well when other hacks try to take advantage of it. BGB seems to be the only emulator out there and supports this well.

Dabomstew commented 4 years ago

Is there a spec for this somewhere or is it just a ROM declaring itself as MBC3 (cartridge type 10-13) with rom size 4MB (07)?

nephitejnf commented 4 years ago

I have a 4MB test rom, i'll upload it once I get home to my computer

nephitejnf commented 4 years ago

https://drive.google.com/file/d/1qJY6P0PWiPYn6nFYLQiifY9C-3BpIy7M/view?usp=sharing

nephitejnf commented 4 years ago

Other technicalities are explained here in a much better form https://github.com/visualboyadvance-m/visualboyadvance-m/issues/652

nephitejnf commented 4 years ago

https://github.com/mgba-emu/mgba/commit/ba11b8aa0cd8dca77efcd12913bbbfa74f69b04d https://github.com/LIJI32/SameBoy/commit/0ed5cf6b3879c0b7d6adfe769354e55fe04d1d1b Applicable commits on sameboy and mgba, if it helps

entrpntr commented 4 years ago

I am wondering about things like rgbds and pokecrystal-based projects, since they get tied up in this. Creating a game for MBC30 would have to be a deliberate choice if hardware is involved, since it's essentially a custom chip (it reports its cartridge type in the header with the same MBC3 identifier as the other Gen 2 Pokémon games; was only ever officially used for JP Crystal).

This doesn't seem like something that should be decided just because of the size of the ROM. pokecrystal-based projects could very conceivably exceed 2MB accidentally, and I'm not sure it's desirable for that to automatically toggle being MBC30-only (if the build toolchain hypothetically supported this scenario). RAM size wouldn't be any more reliable of an indicator to an emulator though, unless all MBC30 homebrew games standardized and reported having 64 KB of RAM.

On the other hand, since any 4 MB MBC3 ROM will necessarily be homebrew, devs may not care about about whether their game would be playable on a typical MBC3 cartridge, and making their game unplayable by blocking access past ROM bank $7f does seem a bit inappropriate.

So I'm not completely sure what the best solution is from the emulator's perspective for detecting an MBC3 ROM as MBC30; probably the SameBoy solution of either/or for ROM size/RAM size, and leave any hardware implications up to the dev.

entrpntr commented 4 years ago

Side note: BGB seems to essentially always emulate MBC3 as MBC30. There are theoretical implications for glitched speedruns, because normal MBC3 carts ignore bit 7 when selecting a ROM bank. (We noted technically inaccurate behavior when switching to bank $80 in Red/Blue and reading memory from $4000-$7fff.)

Side-side note: a preliminary MBC3 RTC testrom exists as of ~10 months ago testing some simple MBC3 RTC edge case behaviors. We currently fail some tests, which we can possibly address while fixing other stuff for MBC3/MBC30 address later; wonder if the testrom shows any different behavior on an MBC30 flashcart.

Dabomstew commented 4 years ago

MBC30 done as of b72accc, the edge cases can wait for a separate issue/PR.