Commit 562bab11 authored by ROOL's avatar ROOL 🤖
Browse files

Brush tool enhancements

Detail:
  A visual brush 'palette' now makes it easy to see the internal shapes or chosen sprite.
  More clear brush tool window layout.
  Adds an opacity slider.
  Tint of a sprite using the currently selected colour using a ColourTrans transfer
  function.
  Use alpha channel sprite as the brush sprite.
  Fix to colours_entry() in Colours.c for 16M colour sprites.

  Notes -
  The non-100% opacity features are disabled if supporting modules are missing/too old.
  Translucent painting is performed into an off screen buffer, then the result merged onto
  the sprite once the mouse is idle.
Admin:
  Submission for Paint bounty.

Version 2.42. Tagged as 'Paint-2_42'
parent f452764e
......@@ -84,12 +84,12 @@ DFILES = \
debug.${APP}.Templates
OBJS = o.colourpanel o.colours o.Export o.main o.menus o.psprite o.sprwindow o.tools o.toolwindow\
o.AltRename o.PaintLib o.CnPDrag o.Clipboard o.Drawfile o.PaintChoice
o.AltRename o.PaintLib o.CnPDrag o.Clipboard o.Drawfile o.PaintChoice o.BrushTransFunc
OBJSZ = oz.colourpanel oz.colours oz.Export oz.main oz.menus oz.psprite oz.sprwindow oz.tools\
oz.toolwindow oz.AltRename oz.PaintLib oz.CnPDrag oz.Clipboard oz.Drawfile oz.PaintChoice
oz.toolwindow oz.AltRename oz.PaintLib oz.CnPDrag oz.Clipboard oz.Drawfile oz.PaintChoice oz.BrushTransFunc
OBJSD = od.colourpanel od.colours od.Export od.ftrace od.guard od.main od.menus\
od.psprite od.sprwindow od.tools od.toolwindow o.m\
od.AltRename od.PaintLib od.CnPDrag od.Clipboard od.Drawfile od.PaintChoice
od.AltRename od.PaintLib od.CnPDrag od.Clipboard od.Drawfile od.PaintChoice od.BrushTransFunc
#
# Rule patterns
......@@ -99,6 +99,8 @@ OBJSD = od.colourpanel od.colours od.Export od.ftrace od.guard od.main od.me
.c.oz:; ${CC} ${CFLAGS} -c ${C_NO_FNAMES} ${C_MODULE} ${C_NO_STKCHK} -o $@ $<
.c.od:; ${CC} ${CFLAGS} -c -DTRACE=1 -g -o $@ $<
.asm.o:; ${AS} ${ASFLAGS} $< $@
.asm.oz:; ${AS} ${ASFLAGS} $< $@
.asm.od:; ${AS} ${ASFLAGS} $< $@
.c.s:; ${CC} ${CFLAGS} -s ${C_NO_FNAMES} $<
#
......
No preview for this file type
......@@ -9,12 +9,12 @@
GBLS Module_ApplicationDate
GBLS Module_HelpVersion
GBLS Module_ComponentName
Module_MajorVersion SETS "2.41"
Module_Version SETA 241
Module_MajorVersion SETS "2.42"
Module_Version SETA 242
Module_MinorVersion SETS ""
Module_Date SETS "12 May 2021"
Module_ApplicationDate SETS "12-May-21"
Module_Date SETS "07 Jul 2021"
Module_ApplicationDate SETS "07-Jul-21"
Module_ComponentName SETS "Paint"
Module_FullVersion SETS "2.41"
Module_HelpVersion SETS "2.41 (12 May 2021)"
Module_FullVersion SETS "2.42"
Module_HelpVersion SETS "2.42 (07 Jul 2021)"
END
/* (2.41)
/* (2.42)
*
* This file is automatically maintained by srccommit, do not edit manually.
*
*/
#define Module_MajorVersion_CMHG 2.41
#define Module_MajorVersion_CMHG 2.42
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 12 May 2021
#define Module_Date_CMHG 07 Jul 2021
#define Module_MajorVersion "2.41"
#define Module_Version 241
#define Module_MajorVersion "2.42"
#define Module_Version 242
#define Module_MinorVersion ""
#define Module_Date "12 May 2021"
#define Module_Date "07 Jul 2021"
#define Module_ApplicationDate "12-May-21"
#define Module_ApplicationDate "07-Jul-21"
#define Module_ComponentName "Paint"
#define Module_FullVersion "2.41"
#define Module_HelpVersion "2.41 (12 May 2021)"
#define Module_LibraryVersionInfo "2:41"
#define Module_FullVersion "2.42"
#define Module_HelpVersion "2.42 (07 Jul 2021)"
#define Module_LibraryVersionInfo "2:42"
; Copyright 2021 RISC OS Open 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.
;
GET Hdr:ListOpts
GET Hdr:Macros
AREA |C$$code|, CODE, READONLY
EXPORT brush_transfunc
; ColourTrans Transfer Function for the Brush Tool
; Entry R0 = palette entry
; R12 = workspace
; Exit R0 = processed palette entry
brush_transfunc
Push "R1-R7"
LDMIA R12,{R1-R4} ; Load our arguments
CMP R1,#2 ; 2 means the colour will be left unchanged
Pull "R1-R7",EQ
MOVEQ PC,R14 ; Exit the function
CMP R1,#1 ; 1 means set all colours from R2 (Shape feature)
MOVEQ R0,R2 ; Just output the supplied colour (and alpha)
Pull "R1-R7",EQ
MOVEQ PC,R14 ; Exit the function
AND R5,R0,#&FF00 ; Copy red to R5
AND R6,R0,#&FF0000 ; Copy green to R6
AND R7,R0,#&FF000000 ; Copy blue to R7
ADD R5,R2,R5,LSR #1 ; Blend 50% with red tint
ADD R6,R3,R6,LSR #1 ; Blend 50% with green tint
ADD R7,R4,R7,LSR #1 ; Blend 50% with blue tint
AND R0,R0,#&FF ; Clear all except source alpha
AND R5,R5,#&FF00 ; Clear all except red
AND R6,R6,#&FF0000 ; Clear all except green
AND R7,R7,#&FF000000 ; Clear all except blue
ADD R0,R0,R5 ; Set final red in output
ADD R0,R0,R6 ; Set final green in output
ADD R0,R0,R7 ; Set final blue in output
Pull "R1-R7"
MOV PC,R14 ; Exit the function
END
......@@ -25,6 +25,7 @@
#include "PaintLib.h"
#include "main.h"
#include "SprWindow.h"
#include "ToolWindow.h"
#include "akbd.h"
static wimp_i rename_icon = -1;
......@@ -99,6 +100,9 @@ static void altrename_renamesprite (main_sprite *sprite, char *newname)
colourpicker_UPDATE_TITLE, sprite->bgcolourdialogue,
&dialogue));
}
/* Check if we just renamed a brush sprite as well */
toolwindow_brush_check_rename (sprite, newname);
}
void altrename_delete (void)
......
......@@ -42,6 +42,8 @@
#include "CnPDrag.h"
#include "Clipboard.h"
#include "Drawfile.h"
#include "ToolWindow.h"
#include "Tools.h"
#include "swis.h"
......@@ -437,6 +439,18 @@ void cnp_drag_poll_response(wimp_eventstr *e)
}
cnp_drag_stop_current ();
}
else if (mouse.w == tools_brushpane_handle)
{ /* Copy data internally to brush pane */
main_sprite *sprite;
main_window *window = current_drag_op.datasource;
for (sprite = window->data->file.sprites; sprite != NULL; sprite = sprite->link)
{ if (sprite->flags & MSF_SELECTED)
{ /* Just set the first sprite as a user brush */
toolwindow_brush_pane_add_sprite (sprite, TRUE);
break;
}
}
}
else
{ /*Final dragging message goes out*/
cnp_drag_message_dragging (mouse);
......
......@@ -1095,6 +1095,58 @@ void colours_create_window (main_sprite *sprite, BOOL for_bg_colour)
}
}
int colours_entry_from_gcol (main_sprite *sprite, BOOL background, BOOL forceBGR)
{ /*Returns the &BBGGRRxx palette entry corresponding to the sprite's currently
selected foreground or background colour. Works in all modes with or without palette.*/
main_colour gcol = background ? sprite->gcol2 : sprite->gcol;
int nc = colours_count (sprite);
int mode = psprite_address (sprite)->mode;
int i = gcol.colour;
int entry;
ftracef0 ("colours_entry_from_gcol\n");
if (gcol.ecf) return 0;
if (nc > 256)
entry = colours_entry (mode, i);
else
{ /* Look in palettes using same logic as the Colours window */
if (psprite_hastruecolpal (sprite))
entry = (&psprite_address (sprite)->mode + 1) [2*i];
else
{ if (psprite_haspal (sprite))
/*Use the brain-damaged palette.*/
entry = (&psprite_address (sprite)->mode + 1) [2*(i & 15)] |
(i & 16) << 11 | (i & 96) << 17 | (i & 128) << 24;
else
{ /*Use the relevant "standard palette."*/
if (nc == 256)
entry = psprite_std_palettes
[sprite->file->use_current_palette? 0: 1]
[3] [i & 15] |
(i & 16) << 11 | (i & 96) << 17 | (i & 128) << 24;
else
entry = psprite_std_palettes
[sprite->file->use_current_palette? 0: 1]
[nc == 2? 0: nc == 4? 1: 2] [i];
/*Copy nybbles.*/
entry |= entry >> 4;
}
}
}
if (forceBGR && (bbc_modevar(mode, bbc_ModeFlags) & ModeFlag_DataFormatSub_RGB))
{ int r = (entry >> 16) & 0xFF00;
int g = (entry & 0xFF0000);
int b = (entry & 0xFF00) << 16;
return r | g | b;
}
ftracef2 ("gcol.colour: %d entry: %x\n", gcol.colour, entry);
return entry;
}
int colours_entry (int mode, int colour)
{ /*Returns the &BBGGRRxx palette entry corresponding to the given colour number.*/
......@@ -1127,7 +1179,7 @@ int colours_entry (int mode, int colour)
}
b = 255*(colour & 0x1F)/31;
break;
case 1677215:
case 16777215:
case -1:
r = colour & 0xff;
g = (colour>>8) & 0xff;
......
......@@ -628,7 +628,7 @@ static void snapshot_happysnapper (int x0, int y0, int x1, int y1)
*/
ftracef0 ("calling psprite_ttab_for_sprite ()\n");
if ((tempsprite.transtab = psprite_ttab_for_sprite (&tempsprite,
-1, (int *) -1)) == NULL)
-1, (int *) -1, 0, 0)) == NULL)
{ error = main_error ("PntEG");
goto finish;
}
......@@ -1289,7 +1289,10 @@ static void delete_file_window (main_window *window)
/* Delete all the pointers in the array backwards (flex faster) */
for (loop=count-1;loop>=0;loop--)
{ /* Also check if it was in use as a brush */
toolwindow_brush_check_deletion (todelete[loop]);
psprite_delete (window, todelete[loop]);
}
ftracef0 ("deleted all sprite blocks\n");
}
......@@ -1792,9 +1795,27 @@ static void main_draw_icon (main_window *window, main_sprite *sprite, int x0, in
}
if (!(sinfo.width == -1 || sinfo.height == -1))
wimpt_noerr (psprite_plot_scaled (sx + rds->box.x0 - rds->scx,
sy + rds->box.y1 - rds->scy, sprite,
&sprite->iconsize, (sprite->flags & MSF_SELECTED?3:0)));
{ main_sprite *translucentlayer = tools_get_layer (sprite);
int mode = (sprite->flags & MSF_SELECTED?3:0);
int x = sx + rds->box.x0 - rds->scx;
int y = sy + rds->box.y1 - rds->scy;
wimpt_noerr (psprite_plot_scaled (x, y, sprite, &sprite->iconsize,
mode));
/* Plot any additional layer (currently only ever 1, used by *
* translucent brushes) on top of the base sprite now */
if (translucentlayer != NULL)
{ main_ttab *oldttab = translucentlayer->transtab;
unsigned char translucency = 255 - (unsigned char)
translucentlayer->gcol.alpha;
/* We may need a different translation table to plot sprite to *
* screen than onto another sprite */
translucentlayer->transtab = tools_get_layer_screen_transtab (sprite);
os_error *err = psprite_plot_scaled_m (x, y, translucentlayer,
&sprite->iconsize, mode, 0, translucency);
translucentlayer->transtab = oldttab;
wimpt_noerr (err);
}
}
}
/* bbox in work area coords */
......@@ -2699,6 +2720,7 @@ static void load_resources (void)
wt.work_free += 128;
load_template (&wt, "toolwind", &tools_tool_template.t);
wt.work_free += 128;
load_template (&wt, "brushpane", &tools_brushpane_template.t);
load_template (&wt, "SpriteFile", &file_template.t);
wt.work_free += 128;
load_template (&wt, "colourpanel", &colourpanel_template.t);
......@@ -2763,7 +2785,7 @@ BOOL main_create_window (wimp_wind *win, wimp_w *h, win_event_handler handler,
}
/* Create a new window. The flag indicates if it to be opened */
static main_window *New_Window (BOOL open)
main_window *main_new_window (BOOL open)
{ main_window *window;
main_file *file;
......@@ -2771,7 +2793,7 @@ static main_window *New_Window (BOOL open)
wimp_openstr open_str;
wimp_w w;
ftracef1 ("New_Window: open %s\n", WHETHER (open));
ftracef1 ("main_new_window: open %s\n", WHETHER (open));
if ((window = m_ALLOC (sizeof (main_window))) == NULL)
{ main_NO_ROOM ("new file window block");
......@@ -2892,7 +2914,7 @@ static void main_iconclick (wimp_i iconno)
iconno = iconno;
ftracef1 ("main_iconclick %d\n", iconno);
if ((wind = New_Window (FALSE)) != NULL)
if ((wind = main_new_window (FALSE)) != NULL)
{ main_set_extent (wind);
main_check_position (wind);
......@@ -2909,7 +2931,7 @@ static void main_iconclick (wimp_i iconno)
static void New_File (char *name)
{ main_window *w = New_Window (TRUE);
{ main_window *w = main_new_window (TRUE);
ftracef0 ("New_File\n");
if (w)
......@@ -2962,7 +2984,7 @@ void main_help_message (char *tag, wimp_eventstr *e)
static void print_file (char *name)
{ main_window *w = New_Window (TRUE);
{ main_window *w = main_new_window (TRUE);
ftracef0 ("print_file\n");
if (w)
......@@ -3123,7 +3145,7 @@ static void Background_Events (wimp_eventstr *e, void *handle)
{ main_window *w;
ftracef1 ("printing file \"%s\"\n", name);
if ((w = New_Window (TRUE)) != NULL)
if ((w = main_new_window (TRUE)) != NULL)
{ int ok;
visdelay_begin ();
......@@ -3192,7 +3214,9 @@ static void Background_Events (wimp_eventstr *e, void *handle)
main_force_redraw (window->handle);
if (toolwindow_current_tool == &tools_brushpaint)
{ if ((error = psprite_free_brush_blocks ()) != NULL)
{ /*Layer used for translucent painting will need recreating*/
tools_delete_layer ();
if ((error = psprite_free_brush_blocks ()) != NULL)
goto changed;
if ((error = psprite_set_brush_colour_translations ()) != NULL)
goto changed;
......@@ -3669,7 +3693,7 @@ int main (int argc, char *argv[])
argc=1; /* ignore bad parameters */
}
else /* must be a filename */
{ main_window *w = New_Window (TRUE);
{ main_window *w = main_new_window (TRUE);
if (w)
{ int ok /*for Norcroft*/;
......
......@@ -505,7 +505,7 @@ void menus_sprite_new (main_window *window, BOOL hack_palette)
if (hack_palette) menus_hack_palette (sprite);
psprite_set_colour (sprite);
psprite_set_brush_translation (sprite);
psprite_set_brush_translation (sprite, FALSE);
}
/*************************************
......@@ -1449,7 +1449,9 @@ static void sprite_palette_has_changed (main_sprite *sprite)
{ ftracef0 ("sprite_palette_has_changed\n");
sprite->artistfriendly = artist_unknown;
psprite_set_colour (sprite);
psprite_set_brush_translation (sprite);
psprite_set_brush_translation (sprite, FALSE);
/*Layer used for translucent painting will need recreating*/
tools_delete_layer ();
sprwindow_redisplay (sprite, NULL);
/*if (sprite->colourhandle != 0)
......@@ -1921,6 +1923,9 @@ void menus_sprite_handler (void *handle, char *hit)
ftracef5 ("menu hit is {%d, %d, %d, %d, %d}\n",
hit [0], hit [1], hit [2], hit [3], hit [4]);
/*First make sure any outstanding layer merge was handled*/
tools_merge_layer_onto (window->data->sprite.sprite);
switch (hit [0])
{ case s_Misc:
switch (hit [1])
......@@ -3050,7 +3055,8 @@ BOOL menus_do_print (main_sprite *sprite)
/*J R C 10th Jan 1994 It does now! So use it!!*/
/*J R C 28th Jan 1994 Now it doesn't again, we use the part of it that
does.*/
if ((sprite->transtab = psprite_ttab_new (sprite, -1, (int *) -1)) == NULL)
if ((sprite->transtab = psprite_ttab_new (sprite, -1, (int *) -1, 0, 0))
== NULL)
{ txt = msgs_lookup ("PntEG");
goto finish;
}
......@@ -3471,6 +3477,9 @@ void menus_file_handler (void *handle, char *hit)
ftracef0 ("Edit delete\n");
/*Check if it was in use as a brush*/
toolwindow_brush_check_deletion (sprite);
/*The next two lines used to be reversed, but it could give a
fatal error. So do it this way*/
wimpt_complain (sprite_delete (sarea, &sid));
......@@ -3592,6 +3601,8 @@ void menus_file_handler (void *handle, char *hit)
colourpicker_UPDATE_TITLE, hit_sprite->bgcolourdialogue,
&dialogue);
}
/*Check if we just renamed a brush sprite as well*/
toolwindow_brush_check_rename (hit_sprite, spritenamebuffer);
}
}
break;
......
......@@ -61,6 +61,7 @@
#include <limits.h>
#include <math.h>
#include <stddef.h> /*font.h needs it, but not all get it*/
#include <stdint.h>
#include <swis.h>
#include "Global/VduExt.h"
......@@ -70,7 +71,6 @@
#include "flex.h"
#include "help.h"
#include "resspr.h"
#include "stdint.h"
#include "visdelay.h"
#include "werr.h"
#include "wimp.h"
......@@ -463,12 +463,23 @@ main_sprite *psprite_new (int offset, int spriteno, main_file *parent)
*/
static void table_new (void *a0, void *a1, int dmode, int *dpal, int flags,
int *size, char **table)
int *workspace, void (*transfunc) (void), int *size, char **table)
{ ftracef0 ("table_new\n");
os_swi6r (ColourTrans_GenerateTable,
a0, a1, dmode, dpal, 0 /*read size*/, flags,
NULL, NULL, NULL, NULL, size, NULL);
{ os_regset regs;
ftracef0 ("table_new\n");
regs.r[0] = (int)(int *)a0;
regs.r[1] = (int)(int *)a1;
regs.r[2] = dmode;
regs.r[3] = (int)(int *)dpal;
regs.r[4] = 0 /*read size*/;
regs.r[5] = flags;
regs.r[6] = (int)workspace;
regs.r[7] = (int)transfunc;
os_swi (ColourTrans_GenerateTable, &regs);
*size = regs.r[4];
ftracef1 ("size %d\n", *size);
if (*size == 0)
......@@ -480,8 +491,8 @@ static void table_new (void *a0, void *a1, int dmode, int *dpal, int flags,
return;
}
os_swi6 (ColourTrans_GenerateTable, a0, a1, dmode, dpal, *table,
flags);
regs.r[4] = (int)*table;
os_swi (ColourTrans_GenerateTable, &regs);
}
}
......@@ -561,14 +572,17 @@ static int Current_Palette [256];
static void Trace_Ttab (main_ttab *ttab)
{ int i;
if (ttab == NULL)
{ ftracef0 ("ERROR Trace_Ttab: ttab is NULL!\n");
return;
}
ftracef1 ("Trace_Ttab: refcount %d table1 {", ttab->refcount);
for (i = 0; i < ttab->ttab_size; i++)
ftracef (NULL, 0, i == 0? "%d": ", %d", ttab->table [i]);
ftracef (NULL, 0, "} sbpp %d, table2 {", ttab->sbpp);
ftracef (NULL, 0, "} smode %d, table2 {", ttab->smode);
for (i = 0; i < ttab->ttab2_size; i++)
ftracef (NULL, 0, i == 0? "%d": ", %d", ttab->table2 [i]);
ftracef (NULL, 0, "} dbpp %d\n", ttab->dbpp);
ftracef (NULL, 0, "} dlog2bpp %d\n", ttab->dlog2bpp);
}
#else
#define Trace_Ttab(ttab) ((void) 0)
......@@ -595,7 +609,7 @@ static int Current_Palette [256];
#endif
main_ttab *psprite_ttab_for_sprite (main_sprite *sprite, int dmode,
int *dpal)
int *dpal, int *workspace, void (*transfunc) (void))
{ main_ttab *tb = NULL;
int smode, slb_bpp, dlb_bpp, sbpp, dbpp, spal [256 /*no palette can be
......@@ -669,6 +683,7 @@ main_ttab *psprite_ttab_for_sprite (main_sprite *sprite, int dmode,
ftracef0 ("looking for table\n");
for (tb = tbchain; tb != NULL; tb = tb->link)
if (tb->smode == smode && tb->dlog2bpp == dlb_bpp && tb->dncolour == dncolour && tb->dmodeflags == dmodeflags && tb->spalsize == spalsize &&
tb->workspace == workspace && tb->transfunc == transfunc &&
(sbpp <= 8? memcmp (tb->spal, spal, 4 << sbpp) == 0: TRUE) &&
(dbpp <= 8? memcmp (tb->dpal, destpal, 4 << dbpp) == 0: TRUE))
{ tb->refcount++;
......@@ -676,7 +691,7 @@ main_ttab *psprite_ttab_for_sprite (main_sprite *sprite, int dmode,
}
if (tb == NULL)
{ if ((tb = psprite_ttab_new (sprite, dmode, dpal)) == NULL)
{ if ((tb = psprite_ttab_new (sprite, dmode, dpal, workspace, transfunc)) == NULL)
{ msg = msgs_lookup ("PntEG");
goto finish;
}
......@@ -690,6 +705,7 @@ main_ttab *psprite_ttab_for_sprite (main_sprite *sprite, int dmode,
else
{ ftracef0 ("using preexisting table\n");
}
ftracef4 ("tb: %x refcount: %d workspace: %x transfunc: %x\n", tb, tb->refcount, tb->workspace, tb->transfunc);
}
finish:
......@@ -704,7 +720,8 @@ finish:
}
}
main_ttab *psprite_ttab_new (main_sprite *sprite, int dmode, int *dpal)
main_ttab *psprite_ttab_new (main_sprite *sprite, int dmode, int *dpal,
int *workspace, void (*transfunc) (void))
{ main_ttab *tb = NULL;
int smode, slb_bpp, dlb_bpp, sbpp, dbpp, spal [256 /*no palette can
......@@ -832,6 +849,15 @@ main_ttab *psprite_ttab_new (main_sprite *sprite, int dmode, int *dpal)
else
tb->dpal = 0;
if (workspace != 0 && workspace [0] == 2)
{ /* If the transfer function's disabled, there's no point in
specifying one at all! */
workspace = NULL;
transfunc = NULL;
}
tb->workspace = workspace;
tb->transfunc = transfunc;
/*Black*/
if (slb_bpp > 3 || psprite_hastruecolpal (sprite))
{ /*Use the sprites own palette if it has one, or if it is a deep
......@@ -839,7 +865,8 @@ main_ttab *psprite_ttab_new (main_sprite *sprite, int dmode, int *dpal)
palette at all, and ColourTrans understands this).*/
table_new (sprite->file->spritearea, psprite_address (sprite), dmode,
dpal, 1 << 0 /*R1 is sprite*/ | 1 << 4 /*wide entries for deep
modes*/, &tb->ttab_size, &tb->table);
modes*/| ((transfunc)? (1 << 2) : 0)/*do R6, R7 have transfer func*/
,workspace, transfunc, &tb->ttab_size, &tb->table);
if (tb->ttab_size != 0 && tb->table == NULL)
{ msg = msgs_lookup ("PntEG");
goto finish;
......@@ -850,8 +877,9 @@ main_ttab *psprite_ttab_new (main_sprite *sprite, int dmode, int *dpal)
{ /*Use one of the standard palettes for sprites without one.*/
table_new ((void *) psprite_address (sprite)->mode,
psprite_std_palettes [sprite->file->use_current_palette? 0: 1]
[slb_bpp], dmode, dpal, 1 << 4 /*wide entries for deep modes*/,
&tb->ttab_size, &tb->table);
[slb_bpp], dmode, dpal, 1 << 4 /*wide entries for deep modes*/
| ((transfunc)? (1 << 2) : 0)/*do R6, R7 have transfer func*/,
workspace, transfunc, &tb->ttab_size, &tb->table);
if (tb->ttab_size != 0 && tb->table == NULL)
{ msg = msgs_lookup ("PntEG");
goto finish;
......@@ -894,17 +922,22 @@ void psprite_drop_translation (main_ttab **tb)
{ ftracef0 ("psprite_drop_translation\n");
if (*tb != NULL && --(*tb)->refcount == 0)
{ main_ttab **prev;
if (*tb != NULL)
{ if (--(*tb)->refcount == 0)
{ main_ttab **prev;
for (prev = &tbchain; *prev != NULL; prev = &(*prev)->link)
if (*prev == *tb)
{ ftracef1 ("ttab block @ 0x%X dies\n", *tb);
*prev = (*tb)->link;
psprite_ttab_delete (*tb);
*tb = NULL;
break;
}
for (prev = &tbchain; *prev != NULL; prev = &(*prev)->link)
if (*prev == *tb)
{ ftracef1 ("ttab block @ 0x%X dies\n", *tb);
*prev = (*tb)->link;
psprite_ttab_delete (*tb);
break;
}
}
/* Always nullify the pointer passed in, even if refcount hasn't *
* reached 0, because this particular reference is now invalid *
* and should no longer be used. */
*tb = NULL;
}
}
......@@ -1115,7 +1148,8 @@ os_error *psprite_set_plot_info (main_file *file)
int psprite_palsize (main_sprite *sprite)