Advertisement
Guest User

TSTIMG.C

a guest
Feb 1st, 2018
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.41 KB | None | 0 0
  1. #include <dos.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. unsigned char far *Video = (unsigned char 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 char 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. FILE *fimg;
  36. unsigned char imgr[256];
  37. unsigned char incx = 0;
  38. unsigned char incy = 0;
  39. unsigned short inca = 0;
  40. fimg = fopen("C:/IMGOUT.VGA", "rb");
  41. fread(imgr, 1, 256, fimg);
  42. fclose(fimg);
  43. while(1 == 1){
  44. setpixel(incx, incy, imgr[inca]);
  45. inca++;
  46. if(inca >= 256){
  47. break;
  48. }
  49. if(incx == 15){
  50. incy++;
  51. incx = 0;
  52. }else incx++;
  53.  
  54. }
  55. loopbreak = 1;
  56. }
  57.  
  58. int main(void){
  59.     unsigned short incpal = 1;
  60.     /* do initializations*/
  61.     printf("\nThis test will place a bitmap in the screen corner.");
  62.     printf("\nPress enter to continue...");
  63.     getchar();
  64.     _AH = 0x00;
  65.     _AL = 0x13;
  66.     geninterrupt(0x10);
  67.     while(loopbreak == 0){
  68.     gameloop();
  69.     }
  70.     getchar();
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement