public void writeCONTROL_REG(int /* reg8 */control) {
		waveform = (control >> 4) & 0x0f;
		ring_mod = control & 0x04;
		sync = control & 0x02;

		int /* reg8 */test_next = control & 0x08;

		if (ANTTI_LANKILA_PATCH) {
			/*
			 * SounDemoN found out that test bit can be used to control the
			 * noise register. Hear the result in Bojojoing.sid.
			 */

			// testbit set. invert bit 19 and write it to bit 1
			if (test_next != 0 && test == 0) {
				accumulator = 0;
				int /* reg24 */bit19 = (shift_register >> 19) & 1;
				shift_register = (shift_register & 0x7ffffd)
						| ((bit19 ^ 1) << 1);
			}
			// Test bit cleared.
			// The accumulator starts counting, and the shift register is reset
			// to
			// the value 0x7ffff8.
			// NB! The shift register will not actually be set to this exact
			// value
			// if the
			// shift register bits have not had time to fade to zero.
			// This is not modeled.
			else if (test_next == 0 && test > 0) {
				int /* reg24 */bit0 = ((shift_register >> 22) ^ (shift_register >> 17)) & 0x1;
				shift_register <<= 1;
				shift_register &= 0x7fffff;
				shift_register |= bit0;
			}
			// clear output bits of shift register if noise and other waveforms
			// are selected simultaneously

			if (waveform > 8) {
				shift_register &= 0x7fffff ^ (1 << 22) ^ (1 << 20) ^ (1 << 16)
						^ (1 << 13) ^ (1 << 11) ^ (1 << 7) ^ (1 << 4)
						^ (1 << 2);
			}
		} else {
			// Test bit set.
			// The accumulator and the shift register are both cleared.
			// NB! The shift register is not really cleared immediately. It
			// seems
			// like the individual bits in the shift register start to fade down
			// towards zero when test is set. All bits reach zero within
			// approximately $2000 - $4000 cycles.
			// This is not modeled. There should fortunately be little audible
			// output from this peculiar behavior.
			if (test_next != 0) {
				accumulator = 0;
				shift_register = 0;
			}
			// Test bit cleared.
			// The accumulator starts counting, and the shift register is reset
			// to
			// the value 0x7ffff8.
			// NB! The shift register will not actually be set to this exact
			// value
			// if the
			// shift register bits have not had time to fade to zero.
			// This is not modeled.
			else if (test != 0) {
				shift_register = 0x7ffff8;
			}
		}
		test = test_next;

		// The gate bit is handled by the EnvelopeGenerator.
	}