#!/usr/bin/env python # # Patches and hooks for the binary translation of GAME.EXE. # Micah Elizabeth Scott <*****@*****.**> # import sys import sbt86 import bt_common b = sbt86.DOSBinary('build/game.exe') bt_common.patch(b) bt_common.patchChips(b) bt_common.patchLoadSave(b) b.decl("#include <stdio.h>") b.patchAndHook(b.findCode('2c01 :2f a2____ a2____ b12c 32ed'), 'nop', length=1, cCode=''' sassert(false, "Unimplemented DAS instruction\\n"); ''') b.writeCodeToFile('build/bt_game.cpp', 'GameEXE')
# # We want to start with GAME.EXE since it's the only binary that knows # about the fourth robot, but we trim out most of the code via # patching. Everything that modifies the world state can be removed, # since we're just rendering the state copied from another binary. # # Micah Elizabeth Scott <*****@*****.**> # import sbt86 import bt_common b = sbt86.DOSBinary('build/game.exe') bt_common.patch(b) bt_common.patchChips(b) # Skip command line parsing b.patch('0DAB:0005', 'jmp 0x005D') # Skip reading world data b.patch('0DAB:01A3', 'jmp 0x01CE') # Skip reading circuit data b.patch('0DAB:01F0', 'jmp 0x0219') # Statically remove all main loops other than Level 1, skip video mode # initialization, and skip chip loading. We still need to be sure to # run the sprite table initialization though, which is buried in the # same subroutine as chip loading. b.patch('0DAB:2C0F', 'jmp 0x66b5')