Skip to content

Commit 868c191

Browse files
committed
GBC: Removed unecessary memset in mem_updatemap()
1 parent 5283e66 commit 868c191

File tree

1 file changed

+15
-8
lines changed
  • gnuboy-go/components/gnuboy

1 file changed

+15
-8
lines changed

gnuboy-go/components/gnuboy/mem.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ void IRAM_ATTR mem_updatemap()
3838
rom_loadbank(mbc.rombank);
3939
}
4040

41-
memset(mbc.rmap, 0, sizeof(mbc.rmap));
42-
memset(mbc.wmap, 0, sizeof(mbc.wmap));
43-
4441
// ROM
4542
mbc.rmap[0x0] = rom.bank[0];
4643
mbc.rmap[0x1] = rom.bank[0];
@@ -54,21 +51,28 @@ void IRAM_ATTR mem_updatemap()
5451
mbc.rmap[0x6] = rom.bank[mbc.rombank] - 0x4000;
5552
mbc.rmap[0x7] = rom.bank[mbc.rombank] - 0x4000;
5653
}
54+
else
55+
{
56+
mbc.rmap[0x4] = NULL;
57+
mbc.rmap[0x5] = NULL;
58+
mbc.rmap[0x6] = NULL;
59+
mbc.rmap[0x7] = NULL;
60+
}
5761

5862
// Video RAM
5963
mbc.rmap[0x8] = mbc.wmap[0x8] = lcd.vbank[R_VBK & 1] - 0x8000;
6064
mbc.rmap[0x9] = mbc.wmap[0x9] = lcd.vbank[R_VBK & 1] - 0x8000;
6165

6266
// Backup RAM
63-
if (mbc.enableram && !(rtc.sel & 8))
64-
{
65-
// mbc.rmap[0xA] = mbc.wmap[0xA] = ram.sbank[mbc.rambank] - 0xA000;
66-
// mbc.rmap[0xB] = mbc.wmap[0xB] = ram.sbank[mbc.rambank] - 0xA000;
67-
}
67+
mbc.rmap[0xA] = NULL;
68+
mbc.rmap[0xB] = NULL;
6869

6970
// Work RAM
7071
mbc.rmap[0xC] = mbc.wmap[0xC] = ram.ibank[0] - 0xC000;
7172

73+
// ?
74+
mbc.rmap[0xD] = NULL;
75+
7276
// IO port and registers
7377
mbc.rmap[0xF] = mbc.wmap[0xF] = NULL;
7478
}
@@ -565,6 +569,9 @@ void mem_reset(bool hard)
565569
memset(ram.sbank, 0xff, 8192 * mbc.ramsize);
566570
}
567571

572+
memset(mbc.rmap, 0, sizeof(mbc.rmap));
573+
memset(mbc.wmap, 0, sizeof(mbc.wmap));
574+
568575
// Mark all sectors as dirty and wait for sram_dirty to trigger
569576
memset(ram.sram_dirty_sector, 1, 256);
570577
ram.sram_dirty = 0;

0 commit comments

Comments
 (0)