home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 10: Diskmags / nf_archive_10.iso / MAGS / STFORMAT / STF11.MSA / SIDE_B_C_TUTOR_FLIP.C < prev    next >
C/C++ Source or Header  |  1990-04-15  |  1KB  |  53 lines

  1. /* ----------------- ST FORMAT PINBALL PROGRAM ------- ------------------------
  2.  
  3.     Title:        PINBALL
  4.  
  5.     Module:        flip.c
  6.  
  7.     Version:    1.1
  8.  
  9.     Author:        Warwick Grigg
  10.  
  11.     Copyright (c) Warwick Grigg 1990. All rights reserved.
  12.  
  13. ----------------------------------------------------------------------------- */
  14. #include <osbind.h>
  15. #include <gemfast.h>
  16. #include <stdio.h>
  17. #include "flipc.h"
  18.  
  19. /*    SCREEN CONSTANTS    */
  20.  
  21. #define SCREENALLOC    (32256)
  22.  
  23. static struct flipdef_s loc, phys;
  24. static char myscreen[SCREENALLOC];    /* Alternate screen for flipping */
  25.  
  26. struct flipdef_s *Flip(curlog)    /* Animate by switching over screen buffers    */
  27. struct flipdef_s *curlog;
  28. {
  29.     Setscreen(curlog->nextflip->mempos, curlog->mempos, -1);
  30.     Vsync();            /* wait til done on next vertical blank    */
  31.     return curlog->nextflip;    /* cycle onto next screen buffer    */
  32. }
  33.  
  34. struct flipdef_s *PrepScreens()    /* Get screen buffers */ 
  35. {
  36.     loc.nextflip = &phys;
  37.     phys.nextflip = &loc;    /* now buffers are in a cyclic structure      */
  38.     phys.mempos = (char *)Physbase();
  39.     {
  40.     register long temp = (long)myscreen;
  41.     
  42.     temp = (temp+255) & 0xffffff00;
  43.     loc.mempos = (char *)temp;    /* now buffer is at 256 byte boundary */
  44.     }
  45.     return &loc;    /* return pointer to control block for new screen */
  46. }
  47.  
  48. void DeFlip()
  49. {
  50.     Setscreen(phys.mempos, phys.mempos, -1);
  51.     Vsync();
  52. }
  53.