home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 17 / CD_ASCQ_17_101194.iso / dos / prg / sphinx / examples / vga / ppixel.c__ < prev    next >
Encoding:
Text File  |  1993-11-28  |  1.7 KB  |  59 lines

  1. /*
  2.     SPHINX C-- example program of loop speed
  3.  
  4.     SPHINX C-- is a tiny memory model high speed C-- compiler
  5.     by SPHINX programming.
  6.  
  7.     C-- a half way point between C and ASSEMBLY.  It has some
  8.     features which may be desirable with small high speed
  9.     applications.  This program generates a .COM file of the
  10.     size of 284 bytes, not bad?
  11.  
  12.     SPHINX programming:
  13.  
  14.     PETER CELLIK
  15.     RR#2 Site 33 C11
  16.     Gabriola Is.  B.C.
  17.     V0R 1X0
  18.     CANADA
  19. */
  20.  
  21.  
  22. ?include "VIDEO.H--"
  23. ?include "WRITE.H--"
  24. ?include "RANDOM.H--"
  25. ?include "DOS.H--"
  26. ?include "KEYCODES.H--"
  27.  
  28. byte color=0;  
  29.  
  30. main ()               /* execution starts here like in C */
  31. {
  32. @ SETVIDEOMODE(vid_320x200_256);  /* set videomode to 320x200 256 colours */
  33. IF(byte @GETVIDEOMODE() <> vid_320x200_256)
  34.     {WRITESTR("Unable to enter 320x200-256 video mode.\n");
  35.     EXIT(-1);
  36.     }
  37.  
  38. @ RANDOMIZE();  /* seed the random number generator with the clock ticks */
  39. do {
  40.     ES = VGA_SEG;       /* set the ES register to VGA segment */
  41.  
  42.     SI = 0;        
  43.     loop(SI)  /* loop 65536 times since count is 0, use SI as loop counter */
  44.         {AX = @RAND();      /* generate random number */
  45.         IF( AX < 64000 )    /* if random number is valid screen address */
  46.             {DI = AX;
  47.             ESBYTE[DI] = color;  /* use ES segment to write byte to screen */
  48.             }
  49.         }
  50.  
  51.     color++;            /* increment colour */
  52.     } while( @KBHIT() == 0 );     /* loop while no key has been hit */
  53.  
  54. @ BIOSREADKEY();             /* read the key pressed with BIOS */
  55. @ SETVIDEOMODE(vid_text80c);    /* set videomode with macro */
  56. WRITESTR("SPHINX Programming 1993");  /* display end message */
  57. }
  58.  
  59. /* end of PPIXEL.C-- */