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

     $RCSfile: Cia.mod $
  Description: Interface to ciaa.resource and ciab.resource

   Created by: fjc (Frank Copeland)
    $Revision: 3.2 $
      $Author: fjc $
        $Date: 1994/08/08 00:50:01 $

  Includes Release 40.15

  (C) Copyright 1985-1993 Commodore-Amiga, Inc.
      All Rights Reserved

  Oberon-A interface Copyright © 1994, Frank Copeland.
  This file is part of the Oberon-A Interface.
  See Oberon-A.doc for conditions of use and distribution.

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

MODULE Cia;

(*
** $C- CaseChk       $I- IndexChk  $L+ LongAdr   $N- NilChk
** $P- PortableCode  $R- RangeChk  $S- StackChk  $T- TypeChk
** $V- OvflChk       $Z- ZeroVars
*)

IMPORT E := Exec;


(*
**      $VER: cia.h 36.4 (9.1.91)
**
**      Cia resource name strings.
*)

CONST

  ciaaName * = "ciaa.resource";
  ciabName * = "ciab.resource";

(*
**      $VER: ciabase.h 1.2 (16.5.90)
**
**      cia base definitions
*)


(*
 *      There is no public information in CiaBase
 *)


(**-- Resource Base variable --------------------------------------------*)

TYPE

  CiaBasePtr * = CPOINTER TO CiaBase;
  CiaBase * = RECORD END;

VAR

  ciaA *, ciaB * : CiaBasePtr;


(**-- Resource Functions ------------------------------------------------*)

(*
**      $VER: cia_protos.h 1.7 (19.7.90)
*)


LIBCALL (base : CiaBasePtr) AddICRVector*
  ( icrBit    [0] : SHORTINT;
    interrupt [9] : E.InterruptPtr )
  : E.InterruptPtr;
  -6;
LIBCALL (base : CiaBasePtr) RemICRVector*
  ( icrBit    [0] : LONGINT;
    interrupt [9] : E.InterruptPtr );
  -12;
LIBCALL (base : CiaBasePtr) AbleICR*
  ( mask [0] : E.BSET )
  : E.BSET;
  -18;
LIBCALL (base : CiaBasePtr) SetICR*
  ( mask [0] : E.BSET )
  : E.BSET;
  -24;


(**-- Resource Base variable --------------------------------------------*)
(** $L- Address globals through A4 *)


(**-----------------------------------*)
PROCEDURE OpenCiaA * (mustOpen : BOOLEAN);

BEGIN (* OpenCiaA *)
  IF ciaA = NIL THEN
    ciaA := E.base.OpenResource (ciaaName);
    IF mustOpen & (ciaA = NIL) THEN HALT (100) END;
  END; (* IF *)
END OpenCiaA;

(**-----------------------------------*)
PROCEDURE OpenCiaB * (mustOpen : BOOLEAN);

BEGIN (* OpenCiaB *)
  IF ciaB = NIL THEN
    ciaB := E.base.OpenResource (ciabName);
    IF mustOpen & (ciaB = NIL) THEN HALT (100) END;
  END; (* IF *)
END OpenCiaB;

END Cia.
