ETHZ_Logo RAMSES_Logo_Right   RAMSES   RAMSES_Logo_Left Systems Ecology  
Start    search button      Modules:   A-Z   Function   Layer        QuickRefs:   DM   AuxLib   AuxLibE   SciLib   EasyMW   MW   ISIS   RMSLib

DEFINITION MODULE  DMSystem;

  (*******************************************************************

    Module  DMSystem     ('Dialog Machine' DM_V3.0)

      Copyright (c) 1986-2006 by Andreas Fischlin, Alex Itten and
      ETH Zurich.

    Purpose   Provides information about system specific
              objects used by the 'Dialog Machine'.

    Remarks   This module belongs to the 'Dialog Machine'.


    Programming

      o Design
        Andreas Fischlin          23/04/1986

      o Implementation
        Andreas Fischlin          23/04/1986
        Alex Itten                05/02/1988


    ETH Zurich
    Systems Ecology
    CHN E 35.1
    Universitaetstrasse 16
    8092 Zurich
    SWITZERLAND

    URLs:
        <mailto:RAMSES@env.ethz.ch>
        <http://www.sysecol.ethz.ch>
        <http://www.sysecol.ethz.ch/SimSoftware/RAMSES>


    Last revision of definition:  25/02/2005  AF

  *******************************************************************)


  (***************************************)
  (*#####   Dialog Machine System   #####*)
  (***************************************)

  (* All the routines dealing with subprogram levels are only of use
  if the Dialog Machine has been implemented using a dynamic linking
  loader.  This is the case for the Macintosh implementation of the
  DM, but may not be the case for implementations on other
  platforms.  However, calling these routines will be of no harm if
  there is no dynamic linking loader present and the routines will
  behave as if all subprograms are always just executed on the
  startUpLevel.  However note, when the running program terminates,
  all installed termination routines (see procedure InstallTermProc)
  will be executed once, right before final program termination.  *)

  CONST
    startUpLevel = 1; (* program level on which "Dialog Machine"
                         is loaded *)
    maxLevel     = 5; (* maximum level to which subprograms may
                         be called *)

  PROCEDURE CurrentDMLevel(): CARDINAL;
  (* returns current subprogram level *)

  PROCEDURE TopDMLevel(): CARDINAL;
  (* current topmost subprogram level *)

  PROCEDURE LevelisDMLevel(l: CARDINAL): BOOLEAN;
  (*
    level is actually a DM level, i.e. RunDialogMachine has been
    called on level l
  *)

  PROCEDURE LevelIsTerminating(): BOOLEAN;
  (*
    Installed terminate procedures (see InstallTermProc) are
    executing on current subprogram level, i.e. returns wether
    procedure ExecuteTermProcs is currently executing
  *)

  PROCEDURE DoOnSubProgLevel(l: CARDINAL; p: PROC);
  (*
    force execution of p on level l regardless of current DM level
  *)

  PROCEDURE ForceDMLevel(extraLevel: CARDINAL);
  PROCEDURE ResumeDMLevel(normalLevel: CARDINAL);
  (*
    Allows the forcing of the current DM level to another than
    the normal level.  Note that these procedures should be used
    only as a last resort; try to use DoOnSubProgLevel instead.
    If these procedures are used, it is recommended to program
    such an «excursion» in the following reentrant way, which
    supports also nested calls:

        PROCEDURE MyExcursionOnStrangeDMLevel (strangeLevel: CARDINAL);
          VAR normalDMLevel: CARDINAL;
        BEGIN
          normalDMLevel := CurrentDMLevel();
          ForceDMLevel (strangeLevel);
          TheActualExcursion; (* on the strange level *)
          ResumeDMLevel (normalDMLevel);
        END MyExcursionOnStrangeDMLevel;

    Note that procedure DoOnSubProgLevel is actually implemented
    in a similar way. Moreover note, that the actual
    implementation in the Dialog Machine supports also the
    abortion in the middle of an excursion.  However, note that
    an abortion means an immediate quitting of the normal level
    without finishing the remainder of the excursion, nor the
    rest of the body of procedure MyExcursionOnStrangeDMLevel or
    any other, remaining part of the program on the normal
    level.  In case of an abortion the DM will automatically
    resume the original level, i.e. the TopDMLevel, on which the
    very first excursion was started, independent of any eventual
    nesting of excursions.

    Implementation restriction:  Note that it is not allowed to
    make any excursions in termination or initialization
    procedures.
  *)


  (*
    Installation of initialization and termination procedures
    called at the begin or the end (reverse order of installation)
    of a subprogram level. For each kind up to a maximum of 32 can
    be installed:
  *)
  PROCEDURE InstallInitProc(ip: PROC; VAR done: BOOLEAN);
  PROCEDURE InstallTermProc(tp: PROC; VAR done: BOOLEAN);
   (* force execution now of all currently installed procs: *)
  PROCEDURE ExecuteInitProcs;
  PROCEDURE ExecuteTermProcs;




  (****************************************)
  (*#####   Screen Size and Colors   #####*)
  (****************************************)

  PROCEDURE ScreenWidth()   : INTEGER; (* of main screen *)
  PROCEDURE ScreenHeight()  : INTEGER; (* of main screen including menu bar *)
  PROCEDURE MenuBarHeight() : INTEGER;

  (*
    on machines with multiple screens first screen has # 1
    (normally main) and # of last screen is returned by
    HowManyScreens.  The screens have all a global coordinate
    system (type INTEGER) where the origin [0,0] is in the lower
    left bottom of the main screen.
  *)

  PROCEDURE MainScreen(): INTEGER;  (* is screen which contains menu bar *)
  PROCEDURE HowManyScreens(): INTEGER;
  PROCEDURE SuperScreen(VAR whichScreen, x,y,w,h, pixelDepth: INTEGER;
                        colorPriority: BOOLEAN);
  (*
    Finds the screen which has the highest number of colors
    (colorPriority = TRUE) or has the largest size (colorPriority =
    FALSE).  In case there are several screens with the same number
    of colors (colorPriority = TRUE) it will return the one among
    them with the largest size.  In case there should be several
    identical screens it will return the one with the lowest
    ordinal number. The returned whichScreen is a number between
    1 and HowManyScreens() and may or may not be identical to
    MainScreen().

    IMPLEMENTATION RESTRICTION: Due to restrictions in the
    Macintosh system software, this routine does actually test only
    for the presence of screen interfaces, not the physical
    presence of screens, which of course would be of greater
    relevance from the viewpoint of the user.  These restrictions
    have the following consequences: SuperScreen may return a
    screen which is actually not present or currently not turned
    on, which may cause a 'Dialog Machine' program to place a
    window on a screen, on which the user may see nothing at all.
    In particular, note that a screen, which is currently turned
    off or disconnected is treated identically as if it would be
    fully functional, as long as a corresponding interface card is
    currently present in the machine. Therefore, 'Dialog Machine'
    programs using SuperScreen to place windows on the best
    suitable screen, behave only optimally, if you alwyas connect a
    screen to every present interface card and if you turn on all
    hooked up screens.  A quick remedy to force an absent screen to
    stop being the super screen may be to reduce its colors and/or
    resolution such that they become inferior to the properties of
    a screen on which the user can actually see something.
    SuperScreen inspects at each call the current configuration and
    does not require a restart of the computer system.
  *)

  PROCEDURE GetScreenSize(screen: INTEGER; VAR x,y,w,h: INTEGER);
  (*
    Note that the value h returned by this routine when calling
    GetScreenSize(MainScreen(),...h) is already corrected for
    the menu bar.  The parameter screen must be a number
    between 1 and HowManyScreens() or all values returned will
    be 0.
  *)

  PROCEDURE TitleBarHeight(): INTEGER;
  PROCEDURE ScrollBarWidth(): INTEGER;
  PROCEDURE GrowIconSize(): INTEGER;   (* icon at the lower right corner of a window *)

  PROCEDURE MaxPixelDepth(): INTEGER;
  (*
    Returns the maximum depth of a pixel, i.e. the number of
    bits per pixel, currently available on the computer system
    the 'Dialog Machine' is running on.  This limit is
    typically determined by software as well as the graphic
    hardware of the current computer system.  MaxPixelDepth()
    determines the maximum of simultaneously usable colors =
    2^MaxPixelDepth().  NOTE: The returned value is independent
    of the colors actually visible on any currently connected
    screen, since it represents what is actually supported by
    drawing routines (see module DMWindIO).  For instance,
    while using a black and white screen only, the routine may
    still return a value greater than 1.  In such a case the
    'Dialog Machine' program may still be capable to produce
    (cf.  module DMPrinting) colors on a color printer (e.g.
    ImageWriter II with a color ribbon or a color laser
    printer).  To learn about colors actually available, i.e.
    now visible on a particular screen, use procedure
    PixelDepthOnScreen.
  *)

  PROCEDURE PixelDepthOnScreen(screen: INTEGER): INTEGER;
  (*
    Returns the depth of a pixel, i.e. the number of bits per
    pixel, currently used on a given screen.  Note, the
    returned value can change via preference settings (control
    panel, systems preferences) under the control of the user.
    This value is also limited by the specific characteristics
    of the particular screen and the graphic hardware driving
    that screen and will never exceed the value returned by
    routine MaxPixelDepth().  The number of colors which may be
    displayed simultaneously can be derived from the returned
    value: 2^PixelDepthOnScreen().  The parameter screen must
    be a number between 1 and HowManyScreens() or 0 will be
    returned.
  *)





  (****************************************)
  (*#####   Dialog Machine Version   #####*)
  (****************************************)

  PROCEDURE GetDMVersion(VAR vers,lastModifDate: ARRAY OF CHAR);
  (*
    Returns current version of the Dialog Machine, e.g. 2.03a, and
    the date of the last modification, e.g. 05/Aug/1991.  In case
    the "Dialog Machine" is implemented as a so-called "Batch Dialog
    Machine" (BatchDM) then the string returns this fact as well,
    e.g. "BatchDM 2.2".
  *)



  (***********************************************)
  (*#####   High Level Platform Inquiries   #####*)
  (***********************************************)

  (*
    Simple high level routines returning information about the
    computer system on which the 'Dialog Machine' is curently
    running.  The use of these routines is recommended in favor
    of the more technical, riskier, and less portable routines
    given towards the end of this module.  Platform dependent
    code should use the robust routines RunsOnAMac,
    RunsOnAnIBMPC, and RunsOnAUnixMachine.  Use GetComputerName
    only to document the current machine, not to derive any
    conditions about the actual platform.

    IMPLEMENTATION RESTRICTION: Please note, since the hardware
    development changes faster than any "Dialog Machine"
    implementation can keep up with, the information these
    routines return, may not always be the most precise.
    Moreover, Apple and other computer vendors change the
    technique by which such information can be retrieved all the
    time.
  *)

  PROCEDURE GetComputerName(VAR name: ARRAY OF CHAR);
  (*
    Returns the brand and/or model name of the computer on which
    the Dialog Machine is currently running.  For some computers
    the 'Dialog Machine' can also return a unique integer value
    (see also procedure ComputerSystem).
  *)

  PROCEDURE RunsOnAMac(): BOOLEAN;
  (*
    Returns TRUE if the 'Dialog Machine' runs on a Machintosh
  *)
    PROCEDURE RunsInMacOSClassic(): BOOLEAN;
    (*
      Returns TRUE if the 'Dialog Machine' runs in MacOS Classic.  Note,
      if the 'Dialog Machine' program runs as a Classic application,
      this routine returns always TRUE, regardless whether the Macintosh
      has been booted natively into Classic or the application is running
      within the Classic environment of OS X.
    *)
    PROCEDURE RunsInMacOSX(): BOOLEAN;
    (*
      Returns TRUE only if the 'Dialog Machine' runs as a native
      Mac OS X application under OS X.
    *)
  PROCEDURE RunsOnAnIBMPC(): BOOLEAN;
  (*
    Returns TRUE if the 'Dialog Machine' runs on an IBM PC
  *)
  PROCEDURE RunsOnAUnixMachine(): BOOLEAN;
  (*
    Typically RunsOnAUnixMachine is only TRUE for Sun oder IBM
    RISC platforms.  On a Macintosh using OS X, the routine
    RunsOnAMac returns TRUE and RunsOnAUnixMachine returns FALSE.
  *)



  (*
    Most of following routines return a string describing the
    hardware.  For routines which return a unique integer value
    instead see below.
  *)

  PROCEDURE GetCPUName(VAR name: ARRAY OF CHAR);

  PROCEDURE GetFPUName(VAR name: ARRAY OF CHAR);
  PROCEDURE FPUPresent(): BOOLEAN;

  PROCEDURE GetROMName(VAR name: ARRAY OF CHAR);





  (******************************************************)
  (*#####   Specific Platform Dependent Routines   #####*)
  (******************************************************)

  (*------------------------------*)
  (*=====   Computer Model   =====*)
  (*------------------------------*)

  (* The following routines offer advanced programmers means to
  inquire into the present hardware in a way which may be more
  convenient than the high level routines offered earlier *)

  CONST
    unknown     =   0; (* value usable for ComputerSystem, Central Processing
                          Unit (CPUType), Floating Point Unit (FPU), or keyboard *)

    (* Note: The Dialog Machine does not run on the older Mac models, (Lisa XL,
    Classic with only 128K or the Fat Mac with 512K RAM), since the DM functions properly
    only if the newer ROMs with size of at least 128 KB are present. *)
    Mac512KE            =   3; (* 68000 ( 8 MHz),   no FPU,                128 KB ROM *)
    MacPlus             =   4; (* 68000 ( 8 MHz),   no FPU,                128 KB ROM *)
    MacSE               =   5; (* 68000 ( 8 MHz),   no FPU,                256 KB ROM *)
    MacII               =   6; (* 68020 (16 MHz),   68881 (16 MHz),        256 KB ROM *)
    MacIIx              =   7; (* 68030 (16 MHz),   68882 (16 MHz),        256 KB ROM *)
    MacIIcx             =   8; (* 68030 (16 MHz),   68882 (16 MHz),        256 KB ROM *)
    MacSE30             =   9; (* 68030 (16 MHz),   68882 (16 MHz),        256 KB ROM *)
    MacPortable         =  10; (* 68000 (16 MHz),   no FPU,                256 KB ROM *)
    MacIIci             =  11; (* 68030 (25 MHz),   68882 (25 MHz),        512 KB ROM *)
    MacIIfx             =  12; (* 68030 (40 MHz),   68882 (40 MHz),        512 KB ROM *)
    MacClassic          =  17; (* 68000 ( 8 MHz),   no FPU,                256 KB ROM *)
    MacIIsi             =  18; (* 68030 (20 MHz),   68882 opt.(20 MHz),    512 KB ROM *)
    MacLC               =  19; (* 68020 (16 MHz),   68882 opt.(16 MHz),    512 KB ROM *)
    MacLCII             =  19; (* 68030 (16 MHz),   68882 opt.(16 MHz),    512 KB ROM *)
    MacQuadra900        =  20; (* 68040 (25 MHz),   FPU & MMU integrated, 1024 KB ROM *)
    MacPowerBook170     =  20; (* 68030 (25 MHz),   68882 (25 MHz),       1024 KB ROM *)
    MacQuadra700        =  22; (* 68040 (25 MHz),   FPU & MMU integrated, 1024 KB ROM *)
    MacClassicII        =  23; (* 68030 (16 MHz),   68882 opt.(16 MHz),    512 KB ROM *)
    MacPowerBook100     =  24; (* 68HC000 (16 MHz), no FPU,                256 KB ROM *)
    MacPowerBook140     =  25; (* 68030 (16 MHz),   no FPU,               1024 KB ROM *)
    MacQuadra950        =  26; (* 68040 (33 MHz),   FPU & MMU integrated, 1024 KB ROM *)
    (* PowerBook 145 *)        (* 68030 (25 MHz),   No FPU,               ? KB ROM *)
    (* PowerBook 160 *)        (* 68030 (25 MHz),   No FPU,               ? KB ROM *)
    (* PowerBook 180 *)        (* 68030 (33 MHz),   68882,                ? KB ROM *)
    (* Duo 210 *)              (* 68030 (25 MHz),   No FPU,               ? KB ROM *)
    (* Duo 230 *)              (* 68030 (33 MHz),   No FPU,               ? KB ROM *)
    (* MacIIvi *)              (* 68030 (16 MHz),   68882 opt.(16 MHz),   ? KB ROM *)
    (* MacIIvx *)              (* 68030 (32 MHz),   68882,                ? KB ROM *)

    (* ==============================================================

      IMPORTANT COMMENT:

      Since machines are manufactered faster than we can update
      the 'Dialog Machine', we have decided to abandon above
      scheme to export well defined constants for all the computer
      systems.  To identify a particular system you can still use
      the procedure function ComputerSystem.  However, the
      constant it returns is no longer exported.

      HINT: If you only want to learn about the computer platform on
      which you are running the 'Dialog Machine', use the new
      routines RunsOnAMac, RunsOnAnIBMPC, RunsOnAUnixMachine.  They
      are the only safe method to reliably know on which computer
      platform your 'Dialog Machine' program is executing.

      To learn about a particular model or hardware on any platform,
      use routine GetComputerName, GetCPUName, and FPUPresent.
      However, note, the information returned may not always be
      complete (not even for these high-level routines).  On the
      Macintosh platform, the Gestalt manager is used to retrieve
      the needed information, hence all values returned by all
      routines is accurate.

    ============================================================== *)

    SUN         = 101;
    SUN3        = 102;
    SUNSparc    = 103;

    IBMPC       = 201;
    IBMAT       = 202;
    IBMPS2      = 203;

    IBMRisc6000 = 300;

  PROCEDURE ComputerSystem(): INTEGER;
  (*
    For meaning of returned values see above constants.  If you
    can't find the value listed, consult for a Macintosh
    implementation of the 'Dialog Machine' e.g. "Inside
    Macintosh Volume VI", Addison Wesley, 1991, the Gestalt
    Manager or a Windows Programmers Documentation by
    Microsoft. See also above, IMPORTANT COMMENT.
  *)



  (*---------------------------------------*)
  (*=====   Central Processing Unit   =====*)
  (*---------------------------------------*)

  CONST
    CPU68000    =   1;
    CPU68010    =   2;
    CPU68020    =   3;
    CPU68030    =   4;  (* PMMU integrated *)
    CPU68040    =   5;  (* FPU and MMU integrated *)
    CPU68050    =   6;

    CPU8088      = 201;
    CPU8086      = 202;
    CPU80186     = 203;
    CPU80286     = 204;
    CPU80386     = 205;
    CPU80486     = 206;

  PROCEDURE CPUType(): INTEGER;
    (* See also above, IMPORTANT COMMENT. *)



  (*-----------------------------------*)
  (*=====   Floating Point Unit   =====*)
  (*-----------------------------------*)

  (* It is recommended to refrain from the use of the following
  procedures, since a DM program using these routines may not
  get meaningful values while calling these routines on other
  machines than a Macintosh: *)

  CONST
    FPU68881    =   1;
    FPU68882    =   2;
    FPU68040    =   3;

  PROCEDURE FPUType(): INTEGER;
    (* See also above, IMPORTANT COMMENT. *)



  (*------------------------*)
  (*=====   Keyboard   =====*)
  (*------------------------*)

  (* It is recommended to refrain from the use of the following
  procedures, since a DM program using these routines may not
  get meaningful values while calling these routines on other
  machines than a Macintosh: *)

  CONST
    MacKeyboard         = 1; (* 128K or 512K (Fat) Mac keyboard *)
    MacKbdAndPad        = 2; (* 128K or 512K (Fat) Mac keyboard plus numeric keypad *)
    MacPlusKbd          = 3; (* Mac Plus keyboard *)
    AExtendKbd          = 4; (* Apple Extended keyboard *)
    ADBKeyboard         = 5; (* standard Apple Dektop Bus (ADB) keyboard *)
    PortableKbd         = 6; (* Standard Portable Keyboard *)
    PortableISOKbd      = 7; (* Standard Portable Keyboard (ISO) *)
    EastwoodISOKbd      = 8; (* Apple Standard Keyboard (ISO) (Eastwood) *)
    SaratogaISOKbd      = 9; (* Apple Extended Keyboard (ISO) (Saratoga) *)
    ADBKbdII            =10; (* Apple Keyboard II (Mac Classic & Mac LC) *)
    ADBISOKbdII         =11; (* Apple Keyboard II, 81 Keys (ISO) Mac Classic & Mac LC) *)
    PwrBkADBKbd         =12; (* Powerbook Keyboard *)
    PwrBkISOKbd         =13; (* Powerbook Keyboard (ISO) *)

  PROCEDURE Keyboard(): INTEGER;
    (* See also above, IMPORTANT COMMENT. *)



  (*-------------------*)
  (*=====   ROM   =====*)
  (*-------------------*)

  (* It is recommended to refrain from the use of the following
  procedures, since a DM program using these routines is likely to
  get no meaningful values while calling these routines on other
  machines than a Macintosh *)

  CONST
    ROM64k        = 1;
    ROM128k       = 2;
    ROM256k       = 3;
    ROM512k       = 4;
    ROM1024k      = 5;

  PROCEDURE ROMType(): INTEGER;
    (* See also above, IMPORTANT COMMENT. *)



  (*-----------------------------------------*)
  (*=====   Operating-System Software   =====*)
  (*-----------------------------------------*)


  PROCEDURE SystemVersion(): REAL;
  (*
    Returns version of the currently running operating system :
    ( e.g. 6.07 ).  See also above, IMPORTANT COMMENT.
  *)


    (*-----------------------------------*)
    (*=====   Mac Version Numbers   =====*)
    (*-----------------------------------*)

  (* It is recommended to refrain from the use of the following
  procedures, since a DM program using these routines will not
  get meaningful values while calling these routines on other
  machines than a Macintosh *)

      PROCEDURE QuickDrawVersion(): REAL;
      (*
        Returns current version of QuickDraw: ( e.g. 2.02 )
        Numbers >= 1 mean there is Color QuickDraw available.
        See also above, IMPORTANT COMMENT.
      *)

      PROCEDURE ROMVersionNr(): INTEGER;
      (*
        Returns Apple's internal ROM version number (see also
        the Gestalt Manager Inside Macintosh Vol.  VI, p.
        3-42).  See also above, IMPORTANT COMMENT.
      *)


END DMSystem.

  Contact RAMSES@env.ethz.ch Last updated: 25-Jul-2011 [Top of page]