VGATV Version 2.0
By Paulo Srgio Coelho, 1997

Last updated: March 2nd, 1997

--- Impatient ? -----------------

  Ok, just enter this: VGATV /? for a short help on which parameters suit you
best.  Entering VGATV, loads the driver with PAL timings, and will try to
determine which VGA chipset is present, otherwise will just support plain VGA.
Supports VESA at all times, though might work better if the chipset is
recognized earlier.

  Parameters can be entered in any order, and are case insensitive.

  /? - Prints a short help text, so you can get a general idea on how to use
       the program;

  /IBM - makes the program ignore any chipset on the system, which might be
         useful if the program improperly detects your VGA card;
  /OAK - to support the Oak series VGA boards. Note that the Oak 037 chipset
         doesn't have interlace support. Also, the Oak 083/087 chipset doesn't
         allow full-screen low-resolution modes (320x200 at 4 or 16 colors) so
         the normal, standard setting must be used. Other Oaks do, however.
  /S3 - supports the S3 range of chipsets, not fully supported yet;
  /CIRRUS - same thing for Cirrus Logic chipsets, not fully supported yet;
  /TSENG - Tseng Labs, not supported yet;
  /TRIDENT - Trident VGA cards, not full supported yet; and,

  /NTSC - chooses NTSC timings, instead of PAL timings.

--- The program -----------------

  This program allows you to use your TV as a monitor, given that you use the
proper hardware to connect your VGA to the output equipment.

  The driver is a TSR (Terminate and Stay Resident) which will try to make
sure your VGA card is, at all times, properly programmed for TV timings, which
are quite different from VGA standards:

  - VGA timings are normally 31.469KHz horizontal frequency, and 70.08Hz
    vertical frequency. Non-interlaced.

  - PAL and NTSC are interlaced. PAL (Phase Alternating Line) has a horizontal
    frequency of 15.625Khz and 50Hz vertical frequency. NTSC (National
    Television Standards Committee) has 15.750Khz and 60Hz respectively.

  There will be programs which won't work well, others won't work at all,
because they either use an unsupported video mode, or program the video card
directly, after they've set the mode.

  Supported resolutions so far: due to the way the program works, resolutions
"per si"  are not supported, but rather widths, height and combinations among
them. This makes the driver more flexible among different SVGA chipsets.
  Thus, screen modes with the following dots per line (either logically or
viewable) are supported: 320, 512, 640, 768, 800, 960, 1024, 1056, 1152, 1280
and 1600.
  Screen modes with these number of lines are also supported (fully viewable
or not, depending on the mode, chipset and the TV standard being used):
  175/350, 192/384/768, 200/400, 216/432/864, 240/480, 256/512/1024, 300/600/
/1200 and 320/640/1280 lines.
  A screen mode can appear with any combination of these, so the program ought
to support a fair number of display modes, covering a wide array of video cards
and some of their more exotic display modes... Also, VESA support is straight-
forward.

  There is no limit on the number of colours. However, due to the way some of
the higher colour mode modes are programmed, some of them may not be usable
under certain cards. For example, while I don't support 640x480x16.7M colors
in the Oak chipset, that mode is supported on the Cirrus Logic chipset.


--- The keys --------------------

  Ctrl+Alt+D will uninstall the program, provided nothing else got in it's way
like another TSR. After successful unloading the program, the screen will get
back to VGA mode.

  Ctrl+Alt+R resets the current video mode, so that if some crappy program
messed your screen, you can restore it back to normal. Also works when in VGA
mode.

  Ctrl+Alt+S swaps between VGA and TV modes.

--- The requirements ------------

  For this to work, you need the following:

  a) a IBM PC or compatible computer system (clone for short :-). And yes,
     your 4.77Mhz IBM PC will do;

  b) a VGA card;

  c) some memory to load this driver; if you can run DOS, you can run this.
     To save memory, you can try loading it high. Like :

     LH VGATV in AUTOEXEC.BAT

  Optionally, you can also have this:

  d) some hardware for the video connection, described below, without which,
     this whole thing just becomes an academic exercise...;

  e) a BIG screen TV, for those games;

  f) a VCR for saving those presentations;

  g) a sound board connected to your Hi-Fi system, with volume turned fully
     clockwise, or at the point where neighbours start to complain :-)

  h) some application software (a game _IS_ an application!).

--- The limitations -------------

  Humm, right. As stated above, besides the occasional badly-behaved program,
this driver comes with guaranteed limitations:

  With PAL timings, only resolutions up to 800x600 can be fully viewed. With
NTSC this figure goes down to 640x480, thanks to the lower resolution of this
TV standard (525 horizontal lines, as opposed to PAL's 625).
  Note that these resolutions are available in ALL VGA cards.

  Since there are obvious limitations on the number of lines, modes that have
more than 525/625 lines, use the trick described below, in which the resolution
is actually halved, though for most purposes, it doesn't show much. Only if
you're trying to display text, you might run into trouble if the pitch is too
small. However, for photographs or most drawings, there isn't a noticeable
decrease in resolution.

  In order to get the correct aspect ratio of the screen modes, the maximum
resolution in PAL is 1600x1280 and in NTSC 1280x1024. Resolution is halved in
modes 1024x768 and above, in both PAL and NTSC, but NTSC has much more overscan
than PAL. Resolution is also halved in unsupported chipsets at 640x480 and
above resolutions, if they aren't interlaced originally.

  Because standard VGA has no support for interlaced screen modes, a trick has
to be employed to get the visible area of a video mode in the screen at all
times, including modes with more than 480/600 lines.
  It works by skiping every other line, namely even numbered lines (2,4,6,...).

  This, however, has some disadvantages:
  - normal text in those modes (which by themselves are high, like 1024x768) is
    very hard to read, if not impossible;
  - 256 color modes are affected. The result is a kind of solarizing effect on
    the palette, making some images look a bit 16 colourish... Note that this
    depends on the picture being displayed. Some programs or pictures don't
    seem to be affected.

  Fortunately, your VGA card's chipset may be supported by the program, thus
allowing you to have an interlaced screen, no missing lines, and a perfect
colour display (up to 480/600 lines per image, remember).

  The program is clever enough to, under certain conditions, support
non-standard VGA modes while not supporting any specific chipset. This depends
on the fact that some modes on some boards, specifically turn on interlacing
so that the driver doesn't have to do it, and you can see a 1280x1024 mode
even if the driver doesn't actually support your board.
  If the mode has more than 600 lines, and doesn't turn on interlacing, only
part of the screen will be shown, full-screen, but stretched downwards.
  Also, depending on how the program sets the dot-clock, some modes might not
sync, while others, higher resolution ones, might do. 800x600 is a general
culprit...

  There is no limit about colours, though some boards, due to the way they
program the card, might not allow us to see 640x480 at 16.7Mcolours, or more
than 800x600 at 64K/32K colours. Others do, however!

  Note that screen modes which have less than 300 lines, don't need
interlacing, thus are fully viewable, with no lines missing. This includes all
low resolution modes, such as mode 13h (320x200 with 256 colours).

  Text modes are limited to 32 lines, but there is no limitation on width.
Currently, modes 40x25, 80x25 and 132x25 are supported since I know of none
other. If they appear, there might be a chance that the program does recognize
them. Modes with more than 25 (or 30, if your card has 30-line modes) won't
show more than 32 lines at one time. The remaining lines aren't shown.

  Also, some programs reprogram text mode fonts (namely those from PC Tools,
Norton Utilities, and others), which may have nasty effects when you get back
to DOS. If the screen is corrupted on exit, try resetting the screen by
pressing Ctrl+Alt+R.

  200-line modes are not interlaced. I tried to, but it seemed impossible, at
least on the Oak 087 chipset. Anyway, as it is, the screen is much stabler,
since there is no interlacing.

--- The hardware ----------------

  First, there's the the original VGA->SCART project, by Tomi Engdahl. This
circuit is in HTML format, in http://www.hut.fi/~then/circuits/vga2tv.html,
which contains help, hints, schematics (proper drawings), even a picture of
one PCB, plus drivers. My ASCII version wouldn't make justice to the schema-
tics on that page, so you'll have to check there for them. I'll have enough
trouble to place my own circuit design here...

  Anyway, about the SCART version. SCART has an RGB input, therefore it's much
better than the composite video version. Remember however, that what you see
on your everyday TV broadcast, is truly composite video, so it's not that bad.
Except RGB is even better. However, composite has other advantages, such as:

  - you can record the signals on tape, since it seems some (all?) VCRs don't
    have RGB inputs on the SCART connection;
  - there are lots of SCARTs around, but on older equipment, you'll get plain
    RCA composite video plugs, so the SCART wouldn't work; and,
  - SCART is just too big, and it's not too healthy to get it in and out the
    input equipment at all times, unless it's a thing to plug in and forget.

  I've went the composite way because of issues 1 and 2. I don't have SCART
equipment at hand, and I would like to get the output recorded sometime, so,
despite the more complicated design, I've chosen this way. This driver however,
will work no matter the output device.

  On my circuit, I used a simplified version of Tomi Engdahl's VGA->SCART
circuit, to get composite sync, so, some credit must go to him.
  I also based the design heavily on Motorola's MC1377 datasheet, using more
or less the same components, with mostly the same values. You should see this
datasheet if in doubt. Check out http://motserv.indirect.com/cgi-bin/dlsrch,
and follow on-screen instructions.

  You can (and probably should) build an RGB circuit around another chip.
  I know of 3: Analog Devices AD722/AD724, which is a chip as simple as it
gets, allowing S-VHS output, easily, like Motorola's MC13077 (and unlike the
MC1377, which requires yet more circuitry for this), and Sony's CXA1645, which
is a bit more complicated than the AD722/AD724, but has RGB passthrough,
allowing RGB signals to feed the chip and go on to something else in the board
(like a SCART output).

  The circuit is comprised of 3 parts: the circuit box itself, a cable going
to the outside the case plugged into the VGA output, and another cable which
goes from the circuit box to the input equipment. This cable also plugs on the
circuit box (and is not soldered to the circuit's PCB as the other cable). You
can, of course, do it your own way.

  Outside component list:

  1 DB15P male VGA plug
  1 multi-wire cable (I used 8 wires+shield) to connect the VGA to the circuit
    box.
  1 box (metalic is better, though a plastic one is cheaper, and it's the one
    I also used). This holds the circuit. The box is 13cm x 5.5cm x 2.5 cm
    (W x D x H).
  1 female panel-mountable RCA plug
  1 male PCB mountable DC socket
  2 male RCA plugs (for the connecting cable)
  1 75 cable, to connect the box to the input equipment. You can probably get
    one of these in a shop somewhere. In that case, disregard the 2 male RCAs
    above. I used a 50 cable (by mistake), but it's quite okay. Just don't
    use plain audio cable for this. It's AWFUL...
  1 12VDC power supply. The circuit I made is only regulated for 5V. The chip
    itself (MC1377) has an internal 8.5V regulator. Thus, you can plug in from
    about 10V to 14V, unregulated power supply. This means a 9VDC transformer
    can be used. I do. The chip needs 60mA maximum, but I haven't determined
    the entire circuit supply current needs.

  The inside component list is comprised of:

  1 Motorola MC1377P chip
  1 DIP-20 socket, for the chip
  1 7805 5V PS regulator
  2 BC547 transistors
  1 Philips 330ns delay-line. These are H-A-R-D to find. Motorola suggests a
    400ns delay line, though it seems 330ns are more common here in Europe.
    Best place to look for one of these things, is inside a TV. The Philips
    one is green, and about the size of your thumb (1 inch). I have seen 3 so
    far, including the one I have. I have seen 2 other, being used in 2
    Elektor Magazine projects. You can try your local TV repair shop. Beware
    that some folks don't even know what this is, so be patient...
    The impedance on these delay lines is 1K. Motorola advises that it falls
    between 1K and 1.5K.
  1 chroma bandpass transformer. This one's a little hard to tell what it is.
    If you don't know diddley about this, it's one of those things inside the
    TV that you turn round and around, which have a lot of wires around them.
    About 1 cm high. For details on skiping this, refer to the MC1377P
    datasheet. But you can probably get one of your electronics-skilled
    friends to built one for you. Here's the details.

    The transformer itself is 15mm high, plus 3.5mm for the pins, which are
    0.7mm in diameter. Has 2 windings, and each one takes 60 turns of #38 AWG
    wire (0.1 m/m).
    Unloaded Q (Pins 1-3): 15 @ 2.5Mhz. Inductance: 30H  10% @ 2.5Mhz.

    Bottom view:
      ___________
     /           \
     3 -\   /-4  --------
        /   \         ^
     2  \ S / S     7  0.2mm
        /  /          v
     1 -   \- 5  --------
     \___________/

  1 4.43Mhz crystal, just like the ones found on TVs. 4.43Mhz is the PAL color
    carrier frequency. NTSC is 3.58Mhz, so you should get the appropriate one
    for you.

  Resistors:

  1 trimmer, 47K
  4 75
  3 47
  3 1.8K
  1 2.7K
  1 33K
  1 3.3K
  2 1K
  1 220

  Capacitors:

  1 trimmer 5pF-25pF (doesn't matter much, get one around this)
  1 100F, 16V (or more V)
  1 10F, 25V
  4 100nF
  1 12pF
  2 1nF
  2 10nF
  2 180pF
  1 33pF (NTSC: 47pF)
  1 62pF (NTSC:100pF)
  3 22F

  Now, follows 3 parts of the circuit, which should be joined together in the
  end.

  Power Supply
  ------------
                   Ŀ
                   Ĵ
                   7805C
                   Ĵ
                       
   +12V >    > +5V
                                  
          +  10F  +  10F    100nF
                             
    GND o-o GND

  Composite Sync
  --------------
   VGA pin 10: Sync_Gnd oĿ
                                                               
                                                               
   VGA pin 13: H_Sync   o/\/\/Ŀ           
                           1.8K                              
                                                              
   VGA pin 14: V_Sync   o/\/\//\/\/Ĵ
                           1.8K                      1.8K   
                                           BC547          
                  +5V   o/\/\/ >Ĵ
                          2.7K   BC547                  
                         >/\/\//\/\/o GND
                                                 47    47
                                                      
                                                      /\/\/o C_Sync
                                                         47
  Application Circuit
  -------------------
                                    33K
                               /\/\/Ŀ
                               v             
                           /\/\/ 47K      
                                            
                             ͻ  
               GND oĴĶ 1      20 ĳo GND (only if NTSC)
                        1nF                
                                           
            C_Sync oĶ 2      19 ĳĴo
                                            10nF
                         +                 
  VGA pin 1: Red   oĴĶ 3      18 ĳĴo GND
                      22F                  180pF
       GND o/\/\/                      180pF
                75      +                  
  VGA pin 2: Green oĴĶ 4      17 ĳĴĴo GND
                      22F                4.43/3.58Mhz   12pF
       GND o/\/\/                                 
                75      +                      5-25pF  <Ŀ
  VGA pin 3: Blue  oĴĶ 5      16              o GND
                      22F              
       GND o/\/\/          MC1377P  
                75                      
               /\/\/Ķ 6      15 o GND
             D /        1K              
             E\L  G                     
       GND oL/I  N oĴĶ 7      14 o +12V
             A\N  D   10nF                                       
             Y /E                                 62/100pF Ŀ
               Ķ 8      13 /\/\/ĴĴ4   5Ŀ
                                          220                 100nF
                1K                                             
                 /\/\/Ķ 9      12 Ĵo GND   Ĵ3 2 1Ĵ
       GND o       75                100nF             
                                                        ĴĴ
       Composite         Ķ 10     11 Ĵo GND     33/47pF  
           o      ͼ  100nF                    
       Video Output       1nF                           /\/\/o GND
                             3.3K

--- The contacts ----------------

  If you want to share some comments on this, suggestions, criticism, chipset
  programming details on unsupported cards, post-cards, money, etc, just write
  to:

  e-mail : psergio@mail.telepac.pt

  or,

  snail-mail : Paulo Srgio Coelho
               Rua Luis de Cames, 25
               Pateiro
               8400 Lagoa
               Portugal

  Please note that mail-bombs will be returned to sender. No kidding.

--- The legal juice -------------

  Ok, so you find this little piece of software useful.

  Very well, you can use it, at your OWN risk, meaning if you blow up the TV,
the VCR or your room, I really don't give a damn, it was YOUR fault, NOT mine.
Same thing for the hardware description. So there.

  Also, this software may be copied, used and abused, but nowhere modified.
This includes not only the executable, but also this DOC file, which should
always be present with the executable.

  Additionally, you can consider this work, one of the following:

  - freeware, meaning you can use it 'till it wears off;
  - shareware, meaning if you send me money, I'll appreciate it, and you'll
    win a line in this DOC; or,
  - cardware, in which you send me one (or more!) of those fancy postcards
    showing off the views on your local town.

  Ok, I think this one's done. Next!

--- The contributions -----------

  All right, here's a bunch of thanks for the folks which have a piece in
this.

  Me (psergio@mail.telepac.pt)
  - for typing this thing in, and generally spending lots of hours in front of
    a TV making this sh*t work;

  You - for being so patient, that you've actually read this thing so far;

  Tomi Engdahl (then@cc.hut.fi)
  - for developing the initial VGA->SCART hardware design, and having such a
    nice, informative page on the net, all about this VGA to TV stuff.
    Also, thanks for the help provided, in the countless mails about hardware,
    and other technical issues;

  Rui "Gusmo" Rodrigues (nop27007@mail.telepac.pt, CT1FKP)
  - He actually built my RGB-composite video circuit, after my design. He also
    has put a lot with me, since I'm such a no-good with the soldering iron,
    and an almost illiterate when it comes to electronics...;

  Herman Dullink (dullink@castel.nl)
  - for helping out on VESA issues (lots of info), S3 and Tseng Labs chipsets,
    interlace programming details on these, and mode X programming;

  Avery Lee (Psilon@concentric.net)
  - for helping out a bit on mode X, comments on an initial test program, info
    on how to turn protection off in the S3 chipset, and testing this in a
    Genoa Phantom 64;

  and other people who also contributed to the project.

  Thanks to you all!

--- The history log -------------

  Version 1.0  - Well, for a 2 day job, it wasn't that bad. Supported all
  Jan 17, 1997   standard VGA modes and fixed some problems occuring in a
                 previously used driver. However, it had some problem with
                 another driver, which I didn't bother to identify, and also
                 had a color problem in a Trident card, in mode 13h (320x200,
                 256 colors).

  Version 2.0  - I'm working on it... :-)
