;---------------------------------------------------------------------------
;   IFND UTILITY_TAGITEM_I
;                include   utility/tagitem.i
;   ENDC
;---------------------------------------------------------------------------
RETINA_LIB_VERSION  equ  5            ;the current version of retina.library
;---------------------------------------------------------------------------
SEGMENTSIZE    equ       64*1024
;---------------------------------------------------------------------------
;---- Alerts:

; an alert number like 35xx01xx identifies an alert caused by retina.library

ALERT_NOHARD             equ   $0100   ;no Retina hardware present

ALERT_NOMEM              equ   $0110|AG_NoMemory  ;Retina does not have any memory at all
ALERT_NOMEMTOFREE        equ   $0111   ;tried to free memory although no memory is in use
ALERT_MEMTOFREENOTFOUND  equ   $0112   ;tried to free memory which has not been allocated
ALERT_NOMEMNODEMEM       equ   $0113|AG_NoMemory  ;no Amiga memory for memory listnode
ALERT_MEMNOTFREED        equ   $0114   ;still some memory in use at library expunge

ALERT_CLOSE_LIB_MONITOR  equ   $0121   ;tried to remove a library internal monitor
ALERT_MONITOR_NOT_CLOSED equ   $0122   ;LIB_Expunge and not all monitors removed
ALERT_MONITOR_ID_INUSE   equ   $0123   ;monitor ID used twice (internal use only)
;---------------------------------------------------------------------------
; modes for Retina_SetDrMd()

RDM_JAM1       equ       0
RDM_COMPLEMENT equ       2
;---------------------------------------------------------------------------
; modes for Retina_WriteBitMap()

WBMMODE_STD    equ       0      ;normal 2 to 256 color images and EHB to 8 bit
WBMMODE_HAM    equ       1      ;4096 color HAM to 16 or 24 bit (16 Bit: (v4))
WBMMODE_HAM8   equ       2      ;256k color AA HAM to 24 bit

 BITDEF WBMMODE,EXTENDED,16     ;see retina.doc/Retina_WriteBitMap() (v3)
;---------------------------------------------------------------------------
; modes for Retina_WriteRect(), ...

RECTMODE_RGB     equ     0      ;one byte each for red, green, blue
RECTMODE_RGBA    equ     1      ;one byte each for red, green, blue and alpha
RECTMODE_BGR     equ     2      ;same as RGB, but reverse pixel order
RECTMODE_GB_R    equ     3      ;PRIVATE, do not use
RECTMODE_256     equ     4      ;one byte for each pixel
RECTMODE_GB_R0   equ     5      ;PRIVATE, do not use
RECTMODE_RAW     equ     6      ;raw data, either 8, 16 or 24 bit (v4)
RECTMODE_RGBA_0  equ     7      ;PRIVATE, do not use (v5)
;---------------------------------------------------------------------------
; Tagitems for SetSprite() or SpriteFunction():

RSP_On         equ       TAG_USER+1
RSP_Color0     equ       TAG_USER+2
RSP_Color1     equ       TAG_USER+3
RSP_ZoomX      equ       TAG_USER+4
RSP_ZoomY      equ       TAG_USER+5         ;ignored by SpriteFunction()
;---------------------------------------------------------------------------
MONID_LIB      equ       $00000000   ; IDs used by retina.library. Do NOT use!
MONID_WBEMU    equ       $10000000   ; IDs used by RetinaEmu. Do NOT use!
MONID_CUSTOM   equ       $20000000   ; Software which adds custom monitor
                                     ; definitions must set the highest
                                     ; nibble of the monitor ID to 2!
MONID_AUTO     equ       $70000000   ; Auto-IDs created by Retina_AddMonitor().
                                     ; Do NOT use!
MONID_ADDAUTO  equ       $ffffffff   ; Used by Retina_AddMonitor() to create
                                     ; auto IDs.

; flag definitions for _nrm_Flags and _rm_Flags:

 BITDEF MD,DBL,0         ;1 = Double-Scan
 BITDEF MD,LACE,1        ;1 = Interlace
 BITDEF MD,CLKDIV2,2     ;1 = use 1/2 pixel clock
 BITDEF MD,PLANAR,3      ;1 = screen has 16 colors on 4 planes          (v2)
 BITDEF MD,HIDE,4        ;1 = entry should not appear in public lists   (v2)
 BITDEF MD,GROUP,5       ;1 = this definition is a group-header         (v2)
 BITDEF MD,POSHSYNC,6    ;1 = HSync wird positiv                        (v4)
 BITDEF MD,POSVSYNC,7    ;1 = VSync wird positiv                        (v4)

ATNT_MODE_8    equ       0   ; 8 bit with color lookup
ATNT_MODE_15   equ       1   ;15 bit true color with color lookup  (not supported)
ATNT_MODE_24   equ       2   ;24 bit true color with color lookup
ATNT_MODE_16   equ       3   ;16 bit true color with color lookup
ATNT_MODE_res  equ       4   ;not available
ATNT_MODE_15b  equ       5   ;same as 1, but lookup table bypassed (currently unused)
ATNT_MODE_16b  equ       6   ;same as 3, but lookup table bypassed (currently unused)
ATNT_MODE_24b  equ       7   ;same as 2, but lookup table bypassed (currently unused)

 STRUCTURE __NewRetinaMonitor,0
               LONG      _nrm_MonitorID     ;a unique ID to describe this monitor
                                            ; 0 is NOT a valid ID
                                            ;-1 forces Retina_Addmonitor() to
                                            ;   generate a unique ID
               LONG      _nrm_PixelClock    ;the desired pixelclock, must be one
                                            ;out of:
                                            ;25175000,28322000,36000000,44900000
                                            ;50000000,56644000,63000000,65000000
                                            ;72000000,75000000,80000000,90000000
               BYTE      _nrm_AtntMode      ;see definitions above
               BYTE      _nrm_Flags         ;see definitions above

               LABEL     _nrm_NewGroupIDs   ;PRIVATE (v5)

               WORD      _nrm_StdWidth      ;standard width of the monitor
               WORD      _nrm_StdHeight     ;standard height of the monitor
               WORD      _nrm_MaxWidth      ;maximum (overscen) width of the monitor
               WORD      _nrm_MaxHeight     ;maximum (overscen) height of the monitor

               LABEL     _nrm_GroupIDs      ;a ULONG *, pointing to a NULL terminated
                                            ;  array of monitor IDs. (v2)
               WORD      _nrm_HBStart
               WORD      _nrm_HSStart
               WORD      _nrm_HSEnd
               WORD      _nrm_HBEnd
               WORD      _nrm_HTotal

               WORD      _nrm_VBStart
               WORD      _nrm_VSStart
               WORD      _nrm_VSEnd
               WORD      _nrm_VBEnd
               WORD      _nrm_VTotal

               LABEL     _nrm_SIZEOF

; Do NOT refer to _nrm_SIZEOF, this structure may grow in the future!
;---------------------------------------------------------------------------
 STRUCTURE __RetinaMonitor,0
               STRUCT    _rm_Node,LN_SIZE

               LONG      _rm_MonitorID

               LONG      _rm_HFrequency
               LONG      _rm_VFrequency

               WORD      _rm_BytesPerPixel

               WORD      _rm_StdWidth
               WORD      _rm_StdHeight
               WORD      _rm_MaxWidth
               WORD      _rm_MaxHeight

               BYTE      _rm_PrivateFlags   ;PRIVATE, do not use!
               BYTE      _rm_Reserved1      ;PRIVATE, do not use!
               BYTE      _rm_AtntMode       ;a copy of _nrm_AtntMode
               BYTE      _rm_Flags          ;a copy of _nrm_Flags

               APTR      _rm_GroupIDs       ;points to a null terminated array of IDs
                                            ;if this is a group, otherwise NULL (v5)
               LONG      _rm_PixelClock     ;(v5)

               LABEL     _rm_PUBSIZE        ;never use this!
;---------------------------------------------------------------------------
;definitions for _dsi_Flags
 BITDEF DSI,USEWIDTH,0     ;If set, use the value in _dsi_Width. If not set,
                           ;  pass the original value to Retina_OpenScreen().
 BITDEF DSI,USEHEIGHT,1    ;If set, use the value in _dsi_Height. If not set,
                           ;  pass the original value to Retina_OpenScreen().

 STRUCTURE _DefaultScreenInfo,0
               LONG      _dsi_ID            ;the current ScreenMode-ID
               WORD      _dsi_Width         ;the current width
                                            ;(only valid if DSIB_USEWIDTH is set)
               WORD      _dsi_Height        ;the current height
                                            ;(only valid if DSIB_USEHEIGHT is set)
               BYTE      _dsi_Flags         ;flag definitions see above
               STRUCT    _dsi_Reserved,7    ;reserved, do not use
               LABEL     _dsi_SIZEOF
;---------------------------------------------------------------------------
; special values vor Retina_OpenScreen() Width and Height

RSCR_MINWIDTH  equ       13              ;minimum width of a Retina screen
RSCR_MINHEIGHT equ       1               ;minimum height of a Retina screen

RSCR_STDWIDTH  equ       -1              ;open the screen at its standard width
RSCR_STDHEIGHT equ       -1              ;open the screen at its standard height
RSCR_MAXWIDTH  equ       -2              ;open the screen at its maximum width
RSCR_MAXHEIGHT equ       -2              ;open the screen at its maximum height

; TagItems for Retina_OpenScreen():

RSA_BitMap     equ       TAG_USER+1      ;use this BitMap
RSA_DBufBitMap equ       TAG_USER+2      ;not supported yet
RSA_ErrorCode  equ       TAG_USER+3      ;return an error code
RSA_Name       equ       TAG_USER+4      ;the screens name (v3)
RSA_Palette    equ       TAG_USER+5      ;the screens initial palette (v3)
RSA_PaletteRange  equ    TAG_USER+6      ;to select less then 256 colors (v3)
                                         ;high word of ti_Data: First
                                         ;low word of ti_Data: Count
                                         ;see: retina.doc/Retina_LoadPalette()
RSA_FreeID     equ       TAG_USER+7      ;optional ID for 'free screens' (v4)
RSA_TopEdge    equ       TAG_USER+8      ;top edge of the panel screen (v5)
RSA_Parent     equ       TAG_USER+9      ;parent screen used by the panel screen (v5)
RSA_Depth      equ       TAG_USER+10     ;PRIVATE, do not use!

; values for RSA_ErrorCode:

ROSERR_NONE         equ  0   ; everything ok if Retina_OpenScreen() returned NON-NULL
                             ;   or unknown error if it returned NULL
ROSERR_ID           equ  1   ; unknown monitor-ID
ROSERR_DEFAULTID    equ  2   ; unknown default monitor-ID
ROSERR_TOOBIG       equ  3   ; screen size is too big
ROSERR_NOMEM        equ  4   ; couldn't get normal memory
ROSERR_NORETINAMEM  equ  5   ; couldn't get Retina graphics memory
ROSERR_TOOSMALL     equ  6   ; screen size is too small (< 13*1) (v5)
ROSERR_CLOCK        equ  7   ; pixelclock is too high (v5)

; Flags for _rs_Flags:

 BITDEF RSF,DONTCLEARONOPEN,0          ;don't clear the screens memory when opened
 BITDEF RSF,DONTCLEARONCLOSE,1         ;don't turn off display after closing screen
 BITDEF RSF,DOUBLEBUFFER,2             ;prepare screen for double buffering
 BITDEF RSF,CUSTOMBITMAP,3             ;PRIVATE, do not use
 BITDEF RSF,CUSTOMDBUFBITMAP,4         ;PRIVATE, do not use
 BITDEF RSF,AUTOADJUST,5               ;adjust the screens size if too big, ...
 BITDEF RSF,OPENBEHIND,6               ;open the screen behind all others
 BITDEF RSF,DBUFPALETTE,7              ;use special palette handling (v3)
 BITDEF RSF,OVERSIZED,8                ;PRIVATE, do not use (v3)
 BITDEF RSF,SYSTEM,9                   ;PRIVATE, do not use (v3)
 BITDEF RSF,DONTCLOSEONCLOSE,10        ;don't close the screen on CloseScreen() (v4)
 BITDEF RSF,FREE,11                    ;PRIVATE, do not use (v4)
 BITDEF RSF,ZEROBITMAP,12              ;PRIVATE, do not use (v5)
 BITDEF RSF,PANEL,13                   ;screen is a panel screen (v5)
 BITDEF RSF,LOCKPANEL,14               ;panel screen is locked to its parent (v5)

  STRUCTURE __RetinaScreen,LN_SIZE          ;ListNode for internal use only
                                            ;LN_NAME MAY point to the screens name
                                            ;  it also may be NULL! (v3)
               WORD      _rs_Width          ;number of pixels in one horizontal line
               WORD      _rs_Height         ;number of lines
;---
               APTR      _rs_BitMap         ;the screen's address in Retina memory
               APTR      _rs_DBufBitMap     ;used for double buffered screens

               LONG      _rs_Flags          ;flags see above

               LABEL     _rs_APen
               BYTE      _rs_APen_reserved  ;reserved
               BYTE      _rs_APenR          ;the red component (true color only)
               BYTE      _rs_APenG          ;the green component (true color only)
               LABEL     _rs_APen256        ;the number of the palette register
                                            ;  on a 256 color screen
               BYTE      _rs_APenB          ;  or the blue component (true color)
;---
               BYTE      _rs_DrawMode       ;RDM_JAM1, ...
               BYTE      _rs_Reserved       ;(v3)
;---
               WORD      _rs_BytesPerPixel  ;number of bytes per pixel (1..3)
               WORD      _rs_Modulo         ;number of bytes in one line
               APTR      _rs_Monitor        ;struct RetinaMonitor *

               APTR      _rs_Palette        ;points to an array of 256 RGB values
                                            ;  read only!

               WORD      _rs_BitsPerPixel   ;number of bits per pixel (4,8,16,24) (v3)

               WORD      _rs_LeftEdge       ;currently always 0 (v3)
               WORD      _rs_TopEdge        ;currently always 0 (v3) >0 (v5)

               WORD      _rs_VisibleWidth   ;currently same as _rs_Width (v3)
               WORD      _rs_VisibleHeight  ;currently same as _rs_Height (v3)

               LABEL     _rs_PUBSIZE        ;never use this!
;---------------------------------------------------------------------------
; These are the currently available Mode-ID's you need for OpenScreen()
; or GetDefaultMonitorID()

MID_DEFAULT_08 equ       -1                 ;ask for the default 8 bit screen
MID_DEFAULT_16 equ       -2                 ;ask for the default 16 bit screen
MID_DEFAULT_24 equ       -3                 ;ask for the default 24 bit screen

MID_UNKNOWN    equ       0
;---------------------------------------------------------------------------
; the public-part of retina.library

    STRUCTURE _xy_RetinaBase,LIB_SIZE
               APTR      _rb_FirstScreen    ;A pointer to the first screen. This
                                            ;is the visible screen. If no screen
                                            ;is open, _rb_FirstScreen is NULL.
               ULONG     _rb_FrameCount     ;This is incremented each Retina
                                            ;vertical blank interrupt. You may use
                                            ;it to check wether your animation got
                                            ;every frame, but NEVER use it at a
                                            ;clock!
               APTR      _rb_HardInfo       ;NULL, if there is no Retina hardware
                                            ;Non-NULL if there is a hardware. (v2)
                                            ;Starting with (v5) _rb_HardInfo is a 
                                            ;pointer to struct HardInfo (PRIVATE) 
                                            ;or NULL.
                                            ;Do NOT use _rb_HardInfo as a pointer
                                            ;in earlier versions!
               APTR      _rb_BoardAddress   ;the address of the Retina board (v3)
               APTR      _rb_SegmentAddress ;the address of the Retina memory
                                            ;window (v3)
               STRUCT    _rb_private1,12            ;PRIVATE, do not use

               STRUCT    _rb_ScreenList,LH_SIZE     ;all open Retina screens (v3)

               APTR      _rb_SpriteMem              ;PRIVATE, do not use
               STRUCT    _rb_MemList,LH_SIZE        ;PRIVATE, do not use

    LABEL   _rb_PUBSIZE           ; you should never use this

; subsequent fields in the library base are RETINA PRIVATE
;---------------------------------------------------------------------------
  STRUCTURE __MemNode,MLN_SIZE                      ;PRIVATE, do not use
               APTR      _mn_Memory                 ;PRIVATE, do not use
               LONG      _mn_Size                   ;PRIVATE, do not use
               LABEL     _mn_SIZEOF                 ;PRIVATE, do not use
;---------------------------------------------------------------------------
; You may use this macro to call the functions in retina.library. To avoid
; conflicts with existing functions, they have a slightly unusual name.
CALLRET:     MACRO
               move.l    a6,-(a7)
               movea.l   _RetinaBase(a5),a6
               jsr       _LVORetina_\1(a6)
               movea.l   (a7)+,a6
             ENDM
;---------------------------------------------------------------------------
