VRServer - Vertical Retrace Interrupt Server, v1.00 --------------------------------------------------- by Petteri Kangaslampi 1993. NOT COPYRIGHTED, PUBLIC DOMAIN Table of contents: ------------------ 1. Introduction 2. License 3. Using VRServer 3.1 Initialization 3.2 The Vertical Retrace interrupt 3.3 Synchronization 4. Compatibility 5. Troubleshooting 6. Contacting the author 1. Introduction --------------- VRServer is a collection of routines which allow an interrupt to be generated at every Vertical Retrace of the VGA card. The Vertical Retrace interrupt helps to maintain correct speed in games which don't run in full frame-rate and it can be used to "automatize" some simple tasks like repainting parts of the screen in various kinds of programs. Using the Vertical Retrace interrupt also eliminates the need to wait for the Vertical Retrace manually, thus freeing that processor time for other use. 2. License ---------- The VRServer with all its source code is fully public domain. It can be freely distributed and used in any form and in all kinds of applications, including commercial ones. I only ask for one thing: If you use this code in your programs, please mention it somewhere in the program or it's documentation. "Forgetting" to do so is not illegal or anything - it's simply lame and morally wrong. I also hope that if you distribute this source code in original or modified form, you would leave my name on it. Since VRServer is public domain it has no warranties of any kind. That means that you can freely use VRServer, but you must do it with your own risk. I hope you understand that. 3. Using VRServer ----------------- Since VRServer is very simple and straightforward to use, this documentation is very brief. If you don't understand something, take a look at the example programs. They're there to help you. 3.1 Initialization ------------------ VRServer is initialized with the InitVRServer() -function. It takes as arguments two far pointers to the functions you wish to be called by the Vertical Retrace interrupt. You should call InitVRServer() after you have initialized the display mode to make sure VRServer gets properly sychronized with the screen refresh. 3.2 The Vertical Retrace interrupt ---------------------------------- When the interrupt comes, VRServer saves all the standard 8086 registers before calling your routines, but if you use the 32- bit registers or ES or GS registers added to the 80386 you must preserve them yourself. You also must preserve the DS register. The first function will be called just before the Vertical Retrace and should therefore be as short as possible to be sure the Vertical Retrace doesn't start during the execution of this routine. That means that you shouldn't do much else in this routine that just, for example, set the screen page start address or panning registers and leave everything that doesn't need to be done before the Vertical Retrace to the second routine. The second function is called in the Vertical Retrace. It's execution time is not critical and it can be used, for example, for repainting the screen and setting the palette. You should take care that the execution of this routine never takes more time that about 1/80th of a second so that a new Vertical Retrace Interrupt won't arrive before the current one is handled. After the both user functions are called, the Vertical Retrace interrupts calls the old timer interrupt if necessary, about 18.2 times per second. That ensures that the DOS clock stays in time, the diskette drive motors are turned off etc. 3.3 Synchronization ------------------- When VRServer is initialized it synchronizes the interrupt to the screen refresh by calculating the time elapsed between two Vertical Retraces. The Vertical Retrace interrupt also resets the timer in every Vertical Retrace so there is no need to resynchronize VRServer if the interrupts have been disable for some time. You must, however, resynchronize VRServer by calling SyncVRServer() if the screen refresh rate changes. Some of the display modes have a refresh rate of 60Hz and some 70Hz. If you are not sure whether the refresh rate changes or not, I suggest you call the SyncVRServer() always you change the display mode. 3.4 Disabling the VRServer -------------------------- You can remove the VRServer and thus remove the Vertical Retrace Interrupt by calling RemoveVRServer(). You must ALWAYS do that before your program exits IF you have called InitVRServer(). RemoveVRServer() returns the old timer interrupt and frequency. 4. Compatibility ---------------- VRServer should work with any 8086 compatible processor and EGA compatible video card, but it has only been tested with 80386 and VGA. VRServer has been tested to compile with Borland C++ 3.1, Borland Turbo Pascal 6.0 and Borland Pascal 7.0, in real and protected mode. The assembly code compiles at least with Borland Turbo Assembler 3.1. 5. Troubleshooting ------------------ Interrupt routines are very hard to debug and therefore it helps a lot if you can get your routines correct immediately. But since every programmer makes mistakes sometimes, here are some remarks about the routines you want VRServer to call: * NEVER CALL ANY DOS FUNCTIONS * Preserve the DS register * Preserve any non-8086 (eg. EAX) registers you use * Make the routines, especially the first one, as simple as possible Also remember that VRServer can have bugs in it too, just like this documentation. Take look at the source code and example programs if you don't understand how something must be done. 6. Contacting the author ------------------------ If you have a problem you can't solve, have some ideas how to improve VRServer or want to send me some money (why would you?), you can contact me by writing to: Petteri Kangaslampi Simeoninkuja 4 36240 Kangasala 4 Finland You can also contact me without any particular reason. I can't promise to answer everyone, so if you want to be dead sure about getting an answer, you should include a SASE (Finnish stamps only...). If live outside Finland and can't get any Finnish stamps you can send me a 3.5" HD-diskette to cover the postage fees.