Arcade Monitor Timing

First off, there is no such thing as standardized "perfect" Arcade Modes. Different games use different timings, different resolutions, and different vertical refresh-rates. It is normal to adjust your monitor a little when chaning games. Some examples (no monitor adjustments):

Duplicating the timings these games use perfectly, is probably not what most people want. What we're after is:

    • Exact vertical refresh according to the emulated game - i.e we don't want Moon Patrol to run at 60Hz, we want it to run at 57.0Hz
    • As far as possible, identical horizontal timing periods

A "standard" Arcade mode

This specification should give us some idea what we're after, we have to do some terminology decoding first though.


                   STANDARD RESOLUTION

          HORIZONTAL                    VERTICAL
Scan Frequency: 15.72 KHz    Scan Frequency: 60.0 Hz
   Scan Period: 63.6 µSec       Scan Period: 16.7 mSec
  Active Video: 46.9 µSec      Active Video: 15.3 mSec
   Video Delay: 11.9 µSec       Video Delay:  1.2 mSec
    Sync Pulse:  4.7 µSec        Sync Pulse:  0.2 mSec
     Scan Line: 456 Pixels           Screen: 262 Lines
    Resolution: 336 Pixels       Resolution: 240 Lines
    Clock Freq: 7.16 MHz

    • Scan Period = 63.6µS (A+B+C+D)
    • Active Video = 46.9µS (A)
    • Sync Pulse = 4.7 µS (C)
    • Video Delay = 11.9 (probably C+D)
    • Front Porch =(A+B+C+D)-(C+D)-(A)= 4.8 (B)
    • Back Porch = (A+B+C+D) - (A+B+C) = 7.2 (D)

In summary (A+B+C+D)=46.9 + 4.8 +4.7 + 7.2 = 63.6. These time units are our targets, and the next step is getting them into pixeltime so we can program our cards.


First off we need a horizontal resolution (A), lets start with 336. 336 pixels should take 46.9µS to draw, from this we can calculate how long one pixel should last: 46.9µS / 336 = 0.139583333. This is our tentative pixelclock value in microseconds.

    • The sync pulse should last 4.7µS, 4.7 / 0.139583333 = 33.67 pixelperiods
    • The front porch should last 4.8µS, 4.8 / 0.139583333 = 34.4 pixelperiods
    • The back porch should last 7.2µS, 7.2 / 0.139583333 = 51.6 pixelperiods

VGA cards do not operate with floating-point precison, but in integers that aremultiples of 8, so we have to do some rounding: 33.67=32, 34,4=32, 51,6=48. This gives us a A+B+C+D in pixeltime, 336+32+32+48=448 - our horizontal total in "pixels".

448*0.139583333 = 62.53µS, which is not exactly the 63.6µS we were after, so we do another iteration to get a more precise pixelclock: 63.6 / 448 =0.141964286. This pixelclock will give us an exact scanperiod, which is what we're after. The individual periods are not perfect due to rounding with multiples of 8, but the sum is. With the new pixelclock, we get

    • Horizontal Active = 336*pixclock = 47.7µS, error=-0.8µS
    • Front Porch = 32*pixclock=4.54µS, error=0.16µS
    • Sync Pulse = 32*pixclock=4.54µS, error=0.26
    • Back Porch = 48*pixclock=6.81µS, error=0.39

Not quite perfect, but perfectly fine - at these low resolutions, 8 pixelsperiods accounts for about 1µS, so this is pretty good. When making a script or program to generate these modes, it would probably be a good idea to use even more accurate targets, e.g use 1/15720 instead of 63.6. We now have what we need for the horizonal part of the mode:

mode "atarimode1"
  geometry 336 ?  336 ? 32
  timings 141964 48 32 ? ? 32 ?

Vertical resolution & Refresh

At 60Hz refresh, the total number of lines pr frames is 15720/60=262, including sync and porch. This nicely illustrates how everything is connected. If you want higher vertical resolutions, you either have to decrease the horizontal period, i.e draw the lines faster, or decrease the vertical refresh. In the case of fixed frequency monitors, our only option is to decrease the refresh rate, but for now let's stick with 60.0Hz and 240 visible lines. Vertical periods are multiples of the horizontal Scan Period, 1/15720 seconds in our case.

  • Vertical Scan Period (A+B+C+D) = (1/60)/(1/15720)=262.
  • Vertical Active Display (A) = 240.
  • Vertical sync pulse (C) should last 0.2mS, or 0,0002µS, which in pixeltime equals (0,0002)/(1/15720)=3.144, or 3 lines.
    I assume that video delay means C+D, resulting in a backporch of 1ms, in pixeltime (0,001)/(1/15720)=15.72=16 lines.
    Frontporch(B)=16.7-15.3-1.2=0.2, same length as the syncpulse=3 lines.

      • Vertical Active = 240*(1/15720)=15.27
      • Front Porch = 3*(1/15720)=0.19
      • Sync Pulse = 3*(1/15720)=0.19
      • Back Porch = 16*(1/15720)=1.02
    This completes the mode:
    mode "atarimode1"
      geometry 336 240 336 240 32
      timings 141964 48 32 16 3 32 3


    Another mode to illustrate, 800x224@57Hz (yessir:)). First off, we need to be aware of our targets, and our targets are time periods. We want the horizontal timings to be as identical as possible to the previous mode to avoid having to adjust our monitor, recalling (A+B+C+D)=46.9 + 4.8 +4.7 + 7.2 = 63.6.

      • Horizontal Active (A) =800 pixels = 46.9µS, giving a tentative pixelclock value of 46.9/800=0.058625 in microseconds.
      • Front Porch (B) = 4.8µS= 4.8/pixlock = 81.88 pixelperiods = 80 rounded
      • Sync Period (C) = 4.7µS= 4.7/pixclock = 80.17 pixelperiods = 80 rounded
      • Back Porch (D) = 7.2µS= 7.2/pixclock = 122.81 pixelperiods = 120 rounded

    Horizontal Scan Period (A+B+C+D)=800+80+80+120=1080 pixelperiods. We can now get the exact pixelclock to assure that A+B+C+D equals 63.61: pixclock = 63,61/1080=0.05890114, resulting in:
      • A=800*pixclock=47.1, error = -0.2µS
      • B=80*pixclock=4.7, error = 0.1µS
      • C=80*pixlcock=4.7, error = 0
      • D=120*pixclock=7.1, error = 0.1µS
    We now have the horizontal part of our mode:
    mode "unlikely1"
      geometry 800 224 800 224 32
      timings 58901 120 80 ? ? 80 ?
    Recalling that the number of lines equals HorizotalHz/VerticalHz, with 15.72kHz horizontal and 57Hz vertical, we have 15720/57=275.7895. At the risk of complicating too much, this seems like a highly unlikely number, and it is.

    Games that run with a 57.0Hz vertical frequency does not have a horizontal scanrate of 15.72kHz, but we will ignore this fact for now, and do our best to make something of practical value. Since we (and nobody else for that matter) cannot operate with half-lines, we have to round to 276 lines (A+B+C+D), giving us a vertical refresh of 15720/276=56.96Hz.

    Since the vertical periods are functions of the horizontal period (lines), and the lines take the same amount of time to draw no matter what the horizontal resolution, we can use some of the work from the previous mode - we want the sync-pulse(C) and the back-porch (D) to be the same, 3 and 16 lines.
    This leaves with a front porch of 276-224-3-16=33. We simply use the front-porch as a "padding" area. If we increased the vertical resolution, and drew black lines instead of using it for front-porch, the result would be exactly the same.