Baekalfen / PyBoy

Game Boy emulator written in Python
Other
4.57k stars 472 forks source link

Mask Rom Bank To Required Bits #305

Closed nishantc1527 closed 7 months ago

nishantc1527 commented 7 months ago

image Taken from here

Added this missing functionality to the mbc1 mapper. I am not sure of any games that would require this / break without this. Tests still pass.

Baekalfen commented 7 months ago

Hi, thank you for your PR! Have you identified any issue with not having this? Because I think it might be covered by the get method and % self.external_rom_count.

But I can see that we never check 0x148, but that might be good to do in general.

nishantc1527 commented 7 months ago

I did not notice the external_rom_count part, sorry. However, I noticed that this value is gotten from the length of the file. Could this be something else to fix? Because there are cases when the rom file is padded at the end for whatever reason leading to inaccuracies, and reading directly from 0x0148 will prevent inaccuracies.

Baekalfen commented 7 months ago

I did not notice the external_rom_count part, sorry. However, I noticed that this value is gotten from the length of the file. Could this be something else to fix? Because there are cases when the rom file is padded at the end for whatever reason leading to inaccuracies, and reading directly from 0x0148 will prevent inaccuracies.

No worries :) Would you like to do a quick survey, and check the games you have? It's allowed to be padded with zeros, but I have no idea how often the files don't match the bank count in 0x148.