void sound_init( void ) { /* Initialize FM chip */ if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) { /* YM2612 */ YM2612Init(); YM2612Config(config.dac_bits); YM_Reset = YM2612ResetChip; YM_Update = YM2612Update; YM_Write = YM2612Write; /* chip is running a VCLK / 144 = MCLK / 7 / 144 */ fm_cycles_ratio = 144 * 7; } else { /* YM2413 */ YM2413Init(); YM_Reset = YM2413ResetChip; YM_Update = YM2413Update; YM_Write = YM2413Write; /* chip is running a ZCLK / 72 = MCLK / 15 / 72 */ fm_cycles_ratio = 72 * 15; } /* Initialize PSG chip */ SN76489_Config(0, config.psg_preamp, config.psgBoostNoise, 0xff); }
SN76489_Context* SN76489_Init( int PSGClockValue, int SamplingRate) { int i; SN76489_Context* chip = (SN76489_Context*)malloc(sizeof(SN76489_Context)); if(chip) { chip->dClock=(float)(PSGClockValue & 0x7FFFFFF)/16/SamplingRate; SN76489_SetMute(chip, MUTE_ALLON); SN76489_Config(chip, /*MUTE_ALLON,*/ FB_SEGAVDP, SRW_SEGAVDP, 1); for( i = 0; i <= 3; i++ ) centre_panning(chip->panning[i]); //SN76489_Reset(chip); if ((PSGClockValue & 0x80000000) && LastChipInit != NULL) { // Activate special NeoGeoPocket Mode LastChipInit->NgpFlags = 0x80 | 0x00; chip->NgpFlags = 0x80 | 0x01; chip->NgpChip2 = LastChipInit; LastChipInit->NgpChip2 = chip; LastChipInit = NULL; } else { chip->NgpFlags = 0x00; chip->NgpChip2 = NULL; LastChipInit = chip; } } return chip; }
int device_start_sn764xx(UINT8 ChipID, int clock, int shiftregwidth, int noisetaps, int negate, int stereo, int clockdivider, int freq0) { sn764xx_state *info; int rate; if (ChipID >= MAX_CHIPS) return 0; info = &SN764xxData[ChipID]; /* emulator create */ switch(EMU_CORE) { case EC_MAME: rate = sn76496_start(&info->chip, clock, shiftregwidth, noisetaps, negate, stereo, clockdivider, freq0); sn76496_freq_limiter(clock & 0x3FFFFFFF, clockdivider, SampleRate); break; #ifdef ENABLE_ALL_CORES case EC_MAXIM: rate = SampleRate; info->chip = SN76489_Init(clock, rate); if (info->chip == NULL) return 0; SN76489_Config((SN76489_Context*)info->chip, noisetaps, shiftregwidth, 0); break; #endif } return rate; }
int device_start_sn764xx(void **_info, int EMU_CORE, int clock, int SampleRate, int shiftregwidth, int noisetaps, int negate, int stereo, int clockdivider, int freq0) { sn764xx_state *info; int rate; #ifdef ENABLE_ALL_CORES if (EMU_CORE >= 0x02) EMU_CORE = EC_MAME; #else EMU_CORE = EC_MAME; #endif info = (sn764xx_state*) calloc(1, sizeof(sn764xx_state)); *_info = (void *) info; /* emulator create */ info->EMU_CORE = EMU_CORE; switch(EMU_CORE) { case EC_MAME: rate = sn76496_start(&info->chip, clock, shiftregwidth, noisetaps, negate, stereo, clockdivider, freq0); sn76496_freq_limiter(clock & 0x3FFFFFFF, clockdivider, SampleRate); break; #ifdef ENABLE_ALL_CORES case EC_MAXIM: rate = SampleRate; info->chip = SN76489_Init(clock, rate); if (info->chip == NULL) return 0; SN76489_Config((SN76489_Context*)info->chip, noisetaps, shiftregwidth, 0); break; #endif } return rate; }