public static WriteHandlerPtr astinvad_sh_port_4_w = new WriteHandlerPtr() { public void handler(int offset, int data)
	{
		int bitsChanged;
		int bitsGoneHigh;
		int bitsGoneLow;
	
	
		bitsChanged  = port4State ^ data;
		bitsGoneHigh = bitsChanged & data;
		bitsGoneLow  = bitsChanged & ~data;
	
		port4State = data;
	
	
		if ((bitsGoneHigh & OUT_PORT_4_UFO) != 0)  PLAY( SND_UFO, 1 );
		if ((bitsGoneLow & OUT_PORT_4_UFO) != 0)  STOP( SND_UFO );
	
		if ((bitsGoneHigh & OUT_PORT_4_SHOT) != 0)  PLAY( SND_SHOT, 0 );
		if ((bitsGoneLow & OUT_PORT_4_SHOT) != 0)  STOP( SND_SHOT );
	
		if ((bitsGoneHigh & OUT_PORT_4_BASEHIT) != 0)
		{
			PLAY( SND_BASEHIT, 0 );
	    	/* turn all colours red here */
	    	invaders_screen_red_w(1);
	    }
		if ((bitsGoneLow & OUT_PORT_4_BASEHIT) != 0)
		{
			STOP( SND_BASEHIT );
	    	/* restore colours here */
	    	invaders_screen_red_w(0);
	    }
	
		if ((bitsGoneHigh & OUT_PORT_4_INVADERHIT) != 0)  PLAY( SND_INVADERHIT, 0 );
		if ((bitsGoneLow & OUT_PORT_4_INVADERHIT) != 0)  STOP( SND_INVADERHIT );
	
		if (((bitsChanged & OUT_PORT_4_UNUSED)!=0) && errorlog!= null)  fprintf(errorlog, "Snd Port 4 = %02X\n", data & OUT_PORT_4_UNUSED);
	} }