home *** CD-ROM | disk | FTP | other *** search
/ Best Objectech Shareware Selections / UNTITLED.iso / boss / grap / util / 020 / tweak.doc < prev    next >
Encoding:
Text File  |  1993-02-04  |  38.6 KB  |  966 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.                 TWEAK 1.0 - Mold your own VGA modes
  8.  
  9.          by Robert Schmidt of Ztiff Zox Softwear, 1992-93
  10.  
  11.  
  12.           This program and the accompanying source files
  13.               are hereby donated to the public domain.
  14.                   (for whatever that's worth...)
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23. Contents:
  24. (sorry for not page-formatting this doc)
  25.  
  26. WHAT IS TWEAK, ANYWAY?
  27. SUGGESTION BOX
  28. DISCLAIMER
  29. A QUICK PRIMER
  30. WHAT HAS TWEAK GOT TO DO WITH THIS?
  31. A COUPLE OF RULES
  32. A TUTORIAL
  33. EDITOR REFERENCE
  34. FREQUENTLY ASKED QUESTIONS
  35. THE TWEAK FILES
  36. USING TWEAK MODES ON YOUR OWN
  37. THE INCLUDED FILES
  38. THE 'MISC' DIRECTORY
  39. CREDITS
  40. BIBLIOGRAPHY
  41. HOW TO REACH ME
  42.  
  43.  
  44.  
  45.  
  46.                         WHAT IS TWEAK, ANYWAY?
  47.  
  48.  
  49. TWEAK is an utility to ease the work of twiddling with the registers on
  50. a standard VGA compatible video card to produce and explore new, previously
  51. undocumented screen modes with weird resolutions.  You will want to
  52. purchase a technical VGA reference to get the full potential out of
  53. TWEAK, but I included some files to get you started (see the section
  54. on the 'MISC' directory).
  55.  
  56. TWEAK.EXE is the executable for version 1.0.  This version is *not*
  57. compatible with any earlier versions, so if you want to use files
  58. created by version 0.9x, convert them with 09TO10.EXE.  Version 0.95
  59. is included, which is fully compatible with version 0.9.  The
  60. differences are just some bug fixes and a few enhancements to the editor.
  61. If you are new to TWEAK, don't even consider using version 0.95, as it
  62. is just included for those particularly interested.
  63.  
  64.  
  65.  
  66.  
  67.  
  68.                         SUGGESTION BOX
  69.  
  70.  
  71. All suggestions to enhance or modify TWEAK are welcome, especially bug
  72. reports/fixes.  So are donations, for that matter.  See e-mail and
  73. snail-mail addresses at the end of this file.
  74.  
  75. Please send me any changes you make to enhance TWEAK or to make it
  76. compatible with other compilers or video cards, and I will start
  77. including conditional sections for each supported compiler.
  78. Do *not* re-release the changed source without my permission.
  79. Well, how can I stop ya...?
  80.  
  81. Any suggestions and contributions will be credited in subsequent
  82. version, although I can't guarantee that your ideas will actually be
  83. used.
  84.  
  85.  
  86.  
  87.  
  88.  
  89.                           DISCLAIMER
  90.  
  91.  
  92. I don't think this is neccessary in PD stuff, but everybody else does
  93. it:
  94.  
  95. This product, TWEAK, referred to as THE WORK OF ART, is provided as is,
  96. as they say.  From now on, I'll refer to myself as THE ARTIST, and
  97. you as THE ART LOVER.  THE ARTIST doesn't know what 'as is' means to
  98. THE ART LOVERs, but to THE ARTIST it means that THE ART LOVER ain't
  99. got no friggin' right to hold THE ARTIST responsible for anything
  100. mean, nice, cool, devastating, awesome or terrible happening to
  101. THE ART LOVER, THE ART LOVER's computer or any part within and
  102. outside, connected or disconnected, THE ART LOVER's family, ex-family
  103. and their kin, THE ART LOVER's sex life, THE ART LOVER's house,
  104. car, boat, in short: THE ART LOVER's anything, as a consequence of
  105. using, not using, abusing or eating THE WORK OF ART or any part
  106. contained within, including executable, documentation, source,
  107. recommendations and references.
  108.  
  109. Phew.
  110.  
  111. Some time ago, putting illegal or unsupported values or combinations
  112. of such into the video card registers might prove hazardous to both
  113. your monitor and your health.  I have *never* claimed that bad things
  114. can't happen if you use TWEAK, although I'm pretty sure it never will.
  115. I've never heard of any damage arising from trying out TWEAK, or from
  116. general VGA tweaking in any case.
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.                            A QUICK PRIMER
  125.  
  126.  
  127. You never heard about neither documented nor undocumented modes, you say?
  128. Well, to begin with:  Your VGA cards has a number of registers that
  129. control the way the card works.  That is, how it is going to translate
  130. the data that programs put into the video memory, to the signals that
  131. produce text and/or graphics on your monitor.
  132.  
  133. The standard interface to a video card on all IBM compatible PCs is the
  134. BIOS, which consists of several device independant routines for setting
  135. screen modes, moving the cursor, writing text, scrolling blocks of text
  136. etc.  The BIOS also takes care of setting the appropriate registers
  137. at appropriate times, for example when changing screen modes.  That way,
  138. programmers have a consistent interface to the VGA, and usually won't
  139. need to tamper with the registers directly.
  140.  
  141. A screen mode specifies the resolution of the image you see on the
  142. screen, i.e. the number of pixels (dots) horizontally and vertically,
  143. the number of colors, and wether the screen should be capable of showing
  144. just text, or if graphics are allowed.  These things are controlled by
  145. the VGA registers, and the BIOS contains a number of predefined tables
  146. of register values for the standard VGA modes we've all come to love and
  147. honour.  Mode number 3, for example, is the 80 characters times 25 lines
  148. (80x25) text screen that most people use daily.  Mode number 19 (or 13h
  149. in hexadecimal) is the 256-color 320x200 mode used in most popular games
  150. supporting the VGA.
  151.  
  152.  
  153.  
  154.  
  155.  
  156.                 WHAT HAS TWEAK GOT TO DO WITH THIS?
  157.  
  158.  
  159. Well, some people, me included, are of the 'power-hungry' breed.  We want
  160. to exploit the full potential of everything we get between our hands.
  161. We think that the one 320x200 256-color mode supported by all standard VGA
  162. BIOS'es is for wimps.  Some guy came up with the idea of modidying the
  163. register configuration, to achieve greater resolution and a different
  164. video memory layout.
  165.  
  166. TWEAK grants you direct access to all the most significant registers
  167. that control such things as resolution and colors.  You may have thought
  168. that your VGA was limited to 320x200 when it was displaying 256 colors?
  169. Well, all VGAs are able to support no less than 400x600 in 256 colors.
  170. (The problem is with the monitors, which might not be sophisticated
  171. enough to support the relatively much higher clock frequency needed to
  172. output that many pixels.  My monitor flickers and rolls occasionaly.)
  173.  
  174. Most newer VGA cards' BIOSes add several enhanced modes not supported
  175. by the standard VGA defined by IBM, for example text modes with 132
  176. characters on each line, or graphics resolutions of 800x600, 1280x1024
  177. and more.  Such cards are usually referred to as Super VGAs.  To make it
  178. possible to produce such resolutions, video card developers has had to
  179. add new registers to the set of registers defined by the VGA.  TWEAK is
  180. generally not able to support such extended registers, meaning that you
  181. will not be able to tweak a Super VGA any more than is possible on a
  182. standard VGA.  Extensions that are provided by utilizing undefined bits
  183. in the standard VGA registers are supported however.  The included
  184. Chips & Technologies specific 132x*.twk files are examples of such.
  185.  
  186. The main reason for not including Super VGA (SVGA) support is that
  187. there are so many different SVGA standards.  Nearly every developer has
  188. their own standard.  Also, I can see no real reason for wanting to tweak
  189. any SVGAs, as the resolution dimensions they offer usually are far
  190. superior to the VGA's resolutions.
  191.  
  192. If this is the first you have read about VGA registers and the BIOS,
  193. TWEAK.EXE and this documentation alone is not enough to get you going.
  194. You will need, and probably want, a somewhat technical reference to the
  195. VGA, which explains all standard VGA registers and the meaning of every
  196. contained bit.  Although TWEAK doesn't support it, you'll probably want
  197. a reference which also contains some discussion on Super VGAs, just for
  198. your convenience when you want to program serious applications etc.  If
  199. you're of the adventurous breed, check out the VGA.TXT and VGABIOS.TXT
  200. files included in the .\MISC directory.
  201.  
  202. You see, tweaking the VGA is not as simple as putting the horizontal
  203. resolution in one register, the vertical in another and the number of
  204. colours in yet another.  Several registers has to be set to cooperating
  205. values that work together to acheive what you want.  Single bits has to
  206. be toggled into the correct states, even before you can see anything on
  207. screen.  TWEAK simplifies this process by letting you do this
  208. interactively, and by letting you test your register set at the touch
  209. of one key (ENTER, actually).  The pre-TWEAK process was to make a small
  210. program that set up the registers in the way the programmer thought
  211. would work.  If it didn't he had to edit the program source file,
  212. recompile, and re-run.  Not seldom, the PC crashed because of some
  213. *really bad* register values, and a full reset was required.
  214.  
  215. TWEAK lets you save and load register sets to and from files, and lets
  216. you select any video mode supported by your BIOS to work out from.
  217. It supports text modes and graphics, 16-color and 256-color.  Monochrome
  218. modes, however, are not supported, because they use another set of I/O
  219. ports, and because few people really are interested in them.
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.                         A COUPLE OF RULES
  228.  
  229.  
  230. I'll be the first to admit:  TWEAK isn't much of an editor.  The screen
  231. is boring, there is no online help, no undo command, no file pick lists
  232. etc.  In short, TWEAK is not meant for people not knowing what they are
  233. doing.  I strongly beleive that nothing can be damaged from the use of
  234. TWEAK, but for starters, I'll recommend the following precautions:
  235.  
  236.   *  When loading/saving, take care to check that you selected the
  237.      function (load or save) that you want, before typing a filename
  238.      and pressing Enter.  Also verify that the filename you type when
  239.      saving is the filename that you want, because TWEAK overwrites
  240.      any existing files with the same name without asking for permission.
  241.  
  242.   *  If, when you press the Enter screen to test the screen mode,
  243.      nothing appears after 5-10 seconds, press Enter again.  If you're
  244.      not immediately returned to the editing screen, reboot your
  245.      computer by pressing the reset button.  Keep in mind that some of
  246.      the test patterns, especially the 256-color 4-planar one, can be
  247.      slow to put into the video memory buffer, so be a *little*
  248.      patient & tolerant.
  249.  
  250. That last rule is present to prevent that the monitor is exposed to crazy
  251. sync timings for too long a time.  And I repeat, there usually never is
  252. any reason to panic, even if your monitor makes strange sounds
  253. ('tweeeeee' for example, or 'flick-flick-flick').  Press ENTER, wait for
  254. a couple of seconds more, then reset if the edit screen doesn't reappear.
  255.  
  256.  
  257.  
  258.  
  259.  
  260.                            A TUTORIAL
  261.  
  262.  
  263. To start TWEAK, change to the directory where you have put the files,
  264. and type TWEAK.EXE at the DOS prompt.  A banner with a short help screen
  265. should appear, together with a message about pressing a key.  At this
  266. point, you can press any of the command keys listed in the help screen
  267. to execute it at once.  You might, for example press 'M' to select a
  268. BIOS mode to work from, or F9 to load a register set file.  Pressing
  269. SPACE is probably the safest bet, as this will just put you in the
  270. editor without doing anything more.
  271.  
  272. Well, now you're in the editor, and you can see the following things:
  273.  
  274.   *  One (possibly two) column(s) of VGA registers on the form:
  275.      ppp (ii)         Register Name : vv
  276.      where
  277.        -  ppp is the port number
  278.        -  ii is the index into that port, if applicable
  279.        -  vv is the selected value for this register
  280.      All numbers are hexadecimal.  The current register is marked by one
  281.      arrowhead on each side of the line.  When you first start TWEAK,
  282.      the current register is the top left.
  283.  
  284.   *  A bit pattern display showing the bit pattern of the 8-bit value
  285.      contained in the currently selected register.
  286.  
  287.   *  The bottom line tells you which test pattern is currently active.
  288.  
  289. Now try the following simple tutorial:
  290.  
  291.   1. Press H, and a small red window should appear, describing all keys
  292.      available for use in TWEAK.
  293.  
  294.   2. Press M, then type the number 03.  Notice that you don't have to
  295.      press ENTER.  You have now selected BIOS mode 3 as the basis for
  296.      you explorations.
  297.  
  298.   3. Press TAB until 'Text screen, 16 point' appears at the bottom line,
  299.      if it doesn't already.  TAB selects which test pattern to use, and
  300.      you have now readied the 16-point font version of the text screen
  301.      test ready.
  302.  
  303.   4. Press ENTER.  You should see a screen with numbers along the top
  304.      row, and various characters and colors down the rest of the screen.
  305.      This is the text test pattern, as it looks when viewed in mode 3.
  306.      Press ENTER to return to editing mode.
  307.  
  308.   5. Now press F10, and type '40x12' and press ENTER.  This loads the
  309.      file '40x12' and uses its contents as the current register set.
  310.  
  311.   6. Press ENTER again.  A screen similar to the previous test pattern
  312.      should appear, but the characters should be twice as wide and twice
  313.      as high.  This is a tweaked VGA mode, which is not supported by the
  314.      BIOS.  It looks a little odd, as the bottom line is cut in half,
  315.      making this a 40x12.5 text mode, in fact.  Press ENTER to return.
  316.  
  317.   7. Press F10, type '360x240.256' and ENTER.  Press TAB until the text
  318.      '4 planes, 256 colors' appear in the bottom line.
  319.  
  320.   8. Press ENTER.  This is a well known tweaked VGA mode that has even
  321.      been used in commercial games for the PC, but it remains
  322.      unsupported by the BIOS (and it probably always will).  If the
  323.      screen rolls, try adjusting your monitor knobs.  If you can't get a
  324.      steady picture, it probably means your monitor isn't capable of
  325.      handling the horizontal resolution of 360 pixels.
  326.  
  327.   9. Press ENTER to return to editing, then press ESC to quit TWEAK.
  328.  
  329.  
  330. The last graphics display might not have been especially pleasing to the
  331. eye.  First, if the picture was rolling uncontrollably, you might think
  332. that TWEAK is of no use for you, as your monitor isn't good enough.
  333. However there are still interesting things to try out.  There are
  334. tweaked modes 'available' with a little lower resolution that are almost
  335. guaranteed to work on your monitor, and which are of great interest to
  336. games programmers for example.  The file 320x240.256 contains the
  337. register set for the infamous Mode X, which was 'discovered' and
  338. documented by Michael Abrash in his monthly columns in Doctor Dobbs
  339. Journal.
  340.  
  341. Mode X has the following interesting properties:
  342.  
  343.   *  The pixels are 'perfectly' square.  That is, if you try to draw a
  344.      circle with aspect ratio 1:1, it will look like a circle (unless
  345.      your monitor is adjusted to some extreme).  The BIOS mode 13h
  346.      (320x200x256) has pixels that are a little higher than they are
  347.      wide, making 1:1 circles look stretched vertically.
  348.  
  349.   *  The video memory is divided into 4 planes, each of which contains
  350.      64 Kb.  By setting the Write Plane Enable register to the actual
  351.      plane, you can address the full 256 Kb of video memory through the
  352.      'tiny' address space of 64 Kb from 0xA000:0 to 0xA000:0xFFFF.
  353.      Thus, you can have more than three full screens in video memory at
  354.      any one time, making you able to perform animation tricks as
  355.      page flipping, and to do fast 32-bit video to video transfers.
  356.  
  357. This was just to get you going, and others have written tons of text on
  358. drawing stuff (lines, circles, images) in Mode X.  The rest of this
  359. part will deal with the commands available in TWEAK.  To get more
  360. information about VGA programming in general and registers in particular,
  361. check out the reference list somewhere at the end.
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.                          EDITOR REFERENCE
  369.  
  370.  
  371. This reference applies only to version 1.0 of TWEAK, although *most*
  372. keys are supported by the included version 0.95 too.
  373.  
  374. Select the register value you want to modify using the following keys:
  375.  
  376.      Up         selects previous register
  377.      Down       selects next register
  378.      Home       selects first register
  379.      End        selects last register
  380.  
  381. Use these keys to modify a register value:
  382.  
  383.      a 2-digit, hexadecimal number : sets the register to the given value
  384.      '-'        decreases the value of the register
  385.      '+'        increases the value of the register
  386.      F1 ... F8  toggle bits 7, 6, ..., 0 of the selected register,
  387.                 respectively.
  388.  
  389. Use these keys for testing the set of register values:
  390.  
  391.      TAB [->|]  cycle among the available test patterns, to find the
  392.                 one you think will suit your custom register set.
  393.                 Shift+TAB cycles in the opposite direction.
  394.  
  395.      ENTER      sends your custom register set to the VGA registers, then
  396.                 writes the selected test pattern to the video memory buffer.
  397.  
  398. Some other important or useful actions:
  399.  
  400.      Backspace  toggles the active state of the current register.  If a
  401.                 register is inactive, it color is grey instead of yellow.
  402.                 When you test the mode (by pressing ENTER), inactive
  403.                 registers will *not* be sent to the VGA card.  Also, they
  404.                 will *not* be saved to the file when a Save command is
  405.                 executed.  This feature is included to enable you to ignore
  406.                 registers that doesn't affect your screen mode.  For
  407.                 example, for most practical uses, the Color Compare register
  408.                 can be deactivated.
  409.  
  410.      'M'        prompts the user for a 2-digit, hexadecimal number
  411.                 specifying a standard VGA BIOS screen mode number.  Note
  412.                 that TWEAK does *not* support true monochrome modes.
  413.                 The VGA is set to this mode using INT 10h with AX=mode
  414.                 number.  Then all relevant registers are read from the
  415.                 VGA into the editing set, and you're returned to the
  416.                 editing screen.
  417.  
  418.      F9 or 'S'  prompts the user for a file name, then saves the register
  419.                 set to this file, overwriting any pre-existing
  420.                 file by the same name.  Inactive registers are not saved,
  421.                 thus there are no longer a fixed size to TWEAK's mode
  422.                 files.
  423.  
  424.      F10 or 'L' prompts the user for a file name, then loads the register
  425.                 set from this file, if it exists.  Registers that are
  426.                 supported by TWEAK, but that are not included in the file,
  427.                 will be deactivated (greyed).
  428.  
  429.      ESC        quits TWEAK immediately (no option to save).
  430.  
  431.  
  432. There are currently 5 available test patterns with TWEAK.  Numbers in
  433. parentheses are all the standard VGA BIOS modes that display the test
  434. patterns correctly:
  435.  
  436.   o  2 text test screens at 0B800h
  437.      -  one using the normal 8x16-point VGA font (0, 1, 2, 3)
  438.      -  one using the 8x8-point CGA font (normally used in 43/50-line
  439.         modes, but none of those are defined by the VGA BIOS.  Check
  440.         VGABIOS.DOC for the function to load a specific font.)
  441.   o  A screen for 4-planar, 16-color modes at 0A000h (0Dh, 0Eh, 10h, 12h)
  442.   o  A screen for 4-chained, 256-color modes at 0A000h (13h)
  443.   o  A screen for 4-planar, 256-color modes at 0A000h (None supported by
  444.      BIOS)
  445.  
  446. See the source (TWEAK.CPP) for descriptions on how the test patterns are
  447. supposed to look.  Generally, if it looks good, it might be correct.
  448.  
  449. TWEAK automagically detects the logical scan line width of your screen
  450. mode, and adjusts the patterns accordingly.
  451.  
  452. It is possible for me to make TWEAK select or suggest the most proper
  453. test pattern, but this is *not* done in this version.  So make sure you
  454. have selected the correct pattern before considering changes to the
  455. register values.
  456.  
  457.  
  458.  
  459.  
  460.                     FREQUENTLY ASKED QUESTIONS
  461.  
  462.  
  463. Q:      I'd like to study the register configuration for a screen mode
  464.         supported by my (Super-)VGA.  How do I get to it?
  465.  
  466. A:      The 'M' key lets you select a BIOS mode to study.  Note that you
  467.         will need to know the mode number.
  468.  
  469.  
  470. Q:      None of the tests seem to produce sane results.  The screen
  471.         a) goes black,
  472.         b) rolls or
  473.         c) the program crashes.
  474.  
  475. A:      a)  - Make sure you tried ALL 5 tests.
  476.             - Set the Color Plane Write Enable register to 0Fh.
  477.             - Note that Super VGA modes are generally not supported
  478.               (though they *might* work).
  479.         b)  - The timing/sync registers are not set correctly/in sync.
  480.               See your VGA reference for more information.
  481.             - Try adjusting the knobs on your monitor.
  482.         c)  - You must have hit a major incompatibility/bug.  Send me a
  483.               mail, telling me what kind of hardware you're using.  I
  484.               will probably not be able to fix it, but an incompatibility
  485.               list will be emitted with the next release, if any.
  486.  
  487.  
  488. Q:      How about a TSR to save the current register configuration from
  489.         any program?
  490.  
  491. A:      I've considered this, but haven't had the time.  A hint, though:
  492.         Get CBOOTxxx.ZIP from simtel or any mirror, in .../msdos/sysutl.
  493.         This program lets you break out from most applications,
  494.         *without* resetting the screen mode.  A typical session:
  495.             - Install CBOOT.
  496.             - Run FRACTINT (a fractal explorer package, supporting lots
  497.               of tweaked modes), and select the mode you want to 'grab'.
  498.             - Press ALT+SHIFT+B, and the CBOOT menu pops up.
  499.             - Press '7' to reset interrupt vectors.
  500.             - Press '6' to 'properly' exit from FRACTINT.
  501.             - You might not see it, but you should be at the DOS prompt.
  502.             - Run TWEAK directly, which will start up with the current
  503.               register configuration.  Now you're off!
  504.  
  505.  
  506. Q:      I'd like to use tweaked modes in my own programs.
  507.  
  508. A:      Provided you have produced TWEAK files corresponding to your
  509.         modes, take a look at the example files for different approaches
  510.         to using the mode files.  The examples are in C, but are simple
  511.         enough, so translation to Pascal should be a breeze.
  512.  
  513.  
  514. Q:      - What is the register which makes x do y/sets a to b/etc.?
  515.         - Is there a BIOS call to do x?
  516.  
  517. A:      First check the VGA.TXT and VGABIOS.TXT files in the MISC
  518.         directory.  If they don't help you, please consider buying a
  519.         technical reference to the VGA.  That would please you and me.
  520.  
  521.  
  522. Q:      How do I make a mode with resolution x times y with z colors?
  523.  
  524. A:      - See the sample *.TWK, *.256 and *.16 files provided with
  525.           TWEAK.  Not a great lot, but you might be able to work out
  526.           one of those.
  527.         - Get FRACTINT or SVGABGI, and use the method mentioned above to
  528.           'grab' modes from these programs.
  529.         - Experiment!  That's what I had to do.
  530.         - Finally: ask people on the net for help.
  531.  
  532.  
  533. Q:      I can't find this MISC directory!
  534.  
  535. A:      Make sure you unzip the TWEAK archive with the -d option, which
  536.         is needed to extract subdirectories.  I.e:
  537.           PKUNZIP -D A:TWEAK10
  538.  
  539.  
  540. Q:      I have lots of files with modes that I saved with version 0.9 of
  541.         TWEAK...
  542.  
  543. A:      Use the 09TO10 utility to convert them.  Run 09TO10.EXE with no
  544.         parameters for a simple help screen.
  545.  
  546.  
  547. Q:      What do I need to rebuild TWEAK and/or the utilities?
  548.  
  549. A:      You will need Borland C++.  I used version 3.1, but it might
  550.         work as far back as Turbo C++ 1.0.  I included a Makefile to
  551.         make rebuilding as painless as possible, provided you have
  552.         BCC.EXE in your path, and it knows where to find headers and
  553.         libraries (usually it does).
  554.  
  555.  
  556. Q:      What do I need to use the mode files produced by TWEAK in my own
  557.         programs?
  558.  
  559. A:      If you want to use the TwkUser module, you'll need a C compiler.
  560.         I don't think I used anything Borland specific here.
  561.         Otherwise the file format is pretty simple, so you should have
  562.         no problem making similar functions/procedures using any
  563.         language (Basic, Pascal, Prolog...).
  564.  
  565.  
  566. Q:      Where can I find more information on tweaking the VGA?
  567.  
  568. A:      See the Bibliography section below.  Michael Abrash's articles
  569.         in Doctor Dobb's Journal from a year or so are probably the best
  570.         sources.  Join the rec.games.programmer newsgroup.  There has
  571.         been some discussion on tweaking there.
  572.  
  573.  
  574. Q:      How can I ever repay you for making such a great utility???!!
  575.  
  576. A:      Easy!  The cheapest way is to send me a cool postcard with some
  577.         (readable) words on it.  I will of course accept donations too,
  578.         even though TWEAK is public domain.  See the end of this file.
  579.  
  580.  
  581. Q:      PKUNZIP refused to unzip the TWEAK archive!
  582.  
  583. A:      I guess you decoded this DOC file by hand, then...  well, make
  584.         sure you transfer in BINARY mode from the ftp site.
  585.  
  586.  
  587. Q:      I can't find my question in the Frequently Asked Questions list!
  588.         Does this mean I'm stupid??
  589.  
  590. A:      It might.  :-)  However, I just thought up all these questions
  591.         myself, so if you have a suggestion for more FAQs, don't
  592.         hesitate to let me know!  I promise I won't laugh...
  593.  
  594.  
  595.  
  596.                         THE TWEAK FILES
  597.  
  598.  
  599. The file format used for saved files is pretty simple.  The files will
  600. usually be bigger than the files saved with TWEAK 0.9, and version 0.9
  601. files are *not* readable by version 1.0.  This is undetectable by TWEAK,
  602. because of the simple nature of the files.  If you try, there's a fat
  603. chance that your computer will hang.
  604.  
  605. Here is the format:
  606.  
  607. offset 0: WORD - port number of first register
  608. offset 2: BYTE - index of first register
  609. offset 3: BYTE - value of first register
  610.  
  611. offset 4: WORD - port number of second register
  612. .
  613. .etc.
  614. .
  615.  
  616. Pretty simple, as you can see, but also flexible from TWEAK's point of
  617. view.  This makes it easy to add new ports if neccessary.  The file size
  618. is not constant, as registers that are disabled at save time are not
  619. written to the file.  Divide the file size by 4 to determine the number
  620. of registers in a file, or just read to EOF (as TWEAK does... :).
  621.  
  622. Also note that the VGA registers use varying methods for access.  For
  623. some registers you just send the value directly to the port (ignoring the
  624. index).  For some you send the index to the port, then the value to the
  625. port+1.  For still some you have to ...  Rather, refer to the source
  626. code for all the how-to's...  it's not difficult, just inconvenient, and
  627. it hinders really general storage of register addresses and their values.
  628.  
  629. Use the 09TO10.EXE program to convert from version 0.9 files to version
  630. 1.0 files.  Run 09TO10.EXE with no parameters for information on how to
  631. use the utility.
  632.  
  633. I have selected the following standard of file extensions for
  634. TWEAK-files:
  635.  
  636.   o  *.TWK are text modes
  637.   o  *.16 are 16-color graphic modes
  638.   o  *.256 are 256-color graphic modes
  639.  
  640. Note that you'll always have to type an extension in TWEAK if you want
  641. any, as TWEAK neither assumes anything nor provides default extensions.
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.                   USING TWEAK MODES ON YOUR OWN
  649.  
  650.  
  651. The Register and RegisterTable classes used in TWEAK.CPP might be a
  652. little huge and clumsy to use in your own programs, where you probably
  653. just want to set the registers according to a linked-in array.
  654. Therefore I have provided a simple C module for the following functions:
  655.  
  656.   o  Reading a file saved from TWEAK into a dynamically allocated
  657.      array of registers.
  658.   o  Setting VGA registers according to the contents of an array of
  659.      registers.
  660.   o  Setting a single register.
  661.  
  662. The types and functions are declared in TWKUSER.H, which should be
  663. included in every source file using these functions.  The definitions
  664. are contained in TWKUSER.C, which should be compiled under the wanted
  665. memory model and linked together with your program modules.  You are
  666. free, in fact you're encouraged to modify the TWKUSER files to suit
  667. your own needs.  In their present form, they just provide enough
  668. functionality to get you started.
  669.  
  670. A couple of simple examples are provided:
  671.  
  672.   o  Example1.C - demonstrates how to use a TWEAK-generated file in your
  673.      own program by loading the file at run-time, and setting the VGA
  674.      registers according to the file contents.
  675.  
  676.   o  Example2.C - does the same, but now the TWEAK-file is converted to
  677.      a C-includable file by using the TWEAK2C utility.  Thus, the contents
  678.      of the TWEAK file is linked with the program as global data.
  679.  
  680. Both programs set the VGA to the famous Mode X, 320x240 in 256 colors,
  681. but no attempt is made to make it look beautiful.  What you'll see on
  682. screen is whatever happened to be in the video memory at the moment.
  683. Press any key, and you're returned to DOS.
  684.  
  685. I would very much like to provide similar Borland Pascal examples, but
  686. as I don't have Turbo/Borland Pascal available at the moment, I'm just
  687. going to skip it at this time.  If *you* feel like porting the TwkUser.C
  688. and .H files to a Pascal unit, please do.  It should be a peice of cake.
  689. If you mail the result to me, I might include it in the next release of
  690. TWEAK, and in any case you'll be credited for your contribution.
  691.  
  692.  
  693.  
  694.  
  695.  
  696.                       THE INCLUDED FILES
  697.  
  698.  
  699. This is a dump of the 4DOS compatible DESCRIPT.ION file included in this
  700. archive:
  701.  
  702. 320x200.256 Standard VGA BIOS mode 13h
  703. 320x240.256 Planar tweaked 'Mode X'
  704. 360x480.256 Planar tweaked
  705. 400x300s.256 Tweaked C&T SVGA planar
  706. 400x600.256 Tweaked VGA, req. good monitor
  707. 400x600s.256 Tweaked C&T SVGA planar
  708. 432x600s.256 Tweaked C&T SVGA planar
  709. 640x480.16 Standard VGA BIOS mode 12h
  710. 800x600s.16 Standard C&T SVGA BIOS mode
  711. 132x25.twk Standard C&T SVGA BIOS mode
  712. 132x45.twk Standard C&T SVGA BIOS mode
  713. 132x50.twk Standard C&T SVGA BIOS mode
  714. 132x60.twk Ultravision C&T SVGA mode
  715. 40x12.twk Standard VGA BIOS mode 1, double scanned
  716. 80x43.twk Standard VGA mode, needs 8x8 font
  717. 80x50.twk Standard VGA mode, needs 8x8 font
  718. 09to10.cpp Version 0.9x to 1.0 conv. util. source
  719. 09to10.exe Version 0.9x to 1.0 conversion utility
  720. 800x600.16 Tweaked VGA, req. good monitor
  721. example1.c C source for Example1.EXE
  722. example2.c C source for Example2.EXE
  723. makefile Type MAKE ALL to update TWEAK project
  724. namedreg.cpp C++ source defining NamedReg. members
  725. register.hpp C++ header declaring Register & NamedReg
  726. regtable.cpp C++ source defining RegisterTable
  727. regtable.hpp C++ header declaring RegisterTable
  728. screen.cpp C++ source defining screen functions
  729. screen.hpp C++ header declaring screen functions
  730. testpat.cpp C++ source defining TestPatterns members
  731. testpat.hpp C++ header declaring TestPatterns
  732. tweak.cpp C++ source defining TWEAK's main program
  733. tweak.dat Text file: list of supported registers
  734. tweak.doc Documentation for the TWEAK suite
  735. tweak.exe The TWEAK executable
  736. tweak095.cpp C++ source for the old TWEAK version
  737. tweak2c.cpp C++ source for the TWEAK2C utility
  738. tweak2c.exe The TWEAK-file to C-file utility
  739. twkuser.c C source defining som usable functions
  740. twkuser.h C header with TwkUser.C prototypes
  741. register.cpp C++ source defining Register members
  742.  
  743. The only files required to run TWEAK are:
  744.  
  745.   o  TWEAK.EXE
  746.   o  TWEAK.DAT
  747.  
  748. The register definitions have been moved out from the executable into
  749. the external .DAT file, to increase flexibility.  You might edit the
  750. TWEAK.DAT file as you like to include support for any registers you
  751. might think of.  Remember to update the number in the first line to
  752. reflect the number of defined registers.  Note that if your new registers
  753. are not on one of the ports supported by TWEAK.EXE, you might need to
  754. modify and recompile the TWEAK sources to accomodate the new port(s).
  755. See REGISTER.CPP.
  756.  
  757.  
  758.  
  759. Some words on my convention of naming files made by TWEAK:
  760. ----------------------------------------------------------
  761.  
  762.   o  The general name format is XXXxYYY.CCC, where
  763.         XXX is the horizontal resolution
  764.         YYY is the vertical resolution
  765.         CCC is the number of colors supported, except for text modes,
  766.             which are named *.TWK.
  767.   o  An 's' after YYY specifies a Super VGA specific mode which I grabbed
  768.      from the BIOS of my Chips & Technologies Super VGA.  These modes will
  769.      probably *not* work with your card unless it's C&T compatible!  I've
  770.      had reports that most of these modes even crash some sensitive
  771.      machines.  See .\MISC\KAI1.TXT
  772.  
  773.  
  774. The Makefile & sources
  775. ----------------------
  776.  
  777. See the Makefile for all dependencies between the source files.  It's not
  778. very complicated.
  779.  
  780. The following makes are defined in the Makefile:
  781.  
  782. make tweak: makes the TWEAK executable.
  783. make oldtweak: makes the TWEAK095 executable.
  784. make examples: makes EXAMPLE*.EXE.
  785. make utilities: makes 09TO10.EXE and TWEAK2C.EXE.
  786. make all: combines all the above makes.
  787.  
  788. The Makefile is Borland C++/MAKE specific, and uses bcc.exe for all the
  789. work, with one reference to TWEAK2C.EXE.
  790.  
  791. When studying the sources, note that TWEAK was started as an experiment
  792. in object oriented programming with C++.  Thus the entire project may look
  793. a bit pompous in its use of classes, overloaded operators and such.
  794. Bear with me.  At last I provided the TwkUser files to help you get
  795. started with something down to earth.
  796.  
  797. In their curretn state, some of the source files produce a couple of
  798. warnings.  These can be ignored.
  799.  
  800. Also note that TwkUser.* and the examples are C (but C++ compatible),
  801. while TWEAK and its utilities are strictly C++.
  802.  
  803.  
  804. The utilities TWEAK2C and 09TO10
  805. --------------------------------
  806.  
  807. The following are dumps of the help screens from there programs:
  808.  
  809. "TWEAK2C version 1.0
  810.  by Robert Schmidt of Ztiff Zox Softwear 1993
  811.  Converts a TWEAK version 1.0 file to an #include-able C file.
  812.  
  813.  Syntax:  TWEAK2C <TWEAK-file> <C file to create> <array name>
  814.  All parameters are required."
  815.  
  816. "09TO10 version 1.0
  817.  by Robert Schmidt of Ztiff Zox Softwear 1993
  818.  
  819.  Converts TWEAK version 0.9 files to TWEAK version 1.0 files.
  820.  
  821.  Syntax:  09TO10 <oldfile> <newfile>"
  822.  
  823. For both programs, the following goes:  If the file to be created already
  824. exists, the data contained in the file on disk will be overwritten with the
  825. new data.
  826.  
  827.  
  828.  
  829.  
  830.  
  831.                       THE 'MISC' DIRECTORY
  832.  
  833.  
  834. In this directory I have included files from other sources than myself.
  835. Kai Rohrbacher allowed me to include his contributions in this release of
  836. TWEAK, but for the other stuff I can't guarantee no legal status.
  837.  
  838. KAI1.TXT
  839. MODES.ZIP
  840.         A mail from Kai Rohrbacher of Germany, discussing the use
  841.         of TWEAK 0.9 on Diamond and SPEA super VGA cards.  I extracted
  842.         the uuencoded MODES.ZIP for your convenience.  Note that these
  843.         modes must be converted with the 09TO10 utility if you want to
  844.         test/use them with TWEAK 1.0.  TWEAK 0.95 uses them fine.
  845.  
  846. KAI2.TXT
  847.         Another mail from Kai containing an interesting Turbo Pascal
  848.         program to convert TWEAK 0.9x's 36-byte files into Turbo Pascal
  849.         source files defining procedures to set the modes directly.
  850.         I haven't been able to test this, as I don't have TP available,
  851.         but it sounds terrific.  Note that this program is compatible
  852.         with TWEAK 0.95, but *not* with TWEAK 1.0!
  853.  
  854. READ.ME
  855. VGA.TXT
  856. VGABIOS.TXT
  857.         I found these files in an archive assembled by Finn Thoegersen
  858.         of Denmark.  I beleive VGABIOS.DOC was taken from Ralph Brown's
  859.         interrupt list.  VGA.TXT lists VGA registers and their purpose,
  860.         but as I never used either VGA.TXT or VGABIOS.TXT, I can't
  861.         guarantee their correctness.  The complete archive containing
  862.         similar info on most popular Super VGAs can be found on
  863.         garbo.uwasa.fi in /pc/doc-hard/vgadoc2.zip
  864.  
  865. CGA160.TXT
  866.         A post grabbed from some newsgroup, discussing tweaking on the
  867.         ancient CGA adapter.  I think 16-color 'graphics' on a CGA
  868.         sounds pretty interesting, so I included it for your enjoyment.
  869.  
  870. SETMODEX.ASM
  871.         Michael Abrash's code to set the VGA in the infamous Mode X.
  872.         Provided as an example of how programmers were used to tweaking,
  873.         before TWEAK came along... :)
  874.  
  875.  
  876.  
  877.  
  878.                            CREDITS
  879.  
  880. Alphabetically:
  881.  
  882.   o  Michael Abrash for doing so much work on Mode X and PC graphics in
  883.      general.
  884.   o  Ralph Brown for the great work on the Interrupt List.
  885.   o  Kai Rohrbacher for the above contributions.
  886.   o  Finn Thoegersen for the VGA*.TXT files.
  887.   o  Yaniv Shaya for inspiring me to make finish version 1.0.  Good luck
  888.      with your project!
  889.   o  Myself for being so cool...  >;*]
  890.  
  891.  
  892.  
  893.  
  894.                          BIBLIOGRAPHY
  895.  
  896.   o  George Sutty & Steve Blair : "Advanced Pogrammer's Guide to the
  897.      EGA/VGA" from Brady.  A bit old perhaps, but covers all *standard*
  898.      EGA/VGA registers, and discusses most BIOS functions and other
  899.      operations.  Contains disk with C/Pascal source code.
  900.  
  901.   o  Michael Abrash : "Power Graphics Programming" from QUE/Programmer's
  902.      Journal.  Collections of (old) articles in Doctor Dobb's Journal on
  903.      EGA/VGA, read modes and write modes, animation, tweaking (320x240
  904.      and 360x480).  His newer ravings in DDJ covers fast 256-color
  905.      bitmaps, compiled bitmaps, 3D graphics, polygons, texture mapping
  906.      among other stuff.  Check out the XSHARP library available on all
  907.      simtel mirrors!
  908.  
  909.   o  Ralph Brown's interrupt list is a must for every serious
  910.      programmer, containing, among 1 million other things, a VGA BIOS
  911.      interrupt reference.  Available for anonymous ftp from
  912.      oak.oakland.edu in directory /pub/msdos/info as inter*.zip (Usually
  913.      3 files, around 330 Kb each), and on most serious BBSes.
  914.  
  915.   o  Richard F. Ferraro : "Programmer's Guide to the EGA and VGA video
  916.      cards including Super VGA".  I don't have this one, but heard it's
  917.      nice.  The Super VGA reference makes it attractive, though that is
  918.      no help with TWEAK.
  919.  
  920.   o  Richard Wilton : "Programmer's Guide to PC & PS/2 Video Systems"
  921.      Less technical, more application/algorithm oriented.  Supposed to be
  922.      good.
  923.  
  924.  
  925.  
  926.  
  927.                         HOW TO REACH ME
  928.  
  929.  
  930. I welcome any suggestions for further improvement of TWEAK.  I also
  931. accept donations if you think it's worth it, or if TWEAK has in any way
  932. helped you out with a tricky problem and you'd like to show your
  933. appreciation.  I will personally e-mail subsequent versions to people who
  934. donate $5 or more.  Make checks payable to Robert Schmidt personally.
  935.  
  936. Postcards from all over the world are fun to get.  Please, if you
  937. contact me by ordinary mail, use a postcard!  I would appreciate that a
  938. lot!
  939.  
  940.  
  941.  
  942. Internet e-mail: robert@solan.unit.no
  943.              or: robert@alkymi.unit.no (preferred at the moment)
  944.  
  945. (I guess those should be reachable from Compuserve and other networks
  946. too.)
  947.  
  948.  
  949.  
  950. If you ever join IRC, direct a /msg to Buuud for a chat!
  951.  
  952.  
  953.  
  954. Ordinary (snail-)mail:
  955.  
  956. Ztiff Zox Softwear
  957. c/o Robert Schmidt
  958. Stud.post 170
  959. Norwegian Institute of Technology
  960. Trondheim
  961. NORWAY
  962.  
  963.  
  964. Have phun!
  965.  
  966.