rem: MaskFrame = pSolarSysState->PlanetFrameArray[offset];
add: MaskFrame = SetAbsFrameIndex (pSolarSysState->PlanetFrameArray, (COUNT)(offset + 1));
context: RenderLevelMasks (int offset){	POINT pt;	DWORD **rgba;	int x, y;	DWORD p, **pixels;	FRAME MaskFrame;#if PROFILE	static clock_t t = 0;	static int frames_done = 1;	clock_t t1;	t1 = clock ();#endif	rgba = HMalloc (sizeof (DWORD *) * (DIAMETER));	// Choose the correct Frame to wrte to	MaskFrame = pSolarSysState->PlanetFrameArray[offset];	pixels = pSolarSysState->lpTopoMap;	for (pt.y = 0, y = -RADIUS; pt.y <= TWORADIUS; ++pt.y, ++y)	{		rgba[pt.y] = HCalloc (sizeof (DWORD) * (DIAMETER));		for (pt.x = 0,  x = -RADIUS; pt.x <= TWORADIUS; ++pt.x, ++x)		{			UBYTE c[3];			int ph;			COUNT i;			DWORD p1[4];			MAP3D_POINT *ppt = &map_rotate[pt.y][pt.x];			ph = phong[pt.y][pt.x];			if (ph < 1 << PHONG_BITS)			{				if (ppt->m[0] == 0) 				{					p = pixels[ppt->p[0].y][ppt->p[0].x + offset];					c[0] = (UBYTE)(p >> 8);					c[1] = (UBYTE)(p >> 16);					c[2] = (UBYTE)(p >> 24);				} 				else				{					for (i = 0; i < 4; i++)						p1[i]=pixels[ppt->p[i].y][ppt->p[i].x + offset];					for (i = 1; i < 4; i++)						c[i-1] = get_avg_rgb (p1, ppt->m, i);				}			// Apply the lightinng model.  This also bounds the sphere to make it circular				if (pSolarSysState->ShieldFrame)				{					c[2] = GET_PHONG (255, ph);					c[1] = GET_PHONG (c[1] >> 1, ph);					c[0] = GET_PHONG (c[0] >> 1, ph);				} 				else				{					c[2] = GET_PHONG (c[2], ph);					c[1] = GET_PHONG (c[1], ph);					c[0] = GET_PHONG (c[0], ph);				}				rgba[pt.y][pt.x] = frame_mapRGBA (					MaskFrame, c[2], c[1], c[0], (UBYTE)255);			} 			else				rgba[pt.y][pt.x] = frame_mapRGBA (MaskFrame, 0, 0, 0, 0);		}	}	// Map the rgb bitmap onto the SDL_Surface	process_rgb_bmp (pSolarSysState->PlanetFrameArray[offset], rgba, DIAMETER, DIAMETER);	SetFrameHot (MaskFrame, MAKE_HOT_SPOT (RADIUS + 1, RADIUS + 1));	for (pt.y = 0; pt.y <= TWORADIUS; ++pt.y)		HFree (rgba[pt.y]);	HFree(rgba);#if PROFILE	t += clock() - t1;	if (frames_done == MAP_WIDTH)	{		fprintf (stderr, "frames/sec: %d/%d(msec)=%f\n", frames_done, t,			frames_done / ((double)t / CLOCKS_PER_SEC));		frames_done = 1;		t = clock () - t1;	}	else		frames_done++;#endif}