Commit 92007754 authored by Robert Sprowson's avatar Robert Sprowson
Browse files

Change to use shared JPEG library code.

Fix some easy warnings.
Swap to use centralised AWK script to get the version number into the messages.
Removed one use of _swi.
Refer to FileType_ using the filetypes header file.
Fixed linkmap target to link with the libraries.
Rationalise headers a bit.

Version 1.16. Tagged as 'Draw-1_16'
parent 04aa7146
......@@ -13,4 +13,4 @@
| limitations under the License.
|
Dir <Obey$Dir>
amu_machine install INSTDIR=<Install$Dir>.HardDisc4.Apps.!Draw
amu_machine install INSTDIR=<Install$Dir>.Apps.!Draw
s/** gitlab-language=armasm linguist-language=armasm linguist-detectable=true
awk/** gitlab-language=awk linguist-language=awk linguist-detectable=true
*,ffb gitlab-language=bbcbasic linguist-language=bbcbasic linguist-detectable=true
c/** gitlab-language=c linguist-language=c linguist-detectable=true
h/** gitlab-language=c linguist-language=c linguist-detectable=true
* Dither sprites on output.
* Set |draw_jpegs_rotate| when a JPEG is displayed for the first time -
ensures that the rotation code is disabled for all JPEG's, not only those
loaded from file.
* Grey out Transform => Rotate when the selection is not rotatable.
* Reinstate bounding of the diagram before printing.
......@@ -32,7 +32,7 @@ MODULE = rm.!Draw
ROM_MODULE = aof.Draw
RDIR = Resources
LDIR = ${RDIR}.${LOCALE}
MSGVERSION = ${AWK} -f Build:AwkVers
MSGS = Resources.GenMessage
#
......@@ -54,6 +54,7 @@ RM = remove
SQUEEZE = squeeze
WIPE = -wipe
XWIPE = x wipe
AWK = GNU.gawk
AFLAGS = ${THROWBACK} -depend !Depend -nocache -stamp -quit
CFLAGS = ${THROWBACK} -depend !Depend -fah ${INCLUDES} -wp
......@@ -115,20 +116,20 @@ OBJS =\
o.Draw o.DrawAction o.DrawCheck o.DrawDispl o.DrawDXF\
o.DrawEdit o.DrawEnter o.DrawFileIO o.DrawGrid o.DrawHelp\
o.DrawMenu o.DrawObject o.DrawPrint o.DrawScan o.DrawSelect\
o.DrawTextC o.DrawTrans o.DrawUndo o.bezierarc o.jpeg
o.DrawTextC o.DrawTrans o.DrawUndo o.bezierarc
OBJSZ =\
oz.Draw oz.DrawAction oz.DrawCheck oz.DrawDispl oz.DrawDXF\
oz.DrawEdit oz.DrawEnter oz.DrawFileIO oz.DrawGrid oz.DrawHelp\
oz.DrawMenu oz.DrawObject oz.DrawPrint oz.DrawScan oz.DrawSelect\
oz.DrawTextC oz.DrawTrans oz.DrawUndo oz.bezierarc o.jpeg
oz.DrawTextC oz.DrawTrans oz.DrawUndo oz.bezierarc
OBJSD =\
od.Draw od.DrawAction od.DrawCheck od.DrawDispl\
od.DrawDXF od.DrawEdit od.DrawEnter od.DrawFileIO od.DrawGrid\
od.DrawHelp od.DrawMenu od.DrawObject od.DrawPrint od.DrawScan\
od.DrawSelect od.DrawTextC od.DrawTrans od.DrawUndo\
od.bezierarc od.ftrace od.guard od.flex o.jpeg
od.bezierarc od.ftrace od.guard od.flex
ASMS =\
s.Draw s.DrawAction s.DrawCheck s.DrawDispl s.DrawDXF\
......@@ -236,11 +237,11 @@ mod: ${MODULE}
asms: ${ASMS}
linkmap: ${OBJS} ${LIBS}
${LD} -map -o null:x ${OBJS} ${LIBS} > map.linked
linkmap: ${OBJS} ${LIBSD}
${LD} -map -o null:x ${OBJS} ${LIBSD} > map.linked
map:
${LD} -map -rmf -base 0 -o null: ${OBJS} ${LIBS} > map.base0
${LD} -map -rmf -base 0 -o null: ${OBJS} ${LIBSD} > map.base0
clean_all:
x Access ${INSTDIR}.!Boot rw/rw
......@@ -284,8 +285,8 @@ oz.ModuleWrap: s.ModuleWrap ${MSGS} s.AppName ${RESFILES} s.resfiles
s.ModuleWrap: ${WRAPPER}
${CP} ${WRAPPER} $@ ${CPFLAGS}
${MSGS}: ${LDIR}.Messages awk.Version
GNU.gawk -f awk.Version ${LDIR}.Messages > $@
${MSGS}: ${LDIR}.Messages VersionNum
${MSGVERSION} ${LDIR}.Messages > $@
s.ResFiles: asm.ResFiles
${CP} asm.ResFiles $@ ${CPFLAGS}
......
No preview for this file type
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "1.15"
Module_Version SETA 115
Module_MajorVersion SETS "1.16"
Module_Version SETA 116
Module_MinorVersion SETS ""
Module_Date SETS "01 Oct 2009"
Module_ApplicationDate SETS "01-Oct-09"
Module_Date SETS "06 Dec 2010"
Module_ApplicationDate SETS "06-Dec-10"
Module_ComponentName SETS "Draw"
Module_ComponentPath SETS "castle/RiscOS/Sources/Apps/Draw"
Module_FullVersion SETS "1.15"
Module_HelpVersion SETS "1.15 (01 Oct 2009)"
Module_FullVersion SETS "1.16"
Module_HelpVersion SETS "1.16 (06 Dec 2010)"
END
/* (1.15)
/* (1.16)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 1.15
#define Module_MajorVersion_CMHG 1.16
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 01 Oct 2009
#define Module_Date_CMHG 06 Dec 2010
#define Module_MajorVersion "1.15"
#define Module_Version 115
#define Module_MajorVersion "1.16"
#define Module_Version 116
#define Module_MinorVersion ""
#define Module_Date "01 Oct 2009"
#define Module_Date "06 Dec 2010"
#define Module_ApplicationDate "01-Oct-09"
#define Module_ApplicationDate "06-Dec-10"
#define Module_ComponentName "Draw"
#define Module_ComponentPath "castle/RiscOS/Sources/Apps/Draw"
#define Module_FullVersion "1.15"
#define Module_HelpVersion "1.15 (01 Oct 2009)"
#define Module_LibraryVersionInfo "1:15"
#define Module_FullVersion "1.16"
#define Module_HelpVersion "1.16 (06 Dec 2010)"
#define Module_LibraryVersionInfo "1:16"
;ObjAsm file for JPEG
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 xjpeg_plot_scaled
EXPORT xjpeg_plot_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
xjpeg_plot_scaled ROUT
MOV IP, SP
STMFD SP!, {V1, V2, LR}
LDMFD IP, {R4, R5}
SWI &69982
MOVVC R, #0
Return "V1, V2"
xjpeg_plot_transformed ROUT
MOV IP, LR
SWI &69984
MOVVC R, #0
Return ,LinkNotStacked,,IP
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] == "DrawID") {
found = 1
split($2, Date, "-")
}
}
}
END {
printf("; AppName - generated from Messages, used by ModuleWrap\n")
printf("\n")
printf(" GBLS ApplicationName\n")
printf(" GBLS ApplicationVersion\n")
printf("\n")
printf("ApplicationName SETS \"Draw\"\n")
printf("ApplicationVersion SETS \"%s %s %s 19%s\"\n", Id[2], Date[1], Date[2], Date[3])
printf("\n")
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];
}
}
}
}
/^DrawID/ { printf("DrawID:%s (%s)\n", VString, Date); done = 1; next; }
{ print }
END {
if (!done) {
printf("DrawID:%s (%s)\n", VString, Date);
}
}
......@@ -51,7 +51,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "swis.h"
#include <swis.h>
#include "Global/FileTypes.h"
#include "os.h"
#include "akbd.h"
......@@ -76,6 +77,10 @@
#include "saveas.h"
#include "bezierarc.h"
#include "help.h"
#include "drawmod.h"
#include "jpeg.h"
#include "dbox.h"
#include "font.h"
#include "ftrace.h"
#include "guard.h"
......@@ -592,17 +597,14 @@ static void draw_setpointer (diagrec *diag)
{ case state_path:
case state_elli:
case state_rect:
{ sprite_id sprite;
os_regset r;
sprite.tag = sprite_id_name;
sprite.s.name = "crosshairs";
r.r[0] = 256 + 40; /* read sprite information */
r.r[1] = (int) resspr_area ();
r.r[2] = (int) sprite.s.name;
wimpt_noerr (os_swix (OS_SpriteOp, &r));
wimpt_noerr (pointer_set_shape (resspr_area (), &sprite, (r.r[3]-1)/2, (r.r[4]-1)/2));
{ sprite_id id;
sprite_info info;
/* read sprite information for the crosshairs */
id.tag = sprite_id_name;
id.s.name = "crosshairs";
wimpt_noerr (sprite_readsize (resspr_area (), &id, &info));
wimpt_noerr (pointer_set_shape (resspr_area (), &id, (info.width-1)/2, (info.height-1)/2));
}
break;
......@@ -1295,7 +1297,7 @@ void draw_paper_close (viewrec *vuue)
switch (dboxquery_close (a))
{ case dboxquery_close_SAVE:
if (*name == 0) name = filename_whole;
saveas (filetype_DRAWFILE, name, 1024,
saveas (FileType_Draw, name, 1024,
draw_file_file_saveall, draw_file_ram_saveall,
draw_file_printall, (void*)diag);
break;
......@@ -1557,17 +1559,17 @@ static os_error *load_file (diagrec *diag, viewrec *vuue, draw_objcoord *pt,
if (diag == NULL) vuue = NULL;
switch (filetype)
{ case filetype_DXF:
{ case FileType_DataExchangeFormat:
/*if (!draw_dxf_setOptions ()) break; can't do this yet - breaks the
data transfer protocol*/
/*fall into general case*/
case filetype_DRAWFILE:
case FileType_Draw:
#if ALLOW_DFILES
case filetype_DFILE:
case FileType_EarlyDrawingProgram:
#endif
case filetype_SPRITE:
case filetype_text:
case jpeg_FILE_TYPE:
case FileType_Sprite:
case FileType_Text:
case FileType_JPEG:
draw_file_loadfile (diag, vuue, "", filetype, estsize, via_RAM, pt);
break;
......@@ -1583,18 +1585,18 @@ static os_error *load_file (diagrec *diag, viewrec *vuue, draw_objcoord *pt,
filetype = xferrecv_checkinsert (&name);
switch (filetype)
{ case filetype_SPRITE:
{ case FileType_Sprite:
#if ALLOW_DFILES
case filetype_DFILE:
case FileType_EarlyDrawingProgram:
#endif
case filetype_text:
case filetype_DXF:
case jpeg_FILE_TYPE:
case FileType_Text:
case FileType_DataExchangeFormat:
case FileType_JPEG:
if (insert) break;
case filetype_DRAWFILE:
case FileType_Draw:
if (check_filename (name, filename, FILENAMEMAX))
{ /*if (filetype == filetype_DXF && !draw_dxf_setOptions ())
{ /*if (filetype == FileType_DataExchangeFormat && !draw_dxf_setOptions ())
break; Can't do this yet - breaks the data transfer
protocol.*/
......@@ -2167,7 +2169,7 @@ static void draw_bkg_events (wimp_eventstr *e, void *handle)
filetype = xferrecv_checkprint (&name);
switch (filetype)
{ case filetype_DRAWFILE:
{ case FileType_Draw:
{ diagrec *diag;
diag = draw_file_loadfile (NULL, NULL, name, 0, 0,
......@@ -2634,6 +2636,10 @@ int main (int argc, char **argv)
/*handler receives a mode change message*/
wimp_readpalette (&draw_palette); /*Record palette colours*/
/*Find out if jpegs are rotatable by this version of SpriteExtend*/
draw_jpegs_rotate = jpeg_arbitrary_trans_supported ();
ftracef1 ("jpegs rotate: %s\n", draw_jpegs_rotate ? "TRUE" : "FALSE");
/*Generate the points on a circle of standard radius, centre (0,0).*/
/*These are placed in a point buffer implemented as an array of coords,*/
/*the circle is given by:*/
......@@ -2668,7 +2674,7 @@ int main (int argc, char **argv)
BOOL reported = FALSE;
os_filestr file_str;
os_error error;
os_regset reg_set;
os_regset regs;
_kernel_oserror *last_error;
char last_errmess [256];
......@@ -2698,15 +2704,21 @@ int main (int argc, char **argv)
{ struct {int errno; char errmess [sizeof "DrawX"];} DrawX =
{0, "DrawX"};
reg_set.r [0] = (int) msgtrans_error_lookup (&DrawX,
msgs_main_control_block (), NULL, 0, last_errmess,
"<WIMP$ScrapDir>", draw, 0);
reg_set.r [1] = 3 /*OK and Cancel boxes*/;
reg_set.r [2] = (int) draw;
(void) os_swix (Wimp_ReportError, &reg_set);
regs.r[0] = (int)&DrawX;
regs.r[1] = (int)msgs_main_control_block ();
regs.r[2] = NULL;
regs.r[3] = 0;
regs.r[4] = (int)last_errmess;
regs.r[5] = (int)"<WIMP$ScrapDir>";
regs.r[6] = (int)draw;
regs.r[7] = 0;
os_swix (MessageTrans_ErrorLookup, &regs);
regs.r[1] = 3 /*OK and Cancel boxes*/;
regs.r[2] = (int)draw;
os_swix (Wimp_ReportError, &regs);
reported = TRUE;
if (reg_set.r [1] == 2) break; /*cancel*/
if (regs.r[1] == 2) break; /*cancel*/
/*Make the directory, if necessary.*/
sprintf (preserve, "%s.%s", scrap_dir, draw);
......@@ -2730,9 +2742,14 @@ int main (int argc, char **argv)
/*Report the error if we haven't yet.*/
if (!reported)
{ os_error *err;
os_error errblk = {0, "wimpt1"};
err = msgtrans_error_lookup (&errblk, msgs_default_control_block (), NULL, 0, 0, 0, 0, 0);
os_regset regs;
os_error errblk = {0, "wimpt1"};
regs.r[0] = (int)&errblk;
regs.r[1] = (int)msgs_main_control_block ();
regs.r[2] = NULL;
regs.r[3] = 0;
err = os_swix (MessageTrans_ErrorLookup, &regs);
sprintf (errblk.errmess, err->errmess, last_errmess);
wimpt_reporterror (&errblk, (wimp_errflags) 0);
}
......
......@@ -34,6 +34,11 @@
#include "bbc.h"
#include "wimp.h"
#include "wimpt.h"
#include "drawmod.h"
#include "jpeg.h"
#include "dbox.h"
#include "font.h"
#include "menu.h"
#include "ftrace.h"
#include "guard.h"
......
......@@ -59,6 +59,10 @@
#include "werr.h"
#include "xferrecv.h"
#include "msgs.h"
#include "drawmod.h"
#include "jpeg.h"
#include "dbox.h"
#include "font.h"
#include "ftrace.h"
#include "guard.h"
......
......@@ -86,6 +86,9 @@
#include "bezierarc.h"
#include "dbox.h"
#include "help.h"
#include "drawmod.h"
#include "jpeg.h"
#include "font.h"
#include "ftrace.h"
#include "guard.h"
......@@ -1001,7 +1004,7 @@ static BOOL dxf__getPoint (int group, dxf__coord *point)
/*Map colour number to BBGGRRxx value*/
static draw_coltyp dxf__colourTable [] =
{ 0xffffff00, /*white*/
{ 0xffffff00, /*white*/
0x0000ff00, /*red*/
0x00ffff00, /*yellow*/
0x00ff0000, /*green*/
......
......@@ -43,6 +43,9 @@
#include "werr.h"
#include "wimp.h"
#include "wimpt.h"
#include "jpeg.h"
#include "dbox.h"
#include "font.h"
#include "ftrace.h"
#include "guard.h"
......@@ -61,9 +64,6 @@
#undef font_ABS
#define font_ABS 0
#undef ColourTrans_GenerateTable
#define ColourTrans_GenerateTable 0x40763
#ifndef USETAGBBOX
draw_bboxtyp *draw_displ_bbox (draw_objptr hdrptr)
......@@ -1297,7 +1297,11 @@ static os_error *do_objtrfmtext (draw_objptr hdrptr, draw_objcoord *org)
static os_error *do_objjpeg (draw_objptr hdrptr, draw_objcoord *org)
{ sprite_transmat mat;
jpeg_id jid;
jid.s.image.addr = &hdrptr.jpegp->image;
jid.s.image.size = hdrptr.jpegp->len;
jid.tag = jpeg_id_addr;
ftracef0 ("do_objjpeg\n");
mat [0] = (int) (draw_displ_scalefactor*hdrptr.jpegp->trans_mat [0]);
......@@ -1309,8 +1313,7 @@ static os_error *do_objjpeg (draw_objptr hdrptr, draw_objcoord *org)
ftracef3 ("matrix 0x(% .8X % .8X % .8X)\n", mat [0], mat [2], mat [4]);
ftracef3 (" 0x(% .8X % .8X % .8X)\n", mat [1], mat [3], mat [5]);
return xjpeg_plot_transformed (&hdrptr.jpegp->image, jpeg_PLOT_TRANSFORM_DITHERED, mat,
hdrptr.jpegp->len);
return jpeg_put_trans (&jid, jpeg_PUT_DITHER_ENABLE, NULL, &mat);
}
/* ------------------------------------------------------------------- */
......@@ -1430,7 +1433,7 @@ os_error *draw_displ_do_objects (diagrec *diag, int offset, int end,
bbc_rectanglefill (x0, y0, x1 - x0, y1 - y0);
wimp_setcolour (7); /*black*/
draw_displ_setVDU5charsize (xsize, ysize, xsize, ysize);
wimpt_noerr (_swix (OS_ReadVduVariables, _IN(0)|_IN(1), grwinvars, gw));
wimpt_noerr (os_swix2 (OS_ReadVduVariables, grwinvars, gw));
gw [0] <<= draw_currentmode.xeigfactor;
gw [1] <<= draw_currentmode.yeigfactor;
gw [2] <<= draw_currentmode.xeigfactor;
......
......@@ -40,6 +40,9 @@
#include "dbox.h"
#include "msgs.h"
#include "help.h"
#include "drawmod.h"
#include "jpeg.h"
#include "font.h"
#include "ftrace.h"
#include "guard.h"
......
......@@ -34,6 +34,10 @@
#include "wimpt.h"
#include "win.h"
#include "event.h"
#include "drawmod.h"
#include "jpeg.h"
#include "dbox.h"
#include "font.h"
#include "ftrace.h"
#include "guard.h"
......
......@@ -33,6 +33,8 @@
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <swis.h>
#include "Global/FileTypes.h"
#include "os.h"
#include "bbc.h"
......@@ -44,6 +46,11 @@
#include "visdelay.h"
#include "xferrecv.h"
#include "xfersend.h"
#include "menu.h"
#include "drawmod.h"
#include "jpeg.h"
#include "dbox.h"
#include "font.h"
#include "ftrace.h"
#include "guard.h"
......@@ -62,9 +69,6 @@
#include "DrawTextC.h"
#include "DrawUndo.h"
#undef PDriver_SelectDriver
#define PDriver_SelectDriver 0x80158
static struct
{ diagrec *diag;
int filelen;
......@@ -612,8 +616,9 @@ static BOOL fetch_jpeg (diagrec *diag, char *name, int filelen,
draw_objcoord *pt)
{ /*filelen is correct for xfer via_FILE, but a guess for xfer via_RAM*/
draw_objptr hdrptr;
unsigned int info;
draw_objptr hdrptr;
jpeg_id jid;
jpeg_info jinfo;
ftracef0 ("draw_file: fetch_jpeg\n");
if (wimpt_complain (draw_obj_checkspace (diag, sizeof (draw_fileheader) +
......@@ -632,19 +637,17 @@ static BOOL fetch_jpeg (diagrec *diag, char *name, int filelen,
hdrptr.jpegp->len = filelen;
/*Get width, height in OSU.*/
if (wimpt_complain (xjpeginfo_dimensions (&hdrptr.jpegp->image,
hdrptr.jpegp->len, &info, &hdrptr.jpegp->width, &hdrptr.jpegp->height,
&hdrptr.jpegp->xdpi, &hdrptr.jpegp->ydpi)))
jid.tag = jpeg_id_addr;
jid.s.image.addr = &hdrptr.jpegp->image;
jid.s.image.size = hdrptr.jpegp->len;
if (wimpt_complain (jpeg_readinfo (&jid, &jinfo)))
return FALSE;
ftracef3 ("JPEG scaling (%d, %d) %s\n", hdrptr.jpegp->xdpi, hdrptr.jpegp->ydpi,
(info & jpeg_INFO_DPI_UNKNOWN) == 0u? "absolute": "relative");
if ((info & jpeg_INFO_NO_TRFM) != 0u) draw_jpegs_rotate = FALSE;
ftracef1 ("jpegs rotate: %s\n", draw_jpegs_rotate? "TRUE": "FALSE");
/*If we have no pixel size, assume 1 xpixel == 2 OSU.*/