Time to put my hypothesis to test.
Who wants to check if this works?
#include <stdio.h>
#include <stdlib.h>
static FILE*fp;
static void Put(unsigned p,char*s,unsigned n)
{
fseek(fp,p,SEEK_SET); fwrite(s,n,1,fp);
}
int main(void)
{
fp = fopen("FAM60.EXE", "rb+");
if(!fp) { perror("FAM60.EXE"); return -1; }
Put(0x196FF, "\x88\x13\0\0", 4); /* mov a,5000 */
Put(0x28042, "\x88\x13\0\0", 4);
Put(0x28099, "\x88\x13\0\0", 4);
Put(0x19705, "\x51\x8B\x49\x14", 4); /* push c,mov c */
Put(0x1970E, "\x59\xEB\x0E", 3); /* pop c,jmp */
Put(0x28048, "\x8B\x0D\xD4\xDC\x46\x00", 6); /* mov c,x */
Put(0x280A5, "\x8B\x0D\xD4\xDC\x46\x00", 6);
Put(0x19709, "\x8D\x0C\x49\xF7\xF9", 5); /* lea,idiv */
Put(0x2804E, "\x8D\x0C\x49\xF7\xF9", 5);
Put(0x280AB, "\x8D\x0C\x49\xF7\xF9", 5);
Put(0x28053, "\xEB\x10", 2); /* jmp */
Put(0x280B0, "\x90", 1); /* nop */
Put(0x280B9, "\xBB\1\0\0\0\xEB\x0F", 7); /* mov b, jmp */
Put(0x28087, "\1", 1);
Put(0x28097, "\1", 1);
Put(0x28113, "\1", 1);
puts("done");
fclose(fp);
}
I can't test it very carefully right now, but it
seems to work.
I'm interested whether it fixes the timing problem.
As a zip file:
https://files.tasvideos.org/bisqwit/fam60.zip