home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 199.lha / GimmeLib / dbuf.c < prev    next >
C/C++ Source or Header  |  1988-12-27  |  2KB  |  95 lines

  1. /*
  2.  *  FILE: dbuf.c
  3.  *  Support routines for converting a single-buffered Intuition screen
  4.  *  into a double-buffered screen and back.
  5.  *
  6.  *  Public Domain, but keep my name in it as the original author.
  7.  *  31-Aug-88    Jan Sven Trabandt   first release version
  8.  */
  9.  
  10.  
  11. #define I_AM_DBUF
  12. #include "gimmelib/gimmefuncs.h"
  13. #include "gimmelib/minterm.h"
  14.  
  15.  
  16. short makeDBuf( screen, bmptr )
  17.     struct Screen   *screen;
  18.     struct BitMap   **bmptr;
  19. {
  20. #ifdef GIMME_WIMPY
  21.     if( !screen || !bmptr ) {
  22.     return( -1 );
  23.     }
  24. #endif
  25.     if( !*bmptr ) {
  26.     *bmptr = gimmeBitMap( screen->BitMap.Depth, screen->Width,
  27.                 screen->Height );
  28.     if( !*bmptr ) {
  29.         return( -1 );
  30.     }
  31.     }
  32.     screen->RastPort.BitMap = *bmptr;        /* draw to back buffer */
  33.     return( 0 );
  34. } /* makeDBuf */
  35.  
  36.  
  37. short unmakeDBuf( screen, bmptr, bm )
  38.     struct Screen   *screen;
  39.     struct BitMap   **bmptr;
  40.     struct BitMap   *bm;
  41. {
  42.     struct BitMap   *viewbm;
  43.  
  44. #ifdef GIMME_WIMPY
  45.     if( !screen || !bmptr ) {
  46.     return( -1 );
  47.     }
  48. #endif
  49.     viewbm = screen->ViewPort.RasInfo->BitMap;
  50.     if( !(screen->Flags & CUSTOMBITMAP) && viewbm == *bmptr ) {
  51.     BltBitMap( viewbm, 0L, 0L, screen->RastPort.BitMap, 0L, 0L,
  52.             (ULONG)(bm->BytesPerRow) << 3, (ULONG) bm->Rows,
  53.             (ULONG) GIM_MINTERM_COPY, 0x0ffL, NULL );
  54.     swapDBuf( screen, GIM_MINTERM_DEST );
  55.     }
  56.     if( viewbm != screen->RastPort.BitMap ) {
  57.     screen->RastPort.BitMap = viewbm;
  58.     }
  59.     if( bm ) {
  60.     getRidOfBitMap( bm );
  61.     }
  62.     return( 0 );
  63. } /* unmakeDBuf */
  64.  
  65.  
  66. short swapDBuf( screen, minterm )
  67.     register struct Screen  *screen;
  68.     SHORT   minterm;
  69. {
  70.     struct BitMap   *bm;
  71.  
  72. #ifdef GIMME_WIMPY
  73.     if( !screen ) {
  74.     return( -1 );
  75.     }
  76. #endif
  77.     Forbid();
  78.     bm = screen->ViewPort.RasInfo->BitMap;
  79.     if( bm == screen->RastPort.BitMap ) {
  80.     Permit();
  81.     return( 0 );
  82.     }
  83.     screen->ViewPort.RasInfo->BitMap = screen->RastPort.BitMap;
  84.     screen->RastPort.BitMap = bm;
  85.     Permit();
  86.     MakeScreen( screen );
  87.     RethinkDisplay();
  88.     if( minterm != GIM_MINTERM_DEST ) {
  89.     BltBitMap( screen->ViewPort.RasInfo->BitMap, 0L, 0L, bm, 0L, 0L,
  90.             (ULONG)(bm->BytesPerRow) << 3, (ULONG) bm->Rows,
  91.             (ULONG) minterm, 0x0ffL, NULL );
  92.     }
  93.     return( 0 );
  94. } /* swapDBuf */
  95.