public static WriteHandlerPtr zaxxon_sound_w = new WriteHandlerPtr() { public void handler(int offset, int data)
    {
        int line;
        int noise;


        if (offset == 0)
        {
		/* handle background rumble */
            switch (data & 0x0c)
            {
                case 0x04:
                    soundplaying[20] = 0;
                    sample_stop(sa[20].channel);
                    if (soundplaying[21] == 0)
                    {
                        soundplaying[21] = 1;
                        sample_start(sa[21].channel,sa[21].num,sa[21].looped);
                    }
                    sample_set_volume(sa[21].channel,128 + 40 * (data & 0x03));
                    break;
                case 0x00:
                case 0x08:
                    if (soundplaying[20] == 0)
                    {
                        soundplaying[20] = 1;
                        sample_start(sa[20].channel,sa[20].num,sa[20].looped);
                    }
                    sample_set_volume(sa[20].channel,128 + 40 * (data & 0x03));
                    soundplaying[21] = 0;
                    sample_stop(sa[21].channel);
                    break;
                case 0x0c:
                    soundplaying[20] = 0;
                    sample_stop(sa[20].channel);
                    soundplaying[21] = 0;
                    sample_stop(sa[21].channel);
                    break;
            }
        }

        for (line = 0;line < 8;line++)
        {
            noise = 8 * offset + line - 4;

		/* the first four sound lines are handled separately */
            if (noise >= 0)
            {
                if ((data & (1 << line)) == 0)
                {
				/* trigger sound */
                    if (soundplaying[noise] == 0)
                    {
                        soundplaying[noise] = 1;
                        if (sa[noise].channel != -1)
                        {
                            if (sa[noise].restartable!=0 || sample_playing(sa[noise].channel)==0)
                                sample_start(sa[noise].channel,sa[noise].num,sa[noise].looped);
                        }
                    }
                }
                else
                {
                    if (soundplaying[noise]!=0)
                    {
                        soundplaying[noise] = 0;
                        if (sa[noise].channel != -1 && sa[noise].stoppable!=0)
                            sample_stop(sa[noise].channel);
                    }
                }
            }
        }
    }}