summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2016-04-30 20:57:29 -0700
committerMichael Pavone <pavone@retrodev.com>2016-04-30 20:57:29 -0700
commit5be1df76921a1f7ad103dca3e7f731fa4a53d254 (patch)
treeb76eca01529d420f487f57d371622f20d3e7dbe4
parent71de7d6f718cd6d0e5110c0a3db52a680a8554c4 (diff)
Fix bug in SAT cache address calculation that caused a crash in Strider II
-rw-r--r--vdp.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/vdp.c b/vdp.c
index 4c764fa..e86407e 100644
--- a/vdp.c
+++ b/vdp.c
@@ -518,13 +518,15 @@ void vdp_advance_dma(vdp_context * context)
context->cd &= 0xF;
}
}
-
+#include <assert.h>
void write_vram_byte(vdp_context *context, uint16_t address, uint8_t value)
{
if (!(address & 4)) {
uint16_t sat_address = (context->regs[REG_SAT] & 0x7F) << 9;
- if(address >= sat_address && address <= sat_address + SAT_CACHE_SIZE*2) {
- context->sat_cache[(address & 3) | (address >> 1 & 0x1FC)] = value;
+ if(address >= sat_address && address < (sat_address + SAT_CACHE_SIZE*2)) {
+ uint16_t cache_address = address - sat_address;
+ cache_address = (cache_address & 3) | (cache_address >> 1 & 0x1FC);
+ context->sat_cache[cache_address] = value;
}
}
context->vdpmem[address] = value;