A Monte Carlo method is described for a reliable and highly accurate calculation of the total resolution function of a direct-geometry neutron time-of-flight spectrometer. The total resolution is made up of two components. The first is the purely instrumental part, which is described by the time-energy distribution of a typical neutron pulse. The second is the sample-dependent component, which enters in the form of a model scattering function at the sample position, scattering neutrons into the detectors. The simulated data are treated identically to the real data, for which the resolution is being calculated. In this way correlations or other systematic errors introduced into the data by the data reduction procedure are reproduced in the simulated data. The total resolution function is then obtained by fitting the model scattering function convoluted by a sufficiently flexible resolution peak shape function to the simulated data.