home *** CD-ROM | disk | FTP | other *** search
/ Graphics 16,000 / graphics-16000.iso / msdos / fractal / fdesi313 / fdes13s / fdesvirt.c < prev    next >
Text File  |  1989-12-07  |  2KB  |  88 lines

  1. /*
  2.         Virtual screen support
  3. */
  4. #include <alloc.h>
  5. #include <graphics.h>
  6. #include <dos.h>
  7. #include "fdesplot.h"
  8. #include "fdesmenu.h"
  9. #define VWIDTH 1504             /* virtual screen dimensions */
  10. #define VHEIGHT 1200            /* virtual screen dimensions */
  11.  
  12. long virt_target_size;
  13.  
  14. int vstop,vsbottom,vsleft,vsright;      /* part of virtual screen in display */
  15.  
  16. void vscreen_view(int top, int bottom, int left, int right)
  17. {
  18.         vstop = top;
  19.         vsbottom = bottom;
  20.         vsleft = left;
  21.         vsright = right;
  22. }
  23. void vscreen_right(int right)
  24. {
  25.         vsleft += right;
  26.         vsright += right;
  27. }
  28. void vscreen_down(int down)
  29. {
  30.         vstop += down;
  31.         vsbottom += down;
  32. }
  33.  
  34. char huge *vscreen;
  35. void vscreen_close(void)
  36. {
  37.         farfree((void far *)vscreen);
  38. }
  39. int vscreen_open(void)
  40. {
  41.         vscreen = (char huge *)farmalloc((long)VWIDTH*VHEIGHT/8);
  42.         if (vscreen == NULL)
  43.         {
  44.                 putmsg(100,100,"Not Enough Memory Available",RED,WHITE);
  45.                 delay(2000);
  46.                 clrmsg();
  47.                 return(0);
  48.         }
  49.         vscreen_view(0,maxy,0,maxx);
  50.         return(1);
  51. }
  52. void vputpixel(int x, int y)    /* sets pixel in virtual screen */
  53. {
  54. long byteno;
  55. int bitmap;
  56. /* debug */
  57. /*        if ((x < vsright) && (x > vsleft) && (y < vsbottom)
  58.             && (y > vstop))
  59.         {
  60.                 putpixel(x-vsleft,y-vstop,15);
  61.         }
  62. */
  63.         if ((x >= VWIDTH) || (y >= VHEIGHT)) return;
  64.         if ((x < 0) || (y < 0)) return;
  65.         byteno = (x/8) + (long)y*(VWIDTH/8);
  66. /*        if (byteno >= ((long)VWIDTH*VHEIGHT/8)) return; */
  67.     bitmap = *(vscreen+byteno);
  68.         bitmap |= (1 << (x&7));
  69.         *(vscreen+byteno) = bitmap;
  70. }
  71. int vgetpixel(int x, int y)     /* returns nonzero if pixel lit */
  72. {
  73. long byteno;
  74. int bitmap;
  75.         if ((x >= VWIDTH) || (y >= VHEIGHT)) return(0);
  76.         byteno = (x/8) + (long)y*(VWIDTH/8);
  77. /*        if (byteno >= ((long)VWIDTH*VHEIGHT/8)) return(0); */
  78.     bitmap = *(vscreen+byteno);
  79.     return (bitmap & (1 << (x&7)));
  80. }
  81. void vscreen_clear(void)
  82. {
  83. long i;
  84.         for (i=0; i<((long)VWIDTH*VHEIGHT/8); i++) *(vscreen+i) = 0;
  85.  
  86. }
  87.  
  88.