;---------------------------------------------------------------------------
;   IFND UTILITY_TAGITEM_I
;                include   utility/tagitem.i
;   ENDC
;---------------------------------------------------------------------------
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   ;CloseMonitor() eines Library-internen Monitors
ALERT_MONITOR_NOT_CLOSED equ   $0122   ;LIB_Expunge und ein Monitor ist noch offen
ALERT_MONITOR_ID_INUSE   equ   $0123   ;interne Monitorliste hat eine ID doppelt
;---------------------------------------------------------------------------
; 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 24 bit
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      ;faster than MODE_RGB (see retina.doc)
RECTMODE_GB_R  equ       3      ;PRIVATE, do not use
RECTMODE_256   equ       4      ;one byte with 256 color lookup
RECTMODE_GB_R0 equ       5      ;PRIVATE, do not use
;---------------------------------------------------------------------------
; 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()
;---------------------------------------------------------------------------
; flag definitions for _nrm_Flags:

 BITDEF MD,DBL,0         ;1 = Double-Scan
 BITDEF MD,LACE,1        ;1 = Interlace
 BITDEF MD,CLKDIV2,2     ;1 = 1/2 Pixelclock benutzen
 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)

ATNT_MODE_8    equ       0                  ; 8 bit with color lookup
ATNT_MODE_15   equ       1                  ;15 bit true color with color lookup
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
ATNT_MODE_16b  equ       6                  ;same as 3, but lookup table bypassed
ATNT_MODE_24b  equ       7                  ;same as 2, but lookup table bypassed

 STRUCTURE __NewRetinaMonitor,0
               LONG      _nrm_MonitorID
               LONG      _nrm_PixelClock
               BYTE      _nrm_AtntMode
               BYTE      _nrm_Flags

               WORD      _nrm_StdWidth
               WORD      _nrm_StdHeight
               WORD      _nrm_MaxWidth
               WORD      _nrm_MaxHeight

               LABEL     _nrm_GroupIDs      ;ein Long, das auf ein Array mit
                                            ;IDs dieser Gruppe zeigt        (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

               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()

; values for RSA_ErrorCode:

ROSERR_NONE         equ  0   ; everything ok or unknown error
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

; 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                    ;does not work if 'out of memory'
 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)

  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
;---
               LONG      _rs_BitMap         ;the screen's address in Retina memory
               LONG      _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

               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)

               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
MID_DEFAULT_16 equ       -2
MID_DEFAULT_24 equ       -3

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!
               ULONG     _rb_HardInfo       ;NULL, if there is no Retina hardware
                                            ;Non-NULL if there is a hardware. Do
                                            ;not assume any special value, it may
                                            ;change in the future! (v2)
               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
;---------------------------------------------------------------------------
