home *** CD-ROM | disk | FTP | other *** search
/ Graphics Programming Black Book (Special Edition) / BlackBook.bin / disk1 / source / chapter18 / video.c < prev   
Encoding:
C/C++ Source or Header  |  1997-06-18  |  727 b   |  38 lines

  1. /* VGA mode 13h functions for Game of Life.
  2.    Tested with Borland C++. */
  3. #include <stdio.h>
  4. #include <conio.h>
  5. #include <dos.h>
  6.  
  7. #define TEXT_X_OFFSET   28
  8. #define SCREEN_WIDTH_IN_BYTES 320
  9.  
  10. #define SCREEN_SEGMENT  0xA000
  11.  
  12.  
  13. /* Mode 13h mode-set function. */
  14. void enter_display_mode()
  15. {
  16.    union REGS regset;
  17.  
  18.    regset.x.ax = 0x0013;
  19.    int86(0x10, ®set, ®set);
  20. }
  21.  
  22. /* Text mode mode-set function. */
  23. void exit_display_mode()
  24. {
  25.    union REGS regset;
  26.  
  27.    regset.x.ax = 0x0003;
  28.    int86(0x10, ®set, ®set);
  29. }
  30.  
  31. /* Text display function. Offsets text to non-graphics area of
  32.    screen. */
  33. void show_text(int x, int y, char *text)
  34. {
  35.    gotoxy(TEXT_X_OFFSET + x, y);
  36.    puts(text);
  37. }
  38.