Have a global variable g_MemoryEnd that you modify on bootup depending on if g_RemasterMode is set (and the particular memory size of the game), instead.