home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 24 / CD_ASCQ_24_0995.iso / vrac / homonlib.zip / VPAGE.BAS < prev    next >
BASIC Source File  |  1995-04-13  |  2KB  |  58 lines

  1. DEFINT A-Z
  2.  
  3. DECLARE FUNCTION VPage (p)
  4.  
  5. FUNCTION VPage (p) STATIC
  6. '****************************************************************************
  7. 'This function is used to allocate and release pages of video memory.
  8. '
  9. 'To request (allocate) a page, pass zero as the argument.  The function will
  10. ' return the page number that has been allocated, or zero if none are left.
  11. '
  12. 'To release a video page when your procedure is finished with it, pass the
  13. ' page number as the argument to the function.  The function will note the
  14. ' page as being available, and will return zero.
  15. '
  16. 'The reason behind the function is so that procedures that need to use or
  17. ' swap video pages can do so without fear of using a page that may already
  18. ' be in use by another procedure.
  19. '
  20. 'The function doesn't actually do anything at all with video pages.  It
  21. ' merely keeps track of a small array that remembers which pages are in use.
  22. '
  23. 'NOTE: This function assumes VGA video with 8 pages (0-7) of video memory for
  24. ' screen mode 0.  It also assumes that page 0 is always in use, and does not
  25. ' bother to keep track of it.
  26. '
  27. 'See function ColorSet() or any of the pop-up box functions for examples of
  28. ' use.
  29. '
  30. '****************************************************************************
  31.  
  32. STATIC page()                           'To keep track of which are in use.
  33.  
  34. STATIC newdim                           'This is so the array only gets
  35. IF newdim = 0 THEN                      'dimensioned once.
  36.      DIM page(1 TO 7)
  37.      newdim = 1
  38. END IF
  39.  
  40. free = 0                                'For clarity's sake.
  41. used = 1
  42.  
  43. SELECT CASE p
  44.      CASE 0                             'Allocate a page
  45.           FOR x = 1 TO 7
  46.                IF page(x) = free THEN        'Returns the number of the page
  47.                     page(x) = used           'that was allocated, or zero if
  48.                     VPage = x                'none were left.
  49.                     EXIT FOR
  50.                END IF
  51.           NEXT x
  52.      CASE ELSE                          'Release the specified page
  53.           page(p) = free
  54. END SELECT
  55.  
  56. END FUNCTION
  57.  
  58.