static void *ymf262_start(int sndindex, int clock, const void *config) { static const struct YMF262interface dummy = { 0 }; int rate = Machine->sample_rate; struct ymf262_info *info; info = auto_malloc(sizeof(*info)); memset(info, 0, sizeof(*info)); info->intf = config ? config : &dummy; rate = clock/288; /* stream system initialize */ info->chip = YMF262Init(clock,rate); if (info->chip == NULL) return NULL; info->stream = stream_create(0,4,rate,info,ymf262_stream_update); /* YMF262 setup */ YMF262SetTimerHandler (info->chip, TimerHandler_262, info); YMF262SetIRQHandler (info->chip, IRQHandler_262, info); YMF262SetUpdateHandler(info->chip, _stream_update, info); info->timer[0] = timer_alloc_ptr(timer_callback_262_0, info); info->timer[1] = timer_alloc_ptr(timer_callback_262_1, info); return info; }
void opl3_init(void) { emu_iodev_t io_device; S_printf("SB: OPL3 Initialization\n"); /* This is the FM (Adlib + Advanced Adlib) */ io_device.read_portb = adlib_io_read; io_device.write_portb = adlib_io_write; io_device.read_portw = NULL; io_device.write_portw = NULL; io_device.read_portd = NULL; io_device.write_portd = NULL; io_device.handler_name = "Adlib (+ Advanced) Emulation"; io_device.start_addr = ADLIB_BASE; io_device.end_addr = ADLIB_BASE + 3; io_device.irq = EMU_NO_IRQ; io_device.fd = -1; if (port_register_handler(io_device, 0) != 0) { error("ADLIB: Cannot registering port handler\n"); } #ifdef HAS_YMF262 opl3 = YMF262Init(OPL3_INTERNAL_FREQ, opl3_rate); YMF262SetTimerHandler(opl3, opl3_set_timer, &opl3_timers); YMF262SetUpdateHandler(opl3, opl3_update, NULL); #endif }
int YMF262_sh_start(const struct MachineSound *msound) { int i,chip; int rate = Machine->sample_rate; intf_262 = msound->sound_interface; if( intf_262->num > MAX_262 ) return 1; if (options.use_filter) rate = intf_262->baseclock/288; /* Timer state clear */ memset(Timer_262,0,sizeof(Timer_262)); /* stream system initialize */ if ( YMF262Init(intf_262->num,intf_262->baseclock,rate) != 0) return 1; for (chip = 0;chip < intf_262->num; chip++) { int mixed_vol; int vol[4]; /* four separate outputs */ char buf[4][40]; const char *name[4]; mixed_vol = intf_262->mixing_levelAB[chip]; for (i=0; i<4; i++) { if (i==2) /*channels C ad D use separate field */ mixed_vol = intf_262->mixing_levelCD[chip]; vol[i] = mixed_vol & 0xffff; mixed_vol >>= 16; name[i] = buf[i]; sprintf(buf[i],"%s #%d ch%c",sound_name(msound),chip,'A'+i); logerror("%s #%d ch%c vol %d\n",sound_name(msound),chip,'A'+i,mixed_vol); } stream_262[chip] = stream_init_multi(4,name,vol,rate,chip,YMF262UpdateOne); /* YMF262 setup */ YMF262SetTimerHandler (chip, TimerHandler_262, chip*2); YMF262SetIRQHandler (chip, IRQHandler_262, chip); YMF262SetUpdateHandler(chip, stream_update, stream_262[chip]); Timer_262[chip*2+0] = timer_alloc(timer_callback_262); Timer_262[chip*2+1] = timer_alloc(timer_callback_262); } return 0; }