public static WriteHandlerPtr sys16_paletteram_w = new WriteHandlerPtr() { public void handler(int offset, int data){
		char oldword = (char)paletteram.READ_WORD(offset);
		char newword = (char)COMBINE_WORD (oldword, data);
		if( oldword!=newword ){
			/* we can do this, because we initialize palette RAM to all black in vh_start */
	
			/*	   byte 0    byte 1 */
			/*	GBGR BBBB GGGG RRRR */
			/*	5444 3210 3210 3210 */
	
			char/*UINT8*/ r = (char)(((newword & 0x00f)<<1)&0xFF);
			char/*UINT8*/ g = (char)(((newword & 0x0f0)>>2)&0xFF);
			char/*UINT8*/ b = (char)(((newword & 0xf00)>>7)&0xFF);
	
			if(sys16_dactype == 0)
			{
				/* dac_type == 0 (from GCS file) */
				if ((newword & 0x1000) != 0) r|=1;
				if ((newword & 0x2000) != 0) g|=2;
				if ((newword & 0x8000) != 0) g|=1;
				if ((newword & 0x4000) != 0) b|=1;
			}
			else if(sys16_dactype == 1)
			{
				/* dac_type == 1 (from GCS file) Shinobi Only*/
				if ((newword & 0x1000) != 0) r|=1;
				if ((newword & 0x4000) != 0) g|=2;
				if ((newword & 0x8000) != 0) g|=1;
				if ((newword & 0x2000) != 0) b|=1;
			}
			if (Machine.scrbitmap.depth == 8) /* 8 bit shadows */
			{
				if(sys16_freezepalette==0)
				{
					palette_change_color( offset/2,
						(r << 3) | (r >> 3), /* 5 bits red */
						(g << 2) | (g >> 4), /* 6 bits green */
						(b << 3) | (b >> 3) /* 5 bits blue */
					);
				}
				else
				{
					r=(char)(((r << 3) | (r >> 3))&0xFF); /* 5 bits red */
					g=(char)(((g << 2) | (g >> 4))&0xFF); /* 6 bits green */
					b=(char)(((b << 3) | (b >> 3))&0xFF); /* 5 bits blue */
					sys16_palettedirty[offset/2]=0xff000000+(r<<16)+(g<<8)+b;
				}
			}
			else
			{
                            throw new UnsupportedOperationException("Unimplemented"); 
/*TODO*///				if(!sys16_freezepalette)
/*TODO*///				{
/*TODO*///					r=(r << 3) | (r >> 2); /* 5 bits red */
/*TODO*///					g=(g << 2) | (g >> 4); /* 6 bits green */
/*TODO*///					b=(b << 3) | (b >> 2); /* 5 bits blue */
/*TODO*///	
/*TODO*///					palette_change_color( offset/2,r,g,b);
/*TODO*///	
/*TODO*///					/* shadow color */
/*TODO*///	
/*TODO*///					r= r * 160 / 256;
/*TODO*///					g= g * 160 / 256;
/*TODO*///					b= b * 160 / 256;
/*TODO*///	
/*TODO*///					palette_change_color( offset/2+Machine.drv.total_colors/2,r,g,b);
/*TODO*///				}
/*TODO*///				else
/*TODO*///				{
/*TODO*///					r=(r << 3) | (r >> 3); /* 5 bits red */
/*TODO*///					g=(g << 2) | (g >> 4); /* 6 bits green */
/*TODO*///					b=(b << 3) | (b >> 3); /* 5 bits blue */
/*TODO*///					sys16_palettedirty[offset/2]=0xff000000+(r<<16)+(g<<8)+b;
/*TODO*///	
/*TODO*///					r= r * 160 / 256;
/*TODO*///					g= g * 160 / 256;
/*TODO*///					b= b * 160 / 256;
/*TODO*///					sys16_palettedirty[offset/2+Machine.drv.total_colors/2]=0xff000000+(r<<16)+(g<<8)+b;
/*TODO*///				}
			}
			paletteram.WRITE_WORD(offset, newword);
		}
	} }