From 1e0d602672f65189bf85556d13f4c1c545045c70 Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Wed, 14 Apr 2010 14:52:34 +0300 Subject: [PATCH] Wrap 16-bit addresses in protected mode A16 REP STOSx Jazz Jackrabbit appears to execute A16 REP STOSB on bonus level entry that crosses 64KiB limit. Make this wrap around to zero address, not crash with GPF. --- .../memory/codeblock/optimised/ProtectedModeUBlock.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/org/jpc/emulator/memory/codeblock/optimised/ProtectedModeUBlock.java b/org/jpc/emulator/memory/codeblock/optimised/ProtectedModeUBlock.java index 2ea0172..938c675 100644 --- a/org/jpc/emulator/memory/codeblock/optimised/ProtectedModeUBlock.java +++ b/org/jpc/emulator/memory/codeblock/optimised/ProtectedModeUBlock.java @@ -3413,14 +3413,14 @@ public class ProtectedModeUBlock implements ProtectedModeCodeBlock //check hardware interrupts cpu.es.setByte(addr, (byte)data); count--; - addr -= 1; + addr = (addr - 1) & 0xFFFF; } } else { while (count != 0) { //check hardware interrupts cpu.es.setByte(addr, (byte)data); count--; - addr += 1; + addr = (addr + 1) & 0xFFFF; } } } @@ -3471,14 +3471,14 @@ public class ProtectedModeUBlock implements ProtectedModeCodeBlock //check hardware interrupts cpu.es.setWord(addr, (short)data); count--; - addr -= 2; + addr = (addr - 2) & 0xFFFF; } } else { while (count != 0) { //check hardware interrupts cpu.es.setWord(addr, (short)data); count--; - addr += 2; + addr = (addr + 2) & 0xFFFF; } } } @@ -3529,14 +3529,14 @@ public class ProtectedModeUBlock implements ProtectedModeCodeBlock //check hardware interrupts cpu.es.setDoubleWord(addr, data); count--; - addr -= 4; + addr = (addr - 4) & 0xFFFF; } } else { while (count != 0) { //check hardware interrupts cpu.es.setDoubleWord(addr, data); count--; - addr += 4; + addr = (addr + 4) & 0xFFFF; } } } -- 2.11.4.GIT