# HG changeset patch # User Michael Pavone # Date 1484069368 28800 # Node ID 9fc680b35dbbd775fc2f02de5acb95d0e0554239 # Parent 21df13266e6af69f65c48283d693c0620590993d Fix crash regression for games with some kind of mapper functionality diff -r 21df13266e6a -r 9fc680b35dbb genesis.c --- a/genesis.c Tue Jan 10 09:19:58 2017 -0800 +++ b/genesis.c Tue Jan 10 09:29:28 2017 -0800 @@ -961,13 +961,12 @@ gen->save_storage = NULL; } + //This must happen before we generate memory access functions in init_m68k_opts for (int i = 0; i < rom->map_chunks; i++) { - if (rom->map[i].flags & MMAP_PTR_IDX) { - gen->m68k->mem_pointers[rom->map[i].ptr_index] = rom->map[i].buffer; - } if (rom->map[i].start == 0xE00000) { rom->map[i].buffer = gen->work_ram; + break; } } @@ -978,6 +977,14 @@ gen->m68k = init_68k_context(opts, NULL); gen->m68k->system = gen; opts->address_log = (system_opts & OPT_ADDRESS_LOG) ? fopen("address.log", "w") : NULL; + + //This must happen after the 68K context has been allocated + for (int i = 0; i < rom->map_chunks; i++) + { + if (rom->map[i].flags & MMAP_PTR_IDX) { + gen->m68k->mem_pointers[rom->map[i].ptr_index] = rom->map[i].buffer; + } + } return gen; }