changeset 1964:9d35ce5012a6

Apply fixes to helper functions in backend.c from interp branch
author Michael Pavone <pavone@retrodev.com>
date Sun, 03 May 2020 23:24:03 -0700
parents 495569c1dc61
children 3a46ff899fa6
files backend.c
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/backend.c	Tue Apr 28 22:03:04 2020 +1000
+++ b/backend.c	Sun May 03 23:24:03 2020 -0700
@@ -160,7 +160,7 @@
 	if (!chunk) {
 		return;
 	}
-	uint32_t offset = (address - chunk->start) & chunk->mask;
+	uint32_t offset = address & chunk->mask;
 	if (chunk->flags & MMAP_WRITE) {
 		uint8_t *base;
 		if (chunk->flags & MMAP_PTR_IDX) {
@@ -210,6 +210,8 @@
 					return 0xFF;
 				}
 				offset /= 2;
+			} else if(opts->byte_swap) {
+				offset ^= 1;
 			}
 			return base[offset];
 		}
@@ -244,6 +246,8 @@
 					return;
 				}
 				offset /= 2;
+			} else if(opts->byte_swap) {
+				offset ^= 1;
 			}
 			base[offset] = value;
 		}