static void *ym2608_start(int sndindex, int clock, const void *config) { static const struct YM2608interface generic_2608 = { { AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT, AY8910_DEFAULT_LOADS, NULL, NULL, NULL, NULL }, NULL, 0, }; const struct YM2608interface *intf = config ? config : &generic_2608; int rate = clock/72; void *pcmbufa; int pcmsizea; struct ym2608_info *info; info = auto_malloc(sizeof(*info)); memset(info, 0, sizeof(*info)); info->intf = intf; /* FIXME: Force to use simgle output */ info->psg = ay8910_start_ym(SOUND_YM2608, sndindex, clock, &intf->ay8910_intf); if (!info->psg) return NULL; /* Timer Handler set */ info->timer[0] = timer_alloc(timer_callback_2608_0, info); info->timer[1] = timer_alloc(timer_callback_2608_1, info); /* stream system initialize */ info->stream = stream_create(0,2,rate,info,ym2608_stream_update); /* setup adpcm buffers */ pcmbufa = (void *)(memory_region(info->intf->pcmrom)); pcmsizea = memory_region_length(info->intf->pcmrom); /* initialize YM2608 */ info->chip = YM2608Init(info,sndindex,clock,rate, pcmbufa,pcmsizea, timer_handler,IRQHandler,&psgintf); state_save_register_postload(Machine, ym2608_postload, info); if (info->chip) return info; /* error */ return NULL; }
static int open_cb(struct archive *arch, void *priv) { struct mp_archive_volume *vol = priv; vol->seek_to = -1; if (!vol->src) { vol->src = stream_create(vol->url, STREAM_READ, vol->mpa->primary_src->cancel, vol->mpa->primary_src->global); return vol->src ? ARCHIVE_OK : ARCHIVE_FATAL; } // just rewind the primary stream return stream_seek(vol->src, 0) ? ARCHIVE_OK : ARCHIVE_FATAL; }
static void *namco_63701x_start(int sndindex, int clock, const void *config) { struct namco_63701x *chip; chip = auto_malloc(sizeof(*chip)); memset(chip, 0, sizeof(*chip)); chip->intf = config; chip->rom = memory_region(chip->intf->region); chip->stream = stream_create(0, 2, clock/1000, chip, namco_63701x_update); return chip; }
void *exidy440_sh_start(int clock, const struct CustomSound_interface *config) { int i, length; /* reset the system */ exidy440_sound_command = 0; exidy440_sound_command_ack = 1; state_save_register_global(exidy440_sound_command); state_save_register_global(exidy440_sound_command_ack); /* reset the 6844 */ for (i = 0; i < 4; i++) { m6844_channel[i].active = 0; m6844_channel[i].control = 0x00; } m6844_priority = 0x00; m6844_interrupt = 0x00; m6844_chain = 0x00; state_save_register_int("m6844", 0, "priority", &m6844_priority); state_save_register_int("m6844", 0, "interrupt", &m6844_interrupt); state_save_register_int("m6844", 0, "chain", &m6844_chain); channel_frequency[0] = clock; /* channels 0 and 1 are run by FCLK */ channel_frequency[1] = clock; channel_frequency[2] = clock/2; /* channels 2 and 3 are run by SCLK */ channel_frequency[3] = clock/2; /* get stream channels */ stream = stream_create(0, 2, clock, NULL, channel_update); /* allocate the sample cache */ length = memory_region_length(REGION_SOUND1) * 16 + MAX_CACHE_ENTRIES * sizeof(sound_cache_entry); sound_cache = auto_malloc(length); /* determine the hard end of the cache and reset */ sound_cache_max = (sound_cache_entry *)((UINT8 *)sound_cache + length); reset_sound_cache(); /* allocate the mixer buffer */ mixer_buffer_left = auto_malloc(2 * clock * sizeof(INT32)); mixer_buffer_right = mixer_buffer_left + clock; if (SOUND_LOG) debuglog = fopen("sound.log", "w"); return auto_malloc(1); }
static void sid_start(running_device *device, SIDTYPE sidtype) { SID6581 *sid = get_sid(device); const sid6581_interface *iface = (const sid6581_interface*) device->baseconfig().static_config(); sid->device = device; sid->mixer_channel = stream_create (device, 0, 1, device->machine->sample_rate, (void *) sid, sid_update); sid->PCMfreq = device->machine->sample_rate; sid->clock = device->clock(); sid->ad_read = iface ? iface->ad_read : NULL; sid->type = sidtype; sid6581_init(sid); sidInitWaveformTables(sidtype); }
static void *saa1099_start(int sndindex, int clock, const void *config) { struct SAA1099 *saa; saa = auto_malloc(sizeof(*saa)); memset(saa, 0, sizeof(*saa)); /* copy global parameters */ saa->sample_rate = 1.0 * Machine->sample_rate; /* for each chip allocate one stream */ saa->stream = stream_create(0, 2, saa->sample_rate, saa, saa1099_update); return saa; }
stream_t *fileMgr_create(char *name) { HANDLE hFile = CreateFile(name, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, 0, CREATE_ALWAYS, 0, 0); if( hFile == INVALID_HANDLE_VALUE ) return NULL; file_t *file = (file_t*)memMgr_alloc(NULL, sizeof(file_t)); file->hFile = hFile; file->stream = NULL; if( file->stream == NULL ) { stream_t* stream = stream_create(&fileStreamSettings, file); file->stream = stream; } return file->stream; }
static DEVICE_START( ym2610 ) { static const ym2610_interface generic_2610 = { 0 }; static const ay8910_interface generic_ay8910 = { AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT, AY8910_DEFAULT_LOADS, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL }; const ym2610_interface *intf = device->baseconfig().static_config() ? (const ym2610_interface *)device->baseconfig().static_config() : &generic_2610; int rate = device->clock()/72; void *pcmbufa,*pcmbufb; int pcmsizea,pcmsizeb; ym2610_state *info = get_safe_token(device); astring name; device_type type = device->type(); info->intf = intf; info->device = device; info->psg = ay8910_start_ym(NULL, device->type(), device, device->clock(), &generic_ay8910); assert_always(info->psg != NULL, "Error creating YM2610/AY8910 chip"); /* Timer Handler set */ info->timer[0] = timer_alloc(device->machine, timer_callback_0, info); info->timer[1] = timer_alloc(device->machine, timer_callback_1, info); /* stream system initialize */ info->stream = stream_create(device,0,2,rate,info,(type == SOUND_YM2610) ? ym2610_stream_update : ym2610b_stream_update); /* setup adpcm buffers */ pcmbufa = *device->region(); pcmsizea = device->region()->bytes(); name.printf("%s.deltat", device->tag()); pcmbufb = (void *)(memory_region(device->machine, name)); pcmsizeb = memory_region_length(device->machine, name); if (pcmbufb == NULL || pcmsizeb == 0) { pcmbufb = pcmbufa; pcmsizeb = pcmsizea; } /**** initialize YM2610 ****/ info->chip = ym2610_init(info,device,device->clock(),rate, pcmbufa,pcmsizea,pcmbufb,pcmsizeb, timer_handler,IRQHandler,&psgintf); assert_always(info->chip != NULL, "Error creating YM2610 chip"); state_save_register_postload(device->machine, ym2610_intf_postload, info); }
static DEVICE_START( exidy440_sound ) { running_machine *machine = device->machine; int i, length; /* reset the system */ exidy440_sound_command = 0; exidy440_sound_command_ack = 1; state_save_register_global(machine, exidy440_sound_command); state_save_register_global(machine, exidy440_sound_command_ack); /* reset the 6844 */ for (i = 0; i < 4; i++) { m6844_channel[i].active = 0; m6844_channel[i].control = 0x00; } m6844_priority = 0x00; m6844_interrupt = 0x00; m6844_chain = 0x00; state_save_register_global(machine, m6844_priority); state_save_register_global(machine, m6844_interrupt); state_save_register_global(machine, m6844_chain); channel_frequency[0] = device->clock; /* channels 0 and 1 are run by FCLK */ channel_frequency[1] = device->clock; channel_frequency[2] = device->clock/2; /* channels 2 and 3 are run by SCLK */ channel_frequency[3] = device->clock/2; /* get stream channels */ stream = stream_create(device, 0, 2, device->clock, NULL, channel_update); /* allocate the sample cache */ length = memory_region_length(machine, "cvsd") * 16 + MAX_CACHE_ENTRIES * sizeof(sound_cache_entry); sound_cache = (sound_cache_entry *)auto_alloc_array(machine, UINT8, length); /* determine the hard end of the cache and reset */ sound_cache_max = (sound_cache_entry *)((UINT8 *)sound_cache + length); reset_sound_cache(); /* allocate the mixer buffer */ mixer_buffer_left = auto_alloc_array(machine, INT32, 2 * device->clock); mixer_buffer_right = mixer_buffer_left + device->clock; if (SOUND_LOG) debuglog = fopen("sound.log", "w"); }
stream_t *fileMgr_openForAppend(char *name) { HANDLE hFile = CreateFile(name, FILE_GENERIC_READ|FILE_GENERIC_WRITE, FILE_SHARE_READ, 0, OPEN_ALWAYS, 0, 0); if( hFile == INVALID_HANDLE_VALUE ) return NULL; file_t *file = (file_t*)memMgr_alloc(NULL, sizeof(file_t)); file->hFile = hFile; file->stream = NULL; SetFilePointer(file->hFile, 0, 0, FILE_END); if( file->stream == NULL ) { stream_t* stream = stream_create(&fileStreamSettings, file); file->stream = stream; } return file->stream; }
void *exidy_sh6840_sh_start(int clock, const struct CustomSound_interface *config) { int sample_rate = SH8253_CLOCK; sh6840_clocks_per_sample = (int)((double)SH6840_CLOCK / (double)sample_rate * (double)(1 << 24)); /* allocate the stream */ exidy_stream = stream_create(0, 1, sample_rate, NULL, exidy_stream_update); /* indicate no additional hardware */ has_sh8253 = FALSE; has_tms5220 = FALSE; has_mc3417 = FALSE; return auto_malloc(1); }
// the trace stream is an event stream void trace_init() { if (failed(stream_open(0, dmesg_str, &trace_stream))) { stream_create(0, dmesg_str, &trace_stream); } else stream_truncate(trace_stream, 0); if (failed(reg_get_uint16(0, trace_str, &trace_level))) #ifdef _DEBUG trace_level = 7; #else trace_level = 3; #endif }
static void *dac_start(int sndindex, int clock, const void *config) { struct dac_info *info; info = auto_malloc(sizeof(*info)); memset(info, 0, sizeof(*info)); DAC_build_voltable(info); info->channel = stream_create(0,1,clock ? clock : DEFAULT_SAMPLE_RATE,info,DAC_update); info->output = 0; state_save_register_item("dac", sndindex, info->output); return info; }
kchannel_ref_t* knet_channel_ref_create(kloop_t* loop, kchannel_t* channel) { kchannel_ref_t* channel_ref = create(kchannel_ref_t); verify(channel_ref); memset(channel_ref, 0, sizeof(kchannel_ref_t)); channel_ref->ref_info = create(channel_ref_info_t); verify(channel_ref->ref_info); memset(channel_ref->ref_info, 0, sizeof(channel_ref_info_t)); channel_ref->ref_info->stream = stream_create(channel_ref); verify(channel_ref->ref_info->stream); channel_ref->ref_info->channel = channel; channel_ref->ref_info->ref_count = 0; channel_ref->ref_info->loop = loop; channel_ref->ref_info->last_recv_ts = time(0); channel_ref->ref_info->state = channel_state_init; knet_loop_profile_increase_active_channel_count(knet_loop_get_profile(loop)); return channel_ref; }
result_t edit_name_action(cli_t *context, const char * name_) { if(name_ == 0) return e_bad_parameter; result_t result; handle_t stream; if(failed(stream_open(get_context(context), name_, &stream))) { if(failed(result = stream_create(get_context(context), name_, &stream))) return result; } // open the editor and edit the script. return edit_script(context, name_, stream); }
static void *vrender0_start(int sndindex, int clock, const void *config) { const struct VR0Interface *intf; struct _VR0Chip *VR0; VR0 = auto_malloc(sizeof(*VR0)); memset(VR0, 0, sizeof(*VR0)); intf=config; memcpy(&(VR0->Intf),intf,sizeof(struct VR0Interface)); memset(VR0->SOUNDREGS,0,0x10000); VR0->stream = stream_create(0, 2, 44100, VR0, VR0_Update); return VR0; }
int main(int argc, char** argv) { int show_usage; printf("Myst IV texture extractor\n"); printf("WRS (XeNTaX.com)\n\n"); show_usage = 1; if (argc > 1) { switch (argv[1][0]) { case 'e': { if (argc == 4) { show_usage = 0; FStream *fs_in; stream_create(&fs_in); if (stream_open(fs_in, argv[2]) == 1) { printf("Failed to open source file\n"); } else { extract_bin_texture(fs_in, argv[3]); } stream_destroy(&fs_in); } break; } } } if (show_usage != 0) { printf("Usage:\n"); printf(" myst_extract_img e <file>.bin <result>\n"); printf("\n"); } mem_dbg(); return 0; }
static void *sid_start(int sndindex, int clock, const void *config, SIDTYPE sidtype) { SID6581 *sid; const SID6581_interface *iface = (const SID6581_interface*) config; sid = (SID6581 *) auto_malloc(sizeof(*sid)); memset(sid, 0, sizeof(*sid)); sid->mixer_channel = stream_create (0, 1, Machine->sample_rate, (void *) sid, sid_update); sid->PCMfreq = Machine->sample_rate; sid->clock = clock; sid->ad_read = iface ? iface->ad_read : NULL; sid->type = sidtype; sid6581_init(sid); sidInitWaveformTables(sidtype); return sid; }
static DEVICE_START( s14001a ) { S14001AChip *chip = get_safe_token(device); int i; chip->GlobalSilenceState = 1; chip->OldDelta = 0x02; chip->DACOutput = SILENCE; for (i = 0; i < 8; i++) { chip->filtervals[i] = SILENCE; } chip->SpeechRom = *device->region(); chip->stream = stream_create(device, 0, 1, device->clock() ? device->clock() : device->machine->sample_rate, chip, s14001a_pcm_update); }
static void AY8910_init(struct AY8910 *PSG, int streams, int clock,int sample_rate, read8_handler portAread,read8_handler portBread, write8_handler portAwrite,write8_handler portBwrite) { PSG->PortAread = portAread; PSG->PortBread = portBread; PSG->PortAwrite = portAwrite; PSG->PortBwrite = portBwrite; /* the step clock for the tone and noise generators is the chip clock */ /* divided by 8; for the envelope generator of the AY-3-8910, it is half */ /* that much (clock/16), but the envelope of the YM2149 goes twice as */ /* fast, therefore again clock/8. */ PSG->Channel = stream_create(0,streams,clock/8,PSG,AY8910Update); ay8910_set_clock_ym(PSG,clock); }
void *wswan_sh_start(int clock, const struct CustomSound_interface *config) { channel = stream_create(0, 2, Machine->sample_rate, 0, wswan_sh_update); snd.audio1.on = 0; snd.audio1.signal = 16; snd.audio1.pos = 0; snd.audio2.on = 0; snd.audio2.signal = 16; snd.audio2.pos = 0; snd.audio3.on = 0; snd.audio3.signal = 16; snd.audio3.pos = 0; snd.audio4.on = 0; snd.audio4.signal = 16; snd.audio4.pos = 0; return (void *) ~0; }
void okim6295_device::device_start() { // create the stream int divisor = m_config.m_pin7 ? 132 : 165; m_stream = stream_create(this, 0, 1, clock() / divisor, this, static_stream_generate); state_save_register_device_item(this, 0, m_command); state_save_register_device_item(this, 0, m_bank_offs); for (int voicenum = 0; voicenum < OKIM6295_VOICES; voicenum++) { state_save_register_device_item(this, voicenum, m_voice[voicenum].m_playing); state_save_register_device_item(this, voicenum, m_voice[voicenum].m_sample); state_save_register_device_item(this, voicenum, m_voice[voicenum].m_count); state_save_register_device_item(this, voicenum, m_voice[voicenum].m_adpcm.m_signal); state_save_register_device_item(this, voicenum, m_voice[voicenum].m_adpcm.m_step); state_save_register_device_item(this, voicenum, m_voice[voicenum].m_volume); state_save_register_device_item(this, voicenum, m_voice[voicenum].m_base_offset); } }
static void *ym2610_start(int sndindex, int clock, const void *config) { static const struct YM2610interface generic_2610 = { 0 }; const struct YM2610interface *intf = config ? config : &generic_2610; int rate = Machine->sample_rate; void *pcmbufa,*pcmbufb; int pcmsizea,pcmsizeb; struct ym2610_info *info; sound_type = SOUND_YM2610; info = auto_malloc(sizeof(*info)); memset(info, 0, sizeof(*info)); info->intf = intf; info->psg = ay8910_start_ym(SOUND_YM2610, sndindex, clock, 1, NULL, NULL, NULL, NULL); if (!info->psg) return NULL; /* Timer Handler set */ info->timer[0] =timer_alloc_ptr(timer_callback_0, info); info->timer[1] =timer_alloc_ptr(timer_callback_1, info); /* stream system initialize */ info->stream = stream_create(0,2,rate,info,ym2610_stream_update); /* setup adpcm buffers */ pcmbufa = (void *)(memory_region(info->intf->pcmroma)); pcmsizea = memory_region_length(info->intf->pcmroma); pcmbufb = (void *)(memory_region(info->intf->pcmromb)); pcmsizeb = memory_region_length(info->intf->pcmromb); /**** initialize YM2610 ****/ info->chip = YM2610Init(info,sndindex,clock,rate, pcmbufa,pcmsizea,pcmbufb,pcmsizeb, TimerHandler,IRQHandler,&psgintf); state_save_register_func_postload_ptr(ym2610_postload, info); if (info->chip) return info; /* error */ return NULL; }
static DEVICE_START( cdp1863 ) { cdp1863_t *cdp1863 = get_safe_token(device); const cdp1863_config *config = get_safe_config(device); /* set initial values */ cdp1863->stream = stream_create(device, 0, 1, device->machine->sample_rate, cdp1863, cdp1863_stream_update); cdp1863->clock1 = device->clock(); cdp1863->clock2 = config->clock2; cdp1863->oe = 1; /* register for state saving */ state_save_register_device_item(device, 0, cdp1863->clock1); state_save_register_device_item(device, 0, cdp1863->clock2); state_save_register_device_item(device, 0, cdp1863->oe); state_save_register_device_item(device, 0, cdp1863->latch); state_save_register_device_item(device, 0, cdp1863->signal); state_save_register_device_item(device, 0, cdp1863->incr); }
static DEVICE_START( ym2608 ) { static const ym2608_interface generic_2608 = { { AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT, AY8910_DEFAULT_LOADS, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL }, NULL }; const ym2608_interface *intf = device->baseconfig().static_config() ? (const ym2608_interface *)device->baseconfig().static_config() : &generic_2608; int rate = device->clock()/72; void *pcmbufa; int pcmsizea; ym2608_state *info = get_safe_token(device); info->intf = intf; info->device = device; /* FIXME: Force to use simgle output */ info->psg = ay8910_start_ym(NULL, SOUND_YM2608, device, device->clock(), &intf->ay8910_intf); assert_always(info->psg != NULL, "Error creating YM2608/AY8910 chip"); /* Timer Handler set */ info->timer[0] = timer_alloc(device->machine, timer_callback_2608_0, info); info->timer[1] = timer_alloc(device->machine, timer_callback_2608_1, info); /* stream system initialize */ info->stream = stream_create(device,0,2,rate,info,ym2608_stream_update); /* setup adpcm buffers */ pcmbufa = *device->region(); pcmsizea = device->region()->bytes(); /* initialize YM2608 */ info->chip = ym2608_init(info,device,device->clock(),rate, pcmbufa,pcmsizea, timer_handler,IRQHandler,&psgintf); assert_always(info->chip != NULL, "Error creating YM2608 chip"); state_save_register_postload(device->machine, ym2608_intf_postload, info); }
void *redbaron_sh_start(int clock, const struct CustomSound_interface *config) { int i; vol_lookup = (INT16 *)auto_malloc(32768 * sizeof(INT16)); for( i = 0; i < 0x8000; i++ ) vol_lookup[0x7fff-i] = (INT16) (0x7fff/exp(1.0*i/4096)); for( i = 0; i < 16; i++ ) { /* r0 = R18 and R24, r1 = open */ double r0 = 1.0/(5600 + 680), r1 = 1/6e12; /* R14 */ if( i & 1 ) r1 += 1.0/8200; else r0 += 1.0/8200; /* R15 */ if( i & 2 ) r1 += 1.0/3900; else r0 += 1.0/3900; /* R16 */ if( i & 4 ) r1 += 1.0/2200; else r0 += 1.0/2200; /* R17 */ if( i & 8 ) r1 += 1.0/1000; else r0 += 1.0/1000; r0 = 1.0/r0; r1 = 1.0/r1; vol_crash[i] = 32767 * r0 / (r0 + r1); } channel = stream_create(0, 1, Machine->sample_rate, 0, redbaron_sound_update); return auto_malloc(1); }
static void *ym2203_start(int sndindex, int clock, const void *config) { static const struct YM2203interface generic_2203 = { { AY8910_LEGACY_OUTPUT, AY8910_DEFAULT_LOADS, NULL, NULL, NULL, NULL }, NULL }; const struct YM2203interface *intf = config ? config : &generic_2203; struct ym2203_info *info; int rate = clock/72; /* ??? */ info = auto_malloc(sizeof(*info)); memset(info, 0, sizeof(*info)); info->intf = intf; info->psg = ay8910_start_ym(SOUND_YM2203, sndindex, clock, &intf->ay8910_intf); if (!info->psg) return NULL; /* Timer Handler set */ info->timer[0] = timer_alloc(timer_callback_2203_0, info); info->timer[1] = timer_alloc(timer_callback_2203_1, info); /* stream system initialize */ info->stream = stream_create(0,1,rate,info,ym2203_stream_update); /* Initialize FM emurator */ info->chip = YM2203Init(info,sndindex,clock,rate,timer_handler,IRQHandler,&psgintf); state_save_register_postload(Machine, ym2203_postload, info); if (info->chip) return info; /* error */ /* stream close */ return NULL; }
static DEVICE_START( dmadac ) { dmadac_state *info = get_safe_token(device); /* allocate a clear a buffer */ info->buffer = auto_alloc_array_clear(device->machine, INT16, BUFFER_SIZE); /* reset the state */ info->volume = 0x100; /* allocate a stream channel */ info->channel = stream_create(device, 0, 1, DEFAULT_SAMPLE_RATE, info, dmadac_update); /* register with the save state system */ state_save_register_device_item(device, 0, info->bufin); state_save_register_device_item(device, 0, info->bufout); state_save_register_device_item(device, 0, info->volume); state_save_register_device_item(device, 0, info->enabled); state_save_register_device_item(device, 0, info->frequency); state_save_register_device_item_pointer(device, 0, info->buffer, BUFFER_SIZE); }
static DEVICE_START( ym2151 ) { static const ym2151_interface dummy = { 0 }; ym2151_state *info = get_safe_token(device); int rate; info->intf = device->baseconfig().static_config ? (const ym2151_interface *)device->baseconfig().static_config : &dummy; rate = device->clock/64; /* stream setup */ info->stream = stream_create(device,0,2,rate,info,ym2151_update); info->chip = ym2151_init(device,device->clock,rate); assert_always(info->chip != NULL, "Error creating YM2151 chip"); state_save_register_postload(device->machine, ym2151intf_postload, info); ym2151_set_irq_handler(info->chip,info->intf->irqhandler); ym2151_set_port_write_handler(info->chip,info->intf->portwritehandler); }
void extract_bin_texture(FStream* fs, const char* out_fn) { Texture *myst_img; myst_img = myst_read_bin_texture(fs); if (myst_img != 0){ FStream* out; stream_create(&out); stream_make(out, out_fn); if (out->handle != 0) { myst_write_bin_texture(out, myst_img); } stream_destroy(&out); } texture_destroy(&myst_img); }