(**********************************************************************
   :Program.    GraphicSupport
   :Author.     Frank Staudte. [fst]
   :Address.    Hasenbergstr. 91 D-7000 Stuttgart 1
   :Support.    [bne] & [pit] Thanks!
   :History.    AUG-88 1.0 first PD Amok #9 all basic funktions
   :History.    APR-89 1.1 second PD AddBitPane, FreeBitPlane added
   :History.    MAY-89 1.2 New Coding for m2c V3.2d [fst]
   :Copyright.  (C) Frank Staudte 1989. This is in the public domain.
   :Language.   Modula-II.
   :Translator. M2Amiga. V3.11d
   :Imports.    MemSystem V1.0 [bne] Amok#5,
   :Imports.    IFFSupport V1.1 [fbs] AMOK#21.
   :Contents.   Supports the Graphic-Primitives. (See documentation!)
   :Remark.     Please read the Copyright-file about copyright!!!
**********************************************************************)

DEFINITION MODULE GraphicSupport;

FROM Graphics   IMPORT BitMapPtr, ViewPortPtr, ViewModeSet, ViewPtr,
  ViewModes, RastPortPtr, RasInfoPtr;
FROM Exec       IMPORT UByte;

CONST
  dualPF        = ViewModeSet{dualpf,pfba};
  extraHB       = ViewModeSet{extraHalfbrite};
  Ham           = ViewModeSet{ham};
  Hires         = ViewModeSet{hires};
  Lace          = ViewModeSet{lace};
  Standard      = ViewModeSet{};

  maxDepth      = 8; (* new in V1.1: *)

TYPE
  ILBMColors = RECORD
    ColCount: CARDINAL;
    red,green,blue: ARRAY [0..63] OF UByte;
  END;

(* ================================================================== *)
(*                          Version 1.0                               *)
(* ================================================================== *)

PROCEDURE RasSize(width,height: CARDINAL): CARDINAL;
(* :Input.     width & height of the raster or bitmap
   :Result.    Size of the complete raster.
   :Semantic.  This Macro is a replacement for RasSize.GelMacros
   :Semantic.  Author: Nicolas Benezan [bne] !!!
*)


PROCEDURE CreateBitMap(width,height,depth: INTEGER):BitMapPtr;
(* :Input.     width,height and depth of the Bitmap
   :Result.    A Pointer to a complete Bitmap in CHIP-Ram!
   :Semantic.  Use this to create a Bitmap
*)


PROCEDURE CreateRastPort(bitMap: BitMapPtr): RastPortPtr;
(* :Input.      bitMap: Pointer to the Bitmap to be used in this Rastport.
   :Result.     Pointer to a Rastport-Structure
   :Semantic.   Use this to create a Rastport
*)


PROCEDURE CreateViewPort(VAR rInfo: RasInfoPtr;
                             nextViewPort: ViewPortPtr;
                             leftEdge,topEdge: INTEGER;
                             width,height: INTEGER;
                             Bitmap: BitMapPtr;
                             Modes: ViewModeSet;
                             NumberOfColors: INTEGER): ViewPortPtr;

(* :Input.     nextViewPort: Pointer to a next ViewPort
   :Input.     leftEdge, topEdge: where to start the ViewPort
   :Input.     width,height: which size ?
   :Input.     BitMap: Where to find the data for graphics?
   :Input.     Modes: Same as Intuition.Screen.viewModes
   :Input.     NumberOfColors: How many Colors for the ViewPort
   :Output.    rInfo: Pointer to the RasInfo of the ViewPort
   :Result.    Pointer to the ViewPort
   :Semantic.  Use this to create a ViewPort for your display
*)


PROCEDURE CreateView(FirstViewPort: ViewPortPtr): ViewPtr;
(* :Input.     Pointer to the ViewPort which is to be installed on
   :Input.     a View.
   :Output.    Pointer to a View-Structure.
   :Semantic.  Use this to create a View! Use REMAKE to display it!
*)


PROCEDURE FreeBitMap(bitMap: BitMapPtr);
(* :Input.     Which BitMap?
   :Semantic.  Free's all the memory of a BitMap
*)


PROCEDURE FreeRastPort(rastPort: RastPortPtr);
(* :Input.     Which RastPort?
   :Semantic.  Deletes a RastPort
*)


PROCEDURE FreeViewPort(viewPort: ViewPortPtr; rInfo: RasInfoPtr);
(* :Input.     Which ViewPort and which rInfo?
   :Semantic.  Deletes a ViewPort
*)


PROCEDURE FreeView(VAR NewView: ViewPtr; ActiveView,OldView: ViewPtr);
(* :Input.     ActiveView: Pointer to the View to be freed
   :Input.     OldView: Pointer to the View which as been active
   :Input.              before ActiveView started working.
   :Output.    NewView: Same as OldView. This View is now Active!
   :Semantic.  This is to free a View and bring control back to the old
   :Semantic.  View (perhaps the Workbench-View!)
*)


PROCEDURE MakeVPDualPF(VAR viewPort: ViewPortPtr;
                           Bitmap: BitMapPtr): RasInfoPtr;
(* :Input.     Which ViewPort? Which additional BitMap?
   :Output.    New ViewPort-Structure
   :Result.    Newly created RasIfon-Structure
   :Semantic.  Extendes your ViewPort to DualPlayField
*)


PROCEDURE Remake(view: ViewPtr; viewPort: ViewPortPtr);
(* :Input.     Which View and which ViewPort?
   :Semantic.  Use this to display or refresh your View(Port)
*)


PROCEDURE ReadILBMBitMap(name: ARRAY OF CHAR;
                         VAR Width, Height, Depth: INTEGER;
                         VAR Colors: ILBMColors;
                         VAR err: BOOLEAN): BitMapPtr;
(* :Input.     name: Path to the Picture
   :Output.    Width, Height, Depth: Size of the Bitmap
   :Output.    Colors of the Picture. (see SetILBMColors!!)
   :Output.    err contains a BOOLEAN if loading was successfull
   :Result.    Pointer to a Bitmap containing data about the picture.
   :Result.    Use as a simple BitMap!
   :Semantic.  This is an easy ILBM-Loader. Actaully this is the same
   :Semantic.  as IFFSupport.LoadIFF [fbs] but with changes on the
   :Semantic.  interface.
   :Note.      ReadILBM written by [fbs].
   :Note.      ReadILBMBitMap written by [fst] based on ReadILBM!
*)


PROCEDURE SetILBMColors(viewPort: ViewPortPtr; Colors: ILBMColors);
(* :Input.     Which ViewPort and what colors?
   :Semantic.  This sets the Color of a Picture in your ViewPort
*)


PROCEDURE FreeILBMBitMap(bitMap: BitMapPtr);
(* :Input.     Wich Bitmap?
   :Semantic.  Free's data and memory of your Picture(bitmap)
   :Semantic.  This does the not exactly the same as FreeBitMap
*)


PROCEDURE ScrollVPort(viewPort: ViewPortPtr; rInfo: RasInfoPtr;
                      pixX, pixY: INTEGER): BOOLEAN;
(* :Input.     Which ViewPort and rasInfo?
   :Input.     How many Pixel to scroll
   :Result.    TRUE if scrolling was succsessful or not
   :Semantic.  This scrolls your Bitmap arround!
*)


PROCEDURE Swap(VAR rastPort: RastPortPtr; VAR rInfo: RasInfoPtr);
(* :Input.     Which RastPort and which rasInfo of a ViewPort
   :Output.    Pointers to new RastPort and RasInfo
   :Semantic.  Use this to "swap" the BitMaps if you want them
   :Semantic.  Doubble-Bufferd!
*)


(* ================================================================== *)
(*                          Version 1.1                               *)
(* ================================================================== *)

PROCEDURE AddBitPlane(VAR bitMap: BitMapPtr; number: INTEGER): BOOLEAN;
(* :Input.     Which BitMap is to be extended?
   :Input.     How many planes to be added?
   :Output.    Pointer to the new, extended BitMap
   :Result.    TRUE if adding was successful. (Read DOC!)
   :Semantic.  Use this to extend a BitMap (increase the depth)
*)


PROCEDURE FreeBitPlane(VAR bitMap: BitMapPtr; number: INTEGER): BOOLEAN;
(* :Input.     Which BitMap?
   :Input.     How many planes to be deleted?
   :Output.    Pointer to the newer, smaler BitMap
   :Result.    TRUE if deleting was successful. (Read DOC!)
   :Semantic.  Use this to delete some Planes on your BitMap
*)

END GraphicSupport.DEF
