Commit 52984de9 authored by Robert Sprowson's avatar Robert Sprowson

Fix abort when sorting the sprites by name and one or more sprite viewers are...

Fix abort when sorting the sprites by name and one or more sprite viewers are open, also massively simplified it since the copying around of main_sprite blocks was pointless - much simpler to just rejoin the linked list leaving the data in place.

*Tidy up
 Delete awk.*, change to use central 'AwkVers' script.
 Delete h.types.
 Delete h.Paint, it's a duplicate of h.main.
 Delete writepixel, swap to using the one in RISCOS_Lib
 Retire 'h.fixes', switches collapsed, bugfixes proven after 18 years use.
 Cast away some warnings.
 Sprinkled in some consts, moved pointer qualifiers to get syntax colouring
 right.
 Remove local SWI defines, read from <swis.h> now.
 !MkInstall now installs into <Install$Dir>.Apps
*Little UI changes
 Make the colour number in the colour picker be in the right place vertically
 and correct horizontal position of 'T' and 'E' for ECFs.
 In the create new sprite dialogue box the 32k and 16M options are shaded
 when a palette is requested, this avoids the problem of selecting a deep
 colour mode (which trapped the radio icon in a shaded paletted selection).
 The 'Selection' menu is now shaded when there are zero sprites in the
 file
*Sprite filer
 Fix tiled main window fill to work in EX0 modes and not overwrite in EX2
 modes (was using the sprite's mode word not the current mode to deduce eigen
 factors), leading to odd chequer board areas not being redrawn.
 Refactored main_clear_background() to use stronger typing of RISC_OSLib
 rather than _swix where possible.
 A failure to get the Wimp pixel translation table now falls back to solid
 fill
 Double clicking on a sprite in the sprite file window no longer leaves it
 selected, to mimic the filer.
 Set DISPLAY_MARGIN to 0 to counter for the recent increase from 32 to 40
 of main_FILER_TextHeight
 Added 'Sort by size' after 'Sort by name'

Version 2.02. Tagged as 'Paint-2_02'
parent 93a159b1
......@@ -14,5 +14,5 @@
|
Dir <Obey$Dir>
wimpslot -min 1024k
cdir <Install$Dir>.!Paint
amu_machine install INSTDIR=<Install$Dir>.!Paint
cdir <Install$Dir>.Apps.!Paint
amu_machine install INSTDIR=<Install$Dir>.Apps.!Paint
s/** gitlab-language=armasm linguist-language=armasm linguist-detectable=true
awk/** gitlab-language=awk linguist-language=awk linguist-detectable=true
*,ffb gitlab-language=bbcbasic linguist-language=bbcbasic linguist-detectable=true
c/** gitlab-language=c linguist-language=c linguist-detectable=true
**/c/** gitlab-language=c linguist-language=c linguist-detectable=true
......
......@@ -32,7 +32,7 @@ MODULE = rm.!Paint
ROM_MODULE = aof.Paint
RDIR = Resources
LDIR = ${RDIR}.${LOCALE}
MSGVERSION = ${AWK} -f Build:AwkVers
MSGS = Resources.GenMessage
#
......@@ -54,6 +54,7 @@ RM = remove
SQUEEZE = squeeze
WIPE = -wipe
XWIPE = x wipe
AWK = GNU.gawk
AFLAGS = ${THROWBACK} -depend !Depend -nocache -stamp -quit
CFLAGS = ${THROWBACK} -c -depend !Depend -fah ${INCLUDES} -wp
......@@ -107,11 +108,11 @@ DFILES = \
debug.${APP}.Templates
OBJS = o.colours o.main o.menus o.psprite o.sprwindow o.tools o.toolwindow \
o.jpeg o.writepixel o.AltRename o.PaintLib
o.jpeg o.AltRename o.PaintLib
OBJSZ = oz.colours oz.main oz.menus oz.psprite oz.sprwindow\
oz.tools oz.toolwindow o.jpeg o.writepixel oz.AltRename oz.PaintLib
oz.tools oz.toolwindow o.jpeg oz.AltRename oz.PaintLib
OBJSD = od.colours od.ftrace od.guard od.main od.menus\
od.psprite od.sprwindow od.tools od.toolwindow o.jpeg o.m o.writepixel\
od.psprite od.sprwindow od.tools od.toolwindow o.jpeg o.m\
od.AltRename od.PaintLib
ASMS = s.colours s.main s.menus s.psprite s.sprwindow s.tools s.toolwindow
INCS = i.colours i.main i.menus i.psprite i.sprwindow i.tools i.toolwindow
......@@ -262,8 +263,8 @@ oz.ModuleWrap: s.ModuleWrap ${MSGS} s.AppName ${RESFILES} s.Resfiles
s.ModuleWrap: ${WRAPPER}
${CP} ${WRAPPER} $@ ${CPFLAGS}
${MSGS}: ${LDIR}.Messages awk.Version
GNU.gawk -f awk.Version ${LDIR}.Messages > $@
${MSGS}: ${LDIR}.Messages VersionNum
${MSGVERSION} ${LDIR}.Messages > $@
s.ResFiles: asm.ResFiles
${CP} asm.ResFiles $@ ${CPFLAGS}
......
No preview for this file type
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "2.01"
Module_Version SETA 201
Module_MajorVersion SETS "2.02"
Module_Version SETA 202
Module_MinorVersion SETS ""
Module_Date SETS "01 Oct 2009"
Module_ApplicationDate SETS "01-Oct-09"
Module_Date SETS "29 Nov 2010"
Module_ApplicationDate SETS "29-Nov-10"
Module_ComponentName SETS "Paint"
Module_ComponentPath SETS "castle/RiscOS/Sources/Apps/Paint"
Module_FullVersion SETS "2.01"
Module_HelpVersion SETS "2.01 (01 Oct 2009)"
Module_FullVersion SETS "2.02"
Module_HelpVersion SETS "2.02 (29 Nov 2010)"
END
/* (2.01)
/* (2.02)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 2.01
#define Module_MajorVersion_CMHG 2.02
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 01 Oct 2009
#define Module_Date_CMHG 29 Nov 2010
#define Module_MajorVersion "2.01"
#define Module_Version 201
#define Module_MajorVersion "2.02"
#define Module_Version 202
#define Module_MinorVersion ""
#define Module_Date "01 Oct 2009"
#define Module_Date "29 Nov 2010"
#define Module_ApplicationDate "01-Oct-09"
#define Module_ApplicationDate "29-Nov-10"
#define Module_ComponentName "Paint"
#define Module_ComponentPath "castle/RiscOS/Sources/Apps/Paint"
#define Module_FullVersion "2.01"
#define Module_HelpVersion "2.01 (01 Oct 2009)"
#define Module_LibraryVersionInfo "2:1"
#define Module_FullVersion "2.02"
#define Module_HelpVersion "2.02 (29 Nov 2010)"
#define Module_LibraryVersionInfo "2:2"
;ObjAsm file for OSSpriteOp_{WritePixelColour,WritePixelMask}
;written by DefMod (Oct 24 1994) on Wed Oct 26 11:31:56 1994
;Copyright Acorn Computers Ltd, 1994
;Tweaked for 32-bit by KBracey on Sat Nov 27 1999
R0 RN 0
R1 RN 1
R2 RN 2
R3 RN 3
R4 RN 4
R5 RN 5
R6 RN 6
R7 RN 7
R8 RN 8
R9 RN 9
A1 RN 0
A2 RN 1
A3 RN 2
A4 RN 3
V1 RN 4
V2 RN 5
V3 RN 6
V4 RN 7
V5 RN 8
V6 RN 9
R RN 0
SL RN 10
FP RN 11
IP RN 12
SP RN 13
LR RN 14
PC RN 15
GET Hdr:ListOpts
GET Hdr:APCS.<APCS>
EXPORT xosspriteop_write_pixel_colour
EXPORT xosspriteop_write_pixel_mask
AREA |SWI$$Code|, CODE, READONLY
xosspriteop_write_pixel_colour ROUT
MOV IP, SP
STMFD SP!, {V1, V2, V3, LR}
LDMFD IP, {R4, R5, R6}
ORR R0, R0, #&2A
SWI &2002E
MOVVC R, #0
Return "V1, V2, V3"
xosspriteop_write_pixel_mask ROUT
MOV IP, SP
STMFD SP!, {V1, V2, LR}
LDMFD IP, {R4, R5}
ORR R0, R0, #&2C
SWI &2002E
MOVVC R, #0
Return "V1, V2"
END
# Generate an assembler header file containing ApplicationName
# and ApplicationVersion using information in the Messages file.
# Component version and date need only be updated in Messages file
#
BEGIN {
found = 0
}
{
if (!found) {
split($1, Id, ":")
if (Id[1] == "PntID") {
found = 1
split($2, Date, "-")
}
}
}
END {
printf("; AppName - generated from Messages, used by ModuleWrap\n;\n")
printf(" GBLS ApplicationName\n")
printf("ApplicationName SETS \"Paint\"\n")
printf(" GBLS ApplicationVersion\n")
printf("ApplicationVersion SETS \"%s %s %s 19%s\"\n\n", Id[2], Date[1], Date[2], Date[3])
printf(" END\n")
}
#
# Output a messages file,with the ID token replaced with the date taken from the VersionNum file
#
BEGIN {
while (getline < "VersionNum" > 0) {
split($0, Version);
if (Version[1] == "#define") {
if (Version[2] == "Module_ApplicationDate") {
Date = substr(Version[3], 2, length(Version[3]) -2 );
}
if (Version[2] == "Module_MajorVersion_CMHG") {
VString = Version[3];
}
}
}
}
/^PntID/ { printf("PntID:%s (%s)\n", VString, Date); done = 1; next; }
{ print }
END {
if (!done) {
printf("PntID:%s (%s)\n", VString, Date);
}
}
......@@ -12,28 +12,29 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "AltRename.h"
#include <swis.h>
#include <string.h>
#include "os.h"
#include "bbc.h"
#include "wimpt.h"
#include "werr.h"
#include "string.h"
#include "sprite.h"
#include "AltRename.h"
#include "PSprite.h"
#include "PaintLib.h"
#include "os.h"
#include "main.h"
#include "sprite.h"
#include "SprWindow.h"
#include "swis.h"
#include "akbd.h"
static wimp_i rename_icon=-1;
static char rename_buffer[16];
static main_window* rename_window;
static main_sprite* rename_sprite;
static main_window *rename_window;
static main_sprite *rename_sprite;
static wimp_box rename_bbox;
static int rename_sprites_per_row;
static void AltRename_renamesprite(main_sprite* sprite,char* newname)
static void AltRename_renamesprite(main_sprite *sprite, char *newname)
{
sprite_id sid;
char name[NAME_LIMIT+1];
......@@ -104,7 +105,7 @@ void AltRename_delete(void)
rename_window=0;
}
static int AltRename_sprites_per_row(int* toggled)
static int AltRename_sprites_per_row(int *toggled)
{
wimp_wstate ws;
int width;
......@@ -126,7 +127,7 @@ static int AltRename_sprites_per_row(int* toggled)
return width?width:1;
}
void AltRename_start(main_window* window, main_sprite* sprite)
void AltRename_start(main_window *window, main_sprite *sprite)
{
wimp_box bbox;
psprite_info sinfo;
......@@ -194,7 +195,7 @@ void AltRename_start(main_window* window, main_sprite* sprite)
}
BOOL AltRename_claim_event(wimp_eventstr *e,main_window* window)
BOOL AltRename_claim_event(wimp_eventstr *e,main_window *window)
{
if (!rename_window) return 0;
switch (e->e)
......@@ -241,14 +242,14 @@ BOOL AltRename_claim_event(wimp_eventstr *e,main_window* window)
// fall through
case 0x18A: /* TAB - next sprite */
{
main_sprite* sprite=rename_sprite->link;
main_sprite *sprite=rename_sprite->link;
if (sprite==0) sprite=rename_window->data->file.sprites;
AltRename_start(rename_window,sprite);
}
break;
case 0x19A: /* Shift TAB - previous sprite */
{
main_sprite* sprite=rename_sprite;
main_sprite *sprite=rename_sprite;
for (sprite=rename_window->data->file.sprites;
!(sprite->link==0 || sprite->link==rename_sprite);
sprite=sprite->link);
......
......@@ -25,7 +25,7 @@
* JAB, 23 Nov 90 - Doesn't reset options when closing colour window
*/
#include "swis.h"
#include <swis.h>
#include "bbc.h"
#include "wimpt.h"
......@@ -40,17 +40,6 @@
#include "Colours.h"
#include "PaintLib.h"
#undef OS_SetColour
#define OS_SetColour 0x61
#undef ColourPicker_OpenDialogue
#define ColourPicker_OpenDialogue 0x47702
#undef ColourPicker_CloseDialogue
#define ColourPicker_CloseDialogue 0x47703
#undef Wimp_TextOp
#define Wimp_TextOp 0x400F9
#undef ColourTrans_GenerateTable
#define ColourTrans_GenerateTable 0x40763
/**********************************
* Number of colours in a sprite *
**********************************/
......@@ -93,22 +82,6 @@ void colours_set_gcol (int col, int action, int back)
break;
} }
#if 0
/*replaces the following. J R C 22nd Feb 1994*/
{ if (bbc_modevar (-1, bbc_Log2BPP) >= 3) /* 256 colour mode */
{ bbc_gcol (action, colours_gcol_ttab [col >> 2] | back << 7);
bbc_tint (2 + back, col & 3); /* library shifts it for me */
ftracef3 ("GCOL 0x%X=%d, TINT %d\n",
colours_gcol_ttab [col >> 2] | back << 7,
colours_gcol_ttab [col >> 2] | back << 7, col & 3);
}
else
{ bbc_gcol (action, (col & 127) | back << 7);
ftracef2 ("GCOL 0x%X=%d\n", (col & 127) | back << 7,
(col & 127) | back << 7);
} }
#endif
/***********************************************************
* Set the gcol, doing sprite ECF selection if appropriate *
***********************************************************/
......@@ -159,7 +132,7 @@ void colours_event_handler (wimp_eventstr *e, void *handle)
wimp_redrawstr rds;
unsigned char mono_ttab [256];
static int mono_palette [] = {0x00000000, 0xFFFFFF00};
static const unsigned int mono_palette [] = {0x00000000, 0xFFFFFF00};
mask = psprite_hasmask (sprite);
lim = nc = colours_count (sprite);
......@@ -325,9 +298,8 @@ void colours_event_handler (wimp_eventstr *e, void *handle)
-1, -1,
xpos + coloursize/2 -
(i < nc? (i < 10? 1: i < 100? 2: 3):
!ECF? 2: 1)*(main_FILER_TextWidth - 4)/2,
ypos -
(coloursize + main_FILER_TextHeight + (1 << y_eig))/2);
!ECF? 1: 2)*(main_FILER_TextWidth - 4)/2,
ypos - coloursize + (main_FILER_TextHeight/2));
}
else
{ /*WIMP Does not support wimptextop_set_colour.*/
......@@ -336,9 +308,8 @@ void colours_event_handler (wimp_eventstr *e, void *handle)
bbc_move (xpos + coloursize/2 -
(i < nc? (i < 10? 1: i < 100? 2: 3):
!ECF? 2: 1)*(main_FILER_TextWidth - 4)/2,
ypos - (coloursize - main_FILER_TextHeight +
(1 << y_eig))/2);
!ECF? 1: 2)*(main_FILER_TextWidth - 4)/2,
ypos - (main_FILER_TextHeight/2));
/*the main_FILER_TextWidth's have 4 taken off to set value
to the original size*/
......
This diff is collapsed.
......@@ -87,19 +87,20 @@
#include "PaintLib.h"
#include "AltRename.h"
#undef ColourPicker_UpdateDialogue
#define ColourPicker_UpdateDialogue 0x47704
#define MIN(x, y) ((x) < (y)? (x): (y))
#define MAX(x, y) ((x) > (y)? (x): (y))
#define COPY_N(s1, s2, n) (sprintf ((s1), "%.*s", (n), (s2)), s1)
/*this is strncpy() really*/
#define XPDriver_DeclareFont (0x80155 | 1 << 17)
#define COPY_N(s1, s2, n) (sprintf ((s1), "%.*s", (n), (s2)), s1) /*this is strncpy() really*/
static int Do_Print (char *, void *);
typedef struct
{
union
{
char orgname[NAME_LIMIT + 1];
int orgsize;
} type;
main_sprite *orgsprite;
} sprite_tosort;
/***********************
* Static menu handles *
***********************/
......@@ -218,7 +219,7 @@ static void show_info_box (void)
{ dbox_setfield (d, d_Prog_Name, msgs_lookup ("Pnt00"));
dbox_setfield (d, d_Prog_Copy, msgs_lookup ("PntM1"));
dbox_setfield (d, d_Prog_WhatIsIt, msgs_lookup ("PntM2"));
dbox_setfield (d, d_Prog_Version, msgs_lookup ("PntID"));
dbox_setfield (d, d_Prog_Version, msgs_lookup ("_Version"));
dbox_show (d);
dbox_raw_eventhandler (d, &help_dboxrawevents, (void *) "PntH8");
......@@ -291,33 +292,30 @@ void menus_sprite_new (main_window *window, BOOL hack_palette)
/*************************************
* Ensure spritearea large enough *
*************************************/
#if 1
#if FIX0770
/*
* OK: this is what *I* think menus_ensure_size() is supposed to do.
*
* bytesneeded > 0: if not at least <bytesneeded> bytes free in sprite area,
* extend it.
* bytesneeded < 0: reduce size of sprite area by <bytesneeded> bytes. This
* used to do this regardless but I have changed it so
* that it never reduces it such that the free offset points
* outside the area. This should fix many bugs.
* bytesneeded = 0: reduce size of sprite area to exactly what is needed by
* the contents of the area.
*
* Hence I expect an operation that changes the size of a sprite area to
* do an menus_ensure_size( , 0) on completion to release the free space. This seems
* to be what is done so was probably the intention.
*
* Christopher Partington 18-Feb-1992
*/
#endif
BOOL menus_ensure_size (sprite_area **sarea, int bytesneeded)
{ int bytesfree = (*sarea)->size - (*sarea)->freeoff;
#if FIX9544
int newsize;
#endif
/*
* OK: this is what I think menus_ensure_size() is supposed to do.
*
* bytesneeded > 0: if not at least <bytesneeded> bytes free in sprite area,
* extend it.
* bytesneeded < 0: reduce size of sprite area by <bytesneeded> bytes. This
* used to do this regardless but I have changed it so
* that it never reduces it such that the free offset points
* outside the area. This should fix many bugs.
* bytesneeded = 0: reduce size of sprite area to exactly what is needed by
* the contents of the area.
*
* Hence I expect an operation that changes the size of a sprite area to
* do an menus_ensure_size( , 0) on completion to release the free space. This seems
* to be what is done so was probably the intention.
*
* Christopher Partington 18-Feb-1992
*/
ftracef1 ("menus_ensure_size of %d\n", bytesneeded);
ftracef3("bytesfree = %d - %d = %d\n", (*sarea)->size, (*sarea)->freeoff,
......@@ -338,7 +336,7 @@ BOOL menus_ensure_size (sprite_area **sarea, int bytesneeded)
bytesneeded += 256; /* and a little headroom */
ftracef1 ("... do flex_extend of %d\n", bytesneeded);
#if FIX0770
if (bytesneeded < 0)
{
ftracef1("shrinking area, change = %d bytes\n", bytesneeded);
......@@ -354,9 +352,7 @@ BOOL menus_ensure_size (sprite_area **sarea, int bytesneeded)
ftracef0("area is just the right size - no change\n");
return TRUE;
}
#endif
#if FIX9544
newsize = flex_size((flex_ptr) sarea) + bytesneeded;
/* check for overflow before calling flex */
#if TRACE
......@@ -364,10 +360,6 @@ BOOL menus_ensure_size (sprite_area **sarea, int bytesneeded)
ftracef0("arithmetic overflow, so not enough memory\n");
#endif
if (newsize < 0 || !flex_extend((flex_ptr) sarea, newsize))
#else
if (!flex_extend ((flex_ptr) sarea,
flex_size ((flex_ptr) sarea) + bytesneeded))
#endif
return FALSE;
(*sarea)->size += bytesneeded;
......@@ -375,32 +367,6 @@ BOOL menus_ensure_size (sprite_area **sarea, int bytesneeded)
(*sarea)->size - (*sarea)->freeoff);
return TRUE;
}
#else
int menus_ensure_size (sprite_area **sarea, int bytesneeded)
{ int bytesfree = (*sarea)->size - (*sarea)->freeoff;
ftracef1 ("menus_ensure_size of %d\n", bytes_needed);
if (bytesneeded < 0)
{ ftracef0 ("Asked to shrink negatively\n");
bytesneeded = 0;
}
bytesneeded -= bytesfree; /* amount needed */
bytesneeded += 256; /* and a little headroom */
ftracef3 ("Extend sprite area from %d by %d (spare %d)\n",
flex_size ((flex_ptr) sarea), bytesneeded, bytesfree);
if (!flex_extend ((flex_ptr) sarea,
flex_size ((flex_ptr) sarea) + bytesneeded))
{ main_NO_ROOM ("ensure size");
return 0;
}
(*sarea)->size += bytesneeded;
return 1;
}
#endif
/**********************************
* Check for sprite existence *
......@@ -734,13 +700,13 @@ static BOOL buffer_sprite_palette (void *shandle, int *max)
return mysendbuf (&pp, len, max, 0);
}
static void menus_save_selection (main_window* window)
static void menus_save_selection (main_window *window)
{
ftracef0 ("menus_save_selection\n");
if (window->selection.count==1)
{
main_sprite* sprite;
main_sprite *sprite;
for (sprite=window->data->file.sprites;sprite;sprite=sprite->link)
{
if (sprite->flags & MSF_SELECTED) break;
......@@ -911,7 +877,7 @@ static void stop_insdel_graphics (void)
menus_restart_tool ();
}
static void insdel_drawEOR(main_sprite_window* sprw,int x0,int y0)
static void insdel_drawEOR(main_sprite_window *sprw, int x0, int y0)
{
int xmul = sprw->blobsize.scale_xmul*insdel_sprite->mode.scale_xmul;
int xdiv = sprw->blobsize.scale_xdiv;
......@@ -2255,127 +2221,109 @@ void menus_file_handler (void *handle, char *hit)
} }
break;
case m_Misc_SBName: {
/* Sort by name */
sprite_area *sarea = window->data->file.spritearea;
int count = sarea->number;
if (count < 2) break; /* Not worth sorting */
/* The sprite name has no terminator when it's 12 long,so copy and terminate the names */
case m_Misc_SBName:
case m_Misc_SBSize:
{ /* Sort by name or size */
sprite_area *unsorted = window->data->file.spritearea;
sprite_area *sorted;
sprite_id sid;
main_sprite *sprite,*nextsprite;
main_file *file = &window->data->file;
int size = sarea->size;
int loop, next, i;
sprite_header *header;
int count = unsorted->number;
main_file *file = &window->data->file;
main_sprite *sprite;
int loop, next;
BOOL byname = (hit[1] == m_Misc_SBName);
sprite_tosort tosort[count];
sprite_tosort *tosortptr[count];
ftracef1("sort - sorting %d sprites\n", count);
if (count < 2) break; /* Not worth sorting */
ftracef1 ("sort - sorting %d sprites\n", count);
count = 0;
for (sprite=file->sprites;sprite!=NULL;sprite=sprite->link)
{
strncpy((char *)tosort[count].tosort, /* The heapsort copy */
((char *)sarea) + sprite->offset + 4, /* The source name */
NAME_LIMIT);
tosort[count].tosort[NAME_LIMIT] = '\0'; /* Ensure a terminator */
tosort[count].tojumble = sprite; /* Remember the corresponding sprite structure pointer */
tosortptr[count] = &tosort[count];
count++;
}
{ if (byname)
{ /* Sprite names can be the full 12 letters long so take a copy */
memcpy ((char *)tosort[count].type.orgname,
((char *)unsorted) + sprite->offset + offsetof (sprite_header, name),
NAME_LIMIT);
tosort[count].type.orgname[NAME_LIMIT] = '\0'; /* Ensure a string terminator */
}
else
{ /* Infer the size */
header = (sprite_header *)((int)unsorted + sprite->offset);
tosort[count].type.orgsize = header->next;
}
tosort[count].orgsprite = sprite; /* Remember its corresponding structure */
tosortptr[count] = &tosort[count];
count++;
}
if (((int)&tosortptr) & 0xE0000000)
{
/* Too high - give it to HeapSort32 to jiggle the pointers */
if (wimpt_complain (_swix (OS_HeapSort32, _INR(0,2) | _IN(7), count, &tosortptr, 4, 0)))
break;
}
{ /* Too high - give it to HeapSort32 to jiggle the pointers */
if (wimpt_complain (_swix (OS_HeapSort32, _INR(0,2) | _IN(7),
count, &tosortptr, byname ? 4 : 2, 0)))
break;
}
else
{
/* Give it to HeapSort to jiggle the pointers */
if (wimpt_complain (_swix (OS_HeapSort, _INR(0,2), count, &tosortptr, 4)))
break;
}
{ /* Give it to HeapSort to jiggle the pointers */
if (wimpt_complain (_swix (OS_HeapSort, _INR(0,2),
count, &tosortptr, byname ? 4 : 2)))
break;
}
for (loop = 0; (loop < (count-1)) && (tosortptr[loop] < tosortptr[loop+1]); loop++)
{
/* Nothing */
}
{ /* Nothing */
}
if (loop==(count-1)) break; /* They were already in order */
visdelay_begin ();
/* Copy them over to a new area in the right order */
if (!flex_alloc((flex_ptr) &sorted, size))
{
werr (FALSE, msgs_lookup ("PntEG"));
break;
}
ftracef1("sort flex'd %08X\n",(char *)sorted);
sorted->size = size;
/* Allocate a new blank area to copy into */
if (!flex_alloc ((flex_ptr)&sorted, unsorted->size))
{ werr (FALSE, msgs_lookup ("PntEG"));
break;
}
ftracef1 ("sort flex'd %08X\n", (char *)sorted);
unsorted = window->data->file.spritearea; /* Might have shifted */
sorted->size = unsorted->size;
sorted->number = count;
sorted->sproff = next = 16;
if ((nextsprite = m_ALLOC( sizeof(main_sprite))) == NULL)
{ main_NO_ROOM ("sort rebuild link");
visdelay_end ();
flex_free ((flex_ptr) &sorted);
break;
/* If this happens it'll revert to the old unsorted sprite */
}
file->sprites = nextsprite;
for (loop = 0; loop < count; loop++)
{
sprite = nextsprite;
sid.s.name = tosortptr[loop]->tosort;
sid.tag = sprite_id_name;
sarea = window->data->file.spritearea; /* Incase flex shuffled */
sprite_select_rp(sarea, &sid, &sid.s.addr); /* Will succeed as they were there about 15 lines ago */
size = ((sprite_header *) sid.s.addr)->next;
ftracef2("sort selected %08X size %d\n",(int)sid.s.addr, size);
memcpy((char *)sorted + next,(char *)sid.s.addr, size);
next = next + size;
/* Now magic up a new sprite info block */
sprite->file = tosortptr[loop]->tojumble->file;
sprite->windows = tosortptr[loop]->tojumble->windows;
sprite->transtab = tosortptr[loop]->tojumble->transtab;
sprite->mode = tosortptr[loop]->tojumble->mode;
sprite->iconsize = tosortptr[loop]->tojumble->iconsize;
sprite->colourhandle = tosortptr[loop]->tojumble->colourhandle;
for (i = 0; i < 4; i++) sprite->ECFs [i].sarea = tosortptr[loop]->tojumble->ECFs [i].sarea;
sprite->gcol = tosortptr[loop]->tojumble->gcol;
sprite->gcol2 = tosortptr[loop]->tojumble->gcol2;
for (i = 0; i < toolspacesize; i++) sprite->toolspace [i] = tosortptr[loop]->tojumble->toolspace [i];
sprite->colourdialogue = tosortptr[loop]->tojumble->colourdialogue;
sprite->colourtitle = tosortptr[loop]->tojumble->colourtitle;
sprite->needsnull= tosortptr[loop]->tojumble->needsnull;
sprite->coloursize = tosortptr[loop]->tojumble->coloursize;
/* Free the original,as that linked list is dead now */
m_FREE(tosortptr[loop]->tojumble, sizeof(main_sprite));
nextsprite = m_ALLOC( sizeof(main_sprite));
sprite->link = nextsprite;
}
{ int size;
/* For each sprite in the sorted pointers, locate the unsorted one, copy it */
header = (sprite_header *)((int)unsorted + tosortptr[loop]->orgsprite->offset);
size = header->next;
ftracef2 ("sort selected %08X size %d\n", (int)header, size);
memcpy ((char *)sorted + next, (char *)header, size);
next = next + size;
/* Append its structure to the list, when the file is marked as changed later
a call to psprite_recalculate_offsets fixes up the spriteno and offset
fields */
if (loop == 0)
file->sprites = tosortptr[loop]->orgsprite; /* Head */
else
sprite->link