MBC1 issues should be mostly fixed
This commit is contained in:
10
README.md
10
README.md
@@ -1,13 +1,17 @@
|
||||
# GameBoy++
|
||||
|
||||
## Limitations and Features
|
||||
|
||||
Currently supports 32 KiB roms and MBC1 roms.
|
||||
Currently passes [dmg-acid2](https://github.com/mattcurrie/dmg-acid2?tab=readme-ov-file), [blargg's cpu_instrs test](https://github.com/retrio/gb-test-roms/tree/master/cpu_instrs), and the [jsmoo SM83 JSON tests](https://github.com/raddad772/jsmoo-json-tests/tree/main/tests/sm83)
|
||||
Currently
|
||||
passes [dmg-acid2](https://github.com/mattcurrie/dmg-acid2?tab=readme-ov-file), [blargg's cpu_instrs test](https://github.com/retrio/gb-test-roms/tree/master/cpu_instrs),
|
||||
and the [jsmoo SM83 JSON tests](https://github.com/raddad772/jsmoo-json-tests/tree/main/tests/sm83)
|
||||
|
||||
Tested running Super Mario Land, Dr Mario and Tetris.
|
||||
Does not currently support MBC3 (needed for games like Pokemon) or loading saves. Some MBC1 games have issues still.
|
||||
Does not currently support MBC3 (needed for games like english versions of Pokemon Red and Blue) or loading saves.
|
||||
|
||||
## Building
|
||||
|
||||
`mkdir build && cd build`
|
||||
|
||||
`cmake ..`
|
||||
@@ -15,13 +19,13 @@ Does not currently support MBC3 (needed for games like Pokemon) or loading saves
|
||||
`./GameBoy++ <bios> <rom>`
|
||||
|
||||
## Controls
|
||||
|
||||
WASD is mapped to the d-pad
|
||||
|
||||
K and L are mapped to A and B
|
||||
|
||||
O and P are mapped to select and start
|
||||
|
||||
|
||||
H enters and exits debug mode
|
||||
|
||||
N steps through one instruction
|
||||
|
||||
30
src/mbc.cpp
30
src/mbc.cpp
@@ -68,16 +68,37 @@ Byte* AddressSpace::MBCRead(const Word address) {
|
||||
}
|
||||
|
||||
void AddressSpace::MBCUpdate() {
|
||||
//TODO: multicart roms need to be able to switch the first rom bank as well
|
||||
//see: https://gbdev.io/pandocs/MBC1.html
|
||||
if (MBC == MBC1) {
|
||||
//TODO: multicart roms need to be able to switch the first rom bank as well
|
||||
//see: https://gbdev.io/pandocs/MBC1.html
|
||||
|
||||
//Selected ROM Bank = (Secondary Bank << 5) + ROM Bank
|
||||
romBankRegister &= 0x1F;
|
||||
twoBitBankRegister &= 0x3;
|
||||
|
||||
//512 KiB can only have 8KiB of ram
|
||||
if (romSize > 524288) {
|
||||
if (romSize >= 524288) {
|
||||
if (romBankRegister == 0)
|
||||
selectedRomBank = (twoBitBankRegister << 5) + 1;
|
||||
selectedRomBank = (twoBitBankRegister << 5) + romBankRegister;
|
||||
}
|
||||
else {
|
||||
if (romBankRegister == 0)
|
||||
selectedRomBank = 1;
|
||||
else
|
||||
selectedRomBank = romBankRegister;
|
||||
}
|
||||
selectedExternalRamBank = 0;
|
||||
|
||||
loadRomBank();
|
||||
loadRamBank();
|
||||
}
|
||||
if (MBC == MBC1Ram || MBC == MBC1RamBattery) {
|
||||
//Selected ROM Bank = (Secondary Bank << 5) + ROM Bank
|
||||
romBankRegister &= 0x1F;
|
||||
twoBitBankRegister &= 0x3;
|
||||
|
||||
//512 KiB can only have 8KiB of ram
|
||||
if (romSize >= 524288) {
|
||||
if (romBankRegister == 0)
|
||||
selectedRomBank = (twoBitBankRegister << 5) + 1;
|
||||
selectedRomBank = (twoBitBankRegister << 5) + romBankRegister;
|
||||
@@ -93,7 +114,6 @@ void AddressSpace::MBCUpdate() {
|
||||
loadRomBank();
|
||||
loadRamBank();
|
||||
}
|
||||
if (MBC == MBC1Ram || MBC == MBC1RamBattery) {}
|
||||
}
|
||||
|
||||
void AddressSpace::loadRomBank() {
|
||||
|
||||
Reference in New Issue
Block a user