home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / misc / gms_dev.lha / GMS / Source / E / Screens / DoubleBuffer.e < prev    next >
Encoding:
Text File  |  1997-01-29  |  1.9 KB  |  60 lines

  1. /* Double Buffering
  2. ** ----------------
  3. ** This just shows how to double buffer the screen.  You can also try out
  4. ** triple buffering just by changing the DBLBUFFER flag to TPLBUFFER in the
  5. ** ScreenStruct.
  6. ** 
  7. ** Notice that this thing does in fact fully multi-task (no forbid/permit)!
  8. ** Instead we set our task priority to be a little higher than any other
  9. ** tasks -- if we didn't do this sometimes our frames could be stalled (try
  10. ** removing the SetUserPri and watch the demo again).
  11. */
  12.  
  13. MODULE 'games','games/games'
  14.  
  15. PROC main()
  16.    DEF screen:PTR TO gamescreen, loadpic:PTR TO picture
  17.  
  18.    loadpic := [
  19.     PCV1,0,            -> Version header.
  20.     0,                 -> Destination.
  21.     320,0,256,         -> Width, Height.
  22.     5,                 -> Amount of Planes.
  23.     32,                -> Amount of colours.
  24.     0,                 -> Palette.
  25.     LORES OR COL12BIT, -> Screen mode.
  26.     INTERLEAVED,       -> Destination.
  27.     0,                 -> Parameters.
  28.     'GAMESLIB:data/IFF.Pic320'
  29.    ]:picture;
  30.  
  31.    IF gmsbase := OpenLibrary('games.library',0)
  32.       SetUserPrefs(0)
  33.       IF (screen := AddScreen([TAGS,0,
  34.            GSA_PALETTE,[$000,$130,$FCB,$FA9,$D88,$965,$644,$211,$400,$444,
  35.                         $FF0,$432,$CC0,$150,$501,$880,$261,$271,$382,$492,
  36.                         $5A3,$5B4,$677,$6C4,$788,$9AA,$BCC,$801,$901,$A02,
  37.                         $701,$601]:INT,
  38.            GSA_SCRWIDTH,320,
  39.            GSA_SCRHEIGHT,256,
  40.            GSA_PLANES,5,
  41.            GSA_SCRATTRIB,DBLBUFFER,
  42.            GSA_SCRMODE,LORES OR COL12BIT,
  43.            GSA_SCRTYPE,INTERLEAVED,
  44.            TAGEND]))
  45.  
  46.          loadpic.data := screen.memptr1;
  47.          IF (LoadPic(loadpic) = ERR_OK)
  48.             ShowScreen(screen)
  49.             REPEAT
  50.               WaitSVBL()
  51.               SwapBuffers(screen)
  52.             UNTIL !(ReadMouse(JPORT1) AND MB_LMB)
  53.          ENDIF
  54.          DeleteScreen(screen)        
  55.       ENDIF
  56.    CloseLibrary(gmsbase)
  57.    ENDIF
  58. ENDPROC
  59.  
  60.