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

:Program.     SuperPlay.mod
:Contents.    interface module for superplay.library
:Copyright.   © 1994 by Andreas R. Kleinert
:Language.    Oberon-2
:Translator.  A+L Amiga Oberon Compiler V3.11d
:History.     V4.1  indy  23-Dec-95 first translation of c include
:History.     V5.1  indy  07-Jan-96 update to c include V5.1(8.8.96)
:History.                           change GetErrorString() e.STRPTR TO e.LSTRPTR
*********************************************************************)

MODULE SuperPlay;

(* $VER: SuperPlay 5.1 (07.01.96)

 * !!! IMPORTANT NOTE !!!
 * Before procedures of this module may be used, you have to check
 * SuperPlay.base#NIL because opening SuperPlay fails on Amigas without
 * SuperPlay.library V4.0+.

 * If you want to use procedures of this module which needs
 * SuperPlay.library > V4.0 you have to check SuperPlay.base.libNode.version
 * (SuperPlay.LibVer()).

 Example:
 --------
   IMPORT
     sp: SuperPlay,
     io;

   BEGIN
     IF sp.base=NIL THEN
       io.WriteString ("I need SuperPlay.library V4.0+\n"); END;

     (* Example for Version >= V4.0+ check *)

     IF  sp.LibVer(sp.base)<5 THEN
       io.WriteString ("I need SuperPlay.library V4.0+\n"); END;
     END;


  This Oberon-2 interface module contains the c-includes:
  -------------------------------------------------------
    superplay/superplaybase.h
      Version    : 5.1
      Date       : 8.8.1996
      Written by : Andreas R. Kleinert

    superplay/superplay.h
      Version    : 5.1
      Date       : 8.8.1996
      Written by : Andreas R. Kleinert
*)


IMPORT
  e   *: Exec,
  d   *: Dos,
  dt  *: Datatypes,
  i   *: Intuition,
  iff *: IFFParse,
  u   *: Utility,

  spo *: spObjects;
(*****************************************************************************)


CONST
  name     - = "superplay.library";

  (***************************************
   *  superplay/superplay.h              *
   *    Version    : 5.1                 *
   *    Date       : 8.8.1996            *
   *    Written by : Andreas R. Kleinert *
   ****************************************)

  (***************************************************
   *                                                 *
   * Version Defines                                 *
   *                                                 *
   ***************************************************)

  libMinimum = 5 ;  (* lowest supported version                   *)
  libVersion = 5;   (* just for info, should not be used anywhere *)


  (***************************************************
   *                                                 *
   * MACROs for Version-Tests                        *
   *                                                 *
   ***************************************************)

PROCEDURE LibVer*(lib: e.LibraryPtr): INTEGER;

BEGIN
  RETURN lib.version;
END LibVer;


PROCEDURE OSVer*(): INTEGER;

BEGIN
  RETURN LibVer(e.SysBase);
END OSVer;


TYPE
  SuperPlayBasePtr * = UNTRACED POINTER TO SuperPlayBase;

  (***************************************************
   *                                                 *
   * DEFINES                                         *
   *                                                 *
   ***************************************************)


(* Possible FileTypes *)

CONST
  filetypeNone    - = 0;
  filetypeUnknown - = filetypeNone;

     (*
        above : External, user defined FileTypes
                (defined EACH TIME NEW at Library's startup-time).
     *)

  filetypeIllegal - = 0FFFFFFFFH;


(* Possible SubTypes of FileTypes *)

  subtypeNone     - = 0;
  subtypeUnknown  - = subtypeNone;

     (*
        above : External, user defined FileSubTypes
                (defined EACH TIME NEW at Library's startup-time).
     *)

  subtypeIllegal  - = 0FFFFFFFFH;


(* Possible Input and Output mediums *)

  mediumNone      - = 0;
  mediumIllegal   - = 0FFFFFFFFH;

  mediumDisk      - = 1;              (* Play and Write options   *)
  mediumClip      - = 2;

     (* might not be supported by all kinds of File(Sub)Types *)


  (***************************************************
   *                                                 *
   * Function Error Codes                            *
   *                                                 *
   ***************************************************)

  errMaxErrorTextLength - = 80;    (* plus Null-Byte *)

  errNoError            - =  0;
  errInternalError      - =  0FFFFFFFFH;

  errUnknownFileFormat  - =  1;
  errFileNotFound       - =  2;
  errNoMemory           - =  3;
  errIFFParseError      - =  4;
  errNoClipboard        - =  5;
  errNoFile             - =  6;
  errNoHandle           - =  7;
  errNoData             - =  8;
  errNoInformation      - =  9;
  errIllegalAccess      - = 10;
  errDecodeError        - = 11;
  errUnknownParameters  - = 12;
  errActionNotSupported - = 13;
  errNoChannels         - = 14;
  errVersionConflict    - = 15;
  errNoSamplesLoaded    - = 16;

        (* Each new Library-Subversion may contain new Codes above
           the last one of these.
           So do not interpret the codes directly, but use
           SPL_GetErrorString.
           Maybe, newer Codes might not be listed up here.
        *)


(************************************
 * superplay/superplaybase.h        *
 * Version    : 5.1                 *
 * Date       : 8.8.1996            *
 * Written by : Andreas R. Kleinert *
 ************************************)

   (*
      All entries are READ-ONLY.
      The private entries should NEVER be accessed.

      Oberon-2:
        spObjectList is define as read- and writeable because with
        Oberon V3.11d its not possible to get the address of a read only
        variable with SYSTEM.ADR().
   *)

TYPE
  SuperPlayBase   - = STRUCT (libNode - : e.Library)
    segList       - : e.APTR;
    sysBase       - : e.ExecBasePtr;
    dosBase       - : d.DosLibraryPtr;
    intuitionBase - : i.IntuitionBasePtr;
    spObjectList  * : e.List;
    private1      - : LONGINT;
    private2      - : LONGINT;
    utilityBase   - : u.UtilityBasePtr;
    iffParseBase  - : e.LibraryPtr;          (* may be NULL *)
    dataTypesBase - : e.LibraryPtr;          (* may be NULL *)
  END;


VAR
  base -: SuperPlayBasePtr;


(*  Functions available since Version 1 *)

PROCEDURE AllocHandle     * {base, - 30} (future{9}: e.APTR): e.APTR;
PROCEDURE FreeHandle      * {base, - 36} (handle{9}: e.APTR);
PROCEDURE StopReplay      * {base, - 42} (handle{9}: e.APTR);
PROCEDURE FreeResources   * {base, - 48} (handle{9}: e.APTR);
PROCEDURE SuperPlay       * {base, - 54} (handle{9}: e.APTR; filename{10}: ARRAY OF CHAR): LONGINT;
PROCEDURE SuperWrite      * {base, - 60} (handle{9}, sourceHandle{10}: e.APTR): LONGINT;
PROCEDURE InitHandleAsDOS * {base, - 66} (handle{9}, future{10}: e.APTR): LONGINT;
PROCEDURE InitHandleAsClip* {base, - 72} (handle{9}, future{10}: e.APTR): LONGINT;
PROCEDURE SetWriteType    * {base, - 78} (handle{9}: e.APTR; writeType{10}: LONGINT; future{11}: e.APTR): LONGINT;
PROCEDURE GetErrorString  * {base, - 84} (errorCode{9}: LONGINT): e.LSTRPTR;
PROCEDURE SetWriteName    * {base, - 90} (handle{9}: e.APTR; writeName{10}: ARRAY OF CHAR; future{11}: e.APTR): LONGINT;
PROCEDURE FileInfoRequest * {base, - 96} (handle{9}: e.APTR; window{10}: i.WindowPtr; future{11}: e.APTR): LONGINT;
PROCEDURE SetReqIOWindow  * {base, -102} (handle{9}: e.APTR; window{10}: i.WindowPtr): LONGINT;
PROCEDURE ReadPlayData    * {base, -108} (handle{9}: e.APTR; filename{10}: ARRAY OF CHAR): LONGINT;
PROCEDURE ContinueReplay  * {base, -114} (handle{9}: e.APTR): LONGINT;
PROCEDURE FastForward     * {base, -120} (handle{9}: e.APTR): LONGINT;
PROCEDURE FastBackward    * {base, -126} (handle{9}: e.APTR): LONGINT;

(* Functions added with Version 2 *)

PROCEDURE GetSampleList   * {base, -132} (handle{9}: e.APTR; list{10}: UNTRACED POINTER TO spo.SampleListPtr): LONGINT;
PROCEDURE SetSampleList   * {base, -138} (handle{9}: e.APTR; list{10}: spo.SampleListPtr): LONGINT;

(* Functions added with Version 4 *)

PROCEDURE GetFileType     * {base, -144} (handle{9}: e.APTR; filename{10}: ARRAY OF CHAR; fileType{11}: UNTRACED POINTER TO LONGINT): LONGINT;


BEGIN
  base :=  e.OpenLibrary(name, 4);

CLOSE
  IF base#NIL THEN e.CloseLibrary(base) END;

END SuperPlay.
