Skip to content

Commit

Permalink
(libretro) Fixing some ngcd sound issues (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
barbudreadmon committed Feb 9, 2019
1 parent 06faa6e commit df22096
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 30 deletions.
4 changes: 4 additions & 0 deletions makefile.libretro
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,10 @@ endif
%.o: %.c
$(CC) -c $(OBJOUT)$@ $< $(CFLAGS) $(INCFLAGS)

# Disabling file_stream_transform for this file, it's messing up cdda playback
src/burner/libretro/retro_cdemu.o: src/burner/libretro/retro_cdemu.cpp
$(CXX) -c $(OBJOUT)$@ $< $(CXXFLAGS) $(INCFLAGS) -DSKIP_STDIO_REDEFINES

%.o: %.cpp
$(CXX) -c $(OBJOUT)$@ $< $(CXXFLAGS) $(INCFLAGS)

Expand Down
14 changes: 1 addition & 13 deletions src/burner/libretro/libretro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ INT32 (__cdecl *bprintf) (INT32 nStatus, TCHAR* szFormat, ...) = libretro_bprint

int kNetGame = 0;
INT32 nReplayStatus = 0;
static unsigned nGameType = 0;
unsigned nGameType = 0;

static unsigned int BurnDrvGetIndexByName(const char* name);
char* DecorateGameName(UINT32 nBurnDrv);
Expand Down Expand Up @@ -104,18 +104,6 @@ void retro_set_video_refresh(retro_video_refresh_t cb) { video_cb = cb; }
void retro_set_audio_sample(retro_audio_sample_t) {}
void retro_set_audio_sample_batch(retro_audio_sample_batch_t cb) { audio_batch_cb = cb; }

#define RETRO_GAME_TYPE_CV 1
#define RETRO_GAME_TYPE_GG 2
#define RETRO_GAME_TYPE_MD 3
#define RETRO_GAME_TYPE_MSX 4
#define RETRO_GAME_TYPE_PCE 5
#define RETRO_GAME_TYPE_SG1K 6
#define RETRO_GAME_TYPE_SGX 7
#define RETRO_GAME_TYPE_SMS 8
#define RETRO_GAME_TYPE_TG 9
#define RETRO_GAME_TYPE_SPEC 10
#define RETRO_GAME_TYPE_NEOCD 11

void retro_set_environment(retro_environment_t cb)
{
environ_cb = cb;
Expand Down
2 changes: 1 addition & 1 deletion src/burner/libretro/retro_cdemu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ static int cdimgParseCueFile()
}

while (1) {
if (_fgetts(szLine, sizeof(szLine), h) == NULL) {
if (fgets(szLine, sizeof(szLine), h) == NULL) {
break;
}

Expand Down
35 changes: 22 additions & 13 deletions src/burner/libretro/retro_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ void set_environment()
vars_systems.push_back(&var_fba_frameskip);
vars_systems.push_back(&var_fba_cpu_speed_adjust);
vars_systems.push_back(&var_fba_hiscores);
vars_systems.push_back(&var_fba_samplerate);
if (nGameType != RETRO_GAME_TYPE_NEOCD)
vars_systems.push_back(&var_fba_samplerate);
vars_systems.push_back(&var_fba_sample_interpolation);
vars_systems.push_back(&var_fba_fm_interpolation);
vars_systems.push_back(&var_fba_analog_speed);
Expand Down Expand Up @@ -478,19 +479,27 @@ void check_variables(void)
EnableHiscores = false;
}

var.key = var_fba_samplerate.key;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var))
if (nGameType != RETRO_GAME_TYPE_NEOCD)
{
if (strcmp(var.value, "48000") == 0)
g_audio_samplerate = 48000;
else if (strcmp(var.value, "44100") == 0)
g_audio_samplerate = 44100;
else if (strcmp(var.value, "22050") == 0)
g_audio_samplerate = 22050;
else if (strcmp(var.value, "11025") == 0)
g_audio_samplerate = 11025;
else
g_audio_samplerate = 48000;
var.key = var_fba_samplerate.key;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var))
{
if (strcmp(var.value, "48000") == 0)
g_audio_samplerate = 48000;
else if (strcmp(var.value, "44100") == 0)
g_audio_samplerate = 44100;
else if (strcmp(var.value, "22050") == 0)
g_audio_samplerate = 22050;
else if (strcmp(var.value, "11025") == 0)
g_audio_samplerate = 11025;
else
g_audio_samplerate = 48000;
}
}
else
{
// src/burn/drv/neogeo/neo_run.cpp is mentioning issues with ngcd cdda playback if samplerate isn't 44100
g_audio_samplerate = 44100;
}

var.key = var_fba_sample_interpolation.key;
Expand Down
13 changes: 13 additions & 0 deletions src/burner/libretro/retro_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@
#include <vector>
#include "burner.h"

#define RETRO_GAME_TYPE_CV 1
#define RETRO_GAME_TYPE_GG 2
#define RETRO_GAME_TYPE_MD 3
#define RETRO_GAME_TYPE_MSX 4
#define RETRO_GAME_TYPE_PCE 5
#define RETRO_GAME_TYPE_SG1K 6
#define RETRO_GAME_TYPE_SGX 7
#define RETRO_GAME_TYPE_SMS 8
#define RETRO_GAME_TYPE_TG 9
#define RETRO_GAME_TYPE_SPEC 10
#define RETRO_GAME_TYPE_NEOCD 11

struct macro_core_option_value
{
unsigned retro_device_id;
Expand Down Expand Up @@ -80,6 +92,7 @@ extern UINT8 NeoSystem;
extern INT32 g_audio_samplerate;
extern UINT8 *diag_input;
extern neo_geo_modes g_opt_neo_geo_mode;
extern unsigned nGameType;

char* str_char_replace(char* destination, char c_find, char c_replace);
void set_neo_system_bios();
Expand Down
6 changes: 3 additions & 3 deletions src/burner/libretro/tchar.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#endif

#define _T(x) x
#define _tfopen rfopen
#define _tfopen fopen
#define _tcstol strtol
#define _tcsstr strstr
#define _istspace(x) isspace(x)
Expand All @@ -34,8 +34,8 @@
#define _tcsncpy strncpy
#define _stscanf sscanf
#define _ftprintf fprintf
#define fseeko rfseek
#define ftello rftell
#define fseeko fseek
#define ftello ftell

#ifdef UNICODE //Is there any point in this? Can we not just typedef TCHAR to CHAR?
typedef wchar_t TCHAR;
Expand Down

0 comments on commit df22096

Please sign in to comment.