//void okim6295_set_pin7(running_device *device, int pin7) private static void okim6295_set_pin7(okim6295_state info, int pin7,okim6295Info Info) { //okim6295_state *info = get_safe_token(device); //int divisor = pin7 ? 132 : 165; Info.pin7State = (byte)pin7; info.pin7_state = (byte)pin7; //stream_set_sample_rate(info->stream, info->master_clock/divisor); okim6295_clock_changed(info); }
/********************************************************************************************** okim6295_data_w -- write to the data port of an OKIM6295-compatible chip ***********************************************************************************************/ //WRITE8_DEVICE_HANDLER( okim6295_w ) private void okim6295_write_command(okim6295_state info, byte data,okim6295Info Info) { //okim6295_state *info = get_safe_token(device); /* if a command is pending, process the second half */ if (info.command != -1) { int temp = data >> 4, i, start, stop; int iBase; /* the manual explicitly says that it's not possible to start multiple voices at the same time */ // if (temp != 0 && temp != 1 && temp != 2 && temp != 4 && temp != 8) // System.Console.Write("OKI6295 start %x contact MAMEDEV\n", temp); /* update the stream */ //stream_update(info->stream); /* determine which voice(s) (voice is set by a 1 bit in the upper 4 bits of the second byte) */ for (i = 0; i < okim6295_state.OKIM6295_VOICES; i++, temp >>= 1) { if ((temp & 1) != 0) { ADPCMVoice voice = info.voice[i]; /* determine the start/stop positions */ iBase = info.command * 8; //start = memory_raw_read_byte(device->space(), base + 0) << 16; start = memory_raw_read_byte(info, iBase + 0) << 16; start |= memory_raw_read_byte(info, iBase + 1) << 8; start |= memory_raw_read_byte(info, iBase + 2) << 0; start &= 0x3ffff; Info.chInfo[i].stAdr = start; stop = memory_raw_read_byte(info, iBase + 3) << 16; stop |= memory_raw_read_byte(info, iBase + 4) << 8; stop |= memory_raw_read_byte(info, iBase + 5) << 0; stop &= 0x3ffff; Info.chInfo[i].edAdr = stop; /* set up the voice to play this sample */ if (start < stop) { if (voice.playing == 0) /* fixes Got-cha and Steel Force */ { voice.playing = 1; voice.base_offset = (uint)start; voice.sample = 0; voice.count = (uint)(2 * (stop - start + 1)); /* also reset the ADPCM parameters */ reset_adpcm(voice.adpcm); voice.volume = (uint)volume_table[data & 0x0f]; Info.keyon[i] = true; } else { //logerror("OKIM6295:'%s' requested to play sample %02x on non-stopped voice\n",device->tag(),info->command); // just displays warnings when seeking //logerror("OKIM6295: Voice %u requested to play sample %02x on non-stopped voice\n",i,info->command); } } /* invalid samples go here */ else { //logerror("OKIM6295:'%s' requested to play invalid sample %02x\n",device->tag(),info->command); //System.Console.Write("OKIM6295: Voice {0} requested to play invalid sample {1:X2} StartAddr {2:X} StopAdr {3:X} \n", i, info.command, start, stop); voice.playing = 0; } } } /* reset the command */ info.command = -1; } /* if this is the start of a command, remember the sample number for next time */ else if ((data & 0x80) != 0) { info.command = data & 0x7f; } /* otherwise, see if this is a silence command */ else { int temp = data >> 3, i; /* update the stream, then turn it off */ //stream_update(info->stream); /* determine which voice(s) (voice is set by a 1 bit in bits 3-6 of the command */ for (i = 0; i < okim6295_state.OKIM6295_VOICES; i++, temp >>= 1) { if ((temp & 1) != 0) { ADPCMVoice voice = info.voice[i]; voice.playing = 0; } } } }