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 cruising through the ROM BIOS video services, you've seen how they work
  individually. Once you have that information in mind, the next question
  usually is: Given a choice between using the ROM BIOS services directly or
  using higher-level services such as the DOS services or the services built
  into your programming language, which is best? The general advice that we
  always give is to use the highest-level services that will accomplish what
  you want to do. In this case, there is no specific reason for you to avoid
  using the ROM BIOS video services--you can't do any great harm by using
  them. But in the next chapter on the diskette services, we'll argue the
  case the other way, advising you to avoid using the ROM BIOS diskette
  services because more risk is associated with them.

  The video capabilities of the PC models are remarkable, and the ROM BIOS
  services give you full use of them. The DOS services, as you'll see in
  Chapters 14 through 18, are rather weak and provide only the simplest
  character services. Likewise, many programming languages (for example,
  Pascal and C) only provide a dressed-up version of the DOS services and
  nothing more. So, if you need to use the PC's fancy screen capabilities
  and if you aren't using a language such as BASIC that provides the
  services you need, you should be using the ROM BIOS services. Getting
  control of the display screen is one of the very best reasons for using
  the ROM BIOS services.

  Using the ROM BIOS services directly usually calls for an
  assembly-language interface, so we'll give you an example of how one can
  be set up. For the example, we'll set up a module in a format that would
  be called by C. We'll make the module switch to video mode 1 (40-column
  text in color) and set the border color to blue.

  Here is the assembly module (see Chapter 8, page 161, for general notes
  on the format):

  _TEXT           SEGMENT         byte public 'CODE'
                  ASSUME          cs:_TEXT

                  PUBLIC          _Blue40
  _Blue40         PROC            near

                  push            bp       ; save previous BP value
                  mov             bp,sp    ; use BP to access the stack


  ; set video mode

                  mov            ah,0      ; BIOS service number
                  mov            al,1      ; video mode number
                  int            10h       ; call BIOS to set 40x25 text mode

  ; set border color

                  mov            ah,0Bh    ; BIOS service number
                  mov            bh,0      ; subservice number
                  mov            bl,1      ; color value (blue)
                  int            10h       ; call BIOS to set border color

                  pop            bp        ; restore previous BP value
                  ret

  _Blue40         ENDP

  _TEXT           ENDS

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