Example #1
0
static TIMER_CALLBACK( music_playback )
{
	int pattern = 0;
	const device_config *device = devtag_get_device(machine, "oki");

	if ((okim6295_r(device,0) & 0x08) == 0)
	{
		if (sslam_bar != 0) {
			sslam_bar += 1;
			if (sslam_bar >= (sslam_snd_loop[sslam_melody][0] + 1))
				sslam_bar = 1;
		}
		pattern = sslam_snd_loop[sslam_melody][sslam_bar];

		if (pattern == 0xff) {		/* Restart track from first bar */
			sslam_bar = 1;
			pattern = sslam_snd_loop[sslam_melody][sslam_bar];
		}
		if (pattern == 0x00) {		/* Non-looped track. Stop playing it */
			sslam_track = 0;
			sslam_melody = 0;
			sslam_bar = 0;
			timer_enable(music_timer,0);
		}
		if (pattern) {
			logerror("Changing bar in music track to pattern %02x\n",pattern);
			okim6295_w(device,0,(0x80 | pattern));
			okim6295_w(device,0,0x81);
		}
	}
//  {
//      pattern = sslam_snd_loop[sslam_melody][sslam_bar];
//      popmessage("Music track: %02x, Melody: %02x, Pattern: %02x, Bar:%02d",sslam_track,sslam_melody,pattern,sslam_bar);
//  }
}
Example #2
0
static void play_oki_sound(const device_config *device, int game_sound, int data)
{
	int status = okim6295_r(device,0);

	logerror("Playing sample %02x from command %02x\n",game_sound,data);

	if (game_sound != 0)
	{
		if ((status & 0x01) == 0) {
			okim6295_w(device,0,(0x80 | game_sound));
			okim6295_w(device,0,0x11);
		}
		else if ((status & 0x02) == 0) {
			okim6295_w(device,0,(0x80 | game_sound));
			okim6295_w(device,0,0x21);
		}
		else if ((status & 0x04) == 0) {
			okim6295_w(device,0,(0x80 | game_sound));
			okim6295_w(device,0,0x41);
		}
		else if ((status & 0x08) == 0) {
			okim6295_w(device,0,(0x80 | game_sound));
			okim6295_w(device,0,0x81);
		}
	}
}
Example #3
0
static void sslam_play(const device_config *device, int track, int data)
{
	int status = okim6295_r(device,0);

	if (data < 0x80) {
		if (track) {
			if (sslam_track != data) {
				sslam_track  = data;
				sslam_bar = 1;
				if (status & 0x08)
					okim6295_w(device,0,0x40);
				okim6295_w(device,0,(0x80 | data));
				okim6295_w(device,0,0x81);
				timer_adjust_periodic(music_timer, ATTOTIME_IN_MSEC(4), 0, ATTOTIME_IN_HZ(250));	/* 250Hz for smooth sequencing */
			}
		}
		else {
			if ((status & 0x01) == 0) {
				okim6295_w(device,0,(0x80 | data));
				okim6295_w(device,0,0x11);
			}
			else if ((status & 0x02) == 0) {
				okim6295_w(device,0,(0x80 | data));
				okim6295_w(device,0,0x21);
			}
			else if ((status & 0x04) == 0) {
				okim6295_w(device,0,(0x80 | data));
				okim6295_w(device,0,0x41);
			}
		}
	}
	else {		/* use above 0x80 to turn off channels */
		if (track) {
			timer_enable(music_timer,0);
			sslam_track = 0;
			sslam_melody = 0;
			sslam_bar = 0;
		}
		data &= 0x7f;
		okim6295_w(device,0,data);
	}
}
Example #4
0
static void oki_play_sample(INT32 sample_no)
{
	UINT16 table_start = (sample_no & 0x80) ? read16(SAMPLE_TABLE_1) : read16(SAMPLE_TABLE_0);
	UINT8 byte1 = read8(table_start + 2 * (sample_no & 0x7f) + 0);
	UINT8 byte2 = read8(table_start + 2 * (sample_no & 0x7f) + 1);
	INT32 chip = (byte1 & 0x80) >> 7;
	const INT32 okidevice = (chip) ? NMK004_state.oki2device : NMK004_state.oki1device;

	if ((byte1 & 0x7f) == 0)
	{
		// stop all channels
		okim6295_w(okidevice, 0, 0x78 );
	}
	else
	{
		INT32 sample = byte1 & 0x7f;
		INT32 ch = byte2 & 0x03;
		INT32 force = (byte2 & 0x80) >> 7;

		if (!force && (NMK004_state.oki_playing & (1 << (ch + 4*chip))))
			return;

		NMK004_state.oki_playing |= 1 << (ch + 4*chip);

		// stop channel
		okim6295_w(okidevice, 0, (0x08 << ch) );

		if (sample != 0)
		{
			UINT8 *rom = (chip == 0) ? NMK004OKIROM0 : NMK004OKIROM1;
			INT32 bank = (byte2 & 0x0c) >> 2;
			INT32 vol = (byte2 & 0x70) >> 4;

			if (bank != 3)
				memcpy(rom + 0x20000,rom + 0x40000 + bank * 0x20000,0x20000);

			okim6295_w(okidevice, 0, 0x80 | sample );
			okim6295_w(okidevice, 0, (0x10 << ch) | vol );
		}
	}
Example #5
0
static void oki_play_sample(int sample_no)
{
	UINT16 table_start = (sample_no & 0x80) ? read16(SAMPLE_TABLE_1) : read16(SAMPLE_TABLE_0);
	UINT8 byte1 = read8(table_start + 2 * (sample_no & 0x7f) + 0);
	UINT8 byte2 = read8(table_start + 2 * (sample_no & 0x7f) + 1);
	int chip = (byte1 & 0x80) >> 7;
	const device_config *okidevice = (chip) ? NMK004_state.oki2device : NMK004_state.oki1device;

	if ((byte1 & 0x7f) == 0)
	{
		// stop all channels
		okim6295_w(okidevice, 0, 0x78 );
	}
	else
	{
		int sample = byte1 & 0x7f;
		int ch = byte2 & 0x03;
		int force = (byte2 & 0x80) >> 7;

		if (!force && (NMK004_state.oki_playing & (1 << (ch + 4*chip))))
			return;

		NMK004_state.oki_playing |= 1 << (ch + 4*chip);

		// stop channel
		okim6295_w(okidevice, 0, (0x08 << ch) );

		if (sample != 0)
		{
			UINT8 *rom = memory_region(NMK004_state.machine, (chip == 0) ? "oki1" : "oki2");
			int bank = (byte2 & 0x0c) >> 2;
			int vol = (byte2 & 0x70) >> 4;

			if (bank != 3)
				memcpy(rom + 0x20000,rom + 0x40000 + bank * 0x20000,0x20000);

			okim6295_w(okidevice, 0, 0x80 | sample );
			okim6295_w(okidevice, 0, (0x10 << ch) | vol );
		}
	}
Example #6
0
void batsugun_okisnd_w(const device_config *device, int data)
{
//  popmessage("Writing %04x to Sound CPU",data);

	if (data == 0)
	{
		okim6295_w(device,0,0x78);		/* Stop playing effects */
	}
	else if ((data > 0) && (data < 64))
	{
		play_oki_sound(device, batsugun_cmd_snd[data], data);
	}
}
Example #7
0
static WRITE8_HANDLER( playmark_snd_control_w )
{
	playmark_oki_control = data;

	if(data & 3)
	{
		if(playmark_oki_bank != ((data & 3) - 1))
		{
			playmark_oki_bank = (data & 3) - 1;
			okim6295_set_bank_base(devtag_get_device(space->machine, "oki"), 0x40000 * playmark_oki_bank);
		}
	}

	if ((data & 0x38) == 0x18)
	{
		okim6295_w(devtag_get_device(space->machine, "oki"), 0, playmark_oki_command);
	}

//  !(data & 0x80) -> sound enable
//   (data & 0x40) -> always set
}
Example #8
0
static WRITE8_DEVICE_HANDLER( aquarium_oki_w )
{
	logerror("%s:Writing %04x to the OKI M6295\n",cpuexec_describe_context(device->machine),aquarium_snd_bitswap(data));
	okim6295_w( device, 0, (aquarium_snd_bitswap(data)) );
}
Example #9
0
static WRITE16_DEVICE_HANDLER( tumblep_oki_w )
{
	okim6295_w(0, data & 0xff);
    /* STUFF IN OTHER BYTE TOO..*/
}