Source
...
Target
Commits (13)
  • Robert Sprowson's avatar
    Fix abort when sorting the sprites by name and one or more sprite viewers are... · 52984de9
    Robert Sprowson authored
    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'
    52984de9
  • Robert Sprowson's avatar
    Prune the plethora of targets a bit. · cba6e241
    Robert Sprowson authored
    Spurious ';' after an if at line 2386 of c.Main deleted, something to do with scroll wheel support. Untested.
    Refer to FileType_ using the filetypes header file.
    Internationalised "Selection" when saving a sprite selection.
    main_save_selection wasn't checking if fwrite() worked so never reported 'disc full'.
    Turn on egg timer during main_save_selection().
    Fix (de)selection bug when in full sprite info view, the 'spritesperrow' was being rounded down to zero, and unlike everywhere else it wasn't being adjusted back to a minimum of 1.
    
    Version 2.03. Tagged as 'Paint-2_03'
    cba6e241
  • Robert Sprowson's avatar
    Redundant files removed. · 2c57b174
    Robert Sprowson authored
    2c57b174
  • Robert Sprowson's avatar
    Redundant files removed. · af6ac588
    Robert Sprowson authored
    af6ac588
  • Robert Sprowson's avatar
    Clean up pass. · f11f2074
    Robert Sprowson authored
    No functional changes, but it's now a consistent ball of spaghetti.
    f11f2074
  • Robert Sprowson's avatar
    Simplify _swix to os_swix. · a42c3c38
    Robert Sprowson authored
    Function main_icon_bboxes() reordered to only call the SWIs it needs to fulfil the requested information.
    
    Version 2.04. Tagged as 'Paint-2_04'
    a42c3c38
  • Robert Sprowson's avatar
    Switch to using common JPEG code in RISC_OSLib. · e5100890
    Robert Sprowson authored
    Allows better sharing when !Draw is also in ROM.
    Fix long (long) standing bug of not being able to drag JPEGs into !Paint using the RAM transfer protocol - some dubious pointer arithmetic meant the wrong address of JPEG data was used and so gave an error.
    The 3 paths that result in a JPEG->Sprite conversion now share code too.
    Remove local definition of FileType_JPEG, use that in the exports.
    
    Version 2.05. Tagged as 'Paint-2_05'
    e5100890
  • Robert Sprowson's avatar
    Minor reformatting step. · a0724eed
    Robert Sprowson authored
    Not tested, not tagged.
    a0724eed
  • Robert Sprowson's avatar
    Fix crashes when dragging from the sprite filer to the filer to save sprite(s). · 97539240
    Robert Sprowson authored
    The use of DragASprite tended to cause an abort somewhere in the kernel's sprite handling code for some reason, changed this to instead create a temporary WIMP icon on the sprite filer in question which can than be referred to in a normal call to xfersend(). The rest of the save is then handled by the normal xfersend() handlers and the temporary icon destroyed since the WIMP takes a copy anyway.
    Has the extra benefits
     * Dragging from the sprite filer now obeys the 'solid drag' flags.
     * Dragging from the sprite filer no longer crashes if dropping back on the originating filer window itself.
    When dragging a selection from the filer the selection is cleared at the end of the drag, to match the behaviour of the desktop filer. When saving a selection from the 'Selection' menu, they are not deselected.
    Changed to use the 'package' icon when dragging multiple sprites, or file_ff9 for singles.
    
    Version 2.06. Tagged as 'Paint-2_06'
    97539240
  • Robert Sprowson's avatar
    Help messages refined. · ecdac85b
    Robert Sprowson authored
    Retagged as Paint-2_06.
    ecdac85b
  • Robert Sprowson's avatar
    Colour picker help made more helpful. · ee21e95d
    Robert Sprowson authored
    Previously, the help requests would end up in the background event handler which didn't look at the window handle and would just return "This is paint" even if the handle was that of the colour picker dialogue.
    Also now passes documented 0x80000000 and 0x7FFFFFFF on opening rather than zero.
    
    Version 2.07. Tagged as 'Paint-2_07'
    ee21e95d
  • Jeffrey Lee's avatar
    Fix CATCH_SIGNALS code to report the right error if WIMP$ScrapDir is undefined · 58d77a84
    Jeffrey Lee authored
    Detail:
      c/Main - Previously the signal handling code was using a pointer to the original error block when reporting the error to the user. This could cause the wrong error to be reported in some situations (e.g. if WIMP$ScrapDir is undefined). Instead, the code now stores a copy of the error block on the stack.
    Admin:
      Tested on rev A2 BB-xM
    
    
    Version 2.08. Tagged as 'Paint-2_08'
    58d77a84
  • Robert Sprowson's avatar
    Failure to plot JPEG would not switch output back. · 13cf3af4
    Robert Sprowson authored
    Always switches back now before reporting the error.
    
    Version 2.09. Tagged as 'Paint-2_09'
    13cf3af4
| Copyright 1996 Acorn Computers 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.
|
Dir <Obey$Dir>
Echo Cleaning <Obey$Dir> ...
AMU_machine INSTDIR=!Paint clean_all
StripDepnd Makefile
| Copyright 1996 Acorn Computers 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.
|
WIMPSlot -min 1996K -max 1996K
Dir <Obey$Dir>
Echo Making <Obey$Dir> ...
AMU_machine THROWBACK=-throwback INSTDIR=!Paint asms
| Copyright 1996 Acorn Computers 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.
|
WIMPSlot -min 1996K -max 1996K
Dir <Obey$Dir>
Echo Making <Obey$Dir> ...
AMU_machine THROWBACK=-throwback INSTDIR=debug.!Paint installd
| Copyright 1996 Acorn Computers 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.
|
WIMPSlot -min 1996K -max 1996K
Dir <Obey$Dir>
Echo Making <Obey$Dir> ...
AMU_machine THROWBACK=-throwback INSTDIR=!Paint install
......@@ -14,4 +14,5 @@
|
Dir <Obey$Dir>
wimpslot -min 1024k
amu_machine appd
cdir debug.!Paint
amu_machine installd THROWBACK=-throwback INSTDIR=debug.!Paint
......@@ -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,12 +54,13 @@ 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
CPFLAGS = ~cfr~v
SQFLAGS =
WFLAGS = ~c~v
WFLAGS = ~c~vf
#
# Libraries
......@@ -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.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 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.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
......@@ -130,8 +131,6 @@ INCS = i.colours i.main i.menus i.psprite i.sprwindow i.tools i.toolwindow
#
# Main rules:
#
# Application
#
all: ${FILES}
@echo ${COMPONENT}: Application built (Disc)
......@@ -161,7 +160,7 @@ installd: ${FILESD}
${CP} ${LDIR}.!Help ${INSTDIR}.!Help ${CPFLAGS}
${CP} ${LDIR}.!Run ${INSTDIR}.!Run ${CPFLAGS}
${CP} abs.!RunImageD ${INSTDIR}.!RunImage ${CPFLAGS}
${CP} ${LDIR}.Messages ${INSTDIR}.Messages ${CPFLAGS}
${CP} ${MSGS} ${INSTDIR}.Messages ${CPFLAGS}
${CP} ${LDIR}.Sprites ${INSTDIR}.Sprites ${CPFLAGS}
${CP} ${LDIR}.Templates ${INSTDIR}.Templates ${CPFLAGS}
Access ${INSTDIR}.!Boot lr/r
......@@ -196,6 +195,8 @@ clean:
${XWIPE} s.* ${WFLAGS}
${XWIPE} linked.* ${WFLAGS}
${XWIPE} map.* ${WFLAGS}
${XWIPE} debug.!Paint.* ${WFLAGS}
${XWIPE} !Paint.* ${WFLAGS}
${RM} abs.!RunImage
${RM} abs.!RunImageD
${RM} ${ROM_MODULE}
......@@ -203,39 +204,6 @@ clean:
${RM} ${MODULE}
@echo ${COMPONENT}: cleaned
#
# Development rules:
#
app: ${FILES}
@echo Made application ${APP}
appd: ${DFILES}
@echo Made debug.${APP}
mod: ${MODULE}
@echo ${COMPONENT}: Module built (RAM)
asms: ${ASMS}
incs: ${INCS}
clean_all:
x Access ${INSTDIR}.!Boot rw/rw
x Access ${INSTDIR}.!Help rw/rw
x Access ${INSTDIR}.!Run rw/rw
x Access ${INSTDIR}.!RunImage rw/rw
x Access ${INSTDIR}.Messages rw/rw
x Access ${INSTDIR}.Sprites rw/rw
x Access ${INSTDIR}.Templates rw/rw
Destroy ${OBJS} ${OBJSZ} ${OBJSD} o.ModuleWrap \
${APP}.!RunImage \
debug.${APP}.!RunImage \
${ROM_MODULE} ${MODULE} \
${ASMS} s.Appname s.ModuleWrap s.ResFiles \
${DFILES} ${INSTDIR}.!Boot ${INSTDIR}.!Help ${INSTDIR}.!Run \
${INSTDIR}.!RunImage ${INSTDIR}.Messages ${INSTDIR}.Sprites \
${INSTDIR}.Templates
#
# Static dependencies:
#
......@@ -262,8 +230,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
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.09"
Module_Version SETA 209
Module_MinorVersion SETS ""
Module_Date SETS "01 Oct 2009"
Module_ApplicationDate SETS "01-Oct-09"
Module_Date SETS "24 Sep 2011"
Module_ApplicationDate SETS "24-Sep-11"
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.09"
Module_HelpVersion SETS "2.09 (24 Sep 2011)"
END
/* (2.01)
/* (2.09)
*
* 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.09
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 01 Oct 2009
#define Module_Date_CMHG 24 Sep 2011
#define Module_MajorVersion "2.01"
#define Module_Version 201
#define Module_MajorVersion "2.09"
#define Module_Version 209
#define Module_MinorVersion ""
#define Module_Date "01 Oct 2009"
#define Module_Date "24 Sep 2011"
#define Module_ApplicationDate "01-Oct-09"
#define Module_ApplicationDate "24-Sep-11"
#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.09"
#define Module_HelpVersion "2.09 (24 Sep 2011)"
#define Module_LibraryVersionInfo "2:9"
;ObjAsm file for JPEG
;written by DefMod (Aug 16 1994) on Tue Sep 20 15:06:43 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 xjpeginfo_dimensions
EXPORT jpeginfo_dimensions
EXPORT xjpegfileinfo_dimensions
EXPORT jpegfileinfo_dimensions
EXPORT xjpeg_plot_scaled
EXPORT jpeg_plot_scaled
EXPORT xjpeg_plot_file_scaled
EXPORT jpeg_plot_file_scaled
EXPORT xjpeg_plot_transformed
EXPORT jpeg_plot_transformed
EXPORT xjpeg_plot_file_transformed
EXPORT jpeg_plot_file_transformed
AREA |SWI$$Code|, CODE, READONLY
xjpeginfo_dimensions ROUT
MOV IP, LR
STMFD SP!, {A3, A4, V1, V2, V3}
MOV R2, A2
MOV R1, A1
MOV R0, #&1
SWI &69980
BVS %99
LDR LR, [SP, #0]
TEQ LR, #0
STRNE R0, [LR]
LDR LR, [SP, #4]
TEQ LR, #0
STRNE R2, [LR]
LDR LR, [SP, #20]
TEQ LR, #0
STRNE R3, [LR]
LDR LR, [SP, #24]
TEQ LR, #0
STRNE R4, [LR]
LDR LR, [SP, #28]
TEQ LR, #0
STRNE R5, [LR]
MOV R, #0
99 ADD SP, SP, #8
LDMFD SP!, {V1, V2, V3}
Return ,LinkNotStacked,,IP
jpeginfo_dimensions ROUT
STMFD SP!, {A3, A4, V1, V2, V3}
MOV R2, A2
MOV R1, A1
MOV R0, #&1
SWI &49980
LDR IP, [SP, #0]
TEQ IP, #0
STRNE R2, [IP]
LDR IP, [SP, #4]
TEQ IP, #0
STRNE R3, [IP]
LDR IP, [SP, #20]
TEQ IP, #0
STRNE R4, [IP]
LDR IP, [SP, #24]
TEQ IP, #0
STRNE R5, [IP]
ADD SP, SP, #8
LDMFD SP!, {V1, V2, V3}
Return ,LinkNotStacked
xjpegfileinfo_dimensions ROUT
MOV IP, LR
STMFD SP!, {A2, A3, A4, V1, V2, V3}
MOV R1, A1
MOV R0, #&1
SWI &69981
BVS %99
LDR LR, [SP, #0]
TEQ LR, #0
STRNE R0, [LR]
LDR LR, [SP, #4]
TEQ LR, #0
STRNE R2, [LR]
LDR LR, [SP, #8]
TEQ LR, #0
STRNE R3, [LR]
LDR LR, [SP, #24]
TEQ LR, #0
STRNE R4, [LR]
LDR LR, [SP, #28]
TEQ LR, #0
STRNE R5, [LR]
MOV R, #0
99 ADD SP, SP, #12
LDMFD SP!, {V1, V2, V3}
Return ,LinkNotStacked,,IP
jpegfileinfo_dimensions ROUT
STMFD SP!, {A2, A3, A4, V1, V2, V3}
MOV R1, A1
MOV R0, #&1
SWI &49981
LDR IP, [SP, #0]
TEQ IP, #0
STRNE R2, [IP]
LDR IP, [SP, #4]
TEQ IP, #0
STRNE R3, [IP]
LDR IP, [SP, #8]
TEQ IP, #0
STRNE R4, [IP]
LDR IP, [SP, #24]
TEQ IP, #0
STRNE R5, [IP]
ADD SP, SP, #12
LDMFD SP!, {V1, V2, V3}
Return ,LinkNotStacked
xjpeg_plot_scaled ROUT
MOV IP, SP
STMFD SP!, {V1, V2, LR}
LDMFD IP, {R4, R5}
SWI &69982
MOVVC R, #0
Return "V1, V2"
jpeg_plot_scaled ROUT
MOV IP, SP
STMFD SP!, {V1, V2, LR}
LDMFD IP, {R4, R5}
SWI &49982
Return "V1, V2"
xjpeg_plot_file_scaled ROUT
MOV IP, SP
STMFD SP!, {V1, LR}
LDMFD IP, {R4}
SWI &69983
MOVVC R, #0
Return "V1"
jpeg_plot_file_scaled ROUT
MOV IP, SP
STMFD SP!, {V1, LR}
LDMFD IP, {R4}
SWI &49983
Return "V1"
xjpeg_plot_transformed ROUT
MOV IP, LR
SWI &69984
MOVVC R, #0
Return ,LinkNotStacked,,IP
jpeg_plot_transformed ROUT
SWI &49984
Return ,LinkNotStacked
xjpeg_plot_file_transformed ROUT
MOV IP, LR
SWI &69985
MOVVC R, #0
Return ,LinkNotStacked,,IP
jpeg_plot_file_transformed ROUT
SWI &49985
Return ,LinkNotStacked
END
;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,47 +12,48 @@
* 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 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)
{
sprite_id sid;
static void altrename_renamesprite (main_sprite *sprite, char *newname)
{ sprite_id sid;
char name[NAME_LIMIT+1];
sid.tag = sprite_id_name; /*doesn't flex*/
sid.s.name = newname;
if (*newname==0) return;
if (*newname == 0) return;
/* check if new name exists */
if (!sprite_select (sprite->file->spritearea,&sid)) return ;
if (!sprite_select (sprite->file->spritearea,&sid)) return;
strncpy(name,psprite_address(sprite)->name,NAME_LIMIT);
name[NAME_LIMIT]=0;
sid.s.name=name;
strncpy (name, psprite_address (sprite)->name, NAME_LIMIT);
name[NAME_LIMIT] = 0;
sid.s.name = name;
if (wimpt_complain (sprite_rename
(sprite->file->spritearea, &sid, newname)) !=
NULL) return;
main_set_modified(sprite->file);
main_set_modified (sprite->file);
sprwindow_set_window_titles (sprite);
/* rename must reset the titles of all the windows open on
......@@ -74,7 +75,7 @@ static void AltRename_renamesprite(main_sprite* sprite,char* newname)
wimp_wstate wstate;
winfo.w = sprite->colourhandle;
wimpt_noerr (PaintLib_get_wind_info (&winfo));
wimpt_noerr (paintlib_get_wind_info (&winfo));
sprintf (winfo.info.title.indirecttext.buffer,
msgs_lookup ("PntW7"), newname);
......@@ -92,21 +93,22 @@ static void AltRename_renamesprite(main_sprite* sprite,char* newname)
}
}
void AltRename_delete(void)
{
wimp_redrawstr ds;
void altrename_delete (void)
{ wimp_redrawstr ds;
if (!rename_window) return;
wimp_delete_icon(rename_window->handle,rename_icon);
ds.w=rename_window->handle;
ds.box=rename_bbox;
wimp_force_redraw(&ds);
wimp_delete_icon (rename_window->handle, rename_icon);
ds.w = rename_window->handle;
ds.box = rename_bbox;
wimp_force_redraw (&ds);
rename_window=0;
rename_window = NULL;
}
static int AltRename_sprites_per_row(int* toggled)
{
wimp_wstate ws;
static int altrename_sprites_per_row (int *toggled)
{ wimp_wstate ws;
int width;
if (!rename_window) return 0;
......@@ -116,146 +118,140 @@ static int AltRename_sprites_per_row(int* toggled)
else
width = main_FILER_TotalWidth;
wimp_get_wind_state(rename_window->handle,&ws);
if (toggled) *toggled=(ws.flags & wimp_WCLICK_TOGGLE);
wimp_get_wind_state(rename_window->handle, &ws);
width=(ws.o.box.x1-ws.o.box.x0)/width;
if (toggled) *toggled = (ws.flags & wimp_WCLICK_TOGGLE);
width = (ws.o.box.x1-ws.o.box.x0)/width;
return width?width:1;
return width ? width : 1;
}
void AltRename_start(main_window* window, main_sprite* sprite)
{
wimp_box bbox;
void altrename_start (main_window *window, main_sprite *sprite)
{ wimp_box bbox;
psprite_info sinfo;
wimp_icreate icon;
wimp_wstate ws;
int y,scy;
int y, scy;
wimp_redrawstr ds;
wimp_caretstr caret;
if (!window || ! sprite) return;
if (!window || !sprite) return;
if (window==rename_window && sprite==rename_sprite) return;
AltRename_delete();
altrename_delete();
if (!main_get_all_sprite_bboxes (window,sprite,&bbox,0,&icon.i.box))
if (!main_get_all_sprite_bboxes (window, sprite, &bbox, 0, &icon.i.box))
return;
if (window->data->file.fullinfo)
icon.i.box.x1=icon.i.box.x0+12*main_FILER_TextWidth;
icon.i.box.x1 = icon.i.box.x0+12*main_FILER_TextWidth;
else
{
icon.i.box.x0=bbox.x0;
icon.i.box.x1=bbox.x1;
{ icon.i.box.x0 = bbox.x0;
icon.i.box.x1 = bbox.x1;
}
icon.w=window->handle;
icon.i.flags=(wimp_iconflags)(wimp_ITEXT | wimp_INDIRECT | wimp_IHCENTRE |
icon.w = window->handle;
icon.i.flags = (wimp_iconflags)(wimp_ITEXT | wimp_INDIRECT | wimp_IHCENTRE |
wimp_IFILLED | wimp_IBORDER |
(7*wimp_IFORECOL) | (0*wimp_IBACKCOL) |
(wimp_BWRITABLE*wimp_IBTYPE));
(7 * wimp_IFORECOL) | (0 * wimp_IBACKCOL) |
(wimp_BWRITABLE * wimp_IBTYPE));
icon.i.data.indirecttext.buffer=rename_buffer;
icon.i.data.indirecttext.validstring="";
icon.i.data.indirecttext.bufflen=NAME_LIMIT+1;
icon.i.data.indirecttext.buffer = rename_buffer;
icon.i.data.indirecttext.validstring = "";
icon.i.data.indirecttext.bufflen = NAME_LIMIT+1;
psprite_read_full_info (sprite, &sinfo);
strcpy(rename_buffer,sinfo.name);
if (wimpt_complain(wimp_create_icon(&icon,&rename_icon))) return;
wimp_redrawstr ds;
wimp_caretstr caret;
rename_window=window;
rename_sprite=sprite;
ds.w=icon.w;
ds.box=icon.i.box;
rename_bbox=ds.box;
rename_sprites_per_row=AltRename_sprites_per_row(0);
caret.w=window->handle;
caret.i=rename_icon;
caret.x=caret.y=0;
caret.height=-1;
caret.index=strlen(sinfo.name);
wimp_set_caret_pos(&caret);
wimp_force_redraw(&ds);
wimp_get_wind_state(window->handle,&ws);
scy=ws.o.y;
y=WORKAREA_TO_SCREEN_Y(&ws,bbox.y1);
strcpy (rename_buffer, sinfo.name);
if (wimpt_complain (wimp_create_icon (&icon, &rename_icon))) return;
rename_window = window;
rename_sprite = sprite;
ds.w = icon.w;
ds.box = icon.i.box;
rename_bbox = ds.box;
rename_sprites_per_row = altrename_sprites_per_row (0);
caret.w = window->handle;
caret.i = rename_icon;
caret.x = caret.y = 0;
caret.height = -1;
caret.index = strlen (sinfo.name);
wimp_set_caret_pos (&caret);
wimp_force_redraw (&ds);
wimp_get_wind_state (window->handle,&ws);
scy = ws.o.y;
y = WORKAREA_TO_SCREEN_Y(&ws, bbox.y1);
if (y>ws.o.box.y1)
ws.o.y+=(y-ws.o.box.y1);
ws.o.y += (y-ws.o.box.y1);
y=WORKAREA_TO_SCREEN_Y(&ws,bbox.y0);
y = WORKAREA_TO_SCREEN_Y(&ws, bbox.y0);
if (y<ws.o.box.y0)
ws.o.y+=(y-ws.o.box.y0);
if (scy != ws.o.y) wimp_open_wind(&ws.o);
ws.o.y += (y-ws.o.box.y0);
if (scy != ws.o.y) wimp_open_wind (&ws.o);
}
BOOL AltRename_claim_event(wimp_eventstr *e,main_window* window)
{
if (!rename_window) return 0;
BOOL altrename_claim_event (wimp_eventstr *e, main_window *window)
{ if (!rename_window) return FALSE;
switch (e->e)
{
case wimp_EBUT:
if (window->handle!=rename_window->handle ||
(e->data.but.m.bbits & 2))
{
AltRename_delete();
{ altrename_delete ();
break;
}
if ( e->data.but.m.i==rename_icon &&
window->handle==rename_window->handle) return 1;
window->handle==rename_window->handle) return TRUE;
if (e->data.but.m.bbits & (wimp_BCLICKLEFT | wimp_BCLICKRIGHT))
{
AltRename_delete();
{ altrename_delete ();
break;
}
return 1;
return TRUE;
case wimp_EOPEN:
{
int wid;
{ int wid;
if (window->handle==rename_window->handle)
{
int toggled;
wid = AltRename_sprites_per_row(&toggled);
{ int toggled;
wid = altrename_sprites_per_row (&toggled);
if (wid != rename_sprites_per_row || toggled)
AltRename_delete();
altrename_delete();
}
break;
}
case wimp_EKEY:
if (window->handle!=rename_window->handle) break;
switch (e->data.key.chcode)
{
case 13:
AltRename_renamesprite(rename_sprite,rename_buffer);
if (!akbd_pollctl())
{
AltRename_delete();
altrename_renamesprite (rename_sprite, rename_buffer);
if (!akbd_pollctl ())
{ altrename_delete ();
break;
}
// fall through
/*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);
altrename_start (rename_window, sprite);
}
break;
case 0x19A: /* Shift TAB - previous sprite */
{
main_sprite* sprite=rename_sprite;
for (sprite=rename_window->data->file.sprites;
!(sprite->link==0 || sprite->link==rename_sprite);
sprite=sprite->link);
AltRename_start(rename_window,sprite);
{ main_sprite *sprite=rename_sprite;
for (sprite = rename_window->data->file.sprites;
!(sprite->link == NULL || sprite->link == rename_sprite);
sprite = sprite->link);
altrename_start (rename_window, sprite);
}
break;
}
}
return 0;
return FALSE;
}
......@@ -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 *
**********************************/
......@@ -91,23 +80,8 @@ void colours_set_gcol (int col, int action, int back)
os_swi2 (OS_SetColour, action | back << 4, col);
ftracef2 ("SetColour 0x%X=%d\n", col, col);
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 +133,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);
......@@ -259,7 +233,9 @@ void colours_event_handler (wimp_eventstr *e, void *handle)
os_swi2 (OS_SetColour, 0, t [i]);
}
break;
} } }
}
}
}
if (!ECF) bbc_rectanglefill (x, y, coloursize - (1 << x_eig),
coloursize - (1 << y_eig));
......@@ -303,7 +279,8 @@ void colours_event_handler (wimp_eventstr *e, void *handle)
/*Copy nybbles.*/
bg |= bg >> 4;
} }
}
}
if (mono_ttab [i /*was colour 31st Jan 1994*/])
fg = 0 /*black*/;
......@@ -325,9 +302,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 +312,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*/
......@@ -348,7 +323,10 @@ void colours_event_handler (wimp_eventstr *e, void *handle)
puts ("T");
else
printf ("E%d", ECF);
} } } }
}
}
}
}
wimpt_noerr (wimp_get_rectangle (&rds, &more));
}
......@@ -506,7 +484,7 @@ void colours_set_extent (main_sprite *sprite)
wimp_redrawstr newext;
curr.w = sprite->colourhandle;
wimpt_noerr (PaintLib_get_wind_info (&curr));
wimpt_noerr (paintlib_get_wind_info (&curr));
newext.w = sprite->colourhandle;
calculate_colour_extent (sprite, &newext.box,
......@@ -554,13 +532,12 @@ void colours_create_window (main_sprite *sprite)
(psprite_hasmask (sprite)?
colourpicker_DIALOGUE_OFFERS_TRANSPARENT: 0) |
(sprite->gcol == nc? colourpicker_DIALOGUE_TRANSPARENT: 0) |
colourpicker_DIALOGUE_TYPE_CLICK <<
colourpicker_DIALOGUE_TYPE_SHIFT;
(colourpicker_DIALOGUE_TYPE_CLICK << colourpicker_DIALOGUE_TYPE_SHIFT);
ftracef1 ("flags set to 0x%X\n", dialogue.flags);
dialogue.title = sprite->colourtitle;
dialogue.visible.x0 = sprite_redraw_str.box.x1;
dialogue.visible.y0 = 0;
dialogue.visible.x1 = 0;
dialogue.visible.y0 = (int)0x80000000;
dialogue.visible.x1 = 0x7FFFFFFF;
dialogue.visible.y1 = sprite_w_state.o.box.y1;
dialogue.xscroll = 0;
dialogue.yscroll = 0;
......@@ -574,7 +551,8 @@ void colours_create_window (main_sprite *sprite)
{ m_FREE (sprite->colourtitle, 23);
sprite->colourtitle = 0;
return;
} }
}
}
else
{ wimp_wind colours_wind;
......@@ -608,7 +586,8 @@ void colours_create_window (main_sprite *sprite)
colours_open_str.x = 0;
colours_open_str.y = 0;
wimpt_noerr (wimp_open_wind (&colours_open_str));
} }
}
}
else
{ /* if the window is already open, then bring it to the front */
wimp_wstate colour_w_state;
......@@ -620,11 +599,10 @@ void colours_create_window (main_sprite *sprite)
}
}
extern int colours_entry (int nc, int colour)
/*Returns the palette entry corresponding to the given colour number.*/
int colours_entry (int nc, int colour)
{ ftracef0 ("colours_entry\n");
{ /*Returns the palette entry corresponding to the given colour number.*/
ftracef0 ("colours_entry\n");
switch (nc)
{ case 1 << 15:
......@@ -645,4 +623,5 @@ extern int colours_entry (int nc, int colour)
ftracef0 ("INVALID SPRITE MODE!!!\n");
return 0;
break;
} }
}
}
......@@ -14,7 +14,7 @@
*/
/* > c.Main
*
* Paint: RISC O S sprite editor
* Paint: RISC OS sprite editor
* Main loop and resource loading
*
* Author: A.P. Thompson
......@@ -68,13 +68,15 @@
#include <setjmp.h>
#include <stdarg.h>
#include <swis.h>
#include "Global/CMOS.h"
#include "Global/FileTypes.h"
#include "pointer.h"
#include "akbd.h"
#include "alarm.h"
#include "baricon.h"
#include "bbc.h"
#include "colourpick.h"
#include "colourtran.h"
#include "dboxquery.h"
#include "heap.h"
#include "help.h"
......@@ -89,6 +91,8 @@
#include "wimp.h"
#include "wimpt.h"
#include "xferrecv.h"
#include "jpeg.h"
#include "xfersend.h"
#define FILENAMEMAX 255
......@@ -103,17 +107,9 @@
#include "ToolWindow.h"
#include "Tools.h"
#include "Colours.h"
#include "jpeg.h"
#include "xfersend.h"
#include "AltRename.h"
#include "PaintLib.h"
#undef ColourPicker_CloseDialogue
#define ColourPicker_CloseDialogue 0x47703
#define MIN(x, y) ((x) < (y)? (x): (y))
#define MAX(x, y) ((x) > (y)? (x): (y))
#define FREEZE_STACK 0
#define CATCH_SIGNALS 1
......@@ -127,9 +123,8 @@
extern _kernel_ExtendProc flex_dont_budge;
#endif
#define ICON_SPACE_SIZE 1200
#define DISPLAY_MARGIN 8
#define ICON_SPACE_SIZE 1200 /* For icons in the template */
#define DISPLAY_MARGIN 0
#define SPACE_FOR_HELP_TEXT (main_FILER_TextHeight+DISPLAY_MARGIN)
typedef
......@@ -146,15 +141,12 @@ typedef
}
snapshotstr;
static main_template File_Template;
static menu Main_Menu;
main_window *main_windows;
#define NOEXAMPLE
#ifndef NOEXAMPLE
int never_been_kissed = 1;
#endif
main_options main_current_options;
int main_mode_flags;
const wimp_box main_big_extent =
{-0x1FFFFFFF, -0x1FFFFFFF, 0x1FFFFFFF, 0x1FFFFFFF};
/**************************************************************************
* *
......@@ -162,47 +154,27 @@ int main_mode_flags;
* *
**************************************************************************/
#ifdef ModuleVersion
static main_file fudgefile =
static main_template file_template;
static menu main_menu;
static main_file fudgefile =
{NULL, NULL, NULL, NULL, 0, 0, 1, 0, NULL /* &fudgewindow */};
static main_window fudgewindow = { NULL, 0, main_window_is_file,
static main_window fudgewindow = { NULL, 0, main_window_is_file,
NULL /* (main_info_block *) &fudgefile */ };
main_window *main_windows;
static char *ramfetch_buffer = NULL;
static char *ramfetch_buffer = NULL;
static char Paint_Dir [FILENAME_MAX + 1];
static char Paint_Dir [FILENAME_MAX + 1];
static void init_statics (void)
wimp_box main_big_extent =
{-0x1FFFFFFF, -0x1FFFFFFF, 0x1FFFFFFF, 0x1FFFFFFF};
static void init_statics (void)
{ fudgefile.window = &fudgewindow;
{ /* Required to generate relocatable code */
fudgefile.window = &fudgewindow;
fudgewindow.data = (main_info_block *)&fudgefile;
main_windows = &fudgewindow;
}
#else
static main_file fudgefile =
{ NULL, NULL, NULL, NULL, 0, 0, 1, 0, &fudgewindow };
static main_window fudgewindow = { NULL, 0, main_window_is_file,
(main_info_block *) &fudgefile };
main_window *main_windows = &fudgewindow;
static char *ramfetch_buffer = NULL;
wimp_box main_big_extent =
{-0x1FFFFFFF, -0x1FFFFFFF, 0x1FFFFFFF, 0x1FFFFFFF};
static void init_statics (void)
{ fudgefile.window = &fudgewindow;
fudgewindow.data = &fudgefile;
main_windows = &fudgewindow;
}
#endif
}
static
main_options
......@@ -215,8 +187,6 @@ static
{/*extended*/ TRUE /*always on in versions from Black onwards*/}
};
main_options main_current_options;
static
snapshotstr
sshot =
......@@ -243,92 +213,86 @@ static
* Now the code *
*******************************************************************/
static void main_clear_background(wimp_redrawstr* rds)
{
char name[16];
sprite_header* address;
char* base;
char* rombase;
int width;
int height;
int left;
int top;
int use_sprite=0;
static void main_clear_background (wimp_redrawstr *rds)
// test tiling disabled in CMOS
_swix(OS_Byte,_INR(0,1) | _OUT(2),161,0x8c,&use_sprite);
use_sprite=(use_sprite & 128)==0;
{ sprite_area *base;
sprite_area *rombase;
sprite_pixtrans transtab[16];
sprite_info sinfo;
sprite_id sid;
int dummy;
BOOL use_sprite;
BOOL scaled = FALSE;
char name[NAME_LIMIT + 1];
/* Test tiling disabled in CMOS */
os_byte (161, (dummy = DesktopFeaturesCMOS, &dummy), &use_sprite);
use_sprite = (use_sprite & desktopwindowtile) == 0;
if (use_sprite)
{
// find sprite for mode
_swix(Wimp_BaseOfSprites,_OUTR(0,1),&rombase,&base);
sprintf(name,"tile_1-%d",1<<bbc_vduvar(bbc_Log2BPP));
if (_swix(OS_SpriteOp,_INR(0,2) | _OUT(2),0x100+24,base,name,&address))
{
if (_swix(OS_SpriteOp,_INR(0,2) | _OUT(2),0x100+24,rombase,name,&address))
use_sprite=0;
base=rombase;
{ /* Find tile sprite for mode */
os_swix2r (Wimp_BaseOfSprites, 0, 0, &rombase, &base);
sprintf (name, "tile_1-%d", 1<<bbc_vduvar (bbc_Log2BPP));
sid.s.name = name;
sid.tag = sprite_id_name;
if (sprite_readsize (base, &sid, &sinfo) != NULL)
{ if (sprite_readsize (rombase, &sid, &sinfo) != NULL)
use_sprite = 0;
base = rombase;
}
if (bbc_vduvar (bbc_Log2BPP) != bbc_modevar (sinfo.mode, bbc_Log2BPP))
{ scaled = TRUE;
if (wimp_readpixtrans (base, &sid, NULL, transtab) != NULL)
use_sprite = 0;
}
}
if (use_sprite)
{
int spriteop=0x200+34;
char* transtab=0;
char pixtranstab[16];
_swix(OS_SpriteOp,_INR(0,2) | _OUTR(3,4),40+0x200,base,address,&width,&height);
width<<=bbc_modevar(address->mode,bbc_XEigFactor);
height<<=bbc_modevar(address->mode,bbc_YEigFactor);
{ int left, top;
if (bbc_vduvar(bbc_Log2BPP)!=bbc_modevar(address->mode,bbc_Log2BPP))
{
spriteop=0x200+52;
transtab=pixtranstab;
_swix(Wimp_ReadPixTrans,_INR(0,2) | _INR(6,7),0x200,base,address,0,transtab);
}
/* Adjust for eigen factors */
sinfo.width <<= bbc_vduvar (bbc_XEigFactor);
sinfo.height <<= bbc_vduvar (bbc_YEigFactor);
left=WORKAREA_TO_SCREEN_X(rds,0);
left=left+(((left-rds->g.x0)/width)*width);
top=WORKAREA_TO_SCREEN_Y(rds,0);
top=top-(((top-rds->g.y1)/height)*height);
left = WORKAREA_TO_SCREEN_X(rds, 0);
left = left + (((left - rds->g.x0)/sinfo.width) * sinfo.width);
top = WORKAREA_TO_SCREEN_Y(rds, 0);
top = top - (((top - rds->g.y1)/sinfo.height) * sinfo.height);
//werr(0,"%d %d %d %d %d",left,bottom,width,height,rds->g.y0 );
/*werr(0, "%d %d %d %d %d", left, top, width, height, rds->g.y0);*/
for (;top>rds->g.y0;top-=height)
{
int x;
for (x=left;x<rds->g.x1;x+=width)
{
use_sprite=!_swix(OS_SpriteOp,_INR(0,7),spriteop,base,address,x,top-height,0,0,transtab);
for (; top>rds->g.y0; top -= sinfo.height)
{ 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);
else
use_sprite = (sprite_put_given (base, &sid, 0, x, top - sinfo.height) == NULL);
if (!use_sprite) break;
}
}
}
if (!use_sprite)
{
_swix(ColourTrans_SetGCOL,_IN(0) | _INR(3,4),0xdfdfdf00,0x80,0) /* background_colour */;
bbc_clg();
return;
}
{ wimp_paletteword palette_grey;
palette_grey.word = (int)0xdfdfdf00; /* background_colour */
wimpt_noerr (colourtran_setGCOL (palette_grey, 1 << 7, 0, &dummy));
bbc_clg ();
}
}
os_error *main_read_pixel (sprite_area *area, sprite_id *id,
int x, int y, sprite_colour *colour)
/*This routine is used instead of sprite_readpixel, which is badly
broken under Medusa. J R C 24th Feb 1994*/
{ os_error *error = NULL;
os_regset reg_set;
int pal_size;
sprite_header *header;
/*This routine is used instead of sprite_readpixel, which is badly
broken under Medusa. J R C 24th Feb 1994*/
reg_set.r [0] = 37 /*create/remove palette*/;
if (id->tag == sprite_id_addr)
......@@ -391,56 +355,97 @@ static int mouseB (void)
return r.r[2];
}
static void main_icon_bboxes(main_window* window,main_sprite* sprite,wimp_box* iniconbbox,
wimp_box* spritebbox,wimp_box* namebbox)
{
int swidth,sheight;
int width;
static sprite_header *main_make_newjpeg (sprite_area *area, int size, jpeg_info *info)
{ sprite_header *header;
int log2bpp = bbc_modevar (-1, bbc_Log2BPP);
area->size = size + sizeof (sprite_area);
area->number = 1;
area->sproff = 16;
area->freeoff = size + sizeof (sprite_area);
header = (sprite_header *)((char *)area + sizeof (sprite_area));
header->next = size;
strcpy (header->name, "!newjpeg");
header->width = ((info->width << log2bpp) - 1)/32;
header->height = info->height - 1;
header->lbit = 0;
header->rbit = (info->width << log2bpp) - 32 * header->width - 1;
header->image =
header->mask = sizeof (sprite_header) +
(log2bpp <= 3 ? 8 << (1 << log2bpp) : 0);
header->mode = log2bpp + 1 << 27 | 180/wimpt_dy () << 14 |
180/wimpt_dx () << 1 | 1;
return header;
}
static os_error *main_plot_fromjpeg (sprite_area *area, sprite_header *header, jpeg_id *jid)
{ os_error *error;
int s1, s2, s3;
/* Switch to sprite, plot the JPEG */
error = os_swix4r (OS_SpriteOp, 0x23C, area, header, 0,
NULL, &s1, &s2, &s3);
if (error != NULL) return error;
error = jpeg_put_scaled (jid, 0, 0, NULL,
jpeg_PUT_DITHER_ENABLE | jpeg_PUT_ERROR_DIFFUSED_DITHER);
/* Unconditionally switch back */
os_swix4 (OS_SpriteOp, 0x23C, s1, s2, s3);
return error;
}
static void main_icon_bboxes (main_window *window, main_sprite *sprite, wimp_box *iniconbbox,
wimp_box *spritebbox, wimp_box *namebbox)
{ /* Return the bounding boxes for this sprite */
psprite_info sinfo;
psprite_read_full_info (sprite, &sinfo);
_swix(Wimp_TextOp,_INR(0,2) | _OUT(0),1,sinfo.name,0,&width);
width+=16;
swidth=sinfo.width*sprite->iconsize.scale_xmul/sprite->iconsize.scale_xdiv;
swidth=swidth*sprite->mode.scale_xmul;
sheight=sinfo.height*sprite->iconsize.scale_ymul/sprite->iconsize.scale_ydiv;
sheight=sheight*sprite->mode.scale_ymul;
if (namebbox != NULL)
{ int width;
os_swix3r (Wimp_TextOp, 1, sinfo.name, 0, &width, NULL, NULL);
width += 16;
if (window->data->file.fullinfo)
{
if (spritebbox)
{
spritebbox->x0 = iniconbbox->x0 + main_FILER_Border/2;
spritebbox->x1 = spritebbox->x0 + swidth;
spritebbox->y0 = iniconbbox->y0 + main_FILER_Border/2;
spritebbox->y1 = spritebbox->y0 + sheight;
}
if (namebbox)
{
namebbox->x0 = iniconbbox->x0 + 6*main_FILER_TextWidth;
{ namebbox->x0 = iniconbbox->x0 + 6*main_FILER_TextWidth;
namebbox->x1 = namebbox->x0 + width;
namebbox->y0 = iniconbbox->y0 + main_FILER_TextHeight;
namebbox->y1 = namebbox->y0 + main_FILER_TextHeight;
}
else
{ namebbox->x0 = (iniconbbox->x0 + iniconbbox->x1 - width)/2;
namebbox->x1 = namebbox->x0 + width;
namebbox->y0 = iniconbbox->y0;
namebbox->y1 = namebbox->y0 + main_FILER_TextHeight;
}
}
if (spritebbox != NULL)
{ int swidth, sheight;
swidth = sinfo.width * sprite->iconsize.scale_xmul/sprite->iconsize.scale_xdiv;
swidth = swidth * sprite->mode.scale_xmul;
sheight = sinfo.height * sprite->iconsize.scale_ymul/sprite->iconsize.scale_ydiv;
sheight = sheight * sprite->mode.scale_ymul;
if (window->data->file.fullinfo)
{ spritebbox->x0 = iniconbbox->x0 + main_FILER_Border/2;
spritebbox->x1 = spritebbox->x0 + swidth;
spritebbox->y0 = iniconbbox->y0 + main_FILER_Border/2;
spritebbox->y1 = spritebbox->y0 + sheight;
}
else
{
if (spritebbox)
{
spritebbox->x0 = (iniconbbox->x0 + iniconbbox->x1-swidth)/2;
{ spritebbox->x0 = (iniconbbox->x0 + iniconbbox->x1-swidth)/2;
spritebbox->x1 = spritebbox->x0 + swidth;
spritebbox->y0 = iniconbbox->y1 - (main_FILER_Border + main_FILER_YSize + sheight)/2;
spritebbox->y1 = spritebbox->y0 + sheight;
}
if (namebbox)
{
namebbox->x0 = (iniconbbox->x0 + iniconbbox->x1 - width)/2;
namebbox->x1 = namebbox->x0 + width;
namebbox->y0 = iniconbbox->y0;
namebbox->y1 = namebbox->y0 + main_FILER_TextHeight;
}
}
}
......@@ -460,8 +465,7 @@ void main_iprintf (int flags, int x, int y, char *format, ...)
if (flags & wimp_IFONT)
width = 16*strlen (s);
else
{
_swix(Wimp_TextOp,_INR(0,2) | _OUT(0),1,s,0,&width);
{ os_swix3r (Wimp_TextOp, 1, s, 0, &width, NULL, NULL);
width/=2;
width+=8;
}
......@@ -482,7 +486,6 @@ void main_iprintf (int flags, int x, int y, char *format, ...)
icon.box.y0 = y - main_FILER_TextHeight;
icon.box.y1 = y;
icon.flags = (wimp_iconflags) (flags | wimp_ITEXT | wimp_INDIRECT | 7 << 24);
icon.data.indirecttext.buffer = s;
icon.data.indirecttext.validstring = (char *) -1;
......@@ -490,7 +493,10 @@ void main_iprintf (int flags, int x, int y, char *format, ...)
wimpt_noerr (wimp_ploticon (&icon));
}
static int escape (void) {return bbc_inkey (-113) || bbc_inkey (-45);}
static int escape (void)
{ return bbc_inkey (-113) || bbc_inkey (-45);
}
/******************************************
* Snapshot functions - external for *
......@@ -615,7 +621,7 @@ static void snapshot_happysnapper (int x0, int y0, int x1, int y1)
/* Create a translation table. If you don't do this, you get
fatal overwriting on saving the screen area to the printer
*/
ftracef0 ("calling psprite_ttab_for_sprite()\n");
ftracef0 ("calling psprite_ttab_for_sprite ()\n");
if ((tempsprite.transtab = psprite_ttab_for_sprite (&tempsprite,
-1, (int *) -1)) == NULL)
{ error = main_error ("PntEG");
......@@ -645,9 +651,9 @@ finish:
}
static void Timer_Cb (dbox d, void *h)
/*Callback for timer events - the only one is Cancel.*/
{ ftracef0 ("Timer_Cb\n");
{ /*Callback for timer events - the only one is Cancel.*/
ftracef0 ("Timer_Cb\n");
h = h;
switch (dbox_get (d))
......@@ -663,12 +669,13 @@ static void Timer_Cb (dbox d, void *h)
dbox_dispose (&sshot.timer);
sshot.timer = NULL;
break;
} }
}
}
static void Snapshot_Cb (int due, void *h)
/*Callback for the second timer, ending in a call to take the snapshot.*/
{ int time_now, time_left, secs_left;
{ /*Callback for the second timer, ending in a call to take the snapshot.*/
int time_now, time_left, secs_left;
ftracef0 ("Snapshot_Cb\n");
due = due, h = h; /*for Norcroft*/
......@@ -713,7 +720,8 @@ static void Snapshot_Cb (int due, void *h)
{ /*Kill it.*/
dbox_dispose (&sshot.timer);
sshot.timer = NULL;
} }
}
}
if (secs_left == 0)
{ /*Smile for the camera.*/
......@@ -886,7 +894,7 @@ static int ramfetch_buffer_extender (char **buffer, int *size)
static BOOL ramtransfer_file (wimp_msgdatasave *ms)
{ int size, import = -1, file_type, s1, s2, s3, sprite_size, width, height,
{ int size, import = -1, file_type, sprite_size,
ram_size, log2_bpp = bbc_modevar (-1, bbc_Log2BPP);
sprite_area *area;
sprite_header *header;
......@@ -894,8 +902,8 @@ static BOOL ramtransfer_file (wimp_msgdatasave *ms)
ftracef0 ("ramtransfer_file\n");
/*only interested in sprites*/
/*and jpeg's. J R C 27th Jun 1994*/
if (!((file_type = xferrecv_checkimport (&size)) == SPRITE_FILE ||
file_type == jpeg_FILE_TYPE))
if (!((file_type = xferrecv_checkimport (&size)) == FileType_Sprite ||
file_type == FileType_JPEG))
{ werr (FALSE, msgs_lookup ("PntEB"), ms->leaf);
return FALSE;
}
......@@ -924,111 +932,85 @@ static BOOL ramtransfer_file (wimp_msgdatasave *ms)
return FALSE;
}
if (file_type == jpeg_FILE_TYPE)
{ /*For JPEG's, we find it convenient to read the file data into
if (file_type == FileType_JPEG)
{ jpeg_id jid;
jpeg_info jinfo;
/*For JPEG's, we find it convenient to read the file data into
|ramfetch_buffer| (since that is how ramfetch_buffer_extender() is set
up), then read the consequent sprite size, malloc that much space,
paint the sprite and copy it back into |ramfetch_buffer|.*/
ram_size = flex_size ((flex_ptr) &ramfetch_buffer);
#ifdef XTRACE
{ char cmd [1024];
#ifdef XTRACE
{ char cmd [128];
sprintf (cmd, "%%Save $.JPEG %X +%X", ramfetch_buffer, ram_size);
os_cli (cmd);
}
#endif
#endif
if (wimpt_complain (xjpeginfo_dimensions
((jpeg_image *) &ramfetch_buffer [12], ram_size, NULL, &width,
&height, NULL, NULL)) != NULL)
jid.s.image.addr = ramfetch_buffer;
jid.s.image.size = ram_size;
jid.tag = jpeg_id_addr;
if (wimpt_complain (jpeg_readinfo (&jid, &jinfo)) != NULL)
{ flex_free ((flex_ptr) &ramfetch_buffer);
return FALSE;
}
sprite_size = psprite_size (width, height, wimpt_mode (), /*mask?*/ FALSE,
2 /*full palette*/);
sprite_size = psprite_size (jinfo.width, jinfo.height, wimpt_mode (),
FALSE /*mask?*/, 2 /*full palette*/);
if ((area = m_ALLOC (sprite_size + 16)) == NULL)
if ((area = m_ALLOC (sprite_size + sizeof (sprite_area))) == NULL)
{ flex_free ((flex_ptr) &ramfetch_buffer);
return FALSE;
}
/*... redirect output into 'area + 16' ...*/
area->size = sprite_size + 16;
area->number = 1;
area->sproff = 16;
area->freeoff = sprite_size + 16;
/*Create an empty sprite called '!newjpeg' in area*/
header = main_make_newjpeg(area, sprite_size, &jinfo);
header = (sprite_header *) ((char *) area + 16);
header->next = sprite_size;
strcpy (header->name, "!newjpeg");
header->width = ((width << log2_bpp) - 1)/32;
header->height = height - 1;
header->lbit = 0;
header->rbit = (width << log2_bpp) - 32*header->width - 1;
header->image =
header->mask = sizeof (sprite_header) +
(log2_bpp <= 3? 8 << (1 << log2_bpp): 0);
header->mode = log2_bpp + 1 << 27 | 180/wimpt_dy () << 14 |
180/wimpt_dx () << 1 | 1;
/*Set the name with a sprite op to get the case right.*/
if (wimpt_complain (_swix (OS_SpriteOp, _IN(0)|_IN(1)|_IN(2)|_IN(3),
0x1A | 512, area, header, ms->leaf)) != NULL)
if (wimpt_complain (os_swix4 (OS_SpriteOp, 0x1A | 512,
area, header, ms->leaf)) != NULL)
return -1;
ftracef5 ("SPRITE %.12s: mode 0x%X, width %d + 1 words, height %d + "
"1 pixels, rbit %d\n", header->name, header->mode, header->width,
header->height, header->rbit);
ftracef5 ("SPRITE %.12s: mode 0x%X, width %d words, height %d pixels, rbit %d\n",
header->name, header->mode, 1 + header->width, 1 + header->height,
header->rbit);
if (log2_bpp <= 3)
/*Set the sprite's palette to be the same as the screen one. JRC 6th Feb
1995.*/
if (wimpt_complain (_swix (ColourTrans_ReadPalette,
_IN(0)|_IN(1)|_IN(2)|_IN(3)|_IN(4), -1, -1, header + 1,
8 << (1 << log2_bpp), 1 << 1)) != NULL)
{ m_FREE (area, sprite_size + 16);
if (wimpt_complain (os_swix5 (ColourTrans_ReadPalette, -1, -1,
header + 1, 8 << (1 << log2_bpp), 1 << 1)) != NULL)
{ m_FREE (area, sprite_size + sizeof (sprite_area));
flex_free ((flex_ptr) &ramfetch_buffer);
return FALSE;
}
if (wimpt_complain (_swix (OS_SpriteOp,
_IN(0)|_IN(1)|_IN(2)|_IN(3)|_OUT(1)|_OUT(2)|_OUT(3),
0x23C, area, header, 0, &s1, &s2, &s3)) != NULL)
{ m_FREE (area, sprite_size + 16);
jid.s.image.addr = ramfetch_buffer; /*Might have shifted*/
if (wimpt_complain (main_plot_fromjpeg (area, header, &jid)) != NULL)
{ m_FREE (area, sprite_size + sizeof (sprite_area));
flex_free ((flex_ptr) &ramfetch_buffer);
return FALSE;
}
if (wimpt_complain (xjpeg_plot_scaled ((jpeg_image *) &ramfetch_buffer [12],
0, 0, NULL, ram_size, jpeg_SCALE_DITHERED | jpeg_SCALE_ERROR_DIFFUSED)) != NULL)
{ m_FREE (area, sprite_size + 16);
if (!flex_extend ((flex_ptr) &ramfetch_buffer, sprite_size + sizeof (sprite_area)))
{ m_FREE (area, sprite_size + sizeof (sprite_area));
flex_free ((flex_ptr) &ramfetch_buffer);
return FALSE;
}
/*... direct output back ...*/
if (wimpt_complain (_swix (OS_SpriteOp, _IN(0)|_IN(1)|_IN(2)|_IN(3),
0x23C, s1, s2, s3)) != NULL)
{ m_FREE (area, sprite_size + 16);
flex_free ((flex_ptr) &ramfetch_buffer);
return FALSE;
}
if (!flex_extend ((flex_ptr) &ramfetch_buffer, sprite_size + 12))
{ m_FREE (area, sprite_size + 16);
flex_free ((flex_ptr) &ramfetch_buffer);
return FALSE;
}
memcpy (ramfetch_buffer, (char *) area + 4, sprite_size + 12);
#ifdef XTRACE
{ char cmd [1024];
sprintf (cmd, "%%Save $.Sprite %X +%X", ramfetch_buffer,
sprite_size + 12);
/*Make it look like a sprite file by trimming off 4 bytes*/
memcpy (ramfetch_buffer, &area->number,
sprite_size + sizeof (sprite_area) - sizeof (area->size));
#ifdef XTRACE
{ char cmd [128];
sprintf (cmd, "%%Save $.Sprite %X +%X", &area->size,
sprite_size + sizeof (sprite_area) - sizeof (area->size));
os_cli (cmd);
}
#endif
#endif
m_FREE (area, sprite_size + 16);
m_FREE (area, sprite_size + sizeof (sprite_area));
}
return TRUE;
......@@ -1045,9 +1027,9 @@ void main_force_redraw (wimp_w handle)
ftracef0 ("main_force_redraw\n");
rds.w = handle;
rds.box = main_big_extent;
ftracef0("do wimp_force_redraw\n");
ftracef0 ("do wimp_force_redraw\n");
wimpt_noerr (wimp_force_redraw (&rds));
ftracef0("done\n");
ftracef0 ("done\n");
}
/************************************+**
......@@ -1071,7 +1053,7 @@ void main_set_extent (main_window *window)
x = main_FILER_TotalWidth, y = main_FILER_TotalHeight;
curr.w = window->handle;
wimpt_noerr (PaintLib_get_wind_info (&curr));
wimpt_noerr (paintlib_get_wind_info (&curr));
nsprites = window->data->file.spritearea->number;
ftracef1 ("main_set_extent: %d sprites across\n", nsprites);
......@@ -1120,7 +1102,7 @@ void main_set_extent (main_window *window)
wimpt_noerr (wimp_set_extent (&newext));
curr.w = window->handle;
wimpt_noerr (PaintLib_get_wind_info (&curr));
wimpt_noerr (paintlib_get_wind_info (&curr));
ftracef0 ("Really resetting\n");
wimpt_noerr (wimp_open_wind ((wimp_openstr *) &curr));
......@@ -1131,7 +1113,8 @@ void main_set_extent (main_window *window)
window->data->file.lastwidth = no_across; /*avoid ghastly flicker. J R C
18th Oct 1993*/
} }
}
}
/**************************
* *
......@@ -1151,7 +1134,7 @@ void main_window_delete (main_window *thiswindow)
{ main_window *window = (main_window *) &main_windows;
AltRename_delete();
altrename_delete ();
ftracef2 ("main_window_delete: killing %s window: %d\n",
thiswindow->tag == main_window_is_file? "file": "sprite",
......@@ -1168,7 +1151,8 @@ void main_window_delete (main_window *thiswindow)
sizeof (main_sprite_window));
m_FREE (thiswindow, sizeof (main_window));
win_activedec ();
} }
}
}
/**************************
* File window killer *
......@@ -1178,34 +1162,27 @@ static void delete_file_window (main_window *window)
{ main_sprite *sprite;
main_file *file = &window->data->file;
int loop=0,count=0;
int loop = 0, count = 0;
ftracef0 ("delete_file_window\n");
/* First copy all their pointers into an array */
for (sprite=file->sprites;sprite!=NULL;sprite=sprite->link)
{
for (sprite = file->sprites; sprite != NULL; sprite = sprite->link)
count++;
}
main_sprite *todelete[count];
for (sprite=file->sprites;sprite!=NULL;sprite=sprite->link)
{
todelete[loop] = sprite;
if (count)
{ main_sprite *todelete[count];
/* First copy all their pointers into an array */
for (sprite = file->sprites; sprite != NULL; sprite = sprite->link)
{ todelete[loop] = sprite;
loop++;
}
#if 1
/* And delete all the pointers in the array backwards,faster */
for (loop=count-1; loop != -1; loop--)
#else
/* And delete all the pointers in the array forwards,slow */
for (loop=0; loop<count; loop++)
#endif
{
psprite_delete (window,todelete[loop]);
}
/* Delete all the pointers in the array backwards (flex faster) */
for (loop=count-1;loop>=0;loop--)
psprite_delete (window, todelete[loop]);
ftracef0 ("deleted all sprite blocks\n");
}
flex_free ((flex_ptr) &file->spritearea);
if (file->filename != NULL) flex_free ((flex_ptr) &file->filename);
......@@ -1325,23 +1302,23 @@ void main_check_position (main_window *w)
static int Load_File (main_window *window, char *filename, int merge,
int safe)
/*Copes with JPEGs now. J R C 24th Jun 1994*/
{ int rc = 1, i = 0, offset, ramcopy = filename == (char *) -1,
temp_file = !(safe || xferrecv_file_is_safe ()), file_type = SPRITE_FILE,
sprite_size, width, height, s1, s2, s3,
temp_file = !(safe || xferrecv_file_is_safe ()), file_type = FileType_Sprite,
sprite_size,
log2_bpp = bbc_modevar (-1, bbc_Log2BPP);
os_filestr filestr;
main_sprite *sprite, **sprptr;
sprite_header *header;
main_file *file = &window->data->file;
wimp_winfo curr;
jpeg_id jid;
jpeg_info jinfo;
if (window->selection.flags & MW_SELSAVING) return 0;
ftracef0 ("Load_File\n");
AltRename_delete();
altrename_delete ();
ftracef4 ("Asked to %s %s %s into window 0x%X\n",
merge? "merge": "load",
......@@ -1364,10 +1341,11 @@ static int Load_File (main_window *window, char *filename, int merge,
}
file_type = (filestr.loadaddr & 0xFFF00) >> 8;
if (!(file_type == SPRITE_FILE || file_type == jpeg_FILE_TYPE))
if (!(file_type == FileType_Sprite || file_type == FileType_JPEG))
{ werr (FALSE, msgs_lookup ("PntEB"), filename);
return 0; /* failed */
} }
}
}
else
filestr.start = flex_size ((flex_ptr) &ramfetch_buffer);
......@@ -1383,94 +1361,72 @@ static int Load_File (main_window *window, char *filename, int merge,
{ if (!flex_extend ((flex_ptr) &file->filename, strlen (filename) + 1))
{ main_NO_ROOM ("extended file title");
return -1;
} } }
}
}
}
/*If ramcopy or merge, read the stuff to be loaded into ramfetch_buffer
(already there if ramcopy). Otherwise (filecopy and not merge), just make
sure that file->spritearea is big enough to load the file into.*/
if (!ramcopy)
{ /*Copying from a file.*/
if (file_type == SPRITE_FILE)
if (file_type == FileType_Sprite)
sprite_size = filestr.start - 12;
else
{ if (wimpt_complain (xjpegfileinfo_dimensions (filename, NULL, &width,
&height, NULL, NULL)))
{ jid.s.name = filename;
jid.tag = jpeg_id_name;
if (wimpt_complain (jpeg_readinfo (&jid, &jinfo)))
return 0;
ftracef2 ("JPEG info: %d x %d\n", width, height);
ftracef2 ("JPEG info: %d x %d\n", jinfo.width, jinfo.height);
sprite_size = psprite_size (width, height, wimpt_mode (), /*mask?*/ FALSE,
2 /*full palette*/);
sprite_size = psprite_size (jinfo.width, jinfo.height, wimpt_mode (),
FALSE /*mask?*/, 2 /*full palette*/);
}
if (merge)
{ /*filecopy && merge*/
ftracef0 ("allocate ram buffer for file\n");
if (!flex_alloc ((flex_ptr) &ramfetch_buffer, sprite_size + 16))
if (!flex_alloc ((flex_ptr) &ramfetch_buffer, sprite_size + sizeof (sprite_area)))
{ werr (FALSE, msgs_lookup ("PntEG"));
return -1;
}
ftracef0 ("load file into ram buffer\n");
if (file_type == SPRITE_FILE)
{ ftracef1 ("writing size (%d) at front of buffer\n", sprite_size + 16);
*(int *) ramfetch_buffer = sprite_size + 16;
if (file_type == FileType_Sprite)
{ ftracef1 ("writing size (%d) at front of buffer\n", sprite_size + sizeof (sprite_area));
*(int *) ramfetch_buffer = sprite_size + sizeof (sprite_area);
/* convert into sprite area */
if (wimpt_complain (sprite_area_load
((sprite_area *) ramfetch_buffer, filename)))
{ flex_free ((flex_ptr) &ramfetch_buffer);
return -1;
} }
}
}
else
{ char *cc;
/*... redirect output into 'file->spritearea + 16' ...*/
((int *) ramfetch_buffer) [0] = sprite_size + 16;
((int *) ramfetch_buffer) [1] = 1;
((int *) ramfetch_buffer) [2] = 16;
((int *) ramfetch_buffer) [3] = sprite_size + 16;
header = (sprite_header *) ((char *) ramfetch_buffer + 16);
header->next = sprite_size;
strcpy (header->name, "!newjpeg");
header->width = ((width << log2_bpp) - 1)/32;
header->height = height - 1;
header->lbit = 0;
header->rbit = (width << log2_bpp) - 32*header->width - 1;
header->image =
header->mask = sizeof (sprite_header) +
(log2_bpp <= 3? 8 << (1 << log2_bpp): 0);
header->mode = log2_bpp + 1 << 27 | 180/wimpt_dy () << 14 |
180/wimpt_dx () << 1 | 1;
/*Create an empty sprite called '!newjpeg' in ramfetch_buffer*/
header = main_make_newjpeg((sprite_area *)ramfetch_buffer, sprite_size, &jinfo);
/*Set the name with a sprite op to get the case right.*/
if (wimpt_complain (_swix (OS_SpriteOp, _IN(0)|_IN(1)|_IN(2)|_IN(3),
0x1A | 512, file->spritearea, header, (cc = strrchr (filename,
'.')) != NULL || (cc = strrchr (filename, ':')) != NULL? cc + 1:
"jpeg")) != NULL)
if (wimpt_complain (os_swix4 (OS_SpriteOp, 0x1A | 512,
file->spritearea, header,
(cc = strrchr (filename, '.')) != NULL ||
(cc = strrchr (filename, ':')) != NULL ? cc + 1 : "jpeg")) != NULL)
return -1;
ftracef5 ("SPRITE %.12s: mode 0x%X, width %d + 1 words, height %d + "
"1 pixels, rbit %d\n", header->name, header->mode, header->width,
header->height, header->rbit);
ftracef5 ("SPRITE %.12s: mode 0x%X, width %d words, height %d pixels, rbit %d\n",
header->name, header->mode, 1 + header->width, 1 + header->height,
header->rbit);
if (log2_bpp <= 3)
/*Set the sprite's palette to be the same as the screen one. JRC 6th
Feb 1995.*/
if (wimpt_complain (_swix (ColourTrans_ReadPalette,
_IN(0)|_IN(1)|_IN(2)|_IN(3)|_IN(4), -1, -1, header + 1,
8 << (1 << log2_bpp), 1 << 1)) != NULL)
return -1;
if (wimpt_complain (_swix (OS_SpriteOp,
_IN(0)|_IN(1)|_IN(2)|_IN(3)|_OUT(1)|_OUT(2)|_OUT(3),
0x23C, ramfetch_buffer, header, 0, &s1, &s2, &s3)) != NULL)
if (wimpt_complain (os_swix5 (ColourTrans_ReadPalette, -1, -1,
header + 1, 8 << (1 << log2_bpp), 1 << 1)) != NULL)
return -1;
if (wimpt_complain (xjpeg_plot_file_scaled (filename, 0, 0, NULL,
jpeg_SCALE_DITHERED | jpeg_SCALE_ERROR_DIFFUSED)) != NULL)
return -1;
/*... direct output back ...*/
if (wimpt_complain (_swix (OS_SpriteOp, _IN(0)|_IN(1)|_IN(2)|_IN(3),
0x23C, s1, s2, s3)) != NULL)
if (wimpt_complain (main_plot_fromjpeg ((sprite_area *)ramfetch_buffer, header, &jid)) != NULL)
return -1;
rc = 1;
......@@ -1478,13 +1434,13 @@ static int Load_File (main_window *window, char *filename, int merge,
}
else
{ /*filecopy && !merge*/
if (!menus_ensure_size (&file->spritearea, sprite_size + 16))
if (!menus_ensure_size (&file->spritearea, sprite_size + sizeof (sprite_area)))
{ werr (FALSE, msgs_lookup ("PntEG"));
return -1;
}
ftracef0 ("initialise sprite area\n");
sprite_area_initialise (file->spritearea, sprite_size + 16);
sprite_area_initialise (file->spritearea, sprite_size + sizeof (sprite_area));
}
}
else /*ramcopy - file contents already converted to sprite*/
......@@ -1496,13 +1452,12 @@ static int Load_File (main_window *window, char *filename, int merge,
return -1;
}
ftracef1 ("writing size (%d) at front of buffer\n", sprite_size + 16);
*(int *) ramfetch_buffer = sprite_size + 16;
ftracef1 ("writing size (%d) at front of buffer\n", sprite_size + sizeof (sprite_area));
*(int *) ramfetch_buffer = sprite_size + sizeof (sprite_area);
/* convert into sprite area */
ftracef0 ("verify area ...\n"); /*J R C 18th Nov 1994*/
if (wimpt_complain (_swix (OS_SpriteOp, _IN(0)|_IN(1), 512 | 17,
ramfetch_buffer)))
if (wimpt_complain (os_swix2 (OS_SpriteOp, 512 | 17, ramfetch_buffer)))
{ ftracef0 ("area invalid\n");
return NULL;
}
......@@ -1511,7 +1466,7 @@ static int Load_File (main_window *window, char *filename, int merge,
if (ramcopy || merge)
{ ftracef0 ("copy all the ram sprites across\n");
rc = psprite_merge_area (window,file, (sprite_area **) &ramfetch_buffer)? 1:
rc = psprite_merge_area (window, file, (sprite_area **) &ramfetch_buffer)? 1:
-1;
flex_free ((flex_ptr) &ramfetch_buffer);
}
......@@ -1525,13 +1480,12 @@ static int Load_File (main_window *window, char *filename, int merge,
ftracef2 ("Load_File: loading \"%s\" into area 0x%X\n",
filename, file->spritearea);
if (file_type == SPRITE_FILE)
if (file_type == FileType_Sprite)
{ if (wimpt_complain (sprite_area_load (file->spritearea, filename)))
return NULL;
ftracef0 ("verify area ...\n"); /*J R C 7th Nov 1994*/
if (wimpt_complain (_swix (OS_SpriteOp, _IN(0)|_IN(1), 512 | 17,
file->spritearea)))
if (wimpt_complain (os_swix2 (OS_SpriteOp, 512 | 17, file->spritearea)))
{ ftracef0 ("area invalid\n");
return NULL;
}
......@@ -1540,53 +1494,27 @@ static int Load_File (main_window *window, char *filename, int merge,
else
{ char *cc;
/*... redirect output into 'file->spritearea + 16' ...*/
file->spritearea->number = 1;
file->spritearea->sproff = 16;
file->spritearea->freeoff = sprite_size + 16;
/*Create an empty sprite called '!newjpeg' in file->spritearea*/
header = main_make_newjpeg(file->spritearea, sprite_size, &jinfo);
header = (sprite_header *) ((int) file->spritearea + 16);
header->next = sprite_size;
strcpy (header->name, "!newjpeg");
header->width = ((width << log2_bpp) - 1)/32;
header->height = height - 1;
header->lbit = 0;
header->rbit = (width << log2_bpp) - 32*header->width - 1;
header->image =
header->mask = sizeof (sprite_header) +
(log2_bpp <= 3? 8 << (1 << log2_bpp): 0);
header->mode = log2_bpp + 1 << 27 | 180/wimpt_dy () << 14 |
180/wimpt_dx () << 1 | 1;
/*Set the name with a sprite op to get the case right.*/
if (wimpt_complain (_swix (OS_SpriteOp, _IN(0)|_IN(1)|_IN(2)|_IN(3),
0x1A | 512, file->spritearea, header, (cc = strrchr (filename,
'.')) != NULL || (cc = strrchr (filename, ':')) != NULL? cc + 1:
"jpeg")) != NULL)
if (wimpt_complain (os_swix4 (OS_SpriteOp, 0x1A | 512,
file->spritearea, header,
(cc = strrchr (filename, '.')) != NULL ||
(cc = strrchr (filename, ':')) != NULL ? cc + 1 : "jpeg")) != NULL)
return -1;
ftracef5 ("SPRITE %.12s: mode 0x%X, width %d + 1 words, height %d + "
"1 pixels, rbit %d\n", header->name, header->mode, header->width,
header->height, header->rbit);
ftracef5 ("SPRITE %.12s: mode 0x%X, width %d words, height %d pixels, rbit %d\n",
header->name, header->mode, 1 + header->width, 1 + header->height,
header->rbit);
if (log2_bpp <= 3)
/*Set the sprite's palette to be the same as the screen one. JRC 6th
Feb 1995.*/
if (wimpt_complain (_swix (ColourTrans_ReadPalette,
_IN(0)|_IN(1)|_IN(2)|_IN(3)|_IN(4), -1, -1, header + 1,
8 << (1 << log2_bpp), 1 << 1)) != NULL)
rc = -1;
if (wimpt_complain (_swix (OS_SpriteOp,
_IN(0)|_IN(1)|_IN(2)|_IN(3)|_OUT(1)|_OUT(2)|_OUT(3),
0x23C, file->spritearea, header, 0, &s1, &s2, &s3)) != NULL)
rc = -1;
if (wimpt_complain (xjpeg_plot_file_scaled (filename, 0, 0, NULL,
jpeg_SCALE_DITHERED | jpeg_SCALE_ERROR_DIFFUSED)) != NULL)
if (wimpt_complain (os_swix5 (ColourTrans_ReadPalette, -1, -1,
header + 1, 8 << (1 << log2_bpp), 1 << 1)) != NULL)
rc = -1;
/*... direct output back ...*/
if (wimpt_complain (_swix (OS_SpriteOp, _IN(0)|_IN(1)|_IN(2)|_IN(3),
0x23C, s1, s2, s3)) != NULL)
if (wimpt_complain (main_plot_fromjpeg (file->spritearea, header, &jid)) != NULL)
rc = -1;
}
......@@ -1603,7 +1531,8 @@ static int Load_File (main_window *window, char *filename, int merge,
}
sprptr = &(*sprptr)->link; /* keep at end of list */
} }
}
}
if (merge) main_set_modified (file);
psprite_set_plot_info (file);
......@@ -1612,7 +1541,7 @@ static int Load_File (main_window *window, char *filename, int merge,
/* now shrink box if not enough sprites to fill it */
curr.w = window->handle;
wimpt_noerr (PaintLib_get_wind_info (&curr));
wimpt_noerr (paintlib_get_wind_info (&curr));
if (curr.info.box.x1-curr.info.box.x0 >
file->spritearea->number*main_FILER_TotalWidth)
{ curr.info.box.x1 = curr.info.box.x0 +
......@@ -1633,7 +1562,7 @@ static int Load_File (main_window *window, char *filename, int merge,
main_set_extent (window);
for (sprite = file->sprites ; sprite != NULL; sprite = sprite->link)
for (sprite = file->sprites; sprite != NULL; sprite = sprite->link)
{ main_sprite_window *sprw;
for (sprw = sprite->windows; sprw != NULL; sprw = sprw->link)
......@@ -1648,9 +1577,9 @@ static int Load_File (main_window *window, char *filename, int merge,
return rc;
}
static void main_draw_icon(main_window* window,main_sprite* sprite,int x0,int y0,wimp_redrawstr* rds)
{
sprite_info infoblock;
static void main_draw_icon (main_window *window, main_sprite *sprite, int x0, int y0, wimp_redrawstr *rds)
{ sprite_info infoblock;
int sx, sy;
psprite_info sinfo;
......@@ -1741,19 +1670,20 @@ static void main_draw_icon(main_window* window,main_sprite* sprite,int x0,int y0
}
/* bbox in work area coords */
static void main_update_icon(main_window* window,main_sprite* sprite,wimp_box* bbox)
{
wimp_redrawstr ds;
static void main_update_icon (main_window *window, main_sprite *sprite, wimp_box *bbox)
{ wimp_redrawstr ds;
int more;
os_error* e;
ds.w=window->handle;
ds.box=*bbox;
os_error *e;
ds.w = window->handle;
ds.box = *bbox;
/* just redraw area containing higlighted parts in fullinfo to reduce flicker */
if (window->data->file.fullinfo) ds.box.x1=ds.box.x0+20*main_FILER_TextWidth;
for (e=wimp_update_wind(&ds,&more);!e && more;e=wimp_get_rectangle(&ds,&more))
{
main_clear_background(&ds);
main_draw_icon(window,sprite,bbox->x0,bbox->y0,&ds);
if (window->data->file.fullinfo) ds.box.x1 = ds.box.x0+20*main_FILER_TextWidth;
for (e = wimp_update_wind(&ds,&more); !e && more; e = wimp_get_rectangle(&ds, &more))
{ main_clear_background (&ds);
main_draw_icon(window, sprite, bbox->x0, bbox->y0, &ds);
}
}
......@@ -1761,246 +1691,225 @@ static void main_update_icon(main_window* window,main_sprite* sprite,wimp_box* b
* selections *
********************************************************/
typedef enum
{
SI_SELECT,
{ SI_SELECT,
SI_CLEAR,
SI_TOGGLE
} select_icon_how;
static void main_select_icon(main_window* window,main_sprite* sprite,wimp_box* iconbbox,select_icon_how how)
{
switch (how)
{
case SI_CLEAR: /* clear */
static void main_select_icon(main_window *window, main_sprite *sprite, wimp_box *iconbbox, select_icon_how how)
{ switch (how)
{ case SI_CLEAR: /* clear */
if (sprite->flags & MSF_SELECTED)
{
sprite->flags &= ~MSF_SELECTED;
{ sprite->flags &= ~MSF_SELECTED;
window->selection.count--;
main_update_icon(window,sprite,iconbbox);
main_update_icon (window, sprite, iconbbox);
}
break;
case SI_SELECT: /* set */
if (!(sprite->flags & MSF_SELECTED))
{
sprite->flags |= MSF_SELECTED;
{ sprite->flags |= MSF_SELECTED;
window->selection.count++;
main_update_icon(window,sprite,iconbbox);
main_update_icon (window, sprite, iconbbox);
}
break;
case SI_TOGGLE: /* toggle */
if (sprite->flags & MSF_SELECTED)
{
sprite->flags &= ~MSF_SELECTED;
{ sprite->flags &= ~MSF_SELECTED;
window->selection.count--;
main_update_icon(window,sprite,iconbbox);
main_update_icon (window, sprite, iconbbox);
}
else
{
sprite->flags |= MSF_SELECTED;
{ sprite->flags |= MSF_SELECTED;
window->selection.count++;
main_update_icon(window,sprite,iconbbox);
main_update_icon (window, sprite, iconbbox);
}
}
}
#define MIN_TARGET_SIZE 64
static void ensure_min_target_size(wimp_box* bbox,int fullinfo)
{
if (bbox->x1-bbox->x0 < MIN_TARGET_SIZE)
{
if (!fullinfo) bbox->x0=(bbox->x0+bbox->x1-MIN_TARGET_SIZE)/2;
static void ensure_min_target_size(wimp_box *bbox, int fullinfo)
{ if (bbox->x1-bbox->x0 < MIN_TARGET_SIZE)
{ if (!fullinfo) bbox->x0=(bbox->x0+bbox->x1-MIN_TARGET_SIZE)/2;
bbox->x1=bbox->x0+MIN_TARGET_SIZE;
}
if (bbox->y1-bbox->y0 < MIN_TARGET_SIZE)
{
if (!fullinfo) bbox->y0=(bbox->y0+bbox->y1-MIN_TARGET_SIZE)/2;
{ if (!fullinfo) bbox->y0=(bbox->y0+bbox->y1-MIN_TARGET_SIZE)/2;
bbox->y1=bbox->y0+MIN_TARGET_SIZE;
}
}
/* clip area in work area coords */
static void main_clear_selection(main_window *window,wimp_box* clip,select_icon_how how)
{
static wimp_box defclip = {0,-0x7f000000,0x7f000000,0};
static void main_clear_selection (main_window *window, wimp_box *clip, select_icon_how how)
{ static wimp_box defclip = {0, -0x7f000000, 0x7f000000, 0};
wimp_box bbox;
main_sprite *sprite;
int width,height;
int width, height;
wimp_wstate ws;
int column,spritesperrow;
int left,top;
int column, spritesperrow;
int left, top;
if (!window || (window->selection.count==0 && how == SI_CLEAR )) return;
if (!window || (window->selection.count==0 && how == SI_CLEAR)) return;
if (!clip) clip=&defclip;
if (!clip) clip = &defclip;
if (window->data->file.fullinfo)
{
width = main_FILER_FullInfoWidth;
{ width = main_FILER_FullInfoWidth;
height = main_FILER_FullInfoHeight;
}
else
{
width = main_FILER_TotalWidth;
{ width = main_FILER_TotalWidth;
height = main_FILER_TotalHeight;
}
wimpt_noerr (wimp_get_wind_state (window->handle, &ws));
spritesperrow = (ws.o.box.x1 - ws.o.box.x0) / width;
if (spritesperrow == 0)
spritesperrow = 1;
column=0;
left=0;
top=0;
for (sprite=window->data->file.sprites;sprite != NULL; sprite = sprite->link)
{
if (main_CLIPS(clip,left,top-height, left+width,top))
{
int is_over_graphic=1;
bbox.x0=left;
bbox.x1=left+width;
bbox.y0=top-height;
bbox.y1=top;
column = 0;
left = 0;
top = 0;
for (sprite = window->data->file.sprites; sprite != NULL; sprite = sprite->link)
{ if (main_CLIPS(clip, left, top-height, left+width, top))
{ int is_over_graphic = 1;
bbox.x0 = left;
bbox.x1 = left + width;
bbox.y0 = top - height;
bbox.y1 = top;
if (bbox.x0<clip->x0 || bbox.x1>clip->x1 || bbox.y0<clip->y0 || bbox.y1>clip->y1)
{
wimp_box spritebbox;
{ wimp_box spritebbox;
wimp_box namebbox;
main_icon_bboxes(window,sprite,&bbox,&spritebbox,&namebbox);
main_icon_bboxes(window, sprite, &bbox, &spritebbox, &namebbox);
ensure_min_target_size(&spritebbox,window->data->file.fullinfo);
ensure_min_target_size(&spritebbox, window->data->file.fullinfo);
is_over_graphic=0;
if (main_CLIPS(&spritebbox,clip->x0,clip->y0,clip->x1,clip->y1) ||
main_CLIPS(&namebbox,clip->x0,clip->y0,clip->x1,clip->y1)) is_over_graphic=1;
is_over_graphic = 0;
if (main_CLIPS(&spritebbox, clip->x0, clip->y0, clip->x1, clip->y1) ||
main_CLIPS(&namebbox, clip->x0, clip->y0, clip->x1, clip->y1))
is_over_graphic = 1;
}
if (is_over_graphic)
main_select_icon(window,sprite,&bbox,how);
main_select_icon(window, sprite, &bbox, how);
}
column++;
left+=width;
if (column==spritesperrow)
{
column=0;
left=0;
top-=height;
left += width;
if (column == spritesperrow)
{ column = 0;
left = 0;
top -= height;
}
}
}
void main_select_all(main_window* window)
{
main_clear_selection(window,0,SI_SELECT);
void main_select_all (main_window *window)
{ main_clear_selection (window, 0, SI_SELECT);
}
void main_clear_all(main_window* window)
{
main_clear_selection(window,0,SI_CLEAR);
void main_clear_all (main_window *window)
{ main_clear_selection (window, 0, SI_CLEAR);
}
static BOOL main_select_area(wimp_eventstr* event, void *handle)
{
wimp_wstate ws;
static BOOL main_select_area (wimp_eventstr *event, void *handle)
{ wimp_wstate ws;
wimp_box clip;
main_window* window = (main_window*)handle;
if (event->e != wimp_EUSERDRAG) return 0;
win_remove_unknown_event_processor(main_select_area,handle);
_swix(Wimp_AutoScroll,_IN(0),0);
wimp_get_wind_state(window->handle,&ws);
clip.x0=SCREEN_TO_WORKAREA_X(&ws,MIN(event->data.dragbox.x0,event->data.dragbox.x1));
clip.x1=SCREEN_TO_WORKAREA_X(&ws,MAX(event->data.dragbox.x0,event->data.dragbox.x1));
clip.y0=SCREEN_TO_WORKAREA_Y(&ws,MIN(event->data.dragbox.y0,event->data.dragbox.y1));
clip.y1=SCREEN_TO_WORKAREA_Y(&ws,MAX(event->data.dragbox.y0,event->data.dragbox.y1));
main_clear_selection(window,&clip,(window->selection.flags & MW_SELDRAGRIGHT )?SI_TOGGLE:SI_SELECT);
main_window *window = (main_window *)handle;
return 1;
if (event->e != wimp_EUSERDRAG) return FALSE;
win_remove_unknown_event_processor (main_select_area, handle);
os_swix1 (Wimp_AutoScroll, 0);
wimp_get_wind_state (window->handle, &ws);
clip.x0 = SCREEN_TO_WORKAREA_X(&ws, MIN(event->data.dragbox.x0, event->data.dragbox.x1));
clip.x1 = SCREEN_TO_WORKAREA_X(&ws, MAX(event->data.dragbox.x0, event->data.dragbox.x1));
clip.y0 = SCREEN_TO_WORKAREA_Y(&ws, MIN(event->data.dragbox.y0, event->data.dragbox.y1));
clip.y1 = SCREEN_TO_WORKAREA_Y(&ws, MAX(event->data.dragbox.y0, event->data.dragbox.y1));
main_clear_selection (window, &clip, (window->selection.flags & MW_SELDRAGRIGHT) ? SI_TOGGLE : SI_SELECT);
return TRUE;
}
int main_selection_file_size(main_window* window)
{
main_sprite* sprite;
int size=0;
int main_selection_file_size (main_window *window)
{ main_sprite *sprite;
int size = 0;
if (!window || window->selection.count==0) return 0;
for (sprite=window->data->file.sprites;sprite != NULL; sprite = sprite->link)
{
if (sprite->flags & MSF_SELECTED)
{
sprite_header *spriteaddr = psprite_address (sprite);
size+=spriteaddr->next;
for (sprite = window->data->file.sprites; sprite != NULL; sprite = sprite->link)
{ if (sprite->flags & MSF_SELECTED)
{ sprite_header *spriteaddr = psprite_address (sprite);
size += spriteaddr->next;
}
}
return size+12;/* include file header size */
return size + sizeof (sprite_area) - sizeof (int);/* file size not area size */
}
static void main_save_finished(int at,void* handle)
{
main_window* window = (main_window*)handle;
static void main_save_finished (int at, void *arg)
{ main_window *window = (main_window *)arg;
at=at;
xfersend_clear_unknowns();
window->selection.flags &= ~MW_SELSAVING;
xfersend_clear_unknowns ();
if (window->selection.flags & MW_SELSAVEBYDRAG)
main_clear_selection (window, 0, SI_CLEAR);
window->selection.flags &= ~(MW_SELSAVING | MW_SELSAVEBYDRAG);
}
BOOL main_save_selection(char* filename,void* handle)
{
main_window* window = (main_window*)handle;
main_sprite* sprite;
FILE* file;
_kernel_oserror* err=0;
BOOL main_save_selection (char *filename, void *arg)
{ main_window *window = (main_window *)arg;
main_sprite *sprite;
int file;
os_error *err;
struct
{
int num_of_sprites;
{ int num_of_sprites;
int offset_to_first;
int offset_to_free;
} header;
if (window->selection.count==0 || !filename) return 0;
if (window->selection.count==0 || !filename) return FALSE;
header.num_of_sprites=window->selection.count;
header.offset_to_first=16;
header.offset_to_free=main_selection_file_size(window)+4;
if (header.offset_to_free<=16) return 0;
header.num_of_sprites = window->selection.count;
header.offset_to_first = sizeof (sprite_area);
header.offset_to_free = main_selection_file_size (window) + 4;
if (header.offset_to_free <= sizeof (sprite_area)) return FALSE;
file=fopen(filename,"wb");
if (!file)
{
wimpt_complain(_kernel_last_oserror());
return 0;
}
visdelay_begin ();
if (wimpt_complain (os_swix2r (OS_Find, 0x83, filename, &file, NULL)) != NULL)
return FALSE;
fwrite(&header,sizeof(header),1,file);
for (sprite=window->data->file.sprites;sprite != NULL; sprite = sprite->link)
{
if (sprite->flags & MSF_SELECTED)
{
sprite_header *spriteaddr = psprite_address (sprite);
fwrite(spriteaddr,spriteaddr->next,1,file);
err = os_swix4 (OS_GBPB, 2, file, &header, sizeof (header));
if (err == NULL)
{ for (sprite = window->data->file.sprites; sprite != NULL; sprite = sprite->link)
{ if (sprite->flags & MSF_SELECTED)
{ sprite_header *header = psprite_address (sprite);
err = os_swix4 (OS_GBPB, 2, file, header, header->next);
if (err != NULL) break;
}
}
}
if (ferror(file)) err=_kernel_last_oserror();
fclose(file);
os_swix2 (OS_Find, 0x00, file);
if (err)
{
wimpt_complain(err);
remove(filename);
return 0;
if (err != NULL)
{ wimpt_complain (err);
remove (filename);
return FALSE;
}
_swix(OS_File,_INR(0,2),18,filename,SPRITE_FILE); /* set file type*/
wimpt_complain (os_swix3 (OS_File, 18, filename, FileType_Sprite)); /* set file type*/
visdelay_end ();
alarm_set(alarm_timenow()+1,main_save_finished,window);
alarm_set (alarm_timenow ()+1, main_save_finished, window);
window->selection.flags |= MW_SELSAVING;
return 1;
}
static BOOL main_select_drag(wimp_eventstr* event, void *handle)
{
main_window* window = (main_window*)handle;
if (event->e != wimp_EUSERDRAG) return 0;
win_remove_unknown_event_processor(main_select_drag,handle);
xfersend(SPRITE_FILE,0,main_selection_file_size(window),main_save_selection,0,0,event,handle);
return 0;
return TRUE;
}
/********************************************************
......@@ -2008,27 +1917,25 @@ static BOOL main_select_drag(wimp_eventstr* event, void *handle)
********************************************************/
static main_sprite *main_pick_sprite_bbox (main_window *window,
wimp_mousestr *mouse, int* is_over_graphic,wimp_box* bbox)
wimp_mousestr *mouse, int *is_over_graphic, wimp_box *bbox)
{ wimp_wstate whereisit;
int spritesperrow, spritenumber;
main_sprite *sprite;
int x, y, width, height,mx,my;
int x, y, width, height, mx, my;
wimp_box dummy;
if (!bbox) bbox=&dummy;
ftracef2 ("main_pick sprite: (%d, %d)\n",mouse->x, mouse->y);
ftracef2 ("main_pick sprite: (%d, %d)\n", mouse->x, mouse->y);
wimpt_noerr (wimp_get_wind_state (window->handle, &whereisit));
if (window->data->file.fullinfo)
{
width = main_FILER_FullInfoWidth;
{ width = main_FILER_FullInfoWidth;
height = main_FILER_FullInfoHeight;
}
else
{
width = main_FILER_TotalWidth;
{ width = main_FILER_TotalWidth;
height = main_FILER_TotalHeight;
}
......@@ -2054,29 +1961,29 @@ static main_sprite *main_pick_sprite_bbox (main_window *window,
y /= height;
spritenumber = y * spritesperrow + x;
ftracef3 ("Sprite %d x %d, %d\n",x,y,spritenumber);
ftracef3 ("Sprite %d x %d, %d\n", x, y, spritenumber);
bbox->x0=x*width;
bbox->x1=bbox->x0+width-1;
bbox->y1=-y*height;
bbox->y0=bbox->y1-height;
bbox->x0 = x*width;
bbox->x1 = bbox->x0+width-1;
bbox->y1 = -y*height;
bbox->y0 = bbox->y1-height;
for (sprite=window->data->file.sprites;
spritenumber>0 && sprite != NULL;
spritenumber--, sprite = sprite->link);
if (sprite && is_over_graphic)
{
wimp_box spritebbox;
{ wimp_box spritebbox;
wimp_box namebbox;
main_icon_bboxes(window,sprite,bbox,&spritebbox,&namebbox);
ensure_min_target_size(&spritebbox,window->data->file.fullinfo);
main_icon_bboxes(window, sprite, bbox, &spritebbox, &namebbox);
ensure_min_target_size(&spritebbox, window->data->file.fullinfo);
*is_over_graphic=0;
if (main_CLIPS(&spritebbox,mx,my,mx,my))
if (main_CLIPS(&spritebbox, mx, my, mx, my))
*is_over_graphic=1;
else if (main_CLIPS(&namebbox,mx,my,mx,my))
else if (main_CLIPS(&namebbox, mx, my, mx, my))
*is_over_graphic=2;
}
......@@ -2084,36 +1991,33 @@ static main_sprite *main_pick_sprite_bbox (main_window *window,
}
/* returns work area of all bounding boxes */
/* wimp_box* may be 0 if not required */
BOOL main_get_all_sprite_bboxes (main_window *window,main_sprite* sprite,
wimp_box* bbox,wimp_box* spritebbox,
wimp_box* namebbox)
/* bboxes may be 0 if not required */
BOOL main_get_all_sprite_bboxes (main_window *window, main_sprite *sprite,
wimp_box *bbox, wimp_box *spritebbox,
wimp_box *namebbox)
{ wimp_wstate ws;
int spritesperrow, spritenumber;
main_sprite *sp;
int x, y, width, height;
wimp_box dummy;
if (!bbox) bbox=&dummy;
if (!window || !sprite) return 0;
if (!bbox) bbox = &dummy;
for (spritenumber=0,sp=window->data->file.sprites;
sp != sprite;
spritenumber++, sp = sp->link)
if (!window || !sprite) return FALSE;
if (!sp) return 0;
for (spritenumber = 0, sp = window->data->file.sprites;
sp != sprite; spritenumber++, sp = sp->link)
if (!sp) return FALSE;
wimpt_noerr (wimp_get_wind_state (window->handle, &ws));
if (window->data->file.fullinfo)
{
width = main_FILER_FullInfoWidth;
{ width = main_FILER_FullInfoWidth;
height = main_FILER_FullInfoHeight;
}
else
{
width = main_FILER_TotalWidth;
{ width = main_FILER_TotalWidth;
height = main_FILER_TotalHeight;
}
......@@ -2124,50 +2028,50 @@ BOOL main_get_all_sprite_bboxes (main_window *window,main_sprite* sprite,
x = spritenumber % spritesperrow;
y = spritenumber / spritesperrow;
bbox->x0=x*width;
bbox->x1=bbox->x0+width-1;
bbox->y1=-y*height;
bbox->y0=bbox->y1-height;
bbox->x0 = x * width;
bbox->x1 = bbox->x0 + width-1;
bbox->y1 = -y * height;
bbox->y0 = bbox->y1 - height;
main_icon_bboxes(window,sprite,bbox,spritebbox,namebbox);
main_icon_bboxes(window, sprite, bbox, spritebbox, namebbox);
return 1;
return TRUE;
}
static main_sprite *main_pick_sprite (main_window *window, wimp_mousestr *mouse)
{
int is_in_graphic;
main_sprite* sprite=main_pick_sprite_bbox(window,mouse,&is_in_graphic,0);
return (sprite && is_in_graphic)?sprite:0;
{ int is_in_graphic;
main_sprite *sprite = main_pick_sprite_bbox (window, mouse, &is_in_graphic, 0);
return (sprite && is_in_graphic) ? sprite : 0;
}
main_sprite *main_pick_menu_button_sprite (main_window *window)
{
if (window->selection.count==0)
{
int is_in_graphic;
{ if (window->selection.count==0)
{ int is_in_graphic;
wimp_mousestr mouse;
main_sprite* sprite;
main_sprite *sprite;
wimp_box bbox;
wimpt_noerr (wimp_get_point_info (&mouse));
sprite=main_pick_sprite_bbox(window,&mouse,&is_in_graphic,&bbox);
sprite = main_pick_sprite_bbox(window, &mouse, &is_in_graphic,&bbox);
if (!sprite || !is_in_graphic) return 0;
main_select_icon(window,sprite,&bbox,SI_SELECT);
main_select_icon (window, sprite, &bbox, SI_SELECT);
return sprite;
}
if (window->selection.count==1)
{
main_sprite* sprite;
for (sprite=window->data->file.sprites;sprite;sprite=sprite->link)
{
if (sprite->flags & MSF_SELECTED) break;
{ main_sprite *sprite;
for (sprite = window->data->file.sprites; sprite != NULL; sprite = sprite->link)
{ if (sprite->flags & MSF_SELECTED)
break;
}
return sprite;
}
return 0;
return NULL;
}
/***************************************************************************
* *
* Window event handler for sprite file windows. *
......@@ -2178,7 +2082,7 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
{ main_window *window = (main_window *) handle;
if (AltRename_claim_event(e,window)) return;
if (altrename_claim_event (e, window)) return;
ftracef0 ("spritefile_event_handler\n");
/*if (!help_process (e))*/ {switch (e->e)
......@@ -2187,7 +2091,7 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
main_set_extent (window);
break;
case wimp_ESCROLL: // use wimp_escroll to make mousewheel work (Colin Granville)
case wimp_ESCROLL: /* use wimp_escroll to make mousewheel work (Colin Granville) */
if (e->data.scroll.x || e->data.scroll.y)
{
switch (e->data.scroll.x)
......@@ -2243,7 +2147,7 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
int spritex = -1, spritey = 0;
int x0, y0, x1, y1;
main_clear_background(&rds);
main_clear_background (&rds);
#if SPACE_FOR_HELP_TEXT != 0
x0 = rds.box.x0 - rds.scx;
......@@ -2263,7 +2167,7 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
}
#endif
for (; currsprite != NULL ; currsprite = currsprite->link)
for (; currsprite != NULL; currsprite = currsprite->link)
{ if (++spritex == spritesperline) spritex = 0, spritey++;
ftracef2 ("x %d, y %d\n", spritex, spritey);
......@@ -2278,7 +2182,7 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
y0 + rds.box.y1 - rds.scy,
x1 + rds.box.x0 - rds.scx,
y1 + rds.box.y1 - rds.scy))
main_draw_icon(window,currsprite,x0,y0,&rds);
main_draw_icon (window, currsprite, x0, y0, &rds);
}
#if TRACE
......@@ -2292,17 +2196,15 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
case wimp_EBUT:
if (bbc_inkey(-3) || bbc_inkey(-4))
{
/* alt pressed */
if (bbc_inkey (-3) || bbc_inkey (-4))
{ /* alt pressed */
if (e->data.but.m.bbits & (wimp_BCLICKLEFT | wimp_BCLICKRIGHT))
{
int is_over_graphic;
main_sprite *sprite = main_pick_sprite_bbox (window, &e->data.but.m,&is_over_graphic,0);
{ int is_over_graphic;
main_sprite *sprite = main_pick_sprite_bbox (window, &e->data.but.m, &is_over_graphic, 0);
if (sprite && is_over_graphic==2 && (e->data.but.m.bbits & wimp_BCLICKLEFT))
{
/* alt click over name */
AltRename_start(window,sprite);
altrename_start (window, sprite);
break;
}
}
......@@ -2310,8 +2212,7 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
}
if (e->data.but.m.bbits & 4)
{ main_sprite *sprite =
main_pick_sprite (window, &e->data.but.m);
{ main_sprite *sprite = main_pick_sprite (window, &e->data.but.m);
if (sprite != NULL)
{ /*Check sprite has a valid mode. JRC 14 June 1990*/
......@@ -2323,6 +2224,7 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
}
sprwindow_new (sprite);
main_clear_selection (window, 0, SI_CLEAR);
if (main_current_options.tools.show_tools)
toolwindow_display (FALSE);
}
......@@ -2332,77 +2234,109 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
}
}
else if (e->data.but.m.bbits & (wimp_BCLICKLEFT | wimp_BCLICKRIGHT))
{
wimp_redrawstr rds;
{ wimp_redrawstr rds;
int is_over_graphic;
main_sprite *sprite = main_pick_sprite_bbox (window, &e->data.but.m,&is_over_graphic,&rds.box);
main_sprite *sprite = main_pick_sprite_bbox (window, &e->data.but.m, &is_over_graphic, &rds.box);
if (e->data.but.m.bbits & wimp_BCLICKLEFT)
{
if (sprite && is_over_graphic && (sprite->flags & MSF_SELECTED)) break;
if (sprite == NULL || !is_over_graphic)
{
main_clear_selection(window,0,SI_CLEAR);
{ main_clear_selection (window, 0, SI_CLEAR);
break;
}
if (window->selection.count==0)
{
main_select_icon(window,sprite,&rds.box,SI_SELECT);
{ main_select_icon (window, sprite, &rds.box, SI_SELECT);
break;
}
if (!(sprite->flags & MSF_SELECTED))
{
main_clear_selection(window,0,SI_CLEAR);
main_select_icon(window,sprite,&rds.box,SI_SELECT);
{ main_clear_selection (window, 0, SI_CLEAR);
main_select_icon (window, sprite, &rds.box, SI_SELECT);
break;
}
}
else
{
{ /* else right click */
if (sprite && is_over_graphic)
main_select_icon(window,sprite,&rds.box,SI_TOGGLE);
main_select_icon (window, sprite, &rds.box, SI_TOGGLE);
}
}
else if (e->data.but.m.bbits & (wimp_BDRAGLEFT | wimp_BDRAGRIGHT))
{
wimp_redrawstr rds;
{ wimp_redrawstr rds;
int is_over_graphic;
main_sprite *sprite = main_pick_sprite_bbox (window, &e->data.but.m,&is_over_graphic,&rds.box);
main_sprite *sprite = main_pick_sprite_bbox (window, &e->data.but.m, &is_over_graphic, &rds.box);
if (sprite && is_over_graphic)
{
main_select_icon(window,sprite,&rds.box,SI_SELECT);
{ wimp_icreate create;
wimp_icon icon;
wimp_wstate ws;
static const char iconfile[] = "file_ff9";
static const char iconfiles[] = "package";
wimp_i iconhandle;
int width, height;
if (window->selection.count)
{
wimp_box box;
box.x0=e->data.but.m.x-17;
box.x1=e->data.but.m.x+17;
box.y0=e->data.but.m.y-17;
box.y1=e->data.but.m.y+17;
if (_swix(DragASprite_Start,_INR(0,3),1 | (1<<2) | (1<<6) | (1<<7),1,"file_ff9",&box)) break;
win_add_unknown_event_processor(main_select_drag,window);
/* Read where the window where the click was is */
wimpt_noerr (wimp_get_wind_state (e->data.but.m.w, &ws));
/* Bounding box is filer thumbnail size */
if (window->data->file.fullinfo)
{ width = main_FILER_XSize/2;
height = main_FILER_YSize/2;
}
else
{ width = main_FILER_XSize;
height = main_FILER_YSize;
}
/* Convert mouse to window offset coordinates */
icon.box.x0 = e->data.but.m.x - (ws.o.box.x0 - ws.o.x) - (width/2);
icon.box.y0 = e->data.but.m.y - (ws.o.box.y1 - ws.o.y) - (height/2);
icon.box.x1 = icon.box.x0 + width;
icon.box.y1 = icon.box.y0 + height;
/* Create an icon and add it to the window */
icon.flags = wimp_ISPRITE | wimp_INDIRECT;
icon.data.indirectsprite.name = window->selection.count > 1 ? (char *)iconfiles :
(char *)iconfile;
icon.data.indirectsprite.spritearea = (sprite_area *)1;
icon.data.indirectsprite.nameisname = strlen(icon.data.indirectsprite.name);
create.w = e->data.but.m.w;
create.i = icon;
wimpt_noerr (wimp_create_icon (&create, &iconhandle));
/* Pretend the event came from that icon which allows it to be
picked up by DragASprite */
e->data.but.m.i = iconhandle;
/* Start the xfersend */
xfersend (FileType_Sprite, msgs_lookup ("PntG6"),
main_selection_file_size(window),
main_save_selection, 0, 0, e, window);
/* Denote this as a drag save rather than menu save */
window->selection.flags |= MW_SELSAVEBYDRAG;
/* Finished with the icon */
wimpt_noerr (wimp_delete_icon(create.w, iconhandle));
}
else
{
wimp_dragstr drag;
{ wimp_dragstr drag;
wimp_wstate ws;
struct
{
int window_handle;
struct {int left,bottom,right,top;}pause_zone;
struct {int left, bottom, right, top;} pause_zone;
int pause_duration;
int handler;
void* handle;
void *handle;
} scroll;
wimp_get_wind_state(window->handle,&ws);
wimp_get_wind_state (window->handle, &ws);
drag.window=window->handle;
drag.type=wimp_USER_RUBBER;
......@@ -2411,7 +2345,7 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
drag.parent=ws.o.box;
drag.parent.y1=0x7f000000;
drag.parent.y0=-0x7f000000;
_swix(Wimp_DragBox,_INR(1,3),&drag,*(int*)"TASK",3);
os_swix4 (Wimp_DragBox, 0, &drag, *(int *)"TASK", 3);
scroll.window_handle=window->handle;
scroll.pause_zone.left=0;
......@@ -2421,18 +2355,18 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
scroll.pause_duration=0;
scroll.handler=1;
scroll.handle=0;
_swix(Wimp_AutoScroll,_INR(0,1),2,&scroll);
os_swix2 (Wimp_AutoScroll, 2, &scroll);
window->selection.flags &= ~MW_SELDRAGRIGHT;
if (e->data.but.m.bbits & wimp_BDRAGRIGHT);
if (e->data.but.m.bbits & wimp_BDRAGRIGHT)
window->selection.flags |= MW_SELDRAGRIGHT;
win_add_unknown_event_processor(main_select_area,window);
win_add_unknown_event_processor (main_select_area, window);
}
}
break;
case wimp_ECLOSE:
{ main_file *file = &window->data->file;
dboxquery_close_REPLY delete = dboxquery_close_SAVE;
dboxquery_close_REPLY action = dboxquery_close_SAVE;
/* Deal with ADJUST clicks on the close box */
int shifted = akbd_pollsh ();
wimp_mousestr m;
......@@ -2449,9 +2383,9 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
sprintf (mess,
msgs_lookup (file->filename == NULL ? "PntF2" : "PntF3"),
file->filename);
delete = dboxquery_close (mess);
if (delete == dboxquery_close_SAVE)
if (!menus_save_file (window, 1)) delete = dboxquery_close_CANCEL;
action = dboxquery_close (mess);
if (action == dboxquery_close_SAVE)
if (!menus_save_file (window, 1)) action = dboxquery_close_CANCEL;
}
if ((m.bbits & wimp_BRIGHT) != 0)
......@@ -2461,20 +2395,22 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
while (i > 0 && file->filename[i] != '.') i--;
if (i > 0)
{ char a[255];
{ char a[FILENAMEMAX + 1];
file->filename[i] = 0;
sprintf (a, "filer_opendir %s", file->filename);
wimpt_complain (os_cli (a));
file->filename[i] = '.';
} }
}
}
if (shifted) break; /* don't close if SHIFT down */
}
if (delete != dboxquery_close_CANCEL)
if (action != dboxquery_close_CANCEL)
{ delete_file_window (window);
toolwindow_close ();
} }
}
}
break;
case wimp_ESEND:
......@@ -2493,7 +2429,7 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
int type;
type = xferrecv_checkinsert (&name); /* sets up reply */
if (type == SPRITE_FILE || type == jpeg_FILE_TYPE)
if (type == FileType_Sprite || type == FileType_JPEG)
{ int ok;
ftracef1 ("Loading file \"%s\"\n", name);
visdelay_begin ();
......@@ -2501,7 +2437,8 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
visdelay_end ();
if (ok > 0) xferrecv_insertfileok ();
ftracef0 ("file merged\n");
} }
}
}
break;
case wimp_MHELPREQUEST:
......@@ -2511,13 +2448,13 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
break;
default:
ftracef1 ("Got file message %d\n",e->data.msg.hdr.action);
ftracef1 ("Got file message %d\n", e->data.msg.hdr.action);
break;
}
break;
default:
ftracef1 ("File window event %d\n",e->e);
ftracef1 ("File window event %d\n", e->e);
break;
}
}
......@@ -2532,11 +2469,11 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
static void load_template (wimp_template *wt, char *name, wimp_wind *buf)
{ char namebuff [256]; /*have to copy it because Neil will piss off the end
{ char namebuff [FILENAMEMAX + 1]; /*have to copy it because Neil will piss off the end
of the given string */
ftracef0 ("load_template\n");
strcpy (namebuff,name);
strcpy (namebuff, name);
ftracef2 ("Load template '%s': %p\n", name, buf);
wt->buf = buf;
......@@ -2567,20 +2504,6 @@ static void load_resources (void)
{ wimp_template wt;
/* OSS All redundant now. And quite why Paint opens its Templates file
twice is beyond me!
char tname[256];
ftracef1 ("load_resources: ourname %s\n", our_name);
res_init (our_name);
if (!res_findname ("Templates",tname))
werr (TRUE, msgs_lookup ("PntEF"));
wimpt_noerr (wimp_open_template (tname));
*/
ftracef0 ("load_resources\n");
wimpt_noerr (wimp_open_template ("Paint:Templates"));
......@@ -2593,7 +2516,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, "SpriteFile", &File_Template.t);
load_template (&wt, "SpriteFile", &file_template.t);
/*Use radioon, radiooff, opton, optoff from WIMP pool. JRC*/
template_syshandle ("create")->spritearea = (void *) 1;
......@@ -2665,15 +2588,11 @@ static main_window *New_Window (BOOL open)
ftracef1 ("New_Window: open %s\n", WHETHER (open));
#ifndef NOEXAMPLE
never_been_kissed = 0;
#endif
if ((window = m_ALLOC (sizeof (main_window))) == NULL)
{ main_NO_ROOM ("new file window block");
return NULL;
}
ftracef1 ("New file window, descriptor at %p\n",window);
ftracef1 ("New file window, descriptor at %p\n", window);
if ((file = m_ALLOC (sizeof (main_file))) == NULL)
{ m_FREE (window, sizeof (main_window));
......@@ -2681,7 +2600,7 @@ static main_window *New_Window (BOOL open)
return NULL;
}
wind = File_Template.t;
wind = file_template.t;
wind.scx = wind.scy = 0;
wind.minsize = 0x00010001;
wind.ex = main_big_extent;
......@@ -2784,13 +2703,9 @@ static void main_iconclick (wimp_i iconno)
{ main_window *wind;
ftracef0 ("main_iconclick\n");
#ifndef NOEXAMPLE
char name[256];
int nbk = never_been_kissed;
#endif
iconno = iconno;
ftracef1 ("main_iconclick %d\n",iconno);
ftracef1 ("main_iconclick %d\n", iconno);
if ((wind = New_Window (FALSE)) != NULL)
{ main_set_extent (wind);
main_check_position (wind);
......@@ -2808,9 +2723,8 @@ static void main_iconclick (wimp_i iconno)
static char *write_options (void)
/*Translate main_current_options to string (in static space).*/
{ static char buffer [MAX_OPTIONS + 1];
{ /*Translate main_current_options to string (in static space).*/
static char buffer [MAX_OPTIONS + 1];
int len;
main_options *opt = &main_current_options;
main_options *opt0 = &initial_options;
......@@ -2888,10 +2802,10 @@ static void New_File (char *name)
if (name != (char *) -1)
/* must acknowledge message or we'll get an error */
xferrecv_insertfileok();
xferrecv_insertfileok ();
if (ok > 0)
{ main_check_position(w);
{ main_check_position (w);
if (w->data->file.spritearea->number == 1 &&
/*Don't attempt sprites with illegal modes. JRC 21st Nov 1994*/
bbc_modevar
......@@ -2901,7 +2815,7 @@ static void New_File (char *name)
sprwindow_new (w->data->file.sprites);
}
else
delete_file_window(w);
delete_file_window (w);
}
}
......@@ -2943,10 +2857,9 @@ static void print_file (char *name)
void main_set_printer_data (void)
/*Now only updates menus_print_where if the bottom left origin has changed*/
{ print_pagesizestr ps;
/*Now only updates menus_print_where if the bottom left origin has changed*/
ftracef0 ("set printer_data\n");
if (!print_pagesize (&ps))
{ if ((menus_print_last_where.dx != ps.bbox.x0) ||
......@@ -2969,7 +2882,7 @@ static void set_icon (wimp_w w, wimp_i i, char *buffer, int size)
/*A-RO-???? JRC 25 Sep 1991*/
if (wimpt_complain (wimp_get_icon_info (w, i, &wi)) != NULL)
return;
memcpy (wi.data.indirecttext.buffer,buffer,size);
memcpy (wi.data.indirecttext.buffer, buffer, size);
r.w = w;
r.box = wi.box;
wimpt_complain (wimp_force_redraw (&r));
......@@ -2982,9 +2895,9 @@ static void Background_Events (wimp_eventstr *e, void *handle)
handle = handle; /* avoid not used warning */
#if TRACE
ftracef1 ("Got Icon bar event %d\n",e->e);
ftracef1 ("Got Icon bar event %d\n", e->e);
if (e->e == 17 || e->e == 18)
ftracef1 ("Got Wimp Message %d\n",e->data.msg.hdr.action);
ftracef1 ("Got Wimp Message %d\n", e->data.msg.hdr.action);
#endif
switch (e->e)
......@@ -3050,11 +2963,11 @@ static void Background_Events (wimp_eventstr *e, void *handle)
break;
case wimp_MDATAOPEN:
if (e->data.msg.data.dataopen.type != SPRITE_FILE) break;
if (e->data.msg.data.dataopen.type != FileType_Sprite) break;
/*Fall through*/
case wimp_MDATALOAD:
ftracef1("wimp_DATALOAD %s\n", e->data.msg.data.dataload.name);
ftracef1 ("wimp_DATALOAD %s\n", e->data.msg.data.dataload.name);
New_File ((char *) &e->data.msg.data.dataload.name);
break;
......@@ -3064,7 +2977,7 @@ static void Background_Events (wimp_eventstr *e, void *handle)
ftracef0 ("Printer broadcast\n");
/*FIX G-RO-7139 17 Oct '91 We must print the file now, not
just queue it (was print_file (name);).*/
if (xferrecv_checkprint (&name) == SPRITE_FILE)
if (xferrecv_checkprint (&name) == FileType_Sprite)
{ main_window *w;
ftracef1 ("printing file \"%s\"\n", name);
......@@ -3104,34 +3017,9 @@ static void Background_Events (wimp_eventstr *e, void *handle)
ftracef1 ("Message %d\n", e->data.msg.hdr.action);
wimpt_checkmode ();
main_mode_flags = bbc_modevar (-1, bbc_ModeFlags);
if ((error = psprite_set_default_translations ()) != NULL)
goto changed;
#if 0
{ int tb_count;
main_ttab *tb;
extern main_ttab *tbchain;
tb_count = 0;
for (tb = tbchain; tb != NULL; tb = tb->link)
tb_count++;
werr (FALSE, "tb_count %d", tb_count);
}
#endif
#if 0
/*Drop all translation tables first, because otherwise an
out-of-date one can be picked up and never lost properly. J R C
10th Mar 1994*/
for (window = main_windows; window != NULL; window = window->link)
if (window->tag == main_window_is_file)
for (sprite = (&window->data->file)->sprites; sprite != NULL;
sprite = sprite->link)
psprite_drop_translation (&sprite->transtab);
#endif
for (window = main_windows; window != NULL; window = window->link)
if (window->tag == main_window_is_file)
{ if ((error = psprite_set_plot_info (&window->data->file)) !=
......@@ -3171,7 +3059,8 @@ static void Background_Events (wimp_eventstr *e, void *handle)
tools_text_ysize, 5);
set_icon (toolwindow_handle, tools_icons [7],
tools_text_xspace, 5);
} }
}
}
changed:
wimpt_noerr (error);
......@@ -3183,9 +3072,23 @@ static void Background_Events (wimp_eventstr *e, void *handle)
break;
case wimp_MHELPREQUEST:
{ main_window *window;
ftracef0 ("Help request on icon\n");
e->data.msg.data.helprequest.m.i = 0;
/*Look to see if this is a request to an adopted colour picker
window, if it's not just give generic 'This is paint' help */
for (window = main_windows; window != NULL; window = window->link)
if (window->tag == main_window_is_sprite)
{ if (window->data->sprite.sprite->colourhandle == e->data.msg.data.helprequest.m.w)
{ os_swix2 (ColourPicker_HelpReply, 0, &e->data);
break;
}
}
if (window == NULL)
{ e->data.msg.data.helprequest.m.i = 0;
main_help_message ("PntH5", e);
}
}
break;
case wimp_SAVEDESK:
......@@ -3226,7 +3129,8 @@ static void Background_Events (wimp_eventstr *e, void *handle)
sprite->colourdialogue = 0;
sprite->colourhandle = 0;
m_FREE (sprite->colourtitle, 23);
} }
}
}
os_swi2 (ColourPicker_CloseDialogue, 0, d);
main_current_options.colours.show_colours = FALSE;
......@@ -3249,15 +3153,16 @@ static void Background_Events (wimp_eventstr *e, void *handle)
colourpicker_COLOUR_TRANSPARENT) != 0)
sprite->gcol = colours_count (sprite);
else
{ int junk;
os_swi3r (ColourTrans_ReturnColourNumberForMode,
{ os_swi3r (ColourTrans_ReturnColourNumberForMode,
e->data.msg.data.words [2],
psprite_address (sprite)->mode, 0,
&sprite->gcol, &junk, &junk);
&sprite->gcol, NULL, NULL);
ftracef2 ("rgb is 0x%X => colour number 0x%X\n",
e->data.msg.data.words [2], sprite->gcol);
} } } }
}
}
}
}
break;
default:
......@@ -3270,9 +3175,8 @@ static void Background_Events (wimp_eventstr *e, void *handle)
static void read_options (void)
/*Sets main_current_options. Called only once, at startup. JRC*/
{ char buffer [MAX_OPTIONS + 1], *token, *options;
{ /*Sets main_current_options. Called only once, at startup. JRC*/
char buffer [MAX_OPTIONS + 1], *token, *options;
main_options *opt = &main_current_options;
/*name equivalence to save typing.*/
......@@ -3369,8 +3273,8 @@ static menu main_iconmenumaker (void *handle)
{ ftracef0 ("main_iconmenumaker\n");
handle = handle;
help_register_handler (&help_simplehandler, (void *) "ICONB");
menu_setflags (Main_Menu, i_GetScreen, FALSE, sshot.active);
return Main_Menu;
menu_setflags (main_menu, i_GetScreen, FALSE, sshot.active);
return main_menu;
}
/***************************************************************************
......@@ -3476,7 +3380,7 @@ int main (int argc, char *argv[])
res_init ("Paint");
/* OSS Read Messages file by explicit pathname. */
msgs_readfile("Paint:Messages");
msgs_readfile ("Paint:Messages");
wimpt_wimpversion (300);
wimpt_messages (Messages);
......@@ -3486,28 +3390,26 @@ int main (int argc, char *argv[])
heap_init (FALSE /* non-compacting */);
/* OSS Read Templates file by explicit pathname. */
template_readfile("Paint:Templates");
template_readfile ("Paint:Templates");
visdelay_init ();
dbox_init ();
/* OSS Read Sprites file by explicit name. */
resspr_readfile("Paint:Sprites");
resspr_readfile ("Paint:Sprites");
dboxquery_close (0);
dboxquery_quit (0); /* Reserves space */
alarm_init ();
#ifdef ModuleVersion
init_statics ();
#endif
baricon (msgs_lookup("BarIcon"), /* OSS Look sprite name up in Messages */
baricon (msgs_lookup ("BarIcon"), /* OSS Look sprite name up in Messages */
1 /*was (int) resspr_area (). JRC 14 June 1990*/,
main_iconclick);
#if 1
{ Main_Menu = menu_new (msgs_lookup ("Pnt00"), msgs_lookup ("PntMI"));
{ main_menu = menu_new (msgs_lookup ("Pnt00"), msgs_lookup ("PntMI"));
if (!event_attachmenumaker (win_ICONBAR, &main_iconmenumaker,
&menus_icon_proc, NULL))
......@@ -3516,21 +3418,21 @@ int main (int argc, char *argv[])
#else
if (!event_attachmenu (win_ICONBAR,
menu_new (msgs_lookup ("Pnt00"), msgs_lookup ("PntMI")),
menus_icon_proc,0))
menus_icon_proc, 0))
werr (TRUE, msgs_lookup ("PntEH"));
#endif
load_resources ();
nextx = startx = File_Template.t.box.x0;
nexty = starty = File_Template.t.box.y1;
nextx = startx = file_template.t.box.x0;
nexty = starty = file_template.t.box.y1;
/* set up a dummy window event handler to get icon messages */
win_register_event_handler (win_ICONBARLOAD, Background_Events, 0);
win_claim_unknown_events (win_ICONBARLOAD);
/*Add an unknown event handler for menu help messages.*/
win_add_unknown_event_processor (&Help_Process,NULL);
win_add_unknown_event_processor (&Help_Process, NULL);
/* Read Paint$Dir for desksaving */
os_read_var_val ("Paint$Dir", Paint_Dir, FILENAME_MAX);
......@@ -3577,20 +3479,21 @@ int main (int argc, char *argv[])
int f = 0;
BOOL reported = FALSE;
os_filestr file_str;
os_error error;
os_regset reg_set;
os_regset regs;
main_window *w;
_kernel_oserror *last_error;
char last_errmess [256];
_kernel_oserror error;
/*Remember the error first.*/
last_error = _kernel_last_oserror ();
_kernel_oserror *last_error = _kernel_last_oserror();
if (last_error != NULL)
strcpy (last_errmess, last_error->errmess);
memcpy (&error, last_error, sizeof(_kernel_oserror));
else
CLEAR (last_errmess);
{
error.errnum = 0;
sprintf(error.errmess,"Caught signal %d",sig); /* Should probably be sent through messagetrans, but this case shouldn't happen anyway */
}
ftracef2 ("CAUGHT SIGNAL %d!\nError was \"%s\"\n", sig, last_errmess);
ftracef2 ("CAUGHT SIGNAL %d!\nError was \"%s\"\n", sig, error.errmess);
scrap_dir = getenv ("WIMP$ScrapDir");
paint = msgs_lookup ("Pnt00");
......@@ -3602,8 +3505,6 @@ int main (int argc, char *argv[])
signal (s, Saved_Handlers [s]) == SIG_ERR))
werr (FALSE, _kernel_last_oserror ()->errmess);
error.errnum = 0;
if (scrap_dir != NULL)
for (w = main_windows; w != NULL; w = w->link)
if (w->tag == main_window_is_file && w->data->file.modified)
......@@ -3611,15 +3512,21 @@ int main (int argc, char *argv[])
{ struct {int errno; char errmess [sizeof "PntX"];} PntX =
{0, "PntX"};
reg_set.r [0] = (int) msgtrans_error_lookup (&PntX,
msgs_main_control_block (), NULL, 0, last_errmess,
"<WIMP$ScrapDir>", paint, 0);
reg_set.r [1] = 3 /*OK and Cancel boxes*/;
reg_set.r [2] = (int) paint;
(void) os_swix (Wimp_ReportError, &reg_set);
regs.r[0] = (int)&PntX;
regs.r[1] = (int)msgs_main_control_block ();
regs.r[2] = NULL;
regs.r[3] = 0;
regs.r[4] = (int)error.errmess;
regs.r[5] = (int)"<WIMP$ScrapDir>";
regs.r[6] = (int)paint;
regs.r[7] = 0;
os_swix (MessageTrans_ErrorLookup, &regs);
regs.r[1] = 3 /*OK and Cancel boxes*/;
regs.r[2] = (int)paint;
os_swix (Wimp_ReportError, &regs);
reported = TRUE;
if (reg_set.r [1] == 2) break; /*cancel*/
if (regs.r[1] == 2) break; /*cancel*/
/*Make the directory, if necessary.*/
sprintf (preserve, "%s.%s", scrap_dir, paint);
......@@ -3642,7 +3549,7 @@ int main (int argc, char *argv[])
/*Report the error if we haven't yet.*/
if (!reported)
wimpt_complain ((os_error *) last_error);
wimpt_complain ((os_error *) &error);
return 1;
}
......@@ -3662,7 +3569,7 @@ int main (int argc, char *argv[])
if (w)
{ int ok /*for Norcroft*/;
ftracef1 ("load into new window %d\n",w->handle);
ftracef1 ("load into new window %d\n", w->handle);
visdelay_begin ();
ok = Load_File (w, *argv, 0, 1);
visdelay_end ();
......@@ -3675,7 +3582,9 @@ int main (int argc, char *argv[])
else
delete_file_window (w);
/* might have been asked to run with a non-sprite file */
} } }
}
}
}
ftracef0 ("Start main loop.....\n");
for (;;) /* ever */
......
......@@ -57,6 +57,7 @@
#include <stddef.h>
#include <swis.h>
#include <signal.h>
#include "Global/FileTypes.h"
#include "bbc.h"
#include "colourmenu.h"
......@@ -87,19 +88,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 +220,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,10 +293,14 @@ 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.
BOOL menus_ensure_size (sprite_area **sarea, int bytesneeded)
{ int bytesfree = (*sarea)->size - (*sarea)->freeoff;
int newsize;
/*
* 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.
......@@ -311,13 +317,6 @@ void menus_sprite_new (main_window *window, BOOL hack_palette)
*
* 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
ftracef1 ("menus_ensure_size of %d\n", bytesneeded);
ftracef3("bytesfree = %d - %d = %d\n", (*sarea)->size, (*sarea)->freeoff,
......@@ -338,7 +337,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 +353,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 +361,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 +368,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 *
......@@ -433,12 +400,10 @@ static BOOL myxfersend (int filetype, char *name, int estsize,
ftracef0 ("myxfersend\n");
main_claim_idle ((wimp_w) -1);
#if (1)
ftracef1 ("myxfersend: calling saveas (..., \"%s\", ...)\n", name);
res = saveas (filetype, name, estsize, p1, p2, p3, handle);
#else
res = xfersend (filetype, name, estsize, p1, p2, p3, handle);
#endif
main_claim_idle (nullc);
return res;
}
......@@ -538,7 +503,7 @@ finish:
/*Set the file to type "Sprite"*/
file_str.action = 18;
file_str.name = filename;
file_str.loadaddr = SPRITE_FILE;
file_str.loadaddr = FileType_Sprite;
error1 = os_file (&file_str);
if (txt == NULL && error1 != NULL) txt = error1->errmess;
}
......@@ -598,7 +563,8 @@ static void build_sprite_palette_file (main_sprite *sprite,
*p++ = palette_str.c [16 + i].bytes.red;
*p++ = palette_str.c [16 + i].bytes.green;
*p++ = palette_str.c [16 + i].bytes.blue;
} }
}
}
finish:
wimpt_noerr (error);
......@@ -623,11 +589,11 @@ static BOOL save_sprite_palette (char *filename, void *shandle)
r.r [0] = 17; /* Read cat info */
r.r [1] = (int) filename;
(void) os_swix (OS_File, &r);
/* if something is already there,remember its attributes */
/* if something is already there, remember its attributes */
if (r.r [0] != 0) oldattribs = r.r [5];
r.r [0] = 10;
r.r [2] = 0xFED;
r.r [2] = FileType_Palette;
r.r [4] = (int) &palette;
r.r [5] = (int) &palette + len;
......@@ -734,22 +700,27 @@ static BOOL buffer_sprite_palette (void *shandle, int *max)
return mysendbuf (&pp, len, max, 0);
}
static void menus_save_selection (main_window* window)
{
ftracef0 ("menus_save_selection\n");
static void menus_save_selection (main_window *window)
{ ftracef0 ("menus_save_selection\n");
if (window->selection.count==1)
{
main_sprite* sprite;
for (sprite=window->data->file.sprites;sprite;sprite=sprite->link)
{
if (sprite->flags & MSF_SELECTED) break;
{ main_sprite *sprite;
/* Just one selected, find it, and save it on its own with
the sprite name as the filename instead */
for (sprite = window->data->file.sprites; sprite != NULL; sprite = sprite->link)
{ if (sprite->flags & MSF_SELECTED)
{ menus_save_sprite (sprite);
break;
}
}
if (sprite) menus_save_sprite(sprite);
return;
}
myxfersend (SPRITE_FILE,"Selection",main_selection_file_size(window),main_save_selection,0,0,window);
myxfersend (FileType_Sprite, msgs_lookup ("PntG6"),
main_selection_file_size (window),
main_save_selection, 0, 0, window);
}
void menus_save_sprite (main_sprite *sprite)
......@@ -761,14 +732,9 @@ void menus_save_sprite (main_sprite *sprite)
ftracef1 ("sprite called \"%s\"\n", name);
myxfersend (SPRITE_FILE, name,
myxfersend (FileType_Sprite, name,
psprite_address (sprite)->next + sizeof (sprite_area),
&save_sprite, &buffer_sprite,
&Do_Print, /*Protocol now in xfersend(), immediate printing
allowed. Was NULL. JRC 4 Apr 1992*/
/*FIX G-RO-7139 JRC 16 Oct '91 Use new printer protocol - was
&call_print_sprite*/
sprite);
&save_sprite, &buffer_sprite, &Do_Print, sprite);
}
BOOL menus_save_file (main_window *window, int askfor_name)
......@@ -785,7 +751,7 @@ BOOL menus_save_file (main_window *window, int askfor_name)
if (askfor_name)
{ My_File_Is_Safe = FALSE;
ftracef0 ("menus_save_file: myxfersend\n");
myxfersend (SPRITE_FILE, name, window->data->file.spritearea->size,
myxfersend (FileType_Sprite, name, window->data->file.spritearea->size,
&save_file_proc, &buffer_file_proc,
&print_file_proc, /*Protocol now in xfersend(), immediate printing
allowed. Was NULL. JRC 4 Apr 1992*/
......@@ -840,7 +806,8 @@ static void Change_Size (sprite_area **sarea, sprite_id *sid,
if (!menus_ensure_size (sarea, newsize - info.size))
{ msg = msgs_lookup ("PntEG");
goto finish;
} }
}
}
else
{ /* Deleting - find the maximum number or rows or columns that can go */
int max;
......@@ -895,7 +862,7 @@ void menus_restart_tool (void)
for (window = main_windows; window != NULL; window = window->link)
if (window->tag == main_window_is_file)
for (sprite = window->data->file.sprites; sprite != NULL;
sprite=sprite->link)
sprite = sprite->link)
sprite->needsnull = 1;
}
......@@ -911,7 +878,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;
......@@ -926,16 +893,16 @@ static void insdel_drawEOR(main_sprite_window* sprw,int x0,int y0)
if (insdel_rowfield != -1)
{ ftracef0 ("insdel_EOR row\n");
int top=MAX(insdel_row,Row)+1;
int bottom=MIN(insdel_row,Row);
int top = MAX(insdel_row, Row) + 1;
int bottom = MIN(insdel_row, Row);
bbc_rectanglefill (MAX (x0, 0), y0 + bottom*ymul/ydiv,
0x1FFF, (top - bottom)*ymul/ydiv-1);
}
if (insdel_colfield != -1)
{ ftracef0 ("insdel_EOR column\n");
int left=MIN(insdel_col,Column);
int right=MAX(insdel_col,Column)+1;
int left = MIN(insdel_col, Column);
int right = MAX(insdel_col, Column) + 1;
bbc_rectanglefill (x0 + left*xmul/xdiv, MAX (y0, 0),
(right-left)*xmul/xdiv-1, 0x1FFF);
}
......@@ -953,7 +920,7 @@ static void insdel_EOR (void)
wimp_winfo curr;
curr.w = sprw->window->handle;
wimpt_noerr (PaintLib_get_wind_info (&curr));
wimpt_noerr (paintlib_get_wind_info (&curr));
rds.w = sprw->window->handle;
rds.box = main_big_extent;
wimpt_noerr (wimp_update_wind (&rds, &more));
......@@ -962,8 +929,7 @@ static void insdel_EOR (void)
y0 = rds.box.y1 - rds.scy + curr.info.ex.y0;
while (more)
{
insdel_drawEOR(sprw,x0,y0);
{ insdel_drawEOR(sprw, x0, y0);
wimpt_noerr (wimp_get_rectangle (&rds, &more));
}
}
......@@ -1025,7 +991,7 @@ static void insdeltool_redraw (main_window *window, int x0, int y0)
ftracef0 ("insdeltool_redraw\n");
if (window->data->sprite.sprite->needsnull)
insdel_drawEOR(&window->data->sprite,x0,y0);
insdel_drawEOR(&window->data->sprite, x0, y0);
}
static void insdeltool_stop (main_sprite *sprite)
......@@ -1179,7 +1145,8 @@ void menus_set_palette (main_sprite *sprite, int entries, int *palette)
for (i = 0; i < entries; i++)
{ *e = *(e + 1) = palette [i];
e += 2;
} }
}
}
/*Fix up every pointer in the world.*/
header->image += diff;
......@@ -1260,7 +1227,7 @@ void menus_sprite_handler (void *handle, char *hit)
{ int size = psprite_palsize (sprite);
ftracef0 ("Sprite palette save\n");
myxfersend (0xFED, msgs_lookup ("PntG5"), size,
myxfersend (FileType_Palette, msgs_lookup ("PntG5"), size,
&save_sprite_palette, &buffer_sprite_palette, 0, sprite);
}
break;
......@@ -1383,7 +1350,9 @@ void menus_sprite_handler (void *handle, char *hit)
os_swi3 (ColourPicker_UpdateDialogue,
colourpicker_UPDATE_COLOUR, sprite->colourdialogue,
&dialogue);
} } }
}
}
}
break;
case s_Paint_Show_Col:
......@@ -1684,7 +1653,8 @@ void menus_sprite_handler (void *handle, char *hit)
Change_Size (sarea, &sid, sprite, number, !col,
!col? MIN (Row, insdel_row): MIN (Column, insdel_col));
menus_ensure_size (sarea, 0);
} }
}
}
break;
case s_Edit_Mask:
......@@ -1741,7 +1711,8 @@ void menus_sprite_handler (void *handle, char *hit)
sprite->colourdialogue, &dialogue)) != NULL)
{ msg = error->errmess;
goto masked;
} }
}
}
/*Fix MED-xxx J R C 21st Jul 1994*/
if (!create)
......@@ -1884,7 +1855,7 @@ static BOOL queue_print (dbox d, main_sprite *sprite)
psprite_read_full_info (sprite, &info);
if (!xfersend_print (SPRITE_FILE, info.name, info.size,
if (!xfersend_print (FileType_Sprite, info.name, info.size,
/*saver*/ &save_sprite, /*sender - no point yet*/ NULL,
/*printer*/ &Do_Print, /*handle*/ sprite))
return FALSE;
......@@ -1989,7 +1960,8 @@ BOOL menus_do_print (main_sprite *sprite)
if ((err = os_swix3 (PDriver_DeclareFont, 0, NULL, 0)) != NULL)
{ txt = err->errmess;
goto finish;
} }
}
}
if (print_landscape) menus_print_where.dx += ssize.y1*72000/180;
......@@ -2032,7 +2004,8 @@ BOOL menus_do_print (main_sprite *sprite)
if ((err = print_getrectangle (&pbox, &more, &ID)) != NULL)
{ txt = err->errmess;
goto finish;
} }
}
}
finish:
if (done_translate)
......@@ -2172,9 +2145,11 @@ void menus_print_sprite (main_sprite *sprite, BOOL ask)
case dbox_CLOSE:
open = FALSE;
break;
} }
}
}
dbox_dispose (&d);
} }
}
}
else
/*FIX G-RO-7139 JRC 17 Oct '91 Call queue_print() instead of
menus_do_print().*/
......@@ -2197,7 +2172,9 @@ void menus_hack_palette (main_sprite *sprite)
ftracef2 ("was 0x%.8X now 0x%.8X\n",
*palstart, t | ((t >> 4) & 0xF0F0F00));
*palstart = t | ((t >> 4) & 0xF0F0F00);
} } }
}
}
}
/***************************************************************************
* *
......@@ -2247,135 +2224,121 @@ void menus_file_handler (void *handle, char *hit)
window->data->file.filename == NULL?
msgs_lookup ("PntF4"): window->data->file.filename);
dbox_setnumeric (d, d_File_Number, sarea->number);
_swix (OS_ConvertFileSize, _INR(0,2), sarea->size, &sizestring, 32);
os_swix3 (OS_ConvertFileSize, sarea->size, &sizestring, 32);
dbox_setfield (d, d_File_Size, sizestring);
dbox_setfield (d, d_File_Mod, yesno (window->data->file.modified));
dbox_show (d);
dbox_raw_eventhandler (d, sprite_file_info_events, NULL);
} }
}
}
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;
sprite_header *header;
int count = unsorted->number;
main_file *file = &window->data->file;
int size = sarea->size;
int loop, next, i;
main_sprite *sprite;
int loop, next;
BOOL byname = (hit[1] == m_Misc_SBName);
sprite_tosort tosort[count];
sprite_tosort *tosortptr[count];
os_regset regs;
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 */
for (sprite = file->sprites; sprite != NULL; sprite = sprite->link)
{ 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].tosort[NAME_LIMIT] = '\0'; /* Ensure a terminator */
tosort[count].tojumble = sprite; /* Remember the corresponding sprite structure pointer */
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)))
regs.r[0] = count;
regs.r[1] = (int)&tosortptr;
regs.r[2] = byname ? 4 : 2;
if (regs.r[1] & 0xE0000000)
{ /* Too high - give it to HeapSort32 to jiggle the pointers */
regs.r[7] = 0;
if (wimpt_complain (os_swix (OS_HeapSort32, &regs)) != NULL)
break;
}
else
{
/* Give it to HeapSort to jiggle the pointers */
if (wimpt_complain (_swix (OS_HeapSort, _INR(0,2), count, &tosortptr, 4)))
{ /* Give it to HeapSort to jiggle the pointers */
if (wimpt_complain (os_swix (OS_HeapSort, &regs)) != NULL)
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"));
/* 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);
sorted->size = size;
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);
{ 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;
/* 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;
}
/* Free the original area,and update pointers */
m_FREE(nextsprite, sizeof(main_sprite));
/* 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 = tosortptr[loop]->orgsprite;
sprite = tosortptr[loop]->orgsprite;
}
/* End the sprite area nicely */
sprite->link = NULL;
sorted->number = count;
sorted->freeoff = next;
flex_free((flex_ptr) &window->data->file.spritearea);
*((int *)sorted - 2) =
flex_free ((flex_ptr)&window->data->file.spritearea);
/* Reanchor the flex block assuming the format is
int anchor
int size
char store */
(int)&window->data->file.spritearea;
flex_ptr -> char store[] */
*((int *)sorted - 2) = (int)&window->data->file.spritearea;
window->data->file.spritearea = sorted;
ftracef1("sort budg'd %08X\n",(char *)sorted);
psprite_recalculate_offsets (file);
menus_file_has_changed(window);
ftracef2 ("sort budg'd from %08X to %08X\n", (int)unsorted, (int)sorted);
menus_file_has_changed (window);
visdelay_end ();
}
break;
}
break;
......@@ -2405,24 +2368,21 @@ void menus_file_handler (void *handle, char *hit)
break;
case m_Sprite_Delete:
{
main_sprite* sprite;
main_sprite* next;
{ main_sprite *sprite;
main_sprite *next;
int count;
int total=window->selection.count;
if (window->selection.count==0) break;
visdelay_begin();
for (count=1,sprite=window->data->file.sprites;sprite;sprite=next,count++)
{
visdelay_percent(count*100/total);
next=sprite->link;
for (count=1, sprite=window->data->file.sprites; sprite != NULL;
sprite = next, count++)
{ visdelay_percent(count*100/total);
next = sprite->link;
if (sprite->flags & MSF_SELECTED)
{
sprite_area *sarea = sprite->file->spritearea;
#if FIXDELSPR
{ sprite_area *sarea = sprite->file->spritearea;
main_file *spritefile = sprite->file;
#endif
sprite_id sid;
char name [NAME_LIMIT + 1];
......@@ -2435,16 +2395,12 @@ void menus_file_handler (void *handle, char *hit)
/*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));
#if FIXDELSPR
menus_ensure_size(&spritefile->spritearea,0);
#endif
psprite_delete (window,sprite);
menus_ensure_size(&spritefile->spritearea, 0);
psprite_delete (window, sprite);
ftracef0("do menus_file_has_changed\n");
menus_file_has_changed (window);
ftracef0("do menus_ensure_size(,0)\n");
#if !FIXDELSPR
menus_ensure_size (&sprite->file->spritearea, 0);
#endif
}
}
visdelay_end();
......@@ -2526,7 +2482,7 @@ void menus_file_handler (void *handle, char *hit)
wimp_wstate wstate;
winfo.w = hit_sprite->colourhandle;
wimpt_noerr (PaintLib_get_wind_info (&winfo));
wimpt_noerr (paintlib_get_wind_info (&winfo));
sprintf (winfo.info.title.indirecttext.buffer,
msgs_lookup ("PntW7"), spritenamebuffer);
......@@ -2541,7 +2497,9 @@ void menus_file_handler (void *handle, char *hit)
redraw_str.w = -1;
redraw_str.box.y0 = wstate.o.box.y1;
wimpt_noerr (wimp_force_redraw (&redraw_str));
} } }
}
}
}
break;
case m_Sprite_Save:
......@@ -2584,7 +2542,7 @@ void menus_file_handler (void *handle, char *hit)
/*Change window width to allow one full item, if it is less.*/
curr.w = window->handle;
wimpt_noerr (PaintLib_get_wind_info (&curr));
wimpt_noerr (paintlib_get_wind_info (&curr));
ftracef2 ("current width is %d; need %d\n",
curr.info.box.x1 - curr.info.box.x0,
......@@ -2725,13 +2683,13 @@ static void hack_entry (menu menyoo, int entryno, char *name)
menu menus_file_maker (void *handle)
{
main_window* window =(main_window *) handle;
main_window *window =(main_window *) handle;
main_file *file = &window->data->file;
int len;
char term [2];
AltRename_delete();
altrename_delete();
ftracef0 ("spritefile_menu_maker\n");
if (!event_is_menu_being_recreated ())
......@@ -2750,7 +2708,7 @@ menu menus_file_maker (void *handle)
if (window->selection.count!=1)
{
strcpy (Spritename,msgs_lookup ("PntG6"));
strcpy (Spritename, msgs_lookup ("PntG6"));
}
else
{
......@@ -2776,24 +2734,24 @@ menu menus_file_maker (void *handle)
hack_entry (spritefile_main_menu, m_Sprite, Spritename);
// menu_setflags (spritefile_main_menu, m_Sprite, 0, hit_sprite == NULL && window->selection.count==0);
/* When there are no sprites in the file,forbid its saving */
/* When there are no sprites in the file, forbid its saving & selecting */
menu_setflags (spritefile_main_menu, m_Save, 0,
(file->spritearea->number == 0));
menu_setflags (spritefile_main_menu, m_Sprite, 0,
(file->spritearea->number == 0));
menu_setflags (filedisplay_menu, m_Display_Name, !file->fullinfo, 0);
menu_setflags (filedisplay_menu, m_Display_Full, file->fullinfo, 0);
menu_setflags (filedisplay_menu, m_Display_UseDT,
file->use_current_palette, 0);
menu_setflags (sprite_selection_menu,m_Sprite_ClearAll,0,window->selection.count==0);
menu_setflags (sprite_selection_menu,m_Sprite_Copy,0,window->selection.count!=1);
menu_setflags (sprite_selection_menu,m_Sprite_Rename,0,window->selection.count!=1);
menu_setflags (sprite_selection_menu,m_Sprite_Delete,0,window->selection.count==0);
menu_setflags (sprite_selection_menu,m_Sprite_Save,0,window->selection.count==0);
menu_setflags (sprite_selection_menu,m_Sprite_Info,0,window->selection.count!=1);
menu_setflags (sprite_selection_menu,m_Sprite_Print,0,window->selection.count!=1);
menu_setflags (sprite_selection_menu, m_Sprite_ClearAll, 0, window->selection.count==0);
menu_setflags (sprite_selection_menu, m_Sprite_Copy, 0, window->selection.count!=1);
menu_setflags (sprite_selection_menu, m_Sprite_Rename, 0, window->selection.count!=1);
menu_setflags (sprite_selection_menu, m_Sprite_Delete, 0, window->selection.count==0);
menu_setflags (sprite_selection_menu, m_Sprite_Save, 0, window->selection.count==0);
menu_setflags (sprite_selection_menu, m_Sprite_Info, 0, window->selection.count!=1);
menu_setflags (sprite_selection_menu, m_Sprite_Print, 0, window->selection.count!=1);
help_register_handler (&help_simplehandler, (void *) "FILER");
......