Commit bec3eb90 authored by Jeffrey Lee's avatar Jeffrey Lee
Browse files

OS_SpriteOp 38 fixes & improvements

Detail:
  Sources/SprOp:
  - OS_SpriteOp 38 implementation improved so that it will (almost) always attempt to simplify the sprite mode word (even if not performing any transformation on the data)
  - Also fixed/improved it to evaluate bit 8 of R3 with respect to the output data, not the input. So reducing from 8bpp to 1bpp with bit 8 set will now cause the mask to be discarded if all the source pixels were above the cutoff, instead of the old behaviour which would have only discarded the mask if all source pixels were 255.
  - Fixed bug in ExamineAlpha which meant that the 8bpp mask flag was always being cleared - resulting in problems for most conversions (or if the mask was to be left intact)
Admin:
  Tested on BB-xM


Version 1.58. Tagged as 'SprExtend-1_58'
parent f6ceacd8
......@@ -416,7 +416,7 @@ bpp8 DCD &00000000 ; 0000
; R3 bits 0-7 = cutoff for reduction to binary mask/alpha, or 0 to only
; reduce if no information will be lost (i.e. already
; binary or 4bpp)
; R3 bit 8 = remove mask/alpha if completely unnecesary
; R3 bit 8 = remove mask/alpha if completely unnecessary
; R3 bit 30-31 = 0 -> convert to 1bpp mask. Bits 0-8 relevant.
; 1 -> reserved
; 2 -> convert to 8bpp mask. Bits 0-8 ignored.
......@@ -469,9 +469,11 @@ cra_examine_has1bppalpha * 4
cra_examine_has4bppalpha * 8
cra_examine_has8bppalpha * 16
cra_examine_isbinary * 32
cra_examine_issolid * 64
cra_examine_is4bpp * 128
cra_examine_isbinary * 32 ; All mask pixels are 0 or 255
cra_examine_issolid * 64 ; All mask pixels are 255
cra_examine_is4bpp * 128 ; All mask pixels are X*17
cra_examine_isabovecutoff * 256 ; All mask pixels are >= cutoff value
cra_examine_isabove240 * 512 ; All mask pixels are >= &F0
AND LR, R3, #cra_mode
BIC R3, R3, #cra_mode
......@@ -493,10 +495,10 @@ cra_examine_is4bpp * 128
CMP R4, #0 ; No mask at all?
EORNE LR, R4, #cra_examine_has1bppmask
TSTNE LR, #cra_examine_has1bppmask ; Or already 1bpp mask?
Pull "r1-r11, PC", EQ ; Success! TODO - Convert down to RO 3.5 mode word?
BEQ %FT29 ; Success!
TST R3, #cra_canremove
TSTNE R4, #cra_examine_issolid
TSTNE R4, #cra_examine_issolid+cra_examine_isabovecutoff ; If it's solid, or will be solid after cutoff is taken into consideration, remove it
BEQ %FT12
11
; Remove mask altogether
......@@ -505,17 +507,21 @@ cra_examine_is4bpp * 128
SWI XOS_SpriteOp
Pull "r1-r11, PC", VS
LDR R0, [R2, #spMode]
BIC R0, R0, #&80000000
BL GetNonAlphaEquivalent
STR R0, [R2, #spMode]
Pull "r1-r11, PC"
12
ANDS R3, R3, #cra_cutoff ; If we can only reduce if it's binary
MOVEQ R3, #1 ; Set cutoff to sensible value if it was zero
MOVEQ R3, #255 ; Set cutoff to sensible value if it was zero
TSTEQ R4, #cra_examine_isbinary ; And it's not binary
Pull "r1-r11, PC", EQ ; Then there's nothing we can do
BNE %FT16
; Then there's nothing we can do, except tidy up the mode word a bit
TST R4, #cra_examine_has8bppmask
BNE %FT31 ; Try converting RO 5 to 3.5 with alpha mask
Pull "r1-r11, PC" ; If it wasn't an alpha mask, it must be an alpha channel - and there's nothing we can do simplify the mode word in that case
16
TST R4, #cra_examine_hasalpha
BNE %FT20
; We have an 8bpp mask, so can do an in-place reduction
......@@ -525,7 +531,7 @@ cra_examine_is4bpp * 128
BL TransferTo1bppMask
BL ShrinkAreaR11ToR0
LDR R0, [R2, #spMode]
BIC R0, R0, #&80000000
BL GetNonAlphaEquivalent ; Demote to 3.5 sprite type if possible (may have been RISC OS 5 type but with alpha mask)
STR R0, [R2, #spMode]
Pull "r1-r11, PC"
......@@ -553,6 +559,7 @@ cra_examine_is4bpp * 128
BL TransferTo1bppMask
; Destroy src alpha
BL DestroySrcAlpha
29
; Update sprite mode word
LDR R0, [R2, #spMode]
BL GetNonAlphaEquivalent
......@@ -562,7 +569,7 @@ cra_examine_is4bpp * 128
30
; Convert to 8bpp alpha mask
TST R4, #cra_examine_has8bppmask
Pull "r1-R11, PC", NE ; Already have one
BNE %FT31 ; Already have one
; Create 8bpp alpha mask
Debug so,"Creating 8bpp mask"
LDR R0, [R2, #spMode]
......@@ -632,11 +639,7 @@ cra_examine_is4bpp * 128
SUBS R5, R5, #1
SUB R0, R0, R4 ; Advance dest row ptr
BGE %BT43
; Update sprite mode word
LDR R0, [R2, #spMode]
ORR R0, R0, #&80000000
STR R0, [R2, #spMode]
Pull "r1-r11, PC"
B %BT31
50
; Convert to alpha channel
......@@ -667,10 +670,16 @@ cra_examine_is4bpp * 128
; Convert to 1bpp alpha
Debug so,"Convert to 1bpp alpha"
TST R3, #cra_canremove ; If we can remove
TSTNE R4, #cra_examine_isabovecutoff ; And it was all above the cutoff
BNE %BT11 ; Then get rid of it
ANDS R3, R3, #cra_cutoff ; If we can only reduce if it's binary
MOVEQ R3, #1 ; Set cutoff to sensible value if it was zero
MOVEQ R3, #255 ; Set cutoff to sensible value if it was zero
TSTEQ R4, #cra_examine_isbinary ; And it's not binary
Pull "r1-r11, PC", EQ ; Then there's nothing we can do
STR R0, [R2, #spMode]
LDR R0, [R2, #spImage]
ADD R0, R0, R2
......@@ -713,9 +722,15 @@ cra_examine_is4bpp * 128
60
; Convert to 4bpp alpha
Debug so,"Convert to 4bpp alpha"
TST R3, #cra_cutoff ; If we can only reduce if it's 4bpp
TSTEQ R4, #cra_examine_is4bpp ; And it's not 4bpp
Pull "r1-r11, PC", EQ ; Then there's nothing we can do
TST R3, #cra_canremove ; If we can remove
TSTNE R4, #cra_examine_isabove240 ; And it was all >= &F0
BNE %BT11 ; Then get rid of it
STR R0, [R2, #spMode]
LDR R0, [R2, #spImage]
ADD R0, R0, R2
......@@ -746,6 +761,7 @@ cra_examine_is4bpp * 128
70
; Convert to 8bpp alpha
Debug so,"Convert to 8bpp alpha"
STR R0, [R2, #spMode]
LDR R0, [R2, #spImage]
ADD R0, R0, R2
......@@ -1022,15 +1038,9 @@ TransferTo8bppMask ROUT
; In:
; R2 = sprite
; R3 = cra_* flags word
; Out:
; R4 bit 0: has 1bpp mask
; bit 1: has 8bpp mask
; bit 2: has 1bpp alpha
; bit 3: has 4bpp alpha
; bit 4: has 8bpp alpha
; bit 5: is binary alpha/mask
; bit 6: is fully solid alpha/mask
; bit 7: is 4bpp alpha/mask
; R4 = cra_examine_* flags, or 0 if no mask/alpha
; R6 = mask/alpha width in words
; R7 -> mask/alpha read routine
; R8 = mask/alpha width in bits - 1
......@@ -1061,10 +1071,11 @@ ExamineAlpha ROUT
BL FindMaskWidth
TST R0, #&80000000
ADREQ R7, Get1bppMaskPixel
MOVEQ R4, #cra_examine_has1bppmask + cra_examine_isbinary + cra_examine_issolid + cra_examine_is4bpp
MOVEQ R4, #cra_examine_has1bppmask
ADRNE R7, Get8bppMaskPixel
MOVNE R4, #cra_examine_has8bppmask + cra_examine_isbinary + cra_examine_issolid + cra_examine_is4bpp
MOVNE R4, #cra_examine_has8bppmask
10
ORR R4, R4, #cra_examine_isbinary + cra_examine_issolid + cra_examine_is4bpp + cra_examine_isabovecutoff + cra_examine_isabove240
LDR R6, [R2, #spHeight]
ADD R0, R5, #1 ; Width in words
STR R11, [SP, #11*4]
......@@ -1073,6 +1084,9 @@ ExamineAlpha ROUT
ADD R5, R8, R5, LSL #5 ; Convert to width in bits (-1)
STR R5, [SP, #8*4]
MOV R10, #0
LDRB R3, [SP, #3*4] ; Recover cutoff value
CMP R3, #0
MOVEQ R3, #255 ; Ensure isabovecutoff remaains sensible. 255 chosen so that for reduction to 1bpp it won't matter which order we check isbinary/isabovecutoff.
15
; Load mask/alpha pixel
[ NoARMv5
......@@ -1084,13 +1098,18 @@ ExamineAlpha ROUT
; Examine
CMP R9, #255
BEQ %FT16
CMP R9, R3
BICLT R4, R4, #cra_examine_isabovecutoff
CMP R9, #240
BICLT R4, R4, #cra_examine_isabove240
CMP R9, #0
BICGT R4, R4, #cra_examine_isbinary
BIC R4, R4, #cra_examine_issolid
EOR R9, R9, R9, LSR #4
TST R9, #&F
BICNE R4, R4, #cra_examine_is4bpp
BNE %FT90 ; If it's not 4bpp then we also know it's not binary or solid -> therefore all checks have been performed and we can skip checking the other pixels
TST R4, #cra_examine_isbinary + cra_examine_issolid + cra_examine_is4bpp + cra_examine_isabovecutoff + cra_examine_isabove240
BEQ %FT90 ; If all checks have failed, skip to the end
16
CMP R10, R5
BLE %BT15
......@@ -1098,6 +1117,7 @@ ExamineAlpha ROUT
SUBS R6, R6, #1
MOV R10, #0
BGE %BT15
B %FT90
89
; Get rid of any phantom 8bpp mask
......@@ -1124,17 +1144,17 @@ ExamineAlpha ROUT
LDR R5, [R2, #spWidth]
LDR R8, [R2, #spRBit]
ADD R11, R2, R6
MOVEQ R4, #cra_examine_has8bppalpha + cra_examine_isbinary + cra_examine_issolid + cra_examine_is4bpp
MOVEQ R4, #cra_examine_has8bppalpha
ADREQ R7, Get8bppAlphaPixel
BEQ %BT10
CMP R7, #65536
MOVEQ R4, #cra_examine_has1bppalpha + cra_examine_isbinary + cra_examine_issolid + cra_examine_is4bpp
MOVEQ R4, #cra_examine_has1bppalpha
ADREQ R7, Get1bppAlphaPixel
BEQ %BT10
CMP R7, #4096
BNE %FT95
; 4bpp alpha
MOV R4, #cra_examine_has4bppalpha + cra_examine_isbinary + cra_examine_issolid + cra_examine_is4bpp
MOV R4, #cra_examine_has4bppalpha
ADR R7, Get4bppAlphaPixel
B %BT10
......
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "1.57"
Module_Version SETA 157
Module_MajorVersion SETS "1.58"
Module_Version SETA 158
Module_MinorVersion SETS ""
Module_Date SETS "13 Oct 2013"
Module_ApplicationDate SETS "13-Oct-13"
Module_ComponentName SETS "SprExtend"
Module_ComponentPath SETS "mixed/RiscOS/Sources/Video/Render/SprExtend"
Module_FullVersion SETS "1.57"
Module_HelpVersion SETS "1.57 (13 Oct 2013)"
Module_FullVersion SETS "1.58"
Module_HelpVersion SETS "1.58 (13 Oct 2013)"
END
/* (1.57)
/* (1.58)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 1.57
#define Module_MajorVersion_CMHG 1.58
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 13 Oct 2013
#define Module_MajorVersion "1.57"
#define Module_Version 157
#define Module_MajorVersion "1.58"
#define Module_Version 158
#define Module_MinorVersion ""
#define Module_Date "13 Oct 2013"
......@@ -18,6 +18,6 @@
#define Module_ComponentName "SprExtend"
#define Module_ComponentPath "mixed/RiscOS/Sources/Video/Render/SprExtend"
#define Module_FullVersion "1.57"
#define Module_HelpVersion "1.57 (13 Oct 2013)"
#define Module_LibraryVersionInfo "1:57"
#define Module_FullVersion "1.58"
#define Module_HelpVersion "1.58 (13 Oct 2013)"
#define Module_LibraryVersionInfo "1:58"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment