Commit 0aab2177 authored by Kevin Bracey's avatar Kevin Bracey
Browse files

Version RO_3_71 taken

parent 6d9d6498
RMEnsure UtilityModule 3.10 Error This version of Draw requires RISC OS 3.10
RMEnsure UtilityModule 3.60 Error This version of Draw requires RISC OS 3.60
If "<Wimp$ScrapDir>"="" then Error Draw requires a scrap directory: open a directory that contains the Scrap application
Set Draw$Dir <Obey$Dir>
......
No preview for this file type
......@@ -658,84 +658,83 @@ static os_error *do_objsprite (draw_objptr hdrptr, draw_objcoord *org)
sprite_id id;
sprite_info info;
sprite_factors factors;
char pixtrans[256]; /* pixel conversion tab */
int pixtrans[256]; /* pixel conversion tab */
int ne;
os_regset reg_set;
ftracef1 ("do_objsprite: \"%.12s\"\n", hdrptr.spritep->sprite.name);
id.tag = sprite_id_addr;
id.s.addr = &hdrptr.spritep->sprite;
{ int ne = (hdrptr.spritep->sprite.image - sizeof (sprite_header))/
(2*sizeof (int));
ne = (hdrptr.spritep->sprite.image - sizeof (sprite_header))/
(2*sizeof (int));
if (ne != 0)
{ os_regset reg_set;
if (ne != 0)
{ reg_set.r [0] = 0x100 /*source mode*/;
reg_set.r [1] = (int) &hdrptr.spritep->sprite /*source palette*/;
reg_set.r [2] = -1 /*destination mode*/;
reg_set.r [3] = -1 /*destination palette*/;
reg_set.r [4] = (int) pixtrans /*pixel translation table*/;
reg_set.r [5] = 1 << 0 /*R1 is a sprite pointer*/ |
1 << 1 /*use current palette if sprite has none*/ |
1 << 4 /*return wide entries*/;
reg_set.r [0] = 0x100 /*source mode*/;
reg_set.r [1] = (int) &hdrptr.spritep->sprite /*source palette*/;
reg_set.r [2] = -1 /*destination mode*/;
reg_set.r [3] = -1 /*destination palette*/;
reg_set.r [4] = (int) &pixtrans [0] /*pixel translation table*/;
reg_set.r [5] = 1 << 0 /*R1 is a sprite pointer*/ |
1 << 1 /*use current palette if sprite has none*/;
#if TRACE
ftracef (__FILE__, __LINE__,
"SWI ColourTrans_GenerateTable, %d, %d, %d, %d, %d, %d\n",
reg_set.r [0], reg_set.r [1], reg_set.r [2],
reg_set.r [3], reg_set.r [4], reg_set.r [5]);
#endif
if ((err = os_swix (ColourTrans_GenerateTable, &reg_set)) != NULL)
return err;
}
else
{ /*Sprite has no palette*/
wimp_palettestr palette_str;
int lb_bpp;
#if TRACE
ftracef (__FILE__, __LINE__,
"SWI ColourTrans_GenerateTable, %d, %d, %d, %d, %d, %d\n",
reg_set.r [0], reg_set.r [1], reg_set.r [2],
reg_set.r [3], reg_set.r [4], reg_set.r [5]);
#endif
if ((err = os_swix (ColourTrans_GenerateTable, &reg_set)) != NULL)
return err;
if ((lb_bpp = bbc_modevar (hdrptr.spritep->sprite.mode, bbc_Log2BPP))
== -1)
return NULL;
if (lb_bpp < 3)
{ ftracef0 ("read WIMP's palette\n");
if ((err = wimp_readpalette (&palette_str)) != NULL)
return err;
}
else
{ /*Sprite has no palette*/
wimp_palettestr palette_str;
int lb_bpp;
os_regset reg_set;
if ((lb_bpp = bbc_modevar (hdrptr.spritep->sprite.mode, bbc_Log2BPP))
== -1)
return NULL;
if (lb_bpp < 3)
{ ftracef0 ("read WIMP's palette\n");
if ((err = wimp_readpalette (&palette_str)) != NULL)
return err;
}
/*Fix MED-4786: use the right entries for palettes < 16 entries. J R C
6th Mar 1995*/
switch (lb_bpp)
{ case 0:
palette_str.c [1] = palette_str.c [7];
break;
case 1:
palette_str.c [1] = palette_str.c [2];
palette_str.c [2] = palette_str.c [4];
palette_str.c [3] = palette_str.c [7];
break;
}
/*Fix MED-4786: use the right entries for palettes < 16 entries. J R C
6th Mar 1995*/
switch (lb_bpp)
{ case 0:
palette_str.c [1] = palette_str.c [7];
break;
case 1:
palette_str.c [1] = palette_str.c [2];
palette_str.c [2] = palette_str.c [4];
palette_str.c [3] = palette_str.c [7];
break;
}
reg_set.r [0] = hdrptr.spritep->sprite.mode /*source mode*/;
reg_set.r [1] = lb_bpp < 3? (int) &palette_str.c [0]:
-1 /*source palette*/;
/*was NULL. J R C 5th Oct 1993**/
reg_set.r [2] = -1 /*destination mode*/;
reg_set.r [3] = -1 /*destination palette*/;
reg_set.r [4] = (int) pixtrans /*pixel translation table*/;
reg_set.r [5] = 0;
reg_set.r [0] = hdrptr.spritep->sprite.mode /*source mode*/;
reg_set.r [1] = lb_bpp < 3? (int) &palette_str.c [0]:
-1 /*source palette*/;
/*was NULL. J R C 5th Oct 1993**/
reg_set.r [2] = -1 /*destination mode*/;
reg_set.r [3] = -1 /*destination palette*/;
reg_set.r [4] = (int) pixtrans /*pixel translation table*/;
reg_set.r [5] = 1 << 4 /*return wide entries*/;
#if TRACE
ftracef (__FILE__, __LINE__,
"SWI ColourTrans_GenerateTable, %d, %d, %d, %d, %d, %d\n",
reg_set.r [0], reg_set.r [1], reg_set.r [2],
reg_set.r [3], reg_set.r [4], reg_set.r [5]);
#endif
if ((err = os_swix (ColourTrans_GenerateTable, &reg_set)) != NULL)
return err;
}
#if TRACE
ftracef (__FILE__, __LINE__,
"SWI ColourTrans_GenerateTable, %d, %d, %d, %d, %d, %d\n",
reg_set.r [0], reg_set.r [1], reg_set.r [2],
reg_set.r [3], reg_set.r [4], reg_set.r [5]);
#endif
if ((err = os_swix (ColourTrans_GenerateTable, &reg_set)) != NULL)
return err;
}
sprite_readsize ((sprite_area *) 0xFF, &id, &info);
......@@ -767,20 +766,23 @@ static os_error *do_objsprite (draw_objptr hdrptr, draw_objcoord *org)
return sprite_put_scaled
((sprite_area*) 0xFF, /* this op needs no area */
&id, /* address of sprite */
8 | 1 << 6, /* GcolAction=STORE thro mask */
8 | 1 << 5 | 1 << 6, /* GcolAction=STORE thro mask, wide entries, dithered*/
scaleS (org->x, hdrptr.spritep->bbox.x0),
scaleS (org->y, hdrptr.spritep->bbox.y0),
&factors,
(sprite_pixtrans *) &pixtrans [0]);
(sprite_pixtrans *) pixtrans);
}
static os_error *do_objtrfmsprite (draw_objptr hdrptr, draw_objcoord *org)
/*Fix med-5342: use wide ttab.*/
{ os_error *err;
sprite_id id;
char pixtrans [256]; /* pixel conversion tab */
int pixtrans [256]; /* pixel conversion tab */
sprite_transmat mat;
int i, ne;
os_regset reg_set;
ftracef1 ("do_objtrfmsprite: name: \"%.12s\"\n",
hdrptr.trfmspritep->sprite.name);
......@@ -792,23 +794,22 @@ static os_error *do_objtrfmsprite (draw_objptr hdrptr, draw_objcoord *org)
(2*sizeof (int));
if (ne != 0)
{ os_regset reg_set;
reg_set.r [0] = 0x100 /*source mode*/;
{ reg_set.r [0] = 0x100 /*source mode*/;
reg_set.r [1] = (int) &hdrptr.trfmspritep->sprite /*source palette*/;
reg_set.r [2] = -1 /*destination mode*/;
reg_set.r [3] = -1 /*destination palette*/;
reg_set.r [4] = (int) &pixtrans [0] /*pixel translation table*/;
reg_set.r [4] = (int) pixtrans /*pixel translation table*/;
reg_set.r [5] = 1 << 0 /*R1 is a sprite pointer*/ |
1 << 1 /*use current palette if sprite has none*/;
1 << 1 /*use current palette if sprite has none*/ |
1 << 4 /*return wide entries*/;
#if TRACE
ftracef (__FILE__, __LINE__,
"SWI ColourTrans_SelectTable, %d, %d, %d, %d, %d, %d\n",
"SWI ColourTrans_GenerateTable, %d, %d, %d, %d, %d, %d\n",
reg_set.r [0], reg_set.r [1], reg_set.r [2],
reg_set.r [3], reg_set.r [4], reg_set.r [5]);
#endif
if ((err = os_swix (ColourTrans_SelectTable, &reg_set)) != NULL)
if ((err = os_swix (ColourTrans_GenerateTable, &reg_set)) != NULL)
return err;
}
else
......@@ -826,26 +827,35 @@ static os_error *do_objtrfmsprite (draw_objptr hdrptr, draw_objcoord *org)
return err;
}
/*Fix MED-4786: use the right entries for palettes < 16 entries. J R C
6th Mar 1995*/
switch (lb_bpp)
{ case 0:
palette_str.c [1] = palette_str.c [7];
break;
/*Fix MED-4786: use the right entries for palettes < 16 entries. J R C
6th Mar 1995*/
switch (lb_bpp)
{ case 0:
palette_str.c [1] = palette_str.c [7];
break;
case 1:
palette_str.c [1] = palette_str.c [2];
palette_str.c [2] = palette_str.c [4];
palette_str.c [3] = palette_str.c [7];
break;
}
case 1:
palette_str.c [1] = palette_str.c [2];
palette_str.c [2] = palette_str.c [4];
palette_str.c [3] = palette_str.c [7];
break;
}
if ((err = colourtran_select_table
(hdrptr.trfmspritep->sprite.mode, /*source mode*/
lb_bpp < 3? &palette_str.c [0]: NULL, /*source palette*/
-1, /*dest mode*/
(wimp_paletteword *) -1, /*dest palette*/
(sprite_pixtrans *) &pixtrans [0])) != NULL)
reg_set.r [0] = hdrptr.trfmspritep->sprite.mode /*source mode*/;
reg_set.r [1] = lb_bpp < 3? (int) &palette_str.c [0]: -1 /*source palette*/;
/*was NULL. J R C 13th Jun 1995*/
reg_set.r [2] = -1 /*destination mode*/;
reg_set.r [3] = -1 /*destination palette*/;
reg_set.r [4] = (int) pixtrans /*pixel translation table*/;
reg_set.r [5] = 1 << 4 /*return wide entries*/;
#if TRACE
ftracef (__FILE__, __LINE__,
"SWI ColourTrans_GenerateTable, %d, %d, %d, %d, %d, %d\n",
reg_set.r [0], reg_set.r [1], reg_set.r [2],
reg_set.r [3], reg_set.r [4], reg_set.r [5]);
#endif
if ((err = os_swix (ColourTrans_GenerateTable, &reg_set)) != NULL)
return err;
}
......@@ -871,13 +881,13 @@ static os_error *do_objtrfmsprite (draw_objptr hdrptr, draw_objcoord *org)
pixtrans [12], pixtrans [13], pixtrans [14], pixtrans [15]);
#endif
return sprite_put_trans
return sprite_put_trans /*osspriteop_put_sprite_scaled*/
((sprite_area *) 0xFF, /*this op needs no spArea*/
&id, /*pass address of sprite*/
8 | 1 << 6, /*GcolAction=STORE thro mask*/
8 | 1 << 5 | 1 << 6, /*GcolAction=STORE thro mask, wide entries, dithered*/
NULL, /*no box - put whole sprite*/
(sprite_transmat *) mat, /*transformation matrix*/
(sprite_pixtrans *) &pixtrans [0]);
(sprite_pixtrans *) pixtrans);
}
#if TRACE
......@@ -1429,7 +1439,7 @@ os_error *draw_displ_do_objects (diagrec *diag, int offset, int end,
if (width == 0) width = 1;
height = (strlen (e->errmess) + width - 1)/width;
for (i = 0; i < height; i++)
{ bbc_move (x0, y1 - i*32*draw_displ_scalefactor);
{ bbc_move (x0, y1 - (int) (32*(i*draw_displ_scalefactor)));
printf ("%.*s", width, e->errmess + width*i);
}
bbc_gwindow (gw [0], gw [1], gw [2], gw [3]);
......
......@@ -75,6 +75,7 @@
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......@@ -111,7 +112,7 @@
#define strnul(s) ((s) [0] == '\0')
static BOOL Started_Printing; /*used to suppress leading newlines in the
text area. JRC 18 June 1991*/
text area. J R C 18 June 1991*/
static int scaleup (int xx)
......@@ -149,7 +150,7 @@ static draw_usedFont [256];
#define draw_font_vmove 11
#define draw_font_colour 18
#define draw_font_true_colour \
19 /*JRC 22 Nov '89*/
19 /*J R C 22 Nov '89*/
#define draw_font_comment 21
#define draw_font_underline 25
#define draw_font_setfont 26
......@@ -181,10 +182,10 @@ static int lineNum;
static BOOL isSep (int c)
{
#ifdef XTRACE
ftracef0 ("isSep\n");
#endif
return isprint (c) && isspace (c);
#ifdef XTRACE
ftracef0 ("isSep\n");
#endif
return c == ' ' || c == '\t'; /*J R C 24th Jul 1995*/
}
/* Globals used for address and maximum length of current chunk */
......@@ -357,6 +358,100 @@ static int draw_getNum (int from, char *base, int *to, BOOL negative,
} }
}
/*
Function : draw_getFloat
Purpose : get a float out of a string
Parameters : offset into string
pointer to string
pointer to double (NULL -> no assignment)
flag: TRUE if negative numbers are allowed
flag: TRUE if the terminator must be present
OUT : updated offset
Returns : termination code (see below)
Description : skip leading space; read a float; find terminator (if
required). Sets the termination code on the basis of what was
read, as follows:
OK: number read ok, terminator was <spaces>\n or <spaces>/,
or no terminator required. Output pointer is character
after terminator)
BAD: no number could be read, or invalid terminator
MORE: number read ok, terminator was another digit
(output pointer points to digit)
The string is accessed via offsets to avoid flex block
problems.
*/
static int draw_getFloat (int from, char *base, double *to, BOOL negative,
BOOL terminate, int *rest)
{ int r;
double d;
char *end;
#if TRACE
ftracef (__FILE__, __LINE__,
"draw_getFloat (\"%.10s...\"): from %d, to 0x%X, -ve %s, "
"terminate %s, rest 0x%X\n",
&base [from], from, to, whether (negative),
whether (terminate), rest);
#endif
/*Skip leading spaces*/
while (isSep (base [from])) from++;
/*Skip leading minus and digits (and .)*/
if (isdigit (base [from]) || base [from] == '.')
r = from;
else if (negative && base [from] == '-')
r = from + 1;
else
{ ftracef0 ("draw_getFloat -> draw_numBAD\n");
return draw_numBAD;
}
while (isdigit (base [r]) || base [r] == '.') r++;
/*Get the value*/
d = strtod (&base [from], &end);
ftracef1 ("Read %f\n", d);
if (r == from || end == &base [from] || d == HUGE_VAL || d == -HUGE_VAL)
{ ftracef0 ("draw_getFloat -> draw_numBAD\n");
return draw_numBAD;
}
if (to != NULL) *to = d;
if (!terminate)
{ if (base [r] == '/')
/*Termination is allowed, just not compulsory.*/
*rest = r + 1;
else
*rest = r;
ftracef1 ("draw_getFloat -> draw_numOK, next \'%c\'\n",
base [*rest]);
return draw_numOK;
}
else
{ /*Skip trailing spaces*/
while (isSep (base [r])) r++;
if (isdigit (base [r]))
{ *rest = r;
ftracef1 ("draw_getFloat -> draw_numMORE, next \'%c\'\n",
base [*rest]);
return draw_numMORE;
}
else if (isTerm (base [r]))
{ *rest = r + 1;
ftracef1 ("draw_getFloat -> draw_numOK, next \'%c\'\n",
base [*rest]);
return draw_numOK;
}
else
{ ftracef0 ("draw_getFloat -> draw_numBAD\n");
return draw_numBAD;
} }
}
/*
Function : draw_text_setFont
Purpose : locate and record font
......@@ -386,7 +481,8 @@ static char *draw_text_setFont (char *in, font *fonts, BOOL whinge,
draw_usedFont [handle], and return the handle in *handle. Otherwise,
look up the font name in draw_fontcat and return its entry number.*/
{ int fontNumber, end, pointSize, scaleSize, pointWidth, scaleWidth;
{ int fontNumber, end, scaleSize, scaleWidth;
double pointSize, pointWidth;
char *name, displaced;
os_error *err;
font fontHandle;
......@@ -413,10 +509,10 @@ static char *draw_text_setFont (char *in, font *fonts, BOOL whinge,
*in = '\0';
/* Get point size, and maybe width */
ftracef0 ("calling draw_getNum()\n");
if (draw_getNum (1, in, &pointSize, FALSE, TRUE, &end) == draw_numMORE)
{ ftracef0 ("calling draw_getNum() again\n");
draw_getNum (end, in, &pointWidth, FALSE, TRUE, &end);
ftracef0 ("calling draw_getFloat()\n");
if (draw_getFloat (1, in, &pointSize, FALSE, TRUE, &end) == draw_numMORE)
{ ftracef0 ("calling draw_getFloat() again\n");
draw_getFloat (end, in, &pointWidth, FALSE, TRUE, &end);
}
else
pointWidth = pointSize;
......@@ -429,7 +525,7 @@ static char *draw_text_setFont (char *in, font *fonts, BOOL whinge,
else if (fonts != NULL)
{ /*Find sizes at current scaling*/
if (draw_displ_scalefactor == 0.0)
scaleSize = 16*pointSize, scaleWidth = 16*pointWidth;
scaleSize = (int) (16*pointSize), scaleWidth = (int) (16*pointWidth);
else
scaleSize = (int) (16*draw_displ_scalefactor*pointSize),
scaleWidth = (int) (16*draw_displ_scalefactor*pointWidth);
......@@ -472,7 +568,7 @@ static char *draw_text_setFont (char *in, font *fonts, BOOL whinge,
static void draw_text_setColour (int colour, int backcolour)
{ font fonth = 0; /*was -1 JRC 23 Nov '89*/
{ font fonth = 0; /*was -1 J R C 23 Nov '89*/
int offset = 14;
ftracef2 ("draw_text_setColour: colour: 0x%X; backcolour: 0x%X\n",
......@@ -823,32 +919,30 @@ static char *draw_text_getString (char *in, font *fonts,
if (out >= chunkLen) break;
if (*in == '\t') /* tab -> space */
{ /*if (currentFont != -1) No need to check font here. JRC 25 Jan 1990*/
{ /*if (currentFont != -1) No need to check font here. J R C 25 Jan 1990*/
{ chunk [out++] = ' ';
Started_Printing = printing = TRUE;
}
in++;
}
else if (*in == '\n')
{ if (currentFont == -1 || !Started_Printing)
{ in++;
if (currentFont != -1 && Started_Printing)
/*Skip newlines before first valid font - or if not printing yet
JRC 24 Jan 1990*/
in++;
else
{ /*Newline - paragraph break if either followed by another
newline. Used to be also if it was the first printable
character, but that can't happen now. JRC 24 Jan 1990*/
if (!printing || *++in == '\n')
J R C 24 Jan 1990*/
{ if (!printing || *in == '\n' || isSep (*in))
/*Newline-space also starts a new paragraph. J R C 24th Jul 1995*/
{ /* Paragraph termination */
chunk [out++] = '\n';
in++;
if (*in == '\n') in++; /*Do not skip over a space, if it was
one. J R C 24th Jul 1995*/
getOut = TRUE;
}
else
{ /*Newline not preceded or followed by a space generates a space*/
if (!isSep (chunk [out - 1]) && !isSep (*in) && *in != '\t')
/*Newline not preceded or followed by a space generates a space*/
if (!(isSep (chunk [out - 1]) || isSep (*in)))
chunk [out++] = ' ';
} } }
} }
else if (*in < ' ')
/* skip control character */
in++;
......@@ -863,7 +957,7 @@ static char *draw_text_getString (char *in, font *fonts,
else /* \ -> special sequence */
{ switch (*++in)
{ case '\\': /* \\ : replace by \ */
if (TRUE /*currentFont != -1 JRC*/)
if (TRUE /*currentFont != -1 J R C*/)
{ chunk [out++] = '\\';
Started_Printing = printing = TRUE;
}
......@@ -1151,7 +1245,7 @@ static int draw_text_getLine (int offset, os_error **error, int width,
i += 4;
break;
case draw_font_true_colour: /*JRC 22 Nov '89*/
case draw_font_true_colour: /*J R C 22 Nov '89*/
i += 8;
break;
......@@ -1352,7 +1446,7 @@ static int draw_text_paintCheck (int offset, int y, /*draw_bboxtyp *clip,*/
t += 4;
break;
case draw_font_true_colour: /*JRC 22 Nov '89*/
case draw_font_true_colour: /*J R C 22 Nov '89*/
draw_text_setColour
( chunk [t + 4] << 8 | chunk [t + 5] << 16 | chunk [t + 6] << 24,
chunk [t + 1] << 8 | chunk [t + 2] << 16 | chunk [t + 3] << 24
......@@ -1517,7 +1611,7 @@ static void draw_text_stateScan (char *chunk, int start, int end,
case draw_font_true_colour:
c += 7;
break; /*JRC 22 Nov '89*/
break; /*J R C 22 Nov '89*/
case draw_font_vmove:
{ int move = chunk [c] | chunk [c + 1] << 8 | chunk [c + 2] << 16;
......@@ -1919,12 +2013,12 @@ BOOL draw_text_verifyTextArea (char *text, int length, int *columns,
return FALSE;
}
ftracef0 ("calling draw_getNum()\n");
if ((sizeTerm = draw_getNum (0, text, NULL, FALSE, TRUE, &i)) ==
ftracef0 ("calling draw_getFloat()\n");
if ((sizeTerm = draw_getFloat (0, text, NULL, FALSE, TRUE, &i)) ==
draw_numMORE)
{ /* Read second number */
ftracef0 ("calling draw_getNum()\n");
if (draw_getNum (i, text, NULL, FALSE, TRUE, &i) != draw_numOK)
ftracef0 ("calling draw_getFloat()\n");
if (draw_getFloat (i, text, NULL, FALSE, TRUE, &i) != draw_numOK)
{ draw_report ("TextF3", 0);
return FALSE;
}
......@@ -1997,7 +2091,7 @@ BOOL draw_text_verifyTextArea (char *text, int length, int *columns,
}
if (*++text == '/') text++;
#else
/*JRC 20 June 1991 allow any number here*/
/*J R C 20 June 1991 allow any number here*/
{ int i;
ftracef0 ("calling draw_getNum()\n");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment