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

  1. /*
  2.  *  FILE: dualpf.c
  3.  *  Support routines for converting a single-playfield Intuition screen
  4.  *  into a dual-playfield 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. #include "gimmelib/gimmefuncs.h"
  12.  
  13.  
  14. short makeDualPlayfield( screen, ri, reldepth )
  15.     struct Screen   *screen;
  16.     struct RasInfo  *ri;
  17.     SHORT        reldepth;
  18. {
  19.     SHORT   depth;
  20.  
  21. #ifdef GIMME_WIMPY
  22.     if( !screen ) {
  23.     return( -1 );
  24.     }
  25. #endif
  26.     if( (screen->ViewPort.Modes & DUALPF)
  27.     || reldepth < -1 || reldepth > 0 || screen->BitMap.Depth > 3 ) {
  28.     return( -1 );
  29.     }
  30.     depth = screen->BitMap.Depth + reldepth;
  31.     if( depth > 3 ) {
  32.     return( -1 );
  33.     }
  34.     ri->BitMap = gimmeBitMap( depth, screen->Width, screen->Height );
  35.     if( !ri->BitMap ) {
  36.     return( -1 );
  37.     }
  38.     ri->Next = NULL;
  39.     ri->RxOffset = 0;
  40.     ri->RyOffset = 0;
  41.     Forbid();
  42.     screen->ViewPort.RasInfo->Next = ri;
  43.     screen->ViewPort.Modes |= DUALPF;
  44.     Permit();
  45.     MakeScreen( screen );
  46.     RethinkDisplay();
  47.     return( 0 );
  48. } /* makeDualPlayfield */
  49.  
  50.  
  51. short unmakeDualPlayfield( screen )
  52.     struct Screen   *screen;
  53. {
  54.     struct RasInfo  *ri;
  55.     struct BitMap   *bm;
  56.  
  57. #ifdef GIMME_WIMPY
  58.     if( !screen ) {
  59.     return( -1 );
  60.     }
  61. #endif
  62.     if( !(screen->ViewPort.Modes & DUALPF) ) {
  63.     return( -1 );
  64.     }
  65.     Forbid();
  66.     ri = screen->ViewPort.RasInfo->Next;
  67.     bm = ri->BitMap;
  68.     ri->BitMap = NULL;
  69.     screen->ViewPort.RasInfo->Next = NULL;
  70.     screen->ViewPort.Modes &= ~(DUALPF | PFBA);
  71.     Permit();
  72.     MakeScreen( screen );
  73.     RethinkDisplay();
  74.     if( bm ) {
  75.     getRidOfBitMap( bm );
  76.     }
  77.     return( 0 );
  78. } /* unmakeDualPlayfield */
  79.