; Copyright 1996 Acorn Computers Ltd
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
;     http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
; > &.Hdr.Sprite

; ***********************************
; ***    C h a n g e   L i s t    ***
; ***********************************

; Date       Name  Description
; ----       ----  -----------
; 22-Sep-87  TMD   Added SwitchOutputToSprite/Mask reason codes
;  8-Oct-87  NDR   Added sprite scaling and colour translation reason codes
;  8-Oct-87  NDR   Moved SwitchOutputToSprite/Mask reason codes to 60,61
;  6-Nov-87  NDR   Added SpriteReason_MergeSprites reason code (35)
; 12-Nov-87  NDR   Changed name from MergeSprites to AppendSprite
; 29-Jan-88  NDR   Added SpriteReason_SetPointerShape
;  2-Feb-88  NDR   Removed SpriteReason_Set/ReadScaleFactors/ColourTranslation
; 17-Feb-88  NDR   Added SpriteReason_ReadVduBlockSize
; 03-Mar-88  TMD   Renamed ReadVduBlockSize as ReadSaveAreaSize
; 11-Oct-88  TMD   Added SpriteReason_RemoveLeftHandWastage
; 13-Sep-89  NDR   Added SpriteReason_PutSpriteTransformed
;                  Added SpriteReason_PlotMaskTransformed
; 28-Nov-89  GJS   Added SpriteReason_InsertDeleteRows
;                  Added SpriteReadon_InsertDeleteColumns
; 30-Jan-91  DDV   Added SpriteReason_CreateRemovePalette
; 28-Aug-92  DDV   Defined new constants about the revised header format
; 11-Mar-93  AMG   Amend the above new constants to reflect reality, and
;                    define the new sprite types
; 16-Jul-93  JSR   MaxSpitePaletteSize put back to 16*8 because 256*8 didn't work
; 28-Sep-93  AMG   Add SpriteReason_PutSpriteTransformedCalibrated, PutSpriteScaledCalibrated
;                    and reserve T=7,T=8 sprites for CC.
; 27-Oct-93  AMG   Add T=9 for JPEG (for WRS).
; 18-Nov-93  AMG   Add SpriteType_Substitute and explanation
; 01-Feb-94  AMG   Correct MaxSpritePaletteSize ( warning! it's no longer an immediate value)
; 27-Sep-94  GPS   Added SpriteReason_CheckSpriteArea (17)
; 25-Oct-94  GPS   Removed SpriteReason_PutSpriteTransformedCalibrated, PutSpriteScaledCalibrated
;                  Added definitions for JPEG SWIs.
; 29-Oct-94  AMcC  Removed definitions for JPEG SWIs (now in Hdr:SprExtend)
;

;
; Reason codes for SWI SpriteOp, passed in R0
;

;SpriteReason_ReportError           * 0
;SpriteReason_ClaimSpace            * 1  ;*SSpace <n>
SpriteReason_ScreenSave             * 2
SpriteReason_ScreenLoad             * 3

SpriteReason_ReadAreaCB             * 8  ;*SInfo
SpriteReason_ClearSprites           * 9  ;*SNew
SpriteReason_LoadSpriteFile         * 10 ;*SLoad <filename>
SpriteReason_MergeSpriteFile        * 11 ;*SMerge <filename>
SpriteReason_SaveSpriteFile         * 12 ;*SSave <filename>
SpriteReason_ReturnName             * 13
SpriteReason_GetSprite              * 14 ;*SGet <n>
SpriteReason_CreateSprite           * 15
SpriteReason_GetSpriteUserCoords    * 16
SpriteReason_CheckSpriteArea        * 17

SpriteReason_SelectSprite           * 24 ;*SChoose <n> [<m>]
SpriteReason_DeleteSprite           * 25 ;*SDelete <n>
SpriteReason_RenameSprite           * 26 ;*SRename
SpriteReason_CopySprite             * 27
SpriteReason_PutSprite              * 28
SpriteReason_CreateMask             * 29
SpriteReason_RemoveMask             * 30
SpriteReason_InsertRow              * 31
SpriteReason_DeleteRow              * 32
SpriteReason_FlipAboutXAxis         * 33
SpriteReason_PutSpriteUserCoords    * 34
SpriteReason_AppendSprite           * 35
SpriteReason_SetPointerShape        * 36
SpriteReason_CreateRemovePalette    * 37
SpriteReason_CreateRemoveAlpha      * 38

SpriteReason_ReadSpriteSize         * 40
SpriteReason_ReadPixelColour        * 41
SpriteReason_WritePixelColour       * 42
SpriteReason_ReadPixelMask          * 43
SpriteReason_WritePixelMask         * 44
SpriteReason_InsertCol              * 45
SpriteReason_DeleteCol              * 46
SpriteReason_FlipAboutYAxis         * 47
SpriteReason_PlotMask               * 48
SpriteReason_PlotMaskUserCoords     * 49

SpriteReason_PlotMaskScaled         * 50
SpriteReason_PaintCharScaled        * 51
SpriteReason_PutSpriteScaled        * 52
SpriteReason_PutSpriteGreyScaled    * 53
SpriteReason_RemoveLeftHandWastage  * 54
SpriteReason_PlotMaskTransformed    * 55
SpriteReason_PutSpriteTransformed   * 56
SpriteReason_InsertDeleteRows       * 57
SpriteReason_InsertDeleteColumns    * 58

SpriteReason_SwitchOutputToSprite   * 60
SpriteReason_SwitchOutputToMask     * 61
SpriteReason_ReadSaveAreaSize       * 62

;SpriteReason_PutSpriteScaledCalibrated        * 63
;SpriteReason_PutSpriteTransformedCalibrated   * 64

SpriteReason_TileSpriteScaled       * 65

SpriteReason_BadReasonCode          * 66


 ^ 0

spNext    # 4  ;  Offset to next sprite
spName    # 12 ;  Sprite name
spWidth   # 4  ;  Width in words-1      (0..639)
spHeight  # 4  ;  Height in scanlines-1 (0..255/511)
spLBit    # 4  ;  First bit used (left end of row)
spRBit    # 4  ;  Last bit used (right end of row)
spImage   # 4  ;  Offset to sprite image
spTrans   # 4  ;  Offset to transparancy mask
spMode    # 4  ;  Mode sprite was defined in
spPalette # 0  ;

; These two map onto the header format used above

sp2Width    * spLBit
sp2Reserved * spRBit

SpriteCBsize * (spPalette-spNext)
SpriteNameSize * (spWidth-spName)
MaxSpritePaletteSize * 256*8

MaxSpriteWidth  * 32768  ;Words ???
MaxSpriteHeight * 32768  ;Rows


 ^ 0

saEnd        # 4 ; Offset to end of sprite area (ie total size)
saNumber     # 4 ; Number of sprites in area
saFirst      # 4 ; Offset to first sprite
saFree       # 4 ; Offset to first free word
saExten      # 0 ;

SpriteAreaCBsize * (saExten-saEnd)

; The RISC OS 3.5 definition of the sprite mode word is:
; Bits 30-27 Sprite type:
;             0 - the word represents a mode number, ie the old world
;             1 - 6  new format as below
;             7 - 15 not assigned
;
; For types >0 the format is:
;
; 31 30--27 26--14 13--01 00
;                          1 - always
;                  <xdpi>    - dots per inch, x
;           <ydpi>           - dots per inch, y
;    <type>                  - type of sprite
; <wm>                       - wide mask (1 => 8 bit alpha, 0 => 1 bit on/off)
;                              (RO Select extension, not in 3.5)
;
; T values allocated so far:
; -
; 0 old format (i.e. just a mode number. <wm> must be zero)
; 1 1bpp
; 2 2bpp
; 3 4bpp
; 4 8bpp
; 5 16bpp 1:5:5:5 TBGR
; 6 32bpp 8:8:8:8 TBGR
; 7 cmyk (no OS support)
; 8 24bpp (no OS support)
; 9 JPEG (no OS support)
; 10 16bpp 5:6:5 TBGR
; 11-14 reserved
; 15 reserved for identifying RISC OS 5 style sprite mode words

; RISC OS 5 introduces another new sprite mode word format, which is:
;
; w111 1ttt tttt 0000 ffff ffff yyxx 0001
;  111 1         0000                0001 - always
;                                 xx      - DPI, x (0=180, 1=90, 2=45, 3=22.5)
;                               yy        - DPI, y (0=180, 1=90, 2=45, 3=22.5)
;                     ffff ffff           - bits 8-15 of ModeFlags
;       ttt tttt                          - sprite type
; w                                       - wide mask flag
;
; Sprite types are:
;
; 0-14 as above, modified by ModeFlags where appropriate
; 15 reserved
; 16 16bpp 4:4:4:4
; 17 4:2:2 YCbCr
; 18 4:2:0 YCbCr
; 19-127 reserved


                    ^ 0
SpriteType_Old      # 1 ; 0   old format
SpriteType_New1bpp  # 1 ; 1   1 bpp
SpriteType_New2bpp  # 1 ; 2   2 bpp
SpriteType_New4bpp  # 1 ; 3   4 bpp
SpriteType_New8bpp  # 1 ; 4   8 bpp
SpriteType_New16bpp # 1 ; 5   16 bpp 1555
SpriteType_New32bpp # 1 ; 6   32 bpp
SpriteType_MAX      * :INDEX: @ ; maximum 3.5 type supported. 64K is an exception.

SpriteType_CMYK     # 1 ; 7   cmyk - no support in OS
SpriteType_New24bpp # 1 ; 8   packed 24bpp - no support in OS
SpriteType_JPEG     # 1 ; 9   JPEG - no support in OS
SpriteType_New64K   # 1 ; 10  16 bpp 565
                    # 4
SpriteType_RISCOS5  # 1 ; 15  New RISC OS 5 sprite mode word
SpriteType_New4K    # 1 ; 16  16 bpp 4444
SpriteType_New422   # 1 ; 17  YCbCr 4:2:2
SpriteType_New420   # 1 ; 18  YCbCr 4:2:0
SpriteType_RO5MAX   * :INDEX: @

; if a Sprite Type >= SpriteType_Max is passed through the kernel (ie one that
; there's no support for) it will treat it as the substitute type instead of
; returning an error. This should make it more painless to pass unsupported
; and undefined types through the kernel

SpriteType_Substitute * SpriteType_New32bpp


        END
