Commit 0d41cfbb authored by Robert Sprowson's avatar Robert Sprowson

Add support for type 15 (extended type) and 16 (4k colour) sprites

Sprite type 16 is now accepted as an input format, by defining the appropriate 4:4:4 colour lookup tables.
Type 15 class RGB is handled too with 1/2/4/8/12/15/16/32bpp sprites with and without RGB/BGR reversal.
Other changes:
Tighten up the check for BTPC files, it turns out BTPC 5 also exists but has an incompatible format, so rather than trying to decode them and fail, fail early.
Mention the return code in Documents/CmdBasUse.
Change real variable 'rgb' to integer since it's only holding a flag.

Tested with a variety of special sprites, and a BTPC 5 file.

Version 1.56. Tagged as 'ChangeFSI-1_56'
parent 41d2f57d
......@@ -233,6 +233,10 @@ For command line or BASIC library use, the variable ChangeFSI$Dir must be
set to the full pathname of the !ChangeFSI application, or certain
operations may fail.
For command line use, if a fatal error occurs during processing the error
message is captured in ChangeFSI$ReturnCode. This variable is cleared (unset)
if the requested operation completed successfully.
By default ChangeFSI uses a 128K cache to speed processing; in particular,
JPEG files that fit inside the cache will be read much more quickly. You can
change the size of this cache by setting the variable ChangeFSI$Cache. For
......
......@@ -13,7 +13,7 @@ Summary of formats
Input formats
-------------
RISC OS sprites 1, 2, 4, 8 bits per pixel -
and new format 15, 16, 32 bits per pixel
and new format 12, 15, 16, 32 bits per pixel
ArVis 15-bit HIP + LOP sprites
Watford digitiser pictures, 512×256, 64 greys -
and triple red, green, blue separations
......@@ -101,7 +101,7 @@ the RISC OS Programmer's Reference Manual.
The new RISC OS sprite format
·····························
Contains 1, 2, 4, 8, 15, 16 or 32 bits per pixel.
Contains 1, 2, 4, 8, 12, 15, 16 or 32 bits per pixel.
Recognised by file type FF9.
......@@ -690,7 +690,7 @@ Kodak RGB images, 24 bits per pixel
BTPC 4.1 images
---------------
Recognised by "btpc" at the start of the file.
Recognised by "btpc 4." at the start of the file.
Binary tree predictive coding is used to achieve a signal to noise ratio
better than that achieved with a JPEG algorithm, and in less time too.
......@@ -721,7 +721,7 @@ Table summarising the formats
=============================
RISC OS sprites 1, 2, 4, 8 bits per pixel [file type FF9]
and new format 15, 16, 32 bits per pixel
and new format 12, 15, 16, 32 bits per pixel
ArVis 15 bit HIP.+LOP. sprites [file type FF9 named HIP.]
Watford digitiser pictures 512x256y64g [file type DFA]
and triple red, green, blue seperations [directory of r,g,b DFA]
......@@ -776,7 +776,7 @@ PC EGA .DSP images 640x350y16c [named dsp. OR /DSP]
Alpiar 36 bit per pixel [ALPIAR12 at start of file]
Alpiar 48 bit per pixel [ALPIAR16 at start of file]
Kodak RGB images, 24 bits per pixel [named /RGB]
BTPC file [bptc at start of file]
BTPC file [bptc 4. at start of file]
Portable network graphics [8 byte signature at start of file]
Wireless application protocol bitmap [0,0 in file AND (file type F8F
OR named /WBMP)]
/* (1.55)
/* (1.56)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 1.55
#define Module_MajorVersion_CMHG 1.56
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 06 Oct 2015
#define Module_MajorVersion "1.55"
#define Module_Version 155
#define Module_MajorVersion "1.56"
#define Module_Version 156
#define Module_MinorVersion ""
#define Module_Date "06 Oct 2015"
......@@ -18,6 +18,6 @@
#define Module_ComponentName "ChangeFSI"
#define Module_ComponentPath "mixed/RiscOS/Sources/Apps/ChangeFSI"
#define Module_FullVersion "1.55"
#define Module_HelpVersion "1.55 (06 Oct 2015)"
#define Module_LibraryVersionInfo "1:55"
#define Module_FullVersion "1.56"
#define Module_HelpVersion "1.56 (06 Oct 2015)"
#define Module_LibraryVersionInfo "1:56"
......@@ -1846,7 +1846,7 @@ DEF FNChangeFSI(A$,spritearea%,workspace%,worklimit%,oksave%,okinfo%,RETURN ram%
ENDIF
ENDIF
IF flag=-1 THEN
IF LEFT$(S$,5)="btpc " THEN
IF LEFT$(S$,7)="btpc 4." THEN
CLOSE#c%
c%=0
PROCsubtask("<ChangeFSI$Dir>.btpc "+s$+" <Wimp$Scrap>")
......@@ -2000,7 +2000,26 @@ DEF FNChangeFSI(A$,spritearea%,workspace%,worklimit%,oksave%,okinfo%,RETURN ram%
info$="RISC OS sprite, "+s$+"mode "+STR$sm+", "+STR$sx%+" by "+STR$sy%+" pixels, "+FNbits(input)
ELSE
REM Is a sprite mode word
CASE (sm>>27)AND15 OF
T%=sm>>>27
rgb%=FALSE
IF T%=15 THEN
REM Is an extended sprite mode word
IF (sm AND &780F300F)<>&78000001 THEN
ERROR 42,"Not understood extended RISC OS sprite type"
ELSE
REM Is an RGB family extended sprite mode word
T%=(sm>>20) AND &7F
nx=180>>((sm>>4) AND 3)
ny=180>>((sm>>6) AND 3)
rgb%=(sm AND (1<<14))<>0:REM RGB or BGR ordering?
ENDIF
ELSE
REM Is a RISC OS 3.50 mode word
T%=T% AND15:REM Knock out the wide alpha channel mask bit
nx=(sm>>1) AND &1fff
ny=(sm>>14) AND &1fff
ENDIF
CASE T% OF
WHEN 1
bpp%=1
r$="FN8"
......@@ -2027,7 +2046,7 @@ DEF FNChangeFSI(A$,spritearea%,workspace%,worklimit%,oksave%,okinfo%,RETURN ram%
ENDIF
ENDIF
WHEN 5
bpp%=16
bpp%=15
r$="FN16"
DIM rpal%(255),gpal%(255)
FOR C%=0 TO 31
......@@ -2035,9 +2054,10 @@ DEF FNChangeFSI(A$,spritearea%,workspace%,worklimit%,oksave%,okinfo%,RETURN ram%
NEXT
g%()=r%()
b%()=r%()
IF rgb% THEN rs%=16:bs%=0 ELSE rs%=0:bs%=16
FOR C%=0 TO 255
gpal%(C%)=(C%>>5)<<8 OR (C% AND 31)
rpal%(C%)=((C%>>2) AND 31)<<16 OR (C% AND 3)<<11
gpal%(C%)=(C%>>5)<<8 OR ((C% AND 31)<<rs%)
rpal%(C%)=(((C%>>2) AND 31)<<bs%) OR (C% AND 3)<<11
NEXT
s$="32k colours, ":REM 15bpp 5:5:5
step24=2
......@@ -2046,12 +2066,14 @@ DEF FNChangeFSI(A$,spritearea%,workspace%,worklimit%,oksave%,okinfo%,RETURN ram%
r$="FN24"
PROCnopal
rbo%=0:gbo%=1:bbo%=2
IF rgb% THEN SWAP bbo%,rbo%
step24=4
WHEN 8
bpp%=24
r$="FN24"
PROCnopal
rbo%=0:gbo%=1:bbo%=2
IF rgb% THEN SWAP bbo%,rbo%
WHEN 10
bpp%=16
r$="FN16"
......@@ -2063,29 +2085,45 @@ DEF FNChangeFSI(A$,spritearea%,workspace%,worklimit%,oksave%,okinfo%,RETURN ram%
g%(C%)=C%/63*F
NEXT
b%()=r%()
IF rgb% THEN rs%=16:bs%=0 ELSE rs%=0:bs%=16
FOR C%=0 TO 255
gpal%(C%)=(C%>>5)<<8 OR (C% AND 31)
rpal%(C%)=((C%>>3) AND 31)<<16 OR (C% AND 7)<<11
gpal%(C%)=(C%>>5)<<8 OR ((C% AND 31)<<rs%)
rpal%(C%)=(((C%>>3) AND 31)<<bs%) OR (C% AND 7)<<11
NEXT
s$="64k colours, ":REM 16bpp 5:6:5
step24=2
WHEN 15
ERROR 42,"Not understood extended RISC OS sprite type"
WHEN 16
bpp%=12
r$="FN16"
DIM rpal%(255),gpal%(255)
FOR C%=0 TO 15
r%(C%)=C%/15*F
NEXT
g%()=r%()
b%()=r%()
IF rgb% THEN rs%=16:bs%=0 ELSE rs%=0:bs%=16
FOR C%=0 TO 255
gpal%(C%)=(C%>>4)<<8 OR ((C% AND 15)<<rs%)
rpal%(C%)=((C% AND 15)<<bs%)
NEXT
s$="4k colours, ":REM 12bpp 4:4:4
step24=2
OTHERWISE
REM Types 0/7/9/11-14 come here
REM Types 0/7/9/11-14/17-127 come here
ERROR 42,"Not understood RISC OS sprite type"
ENDCASE
nx=(sm>>1) AND &1fff
ny=(sm>>14) AND &1fff
IF scale% xdiv%=xdiv%*nx:ydiv%=ydiv%*ny:xmul%=xmul%*90:ymul%=ymul%*90
PTR#c%=F%-16
rowbytes%=(FNW+1)*4
sy%=FNW+1
I%=FNW
sx%=(rowbytes%*8-(31-FNW))/bpp%
IF bpp%<8 THEN B%=bpp% ELSE B%=(bpp%+7) AND NOT 7:REM Storage bpp including non display bits
sx%=(rowbytes%*8-(31-FNW))/B%
info$="RISC OS sprite, "+s$+STR$sx%+" by "+STR$sy%+" pixels, "+FNbits(bpp%)
input=bpp%
info$="RISC OS sprite, "+s$+STR$sx%+" by "+STR$sy%+" pixels, "+FNbits(input)
IF bpp%=32 input=24
IF bpp%=15 input=16
IF bpp%=12 input=16
ENDIF
PTR#c%=st%
cache%= TRUE
......@@ -2649,7 +2687,7 @@ DEF FNChangeFSI(A$,spritearea%,workspace%,worklimit%,oksave%,okinfo%,RETURN ram%
PTR#c%=4
dir%=FNtiff(4)
PTR#c%=dir%
rgb= FALSE
rgb%= FALSE
greyunit=100
planar%=1
fillorder=1
......@@ -2715,7 +2753,7 @@ DEF FNChangeFSI(A$,spritearea%,workspace%,worklimit%,oksave%,okinfo%,RETURN ram%
WHEN 277
sampperpix%=V%
input=quant%*V%
rgb=V%=3
rgb%=V%=3
WHEN 278
striprows%=V%
WHEN 279
......@@ -2823,7 +2861,7 @@ DEF FNChangeFSI(A$,spritearea%,workspace%,worklimit%,oksave%,okinfo%,RETURN ram%
ERROR 42,"Can't do "+FNbits(input)+" TIFF"
ENDCASE
IF planar%=2 rowbytes%=rowbytes%*sampperpix%
IF planar%<>1 AND rgb<>0 ERROR 42,"Can't do this style of TIFF yet" ELSE planar%= FALSE
IF planar%<>1 AND rgb%<>0 ERROR 42,"Can't do this style of TIFF yet" ELSE planar%= FALSE
IF compression<2 THEN
cache%= TRUE
stripptr=-1
......
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