static void f1dream_protection_w()
	{
		int indx;
		int value = 255;
		int prevpc = cpu_getpreviouspc();
	
		if (prevpc == 0x244c)
		{
			/* Called once, when a race is started.*/
			indx = ram.READ_WORD(0x3ff0);
			ram.WRITE_WORD(0x3fe6,f1dream_2450_lookup[indx]);
			ram.WRITE_WORD(0x3fe8,f1dream_2450_lookup[++indx]);
			ram.WRITE_WORD(0x3fea,f1dream_2450_lookup[++indx]);
			ram.WRITE_WORD(0x3fec,f1dream_2450_lookup[++indx]);
		}
		else if (prevpc == 0x613a)
		{
			/* Called for every sprite on-screen.*/
			if ((ram.READ_WORD(0x3ff6)) < 15)
			{
				indx = f1dream_613ea_lookup[ram.READ_WORD(0x3ff6)] - (ram.READ_WORD(0x3ff4));
				if (indx > 255)
				{
					indx <<= 4;
					indx += ram.READ_WORD(0x3ff6) & 0x00ff;
					value = f1dream_613eb_lookup[indx];
				}
			}
	
			ram.WRITE_WORD(0x3ff2,value);
		}
		else if (prevpc == 0x17b70)
		{
			/* Called only before a real race, not a time trial.*/
			if ((ram.READ_WORD(0x3ff0)) >= 0x04) indx = 128;
			else if ((ram.READ_WORD(0x3ff0)) > 0x02) indx = 96;
			else if ((ram.READ_WORD(0x3ff0)) == 0x02) indx = 64;
			else if ((ram.READ_WORD(0x3ff0)) == 0x01) indx = 32;
			else indx = 0;
	
			indx += ram.READ_WORD(0x3fee);
			if (indx < 128)
			{
				ram.WRITE_WORD(0x3fe6,f1dream_17b74_lookup[indx]);
				ram.WRITE_WORD(0x3fe8,f1dream_17b74_lookup[++indx]);
				ram.WRITE_WORD(0x3fea,f1dream_17b74_lookup[++indx]);
				ram.WRITE_WORD(0x3fec,f1dream_17b74_lookup[++indx]);
			}
			else
			{
				ram.WRITE_WORD(0x3fe6,0x00ff);
				ram.WRITE_WORD(0x3fe8,0x00ff);
				ram.WRITE_WORD(0x3fea,0x00ff);
				ram.WRITE_WORD(0x3fec,0x00ff);
			}
		}
		else if ((prevpc == 0x27f8) || (prevpc == 0x511a) || (prevpc == 0x5142) || (prevpc == 0x516a))
		{
			/* The main CPU stuffs the byte for the soundlatch into 0xfffffd.*/
			soundlatch_w.handler(2,ram.READ_WORD(0x3ffc));
		}
	}