Commit 3a9a3a2c authored by Jeffrey Lee's avatar Jeffrey Lee

Various bugfixes. Improve sprite info dialog.

Detail:
  - Handling of currently selected foreground & background colour rewritten; colour is now stored as a 'main_colour' struct, in order to allow representation of alpha level, pixel colour/palette index (which must be 4 bytes for things like CMYK) and ECF index (previously encoded as negative colour values). Fixes crashes when editing RISC OS 5 32bpp ARGB sprites. Note that although the alpha level is now stored internally, and tools should mostly respect it, palette/colour picker limitations mean that only 0/255 is available when selecting colours.
  - "Select colour" code rewritten to decode all the new pixel formats correctly; colours_entry() now accepts a sprite mode word instead of a number-of-colours value
  - "Full info" display tweaked to give more information about the mask (now displays no mask, normal mask, alpha mask, alpha channel)
  - Sprite info dialog extended to display lots more information, including OS version compatibility
  - Fix sprite menu to disallow add/remove mask option if the sprite has a RISC OS 5 alpha channel
  - Fix ECF pattern that's used for the background of masked sprites to get black/white colour values from ColourTrans when in >8bpp modes, to ensure correct colours in new RISC OS 5 modes
  - Fix palette window to render ECF patterns correctly - when creating the sprite that shows the ECF pattern in the palette, psprite_setup_ecf() was failing to set its palette due to passing a sprite pointer to ColourTrans but setting the flags as if it was a sprite name
  - Fix sprwindow_redisplay() and sprwindow_invalidate() to refresh the display correctly when in full info mode; was previously assuming only one column of sprites visible
  - Fix sprites with alpha channels to have the mask ECF pattern plotted in the background
  Files changed:
  - Resources/UK/Messages, Resources/UK/Templates,fec, c/Colours, c/Main, c/Menus, c/PSprite, c/SprWindow, c/Tools, h/Colours, h/MenuD, h/PSprite, h/main
Admin:
  Tested on BB-xM
  Amongst others, fixes issue reported on forums with spritefile window not refreshing correctly when in full info display with multiple columns:
  http://www.riscosopen.org/forum/forums/8/topics/2146?page=5#posts-31272


Version 2.16. Tagged as 'Paint-2_16'
parent fafa11de
No preview for this file type
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "2.15"
Module_Version SETA 215
Module_MajorVersion SETS "2.16"
Module_Version SETA 216
Module_MinorVersion SETS ""
Module_Date SETS "07 Aug 2013"
Module_ApplicationDate SETS "07-Aug-13"
Module_Date SETS "27 Mar 2014"
Module_ApplicationDate SETS "27-Mar-14"
Module_ComponentName SETS "Paint"
Module_ComponentPath SETS "castle/RiscOS/Sources/Apps/Paint"
Module_FullVersion SETS "2.15"
Module_HelpVersion SETS "2.15 (07 Aug 2013)"
Module_FullVersion SETS "2.16"
Module_HelpVersion SETS "2.16 (27 Mar 2014)"
END
/* (2.15)
/* (2.16)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 2.15
#define Module_MajorVersion_CMHG 2.16
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 07 Aug 2013
#define Module_Date_CMHG 27 Mar 2014
#define Module_MajorVersion "2.15"
#define Module_Version 215
#define Module_MajorVersion "2.16"
#define Module_Version 216
#define Module_MinorVersion ""
#define Module_Date "07 Aug 2013"
#define Module_Date "27 Mar 2014"
#define Module_ApplicationDate "07-Aug-13"
#define Module_ApplicationDate "27-Mar-14"
#define Module_ComponentName "Paint"
#define Module_ComponentPath "castle/RiscOS/Sources/Apps/Paint"
#define Module_FullVersion "2.15"
#define Module_HelpVersion "2.15 (07 Aug 2013)"
#define Module_LibraryVersionInfo "2:15"
#define Module_FullVersion "2.16"
#define Module_HelpVersion "2.16 (27 Mar 2014)"
#define Module_LibraryVersionInfo "2:16"
......@@ -26,6 +26,7 @@
*/
#include <swis.h>
#include "Global/VduExt.h"
#include "bbc.h"
#include "wimpt.h"
......@@ -46,13 +47,27 @@
int colours_count (main_sprite *sprite)
{ static int N [] = {-1, 1 << 1, 1 << 2, 1 << 4, 1 << 8, 1 << 15, 1 << 24};
{
int mode = psprite_address(sprite)->mode;
int ncolour,modeflags;
ncolour = bbc_modevar(mode, bbc_NColour)+1;
modeflags = bbc_modevar(mode, bbc_ModeFlags);
/* Use similar logic to psprite_get_colours() */
if (modeflags == -1) /* i.e. error */
ncolour = -1;
else if (ncolour == 64)
ncolour = 256;
else if ((ncolour == 65536) && !(modeflags & ModeFlag_64k))
ncolour = 32768;
else if (!ncolour)
ncolour = 1<<24;
ftracef2 ("colours_count (\"%.12s\") -> 0x%X\n",
psprite_address (sprite)->name,
N [bbc_modevar (psprite_address (sprite)->mode, bbc_Log2BPP) + 1]);
ncolour);
return N [bbc_modevar (psprite_address (sprite)->mode, bbc_Log2BPP) + 1];
return ncolour;
}
/**************************************************
......@@ -87,22 +102,26 @@ void colours_set_gcol (int col, int action, int back)
* Set the gcol, doing sprite ECF selection if appropriate *
***********************************************************/
void colours_set_sprite_gcol (int gcol, main_sprite *sprite, int back)
void colours_set_sprite_gcol (main_colour gcol, main_sprite *sprite, int back)
{ ftracef2 ("colours_set_sprite_gcol (%d, ..., %d)\n", gcol, back);
{ ftracef4 ("colours_set_sprite_gcol (0x%08x %d %d, ..., %d)\n", gcol.colour, gcol.alpha, gcol.ecf, back);
if (gcol < 0)
psprite_set_ecf (sprite, -gcol - 1, back);
else if (colours_count (sprite) != 256 || psprite_hastruecolpal (sprite))
{ /*Deep sprite - just use OS_SetColour.*/
ftracef2 ("OS_SetColour (%d, %d)\n",
toolwindow_current_mode | back << 4, gcol);
os_swix2 (OS_SetColour, toolwindow_current_mode | back << 4, gcol);
}
if (gcol.ecf)
psprite_set_ecf (sprite, gcol.colour, back);
else
colours_set_gcol (gcol, toolwindow_current_mode, back);
{
int col = colours_pack_alpha(sprite, gcol);
if (colours_count (sprite) != 256 || psprite_hastruecolpal (sprite))
{ /*Deep sprite - just use OS_SetColour.*/
ftracef2 ("OS_SetColour (%d, %d)\n",
toolwindow_current_mode | back << 4, col);
os_swix2 (OS_SetColour, toolwindow_current_mode | back << 4, col);
}
else
colours_set_gcol (col, toolwindow_current_mode, back);
}
ftracef1 ("set gcol 0x%X\n", gcol);
ftracef3 ("set gcol 0x%X %d %d\n", gcol.colour, gcol.alpha, gcol.ecf);
}
/**********************************************************************
......@@ -242,7 +261,14 @@ void colours_event_handler (wimp_eventstr *e, void *handle)
/*If this is the selected colour, border is white, otherwise
black.*/
wimpt_noerr (wimp_setcolour (sprite->gcol == (!ECF? i: -ECF)?
BOOL selected;
if (ECF)
selected = sprite->gcol.ecf && (sprite->gcol.colour == ECF-1);
else if(i == nc)
selected = !sprite->gcol.ecf && !sprite->gcol.alpha;
else
selected = !sprite->gcol.ecf && sprite->gcol.alpha && (sprite->gcol.colour == i);
wimpt_noerr (wimp_setcolour (selected?
0: 7));
bbc_rectangle (x, y, coloursize - (1 << x_eig),
coloursize - (1 << y_eig));
......@@ -251,8 +277,7 @@ void colours_event_handler (wimp_eventstr *e, void *handle)
if
( coloursize == colours_SIZE
#if !TRACE
&& (sprite->gcol == (!ECF? i: -ECF) /*||
sprite->gcol2 == (!ECF? i: -ECF)*/)
&& selected
#endif
)
{ unsigned int fg, bg;
......@@ -337,11 +362,13 @@ void colours_event_handler (wimp_eventstr *e, void *handle)
if (e->data.but.m.bbits & (wimp_BRIGHT | wimp_BLEFT))
{ wimp_wstate whereisit;
wimp_redrawstr rds;
int x, y, oldgcol, newgcol, ncols, ncs, perrow;
int x, y, ncols, ncs, perrow;
main_colour oldgcol,newgcol;
BOOL mask = psprite_hasmask(sprite);
wimpt_noerr (wimp_get_wind_state (sprite->colourhandle, &whereisit));
ncs = colours_count (sprite);
if (!psprite_hasmask (sprite)) ncs--;
if (!mask) ncs--;
ncols = ncs;
for (x=0; x<4; x++) if (sprite->ECFs[x].sarea != NULL) ncols++;
perrow = ncols > 20 ? 16 : 4;
......@@ -355,22 +382,30 @@ void colours_event_handler (wimp_eventstr *e, void *handle)
if (x>=perrow) break;
y /= coloursize;
newgcol = y*perrow + x;
newgcol.colour = y*perrow + x;
newgcol.alpha = 255;
newgcol.ecf = FALSE;
oldgcol = e->data.but.m.bbits & wimp_BLEFT ? sprite->gcol : sprite->gcol2;
if (newgcol > ncols) break;
if (newgcol.colour > ncols) break;
if (newgcol > ncs)
{ int ECF, n = newgcol - ncs;
if (newgcol.colour > ncs)
{ int ECF, n = newgcol.colour - ncs;
for (ECF = 0; n; ECF++)
if (sprite->ECFs [ECF].sarea != NULL)
n--;
newgcol = -ECF;
newgcol.colour = ECF-1;
newgcol.ecf = TRUE;
}
else if((newgcol.colour == ncs) && mask)
{
newgcol.colour = 0;
newgcol.alpha = 0;
}
ftracef1 ("Colour %d\n", newgcol /*sprite->gcol*/);
ftracef2 ("Colour %d %d\n", newgcol.colour, newgcol.ecf /*sprite->gcol*/);
rds.w = sprite->colourhandle;
rds.box.x0 = x*coloursize /*x*coloursize*/;
rds.box.y0 = -(y + 1)*coloursize /*rds.box.y1 - coloursize*/;
......@@ -379,18 +414,20 @@ void colours_event_handler (wimp_eventstr *e, void *handle)
rds.box.y1 =-y*coloursize /*-y*coloursize*/;
wimpt_noerr (wimp_force_redraw (&rds)); /* of new colour */
if (oldgcol < 0)
if (oldgcol.ecf)
{ int ECFno, n = 0;
for (ECFno = 0; ECFno < -oldgcol; ECFno++)
for (ECFno = 0; ECFno < oldgcol.colour; ECFno++)
if (sprite->ECFs[ECFno].sarea != NULL) n++;
oldgcol = n + ncs;
oldgcol.colour = n + ncs + 1;
}
else if(!oldgcol.alpha)
oldgcol.colour = ncs;
rds.w = sprite->colourhandle;
x = oldgcol%perrow;
y = oldgcol/perrow;
x = oldgcol.colour%perrow;
y = oldgcol.colour/perrow;
rds.box.x0 = x*coloursize /*x*coloursize*/;
rds.box.y0 =- (y + 1)*coloursize /*rds.box.y1 - coloursize*/;
......@@ -529,9 +566,9 @@ void colours_create_window (main_sprite *sprite)
colourpicker_dialogue dialogue;
dialogue.flags =
(psprite_hasmask (sprite)?
((psprite_transparency_type (sprite) != transparency_type_none)?
colourpicker_DIALOGUE_OFFERS_TRANSPARENT: 0) |
(sprite->gcol == nc? colourpicker_DIALOGUE_TRANSPARENT: 0) |
((!sprite->gcol.alpha)? colourpicker_DIALOGUE_TRANSPARENT: 0) |
(colourpicker_DIALOGUE_TYPE_CLICK << colourpicker_DIALOGUE_TYPE_SHIFT);
ftracef1 ("flags set to 0x%X\n", dialogue.flags);
dialogue.title = sprite->colourtitle;
......@@ -541,8 +578,8 @@ void colours_create_window (main_sprite *sprite)
dialogue.visible.y1 = sprite_w_state.o.box.y1;
dialogue.xscroll = 0;
dialogue.yscroll = 0;
dialogue.colour = sprite->gcol == nc? 0:
colours_entry (nc, sprite->gcol);
dialogue.colour = (!sprite->gcol.alpha)? 0:
colours_entry (psprite_address(sprite)->mode, sprite->gcol.colour);
dialogue.size = 0;
if (wimpt_complain (os_swix2r (ColourPicker_OpenDialogue,
......@@ -599,29 +636,158 @@ void colours_create_window (main_sprite *sprite)
}
}
int colours_entry (int nc, int colour)
int colours_entry (int mode, int colour)
{ /*Returns the palette entry corresponding to the given colour number.*/
{ /*Returns the &BBGGRRxx palette entry corresponding to the given colour number.*/
ftracef0 ("colours_entry\n");
switch (nc)
{ case 1 << 15:
{ int
r = colour & 0x1F,
g = (colour & 0x3E0) >> 5,
b = (colour & 0x7C00) >> 10;
return 0xFF*r/0x1F << 8 | 0xFF*g/0x1F << 16 | 0xFF*b/0x1F << 24;
}
break;
case 1 << 24:
return colour << 8;
break;
int ncolour,modeflags;
ncolour = bbc_modevar(mode, bbc_NColour);
modeflags = bbc_modevar(mode, bbc_ModeFlags);
int r,g,b;
/* Assume RGB colourspace */
switch (ncolour)
{ case 4095:
r = (colour & 0xF)*0x11;
g = ((colour>>4) & 0xF)*0x11;
b = ((colour>>8) & 0xF)*0x11;
break;
case 65535:
r = 255*(colour & 0x1F)/31;
if (modeflags & ModeFlag_64k)
{
g = 255*((colour & 0x7E0)>>5)/63;
colour = colour>>11;
}
else
{
g = 255*((colour & 0x3E0)>>5)/31;
colour = colour>>10;
}
b = 255*(colour & 0x1F)/31;
break;
case 1677215:
case -1:
r = colour & 0xff;
g = (colour>>8) & 0xff;
b = (colour>>16) & 0xff;
break;
default:
ftracef0 ("INVALID SPRITE MODE!!!\n");
return 0;
break;
}
if(modeflags & ModeFlag_DataFormatSub_RGB)
{
return (r<<24) | (g<<16) | (b<<8);
}
else
{
return (r<<8) | (g<<16) | (b<<24);
}
}
int colours_pack_alpha(main_sprite *sprite, main_colour gcol)
{
int mode = psprite_address(sprite)->mode;
int modeflags = bbc_modevar(mode, bbc_ModeFlags);
int colour = gcol.colour;
if ((modeflags != -1) && (modeflags & ModeFlag_DataFormatSub_Alpha))
{
int ncolour = bbc_modevar(mode, bbc_NColour);
if(ncolour == 4095)
colour |= (gcol.alpha & 0xf0)<<8;
else if(ncolour == 65535)
colour |= (gcol.alpha & 0x80)<<8;
else
colour |= gcol.alpha<<24;
}
return colour;
}
sprite_colour colours_pack_colour(main_sprite *sprite, main_colour gcol)
{
sprite_colour colour;
if (colours_count(sprite) != 256 || psprite_hastruecolpal (sprite))
{
colour.colour = colours_pack_alpha(sprite,gcol);
colour.tint = 0;
}
else
{
colour.colour = colours_gcol_ttab [gcol.colour >> 2];
colour.tint = (gcol.colour & 3) << 6;
}
return colour;
}
main_colour colours_unpack_colour(main_sprite *sprite, sprite_colour colour)
{
main_colour gcol;
gcol.alpha = 255;
gcol.ecf = FALSE;
int nc = colours_count(sprite);
if (nc != 256 || psprite_hastruecolpal (sprite))
{
gcol.colour = colour.colour;
int modeflags = bbc_modevar(psprite_address(sprite)->mode, bbc_ModeFlags);
if((modeflags != -1) && (modeflags & ModeFlag_DataFormatSub_Alpha))
{
if(nc == 4096)
{
gcol.alpha = (gcol.colour>>12) * 0x11;
gcol.colour &= ~0xf000;
}
else if(nc == 32768)
{
if(!(gcol.colour & 32768))
gcol.alpha = 0;
gcol.colour &= ~32768;
}
else
{
gcol.alpha = gcol.colour >> 24;
gcol.colour &= ~0xff000000;
}
}
}
else
{
gcol.colour =
colours_gcol_ttab [colours_gcol_ttab [colours_gcol_ttab
[colour.colour]]] << 2 | colour.tint >> 6;
}
return gcol;
}
sprite_maskstate colours_pack_mask(main_sprite *sprite, main_colour gcol)
{
switch(psprite_transparency_type(sprite))
{
case transparency_type_onoffmask:
return (gcol.alpha?sprite_masksolid:sprite_masktransparent);
case transparency_type_alphamask:
return (sprite_maskstate) gcol.alpha;
}
return sprite_masksolid;
}
main_colour colours_unpack_colour2(main_sprite *sprite, sprite_colour colour, sprite_maskstate mask)
{
main_colour gcol = colours_unpack_colour(sprite,colour);
switch(psprite_transparency_type(sprite))
{
case transparency_type_onoffmask:
gcol.alpha = (mask==sprite_masksolid?255:0);
break;
case transparency_type_alphamask:
gcol.alpha = mask;
break;
}
return gcol;
}
......@@ -1652,11 +1652,18 @@ static void main_draw_icon (main_window *window, main_sprite *sprite, int x0, in
y0 + 2*main_FILER_TextHeight,
"%s", sizebuf);
static char *masktypes[] =
{
"PntW6", // transparency_type_none
"PntW5", // transparency_type_onoffmask
"PntWD", // transparency_type_alphamask
"PntWE", // transparency_type_alphachannel
};
main_iprintf (0, x0 + 20*main_FILER_TextWidth,
y0 + main_FILER_TextHeight,
"%s, %s", msgs_lookup (sinfo.palette?
sinfo.truepalette? "PntW3a": "PntW3": "PntW4"),
msgs_lookup (sinfo.mask? "PntW5": "PntW6"));
msgs_lookup (masktypes[psprite_transparency_type(sprite)]));
sx = x0 + main_FILER_Border/2;
sy = y0 + main_FILER_Border/2;
......@@ -3194,14 +3201,17 @@ static void Background_Events (wimp_eventstr *e, void *handle)
{ ftracef1 ("Found given picker %s\n", sprite->colourtitle);
if ((e->data.msg.data.words [1] &
colourpicker_COLOUR_TRANSPARENT) != 0)
sprite->gcol = colours_count (sprite);
sprite->gcol.alpha = 0;
else
{ os_swi3r (ColourTrans_ReturnColourNumberForMode,
{
sprite_colour col;
os_swi3r (ColourTrans_ReturnColourNumberForMode,
e->data.msg.data.words [2],
psprite_address (sprite)->mode, 0,
&sprite->gcol, NULL, NULL);
&col.colour, NULL, NULL);
sprite->gcol = colours_unpack_colour(sprite, col);
ftracef2 ("rgb is 0x%X => colour number 0x%X\n",
e->data.msg.data.words [2], sprite->gcol);
e->data.msg.data.words [2], sprite->gcol.colour);
}
}
}
......
......@@ -58,6 +58,8 @@
#include <swis.h>
#include <signal.h>
#include "Global/FileTypes.h"
#include "Global/VduExt.h"
#include "Global/Sprite.h"
#include "bbc.h"
#include "colourmenu.h"
......@@ -169,6 +171,7 @@ static void display_sprite_info (main_sprite *sprite)
{ dbox d;
psprite_info info;
char temp[64];
ftracef0 ("display_sprite_info\n");
psprite_read_full_info (sprite, &info);
......@@ -176,17 +179,124 @@ static void display_sprite_info (main_sprite *sprite)
if ((d = dbox_new ("spriteInfo")) != 0)
{ dbox_setfield (d, d_Info_Name, info.name);
if ((unsigned) info.mode < 256u)
{ dbox_setfield (d, d_Info_Type, msgs_lookup ("PntWB"));
{
dbox_setnumeric (d, d_Info_Mode, info.mode);
}
else
{
char *ncol = psprite_get_colours(info.mode);
dbox_setfield (d, d_Info_Type, msgs_lookup ("PntWC"));
dbox_setfield (d, d_Info_Mode, ncol);
sprintf(temp,"&%08x",info.mode);
dbox_setfield (d, d_Info_Mode, temp);
}
dbox_setnumeric (d, d_Info_Size, info.size);
strcpy(temp,psprite_get_colours(info.mode));
/* Attempt to extract the mode flags manually, so that we can display
somewhat sensible information even if the kernel doesn't recognise the
format. E.g. prior to full CMYK support in the kernel+SpriteExtend,
RISC OS 5 will report CMYK sprites as being RGB */
int modeflags;
if(((unsigned) info.mode) < 256u)
{
/* Mode number - ask the OS, just in case something special */
modeflags = bbc_modevar(info.mode,bbc_ModeFlags);
}
else if(((info.mode>>27) & 15) == SpriteType_RISCOS5)
{
/* RISC OS 5 mode word */
modeflags = info.mode & 0xff00;
}
else
{
/* RISC OS 3.5 mode word */
if(((info.mode>>27) & 15) == SpriteType_CMYK)
modeflags = ModeFlag_DataFormatFamily_Misc;
else
modeflags = 0;
}
unsigned int colours = colours_count(sprite);
if((modeflags != -1) && ((colours > 256) || (modeflags & ModeFlag_DataFormat_Mask)))
{
switch(modeflags & ModeFlag_DataFormatFamily_Mask)
{
case ModeFlag_DataFormatFamily_RGB:
if(modeflags & ModeFlag_DataFormatSub_Alpha)
strcat(temp," A");
else
strcat(temp," ");
if(modeflags & ModeFlag_DataFormatSub_RGB)
strcat(temp,"RGB");
else
strcat(temp,"BGR");
break;
case ModeFlag_DataFormatFamily_Misc:
if(!(modeflags & ModeFlag_DataFormatSub_Mask))
strcat(temp," CMYK");
break;
case ModeFlag_DataFormatFamily_YCbCr:
strcat(temp," YCbCr"); /* Skip giving sub-format info */
break;
}
}
dbox_setfield (d, d_Info_Colours, temp);
if((((unsigned) info.mode) >= 256u) && (((info.mode >> 27) & 15) != 15))
{
/* Looks like RISC OS 3.5 mode word, extract DPI manually, in case there's something unusual there */
int xdpi = (info.mode >> 1) & 8191;
int ydpi = (info.mode >> 14) & 8191;
sprintf(temp,msgs_lookup("PntGF"),(float)xdpi,(float)ydpi);
dbox_setfield(d, d_Info_DPI, temp);
}
else
{
int xeig = bbc_modevar(info.mode,bbc_XEigFactor);
int yeig = bbc_modevar(info.mode,bbc_YEigFactor);
if((xeig == -1) || (yeig == -1))
dbox_setfield(d, d_Info_DPI, "?");
else
{
sprintf(temp,msgs_lookup("PntGF"),180.0f/(1<<xeig),180.0f/(1<<yeig));
dbox_setfield(d, d_Info_DPI, temp);
}
}
transparency_type transparency = psprite_transparency_type(sprite);
static char *masktypes[] =
{
"PntG2", "PntG4", // transparency_type_none
"PntG2", "PntG3", // transparency_type_onoffmask
"PntG2", "PntGI", // transparency_type_alphamask
"PntG7", "PntGE", // transparency_type_alphachannel
};
dbox_setfield (d, d_Info_MaskType, msgs_lookup(masktypes[transparency*2]));
int alphabits=8;
if(transparency == transparency_type_alphachannel)
{
switch(colours)
{
case 4096:
alphabits = 4;
break;
case 32768:
alphabits = 1;
break;
}
}
sprintf(temp,msgs_lookup(masktypes[transparency*2+1]),alphabits);
dbox_setfield (d, d_Info_MaskSize, temp);
dbox_setfield (d, d_Info_Mask, yesno (info.mask));
if ((colours == 256) && info.palette)
{
if (info.truepalette)
dbox_setfield (d, d_Info_Palette, msgs_lookup("PntGH"));
else
dbox_setfield (d, d_Info_Palette, msgs_lookup("PntGD"));
}
else
dbox_setfield (d, d_Info_Palette, yesno(info.palette));
if (info.width == -1)
dbox_setfield (d, d_Info_Width, "?");
......@@ -198,8 +308,107 @@ static void display_sprite_info (main_sprite *sprite)
else
dbox_setnumeric (d, d_Info_Height, info.height);
dbox_setfield (d, d_Info_Palette, yesno (info.palette));
dbox_setnumeric (d, d_Info_Size, info.size);
int type = (info.mode>>27) & 31;
if(type && !(info.mode & 1))
type = -1;
switch(type)
{
case SpriteType_Old:
/* Arc */
if(((unsigned) info.mode) >= 128u)
dbox_setfield(d, d_Info_Compat, "?"); /* Shadow bit set or not mode number */
else
dbox_setfield(d, d_Info_Compat, msgs_lookup("PntG8"));
break;
case SpriteType_New1bpp:
case SpriteType_New2bpp:
case SpriteType_New4bpp:
case SpriteType_New8bpp:
case SpriteType_New16bpp:
case SpriteType_New32bpp:
/* 3.5 */
dbox_setfield(d, d_Info_Compat, msgs_lookup("PntG9"));
break;
case SpriteType_CMYK:
case 16+SpriteType_CMYK:
/* CMYK -> Select */
dbox_setfield(d, d_Info_Compat, msgs_lookup("PntGC"));
break;
case 16+SpriteType_New1bpp:
case 16+SpriteType_New2bpp:
case 16+SpriteType_New4bpp:
case 16+SpriteType_New8bpp:
case 16+SpriteType_New16bpp:
case 16+SpriteType_New32bpp:
/* Alpha masks -> Select, 5.21 */
dbox_setfield(d, d_Info_Compat, msgs_lookup("PntGG"));
break;
case SpriteType_New64K:
case 16+SpriteType_New64K:
/* 64K -> RISC OS 5.21, 6 */
dbox_setfield(d, d_Info_Compat, msgs_lookup("PntGB"));
break;
case SpriteType_RISCOS5:
case 16+SpriteType_RISCOS5:
/* RISC OS 5 types */
/* However, only list types which are known to be fully supported */
type = (info.mode>>20) & 127;
if((info.mode & 0xf000f) != 1)
type = -1;
switch(type)
{
case SpriteType_New1bpp:
case SpriteType_New2bpp:
case SpriteType_New4bpp:
case SpriteType_New8bpp:
/* Nonstandard but valid: palettised sprite with RO 5 mode word */
if(!(info.mode & 0xff00)) /* Can't have any mode flags set */
{
dbox_setfield(d, d_Info_Compat, msgs_lookup("PntGA"));
break;
}
dbox_setfield(d, d_Info_Compat, "?");
break;
case SpriteType_New16bpp:
case SpriteType_New32bpp:
case SpriteType_New4K:
/* RGB flag possible. Alpha flag only possible if no mask. */
if(!(info.mode & 0x3f00)
&& !((info.mode & ModeFlag_DataFormatSub_Alpha) && (info.mask || (info.mode & 0x80000000))))
{
dbox_setfield(d, d_Info_Compat, msgs_lookup("PntGA"));
break;
}
dbox_setfield(d, d_Info_Compat, "?");
break;
case SpriteType_New64K:
/* Only RGB flag possible */
if(!(info.mode & 0xbf00))
{
dbox_setfield(d, d_Info_Compat, msgs_lookup("PntGA"));
break;
}
dbox_setfield(d, d_Info_Compat, "?");
break;
case SpriteType_CMYK:
/* Nonstandard but valid. Make sure mode flags agree with colourspace. */ if((info.mode & 0xff00) == 0x1000)
{
dbox_setfield(d, d_Info_Compat, msgs_lookup("PntGA"));
break;
}
dbox_setfield(d, d_Info_Compat, "?");
break;
default:
/* Not defined or not fully supported yet */
dbox_setfield(d, d_Info_Compat, "?");
break;
}
break;
default:
/* Not defined or not fully supported yet */
dbox_setfield(d, d_Info_Compat, "?");
break;
}
dbox_show (d);
dbox_raw_eventhandler (d, &help_dboxrawevents, (void *) "PntHA");
......@@ -280,8 +489,12 @@ void menus_sprite_new (main_window *window, BOOL hack_palette)