Advertisement
Guest User

REDTEST.C

a guest
Feb 1st, 2018
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.21 KB | None | 0 0
  1. #include <dos.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. unsigned short int far *Video = (unsigned short int far *)MK_FP(0xA000, 0x0000);
  5. unsigned short loopbreak = 0;
  6. unsigned incx = 0;
  7. unsigned incy = 0;
  8. unsigned short inccolor = 0;
  9.  
  10. void setpixel(unsigned x, unsigned y, unsigned short color){
  11.  
  12. /*set initial values for what segment to write to*/
  13.  
  14. unsigned int segment = 0xA000;
  15. unsigned int offset = 0x0000;
  16.  
  17. /* first ensure that the pixel is within bounds */
  18.  
  19. if(x > 319 || y > 199){
  20. return;
  21. }
  22.  
  23. /* now calculate segments and offset for x and y */
  24.  
  25. segment = segment + (20 * y);
  26. offset = x;
  27.  
  28. /* now set the pointer to the needed location and write the pixel*/
  29.  
  30. Video = (unsigned short int far *)MK_FP(segment, offset);
  31. *Video = color;
  32. }
  33.  
  34. void gameloop(){
  35. setpixel(incx,incy,12);
  36. incx++;
  37. if(incx == 319 && incy == 199){
  38. loopbreak = 1;
  39. return;
  40. }
  41. if(incx == 319){
  42. incy++;
  43. incx = 0;
  44. }
  45.  
  46. }
  47.  
  48. int main(void){
  49.     unsigned short incpal = 1;
  50.     /* do initializations*/
  51.     printf("\nThis test will slowly fill the screen with red");
  52.     printf("\nPress enter to continue...");
  53.     getchar();
  54.     _AH = 0x00;
  55.     _AL = 0x13;
  56.     geninterrupt(0x10);
  57.     while(loopbreak == 0){
  58.     gameloop();
  59.     delay(1);
  60.     }
  61.     getchar();
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement