Commit fafa11de authored by Jeffrey Lee's avatar Jeffrey Lee

Fix rendering issues in new screen modes. Add basic support for new sprite types.

Detail:
  c/Main, c/PSprite, h/main - Update window background rendering & sprite translation table caching to work properly with new screen modes.
  c/Main, c/Menus, c/PSprite, h/PSprite, h/main - Code to generate description text for sprite colour count now uses new shared function, psprite_get_colours(), which understands the new sprite formats and won't crash horribly if given something unknown.
Admin:
  Tested on BB-xM with new format sprites and new screen modes
  Needs extending to report more info about new format sprites (RGB order, alpha channel, wide mask, etc.) along with relevant editing facilities.
  Part of an implementation of the Extended Framebuffer Format spec:
  http://www.riscosopen.org/wiki/documentation/show/Extended%20Framebuffer%20Format%20Specification


Version 2.15. Tagged as 'Paint-2_15'
parent 8cfa18c5
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "2.14"
Module_Version SETA 214
Module_MajorVersion SETS "2.15"
Module_Version SETA 215
Module_MinorVersion SETS ""
Module_Date SETS "13 Jul 2013"
Module_ApplicationDate SETS "13-Jul-13"
Module_Date SETS "07 Aug 2013"
Module_ApplicationDate SETS "07-Aug-13"
Module_ComponentName SETS "Paint"
Module_ComponentPath SETS "castle/RiscOS/Sources/Apps/Paint"
Module_FullVersion SETS "2.14"
Module_HelpVersion SETS "2.14 (13 Jul 2013)"
Module_FullVersion SETS "2.15"
Module_HelpVersion SETS "2.15 (07 Aug 2013)"
END
/* (2.14)
/* (2.15)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 2.14
#define Module_MajorVersion_CMHG 2.15
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 13 Jul 2013
#define Module_Date_CMHG 07 Aug 2013
#define Module_MajorVersion "2.14"
#define Module_Version 214
#define Module_MajorVersion "2.15"
#define Module_Version 215
#define Module_MinorVersion ""
#define Module_Date "13 Jul 2013"
#define Module_Date "07 Aug 2013"
#define Module_ApplicationDate "13-Jul-13"
#define Module_ApplicationDate "07-Aug-13"
#define Module_ComponentName "Paint"
#define Module_ComponentPath "castle/RiscOS/Sources/Apps/Paint"
#define Module_FullVersion "2.14"
#define Module_HelpVersion "2.14 (13 Jul 2013)"
#define Module_LibraryVersionInfo "2:14"
#define Module_FullVersion "2.15"
#define Module_HelpVersion "2.15 (07 Aug 2013)"
#define Module_LibraryVersionInfo "2:15"
......@@ -71,6 +71,7 @@
#include "Global/CMOS.h"
#include "Global/FileTypes.h"
#include "Global/OsBytes.h"
#include "Global/VduExt.h"
#include "pointer.h"
#include "akbd.h"
......@@ -224,6 +225,7 @@ static void main_clear_background (wimp_redrawstr *rds)
int dummy;
BOOL use_sprite;
BOOL scaled = FALSE;
BOOL use_transtab = FALSE;
char name[NAME_LIMIT + 1];
/* Test tiling disabled in CMOS */
......@@ -241,10 +243,19 @@ static void main_clear_background (wimp_redrawstr *rds)
use_sprite = 0;
base = rombase;
}
if (bbc_vduvar (bbc_Log2BPP) != bbc_modevar (sinfo.mode, bbc_Log2BPP))
int mode_log2bpp = bbc_vduvar (bbc_Log2BPP);
int sprite_log2bpp = bbc_modevar (sinfo.mode, bbc_Log2BPP);
if ((mode_log2bpp != sprite_log2bpp)
|| ((bbc_vduvar (bbc_ModeFlags) ^ bbc_modevar (sinfo.mode, bbc_ModeFlags)) & (ModeFlag_FullPalette | ModeFlag_64k | ModeFlag_DataFormat_Mask))
|| (bbc_vduvar (bbc_NColour) != bbc_modevar (sinfo.mode, bbc_NColour)))
{ scaled = TRUE;
if (wimp_readpixtrans (base, &sid, NULL, transtab) != NULL)
use_sprite = 0;
/* Wimp translation tables only possible for <=8bpp screen and <4bpp sprite. We should probably be asking ColourTrans for a table instead. */
if ((mode_log2bpp < 4) && (sprite_log2bpp < 3))
{
use_transtab = TRUE;
if (wimp_readpixtrans (base, &sid, NULL, transtab) != NULL)
use_sprite = 0;
}
}
}
......@@ -266,7 +277,7 @@ static void main_clear_background (wimp_redrawstr *rds)
{ int x;
for (x = left; x < rds->g.x1; x += sinfo.width)
{ if (scaled)
use_sprite = (sprite_put_scaled (base, &sid, 0, x, top - sinfo.height, NULL, transtab) == NULL);
use_sprite = (sprite_put_scaled (base, &sid, 0, x, top - sinfo.height, NULL, (use_transtab?transtab:NULL)) == NULL);
else
use_sprite = (sprite_put_given (base, &sid, 0, x, top - sinfo.height) == NULL);
if (!use_sprite) break;
......@@ -1596,7 +1607,7 @@ static void main_draw_icon (main_window *window, main_sprite *sprite, int x0, in
}
if (window->data->file.fullinfo)
{ int T;
{
char sizebuf [20];
main_iprintf ((sprite->flags & MSF_SELECTED?(wimp_ISELECTED | wimp_IFILLED):0),
......@@ -1625,14 +1636,12 @@ static void main_draw_icon (main_window *window, main_sprite *sprite, int x0, in
msgs_lookup ("PntW23"),
sinfo.mode);
else
{ char *ncol [] =
{"2", "4", "16", "256", "32k", "16M"};
T = (unsigned) sinfo.mode >> 27;
{
char *ncol = psprite_get_colours(sinfo.mode);
main_iprintf (0,
x0 + 33*main_FILER_TextWidth,
y0 + 2*main_FILER_TextHeight,
msgs_lookup ("PntW24"), ncol [T - 1]);
msgs_lookup ("PntW24"), ncol);
}
(void) os_swix3 (OS_ConvertFixedFileSize, sinfo.size, sizebuf,
......
......@@ -180,12 +180,10 @@ static void display_sprite_info (main_sprite *sprite)
dbox_setnumeric (d, d_Info_Mode, info.mode);
}
else
{ int T = (unsigned) info.mode >> 27;
char *ncol [] =
{"2", "4", "16", "256", "32k", "16M"};
{
char *ncol = psprite_get_colours(info.mode);
dbox_setfield (d, d_Info_Type, msgs_lookup ("PntWC"));
dbox_setfield (d, d_Info_Mode, ncol [T - 1]);
dbox_setfield (d, d_Info_Mode, ncol);
}
dbox_setfield (d, d_Info_Mask, yesno (info.mask));
......
......@@ -62,6 +62,7 @@
#include <math.h>
#include <stddef.h> /*font.h needs it, but not all get it*/
#include <swis.h>
#include "Global/VduExt.h"
#include "bbc.h"
#include "colourtran.h"
......@@ -555,7 +556,7 @@ main_ttab *psprite_ttab_for_sprite (main_sprite *sprite, int dmode,
{ main_ttab *tb = NULL;
int smode, slb_bpp, dlb_bpp, sbpp, dbpp, spal [256 /*no palette can be
larger than this*/], *destpal, spalsize;
larger than this*/], *destpal, spalsize, dncolour, dmodeflags;
os_error *error;
char *msg = NULL; /*this is our error indicator*/
......@@ -566,6 +567,8 @@ main_ttab *psprite_ttab_for_sprite (main_sprite *sprite, int dmode,
smode = psprite_address (sprite)->mode;
slb_bpp = bbc_modevar (smode, bbc_Log2BPP);
dlb_bpp = bbc_modevar (dmode, bbc_Log2BPP);
dncolour = bbc_modevar (dmode, bbc_NColour);
dmodeflags = bbc_modevar (dmode, bbc_ModeFlags);
ftracef3 ("smode 0x%X, slb_bpp %d, dlb_bpp %d\n",
smode, slb_bpp, dlb_bpp);
......@@ -622,7 +625,7 @@ main_ttab *psprite_ttab_for_sprite (main_sprite *sprite, int dmode,
/*If the table already exists, reuse it.*/
ftracef0 ("looking for table\n");
for (tb = tbchain; tb != NULL; tb = tb->link)
if (tb->sbpp == sbpp && tb->dbpp == dbpp && tb->spalsize == spalsize &&
if (tb->smode == smode && tb->dlog2bpp == dlb_bpp && tb->dncolour == dncolour && tb->dmodeflags == dmodeflags && tb->spalsize == spalsize &&
(sbpp <= 8? memcmp (tb->spal, spal, 4 << sbpp) == 0: TRUE) &&
(dbpp <= 8? memcmp (tb->dpal, destpal, 4 << dbpp) == 0: TRUE))
{ tb->refcount++;
......@@ -662,7 +665,7 @@ main_ttab *psprite_ttab_new (main_sprite *sprite, int dmode, int *dpal)
{ main_ttab *tb = NULL;
int smode, slb_bpp, dlb_bpp, sbpp, dbpp, spal [256 /*no palette can
be larger than this*/], *destpal, spalsize;
be larger than this*/], *destpal, spalsize, dncolour, dmodeflags;
os_error *error;
char *msg = NULL; /*this is our error indicator*/
BOOL done_tb = FALSE, done_spal = FALSE, done_dpal = FALSE,
......@@ -690,6 +693,8 @@ main_ttab *psprite_ttab_new (main_sprite *sprite, int dmode, int *dpal)
smode = psprite_address (sprite)->mode;
slb_bpp = bbc_modevar (smode, bbc_Log2BPP);
dlb_bpp = bbc_modevar (dmode, bbc_Log2BPP);
dncolour = bbc_modevar (dmode, bbc_NColour);
dmodeflags = bbc_modevar (dmode, bbc_ModeFlags);
ftracef3 ("smode 0x%X, slb_bpp %d, dlb_bpp %d\n",
smode, slb_bpp, dlb_bpp);
......@@ -753,7 +758,7 @@ main_ttab *psprite_ttab_new (main_sprite *sprite, int dmode, int *dpal)
tb->refcount = 1;
ftracef0 ("Copy the palettes into the block\n");
tb->sbpp = sbpp;
tb->smode = smode;
tb->spalsize = spalsize;
if (sbpp <= 8)
{ if (!flex_alloc ((flex_ptr) &tb->spal, spalsize))
......@@ -768,7 +773,9 @@ main_ttab *psprite_ttab_new (main_sprite *sprite, int dmode, int *dpal)
else
tb->spal = 0;
tb->dbpp = dbpp;
tb->dlog2bpp = dlb_bpp;
tb->dncolour = dncolour;
tb->dmodeflags = dmodeflags;
if (dbpp <= 8)
{ if (!flex_alloc ((flex_ptr) &tb->dpal, 4 << dbpp))
{ tb->dpal = 0;
......@@ -3031,3 +3038,36 @@ void psprite_create_show (main_window *window, BOOL auto_open,
dbox_eventhandler (Create, &Create_Cb, (void *) window);
}
}
char *psprite_get_colours(int mode)
{
int ncolour,modeflags;
ncolour = bbc_modevar(mode, bbc_NColour);
modeflags = bbc_modevar(mode, bbc_ModeFlags);
/* Assuming RGB */
char *ncol;
switch(ncolour)
{
case 1: ncol = "2"; break;
case 3: ncol = "4"; break;
case 15: ncol = "16"; break;
case 63: case 255: ncol = "256"; break;
case 4095: ncol = "4k"; break;
case 65535:
if(modeflags & ModeFlag_64k)
ncol = "64k";
else
ncol = "32k";
break;
case 16777215:
case -1:
ncol = "16M";
break;
default:
ncol = "?";
break;
}
return ncol;
}
......@@ -122,4 +122,6 @@ extern void psprite_create_show (main_window *, BOOL, char *);
extern BOOL psprite_close_createbox (wimp_w);
extern char *psprite_get_colours(int mode);
#endif
......@@ -77,9 +77,9 @@ typedef
{ struct main_ttab *link;
int refcount;
int sbpp, spalsize;
int smode, spalsize;
int *spal;
int dbpp;
int dlog2bpp,dncolour,dmodeflags;
int *dpal; /*If these match, the rest must be the same.*/
int ttab_size;
......
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