-- AlpineInline.mesa
-- Simple procedures used by several Alpine components.
-- Last edited by
--   MBrown on January 30, 1984 11:31:04 am PST

  DIRECTORY
    AlpineEnvironment,
    Basics,
    PrincOpsUtils;

AlpineInline: DEFINITIONS
  IMPORTS
    Basics,
    PrincOpsUtils
  = BEGIN
  PageNumber: TYPE = AlpineEnvironment.PageNumber;
  WordNumber: TYPE = INT;
  wordsPerPage: CARDINAL = AlpineEnvironment.wordsPerPage;
  logWordsPerPage: CARDINAL = AlpineEnvironment.logWordsPerPage;

  LongZero: PROC [where: LONG POINTER, nWords: CARDINAL] = INLINE {
    PrincOpsUtils.LongZero[where, nWords] };

  ShortWordsFromPages: PROC [pages: CARDINAL] RETURNS [words: CARDINAL] = INLINE {
    RETURN [Basics.BITSHIFT[value: pages, count: logWordsPerPage]] };

  WordsFromPages: PROC [pages: PageNumber] RETURNS [words: WordNumber] = INLINE {
    RETURN [pages * wordsPerPage] };

  PagesFromWords: PROC [words: WordNumber] RETURNS [pages: PageNumber] = INLINE {
    RETURN [words / wordsPerPage] };

  DecomposeWords: PROC [words: WordNumber]
    RETURNS [page: PageNumber, wordInPage: CARDINAL] = INLINE {
    RETURN [page: words/wordsPerPage, wordInPage: words MOD wordsPerPage] };

  END.