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