Fixed a bug where MBC RAM was no longer accessible after using the GB_reset functions

This commit is contained in:
Lior Halphon 2017-06-08 22:48:23 +03:00
parent a9475fbdf4
commit c650337928
1 changed files with 2 additions and 1 deletions

View File

@ -600,6 +600,7 @@ void GB_set_user_data(GB_gameboy_t *gb, void *data)
void GB_reset(GB_gameboy_t *gb)
{
uint32_t mbc_ram_size = gb->mbc_ram_size;
bool cgb = gb->is_cgb;
memset(gb, 0, (size_t)GB_GET_SECTION((GB_gameboy_t *) 0, unsaved));
gb->version = GB_STRUCT_VERSION;
@ -609,7 +610,7 @@ void GB_reset(GB_gameboy_t *gb)
gb->cgb_ram_bank = 1;
gb->io_registers[GB_IO_JOYP] = 0xF;
gb->io_registers[GB_IO_OBP0] = gb->io_registers[GB_IO_OBP1] = 0xFF;
gb->mbc_ram_size = mbc_ram_size;
if (cgb) {
gb->ram_size = 0x2000 * 8;
memset(gb->ram, 0, gb->ram_size);