Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Peter Norton Programmer's Guide - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

  In general, control of the display screen, like most other computer
  operations, can be done in four ways:

  .  By using the programming-language services (for example, BASIC's SCREEN
     statement)

  .  By using the DOS services (see Chapters 16 and 17)

  .  By using the ROM BIOS video services (see Chapter 9)

  .  By direct manipulation of the hardware via memory or I/O ports

  The video services available through programming languages, DOS, and the
  ROM BIOS automatically place screen output data in the video buffer, with
  each type of service offering varying levels of control. The ROM BIOS
  services are particularly powerful, providing nearly all the functions
  needed to generate display-screen output, control the cursor, and
  manipulate screen information. (All video services are fully described in
  Chapter 9.) For maximum control over the video display, you also have the
  option of bypassing the software services and placing data directly in the
  video buffer--when you feel you have good reason to.

  --------------------------------------------------------------------------
  About the Cursor
    A blinking cursor is a feature of the text modes that is used to
    indicate the active location on the display screen. The cursor is
    actually a group of scan lines that fill the entire width of the
    character box. The size of the character-box varies with the video
    hardware and video mode: The Monochrome Display Adapter uses a
    9-pixels-wide-by-14-scan-lines-high format; the Color Graphics Adapter
    uses an 8-pixels-by-8-scan-lines format; the EGA's default text-mode
    character box is 8 pixels wide by 14 scan lines high; and the VGA's is 9
    by 16. The higher-resolution video subsystems use character boxes with
    more scan lines, so their text-mode characters appear sharper and more
    detailed, as you'll see in Appendix C.

    The default cursor format uses two scan lines near the bottom of the
    character box but may be changed to display any number of scan lines
    within the character box. Since the blinking cursor used in text modes
    is a hardware-created feature, software has only limited control over
    it.

    You can change the size of the cursor as well as its location on the
    screen using the services provided by the ROM BIOS. Interrupt 10H,
    service 01H lets you set the size of the cursor, whereas service 02H
    lets you move the cursor to any character position on the screen. The
    ROM BIOS also provides a service (interrupt 10H, service 03H) that
    reports the current size and location of the cursor.

    So far, we've been talking about the text-mode cursor. In graphics modes
    there is no hardware-generated cursor, but the ROM BIOS routines keep
    track of a logical cursor location that tells you the active screen
    location. As in text modes, you can use ROM BIOS services 02H and 03H to
    keep track of the graphics-mode cursor location.

    To create a cursor in graphics modes, many programs, including BASIC,
    simulate the block cursor by using a distinctive background color at the
    cursor location or by using the ASCII block characters.
  --------------------------------------------------------------------------

  Before opting for direct video output, you should know that it does
  interfere with windowing systems and more advanced multitasking operating
  environments. All the same, many important programs for the PC family
  generate direct video output--so many, in fact, that this has become a
  standard and accepted way of creating output. So, even though in the long
  run it's probably not wise to place output directly in the video buffer,
  everyone seems to be doing it.

  Basically, you can't mix programs that write directly into the display
  memory and windowing systems because two programs would be fighting over
  the control of the same memory and messing up each other's data. But
  because so many programs now generate direct video output, multitasking
  operating systems like OS/2 go to great lengths to accommodate programs
  that write directly to the display memory. A system like OS/2 can make
  this accommodation simply by keeping a separate copy of the program's
  display memory; when the program is running, the copy is moved into the
  display buffer, and when the program is stopped, a fresh copy of the
  display buffer is made. This technique allows OS/2 to run programs that
  work directly with the display memory, but at a cost: First, computing and
  memory overhead go up; second, the program can't run in the background
  simultaneously with other programs; and third, the display information
  can't be "windowed"; that is, it can't be moved or adjusted in size.

  Programmers are faced with a conflict here: Direct output to the screen
  has the benefit of speed and power, but using ROM BIOS or higher-level
  services for screen output has the benefit of more flexibility for
  adapting to windowing systems, new video hardware, and so on. The best
  solution is to use both techniques, trading off portability whenever
  maximum performance is an absolute priority.

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson