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 @@ ...@@ -14,4 +14,5 @@
| |
Dir <Obey$Dir> Dir <Obey$Dir>
wimpslot -min 1024k wimpslot -min 1024k
amu_machine appd cdir debug.!Paint
amu_machine installd THROWBACK=-throwback INSTDIR=debug.!Paint
...@@ -14,5 +14,5 @@ ...@@ -14,5 +14,5 @@
| |
Dir <Obey$Dir> Dir <Obey$Dir>
wimpslot -min 1024k wimpslot -min 1024k
cdir <Install$Dir>.!Paint cdir <Install$Dir>.Apps.!Paint
amu_machine install INSTDIR=<Install$Dir>.!Paint amu_machine install INSTDIR=<Install$Dir>.Apps.!Paint
s/** gitlab-language=armasm linguist-language=armasm linguist-detectable=true 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 *,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
**/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 ...@@ -32,7 +32,7 @@ MODULE = rm.!Paint
ROM_MODULE = aof.Paint ROM_MODULE = aof.Paint
RDIR = Resources RDIR = Resources
LDIR = ${RDIR}.${LOCALE} LDIR = ${RDIR}.${LOCALE}
MSGVERSION = ${AWK} -f Build:AwkVers
MSGS = Resources.GenMessage MSGS = Resources.GenMessage
# #
...@@ -54,12 +54,13 @@ RM = remove ...@@ -54,12 +54,13 @@ RM = remove
SQUEEZE = squeeze SQUEEZE = squeeze
WIPE = -wipe WIPE = -wipe
XWIPE = x wipe XWIPE = x wipe
AWK = GNU.gawk
AFLAGS = ${THROWBACK} -depend !Depend -nocache -stamp -quit AFLAGS = ${THROWBACK} -depend !Depend -nocache -stamp -quit
CFLAGS = ${THROWBACK} -c -depend !Depend -fah ${INCLUDES} -wp CFLAGS = ${THROWBACK} -c -depend !Depend -fah ${INCLUDES} -wp
CPFLAGS = ~cfr~v CPFLAGS = ~cfr~v
SQFLAGS = SQFLAGS =
WFLAGS = ~c~v WFLAGS = ~c~vf
# #
# Libraries # Libraries
...@@ -107,11 +108,11 @@ DFILES = \ ...@@ -107,11 +108,11 @@ DFILES = \
debug.${APP}.Templates debug.${APP}.Templates
OBJS = o.colours o.main o.menus o.psprite o.sprwindow o.tools o.toolwindow \ 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\ 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\ 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 od.AltRename od.PaintLib
ASMS = s.colours s.main s.menus s.psprite s.sprwindow s.tools s.toolwindow 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 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 ...@@ -130,8 +131,6 @@ INCS = i.colours i.main i.menus i.psprite i.sprwindow i.tools i.toolwindow
# #
# Main rules: # Main rules:
# #
# Application
#
all: ${FILES} all: ${FILES}
@echo ${COMPONENT}: Application built (Disc) @echo ${COMPONENT}: Application built (Disc)
...@@ -161,7 +160,7 @@ installd: ${FILESD} ...@@ -161,7 +160,7 @@ installd: ${FILESD}
${CP} ${LDIR}.!Help ${INSTDIR}.!Help ${CPFLAGS} ${CP} ${LDIR}.!Help ${INSTDIR}.!Help ${CPFLAGS}
${CP} ${LDIR}.!Run ${INSTDIR}.!Run ${CPFLAGS} ${CP} ${LDIR}.!Run ${INSTDIR}.!Run ${CPFLAGS}
${CP} abs.!RunImageD ${INSTDIR}.!RunImage ${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}.Sprites ${INSTDIR}.Sprites ${CPFLAGS}
${CP} ${LDIR}.Templates ${INSTDIR}.Templates ${CPFLAGS} ${CP} ${LDIR}.Templates ${INSTDIR}.Templates ${CPFLAGS}
Access ${INSTDIR}.!Boot lr/r Access ${INSTDIR}.!Boot lr/r
...@@ -196,6 +195,8 @@ clean: ...@@ -196,6 +195,8 @@ clean:
${XWIPE} s.* ${WFLAGS} ${XWIPE} s.* ${WFLAGS}
${XWIPE} linked.* ${WFLAGS} ${XWIPE} linked.* ${WFLAGS}
${XWIPE} map.* ${WFLAGS} ${XWIPE} map.* ${WFLAGS}
${XWIPE} debug.!Paint.* ${WFLAGS}
${XWIPE} !Paint.* ${WFLAGS}
${RM} abs.!RunImage ${RM} abs.!RunImage
${RM} abs.!RunImageD ${RM} abs.!RunImageD
${RM} ${ROM_MODULE} ${RM} ${ROM_MODULE}
...@@ -203,39 +204,6 @@ clean: ...@@ -203,39 +204,6 @@ clean:
${RM} ${MODULE} ${RM} ${MODULE}
@echo ${COMPONENT}: cleaned @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: # Static dependencies:
# #
...@@ -262,8 +230,8 @@ oz.ModuleWrap: s.ModuleWrap ${MSGS} s.AppName ${RESFILES} s.Resfiles ...@@ -262,8 +230,8 @@ oz.ModuleWrap: s.ModuleWrap ${MSGS} s.AppName ${RESFILES} s.Resfiles
s.ModuleWrap: ${WRAPPER} s.ModuleWrap: ${WRAPPER}
${CP} ${WRAPPER} $@ ${CPFLAGS} ${CP} ${WRAPPER} $@ ${CPFLAGS}
${MSGS}: ${LDIR}.Messages awk.Version ${MSGS}: ${LDIR}.Messages VersionNum
GNU.gawk -f awk.Version ${LDIR}.Messages > $@ ${MSGVERSION} ${LDIR}.Messages > $@
s.ResFiles: asm.ResFiles s.ResFiles: asm.ResFiles
${CP} asm.ResFiles $@ ${CPFLAGS} ${CP} asm.ResFiles $@ ${CPFLAGS}
......
No preview for this file type
No preview for this file type
...@@ -11,13 +11,13 @@ ...@@ -11,13 +11,13 @@
GBLS Module_HelpVersion GBLS Module_HelpVersion
GBLS Module_ComponentName GBLS Module_ComponentName
GBLS Module_ComponentPath GBLS Module_ComponentPath
Module_MajorVersion SETS "2.01" Module_MajorVersion SETS "2.09"
Module_Version SETA 201 Module_Version SETA 209
Module_MinorVersion SETS "" Module_MinorVersion SETS ""
Module_Date SETS "01 Oct 2009" Module_Date SETS "24 Sep 2011"
Module_ApplicationDate SETS "01-Oct-09" Module_ApplicationDate SETS "24-Sep-11"
Module_ComponentName SETS "Paint" Module_ComponentName SETS "Paint"
Module_ComponentPath SETS "castle/RiscOS/Sources/Apps/Paint" Module_ComponentPath SETS "castle/RiscOS/Sources/Apps/Paint"
Module_FullVersion SETS "2.01" Module_FullVersion SETS "2.09"
Module_HelpVersion SETS "2.01 (01 Oct 2009)" Module_HelpVersion SETS "2.09 (24 Sep 2011)"
END END
/* (2.01) /* (2.09)
* *
* This file is automatically maintained by srccommit, do not edit manually. * This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1. * 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_MinorVersion_CMHG
#define Module_Date_CMHG 01 Oct 2009 #define Module_Date_CMHG 24 Sep 2011
#define Module_MajorVersion "2.01" #define Module_MajorVersion "2.09"
#define Module_Version 201 #define Module_Version 209
#define Module_MinorVersion "" #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_ComponentName "Paint"
#define Module_ComponentPath "castle/RiscOS/Sources/Apps/Paint" #define Module_ComponentPath "castle/RiscOS/Sources/Apps/Paint"
#define Module_FullVersion "2.01" #define Module_FullVersion "2.09"
#define Module_HelpVersion "2.01 (01 Oct 2009)" #define Module_HelpVersion "2.09 (24 Sep 2011)"
#define Module_LibraryVersionInfo "2:1" #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 @@ ...@@ -12,47 +12,48 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#include "AltRename.h" #include <swis.h>
#include <string.h>
#include "os.h"
#include "bbc.h" #include "bbc.h"
#include "wimpt.h" #include "wimpt.h"
#include "werr.h" #include "werr.h"
#include "string.h" #include "sprite.h"
#include "AltRename.h"
#include "PSprite.h" #include "PSprite.h"
#include "PaintLib.h" #include "PaintLib.h"
#include "os.h"
#include "main.h" #include "main.h"
#include "sprite.h"
#include "SprWindow.h" #include "SprWindow.h"
#include "swis.h"
#include "akbd.h" #include "akbd.h"
static wimp_i rename_icon=-1; static wimp_i rename_icon = -1;
static char rename_buffer[16]; static char rename_buffer[16];
static main_window* rename_window; static main_window *rename_window;
static main_sprite* rename_sprite; static main_sprite *rename_sprite;
static wimp_box rename_bbox; static wimp_box rename_bbox;
static int rename_sprites_per_row; static int rename_sprites_per_row;
static void AltRename_renamesprite(main_sprite* sprite,char* newname) static void altrename_renamesprite (main_sprite *sprite, char *newname)
{
sprite_id sid; { sprite_id sid;
char name[NAME_LIMIT+1]; char name[NAME_LIMIT+1];
sid.tag = sprite_id_name; /*doesn't flex*/ sid.tag = sprite_id_name; /*doesn't flex*/
sid.s.name = newname; sid.s.name = newname;
if (*newname==0) return; if (*newname == 0) return;
/* check if new name exists */ /* 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); strncpy (name, psprite_address (sprite)->name, NAME_LIMIT);
name[NAME_LIMIT]=0; name[NAME_LIMIT] = 0;
sid.s.name=name; sid.s.name = name;
if (wimpt_complain (sprite_rename if (wimpt_complain (sprite_rename
(sprite->file->spritearea, &sid, newname)) != (sprite->file->spritearea, &sid, newname)) !=
NULL) return; NULL) return;
main_set_modified(sprite->file); main_set_modified (sprite->file);
sprwindow_set_window_titles (sprite); sprwindow_set_window_titles (sprite);
/* rename must reset the titles of all the windows open on /* rename must reset the titles of all the windows open on
...@@ -74,7 +75,7 @@ static void AltRename_renamesprite(main_sprite* sprite,char* newname) ...@@ -74,7 +75,7 @@ static void AltRename_renamesprite(main_sprite* sprite,char* newname)
wimp_wstate wstate; wimp_wstate wstate;
winfo.w = sprite->colourhandle; winfo.w = sprite->colourhandle;
wimpt_noerr (PaintLib_get_wind_info (&winfo)); wimpt_noerr (paintlib_get_wind_info (&winfo));
sprintf (winfo.info.title.indirecttext.buffer, sprintf (winfo.info.title.indirecttext.buffer,
msgs_lookup ("PntW7"), newname); msgs_lookup ("PntW7"), newname);
...@@ -92,21 +93,22 @@ static void AltRename_renamesprite(main_sprite* sprite,char* newname) ...@@ -92,21 +93,22 @@ static void AltRename_renamesprite(main_sprite* sprite,char* newname)
} }
} }
void AltRename_delete(void) void altrename_delete (void)
{
wimp_redrawstr ds; { wimp_redrawstr ds;
if (!rename_window) return; if (!rename_window) return;
wimp_delete_icon(rename_window->handle,rename_icon); wimp_delete_icon (rename_window->handle, rename_icon);
ds.w=rename_window->handle; ds.w = rename_window->handle;
ds.box=rename_bbox; ds.box = rename_bbox;
wimp_force_redraw(&ds); wimp_force_redraw (&ds);
rename_window=0; rename_window = NULL;
} }
static int AltRename_sprites_per_row(int* toggled) static int altrename_sprites_per_row (int *toggled)
{
wimp_wstate ws; { wimp_wstate ws;
int width; int width;
if (!rename_window) return 0; if (!rename_window) return 0;
...@@ -116,146 +118,140 @@ static int AltRename_sprites_per_row(int* toggled) ...@@ -116,146 +118,140 @@ static int AltRename_sprites_per_row(int* toggled)
else else
width = main_FILER_TotalWidth; width = main_FILER_TotalWidth;
wimp_get_wind_state(rename_window->handle,&ws); wimp_get_wind_state(rename_window->handle, &ws);
if (toggled) *toggled=(ws.flags & wimp_WCLICK_TOGGLE);
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) void altrename_start (main_window *window, main_sprite *sprite)
{
wimp_box bbox; { wimp_box bbox;
psprite_info sinfo; psprite_info sinfo;
wimp_icreate icon; wimp_icreate icon;
wimp_wstate ws; 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; 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; return;
if (window->data->file.fullinfo) 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 else
{ { icon.i.box.x0 = bbox.x0;
icon.i.box.x0=bbox.x0; icon.i.box.x1 = bbox.x1;
icon.i.box.x1=bbox.x1;
} }
icon.w=window->handle; icon.w = window->handle;
icon.i.flags=(wimp_iconflags)(wimp_ITEXT | wimp_INDIRECT | wimp_IHCENTRE | icon.i.flags = (wimp_iconflags)(wimp_ITEXT | wimp_INDIRECT | wimp_IHCENTRE |
wimp_IFILLED | wimp_IBORDER | wimp_IFILLED | wimp_IBORDER |
(7*wimp_IFORECOL) | (0*wimp_IBACKCOL) | (7 * wimp_IFORECOL) | (0 * wimp_IBACKCOL) |
(wimp_BWRITABLE*wimp_IBTYPE)); (wimp_BWRITABLE * wimp_IBTYPE));
icon.i.data.indirecttext.buffer=rename_buffer; icon.i.data.indirecttext.buffer = rename_buffer;
icon.i.data.indirecttext.validstring=""; icon.i.data.indirecttext.validstring = "";
icon.i.data.indirecttext.bufflen=NAME_LIMIT+1; icon.i.data.indirecttext.bufflen = NAME_LIMIT+1;
psprite_read_full_info (sprite, &sinfo); psprite_read_full_info (sprite, &sinfo);
strcpy(rename_buffer,sinfo.name); strcpy (rename_buffer, sinfo.name);
if (wimpt_complain(wimp_create_icon(&icon,&rename_icon))) return; if (wimpt_complain (wimp_create_icon (&icon, &rename_icon))) return;
wimp_redrawstr ds; rename_window = window;
wimp_caretstr caret; rename_sprite = sprite;
rename_window=window; ds.w = icon.w;
rename_sprite=sprite; ds.box = icon.i.box;
ds.w=icon.w; rename_bbox = ds.box;
ds.box=icon.i.box; rename_sprites_per_row = altrename_sprites_per_row (0);
rename_bbox=ds.box; caret.w = window->handle;
rename_sprites_per_row=AltRename_sprites_per_row(0); caret.i = rename_icon;
caret.w=window->handle; caret.x = caret.y = 0;
caret.i=rename_icon; caret.height = -1;
caret.x=caret.y=0; caret.index = strlen (sinfo.name);
caret.height=-1; wimp_set_caret_pos (&caret);
caret.index=strlen(sinfo.name); wimp_force_redraw (&ds);
wimp_set_caret_pos(&caret); wimp_get_wind_state (window->handle,&ws);
wimp_force_redraw(&ds);
wimp_get_wind_state(window->handle,&ws); scy = ws.o.y;
y = WORKAREA_TO_SCREEN_Y(&ws, bbox.y1);
scy=ws.o.y;
y=WORKAREA_TO_SCREEN_Y(&ws,bbox.y1);
if (y>ws.o.box.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) if (y<ws.o.box.y0)
ws.o.y+=(y-ws.o.box.y0); ws.o.y += (y-ws.o.box.y0);
if (scy != ws.o.y) wimp_open_wind(&ws.o);
if (scy != ws.o.y) wimp_open_wind (&ws.o);
} }
BOOL AltRename_claim_event(wimp_eventstr *e,main_window* window) BOOL altrename_claim_event (wimp_eventstr *e, main_window *window)
{
if (!rename_window) return 0; { if (!rename_window) return FALSE;
switch (e->e) switch (e->e)
{ {
case wimp_EBUT: case wimp_EBUT:
if (window->handle!=rename_window->handle || if (window->handle!=rename_window->handle ||
(e->data.but.m.bbits & 2)) (e->data.but.m.bbits & 2))
{ { altrename_delete ();
AltRename_delete();
break; break;
} }
if ( e->data.but.m.i==rename_icon && 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)) if (e->data.but.m.bbits & (wimp_BCLICKLEFT | wimp_BCLICKRIGHT))
{ { altrename_delete ();
AltRename_delete();
break; break;
} }
return 1; return TRUE;
case wimp_EOPEN: case wimp_EOPEN:
{ { int wid;
int wid;
if (window->handle==rename_window->handle) if (window->handle==rename_window->handle)
{ { int toggled;
int toggled; wid = altrename_sprites_per_row (&toggled);
wid = AltRename_sprites_per_row(&toggled);
if (wid != rename_sprites_per_row || toggled) if (wid != rename_sprites_per_row || toggled)
AltRename_delete(); altrename_delete();
} }
break; break;
} }
case wimp_EKEY: case wimp_EKEY:
if (window->handle!=rename_window->handle) break; if (window->handle!=rename_window->handle) break;
switch (e->data.key.chcode) switch (e->data.key.chcode)
{ {
case 13: case 13:
AltRename_renamesprite(rename_sprite,rename_buffer); altrename_renamesprite (rename_sprite, rename_buffer);
if (!akbd_pollctl()) if (!akbd_pollctl ())
{ { altrename_delete ();
AltRename_delete();
break; break;
} }
// fall through /*fall through*/
case 0x18A: /* TAB - next sprite */ 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; if (sprite==0) sprite=rename_window->data->file.sprites;
AltRename_start(rename_window,sprite); altrename_start (rename_window, sprite);
} }
break; break;
case 0x19A: /* Shift TAB - previous sprite */ case 0x19A: /* Shift TAB - previous sprite */
{ { main_sprite *sprite=rename_sprite;
main_sprite* sprite=rename_sprite; for (sprite = rename_window->data->file.sprites;
for (sprite=rename_window->data->file.sprites; !(sprite->link == NULL || sprite->link == rename_sprite);
!(sprite->link==0 || sprite->link==rename_sprite); sprite = sprite->link);
sprite=sprite->link); altrename_start (rename_window, sprite);
AltRename_start(rename_window,sprite);
} }
break; break;
} }
} }
return 0; return FALSE;
} }
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
* JAB, 23 Nov 90 - Doesn't reset options when closing colour window * JAB, 23 Nov 90 - Doesn't reset options when closing colour window
*/ */
#include "swis.h" #include <swis.h>
#include "bbc.h" #include "bbc.h"
#include "wimpt.h" #include "wimpt.h"
...@@ -40,17 +40,6 @@ ...@@ -40,17 +40,6 @@
#include "Colours.h" #include "Colours.h"
#include "PaintLib.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 * * Number of colours in a sprite *
**********************************/ **********************************/
...@@ -91,23 +80,8 @@ void colours_set_gcol (int col, int action, int back) ...@@ -91,23 +80,8 @@ void colours_set_gcol (int col, int action, int back)
os_swi2 (OS_SetColour, action | back << 4, col); os_swi2 (OS_SetColour, action | back << 4, col);
ftracef2 ("SetColour 0x%X=%d\n", col, col); ftracef2 ("SetColour 0x%X=%d\n", col, col);
break; 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 * * Set the gcol, doing sprite ECF selection if appropriate *
...@@ -159,7 +133,7 @@ void colours_event_handler (wimp_eventstr *e, void *handle) ...@@ -159,7 +133,7 @@ void colours_event_handler (wimp_eventstr *e, void *handle)
wimp_redrawstr rds; wimp_redrawstr rds;
unsigned char mono_ttab [256]; unsigned char mono_ttab [256];
static int mono_palette [] = {0x00000000, 0xFFFFFF00}; static const unsigned int mono_palette [] = {0x00000000, 0xFFFFFF00};
mask = psprite_hasmask (sprite); mask = psprite_hasmask (sprite);
lim = nc = colours_count (sprite); lim = nc = colours_count (sprite);
...@@ -259,7 +233,9 @@ void colours_event_handler (wimp_eventstr *e, void *handle) ...@@ -259,7 +233,9 @@ void colours_event_handler (wimp_eventstr *e, void *handle)
os_swi2 (OS_SetColour, 0, t [i]); os_swi2 (OS_SetColour, 0, t [i]);
} }
break; break;
} } } }
}
}
if (!ECF) bbc_rectanglefill (x, y, coloursize - (1 << x_eig), if (!ECF) bbc_rectanglefill (x, y, coloursize - (1 << x_eig),
coloursize - (1 << y_eig)); coloursize - (1 << y_eig));
...@@ -303,7 +279,8 @@ void colours_event_handler (wimp_eventstr *e, void *handle) ...@@ -303,7 +279,8 @@ void colours_event_handler (wimp_eventstr *e, void *handle)
/*Copy nybbles.*/ /*Copy nybbles.*/
bg |= bg >> 4; bg |= bg >> 4;
} } }
}
if (mono_ttab [i /*was colour 31st Jan 1994*/]) if (mono_ttab [i /*was colour 31st Jan 1994*/])
fg = 0 /*black*/; fg = 0 /*black*/;
...@@ -325,9 +302,8 @@ void colours_event_handler (wimp_eventstr *e, void *handle) ...@@ -325,9 +302,8 @@ void colours_event_handler (wimp_eventstr *e, void *handle)
-1, -1, -1, -1,
xpos + coloursize/2 - xpos + coloursize/2 -
(i < nc? (i < 10? 1: i < 100? 2: 3): (i < nc? (i < 10? 1: i < 100? 2: 3):
!ECF? 2: 1)*(main_FILER_TextWidth - 4)/2, !ECF? 1: 2)*(main_FILER_TextWidth - 4)/2,
ypos - ypos - coloursize + (main_FILER_TextHeight/2));
(coloursize + main_FILER_TextHeight + (1 << y_eig))/2);
} }
else else
{ /*WIMP Does not support wimptextop_set_colour.*/ { /*WIMP Does not support wimptextop_set_colour.*/
...@@ -336,9 +312,8 @@ void colours_event_handler (wimp_eventstr *e, void *handle) ...@@ -336,9 +312,8 @@ void colours_event_handler (wimp_eventstr *e, void *handle)
bbc_move (xpos + coloursize/2 - bbc_move (xpos + coloursize/2 -
(i < nc? (i < 10? 1: i < 100? 2: 3): (i < nc? (i < 10? 1: i < 100? 2: 3):
!ECF? 2: 1)*(main_FILER_TextWidth - 4)/2, !ECF? 1: 2)*(main_FILER_TextWidth - 4)/2,
ypos - (coloursize - main_FILER_TextHeight + ypos - (main_FILER_TextHeight/2));
(1 << y_eig))/2);
/*the main_FILER_TextWidth's have 4 taken off to set value /*the main_FILER_TextWidth's have 4 taken off to set value
to the original size*/ to the original size*/
...@@ -348,7 +323,10 @@ void colours_event_handler (wimp_eventstr *e, void *handle) ...@@ -348,7 +323,10 @@ void colours_event_handler (wimp_eventstr *e, void *handle)
puts ("T"); puts ("T");
else else
printf ("E%d", ECF); printf ("E%d", ECF);
} } } } }
}
}
}
wimpt_noerr (wimp_get_rectangle (&rds, &more)); wimpt_noerr (wimp_get_rectangle (&rds, &more));
} }
...@@ -506,7 +484,7 @@ void colours_set_extent (main_sprite *sprite) ...@@ -506,7 +484,7 @@ void colours_set_extent (main_sprite *sprite)
wimp_redrawstr newext; wimp_redrawstr newext;
curr.w = sprite->colourhandle; curr.w = sprite->colourhandle;
wimpt_noerr (PaintLib_get_wind_info (&curr)); wimpt_noerr (paintlib_get_wind_info (&curr));
newext.w = sprite->colourhandle; newext.w = sprite->colourhandle;
calculate_colour_extent (sprite, &newext.box, calculate_colour_extent (sprite, &newext.box,
...@@ -554,13 +532,12 @@ void colours_create_window (main_sprite *sprite) ...@@ -554,13 +532,12 @@ void colours_create_window (main_sprite *sprite)
(psprite_hasmask (sprite)? (psprite_hasmask (sprite)?
colourpicker_DIALOGUE_OFFERS_TRANSPARENT: 0) | colourpicker_DIALOGUE_OFFERS_TRANSPARENT: 0) |
(sprite->gcol == nc? colourpicker_DIALOGUE_TRANSPARENT: 0) | (sprite->gcol == nc? colourpicker_DIALOGUE_TRANSPARENT: 0) |
colourpicker_DIALOGUE_TYPE_CLICK << (colourpicker_DIALOGUE_TYPE_CLICK << colourpicker_DIALOGUE_TYPE_SHIFT);
colourpicker_DIALOGUE_TYPE_SHIFT;
ftracef1 ("flags set to 0x%X\n", dialogue.flags); ftracef1 ("flags set to 0x%X\n", dialogue.flags);
dialogue.title = sprite->colourtitle; dialogue.title = sprite->colourtitle;
dialogue.visible.x0 = sprite_redraw_str.box.x1; dialogue.visible.x0 = sprite_redraw_str.box.x1;
dialogue.visible.y0 = 0; dialogue.visible.y0 = (int)0x80000000;
dialogue.visible.x1 = 0; dialogue.visible.x1 = 0x7FFFFFFF;
dialogue.visible.y1 = sprite_w_state.o.box.y1; dialogue.visible.y1 = sprite_w_state.o.box.y1;
dialogue.xscroll = 0; dialogue.xscroll = 0;
dialogue.yscroll = 0; dialogue.yscroll = 0;
...@@ -574,7 +551,8 @@ void colours_create_window (main_sprite *sprite) ...@@ -574,7 +551,8 @@ void colours_create_window (main_sprite *sprite)
{ m_FREE (sprite->colourtitle, 23); { m_FREE (sprite->colourtitle, 23);
sprite->colourtitle = 0; sprite->colourtitle = 0;
return; return;
} } }
}
else else
{ wimp_wind colours_wind; { wimp_wind colours_wind;
...@@ -608,7 +586,8 @@ void colours_create_window (main_sprite *sprite) ...@@ -608,7 +586,8 @@ void colours_create_window (main_sprite *sprite)
colours_open_str.x = 0; colours_open_str.x = 0;
colours_open_str.y = 0; colours_open_str.y = 0;
wimpt_noerr (wimp_open_wind (&colours_open_str)); wimpt_noerr (wimp_open_wind (&colours_open_str));
} } }
}
else else
{ /* if the window is already open, then bring it to the front */ { /* if the window is already open, then bring it to the front */
wimp_wstate colour_w_state; wimp_wstate colour_w_state;
...@@ -620,11 +599,10 @@ void colours_create_window (main_sprite *sprite) ...@@ -620,11 +599,10 @@ void colours_create_window (main_sprite *sprite)
} }
} }
extern int colours_entry (int nc, int colour) int colours_entry (int nc, int colour)
/*Returns the palette entry corresponding to the given colour number.*/
{ ftracef0 ("colours_entry\n"); { /*Returns the palette entry corresponding to the given colour number.*/
ftracef0 ("colours_entry\n");
switch (nc) switch (nc)
{ case 1 << 15: { case 1 << 15:
...@@ -645,4 +623,5 @@ extern int colours_entry (int nc, int colour) ...@@ -645,4 +623,5 @@ extern int colours_entry (int nc, int colour)
ftracef0 ("INVALID SPRITE MODE!!!\n"); ftracef0 ("INVALID SPRITE MODE!!!\n");
return 0; return 0;
break; break;
} } }
}
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
*/ */
/* > c.Main /* > c.Main
* *
* Paint: RISC O S sprite editor * Paint: RISC OS sprite editor
* Main loop and resource loading * Main loop and resource loading
* *
* Author: A.P. Thompson * Author: A.P. Thompson
...@@ -68,13 +68,15 @@ ...@@ -68,13 +68,15 @@
#include <setjmp.h> #include <setjmp.h>
#include <stdarg.h> #include <stdarg.h>
#include <swis.h> #include <swis.h>
#include "Global/CMOS.h"
#include "Global/FileTypes.h"
#include "pointer.h" #include "pointer.h"
#include "akbd.h" #include "akbd.h"
#include "alarm.h" #include "alarm.h"
#include "baricon.h" #include "baricon.h"
#include "bbc.h" #include "bbc.h"
#include "colourpick.h" #include "colourtran.h"
#include "dboxquery.h" #include "dboxquery.h"
#include "heap.h" #include "heap.h"
#include "help.h" #include "help.h"
...@@ -89,6 +91,8 @@ ...@@ -89,6 +91,8 @@
#include "wimp.h" #include "wimp.h"
#include "wimpt.h" #include "wimpt.h"
#include "xferrecv.h" #include "xferrecv.h"
#include "jpeg.h"
#include "xfersend.h"
#define FILENAMEMAX 255 #define FILENAMEMAX 255
...@@ -103,17 +107,9 @@ ...@@ -103,17 +107,9 @@
#include "ToolWindow.h" #include "ToolWindow.h"
#include "Tools.h" #include "Tools.h"
#include "Colours.h" #include "Colours.h"
#include "jpeg.h"
#include "xfersend.h"
#include "AltRename.h" #include "AltRename.h"
#include "PaintLib.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 FREEZE_STACK 0
#define CATCH_SIGNALS 1 #define CATCH_SIGNALS 1
...@@ -127,9 +123,8 @@ ...@@ -127,9 +123,8 @@
extern _kernel_ExtendProc flex_dont_budge; extern _kernel_ExtendProc flex_dont_budge;
#endif #endif
#define ICON_SPACE_SIZE 1200 #define ICON_SPACE_SIZE 1200 /* For icons in the template */
#define DISPLAY_MARGIN 0
#define DISPLAY_MARGIN 8
#define SPACE_FOR_HELP_TEXT (main_FILER_TextHeight+DISPLAY_MARGIN) #define SPACE_FOR_HELP_TEXT (main_FILER_TextHeight+DISPLAY_MARGIN)
typedef typedef
...@@ -146,15 +141,12 @@ typedef ...@@ -146,15 +141,12 @@ typedef
} }
snapshotstr; snapshotstr;
static main_template File_Template; main_window *main_windows;
static menu Main_Menu;
#define NOEXAMPLE main_options main_current_options;
#ifndef NOEXAMPLE
int never_been_kissed = 1;
#endif
int main_mode_flags; const wimp_box main_big_extent =
{-0x1FFFFFFF, -0x1FFFFFFF, 0x1FFFFFFF, 0x1FFFFFFF};
/************************************************************************** /**************************************************************************
* * * *
...@@ -162,47 +154,27 @@ int main_mode_flags; ...@@ -162,47 +154,27 @@ int main_mode_flags;
* * * *
**************************************************************************/ **************************************************************************/
#ifdef ModuleVersion static main_template file_template;
static main_file fudgefile =
static menu main_menu;
static main_file fudgefile =
{NULL, NULL, NULL, NULL, 0, 0, 1, 0, NULL /* &fudgewindow */}; {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 */ }; 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 = { /* Required to generate relocatable code */
{-0x1FFFFFFF, -0x1FFFFFFF, 0x1FFFFFFF, 0x1FFFFFFF}; fudgefile.window = &fudgewindow;
static void init_statics (void)
{ fudgefile.window = &fudgewindow;
fudgewindow.data = (main_info_block *)&fudgefile; fudgewindow.data = (main_info_block *)&fudgefile;
main_windows = &fudgewindow; 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 static
main_options main_options
...@@ -215,8 +187,6 @@ static ...@@ -215,8 +187,6 @@ static
{/*extended*/ TRUE /*always on in versions from Black onwards*/} {/*extended*/ TRUE /*always on in versions from Black onwards*/}
}; };
main_options main_current_options;
static static
snapshotstr snapshotstr
sshot = sshot =
...@@ -243,92 +213,86 @@ static ...@@ -243,92 +213,86 @@ static
* Now the code * * Now the code *
*******************************************************************/ *******************************************************************/
static void main_clear_background(wimp_redrawstr* rds) 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;
// test tiling disabled in CMOS { sprite_area *base;
_swix(OS_Byte,_INR(0,1) | _OUT(2),161,0x8c,&use_sprite); sprite_area *rombase;
use_sprite=(use_sprite & 128)==0; 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) if (use_sprite)
{ { /* Find tile sprite for mode */
// find sprite for mode os_swix2r (Wimp_BaseOfSprites, 0, 0, &rombase, &base);
_swix(Wimp_BaseOfSprites,_OUTR(0,1),&rombase,&base); sprintf (name, "tile_1-%d", 1<<bbc_vduvar (bbc_Log2BPP));
sprintf(name,"tile_1-%d",1<<bbc_vduvar(bbc_Log2BPP)); sid.s.name = name;
if (_swix(OS_SpriteOp,_INR(0,2) | _OUT(2),0x100+24,base,name,&address)) sid.tag = sprite_id_name;
{ if (sprite_readsize (base, &sid, &sinfo) != NULL)
if (_swix(OS_SpriteOp,_INR(0,2) | _OUT(2),0x100+24,rombase,name,&address)) { if (sprite_readsize (rombase, &sid, &sinfo) != NULL)
use_sprite=0; use_sprite = 0;
base=rombase; 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) if (use_sprite)
{ { int left, top;
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);
if (bbc_vduvar(bbc_Log2BPP)!=bbc_modevar(address->mode,bbc_Log2BPP)) /* Adjust for eigen factors */
{ sinfo.width <<= bbc_vduvar (bbc_XEigFactor);
spriteop=0x200+52; sinfo.height <<= bbc_vduvar (bbc_YEigFactor);
transtab=pixtranstab;
_swix(Wimp_ReadPixTrans,_INR(0,2) | _INR(6,7),0x200,base,address,0,transtab);
}
left=WORKAREA_TO_SCREEN_X(rds,0); left = WORKAREA_TO_SCREEN_X(rds, 0);
left=left+(((left-rds->g.x0)/width)*width); left = left + (((left - rds->g.x0)/sinfo.width) * sinfo.width);
top=WORKAREA_TO_SCREEN_Y(rds,0); top = WORKAREA_TO_SCREEN_Y(rds, 0);
top=top-(((top-rds->g.y1)/height)*height); 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) for (; top>rds->g.y0; top -= sinfo.height)
{ { int x;
int x; for (x = left; x < rds->g.x1; x += sinfo.width)
for (x=left;x<rds->g.x1;x+=width) { if (scaled)
{ use_sprite = (sprite_put_scaled (base, &sid, 0, x, top - sinfo.height, NULL, transtab) == NULL);
use_sprite=!_swix(OS_SpriteOp,_INR(0,7),spriteop,base,address,x,top-height,0,0,transtab); else
use_sprite = (sprite_put_given (base, &sid, 0, x, top - sinfo.height) == NULL);
if (!use_sprite) break; if (!use_sprite) break;
} }
} }
} }
if (!use_sprite) if (!use_sprite)
{ { wimp_paletteword palette_grey;
_swix(ColourTrans_SetGCOL,_IN(0) | _INR(3,4),0xdfdfdf00,0x80,0) /* background_colour */;
bbc_clg();
return;
}
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, os_error *main_read_pixel (sprite_area *area, sprite_id *id,
int x, int y, sprite_colour *colour) 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_error *error = NULL;
os_regset reg_set; os_regset reg_set;
int pal_size; int pal_size;
sprite_header *header; 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*/; reg_set.r [0] = 37 /*create/remove palette*/;
if (id->tag == sprite_id_addr) if (id->tag == sprite_id_addr)
...@@ -391,56 +355,97 @@ static int mouseB (void) ...@@ -391,56 +355,97 @@ static int mouseB (void)
return r.r[2]; return r.r[2];
} }
static void main_icon_bboxes(main_window* window,main_sprite* sprite,wimp_box* iniconbbox, static sprite_header *main_make_newjpeg (sprite_area *area, int size, jpeg_info *info)
wimp_box* spritebbox,wimp_box* namebbox)
{ { sprite_header *header;
int swidth,sheight; int log2bpp = bbc_modevar (-1, bbc_Log2BPP);
int width;
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_info sinfo;
psprite_read_full_info (sprite, &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; if (namebbox != NULL)
swidth=swidth*sprite->mode.scale_xmul; { int width;
sheight=sinfo.height*sprite->iconsize.scale_ymul/sprite->iconsize.scale_ydiv; os_swix3r (Wimp_TextOp, 1, sinfo.name, 0, &width, NULL, NULL);
sheight=sheight*sprite->mode.scale_ymul; width += 16;
if (window->data->file.fullinfo) if (window->data->file.fullinfo)
{ { namebbox->x0 = iniconbbox->x0 + 6*main_FILER_TextWidth;
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->x1 = namebbox->x0 + width; namebbox->x1 = namebbox->x0 + width;
namebbox->y0 = iniconbbox->y0 + main_FILER_TextHeight; namebbox->y0 = iniconbbox->y0 + main_FILER_TextHeight;
namebbox->y1 = namebbox->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 else
{ { spritebbox->x0 = (iniconbbox->x0 + iniconbbox->x1-swidth)/2;
if (spritebbox)
{
spritebbox->x0 = (iniconbbox->x0 + iniconbbox->x1-swidth)/2;
spritebbox->x1 = spritebbox->x0 + swidth; spritebbox->x1 = spritebbox->x0 + swidth;
spritebbox->y0 = iniconbbox->y1 - (main_FILER_Border + main_FILER_YSize + sheight)/2; spritebbox->y0 = iniconbbox->y1 - (main_FILER_Border + main_FILER_YSize + sheight)/2;
spritebbox->y1 = spritebbox->y0 + sheight; 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, ...) ...@@ -460,8 +465,7 @@ void main_iprintf (int flags, int x, int y, char *format, ...)
if (flags & wimp_IFONT) if (flags & wimp_IFONT)
width = 16*strlen (s); width = 16*strlen (s);
else else
{ { os_swix3r (Wimp_TextOp, 1, s, 0, &width, NULL, NULL);
_swix(Wimp_TextOp,_INR(0,2) | _OUT(0),1,s,0,&width);
width/=2; width/=2;
width+=8; width+=8;
} }
...@@ -482,7 +486,6 @@ void main_iprintf (int flags, int x, int y, char *format, ...) ...@@ -482,7 +486,6 @@ void main_iprintf (int flags, int x, int y, char *format, ...)
icon.box.y0 = y - main_FILER_TextHeight; icon.box.y0 = y - main_FILER_TextHeight;
icon.box.y1 = y; icon.box.y1 = y;
icon.flags = (wimp_iconflags) (flags | wimp_ITEXT | wimp_INDIRECT | 7 << 24); icon.flags = (wimp_iconflags) (flags | wimp_ITEXT | wimp_INDIRECT | 7 << 24);
icon.data.indirecttext.buffer = s; icon.data.indirecttext.buffer = s;
icon.data.indirecttext.validstring = (char *) -1; icon.data.indirecttext.validstring = (char *) -1;
...@@ -490,7 +493,10 @@ void main_iprintf (int flags, int x, int y, char *format, ...) ...@@ -490,7 +493,10 @@ void main_iprintf (int flags, int x, int y, char *format, ...)
wimpt_noerr (wimp_ploticon (&icon)); 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 * * Snapshot functions - external for *
...@@ -615,7 +621,7 @@ static void snapshot_happysnapper (int x0, int y0, int x1, int y1) ...@@ -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 /* Create a translation table. If you don't do this, you get
fatal overwriting on saving the screen area to the printer 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, if ((tempsprite.transtab = psprite_ttab_for_sprite (&tempsprite,
-1, (int *) -1)) == NULL) -1, (int *) -1)) == NULL)
{ error = main_error ("PntEG"); { error = main_error ("PntEG");
...@@ -645,9 +651,9 @@ finish: ...@@ -645,9 +651,9 @@ finish:
} }
static void Timer_Cb (dbox d, void *h) 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; h = h;
switch (dbox_get (d)) switch (dbox_get (d))
...@@ -663,12 +669,13 @@ static void Timer_Cb (dbox d, void *h) ...@@ -663,12 +669,13 @@ static void Timer_Cb (dbox d, void *h)
dbox_dispose (&sshot.timer); dbox_dispose (&sshot.timer);
sshot.timer = NULL; sshot.timer = NULL;
break; break;
} } }
}
static void Snapshot_Cb (int due, void *h) 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"); ftracef0 ("Snapshot_Cb\n");
due = due, h = h; /*for Norcroft*/ due = due, h = h; /*for Norcroft*/
...@@ -713,7 +720,8 @@ static void Snapshot_Cb (int due, void *h) ...@@ -713,7 +720,8 @@ static void Snapshot_Cb (int due, void *h)
{ /*Kill it.*/ { /*Kill it.*/
dbox_dispose (&sshot.timer); dbox_dispose (&sshot.timer);
sshot.timer = NULL; sshot.timer = NULL;
} } }
}
if (secs_left == 0) if (secs_left == 0)
{ /*Smile for the camera.*/ { /*Smile for the camera.*/
...@@ -886,7 +894,7 @@ static int ramfetch_buffer_extender (char **buffer, int *size) ...@@ -886,7 +894,7 @@ static int ramfetch_buffer_extender (char **buffer, int *size)
static BOOL ramtransfer_file (wimp_msgdatasave *ms) 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); ram_size, log2_bpp = bbc_modevar (-1, bbc_Log2BPP);
sprite_area *area; sprite_area *area;
sprite_header *header; sprite_header *header;
...@@ -894,8 +902,8 @@ static BOOL ramtransfer_file (wimp_msgdatasave *ms) ...@@ -894,8 +902,8 @@ static BOOL ramtransfer_file (wimp_msgdatasave *ms)
ftracef0 ("ramtransfer_file\n"); ftracef0 ("ramtransfer_file\n");
/*only interested in sprites*/ /*only interested in sprites*/
/*and jpeg's. J R C 27th Jun 1994*/ /*and jpeg's. J R C 27th Jun 1994*/
if (!((file_type = xferrecv_checkimport (&size)) == SPRITE_FILE || if (!((file_type = xferrecv_checkimport (&size)) == FileType_Sprite ||
file_type == jpeg_FILE_TYPE)) file_type == FileType_JPEG))
{ werr (FALSE, msgs_lookup ("PntEB"), ms->leaf); { werr (FALSE, msgs_lookup ("PntEB"), ms->leaf);
return FALSE; return FALSE;
} }
...@@ -924,111 +932,85 @@ static BOOL ramtransfer_file (wimp_msgdatasave *ms) ...@@ -924,111 +932,85 @@ static BOOL ramtransfer_file (wimp_msgdatasave *ms)
return FALSE; return FALSE;
} }
if (file_type == jpeg_FILE_TYPE) if (file_type == FileType_JPEG)
{ /*For JPEG's, we find it convenient to read the file data into { 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 |ramfetch_buffer| (since that is how ramfetch_buffer_extender() is set
up), then read the consequent sprite size, malloc that much space, up), then read the consequent sprite size, malloc that much space,
paint the sprite and copy it back into |ramfetch_buffer|.*/ paint the sprite and copy it back into |ramfetch_buffer|.*/
ram_size = flex_size ((flex_ptr) &ramfetch_buffer); ram_size = flex_size ((flex_ptr) &ramfetch_buffer);
#ifdef XTRACE #ifdef XTRACE
{ char cmd [1024]; { char cmd [128];
sprintf (cmd, "%%Save $.JPEG %X +%X", ramfetch_buffer, ram_size); sprintf (cmd, "%%Save $.JPEG %X +%X", ramfetch_buffer, ram_size);
os_cli (cmd); os_cli (cmd);
} }
#endif #endif
if (wimpt_complain (xjpeginfo_dimensions jid.s.image.addr = ramfetch_buffer;
((jpeg_image *) &ramfetch_buffer [12], ram_size, NULL, &width, jid.s.image.size = ram_size;
&height, NULL, NULL)) != NULL) jid.tag = jpeg_id_addr;
if (wimpt_complain (jpeg_readinfo (&jid, &jinfo)) != NULL)
{ flex_free ((flex_ptr) &ramfetch_buffer); { flex_free ((flex_ptr) &ramfetch_buffer);
return FALSE; return FALSE;
} }
sprite_size = psprite_size (width, height, wimpt_mode (), /*mask?*/ FALSE, sprite_size = psprite_size (jinfo.width, jinfo.height, wimpt_mode (),
2 /*full palette*/); 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); { flex_free ((flex_ptr) &ramfetch_buffer);
return FALSE; return FALSE;
} }
/*... redirect output into 'area + 16' ...*/ /*Create an empty sprite called '!newjpeg' in area*/
area->size = sprite_size + 16; header = main_make_newjpeg(area, sprite_size, &jinfo);
area->number = 1;
area->sproff = 16;
area->freeoff = sprite_size + 16;
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.*/ /*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), if (wimpt_complain (os_swix4 (OS_SpriteOp, 0x1A | 512,
0x1A | 512, area, header, ms->leaf)) != NULL) area, header, ms->leaf)) != NULL)
return -1; return -1;
ftracef5 ("SPRITE %.12s: mode 0x%X, width %d + 1 words, height %d + " ftracef5 ("SPRITE %.12s: mode 0x%X, width %d words, height %d pixels, rbit %d\n",
"1 pixels, rbit %d\n", header->name, header->mode, header->width, header->name, header->mode, 1 + header->width, 1 + header->height,
header->height, header->rbit); header->rbit);
if (log2_bpp <= 3) if (log2_bpp <= 3)
/*Set the sprite's palette to be the same as the screen one. JRC 6th Feb /*Set the sprite's palette to be the same as the screen one. JRC 6th Feb
1995.*/ 1995.*/
if (wimpt_complain (_swix (ColourTrans_ReadPalette, if (wimpt_complain (os_swix5 (ColourTrans_ReadPalette, -1, -1,
_IN(0)|_IN(1)|_IN(2)|_IN(3)|_IN(4), -1, -1, header + 1, header + 1, 8 << (1 << log2_bpp), 1 << 1)) != NULL)
8 << (1 << log2_bpp), 1 << 1)) != NULL) { m_FREE (area, sprite_size + sizeof (sprite_area));
{ m_FREE (area, sprite_size + 16);
flex_free ((flex_ptr) &ramfetch_buffer); flex_free ((flex_ptr) &ramfetch_buffer);
return FALSE; return FALSE;
} }
if (wimpt_complain (_swix (OS_SpriteOp, jid.s.image.addr = ramfetch_buffer; /*Might have shifted*/
_IN(0)|_IN(1)|_IN(2)|_IN(3)|_OUT(1)|_OUT(2)|_OUT(3), if (wimpt_complain (main_plot_fromjpeg (area, header, &jid)) != NULL)
0x23C, area, header, 0, &s1, &s2, &s3)) != NULL) { m_FREE (area, sprite_size + sizeof (sprite_area));
{ m_FREE (area, sprite_size + 16);
flex_free ((flex_ptr) &ramfetch_buffer); flex_free ((flex_ptr) &ramfetch_buffer);
return FALSE; return FALSE;
} }
if (wimpt_complain (xjpeg_plot_scaled ((jpeg_image *) &ramfetch_buffer [12], if (!flex_extend ((flex_ptr) &ramfetch_buffer, sprite_size + sizeof (sprite_area)))
0, 0, NULL, ram_size, jpeg_SCALE_DITHERED | jpeg_SCALE_ERROR_DIFFUSED)) != NULL) { m_FREE (area, sprite_size + sizeof (sprite_area));
{ m_FREE (area, sprite_size + 16);
flex_free ((flex_ptr) &ramfetch_buffer); flex_free ((flex_ptr) &ramfetch_buffer);
return FALSE; return FALSE;
} }
/*... direct output back ...*/ /*Make it look like a sprite file by trimming off 4 bytes*/
if (wimpt_complain (_swix (OS_SpriteOp, _IN(0)|_IN(1)|_IN(2)|_IN(3), memcpy (ramfetch_buffer, &area->number,
0x23C, s1, s2, s3)) != NULL) sprite_size + sizeof (sprite_area) - sizeof (area->size));
{ m_FREE (area, sprite_size + 16); #ifdef XTRACE
flex_free ((flex_ptr) &ramfetch_buffer); { char cmd [128];
return FALSE; sprintf (cmd, "%%Save $.Sprite %X +%X", &area->size,
} sprite_size + sizeof (sprite_area) - sizeof (area->size));
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);
os_cli (cmd); os_cli (cmd);
} }
#endif #endif
m_FREE (area, sprite_size + 16); m_FREE (area, sprite_size + sizeof (sprite_area));
} }
return TRUE; return TRUE;
...@@ -1045,9 +1027,9 @@ void main_force_redraw (wimp_w handle) ...@@ -1045,9 +1027,9 @@ void main_force_redraw (wimp_w handle)
ftracef0 ("main_force_redraw\n"); ftracef0 ("main_force_redraw\n");
rds.w = handle; rds.w = handle;
rds.box = main_big_extent; rds.box = main_big_extent;
ftracef0("do wimp_force_redraw\n"); ftracef0 ("do wimp_force_redraw\n");
wimpt_noerr (wimp_force_redraw (&rds)); wimpt_noerr (wimp_force_redraw (&rds));
ftracef0("done\n"); ftracef0 ("done\n");
} }
/************************************+** /************************************+**
...@@ -1071,7 +1053,7 @@ void main_set_extent (main_window *window) ...@@ -1071,7 +1053,7 @@ void main_set_extent (main_window *window)
x = main_FILER_TotalWidth, y = main_FILER_TotalHeight; x = main_FILER_TotalWidth, y = main_FILER_TotalHeight;
curr.w = window->handle; curr.w = window->handle;
wimpt_noerr (PaintLib_get_wind_info (&curr)); wimpt_noerr (paintlib_get_wind_info (&curr));
nsprites = window->data->file.spritearea->number; nsprites = window->data->file.spritearea->number;
ftracef1 ("main_set_extent: %d sprites across\n", nsprites); ftracef1 ("main_set_extent: %d sprites across\n", nsprites);
...@@ -1120,7 +1102,7 @@ void main_set_extent (main_window *window) ...@@ -1120,7 +1102,7 @@ void main_set_extent (main_window *window)
wimpt_noerr (wimp_set_extent (&newext)); wimpt_noerr (wimp_set_extent (&newext));
curr.w = window->handle; curr.w = window->handle;
wimpt_noerr (PaintLib_get_wind_info (&curr)); wimpt_noerr (paintlib_get_wind_info (&curr));
ftracef0 ("Really resetting\n"); ftracef0 ("Really resetting\n");
wimpt_noerr (wimp_open_wind ((wimp_openstr *) &curr)); wimpt_noerr (wimp_open_wind ((wimp_openstr *) &curr));
...@@ -1131,7 +1113,8 @@ void main_set_extent (main_window *window) ...@@ -1131,7 +1113,8 @@ void main_set_extent (main_window *window)
window->data->file.lastwidth = no_across; /*avoid ghastly flicker. J R C window->data->file.lastwidth = no_across; /*avoid ghastly flicker. J R C
18th Oct 1993*/ 18th Oct 1993*/
} } }
}
/************************** /**************************
* * * *
...@@ -1151,7 +1134,7 @@ void main_window_delete (main_window *thiswindow) ...@@ -1151,7 +1134,7 @@ void main_window_delete (main_window *thiswindow)
{ main_window *window = (main_window *) &main_windows; { main_window *window = (main_window *) &main_windows;
AltRename_delete(); altrename_delete ();
ftracef2 ("main_window_delete: killing %s window: %d\n", ftracef2 ("main_window_delete: killing %s window: %d\n",
thiswindow->tag == main_window_is_file? "file": "sprite", thiswindow->tag == main_window_is_file? "file": "sprite",
...@@ -1168,7 +1151,8 @@ void main_window_delete (main_window *thiswindow) ...@@ -1168,7 +1151,8 @@ void main_window_delete (main_window *thiswindow)
sizeof (main_sprite_window)); sizeof (main_sprite_window));
m_FREE (thiswindow, sizeof (main_window)); m_FREE (thiswindow, sizeof (main_window));
win_activedec (); win_activedec ();
} } }
}
/************************** /**************************
* File window killer * * File window killer *
...@@ -1178,34 +1162,27 @@ static void delete_file_window (main_window *window) ...@@ -1178,34 +1162,27 @@ static void delete_file_window (main_window *window)
{ main_sprite *sprite; { main_sprite *sprite;
main_file *file = &window->data->file; main_file *file = &window->data->file;
int loop=0,count=0; int loop = 0, count = 0;
ftracef0 ("delete_file_window\n"); 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++; count++;
} if (count)
main_sprite *todelete[count]; { main_sprite *todelete[count];
for (sprite=file->sprites;sprite!=NULL;sprite=sprite->link)
{ /* First copy all their pointers into an array */
todelete[loop] = sprite; for (sprite = file->sprites; sprite != NULL; sprite = sprite->link)
{ todelete[loop] = sprite;
loop++; loop++;
} }
#if 1 /* Delete all the pointers in the array backwards (flex faster) */
/* And delete all the pointers in the array backwards,faster */ for (loop=count-1;loop>=0;loop--)
for (loop=count-1; loop != -1; loop--) psprite_delete (window, todelete[loop]);
#else
/* And delete all the pointers in the array forwards,slow */
for (loop=0; loop<count; loop++)
#endif
{
psprite_delete (window,todelete[loop]);
}
ftracef0 ("deleted all sprite blocks\n"); ftracef0 ("deleted all sprite blocks\n");
}
flex_free ((flex_ptr) &file->spritearea); flex_free ((flex_ptr) &file->spritearea);
if (file->filename != NULL) flex_free ((flex_ptr) &file->filename); if (file->filename != NULL) flex_free ((flex_ptr) &file->filename);
...@@ -1325,23 +1302,23 @@ void main_check_position (main_window *w) ...@@ -1325,23 +1302,23 @@ void main_check_position (main_window *w)
static int Load_File (main_window *window, char *filename, int merge, static int Load_File (main_window *window, char *filename, int merge,
int safe) int safe)
/*Copes with JPEGs now. J R C 24th Jun 1994*/
{ int rc = 1, i = 0, offset, ramcopy = filename == (char *) -1, { int rc = 1, i = 0, offset, ramcopy = filename == (char *) -1,
temp_file = !(safe || xferrecv_file_is_safe ()), file_type = SPRITE_FILE, temp_file = !(safe || xferrecv_file_is_safe ()), file_type = FileType_Sprite,
sprite_size, width, height, s1, s2, s3, sprite_size,
log2_bpp = bbc_modevar (-1, bbc_Log2BPP); log2_bpp = bbc_modevar (-1, bbc_Log2BPP);
os_filestr filestr; os_filestr filestr;
main_sprite *sprite, **sprptr; main_sprite *sprite, **sprptr;
sprite_header *header; sprite_header *header;
main_file *file = &window->data->file; main_file *file = &window->data->file;
wimp_winfo curr; wimp_winfo curr;
jpeg_id jid;
jpeg_info jinfo;
if (window->selection.flags & MW_SELSAVING) return 0; if (window->selection.flags & MW_SELSAVING) return 0;
ftracef0 ("Load_File\n"); ftracef0 ("Load_File\n");
AltRename_delete(); altrename_delete ();
ftracef4 ("Asked to %s %s %s into window 0x%X\n", ftracef4 ("Asked to %s %s %s into window 0x%X\n",
merge? "merge": "load", merge? "merge": "load",
...@@ -1364,10 +1341,11 @@ static int Load_File (main_window *window, char *filename, int merge, ...@@ -1364,10 +1341,11 @@ static int Load_File (main_window *window, char *filename, int merge,
} }
file_type = (filestr.loadaddr & 0xFFF00) >> 8; 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); { werr (FALSE, msgs_lookup ("PntEB"), filename);
return 0; /* failed */ return 0; /* failed */
} } }
}
else else
filestr.start = flex_size ((flex_ptr) &ramfetch_buffer); filestr.start = flex_size ((flex_ptr) &ramfetch_buffer);
...@@ -1383,94 +1361,72 @@ static int Load_File (main_window *window, char *filename, int merge, ...@@ -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)) { if (!flex_extend ((flex_ptr) &file->filename, strlen (filename) + 1))
{ main_NO_ROOM ("extended file title"); { main_NO_ROOM ("extended file title");
return -1; return -1;
} } } }
}
}
/*If ramcopy or merge, read the stuff to be loaded into ramfetch_buffer /*If ramcopy or merge, read the stuff to be loaded into ramfetch_buffer
(already there if ramcopy). Otherwise (filecopy and not merge), just make (already there if ramcopy). Otherwise (filecopy and not merge), just make
sure that file->spritearea is big enough to load the file into.*/ sure that file->spritearea is big enough to load the file into.*/
if (!ramcopy) if (!ramcopy)
{ /*Copying from a file.*/ { /*Copying from a file.*/
if (file_type == SPRITE_FILE) if (file_type == FileType_Sprite)
sprite_size = filestr.start - 12; sprite_size = filestr.start - 12;
else else
{ if (wimpt_complain (xjpegfileinfo_dimensions (filename, NULL, &width, { jid.s.name = filename;
&height, NULL, NULL))) jid.tag = jpeg_id_name;
if (wimpt_complain (jpeg_readinfo (&jid, &jinfo)))
return 0; 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, sprite_size = psprite_size (jinfo.width, jinfo.height, wimpt_mode (),
2 /*full palette*/); FALSE /*mask?*/, 2 /*full palette*/);
} }
if (merge) if (merge)
{ /*filecopy && merge*/ { /*filecopy && merge*/
ftracef0 ("allocate ram buffer for file\n"); 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")); { werr (FALSE, msgs_lookup ("PntEG"));
return -1; return -1;
} }
ftracef0 ("load file into ram buffer\n"); ftracef0 ("load file into ram buffer\n");
if (file_type == SPRITE_FILE) if (file_type == FileType_Sprite)
{ ftracef1 ("writing size (%d) at front of buffer\n", sprite_size + 16); { ftracef1 ("writing size (%d) at front of buffer\n", sprite_size + sizeof (sprite_area));
*(int *) ramfetch_buffer = sprite_size + 16; *(int *) ramfetch_buffer = sprite_size + sizeof (sprite_area);
/* convert into sprite area */ /* convert into sprite area */
if (wimpt_complain (sprite_area_load if (wimpt_complain (sprite_area_load
((sprite_area *) ramfetch_buffer, filename))) ((sprite_area *) ramfetch_buffer, filename)))
{ flex_free ((flex_ptr) &ramfetch_buffer); { flex_free ((flex_ptr) &ramfetch_buffer);
return -1; return -1;
} } }
}
else else
{ char *cc; { char *cc;
/*... redirect output into 'file->spritearea + 16' ...*/ /*Create an empty sprite called '!newjpeg' in ramfetch_buffer*/
((int *) ramfetch_buffer) [0] = sprite_size + 16; header = main_make_newjpeg((sprite_area *)ramfetch_buffer, sprite_size, &jinfo);
((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;
/*Set the name with a sprite op to get the case right.*/ /*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), if (wimpt_complain (os_swix4 (OS_SpriteOp, 0x1A | 512,
0x1A | 512, file->spritearea, header, (cc = strrchr (filename, file->spritearea, header,
'.')) != NULL || (cc = strrchr (filename, ':')) != NULL? cc + 1: (cc = strrchr (filename, '.')) != NULL ||
"jpeg")) != NULL) (cc = strrchr (filename, ':')) != NULL ? cc + 1 : "jpeg")) != NULL)
return -1; return -1;
ftracef5 ("SPRITE %.12s: mode 0x%X, width %d + 1 words, height %d + " ftracef5 ("SPRITE %.12s: mode 0x%X, width %d words, height %d pixels, rbit %d\n",
"1 pixels, rbit %d\n", header->name, header->mode, header->width, header->name, header->mode, 1 + header->width, 1 + header->height,
header->height, header->rbit); header->rbit);
if (log2_bpp <= 3) if (log2_bpp <= 3)
/*Set the sprite's palette to be the same as the screen one. JRC 6th /*Set the sprite's palette to be the same as the screen one. JRC 6th
Feb 1995.*/ Feb 1995.*/
if (wimpt_complain (_swix (ColourTrans_ReadPalette, if (wimpt_complain (os_swix5 (ColourTrans_ReadPalette, -1, -1,
_IN(0)|_IN(1)|_IN(2)|_IN(3)|_IN(4), -1, -1, header + 1, header + 1, 8 << (1 << log2_bpp), 1 << 1)) != NULL)
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)
return -1; return -1;
if (wimpt_complain (xjpeg_plot_file_scaled (filename, 0, 0, NULL, if (wimpt_complain (main_plot_fromjpeg ((sprite_area *)ramfetch_buffer, header, &jid)) != 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)
return -1; return -1;
rc = 1; rc = 1;
...@@ -1478,13 +1434,13 @@ static int Load_File (main_window *window, char *filename, int merge, ...@@ -1478,13 +1434,13 @@ static int Load_File (main_window *window, char *filename, int merge,
} }
else else
{ /*filecopy && !merge*/ { /*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")); { werr (FALSE, msgs_lookup ("PntEG"));
return -1; return -1;
} }
ftracef0 ("initialise sprite area\n"); 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*/ else /*ramcopy - file contents already converted to sprite*/
...@@ -1496,13 +1452,12 @@ static int Load_File (main_window *window, char *filename, int merge, ...@@ -1496,13 +1452,12 @@ static int Load_File (main_window *window, char *filename, int merge,
return -1; return -1;
} }
ftracef1 ("writing size (%d) at front of buffer\n", sprite_size + 16); ftracef1 ("writing size (%d) at front of buffer\n", sprite_size + sizeof (sprite_area));
*(int *) ramfetch_buffer = sprite_size + 16; *(int *) ramfetch_buffer = sprite_size + sizeof (sprite_area);
/* convert into sprite area */ /* convert into sprite area */
ftracef0 ("verify area ...\n"); /*J R C 18th Nov 1994*/ ftracef0 ("verify area ...\n"); /*J R C 18th Nov 1994*/
if (wimpt_complain (_swix (OS_SpriteOp, _IN(0)|_IN(1), 512 | 17, if (wimpt_complain (os_swix2 (OS_SpriteOp, 512 | 17, ramfetch_buffer)))
ramfetch_buffer)))
{ ftracef0 ("area invalid\n"); { ftracef0 ("area invalid\n");
return NULL; return NULL;
} }
...@@ -1511,7 +1466,7 @@ static int Load_File (main_window *window, char *filename, int merge, ...@@ -1511,7 +1466,7 @@ static int Load_File (main_window *window, char *filename, int merge,
if (ramcopy || merge) if (ramcopy || merge)
{ ftracef0 ("copy all the ram sprites across\n"); { 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; -1;
flex_free ((flex_ptr) &ramfetch_buffer); flex_free ((flex_ptr) &ramfetch_buffer);
} }
...@@ -1525,13 +1480,12 @@ static int Load_File (main_window *window, char *filename, int merge, ...@@ -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", ftracef2 ("Load_File: loading \"%s\" into area 0x%X\n",
filename, file->spritearea); filename, file->spritearea);
if (file_type == SPRITE_FILE) if (file_type == FileType_Sprite)
{ if (wimpt_complain (sprite_area_load (file->spritearea, filename))) { if (wimpt_complain (sprite_area_load (file->spritearea, filename)))
return NULL; return NULL;
ftracef0 ("verify area ...\n"); /*J R C 7th Nov 1994*/ ftracef0 ("verify area ...\n"); /*J R C 7th Nov 1994*/
if (wimpt_complain (_swix (OS_SpriteOp, _IN(0)|_IN(1), 512 | 17, if (wimpt_complain (os_swix2 (OS_SpriteOp, 512 | 17, file->spritearea)))
file->spritearea)))
{ ftracef0 ("area invalid\n"); { ftracef0 ("area invalid\n");
return NULL; return NULL;
} }
...@@ -1540,53 +1494,27 @@ static int Load_File (main_window *window, char *filename, int merge, ...@@ -1540,53 +1494,27 @@ static int Load_File (main_window *window, char *filename, int merge,
else else
{ char *cc; { char *cc;
/*... redirect output into 'file->spritearea + 16' ...*/ /*Create an empty sprite called '!newjpeg' in file->spritearea*/
file->spritearea->number = 1; header = main_make_newjpeg(file->spritearea, sprite_size, &jinfo);
file->spritearea->sproff = 16;
file->spritearea->freeoff = sprite_size + 16;
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.*/ /*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), if (wimpt_complain (os_swix4 (OS_SpriteOp, 0x1A | 512,
0x1A | 512, file->spritearea, header, (cc = strrchr (filename, file->spritearea, header,
'.')) != NULL || (cc = strrchr (filename, ':')) != NULL? cc + 1: (cc = strrchr (filename, '.')) != NULL ||
"jpeg")) != NULL) (cc = strrchr (filename, ':')) != NULL ? cc + 1 : "jpeg")) != NULL)
return -1; return -1;
ftracef5 ("SPRITE %.12s: mode 0x%X, width %d + 1 words, height %d + " ftracef5 ("SPRITE %.12s: mode 0x%X, width %d words, height %d pixels, rbit %d\n",
"1 pixels, rbit %d\n", header->name, header->mode, header->width, header->name, header->mode, 1 + header->width, 1 + header->height,
header->height, header->rbit); header->rbit);
if (log2_bpp <= 3) if (log2_bpp <= 3)
/*Set the sprite's palette to be the same as the screen one. JRC 6th /*Set the sprite's palette to be the same as the screen one. JRC 6th
Feb 1995.*/ Feb 1995.*/
if (wimpt_complain (_swix (ColourTrans_ReadPalette, if (wimpt_complain (os_swix5 (ColourTrans_ReadPalette, -1, -1,
_IN(0)|_IN(1)|_IN(2)|_IN(3)|_IN(4), -1, -1, header + 1, header + 1, 8 << (1 << log2_bpp), 1 << 1)) != NULL)
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)
rc = -1; rc = -1;
/*... direct output back ...*/ if (wimpt_complain (main_plot_fromjpeg (file->spritearea, header, &jid)) != NULL)
if (wimpt_complain (_swix (OS_SpriteOp, _IN(0)|_IN(1)|_IN(2)|_IN(3),
0x23C, s1, s2, s3)) != NULL)
rc = -1; rc = -1;
} }
...@@ -1603,7 +1531,8 @@ static int Load_File (main_window *window, char *filename, int merge, ...@@ -1603,7 +1531,8 @@ static int Load_File (main_window *window, char *filename, int merge,
} }
sprptr = &(*sprptr)->link; /* keep at end of list */ sprptr = &(*sprptr)->link; /* keep at end of list */
} } }
}
if (merge) main_set_modified (file); if (merge) main_set_modified (file);
psprite_set_plot_info (file); psprite_set_plot_info (file);
...@@ -1612,7 +1541,7 @@ static int Load_File (main_window *window, char *filename, int merge, ...@@ -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 */ /* now shrink box if not enough sprites to fill it */
curr.w = window->handle; 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 > if (curr.info.box.x1-curr.info.box.x0 >
file->spritearea->number*main_FILER_TotalWidth) file->spritearea->number*main_FILER_TotalWidth)
{ curr.info.box.x1 = curr.info.box.x0 + { curr.info.box.x1 = curr.info.box.x0 +
...@@ -1633,7 +1562,7 @@ static int Load_File (main_window *window, char *filename, int merge, ...@@ -1633,7 +1562,7 @@ static int Load_File (main_window *window, char *filename, int merge,
main_set_extent (window); 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; { main_sprite_window *sprw;
for (sprw = sprite->windows; sprw != NULL; sprw = sprw->link) for (sprw = sprite->windows; sprw != NULL; sprw = sprw->link)
...@@ -1648,9 +1577,9 @@ static int Load_File (main_window *window, char *filename, int merge, ...@@ -1648,9 +1577,9 @@ static int Load_File (main_window *window, char *filename, int merge,
return rc; return rc;
} }
static void main_draw_icon(main_window* window,main_sprite* sprite,int x0,int y0,wimp_redrawstr* rds) static void main_draw_icon (main_window *window, main_sprite *sprite, int x0, int y0, wimp_redrawstr *rds)
{
sprite_info infoblock; { sprite_info infoblock;
int sx, sy; int sx, sy;
psprite_info sinfo; psprite_info sinfo;
...@@ -1741,19 +1670,20 @@ static void main_draw_icon(main_window* window,main_sprite* sprite,int x0,int y0 ...@@ -1741,19 +1670,20 @@ static void main_draw_icon(main_window* window,main_sprite* sprite,int x0,int y0
} }
/* bbox in work area coords */ /* bbox in work area coords */
static void main_update_icon(main_window* window,main_sprite* sprite,wimp_box* bbox) static void main_update_icon (main_window *window, main_sprite *sprite, wimp_box *bbox)
{
wimp_redrawstr ds; { wimp_redrawstr ds;
int more; int more;
os_error* e; os_error *e;
ds.w=window->handle;
ds.box=*bbox; ds.w = window->handle;
ds.box = *bbox;
/* just redraw area containing higlighted parts in fullinfo to reduce flicker */ /* 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; 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)) for (e = wimp_update_wind(&ds,&more); !e && more; e = wimp_get_rectangle(&ds, &more))
{ { main_clear_background (&ds);
main_clear_background(&ds); main_draw_icon(window, sprite, bbox->x0, bbox->y0, &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 ...@@ -1761,246 +1691,225 @@ static void main_update_icon(main_window* window,main_sprite* sprite,wimp_box* b
* selections * * selections *
********************************************************/ ********************************************************/
typedef enum typedef enum
{ { SI_SELECT,
SI_SELECT,
SI_CLEAR, SI_CLEAR,
SI_TOGGLE SI_TOGGLE
} select_icon_how; } select_icon_how;
static void main_select_icon(main_window* window,main_sprite* sprite,wimp_box* iconbbox,select_icon_how how) static void main_select_icon(main_window *window, main_sprite *sprite, wimp_box *iconbbox, select_icon_how how)
{
switch (how) { switch (how)
{ { case SI_CLEAR: /* clear */
case SI_CLEAR: /* clear */
if (sprite->flags & MSF_SELECTED) if (sprite->flags & MSF_SELECTED)
{ { sprite->flags &= ~MSF_SELECTED;
sprite->flags &= ~MSF_SELECTED;
window->selection.count--; window->selection.count--;
main_update_icon(window,sprite,iconbbox); main_update_icon (window, sprite, iconbbox);
} }
break; break;
case SI_SELECT: /* set */ case SI_SELECT: /* set */
if (!(sprite->flags & MSF_SELECTED)) if (!(sprite->flags & MSF_SELECTED))
{ { sprite->flags |= MSF_SELECTED;
sprite->flags |= MSF_SELECTED;
window->selection.count++; window->selection.count++;
main_update_icon(window,sprite,iconbbox); main_update_icon (window, sprite, iconbbox);
} }
break; break;
case SI_TOGGLE: /* toggle */ case SI_TOGGLE: /* toggle */
if (sprite->flags & MSF_SELECTED) if (sprite->flags & MSF_SELECTED)
{ { sprite->flags &= ~MSF_SELECTED;
sprite->flags &= ~MSF_SELECTED;
window->selection.count--; window->selection.count--;
main_update_icon(window,sprite,iconbbox); main_update_icon (window, sprite, iconbbox);
} }
else else
{ { sprite->flags |= MSF_SELECTED;
sprite->flags |= MSF_SELECTED;
window->selection.count++; window->selection.count++;
main_update_icon(window,sprite,iconbbox); main_update_icon (window, sprite, iconbbox);
} }
} }
} }
#define MIN_TARGET_SIZE 64 #define MIN_TARGET_SIZE 64
static void ensure_min_target_size(wimp_box* bbox,int fullinfo) static void ensure_min_target_size(wimp_box *bbox, int fullinfo)
{
if (bbox->x1-bbox->x0 < MIN_TARGET_SIZE) { if (bbox->x1-bbox->x0 < MIN_TARGET_SIZE)
{ { if (!fullinfo) bbox->x0=(bbox->x0+bbox->x1-MIN_TARGET_SIZE)/2;
if (!fullinfo) bbox->x0=(bbox->x0+bbox->x1-MIN_TARGET_SIZE)/2;
bbox->x1=bbox->x0+MIN_TARGET_SIZE; bbox->x1=bbox->x0+MIN_TARGET_SIZE;
} }
if (bbox->y1-bbox->y0 < 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; bbox->y1=bbox->y0+MIN_TARGET_SIZE;
} }
} }
/* clip area in work area coords */ /* clip area in work area coords */
static void main_clear_selection(main_window *window,wimp_box* clip,select_icon_how how) static void main_clear_selection (main_window *window, wimp_box *clip, select_icon_how how)
{
static wimp_box defclip = {0,-0x7f000000,0x7f000000,0}; { static wimp_box defclip = {0, -0x7f000000, 0x7f000000, 0};
wimp_box bbox; wimp_box bbox;
main_sprite *sprite; main_sprite *sprite;
int width,height; int width, height;
wimp_wstate ws; wimp_wstate ws;
int column,spritesperrow; int column, spritesperrow;
int left,top; 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) if (window->data->file.fullinfo)
{ { width = main_FILER_FullInfoWidth;
width = main_FILER_FullInfoWidth;
height = main_FILER_FullInfoHeight; height = main_FILER_FullInfoHeight;
} }
else else
{ { width = main_FILER_TotalWidth;
width = main_FILER_TotalWidth;
height = main_FILER_TotalHeight; height = main_FILER_TotalHeight;
} }
wimpt_noerr (wimp_get_wind_state (window->handle, &ws)); wimpt_noerr (wimp_get_wind_state (window->handle, &ws));
spritesperrow = (ws.o.box.x1 - ws.o.box.x0) / width; spritesperrow = (ws.o.box.x1 - ws.o.box.x0) / width;
if (spritesperrow == 0)
spritesperrow = 1;
column=0; column = 0;
left=0; left = 0;
top=0; top = 0;
for (sprite=window->data->file.sprites;sprite != NULL; sprite = sprite->link) for (sprite = window->data->file.sprites; sprite != NULL; sprite = sprite->link)
{ { if (main_CLIPS(clip, left, top-height, left+width, top))
if (main_CLIPS(clip,left,top-height, left+width,top)) { int is_over_graphic = 1;
{ bbox.x0 = left;
int is_over_graphic=1; bbox.x1 = left + width;
bbox.x0=left; bbox.y0 = top - height;
bbox.x1=left+width; bbox.y1 = top;
bbox.y0=top-height;
bbox.y1=top;
if (bbox.x0<clip->x0 || bbox.x1>clip->x1 || bbox.y0<clip->y0 || bbox.y1>clip->y1) 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; 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; is_over_graphic = 0;
if (main_CLIPS(&spritebbox,clip->x0,clip->y0,clip->x1,clip->y1) || 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; main_CLIPS(&namebbox, clip->x0, clip->y0, clip->x1, clip->y1))
is_over_graphic = 1;
} }
if (is_over_graphic) if (is_over_graphic)
main_select_icon(window,sprite,&bbox,how); main_select_icon(window, sprite, &bbox, how);
} }
column++; column++;
left+=width; left += width;
if (column==spritesperrow) if (column == spritesperrow)
{ { column = 0;
column=0; left = 0;
left=0; top -= height;
top-=height;
} }
} }
} }
void main_select_all(main_window* window) void main_select_all (main_window *window)
{
main_clear_selection(window,0,SI_SELECT); { main_clear_selection (window, 0, SI_SELECT);
} }
void main_clear_all(main_window* window) void main_clear_all (main_window *window)
{
main_clear_selection(window,0,SI_CLEAR); { main_clear_selection (window, 0, SI_CLEAR);
} }
static BOOL main_select_area(wimp_eventstr* event, void *handle) static BOOL main_select_area (wimp_eventstr *event, void *handle)
{
wimp_wstate ws; { wimp_wstate ws;
wimp_box clip; wimp_box clip;
main_window* window = (main_window*)handle; 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);
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) int main_selection_file_size (main_window *window)
{
main_sprite* sprite; { main_sprite *sprite;
int size=0; int size = 0;
if (!window || window->selection.count==0) return 0; if (!window || window->selection.count==0) return 0;
for (sprite=window->data->file.sprites;sprite != NULL; sprite = sprite->link) for (sprite = window->data->file.sprites; sprite != NULL; sprite = sprite->link)
{ { if (sprite->flags & MSF_SELECTED)
if (sprite->flags & MSF_SELECTED) { sprite_header *spriteaddr = psprite_address (sprite);
{ size += spriteaddr->next;
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) static void main_save_finished (int at, void *arg)
{
main_window* window = (main_window*)handle; { main_window *window = (main_window *)arg;
at=at; at=at;
xfersend_clear_unknowns(); xfersend_clear_unknowns ();
window->selection.flags &= ~MW_SELSAVING; 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) BOOL main_save_selection (char *filename, void *arg)
{
main_window* window = (main_window*)handle; { main_window *window = (main_window *)arg;
main_sprite* sprite; main_sprite *sprite;
FILE* file; int file;
_kernel_oserror* err=0; os_error *err;
struct struct
{ { int num_of_sprites;
int num_of_sprites;
int offset_to_first; int offset_to_first;
int offset_to_free; int offset_to_free;
} header; } 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.num_of_sprites = window->selection.count;
header.offset_to_first=16; header.offset_to_first = sizeof (sprite_area);
header.offset_to_free=main_selection_file_size(window)+4; header.offset_to_free = main_selection_file_size (window) + 4;
if (header.offset_to_free<=16) return 0; if (header.offset_to_free <= sizeof (sprite_area)) return FALSE;
file=fopen(filename,"wb"); visdelay_begin ();
if (!file) if (wimpt_complain (os_swix2r (OS_Find, 0x83, filename, &file, NULL)) != NULL)
{ return FALSE;
wimpt_complain(_kernel_last_oserror());
return 0;
}
fwrite(&header,sizeof(header),1,file); err = os_swix4 (OS_GBPB, 2, file, &header, sizeof (header));
for (sprite=window->data->file.sprites;sprite != NULL; sprite = sprite->link) if (err == NULL)
{ { for (sprite = window->data->file.sprites; sprite != NULL; sprite = sprite->link)
if (sprite->flags & MSF_SELECTED) { if (sprite->flags & MSF_SELECTED)
{ { sprite_header *header = psprite_address (sprite);
sprite_header *spriteaddr = psprite_address (sprite); err = os_swix4 (OS_GBPB, 2, file, header, header->next);
fwrite(spriteaddr,spriteaddr->next,1,file); if (err != NULL) break;
}
} }
} }
if (ferror(file)) err=_kernel_last_oserror(); os_swix2 (OS_Find, 0x00, file);
fclose(file);
if (err) if (err != NULL)
{ { wimpt_complain (err);
wimpt_complain(err); remove (filename);
remove(filename); return FALSE;
return 0;
} }
_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; window->selection.flags |= MW_SELSAVING;
return 1;
}
static BOOL main_select_drag(wimp_eventstr* event, void *handle) return TRUE;
{
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;
} }
/******************************************************** /********************************************************
...@@ -2008,27 +1917,25 @@ static BOOL main_select_drag(wimp_eventstr* event, void *handle) ...@@ -2008,27 +1917,25 @@ static BOOL main_select_drag(wimp_eventstr* event, void *handle)
********************************************************/ ********************************************************/
static main_sprite *main_pick_sprite_bbox (main_window *window, 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; { wimp_wstate whereisit;
int spritesperrow, spritenumber; int spritesperrow, spritenumber;
main_sprite *sprite; main_sprite *sprite;
int x, y, width, height,mx,my; int x, y, width, height, mx, my;
wimp_box dummy; wimp_box dummy;
if (!bbox) bbox=&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)); wimpt_noerr (wimp_get_wind_state (window->handle, &whereisit));
if (window->data->file.fullinfo) if (window->data->file.fullinfo)
{ { width = main_FILER_FullInfoWidth;
width = main_FILER_FullInfoWidth;
height = main_FILER_FullInfoHeight; height = main_FILER_FullInfoHeight;
} }
else else
{ { width = main_FILER_TotalWidth;
width = main_FILER_TotalWidth;
height = main_FILER_TotalHeight; height = main_FILER_TotalHeight;
} }
...@@ -2054,29 +1961,29 @@ static main_sprite *main_pick_sprite_bbox (main_window *window, ...@@ -2054,29 +1961,29 @@ static main_sprite *main_pick_sprite_bbox (main_window *window,
y /= height; y /= height;
spritenumber = y * spritesperrow + x; 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->x0 = x*width;
bbox->x1=bbox->x0+width-1; bbox->x1 = bbox->x0+width-1;
bbox->y1=-y*height; bbox->y1 = -y*height;
bbox->y0=bbox->y1-height; bbox->y0 = bbox->y1-height;
for (sprite=window->data->file.sprites; for (sprite=window->data->file.sprites;
spritenumber>0 && sprite != NULL; spritenumber>0 && sprite != NULL;
spritenumber--, sprite = sprite->link); spritenumber--, sprite = sprite->link);
if (sprite && is_over_graphic) if (sprite && is_over_graphic)
{ { wimp_box spritebbox;
wimp_box spritebbox;
wimp_box namebbox; 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; *is_over_graphic=0;
if (main_CLIPS(&spritebbox,mx,my,mx,my)) if (main_CLIPS(&spritebbox, mx, my, mx, my))
*is_over_graphic=1; *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; *is_over_graphic=2;
} }
...@@ -2084,36 +1991,33 @@ static main_sprite *main_pick_sprite_bbox (main_window *window, ...@@ -2084,36 +1991,33 @@ static main_sprite *main_pick_sprite_bbox (main_window *window,
} }
/* returns work area of all bounding boxes */ /* returns work area of all bounding boxes */
/* wimp_box* may be 0 if not required */ /* bboxes may be 0 if not required */
BOOL main_get_all_sprite_bboxes (main_window *window,main_sprite* sprite, BOOL main_get_all_sprite_bboxes (main_window *window, main_sprite *sprite,
wimp_box* bbox,wimp_box* spritebbox, wimp_box *bbox, wimp_box *spritebbox,
wimp_box* namebbox) wimp_box *namebbox)
{ wimp_wstate ws; { wimp_wstate ws;
int spritesperrow, spritenumber; int spritesperrow, spritenumber;
main_sprite *sp; main_sprite *sp;
int x, y, width, height; int x, y, width, height;
wimp_box dummy; wimp_box dummy;
if (!bbox) bbox=&dummy; if (!bbox) bbox = &dummy;
if (!window || !sprite) return 0;
for (spritenumber=0,sp=window->data->file.sprites; if (!window || !sprite) return FALSE;
sp != sprite;
spritenumber++, sp = sp->link)
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)); wimpt_noerr (wimp_get_wind_state (window->handle, &ws));
if (window->data->file.fullinfo) if (window->data->file.fullinfo)
{ { width = main_FILER_FullInfoWidth;
width = main_FILER_FullInfoWidth;
height = main_FILER_FullInfoHeight; height = main_FILER_FullInfoHeight;
} }
else else
{ { width = main_FILER_TotalWidth;
width = main_FILER_TotalWidth;
height = main_FILER_TotalHeight; height = main_FILER_TotalHeight;
} }
...@@ -2124,50 +2028,50 @@ BOOL main_get_all_sprite_bboxes (main_window *window,main_sprite* sprite, ...@@ -2124,50 +2028,50 @@ BOOL main_get_all_sprite_bboxes (main_window *window,main_sprite* sprite,
x = spritenumber % spritesperrow; x = spritenumber % spritesperrow;
y = spritenumber / spritesperrow; y = spritenumber / spritesperrow;
bbox->x0=x*width; bbox->x0 = x * width;
bbox->x1=bbox->x0+width-1; bbox->x1 = bbox->x0 + width-1;
bbox->y1=-y*height; bbox->y1 = -y * height;
bbox->y0=bbox->y1-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) static main_sprite *main_pick_sprite (main_window *window, wimp_mousestr *mouse)
{
int is_in_graphic; { 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 *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) main_sprite *main_pick_menu_button_sprite (main_window *window)
{
if (window->selection.count==0) { if (window->selection.count==0)
{ { int is_in_graphic;
int is_in_graphic;
wimp_mousestr mouse; wimp_mousestr mouse;
main_sprite* sprite; main_sprite *sprite;
wimp_box bbox; wimp_box bbox;
wimpt_noerr (wimp_get_point_info (&mouse)); 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; 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; return sprite;
} }
if (window->selection.count==1) if (window->selection.count==1)
{ { main_sprite *sprite;
main_sprite* sprite; for (sprite = window->data->file.sprites; sprite != NULL; sprite = sprite->link)
for (sprite=window->data->file.sprites;sprite;sprite=sprite->link) { if (sprite->flags & MSF_SELECTED)
{ break;
if (sprite->flags & MSF_SELECTED) break;
} }
return sprite; return sprite;
} }
return 0; return NULL;
} }
/*************************************************************************** /***************************************************************************
* * * *
* Window event handler for sprite file windows. * * Window event handler for sprite file windows. *
...@@ -2178,7 +2082,7 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle) ...@@ -2178,7 +2082,7 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
{ main_window *window = (main_window *) 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"); ftracef0 ("spritefile_event_handler\n");
/*if (!help_process (e))*/ {switch (e->e) /*if (!help_process (e))*/ {switch (e->e)
...@@ -2187,7 +2091,7 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle) ...@@ -2187,7 +2091,7 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
main_set_extent (window); main_set_extent (window);
break; 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) if (e->data.scroll.x || e->data.scroll.y)
{ {
switch (e->data.scroll.x) switch (e->data.scroll.x)
...@@ -2243,7 +2147,7 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle) ...@@ -2243,7 +2147,7 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
int spritex = -1, spritey = 0; int spritex = -1, spritey = 0;
int x0, y0, x1, y1; int x0, y0, x1, y1;
main_clear_background(&rds); main_clear_background (&rds);
#if SPACE_FOR_HELP_TEXT != 0 #if SPACE_FOR_HELP_TEXT != 0
x0 = rds.box.x0 - rds.scx; x0 = rds.box.x0 - rds.scx;
...@@ -2263,7 +2167,7 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle) ...@@ -2263,7 +2167,7 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
} }
#endif #endif
for (; currsprite != NULL ; currsprite = currsprite->link) for (; currsprite != NULL; currsprite = currsprite->link)
{ if (++spritex == spritesperline) spritex = 0, spritey++; { if (++spritex == spritesperline) spritex = 0, spritey++;
ftracef2 ("x %d, y %d\n", spritex, spritey); ftracef2 ("x %d, y %d\n", spritex, spritey);
...@@ -2278,7 +2182,7 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle) ...@@ -2278,7 +2182,7 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
y0 + rds.box.y1 - rds.scy, y0 + rds.box.y1 - rds.scy,
x1 + rds.box.x0 - rds.scx, x1 + rds.box.x0 - rds.scx,
y1 + rds.box.y1 - rds.scy)) y1 + rds.box.y1 - rds.scy))
main_draw_icon(window,currsprite,x0,y0,&rds); main_draw_icon (window, currsprite, x0, y0, &rds);
} }
#if TRACE #if TRACE
...@@ -2292,17 +2196,15 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle) ...@@ -2292,17 +2196,15 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
case wimp_EBUT: case wimp_EBUT:
if (bbc_inkey(-3) || bbc_inkey(-4)) if (bbc_inkey (-3) || bbc_inkey (-4))
{ { /* alt pressed */
/* alt pressed */
if (e->data.but.m.bbits & (wimp_BCLICKLEFT | wimp_BCLICKRIGHT)) if (e->data.but.m.bbits & (wimp_BCLICKLEFT | wimp_BCLICKRIGHT))
{ { int is_over_graphic;
int is_over_graphic; main_sprite *sprite = main_pick_sprite_bbox (window, &e->data.but.m, &is_over_graphic, 0);
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)) if (sprite && is_over_graphic==2 && (e->data.but.m.bbits & wimp_BCLICKLEFT))
{ {
/* alt click over name */ /* alt click over name */
AltRename_start(window,sprite); altrename_start (window, sprite);
break; break;
} }
} }
...@@ -2310,8 +2212,7 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle) ...@@ -2310,8 +2212,7 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
} }
if (e->data.but.m.bbits & 4) if (e->data.but.m.bbits & 4)
{ main_sprite *sprite = { main_sprite *sprite = main_pick_sprite (window, &e->data.but.m);
main_pick_sprite (window, &e->data.but.m);
if (sprite != NULL) if (sprite != NULL)
{ /*Check sprite has a valid mode. JRC 14 June 1990*/ { /*Check sprite has a valid mode. JRC 14 June 1990*/
...@@ -2323,6 +2224,7 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle) ...@@ -2323,6 +2224,7 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
} }
sprwindow_new (sprite); sprwindow_new (sprite);
main_clear_selection (window, 0, SI_CLEAR);
if (main_current_options.tools.show_tools) if (main_current_options.tools.show_tools)
toolwindow_display (FALSE); toolwindow_display (FALSE);
} }
...@@ -2332,77 +2234,109 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle) ...@@ -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)) else if (e->data.but.m.bbits & (wimp_BCLICKLEFT | wimp_BCLICKRIGHT))
{ { wimp_redrawstr rds;
wimp_redrawstr rds;
int is_over_graphic; 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 (e->data.but.m.bbits & wimp_BCLICKLEFT)
{ {
if (sprite && is_over_graphic && (sprite->flags & MSF_SELECTED)) break; if (sprite && is_over_graphic && (sprite->flags & MSF_SELECTED)) break;
if (sprite == NULL || !is_over_graphic) if (sprite == NULL || !is_over_graphic)
{ { main_clear_selection (window, 0, SI_CLEAR);
main_clear_selection(window,0,SI_CLEAR);
break; break;
} }
if (window->selection.count==0) if (window->selection.count==0)
{ { main_select_icon (window, sprite, &rds.box, SI_SELECT);
main_select_icon(window,sprite,&rds.box,SI_SELECT);
break; break;
} }
if (!(sprite->flags & MSF_SELECTED)) if (!(sprite->flags & MSF_SELECTED))
{ { main_clear_selection (window, 0, SI_CLEAR);
main_clear_selection(window,0,SI_CLEAR); main_select_icon (window, sprite, &rds.box, SI_SELECT);
main_select_icon(window,sprite,&rds.box,SI_SELECT);
break; break;
} }
} }
else else
{ { /* else right click */
if (sprite && is_over_graphic) 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)) else if (e->data.but.m.bbits & (wimp_BDRAGLEFT | wimp_BDRAGRIGHT))
{ { wimp_redrawstr rds;
wimp_redrawstr rds;
int is_over_graphic; 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) if (sprite && is_over_graphic)
{ { wimp_icreate create;
main_select_icon(window,sprite,&rds.box,SI_SELECT); 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) /* Read where the window where the click was is */
{ wimpt_noerr (wimp_get_wind_state (e->data.but.m.w, &ws));
wimp_box box;
box.x0=e->data.but.m.x-17; /* Bounding box is filer thumbnail size */
box.x1=e->data.but.m.x+17; if (window->data->file.fullinfo)
box.y0=e->data.but.m.y-17; { width = main_FILER_XSize/2;
box.y1=e->data.but.m.y+17; height = main_FILER_YSize/2;
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);
} }
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 else
{ { wimp_dragstr drag;
wimp_dragstr drag;
wimp_wstate ws; wimp_wstate ws;
struct struct
{ {
int window_handle; int window_handle;
struct {int left,bottom,right,top;}pause_zone; struct {int left, bottom, right, top;} pause_zone;
int pause_duration; int pause_duration;
int handler; int handler;
void* handle; void *handle;
} scroll; } scroll;
wimp_get_wind_state(window->handle,&ws); wimp_get_wind_state (window->handle, &ws);
drag.window=window->handle; drag.window=window->handle;
drag.type=wimp_USER_RUBBER; drag.type=wimp_USER_RUBBER;
...@@ -2411,7 +2345,7 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle) ...@@ -2411,7 +2345,7 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
drag.parent=ws.o.box; drag.parent=ws.o.box;
drag.parent.y1=0x7f000000; drag.parent.y1=0x7f000000;
drag.parent.y0=-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.window_handle=window->handle;
scroll.pause_zone.left=0; scroll.pause_zone.left=0;
...@@ -2421,18 +2355,18 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle) ...@@ -2421,18 +2355,18 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
scroll.pause_duration=0; scroll.pause_duration=0;
scroll.handler=1; scroll.handler=1;
scroll.handle=0; scroll.handle=0;
_swix(Wimp_AutoScroll,_INR(0,1),2,&scroll); os_swix2 (Wimp_AutoScroll, 2, &scroll);
window->selection.flags &= ~MW_SELDRAGRIGHT; 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; window->selection.flags |= MW_SELDRAGRIGHT;
win_add_unknown_event_processor(main_select_area,window); win_add_unknown_event_processor (main_select_area, window);
} }
} }
break; break;
case wimp_ECLOSE: case wimp_ECLOSE:
{ main_file *file = &window->data->file; { 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 */ /* Deal with ADJUST clicks on the close box */
int shifted = akbd_pollsh (); int shifted = akbd_pollsh ();
wimp_mousestr m; wimp_mousestr m;
...@@ -2449,9 +2383,9 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle) ...@@ -2449,9 +2383,9 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
sprintf (mess, sprintf (mess,
msgs_lookup (file->filename == NULL ? "PntF2" : "PntF3"), msgs_lookup (file->filename == NULL ? "PntF2" : "PntF3"),
file->filename); file->filename);
delete = dboxquery_close (mess); action = dboxquery_close (mess);
if (delete == dboxquery_close_SAVE) if (action == dboxquery_close_SAVE)
if (!menus_save_file (window, 1)) delete = dboxquery_close_CANCEL; if (!menus_save_file (window, 1)) action = dboxquery_close_CANCEL;
} }
if ((m.bbits & wimp_BRIGHT) != 0) if ((m.bbits & wimp_BRIGHT) != 0)
...@@ -2461,20 +2395,22 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle) ...@@ -2461,20 +2395,22 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
while (i > 0 && file->filename[i] != '.') i--; while (i > 0 && file->filename[i] != '.') i--;
if (i > 0) if (i > 0)
{ char a[255]; { char a[FILENAMEMAX + 1];
file->filename[i] = 0; file->filename[i] = 0;
sprintf (a, "filer_opendir %s", file->filename); sprintf (a, "filer_opendir %s", file->filename);
wimpt_complain (os_cli (a)); wimpt_complain (os_cli (a));
file->filename[i] = '.'; file->filename[i] = '.';
} } }
}
if (shifted) break; /* don't close if SHIFT down */ if (shifted) break; /* don't close if SHIFT down */
} }
if (delete != dboxquery_close_CANCEL) if (action != dboxquery_close_CANCEL)
{ delete_file_window (window); { delete_file_window (window);
toolwindow_close (); toolwindow_close ();
} } }
}
break; break;
case wimp_ESEND: case wimp_ESEND:
...@@ -2493,7 +2429,7 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle) ...@@ -2493,7 +2429,7 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
int type; int type;
type = xferrecv_checkinsert (&name); /* sets up reply */ type = xferrecv_checkinsert (&name); /* sets up reply */
if (type == SPRITE_FILE || type == jpeg_FILE_TYPE) if (type == FileType_Sprite || type == FileType_JPEG)
{ int ok; { int ok;
ftracef1 ("Loading file \"%s\"\n", name); ftracef1 ("Loading file \"%s\"\n", name);
visdelay_begin (); visdelay_begin ();
...@@ -2501,7 +2437,8 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle) ...@@ -2501,7 +2437,8 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
visdelay_end (); visdelay_end ();
if (ok > 0) xferrecv_insertfileok (); if (ok > 0) xferrecv_insertfileok ();
ftracef0 ("file merged\n"); ftracef0 ("file merged\n");
} } }
}
break; break;
case wimp_MHELPREQUEST: case wimp_MHELPREQUEST:
...@@ -2511,13 +2448,13 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle) ...@@ -2511,13 +2448,13 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
break; break;
default: 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;
} }
break; break;
default: default:
ftracef1 ("File window event %d\n",e->e); ftracef1 ("File window event %d\n", e->e);
break; break;
} }
} }
...@@ -2532,11 +2469,11 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle) ...@@ -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) 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 */ of the given string */
ftracef0 ("load_template\n"); ftracef0 ("load_template\n");
strcpy (namebuff,name); strcpy (namebuff, name);
ftracef2 ("Load template '%s': %p\n", name, buf); ftracef2 ("Load template '%s': %p\n", name, buf);
wt->buf = buf; wt->buf = buf;
...@@ -2567,20 +2504,6 @@ static void load_resources (void) ...@@ -2567,20 +2504,6 @@ static void load_resources (void)
{ wimp_template wt; { 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"); ftracef0 ("load_resources\n");
wimpt_noerr (wimp_open_template ("Paint:Templates")); wimpt_noerr (wimp_open_template ("Paint:Templates"));
...@@ -2593,7 +2516,7 @@ static void load_resources (void) ...@@ -2593,7 +2516,7 @@ static void load_resources (void)
wt.work_free += 128; wt.work_free += 128;
load_template (&wt, "toolwind", &tools_tool_template.t); load_template (&wt, "toolwind", &tools_tool_template.t);
wt.work_free += 128; 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*/ /*Use radioon, radiooff, opton, optoff from WIMP pool. JRC*/
template_syshandle ("create")->spritearea = (void *) 1; template_syshandle ("create")->spritearea = (void *) 1;
...@@ -2665,15 +2588,11 @@ static main_window *New_Window (BOOL open) ...@@ -2665,15 +2588,11 @@ static main_window *New_Window (BOOL open)
ftracef1 ("New_Window: open %s\n", WHETHER (open)); ftracef1 ("New_Window: open %s\n", WHETHER (open));
#ifndef NOEXAMPLE
never_been_kissed = 0;
#endif
if ((window = m_ALLOC (sizeof (main_window))) == NULL) if ((window = m_ALLOC (sizeof (main_window))) == NULL)
{ main_NO_ROOM ("new file window block"); { main_NO_ROOM ("new file window block");
return NULL; 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) if ((file = m_ALLOC (sizeof (main_file))) == NULL)
{ m_FREE (window, sizeof (main_window)); { m_FREE (window, sizeof (main_window));
...@@ -2681,7 +2600,7 @@ static main_window *New_Window (BOOL open) ...@@ -2681,7 +2600,7 @@ static main_window *New_Window (BOOL open)
return NULL; return NULL;
} }
wind = File_Template.t; wind = file_template.t;
wind.scx = wind.scy = 0; wind.scx = wind.scy = 0;
wind.minsize = 0x00010001; wind.minsize = 0x00010001;
wind.ex = main_big_extent; wind.ex = main_big_extent;
...@@ -2784,13 +2703,9 @@ static void main_iconclick (wimp_i iconno) ...@@ -2784,13 +2703,9 @@ static void main_iconclick (wimp_i iconno)
{ main_window *wind; { main_window *wind;
ftracef0 ("main_iconclick\n"); ftracef0 ("main_iconclick\n");
#ifndef NOEXAMPLE
char name[256];
int nbk = never_been_kissed;
#endif
iconno = iconno; iconno = iconno;
ftracef1 ("main_iconclick %d\n",iconno); ftracef1 ("main_iconclick %d\n", iconno);
if ((wind = New_Window (FALSE)) != NULL) if ((wind = New_Window (FALSE)) != NULL)
{ main_set_extent (wind); { main_set_extent (wind);
main_check_position (wind); main_check_position (wind);
...@@ -2808,9 +2723,8 @@ static void main_iconclick (wimp_i iconno) ...@@ -2808,9 +2723,8 @@ static void main_iconclick (wimp_i iconno)
static char *write_options (void) static char *write_options (void)
/*Translate main_current_options to string (in static space).*/ { /*Translate main_current_options to string (in static space).*/
static char buffer [MAX_OPTIONS + 1];
{ static char buffer [MAX_OPTIONS + 1];
int len; int len;
main_options *opt = &main_current_options; main_options *opt = &main_current_options;
main_options *opt0 = &initial_options; main_options *opt0 = &initial_options;
...@@ -2888,10 +2802,10 @@ static void New_File (char *name) ...@@ -2888,10 +2802,10 @@ static void New_File (char *name)
if (name != (char *) -1) if (name != (char *) -1)
/* must acknowledge message or we'll get an error */ /* must acknowledge message or we'll get an error */
xferrecv_insertfileok(); xferrecv_insertfileok ();
if (ok > 0) if (ok > 0)
{ main_check_position(w); { main_check_position (w);
if (w->data->file.spritearea->number == 1 && if (w->data->file.spritearea->number == 1 &&
/*Don't attempt sprites with illegal modes. JRC 21st Nov 1994*/ /*Don't attempt sprites with illegal modes. JRC 21st Nov 1994*/
bbc_modevar bbc_modevar
...@@ -2901,7 +2815,7 @@ static void New_File (char *name) ...@@ -2901,7 +2815,7 @@ static void New_File (char *name)
sprwindow_new (w->data->file.sprites); sprwindow_new (w->data->file.sprites);
} }
else else
delete_file_window(w); delete_file_window (w);
} }
} }
...@@ -2943,10 +2857,9 @@ static void print_file (char *name) ...@@ -2943,10 +2857,9 @@ static void print_file (char *name)
void main_set_printer_data (void) void main_set_printer_data (void)
/*Now only updates menus_print_where if the bottom left origin has changed*/
{ print_pagesizestr ps; { print_pagesizestr ps;
/*Now only updates menus_print_where if the bottom left origin has changed*/
ftracef0 ("set printer_data\n"); ftracef0 ("set printer_data\n");
if (!print_pagesize (&ps)) if (!print_pagesize (&ps))
{ if ((menus_print_last_where.dx != ps.bbox.x0) || { 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) ...@@ -2969,7 +2882,7 @@ static void set_icon (wimp_w w, wimp_i i, char *buffer, int size)
/*A-RO-???? JRC 25 Sep 1991*/ /*A-RO-???? JRC 25 Sep 1991*/
if (wimpt_complain (wimp_get_icon_info (w, i, &wi)) != NULL) if (wimpt_complain (wimp_get_icon_info (w, i, &wi)) != NULL)
return; return;
memcpy (wi.data.indirecttext.buffer,buffer,size); memcpy (wi.data.indirecttext.buffer, buffer, size);
r.w = w; r.w = w;
r.box = wi.box; r.box = wi.box;
wimpt_complain (wimp_force_redraw (&r)); wimpt_complain (wimp_force_redraw (&r));
...@@ -2982,9 +2895,9 @@ static void Background_Events (wimp_eventstr *e, void *handle) ...@@ -2982,9 +2895,9 @@ static void Background_Events (wimp_eventstr *e, void *handle)
handle = handle; /* avoid not used warning */ handle = handle; /* avoid not used warning */
#if TRACE #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) 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 #endif
switch (e->e) switch (e->e)
...@@ -3050,11 +2963,11 @@ static void Background_Events (wimp_eventstr *e, void *handle) ...@@ -3050,11 +2963,11 @@ static void Background_Events (wimp_eventstr *e, void *handle)
break; break;
case wimp_MDATAOPEN: 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*/ /*Fall through*/
case wimp_MDATALOAD: 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); New_File ((char *) &e->data.msg.data.dataload.name);
break; break;
...@@ -3064,7 +2977,7 @@ static void Background_Events (wimp_eventstr *e, void *handle) ...@@ -3064,7 +2977,7 @@ static void Background_Events (wimp_eventstr *e, void *handle)
ftracef0 ("Printer broadcast\n"); ftracef0 ("Printer broadcast\n");
/*FIX G-RO-7139 17 Oct '91 We must print the file now, not /*FIX G-RO-7139 17 Oct '91 We must print the file now, not
just queue it (was print_file (name);).*/ just queue it (was print_file (name);).*/
if (xferrecv_checkprint (&name) == SPRITE_FILE) if (xferrecv_checkprint (&name) == FileType_Sprite)
{ main_window *w; { main_window *w;
ftracef1 ("printing file \"%s\"\n", name); ftracef1 ("printing file \"%s\"\n", name);
...@@ -3104,34 +3017,9 @@ static void Background_Events (wimp_eventstr *e, void *handle) ...@@ -3104,34 +3017,9 @@ static void Background_Events (wimp_eventstr *e, void *handle)
ftracef1 ("Message %d\n", e->data.msg.hdr.action); ftracef1 ("Message %d\n", e->data.msg.hdr.action);
wimpt_checkmode (); wimpt_checkmode ();
main_mode_flags = bbc_modevar (-1, bbc_ModeFlags);
if ((error = psprite_set_default_translations ()) != NULL) if ((error = psprite_set_default_translations ()) != NULL)
goto changed; 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) for (window = main_windows; window != NULL; window = window->link)
if (window->tag == main_window_is_file) if (window->tag == main_window_is_file)
{ if ((error = psprite_set_plot_info (&window->data->file)) != { if ((error = psprite_set_plot_info (&window->data->file)) !=
...@@ -3171,7 +3059,8 @@ static void Background_Events (wimp_eventstr *e, void *handle) ...@@ -3171,7 +3059,8 @@ static void Background_Events (wimp_eventstr *e, void *handle)
tools_text_ysize, 5); tools_text_ysize, 5);
set_icon (toolwindow_handle, tools_icons [7], set_icon (toolwindow_handle, tools_icons [7],
tools_text_xspace, 5); tools_text_xspace, 5);
} } }
}
changed: changed:
wimpt_noerr (error); wimpt_noerr (error);
...@@ -3183,9 +3072,23 @@ static void Background_Events (wimp_eventstr *e, void *handle) ...@@ -3183,9 +3072,23 @@ static void Background_Events (wimp_eventstr *e, void *handle)
break; break;
case wimp_MHELPREQUEST: case wimp_MHELPREQUEST:
{ main_window *window;
ftracef0 ("Help request on icon\n"); 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); main_help_message ("PntH5", e);
}
}
break; break;
case wimp_SAVEDESK: case wimp_SAVEDESK:
...@@ -3226,7 +3129,8 @@ static void Background_Events (wimp_eventstr *e, void *handle) ...@@ -3226,7 +3129,8 @@ static void Background_Events (wimp_eventstr *e, void *handle)
sprite->colourdialogue = 0; sprite->colourdialogue = 0;
sprite->colourhandle = 0; sprite->colourhandle = 0;
m_FREE (sprite->colourtitle, 23); m_FREE (sprite->colourtitle, 23);
} } }
}
os_swi2 (ColourPicker_CloseDialogue, 0, d); os_swi2 (ColourPicker_CloseDialogue, 0, d);
main_current_options.colours.show_colours = FALSE; main_current_options.colours.show_colours = FALSE;
...@@ -3249,15 +3153,16 @@ static void Background_Events (wimp_eventstr *e, void *handle) ...@@ -3249,15 +3153,16 @@ static void Background_Events (wimp_eventstr *e, void *handle)
colourpicker_COLOUR_TRANSPARENT) != 0) colourpicker_COLOUR_TRANSPARENT) != 0)
sprite->gcol = colours_count (sprite); sprite->gcol = colours_count (sprite);
else else
{ int junk; { os_swi3r (ColourTrans_ReturnColourNumberForMode,
os_swi3r (ColourTrans_ReturnColourNumberForMode,
e->data.msg.data.words [2], e->data.msg.data.words [2],
psprite_address (sprite)->mode, 0, psprite_address (sprite)->mode, 0,
&sprite->gcol, &junk, &junk); &sprite->gcol, NULL, NULL);
ftracef2 ("rgb is 0x%X => colour number 0x%X\n", ftracef2 ("rgb is 0x%X => colour number 0x%X\n",
e->data.msg.data.words [2], sprite->gcol); e->data.msg.data.words [2], sprite->gcol);
} } } } }
}
}
}
break; break;
default: default:
...@@ -3270,9 +3175,8 @@ static void Background_Events (wimp_eventstr *e, void *handle) ...@@ -3270,9 +3175,8 @@ static void Background_Events (wimp_eventstr *e, void *handle)
static void read_options (void) static void read_options (void)
/*Sets main_current_options. Called only once, at startup. JRC*/ { /*Sets main_current_options. Called only once, at startup. JRC*/
char buffer [MAX_OPTIONS + 1], *token, *options;
{ char buffer [MAX_OPTIONS + 1], *token, *options;
main_options *opt = &main_current_options; main_options *opt = &main_current_options;
/*name equivalence to save typing.*/ /*name equivalence to save typing.*/
...@@ -3369,8 +3273,8 @@ static menu main_iconmenumaker (void *handle) ...@@ -3369,8 +3273,8 @@ static menu main_iconmenumaker (void *handle)
{ ftracef0 ("main_iconmenumaker\n"); { ftracef0 ("main_iconmenumaker\n");
handle = handle; handle = handle;
help_register_handler (&help_simplehandler, (void *) "ICONB"); help_register_handler (&help_simplehandler, (void *) "ICONB");
menu_setflags (Main_Menu, i_GetScreen, FALSE, sshot.active); menu_setflags (main_menu, i_GetScreen, FALSE, sshot.active);
return Main_Menu; return main_menu;
} }
/*************************************************************************** /***************************************************************************
...@@ -3476,7 +3380,7 @@ int main (int argc, char *argv[]) ...@@ -3476,7 +3380,7 @@ int main (int argc, char *argv[])
res_init ("Paint"); res_init ("Paint");
/* OSS Read Messages file by explicit pathname. */ /* OSS Read Messages file by explicit pathname. */
msgs_readfile("Paint:Messages"); msgs_readfile ("Paint:Messages");
wimpt_wimpversion (300); wimpt_wimpversion (300);
wimpt_messages (Messages); wimpt_messages (Messages);
...@@ -3486,28 +3390,26 @@ int main (int argc, char *argv[]) ...@@ -3486,28 +3390,26 @@ int main (int argc, char *argv[])
heap_init (FALSE /* non-compacting */); heap_init (FALSE /* non-compacting */);
/* OSS Read Templates file by explicit pathname. */ /* OSS Read Templates file by explicit pathname. */
template_readfile("Paint:Templates"); template_readfile ("Paint:Templates");
visdelay_init (); visdelay_init ();
dbox_init (); dbox_init ();
/* OSS Read Sprites file by explicit name. */ /* OSS Read Sprites file by explicit name. */
resspr_readfile("Paint:Sprites"); resspr_readfile ("Paint:Sprites");
dboxquery_close (0); dboxquery_close (0);
dboxquery_quit (0); /* Reserves space */ dboxquery_quit (0); /* Reserves space */
alarm_init (); alarm_init ();
#ifdef ModuleVersion
init_statics (); 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*/, 1 /*was (int) resspr_area (). JRC 14 June 1990*/,
main_iconclick); main_iconclick);
#if 1 #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, if (!event_attachmenumaker (win_ICONBAR, &main_iconmenumaker,
&menus_icon_proc, NULL)) &menus_icon_proc, NULL))
...@@ -3516,21 +3418,21 @@ int main (int argc, char *argv[]) ...@@ -3516,21 +3418,21 @@ int main (int argc, char *argv[])
#else #else
if (!event_attachmenu (win_ICONBAR, if (!event_attachmenu (win_ICONBAR,
menu_new (msgs_lookup ("Pnt00"), msgs_lookup ("PntMI")), menu_new (msgs_lookup ("Pnt00"), msgs_lookup ("PntMI")),
menus_icon_proc,0)) menus_icon_proc, 0))
werr (TRUE, msgs_lookup ("PntEH")); werr (TRUE, msgs_lookup ("PntEH"));
#endif #endif
load_resources (); load_resources ();
nextx = startx = File_Template.t.box.x0; nextx = startx = file_template.t.box.x0;
nexty = starty = File_Template.t.box.y1; nexty = starty = file_template.t.box.y1;
/* set up a dummy window event handler to get icon messages */ /* set up a dummy window event handler to get icon messages */
win_register_event_handler (win_ICONBARLOAD, Background_Events, 0); win_register_event_handler (win_ICONBARLOAD, Background_Events, 0);
win_claim_unknown_events (win_ICONBARLOAD); win_claim_unknown_events (win_ICONBARLOAD);
/*Add an unknown event handler for menu help messages.*/ /*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 */ /* Read Paint$Dir for desksaving */
os_read_var_val ("Paint$Dir", Paint_Dir, FILENAME_MAX); os_read_var_val ("Paint$Dir", Paint_Dir, FILENAME_MAX);
...@@ -3577,20 +3479,21 @@ int main (int argc, char *argv[]) ...@@ -3577,20 +3479,21 @@ int main (int argc, char *argv[])
int f = 0; int f = 0;
BOOL reported = FALSE; BOOL reported = FALSE;
os_filestr file_str; os_filestr file_str;
os_error error; os_regset regs;
os_regset reg_set;
main_window *w; main_window *w;
_kernel_oserror *last_error; _kernel_oserror error;
char last_errmess [256];
/*Remember the error first.*/ /*Remember the error first.*/
last_error = _kernel_last_oserror (); _kernel_oserror *last_error = _kernel_last_oserror();
if (last_error != NULL) if (last_error != NULL)
strcpy (last_errmess, last_error->errmess); memcpy (&error, last_error, sizeof(_kernel_oserror));
else 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"); scrap_dir = getenv ("WIMP$ScrapDir");
paint = msgs_lookup ("Pnt00"); paint = msgs_lookup ("Pnt00");
...@@ -3602,8 +3505,6 @@ int main (int argc, char *argv[]) ...@@ -3602,8 +3505,6 @@ int main (int argc, char *argv[])
signal (s, Saved_Handlers [s]) == SIG_ERR)) signal (s, Saved_Handlers [s]) == SIG_ERR))
werr (FALSE, _kernel_last_oserror ()->errmess); werr (FALSE, _kernel_last_oserror ()->errmess);
error.errnum = 0;
if (scrap_dir != NULL) if (scrap_dir != NULL)
for (w = main_windows; w != NULL; w = w->link) for (w = main_windows; w != NULL; w = w->link)
if (w->tag == main_window_is_file && w->data->file.modified) if (w->tag == main_window_is_file && w->data->file.modified)
...@@ -3611,15 +3512,21 @@ int main (int argc, char *argv[]) ...@@ -3611,15 +3512,21 @@ int main (int argc, char *argv[])
{ struct {int errno; char errmess [sizeof "PntX"];} PntX = { struct {int errno; char errmess [sizeof "PntX"];} PntX =
{0, "PntX"}; {0, "PntX"};
reg_set.r [0] = (int) msgtrans_error_lookup (&PntX, regs.r[0] = (int)&PntX;
msgs_main_control_block (), NULL, 0, last_errmess, regs.r[1] = (int)msgs_main_control_block ();
"<WIMP$ScrapDir>", paint, 0); regs.r[2] = NULL;
reg_set.r [1] = 3 /*OK and Cancel boxes*/; regs.r[3] = 0;
reg_set.r [2] = (int) paint; regs.r[4] = (int)error.errmess;
(void) os_swix (Wimp_ReportError, &reg_set); 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; reported = TRUE;
if (reg_set.r [1] == 2) break; /*cancel*/ if (regs.r[1] == 2) break; /*cancel*/
/*Make the directory, if necessary.*/ /*Make the directory, if necessary.*/
sprintf (preserve, "%s.%s", scrap_dir, paint); sprintf (preserve, "%s.%s", scrap_dir, paint);
...@@ -3642,7 +3549,7 @@ int main (int argc, char *argv[]) ...@@ -3642,7 +3549,7 @@ int main (int argc, char *argv[])
/*Report the error if we haven't yet.*/ /*Report the error if we haven't yet.*/
if (!reported) if (!reported)
wimpt_complain ((os_error *) last_error); wimpt_complain ((os_error *) &error);
return 1; return 1;
} }
...@@ -3662,7 +3569,7 @@ int main (int argc, char *argv[]) ...@@ -3662,7 +3569,7 @@ int main (int argc, char *argv[])
if (w) if (w)
{ int ok /*for Norcroft*/; { int ok /*for Norcroft*/;
ftracef1 ("load into new window %d\n",w->handle); ftracef1 ("load into new window %d\n", w->handle);
visdelay_begin (); visdelay_begin ();
ok = Load_File (w, *argv, 0, 1); ok = Load_File (w, *argv, 0, 1);
visdelay_end (); visdelay_end ();
...@@ -3675,7 +3582,9 @@ int main (int argc, char *argv[]) ...@@ -3675,7 +3582,9 @@ int main (int argc, char *argv[])
else else
delete_file_window (w); delete_file_window (w);
/* might have been asked to run with a non-sprite file */ /* might have been asked to run with a non-sprite file */
} } } }
}
}
ftracef0 ("Start main loop.....\n"); ftracef0 ("Start main loop.....\n");
for (;;) /* ever */ for (;;) /* ever */
......
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
#include <stddef.h> #include <stddef.h>
#include <swis.h> #include <swis.h>
#include <signal.h> #include <signal.h>
#include "Global/FileTypes.h"
#include "bbc.h" #include "bbc.h"
#include "colourmenu.h" #include "colourmenu.h"
...@@ -87,19 +88,20 @@ ...@@ -87,19 +88,20 @@
#include "PaintLib.h" #include "PaintLib.h"
#include "AltRename.h" #include "AltRename.h"
#undef ColourPicker_UpdateDialogue #define COPY_N(s1, s2, n) (sprintf ((s1), "%.*s", (n), (s2)), s1) /*this is strncpy() really*/
#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)
static int Do_Print (char *, void *); 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 * * Static menu handles *
***********************/ ***********************/
...@@ -218,7 +220,7 @@ static void show_info_box (void) ...@@ -218,7 +220,7 @@ static void show_info_box (void)
{ dbox_setfield (d, d_Prog_Name, msgs_lookup ("Pnt00")); { dbox_setfield (d, d_Prog_Name, msgs_lookup ("Pnt00"));
dbox_setfield (d, d_Prog_Copy, msgs_lookup ("PntM1")); dbox_setfield (d, d_Prog_Copy, msgs_lookup ("PntM1"));
dbox_setfield (d, d_Prog_WhatIsIt, msgs_lookup ("PntM2")); 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_show (d);
dbox_raw_eventhandler (d, &help_dboxrawevents, (void *) "PntH8"); dbox_raw_eventhandler (d, &help_dboxrawevents, (void *) "PntH8");
...@@ -291,10 +293,14 @@ void menus_sprite_new (main_window *window, BOOL hack_palette) ...@@ -291,10 +293,14 @@ void menus_sprite_new (main_window *window, BOOL hack_palette)
/************************************* /*************************************
* Ensure spritearea large enough * * Ensure spritearea large enough *
*************************************/ *************************************/
#if 1
#if FIX0770 BOOL menus_ensure_size (sprite_area **sarea, int bytesneeded)
/*
* OK: this is what *I* think menus_ensure_size() is supposed to do. { 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, * bytesneeded > 0: if not at least <bytesneeded> bytes free in sprite area,
* extend it. * extend it.
...@@ -311,13 +317,6 @@ void menus_sprite_new (main_window *window, BOOL hack_palette) ...@@ -311,13 +317,6 @@ void menus_sprite_new (main_window *window, BOOL hack_palette)
* *
* Christopher Partington 18-Feb-1992 * 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); ftracef1 ("menus_ensure_size of %d\n", bytesneeded);
ftracef3("bytesfree = %d - %d = %d\n", (*sarea)->size, (*sarea)->freeoff, ftracef3("bytesfree = %d - %d = %d\n", (*sarea)->size, (*sarea)->freeoff,
...@@ -338,7 +337,7 @@ BOOL menus_ensure_size (sprite_area **sarea, int bytesneeded) ...@@ -338,7 +337,7 @@ BOOL menus_ensure_size (sprite_area **sarea, int bytesneeded)
bytesneeded += 256; /* and a little headroom */ bytesneeded += 256; /* and a little headroom */
ftracef1 ("... do flex_extend of %d\n", bytesneeded); ftracef1 ("... do flex_extend of %d\n", bytesneeded);
#if FIX0770
if (bytesneeded < 0) if (bytesneeded < 0)
{ {
ftracef1("shrinking area, change = %d bytes\n", bytesneeded); ftracef1("shrinking area, change = %d bytes\n", bytesneeded);
...@@ -354,9 +353,7 @@ BOOL menus_ensure_size (sprite_area **sarea, int bytesneeded) ...@@ -354,9 +353,7 @@ BOOL menus_ensure_size (sprite_area **sarea, int bytesneeded)
ftracef0("area is just the right size - no change\n"); ftracef0("area is just the right size - no change\n");
return TRUE; return TRUE;
} }
#endif
#if FIX9544
newsize = flex_size((flex_ptr) sarea) + bytesneeded; newsize = flex_size((flex_ptr) sarea) + bytesneeded;
/* check for overflow before calling flex */ /* check for overflow before calling flex */
#if TRACE #if TRACE
...@@ -364,10 +361,6 @@ BOOL menus_ensure_size (sprite_area **sarea, int bytesneeded) ...@@ -364,10 +361,6 @@ BOOL menus_ensure_size (sprite_area **sarea, int bytesneeded)
ftracef0("arithmetic overflow, so not enough memory\n"); ftracef0("arithmetic overflow, so not enough memory\n");
#endif #endif
if (newsize < 0 || !flex_extend((flex_ptr) sarea, newsize)) 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; return FALSE;
(*sarea)->size += bytesneeded; (*sarea)->size += bytesneeded;
...@@ -375,32 +368,6 @@ BOOL menus_ensure_size (sprite_area **sarea, int bytesneeded) ...@@ -375,32 +368,6 @@ BOOL menus_ensure_size (sprite_area **sarea, int bytesneeded)
(*sarea)->size - (*sarea)->freeoff); (*sarea)->size - (*sarea)->freeoff);
return TRUE; 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 * * Check for sprite existence *
...@@ -433,12 +400,10 @@ static BOOL myxfersend (int filetype, char *name, int estsize, ...@@ -433,12 +400,10 @@ static BOOL myxfersend (int filetype, char *name, int estsize,
ftracef0 ("myxfersend\n"); ftracef0 ("myxfersend\n");
main_claim_idle ((wimp_w) -1); main_claim_idle ((wimp_w) -1);
#if (1)
ftracef1 ("myxfersend: calling saveas (..., \"%s\", ...)\n", name); ftracef1 ("myxfersend: calling saveas (..., \"%s\", ...)\n", name);
res = saveas (filetype, name, estsize, p1, p2, p3, handle); res = saveas (filetype, name, estsize, p1, p2, p3, handle);
#else
res = xfersend (filetype, name, estsize, p1, p2, p3, handle);
#endif
main_claim_idle (nullc); main_claim_idle (nullc);
return res; return res;
} }
...@@ -538,7 +503,7 @@ finish: ...@@ -538,7 +503,7 @@ finish:
/*Set the file to type "Sprite"*/ /*Set the file to type "Sprite"*/
file_str.action = 18; file_str.action = 18;
file_str.name = filename; file_str.name = filename;
file_str.loadaddr = SPRITE_FILE; file_str.loadaddr = FileType_Sprite;
error1 = os_file (&file_str); error1 = os_file (&file_str);
if (txt == NULL && error1 != NULL) txt = error1->errmess; if (txt == NULL && error1 != NULL) txt = error1->errmess;
} }
...@@ -598,7 +563,8 @@ static void build_sprite_palette_file (main_sprite *sprite, ...@@ -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.red;
*p++ = palette_str.c [16 + i].bytes.green; *p++ = palette_str.c [16 + i].bytes.green;
*p++ = palette_str.c [16 + i].bytes.blue; *p++ = palette_str.c [16 + i].bytes.blue;
} } }
}
finish: finish:
wimpt_noerr (error); wimpt_noerr (error);
...@@ -623,11 +589,11 @@ static BOOL save_sprite_palette (char *filename, void *shandle) ...@@ -623,11 +589,11 @@ static BOOL save_sprite_palette (char *filename, void *shandle)
r.r [0] = 17; /* Read cat info */ r.r [0] = 17; /* Read cat info */
r.r [1] = (int) filename; r.r [1] = (int) filename;
(void) os_swix (OS_File, &r); (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]; if (r.r [0] != 0) oldattribs = r.r [5];
r.r [0] = 10; r.r [0] = 10;
r.r [2] = 0xFED; r.r [2] = FileType_Palette;
r.r [4] = (int) &palette; r.r [4] = (int) &palette;
r.r [5] = (int) &palette + len; r.r [5] = (int) &palette + len;
...@@ -734,22 +700,27 @@ static BOOL buffer_sprite_palette (void *shandle, int *max) ...@@ -734,22 +700,27 @@ static BOOL buffer_sprite_palette (void *shandle, int *max)
return mysendbuf (&pp, len, max, 0); return mysendbuf (&pp, len, max, 0);
} }
static void menus_save_selection (main_window* window) static void menus_save_selection (main_window *window)
{
ftracef0 ("menus_save_selection\n"); { ftracef0 ("menus_save_selection\n");
if (window->selection.count==1) if (window->selection.count==1)
{ { main_sprite *sprite;
main_sprite* sprite;
for (sprite=window->data->file.sprites;sprite;sprite=sprite->link) /* Just one selected, find it, and save it on its own with
{ the sprite name as the filename instead */
if (sprite->flags & MSF_SELECTED) break; 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; 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) void menus_save_sprite (main_sprite *sprite)
...@@ -761,14 +732,9 @@ void menus_save_sprite (main_sprite *sprite) ...@@ -761,14 +732,9 @@ void menus_save_sprite (main_sprite *sprite)
ftracef1 ("sprite called \"%s\"\n", name); ftracef1 ("sprite called \"%s\"\n", name);
myxfersend (SPRITE_FILE, name, myxfersend (FileType_Sprite, name,
psprite_address (sprite)->next + sizeof (sprite_area), psprite_address (sprite)->next + sizeof (sprite_area),
&save_sprite, &buffer_sprite, &save_sprite, &buffer_sprite, &Do_Print, 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);
} }
BOOL menus_save_file (main_window *window, int askfor_name) BOOL menus_save_file (main_window *window, int askfor_name)
...@@ -785,7 +751,7 @@ 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) if (askfor_name)
{ My_File_Is_Safe = FALSE; { My_File_Is_Safe = FALSE;
ftracef0 ("menus_save_file: myxfersend\n"); 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, &save_file_proc, &buffer_file_proc,
&print_file_proc, /*Protocol now in xfersend(), immediate printing &print_file_proc, /*Protocol now in xfersend(), immediate printing
allowed. Was NULL. JRC 4 Apr 1992*/ allowed. Was NULL. JRC 4 Apr 1992*/
...@@ -840,7 +806,8 @@ static void Change_Size (sprite_area **sarea, sprite_id *sid, ...@@ -840,7 +806,8 @@ static void Change_Size (sprite_area **sarea, sprite_id *sid,
if (!menus_ensure_size (sarea, newsize - info.size)) if (!menus_ensure_size (sarea, newsize - info.size))
{ msg = msgs_lookup ("PntEG"); { msg = msgs_lookup ("PntEG");
goto finish; goto finish;
} } }
}
else else
{ /* Deleting - find the maximum number or rows or columns that can go */ { /* Deleting - find the maximum number or rows or columns that can go */
int max; int max;
...@@ -895,7 +862,7 @@ void menus_restart_tool (void) ...@@ -895,7 +862,7 @@ void menus_restart_tool (void)
for (window = main_windows; window != NULL; window = window->link) for (window = main_windows; window != NULL; window = window->link)
if (window->tag == main_window_is_file) if (window->tag == main_window_is_file)
for (sprite = window->data->file.sprites; sprite != NULL; for (sprite = window->data->file.sprites; sprite != NULL;
sprite=sprite->link) sprite = sprite->link)
sprite->needsnull = 1; sprite->needsnull = 1;
} }
...@@ -911,7 +878,7 @@ static void stop_insdel_graphics (void) ...@@ -911,7 +878,7 @@ static void stop_insdel_graphics (void)
menus_restart_tool (); 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 xmul = sprw->blobsize.scale_xmul*insdel_sprite->mode.scale_xmul;
int xdiv = sprw->blobsize.scale_xdiv; int xdiv = sprw->blobsize.scale_xdiv;
...@@ -926,16 +893,16 @@ static void insdel_drawEOR(main_sprite_window* sprw,int x0,int y0) ...@@ -926,16 +893,16 @@ static void insdel_drawEOR(main_sprite_window* sprw,int x0,int y0)
if (insdel_rowfield != -1) if (insdel_rowfield != -1)
{ ftracef0 ("insdel_EOR row\n"); { ftracef0 ("insdel_EOR row\n");
int top=MAX(insdel_row,Row)+1; int top = MAX(insdel_row, Row) + 1;
int bottom=MIN(insdel_row,Row); int bottom = MIN(insdel_row, Row);
bbc_rectanglefill (MAX (x0, 0), y0 + bottom*ymul/ydiv, bbc_rectanglefill (MAX (x0, 0), y0 + bottom*ymul/ydiv,
0x1FFF, (top - bottom)*ymul/ydiv-1); 0x1FFF, (top - bottom)*ymul/ydiv-1);
} }
if (insdel_colfield != -1) if (insdel_colfield != -1)
{ ftracef0 ("insdel_EOR column\n"); { ftracef0 ("insdel_EOR column\n");
int left=MIN(insdel_col,Column); int left = MIN(insdel_col, Column);
int right=MAX(insdel_col,Column)+1; int right = MAX(insdel_col, Column) + 1;
bbc_rectanglefill (x0 + left*xmul/xdiv, MAX (y0, 0), bbc_rectanglefill (x0 + left*xmul/xdiv, MAX (y0, 0),
(right-left)*xmul/xdiv-1, 0x1FFF); (right-left)*xmul/xdiv-1, 0x1FFF);
} }
...@@ -953,7 +920,7 @@ static void insdel_EOR (void) ...@@ -953,7 +920,7 @@ static void insdel_EOR (void)
wimp_winfo curr; wimp_winfo curr;
curr.w = sprw->window->handle; 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.w = sprw->window->handle;
rds.box = main_big_extent; rds.box = main_big_extent;
wimpt_noerr (wimp_update_wind (&rds, &more)); wimpt_noerr (wimp_update_wind (&rds, &more));
...@@ -962,8 +929,7 @@ static void insdel_EOR (void) ...@@ -962,8 +929,7 @@ static void insdel_EOR (void)
y0 = rds.box.y1 - rds.scy + curr.info.ex.y0; y0 = rds.box.y1 - rds.scy + curr.info.ex.y0;
while (more) while (more)
{ { insdel_drawEOR(sprw, x0, y0);
insdel_drawEOR(sprw,x0,y0);
wimpt_noerr (wimp_get_rectangle (&rds, &more)); wimpt_noerr (wimp_get_rectangle (&rds, &more));
} }
} }
...@@ -1025,7 +991,7 @@ static void insdeltool_redraw (main_window *window, int x0, int y0) ...@@ -1025,7 +991,7 @@ static void insdeltool_redraw (main_window *window, int x0, int y0)
ftracef0 ("insdeltool_redraw\n"); ftracef0 ("insdeltool_redraw\n");
if (window->data->sprite.sprite->needsnull) 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) static void insdeltool_stop (main_sprite *sprite)
...@@ -1179,7 +1145,8 @@ void menus_set_palette (main_sprite *sprite, int entries, int *palette) ...@@ -1179,7 +1145,8 @@ void menus_set_palette (main_sprite *sprite, int entries, int *palette)
for (i = 0; i < entries; i++) for (i = 0; i < entries; i++)
{ *e = *(e + 1) = palette [i]; { *e = *(e + 1) = palette [i];
e += 2; e += 2;
} } }
}
/*Fix up every pointer in the world.*/ /*Fix up every pointer in the world.*/
header->image += diff; header->image += diff;
...@@ -1260,7 +1227,7 @@ void menus_sprite_handler (void *handle, char *hit) ...@@ -1260,7 +1227,7 @@ void menus_sprite_handler (void *handle, char *hit)
{ int size = psprite_palsize (sprite); { int size = psprite_palsize (sprite);
ftracef0 ("Sprite palette save\n"); 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); &save_sprite_palette, &buffer_sprite_palette, 0, sprite);
} }
break; break;
...@@ -1383,7 +1350,9 @@ void menus_sprite_handler (void *handle, char *hit) ...@@ -1383,7 +1350,9 @@ void menus_sprite_handler (void *handle, char *hit)
os_swi3 (ColourPicker_UpdateDialogue, os_swi3 (ColourPicker_UpdateDialogue,
colourpicker_UPDATE_COLOUR, sprite->colourdialogue, colourpicker_UPDATE_COLOUR, sprite->colourdialogue,
&dialogue); &dialogue);
} } } }
}
}
break; break;
case s_Paint_Show_Col: case s_Paint_Show_Col:
...@@ -1684,7 +1653,8 @@ void menus_sprite_handler (void *handle, char *hit) ...@@ -1684,7 +1653,8 @@ void menus_sprite_handler (void *handle, char *hit)
Change_Size (sarea, &sid, sprite, number, !col, Change_Size (sarea, &sid, sprite, number, !col,
!col? MIN (Row, insdel_row): MIN (Column, insdel_col)); !col? MIN (Row, insdel_row): MIN (Column, insdel_col));
menus_ensure_size (sarea, 0); menus_ensure_size (sarea, 0);
} } }
}
break; break;
case s_Edit_Mask: case s_Edit_Mask:
...@@ -1741,7 +1711,8 @@ void menus_sprite_handler (void *handle, char *hit) ...@@ -1741,7 +1711,8 @@ void menus_sprite_handler (void *handle, char *hit)
sprite->colourdialogue, &dialogue)) != NULL) sprite->colourdialogue, &dialogue)) != NULL)
{ msg = error->errmess; { msg = error->errmess;
goto masked; goto masked;
} } }
}
/*Fix MED-xxx J R C 21st Jul 1994*/ /*Fix MED-xxx J R C 21st Jul 1994*/
if (!create) if (!create)
...@@ -1884,7 +1855,7 @@ static BOOL queue_print (dbox d, main_sprite *sprite) ...@@ -1884,7 +1855,7 @@ static BOOL queue_print (dbox d, main_sprite *sprite)
psprite_read_full_info (sprite, &info); 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, /*saver*/ &save_sprite, /*sender - no point yet*/ NULL,
/*printer*/ &Do_Print, /*handle*/ sprite)) /*printer*/ &Do_Print, /*handle*/ sprite))
return FALSE; return FALSE;
...@@ -1989,7 +1960,8 @@ BOOL menus_do_print (main_sprite *sprite) ...@@ -1989,7 +1960,8 @@ BOOL menus_do_print (main_sprite *sprite)
if ((err = os_swix3 (PDriver_DeclareFont, 0, NULL, 0)) != NULL) if ((err = os_swix3 (PDriver_DeclareFont, 0, NULL, 0)) != NULL)
{ txt = err->errmess; { txt = err->errmess;
goto finish; goto finish;
} } }
}
if (print_landscape) menus_print_where.dx += ssize.y1*72000/180; if (print_landscape) menus_print_where.dx += ssize.y1*72000/180;
...@@ -2032,7 +2004,8 @@ BOOL menus_do_print (main_sprite *sprite) ...@@ -2032,7 +2004,8 @@ BOOL menus_do_print (main_sprite *sprite)
if ((err = print_getrectangle (&pbox, &more, &ID)) != NULL) if ((err = print_getrectangle (&pbox, &more, &ID)) != NULL)
{ txt = err->errmess; { txt = err->errmess;
goto finish; goto finish;
} } }
}
finish: finish:
if (done_translate) if (done_translate)
...@@ -2172,9 +2145,11 @@ void menus_print_sprite (main_sprite *sprite, BOOL ask) ...@@ -2172,9 +2145,11 @@ void menus_print_sprite (main_sprite *sprite, BOOL ask)
case dbox_CLOSE: case dbox_CLOSE:
open = FALSE; open = FALSE;
break; break;
} } }
}
dbox_dispose (&d); dbox_dispose (&d);
} } }
}
else else
/*FIX G-RO-7139 JRC 17 Oct '91 Call queue_print() instead of /*FIX G-RO-7139 JRC 17 Oct '91 Call queue_print() instead of
menus_do_print().*/ menus_do_print().*/
...@@ -2197,7 +2172,9 @@ void menus_hack_palette (main_sprite *sprite) ...@@ -2197,7 +2172,9 @@ void menus_hack_palette (main_sprite *sprite)
ftracef2 ("was 0x%.8X now 0x%.8X\n", ftracef2 ("was 0x%.8X now 0x%.8X\n",
*palstart, t | ((t >> 4) & 0xF0F0F00)); *palstart, t | ((t >> 4) & 0xF0F0F00));
*palstart = t | ((t >> 4) & 0xF0F0F00); *palstart = t | ((t >> 4) & 0xF0F0F00);
} } } }
}
}
/*************************************************************************** /***************************************************************************
* * * *
...@@ -2247,135 +2224,121 @@ void menus_file_handler (void *handle, char *hit) ...@@ -2247,135 +2224,121 @@ void menus_file_handler (void *handle, char *hit)
window->data->file.filename == NULL? window->data->file.filename == NULL?
msgs_lookup ("PntF4"): window->data->file.filename); msgs_lookup ("PntF4"): window->data->file.filename);
dbox_setnumeric (d, d_File_Number, sarea->number); 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_Size, sizestring);
dbox_setfield (d, d_File_Mod, yesno (window->data->file.modified)); dbox_setfield (d, d_File_Mod, yesno (window->data->file.modified));
dbox_show (d); dbox_show (d);
dbox_raw_eventhandler (d, sprite_file_info_events, NULL); dbox_raw_eventhandler (d, sprite_file_info_events, NULL);
} } }
}
break; break;
case m_Misc_SBName: { case m_Misc_SBName:
/* Sort by name */ case m_Misc_SBSize:
sprite_area *sarea = window->data->file.spritearea; { /* Sort by name or size */
int count = sarea->number; sprite_area *unsorted = window->data->file.spritearea;
if (count < 2) break; /* Not worth sorting */
/* The sprite name has no terminator when it's 12 long,so copy and terminate the names */
sprite_area *sorted; sprite_area *sorted;
sprite_id sid; sprite_header *header;
main_sprite *sprite,*nextsprite; int count = unsorted->number;
main_file *file = &window->data->file; main_file *file = &window->data->file;
int size = sarea->size; main_sprite *sprite;
int loop, next, i; int loop, next;
BOOL byname = (hit[1] == m_Misc_SBName);
sprite_tosort tosort[count]; sprite_tosort tosort[count];
sprite_tosort *tosortptr[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; count = 0;
for (sprite=file->sprites;sprite!=NULL;sprite=sprite->link) for (sprite = file->sprites; sprite != NULL; sprite = sprite->link)
{ { if (byname)
strncpy((char *)tosort[count].tosort, /* The heapsort copy */ { /* Sprite names can be the full 12 letters long so take a copy */
((char *)sarea) + sprite->offset + 4, /* The source name */ memcpy ((char *)tosort[count].type.orgname,
((char *)unsorted) + sprite->offset + offsetof (sprite_header, name),
NAME_LIMIT); NAME_LIMIT);
tosort[count].tosort[NAME_LIMIT] = '\0'; /* Ensure a terminator */ tosort[count].type.orgname[NAME_LIMIT] = '\0'; /* Ensure a string terminator */
tosort[count].tojumble = sprite; /* Remember the corresponding sprite structure pointer */ }
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]; tosortptr[count] = &tosort[count];
count++; count++;
} }
if (((int)&tosortptr) & 0xE0000000) regs.r[0] = count;
{ regs.r[1] = (int)&tosortptr;
/* Too high - give it to HeapSort32 to jiggle the pointers */ regs.r[2] = byname ? 4 : 2;
if (wimpt_complain (_swix (OS_HeapSort32, _INR(0,2) | _IN(7), count, &tosortptr, 4, 0))) 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; break;
} }
else else
{ { /* Give it to HeapSort to jiggle the pointers */
/* Give it to HeapSort to jiggle the pointers */ if (wimpt_complain (os_swix (OS_HeapSort, &regs)) != NULL)
if (wimpt_complain (_swix (OS_HeapSort, _INR(0,2), count, &tosortptr, 4)))
break; break;
} }
for (loop = 0; (loop < (count-1)) && (tosortptr[loop] < tosortptr[loop+1]); loop++) for (loop = 0; (loop < (count-1)) && (tosortptr[loop] < tosortptr[loop+1]); loop++)
{ { /* Nothing */
/* Nothing */
} }
if (loop==(count-1)) break; /* They were already in order */ if (loop==(count-1)) break; /* They were already in order */
visdelay_begin (); visdelay_begin ();
/* Copy them over to a new area in the right order */ /* Allocate a new blank area to copy into */
if (!flex_alloc((flex_ptr) &sorted, size)) if (!flex_alloc ((flex_ptr)&sorted, unsorted->size))
{ { werr (FALSE, msgs_lookup ("PntEG"));
werr (FALSE, msgs_lookup ("PntEG"));
break; break;
} }
ftracef1("sort flex'd %08X\n",(char *)sorted); ftracef1 ("sort flex'd %08X\n", (char *)sorted);
sorted->size = size; unsorted = window->data->file.spritearea; /* Might have shifted */
sorted->size = unsorted->size;
sorted->number = count;
sorted->sproff = next = 16; 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++) for (loop = 0; loop < count; loop++)
{ { int size;
sprite = nextsprite; /* For each sprite in the sorted pointers, locate the unsorted one, copy it */
sid.s.name = tosortptr[loop]->tosort; header = (sprite_header *)((int)unsorted + tosortptr[loop]->orgsprite->offset);
sid.tag = sprite_id_name; size = header->next;
sarea = window->data->file.spritearea; /* Incase flex shuffled */ ftracef2 ("sort selected %08X size %d\n", (int)header, size);
sprite_select_rp(sarea, &sid, &sid.s.addr); /* Will succeed as they were there about 15 lines ago */ memcpy ((char *)sorted + next, (char *)header, size);
size = ((sprite_header *) sid.s.addr)->next;
ftracef2("sort selected %08X size %d\n",(int)sid.s.addr, size);
memcpy((char *)sorted + next,(char *)sid.s.addr, size);
next = next + size; next = next + size;
/* Now magic up a new sprite info block */
sprite->file = tosortptr[loop]->tojumble->file; /* Append its structure to the list, when the file is marked as changed later
sprite->windows = tosortptr[loop]->tojumble->windows; a call to psprite_recalculate_offsets fixes up the spriteno and offset
sprite->transtab = tosortptr[loop]->tojumble->transtab; fields */
sprite->mode = tosortptr[loop]->tojumble->mode; if (loop == 0)
sprite->iconsize = tosortptr[loop]->tojumble->iconsize; file->sprites = tosortptr[loop]->orgsprite; /* Head */
sprite->colourhandle = tosortptr[loop]->tojumble->colourhandle; else
for (i = 0; i < 4; i++) sprite->ECFs [i].sarea = tosortptr[loop]->tojumble->ECFs [i].sarea; sprite->link = tosortptr[loop]->orgsprite;
sprite->gcol = tosortptr[loop]->tojumble->gcol; sprite = tosortptr[loop]->orgsprite;
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; /* End the sprite area nicely */
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));
sprite->link = NULL; sprite->link = NULL;
sorted->number = count;
sorted->freeoff = next; sorted->freeoff = next;
flex_free((flex_ptr) &window->data->file.spritearea); flex_free ((flex_ptr)&window->data->file.spritearea);
*((int *)sorted - 2) =
/* Reanchor the flex block assuming the format is /* Reanchor the flex block assuming the format is
int anchor int anchor
int size int size
char store */ flex_ptr -> char store[] */
(int)&window->data->file.spritearea; *((int *)sorted - 2) = (int)&window->data->file.spritearea;
window->data->file.spritearea = sorted; window->data->file.spritearea = sorted;
ftracef1("sort budg'd %08X\n",(char *)sorted); ftracef2 ("sort budg'd from %08X to %08X\n", (int)unsorted, (int)sorted);
psprite_recalculate_offsets (file);
menus_file_has_changed(window); menus_file_has_changed (window);
visdelay_end (); visdelay_end ();
} }
break; break;
} }
break; break;
...@@ -2405,24 +2368,21 @@ void menus_file_handler (void *handle, char *hit) ...@@ -2405,24 +2368,21 @@ void menus_file_handler (void *handle, char *hit)
break; break;
case m_Sprite_Delete: case m_Sprite_Delete:
{ { main_sprite *sprite;
main_sprite* sprite; main_sprite *next;
main_sprite* next;
int count; int count;
int total=window->selection.count; int total=window->selection.count;
if (window->selection.count==0) break; if (window->selection.count==0) break;
visdelay_begin(); visdelay_begin();
for (count=1,sprite=window->data->file.sprites;sprite;sprite=next,count++) for (count=1, sprite=window->data->file.sprites; sprite != NULL;
{ sprite = next, count++)
visdelay_percent(count*100/total); { visdelay_percent(count*100/total);
next=sprite->link; next = sprite->link;
if (sprite->flags & MSF_SELECTED) if (sprite->flags & MSF_SELECTED)
{ { sprite_area *sarea = sprite->file->spritearea;
sprite_area *sarea = sprite->file->spritearea;
#if FIXDELSPR
main_file *spritefile = sprite->file; main_file *spritefile = sprite->file;
#endif
sprite_id sid; sprite_id sid;
char name [NAME_LIMIT + 1]; char name [NAME_LIMIT + 1];
...@@ -2435,16 +2395,12 @@ void menus_file_handler (void *handle, char *hit) ...@@ -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 /*The next two lines used to be reversed, but it could give a
fatal error. So do it this way*/ fatal error. So do it this way*/
wimpt_complain (sprite_delete (sarea, &sid)); wimpt_complain (sprite_delete (sarea, &sid));
#if FIXDELSPR
menus_ensure_size(&spritefile->spritearea,0); menus_ensure_size(&spritefile->spritearea, 0);
#endif
psprite_delete (window,sprite); psprite_delete (window, sprite);
ftracef0("do menus_file_has_changed\n"); ftracef0("do menus_file_has_changed\n");
menus_file_has_changed (window); menus_file_has_changed (window);
ftracef0("do menus_ensure_size(,0)\n");
#if !FIXDELSPR
menus_ensure_size (&sprite->file->spritearea, 0);
#endif
} }
} }
visdelay_end(); visdelay_end();
...@@ -2526,7 +2482,7 @@ void menus_file_handler (void *handle, char *hit) ...@@ -2526,7 +2482,7 @@ void menus_file_handler (void *handle, char *hit)
wimp_wstate wstate; wimp_wstate wstate;
winfo.w = hit_sprite->colourhandle; 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, sprintf (winfo.info.title.indirecttext.buffer,
msgs_lookup ("PntW7"), spritenamebuffer); msgs_lookup ("PntW7"), spritenamebuffer);
...@@ -2541,7 +2497,9 @@ void menus_file_handler (void *handle, char *hit) ...@@ -2541,7 +2497,9 @@ void menus_file_handler (void *handle, char *hit)
redraw_str.w = -1; redraw_str.w = -1;
redraw_str.box.y0 = wstate.o.box.y1; redraw_str.box.y0 = wstate.o.box.y1;
wimpt_noerr (wimp_force_redraw (&redraw_str)); wimpt_noerr (wimp_force_redraw (&redraw_str));
} } } }
}
}
break; break;
case m_Sprite_Save: case m_Sprite_Save:
...@@ -2584,7 +2542,7 @@ void menus_file_handler (void *handle, char *hit) ...@@ -2584,7 +2542,7 @@ void menus_file_handler (void *handle, char *hit)
/*Change window width to allow one full item, if it is less.*/ /*Change window width to allow one full item, if it is less.*/
curr.w = window->handle; 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", ftracef2 ("current width is %d; need %d\n",
curr.info.box.x1 - curr.info.box.x0, curr.info.box.x1 - curr.info.box.x0,
...@@ -2725,13 +2683,13 @@ static void hack_entry (menu menyoo, int entryno, char *name) ...@@ -2725,13 +2683,13 @@ static void hack_entry (menu menyoo, int entryno, char *name)
menu menus_file_maker (void *handle) menu menus_file_maker (void *handle)
{ {
main_window* window =(main_window *) handle; main_window *window =(main_window *) handle;
main_file *file = &window->data->file; main_file *file = &window->data->file;
int len; int len;
char term [2]; char term [2];
AltRename_delete(); altrename_delete();
ftracef0 ("spritefile_menu_maker\n"); ftracef0 ("spritefile_menu_maker\n");
if (!event_is_menu_being_recreated ()) if (!event_is_menu_being_recreated ())
...@@ -2750,7 +2708,7 @@ menu menus_file_maker (void *handle) ...@@ -2750,7 +2708,7 @@ menu menus_file_maker (void *handle)
if (window->selection.count!=1) if (window->selection.count!=1)
{ {
strcpy (Spritename,msgs_lookup ("PntG6")); strcpy (Spritename, msgs_lookup ("PntG6"));
} }
else else
{ {
...@@ -2776,24 +2734,24 @@ menu menus_file_maker (void *handle) ...@@ -2776,24 +2734,24 @@ menu menus_file_maker (void *handle)
hack_entry (spritefile_main_menu, m_Sprite, Spritename); 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 & selecting */
/* When there are no sprites in the file,forbid its saving */
menu_setflags (spritefile_main_menu, m_Save, 0, menu_setflags (spritefile_main_menu, m_Save, 0,
(file->spritearea->number == 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_Name, !file->fullinfo, 0);
menu_setflags (filedisplay_menu, m_Display_Full, file->fullinfo, 0); menu_setflags (filedisplay_menu, m_Display_Full, file->fullinfo, 0);
menu_setflags (filedisplay_menu, m_Display_UseDT, menu_setflags (filedisplay_menu, m_Display_UseDT,
file->use_current_palette, 0); 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_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_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_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_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_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_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_Print, 0, window->selection.count!=1);
help_register_handler (&help_simplehandler, (void *) "FILER"); help_register_handler (&help_simplehandler, (void *) "FILER");
......