ciaran2 / pyGB

An emulator for the Nintendo GameBoy written in Python.
MIT License
0 stars 1 forks source link

Mbc1Cartrige.__getitem__ -> None return value #2

Open zstewar1 opened 8 years ago

zstewar1 commented 8 years ago

Mbc1Cartridge.__getitem__ will return None for RAM addresses when ram_enable is off.

Is this intended behavior? It seems to me like a more obvious default action would be to return 0x0, and I haven't checked, but that seems more like what hardware would do if you accessed a disabled thing.

Unless that action is supposed to signal an interrupt or something and None is a sigil return value to tell the emulator to trigger that interrupt, but if that is the case, then None should probably be returned explicitly, and a comment should be added explaining why, when all the other functions return integers.

ciaran2 commented 8 years ago

Oops. Definitely a bug. Feel free to fix.

zstewar1 commented 8 years ago

Will wait until after #3, since this function also uses [] indexing on str variables in Python 2, when it should return an int. (The behavior should be correct in Python 3 because there the type will be bytes, which indexes to int, while in Python 2, bytes == str, which indexes to str).

Once #3 is merged, this can be rectified and made cross compatible by using six.indexbytes to always get an int in both 2 and 3.