***********************************************************************
*
*   libraries/dctv.i
*
*   Copyright (C) 1991, 1992 Digital Creations, Inc.
*
*   v3.0 - 22 May 1992
*
***********************************************************************

    ifnd    LIBRARIES_DCTV_I
LIBRARIES_DCTV_I set 1

    ifnd GRAPHICS_GFX_I
      include "graphics/gfx.i"
    endc

    ifnd UTILITY_TAGITEM_I
      include "utility/tagitem.i"
    endc


* --------------------- Library name & version

DCTVLIB_Name macro
        dc.b    'dctv.library',0
        endm

DCTVLIB_Minimum equ 1               ; Minimum supported library version #.


* --------------------- DCTVCvtHandle structure

*   This is the conversion environment structure returned by
*   AllocDCTVCvtTagList() and used by all dctv.library conversion
*   functions.
*
*   All fields, unless otherwise noted, are READ-ONLY.

    STRUCTURE DCTVCvtHandle,0
        APTR    cvt_Red             ; 24-bit RGB 70ns chunky line buffer.
        APTR    cvt_Green           ;
        APTR    cvt_Blue            ; DCTVCVTT_RGBtoDCTV:
                                    ;     Buffer contents are input to
                                    ;     CvtDCTVLine().  CvtDCTVLine()
                                    ;     preserves the contents of this
                                    ;     buffer.
                                    ;
                                    ; DCTVCVTT_DCTVtoRGB:
                                    ;     Buffer contents are output from
                                    ;     CvtDCTVLine().
                                    ;
                                    ; Data maps pixel for pixel with
                                    ; the output BitMap (i.e. Red[0]
                                    ; maps to the leftmost pixel in the
                                    ; the BitMap; Red[Width-1] maps to
                                    ; the rightmost pixel in the
                                    ; BitMap).
                                    ;
                                    ; This buffer is automatically
                                    ; allocated by AllocDCTVCvtTagList()
                                    ; when DCTVCVTF_CustomRGBBuf isn't
                                    ; specified.  In this case these
                                    ; pointers are read-only (the buffer
                                    ; may still be written to, though).
                                    ;
                                    ; When DCTVCVTF_CustomRGBBuf is
                                    ; specified, these pointers start
                                    ; out being NULL.  The Client must set these
                                    ; pointers to a custom RGB line buffer
                                    ; set before calling CvtDCTVLine().
                                    ; Also, in this case, these pointers may
                                    ; be changed between calls to CvtDCTVLine().

        APTR    cvt_BitMap          ; Pointer to client-supplied BitMap.
                                    ; DCTVCVTT_RGBtoDCTV:
                                    ;     Output of conversion.
                                    ; DCTVCVTT_DCTVtoRGB:
                                    ;     Input to conversion.  Contents
                                    ;     are preserved.
                                    ;
                                    ; The BitMap structure itself is read-only
                                    ; (i.e. don't change dimensions or Planes[] pointers).

        WORD    cvt_Width           ; Width of RGB line buffers (derived from DCTVCVTA_Width).
        WORD    cvt_Height          ; Conversion Height (derived from DCTVCVTA_Height).

        STRUCT  cvt_ImageBounds,ra_SIZEOF
                                    ; Visible image area within BitMap.
                                    ; Pixels outside this rectangle are
                                    ; used for DCTV control
                                    ; information.  RGB data supplied
                                    ; outside this rectangle are be
                                    ; ignored by CvtDCTVLine().

        APTR    cvt_ColorTable      ; RGB4 color table for DCTV display.
                                    ; The data in this array is also
                                    ; read-only.
                                    ;
                                    ; DCTVCVTT_RGBtoDCTV:
                                    ;     Allocated and supplied by
                                    ;     dctv.library.
                                    ; DCTVCVTT_DCTVtoRGB:
                                    ;     Supplied by client in
                                    ;     DCTVCVTA_ColorTable.
                                    ;     The contents can be changed
                                    ;     with SetDCTVColorTable().

        UBYTE   cvt_NColors         ; # of colors in ColorTable.

        BYTE    cvt_NDelayLines     ; # of lines delay between input
                                    ; and output data.  Actual value
                                    ; depends on conversion type and
                                    ; options.  May change from one
                                    ; release of the library to another.

            ; Line numbers incremented by calls to CvtDCTVLine().
        WORD    cvt_SrcLineNum      ; # of source lines converted.
                                    ; (0 <= SrcLineNum <= Height+NDelayLines)
        WORD    cvt_DstLineNum      ; # of destination lines output.
                                    ; (-NDelayLines <= DstLineNum <= Height)

            ; padding
        STRUCT  cvt_pad,16

    LABEL   DCTVCvtHandle_PublicSize
    ; private stuff follows


* --------------------- AllocDCTVCvtTagList() tags

    ; V3 tags
DCTVCVTA_base       equ TAG_USER+1

DCTVCVTA_Type       equ DCTVCVTA_base+0     ; (UWORD) - DCTVCVTT_ types defined below.
                                            ; Default is DCTVCVTT_RGBtoDCTV.

DCTVCVTA_Width      equ DCTVCVTA_base+1     ; (WORD) - Pixel width of conversion.
                                            ; Truncated to a multiple of 16.
                                            ; Default is derived from the BitMap.

DCTVCVTA_Height     equ DCTVCVTA_base+2     ; (WORD) - Height of conversion.
                                            ; Default is derived from the BitMap.

DCTVCVTA_Flags      equ DCTVCVTA_base+3     ; (UWORD) - DCTVCVTF_ flags defined below.
                                            ; Default is 0.

DCTVCVTA_ColorTable equ DCTVCVTA_base+4     ; (UWORD *) - Initial ColorTable for DCTVCVTT_DCTVtoRGB.
                                            ; RGB4 color array containing 1<<bitmap->Depth entries.
                                            ; Required for DCTVCVTT_DCTVtoRGB; ignored for
                                            ; DCTVCVTT_RGBtoDCTV.  Subsequent palette changes
                                            ; must be registered with SetDCTVColorTable().
                                            ; Array must remain valid until it is replaced with
                                            ; SetDCTVColorTAble() or the conversion environment is freed.

DCTVCVTA_ErrorCode  equ DCTVCVTA_base+5     ; (ULONG *) - Pointer to a ULONG where an
                                            ; extended error code is placed if AllocDCTVCvtTagList()
                                            ; fails.  Results are DCTVCVTERR_ defined below.
                                            ; Error code buffer isn't changed if there is no error.


* --------------------- DCTVCVTA_Type types

    ENUM
    EITEM   DCTVCVTT_RGBtoDCTV      ; RGB to DCTV conversion
    EITEM   DCTVCVTT_DCTVtoRGB      ; DCTV to RGB conversion


* --------------------- AllocDCTVCvt() flags / DCTVCVTA_Flags flags

    BITDEF  DCTVCVT,Lace,0          ; Interlaced DCTV display image.
    BITDEF  DCTVCVT,Filter,1        ; Apply RGB filtering for DCTVCVTT_RGBtoDCTV.
                                    ; Ignored for DCTVCTVT_DCTVtoRGB.
    BITDEF  DCTVCVT,1LineBM,2       ; Use BitMap as a single-line buffer.

        ; V3 flags
    BITDEF  DCTVCVT,CustomRGBBuf,3  ; Don't allocate RGB line buffer, client will be supplying his own.


* --------------------- DCTVCVTERR_ error codes

    ENUM    1
    EITEM   DCTVCVTERR_NoMem        ; Not enough memory.
    EITEM   DCTVCVTERR_BadBitMap    ; Supplied BitMap is invalid:  invalid depth or dimensions.
    EITEM   DCTVCVTERR_UnknownType  ; Unknown conversion type.
    EITEM   DCTVCVTERR_BadParams    ; Invalid parameters for conversion type.


    endc
