apps,fceux: add config.h for configuration of frameskip and sound

This commit is contained in:
Zihao Yu 2020-04-24 19:47:44 +08:00
parent 2c17242576
commit a149aba788
5 changed files with 42 additions and 8 deletions

View File

@ -12,6 +12,7 @@ INCLUDES += $(addprefix -I, $(INC_DIR)) -I$(AM_HOME)/am/
INCLUDES += -I$(AM_HOME)/am/include
CFLAGS += -O2 -MMD -Wall -Werror -ggdb $(INCLUDES) \
-D__ISA__=\"$(ISA)\" -D__ISA_$(shell echo $(ISA) | tr a-z A-Z)__ \
-D__PLATFORM__=\"$(PLATFORM)\" -D__PLATFORM_$(shell echo $(PLATFORM) | tr a-z A-Z)__ \
-D__ARCH__=$(ARCH) -D__ARCH_$(shell echo $(ARCH) | tr a-z A-Z | tr - _) \
-DARCH_H=\"arch/$(ARCH).h\" \
-fno-asynchronous-unwind-tables -fno-builtin -fno-stack-protector \

19
apps/fceux/src/config.h Normal file
View File

@ -0,0 +1,19 @@
#ifndef __CONFIG_H__
#define __CONFIG_H__
#define SOUND_NONE 0
#define SOUND_LQ 1
#define SOUND_HQ 2
#if defined(__PLATFORM_NEMU__)
# define NR_FRAMESKIP 1
# define SOUND_CONFIG SOUND_LQ
#elif defined(__PLATFORM_NOOP__)
# define NR_FRAMESKIP 2
# define SOUND_CONFIG SOUND_NONE
#else
# define NR_FRAMESKIP 0
# define SOUND_CONFIG SOUND_HQ
#endif
#endif

View File

@ -23,6 +23,7 @@
#include "sdl.h"
#include <amdev.h>
#include "../../config.h"
// unit: 16-bit
static unsigned int s_BufferSize;
@ -33,7 +34,17 @@ static unsigned int s_BufferSize;
int
InitSound()
{
#if SOUND_CONFIG == SOUND_NONE
return 1;
#endif
#if SOUND_CONFIG == SOUND_HQ
const int soundrate = 44100;
const int soundq = 1;
#else
const int soundrate = 11025;
const int soundq = 0;
#endif
const int soundbufsize = 128;
const int soundvolume = 150;
const int soundtrianglevolume = 256;
@ -41,10 +52,9 @@ InitSound()
const int soundsquare2volume = 256;
const int soundnoisevolume = 256;
const int soundpcmvolume = 256;
const int soundq = 1;
_DEV_AUDIO_INIT_t init;
init.freq = 44100;
init.freq = soundrate;
init.channels = 1;
init.samples = 512;
init.bufsize = soundbufsize * soundrate / 1000;

View File

@ -11,12 +11,7 @@
#include "sdl-video.h"
#include "../../types.h"
#ifdef __ISA_NATIVE__
#define NR_FRAMESKIP 0
#else
#define NR_FRAMESKIP 2
#endif
#include "../../config.h"
int isloaded;

View File

@ -25,6 +25,7 @@
#include "sound.h"
#include "filter.h"
#include "state.h"
#include "config.h"
//#include "wave.h"
//#include "debug.h"
@ -516,6 +517,10 @@ static INLINE void DMCDMA(void)
void FCEU_SoundCPUHook(int cycles)
{
#if SOUND_CONFIG != SOUND_HQ
return;
#endif
fhcnt-=cycles*48;
if(fhcnt<=0)
{
@ -1007,6 +1012,10 @@ void SetNESSoundMap(void)
static int32 inbuf=0;
int FlushEmulateSound(void)
{
#if SOUND_CONFIG == SOUND_NONE
return 0;
#endif
int x;
int32 end,left;