Updated Game_Music_Emu with changes that don't currently affect playback.
parent
87ea9f3428
commit
f10fa14668
|
@ -28,6 +28,7 @@ Vgm_Core::Vgm_Core()
|
||||||
Vgm_Core::~Vgm_Core()
|
Vgm_Core::~Vgm_Core()
|
||||||
{
|
{
|
||||||
StopVGM(vgmp);
|
StopVGM(vgmp);
|
||||||
|
CloseVGMFile(vgmp);
|
||||||
VGMPlay_Deinit(vgmp);
|
VGMPlay_Deinit(vgmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,6 +165,43 @@ blargg_err_t Vgm_Core::load_mem_( byte const data [], int size )
|
||||||
return blargg_ok;
|
return blargg_ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Vgm_Core::get_channel_count()
|
||||||
|
{
|
||||||
|
// XXX may support more than this, but 32 bit masks and all...
|
||||||
|
unsigned i;
|
||||||
|
UINT32 j;
|
||||||
|
for (i = 0; i < 32; i++)
|
||||||
|
{
|
||||||
|
if (!GetAccurateChipNameByChannel(vgmp, i, &j))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* Vgm_Core::get_voice_name(int channel)
|
||||||
|
{
|
||||||
|
UINT32 realChannel;
|
||||||
|
const char * name = GetAccurateChipNameByChannel(vgmp, channel, &realChannel);
|
||||||
|
size_t length = strlen(name) + 16;
|
||||||
|
char * finalName = (char *) malloc(length);
|
||||||
|
if (finalName)
|
||||||
|
sprintf(finalName, "%s #%u", name, realChannel);
|
||||||
|
return finalName;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Vgm_Core::free_voice_name(char *name)
|
||||||
|
{
|
||||||
|
free(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Vgm_Core::set_mute(int mask)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 32; i++)
|
||||||
|
{
|
||||||
|
SetChannelMute(vgmp, i, (mask >> i) & 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Vgm_Core::start_track()
|
void Vgm_Core::start_track()
|
||||||
{
|
{
|
||||||
PlayVGM(vgmp);
|
PlayVGM(vgmp);
|
||||||
|
|
|
@ -39,6 +39,13 @@ public:
|
||||||
// Skips the specified number of samples
|
// Skips the specified number of samples
|
||||||
void skip_( int count );
|
void skip_( int count );
|
||||||
|
|
||||||
|
int get_channel_count();
|
||||||
|
|
||||||
|
char* get_voice_name(int channel);
|
||||||
|
void free_voice_name(char *);
|
||||||
|
|
||||||
|
void set_mute(int mask);
|
||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
public:
|
public:
|
||||||
Vgm_Core();
|
Vgm_Core();
|
||||||
|
|
|
@ -31,7 +31,21 @@ Vgm_Emu::Vgm_Emu()
|
||||||
set_silence_lookahead( 1 ); // tracks should already be trimmed
|
set_silence_lookahead( 1 ); // tracks should already be trimmed
|
||||||
}
|
}
|
||||||
|
|
||||||
Vgm_Emu::~Vgm_Emu() { }
|
Vgm_Emu::~Vgm_Emu()
|
||||||
|
{
|
||||||
|
// XXX ugly use of deprecated functions to free allocated voice names
|
||||||
|
const char ** voice_names_ = voice_names();
|
||||||
|
if (voice_names_)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 32; ++i)
|
||||||
|
{
|
||||||
|
if (voice_names_[i])
|
||||||
|
core.free_voice_name((char*)voice_names_[i]);
|
||||||
|
else break;
|
||||||
|
}
|
||||||
|
free((void *)voice_names_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Vgm_Emu::unload()
|
void Vgm_Emu::unload()
|
||||||
{
|
{
|
||||||
|
@ -431,6 +445,7 @@ blargg_err_t Vgm_Emu::set_sample_rate_( int sample_rate )
|
||||||
void Vgm_Emu::mute_voices_( int mask )
|
void Vgm_Emu::mute_voices_( int mask )
|
||||||
{
|
{
|
||||||
muted_voices = mask;
|
muted_voices = mask;
|
||||||
|
core.set_mute(mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emulation
|
// Emulation
|
||||||
|
@ -475,6 +490,33 @@ blargg_err_t Vgm_Emu::load_mem_( const byte* in, int file_size )
|
||||||
{
|
{
|
||||||
RETURN_ERR( core.load_mem(in, file_size) );
|
RETURN_ERR( core.load_mem(in, file_size) );
|
||||||
|
|
||||||
|
int voice_count = core.get_channel_count();
|
||||||
|
|
||||||
|
set_voice_count( voice_count );
|
||||||
|
|
||||||
|
char ** voice_names = (char **) calloc( sizeof(char *), voice_count + 1 );
|
||||||
|
if (voice_names)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < voice_count; i++)
|
||||||
|
{
|
||||||
|
voice_names[i] = core.get_voice_name(i);
|
||||||
|
if (!voice_names[i])
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (i == voice_count)
|
||||||
|
set_voice_names(voice_names);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (i = 0; i < voice_count; i++)
|
||||||
|
{
|
||||||
|
if (voice_names[i])
|
||||||
|
free(voice_names[i]);
|
||||||
|
}
|
||||||
|
free(voice_names);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
get_vgm_length( header(), &metadata );
|
get_vgm_length( header(), &metadata );
|
||||||
|
|
||||||
int data_offset = header().lngDataOffset;
|
int data_offset = header().lngDataOffset;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -50,6 +50,10 @@ const char* GetChipName(UINT8 ChipID);
|
||||||
const char* GetAccurateChipName(UINT8 ChipID, UINT8 SubType);
|
const char* GetAccurateChipName(UINT8 ChipID, UINT8 SubType);
|
||||||
UINT32 GetChipClock(void* vgmp, UINT8 ChipID, UINT8* RetSubType);
|
UINT32 GetChipClock(void* vgmp, UINT8 ChipID, UINT8* RetSubType);
|
||||||
|
|
||||||
|
const char* GetAccurateChipNameByChannel(void* vgmp, UINT32 channel, UINT32 *realChannel);
|
||||||
|
|
||||||
|
void SetChannelMute(void* vgmp, UINT32 channel, UINT8 mute);
|
||||||
|
|
||||||
#ifndef NO_WCHAR_FILENAMES
|
#ifndef NO_WCHAR_FILENAMES
|
||||||
UINT32 GetGZFileLengthW(const wchar_t* FileName);
|
UINT32 GetGZFileLengthW(const wchar_t* FileName);
|
||||||
bool OpenVGMFileW(void* vgmp, const wchar_t* FileName);
|
bool OpenVGMFileW(void* vgmp, const wchar_t* FileName);
|
||||||
|
|
|
@ -72,6 +72,8 @@ struct _okim6258_state
|
||||||
|
|
||||||
UINT8 Iternal10Bit;
|
UINT8 Iternal10Bit;
|
||||||
UINT8 DCRemoval;
|
UINT8 DCRemoval;
|
||||||
|
|
||||||
|
UINT8 mute;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* step size index shift table */
|
/* step size index shift table */
|
||||||
|
@ -171,6 +173,7 @@ void okim6258_update(void *param, stream_sample_t **outputs, int samples)
|
||||||
//stream_sample_t *buffer = outputs[0];
|
//stream_sample_t *buffer = outputs[0];
|
||||||
stream_sample_t *bufL = outputs[0];
|
stream_sample_t *bufL = outputs[0];
|
||||||
stream_sample_t *bufR = outputs[1];
|
stream_sample_t *bufR = outputs[1];
|
||||||
|
int mute = chip->mute;
|
||||||
|
|
||||||
//memset(outputs[0], 0, samples * sizeof(*outputs[0]));
|
//memset(outputs[0], 0, samples * sizeof(*outputs[0]));
|
||||||
|
|
||||||
|
@ -231,8 +234,16 @@ void okim6258_update(void *param, stream_sample_t **outputs, int samples)
|
||||||
nibble_shift ^= 4;
|
nibble_shift ^= 4;
|
||||||
|
|
||||||
//*buffer++ = sample;
|
//*buffer++ = sample;
|
||||||
|
if (mute)
|
||||||
|
{
|
||||||
|
*bufL++ = 0;
|
||||||
|
*bufR++ = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
*bufL++ = (chip->pan & 0x02) ? 0x00 : sample;
|
*bufL++ = (chip->pan & 0x02) ? 0x00 : sample;
|
||||||
*bufR++ = (chip->pan & 0x01) ? 0x00 : sample;
|
*bufR++ = (chip->pan & 0x01) ? 0x00 : sample;
|
||||||
|
}
|
||||||
samples--;
|
samples--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,6 +263,12 @@ void okim6258_update(void *param, stream_sample_t **outputs, int samples)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void okim6258_mute(void *ptr, int mute)
|
||||||
|
{
|
||||||
|
okim6258_state *chip = (okim6258_state *)ptr;
|
||||||
|
chip->mute = mute;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************************************
|
/**********************************************************************************************
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,8 @@ void okim6258_set_divider(void *chip, int val);
|
||||||
void okim6258_set_clock(void *chip, int val);
|
void okim6258_set_clock(void *chip, int val);
|
||||||
int okim6258_get_vclk(void *chip);
|
int okim6258_get_vclk(void *chip);
|
||||||
|
|
||||||
|
void okim6258_mute(void *chip, int mute);
|
||||||
|
|
||||||
//READ8_DEVICE_HANDLER( okim6258_status_r );
|
//READ8_DEVICE_HANDLER( okim6258_status_r );
|
||||||
//WRITE8_DEVICE_HANDLER( okim6258_data_w );
|
//WRITE8_DEVICE_HANDLER( okim6258_data_w );
|
||||||
//WRITE8_DEVICE_HANDLER( okim6258_ctrl_w );
|
//WRITE8_DEVICE_HANDLER( okim6258_ctrl_w );
|
||||||
|
|
|
@ -87,6 +87,8 @@ typedef struct _pwm_chip
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int clock;
|
int clock;
|
||||||
|
|
||||||
|
unsigned char Mute;
|
||||||
} pwm_chip;
|
} pwm_chip;
|
||||||
#if CHILLY_WILLY_SCALE
|
#if CHILLY_WILLY_SCALE
|
||||||
// TODO: Fix Chilly Willy's new scaling algorithm.
|
// TODO: Fix Chilly Willy's new scaling algorithm.
|
||||||
|
@ -327,6 +329,9 @@ void PWM_Update(pwm_chip* chip, int **buf, int length)
|
||||||
tmpOutL = PWM_Update_Scale(chip, (int)chip->PWM_Out_L);
|
tmpOutL = PWM_Update_Scale(chip, (int)chip->PWM_Out_L);
|
||||||
tmpOutR = PWM_Update_Scale(chip, (int)chip->PWM_Out_R);
|
tmpOutR = PWM_Update_Scale(chip, (int)chip->PWM_Out_R);
|
||||||
|
|
||||||
|
tmpOutL = chip->Mute ? 0 : tmpOutL;
|
||||||
|
tmpOutR = chip->Mute ? 0 : tmpOutR;
|
||||||
|
|
||||||
for (i = 0; i < length; i ++)
|
for (i = 0; i < length; i ++)
|
||||||
{
|
{
|
||||||
buf[0][i] = tmpOutL;
|
buf[0][i] = tmpOutL;
|
||||||
|
@ -342,6 +347,12 @@ void pwm_update(void *_info, stream_sample_t **outputs, int samples)
|
||||||
PWM_Update(chip, outputs, samples);
|
PWM_Update(chip, outputs, samples);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pwm_mute(void *_info, UINT8 Mute)
|
||||||
|
{
|
||||||
|
pwm_chip *chip = (pwm_chip *)_info;
|
||||||
|
chip->Mute = Mute;
|
||||||
|
}
|
||||||
|
|
||||||
int device_start_pwm(void **_info, int clock, int CHIP_SAMPLING_MODE, int CHIP_SAMPLE_RATE)
|
int device_start_pwm(void **_info, int clock, int CHIP_SAMPLING_MODE, int CHIP_SAMPLE_RATE)
|
||||||
{
|
{
|
||||||
/* allocate memory for the chip */
|
/* allocate memory for the chip */
|
||||||
|
|
|
@ -58,4 +58,6 @@ int device_start_pwm(void **chip, int clock, int CHIP_SAMPLING_MODE, int CHIP_SA
|
||||||
void device_stop_pwm(void *chip);
|
void device_stop_pwm(void *chip);
|
||||||
void device_reset_pwm(void *chip);
|
void device_reset_pwm(void *chip);
|
||||||
|
|
||||||
|
void pwm_mute(void *chip, UINT8 Mute);
|
||||||
|
|
||||||
void pwm_chn_w(void *chip, UINT8 Channel, UINT16 data);
|
void pwm_chn_w(void *chip, UINT8 Channel, UINT16 data);
|
||||||
|
|
|
@ -204,6 +204,8 @@ struct _upd7759_state
|
||||||
UINT8 data_buf[0x40];
|
UINT8 data_buf[0x40];
|
||||||
UINT8 dbuf_pos_read;
|
UINT8 dbuf_pos_read;
|
||||||
UINT8 dbuf_pos_write;
|
UINT8 dbuf_pos_write;
|
||||||
|
|
||||||
|
UINT8 mute;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -511,14 +513,23 @@ void upd7759_update(void *param, stream_sample_t **outputs, int samples)
|
||||||
UINT32 pos = chip->pos;
|
UINT32 pos = chip->pos;
|
||||||
stream_sample_t *buffer = outputs[0];
|
stream_sample_t *buffer = outputs[0];
|
||||||
stream_sample_t *buffer2 = outputs[1];
|
stream_sample_t *buffer2 = outputs[1];
|
||||||
|
int mute = chip->mute;
|
||||||
|
|
||||||
/* loop until done */
|
/* loop until done */
|
||||||
if (chip->state != STATE_IDLE)
|
if (chip->state != STATE_IDLE)
|
||||||
while (samples != 0)
|
while (samples != 0)
|
||||||
{
|
{
|
||||||
/* store the current sample */
|
/* store the current sample */
|
||||||
|
if (mute)
|
||||||
|
{
|
||||||
|
*buffer++ = 0;
|
||||||
|
*buffer2++ = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
*buffer++ = sample << 7;
|
*buffer++ = sample << 7;
|
||||||
*buffer2++ = sample << 7;
|
*buffer2++ = sample << 7;
|
||||||
|
}
|
||||||
samples--;
|
samples--;
|
||||||
|
|
||||||
/* advance by the number of clocks/output sample */
|
/* advance by the number of clocks/output sample */
|
||||||
|
@ -586,6 +597,11 @@ void upd7759_update(void *param, stream_sample_t **outputs, int samples)
|
||||||
chip->pos = pos;
|
chip->pos = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void upd7759_mute(void *ptr, int mute)
|
||||||
|
{
|
||||||
|
upd7759_state *chip = (upd7759_state *)ptr;
|
||||||
|
chip->mute = mute;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************************************************
|
/************************************************************
|
||||||
|
|
|
@ -21,6 +21,8 @@ void device_reset_upd7759(void *chip);
|
||||||
int device_start_upd7759(void **chip, int clock);
|
int device_start_upd7759(void **chip, int clock);
|
||||||
void device_stop_upd7759(void *chip);
|
void device_stop_upd7759(void *chip);
|
||||||
|
|
||||||
|
void upd7759_mute(void *chip, int mute);
|
||||||
|
|
||||||
//void upd7759_set_bank_base(running_device *device, offs_t base);
|
//void upd7759_set_bank_base(running_device *device, offs_t base);
|
||||||
|
|
||||||
//void upd7759_reset_w(running_device *device, UINT8 data);
|
//void upd7759_reset_w(running_device *device, UINT8 data);
|
||||||
|
|
Loading…
Reference in New Issue