Warning: this method was developed for multisync monitors. It will probably work with fixed-frequency monitors as well, but no guarantees!
Start by dividing DCF by your highest available HSF to get a horizontal frame length.
For example; suppose you have a Sigma Legend SVGA with a 65MHz dot clock, and your monitor has a 55KHz horizontal scan frequency. The quantity (DCF / HSF) is then 1181 (65MHz = 65000KHz; 65000/55 = 1181).
Now for our first bit of black magic. You need to round this figure to the nearest multiple of 8. This has to do with the VGA hardware controller used by SVGA and S3 cards; it uses an 8-bit register, left-shifted 3 bits, for what's really an 11-bit quantity. Other card types such as ATI 8514/A may not have this requirement, but we don't know and the correction can't hurt. So round the usable horizontal frame length figure down to 1176.
This figure (DCF / HSF rounded to a multiple of 8) is the minimum HFL you can use. You can get longer HFLs (and thus, possibly, more horizontal dots on the screen) by setting the sync pulse to produce a lower HSF. But you'll pay with a slower and more visible flicker rate.
As a rule of thumb, 80% of the horizontal frame length is available for horizontal resolution, the visible part of the horizontal scan line (this allows, roughly, for borders and sweepback time -- that is, the time required for the beam to move from the right screen edge to the left edge of the next raster line). In this example, that's 940 ticks.
Now, to get the normal 4:3 screen aspect ratio, set your vertical resolution to 3/4ths of the horizontal resolution you just calculated. For this example, that's 705 ticks. To get your actual VFL, multiply that by 1.05 to get 740 ticks.
The 4:3 is not technically magic; nothing prevents you from using a different ratio if that will get the best use out of your screen real estate. It does make figuring frame height and frame width from the diagonal size convenient, you just multiply the diagonal by by 0.8 to get width and 0.6 to get height.
So, HFL=1176 and VFL=740. Dividing 65MHz by the product of the two gives us a nice, healthy 74.6Hz refresh rate. Excellent! Better than VESA standard! And you got 944x705 to boot, more than the 800 by 600 you were probably expecting. Not bad at all!
You can even improve the refresh rate further, to almost 76 Hz, by using the fact that monitors can often sync horizontally at 2khz or so higher than rated, and by lowering VFL somewhat (that is, taking less than 75% of 940 in the example above). But before you try this "overdriving" maneuver, if you do, make sure that your monitor electron guns can sync up to 76 Hz vertical. (the popular NEC 4D, for instance, cannot. It goes only up to 75 Hz VSF). (See Overdriving Your Monitor for more general discussion of this issue. )
So far, most of this is simple arithmetic and basic facts about raster displays. Hardly any black magic at all!