bsnes icon indicating copy to clipboard operation
bsnes copied to clipboard

Make SGB boot ROMs optional

Open TiKevin83 opened this issue 3 years ago • 6 comments

bd8e94a implementing SameBoy for SGB emulation was written in such a way that copyrighted binaries are baked into the bsnes codebase. CasualPokePlayer noticed that in BizHawk's recent bsnes update the copyrighted code had leaked into BizHawk. The firmware should instead be providable by the user with a fallback to use SameBoy's homebrew bootroms or a known state of the emulator post-bootROM.

https://github.com/bsnes-emu/bsnes/blob/bd8e94a7c7cbfdf7ac0b7f24ce06fa219e7e5974/bsnes/sfc/coprocessor/icd/boot-roms.cpp

TiKevin83 avatar Jul 09 '21 05:07 TiKevin83

bsnes has always included a binary of the 64-byte SNES initial-program loader ROM (1, 2), assuming (without the advice of a lawyer, so far as I can tell) that it was too small to be copyrighted.

Eventually Near got sufficiently sick of dealing with end-user support requests ("I made a legal backup of my Super Game Boy cart, but it won't run!") that he decided to include the 256-byte SGB initial-program loader ROMs too, under the same justification.

I don't know that Near's justification makes sense, but I don't know that it doesn't make sense either. Since bsnes has made the international news two or three times in its current state, I'm inclined to leave things the way they are until somebody provides firm evidence one way or the other.

Screwtapello avatar Jul 09 '21 08:07 Screwtapello

But thank you for bringing the matter to my attention.

Screwtapello avatar Jul 09 '21 08:07 Screwtapello

The 64 byte SNES IPL might possibly be too small to sufficiently copyright due to triviality of the code (at least, as far as I'm reading it's literally init the stack pointer, init zero some RAM, then wait for the SNES to send data? something like that you could perhaps end up with a very close match just doing a homebrew equivalent). Although, still, it would probably be better to just have execution start post IPL anyways, with the state expected from that. But I regress.

Still, the SGB bootroms I would argue would not fall under being too trivial, and are at the very least as copyrightable as the original DMG bootroms. And can easily be substituted for homebrew bootroms (provided by SameBoy itself, which uses them for its own SGB HLE emulation).

Of course I'm not responsible for this repo, and I understand why this isn't as big as a concern by your perspective, so /shrug.

CasualPokePlayer avatar Jul 09 '21 09:07 CasualPokePlayer

Now that I think about it, all other things being equal, it'd be nice for bsnes to support both high-level emulation (initialising the hardware to a post-boot-ROM state) and low-level-emulation (actually executing the boot ROM), in the same way it supports both HLE and LLE of the DSP1 co-processor. I have no idea how difficult that would be to do with bsnes' architecture, and I have no idea what the compatibility consequences would be (there must be some, otherwise why would SameBoy provide a homebrew boot ROM?), but I would merge a patch that didn't regress compatibility very much, didn't make the code too messy, and made the SGB boot ROMs optional.

Screwtapello avatar Jul 09 '21 12:07 Screwtapello

I asked LIJI (SameBoy's author) about this, and he replied:

...the CGB boot ROM includes quite a few features compared to the older boot ROMs, so HLE of them is even more effort than providing your own boot ROMs. It also removes the requirement for having a separate flow for using SameBoy without a boot ROM

Also, on both the SGB and the CGB, the initial state depends quite a lot on the ROM header, accurate initial state might prove problematic due to this

And keep in mind SameBoy's boot ROMs affect RNG because they're not timing accurate, so if you want to play a valid speed run on SameBoy (or bsnes+SameBoy for that matter) you must use the official boot ROMs for that

Since bsnes doesn't emulate the CGB, that part isn't relevant.

For bsnes, it sounds like initialising the hardware to a "standard" post-boot-ROM state is likely to have compatibility consequences. That's not necessarily a deal-breaker, but I'd be interested to know what proportion of games break (20%? 5%? 1%? 0.1%?)

For BizHawk, an emulator designed for speedrunning, it sounds like neither HLE nor SameBoy's homebrew boot ROM are suitable and it should demand an original SGB boot ROMs in order to enable SGB emulation.

Screwtapello avatar Jul 09 '21 14:07 Screwtapello

Games would likely not "break" outright unless they rely on start up timing to be exact (which is more effectively limited to some homebrew demos and test roms).

For BizHawk, while it is designed for speedrunners, it is also designed for casual gamers. Thus homebrew/HLE solutions are often available for them. Unless you care about 100% exact timing with console (which you arguably aren't a casual gamer at that point), the homebrew/HLE solutions are fine.

CasualPokePlayer avatar Jul 09 '21 18:07 CasualPokePlayer