First post, by DivByZero
- Rank
- Newbie
On my continuing quest to get my full list of classic games working on my 486 retro box, I've prepared another new patch, this time for the DOS text adventure game "The Hobbit", circa 1983. This game was unplayable on anything above a 286, with the game locking up right at the start with only the text "You are an" present. Turns out this one was due to polymorphic code and the prefetch cache. Notes from the patch below:
# This patch modifies HOBBIT.DAT from the 1983 DOS release of "The Hobbit" to fix a prefetch issue causing
# the game to crash on 386 or newer CPUs. This results in the game locking up as soon as it brings up the text
# interface, possibly with the text "You are an" being the only thing shown. The game was originally written
# for the 8086, which had a prefetch queue of 6 bytes. When the 386 came out, that increased to 16 bytes. The
# Hobbit used code which modified instructions only a few bytes ahead, with two NOP instructions (0x90) inserted
# between them to just reach the 6 bytes space required. This was insufficient on the 386, and the old data was
# stuck in the prefetch queue, causing the code to malfunction. This fix replaces the two successive NOP
# instructions with a branch instruction past itself. Since branches invalidate the prefetch queue, this flushes
# the old data from the queue and ensures the newly modified opcodes are read in instead.
Like my other patches, I kept the patch in python since it's transparent and self-documenting. If someone has a question about this 10 years from now, if I just drop an opaque 16-bit binary, that's going to be a pain. This script on the other hand does everything using a few regex expressions. As a python script, you won't be able to run this from dos, but once the files are patched you just need to transfer them onto your DOS machine.
Anyway, that's about it. Let me know if there are any questions or issues.