src/memory.c
static void gb_memory_change_rom_bank(gb_memory *mem, int bank)
{
    if (mem->current_rom_bank == bank)
        return;

    if (munmap(mem->mem + 0x4000, 0x4000) != 0) {
        LOG_ERROR("munmap failed (%i)\n", errno);
        return;
    }

    if (mmap(mem->mem + 0x4000, 0x4000, PROT_READ, MAP_PRIVATE | MAP_FIXED,
             mem->fd, 0x4000 * bank) == MAP_FAILED) {
        LOG_ERROR("mmap failed! (%i)\n", errno);
        return;
    }

    mem->current_rom_bank = bank;
}
/* change ROM bank to bank if supported */
change ROM bank to bank if supported
change ROM bank to bank if supported
static void gb_memory_change_rom_bank(gb_memory *mem, int bank)
{
    if (mem->current_rom_bank == bank)
        return;
    if (munmap(mem->mem + 0x4000, 0x4000) != 0) {
        LOG_ERROR("munmap failed (%i)\n", errno);
        return;
    }
    if (mmap(mem->mem + 0x4000, 0x4000, PROT_READ, MAP_PRIVATE | MAP_FIXED,
             mem->fd, 0x4000 * bank) == MAP_FAILED) {
        LOG_ERROR("mmap failed! (%i)\n", errno);
        return;
    }
    mem->current_rom_bank = bank;
}
static void gb_memory_change_rom_bank ( gb_memory * mem , int bank ) { if ( mem -> current_rom_bank == bank ) return ; if ( munmap ( mem -> mem + 0x4000 , 0x4000 ) != 0 ) { LOG_ERROR ( " \n " , errno ) ; return ; } if ( mmap ( mem -> mem + 0x4000 , 0x4000 , PROT_READ , MAP_PRIVATE | MAP_FIXED , mem -> fd , 0x4000 * bank ) == MAP_FAILED ) { LOG_ERROR ( " \n " , errno ) ; return ; } mem -> current_rom_bank = bank ; }
change ROM bank to bank if supported
change ROM bank to bank if supported