Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rejects ROMs as invalid #43

Open
basxto opened this issue Feb 14, 2022 · 4 comments
Open

Rejects ROMs as invalid #43

basxto opened this issue Feb 14, 2022 · 4 comments

Comments

@basxto
Copy link
Contributor

basxto commented Feb 14, 2022

334B is the minimum size needed. 334th Byte is the header checksum, which is the last header byte touched by the bootrom. Global checksum doesn't get verified. SIERPINSKIBOY should therefore have everything, the bootrom needs.

$ bin/binjgb testrom/sierpinskiboy.smol.cgb
/tmp/binjgb/src/emulator.c:4847: File size (334) should be a multiple of minimum rom size (32768).

TINYMIRRORBOY has the correct first half of the Nintendo logo and a correct header checksum. That's everything CGB needs to boot.

$ bin/binjgb testrom/tinymirrorboy.mirrored.32k.cgb
/tmp/binjgb/src/emulator.c:1178: Invalid ROM.

These ROMs work on Sameboy, Emulicious and BGB. And they also boot with EVERDRIVE GB X3 on my CGB-D.

@binji
Copy link
Owner

binji commented Feb 22, 2022

You're right, I added these checks a long time ago, but never verified they were correct. I'll see if I can remove them so these roms will work.

@basxto
Copy link
Contributor Author

basxto commented Feb 22, 2022

I don’t know if they will really work, but it would be great if they at least started.
They strongly depend on registers set by CGB bootrom and that the (modified) nintendo logo gets upscaled and loaded into vram. SIERPINKSIBOY further depends on builtin color palettes for pre-cgb nintendo games and that the sound registers are initialized from the start bling. Both run in CGB’s DMG mode, but are intentionally incompatible with DMG and SGB.
Those are the things, I actually wanted to test.

@binji
Copy link
Owner

binji commented Feb 22, 2022

Oh, those things almost certainly won't work haha! Maybe not too hard to set some initial state to allow it though.

@basxto
Copy link
Contributor Author

basxto commented Feb 22, 2022

The initial state is quite complex, if I remember correctly in CGB’s DMG mode with the licensee set to nintendo, one register will be a leftover of the title checksum calculation and that depends on the title of the ROM.
The logo is also a bit more complicated algorithm, because it upscales the 4x4 logo stored on the ROM to 8x8 and my demos abuse that to load a custom 4x4 font.
Easiest solution is probably to support bootroms, I don’t know what they all need, execution starts at `0x0. Since they overlay the actual ROM, there has to be some mechanism to to switch to the game ROM. CGB has a byte with which the bootrom enables/disables CGB mode, in DMG mode it enables it to set up the palettes and then disables it.
Sameboy is also MIT licensed and it has custom BootROMs available, where it should be enough to change SameBoyLogo.png to BINJGB.
Or just allow to boot with a user specified bootrom, though I don’t know how that would work in webasm then.

binji added a commit that referenced this issue Mar 30, 2022
* ROMs will be rounded up to the nearest 32KiB and filled with zeroes.
* Still attempt to run the game even if the GB header info isn't valid.
* Don't print any non-ascii characters in the title

Partial fix for #43.
binji added a commit that referenced this issue Sep 16, 2023
See #43 and #49. This will resize the ROM and pad with 0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants