summaryrefslogtreecommitdiff
path: root/backend.c
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2020-05-03 23:24:03 -0700
committerMichael Pavone <pavone@retrodev.com>2020-05-03 23:24:03 -0700
commit11667366054d2c76cfe55713210e7bb0b1d2f22b (patch)
treedf39f31d9bd01a6aeed9d714c93c0539c7c674ed /backend.c
parent8adaf00407538f09d5d0cf306c4100611a5aa8af (diff)
Apply fixes to helper functions in backend.c from interp branch
Diffstat (limited to 'backend.c')
-rw-r--r--backend.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/backend.c b/backend.c
index 595e9da..38cc45b 100644
--- a/backend.c
+++ b/backend.c
@@ -160,7 +160,7 @@ void write_word(uint32_t address, uint16_t value, void **mem_pointers, cpu_optio
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 @@ uint8_t read_byte(uint32_t address, void **mem_pointers, cpu_options *opts, void
return 0xFF;
}
offset /= 2;
+ } else if(opts->byte_swap) {
+ offset ^= 1;
}
return base[offset];
}
@@ -244,6 +246,8 @@ void write_byte(uint32_t address, uint8_t value, void **mem_pointers, cpu_option
return;
}
offset /= 2;
+ } else if(opts->byte_swap) {
+ offset ^= 1;
}
base[offset] = value;
}