static void mark_sprites_colors()
	{
		int offs,color,i,pal_base;
		int[] colmask=new int[16];
                int[] pen_usage; /* Save some struct derefs */
	
		/* Sprites */
		pal_base = Machine.drv.gfxdecodeinfo[4].color_codes_start;
		pen_usage=Machine.gfx[4].pen_usage;
		for (color = 0;color < 16;color++) colmask[color] = 0;
	
		for (offs = 0;offs < 0x800;offs += 8)
		{
			int x,y,sprite,multi;
	
			sprite = cninja_spriteram.READ_WORD(offs+2) & spritemask;
			if (sprite==0) continue;
	
			x = cninja_spriteram.READ_WORD(offs+4);
			y = cninja_spriteram.READ_WORD(offs);
	
			color = (x >> 9) &0xf;
			multi = (1 << ((y & 0x0600) >> 9)) - 1;
			sprite &= ~multi;
	
			/* Save palette by missing offscreen sprites */
			x = x & 0x01ff;
			y = y & 0x01ff;
			if (x >= 256) x -= 512;
			x = 240 - x;
			if (x>256) continue;
	
			while (multi >= 0)
			{
				colmask[color] |= pen_usage[sprite + multi];
				multi--;
			}
		}
	
		for (color = 0;color < 16;color++)
		{
			for (i = 1;i < 16;i++)
			{
				if ((colmask[color] & (1 << i))!=0)
					palette_used_colors.write(pal_base + 16 * color + i, PALETTE_COLOR_USED);
			}
		}
	}