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

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