Created
December 24, 2014 23:36
-
-
Save Dhole/dc998ea525a208987a69 to your computer and use it in GitHub Desktop.
MBC1 read
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Read cartridge operation for MBC1 */ | |
| inline uint8_t mbc1_read(uint16_t addr) { | |
| if (addr < 0x4000) { | |
| /* 16KB ROM bank 00 */ | |
| return rom_gb[addr]; | |
| } else if (addr < 0x8000) { | |
| /* 16KB ROM Bank 01-7F */ | |
| return rom_gb[addr + 0x4000 * (rom_bank - 1)]; | |
| } else if (addr >= 0xA000 && addr < 0xC000) { | |
| /* 8KB RAM Bank 00-03, if any */ | |
| return ram[addr - 0xA000 + 0x2000 * ram_bank]; | |
| } | |
| return 0x00; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment