home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l350 / 3.ddi / EXAMPLES / MSC / PVIDEO.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-31  |  1.3 KB  |  73 lines

  1. /* 
  2. PVIDEO.C -- protected mode program to poke video display memory 
  3.             1 million times using a real mode FAR pointer.
  4. */ 
  5.  
  6. #include <stdlib.h> 
  7. #include <stdio.h> 
  8. #include <dos.h>
  9. #include <pharlap.h>
  10.  
  11. #define MAX 1000000L
  12.  
  13. unsigned short GetVidSeg(void);
  14.  
  15. int main()
  16.     unsigned short VidSeg;
  17.     REALPTR pVid;
  18.     FARPTR fp;
  19.     long i; 
  20.  
  21. //
  22. // Get real mode paragraph addr of video memory, and use it to construct
  23. // a real mode FAR pointer to video memory.
  24. //
  25.     VidSeg = GetVidSeg();
  26.     if (VidSeg == 0)
  27.         return 1;
  28.     RP_SET(pVid, 0, VidSeg);
  29.  
  30.  //
  31.  // Poke video memory MAX times
  32.  //
  33.     for (i=MAX; i--; ) 
  34.         PokeRealWord(pVid + (i % 2000)*2, (USHORT) i);
  35.  
  36.     return 0; 
  37.  
  38. unsigned short GetVidSeg(void)
  39. {
  40.     char VidMode;
  41.     char ActivePage;
  42.  
  43. //
  44. // Get video mode
  45. //
  46.     _asm {
  47.         mov    ah,0Fh
  48.     int    10h
  49.     mov    VidMode,al
  50.     mov    ActivePage,bh
  51.     }
  52.  
  53. //
  54. // This simple program only supports video page 0, 80x25 text modes
  55. //
  56.     if (ActivePage != 0)
  57.     {
  58.         printf("Only video page 0 is supported\n");
  59.     return 0;
  60.     }
  61.     if (VidMode == 7)
  62.         return (unsigned short) 0xB000;    // monochrome
  63.     else if (VidMode == 2 || VidMode == 3)
  64.         return (unsigned short) 0xB800;
  65.     else
  66.     {
  67.         printf("Only 80x25 text modes are supported\n");
  68.     return 0;
  69.     }
  70. }
  71.