Esempio n. 1
0
void
RPL_Push(DWORD n)
{
	DWORD stkp, avmem;

	avmem = Read5(AVMEM);					// amount of free memory
	if (avmem==0) return;					// no memory free
	avmem--;
	// fetch memory
	Write5(AVMEM,avmem);					// save new amount of free memory
	stkp = Read5(DSKTOP);					// get pointer to stack level 1
# if 0
	if (METAKERNEL)							// Metakernel running ?
	{
		
		Write5(stkp-5,Read5(stkp));			// copy object pointer of stack level 1 to new stack level 1 entry
		Write5(stkp,n);						// save pointer to new object on stack level 2
		stkp-=5;							// fetch new stack entry
	}
	else
# else
	{
		stkp-=5;							// fetch new stack entry
		Write5(stkp,n);						// save pointer to new object on stack level 1
	}
# endif
	Write5(DSKTOP,stkp);					// save new pointer to stack level 1
	return;
}
Esempio n. 2
0
DWORD 
RPL_CreateTemp(DWORD l)
{
	DWORD a, b, c;
	BYTE *p;

	l += 6;									// memory for link field (5) + marker (1) and end
	a = Read5(TEMPTOP);						// tail address of top object
	b = Read5(RSKTOP);						// tail address of rtn stack
	c = Read5(DSKTOP);						// top of data stack
	if ((b+l)>c) return 0;					// check if there's enough memory to move DSKTOP
	Write5(TEMPTOP, a+l);					// adjust new end of top object
	Write5(RSKTOP,  b+l);					// adjust new end of rtn stack
	Write5(AVMEM, (c-b-l)/5);				// calculate free memory (*5 nibbles)
	p = (BYTE *)malloc(b-a);				
  memset(p,0,b-a);
	Npeek(p,a,b-a);
	Nwrite(p,a+l,b-a);
	free(p);
	Write5(a+l-5,l);						// set object length field
	return (a+1);							// return base address of new object
}
bool BilinearScalerInternal_2x(SDL_Surface *tex, sint32 sx, sint32 sy, sint32 sw, sint32 sh,
                               uint8 *pixel, sint32 dw, sint32 dh, sint32 pitch, bool clamp_src) {
	ignore_unused_variable_warning(dh);
	// Source buffer pointers
	int tpitch = tex->pitch / sizeof(uintS);
	uintS *texel = reinterpret_cast<uintS *>(tex->pixels) + (sy * tpitch + sx);
	uintS *tline_end = texel + (sw - 1);
	uintS *tex_end = texel + (sh - 4) * tpitch;
	int tex_diff = (tpitch * 4) - sw;

	uint8 a[4], b[4], c[4], d[4], e[4], f[4], g[4], h[4], i[4], j[4];
	int p_diff    = (pitch * 8) - (dw * sizeof(uintX));

	bool clip_x = true;
	if (sw + sx < tpitch && clamp_src == false) {
		clip_x = false;
		tline_end = texel + (sw + 1);
		tex_diff--;
	}

	bool clip_y = true;
	if (sh + sy < tex->h && clamp_src == false) {
		clip_y = false;
		tex_end = texel + (sh) * tpitch;
	}

	// Src Loop Y
	do {
		Read5(a, b, c, d, e);
		texel++;

		// Src Loop X
		do {
			Read5(f, g, h, i, j);
			texel++;

			ScalePixel2x(a, b, f, g);
			ScalePixel2x(b, c, g, h);
			ScalePixel2x(c, d, h, i);
			ScalePixel2x(d, e, i, j);

			pixel -= pitch * 8;
			pixel += sizeof(uintX) * 2;

			Read5(a, b, c, d, e);
			texel++;

			ScalePixel2x(f, g, a, b);
			ScalePixel2x(g, h, b, c);
			ScalePixel2x(h, i, c, d);
			ScalePixel2x(i, j, d, e);

			pixel -= pitch * 8;
			pixel += sizeof(uintX) * 2;

		} while (texel != tline_end);

		// Final X (clipping)
		if (clip_x) {
			Read5(f, g, h, i, j);
			texel++;

			ScalePixel2x(a, b, f, g);
			ScalePixel2x(b, c, g, h);
			ScalePixel2x(c, d, h, i);
			ScalePixel2x(d, e, i, j);

			pixel -= pitch * 8;
			pixel += sizeof(uintX) * 2;

			ScalePixel2x(f, g, f, g);
			ScalePixel2x(g, h, g, h);
			ScalePixel2x(h, i, h, i);
			ScalePixel2x(i, j, i, j);

			pixel -= pitch * 8;
			pixel += sizeof(uintX) * 2;
		};

		pixel  += p_diff;

		texel += tex_diff;
		tline_end += tpitch * 4;
	} while (texel != tex_end);

	//
	// Final Rows - Clipping
	//

	// Src Loop Y
	if (clip_y) {
		Read5_Clipped(a, b, c, d, e);
		texel++;

		// Src Loop X
		do {
			Read5_Clipped(f, g, h, i, j);
			texel++;
			ScalePixel2x(a, b, f, g);
			ScalePixel2x(b, c, g, h);
			ScalePixel2x(c, d, h, i);
			ScalePixel2x(d, e, i, j);
			pixel -= pitch * 8;
			pixel += sizeof(uintX) * 2;

			Read5_Clipped(a, b, c, d, e);
			texel++;
			ScalePixel2x(f, g, a, b);
			ScalePixel2x(g, h, b, c);
			ScalePixel2x(h, i, c, d);
			ScalePixel2x(i, j, d, e);
			pixel -= pitch * 8;
			pixel += sizeof(uintX) * 2;
		} while (texel != tline_end);

		// Final X (clipping)
		if (clip_x) {
			Read5_Clipped(f, g, h, i, j);
			texel++;

			ScalePixel2x(a, b, f, g);
			ScalePixel2x(b, c, g, h);
			ScalePixel2x(c, d, h, i);
			ScalePixel2x(d, e, i, j);

			pixel -= pitch * 8;
			pixel += sizeof(uintX) * 2;

			ScalePixel2x(f, g, f, g);
			ScalePixel2x(g, h, g, h);
			ScalePixel2x(h, i, h, i);
			ScalePixel2x(i, j, i, j);

			pixel -= pitch * 8;
			pixel += sizeof(uintX) * 2;
		};

		pixel  += p_diff;

		texel += tex_diff;
		tline_end += tpitch * 4;
	}

	return true;
}