changeset 2279:3b5fef896475

Fix edge case in m68k_invalidate_code_range that caused problems when loading save states
author Michael Pavone <pavone@retrodev.com>
date Sun, 08 Jan 2023 14:20:43 -0800
parents 5a21bc0ec583
children 9ead0fe69d9b
files m68k_core_x86.c
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/m68k_core_x86.c	Mon Jan 02 13:08:49 2023 -0800
+++ b/m68k_core_x86.c	Sun Jan 08 14:20:43 2023 -0800
@@ -2528,10 +2528,10 @@
 		//calculate the lowest alias for this address
 		start = mem_chunk->start + ((start - mem_chunk->start) & mem_chunk->mask);
 	}
-	mem_chunk = find_map_chunk(end, &opts->gen, 0, NULL);
+	mem_chunk = find_map_chunk(end - 1, &opts->gen, 0, NULL);
 	if (mem_chunk) {
 		//calculate the lowest alias for this address
-		end = mem_chunk->start + ((end - mem_chunk->start) & mem_chunk->mask);
+		end = mem_chunk->start + ((end - 1 - mem_chunk->start) & mem_chunk->mask) + 1;
 	}
 	uint32_t start_chunk = start / NATIVE_CHUNK_SIZE, end_chunk = end / NATIVE_CHUNK_SIZE;
 	for (uint32_t chunk = start_chunk; chunk <= end_chunk; chunk++)