diff options
author | Michael Pavone <pavone@retrodev.com> | 2017-06-19 19:18:50 -0700 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2017-06-19 19:18:50 -0700 |
commit | 2fc5425f96a03d2814ba544e31590699c8c3e75f (patch) | |
tree | 83e2ca07647660dd368eacfa7aaa269dcf0907ba | |
parent | 86aab4a244c6537ec09ca9adf17661dc5736e332 (diff) |
Better handling of S&K lock on support. Pre-combined ROMs and large (>2MB) S&K hacks should now work. Implemented correct behavior from locking on a 4MB cart
-rw-r--r-- | rom.db | 1 | ||||
-rw-r--r-- | romdb.c | 15 |
2 files changed, 13 insertions, 3 deletions
@@ -443,6 +443,7 @@ MK-1563 { 200000 { device LOCK-ON last 3FFFFF + offset 200000 } } } @@ -1028,13 +1028,22 @@ void map_iter_fun(char *key, tern_val val, uint8_t valtype, void *data) map->flags = MMAP_READ; map->mask = calc_mask(state->rom_size - offset, start, end); } else if (!strcmp(dtype, "LOCK-ON")) { - if (!state->lock_on) { + if (state->lock_on) { + if (state->lock_on_size > offset) { + map->mask = calc_mask(state->lock_on_size - offset, start, end); + } else { + map->mask = calc_mask(state->lock_on_size, start, end); + } + map->buffer = state->lock_on + (offset & (nearest_pow2(state->lock_on_size) - 1)); + } else if (state->rom_size > start) { + //This is a bit of a hack to deal with pre-combined S3&K/S2&K ROMs and S&K ROM hacks + map->buffer = state->rom + start; + map->mask = calc_mask(state->rom_size - start, start, end); + } else { //skip this entry if there is no lock on cartridge attached return; } - map->buffer = state->lock_on + offset; map->flags = MMAP_READ; - map->mask = calc_mask(state->lock_on_size - offset, start, end); } else if (!strcmp(dtype, "EEPROM")) { process_eeprom_def(key, state); add_eeprom_map(node, start, end, state); |