![]() |
|
![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
|
![]() |
![]() |
Listing 8.1 then slides the split screen up from the bottom of the screen, one scan line at a time. The split screen slides halfway up the screen, bounces down a quarter of the screen, advances another half-screen, drops another quarter-screen, and finally slides all the way up to the top. If youve never seen the split screen in action, you should run Listing 8.1; the smooth overlapping of the split screen on top of the normal display is a striking effect. Listing 8.1 isnt done just yet, however. After a keypress, Listing 8.1 demonstrates how to turn the split screen off (by setting all bits of the split screen start scan line to 1). After another keypress, Listing 8.1 shows that the split screen can never cover the whole screen, by setting the start address to 0 and then flipping back and forth between the normal screen and the split screen with a split screen start scan line setting of zero. Both the normal screen and the split screen display the same text, but the split screen displays it one scan line lower, because the split screen doesnt start until after the first scan line, and that produces a jittering effect as the program switches the split screen on and off. (On the EGA, the split screen may display two scan lines lower, for reasons Ill discuss shortly.) Finally, after another keypress, Listing 8.1 halts. VGA and EGA Split-Screen Operation Dont MixYou must set the IS_VGA equate at the start of Listing 8.1 correctly for the adapter the code will run on in order for the program to perform properly. This equate determines how the upper bits of the split screen start scan line are set by SetSplitScreenRow. If IS_VGA is 0 (specifying an EGA target), then bit 8 of the split screen start scan line is set by programming the entire Overflow register to 1FH; this is hard-wired for the 350-scan-line modes of the EGA. If IS_VGA is 1 (specifying a VGA target), then bits 8 and 9 of the split screen start scan line are set by reading the registers they reside in, changing only the split-screen-related bits, and writing the modified settings back to their respective registers. The VGA version of Listing 8.1 wont work on an EGA, because EGA registers arent readable. The EGA version of Listing 8.1 wont work on a VGA, both because VGA monitors require different vertical settings than EGA monitors and because the EGA version doesnt set bit 9 of the split screen start scan line. In short, there is no way that I know of to support both VGA and EGA split screens with common code; separate drivers are required. This is one of the reasons that split screens are so rarely used in PC programming. By the way, Listing 8.1 operates in mode 10H because thats the highest-resolution mode the VGA and EGA share. Thats not the only mode the split screen works in, however. In fact, it works in all modes, as well see later. Setting the Split-Screen-Related RegistersSetting the split-screen-related registers is not as simple a matter as merely outputting the right values to the right registers; timing is also important. The split screen start scan line value is checked against the number of each scan line as that scan line is displayed, which means that the split screen start scan line potentially takes effect the moment it is set. In other words, if the screen is displaying scan line 15 and you set the split screen start to 16, that change will be picked up immediately and the split screen will start after the next scan line. This is markedly different from changes to the start address, which take effect only at the start of the next frame. The instantly-effective nature of the split screen is a bit of a problem, not because the changed screen appears as soon as the new split screen start scan line is setthat seems to me to be an advantagebut because the changed screen can appear before the new split screen start scan line is set.
The solution is simple: Set the split screen start scan line at a time when it cant possibly match the currently displayed scan line. The easy way to do that is to set it when there isnt any currently displayed scan lineduring vertical non-display time. One safe time thats easy to find is the start of the vertical sync pulse, which is typically pretty near the middle of vertical non-display time, and thats the approach Ive followed in Listing 8.1. Ive also disabled interrupts during the period when the split screen registers are being set. This isnt absolutely necessary, but if its not done, theres the possibility that an interrupt will occur between register sets and delay the later register sets until display time, again causing flicker. One interesting effect of setting the split screen registers at the start of vertical sync is that it has the effect of synchronizing the program to the display adapters frame rate. No matter how fast the computer running Listing 8.1 may be, the split screen will move at a maximum rate of once per frame. This is handy for regulating execution speed over a wide variety of hardware performance ranges; however, be aware that the VGA supports 70 Hz frame rates in all non-480-scan-line modes, while the VGA in 480-scan-line-modes and the EGA in all color modes support 60 Hz frame rates.
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
|