Commit 6e778458 authored by Robert Sprowson's avatar Robert Sprowson

Use some constants from headers

While investigating SprExtend-1_69, tidied up JPEGprint a bit.
Binary unchanged, not tagged.
parent 0d41cfbb
......@@ -83,6 +83,7 @@
#include <ctype.h>
#include "kernel.h"
#include "Global/FileTypes.h"
#if Debug
# include "alarm.h"
......@@ -127,9 +128,6 @@
#define DeclareFontFlag (1<<29) /* in PDriver_Info features word */
#define DrawPageFlags (1<<13) /* in PDriver_Info features word */
#define SpriteFileType 0xff9
#define JPEGFileType 0xc85
/* avoid code-breaking scale for very small pictures */
#define AbsoluteMaxScale 100
......@@ -281,7 +279,7 @@ static void check_JPEG_support(void)
regs.r[1] = (int)"JPEG_Info";
error = _kernel_swi(OS_SWINumberFromString, &regs, &regs);
if (error) internal_give_up("MJSOSPX:You need SpriteExtend 0.75 or "
"later to print JPEG's directly",(char *)0);
"later to print JPEG's directly",NULL);
}
/* ------------------------------------------------------------------------ */
......@@ -438,7 +436,7 @@ static void set_translation_table(sprite_t *sp)
else
{
sp->sptrans = malloc(regs.r[4]);
if (sp->sptrans == NULL) internal_give_up("NoMem",(char *)0);
if (sp->sptrans == NULL) internal_give_up("NoMem",NULL);
regs.r[4] = (int)sp->sptrans; /* generate table in sized buffer */
swi(ColourTrans_GenerateTable,&regs);
}
......@@ -477,12 +475,12 @@ static int read_sprite(char *fname, imagerec_t *im)
regs.r[1] = (int)fname;
swi(OS_File,&regs);
if (regs.r[0] == 0) internal_give_up("NoFile",fname);
if (regs.r[6] != SpriteFileType) return 0;
if (regs.r[6] != FileType_Sprite) return 0;
im->image_type = SpriteFileType;
im->image_type = FileType_Sprite;
im->image.sprite.SpSize = regs.r[4] + 4; /* size of area = filesize + 4 */
im->image.sprite.spbuff = malloc(im->image.sprite.SpSize);
if (im->image.sprite.spbuff == NULL) internal_give_up("NoMem",(char *)0);
if (im->image.sprite.spbuff == NULL) internal_give_up("NoMem",NULL);
#if Debug
tprintf("sprite file size = %1d\n",regs.r[4]);
#endif
......@@ -575,7 +573,7 @@ static void prime_spriteextend(jpeg_t *jp)
#endif
sparea = malloc(512); /* plenty for 8x8 32 bit Sprite */
if (sparea == NULL) internal_give_up("NoMem",(char *)0);
if (sparea == NULL) internal_give_up("NoMem",NULL);
sparea[0] = 512; /* size */
sparea[2] = 16;
......@@ -624,12 +622,12 @@ static int read_jpeg(char *fname, imagerec_t *im)
regs.r[1] = (int)fname;
swi(OS_File,&regs);
if (regs.r[0] == 0) internal_give_up("NoFile",fname);
if (regs.r[6] != JPEGFileType) return 0;
if (regs.r[6] != FileType_JPEG) return 0;
im->image_type = JPEGFileType;
im->image_type = FileType_JPEG;
im->image.jpeg.JPSize = regs.r[4]; /* size of area required */
im->image.jpeg.jpbuff = malloc(im->image.jpeg.JPSize);
if (im->image.jpeg.jpbuff == NULL) internal_give_up("NoMem",(char *)0);
if (im->image.jpeg.jpbuff == NULL) internal_give_up("NoMem",NULL);
#if Debug
tprintf("jpeg file size = %1d\n",regs.r[4]);
#endif
......@@ -727,7 +725,6 @@ static void plot_jpeg(jpeg_t *jp, int scale[4])
{
_kernel_swi_regs regs;
regs.r[0] = (int)jp->jpbuff;
regs.r[1] = 0; /* x coord */
regs.r[2] = 0; /* y coord */
......@@ -881,7 +878,7 @@ static void decide_printrec(int centred, char orientation, int max_scale,
width = margins[2] - margins[0];
height = margins[3] - margins[1];
if ((width < 7200) || (height < 7200))
internal_give_up("MJSPATS:printable area too small",(char *)0);
internal_give_up("MJSPATS:printable area too small",NULL);
}
/* safety margin means we don't risk clipping the image slightly */
......@@ -1105,10 +1102,10 @@ static void handle_print(imagerec_t *im)
only_counting = (more & 0x1000000) != 0;
switch(im->image_type)
{
case JPEGFileType:
case FileType_JPEG:
plot_jpeg(&(im->image.jpeg),im->scale);
break;
case SpriteFileType:
case FileType_Sprite:
plot_sprite(&(im->image.sprite),im->scale, only_counting);
break;
}
......@@ -1148,7 +1145,7 @@ static void set_options(int *centred, int *max_scale, char *orientation)
{
regs.r[0] = (int)"JPEGprint$Options";
regs.r[1] = (int)buff;
regs.r[2] = 256; /* read it (256 = size of buff) */
regs.r[2] = sizeof(buff);
regs.r[3] = 0;
regs.r[4] = 3;
swi(OS_ReadVarVal,&regs);
......@@ -1208,7 +1205,7 @@ int main(int argc, char *argv[])
check_JPEG_support();
if (argc != 2) internal_give_up("BadParm",(char *)0);
if (argc != 2) internal_give_up("BadParm",NULL);
set_options(&centred, &max_scale, &orientation);
......@@ -1227,7 +1224,7 @@ int main(int argc, char *argv[])
if (!read_jpeg(argv[argc-1], &imagerec) &&
!read_sprite(argv[argc-1], &imagerec) )
internal_give_up("MJSCPFT:cannot print file of this type",(char *)0);
internal_give_up("MJSCPFT:cannot print file of this type",NULL);
decide_printrec(centred, orientation, max_scale, &imagerec, &printrec);
......
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