--- /dev/null
+\r
+\r
+\r
+\r
+\r
+\r
+ TWEAK 1.6á - Mold your own VGA modes\r
+\r
+ by Robert Schmidt of Ztiff Zox Softwear, 1992-93\r
+\r
+\r
+ This program and the accompanying source files\r
+ are hereby donated to the public domain.\r
+ (for whatever that's worth...)\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+(Sorry for not page-formatting this doc. The headers can be found by\r
+doing a text search with your favourite editor.)\r
+\r
+\r
+Contents:\r
+\r
+WHAT IS TWEAK, ANYWAY?\r
+SUGGESTION BOX\r
+DISCLAIMER\r
+A QUICK PRIMER\r
+WHAT HAS TWEAK GOT TO DO WITH THIS?\r
+A COUPLE OF RULES\r
+A TUTORIAL\r
+EDITOR REFERENCE\r
+FREQUENTLY ASKED QUESTIONS\r
+THE TWEAK FILES\r
+USING TWEAK MODES ON YOUR OWN\r
+THE INCLUDED FILES\r
+THE 'MISC' DIRECTORY\r
+CREDITS\r
+BIBLIOGRAPHY\r
+HOW TO REACH ME\r
+\r
+\r
+\r
+\r
+ WHAT IS TWEAK, ANYWAY?\r
+\r
+\r
+TWEAK is an utility to ease the work of twiddling with the registers on\r
+a standard VGA compatible video card to produce and explore new, previously\r
+undocumented screen modes with weird resolutions. You will want to\r
+purchase a technical VGA reference to get the full potential out of\r
+TWEAK, but I included some files to get you started (see the section\r
+on the 'MISC' directory).\r
+\r
+TWEAK.EXE is the main executable. This version is not compatible with \r
+any versions prior to 1.0, so if you want to use files created by \r
+version 0.9x, convert them with 09TO10.EXE. \r
+\r
+Stop press! In the subdirectory XINTRO is an article which serves as\r
+an introduction to programming in Mode X (320x240 with 256 colors).\r
+Make sure you read this if you're new to tweaking and Mode X!\r
+\r
+MODES.DOC describes some of the more exciting 256x256, 400x300 \r
+and 400x600 256-color modes!\r
+\r
+\r
+\r
+\r
+ SUGGESTION BOX\r
+\r
+\r
+All suggestions to enhance or modify TWEAK are welcome, especially bug\r
+reports/fixes. So are donations, for that matter. See e-mail and\r
+snail-mail addresses at the end of this file.\r
+\r
+Please send me any changes you make to enhance TWEAK or to make it\r
+compatible with other compilers or video cards, and I will start\r
+including conditional sections for each supported compiler.\r
+Do *not* re-release the changed source without my permission.\r
+Well, how can I stop ya...?\r
+\r
+Any suggestions and contributions will be credited in subsequent\r
+versions, although I can't guarantee that your ideas will actually be\r
+used.\r
+\r
+\r
+\r
+\r
+\r
+ DISCLAIMER\r
+\r
+\r
+I don't think this is neccessary in PD stuff, but everybody else does\r
+it:\r
+\r
+The author author of this archive has used his best efforts in \r
+preparing it. However, the author makes no warranty of any kind, \r
+expressed or implied, with regard to the programs, data or \r
+documentation included with the archive. The author shall not be \r
+liable in any event for incidental or consequential damages in \r
+connection with, or arising out of, the furnishing, performance, \r
+quality, or use of the programs, data or documentation included in this \r
+archive.\r
+\r
+Phew.\r
+\r
+Some time ago, putting illegal or unsupported values or combinations\r
+of such into the video card registers might prove hazardous to both\r
+your monitor and your health. I have *never* claimed that bad things\r
+can't happen if you use TWEAK, although I'm pretty sure it never will.\r
+I've never heard of any damage arising from trying out TWEAK, or from\r
+general VGA tweaking in any case. I did receive a mail from a person\r
+whose monitor failed producing the correct colors, after using mode\r
+X.\r
+\r
+\r
+\r
+\r
+\r
+\r
+ A QUICK PRIMER\r
+\r
+\r
+You never heard about neither documented nor undocumented modes, you \r
+say? Well, to begin with: Your VGA card has a number of registers \r
+that control the way the card works. That is, how it is going to \r
+translate the data that programs put into the video memory, to the \r
+signals that produce text and/or graphics on your monitor.\r
+\r
+The standard interface to a video card on all IBM compatible PCs is the \r
+BIOS, which consists of several device independant routines for setting \r
+screen modes, moving the cursor, writing text, scrolling blocks of text \r
+etc. The BIOS also takes care of setting the appropriate registers at \r
+appropriate times, for example when changing screen modes. That way, \r
+programmers have a consistent interface to the VGA, and usually won't \r
+need to tamper with the registers directly.\r
+\r
+A screen mode specifies the resolution of the image you see on the \r
+screen, i.e. the number of pixels (dots) horizontally and vertically, \r
+the number of colors, and wether the screen should be capable of \r
+showing just text, or if graphics are allowed. These things are \r
+controlled by the VGA registers, and the BIOS contains a number of \r
+predefined tables of register values for the standard VGA modes we've \r
+all come to love and honour. Mode number 3, for example, is the 80 \r
+characters times 25 lines (80x25) text screen that most people use \r
+daily. Mode number 19 (or 13h in hexadecimal) is the 256-color 320x200 \r
+mode used in most popular games supporting the VGA.\r
+\r
+\r
+\r
+\r
+\r
+\r
+ WHAT HAS TWEAK GOT TO DO WITH THIS?\r
+\r
+\r
+Well, some people, me included, are of the 'power-hungry' breed. We want\r
+to exploit the full potential of everything we get between our hands.\r
+We think that the one 320x200 256-color mode supported by all standard VGA\r
+BIOS'es is for wimps. Some guy came up with the idea of modifying the\r
+register configuration, to achieve greater resolution and a different\r
+video memory layout.\r
+\r
+TWEAK grants you direct access to all the most significant registers\r
+that control such things as resolution and colors. You may have thought\r
+that your VGA was limited to 320x200 when it was displaying 256 colors?\r
+Well, all VGAs are able to support no less than 400x600 in 256 colors.\r
+(The problem is with the monitors, which might not be sophisticated\r
+enough to support the relatively much higher clock frequency needed to\r
+output that many pixels. My monitor flickers and rolls occasionaly.)\r
+\r
+Most newer VGA cards' BIOSes add several enhanced modes not supported\r
+by the standard VGA defined by IBM, for example text modes with 132\r
+characters on each line, or graphics resolutions of 800x600, 1280x1024\r
+and more. Such cards are usually referred to as Super VGAs. To make it\r
+possible to produce such resolutions, video card developers has had to\r
+add new registers to the set of registers defined by the VGA. TWEAK is\r
+generally not able to support such extended registers, meaning that you\r
+will not be able to tweak a Super VGA any more than is possible on a\r
+standard VGA. Extensions that are provided by utilizing undefined bits\r
+in the standard VGA registers are supported however. The included\r
+Chips & Technologies specific 132x*.twk files are examples of such.\r
+\r
+The main reason for not including Super VGA (SVGA) support is that\r
+there are so many different SVGA standards. Nearly every developer has\r
+their own standard. Also, I can see no real reason for wanting to tweak\r
+any SVGAs, as the resolution dimensions they offer usually are far\r
+superior to the VGA's resolutions. With tweaked VGA modes there's\r
+a much higher propability that they will work on most VGAs and SVGA,\r
+than tweaked SVGA modes.\r
+\r
+If this is the first you have read about VGA registers and the BIOS,\r
+TWEAK.EXE and this documentation alone is not enough to get you going.\r
+You will need, and probably want, a somewhat technical reference to the\r
+VGA, which explains all standard VGA registers and the meaning of every\r
+contained bit. Although TWEAK doesn't support it, you'll probably want\r
+a reference which also contains some discussion on Super VGAs, just for\r
+your convenience when you want to program serious applications etc. If\r
+you're of the adventurous breed, check out the VGA.TXT and VGABIOS.TXT\r
+files included in the .\MISC directory.\r
+\r
+You see, tweaking the VGA is not as simple as putting the horizontal\r
+resolution in one register, the vertical in another and the number of\r
+colours in yet another. Several registers has to be set to cooperating\r
+values that work together to acheive what you want. Single bits has to\r
+be toggled into the correct states, even before you can see anything on\r
+screen. TWEAK simplifies this process by letting you do this\r
+interactively, and by letting you test your register set at the touch\r
+of one key (ENTER, actually). The pre-TWEAK process was to make a small\r
+program that set up the registers in the way the programmer thought\r
+would work. If it didn't he had to edit the program source file,\r
+recompile, and re-run. Not seldom, the PC crashed because of some\r
+*really bad* register values, and a full reset was required.\r
+\r
+TWEAK let you save and load register sets to and from files, and let\r
+you select any video mode supported by your BIOS to work out from.\r
+It supports text modes and graphics, 16-color and 256-color. Monochrome\r
+modes and CGA modes (4- and 2-color), however, are not supported,\r
+because they use another set of I/O ports, and because few people are\r
+really interested in them.\r
+\r
+As of version 1.6, TWEAK further simplifies the VGA tweaking process by \r
+providing instant feedback on the register values, in the form of a \r
+live mode heuristic, i.e. a detection scheme tried to figure out what \r
+type of mode your making, the number of colors, its physical and \r
+virtual resolution, the number of pages (both horizontally and \r
+vertically).\r
+\r
+\r
+\r
+\r
+\r
+\r
+ A COUPLE OF RULES\r
+\r
+\r
+I'll be the first to admit: TWEAK isn't much of an editor. The screen\r
+is boring, there is just one simple help window, no undo command, no\r
+file pick lists etc. In short, TWEAK is not meant for people not\r
+knowing what they are doing. I strongly beleive that nothing can be\r
+damaged from the use of TWEAK, but for starters, I'll recommend the\r
+following precautions:\r
+\r
+ * When loading/saving, take care to check that you selected the\r
+ function (load or save) that you want, before typing a filename\r
+ and pressing Enter. Also verify that the filename you type when\r
+ saving is the filename that you want, because TWEAK overwrites\r
+ any existing files with the same name without asking for permission.\r
+\r
+ * If, when you press the Enter screen to test the screen mode,\r
+ nothing appears after 5-10 seconds, press Enter again. If you're\r
+ not immediately returned to the editing screen, reboot your\r
+ computer by pressing the reset button. Keep in mind that some of\r
+ the test patterns, especially the 256-color 4-planar one, can be\r
+ slow to put into the video memory buffer, so be a *little*\r
+ patient & tolerant.\r
+\r
+That last rule is present to prevent that the monitor is exposed to crazy\r
+sync timings for too long a time. And I repeat, there usually never is\r
+any reason to panic, even if your monitor makes strange sounds\r
+('tweeeeee' for example, or 'flick-flick-flick'). Press ENTER, wait for\r
+a couple of seconds more, then reset your computer if the edit screen\r
+doesn't reappear, and try a different approach.\r
+\r
+\r
+\r
+\r
+\r
+\r
+ A TUTORIAL\r
+\r
+\r
+To start TWEAK, change to the directory where you have put the files,\r
+and type TWEAK at the DOS prompt. Well, now you're in the editor, and\r
+you can see the following things (you might want to print this tutorial\r
+so you have it on paper):\r
+\r
+ * One (possibly two) column(s) of VGA registers on the form:\r
+ ppp (ii) Register Name : vv\r
+ where\r
+ - ppp is the port number\r
+ - ii is the index into that port, if applicable\r
+ - vv is the selected value for this register\r
+ All numbers are hexadecimal. The current register is marked by one\r
+ arrowhead on each side of the line. When you first start TWEAK,\r
+ the current register is the top left.\r
+\r
+ * A bit pattern display showing the bit pattern of the 8-bit value\r
+ contained in the currently selected register.\r
+\r
+ * The bottom line tells you which test pattern is currently active.\r
+\r
+ * You will also see the mode heuristic which usually makes a good\r
+ guess at what mode you have at the moment.\r
+\r
+When executed, TWEAK starts up by reading the registers of your current \r
+BIOS mode, so that you have something to work with. This is usually a \r
+text mode, 80x25 for example, so you'll probably want to set a graphics \r
+mode for more interesting results.\r
+\r
+Now try the following simple tutorial:\r
+\r
+ 1. Press H, and a red window should appear, describing all keys\r
+ available for use in TWEAK. These will also be described below.\r
+\r
+ 2. Press M, then type the number 03. Notice that you don't have to\r
+ press ENTER. You have now selected BIOS mode 3 as the basis for\r
+ you explorations. Notice also the information provided by the \r
+ mode heuristic on the right.\r
+\r
+ 3. Press TAB until 'Text screen, 16 point' appears at the bottom line,\r
+ if it doesn't already. TAB selects which test pattern to use, and\r
+ you have now readied the 16-point font version of the text screen\r
+ test.\r
+\r
+ 4. Press ENTER. You should see a screen with numbers along the top\r
+ row, and various characters and colors down the rest of the screen.\r
+ This is the text test pattern, as it looks when viewed in mode 3.\r
+ Press ENTER to return to editing mode.\r
+\r
+ 5. Now press F10, and type '40x12' and press ENTER. This loads the\r
+ file '40x12' and uses its contents as the current register set. \r
+ Notice how the mode heuristic immediately changes.\r
+\r
+ 6. Press ENTER again. A screen similar to the previous test pattern\r
+ should appear, but the characters should be twice as wide and twice\r
+ as high. This is a tweaked VGA mode, which is not supported by the\r
+ BIOS. It looks a little odd, as the bottom line is cut in half,\r
+ making this a 40x12.5 text mode, in fact. Press ENTER to return.\r
+\r
+ 7. Press F10, type '360x480.256' and ENTER. Take a look at the \r
+ mode heuristic again. Press TAB until the text 'Graphics \r
+ autodetect' appear in the bottom line.\r
+\r
+ 8. Press ENTER. This is a well known tweaked VGA mode that has even\r
+ been used in commercial games for the PC, but it remains\r
+ unsupported by the BIOS (and it probably always will). If the\r
+ screen rolls, try adjusting your monitor knobs. If you can't get a\r
+ steady picture, it probably means your monitor isn't capable of\r
+ handling the horizontal resolution of 360 pixels.\r
+\r
+ 9. Try using the arrows to scroll the virtual screen.\r
+\r
+ 9. Press ENTER to return to editing, then press ESC and 'Y' to quit \r
+ TWEAK.\r
+\r
+\r
+The last graphics display might not have been especially pleasing to the\r
+eye. First, if the picture was rolling uncontrollably, you might think\r
+that TWEAK is of no use for you, as your monitor isn't good enough.\r
+However there are still interesting things to try out. There are\r
+tweaked modes 'available' with a little lower resolution that are almost\r
+guaranteed to work on your monitor, and which are of great interest to\r
+games programmers for example. The file 320x240.256 contains the\r
+register set for the infamous Mode X, which was 'discovered' and\r
+documented by Michael Abrash in his monthly columns in Doctor Dobbs\r
+Journal.\r
+\r
+Following points 7 onward above, see if you can load Mode X into the \r
+editor and get the test screen going!\r
+\r
+Mode X has the following interesting properties:\r
+\r
+ * The pixels are 'perfectly' square. That is, if you try to draw a\r
+ circle with aspect ratio 1:1, it will look like a circle (unless\r
+ your monitor is adjusted to some extreme). The BIOS mode 13h\r
+ (320x200x256) has pixels that are a little higher than they are\r
+ wide, making 1:1 circles look stretched vertically.\r
+\r
+ * The video memory is divided into 4 planes, each of which contains\r
+ 64 Kb. By setting the Write Plane Enable register to the actual\r
+ plane, you can address the full 256 Kb of video memory through the\r
+ 'tiny' address space of 64 Kb from 0xA000:0 to 0xA000:0xFFFF.\r
+ Thus, you can have more than three full screens in video memory at\r
+ any one time, making you able to perform animation tricks as\r
+ page flipping, and to do fast 32-bit video to video transfers.\r
+\r
+This was just to get you going, and others have written tons of text on\r
+drawing stuff (lines, circles, images) in Mode X. The rest of this\r
+part will deal with the commands available in TWEAK. To get more\r
+information about VGA programming in general and registers and Mode X \r
+in particular, check out the reference list somewhere at the end.\r
+\r
+Stop press! Read the article in the XINTRO subdirectory for an\r
+introduction to Mode X.\r
+\r
+\r
+\r
+\r
+\r
+ EDITOR REFERENCE\r
+\r
+\r
+This reference applies only to version 1.0 of TWEAK or later, although\r
+*most* keys are supported by the included version 0.95 too.\r
+\r
+Select the register value you want to modify using the following keys:\r
+\r
+ Up selects previous register\r
+ Down selects next register\r
+ Home selects first register\r
+ End selects last register\r
+\r
+Use these keys to modify a register value:\r
+\r
+ a 2-digit, hexadecimal number : sets the register to the given value\r
+ '-' decreases the value of the register\r
+ '+' increases the value of the register\r
+ F1 ... F8 toggle bits 7, 6, ..., 0 of the selected register,\r
+ respectively.\r
+\r
+Use these keys for testing the set of register values:\r
+\r
+ TAB [->|] cycle among the available test patterns, to find the\r
+ one you think will suit your custom register set.\r
+ Shift+TAB cycles in the opposite direction.\r
+\r
+ ENTER sends your custom register set to the VGA registers, then\r
+ writes the selected test pattern to the video memory buffer.\r
+\r
+Some other important or useful actions:\r
+\r
+ Backspace toggles the active state of the current register. If a\r
+ register is inactive, it color is grey instead of yellow.\r
+ When you test the mode (by pressing ENTER), inactive\r
+ registers will *not* be sent to the VGA card. Also, they\r
+ will *not* be saved to the file when a Save command is\r
+ executed. This feature is included to enable you to ignore\r
+ registers that doesn't affect your screen mode. For\r
+ example, for most practical uses, the Color Compare register\r
+ can be deactivated.\r
+\r
+ 'M' prompts the user for a 2-digit, hexadecimal number\r
+ specifying a standard VGA BIOS screen mode number. Note\r
+ that TWEAK does *not* support true monochrome modes.\r
+ The VGA is set to this mode using INT 10h with AX=mode\r
+ number. Then all relevant registers are read from the\r
+ VGA into the editing set, and you're returned to the\r
+ editing screen.\r
+\r
+ F9 or 'S' prompts the user for a file name, then saves the register\r
+ set to this file, overwriting any pre-existing\r
+ file by the same name. Inactive registers are not saved,\r
+ thus there are no longer a fixed size to TWEAK's mode\r
+ files.\r
+\r
+ F10 or 'L' prompts the user for a file name, then loads the register\r
+ set from this file, if it exists. Registers that are\r
+ supported by TWEAK, but that are not included in the file,\r
+ will be deactivated (greyed).\r
+\r
+ ESC quits TWEAK, if you answer 'y' or 'Y' to the 'Really\r
+ quit?' question. Make sure you have saved your work.\r
+\r
+Pressing just ENTER at one of the two file name requests will cancel \r
+the file operation.\r
+\r
+\r
+There are currently 6 available test screens with TWEAK. Numbers in\r
+parentheses are all the standard VGA BIOS modes that display the test\r
+patterns correctly:\r
+\r
+ o An autodetected graphics screen test. This will detect *most*\r
+ EGA and VGA graphics modes (of course no monochrome modes), and\r
+ display a pretty screen containing:\r
+\r
+ - axes along the left and top borders visualizing the resolution.\r
+ - text telling you both the physical and the virtual resolutions,\r
+ and the number of colors.\r
+ - the entire palette available in this mode. Note that the\r
+ palette is *not* set, so the colours are not guaranteed to be\r
+ the normal VGA palette, except in 16-color mode.\r
+\r
+ The following keys are available in the autodetect test screen:\r
+\r
+ - arrows scroll the screen across the virtual area\r
+ - ESC returns to the editor\r
+\r
+ If the mode being edited is not a graphics mode, a text screen\r
+ appears with some helping hints.\r
+\r
+ o 2 text test screens at 0B800h\r
+ - one using the normal 8x16-point VGA font (0, 1, 2, 3)\r
+ - one using the 8x8-point CGA font (normally used in 43/50-line\r
+ modes, but none of those are defined by the VGA BIOS. Check\r
+ VGABIOS.DOC for the function to load a specific font in your \r
+ own programs.)\r
+\r
+ o A screen for 4-planar, 16-color modes at 0A000h (0Dh, 0Eh, 10h,\r
+ 12h)\r
+\r
+ o A screen for 4-chained, 256-color modes at 0A000h (13h)\r
+\r
+ o A screen for 4-planar, 256-color modes at 0A000h (None supported\r
+ by BIOS)\r
+\r
+See the source (TESTPAT.CPP) for descriptions on how the test patterns are\r
+supposed to look. Generally, if it looks good, it should be correct.\r
+\r
+\r
+\r
+\r
+\r
+ FREQUENTLY ASKED QUESTIONS\r
+\r
+\r
+Q: I'd like to study the register configuration for a screen mode\r
+ supported by my (Super-)VGA. How do I get to it?\r
+\r
+A: The 'M' key lets you select a BIOS mode to study. Note that you\r
+ will need to know the mode number. Note that TWEAK does not \r
+ support any SVGA-specific registers.\r
+\r
+\r
+Q: None of the tests seem to produce sane results. The screen\r
+ a) goes black,\r
+ b) rolls or\r
+ c) the program crashes.\r
+\r
+A: a) - Make sure you tried ALL 5 tests.\r
+ - Set the Color Plane Write Enable register to 0Fh.\r
+ - Note that Super VGA modes are generally not supported\r
+ (though they *might* work).\r
+ b) - The timing/sync registers are not set correctly/in sync.\r
+ See your VGA reference for more information.\r
+ - Try adjusting the knobs on your monitor.\r
+ c) - I know some (S)VGAs completely hang the system if\r
+ unsupported bit combinations are fed into the Misc.\r
+ Output Register (0x3c2). This is one of the most useful\r
+ registers, however, so experiment with care, and take note\r
+ of what values causes the crash.\r
+ - You may have hit a major incompatibility/bug. Send me a\r
+ mail, telling me what kind of hardware you're using. I\r
+ will probably not be able to fix it, but an incompatibility\r
+ list will be emitted with the next release, if any.\r
+\r
+\r
+Q: How about a TSR to save the current register configuration from\r
+ any program?\r
+\r
+A: I've considered this, but haven't had the time. A hint, though:\r
+ Get CBOOTxxx.ZIP from simtel or any mirror, in .../msdos/sysutl.\r
+ This program lets you break out from most applications,\r
+ *without* resetting the screen mode. A typical session:\r
+ - Install CBOOT.\r
+ - Run FRACTINT (a fractal explorer package, supporting lots\r
+ of tweaked modes), and select the mode you want to 'grab'.\r
+ - Press ALT+SHIFT+B, and the CBOOT menu pops up.\r
+ - Press '7' to reset interrupt vectors.\r
+ - Press '6' to 'properly' exit from FRACTINT.\r
+ - You might not see it, but you should be at the DOS prompt.\r
+ - Run TWEAK directly, which will start up with the current\r
+ register configuration. Now you're off!\r
+ From programs (games) which assume total keyboard domination, I\r
+ currently cannot help you grab modes.\r
+\r
+\r
+Q: I'd like to use tweaked modes in my own programs.\r
+\r
+A: Provided you have produced TWEAK files corresponding to your\r
+ modes, take a look at the example files for different approaches\r
+ to using the mode files. The examples are in C, but are simple\r
+ enough, so translation to Pascal should be a breeze.\r
+\r
+\r
+Q: - What is the register which makes x do y/sets a to b/etc.?\r
+ - Is there a BIOS call to do x?\r
+\r
+A: First check the VGA.TXT and VGABIOS.TXT files in the MISC\r
+ directory. If they don't help you, please consider buying a\r
+ technical reference to the VGA. That would please you and me.\r
+\r
+\r
+Q: How do I make a mode with resolution x times y with z colors?\r
+\r
+A: - See the sample *.TWK, *.256 and *.16 files provided with\r
+ TWEAK. Not a great lot, but you might be able to work out\r
+ something from one of those.\r
+ - Get FRACTINT or SVGABGI, and use the method mentioned above to\r
+ 'grab' modes from these programs.\r
+ - Learn what each of the VGA timing registers means.\r
+ - Experiment! That's what I had to do.\r
+\r
+\r
+Q: I can't find this MISC or XINTRO directory!\r
+\r
+A: Make sure you unzip the TWEAK archive with the -d option, which\r
+ is needed to extract subdirectories. I.e:\r
+ PKUNZIP -D A:TWEAK10\r
+ If you didn't use -D, the files in the MISC directory are mixed\r
+ in with the rest of the TWEAK package files, all in the same\r
+ directory.\r
+\r
+\r
+Q: I have lots of files with modes that I saved with version 0.9 of\r
+ TWEAK...\r
+\r
+A: Use the 09TO10 utility to convert them. Run 09TO10.EXE with no\r
+ parameters for a simple help screen.\r
+\r
+\r
+Q: What do I need to rebuild TWEAK and/or the utilities?\r
+\r
+A: You will need Borland C++. I used version 3.1, but it might\r
+ work as far back as Turbo C++ 1.0. I included a Makefile to\r
+ make rebuilding as painless as possible, provided you have\r
+ BCC.EXE in your path, and it knows where to find headers and\r
+ libraries (usually it does). I know some of the sources\r
+ produce warnings, but feel free to ignore them. I did.\r
+\r
+\r
+Q: What do I need to use the mode files produced by TWEAK in my own\r
+ programs?\r
+\r
+A: If you want to use the TwkUser module, you'll need a C compiler.\r
+ I don't think I used anything Borland specific here.\r
+ Otherwise the file format is pretty simple, so you should have\r
+ no problem making similar functions/procedures using any\r
+ language (assembler, Basic, Pascal, Prolog...).\r
+\r
+\r
+Q: Where can I find more information on tweaking the VGA?\r
+\r
+A: See the Bibliography section below. Michael Abrash's articles\r
+ in Doctor Dobb's Journal from a year or so are probably the best\r
+ sources. Join the rec.games.programmer newsgroup. There has\r
+ been some discussion on tweaking there, especially mode X\r
+ (320x240x256) and how to optimize code for this mode.\r
+\r
+\r
+Q: How can I ever repay you for making such a great utility?\r
+\r
+A: Easy! The cheapest way is to send me a cool postcard with some\r
+ (readable) words on it. I will of course accept donations too,\r
+ even though TWEAK is public domain. See the end of this file.\r
+\r
+\r
+Q: PKUNZIP refused to unzip the TWEAK archive!\r
+\r
+A: I guess you decoded this DOC file by hand, then... well, make\r
+ sure you transfer in BINARY mode from the ftp site, and in \r
+ BINARY from your user account to your PC.\r
+\r
+\r
+Q: I can't find my question in the Frequently Asked Questions list!\r
+ Does this mean I'm stupid?\r
+\r
+A: It might. :-) However, I just thought up all these questions\r
+ myself, so if you have a suggestion for more FAQs, don't\r
+ hesitate to let me know! I promise I won't laugh...\r
+\r
+\r
+Q: The mode heuristic tells me I have the mode I want, but none of \r
+ the test screens works, not even the autodetecting one!\r
+\r
+A: The heuristic is far from perfect. It does NOT verify that the \r
+ timing values you are using are sane - it merely checks the \r
+ registers determining the logical resolutions. The best advice \r
+ I can give is to get a VGA reference and try to learn what the \r
+ horizontal and vertical timing registers do. TWEAK is less \r
+ intelligent than you (hopefully)!\r
+\r
+\r
+\r
+\r
+ THE TWEAK FILES\r
+\r
+\r
+The file format used for saved files is pretty simple. The files will\r
+usually be bigger than the files saved with TWEAK 0.9, and version 0.9\r
+files are *not* readable by version 1.0. This is undetectable by TWEAK,\r
+because of the simple nature of the files. (No headers are present!) \r
+If you try, there's a fat chance that your computer will hang.\r
+\r
+Here is the format:\r
+\r
+offset 0: WORD - port number of first register\r
+offset 2: BYTE - index of first register\r
+offset 3: BYTE - value of first register\r
+\r
+offset 4: WORD - port number of second register\r
+.\r
+.etc.\r
+.\r
+\r
+Pretty simple, as you can see, but also flexible from TWEAK's point of\r
+view. This makes it easy to add new ports if neccessary. The file size\r
+is not constant, as registers that are disabled at save time are not\r
+written to the file. Divide the file size by 4 to determine the number\r
+of registers in a file, or just read to EOF (as TWEAK does... :).\r
+\r
+Also note that the VGA registers use varying methods for access. For\r
+some registers you just send the value directly to the port (ignoring the\r
+index). For some you send the index to the port, then the value to the\r
+port+1. For still some you have to ... Rather, refer to the source\r
+code for all the how-to's... it's not difficult, just inconvenient, and\r
+it hinders really general storage of register addresses and their values.\r
+\r
+Use the 09TO10.EXE program to convert from version 0.9 files to version\r
+1.0 files. Run 09TO10.EXE with no parameters for information on how to\r
+use the utility.\r
+\r
+I have selected the following standard of file extensions for\r
+TWEAK-files, but these are just suggestions for my own convenience:\r
+\r
+ o *.TWK are text modes\r
+ o *.16 are 16-color graphic modes\r
+ o *.256 are 256-color graphic modes\r
+\r
+Note that you'll always have to type an extension in TWEAK if you want\r
+any, as TWEAK neither assumes anything nor provides default extensions.\r
+\r
+I have also started addint a 'c' to the name (like in 256x256c.256) if \r
+the mode is chained, i.e. uses linear addressing like mode 13h. I add \r
+an 's' if the mode is specific to my Chips & Technologies SVGA.\r
+\r
+Make sure you read MODES.DOC!\r
+\r
+\r
+\r
+\r
+\r
+ USING TWEAK MODES ON YOUR OWN\r
+\r
+\r
+The Register and RegisterTable classes used in TWEAK.CPP might be a\r
+little huge and clumsy to use in your own programs, where you probably\r
+just want to set the registers according to a linked-in array.\r
+Therefore I have provided a simple C module for the following functions:\r
+\r
+ o Reading a file saved from TWEAK into a dynamically allocated\r
+ array of registers.\r
+ o Setting VGA registers according to the contents of an array of\r
+ registers.\r
+ o Setting a single register.\r
+\r
+The types and functions are declared in TWKUSER.H, which should be\r
+included in every source file using these functions. The definitions\r
+are contained in TWKUSER.C, which should be compiled under the wanted\r
+memory model and linked together with your program modules. You are\r
+free, in fact you're encouraged to modify the TWKUSER files to suit\r
+your own needs. In their present form, they just provide enough\r
+functionality to get you started.\r
+\r
+A couple of simple examples are provided - the second one is easiest to\r
+follow, and I think you will prefer that one:\r
+\r
+ o EXAMPLE1.C - demonstrates how to use a TWEAK-generated file\r
+ in your own program by loading the file at run-time, and setting \r
+ the VGA registers according to the file contents. The mode file \r
+ has to be available at run-time.\r
+\r
+ o EXAMPLE2.C - does the same, but now the TWEAK-file is converted to\r
+ a C-includable file by using the TWEAK2C utility. Thus, the contents\r
+ of the TWEAK file is linked with the program as global data, and no\r
+ external file is needed in addition to the executable.\r
+\r
+Both programs set the VGA to the famous Mode X, 320x240 in 256 colors,\r
+then fill the screen with some colors.\r
+\r
+Note that since the files produced by TWEAK does not keep any \r
+information on what BIOS mode they are based on, you are responsible \r
+for setting the palette used. Keep in mind that you need to set both \r
+the EGA and VGA palette for 256-color modes! The easiest way to \r
+accomplish this is to set mode 13h before outputting your register \r
+settings.\r
+\r
+I would very much like to provide similar Borland Pascal examples, but\r
+as I don't have Turbo/Borland Pascal available at the moment, I'm just\r
+going to skip it at this time. If *you* feel like porting the TwkUser.C\r
+and .H files to a Pascal unit, please do. It should be a peice of cake.\r
+If you mail the result to me, I'll probably include it in the next release\r
+of TWEAK, and in any case you'll be credited for your contribution.\r
+\r
+\r
+\r
+\r
+\r
+ THE INCLUDED FILES\r
+\r
+\r
+This is a dump of the 4DOS compatible DESCRIPT.ION file included in this\r
+archive:\r
+\r
+320x200.256 Planar 320x200x256\r
+320x240.256 Planar 320x240x256 (Mode X)\r
+360x480.256 Planar 360x480x256\r
+400x300s.256 Tweaked C&T SVGA planar\r
+400x600.256 Tweaked VGA, req. good monitor\r
+400x600s.256 Tweaked C&T SVGA planar\r
+432x600s.256 Tweaked C&T SVGA planar\r
+800x600s.16 Standard C&T SVGA BIOS mode\r
+40x12.twk Standard VGA BIOS mode 1, double scanned\r
+80x43.twk Standard VGA mode, needs 8x8 font\r
+80x50.twk Standard VGA mode, needs 8x8 font\r
+09to10.cpp Version 0.9x to 1.0 conv. util. source\r
+800x600.16 Tweaked VGA, req. good monitor\r
+example1.c C source for EXAMPLE1.EXE\r
+example2.c C source for EXAMPLE2.EXE\r
+makefile Type MAKE ALL to update TWEAK project\r
+namedreg.cpp C++ source defining NamedReg. members\r
+register.hpp C++ header declaring Register & NamedReg\r
+regtable.cpp C++ source defining RegisterTable\r
+regtable.hpp C++ header declaring RegisterTable\r
+screen.cpp C++ source defining screen functions\r
+screen.hpp C++ header declaring screen functions\r
+tweak.cpp C++ source defining TWEAK's main program\r
+tweak.doc Documentation for the TWEAK archive\r
+tweak2c.cpp C++ source for the TWEAK2C utility\r
+twkuser.c C source defining som usable functions\r
+twkuser.h C header with TwkUser.C prototypes\r
+register.cpp C++ source defining Register members\r
+320x240.c C file created by TWEAK2C\r
+c&t.dat Text file: list of supported registers\r
+256x256.256 Planar 256x256x256 (Mode Q)\r
+256x256c.256 Chained 256x256x256 (Mode Q, chained)\r
+testpat.cpp C++ source defining TestPatterns members\r
+testpat.hpp C++ header declaring TestPatterns\r
+256x240.256 Planar 256x240x256\r
+360x270.256 Experimental mode\r
+400x300.256 Planar 400x300x256 - great!\r
+detect.cpp C++ source for mode detected module\r
+detect.hpp C++ header for detect.cpp\r
+misc.hpp Various common routines and macros\r
+tweak095.cpp C++ source for TWEAK version 0.95\r
+vgalib.cpp The mode-independant VGA library source\r
+vgalib.hpp Header for VGALIB.HPP\r
+regedit.cpp C++ source for the RegisterEditor class\r
+regedit.hpp C++ header for REGEDIT.CPP\r
+descript.ion Descriptions of all files\r
+tweak.prj TWEAK archive BC++ 3.1 project file\r
+320x400.256 Planar 320x400x256\r
+360x360.256 Planar 360x360x256\r
+360x400.256 Planar 360x400x256\r
+376x564.256 Planar 376x564x256\r
+tweakold.dat Data file: list of supported registers\r
+132x25s.twk Standard C&T SVGA BIOS mode\r
+132x43s.twk Standard C&T SVGA BIOS mode\r
+132x50s.twk Standard C&T SVGA BIOS mode\r
+132x60s.twk Ultravision C&T SVGA mode\r
+modes.doc Document on Mode Q, 400x300 and 400x600\r
+\r
+The only files required to run TWEAK are:\r
+\r
+ o TWEAK.EXE\r
+ o TWEAK.DAT\r
+\r
+The register definitions have been moved out from the executable into\r
+the external .DAT file, to increase flexibility. You might edit the\r
+TWEAK.DAT file as you like to include support for any registers you\r
+might think of. Remember to update the number in the first line to\r
+reflect the number of defined registers. Note that if your new registers\r
+are not on one of the ports supported by TWEAK.EXE, you might need to\r
+modify and recompile the TWEAK sources to accomodate the new port(s).\r
+See REGISTER.CPP.\r
+\r
+\r
+\r
+Some words on my convention of naming files made by TWEAK:\r
+----------------------------------------------------------\r
+\r
+ o The general name format is XXXxYYY.CCC, where\r
+ XXX is the horizontal resolution\r
+ YYY is the vertical resolution\r
+ CCC is the number of colors supported, except for text modes,\r
+ which are named *.TWK.\r
+ o An 's' after YYY specifies a Super VGA specific mode which I grabbed\r
+ from the BIOS of my Chips & Technologies Super VGA. These modes will\r
+ probably *not* work with your card unless it's C&T compatible! I've\r
+ had reports that most of these modes even crash some sensitive\r
+ machines/VGA cards.\r
+ o A 'c' signals a chained 256-color mode, much like mode 13h, as \r
+ opposed to unchained modes like mode X.\r
+\r
+\r
+The Makefile & sources\r
+----------------------\r
+\r
+See the Makefile for all dependencies between the source files. It's not\r
+very complicated.\r
+\r
+The following makes are defined in the Makefile:\r
+\r
+make tweak: makes the TWEAK executable.\r
+make oldtweak: makes the TWEAK095 executable.\r
+make examples: makes EXAMPLE*.EXE.\r
+make utilities: makes 09TO10.EXE and TWEAK2C.EXE.\r
+make all: combines all the above makes.\r
+\r
+The Makefile is Borland C++/MAKE specific, and uses bcc.exe for all the\r
+work, with one reference to TWEAK2C.EXE.\r
+\r
+When studying the sources, note that TWEAK was started as an experiment\r
+in object oriented programming with C++. Thus the entire project may look\r
+a bit pompous in its use of classes, overloaded operators and such.\r
+Bear with me. At last I provided the TwkUser files to help you get\r
+started with something down to earth.\r
+\r
+In their current state, some of the source files produce a couple of\r
+warnings. These can be ignored. I do.\r
+\r
+Also note that TwkUser.* and the examples are C (but C++ compatible),\r
+while TWEAK and its utilities are strictly C++.\r
+\r
+\r
+The utilities TWEAK2C and 09TO10\r
+--------------------------------\r
+\r
+The following are dumps of the help screens from there programs:\r
+\r
+"TWEAK2C version 1.0\r
+ by Robert Schmidt of Ztiff Zox Softwear 1993\r
+ Converts a TWEAK version 1.x file to an #include-able C file.\r
+\r
+ Syntax: TWEAK2C <TWEAK-file> <C file to create> <array name>\r
+ All parameters are required."\r
+\r
+"09TO10 version 1.0\r
+ by Robert Schmidt of Ztiff Zox Softwear 1993\r
+\r
+ Converts TWEAK version 0.9 files to TWEAK version 1.0 files.\r
+\r
+ Syntax: 09TO10 <oldfile> <newfile>"\r
+\r
+For both programs, the following goes: If the file to be created already\r
+exists, the data contained in the file on disk will be overwritten with the\r
+new data.\r
+\r
+\r
+\r
+\r
+\r
+ THE 'MISC' DIRECTORY\r
+\r
+\r
+In this directory I have included files from other sources than myself.\r
+\r
+READ.ME\r
+VGA.TXT\r
+VGABIOS.TXT\r
+ I found these files in an archive assembled by Finn Thoegersen\r
+ of Denmark. I beleive VGABIOS.DOC was taken from Ralph Brown's\r
+ interrupt list. VGA.TXT lists VGA registers and their purpose,\r
+ but as I never used either VGA.TXT or VGABIOS.TXT, I can't\r
+ guarantee their correctness. The complete archive containing\r
+ similar info on most popular Super VGAs can be found on\r
+ garbo.uwasa.fi in /pc/doc-hard/vgadoc2.zip.\r
+\r
+CGA160.TXT\r
+ A post grabbed from some newsgroup, discussing tweaking on the\r
+ ancient CGA adapter. I think 16-color 'graphics' on a CGA\r
+ sounds pretty interesting, so I included it for your enjoyment.\r
+\r
+SETMODEX.ASM\r
+ Michael Abrash's code to set the VGA in the infamous Mode X.\r
+ Provided as an example of how programmers were used to tweaking,\r
+ before TWEAK came along... :)\r
+\r
+\r
+\r
+\r
+\r
+ CREDITS\r
+\r
+Alphabetically:\r
+\r
+ o Michael Abrash for doing so much work on Mode X and PC graphics in\r
+ general.\r
+ o Ralph Brown for the great work on the Interrupt List.\r
+ o Peter McDermott for an improved 16-color test screen, and valuable\r
+ sugestions, he also inspired me to make the autodetecting test\r
+ screen.\r
+ o Kai Rohrbacher for helpful bug reports and info on working modes.\r
+ o Finn Thoegersen for the MISC\VGA*.TXT files. See MISC\READ.ME\r
+ o Yaniv Shaya for inspiring me to make finish version 1.0. Good luck\r
+ with your project!\r
+\r
+\r
+\r
+\r
+\r
+ BIBLIOGRAPHY\r
+\r
+ o George Sutty & Steve Blair : "Advanced Pogrammer's Guide to the\r
+ EGA/VGA" from Brady. A bit old perhaps, but covers all *standard*\r
+ EGA/VGA registers, and discusses most BIOS functions and other\r
+ operations. Contains disk with C/Pascal source code.\r
+\r
+ o Michael Abrash : "Power Graphics Programming" from QUE/Programmer's\r
+ Journal. Collections of (old) articles in Doctor Dobb's Journal on\r
+ EGA/VGA, read modes and write modes, animation, tweaking (320x240\r
+ and 360x480). His newer ravings in DDJ covers fast 256-color\r
+ bitmaps, compiled bitmaps, 3D graphics, polygons, texture mapping\r
+ among other stuff. Check out the XSHARP library available on all\r
+ simtel mirrors!\r
+\r
+ o Ralph Brown's interrupt list is a must for every serious\r
+ programmer, containing, among 1 million other things, a VGA BIOS\r
+ interrupt reference. Available for anonymous ftp from\r
+ oak.oakland.edu in directory /pub/msdos/info as inter*.zip (Usually\r
+ 3 files, around 330 Kb each), and on most serious BBSes.\r
+\r
+ o Richard F. Ferraro : "Programmer's Guide to the EGA and VGA video\r
+ cards including Super VGA". I don't have this one, but heard it's\r
+ nice. The Super VGA reference makes it attractive, though that is\r
+ no help with TWEAK.\r
+\r
+ o Richard Wilton : "Programmer's Guide to PC & PS/2 Video Systems"\r
+ Less technical, more application/algorithm oriented. Supposed to be\r
+ good.\r
+\r
+\r
+\r
+\r
+ HOW TO REACH ME\r
+\r
+\r
+I welcome any suggestions for further improvement of TWEAK. I also\r
+accept donations if you think it's worth it, or if TWEAK has in any way\r
+helped you out with a tricky problem and you'd like to show your\r
+appreciation. I will personally e-mail subsequent versions to people who\r
+donate $5 or more. Make checks payable to Robert Schmidt personally.\r
+\r
+Postcards from all over the world are fun to get. Please, if you\r
+contact me by ordinary mail, use a postcard with some photos from the\r
+place you live on the front! I appreciate that a lot.\r
+\r
+\r
+\r
+Internet e-mail: robert@stud.unit.no\r
+\r
+(I guess this should be reachable from Compuserve and other networks\r
+too. I don't know how, though.)\r
+\r
+If you ever join the IRC service on the Internet, direct a /msg Buuud\r
+for a chat! I'm on pretty often.\r
+\r
+\r
+\r
+Ordinary (snail-)mail:\r
+\r
+Ztiff Zox Softwear\r
+c/o Robert Schmidt\r
+Stud.post 170\r
+Norwegian Institute of Technology\r
+Trondheim\r
+NORWAY\r
+\r
+\r
+Good luck, and remember the most important bit is to have fun!\r
+\r