Example #1
0
void okim6376_device::device_start()
{
	int voice;
	compute_tables();

	m_command[0] = -1;
	m_command[1] = -1;
	m_stage[0] = 0;
	m_stage[1] = 0;
	m_latch = 0;
	m_master_clock = clock();
	m_divisor = divisor_table[0];
	m_nar = 1;
	m_nartimer = 0;
	m_busy = 1;
	m_st = 1;
	m_ch2 = 1;
	m_st_update = 0;
	m_ch2_update = 0;
	m_st_pulses = 0;
	/* generate the name and create the stream */
	m_stream = machine().sound().stream_alloc(*this, 0, 1, clock() / m_divisor);

	/* initialize the voices */
	for (voice = 0; voice < OKIM6376_VOICES; voice++)
	{
		/* initialize the rest of the structure */
		m_voice[voice].volume = 0;
		reset_adpcm(&m_voice[voice]);
	}

	okim6376_state_save_register();
}
Example #2
0
static void RenegadeADPCMInit(int clock)
{
	struct renegade_adpcm_state *state = &renegade_adpcm;
	state->playing = 0;
	state->base = DrvADPCMRom;
	reset_adpcm(&state->adpcm);
	
	nUpdateStep = (int)(((float)clock / nBurnSoundRate) * 4096);
}
Example #3
0
static void oki_process(okim6376_state *info, int channel, int command)
{
	/* if a command is pending, process the second half */
	if ((command != -1) && (command != 0)) //process silence separately
	{
		int start;
		unsigned char *base/*, *base_end*/;
		/* update the stream */
		info->stream->update();

		/* determine which voice(s) (voice is set by the state of 2CH) */
		{
			struct ADPCMVoice *voice = &info->voice[channel];

			/* determine the start position, max address space is 16Mbit */
			base = &info->region_base[info->command[channel] * 4];
			//base_end = &info->region_base[(MAX_WORDS+1) * 4];
			start = ((base[0] << 16) + (base[1] << 8) + base[2]) & 0x1fffff;

				if (start == 0)
				{
					voice->playing = 0;
				}
				else
				{
					/* set up the voice to play this sample */
					if (!voice->playing)
					{
						voice->playing = 1;
						voice->base_offset = start;
						voice->sample = 0;
						voice->count = 0;

						/* also reset the ADPCM parameters */
						reset_adpcm(voice);
						if (channel == 0)
						{
							/* We set channel 2's audio separately */
							voice->volume = volume_table[0];
						}
					}
					else
					{
						if (((info->nar)&&(channel == 0))||(channel == 1))//Store the request, for later processing (channel 2 ignores NAR)
						{
							info->stage[channel] = 1;
						}
					}
				}
			}
		}
		/* otherwise, see if this is a silence command */
		else
		{
			/* update the stream, then turn it off */
			info->stream->update();

			if (command ==0)
			{
				int i;
				for (i = 0; i < OKIM6376_VOICES; i++)
				{
					struct ADPCMVoice *voice = &info->voice[i];
					voice->playing = 0;
			}
		}
	}
}