コード例 #1
0
ファイル: spline.c プロジェクト: AnimatorPro/Animator-Pro
/* of interpreted points to generate.				   */
static int
s_spline(Poly *poly, Vector dotout, Vector vecout, int closed, int ir,
		Poly *filledp)
{
fpoint *newx, *newy;
int ptcount;
LLpoint *p;
int i;

ptcount = poly->pt_count;
if ((newx = begmem(ptcount*sizeof(fpoint) )) == NULL)
	return(0);
if ((newy = begmem(ptcount*sizeof(fpoint) )) == NULL)
	{
	freemem(newx);
	return(0);
	}
p = poly->clipped_list;
for (i=0; i<ptcount; i++)
	{
	newx[i] = FVAL(p->x);
	newy[i] = FVAL(p->y);
	p = p->next;
	}
if (alloc_spline_tab(ptcount))
	{
	do_spline(newx,newy,ptcount,ir,closed,
		dotout,vecout, filledp);
	free_spline_tab();
	}
freemem(newx);
freemem(newy);
return(1);
}
コード例 #2
0
ファイル: spiral.c プロジェクト: AnimatorPro/Animator-Pro
static int
make_spiral_poly(int x0, int y0, int rad, int itheta, long ttheta)
{
int i;
register int ppoints;
register LLpoint *next;

poly_nopoints(&working_poly);
ppoints = 32*(ttheta/TWOPI);
ppoints = intabs(ppoints);
ppoints += 32;
working_poly.pt_count = ppoints+1;
for (i=0; i<=ppoints; i++)
	{
	if ((next = begmem(sizeof(*next))) == NULL)
		{
		poly_nopoints(&working_poly);
		return(0);
		}
	next->next = working_poly.clipped_list;
	working_poly.clipped_list = next;
	polar((int)((long)itheta + 
		((long)ttheta*i+ppoints/2)/ppoints),
		(int)(((long)rad*i+ppoints/2)/ppoints),
		&next->x);
	next->x += x0;
	next->y += y0;
	}
poly_last_point(&working_poly)->next = working_poly.clipped_list;
working_poly.closed = 0;
return(1);
}
コード例 #3
0
ファイル: fli.c プロジェクト: AnimatorPro/Animator-Pro
Errcode unfli(Rcel *f, /* screen to update */
		 int ix,	/* which frame of file to read */
		 int wait)	/* wait for vblank (and update hardward color registers)? */

/* allocate a buffer to read in a compressed delta frame from FLX (indexed
   FLI) file.  If can't allocate buffer go swap out everything we can 
   and try again.  Once got the buffer call above routine to read in 
   frame and eventually uncompress it. */
{
struct fli_frame *frame;	/* buffer area */
Errcode err;
long size;
int pushed = 0;

	size = flix.idx[ix].fsize;
	if((frame = pj_malloc(Max(size,sizeof(Fli_frame)))) == NULL)
	{
		pushed = 1;
		push_most();
		if ((frame = begmem(size)) == NULL)
		{
			err = Err_reported;
			goto OUT;
		}
	}
	err = gb_unfli_flx_frame(&flix,f, ix, wait, frame);

OUT:
	pj_gentle_free(frame);
	if (pushed)
		pop_most();
	return(err);
}
コード例 #4
0
ファイル: pocolibs.c プロジェクト: AnimatorPro/Animator-Pro
Errcode po_arrays_to_poly(Poly *p, int ptcount, Popot *px, Popot *py)
/*****************************************************************************
 * This creates a Poly quickly from Poco array representation.
 * However this poly needs to be disposed with free(p->clipped_list)
 * rather than freeing each point individually.
 ****************************************************************************/
{
	LLpoint *list;
	int i;
	int *x;
	int *y;
	Errcode err;

	if ((err = po_2_arrays_check(ptcount, px, py)) < Success)
		return err;
	x = px->pt;
	y = py->pt;
	if((list = p->clipped_list = begmem(ptcount * sizeof(LLpoint))) == NULL)
		return(Err_no_memory);
	i = p->pt_count = ptcount;
	while (--i >= 0)
		{
		list->x = *x++;
		list->y = *y++;
		list++;
		}
	p->polymagic = POLYMAGIC;
	linkup_poly(p);
	return(Success);
}
コード例 #5
0
ファイル: stubs2.c プロジェクト: AnimatorPro/Animator-Pro
make_bhash()
{
flush_dither_err();
if ((bhash = begmem(BSIZ)) != NULL)
	{
	zero_structure(bhash, BSIZ);
	return(1);
	}
else
	return(0);
}
コード例 #6
0
void add_sub_file(char *name)
/******************************************************************
 * Add a file to the list of files to do substitutions on.
 ******************************************************************/
{
Name *n;

n = begmem(sizeof(*n));
n->name = clone_string(name);
n->next = plist;
plist = n;
}
コード例 #7
0
char *clone_string(char *n)
/******************************************************************
 * Make a duplicate of a string on the heap.
 ******************************************************************/
{
int len;
char *d;

len = strlen(n);
d = begmem(len+1);
strcpy(d,n);
return(d);
}
コード例 #8
0
void sub_file(char *t)
/******************************************************************
 * Do our substitutions on a single file.
 ******************************************************************/
{
Name *ll, *n;
FILE *sfile;

sfile = must_open(t, "r");
printf("Subbing %s\n", t);
ll = NULL;
llcount = 0;
ltitle = t;
dirty = FALSE;
for (;;)
	{
	if (fgets(b1, sizeof(b1)-1, sfile) == NULL)
		break;
	if (embedded)
		embedded_subline();
	else
		csym_subline();
	n = begmem(sizeof(*n));
	n->name = clone_string(b2);
	n->next = ll;
	ll = n;
	llcount += 1;
	}
fclose(sfile);
if (dirty && writeit)
	{
	printf("saving new %s\n", t);
	ll = reverse_list(ll);
	n = ll;
	if (backup)
		backitup(t);
	sfile = must_open(t, "w");
	while (n != NULL)
		{
		fputs(n->name, sfile);
		n = n->next;
		}
	fclose(sfile);
	}
free_names(ll);
}
コード例 #9
0
ファイル: TRUECOLO.C プロジェクト: Breton/Animator-Pro
static
make_glow()
{
int i;
UBYTE *bun, c, c1;

if ((glow_lookup = begmem(COLORS))== NULL)
	return(0);
for (i=0;i<COLORS;i++)
	glow_lookup[i]=i;
i = vs.buns[vs.use_bun].bun_count;
bun = vs.buns[vs.use_bun].bundle;
c1 = *bun;
while (--i > 0)
	{
	c = *bun++;
	glow_lookup[c] = *bun;
	}
glow_lookup[*bun] = c1;
return(1);
}
コード例 #10
0
ファイル: vision.c プロジェクト: AnimatorPro/Animator-Pro
open_verify_vision()
{
int i;

if ((bopen(vision_name, &vision_bf)) == 0)
	{
	cant_find(vision_name);
	return(0);
	}
if (bread(&vision_bf, &vh, sizeof(vh)) <
	sizeof(vh))
	{
	vitrunc();
	return(0);
	}
linebytes = VWID;
switch (vh.imgdata.pixsiz)
	{
	case 16:
		bap = 2;
		break;
	case 24:
		bap = 3;
		break;
	case 32:
		bap = 4;
		break;
	default:
		continu_box(not_vision_lines);
		return(0);
	}
linebytes *= bap;
switch (vh.imgtype)
    {
	case 2:             /* uncompressed */
		is_compressed = 0;
		break;
	case 10:
		is_compressed = 1;
		break;
	default:
		continu_line(vision_103 /* "Unknown compression type" */);
		return(0);
	}
if ((vh.imgdata.imgdesc & INLEAVE) != 0)
	{
	continu_line(vision_104 /* "Sorry, can't deal with Interleave" */);
	return(0);
	}
if ((buf = lbegmem(linebytes + 130*bap)) == NULL)
	return(0);
over = buf + linebytes;	/* extra at end to make decompression easier */
for (i=0; i<3; i++)
	{
	if ((rgb_bufs[i] = begmem(VWID)) == NULL)
		return(0);
	}
is_flipped = !((vh.imgdata.imgdesc&SCRORG) == SCRORG);
if ((pic_cel = alloc_cel(VWID, vh.imgdata.height,
	vh.imgdata.xorg, vh.imgdata.yorg)) == NULL)
	return(0);
vstart = pic_cel->p;
vnext = pic_cel->bpr;
if (is_flipped)
	{
	vstart = long_to_pt(
		pt_to_long(vstart) + vnext * (vh.imgdata.height-1));
	vnext = -vnext;
	}
data_offset = vh.idlength + sizeof(vh);
if (vh.maptype != 0)
	data_offset += ((vh.cms.mapbits+7)/8)*vh.cms.maplen;
return(1);
}
コード例 #11
0
ファイル: VIP.C プロジェクト: Breton/Animator-Pro
void *load_exe(char *filename, Exe_head *eh)
{
long retval;
char *alligned_buf;
char *alloc_buf = NULL;
long (*rfunc)();
unsigned long code_offset;
unsigned long init_size;
unsigned long bss_size;
unsigned long total_size;
void *v;
unsigned long fixup_offset;
UWORD fixup[2];
UWORD *segpt;
UWORD code_seg;
int f;
unsigned i;
int ok = 0;

if ((f = jopen(filename, JREADONLY)) == 0)
	{
	cant_find(filename);
	return(NULL);
	}
if (!verify_exe_head(f, eh))
	goto OUT;
code_offset = eh->head_size;
code_offset *= 16;	/* make it a paragraph */
init_size = eh->blocks;
init_size *= 512;
init_size += eh->mod512;
if (eh->mod512 != 0)
	init_size -= 512;
init_size -= code_offset;
bss_size = eh->min_data;
bss_size *= 16;
total_size = init_size + bss_size;
if ((alloc_buf = begmem((unsigned)total_size+16)) == NULL)
	goto OUT;
code_seg = ptr_seg(alloc_buf) + 1;
alligned_buf = make_ptr(0, code_seg);
zero_structure(alligned_buf, (unsigned)total_size);
jseek(f, code_offset, JSEEK_START);
if (jread(f, alligned_buf, init_size) < init_size)
	{
	truncated(filename);
	goto OUT;
	}
v = alligned_buf;
eh->entry_point = v;
if (eh->reloc_count > 0)
	{
	fixup_offset = eh->reloc_list;
	jseek(f, fixup_offset, JSEEK_START);
	for (i=0; i<eh->reloc_count; i++)
		{
		if (jread(f, fixup, sizeof(fixup)) != sizeof(fixup))
			{
			truncated(filename);
			goto OUT;
			}
		segpt = make_ptr(fixup[0], code_seg + fixup[1]);
		segpt[0] += code_seg;
		}
	}
ok = 1;
OUT:
if (!ok)
	{
	gentle_freemem(alloc_buf);
	alloc_buf = NULL;
	}
jclose(f);
return(alloc_buf);
}
コード例 #12
0
void build_sub_file(char *sname, Boolean embed)
/******************************************************************
 * go look for lines of format :
 *		in|out
 * to tell us what to substitute
 *		in|
 * is ok if embed is false, and will delete all ins.
 *
 * if embed is true, we'll skip all white space.
 *
 ******************************************************************/
{
FILE *sfile;
int line;
char buf[256];
char *s;
char word1[256];
char word2[256];
char *d;
char c;
Sub *sub;

sfile = must_open(sname, "r");
line = 0;
for (;;)
	{
	if (fgets(buf, sizeof(buf)-1, sfile) == NULL)
		break;
	line++;
	s = buf;
	if (!embed)	
		s = skip_space(s);
	d = word1;
	for (;;)
		{
		c = *s++;
		if (c == 0)
			{
			fatal("%s %d - Line with no separator", sname, line);
			}
		if (!embed)
			{
			if (isspace(c))
				break;
			}
		else if (c == separator)
			break;
		*d++ = c;
		}
	*d++ = 0;
	d = word2;
	if (!embed)	
		s = skip_space(s);
	for (;;)
		{
		c = *s++;
		if (!embed)
			{
			if (isspace(c) || c == 0)
				break;
			}
		else
			{
			if (c == 0 || c == '\r' || c == '\n')
				break;
			}
		*d++ = c;
		}
	*d++ = 0;
	if (!embed && (word2[0] == 0))
		fatal("%s %d - Line with no substitution", sname, line);
	sub = begmem(sizeof(*sub));
	sub->in = clone_string(word1);
	sub->insize = strlen(word1);
	sub->out = clone_string(word2);
	sub->outsize = strlen(word2);
	add_hash(global_hash, sub);
	}
fclose(sfile);
}
コード例 #13
0
ファイル: SAVEFLI.C プロジェクト: AnimatorPro/Animator-Pro
Errcode sub_cur_frame(void)
/* returns frame index left in undo buffer errcode if not possible */
{
Errcode err;
int pushed = 0;
int unzoomed = 0;
long cbufsz;
Fli_frame *cbuf;
Fli_frame *cbuf2;
void *alloc2;
SHORT undoix;
Boolean overwrite;
Flx ocurflx;

	if (!flix.fd)
		return(Err_bad_input);

	flx_clear_olays(); /* undraw cels cursors etc */

	if (vs.frame_ix == vs.bframe_ix)	/* mark buffer frame as no good */
		vs.bframe_ix = 0;
	/* grovel for memory... freeing up more and more ... */

	cbufsz = pj_fli_cbuf_size(vb.pencel->width,vb.pencel->height,
					   vb.pencel->cmap->num_colors);

	if ((cbuf = pj_malloc(cbufsz)) == NULL)
	{
		unzoomed = 1;
		unzoom();
		if ((cbuf = pj_malloc(cbufsz)) == NULL)
		{
			pushed = 1;
			push_most();
			if ((cbuf = begmem(cbufsz)) == NULL)
			{
				err = Err_reported;
				goto error;
			}
		}
	}

	/* put old frame 0 in undo buffer if not compressing the one and 
	 * only first frame */

	if(flix.hdr.frame_count != 1)
	{
		if ((err = gb_unfli(undof,0,0,cbuf)) < 0)
			goto error;
	}

	overwrite = TRUE; /* allow current record to be overwritten unless
					   * we find we can't allocate buffers etc */

	if(vs.frame_ix == 0)
	{
		undoix = 0;
		pj_fli_comp_frame1(cbuf,vb.pencel,flix.comp_type);
		if((err = write_flx_frame(&flix,0,cbuf))<0)
			goto error;
		if(flix.hdr.frame_count == 1)
		{
			save_undo();
			undoix = 0;
			goto done;
		}
	}
	else
	{
		/* seek to frame before and compress current delta */
		if(vs.frame_ix > 1)
		{
			if ((err = gb_fli_tseek(undof,0,vs.frame_ix-1, cbuf)) < 0)
				goto error;
		}
		ocurflx = flix.idx[vs.frame_ix];
		if(ocurflx.fsize == 0)
			ocurflx.fsize = sizeof(Fli_frame);

		pj_fli_comp_cel(cbuf,undof,vb.pencel,COMP_DELTA_FRAME,flix.comp_type);

		if((cbufsz - cbuf->size) >= ocurflx.fsize)
		{
			cbuf2 = OPTR(cbuf,cbuf->size);
			alloc2 = NULL;
		}
		else 
		{
			if((alloc2 = pj_malloc(ocurflx.fsize)) == NULL)
				overwrite = FALSE;
			cbuf2 = alloc2;
		}
		if(overwrite) /* unfli old frame via cbuf2 we may overwrite it */
		{
			err = gb_unfli(undof,vs.frame_ix,0,cbuf2);
			pj_freez(&alloc2); /* get rid of any alloc'd buffers */
			if(err < Success)
				goto error;
		}

		if(cbuf->size <= sizeof(Fli_frame))
			cbuf->size = 0;

		if((err = make_flx_record(&flix,vs.frame_ix,
								  cbuf,cbuf->size,overwrite)) < 0)
		{
			goto error;
		}

		/* re read old record from its old file slot */
		if(!overwrite && ocurflx.fsize > sizeof(Fli_frame))
		{
			if((err = pj_readoset(flix.fd,cbuf,ocurflx.foff,ocurflx.fsize))<0)
				goto error;
			if(cbuf->type != FCID_FRAME)
			{
				err = Err_bad_magic;
				goto error;
			}
			pj_fli_uncomp_frame(undof,cbuf,0);
		}
	}

	/* unfli to next frame */
	undoix = vs.frame_ix+1;
	if((err = gb_unfli(undof,undoix,0,cbuf)) < 0)
		goto error;

	pj_fli_comp_cel(cbuf,vb.pencel,undof,COMP_DELTA_FRAME,flix.comp_type);

	if((err = write_flx_frame(&flix,undoix,cbuf)) < 0)
		goto error;

	/* possibly have to update last loop frame if changing first frame 
	 * and more than one frame in fli */

	if(vs.frame_ix == 0)
	{
		/* advance undo to last frame in file */
		if((err = gb_fli_tseek(undof,undoix,flix.hdr.frame_count-1,cbuf))<0)
			goto error;
		undoix = flix.hdr.frame_count-1;
		pj_fli_comp_cel(cbuf,undof,vb.pencel,COMP_DELTA_FRAME,flix.comp_type);
		if((err = write_flx_frame(&flix,flix.hdr.frame_count,cbuf)) < 0)
			goto error;
	}

done:
	flush_tflx();
	err = wrap_frame(undoix);
error:
	pj_gentle_free(cbuf);
	if (pushed)
		pop_most();
	if (unzoomed)
		rezoom();
	flx_draw_olays(); /* restore cels and such */
	return(err);
}