Use 32040hz sample rate in libretro to avoid resampling.

This commit is contained in:
Brandon Wright 2016-12-10 10:52:05 -06:00
parent cf846e0c56
commit bbeb13c2f0
1 changed files with 28 additions and 28 deletions

View File

@ -76,7 +76,7 @@ static bool rom_loaded = false;
void retro_set_environment(retro_environment_t cb)
{
environ_cb = cb;
const struct retro_variable variables[] = {
// These variable names and possible values constitute an ABI with ZMZ (ZSNES Libretro player).
// Changing "Show layer 1" is fine, but don't change "layer_1"/etc or the possible values ("Yes|No").
@ -98,7 +98,7 @@ void retro_set_environment(retro_environment_t cb)
{ "snes9x_sndchan_8", "Enable sound channel 8; Yes|No" },
{ NULL, NULL },
};
environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, (void *)variables);
const struct retro_controller_description port_1[] = {
@ -128,9 +128,9 @@ static void update_variables(void)
{
char key[256];
struct retro_variable var;
var.key=key;
int disabled_channels=0;
strcpy(key, "snes9x_sndchan_x");
for (int i=0;i<8;i++)
@ -140,7 +140,7 @@ static void update_variables(void)
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value && var.value[0]=='N') disabled_channels|=1<<i;
}
S9xSetSoundControl(disabled_channels^0xFF);
int disabled_layers=0;
strcpy(key, "snes9x_layer_x");
for (int i=0;i<5;i++)
@ -150,7 +150,7 @@ static void update_variables(void)
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value && var.value[0]=='N') disabled_layers|=1<<i;
}
Settings.BG_Forced=disabled_layers;
//for some reason, Transparency seems to control both the fixed color and the windowing registers?
var.key="snes9x_gfx_clip";
var.value=NULL;
@ -192,7 +192,7 @@ void retro_get_system_av_info(struct retro_system_av_info *info)
info->geometry.max_width = MAX_SNES_WIDTH;
info->geometry.max_height = MAX_SNES_HEIGHT;
info->geometry.aspect_ratio = 4.0f / 3.0f;
info->timing.sample_rate = 32040.5;
info->timing.sample_rate = 32040;
info->timing.fps = retro_get_region() == RETRO_REGION_NTSC ? 21477272.0 / 357366.0 : 21281370.0 / 425568.0;
}
@ -256,10 +256,10 @@ void retro_cheat_set(unsigned index, bool enabled, const char *code)
{
uint32 address;
uint8 val;
bool8 sram;
uint8 bytes[3];//used only by GoldFinger, ignored for now
if (S9xGameGenieToRaw(code, address, val)!=NULL &&
S9xProActionReplayToRaw(code, address, val)!=NULL &&
S9xGoldFingerToRaw(code, address, sram, val, bytes)!=NULL)
@ -268,13 +268,13 @@ void retro_cheat_set(unsigned index, bool enabled, const char *code)
}
if (index>Cheat.num_cheats) return; // cheat added in weird order, ignore
if (index==Cheat.num_cheats) Cheat.num_cheats++;
Cheat.c[index].address = address;
Cheat.c[index].byte = val;
Cheat.c[index].enabled = enabled;
Cheat.c[index].saved = FALSE; // it'll be saved next time cheats run anyways
Settings.ApplyCheats=true;
S9xApplyCheats();
}
@ -374,7 +374,7 @@ bool retro_load_game(const struct retro_game_info *game)
if (!rom_loaded && log_cb)
log_cb(RETRO_LOG_ERROR, "[libretro]: Rom loading failed...\n");
return rom_loaded;
}
@ -387,7 +387,7 @@ bool retro_load_game_special(unsigned game_type,
init_descriptors();
switch (game_type) {
case RETRO_GAME_TYPE_BSX:
if(num_info == 1) {
rom_loaded = Memory.LoadROMMem((const uint8_t*)info[0].data,info[0].size);
} else if(num_info == 2) {
@ -399,7 +399,7 @@ bool retro_load_game_special(unsigned game_type,
log_cb(RETRO_LOG_ERROR, "[libretro]: BSX ROM loading failed...\n");
break;
case RETRO_GAME_TYPE_BSX_SLOTTED:
if(num_info == 2)
@ -462,8 +462,8 @@ void retro_init()
Settings.FrameTimeNTSC = 16667;
Settings.SixteenBitSound = TRUE;
Settings.Stereo = TRUE;
Settings.SoundPlaybackRate = 32000;
Settings.SoundInputRate = 32000;
Settings.SoundPlaybackRate = 32040;
Settings.SoundInputRate = 32040;
Settings.SupportHiRes = TRUE;
Settings.Transparency = TRUE;
Settings.AutoDisplayMessages = TRUE;
@ -633,7 +633,7 @@ static void map_buttons()
}
// libretro uses relative values for analogue devices.
// libretro uses relative values for analogue devices.
// S9x seems to use absolute values, but do convert these into relative values in the core. (Why?!)
// Hack around it. :)
static int16_t snes_mouse_state[2][2] = {{0}, {0}};
@ -692,7 +692,7 @@ static void report_buttons()
for (int i = JUSTIFIER_TRIGGER; i <= JUSTIFIER_LAST; i++)
S9xReportButton(MAKE_BUTTON(2, i), input_state_cb(port, RETRO_DEVICE_LIGHTGUN, 0, i));
break;
default:
if (log_cb)
log_cb(RETRO_LOG_ERROR, "[libretro]: Unknown device...\n");
@ -718,14 +718,14 @@ void retro_deinit()
Memory.Deinit();
S9xGraphicsDeinit();
S9xUnmapAllControls();
free(GFX.Screen);
}
unsigned retro_get_region()
{
return Settings.PAL ? RETRO_REGION_PAL : RETRO_REGION_NTSC;
{
return Settings.PAL ? RETRO_REGION_PAL : RETRO_REGION_NTSC;
}
void* retro_get_memory_data(unsigned type)
@ -794,7 +794,7 @@ size_t retro_serialize_size()
}
bool retro_serialize(void *data, size_t size)
{
{
if (S9xFreezeGameMem((uint8_t*)data,size) == FALSE)
return false;
@ -802,7 +802,7 @@ bool retro_serialize(void *data, size_t size)
}
bool retro_unserialize(const void* data, size_t size)
{
{
if (S9xUnfreezeGameMem((const uint8_t*)data,size) != SUCCESS)
return false;
return true;
@ -870,8 +870,8 @@ void S9xExit() {}
bool S9xPollPointer(unsigned int, short*, short*) { return false; }
const char *S9xChooseMovieFilename(unsigned char) { return NULL; }
bool8 S9xOpenSnapshotFile(const char* filepath, bool8 read_only, STREAM *file)
{
bool8 S9xOpenSnapshotFile(const char* filepath, bool8 read_only, STREAM *file)
{
if(read_only)
{
if((*file = OPEN_STREAM(filepath, "rb")) != 0)
@ -889,12 +889,12 @@ bool8 S9xOpenSnapshotFile(const char* filepath, bool8 read_only, STREAM *file)
return (FALSE);
}
void S9xCloseSnapshotFile(STREAM file)
void S9xCloseSnapshotFile(STREAM file)
{
CLOSE_STREAM(file);
}
void S9xAutoSaveSRAM()
void S9xAutoSaveSRAM()
{
return;
}